@prismicio/client 7.10.0-alpha.0 → 7.10.1
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/BaseClient.cjs +108 -0
- package/dist/BaseClient.cjs.map +1 -0
- package/dist/BaseClient.d.ts +152 -0
- package/dist/BaseClient.js +108 -0
- package/dist/BaseClient.js.map +1 -0
- package/dist/Client.cjs +1217 -0
- package/dist/Client.cjs.map +1 -0
- package/dist/Client.d.ts +924 -0
- package/dist/Client.js +1217 -0
- package/dist/Client.js.map +1 -0
- package/dist/Migration.cjs +318 -0
- package/dist/Migration.cjs.map +1 -0
- package/dist/Migration.d.ts +213 -0
- package/dist/Migration.js +318 -0
- package/dist/Migration.js.map +1 -0
- package/dist/WriteClient.cjs +515 -0
- package/dist/WriteClient.cjs.map +1 -0
- package/dist/WriteClient.d.ts +314 -0
- package/dist/WriteClient.js +515 -0
- package/dist/WriteClient.js.map +1 -0
- package/dist/createClient.cjs +2 -1215
- package/dist/createClient.cjs.map +1 -1
- package/dist/createClient.d.ts +2 -1003
- package/dist/createClient.js +1 -1214
- package/dist/createClient.js.map +1 -1
- package/dist/createMigration.cjs +6 -0
- package/dist/createMigration.cjs.map +1 -0
- package/dist/createMigration.d.ts +24 -0
- package/dist/createMigration.js +6 -0
- package/dist/createMigration.js.map +1 -0
- package/dist/createWriteClient.cjs +6 -0
- package/dist/createWriteClient.cjs.map +1 -0
- package/dist/createWriteClient.d.ts +32 -0
- package/dist/createWriteClient.js +6 -0
- package/dist/createWriteClient.js.map +1 -0
- package/dist/getRepositoryName.cjs +7 -2
- package/dist/getRepositoryName.cjs.map +1 -1
- package/dist/getRepositoryName.d.ts +3 -6
- package/dist/getRepositoryName.js +7 -2
- package/dist/getRepositoryName.js.map +1 -1
- package/dist/index.cjs +14 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +17 -2
- package/dist/index.js +14 -1
- package/dist/index.js.map +1 -1
- package/dist/lib/isMigrationValue.cjs +24 -0
- package/dist/lib/isMigrationValue.cjs.map +1 -0
- package/dist/lib/isMigrationValue.d.ts +62 -0
- package/dist/lib/isMigrationValue.js +24 -0
- package/dist/lib/isMigrationValue.js.map +1 -0
- package/dist/lib/isValue.cjs +53 -0
- package/dist/lib/isValue.cjs.map +1 -0
- package/dist/lib/isValue.d.ts +72 -0
- package/dist/lib/isValue.js +53 -0
- package/dist/lib/isValue.js.map +1 -0
- package/dist/lib/pLimit.cjs +49 -0
- package/dist/lib/pLimit.cjs.map +1 -0
- package/dist/lib/pLimit.d.ts +22 -0
- package/dist/lib/pLimit.js +49 -0
- package/dist/lib/pLimit.js.map +1 -0
- package/dist/lib/resolveMigrationDocumentData.cjs +123 -0
- package/dist/lib/resolveMigrationDocumentData.cjs.map +1 -0
- package/dist/lib/resolveMigrationDocumentData.d.ts +52 -0
- package/dist/lib/resolveMigrationDocumentData.js +123 -0
- package/dist/lib/resolveMigrationDocumentData.js.map +1 -0
- package/dist/lib/validateAssetMetadata.cjs +28 -0
- package/dist/lib/validateAssetMetadata.cjs.map +1 -0
- package/dist/lib/validateAssetMetadata.d.ts +10 -0
- package/dist/lib/validateAssetMetadata.js +28 -0
- package/dist/lib/validateAssetMetadata.js.map +1 -0
- package/dist/package.json.cjs +1 -1
- package/dist/package.json.js +1 -1
- package/dist/types/api/asset/asset.d.ts +177 -0
- package/dist/types/api/asset/tag.d.ts +53 -0
- package/dist/types/api/migration/document.d.ts +60 -0
- package/dist/types/migration/Asset.cjs +33 -0
- package/dist/types/migration/Asset.cjs.map +1 -0
- package/dist/types/migration/Asset.d.ts +109 -0
- package/dist/types/migration/Asset.js +33 -0
- package/dist/types/migration/Asset.js.map +1 -0
- package/dist/types/migration/ContentRelationship.d.ts +17 -0
- package/dist/types/migration/Document.cjs +47 -0
- package/dist/types/migration/Document.cjs.map +1 -0
- package/dist/types/migration/Document.d.ts +94 -0
- package/dist/types/migration/Document.js +47 -0
- package/dist/types/migration/Document.js.map +1 -0
- package/dist/types/model/link.cjs.map +1 -1
- package/dist/types/model/link.d.ts +0 -1
- package/dist/types/model/link.js.map +1 -1
- package/dist/types/model/linkToMedia.d.ts +0 -1
- package/dist/types/value/contentRelationship.d.ts +0 -1
- package/dist/types/value/link.cjs.map +1 -1
- package/dist/types/value/link.d.ts +0 -2
- package/dist/types/value/link.js.map +1 -1
- package/dist/types/value/linkToMedia.d.ts +0 -1
- package/package.json +2 -2
- package/src/BaseClient.ts +330 -0
- package/src/Client.ts +1787 -0
- package/src/Migration.ts +531 -0
- package/src/WriteClient.ts +916 -0
- package/src/createClient.ts +3 -1931
- package/src/createMigration.ts +31 -0
- package/src/createWriteClient.ts +43 -0
- package/src/getRepositoryName.ts +19 -14
- package/src/index.ts +32 -4
- package/src/lib/isMigrationValue.ts +126 -0
- package/src/lib/isValue.ts +196 -0
- package/src/lib/pLimit.ts +106 -0
- package/src/lib/resolveMigrationDocumentData.ts +233 -0
- package/src/lib/validateAssetMetadata.ts +82 -0
- package/src/types/api/asset/asset.ts +211 -0
- package/src/types/api/asset/tag.ts +59 -0
- package/src/types/api/migration/document.ts +84 -0
- package/src/types/migration/Asset.ts +156 -0
- package/src/types/migration/ContentRelationship.ts +36 -0
- package/src/types/migration/Document.ts +157 -0
- package/src/types/model/link.ts +0 -1
- package/src/types/model/linkToMedia.ts +0 -1
- package/src/types/value/contentRelationship.ts +0 -1
- package/src/types/value/link.ts +0 -2
- package/src/types/value/linkToMedia.ts +0 -1
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* An object representing an tag used by the Asset API.
|
|
3
|
+
*
|
|
4
|
+
* @see Prismic Asset API technical reference: {@link https://prismic.io/docs/asset-api-technical-reference}
|
|
5
|
+
*/
|
|
6
|
+
export type AssetTag = {
|
|
7
|
+
/**
|
|
8
|
+
* Tag ID.
|
|
9
|
+
*/
|
|
10
|
+
id: string;
|
|
11
|
+
/**
|
|
12
|
+
* Tag name.
|
|
13
|
+
*/
|
|
14
|
+
name: string;
|
|
15
|
+
/**
|
|
16
|
+
* Tag creation date.
|
|
17
|
+
*/
|
|
18
|
+
created_at: number;
|
|
19
|
+
/**
|
|
20
|
+
* Tag last modification date.
|
|
21
|
+
*/
|
|
22
|
+
last_modified: number;
|
|
23
|
+
/**
|
|
24
|
+
* @internal
|
|
25
|
+
*/
|
|
26
|
+
uploader_id?: string;
|
|
27
|
+
/**
|
|
28
|
+
* Number of assets tagged with this tag.
|
|
29
|
+
*/
|
|
30
|
+
count?: number;
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* An object representing the result of querying tags from the Asset API.
|
|
34
|
+
*
|
|
35
|
+
* @see Prismic Asset API technical reference: {@link https://prismic.io/docs/asset-api-technical-reference}
|
|
36
|
+
*/
|
|
37
|
+
export type GetAssetTagsResult = {
|
|
38
|
+
items: AssetTag[];
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* Parameters for creating a tag in the Asset API.
|
|
42
|
+
*
|
|
43
|
+
* @see Prismic Asset API technical reference: {@link https://prismic.io/docs/asset-api-technical-reference}
|
|
44
|
+
*/
|
|
45
|
+
export type PostAssetTagParams = {
|
|
46
|
+
name: string;
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* Result of creating a tag in the Asset API.
|
|
50
|
+
*
|
|
51
|
+
* @see Prismic Asset API technical reference: {@link https://prismic.io/docs/asset-api-technical-reference}
|
|
52
|
+
*/
|
|
53
|
+
export type PostAssetTagResult = AssetTag;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type { PrismicDocument, PrismicDocumentWithUID } from "../../value/document";
|
|
2
|
+
/**
|
|
3
|
+
* An object representing the parameters required when creating a document
|
|
4
|
+
* through the Migration API.
|
|
5
|
+
*
|
|
6
|
+
* @typeParam TDocument - Type of the Prismic document to create.
|
|
7
|
+
*
|
|
8
|
+
* @see Prismic Migration API technical reference: {@link https://prismic.io/docs/migration-api-technical-reference}
|
|
9
|
+
*/
|
|
10
|
+
export type PostDocumentParams<TDocument extends PrismicDocument = PrismicDocument> = TDocument extends PrismicDocument<infer TData, infer TType, infer TLang> ? {
|
|
11
|
+
title: string;
|
|
12
|
+
type: TType;
|
|
13
|
+
lang: TLang;
|
|
14
|
+
alternate_language_id?: string;
|
|
15
|
+
tags?: string[];
|
|
16
|
+
data: TData | Record<string, never>;
|
|
17
|
+
} & (TDocument extends PrismicDocumentWithUID ? {
|
|
18
|
+
uid: TDocument["uid"];
|
|
19
|
+
} : {
|
|
20
|
+
uid?: TDocument["uid"];
|
|
21
|
+
}) : never;
|
|
22
|
+
/**
|
|
23
|
+
* Result of creating a document with the Migration API.
|
|
24
|
+
*
|
|
25
|
+
* @typeParam TDocument - Type of the created Prismic document.
|
|
26
|
+
*
|
|
27
|
+
* @see Prismic Asset API technical reference: {@link https://prismic.io/docs/asset-api-technical-reference}
|
|
28
|
+
*/
|
|
29
|
+
export type PostDocumentResult<TDocument extends PrismicDocument = PrismicDocument> = TDocument extends PrismicDocument<infer _TData, infer TType, infer TLang> ? {
|
|
30
|
+
title: string;
|
|
31
|
+
id: string;
|
|
32
|
+
type: TType;
|
|
33
|
+
lang: TLang;
|
|
34
|
+
} & (TDocument["uid"] extends string ? {
|
|
35
|
+
uid: TDocument["uid"];
|
|
36
|
+
} : {
|
|
37
|
+
uid?: TDocument["uid"];
|
|
38
|
+
}) : never;
|
|
39
|
+
/**
|
|
40
|
+
* An object representing the parameters required when updating a document
|
|
41
|
+
* through the Migration API.
|
|
42
|
+
*
|
|
43
|
+
* @typeParam TDocument - Type of the Prismic document to update.
|
|
44
|
+
*
|
|
45
|
+
* @see Prismic Migration API technical reference: {@link https://prismic.io/docs/migration-api-technical-reference}
|
|
46
|
+
*/
|
|
47
|
+
export type PutDocumentParams<TDocument extends PrismicDocument = PrismicDocument> = {
|
|
48
|
+
title?: string;
|
|
49
|
+
uid?: string;
|
|
50
|
+
tags?: string[];
|
|
51
|
+
data: TDocument["data"] | Record<string, never>;
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* Result of updating a document with the Migration API.
|
|
55
|
+
*
|
|
56
|
+
* @typeParam TDocument - Type of the updated Prismic document.
|
|
57
|
+
*
|
|
58
|
+
* @see Prismic Asset API technical reference: {@link https://prismic.io/docs/asset-api-technical-reference}
|
|
59
|
+
*/
|
|
60
|
+
export type PutDocumentResult<TDocument extends PrismicDocument = PrismicDocument> = PostDocumentResult<TDocument>;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
4
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
6
|
+
class PrismicMigrationAsset {
|
|
7
|
+
/**
|
|
8
|
+
* Creates a migration asset used with the Prismic Migration API.
|
|
9
|
+
*
|
|
10
|
+
* @param config - Configuration of the asset.
|
|
11
|
+
* @param initialField - The initial field value if any.
|
|
12
|
+
*
|
|
13
|
+
* @returns A migration asset instance.
|
|
14
|
+
*/
|
|
15
|
+
constructor(config, initialField) {
|
|
16
|
+
/**
|
|
17
|
+
* Asset object from Prismic, available once created.
|
|
18
|
+
*/
|
|
19
|
+
__publicField(this, "asset");
|
|
20
|
+
/**
|
|
21
|
+
* Configuration of the asset.
|
|
22
|
+
*/
|
|
23
|
+
__publicField(this, "config");
|
|
24
|
+
/**
|
|
25
|
+
* The initial field value this migration field was created with.
|
|
26
|
+
*/
|
|
27
|
+
__publicField(this, "originalField");
|
|
28
|
+
this.config = config;
|
|
29
|
+
this.originalField = initialField;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
exports.PrismicMigrationAsset = PrismicMigrationAsset;
|
|
33
|
+
//# sourceMappingURL=Asset.cjs.map
|
|
@@ -0,0 +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 { LinkToMediaField } 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\tLinkToMediaField<\"filled\">,\n\t\"link_type\"\n> &\n\tPartial<\n\t\tPick<\n\t\t\tLinkToMediaField<\"filled\">,\n\t\t\t// TODO: Remove when link text PR is merged\n\t\t\t// @ts-expect-error - Future-proofing for link text\n\t\t\t\"text\"\n\t\t>\n\t> & {\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// TODO: Remove when link text PR is merged\n\t// @ts-expect-error - Future-proofing for link text\n\t| Pick<LinkToMediaField<\"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":";;;;;MAsHa,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;;"}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import type { Asset } from "../api/asset/asset";
|
|
2
|
+
import type { FilledImageFieldImage } from "../value/image";
|
|
3
|
+
import type { EmptyLinkField } from "../value/link";
|
|
4
|
+
import type { LinkToMediaField } from "../value/linkToMedia";
|
|
5
|
+
import { type RTImageNode } from "../value/richText";
|
|
6
|
+
import type { InjectMigrationSpecificTypes } from "./Document";
|
|
7
|
+
/**
|
|
8
|
+
* An asset to be uploaded to Prismic media library.
|
|
9
|
+
*/
|
|
10
|
+
export type MigrationAssetConfig = {
|
|
11
|
+
/**
|
|
12
|
+
* ID the assets is indexed with on the migration instance.
|
|
13
|
+
*
|
|
14
|
+
* @remarks
|
|
15
|
+
* This property's value is not necessarily the same as the as the one in the
|
|
16
|
+
* `file` property. It is mainly used for deduplication within a `Migration`
|
|
17
|
+
* instance.
|
|
18
|
+
*/
|
|
19
|
+
id: string | URL | File | NonNullable<ConstructorParameters<File>[0]>[0];
|
|
20
|
+
/**
|
|
21
|
+
* File to be uploaded as an asset.
|
|
22
|
+
*/
|
|
23
|
+
file: string | URL | File | NonNullable<ConstructorParameters<File>[0]>[0];
|
|
24
|
+
/**
|
|
25
|
+
* Filename of the asset.
|
|
26
|
+
*/
|
|
27
|
+
filename: string;
|
|
28
|
+
/**
|
|
29
|
+
* Notes about the asset. Notes are private and only visible in Prismic media
|
|
30
|
+
* library.
|
|
31
|
+
*/
|
|
32
|
+
notes?: string;
|
|
33
|
+
/**
|
|
34
|
+
* Credits and copyright for the asset if any.
|
|
35
|
+
*/
|
|
36
|
+
credits?: string;
|
|
37
|
+
/**
|
|
38
|
+
* Alternate text for the asset.
|
|
39
|
+
*/
|
|
40
|
+
alt?: string;
|
|
41
|
+
/**
|
|
42
|
+
* Tags associated with the asset.
|
|
43
|
+
*
|
|
44
|
+
* @remarks
|
|
45
|
+
* Tags should be at least 3 characters long and 20 characters at most.
|
|
46
|
+
*/
|
|
47
|
+
tags?: string[];
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* An image field in a migration.
|
|
51
|
+
*/
|
|
52
|
+
export type MigrationImage = PrismicMigrationAsset | ({
|
|
53
|
+
/**
|
|
54
|
+
* A reference to the migration asset used to resolve the image field's
|
|
55
|
+
* value.
|
|
56
|
+
*/
|
|
57
|
+
id: PrismicMigrationAsset;
|
|
58
|
+
} & Record<string, PrismicMigrationAsset>);
|
|
59
|
+
/**
|
|
60
|
+
* A link to media field in a migration.
|
|
61
|
+
*/
|
|
62
|
+
export type MigrationLinkToMedia = Pick<LinkToMediaField<"filled">, "link_type"> & Partial<Pick<LinkToMediaField<"filled">, "text">> & {
|
|
63
|
+
/**
|
|
64
|
+
* A reference to the migration asset used to resolve the link to media
|
|
65
|
+
* field's value.
|
|
66
|
+
*/
|
|
67
|
+
id: PrismicMigrationAsset;
|
|
68
|
+
};
|
|
69
|
+
/**
|
|
70
|
+
* The minimum amount of information needed to represent a link to media field
|
|
71
|
+
* with the migration API.
|
|
72
|
+
*/
|
|
73
|
+
export type MigrationLinkToMediaField = Pick<LinkToMediaField<"filled">, "link_type" | "id" | "text"> | EmptyLinkField<"Media">;
|
|
74
|
+
/**
|
|
75
|
+
* A rich text image node in a migration.
|
|
76
|
+
*/
|
|
77
|
+
export type MigrationRTImageNode = InjectMigrationSpecificTypes<Pick<RTImageNode, "type" | "linkTo">> & {
|
|
78
|
+
/**
|
|
79
|
+
* A reference to the migration asset used to resolve the rich text image
|
|
80
|
+
* node's value.
|
|
81
|
+
*/
|
|
82
|
+
id: PrismicMigrationAsset;
|
|
83
|
+
};
|
|
84
|
+
/**
|
|
85
|
+
* A migration asset used with the Prismic Migration API.
|
|
86
|
+
*/
|
|
87
|
+
export declare class PrismicMigrationAsset {
|
|
88
|
+
/**
|
|
89
|
+
* Asset object from Prismic, available once created.
|
|
90
|
+
*/
|
|
91
|
+
asset?: Asset;
|
|
92
|
+
/**
|
|
93
|
+
* Configuration of the asset.
|
|
94
|
+
*/
|
|
95
|
+
config: MigrationAssetConfig;
|
|
96
|
+
/**
|
|
97
|
+
* The initial field value this migration field was created with.
|
|
98
|
+
*/
|
|
99
|
+
originalField?: FilledImageFieldImage | LinkToMediaField<"filled"> | RTImageNode;
|
|
100
|
+
/**
|
|
101
|
+
* Creates a migration asset used with the Prismic Migration API.
|
|
102
|
+
*
|
|
103
|
+
* @param config - Configuration of the asset.
|
|
104
|
+
* @param initialField - The initial field value if any.
|
|
105
|
+
*
|
|
106
|
+
* @returns A migration asset instance.
|
|
107
|
+
*/
|
|
108
|
+
constructor(config: MigrationAssetConfig, initialField?: FilledImageFieldImage | LinkToMediaField<"filled"> | RTImageNode);
|
|
109
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
|
+
class PrismicMigrationAsset {
|
|
5
|
+
/**
|
|
6
|
+
* Creates a migration asset used with the Prismic Migration API.
|
|
7
|
+
*
|
|
8
|
+
* @param config - Configuration of the asset.
|
|
9
|
+
* @param initialField - The initial field value if any.
|
|
10
|
+
*
|
|
11
|
+
* @returns A migration asset instance.
|
|
12
|
+
*/
|
|
13
|
+
constructor(config, initialField) {
|
|
14
|
+
/**
|
|
15
|
+
* Asset object from Prismic, available once created.
|
|
16
|
+
*/
|
|
17
|
+
__publicField(this, "asset");
|
|
18
|
+
/**
|
|
19
|
+
* Configuration of the asset.
|
|
20
|
+
*/
|
|
21
|
+
__publicField(this, "config");
|
|
22
|
+
/**
|
|
23
|
+
* The initial field value this migration field was created with.
|
|
24
|
+
*/
|
|
25
|
+
__publicField(this, "originalField");
|
|
26
|
+
this.config = config;
|
|
27
|
+
this.originalField = initialField;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
export {
|
|
31
|
+
PrismicMigrationAsset
|
|
32
|
+
};
|
|
33
|
+
//# sourceMappingURL=Asset.js.map
|
|
@@ -0,0 +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 { LinkToMediaField } 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\tLinkToMediaField<\"filled\">,\n\t\"link_type\"\n> &\n\tPartial<\n\t\tPick<\n\t\t\tLinkToMediaField<\"filled\">,\n\t\t\t// TODO: Remove when link text PR is merged\n\t\t\t// @ts-expect-error - Future-proofing for link text\n\t\t\t\"text\"\n\t\t>\n\t> & {\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// TODO: Remove when link text PR is merged\n\t// @ts-expect-error - Future-proofing for link text\n\t| Pick<LinkToMediaField<\"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":";;;MAsHa,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;"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { FilledContentRelationshipField } from "../value/contentRelationship";
|
|
2
|
+
import type { PrismicDocument } from "../value/document";
|
|
3
|
+
import type { EmptyLinkField } from "../value/link";
|
|
4
|
+
import type { PrismicMigrationDocument } from "./Document";
|
|
5
|
+
type ValueOrThunk<T> = T | (() => Promise<T> | T);
|
|
6
|
+
/**
|
|
7
|
+
* A content relationship field in a migration.
|
|
8
|
+
*/
|
|
9
|
+
export type MigrationContentRelationship<TDocuments extends PrismicDocument = PrismicDocument> = ValueOrThunk<TDocuments | PrismicMigrationDocument<TDocuments> | undefined> | (Pick<FilledContentRelationshipField, "link_type"> & Partial<Pick<FilledContentRelationshipField, "text">> & {
|
|
10
|
+
id: ValueOrThunk<TDocuments | PrismicMigrationDocument<TDocuments> | undefined>;
|
|
11
|
+
});
|
|
12
|
+
/**
|
|
13
|
+
* The minimum amount of information needed to represent a content relationship
|
|
14
|
+
* field with the migration API.
|
|
15
|
+
*/
|
|
16
|
+
export type MigrationContentRelationshipField = Pick<FilledContentRelationshipField, "link_type" | "id"> | EmptyLinkField<"Document">;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
4
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
6
|
+
class PrismicMigrationDocument {
|
|
7
|
+
/**
|
|
8
|
+
* Creates a Prismic migration document instance.
|
|
9
|
+
*
|
|
10
|
+
* @param document - The document to be sent to the Migration API.
|
|
11
|
+
* @param title - The name of the document displayed in the editor.
|
|
12
|
+
* @param params - Parameters to create/update the document with on the
|
|
13
|
+
* Migration API.
|
|
14
|
+
*
|
|
15
|
+
* @returns A Prismic migration document instance.
|
|
16
|
+
*/
|
|
17
|
+
constructor(document, title, params) {
|
|
18
|
+
/**
|
|
19
|
+
* The document to be sent to the Migration API.
|
|
20
|
+
*/
|
|
21
|
+
__publicField(this, "document");
|
|
22
|
+
/**
|
|
23
|
+
* The name of the document displayed in the editor.
|
|
24
|
+
*/
|
|
25
|
+
__publicField(this, "title");
|
|
26
|
+
/**
|
|
27
|
+
* The link to the master language document to relate the document to if any.
|
|
28
|
+
*/
|
|
29
|
+
__publicField(this, "masterLanguageDocument");
|
|
30
|
+
/**
|
|
31
|
+
* Original Prismic document when the migration document came from another
|
|
32
|
+
* Prismic repository.
|
|
33
|
+
*
|
|
34
|
+
* @remarks
|
|
35
|
+
* When migrating a document from another repository, one might want to alter
|
|
36
|
+
* it with migration specific types, hence accepting an
|
|
37
|
+
* `ExistingPrismicDocument` instead of a regular `PrismicDocument`.
|
|
38
|
+
*/
|
|
39
|
+
__publicField(this, "originalPrismicDocument");
|
|
40
|
+
this.document = document;
|
|
41
|
+
this.title = title;
|
|
42
|
+
this.masterLanguageDocument = params == null ? void 0 : params.masterLanguageDocument;
|
|
43
|
+
this.originalPrismicDocument = params == null ? void 0 : params.originalPrismicDocument;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
exports.PrismicMigrationDocument = PrismicMigrationDocument;
|
|
47
|
+
//# sourceMappingURL=Document.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Document.cjs","sources":["../../../../src/types/migration/Document.ts"],"sourcesContent":["import type { FilledContentRelationshipField } from \"../value/contentRelationship\"\nimport type { PrismicDocument, PrismicDocumentWithUID } from \"../value/document\"\nimport type { AnyOEmbed, EmbedField, OEmbedExtra } from \"../value/embed\"\nimport type { FilledImageFieldImage } from \"../value/image\"\nimport type { FilledLinkToMediaField } from \"../value/linkToMedia\"\nimport type { RTImageNode } from \"../value/richText\"\nimport type { SharedSlice } from \"../value/sharedSlice\"\n\nimport type {\n\tMigrationImage,\n\tMigrationLinkToMedia,\n\tMigrationRTImageNode,\n} from \"./Asset\"\nimport type { MigrationContentRelationship } from \"./ContentRelationship\"\n\n/**\n * A utility type that extends any fields in a record with their migration\n * fields equivalent.\n *\n * @typeParam T - Type of the record to extend.\n */\nexport type InjectMigrationSpecificTypes<T> = T extends RTImageNode\n\t?\n\t\t\t| T\n\t\t\t| (Omit<T, \"linkTo\"> & InjectMigrationSpecificTypes<Pick<T, \"linkTo\">>)\n\t\t\t| MigrationRTImageNode\n\t\t\t| undefined\n\t: T extends FilledImageFieldImage\n\t\t? T | MigrationImage | undefined\n\t\t: T extends FilledLinkToMediaField\n\t\t\t? T | MigrationLinkToMedia | undefined\n\t\t\t: T extends FilledContentRelationshipField\n\t\t\t\t? T | MigrationContentRelationship\n\t\t\t\t: T extends EmbedField<AnyOEmbed & OEmbedExtra, \"filled\">\n\t\t\t\t\t? T | Pick<T, \"embed_url\">\n\t\t\t\t\t: T extends SharedSlice\n\t\t\t\t\t\t?\n\t\t\t\t\t\t\t\t| T\n\t\t\t\t\t\t\t\t| InjectMigrationSpecificTypes<\n\t\t\t\t\t\t\t\t\t\tOmit<T, \"id\" | \"slice_label\" | \"version\">\n\t\t\t\t\t\t\t\t >\n\t\t\t\t\t\t: // eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t\t\t\t\t\t\tT extends Record<any, any>\n\t\t\t\t\t\t\t? { [P in keyof T]: InjectMigrationSpecificTypes<T[P]> }\n\t\t\t\t\t\t\t: T extends Array<infer U>\n\t\t\t\t\t\t\t\t? Array<InjectMigrationSpecificTypes<U>>\n\t\t\t\t\t\t\t\t: T\n\n/**\n * A utility type that ties the type and data of a Prismic document, creating a\n * strict union.\n */\ntype TiedDocumentTypeAndData<TDocument extends PrismicDocument> =\n\tTDocument extends PrismicDocument<infer TData, infer TType>\n\t\t? {\n\t\t\t\t/**\n\t\t\t\t * Type of the document.\n\t\t\t\t */\n\t\t\t\ttype: TType\n\n\t\t\t\t/**\n\t\t\t\t * Data contained in the document.\n\t\t\t\t */\n\t\t\t\tdata: InjectMigrationSpecificTypes<TData>\n\t\t\t} & (TDocument extends PrismicDocumentWithUID\n\t\t\t\t? Pick<TDocument, \"uid\">\n\t\t\t\t: Partial<Pick<TDocument, \"uid\">>)\n\t\t: never\n\n/**\n * A pending Prismic document to be created with the Migration API.\n *\n * @typeParam TDocument - Type of the Prismic document.\n */\nexport type PendingPrismicDocument<\n\tTDocument extends PrismicDocument = PrismicDocument,\n> = Pick<TDocument, \"lang\"> &\n\tPartial<Pick<TDocument, \"tags\">> &\n\tTiedDocumentTypeAndData<TDocument>\n\n/**\n * An existing Prismic document to be updated with the Migration API.\n *\n * @typeParam TDocument - Type of the Prismic document.\n */\nexport type ExistingPrismicDocument<\n\tTDocument extends PrismicDocument = PrismicDocument,\n> = Omit<TDocument, \"uid\" | \"type\" | \"data\"> &\n\tTiedDocumentTypeAndData<TDocument>\n\n/**\n * A Prismic document to be sent to the Migration API.\n *\n * @typeParam TDocument - Type of the Prismic document.\n */\nexport type MigrationDocument<\n\tTDocument extends PrismicDocument = PrismicDocument,\n> = PendingPrismicDocument<TDocument> | ExistingPrismicDocument<TDocument>\n\n/**\n * A Prismic migration document instance.\n *\n * @typeParam TDocument - Type of the Prismic document.\n */\nexport class PrismicMigrationDocument<\n\tTDocument extends PrismicDocument = PrismicDocument,\n> {\n\t/**\n\t * The document to be sent to the Migration API.\n\t */\n\tdocument: MigrationDocument<TDocument> & Partial<Pick<TDocument, \"id\">>\n\n\t/**\n\t * The name of the document displayed in the editor.\n\t */\n\ttitle?: string\n\n\t/**\n\t * The link to the master language document to relate the document to if any.\n\t */\n\tmasterLanguageDocument?: MigrationContentRelationship\n\n\t/**\n\t * Original Prismic document when the migration document came from another\n\t * Prismic repository.\n\t *\n\t * @remarks\n\t * When migrating a document from another repository, one might want to alter\n\t * it with migration specific types, hence accepting an\n\t * `ExistingPrismicDocument` instead of a regular `PrismicDocument`.\n\t */\n\toriginalPrismicDocument?: ExistingPrismicDocument<PrismicDocument>\n\n\t/**\n\t * Creates a Prismic migration document instance.\n\t *\n\t * @param document - The document to be sent to the Migration API.\n\t * @param title - The name of the document displayed in the editor.\n\t * @param params - Parameters to create/update the document with on the\n\t * Migration API.\n\t *\n\t * @returns A Prismic migration document instance.\n\t */\n\tconstructor(\n\t\tdocument: MigrationDocument<TDocument>,\n\t\ttitle?: string,\n\t\tparams?: {\n\t\t\tmasterLanguageDocument?: MigrationContentRelationship\n\t\t\toriginalPrismicDocument?: ExistingPrismicDocument<PrismicDocument>\n\t\t},\n\t) {\n\t\tthis.document = document\n\t\tthis.title = title\n\t\tthis.masterLanguageDocument = params?.masterLanguageDocument\n\t\tthis.originalPrismicDocument = params?.originalPrismicDocument\n\t}\n}\n"],"names":[],"mappings":";;;;;MAwGa,yBAAwB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAuCpC,YACC,UACA,OACA,QAGC;AAvCF;AAAA;AAAA;AAAA;AAKA;AAAA;AAAA;AAAA;AAKA;AAAA;AAAA;AAAA;AAWA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAoBC,SAAK,WAAW;AAChB,SAAK,QAAQ;AACb,SAAK,yBAAyB,iCAAQ;AACtC,SAAK,0BAA0B,iCAAQ;AAAA,EACxC;AACA;;"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import type { FilledContentRelationshipField } from "../value/contentRelationship";
|
|
2
|
+
import type { PrismicDocument, PrismicDocumentWithUID } from "../value/document";
|
|
3
|
+
import type { AnyOEmbed, EmbedField, OEmbedExtra } from "../value/embed";
|
|
4
|
+
import type { FilledImageFieldImage } from "../value/image";
|
|
5
|
+
import type { FilledLinkToMediaField } from "../value/linkToMedia";
|
|
6
|
+
import type { RTImageNode } from "../value/richText";
|
|
7
|
+
import type { SharedSlice } from "../value/sharedSlice";
|
|
8
|
+
import type { MigrationImage, MigrationLinkToMedia, MigrationRTImageNode } from "./Asset";
|
|
9
|
+
import type { MigrationContentRelationship } from "./ContentRelationship";
|
|
10
|
+
/**
|
|
11
|
+
* A utility type that extends any fields in a record with their migration
|
|
12
|
+
* fields equivalent.
|
|
13
|
+
*
|
|
14
|
+
* @typeParam T - Type of the record to extend.
|
|
15
|
+
*/
|
|
16
|
+
export type InjectMigrationSpecificTypes<T> = T extends RTImageNode ? T | (Omit<T, "linkTo"> & InjectMigrationSpecificTypes<Pick<T, "linkTo">>) | MigrationRTImageNode | undefined : T extends FilledImageFieldImage ? T | MigrationImage | undefined : T extends FilledLinkToMediaField ? T | MigrationLinkToMedia | undefined : T extends FilledContentRelationshipField ? T | MigrationContentRelationship : T extends EmbedField<AnyOEmbed & OEmbedExtra, "filled"> ? T | Pick<T, "embed_url"> : T extends SharedSlice ? T | InjectMigrationSpecificTypes<Omit<T, "id" | "slice_label" | "version">> : T extends Record<any, any> ? {
|
|
17
|
+
[P in keyof T]: InjectMigrationSpecificTypes<T[P]>;
|
|
18
|
+
} : T extends Array<infer U> ? Array<InjectMigrationSpecificTypes<U>> : T;
|
|
19
|
+
/**
|
|
20
|
+
* A utility type that ties the type and data of a Prismic document, creating a
|
|
21
|
+
* strict union.
|
|
22
|
+
*/
|
|
23
|
+
type TiedDocumentTypeAndData<TDocument extends PrismicDocument> = TDocument extends PrismicDocument<infer TData, infer TType> ? {
|
|
24
|
+
/**
|
|
25
|
+
* Type of the document.
|
|
26
|
+
*/
|
|
27
|
+
type: TType;
|
|
28
|
+
/**
|
|
29
|
+
* Data contained in the document.
|
|
30
|
+
*/
|
|
31
|
+
data: InjectMigrationSpecificTypes<TData>;
|
|
32
|
+
} & (TDocument extends PrismicDocumentWithUID ? Pick<TDocument, "uid"> : Partial<Pick<TDocument, "uid">>) : never;
|
|
33
|
+
/**
|
|
34
|
+
* A pending Prismic document to be created with the Migration API.
|
|
35
|
+
*
|
|
36
|
+
* @typeParam TDocument - Type of the Prismic document.
|
|
37
|
+
*/
|
|
38
|
+
export type PendingPrismicDocument<TDocument extends PrismicDocument = PrismicDocument> = Pick<TDocument, "lang"> & Partial<Pick<TDocument, "tags">> & TiedDocumentTypeAndData<TDocument>;
|
|
39
|
+
/**
|
|
40
|
+
* An existing Prismic document to be updated with the Migration API.
|
|
41
|
+
*
|
|
42
|
+
* @typeParam TDocument - Type of the Prismic document.
|
|
43
|
+
*/
|
|
44
|
+
export type ExistingPrismicDocument<TDocument extends PrismicDocument = PrismicDocument> = Omit<TDocument, "uid" | "type" | "data"> & TiedDocumentTypeAndData<TDocument>;
|
|
45
|
+
/**
|
|
46
|
+
* A Prismic document to be sent to the Migration API.
|
|
47
|
+
*
|
|
48
|
+
* @typeParam TDocument - Type of the Prismic document.
|
|
49
|
+
*/
|
|
50
|
+
export type MigrationDocument<TDocument extends PrismicDocument = PrismicDocument> = PendingPrismicDocument<TDocument> | ExistingPrismicDocument<TDocument>;
|
|
51
|
+
/**
|
|
52
|
+
* A Prismic migration document instance.
|
|
53
|
+
*
|
|
54
|
+
* @typeParam TDocument - Type of the Prismic document.
|
|
55
|
+
*/
|
|
56
|
+
export declare class PrismicMigrationDocument<TDocument extends PrismicDocument = PrismicDocument> {
|
|
57
|
+
/**
|
|
58
|
+
* The document to be sent to the Migration API.
|
|
59
|
+
*/
|
|
60
|
+
document: MigrationDocument<TDocument> & Partial<Pick<TDocument, "id">>;
|
|
61
|
+
/**
|
|
62
|
+
* The name of the document displayed in the editor.
|
|
63
|
+
*/
|
|
64
|
+
title?: string;
|
|
65
|
+
/**
|
|
66
|
+
* The link to the master language document to relate the document to if any.
|
|
67
|
+
*/
|
|
68
|
+
masterLanguageDocument?: MigrationContentRelationship;
|
|
69
|
+
/**
|
|
70
|
+
* Original Prismic document when the migration document came from another
|
|
71
|
+
* Prismic repository.
|
|
72
|
+
*
|
|
73
|
+
* @remarks
|
|
74
|
+
* When migrating a document from another repository, one might want to alter
|
|
75
|
+
* it with migration specific types, hence accepting an
|
|
76
|
+
* `ExistingPrismicDocument` instead of a regular `PrismicDocument`.
|
|
77
|
+
*/
|
|
78
|
+
originalPrismicDocument?: ExistingPrismicDocument<PrismicDocument>;
|
|
79
|
+
/**
|
|
80
|
+
* Creates a Prismic migration document instance.
|
|
81
|
+
*
|
|
82
|
+
* @param document - The document to be sent to the Migration API.
|
|
83
|
+
* @param title - The name of the document displayed in the editor.
|
|
84
|
+
* @param params - Parameters to create/update the document with on the
|
|
85
|
+
* Migration API.
|
|
86
|
+
*
|
|
87
|
+
* @returns A Prismic migration document instance.
|
|
88
|
+
*/
|
|
89
|
+
constructor(document: MigrationDocument<TDocument>, title?: string, params?: {
|
|
90
|
+
masterLanguageDocument?: MigrationContentRelationship;
|
|
91
|
+
originalPrismicDocument?: ExistingPrismicDocument<PrismicDocument>;
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
export {};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
|
+
class PrismicMigrationDocument {
|
|
5
|
+
/**
|
|
6
|
+
* Creates a Prismic migration document instance.
|
|
7
|
+
*
|
|
8
|
+
* @param document - The document to be sent to the Migration API.
|
|
9
|
+
* @param title - The name of the document displayed in the editor.
|
|
10
|
+
* @param params - Parameters to create/update the document with on the
|
|
11
|
+
* Migration API.
|
|
12
|
+
*
|
|
13
|
+
* @returns A Prismic migration document instance.
|
|
14
|
+
*/
|
|
15
|
+
constructor(document, title, params) {
|
|
16
|
+
/**
|
|
17
|
+
* The document to be sent to the Migration API.
|
|
18
|
+
*/
|
|
19
|
+
__publicField(this, "document");
|
|
20
|
+
/**
|
|
21
|
+
* The name of the document displayed in the editor.
|
|
22
|
+
*/
|
|
23
|
+
__publicField(this, "title");
|
|
24
|
+
/**
|
|
25
|
+
* The link to the master language document to relate the document to if any.
|
|
26
|
+
*/
|
|
27
|
+
__publicField(this, "masterLanguageDocument");
|
|
28
|
+
/**
|
|
29
|
+
* Original Prismic document when the migration document came from another
|
|
30
|
+
* Prismic repository.
|
|
31
|
+
*
|
|
32
|
+
* @remarks
|
|
33
|
+
* When migrating a document from another repository, one might want to alter
|
|
34
|
+
* it with migration specific types, hence accepting an
|
|
35
|
+
* `ExistingPrismicDocument` instead of a regular `PrismicDocument`.
|
|
36
|
+
*/
|
|
37
|
+
__publicField(this, "originalPrismicDocument");
|
|
38
|
+
this.document = document;
|
|
39
|
+
this.title = title;
|
|
40
|
+
this.masterLanguageDocument = params == null ? void 0 : params.masterLanguageDocument;
|
|
41
|
+
this.originalPrismicDocument = params == null ? void 0 : params.originalPrismicDocument;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
export {
|
|
45
|
+
PrismicMigrationDocument
|
|
46
|
+
};
|
|
47
|
+
//# sourceMappingURL=Document.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Document.js","sources":["../../../../src/types/migration/Document.ts"],"sourcesContent":["import type { FilledContentRelationshipField } from \"../value/contentRelationship\"\nimport type { PrismicDocument, PrismicDocumentWithUID } from \"../value/document\"\nimport type { AnyOEmbed, EmbedField, OEmbedExtra } from \"../value/embed\"\nimport type { FilledImageFieldImage } from \"../value/image\"\nimport type { FilledLinkToMediaField } from \"../value/linkToMedia\"\nimport type { RTImageNode } from \"../value/richText\"\nimport type { SharedSlice } from \"../value/sharedSlice\"\n\nimport type {\n\tMigrationImage,\n\tMigrationLinkToMedia,\n\tMigrationRTImageNode,\n} from \"./Asset\"\nimport type { MigrationContentRelationship } from \"./ContentRelationship\"\n\n/**\n * A utility type that extends any fields in a record with their migration\n * fields equivalent.\n *\n * @typeParam T - Type of the record to extend.\n */\nexport type InjectMigrationSpecificTypes<T> = T extends RTImageNode\n\t?\n\t\t\t| T\n\t\t\t| (Omit<T, \"linkTo\"> & InjectMigrationSpecificTypes<Pick<T, \"linkTo\">>)\n\t\t\t| MigrationRTImageNode\n\t\t\t| undefined\n\t: T extends FilledImageFieldImage\n\t\t? T | MigrationImage | undefined\n\t\t: T extends FilledLinkToMediaField\n\t\t\t? T | MigrationLinkToMedia | undefined\n\t\t\t: T extends FilledContentRelationshipField\n\t\t\t\t? T | MigrationContentRelationship\n\t\t\t\t: T extends EmbedField<AnyOEmbed & OEmbedExtra, \"filled\">\n\t\t\t\t\t? T | Pick<T, \"embed_url\">\n\t\t\t\t\t: T extends SharedSlice\n\t\t\t\t\t\t?\n\t\t\t\t\t\t\t\t| T\n\t\t\t\t\t\t\t\t| InjectMigrationSpecificTypes<\n\t\t\t\t\t\t\t\t\t\tOmit<T, \"id\" | \"slice_label\" | \"version\">\n\t\t\t\t\t\t\t\t >\n\t\t\t\t\t\t: // eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t\t\t\t\t\t\tT extends Record<any, any>\n\t\t\t\t\t\t\t? { [P in keyof T]: InjectMigrationSpecificTypes<T[P]> }\n\t\t\t\t\t\t\t: T extends Array<infer U>\n\t\t\t\t\t\t\t\t? Array<InjectMigrationSpecificTypes<U>>\n\t\t\t\t\t\t\t\t: T\n\n/**\n * A utility type that ties the type and data of a Prismic document, creating a\n * strict union.\n */\ntype TiedDocumentTypeAndData<TDocument extends PrismicDocument> =\n\tTDocument extends PrismicDocument<infer TData, infer TType>\n\t\t? {\n\t\t\t\t/**\n\t\t\t\t * Type of the document.\n\t\t\t\t */\n\t\t\t\ttype: TType\n\n\t\t\t\t/**\n\t\t\t\t * Data contained in the document.\n\t\t\t\t */\n\t\t\t\tdata: InjectMigrationSpecificTypes<TData>\n\t\t\t} & (TDocument extends PrismicDocumentWithUID\n\t\t\t\t? Pick<TDocument, \"uid\">\n\t\t\t\t: Partial<Pick<TDocument, \"uid\">>)\n\t\t: never\n\n/**\n * A pending Prismic document to be created with the Migration API.\n *\n * @typeParam TDocument - Type of the Prismic document.\n */\nexport type PendingPrismicDocument<\n\tTDocument extends PrismicDocument = PrismicDocument,\n> = Pick<TDocument, \"lang\"> &\n\tPartial<Pick<TDocument, \"tags\">> &\n\tTiedDocumentTypeAndData<TDocument>\n\n/**\n * An existing Prismic document to be updated with the Migration API.\n *\n * @typeParam TDocument - Type of the Prismic document.\n */\nexport type ExistingPrismicDocument<\n\tTDocument extends PrismicDocument = PrismicDocument,\n> = Omit<TDocument, \"uid\" | \"type\" | \"data\"> &\n\tTiedDocumentTypeAndData<TDocument>\n\n/**\n * A Prismic document to be sent to the Migration API.\n *\n * @typeParam TDocument - Type of the Prismic document.\n */\nexport type MigrationDocument<\n\tTDocument extends PrismicDocument = PrismicDocument,\n> = PendingPrismicDocument<TDocument> | ExistingPrismicDocument<TDocument>\n\n/**\n * A Prismic migration document instance.\n *\n * @typeParam TDocument - Type of the Prismic document.\n */\nexport class PrismicMigrationDocument<\n\tTDocument extends PrismicDocument = PrismicDocument,\n> {\n\t/**\n\t * The document to be sent to the Migration API.\n\t */\n\tdocument: MigrationDocument<TDocument> & Partial<Pick<TDocument, \"id\">>\n\n\t/**\n\t * The name of the document displayed in the editor.\n\t */\n\ttitle?: string\n\n\t/**\n\t * The link to the master language document to relate the document to if any.\n\t */\n\tmasterLanguageDocument?: MigrationContentRelationship\n\n\t/**\n\t * Original Prismic document when the migration document came from another\n\t * Prismic repository.\n\t *\n\t * @remarks\n\t * When migrating a document from another repository, one might want to alter\n\t * it with migration specific types, hence accepting an\n\t * `ExistingPrismicDocument` instead of a regular `PrismicDocument`.\n\t */\n\toriginalPrismicDocument?: ExistingPrismicDocument<PrismicDocument>\n\n\t/**\n\t * Creates a Prismic migration document instance.\n\t *\n\t * @param document - The document to be sent to the Migration API.\n\t * @param title - The name of the document displayed in the editor.\n\t * @param params - Parameters to create/update the document with on the\n\t * Migration API.\n\t *\n\t * @returns A Prismic migration document instance.\n\t */\n\tconstructor(\n\t\tdocument: MigrationDocument<TDocument>,\n\t\ttitle?: string,\n\t\tparams?: {\n\t\t\tmasterLanguageDocument?: MigrationContentRelationship\n\t\t\toriginalPrismicDocument?: ExistingPrismicDocument<PrismicDocument>\n\t\t},\n\t) {\n\t\tthis.document = document\n\t\tthis.title = title\n\t\tthis.masterLanguageDocument = params?.masterLanguageDocument\n\t\tthis.originalPrismicDocument = params?.originalPrismicDocument\n\t}\n}\n"],"names":[],"mappings":";;;MAwGa,yBAAwB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAuCpC,YACC,UACA,OACA,QAGC;AAvCF;AAAA;AAAA;AAAA;AAKA;AAAA;AAAA;AAAA;AAKA;AAAA;AAAA;AAAA;AAWA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAoBC,SAAK,WAAW;AAChB,SAAK,QAAQ;AACb,SAAK,yBAAyB,iCAAQ;AACtC,SAAK,0BAA0B,iCAAQ;AAAA,EACxC;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\
|
|
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\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":";;AAwBO,MAAM,gCAAgC;AAAA,EAC5C,UAAU;AAAA,EACV,OAAO;AAAA,EACP,KAAK;;;"}
|
|
@@ -10,7 +10,6 @@ export interface CustomTypeModelLinkField {
|
|
|
10
10
|
label?: string | null;
|
|
11
11
|
placeholder?: string;
|
|
12
12
|
select?: null | (typeof CustomTypeModelLinkSelectType)[keyof typeof CustomTypeModelLinkSelectType];
|
|
13
|
-
allowText?: boolean;
|
|
14
13
|
allowTargetBlank?: boolean;
|
|
15
14
|
};
|
|
16
15
|
}
|
|
@@ -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\
|
|
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\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":"AAwBO,MAAM,gCAAgC;AAAA,EAC5C,UAAU;AAAA,EACV,OAAO;AAAA,EACP,KAAK;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"link.cjs","sources":["../../../../src/types/value/link.ts"],"sourcesContent":["import type { AnyRegularField, FieldState } from \"./types\"\n\nimport type { ContentRelationshipField } from \"./contentRelationship\"\nimport type { GroupField } from \"./group\"\nimport type { LinkToMediaField } 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
|
|
1
|
+
{"version":3,"file":"link.cjs","sources":["../../../../src/types/value/link.ts"],"sourcesContent":["import type { AnyRegularField, FieldState } from \"./types\"\n\nimport type { ContentRelationshipField } from \"./contentRelationship\"\nimport type { GroupField } from \"./group\"\nimport type { LinkToMediaField } 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}\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}\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> = State extends \"empty\"\n\t? EmptyLinkField<typeof LinkType.Any>\n\t:\n\t\t\t| ContentRelationshipField<TypeEnum, LangEnum, DataInterface, State>\n\t\t\t| FilledLinkToWebField\n\t\t\t| LinkToMediaField<State>\n"],"names":[],"mappings":";;AAUO,MAAM,WAAW;AAAA,EACvB,KAAK;AAAA,EACL,UAAU;AAAA,EACV,OAAO;AAAA,EACP,KAAK;;;"}
|
|
@@ -19,7 +19,6 @@ export declare const LinkType: {
|
|
|
19
19
|
*/
|
|
20
20
|
export type EmptyLinkField<Type extends (typeof LinkType)[keyof typeof LinkType] = typeof LinkType.Any> = {
|
|
21
21
|
link_type: Type | string;
|
|
22
|
-
text?: string;
|
|
23
22
|
};
|
|
24
23
|
/**
|
|
25
24
|
* Link that points to external website
|
|
@@ -28,7 +27,6 @@ export interface FilledLinkToWebField {
|
|
|
28
27
|
link_type: typeof LinkType.Web;
|
|
29
28
|
url: string;
|
|
30
29
|
target?: string;
|
|
31
|
-
text?: string;
|
|
32
30
|
}
|
|
33
31
|
/**
|
|
34
32
|
* A link field.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"link.js","sources":["../../../../src/types/value/link.ts"],"sourcesContent":["import type { AnyRegularField, FieldState } from \"./types\"\n\nimport type { ContentRelationshipField } from \"./contentRelationship\"\nimport type { GroupField } from \"./group\"\nimport type { LinkToMediaField } 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
|
|
1
|
+
{"version":3,"file":"link.js","sources":["../../../../src/types/value/link.ts"],"sourcesContent":["import type { AnyRegularField, FieldState } from \"./types\"\n\nimport type { ContentRelationshipField } from \"./contentRelationship\"\nimport type { GroupField } from \"./group\"\nimport type { LinkToMediaField } 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}\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}\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> = State extends \"empty\"\n\t? EmptyLinkField<typeof LinkType.Any>\n\t:\n\t\t\t| ContentRelationshipField<TypeEnum, LangEnum, DataInterface, State>\n\t\t\t| FilledLinkToWebField\n\t\t\t| LinkToMediaField<State>\n"],"names":[],"mappings":"AAUO,MAAM,WAAW;AAAA,EACvB,KAAK;AAAA,EACL,UAAU;AAAA,EACV,OAAO;AAAA,EACP,KAAK;;"}
|