@starlightcms/js-sdk 0.12.1 → 0.13.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.
Files changed (31) hide show
  1. package/dist/cjs/selectors/Entry/index.d.ts +2 -2
  2. package/dist/cjs/selectors/Entry/index.d.ts.map +1 -1
  3. package/dist/cjs/selectors/Entry/index.js.map +1 -1
  4. package/dist/cjs/selectors/Entry/types.d.ts +21 -0
  5. package/dist/cjs/selectors/Entry/types.d.ts.map +1 -1
  6. package/dist/cjs/selectors/Entry/types.js.map +1 -1
  7. package/dist/cjs/selectors/ModelCategory/index.d.ts +2 -2
  8. package/dist/cjs/selectors/ModelCategory/index.d.ts.map +1 -1
  9. package/dist/cjs/selectors/ModelCategory/index.js.map +1 -1
  10. package/dist/cjs/selectors/ModelCategory/types.d.ts +22 -1
  11. package/dist/cjs/selectors/ModelCategory/types.d.ts.map +1 -1
  12. package/dist/cjs/selectors/ModelCategory/types.js.map +1 -1
  13. package/dist/cjs/types/selectors.d.ts +2 -2
  14. package/dist/cjs/types/selectors.d.ts.map +1 -1
  15. package/dist/cjs/types/selectors.js.map +1 -1
  16. package/dist/esm/selectors/Entry/index.d.ts +2 -2
  17. package/dist/esm/selectors/Entry/index.d.ts.map +1 -1
  18. package/dist/esm/selectors/Entry/index.js.map +1 -1
  19. package/dist/esm/selectors/Entry/types.d.ts +21 -0
  20. package/dist/esm/selectors/Entry/types.d.ts.map +1 -1
  21. package/dist/esm/selectors/Entry/types.js.map +1 -1
  22. package/dist/esm/selectors/ModelCategory/index.d.ts +2 -2
  23. package/dist/esm/selectors/ModelCategory/index.d.ts.map +1 -1
  24. package/dist/esm/selectors/ModelCategory/index.js.map +1 -1
  25. package/dist/esm/selectors/ModelCategory/types.d.ts +22 -1
  26. package/dist/esm/selectors/ModelCategory/types.d.ts.map +1 -1
  27. package/dist/esm/selectors/ModelCategory/types.js.map +1 -1
  28. package/dist/esm/types/selectors.d.ts +2 -2
  29. package/dist/esm/types/selectors.d.ts.map +1 -1
  30. package/dist/esm/types/selectors.js.map +1 -1
  31. package/package.json +12 -3
@@ -1,5 +1,5 @@
1
1
  import { SerializedData, StarlightClient } from '../../types';
2
- import { EntrySelector } from './types';
2
+ import { EntrySelector, ListEntriesParams } from './types';
3
3
  export default function makeEntrySelector<D extends SerializedData>(client: StarlightClient, model: string): EntrySelector<D>;
4
- export { EntrySelector };
4
+ export { EntrySelector, ListEntriesParams };
5
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/selectors/Entry/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,cAAc,EACd,eAAe,EAGhB,MAAM,aAAa,CAAA;AACpB,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAEvC,MAAM,CAAC,OAAO,UAAU,iBAAiB,CAAC,CAAC,SAAS,cAAc,EAChE,MAAM,EAAE,eAAe,EACvB,KAAK,EAAE,MAAM,GACZ,aAAa,CAAC,CAAC,CAAC,CAclB;AAED,OAAO,EAAE,aAAa,EAAE,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/selectors/Entry/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,cAAc,EACd,eAAe,EAGhB,MAAM,aAAa,CAAA;AACpB,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAE1D,MAAM,CAAC,OAAO,UAAU,iBAAiB,CAAC,CAAC,SAAS,cAAc,EAChE,MAAM,EAAE,eAAe,EACvB,KAAK,EAAE,MAAM,GACZ,aAAa,CAAC,CAAC,CAAC,CAclB;AAED,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/selectors/Entry/index.ts"],"names":[],"mappings":";;AASA,SAAwB,iBAAiB,CACvC,MAAuB,EACvB,KAAa;IAEb,OAAO;QACL,IAAI,CAAC,OAAO;YACV,OAAO,MAAM,CAAC,GAAG,CAAC,WAAW,KAAK,UAAU,EAAE,OAAO,CAAC,CAAA;QACxD,CAAC;QAED,GAAG,CACD,IAAY,EACZ,MAAM,EACN,OAAO;YAEP,OAAO,MAAM,CAAC,GAAG,CAAC,WAAW,KAAK,YAAY,IAAI,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,CAAA;QACxE,CAAC;KACF,CAAA;AACH,CAAC;AAjBD,oCAiBC","sourcesContent":["import {\n Entry,\n SerializedData,\n StarlightClient,\n StarlightItemResponse,\n StarlightListResponse,\n} from '../../types'\nimport { EntrySelector } from './types'\n\nexport default function makeEntrySelector<D extends SerializedData>(\n client: StarlightClient,\n model: string\n): EntrySelector<D> {\n return {\n list(options): Promise<StarlightListResponse<Entry<D>>> {\n return client.get(`/models/${model}/entries`, options)\n },\n\n get(\n slug: string,\n params,\n options\n ): Promise<StarlightItemResponse<Entry<D>>> {\n return client.get(`/models/${model}/entries/${slug}`, params, options)\n },\n }\n}\n\nexport { EntrySelector }\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/selectors/Entry/index.ts"],"names":[],"mappings":";;AASA,SAAwB,iBAAiB,CACvC,MAAuB,EACvB,KAAa;IAEb,OAAO;QACL,IAAI,CAAC,OAAO;YACV,OAAO,MAAM,CAAC,GAAG,CAAC,WAAW,KAAK,UAAU,EAAE,OAAO,CAAC,CAAA;QACxD,CAAC;QAED,GAAG,CACD,IAAY,EACZ,MAAM,EACN,OAAO;YAEP,OAAO,MAAM,CAAC,GAAG,CAAC,WAAW,KAAK,YAAY,IAAI,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,CAAA;QACxE,CAAC;KACF,CAAA;AACH,CAAC;AAjBD,oCAiBC","sourcesContent":["import {\n Entry,\n SerializedData,\n StarlightClient,\n StarlightItemResponse,\n StarlightListResponse,\n} from '../../types'\nimport { EntrySelector, ListEntriesParams } from './types'\n\nexport default function makeEntrySelector<D extends SerializedData>(\n client: StarlightClient,\n model: string\n): EntrySelector<D> {\n return {\n list(options): Promise<StarlightListResponse<Entry<D>>> {\n return client.get(`/models/${model}/entries`, options)\n },\n\n get(\n slug: string,\n params,\n options\n ): Promise<StarlightItemResponse<Entry<D>>> {\n return client.get(`/models/${model}/entries/${slug}`, params, options)\n },\n }\n}\n\nexport { EntrySelector, ListEntriesParams }\n"]}
@@ -20,6 +20,27 @@ export interface ListEntriesParams extends BaseRequestParameters, QueryableReque
20
20
  * allowed options.
21
21
  */
22
22
  order?: 'title:asc' | 'title:desc' | 'published_at:asc' | 'published_at:desc' | 'views:asc' | 'views:desc';
23
+ /**
24
+ * When false, the returned entries won't have any data attached to them,
25
+ * even if their Model have listable fields. Defaults to true.
26
+ */
27
+ data?: boolean;
28
+ /**
29
+ * When given, return entries published before the given date. Should be an
30
+ * ISO 8601 date string.
31
+ *
32
+ * Tip: in JavaScript, you can get an ISO 8601 date string by using
33
+ * [Date.toISOString()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString).
34
+ */
35
+ published_before?: string;
36
+ /**
37
+ * When given, return entries published after the given date. Should be an
38
+ * ISO 8601 date string.
39
+ *
40
+ * Tip: in JavaScript, you can get an ISO 8601 date string by using
41
+ * [Date.toISOString()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString).
42
+ */
43
+ published_after?: string;
23
44
  }
