@starlightcms/js-sdk 0.10.0 → 0.11.0

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 (144) hide show
  1. package/README.md +54 -0
  2. package/dist/cjs/client.d.ts +5 -5
  3. package/dist/cjs/client.js +5 -5
  4. package/dist/cjs/client.js.map +1 -1
  5. package/dist/cjs/errors.d.ts +23 -0
  6. package/dist/cjs/errors.d.ts.map +1 -1
  7. package/dist/cjs/errors.js.map +1 -1
  8. package/dist/cjs/index.d.ts +5 -4
  9. package/dist/cjs/index.d.ts.map +1 -1
  10. package/dist/cjs/index.js +5 -4
  11. package/dist/cjs/index.js.map +1 -1
  12. package/dist/cjs/instances/Collection/index.d.ts +2 -2
  13. package/dist/cjs/instances/Collection/index.d.ts.map +1 -1
  14. package/dist/cjs/instances/Collection/index.js.map +1 -1
  15. package/dist/cjs/instances/Collection/types.d.ts +25 -13
  16. package/dist/cjs/instances/Collection/types.d.ts.map +1 -1
  17. package/dist/cjs/instances/Collection/types.js +1 -0
  18. package/dist/cjs/instances/Collection/types.js.map +1 -1
  19. package/dist/cjs/instances/Model/types.d.ts +83 -0
  20. package/dist/cjs/instances/Model/types.d.ts.map +1 -1
  21. package/dist/cjs/instances/Model/types.js.map +1 -1
  22. package/dist/cjs/instances/ModelCategory/index.d.ts +2 -2
  23. package/dist/cjs/instances/ModelCategory/index.d.ts.map +1 -1
  24. package/dist/cjs/instances/ModelCategory/index.js.map +1 -1
  25. package/dist/cjs/instances/ModelCategory/types.d.ts +62 -10
  26. package/dist/cjs/instances/ModelCategory/types.d.ts.map +1 -1
  27. package/dist/cjs/instances/ModelCategory/types.js.map +1 -1
  28. package/dist/cjs/selectors/Collection/index.d.ts +2 -2
  29. package/dist/cjs/selectors/Collection/index.d.ts.map +1 -1
  30. package/dist/cjs/selectors/Collection/index.js +1 -1
  31. package/dist/cjs/selectors/Collection/index.js.map +1 -1
  32. package/dist/cjs/selectors/Collection/types.d.ts +82 -7
  33. package/dist/cjs/selectors/Collection/types.d.ts.map +1 -1
  34. package/dist/cjs/selectors/Collection/types.js.map +1 -1
  35. package/dist/cjs/selectors/Entry/types.d.ts +105 -10
  36. package/dist/cjs/selectors/Entry/types.d.ts.map +1 -1
  37. package/dist/cjs/selectors/Entry/types.js.map +1 -1
  38. package/dist/cjs/selectors/Media/index.js +2 -2
  39. package/dist/cjs/selectors/Media/index.js.map +1 -1
  40. package/dist/cjs/selectors/Media/types.d.ts +35 -1
  41. package/dist/cjs/selectors/Media/types.d.ts.map +1 -1
  42. package/dist/cjs/selectors/Media/types.js.map +1 -1
  43. package/dist/cjs/selectors/Model/types.d.ts +59 -0
  44. package/dist/cjs/selectors/Model/types.d.ts.map +1 -1
  45. package/dist/cjs/selectors/Model/types.js.map +1 -1
  46. package/dist/cjs/selectors/ModelCategory/index.js +1 -1
  47. package/dist/cjs/selectors/ModelCategory/index.js.map +1 -1
  48. package/dist/cjs/selectors/ModelCategory/types.d.ts +49 -6
  49. package/dist/cjs/selectors/ModelCategory/types.d.ts.map +1 -1
  50. package/dist/cjs/selectors/ModelCategory/types.js.map +1 -1
  51. package/dist/cjs/selectors/Search/index.d.ts +2 -2
  52. package/dist/cjs/selectors/Search/index.d.ts.map +1 -1
  53. package/dist/cjs/selectors/Search/index.js +1 -1
  54. package/dist/cjs/selectors/Search/index.js.map +1 -1
  55. package/dist/cjs/selectors/Search/types.d.ts +80 -7
  56. package/dist/cjs/selectors/Search/types.d.ts.map +1 -1
  57. package/dist/cjs/selectors/Search/types.js.map +1 -1
  58. package/dist/cjs/selectors/Singleton/types.d.ts +49 -0
  59. package/dist/cjs/selectors/Singleton/types.d.ts.map +1 -1
  60. package/dist/cjs/selectors/Singleton/types.js.map +1 -1
  61. package/dist/cjs/types/entities.d.ts +89 -8
  62. package/dist/cjs/types/entities.d.ts.map +1 -1
  63. package/dist/cjs/types/entities.js.map +1 -1
  64. package/dist/cjs/types/index.d.ts +98 -8
  65. package/dist/cjs/types/index.d.ts.map +1 -1
  66. package/dist/cjs/types/index.js.map +1 -1
  67. package/dist/cjs/types/instances.d.ts +2 -2
  68. package/dist/cjs/types/instances.d.ts.map +1 -1
  69. package/dist/cjs/types/instances.js.map +1 -1
  70. package/dist/cjs/types/selectors.d.ts +2 -2
  71. package/dist/cjs/types/selectors.d.ts.map +1 -1
  72. package/dist/cjs/types/selectors.js.map +1 -1
  73. package/dist/esm/client.d.ts +5 -5
  74. package/dist/esm/client.js +5 -5
  75. package/dist/esm/client.js.map +1 -1
  76. package/dist/esm/errors.d.ts +23 -0
  77. package/dist/esm/errors.d.ts.map +1 -1
  78. package/dist/esm/errors.js.map +1 -1
  79. package/dist/esm/index.d.ts +5 -4
  80. package/dist/esm/index.d.ts.map +1 -1
  81. package/dist/esm/index.js +5 -4
  82. package/dist/esm/index.js.map +1 -1
  83. package/dist/esm/instances/Collection/index.d.ts +2 -2
  84. package/dist/esm/instances/Collection/index.d.ts.map +1 -1
  85. package/dist/esm/instances/Collection/index.js.map +1 -1
  86. package/dist/esm/instances/Collection/types.d.ts +25 -13
  87. package/dist/esm/instances/Collection/types.d.ts.map +1 -1
  88. package/dist/esm/instances/Collection/types.js +1 -0
  89. package/dist/esm/instances/Collection/types.js.map +1 -1
  90. package/dist/esm/instances/Model/types.d.ts +83 -0
  91. package/dist/esm/instances/Model/types.d.ts.map +1 -1
  92. package/dist/esm/instances/Model/types.js.map +1 -1
  93. package/dist/esm/instances/ModelCategory/index.d.ts +2 -2
  94. package/dist/esm/instances/ModelCategory/index.d.ts.map +1 -1
  95. package/dist/esm/instances/ModelCategory/index.js.map +1 -1
  96. package/dist/esm/instances/ModelCategory/types.d.ts +62 -10
  97. package/dist/esm/instances/ModelCategory/types.d.ts.map +1 -1
  98. package/dist/esm/instances/ModelCategory/types.js.map +1 -1
  99. package/dist/esm/selectors/Collection/index.d.ts +2 -2
  100. package/dist/esm/selectors/Collection/index.d.ts.map +1 -1
  101. package/dist/esm/selectors/Collection/index.js +1 -1
  102. package/dist/esm/selectors/Collection/index.js.map +1 -1
  103. package/dist/esm/selectors/Collection/types.d.ts +82 -7
  104. package/dist/esm/selectors/Collection/types.d.ts.map +1 -1
  105. package/dist/esm/selectors/Collection/types.js.map +1 -1
  106. package/dist/esm/selectors/Entry/types.d.ts +105 -10
  107. package/dist/esm/selectors/Entry/types.d.ts.map +1 -1
  108. package/dist/esm/selectors/Entry/types.js.map +1 -1
  109. package/dist/esm/selectors/Media/index.js +2 -2
  110. package/dist/esm/selectors/Media/index.js.map +1 -1
  111. package/dist/esm/selectors/Media/types.d.ts +35 -1
  112. package/dist/esm/selectors/Media/types.d.ts.map +1 -1
  113. package/dist/esm/selectors/Media/types.js.map +1 -1
  114. package/dist/esm/selectors/Model/types.d.ts +59 -0
  115. package/dist/esm/selectors/Model/types.d.ts.map +1 -1
  116. package/dist/esm/selectors/Model/types.js.map +1 -1
  117. package/dist/esm/selectors/ModelCategory/index.js +1 -1
  118. package/dist/esm/selectors/ModelCategory/index.js.map +1 -1
  119. package/dist/esm/selectors/ModelCategory/types.d.ts +49 -6
  120. package/dist/esm/selectors/ModelCategory/types.d.ts.map +1 -1
  121. package/dist/esm/selectors/ModelCategory/types.js.map +1 -1
  122. package/dist/esm/selectors/Search/index.d.ts +2 -2
  123. package/dist/esm/selectors/Search/index.d.ts.map +1 -1
  124. package/dist/esm/selectors/Search/index.js +1 -1
  125. package/dist/esm/selectors/Search/index.js.map +1 -1
  126. package/dist/esm/selectors/Search/types.d.ts +80 -7
  127. package/dist/esm/selectors/Search/types.d.ts.map +1 -1
  128. package/dist/esm/selectors/Search/types.js.map +1 -1
  129. package/dist/esm/selectors/Singleton/types.d.ts +49 -0
  130. package/dist/esm/selectors/Singleton/types.d.ts.map +1 -1
  131. package/dist/esm/selectors/Singleton/types.js.map +1 -1
  132. package/dist/esm/types/entities.d.ts +89 -8
  133. package/dist/esm/types/entities.d.ts.map +1 -1
  134. package/dist/esm/types/entities.js.map +1 -1
  135. package/dist/esm/types/index.d.ts +98 -8
  136. package/dist/esm/types/index.d.ts.map +1 -1
  137. package/dist/esm/types/index.js.map +1 -1
  138. package/dist/esm/types/instances.d.ts +2 -2
  139. package/dist/esm/types/instances.d.ts.map +1 -1
  140. package/dist/esm/types/instances.js.map +1 -1
  141. package/dist/esm/types/selectors.d.ts +2 -2
  142. package/dist/esm/types/selectors.d.ts.map +1 -1
  143. package/dist/esm/types/selectors.js.map +1 -1
  144. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/instances/ModelCategory/index.ts"],"names":[],"mappings":"AAUA,MAAM,CAAC,OAAO,UAAU,yBAAyB,CAC/C,MAAuB,EACvB,KAAa,EACb,QAAgB;IAEhB,OAAO;QACL,GAAG;YACD,OAAO,MAAM,CAAC,GAAG,CAAC,WAAW,KAAK,eAAe,QAAQ,EAAE,CAAC,CAAA;QAC9D,CAAC;QACD,OAAO,CACL,OAAyC;YAEzC,OAAO,MAAM,CAAC,GAAG,CACf,WAAW,KAAK,eAAe,QAAQ,UAAU,EACjD,OAAO,CACR,CAAA;QACH,CAAC;KACF,CAAA;AACH,CAAC","sourcesContent":["import {\n Entry,\n ModelCategory,\n SerializedData,\n StarlightClient,\n StarlightItemResponse,\n StarlightListResponse,\n} from '../../types'\nimport { ModelCategoryInstance, ModelCategoryEntryListOptions } from './types'\n\nexport default function makeModelCategoryInstance<D extends SerializedData>(\n client: StarlightClient,\n model: string,\n category: string\n): ModelCategoryInstance<D> {\n return {\n get(): Promise<StarlightItemResponse<ModelCategory>> {\n return client.get(`/models/${model}/categories/${category}`)\n },\n entries(\n options: ModelCategoryEntryListOptions<D>\n ): Promise<StarlightListResponse<Entry<D>>> {\n return client.get(\n `/models/${model}/categories/${category}/entries`,\n options\n )\n },\n }\n}\n\nexport { ModelCategoryInstance }\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/instances/ModelCategory/index.ts"],"names":[],"mappings":"AAWA,MAAM,CAAC,OAAO,UAAU,yBAAyB,CAC/C,MAAuB,EACvB,KAAa,EACb,QAAgB;IAEhB,OAAO;QACL,GAAG;YACD,OAAO,MAAM,CAAC,GAAG,CAAC,WAAW,KAAK,eAAe,QAAQ,EAAE,CAAC,CAAA;QAC9D,CAAC;QACD,OAAO,CACL,OAA0D;YAE1D,OAAO,MAAM,CAAC,GAAG,CACf,WAAW,KAAK,eAAe,QAAQ,UAAU,EACjD,OAAO,CACR,CAAA;QACH,CAAC;KACF,CAAA;AACH,CAAC","sourcesContent":["import {\n Entry,\n ModelCategory,\n QueryableFields,\n SerializedData,\n StarlightClient,\n StarlightItemResponse,\n StarlightListResponse,\n} from '../../types'\nimport { ModelCategoryInstance, ModelCategoryEntryListParams } from './types'\n\nexport default function makeModelCategoryInstance<D extends SerializedData>(\n client: StarlightClient,\n model: string,\n category: string\n): ModelCategoryInstance<D> {\n return {\n get(): Promise<StarlightItemResponse<ModelCategory>> {\n return client.get(`/models/${model}/categories/${category}`)\n },\n entries(\n options: ModelCategoryEntryListParams & QueryableFields<D>\n ): Promise<StarlightListResponse<Entry<D>>> {\n return client.get(\n `/models/${model}/categories/${category}/entries`,\n options\n )\n },\n }\n}\n\nexport { ModelCategoryInstance, ModelCategoryEntryListParams }\n"]}
