@crombolo/delivery-client 0.39.1 → 0.41.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +18 -2
- package/dist/index.js +2 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -213,8 +213,14 @@ export interface ApiImageCropper {
|
|
|
213
213
|
export interface DeliverySchema {
|
|
214
214
|
content: object;
|
|
215
215
|
media: object;
|
|
216
|
+
/** The aliases of the site's settings types (story 058), when it has any. */
|
|
217
|
+
settings?: string;
|
|
216
218
|
}
|
|
217
219
|
type Aliases<Map> = Extract<keyof Map, string>;
|
|
220
|
+
/** The site's settings page: of its settings type when the schema names one, else any page. */
|
|
221
|
+
export type SettingsItem<Schema extends DeliverySchema = DeliverySchema> = Schema extends {
|
|
222
|
+
settings: infer Alias extends Aliases<Schema['content']>;
|
|
223
|
+
} ? ApiContentResponse<Alias, Schema['content'][Alias]> : ContentItem<Schema>;
|
|
218
224
|
/** Any page the site serves, told apart by `contentType`. */
|
|
219
225
|
export type ContentItem<Schema extends DeliverySchema = DeliverySchema> = DeliverySchema extends Schema ? ApiContentResponse : {
|
|
220
226
|
[Alias in Aliases<Schema['content']>]: ApiContentResponse<Alias, Schema['content'][Alias]>;
|
|
@@ -435,13 +441,23 @@ export interface DeliveryClient<Schema extends DeliverySchema = DeliverySchema>
|
|
|
435
441
|
media<Options extends MediaQuery>(query: Options): Promise<Paged<Fielded<MediaItem<Schema>, Options>>>;
|
|
436
442
|
/** Published pages matching every word of the term, best first. */
|
|
437
443
|
search(term: string, options?: SearchOptions): Promise<Paged<SearchHit<Schema>>>;
|
|
444
|
+
/** A menu by its alias, in the culture asked for; undefined when there is none. */
|
|
445
|
+
menu(alias: string, options?: Pick<RequestOptions, 'culture' | 'signal'>): Promise<ApiMenu | undefined>;
|
|
446
|
+
/**
|
|
447
|
+
* Every dictionary item in the culture asked for, as key to text, each falling
|
|
448
|
+
* back as a template's `dictionary()` does; `keys` narrows it (story 058).
|
|
449
|
+
*/
|
|
450
|
+
dictionary(keys?: readonly string[], options?: Pick<RequestOptions, 'culture' | 'signal'>): Promise<Record<string, string>>;
|
|
451
|
+
/**
|
|
452
|
+
* The site's settings page, under `startItem`'s root or the first; undefined
|
|
453
|
+
* when it has none (story 058).
|
|
454
|
+
*/
|
|
455
|
+
settings<Options extends Omit<RequestOptions, 'seo'>>(options?: Options): Promise<Fielded<SettingsItem<Schema>, Options> | undefined>;
|
|
438
456
|
/**
|
|
439
457
|
* What the site would answer at a visitor's address — the page, a redirect, or
|
|
440
458
|
* not found — for an app's router. `host` picks the root and culture as the
|
|
441
459
|
* site's domains do.
|
|
442
460
|
*/
|
|
443
|
-
/** A menu by its alias, in the culture asked for; undefined when there is none. */
|
|
444
|
-
menu(alias: string, options?: Pick<RequestOptions, 'culture' | 'signal'>): Promise<ApiMenu | undefined>;
|
|
445
461
|
route(path: string, options?: Omit<RequestOptions, 'culture' | 'fields'> & {
|
|
446
462
|
host?: string;
|
|
447
463
|
}): Promise<RouteAnswer<Schema>>;
|
package/dist/index.js
CHANGED
|
@@ -197,6 +197,8 @@ function createDeliveryClient(options) {
|
|
|
197
197
|
mediaItems: (keys, request) => get("media/items", [...ids(keys), ...shaping(request ?? {})], request ?? {}, "throw"),
|
|
198
198
|
media: (query) => get("media", [["fetch", query.fetch], ...paging(query), ...shaping(query)], query, "throw"),
|
|
199
199
|
menu: (alias, request = {}) => get(`menus/${encodeURIComponent(alias)}`, [], request, "undefined"),
|
|
200
|
+
dictionary: (keys, request = {}) => get("dictionary", keys && keys.length > 0 ? [["keys", keys.join(",")]] : [], request, "body"),
|
|
201
|
+
settings: (request) => get("settings", shaping(request ?? {}), request ?? {}, "undefined"),
|
|
200
202
|
route: (path, request = {}) => get("route", [
|
|
201
203
|
["path", path],
|
|
202
204
|
...request.host ? [["host", request.host]] : [],
|
package/package.json
CHANGED