@prismicio/types-internal 2.2.0-alpha.1 → 2.2.0-alpha.2
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/content/fields/GroupContent.js +11 -4
- package/lib/customtypes/widgets/nestable/NestableWidget.d.ts +0 -157
- package/lib/customtypes/widgets/nestable/NestableWidget.js +1 -17
- package/lib/import/converters/Document.d.ts +3 -2
- package/lib/import/converters/Document.js +9 -7
- package/lib/import/converters/fields/UID.d.ts +3 -0
- package/lib/import/converters/fields/UID.js +12 -0
- package/lib/import/converters/fields/index.d.ts +1 -0
- package/lib/import/converters/fields/index.js +1 -0
- package/lib/import/converters/fields/nestable/Boolean.d.ts +3 -0
- package/lib/import/converters/fields/nestable/Boolean.js +12 -0
- package/lib/import/converters/fields/nestable/Color.js +9 -6
- package/lib/import/converters/fields/nestable/Date.d.ts +1 -1
- package/lib/import/converters/fields/nestable/Date.js +5 -5
- package/lib/import/converters/fields/nestable/Embed.d.ts +3 -0
- package/lib/import/converters/fields/nestable/Embed.js +13 -0
- package/lib/import/converters/fields/nestable/Image.d.ts +18 -0
- package/lib/import/converters/fields/nestable/Image.js +45 -0
- package/lib/import/converters/fields/nestable/Link.d.ts +3 -0
- package/lib/import/converters/fields/nestable/Link.js +19 -0
- package/lib/import/converters/fields/nestable/Nestable.d.ts +2 -1
- package/lib/import/converters/fields/nestable/Nestable.js +7 -1
- package/lib/import/converters/fields/nestable/Number.js +9 -6
- package/lib/import/converters/fields/nestable/Select.js +9 -6
- package/lib/import/converters/fields/nestable/Text.js +9 -6
- package/lib/import/converters/fields/nestable/Timestamp.d.ts +1 -1
- package/lib/import/converters/fields/nestable/Timestamp.js +9 -6
- package/lib/import/converters/fields/nestable/index.d.ts +3 -0
- package/lib/import/converters/fields/nestable/index.js +3 -0
- package/lib/import/validators/Document.d.ts +4 -4
- package/lib/import/validators/Document.js +41 -44
- package/lib/import/validators/fields/ImportContent.d.ts +5 -0
- package/lib/import/validators/fields/ImportContent.js +21 -0
- package/lib/import/validators/fields/ImportField.d.ts +131 -0
- package/lib/import/validators/fields/ImportField.js +24 -0
- package/lib/import/validators/fields/UID.d.ts +6 -0
- package/lib/import/validators/fields/UID.js +15 -0
- package/lib/import/validators/fields/index.d.ts +1 -5
- package/lib/import/validators/fields/index.js +1 -0
- package/lib/import/validators/fields/nestable/Boolean.d.ts +6 -0
- package/lib/import/validators/fields/nestable/Boolean.js +6 -0
- package/lib/import/validators/fields/nestable/Color.d.ts +5 -4
- package/lib/import/validators/fields/nestable/Color.js +4 -4
- package/lib/import/validators/fields/nestable/Date.d.ts +5 -3
- package/lib/import/validators/fields/nestable/Date.js +4 -2
- package/lib/import/validators/fields/nestable/Embed.d.ts +27 -0
- package/lib/import/validators/fields/nestable/Embed.js +54 -0
- package/lib/import/validators/fields/nestable/Image.d.ts +24 -0
- package/lib/import/validators/fields/nestable/Image.js +45 -0
- package/lib/import/validators/fields/nestable/Link.d.ts +20 -0
- package/lib/import/validators/fields/nestable/Link.js +30 -0
- package/lib/import/validators/fields/nestable/Nestable.d.ts +124 -4
- package/lib/import/validators/fields/nestable/Nestable.js +50 -27
- package/lib/import/validators/fields/nestable/Number.d.ts +16 -9
- package/lib/import/validators/fields/nestable/Number.js +5 -4
- package/lib/import/validators/fields/nestable/Select.d.ts +15 -8
- package/lib/import/validators/fields/nestable/Select.js +4 -2
- package/lib/import/validators/fields/nestable/Text.d.ts +6 -3
- package/lib/import/validators/fields/nestable/Text.js +2 -1
- package/lib/import/validators/fields/nestable/Timestamp.d.ts +5 -3
- package/lib/import/validators/fields/nestable/Timestamp.js +4 -2
- package/lib/import/validators/fields/nestable/index.d.ts +3 -0
- package/lib/import/validators/fields/nestable/index.js +3 -0
- package/lib/utils/Objects.d.ts +1 -0
- package/lib/utils/Objects.js +5 -1
- package/lib/validators/BasicTypes.d.ts +8 -0
- package/lib/validators/BasicTypes.js +19 -1
- package/lib/validators/DefaultOrElse.d.ts +5 -0
- package/lib/validators/DefaultOrElse.js +21 -0
- package/lib/validators/index.d.ts +1 -1
- package/lib/validators/index.js +1 -1
- package/package.json +3 -2
- package/src/content/fields/GroupContent.ts +9 -5
- package/src/customtypes/widgets/nestable/NestableWidget.ts +0 -17
- package/src/import/converters/Document.ts +18 -11
- package/src/import/converters/fields/UID.ts +13 -0
- package/src/import/converters/fields/index.ts +1 -0
- package/src/import/converters/fields/nestable/Boolean.ts +13 -0
- package/src/import/converters/fields/nestable/Color.ts +7 -5
- package/src/import/converters/fields/nestable/Date.ts +12 -13
- package/src/import/converters/fields/nestable/Embed.ts +15 -0
- package/src/import/converters/fields/nestable/Image.ts +68 -0
- package/src/import/converters/fields/nestable/Nestable.ts +11 -0
- package/src/import/converters/fields/nestable/Number.ts +7 -5
- package/src/import/converters/fields/nestable/Select.ts +7 -5
- package/src/import/converters/fields/nestable/Text.ts +7 -5
- package/src/import/converters/fields/nestable/Timestamp.ts +8 -6
- package/src/import/converters/fields/nestable/index.ts +3 -0
- package/src/import/validators/Document.ts +94 -79
- package/src/import/validators/fields/ImportContent.ts +30 -0
- package/src/import/validators/fields/ImportField.ts +25 -0
- package/src/import/validators/fields/UID.ts +27 -0
- package/src/import/validators/fields/index.ts +1 -7
- package/src/import/validators/fields/nestable/Boolean.ts +7 -0
- package/src/import/validators/fields/nestable/Color.ts +23 -23
- package/src/import/validators/fields/nestable/Date.ts +26 -27
- package/src/import/validators/fields/nestable/Embed.ts +86 -0
- package/src/import/validators/fields/nestable/Image.ts +90 -0
- package/src/import/validators/fields/nestable/Nestable.ts +55 -26
- package/src/import/validators/fields/nestable/Number.ts +32 -30
- package/src/import/validators/fields/nestable/Select.ts +32 -30
- package/src/import/validators/fields/nestable/Text.ts +6 -6
- package/src/import/validators/fields/nestable/Timestamp.ts +29 -26
- package/src/import/validators/fields/nestable/index.ts +3 -0
- package/src/utils/Objects.ts +10 -0
- package/src/validators/BasicTypes.ts +48 -0
- package/src/validators/DefaultOrElse.ts +24 -0
- package/src/validators/index.ts +1 -1
- package/lib/import/converters/fields/utils.d.ts +0 -1
- package/lib/import/converters/fields/utils.js +0 -10
- package/lib/validators/NullOrT.d.ts +0 -2
- package/lib/validators/NullOrT.js +0 -13
- package/src/import/converters/fields/utils.ts +0 -7
- package/src/validators/NullOrT.ts +0 -18
|
@@ -48,16 +48,23 @@ const GroupItemLegacy = (ctx) => {
|
|
|
48
48
|
};
|
|
49
49
|
exports.GroupItemLegacy = GroupItemLegacy;
|
|
50
50
|
const GroupLegacy = (ctx) => {
|
|
51
|
-
const
|
|
51
|
+
const codecDecode = t.array(t.union([t.null, (0, exports.GroupItemLegacy)(ctx)]));
|
|
52
|
+
const codecEncode = t.array((0, exports.GroupItemLegacy)(ctx));
|
|
52
53
|
return new t.Type("GroupLegacy", exports.isGroupContent, (items) => {
|
|
53
|
-
return (0, function_1.pipe)(
|
|
54
|
+
return (0, function_1.pipe)(codecDecode.decode(items), fp_ts_1.either.map((parsedItems) => {
|
|
54
55
|
return {
|
|
55
|
-
value: parsedItems
|
|
56
|
+
value: parsedItems.map((i) => {
|
|
57
|
+
if (i === null) {
|
|
58
|
+
return { __TYPE__: exports.GroupItemContentType, value: [] };
|
|
59
|
+
}
|
|
60
|
+
else
|
|
61
|
+
return i;
|
|
62
|
+
}),
|
|
56
63
|
__TYPE__: exports.GroupContentType,
|
|
57
64
|
};
|
|
58
65
|
}));
|
|
59
66
|
}, (g) => {
|
|
60
|
-
const res =
|
|
67
|
+
const res = codecEncode.encode(g.value);
|
|
61
68
|
return {
|
|
62
69
|
content: res.map((block) => block.content),
|
|
63
70
|
types: res.reduce((acc, block) => {
|
|
@@ -156,162 +156,5 @@ export declare const NestableWidget: t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC
|
|
|
156
156
|
catalog: t.StringC;
|
|
157
157
|
}>>;
|
|
158
158
|
}>]>>]>;
|
|
159
|
-
export declare const isNestableWidget: (u: unknown) => u is ({
|
|
160
|
-
type: "Boolean";
|
|
161
|
-
} & {
|
|
162
|
-
config?: {
|
|
163
|
-
label?: string | null | undefined;
|
|
164
|
-
default_value?: boolean;
|
|
165
|
-
placeholder_true?: string;
|
|
166
|
-
placeholder_false?: string;
|
|
167
|
-
};
|
|
168
|
-
}) | ({
|
|
169
|
-
type: "Color";
|
|
170
|
-
} & {
|
|
171
|
-
fieldset?: string | null | undefined;
|
|
172
|
-
config?: {
|
|
173
|
-
label?: string | null | undefined;
|
|
174
|
-
placeholder?: string;
|
|
175
|
-
};
|
|
176
|
-
}) | ({
|
|
177
|
-
type: "Date";
|
|
178
|
-
} & {
|
|
179
|
-
fieldset?: string | null | undefined;
|
|
180
|
-
config?: {
|
|
181
|
-
label?: string | null | undefined;
|
|
182
|
-
placeholder?: string;
|
|
183
|
-
default?: string;
|
|
184
|
-
};
|
|
185
|
-
}) | ({
|
|
186
|
-
type: "Embed";
|
|
187
|
-
} & {
|
|
188
|
-
fieldset?: string | null | undefined;
|
|
189
|
-
config?: {
|
|
190
|
-
label?: string | null | undefined;
|
|
191
|
-
placeholder?: string;
|
|
192
|
-
useAsTitle?: boolean;
|
|
193
|
-
};
|
|
194
|
-
}) | ({
|
|
195
|
-
type: "GeoPoint";
|
|
196
|
-
} & {
|
|
197
|
-
fieldset?: string | null | undefined;
|
|
198
|
-
config?: {
|
|
199
|
-
label?: string | null | undefined;
|
|
200
|
-
};
|
|
201
|
-
}) | ({
|
|
202
|
-
type: "Image";
|
|
203
|
-
} & {
|
|
204
|
-
fieldset?: string | null | undefined;
|
|
205
|
-
config?: {
|
|
206
|
-
label?: string | null | undefined;
|
|
207
|
-
placeholder?: string;
|
|
208
|
-
constraint?: {
|
|
209
|
-
width?: number | null;
|
|
210
|
-
height?: number | null;
|
|
211
|
-
};
|
|
212
|
-
thumbnails?: readonly ({
|
|
213
|
-
name: string;
|
|
214
|
-
} & {
|
|
215
|
-
width?: number | null;
|
|
216
|
-
height?: number | null;
|
|
217
|
-
})[];
|
|
218
|
-
};
|
|
219
|
-
}) | ({
|
|
220
|
-
type: "IntegrationFields";
|
|
221
|
-
} & {
|
|
222
|
-
fieldset?: string | null | undefined;
|
|
223
|
-
config?: {
|
|
224
|
-
label?: string | null | undefined;
|
|
225
|
-
placeholder?: string;
|
|
226
|
-
catalog?: string;
|
|
227
|
-
};
|
|
228
|
-
}) | ({
|
|
229
|
-
type: "Link";
|
|
230
|
-
} & {
|
|
231
|
-
fieldset?: string | null | undefined;
|
|
232
|
-
config?: {
|
|
233
|
-
label?: string | null | undefined;
|
|
234
|
-
useAsTitle?: boolean;
|
|
235
|
-
placeholder?: string;
|
|
236
|
-
select?: "media" | "document" | "web" | null;
|
|
237
|
-
customtypes?: readonly string[];
|
|
238
|
-
masks?: readonly string[];
|
|
239
|
-
tags?: readonly string[];
|
|
240
|
-
allowTargetBlank?: boolean;
|
|
241
|
-
};
|
|
242
|
-
}) | ({
|
|
243
|
-
type: "Number";
|
|
244
|
-
} & {
|
|
245
|
-
fieldset?: string | null | undefined;
|
|
246
|
-
config?: {
|
|
247
|
-
label?: string | null | undefined;
|
|
248
|
-
placeholder?: string;
|
|
249
|
-
min?: number;
|
|
250
|
-
max?: number;
|
|
251
|
-
step?: number;
|
|
252
|
-
};
|
|
253
|
-
}) | ({
|
|
254
|
-
type: "Range";
|
|
255
|
-
} & {
|
|
256
|
-
fieldset?: string | null | undefined;
|
|
257
|
-
config?: {
|
|
258
|
-
label?: string | null | undefined;
|
|
259
|
-
placeholder?: string;
|
|
260
|
-
min?: number;
|
|
261
|
-
max?: number;
|
|
262
|
-
step?: number;
|
|
263
|
-
};
|
|
264
|
-
}) | ({
|
|
265
|
-
type: "StructuredText";
|
|
266
|
-
} & {
|
|
267
|
-
fieldset?: string | null | undefined;
|
|
268
|
-
config?: {
|
|
269
|
-
label?: string | null | undefined;
|
|
270
|
-
placeholder?: string;
|
|
271
|
-
useAsTitle?: boolean;
|
|
272
|
-
single?: string;
|
|
273
|
-
multi?: string;
|
|
274
|
-
imageConstraint?: {
|
|
275
|
-
width?: number | null;
|
|
276
|
-
height?: number | null;
|
|
277
|
-
};
|
|
278
|
-
labels?: readonly string[];
|
|
279
|
-
allowTargetBlank?: boolean;
|
|
280
|
-
};
|
|
281
|
-
}) | ({
|
|
282
|
-
type: "Select";
|
|
283
|
-
} & {
|
|
284
|
-
fieldset?: string | null | undefined;
|
|
285
|
-
config?: {
|
|
286
|
-
label?: string | null | undefined;
|
|
287
|
-
placeholder?: string;
|
|
288
|
-
default_value?: string;
|
|
289
|
-
options?: readonly string[];
|
|
290
|
-
};
|
|
291
|
-
}) | ({
|
|
292
|
-
type: "Separator";
|
|
293
|
-
} & {
|
|
294
|
-
config?: {
|
|
295
|
-
label?: string | null | undefined;
|
|
296
|
-
};
|
|
297
|
-
}) | ({
|
|
298
|
-
type: "Text";
|
|
299
|
-
} & {
|
|
300
|
-
fieldset?: string | null | undefined;
|
|
301
|
-
config?: {
|
|
302
|
-
label?: string | null | undefined;
|
|
303
|
-
useAsTitle?: boolean;
|
|
304
|
-
placeholder?: string;
|
|
305
|
-
};
|
|
306
|
-
}) | ({
|
|
307
|
-
type: "Timestamp";
|
|
308
|
-
} & {
|
|
309
|
-
fieldset?: string | null | undefined;
|
|
310
|
-
config?: {
|
|
311
|
-
label?: string | null | undefined;
|
|
312
|
-
placeholder?: string;
|
|
313
|
-
default?: string;
|
|
314
|
-
};
|
|
315
|
-
});
|
|
316
159
|
export declare type NestableWidget = t.TypeOf<typeof NestableWidget>;
|
|
317
160
|
export declare type NestableFieldTypes = NestableWidget["type"];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.NestableWidget = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const t = (0, tslib_1.__importStar)(require("io-ts"));
|
|
6
6
|
const BooleanField_1 = require("./BooleanField");
|
|
@@ -35,19 +35,3 @@ exports.NestableWidget = t.union([
|
|
|
35
35
|
Image_1.Image,
|
|
36
36
|
IntegrationField_1.IntegrationField,
|
|
37
37
|
]);
|
|
38
|
-
const isNestableWidget = (u) => Color_1.Color.is(u) ||
|
|
39
|
-
BooleanField_1.BooleanField.is(u) ||
|
|
40
|
-
Embed_1.Embed.is(u) ||
|
|
41
|
-
GeoPoint_1.GeoPoint.is(u) ||
|
|
42
|
-
Date_1.Date.is(u) ||
|
|
43
|
-
Number_1.Number.is(u) ||
|
|
44
|
-
Range_1.Range.is(u) ||
|
|
45
|
-
RichText_1.RichText.is(u) ||
|
|
46
|
-
Select_1.Select.is(u) ||
|
|
47
|
-
Separator_1.Separator.is(u) ||
|
|
48
|
-
Text_1.Text.is(u) ||
|
|
49
|
-
Timestamp_1.Timestamp.is(u) ||
|
|
50
|
-
Link_1.Link.is(u) ||
|
|
51
|
-
Image_1.Image.is(u) ||
|
|
52
|
-
IntegrationField_1.IntegrationField.is(u);
|
|
53
|
-
exports.isNestableWidget = isNestableWidget;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import type { Document } from "../../content";
|
|
2
|
-
import { ImportDocument } from "../validators";
|
|
3
|
-
|
|
2
|
+
import type { ImportDocument } from "../validators";
|
|
3
|
+
import { Asset } from "./fields";
|
|
4
|
+
export declare function convertImportToContent(document: ImportDocument, images: Map<string, Asset>): Document;
|
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.convertImportToContent = void 0;
|
|
4
|
-
const validators_1 = require("../validators");
|
|
5
4
|
const fields_1 = require("./fields");
|
|
6
|
-
function convertImportToContent(document) {
|
|
5
|
+
function convertImportToContent(document, images) {
|
|
7
6
|
return Object.entries(document).reduce((acc, [fieldKey, fieldValue]) => {
|
|
8
|
-
const newFieldValue = convertWidget(fieldValue);
|
|
7
|
+
const newFieldValue = convertWidget(fieldValue, images);
|
|
9
8
|
return newFieldValue ? { ...acc, [fieldKey]: newFieldValue } : acc;
|
|
10
9
|
}, {});
|
|
11
10
|
}
|
|
12
11
|
exports.convertImportToContent = convertImportToContent;
|
|
13
|
-
function convertWidget(field) {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
12
|
+
function convertWidget(field, images) {
|
|
13
|
+
switch (field.type) {
|
|
14
|
+
case "UID":
|
|
15
|
+
return (0, fields_1.uidConverter)(field.value);
|
|
16
|
+
default:
|
|
17
|
+
return (0, fields_1.convertNestableWidget)(field, images);
|
|
18
|
+
}
|
|
17
19
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.uidConverter = void 0;
|
|
4
|
+
const uidConverter = (field) => {
|
|
5
|
+
if (field === null)
|
|
6
|
+
return;
|
|
7
|
+
return {
|
|
8
|
+
value: field,
|
|
9
|
+
__TYPE__: "UIDContent",
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
exports.uidConverter = uidConverter;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.booleanConverter = void 0;
|
|
4
|
+
const booleanConverter = (field) => {
|
|
5
|
+
if (field === null)
|
|
6
|
+
return;
|
|
7
|
+
return {
|
|
8
|
+
value: field,
|
|
9
|
+
__TYPE__: "BooleanContent",
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
exports.booleanConverter = booleanConverter;
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.colorConverter = void 0;
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
4
|
+
const colorConverter = (field) => {
|
|
5
|
+
if (field === null)
|
|
6
|
+
return;
|
|
7
|
+
return {
|
|
8
|
+
type: "Color",
|
|
9
|
+
value: field,
|
|
10
|
+
__TYPE__: "FieldContent",
|
|
11
|
+
};
|
|
12
|
+
};
|
|
10
13
|
exports.colorConverter = colorConverter;
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.dateConverter = void 0;
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const isoDate =
|
|
4
|
+
const dateConverter = (field) => {
|
|
5
|
+
if (field === null)
|
|
6
|
+
return;
|
|
7
|
+
const isoDate = field.toISOString();
|
|
8
8
|
const [withoutTime] = isoDate.split("T");
|
|
9
9
|
return {
|
|
10
10
|
type: "Date",
|
|
11
11
|
value: withoutTime || isoDate,
|
|
12
12
|
__TYPE__: "FieldContent",
|
|
13
13
|
};
|
|
14
|
-
}
|
|
14
|
+
};
|
|
15
15
|
exports.dateConverter = dateConverter;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.embedConverter = void 0;
|
|
4
|
+
const embedConverter = (field) => {
|
|
5
|
+
if (field === null)
|
|
6
|
+
return;
|
|
7
|
+
return {
|
|
8
|
+
...field,
|
|
9
|
+
__TYPE__: "EmbedContent",
|
|
10
|
+
};
|
|
11
|
+
return;
|
|
12
|
+
};
|
|
13
|
+
exports.embedConverter = embedConverter;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ImageContent } from "../../../../content";
|
|
2
|
+
import type { ImportImage } from "../../../validators";
|
|
3
|
+
export declare type Asset = {
|
|
4
|
+
id: string;
|
|
5
|
+
last_modified: string;
|
|
6
|
+
kind: "image" | "all";
|
|
7
|
+
filename?: string;
|
|
8
|
+
extension?: string;
|
|
9
|
+
size?: string;
|
|
10
|
+
origin_url: string;
|
|
11
|
+
url: string;
|
|
12
|
+
width?: number;
|
|
13
|
+
height?: number;
|
|
14
|
+
notes?: string;
|
|
15
|
+
credits?: string;
|
|
16
|
+
alt?: string;
|
|
17
|
+
};
|
|
18
|
+
export declare const imageConverter: (field: ImportImage["value"], images: Map<string, Asset>) => ImageContent | undefined;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.imageConverter = void 0;
|
|
4
|
+
const Objects_1 = require("../../../../utils/Objects");
|
|
5
|
+
function convertImage(field, image) {
|
|
6
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
7
|
+
return (0, Objects_1.withOptionals)({
|
|
8
|
+
origin: {
|
|
9
|
+
id: field.id,
|
|
10
|
+
url: image.origin_url,
|
|
11
|
+
width: image.width,
|
|
12
|
+
height: image.height,
|
|
13
|
+
},
|
|
14
|
+
width: (_b = (_a = field.edit) === null || _a === void 0 ? void 0 : _a.width) !== null && _b !== void 0 ? _b : image.width,
|
|
15
|
+
height: (_d = (_c = field.edit) === null || _c === void 0 ? void 0 : _c.height) !== null && _d !== void 0 ? _d : image.height,
|
|
16
|
+
edit: {
|
|
17
|
+
zoom: (_f = (_e = field.edit) === null || _e === void 0 ? void 0 : _e.zoom) !== null && _f !== void 0 ? _f : 1,
|
|
18
|
+
crop: {
|
|
19
|
+
x: (_h = (_g = field.edit) === null || _g === void 0 ? void 0 : _g.x) !== null && _h !== void 0 ? _h : 0,
|
|
20
|
+
y: (_k = (_j = field.edit) === null || _j === void 0 ? void 0 : _j.y) !== null && _k !== void 0 ? _k : 0,
|
|
21
|
+
},
|
|
22
|
+
background: (_m = (_l = field.edit) === null || _l === void 0 ? void 0 : _l.background) !== null && _m !== void 0 ? _m : "transparent",
|
|
23
|
+
},
|
|
24
|
+
url: image.url,
|
|
25
|
+
}, [
|
|
26
|
+
["alt", field.alt || image.alt],
|
|
27
|
+
["credits", field.credit || image.credits],
|
|
28
|
+
]);
|
|
29
|
+
}
|
|
30
|
+
const imageConverter = (field, images) => {
|
|
31
|
+
const getImageById = (id) => {
|
|
32
|
+
const image = images.get(id);
|
|
33
|
+
if (!image)
|
|
34
|
+
throw new Error(`Missing asset with id '${id}'`);
|
|
35
|
+
return image;
|
|
36
|
+
};
|
|
37
|
+
if (!field)
|
|
38
|
+
return;
|
|
39
|
+
return {
|
|
40
|
+
...convertImage(field, getImageById(field.id)),
|
|
41
|
+
thumbnails: (0, Objects_1.mapValues)(field.thumbnails, (thumbnail) => convertImage(thumbnail, getImageById(thumbnail.id))),
|
|
42
|
+
__TYPE__: "ImageContent",
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
exports.imageConverter = imageConverter;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.linkConverter = void 0;
|
|
4
|
+
const linkConverter = (field) => {
|
|
5
|
+
if (field === null)
|
|
6
|
+
return;
|
|
7
|
+
if (field.link_type === "Document" || field.link_type === "Media") {
|
|
8
|
+
throw new Error("`Document` and `Media` links are not yet supported");
|
|
9
|
+
}
|
|
10
|
+
return {
|
|
11
|
+
value: {
|
|
12
|
+
url: field.url,
|
|
13
|
+
target: field.target,
|
|
14
|
+
__TYPE__: "ExternalLink",
|
|
15
|
+
},
|
|
16
|
+
__TYPE__: "LinkContent",
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
exports.linkConverter = linkConverter;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import type { WidgetContent } from "../../../../content";
|
|
2
2
|
import type { ImportNestable } from "../../../validators";
|
|
3
|
-
|
|
3
|
+
import { Asset } from ".";
|
|
4
|
+
export declare function convertNestableWidget(field: ImportNestable, images: Map<string, Asset>): WidgetContent | undefined;
|
|
@@ -2,8 +2,10 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.convertNestableWidget = void 0;
|
|
4
4
|
const _1 = require(".");
|
|
5
|
-
function convertNestableWidget(field) {
|
|
5
|
+
function convertNestableWidget(field, images) {
|
|
6
6
|
switch (field.type) {
|
|
7
|
+
case "Boolean":
|
|
8
|
+
return (0, _1.booleanConverter)(field.value);
|
|
7
9
|
case "Color":
|
|
8
10
|
return (0, _1.colorConverter)(field.value);
|
|
9
11
|
case "Select":
|
|
@@ -16,6 +18,10 @@ function convertNestableWidget(field) {
|
|
|
16
18
|
return (0, _1.dateConverter)(field.value);
|
|
17
19
|
case "Timestamp":
|
|
18
20
|
return (0, _1.timestampConverter)(field.value);
|
|
21
|
+
case "Embed":
|
|
22
|
+
return (0, _1.embedConverter)(field.value);
|
|
23
|
+
case "Image":
|
|
24
|
+
return (0, _1.imageConverter)(field.value, images);
|
|
19
25
|
default:
|
|
20
26
|
throw new Error(`Unsupported type of nestable converter ${JSON.stringify(field)}`);
|
|
21
27
|
}
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.numberConverter = void 0;
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
4
|
+
const numberConverter = (field) => {
|
|
5
|
+
if (field === null)
|
|
6
|
+
return;
|
|
7
|
+
return {
|
|
8
|
+
type: "Number",
|
|
9
|
+
value: field.toString(),
|
|
10
|
+
__TYPE__: "FieldContent",
|
|
11
|
+
};
|
|
12
|
+
};
|
|
10
13
|
exports.numberConverter = numberConverter;
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.selectConverter = void 0;
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
4
|
+
const selectConverter = (field) => {
|
|
5
|
+
if (field === null)
|
|
6
|
+
return;
|
|
7
|
+
return {
|
|
8
|
+
type: "Select",
|
|
9
|
+
value: field,
|
|
10
|
+
__TYPE__: "FieldContent",
|
|
11
|
+
};
|
|
12
|
+
};
|
|
10
13
|
exports.selectConverter = selectConverter;
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.textConverter = void 0;
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
4
|
+
const textConverter = (field) => {
|
|
5
|
+
if (field === null)
|
|
6
|
+
return;
|
|
7
|
+
return {
|
|
8
|
+
type: "Text",
|
|
9
|
+
value: field,
|
|
10
|
+
__TYPE__: "FieldContent",
|
|
11
|
+
};
|
|
12
|
+
};
|
|
10
13
|
exports.textConverter = textConverter;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { TimestampContent } from "../../../../content";
|
|
2
|
-
import type { ImportTimestamp } from "
|
|
2
|
+
import type { ImportTimestamp } from "../../../validators";
|
|
3
3
|
export declare const timestampConverter: (field: ImportTimestamp["value"]) => TimestampContent | undefined;
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.timestampConverter = void 0;
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
4
|
+
const timestampConverter = (field) => {
|
|
5
|
+
if (field === null)
|
|
6
|
+
return;
|
|
7
|
+
return {
|
|
8
|
+
type: "Timestamp",
|
|
9
|
+
value: field.toISOString(),
|
|
10
|
+
__TYPE__: "FieldContent",
|
|
11
|
+
};
|
|
12
|
+
};
|
|
10
13
|
exports.timestampConverter = timestampConverter;
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
|
+
(0, tslib_1.__exportStar)(require("./Boolean"), exports);
|
|
4
5
|
(0, tslib_1.__exportStar)(require("./Color"), exports);
|
|
5
6
|
(0, tslib_1.__exportStar)(require("./Date"), exports);
|
|
7
|
+
(0, tslib_1.__exportStar)(require("./Embed"), exports);
|
|
8
|
+
(0, tslib_1.__exportStar)(require("./Image"), exports);
|
|
6
9
|
(0, tslib_1.__exportStar)(require("./Nestable"), exports);
|
|
7
10
|
(0, tslib_1.__exportStar)(require("./Number"), exports);
|
|
8
11
|
(0, tslib_1.__exportStar)(require("./Select"), exports);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as t from "io-ts";
|
|
2
2
|
import type { WidgetKey } from "../../common";
|
|
3
|
-
import { StaticCustomType } from "../../customtypes";
|
|
4
|
-
import {
|
|
5
|
-
export declare type ImportDocument = Record<WidgetKey,
|
|
6
|
-
export declare const ImportDocument: (
|
|
3
|
+
import type { StaticCustomType } from "../../customtypes";
|
|
4
|
+
import { ImportField } from "./fields/ImportField";
|
|
5
|
+
export declare type ImportDocument = Record<WidgetKey, ImportField>;
|
|
6
|
+
export declare const ImportDocument: (customType: StaticCustomType) => t.Type<ImportDocument, ImportDocument, unknown>;
|