@starlightcms/js-sdk 3.0.0 → 3.1.0-beta.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/dist/cjs/client.d.ts.map +1 -1
- package/dist/cjs/client.js +1 -1
- package/dist/cjs/client.js.map +1 -1
- package/dist/cjs/instances/Collection/index.js +4 -4
- package/dist/cjs/instances/Collection/index.js.map +1 -1
- package/dist/cjs/instances/Collection/types.d.ts +14 -6
- package/dist/cjs/instances/Collection/types.d.ts.map +1 -1
- package/dist/cjs/instances/Collection/types.js.map +1 -1
- package/dist/cjs/instances/Form/index.d.ts.map +1 -1
- package/dist/cjs/instances/Form/index.js +4 -4
- package/dist/cjs/instances/Form/index.js.map +1 -1
- package/dist/cjs/instances/Form/types.d.ts +12 -4
- package/dist/cjs/instances/Form/types.d.ts.map +1 -1
- package/dist/cjs/instances/Form/types.js.map +1 -1
- package/dist/cjs/instances/Model/index.d.ts.map +1 -1
- package/dist/cjs/instances/Model/index.js +2 -2
- package/dist/cjs/instances/Model/index.js.map +1 -1
- package/dist/cjs/instances/Model/types.d.ts +7 -2
- 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 +1 -1
- package/dist/cjs/instances/ModelCategory/index.d.ts.map +1 -1
- package/dist/cjs/instances/ModelCategory/index.js +4 -4
- package/dist/cjs/instances/ModelCategory/index.js.map +1 -1
- package/dist/cjs/instances/ModelCategory/types.d.ts +16 -7
- 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.js +4 -4
- package/dist/cjs/selectors/Collection/index.js.map +1 -1
- package/dist/cjs/selectors/Collection/types.d.ts +13 -6
- 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/index.d.ts.map +1 -1
- package/dist/cjs/selectors/Entry/index.js +6 -2
- package/dist/cjs/selectors/Entry/index.js.map +1 -1
- package/dist/cjs/selectors/Entry/types.d.ts +13 -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 +4 -4
- package/dist/cjs/selectors/Media/index.js.map +1 -1
- package/dist/cjs/selectors/Media/types.d.ts +12 -3
- 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 +1 -1
- package/dist/cjs/selectors/Model/index.d.ts.map +1 -1
- package/dist/cjs/selectors/Model/index.js +4 -4
- package/dist/cjs/selectors/Model/index.js.map +1 -1
- package/dist/cjs/selectors/Model/types.d.ts +12 -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 +1 -1
- package/dist/cjs/selectors/ModelCategory/index.d.ts.map +1 -1
- package/dist/cjs/selectors/ModelCategory/index.js +4 -4
- package/dist/cjs/selectors/ModelCategory/index.js.map +1 -1
- package/dist/cjs/selectors/ModelCategory/types.d.ts +13 -6
- 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.map +1 -1
- package/dist/cjs/selectors/Search/index.js +2 -2
- package/dist/cjs/selectors/Search/index.js.map +1 -1
- package/dist/cjs/selectors/Search/types.d.ts +8 -5
- 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/index.js +4 -4
- package/dist/cjs/selectors/Singleton/index.js.map +1 -1
- package/dist/cjs/selectors/Singleton/types.d.ts +12 -3
- 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/index.d.ts +10 -2
- package/dist/cjs/types/index.d.ts.map +1 -1
- package/dist/cjs/types/index.js.map +1 -1
- package/dist/esm/client.d.ts.map +1 -1
- package/dist/esm/client.js +1 -1
- package/dist/esm/client.js.map +1 -1
- package/dist/esm/instances/Collection/index.js +4 -4
- package/dist/esm/instances/Collection/index.js.map +1 -1
- package/dist/esm/instances/Collection/types.d.ts +14 -6
- package/dist/esm/instances/Collection/types.d.ts.map +1 -1
- package/dist/esm/instances/Collection/types.js.map +1 -1
- package/dist/esm/instances/Form/index.d.ts.map +1 -1
- package/dist/esm/instances/Form/index.js +4 -4
- package/dist/esm/instances/Form/index.js.map +1 -1
- package/dist/esm/instances/Form/types.d.ts +12 -4
- package/dist/esm/instances/Form/types.d.ts.map +1 -1
- package/dist/esm/instances/Form/types.js.map +1 -1
- package/dist/esm/instances/Model/index.d.ts.map +1 -1
- package/dist/esm/instances/Model/index.js +2 -2
- package/dist/esm/instances/Model/index.js.map +1 -1
- package/dist/esm/instances/Model/types.d.ts +7 -2
- 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 +1 -1
- package/dist/esm/instances/ModelCategory/index.d.ts.map +1 -1
- package/dist/esm/instances/ModelCategory/index.js +4 -4
- package/dist/esm/instances/ModelCategory/index.js.map +1 -1
- package/dist/esm/instances/ModelCategory/types.d.ts +16 -7
- 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.js +4 -4
- package/dist/esm/selectors/Collection/index.js.map +1 -1
- package/dist/esm/selectors/Collection/types.d.ts +13 -6
- 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/index.d.ts.map +1 -1
- package/dist/esm/selectors/Entry/index.js +6 -2
- package/dist/esm/selectors/Entry/index.js.map +1 -1
- package/dist/esm/selectors/Entry/types.d.ts +13 -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 +4 -4
- package/dist/esm/selectors/Media/index.js.map +1 -1
- package/dist/esm/selectors/Media/types.d.ts +12 -3
- 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 +1 -1
- package/dist/esm/selectors/Model/index.d.ts.map +1 -1
- package/dist/esm/selectors/Model/index.js +4 -4
- package/dist/esm/selectors/Model/index.js.map +1 -1
- package/dist/esm/selectors/Model/types.d.ts +12 -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 +1 -1
- package/dist/esm/selectors/ModelCategory/index.d.ts.map +1 -1
- package/dist/esm/selectors/ModelCategory/index.js +4 -4
- package/dist/esm/selectors/ModelCategory/index.js.map +1 -1
- package/dist/esm/selectors/ModelCategory/types.d.ts +13 -6
- 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.map +1 -1
- package/dist/esm/selectors/Search/index.js +2 -2
- package/dist/esm/selectors/Search/index.js.map +1 -1
- package/dist/esm/selectors/Search/types.d.ts +8 -5
- 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/index.js +4 -4
- package/dist/esm/selectors/Singleton/index.js.map +1 -1
- package/dist/esm/selectors/Singleton/types.d.ts +12 -3
- 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/index.d.ts +10 -2
- package/dist/esm/types/index.d.ts.map +1 -1
- package/dist/esm/types/index.js.map +1 -1
- package/package.json +1 -1
package/dist/cjs/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,sBAAsB,EACtB,sBAAsB,EAEtB,eAAe,EACf,wBAAwB,EACzB,MAAM,SAAS,CAAA;AAYhB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,wBAAgB,UAAU,CACxB,CAAC,SAAS,wBAAwB,GAAG,sBAAsB,EAE3D,MAAM,GAAE,eAAoB,GAC3B,sBAAsB,CAAC,CAAC,GAAG,wBAAwB,CAAC,
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,sBAAsB,EACtB,sBAAsB,EAEtB,eAAe,EACf,wBAAwB,EACzB,MAAM,SAAS,CAAA;AAYhB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,wBAAgB,UAAU,CACxB,CAAC,SAAS,wBAAwB,GAAG,sBAAsB,EAE3D,MAAM,GAAE,eAAoB,GAC3B,sBAAsB,CAAC,CAAC,GAAG,wBAAwB,CAAC,CAoGtD"}
|
package/dist/cjs/client.js
CHANGED
|
@@ -88,7 +88,7 @@ function makeClient(config = {}) {
|
|
|
88
88
|
return __awaiter(this, arguments, void 0, function* (path, params = {}, options) {
|
|
89
89
|
const filteredParams = Object.keys(params).reduce((accumulator, key) => {
|
|
90
90
|
const param = params[key];
|
|
91
|
-
if (param || param === false)
|
|
91
|
+
if (param || param === false || param === 0)
|
|
92
92
|
accumulator[key] = String(param);
|
|
93
93
|
return accumulator;
|
|
94
94
|
}, {});
|
package/dist/cjs/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/client.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAyDA,
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/client.ts"],"names":[],"mappings":"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","sourcesContent":["import {\n DefaultModelDefinition,\n DynamicStarlightClient,\n StarlightClient,\n StarlightConfig,\n WorkspaceModelDefinition,\n} from './types'\nimport { StarlightError } from './errors'\nimport makeModelSelector from './selectors/Model'\nimport makeModelInstance from './instances/Model'\nimport makeSingletonSelector from './selectors/Singleton'\nimport makeCollectionSelector from './selectors/Collection'\nimport makeMediaSelector from './selectors/Media'\nimport makeSearchSelector from './selectors/Search'\nimport makeCollectionInstance from './instances/Collection'\nimport makeFormSelector from './selectors/Form'\nimport makeFormInstance from './instances/Form'\n\n/**\n * Returns a new {@link DynamicStarlightClient}, which is a\n * {@link StarlightClient} with support to create\n * {@apilink ModelInstance | ModelInstances} using the dynamic syntax. To learn\n * which methods a client supports, see {@link StarlightClient}.\n *\n * This function accepts a {@link StarlightConfig} object and can be used to\n * create new clients that connect to a single Starlight workspace. Each client\n * returned by this function is separate and independent of the others.\n *\n * If you only need to make requests to a single workspace, it's probably easier\n * to use the SDK's default client. To use it, you only need to\n * import the default object exported by the SDK:\n *\n * ```ts\n * // `Starlight` below is the default StarlightClient.\n * import Starlight from '@starlightcms/js-sdk'\n * ```\n *\n * See {@link default} for more info on how to use the default client.\n *\n * @example Creating a new client and exporting it.\n * ```ts\n * import { makeStarlightClient } from '@starlightcms/js-sdk'\n *\n * const BlogClient = makeStarlightClient({\n * workspace: '123123123',\n * debug: true\n * })\n *\n * // Feel free to export the new client so your application can use it.\n * export default BlogClient\n * ```\n *\n * @param config The client configuration object. You need to provide at least\n * the `workspace` property. See {@link StarlightConfig} to view all the\n * available options.\n * @group Client\n */\nexport function makeClient<\n D extends WorkspaceModelDefinition = DefaultModelDefinition,\n>(\n config: StarlightConfig = {},\n): DynamicStarlightClient<D & WorkspaceModelDefinition> {\n let baseUrl = config.baseUrl ?? 'https://query.starlightcms.io/v2'\n let workspace = config.workspace ?? ''\n let debug = config.debug ?? false\n\n const client: StarlightClient = {\n configure(config) {\n baseUrl = config.baseUrl ?? baseUrl\n workspace = config.workspace ?? workspace\n debug = config.debug ?? debug\n },\n\n log(message, ...optionalParams) {\n if (debug) console.log(message, ...optionalParams)\n },\n\n getBaseUrl() {\n if (!workspace.length) {\n throw new Error(\n 'No workspace defined. Use the `configure()` method on the Starlight client to define one.',\n )\n }\n\n return `${baseUrl}/workspaces/${workspace}`\n },\n\n async get(path, params = {}, options) {\n const filteredParams = Object.keys(params).reduce(\n (accumulator, key) => {\n const param = params[key]\n\n if (param || param === false || param === 0)\n accumulator[key] = String(param)\n\n return accumulator\n },\n {} as Record<string, string>,\n )\n\n const searchParams = new URLSearchParams(filteredParams).toString()\n const finalPath = searchParams ? `${path}?${searchParams}` : path\n\n this.log(`Starlight - GET ${finalPath}`)\n\n const response = await fetch(`${this.getBaseUrl()}${finalPath}`, options)\n\n if (response.status >= 200 && response.status < 300) {\n return await response.json()\n } else {\n const message = `Starlight - GET ${path} returned ${response.status}: ${response.statusText}`\n throw new StarlightError(message, response)\n }\n },\n\n get models() {\n return makeModelSelector(this)\n },\n\n model(slug) {\n return makeModelInstance(this, slug as string)\n },\n\n get forms() {\n return makeFormSelector(this)\n },\n\n form(slug) {\n return makeFormInstance(this, String(slug))\n },\n\n get singletons() {\n return makeSingletonSelector(this)\n },\n\n get collections() {\n return makeCollectionSelector(this)\n },\n\n collection(slug) {\n return makeCollectionInstance(this, slug)\n },\n\n get media() {\n return makeMediaSelector(this)\n },\n\n get search() {\n return makeSearchSelector(this)\n },\n }\n\n return new Proxy(client, {\n get(target, prop) {\n if (typeof prop === 'string' && !Reflect.has(target, prop)) {\n return makeModelInstance(target, prop)\n }\n\n return Reflect.get(target, prop)\n },\n }) as DynamicStarlightClient<D & WorkspaceModelDefinition>\n}\n"]}
|
|
@@ -3,11 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.default = makeCollectionInstance;
|
|
4
4
|
function makeCollectionInstance(client, collection) {
|
|
5
5
|
return {
|
|
6
|
-
get() {
|
|
7
|
-
return client.get(`/collections/${collection}
|
|
6
|
+
get(params, options) {
|
|
7
|
+
return client.get(`/collections/${collection}`, params, options);
|
|
8
8
|
},
|
|
9
|
-
items(options) {
|
|
10
|
-
return client.get(`/collections/${collection}/items`, options);
|
|
9
|
+
items(params, options) {
|
|
10
|
+
return client.get(`/collections/${collection}/items`, params, options);
|
|
11
11
|
},
|
|
12
12
|
};
|
|
13
13
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/instances/Collection/index.ts"],"names":[],"mappings":";;AAGA,yCAYC;AAZD,SAAwB,sBAAsB,CAE5C,MAAuB,EAAE,UAA2B;IACpD,OAAO;QACL,GAAG;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/instances/Collection/index.ts"],"names":[],"mappings":";;AAGA,yCAYC;AAZD,SAAwB,sBAAsB,CAE5C,MAAuB,EAAE,UAA2B;IACpD,OAAO;QACL,GAAG,CAAC,MAAM,EAAE,OAAO;YACjB,OAAO,MAAM,CAAC,GAAG,CAAC,gBAAgB,UAAU,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,CAAA;QAClE,CAAC;QAED,KAAK,CAAC,MAAM,EAAE,OAAO;YACnB,OAAO,MAAM,CAAC,GAAG,CAAC,gBAAgB,UAAU,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,CAAA;QACxE,CAAC;KACF,CAAA;AACH,CAAC","sourcesContent":["import { CollectionEntityTypes, StarlightClient } from '../../types'\nimport { CollectionInstance, ListCollectionItemsParams } from './types'\n\nexport default function makeCollectionInstance<\n T extends CollectionEntityTypes = unknown,\n>(client: StarlightClient, collection: string | number): CollectionInstance<T> {\n return {\n get(params, options) {\n return client.get(`/collections/${collection}`, params, options)\n },\n\n items(params, options) {\n return client.get(`/collections/${collection}/items`, params, options)\n },\n }\n}\n\nexport { CollectionInstance, ListCollectionItemsParams }\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ListRequestParameters, Collection, CollectionEntityTypes, CollectionTypeMapper, QueryableRequestParameters, StarlightItemResponse, StarlightListResponse, WithQueryableFieldsOnModelables, BaseRequestParameters } from '../../types';
|
|
2
2
|
/**
|
|
3
3
|
* Request parameters for listing collection items.
|
|
4
4
|
*
|
|
@@ -6,7 +6,7 @@ import { BaseRequestParameters, Collection, CollectionEntityTypes, CollectionTyp
|
|
|
6
6
|
*
|
|
7
7
|
* @group Request Parameters
|
|
8
8
|
*/
|
|
9
|
-
export interface ListCollectionItemsParams extends
|
|
9
|
+
export interface ListCollectionItemsParams extends ListRequestParameters, QueryableRequestParameters {
|
|
10
10
|
/**
|
|
11
11
|
* Define how entries will be ordered. Check this field type to see the
|
|
12
12
|
* allowed options.
|
|
@@ -34,8 +34,13 @@ export interface CollectionInstance<C extends CollectionEntityTypes> {
|
|
|
34
34
|
*
|
|
35
35
|
* const response = await Starlight.collection('featured-news').get()
|
|
36
36
|
* ```
|
|
37
|
+
*
|
|
38
|
+
* @param params An optional object of request parameters.
|
|
39
|
+
* @param options An optional object of fetch options. See
|
|
40
|
+
* {@link https://developer.mozilla.org/en-US/docs/Web/API/RequestInit} for
|
|
41
|
+
* more info.
|
|
37
42
|
*/
|
|
38
|
-
get(): Promise<StarlightItemResponse<Collection<CollectionTypeMapper<C>>>>;
|
|
43
|
+
get(params?: BaseRequestParameters, options?: RequestInit): Promise<StarlightItemResponse<Collection<CollectionTypeMapper<C>>>>;
|
|
39
44
|
/**
|
|
40
45
|
* Returns a {@link StarlightListResponse} with the list of items of this
|
|
41
46
|
* {@link Collection}. The returned list type depends on the collection type:
|
|
@@ -62,10 +67,13 @@ export interface CollectionInstance<C extends CollectionEntityTypes> {
|
|
|
62
67
|
* const response = await Starlight.collection<Entry<NewsPostType>>('featured-news').items()
|
|
63
68
|
* ```
|
|
64
69
|
*
|
|
65
|
-
* @param
|
|
66
|
-
* {@link ListCollectionItemsParams} for all available
|
|
70
|
+
* @param params An optional object of request parameters. See
|
|
71
|
+
* {@link ListCollectionItemsParams} for all available parameters. `field:foo`
|
|
67
72
|
* syntax is also supported, see {@link QueryableFields} for more info.
|
|
73
|
+
* @param options An optional object of fetch options. See
|
|
74
|
+
* {@link https://developer.mozilla.org/en-US/docs/Web/API/RequestInit} for
|
|
75
|
+
* more info.
|
|
68
76
|
*/
|
|
69
|
-
items(
|
|
77
|
+
items(params?: ListCollectionItemsParams | WithQueryableFieldsOnModelables<C>, options?: RequestInit): Promise<StarlightListResponse<C>>;
|
|
70
78
|
}
|
|
71
79
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/instances/Collection/types.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,EACrB,UAAU,EACV,qBAAqB,EACrB,oBAAoB,EACpB,0BAA0B,EAC1B,qBAAqB,EACrB,qBAAqB,EACrB,+BAA+B,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/instances/Collection/types.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,EACrB,UAAU,EACV,qBAAqB,EACrB,oBAAoB,EACpB,0BAA0B,EAC1B,qBAAqB,EACrB,qBAAqB,EACrB,+BAA+B,EAC/B,qBAAqB,EACtB,MAAM,aAAa,CAAA;AAEpB;;;;;;GAMG;AACH,MAAM,WAAW,yBACf,SAAQ,qBAAqB,EAAE,0BAA0B;IACzD;;;OAGG;IACH,KAAK,CAAC,EACF,WAAW,GACX,YAAY,GACZ,kBAAkB,GAClB,mBAAmB,GACnB,WAAW,GACX,YAAY,CAAA;CACjB;AAED;;;;;;;;;;GAUG;AACH,MAAM,WAAW,kBAAkB,CAAC,CAAC,SAAS,qBAAqB;IACjE;;;;;;;;;;;;;;OAcG;IACH,GAAG,CACD,MAAM,CAAC,EAAE,qBAAqB,EAC9B,OAAO,CAAC,EAAE,WAAW,GACpB,OAAO,CAAC,qBAAqB,CAAC,UAAU,CAAC,oBAAoB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;IAEtE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAgCG;IACH,KAAK,CACH,MAAM,CAAC,EAAE,yBAAyB,GAAG,+BAA+B,CAAC,CAAC,CAAC,EACvE,OAAO,CAAC,EAAE,WAAW,GACpB,OAAO,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC,CAAA;CACrC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/instances/Collection/types.ts"],"names":[],"mappings":"","sourcesContent":["import {\n
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/instances/Collection/types.ts"],"names":[],"mappings":"","sourcesContent":["import {\n ListRequestParameters,\n Collection,\n CollectionEntityTypes,\n CollectionTypeMapper,\n QueryableRequestParameters,\n StarlightItemResponse,\n StarlightListResponse,\n WithQueryableFieldsOnModelables,\n BaseRequestParameters,\n} from '../../types'\n\n/**\n * Request parameters for listing collection items.\n *\n * Used by {@apilink CollectionInstance.items}.\n *\n * @group Request Parameters\n */\nexport interface ListCollectionItemsParams\n extends ListRequestParameters, 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 and items from\n * a specific {@link Collection}.\n *\n * You can access a CollectionInstance using\n * {@apilink StarlightClient.collection}.\n *\n * To list all workspace collections, use a {@link CollectionSelector}.\n *\n * @group Instances\n */\nexport interface CollectionInstance<C extends CollectionEntityTypes> {\n /**\n * Returns a {@link StarlightItemResponse} with a single {@link Collection}.\n *\n * @example Requesting information from a collection of slug `featured-news`.\n * ```ts\n * import Starlight from '@starlightcms/js-sdk'\n *\n * const response = await Starlight.collection('featured-news').get()\n * ```\n *\n * @param params An optional object of request parameters.\n * @param options An optional object of fetch options. See\n * {@link https://developer.mozilla.org/en-US/docs/Web/API/RequestInit} for\n * more info.\n */\n get(\n params?: BaseRequestParameters,\n options?: RequestInit,\n ): Promise<StarlightItemResponse<Collection<CollectionTypeMapper<C>>>>\n\n /**\n * Returns a {@link StarlightListResponse} with the list of items of this\n * {@link Collection}. The returned list type depends on the collection type:\n * a list of {@apilink Entry | Entries} for a collection of type `entry`, a\n * list of {@apilink MediaObject | MediaObjects} for a collection o type\n * `media`, and so on.\n *\n * If the given Collection is not typed, this method will return a response of\n * `StarlightListResponse<unknown>`.\n *\n * @example Requesting all items from an Entry collection of slug `featured-news`.\n * ```ts\n * import Starlight from '@starlightcms/js-sdk'\n *\n * const response = await Starlight.collection('featured-news').items()\n * ```\n *\n * @example Explicitly typing the returned items. Only possible in TypeScript.\n * ```ts\n * import Starlight from '@starlightcms/js-sdk'\n * import { NewsPostType } from '../types'\n *\n * // response will be StarlightListResponse<Entry<NewsPostType>>\n * const response = await Starlight.collection<Entry<NewsPostType>>('featured-news').items()\n * ```\n *\n * @param params An optional object of request parameters. See\n * {@link ListCollectionItemsParams} for all available parameters. `field:foo`\n * syntax is also supported, see {@link QueryableFields} for more info.\n * @param options An optional object of fetch options. See\n * {@link https://developer.mozilla.org/en-US/docs/Web/API/RequestInit} for\n * more info.\n */\n items(\n params?: ListCollectionItemsParams | WithQueryableFieldsOnModelables<C>,\n options?: RequestInit,\n ): Promise<StarlightListResponse<C>>\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/instances/Form/index.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/instances/Form/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAEtC,MAAM,CAAC,OAAO,UAAU,gBAAgB,CACtC,MAAM,EAAE,eAAe,EACvB,IAAI,EAAE,MAAM,GACX,YAAY,CASd;AAED,OAAO,EAAE,YAAY,EAAE,CAAA"}
|
|
@@ -3,11 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.default = makeFormInstance;
|
|
4
4
|
function makeFormInstance(client, form) {
|
|
5
5
|
return {
|
|
6
|
-
get() {
|
|
7
|
-
return client.get(`/forms/${form}
|
|
6
|
+
get(params, options) {
|
|
7
|
+
return client.get(`/forms/${form}`, params, options);
|
|
8
8
|
},
|
|
9
|
-
schema() {
|
|
10
|
-
return client.get(`/forms/${form}/schema
|
|
9
|
+
schema(params, options) {
|
|
10
|
+
return client.get(`/forms/${form}/schema`, params, options);
|
|
11
11
|
},
|
|
12
12
|
};
|
|
13
13
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/instances/Form/index.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/instances/Form/index.ts"],"names":[],"mappings":";;AAGA,mCAYC;AAZD,SAAwB,gBAAgB,CACtC,MAAuB,EACvB,IAAY;IAEZ,OAAO;QACL,GAAG,CAAC,MAAM,EAAE,OAAO;YACjB,OAAO,MAAM,CAAC,GAAG,CAAC,UAAU,IAAI,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,CAAA;QACtD,CAAC;QACD,MAAM,CAAC,MAAM,EAAE,OAAO;YACpB,OAAO,MAAM,CAAC,GAAG,CAAC,UAAU,IAAI,SAAS,EAAE,MAAM,EAAE,OAAO,CAAC,CAAA;QAC7D,CAAC;KACF,CAAA;AACH,CAAC","sourcesContent":["import { StarlightClient } from '../../types'\nimport { FormInstance } from './types'\n\nexport default function makeFormInstance(\n client: StarlightClient,\n form: string,\n): FormInstance {\n return {\n get(params, options) {\n return client.get(`/forms/${form}`, params, options)\n },\n schema(params, options) {\n return client.get(`/forms/${form}/schema`, params, options)\n },\n }\n}\n\nexport { FormInstance }\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Form, FormSchema, StarlightItemResponse } from '../../types';
|
|
1
|
+
import { BaseRequestParameters, Form, FormSchema, StarlightItemResponse } from '../../types';
|
|
2
2
|
/**
|
|
3
3
|
* An Instance that provide methods to request information from a {@link Form}
|
|
4
4
|
* and its {@apilink Field | Fields}.
|
|
@@ -19,8 +19,13 @@ export interface FormInstance {
|
|
|
19
19
|
*
|
|
20
20
|
* const response = await Starlight.forms.signup.get()
|
|
21
21
|
* ```
|
|
22
|
+
*
|
|
23
|
+
* @param params An optional object of request parameters.
|
|
24
|
+
* @param options An optional object of fetch options. See
|
|
25
|
+
* {@link https://developer.mozilla.org/en-US/docs/Web/API/RequestInit} for
|
|
26
|
+
* more info.
|
|
22
27
|
*/
|
|
23
|
-
get(): Promise<StarlightItemResponse<Form>>;
|
|
28
|
+
get(params?: BaseRequestParameters, options?: RequestInit): Promise<StarlightItemResponse<Form>>;
|
|
24
29
|
/**
|
|
25
30
|
* Returns a {@link StarlightItemResponse} with a {@link FormSchema}.
|
|
26
31
|
*
|
|
@@ -31,8 +36,11 @@ export interface FormInstance {
|
|
|
31
36
|
* const response = await Starlight.forms.signup.schema()
|
|
32
37
|
* ```
|
|
33
38
|
*
|
|
34
|
-
* @param
|
|
39
|
+
* @param params An optional object of request parameters.
|
|
40
|
+
* @param options An optional object of fetch options. See
|
|
41
|
+
* {@link https://developer.mozilla.org/en-US/docs/Web/API/RequestInit} for
|
|
42
|
+
* more info.
|
|
35
43
|
*/
|
|
36
|
-
schema(): Promise<StarlightItemResponse<FormSchema>>;
|
|
44
|
+
schema(params?: BaseRequestParameters, options?: RequestInit): Promise<StarlightItemResponse<FormSchema>>;
|
|
37
45
|
}
|
|
38
46
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/instances/Form/types.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/instances/Form/types.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,EACrB,IAAI,EACJ,UAAU,EACV,qBAAqB,EACtB,MAAM,aAAa,CAAA;AAEpB;;;;;;;;;GASG;AACH,MAAM,WAAW,YAAY;IAC3B;;;;;;;;;;;;;;OAcG;IACH,GAAG,CACD,MAAM,CAAC,EAAE,qBAAqB,EAC9B,OAAO,CAAC,EAAE,WAAW,GACpB,OAAO,CAAC,qBAAqB,CAAC,IAAI,CAAC,CAAC,CAAA;IAEvC;;;;;;;;;;;;;;OAcG;IACH,MAAM,CACJ,MAAM,CAAC,EAAE,qBAAqB,EAC9B,OAAO,CAAC,EAAE,WAAW,GACpB,OAAO,CAAC,qBAAqB,CAAC,UAAU,CAAC,CAAC,CAAA;CAC9C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/instances/Form/types.ts"],"names":[],"mappings":"","sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/instances/Form/types.ts"],"names":[],"mappings":"","sourcesContent":["import {\n BaseRequestParameters,\n Form,\n FormSchema,\n StarlightItemResponse,\n} from '../../types'\n\n/**\n * An Instance that provide methods to request information from a {@link Form}\n * and its {@apilink Field | Fields}.\n *\n * You can access a FormInstance using {@apilink StarlightClient.form} or\n * using the dynamic syntax on a {@link DynamicFormSelector}. Usage\n * examples will use the dynamic syntax.\n *\n * @group Instances\n */\nexport interface FormInstance {\n /**\n * Returns a {@link StarlightItemResponse} with a single {@link Form}.\n *\n * @example Requesting information from a form of slug `signup`.\n * ```ts\n * import Starlight from '@starlightcms/js-sdk'\n *\n * const response = await Starlight.forms.signup.get()\n * ```\n *\n * @param params An optional object of request parameters.\n * @param options An optional object of fetch options. See\n * {@link https://developer.mozilla.org/en-US/docs/Web/API/RequestInit} for\n * more info.\n */\n get(\n params?: BaseRequestParameters,\n options?: RequestInit,\n ): Promise<StarlightItemResponse<Form>>\n\n /**\n * Returns a {@link StarlightItemResponse} with a {@link FormSchema}.\n *\n * @example Listing the schema from a form of slug `signup`.\n * ```ts\n * import Starlight from '@starlightcms/js-sdk'\n *\n * const response = await Starlight.forms.signup.schema()\n * ```\n *\n * @param params An optional object of request parameters.\n * @param options An optional object of fetch options. See\n * {@link https://developer.mozilla.org/en-US/docs/Web/API/RequestInit} for\n * more info.\n */\n schema(\n params?: BaseRequestParameters,\n options?: RequestInit,\n ): Promise<StarlightItemResponse<FormSchema>>\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/instances/Model/index.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/instances/Model/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAC7D,OAAO,EAAE,oBAAoB,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAK7D,MAAM,CAAC,OAAO,UAAU,iBAAiB,CAAC,CAAC,SAAS,cAAc,EAChE,MAAM,EAAE,eAAe,EACvB,KAAK,EAAE,MAAM,GACZ,oBAAoB,CAAC,CAAC,CAAC,CA4BzB;AAED,OAAO,EAAE,oBAAoB,EAAE,aAAa,EAAE,CAAA"}
|
|
@@ -9,8 +9,8 @@ const ModelCategory_1 = __importDefault(require("../../selectors/ModelCategory")
|
|
|
9
9
|
const ModelCategory_2 = __importDefault(require("../ModelCategory"));
|
|
10
10
|
function makeModelInstance(client, model) {
|
|
11
11
|
const instance = {
|
|
12
|
-
get() {
|
|
13
|
-
return client.get(`/models/${model}
|
|
12
|
+
get(params, options) {
|
|
13
|
+
return client.get(`/models/${model}`, params, options);
|
|
14
14
|
},
|
|
15
15
|
category(slug) {
|
|
16
16
|
return (0, ModelCategory_2.default)(client, model, slug);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/instances/Model/index.ts"],"names":[],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/instances/Model/index.ts"],"names":[],"mappings":";;;;;AAMA,oCA+BC;AAnCD,kEAAqD;AACrD,kFAAqE;AACrE,qEAAwD;AAExD,SAAwB,iBAAiB,CACvC,MAAuB,EACvB,KAAa;IAEb,MAAM,QAAQ,GAAqB;QACjC,GAAG,CAAC,MAAM,EAAE,OAAO;YACjB,OAAO,MAAM,CAAC,GAAG,CAAC,WAAW,KAAK,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,CAAA;QACxD,CAAC;QAED,QAAQ,CAAC,IAAY;YACnB,OAAO,IAAA,uBAAyB,EAAI,MAAM,EAAE,KAAK,EAAE,IAAI,CAAC,CAAA;QAC1D,CAAC;QAED,IAAI,OAAO;YACT,OAAO,IAAA,eAAiB,EAAI,MAAM,EAAE,KAAK,CAAC,CAAA;QAC5C,CAAC;QAED,IAAI,UAAU;YACZ,OAAO,IAAA,uBAAyB,EAAI,MAAM,EAAE,KAAK,CAAC,CAAA;QACpD,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,CAAC;gBAC3D,OAAO,IAAA,uBAAyB,EAAC,MAAM,EAAE,KAAK,EAAE,IAAI,CAAC,CAAA;YACvD,CAAC;YAED,OAAO,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,CAAA;QAClC,CAAC;KACF,CAA4B,CAAA;AAC/B,CAAC","sourcesContent":["import { SerializedData, StarlightClient } from '../../types'\nimport { DynamicModelInstance, ModelInstance } from './types'\nimport makeEntrySelector from '../../selectors/Entry'\nimport makeModelCategorySelector from '../../selectors/ModelCategory'\nimport makeModelCategoryInstance from '../ModelCategory'\n\nexport default function makeModelInstance<D extends SerializedData>(\n client: StarlightClient,\n model: string,\n): DynamicModelInstance<D> {\n const instance: ModelInstance<D> = {\n get(params, options) {\n return client.get(`/models/${model}`, params, options)\n },\n\n category(slug: string) {\n return makeModelCategoryInstance<D>(client, model, slug)\n },\n\n get entries() {\n return makeEntrySelector<D>(client, model)\n },\n\n get categories() {\n return makeModelCategorySelector<D>(client, model)\n },\n }\n\n return new Proxy(instance, {\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 DynamicModelInstance<D>\n}\n\nexport { DynamicModelInstance, ModelInstance }\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Model, SerializedData, StarlightItemResponse } from '../../types';
|
|
1
|
+
import { BaseRequestParameters, Model, SerializedData, StarlightItemResponse } from '../../types';
|
|
2
2
|
import { EntrySelector } from '../../selectors/Entry';
|
|
3
3
|
import { DynamicModelCategorySelector } from '../../selectors/ModelCategory';
|
|
4
4
|
import { ModelCategoryInstance } from '../ModelCategory';
|
|
@@ -24,8 +24,13 @@ export interface ModelInstance<D extends SerializedData> {
|
|
|
24
24
|
*
|
|
25
25
|
* const response = await Starlight.posts.get()
|
|
26
26
|
* ```
|
|
27
|
+
*
|
|
28
|
+
* @param params An optional object of request parameters.
|
|
29
|
+
* @param options An optional object of fetch options. See
|
|
30
|
+
* {@link https://developer.mozilla.org/en-US/docs/Web/API/RequestInit} for
|
|
31
|
+
* more info.
|
|
27
32
|
*/
|
|
28
|
-
get(): Promise<StarlightItemResponse<Model>>;
|
|
33
|
+
get(params?: BaseRequestParameters, options?: RequestInit): Promise<StarlightItemResponse<Model>>;
|
|
29
34
|
/**
|
|
30
35
|
* Returns a {@link ModelCategoryInstance}.
|
|
31
36
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/instances/Model/types.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/instances/Model/types.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,EACrB,KAAK,EACL,cAAc,EACd,qBAAqB,EACtB,MAAM,aAAa,CAAA;AACpB,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;;;;;;;;;;;;;;OAcG;IACH,GAAG,CACD,MAAM,CAAC,EAAE,qBAAqB,EAC9B,OAAO,CAAC,EAAE,WAAW,GACpB,OAAO,CAAC,qBAAqB,CAAC,KAAK,CAAC,CAAC,CAAA;IAExC;;;;;;;;;;;;;;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,MAAM,MAAM,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 {
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/instances/Model/types.ts"],"names":[],"mappings":"","sourcesContent":["import {\n BaseRequestParameters,\n Model,\n SerializedData,\n StarlightItemResponse,\n} 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 * @param params An optional object of request parameters.\n * @param options An optional object of fetch options. See\n * {@link https://developer.mozilla.org/en-US/docs/Web/API/RequestInit} for\n * more info.\n */\n get(\n params?: BaseRequestParameters,\n options?: RequestInit,\n ): 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 {
|
|
2
|
+
import { ModelCategoryEntryListParams, ModelCategoryInstance } from './types';
|
|
3
3
|
export default function makeModelCategoryInstance<D extends SerializedData>(client: StarlightClient, model: string, category: string): ModelCategoryInstance<D>;
|
|
4
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,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAC7D,OAAO,EAAE,4BAA4B,EAAE,qBAAqB,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,CAiB1B;AAED,OAAO,EAAE,qBAAqB,EAAE,4BAA4B,EAAE,CAAA"}
|
|
@@ -3,11 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.default = makeModelCategoryInstance;
|
|
4
4
|
function makeModelCategoryInstance(client, model, category) {
|
|
5
5
|
return {
|
|
6
|
-
get() {
|
|
7
|
-
return client.get(`/models/${model}/categories/${category}
|
|
6
|
+
get(params, options) {
|
|
7
|
+
return client.get(`/models/${model}/categories/${category}`, params, options);
|
|
8
8
|
},
|
|
9
|
-
entries(options) {
|
|
10
|
-
return client.get(`/models/${model}/categories/${category}/entries`, options);
|
|
9
|
+
entries(params, options) {
|
|
10
|
+
return client.get(`/models/${model}/categories/${category}/entries`, params, options);
|
|
11
11
|
},
|
|
12
12
|
};
|
|
13
13
|
}
|
|
@@ -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":";;AAGA,4CAqBC;AArBD,SAAwB,yBAAyB,CAC/C,MAAuB,EACvB,KAAa,EACb,QAAgB;IAEhB,OAAO;QACL,GAAG,CAAC,MAAM,EAAE,OAAO;YACjB,OAAO,MAAM,CAAC,GAAG,CACf,WAAW,KAAK,eAAe,QAAQ,EAAE,EACzC,MAAM,EACN,OAAO,CACR,CAAA;QACH,CAAC;QACD,OAAO,CAAC,MAAM,EAAE,OAAO;YACrB,OAAO,MAAM,CAAC,GAAG,CACf,WAAW,KAAK,eAAe,QAAQ,UAAU,EACjD,MAAM,EACN,OAAO,CACR,CAAA;QACH,CAAC;KACF,CAAA;AACH,CAAC","sourcesContent":["import { SerializedData, StarlightClient } from '../../types'\nimport { ModelCategoryEntryListParams, ModelCategoryInstance } 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(params, options) {\n return client.get(\n `/models/${model}/categories/${category}`,\n params,\n options,\n )\n },\n entries(params, options) {\n return client.get(\n `/models/${model}/categories/${category}/entries`,\n params,\n options,\n )\n },\n }\n}\n\nexport { ModelCategoryInstance, ModelCategoryEntryListParams }\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ListRequestParameters, Entry, ModelCategory, QueryableFields, QueryableRequestParameters, SerializedData, StarlightItemResponse, StarlightListResponse, BaseRequestParameters } from '../../types';
|
|
2
2
|
/**
|
|
3
3
|
* Request parameters for listing category entries.
|
|
4
4
|
*
|
|
@@ -6,7 +6,7 @@ import { BaseRequestParameters, Entry, ModelCategory, QueryableFields, Queryable
|
|
|
6
6
|
*
|
|
7
7
|
* @group Request Parameters
|
|
8
8
|
*/
|
|
9
|
-
export interface ModelCategoryEntryListParams extends
|
|
9
|
+
export interface ModelCategoryEntryListParams extends ListRequestParameters, QueryableRequestParameters {
|
|
10
10
|
/**
|
|
11
11
|
* Define how entries will be ordered. Check this field type to see the
|
|
12
12
|
* allowed options.
|
|
@@ -35,8 +35,13 @@ export interface ModelCategoryInstance<D extends SerializedData> {
|
|
|
35
35
|
*
|
|
36
36
|
* const response = await Starlight.posts.articles.get()
|
|
37
37
|
* ```
|
|
38
|
+
*
|
|
39
|
+
* @param params An optional object of request parameters.
|
|
40
|
+
* @param options An optional object of fetch options. See
|
|
41
|
+
* {@link https://developer.mozilla.org/en-US/docs/Web/API/RequestInit} for
|
|
42
|
+
* more info.
|
|
38
43
|
*/
|
|
39
|
-
get(): Promise<StarlightItemResponse<ModelCategory>>;
|
|
44
|
+
get(params?: BaseRequestParameters, options?: RequestInit): Promise<StarlightItemResponse<ModelCategory>>;
|
|
40
45
|
/**
|
|
41
46
|
* Returns a {@link StarlightListResponse} with the list of entries of this
|
|
42
47
|
* {@link ModelCategory}.
|
|
@@ -58,10 +63,14 @@ export interface ModelCategoryInstance<D extends SerializedData> {
|
|
|
58
63
|
* })
|
|
59
64
|
* ```
|
|
60
65
|
*
|
|
61
|
-
* @param
|
|
62
|
-
* {@link ModelCategoryEntryListParams} for all available
|
|
63
|
-
* syntax is also supported, see {@link QueryableFields}
|
|
66
|
+
* @param params An optional object of request parameters. See
|
|
67
|
+
* {@link ModelCategoryEntryListParams} for all available parameters.
|
|
68
|
+
* `field:foo` syntax is also supported, see {@link QueryableFields}
|
|
69
|
+
* for more info.
|
|
70
|
+
* @param options An optional object of fetch options. See
|
|
71
|
+
* {@link https://developer.mozilla.org/en-US/docs/Web/API/RequestInit} for
|
|
72
|
+
* more info.
|
|
64
73
|
*/
|
|
65
|
-
entries(
|
|
74
|
+
entries(params?: ModelCategoryEntryListParams & QueryableFields<D>, options?: RequestInit): Promise<StarlightListResponse<Entry<D>>>;
|
|
66
75
|
}
|
|
67
76
|
//# 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,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,
|
|
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,EACrB,qBAAqB,EACtB,MAAM,aAAa,CAAA;AAEpB;;;;;;GAMG;AACH,MAAM,WAAW,4BACf,SAAQ,qBAAqB,EAAE,0BAA0B;IACzD;;;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;;;;;;;;;;;;;;OAcG;IACH,GAAG,CACD,MAAM,CAAC,EAAE,qBAAqB,EAC9B,OAAO,CAAC,EAAE,WAAW,GACpB,OAAO,CAAC,qBAAqB,CAAC,aAAa,CAAC,CAAC,CAAA;IAEhD;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA4BG;IACH,OAAO,CACL,MAAM,CAAC,EAAE,4BAA4B,GAAG,eAAe,CAAC,CAAC,CAAC,EAC1D,OAAO,CAAC,EAAE,WAAW,GACpB,OAAO,CAAC,qBAAqB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;CAC5C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/instances/ModelCategory/types.ts"],"names":[],"mappings":"","sourcesContent":["import {\n
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/instances/ModelCategory/types.ts"],"names":[],"mappings":"","sourcesContent":["import {\n ListRequestParameters,\n Entry,\n ModelCategory,\n QueryableFields,\n QueryableRequestParameters,\n SerializedData,\n StarlightItemResponse,\n StarlightListResponse,\n BaseRequestParameters,\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 ListRequestParameters, 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 * @param params An optional object of request parameters.\n * @param options An optional object of fetch options. See\n * {@link https://developer.mozilla.org/en-US/docs/Web/API/RequestInit} for\n * more info.\n */\n get(\n params?: BaseRequestParameters,\n options?: RequestInit,\n ): 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 params An optional object of request parameters. See\n * {@link ModelCategoryEntryListParams} for all available parameters.\n * `field:foo` syntax is also supported, see {@link QueryableFields}\n * for more info.\n * @param options An optional object of fetch options. See\n * {@link https://developer.mozilla.org/en-US/docs/Web/API/RequestInit} for\n * more info.\n */\n entries(\n params?: ModelCategoryEntryListParams & QueryableFields<D>,\n options?: RequestInit,\n ): Promise<StarlightListResponse<Entry<D>>>\n}\n"]}
|
|
@@ -7,11 +7,11 @@ exports.default = makeCollectionSelector;
|
|
|
7
7
|
const Collection_1 = __importDefault(require("../../instances/Collection"));
|
|
8
8
|
function makeCollectionSelector(client) {
|
|
9
9
|
const selector = {
|
|
10
|
-
list(options) {
|
|
11
|
-
return client.get('/collections',
|
|
10
|
+
list(params, options) {
|
|
11
|
+
return client.get('/collections', params, options);
|
|
12
12
|
},
|
|
13
|
-
get(slug) {
|
|
14
|
-
return client.get(`/collections/${slug}
|
|
13
|
+
get(slug, params, options) {
|
|
14
|
+
return client.get(`/collections/${slug}`, params, options);
|
|
15
15
|
},
|
|
16
16
|
};
|
|
17
17
|
return new Proxy(selector, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/selectors/Collection/index.ts"],"names":[],"mappings":";;;;;AAQA,yCAsBC;AAxBD,4EAA+D;AAE/D,SAAwB,sBAAsB,CAC5C,MAAuB;IAEvB,MAAM,QAAQ,GAAuB;QACnC,IAAI,CAAC,OAAO;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/selectors/Collection/index.ts"],"names":[],"mappings":";;;;;AAQA,yCAsBC;AAxBD,4EAA+D;AAE/D,SAAwB,sBAAsB,CAC5C,MAAuB;IAEvB,MAAM,QAAQ,GAAuB;QACnC,IAAI,CAAC,MAAM,EAAE,OAAO;YAClB,OAAO,MAAM,CAAC,GAAG,CAAC,cAAc,EAAE,MAAM,EAAE,OAAO,CAAC,CAAA;QACpD,CAAC;QAED,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO;YACvB,OAAO,MAAM,CAAC,GAAG,CAAC,gBAAgB,IAAI,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,CAAA;QAC5D,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,CAAC;gBAC3D,OAAO,IAAA,oBAAsB,EAAC,MAAM,EAAE,IAAI,CAAC,CAAA;YAC7C,CAAC;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(params, options) {\n return client.get('/collections', params, options)\n },\n\n get(slug, params, options) {\n return client.get(`/collections/${slug}`, params, options)\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,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ListRequestParameters, Collection, StarlightItemResponse, StarlightListResponse, BaseRequestParameters } from '../../types';
|
|
2
2
|
import { CollectionInstance } from '../../instances/Collection';
|
|
3
3
|
/**
|
|
4
4
|
* Request parameters for listing collections.
|
|
@@ -7,7 +7,7 @@ import { CollectionInstance } from '../../instances/Collection';
|
|
|
7
7
|
*
|
|
8
8
|
* @group Request Parameters
|
|
9
9
|
*/
|
|
10
|
-
export interface ListCollectionsParams extends
|
|
10
|
+
export interface ListCollectionsParams extends ListRequestParameters {
|
|
11
11
|
/**
|
|
12
12
|
* Define how items will be ordered. Check this field type to see the
|
|
13
13
|
* allowed options.
|
|
@@ -47,10 +47,13 @@ export interface CollectionSelector {
|
|
|
47
47
|
* })
|
|
48
48
|
* ```
|
|
49
49
|
*
|
|
50
|
-
* @param
|
|
51
|
-
* {@link ListCollectionsParams} for all available
|
|
50
|
+
* @param params An optional object of request parameters. See
|
|
51
|
+
* {@link ListCollectionsParams} for all available parameters.
|
|
52
|
+
* @param options An optional object of fetch options. See
|
|
53
|
+
* {@link https://developer.mozilla.org/en-US/docs/Web/API/RequestInit} for
|
|
54
|
+
* more info.
|
|
52
55
|
*/
|
|
53
|
-
list(options?:
|
|
56
|
+
list(params?: ListCollectionsParams, options?: RequestInit): Promise<StarlightListResponse<Collection>>;
|
|
54
57
|
/**
|
|
55
58
|
* Returns a {@link StarlightItemResponse} with a single {@link Collection}.
|
|
56
59
|
*
|
|
@@ -62,8 +65,12 @@ export interface CollectionSelector {
|
|
|
62
65
|
* ```
|
|
63
66
|
*
|
|
64
67
|
* @param slug The collection slug.
|
|
68
|
+
* @param params An optional object of request parameters.
|
|
69
|
+
* @param options An optional object of fetch options. See
|
|
70
|
+
* {@link https://developer.mozilla.org/en-US/docs/Web/API/RequestInit} for
|
|
71
|
+
* more info.
|
|
65
72
|
*/
|
|
66
|
-
get(slug: string | number): Promise<StarlightItemResponse<Collection>>;
|
|
73
|
+
get(slug: string | number, params?: BaseRequestParameters, options?: RequestInit): Promise<StarlightItemResponse<Collection>>;
|
|
67
74
|
}
|
|
68
75
|
/**
|
|
69
76
|
* A Selector that provide all {@link CollectionSelector} methods and adds
|
|
@@ -1 +1 @@
|
|
|
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
|
|
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,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;;;;;;;;;;;;;;;;;;;;;;;;;;OA0BG;IACH,IAAI,CACF,MAAM,CAAC,EAAE,qBAAqB,EAC9B,OAAO,CAAC,EAAE,WAAW,GACpB,OAAO,CAAC,qBAAqB,CAAC,UAAU,CAAC,CAAC,CAAA;IAE7C;;;;;;;;;;;;;;;OAeG;IACH,GAAG,CACD,IAAI,EAAE,MAAM,GAAG,MAAM,EACrB,MAAM,CAAC,EAAE,qBAAqB,EAC9B,OAAO,CAAC,EAAE,WAAW,GACpB,OAAO,CAAC,qBAAqB,CAAC,UAAU,CAAC,CAAC,CAAA;CAC9C;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,MAAM,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
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/selectors/Collection/types.ts"],"names":[],"mappings":"","sourcesContent":["import {\n ListRequestParameters,\n Collection,\n StarlightItemResponse,\n StarlightListResponse,\n BaseRequestParameters,\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 ListRequestParameters {\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 params An optional object of request parameters. See\n * {@link ListCollectionsParams} for all available parameters.\n * @param options An optional object of fetch options. See\n * {@link https://developer.mozilla.org/en-US/docs/Web/API/RequestInit} for\n * more info.\n */\n list(\n params?: ListCollectionsParams,\n options?: RequestInit,\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 * @param params An optional object of request parameters.\n * @param options An optional object of fetch options. See\n * {@link https://developer.mozilla.org/en-US/docs/Web/API/RequestInit} for\n * more info.\n */\n get(\n slug: string | number,\n params?: BaseRequestParameters,\n options?: RequestInit,\n ): 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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/selectors/Entry/index.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/selectors/Entry/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAC7D,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAO1D,MAAM,CAAC,OAAO,UAAU,iBAAiB,CAAC,CAAC,SAAS,cAAc,EAChE,MAAM,EAAE,eAAe,EACvB,KAAK,EAAE,MAAM,GACZ,aAAa,CAAC,CAAC,CAAC,CAUlB;AAED,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,CAAA"}
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.default = makeEntrySelector;
|
|
4
|
+
// TODO continuar adicionando params e options em todas as requisições, ver janela Find abaixo
|
|
5
|
+
// TODO talvez tenha que adicionar as opções de cache adicionais do Next nos tipos do next-sdk? verificar
|
|
6
|
+
// TODO lançar versão 3.1.0 de todos os sdks
|
|
7
|
+
// TODO continuar os-template passando cache pras opções do fetch
|
|
4
8
|
function makeEntrySelector(client, model) {
|
|
5
9
|
return {
|
|
6
|
-
list(options) {
|
|
7
|
-
return client.get(`/models/${model}/entries`, options);
|
|
10
|
+
list(params, options) {
|
|
11
|
+
return client.get(`/models/${model}/entries`, params, options);
|
|
8
12
|
},
|
|
9
13
|
get(slug, params, options) {
|
|
10
14
|
return client.get(`/models/${model}/entries/${slug}`, params, options);
|