@starlightcms/js-sdk 2.1.0 → 2.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. package/dist/cjs/client.d.ts.map +1 -1
  2. package/dist/cjs/client.js +8 -0
  3. package/dist/cjs/client.js.map +1 -1
  4. package/dist/cjs/instances/Form/index.d.ts +5 -0
  5. package/dist/cjs/instances/Form/index.d.ts.map +1 -0
  6. package/dist/cjs/instances/Form/index.js +14 -0
  7. package/dist/cjs/instances/Form/index.js.map +1 -0
  8. package/dist/cjs/instances/Form/types.d.ts +38 -0
  9. package/dist/cjs/instances/Form/types.d.ts.map +1 -0
  10. package/dist/cjs/instances/Form/types.js +3 -0
  11. package/dist/cjs/instances/Form/types.js.map +1 -0
  12. package/dist/cjs/selectors/Form/index.d.ts +4 -0
  13. package/dist/cjs/selectors/Form/index.d.ts.map +1 -0
  14. package/dist/cjs/selectors/Form/index.js +18 -0
  15. package/dist/cjs/selectors/Form/index.js.map +1 -0
  16. package/dist/cjs/selectors/Form/types.d.ts +22 -0
  17. package/dist/cjs/selectors/Form/types.d.ts.map +1 -0
  18. package/dist/cjs/selectors/Form/types.js +3 -0
  19. package/dist/cjs/selectors/Form/types.js.map +1 -0
  20. package/dist/cjs/types/entities.d.ts +54 -0
  21. package/dist/cjs/types/entities.d.ts.map +1 -1
  22. package/dist/cjs/types/entities.js.map +1 -1
  23. package/dist/cjs/types/index.d.ts +35 -0
  24. package/dist/cjs/types/index.d.ts.map +1 -1
  25. package/dist/cjs/types/index.js.map +1 -1
  26. package/dist/cjs/types/visual.d.ts +1 -1
  27. package/dist/cjs/types/visual.d.ts.map +1 -1
  28. package/dist/cjs/types/visual.js.map +1 -1
  29. package/dist/esm/client.d.ts.map +1 -1
  30. package/dist/esm/client.js +8 -0
  31. package/dist/esm/client.js.map +1 -1
  32. package/dist/esm/instances/Form/index.d.ts +5 -0
  33. package/dist/esm/instances/Form/index.d.ts.map +1 -0
  34. package/dist/esm/instances/Form/index.js +11 -0
  35. package/dist/esm/instances/Form/index.js.map +1 -0
  36. package/dist/esm/instances/Form/types.d.ts +38 -0
  37. package/dist/esm/instances/Form/types.d.ts.map +1 -0
  38. package/dist/esm/instances/Form/types.js +2 -0
  39. package/dist/esm/instances/Form/types.js.map +1 -0
  40. package/dist/esm/selectors/Form/index.d.ts +4 -0
  41. package/dist/esm/selectors/Form/index.d.ts.map +1 -0
  42. package/dist/esm/selectors/Form/index.js +12 -0
  43. package/dist/esm/selectors/Form/index.js.map +1 -0
  44. package/dist/esm/selectors/Form/types.d.ts +22 -0
  45. package/dist/esm/selectors/Form/types.d.ts.map +1 -0
  46. package/dist/esm/selectors/Form/types.js +2 -0
  47. package/dist/esm/selectors/Form/types.js.map +1 -0
  48. package/dist/esm/types/entities.d.ts +54 -0
  49. package/dist/esm/types/entities.d.ts.map +1 -1
  50. package/dist/esm/types/entities.js.map +1 -1
  51. package/dist/esm/types/index.d.ts +35 -0
  52. package/dist/esm/types/index.d.ts.map +1 -1
  53. package/dist/esm/types/index.js.map +1 -1
  54. package/dist/esm/types/visual.d.ts +1 -1
  55. package/dist/esm/types/visual.d.ts.map +1 -1
  56. package/dist/esm/types/visual.js.map +1 -1
  57. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,sBAAsB,EACtB,sBAAsB,EAEtB,eAAe,EACf,wBAAwB,EACzB,MAAM,SAAS,CAAA;AAUhB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,wBAAgB,UAAU,CACxB,CAAC,SAAS,wBAAwB,GAAG,sBAAsB,EAE3D,MAAM,GAAE,eAAoB,GAC3B,sBAAsB,CAAC,CAAC,GAAG,wBAAwB,CAAC,CAwFtD"}
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,sBAAsB,EACtB,sBAAsB,EAEtB,eAAe,EACf,wBAAwB,EACzB,MAAM,SAAS,CAAA;AAYhB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,wBAAgB,UAAU,CACxB,CAAC,SAAS,wBAAwB,GAAG,sBAAsB,EAE3D,MAAM,GAAE,eAAoB,GAC3B,sBAAsB,CAAC,CAAC,GAAG,wBAAwB,CAAC,CAgGtD"}
@@ -21,6 +21,8 @@ const Collection_1 = __importDefault(require("./selectors/Collection"));
21
21
  const Media_1 = __importDefault(require("./selectors/Media"));
22
22
  const Search_1 = __importDefault(require("./selectors/Search"));
23
23
  const Collection_2 = __importDefault(require("./instances/Collection"));