24
45
  /**
25
46
  * Request parameters for getting an entry.
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/selectors/Entry/types.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,EACrB,KAAK,EACL,eAAe,EACf,0BAA0B,EAC1B,cAAc,EACd,qBAAqB,EACrB,qBAAqB,EACtB,MAAM,aAAa,CAAA;AAEpB;;;;;;GAMG;AACH,MAAM,WAAW,iBACf,SAAQ,qBAAqB,EAC3B,0BAA0B;IAC5B;;;;;;OAMG;IACH,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB;;;OAGG;IACH,KAAK,CAAC,EACF,WAAW,GACX,YAAY,GACZ,kBAAkB,GAClB,mBAAmB,GACnB,WAAW,GACX,YAAY,CAAA;CACjB;AAED;;;;;;GAMG;AACH,oBAAY,cAAc,GAAG;IAC3B;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB,CAAA;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,aAAa,CAAC,CAAC,SAAS,cAAc;IACrD;;;;;;;;;;;;;;;;;;;;;;;;;;OA0BG;IACH,GAAG,CACD,IAAI,EAAE,MAAM,EACZ,MAAM,CAAC,EAAE,cAAc,EACvB,OAAO,CAAC,EAAE,WAAW,GACpB,OAAO,CAAC,qBAAqB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;IAE3C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAkCG;IACH,IAAI,CACF,OAAO,CAAC,EAAE,iBAAiB,GAAG,eAAe,CAAC,CAAC,CAAC,GAC/C,OAAO,CAAC,qBAAqB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;CAC5C"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/selectors/Entry/types.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,EACrB,KAAK,EACL,eAAe,EACf,0BAA0B,EAC1B,cAAc,EACd,qBAAqB,EACrB,qBAAqB,EACtB,MAAM,aAAa,CAAA;AAEpB;;;;;;GAMG;AACH,MAAM,WAAW,iBACf,SAAQ,qBAAqB,EAC3B,0BAA0B;IAC5B;;;;;;OAMG;IACH,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB;;;OAGG;IACH,KAAK,CAAC,EACF,WAAW,GACX,YAAY,GACZ,kBAAkB,GAClB,mBAAmB,GACnB,WAAW,GACX,YAAY,CAAA;IAChB;;;OAGG;IACH,IAAI,CAAC,EAAE,OAAO,CAAA;IACd;;;;;;OAMG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB;;;;;;OAMG;IACH,eAAe,CAAC,EAAE,MAAM,CAAA;CACzB;AAED;;;;;;GAMG;AACH,oBAAY,cAAc,GAAG;IAC3B;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB,CAAA;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,aAAa,CAAC,CAAC,SAAS,cAAc;IACrD;;;;;;;;;;;;;;;;;;;;;;;;;;OA0BG;IACH,GAAG,CACD,IAAI,EAAE,MAAM,EACZ,MAAM,CAAC,EAAE,cAAc,EACvB,OAAO,CAAC,EAAE,WAAW,GACpB,OAAO,CAAC,qBAAqB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;IAE3C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAkCG;IACH,IAAI,CACF,OAAO,CAAC,EAAE,iBAAiB,GAAG,eAAe,CAAC,CAAC,CAAC,GAC/C,OAAO,CAAC,qBAAqB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;CAC5C"}
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/selectors/Entry/types.ts"],"names":[],"mappings":"","sourcesContent":["import {\n BaseRequestParameters,\n Entry,\n QueryableFields,\n QueryableRequestParameters,\n SerializedData,\n StarlightItemResponse,\n StarlightListResponse,\n} from '../../types'\n\n/**\n * Request parameters for listing entries.\n *\n * Used by {@apilink EntrySelector.list}.\n *\n * @group Request Parameters\n */\nexport interface ListEntriesParams\n extends BaseRequestParameters,\n QueryableRequestParameters {\n /**\n * A comma-separated list of categories. Only entries in these categories\n * will be returned. If undefined, all entries in the model will be listed.\n *\n * For instance, to show only entries in the \"news\" and \"articles\" categories,\n * pass `'news,category'`.\n */\n categories?: string\n /**\n * Define how items will be ordered. Check this field type to see the\n * allowed options.\n */\n order?:\n | 'title:asc'\n | 'title:desc'\n | 'published_at:asc'\n | 'published_at:desc'\n | 'views:asc'\n | 'views:desc'\n}\n\n/**\n * Request parameters for getting an entry.\n *\n * Used by {@apilink EntrySelector.get}.\n *\n * @group Request Parameters\n */\nexport type GetEntryParams = {\n /**\n * Preview token generated by the Starlight admin interface. If defined and\n * valid, the API will return a preview of the entry revision associated\n * with the token.\n */\n preview?: string\n}\n\n/**\n * A Selector that provide methods to list and request information on\n * {@apilink Entry | Entries}.\n *\n * You can use an EntrySelector by accessing\n * {@apilink ModelInstance.entries}.\n *\n * @group Selectors\n */\nexport interface EntrySelector<D extends SerializedData> {\n /**\n * Returns a {@link StarlightItemResponse} with a single {@link Entry}.\n * Supports revision previewing by passing a `preview` parameter.\n *\n * @example Requesting information from an entry \"hello-world\" from a model of slug \"posts\".\n * ```ts\n * import Starlight from '@starlightcms/js-sdk'\n *\n * const response = await Starlight.posts.entries.get('hello-world')\n * ```\n *\n * @example Passing a preview token on the last example.\n * ```ts\n * import Starlight from '@starlightcms/js-sdk'\n *\n * const response = await Starlight.posts.entries.get('hello-world', {\n * preview: 'CDfkvt1zTF5XhxWzi2Lejgo1'\n * })\n * ```\n *\n * @param slug The entry slug.\n * @param params An optional object of request parameters. See\n * {@link GetEntryParams} for all available options.\n * @param options An optional object of Fetch parameters. Use it to modify\n * the fetch request.See [MDN documentation on fetch()](https://developer.mozilla.org/en-US/docs/Web/API/fetch)\n * for all available options.\n */\n get(\n slug: string,\n params?: GetEntryParams,\n options?: RequestInit\n ): Promise<StarlightItemResponse<Entry<D>>>\n\n /**\n * Returns a {@link StarlightListResponse} with a list of\n * {@apilink Entry | Entries}.\n *\n * @example Requesting all entries from a model of slug \"recipes\".\n * ```ts\n * import Starlight from '@starlightcms/js-sdk'\n *\n * const response = await Starlight.recipes.entries.list()\n * ```\n *\n * @example Paginating and searching on the last example.\n * ```ts\n * import Starlight from '@starlightcms/js-sdk'\n *\n * const response = await Starlight.recipes.entries.list({\n * page: 2,\n * query: 'gravy',\n * 'field:is_vegan': true,\n * })\n * ```\n *\n * @example Ordering entries by number of views.\n * ```ts\n * import Starlight from '@starlightcms/js-sdk'\n *\n * const response = await Starlight.recipes.entries.list({\n * order: 'views:desc'\n * })\n * ```\n *\n * @param options An optional object of request parameters. See\n * {@link ListEntriesParams} for all available options. `field:foo`\n * syntax is also supported, see {@link QueryableFields} for more info.\n */\n list(\n options?: ListEntriesParams & QueryableFields<D>\n ): Promise<StarlightListResponse<Entry<D>>>\n}\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/selectors/Entry/types.ts"],"names":[],"mappings":"","sourcesContent":["import {\n BaseRequestParameters,\n Entry,\n QueryableFields,\n QueryableRequestParameters,\n SerializedData,\n StarlightItemResponse,\n StarlightListResponse,\n} from '../../types'\n\n/**\n * Request parameters for listing entries.\n *\n * Used by {@apilink EntrySelector.list}.\n *\n * @group Request Parameters\n */\nexport interface ListEntriesParams\n extends BaseRequestParameters,\n QueryableRequestParameters {\n /**\n * A comma-separated list of categories. Only entries in these categories\n * will be returned. If undefined, all entries in the model will be listed.\n *\n * For instance, to show only entries in the \"news\" and \"articles\" categories,\n * pass `'news,category'`.\n */\n categories?: string\n /**\n * Define how items will be ordered. Check this field type to see the\n * allowed options.\n */\n order?:\n | 'title:asc'\n | 'title:desc'\n | 'published_at:asc'\n | 'published_at:desc'\n | 'views:asc'\n | 'views:desc'\n /**\n * When false, the returned entries won't have any data attached to them,\n * even if their Model have listable fields. Defaults to true.\n */\n data?: boolean\n /**\n * When given, return entries published before the given date. Should be an\n * ISO 8601 date string.\n *\n * Tip: in JavaScript, you can get an ISO 8601 date string by using\n * [Date.toISOString()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString).\n */\n published_before?: string\n /**\n * When given, return entries published after the given date. Should be an\n * ISO 8601 date string.\n *\n * Tip: in JavaScript, you can get an ISO 8601 date string by using\n * [Date.toISOString()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString).\n */\n published_after?: string\n}\n\n/**\n * Request parameters for getting an entry.\n *\n * Used by {@apilink EntrySelector.get}.\n *\n * @group Request Parameters\n */\nexport type GetEntryParams = {\n /**\n * Preview token generated by the Starlight admin interface. If defined and\n * valid, the API will return a preview of the entry revision associated\n * with the token.\n */\n preview?: string\n}\n\n/**\n * A Selector that provide methods to list and request information on\n * {@apilink Entry | Entries}.\n *\n * You can use an EntrySelector by accessing\n * {@apilink ModelInstance.entries}.\n *\n * @group Selectors\n */\nexport interface EntrySelector<D extends SerializedData> {\n /**\n * Returns a {@link StarlightItemResponse} with a single {@link Entry}.\n * Supports revision previewing by passing a `preview` parameter.\n *\n * @example Requesting information from an entry \"hello-world\" from a model of slug \"posts\".\n * ```ts\n * import Starlight from '@starlightcms/js-sdk'\n *\n * const response = await Starlight.posts.entries.get('hello-world')\n * ```\n *\n * @example Passing a preview token on the last example.\n * ```ts\n * import Starlight from '@starlightcms/js-sdk'\n *\n * const response = await Starlight.posts.entries.get('hello-world', {\n * preview: 'CDfkvt1zTF5XhxWzi2Lejgo1'\n * })\n * ```\n *\n * @param slug The entry slug.\n * @param params An optional object of request parameters. See\n * {@link GetEntryParams} for all available options.\n * @param options An optional object of Fetch parameters. Use it to modify\n * the fetch request.See [MDN documentation on fetch()](https://developer.mozilla.org/en-US/docs/Web/API/fetch)\n * for all available options.\n */\n get(\n slug: string,\n params?: GetEntryParams,\n options?: RequestInit\n ): Promise<StarlightItemResponse<Entry<D>>>\n\n /**\n * Returns a {@link StarlightListResponse} with a list of\n * {@apilink Entry | Entries}.\n *\n * @example Requesting all entries from a model of slug \"recipes\".\n * ```ts\n * import Starlight from '@starlightcms/js-sdk'\n *\n * const response = await Starlight.recipes.entries.list()\n * ```\n *\n * @example Paginating and searching on the last example.\n * ```ts\n * import Starlight from '@starlightcms/js-sdk'\n *\n * const response = await Starlight.recipes.entries.list({\n * page: 2,\n * query: 'gravy',\n * 'field:is_vegan': true,\n * })\n * ```\n *\n * @example Ordering entries by number of views.\n * ```ts\n * import Starlight from '@starlightcms/js-sdk'\n *\n * const response = await Starlight.recipes.entries.list({\n * order: 'views:desc'\n * })\n * ```\n *\n * @param options An optional object of request parameters. See\n * {@link ListEntriesParams} for all available options. `field:foo`\n * syntax is also supported, see {@link QueryableFields} for more info.\n */\n list(\n options?: ListEntriesParams & QueryableFields<D>\n ): Promise<StarlightListResponse<Entry<D>>>\n}\n"]}
@@ -1,5 +1,5 @@
1
1
  import { SerializedData, StarlightClient } from '../../types';
2
- import { ModelCategorySelector, DynamicModelCategorySelector } from './types';
2
+ import { ModelCategorySelector, DynamicModelCategorySelector, ListModelCategoriesOptions } from './types';
3
3
  export default function makeModelCategorySelector<D extends SerializedData>(client: StarlightClient, model: string): DynamicModelCategorySelector<D>;
