@starlightcms/js-sdk 3.0.0 → 3.1.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 (143) hide show
  1. package/dist/cjs/client.d.ts.map +1 -1
  2. package/dist/cjs/client.js +1 -1
  3. package/dist/cjs/client.js.map +1 -1
  4. package/dist/cjs/instances/Collection/index.js +4 -4
  5. package/dist/cjs/instances/Collection/index.js.map +1 -1
  6. package/dist/cjs/instances/Collection/types.d.ts +14 -6
  7. package/dist/cjs/instances/Collection/types.d.ts.map +1 -1
  8. package/dist/cjs/instances/Collection/types.js.map +1 -1
  9. package/dist/cjs/instances/Form/index.d.ts.map +1 -1
  10. package/dist/cjs/instances/Form/index.js +4 -4
  11. package/dist/cjs/instances/Form/index.js.map +1 -1
  12. package/dist/cjs/instances/Form/types.d.ts +12 -4
  13. package/dist/cjs/instances/Form/types.d.ts.map +1 -1
  14. package/dist/cjs/instances/Form/types.js.map +1 -1
  15. package/dist/cjs/instances/Model/index.d.ts.map +1 -1
  16. package/dist/cjs/instances/Model/index.js +2 -2
  17. package/dist/cjs/instances/Model/index.js.map +1 -1
  18. package/dist/cjs/instances/Model/types.d.ts +7 -2
  19. package/dist/cjs/instances/Model/types.d.ts.map +1 -1
  20. package/dist/cjs/instances/Model/types.js.map +1 -1
  21. package/dist/cjs/instances/ModelCategory/index.d.ts +1 -1
  22. package/dist/cjs/instances/ModelCategory/index.d.ts.map +1 -1
  23. package/dist/cjs/instances/ModelCategory/index.js +4 -4
  24. package/dist/cjs/instances/ModelCategory/index.js.map +1 -1
  25. package/dist/cjs/instances/ModelCategory/types.d.ts +16 -7
  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.js +4 -4
  29. package/dist/cjs/selectors/Collection/index.js.map +1 -1
  30. package/dist/cjs/selectors/Collection/types.d.ts +13 -6
  31. package/dist/cjs/selectors/Collection/types.d.ts.map +1 -1
  32. package/dist/cjs/selectors/Collection/types.js.map +1 -1
  33. package/dist/cjs/selectors/Entry/index.d.ts.map +1 -1
  34. package/dist/cjs/selectors/Entry/index.js +2 -2
  35. package/dist/cjs/selectors/Entry/index.js.map +1 -1
  36. package/dist/cjs/selectors/Entry/types.d.ts +13 -10
  37. package/dist/cjs/selectors/Entry/types.d.ts.map +1 -1
  38. package/dist/cjs/selectors/Entry/types.js.map +1 -1
  39. package/dist/cjs/selectors/Media/index.js +4 -4
  40. package/dist/cjs/selectors/Media/index.js.map +1 -1
  41. package/dist/cjs/selectors/Media/types.d.ts +12 -3
  42. package/dist/cjs/selectors/Media/types.d.ts.map +1 -1
  43. package/dist/cjs/selectors/Media/types.js.map +1 -1
  44. package/dist/cjs/selectors/Model/index.d.ts +1 -1
  45. package/dist/cjs/selectors/Model/index.d.ts.map +1 -1
  46. package/dist/cjs/selectors/Model/index.js +4 -4
  47. package/dist/cjs/selectors/Model/index.js.map +1 -1
  48. package/dist/cjs/selectors/Model/types.d.ts +12 -3
  49. package/dist/cjs/selectors/Model/types.d.ts.map +1 -1
  50. package/dist/cjs/selectors/Model/types.js.map +1 -1
  51. package/dist/cjs/selectors/ModelCategory/index.d.ts +1 -1
  52. package/dist/cjs/selectors/ModelCategory/index.d.ts.map +1 -1
  53. package/dist/cjs/selectors/ModelCategory/index.js +4 -4
  54. package/dist/cjs/selectors/ModelCategory/index.js.map +1 -1
  55. package/dist/cjs/selectors/ModelCategory/types.d.ts +13 -6
  56. package/dist/cjs/selectors/ModelCategory/types.d.ts.map +1 -1
  57. package/dist/cjs/selectors/ModelCategory/types.js.map +1 -1
  58. package/dist/cjs/selectors/Search/index.d.ts.map +1 -1
  59. package/dist/cjs/selectors/Search/index.js +2 -2
  60. package/dist/cjs/selectors/Search/index.js.map +1 -1
  61. package/dist/cjs/selectors/Search/types.d.ts +8 -5
  62. package/dist/cjs/selectors/Search/types.d.ts.map +1 -1
  63. package/dist/cjs/selectors/Search/types.js.map +1 -1
  64. package/dist/cjs/selectors/Singleton/index.js +4 -4
  65. package/dist/cjs/selectors/Singleton/index.js.map +1 -1
  66. package/dist/cjs/selectors/Singleton/types.d.ts +12 -3
  67. package/dist/cjs/selectors/Singleton/types.d.ts.map +1 -1
  68. package/dist/cjs/selectors/Singleton/types.js.map +1 -1
  69. package/dist/cjs/types/index.d.ts +10 -2
  70. package/dist/cjs/types/index.d.ts.map +1 -1
  71. package/dist/cjs/types/index.js.map +1 -1
  72. package/dist/esm/client.d.ts.map +1 -1
  73. package/dist/esm/client.js +1 -1
  74. package/dist/esm/client.js.map +1 -1
  75. package/dist/esm/instances/Collection/index.js +4 -4
  76. package/dist/esm/instances/Collection/index.js.map +1 -1
  77. package/dist/esm/instances/Collection/types.d.ts +14 -6
  78. package/dist/esm/instances/Collection/types.d.ts.map +1 -1
  79. package/dist/esm/instances/Collection/types.js.map +1 -1
  80. package/dist/esm/instances/Form/index.d.ts.map +1 -1
  81. package/dist/esm/instances/Form/index.js +4 -4
  82. package/dist/esm/instances/Form/index.js.map +1 -1
  83. package/dist/esm/instances/Form/types.d.ts +12 -4
  84. package/dist/esm/instances/Form/types.d.ts.map +1 -1
  85. package/dist/esm/instances/Form/types.js.map +1 -1
  86. package/dist/esm/instances/Model/index.d.ts.map +1 -1
  87. package/dist/esm/instances/Model/index.js +2 -2
  88. package/dist/esm/instances/Model/index.js.map +1 -1
  89. package/dist/esm/instances/Model/types.d.ts +7 -2
  90. package/dist/esm/instances/Model/types.d.ts.map +1 -1
  91. package/dist/esm/instances/Model/types.js.map +1 -1
  92. package/dist/esm/instances/ModelCategory/index.d.ts +1 -1
  93. package/dist/esm/instances/ModelCategory/index.d.ts.map +1 -1
  94. package/dist/esm/instances/ModelCategory/index.js +4 -4
  95. package/dist/esm/instances/ModelCategory/index.js.map +1 -1
  96. package/dist/esm/instances/ModelCategory/types.d.ts +16 -7
  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.js +4 -4
  100. package/dist/esm/selectors/Collection/index.js.map +1 -1
  101. package/dist/esm/selectors/Collection/types.d.ts +13 -6
  102. package/dist/esm/selectors/Collection/types.d.ts.map +1 -1
  103. package/dist/esm/selectors/Collection/types.js.map +1 -1
  104. package/dist/esm/selectors/Entry/index.d.ts.map +1 -1
  105. package/dist/esm/selectors/Entry/index.js +2 -2
  106. package/dist/esm/selectors/Entry/index.js.map +1 -1
  107. package/dist/esm/selectors/Entry/types.d.ts +13 -10
  108. package/dist/esm/selectors/Entry/types.d.ts.map +1 -1
  109. package/dist/esm/selectors/Entry/types.js.map +1 -1
  110. package/dist/esm/selectors/Media/index.js +4 -4
  111. package/dist/esm/selectors/Media/index.js.map +1 -1
  112. package/dist/esm/selectors/Media/types.d.ts +12 -3
  113. package/dist/esm/selectors/Media/types.d.ts.map +1 -1
  114. package/dist/esm/selectors/Media/types.js.map +1 -1
  115. package/dist/esm/selectors/Model/index.d.ts +1 -1
  116. package/dist/esm/selectors/Model/index.d.ts.map +1 -1
  117. package/dist/esm/selectors/Model/index.js +4 -4
  118. package/dist/esm/selectors/Model/index.js.map +1 -1
  119. package/dist/esm/selectors/Model/types.d.ts +12 -3
  120. package/dist/esm/selectors/Model/types.d.ts.map +1 -1
  121. package/dist/esm/selectors/Model/types.js.map +1 -1
  122. package/dist/esm/selectors/ModelCategory/index.d.ts +1 -1
  123. package/dist/esm/selectors/ModelCategory/index.d.ts.map +1 -1
  124. package/dist/esm/selectors/ModelCategory/index.js +4 -4
  125. package/dist/esm/selectors/ModelCategory/index.js.map +1 -1
  126. package/dist/esm/selectors/ModelCategory/types.d.ts +13 -6
  127. package/dist/esm/selectors/ModelCategory/types.d.ts.map +1 -1
  128. package/dist/esm/selectors/ModelCategory/types.js.map +1 -1
  129. package/dist/esm/selectors/Search/index.d.ts.map +1 -1
  130. package/dist/esm/selectors/Search/index.js +2 -2
  131. package/dist/esm/selectors/Search/index.js.map +1 -1
  132. package/dist/esm/selectors/Search/types.d.ts +8 -5
  133. package/dist/esm/selectors/Search/types.d.ts.map +1 -1
  134. package/dist/esm/selectors/Search/types.js.map +1 -1
  135. package/dist/esm/selectors/Singleton/index.js +4 -4
  136. package/dist/esm/selectors/Singleton/index.js.map +1 -1
  137. package/dist/esm/selectors/Singleton/types.d.ts +12 -3
  138. package/dist/esm/selectors/Singleton/types.d.ts.map +1 -1
  139. package/dist/esm/selectors/Singleton/types.js.map +1 -1
  140. package/dist/esm/types/index.d.ts +10 -2
  141. package/dist/esm/types/index.d.ts.map +1 -1
  142. package/dist/esm/types/index.js.map +1 -1
  143. package/package.json +1 -1