@@ -1,15 +1,67 @@
1
- import { Entry, ModelCategory, ModelFieldOptions, SerializedData, StarlightItemResponse, StarlightListResponse } from '../../types';
2
- export declare type ModelCategoryEntryListOptions<D extends SerializedData> = {
3
- page?: number;
4
- limit?: number;
5
- query?: string;
6
- 'query:word'?: string;
7
- fields?: string;
1
+ import { BaseRequestParameters, Entry, ModelCategory, QueryableFields, QueryableRequestParameters, SerializedData, StarlightItemResponse, StarlightListResponse } from '../../types';
2
+ /**
3
+ * Request parameters for listing category entries.
4
+ *
5
+ * Used by {@apilink ModelCategoryInstance.entries}.
6
+ *
7
+ * @group Request Parameters
8
+ */
9
+ export interface ModelCategoryEntryListParams extends BaseRequestParameters, QueryableRequestParameters {
10
+ /**
11
+ * Define how entries will be ordered. Check this field type to see the
12
+ * allowed options.
13
+ */
8
14
  order?: 'title:asc' | 'title:desc' | 'published_at:asc' | 'published_at:desc' | 'views:asc' | 'views:desc';
9
- except?: number;
10
- } & ModelFieldOptions<D>;
15
+ }
16
+ /**
17
+ * An Instance that provide methods to request information from a
18
+ * {@link ModelCategory} and its {@apilink Entry | Entries}.
19
+ *
20
+ * You can access a ModelCategoryInstance using
21
+ * {@apilink ModelInstance.category} or using the dynamic syntax on a
22
+ * {@link DynamicModelInstance}. Usage examples will use the dynamic syntax.
23
+ *
24
+ * To list all categories from a model, use a {@link ModelCategorySelector}.
25
+ *
26
+ * @group Instances
27
+ */
11
28
  export interface ModelCategoryInstance<D extends SerializedData> {
29
+ /**
30
+ * Returns a {@link StarlightItemResponse} with a single {@link ModelCategory}.
31
+ *
32
+ * @example Requesting information from a category called "articles" in a model of slug "posts".
33
+ * ```ts
34
+ * import Starlight from '@starlightcms/js-sdk'
35
+ *
36
+ * const response = await Starlight.posts.articles.get()
37
+ * ```
38
+ */
12
39
  get(): Promise<StarlightItemResponse<ModelCategory>>;
13
- entries(options?: ModelCategoryEntryListOptions<D>): Promise<StarlightListResponse<Entry<D>>>;
40
+ /**
41
+ * Returns a {@link StarlightListResponse} with the list of entries of this
42
+ * {@link ModelCategory}.
43
+ *
44
+ * @example Requesting all items from a category called "gaming" in a model of slug "posts".
45
+ * ```ts
46
+ * import Starlight from '@starlightcms/js-sdk'
47
+ *
48
+ * const response = await Starlight.posts.gaming.items()
49
+ * ```
50
+ *
51
+ * @example Paginating and searching on the last example.
52
+ * ```ts
53
+ * import Starlight from '@starlightcms/js-sdk'
54
+ *
55
+ * const response = await Starlight.posts.gaming.items({
56
+ * page: 5,
57
+ * query: 'kirby'
58
+ * })
59
+ * ```
60
+ *
61
+ * @param options An optional object of request parameters. See
62
+ * {@link ModelCategoryEntryListParams} for all available options. `field:foo`
63
+ * syntax is also supported, see {@link QueryableFields} for more info.
64
+ */
65
+ entries(options?: ModelCategoryEntryListParams & QueryableFields<D>): Promise<StarlightListResponse<Entry<D>>>;
14
66
  }