4
- export { ModelCategorySelector, DynamicModelCategorySelector };
4
+ export { ModelCategorySelector, DynamicModelCategorySelector, ListModelCategoriesOptions, };
5
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/selectors/ModelCategory/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,cAAc,EACd,eAAe,EAGhB,MAAM,aAAa,CAAA;AACpB,OAAO,EAAE,qBAAqB,EAAE,4BAA4B,EAAE,MAAM,SAAS,CAAA;AAG7E,MAAM,CAAC,OAAO,UAAU,yBAAyB,CAAC,CAAC,SAAS,cAAc,EACxE,MAAM,EAAE,eAAe,EACvB,KAAK,EAAE,MAAM,GACZ,4BAA4B,CAAC,CAAC,CAAC,CAoBjC;AAED,OAAO,EAAE,qBAAqB,EAAE,4BAA4B,EAAE,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/selectors/ModelCategory/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,cAAc,EACd,eAAe,EAGhB,MAAM,aAAa,CAAA;AACpB,OAAO,EACL,qBAAqB,EACrB,4BAA4B,EAC5B,0BAA0B,EAC3B,MAAM,SAAS,CAAA;AAGhB,MAAM,CAAC,OAAO,UAAU,yBAAyB,CAAC,CAAC,SAAS,cAAc,EACxE,MAAM,EAAE,eAAe,EACvB,KAAK,EAAE,MAAM,GACZ,4BAA4B,CAAC,CAAC,CAAC,CAoBjC;AAED,OAAO,EACL,qBAAqB,EACrB,4BAA4B,EAC5B,0BAA0B,GAC3B,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/selectors/ModelCategory/index.ts"],"names":[],"mappings":";;;;;AAQA,kFAAqE;AAErE,SAAwB,yBAAyB,CAC/C,MAAuB,EACvB,KAAa;IAEb,MAAM,QAAQ,GAA0B;QACtC,IAAI,CAAC,OAAO;YACV,OAAO,MAAM,CAAC,GAAG,CAAC,WAAW,KAAK,aAAa,oBAAO,OAAO,EAAG,CAAA;QAClE,CAAC;QAED,GAAG,CAAC,IAAI;YACN,OAAO,MAAM,CAAC,GAAG,CAAC,WAAW,KAAK,eAAe,IAAI,EAAE,CAAC,CAAA;QAC1D,CAAC;KACF,CAAA;IAED,OAAO,IAAI,KAAK,CAAC,QAAQ,EAAE;QACzB,GAAG,CAAC,MAAM,EAAE,IAAI;YACd,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,EAAE;gBAC1D,OAAO,IAAA,uBAAyB,EAAC,MAAM,EAAE,KAAK,EAAE,IAAI,CAAC,CAAA;aACtD;YAED,OAAO,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,CAAA;QAClC,CAAC;KACF,CAAoC,CAAA;AACvC,CAAC;AAvBD,4CAuBC","sourcesContent":["import {\n ModelCategory,\n SerializedData,\n StarlightClient,\n StarlightItemResponse,\n StarlightListResponse,\n} from '../../types'\nimport { ModelCategorySelector, DynamicModelCategorySelector } from './types'\nimport makeModelCategoryInstance from '../../instances/ModelCategory'\n\nexport default function makeModelCategorySelector<D extends SerializedData>(\n client: StarlightClient,\n model: string\n): DynamicModelCategorySelector<D> {\n const selector: ModelCategorySelector = {\n list(options): Promise<StarlightListResponse<ModelCategory>> {\n return client.get(`/models/${model}/categories`, { ...options })\n },\n\n get(slug): Promise<StarlightItemResponse<ModelCategory>> {\n return client.get(`/models/${model}/categories/${slug}`)\n },\n }\n\n return new Proxy(selector, {\n get(target, prop) {\n if (typeof prop === 'string' && !Reflect.has(target, prop)) {\n return makeModelCategoryInstance(client, model, prop)\n }\n\n return Reflect.get(target, prop)\n },\n }) as DynamicModelCategorySelector<D>\n}\n\nexport { ModelCategorySelector, DynamicModelCategorySelector }\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/selectors/ModelCategory/index.ts"],"names":[],"mappings":";;;;;AAYA,kFAAqE;AAErE,SAAwB,yBAAyB,CAC/C,MAAuB,EACvB,KAAa;IAEb,MAAM,QAAQ,GAA0B;QACtC,IAAI,CAAC,OAAO;YACV,OAAO,MAAM,CAAC,GAAG,CAAC,WAAW,KAAK,aAAa,oBAAO,OAAO,EAAG,CAAA;QAClE,CAAC;QAED,GAAG,CAAC,IAAI;YACN,OAAO,MAAM,CAAC,GAAG,CAAC,WAAW,KAAK,eAAe,IAAI,EAAE,CAAC,CAAA;QAC1D,CAAC;KACF,CAAA;IAED,OAAO,IAAI,KAAK,CAAC,QAAQ,EAAE;QACzB,GAAG,CAAC,MAAM,EAAE,IAAI;YACd,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,EAAE;gBAC1D,OAAO,IAAA,uBAAyB,EAAC,MAAM,EAAE,KAAK,EAAE,IAAI,CAAC,CAAA;aACtD;YAED,OAAO,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,CAAA;QAClC,CAAC;KACF,CAAoC,CAAA;AACvC,CAAC;AAvBD,4CAuBC","sourcesContent":["import {\n ModelCategory,\n SerializedData,\n StarlightClient,\n StarlightItemResponse,\n StarlightListResponse,\n} from '../../types'\nimport {\n ModelCategorySelector,\n DynamicModelCategorySelector,\n ListModelCategoriesOptions,\n} from './types'\nimport makeModelCategoryInstance from '../../instances/ModelCategory'\n\nexport default function makeModelCategorySelector<D extends SerializedData>(\n client: StarlightClient,\n model: string\n): DynamicModelCategorySelector<D> {\n const selector: ModelCategorySelector = {\n list(options): Promise<StarlightListResponse<ModelCategory>> {\n return client.get(`/models/${model}/categories`, { ...options })\n },\n\n get(slug): Promise<StarlightItemResponse<ModelCategory>> {\n return client.get(`/models/${model}/categories/${slug}`)\n },\n }\n\n return new Proxy(selector, {\n get(target, prop) {\n if (typeof prop === 'string' && !Reflect.has(target, prop)) {\n return makeModelCategoryInstance(client, model, prop)\n }\n\n return Reflect.get(target, prop)\n },\n }) as DynamicModelCategorySelector<D>\n}\n\nexport {\n ModelCategorySelector,\n DynamicModelCategorySelector,\n ListModelCategoriesOptions,\n}\n"]}
@@ -1,11 +1,18 @@
1
1
  import { BaseRequestParameters, ModelCategory, SerializedData, StarlightItemResponse, StarlightListResponse } from '../../types';
2
2
  import { ModelCategoryInstance } from '../../instances/ModelCategory';
3
+ /**
4
+ * Request parameters for listing model categories.
5
+ *
6
+ * Used by {@apilink ModelCategorySelector.list}.
7
+ *
8
+ * @group Request Parameters
9
+ */
3
10
  export interface ListModelCategoriesOptions extends BaseRequestParameters {
4
11
  /**
5
12
  * Define how items will be ordered. Check this field type to see the
6
13
  * allowed options.
7
14
  */
8
- order?: 'title:asc' | 'title:desc' | 'entry_count:asc' | 'entry_count:desc';
15
+ order?: 'title:asc' | 'title:desc' | 'entry_count:asc' | 'entry_count:desc' | 'slug:asc' | 'slug:desc' | 'created_at:asc' | 'created_at:desc' | 'updated_at:asc' | 'updated_at:desc';
9
16
  }
10
17
  /**
11
18
  * A Selector that provide methods to list and request information on
@@ -17,6 +24,20 @@ export interface ListModelCategoriesOptions extends BaseRequestParameters {
17
24
  * @group Selectors
18
25
  */