@@ -1,4 +1,4 @@
1
- import { BaseRequestParameters, Entry, SerializedData, StarlightListResponse } from '../../types';
1
+ import { ListRequestParameters, Entry, SerializedData, StarlightListResponse } from '../../types';
2
2
  /**
3
3
  * Request parameters for searching entries.
4
4
  *
@@ -6,7 +6,7 @@ import { BaseRequestParameters, Entry, SerializedData, StarlightListResponse } f
6
6
  *
7
7
  * @group Request Parameters
8
8
  */
9
- export interface SearchEntriesParams extends BaseRequestParameters {
9
+ export interface SearchEntriesParams extends ListRequestParameters {
10
10
  /**
11
11
  * A comma-separated list of models. Only entries in these models
12
12
  * will be returned. If undefined, entries from all
@@ -79,9 +79,12 @@ export interface SearchSelector {
79
79
  * })
80
80
  * ```
81
81
  *
82
- * @param options An optional object of request parameters. See
83
- * {@link SearchEntriesParams} for all available options.
82
+ * @param params An optional object of request parameters. See
83
+ * {@link SearchEntriesParams} for all available parameters.
84
+ * @param options An optional object of fetch options. See
85
+ * {@link https://developer.mozilla.org/en-US/docs/Web/API/RequestInit} for
86
+ * more info.
84
87
  */
85
- entries<T extends SerializedData = Record<string, unknown>>(options?: SearchEntriesParams): Promise<StarlightListResponse<Entry<T>>>;
88
+ entries<T extends SerializedData = Record<string, unknown>>(params?: SearchEntriesParams, options?: RequestInit): Promise<StarlightListResponse<Entry<T>>>;
86
89
  }
87
90
  //# 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,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
+ {"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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAoCG;IACH,OAAO,CAAC,CAAC,SAAS,cAAc,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACxD,MAAM,CAAC,EAAE,mBAAmB,EAC5B,OAAO,CAAC,EAAE,WAAW,GACpB,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 {\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
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/selectors/Search/types.ts"],"names":[],"mappings":"","sourcesContent":["import {\n ListRequestParameters,\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 ListRequestParameters {\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 params An optional object of request parameters. See\n * {@link SearchEntriesParams} for all available parameters.\n * @param options An optional object of fetch options. See\n * {@link https://developer.mozilla.org/en-US/docs/Web/API/RequestInit} for\n * more info.\n */\n entries<T extends SerializedData = Record<string, unknown>>(\n params?: SearchEntriesParams,\n options?: RequestInit,\n ): Promise<StarlightListResponse<Entry<T>>>\n}\n"]}
@@ -1,10 +1,10 @@
1
1
  export default function makeSingletonSelector(client) {
2
2
  return {
3
- list() {
4
- return client.get('/singletons');
3
+ list(params, options) {
4
+ return client.get('/singletons', params, options);
5
5
  },
6
- get(slug) {
7
- return client.get(`/singletons/${slug}`);
6
+ get(slug, params, options) {
7
+ return client.get(`/singletons/${slug}`, params, options);
8
8
  },
9
9
  };
10
10
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/selectors/Singleton/index.ts"],"names":[],"mappings":"AAGA,MAAM,CAAC,OAAO,UAAU,qBAAqB,CAC3C,MAAuB;IAEvB,OAAO;QACL,IAAI;YACF,OAAO,MAAM,CAAC,GAAG,CAAC,aAAa,CAAC,CAAA;QAClC,CAAC;QAED,GAAG,CAAC,IAAI;YACN,OAAO,MAAM,CAAC,GAAG,CAAC,eAAe,IAAI,EAAE,CAAC,CAAA;QAC1C,CAAC;KACF,CAAA;AACH,CAAC","sourcesContent":["import { StarlightClient } from '../../types'\nimport { SingletonSelector } from './types'\n\nexport default function makeSingletonSelector(\n client: StarlightClient\n): SingletonSelector {\n return {\n list() {\n return client.get('/singletons')\n },\n\n get(slug) {\n return client.get(`/singletons/${slug}`)\n },\n }\n}\n\nexport { SingletonSelector }\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/selectors/Singleton/index.ts"],"names":[],"mappings":"AAGA,MAAM,CAAC,OAAO,UAAU,qBAAqB,CAC3C,MAAuB;IAEvB,OAAO;QACL,IAAI,CAAC,MAAM,EAAE,OAAO;YAClB,OAAO,MAAM,CAAC,GAAG,CAAC,aAAa,EAAE,MAAM,EAAE,OAAO,CAAC,CAAA;QACnD,CAAC;QAED,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO;YACvB,OAAO,MAAM,CAAC,GAAG,CAAC,eAAe,IAAI,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,CAAA;QAC3D,CAAC;KACF,CAAA;AACH,CAAC","sourcesContent":["import { StarlightClient } from '../../types'\nimport { SingletonSelector } from './types'\n\nexport default function makeSingletonSelector(\n client: StarlightClient,\n): SingletonSelector {\n return {\n list(params, options) {\n return client.get('/singletons', params, options)\n },\n\n get(slug, params, options) {\n return client.get(`/singletons/${slug}`, params, options)\n },\n }\n}\n\nexport { SingletonSelector }\n"]}
@@ -1,4 +1,4 @@
1
- import { SerializedData, Singleton, StarlightItemResponse, StarlightListResponse } from '../../types';
1
+ import { BaseRequestParameters, SerializedData, Singleton, StarlightItemResponse, StarlightListResponse } from '../../types';
2
2
  /**
3
3
  * A Selector that provide methods to list and request information on
4
4
  * {@apilink Singleton | Singletons}.
@@ -37,8 +37,12 @@ export interface SingletonSelector {
37
37
  * ```
38
38
  * @typeParam D - The type of the returned Singleton's `data` property.
39
39
  * @param slug The singleton slug.
40
+ * @param params An optional object of request parameters.
41
+ * @param options An optional object of fetch options. See
42
+ * {@link https://developer.mozilla.org/en-US/docs/Web/API/RequestInit} for
43
+ * more info.
40
44
  */
41
- get<D extends SerializedData>(slug: string): Promise<StarlightItemResponse<Singleton<D>>>;
45
+ get<D extends SerializedData>(slug: string, params?: BaseRequestParameters, options?: RequestInit): Promise<StarlightItemResponse<Singleton<D>>>;
42
46
  /**
43
47
  * Returns a {@link StarlightListResponse} with a list of
44
48
  * {@apilink Singleton | Singletons}.
@@ -49,7 +53,12 @@ export interface SingletonSelector {
49
53
  *
50
54
  * const response = await Starlight.singletons.list()
51
55
  * ```
56
+ *
57
+ * @param params An optional object of request parameters.
58
+ * @param options An optional object of fetch options. See
59
+ * {@link https://developer.mozilla.org/en-US/docs/Web/API/RequestInit} for
60
+ * more info.
52
61
  */
53
- list(): Promise<StarlightListResponse<Singleton<Record<string, unknown>>>>;
62
+ list(params?: BaseRequestParameters, options?: RequestInit): Promise<StarlightListResponse<Singleton<Record<string, unknown>>>>;
54
63
  }
55
64
  //# 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;;;;;;;;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
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/selectors/Singleton/types.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,EACrB,cAAc,EACd,SAAS,EACT,qBAAqB,EACrB,qBAAqB,EACtB,MAAM,aAAa,CAAA;AAEpB;;;;;;;;GAQG;AACH,MAAM,WAAW,iBAAiB;IAChC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAgCG;IACH,GAAG,CAAC,CAAC,SAAS,cAAc,EAC1B,IAAI,EAAE,MAAM,EACZ,MAAM,CAAC,EAAE,qBAAqB,EAC9B,OAAO,CAAC,EAAE,WAAW,GACpB,OAAO,CAAC,qBAAqB,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;IAE/C;;;;;;;;;;;;;;;OAeG;IACH,IAAI,CACF,MAAM,CAAC,EAAE,qBAAqB,EAC9B,OAAO,CAAC,EAAE,WAAW,GACpB,OAAO,CAAC,qBAAqB,CAAC,SAAS,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,CAAA;CACtE"}
@@ -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\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"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/selectors/Singleton/types.ts"],"names":[],"mappings":"","sourcesContent":["import {\n BaseRequestParameters,\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 * @param params An optional object of request parameters.\n * @param options An optional object of fetch options. See\n * {@link https://developer.mozilla.org/en-US/docs/Web/API/RequestInit} for\n * more info.\n */\n get<D extends SerializedData>(\n slug: string,\n params?: BaseRequestParameters,\n options?: RequestInit,\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 * @param params An optional object of request parameters.\n * @param options An optional object of fetch options. See\n * {@link https://developer.mozilla.org/en-US/docs/Web/API/RequestInit} for\n * more info.\n */\n list(\n params?: BaseRequestParameters,\n options?: RequestInit,\n ): Promise<StarlightListResponse<Singleton<Record<string, unknown>>>>\n}\n"]}
@@ -142,7 +142,7 @@ export interface StarlightClient<D extends WorkspaceModelDefinition = DefaultMod
142
142
  * @throws {@link StarlightError} on any errors.
143
143
  * @category Other Methods
144
144
  */
145
- get<T = Record<string, unknown>>(path: string, params?: Record<string, string | number | boolean | undefined>, options?: RequestInit): Promise<T>;
145
+ get<T = Record<string, unknown>>(path: string, params?: BaseRequestParameters, options?: RequestInit): Promise<T>;
146
146
  /**
147
147
  * Returns a {@link DynamicModelSelector}, which is a {@link ModelSelector}
148
148
  * with support for creating {@apilink ModelInstance | ModelInstances} using the dynamic syntax.
@@ -542,12 +542,20 @@ export interface WorkspaceModelDefinition {
542
542
  [slug: string]: SerializedData;
543
543
  }
544
544
  /**
545
- * Request parameters used by most SDK `list()` methods.
545
+ * An object that accepts any string, number and boolean values.
546
+ * Used as the base for most request parameter interfaces in the SDK.
546
547
  *
547
548
  * @group Request Parameters
548
549
  */
549
550
  export interface BaseRequestParameters {
550
551
  [key: string]: string | number | boolean | undefined;
552
+ }
553
+ /**
554
+ * Request parameters used by most SDK `list()` methods.
555
+ *
556
+ * @group Request Parameters
557
+ */
558
+ export interface ListRequestParameters extends BaseRequestParameters {
551
559
  /**
552
560
  * The page requested.
553
561
  */
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAClE,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAA;AACzD,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAA;AACzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AAC1D,OAAO,EAAE,yBAAyB,EAAE,MAAM,yBAAyB,CAAA;AACnE,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAClD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AACpD,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAChD,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAA;AAE7D,cAAc,UAAU,CAAA;AACxB,cAAc,YAAY,CAAA;AAC1B,cAAc,UAAU,CAAA;AACxB,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAE3B;;;;GAIG;AACH,MAAM,MAAM,OAAO,GAAG,kCAAkC,GAAG,MAAM,CAAA;AAEjE;;;;;;GAMG;AACH,MAAM,MAAM,eAAe,GAAG;IAC5B;;;;;;;OAOG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB;;;;;OAKG;IACH,OAAO,CAAC,EAA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;;;;OAOG;IACH,MAAM,CAAC,EAAE,MAAM,CAAA;IACf;;;;;OAKG;IACH,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":"AAWA,cAAc,UAAU,CAAA;AACxB,cAAc,YAAY,CAAA;AAC1B,cAAc,UAAU,CAAA;AACxB,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA","sourcesContent":["import { CollectionEntityTypes, SerializedData } from './entities'\nimport { DynamicModelSelector } from '../selectors/Model'\nimport { DynamicModelInstance } from '../instances/Model'\nimport { SingletonSelector } from '../selectors/Singleton'\nimport { DynamicCollectionSelector } from '../selectors/Collection'\nimport { MediaSelector } from '../selectors/Media'\nimport { SearchSelector } from '../selectors/Search'\nimport { CollectionInstance } from '../instances/Collection'\nimport { FormInstance } from '../instances/Form'\nimport { DynamicFormSelector } from '../selectors/Form/types'\n\nexport * from './fields'\nexport * from './entities'\nexport * from './visual'\nexport * from './instances'\nexport * from './selectors'\n\n/**\n * This is a utility type that allows any string to be used as a URL, but\n * provides a default one which can be used by IDEs to provide auto-completion.\n * The default URL points to version 2 of the Query API.\n */\nexport type BaseUrl = 'https://query.starlightcms.io/v2' | string\n\n/**\n * The available options to configure a {@link StarlightClient}.\n *\n * `workspace` is required when creating new clients or configuring the\n * {@apilink default | default client}.\n * @group Client\n */\nexport type StarlightConfig = {\n /**\n * The ID of the workspace that the client should use to request data.\n *\n * Note: the current APIs only support using workspace IDs as identifiers,\n * and **not** slugs. Slug support will be added in the future. You can find\n * the workspace ID in the left-side menu on the Starlight interface or below\n * the workspace name in the workspace list.\n */\n workspace?: string\n /**\n * The Starlight Query API URL, including the version, and without a trailing\n * slash. Defaults to the production Query API URL.\n *\n * You only need to set this if you're not using Starlight's production APIs.\n */\n baseUrl?: BaseUrl\n /**\n * When true, logs all API requests in the console. Defaults to false.\n */\n debug?: boolean\n}\n\n/**\n * The Starlight client is the main entry point for any requests you might want\n * to make to Starlight's APIs.\n *\n * There's two ways of interacting with a client: using the\n * {@apilink default | default client} exported by the SDK or creating a new\n * client instance using the\n * {@apilink makeStarlightClient | makeStarlightClient function}. Follow the\n * provided links to learn how to use each method.\n *\n * Either way you choose to interact, all clients expose the same methods and\n * accessors that provide ways to request data. These methods and accessors\n * return Selector or Instance objects, which are documented in the sections\n * of the same name found in this API's sidebar.\n *\n * @group Client\n */\nexport interface StarlightClient<\n D extends WorkspaceModelDefinition = DefaultModelDefinition,\n> {\n /**\n * Updates the client configuration. See {@link StarlightConfig} to see all\n * the available options.\n *\n * If you want to use the {@apilink default | default SDK client}, you need to\n * set its workspace using this method in your application. You should run\n * this method only once, and as soon as possible in your application\n * lifecycle. For instance, when using React:\n *\n * ```js\n * // src/index.js\n * import { createRoot } from \"react-dom/client\"\n * import Starlight from '@starlightcms/js-sdk'\n * import MyApp from './MyApp.js'\n *\n * // We only need to run this once. In this case, we're\n * // running it before initializing our React app.\n * Starlight.configure({\n * workspace: '1234567890'\n * })\n *\n * const rootElement = document.getElementById(\"root\")\n * const root = createRoot(rootElement)\n *\n * root.render(<MyApp />)\n * ```\n *\n * @param config A configuration object. See {@link StarlightConfig} to view\n * all available options.\n * @category Other Methods\n */\n configure(config: StarlightConfig): void\n\n /**\n * Logs a message (or any kind of data, really) into the console if the debug\n * configuration is true. Uses `console.log` internally.\n *\n * This function's type definition is the same as the `console.log` function.\n *\n * @param message The data that will be logged.\n * @param optionalParams Additional data to be logged or string substitutions.\n * @see [MDN documentation on console.log](https://developer.mozilla.org/en-US/docs/web/api/console/log)\n * @internal\n */\n log(message?: unknown, ...optionalParams: unknown[]): void\n\n /**\n * Returns the base API URL for requests, including the configured workspace.\n * Doesn't include a trailing slash.\n *\n * @internal\n */\n getBaseUrl(): string\n\n /**\n * Returns a Promise that results in a response or throws a StarlightError.\n * The response will be the parsed JSON data sent by the API.\n *\n * This method is used internally by all Selectors and Instances to request\n * data to Starlight's Query API, but it can also be used standalone if\n * desired.\n *\n * This method automatically prefixes the given path with the API URL, but it\n * doesn't include a trailing slash, so be sure to include one at the start\n * of your path.\n *\n * @param path The path to GET. Will be prefixed with the API URL. Must start\n * with a forward slash (/).\n * @param params An optional object of values that will be converted to a\n * string and passed as GET params.\n * @param options An optional configuration object passed to the fetch method.\n * Check [MDN documentation on fetch](https://developer.mozilla.org/en-US/docs/Web/API/fetch)\n * to see the available options.\n * @typeParam T - The shape of the expected response on success. Client\n * methods generally pass {@link StarlightItemResponse} or\n * {@link StarlightListResponse} types here.\n * @throws {@link StarlightError} on any errors.\n * @category Other Methods\n */\n get<T = Record<string, unknown>>(\n path: string,\n params?: Record<string, string | number | boolean | undefined>,\n options?: RequestInit,\n ): Promise<T>\n\n /**\n * Returns a {@link DynamicModelSelector}, which is a {@link ModelSelector}\n * with support for creating {@apilink ModelInstance | ModelInstances} using the dynamic syntax.\n *\n * This is an accessor, which means that it should be used just like a common\n * object parameter. For instance:\n *\n * ```ts\n * import Starlight from '@starlightcms/js-sdk'\n *\n * const response = await Starlight.models.list()\n * ```\n *\n * See {@link DynamicModelSelector} for more info.\n *\n * @category Selector Accessors\n */\n get models(): DynamicModelSelector<D>\n\n /**\n * Returns a {@link DynamicModelInstance}, which is a\n * {@link ModelInstance} with support for creating\n * {@apilink ModelCategoryInstance | ModelCategoryInstances} using the dynamic syntax. For instance:\n *\n * ```ts\n * import Starlight from '@starlightcms/js-sdk'\n *\n * const response = await Starlight.model('posts').entries.list()\n * ```\n *\n * See {@link DynamicModelInstance} for more info.\n *\n * @category Instance Methods\n */\n model<S extends keyof D>(slug: S): DynamicModelInstance<D[S]>\n\n /**\n * Returns a {@link DynamicFormSelector}, which provides support for creating\n * {@apilink FormInstance | FormInstances} using the dynamic syntax.\n *\n * This is an accessor, which means that it should be used just like a common\n * object parameter. For instance:\n *\n * ```ts\n * import Starlight from '@starlightcms/js-sdk'\n *\n * const response = await Starlight.forms.signup.get()\n * ```\n *\n * See {@link DynamicFormSelector} for more info.\n *\n * @category Selector Accessors\n */\n get forms(): DynamicFormSelector\n\n /**\n * Returns a {@link FormInstance}, which provides methods to retrieve basic information\n * about a Starlight form and its schema. For instance:\n *\n * ```ts\n * import Starlight from '@starlightcms/js-sdk'\n *\n * const response = await Starlight.form('signup').schema()\n * ```\n *\n * See {@link FormInstance} for more info.\n *\n * @category Instance Methods\n */\n form(slug: string | number): FormInstance\n\n /**\n * Returns a {@link SingletonSelector}.\n *\n * This is an accessor, which means that it should be used just like a common\n * object parameter. For instance:\n *\n * ```ts\n * import Starlight from '@starlightcms/js-sdk'\n *\n * const response = await Starlight.singletons.list()\n * ```\n *\n * See {@link SingletonSelector} for more info.\n *\n * @category Selector Accessors\n */\n get singletons(): SingletonSelector\n\n /**\n * Returns a {@link DynamicCollectionSelector}, which is a\n * {@link CollectionSelector} with support for creating\n * {@apilink CollectionInstance | CollectionInstances} using the dynamic syntax.\n *\n * This is an accessor, which means that it should be used just like a common\n * object parameter. For instance:\n *\n * ```ts\n * import Starlight from '@starlightcms/js-sdk'\n *\n * const response = await Starlight.collections.list()\n * ```\n *\n * See {@link DynamicCollectionSelector} for more info.\n *\n * @category Selector Accessors\n */\n get collections(): DynamicCollectionSelector\n\n /**\n * Returns a {@link CollectionInstance}. For instance:\n *\n * ```ts\n * import Starlight from '@starlightcms/js-sdk'\n *\n * const response = await Starlight.collection('featured-posts').items()\n * ```\n *\n * See {@link CollectionInstance} for more info.\n *\n * @example Typing the returned CollectionInstance.\n * ```ts\n * import Starlight, { MediaObject } from '@starlightcms/js-sdk'\n *\n * const response = await Starlight.collection<MediaObject>('carousel-images').items()\n * ```\n *\n * @typeParam T - The type of entity this Collection holds. You can pass this\n * type parameter to correctly type the response of the\n * {@apilink CollectionInstance.items} method.\n * @category Instance Methods\n */\n collection<T extends CollectionEntityTypes>(\n slug: string | number,\n ): CollectionInstance<T>\n\n /**\n * Returns a {@link MediaSelector}.\n *\n * This is an accessor, which means that it should be used just like a common\n * object parameter. For instance:\n *\n * ```ts\n * import Starlight from '@starlightcms/js-sdk'\n *\n * const response = await Starlight.media.list()\n * ```\n *\n * See {@link MediaSelector} for more info.\n *\n * @category Selector Accessors\n */\n get media(): MediaSelector\n\n /**\n * Returns a {@link SearchSelector}.\n *\n * This is an accessor, which means that it should be used just like a common\n * object parameter. For instance:\n *\n * ```ts\n * import Starlight from '@starlightcms/js-sdk'\n *\n * const response = await Starlight.search.entries()\n * ```\n *\n * See {@link SearchSelector} for more info.\n *\n * @category Selector Accessors\n */\n get search(): SearchSelector\n}\n\n/**\n * This type adds support for the dynamic syntax to the StarlightClient\n * interface, which allows users to create\n * {@apilink DynamicModelInstance| DynamicModelInstances} dynamically.\n * See {@link StarlightClient} to learn which methods it provides. Also see\n * {@doclink requests-and-responses#dynamic-syntax | Dynamic Instances}\n * documentation to learn more about the dynamic syntax.\n *\n *\n * This allows TypeScript to correctly type all models defined by the user\n * in the DefaultModelDefinition type, aside from letting the user using any\n * \"unknown\" model slug, which is provided by the WorkspaceModelDefinition type.\n *\n * This type is only aware of the DefaultModelDefinition type because the\n * StarlightClient uses it by default when no model definition type is passed.\n *\n * @group Client\n */\nexport type DynamicStarlightClient<T extends WorkspaceModelDefinition> =\n StarlightClient<T> & {\n [K in keyof T]: DynamicModelInstance<T[K]>\n }\n\n/**\n * This interface represents an API response that returns a single entity, like\n * a single {@link Entry} or a single {@link MediaObject}, for instance.\n *\n * It contains only one field: `data`. This field type is generic and\n * depends on the kind of request that was made to the API.\n *\n * All SDK request methods that returna single entity\n * will return this interface.\n *\n * @group Client\n */\nexport interface StarlightItemResponse<T> {\n /**\n * The entity returned by the API request. Its type depends on which request\n * was made. SDK methods will generally type this parameter automatically.\n */\n data: T\n}\n\n/**\n * This interface represents an API response that returns a list of entities,\n * like a list of {@apilink Entry | Entries} or a list of items from a\n * {@link Collection}.\n *\n * It contains a `data` parameter, which is an array of items with a generic\n * type that depends on the kind of request that was made, and two metadata\n * objects: `links` and `meta`. Metadata is useful for pagination.\n *\n * All SDK request methods that return a list of entities will return this\n * interface.\n *\n * @group Client\n */\nexport interface StarlightListResponse<T> {\n /**\n * The list of entities returned by the API request. Its type depends on which\n * request was made. SDK methods will generally type\n * this parameter automatically.\n */\n data: T[]\n /**\n * An object containing useful links for easier pagination. All links points\n * to the same list requested, but with a varying `page` parameter.\n */\n links: {\n /**\n * A link for the first page of the list.\n */\n first: string\n /**\n * A link for the last page of the list.\n */\n last: string\n /**\n * A link to the previous page of the list, if there's any.\n */\n prev?: string\n /**\n * A link to the next page of the list, if there's any.\n */\n next?: string\n }\n /**\n * An object with useful metadata related to the current list. It can be used\n * in applications to create pagination logic and interfaces.\n *\n * `from` and `to` are indexes indicating which items start and finish the\n * current page of the list. For instance, in a list with 100 items with 15\n * items per page, on the first page, `from` and `to` will be `1` and `15`\n * respectively.\n */\n meta: {\n /**\n * The number of the current page.\n */\n current_page: number\n /**\n * The number of the last page for the current list.\n */\n last_page: number\n /**\n * The index of the first item on this page out of all list items.\n */\n from: number\n /**\n * The index of the last item on this page out of all list items.\n */\n to: number\n /**\n * The number of items per page.\n */\n per_page: number\n /**\n * The total number of items in the current list.\n */\n total: number\n }\n}\n\n/**\n * The DefaultModelDefinition type is used to correctly type Entry data when\n * requesting it using a StarlightClient.\n *\n * Without using a DefaultModelDefinition, Entry data will be typed as a\n * \"generic\" JS object which can hold any kind of data:\n *\n * ```ts\n * import Starlight from '@starlightcms/js-sdk'\n *\n * // response type will be StarlightItemResponse<Entry> on request success.\n * const response = await Starlight.posts.entries.get('hello-world')\n *\n * // helloWorld type is Entry<Record<string, unknown>>. This means that\n * // `data` can hold anything, which is not type-safe.\n * const helloWorld = response.data\n * ```\n *\n * One way of safely adding type information to Entry objects is by passing a\n * data definition type to the EntrySelector when requesting something:\n *\n * ```ts\n * import Starlight, { VisualField, MediaField } from '@starlightcms/js-sdk'\n *\n * type PostFields = {\n * featured_image: MediaField\n * content: VisualField\n * }\n *\n * // response type will now be StarlightItemResponse<Entry<PostsFields>>.\n * const response = await Starlight.posts.entries<PostFields>.get('hello-world')\n *\n * // Now, helloWorld type is Entry<PostsFields>.\n * const helloWorld = response.data\n *\n * // Which means we can safely access its data, and IDEs will\n * // auto-complete the data field name below:\n * console.log(helloWorld.data.featured_image)\n * ```\n *\n * Note that we used \"Fields\" to define our data shape. We recommend using these\n * types, which are exported by this SDK, because they map to the field types\n * available in the Starlight admin when creating models, and should simplify\n * the type definition process. All available Field types are documented in the\n * {@apilink BooleanField | Data Fields section of this API}.\n *\n * However, passing model definition types around your application is not ideal,\n * and actually unnecessary. Using the DefaultModelDefinition type, all model\n * definitions can be automatically inferred.\n *\n * To get started, you need to create a\n * [type declaration file](https://www.typescriptlang.org/docs/handbook/declaration-files/introduction.html)\n * in which you'll define all your types. You can name it anything and place it\n * anywhere inside your project, but we recommend naming it `starlight.d.ts` and\n * placing it in the root folder of your source code, so it can be easily\n * imported later in your application if you ever need to reference these types.\n *\n * In this file, you can place all your model type definitions (including type\n * definitions for Singleton data, if you want!). Finally, you just need to\n * add a \"module definition block\" that will tell the SDK which types you expect\n * to receive when requesting models.\n *\n * Here's a complete exemple defining two models, Posts and Magazines:\n *\n * ```ts\n * import { StringField, VisualField, MediaField } from '@starlightcms/js-sdk'\n *\n * type PostFields = {\n * featured_image: MediaField\n * content: VisualField\n * }\n *\n * type MagazineFields = {\n * cover_image: MediaField\n * content: VisualField\n * issue_number: StringField\n * issue_year: StringField\n * }\n *\n * declare module '@starlightcms/js-sdk' {\n * export interface DefaultModelDefinition {\n * // Notice that each key in this interface is a Model slug!\n * posts: PostFields\n * magazines: MagazineFields\n * }\n * }\n * ```\n *\n * After creating this file, types should be automatically inferred without the\n * need to pass these types around:\n *\n * ```ts\n * import Starlight from '@starlightcms/js-sdk'\n *\n * // response type will be StarlightItemResponse<Entry<PostsFields>>,\n * // which was implicitly inferred by the SDK!\n * const response = await Starlight.posts.entries.get('hello-world')\n *\n * // helloWorld type is Entry<PostsFields>\n * const helloWorld = response.data\n *\n * // Auto-complete will work just as before when we explicitly type the Entry!\n * console.log(helloWorld.data.featured_image)\n * ```\n *\n * @group Client\n */\n// eslint-disable-next-line @typescript-eslint/no-empty-object-type\nexport interface DefaultModelDefinition extends WorkspaceModelDefinition {}\n\n/**\n * This type is only used as a base for the DefaultModelDefinition type.\n *\n * @internal\n */\nexport interface WorkspaceModelDefinition {\n [slug: string]: SerializedData\n}\n\n/**\n * Request parameters used by most SDK `list()` methods.\n *\n * @group Request Parameters\n */\nexport interface BaseRequestParameters {\n [key: string]: string | number | boolean | undefined\n /**\n * The page requested.\n */\n page?: number\n /**\n * The limit of items per page.\n */\n limit?: number\n /**\n * A search query string.\n *\n * For instance, searching for \"out\" will match both \"check out!\" and\n * \"about us\". Search is not case-sensitive.\n */\n query?: string\n}\n\n/**\n * Request parameters used by most SDK methods that support advanced querying.\n *\n * @group Request Parameters\n */\nexport interface QueryableRequestParameters {\n /**\n * A search query string that matches a specific word within boundaries.\n * Search is not case-sensitive.\n *\n * For instance, searching for \"phone\" will match \"This is my phone!\"\n * but won't match \"This is my telephone!\".\n */\n 'query:word'?: string\n /**\n * A comma-separated list of fields to look up on when searching using\n * `query` or `query:word`. If undefined, all text fields will be searched on,\n * including Visual Editor fields. Search is not case-sensitive.\n *\n * For instance, to limit search on the \"content\" and \"summary\" fields of a\n * model, pass `'content,summary'`.\n */\n fields?: string\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"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":"AAWA,cAAc,UAAU,CAAA;AACxB,cAAc,YAAY,CAAA;AAC1B,cAAc,UAAU,CAAA;AACxB,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA","sourcesContent":["import { CollectionEntityTypes, SerializedData } from './entities'\nimport { DynamicModelSelector } from '../selectors/Model'\nimport { DynamicModelInstance } from '../instances/Model'\nimport { SingletonSelector } from '../selectors/Singleton'\nimport { DynamicCollectionSelector } from '../selectors/Collection'\nimport { MediaSelector } from '../selectors/Media'\nimport { SearchSelector } from '../selectors/Search'\nimport { CollectionInstance } from '../instances/Collection'\nimport { FormInstance } from '../instances/Form'\nimport { DynamicFormSelector } from '../selectors/Form/types'\n\nexport * from './fields'\nexport * from './entities'\nexport * from './visual'\nexport * from './instances'\nexport * from './selectors'\n\n/**\n * This is a utility type that allows any string to be used as a URL, but\n * provides a default one which can be used by IDEs to provide auto-completion.\n * The default URL points to version 2 of the Query API.\n */\nexport type BaseUrl = 'https://query.starlightcms.io/v2' | string\n\n/**\n * The available options to configure a {@link StarlightClient}.\n *\n * `workspace` is required when creating new clients or configuring the\n * {@apilink default | default client}.\n * @group Client\n */\nexport type StarlightConfig = {\n /**\n * The ID of the workspace that the client should use to request data.\n *\n * Note: the current APIs only support using workspace IDs as identifiers,\n * and **not** slugs. Slug support will be added in the future. You can find\n * the workspace ID in the left-side menu on the Starlight interface or below\n * the workspace name in the workspace list.\n */\n workspace?: string\n /**\n * The Starlight Query API URL, including the version, and without a trailing\n * slash. Defaults to the production Query API URL.\n *\n * You only need to set this if you're not using Starlight's production APIs.\n */\n baseUrl?: BaseUrl\n /**\n * When true, logs all API requests in the console. Defaults to false.\n */\n debug?: boolean\n}\n\n/**\n * The Starlight client is the main entry point for any requests you might want\n * to make to Starlight's APIs.\n *\n * There's two ways of interacting with a client: using the\n * {@apilink default | default client} exported by the SDK or creating a new\n * client instance using the\n * {@apilink makeStarlightClient | makeStarlightClient function}. Follow the\n * provided links to learn how to use each method.\n *\n * Either way you choose to interact, all clients expose the same methods and\n * accessors that provide ways to request data. These methods and accessors\n * return Selector or Instance objects, which are documented in the sections\n * of the same name found in this API's sidebar.\n *\n * @group Client\n */\nexport interface StarlightClient<\n D extends WorkspaceModelDefinition = DefaultModelDefinition,\n> {\n /**\n * Updates the client configuration. See {@link StarlightConfig} to see all\n * the available options.\n *\n * If you want to use the {@apilink default | default SDK client}, you need to\n * set its workspace using this method in your application. You should run\n * this method only once, and as soon as possible in your application\n * lifecycle. For instance, when using React:\n *\n * ```js\n * // src/index.js\n * import { createRoot } from \"react-dom/client\"\n * import Starlight from '@starlightcms/js-sdk'\n * import MyApp from './MyApp.js'\n *\n * // We only need to run this once. In this case, we're\n * // running it before initializing our React app.\n * Starlight.configure({\n * workspace: '1234567890'\n * })\n *\n * const rootElement = document.getElementById(\"root\")\n * const root = createRoot(rootElement)\n *\n * root.render(<MyApp />)\n * ```\n *\n * @param config A configuration object. See {@link StarlightConfig} to view\n * all available options.\n * @category Other Methods\n */\n configure(config: StarlightConfig): void\n\n /**\n * Logs a message (or any kind of data, really) into the console if the debug\n * configuration is true. Uses `console.log` internally.\n *\n * This function's type definition is the same as the `console.log` function.\n *\n * @param message The data that will be logged.\n * @param optionalParams Additional data to be logged or string substitutions.\n * @see [MDN documentation on console.log](https://developer.mozilla.org/en-US/docs/web/api/console/log)\n * @internal\n */\n log(message?: unknown, ...optionalParams: unknown[]): void\n\n /**\n * Returns the base API URL for requests, including the configured workspace.\n * Doesn't include a trailing slash.\n *\n * @internal\n */\n getBaseUrl(): string\n\n /**\n * Returns a Promise that results in a response or throws a StarlightError.\n * The response will be the parsed JSON data sent by the API.\n *\n * This method is used internally by all Selectors and Instances to request\n * data to Starlight's Query API, but it can also be used standalone if\n * desired.\n *\n * This method automatically prefixes the given path with the API URL, but it\n * doesn't include a trailing slash, so be sure to include one at the start\n * of your path.\n *\n * @param path The path to GET. Will be prefixed with the API URL. Must start\n * with a forward slash (/).\n * @param params An optional object of values that will be converted to a\n * string and passed as GET params.\n * @param options An optional configuration object passed to the fetch method.\n * Check [MDN documentation on fetch](https://developer.mozilla.org/en-US/docs/Web/API/fetch)\n * to see the available options.\n * @typeParam T - The shape of the expected response on success. Client\n * methods generally pass {@link StarlightItemResponse} or\n * {@link StarlightListResponse} types here.\n * @throws {@link StarlightError} on any errors.\n * @category Other Methods\n */\n get<T = Record<string, unknown>>(\n path: string,\n params?: BaseRequestParameters,\n options?: RequestInit,\n ): Promise<T>\n\n /**\n * Returns a {@link DynamicModelSelector}, which is a {@link ModelSelector}\n * with support for creating {@apilink ModelInstance | ModelInstances} using the dynamic syntax.\n *\n * This is an accessor, which means that it should be used just like a common\n * object parameter. For instance:\n *\n * ```ts\n * import Starlight from '@starlightcms/js-sdk'\n *\n * const response = await Starlight.models.list()\n * ```\n *\n * See {@link DynamicModelSelector} for more info.\n *\n * @category Selector Accessors\n */\n get models(): DynamicModelSelector<D>\n\n /**\n * Returns a {@link DynamicModelInstance}, which is a\n * {@link ModelInstance} with support for creating\n * {@apilink ModelCategoryInstance | ModelCategoryInstances} using the dynamic syntax. For instance:\n *\n * ```ts\n * import Starlight from '@starlightcms/js-sdk'\n *\n * const response = await Starlight.model('posts').entries.list()\n * ```\n *\n * See {@link DynamicModelInstance} for more info.\n *\n * @category Instance Methods\n */\n model<S extends keyof D>(slug: S): DynamicModelInstance<D[S]>\n\n /**\n * Returns a {@link DynamicFormSelector}, which provides support for creating\n * {@apilink FormInstance | FormInstances} using the dynamic syntax.\n *\n * This is an accessor, which means that it should be used just like a common\n * object parameter. For instance:\n *\n * ```ts\n * import Starlight from '@starlightcms/js-sdk'\n *\n * const response = await Starlight.forms.signup.get()\n * ```\n *\n * See {@link DynamicFormSelector} for more info.\n *\n * @category Selector Accessors\n */\n get forms(): DynamicFormSelector\n\n /**\n * Returns a {@link FormInstance}, which provides methods to retrieve basic information\n * about a Starlight form and its schema. For instance:\n *\n * ```ts\n * import Starlight from '@starlightcms/js-sdk'\n *\n * const response = await Starlight.form('signup').schema()\n * ```\n *\n * See {@link FormInstance} for more info.\n *\n * @category Instance Methods\n */\n form(slug: string | number): FormInstance\n\n /**\n * Returns a {@link SingletonSelector}.\n *\n * This is an accessor, which means that it should be used just like a common\n * object parameter. For instance:\n *\n * ```ts\n * import Starlight from '@starlightcms/js-sdk'\n *\n * const response = await Starlight.singletons.list()\n * ```\n *\n * See {@link SingletonSelector} for more info.\n *\n * @category Selector Accessors\n */\n get singletons(): SingletonSelector\n\n /**\n * Returns a {@link DynamicCollectionSelector}, which is a\n * {@link CollectionSelector} with support for creating\n * {@apilink CollectionInstance | CollectionInstances} using the dynamic syntax.\n *\n * This is an accessor, which means that it should be used just like a common\n * object parameter. For instance:\n *\n * ```ts\n * import Starlight from '@starlightcms/js-sdk'\n *\n * const response = await Starlight.collections.list()\n * ```\n *\n * See {@link DynamicCollectionSelector} for more info.\n *\n * @category Selector Accessors\n */\n get collections(): DynamicCollectionSelector\n\n /**\n * Returns a {@link CollectionInstance}. For instance:\n *\n * ```ts\n * import Starlight from '@starlightcms/js-sdk'\n *\n * const response = await Starlight.collection('featured-posts').items()\n * ```\n *\n * See {@link CollectionInstance} for more info.\n *\n * @example Typing the returned CollectionInstance.\n * ```ts\n * import Starlight, { MediaObject } from '@starlightcms/js-sdk'\n *\n * const response = await Starlight.collection<MediaObject>('carousel-images').items()\n * ```\n *\n * @typeParam T - The type of entity this Collection holds. You can pass this\n * type parameter to correctly type the response of the\n * {@apilink CollectionInstance.items} method.\n * @category Instance Methods\n */\n collection<T extends CollectionEntityTypes>(\n slug: string | number,\n ): CollectionInstance<T>\n\n /**\n * Returns a {@link MediaSelector}.\n *\n * This is an accessor, which means that it should be used just like a common\n * object parameter. For instance:\n *\n * ```ts\n * import Starlight from '@starlightcms/js-sdk'\n *\n * const response = await Starlight.media.list()\n * ```\n *\n * See {@link MediaSelector} for more info.\n *\n * @category Selector Accessors\n */\n get media(): MediaSelector\n\n /**\n * Returns a {@link SearchSelector}.\n *\n * This is an accessor, which means that it should be used just like a common\n * object parameter. For instance:\n *\n * ```ts\n * import Starlight from '@starlightcms/js-sdk'\n *\n * const response = await Starlight.search.entries()\n * ```\n *\n * See {@link SearchSelector} for more info.\n *\n * @category Selector Accessors\n */\n get search(): SearchSelector\n}\n\n/**\n * This type adds support for the dynamic syntax to the StarlightClient\n * interface, which allows users to create\n * {@apilink DynamicModelInstance| DynamicModelInstances} dynamically.\n * See {@link StarlightClient} to learn which methods it provides. Also see\n * {@doclink requests-and-responses#dynamic-syntax | Dynamic Instances}\n * documentation to learn more about the dynamic syntax.\n *\n *\n * This allows TypeScript to correctly type all models defined by the user\n * in the DefaultModelDefinition type, aside from letting the user using any\n * \"unknown\" model slug, which is provided by the WorkspaceModelDefinition type.\n *\n * This type is only aware of the DefaultModelDefinition type because the\n * StarlightClient uses it by default when no model definition type is passed.\n *\n * @group Client\n */\nexport type DynamicStarlightClient<T extends WorkspaceModelDefinition> =\n StarlightClient<T> & {\n [K in keyof T]: DynamicModelInstance<T[K]>\n }\n\n/**\n * This interface represents an API response that returns a single entity, like\n * a single {@link Entry} or a single {@link MediaObject}, for instance.\n *\n * It contains only one field: `data`. This field type is generic and\n * depends on the kind of request that was made to the API.\n *\n * All SDK request methods that returna single entity\n * will return this interface.\n *\n * @group Client\n */\nexport interface StarlightItemResponse<T> {\n /**\n * The entity returned by the API request. Its type depends on which request\n * was made. SDK methods will generally type this parameter automatically.\n */\n data: T\n}\n\n/**\n * This interface represents an API response that returns a list of entities,\n * like a list of {@apilink Entry | Entries} or a list of items from a\n * {@link Collection}.\n *\n * It contains a `data` parameter, which is an array of items with a generic\n * type that depends on the kind of request that was made, and two metadata\n * objects: `links` and `meta`. Metadata is useful for pagination.\n *\n * All SDK request methods that return a list of entities will return this\n * interface.\n *\n * @group Client\n */\nexport interface StarlightListResponse<T> {\n /**\n * The list of entities returned by the API request. Its type depends on which\n * request was made. SDK methods will generally type\n * this parameter automatically.\n */\n data: T[]\n /**\n * An object containing useful links for easier pagination. All links points\n * to the same list requested, but with a varying `page` parameter.\n */\n links: {\n /**\n * A link for the first page of the list.\n */\n first: string\n /**\n * A link for the last page of the list.\n */\n last: string\n /**\n * A link to the previous page of the list, if there's any.\n */\n prev?: string\n /**\n * A link to the next page of the list, if there's any.\n */\n next?: string\n }\n /**\n * An object with useful metadata related to the current list. It can be used\n * in applications to create pagination logic and interfaces.\n *\n * `from` and `to` are indexes indicating which items start and finish the\n * current page of the list. For instance, in a list with 100 items with 15\n * items per page, on the first page, `from` and `to` will be `1` and `15`\n * respectively.\n */\n meta: {\n /**\n * The number of the current page.\n */\n current_page: number\n /**\n * The number of the last page for the current list.\n */\n last_page: number\n /**\n * The index of the first item on this page out of all list items.\n */\n from: number\n /**\n * The index of the last item on this page out of all list items.\n */\n to: number\n /**\n * The number of items per page.\n */\n per_page: number\n /**\n * The total number of items in the current list.\n */\n total: number\n }\n}\n\n/**\n * The DefaultModelDefinition type is used to correctly type Entry data when\n * requesting it using a StarlightClient.\n *\n * Without using a DefaultModelDefinition, Entry data will be typed as a\n * \"generic\" JS object which can hold any kind of data:\n *\n * ```ts\n * import Starlight from '@starlightcms/js-sdk'\n *\n * // response type will be StarlightItemResponse<Entry> on request success.\n * const response = await Starlight.posts.entries.get('hello-world')\n *\n * // helloWorld type is Entry<Record<string, unknown>>. This means that\n * // `data` can hold anything, which is not type-safe.\n * const helloWorld = response.data\n * ```\n *\n * One way of safely adding type information to Entry objects is by passing a\n * data definition type to the EntrySelector when requesting something:\n *\n * ```ts\n * import Starlight, { VisualField, MediaField } from '@starlightcms/js-sdk'\n *\n * type PostFields = {\n * featured_image: MediaField\n * content: VisualField\n * }\n *\n * // response type will now be StarlightItemResponse<Entry<PostsFields>>.\n * const response = await Starlight.posts.entries<PostFields>.get('hello-world')\n *\n * // Now, helloWorld type is Entry<PostsFields>.\n * const helloWorld = response.data\n *\n * // Which means we can safely access its data, and IDEs will\n * // auto-complete the data field name below:\n * console.log(helloWorld.data.featured_image)\n * ```\n *\n * Note that we used \"Fields\" to define our data shape. We recommend using these\n * types, which are exported by this SDK, because they map to the field types\n * available in the Starlight admin when creating models, and should simplify\n * the type definition process. All available Field types are documented in the\n * {@apilink BooleanField | Data Fields section of this API}.\n *\n * However, passing model definition types around your application is not ideal,\n * and actually unnecessary. Using the DefaultModelDefinition type, all model\n * definitions can be automatically inferred.\n *\n * To get started, you need to create a\n * [type declaration file](https://www.typescriptlang.org/docs/handbook/declaration-files/introduction.html)\n * in which you'll define all your types. You can name it anything and place it\n * anywhere inside your project, but we recommend naming it `starlight.d.ts` and\n * placing it in the root folder of your source code, so it can be easily\n * imported later in your application if you ever need to reference these types.\n *\n * In this file, you can place all your model type definitions (including type\n * definitions for Singleton data, if you want!). Finally, you just need to\n * add a \"module definition block\" that will tell the SDK which types you expect\n * to receive when requesting models.\n *\n * Here's a complete exemple defining two models, Posts and Magazines:\n *\n * ```ts\n * import { StringField, VisualField, MediaField } from '@starlightcms/js-sdk'\n *\n * type PostFields = {\n * featured_image: MediaField\n * content: VisualField\n * }\n *\n * type MagazineFields = {\n * cover_image: MediaField\n * content: VisualField\n * issue_number: StringField\n * issue_year: StringField\n * }\n *\n * declare module '@starlightcms/js-sdk' {\n * export interface DefaultModelDefinition {\n * // Notice that each key in this interface is a Model slug!\n * posts: PostFields\n * magazines: MagazineFields\n * }\n * }\n * ```\n *\n * After creating this file, types should be automatically inferred without the\n * need to pass these types around:\n *\n * ```ts\n * import Starlight from '@starlightcms/js-sdk'\n *\n * // response type will be StarlightItemResponse<Entry<PostsFields>>,\n * // which was implicitly inferred by the SDK!\n * const response = await Starlight.posts.entries.get('hello-world')\n *\n * // helloWorld type is Entry<PostsFields>\n * const helloWorld = response.data\n *\n * // Auto-complete will work just as before when we explicitly type the Entry!\n * console.log(helloWorld.data.featured_image)\n * ```\n *\n * @group Client\n */\n// eslint-disable-next-line @typescript-eslint/no-empty-object-type\nexport interface DefaultModelDefinition extends WorkspaceModelDefinition {}\n\n/**\n * This type is only used as a base for the DefaultModelDefinition type.\n *\n * @internal\n */\nexport interface WorkspaceModelDefinition {\n [slug: string]: SerializedData\n}\n\n/**\n * An object that accepts any string, number and boolean values.\n * Used as the base for most request parameter interfaces in the SDK.\n *\n * @group Request Parameters\n */\nexport interface BaseRequestParameters {\n [key: string]: string | number | boolean | undefined\n}\n\n/**\n * Request parameters used by most SDK `list()` methods.\n *\n * @group Request Parameters\n */\nexport interface ListRequestParameters extends BaseRequestParameters {\n /**\n * The page requested.\n */\n page?: number\n /**\n * The limit of items per page.\n */\n limit?: number\n /**\n * A search query string.\n *\n * For instance, searching for \"out\" will match both \"check out!\" and\n * \"about us\". Search is not case-sensitive.\n */\n query?: string\n}\n\n/**\n * Request parameters used by most SDK methods that support advanced querying.\n *\n * @group Request Parameters\n */\nexport interface QueryableRequestParameters {\n /**\n * A search query string that matches a specific word within boundaries.\n * Search is not case-sensitive.\n *\n * For instance, searching for \"phone\" will match \"This is my phone!\"\n * but won't match \"This is my telephone!\".\n */\n 'query:word'?: string\n /**\n * A comma-separated list of fields to look up on when searching using\n * `query` or `query:word`. If undefined, all text fields will be searched on,\n * including Visual Editor fields. Search is not case-sensitive.\n *\n * For instance, to limit search on the \"content\" and \"summary\" fields of a\n * model, pass `'content,summary'`.\n */\n fields?: string\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"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@starlightcms/js-sdk",
3
- "version": "3.0.0",
3
+ "version": "3.1.0",
4
4
  "description": "The Starlight SDK for JavaScript",
5
5
  "main": "dist/cjs/index.js",
6
6
  "exports": {