15
67
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/instances/ModelCategory/types.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,EACL,aAAa,EACb,iBAAiB,EACjB,cAAc,EACd,qBAAqB,EACrB,qBAAqB,EACtB,MAAM,aAAa,CAAA;AAEpB,oBAAY,6BAA6B,CAAC,CAAC,SAAS,cAAc,IAAI;IACpE,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,KAAK,CAAC,EACF,WAAW,GACX,YAAY,GACZ,kBAAkB,GAClB,mBAAmB,GACnB,WAAW,GACX,YAAY,CAAA;IAChB,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB,GAAG,iBAAiB,CAAC,CAAC,CAAC,CAAA;AAExB,MAAM,WAAW,qBAAqB,CAAC,CAAC,SAAS,cAAc;IAC7D,GAAG,IAAI,OAAO,CAAC,qBAAqB,CAAC,aAAa,CAAC,CAAC,CAAA;IACpD,OAAO,CACL,OAAO,CAAC,EAAE,6BAA6B,CAAC,CAAC,CAAC,GACzC,OAAO,CAAC,qBAAqB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;CAC5C"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/instances/ModelCategory/types.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,EACrB,KAAK,EACL,aAAa,EACb,eAAe,EACf,0BAA0B,EAC1B,cAAc,EACd,qBAAqB,EACrB,qBAAqB,EACtB,MAAM,aAAa,CAAA;AAEpB;;;;;;GAMG;AACH,MAAM,WAAW,4BACf,SAAQ,qBAAqB,EAC3B,0BAA0B;IAC5B;;;OAGG;IACH,KAAK,CAAC,EACF,WAAW,GACX,YAAY,GACZ,kBAAkB,GAClB,mBAAmB,GACnB,WAAW,GACX,YAAY,CAAA;CACjB;AAED;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,qBAAqB,CAAC,CAAC,SAAS,cAAc;IAC7D;;;;;;;;;OASG;IACH,GAAG,IAAI,OAAO,CAAC,qBAAqB,CAAC,aAAa,CAAC,CAAC,CAAA;IAEpD;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;IACH,OAAO,CACL,OAAO,CAAC,EAAE,4BAA4B,GAAG,eAAe,CAAC,CAAC,CAAC,GAC1D,OAAO,CAAC,qBAAqB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;CAC5C"}
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/instances/ModelCategory/types.ts"],"names":[],"mappings":"","sourcesContent":["import {\n Entry,\n ModelCategory,\n ModelFieldOptions,\n SerializedData,\n StarlightItemResponse,\n StarlightListResponse,\n} from '../../types'\n\nexport type ModelCategoryEntryListOptions<D extends SerializedData> = {\n page?: number\n limit?: number\n query?: string\n 'query:word'?: string\n fields?: string\n order?:\n | 'title:asc'\n | 'title:desc'\n | 'published_at:asc'\n | 'published_at:desc'\n | 'views:asc'\n | 'views:desc'\n except?: number\n} & ModelFieldOptions<D>\n\nexport interface ModelCategoryInstance<D extends SerializedData> {\n get(): Promise<StarlightItemResponse<ModelCategory>>\n entries(\n options?: ModelCategoryEntryListOptions<D>\n ): Promise<StarlightListResponse<Entry<D>>>\n}\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/instances/ModelCategory/types.ts"],"names":[],"mappings":"","sourcesContent":["import {\n BaseRequestParameters,\n Entry,\n ModelCategory,\n QueryableFields,\n QueryableRequestParameters,\n SerializedData,\n StarlightItemResponse,\n StarlightListResponse,\n} from '../../types'\n\n/**\n * Request parameters for listing category entries.\n *\n * Used by {@apilink ModelCategoryInstance.entries}.\n *\n * @group Request Parameters\n */\nexport interface ModelCategoryEntryListParams\n extends BaseRequestParameters,\n QueryableRequestParameters {\n /**\n * Define how entries 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 * An Instance that provide methods to request information from a\n * {@link ModelCategory} and its {@apilink Entry | Entries}.\n *\n * You can access a ModelCategoryInstance using\n * {@apilink ModelInstance.category} or using the dynamic syntax on a\n * {@link DynamicModelInstance}. Usage examples will use the dynamic syntax.\n *\n * To list all categories from a model, use a {@link ModelCategorySelector}.\n *\n * @group Instances\n */\nexport interface ModelCategoryInstance<D extends SerializedData> {\n /**\n * Returns a {@link StarlightItemResponse} with a single {@link ModelCategory}.\n *\n * @example Requesting information from a category called \"articles\" in a model of slug \"posts\".\n * ```ts\n * import Starlight from '@starlightcms/js-sdk'\n *\n * const response = await Starlight.posts.articles.get()\n * ```\n */\n get(): Promise<StarlightItemResponse<ModelCategory>>\n\n /**\n * Returns a {@link StarlightListResponse} with the list of entries of this\n * {@link ModelCategory}.\n *\n * @example Requesting all items from a category called \"gaming\" in a model of slug \"posts\".\n * ```ts\n * import Starlight from '@starlightcms/js-sdk'\n *\n * const response = await Starlight.posts.gaming.items()\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.posts.gaming.items({\n * page: 5,\n * query: 'kirby'\n * })\n * ```\n *\n * @param options An optional object of request parameters. See\n * {@link ModelCategoryEntryListParams} for all available options. `field:foo`\n * syntax is also supported, see {@link QueryableFields} for more info.\n */\n entries(\n options?: ModelCategoryEntryListParams & QueryableFields<D>\n ): Promise<StarlightListResponse<Entry<D>>>\n}\n"]}
@@ -1,5 +1,5 @@
1
1
  import { StarlightClient } from '../../types';
2
- import { CollectionSelector, DynamicCollectionSelector } from './types';
2
+ import { CollectionSelector, DynamicCollectionSelector, ListCollectionsParams } from './types';
3
3
  export default function makeCollectionSelector(client: StarlightClient): DynamicCollectionSelector;
4
- export { CollectionSelector, DynamicCollectionSelector };
4
+ export { CollectionSelector, DynamicCollectionSelector, ListCollectionsParams };
5
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/selectors/Collection/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAC7C,OAAO,EAAE,kBAAkB,EAAE,yBAAyB,EAAE,MAAM,SAAS,CAAA;AAGvE,MAAM,CAAC,OAAO,UAAU,sBAAsB,CAC5C,MAAM,EAAE,eAAe,GACtB,yBAAyB,CAoB3B;AAED,OAAO,EAAE,kBAAkB,EAAE,yBAAyB,EAAE,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/selectors/Collection/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAC7C,OAAO,EACL,kBAAkB,EAClB,yBAAyB,EACzB,qBAAqB,EACtB,MAAM,SAAS,CAAA;AAGhB,MAAM,CAAC,OAAO,UAAU,sBAAsB,CAC5C,MAAM,EAAE,eAAe,GACtB,yBAAyB,CAoB3B;AAED,OAAO,EAAE,kBAAkB,EAAE,yBAAyB,EAAE,qBAAqB,EAAE,CAAA"}
@@ -2,7 +2,7 @@ import makeCollectionInstance from '../../instances/Collection';
2
2
  export default function makeCollectionSelector(client) {
3
3
  const selector = {
4
4
  list(options) {
5
- return client.get('/collections', options);
5
+ return client.get('/collections', Object.assign({}, options));
6
6
  },
7
7
  get(slug) {
8
8
  return client.get(`/collections/${slug}`);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/selectors/Collection/index.ts"],"names":[],"mappings":"AAEA,OAAO,sBAAsB,MAAM,4BAA4B,CAAA;AAE/D,MAAM,CAAC,OAAO,UAAU,sBAAsB,CAC5C,MAAuB;IAEvB,MAAM,QAAQ,GAAuB;QACnC,IAAI,CAAC,OAAO;YACV,OAAO,MAAM,CAAC,GAAG,CAAC,cAAc,EAAE,OAAO,CAAC,CAAA;QAC5C,CAAC;QAED,GAAG,CAAC,IAAI;YACN,OAAO,MAAM,CAAC,GAAG,CAAC,gBAAgB,IAAI,EAAE,CAAC,CAAA;QAC3C,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,sBAAsB,CAAC,MAAM,EAAE,IAAI,CAAC,CAAA;aAC5C;YAED,OAAO,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,CAAA;QAClC,CAAC;KACF,CAA8B,CAAA;AACjC,CAAC","sourcesContent":["import { StarlightClient } from '../../types'\nimport { CollectionSelector, DynamicCollectionSelector } from './types'\nimport makeCollectionInstance from '../../instances/Collection'\n\nexport default function makeCollectionSelector(\n client: StarlightClient\n): DynamicCollectionSelector {\n const selector: CollectionSelector = {\n list(options) {\n return client.get('/collections', options)\n },\n\n get(slug) {\n return client.get(`/collections/${slug}`)\n },\n }\n\n return new Proxy(selector, {\n get(target, prop) {\n if (typeof prop === 'string' && !Reflect.has(target, prop)) {\n return makeCollectionInstance(client, prop)\n }\n\n return Reflect.get(target, prop)\n },\n }) as DynamicCollectionSelector\n}\n\nexport { CollectionSelector, DynamicCollectionSelector }\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/selectors/Collection/index.ts"],"names":[],"mappings":"AAMA,OAAO,sBAAsB,MAAM,4BAA4B,CAAA;AAE/D,MAAM,CAAC,OAAO,UAAU,sBAAsB,CAC5C,MAAuB;IAEvB,MAAM,QAAQ,GAAuB;QACnC,IAAI,CAAC,OAAO;YACV,OAAO,MAAM,CAAC,GAAG,CAAC,cAAc,oBAAO,OAAO,EAAG,CAAA;QACnD,CAAC;QAED,GAAG,CAAC,IAAI;YACN,OAAO,MAAM,CAAC,GAAG,CAAC,gBAAgB,IAAI,EAAE,CAAC,CAAA;QAC3C,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,sBAAsB,CAAC,MAAM,EAAE,IAAI,CAAC,CAAA;aAC5C;YAED,OAAO,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,CAAA;QAClC,CAAC;KACF,CAA8B,CAAA;AACjC,CAAC","sourcesContent":["import { StarlightClient } from '../../types'\nimport {\n CollectionSelector,\n DynamicCollectionSelector,\n ListCollectionsParams,\n} from './types'\nimport makeCollectionInstance from '../../instances/Collection'\n\nexport default function makeCollectionSelector(\n client: StarlightClient\n): DynamicCollectionSelector {\n const selector: CollectionSelector = {\n list(options) {\n return client.get('/collections', { ...options })\n },\n\n get(slug) {\n return client.get(`/collections/${slug}`)\n },\n }\n\n return new Proxy(selector, {\n get(target, prop) {\n if (typeof prop === 'string' && !Reflect.has(target, prop)) {\n return makeCollectionInstance(client, prop)\n }\n\n return Reflect.get(target, prop)\n },\n }) as DynamicCollectionSelector\n}\n\nexport { CollectionSelector, DynamicCollectionSelector, ListCollectionsParams }\n"]}
@@ -1,15 +1,90 @@
1
- import { Collection, StarlightItemResponse, StarlightListResponse } from '../../types';
1
+ import { BaseRequestParameters, Collection, StarlightItemResponse, StarlightListResponse } from '../../types';
2
2
  import { CollectionInstance } from '../../instances/Collection';
3
- export declare type ListCollectionsOptions = {
4
- query?: string;
5
- page?: number;
6
- limit?: number;
3
+ /**
4
+ * Request parameters for listing collections.
5
+ *
6
+ * Used by {@apilink CollectionSelector.list}.
7
+ *
8
+ * @group Request Parameters
9
+ */
10
+ export interface ListCollectionsParams extends BaseRequestParameters {
11
+ /**
12
+ * Define how items will be ordered. Check this field type to see the
13
+ * allowed options.
14
+ */
7
15
  order?: 'title:asc' | 'title:desc' | 'item_count:asc' | 'item_count:desc';
8
- };
16
+ }
17
+ /**
18
+ * A Selector that provide methods to list and request information on
19
+ * {@apilink Collection | Collections}.
20
+ *
21
+ * You can use a CollectionSelector by accessing
22
+ * {@apilink StarlightClient.collections}.
23
+ *
24
+ * To get items from a specific collection, use a {@link CollectionInstance}.
25
+ *
26
+ * @group Selectors
27
+ */
9
28
  export interface CollectionSelector {
10
- list(options?: ListCollectionsOptions): Promise<StarlightListResponse<Collection>>;
29
+ /**
30
+ * Returns a {@link StarlightListResponse} with the list of
31
+ * {@apilink Collection | Collections} in this workspace.
32
+ *
33
+ * @example Requesting all collections from the workspace.
34
+ * ```ts
35
+ * import Starlight from '@starlightcms/js-sdk'
36
+ *
37
+ * const response = await Starlight.collections.list()
38
+ * ```
39
+ *
40
+ * @example Paginating and searching on the last example.
41
+ * ```ts
42
+ * import Starlight from '@starlightcms/js-sdk'
43
+ *
44
+ * const response = await Starlight.collections.list({
45
+ * page: 2,
46
+ * query: 'photos',
47
+ * })
48
+ * ```
49
+ *
50
+ * @param options An optional object of request parameters. See
51
+ * {@link ListCollectionsParams} for all available options.
52
+ */
53
+ list(options?: ListCollectionsParams): Promise<StarlightListResponse<Collection>>;
54
+ /**
55
+ * Returns a {@link StarlightItemResponse} with a single {@link Collection}.
56
+ *
57
+ * @example Requesting information from a collection of slug "event-photos".
58
+ * ```ts
59
+ * import Starlight from '@starlightcms/js-sdk'
60
+ *
61
+ * const response = await Starlight.collections.get('event-photos')
62
+ * ```
63
+ *
64
+ * @param slug The collection slug.
65
+ */
11
66
  get(slug: string | number): Promise<StarlightItemResponse<Collection>>;
12
67
  }
68
+ /**
69
+ * A Selector that provide all {@link CollectionSelector} methods and adds
70
+ * support for creating {@apilink CollectionInstance | CollectionInstances}
71
+ * using the dynamic syntax.
72
+ *
73
+ * See {@link CollectionSelector} to view all available methods.
74
+ *
75
+ * See {@doclink requests-and-responses#dynamic-syntax | Dynamic Instances}
76
+ * documentation to learn more about the dynamic syntax.
77
+ *
78
+ * @example Accessing a CollectionInstance using the dynamic syntax.
79
+ * ```ts
80
+ * import Starlight from '@starlightcms/js-sdk'
81
+ *
82
+ * // "sliders" below will be a CollectionInstance.
83
+ * const response = await Starlight.collections.sliders.list()
84
+ * ```
85
+ *
86
+ * @category Instances
87
+ */
13
88
  export declare type DynamicCollectionSelector = CollectionSelector & {
14
89
  [key: string]: CollectionInstance<unknown>;
15
90
  };
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/selectors/Collection/types.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,qBAAqB,EACrB,qBAAqB,EACtB,MAAM,aAAa,CAAA;AACpB,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAA;AAE/D,oBAAY,sBAAsB,GAAG;IACnC,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,KAAK,CAAC,EAAE,WAAW,GAAG,YAAY,GAAG,gBAAgB,GAAG,iBAAiB,CAAA;CAC1E,CAAA;AAED,MAAM,WAAW,kBAAkB;IACjC,IAAI,CACF,OAAO,CAAC,EAAE,sBAAsB,GAC/B,OAAO,CAAC,qBAAqB,CAAC,UAAU,CAAC,CAAC,CAAA;IAC7C,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,qBAAqB,CAAC,UAAU,CAAC,CAAC,CAAA;CACvE;AAED,oBAAY,yBAAyB,GAAG,kBAAkB,GAAG;IAC3D,CAAC,GAAG,EAAE,MAAM,GAAG,kBAAkB,CAAC,OAAO,CAAC,CAAA;CAC3C,CAAA"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/selectors/Collection/types.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,EACrB,UAAU,EACV,qBAAqB,EACrB,qBAAqB,EACtB,MAAM,aAAa,CAAA;AACpB,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAA;AAE/D;;;;;;GAMG;AACH,MAAM,WAAW,qBAAsB,SAAQ,qBAAqB;IAClE;;;OAGG;IACH,KAAK,CAAC,EAAE,WAAW,GAAG,YAAY,GAAG,gBAAgB,GAAG,iBAAiB,CAAA;CAC1E;AAED;;;;;;;;;;GAUG;AACH,MAAM,WAAW,kBAAkB;IACjC;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IACH,IAAI,CACF,OAAO,CAAC,EAAE,qBAAqB,GAC9B,OAAO,CAAC,qBAAqB,CAAC,UAAU,CAAC,CAAC,CAAA;IAE7C;;;;;;;;;;;OAWG;IACH,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,qBAAqB,CAAC,UAAU,CAAC,CAAC,CAAA;CACvE;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,oBAAY,yBAAyB,GAAG,kBAAkB,GAAG;IAC3D,CAAC,GAAG,EAAE,MAAM,GAAG,kBAAkB,CAAC,OAAO,CAAC,CAAA;CAC3C,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/selectors/Collection/types.ts"],"names":[],"mappings":"","sourcesContent":["import {\n Collection,\n StarlightItemResponse,\n StarlightListResponse,\n} from '../../types'\nimport { CollectionInstance } from '../../instances/Collection'\n\nexport type ListCollectionsOptions = {\n query?: string\n page?: number\n limit?: number\n order?: 'title:asc' | 'title:desc' | 'item_count:asc' | 'item_count:desc'\n}\n\nexport interface CollectionSelector {\n list(\n options?: ListCollectionsOptions\n ): Promise<StarlightListResponse<Collection>>\n get(slug: string | number): Promise<StarlightItemResponse<Collection>>\n}\n\nexport type DynamicCollectionSelector = CollectionSelector & {\n [key: string]: CollectionInstance<unknown>\n}\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/selectors/Collection/types.ts"],"names":[],"mappings":"","sourcesContent":["import {\n BaseRequestParameters,\n Collection,\n StarlightItemResponse,\n StarlightListResponse,\n} from '../../types'\nimport { CollectionInstance } from '../../instances/Collection'\n\n/**\n * Request parameters for listing collections.\n *\n * Used by {@apilink CollectionSelector.list}.\n *\n * @group Request Parameters\n */\nexport interface ListCollectionsParams 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' | 'item_count:asc' | 'item_count:desc'\n}\n\n/**\n * A Selector that provide methods to list and request information on\n * {@apilink Collection | Collections}.\n *\n * You can use a CollectionSelector by accessing\n * {@apilink StarlightClient.collections}.\n *\n * To get items from a specific collection, use a {@link CollectionInstance}.\n *\n * @group Selectors\n */\nexport interface CollectionSelector {\n /**\n * Returns a {@link StarlightListResponse} with the list of\n * {@apilink Collection | Collections} in this workspace.\n *\n * @example Requesting all collections from the workspace.\n * ```ts\n * import Starlight from '@starlightcms/js-sdk'\n *\n * const response = await Starlight.collections.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.collections.list({\n * page: 2,\n * query: 'photos',\n * })\n * ```\n *\n * @param options An optional object of request parameters. See\n * {@link ListCollectionsParams} for all available options.\n */\n list(\n options?: ListCollectionsParams\n ): Promise<StarlightListResponse<Collection>>\n\n /**\n * Returns a {@link StarlightItemResponse} with a single {@link Collection}.\n *\n * @example Requesting information from a collection of slug \"event-photos\".\n * ```ts\n * import Starlight from '@starlightcms/js-sdk'\n *\n * const response = await Starlight.collections.get('event-photos')\n * ```\n *\n * @param slug The collection slug.\n */\n get(slug: string | number): Promise<StarlightItemResponse<Collection>>\n}\n\n/**\n * A Selector that provide all {@link CollectionSelector} methods and adds\n * support for creating {@apilink CollectionInstance | CollectionInstances}\n * using the dynamic syntax.\n *\n * See {@link CollectionSelector} to view all available methods.\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 CollectionInstance using the dynamic syntax.\n * ```ts\n * import Starlight from '@starlightcms/js-sdk'\n *\n * // \"sliders\" below will be a CollectionInstance.\n * const response = await Starlight.collections.sliders.list()\n * ```\n *\n * @category Instances\n */\nexport type DynamicCollectionSelector = CollectionSelector & {\n [key: string]: CollectionInstance<unknown>\n}\n"]}
@@ -1,19 +1,114 @@
1
- import { Entry, ModelFieldOptions, SerializedData, StarlightItemResponse, StarlightListResponse } from '../../types';
2
- export declare type ListEntriesOptions<D extends SerializedData> = {
3
- page?: number;
4
- limit?: number;
5
- query?: string;
6
- 'query:word'?: string;
7
- fields?: string;
1
+ import { BaseRequestParameters, Entry, QueryableFields, QueryableRequestParameters, SerializedData, StarlightItemResponse, StarlightListResponse } from '../../types';
2
+ /**
3
+ * Request parameters for listing entries.
4
+ *
5
+ * Used by {@apilink EntrySelector.list}.
6
+ *
7
+ * @group Request Parameters
8
+ */
9
+ export interface ListEntriesParams extends BaseRequestParameters, QueryableRequestParameters {
10
+ /**
11
+ * A comma-separated list of categories. Only entries in these categories
12
+ * will be returned. If undefined, all entries in the model will be listed.
13
+ *
14
+ * For instance, to show only entries in the "news" and "articles" categories,
15
+ * pass `'news,category'`.
16
+ */
8
17
  categories?: string;
18
+ /**
19
+ * Define how items will be ordered. Check this field type to see the
20
+ * allowed options.
21
+ */
9
22
  order?: 'title:asc' | 'title:desc' | 'published_at:asc' | 'published_at:desc' | 'views:asc' | 'views:desc';
10
- except?: number;
11
- } & ModelFieldOptions<D>;
23
+ }
24
+ /**
25
+ * Request parameters for getting an entry.
26
+ *
27
+ * Used by {@apilink EntrySelector.get}.
28
+ *
29
+ * @group Request Parameters
30
+ */
12
31
  export declare type GetEntryParams = {
32
+ /**
33
+ * Preview token generated by the Starlight admin interface. If defined and
34
+ * valid, the API will return a preview of the entry revision associated
35
+ * with the token.
36
+ */
13
37
  preview?: string;
14
38
  };
39
+ /**
40
+ * A Selector that provide methods to list and request information on
41
+ * {@apilink Entry | Entries}.
42
+ *
43
+ * You can use an EntrySelector by accessing
44
+ * {@apilink ModelInstance.entries}.
45
+ *
46
+ * @group Selectors
47
+ */
15
48
  export interface EntrySelector<D extends SerializedData> {
49
+ /**
50
+ * Returns a {@link StarlightItemResponse} with a single {@link Entry}.
51
+ * Supports revision previewing by passing a `preview` parameter.
52
+ *
53
+ * @example Requesting information from an entry "hello-world" from a model of slug "posts".
54
+ * ```ts
55
+ * import Starlight from '@starlightcms/js-sdk'
56
+ *
57
+ * const response = await Starlight.posts.entries.get('hello-world')
58
+ * ```
59
+ *
60
+ * @example Passing a preview token on the last example.
61
+ * ```ts
62
+ * import Starlight from '@starlightcms/js-sdk'
63
+ *
64
+ * const response = await Starlight.posts.entries.get('hello-world', {
65
+ * preview: 'CDfkvt1zTF5XhxWzi2Lejgo1'
66
+ * })
67
+ * ```
68
+ *
69
+ * @param slug The entry slug.
70
+ * @param params An optional object of request parameters. See
71
+ * {@link GetEntryParams} for all available options.
72
+ * @param options An optional object of Fetch parameters. Use it to modify
73
+ * the fetch request.See [MDN documentation on fetch()](https://developer.mozilla.org/en-US/docs/Web/API/fetch)
74
+ * for all available options.
75
+ */
16
76
  get(slug: string, params?: GetEntryParams, options?: RequestInit): Promise<StarlightItemResponse<Entry<D>>>;
17
- list(options?: ListEntriesOptions<D>): Promise<StarlightListResponse<Entry<D>>>;
77
+ /**
78
+ * Returns a {@link StarlightListResponse} with a list of
79
+ * {@apilink Entry | Entries}.
80
+ *
81
+ * @example Requesting all entries from a model of slug "recipes".
82
+ * ```ts
83
+ * import Starlight from '@starlightcms/js-sdk'
84
+ *
85
+ * const response = await Starlight.recipes.entries.list()
86
+ * ```
87
+ *
88
+ * @example Paginating and searching on the last example.
89
+ * ```ts
90
+ * import Starlight from '@starlightcms/js-sdk'
91
+ *
92
+ * const response = await Starlight.recipes.entries.list({
93
+ * page: 2,
94
+ * query: 'gravy',
95
+ * 'field:is_vegan': true,
96
+ * })
97
+ * ```
98
+ *
99
+ * @example Ordering entries by number of views.
100
+ * ```ts
101
+ * import Starlight from '@starlightcms/js-sdk'
102
+ *
103
+ * const response = await Starlight.recipes.entries.list({
104
+ * order: 'views:desc'
105
+ * })
106
+ * ```
107
+ *
108
+ * @param options An optional object of request parameters. See
109
+ * {@link ListEntriesParams} for all available options. `field:foo`
110
+ * syntax is also supported, see {@link QueryableFields} for more info.
111
+ */
112
+ list(options?: ListEntriesParams & QueryableFields<D>): Promise<StarlightListResponse<Entry<D>>>;
18
113
  }
19
114
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/selectors/Entry/types.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,EACL,iBAAiB,EACjB,cAAc,EACd,qBAAqB,EACrB,qBAAqB,EACtB,MAAM,aAAa,CAAA;AAEpB,oBAAY,kBAAkB,CAAC,CAAC,SAAS,cAAc,IAAI;IACzD,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,KAAK,CAAC,EACF,WAAW,GACX,YAAY,GACZ,kBAAkB,GAClB,mBAAmB,GACnB,WAAW,GACX,YAAY,CAAA;IAChB,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB,GAAG,iBAAiB,CAAC,CAAC,CAAC,CAAA;AAExB,oBAAY,cAAc,GAAG;IAC3B,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB,CAAA;AAED,MAAM,WAAW,aAAa,CAAC,CAAC,SAAS,cAAc;IACrD,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;IAC3C,IAAI,CACF,OAAO,CAAC,EAAE,kBAAkB,CAAC,CAAC,CAAC,GAC9B,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;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 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/selectors/Entry/types.ts"],"names":[],"mappings":"","sourcesContent":["import {\n Entry,\n ModelFieldOptions,\n SerializedData,\n StarlightItemResponse,\n StarlightListResponse,\n} from '../../types'\n\nexport type ListEntriesOptions<D extends SerializedData> = {\n page?: number\n limit?: number\n query?: string\n 'query:word'?: string\n fields?: string\n categories?: string\n order?:\n | 'title:asc'\n | 'title:desc'\n | 'published_at:asc'\n | 'published_at:desc'\n | 'views:asc'\n | 'views:desc'\n except?: number\n} & ModelFieldOptions<D>\n\nexport type GetEntryParams = {\n preview?: string\n}\n\nexport interface EntrySelector<D extends SerializedData> {\n get(\n slug: string,\n params?: GetEntryParams,\n options?: RequestInit\n ): Promise<StarlightItemResponse<Entry<D>>>\n list(\n options?: ListEntriesOptions<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\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"]}
@@ -3,8 +3,8 @@ export default function makeMediaSelector(client) {
3
3
  list() {
4
4
  return client.get('/media');
5
5
  },
6
- get(slug) {
7
- return client.get(`/media/${slug}`);
6
+ get(id) {
7
+ return client.get(`/media/${id}`);
8
8
  },
9
9
  };
10
10
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/selectors/Media/index.ts"],"names":[],"mappings":"AAGA,MAAM,CAAC,OAAO,UAAU,iBAAiB,CACvC,MAAuB;IAEvB,OAAO;QACL,IAAI;YACF,OAAO,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;QAC7B,CAAC;QAED,GAAG,CAAC,IAAI;YACN,OAAO,MAAM,CAAC,GAAG,CAAC,UAAU,IAAI,EAAE,CAAC,CAAA;QACrC,CAAC;KACF,CAAA;AACH,CAAC","sourcesContent":["import { StarlightClient } from '../../types'\nimport { MediaSelector } from './types'\n\nexport default function makeMediaSelector(\n client: StarlightClient\n): MediaSelector {\n return {\n list() {\n return client.get('/media')\n },\n\n get(slug) {\n return client.get(`/media/${slug}`)\n },\n }\n}\n\nexport { MediaSelector }\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/selectors/Media/index.ts"],"names":[],"mappings":"AAGA,MAAM,CAAC,OAAO,UAAU,iBAAiB,CACvC,MAAuB;IAEvB,OAAO;QACL,IAAI;YACF,OAAO,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;QAC7B,CAAC;QAED,GAAG,CAAC,EAAE;YACJ,OAAO,MAAM,CAAC,GAAG,CAAC,UAAU,EAAE,EAAE,CAAC,CAAA;QACnC,CAAC;KACF,CAAA;AACH,CAAC","sourcesContent":["import { StarlightClient } from '../../types'\nimport { MediaSelector } from './types'\n\nexport default function makeMediaSelector(\n client: StarlightClient\n): MediaSelector {\n return {\n list() {\n return client.get('/media')\n },\n\n get(id) {\n return client.get(`/media/${id}`)\n },\n }\n}\n\nexport { MediaSelector }\n"]}
@@ -1,6 +1,40 @@
1
1
  import { MediaObject, StarlightItemResponse, StarlightListResponse } from '../../types';
2
+ /**
3
+ * A Selector that provide methods to list and request information on
4
+ * {@apilink MediaObject | MediaObjects}.
5
+ *
6
+ * You can use a MediaSelector by accessing
7
+ * {@apilink StarlightClient.media}.
8
+ *
9
+ * @group Selectors
10
+ */
2
11
  export interface MediaSelector {
3
- get(slug: number | string): Promise<StarlightItemResponse<MediaObject>>;
12
+ /**
13
+ * Returns a {@link StarlightItemResponse} with a single {@link MediaObject}.
14
+ *
15
+ * Note: MediaObjects are identified by their IDs, since they don't have slugs.
16
+ *
17
+ * @example Requesting information from a media object of id "123456789".
18
+ * ```ts
19
+ * import Starlight from '@starlightcms/js-sdk'
20
+ *
21
+ * const response = await Starlight.media.get('123456789')
22
+ * ```
23
+ *
24
+ * @param id The media object ID.
25
+ */
26
+ get(id: number | string): Promise<StarlightItemResponse<MediaObject>>;
27
+ /**
28
+ * Returns a {@link StarlightListResponse} with the list of
29
+ * {@apilink MediaObject | MediaObjects} in this workspace.
30
+ *
31
+ * @example Requesting all media objects from the workspace.
32
+ * ```ts
33
+ * import Starlight from '@starlightcms/js-sdk'
34
+ *
35
+ * const response = await Starlight.media.list()
36
+ * ```
37
+ */
4
38
  list(): Promise<StarlightListResponse<MediaObject>>;
5
39
  }
6
40
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/selectors/Media/types.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,qBAAqB,EACrB,qBAAqB,EACtB,MAAM,aAAa,CAAA;AAEpB,MAAM,WAAW,aAAa;IAC5B,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,qBAAqB,CAAC,WAAW,CAAC,CAAC,CAAA;IACvE,IAAI,IAAI,OAAO,CAAC,qBAAqB,CAAC,WAAW,CAAC,CAAC,CAAA;CACpD"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/selectors/Media/types.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,qBAAqB,EACrB,qBAAqB,EACtB,MAAM,aAAa,CAAA;AAEpB;;;;;;;;GAQG;AACH,MAAM,WAAW,aAAa;IAC5B;;;;;;;;;;;;;OAaG;IACH,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,qBAAqB,CAAC,WAAW,CAAC,CAAC,CAAA;IAErE;;;;;;;;;;OAUG;IACH,IAAI,IAAI,OAAO,CAAC,qBAAqB,CAAC,WAAW,CAAC,CAAC,CAAA;CACpD"}
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/selectors/Media/types.ts"],"names":[],"mappings":"","sourcesContent":["import {\n MediaObject,\n StarlightItemResponse,\n StarlightListResponse,\n} from '../../types'\n\nexport interface MediaSelector {\n get(slug: number | string): Promise<StarlightItemResponse<MediaObject>>\n list(): Promise<StarlightListResponse<MediaObject>>\n}\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/selectors/Media/types.ts"],"names":[],"mappings":"","sourcesContent":["import {\n MediaObject,\n StarlightItemResponse,\n StarlightListResponse,\n} from '../../types'\n\n/**\n * A Selector that provide methods to list and request information on\n * {@apilink MediaObject | MediaObjects}.\n *\n * You can use a MediaSelector by accessing\n * {@apilink StarlightClient.media}.\n *\n * @group Selectors\n */\nexport interface MediaSelector {\n /**\n * Returns a {@link StarlightItemResponse} with a single {@link MediaObject}.\n *\n * Note: MediaObjects are identified by their IDs, since they don't have slugs.\n *\n * @example Requesting information from a media object of id \"123456789\".\n * ```ts\n * import Starlight from '@starlightcms/js-sdk'\n *\n * const response = await Starlight.media.get('123456789')\n * ```\n *\n * @param id The media object ID.\n */\n get(id: number | string): Promise<StarlightItemResponse<MediaObject>>\n\n /**\n * Returns a {@link StarlightListResponse} with the list of\n * {@apilink MediaObject | MediaObjects} in this workspace.\n *\n * @example Requesting all media objects from the workspace.\n * ```ts\n * import Starlight from '@starlightcms/js-sdk'\n *\n * const response = await Starlight.media.list()\n * ```\n */\n list(): Promise<StarlightListResponse<MediaObject>>\n}\n"]}
@@ -1,9 +1,68 @@
1
1
  import { Model, StarlightItemResponse, StarlightListResponse, WorkspaceModelDefinition } from '../../types';
2
2
  import { DynamicModelInstance } from '../../instances/Model';
3
+ /**
4
+ * A Selector that provide methods to list and request information on
5
+ * {@apilink Model | Models}.
6
+ *
7
+ * You can use a ModelSelector by accessing
8
+ * {@apilink StarlightClient.models}.
9
+ *
10
+ * To list entries or categories of a specific model, use a
11
+ * {@link ModelInstance}.
12
+ *
13
+ * @group Selectors
14
+ */
3
15
  export interface ModelSelector {
16
+ /**
17
+ * Returns a {@link StarlightListResponse} with a list of
18
+ * {@apilink Model | Models}.
19
+ *
20
+ * @example Requesting all models from a workspace.
21
+ * ```ts
22
+ * import Starlight from '@starlightcms/js-sdk'
23
+ *
24
+ * const response = await Starlight.models.list()
25
+ * ```
26
+ */
4
27
  list(): Promise<StarlightListResponse<Model>>;
28
+ /**
29
+ * Returns a {@link StarlightItemResponse} with a single {@link Model}.
30
+ *
31
+ * Note that this method only returns information on a model, like its title,
32
+ * slug, creation date, and entry count. If you want list its entries or
33
+ * categories, you need to use a {@link ModelInstance}.
34
+ *
35
+ * @example Requesting information from a model of slug "clients".
36
+ * ```ts
37
+ * import Starlight from '@starlightcms/js-sdk'
38
+ *
39
+ * const response = await Starlight.posts.entries.get('clients')
40
+ * ```
41
+ *
42
+ * @param slug The model slug.
43
+ */
5
44
  get(slug: string): Promise<StarlightItemResponse<Model>>;
6
45
  }
46
+ /**
47
+ * A Selector that provide all {@link ModelSelector} methods and adds support
48
+ * for creating {@apilink DynamicModelInstance | DynamicModelInstances} using
49
+ * the dynamic syntax.
50
+ *
51
+ * See {@link ModelSelector} to view all available methods.
52
+ *
53
+ * See {@doclink requests-and-responses#dynamic-syntax | Dynamic Instances}
54
+ * documentation to learn more about the dynamic syntax.
55
+ *
56
+ * @example Accessing a DynamicModelInstance using the dynamic syntax.
57
+ * ```ts
58
+ * import Starlight from '@starlightcms/js-sdk'
59
+ *
60
+ * // "posts" below will be a DynamicModelInstance.
61
+ * const response = await Starlight.models.posts.entries.list()
62
+ * ```
63
+ *
64
+ * @category Selectors
65
+ */
7
66
  export declare type DynamicModelSelector<T extends WorkspaceModelDefinition> = ModelSelector & {
8
67
  [K in keyof T]: DynamicModelInstance<T[K]>;
9
68
  };
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/selectors/Model/types.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,EACL,qBAAqB,EACrB,qBAAqB,EACrB,wBAAwB,EACzB,MAAM,aAAa,CAAA;AACpB,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAA;AAE5D,MAAM,WAAW,aAAa;IAC5B,IAAI,IAAI,OAAO,CAAC,qBAAqB,CAAC,KAAK,CAAC,CAAC,CAAA;IAC7C,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,qBAAqB,CAAC,KAAK,CAAC,CAAC,CAAA;CACzD;AAED,oBAAY,oBAAoB,CAAC,CAAC,SAAS,wBAAwB,IACjE,aAAa,GAAG;KACb,CAAC,IAAI,MAAM,CAAC,GAAG,oBAAoB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAC3C,CAAA"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/selectors/Model/types.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,EACL,qBAAqB,EACrB,qBAAqB,EACrB,wBAAwB,EACzB,MAAM,aAAa,CAAA;AACpB,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAA;AAE5D;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,aAAa;IAC5B;;;;;;;;;;OAUG;IACH,IAAI,IAAI,OAAO,CAAC,qBAAqB,CAAC,KAAK,CAAC,CAAC,CAAA;IAE7C;;;;;;;;;;;;;;;OAeG;IACH,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,qBAAqB,CAAC,KAAK,CAAC,CAAC,CAAA;CACzD;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,oBAAY,oBAAoB,CAAC,CAAC,SAAS,wBAAwB,IACjE,aAAa,GAAG;KACb,CAAC,IAAI,MAAM,CAAC,GAAG,oBAAoB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAC3C,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/selectors/Model/types.ts"],"names":[],"mappings":"","sourcesContent":["import {\n Model,\n StarlightItemResponse,\n StarlightListResponse,\n WorkspaceModelDefinition,\n} from '../../types'\nimport { DynamicModelInstance } from '../../instances/Model'\n\nexport interface ModelSelector {\n list(): Promise<StarlightListResponse<Model>>\n get(slug: string): Promise<StarlightItemResponse<Model>>\n}\n\nexport type DynamicModelSelector<T extends WorkspaceModelDefinition> =\n ModelSelector & {\n [K in keyof T]: DynamicModelInstance<T[K]>\n }\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/selectors/Model/types.ts"],"names":[],"mappings":"","sourcesContent":["import {\n Model,\n StarlightItemResponse,\n StarlightListResponse,\n WorkspaceModelDefinition,\n} from '../../types'\nimport { DynamicModelInstance } from '../../instances/Model'\n\n/**\n * A Selector that provide methods to list and request information on\n * {@apilink Model | Models}.\n *\n * You can use a ModelSelector by accessing\n * {@apilink StarlightClient.models}.\n *\n * To list entries or categories of a specific model, use a\n * {@link ModelInstance}.\n *\n * @group Selectors\n */\nexport interface ModelSelector {\n /**\n * Returns a {@link StarlightListResponse} with a list of\n * {@apilink Model | Models}.\n *\n * @example Requesting all models from a workspace.\n * ```ts\n * import Starlight from '@starlightcms/js-sdk'\n *\n * const response = await Starlight.models.list()\n * ```\n */\n list(): Promise<StarlightListResponse<Model>>\n\n /**\n * Returns a {@link StarlightItemResponse} with a single {@link Model}.\n *\n * Note that this method only returns information on a model, like its title,\n * slug, creation date, and entry count. If you want list its entries or\n * categories, you need to use a {@link ModelInstance}.\n *\n * @example Requesting information from a model of slug \"clients\".\n * ```ts\n * import Starlight from '@starlightcms/js-sdk'\n *\n * const response = await Starlight.posts.entries.get('clients')\n * ```\n *\n * @param slug The model slug.\n */\n get(slug: string): Promise<StarlightItemResponse<Model>>\n}\n\n/**\n * A Selector that provide all {@link ModelSelector} methods and adds support\n * for creating {@apilink DynamicModelInstance | DynamicModelInstances} using\n * the dynamic syntax.\n *\n * See {@link ModelSelector} to view all available methods.\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 DynamicModelInstance using the dynamic syntax.\n * ```ts\n * import Starlight from '@starlightcms/js-sdk'\n *\n * // \"posts\" below will be a DynamicModelInstance.\n * const response = await Starlight.models.posts.entries.list()\n * ```\n *\n * @category Selectors\n */\nexport type DynamicModelSelector<T extends WorkspaceModelDefinition> =\n ModelSelector & {\n [K in keyof T]: DynamicModelInstance<T[K]>\n }\n"]}
@@ -2,7 +2,7 @@ import makeModelCategoryInstance from '../../instances/ModelCategory';
2
2
  export default function makeModelCategorySelector(client, model) {
3
3
  const selector = {
4
4
  list(options) {
5
- return client.get(`/models/${model}/categories`, options);
5
+ return client.get(`/models/${model}/categories`, Object.assign({}, options));
6
6
  },
7
7
  get(slug) {
8
8
  return client.get(`/models/${model}/categories/${slug}`);
@@ -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,EAAE,OAAO,CAAC,CAAA;QAC3D,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":"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"]}