19
26
  export interface ModelCategorySelector {
27
+ /**
28
+ * Returns a {@link StarlightListResponse} with a list of
29
+ * {@apilink ModelCategory | ModelCategories}.
30
+ *
31
+ * @example Requesting all categories from a model.
32
+ * ```ts
33
+ * import Starlight from '@starlightcms/js-sdk'
34
+ *
35
+ * const response = await Starlight.posts.categories.list()
36
+ * ```
37
+ *
38
+ * @param options An optional object of request parameters. See
39
+ * {@link ListModelCategoriesOptions} for all available options.
40
+ */
20
41
  list(options?: ListModelCategoriesOptions): Promise<StarlightListResponse<ModelCategory>>;
21
42
  /**
22
43
  * Returns a {@link StarlightItemResponse} with a single {@link ModelCategory}.
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/selectors/ModelCategory/types.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,EACrB,aAAa,EACb,cAAc,EACd,qBAAqB,EACrB,qBAAqB,EACtB,MAAM,aAAa,CAAA;AACpB,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAA;AAErE,MAAM,WAAW,0BAA2B,SAAQ,qBAAqB;IACvE;;;OAGG;IACH,KAAK,CAAC,EAAE,WAAW,GAAG,YAAY,GAAG,iBAAiB,GAAG,kBAAkB,CAAA;CAC5E;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,qBAAqB;IACpC,IAAI,CACF,OAAO,CAAC,EAAE,0BAA0B,GACnC,OAAO,CAAC,qBAAqB,CAAC,aAAa,CAAC,CAAC,CAAA;IAEhD;;;;;;;;;;;OAWG;IACH,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,qBAAqB,CAAC,aAAa,CAAC,CAAC,CAAA;CACjE;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,oBAAY,4BAA4B,CAAC,CAAC,SAAS,cAAc,IAC/D,qBAAqB,GAAG;IACtB,CAAC,IAAI,EAAE,MAAM,GAAG,qBAAqB,CAAC,CAAC,CAAC,CAAA;CACzC,CAAA"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/selectors/ModelCategory/types.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,EACrB,aAAa,EACb,cAAc,EACd,qBAAqB,EACrB,qBAAqB,EACtB,MAAM,aAAa,CAAA;AACpB,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAA;AAErE;;;;;;GAMG;AACH,MAAM,WAAW,0BAA2B,SAAQ,qBAAqB;IACvE;;;OAGG;IACH,KAAK,CAAC,EACF,WAAW,GACX,YAAY,GACZ,iBAAiB,GACjB,kBAAkB,GAClB,UAAU,GACV,WAAW,GACX,gBAAgB,GAChB,iBAAiB,GACjB,gBAAgB,GAChB,iBAAiB,CAAA;CACtB;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,qBAAqB;IACpC;;;;;;;;;;;;;OAaG;IACH,IAAI,CACF,OAAO,CAAC,EAAE,0BAA0B,GACnC,OAAO,CAAC,qBAAqB,CAAC,aAAa,CAAC,CAAC,CAAA;IAEhD;;;;;;;;;;;OAWG;IACH,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,qBAAqB,CAAC,aAAa,CAAC,CAAC,CAAA;CACjE;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,oBAAY,4BAA4B,CAAC,CAAC,SAAS,cAAc,IAC/D,qBAAqB,GAAG;IACtB,CAAC,IAAI,EAAE,MAAM,GAAG,qBAAqB,CAAC,CAAC,CAAC,CAAA;CACzC,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/selectors/ModelCategory/types.ts"],"names":[],"mappings":"","sourcesContent":["import {\n BaseRequestParameters,\n ModelCategory,\n SerializedData,\n StarlightItemResponse,\n StarlightListResponse,\n} from '../../types'\nimport { ModelCategoryInstance } from '../../instances/ModelCategory'\n\nexport interface ListModelCategoriesOptions extends BaseRequestParameters {\n /**\n * Define how items will be ordered. Check this field type to see the\n * allowed options.\n */\n order?: 'title:asc' | 'title:desc' | 'entry_count:asc' | 'entry_count:desc'\n}\n\n/**\n * A Selector that provide methods to list and request information on\n * {@apilink ModelCategory | ModelCategories}.\n *\n * You can use a ModelCategorySelector by accessing\n * {@apilink ModelInstance.categories}.\n *\n * @group Selectors\n */\nexport interface ModelCategorySelector {\n list(\n options?: ListModelCategoriesOptions\n ): Promise<StarlightListResponse<ModelCategory>>\n\n /**\n * Returns a {@link StarlightItemResponse} with a single {@link ModelCategory}.\n *\n * @example Requesting information from a category \"premium\" from a model of slug \"plans\".\n * ```ts\n * import Starlight from '@starlightcms/js-sdk'\n *\n * const response = await Starlight.plans.premium.get()\n * ```\n *\n * @param slug The category slug.\n */\n get(slug: string): Promise<StarlightItemResponse<ModelCategory>>\n}\n\n/**\n * A Selector that provide all {@link ModelCategorySelector} methods and adds\n * support for creating {@apilink ModelCategoryInstance | ModelCategoryInstances}\n * using the dynamic syntax.\n *\n * See {@link ModelCategorySelector} to view all available methods. You can use\n * a DynamicModelCategorySelector by accessing {@apilink ModelInstance.categories}.\n *\n * See {@doclink requests-and-responses#dynamic-syntax | Dynamic Instances}\n * documentation to learn more about the dynamic syntax.\n *\n * @example Accessing a ModelCategorySelector using the dynamic syntax on a model of slug \"posts\"\n * ```ts\n * import Starlight from '@starlightcms/js-sdk'\n *\n * // \"articles\" below will be a ModelCategorySelector.\n * const response = await Starlight.posts.categories.articles.list()\n * ```\n *\n * @category Instances\n */\nexport type DynamicModelCategorySelector<D extends SerializedData> =\n ModelCategorySelector & {\n [slug: string]: ModelCategoryInstance<D>\n }\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/selectors/ModelCategory/types.ts"],"names":[],"mappings":"","sourcesContent":["import {\n BaseRequestParameters,\n ModelCategory,\n SerializedData,\n StarlightItemResponse,\n StarlightListResponse,\n} from '../../types'\nimport { ModelCategoryInstance } from '../../instances/ModelCategory'\n\n/**\n * Request parameters for listing model categories.\n *\n * Used by {@apilink ModelCategorySelector.list}.\n *\n * @group Request Parameters\n */\nexport interface ListModelCategoriesOptions extends BaseRequestParameters {\n /**\n * Define how items will be ordered. Check this field type to see the\n * allowed options.\n */\n order?:\n | 'title:asc'\n | 'title:desc'\n | 'entry_count:asc'\n | 'entry_count:desc'\n | 'slug:asc'\n | 'slug:desc'\n | 'created_at:asc'\n | 'created_at:desc'\n | 'updated_at:asc'\n | 'updated_at:desc'\n}\n\n/**\n * A Selector that provide methods to list and request information on\n * {@apilink ModelCategory | ModelCategories}.\n *\n * You can use a ModelCategorySelector by accessing\n * {@apilink ModelInstance.categories}.\n *\n * @group Selectors\n */\nexport interface ModelCategorySelector {\n /**\n * Returns a {@link StarlightListResponse} with a list of\n * {@apilink ModelCategory | ModelCategories}.\n *\n * @example Requesting all categories from a model.\n * ```ts\n * import Starlight from '@starlightcms/js-sdk'\n *\n * const response = await Starlight.posts.categories.list()\n * ```\n *\n * @param options An optional object of request parameters. See\n * {@link ListModelCategoriesOptions} for all available options.\n */\n list(\n options?: ListModelCategoriesOptions\n ): Promise<StarlightListResponse<ModelCategory>>\n\n /**\n * Returns a {@link StarlightItemResponse} with a single {@link ModelCategory}.\n *\n * @example Requesting information from a category \"premium\" from a model of slug \"plans\".\n * ```ts\n * import Starlight from '@starlightcms/js-sdk'\n *\n * const response = await Starlight.plans.premium.get()\n * ```\n *\n * @param slug The category slug.\n */\n get(slug: string): Promise<StarlightItemResponse<ModelCategory>>\n}\n\n/**\n * A Selector that provide all {@link ModelCategorySelector} methods and adds\n * support for creating {@apilink ModelCategoryInstance | ModelCategoryInstances}\n * using the dynamic syntax.\n *\n * See {@link ModelCategorySelector} to view all available methods. You can use\n * a DynamicModelCategorySelector by accessing {@apilink ModelInstance.categories}.\n *\n * See {@doclink requests-and-responses#dynamic-syntax | Dynamic Instances}\n * documentation to learn more about the dynamic syntax.\n *\n * @example Accessing a ModelCategorySelector using the dynamic syntax on a model of slug \"posts\"\n * ```ts\n * import Starlight from '@starlightcms/js-sdk'\n *\n * // \"articles\" below will be a ModelCategorySelector.\n * const response = await Starlight.posts.categories.articles.list()\n * ```\n *\n * @category Instances\n */\nexport type DynamicModelCategorySelector<D extends SerializedData> =\n ModelCategorySelector & {\n [slug: string]: ModelCategoryInstance<D>\n }\n"]}
@@ -1,7 +1,7 @@
1
- export { ModelCategorySelector, DynamicModelCategorySelector, } from '../selectors/ModelCategory';
1
+ export { ModelCategorySelector, DynamicModelCategorySelector, ListModelCategoriesOptions, } from '../selectors/ModelCategory';
2
2
  export { ModelSelector, DynamicModelSelector } from '../selectors/Model';
3
3
  export { CollectionSelector, DynamicCollectionSelector, ListCollectionsParams, } from '../selectors/Collection';
4
- export { EntrySelector } from '../selectors/Entry';
4
+ export { EntrySelector, ListEntriesParams } from '../selectors/Entry';
5
5
  export { MediaSelector } from '../selectors/Media';
6
6
  export { SearchSelector, SearchEntriesParams } from '../selectors/Search';
7
7
  export { SingletonSelector } from '../selectors/Singleton';
