@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,14 +1,97 @@
|
|
|
1
1
|
import { Model, SerializedData, StarlightItemResponse } from '../../types';
|
|
2
2
|
import { EntrySelector } from '../../selectors/Entry';
|
|
3
|
-
import {
|
|
3
|
+
import { DynamicModelCategorySelector } from '../../selectors/ModelCategory';
|
|
4
4
|
import { ModelCategoryInstance } from '../ModelCategory';
|
|
5
|
+
/**
|
|
6
|
+
* An Instance that provide methods to request information from a {@link Model},
|
|
7
|
+
* its {@apilink Entry | Entries}, and its {@apilink ModelCategory | Categories}.
|
|
8
|
+
*
|
|
9
|
+
* You can access a ModelInstance using {@apilink StarlightClient.model} or
|
|
10
|
+
* using the dynamic syntax on a {@link DynamicStarlightClient}. Usage
|
|
11
|
+
* examples will use the dynamic syntax.
|
|
12
|
+
*
|
|
13
|
+
* To list all workspace models, use a {@link ModelSelector}.
|
|
14
|
+
*
|
|
15
|
+
* @group Instances
|
|
16
|
+
*/
|
|
5
17
|
export interface ModelInstance<D extends SerializedData> {
|
|
18
|
+
/**
|
|
19
|
+
* Returns a {@link StarlightItemResponse} with a single {@link Model}.
|
|
20
|
+
*
|
|
21
|
+
* @example Requesting information from a model of slug `posts`.
|
|
22
|
+
* ```ts
|
|
23
|
+
* import Starlight from '@starlightcms/js-sdk'
|
|
24
|
+
*
|
|
25
|
+
* const response = await Starlight.posts.get()
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
6
28
|
get(): Promise<StarlightItemResponse<Model>>;
|
|
29
|
+
/**
|
|
30
|
+
* Returns a {@link ModelCategoryInstance}.
|
|
31
|
+
*
|
|
32
|
+
* If you're using a {@link DynamicModelInstance}, you can use the
|
|
33
|
+
* dynamic syntax instead of this method.
|
|
34
|
+
*
|
|
35
|
+
* @example Listing all entries from the "news" category of a model of slug "posts".
|
|
36
|
+
* ```ts
|
|
37
|
+
* import Starlight from '@starlightcms/js-sdk'
|
|
38
|
+
*
|
|
39
|
+
* const response = await Starlight.posts.category('news').entries()
|
|
40
|
+
* ```
|
|
41
|
+
*
|
|
42
|
+
* @param slug The category slug.
|
|
43
|
+
*/
|
|
7
44
|
category(slug: string): ModelCategoryInstance<D>;
|
|
45
|
+
/**
|
|
46
|
+
* Returns an {@link EntrySelector}.
|
|
47
|
+
*
|
|
48
|
+
* This is an accessor, which means that it should be used just like a common
|
|
49
|
+
* object parameter. For instance:
|
|
50
|
+
*
|
|
51
|
+
* ```ts
|
|
52
|
+
* import Starlight from '@starlightcms/js-sdk'
|
|
53
|
+
*
|
|
54
|
+
* // "entries" below is an EntrySelector.
|
|
55
|
+
* const response = await Starlight.posts.entries.list()
|
|
56
|
+
* ```
|
|
57
|
+
*/
|
|
8
58
|
get entries(): EntrySelector<D>;
|
|
9
|
-
|
|
59
|
+
/**
|
|
60
|
+
* Returns a {@link DynamicModelCategorySelector}.
|
|
61
|
+
*
|
|
62
|
+
* This is an accessor, which means that it should be used just like a common
|
|
63
|
+
* object parameter. For instance:
|
|
64
|
+
*
|
|
65
|
+
* ```ts
|
|
66
|
+
* import Starlight from '@starlightcms/js-sdk'
|
|
67
|
+
*
|
|
68
|
+
* // "categories" below is a DynamicModelCategorySelector.
|
|
69
|
+
* const response = await Starlight.posts.categories.get('interviews')
|
|
70
|
+
* ```
|
|
71
|
+
*/
|
|
72
|
+
get categories(): DynamicModelCategorySelector<D>;
|
|
10
73
|
}
|
|
11
|
-
|
|
74
|
+
/**
|
|
75
|
+
* An Instance that provide all {@link ModelInstance} methods and adds support
|
|
76
|
+
* for creating {@apilink ModelCategoryInstance | ModelCategoryInstances} using
|
|
77
|
+
* the dynamic syntax.
|
|
78
|
+
*
|
|
79
|
+
* See {@link ModelInstance} to view all available methods.
|
|
80
|
+
*
|
|
81
|
+
* See {@doclink requests-and-responses#dynamic-syntax | Dynamic Instances}
|
|
82
|
+
* documentation to learn more about the dynamic syntax.
|
|
83
|
+
*
|
|
84
|
+
* @example Accessing a ModelCategoryInstance using the dynamic syntax.
|
|
85
|
+
* ```ts
|
|
86
|
+
* import Starlight from '@starlightcms/js-sdk'
|
|
87
|
+
*
|
|
88
|
+
* // "articles" below will be a ModelCategoryInstance.
|
|
89
|
+
* const response = await Starlight.posts.articles.list()
|
|
90
|
+
* ```
|
|
91
|
+
*
|
|
92
|
+
* @category Instances
|
|
93
|
+
*/
|
|
94
|
+
export declare type DynamicModelInstance<D extends SerializedData> = ModelInstance<D> & {
|
|
12
95
|
[key: string]: ModelCategoryInstance<D>;
|
|
13
96
|
};
|
|
14
97
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/instances/Model/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAA;AAC1E,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAA;AACrD,OAAO,EAAE,4BAA4B,EAAE,MAAM,+BAA+B,CAAA;AAC5E,OAAO,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAA;AAExD,MAAM,WAAW,aAAa,CAAC,CAAC,SAAS,cAAc;IACrD,GAAG,IAAI,OAAO,CAAC,qBAAqB,CAAC,KAAK,CAAC,CAAC,CAAA;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/instances/Model/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAA;AAC1E,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAA;AACrD,OAAO,EAAE,4BAA4B,EAAE,MAAM,+BAA+B,CAAA;AAC5E,OAAO,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAA;AAExD;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,aAAa,CAAC,CAAC,SAAS,cAAc;IACrD;;;;;;;;;OASG;IACH,GAAG,IAAI,OAAO,CAAC,qBAAqB,CAAC,KAAK,CAAC,CAAC,CAAA;IAE5C;;;;;;;;;;;;;;OAcG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,qBAAqB,CAAC,CAAC,CAAC,CAAA;IAEhD;;;;;;;;;;;;OAYG;IACH,IAAI,OAAO,IAAI,aAAa,CAAC,CAAC,CAAC,CAAA;IAE/B;;;;;;;;;;;;OAYG;IACH,IAAI,UAAU,IAAI,4BAA4B,CAAC,CAAC,CAAC,CAAA;CAClD;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,oBAAY,oBAAoB,CAAC,CAAC,SAAS,cAAc,IACvD,aAAa,CAAC,CAAC,CAAC,GAAG;IACjB,CAAC,GAAG,EAAE,MAAM,GAAG,qBAAqB,CAAC,CAAC,CAAC,CAAA;CACxC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/instances/Model/types.ts"],"names":[],"mappings":"","sourcesContent":["import { Model, SerializedData, StarlightItemResponse } from '../../types'\nimport { EntrySelector } from '../../selectors/Entry'\nimport {
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/instances/Model/types.ts"],"names":[],"mappings":"","sourcesContent":["import { Model, SerializedData, StarlightItemResponse } from '../../types'\nimport { EntrySelector } from '../../selectors/Entry'\nimport { DynamicModelCategorySelector } from '../../selectors/ModelCategory'\nimport { ModelCategoryInstance } from '../ModelCategory'\n\n/**\n * An Instance that provide methods to request information from a {@link Model},\n * its {@apilink Entry | Entries}, and its {@apilink ModelCategory | Categories}.\n *\n * You can access a ModelInstance using {@apilink StarlightClient.model} or\n * using the dynamic syntax on a {@link DynamicStarlightClient}. Usage\n * examples will use the dynamic syntax.\n *\n * To list all workspace models, use a {@link ModelSelector}.\n *\n * @group Instances\n */\nexport interface ModelInstance<D extends SerializedData> {\n /**\n * Returns a {@link StarlightItemResponse} with a single {@link Model}.\n *\n * @example Requesting information from a model of slug `posts`.\n * ```ts\n * import Starlight from '@starlightcms/js-sdk'\n *\n * const response = await Starlight.posts.get()\n * ```\n */\n get(): Promise<StarlightItemResponse<Model>>\n\n /**\n * Returns a {@link ModelCategoryInstance}.\n *\n * If you're using a {@link DynamicModelInstance}, you can use the\n * dynamic syntax instead of this method.\n *\n * @example Listing all entries from the \"news\" category of a model of slug \"posts\".\n * ```ts\n * import Starlight from '@starlightcms/js-sdk'\n *\n * const response = await Starlight.posts.category('news').entries()\n * ```\n *\n * @param slug The category slug.\n */\n category(slug: string): ModelCategoryInstance<D>\n\n /**\n * Returns an {@link EntrySelector}.\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 * // \"entries\" below is an EntrySelector.\n * const response = await Starlight.posts.entries.list()\n * ```\n */\n get entries(): EntrySelector<D>\n\n /**\n * Returns a {@link DynamicModelCategorySelector}.\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 * // \"categories\" below is a DynamicModelCategorySelector.\n * const response = await Starlight.posts.categories.get('interviews')\n * ```\n */\n get categories(): DynamicModelCategorySelector<D>\n}\n\n/**\n * An Instance that provide all {@link ModelInstance} methods and adds support\n * for creating {@apilink ModelCategoryInstance | ModelCategoryInstances} using\n * the dynamic syntax.\n *\n * See {@link ModelInstance} 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 ModelCategoryInstance using the dynamic syntax.\n * ```ts\n * import Starlight from '@starlightcms/js-sdk'\n *\n * // \"articles\" below will be a ModelCategoryInstance.\n * const response = await Starlight.posts.articles.list()\n * ```\n *\n * @category Instances\n */\nexport type DynamicModelInstance<D extends SerializedData> =\n ModelInstance<D> & {\n [key: string]: ModelCategoryInstance<D>\n }\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SerializedData, StarlightClient } from '../../types';
|
|
2
|
-
import { ModelCategoryInstance } from './types';
|
|
2
|
+
import { ModelCategoryInstance, ModelCategoryEntryListParams } from './types';
|
|
3
3
|
export default function makeModelCategoryInstance<D extends SerializedData>(client: StarlightClient, model: string, category: string): ModelCategoryInstance<D>;
|
|
4
|
-
export { ModelCategoryInstance };
|
|
4
|
+
export { ModelCategoryInstance, ModelCategoryEntryListParams };
|
|
5
5
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/instances/ModelCategory/index.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/instances/ModelCategory/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,cAAc,EACd,eAAe,EAGhB,MAAM,aAAa,CAAA;AACpB,OAAO,EAAE,qBAAqB,EAAE,4BAA4B,EAAE,MAAM,SAAS,CAAA;AAE7E,MAAM,CAAC,OAAO,UAAU,yBAAyB,CAAC,CAAC,SAAS,cAAc,EACxE,MAAM,EAAE,eAAe,EACvB,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,MAAM,GACf,qBAAqB,CAAC,CAAC,CAAC,CAc1B;AAED,OAAO,EAAE,qBAAqB,EAAE,4BAA4B,EAAE,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/instances/ModelCategory/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/instances/ModelCategory/index.ts"],"names":[],"mappings":"AAWA,MAAM,CAAC,OAAO,UAAU,yBAAyB,CAC/C,MAAuB,EACvB,KAAa,EACb,QAAgB;IAEhB,OAAO;QACL,GAAG;YACD,OAAO,MAAM,CAAC,GAAG,CAAC,WAAW,KAAK,eAAe,QAAQ,EAAE,CAAC,CAAA;QAC9D,CAAC;QACD,OAAO,CACL,OAA0D;YAE1D,OAAO,MAAM,CAAC,GAAG,CACf,WAAW,KAAK,eAAe,QAAQ,UAAU,EACjD,OAAO,CACR,CAAA;QACH,CAAC;KACF,CAAA;AACH,CAAC","sourcesContent":["import {\n Entry,\n ModelCategory,\n QueryableFields,\n SerializedData,\n StarlightClient,\n StarlightItemResponse,\n StarlightListResponse,\n} from '../../types'\nimport { ModelCategoryInstance, ModelCategoryEntryListParams } from './types'\n\nexport default function makeModelCategoryInstance<D extends SerializedData>(\n client: StarlightClient,\n model: string,\n category: string\n): ModelCategoryInstance<D> {\n return {\n get(): Promise<StarlightItemResponse<ModelCategory>> {\n return client.get(`/models/${model}/categories/${category}`)\n },\n entries(\n options: ModelCategoryEntryListParams & QueryableFields<D>\n ): Promise<StarlightListResponse<Entry<D>>> {\n return client.get(\n `/models/${model}/categories/${category}/entries`,\n options\n )\n },\n }\n}\n\nexport { ModelCategoryInstance, ModelCategoryEntryListParams }\n"]}
|
|
@@ -1,15 +1,67 @@
|
|
|
1
|
-
import { Entry, ModelCategory,
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import { BaseRequestParameters, Entry, ModelCategory, QueryableFields, QueryableRequestParameters, SerializedData, StarlightItemResponse, StarlightListResponse } from '../../types';
|
|
2
|
+
/**
|
|
3
|
+
* Request parameters for listing category entries.
|
|
4
|
+
*
|
|
5
|
+
* Used by {@apilink ModelCategoryInstance.entries}.
|
|
6
|
+
*
|
|
7
|
+
* @group Request Parameters
|
|
8
|
+
*/
|
|
9
|
+
export interface ModelCategoryEntryListParams extends BaseRequestParameters, QueryableRequestParameters {
|
|
10
|
+
/**
|
|
11
|
+
* Define how entries will be ordered. Check this field type to see the
|
|
12
|
+
* allowed options.
|
|
13
|
+
*/
|
|
8
14
|
order?: 'title:asc' | 'title:desc' | 'published_at:asc' | 'published_at:desc' | 'views:asc' | 'views:desc';
|
|
9
|
-
|
|
10
|
-
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* An Instance that provide methods to request information from a
|
|
18
|
+
* {@link ModelCategory} and its {@apilink Entry | Entries}.
|
|
19
|
+
*
|
|
20
|
+
* You can access a ModelCategoryInstance using
|
|
21
|
+
* {@apilink ModelInstance.category} or using the dynamic syntax on a
|
|
22
|
+
* {@link DynamicModelInstance}. Usage examples will use the dynamic syntax.
|
|
23
|
+
*
|
|
24
|
+
* To list all categories from a model, use a {@link ModelCategorySelector}.
|
|
25
|
+
*
|
|
26
|
+
* @group Instances
|
|
27
|
+
*/
|
|
11
28
|
export interface ModelCategoryInstance<D extends SerializedData> {
|
|
29
|
+
/**
|
|
30
|
+
* Returns a {@link StarlightItemResponse} with a single {@link ModelCategory}.
|
|
31
|
+
*
|
|
32
|
+
* @example Requesting information from a category called "articles" in a model of slug "posts".
|
|
33
|
+
* ```ts
|
|
34
|
+
* import Starlight from '@starlightcms/js-sdk'
|
|
35
|
+
*
|
|
36
|
+
* const response = await Starlight.posts.articles.get()
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
12
39
|
get(): Promise<StarlightItemResponse<ModelCategory>>;
|
|
13
|
-
|
|
40
|
+
/**
|
|
41
|
+
* Returns a {@link StarlightListResponse} with the list of entries of this
|
|
42
|
+
* {@link ModelCategory}.
|
|
43
|
+
*
|
|
44
|
+
* @example Requesting all items from a category called "gaming" in a model of slug "posts".
|
|
45
|
+
* ```ts
|
|
46
|
+
* import Starlight from '@starlightcms/js-sdk'
|
|
47
|
+
*
|
|
48
|
+
* const response = await Starlight.posts.gaming.items()
|
|
49
|
+
* ```
|
|
50
|
+
*
|
|
51
|
+
* @example Paginating and searching on the last example.
|
|
52
|
+
* ```ts
|
|
53
|
+
* import Starlight from '@starlightcms/js-sdk'
|
|
54
|
+
*
|
|
55
|
+
* const response = await Starlight.posts.gaming.items({
|
|
56
|
+
* page: 5,
|
|
57
|
+
* query: 'kirby'
|
|
58
|
+
* })
|
|
59
|
+
* ```
|
|
60
|
+
*
|
|
61
|
+
* @param options An optional object of request parameters. See
|
|
62
|
+
* {@link ModelCategoryEntryListParams} for all available options. `field:foo`
|
|
63
|
+
* syntax is also supported, see {@link QueryableFields} for more info.
|
|
64
|
+
*/
|
|
65
|
+
entries(options?: ModelCategoryEntryListParams & QueryableFields<D>): Promise<StarlightListResponse<Entry<D>>>;
|
|
14
66
|
}
|
|
15
67
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/instances/ModelCategory/types.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,EACL,aAAa,EACb,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/instances/ModelCategory/types.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,EACrB,KAAK,EACL,aAAa,EACb,eAAe,EACf,0BAA0B,EAC1B,cAAc,EACd,qBAAqB,EACrB,qBAAqB,EACtB,MAAM,aAAa,CAAA;AAEpB;;;;;;GAMG;AACH,MAAM,WAAW,4BACf,SAAQ,qBAAqB,EAC3B,0BAA0B;IAC5B;;;OAGG;IACH,KAAK,CAAC,EACF,WAAW,GACX,YAAY,GACZ,kBAAkB,GAClB,mBAAmB,GACnB,WAAW,GACX,YAAY,CAAA;CACjB;AAED;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,qBAAqB,CAAC,CAAC,SAAS,cAAc;IAC7D;;;;;;;;;OASG;IACH,GAAG,IAAI,OAAO,CAAC,qBAAqB,CAAC,aAAa,CAAC,CAAC,CAAA;IAEpD;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;IACH,OAAO,CACL,OAAO,CAAC,EAAE,4BAA4B,GAAG,eAAe,CAAC,CAAC,CAAC,GAC1D,OAAO,CAAC,qBAAqB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;CAC5C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/instances/ModelCategory/types.ts"],"names":[],"mappings":"","sourcesContent":["import {\n Entry,\n ModelCategory,\n
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/instances/ModelCategory/types.ts"],"names":[],"mappings":"","sourcesContent":["import {\n BaseRequestParameters,\n Entry,\n ModelCategory,\n QueryableFields,\n QueryableRequestParameters,\n SerializedData,\n StarlightItemResponse,\n StarlightListResponse,\n} from '../../types'\n\n/**\n * Request parameters for listing category entries.\n *\n * Used by {@apilink ModelCategoryInstance.entries}.\n *\n * @group Request Parameters\n */\nexport interface ModelCategoryEntryListParams\n extends BaseRequestParameters,\n QueryableRequestParameters {\n /**\n * Define how entries 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 | 'views:asc'\n | 'views:desc'\n}\n\n/**\n * An Instance that provide methods to request information from a\n * {@link ModelCategory} and its {@apilink Entry | Entries}.\n *\n * You can access a ModelCategoryInstance using\n * {@apilink ModelInstance.category} or using the dynamic syntax on a\n * {@link DynamicModelInstance}. Usage examples will use the dynamic syntax.\n *\n * To list all categories from a model, use a {@link ModelCategorySelector}.\n *\n * @group Instances\n */\nexport interface ModelCategoryInstance<D extends SerializedData> {\n /**\n * Returns a {@link StarlightItemResponse} with a single {@link ModelCategory}.\n *\n * @example Requesting information from a category called \"articles\" in a model of slug \"posts\".\n * ```ts\n * import Starlight from '@starlightcms/js-sdk'\n *\n * const response = await Starlight.posts.articles.get()\n * ```\n */\n get(): Promise<StarlightItemResponse<ModelCategory>>\n\n /**\n * Returns a {@link StarlightListResponse} with the list of entries of this\n * {@link ModelCategory}.\n *\n * @example Requesting all items from a category called \"gaming\" in a model of slug \"posts\".\n * ```ts\n * import Starlight from '@starlightcms/js-sdk'\n *\n * const response = await Starlight.posts.gaming.items()\n * ```\n *\n * @example Paginating and searching on the last example.\n * ```ts\n * import Starlight from '@starlightcms/js-sdk'\n *\n * const response = await Starlight.posts.gaming.items({\n * page: 5,\n * query: 'kirby'\n * })\n * ```\n *\n * @param options An optional object of request parameters. See\n * {@link ModelCategoryEntryListParams} for all available options. `field:foo`\n * syntax is also supported, see {@link QueryableFields} for more info.\n */\n entries(\n options?: ModelCategoryEntryListParams & QueryableFields<D>\n ): Promise<StarlightListResponse<Entry<D>>>\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { StarlightClient } from '../../types';
|
|
2
|
-
import { CollectionSelector,
|
|
3
|
-
export default function makeCollectionSelector(client: StarlightClient):
|
|
4
|
-
export { CollectionSelector,
|
|
2
|
+
import { CollectionSelector, DynamicCollectionSelector, ListCollectionsParams } from './types';
|
|
3
|
+
export default function makeCollectionSelector(client: StarlightClient): DynamicCollectionSelector;
|
|
4
|
+
export { CollectionSelector, DynamicCollectionSelector, ListCollectionsParams };
|
|
5
5
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/selectors/Collection/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAC7C,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/selectors/Collection/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAC7C,OAAO,EACL,kBAAkB,EAClB,yBAAyB,EACzB,qBAAqB,EACtB,MAAM,SAAS,CAAA;AAGhB,MAAM,CAAC,OAAO,UAAU,sBAAsB,CAC5C,MAAM,EAAE,eAAe,GACtB,yBAAyB,CAoB3B;AAED,OAAO,EAAE,kBAAkB,EAAE,yBAAyB,EAAE,qBAAqB,EAAE,CAAA"}
|
|
@@ -2,7 +2,7 @@ import makeCollectionInstance from '../../instances/Collection';
|
|
|
2
2
|
export default function makeCollectionSelector(client) {
|
|
3
3
|
const selector = {
|
|
4
4
|
list(options) {
|
|
5
|
-
return client.get('/collections', options);
|
|
5
|
+
return client.get('/collections', Object.assign({}, options));
|
|
6
6
|
},
|
|
7
7
|
get(slug) {
|
|
8
8
|
return client.get(`/collections/${slug}`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/selectors/Collection/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/selectors/Collection/index.ts"],"names":[],"mappings":"AAMA,OAAO,sBAAsB,MAAM,4BAA4B,CAAA;AAE/D,MAAM,CAAC,OAAO,UAAU,sBAAsB,CAC5C,MAAuB;IAEvB,MAAM,QAAQ,GAAuB;QACnC,IAAI,CAAC,OAAO;YACV,OAAO,MAAM,CAAC,GAAG,CAAC,cAAc,oBAAO,OAAO,EAAG,CAAA;QACnD,CAAC;QAED,GAAG,CAAC,IAAI;YACN,OAAO,MAAM,CAAC,GAAG,CAAC,gBAAgB,IAAI,EAAE,CAAC,CAAA;QAC3C,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,sBAAsB,CAAC,MAAM,EAAE,IAAI,CAAC,CAAA;aAC5C;YAED,OAAO,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,CAAA;QAClC,CAAC;KACF,CAA8B,CAAA;AACjC,CAAC","sourcesContent":["import { StarlightClient } from '../../types'\nimport {\n CollectionSelector,\n DynamicCollectionSelector,\n ListCollectionsParams,\n} from './types'\nimport makeCollectionInstance from '../../instances/Collection'\n\nexport default function makeCollectionSelector(\n client: StarlightClient\n): DynamicCollectionSelector {\n const selector: CollectionSelector = {\n list(options) {\n return client.get('/collections', { ...options })\n },\n\n get(slug) {\n return client.get(`/collections/${slug}`)\n },\n }\n\n return new Proxy(selector, {\n get(target, prop) {\n if (typeof prop === 'string' && !Reflect.has(target, prop)) {\n return makeCollectionInstance(client, prop)\n }\n\n return Reflect.get(target, prop)\n },\n }) as DynamicCollectionSelector\n}\n\nexport { CollectionSelector, DynamicCollectionSelector, ListCollectionsParams }\n"]}
|
|
@@ -1,16 +1,91 @@
|
|
|
1
|
-
import { Collection, StarlightItemResponse, StarlightListResponse } from '../../types';
|
|
1
|
+
import { BaseRequestParameters, Collection, StarlightItemResponse, StarlightListResponse } from '../../types';
|
|
2
2
|
import { CollectionInstance } from '../../instances/Collection';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
/**
|
|
4
|
+
* Request parameters for listing collections.
|
|
5
|
+
*
|
|
6
|
+
* Used by {@apilink CollectionSelector.list}.
|
|
7
|
+
*
|
|
8
|
+
* @group Request Parameters
|
|
9
|
+
*/
|
|
10
|
+
export interface ListCollectionsParams extends BaseRequestParameters {
|
|
11
|
+
/**
|
|
12
|
+
* Define how items will be ordered. Check this field type to see the
|
|
13
|
+
* allowed options.
|
|
14
|
+
*/
|
|
7
15
|
order?: 'title:asc' | 'title:desc' | 'item_count:asc' | 'item_count:desc';
|
|
8
|
-
}
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* A Selector that provide methods to list and request information on
|
|
19
|
+
* {@apilink Collection | Collections}.
|
|
20
|
+
*
|
|
21
|
+
* You can use a CollectionSelector by accessing
|
|
22
|
+
* {@apilink StarlightClient.collections}.
|
|
23
|
+
*
|
|
24
|
+
* To get items from a specific collection, use a {@link CollectionInstance}.
|
|
25
|
+
*
|
|
26
|
+
* @group Selectors
|
|
27
|
+
*/
|
|
9
28
|
export interface CollectionSelector {
|
|
10
|
-
|
|
29
|
+
/**
|
|
30
|
+
* Returns a {@link StarlightListResponse} with the list of
|
|
31
|
+
* {@apilink Collection | Collections} in this workspace.
|
|
32
|
+
*
|
|
33
|
+
* @example Requesting all collections from the workspace.
|
|
34
|
+
* ```ts
|
|
35
|
+
* import Starlight from '@starlightcms/js-sdk'
|
|
36
|
+
*
|
|
37
|
+
* const response = await Starlight.collections.list()
|
|
38
|
+
* ```
|
|
39
|
+
*
|
|
40
|
+
* @example Paginating and searching on the last example.
|
|
41
|
+
* ```ts
|
|
42
|
+
* import Starlight from '@starlightcms/js-sdk'
|
|
43
|
+
*
|
|
44
|
+
* const response = await Starlight.collections.list({
|
|
45
|
+
* page: 2,
|
|
46
|
+
* query: 'photos',
|
|
47
|
+
* })
|
|
48
|
+
* ```
|
|
49
|
+
*
|
|
50
|
+
* @param options An optional object of request parameters. See
|
|
51
|
+
* {@link ListCollectionsParams} for all available options.
|
|
52
|
+
*/
|
|
53
|
+
list(options?: ListCollectionsParams): Promise<StarlightListResponse<Collection>>;
|
|
54
|
+
/**
|
|
55
|
+
* Returns a {@link StarlightItemResponse} with a single {@link Collection}.
|
|
56
|
+
*
|
|
57
|
+
* @example Requesting information from a collection of slug "event-photos".
|
|
58
|
+
* ```ts
|
|
59
|
+
* import Starlight from '@starlightcms/js-sdk'
|
|
60
|
+
*
|
|
61
|
+
* const response = await Starlight.collections.get('event-photos')
|
|
62
|
+
* ```
|
|
63
|
+
*
|
|
64
|
+
* @param slug The collection slug.
|
|
65
|
+
*/
|
|
11
66
|
get(slug: string | number): Promise<StarlightItemResponse<Collection>>;
|
|
12
67
|
}
|
|
13
|
-
|
|
14
|
-
|
|
68
|
+
/**
|
|
69
|
+
* A Selector that provide all {@link CollectionSelector} methods and adds
|
|
70
|
+
* support for creating {@apilink CollectionInstance | CollectionInstances}
|
|
71
|
+
* using the dynamic syntax.
|
|
72
|
+
*
|
|
73
|
+
* See {@link CollectionSelector} to view all available methods.
|
|
74
|
+
*
|
|
75
|
+
* See {@doclink requests-and-responses#dynamic-syntax | Dynamic Instances}
|
|
76
|
+
* documentation to learn more about the dynamic syntax.
|
|
77
|
+
*
|
|
78
|
+
* @example Accessing a CollectionInstance using the dynamic syntax.
|
|
79
|
+
* ```ts
|
|
80
|
+
* import Starlight from '@starlightcms/js-sdk'
|
|
81
|
+
*
|
|
82
|
+
* // "sliders" below will be a CollectionInstance.
|
|
83
|
+
* const response = await Starlight.collections.sliders.list()
|
|
84
|
+
* ```
|
|
85
|
+
*
|
|
86
|
+
* @category Instances
|
|
87
|
+
*/
|
|
88
|
+
export declare type DynamicCollectionSelector = CollectionSelector & {
|
|
89
|
+
[key: string]: CollectionInstance<unknown>;
|
|
15
90
|
};
|
|
16
91
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/selectors/Collection/types.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,qBAAqB,EACrB,qBAAqB,EACtB,MAAM,aAAa,CAAA;AACpB,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAA;AAE/D
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/selectors/Collection/types.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,EACrB,UAAU,EACV,qBAAqB,EACrB,qBAAqB,EACtB,MAAM,aAAa,CAAA;AACpB,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAA;AAE/D;;;;;;GAMG;AACH,MAAM,WAAW,qBAAsB,SAAQ,qBAAqB;IAClE;;;OAGG;IACH,KAAK,CAAC,EAAE,WAAW,GAAG,YAAY,GAAG,gBAAgB,GAAG,iBAAiB,CAAA;CAC1E;AAED;;;;;;;;;;GAUG;AACH,MAAM,WAAW,kBAAkB;IACjC;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IACH,IAAI,CACF,OAAO,CAAC,EAAE,qBAAqB,GAC9B,OAAO,CAAC,qBAAqB,CAAC,UAAU,CAAC,CAAC,CAAA;IAE7C;;;;;;;;;;;OAWG;IACH,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,qBAAqB,CAAC,UAAU,CAAC,CAAC,CAAA;CACvE;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,oBAAY,yBAAyB,GAAG,kBAAkB,GAAG;IAC3D,CAAC,GAAG,EAAE,MAAM,GAAG,kBAAkB,CAAC,OAAO,CAAC,CAAA;CAC3C,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/selectors/Collection/types.ts"],"names":[],"mappings":"","sourcesContent":["import {\n Collection,\n StarlightItemResponse,\n StarlightListResponse,\n} from '../../types'\nimport { CollectionInstance } from '../../instances/Collection'\n\
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/selectors/Collection/types.ts"],"names":[],"mappings":"","sourcesContent":["import {\n BaseRequestParameters,\n Collection,\n StarlightItemResponse,\n StarlightListResponse,\n} from '../../types'\nimport { CollectionInstance } from '../../instances/Collection'\n\n/**\n * Request parameters for listing collections.\n *\n * Used by {@apilink CollectionSelector.list}.\n *\n * @group Request Parameters\n */\nexport interface ListCollectionsParams 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' | 'item_count:asc' | 'item_count:desc'\n}\n\n/**\n * A Selector that provide methods to list and request information on\n * {@apilink Collection | Collections}.\n *\n * You can use a CollectionSelector by accessing\n * {@apilink StarlightClient.collections}.\n *\n * To get items from a specific collection, use a {@link CollectionInstance}.\n *\n * @group Selectors\n */\nexport interface CollectionSelector {\n /**\n * Returns a {@link StarlightListResponse} with the list of\n * {@apilink Collection | Collections} in this workspace.\n *\n * @example Requesting all collections from the workspace.\n * ```ts\n * import Starlight from '@starlightcms/js-sdk'\n *\n * const response = await Starlight.collections.list()\n * ```\n *\n * @example Paginating and searching on the last example.\n * ```ts\n * import Starlight from '@starlightcms/js-sdk'\n *\n * const response = await Starlight.collections.list({\n * page: 2,\n * query: 'photos',\n * })\n * ```\n *\n * @param options An optional object of request parameters. See\n * {@link ListCollectionsParams} for all available options.\n */\n list(\n options?: ListCollectionsParams\n ): Promise<StarlightListResponse<Collection>>\n\n /**\n * Returns a {@link StarlightItemResponse} with a single {@link Collection}.\n *\n * @example Requesting information from a collection of slug \"event-photos\".\n * ```ts\n * import Starlight from '@starlightcms/js-sdk'\n *\n * const response = await Starlight.collections.get('event-photos')\n * ```\n *\n * @param slug The collection slug.\n */\n get(slug: string | number): Promise<StarlightItemResponse<Collection>>\n}\n\n/**\n * A Selector that provide all {@link CollectionSelector} methods and adds\n * support for creating {@apilink CollectionInstance | CollectionInstances}\n * using the dynamic syntax.\n *\n * See {@link CollectionSelector} 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 CollectionInstance using the dynamic syntax.\n * ```ts\n * import Starlight from '@starlightcms/js-sdk'\n *\n * // \"sliders\" below will be a CollectionInstance.\n * const response = await Starlight.collections.sliders.list()\n * ```\n *\n * @category Instances\n */\nexport type DynamicCollectionSelector = CollectionSelector & {\n [key: string]: CollectionInstance<unknown>\n}\n"]}
|
|
@@ -1,19 +1,114 @@
|
|
|
1
|
-
import { Entry,
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import { BaseRequestParameters, Entry, QueryableFields, QueryableRequestParameters, SerializedData, StarlightItemResponse, StarlightListResponse } from '../../types';
|
|
2
|
+
/**
|
|
3
|
+
* Request parameters for listing entries.
|
|
4
|
+
*
|
|
5
|
+
* Used by {@apilink EntrySelector.list}.
|
|
6
|
+
*
|
|
7
|
+
* @group Request Parameters
|
|
8
|
+
*/
|
|
9
|
+
export interface ListEntriesParams extends BaseRequestParameters, QueryableRequestParameters {
|
|
10
|
+
/**
|
|
11
|
+
* A comma-separated list of categories. Only entries in these categories
|
|
12
|
+
* will be returned. If undefined, all entries in the model will be listed.
|
|
13
|
+
*
|
|
14
|
+
* For instance, to show only entries in the "news" and "articles" categories,
|
|
15
|
+
* pass `'news,category'`.
|
|
16
|
+
*/
|
|
8
17
|
categories?: string;
|
|
18
|
+
/**
|
|
19
|
+
* Define how items will be ordered. Check this field type to see the
|
|
20
|
+
* allowed options.
|
|
21
|
+
*/
|
|
9
22
|
order?: 'title:asc' | 'title:desc' | 'published_at:asc' | 'published_at:desc' | 'views:asc' | 'views:desc';
|
|
10
|
-
|
|
11
|
-
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Request parameters for getting an entry.
|
|
26
|
+
*
|
|
27
|
+
* Used by {@apilink EntrySelector.get}.
|
|
28
|
+
*
|
|
29
|
+
* @group Request Parameters
|
|
30
|
+
*/
|
|
12
31
|
export declare type GetEntryParams = {
|
|
32
|
+
/**
|
|
33
|
+
* Preview token generated by the Starlight admin interface. If defined and
|
|
34
|
+
* valid, the API will return a preview of the entry revision associated
|
|
35
|
+
* with the token.
|
|
36
|
+
*/
|
|
13
37
|
preview?: string;
|
|
14
38
|
};
|
|
39
|
+
/**
|
|
40
|
+
* A Selector that provide methods to list and request information on
|
|
41
|
+
* {@apilink Entry | Entries}.
|
|
42
|
+
*
|
|
43
|
+
* You can use an EntrySelector by accessing
|
|
44
|
+
* {@apilink ModelInstance.entries}.
|
|
45
|
+
*
|
|
46
|
+
* @group Selectors
|
|
47
|
+
*/
|
|
15
48
|
export interface EntrySelector<D extends SerializedData> {
|
|
49
|
+
/**
|
|
50
|
+
* Returns a {@link StarlightItemResponse} with a single {@link Entry}.
|
|
51
|
+
* Supports revision previewing by passing a `preview` parameter.
|
|
52
|
+
*
|
|
53
|
+
* @example Requesting information from an entry "hello-world" from a model of slug "posts".
|
|
54
|
+
* ```ts
|
|
55
|
+
* import Starlight from '@starlightcms/js-sdk'
|
|
56
|
+
*
|
|
57
|
+
* const response = await Starlight.posts.entries.get('hello-world')
|
|
58
|
+
* ```
|
|
59
|
+
*
|
|
60
|
+
* @example Passing a preview token on the last example.
|
|
61
|
+
* ```ts
|
|
62
|
+
* import Starlight from '@starlightcms/js-sdk'
|
|
63
|
+
*
|
|
64
|
+
* const response = await Starlight.posts.entries.get('hello-world', {
|
|
65
|
+
* preview: 'CDfkvt1zTF5XhxWzi2Lejgo1'
|
|
66
|
+
* })
|
|
67
|
+
* ```
|
|
68
|
+
*
|
|
69
|
+
* @param slug The entry slug.
|
|
70
|
+
* @param params An optional object of request parameters. See
|
|
71
|
+
* {@link GetEntryParams} for all available options.
|
|
72
|
+
* @param options An optional object of Fetch parameters. Use it to modify
|
|
73
|
+
* the fetch request.See [MDN documentation on fetch()](https://developer.mozilla.org/en-US/docs/Web/API/fetch)
|
|
74
|
+
* for all available options.
|
|
75
|
+
*/
|
|
16
76
|
get(slug: string, params?: GetEntryParams, options?: RequestInit): Promise<StarlightItemResponse<Entry<D>>>;
|
|
17
|
-
|
|
77
|
+
/**
|
|
78
|
+
* Returns a {@link StarlightListResponse} with a list of
|
|
79
|
+
* {@apilink Entry | Entries}.
|
|
80
|
+
*
|
|
81
|
+
* @example Requesting all entries from a model of slug "recipes".
|
|
82
|
+
* ```ts
|
|
83
|
+
* import Starlight from '@starlightcms/js-sdk'
|
|
84
|
+
*
|
|
85
|
+
* const response = await Starlight.recipes.entries.list()
|
|
86
|
+
* ```
|
|
87
|
+
*
|
|
88
|
+
* @example Paginating and searching on the last example.
|
|
89
|
+
* ```ts
|
|
90
|
+
* import Starlight from '@starlightcms/js-sdk'
|
|
91
|
+
*
|
|
92
|
+
* const response = await Starlight.recipes.entries.list({
|
|
93
|
+
* page: 2,
|
|
94
|
+
* query: 'gravy',
|
|
95
|
+
* 'field:is_vegan': true,
|
|
96
|
+
* })
|
|
97
|
+
* ```
|
|
98
|
+
*
|
|
99
|
+
* @example Ordering entries by number of views.
|
|
100
|
+
* ```ts
|
|
101
|
+
* import Starlight from '@starlightcms/js-sdk'
|
|
102
|
+
*
|
|
103
|
+
* const response = await Starlight.recipes.entries.list({
|
|
104
|
+
* order: 'views:desc'
|
|
105
|
+
* })
|
|
106
|
+
* ```
|
|
107
|
+
*
|
|
108
|
+
* @param options An optional object of request parameters. See
|
|
109
|
+
* {@link ListEntriesParams} for all available options. `field:foo`
|
|
110
|
+
* syntax is also supported, see {@link QueryableFields} for more info.
|
|
111
|
+
*/
|
|
112
|
+
list(options?: ListEntriesParams & QueryableFields<D>): Promise<StarlightListResponse<Entry<D>>>;
|
|
18
113
|
}
|
|
19
114
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/selectors/Entry/types.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,EACL,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/selectors/Entry/types.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,EACrB,KAAK,EACL,eAAe,EACf,0BAA0B,EAC1B,cAAc,EACd,qBAAqB,EACrB,qBAAqB,EACtB,MAAM,aAAa,CAAA;AAEpB;;;;;;GAMG;AACH,MAAM,WAAW,iBACf,SAAQ,qBAAqB,EAC3B,0BAA0B;IAC5B;;;;;;OAMG;IACH,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB;;;OAGG;IACH,KAAK,CAAC,EACF,WAAW,GACX,YAAY,GACZ,kBAAkB,GAClB,mBAAmB,GACnB,WAAW,GACX,YAAY,CAAA;CACjB;AAED;;;;;;GAMG;AACH,oBAAY,cAAc,GAAG;IAC3B;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB,CAAA;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,aAAa,CAAC,CAAC,SAAS,cAAc;IACrD;;;;;;;;;;;;;;;;;;;;;;;;;;OA0BG;IACH,GAAG,CACD,IAAI,EAAE,MAAM,EACZ,MAAM,CAAC,EAAE,cAAc,EACvB,OAAO,CAAC,EAAE,WAAW,GACpB,OAAO,CAAC,qBAAqB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;IAE3C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAkCG;IACH,IAAI,CACF,OAAO,CAAC,EAAE,iBAAiB,GAAG,eAAe,CAAC,CAAC,CAAC,GAC/C,OAAO,CAAC,qBAAqB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;CAC5C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/selectors/Entry/types.ts"],"names":[],"mappings":"","sourcesContent":["import {\n Entry,\n
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/selectors/Entry/types.ts"],"names":[],"mappings":"","sourcesContent":["import {\n BaseRequestParameters,\n Entry,\n QueryableFields,\n QueryableRequestParameters,\n SerializedData,\n StarlightItemResponse,\n StarlightListResponse,\n} from '../../types'\n\n/**\n * Request parameters for listing entries.\n *\n * Used by {@apilink EntrySelector.list}.\n *\n * @group Request Parameters\n */\nexport interface ListEntriesParams\n extends BaseRequestParameters,\n QueryableRequestParameters {\n /**\n * A comma-separated list of categories. Only entries in these categories\n * will be returned. If undefined, all entries in the model will be listed.\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 | 'views:asc'\n | 'views:desc'\n}\n\n/**\n * Request parameters for getting an entry.\n *\n * Used by {@apilink EntrySelector.get}.\n *\n * @group Request Parameters\n */\nexport type GetEntryParams = {\n /**\n * Preview token generated by the Starlight admin interface. If defined and\n * valid, the API will return a preview of the entry revision associated\n * with the token.\n */\n preview?: string\n}\n\n/**\n * A Selector that provide methods to list and request information on\n * {@apilink Entry | Entries}.\n *\n * You can use an EntrySelector by accessing\n * {@apilink ModelInstance.entries}.\n *\n * @group Selectors\n */\nexport interface EntrySelector<D extends SerializedData> {\n /**\n * Returns a {@link StarlightItemResponse} with a single {@link Entry}.\n * Supports revision previewing by passing a `preview` parameter.\n *\n * @example Requesting information from an entry \"hello-world\" from a model of slug \"posts\".\n * ```ts\n * import Starlight from '@starlightcms/js-sdk'\n *\n * const response = await Starlight.posts.entries.get('hello-world')\n * ```\n *\n * @example Passing a preview token on the last example.\n * ```ts\n * import Starlight from '@starlightcms/js-sdk'\n *\n * const response = await Starlight.posts.entries.get('hello-world', {\n * preview: 'CDfkvt1zTF5XhxWzi2Lejgo1'\n * })\n * ```\n *\n * @param slug The entry slug.\n * @param params An optional object of request parameters. See\n * {@link GetEntryParams} for all available options.\n * @param options An optional object of Fetch parameters. Use it to modify\n * the fetch request.See [MDN documentation on fetch()](https://developer.mozilla.org/en-US/docs/Web/API/fetch)\n * for all available options.\n */\n get(\n slug: string,\n params?: GetEntryParams,\n options?: RequestInit\n ): Promise<StarlightItemResponse<Entry<D>>>\n\n /**\n * Returns a {@link StarlightListResponse} with a list of\n * {@apilink Entry | Entries}.\n *\n * @example Requesting all entries from a model of slug \"recipes\".\n * ```ts\n * import Starlight from '@starlightcms/js-sdk'\n *\n * const response = await Starlight.recipes.entries.list()\n * ```\n *\n * @example Paginating and searching on the last example.\n * ```ts\n * import Starlight from '@starlightcms/js-sdk'\n *\n * const response = await Starlight.recipes.entries.list({\n * page: 2,\n * query: 'gravy',\n * 'field:is_vegan': true,\n * })\n * ```\n *\n * @example Ordering entries by number of views.\n * ```ts\n * import Starlight from '@starlightcms/js-sdk'\n *\n * const response = await Starlight.recipes.entries.list({\n * order: 'views:desc'\n * })\n * ```\n *\n * @param options An optional object of request parameters. See\n * {@link ListEntriesParams} for all available options. `field:foo`\n * syntax is also supported, see {@link QueryableFields} for more info.\n */\n list(\n options?: ListEntriesParams & QueryableFields<D>\n ): Promise<StarlightListResponse<Entry<D>>>\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/selectors/Media/index.ts"],"names":[],"mappings":"AAGA,MAAM,CAAC,OAAO,UAAU,iBAAiB,CACvC,MAAuB;IAEvB,OAAO;QACL,IAAI;YACF,OAAO,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;QAC7B,CAAC;QAED,GAAG,CAAC,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/selectors/Media/index.ts"],"names":[],"mappings":"AAGA,MAAM,CAAC,OAAO,UAAU,iBAAiB,CACvC,MAAuB;IAEvB,OAAO;QACL,IAAI;YACF,OAAO,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;QAC7B,CAAC;QAED,GAAG,CAAC,EAAE;YACJ,OAAO,MAAM,CAAC,GAAG,CAAC,UAAU,EAAE,EAAE,CAAC,CAAA;QACnC,CAAC;KACF,CAAA;AACH,CAAC","sourcesContent":["import { StarlightClient } from '../../types'\nimport { MediaSelector } from './types'\n\nexport default function makeMediaSelector(\n client: StarlightClient\n): MediaSelector {\n return {\n list() {\n return client.get('/media')\n },\n\n get(id) {\n return client.get(`/media/${id}`)\n },\n }\n}\n\nexport { MediaSelector }\n"]}
|
|
@@ -1,6 +1,40 @@
|
|
|
1
1
|
import { MediaObject, StarlightItemResponse, StarlightListResponse } from '../../types';
|
|
2
|
+
/**
|
|
3
|
+
* A Selector that provide methods to list and request information on
|
|
4
|
+
* {@apilink MediaObject | MediaObjects}.
|
|
5
|
+
*
|
|
6
|
+
* You can use a MediaSelector by accessing
|
|
7
|
+
* {@apilink StarlightClient.media}.
|
|
8
|
+
*
|
|
9
|
+
* @group Selectors
|
|
10
|
+
*/
|
|
2
11
|
export interface MediaSelector {
|
|
3
|
-
|
|
12
|
+
/**
|
|
13
|
+
* Returns a {@link StarlightItemResponse} with a single {@link MediaObject}.
|
|
14
|
+
*
|
|
15
|
+
* Note: MediaObjects are identified by their IDs, since they don't have slugs.
|
|
16
|
+
*
|
|
17
|
+
* @example Requesting information from a media object of id "123456789".
|
|
18
|
+
* ```ts
|
|
19
|
+
* import Starlight from '@starlightcms/js-sdk'
|
|
20
|
+
*
|
|
21
|
+
* const response = await Starlight.media.get('123456789')
|
|
22
|
+
* ```
|
|
23
|
+
*
|
|
24
|
+
* @param id The media object ID.
|
|
25
|
+
*/
|
|
26
|
+
get(id: number | string): Promise<StarlightItemResponse<MediaObject>>;
|
|
27
|
+
/**
|
|
28
|
+
* Returns a {@link StarlightListResponse} with the list of
|
|
29
|
+
* {@apilink MediaObject | MediaObjects} in this workspace.
|
|
30
|
+
*
|
|
31
|
+
* @example Requesting all media objects from the workspace.
|
|
32
|
+
* ```ts
|
|
33
|
+
* import Starlight from '@starlightcms/js-sdk'
|
|
34
|
+
*
|
|
35
|
+
* const response = await Starlight.media.list()
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
4
38
|
list(): Promise<StarlightListResponse<MediaObject>>;
|
|
5
39
|
}
|
|
6
40
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/selectors/Media/types.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,qBAAqB,EACrB,qBAAqB,EACtB,MAAM,aAAa,CAAA;AAEpB,MAAM,WAAW,aAAa;IAC5B,GAAG,CAAC,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/selectors/Media/types.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,qBAAqB,EACrB,qBAAqB,EACtB,MAAM,aAAa,CAAA;AAEpB;;;;;;;;GAQG;AACH,MAAM,WAAW,aAAa;IAC5B;;;;;;;;;;;;;OAaG;IACH,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,qBAAqB,CAAC,WAAW,CAAC,CAAC,CAAA;IAErE;;;;;;;;;;OAUG;IACH,IAAI,IAAI,OAAO,CAAC,qBAAqB,CAAC,WAAW,CAAC,CAAC,CAAA;CACpD"}
|