@starlightcms/js-sdk 0.8.0 → 0.10.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 +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 +12 -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 +21 -1
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +20 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/instances/Collection/index.d.ts +2 -2
- 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 +49 -5
- 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/Model/index.d.ts +3 -3
- package/dist/cjs/instances/Model/index.d.ts.map +1 -1
- package/dist/cjs/instances/Model/index.js +9 -1
- package/dist/cjs/instances/Model/index.js.map +1 -1
- package/dist/cjs/instances/Model/types.d.ts +5 -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/selectors/Collection/index.d.ts +3 -3
- package/dist/cjs/selectors/Collection/index.js.map +1 -1
- package/dist/cjs/selectors/Collection/types.d.ts +2 -2
- 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/Model/index.d.ts +3 -3
- package/dist/cjs/selectors/Model/index.js.map +1 -1
- package/dist/cjs/selectors/Model/types.d.ts +3 -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.map +1 -1
- package/dist/cjs/selectors/ModelCategory/types.d.ts +1 -1
- package/dist/cjs/selectors/ModelCategory/types.js.map +1 -1
- package/dist/cjs/types/entities.d.ts +158 -0
- 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 +424 -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 +12 -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 +21 -1
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +20 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/instances/Collection/index.d.ts +2 -2
- 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 +49 -5
- 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/Model/index.d.ts +3 -3
- package/dist/esm/instances/Model/index.d.ts.map +1 -1
- package/dist/esm/instances/Model/index.js +9 -1
- package/dist/esm/instances/Model/index.js.map +1 -1
- package/dist/esm/instances/Model/types.d.ts +5 -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/selectors/Collection/index.d.ts +3 -3
- package/dist/esm/selectors/Collection/index.js.map +1 -1
- package/dist/esm/selectors/Collection/types.d.ts +2 -2
- 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/Model/index.d.ts +3 -3
- package/dist/esm/selectors/Model/index.js.map +1 -1
- package/dist/esm/selectors/Model/types.d.ts +3 -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.map +1 -1
- package/dist/esm/selectors/ModelCategory/types.d.ts +1 -1
- package/dist/esm/selectors/ModelCategory/types.js.map +1 -1
- package/dist/esm/types/entities.d.ts +158 -0
- 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 +424 -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
package/dist/cjs/client.d.ts
CHANGED
|
@@ -1,3 +1,42 @@
|
|
|
1
|
-
import { DefaultModelDefinition,
|
|
2
|
-
|
|
1
|
+
import { DefaultModelDefinition, DynamicStarlightClient, StarlightConfig, WorkspaceModelDefinition } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Returns a new {@link DynamicStarlightClient}, which is a
|
|
4
|
+
* {@link StarlightClient} with support to create
|
|
5
|
+
* {@apilink ModelInstance | ModelInstances} using the dynamic syntax. To learn
|
|
6
|
+
* which methods a client supports, see {@link StarlightClient}.
|
|
7
|
+
*
|
|
8
|
+
* This function accepts a {@link StarlightConfig} object and can be used to
|
|
9
|
+
* create new clients that connect to a single Starlight workspace. Each client
|
|
10
|
+
* returned by this function is separate and independent from the others.
|
|
11
|
+
*
|
|
12
|
+
* If you only need to make requests to a single workspace, it's probably easier
|
|
13
|
+
* to use the SDK's default client. To use the default client, you only need to
|
|
14
|
+
* import the default object exported by the SDK:
|
|
15
|
+
*
|
|
16
|
+
* ```ts
|
|
17
|
+
* // `Starlight` below is the default StarlightClient.
|
|
18
|
+
* import Starlight from '@starlightcms/js-sdk'
|
|
19
|
+
* ```
|
|
20
|
+
*
|
|
21
|
+
* See {@link default} for more info on how to use the default client.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* Creating a new client and exporting it.
|
|
25
|
+
* ```ts
|
|
26
|
+
* import { makeStarlightClient } from '@starlightcms/js-sdk'
|
|
27
|
+
*
|
|
28
|
+
* const BlogClient = makeStarlightClient({
|
|
29
|
+
* workspace: '123123123'
|
|
30
|
+
* })
|
|
31
|
+
*
|
|
32
|
+
* // Feel free to export the new client so your application can use it.
|
|
33
|
+
* export default BlogClient
|
|
34
|
+
* ```
|
|
35
|
+
*
|
|
36
|
+
* @param config The client configuration object. You need to provide at least
|
|
37
|
+
* the `workspace` property. See {@link StarlightConfig} to view all the
|
|
38
|
+
* available options.
|
|
39
|
+
* @group Client
|
|
40
|
+
*/
|
|
41
|
+
export declare function makeClient<D extends WorkspaceModelDefinition = DefaultModelDefinition>(config?: StarlightConfig): DynamicStarlightClient<D>;
|
|
3
42
|
//# sourceMappingURL=client.d.ts.map
|
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;AAUhB,wBAAgB,UAAU,CACxB,CAAC,SAAS,wBAAwB,GAAG,sBAAsB,EAC3D,MAAM,GAAE,eAAoB,GAAG,sBAAsB,CAAC,CAAC,CAAC,CAkFzD"}
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,sBAAsB,EACtB,sBAAsB,EAEtB,eAAe,EACf,wBAAwB,EACzB,MAAM,SAAS,CAAA;AAUhB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,wBAAgB,UAAU,CACxB,CAAC,SAAS,wBAAwB,GAAG,sBAAsB,EAC3D,MAAM,GAAE,eAAoB,GAAG,sBAAsB,CAAC,CAAC,CAAC,CAkFzD"}
|
package/dist/cjs/client.js
CHANGED
|
@@ -21,6 +21,45 @@ const Collection_1 = __importDefault(require("./selectors/Collection"));
|
|
|
21
21
|
const Media_1 = __importDefault(require("./selectors/Media"));
|
|
22
22
|
const Search_1 = __importDefault(require("./selectors/Search"));
|
|
23
23
|
const Collection_2 = __importDefault(require("./instances/Collection"));
|
|
24
|
+
/**
|
|
25
|
+
* Returns a new {@link DynamicStarlightClient}, which is a
|
|
26
|
+
* {@link StarlightClient} with support to create
|
|
27
|
+
* {@apilink ModelInstance | ModelInstances} using the dynamic syntax. To learn
|
|
28
|
+
* which methods a client supports, see {@link StarlightClient}.
|
|
29
|
+
*
|
|
30
|
+
* This function accepts a {@link StarlightConfig} object and can be used to
|
|
31
|
+
* create new clients that connect to a single Starlight workspace. Each client
|
|
32
|
+
* returned by this function is separate and independent from the others.
|
|
33
|
+
*
|
|
34
|
+
* If you only need to make requests to a single workspace, it's probably easier
|
|
35
|
+
* to use the SDK's default client. To use the default client, you only need to
|
|
36
|
+
* import the default object exported by the SDK:
|
|
37
|
+
*
|
|
38
|
+
* ```ts
|
|
39
|
+
* // `Starlight` below is the default StarlightClient.
|
|
40
|
+
* import Starlight from '@starlightcms/js-sdk'
|
|
41
|
+
* ```
|
|
42
|
+
*
|
|
43
|
+
* See {@link default} for more info on how to use the default client.
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* Creating a new client and exporting it.
|
|
47
|
+
* ```ts
|
|
48
|
+
* import { makeStarlightClient } from '@starlightcms/js-sdk'
|
|
49
|
+
*
|
|
50
|
+
* const BlogClient = makeStarlightClient({
|
|
51
|
+
* workspace: '123123123'
|
|
52
|
+
* })
|
|
53
|
+
*
|
|
54
|
+
* // Feel free to export the new client so your application can use it.
|
|
55
|
+
* export default BlogClient
|
|
56
|
+
* ```
|
|
57
|
+
*
|
|
58
|
+
* @param config The client configuration object. You need to provide at least
|
|
59
|
+
* the `workspace` property. See {@link StarlightConfig} to view all the
|
|
60
|
+
* available options.
|
|
61
|
+
* @group Client
|
|
62
|
+
*/
|
|
24
63
|
function makeClient(config = {}) {
|
|
25
64
|
var _a, _b, _c;
|
|
26
65
|
let baseUrl = (_a = config.baseUrl) !== null && _a !== void 0 ? _a : 'https://query.starlight.sh/v2';
|
package/dist/cjs/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/client.ts"],"names":[],"mappings":"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","sourcesContent":["import {\n DefaultModelDefinition,\n
|
|
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'\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 from 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 the default client, 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\n * 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 * })\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>(config: StarlightConfig = {}): DynamicStarlightClient<D> {\n let baseUrl = config.baseUrl ?? 'https://query.starlight.sh/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 return `${baseUrl}/workspaces/${workspace}`\n },\n\n async get(path, params = {}, options) {\n const filteredParams = Object.keys(params).reduce((accumulator, key) => {\n const param = params[key]\n\n if (param || param === false) accumulator[key] = String(param)\n\n return accumulator\n }, {} as Record<string, string>)\n\n const searchParams = new URLSearchParams(filteredParams).toString()\n const finalPath = searchParams ? `${path}?${searchParams}` : path\n\n this.log(`Starlight - GET ${finalPath}`)\n\n const response = await fetch(`${this.getBaseUrl()}${finalPath}`, options)\n\n if (response.status >= 200 && response.status < 300) {\n return await response.json()\n } else {\n const message = `Starlight - GET ${path} returned ${response.status}: ${response.statusText}`\n throw new StarlightError(message, response)\n }\n },\n\n get models() {\n return makeModelSelector(this)\n },\n\n model(slug) {\n return makeModelInstance(this, slug as string)\n },\n\n get singletons() {\n return makeSingletonSelector(this)\n },\n\n get collections() {\n return makeCollectionSelector(this)\n },\n\n collection(slug: string | number) {\n return makeCollectionInstance(this, slug)\n },\n\n get media() {\n return makeMediaSelector(this)\n },\n\n get search() {\n return makeSearchSelector(this)\n },\n }\n\n return new Proxy(client, {\n get(target, prop) {\n if (typeof prop === 'string' && !Reflect.has(target, prop)) {\n return makeModelInstance(target, prop)\n }\n\n return Reflect.get(target, prop)\n },\n }) as DynamicStarlightClient<D>\n}\n"]}
|
package/dist/cjs/errors.d.ts
CHANGED
|
@@ -1,4 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This error is thrown every time a problem occurs when requesting something
|
|
3
|
+
* from Starlight's APIs. When it does, you can inspect the attached response
|
|
4
|
+
* to verify what kind of problem happened and handle it accordingly.
|
|
5
|
+
*
|
|
6
|
+
* @group Errors
|
|
7
|
+
*/
|
|
1
8
|
export declare class StarlightError extends Error {
|
|
9
|
+
/**
|
|
10
|
+
* The response provided by the `fetch` method when the error occurred.
|
|
11
|
+
*
|
|
12
|
+
* @see [MDN documentation on the Response object](https://developer.mozilla.org/en-US/docs/Web/API/Response)
|
|
13
|
+
*/
|
|
2
14
|
response: Response;
|
|
3
15
|
constructor(message: string, response: Response);
|
|
4
16
|
}
|
package/dist/cjs/errors.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/errors.ts"],"names":[],"mappings":"AAAA,qBAAa,cAAe,SAAQ,KAAK;
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,qBAAa,cAAe,SAAQ,KAAK;IACvC;;;;OAIG;IACI,QAAQ,EAAE,QAAQ,CAAA;gBAEb,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ;CAIhD"}
|
package/dist/cjs/errors.js
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.StarlightError = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* This error is thrown every time a problem occurs when requesting something
|
|
6
|
+
* from Starlight's APIs. When it does, you can inspect the attached response
|
|
7
|
+
* to verify what kind of problem happened and handle it accordingly.
|
|
8
|
+
*
|
|
9
|
+
* @group Errors
|
|
10
|
+
*/
|
|
4
11
|
class StarlightError extends Error {
|
|
5
12
|
constructor(message, response) {
|
|
6
13
|
super(message);
|
package/dist/cjs/errors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/errors.ts"],"names":[],"mappings":";;;AAAA,MAAa,cAAe,SAAQ,KAAK;
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/errors.ts"],"names":[],"mappings":";;;AAAA;;;;;;GAMG;AACH,MAAa,cAAe,SAAQ,KAAK;IAQvC,YAAY,OAAe,EAAE,QAAkB;QAC7C,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAA;IAC1B,CAAC;CACF;AAZD,wCAYC","sourcesContent":["/**\n * This error is thrown every time a problem occurs when requesting something\n * from Starlight's APIs. When it does, you can inspect the attached response\n * to verify what kind of problem happened and handle it accordingly.\n *\n * @group Errors\n */\nexport class StarlightError extends Error {\n /**\n * The response provided by the `fetch` method when the error occurred.\n *\n * @see [MDN documentation on the Response object](https://developer.mozilla.org/en-US/docs/Web/API/Response)\n */\n public response: Response\n\n constructor(message: string, response: Response) {\n super(message)\n this.response = response\n }\n}\n"]}
|
package/dist/cjs/index.d.ts
CHANGED
|
@@ -1,7 +1,27 @@
|
|
|
1
1
|
import { makeClient } from './client';
|
|
2
2
|
export { StarlightError } from './errors';
|
|
3
3
|
export * from './types';
|
|
4
|
-
|
|
4
|
+
/**
|
|
5
|
+
* This is the default object exported by the SDK module, which is a
|
|
6
|
+
* pre-created {@link StarlightClient}. If your application only requests
|
|
7
|
+
* data from a single Starlight workspace, using this client is easier than
|
|
8
|
+
* creating a new one using {@link makeStarlightClient}.
|
|
9
|
+
*
|
|
10
|
+
* Using the default client is as easy as importing the SDK:
|
|
11
|
+
*
|
|
12
|
+
* ```ts
|
|
13
|
+
* // "Starlight" below is the default client.
|
|
14
|
+
* import Starlight from '@starlightcms/js-sdk'
|
|
15
|
+
*
|
|
16
|
+
* const response = await Starlight.posts.entries.list()
|
|
17
|
+
* ```
|
|
18
|
+
*
|
|
19
|
+
* You need to configure the default workspace once before using it, however.
|
|
20
|
+
* See {@apilink StarlightClient.configure} to learn more.
|
|
21
|
+
*
|
|
22
|
+
* @group Client
|
|
23
|
+
*/
|
|
24
|
+
declare const Starlight: import("./types").DynamicStarlightClient<import("./types").DefaultModelDefinition>;
|
|
5
25
|
export { makeClient as makeStarlightClient };
|
|
6
26
|
export default Starlight;
|
|
7
27
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/cjs/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AACrC,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AACzC,cAAc,SAAS,CAAA;AAEvB,QAAA,MAAM,SAAS,oFAAe,CAAA;AAE9B,OAAO,EAAE,UAAU,IAAI,mBAAmB,EAAE,CAAA;AAE5C,eAAe,SAAS,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AACrC,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AACzC,cAAc,SAAS,CAAA;AAEvB;;;;;;;;;;;;;;;;;;;GAmBG;AACH,QAAA,MAAM,SAAS,oFAAe,CAAA;AAE9B,OAAO,EAAE,UAAU,IAAI,mBAAmB,EAAE,CAAA;AAE5C,eAAe,SAAS,CAAA"}
|
package/dist/cjs/index.js
CHANGED
|
@@ -20,6 +20,26 @@ Object.defineProperty(exports, "makeStarlightClient", { enumerable: true, get: f
|
|
|
20
20
|
var errors_1 = require("./errors");
|
|
21
21
|
Object.defineProperty(exports, "StarlightError", { enumerable: true, get: function () { return errors_1.StarlightError; } });
|
|
22
22
|
__exportStar(require("./types"), exports);
|
|
23
|
+
/**
|
|
24
|
+
* This is the default object exported by the SDK module, which is a
|
|
25
|
+
* pre-created {@link StarlightClient}. If your application only requests
|
|
26
|
+
* data from a single Starlight workspace, using this client is easier than
|
|
27
|
+
* creating a new one using {@link makeStarlightClient}.
|
|
28
|
+
*
|
|
29
|
+
* Using the default client is as easy as importing the SDK:
|
|
30
|
+
*
|
|
31
|
+
* ```ts
|
|
32
|
+
* // "Starlight" below is the default client.
|
|
33
|
+
* import Starlight from '@starlightcms/js-sdk'
|
|
34
|
+
*
|
|
35
|
+
* const response = await Starlight.posts.entries.list()
|
|
36
|
+
* ```
|
|
37
|
+
*
|
|
38
|
+
* You need to configure the default workspace once before using it, however.
|
|
39
|
+
* See {@apilink StarlightClient.configure} to learn more.
|
|
40
|
+
*
|
|
41
|
+
* @group Client
|
|
42
|
+
*/
|
|
23
43
|
const Starlight = (0, client_1.makeClient)();
|
|
24
44
|
exports.default = Starlight;
|
|
25
45
|
//# sourceMappingURL=index.js.map
|
package/dist/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,qCAAqC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,qCAAqC;AA0Bd,oGA1Bd,mBAAU,OA0BuB;AAzB1C,mCAAyC;AAAhC,wGAAA,cAAc,OAAA;AACvB,0CAAuB;AAEvB;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,SAAS,GAAG,IAAA,mBAAU,GAAE,CAAA;AAI9B,kBAAe,SAAS,CAAA","sourcesContent":["import { makeClient } from './client'\nexport { StarlightError } from './errors'\nexport * from './types'\n\n/**\n * This is the default object exported by the SDK module, which is a\n * pre-created {@link StarlightClient}. If your application only requests\n * data from a single Starlight workspace, using this client is easier than\n * creating a new one using {@link makeStarlightClient}.\n *\n * Using the default client is as easy as importing the SDK:\n *\n * ```ts\n * // \"Starlight\" below is the default client.\n * import Starlight from '@starlightcms/js-sdk'\n *\n * const response = await Starlight.posts.entries.list()\n * ```\n *\n * You need to configure the default workspace once before using it, however.\n * See {@apilink StarlightClient.configure} to learn more.\n *\n * @group Client\n */\nconst Starlight = makeClient()\n\nexport { makeClient as makeStarlightClient }\n\nexport default Starlight\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CollectionEntityTypes, StarlightClient } from '../../types';
|
|
2
2
|
import { CollectionInstance } from './types';
|
|
3
|
-
export default function makeCollectionInstance<T extends
|
|
3
|
+
export default function makeCollectionInstance<T extends CollectionEntityTypes = unknown>(client: StarlightClient, collection: string | number): CollectionInstance<T>;
|
|
4
4
|
export { CollectionInstance };
|
|
5
5
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/instances/Collection/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/instances/Collection/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AACpE,OAAO,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAA;AAE5C,MAAM,CAAC,OAAO,UAAU,sBAAsB,CAC5C,CAAC,SAAS,qBAAqB,GAAG,OAAO,EACzC,MAAM,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,GAAG,kBAAkB,CAAC,CAAC,CAAC,CAU7E;AAED,OAAO,EAAE,kBAAkB,EAAE,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/instances/Collection/index.ts"],"names":[],"mappings":";;AAGA,SAAwB,sBAAsB,CAE5C,MAAuB,EAAE,UAA2B;IACpD,OAAO;QACL,GAAG;YACD,OAAO,MAAM,CAAC,GAAG,CAAC,gBAAgB,UAAU,EAAE,CAAC,CAAA;QACjD,CAAC;QAED,KAAK,CAAC,OAAO;YACX,OAAO,MAAM,CAAC,GAAG,CAAC,gBAAgB,UAAU,QAAQ,EAAE,OAAO,CAAC,CAAA;QAChE,CAAC;KACF,CAAA;AACH,CAAC;AAZD,yCAYC","sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/instances/Collection/index.ts"],"names":[],"mappings":";;AAGA,SAAwB,sBAAsB,CAE5C,MAAuB,EAAE,UAA2B;IACpD,OAAO;QACL,GAAG;YACD,OAAO,MAAM,CAAC,GAAG,CAAC,gBAAgB,UAAU,EAAE,CAAC,CAAA;QACjD,CAAC;QAED,KAAK,CAAC,OAAO;YACX,OAAO,MAAM,CAAC,GAAG,CAAC,gBAAgB,UAAU,QAAQ,EAAE,OAAO,CAAC,CAAA;QAChE,CAAC;KACF,CAAA;AACH,CAAC;AAZD,yCAYC","sourcesContent":["import { CollectionEntityTypes, StarlightClient } from '../../types'\nimport { CollectionInstance } from './types'\n\nexport default function makeCollectionInstance<\n T extends CollectionEntityTypes = unknown\n>(client: StarlightClient, collection: string | number): CollectionInstance<T> {\n return {\n get() {\n return client.get(`/collections/${collection}`)\n },\n\n items(options) {\n return client.get(`/collections/${collection}/items`, options)\n },\n }\n}\n\nexport { CollectionInstance }\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Collection,
|
|
1
|
+
import { Collection, CollectionEntityTypes, CollectionTypeMapper, Entry, ModelFieldOptions, Singleton, StarlightItemResponse, StarlightListResponse } from '../../types';
|
|
2
2
|
export declare type ListCollectionItemsOptions<T> = {
|
|
3
3
|
page?: number;
|
|
4
4
|
limit?: number;
|
|
@@ -7,9 +7,53 @@ export declare type ListCollectionItemsOptions<T> = {
|
|
|
7
7
|
fields?: string;
|
|
8
8
|
order?: 'title:asc' | 'title:desc' | 'published_at:asc' | 'published_at:desc' | 'views:asc' | 'views:desc';
|
|
9
9
|
except?: number;
|
|
10
|
-
} & (T extends
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
} & (T extends Entry<never> | Singleton<never> ? ModelFieldOptions<Pick<T, 'data'>> : Record<string, never>);
|
|
11
|
+
/**
|
|
12
|
+
* An Instance that provide methods to request information and items from
|
|
13
|
+
* {@apilink Collection | Collections}.
|
|
14
|
+
*
|
|
15
|
+
* @group Instances
|
|
16
|
+
*/
|
|
17
|
+
export interface CollectionInstance<C extends CollectionEntityTypes> {
|
|
18
|
+
/**
|
|
19
|
+
* Returns a {@link StarlightItemResponse} with a single {@link Collection}.
|
|
20
|
+
*
|
|
21
|
+
* @example Requesting information from a collection of slug `featured-news`.
|
|
22
|
+
* ```ts
|
|
23
|
+
* import Starlight from '@starlightcms/js-sdk'
|
|
24
|
+
*
|
|
25
|
+
* const response = await Starlight.collection('featured-news').get()
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
get(): Promise<StarlightItemResponse<Collection<CollectionTypeMapper<C>>>>;
|
|
29
|
+
/**
|
|
30
|
+
* Returns a {@link StarlightListResponse} with the list of items of the given
|
|
31
|
+
* {@link Collection}. The returned list type depends on the collection type:
|
|
32
|
+
* a list of {@apilink Entry | Entries} for a collection of type `entry`, a
|
|
33
|
+
* list of {@apilink MediaObject | MediaObjects} for a collection o type
|
|
34
|
+
* `media`, and so on.
|
|
35
|
+
*
|
|
36
|
+
* If the given Collection is not typed, this method will return a response of
|
|
37
|
+
* `StarlightListResponse<unknown>`.
|
|
38
|
+
*
|
|
39
|
+
* @example Requesting all items from an Entry collection of slug `featured-news`.
|
|
40
|
+
* ```ts
|
|
41
|
+
* import Starlight from '@starlightcms/js-sdk'
|
|
42
|
+
*
|
|
43
|
+
* const response = await Starlight.collection('featured-news').items()
|
|
44
|
+
* ```
|
|
45
|
+
*
|
|
46
|
+
* @example Explicitly typing the returned items. Only possible in TypeScript.
|
|
47
|
+
* ```ts
|
|
48
|
+
* import Starlight from '@starlightcms/js-sdk'
|
|
49
|
+
* import { NewsPostType } from '../types'
|
|
50
|
+
*
|
|
51
|
+
* // response will be StarlightListResponse<Entry<NewsPostType>>
|
|
52
|
+
* const response = await Starlight.collection<Entry<NewsPostType>>('featured-news').items()
|
|
53
|
+
* ```
|
|
54
|
+
*
|
|
55
|
+
* @param options
|
|
56
|
+
*/
|
|
57
|
+
items(options?: ListCollectionItemsOptions<C>): Promise<StarlightListResponse<C>>;
|
|
14
58
|
}
|
|
15
59
|
//# 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,UAAU,EACV,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/instances/Collection/types.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,qBAAqB,EACrB,oBAAoB,EACpB,KAAK,EACL,iBAAiB,EACjB,SAAS,EACT,qBAAqB,EACrB,qBAAqB,EACtB,MAAM,aAAa,CAAA;AAEpB,oBAAY,0BAA0B,CAAC,CAAC,IAAI;IAC1C,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,KAAK,CAAC,EACF,WAAW,GACX,YAAY,GACZ,kBAAkB,GAClB,mBAAmB,GACnB,WAAW,GACX,YAAY,CAAA;IAChB,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB,GAAG,CAAC,CAAC,SAAS,KAAK,CAAC,KAAK,CAAC,GAAG,SAAS,CAAC,KAAK,CAAC,GAC1C,iBAAiB,CAAC,IAAI,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,GAClC,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,CAAA;AAE1B;;;;;GAKG;AACH,MAAM,WAAW,kBAAkB,CAAC,CAAC,SAAS,qBAAqB;IACjE;;;;;;;;;OASG;IACH,GAAG,IAAI,OAAO,CAAC,qBAAqB,CAAC,UAAU,CAAC,oBAAoB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;IAE1E;;;;;;;;;;;;;;;;;;;;;;;;;;;OA2BG;IACH,KAAK,CACH,OAAO,CAAC,EAAE,0BAA0B,CAAC,CAAC,CAAC,GACtC,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 Collection,\n
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/instances/Collection/types.ts"],"names":[],"mappings":"","sourcesContent":["import {\n Collection,\n CollectionEntityTypes,\n CollectionTypeMapper,\n Entry,\n ModelFieldOptions,\n Singleton,\n StarlightItemResponse,\n StarlightListResponse,\n} from '../../types'\n\nexport type ListCollectionItemsOptions<T> = {\n page?: number\n limit?: number\n query?: string\n 'query:word'?: string\n fields?: string\n order?:\n | 'title:asc'\n | 'title:desc'\n | 'published_at:asc'\n | 'published_at:desc'\n | 'views:asc'\n | 'views:desc'\n except?: number\n} & (T extends Entry<never> | Singleton<never>\n ? ModelFieldOptions<Pick<T, 'data'>>\n : Record<string, never>)\n\n/**\n * An Instance that provide methods to request information and items from\n * {@apilink Collection | Collections}.\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 get(): Promise<StarlightItemResponse<Collection<CollectionTypeMapper<C>>>>\n\n /**\n * Returns a {@link StarlightListResponse} with the list of items of the given\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 options\n */\n items(\n options?: ListCollectionItemsOptions<C>\n ): Promise<StarlightListResponse<C>>\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SerializedData, StarlightClient } from '../../types';
|
|
2
|
-
import { ModelInstance } from './types';
|
|
3
|
-
export default function makeModelInstance<D extends SerializedData>(client: StarlightClient, model: string):
|
|
4
|
-
export { ModelInstance };
|
|
2
|
+
import { DynamicModelInstance, ModelInstance } from './types';
|
|
3
|
+
export default function makeModelInstance<D extends SerializedData>(client: StarlightClient, model: string): DynamicModelInstance<D>;
|
|
4
|
+
export { DynamicModelInstance, ModelInstance };
|
|
5
5
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/instances/Model/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,cAAc,EACd,eAAe,EAEhB,MAAM,aAAa,CAAA;AACpB,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/instances/Model/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,cAAc,EACd,eAAe,EAEhB,MAAM,aAAa,CAAA;AACpB,OAAO,EAAE,oBAAoB,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAS7D,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"}
|
|
@@ -7,7 +7,7 @@ const Entry_1 = __importDefault(require("../../selectors/Entry"));
|
|
|
7
7
|
const ModelCategory_1 = __importDefault(require("../../selectors/ModelCategory"));
|
|
8
8
|
const ModelCategory_2 = __importDefault(require("../ModelCategory"));
|
|
9
9
|
function makeModelInstance(client, model) {
|
|
10
|
-
|
|
10
|
+
const instance = {
|
|
11
11
|
get() {
|
|
12
12
|
return client.get(`/models/${model}`);
|
|
13
13
|
},
|
|
@@ -21,6 +21,14 @@ function makeModelInstance(client, model) {
|
|
|
21
21
|
return (0, ModelCategory_1.default)(client, model);
|
|
22
22
|
},
|
|
23
23
|
};
|
|
24
|
+
return new Proxy(instance, {
|
|
25
|
+
get(target, prop) {
|
|
26
|
+
if (typeof prop === 'string' && !Reflect.has(target, prop)) {
|
|
27
|
+
return (0, ModelCategory_2.default)(client, model, prop);
|
|
28
|
+
}
|
|
29
|
+
return Reflect.get(target, prop);
|
|
30
|
+
},
|
|
31
|
+
});
|
|
24
32
|
}
|
|
25
33
|
exports.default = makeModelInstance;
|
|
26
34
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/instances/Model/index.ts"],"names":[],"mappings":";;;;;AAOA,kEAAwE;AACxE,kFAEsC;AACtC,qEAEyB;AAEzB,SAAwB,iBAAiB,CACvC,MAAuB,EACvB,KAAa;IAEb,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/instances/Model/index.ts"],"names":[],"mappings":";;;;;AAOA,kEAAwE;AACxE,kFAEsC;AACtC,qEAEyB;AAEzB,SAAwB,iBAAiB,CACvC,MAAuB,EACvB,KAAa;IAEb,MAAM,QAAQ,GAAG;QACf,GAAG;YACD,OAAO,MAAM,CAAC,GAAG,CAAC,WAAW,KAAK,EAAE,CAAC,CAAA;QACvC,CAAC;QAED,QAAQ,CAAC,IAAY;YACnB,OAAO,IAAA,uBAAyB,EAAC,MAAM,EAAE,KAAK,EAAE,IAAI,CAAC,CAAA;QACvD,CAAC;QAED,IAAI,OAAO;YACT,OAAO,IAAA,eAAiB,EAAI,MAAM,EAAE,KAAK,CAAC,CAAA;QAC5C,CAAC;QAED,IAAI,UAAU;YACZ,OAAO,IAAA,uBAAyB,EAAC,MAAM,EAAE,KAAK,CAAC,CAAA;QACjD,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,IAAA,uBAAyB,EAAC,MAAM,EAAE,KAAK,EAAE,IAAI,CAAC,CAAA;aACtD;YAED,OAAO,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,CAAA;QAClC,CAAC;KACF,CAA4B,CAAA;AAC/B,CAAC;AA/BD,oCA+BC","sourcesContent":["import {\n Model,\n SerializedData,\n StarlightClient,\n StarlightItemResponse,\n} from '../../types'\nimport { DynamicModelInstance, ModelInstance } from './types'\nimport makeEntrySelector, { EntrySelector } from '../../selectors/Entry'\nimport makeModelCategorySelector, {\n DynamicModelCategorySelector,\n} from '../../selectors/ModelCategory'\nimport makeModelCategoryInstance, {\n ModelCategoryInstance,\n} from '../ModelCategory'\n\nexport default function makeModelInstance<D extends SerializedData>(\n client: StarlightClient,\n model: string\n): DynamicModelInstance<D> {\n const instance = {\n get(): Promise<StarlightItemResponse<Model>> {\n return client.get(`/models/${model}`)\n },\n\n category(slug: string): ModelCategoryInstance<D> {\n return makeModelCategoryInstance(client, model, slug)\n },\n\n get entries(): EntrySelector<D> {\n return makeEntrySelector<D>(client, model)\n },\n\n get categories(): DynamicModelCategorySelector<D> {\n return makeModelCategorySelector(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,11 +1,14 @@
|
|
|
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
5
|
export interface ModelInstance<D extends SerializedData> {
|
|
6
6
|
get(): Promise<StarlightItemResponse<Model>>;
|
|
7
7
|
category(slug: string): ModelCategoryInstance<D>;
|
|
8
8
|
get entries(): EntrySelector<D>;
|
|
9
|
-
get categories():
|
|
9
|
+
get categories(): DynamicModelCategorySelector<D>;
|
|
10
10
|
}
|
|
11
|
+
export declare type DynamicModelInstance<D extends SerializedData> = ModelInstance<D> & {
|
|
12
|
+
[key: string]: ModelCategoryInstance<D>;
|
|
13
|
+
};
|
|
11
14
|
//# 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;IAC5C,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,qBAAqB,CAAC,CAAC,CAAC,CAAA;IAChD,IAAI,OAAO,IAAI,aAAa,CAAC,CAAC,CAAC,CAAA;IAC/B,IAAI,UAAU,IAAI,4BAA4B,CAAC,CAAC,CAAC,CAAA;CAClD"}
|
|
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;IAC5C,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,qBAAqB,CAAC,CAAC,CAAC,CAAA;IAChD,IAAI,OAAO,IAAI,aAAa,CAAC,CAAC,CAAC,CAAA;IAC/B,IAAI,UAAU,IAAI,4BAA4B,CAAC,CAAC,CAAC,CAAA;CAClD;AAED,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\nexport interface ModelInstance<D extends SerializedData> {\n get(): Promise<StarlightItemResponse<Model>>\n category(slug: string): ModelCategoryInstance<D>\n get entries(): EntrySelector<D>\n get categories(): DynamicModelCategorySelector<D>\n}\n\nexport type DynamicModelInstance<D extends SerializedData> =\n ModelInstance<D> & {\n [key: string]: ModelCategoryInstance<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 } from './types';
|
|
3
|
+
export default function makeCollectionSelector(client: StarlightClient): DynamicCollectionSelector;
|
|
4
|
+
export { CollectionSelector, DynamicCollectionSelector };
|
|
5
5
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/selectors/Collection/index.ts"],"names":[],"mappings":";;;;;AAEA,4EAA+D;AAE/D,SAAwB,sBAAsB,CAC5C,MAAuB;IAEvB,MAAM,QAAQ,GAAuB;QACnC,IAAI,CAAC,OAAO;YACV,OAAO,MAAM,CAAC,GAAG,CAAC,cAAc,EAAE,OAAO,CAAC,CAAA;QAC5C,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,IAAA,oBAAsB,EAAC,MAAM,EAAE,IAAI,CAAC,CAAA;aAC5C;YAED,OAAO,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,CAAA;QAClC,CAAC;KACF,CAA8B,CAAA;AACjC,CAAC;AAtBD,yCAsBC","sourcesContent":["import { StarlightClient } from '../../types'\nimport { CollectionSelector,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/selectors/Collection/index.ts"],"names":[],"mappings":";;;;;AAEA,4EAA+D;AAE/D,SAAwB,sBAAsB,CAC5C,MAAuB;IAEvB,MAAM,QAAQ,GAAuB;QACnC,IAAI,CAAC,OAAO;YACV,OAAO,MAAM,CAAC,GAAG,CAAC,cAAc,EAAE,OAAO,CAAC,CAAA;QAC5C,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,IAAA,oBAAsB,EAAC,MAAM,EAAE,IAAI,CAAC,CAAA;aAC5C;YAED,OAAO,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,CAAA;QAClC,CAAC;KACF,CAA8B,CAAA;AACjC,CAAC;AAtBD,yCAsBC","sourcesContent":["import { StarlightClient } from '../../types'\nimport { CollectionSelector, DynamicCollectionSelector } 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 }\n"]}
|
|
@@ -10,7 +10,7 @@ export interface CollectionSelector {
|
|
|
10
10
|
list(options?: ListCollectionsOptions): Promise<StarlightListResponse<Collection>>;
|
|
11
11
|
get(slug: string | number): Promise<StarlightItemResponse<Collection>>;
|
|
12
12
|
}
|
|
13
|
-
export declare type
|
|
14
|
-
[key: string]: CollectionInstance
|
|
13
|
+
export declare type DynamicCollectionSelector = CollectionSelector & {
|
|
14
|
+
[key: string]: CollectionInstance<unknown>;
|
|
15
15
|
};
|
|
16
16
|
//# 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,oBAAY,sBAAsB,GAAG;IACnC,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,KAAK,CAAC,EAAE,WAAW,GAAG,YAAY,GAAG,gBAAgB,GAAG,iBAAiB,CAAA;CAC1E,CAAA;AAED,MAAM,WAAW,kBAAkB;IACjC,IAAI,CACF,OAAO,CAAC,EAAE,sBAAsB,GAC/B,OAAO,CAAC,qBAAqB,CAAC,UAAU,CAAC,CAAC,CAAA;IAC7C,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,qBAAqB,CAAC,UAAU,CAAC,CAAC,CAAA;CACvE;AAED,oBAAY,yBAAyB,GAAG,kBAAkB,GAAG;IAC3D,CAAC,GAAG,EAAE,MAAM,GAAG,kBAAkB,CAAA;
|
|
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,oBAAY,sBAAsB,GAAG;IACnC,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,KAAK,CAAC,EAAE,WAAW,GAAG,YAAY,GAAG,gBAAgB,GAAG,iBAAiB,CAAA;CAC1E,CAAA;AAED,MAAM,WAAW,kBAAkB;IACjC,IAAI,CACF,OAAO,CAAC,EAAE,sBAAsB,GAC/B,OAAO,CAAC,qBAAqB,CAAC,UAAU,CAAC,CAAC,CAAA;IAC7C,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,qBAAqB,CAAC,UAAU,CAAC,CAAC,CAAA;CACvE;AAED,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\nexport type ListCollectionsOptions = {\n query?: string\n page?: number\n limit?: number\n order?: 'title:asc' | 'title:desc' | 'item_count:asc' | 'item_count:desc'\n}\n\nexport interface CollectionSelector {\n list(\n options?: ListCollectionsOptions\n ): Promise<StarlightListResponse<Collection>>\n get(slug: string | number): Promise<StarlightItemResponse<Collection>>\n}\n\nexport type
|
|
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\nexport type ListCollectionsOptions = {\n query?: string\n page?: number\n limit?: number\n order?: 'title:asc' | 'title:desc' | 'item_count:asc' | 'item_count:desc'\n}\n\nexport interface CollectionSelector {\n list(\n options?: ListCollectionsOptions\n ): Promise<StarlightListResponse<Collection>>\n get(slug: string | number): Promise<StarlightItemResponse<Collection>>\n}\n\nexport type DynamicCollectionSelector = CollectionSelector & {\n [key: string]: CollectionInstance<unknown>\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { StarlightClient, WorkspaceModelDefinition } from '../../types';
|
|
2
|
-
import { ModelSelector,
|
|
3
|
-
export default function makeModelSelector<D extends WorkspaceModelDefinition>(client: StarlightClient):
|
|
4
|
-
export { ModelSelector,
|
|
2
|
+
import { ModelSelector, DynamicModelSelector } from './types';
|
|
3
|
+
export default function makeModelSelector<D extends WorkspaceModelDefinition>(client: StarlightClient): DynamicModelSelector<D>;
|
|
4
|
+
export { ModelSelector, DynamicModelSelector };
|
|
5
5
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/selectors/Model/index.ts"],"names":[],"mappings":";;;;;AAQA,kEAAqD;AAErD,SAAwB,iBAAiB,CACvC,MAAuB;IAEvB,MAAM,WAAW,GAAkB;QACjC,IAAI;YACF,OAAO,MAAM,CAAC,GAAG,CAAC,SAAS,CAAC,CAAA;QAC9B,CAAC;QAED,GAAG,CAAC,IAAI;YACN,OAAO,MAAM,CAAC,GAAG,CAAC,WAAW,IAAI,EAAE,CAAC,CAAA;QACtC,CAAC;KACF,CAAA;IAED,OAAO,IAAI,KAAK,CAAC,WAAW,EAAE;QAC5B,GAAG,CAAC,MAAM,EAAE,IAAI;YACd,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,EAAE;gBAC1D,OAAO,IAAA,eAAiB,EAAC,MAAM,EAAE,IAAI,CAAC,CAAA;aACvC;YAED,OAAO,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,CAAA;QAClC,CAAC;KACF,CAA4B,CAAA;AAC/B,CAAC;AAtBD,oCAsBC","sourcesContent":["import {\n Model,\n StarlightClient,\n StarlightItemResponse,\n StarlightListResponse,\n WorkspaceModelDefinition,\n} from '../../types'\nimport { ModelSelector,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/selectors/Model/index.ts"],"names":[],"mappings":";;;;;AAQA,kEAAqD;AAErD,SAAwB,iBAAiB,CACvC,MAAuB;IAEvB,MAAM,WAAW,GAAkB;QACjC,IAAI;YACF,OAAO,MAAM,CAAC,GAAG,CAAC,SAAS,CAAC,CAAA;QAC9B,CAAC;QAED,GAAG,CAAC,IAAI;YACN,OAAO,MAAM,CAAC,GAAG,CAAC,WAAW,IAAI,EAAE,CAAC,CAAA;QACtC,CAAC;KACF,CAAA;IAED,OAAO,IAAI,KAAK,CAAC,WAAW,EAAE;QAC5B,GAAG,CAAC,MAAM,EAAE,IAAI;YACd,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,EAAE;gBAC1D,OAAO,IAAA,eAAiB,EAAC,MAAM,EAAE,IAAI,CAAC,CAAA;aACvC;YAED,OAAO,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,CAAA;QAClC,CAAC;KACF,CAA4B,CAAA;AAC/B,CAAC;AAtBD,oCAsBC","sourcesContent":["import {\n Model,\n StarlightClient,\n StarlightItemResponse,\n StarlightListResponse,\n WorkspaceModelDefinition,\n} from '../../types'\nimport { ModelSelector, DynamicModelSelector } from './types'\nimport makeModelInstance from '../../instances/Model'\n\nexport default function makeModelSelector<D extends WorkspaceModelDefinition>(\n client: StarlightClient\n): DynamicModelSelector<D> {\n const modelClient: ModelSelector = {\n list(): Promise<StarlightListResponse<Model>> {\n return client.get('/models')\n },\n\n get(slug): Promise<StarlightItemResponse<Model>> {\n return client.get(`/models/${slug}`)\n },\n }\n\n return new Proxy(modelClient, {\n get(target, prop) {\n if (typeof prop === 'string' && !Reflect.has(target, prop)) {\n return makeModelInstance(client, prop)\n }\n\n return Reflect.get(target, prop)\n },\n }) as DynamicModelSelector<D>\n}\n\nexport { ModelSelector, DynamicModelSelector }\n"]}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Model, StarlightItemResponse, StarlightListResponse, WorkspaceModelDefinition } from '../../types';
|
|
2
|
-
import {
|
|
2
|
+
import { DynamicModelInstance } from '../../instances/Model';
|
|
3
3
|
export interface ModelSelector {
|
|
4
4
|
list(): Promise<StarlightListResponse<Model>>;
|
|
5
5
|
get(slug: string): Promise<StarlightItemResponse<Model>>;
|
|
6
6
|
}
|
|
7
|
-
export declare type
|
|
8
|
-
[K in keyof T]:
|
|
7
|
+
export declare type DynamicModelSelector<T extends WorkspaceModelDefinition> = ModelSelector & {
|
|
8
|
+
[K in keyof T]: DynamicModelInstance<T[K]>;
|
|
9
9
|
};
|
|
10
10
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/selectors/Model/types.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,EACL,qBAAqB,EACrB,qBAAqB,EACrB,wBAAwB,EACzB,MAAM,aAAa,CAAA;AACpB,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/selectors/Model/types.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,EACL,qBAAqB,EACrB,qBAAqB,EACrB,wBAAwB,EACzB,MAAM,aAAa,CAAA;AACpB,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAA;AAE5D,MAAM,WAAW,aAAa;IAC5B,IAAI,IAAI,OAAO,CAAC,qBAAqB,CAAC,KAAK,CAAC,CAAC,CAAA;IAC7C,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,qBAAqB,CAAC,KAAK,CAAC,CAAC,CAAA;CACzD;AAED,oBAAY,oBAAoB,CAAC,CAAC,SAAS,wBAAwB,IACjE,aAAa,GAAG;KACb,CAAC,IAAI,MAAM,CAAC,GAAG,oBAAoB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAC3C,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/selectors/Model/types.ts"],"names":[],"mappings":"","sourcesContent":["import {\n Model,\n StarlightItemResponse,\n StarlightListResponse,\n WorkspaceModelDefinition,\n} from '../../types'\nimport {
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/selectors/Model/types.ts"],"names":[],"mappings":"","sourcesContent":["import {\n Model,\n StarlightItemResponse,\n StarlightListResponse,\n WorkspaceModelDefinition,\n} from '../../types'\nimport { DynamicModelInstance } from '../../instances/Model'\n\nexport interface ModelSelector {\n list(): Promise<StarlightListResponse<Model>>\n get(slug: string): Promise<StarlightItemResponse<Model>>\n}\n\nexport type DynamicModelSelector<T extends WorkspaceModelDefinition> =\n ModelSelector & {\n [K in keyof T]: DynamicModelInstance<T[K]>\n }\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SerializedData, StarlightClient } from '../../types';
|
|
2
|
-
import { ModelCategorySelector,
|
|
3
|
-
export default function makeModelCategorySelector<D extends SerializedData>(client: StarlightClient, model: string):
|
|
4
|
-
export { ModelCategorySelector,
|
|
2
|
+
import { ModelCategorySelector, DynamicModelCategorySelector } from './types';
|
|
3
|
+
export default function makeModelCategorySelector<D extends SerializedData>(client: StarlightClient, model: string): DynamicModelCategorySelector<D>;
|
|
4
|
+
export { ModelCategorySelector, DynamicModelCategorySelector };
|
|
5
5
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/selectors/ModelCategory/index.ts"],"names":[],"mappings":";;;;;AAQA,kFAAqE;AAErE,SAAwB,yBAAyB,CAC/C,MAAuB,EACvB,KAAa;IAEb,MAAM,QAAQ,GAA0B;QACtC,IAAI,CAAC,OAAO;YACV,OAAO,MAAM,CAAC,GAAG,CAAC,WAAW,KAAK,aAAa,EAAE,OAAO,CAAC,CAAA;QAC3D,CAAC;QAED,GAAG,CAAC,IAAI;YACN,OAAO,MAAM,CAAC,GAAG,CAAC,WAAW,KAAK,eAAe,IAAI,EAAE,CAAC,CAAA;QAC1D,CAAC;KACF,CAAA;IAED,OAAO,IAAI,KAAK,CAAC,QAAQ,EAAE;QACzB,GAAG,CAAC,MAAM,EAAE,IAAI;YACd,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,EAAE;gBAC1D,OAAO,IAAA,uBAAyB,EAAC,MAAM,EAAE,KAAK,EAAE,IAAI,CAAC,CAAA;aACtD;YAED,OAAO,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,CAAA;QAClC,CAAC;KACF,CAAoC,CAAA;AACvC,CAAC;AAvBD,4CAuBC","sourcesContent":["import {\n ModelCategory,\n SerializedData,\n StarlightClient,\n StarlightItemResponse,\n StarlightListResponse,\n} from '../../types'\nimport { ModelCategorySelector,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/selectors/ModelCategory/index.ts"],"names":[],"mappings":";;;;;AAQA,kFAAqE;AAErE,SAAwB,yBAAyB,CAC/C,MAAuB,EACvB,KAAa;IAEb,MAAM,QAAQ,GAA0B;QACtC,IAAI,CAAC,OAAO;YACV,OAAO,MAAM,CAAC,GAAG,CAAC,WAAW,KAAK,aAAa,EAAE,OAAO,CAAC,CAAA;QAC3D,CAAC;QAED,GAAG,CAAC,IAAI;YACN,OAAO,MAAM,CAAC,GAAG,CAAC,WAAW,KAAK,eAAe,IAAI,EAAE,CAAC,CAAA;QAC1D,CAAC;KACF,CAAA;IAED,OAAO,IAAI,KAAK,CAAC,QAAQ,EAAE;QACzB,GAAG,CAAC,MAAM,EAAE,IAAI;YACd,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,EAAE;gBAC1D,OAAO,IAAA,uBAAyB,EAAC,MAAM,EAAE,KAAK,EAAE,IAAI,CAAC,CAAA;aACtD;YAED,OAAO,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,CAAA;QAClC,CAAC;KACF,CAAoC,CAAA;AACvC,CAAC;AAvBD,4CAuBC","sourcesContent":["import {\n ModelCategory,\n SerializedData,\n StarlightClient,\n StarlightItemResponse,\n StarlightListResponse,\n} from '../../types'\nimport { ModelCategorySelector, DynamicModelCategorySelector } from './types'\nimport makeModelCategoryInstance from '../../instances/ModelCategory'\n\nexport default function makeModelCategorySelector<D extends SerializedData>(\n client: StarlightClient,\n model: string\n): DynamicModelCategorySelector<D> {\n const selector: ModelCategorySelector = {\n list(options): Promise<StarlightListResponse<ModelCategory>> {\n return client.get(`/models/${model}/categories`, options)\n },\n\n get(slug): Promise<StarlightItemResponse<ModelCategory>> {\n return client.get(`/models/${model}/categories/${slug}`)\n },\n }\n\n return new Proxy(selector, {\n get(target, prop) {\n if (typeof prop === 'string' && !Reflect.has(target, prop)) {\n return makeModelCategoryInstance(client, model, prop)\n }\n\n return Reflect.get(target, prop)\n },\n }) as DynamicModelCategorySelector<D>\n}\n\nexport { ModelCategorySelector, DynamicModelCategorySelector }\n"]}
|
|
@@ -10,7 +10,7 @@ export interface ModelCategorySelector {
|
|
|
10
10
|
list(options?: ListModelCategoriesOptions): Promise<StarlightListResponse<ModelCategory>>;
|
|
11
11
|
get(slug: string): Promise<StarlightItemResponse<ModelCategory>>;
|
|
12
12
|
}
|
|
13
|
-
export declare type
|
|
13
|
+
export declare type DynamicModelCategorySelector<D extends SerializedData> = ModelCategorySelector & {
|
|
14
14
|
[slug: string]: ModelCategoryInstance<D>;
|
|
15
15
|
};
|
|
16
16
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/selectors/ModelCategory/types.ts"],"names":[],"mappings":"","sourcesContent":["import {\n ModelCategory,\n SerializedData,\n StarlightItemResponse,\n StarlightListResponse,\n} from '../../types'\nimport { ModelCategoryInstance } from '../../instances/ModelCategory'\n\nexport type ListModelCategoriesOptions = {\n query?: string\n page?: number\n limit?: number\n order?: 'title:asc' | 'title:desc' | 'entry_count:asc' | 'entry_count:desc'\n}\n\nexport interface ModelCategorySelector {\n list(\n options?: ListModelCategoriesOptions\n ): Promise<StarlightListResponse<ModelCategory>>\n get(slug: string): Promise<StarlightItemResponse<ModelCategory>>\n}\n\nexport type
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/selectors/ModelCategory/types.ts"],"names":[],"mappings":"","sourcesContent":["import {\n ModelCategory,\n SerializedData,\n StarlightItemResponse,\n StarlightListResponse,\n} from '../../types'\nimport { ModelCategoryInstance } from '../../instances/ModelCategory'\n\nexport type ListModelCategoriesOptions = {\n query?: string\n page?: number\n limit?: number\n order?: 'title:asc' | 'title:desc' | 'entry_count:asc' | 'entry_count:desc'\n}\n\nexport interface ModelCategorySelector {\n list(\n options?: ListModelCategoriesOptions\n ): Promise<StarlightListResponse<ModelCategory>>\n get(slug: string): Promise<StarlightItemResponse<ModelCategory>>\n}\n\nexport type DynamicModelCategorySelector<D extends SerializedData> =\n ModelCategorySelector & {\n [slug: string]: ModelCategoryInstance<D>\n }\n"]}
|