@starlightcms/js-sdk 0.10.0 → 0.12.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 (144) hide show
  1. package/README.md +54 -0
  2. package/dist/cjs/client.d.ts +6 -6
  3. package/dist/cjs/client.d.ts.map +1 -1
  4. package/dist/cjs/client.js +8 -5
  5. package/dist/cjs/client.js.map +1 -1
  6. package/dist/cjs/errors.d.ts +23 -0
  7. package/dist/cjs/errors.d.ts.map +1 -1
  8. package/dist/cjs/errors.js.map +1 -1
  9. package/dist/cjs/index.d.ts +6 -5
  10. package/dist/cjs/index.d.ts.map +1 -1
  11. package/dist/cjs/index.js +5 -4
  12. package/dist/cjs/index.js.map +1 -1
  13. package/dist/cjs/instances/Collection/index.d.ts +2 -2
  14. package/dist/cjs/instances/Collection/index.d.ts.map +1 -1
  15. package/dist/cjs/instances/Collection/index.js.map +1 -1
  16. package/dist/cjs/instances/Collection/types.d.ts +25 -13
  17. package/dist/cjs/instances/Collection/types.d.ts.map +1 -1
  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 +99 -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 +6 -6
  74. package/dist/esm/client.d.ts.map +1 -1
  75. package/dist/esm/client.js +8 -5
  76. package/dist/esm/client.js.map +1 -1
  77. package/dist/esm/errors.d.ts +23 -0
  78. package/dist/esm/errors.d.ts.map +1 -1
  79. package/dist/esm/errors.js.map +1 -1
  80. package/dist/esm/index.d.ts +6 -5
  81. package/dist/esm/index.d.ts.map +1 -1
  82. package/dist/esm/index.js +5 -4
  83. package/dist/esm/index.js.map +1 -1
  84. package/dist/esm/instances/Collection/index.d.ts +2 -2
  85. package/dist/esm/instances/Collection/index.d.ts.map +1 -1
  86. package/dist/esm/instances/Collection/index.js.map +1 -1
  87. package/dist/esm/instances/Collection/types.d.ts +25 -13
  88. package/dist/esm/instances/Collection/types.d.ts.map +1 -1
  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 +99 -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,15 +1,58 @@
1
- import { ModelCategory, SerializedData, StarlightItemResponse, StarlightListResponse } from '../../types';
1
+ import { BaseRequestParameters, ModelCategory, SerializedData, StarlightItemResponse, StarlightListResponse } from '../../types';
2
2
  import { ModelCategoryInstance } from '../../instances/ModelCategory';
3
- export declare type ListModelCategoriesOptions = {
4
- query?: string;
5
- page?: number;
6
- limit?: number;
3
+ export interface ListModelCategoriesOptions extends BaseRequestParameters {
4
+ /**
5
+ * Define how items will be ordered. Check this field type to see the
6
+ * allowed options.
7
+ */
7
8
  order?: 'title:asc' | 'title:desc' | 'entry_count:asc' | 'entry_count:desc';
8
- };
9
+ }
10
+ /**
11
+ * A Selector that provide methods to list and request information on
12
+ * {@apilink ModelCategory | ModelCategories}.
13
+ *
14
+ * You can use a ModelCategorySelector by accessing
15
+ * {@apilink ModelInstance.categories}.
16
+ *
17
+ * @group Selectors
18
+ */
9
19
  export interface ModelCategorySelector {
10
20
  list(options?: ListModelCategoriesOptions): Promise<StarlightListResponse<ModelCategory>>;
21
+ /**
22
+ * Returns a {@link StarlightItemResponse} with a single {@link ModelCategory}.
23
+ *
24
+ * @example Requesting information from a category "premium" from a model of slug "plans".
25
+ * ```ts
26
+ * import Starlight from '@starlightcms/js-sdk'
27
+ *
28
+ * const response = await Starlight.plans.premium.get()
29
+ * ```
30
+ *
31
+ * @param slug The category slug.
32
+ */
11
33
  get(slug: string): Promise<StarlightItemResponse<ModelCategory>>;
12
34
  }
35
+ /**
36
+ * A Selector that provide all {@link ModelCategorySelector} methods and adds
37
+ * support for creating {@apilink ModelCategoryInstance | ModelCategoryInstances}
38
+ * using the dynamic syntax.
39
+ *
40
+ * See {@link ModelCategorySelector} to view all available methods. You can use
41
+ * a DynamicModelCategorySelector by accessing {@apilink ModelInstance.categories}.
42
+ *
43
+ * See {@doclink requests-and-responses#dynamic-syntax | Dynamic Instances}
44
+ * documentation to learn more about the dynamic syntax.
45
+ *
46
+ * @example Accessing a ModelCategorySelector using the dynamic syntax on a model of slug "posts"
47
+ * ```ts
48
+ * import Starlight from '@starlightcms/js-sdk'
49
+ *
50
+ * // "articles" below will be a ModelCategorySelector.
51
+ * const response = await Starlight.posts.categories.articles.list()
52
+ * ```
53
+ *
54
+ * @category Instances
55
+ */
13
56
  export declare type DynamicModelCategorySelector<D extends SerializedData> = ModelCategorySelector & {
14
57
  [slug: string]: ModelCategoryInstance<D>;
15
58
  };
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/selectors/ModelCategory/types.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,cAAc,EACd,qBAAqB,EACrB,qBAAqB,EACtB,MAAM,aAAa,CAAA;AACpB,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAA;AAErE,oBAAY,0BAA0B,GAAG;IACvC,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,iBAAiB,GAAG,kBAAkB,CAAA;CAC5E,CAAA;AAED,MAAM,WAAW,qBAAqB;IACpC,IAAI,CACF,OAAO,CAAC,EAAE,0BAA0B,GACnC,OAAO,CAAC,qBAAqB,CAAC,aAAa,CAAC,CAAC,CAAA;IAChD,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,qBAAqB,CAAC,aAAa,CAAC,CAAC,CAAA;CACjE;AAED,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,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 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/selectors/ModelCategory/types.ts"],"names":[],"mappings":"","sourcesContent":["import {\n ModelCategory,\n SerializedData,\n StarlightItemResponse,\n StarlightListResponse,\n} from '../../types'\nimport { ModelCategoryInstance } from '../../instances/ModelCategory'\n\nexport type ListModelCategoriesOptions = {\n query?: string\n page?: number\n limit?: number\n order?: 'title:asc' | 'title:desc' | 'entry_count:asc' | 'entry_count:desc'\n}\n\nexport interface ModelCategorySelector {\n list(\n options?: ListModelCategoriesOptions\n ): Promise<StarlightListResponse<ModelCategory>>\n get(slug: string): Promise<StarlightItemResponse<ModelCategory>>\n}\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\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,5 +1,5 @@
1
1
  import { StarlightClient } from '../../types';
