@prismicio/client 7.10.0-alpha.0 → 7.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/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 +512 -0
- package/dist/WriteClient.cjs.map +1 -0
- package/dist/WriteClient.d.ts +314 -0
- package/dist/WriteClient.js +512 -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 +911 -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,123 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const Asset = require("../types/migration/Asset.cjs");
|
|
4
|
+
const Document = require("../types/migration/Document.cjs");
|
|
5
|
+
const link = require("../types/value/link.cjs");
|
|
6
|
+
const richText = require("../types/value/richText.cjs");
|
|
7
|
+
const isFilled = require("../helpers/isFilled.cjs");
|
|
8
|
+
const isMigrationValue = require("./isMigrationValue.cjs");
|
|
9
|
+
async function resolveMigrationContentRelationship(relation) {
|
|
10
|
+
if (typeof relation === "function") {
|
|
11
|
+
return resolveMigrationContentRelationship(await relation());
|
|
12
|
+
}
|
|
13
|
+
if (relation instanceof Document.PrismicMigrationDocument) {
|
|
14
|
+
return relation.document.id ? { link_type: link.LinkType.Document, id: relation.document.id } : { link_type: link.LinkType.Document };
|
|
15
|
+
}
|
|
16
|
+
if (relation) {
|
|
17
|
+
if (isMigrationValue.contentRelationship(relation.id) || typeof relation.id === "function") {
|
|
18
|
+
return {
|
|
19
|
+
...await resolveMigrationContentRelationship(relation.id),
|
|
20
|
+
// TODO: Remove when link text PR is merged
|
|
21
|
+
// @ts-expect-error - Future-proofing for link text
|
|
22
|
+
text: relation.text
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
return { link_type: link.LinkType.Document, id: relation.id };
|
|
26
|
+
}
|
|
27
|
+
return { link_type: link.LinkType.Document };
|
|
28
|
+
}
|
|
29
|
+
const resolveMigrationImage = (image, migration, withThumbnails) => {
|
|
30
|
+
var _a;
|
|
31
|
+
const { id: master, ...thumbnails } = image instanceof Asset.PrismicMigrationAsset ? { id: image } : image;
|
|
32
|
+
const asset = (_a = migration._assets.get(master.config.id)) == null ? void 0 : _a.asset;
|
|
33
|
+
const maybeInitialField = master.originalField;
|
|
34
|
+
if (asset) {
|
|
35
|
+
const parameters = ((maybeInitialField == null ? void 0 : maybeInitialField.url) || asset.url).split("?")[1];
|
|
36
|
+
const url = `${asset.url.split("?")[0]}${parameters ? `?${parameters}` : ""}`;
|
|
37
|
+
const dimensions = {
|
|
38
|
+
width: asset.width,
|
|
39
|
+
height: asset.height
|
|
40
|
+
};
|
|
41
|
+
const edit = maybeInitialField && "edit" in maybeInitialField ? maybeInitialField == null ? void 0 : maybeInitialField.edit : { x: 0, y: 0, zoom: 1, background: "transparent" };
|
|
42
|
+
const alt = master.config.alt || asset.alt || null;
|
|
43
|
+
const resolvedThumbnails = {};
|
|
44
|
+
if (withThumbnails) {
|
|
45
|
+
for (const [name, thumbnail] of Object.entries(thumbnails)) {
|
|
46
|
+
const resolvedThumbnail = resolveMigrationImage(thumbnail, migration);
|
|
47
|
+
if (resolvedThumbnail) {
|
|
48
|
+
resolvedThumbnails[name] = resolvedThumbnail;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return {
|
|
53
|
+
id: asset.id,
|
|
54
|
+
url,
|
|
55
|
+
dimensions,
|
|
56
|
+
edit,
|
|
57
|
+
alt,
|
|
58
|
+
copyright: asset.credits || null,
|
|
59
|
+
...resolvedThumbnails
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
const resolveMigrationRTImageNode = async (rtImageNode, migration) => {
|
|
64
|
+
const image = resolveMigrationImage(rtImageNode.id, migration);
|
|
65
|
+
if (image) {
|
|
66
|
+
const linkTo = await resolveMigrationDocumentData(rtImageNode.linkTo, migration);
|
|
67
|
+
return {
|
|
68
|
+
...image,
|
|
69
|
+
type: richText.RichTextNodeType.image,
|
|
70
|
+
linkTo: isFilled.link(linkTo) ? linkTo : void 0
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
const resolveMigrationLinkToMedia = (linkToMedia, migration) => {
|
|
75
|
+
var _a;
|
|
76
|
+
const asset = (_a = migration._assets.get(linkToMedia.id.config.id)) == null ? void 0 : _a.asset;
|
|
77
|
+
if (asset) {
|
|
78
|
+
return {
|
|
79
|
+
id: asset.id,
|
|
80
|
+
link_type: link.LinkType.Media,
|
|
81
|
+
text: linkToMedia.text
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
return { link_type: link.LinkType.Media };
|
|
85
|
+
};
|
|
86
|
+
async function resolveMigrationDocumentData(input, migration) {
|
|
87
|
+
if (isMigrationValue.contentRelationship(input)) {
|
|
88
|
+
return resolveMigrationContentRelationship(input);
|
|
89
|
+
}
|
|
90
|
+
if (isMigrationValue.image(input)) {
|
|
91
|
+
return resolveMigrationImage(input, migration, true);
|
|
92
|
+
}
|
|
93
|
+
if (isMigrationValue.linkToMedia(input)) {
|
|
94
|
+
return resolveMigrationLinkToMedia(input, migration);
|
|
95
|
+
}
|
|
96
|
+
if (isMigrationValue.rtImageNode(input)) {
|
|
97
|
+
return resolveMigrationRTImageNode(input, migration);
|
|
98
|
+
}
|
|
99
|
+
if (typeof input === "function") {
|
|
100
|
+
return await resolveMigrationDocumentData(await input(), migration);
|
|
101
|
+
}
|
|
102
|
+
if (Array.isArray(input)) {
|
|
103
|
+
const res = [];
|
|
104
|
+
for (const element of input) {
|
|
105
|
+
res.push(await resolveMigrationDocumentData(element, migration));
|
|
106
|
+
}
|
|
107
|
+
return res.filter(Boolean);
|
|
108
|
+
}
|
|
109
|
+
if (input && typeof input === "object") {
|
|
110
|
+
const res = {};
|
|
111
|
+
for (const key in input) {
|
|
112
|
+
res[key] = await resolveMigrationDocumentData(input[key], migration);
|
|
113
|
+
}
|
|
114
|
+
return res;
|
|
115
|
+
}
|
|
116
|
+
return input;
|
|
117
|
+
}
|
|
118
|
+
exports.resolveMigrationContentRelationship = resolveMigrationContentRelationship;
|
|
119
|
+
exports.resolveMigrationDocumentData = resolveMigrationDocumentData;
|
|
120
|
+
exports.resolveMigrationImage = resolveMigrationImage;
|
|
121
|
+
exports.resolveMigrationLinkToMedia = resolveMigrationLinkToMedia;
|
|
122
|
+
exports.resolveMigrationRTImageNode = resolveMigrationRTImageNode;
|
|
123
|
+
//# sourceMappingURL=resolveMigrationDocumentData.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolveMigrationDocumentData.cjs","sources":["../../../src/lib/resolveMigrationDocumentData.ts"],"sourcesContent":["import type { MigrationLinkToMediaField } from \"../types/migration/Asset\"\nimport {\n\ttype MigrationImage,\n\ttype MigrationLinkToMedia,\n\ttype MigrationRTImageNode,\n\tPrismicMigrationAsset,\n} from \"../types/migration/Asset\"\nimport type {\n\tMigrationContentRelationship,\n\tMigrationContentRelationshipField,\n} from \"../types/migration/ContentRelationship\"\nimport { PrismicMigrationDocument } from \"../types/migration/Document\"\nimport type { FilledImageFieldImage } from \"../types/value/image\"\nimport type { LinkField } from \"../types/value/link\"\nimport { LinkType } from \"../types/value/link\"\nimport type { RTImageNode } from \"../types/value/richText\"\nimport { RichTextNodeType } from \"../types/value/richText\"\n\nimport * as isFilled from \"../helpers/isFilled\"\nimport type { Migration } from \"../Migration\"\n\nimport * as isMigration from \"./isMigrationValue\"\n\n/**\n * Resolves a migration content relationship to a content relationship field.\n *\n * @param relation - Content relationship to resolve.\n *\n * @returns Resolved content relationship field.\n */\nexport async function resolveMigrationContentRelationship(\n\trelation: MigrationContentRelationship,\n): Promise<MigrationContentRelationshipField> {\n\tif (typeof relation === \"function\") {\n\t\treturn resolveMigrationContentRelationship(await relation())\n\t}\n\n\tif (relation instanceof PrismicMigrationDocument) {\n\t\treturn relation.document.id\n\t\t\t? { link_type: LinkType.Document, id: relation.document.id }\n\t\t\t: { link_type: LinkType.Document }\n\t}\n\n\tif (relation) {\n\t\tif (\n\t\t\tisMigration.contentRelationship(relation.id) ||\n\t\t\ttypeof relation.id === \"function\"\n\t\t) {\n\t\t\treturn {\n\t\t\t\t...(await resolveMigrationContentRelationship(relation.id)),\n\t\t\t\t// TODO: Remove when link text PR is merged\n\t\t\t\t// @ts-expect-error - Future-proofing for link text\n\t\t\t\ttext: relation.text,\n\t\t\t}\n\t\t}\n\n\t\treturn { link_type: LinkType.Document, id: relation.id }\n\t}\n\n\treturn { link_type: LinkType.Document }\n}\n\n/**\n * Resolves a migration image to an image field.\n *\n * @param migrationAsset - Asset to resolve.\n * @param migration - Migration instance.\n * @param withThumbnails - Whether to include thumbnails.\n *\n * @returns Resolved image field.\n */\nexport const resolveMigrationImage = (\n\timage: MigrationImage,\n\tmigration: Migration,\n\twithThumbnails?: boolean,\n): FilledImageFieldImage | undefined => {\n\tconst { id: master, ...thumbnails } =\n\t\timage instanceof PrismicMigrationAsset ? { id: image } : image\n\n\tconst asset = migration._assets.get(master.config.id)?.asset\n\tconst maybeInitialField = master.originalField\n\n\tif (asset) {\n\t\tconst parameters = (maybeInitialField?.url || asset.url).split(\"?\")[1]\n\t\tconst url = `${asset.url.split(\"?\")[0]}${parameters ? `?${parameters}` : \"\"}`\n\t\tconst dimensions: FilledImageFieldImage[\"dimensions\"] = {\n\t\t\twidth: asset.width!,\n\t\t\theight: asset.height!,\n\t\t}\n\t\tconst edit: FilledImageFieldImage[\"edit\"] =\n\t\t\tmaybeInitialField && \"edit\" in maybeInitialField\n\t\t\t\t? maybeInitialField?.edit\n\t\t\t\t: { x: 0, y: 0, zoom: 1, background: \"transparent\" }\n\n\t\t// We give priority to the asset's specific alt text, then the image's general alt text\n\t\tconst alt = master.config.alt || asset.alt || null\n\n\t\tconst resolvedThumbnails: Record<string, FilledImageFieldImage> = {}\n\t\tif (withThumbnails) {\n\t\t\tfor (const [name, thumbnail] of Object.entries(thumbnails)) {\n\t\t\t\tconst resolvedThumbnail = resolveMigrationImage(thumbnail, migration)\n\t\t\t\tif (resolvedThumbnail) {\n\t\t\t\t\tresolvedThumbnails[name] = resolvedThumbnail\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn {\n\t\t\tid: asset.id,\n\t\t\turl,\n\t\t\tdimensions,\n\t\t\tedit,\n\t\t\talt: alt,\n\t\t\tcopyright: asset.credits || null,\n\t\t\t...resolvedThumbnails,\n\t\t}\n\t}\n}\n\n/**\n * Resolves a migration rich text image node to a regular rich text image node.\n *\n * @param rtImageNode - Migration rich text image node to resolve.\n * @param migration - Migration instance.\n *\n * @returns Resolved rich text image node.\n */\nexport const resolveMigrationRTImageNode = async (\n\trtImageNode: MigrationRTImageNode,\n\tmigration: Migration,\n): Promise<RTImageNode | undefined> => {\n\tconst image = resolveMigrationImage(rtImageNode.id, migration)\n\n\tif (image) {\n\t\tconst linkTo = (await resolveMigrationDocumentData(\n\t\t\trtImageNode.linkTo,\n\t\t\tmigration,\n\t\t)) as LinkField\n\n\t\treturn {\n\t\t\t...image,\n\t\t\ttype: RichTextNodeType.image,\n\t\t\tlinkTo: isFilled.link(linkTo) ? linkTo : undefined,\n\t\t}\n\t}\n}\n\n/**\n * Resolves a migration link to media to a regular link to media field.\n *\n * @param linkToMedia - Migration link to media to resolve.\n * @param migration - Migration instance.\n *\n * @returns Resolved link to media field.\n */\nexport const resolveMigrationLinkToMedia = (\n\tlinkToMedia: MigrationLinkToMedia,\n\tmigration: Migration,\n): MigrationLinkToMediaField => {\n\tconst asset = migration._assets.get(linkToMedia.id.config.id)?.asset\n\n\tif (asset) {\n\t\treturn {\n\t\t\tid: asset.id,\n\t\t\tlink_type: LinkType.Media,\n\t\t\ttext: linkToMedia.text,\n\t\t}\n\t}\n\n\treturn { link_type: LinkType.Media }\n}\n\n/**\n * Resolves a migration document data to actual data ready to be sent to the\n * Migration API.\n *\n * @param input - Migration link to media to resolve.\n * @param migration - Migration instance.\n *\n * @returns Resolved data.\n */\nexport async function resolveMigrationDocumentData(\n\tinput: unknown,\n\tmigration: Migration,\n): Promise<unknown> {\n\t// Migration fields\n\tif (isMigration.contentRelationship(input)) {\n\t\treturn resolveMigrationContentRelationship(input)\n\t}\n\n\tif (isMigration.image(input)) {\n\t\treturn resolveMigrationImage(input, migration, true)\n\t}\n\n\tif (isMigration.linkToMedia(input)) {\n\t\treturn resolveMigrationLinkToMedia(input, migration)\n\t}\n\n\tif (isMigration.rtImageNode(input)) {\n\t\treturn resolveMigrationRTImageNode(input, migration)\n\t}\n\n\tif (typeof input === \"function\") {\n\t\treturn await resolveMigrationDocumentData(await input(), migration)\n\t}\n\n\t// Object traversing\n\tif (Array.isArray(input)) {\n\t\tconst res = []\n\n\t\tfor (const element of input) {\n\t\t\tres.push(await resolveMigrationDocumentData(element, migration))\n\t\t}\n\n\t\treturn res.filter(Boolean)\n\t}\n\n\tif (input && typeof input === \"object\") {\n\t\tconst res: Record<PropertyKey, unknown> = {}\n\n\t\tfor (const key in input) {\n\t\t\tres[key] = await resolveMigrationDocumentData(\n\t\t\t\tinput[key as keyof typeof input],\n\t\t\t\tmigration,\n\t\t\t)\n\t\t}\n\n\t\treturn res\n\t}\n\n\t// Primitives\n\treturn input\n}\n"],"names":["PrismicMigrationDocument","LinkType","isMigration.contentRelationship","PrismicMigrationAsset","RichTextNodeType","isFilled.link","isMigration.image","isMigration.linkToMedia","isMigration.rtImageNode"],"mappings":"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"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { MigrationLinkToMediaField } from "../types/migration/Asset";
|
|
2
|
+
import { type MigrationImage, type MigrationLinkToMedia, type MigrationRTImageNode } from "../types/migration/Asset";
|
|
3
|
+
import type { MigrationContentRelationship, MigrationContentRelationshipField } from "../types/migration/ContentRelationship";
|
|
4
|
+
import type { FilledImageFieldImage } from "../types/value/image";
|
|
5
|
+
import type { RTImageNode } from "../types/value/richText";
|
|
6
|
+
import type { Migration } from "../Migration";
|
|
7
|
+
/**
|
|
8
|
+
* Resolves a migration content relationship to a content relationship field.
|
|
9
|
+
*
|
|
10
|
+
* @param relation - Content relationship to resolve.
|
|
11
|
+
*
|
|
12
|
+
* @returns Resolved content relationship field.
|
|
13
|
+
*/
|
|
14
|
+
export declare function resolveMigrationContentRelationship(relation: MigrationContentRelationship): Promise<MigrationContentRelationshipField>;
|
|
15
|
+
/**
|
|
16
|
+
* Resolves a migration image to an image field.
|
|
17
|
+
*
|
|
18
|
+
* @param migrationAsset - Asset to resolve.
|
|
19
|
+
* @param migration - Migration instance.
|
|
20
|
+
* @param withThumbnails - Whether to include thumbnails.
|
|
21
|
+
*
|
|
22
|
+
* @returns Resolved image field.
|
|
23
|
+
*/
|
|
24
|
+
export declare const resolveMigrationImage: (image: MigrationImage, migration: Migration, withThumbnails?: boolean) => FilledImageFieldImage | undefined;
|
|
25
|
+
/**
|
|
26
|
+
* Resolves a migration rich text image node to a regular rich text image node.
|
|
27
|
+
*
|
|
28
|
+
* @param rtImageNode - Migration rich text image node to resolve.
|
|
29
|
+
* @param migration - Migration instance.
|
|
30
|
+
*
|
|
31
|
+
* @returns Resolved rich text image node.
|
|
32
|
+
*/
|
|
33
|
+
export declare const resolveMigrationRTImageNode: (rtImageNode: MigrationRTImageNode, migration: Migration) => Promise<RTImageNode | undefined>;
|
|
34
|
+
/**
|
|
35
|
+
* Resolves a migration link to media to a regular link to media field.
|
|
36
|
+
*
|
|
37
|
+
* @param linkToMedia - Migration link to media to resolve.
|
|
38
|
+
* @param migration - Migration instance.
|
|
39
|
+
*
|
|
40
|
+
* @returns Resolved link to media field.
|
|
41
|
+
*/
|
|
42
|
+
export declare const resolveMigrationLinkToMedia: (linkToMedia: MigrationLinkToMedia, migration: Migration) => MigrationLinkToMediaField;
|
|
43
|
+
/**
|
|
44
|
+
* Resolves a migration document data to actual data ready to be sent to the
|
|
45
|
+
* Migration API.
|
|
46
|
+
*
|
|
47
|
+
* @param input - Migration link to media to resolve.
|
|
48
|
+
* @param migration - Migration instance.
|
|
49
|
+
*
|
|
50
|
+
* @returns Resolved data.
|
|
51
|
+
*/
|
|
52
|
+
export declare function resolveMigrationDocumentData(input: unknown, migration: Migration): Promise<unknown>;
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { PrismicMigrationAsset } from "../types/migration/Asset.js";
|
|
2
|
+
import { PrismicMigrationDocument } from "../types/migration/Document.js";
|
|
3
|
+
import { LinkType } from "../types/value/link.js";
|
|
4
|
+
import { RichTextNodeType } from "../types/value/richText.js";
|
|
5
|
+
import { link } from "../helpers/isFilled.js";
|
|
6
|
+
import { contentRelationship, image, linkToMedia, rtImageNode } from "./isMigrationValue.js";
|
|
7
|
+
async function resolveMigrationContentRelationship(relation) {
|
|
8
|
+
if (typeof relation === "function") {
|
|
9
|
+
return resolveMigrationContentRelationship(await relation());
|
|
10
|
+
}
|
|
11
|
+
if (relation instanceof PrismicMigrationDocument) {
|
|
12
|
+
return relation.document.id ? { link_type: LinkType.Document, id: relation.document.id } : { link_type: LinkType.Document };
|
|
13
|
+
}
|
|
14
|
+
if (relation) {
|
|
15
|
+
if (contentRelationship(relation.id) || typeof relation.id === "function") {
|
|
16
|
+
return {
|
|
17
|
+
...await resolveMigrationContentRelationship(relation.id),
|
|
18
|
+
// TODO: Remove when link text PR is merged
|
|
19
|
+
// @ts-expect-error - Future-proofing for link text
|
|
20
|
+
text: relation.text
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
return { link_type: LinkType.Document, id: relation.id };
|
|
24
|
+
}
|
|
25
|
+
return { link_type: LinkType.Document };
|
|
26
|
+
}
|
|
27
|
+
const resolveMigrationImage = (image2, migration, withThumbnails) => {
|
|
28
|
+
var _a;
|
|
29
|
+
const { id: master, ...thumbnails } = image2 instanceof PrismicMigrationAsset ? { id: image2 } : image2;
|
|
30
|
+
const asset = (_a = migration._assets.get(master.config.id)) == null ? void 0 : _a.asset;
|
|
31
|
+
const maybeInitialField = master.originalField;
|
|
32
|
+
if (asset) {
|
|
33
|
+
const parameters = ((maybeInitialField == null ? void 0 : maybeInitialField.url) || asset.url).split("?")[1];
|
|
34
|
+
const url = `${asset.url.split("?")[0]}${parameters ? `?${parameters}` : ""}`;
|
|
35
|
+
const dimensions = {
|
|
36
|
+
width: asset.width,
|
|
37
|
+
height: asset.height
|
|
38
|
+
};
|
|
39
|
+
const edit = maybeInitialField && "edit" in maybeInitialField ? maybeInitialField == null ? void 0 : maybeInitialField.edit : { x: 0, y: 0, zoom: 1, background: "transparent" };
|
|
40
|
+
const alt = master.config.alt || asset.alt || null;
|
|
41
|
+
const resolvedThumbnails = {};
|
|
42
|
+
if (withThumbnails) {
|
|
43
|
+
for (const [name, thumbnail] of Object.entries(thumbnails)) {
|
|
44
|
+
const resolvedThumbnail = resolveMigrationImage(thumbnail, migration);
|
|
45
|
+
if (resolvedThumbnail) {
|
|
46
|
+
resolvedThumbnails[name] = resolvedThumbnail;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return {
|
|
51
|
+
id: asset.id,
|
|
52
|
+
url,
|
|
53
|
+
dimensions,
|
|
54
|
+
edit,
|
|
55
|
+
alt,
|
|
56
|
+
copyright: asset.credits || null,
|
|
57
|
+
...resolvedThumbnails
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
const resolveMigrationRTImageNode = async (rtImageNode2, migration) => {
|
|
62
|
+
const image2 = resolveMigrationImage(rtImageNode2.id, migration);
|
|
63
|
+
if (image2) {
|
|
64
|
+
const linkTo = await resolveMigrationDocumentData(rtImageNode2.linkTo, migration);
|
|
65
|
+
return {
|
|
66
|
+
...image2,
|
|
67
|
+
type: RichTextNodeType.image,
|
|
68
|
+
linkTo: link(linkTo) ? linkTo : void 0
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
const resolveMigrationLinkToMedia = (linkToMedia2, migration) => {
|
|
73
|
+
var _a;
|
|
74
|
+
const asset = (_a = migration._assets.get(linkToMedia2.id.config.id)) == null ? void 0 : _a.asset;
|
|
75
|
+
if (asset) {
|
|
76
|
+
return {
|
|
77
|
+
id: asset.id,
|
|
78
|
+
link_type: LinkType.Media,
|
|
79
|
+
text: linkToMedia2.text
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
return { link_type: LinkType.Media };
|
|
83
|
+
};
|
|
84
|
+
async function resolveMigrationDocumentData(input, migration) {
|
|
85
|
+
if (contentRelationship(input)) {
|
|
86
|
+
return resolveMigrationContentRelationship(input);
|
|
87
|
+
}
|
|
88
|
+
if (image(input)) {
|
|
89
|
+
return resolveMigrationImage(input, migration, true);
|
|
90
|
+
}
|
|
91
|
+
if (linkToMedia(input)) {
|
|
92
|
+
return resolveMigrationLinkToMedia(input, migration);
|
|
93
|
+
}
|
|
94
|
+
if (rtImageNode(input)) {
|
|
95
|
+
return resolveMigrationRTImageNode(input, migration);
|
|
96
|
+
}
|
|
97
|
+
if (typeof input === "function") {
|
|
98
|
+
return await resolveMigrationDocumentData(await input(), migration);
|
|
99
|
+
}
|
|
100
|
+
if (Array.isArray(input)) {
|
|
101
|
+
const res = [];
|
|
102
|
+
for (const element of input) {
|
|
103
|
+
res.push(await resolveMigrationDocumentData(element, migration));
|
|
104
|
+
}
|
|
105
|
+
return res.filter(Boolean);
|
|
106
|
+
}
|
|
107
|
+
if (input && typeof input === "object") {
|
|
108
|
+
const res = {};
|
|
109
|
+
for (const key in input) {
|
|
110
|
+
res[key] = await resolveMigrationDocumentData(input[key], migration);
|
|
111
|
+
}
|
|
112
|
+
return res;
|
|
113
|
+
}
|
|
114
|
+
return input;
|
|
115
|
+
}
|
|
116
|
+
export {
|
|
117
|
+
resolveMigrationContentRelationship,
|
|
118
|
+
resolveMigrationDocumentData,
|
|
119
|
+
resolveMigrationImage,
|
|
120
|
+
resolveMigrationLinkToMedia,
|
|
121
|
+
resolveMigrationRTImageNode
|
|
122
|
+
};
|
|
123
|
+
//# sourceMappingURL=resolveMigrationDocumentData.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolveMigrationDocumentData.js","sources":["../../../src/lib/resolveMigrationDocumentData.ts"],"sourcesContent":["import type { MigrationLinkToMediaField } from \"../types/migration/Asset\"\nimport {\n\ttype MigrationImage,\n\ttype MigrationLinkToMedia,\n\ttype MigrationRTImageNode,\n\tPrismicMigrationAsset,\n} from \"../types/migration/Asset\"\nimport type {\n\tMigrationContentRelationship,\n\tMigrationContentRelationshipField,\n} from \"../types/migration/ContentRelationship\"\nimport { PrismicMigrationDocument } from \"../types/migration/Document\"\nimport type { FilledImageFieldImage } from \"../types/value/image\"\nimport type { LinkField } from \"../types/value/link\"\nimport { LinkType } from \"../types/value/link\"\nimport type { RTImageNode } from \"../types/value/richText\"\nimport { RichTextNodeType } from \"../types/value/richText\"\n\nimport * as isFilled from \"../helpers/isFilled\"\nimport type { Migration } from \"../Migration\"\n\nimport * as isMigration from \"./isMigrationValue\"\n\n/**\n * Resolves a migration content relationship to a content relationship field.\n *\n * @param relation - Content relationship to resolve.\n *\n * @returns Resolved content relationship field.\n */\nexport async function resolveMigrationContentRelationship(\n\trelation: MigrationContentRelationship,\n): Promise<MigrationContentRelationshipField> {\n\tif (typeof relation === \"function\") {\n\t\treturn resolveMigrationContentRelationship(await relation())\n\t}\n\n\tif (relation instanceof PrismicMigrationDocument) {\n\t\treturn relation.document.id\n\t\t\t? { link_type: LinkType.Document, id: relation.document.id }\n\t\t\t: { link_type: LinkType.Document }\n\t}\n\n\tif (relation) {\n\t\tif (\n\t\t\tisMigration.contentRelationship(relation.id) ||\n\t\t\ttypeof relation.id === \"function\"\n\t\t) {\n\t\t\treturn {\n\t\t\t\t...(await resolveMigrationContentRelationship(relation.id)),\n\t\t\t\t// TODO: Remove when link text PR is merged\n\t\t\t\t// @ts-expect-error - Future-proofing for link text\n\t\t\t\ttext: relation.text,\n\t\t\t}\n\t\t}\n\n\t\treturn { link_type: LinkType.Document, id: relation.id }\n\t}\n\n\treturn { link_type: LinkType.Document }\n}\n\n/**\n * Resolves a migration image to an image field.\n *\n * @param migrationAsset - Asset to resolve.\n * @param migration - Migration instance.\n * @param withThumbnails - Whether to include thumbnails.\n *\n * @returns Resolved image field.\n */\nexport const resolveMigrationImage = (\n\timage: MigrationImage,\n\tmigration: Migration,\n\twithThumbnails?: boolean,\n): FilledImageFieldImage | undefined => {\n\tconst { id: master, ...thumbnails } =\n\t\timage instanceof PrismicMigrationAsset ? { id: image } : image\n\n\tconst asset = migration._assets.get(master.config.id)?.asset\n\tconst maybeInitialField = master.originalField\n\n\tif (asset) {\n\t\tconst parameters = (maybeInitialField?.url || asset.url).split(\"?\")[1]\n\t\tconst url = `${asset.url.split(\"?\")[0]}${parameters ? `?${parameters}` : \"\"}`\n\t\tconst dimensions: FilledImageFieldImage[\"dimensions\"] = {\n\t\t\twidth: asset.width!,\n\t\t\theight: asset.height!,\n\t\t}\n\t\tconst edit: FilledImageFieldImage[\"edit\"] =\n\t\t\tmaybeInitialField && \"edit\" in maybeInitialField\n\t\t\t\t? maybeInitialField?.edit\n\t\t\t\t: { x: 0, y: 0, zoom: 1, background: \"transparent\" }\n\n\t\t// We give priority to the asset's specific alt text, then the image's general alt text\n\t\tconst alt = master.config.alt || asset.alt || null\n\n\t\tconst resolvedThumbnails: Record<string, FilledImageFieldImage> = {}\n\t\tif (withThumbnails) {\n\t\t\tfor (const [name, thumbnail] of Object.entries(thumbnails)) {\n\t\t\t\tconst resolvedThumbnail = resolveMigrationImage(thumbnail, migration)\n\t\t\t\tif (resolvedThumbnail) {\n\t\t\t\t\tresolvedThumbnails[name] = resolvedThumbnail\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn {\n\t\t\tid: asset.id,\n\t\t\turl,\n\t\t\tdimensions,\n\t\t\tedit,\n\t\t\talt: alt,\n\t\t\tcopyright: asset.credits || null,\n\t\t\t...resolvedThumbnails,\n\t\t}\n\t}\n}\n\n/**\n * Resolves a migration rich text image node to a regular rich text image node.\n *\n * @param rtImageNode - Migration rich text image node to resolve.\n * @param migration - Migration instance.\n *\n * @returns Resolved rich text image node.\n */\nexport const resolveMigrationRTImageNode = async (\n\trtImageNode: MigrationRTImageNode,\n\tmigration: Migration,\n): Promise<RTImageNode | undefined> => {\n\tconst image = resolveMigrationImage(rtImageNode.id, migration)\n\n\tif (image) {\n\t\tconst linkTo = (await resolveMigrationDocumentData(\n\t\t\trtImageNode.linkTo,\n\t\t\tmigration,\n\t\t)) as LinkField\n\n\t\treturn {\n\t\t\t...image,\n\t\t\ttype: RichTextNodeType.image,\n\t\t\tlinkTo: isFilled.link(linkTo) ? linkTo : undefined,\n\t\t}\n\t}\n}\n\n/**\n * Resolves a migration link to media to a regular link to media field.\n *\n * @param linkToMedia - Migration link to media to resolve.\n * @param migration - Migration instance.\n *\n * @returns Resolved link to media field.\n */\nexport const resolveMigrationLinkToMedia = (\n\tlinkToMedia: MigrationLinkToMedia,\n\tmigration: Migration,\n): MigrationLinkToMediaField => {\n\tconst asset = migration._assets.get(linkToMedia.id.config.id)?.asset\n\n\tif (asset) {\n\t\treturn {\n\t\t\tid: asset.id,\n\t\t\tlink_type: LinkType.Media,\n\t\t\ttext: linkToMedia.text,\n\t\t}\n\t}\n\n\treturn { link_type: LinkType.Media }\n}\n\n/**\n * Resolves a migration document data to actual data ready to be sent to the\n * Migration API.\n *\n * @param input - Migration link to media to resolve.\n * @param migration - Migration instance.\n *\n * @returns Resolved data.\n */\nexport async function resolveMigrationDocumentData(\n\tinput: unknown,\n\tmigration: Migration,\n): Promise<unknown> {\n\t// Migration fields\n\tif (isMigration.contentRelationship(input)) {\n\t\treturn resolveMigrationContentRelationship(input)\n\t}\n\n\tif (isMigration.image(input)) {\n\t\treturn resolveMigrationImage(input, migration, true)\n\t}\n\n\tif (isMigration.linkToMedia(input)) {\n\t\treturn resolveMigrationLinkToMedia(input, migration)\n\t}\n\n\tif (isMigration.rtImageNode(input)) {\n\t\treturn resolveMigrationRTImageNode(input, migration)\n\t}\n\n\tif (typeof input === \"function\") {\n\t\treturn await resolveMigrationDocumentData(await input(), migration)\n\t}\n\n\t// Object traversing\n\tif (Array.isArray(input)) {\n\t\tconst res = []\n\n\t\tfor (const element of input) {\n\t\t\tres.push(await resolveMigrationDocumentData(element, migration))\n\t\t}\n\n\t\treturn res.filter(Boolean)\n\t}\n\n\tif (input && typeof input === \"object\") {\n\t\tconst res: Record<PropertyKey, unknown> = {}\n\n\t\tfor (const key in input) {\n\t\t\tres[key] = await resolveMigrationDocumentData(\n\t\t\t\tinput[key as keyof typeof input],\n\t\t\t\tmigration,\n\t\t\t)\n\t\t}\n\n\t\treturn res\n\t}\n\n\t// Primitives\n\treturn input\n}\n"],"names":["isMigration.contentRelationship","image","rtImageNode","isFilled.link","linkToMedia","isMigration.image","isMigration.linkToMedia","isMigration.rtImageNode"],"mappings":"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"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const PrismicError = require("../errors/PrismicError.cjs");
|
|
4
|
+
const ASSET_NOTES_MAX_LENGTH = 500;
|
|
5
|
+
const ASSET_CREDITS_MAX_LENGTH = 500;
|
|
6
|
+
const ASSET_ALT_MAX_LENGTH = 500;
|
|
7
|
+
const ASSET_TAG_MIN_LENGTH = 3;
|
|
8
|
+
const ASSET_TAG_MAX_LENGTH = 20;
|
|
9
|
+
const validateAssetMetadata = ({ notes, credits, alt, tags }) => {
|
|
10
|
+
const errors = [];
|
|
11
|
+
if (notes && notes.length > ASSET_NOTES_MAX_LENGTH) {
|
|
12
|
+
errors.push(`\`notes\` must be at most ${ASSET_NOTES_MAX_LENGTH} characters`);
|
|
13
|
+
}
|
|
14
|
+
if (credits && credits.length > ASSET_CREDITS_MAX_LENGTH) {
|
|
15
|
+
errors.push(`\`credits\` must be at most ${ASSET_CREDITS_MAX_LENGTH} characters`);
|
|
16
|
+
}
|
|
17
|
+
if (alt && alt.length > ASSET_ALT_MAX_LENGTH) {
|
|
18
|
+
errors.push(`\`alt\` must be at most ${ASSET_ALT_MAX_LENGTH} characters`);
|
|
19
|
+
}
|
|
20
|
+
if (tags && tags.length && tags.some((tag) => tag.length < ASSET_TAG_MIN_LENGTH || tag.length > ASSET_TAG_MAX_LENGTH)) {
|
|
21
|
+
errors.push(`tags must be at least 3 characters long and 20 characters at most`);
|
|
22
|
+
}
|
|
23
|
+
if (errors.length) {
|
|
24
|
+
throw new PrismicError.PrismicError(`Errors validating asset metadata: ${errors.join(", ")}`, void 0, { notes, credits, alt, tags });
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
exports.validateAssetMetadata = validateAssetMetadata;
|
|
28
|
+
//# sourceMappingURL=validateAssetMetadata.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validateAssetMetadata.cjs","sources":["../../../src/lib/validateAssetMetadata.ts"],"sourcesContent":["import { PrismicError } from \"../errors/PrismicError\"\n\nimport type { CreateAssetParams } from \"../WriteClient\"\n\n/**\n * Max length for asset notes accepted by the API.\n */\nconst ASSET_NOTES_MAX_LENGTH = 500\n\n/**\n * Max length for asset credits accepted by the API.\n */\nconst ASSET_CREDITS_MAX_LENGTH = 500\n\n/**\n * Max length for asset alt text accepted by the API.\n */\nconst ASSET_ALT_MAX_LENGTH = 500\n\n/**\n * Min length for asset tags accepted by the API.\n */\nconst ASSET_TAG_MIN_LENGTH = 3\n\n/**\n * Max length for asset tags accepted by the API.\n */\nconst ASSET_TAG_MAX_LENGTH = 20\n\n/**\n * Validates an asset's metadata, throwing an error if any of the metadata are\n * invalid.\n *\n * @param assetMetadata - The asset metadata to validate.\n *\n * @internal\n */\nexport const validateAssetMetadata = ({\n\tnotes,\n\tcredits,\n\talt,\n\ttags,\n}: CreateAssetParams): void => {\n\tconst errors: string[] = []\n\n\tif (notes && notes.length > ASSET_NOTES_MAX_LENGTH) {\n\t\terrors.push(\n\t\t\t`\\`notes\\` must be at most ${ASSET_NOTES_MAX_LENGTH} characters`,\n\t\t)\n\t}\n\n\tif (credits && credits.length > ASSET_CREDITS_MAX_LENGTH) {\n\t\terrors.push(\n\t\t\t`\\`credits\\` must be at most ${ASSET_CREDITS_MAX_LENGTH} characters`,\n\t\t)\n\t}\n\n\tif (alt && alt.length > ASSET_ALT_MAX_LENGTH) {\n\t\terrors.push(`\\`alt\\` must be at most ${ASSET_ALT_MAX_LENGTH} characters`)\n\t}\n\n\tif (\n\t\ttags &&\n\t\ttags.length &&\n\t\ttags.some(\n\t\t\t(tag) =>\n\t\t\t\ttag.length < ASSET_TAG_MIN_LENGTH || tag.length > ASSET_TAG_MAX_LENGTH,\n\t\t)\n\t) {\n\t\terrors.push(\n\t\t\t`tags must be at least 3 characters long and 20 characters at most`,\n\t\t)\n\t}\n\n\tif (errors.length) {\n\t\tthrow new PrismicError(\n\t\t\t`Errors validating asset metadata: ${errors.join(\", \")}`,\n\t\t\tundefined,\n\t\t\t{ notes, credits, alt, tags },\n\t\t)\n\t}\n}\n"],"names":["PrismicError"],"mappings":";;;AAOA,MAAM,yBAAyB;AAK/B,MAAM,2BAA2B;AAKjC,MAAM,uBAAuB;AAK7B,MAAM,uBAAuB;AAK7B,MAAM,uBAAuB;AAUtB,MAAM,wBAAwB,CAAC,EACrC,OACA,SACA,KACA,WAC6B;AAC7B,QAAM,SAAmB,CAAA;AAErB,MAAA,SAAS,MAAM,SAAS,wBAAwB;AAC5C,WAAA,KACN,6BAA6B,sBAAsB,aAAa;AAAA,EAElE;AAEI,MAAA,WAAW,QAAQ,SAAS,0BAA0B;AAClD,WAAA,KACN,+BAA+B,wBAAwB,aAAa;AAAA,EAEtE;AAEI,MAAA,OAAO,IAAI,SAAS,sBAAsB;AACtC,WAAA,KAAK,2BAA2B,oBAAoB,aAAa;AAAA,EACzE;AAEA,MACC,QACA,KAAK,UACL,KAAK,KACJ,CAAC,QACA,IAAI,SAAS,wBAAwB,IAAI,SAAS,oBAAoB,GAEvE;AACD,WAAO,KACN,mEAAmE;AAAA,EAErE;AAEA,MAAI,OAAO,QAAQ;AAClB,UAAM,IAAIA,aAAA,aACT,qCAAqC,OAAO,KAAK,IAAI,CAAC,IACtD,QACA,EAAE,OAAO,SAAS,KAAK,MAAM;AAAA,EAE/B;AACD;;"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { CreateAssetParams } from "../WriteClient";
|
|
2
|
+
/**
|
|
3
|
+
* Validates an asset's metadata, throwing an error if any of the metadata are
|
|
4
|
+
* invalid.
|
|
5
|
+
*
|
|
6
|
+
* @param assetMetadata - The asset metadata to validate.
|
|
7
|
+
*
|
|
8
|
+
* @internal
|
|
9
|
+
*/
|
|
10
|
+
export declare const validateAssetMetadata: ({ notes, credits, alt, tags, }: CreateAssetParams) => void;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { PrismicError } from "../errors/PrismicError.js";
|
|
2
|
+
const ASSET_NOTES_MAX_LENGTH = 500;
|
|
3
|
+
const ASSET_CREDITS_MAX_LENGTH = 500;
|
|
4
|
+
const ASSET_ALT_MAX_LENGTH = 500;
|
|
5
|
+
const ASSET_TAG_MIN_LENGTH = 3;
|
|
6
|
+
const ASSET_TAG_MAX_LENGTH = 20;
|
|
7
|
+
const validateAssetMetadata = ({ notes, credits, alt, tags }) => {
|
|
8
|
+
const errors = [];
|
|
9
|
+
if (notes && notes.length > ASSET_NOTES_MAX_LENGTH) {
|
|
10
|
+
errors.push(`\`notes\` must be at most ${ASSET_NOTES_MAX_LENGTH} characters`);
|
|
11
|
+
}
|
|
12
|
+
if (credits && credits.length > ASSET_CREDITS_MAX_LENGTH) {
|
|
13
|
+
errors.push(`\`credits\` must be at most ${ASSET_CREDITS_MAX_LENGTH} characters`);
|
|
14
|
+
}
|
|
15
|
+
if (alt && alt.length > ASSET_ALT_MAX_LENGTH) {
|
|
16
|
+
errors.push(`\`alt\` must be at most ${ASSET_ALT_MAX_LENGTH} characters`);
|
|
17
|
+
}
|
|
18
|
+
if (tags && tags.length && tags.some((tag) => tag.length < ASSET_TAG_MIN_LENGTH || tag.length > ASSET_TAG_MAX_LENGTH)) {
|
|
19
|
+
errors.push(`tags must be at least 3 characters long and 20 characters at most`);
|
|
20
|
+
}
|
|
21
|
+
if (errors.length) {
|
|
22
|
+
throw new PrismicError(`Errors validating asset metadata: ${errors.join(", ")}`, void 0, { notes, credits, alt, tags });
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
export {
|
|
26
|
+
validateAssetMetadata
|
|
27
|
+
};
|
|
28
|
+
//# sourceMappingURL=validateAssetMetadata.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validateAssetMetadata.js","sources":["../../../src/lib/validateAssetMetadata.ts"],"sourcesContent":["import { PrismicError } from \"../errors/PrismicError\"\n\nimport type { CreateAssetParams } from \"../WriteClient\"\n\n/**\n * Max length for asset notes accepted by the API.\n */\nconst ASSET_NOTES_MAX_LENGTH = 500\n\n/**\n * Max length for asset credits accepted by the API.\n */\nconst ASSET_CREDITS_MAX_LENGTH = 500\n\n/**\n * Max length for asset alt text accepted by the API.\n */\nconst ASSET_ALT_MAX_LENGTH = 500\n\n/**\n * Min length for asset tags accepted by the API.\n */\nconst ASSET_TAG_MIN_LENGTH = 3\n\n/**\n * Max length for asset tags accepted by the API.\n */\nconst ASSET_TAG_MAX_LENGTH = 20\n\n/**\n * Validates an asset's metadata, throwing an error if any of the metadata are\n * invalid.\n *\n * @param assetMetadata - The asset metadata to validate.\n *\n * @internal\n */\nexport const validateAssetMetadata = ({\n\tnotes,\n\tcredits,\n\talt,\n\ttags,\n}: CreateAssetParams): void => {\n\tconst errors: string[] = []\n\n\tif (notes && notes.length > ASSET_NOTES_MAX_LENGTH) {\n\t\terrors.push(\n\t\t\t`\\`notes\\` must be at most ${ASSET_NOTES_MAX_LENGTH} characters`,\n\t\t)\n\t}\n\n\tif (credits && credits.length > ASSET_CREDITS_MAX_LENGTH) {\n\t\terrors.push(\n\t\t\t`\\`credits\\` must be at most ${ASSET_CREDITS_MAX_LENGTH} characters`,\n\t\t)\n\t}\n\n\tif (alt && alt.length > ASSET_ALT_MAX_LENGTH) {\n\t\terrors.push(`\\`alt\\` must be at most ${ASSET_ALT_MAX_LENGTH} characters`)\n\t}\n\n\tif (\n\t\ttags &&\n\t\ttags.length &&\n\t\ttags.some(\n\t\t\t(tag) =>\n\t\t\t\ttag.length < ASSET_TAG_MIN_LENGTH || tag.length > ASSET_TAG_MAX_LENGTH,\n\t\t)\n\t) {\n\t\terrors.push(\n\t\t\t`tags must be at least 3 characters long and 20 characters at most`,\n\t\t)\n\t}\n\n\tif (errors.length) {\n\t\tthrow new PrismicError(\n\t\t\t`Errors validating asset metadata: ${errors.join(\", \")}`,\n\t\t\tundefined,\n\t\t\t{ notes, credits, alt, tags },\n\t\t)\n\t}\n}\n"],"names":[],"mappings":";AAOA,MAAM,yBAAyB;AAK/B,MAAM,2BAA2B;AAKjC,MAAM,uBAAuB;AAK7B,MAAM,uBAAuB;AAK7B,MAAM,uBAAuB;AAUtB,MAAM,wBAAwB,CAAC,EACrC,OACA,SACA,KACA,WAC6B;AAC7B,QAAM,SAAmB,CAAA;AAErB,MAAA,SAAS,MAAM,SAAS,wBAAwB;AAC5C,WAAA,KACN,6BAA6B,sBAAsB,aAAa;AAAA,EAElE;AAEI,MAAA,WAAW,QAAQ,SAAS,0BAA0B;AAClD,WAAA,KACN,+BAA+B,wBAAwB,aAAa;AAAA,EAEtE;AAEI,MAAA,OAAO,IAAI,SAAS,sBAAsB;AACtC,WAAA,KAAK,2BAA2B,oBAAoB,aAAa;AAAA,EACzE;AAEA,MACC,QACA,KAAK,UACL,KAAK,KACJ,CAAC,QACA,IAAI,SAAS,wBAAwB,IAAI,SAAS,oBAAoB,GAEvE;AACD,WAAO,KACN,mEAAmE;AAAA,EAErE;AAEA,MAAI,OAAO,QAAQ;AAClB,UAAM,IAAI,aACT,qCAAqC,OAAO,KAAK,IAAI,CAAC,IACtD,QACA,EAAE,OAAO,SAAS,KAAK,MAAM;AAAA,EAE/B;AACD;"}
|
package/dist/package.json.cjs
CHANGED
package/dist/package.json.js
CHANGED
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import type { AssetTag } from "./tag";
|
|
2
|
+
/**
|
|
3
|
+
* Asset types.
|
|
4
|
+
*/
|
|
5
|
+
export declare const AssetType: {
|
|
6
|
+
readonly All: "all";
|
|
7
|
+
readonly Audio: "audio";
|
|
8
|
+
readonly Document: "document";
|
|
9
|
+
readonly Image: "image";
|
|
10
|
+
readonly Video: "video";
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* An object representing an asset returned by the Asset API.
|
|
14
|
+
*
|
|
15
|
+
* @see Prismic Asset API technical reference: {@link https://prismic.io/docs/asset-api-technical-reference}
|
|
16
|
+
*/
|
|
17
|
+
export type Asset = {
|
|
18
|
+
/**
|
|
19
|
+
* Asset ID.
|
|
20
|
+
*/
|
|
21
|
+
id: string;
|
|
22
|
+
/**
|
|
23
|
+
* Asset URL.
|
|
24
|
+
*/
|
|
25
|
+
url: string;
|
|
26
|
+
/**
|
|
27
|
+
* Asset creation date.
|
|
28
|
+
*/
|
|
29
|
+
created_at: number;
|
|
30
|
+
/**
|
|
31
|
+
* Asset last modification date.
|
|
32
|
+
*/
|
|
33
|
+
last_modified: number;
|
|
34
|
+
/**
|
|
35
|
+
* Asset filename.
|
|
36
|
+
*/
|
|
37
|
+
filename: string;
|
|
38
|
+
/**
|
|
39
|
+
* Asset extension.
|
|
40
|
+
*/
|
|
41
|
+
extension: string;
|
|
42
|
+
/**
|
|
43
|
+
* Asset size in bytes.
|
|
44
|
+
*/
|
|
45
|
+
size: number;
|
|
46
|
+
/**
|
|
47
|
+
* Asset kind.
|
|
48
|
+
*/
|
|
49
|
+
kind: Exclude<(typeof AssetType)[keyof typeof AssetType], (typeof AssetType)["All"]>;
|
|
50
|
+
/**
|
|
51
|
+
* Asset width in pixels.
|
|
52
|
+
*/
|
|
53
|
+
width?: number;
|
|
54
|
+
/**
|
|
55
|
+
* Asset height in pixels.
|
|
56
|
+
*/
|
|
57
|
+
height?: number;
|
|
58
|
+
/**
|
|
59
|
+
* Asset notes.
|
|
60
|
+
*/
|
|
61
|
+
notes?: string;
|
|
62
|
+
/**
|
|
63
|
+
* Asset credits.
|
|
64
|
+
*/
|
|
65
|
+
credits?: string;
|
|
66
|
+
/**
|
|
67
|
+
* Asset alt text.
|
|
68
|
+
*/
|
|
69
|
+
alt?: string;
|
|
70
|
+
/**
|
|
71
|
+
* Asset tags.
|
|
72
|
+
*/
|
|
73
|
+
tags?: AssetTag[];
|
|
74
|
+
/**
|
|
75
|
+
* @internal
|
|
76
|
+
*/
|
|
77
|
+
origin_url?: string;
|
|
78
|
+
/**
|
|
79
|
+
* @internal
|
|
80
|
+
*/
|
|
81
|
+
uploader_id?: string;
|
|
82
|
+
/**
|
|
83
|
+
* @internal
|
|
84
|
+
*/
|
|
85
|
+
search_highlight?: {
|
|
86
|
+
filename?: string[];
|
|
87
|
+
notes?: string[];
|
|
88
|
+
credits?: string[];
|
|
89
|
+
alt?: string[];
|
|
90
|
+
};
|
|
91
|
+
};
|
|
92
|
+
/**
|
|
93
|
+
* Available query parameters when querying assets from the Asset API.
|
|
94
|
+
*
|
|
95
|
+
* @see Prismic Asset API technical reference: {@link https://prismic.io/docs/asset-api-technical-reference}
|
|
96
|
+
*/
|
|
97
|
+
export type GetAssetsParams = {
|
|
98
|
+
/**
|
|
99
|
+
* Number of items to return.
|
|
100
|
+
*/
|
|
101
|
+
pageSize?: number;
|
|
102
|
+
/**
|
|
103
|
+
* @internal
|
|
104
|
+
*/
|
|
105
|
+
cursor?: string;
|
|
106
|
+
/**
|
|
107
|
+
* Asset type to filter by.
|
|
108
|
+
*/
|
|
109
|
+
assetType?: (typeof AssetType)[keyof typeof AssetType];
|
|
110
|
+
/**
|
|
111
|
+
* Search query.
|
|
112
|
+
*/
|
|
113
|
+
keyword?: string;
|
|
114
|
+
/**
|
|
115
|
+
* Asset IDs to filter by.
|
|
116
|
+
*/
|
|
117
|
+
ids?: string[];
|
|
118
|
+
/**
|
|
119
|
+
* Asset tags to filter by.
|
|
120
|
+
*/
|
|
121
|
+
tags?: string[];
|
|
122
|
+
};
|
|
123
|
+
/**
|
|
124
|
+
* An object representing the result of querying assets from the Asset API.
|
|
125
|
+
*
|
|
126
|
+
* @see Prismic Asset API technical reference: {@link https://prismic.io/docs/asset-api-technical-reference}
|
|
127
|
+
*/
|
|
128
|
+
export type GetAssetsResult = {
|
|
129
|
+
items: Asset[];
|
|
130
|
+
total: number;
|
|
131
|
+
cursor?: string;
|
|
132
|
+
missing_ids?: string[];
|
|
133
|
+
is_opensearch_result: boolean;
|
|
134
|
+
};
|
|
135
|
+
/**
|
|
136
|
+
* Parameters for uploading an asset to the Asset API.
|
|
137
|
+
*
|
|
138
|
+
* @see Prismic Asset API technical reference: {@link https://prismic.io/docs/asset-api-technical-reference}
|
|
139
|
+
*/
|
|
140
|
+
export type PostAssetParams = {
|
|
141
|
+
file: BlobPart;
|
|
142
|
+
notes?: string;
|
|
143
|
+
credits?: string;
|
|
144
|
+
alt?: string;
|
|
145
|
+
};
|
|
146
|
+
/**
|
|
147
|
+
* Result of uploading an asset to the Asset API.
|
|
148
|
+
*
|
|
149
|
+
* @see Prismic Asset API technical reference: {@link https://prismic.io/docs/asset-api-technical-reference}
|
|
150
|
+
*/
|
|
151
|
+
export type PostAssetResult = Asset;
|
|
152
|
+
/**
|
|
153
|
+
* Parameters for updating an asset in the Asset API.
|
|
154
|
+
*
|
|
155
|
+
* @see Prismic Asset API technical reference: {@link https://prismic.io/docs/asset-api-technical-reference}
|
|
156
|
+
*/
|
|
157
|
+
export type PatchAssetParams = {
|
|
158
|
+
notes?: string;
|
|
159
|
+
credits?: string;
|
|
160
|
+
alt?: string;
|
|
161
|
+
filename?: string;
|
|
162
|
+
tags?: string[];
|
|
163
|
+
};
|
|
164
|
+
/**
|
|
165
|
+
* Result of updating an asset in the Asset API.
|
|
166
|
+
*
|
|
167
|
+
* @see Prismic Asset API technical reference: {@link https://prismic.io/docs/asset-api-technical-reference}
|
|
168
|
+
*/
|
|
169
|
+
export type PatchAssetResult = Asset;
|
|
170
|
+
/**
|
|
171
|
+
* Parameters for deleting an asset from the Asset API.
|
|
172
|
+
*
|
|
173
|
+
* @see Prismic Asset API technical reference: {@link https://prismic.io/docs/asset-api-technical-reference}
|
|
174
|
+
*/
|
|
175
|
+
export type BulkDeleteAssetsParams = {
|
|
176
|
+
ids: string[];
|
|
177
|
+
};
|