@prismicio/types-internal 2.2.0-alpha.25 → 2.2.0-alpha.26
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 +2 -0
- package/lib/import/converters/fields/Group.d.ts +4 -0
- package/lib/import/converters/fields/Group.js +14 -0
- package/lib/import/converters/fields/RepeatableZone.d.ts +309 -0
- package/lib/import/converters/fields/RepeatableZone.js +15 -0
- package/lib/import/converters/fields/RepeatableZoneItem.d.ts +11 -0
- package/lib/import/converters/fields/RepeatableZoneItem.js +19 -0
- package/lib/import/converters/fields/Slices/SharedSliceContent.js +6 -41
- package/lib/import/converters/fields/index.d.ts +1 -0
- package/lib/import/converters/fields/index.js +1 -0
- package/lib/import/validators/fields/ImportField.d.ts +11 -1
- package/lib/import/validators/fields/ImportField.js +6 -1
- package/lib/import/validators/fields/ImportGroup.d.ts +345 -0
- package/lib/import/validators/fields/ImportGroup.js +27 -0
- package/lib/import/validators/fields/ImportSlices/SharedSlice/SharedSlice.d.ts +5 -3
- package/lib/import/validators/fields/ImportSlices/SharedSlice/SharedSlice.js +4 -4
- package/lib/import/validators/fields/ImportSlices/SharedSlice/fields/index.d.ts +0 -1
- package/lib/import/validators/fields/ImportSlices/SharedSlice/fields/index.js +0 -1
- package/lib/import/validators/fields/RepeatableZone.d.ts +11 -0
- package/lib/import/validators/fields/RepeatableZone.js +14 -0
- package/lib/import/validators/fields/RepeatableZoneItem.d.ts +11 -0
- package/lib/import/validators/fields/RepeatableZoneItem.js +39 -0
- package/lib/import/validators/fields/index.d.ts +2 -0
- package/lib/import/validators/fields/index.js +2 -0
- package/lib/import/validators/fields/nestable/Nestable.d.ts +60 -0
- package/lib/import/validators/fields/nestable/Nestable.js +32 -30
- package/package.json +1 -1
- package/src/import/converters/Document.ts +7 -1
- package/src/import/converters/fields/Group.ts +18 -0
- package/src/import/converters/fields/RepeatableZone.ts +19 -0
- package/src/import/converters/fields/RepeatableZoneItem.ts +32 -0
- package/src/import/converters/fields/Slices/SharedSliceContent.ts +9 -76
- package/src/import/converters/fields/index.ts +1 -0
- package/src/import/validators/fields/ImportField.ts +7 -2
- package/src/import/validators/fields/ImportGroup.ts +45 -0
- package/src/import/validators/fields/ImportSlices/SharedSlice/SharedSlice.ts +6 -18
- package/src/import/validators/fields/ImportSlices/SharedSlice/fields/index.ts +0 -1
- package/src/import/validators/fields/RepeatableZone.ts +21 -0
- package/src/import/validators/fields/RepeatableZoneItem.ts +64 -0
- package/src/import/validators/fields/index.ts +2 -0
- package/src/import/validators/fields/nestable/Nestable.ts +34 -31
- package/lib/import/validators/fields/ImportSlices/SharedSlice/fields/SharedSliceContent/SharedSliceContent.d.ts +0 -17
- package/lib/import/validators/fields/ImportSlices/SharedSlice/fields/SharedSliceContent/SharedSliceContent.js +0 -30
- package/lib/import/validators/fields/ImportSlices/SharedSlice/fields/SharedSliceContent/SharedSliceContentEntry.d.ts +0 -43
- package/lib/import/validators/fields/ImportSlices/SharedSlice/fields/SharedSliceContent/SharedSliceContentEntry.js +0 -69
- package/lib/import/validators/fields/ImportSlices/SharedSlice/fields/SharedSliceContent/errors.d.ts +0 -4
- package/lib/import/validators/fields/ImportSlices/SharedSlice/fields/SharedSliceContent/errors.js +0 -6
- package/lib/import/validators/fields/ImportSlices/SharedSlice/fields/SharedSliceContent/index.d.ts +0 -2
- package/lib/import/validators/fields/ImportSlices/SharedSlice/fields/SharedSliceContent/index.js +0 -5
- package/lib/import/validators/fields/ImportSlices/SharedSlice/fields/SharedSliceContent/types.d.ts +0 -1
- package/lib/import/validators/fields/ImportSlices/SharedSlice/fields/SharedSliceContent/types.js +0 -2
- package/lib/utils/io-ts.d.ts +0 -2
- package/lib/utils/io-ts.js +0 -22
- package/src/import/validators/fields/ImportSlices/SharedSlice/fields/SharedSliceContent/SharedSliceContent.ts +0 -64
- package/src/import/validators/fields/ImportSlices/SharedSlice/fields/SharedSliceContent/SharedSliceContentEntry.ts +0 -100
- package/src/import/validators/fields/ImportSlices/SharedSlice/fields/SharedSliceContent/errors.ts +0 -10
- package/src/import/validators/fields/ImportSlices/SharedSlice/fields/SharedSliceContent/index.ts +0 -2
- package/src/import/validators/fields/ImportSlices/SharedSlice/fields/SharedSliceContent/types.ts +0 -1
- package/src/utils/io-ts.ts +0 -29
|
@@ -13,6 +13,8 @@ function convertWidget(field, assets, embeds) {
|
|
|
13
13
|
switch (field.type) {
|
|
14
14
|
case "Slices":
|
|
15
15
|
return (0, fields_1.importSlicesConverter)(field.value, assets, embeds);
|
|
16
|
+
case "Group":
|
|
17
|
+
return (0, fields_1.importGroupConverter)(field.value, assets, embeds);
|
|
16
18
|
default:
|
|
17
19
|
return (0, fields_1.convertNestableWidget)(field, assets, embeds);
|
|
18
20
|
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { Asset, Embed } from "../../../common";
|
|
2
|
+
import type { GroupContent } from "../../../content";
|
|
3
|
+
import type { ImportGroup } from "../../validators/fields/ImportGroup";
|
|
4
|
+
export declare const importGroupConverter: (field: ImportGroup["value"], assets: Record<Asset["id"], Asset | undefined>, embeds: Record<string, Embed | undefined>) => GroupContent | undefined;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.importGroupConverter = void 0;
|
|
4
|
+
const content_1 = require("../../../content");
|
|
5
|
+
const RepeatableZone_1 = require("./RepeatableZone");
|
|
6
|
+
const importGroupConverter = (field, assets, embeds) => {
|
|
7
|
+
if (field === null)
|
|
8
|
+
return;
|
|
9
|
+
return {
|
|
10
|
+
__TYPE__: content_1.GroupContentType,
|
|
11
|
+
value: (0, RepeatableZone_1.repeatableZoneConverter)(field, assets, embeds),
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
exports.importGroupConverter = importGroupConverter;
|
|
@@ -0,0 +1,309 @@
|
|
|
1
|
+
import type { Asset, Embed } from "../../../common";
|
|
2
|
+
export declare const repeatableZoneConverter: (zone: import("../../validators").RepeatableZoneItem[], assets: Record<Asset["id"], Asset | undefined>, embeds: Record<string, Embed | undefined>) => {
|
|
3
|
+
__TYPE__: "GroupItemContent";
|
|
4
|
+
value: [string, {
|
|
5
|
+
type: string;
|
|
6
|
+
__TYPE__: "EmptyContent";
|
|
7
|
+
} | {
|
|
8
|
+
__TYPE__: "BooleanContent";
|
|
9
|
+
value: boolean;
|
|
10
|
+
} | ({
|
|
11
|
+
embed_url: string;
|
|
12
|
+
type: string;
|
|
13
|
+
} & {
|
|
14
|
+
version?: string | number | null;
|
|
15
|
+
title?: string | null | undefined;
|
|
16
|
+
author_name?: string | null | undefined;
|
|
17
|
+
author_url?: string | null | undefined;
|
|
18
|
+
provider_name?: string | null | undefined;
|
|
19
|
+
provider_url?: string | null | undefined;
|
|
20
|
+
cache_age?: string | number | null;
|
|
21
|
+
thumbnail_url?: string | null | undefined;
|
|
22
|
+
thumbnail_width?: number | null | undefined;
|
|
23
|
+
thumbnail_height?: number | null | undefined;
|
|
24
|
+
html?: string | null | undefined;
|
|
25
|
+
} & {
|
|
26
|
+
__TYPE__: "EmbedContent";
|
|
27
|
+
all: unknown;
|
|
28
|
+
}) | {
|
|
29
|
+
type: "Color";
|
|
30
|
+
value: string;
|
|
31
|
+
__TYPE__: "FieldContent";
|
|
32
|
+
} | {
|
|
33
|
+
type: "Date";
|
|
34
|
+
value: string;
|
|
35
|
+
__TYPE__: "FieldContent";
|
|
36
|
+
} | {
|
|
37
|
+
type: "Number";
|
|
38
|
+
value: string;
|
|
39
|
+
__TYPE__: "FieldContent";
|
|
40
|
+
} | {
|
|
41
|
+
type: "Range";
|
|
42
|
+
value: string;
|
|
43
|
+
__TYPE__: "FieldContent";
|
|
44
|
+
} | {
|
|
45
|
+
type: "Select";
|
|
46
|
+
value: string;
|
|
47
|
+
__TYPE__: "FieldContent";
|
|
48
|
+
} | {
|
|
49
|
+
type: "Text";
|
|
50
|
+
value: string;
|
|
51
|
+
__TYPE__: "FieldContent";
|
|
52
|
+
} | {
|
|
53
|
+
type: "Timestamp";
|
|
54
|
+
value: string;
|
|
55
|
+
__TYPE__: "FieldContent";
|
|
56
|
+
} | ({
|
|
57
|
+
position: {
|
|
58
|
+
lat: number;
|
|
59
|
+
lng: number;
|
|
60
|
+
};
|
|
61
|
+
} & {
|
|
62
|
+
__TYPE__: "GeoPointContent";
|
|
63
|
+
}) | ({
|
|
64
|
+
origin: {
|
|
65
|
+
id: string;
|
|
66
|
+
url: string;
|
|
67
|
+
width: number;
|
|
68
|
+
height: number;
|
|
69
|
+
};
|
|
70
|
+
width: number;
|
|
71
|
+
height: number;
|
|
72
|
+
edit: {
|
|
73
|
+
zoom: number;
|
|
74
|
+
crop: {
|
|
75
|
+
x: number;
|
|
76
|
+
y: number;
|
|
77
|
+
};
|
|
78
|
+
background: string;
|
|
79
|
+
};
|
|
80
|
+
} & {
|
|
81
|
+
url?: string;
|
|
82
|
+
credits?: string | null;
|
|
83
|
+
alt?: string | null;
|
|
84
|
+
provider?: string | null | undefined;
|
|
85
|
+
} & {
|
|
86
|
+
thumbnails?: {
|
|
87
|
+
[x: string]: {
|
|
88
|
+
origin: {
|
|
89
|
+
id: string;
|
|
90
|
+
url: string;
|
|
91
|
+
width: number;
|
|
92
|
+
height: number;
|
|
93
|
+
};
|
|
94
|
+
width: number;
|
|
95
|
+
height: number;
|
|
96
|
+
edit: {
|
|
97
|
+
zoom: number;
|
|
98
|
+
crop: {
|
|
99
|
+
x: number;
|
|
100
|
+
y: number;
|
|
101
|
+
};
|
|
102
|
+
background: string;
|
|
103
|
+
};
|
|
104
|
+
} & {
|
|
105
|
+
url?: string;
|
|
106
|
+
credits?: string | null;
|
|
107
|
+
alt?: string | null;
|
|
108
|
+
provider?: string | null | undefined;
|
|
109
|
+
};
|
|
110
|
+
};
|
|
111
|
+
} & {
|
|
112
|
+
__TYPE__: "ImageContent";
|
|
113
|
+
}) | {
|
|
114
|
+
__TYPE__: "IntegrationFieldsContent";
|
|
115
|
+
value: string;
|
|
116
|
+
} | {
|
|
117
|
+
__TYPE__: "LinkContent";
|
|
118
|
+
value: ({
|
|
119
|
+
__TYPE__: "ImageLink";
|
|
120
|
+
} & {
|
|
121
|
+
id: string;
|
|
122
|
+
url: string;
|
|
123
|
+
height: string;
|
|
124
|
+
width: string;
|
|
125
|
+
size: string;
|
|
126
|
+
name: string;
|
|
127
|
+
kind: string;
|
|
128
|
+
} & {
|
|
129
|
+
date?: string | null | undefined;
|
|
130
|
+
}) | ({
|
|
131
|
+
id: string;
|
|
132
|
+
url: string;
|
|
133
|
+
name: string;
|
|
134
|
+
kind: string;
|
|
135
|
+
size: string;
|
|
136
|
+
} & {
|
|
137
|
+
date?: string | null | undefined;
|
|
138
|
+
} & {
|
|
139
|
+
__TYPE__: "FileLink";
|
|
140
|
+
} & {
|
|
141
|
+
size?: string;
|
|
142
|
+
}) | ({
|
|
143
|
+
__TYPE__: "DocumentLink";
|
|
144
|
+
} & {
|
|
145
|
+
id: string;
|
|
146
|
+
}) | ({
|
|
147
|
+
__TYPE__: "ExternalLink";
|
|
148
|
+
} & {
|
|
149
|
+
url: string;
|
|
150
|
+
} & {
|
|
151
|
+
kind?: "web";
|
|
152
|
+
target?: string | null | undefined;
|
|
153
|
+
preview?: {
|
|
154
|
+
title?: string;
|
|
155
|
+
} | null | undefined;
|
|
156
|
+
});
|
|
157
|
+
} | {
|
|
158
|
+
__TYPE__: "StructuredTextContent";
|
|
159
|
+
value: (({
|
|
160
|
+
type: "image";
|
|
161
|
+
data: {
|
|
162
|
+
origin: {
|
|
163
|
+
id: string;
|
|
164
|
+
url: string;
|
|
165
|
+
width: number;
|
|
166
|
+
height: number;
|
|
167
|
+
};
|
|
168
|
+
width: number;
|
|
169
|
+
height: number;
|
|
170
|
+
edit: {
|
|
171
|
+
zoom: number;
|
|
172
|
+
crop: {
|
|
173
|
+
x: number;
|
|
174
|
+
y: number;
|
|
175
|
+
};
|
|
176
|
+
background: string;
|
|
177
|
+
};
|
|
178
|
+
} & {
|
|
179
|
+
url?: string;
|
|
180
|
+
credits?: string | null;
|
|
181
|
+
alt?: string | null;
|
|
182
|
+
provider?: string | null | undefined;
|
|
183
|
+
} & {
|
|
184
|
+
linkTo?: ({
|
|
185
|
+
__TYPE__: "ImageLink";
|
|
186
|
+
} & {
|
|
187
|
+
id: string;
|
|
188
|
+
url: string;
|
|
189
|
+
height: string;
|
|
190
|
+
width: string;
|
|
191
|
+
size: string;
|
|
192
|
+
name: string;
|
|
193
|
+
kind: string;
|
|
194
|
+
} & {
|
|
195
|
+
date?: string | null | undefined;
|
|
196
|
+
}) | ({
|
|
197
|
+
id: string;
|
|
198
|
+
url: string;
|
|
199
|
+
name: string;
|
|
200
|
+
kind: string;
|
|
201
|
+
size: string;
|
|
202
|
+
} & {
|
|
203
|
+
date?: string | null | undefined;
|
|
204
|
+
} & {
|
|
205
|
+
__TYPE__: "FileLink";
|
|
206
|
+
} & {
|
|
207
|
+
size?: string;
|
|
208
|
+
}) | ({
|
|
209
|
+
__TYPE__: "DocumentLink";
|
|
210
|
+
} & {
|
|
211
|
+
id: string;
|
|
212
|
+
}) | ({
|
|
213
|
+
__TYPE__: "ExternalLink";
|
|
214
|
+
} & {
|
|
215
|
+
url: string;
|
|
216
|
+
} & {
|
|
217
|
+
kind?: "web";
|
|
218
|
+
target?: string | null | undefined;
|
|
219
|
+
preview?: {
|
|
220
|
+
title?: string;
|
|
221
|
+
} | null | undefined;
|
|
222
|
+
}) | null | undefined;
|
|
223
|
+
};
|
|
224
|
+
} & {
|
|
225
|
+
label?: string | null | undefined;
|
|
226
|
+
direction?: string | null | undefined;
|
|
227
|
+
}) | ({
|
|
228
|
+
type: "embed";
|
|
229
|
+
data: {
|
|
230
|
+
embed_url: string;
|
|
231
|
+
type: string;
|
|
232
|
+
} & {
|
|
233
|
+
version?: string | number | null;
|
|
234
|
+
title?: string | null | undefined;
|
|
235
|
+
author_name?: string | null | undefined;
|
|
236
|
+
author_url?: string | null | undefined;
|
|
237
|
+
provider_name?: string | null | undefined;
|
|
238
|
+
provider_url?: string | null | undefined;
|
|
239
|
+
cache_age?: string | number | null;
|
|
240
|
+
thumbnail_url?: string | null | undefined;
|
|
241
|
+
thumbnail_width?: number | null | undefined;
|
|
242
|
+
thumbnail_height?: number | null | undefined;
|
|
243
|
+
html?: string | null | undefined;
|
|
244
|
+
} & {
|
|
245
|
+
__TYPE__: "EmbedContent";
|
|
246
|
+
all: unknown;
|
|
247
|
+
};
|
|
248
|
+
} & {
|
|
249
|
+
label?: string | null | undefined;
|
|
250
|
+
direction?: string | null | undefined;
|
|
251
|
+
}) | ({
|
|
252
|
+
type: "image" | "paragraph" | "heading1" | "heading2" | "heading3" | "heading4" | "heading5" | "heading6" | "strong" | "em" | "preformatted" | "hyperlink" | "embed" | "list-item" | "o-list-item" | "rtl";
|
|
253
|
+
content: {
|
|
254
|
+
text: string;
|
|
255
|
+
} & {
|
|
256
|
+
spans?: ({
|
|
257
|
+
data?: ({
|
|
258
|
+
__TYPE__: "ImageLink";
|
|
259
|
+
} & {
|
|
260
|
+
id: string;
|
|
261
|
+
url: string;
|
|
262
|
+
height: string;
|
|
263
|
+
width: string;
|
|
264
|
+
size: string;
|
|
265
|
+
name: string;
|
|
266
|
+
kind: string;
|
|
267
|
+
} & {
|
|
268
|
+
date?: string | null | undefined;
|
|
269
|
+
}) | ({
|
|
270
|
+
id: string;
|
|
271
|
+
url: string;
|
|
272
|
+
name: string;
|
|
273
|
+
kind: string;
|
|
274
|
+
size: string;
|
|
275
|
+
} & {
|
|
276
|
+
date?: string | null | undefined;
|
|
277
|
+
} & {
|
|
278
|
+
__TYPE__: "FileLink";
|
|
279
|
+
} & {
|
|
280
|
+
size?: string;
|
|
281
|
+
}) | ({
|
|
282
|
+
__TYPE__: "DocumentLink";
|
|
283
|
+
} & {
|
|
284
|
+
id: string;
|
|
285
|
+
}) | ({
|
|
286
|
+
__TYPE__: "ExternalLink";
|
|
287
|
+
} & {
|
|
288
|
+
url: string;
|
|
289
|
+
} & {
|
|
290
|
+
kind?: "web";
|
|
291
|
+
target?: string | null | undefined;
|
|
292
|
+
preview?: {
|
|
293
|
+
title?: string;
|
|
294
|
+
} | null | undefined;
|
|
295
|
+
});
|
|
296
|
+
} & {
|
|
297
|
+
start: number;
|
|
298
|
+
end: number;
|
|
299
|
+
type: "image" | "label" | "paragraph" | "heading1" | "heading2" | "heading3" | "heading4" | "heading5" | "heading6" | "strong" | "em" | "preformatted" | "hyperlink" | "embed" | "list-item" | "o-list-item" | "rtl";
|
|
300
|
+
})[];
|
|
301
|
+
};
|
|
302
|
+
} & {
|
|
303
|
+
label?: string;
|
|
304
|
+
direction?: string;
|
|
305
|
+
}))[];
|
|
306
|
+
} | {
|
|
307
|
+
__TYPE__: "SeparatorContent";
|
|
308
|
+
}][];
|
|
309
|
+
}[];
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.repeatableZoneConverter = void 0;
|
|
4
|
+
const content_1 = require("../../../content");
|
|
5
|
+
const RepeatableZoneItem_1 = require("./RepeatableZoneItem");
|
|
6
|
+
const repeatableZoneConverter = (zone, assets, embeds) => {
|
|
7
|
+
return zone.map((item) => {
|
|
8
|
+
const groupContent = (0, RepeatableZoneItem_1.repeatableZoneItemConverter)(item, assets, embeds);
|
|
9
|
+
return {
|
|
10
|
+
__TYPE__: content_1.GroupItemContentType,
|
|
11
|
+
value: Object.entries(groupContent),
|
|
12
|
+
};
|
|
13
|
+
});
|
|
14
|
+
};
|
|
15
|
+
exports.repeatableZoneConverter = repeatableZoneConverter;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Asset, Embed } from "../../../common";
|
|
2
|
+
import type { NestableContent } from "../../../content";
|
|
3
|
+
import type { RepeatableZoneItem } from "../../validators";
|
|
4
|
+
/**
|
|
5
|
+
* Converts the RepeatableZoneItem which is a record of widget keys and ImportNestable values to a record of widget keys and NestableContent values.
|
|
6
|
+
*
|
|
7
|
+
* @param content a single RepeatableZoneItem
|
|
8
|
+
* @param assets assets that are required for a conversion of a nestable widget
|
|
9
|
+
* @param embeds embeds that are required for a conversion of a nestable widget
|
|
10
|
+
*/
|
|
11
|
+
export declare const repeatableZoneItemConverter: (content: RepeatableZoneItem, assets: Record<Asset["id"], Asset | undefined>, embeds: Record<string, Embed | undefined>) => Record<string, NestableContent>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.repeatableZoneItemConverter = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const function_1 = require("fp-ts/function");
|
|
6
|
+
const O = (0, tslib_1.__importStar)(require("fp-ts/Option"));
|
|
7
|
+
const R = (0, tslib_1.__importStar)(require("fp-ts/Record"));
|
|
8
|
+
const nestable_1 = require("./nestable");
|
|
9
|
+
/**
|
|
10
|
+
* Converts the RepeatableZoneItem which is a record of widget keys and ImportNestable values to a record of widget keys and NestableContent values.
|
|
11
|
+
*
|
|
12
|
+
* @param content a single RepeatableZoneItem
|
|
13
|
+
* @param assets assets that are required for a conversion of a nestable widget
|
|
14
|
+
* @param embeds embeds that are required for a conversion of a nestable widget
|
|
15
|
+
*/
|
|
16
|
+
const repeatableZoneItemConverter = (content, assets, embeds) => (0, function_1.pipe)(content,
|
|
17
|
+
// convertNestableWidget can theoretically return undefined, so we need to filter out those values
|
|
18
|
+
R.filterMap((contentValue) => (0, function_1.pipe)(contentValue, (content) => content && (0, nestable_1.convertNestableWidget)(content, assets, embeds), O.fromNullable)));
|
|
19
|
+
exports.repeatableZoneItemConverter = repeatableZoneItemConverter;
|
|
@@ -1,46 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.importSharedSliceContentConverter = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const function_1 = require("fp-ts/function");
|
|
6
|
-
const O = (0, tslib_1.__importStar)(require("fp-ts/Option"));
|
|
7
|
-
const R = (0, tslib_1.__importStar)(require("fp-ts/Record"));
|
|
8
4
|
const content_1 = require("../../../../content");
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
* Converts the ImportSharedSliceContent which is a record of widget keys and ImportNestable values to a record of widget keys and NestableContent values.
|
|
12
|
-
*
|
|
13
|
-
* @param content a single ImportSharedSliceContent
|
|
14
|
-
* @param assets assets that are required for a conversion of a nestable widget
|
|
15
|
-
* @param embeds embeds that are required for a conversion of a nestable widget
|
|
16
|
-
*/
|
|
17
|
-
const sharedSliceContentConverter = (content, assets, embeds) => (0, function_1.pipe)(content,
|
|
18
|
-
// convertNestableWidget can theoretically return undefined, so we need to filter out those values
|
|
19
|
-
R.filterMap((contentValue) => (0, function_1.pipe)(contentValue, (content) => (0, nestable_1.convertNestableWidget)(content, assets, embeds), O.fromNullable)));
|
|
20
|
-
/**
|
|
21
|
-
* Converts a list of items to a list of repeatable widgets.
|
|
22
|
-
* Each ImportSharedSliceContent element is a record of fields, but in the content model it is represented as a list of tuples (key, value)
|
|
23
|
-
*
|
|
24
|
-
* For example, given the following slice content:
|
|
25
|
-
* {
|
|
26
|
-
* "slice_text": (ImportNestable),
|
|
27
|
-
* "slice_number": (ImportNestable),
|
|
28
|
-
* }
|
|
29
|
-
*
|
|
30
|
-
* has to be converted to:
|
|
31
|
-
*
|
|
32
|
-
* {
|
|
33
|
-
* __TYPE__: "GroupItemContentType",
|
|
34
|
-
* value: [
|
|
35
|
-
* ["slice_text", (NestableContent)],
|
|
36
|
-
* ["slice_number", (NestableContent)],
|
|
37
|
-
* ]
|
|
38
|
-
* }
|
|
39
|
-
*
|
|
40
|
-
* @param items list of items to be converted
|
|
41
|
-
* @param assets assets that are required for a conversion of a nestable widget
|
|
42
|
-
*/
|
|
43
|
-
const itemsConverter = (items, assets, embeds) => items.map((item) => (0, function_1.pipe)(sharedSliceContentConverter(item, assets, embeds), (record) => Object.entries(record), (entries) => ({ __TYPE__: content_1.GroupItemContentType, value: entries })));
|
|
5
|
+
const RepeatableZone_1 = require("../RepeatableZone");
|
|
6
|
+
const RepeatableZoneItem_1 = require("../RepeatableZoneItem");
|
|
44
7
|
/**
|
|
45
8
|
* Builds SharedSliceContent model from ImportSharedSlice
|
|
46
9
|
* @param field ImportSharedSlice to be converted - a single slice from the slices array in the import document
|
|
@@ -50,9 +13,11 @@ const itemsConverter = (items, assets, embeds) => items.map((item) => (0, functi
|
|
|
50
13
|
const importSharedSliceContentConverter = (field, assets, embeds) => ({
|
|
51
14
|
__TYPE__: content_1.SharedSliceContentType,
|
|
52
15
|
primary: field.primary
|
|
53
|
-
?
|
|
16
|
+
? (0, RepeatableZoneItem_1.repeatableZoneItemConverter)(field.primary, assets, embeds)
|
|
54
17
|
: {},
|
|
55
|
-
items: field.items
|
|
18
|
+
items: field.items
|
|
19
|
+
? (0, RepeatableZone_1.repeatableZoneConverter)(field.items, assets, embeds)
|
|
20
|
+
: [],
|
|
56
21
|
variation: field.variation,
|
|
57
22
|
});
|
|
58
23
|
exports.importSharedSliceContentConverter = importSharedSliceContentConverter;
|
|
@@ -1,6 +1,7 @@
|
|
|
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("./Group"), exports);
|
|
4
5
|
(0, tslib_1.__exportStar)(require("./nestable"), exports);
|
|
5
6
|
(0, tslib_1.__exportStar)(require("./Slices"), exports);
|
|
6
7
|
(0, tslib_1.__exportStar)(require("./UID"), exports);
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { StaticWidget } from "../../../customtypes";
|
|
2
|
+
import { ImportGroup } from "./ImportGroup";
|
|
2
3
|
import { ImportSlices } from "./ImportSlices";
|
|
3
4
|
import { ImportNestable } from "./nestable";
|
|
4
|
-
export declare type ImportField = ImportSlices | ImportNestable;
|
|
5
|
+
export declare type ImportField = ImportSlices | ImportNestable | ImportGroup;
|
|
5
6
|
export declare const ImportField: {
|
|
6
7
|
is(u: unknown): u is ImportField;
|
|
7
8
|
decode: (field: StaticWidget) => (content: unknown) => {
|
|
@@ -127,5 +128,14 @@ export declare const ImportField: {
|
|
|
127
128
|
type: "Slices";
|
|
128
129
|
value: import("./ImportSlices/SharedSlice").SharedSlice[] | null;
|
|
129
130
|
}>;
|
|
131
|
+
} | {
|
|
132
|
+
codec: import("io-ts").Type<{
|
|
133
|
+
type: "Group";
|
|
134
|
+
value: import("./RepeatableZoneItem").RepeatableZoneItem[] | null;
|
|
135
|
+
}, import("./RepeatableZoneItem").RepeatableZoneItem[] | undefined, unknown>;
|
|
136
|
+
result: import("io-ts").Validation<{
|
|
137
|
+
type: "Group";
|
|
138
|
+
value: import("./RepeatableZoneItem").RepeatableZoneItem[] | null;
|
|
139
|
+
}>;
|
|
130
140
|
};
|
|
131
141
|
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ImportField = void 0;
|
|
4
|
+
const ImportGroup_1 = require("./ImportGroup");
|
|
4
5
|
const ImportSlices_1 = require("./ImportSlices");
|
|
5
6
|
const nestable_1 = require("./nestable");
|
|
6
7
|
exports.ImportField = {
|
|
@@ -17,8 +18,12 @@ exports.ImportField = {
|
|
|
17
18
|
codec: (0, ImportSlices_1.ImportSlices)(field),
|
|
18
19
|
result: (0, ImportSlices_1.ImportSlices)(field).decode(content),
|
|
19
20
|
};
|
|
20
|
-
case "Choice":
|
|
21
21
|
case "Group":
|
|
22
|
+
return {
|
|
23
|
+
codec: (0, ImportGroup_1.ImportGroup)(field),
|
|
24
|
+
result: (0, ImportGroup_1.ImportGroup)(field).decode(content),
|
|
25
|
+
};
|
|
26
|
+
case "Choice":
|
|
22
27
|
throw new Error(`Unsupported type of field ${field.type}`);
|
|
23
28
|
default:
|
|
24
29
|
return nestable_1.ImportNestable.decode(field)(content);
|