2
- import { SearchSelector } from './types';
2
+ import { SearchEntriesParams, SearchSelector } from './types';
3
3
  export default function makeSearchSelector(client: StarlightClient): SearchSelector;
4
- export { SearchSelector };
4
+ export { SearchSelector, SearchEntriesParams };
5
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/selectors/Search/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,eAAe,EAEhB,MAAM,aAAa,CAAA;AACpB,OAAO,EAAwB,cAAc,EAAE,MAAM,SAAS,CAAA;AAE9D,MAAM,CAAC,OAAO,UAAU,kBAAkB,CACxC,MAAM,EAAE,eAAe,GACtB,cAAc,CAQhB;AAED,OAAO,EAAE,cAAc,EAAE,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/selectors/Search/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,eAAe,EAEhB,MAAM,aAAa,CAAA;AACpB,OAAO,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAE7D,MAAM,CAAC,OAAO,UAAU,kBAAkB,CACxC,MAAM,EAAE,eAAe,GACtB,cAAc,CAQhB;AAED,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,CAAA"}
@@ -1,7 +1,7 @@
1
1
  export default function makeSearchSelector(client) {
2
2
  return {
3
3
  entries(options) {
4
- return client.get('/search/entries', options);
4
+ return client.get('/search/entries', Object.assign({}, options));
5
5
  },
6
6
  };
7
7
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/selectors/Search/index.ts"],"names":[],"mappings":"AAQA,MAAM,CAAC,OAAO,UAAU,kBAAkB,CACxC,MAAuB;IAEvB,OAAO;QACL,OAAO,CACL,OAA6B;YAE7B,OAAO,MAAM,CAAC,GAAG,CAAC,iBAAiB,EAAE,OAAO,CAAC,CAAA;QAC/C,CAAC;KACF,CAAA;AACH,CAAC","sourcesContent":["import {\n Entry,\n SerializedData,\n StarlightClient,\n StarlightListResponse,\n} from '../../types'\nimport { SearchEntriesOptions, SearchSelector } from './types'\n\nexport default function makeSearchSelector(\n client: StarlightClient\n): SearchSelector {\n return {\n entries<T extends SerializedData = Record<string, unknown>>(\n options: SearchEntriesOptions\n ): Promise<StarlightListResponse<Entry<T>>> {\n return client.get('/search/entries', options)\n },\n }\n}\n\nexport { SearchSelector }\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/selectors/Search/index.ts"],"names":[],"mappings":"AAQA,MAAM,CAAC,OAAO,UAAU,kBAAkB,CACxC,MAAuB;IAEvB,OAAO;QACL,OAAO,CACL,OAA4B;YAE5B,OAAO,MAAM,CAAC,GAAG,CAAC,iBAAiB,oBAAO,OAAO,EAAG,CAAA;QACtD,CAAC;KACF,CAAA;AACH,CAAC","sourcesContent":["import {\n Entry,\n SerializedData,\n StarlightClient,\n StarlightListResponse,\n} from '../../types'\nimport { SearchEntriesParams, SearchSelector } from './types'\n\nexport default function makeSearchSelector(\n client: StarlightClient\n): SearchSelector {\n return {\n entries<T extends SerializedData = Record<string, unknown>>(\n options: SearchEntriesParams\n ): Promise<StarlightListResponse<Entry<T>>> {\n return client.get('/search/entries', { ...options })\n },\n }\n}\n\nexport { SearchSelector, SearchEntriesParams }\n"]}
@@ -1,14 +1,87 @@
1
- import { Entry, SerializedData, StarlightListResponse } from '../../types';
2
- export declare type SearchEntriesOptions = {
3
- page?: number;
4
- limit?: number;
5
- query?: string;
1
+ import { BaseRequestParameters, Entry, SerializedData, StarlightListResponse } from '../../types';
2
+ /**
3
+ * Request parameters for searching entries.
4
+ *
5
+ * Used by {@apilink SearchSelector.entries}.
6
+ *
7
+ * @group Request Parameters
8
+ */
9
+ export interface SearchEntriesParams extends BaseRequestParameters {
10
+ /**
11
+ * A comma-separated list of models. Only entries in these models
12
+ * will be returned. If undefined, entries from all
13
+ * workspace models will be listed.
14
+ *
15
+ * For instance, to show only entries in the "posts" and "videos" categories,
16
+ * pass `'posts,videos'`.
17
+ */
6
18
  models?: string;
19
+ /**
20
+ * A comma-separated list of categories. Only entries in these categories
21
+ * will be returned. If undefined, all entries will be listed, independently
22
+ * of their categories.
23
+ *
24
+ * For instance, to show only entries in the "news" and "articles" categories,
25
+ * pass `'news,category'`.
26
+ */
7
27
  categories?: string;
28
+ /**
29
+ * Define how items will be ordered. Check this field type to see the
30
+ * allowed options.
31
+ */
8
32
  order?: 'title:asc' | 'title:desc' | 'published_at:asc' | 'published_at:desc' | 'updated_at:asc' | 'updated_at:desc';
33
+ /**
34
+ * If defined, removes the given item from the list. Useful to create "related
35
+ * posts" lists.
36
+ *
37
+ * Note: this field only accepts IDs, and not slugs. Only one ID is allowed.
38
+ */
9
39
  except?: number;
10
- };
40
+ }
41
+ /**
42
+ * A Selector that provide methods to search for content. Only entry search
43
+ * is supported for the time being.
44
+ *
45
+ * You can use a SearchSelector by accessing
46
+ * {@apilink StarlightClient.search}.
47
+ *
48
+ * @group Selectors
49
+ */
11
50
  export interface SearchSelector {
12
- entries<T extends SerializedData = Record<string, unknown>>(options?: SearchEntriesOptions): Promise<StarlightListResponse<Entry<T>>>;
51
+ /**
52
+ * Returns a {@link StarlightListResponse} with a list of
53
+ * {@apilink Entry | Entries}. By default, entries from all models are
54
+ * returned, but filtering by model can be configured.
55
+ *
56
+ * @example Listing all entries in all workspace models.
57
+ * ```ts
58
+ * import Starlight from '@starlightcms/js-sdk'
59
+ *
60
+ * const response = await Starlight.search.entries()
61
+ * ```
62
+ *
63
+ * @example Searching for "hello world" within all entries in all workspace models.
64
+ * ```ts
65
+ * import Starlight from '@starlightcms/js-sdk'
66
+ *
67
+ * const response = await Starlight.search.entries({
68
+ * query: 'hello world'
69
+ * })
70
+ * ```
71
+ *
72
+ * @example Filtering the last example within specific models.
73
+ * ```ts
74
+ * import Starlight from '@starlightcms/js-sdk'
75
+ *
76
+ * const response = await Starlight.search.entries({
77
+ * query: 'hello world',
78
+ * models: 'posts,videos,magazines'
79
+ * })
80
+ * ```
81
+ *
82
+ * @param options An optional object of request parameters. See
83
+ * {@link SearchEntriesParams} for all available options.
84
+ */
85
+ entries<T extends SerializedData = Record<string, unknown>>(options?: SearchEntriesParams): Promise<StarlightListResponse<Entry<T>>>;
13
86
  }
14
87
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/selectors/Search/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAA;AAE1E,oBAAY,oBAAoB,GAAG;IACjC,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,KAAK,CAAC,EACF,WAAW,GACX,YAAY,GACZ,kBAAkB,GAClB,mBAAmB,GACnB,gBAAgB,GAChB,iBAAiB,CAAA;IACrB,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB,CAAA;AAED,MAAM,WAAW,cAAc;IAC7B,OAAO,CAAC,CAAC,SAAS,cAAc,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACxD,OAAO,CAAC,EAAE,oBAAoB,GAC7B,OAAO,CAAC,qBAAqB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;CAC5C"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/selectors/Search/types.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,EACrB,KAAK,EACL,cAAc,EACd,qBAAqB,EACtB,MAAM,aAAa,CAAA;AAEpB;;;;;;GAMG;AACH,MAAM,WAAW,mBAAoB,SAAQ,qBAAqB;IAChE;;;;;;;OAOG;IACH,MAAM,CAAC,EAAE,MAAM,CAAA;IACf;;;;;;;OAOG;IACH,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB;;;OAGG;IACH,KAAK,CAAC,EACF,WAAW,GACX,YAAY,GACZ,kBAAkB,GAClB,mBAAmB,GACnB,gBAAgB,GAChB,iBAAiB,CAAA;IACrB;;;;;OAKG;IACH,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,cAAc;IAC7B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAiCG;IACH,OAAO,CAAC,CAAC,SAAS,cAAc,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACxD,OAAO,CAAC,EAAE,mBAAmB,GAC5B,OAAO,CAAC,qBAAqB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;CAC5C"}
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/selectors/Search/types.ts"],"names":[],"mappings":"","sourcesContent":["import { Entry, SerializedData, StarlightListResponse } from '../../types'\n\nexport type SearchEntriesOptions = {\n page?: number\n limit?: number\n query?: string\n models?: string\n categories?: string\n order?:\n | 'title:asc'\n | 'title:desc'\n | 'published_at:asc'\n | 'published_at:desc'\n | 'updated_at:asc'\n | 'updated_at:desc'\n except?: number\n}\n\nexport interface SearchSelector {\n entries<T extends SerializedData = Record<string, unknown>>(\n options?: SearchEntriesOptions\n ): Promise<StarlightListResponse<Entry<T>>>\n}\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/selectors/Search/types.ts"],"names":[],"mappings":"","sourcesContent":["import {\n BaseRequestParameters,\n Entry,\n SerializedData,\n StarlightListResponse,\n} from '../../types'\n\n/**\n * Request parameters for searching entries.\n *\n * Used by {@apilink SearchSelector.entries}.\n *\n * @group Request Parameters\n */\nexport interface SearchEntriesParams extends BaseRequestParameters {\n /**\n * A comma-separated list of models. Only entries in these models\n * will be returned. If undefined, entries from all\n * workspace models will be listed.\n *\n * For instance, to show only entries in the \"posts\" and \"videos\" categories,\n * pass `'posts,videos'`.\n */\n models?: string\n /**\n * A comma-separated list of categories. Only entries in these categories\n * will be returned. If undefined, all entries will be listed, independently\n * of their categories.\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 | 'updated_at:asc'\n | 'updated_at:desc'\n /**\n * If defined, removes the given item from the list. Useful to create \"related\n * posts\" lists.\n *\n * Note: this field only accepts IDs, and not slugs. Only one ID is allowed.\n */\n except?: number\n}\n\n/**\n * A Selector that provide methods to search for content. Only entry search\n * is supported for the time being.\n *\n * You can use a SearchSelector by accessing\n * {@apilink StarlightClient.search}.\n *\n * @group Selectors\n */\nexport interface SearchSelector {\n /**\n * Returns a {@link StarlightListResponse} with a list of\n * {@apilink Entry | Entries}. By default, entries from all models are\n * returned, but filtering by model can be configured.\n *\n * @example Listing all entries in all workspace models.\n * ```ts\n * import Starlight from '@starlightcms/js-sdk'\n *\n * const response = await Starlight.search.entries()\n * ```\n *\n * @example Searching for \"hello world\" within all entries in all workspace models.\n * ```ts\n * import Starlight from '@starlightcms/js-sdk'\n *\n * const response = await Starlight.search.entries({\n * query: 'hello world'\n * })\n * ```\n *\n * @example Filtering the last example within specific models.\n * ```ts\n * import Starlight from '@starlightcms/js-sdk'\n *\n * const response = await Starlight.search.entries({\n * query: 'hello world',\n * models: 'posts,videos,magazines'\n * })\n * ```\n *\n * @param options An optional object of request parameters. See\n * {@link SearchEntriesParams} for all available options.\n */\n entries<T extends SerializedData = Record<string, unknown>>(\n options?: SearchEntriesParams\n ): Promise<StarlightListResponse<Entry<T>>>\n}\n"]}
@@ -1,6 +1,55 @@
1
1
  import { SerializedData, Singleton, StarlightItemResponse, StarlightListResponse } from '../../types';