@@ -1 +1 @@
1
- {"version":3,"file":"selectors.d.ts","sourceRoot":"","sources":["../../../src/types/selectors.ts"],"names":[],"mappings":"AACA,OAAO,EACL,qBAAqB,EACrB,4BAA4B,GAC7B,MAAM,4BAA4B,CAAA;AACnC,OAAO,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAA;AACxE,OAAO,EACL,kBAAkB,EAClB,yBAAyB,EACzB,qBAAqB,GACtB,MAAM,yBAAyB,CAAA;AAChC,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAClD,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAA;AACzE,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA"}
1
+ {"version":3,"file":"selectors.d.ts","sourceRoot":"","sources":["../../../src/types/selectors.ts"],"names":[],"mappings":"AACA,OAAO,EACL,qBAAqB,EACrB,4BAA4B,EAC5B,0BAA0B,GAC3B,MAAM,4BAA4B,CAAA;AACnC,OAAO,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAA;AACxE,OAAO,EACL,kBAAkB,EAClB,yBAAyB,EACzB,qBAAqB,GACtB,MAAM,yBAAyB,CAAA;AAChC,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAA;AACrE,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAClD,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAA;AACzE,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"selectors.js","sourceRoot":"","sources":["../../../src/types/selectors.ts"],"names":[],"mappings":"","sourcesContent":["// Selector types are exported here so they are visible in the API docs.\nexport {\n ModelCategorySelector,\n DynamicModelCategorySelector,\n} from '../selectors/ModelCategory'\nexport { ModelSelector, DynamicModelSelector } from '../selectors/Model'\nexport {\n CollectionSelector,\n DynamicCollectionSelector,\n ListCollectionsParams,\n} from '../selectors/Collection'\nexport { EntrySelector } from '../selectors/Entry'\nexport { MediaSelector } from '../selectors/Media'\nexport { SearchSelector, SearchEntriesParams } from '../selectors/Search'\nexport { SingletonSelector } from '../selectors/Singleton'\n"]}
1
+ {"version":3,"file":"selectors.js","sourceRoot":"","sources":["../../../src/types/selectors.ts"],"names":[],"mappings":"","sourcesContent":["// Selector types are exported here so they are visible in the API docs.\nexport {\n ModelCategorySelector,\n DynamicModelCategorySelector,\n ListModelCategoriesOptions,\n} from '../selectors/ModelCategory'\nexport { ModelSelector, DynamicModelSelector } from '../selectors/Model'\nexport {\n CollectionSelector,\n DynamicCollectionSelector,\n ListCollectionsParams,\n} from '../selectors/Collection'\nexport { EntrySelector, ListEntriesParams } from '../selectors/Entry'\nexport { MediaSelector } from '../selectors/Media'\nexport { SearchSelector, SearchEntriesParams } from '../selectors/Search'\nexport { SingletonSelector } from '../selectors/Singleton'\n"]}
@@ -1,5 +1,5 @@
1
1
  import { SerializedData, StarlightClient } from '../../types';
2
- import { EntrySelector } from './types';
2
+ import { EntrySelector, ListEntriesParams } from './types';
3
3
  export default function makeEntrySelector<D extends SerializedData>(client: StarlightClient, model: string): EntrySelector<D>;
4
- export { EntrySelector };
4
+ export { EntrySelector, ListEntriesParams };
5
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/selectors/Entry/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,cAAc,EACd,eAAe,EAGhB,MAAM,aAAa,CAAA;AACpB,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAEvC,MAAM,CAAC,OAAO,UAAU,iBAAiB,CAAC,CAAC,SAAS,cAAc,EAChE,MAAM,EAAE,eAAe,EACvB,KAAK,EAAE,MAAM,GACZ,aAAa,CAAC,CAAC,CAAC,CAclB;AAED,OAAO,EAAE,aAAa,EAAE,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/selectors/Entry/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,cAAc,EACd,eAAe,EAGhB,MAAM,aAAa,CAAA;AACpB,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAE1D,MAAM,CAAC,OAAO,UAAU,iBAAiB,CAAC,CAAC,SAAS,cAAc,EAChE,MAAM,EAAE,eAAe,EACvB,KAAK,EAAE,MAAM,GACZ,aAAa,CAAC,CAAC,CAAC,CAclB;AAED,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/selectors/Entry/index.ts"],"names":[],"mappings":"AASA,MAAM,CAAC,OAAO,UAAU,iBAAiB,CACvC,MAAuB,EACvB,KAAa;IAEb,OAAO;QACL,IAAI,CAAC,OAAO;YACV,OAAO,MAAM,CAAC,GAAG,CAAC,WAAW,KAAK,UAAU,EAAE,OAAO,CAAC,CAAA;QACxD,CAAC;QAED,GAAG,CACD,IAAY,EACZ,MAAM,EACN,OAAO;YAEP,OAAO,MAAM,CAAC,GAAG,CAAC,WAAW,KAAK,YAAY,IAAI,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,CAAA;QACxE,CAAC;KACF,CAAA;AACH,CAAC","sourcesContent":["import {\n Entry,\n SerializedData,\n StarlightClient,\n StarlightItemResponse,\n StarlightListResponse,\n} from '../../types'\nimport { EntrySelector } from './types'\n\nexport default function makeEntrySelector<D extends SerializedData>(\n client: StarlightClient,\n model: string\n): EntrySelector<D> {\n return {\n list(options): Promise<StarlightListResponse<Entry<D>>> {\n return client.get(`/models/${model}/entries`, options)\n },\n\n get(\n slug: string,\n params,\n options\n ): Promise<StarlightItemResponse<Entry<D>>> {\n return client.get(`/models/${model}/entries/${slug}`, params, options)\n },\n }\n}\n\nexport { EntrySelector }\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/selectors/Entry/index.ts"],"names":[],"mappings":"AASA,MAAM,CAAC,OAAO,UAAU,iBAAiB,CACvC,MAAuB,EACvB,KAAa;IAEb,OAAO;QACL,IAAI,CAAC,OAAO;YACV,OAAO,MAAM,CAAC,GAAG,CAAC,WAAW,KAAK,UAAU,EAAE,OAAO,CAAC,CAAA;QACxD,CAAC;QAED,GAAG,CACD,IAAY,EACZ,MAAM,EACN,OAAO;YAEP,OAAO,MAAM,CAAC,GAAG,CAAC,WAAW,KAAK,YAAY,IAAI,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,CAAA;QACxE,CAAC;KACF,CAAA;AACH,CAAC","sourcesContent":["import {\n Entry,\n SerializedData,\n StarlightClient,\n StarlightItemResponse,\n StarlightListResponse,\n} from '../../types'\nimport { EntrySelector, ListEntriesParams } from './types'\n\nexport default function makeEntrySelector<D extends SerializedData>(\n client: StarlightClient,\n model: string\n): EntrySelector<D> {\n return {\n list(options): Promise<StarlightListResponse<Entry<D>>> {\n return client.get(`/models/${model}/entries`, options)\n },\n\n get(\n slug: string,\n params,\n options\n ): Promise<StarlightItemResponse<Entry<D>>> {\n return client.get(`/models/${model}/entries/${slug}`, params, options)\n },\n }\n}\n\nexport { EntrySelector, ListEntriesParams }\n"]}
@@ -20,6 +20,27 @@ export interface ListEntriesParams extends BaseRequestParameters, QueryableReque
20
20
  * allowed options.
21
21
  */
22
22
  order?: 'title:asc' | 'title:desc' | 'published_at:asc' | 'published_at:desc' | 'views:asc' | 'views:desc';
23
+ /**
24
+ * When false, the returned entries won't have any data attached to them,
25
+ * even if their Model have listable fields. Defaults to true.
26
+ */
27
+ data?: boolean;
28
+ /**
29
+ * When given, return entries published before the given date. Should be an
30
+ * ISO 8601 date string.
31
+ *
32
+ * Tip: in JavaScript, you can get an ISO 8601 date string by using
33
+ * [Date.toISOString()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString).
34
+ */
35
+ published_before?: string;
36
+ /**
37
+ * When given, return entries published after the given date. Should be an
38
+ * ISO 8601 date string.
39
+ *
40
+ * Tip: in JavaScript, you can get an ISO 8601 date string by using
41
+ * [Date.toISOString()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString).
42
+ */
43
+ published_after?: string;
23
44
  }