24
+ const Form_1 = __importDefault(require("./selectors/Form"));
25
+ const Form_2 = __importDefault(require("./instances/Form"));
24
26
  /**
25
27
  * Returns a new {@link DynamicStarlightClient}, which is a
26
28
  * {@link StarlightClient} with support to create
@@ -109,6 +111,12 @@ function makeClient(config = {}) {
109
111
  model(slug) {
110
112
  return (0, Model_2.default)(this, slug);
111
113
  },
114
+ get forms() {
115
+ return (0, Form_1.default)(this);
116
+ },
117
+ form(slug) {
118
+ return (0, Form_2.default)(this, String(slug));
119
+ },
112
120
  get singletons() {
113
121
  return (0, Singleton_1.default)(this);
114
122
  },
@@ -1 +1 @@
1
- {"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/client.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAOA,qCAAyC;AACzC,8DAAiD;AACjD,8DAAiD;AACjD,sEAAyD;AACzD,wEAA2D;AAC3D,8DAAiD;AACjD,gEAAmD;AACnD,wEAA2D;AAE3D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,SAAgB,UAAU,CAGxB,SAA0B,EAAE;;IAE5B,IAAI,OAAO,GAAG,MAAA,MAAM,CAAC,OAAO,mCAAI,kCAAkC,CAAA;IAClE,IAAI,SAAS,GAAG,MAAA,MAAM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IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,EAAE;gBAC1D,OAAO,IAAA,eAAiB,EAAC,MAAM,EAAE,IAAI,CAAC,CAAA;aACvC;YAED,OAAO,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,CAAA;QAClC,CAAC;KACF,CAAyD,CAAA;AAC5D,CAAC;AA5FD,gCA4FC","sourcesContent":["import {\n DefaultModelDefinition,\n DynamicStarlightClient,\n StarlightClient,\n StarlightConfig,\n WorkspaceModelDefinition,\n} from './types'\nimport { StarlightError } from './errors'\nimport makeModelSelector from './selectors/Model'\nimport makeModelInstance from './instances/Model'\nimport makeSingletonSelector from './selectors/Singleton'\nimport makeCollectionSelector from './selectors/Collection'\nimport makeMediaSelector from './selectors/Media'\nimport makeSearchSelector from './selectors/Search'\nimport makeCollectionInstance from './instances/Collection'\n\n/**\n * Returns a new {@link DynamicStarlightClient}, which is a\n * {@link StarlightClient} with support to create\n * {@apilink ModelInstance | ModelInstances} using the dynamic syntax. To learn\n * which methods a client supports, see {@link StarlightClient}.\n *\n * This function accepts a {@link StarlightConfig} object and can be used to\n * create new clients that connect to a single Starlight workspace. Each client\n * returned by this function is separate and independent of the others.\n *\n * If you only need to make requests to a single workspace, it's probably easier\n * to use the SDK's default client. To use it, you only need to\n * import the default object exported by the SDK:\n *\n * ```ts\n * // `Starlight` below is the default StarlightClient.\n * import Starlight from '@starlightcms/js-sdk'\n * ```\n *\n * See {@link default} for more info on how to use the default client.\n *\n * @example Creating a new client and exporting it.\n * ```ts\n * import { makeStarlightClient } from '@starlightcms/js-sdk'\n *\n * const BlogClient = makeStarlightClient({\n * workspace: '123123123',\n * debug: true\n * })\n *\n * // Feel free to export the new client so your application can use it.\n * export default BlogClient\n * ```\n *\n * @param config The client configuration object. You need to provide at least\n * the `workspace` property. See {@link StarlightConfig} to view all the\n * available options.\n * @group Client\n */\nexport function makeClient<\n D extends WorkspaceModelDefinition = DefaultModelDefinition\n>(\n config: StarlightConfig = {}\n): DynamicStarlightClient<D & WorkspaceModelDefinition> {\n let baseUrl = config.baseUrl ?? 'https://query.starlightcms.io/v2'\n let workspace = config.workspace ?? ''\n let debug = config.debug ?? false\n\n const client: StarlightClient = {\n configure(config) {\n baseUrl = config.baseUrl ?? baseUrl\n workspace = config.workspace ?? workspace\n debug = config.debug ?? debug\n },\n\n log(message, ...optionalParams) {\n if (debug) console.log(message, ...optionalParams)\n },\n\n getBaseUrl() {\n if (!workspace.length) {\n throw new Error(\n 'No workspace defined. Use the `configure()` method on the Starlight client to define one.'\n )\n }\n\n return `${baseUrl}/workspaces/${workspace}`\n },\n\n async get(path, params = {}, options) {\n const filteredParams = Object.keys(params).reduce((accumulator, key) => {\n const param = params[key]\n\n if (param || param === false) accumulator[key] = String(param)\n\n return accumulator\n }, {} as Record<string, string>)\n\n const searchParams = new URLSearchParams(filteredParams).toString()\n const finalPath = searchParams ? `${path}?${searchParams}` : path\n\n this.log(`Starlight - GET ${finalPath}`)\n\n const response = await fetch(`${this.getBaseUrl()}${finalPath}`, options)\n\n if (response.status >= 200 && response.status < 300) {\n return await response.json()\n } else {\n const message = `Starlight - GET ${path} returned ${response.status}: ${response.statusText}`\n throw new StarlightError(message, response)\n }\n },\n\n get models() {\n return makeModelSelector(this)\n },\n\n model(slug) {\n return makeModelInstance(this, slug as string)\n },\n\n get singletons() {\n return makeSingletonSelector(this)\n },\n\n get collections() {\n return makeCollectionSelector(this)\n },\n\n collection(slug: string | number) {\n return makeCollectionInstance(this, slug)\n },\n\n get media() {\n return makeMediaSelector(this)\n },\n\n get search() {\n return makeSearchSelector(this)\n },\n }\n\n return new Proxy(client, {\n get(target, prop) {\n if (typeof prop === 'string' && !Reflect.has(target, prop)) {\n return makeModelInstance(target, prop)\n }\n\n return Reflect.get(target, prop)\n },\n }) as DynamicStarlightClient<D & WorkspaceModelDefinition>\n}\n"]}
1
+ {"version":3,"file":"client.js","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AAI;YACP,OAAO,IAAA,cAAgB,EAAC,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC,CAAA;QAC7C,CAAC;QAED,IAAI,UAAU;YACZ,OAAO,IAAA,mBAAqB,EAAC,IAAI,CAAC,CAAA;QACpC,CAAC;QAED,IAAI,WAAW;YACb,OAAO,IAAA,oBAAsB,EAAC,IAAI,CAAC,CAAA;QACrC,CAAC;QAED,UAAU,CAAC,IAAI;YACb,OAAO,IAAA,oBAAsB,EAAC,IAAI,EAAE,IAAI,CAAC,CAAA;QAC3C,CAAC;QAED,IAAI,KAAK;YACP,OAAO,IAAA,eAAiB,EAAC,IAAI,CAAC,CAAA;QAChC,CAAC;QAED,IAAI,MAAM;YACR,OAAO,IAAA,gBAAkB,EAAC,IAAI,CAAC,CAAA;QACjC,CAAC;KACF,CAAA;IAED,OAAO,IAAI,KAAK,CAAC,MAAM,EAAE;QACvB,GAAG,CAAC,MAAM,EAAE,IAAI;YACd,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,EAAE;gBAC1D,OAAO,IAAA,eAAiB,EAAC,MAAM,EAAE,IAAI,CAAC,CAAA;aACvC;YAED,OAAO,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,CAAA;QAClC,CAAC;KACF,CAAyD,CAAA;AAC5D,CAAC;AApGD,gCAoGC","sourcesContent":["import {\n DefaultModelDefinition,\n DynamicStarlightClient,\n StarlightClient,\n StarlightConfig,\n WorkspaceModelDefinition,\n} from './types'\nimport { StarlightError } from './errors'\nimport makeModelSelector from './selectors/Model'\nimport makeModelInstance from './instances/Model'\nimport makeSingletonSelector from './selectors/Singleton'\nimport makeCollectionSelector from './selectors/Collection'\nimport makeMediaSelector from './selectors/Media'\nimport makeSearchSelector from './selectors/Search'\nimport makeCollectionInstance from './instances/Collection'\nimport makeFormSelector from './selectors/Form'\nimport makeFormInstance from './instances/Form'\n\n/**\n * Returns a new {@link DynamicStarlightClient}, which is a\n * {@link StarlightClient} with support to create\n * {@apilink ModelInstance | ModelInstances} using the dynamic syntax. To learn\n * which methods a client supports, see {@link StarlightClient}.\n *\n * This function accepts a {@link StarlightConfig} object and can be used to\n * create new clients that connect to a single Starlight workspace. Each client\n * returned by this function is separate and independent of the others.\n *\n * If you only need to make requests to a single workspace, it's probably easier\n * to use the SDK's default client. To use it, you only need to\n * import the default object exported by the SDK:\n *\n * ```ts\n * // `Starlight` below is the default StarlightClient.\n * import Starlight from '@starlightcms/js-sdk'\n * ```\n *\n * See {@link default} for more info on how to use the default client.\n *\n * @example Creating a new client and exporting it.\n * ```ts\n * import { makeStarlightClient } from '@starlightcms/js-sdk'\n *\n * const BlogClient = makeStarlightClient({\n * workspace: '123123123',\n * debug: true\n * })\n *\n * // Feel free to export the new client so your application can use it.\n * export default BlogClient\n * ```\n *\n * @param config The client configuration object. You need to provide at least\n * the `workspace` property. See {@link StarlightConfig} to view all the\n * available options.\n * @group Client\n */\nexport function makeClient<\n D extends WorkspaceModelDefinition = DefaultModelDefinition\n>(\n config: StarlightConfig = {}\n): DynamicStarlightClient<D & WorkspaceModelDefinition> {\n let baseUrl = config.baseUrl ?? 'https://query.starlightcms.io/v2'\n let workspace = config.workspace ?? ''\n let debug = config.debug ?? false\n\n const client: StarlightClient = {\n configure(config) {\n baseUrl = config.baseUrl ?? baseUrl\n workspace = config.workspace ?? workspace\n debug = config.debug ?? debug\n },\n\n log(message, ...optionalParams) {\n if (debug) console.log(message, ...optionalParams)\n },\n\n getBaseUrl() {\n if (!workspace.length) {\n throw new Error(\n 'No workspace defined. Use the `configure()` method on the Starlight client to define one.'\n )\n }\n\n return `${baseUrl}/workspaces/${workspace}`\n },\n\n async get(path, params = {}, options) {\n const filteredParams = Object.keys(params).reduce((accumulator, key) => {\n const param = params[key]\n\n if (param || param === false) accumulator[key] = String(param)\n\n return accumulator\n }, {} as Record<string, string>)\n\n const searchParams = new URLSearchParams(filteredParams).toString()\n const finalPath = searchParams ? `${path}?${searchParams}` : path\n\n this.log(`Starlight - GET ${finalPath}`)\n\n const response = await fetch(`${this.getBaseUrl()}${finalPath}`, options)\n\n if (response.status >= 200 && response.status < 300) {\n return await response.json()\n } else {\n const message = `Starlight - GET ${path} returned ${response.status}: ${response.statusText}`\n throw new StarlightError(message, response)\n }\n },\n\n get models() {\n return makeModelSelector(this)\n },\n\n model(slug) {\n return makeModelInstance(this, slug as string)\n },\n\n get forms() {\n return makeFormSelector(this)\n },\n\n form(slug) {\n return makeFormInstance(this, String(slug))\n },\n\n get singletons() {\n return makeSingletonSelector(this)\n },\n\n get collections() {\n return makeCollectionSelector(this)\n },\n\n collection(slug) {\n return makeCollectionInstance(this, slug)\n },\n\n get media() {\n return makeMediaSelector(this)\n },\n\n get search() {\n return makeSearchSelector(this)\n },\n }\n\n return new Proxy(client, {\n get(target, prop) {\n if (typeof prop === 'string' && !Reflect.has(target, prop)) {\n return makeModelInstance(target, prop)\n }\n\n return Reflect.get(target, prop)\n },\n }) as DynamicStarlightClient<D & WorkspaceModelDefinition>\n}\n"]}
@@ -0,0 +1,5 @@
1
+ import { StarlightClient } from '../../types';
2
+ import { FormInstance } from './types';
3
+ export default function makeFormInstance(client: StarlightClient, form: string): FormInstance;
4
+ export { FormInstance };
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/instances/Form/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,eAAe,EAEhB,MAAM,aAAa,CAAA;AACpB,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAEtC,MAAM,CAAC,OAAO,UAAU,gBAAgB,CACtC,MAAM,EAAE,eAAe,EACvB,IAAI,EAAE,MAAM,GACX,YAAY,CASd;AAED,OAAO,EAAE,YAAY,EAAE,CAAA"}
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ function makeFormInstance(client, form) {
4
+ return {
5
+ get() {
6
+ return client.get(`/forms/${form}`);
7
+ },
8
+ schema() {
9
+ return client.get(`/forms/${form}/schema`);
10
+ },
11
+ };
12
+ }
13
+ exports.default = makeFormInstance;
14
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/instances/Form/index.ts"],"names":[],"mappings":";;AAQA,SAAwB,gBAAgB,CACtC,MAAuB,EACvB,IAAY;IAEZ,OAAO;QACL,GAAG;YACD,OAAO,MAAM,CAAC,GAAG,CAAC,UAAU,IAAI,EAAE,CAAC,CAAA;QACrC,CAAC;QACD,MAAM;YACJ,OAAO,MAAM,CAAC,GAAG,CAAC,UAAU,IAAI,SAAS,CAAC,CAAA;QAC5C,CAAC;KACF,CAAA;AACH,CAAC;AAZD,mCAYC","sourcesContent":["import {\n Form,\n FormSchema,\n StarlightClient,\n StarlightItemResponse,\n} from '../../types'\nimport { FormInstance } from './types'\n\nexport default function makeFormInstance(\n client: StarlightClient,\n form: string\n): FormInstance {\n return {\n get(): Promise<StarlightItemResponse<Form>> {\n return client.get(`/forms/${form}`)\n },\n schema(): Promise<StarlightItemResponse<FormSchema>> {\n return client.get(`/forms/${form}/schema`)\n },\n }\n}\n\nexport { FormInstance }\n"]}
@@ -0,0 +1,38 @@
1
+ import { Form, FormSchema, StarlightItemResponse } from '../../types';
2
+ /**
3
+ * An Instance that provide methods to request information from a {@link Form}
4
+ * and its {@apilink Field | Fields}.
5
+ *
6
+ * You can access a FormInstance using {@apilink StarlightClient.form} or
7
+ * using the dynamic syntax on a {@link DynamicFormSelector}. Usage
8
+ * examples will use the dynamic syntax.
9
+ *
10
+ * @group Instances
11
+ */
12
+ export interface FormInstance {
13
+ /**
14
+ * Returns a {@link StarlightItemResponse} with a single {@link Form}.
15
+ *
16
+ * @example Requesting information from a form of slug `signup`.
17
+ * ```ts
18
+ * import Starlight from '@starlightcms/js-sdk'
19
+ *
20
+ * const response = await Starlight.forms.signup.get()
21
+ * ```
22
+ */
23
+ get(): Promise<StarlightItemResponse<Form>>;
24
+ /**
25
+ * Returns a {@link StarlightItemResponse} with a {@link FormSchema}.
26
+ *
27
+ * @example Listing the schema from a form of slug `signup`.
28
+ * ```ts
29
+ * import Starlight from '@starlightcms/js-sdk'
30
+ *
31
+ * const response = await Starlight.forms.signup.schema()
32
+ * ```
33
+ *
34
+ * @param slug The category slug.
35
+ */
36
+ schema(): Promise<StarlightItemResponse<FormSchema>>;
37
+ }
38
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/instances/Form/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAA;AAErE;;;;;;;;;GASG;AACH,MAAM,WAAW,YAAY;IAC3B;;;;;;;;;OASG;IACH,GAAG,IAAI,OAAO,CAAC,qBAAqB,CAAC,IAAI,CAAC,CAAC,CAAA;IAE3C;;;;;;;;;;;OAWG;IACH,MAAM,IAAI,OAAO,CAAC,qBAAqB,CAAC,UAAU,CAAC,CAAC,CAAA;CACrD"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/instances/Form/types.ts"],"names":[],"mappings":"","sourcesContent":["import { Form, FormSchema, StarlightItemResponse } from '../../types'\n\n/**\n * An Instance that provide methods to request information from a {@link Form}\n * and its {@apilink Field | Fields}.\n *\n * You can access a FormInstance using {@apilink StarlightClient.form} or\n * using the dynamic syntax on a {@link DynamicFormSelector}. Usage\n * examples will use the dynamic syntax.\n *\n * @group Instances\n */\nexport interface FormInstance {\n /**\n * Returns a {@link StarlightItemResponse} with a single {@link Form}.\n *\n * @example Requesting information from a form of slug `signup`.\n * ```ts\n * import Starlight from '@starlightcms/js-sdk'\n *\n * const response = await Starlight.forms.signup.get()\n * ```\n */\n get(): Promise<StarlightItemResponse<Form>>\n\n /**\n * Returns a {@link StarlightItemResponse} with a {@link FormSchema}.\n *\n * @example Listing the schema from a form of slug `signup`.\n * ```ts\n * import Starlight from '@starlightcms/js-sdk'\n *\n * const response = await Starlight.forms.signup.schema()\n * ```\n *\n * @param slug The category slug.\n */\n schema(): Promise<StarlightItemResponse<FormSchema>>\n}\n"]}
@@ -0,0 +1,4 @@
1
+ import { StarlightClient } from '../../types';
2
+ import { DynamicFormSelector } from './types';
3
+ export default function makeFormSelector(client: StarlightClient): DynamicFormSelector;
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/selectors/Form/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAC7C,OAAO,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAA;AAG7C,MAAM,CAAC,OAAO,UAAU,gBAAgB,CACtC,MAAM,EAAE,eAAe,GACtB,mBAAmB,CAarB"}
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const Form_1 = __importDefault(require("../../instances/Form"));
7
+ function makeFormSelector(client) {
8
+ return new Proxy({}, {
9
+ get(target, prop) {
10
+ if (typeof prop === 'string' && !Reflect.has(target, prop)) {
11
+ return (0, Form_1.default)(client, prop);
12
+ }
13
+ return Reflect.get(target, prop);
14
+ },
15
+ });
16
+ }
17
+ exports.default = makeFormSelector;
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/selectors/Form/index.ts"],"names":[],"mappings":";;;;;AAEA,gEAAmD;AAEnD,SAAwB,gBAAgB,CACtC,MAAuB;IAEvB,OAAO,IAAI,KAAK,CACd,EAAE,EACF;QACE,GAAG,CAAC,MAAM,EAAE,IAAI;YACd,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,EAAE;gBAC1D,OAAO,IAAA,cAAgB,EAAC,MAAM,EAAE,IAAI,CAAC,CAAA;aACtC;YAED,OAAO,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,CAAA;QAClC,CAAC;KACF,CACF,CAAA;AACH,CAAC;AAfD,mCAeC","sourcesContent":["import { StarlightClient } from '../../types'\nimport { DynamicFormSelector } from './types'\nimport makeFormInstance from '../../instances/Form'\n\nexport default function makeFormSelector(\n client: StarlightClient\n): DynamicFormSelector {\n return new Proxy(\n {},\n {\n get(target, prop) {\n if (typeof prop === 'string' && !Reflect.has(target, prop)) {\n return makeFormInstance(client, prop)\n }\n\n return Reflect.get(target, prop)\n },\n }\n )\n}\n"]}
@@ -0,0 +1,22 @@
1
+ import { FormInstance } from '../../instances/Form';
2
+ /**
3
+ * A Selector that provides a way to create {@apilink FormInstance | FormInstances}
4
+ * using the dynamic syntax.
5
+ *
6
+ * See {@doclink requests-and-responses#dynamic-syntax | Dynamic Instances}
7
+ * documentation to learn more about the dynamic syntax.
8
+ *
9
+ * @example Accessing a FormInstance using the dynamic syntax.
10
+ * ```ts
11
+ * import Starlight from '@starlightcms/js-sdk'
12
+ *
13
+ * // "signup" below will be a FormInstance.
14
+ * const response = await Starlight.forms.signup.get()
15
+ * ```
16
+ *
17
+ * @category Selectors
18
+ */
19
+ export declare type DynamicFormSelector = {
20
+ [slug: string]: FormInstance;
21
+ };
22
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/selectors/Form/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AAEnD;;;;;;;;;;;;;;;;GAgBG;AACH,oBAAY,mBAAmB,GAAG;IAChC,CAAC,IAAI,EAAE,MAAM,GAAG,YAAY,CAAA;CAC7B,CAAA"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/selectors/Form/types.ts"],"names":[],"mappings":"","sourcesContent":["import { FormInstance } from '../../instances/Form'\n\n/**\n * A Selector that provides a way to create {@apilink FormInstance | FormInstances}\n * using the dynamic syntax.\n *\n * See {@doclink requests-and-responses#dynamic-syntax | Dynamic Instances}\n * documentation to learn more about the dynamic syntax.\n *\n * @example Accessing a FormInstance using the dynamic syntax.\n * ```ts\n * import Starlight from '@starlightcms/js-sdk'\n *\n * // \"signup\" below will be a FormInstance.\n * const response = await Starlight.forms.signup.get()\n * ```\n *\n * @category Selectors\n */\nexport type DynamicFormSelector = {\n [slug: string]: FormInstance\n}\n"]}
@@ -64,6 +64,60 @@ export interface Model extends StarlightEntity {
64
64
  slug: string;
65
65
  entry_count?: number;
66
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]: any;
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 FieldGroup {
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: FieldGroup[];
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
+ }
67
121
  /**
68
122
  * Represents content data returned by either an {@link Entry} or
69
123
  * {@link Singleton} entity from the API.
@@ -1 +1 @@
1
- {"version":3,"file":"entities.d.ts","sourceRoot":"","sources":["../../../src/types/entities.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,UAAU,eAAe;IACvB,EAAE,EAAE,MAAM,CAAA;IACV,UAAU,EAAE,MAAM,CAAA;IAClB,UAAU,CAAC,EAAE,MAAM,CAAA;CACpB;AAED;;;;GAIG;AACH,MAAM,WAAW,aAAc,SAAQ,eAAe;IACpD,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,EAAE,MAAM,CAAA;IACZ,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB;AAED;;;;GAIG;AACH,MAAM,WAAW,SAAU,SAAQ,eAAe;IAChD,SAAS,EAAE,MAAM,CAAA;IACjB,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;IACZ,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB,QAAQ,EAAE,MAAM,CAAA;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAC/B;AAED;;;;GAIG;AACH,MAAM,WAAW,WAAY,SAAQ,eAAe;IAClD,IAAI,EAAE,MAAM,CAAA;IACZ,SAAS,EAAE,MAAM,CAAA;IACjB,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,SAAS,EAAE,CAAA;IAClB,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB;AAED;;;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,CAAC,GAChB,OAAO,GACP,CAAC,SAAS,SAAS,CAAC,GAAG,CAAC,GACxB,WAAW,GACX,CAAC,SAAS,WAAW,GACrB,OAAO,GACP,MAAM,CAAA;AAEZ;;;;;;;GAOG;AACH,MAAM,WAAW,UAAU,CAAC,CAAC,SAAS,eAAe,GAAG,MAAM,CAC5D,SAAQ,eAAe;IACvB,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,CAAC,CAAA;IACP,UAAU,CAAC,EAAE,MAAM,CAAA;CACpB;AAED;;GAEG;AACH,aAAK,aAAa,GACd,KAAK,CAAC,KAAK,CAAC,GACZ,SAAS,CAAC,KAAK,CAAC,GAChB,WAAW,GACX,UAAU,GACV,OAAO,CAAA;AAEX;;;;GAIG;AACH,MAAM,WAAW,QAAQ,CAAC,CAAC,SAAS,aAAa;IAC/C;;;;OAIG;IACH,IAAI,EAAE,CAAC,SAAS,KAAK,CAAC,KAAK,CAAC,GACxB,OAAO,GACP,CAAC,SAAS,SAAS,CAAC,KAAK,CAAC,GAC1B,WAAW,GACX,CAAC,SAAS,WAAW,GACrB,OAAO,GACP,CAAC,SAAS,UAAU,GACpB,YAAY,GACZ,MAAM,CAAA;IACV,EAAE,EAAE,MAAM,CAAA;IACV,MAAM,EAAE,CAAC,CAAA;CACV"}
@@ -1 +1 @@
1
- {"version":3,"file":"entities.js","sourceRoot":"","sources":["../../../src/types/entities.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * Base interface used by all entities returned by the API.\n *\n * @internal\n */\ninterface StarlightEntity {\n id: number\n created_at: string\n updated_at?: string\n}\n\n/**\n * Represents a Model Category entity returned by the API.\n *\n * @group API Entities\n */\nexport interface ModelCategory extends StarlightEntity {\n title: string\n slug: string\n entry_count?: number\n}\n\n/**\n * Represents a Media File entity returned by the API.\n *\n * @group API Entities\n */\nexport interface MediaFile extends StarlightEntity {\n variation: string\n path: string\n mime: string\n background_color?: string\n filesize: number\n meta?: Record<string, unknown>\n}\n\n/**\n * Represents a Media Object entity returned by the API.\n *\n * @group API Entities\n */\nexport interface MediaObject extends StarlightEntity {\n name: string\n extension: string\n mime: string\n files: MediaFile[]\n alt?: string\n description?: string\n}\n\n/**\n * Represents an Author entity returned by the API. Authors are returned in\n * {@link Entry} requests.\n *\n * @group API Entities\n */\nexport interface Author {\n id: number\n name: string\n}\n\n/**\n * Represents a Model entity returned by the API.\n *\n * @group API Entities\n */\nexport interface Model extends StarlightEntity {\n title: string\n slug: string\n entry_count?: number\n}\n\n/**\n * Represents content data returned by either an {@link Entry} or\n * {@link Singleton} entity from the API.\n *\n * This is a utility type used internally by the SDK and you don't\n * need to use it. Its purpose is to constraint Entry and Singleton\n * data to the shape of a JS object.\n *\n * @category Internal Types\n */\nexport type SerializedData = Record<string, unknown> | undefined\n\n/**\n * Utility type that creates a string map of all fields of the given\n * SerializedData type with the `field:` prefix. This syntax allows to filter\n * specific fields when listing {@apilink Entry | Entries}:\n *\n * - Text fields can be filtered by a string query. This works just like\n * passing a `query` parameter, but it only applies to one field.\n * - Boolean fields can be filtered by \"true\" or \"false\".\n *\n * If a request uses this type, it means that this syntax can be used in their\n * parameters:\n *\n * ```ts\n * import Starlight from '@starlightcms/js-sdk'\n *\n * const response = await Starlight.posts.entries.list({\n * // EntrySelector.list() supports the \"field:foo\" syntax:\n * 'field:content': 'hello world',\n * 'field:is_featured': true,\n *\n * // EntrySelector.list() also support other parameters,\n * // which are passed in this object too:\n * page: 42,\n * limit: 20,\n * })\n * ```\n *\n * @remark\n *\n * The information below is only useful for SDK maintainers.\n *\n * This type receives a {@link SerializedData}-like structure, like an object.\n * For instance, for an {@link Entry} with fields \"content\" and \"summary\",\n * the generated type would look like this:\n *\n * ```ts\n * type GeneratedType = {\n * 'field:content'?: string\n * 'field:summary'?: string\n * }\n * ```\n *\n * However, note that QueryableFields receive a {@link SerializedData}, not an\n * {@link Entry}:\n *\n * ```ts\n * import { VisualField, StringField } from '@starlightcms/js-sdk'\n *\n * type EntryFields = {\n * content: VisualField\n * summary: StringField\n * }\n *\n * type MyEntry = Entry<EntryFields>\n *\n * // Error TS2344: Type does not satisfy the constraint 'SerializedData'\n * type GeneratedType = QueryableFields<MyEntry>\n *\n * // Works!\n * type GeneratedType = QueryableFields<EntryFields>\n * ```\n *\n * This type is only useful to request methods that support\n * field querying using the \"field:foo\" syntax.\n *\n * @category Internal Types\n */\nexport type QueryableFields<D extends SerializedData> = {\n [K in keyof D as `field:${string & K}`]?: string | boolean\n}\n\n/**\n * Utility type that return {@link QueryableFields} if the given type T\n * is an {@link Entry} or a {@link Singleton}, but generates an empty object\n * otherwise.\n *\n * Fun fact: internally, Entries and Singletons have parent Models,\n * which is why they are called \"modelables\" here.\n *\n * @category Internal Types\n */\nexport type WithQueryableFieldsOnModelables<T> = T extends\n | Entry<never>\n | Singleton<never>\n ? QueryableFields<T['data']>\n : never\n\n/**\n * Represents an Entry entity returned by the API.\n *\n * An Entry's `data` field can be further typed by passing an object-like\n * structure as the D generic type. This is useful to provide type-safety to\n * your application, since the `data` field is a generic JS object by default.\n *\n * It's recommended to use the Field types provided by this SDK to type your\n * entities using a type definition file on your project. For instance:\n *\n * ```ts\n * // starlight.d.ts file\n * import { VisualField, MediaField } from '@starlightcms/js-sdk'\n *\n * type PostFields = {\n * featured_image: MediaField\n * content: VisualField\n * }\n *\n * declare module '@starlightcms/js-sdk' {\n * export interface DefaultModelDefinition {\n * posts: PostFields\n * }\n * }\n * ```\n *\n * You can place this type definition file anywhere in your repository, but it's\n * good practice to place it at the same level as your root index.ts file. Then,\n * in your files, all SDK calls will correctly type `posts`:\n *\n * ```ts\n * import Starlight from '@starlightcms/js-sdk'\n *\n * // response type will be StarlightItemResponse<Entry<PostFields>> on request success\n * const response = await Starlight.posts.entries.get('hello-world')\n *\n * // helloWorld type is Entry<PostFields>\n * const helloWorld = response.data\n * ```\n *\n * See {@apilink DefaultModelDefinition} for more info.\n *\n * @group API Entities\n */\nexport interface Entry<D extends SerializedData>\n extends Omit<StarlightEntity, 'created_at'> {\n title: string\n slug: string\n data: D\n author: Author\n model?: Model\n category: ModelCategory | null\n published_at: string | null\n}\n\n/**\n * Represents a Singleton entity returned by the API.\n *\n * A Singleton's `data` field can be further typed by passing an object-like\n * structure as the D generic type. This is useful to provide type-safety to\n * your application, since the `data` field is a generic JS object by default.\n *\n * It's recommended to use the Field types provided by this SDK to type your\n * Singletons. For instance:\n *\n * ```ts\n * import { StringField, VisualField, MediaField } from '@starlightcms/js-sdk'\n *\n * type HomeFields = {\n * site_title: StringField\n * hero_image: MediaField\n * hero_content: VisualField\n * }\n *\n * // response type will be StarlightItemResponse<Singleton<HomeFields>> on request success\n * const response = Starlight.singletons.get<HomeFields>('home')\n *\n * // home type is Singleton<HomeFields>\n * const home = response.data\n * ```\n *\n * You could also place all your Singleton field types in the same type\n * definition file used to configure Entry fields, which makes it easier to\n * import these types in other files on your project. See\n * {@apilink DefaultModelDefinition} for more info.\n *\n * @group API Entities\n */\nexport interface Singleton<D extends SerializedData>\n extends Omit<StarlightEntity, 'created_at'> {\n title: string\n slug: string\n data: D\n published_at: string | null\n}\n\n/**\n * Currently supported Collection types. This type is mainly used to provide\n * autocompletion on IDEs, since it lets users use any string as well as the\n * known supported types.\n *\n * @internal\n */\nexport type CollectionTypes = 'entry' | 'singleton' | 'media' | string\n\n/**\n * Currently supported Collection entities. This type is mainly used to infer\n * the collection type string (see {@link CollectionTypes}) from the type of\n * entity that that Collection holds.\n *\n * @internal\n */\nexport type CollectionEntityTypes =\n | Entry<never>\n | Singleton<never>\n | MediaObject\n | unknown\n\n/**\n * Infers a Collection type from an entity type. See {@link CollectionTypes} and\n * {@link CollectionEntityTypes} to know more.\n *\n * @internal\n */\nexport type CollectionTypeMapper<T extends CollectionEntityTypes> =\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n T extends Entry<any>\n ? 'entry'\n : T extends Singleton<any> // eslint-disable-line @typescript-eslint/no-explicit-any\n ? 'singleton'\n : T extends MediaObject\n ? 'media'\n : string\n\n/**\n * Represents a Collection entity returned by the API.\n *\n * You can request collections using a {@link CollectionInstance} or a\n * {@link CollectionSelector}.\n *\n * @group API Entities\n */\nexport interface Collection<T extends CollectionTypes = string>\n extends StarlightEntity {\n title: string\n slug: string\n type: T\n item_count?: number\n}\n\n/**\n * Currently supported Relation types.\n */\ntype RelationTypes =\n | Entry<never>\n | Singleton<never>\n | MediaObject\n | Collection\n | unknown\n\n/**\n * Represents a Relation entity returned by the API.\n *\n * @group API Entities\n */\nexport interface Relation<T extends RelationTypes> {\n /**\n * The relation type, which is always a string. If the `object` field of this\n * Relation is an Entry, type will be `entry`, if it's a Singleton, type will\n * be `singleton`, and so on.\n */\n type: T extends Entry<never>\n ? 'entry'\n : T extends Singleton<never>\n ? 'singleton'\n : T extends MediaObject\n ? 'media'\n : T extends Collection\n ? 'collection'\n : string\n id: number\n object: T\n}\n"]}
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]: any\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 FieldGroup {\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: FieldGroup[]\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>\n extends Omit<StarlightEntity, 'created_at'> {\n title: string\n slug: string\n data: D\n author: Author\n model?: Model\n category: ModelCategory | null\n published_at: string | null\n}\n\n/**\n * Represents a Singleton entity returned by the API.\n *\n * A Singleton's `data` field can be further typed by passing an object-like\n * structure as the D generic type. This is useful to provide type-safety to\n * your application, since the `data` field is a generic JS object by default.\n *\n * It's recommended to use the Field types provided by this SDK to type your\n * Singletons. For instance:\n *\n * ```ts\n * import { StringField, VisualField, MediaField } from '@starlightcms/js-sdk'\n *\n * type HomeFields = {\n * site_title: StringField\n * hero_image: MediaField\n * hero_content: VisualField\n * }\n *\n * // response type will be StarlightItemResponse<Singleton<HomeFields>> on request success\n * const response = Starlight.singletons.get<HomeFields>('home')\n *\n * // home type is Singleton<HomeFields>\n * const home = response.data\n * ```\n *\n * You could also place all your Singleton field types in the same type\n * definition file used to configure Entry fields, which makes it easier to\n * import these types in other files on your project. See\n * {@apilink DefaultModelDefinition} for more info.\n *\n * @group API Entities\n */\nexport interface Singleton<D extends SerializedData>\n extends Omit<StarlightEntity, 'created_at'> {\n title: string\n slug: string\n data: D\n published_at: string | null\n}\n\n/**\n * Currently supported Collection types. This type is mainly used to provide\n * autocompletion on IDEs, since it lets users use any string as well as the\n * known supported types.\n *\n * @internal\n */\nexport type CollectionTypes = 'entry' | 'singleton' | 'media' | string\n\n/**\n * Currently supported Collection entities. This type is mainly used to infer\n * the collection type string (see {@link CollectionTypes}) from the type of\n * entity that that Collection holds.\n *\n * @internal\n */\nexport type CollectionEntityTypes =\n | Entry<never>\n | Singleton<never>\n | MediaObject\n | unknown\n\n/**\n * Infers a Collection type from an entity type. See {@link CollectionTypes} and\n * {@link CollectionEntityTypes} to know more.\n *\n * @internal\n */\nexport type CollectionTypeMapper<T extends CollectionEntityTypes> =\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n T extends Entry<any>\n ? 'entry'\n : T extends Singleton<any> // eslint-disable-line @typescript-eslint/no-explicit-any\n ? 'singleton'\n : T extends MediaObject\n ? 'media'\n : string\n\n/**\n * Represents a Collection entity returned by the API.\n *\n * You can request collections using a {@link CollectionInstance} or a\n * {@link CollectionSelector}.\n *\n * @group API Entities\n */\nexport interface Collection<T extends CollectionTypes = string>\n extends StarlightEntity {\n title: string\n slug: string\n type: T\n item_count?: number\n}\n\n/**\n * Currently supported Relation types.\n */\ntype RelationTypes =\n | Entry<never>\n | Singleton<never>\n | MediaObject\n | Collection\n | unknown\n\n/**\n * Represents a Relation entity returned by the API.\n *\n * @group API Entities\n */\nexport interface Relation<T extends RelationTypes> {\n /**\n * The relation type, which is always a string. If the `object` field of this\n * Relation is an Entry, type will be `entry`, if it's a Singleton, type will\n * be `singleton`, and so on.\n */\n type: T extends Entry<never>\n ? 'entry'\n : T extends Singleton<never>\n ? 'singleton'\n : T extends MediaObject\n ? 'media'\n : T extends Collection\n ? 'collection'\n : string\n id: number\n object: T\n}\n"]}
@@ -6,6 +6,8 @@ import { DynamicCollectionSelector } from '../selectors/Collection';
6
6
  import { MediaSelector } from '../selectors/Media';
7
7
  import { SearchSelector } from '../selectors/Search';
8
8
  import { CollectionInstance } from '../instances/Collection';
9
+ import { FormInstance } from '../instances/Form';
10
+ import { DynamicFormSelector } from '../selectors/Form/types';
9
11
  export * from './fields';
10
12
  export * from './entities';
11
13
  export * from './visual';
@@ -175,6 +177,39 @@ export interface StarlightClient<D extends WorkspaceModelDefinition = DefaultMod
175
177
  * @category Instance Methods
176
178
  */
177
179
  model<S extends keyof D>(slug: S): DynamicModelInstance<D[S]>;
180
+ /**
181
+ * Returns a {@link DynamicFormSelector}, which provides support for creating
182
+ * {@apilink FormInstance | FormInstances} using the dynamic syntax.
183
+ *
184
+ * This is an accessor, which means that it should be used just like a common
185
+ * object parameter. For instance:
186
+ *
187
+ * ```ts
188
+ * import Starlight from '@starlightcms/js-sdk'
189
+ *
190
+ * const response = await Starlight.forms.signup.get()
191
+ * ```
192
+ *
193
+ * See {@link DynamicFormSelector} for more info.
194
+ *
195
+ * @category Selector Accessors
196
+ */
197
+ get forms(): DynamicFormSelector;
198
+ /**
199
+ * Returns a {@link FormInstance}, which provides methods to retrieve basic information
200
+ * about a Starlight form and its schema. For instance:
201
+ *
202
+ * ```ts
203
+ * import Starlight from '@starlightcms/js-sdk'
204
+ *
205
+ * const response = await Starlight.form('signup').schema()
206
+ * ```
207
+ *
208
+ * See {@link DynamicFormInstance} for more info.
209
+ *
210
+ * @category Instance Methods
211
+ */
212
+ form(slug: string | number): FormInstance;
178
213
  /**
179
214
  * Returns a {@link SingletonSelector}.
180
215
  *
@@ -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;AAE5D,cAAc,UAAU,CAAA;AACxB,cAAc,YAAY,CAAA;AAC1B,cAAc,UAAU,CAAA;AACxB,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAE3B;;;;GAIG;AACH,oBAAY,OAA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;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":";;;;;;;;;;;;;;;;AASA,2CAAwB;AACxB,6CAA0B;AAC1B,2CAAwB;AACxB,8CAA2B;AAC3B,8CAA2B","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'\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 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-interface\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,2CAAwB;AACxB,6CAA0B;AAC1B,2CAAwB;AACxB,8CAA2B;AAC3B,8CAA2B","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 DynamicFormInstance} 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-interface\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"]}
@@ -4,7 +4,7 @@
4
4
  * @group Visual Data Blocks
5
5
  * @internal
6
6
  */
7
- export declare type BlockType = 'paragraph' | 'quote' | 'header' | 'image' | 'raw' | 'list';
7
+ export declare type BlockType = 'paragraph' | 'quote' | 'header' | 'image' | 'raw' | 'list' | 'video';
8
8
  /**
9
9
  * Base interface for types that represent block data.
10
10
  *
@@ -1 +1 @@
1
- {"version":3,"file":"visual.d.ts","sourceRoot":"","sources":["../../../src/types/visual.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,oBAAY,SAAS,GACjB,WAAW,GACX,OAAO,GACP,QAAQ,GACR,OAAO,GACP,KAAK,GACL,MAAM,CAAA;AAEV;;;;GAIG;AACH,MAAM,WAAW,SAAS;IACxB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CACvB;AAED;;;;;GAKG;AACH,MAAM,WAAW,cAAe,SAAQ,SAAS;IAC/C,IAAI,EAAE,MAAM,GAAG,IAAI,CAAA;CACpB;AAED;;;;GAIG;AACH,MAAM,WAAW,WAAY,SAAQ,SAAS;IAC5C,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,MAAM,CAAA;CACd;AAED;;;;GAIG;AACH,MAAM,WAAW,UAAW,SAAQ,SAAS;IAC3C,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,MAAM,CAAA;IACf,SAAS,EAAE,MAAM,GAAG,QAAQ,CAAA;CAC7B;AAED;;;;;GAKG;AACH,aAAK,UAAU,GAAG,MAAM,GAAG,SAAS,GAAG,KAAK,GAAG,MAAM,CAAA;AAErD;;;;;GAKG;AACH,oBAAY,SAAS,GAAG;IACtB,GAAG,EAAE,MAAM,CAAA;IACX,SAAS,EAAE,MAAM,CAAA;IACjB,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,MAAM,CAAA;CACf,CAAA;AAED;;;;GAIG;AACH,MAAM,WAAW,UAAW,SAAQ,SAAS;IAC3C,EAAE,EAAE,MAAM,GAAG,SAAS,CAAA;IACtB,GAAG,EAAE,MAAM,CAAA;IACX,KAAK,EAAE,SAAS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AAE,MAAM,GAAG,SAAS,CAAA;IAC7B,UAAU,EAAE,OAAO,CAAA;CACpB;AAED;;;;;GAKG;AACH,MAAM,WAAW,SAAU,SAAQ,SAAS;IAC1C,IAAI,EAAE,MAAM,CAAA;CACb;AAED;;;;;GAKG;AACH,MAAM,WAAW,QAAQ;IACvB,OAAO,EAAE,MAAM,CAAA;IACf,KAAK,CAAC,EAAE,QAAQ,EAAE,CAAA;CACnB;AAED;;;;GAIG;AACH,MAAM,WAAW,SAAU,SAAQ,SAAS;IAC1C,KAAK,EAAE,SAAS,GAAG,WAAW,CAAA;IAC9B,KAAK,EAAE,QAAQ,EAAE,CAAA;CAClB;AAED;;;;;GAKG;AACH,oBAAY,iBAAiB,GAAG,SAAS,GAAG,OAAO,CAAA;AAEnD;;;;GAIG;AACH,oBAAY,UAAU,GAAG;IACvB,IAAI,EAAE,OAAO,CAAA;IACb,OAAO,EAAE,iBAAiB,CAAA;IAC1B,OAAO,EAAE,MAAM,CAAA;IACf,GAAG,EAAE,MAAM,CAAA;IACX,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,UAAU,CAAA;IACjB,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB,CAAA;AAED;;;;;;GAMG;AACH,MAAM,WAAW,eAAe,CAAC,CAAC,SAAS,SAAS,GAAG,SAAS;IAC9D,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,SAAS,CAAA;IACf,IAAI,EAAE,CAAC,CAAA;CACR;AAED;;;;;;GAMG;AACH,MAAM,WAAW,UAAU;IACzB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,MAAM,EAAE,eAAe,EAAE,CAAA;CAC1B"}
@@ -1 +1 @@
1
- {"version":3,"file":"visual.js","sourceRoot":"","sources":["../../../src/types/visual.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * All supported block types.\n *\n * @group Visual Data Blocks\n * @internal\n */\nexport type BlockType =\n | 'paragraph'\n | 'quote'\n | 'header'\n | 'image'\n | 'raw'\n | 'list'\n\n/**\n * Base interface for types that represent block data.\n *\n * @group Visual Data Blocks\n */\nexport interface BlockData {\n [key: string]: unknown\n}\n\n/**\n * Represents a Paragraph block, which is the default block type used\n * for text content in the Visual Editor.\n *\n * @group Visual Data Blocks\n */\nexport interface ParagraphBlock extends BlockData {\n text: string | null\n}\n\n/**\n * Represents a Header block, which is used to render h1 through h6 HTML elements.\n *\n * @group Visual Data Blocks\n */\nexport interface HeaderBlock extends BlockData {\n text: string\n level: number\n}\n\n/**\n * Represents a Quote block, which is used to render a blockquote HTML element.\n *\n * @group Visual Data Blocks\n */\nexport interface QuoteBlock extends BlockData {\n text: string\n caption: string\n alignment: 'left' | 'center'\n}\n\n/**\n * Represents the possible block widths, used by some blocks.\n *\n * @group Visual Data Blocks\n * @internal\n */\ntype BlockWidth = 'auto' | 'justify' | 'max' | string\n\n/**\n * Represents an image file, used in Image blocks.\n *\n * @group Visual Data Blocks\n * @internal\n */\nexport type ImageFile = {\n url: string\n variation: string\n width: number\n height: number\n}\n\n/**\n * Represents an Image block, which is used to render img or picture HTML elements.\n *\n * @group Visual Data Blocks\n */\nexport interface ImageBlock extends BlockData {\n id: number | undefined\n url: string\n files: ImageFile[]\n caption?: string\n alt?: string\n href?: string\n width: BlockWidth\n variation: string | undefined\n responsive: boolean\n}\n\n/**\n * Represents an HTML block, which is used to render custom HTML code. Mainly\n * used to place embeds or heavily customized content structures.\n *\n * @group Visual Data Blocks\n */\nexport interface HTMLBlock extends BlockData {\n html: string\n}\n\n/**\n * Represents a list item, which is used by List blocks.\n *\n * @group Visual Data Blocks\n * @internal\n */\nexport interface ListItem {\n content: string\n items?: ListItem[]\n}\n\n/**\n * Represents a List block, which is used to render ol or ul HTML elements.\n *\n * @group Visual Data Blocks\n */\nexport interface ListBlock extends BlockData {\n style: 'ordered' | 'unordered'\n items: ListItem[]\n}\n\n/**\n * Represents the current supported video services, used in Video blocks.\n *\n * @group Visual Data Blocks\n * @internal\n */\nexport type SupportedServices = 'youtube' | 'vimeo'\n\n/**\n * Represents a Video block, which is used to render embed video elements.\n *\n * @group Visual Data Blocks\n */\nexport type VideoBlock = {\n type: 'embed'\n service: SupportedServices\n videoId: string\n url: string\n html: string\n width: BlockWidth\n caption?: string\n}\n\n/**\n * A VisualDataBlock object represents a piece of content. Each block has a\n * specific type and some data associated with it. For instance, a Paragraph\n * block has text data, an Image block has a file path and image metadata, etc.\n *\n * @group Visual Data Blocks\n */\nexport interface VisualDataBlock<D extends BlockData = BlockData> {\n id: string\n type: BlockType\n data: D\n}\n\n/**\n * VisualData represents content generated by Starlight using a \"Visual Editor\"\n * field. It's an object-based data representation made out of \"blocks\". Each\n * block has a type string and some data associated with it.\n *\n * @group Visual Data Blocks\n */\nexport interface VisualData {\n time?: number\n version?: string\n blocks: VisualDataBlock[]\n}\n"]}
1
+ {"version":3,"file":"visual.js","sourceRoot":"","sources":["../../../src/types/visual.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * All supported block types.\n *\n * @group Visual Data Blocks\n * @internal\n */\nexport type BlockType =\n | 'paragraph'\n | 'quote'\n | 'header'\n | 'image'\n | 'raw'\n | 'list'\n | 'video'\n\n/**\n * Base interface for types that represent block data.\n *\n * @group Visual Data Blocks\n */\nexport interface BlockData {\n [key: string]: unknown\n}\n\n/**\n * Represents a Paragraph block, which is the default block type used\n * for text content in the Visual Editor.\n *\n * @group Visual Data Blocks\n */\nexport interface ParagraphBlock extends BlockData {\n text: string | null\n}\n\n/**\n * Represents a Header block, which is used to render h1 through h6 HTML elements.\n *\n * @group Visual Data Blocks\n */\nexport interface HeaderBlock extends BlockData {\n text: string\n level: number\n}\n\n/**\n * Represents a Quote block, which is used to render a blockquote HTML element.\n *\n * @group Visual Data Blocks\n */\nexport interface QuoteBlock extends BlockData {\n text: string\n caption: string\n alignment: 'left' | 'center'\n}\n\n/**\n * Represents the possible block widths, used by some blocks.\n *\n * @group Visual Data Blocks\n * @internal\n */\ntype BlockWidth = 'auto' | 'justify' | 'max' | string\n\n/**\n * Represents an image file, used in Image blocks.\n *\n * @group Visual Data Blocks\n * @internal\n */\nexport type ImageFile = {\n url: string\n variation: string\n width: number\n height: number\n}\n\n/**\n * Represents an Image block, which is used to render img or picture HTML elements.\n *\n * @group Visual Data Blocks\n */\nexport interface ImageBlock extends BlockData {\n id: number | undefined\n url: string\n files: ImageFile[]\n caption?: string\n alt?: string\n href?: string\n width: BlockWidth\n variation: string | undefined\n responsive: boolean\n}\n\n/**\n * Represents an HTML block, which is used to render custom HTML code. Mainly\n * used to place embeds or heavily customized content structures.\n *\n * @group Visual Data Blocks\n */\nexport interface HTMLBlock extends BlockData {\n html: string\n}\n\n/**\n * Represents a list item, which is used by List blocks.\n *\n * @group Visual Data Blocks\n * @internal\n */\nexport interface ListItem {\n content: string\n items?: ListItem[]\n}\n\n/**\n * Represents a List block, which is used to render ol or ul HTML elements.\n *\n * @group Visual Data Blocks\n */\nexport interface ListBlock extends BlockData {\n style: 'ordered' | 'unordered'\n items: ListItem[]\n}\n\n/**\n * Represents the current supported video services, used in Video blocks.\n *\n * @group Visual Data Blocks\n * @internal\n */\nexport type SupportedServices = 'youtube' | 'vimeo'\n\n/**\n * Represents a Video block, which is used to render embed video elements.\n *\n * @group Visual Data Blocks\n */\nexport type VideoBlock = {\n type: 'embed'\n service: SupportedServices\n videoId: string\n url: string\n html: string\n width: BlockWidth\n caption?: string\n}\n\n/**\n * A VisualDataBlock object represents a piece of content. Each block has a\n * specific type and some data associated with it. For instance, a Paragraph\n * block has text data, an Image block has a file path and image metadata, etc.\n *\n * @group Visual Data Blocks\n */\nexport interface VisualDataBlock<D extends BlockData = BlockData> {\n id: string\n type: BlockType\n data: D\n}\n\n/**\n * VisualData represents content generated by Starlight using a \"Visual Editor\"\n * field. It's an object-based data representation made out of \"blocks\". Each\n * block has a type string and some data associated with it.\n *\n * @group Visual Data Blocks\n */\nexport interface VisualData {\n time?: number\n version?: string\n blocks: VisualDataBlock[]\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,sBAAsB,EACtB,sBAAsB,EAEtB,eAAe,EACf,wBAAwB,EACzB,MAAM,SAAS,CAAA;AAUhB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,wBAAgB,UAAU,CACxB,CAAC,SAAS,wBAAwB,GAAG,sBAAsB,EAE3D,MAAM,GAAE,eAAoB,GAC3B,sBAAsB,CAAC,CAAC,GAAG,wBAAwB,CAAC,CAwFtD"}
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,sBAAsB,EACtB,sBAAsB,EAEtB,eAAe,EACf,wBAAwB,EACzB,MAAM,SAAS,CAAA;AAYhB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,wBAAgB,UAAU,CACxB,CAAC,SAAS,wBAAwB,GAAG,sBAAsB,EAE3D,MAAM,GAAE,eAAoB,GAC3B,sBAAsB,CAAC,CAAC,GAAG,wBAAwB,CAAC,CAgGtD"}
@@ -15,6 +15,8 @@ import makeCollectionSelector from './selectors/Collection';
15
15
  import makeMediaSelector from './selectors/Media';
16
16
  import makeSearchSelector from './selectors/Search';
17
17
  import makeCollectionInstance from './instances/Collection';
18
+ import makeFormSelector from './selectors/Form';
19
+ import makeFormInstance from './instances/Form';
18
20
  /**
19
21
  * Returns a new {@link DynamicStarlightClient}, which is a
20
22
  * {@link StarlightClient} with support to create
@@ -103,6 +105,12 @@ export function makeClient(config = {}) {
103
105
  model(slug) {
104
106
  return makeModelInstance(this, slug);
105
107
  },
108
+ get forms() {
109
+ return makeFormSelector(this);
110
+ },
111
+ form(slug) {
112
+ return makeFormInstance(this, String(slug));
113
+ },
106
114
  get singletons() {
107
115
  return makeSingletonSelector(this);
108
116
  },