2
+ /**
3
+ * A Selector that provide methods to list and request information on
4
+ * {@apilink Singleton | Singletons}.
5
+ *
6
+ * You can use an SingletonSelector by accessing
7
+ * {@apilink ModelInstance.singletons}.
8
+ *
9
+ * @group Selectors
10
+ */
2
11
  export interface SingletonSelector {
12
+ /**
13
+ * Returns a {@link StarlightItemResponse} with a single {@link Singleton}.
14
+ * This methods supports typing the returned Singleton by passing its data
15
+ * type as the generic type `<D>`.
16
+ *
17
+ * @example Requesting information from a singleton of slug "home".
18
+ * ```ts
19
+ * import Starlight from '@starlightcms/js-sdk'
20
+ *
21
+ * const response = await Starlight.singletons.get('home')
22
+ * ```
23
+ *
24
+ * @example Typing last example's response.
25
+ * ```ts
26
+ * import Starlight, { StringField, MediaField, VisualField } from '@starlightcms/js-sdk'
27
+ *
28
+ * type HomeFields = {
29
+ * title: StringField
30
+ * subtitle: StringField
31
+ * hero_image: MediaField
32
+ * hero_content: VisualField
33
+ * }
34
+ *
35
+ * // `response.data` will be of type Singleton<HomeFields>
36
+ * const response = await Starlight.singletons.get<HomeFields>('home')
37
+ * ```
38
+ * @typeParam D - The type of the returned Singleton's `data` property.
39
+ * @param slug The singleton slug.
40
+ */
3
41
  get<D extends SerializedData>(slug: string): Promise<StarlightItemResponse<Singleton<D>>>;
42
+ /**
43
+ * Returns a {@link StarlightListResponse} with a list of
44
+ * {@apilink Singleton | Singletons}.
45
+ *
46
+ * @example Requesting all workspace singletons.
47
+ * ```ts
48
+ * import Starlight from '@starlightcms/js-sdk'
49
+ *
50
+ * const response = await Starlight.singletons.list()
51
+ * ```
52
+ */
4
53
  list(): Promise<StarlightListResponse<Singleton<Record<string, unknown>>>>;
5
54
  }
