@prismicio/client 7.11.0 → 7.12.0-alpha.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/helpers/asLink.cjs +9 -7
- package/dist/helpers/asLink.cjs.map +1 -1
- package/dist/helpers/asLink.js +9 -7
- package/dist/helpers/asLink.js.map +1 -1
- package/dist/helpers/isFilled.cjs +3 -0
- package/dist/helpers/isFilled.cjs.map +1 -1
- package/dist/helpers/isFilled.d.ts +2 -1
- package/dist/helpers/isFilled.js +3 -0
- package/dist/helpers/isFilled.js.map +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js.map +1 -1
- package/dist/lib/resolveMigrationDocumentData.cjs +6 -1
- package/dist/lib/resolveMigrationDocumentData.cjs.map +1 -1
- package/dist/lib/resolveMigrationDocumentData.js +6 -1
- package/dist/lib/resolveMigrationDocumentData.js.map +1 -1
- package/dist/package.json.cjs +1 -1
- package/dist/package.json.js +1 -1
- package/dist/types/migration/Asset.cjs.map +1 -1
- package/dist/types/migration/Asset.d.ts +3 -3
- package/dist/types/migration/Asset.js.map +1 -1
- package/dist/types/model/contentRelationship.d.ts +1 -0
- package/dist/types/model/link.cjs.map +1 -1
- package/dist/types/model/link.d.ts +1 -0
- package/dist/types/model/link.js.map +1 -1
- package/dist/types/model/linkToMedia.d.ts +1 -0
- package/dist/types/value/contentRelationship.d.ts +24 -1
- package/dist/types/value/link.cjs.map +1 -1
- package/dist/types/value/link.d.ts +26 -3
- package/dist/types/value/link.js.map +1 -1
- package/dist/types/value/linkToMedia.d.ts +13 -1
- package/package.json +2 -2
- package/src/helpers/asLink.ts +11 -8
- package/src/helpers/isFilled.ts +6 -1
- package/src/index.ts +1 -0
- package/src/lib/resolveMigrationDocumentData.ts +10 -3
- package/src/types/migration/Asset.ts +7 -4
- package/src/types/model/contentRelationship.ts +1 -0
- package/src/types/model/link.ts +1 -0
- package/src/types/model/linkToMedia.ts +1 -0
- package/src/types/value/contentRelationship.ts +45 -2
- package/src/types/value/link.ts +49 -6
- package/src/types/value/linkToMedia.ts +21 -2
package/dist/package.json.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Asset.cjs","sources":["../../../../src/types/migration/Asset.ts"],"sourcesContent":["import type { Asset } from \"../api/asset/asset\"\nimport type { FilledImageFieldImage } from \"../value/image\"\nimport type { EmptyLinkField } from \"../value/link\"\nimport type {
|
|
1
|
+
{"version":3,"file":"Asset.cjs","sources":["../../../../src/types/migration/Asset.ts"],"sourcesContent":["import type { Asset } from \"../api/asset/asset\"\nimport type { FilledImageFieldImage } from \"../value/image\"\nimport type { EmptyLinkField } from \"../value/link\"\nimport type {\n\tLinkToMediaField,\n\tSingleLinkToMediaField,\n} from \"../value/linkToMedia\"\nimport { type RTImageNode } from \"../value/richText\"\n\nimport type { InjectMigrationSpecificTypes } from \"./Document\"\n\n/**\n * An asset to be uploaded to Prismic media library.\n */\nexport type MigrationAssetConfig = {\n\t/**\n\t * ID the assets is indexed with on the migration instance.\n\t *\n\t * @remarks\n\t * This property's value is not necessarily the same as the as the one in the\n\t * `file` property. It is mainly used for deduplication within a `Migration`\n\t * instance.\n\t */\n\tid: string | URL | File | NonNullable<ConstructorParameters<File>[0]>[0]\n\n\t/**\n\t * File to be uploaded as an asset.\n\t */\n\tfile: string | URL | File | NonNullable<ConstructorParameters<File>[0]>[0]\n\n\t/**\n\t * Filename of the asset.\n\t */\n\tfilename: string\n\n\t/**\n\t * Notes about the asset. Notes are private and only visible in Prismic media\n\t * library.\n\t */\n\tnotes?: string\n\n\t/**\n\t * Credits and copyright for the asset if any.\n\t */\n\tcredits?: string\n\n\t/**\n\t * Alternate text for the asset.\n\t */\n\talt?: string\n\n\t/**\n\t * Tags associated with the asset.\n\t *\n\t * @remarks\n\t * Tags should be at least 3 characters long and 20 characters at most.\n\t */\n\ttags?: string[]\n}\n\n/**\n * An image field in a migration.\n */\nexport type MigrationImage =\n\t| PrismicMigrationAsset\n\t| ({\n\t\t\t/**\n\t\t\t * A reference to the migration asset used to resolve the image field's\n\t\t\t * value.\n\t\t\t */\n\t\t\tid: PrismicMigrationAsset\n\t } & Record<string, PrismicMigrationAsset>)\n\n/**\n * A link to media field in a migration.\n */\nexport type MigrationLinkToMedia = Pick<\n\tSingleLinkToMediaField<\"filled\">,\n\t\"link_type\"\n> &\n\tPartial<Pick<SingleLinkToMediaField<\"filled\">, \"text\">> & {\n\t\t/**\n\t\t * A reference to the migration asset used to resolve the link to media\n\t\t * field's value.\n\t\t */\n\t\tid: PrismicMigrationAsset\n\t}\n\n/**\n * The minimum amount of information needed to represent a link to media field\n * with the migration API.\n */\nexport type MigrationLinkToMediaField =\n\t| Pick<SingleLinkToMediaField<\"filled\">, \"link_type\" | \"id\" | \"text\">\n\t| EmptyLinkField<\"Media\">\n\n/**\n * A rich text image node in a migration.\n */\nexport type MigrationRTImageNode = InjectMigrationSpecificTypes<\n\tPick<RTImageNode, \"type\" | \"linkTo\">\n> & {\n\t/**\n\t * A reference to the migration asset used to resolve the rich text image\n\t * node's value.\n\t */\n\tid: PrismicMigrationAsset\n}\n\n/**\n * A migration asset used with the Prismic Migration API.\n */\nexport class PrismicMigrationAsset {\n\t/**\n\t * Asset object from Prismic, available once created.\n\t */\n\tasset?: Asset\n\n\t/**\n\t * Configuration of the asset.\n\t */\n\tconfig: MigrationAssetConfig\n\n\t/**\n\t * The initial field value this migration field was created with.\n\t */\n\toriginalField?:\n\t\t| FilledImageFieldImage\n\t\t| LinkToMediaField<\"filled\">\n\t\t| RTImageNode\n\n\t/**\n\t * Creates a migration asset used with the Prismic Migration API.\n\t *\n\t * @param config - Configuration of the asset.\n\t * @param initialField - The initial field value if any.\n\t *\n\t * @returns A migration asset instance.\n\t */\n\tconstructor(\n\t\tconfig: MigrationAssetConfig,\n\t\tinitialField?:\n\t\t\t| FilledImageFieldImage\n\t\t\t| LinkToMediaField<\"filled\">\n\t\t\t| RTImageNode,\n\t) {\n\t\tthis.config = config\n\t\tthis.originalField = initialField\n\t}\n}\n"],"names":[],"mappings":";;;;;MAgHa,sBAAqB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EA2BjC,YACC,QACA,cAGc;AA5Bf;AAAA;AAAA;AAAA;AAKA;AAAA;AAAA;AAAA;AAKA;AAAA;AAAA;AAAA;AAoBC,SAAK,SAAS;AACd,SAAK,gBAAgB;AAAA,EACtB;AACA;;"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Asset } from "../api/asset/asset";
|
|
2
2
|
import type { FilledImageFieldImage } from "../value/image";
|
|
3
3
|
import type { EmptyLinkField } from "../value/link";
|
|
4
|
-
import type { LinkToMediaField } from "../value/linkToMedia";
|
|
4
|
+
import type { LinkToMediaField, SingleLinkToMediaField } from "../value/linkToMedia";
|
|
5
5
|
import { type RTImageNode } from "../value/richText";
|
|
6
6
|
import type { InjectMigrationSpecificTypes } from "./Document";
|
|
7
7
|
/**
|
|
@@ -59,7 +59,7 @@ export type MigrationImage = PrismicMigrationAsset | ({
|
|
|
59
59
|
/**
|
|
60
60
|
* A link to media field in a migration.
|
|
61
61
|
*/
|
|
62
|
-
export type MigrationLinkToMedia = Pick<
|
|
62
|
+
export type MigrationLinkToMedia = Pick<SingleLinkToMediaField<"filled">, "link_type"> & Partial<Pick<SingleLinkToMediaField<"filled">, "text">> & {
|
|
63
63
|
/**
|
|
64
64
|
* A reference to the migration asset used to resolve the link to media
|
|
65
65
|
* field's value.
|
|
@@ -70,7 +70,7 @@ export type MigrationLinkToMedia = Pick<LinkToMediaField<"filled">, "link_type">
|
|
|
70
70
|
* The minimum amount of information needed to represent a link to media field
|
|
71
71
|
* with the migration API.
|
|
72
72
|
*/
|
|
73
|
-
export type MigrationLinkToMediaField = Pick<
|
|
73
|
+
export type MigrationLinkToMediaField = Pick<SingleLinkToMediaField<"filled">, "link_type" | "id" | "text"> | EmptyLinkField<"Media">;
|
|
74
74
|
/**
|
|
75
75
|
* A rich text image node in a migration.
|
|
76
76
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Asset.js","sources":["../../../../src/types/migration/Asset.ts"],"sourcesContent":["import type { Asset } from \"../api/asset/asset\"\nimport type { FilledImageFieldImage } from \"../value/image\"\nimport type { EmptyLinkField } from \"../value/link\"\nimport type {
|
|
1
|
+
{"version":3,"file":"Asset.js","sources":["../../../../src/types/migration/Asset.ts"],"sourcesContent":["import type { Asset } from \"../api/asset/asset\"\nimport type { FilledImageFieldImage } from \"../value/image\"\nimport type { EmptyLinkField } from \"../value/link\"\nimport type {\n\tLinkToMediaField,\n\tSingleLinkToMediaField,\n} from \"../value/linkToMedia\"\nimport { type RTImageNode } from \"../value/richText\"\n\nimport type { InjectMigrationSpecificTypes } from \"./Document\"\n\n/**\n * An asset to be uploaded to Prismic media library.\n */\nexport type MigrationAssetConfig = {\n\t/**\n\t * ID the assets is indexed with on the migration instance.\n\t *\n\t * @remarks\n\t * This property's value is not necessarily the same as the as the one in the\n\t * `file` property. It is mainly used for deduplication within a `Migration`\n\t * instance.\n\t */\n\tid: string | URL | File | NonNullable<ConstructorParameters<File>[0]>[0]\n\n\t/**\n\t * File to be uploaded as an asset.\n\t */\n\tfile: string | URL | File | NonNullable<ConstructorParameters<File>[0]>[0]\n\n\t/**\n\t * Filename of the asset.\n\t */\n\tfilename: string\n\n\t/**\n\t * Notes about the asset. Notes are private and only visible in Prismic media\n\t * library.\n\t */\n\tnotes?: string\n\n\t/**\n\t * Credits and copyright for the asset if any.\n\t */\n\tcredits?: string\n\n\t/**\n\t * Alternate text for the asset.\n\t */\n\talt?: string\n\n\t/**\n\t * Tags associated with the asset.\n\t *\n\t * @remarks\n\t * Tags should be at least 3 characters long and 20 characters at most.\n\t */\n\ttags?: string[]\n}\n\n/**\n * An image field in a migration.\n */\nexport type MigrationImage =\n\t| PrismicMigrationAsset\n\t| ({\n\t\t\t/**\n\t\t\t * A reference to the migration asset used to resolve the image field's\n\t\t\t * value.\n\t\t\t */\n\t\t\tid: PrismicMigrationAsset\n\t } & Record<string, PrismicMigrationAsset>)\n\n/**\n * A link to media field in a migration.\n */\nexport type MigrationLinkToMedia = Pick<\n\tSingleLinkToMediaField<\"filled\">,\n\t\"link_type\"\n> &\n\tPartial<Pick<SingleLinkToMediaField<\"filled\">, \"text\">> & {\n\t\t/**\n\t\t * A reference to the migration asset used to resolve the link to media\n\t\t * field's value.\n\t\t */\n\t\tid: PrismicMigrationAsset\n\t}\n\n/**\n * The minimum amount of information needed to represent a link to media field\n * with the migration API.\n */\nexport type MigrationLinkToMediaField =\n\t| Pick<SingleLinkToMediaField<\"filled\">, \"link_type\" | \"id\" | \"text\">\n\t| EmptyLinkField<\"Media\">\n\n/**\n * A rich text image node in a migration.\n */\nexport type MigrationRTImageNode = InjectMigrationSpecificTypes<\n\tPick<RTImageNode, \"type\" | \"linkTo\">\n> & {\n\t/**\n\t * A reference to the migration asset used to resolve the rich text image\n\t * node's value.\n\t */\n\tid: PrismicMigrationAsset\n}\n\n/**\n * A migration asset used with the Prismic Migration API.\n */\nexport class PrismicMigrationAsset {\n\t/**\n\t * Asset object from Prismic, available once created.\n\t */\n\tasset?: Asset\n\n\t/**\n\t * Configuration of the asset.\n\t */\n\tconfig: MigrationAssetConfig\n\n\t/**\n\t * The initial field value this migration field was created with.\n\t */\n\toriginalField?:\n\t\t| FilledImageFieldImage\n\t\t| LinkToMediaField<\"filled\">\n\t\t| RTImageNode\n\n\t/**\n\t * Creates a migration asset used with the Prismic Migration API.\n\t *\n\t * @param config - Configuration of the asset.\n\t * @param initialField - The initial field value if any.\n\t *\n\t * @returns A migration asset instance.\n\t */\n\tconstructor(\n\t\tconfig: MigrationAssetConfig,\n\t\tinitialField?:\n\t\t\t| FilledImageFieldImage\n\t\t\t| LinkToMediaField<\"filled\">\n\t\t\t| RTImageNode,\n\t) {\n\t\tthis.config = config\n\t\tthis.originalField = initialField\n\t}\n}\n"],"names":[],"mappings":";;;MAgHa,sBAAqB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EA2BjC,YACC,QACA,cAGc;AA5Bf;AAAA;AAAA;AAAA;AAKA;AAAA;AAAA;AAAA;AAKA;AAAA;AAAA;AAAA;AAoBC,SAAK,SAAS;AACd,SAAK,gBAAgB;AAAA,EACtB;AACA;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"link.cjs","sources":["../../../../src/types/model/link.ts"],"sourcesContent":["import type { CustomTypeModelFieldType } from \"./types\"\n\n/**\n * A link custom type field.\n *\n * More details: {@link https://prismic.io/docs/link}\n */\nexport interface CustomTypeModelLinkField {\n\ttype: typeof CustomTypeModelFieldType.Link\n\tconfig?: {\n\t\tlabel?: string | null\n\t\tplaceholder?: string\n\t\tselect?:\n\t\t\t| null\n\t\t\t| (typeof CustomTypeModelLinkSelectType)[keyof typeof CustomTypeModelLinkSelectType]\n\t\tallowText?: boolean\n\t\tallowTargetBlank?: boolean\n\t}\n}\n\n/**\n * Type of a link custom type field.\n *\n * More details: {@link https://prismic.io/docs/link}\n */\nexport const CustomTypeModelLinkSelectType = {\n\tDocument: \"document\",\n\tMedia: \"media\",\n\tWeb: \"web\",\n} as const\n"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"link.cjs","sources":["../../../../src/types/model/link.ts"],"sourcesContent":["import type { CustomTypeModelFieldType } from \"./types\"\n\n/**\n * A link custom type field.\n *\n * More details: {@link https://prismic.io/docs/link}\n */\nexport interface CustomTypeModelLinkField {\n\ttype: typeof CustomTypeModelFieldType.Link\n\tconfig?: {\n\t\tlabel?: string | null\n\t\tplaceholder?: string\n\t\tselect?:\n\t\t\t| null\n\t\t\t| (typeof CustomTypeModelLinkSelectType)[keyof typeof CustomTypeModelLinkSelectType]\n\t\tallowText?: boolean\n\t\tallowTargetBlank?: boolean\n\t\trepeat?: boolean\n\t}\n}\n\n/**\n * Type of a link custom type field.\n *\n * More details: {@link https://prismic.io/docs/link}\n */\nexport const CustomTypeModelLinkSelectType = {\n\tDocument: \"document\",\n\tMedia: \"media\",\n\tWeb: \"web\",\n} as const\n"],"names":[],"mappings":";;AA0BO,MAAM,gCAAgC;AAAA,EAC5C,UAAU;AAAA,EACV,OAAO;AAAA,EACP,KAAK;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"link.js","sources":["../../../../src/types/model/link.ts"],"sourcesContent":["import type { CustomTypeModelFieldType } from \"./types\"\n\n/**\n * A link custom type field.\n *\n * More details: {@link https://prismic.io/docs/link}\n */\nexport interface CustomTypeModelLinkField {\n\ttype: typeof CustomTypeModelFieldType.Link\n\tconfig?: {\n\t\tlabel?: string | null\n\t\tplaceholder?: string\n\t\tselect?:\n\t\t\t| null\n\t\t\t| (typeof CustomTypeModelLinkSelectType)[keyof typeof CustomTypeModelLinkSelectType]\n\t\tallowText?: boolean\n\t\tallowTargetBlank?: boolean\n\t}\n}\n\n/**\n * Type of a link custom type field.\n *\n * More details: {@link https://prismic.io/docs/link}\n */\nexport const CustomTypeModelLinkSelectType = {\n\tDocument: \"document\",\n\tMedia: \"media\",\n\tWeb: \"web\",\n} as const\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"link.js","sources":["../../../../src/types/model/link.ts"],"sourcesContent":["import type { CustomTypeModelFieldType } from \"./types\"\n\n/**\n * A link custom type field.\n *\n * More details: {@link https://prismic.io/docs/link}\n */\nexport interface CustomTypeModelLinkField {\n\ttype: typeof CustomTypeModelFieldType.Link\n\tconfig?: {\n\t\tlabel?: string | null\n\t\tplaceholder?: string\n\t\tselect?:\n\t\t\t| null\n\t\t\t| (typeof CustomTypeModelLinkSelectType)[keyof typeof CustomTypeModelLinkSelectType]\n\t\tallowText?: boolean\n\t\tallowTargetBlank?: boolean\n\t\trepeat?: boolean\n\t}\n}\n\n/**\n * Type of a link custom type field.\n *\n * More details: {@link https://prismic.io/docs/link}\n */\nexport const CustomTypeModelLinkSelectType = {\n\tDocument: \"document\",\n\tMedia: \"media\",\n\tWeb: \"web\",\n} as const\n"],"names":[],"mappings":"AA0BO,MAAM,gCAAgC;AAAA,EAC5C,UAAU;AAAA,EACV,OAAO;AAAA,EACP,KAAK;;"}
|
|
@@ -2,6 +2,29 @@ import type { AnyRegularField, FieldState } from "./types";
|
|
|
2
2
|
import type { GroupField } from "./group";
|
|
3
3
|
import type { EmptyLinkField, LinkType } from "./link";
|
|
4
4
|
import type { SliceZone } from "./sliceZone";
|
|
5
|
+
/**
|
|
6
|
+
* Single field value for related documents
|
|
7
|
+
*
|
|
8
|
+
* @typeParam TypeEnum - Type API ID of the document.
|
|
9
|
+
* @typeParam LangEnum - Language API ID of the document.
|
|
10
|
+
* @typeParam DataInterface - Data fields for the document (filled in via
|
|
11
|
+
* GraphQuery of `fetchLinks`).
|
|
12
|
+
* @typeParam State - State of the field which determines its shape.
|
|
13
|
+
*/
|
|
14
|
+
export type SingleContentRelationshipField<TypeEnum = string, LangEnum = string, DataInterface extends Record<string, AnyRegularField | GroupField | SliceZone> | unknown = unknown, State extends FieldState = FieldState> = State extends "empty" ? EmptyLinkField<typeof LinkType.Document> : FilledContentRelationshipField<TypeEnum, LangEnum, DataInterface>;
|
|
15
|
+
/**
|
|
16
|
+
* Repeatable field value for related documents
|
|
17
|
+
*
|
|
18
|
+
* @typeParam TypeEnum - Type API ID of the document.
|
|
19
|
+
* @typeParam LangEnum - Language API ID of the document.
|
|
20
|
+
* @typeParam DataInterface - Data fields for the document (filled in via
|
|
21
|
+
* GraphQuery of `fetchLinks`).
|
|
22
|
+
* @typeParam State - State of the field which determines its shape.
|
|
23
|
+
*/
|
|
24
|
+
export type RepeatableContentRelationshipField<TypeEnum = string, LangEnum = string, DataInterface extends Record<string, AnyRegularField | GroupField | SliceZone> | unknown = unknown, State extends FieldState = FieldState> = State extends "empty" ? [] : [
|
|
25
|
+
SingleContentRelationshipField<TypeEnum, LangEnum, DataInterface>,
|
|
26
|
+
...SingleContentRelationshipField<TypeEnum, LangEnum, DataInterface>[]
|
|
27
|
+
];
|
|
5
28
|
/**
|
|
6
29
|
* Field for related documents
|
|
7
30
|
*
|
|
@@ -11,7 +34,7 @@ import type { SliceZone } from "./sliceZone";
|
|
|
11
34
|
* GraphQuery of `fetchLinks`).
|
|
12
35
|
* @typeParam State - State of the field which determines its shape.
|
|
13
36
|
*/
|
|
14
|
-
export type ContentRelationshipField<TypeEnum = string, LangEnum = string, DataInterface extends Record<string, AnyRegularField | GroupField | SliceZone> | unknown = unknown, State extends FieldState = FieldState> =
|
|
37
|
+
export type ContentRelationshipField<TypeEnum = string, LangEnum = string, DataInterface extends Record<string, AnyRegularField | GroupField | SliceZone> | unknown = unknown, State extends FieldState = FieldState> = SingleContentRelationshipField<TypeEnum, LangEnum, DataInterface, State> | RepeatableContentRelationshipField<TypeEnum, LangEnum, DataInterface, State>;
|
|
15
38
|
/**
|
|
16
39
|
* Links that refer to documents
|
|
17
40
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"link.cjs","sources":["../../../../src/types/value/link.ts"],"sourcesContent":["import type { AnyRegularField, FieldState } from \"./types\"\n\nimport type {
|
|
1
|
+
{"version":3,"file":"link.cjs","sources":["../../../../src/types/value/link.ts"],"sourcesContent":["import type { AnyRegularField, FieldState } from \"./types\"\n\nimport type { SingleContentRelationshipField } from \"./contentRelationship\"\nimport type { GroupField } from \"./group\"\nimport type { SingleLinkToMediaField } from \"./linkToMedia\"\nimport type { SliceZone } from \"./sliceZone\"\n\n/**\n * Link types\n */\nexport const LinkType = {\n\tAny: \"Any\",\n\tDocument: \"Document\",\n\tMedia: \"Media\",\n\tWeb: \"Web\",\n} as const\n\n/**\n * For link fields that haven't been filled\n *\n * @typeParam Type - The type of link.\n */\nexport type EmptyLinkField<\n\tType extends (typeof LinkType)[keyof typeof LinkType] = typeof LinkType.Any,\n> = {\n\tlink_type: Type | string\n\ttext?: string\n}\n\n/**\n * Link that points to external website\n */\nexport interface FilledLinkToWebField {\n\tlink_type: typeof LinkType.Web\n\turl: string\n\ttarget?: string\n\ttext?: string\n}\n\n/**\n * A single link field value.\n *\n * @typeParam TypeEnum - Type API ID of the document.\n * @typeParam LangEnum - Language API ID of the document.\n * @typeParam DataInterface - Data fields for the document (filled in via\n * GraphQuery of `fetchLinks`).\n * @typeParam State - State of the field which determines its shape.\n */\nexport type SingleLinkField<\n\tTypeEnum = string,\n\tLangEnum = string,\n\tDataInterface extends\n\t\t| Record<string, AnyRegularField | GroupField | SliceZone>\n\t\t| unknown = unknown,\n\tState extends FieldState = FieldState,\n> = State extends \"empty\"\n\t? EmptyLinkField<typeof LinkType.Any>\n\t:\n\t\t\t| SingleContentRelationshipField<TypeEnum, LangEnum, DataInterface, State>\n\t\t\t| FilledLinkToWebField\n\t\t\t| SingleLinkToMediaField<State>\n\n/**\n * A repeatable link field value.\n *\n * @typeParam TypeEnum - Type API ID of the document.\n * @typeParam LangEnum - Language API ID of the document.\n * @typeParam DataInterface - Data fields for the document (filled in via\n * GraphQuery of `fetchLinks`).\n * @typeParam State - State of the field which determines its shape.\n */\nexport type RepeatableLinkFieldValue<\n\tTypeEnum = string,\n\tLangEnum = string,\n\tDataInterface extends\n\t\t| Record<string, AnyRegularField | GroupField | SliceZone>\n\t\t| unknown = unknown,\n\tState extends FieldState = FieldState,\n> = State extends \"empty\"\n\t? []\n\t: [\n\t\t\tSingleLinkField<TypeEnum, LangEnum, DataInterface>,\n\t\t\t...SingleLinkField<TypeEnum, LangEnum, DataInterface>[],\n\t\t]\n\n/**\n * A link field.\n *\n * @typeParam TypeEnum - Type API ID of the document.\n * @typeParam LangEnum - Language API ID of the document.\n * @typeParam DataInterface - Data fields for the document (filled in via\n * GraphQuery of `fetchLinks`).\n * @typeParam State - State of the field which determines its shape.\n */\nexport type LinkField<\n\tTypeEnum = string,\n\tLangEnum = string,\n\tDataInterface extends\n\t\t| Record<string, AnyRegularField | GroupField | SliceZone>\n\t\t| unknown = unknown,\n\tState extends FieldState = FieldState,\n> =\n\t| SingleLinkField<TypeEnum, LangEnum, DataInterface, State>\n\t| RepeatableLinkFieldValue<TypeEnum, LangEnum, DataInterface, State>\n"],"names":[],"mappings":";;AAUO,MAAM,WAAW;AAAA,EACvB,KAAK;AAAA,EACL,UAAU;AAAA,EACV,OAAO;AAAA,EACP,KAAK;;;"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { AnyRegularField, FieldState } from "./types";
|
|
2
|
-
import type {
|
|
2
|
+
import type { SingleContentRelationshipField } from "./contentRelationship";
|
|
3
3
|
import type { GroupField } from "./group";
|
|
4
|
-
import type {
|
|
4
|
+
import type { SingleLinkToMediaField } from "./linkToMedia";
|
|
5
5
|
import type { SliceZone } from "./sliceZone";
|
|
6
6
|
/**
|
|
7
7
|
* Link types
|
|
@@ -30,6 +30,29 @@ export interface FilledLinkToWebField {
|
|
|
30
30
|
target?: string;
|
|
31
31
|
text?: string;
|
|
32
32
|
}
|
|
33
|
+
/**
|
|
34
|
+
* A single link field value.
|
|
35
|
+
*
|
|
36
|
+
* @typeParam TypeEnum - Type API ID of the document.
|
|
37
|
+
* @typeParam LangEnum - Language API ID of the document.
|
|
38
|
+
* @typeParam DataInterface - Data fields for the document (filled in via
|
|
39
|
+
* GraphQuery of `fetchLinks`).
|
|
40
|
+
* @typeParam State - State of the field which determines its shape.
|
|
41
|
+
*/
|
|
42
|
+
export type SingleLinkField<TypeEnum = string, LangEnum = string, DataInterface extends Record<string, AnyRegularField | GroupField | SliceZone> | unknown = unknown, State extends FieldState = FieldState> = State extends "empty" ? EmptyLinkField<typeof LinkType.Any> : SingleContentRelationshipField<TypeEnum, LangEnum, DataInterface, State> | FilledLinkToWebField | SingleLinkToMediaField<State>;
|
|
43
|
+
/**
|
|
44
|
+
* A repeatable link field value.
|
|
45
|
+
*
|
|
46
|
+
* @typeParam TypeEnum - Type API ID of the document.
|
|
47
|
+
* @typeParam LangEnum - Language API ID of the document.
|
|
48
|
+
* @typeParam DataInterface - Data fields for the document (filled in via
|
|
49
|
+
* GraphQuery of `fetchLinks`).
|
|
50
|
+
* @typeParam State - State of the field which determines its shape.
|
|
51
|
+
*/
|
|
52
|
+
export type RepeatableLinkFieldValue<TypeEnum = string, LangEnum = string, DataInterface extends Record<string, AnyRegularField | GroupField | SliceZone> | unknown = unknown, State extends FieldState = FieldState> = State extends "empty" ? [] : [
|
|
53
|
+
SingleLinkField<TypeEnum, LangEnum, DataInterface>,
|
|
54
|
+
...SingleLinkField<TypeEnum, LangEnum, DataInterface>[]
|
|
55
|
+
];
|
|
33
56
|
/**
|
|
34
57
|
* A link field.
|
|
35
58
|
*
|
|
@@ -39,4 +62,4 @@ export interface FilledLinkToWebField {
|
|
|
39
62
|
* GraphQuery of `fetchLinks`).
|
|
40
63
|
* @typeParam State - State of the field which determines its shape.
|
|
41
64
|
*/
|
|
42
|
-
export type LinkField<TypeEnum = string, LangEnum = string, DataInterface extends Record<string, AnyRegularField | GroupField | SliceZone> | unknown = unknown, State extends FieldState = FieldState> =
|
|
65
|
+
export type LinkField<TypeEnum = string, LangEnum = string, DataInterface extends Record<string, AnyRegularField | GroupField | SliceZone> | unknown = unknown, State extends FieldState = FieldState> = SingleLinkField<TypeEnum, LangEnum, DataInterface, State> | RepeatableLinkFieldValue<TypeEnum, LangEnum, DataInterface, State>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"link.js","sources":["../../../../src/types/value/link.ts"],"sourcesContent":["import type { AnyRegularField, FieldState } from \"./types\"\n\nimport type {
|
|
1
|
+
{"version":3,"file":"link.js","sources":["../../../../src/types/value/link.ts"],"sourcesContent":["import type { AnyRegularField, FieldState } from \"./types\"\n\nimport type { SingleContentRelationshipField } from \"./contentRelationship\"\nimport type { GroupField } from \"./group\"\nimport type { SingleLinkToMediaField } from \"./linkToMedia\"\nimport type { SliceZone } from \"./sliceZone\"\n\n/**\n * Link types\n */\nexport const LinkType = {\n\tAny: \"Any\",\n\tDocument: \"Document\",\n\tMedia: \"Media\",\n\tWeb: \"Web\",\n} as const\n\n/**\n * For link fields that haven't been filled\n *\n * @typeParam Type - The type of link.\n */\nexport type EmptyLinkField<\n\tType extends (typeof LinkType)[keyof typeof LinkType] = typeof LinkType.Any,\n> = {\n\tlink_type: Type | string\n\ttext?: string\n}\n\n/**\n * Link that points to external website\n */\nexport interface FilledLinkToWebField {\n\tlink_type: typeof LinkType.Web\n\turl: string\n\ttarget?: string\n\ttext?: string\n}\n\n/**\n * A single link field value.\n *\n * @typeParam TypeEnum - Type API ID of the document.\n * @typeParam LangEnum - Language API ID of the document.\n * @typeParam DataInterface - Data fields for the document (filled in via\n * GraphQuery of `fetchLinks`).\n * @typeParam State - State of the field which determines its shape.\n */\nexport type SingleLinkField<\n\tTypeEnum = string,\n\tLangEnum = string,\n\tDataInterface extends\n\t\t| Record<string, AnyRegularField | GroupField | SliceZone>\n\t\t| unknown = unknown,\n\tState extends FieldState = FieldState,\n> = State extends \"empty\"\n\t? EmptyLinkField<typeof LinkType.Any>\n\t:\n\t\t\t| SingleContentRelationshipField<TypeEnum, LangEnum, DataInterface, State>\n\t\t\t| FilledLinkToWebField\n\t\t\t| SingleLinkToMediaField<State>\n\n/**\n * A repeatable link field value.\n *\n * @typeParam TypeEnum - Type API ID of the document.\n * @typeParam LangEnum - Language API ID of the document.\n * @typeParam DataInterface - Data fields for the document (filled in via\n * GraphQuery of `fetchLinks`).\n * @typeParam State - State of the field which determines its shape.\n */\nexport type RepeatableLinkFieldValue<\n\tTypeEnum = string,\n\tLangEnum = string,\n\tDataInterface extends\n\t\t| Record<string, AnyRegularField | GroupField | SliceZone>\n\t\t| unknown = unknown,\n\tState extends FieldState = FieldState,\n> = State extends \"empty\"\n\t? []\n\t: [\n\t\t\tSingleLinkField<TypeEnum, LangEnum, DataInterface>,\n\t\t\t...SingleLinkField<TypeEnum, LangEnum, DataInterface>[],\n\t\t]\n\n/**\n * A link field.\n *\n * @typeParam TypeEnum - Type API ID of the document.\n * @typeParam LangEnum - Language API ID of the document.\n * @typeParam DataInterface - Data fields for the document (filled in via\n * GraphQuery of `fetchLinks`).\n * @typeParam State - State of the field which determines its shape.\n */\nexport type LinkField<\n\tTypeEnum = string,\n\tLangEnum = string,\n\tDataInterface extends\n\t\t| Record<string, AnyRegularField | GroupField | SliceZone>\n\t\t| unknown = unknown,\n\tState extends FieldState = FieldState,\n> =\n\t| SingleLinkField<TypeEnum, LangEnum, DataInterface, State>\n\t| RepeatableLinkFieldValue<TypeEnum, LangEnum, DataInterface, State>\n"],"names":[],"mappings":"AAUO,MAAM,WAAW;AAAA,EACvB,KAAK;AAAA,EACL,UAAU;AAAA,EACV,OAAO;AAAA,EACP,KAAK;;"}
|
|
@@ -1,11 +1,23 @@
|
|
|
1
1
|
import type { FieldState } from "./types";
|
|
2
2
|
import type { EmptyLinkField, LinkType } from "./link";
|
|
3
|
+
/**
|
|
4
|
+
* A single link field value that points to media.
|
|
5
|
+
*
|
|
6
|
+
* @typeParam State - State of the field which determines its shape.
|
|
7
|
+
*/
|
|
8
|
+
export type SingleLinkToMediaField<State extends FieldState = FieldState> = State extends "empty" ? EmptyLinkField<typeof LinkType.Media> : FilledLinkToMediaField;
|
|
9
|
+
/**
|
|
10
|
+
* Repeatable link field values that point to media.
|
|
11
|
+
*
|
|
12
|
+
* @typeParam State - State of the field which determines its shape.
|
|
13
|
+
*/
|
|
14
|
+
export type RepeatableLinkToMediaField<State extends FieldState = FieldState> = State extends "empty" ? [] : [SingleLinkToMediaField, ...SingleLinkToMediaField[]];
|
|
3
15
|
/**
|
|
4
16
|
* A link field that points to media.
|
|
5
17
|
*
|
|
6
18
|
* @typeParam State - State of the field which determines its shape.
|
|
7
19
|
*/
|
|
8
|
-
export type LinkToMediaField<State extends FieldState = FieldState> = State
|
|
20
|
+
export type LinkToMediaField<State extends FieldState = FieldState> = SingleLinkToMediaField<State> | RepeatableLinkToMediaField<State>;
|
|
9
21
|
/**
|
|
10
22
|
* A link that points to media.
|
|
11
23
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prismicio/client",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.12.0-alpha.0",
|
|
4
4
|
"description": "The official JavaScript + TypeScript client library for Prismic",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typescript",
|
|
@@ -83,7 +83,7 @@
|
|
|
83
83
|
},
|
|
84
84
|
"devDependencies": {
|
|
85
85
|
"@prismicio/mock": "^0.3.9",
|
|
86
|
-
"@prismicio/types-internal": "^2.
|
|
86
|
+
"@prismicio/types-internal": "^2.9.0-alpha.0",
|
|
87
87
|
"@size-limit/preset-small-lib": "^11.1.4",
|
|
88
88
|
"@trivago/prettier-plugin-sort-imports": "^4.3.0",
|
|
89
89
|
"@typescript-eslint/eslint-plugin": "^6.21.0",
|
package/src/helpers/asLink.ts
CHANGED
|
@@ -140,17 +140,20 @@ export const asLink: {
|
|
|
140
140
|
return null as AsLinkReturnType<LinkResolverFunctionReturnType, Field>
|
|
141
141
|
}
|
|
142
142
|
|
|
143
|
-
//
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
143
|
+
// If the link field is repeatable, then it returns the first link in
|
|
144
|
+
// the array. If not, then it converts document to link field if needed
|
|
145
|
+
let linkField: LinkField
|
|
146
|
+
if (Array.isArray(linkFieldOrDocument)) {
|
|
147
|
+
if (!linkFieldOrDocument[0]) {
|
|
148
|
+
return null as AsLinkReturnType<LinkResolverFunctionReturnType, Field>
|
|
149
|
+
}
|
|
150
|
+
linkField = linkFieldOrDocument[0]
|
|
151
|
+
} else {
|
|
152
|
+
linkField =
|
|
150
153
|
"link_type" in linkFieldOrDocument
|
|
151
154
|
? linkFieldOrDocument
|
|
152
155
|
: documentToLinkField(linkFieldOrDocument)
|
|
153
|
-
|
|
156
|
+
}
|
|
154
157
|
|
|
155
158
|
// TODO: Remove when we remove support for deprecated tuple-style configuration.
|
|
156
159
|
const [configObjectOrLinkResolver] = configObjectOrTuple
|
package/src/helpers/isFilled.ts
CHANGED
|
@@ -100,7 +100,8 @@ export const image = imageThumbnail as <
|
|
|
100
100
|
) => field is ImageField<ThumbnailNames, "filled">
|
|
101
101
|
|
|
102
102
|
/**
|
|
103
|
-
* Determines if a link field is filled.
|
|
103
|
+
* Determines if a link field is filled. If the field is repeatable, it checks
|
|
104
|
+
* if the link array contains at least one item
|
|
104
105
|
*
|
|
105
106
|
* @param field - Link field to check.
|
|
106
107
|
*
|
|
@@ -115,6 +116,10 @@ export const link = <
|
|
|
115
116
|
>(
|
|
116
117
|
field: LinkField<TypeEnum, LangEnum, DataInterface> | null | undefined,
|
|
117
118
|
): field is LinkField<TypeEnum, LangEnum, DataInterface, "filled"> => {
|
|
119
|
+
if (Array.isArray(field)) {
|
|
120
|
+
return isNonNullish(field) && isNonEmptyArray(field)
|
|
121
|
+
}
|
|
122
|
+
|
|
118
123
|
return isNonNullish(field) && ("id" in field || "url" in field)
|
|
119
124
|
}
|
|
120
125
|
|
package/src/index.ts
CHANGED
|
@@ -11,7 +11,7 @@ import type {
|
|
|
11
11
|
} from "../types/migration/ContentRelationship"
|
|
12
12
|
import { PrismicMigrationDocument } from "../types/migration/Document"
|
|
13
13
|
import type { FilledImageFieldImage } from "../types/value/image"
|
|
14
|
-
import type {
|
|
14
|
+
import type { SingleLinkField } from "../types/value/link"
|
|
15
15
|
import { LinkType } from "../types/value/link"
|
|
16
16
|
import type { RTImageNode } from "../types/value/richText"
|
|
17
17
|
import { RichTextNodeType } from "../types/value/richText"
|
|
@@ -78,7 +78,14 @@ export const resolveMigrationImage = (
|
|
|
78
78
|
image instanceof PrismicMigrationAsset ? { id: image } : image
|
|
79
79
|
|
|
80
80
|
const asset = migration._assets.get(master.config.id)?.asset
|
|
81
|
-
|
|
81
|
+
let maybeInitialField
|
|
82
|
+
if (Array.isArray(master.originalField)) {
|
|
83
|
+
maybeInitialField = isFilled.link(master.originalField[0])
|
|
84
|
+
? master.originalField[0]
|
|
85
|
+
: undefined
|
|
86
|
+
} else {
|
|
87
|
+
maybeInitialField = master.originalField
|
|
88
|
+
}
|
|
82
89
|
|
|
83
90
|
if (asset) {
|
|
84
91
|
const parameters = (maybeInitialField?.url || asset.url).split("?")[1]
|
|
@@ -135,7 +142,7 @@ export const resolveMigrationRTImageNode = async (
|
|
|
135
142
|
const linkTo = (await resolveMigrationDocumentData(
|
|
136
143
|
rtImageNode.linkTo,
|
|
137
144
|
migration,
|
|
138
|
-
)) as
|
|
145
|
+
)) as SingleLinkField
|
|
139
146
|
|
|
140
147
|
return {
|
|
141
148
|
...image,
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import type { Asset } from "../api/asset/asset"
|
|
2
2
|
import type { FilledImageFieldImage } from "../value/image"
|
|
3
3
|
import type { EmptyLinkField } from "../value/link"
|
|
4
|
-
import type {
|
|
4
|
+
import type {
|
|
5
|
+
LinkToMediaField,
|
|
6
|
+
SingleLinkToMediaField,
|
|
7
|
+
} from "../value/linkToMedia"
|
|
5
8
|
import { type RTImageNode } from "../value/richText"
|
|
6
9
|
|
|
7
10
|
import type { InjectMigrationSpecificTypes } from "./Document"
|
|
@@ -72,10 +75,10 @@ export type MigrationImage =
|
|
|
72
75
|
* A link to media field in a migration.
|
|
73
76
|
*/
|
|
74
77
|
export type MigrationLinkToMedia = Pick<
|
|
75
|
-
|
|
78
|
+
SingleLinkToMediaField<"filled">,
|
|
76
79
|
"link_type"
|
|
77
80
|
> &
|
|
78
|
-
Partial<Pick<
|
|
81
|
+
Partial<Pick<SingleLinkToMediaField<"filled">, "text">> & {
|
|
79
82
|
/**
|
|
80
83
|
* A reference to the migration asset used to resolve the link to media
|
|
81
84
|
* field's value.
|
|
@@ -88,7 +91,7 @@ export type MigrationLinkToMedia = Pick<
|
|
|
88
91
|
* with the migration API.
|
|
89
92
|
*/
|
|
90
93
|
export type MigrationLinkToMediaField =
|
|
91
|
-
| Pick<
|
|
94
|
+
| Pick<SingleLinkToMediaField<"filled">, "link_type" | "id" | "text">
|
|
92
95
|
| EmptyLinkField<"Media">
|
|
93
96
|
|
|
94
97
|
/**
|
package/src/types/model/link.ts
CHANGED
|
@@ -5,7 +5,7 @@ import type { EmptyLinkField, LinkType } from "./link"
|
|
|
5
5
|
import type { SliceZone } from "./sliceZone"
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
|
-
*
|
|
8
|
+
* Single field value for related documents
|
|
9
9
|
*
|
|
10
10
|
* @typeParam TypeEnum - Type API ID of the document.
|
|
11
11
|
* @typeParam LangEnum - Language API ID of the document.
|
|
@@ -13,7 +13,7 @@ import type { SliceZone } from "./sliceZone"
|
|
|
13
13
|
* GraphQuery of `fetchLinks`).
|
|
14
14
|
* @typeParam State - State of the field which determines its shape.
|
|
15
15
|
*/
|
|
16
|
-
export type
|
|
16
|
+
export type SingleContentRelationshipField<
|
|
17
17
|
TypeEnum = string,
|
|
18
18
|
LangEnum = string,
|
|
19
19
|
DataInterface extends
|
|
@@ -24,6 +24,49 @@ export type ContentRelationshipField<
|
|
|
24
24
|
? EmptyLinkField<typeof LinkType.Document>
|
|
25
25
|
: FilledContentRelationshipField<TypeEnum, LangEnum, DataInterface>
|
|
26
26
|
|
|
27
|
+
/**
|
|
28
|
+
* Repeatable field value for related documents
|
|
29
|
+
*
|
|
30
|
+
* @typeParam TypeEnum - Type API ID of the document.
|
|
31
|
+
* @typeParam LangEnum - Language API ID of the document.
|
|
32
|
+
* @typeParam DataInterface - Data fields for the document (filled in via
|
|
33
|
+
* GraphQuery of `fetchLinks`).
|
|
34
|
+
* @typeParam State - State of the field which determines its shape.
|
|
35
|
+
*/
|
|
36
|
+
export type RepeatableContentRelationshipField<
|
|
37
|
+
TypeEnum = string,
|
|
38
|
+
LangEnum = string,
|
|
39
|
+
DataInterface extends
|
|
40
|
+
| Record<string, AnyRegularField | GroupField | SliceZone>
|
|
41
|
+
| unknown = unknown,
|
|
42
|
+
State extends FieldState = FieldState,
|
|
43
|
+
> = State extends "empty"
|
|
44
|
+
? []
|
|
45
|
+
: [
|
|
46
|
+
SingleContentRelationshipField<TypeEnum, LangEnum, DataInterface>,
|
|
47
|
+
...SingleContentRelationshipField<TypeEnum, LangEnum, DataInterface>[],
|
|
48
|
+
]
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Field for related documents
|
|
52
|
+
*
|
|
53
|
+
* @typeParam TypeEnum - Type API ID of the document.
|
|
54
|
+
* @typeParam LangEnum - Language API ID of the document.
|
|
55
|
+
* @typeParam DataInterface - Data fields for the document (filled in via
|
|
56
|
+
* GraphQuery of `fetchLinks`).
|
|
57
|
+
* @typeParam State - State of the field which determines its shape.
|
|
58
|
+
*/
|
|
59
|
+
export type ContentRelationshipField<
|
|
60
|
+
TypeEnum = string,
|
|
61
|
+
LangEnum = string,
|
|
62
|
+
DataInterface extends
|
|
63
|
+
| Record<string, AnyRegularField | GroupField | SliceZone>
|
|
64
|
+
| unknown = unknown,
|
|
65
|
+
State extends FieldState = FieldState,
|
|
66
|
+
> =
|
|
67
|
+
| SingleContentRelationshipField<TypeEnum, LangEnum, DataInterface, State>
|
|
68
|
+
| RepeatableContentRelationshipField<TypeEnum, LangEnum, DataInterface, State>
|
|
69
|
+
|
|
27
70
|
/**
|
|
28
71
|
* Links that refer to documents
|
|
29
72
|
*/
|
package/src/types/value/link.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { AnyRegularField, FieldState } from "./types"
|
|
2
2
|
|
|
3
|
-
import type {
|
|
3
|
+
import type { SingleContentRelationshipField } from "./contentRelationship"
|
|
4
4
|
import type { GroupField } from "./group"
|
|
5
|
-
import type {
|
|
5
|
+
import type { SingleLinkToMediaField } from "./linkToMedia"
|
|
6
6
|
import type { SliceZone } from "./sliceZone"
|
|
7
7
|
|
|
8
8
|
/**
|
|
@@ -38,7 +38,7 @@ export interface FilledLinkToWebField {
|
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
/**
|
|
41
|
-
* A link field.
|
|
41
|
+
* A single link field value.
|
|
42
42
|
*
|
|
43
43
|
* @typeParam TypeEnum - Type API ID of the document.
|
|
44
44
|
* @typeParam LangEnum - Language API ID of the document.
|
|
@@ -46,7 +46,7 @@ export interface FilledLinkToWebField {
|
|
|
46
46
|
* GraphQuery of `fetchLinks`).
|
|
47
47
|
* @typeParam State - State of the field which determines its shape.
|
|
48
48
|
*/
|
|
49
|
-
export type
|
|
49
|
+
export type SingleLinkField<
|
|
50
50
|
TypeEnum = string,
|
|
51
51
|
LangEnum = string,
|
|
52
52
|
DataInterface extends
|
|
@@ -56,6 +56,49 @@ export type LinkField<
|
|
|
56
56
|
> = State extends "empty"
|
|
57
57
|
? EmptyLinkField<typeof LinkType.Any>
|
|
58
58
|
:
|
|
59
|
-
|
|
|
59
|
+
| SingleContentRelationshipField<TypeEnum, LangEnum, DataInterface, State>
|
|
60
60
|
| FilledLinkToWebField
|
|
61
|
-
|
|
|
61
|
+
| SingleLinkToMediaField<State>
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* A repeatable link field value.
|
|
65
|
+
*
|
|
66
|
+
* @typeParam TypeEnum - Type API ID of the document.
|
|
67
|
+
* @typeParam LangEnum - Language API ID of the document.
|
|
68
|
+
* @typeParam DataInterface - Data fields for the document (filled in via
|
|
69
|
+
* GraphQuery of `fetchLinks`).
|
|
70
|
+
* @typeParam State - State of the field which determines its shape.
|
|
71
|
+
*/
|
|
72
|
+
export type RepeatableLinkFieldValue<
|
|
73
|
+
TypeEnum = string,
|
|
74
|
+
LangEnum = string,
|
|
75
|
+
DataInterface extends
|
|
76
|
+
| Record<string, AnyRegularField | GroupField | SliceZone>
|
|
77
|
+
| unknown = unknown,
|
|
78
|
+
State extends FieldState = FieldState,
|
|
79
|
+
> = State extends "empty"
|
|
80
|
+
? []
|
|
81
|
+
: [
|
|
82
|
+
SingleLinkField<TypeEnum, LangEnum, DataInterface>,
|
|
83
|
+
...SingleLinkField<TypeEnum, LangEnum, DataInterface>[],
|
|
84
|
+
]
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* A link field.
|
|
88
|
+
*
|
|
89
|
+
* @typeParam TypeEnum - Type API ID of the document.
|
|
90
|
+
* @typeParam LangEnum - Language API ID of the document.
|
|
91
|
+
* @typeParam DataInterface - Data fields for the document (filled in via
|
|
92
|
+
* GraphQuery of `fetchLinks`).
|
|
93
|
+
* @typeParam State - State of the field which determines its shape.
|
|
94
|
+
*/
|
|
95
|
+
export type LinkField<
|
|
96
|
+
TypeEnum = string,
|
|
97
|
+
LangEnum = string,
|
|
98
|
+
DataInterface extends
|
|
99
|
+
| Record<string, AnyRegularField | GroupField | SliceZone>
|
|
100
|
+
| unknown = unknown,
|
|
101
|
+
State extends FieldState = FieldState,
|
|
102
|
+
> =
|
|
103
|
+
| SingleLinkField<TypeEnum, LangEnum, DataInterface, State>
|
|
104
|
+
| RepeatableLinkFieldValue<TypeEnum, LangEnum, DataInterface, State>
|
|
@@ -3,15 +3,34 @@ import type { FieldState } from "./types"
|
|
|
3
3
|
import type { EmptyLinkField, LinkType } from "./link"
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
|
-
* A link field that points to media.
|
|
6
|
+
* A single link field value that points to media.
|
|
7
7
|
*
|
|
8
8
|
* @typeParam State - State of the field which determines its shape.
|
|
9
9
|
*/
|
|
10
|
-
export type
|
|
10
|
+
export type SingleLinkToMediaField<State extends FieldState = FieldState> =
|
|
11
11
|
State extends "empty"
|
|
12
12
|
? EmptyLinkField<typeof LinkType.Media>
|
|
13
13
|
: FilledLinkToMediaField
|
|
14
14
|
|
|
15
|
+
/**
|
|
16
|
+
* Repeatable link field values that point to media.
|
|
17
|
+
*
|
|
18
|
+
* @typeParam State - State of the field which determines its shape.
|
|
19
|
+
*/
|
|
20
|
+
export type RepeatableLinkToMediaField<State extends FieldState = FieldState> =
|
|
21
|
+
State extends "empty"
|
|
22
|
+
? []
|
|
23
|
+
: [SingleLinkToMediaField, ...SingleLinkToMediaField[]]
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* A link field that points to media.
|
|
27
|
+
*
|
|
28
|
+
* @typeParam State - State of the field which determines its shape.
|
|
29
|
+
*/
|
|
30
|
+
export type LinkToMediaField<State extends FieldState = FieldState> =
|
|
31
|
+
| SingleLinkToMediaField<State>
|
|
32
|
+
| RepeatableLinkToMediaField<State>
|
|
33
|
+
|
|
15
34
|
/**
|
|
16
35
|
* A link that points to media.
|
|
17
36
|
*/
|