@starlightcms/js-sdk 1.0.0 → 1.1.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.
@@ -1,6 +1,7 @@
1
1
  import { makeClient } from './client';
2
2
  export { StarlightError } from './errors';
3
3
  export * from './types';
4
+ export * from './utils';
4
5
  /**
5
6
  * This is the default object exported by the SDK module, which is a
6
7
  * pre-created {@link StarlightClient}. In the docs, this is called the "global
@@ -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;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,QAAA,MAAM,SAAS,iIAAe,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;AACvB,cAAc,SAAS,CAAA;AAEvB;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,QAAA,MAAM,SAAS,iIAAe,CAAA;AAE9B,OAAO,EAAE,UAAU,IAAI,mBAAmB,EAAE,CAAA;AAE5C,eAAe,SAAS,CAAA"}
package/dist/cjs/index.js CHANGED
@@ -20,6 +20,7 @@ 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
+ __exportStar(require("./utils"), exports);
23
24
  /**
24
25
  * This is the default object exported by the SDK module, which is a
25
26
  * pre-created {@link StarlightClient}. In the docs, this is called the "global
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,qCAAqC;AA2Bd,oGA3Bd,mBAAU,OA2BuB;AA1B1C,mCAAyC;AAAhC,wGAAA,cAAc,OAAA;AACvB,0CAAuB;AAEvB;;;;;;;;;;;;;;;;;;;;GAoBG;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}. In the docs, this is called the \"global\n * SDK client\". If your application only requests data from a single Starlight\n * workspace, using this client is easier than creating\n * 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 before using it.\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
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,qCAAqC;AA4Bd,oGA5Bd,mBAAU,OA4BuB;AA3B1C,mCAAyC;AAAhC,wGAAA,cAAc,OAAA;AACvB,0CAAuB;AACvB,0CAAuB;AAEvB;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,SAAS,GAAG,IAAA,mBAAU,GAAE,CAAA;AAI9B,kBAAe,SAAS,CAAA","sourcesContent":["import { makeClient } from './client'\nexport { StarlightError } from './errors'\nexport * from './types'\nexport * from './utils'\n\n/**\n * This is the default object exported by the SDK module, which is a\n * pre-created {@link StarlightClient}. In the docs, this is called the \"global\n * SDK client\". If your application only requests data from a single Starlight\n * workspace, using this client is easier than creating\n * 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 before using it.\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"]}
@@ -0,0 +1,4 @@
1
+ import { MediaFile, MediaObject } from '../types';
2
+ export declare const getMediaFile: (media: MediaObject, variation?: string) => MediaFile;
3
+ export declare const getMediaSource: (media: MediaObject, variation?: string) => string;
4
+ //# sourceMappingURL=image.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"image.d.ts","sourceRoot":"","sources":["../../../src/utils/image.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AASjD,eAAO,MAAM,YAAY,UAChB,WAAW,cACN,MAAM,KACjB,SASF,CAAA;AAED,eAAO,MAAM,cAAc,UAClB,WAAW,cACN,MAAM,KACjB,MAEF,CAAA"}
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getMediaSource = exports.getMediaFile = void 0;
4
+ const getOptimizedOrOriginal = (media) => {
5
+ var _a;
6
+ return ((_a = media.files.find((file) => file.variation === 'optimized')) !== null && _a !== void 0 ? _a : media.files.find((file) => file.variation === 'original'));
7
+ };
8
+ const getMediaFile = (media, variation) => {
9
+ var _a;
10
+ if (variation) {
11
+ return ((_a = media.files.find((file) => file.variation === variation)) !== null && _a !== void 0 ? _a : getOptimizedOrOriginal(media));
12
+ }
13
+ return getOptimizedOrOriginal(media);
14
+ };
15
+ exports.getMediaFile = getMediaFile;
16
+ const getMediaSource = (media, variation) => {
17
+ return (0, exports.getMediaFile)(media, variation).path;
18
+ };
19
+ exports.getMediaSource = getMediaSource;
20
+ //# sourceMappingURL=image.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"image.js","sourceRoot":"","sources":["../../../src/utils/image.ts"],"names":[],"mappings":";;;AAEA,MAAM,sBAAsB,GAAG,CAAC,KAAkB,EAAE,EAAE;;IACpD,OAAO,CACL,MAAA,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,SAAS,KAAK,WAAW,CAAC,mCACzD,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,SAAS,KAAK,UAAU,CAAe,CACzE,CAAA;AACH,CAAC,CAAA;AAEM,MAAM,YAAY,GAAG,CAC1B,KAAkB,EAClB,SAAkB,EACP,EAAE;;IACb,IAAI,SAAS,EAAE;QACb,OAAO,CACL,MAAA,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,SAAS,KAAK,SAAS,CAAC,mCACxD,sBAAsB,CAAC,KAAK,CAAC,CAC9B,CAAA;KACF;IAED,OAAO,sBAAsB,CAAC,KAAK,CAAC,CAAA;AACtC,CAAC,CAAA;AAZY,QAAA,YAAY,gBAYxB;AAEM,MAAM,cAAc,GAAG,CAC5B,KAAkB,EAClB,SAAkB,EACV,EAAE;IACV,OAAO,IAAA,oBAAY,EAAC,KAAK,EAAE,SAAS,CAAC,CAAC,IAAI,CAAA;AAC5C,CAAC,CAAA;AALY,QAAA,cAAc,kBAK1B","sourcesContent":["import { MediaFile, MediaObject } from '../types'\n\nconst getOptimizedOrOriginal = (media: MediaObject) => {\n return (\n media.files.find((file) => file.variation === 'optimized') ??\n (media.files.find((file) => file.variation === 'original') as MediaFile)\n )\n}\n\nexport const getMediaFile = (\n media: MediaObject,\n variation?: string\n): MediaFile => {\n if (variation) {\n return (\n media.files.find((file) => file.variation === variation) ??\n getOptimizedOrOriginal(media)\n )\n }\n\n return getOptimizedOrOriginal(media)\n}\n\nexport const getMediaSource = (\n media: MediaObject,\n variation?: string\n): string => {\n return getMediaFile(media, variation).path\n}\n"]}
@@ -0,0 +1,2 @@
1
+ export * from './image';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAA"}
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./image"), exports);
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0CAAuB","sourcesContent":["export * from './image'\n"]}
@@ -1,6 +1,7 @@
1
1
  import { makeClient } from './client';
2
2
  export { StarlightError } from './errors';
3
3
  export * from './types';
4
+ export * from './utils';
4
5
  /**
5
6
  * This is the default object exported by the SDK module, which is a
6
7
  * pre-created {@link StarlightClient}. In the docs, this is called the "global
@@ -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;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,QAAA,MAAM,SAAS,iIAAe,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;AACvB,cAAc,SAAS,CAAA;AAEvB;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,QAAA,MAAM,SAAS,iIAAe,CAAA;AAE9B,OAAO,EAAE,UAAU,IAAI,mBAAmB,EAAE,CAAA;AAE5C,eAAe,SAAS,CAAA"}
package/dist/esm/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import { makeClient } from './client';
2
2
  export { StarlightError } from './errors';
3
3
  export * from './types';
4
+ export * from './utils';
4
5
  /**
5
6
  * This is the default object exported by the SDK module, which is a
6
7
  * pre-created {@link StarlightClient}. In the docs, this is called the "global
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","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;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,SAAS,GAAG,UAAU,EAAE,CAAA;AAE9B,OAAO,EAAE,UAAU,IAAI,mBAAmB,EAAE,CAAA;AAE5C,eAAe,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}. In the docs, this is called the \"global\n * SDK client\". If your application only requests data from a single Starlight\n * workspace, using this client is easier than creating\n * 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 before using it.\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
+ {"version":3,"file":"index.js","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;AACvB,cAAc,SAAS,CAAA;AAEvB;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,SAAS,GAAG,UAAU,EAAE,CAAA;AAE9B,OAAO,EAAE,UAAU,IAAI,mBAAmB,EAAE,CAAA;AAE5C,eAAe,SAAS,CAAA","sourcesContent":["import { makeClient } from './client'\nexport { StarlightError } from './errors'\nexport * from './types'\nexport * from './utils'\n\n/**\n * This is the default object exported by the SDK module, which is a\n * pre-created {@link StarlightClient}. In the docs, this is called the \"global\n * SDK client\". If your application only requests data from a single Starlight\n * workspace, using this client is easier than creating\n * 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 before using it.\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"]}
@@ -0,0 +1,4 @@
1
+ import { MediaFile, MediaObject } from '../types';
2
+ export declare const getMediaFile: (media: MediaObject, variation?: string) => MediaFile;
3
+ export declare const getMediaSource: (media: MediaObject, variation?: string) => string;
4
+ //# sourceMappingURL=image.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"image.d.ts","sourceRoot":"","sources":["../../../src/utils/image.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AASjD,eAAO,MAAM,YAAY,UAChB,WAAW,cACN,MAAM,KACjB,SASF,CAAA;AAED,eAAO,MAAM,cAAc,UAClB,WAAW,cACN,MAAM,KACjB,MAEF,CAAA"}
@@ -0,0 +1,15 @@
1
+ const getOptimizedOrOriginal = (media) => {
2
+ var _a;
3
+ return ((_a = media.files.find((file) => file.variation === 'optimized')) !== null && _a !== void 0 ? _a : media.files.find((file) => file.variation === 'original'));
4
+ };
5
+ export const getMediaFile = (media, variation) => {
6
+ var _a;
7
+ if (variation) {
8
+ return ((_a = media.files.find((file) => file.variation === variation)) !== null && _a !== void 0 ? _a : getOptimizedOrOriginal(media));
9
+ }
10
+ return getOptimizedOrOriginal(media);
11
+ };
12
+ export const getMediaSource = (media, variation) => {
13
+ return getMediaFile(media, variation).path;
14
+ };
15
+ //# sourceMappingURL=image.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"image.js","sourceRoot":"","sources":["../../../src/utils/image.ts"],"names":[],"mappings":"AAEA,MAAM,sBAAsB,GAAG,CAAC,KAAkB,EAAE,EAAE;;IACpD,OAAO,CACL,MAAA,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,SAAS,KAAK,WAAW,CAAC,mCACzD,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,SAAS,KAAK,UAAU,CAAe,CACzE,CAAA;AACH,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,YAAY,GAAG,CAC1B,KAAkB,EAClB,SAAkB,EACP,EAAE;;IACb,IAAI,SAAS,EAAE;QACb,OAAO,CACL,MAAA,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,SAAS,KAAK,SAAS,CAAC,mCACxD,sBAAsB,CAAC,KAAK,CAAC,CAC9B,CAAA;KACF;IAED,OAAO,sBAAsB,CAAC,KAAK,CAAC,CAAA;AACtC,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,cAAc,GAAG,CAC5B,KAAkB,EAClB,SAAkB,EACV,EAAE;IACV,OAAO,YAAY,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC,IAAI,CAAA;AAC5C,CAAC,CAAA","sourcesContent":["import { MediaFile, MediaObject } from '../types'\n\nconst getOptimizedOrOriginal = (media: MediaObject) => {\n return (\n media.files.find((file) => file.variation === 'optimized') ??\n (media.files.find((file) => file.variation === 'original') as MediaFile)\n )\n}\n\nexport const getMediaFile = (\n media: MediaObject,\n variation?: string\n): MediaFile => {\n if (variation) {\n return (\n media.files.find((file) => file.variation === variation) ??\n getOptimizedOrOriginal(media)\n )\n }\n\n return getOptimizedOrOriginal(media)\n}\n\nexport const getMediaSource = (\n media: MediaObject,\n variation?: string\n): string => {\n return getMediaFile(media, variation).path\n}\n"]}
@@ -0,0 +1,2 @@
1
+ export * from './image';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAA"}
@@ -0,0 +1,2 @@
1
+ export * from './image';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAA","sourcesContent":["export * from './image'\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@starlightcms/js-sdk",
3
- "version": "1.0.0",
3
+ "version": "1.1.0",
4
4
  "description": "The Starlight SDK for JavaScript",
5
5
  "workspaces": [
6
6
  "website"