6
55
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/selectors/Singleton/types.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,SAAS,EACT,qBAAqB,EACrB,qBAAqB,EACtB,MAAM,aAAa,CAAA;AAEpB,MAAM,WAAW,iBAAiB;IAChC,GAAG,CAAC,CAAC,SAAS,cAAc,EAC1B,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,qBAAqB,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;IAC/C,IAAI,IAAI,OAAO,CAAC,qBAAqB,CAAC,SAAS,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,CAAA;CAC3E"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/selectors/Singleton/types.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,SAAS,EACT,qBAAqB,EACrB,qBAAqB,EACtB,MAAM,aAAa,CAAA;AAEpB;;;;;;;;GAQG;AACH,MAAM,WAAW,iBAAiB;IAChC;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA4BG;IACH,GAAG,CAAC,CAAC,SAAS,cAAc,EAC1B,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,qBAAqB,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;IAE/C;;;;;;;;;;OAUG;IACH,IAAI,IAAI,OAAO,CAAC,qBAAqB,CAAC,SAAS,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,CAAA;CAC3E"}
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/selectors/Singleton/types.ts"],"names":[],"mappings":"","sourcesContent":["import {\n SerializedData,\n Singleton,\n StarlightItemResponse,\n StarlightListResponse,\n} from '../../types'\n\nexport interface SingletonSelector {\n get<D extends SerializedData>(\n slug: string\n ): Promise<StarlightItemResponse<Singleton<D>>>\n list(): Promise<StarlightListResponse<Singleton<Record<string, unknown>>>>\n}\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/selectors/Singleton/types.ts"],"names":[],"mappings":"","sourcesContent":["import {\n SerializedData,\n Singleton,\n StarlightItemResponse,\n StarlightListResponse,\n} from '../../types'\n\n/**\n * A Selector that provide methods to list and request information on\n * {@apilink Singleton | Singletons}.\n *\n * You can use an SingletonSelector by accessing\n * {@apilink ModelInstance.singletons}.\n *\n * @group Selectors\n */\nexport interface SingletonSelector {\n /**\n * Returns a {@link StarlightItemResponse} with a single {@link Singleton}.\n * This methods supports typing the returned Singleton by passing its data\n * type as the generic type `<D>`.\n *\n * @example Requesting information from a singleton of slug \"home\".\n * ```ts\n * import Starlight from '@starlightcms/js-sdk'\n *\n * const response = await Starlight.singletons.get('home')\n * ```\n *\n * @example Typing last example's response.\n * ```ts\n * import Starlight, { StringField, MediaField, VisualField } from '@starlightcms/js-sdk'\n *\n * type HomeFields = {\n * title: StringField\n * subtitle: StringField\n * hero_image: MediaField\n * hero_content: VisualField\n * }\n *\n * // `response.data` will be of type Singleton<HomeFields>\n * const response = await Starlight.singletons.get<HomeFields>('home')\n * ```\n * @typeParam D - The type of the returned Singleton's `data` property.\n * @param slug The singleton slug.\n */\n get<D extends SerializedData>(\n slug: string\n ): Promise<StarlightItemResponse<Singleton<D>>>\n\n /**\n * Returns a {@link StarlightListResponse} with a list of\n * {@apilink Singleton | Singletons}.\n *\n * @example Requesting all workspace singletons.\n * ```ts\n * import Starlight from '@starlightcms/js-sdk'\n *\n * const response = await Starlight.singletons.list()\n * ```\n */\n list(): Promise<StarlightListResponse<Singleton<Record<string, unknown>>>>\n}\n"]}
@@ -45,7 +45,8 @@ export interface MediaObject extends StarlightEntity {
45
45
  description?: string;
46
46
  }
