@starlightcms/js-sdk 0.9.0 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +54 -0
- package/dist/cjs/client.d.ts +41 -2
- package/dist/cjs/client.d.ts.map +1 -1
- package/dist/cjs/client.js +39 -0
- package/dist/cjs/client.js.map +1 -1
- package/dist/cjs/errors.d.ts +35 -0
- package/dist/cjs/errors.d.ts.map +1 -1
- package/dist/cjs/errors.js +7 -0
- package/dist/cjs/errors.js.map +1 -1
- package/dist/cjs/index.d.ts +22 -1
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +21 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/instances/Collection/index.d.ts +4 -4
- package/dist/cjs/instances/Collection/index.d.ts.map +1 -1
- package/dist/cjs/instances/Collection/index.js.map +1 -1
- package/dist/cjs/instances/Collection/types.d.ts +68 -12
- package/dist/cjs/instances/Collection/types.d.ts.map +1 -1
- package/dist/cjs/instances/Collection/types.js +1 -0
- package/dist/cjs/instances/Collection/types.js.map +1 -1
- package/dist/cjs/instances/Model/index.d.ts +3 -3
- package/dist/cjs/instances/Model/index.d.ts.map +1 -1
- package/dist/cjs/instances/Model/index.js.map +1 -1
- package/dist/cjs/instances/Model/types.d.ts +86 -3
- package/dist/cjs/instances/Model/types.d.ts.map +1 -1
- package/dist/cjs/instances/Model/types.js.map +1 -1
- package/dist/cjs/instances/ModelCategory/index.d.ts +2 -2
- package/dist/cjs/instances/ModelCategory/index.d.ts.map +1 -1
- package/dist/cjs/instances/ModelCategory/index.js.map +1 -1
- package/dist/cjs/instances/ModelCategory/types.d.ts +62 -10
- package/dist/cjs/instances/ModelCategory/types.d.ts.map +1 -1
- package/dist/cjs/instances/ModelCategory/types.js.map +1 -1
- package/dist/cjs/selectors/Collection/index.d.ts +3 -3
- package/dist/cjs/selectors/Collection/index.d.ts.map +1 -1
- package/dist/cjs/selectors/Collection/index.js +1 -1
- package/dist/cjs/selectors/Collection/index.js.map +1 -1
- package/dist/cjs/selectors/Collection/types.d.ts +84 -9
- package/dist/cjs/selectors/Collection/types.d.ts.map +1 -1
- package/dist/cjs/selectors/Collection/types.js.map +1 -1
- package/dist/cjs/selectors/Entry/types.d.ts +105 -10
- package/dist/cjs/selectors/Entry/types.d.ts.map +1 -1
- package/dist/cjs/selectors/Entry/types.js.map +1 -1
- package/dist/cjs/selectors/Media/index.js +2 -2
- package/dist/cjs/selectors/Media/index.js.map +1 -1
- package/dist/cjs/selectors/Media/types.d.ts +35 -1
- package/dist/cjs/selectors/Media/types.d.ts.map +1 -1
- package/dist/cjs/selectors/Media/types.js.map +1 -1
- package/dist/cjs/selectors/Model/index.d.ts +3 -3
- package/dist/cjs/selectors/Model/index.js.map +1 -1
- package/dist/cjs/selectors/Model/types.d.ts +62 -3
- package/dist/cjs/selectors/Model/types.d.ts.map +1 -1
- package/dist/cjs/selectors/Model/types.js.map +1 -1
- package/dist/cjs/selectors/ModelCategory/index.d.ts +3 -3
- package/dist/cjs/selectors/ModelCategory/index.js +1 -1
- package/dist/cjs/selectors/ModelCategory/index.js.map +1 -1
- package/dist/cjs/selectors/ModelCategory/types.d.ts +50 -7
- package/dist/cjs/selectors/ModelCategory/types.d.ts.map +1 -1
- package/dist/cjs/selectors/ModelCategory/types.js.map +1 -1
- package/dist/cjs/selectors/Search/index.d.ts +2 -2
- package/dist/cjs/selectors/Search/index.d.ts.map +1 -1
- package/dist/cjs/selectors/Search/index.js +1 -1
- package/dist/cjs/selectors/Search/index.js.map +1 -1
- package/dist/cjs/selectors/Search/types.d.ts +80 -7
- package/dist/cjs/selectors/Search/types.d.ts.map +1 -1
- package/dist/cjs/selectors/Search/types.js.map +1 -1
- package/dist/cjs/selectors/Singleton/types.d.ts +49 -0
- package/dist/cjs/selectors/Singleton/types.d.ts.map +1 -1
- package/dist/cjs/selectors/Singleton/types.js.map +1 -1
- package/dist/cjs/types/entities.d.ts +241 -2
- package/dist/cjs/types/entities.d.ts.map +1 -1
- package/dist/cjs/types/entities.js.map +1 -1
- package/dist/cjs/types/fields.d.ts +63 -0
- package/dist/cjs/types/fields.d.ts.map +1 -1
- package/dist/cjs/types/fields.js.map +1 -1
- package/dist/cjs/types/index.d.ts +514 -11
- package/dist/cjs/types/index.d.ts.map +1 -1
- package/dist/cjs/types/index.js +2 -0
- package/dist/cjs/types/index.js.map +1 -1
- package/dist/cjs/types/instances.d.ts +4 -0
- package/dist/cjs/types/instances.d.ts.map +1 -0
- package/dist/cjs/types/instances.js +3 -0
- package/dist/cjs/types/instances.js.map +1 -0
- package/dist/cjs/types/selectors.d.ts +8 -0
- package/dist/cjs/types/selectors.d.ts.map +1 -0
- package/dist/cjs/types/selectors.js +3 -0
- package/dist/cjs/types/selectors.js.map +1 -0
- package/dist/cjs/types/visual.d.ts +69 -0
- package/dist/cjs/types/visual.d.ts.map +1 -1
- package/dist/cjs/types/visual.js.map +1 -1
- package/dist/esm/client.d.ts +41 -2
- package/dist/esm/client.d.ts.map +1 -1
- package/dist/esm/client.js +39 -0
- package/dist/esm/client.js.map +1 -1
- package/dist/esm/errors.d.ts +35 -0
- package/dist/esm/errors.d.ts.map +1 -1
- package/dist/esm/errors.js +7 -0
- package/dist/esm/errors.js.map +1 -1
- package/dist/esm/index.d.ts +22 -1
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +21 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/instances/Collection/index.d.ts +4 -4
- package/dist/esm/instances/Collection/index.d.ts.map +1 -1
- package/dist/esm/instances/Collection/index.js.map +1 -1
- package/dist/esm/instances/Collection/types.d.ts +68 -12
- package/dist/esm/instances/Collection/types.d.ts.map +1 -1
- package/dist/esm/instances/Collection/types.js +1 -0
- package/dist/esm/instances/Collection/types.js.map +1 -1
- package/dist/esm/instances/Model/index.d.ts +3 -3
- package/dist/esm/instances/Model/index.d.ts.map +1 -1
- package/dist/esm/instances/Model/index.js.map +1 -1
- package/dist/esm/instances/Model/types.d.ts +86 -3
- package/dist/esm/instances/Model/types.d.ts.map +1 -1
- package/dist/esm/instances/Model/types.js.map +1 -1
- package/dist/esm/instances/ModelCategory/index.d.ts +2 -2
- package/dist/esm/instances/ModelCategory/index.d.ts.map +1 -1
- package/dist/esm/instances/ModelCategory/index.js.map +1 -1
- package/dist/esm/instances/ModelCategory/types.d.ts +62 -10
- package/dist/esm/instances/ModelCategory/types.d.ts.map +1 -1
- package/dist/esm/instances/ModelCategory/types.js.map +1 -1
- package/dist/esm/selectors/Collection/index.d.ts +3 -3
- package/dist/esm/selectors/Collection/index.d.ts.map +1 -1
- package/dist/esm/selectors/Collection/index.js +1 -1
- package/dist/esm/selectors/Collection/index.js.map +1 -1
- package/dist/esm/selectors/Collection/types.d.ts +84 -9
- package/dist/esm/selectors/Collection/types.d.ts.map +1 -1
- package/dist/esm/selectors/Collection/types.js.map +1 -1
- package/dist/esm/selectors/Entry/types.d.ts +105 -10
- package/dist/esm/selectors/Entry/types.d.ts.map +1 -1
- package/dist/esm/selectors/Entry/types.js.map +1 -1
- package/dist/esm/selectors/Media/index.js +2 -2
- package/dist/esm/selectors/Media/index.js.map +1 -1
- package/dist/esm/selectors/Media/types.d.ts +35 -1
- package/dist/esm/selectors/Media/types.d.ts.map +1 -1
- package/dist/esm/selectors/Media/types.js.map +1 -1
- package/dist/esm/selectors/Model/index.d.ts +3 -3
- package/dist/esm/selectors/Model/index.js.map +1 -1
- package/dist/esm/selectors/Model/types.d.ts +62 -3
- package/dist/esm/selectors/Model/types.d.ts.map +1 -1
- package/dist/esm/selectors/Model/types.js.map +1 -1
- package/dist/esm/selectors/ModelCategory/index.d.ts +3 -3
- package/dist/esm/selectors/ModelCategory/index.js +1 -1
- package/dist/esm/selectors/ModelCategory/index.js.map +1 -1
- package/dist/esm/selectors/ModelCategory/types.d.ts +50 -7
- package/dist/esm/selectors/ModelCategory/types.d.ts.map +1 -1
- package/dist/esm/selectors/ModelCategory/types.js.map +1 -1
- package/dist/esm/selectors/Search/index.d.ts +2 -2
- package/dist/esm/selectors/Search/index.d.ts.map +1 -1
- package/dist/esm/selectors/Search/index.js +1 -1
- package/dist/esm/selectors/Search/index.js.map +1 -1
- package/dist/esm/selectors/Search/types.d.ts +80 -7
- package/dist/esm/selectors/Search/types.d.ts.map +1 -1
- package/dist/esm/selectors/Search/types.js.map +1 -1
- package/dist/esm/selectors/Singleton/types.d.ts +49 -0
- package/dist/esm/selectors/Singleton/types.d.ts.map +1 -1
- package/dist/esm/selectors/Singleton/types.js.map +1 -1
- package/dist/esm/types/entities.d.ts +241 -2
- package/dist/esm/types/entities.d.ts.map +1 -1
- package/dist/esm/types/entities.js.map +1 -1
- package/dist/esm/types/fields.d.ts +63 -0
- package/dist/esm/types/fields.d.ts.map +1 -1
- package/dist/esm/types/fields.js.map +1 -1
- package/dist/esm/types/index.d.ts +514 -11
- package/dist/esm/types/index.d.ts.map +1 -1
- package/dist/esm/types/index.js +2 -0
- package/dist/esm/types/index.js.map +1 -1
- package/dist/esm/types/instances.d.ts +4 -0
- package/dist/esm/types/instances.d.ts.map +1 -0
- package/dist/esm/types/instances.js +2 -0
- package/dist/esm/types/instances.js.map +1 -0
- package/dist/esm/types/selectors.d.ts +8 -0
- package/dist/esm/types/selectors.d.ts.map +1 -0
- package/dist/esm/types/selectors.js +2 -0
- package/dist/esm/types/selectors.js.map +1 -0
- package/dist/esm/types/visual.d.ts +69 -0
- package/dist/esm/types/visual.d.ts.map +1 -1
- package/dist/esm/types/visual.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/selectors/Media/types.ts"],"names":[],"mappings":"","sourcesContent":["import {\n MediaObject,\n StarlightItemResponse,\n StarlightListResponse,\n} from '../../types'\n\nexport interface MediaSelector {\n get(
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/selectors/Media/types.ts"],"names":[],"mappings":"","sourcesContent":["import {\n MediaObject,\n StarlightItemResponse,\n StarlightListResponse,\n} from '../../types'\n\n/**\n * A Selector that provide methods to list and request information on\n * {@apilink MediaObject | MediaObjects}.\n *\n * You can use a MediaSelector by accessing\n * {@apilink StarlightClient.media}.\n *\n * @group Selectors\n */\nexport interface MediaSelector {\n /**\n * Returns a {@link StarlightItemResponse} with a single {@link MediaObject}.\n *\n * Note: MediaObjects are identified by their IDs, since they don't have slugs.\n *\n * @example Requesting information from a media object of id \"123456789\".\n * ```ts\n * import Starlight from '@starlightcms/js-sdk'\n *\n * const response = await Starlight.media.get('123456789')\n * ```\n *\n * @param id The media object ID.\n */\n get(id: number | string): Promise<StarlightItemResponse<MediaObject>>\n\n /**\n * Returns a {@link StarlightListResponse} with the list of\n * {@apilink MediaObject | MediaObjects} in this workspace.\n *\n * @example Requesting all media objects from the workspace.\n * ```ts\n * import Starlight from '@starlightcms/js-sdk'\n *\n * const response = await Starlight.media.list()\n * ```\n */\n list(): Promise<StarlightListResponse<MediaObject>>\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { StarlightClient, WorkspaceModelDefinition } from '../../types';
|
|
2
|
-
import { ModelSelector,
|
|
3
|
-
export default function makeModelSelector<D extends WorkspaceModelDefinition>(client: StarlightClient):
|
|
4
|
-
export { ModelSelector,
|
|
2
|
+
import { ModelSelector, DynamicModelSelector } from './types';
|
|
3
|
+
export default function makeModelSelector<D extends WorkspaceModelDefinition>(client: StarlightClient): DynamicModelSelector<D>;
|
|
4
|
+
export { ModelSelector, DynamicModelSelector };
|
|
5
5
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/selectors/Model/index.ts"],"names":[],"mappings":"AAQA,OAAO,iBAAiB,MAAM,uBAAuB,CAAA;AAErD,MAAM,CAAC,OAAO,UAAU,iBAAiB,CACvC,MAAuB;IAEvB,MAAM,WAAW,GAAkB;QACjC,IAAI;YACF,OAAO,MAAM,CAAC,GAAG,CAAC,SAAS,CAAC,CAAA;QAC9B,CAAC;QAED,GAAG,CAAC,IAAI;YACN,OAAO,MAAM,CAAC,GAAG,CAAC,WAAW,IAAI,EAAE,CAAC,CAAA;QACtC,CAAC;KACF,CAAA;IAED,OAAO,IAAI,KAAK,CAAC,WAAW,EAAE;QAC5B,GAAG,CAAC,MAAM,EAAE,IAAI;YACd,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,EAAE;gBAC1D,OAAO,iBAAiB,CAAC,MAAM,EAAE,IAAI,CAAC,CAAA;aACvC;YAED,OAAO,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,CAAA;QAClC,CAAC;KACF,CAA4B,CAAA;AAC/B,CAAC","sourcesContent":["import {\n Model,\n StarlightClient,\n StarlightItemResponse,\n StarlightListResponse,\n WorkspaceModelDefinition,\n} from '../../types'\nimport { ModelSelector,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/selectors/Model/index.ts"],"names":[],"mappings":"AAQA,OAAO,iBAAiB,MAAM,uBAAuB,CAAA;AAErD,MAAM,CAAC,OAAO,UAAU,iBAAiB,CACvC,MAAuB;IAEvB,MAAM,WAAW,GAAkB;QACjC,IAAI;YACF,OAAO,MAAM,CAAC,GAAG,CAAC,SAAS,CAAC,CAAA;QAC9B,CAAC;QAED,GAAG,CAAC,IAAI;YACN,OAAO,MAAM,CAAC,GAAG,CAAC,WAAW,IAAI,EAAE,CAAC,CAAA;QACtC,CAAC;KACF,CAAA;IAED,OAAO,IAAI,KAAK,CAAC,WAAW,EAAE;QAC5B,GAAG,CAAC,MAAM,EAAE,IAAI;YACd,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,EAAE;gBAC1D,OAAO,iBAAiB,CAAC,MAAM,EAAE,IAAI,CAAC,CAAA;aACvC;YAED,OAAO,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,CAAA;QAClC,CAAC;KACF,CAA4B,CAAA;AAC/B,CAAC","sourcesContent":["import {\n Model,\n StarlightClient,\n StarlightItemResponse,\n StarlightListResponse,\n WorkspaceModelDefinition,\n} from '../../types'\nimport { ModelSelector, DynamicModelSelector } from './types'\nimport makeModelInstance from '../../instances/Model'\n\nexport default function makeModelSelector<D extends WorkspaceModelDefinition>(\n client: StarlightClient\n): DynamicModelSelector<D> {\n const modelClient: ModelSelector = {\n list(): Promise<StarlightListResponse<Model>> {\n return client.get('/models')\n },\n\n get(slug): Promise<StarlightItemResponse<Model>> {\n return client.get(`/models/${slug}`)\n },\n }\n\n return new Proxy(modelClient, {\n get(target, prop) {\n if (typeof prop === 'string' && !Reflect.has(target, prop)) {\n return makeModelInstance(client, prop)\n }\n\n return Reflect.get(target, prop)\n },\n }) as DynamicModelSelector<D>\n}\n\nexport { ModelSelector, DynamicModelSelector }\n"]}
|
|
@@ -1,10 +1,69 @@
|
|
|
1
1
|
import { Model, StarlightItemResponse, StarlightListResponse, WorkspaceModelDefinition } from '../../types';
|
|
2
|
-
import {
|
|
2
|
+
import { DynamicModelInstance } from '../../instances/Model';
|
|
3
|
+
/**
|
|
4
|
+
* A Selector that provide methods to list and request information on
|
|
5
|
+
* {@apilink Model | Models}.
|
|
6
|
+
*
|
|
7
|
+
* You can use a ModelSelector by accessing
|
|
8
|
+
* {@apilink StarlightClient.models}.
|
|
9
|
+
*
|
|
10
|
+
* To list entries or categories of a specific model, use a
|
|
11
|
+
* {@link ModelInstance}.
|
|
12
|
+
*
|
|
13
|
+
* @group Selectors
|
|
14
|
+
*/
|
|
3
15
|
export interface ModelSelector {
|
|
16
|
+
/**
|
|
17
|
+
* Returns a {@link StarlightListResponse} with a list of
|
|
18
|
+
* {@apilink Model | Models}.
|
|
19
|
+
*
|
|
20
|
+
* @example Requesting all models from a workspace.
|
|
21
|
+
* ```ts
|
|
22
|
+
* import Starlight from '@starlightcms/js-sdk'
|
|
23
|
+
*
|
|
24
|
+
* const response = await Starlight.models.list()
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
4
27
|
list(): Promise<StarlightListResponse<Model>>;
|
|
28
|
+
/**
|
|
29
|
+
* Returns a {@link StarlightItemResponse} with a single {@link Model}.
|
|
30
|
+
*
|
|
31
|
+
* Note that this method only returns information on a model, like its title,
|
|
32
|
+
* slug, creation date, and entry count. If you want list its entries or
|
|
33
|
+
* categories, you need to use a {@link ModelInstance}.
|
|
34
|
+
*
|
|
35
|
+
* @example Requesting information from a model of slug "clients".
|
|
36
|
+
* ```ts
|
|
37
|
+
* import Starlight from '@starlightcms/js-sdk'
|
|
38
|
+
*
|
|
39
|
+
* const response = await Starlight.posts.entries.get('clients')
|
|
40
|
+
* ```
|
|
41
|
+
*
|
|
42
|
+
* @param slug The model slug.
|
|
43
|
+
*/
|
|
5
44
|
get(slug: string): Promise<StarlightItemResponse<Model>>;
|
|
6
45
|
}
|
|
7
|
-
|
|
8
|
-
|
|
46
|
+
/**
|
|
47
|
+
* A Selector that provide all {@link ModelSelector} methods and adds support
|
|
48
|
+
* for creating {@apilink DynamicModelInstance | DynamicModelInstances} using
|
|
49
|
+
* the dynamic syntax.
|
|
50
|
+
*
|
|
51
|
+
* See {@link ModelSelector} to view all available methods.
|
|
52
|
+
*
|
|
53
|
+
* See {@doclink requests-and-responses#dynamic-syntax | Dynamic Instances}
|
|
54
|
+
* documentation to learn more about the dynamic syntax.
|
|
55
|
+
*
|
|
56
|
+
* @example Accessing a DynamicModelInstance using the dynamic syntax.
|
|
57
|
+
* ```ts
|
|
58
|
+
* import Starlight from '@starlightcms/js-sdk'
|
|
59
|
+
*
|
|
60
|
+
* // "posts" below will be a DynamicModelInstance.
|
|
61
|
+
* const response = await Starlight.models.posts.entries.list()
|
|
62
|
+
* ```
|
|
63
|
+
*
|
|
64
|
+
* @category Selectors
|
|
65
|
+
*/
|
|
66
|
+
export declare type DynamicModelSelector<T extends WorkspaceModelDefinition> = ModelSelector & {
|
|
67
|
+
[K in keyof T]: DynamicModelInstance<T[K]>;
|
|
9
68
|
};
|
|
10
69
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/selectors/Model/types.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,EACL,qBAAqB,EACrB,qBAAqB,EACrB,wBAAwB,EACzB,MAAM,aAAa,CAAA;AACpB,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAA;AAE5D,MAAM,WAAW,aAAa;IAC5B,IAAI,IAAI,OAAO,CAAC,qBAAqB,CAAC,KAAK,CAAC,CAAC,CAAA;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/selectors/Model/types.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,EACL,qBAAqB,EACrB,qBAAqB,EACrB,wBAAwB,EACzB,MAAM,aAAa,CAAA;AACpB,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAA;AAE5D;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,aAAa;IAC5B;;;;;;;;;;OAUG;IACH,IAAI,IAAI,OAAO,CAAC,qBAAqB,CAAC,KAAK,CAAC,CAAC,CAAA;IAE7C;;;;;;;;;;;;;;;OAeG;IACH,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,qBAAqB,CAAC,KAAK,CAAC,CAAC,CAAA;CACzD;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,oBAAY,oBAAoB,CAAC,CAAC,SAAS,wBAAwB,IACjE,aAAa,GAAG;KACb,CAAC,IAAI,MAAM,CAAC,GAAG,oBAAoB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAC3C,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/selectors/Model/types.ts"],"names":[],"mappings":"","sourcesContent":["import {\n Model,\n StarlightItemResponse,\n StarlightListResponse,\n WorkspaceModelDefinition,\n} from '../../types'\nimport {
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/selectors/Model/types.ts"],"names":[],"mappings":"","sourcesContent":["import {\n Model,\n StarlightItemResponse,\n StarlightListResponse,\n WorkspaceModelDefinition,\n} from '../../types'\nimport { DynamicModelInstance } from '../../instances/Model'\n\n/**\n * A Selector that provide methods to list and request information on\n * {@apilink Model | Models}.\n *\n * You can use a ModelSelector by accessing\n * {@apilink StarlightClient.models}.\n *\n * To list entries or categories of a specific model, use a\n * {@link ModelInstance}.\n *\n * @group Selectors\n */\nexport interface ModelSelector {\n /**\n * Returns a {@link StarlightListResponse} with a list of\n * {@apilink Model | Models}.\n *\n * @example Requesting all models from a workspace.\n * ```ts\n * import Starlight from '@starlightcms/js-sdk'\n *\n * const response = await Starlight.models.list()\n * ```\n */\n list(): Promise<StarlightListResponse<Model>>\n\n /**\n * Returns a {@link StarlightItemResponse} with a single {@link Model}.\n *\n * Note that this method only returns information on a model, like its title,\n * slug, creation date, and entry count. If you want list its entries or\n * categories, you need to use a {@link ModelInstance}.\n *\n * @example Requesting information from a model of slug \"clients\".\n * ```ts\n * import Starlight from '@starlightcms/js-sdk'\n *\n * const response = await Starlight.posts.entries.get('clients')\n * ```\n *\n * @param slug The model slug.\n */\n get(slug: string): Promise<StarlightItemResponse<Model>>\n}\n\n/**\n * A Selector that provide all {@link ModelSelector} methods and adds support\n * for creating {@apilink DynamicModelInstance | DynamicModelInstances} using\n * the dynamic syntax.\n *\n * See {@link ModelSelector} to view all available methods.\n *\n * See {@doclink requests-and-responses#dynamic-syntax | Dynamic Instances}\n * documentation to learn more about the dynamic syntax.\n *\n * @example Accessing a DynamicModelInstance using the dynamic syntax.\n * ```ts\n * import Starlight from '@starlightcms/js-sdk'\n *\n * // \"posts\" below will be a DynamicModelInstance.\n * const response = await Starlight.models.posts.entries.list()\n * ```\n *\n * @category Selectors\n */\nexport type DynamicModelSelector<T extends WorkspaceModelDefinition> =\n ModelSelector & {\n [K in keyof T]: DynamicModelInstance<T[K]>\n }\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SerializedData, StarlightClient } from '../../types';
|
|
2
|
-
import { ModelCategorySelector,
|
|
3
|
-
export default function makeModelCategorySelector<D extends SerializedData>(client: StarlightClient, model: string):
|
|
4
|
-
export { ModelCategorySelector,
|
|
2
|
+
import { ModelCategorySelector, DynamicModelCategorySelector } from './types';
|
|
3
|
+
export default function makeModelCategorySelector<D extends SerializedData>(client: StarlightClient, model: string): DynamicModelCategorySelector<D>;
|
|
4
|
+
export { ModelCategorySelector, DynamicModelCategorySelector };
|
|
5
5
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -2,7 +2,7 @@ import makeModelCategoryInstance from '../../instances/ModelCategory';
|
|
|
2
2
|
export default function makeModelCategorySelector(client, model) {
|
|
3
3
|
const selector = {
|
|
4
4
|
list(options) {
|
|
5
|
-
return client.get(`/models/${model}/categories`, options);
|
|
5
|
+
return client.get(`/models/${model}/categories`, Object.assign({}, options));
|
|
6
6
|
},
|
|
7
7
|
get(slug) {
|
|
8
8
|
return client.get(`/models/${model}/categories/${slug}`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/selectors/ModelCategory/index.ts"],"names":[],"mappings":"AAQA,OAAO,yBAAyB,MAAM,+BAA+B,CAAA;AAErE,MAAM,CAAC,OAAO,UAAU,yBAAyB,CAC/C,MAAuB,EACvB,KAAa;IAEb,MAAM,QAAQ,GAA0B;QACtC,IAAI,CAAC,OAAO;YACV,OAAO,MAAM,CAAC,GAAG,CAAC,WAAW,KAAK,aAAa,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/selectors/ModelCategory/index.ts"],"names":[],"mappings":"AAQA,OAAO,yBAAyB,MAAM,+BAA+B,CAAA;AAErE,MAAM,CAAC,OAAO,UAAU,yBAAyB,CAC/C,MAAuB,EACvB,KAAa;IAEb,MAAM,QAAQ,GAA0B;QACtC,IAAI,CAAC,OAAO;YACV,OAAO,MAAM,CAAC,GAAG,CAAC,WAAW,KAAK,aAAa,oBAAO,OAAO,EAAG,CAAA;QAClE,CAAC;QAED,GAAG,CAAC,IAAI;YACN,OAAO,MAAM,CAAC,GAAG,CAAC,WAAW,KAAK,eAAe,IAAI,EAAE,CAAC,CAAA;QAC1D,CAAC;KACF,CAAA;IAED,OAAO,IAAI,KAAK,CAAC,QAAQ,EAAE;QACzB,GAAG,CAAC,MAAM,EAAE,IAAI;YACd,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,EAAE;gBAC1D,OAAO,yBAAyB,CAAC,MAAM,EAAE,KAAK,EAAE,IAAI,CAAC,CAAA;aACtD;YAED,OAAO,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,CAAA;QAClC,CAAC;KACF,CAAoC,CAAA;AACvC,CAAC","sourcesContent":["import {\n ModelCategory,\n SerializedData,\n StarlightClient,\n StarlightItemResponse,\n StarlightListResponse,\n} from '../../types'\nimport { ModelCategorySelector, DynamicModelCategorySelector } from './types'\nimport makeModelCategoryInstance from '../../instances/ModelCategory'\n\nexport default function makeModelCategorySelector<D extends SerializedData>(\n client: StarlightClient,\n model: string\n): DynamicModelCategorySelector<D> {\n const selector: ModelCategorySelector = {\n list(options): Promise<StarlightListResponse<ModelCategory>> {\n return client.get(`/models/${model}/categories`, { ...options })\n },\n\n get(slug): Promise<StarlightItemResponse<ModelCategory>> {\n return client.get(`/models/${model}/categories/${slug}`)\n },\n }\n\n return new Proxy(selector, {\n get(target, prop) {\n if (typeof prop === 'string' && !Reflect.has(target, prop)) {\n return makeModelCategoryInstance(client, model, prop)\n }\n\n return Reflect.get(target, prop)\n },\n }) as DynamicModelCategorySelector<D>\n}\n\nexport { ModelCategorySelector, DynamicModelCategorySelector }\n"]}
|
|
@@ -1,16 +1,59 @@
|
|
|
1
|
-
import { ModelCategory, SerializedData, StarlightItemResponse, StarlightListResponse } from '../../types';
|
|
1
|
+
import { BaseRequestParameters, ModelCategory, SerializedData, StarlightItemResponse, StarlightListResponse } from '../../types';
|
|
2
2
|
import { ModelCategoryInstance } from '../../instances/ModelCategory';
|
|
3
|
-
export
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
export interface ListModelCategoriesOptions extends BaseRequestParameters {
|
|
4
|
+
/**
|
|
5
|
+
* Define how items will be ordered. Check this field type to see the
|
|
6
|
+
* allowed options.
|
|
7
|
+
*/
|
|
7
8
|
order?: 'title:asc' | 'title:desc' | 'entry_count:asc' | 'entry_count:desc';
|
|
8
|
-
}
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* A Selector that provide methods to list and request information on
|
|
12
|
+
* {@apilink ModelCategory | ModelCategories}.
|
|
13
|
+
*
|
|
14
|
+
* You can use a ModelCategorySelector by accessing
|
|
15
|
+
* {@apilink ModelInstance.categories}.
|
|
16
|
+
*
|
|
17
|
+
* @group Selectors
|
|
18
|
+
*/
|
|
9
19
|
export interface ModelCategorySelector {
|
|
10
20
|
list(options?: ListModelCategoriesOptions): Promise<StarlightListResponse<ModelCategory>>;
|
|
21
|
+
/**
|
|
22
|
+
* Returns a {@link StarlightItemResponse} with a single {@link ModelCategory}.
|
|
23
|
+
*
|
|
24
|
+
* @example Requesting information from a category "premium" from a model of slug "plans".
|
|
25
|
+
* ```ts
|
|
26
|
+
* import Starlight from '@starlightcms/js-sdk'
|
|
27
|
+
*
|
|
28
|
+
* const response = await Starlight.plans.premium.get()
|
|
29
|
+
* ```
|
|
30
|
+
*
|
|
31
|
+
* @param slug The category slug.
|
|
32
|
+
*/
|
|
11
33
|
get(slug: string): Promise<StarlightItemResponse<ModelCategory>>;
|
|
12
34
|
}
|
|
13
|
-
|
|
35
|
+
/**
|
|
36
|
+
* A Selector that provide all {@link ModelCategorySelector} methods and adds
|
|
37
|
+
* support for creating {@apilink ModelCategoryInstance | ModelCategoryInstances}
|
|
38
|
+
* using the dynamic syntax.
|
|
39
|
+
*
|
|
40
|
+
* See {@link ModelCategorySelector} to view all available methods. You can use
|
|
41
|
+
* a DynamicModelCategorySelector by accessing {@apilink ModelInstance.categories}.
|
|
42
|
+
*
|
|
43
|
+
* See {@doclink requests-and-responses#dynamic-syntax | Dynamic Instances}
|
|
44
|
+
* documentation to learn more about the dynamic syntax.
|
|
45
|
+
*
|
|
46
|
+
* @example Accessing a ModelCategorySelector using the dynamic syntax on a model of slug "posts"
|
|
47
|
+
* ```ts
|
|
48
|
+
* import Starlight from '@starlightcms/js-sdk'
|
|
49
|
+
*
|
|
50
|
+
* // "articles" below will be a ModelCategorySelector.
|
|
51
|
+
* const response = await Starlight.posts.categories.articles.list()
|
|
52
|
+
* ```
|
|
53
|
+
*
|
|
54
|
+
* @category Instances
|
|
55
|
+
*/
|
|
56
|
+
export declare type DynamicModelCategorySelector<D extends SerializedData> = ModelCategorySelector & {
|
|
14
57
|
[slug: string]: ModelCategoryInstance<D>;
|
|
15
58
|
};
|
|
16
59
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/selectors/ModelCategory/types.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,cAAc,EACd,qBAAqB,EACrB,qBAAqB,EACtB,MAAM,aAAa,CAAA;AACpB,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAA;AAErE,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/selectors/ModelCategory/types.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,EACrB,aAAa,EACb,cAAc,EACd,qBAAqB,EACrB,qBAAqB,EACtB,MAAM,aAAa,CAAA;AACpB,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAA;AAErE,MAAM,WAAW,0BAA2B,SAAQ,qBAAqB;IACvE;;;OAGG;IACH,KAAK,CAAC,EAAE,WAAW,GAAG,YAAY,GAAG,iBAAiB,GAAG,kBAAkB,CAAA;CAC5E;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,qBAAqB;IACpC,IAAI,CACF,OAAO,CAAC,EAAE,0BAA0B,GACnC,OAAO,CAAC,qBAAqB,CAAC,aAAa,CAAC,CAAC,CAAA;IAEhD;;;;;;;;;;;OAWG;IACH,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,qBAAqB,CAAC,aAAa,CAAC,CAAC,CAAA;CACjE;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,oBAAY,4BAA4B,CAAC,CAAC,SAAS,cAAc,IAC/D,qBAAqB,GAAG;IACtB,CAAC,IAAI,EAAE,MAAM,GAAG,qBAAqB,CAAC,CAAC,CAAC,CAAA;CACzC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/selectors/ModelCategory/types.ts"],"names":[],"mappings":"","sourcesContent":["import {\n ModelCategory,\n SerializedData,\n StarlightItemResponse,\n StarlightListResponse,\n} from '../../types'\nimport { ModelCategoryInstance } from '../../instances/ModelCategory'\n\nexport
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/selectors/ModelCategory/types.ts"],"names":[],"mappings":"","sourcesContent":["import {\n BaseRequestParameters,\n ModelCategory,\n SerializedData,\n StarlightItemResponse,\n StarlightListResponse,\n} from '../../types'\nimport { ModelCategoryInstance } from '../../instances/ModelCategory'\n\nexport interface ListModelCategoriesOptions extends BaseRequestParameters {\n /**\n * Define how items will be ordered. Check this field type to see the\n * allowed options.\n */\n order?: 'title:asc' | 'title:desc' | 'entry_count:asc' | 'entry_count:desc'\n}\n\n/**\n * A Selector that provide methods to list and request information on\n * {@apilink ModelCategory | ModelCategories}.\n *\n * You can use a ModelCategorySelector by accessing\n * {@apilink ModelInstance.categories}.\n *\n * @group Selectors\n */\nexport interface ModelCategorySelector {\n list(\n options?: ListModelCategoriesOptions\n ): Promise<StarlightListResponse<ModelCategory>>\n\n /**\n * Returns a {@link StarlightItemResponse} with a single {@link ModelCategory}.\n *\n * @example Requesting information from a category \"premium\" from a model of slug \"plans\".\n * ```ts\n * import Starlight from '@starlightcms/js-sdk'\n *\n * const response = await Starlight.plans.premium.get()\n * ```\n *\n * @param slug The category slug.\n */\n get(slug: string): Promise<StarlightItemResponse<ModelCategory>>\n}\n\n/**\n * A Selector that provide all {@link ModelCategorySelector} methods and adds\n * support for creating {@apilink ModelCategoryInstance | ModelCategoryInstances}\n * using the dynamic syntax.\n *\n * See {@link ModelCategorySelector} to view all available methods. You can use\n * a DynamicModelCategorySelector by accessing {@apilink ModelInstance.categories}.\n *\n * See {@doclink requests-and-responses#dynamic-syntax | Dynamic Instances}\n * documentation to learn more about the dynamic syntax.\n *\n * @example Accessing a ModelCategorySelector using the dynamic syntax on a model of slug \"posts\"\n * ```ts\n * import Starlight from '@starlightcms/js-sdk'\n *\n * // \"articles\" below will be a ModelCategorySelector.\n * const response = await Starlight.posts.categories.articles.list()\n * ```\n *\n * @category Instances\n */\nexport type DynamicModelCategorySelector<D extends SerializedData> =\n ModelCategorySelector & {\n [slug: string]: ModelCategoryInstance<D>\n }\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { StarlightClient } from '../../types';
|
|
2
|
-
import { SearchSelector } from './types';
|
|
2
|
+
import { SearchEntriesParams, SearchSelector } from './types';
|
|
3
3
|
export default function makeSearchSelector(client: StarlightClient): SearchSelector;
|
|
4
|
-
export { SearchSelector };
|
|
4
|
+
export { SearchSelector, SearchEntriesParams };
|
|
5
5
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/selectors/Search/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,eAAe,EAEhB,MAAM,aAAa,CAAA;AACpB,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/selectors/Search/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,eAAe,EAEhB,MAAM,aAAa,CAAA;AACpB,OAAO,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAE7D,MAAM,CAAC,OAAO,UAAU,kBAAkB,CACxC,MAAM,EAAE,eAAe,GACtB,cAAc,CAQhB;AAED,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/selectors/Search/index.ts"],"names":[],"mappings":"AAQA,MAAM,CAAC,OAAO,UAAU,kBAAkB,CACxC,MAAuB;IAEvB,OAAO;QACL,OAAO,CACL,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/selectors/Search/index.ts"],"names":[],"mappings":"AAQA,MAAM,CAAC,OAAO,UAAU,kBAAkB,CACxC,MAAuB;IAEvB,OAAO;QACL,OAAO,CACL,OAA4B;YAE5B,OAAO,MAAM,CAAC,GAAG,CAAC,iBAAiB,oBAAO,OAAO,EAAG,CAAA;QACtD,CAAC;KACF,CAAA;AACH,CAAC","sourcesContent":["import {\n Entry,\n SerializedData,\n StarlightClient,\n StarlightListResponse,\n} from '../../types'\nimport { SearchEntriesParams, SearchSelector } from './types'\n\nexport default function makeSearchSelector(\n client: StarlightClient\n): SearchSelector {\n return {\n entries<T extends SerializedData = Record<string, unknown>>(\n options: SearchEntriesParams\n ): Promise<StarlightListResponse<Entry<T>>> {\n return client.get('/search/entries', { ...options })\n },\n }\n}\n\nexport { SearchSelector, SearchEntriesParams }\n"]}
|
|
@@ -1,14 +1,87 @@
|
|
|
1
|
-
import { Entry, SerializedData, StarlightListResponse } from '../../types';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { BaseRequestParameters, Entry, SerializedData, StarlightListResponse } from '../../types';
|
|
2
|
+
/**
|
|
3
|
+
* Request parameters for searching entries.
|
|
4
|
+
*
|
|
5
|
+
* Used by {@apilink SearchSelector.entries}.
|
|
6
|
+
*
|
|
7
|
+
* @group Request Parameters
|
|
8
|
+
*/
|
|
9
|
+
export interface SearchEntriesParams extends BaseRequestParameters {
|
|
10
|
+
/**
|
|
11
|
+
* A comma-separated list of models. Only entries in these models
|
|
12
|
+
* will be returned. If undefined, entries from all
|
|
13
|
+
* workspace models will be listed.
|
|
14
|
+
*
|
|
15
|
+
* For instance, to show only entries in the "posts" and "videos" categories,
|
|
16
|
+
* pass `'posts,videos'`.
|
|
17
|
+
*/
|
|
6
18
|
models?: string;
|
|
19
|
+
/**
|
|
20
|
+
* A comma-separated list of categories. Only entries in these categories
|
|
21
|
+
* will be returned. If undefined, all entries will be listed, independently
|
|
22
|
+
* of their categories.
|
|
23
|
+
*
|
|
24
|
+
* For instance, to show only entries in the "news" and "articles" categories,
|
|
25
|
+
* pass `'news,category'`.
|
|
26
|
+
*/
|
|
7
27
|
categories?: string;
|
|
28
|
+
/**
|
|
29
|
+
* Define how items will be ordered. Check this field type to see the
|
|
30
|
+
* allowed options.
|
|
31
|
+
*/
|
|
8
32
|
order?: 'title:asc' | 'title:desc' | 'published_at:asc' | 'published_at:desc' | 'updated_at:asc' | 'updated_at:desc';
|
|
33
|
+
/**
|
|
34
|
+
* If defined, removes the given item from the list. Useful to create "related
|
|
35
|
+
* posts" lists.
|
|
36
|
+
*
|
|
37
|
+
* Note: this field only accepts IDs, and not slugs. Only one ID is allowed.
|
|
38
|
+
*/
|
|
9
39
|
except?: number;
|
|
10
|
-
}
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* A Selector that provide methods to search for content. Only entry search
|
|
43
|
+
* is supported for the time being.
|
|
44
|
+
*
|
|
45
|
+
* You can use a SearchSelector by accessing
|
|
46
|
+
* {@apilink StarlightClient.search}.
|
|
47
|
+
*
|
|
48
|
+
* @group Selectors
|
|
49
|
+
*/
|
|
11
50
|
export interface SearchSelector {
|
|
12
|
-
|
|
51
|
+
/**
|
|
52
|
+
* Returns a {@link StarlightListResponse} with a list of
|
|
53
|
+
* {@apilink Entry | Entries}. By default, entries from all models are
|
|
54
|
+
* returned, but filtering by model can be configured.
|
|
55
|
+
*
|
|
56
|
+
* @example Listing all entries in all workspace models.
|
|
57
|
+
* ```ts
|
|
58
|
+
* import Starlight from '@starlightcms/js-sdk'
|
|
59
|
+
*
|
|
60
|
+
* const response = await Starlight.search.entries()
|
|
61
|
+
* ```
|
|
62
|
+
*
|
|
63
|
+
* @example Searching for "hello world" within all entries in all workspace models.
|
|
64
|
+
* ```ts
|
|
65
|
+
* import Starlight from '@starlightcms/js-sdk'
|
|
66
|
+
*
|
|
67
|
+
* const response = await Starlight.search.entries({
|
|
68
|
+
* query: 'hello world'
|
|
69
|
+
* })
|
|
70
|
+
* ```
|
|
71
|
+
*
|
|
72
|
+
* @example Filtering the last example within specific models.
|
|
73
|
+
* ```ts
|
|
74
|
+
* import Starlight from '@starlightcms/js-sdk'
|
|
75
|
+
*
|
|
76
|
+
* const response = await Starlight.search.entries({
|
|
77
|
+
* query: 'hello world',
|
|
78
|
+
* models: 'posts,videos,magazines'
|
|
79
|
+
* })
|
|
80
|
+
* ```
|
|
81
|
+
*
|
|
82
|
+
* @param options An optional object of request parameters. See
|
|
83
|
+
* {@link SearchEntriesParams} for all available options.
|
|
84
|
+
*/
|
|
85
|
+
entries<T extends SerializedData = Record<string, unknown>>(options?: SearchEntriesParams): Promise<StarlightListResponse<Entry<T>>>;
|
|
13
86
|
}
|
|
14
87
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/selectors/Search/types.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/selectors/Search/types.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,EACrB,KAAK,EACL,cAAc,EACd,qBAAqB,EACtB,MAAM,aAAa,CAAA;AAEpB;;;;;;GAMG;AACH,MAAM,WAAW,mBAAoB,SAAQ,qBAAqB;IAChE;;;;;;;OAOG;IACH,MAAM,CAAC,EAAE,MAAM,CAAA;IACf;;;;;;;OAOG;IACH,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB;;;OAGG;IACH,KAAK,CAAC,EACF,WAAW,GACX,YAAY,GACZ,kBAAkB,GAClB,mBAAmB,GACnB,gBAAgB,GAChB,iBAAiB,CAAA;IACrB;;;;;OAKG;IACH,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,cAAc;IAC7B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAiCG;IACH,OAAO,CAAC,CAAC,SAAS,cAAc,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACxD,OAAO,CAAC,EAAE,mBAAmB,GAC5B,OAAO,CAAC,qBAAqB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;CAC5C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/selectors/Search/types.ts"],"names":[],"mappings":"","sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/selectors/Search/types.ts"],"names":[],"mappings":"","sourcesContent":["import {\n BaseRequestParameters,\n Entry,\n SerializedData,\n StarlightListResponse,\n} from '../../types'\n\n/**\n * Request parameters for searching entries.\n *\n * Used by {@apilink SearchSelector.entries}.\n *\n * @group Request Parameters\n */\nexport interface SearchEntriesParams extends BaseRequestParameters {\n /**\n * A comma-separated list of models. Only entries in these models\n * will be returned. If undefined, entries from all\n * workspace models will be listed.\n *\n * For instance, to show only entries in the \"posts\" and \"videos\" categories,\n * pass `'posts,videos'`.\n */\n models?: string\n /**\n * A comma-separated list of categories. Only entries in these categories\n * will be returned. If undefined, all entries will be listed, independently\n * of their categories.\n *\n * For instance, to show only entries in the \"news\" and \"articles\" categories,\n * pass `'news,category'`.\n */\n categories?: string\n /**\n * Define how items will be ordered. Check this field type to see the\n * allowed options.\n */\n order?:\n | 'title:asc'\n | 'title:desc'\n | 'published_at:asc'\n | 'published_at:desc'\n | 'updated_at:asc'\n | 'updated_at:desc'\n /**\n * If defined, removes the given item from the list. Useful to create \"related\n * posts\" lists.\n *\n * Note: this field only accepts IDs, and not slugs. Only one ID is allowed.\n */\n except?: number\n}\n\n/**\n * A Selector that provide methods to search for content. Only entry search\n * is supported for the time being.\n *\n * You can use a SearchSelector by accessing\n * {@apilink StarlightClient.search}.\n *\n * @group Selectors\n */\nexport interface SearchSelector {\n /**\n * Returns a {@link StarlightListResponse} with a list of\n * {@apilink Entry | Entries}. By default, entries from all models are\n * returned, but filtering by model can be configured.\n *\n * @example Listing all entries in all workspace models.\n * ```ts\n * import Starlight from '@starlightcms/js-sdk'\n *\n * const response = await Starlight.search.entries()\n * ```\n *\n * @example Searching for \"hello world\" within all entries in all workspace models.\n * ```ts\n * import Starlight from '@starlightcms/js-sdk'\n *\n * const response = await Starlight.search.entries({\n * query: 'hello world'\n * })\n * ```\n *\n * @example Filtering the last example within specific models.\n * ```ts\n * import Starlight from '@starlightcms/js-sdk'\n *\n * const response = await Starlight.search.entries({\n * query: 'hello world',\n * models: 'posts,videos,magazines'\n * })\n * ```\n *\n * @param options An optional object of request parameters. See\n * {@link SearchEntriesParams} for all available options.\n */\n entries<T extends SerializedData = Record<string, unknown>>(\n options?: SearchEntriesParams\n ): Promise<StarlightListResponse<Entry<T>>>\n}\n"]}
|
|
@@ -1,6 +1,55 @@
|
|
|
1
1
|
import { SerializedData, Singleton, StarlightItemResponse, StarlightListResponse } from '../../types';
|
|
2
|
+
/**
|
|
3
|
+
* A Selector that provide methods to list and request information on
|
|
4
|
+
* {@apilink Singleton | Singletons}.
|
|
5
|
+
*
|
|
6
|
+
* You can use an SingletonSelector by accessing
|
|
7
|
+
* {@apilink ModelInstance.singletons}.
|
|
8
|
+
*
|
|
9
|
+
* @group Selectors
|
|
10
|
+
*/
|
|
2
11
|
export interface SingletonSelector {
|
|
12
|
+
/**
|
|
13
|
+
* Returns a {@link StarlightItemResponse} with a single {@link Singleton}.
|
|
14
|
+
* This methods supports typing the returned Singleton by passing its data
|
|
15
|
+
* type as the generic type `<D>`.
|
|
16
|
+
*
|
|
17
|
+
* @example Requesting information from a singleton of slug "home".
|
|
18
|
+
* ```ts
|
|
19
|
+
* import Starlight from '@starlightcms/js-sdk'
|
|
20
|
+
*
|
|
21
|
+
* const response = await Starlight.singletons.get('home')
|
|
22
|
+
* ```
|
|
23
|
+
*
|
|
24
|
+
* @example Typing last example's response.
|
|
25
|
+
* ```ts
|
|
26
|
+
* import Starlight, { StringField, MediaField, VisualField } from '@starlightcms/js-sdk'
|
|
27
|
+
*
|
|
28
|
+
* type HomeFields = {
|
|
29
|
+
* title: StringField
|
|
30
|
+
* subtitle: StringField
|
|
31
|
+
* hero_image: MediaField
|
|
32
|
+
* hero_content: VisualField
|
|
33
|
+
* }
|
|
34
|
+
*
|
|
35
|
+
* // `response.data` will be of type Singleton<HomeFields>
|
|
36
|
+
* const response = await Starlight.singletons.get<HomeFields>('home')
|
|
37
|
+
* ```
|
|
38
|
+
* @typeParam D - The type of the returned Singleton's `data` property.
|
|
39
|
+
* @param slug The singleton slug.
|
|
40
|
+
*/
|
|
3
41
|
get<D extends SerializedData>(slug: string): Promise<StarlightItemResponse<Singleton<D>>>;
|
|
42
|
+
/**
|
|
43
|
+
* Returns a {@link StarlightListResponse} with a list of
|
|
44
|
+
* {@apilink Singleton | Singletons}.
|
|
45
|
+
*
|
|
46
|
+
* @example Requesting all workspace singletons.
|
|
47
|
+
* ```ts
|
|
48
|
+
* import Starlight from '@starlightcms/js-sdk'
|
|
49
|
+
*
|
|
50
|
+
* const response = await Starlight.singletons.list()
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
4
53
|
list(): Promise<StarlightListResponse<Singleton<Record<string, unknown>>>>;
|
|
5
54
|
}
|
|
6
55
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/selectors/Singleton/types.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,SAAS,EACT,qBAAqB,EACrB,qBAAqB,EACtB,MAAM,aAAa,CAAA;AAEpB,MAAM,WAAW,iBAAiB;IAChC,GAAG,CAAC,CAAC,SAAS,cAAc,EAC1B,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,qBAAqB,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/selectors/Singleton/types.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,SAAS,EACT,qBAAqB,EACrB,qBAAqB,EACtB,MAAM,aAAa,CAAA;AAEpB;;;;;;;;GAQG;AACH,MAAM,WAAW,iBAAiB;IAChC;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA4BG;IACH,GAAG,CAAC,CAAC,SAAS,cAAc,EAC1B,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,qBAAqB,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;IAE/C;;;;;;;;;;OAUG;IACH,IAAI,IAAI,OAAO,CAAC,qBAAqB,CAAC,SAAS,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,CAAA;CAC3E"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/selectors/Singleton/types.ts"],"names":[],"mappings":"","sourcesContent":["import {\n SerializedData,\n Singleton,\n StarlightItemResponse,\n StarlightListResponse,\n} from '../../types'\n\nexport interface SingletonSelector {\n get<D extends SerializedData>(\n slug: string\n ): Promise<StarlightItemResponse<Singleton<D>>>\n list(): Promise<StarlightListResponse<Singleton<Record<string, unknown>>>>\n}\n"]}
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/selectors/Singleton/types.ts"],"names":[],"mappings":"","sourcesContent":["import {\n SerializedData,\n Singleton,\n StarlightItemResponse,\n StarlightListResponse,\n} from '../../types'\n\n/**\n * A Selector that provide methods to list and request information on\n * {@apilink Singleton | Singletons}.\n *\n * You can use an SingletonSelector by accessing\n * {@apilink ModelInstance.singletons}.\n *\n * @group Selectors\n */\nexport interface SingletonSelector {\n /**\n * Returns a {@link StarlightItemResponse} with a single {@link Singleton}.\n * This methods supports typing the returned Singleton by passing its data\n * type as the generic type `<D>`.\n *\n * @example Requesting information from a singleton of slug \"home\".\n * ```ts\n * import Starlight from '@starlightcms/js-sdk'\n *\n * const response = await Starlight.singletons.get('home')\n * ```\n *\n * @example Typing last example's response.\n * ```ts\n * import Starlight, { StringField, MediaField, VisualField } from '@starlightcms/js-sdk'\n *\n * type HomeFields = {\n * title: StringField\n * subtitle: StringField\n * hero_image: MediaField\n * hero_content: VisualField\n * }\n *\n * // `response.data` will be of type Singleton<HomeFields>\n * const response = await Starlight.singletons.get<HomeFields>('home')\n * ```\n * @typeParam D - The type of the returned Singleton's `data` property.\n * @param slug The singleton slug.\n */\n get<D extends SerializedData>(\n slug: string\n ): Promise<StarlightItemResponse<Singleton<D>>>\n\n /**\n * Returns a {@link StarlightListResponse} with a list of\n * {@apilink Singleton | Singletons}.\n *\n * @example Requesting all workspace singletons.\n * ```ts\n * import Starlight from '@starlightcms/js-sdk'\n *\n * const response = await Starlight.singletons.list()\n * ```\n */\n list(): Promise<StarlightListResponse<Singleton<Record<string, unknown>>>>\n}\n"]}
|