@quoll/client-lib
Advanced tools
Comparing version 0.4.3 to 0.4.4
@@ -6,2 +6,6 @@ # Change Log | ||
## [0.4.4](https://github.com/mzogheib/quoll/compare/@quoll/client-lib@0.4.3...@quoll/client-lib@0.4.4) (2024-02-25) | ||
**Note:** Version bump only for package @quoll/client-lib | ||
## [0.4.3](https://github.com/mzogheib/quoll/compare/@quoll/client-lib@0.4.2...@quoll/client-lib@0.4.3) (2024-02-24) | ||
@@ -8,0 +12,0 @@ |
@@ -0,3 +1,4 @@ | ||
export * from "./storage"; | ||
export * from "./store"; | ||
export * from "./modules"; | ||
export * from "./utils"; |
@@ -17,4 +17,5 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
__exportStar(require("./storage"), exports); | ||
__exportStar(require("./store"), exports); | ||
__exportStar(require("./modules"), exports); | ||
__exportStar(require("./utils"), exports); |
export * from "./date"; | ||
export * from "./feeds"; | ||
export * from "./timeline"; | ||
export * from "./user"; |
@@ -18,2 +18,4 @@ "use strict"; | ||
__exportStar(require("./date"), exports); | ||
__exportStar(require("./feeds"), exports); | ||
__exportStar(require("./timeline"), exports); | ||
__exportStar(require("./user"), exports); |
import { ISO8601Date, TimelineEntry } from "@quoll/lib"; | ||
export type TimelineService = { | ||
get: (date: ISO8601Date) => Promise<TimelineEntry[]>; | ||
}; | ||
import { AuthenticatedApiService } from "../../../utils"; | ||
export declare const getTimelineEntryImage: (entry: TimelineEntry) => string; | ||
export declare class TimelineService extends AuthenticatedApiService { | ||
get(date: ISO8601Date): Promise<TimelineEntry[]>; | ||
} |
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.TimelineService = exports.getTimelineEntryImage = void 0; | ||
const lib_1 = require("@quoll/lib"); | ||
const utils_1 = require("../../../utils"); | ||
const EntryConfigMap = { | ||
bike: { label: "Bike", image: "🚲" }, | ||
bus: { label: "Bus", image: "🚌" }, | ||
car: { label: "Car", image: "🚗" }, | ||
"e-bike": { label: "E-Bike", image: "🚲⚡️" }, | ||
expense: { label: "Expense", image: "💸" }, | ||
ferry: { label: "Ferry", image: "🛳️" }, | ||
flight: { label: "Flight", image: "✈️" }, | ||
hike: { label: "Hike", image: "🥾" }, | ||
home: { label: "Home", image: "🏠" }, | ||
income: { label: "Income", image: "💰" }, | ||
motorcycle: { label: "Motorcycle", image: "🏍️" }, | ||
photo: { label: "Photo", image: "📸" }, | ||
place: { label: "Place", image: "🏬" }, | ||
run: { label: "Run", image: "🏃♂️" }, | ||
train: { label: "Train", image: "🚆" }, | ||
tram: { label: "Tram", image: "🚊" }, | ||
transport: { label: "Transport", image: "⏩" }, | ||
unknown: { label: "Unknown", image: "🤷" }, | ||
velomobile: { label: "Velomobile", image: "🚲🛡️" }, | ||
video: { label: "Video", image: "🎥" }, | ||
walk: { label: "Walk", image: "🚶♂️" }, | ||
work: { label: "Work", image: "🏭" }, | ||
yoga: { label: "Yoga", image: "🧘♂️" }, | ||
}; | ||
// TODO should this be somewhere else? | ||
const getTimelineEntryImage = (entry) => EntryConfigMap[entry.type] ? EntryConfigMap[entry.type].image : "🤠"; | ||
exports.getTimelineEntryImage = getTimelineEntryImage; | ||
// TODO | ||
// Has an array of sources to fetch from | ||
// Consumer can push to the array | ||
class TimelineService extends utils_1.AuthenticatedApiService { | ||
get(date) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const _date = new Date(date); | ||
return this.request({ | ||
method: "GET", | ||
endpoint: "/timeline", | ||
params: { | ||
from: (0, lib_1.getStartOfDay)(_date).toISOString(), | ||
to: (0, lib_1.getEndOfDay)(_date).toISOString(), | ||
}, | ||
}); | ||
}); | ||
} | ||
} | ||
exports.TimelineService = TimelineService; |
@@ -7,5 +7,4 @@ type RequestParams = { | ||
}; | ||
export declare class ApiService { | ||
export declare abstract class ApiService { | ||
private baseUrl; | ||
private authHeader?; | ||
constructor(baseUrl: string); | ||
@@ -23,5 +22,4 @@ private makeUrl; | ||
*/ | ||
request<Response>({ method, endpoint, params, payload, }: RequestParams): Promise<Response>; | ||
authenticate(userId: string): void; | ||
protected request<Response>({ method, endpoint, params, payload, }: RequestParams): Promise<Response>; | ||
} | ||
export {}; |
@@ -41,3 +41,5 @@ "use strict"; | ||
body: JSON.stringify(payload), | ||
headers: Object.assign({ "Content-Type": "application/json" }, this.authHeader), | ||
headers: { | ||
"Content-Type": "application/json", | ||
}, | ||
}; | ||
@@ -62,6 +64,3 @@ const response = yield fetch(url, init); | ||
} | ||
authenticate(userId) { | ||
this.authHeader = { Authorization: `Basic ${userId}:` }; | ||
} | ||
} | ||
exports.ApiService = ApiService; |
export * from "./api"; | ||
export * from "./authenticated-api"; |
@@ -18,1 +18,2 @@ "use strict"; | ||
__exportStar(require("./api"), exports); | ||
__exportStar(require("./authenticated-api"), exports); |
{ | ||
"name": "@quoll/client-lib", | ||
"version": "0.4.3", | ||
"version": "0.4.4", | ||
"description": "Shared code for client side packages", | ||
@@ -18,3 +18,3 @@ "repository": "https://github.com/mzogheib/quoll", | ||
"dependencies": { | ||
"@quoll/lib": "^0.3.0", | ||
"@quoll/lib": "^0.4.0", | ||
"react-redux": "^7.2.1", | ||
@@ -32,3 +32,3 @@ "redux": "^4.0.5" | ||
}, | ||
"gitHead": "9edadc8a9bcd8eda94058b935cf5feda11536b5f" | ||
"gitHead": "34779fc17f3d001f93a24e821a243fb6273836d7" | ||
} |
@@ -0,3 +1,4 @@ | ||
export * from "./storage"; | ||
export * from "./store"; | ||
export * from "./modules"; | ||
export * from "./utils"; |
export * from "./date"; | ||
export * from "./feeds"; | ||
export * from "./timeline"; | ||
export * from "./user"; |
@@ -1,5 +0,62 @@ | ||
import { ISO8601Date, TimelineEntry } from "@quoll/lib"; | ||
import { | ||
ISO8601Date, | ||
TimelineEntry, | ||
TimelineEntryType, | ||
getEndOfDay, | ||
getStartOfDay, | ||
} from "@quoll/lib"; | ||
export type TimelineService = { | ||
get: (date: ISO8601Date) => Promise<TimelineEntry[]>; | ||
import { AuthenticatedApiService } from "../../../utils"; | ||
type EntryConfig = { | ||
label: string; | ||
image: string; | ||
}; | ||
const EntryConfigMap: Record<TimelineEntryType, EntryConfig> = { | ||
bike: { label: "Bike", image: "🚲" }, | ||
bus: { label: "Bus", image: "🚌" }, | ||
car: { label: "Car", image: "🚗" }, | ||
"e-bike": { label: "E-Bike", image: "🚲⚡️" }, | ||
expense: { label: "Expense", image: "💸" }, | ||
ferry: { label: "Ferry", image: "🛳️" }, | ||
flight: { label: "Flight", image: "✈️" }, | ||
hike: { label: "Hike", image: "🥾" }, | ||
home: { label: "Home", image: "🏠" }, | ||
income: { label: "Income", image: "💰" }, | ||
motorcycle: { label: "Motorcycle", image: "🏍️" }, | ||
photo: { label: "Photo", image: "📸" }, | ||
place: { label: "Place", image: "🏬" }, | ||
run: { label: "Run", image: "🏃♂️" }, | ||
train: { label: "Train", image: "🚆" }, | ||
tram: { label: "Tram", image: "🚊" }, | ||
transport: { label: "Transport", image: "⏩" }, | ||
unknown: { label: "Unknown", image: "🤷" }, | ||
velomobile: { label: "Velomobile", image: "🚲🛡️" }, | ||
video: { label: "Video", image: "🎥" }, | ||
walk: { label: "Walk", image: "🚶♂️" }, | ||
work: { label: "Work", image: "🏭" }, | ||
yoga: { label: "Yoga", image: "🧘♂️" }, | ||
}; | ||
// TODO should this be somewhere else? | ||
export const getTimelineEntryImage = (entry: TimelineEntry) => | ||
EntryConfigMap[entry.type] ? EntryConfigMap[entry.type].image : "🤠"; | ||
// TODO | ||
// Has an array of sources to fetch from | ||
// Consumer can push to the array | ||
export class TimelineService extends AuthenticatedApiService { | ||
async get(date: ISO8601Date) { | ||
const _date = new Date(date); | ||
return this.request<TimelineEntry[]>({ | ||
method: "GET", | ||
endpoint: "/timeline", | ||
params: { | ||
from: getStartOfDay(_date).toISOString(), | ||
to: getEndOfDay(_date).toISOString(), | ||
}, | ||
}); | ||
} | ||
} |
@@ -8,5 +8,4 @@ type RequestParams = { | ||
export class ApiService { | ||
export abstract class ApiService { | ||
private baseUrl: string; | ||
private authHeader?: { Authorization: string }; | ||
@@ -38,3 +37,3 @@ constructor(baseUrl: string) { | ||
*/ | ||
async request<Response>({ | ||
protected async request<Response>({ | ||
method, | ||
@@ -51,3 +50,2 @@ endpoint, | ||
"Content-Type": "application/json", | ||
...this.authHeader, | ||
}, | ||
@@ -77,6 +75,2 @@ }; | ||
} | ||
authenticate(userId: string): void { | ||
this.authHeader = { Authorization: `Basic ${userId}:` }; | ||
} | ||
} |
export * from "./api"; | ||
export * from "./authenticated-api"; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
59553
70
1526
2
+ Added@quoll/lib@0.4.9(transitive)
- Removed@quoll/lib@0.3.0(transitive)
Updated@quoll/lib@^0.4.0