@prismicio/types-internal 2.2.0-alpha.6 → 2.2.0-alpha.8
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/lib/common/Embed.d.ts +16 -0
- package/lib/common/Embed.js +10 -0
- package/lib/import/converters/Document.d.ts +1 -2
- package/lib/import/converters/Document.js +4 -6
- package/lib/import/converters/fields/nestable/Image.d.ts +1 -1339
- package/lib/import/converters/fields/nestable/Image.js +17 -39
- package/lib/import/converters/fields/nestable/Nestable.d.ts +1 -2
- package/lib/import/converters/fields/nestable/Nestable.js +2 -2
- package/lib/import/validators/fields/ImportField.d.ts +6 -90
- package/lib/import/validators/fields/nestable/Image.d.ts +48 -33
- package/lib/import/validators/fields/nestable/Image.js +50 -23
- package/lib/import/validators/fields/nestable/Nestable.d.ts +6 -90
- package/lib/import/validators/fields/nestable/Nestable.js +2 -2
- package/package.json +1 -1
- package/src/import/converters/Document.ts +2 -11
- package/src/import/converters/fields/nestable/Image.ts +24 -80
- package/src/import/converters/fields/nestable/Nestable.ts +1 -3
- package/src/import/validators/fields/nestable/Image.ts +97 -46
- package/src/import/validators/fields/nestable/Nestable.ts +2 -2
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export declare type Embed = {
|
|
2
|
+
type: string;
|
|
3
|
+
version?: string | null;
|
|
4
|
+
author_name?: string | null;
|
|
5
|
+
author_url?: string | null;
|
|
6
|
+
provider_name?: string | null;
|
|
7
|
+
provider_url?: string | null;
|
|
8
|
+
cache_age?: string | null;
|
|
9
|
+
thumbnail_url?: string | null;
|
|
10
|
+
thumbnail_width?: number | null;
|
|
11
|
+
thumbnail_height?: number | null;
|
|
12
|
+
html?: string | null;
|
|
13
|
+
title?: string | null;
|
|
14
|
+
};
|
|
15
|
+
export declare type EmbedUrl = string;
|
|
16
|
+
export declare const getEmbedOrThrow: (embeds: Record<string, Embed>) => (embedUrl: string) => Embed;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getEmbedOrThrow = void 0;
|
|
4
|
+
const getEmbedOrThrow = (embeds) => (embedUrl) => {
|
|
5
|
+
const embed = embeds[embedUrl];
|
|
6
|
+
if (!embed)
|
|
7
|
+
throw new Error(`Missing embed with url '${embedUrl}'`);
|
|
8
|
+
return embed;
|
|
9
|
+
};
|
|
10
|
+
exports.getEmbedOrThrow = getEmbedOrThrow;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { Asset, AssetId } from "../../common";
|
|
2
2
|
import type { Document } from "../../content";
|
|
3
|
-
import type { StaticCustomType } from "../../customtypes";
|
|
4
3
|
import type { ImportDocument } from "../validators";
|
|
5
|
-
export declare function convertImportToContent(document: ImportDocument, assets: Record<AssetId, Asset
|
|
4
|
+
export declare function convertImportToContent(document: ImportDocument, assets: Record<AssetId, Asset>): Document;
|
|
@@ -1,21 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.convertImportToContent = void 0;
|
|
4
|
-
const customtypes_1 = require("../../customtypes");
|
|
5
4
|
const fields_1 = require("./fields");
|
|
6
|
-
function convertImportToContent(document, assets
|
|
7
|
-
const fieldModels = (0, customtypes_1.flattenCustomTypeFields)(customType);
|
|
5
|
+
function convertImportToContent(document, assets) {
|
|
8
6
|
return Object.entries(document).reduce((acc, [fieldKey, fieldValue]) => {
|
|
9
|
-
const newFieldValue = convertWidget(fieldValue, assets
|
|
7
|
+
const newFieldValue = convertWidget(fieldValue, assets);
|
|
10
8
|
return newFieldValue ? { ...acc, [fieldKey]: newFieldValue } : acc;
|
|
11
9
|
}, {});
|
|
12
10
|
}
|
|
13
11
|
exports.convertImportToContent = convertImportToContent;
|
|
14
|
-
function convertWidget(field, assets
|
|
12
|
+
function convertWidget(field, assets) {
|
|
15
13
|
switch (field.type) {
|
|
16
14
|
case "UID":
|
|
17
15
|
return (0, fields_1.uidConverter)(field.value);
|
|
18
16
|
default:
|
|
19
|
-
return (0, fields_1.convertNestableWidget)(field, assets
|
|
17
|
+
return (0, fields_1.convertNestableWidget)(field, assets);
|
|
20
18
|
}
|
|
21
19
|
}
|