@prismicio/types-internal 2.2.0-alpha.14 → 2.2.0-alpha.16
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/import/converters/Document.js +0 -2
- package/lib/import/converters/fields/UID.d.ts +1 -1
- package/lib/import/converters/fields/UID.js +0 -2
- package/lib/import/converters/fields/nestable/Link.js +2 -2
- package/lib/import/validators/fields/ImportField.d.ts +2 -12
- package/lib/import/validators/fields/ImportField.js +2 -3
- package/lib/import/validators/fields/UID.d.ts +2 -2
- package/lib/import/validators/fields/UID.js +1 -1
- package/package.json +1 -1
- package/src/import/converters/Document.ts +1 -7
- package/src/import/converters/fields/UID.ts +1 -5
- package/src/import/converters/fields/nestable/Link.ts +2 -2
- package/src/import/validators/fields/ImportField.ts +6 -5
- package/src/import/validators/fields/UID.ts +2 -2
|
@@ -11,8 +11,6 @@ function convertImportToContent(document, assets, embeds) {
|
|
|
11
11
|
exports.convertImportToContent = convertImportToContent;
|
|
12
12
|
function convertWidget(field, assets, embeds) {
|
|
13
13
|
switch (field.type) {
|
|
14
|
-
case "UID":
|
|
15
|
-
return (0, fields_1.uidConverter)(field.value);
|
|
16
14
|
case "Slices":
|
|
17
15
|
return (0, fields_1.importSlicesConverter)(field.value, assets, embeds);
|
|
18
16
|
default:
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { UIDContent } from "../../../content";
|
|
2
2
|
import type { ImportUID } from "../../validators/fields/UID";
|
|
3
|
-
export declare const uidConverter: (field: ImportUID["value"]) => UIDContent
|
|
3
|
+
export declare const uidConverter: (field: ImportUID["value"]) => UIDContent;
|
|
@@ -22,7 +22,7 @@ const fileLinkConverter = (field, asset) => {
|
|
|
22
22
|
return ({
|
|
23
23
|
value: {
|
|
24
24
|
id: field.id,
|
|
25
|
-
url: asset.
|
|
25
|
+
url: asset.origin_url,
|
|
26
26
|
name: (_a = asset.filename) !== null && _a !== void 0 ? _a : "unknown.jpg",
|
|
27
27
|
kind: asset.kind,
|
|
28
28
|
size: asset.size ? String(asset.size) : "0",
|
|
@@ -36,7 +36,7 @@ const imageLinkConverter = (field, asset) => {
|
|
|
36
36
|
return ({
|
|
37
37
|
value: {
|
|
38
38
|
id: field.id,
|
|
39
|
-
url: asset.
|
|
39
|
+
url: asset.origin_url,
|
|
40
40
|
height: String((_a = asset.height) !== null && _a !== void 0 ? _a : 1),
|
|
41
41
|
width: String((_b = asset.width) !== null && _b !== void 0 ? _b : 1),
|
|
42
42
|
name: (_c = asset.filename) !== null && _c !== void 0 ? _c : "unknown.jpg",
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import type { StaticWidget } from "../../../customtypes";
|
|
2
2
|
import { ImportSlices } from "./ImportSlices";
|
|
3
3
|
import { ImportNestable } from "./nestable";
|
|
4
|
-
|
|
5
|
-
export declare type ImportField = ImportUID | ImportSlices | ImportNestable;
|
|
4
|
+
export declare type ImportField = ImportSlices | ImportNestable;
|
|
6
5
|
export declare const ImportField: {
|
|
7
|
-
is(u: unknown): u is
|
|
6
|
+
is(u: unknown): u is ImportField;
|
|
8
7
|
decode: (field: StaticWidget) => (content: unknown) => {
|
|
9
8
|
codec: import("io-ts").Type<{
|
|
10
9
|
type: "Boolean";
|
|
@@ -113,15 +112,6 @@ export declare const ImportField: {
|
|
|
113
112
|
type: "Boolean";
|
|
114
113
|
value: boolean | null;
|
|
115
114
|
}>;
|
|
116
|
-
} | {
|
|
117
|
-
codec: import("io-ts").Type<{
|
|
118
|
-
type: "UID";
|
|
119
|
-
value: string | null;
|
|
120
|
-
}, string | undefined, unknown>;
|
|
121
|
-
result: import("io-ts").Validation<{
|
|
122
|
-
type: "UID";
|
|
123
|
-
value: string | null;
|
|
124
|
-
}>;
|
|
125
115
|
} | {
|
|
126
116
|
codec: import("io-ts").Type<{
|
|
127
117
|
type: "Slices";
|
|
@@ -3,16 +3,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.ImportField = void 0;
|
|
4
4
|
const ImportSlices_1 = require("./ImportSlices");
|
|
5
5
|
const nestable_1 = require("./nestable");
|
|
6
|
-
const UID_1 = require("./UID");
|
|
7
6
|
exports.ImportField = {
|
|
8
7
|
is(u) {
|
|
9
|
-
return
|
|
8
|
+
return exports.ImportField.is(u);
|
|
10
9
|
},
|
|
11
10
|
decode: (field) => {
|
|
12
11
|
return (content) => {
|
|
13
12
|
switch (field.type) {
|
|
14
13
|
case "UID":
|
|
15
|
-
|
|
14
|
+
throw new Error(`The field '${field.type}' should be put at the root level of the document`);
|
|
16
15
|
case "Slices":
|
|
17
16
|
return {
|
|
18
17
|
codec: (0, ImportSlices_1.ImportSlices)(field),
|
|
@@ -12,4 +12,4 @@ const uidValue = validators_1.String.pipe(new t.Type("ImportUIDField", (u) => va
|
|
|
12
12
|
}
|
|
13
13
|
return t.failure(n, c, "UID can only contain alphanumeric characters, dashes, underscores, and dots");
|
|
14
14
|
}, t.identity));
|
|
15
|
-
exports.ImportUID = (0, ImportContent_1.ImportContent)("UID",
|
|
15
|
+
exports.ImportUID = (0, ImportContent_1.ImportContent)("UID", uidValue);
|
package/package.json
CHANGED
|
@@ -2,11 +2,7 @@ import type { Asset, Embed } from "../../common"
|
|
|
2
2
|
import type { Document, WidgetContent } from "../../content"
|
|
3
3
|
import type { ImportDocument } from "../validators"
|
|
4
4
|
import type { ImportField } from "../validators/fields/ImportField"
|
|
5
|
-
import {
|
|
6
|
-
convertNestableWidget,
|
|
7
|
-
importSlicesConverter,
|
|
8
|
-
uidConverter,
|
|
9
|
-
} from "./fields"
|
|
5
|
+
import { convertNestableWidget, importSlicesConverter } from "./fields"
|
|
10
6
|
|
|
11
7
|
export function convertImportToContent(
|
|
12
8
|
document: ImportDocument,
|
|
@@ -28,8 +24,6 @@ function convertWidget(
|
|
|
28
24
|
embeds: Record<string, Embed | undefined>,
|
|
29
25
|
): WidgetContent | undefined {
|
|
30
26
|
switch (field.type) {
|
|
31
|
-
case "UID":
|
|
32
|
-
return uidConverter(field.value)
|
|
33
27
|
case "Slices":
|
|
34
28
|
return importSlicesConverter(field.value, assets, embeds)
|
|
35
29
|
default:
|
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
import type { UIDContent } from "../../../content"
|
|
2
2
|
import type { ImportUID } from "../../validators/fields/UID"
|
|
3
3
|
|
|
4
|
-
export const uidConverter = (
|
|
5
|
-
field: ImportUID["value"],
|
|
6
|
-
): UIDContent | undefined => {
|
|
7
|
-
if (field === null) return
|
|
8
|
-
|
|
4
|
+
export const uidConverter = (field: ImportUID["value"]): UIDContent => {
|
|
9
5
|
return {
|
|
10
6
|
value: field,
|
|
11
7
|
__TYPE__: "UIDContent",
|
|
@@ -28,7 +28,7 @@ const documentLinkConverter = (field: DocumentLink): LinkContent => ({
|
|
|
28
28
|
const fileLinkConverter = (field: MediaLink, asset: Asset): LinkContent => ({
|
|
29
29
|
value: {
|
|
30
30
|
id: field.id,
|
|
31
|
-
url: asset.
|
|
31
|
+
url: asset.origin_url,
|
|
32
32
|
name: asset.filename ?? "unknown.jpg",
|
|
33
33
|
kind: asset.kind,
|
|
34
34
|
size: asset.size ? String(asset.size) : "0",
|
|
@@ -40,7 +40,7 @@ const fileLinkConverter = (field: MediaLink, asset: Asset): LinkContent => ({
|
|
|
40
40
|
const imageLinkConverter = (field: MediaLink, asset: Asset): LinkContent => ({
|
|
41
41
|
value: {
|
|
42
42
|
id: field.id,
|
|
43
|
-
url: asset.
|
|
43
|
+
url: asset.origin_url,
|
|
44
44
|
height: String(asset.height ?? 1),
|
|
45
45
|
width: String(asset.width ?? 1),
|
|
46
46
|
name: asset.filename ?? "unknown.jpg",
|
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
import type { StaticWidget } from "../../../customtypes"
|
|
2
2
|
import { ImportSlices } from "./ImportSlices"
|
|
3
3
|
import { ImportNestable } from "./nestable"
|
|
4
|
-
import { ImportUID } from "./UID"
|
|
5
4
|
|
|
6
|
-
export type ImportField =
|
|
5
|
+
export type ImportField = ImportSlices | ImportNestable
|
|
7
6
|
|
|
8
7
|
export const ImportField = {
|
|
9
|
-
is(u: unknown): u is
|
|
10
|
-
return
|
|
8
|
+
is(u: unknown): u is ImportField {
|
|
9
|
+
return ImportField.is(u)
|
|
11
10
|
},
|
|
12
11
|
decode: (field: StaticWidget) => {
|
|
13
12
|
return (content: unknown) => {
|
|
14
13
|
switch (field.type) {
|
|
15
14
|
case "UID":
|
|
16
|
-
|
|
15
|
+
throw new Error(
|
|
16
|
+
`The field '${field.type}' should be put at the root level of the document`,
|
|
17
|
+
)
|
|
17
18
|
case "Slices":
|
|
18
19
|
return {
|
|
19
20
|
codec: ImportSlices(field),
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as t from "io-ts"
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { String } from "../../../validators"
|
|
4
4
|
import { ImportContent } from "./ImportContent"
|
|
5
5
|
|
|
6
6
|
const regex = /^[a-z0-9-_.]+$/
|
|
@@ -23,5 +23,5 @@ const uidValue = String.pipe(
|
|
|
23
23
|
),
|
|
24
24
|
)
|
|
25
25
|
|
|
26
|
-
export const ImportUID = ImportContent("UID",
|
|
26
|
+
export const ImportUID = ImportContent("UID", uidValue)
|
|
27
27
|
export type ImportUID = t.TypeOf<typeof ImportUID>
|