@starlightcms/js-sdk 4.0.0-beta.2 → 4.0.0-beta.3

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 (304) hide show
  1. package/dist/index.cjs +397 -0
  2. package/dist/index.d.cts +5087 -0
  3. package/dist/index.d.cts.map +1 -0
  4. package/dist/index.d.mts +5087 -0
  5. package/dist/index.d.mts.map +1 -0
  6. package/dist/index.mjs +391 -0
  7. package/dist/index.mjs.map +1 -0
  8. package/package.json +18 -13
  9. package/dist/cjs/client.d.ts +0 -42
  10. package/dist/cjs/client.d.ts.map +0 -1
  11. package/dist/cjs/client.js +0 -145
  12. package/dist/cjs/client.js.map +0 -1
  13. package/dist/cjs/errors.d.ts +0 -40
  14. package/dist/cjs/errors.d.ts.map +0 -1
  15. package/dist/cjs/errors.js +0 -18
  16. package/dist/cjs/errors.js.map +0 -1
  17. package/dist/cjs/index.d.ts +0 -29
  18. package/dist/cjs/index.d.ts.map +0 -1
  19. package/dist/cjs/index.js +0 -47
  20. package/dist/cjs/index.js.map +0 -1
  21. package/dist/cjs/instances/Collection/index.d.ts +0 -5
  22. package/dist/cjs/instances/Collection/index.d.ts.map +0 -1
  23. package/dist/cjs/instances/Collection/index.js +0 -14
  24. package/dist/cjs/instances/Collection/index.js.map +0 -1
  25. package/dist/cjs/instances/Collection/types.d.ts +0 -79
  26. package/dist/cjs/instances/Collection/types.d.ts.map +0 -1
  27. package/dist/cjs/instances/Collection/types.js +0 -3
  28. package/dist/cjs/instances/Collection/types.js.map +0 -1
  29. package/dist/cjs/instances/Form/index.d.ts +0 -5
  30. package/dist/cjs/instances/Form/index.d.ts.map +0 -1
  31. package/dist/cjs/instances/Form/index.js +0 -14
  32. package/dist/cjs/instances/Form/index.js.map +0 -1
  33. package/dist/cjs/instances/Form/types.d.ts +0 -46
  34. package/dist/cjs/instances/Form/types.d.ts.map +0 -1
  35. package/dist/cjs/instances/Form/types.js +0 -3
  36. package/dist/cjs/instances/Form/types.js.map +0 -1
  37. package/dist/cjs/instances/Model/index.d.ts +0 -5
  38. package/dist/cjs/instances/Model/index.d.ts.map +0 -1
  39. package/dist/cjs/instances/Model/index.js +0 -34
  40. package/dist/cjs/instances/Model/index.js.map +0 -1
  41. package/dist/cjs/instances/Model/types.d.ts +0 -102
  42. package/dist/cjs/instances/Model/types.d.ts.map +0 -1
  43. package/dist/cjs/instances/Model/types.js +0 -3
  44. package/dist/cjs/instances/Model/types.js.map +0 -1
  45. package/dist/cjs/instances/ModelCategory/index.d.ts +0 -5
  46. package/dist/cjs/instances/ModelCategory/index.d.ts.map +0 -1
  47. package/dist/cjs/instances/ModelCategory/index.js +0 -14
  48. package/dist/cjs/instances/ModelCategory/index.js.map +0 -1
  49. package/dist/cjs/instances/ModelCategory/types.d.ts +0 -76
  50. package/dist/cjs/instances/ModelCategory/types.d.ts.map +0 -1
  51. package/dist/cjs/instances/ModelCategory/types.js +0 -3
  52. package/dist/cjs/instances/ModelCategory/types.js.map +0 -1
  53. package/dist/cjs/selectors/Collection/index.d.ts +0 -5
  54. package/dist/cjs/selectors/Collection/index.d.ts.map +0 -1
  55. package/dist/cjs/selectors/Collection/index.js +0 -26
  56. package/dist/cjs/selectors/Collection/index.js.map +0 -1
  57. package/dist/cjs/selectors/Collection/types.d.ts +0 -98
  58. package/dist/cjs/selectors/Collection/types.d.ts.map +0 -1
  59. package/dist/cjs/selectors/Collection/types.js +0 -3
  60. package/dist/cjs/selectors/Collection/types.js.map +0 -1
  61. package/dist/cjs/selectors/Entry/index.d.ts +0 -5
  62. package/dist/cjs/selectors/Entry/index.d.ts.map +0 -1
  63. package/dist/cjs/selectors/Entry/index.js +0 -14
  64. package/dist/cjs/selectors/Entry/index.js.map +0 -1
  65. package/dist/cjs/selectors/Entry/types.d.ts +0 -138
  66. package/dist/cjs/selectors/Entry/types.d.ts.map +0 -1
  67. package/dist/cjs/selectors/Entry/types.js +0 -3
  68. package/dist/cjs/selectors/Entry/types.js.map +0 -1
  69. package/dist/cjs/selectors/Form/index.d.ts +0 -4
  70. package/dist/cjs/selectors/Form/index.d.ts.map +0 -1
  71. package/dist/cjs/selectors/Form/index.js +0 -18
  72. package/dist/cjs/selectors/Form/index.js.map +0 -1
  73. package/dist/cjs/selectors/Form/types.d.ts +0 -22
  74. package/dist/cjs/selectors/Form/types.d.ts.map +0 -1
  75. package/dist/cjs/selectors/Form/types.js +0 -3
  76. package/dist/cjs/selectors/Form/types.js.map +0 -1
  77. package/dist/cjs/selectors/Media/index.d.ts +0 -5
  78. package/dist/cjs/selectors/Media/index.d.ts.map +0 -1
  79. package/dist/cjs/selectors/Media/index.js +0 -14
  80. package/dist/cjs/selectors/Media/index.js.map +0 -1
  81. package/dist/cjs/selectors/Media/types.d.ts +0 -49
  82. package/dist/cjs/selectors/Media/types.d.ts.map +0 -1
  83. package/dist/cjs/selectors/Media/types.js +0 -3
  84. package/dist/cjs/selectors/Media/types.js.map +0 -1
  85. package/dist/cjs/selectors/Model/index.d.ts +0 -5
  86. package/dist/cjs/selectors/Model/index.d.ts.map +0 -1
  87. package/dist/cjs/selectors/Model/index.js +0 -26
  88. package/dist/cjs/selectors/Model/index.js.map +0 -1
  89. package/dist/cjs/selectors/Model/types.d.ts +0 -78
  90. package/dist/cjs/selectors/Model/types.d.ts.map +0 -1
  91. package/dist/cjs/selectors/Model/types.js +0 -3
  92. package/dist/cjs/selectors/Model/types.js.map +0 -1
  93. package/dist/cjs/selectors/ModelCategory/index.d.ts +0 -5
  94. package/dist/cjs/selectors/ModelCategory/index.d.ts.map +0 -1
  95. package/dist/cjs/selectors/ModelCategory/index.js +0 -26
  96. package/dist/cjs/selectors/ModelCategory/index.js.map +0 -1
  97. package/dist/cjs/selectors/ModelCategory/types.d.ts +0 -87
  98. package/dist/cjs/selectors/ModelCategory/types.d.ts.map +0 -1
  99. package/dist/cjs/selectors/ModelCategory/types.js +0 -3
  100. package/dist/cjs/selectors/ModelCategory/types.js.map +0 -1
  101. package/dist/cjs/selectors/Search/index.d.ts +0 -5
  102. package/dist/cjs/selectors/Search/index.d.ts.map +0 -1
  103. package/dist/cjs/selectors/Search/index.js +0 -11
  104. package/dist/cjs/selectors/Search/index.js.map +0 -1
  105. package/dist/cjs/selectors/Search/types.d.ts +0 -90
  106. package/dist/cjs/selectors/Search/types.d.ts.map +0 -1
  107. package/dist/cjs/selectors/Search/types.js +0 -3
  108. package/dist/cjs/selectors/Search/types.js.map +0 -1
  109. package/dist/cjs/selectors/Singleton/index.d.ts +0 -5
  110. package/dist/cjs/selectors/Singleton/index.d.ts.map +0 -1
  111. package/dist/cjs/selectors/Singleton/index.js +0 -14
  112. package/dist/cjs/selectors/Singleton/index.js.map +0 -1
  113. package/dist/cjs/selectors/Singleton/types.d.ts +0 -64
  114. package/dist/cjs/selectors/Singleton/types.d.ts.map +0 -1
  115. package/dist/cjs/selectors/Singleton/types.js +0 -3
  116. package/dist/cjs/selectors/Singleton/types.js.map +0 -1
  117. package/dist/cjs/types/entities.d.ts +0 -362
  118. package/dist/cjs/types/entities.d.ts.map +0 -1
  119. package/dist/cjs/types/entities.js +0 -3
  120. package/dist/cjs/types/entities.js.map +0 -1
  121. package/dist/cjs/types/fields.d.ts +0 -123
  122. package/dist/cjs/types/fields.d.ts.map +0 -1
  123. package/dist/cjs/types/fields.js +0 -3
  124. package/dist/cjs/types/fields.js.map +0 -1
  125. package/dist/cjs/types/groups.d.ts +0 -30
  126. package/dist/cjs/types/groups.d.ts.map +0 -1
  127. package/dist/cjs/types/groups.js +0 -3
  128. package/dist/cjs/types/groups.js.map +0 -1
  129. package/dist/cjs/types/index.d.ts +0 -629
  130. package/dist/cjs/types/index.d.ts.map +0 -1
  131. package/dist/cjs/types/index.js +0 -24
  132. package/dist/cjs/types/index.js.map +0 -1
  133. package/dist/cjs/types/instances.d.ts +0 -4
  134. package/dist/cjs/types/instances.d.ts.map +0 -1
  135. package/dist/cjs/types/instances.js +0 -3
  136. package/dist/cjs/types/instances.js.map +0 -1
  137. package/dist/cjs/types/selectors.d.ts +0 -8
  138. package/dist/cjs/types/selectors.d.ts.map +0 -1
  139. package/dist/cjs/types/selectors.js +0 -3
  140. package/dist/cjs/types/selectors.js.map +0 -1
  141. package/dist/cjs/types/utilities.d.ts +0 -83
  142. package/dist/cjs/types/utilities.d.ts.map +0 -1
  143. package/dist/cjs/types/utilities.js +0 -3
  144. package/dist/cjs/types/utilities.js.map +0 -1
  145. package/dist/cjs/types/visual.d.ts +0 -185
  146. package/dist/cjs/types/visual.d.ts.map +0 -1
  147. package/dist/cjs/types/visual.js +0 -3
  148. package/dist/cjs/types/visual.js.map +0 -1
  149. package/dist/cjs/utils/image.d.ts +0 -72
  150. package/dist/cjs/utils/image.d.ts.map +0 -1
  151. package/dist/cjs/utils/image.js +0 -101
  152. package/dist/cjs/utils/image.js.map +0 -1
  153. package/dist/cjs/utils/index.d.ts +0 -2
  154. package/dist/cjs/utils/index.d.ts.map +0 -1
  155. package/dist/cjs/utils/index.js +0 -18
  156. package/dist/cjs/utils/index.js.map +0 -1
  157. package/dist/esm/client.d.ts +0 -42
  158. package/dist/esm/client.d.ts.map +0 -1
  159. package/dist/esm/client.js +0 -139
  160. package/dist/esm/client.js.map +0 -1
  161. package/dist/esm/errors.d.ts +0 -40
  162. package/dist/esm/errors.d.ts.map +0 -1
  163. package/dist/esm/errors.js +0 -14
  164. package/dist/esm/errors.js.map +0 -1
  165. package/dist/esm/index.d.ts +0 -29
  166. package/dist/esm/index.d.ts.map +0 -1
  167. package/dist/esm/index.js +0 -29
  168. package/dist/esm/index.js.map +0 -1
  169. package/dist/esm/instances/Collection/index.d.ts +0 -5
  170. package/dist/esm/instances/Collection/index.d.ts.map +0 -1
  171. package/dist/esm/instances/Collection/index.js +0 -11
  172. package/dist/esm/instances/Collection/index.js.map +0 -1
  173. package/dist/esm/instances/Collection/types.d.ts +0 -79
  174. package/dist/esm/instances/Collection/types.d.ts.map +0 -1
  175. package/dist/esm/instances/Collection/types.js +0 -2
  176. package/dist/esm/instances/Collection/types.js.map +0 -1
  177. package/dist/esm/instances/Form/index.d.ts +0 -5
  178. package/dist/esm/instances/Form/index.d.ts.map +0 -1
  179. package/dist/esm/instances/Form/index.js +0 -11
  180. package/dist/esm/instances/Form/index.js.map +0 -1
  181. package/dist/esm/instances/Form/types.d.ts +0 -46
  182. package/dist/esm/instances/Form/types.d.ts.map +0 -1
  183. package/dist/esm/instances/Form/types.js +0 -2
  184. package/dist/esm/instances/Form/types.js.map +0 -1
  185. package/dist/esm/instances/Model/index.d.ts +0 -5
  186. package/dist/esm/instances/Model/index.d.ts.map +0 -1
  187. package/dist/esm/instances/Model/index.js +0 -28
  188. package/dist/esm/instances/Model/index.js.map +0 -1
  189. package/dist/esm/instances/Model/types.d.ts +0 -102
  190. package/dist/esm/instances/Model/types.d.ts.map +0 -1
  191. package/dist/esm/instances/Model/types.js +0 -2
  192. package/dist/esm/instances/Model/types.js.map +0 -1
  193. package/dist/esm/instances/ModelCategory/index.d.ts +0 -5
  194. package/dist/esm/instances/ModelCategory/index.d.ts.map +0 -1
  195. package/dist/esm/instances/ModelCategory/index.js +0 -11
  196. package/dist/esm/instances/ModelCategory/index.js.map +0 -1
  197. package/dist/esm/instances/ModelCategory/types.d.ts +0 -76
  198. package/dist/esm/instances/ModelCategory/types.d.ts.map +0 -1
  199. package/dist/esm/instances/ModelCategory/types.js +0 -2
  200. package/dist/esm/instances/ModelCategory/types.js.map +0 -1
  201. package/dist/esm/selectors/Collection/index.d.ts +0 -5
  202. package/dist/esm/selectors/Collection/index.d.ts.map +0 -1
  203. package/dist/esm/selectors/Collection/index.js +0 -20
  204. package/dist/esm/selectors/Collection/index.js.map +0 -1
  205. package/dist/esm/selectors/Collection/types.d.ts +0 -98
  206. package/dist/esm/selectors/Collection/types.d.ts.map +0 -1
  207. package/dist/esm/selectors/Collection/types.js +0 -2
  208. package/dist/esm/selectors/Collection/types.js.map +0 -1
  209. package/dist/esm/selectors/Entry/index.d.ts +0 -5
  210. package/dist/esm/selectors/Entry/index.d.ts.map +0 -1
  211. package/dist/esm/selectors/Entry/index.js +0 -11
  212. package/dist/esm/selectors/Entry/index.js.map +0 -1
  213. package/dist/esm/selectors/Entry/types.d.ts +0 -138
  214. package/dist/esm/selectors/Entry/types.d.ts.map +0 -1
  215. package/dist/esm/selectors/Entry/types.js +0 -2
  216. package/dist/esm/selectors/Entry/types.js.map +0 -1
  217. package/dist/esm/selectors/Form/index.d.ts +0 -4
  218. package/dist/esm/selectors/Form/index.d.ts.map +0 -1
  219. package/dist/esm/selectors/Form/index.js +0 -12
  220. package/dist/esm/selectors/Form/index.js.map +0 -1
  221. package/dist/esm/selectors/Form/types.d.ts +0 -22
  222. package/dist/esm/selectors/Form/types.d.ts.map +0 -1
  223. package/dist/esm/selectors/Form/types.js +0 -2
  224. package/dist/esm/selectors/Form/types.js.map +0 -1
  225. package/dist/esm/selectors/Media/index.d.ts +0 -5
  226. package/dist/esm/selectors/Media/index.d.ts.map +0 -1
  227. package/dist/esm/selectors/Media/index.js +0 -11
  228. package/dist/esm/selectors/Media/index.js.map +0 -1
  229. package/dist/esm/selectors/Media/types.d.ts +0 -49
  230. package/dist/esm/selectors/Media/types.d.ts.map +0 -1
  231. package/dist/esm/selectors/Media/types.js +0 -2
  232. package/dist/esm/selectors/Media/types.js.map +0 -1
  233. package/dist/esm/selectors/Model/index.d.ts +0 -5
  234. package/dist/esm/selectors/Model/index.d.ts.map +0 -1
  235. package/dist/esm/selectors/Model/index.js +0 -20
  236. package/dist/esm/selectors/Model/index.js.map +0 -1
  237. package/dist/esm/selectors/Model/types.d.ts +0 -78
  238. package/dist/esm/selectors/Model/types.d.ts.map +0 -1
  239. package/dist/esm/selectors/Model/types.js +0 -2
  240. package/dist/esm/selectors/Model/types.js.map +0 -1
  241. package/dist/esm/selectors/ModelCategory/index.d.ts +0 -5
  242. package/dist/esm/selectors/ModelCategory/index.d.ts.map +0 -1
  243. package/dist/esm/selectors/ModelCategory/index.js +0 -20
  244. package/dist/esm/selectors/ModelCategory/index.js.map +0 -1
  245. package/dist/esm/selectors/ModelCategory/types.d.ts +0 -87
  246. package/dist/esm/selectors/ModelCategory/types.d.ts.map +0 -1
  247. package/dist/esm/selectors/ModelCategory/types.js +0 -2
  248. package/dist/esm/selectors/ModelCategory/types.js.map +0 -1
  249. package/dist/esm/selectors/Search/index.d.ts +0 -5
  250. package/dist/esm/selectors/Search/index.d.ts.map +0 -1
  251. package/dist/esm/selectors/Search/index.js +0 -8
  252. package/dist/esm/selectors/Search/index.js.map +0 -1
  253. package/dist/esm/selectors/Search/types.d.ts +0 -90
  254. package/dist/esm/selectors/Search/types.d.ts.map +0 -1
  255. package/dist/esm/selectors/Search/types.js +0 -2
  256. package/dist/esm/selectors/Search/types.js.map +0 -1
  257. package/dist/esm/selectors/Singleton/index.d.ts +0 -5
  258. package/dist/esm/selectors/Singleton/index.d.ts.map +0 -1
  259. package/dist/esm/selectors/Singleton/index.js +0 -11
  260. package/dist/esm/selectors/Singleton/index.js.map +0 -1
  261. package/dist/esm/selectors/Singleton/types.d.ts +0 -64
  262. package/dist/esm/selectors/Singleton/types.d.ts.map +0 -1
  263. package/dist/esm/selectors/Singleton/types.js +0 -2
  264. package/dist/esm/selectors/Singleton/types.js.map +0 -1
  265. package/dist/esm/types/entities.d.ts +0 -362
  266. package/dist/esm/types/entities.d.ts.map +0 -1
  267. package/dist/esm/types/entities.js +0 -2
  268. package/dist/esm/types/entities.js.map +0 -1
  269. package/dist/esm/types/fields.d.ts +0 -123
  270. package/dist/esm/types/fields.d.ts.map +0 -1
  271. package/dist/esm/types/fields.js +0 -2
  272. package/dist/esm/types/fields.js.map +0 -1
  273. package/dist/esm/types/groups.d.ts +0 -30
  274. package/dist/esm/types/groups.d.ts.map +0 -1
  275. package/dist/esm/types/groups.js +0 -2
  276. package/dist/esm/types/groups.js.map +0 -1
  277. package/dist/esm/types/index.d.ts +0 -629
  278. package/dist/esm/types/index.d.ts.map +0 -1
  279. package/dist/esm/types/index.js +0 -8
  280. package/dist/esm/types/index.js.map +0 -1
  281. package/dist/esm/types/instances.d.ts +0 -4
  282. package/dist/esm/types/instances.d.ts.map +0 -1
  283. package/dist/esm/types/instances.js +0 -2
  284. package/dist/esm/types/instances.js.map +0 -1
  285. package/dist/esm/types/selectors.d.ts +0 -8
  286. package/dist/esm/types/selectors.d.ts.map +0 -1
  287. package/dist/esm/types/selectors.js +0 -2
  288. package/dist/esm/types/selectors.js.map +0 -1
  289. package/dist/esm/types/utilities.d.ts +0 -83
  290. package/dist/esm/types/utilities.d.ts.map +0 -1
  291. package/dist/esm/types/utilities.js +0 -2
  292. package/dist/esm/types/utilities.js.map +0 -1
  293. package/dist/esm/types/visual.d.ts +0 -185
  294. package/dist/esm/types/visual.d.ts.map +0 -1
  295. package/dist/esm/types/visual.js +0 -2
  296. package/dist/esm/types/visual.js.map +0 -1
  297. package/dist/esm/utils/image.d.ts +0 -72
  298. package/dist/esm/utils/image.d.ts.map +0 -1
  299. package/dist/esm/utils/image.js +0 -96
  300. package/dist/esm/utils/image.js.map +0 -1
  301. package/dist/esm/utils/index.d.ts +0 -2
  302. package/dist/esm/utils/index.d.ts.map +0 -1
  303. package/dist/esm/utils/index.js +0 -2
  304. package/dist/esm/utils/index.js.map +0 -1
