@starlightcms/js-sdk 0.13.1 → 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"]}
@@ -20,7 +20,7 @@ export interface BlockData {
20
20
  * @group Visual Data Blocks
21
21
  */
22
22
  export interface ParagraphBlock extends BlockData {
23
- text: string;
23
+ text: string | null;
24
24
  }
25
25
  /**
26
26
  * Represents a Header block, which is used to render h1 through h6 HTML elements.
@@ -1 +1 @@
1
- {"version":3,"file":"visual.d.ts","sourceRoot":"","sources":["../../../src/types/visual.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,oBAAY,SAAS,GACjB,WAAW,GACX,OAAO,GACP,QAAQ,GACR,OAAO,GACP,KAAK,GACL,MAAM,CAAA;AAEV;;;;GAIG;AACH,MAAM,WAAW,SAAS;IACxB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CACvB;AAED;;;;;GAKG;AACH,MAAM,WAAW,cAAe,SAAQ,SAAS;IAC/C,IAAI,EAAE,MAAM,CAAA;CACb;AAED;;;;GAIG;AACH,MAAM,WAAW,WAAY,SAAQ,SAAS;IAC5C,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,MAAM,CAAA;CACd;AAED;;;;GAIG;AACH,MAAM,WAAW,UAAW,SAAQ,SAAS;IAC3C,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,MAAM,CAAA;IACf,SAAS,EAAE,MAAM,GAAG,QAAQ,CAAA;CAC7B;AAED;;;;;GAKG;AACH,aAAK,SAAS,GAAG;IACf,GAAG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AI,EAAE,SAAS,CAAA;IACf,IAAI,EAAE,CAAC,CAAA;CACR;AAED;;;;;;GAMG;AACH,MAAM,WAAW,UAAU;IACzB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,MAAM,EAAE,eAAe,EAAE,CAAA;CAC1B"}
@@ -1 +1 @@
1
- {"version":3,"file":"visual.js","sourceRoot":"","sources":["../../../src/types/visual.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * All supported block types.\n *\n * @group Visual Data Blocks\n * @internal\n */\nexport type BlockType =\n | 'paragraph'\n | 'quote'\n | 'header'\n | 'image'\n | 'raw'\n | 'list'\n\n/**\n * Base interface for types that represent block data.\n *\n * @group Visual Data Blocks\n */\nexport interface BlockData {\n [key: string]: unknown\n}\n\n/**\n * Represents a Paragraph block, which is the default block type used\n * for text content in the Visual Editor.\n *\n * @group Visual Data Blocks\n */\nexport interface ParagraphBlock extends BlockData {\n text: string\n}\n\n/**\n * Represents a Header block, which is used to render h1 through h6 HTML elements.\n *\n * @group Visual Data Blocks\n */\nexport interface HeaderBlock extends BlockData {\n text: string\n level: number\n}\n\n/**\n * Represents a Quote block, which is used to render a blockquote HTML element.\n *\n * @group Visual Data Blocks\n */\nexport interface QuoteBlock extends BlockData {\n text: string\n caption: string\n alignment: 'left' | 'center'\n}\n\n/**\n * Represents an image file, used in Image blocks.\n *\n * @group Visual Data Blocks\n * @internal\n */\ntype ImageFile = {\n url: string\n width: number\n}\n\n/**\n * Represents an Image block, which is used to render img or picture HTML elements.\n *\n * @group Visual Data Blocks\n */\nexport interface ImageBlock extends BlockData {\n id: number\n url: string\n files: ImageFile[]\n caption?: string\n alt?: string\n href?: string\n}\n\n/**\n * Represents an HTML block, which is used to render custom HTML code. Mainly\n * used to place embeds or heavily customized content structures.\n *\n * @group Visual Data Blocks\n */\nexport interface HTMLBlock extends BlockData {\n html: string\n}\n\n/**\n * Represents a list item, which is used by List blocks.\n *\n * @group Visual Data Blocks\n * @internal\n */\nexport interface ListItem {\n content: string\n items?: ListItem[]\n}\n\n/**\n * Represents a List block, which is used to render ol or ul HTML elements.\n *\n * @group Visual Data Blocks\n */\nexport interface ListBlock extends BlockData {\n style: 'ordered' | 'unordered'\n items: ListItem[]\n}\n\n/**\n * A VisualDataBlock object represents a piece of content. Each block has a\n * specific type and some data associated with it. For instance, a Paragraph\n * block has text data, an Image block has a file path and image metadata, etc.\n *\n * @group Visual Data Blocks\n */\nexport interface VisualDataBlock<D extends BlockData = BlockData> {\n id: string\n type: BlockType\n data: D\n}\n\n/**\n * VisualData represents content generated by Starlight using a \"Visual Editor\"\n * field. It's an object-based data representation made out of \"blocks\". Each\n * block has a type string and some data associated with it.\n *\n * @group Visual Data Blocks\n */\nexport interface VisualData {\n time?: number\n version?: string\n blocks: VisualDataBlock[]\n}\n"]}
1
+ {"version":3,"file":"visual.js","sourceRoot":"","sources":["../../../src/types/visual.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * All supported block types.\n *\n * @group Visual Data Blocks\n * @internal\n */\nexport type BlockType =\n | 'paragraph'\n | 'quote'\n | 'header'\n | 'image'\n | 'raw'\n | 'list'\n\n/**\n * Base interface for types that represent block data.\n *\n * @group Visual Data Blocks\n */\nexport interface BlockData {\n [key: string]: unknown\n}\n\n/**\n * Represents a Paragraph block, which is the default block type used\n * for text content in the Visual Editor.\n *\n * @group Visual Data Blocks\n */\nexport interface ParagraphBlock extends BlockData {\n text: string | null\n}\n\n/**\n * Represents a Header block, which is used to render h1 through h6 HTML elements.\n *\n * @group Visual Data Blocks\n */\nexport interface HeaderBlock extends BlockData {\n text: string\n level: number\n}\n\n/**\n * Represents a Quote block, which is used to render a blockquote HTML element.\n *\n * @group Visual Data Blocks\n */\nexport interface QuoteBlock extends BlockData {\n text: string\n caption: string\n alignment: 'left' | 'center'\n}\n\n/**\n * Represents an image file, used in Image blocks.\n *\n * @group Visual Data Blocks\n * @internal\n */\ntype ImageFile = {\n url: string\n width: number\n}\n\n/**\n * Represents an Image block, which is used to render img or picture HTML elements.\n *\n * @group Visual Data Blocks\n */\nexport interface ImageBlock extends BlockData {\n id: number\n url: string\n files: ImageFile[]\n caption?: string\n alt?: string\n href?: string\n}\n\n/**\n * Represents an HTML block, which is used to render custom HTML code. Mainly\n * used to place embeds or heavily customized content structures.\n *\n * @group Visual Data Blocks\n */\nexport interface HTMLBlock extends BlockData {\n html: string\n}\n\n/**\n * Represents a list item, which is used by List blocks.\n *\n * @group Visual Data Blocks\n * @internal\n */\nexport interface ListItem {\n content: string\n items?: ListItem[]\n}\n\n/**\n * Represents a List block, which is used to render ol or ul HTML elements.\n *\n * @group Visual Data Blocks\n */\nexport interface ListBlock extends BlockData {\n style: 'ordered' | 'unordered'\n items: ListItem[]\n}\n\n/**\n * A VisualDataBlock object represents a piece of content. Each block has a\n * specific type and some data associated with it. For instance, a Paragraph\n * block has text data, an Image block has a file path and image metadata, etc.\n *\n * @group Visual Data Blocks\n */\nexport interface VisualDataBlock<D extends BlockData = BlockData> {\n id: string\n type: BlockType\n data: D\n}\n\n/**\n * VisualData represents content generated by Starlight using a \"Visual Editor\"\n * field. It's an object-based data representation made out of \"blocks\". Each\n * block has a type string and some data associated with it.\n *\n * @group Visual Data Blocks\n */\nexport interface VisualData {\n time?: number\n version?: string\n blocks: VisualDataBlock[]\n}\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"]}
@@ -20,7 +20,7 @@ export interface BlockData {
20
20
  * @group Visual Data Blocks
21
21
  */
22
22
  export interface ParagraphBlock extends BlockData {
23
- text: string;
23
+ text: string | null;
24
24
  }
25
25
  /**
26
26
  * Represents a Header block, which is used to render h1 through h6 HTML elements.
@@ -1 +1 @@
1
- {"version":3,"file":"visual.d.ts","sourceRoot":"","sources":["../../../src/types/visual.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,oBAAY,SAAS,GACjB,WAAW,GACX,OAAO,GACP,QAAQ,GACR,OAAO,GACP,KAAK,GACL,MAAM,CAAA;AAEV;;;;GAIG;AACH,MAAM,WAAW,SAAS;IACxB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CACvB;AAED;;;;;GAKG;AACH,MAAM,WAAW,cAAe,SAAQ,SAAS;IAC/C,IAAI,EAAE,MAAM,CAAA;CACb;AAED;;;;GAIG;AACH,MAAM,WAAW,WAAY,SAAQ,SAAS;IAC5C,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,MAAM,CAAA;CACd;AAED;;;;GAIG;AACH,MAAM,WAAW,UAAW,SAAQ,SAAS;IAC3C,IAAI,EAAE,MAAM,CAA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AE,CAAA;CAClB;AAED;;;;;;GAMG;AACH,MAAM,WAAW,eAAe,CAAC,CAAC,SAAS,SAAS,GAAG,SAAS;IAC9D,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,SAAS,CAAA;IACf,IAAI,EAAE,CAAC,CAAA;CACR;AAED;;;;;;GAMG;AACH,MAAM,WAAW,UAAU;IACzB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,MAAM,EAAE,eAAe,EAAE,CAAA;CAC1B"}
@@ -1 +1 @@
1
- {"version":3,"file":"visual.js","sourceRoot":"","sources":["../../../src/types/visual.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * All supported block types.\n *\n * @group Visual Data Blocks\n * @internal\n */\nexport type BlockType =\n | 'paragraph'\n | 'quote'\n | 'header'\n | 'image'\n | 'raw'\n | 'list'\n\n/**\n * Base interface for types that represent block data.\n *\n * @group Visual Data Blocks\n */\nexport interface BlockData {\n [key: string]: unknown\n}\n\n/**\n * Represents a Paragraph block, which is the default block type used\n * for text content in the Visual Editor.\n *\n * @group Visual Data Blocks\n */\nexport interface ParagraphBlock extends BlockData {\n text: string\n}\n\n/**\n * Represents a Header block, which is used to render h1 through h6 HTML elements.\n *\n * @group Visual Data Blocks\n */\nexport interface HeaderBlock extends BlockData {\n text: string\n level: number\n}\n\n/**\n * Represents a Quote block, which is used to render a blockquote HTML element.\n *\n * @group Visual Data Blocks\n */\nexport interface QuoteBlock extends BlockData {\n text: string\n caption: string\n alignment: 'left' | 'center'\n}\n\n/**\n * Represents an image file, used in Image blocks.\n *\n * @group Visual Data Blocks\n * @internal\n */\ntype ImageFile = {\n url: string\n width: number\n}\n\n/**\n * Represents an Image block, which is used to render img or picture HTML elements.\n *\n * @group Visual Data Blocks\n */\nexport interface ImageBlock extends BlockData {\n id: number\n url: string\n files: ImageFile[]\n caption?: string\n alt?: string\n href?: string\n}\n\n/**\n * Represents an HTML block, which is used to render custom HTML code. Mainly\n * used to place embeds or heavily customized content structures.\n *\n * @group Visual Data Blocks\n */\nexport interface HTMLBlock extends BlockData {\n html: string\n}\n\n/**\n * Represents a list item, which is used by List blocks.\n *\n * @group Visual Data Blocks\n * @internal\n */\nexport interface ListItem {\n content: string\n items?: ListItem[]\n}\n\n/**\n * Represents a List block, which is used to render ol or ul HTML elements.\n *\n * @group Visual Data Blocks\n */\nexport interface ListBlock extends BlockData {\n style: 'ordered' | 'unordered'\n items: ListItem[]\n}\n\n/**\n * A VisualDataBlock object represents a piece of content. Each block has a\n * specific type and some data associated with it. For instance, a Paragraph\n * block has text data, an Image block has a file path and image metadata, etc.\n *\n * @group Visual Data Blocks\n */\nexport interface VisualDataBlock<D extends BlockData = BlockData> {\n id: string\n type: BlockType\n data: D\n}\n\n/**\n * VisualData represents content generated by Starlight using a \"Visual Editor\"\n * field. It's an object-based data representation made out of \"blocks\". Each\n * block has a type string and some data associated with it.\n *\n * @group Visual Data Blocks\n */\nexport interface VisualData {\n time?: number\n version?: string\n blocks: VisualDataBlock[]\n}\n"]}
1
+ {"version":3,"file":"visual.js","sourceRoot":"","sources":["../../../src/types/visual.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * All supported block types.\n *\n * @group Visual Data Blocks\n * @internal\n */\nexport type BlockType =\n | 'paragraph'\n | 'quote'\n | 'header'\n | 'image'\n | 'raw'\n | 'list'\n\n/**\n * Base interface for types that represent block data.\n *\n * @group Visual Data Blocks\n */\nexport interface BlockData {\n [key: string]: unknown\n}\n\n/**\n * Represents a Paragraph block, which is the default block type used\n * for text content in the Visual Editor.\n *\n * @group Visual Data Blocks\n */\nexport interface ParagraphBlock extends BlockData {\n text: string | null\n}\n\n/**\n * Represents a Header block, which is used to render h1 through h6 HTML elements.\n *\n * @group Visual Data Blocks\n */\nexport interface HeaderBlock extends BlockData {\n text: string\n level: number\n}\n\n/**\n * Represents a Quote block, which is used to render a blockquote HTML element.\n *\n * @group Visual Data Blocks\n */\nexport interface QuoteBlock extends BlockData {\n text: string\n caption: string\n alignment: 'left' | 'center'\n}\n\n/**\n * Represents an image file, used in Image blocks.\n *\n * @group Visual Data Blocks\n * @internal\n */\ntype ImageFile = {\n url: string\n width: number\n}\n\n/**\n * Represents an Image block, which is used to render img or picture HTML elements.\n *\n * @group Visual Data Blocks\n */\nexport interface ImageBlock extends BlockData {\n id: number\n url: string\n files: ImageFile[]\n caption?: string\n alt?: string\n href?: string\n}\n\n/**\n * Represents an HTML block, which is used to render custom HTML code. Mainly\n * used to place embeds or heavily customized content structures.\n *\n * @group Visual Data Blocks\n */\nexport interface HTMLBlock extends BlockData {\n html: string\n}\n\n/**\n * Represents a list item, which is used by List blocks.\n *\n * @group Visual Data Blocks\n * @internal\n */\nexport interface ListItem {\n content: string\n items?: ListItem[]\n}\n\n/**\n * Represents a List block, which is used to render ol or ul HTML elements.\n *\n * @group Visual Data Blocks\n */\nexport interface ListBlock extends BlockData {\n style: 'ordered' | 'unordered'\n items: ListItem[]\n}\n\n/**\n * A VisualDataBlock object represents a piece of content. Each block has a\n * specific type and some data associated with it. For instance, a Paragraph\n * block has text data, an Image block has a file path and image metadata, etc.\n *\n * @group Visual Data Blocks\n */\nexport interface VisualDataBlock<D extends BlockData = BlockData> {\n id: string\n type: BlockType\n data: D\n}\n\n/**\n * VisualData represents content generated by Starlight using a \"Visual Editor\"\n * field. It's an object-based data representation made out of \"blocks\". Each\n * block has a type string and some data associated with it.\n *\n * @group Visual Data Blocks\n */\nexport interface VisualData {\n time?: number\n version?: string\n blocks: VisualDataBlock[]\n}\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": "0.13.1",
3
+ "version": "1.1.0",
4
4
  "description": "The Starlight SDK for JavaScript",
5
5
  "workspaces": [
6
6
  "website"