24
45
  /**
25
46
  * Request parameters for getting an entry.
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/selectors/Entry/types.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,EACrB,KAAK,EACL,eAAe,EACf,0BAA0B,EAC1B,cAAc,EACd,qBAAqB,EACrB,qBAAqB,EACtB,MAAM,aAAa,CAAA;AAEpB;;;;;;GAMG;AACH,MAAM,WAAW,iBACf,SAAQ,qBAAqB,EAC3B,0BAA0B;IAC5B;;;;;;OAMG;IACH,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB;;;OAGG;IACH,KAAK,CAAC,EACF,WAAW,GACX,YAAY,GACZ,kBAAkB,GAClB,mBAAmB,GACnB,WAAW,GACX,YAAY,CAAA;CACjB;AAED;;;;;;GAMG;AACH,oBAAY,cAAc,GAAG;IAC3B;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB,CAAA;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,aAAa,CAAC,CAAC,SAAS,cAAc;IACrD;;;;;;;;;;;;;;;;;;;;;;;;;;OA0BG;IACH,GAAG,CACD,IAAI,EAAE,MAAM,EACZ,MAAM,CAAC,EAAE,cAAc,EACvB,OAAO,CAAC,EAAE,WAAW,GACpB,OAAO,CAAC,qBAAqB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;IAE3C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAkCG;IACH,IAAI,CACF,OAAO,CAAC,EAAE,iBAAiB,GAAG,eAAe,CAAC,CAAC,CAAC,GAC/C,OAAO,CAAC,qBAAqB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;CAC5C"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/selectors/Entry/types.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,EACrB,KAAK,EACL,eAAe,EACf,0BAA0B,EAC1B,cAAc,EACd,qBAAqB,EACrB,qBAAqB,EACtB,MAAM,aAAa,CAAA;AAEpB;;;;;;GAMG;AACH,MAAM,WAAW,iBACf,SAAQ,qBAAqB,EAC3B,0BAA0B;IAC5B;;;;;;OAMG;IACH,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB;;;OAGG;IACH,KAAK,CAAC,EACF,WAAW,GACX,YAAY,GACZ,kBAAkB,GAClB,mBAAmB,GACnB,WAAW,GACX,YAAY,CAAA;IAChB;;;OAGG;IACH,IAAI,CAAC,EAAE,OAAO,CAAA;IACd;;;;;;OAMG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB;;;;;;OAMG;IACH,eAAe,CAAC,EAAE,MAAM,CAAA;CACzB;AAED;;;;;;GAMG;AACH,oBAAY,cAAc,GAAG;IAC3B;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB,CAAA;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,aAAa,CAAC,CAAC,SAAS,cAAc;IACrD;;;;;;;;;;;;;;;;;;;;;;;;;;OA0BG;IACH,GAAG,CACD,IAAI,EAAE,MAAM,EACZ,MAAM,CAAC,EAAE,cAAc,EACvB,OAAO,CAAC,EAAE,WAAW,GACpB,OAAO,CAAC,qBAAqB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;IAE3C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAkCG;IACH,IAAI,CACF,OAAO,CAAC,EAAE,iBAAiB,GAAG,eAAe,CAAC,CAAC,CAAC,GAC/C,OAAO,CAAC,qBAAqB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;CAC5C"}
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/selectors/Entry/types.ts"],"names":[],"mappings":"","sourcesContent":["import {\n BaseRequestParameters,\n Entry,\n QueryableFields,\n QueryableRequestParameters,\n SerializedData,\n StarlightItemResponse,\n StarlightListResponse,\n} from '../../types'\n\n/**\n * Request parameters for listing entries.\n *\n * Used by {@apilink EntrySelector.list}.\n *\n * @group Request Parameters\n */\nexport interface ListEntriesParams\n extends BaseRequestParameters,\n QueryableRequestParameters {\n /**\n * A comma-separated list of categories. Only entries in these categories\n * will be returned. If undefined, all entries in the model will be listed.\n *\n * For instance, to show only entries in the \"news\" and \"articles\" categories,\n * pass `'news,category'`.\n */\n categories?: string\n /**\n * Define how items will be ordered. Check this field type to see the\n * allowed options.\n */\n order?:\n | 'title:asc'\n | 'title:desc'\n | 'published_at:asc'\n | 'published_at:desc'\n | 'views:asc'\n | 'views:desc'\n}\n\n/**\n * Request parameters for getting an entry.\n *\n * Used by {@apilink EntrySelector.get}.\n *\n * @group Request Parameters\n */\nexport type GetEntryParams = {\n /**\n * Preview token generated by the Starlight admin interface. If defined and\n * valid, the API will return a preview of the entry revision associated\n * with the token.\n */\n preview?: string\n}\n\n/**\n * A Selector that provide methods to list and request information on\n * {@apilink Entry | Entries}.\n *\n * You can use an EntrySelector by accessing\n * {@apilink ModelInstance.entries}.\n *\n * @group Selectors\n */\nexport interface EntrySelector<D extends SerializedData> {\n /**\n * Returns a {@link StarlightItemResponse} with a single {@link Entry}.\n * Supports revision previewing by passing a `preview` parameter.\n *\n * @example Requesting information from an entry \"hello-world\" from a model of slug \"posts\".\n * ```ts\n * import Starlight from '@starlightcms/js-sdk'\n *\n * const response = await Starlight.posts.entries.get('hello-world')\n * ```\n *\n * @example Passing a preview token on the last example.\n * ```ts\n * import Starlight from '@starlightcms/js-sdk'\n *\n * const response = await Starlight.posts.entries.get('hello-world', {\n * preview: 'CDfkvt1zTF5XhxWzi2Lejgo1'\n * })\n * ```\n *\n * @param slug The entry slug.\n * @param params An optional object of request parameters. See\n * {@link GetEntryParams} for all available options.\n * @param options An optional object of Fetch parameters. Use it to modify\n * the fetch request.See [MDN documentation on fetch()](https://developer.mozilla.org/en-US/docs/Web/API/fetch)\n * for all available options.\n */\n get(\n slug: string,\n params?: GetEntryParams,\n options?: RequestInit\n ): Promise<StarlightItemResponse<Entry<D>>>\n\n /**\n * Returns a {@link StarlightListResponse} with a list of\n * {@apilink Entry | Entries}.\n *\n * @example Requesting all entries from a model of slug \"recipes\".\n * ```ts\n * import Starlight from '@starlightcms/js-sdk'\n *\n * const response = await Starlight.recipes.entries.list()\n * ```\n *\n * @example Paginating and searching on the last example.\n * ```ts\n * import Starlight from '@starlightcms/js-sdk'\n *\n * const response = await Starlight.recipes.entries.list({\n * page: 2,\n * query: 'gravy',\n * 'field:is_vegan': true,\n * })\n * ```\n *\n * @example Ordering entries by number of views.\n * ```ts\n * import Starlight from '@starlightcms/js-sdk'\n *\n * const response = await Starlight.recipes.entries.list({\n * order: 'views:desc'\n * })\n * ```\n *\n * @param options An optional object of request parameters. See\n * {@link ListEntriesParams} for all available options. `field:foo`\n * syntax is also supported, see {@link QueryableFields} for more info.\n */\n list(\n options?: ListEntriesParams & QueryableFields<D>\n ): Promise<StarlightListResponse<Entry<D>>>\n}\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/selectors/Entry/types.ts"],"names":[],"mappings":"","sourcesContent":["import {\n BaseRequestParameters,\n Entry,\n QueryableFields,\n QueryableRequestParameters,\n SerializedData,\n StarlightItemResponse,\n StarlightListResponse,\n} from '../../types'\n\n/**\n * Request parameters for listing entries.\n *\n * Used by {@apilink EntrySelector.list}.\n *\n * @group Request Parameters\n */\nexport interface ListEntriesParams\n extends BaseRequestParameters,\n QueryableRequestParameters {\n /**\n * A comma-separated list of categories. Only entries in these categories\n * will be returned. If undefined, all entries in the model will be listed.\n *\n * For instance, to show only entries in the \"news\" and \"articles\" categories,\n * pass `'news,category'`.\n */\n categories?: string\n /**\n * Define how items will be ordered. Check this field type to see the\n * allowed options.\n */\n order?:\n | 'title:asc'\n | 'title:desc'\n | 'published_at:asc'\n | 'published_at:desc'\n | 'views:asc'\n | 'views:desc'\n /**\n * When false, the returned entries won't have any data attached to them,\n * even if their Model have listable fields. Defaults to true.\n */\n data?: boolean\n /**\n * When given, return entries published before the given date. Should be an\n * ISO 8601 date string.\n *\n * Tip: in JavaScript, you can get an ISO 8601 date string by using\n * [Date.toISOString()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString).\n */\n published_before?: string\n /**\n * When given, return entries published after the given date. Should be an\n * ISO 8601 date string.\n *\n * Tip: in JavaScript, you can get an ISO 8601 date string by using\n * [Date.toISOString()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString).\n */\n published_after?: string\n}\n\n/**\n * Request parameters for getting an entry.\n *\n * Used by {@apilink EntrySelector.get}.\n *\n * @group Request Parameters\n */\nexport type GetEntryParams = {\n /**\n * Preview token generated by the Starlight admin interface. If defined and\n * valid, the API will return a preview of the entry revision associated\n * with the token.\n */\n preview?: string\n}\n\n/**\n * A Selector that provide methods to list and request information on\n * {@apilink Entry | Entries}.\n *\n * You can use an EntrySelector by accessing\n * {@apilink ModelInstance.entries}.\n *\n * @group Selectors\n */\nexport interface EntrySelector<D extends SerializedData> {\n /**\n * Returns a {@link StarlightItemResponse} with a single {@link Entry}.\n * Supports revision previewing by passing a `preview` parameter.\n *\n * @example Requesting information from an entry \"hello-world\" from a model of slug \"posts\".\n * ```ts\n * import Starlight from '@starlightcms/js-sdk'\n *\n * const response = await Starlight.posts.entries.get('hello-world')\n * ```\n *\n * @example Passing a preview token on the last example.\n * ```ts\n * import Starlight from '@starlightcms/js-sdk'\n *\n * const response = await Starlight.posts.entries.get('hello-world', {\n * preview: 'CDfkvt1zTF5XhxWzi2Lejgo1'\n * })\n * ```\n *\n * @param slug The entry slug.\n * @param params An optional object of request parameters. See\n * {@link GetEntryParams} for all available options.\n * @param options An optional object of Fetch parameters. Use it to modify\n * the fetch request.See [MDN documentation on fetch()](https://developer.mozilla.org/en-US/docs/Web/API/fetch)\n * for all available options.\n */\n get(\n slug: string,\n params?: GetEntryParams,\n options?: RequestInit\n ): Promise<StarlightItemResponse<Entry<D>>>\n\n /**\n * Returns a {@link StarlightListResponse} with a list of\n * {@apilink Entry | Entries}.\n *\n * @example Requesting all entries from a model of slug \"recipes\".\n * ```ts\n * import Starlight from '@starlightcms/js-sdk'\n *\n * const response = await Starlight.recipes.entries.list()\n * ```\n *\n * @example Paginating and searching on the last example.\n * ```ts\n * import Starlight from '@starlightcms/js-sdk'\n *\n * const response = await Starlight.recipes.entries.list({\n * page: 2,\n * query: 'gravy',\n * 'field:is_vegan': true,\n * })\n * ```\n *\n * @example Ordering entries by number of views.\n * ```ts\n * import Starlight from '@starlightcms/js-sdk'\n *\n * const response = await Starlight.recipes.entries.list({\n * order: 'views:desc'\n * })\n * ```\n *\n * @param options An optional object of request parameters. See\n * {@link ListEntriesParams} for all available options. `field:foo`\n * syntax is also supported, see {@link QueryableFields} for more info.\n */\n list(\n options?: ListEntriesParams & QueryableFields<D>\n ): Promise<StarlightListResponse<Entry<D>>>\n}\n"]}
@@ -1,5 +1,5 @@
1
1
  import { SerializedData, StarlightClient } from '../../types';
2
- import { ModelCategorySelector, DynamicModelCategorySelector } from './types';
2
+ import { ModelCategorySelector, DynamicModelCategorySelector, ListModelCategoriesOptions } from './types';
3
3
  export default function makeModelCategorySelector<D extends SerializedData>(client: StarlightClient, model: string): DynamicModelCategorySelector<D>;