47
47
  /**
48
- * Represents an Author entity returned by the API.
48
+ * Represents an Author entity returned by the API. Authors are returned in
49
+ * {@link Entry} requests.
49
50
  *
50
51
  * @group API Entities
51
52
  */
@@ -64,20 +65,97 @@ export interface Model extends StarlightEntity {
64
65
  entry_count?: number;
65
66
  }
66
67
  /**
67
- * Represents content data returned by either an Entry or
68
- * Singleton entity from the API.
68
+ * Represents content data returned by either an {@link Entry} or
69
+ * {@link Singleton} entity from the API.
70
+ *
71
+ * This is a utility type used internally by the SDK and you don't
72
+ * need to use it. Its purpose is to constraint Entry and Singleton
73
+ * data to the shape of a JS object.
74
+ *
75
+ * @category Internal Types
69
76
  */
70
77
  export declare type SerializedData = Record<string, unknown> | undefined;
71
78
  /**
72
79
  * Utility type that creates a string map of all fields of the given
73
- * SerializedData type with the `field` suffix. This is only useful to create
74
- * request methods that support field querying using the "field:foo" syntax.
80
+ * SerializedData type with the `field:` prefix. This syntax allows to filter
81
+ * specific fields when listing {@apilink Entry | Entries}:
75
82
  *
76
- * @internal
83
+ * - Text fields can be filtered by a string query. This works just like
84
+ * passing a `query` parameter, but it only applies to one field.
85
+ * - Boolean fields can be filtered by "true" or "false".
86
+ *
87
+ * If a request uses this type, it means that this syntax can be used in their
88
+ * parameters:
89
+ *
90
+ * ```ts
91
+ * import Starlight from '@starlightcms/js-sdk'
92
+ *
93
+ * const response = await Starlight.posts.entries.list({
94
+ * // EntrySelector.list() supports the "field:foo" syntax:
95
+ * 'field:content': 'hello world',
96
+ * 'field:is_featured': true,
97
+ *
98
+ * // EntrySelector.list() also support other parameters,
99
+ * // which are passed in this object too:
100
+ * page: 42,
101
+ * limit: 20,
102
+ * })
103
+ * ```
104
+ *
105
+ * @remark
106
+ *
107
+ * The information below is only useful for SDK maintainers.
108
+ *
109
+ * This type receives a {@link SerializedData}-like structure, like an object.
110
+ * For instance, for an {@link Entry} with fields "content" and "summary",
111
+ * the generated type would look like this:
112
+ *
113
+ * ```ts
114
+ * type GeneratedType = {
115
+ * 'field:content'?: string
116
+ * 'field:summary'?: string
117
+ * }
118
+ * ```
119
+ *
120
+ * However, note that QueryableFields receive a {@link SerializedData}, not an
121
+ * {@link Entry}:
122
+ *
123
+ * ```ts
124
+ * import { VisualField, StringField } from '@starlightcms/js-sdk'
125
+ *
126
+ * type EntryFields = {
127
+ * content: VisualField
128
+ * summary: StringField
129
+ * }
130
+ *
131
+ * type MyEntry = Entry<EntryFields>
132
+ *
133
+ * // Error TS2344: Type does not satisfy the constraint 'SerializedData'
134
+ * type GeneratedType = QueryableFields<MyEntry>
135
+ *
136
+ * // Works!
137
+ * type GeneratedType = QueryableFields<EntryFields>
138
+ * ```
139
+ *
140
+ * This type is only useful to request methods that support
141
+ * field querying using the "field:foo" syntax.
142
+ *
143
+ * @category Internal Types
77
144
  */