@@ -1,64 +0,0 @@
1
- import { BaseRequestParameters, 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
- */
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
- * @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.
44
- */
45
- get<D extends SerializedData>(slug: string, params?: BaseRequestParameters, options?: RequestInit): Promise<StarlightItemResponse<Singleton<D>>>;
46
- /**
47
- * Returns a {@link StarlightListResponse} with a list of
48
- * {@apilink Singleton | Singletons}.
49
- *
50
- * @example Requesting all workspace singletons.
51
- * ```ts
52
- * import Starlight from '@starlightcms/js-sdk'
53
- *
54
- * const response = await Starlight.singletons.list()
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.
61
- */
62
- list(params?: BaseRequestParameters, options?: RequestInit): Promise<StarlightListResponse<Singleton<Record<string, unknown>>>>;
63
- }
64
- //# sourceMappingURL=types.d.ts.map
@@ -1 +0,0 @@
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,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=types.js.map
@@ -1 +0,0 @@
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"]}
@@ -1,362 +0,0 @@
1
- /**
2
- * Base interface used by all entities returned by the API.
3
- *
4
- * @internal
5
- */
6
- interface StarlightEntity {
7
- id: number;
8
- created_at: string;
9
- updated_at?: string;
10
- }
11
- /**
12
- * Represents a Model Category entity returned by the API.
13
- *
14
- * @group API Entities
15
- */
16
- export interface ModelCategory extends StarlightEntity {
17
- title: string;
18
- slug: string;
19
- entry_count?: number;
20
- }
21
- /**
22
- * Represents a Media File entity returned by the API.
23
- *
24
- * @group API Entities
25
- */
26
- export interface MediaFile extends StarlightEntity {
27
- variation: string;
28
- path: string;
29
- mime: string;
30
- background_color?: string;
31
- filesize: number;
32
- meta?: Record<string, unknown>;
33
- }
34
- /**
35
- * Represents a Media Object entity returned by the API.
36
- *
37
- * @group API Entities
38
- */
39
- export interface MediaObject extends StarlightEntity {
40
- name: string;
41
- extension: string;
42
- mime: string;
43
- files: MediaFile[];
44
- alt?: string;
45
- description?: string;
46
- }
47
- /**
48
- * Represents an Author entity returned by the API. Authors are returned in
49
- * {@link Entry} requests.
50
- *
51
- * @group API Entities
52
- */
53
- export interface Author {
54
- id: number;
55
- name: string;
56
- }
57
- /**
58
- * Represents a Model entity returned by the API.
59
- *
60
- * @group API Entities
61
- */
62
- export interface Model extends StarlightEntity {
63
- title: string;
64
- slug: string;
65
- entry_count?: number;
66
- }
67
- /**
68
- * Represents a field returned by the API in Model schemas.
69
- *
70
- * @group API Entities
71
- */
72
- export interface Field {
73
- title: string;
74
- key: string;
75
- type: string;
76
- is_required: boolean;
77
- is_listable: boolean;
78
- is_private: boolean;
79
- is_archived: boolean;
80
- rules?: {
81
- [rule: string]: unknown;
82
- };
83
- }
84
- /**
85
- * Represents a group of fields returned by the API in Model schemas.
86
- *
87
- * @group API Entities
88
- */
89
- export interface SchemaFieldGroup {
90
- title: string;
91
- type: string;
92
- fields: Field[];
93
- }
94
- /**
95
- * Represents a Model schema entity returned by the API.
96
- *
97
- * @group API Entities
98
- */
99
- export interface ModelSchema {
100
- version: number;
101
- groups: SchemaFieldGroup[];
102
- }
103
- /**
104
- * Represents a Form entity returned by the API.
105
- *
106
- * @group API Entities
107
- */
108
- export interface Form extends StarlightEntity {
109
- title: string;
110
- slug: string;
111
- action_url: string;
112
- }
113
- /**
114
- * Represents a Form schema entity returned by the API.
115
- *
116
- * @group API Entities
117
- */
118
- export interface FormSchema extends ModelSchema {
119
- action_url: string;
120
- }
121
- /**
122
- * Represents content data returned by either an {@link Entry} or
123
- * {@link Singleton} entity from the API.
124
- *
125
- * This is a utility type used internally by the SDK and you don't
126
- * need to use it. Its purpose is to constraint Entry and Singleton
127
- * data to the shape of a JS object.
128
- *
129
- * @category Internal Types
130
- */
131
- export type SerializedData = Record<string, unknown> | undefined;
132
- /**
133
- * Utility type that creates a string map of all fields of the given
134
- * SerializedData type with the `field:` prefix. This syntax allows to filter
135
- * specific fields when listing {@apilink Entry | Entries}:
136
- *
137
- * - Text fields can be filtered by a string query. This works just like
138
- * passing a `query` parameter, but it only applies to one field.
139
- * - Boolean fields can be filtered by "true" or "false".
140
- *
141
- * If a request uses this type, it means that this syntax can be used in their
142
- * parameters:
143
- *
144
- * ```ts
145
- * import Starlight from '@starlightcms/js-sdk'
146
- *
147
- * const response = await Starlight.posts.entries.list({
148
- * // EntrySelector.list() supports the "field:foo" syntax:
149
- * 'field:content': 'hello world',
150
- * 'field:is_featured': true,
151
- *
152
- * // EntrySelector.list() also support other parameters,
153
- * // which are passed in this object too:
154
- * page: 42,
155
- * limit: 20,
156
- * })
157
- * ```
158
- *
159
- * @remark
160
- *
161
- * The information below is only useful for SDK maintainers.
162
- *
163
- * This type receives a {@link SerializedData}-like structure, like an object.
164
- * For instance, for an {@link Entry} with fields "content" and "summary",
165
- * the generated type would look like this:
166
- *
167
- * ```ts
168
- * type GeneratedType = {
169
- * 'field:content'?: string
170
- * 'field:summary'?: string
171
- * }
172
- * ```
173
- *
174
- * However, note that QueryableFields receive a {@link SerializedData}, not an
175
- * {@link Entry}:
176
- *
177
- * ```ts
178
- * import { VisualField, StringField } from '@starlightcms/js-sdk'
179
- *
180
- * type EntryFields = {
181
- * content: VisualField
182
- * summary: StringField
183
- * }
184
- *
185
- * type MyEntry = Entry<EntryFields>
186
- *
187
- * // Error TS2344: Type does not satisfy the constraint 'SerializedData'
188
- * type GeneratedType = QueryableFields<MyEntry>
189
- *
190
- * // Works!
191
- * type GeneratedType = QueryableFields<EntryFields>
192
- * ```
193
- *
194
- * This type is only useful to request methods that support
195
- * field querying using the "field:foo" syntax.
196
- *
197
- * @category Internal Types
198
- */
199
- export type QueryableFields<D extends SerializedData> = {
200
- [K in keyof D as `field:${string & K}`]?: string | boolean;
201
- };
202
- /**
203
- * Utility type that return {@link QueryableFields} if the given type T
204
- * is an {@link Entry} or a {@link Singleton}, but generates an empty object
205
- * otherwise.
206
- *
207
- * Fun fact: internally, Entries and Singletons have parent Models,
208
- * which is why they are called "modelables" here.
209
- *
210
- * @category Internal Types
211
- */
212
- export type WithQueryableFieldsOnModelables<T> = T extends Entry<never> | Singleton<never> ? QueryableFields<T['data']> : never;
213
- /**
214
- * Represents an Entry entity returned by the API.
215
- *
216
- * An Entry's `data` field can be further typed by passing an object-like
217
- * structure as the D generic type. This is useful to provide type-safety to
218
- * your application, since the `data` field is a generic JS object by default.
219
- *
220
- * It's recommended to use the Field types provided by this SDK to type your
221
- * entities using a type definition file on your project. For instance:
222
- *
223
- * ```ts
224
- * // starlight.d.ts file
225
- * import { VisualField, MediaField } from '@starlightcms/js-sdk'
226
- *
227
- * type PostFields = {
228
- * featured_image: MediaField
229
- * content: VisualField
230
- * }
231
- *
232
- * declare module '@starlightcms/js-sdk' {
233
- * export interface DefaultModelDefinition {
234
- * posts: PostFields
235
- * }
236
- * }
237
- * ```
238
- *
239
- * You can place this type definition file anywhere in your repository, but it's
240
- * good practice to place it at the same level as your root index.ts file. Then,
241
- * in your files, all SDK calls will correctly type `posts`:
242
- *
243
- * ```ts
244
- * import Starlight from '@starlightcms/js-sdk'
245
- *
246
- * // response type will be StarlightItemResponse<Entry<PostFields>> on request success
247
- * const response = await Starlight.posts.entries.get('hello-world')
248
- *
249
- * // helloWorld type is Entry<PostFields>
250
- * const helloWorld = response.data
251
- * ```
252
- *
253
- * See {@apilink DefaultModelDefinition} for more info.
254
- *
255
- * @group API Entities
256
- */
257
- export interface Entry<D extends SerializedData> extends Omit<StarlightEntity, 'created_at'> {
258
- title: string;
259
- slug: string;
260
- data: D;
261
- author: Author;
262
- model?: Model;
263
- category: ModelCategory | null;
264
- published_at: string | null;
265
- }
266
- /**
267
- * Represents a Singleton entity returned by the API.
268
- *
269
- * A Singleton's `data` field can be further typed by passing an object-like
270
- * structure as the D generic type. This is useful to provide type-safety to
271
- * your application, since the `data` field is a generic JS object by default.
272
- *
273
- * It's recommended to use the Field types provided by this SDK to type your
274
- * Singletons. For instance:
275
- *
276
- * ```ts
277
- * import { StringField, VisualField, MediaField } from '@starlightcms/js-sdk'
278
- *
279
- * type HomeFields = {
280
- * site_title: StringField
281
- * hero_image: MediaField
282
- * hero_content: VisualField
283
- * }
284
- *
285
- * // response type will be StarlightItemResponse<Singleton<HomeFields>> on request success
286
- * const response = Starlight.singletons.get<HomeFields>('home')
287
- *
288
- * // home type is Singleton<HomeFields>
289
- * const home = response.data
290
- * ```
291
- *
292
- * You could also place all your Singleton field types in the same type
293
- * definition file used to configure Entry fields, which makes it easier to
294
- * import these types in other files on your project. See
295
- * {@apilink DefaultModelDefinition} for more info.
296
- *
297
- * @group API Entities
298
- */
299
- export interface Singleton<D extends SerializedData> extends Omit<StarlightEntity, 'created_at'> {
300
- title: string;
301
- slug: string;
302
- data: D;
303
- published_at: string | null;
304
- }
305
- /**
306
- * Currently supported Collection types. This type is mainly used to provide
307
- * autocompletion on IDEs, since it lets users use any string as well as the
308
- * known supported types.
309
- *
310
- * @internal
311
- */
312
- export type CollectionTypes = 'entry' | 'singleton' | 'media' | string;
313
- /**
314
- * Currently supported Collection entities. This type is mainly used to infer
315
- * the collection type string (see {@link CollectionTypes}) from the type of
316
- * entity that that Collection holds.
317
- *
318
- * @internal
319
- */
320
- export type CollectionEntityTypes = Entry<never> | Singleton<never> | MediaObject | unknown;
321
- /**
322
- * Infers a Collection type from an entity type. See {@link CollectionTypes} and
323
- * {@link CollectionEntityTypes} to know more.
324
- *
325
- * @internal
326
- */
327
- export type CollectionTypeMapper<T extends CollectionEntityTypes> = T extends Entry<any> ? 'entry' : T extends Singleton<any> ? 'singleton' : T extends MediaObject ? 'media' : string;
328
- /**
329
- * Represents a Collection entity returned by the API.
330
- *
331
- * You can request collections using a {@link CollectionInstance} or a
332
- * {@link CollectionSelector}.
333
- *
334
- * @group API Entities
335
- */
336
- export interface Collection<T extends CollectionTypes = string> extends StarlightEntity {
337
- title: string;
338
- slug: string;
339
- type: T;
340
- item_count?: number;
341
- }
342
- /**
343
- * Currently supported Relation types.
344
- */
345
- type RelationTypes = Entry<never> | Singleton<never> | MediaObject | Collection | unknown;
346
- /**
347
- * Represents a Relation entity returned by the API.
348
- *
349
- * @group API Entities
350
- */
351
- export interface Relation<T extends RelationTypes> {
352
- /**
353
- * The relation type, which is always a string. If the `object` field of this
354
- * Relation is an Entry, type will be `entry`, if it's a Singleton, type will
355
- * be `singleton`, and so on.
356
- */
357
- type: T extends Entry<never> ? 'entry' : T extends Singleton<never> ? 'singleton' : T extends MediaObject ? 'media' : T extends Collection ? 'collection' : string;
358
- id: number;
359
- object: T;
360
- }
361
- export {};
362
- //# sourceMappingURL=entities.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"entities.d.ts","sourceRoot":"","sources":["../../../src/types/entities.ts"],"names":[],"mappings":"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"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=entities.js.map
@@ -1 +0,0 @@
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 a field returned by the API in Model schemas.\n *\n * @group API Entities\n */\nexport interface Field {\n title: string\n key: string\n type: string\n is_required: boolean\n is_listable: boolean\n is_private: boolean\n is_archived: boolean\n rules?: {\n [rule: string]: unknown\n }\n}\n\n/**\n * Represents a group of fields returned by the API in Model schemas.\n *\n * @group API Entities\n */\nexport interface SchemaFieldGroup {\n title: string\n type: string\n fields: Field[]\n}\n\n/**\n * Represents a Model schema entity returned by the API.\n *\n * @group API Entities\n */\nexport interface ModelSchema {\n version: number\n groups: SchemaFieldGroup[]\n}\n\n/**\n * Represents a Form entity returned by the API.\n *\n * @group API Entities\n */\nexport interface Form extends StarlightEntity {\n title: string\n slug: string\n action_url: string\n}\n\n/**\n * Represents a Form schema entity returned by the API.\n *\n * @group API Entities\n */\nexport interface FormSchema extends ModelSchema {\n action_url: string\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> extends Omit<\n StarlightEntity,\n 'created_at'\n> {\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> extends Omit<\n StarlightEntity,\n 'created_at'\n> {\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<\n 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,123 +0,0 @@
1
- import { MediaObject, Relation } from './entities';
2
- import { VisualData } from './visual';
3
- /**
4
- * Represents a Boolean Field returned by the API.
5
- *
6
- * Field types are used to type Entry and Singleton objects when requesting
7
- * them using some SDK methods. See {@apilink DefaultModelDefinition}
8
- * for more info.
9
- *
10
- * @group Data Fields
11
- */
12
- export type BooleanField = boolean | undefined;
13
- /**
14
- * Represents an HTML Field returned by the API.
15
- *
16
- * Field types are used to type Entry and Singleton objects when requesting
17
- * them using some SDK methods. See {@apilink DefaultModelDefinition}
18
- * for more info.
19
- *
20
- * @group Data Fields
21
- */
22
- export type HtmlField = string | undefined;
23
- /**
24
- * Represents a Media Field returned by the API.
25
- *
26
- * Field types are used to type Entry and Singleton objects when requesting
27
- * them using some SDK methods. See {@apilink DefaultModelDefinition}
28
- * for more info.
29
- *
30
- * @group Data Fields
31
- */
32
- export type MediaField = MediaObject | undefined;
33
- /**
34
- * Represents a Relation Field returned by the API.
35
- *
36
- * Field types are used to type Entry and Singleton objects when requesting
37
- * them using some SDK methods. See {@apilink DefaultModelDefinition}
38
- * for more info.
39
- *
40
- * @group Data Fields
41
- */
42
- export type RelationField<T> = Relation<T> | undefined;
43
- /**
44
- * Represents a String Field returned by the API.
45
- *
46
- * Field types are used to type Entry and Singleton objects when requesting
47
- * them using some SDK methods. See {@apilink DefaultModelDefinition}
48
- * for more info.
49
- *
50
- * @group Data Fields
51
- */
52
- export type StringField = string | undefined;
53
- /**
54
- * Represents a Text Field returned by the API.
55
- *
56
- * Field types are used to type Entry and Singleton objects when requesting
57
- * them using some SDK methods. See {@apilink DefaultModelDefinition}
58
- * for more info.
59
- *
60
- * @group Data Fields
61
- */
62
- export type TextField = string | undefined;
63
- /**
64
- * Represents a Visual Field returned by the API.
65
- *
66
- * Field types are used to type Entry and Singleton objects when requesting
67
- * them using some SDK methods. See {@apilink DefaultModelDefinition}
68
- * for more info.
69
- *
70
- * @group Data Fields
71
- */
72
- export type VisualField = VisualData | undefined;
73
- /**
74
- * Represents an Integer Field returned by the API.
75
- *
76
- * Field types are used to type Entry and Singleton objects when requesting
77
- * them using some SDK methods. See {@apilink DefaultModelDefinition}
78
- * for more info.
79
- *
80
- * @group Data Fields
81
- */
82
- export type IntegerField = number | undefined;
83
- /**
84
- * Represents a Float Field returned by the API.
85
- *
86
- * Field types are used to type Entry and Singleton objects when requesting
87
- * them using some SDK methods. See {@apilink DefaultModelDefinition}
88
- * for more info.
89
- *
90
- * @group Data Fields
91
- */
92
- export type FloatField = number | undefined;
93
- /**
94
- * Represents a Decimal Field returned by the API.
95
- *
96
- * Field types are used to type Entry and Singleton objects when requesting
97
- * them using some SDK methods. See {@apilink DefaultModelDefinition}
98
- * for more info.
99
- *
100
- * @group Data Fields
101
- */
102
- export type DecimalField = number | undefined;
103
- export type SelectFieldOptions = {
104
- /**
105
- * Indicates if the Select Field accepts multiple selected choices.
106
- *
107
- * @default false
108
- */
109
- multiple?: boolean;
110
- };
111
- /**
112
- * Represents a Select Field returned by the API.
113
- *
114
- * Field types are used to type Entry and Singleton objects when requesting
115
- * them using some SDK methods. See {@apilink DefaultModelDefinition}
116
- * for more info.
117
- *
118
- * @group Data Fields
119
- */
120
- export type SelectField<Options extends SelectFieldOptions = {
121
- multiple: false;
122
- }> = (Options['multiple'] extends false ? string : string | string[]) | undefined;
123
- //# sourceMappingURL=fields.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"fields.d.ts","sourceRoot":"","sources":["../../../src/types/fields.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AAErC;;;;;;;;GAQG;AACH,MAAM,MAAM,YAAY,GAAG,OAAO,GAAG,SAAS,CAAA;AAE9C;;;;;;;;GAQG;AACH,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,SAAS,CAAA;AAE1C;;;;;;;;GAQG;AACH,MAAM,MAAM,UAAU,GAAG,WAAW,GAAG,SAAS,CAAA;AAEhD;;;;;;;;GAQG;AACH,MAAM,MAAM,aAAa,CAAC,CAAC,IAAI,QAAQ,CAAC,CAAC,CAAC,GAAG,SAAS,CAAA;AAEtD;;;;;;;;GAQG;AACH,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,SAAS,CAAA;AAE5C;;;;;;;;GAQG;AACH,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,SAAS,CAAA;AAE1C;;;;;;;;GAQG;AACH,MAAM,MAAM,WAAW,GAAG,UAAU,GAAG,SAAS,CAAA;AAEhD;;;;;;;;GAQG;AACH,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,SAAS,CAAA;AAE7C;;;;;;;;GAQG;AACH,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,SAAS,CAAA;AAE3C;;;;;;;;GAQG;AACH,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,SAAS,CAAA;AAE7C,MAAM,MAAM,kBAAkB,GAAG;IAC/B;;;;OAIG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB,CAAA;AAED;;;;;;;;GAQG;AACH,MAAM,MAAM,WAAW,CACrB,OAAO,SAAS,kBAAkB,GAAG;IAAE,QAAQ,EAAE,KAAK,CAAA;CAAE,IACtD,CAAC,OAAO,CAAC,UAAU,CAAC,SAAS,KAAK,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,EAAE,CAAC,GAAG,SAAS,CAAA"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=fields.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"fields.js","sourceRoot":"","sources":["../../../src/types/fields.ts"],"names":[],"mappings":"","sourcesContent":["import { MediaObject, Relation } from './entities'\nimport { VisualData } from './visual'\n\n/**\n * Represents a Boolean Field returned by the API.\n *\n * Field types are used to type Entry and Singleton objects when requesting\n * them using some SDK methods. See {@apilink DefaultModelDefinition}\n * for more info.\n *\n * @group Data Fields\n */\nexport type BooleanField = boolean | undefined\n\n/**\n * Represents an HTML Field returned by the API.\n *\n * Field types are used to type Entry and Singleton objects when requesting\n * them using some SDK methods. See {@apilink DefaultModelDefinition}\n * for more info.\n *\n * @group Data Fields\n */\nexport type HtmlField = string | undefined\n\n/**\n * Represents a Media Field returned by the API.\n *\n * Field types are used to type Entry and Singleton objects when requesting\n * them using some SDK methods. See {@apilink DefaultModelDefinition}\n * for more info.\n *\n * @group Data Fields\n */\nexport type MediaField = MediaObject | undefined\n\n/**\n * Represents a Relation Field returned by the API.\n *\n * Field types are used to type Entry and Singleton objects when requesting\n * them using some SDK methods. See {@apilink DefaultModelDefinition}\n * for more info.\n *\n * @group Data Fields\n */\nexport type RelationField<T> = Relation<T> | undefined\n\n/**\n * Represents a String Field returned by the API.\n *\n * Field types are used to type Entry and Singleton objects when requesting\n * them using some SDK methods. See {@apilink DefaultModelDefinition}\n * for more info.\n *\n * @group Data Fields\n */\nexport type StringField = string | undefined\n\n/**\n * Represents a Text Field returned by the API.\n *\n * Field types are used to type Entry and Singleton objects when requesting\n * them using some SDK methods. See {@apilink DefaultModelDefinition}\n * for more info.\n *\n * @group Data Fields\n */\nexport type TextField = string | undefined\n\n/**\n * Represents a Visual Field returned by the API.\n *\n * Field types are used to type Entry and Singleton objects when requesting\n * them using some SDK methods. See {@apilink DefaultModelDefinition}\n * for more info.\n *\n * @group Data Fields\n */\nexport type VisualField = VisualData | undefined\n\n/**\n * Represents an Integer Field returned by the API.\n *\n * Field types are used to type Entry and Singleton objects when requesting\n * them using some SDK methods. See {@apilink DefaultModelDefinition}\n * for more info.\n *\n * @group Data Fields\n */\nexport type IntegerField = number | undefined\n\n/**\n * Represents a Float Field returned by the API.\n *\n * Field types are used to type Entry and Singleton objects when requesting\n * them using some SDK methods. See {@apilink DefaultModelDefinition}\n * for more info.\n *\n * @group Data Fields\n */\nexport type FloatField = number | undefined\n\n/**\n * Represents a Decimal Field returned by the API.\n *\n * Field types are used to type Entry and Singleton objects when requesting\n * them using some SDK methods. See {@apilink DefaultModelDefinition}\n * for more info.\n *\n * @group Data Fields\n */\nexport type DecimalField = number | undefined\n\nexport type SelectFieldOptions = {\n /**\n * Indicates if the Select Field accepts multiple selected choices.\n *\n * @default false\n */\n multiple?: boolean\n}\n\n/**\n * Represents a Select Field returned by the API.\n *\n * Field types are used to type Entry and Singleton objects when requesting\n * them using some SDK methods. See {@apilink DefaultModelDefinition}\n * for more info.\n *\n * @group Data Fields\n */\nexport type SelectField<\n Options extends SelectFieldOptions = { multiple: false },\n> = (Options['multiple'] extends false ? string : string | string[]) | undefined\n"]}
@@ -1,30 +0,0 @@
1
- /**
2
- * Represents a Group returned by the API.
3
- *
4
- * Group types are used to type Entry and Singleton objects when requesting
5
- * them using some SDK methods. See {@apilink DefaultModelDefinition}
6
- * for more info.
7
- *
8
- * @group Data Groups
9
- */
10
- export type Group<Fields extends Record<string, unknown>> = {
11
- [Property in keyof Fields]: Fields[Property];
12
- } | undefined;
13
- /**
14
- * Represents a Repeater Group returned by the API.
15
- *
16
- * Note that the API return empty repeaters as `null`.
17
- *
18
- * To retrieve the type of a `RepeaterGroup` item, use the
19
- * {@apilink RepeaterItem} utility type.
20
- *
21
- * Group types are used to type Entry and Singleton objects when requesting
22
- * them using some SDK methods. See {@apilink DefaultModelDefinition}
23
- * for more info.
24
- *
25
- * @group Data Groups
26
- */
27
- export type RepeaterGroup<Fields extends Record<string, unknown>> = Array<{
28
- [Property in keyof Fields]: Fields[Property];
29
- }> | null | undefined;
30
- //# sourceMappingURL=groups.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"groups.d.ts","sourceRoot":"","sources":["../../../src/types/groups.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,MAAM,MAAM,KAAK,CAAC,MAAM,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,IACpD;KAAG,QAAQ,IAAI,MAAM,MAAM,GAAG,MAAM,CAAC,QAAQ,CAAC;CAAE,GAChD,SAAS,CAAA;AAEb;;;;;;;;;;;;;GAaG;AACH,MAAM,MAAM,aAAa,CAAC,MAAM,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,IAC5D,KAAK,CAAC;KAAG,QAAQ,IAAI,MAAM,MAAM,GAAG,MAAM,CAAC,QAAQ,CAAC;CAAE,CAAC,GACvD,IAAI,GACJ,SAAS,CAAA"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=groups.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"groups.js","sourceRoot":"","sources":["../../../src/types/groups.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * Represents a Group returned by the API.\n *\n * Group types are used to type Entry and Singleton objects when requesting\n * them using some SDK methods. See {@apilink DefaultModelDefinition}\n * for more info.\n *\n * @group Data Groups\n */\nexport type Group<Fields extends Record<string, unknown>> =\n | { [Property in keyof Fields]: Fields[Property] }\n | undefined\n\n/**\n * Represents a Repeater Group returned by the API.\n *\n * Note that the API return empty repeaters as `null`.\n *\n * To retrieve the type of a `RepeaterGroup` item, use the\n * {@apilink RepeaterItem} utility type.\n *\n * Group types are used to type Entry and Singleton objects when requesting\n * them using some SDK methods. See {@apilink DefaultModelDefinition}\n * for more info.\n *\n * @group Data Groups\n */\nexport type RepeaterGroup<Fields extends Record<string, unknown>> =\n | Array<{ [Property in keyof Fields]: Fields[Property] }>\n | null\n | undefined\n"]}