4
- export { ModelCategorySelector, DynamicModelCategorySelector };
4
+ export { ModelCategorySelector, DynamicModelCategorySelector, ListModelCategoriesOptions, };
5
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/selectors/ModelCategory/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,cAAc,EACd,eAAe,EAGhB,MAAM,aAAa,CAAA;AACpB,OAAO,EAAE,qBAAqB,EAAE,4BAA4B,EAAE,MAAM,SAAS,CAAA;AAG7E,MAAM,CAAC,OAAO,UAAU,yBAAyB,CAAC,CAAC,SAAS,cAAc,EACxE,MAAM,EAAE,eAAe,EACvB,KAAK,EAAE,MAAM,GACZ,4BAA4B,CAAC,CAAC,CAAC,CAoBjC;AAED,OAAO,EAAE,qBAAqB,EAAE,4BAA4B,EAAE,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/selectors/ModelCategory/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,cAAc,EACd,eAAe,EAGhB,MAAM,aAAa,CAAA;AACpB,OAAO,EACL,qBAAqB,EACrB,4BAA4B,EAC5B,0BAA0B,EAC3B,MAAM,SAAS,CAAA;AAGhB,MAAM,CAAC,OAAO,UAAU,yBAAyB,CAAC,CAAC,SAAS,cAAc,EACxE,MAAM,EAAE,eAAe,EACvB,KAAK,EAAE,MAAM,GACZ,4BAA4B,CAAC,CAAC,CAAC,CAoBjC;AAED,OAAO,EACL,qBAAqB,EACrB,4BAA4B,EAC5B,0BAA0B,GAC3B,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/selectors/ModelCategory/index.ts"],"names":[],"mappings":"AAQA,OAAO,yBAAyB,MAAM,+BAA+B,CAAA;AAErE,MAAM,CAAC,OAAO,UAAU,yBAAyB,CAC/C,MAAuB,EACvB,KAAa;IAEb,MAAM,QAAQ,GAA0B;QACtC,IAAI,CAAC,OAAO;YACV,OAAO,MAAM,CAAC,GAAG,CAAC,WAAW,KAAK,aAAa,oBAAO,OAAO,EAAG,CAAA;QAClE,CAAC;QAED,GAAG,CAAC,IAAI;YACN,OAAO,MAAM,CAAC,GAAG,CAAC,WAAW,KAAK,eAAe,IAAI,EAAE,CAAC,CAAA;QAC1D,CAAC;KACF,CAAA;IAED,OAAO,IAAI,KAAK,CAAC,QAAQ,EAAE;QACzB,GAAG,CAAC,MAAM,EAAE,IAAI;YACd,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,EAAE;gBAC1D,OAAO,yBAAyB,CAAC,MAAM,EAAE,KAAK,EAAE,IAAI,CAAC,CAAA;aACtD;YAED,OAAO,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,CAAA;QAClC,CAAC;KACF,CAAoC,CAAA;AACvC,CAAC","sourcesContent":["import {\n ModelCategory,\n SerializedData,\n StarlightClient,\n StarlightItemResponse,\n StarlightListResponse,\n} from '../../types'\nimport { ModelCategorySelector, DynamicModelCategorySelector } from './types'\nimport makeModelCategoryInstance from '../../instances/ModelCategory'\n\nexport default function makeModelCategorySelector<D extends SerializedData>(\n client: StarlightClient,\n model: string\n): DynamicModelCategorySelector<D> {\n const selector: ModelCategorySelector = {\n list(options): Promise<StarlightListResponse<ModelCategory>> {\n return client.get(`/models/${model}/categories`, { ...options })\n },\n\n get(slug): Promise<StarlightItemResponse<ModelCategory>> {\n return client.get(`/models/${model}/categories/${slug}`)\n },\n }\n\n return new Proxy(selector, {\n get(target, prop) {\n if (typeof prop === 'string' && !Reflect.has(target, prop)) {\n return makeModelCategoryInstance(client, model, prop)\n }\n\n return Reflect.get(target, prop)\n },\n }) as DynamicModelCategorySelector<D>\n}\n\nexport { ModelCategorySelector, DynamicModelCategorySelector }\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/selectors/ModelCategory/index.ts"],"names":[],"mappings":"AAYA,OAAO,yBAAyB,MAAM,+BAA+B,CAAA;AAErE,MAAM,CAAC,OAAO,UAAU,yBAAyB,CAC/C,MAAuB,EACvB,KAAa;IAEb,MAAM,QAAQ,GAA0B;QACtC,IAAI,CAAC,OAAO;YACV,OAAO,MAAM,CAAC,GAAG,CAAC,WAAW,KAAK,aAAa,oBAAO,OAAO,EAAG,CAAA;QAClE,CAAC;QAED,GAAG,CAAC,IAAI;YACN,OAAO,MAAM,CAAC,GAAG,CAAC,WAAW,KAAK,eAAe,IAAI,EAAE,CAAC,CAAA;QAC1D,CAAC;KACF,CAAA;IAED,OAAO,IAAI,KAAK,CAAC,QAAQ,EAAE;QACzB,GAAG,CAAC,MAAM,EAAE,IAAI;YACd,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,EAAE;gBAC1D,OAAO,yBAAyB,CAAC,MAAM,EAAE,KAAK,EAAE,IAAI,CAAC,CAAA;aACtD;YAED,OAAO,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,CAAA;QAClC,CAAC;KACF,CAAoC,CAAA;AACvC,CAAC","sourcesContent":["import {\n ModelCategory,\n SerializedData,\n StarlightClient,\n StarlightItemResponse,\n StarlightListResponse,\n} from '../../types'\nimport {\n ModelCategorySelector,\n DynamicModelCategorySelector,\n ListModelCategoriesOptions,\n} from './types'\nimport makeModelCategoryInstance from '../../instances/ModelCategory'\n\nexport default function makeModelCategorySelector<D extends SerializedData>(\n client: StarlightClient,\n model: string\n): DynamicModelCategorySelector<D> {\n const selector: ModelCategorySelector = {\n list(options): Promise<StarlightListResponse<ModelCategory>> {\n return client.get(`/models/${model}/categories`, { ...options })\n },\n\n get(slug): Promise<StarlightItemResponse<ModelCategory>> {\n return client.get(`/models/${model}/categories/${slug}`)\n },\n }\n\n return new Proxy(selector, {\n get(target, prop) {\n if (typeof prop === 'string' && !Reflect.has(target, prop)) {\n return makeModelCategoryInstance(client, model, prop)\n }\n\n return Reflect.get(target, prop)\n },\n }) as DynamicModelCategorySelector<D>\n}\n\nexport {\n ModelCategorySelector,\n DynamicModelCategorySelector,\n ListModelCategoriesOptions,\n}\n"]}
@@ -1,11 +1,18 @@
1
1
  import { BaseRequestParameters, ModelCategory, SerializedData, StarlightItemResponse, StarlightListResponse } from '../../types';
2
2
  import { ModelCategoryInstance } from '../../instances/ModelCategory';
3
+ /**
4
+ * Request parameters for listing model categories.
5
+ *
6
+ * Used by {@apilink ModelCategorySelector.list}.
7
+ *
8
+ * @group Request Parameters
9
+ */
3
10
  export interface ListModelCategoriesOptions extends BaseRequestParameters {
4
11
  /**
5
12
  * Define how items will be ordered. Check this field type to see the
6
13
  * allowed options.
7
14
  */
8
- order?: 'title:asc' | 'title:desc' | 'entry_count:asc' | 'entry_count:desc';
15
+ order?: 'title:asc' | 'title:desc' | 'entry_count:asc' | 'entry_count:desc' | 'slug:asc' | 'slug:desc' | 'created_at:asc' | 'created_at:desc' | 'updated_at:asc' | 'updated_at:desc';
9
16
  }
10
17
  /**
11
18
  * A Selector that provide methods to list and request information on
@@ -17,6 +24,20 @@ export interface ListModelCategoriesOptions extends BaseRequestParameters {
17
24
  * @group Selectors
18
25
  */