78
- export declare type ModelFieldOptions<D extends SerializedData> = {
79
- [K in keyof D as `field:${string & K}`]?: string;
145
+ export declare type QueryableFields<D extends SerializedData> = {
146
+ [K in keyof D as `field:${string & K}`]?: string | boolean;
80
147
  };
148
+ /**
149
+ * Utility type that return {@link QueryableFields} if the given type T
150
+ * is an {@link Entry} or a {@link Singleton}, but generates an empty object
151
+ * otherwise.
152
+ *
153
+ * Fun fact: internally, Entries and Singletons have parent Models,
154
+ * which is why they are called "modelables" here.
155
+ *
156
+ * @category Internal Types
157
+ */
158
+ export declare type WithQueryableFieldsOnModelables<T> = T extends Entry<never> | Singleton<never> ? QueryableFields<T['data']> : never;
81
159
  /**
82
160
  * Represents an Entry entity returned by the API.
83
161
  *
@@ -196,6 +274,9 @@ export declare type CollectionTypeMapper<T extends CollectionEntityTypes> = T ex
196
274
  /**
197
275
  * Represents a Collection entity returned by the API.
198
276
  *
277
+ * You can request collections using a {@link CollectionInstance} or a
278
+ * {@link CollectionSelector}.
279
+ *
199
280
  * @group API Entities
200
281
  */
201
282
  export interface Collection<T extends CollectionTypes = string> extends StarlightEntity {
@@ -1 +1 @@
1
- {"version":3,"file":"entities.d.ts","sourceRoot":"","sources":["../../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AM,CAAA;IACb,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,CAAC,CAAA;IACP,UAAU,CAAC,EAAE,MAAM,CAAA;CACpB;AAED;;GAEG;AACH,aAAK,aAAa,GACd,KAAK,CAAC,KAAK,CAAC,GACZ,SAAS,CAAC,KAAK,CAAC,GAChB,WAAW,GACX,UAAU,GACV,OAAO,CAAA;AAEX;;;;GAIG;AACH,MAAM,WAAW,QAAQ,CAAC,CAAC,SAAS,aAAa;IAC/C;;;;OAIG;IACH,IAAI,EAAE,CAAC,SAAS,KAAK,CAAC,KAAK,CAAC,GACxB,OAAO,GACP,CAAC,SAAS,SAAS,CAAC,KAAK,CAAC,GAC1B,WAAW,GACX,CAAC,SAAS,WAAW,GACrB,OAAO,GACP,CAAC,SAAS,UAAU,GACpB,YAAY,GACZ,MAAM,CAAA;IACV,EAAE,EAAE,MAAM,CAAA;IACV,MAAM,EAAE,CAAC,CAAA;CACV"}
@@ -1 +1 @@
1
- {"version":3,"file":"entities.js","sourceRoot":"","sources":["../../../src/types/entities.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * Base interface used by all entities returned by the API.\n *\n * @internal\n */\ninterface StarlightEntity {\n id: number\n created_at: string\n updated_at?: string\n}\n\n/**\n * Represents a Model Category entity returned by the API.\n *\n * @group API Entities\n */\nexport interface ModelCategory extends StarlightEntity {\n title: string\n slug: string\n entry_count?: number\n}\n\n/**\n * Represents a Media File entity returned by the API.\n *\n * @group API Entities\n */\nexport interface MediaFile extends StarlightEntity {\n variation: string\n path: string\n mime: string\n background_color?: string\n filesize: number\n meta?: Record<string, unknown>\n}\n\n/**\n * Represents a Media Object entity returned by the API.\n *\n * @group API Entities\n */\nexport interface MediaObject extends StarlightEntity {\n name: string\n extension: string\n mime: string\n files: MediaFile[]\n alt?: string\n description?: string\n}\n\n/**\n * Represents an Author entity returned by the API.\n *\n * @group API Entities\n */\nexport interface Author {\n id: number\n name: string\n}\n\n/**\n * Represents a Model entity returned by the API.\n *\n * @group API Entities\n */\nexport interface Model extends StarlightEntity {\n title: string\n slug: string\n entry_count?: number\n}\n\n/**\n * Represents content data returned by either an Entry or\n * Singleton entity from the API.\n */\nexport type SerializedData = Record<string, unknown> | undefined\n\n/**\n * Utility type that creates a string map of all fields of the given\n * SerializedData type with the `field` suffix. This is only useful to create\n * request methods that support field querying using the \"field:foo\" syntax.\n *\n * @internal\n */\nexport type ModelFieldOptions<D extends SerializedData> = {\n [K in keyof D as `field:${string & K}`]?: string\n}\n\n/**\n * Represents an Entry entity returned by the API.\n *\n * An Entry's `data` field can be further typed by passing an object-like\n * structure as the D generic type. This is useful to provide type-safety to\n * your application, since the `data` field is a generic JS object by default.\n *\n * It's recommended to use the Field types provided by this SDK to type your\n * entities using a type definition file on your project. For instance:\n *\n * ```ts\n * // starlight.d.ts file\n * import { VisualField, MediaField } from '@starlightcms/js-sdk'\n *\n * type PostFields = {\n * featured_image: MediaField\n * content: VisualField\n * }\n *\n * declare module '@starlightcms/js-sdk' {\n * export interface DefaultModelDefinition {\n * posts: PostFields\n * }\n * }\n * ```\n *\n * You can place this type definition file anywhere in your repository, but it's\n * good practice to place it at the same level as your root index.ts file. Then,\n * in your files, all SDK calls will correctly type `posts`:\n *\n * ```ts\n * import Starlight from '@starlightcms/js-sdk'\n *\n * // response type will be StarlightItemResponse<Entry<PostFields>> on request success\n * const response = await Starlight.posts.entries.get('hello-world')\n *\n * // helloWorld type is Entry<PostFields>\n * const helloWorld = response.data\n * ```\n *\n * See {@apilink DefaultModelDefinition} for more info.\n *\n * @group API Entities\n */\nexport interface Entry<D extends SerializedData>\n extends Omit<StarlightEntity, 'created_at'> {\n title: string\n slug: string\n data: D\n author: Author\n model?: Model\n category: ModelCategory | null\n published_at: string | null\n}\n\n/**\n * Represents a Singleton entity returned by the API.\n *\n * A Singleton's `data` field can be further typed by passing an object-like\n * structure as the D generic type. This is useful to provide type-safety to\n * your application, since the `data` field is a generic JS object by default.\n *\n * It's recommended to use the Field types provided by this SDK to type your\n * Singletons. For instance:\n *\n * ```ts\n * import { StringField, VisualField, MediaField } from '@starlightcms/js-sdk'\n *\n * type HomeFields = {\n * site_title: StringField\n * hero_image: MediaField\n * hero_content: VisualField\n * }\n *\n * // response type will be StarlightItemResponse<Singleton<HomeFields>> on request success\n * const response = Starlight.singletons.get<HomeFields>('home')\n *\n * // home type is Singleton<HomeFields>\n * const home = response.data\n * ```\n *\n * You could also place all your Singleton field types in the same type\n * definition file used to configure Entry fields, which makes it easier to\n * import these types in other files on your project. See\n * {@apilink DefaultModelDefinition} for more info.\n *\n * @group API Entities\n */\nexport interface Singleton<D extends SerializedData>\n extends Omit<StarlightEntity, 'created_at'> {\n title: string\n slug: string\n data: D\n published_at: string | null\n}\n\n/**\n * Currently supported Collection types. This type is mainly used to provide\n * autocompletion on IDEs, since it lets users use any string as well as the\n * known supported types.\n *\n * @internal\n */\nexport type CollectionTypes = 'entry' | 'singleton' | 'media' | string\n\n/**\n * Currently supported Collection entities. This type is mainly used to infer\n * the collection type string (see {@link CollectionTypes}) from the type of\n * entity that that Collection holds.\n *\n * @internal\n */\nexport type CollectionEntityTypes =\n | Entry<never>\n | Singleton<never>\n | MediaObject\n | unknown\n\n/**\n * Infers a Collection type from an entity type. See {@link CollectionTypes} and\n * {@link CollectionEntityTypes} to know more.\n *\n * @internal\n */\nexport type CollectionTypeMapper<T extends CollectionEntityTypes> =\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n T extends Entry<any>\n ? 'entry'\n : T extends Singleton<any> // eslint-disable-line @typescript-eslint/no-explicit-any\n ? 'singleton'\n : T extends MediaObject\n ? 'media'\n : string\n\n/**\n * Represents a Collection entity returned by the API.\n *\n * @group API Entities\n */\nexport interface Collection<T extends CollectionTypes = string>\n extends StarlightEntity {\n title: string\n slug: string\n type: T\n item_count?: number\n}\n\n/**\n * Currently supported Relation types.\n */\ntype RelationTypes =\n | Entry<never>\n | Singleton<never>\n | MediaObject\n | Collection\n | unknown\n\n/**\n * Represents a Relation entity returned by the API.\n *\n * @group API Entities\n */\nexport interface Relation<T extends RelationTypes> {\n /**\n * The relation type, which is always a string. If the `object` field of this\n * Relation is an Entry, type will be `entry`, if it's a Singleton, type will\n * be `singleton`, and so on.\n */\n type: T extends Entry<never>\n ? 'entry'\n : T extends Singleton<never>\n ? 'singleton'\n : T extends MediaObject\n ? 'media'\n : T extends Collection\n ? 'collection'\n : string\n id: number\n object: T\n}\n"]}
1
+ {"version":3,"file":"entities.js","sourceRoot":"","sources":["../../../src/types/entities.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * Base interface used by all entities returned by the API.\n *\n * @internal\n */\ninterface StarlightEntity {\n id: number\n created_at: string\n updated_at?: string\n}\n\n/**\n * Represents a Model Category entity returned by the API.\n *\n * @group API Entities\n */\nexport interface ModelCategory extends StarlightEntity {\n title: string\n slug: string\n entry_count?: number\n}\n\n/**\n * Represents a Media File entity returned by the API.\n *\n * @group API Entities\n */\nexport interface MediaFile extends StarlightEntity {\n variation: string\n path: string\n mime: string\n background_color?: string\n filesize: number\n meta?: Record<string, unknown>\n}\n\n/**\n * Represents a Media Object entity returned by the API.\n *\n * @group API Entities\n */\nexport interface MediaObject extends StarlightEntity {\n name: string\n extension: string\n mime: string\n files: MediaFile[]\n alt?: string\n description?: string\n}\n\n/**\n * Represents an Author entity returned by the API. Authors are returned in\n * {@link Entry} requests.\n *\n * @group API Entities\n */\nexport interface Author {\n id: number\n name: string\n}\n\n/**\n * Represents a Model entity returned by the API.\n *\n * @group API Entities\n */\nexport interface Model extends StarlightEntity {\n title: string\n slug: string\n entry_count?: number\n}\n\n/**\n * Represents content data returned by either an {@link Entry} or\n * {@link Singleton} entity from the API.\n *\n * This is a utility type used internally by the SDK and you don't\n * need to use it. Its purpose is to constraint Entry and Singleton\n * data to the shape of a JS object.\n *\n * @category Internal Types\n */\nexport type SerializedData = Record<string, unknown> | undefined\n\n/**\n * Utility type that creates a string map of all fields of the given\n * SerializedData type with the `field:` prefix. This syntax allows to filter\n * specific fields when listing {@apilink Entry | Entries}:\n *\n * - Text fields can be filtered by a string query. This works just like\n * passing a `query` parameter, but it only applies to one field.\n * - Boolean fields can be filtered by \"true\" or \"false\".\n *\n * If a request uses this type, it means that this syntax can be used in their\n * parameters:\n *\n * ```ts\n * import Starlight from '@starlightcms/js-sdk'\n *\n * const response = await Starlight.posts.entries.list({\n * // EntrySelector.list() supports the \"field:foo\" syntax:\n * 'field:content': 'hello world',\n * 'field:is_featured': true,\n *\n * // EntrySelector.list() also support other parameters,\n * // which are passed in this object too:\n * page: 42,\n * limit: 20,\n * })\n * ```\n *\n * @remark\n *\n * The information below is only useful for SDK maintainers.\n *\n * This type receives a {@link SerializedData}-like structure, like an object.\n * For instance, for an {@link Entry} with fields \"content\" and \"summary\",\n * the generated type would look like this:\n *\n * ```ts\n * type GeneratedType = {\n * 'field:content'?: string\n * 'field:summary'?: string\n * }\n * ```\n *\n * However, note that QueryableFields receive a {@link SerializedData}, not an\n * {@link Entry}:\n *\n * ```ts\n * import { VisualField, StringField } from '@starlightcms/js-sdk'\n *\n * type EntryFields = {\n * content: VisualField\n * summary: StringField\n * }\n *\n * type MyEntry = Entry<EntryFields>\n *\n * // Error TS2344: Type does not satisfy the constraint 'SerializedData'\n * type GeneratedType = QueryableFields<MyEntry>\n *\n * // Works!\n * type GeneratedType = QueryableFields<EntryFields>\n * ```\n *\n * This type is only useful to request methods that support\n * field querying using the \"field:foo\" syntax.\n *\n * @category Internal Types\n */\nexport type QueryableFields<D extends SerializedData> = {\n [K in keyof D as `field:${string & K}`]?: string | boolean\n}\n\n/**\n * Utility type that return {@link QueryableFields} if the given type T\n * is an {@link Entry} or a {@link Singleton}, but generates an empty object\n * otherwise.\n *\n * Fun fact: internally, Entries and Singletons have parent Models,\n * which is why they are called \"modelables\" here.\n *\n * @category Internal Types\n */\nexport type WithQueryableFieldsOnModelables<T> = T extends\n | Entry<never>\n | Singleton<never>\n ? QueryableFields<T['data']>\n : never\n\n/**\n * Represents an Entry entity returned by the API.\n *\n * An Entry's `data` field can be further typed by passing an object-like\n * structure as the D generic type. This is useful to provide type-safety to\n * your application, since the `data` field is a generic JS object by default.\n *\n * It's recommended to use the Field types provided by this SDK to type your\n * entities using a type definition file on your project. For instance:\n *\n * ```ts\n * // starlight.d.ts file\n * import { VisualField, MediaField } from '@starlightcms/js-sdk'\n *\n * type PostFields = {\n * featured_image: MediaField\n * content: VisualField\n * }\n *\n * declare module '@starlightcms/js-sdk' {\n * export interface DefaultModelDefinition {\n * posts: PostFields\n * }\n * }\n * ```\n *\n * You can place this type definition file anywhere in your repository, but it's\n * good practice to place it at the same level as your root index.ts file. Then,\n * in your files, all SDK calls will correctly type `posts`:\n *\n * ```ts\n * import Starlight from '@starlightcms/js-sdk'\n *\n * // response type will be StarlightItemResponse<Entry<PostFields>> on request success\n * const response = await Starlight.posts.entries.get('hello-world')\n *\n * // helloWorld type is Entry<PostFields>\n * const helloWorld = response.data\n * ```\n *\n * See {@apilink DefaultModelDefinition} for more info.\n *\n * @group API Entities\n */\nexport interface Entry<D extends SerializedData>\n extends Omit<StarlightEntity, 'created_at'> {\n title: string\n slug: string\n data: D\n author: Author\n model?: Model\n category: ModelCategory | null\n published_at: string | null\n}\n\n/**\n * Represents a Singleton entity returned by the API.\n *\n * A Singleton's `data` field can be further typed by passing an object-like\n * structure as the D generic type. This is useful to provide type-safety to\n * your application, since the `data` field is a generic JS object by default.\n *\n * It's recommended to use the Field types provided by this SDK to type your\n * Singletons. For instance:\n *\n * ```ts\n * import { StringField, VisualField, MediaField } from '@starlightcms/js-sdk'\n *\n * type HomeFields = {\n * site_title: StringField\n * hero_image: MediaField\n * hero_content: VisualField\n * }\n *\n * // response type will be StarlightItemResponse<Singleton<HomeFields>> on request success\n * const response = Starlight.singletons.get<HomeFields>('home')\n *\n * // home type is Singleton<HomeFields>\n * const home = response.data\n * ```\n *\n * You could also place all your Singleton field types in the same type\n * definition file used to configure Entry fields, which makes it easier to\n * import these types in other files on your project. See\n * {@apilink DefaultModelDefinition} for more info.\n *\n * @group API Entities\n */\nexport interface Singleton<D extends SerializedData>\n extends Omit<StarlightEntity, 'created_at'> {\n title: string\n slug: string\n data: D\n published_at: string | null\n}\n\n/**\n * Currently supported Collection types. This type is mainly used to provide\n * autocompletion on IDEs, since it lets users use any string as well as the\n * known supported types.\n *\n * @internal\n */\nexport type CollectionTypes = 'entry' | 'singleton' | 'media' | string\n\n/**\n * Currently supported Collection entities. This type is mainly used to infer\n * the collection type string (see {@link CollectionTypes}) from the type of\n * entity that that Collection holds.\n *\n * @internal\n */\nexport type CollectionEntityTypes =\n | Entry<never>\n | Singleton<never>\n | MediaObject\n | unknown\n\n/**\n * Infers a Collection type from an entity type. See {@link CollectionTypes} and\n * {@link CollectionEntityTypes} to know more.\n *\n * @internal\n */\nexport type CollectionTypeMapper<T extends CollectionEntityTypes> =\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n T extends Entry<any>\n ? 'entry'\n : T extends Singleton<any> // eslint-disable-line @typescript-eslint/no-explicit-any\n ? 'singleton'\n : T extends MediaObject\n ? 'media'\n : string\n\n/**\n * Represents a Collection entity returned by the API.\n *\n * You can request collections using a {@link CollectionInstance} or a\n * {@link CollectionSelector}.\n *\n * @group API Entities\n */\nexport interface Collection<T extends CollectionTypes = string>\n extends StarlightEntity {\n title: string\n slug: string\n type: T\n item_count?: number\n}\n\n/**\n * Currently supported Relation types.\n */\ntype RelationTypes =\n | Entry<never>\n | Singleton<never>\n | MediaObject\n | Collection\n | unknown\n\n/**\n * Represents a Relation entity returned by the API.\n *\n * @group API Entities\n */\nexport interface Relation<T extends RelationTypes> {\n /**\n * The relation type, which is always a string. If the `object` field of this\n * Relation is an Entry, type will be `entry`, if it's a Singleton, type will\n * be `singleton`, and so on.\n */\n type: T extends Entry<never>\n ? 'entry'\n : T extends Singleton<never>\n ? 'singleton'\n : T extends MediaObject\n ? 'media'\n : T extends Collection\n ? 'collection'\n : string\n id: number\n object: T\n}\n"]}