19
26
  export interface ModelCategorySelector {
27
+ /**
28
+ * Returns a {@link StarlightListResponse} with a list of
29
+ * {@apilink ModelCategory | ModelCategories}.
30
+ *
31
+ * @example Requesting all categories from a model.
32
+ * ```ts
33
+ * import Starlight from '@starlightcms/js-sdk'
34
+ *
35
+ * const response = await Starlight.posts.categories.list()
36
+ * ```
37
+ *
38
+ * @param options An optional object of request parameters. See
39
+ * {@link ListModelCategoriesOptions} for all available options.
40
+ */
20
41
  list(options?: ListModelCategoriesOptions): Promise<StarlightListResponse<ModelCategory>>;
21
42
  /**
22
43
  * Returns a {@link StarlightItemResponse} with a single {@link ModelCategory}.
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/selectors/ModelCategory/types.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,EACrB,aAAa,EACb,cAAc,EACd,qBAAqB,EACrB,qBAAqB,EACtB,MAAM,aAAa,CAAA;AACpB,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAA;AAErE,MAAM,WAAW,0BAA2B,SAAQ,qBAAqB;IACvE;;;OAGG;IACH,KAAK,CAAC,EAAE,WAAW,GAAG,YAAY,GAAG,iBAAiB,GAAG,kBAAkB,CAAA;CAC5E;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,qBAAqB;IACpC,IAAI,CACF,OAAO,CAAC,EAAE,0BAA0B,GACnC,OAAO,CAAC,qBAAqB,CAAC,aAAa,CAAC,CAAC,CAAA;IAEhD;;;;;;;;;;;OAWG;IACH,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,qBAAqB,CAAC,aAAa,CAAC,CAAC,CAAA;CACjE;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,oBAAY,4BAA4B,CAAC,CAAC,SAAS,cAAc,IAC/D,qBAAqB,GAAG;IACtB,CAAC,IAAI,EAAE,MAAM,GAAG,qBAAqB,CAAC,CAAC,CAAC,CAAA;CACzC,CAAA"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/selectors/ModelCategory/types.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,EACrB,aAAa,EACb,cAAc,EACd,qBAAqB,EACrB,qBAAqB,EACtB,MAAM,aAAa,CAAA;AACpB,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAA;AAErE;;;;;;GAMG;AACH,MAAM,WAAW,0BAA2B,SAAQ,qBAAqB;IACvE;;;OAGG;IACH,KAAK,CAAC,EACF,WAAW,GACX,YAAY,GACZ,iBAAiB,GACjB,kBAAkB,GAClB,UAAU,GACV,WAAW,GACX,gBAAgB,GAChB,iBAAiB,GACjB,gBAAgB,GAChB,iBAAiB,CAAA;CACtB;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,qBAAqB;IACpC;;;;;;;;;;;;;OAaG;IACH,IAAI,CACF,OAAO,CAAC,EAAE,0BAA0B,GACnC,OAAO,CAAC,qBAAqB,CAAC,aAAa,CAAC,CAAC,CAAA;IAEhD;;;;;;;;;;;OAWG;IACH,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,qBAAqB,CAAC,aAAa,CAAC,CAAC,CAAA;CACjE;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,oBAAY,4BAA4B,CAAC,CAAC,SAAS,cAAc,IAC/D,qBAAqB,GAAG;IACtB,CAAC,IAAI,EAAE,MAAM,GAAG,qBAAqB,CAAC,CAAC,CAAC,CAAA;CACzC,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/selectors/ModelCategory/types.ts"],"names":[],"mappings":"","sourcesContent":["import {\n BaseRequestParameters,\n ModelCategory,\n SerializedData,\n StarlightItemResponse,\n StarlightListResponse,\n} from '../../types'\nimport { ModelCategoryInstance } from '../../instances/ModelCategory'\n\nexport interface ListModelCategoriesOptions extends BaseRequestParameters {\n /**\n * Define how items will be ordered. Check this field type to see the\n * allowed options.\n */\n order?: 'title:asc' | 'title:desc' | 'entry_count:asc' | 'entry_count:desc'\n}\n\n/**\n * A Selector that provide methods to list and request information on\n * {@apilink ModelCategory | ModelCategories}.\n *\n * You can use a ModelCategorySelector by accessing\n * {@apilink ModelInstance.categories}.\n *\n * @group Selectors\n */\nexport interface ModelCategorySelector {\n list(\n options?: ListModelCategoriesOptions\n ): Promise<StarlightListResponse<ModelCategory>>\n\n /**\n * Returns a {@link StarlightItemResponse} with a single {@link ModelCategory}.\n *\n * @example Requesting information from a category \"premium\" from a model of slug \"plans\".\n * ```ts\n * import Starlight from '@starlightcms/js-sdk'\n *\n * const response = await Starlight.plans.premium.get()\n * ```\n *\n * @param slug The category slug.\n */\n get(slug: string): Promise<StarlightItemResponse<ModelCategory>>\n}\n\n/**\n * A Selector that provide all {@link ModelCategorySelector} methods and adds\n * support for creating {@apilink ModelCategoryInstance | ModelCategoryInstances}\n * using the dynamic syntax.\n *\n * See {@link ModelCategorySelector} to view all available methods. You can use\n * a DynamicModelCategorySelector by accessing {@apilink ModelInstance.categories}.\n *\n * See {@doclink requests-and-responses#dynamic-syntax | Dynamic Instances}\n * documentation to learn more about the dynamic syntax.\n *\n * @example Accessing a ModelCategorySelector using the dynamic syntax on a model of slug \"posts\"\n * ```ts\n * import Starlight from '@starlightcms/js-sdk'\n *\n * // \"articles\" below will be a ModelCategorySelector.\n * const response = await Starlight.posts.categories.articles.list()\n * ```\n *\n * @category Instances\n */\nexport type DynamicModelCategorySelector<D extends SerializedData> =\n ModelCategorySelector & {\n [slug: string]: ModelCategoryInstance<D>\n }\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/selectors/ModelCategory/types.ts"],"names":[],"mappings":"","sourcesContent":["import {\n BaseRequestParameters,\n ModelCategory,\n SerializedData,\n StarlightItemResponse,\n StarlightListResponse,\n} from '../../types'\nimport { ModelCategoryInstance } from '../../instances/ModelCategory'\n\n/**\n * Request parameters for listing model categories.\n *\n * Used by {@apilink ModelCategorySelector.list}.\n *\n * @group Request Parameters\n */\nexport interface ListModelCategoriesOptions extends BaseRequestParameters {\n /**\n * Define how items will be ordered. Check this field type to see the\n * allowed options.\n */\n order?:\n | 'title:asc'\n | 'title:desc'\n | 'entry_count:asc'\n | 'entry_count:desc'\n | 'slug:asc'\n | 'slug:desc'\n | 'created_at:asc'\n | 'created_at:desc'\n | 'updated_at:asc'\n | 'updated_at:desc'\n}\n\n/**\n * A Selector that provide methods to list and request information on\n * {@apilink ModelCategory | ModelCategories}.\n *\n * You can use a ModelCategorySelector by accessing\n * {@apilink ModelInstance.categories}.\n *\n * @group Selectors\n */\nexport interface ModelCategorySelector {\n /**\n * Returns a {@link StarlightListResponse} with a list of\n * {@apilink ModelCategory | ModelCategories}.\n *\n * @example Requesting all categories from a model.\n * ```ts\n * import Starlight from '@starlightcms/js-sdk'\n *\n * const response = await Starlight.posts.categories.list()\n * ```\n *\n * @param options An optional object of request parameters. See\n * {@link ListModelCategoriesOptions} for all available options.\n */\n list(\n options?: ListModelCategoriesOptions\n ): Promise<StarlightListResponse<ModelCategory>>\n\n /**\n * Returns a {@link StarlightItemResponse} with a single {@link ModelCategory}.\n *\n * @example Requesting information from a category \"premium\" from a model of slug \"plans\".\n * ```ts\n * import Starlight from '@starlightcms/js-sdk'\n *\n * const response = await Starlight.plans.premium.get()\n * ```\n *\n * @param slug The category slug.\n */\n get(slug: string): Promise<StarlightItemResponse<ModelCategory>>\n}\n\n/**\n * A Selector that provide all {@link ModelCategorySelector} methods and adds\n * support for creating {@apilink ModelCategoryInstance | ModelCategoryInstances}\n * using the dynamic syntax.\n *\n * See {@link ModelCategorySelector} to view all available methods. You can use\n * a DynamicModelCategorySelector by accessing {@apilink ModelInstance.categories}.\n *\n * See {@doclink requests-and-responses#dynamic-syntax | Dynamic Instances}\n * documentation to learn more about the dynamic syntax.\n *\n * @example Accessing a ModelCategorySelector using the dynamic syntax on a model of slug \"posts\"\n * ```ts\n * import Starlight from '@starlightcms/js-sdk'\n *\n * // \"articles\" below will be a ModelCategorySelector.\n * const response = await Starlight.posts.categories.articles.list()\n * ```\n *\n * @category Instances\n */\nexport type DynamicModelCategorySelector<D extends SerializedData> =\n ModelCategorySelector & {\n [slug: string]: ModelCategoryInstance<D>\n }\n"]}
@@ -1,7 +1,7 @@
1
- export { ModelCategorySelector, DynamicModelCategorySelector, } from '../selectors/ModelCategory';
1
+ export { ModelCategorySelector, DynamicModelCategorySelector, ListModelCategoriesOptions, } from '../selectors/ModelCategory';
2
2
  export { ModelSelector, DynamicModelSelector } from '../selectors/Model';
3
3
  export { CollectionSelector, DynamicCollectionSelector, ListCollectionsParams, } from '../selectors/Collection';
4
- export { EntrySelector } from '../selectors/Entry';
4
+ export { EntrySelector, ListEntriesParams } from '../selectors/Entry';
5
5
  export { MediaSelector } from '../selectors/Media';
6
6
  export { SearchSelector, SearchEntriesParams } from '../selectors/Search';
7
7
  export { SingletonSelector } from '../selectors/Singleton';
@@ -1 +1 @@
1
- {"version":3,"file":"selectors.d.ts","sourceRoot":"","sources":["../../../src/types/selectors.ts"],"names":[],"mappings":"AACA,OAAO,EACL,qBAAqB,EACrB,4BAA4B,GAC7B,MAAM,4BAA4B,CAAA;AACnC,OAAO,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAA;AACxE,OAAO,EACL,kBAAkB,EAClB,yBAAyB,EACzB,qBAAqB,GACtB,MAAM,yBAAyB,CAAA;AAChC,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAClD,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAA;AACzE,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA"}
1
+ {"version":3,"file":"selectors.d.ts","sourceRoot":"","sources":["../../../src/types/selectors.ts"],"names":[],"mappings":"AACA,OAAO,EACL,qBAAqB,EACrB,4BAA4B,EAC5B,0BAA0B,GAC3B,MAAM,4BAA4B,CAAA;AACnC,OAAO,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAA;AACxE,OAAO,EACL,kBAAkB,EAClB,yBAAyB,EACzB,qBAAqB,GACtB,MAAM,yBAAyB,CAAA;AAChC,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAA;AACrE,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAClD,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAA;AACzE,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"selectors.js","sourceRoot":"","sources":["../../../src/types/selectors.ts"],"names":[],"mappings":"","sourcesContent":["// Selector types are exported here so they are visible in the API docs.\nexport {\n ModelCategorySelector,\n DynamicModelCategorySelector,\n} from '../selectors/ModelCategory'\nexport { ModelSelector, DynamicModelSelector } from '../selectors/Model'\nexport {\n CollectionSelector,\n DynamicCollectionSelector,\n ListCollectionsParams,\n} from '../selectors/Collection'\nexport { EntrySelector } from '../selectors/Entry'\nexport { MediaSelector } from '../selectors/Media'\nexport { SearchSelector, SearchEntriesParams } from '../selectors/Search'\nexport { SingletonSelector } from '../selectors/Singleton'\n"]}
1
+ {"version":3,"file":"selectors.js","sourceRoot":"","sources":["../../../src/types/selectors.ts"],"names":[],"mappings":"","sourcesContent":["// Selector types are exported here so they are visible in the API docs.\nexport {\n ModelCategorySelector,\n DynamicModelCategorySelector,\n ListModelCategoriesOptions,\n} from '../selectors/ModelCategory'\nexport { ModelSelector, DynamicModelSelector } from '../selectors/Model'\nexport {\n CollectionSelector,\n DynamicCollectionSelector,\n ListCollectionsParams,\n} from '../selectors/Collection'\nexport { EntrySelector, ListEntriesParams } from '../selectors/Entry'\nexport { MediaSelector } from '../selectors/Media'\nexport { SearchSelector, SearchEntriesParams } from '../selectors/Search'\nexport { SingletonSelector } from '../selectors/Singleton'\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@starlightcms/js-sdk",
3
- "version": "0.12.1",
3
+ "version": "0.13.1",
4
4
  "description": "The Starlight SDK for JavaScript",
5
5
  "workspaces": [
6
6
  "website"
@@ -22,7 +22,10 @@
22
22
  "docs:serve": "npm run serve -w website",
23
23
  "prepare": "husky install",
24
24
  "prepublishOnly": "npm run build",
25
- "test": "echo \"Error: no test specified\" && exit 1"
25
+ "test": "vitest",
26
+ "coverage": "vitest run --coverage",
27
+ "type-check": "tsc --pretty --noEmit",
28
+ "lint": "eslint"
26
29
  },
27
30
  "files": [
28
31
  "dist/**/*"
@@ -45,16 +48,22 @@
45
48
  "@types/node": "^16.10.1",
46
49
  "@typescript-eslint/eslint-plugin": "^4.31.2",
47
50
  "@typescript-eslint/parser": "^4.31.2",
51
+ "@vitest/coverage-c8": "^0.24.3",
52
+ "cross-fetch": "^3.1.5",
48
53
  "eslint": "^7.32.0",
49
54
  "eslint-config-prettier": "^8.3.0",
50
55
  "husky": "^7.0.2",
56
+ "jsdom": "^20.0.1",
51
57
  "lint-staged": "^11.1.2",
58
+ "msw": "^0.47.4",
52
59
  "prettier": "2.4.1",
60
+ "rimraf": "^3.0.2",
53
61
  "typescript": "^4.4.3",
54
- "rimraf": "^3.0.2"
62
+ "vitest": "^0.24.3"
55
63
  },
56
64
  "lint-staged": {
57
65
  "*.{ts}": [
66
+ "vitest --passWithNoTests",
58
67
  "eslint --cache --fix",
59
68
  "prettier --write"
60
69
  ]