@prismicio/types-internal 3.11.2 → 3.12.0-alpha.1
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/CHANGELOG.md +764 -0
- package/lib/content/Document.d.ts +32 -7
- package/lib/content/Document.js +22 -8
- package/lib/content/LegacyContentCtx.d.ts +25 -3
- package/lib/content/LegacyContentCtx.js +67 -5
- package/lib/content/fields/GroupContent.d.ts +4 -2
- package/lib/content/fields/GroupContent.js +40 -17
- package/lib/content/fields/UIDContent.js +1 -0
- package/lib/content/fields/WidgetContent.d.ts +6 -0
- package/lib/content/fields/nestable/BooleanContent.js +1 -0
- package/lib/content/fields/nestable/EmbedContent.js +1 -0
- package/lib/content/fields/nestable/FieldContent/ColorContent.js +1 -0
- package/lib/content/fields/nestable/FieldContent/DateContent.js +1 -0
- package/lib/content/fields/nestable/FieldContent/NumberContent.js +1 -0
- package/lib/content/fields/nestable/FieldContent/RangeContent.js +1 -0
- package/lib/content/fields/nestable/FieldContent/SelectContent.js +1 -0
- package/lib/content/fields/nestable/FieldContent/TextContent.js +1 -0
- package/lib/content/fields/nestable/FieldContent/TimestampContent.js +1 -0
- package/lib/content/fields/nestable/GeoPointContent.js +1 -0
- package/lib/content/fields/nestable/ImageContent.js +1 -0
- package/lib/content/fields/nestable/IntegrationFieldContent.js +1 -0
- package/lib/content/fields/nestable/LinkContent.js +2 -0
- package/lib/content/fields/nestable/RepeatableContent.js +1 -0
- package/lib/content/fields/nestable/RichTextContent/index.js +1 -0
- package/lib/content/fields/nestable/SeparatorContent.js +1 -0
- package/lib/content/fields/nestable/TableContent.js +1 -0
- package/lib/content/fields/slices/Slice/CompositeSliceContent.d.ts +3 -0
- package/lib/content/fields/slices/Slice/CompositeSliceContent.js +19 -5
- package/lib/content/fields/slices/Slice/RepeatableContent.d.ts +5 -4
- package/lib/content/fields/slices/Slice/RepeatableContent.js +2 -1
- package/lib/content/fields/slices/Slice/SharedSliceContent.d.ts +3 -0
- package/lib/content/fields/slices/Slice/SharedSliceContent.js +26 -19
- package/lib/content/fields/slices/Slice/SimpleSliceContent.js +1 -0
- package/lib/content/fields/slices/Slice/index.d.ts +4 -0
- package/lib/content/fields/slices/SliceItem.d.ts +12 -0
- package/lib/content/fields/slices/SliceItem.js +11 -2
- package/lib/content/fields/slices/SlicesContent.d.ts +6 -0
- package/lib/content/fields/slices/SlicesContent.js +1 -0
- package/lib/customtypes/CustomType.js +6 -9
- package/lib/customtypes/Section.js +3 -8
- package/lib/customtypes/widgets/Group.js +20 -20
- package/lib/customtypes/widgets/nestable/NestableWidgetZ.d.ts +3 -0
- package/lib/customtypes/widgets/nestable/NestableWidgetZ.js +29 -0
- package/lib/customtypes/widgets/slices/CompositeSlice.js +9 -22
- package/lib/customtypes/widgets/slices/SharedSlice.js +18 -37
- package/lib/customtypes/widgets/slices/SharedSliceZ.d.ts +16 -0
- package/lib/customtypes/widgets/slices/SharedSliceZ.js +39 -0
- package/lib/customtypes/widgets/slices/SlicePrimaryWidgetZ.d.ts +3 -0
- package/lib/customtypes/widgets/slices/SlicePrimaryWidgetZ.js +6 -0
- package/lib/customtypes/widgets/slices/Slices.js +9 -16
- package/package.json +1 -1
- package/src/content/Document.ts +31 -8
- package/src/content/LegacyContentCtx.ts +72 -16
- package/src/content/fields/GroupContent.ts +58 -16
- package/src/content/fields/UIDContent.ts +1 -0
- package/src/content/fields/nestable/BooleanContent.ts +1 -0
- package/src/content/fields/nestable/EmbedContent.ts +1 -0
- package/src/content/fields/nestable/FieldContent/ColorContent.ts +1 -0
- package/src/content/fields/nestable/FieldContent/DateContent.ts +1 -0
- package/src/content/fields/nestable/FieldContent/NumberContent.ts +1 -0
- package/src/content/fields/nestable/FieldContent/RangeContent.ts +1 -0
- package/src/content/fields/nestable/FieldContent/SelectContent.ts +1 -0
- package/src/content/fields/nestable/FieldContent/TextContent.ts +1 -0
- package/src/content/fields/nestable/FieldContent/TimestampContent.ts +1 -0
- package/src/content/fields/nestable/GeoPointContent.ts +1 -0
- package/src/content/fields/nestable/ImageContent.ts +1 -0
- package/src/content/fields/nestable/IntegrationFieldContent.ts +1 -0
- package/src/content/fields/nestable/LinkContent.ts +2 -0
- package/src/content/fields/nestable/RepeatableContent.ts +4 -0
- package/src/content/fields/nestable/RichTextContent/index.ts +1 -0
- package/src/content/fields/nestable/SeparatorContent.ts +1 -0
- package/src/content/fields/nestable/TableContent.ts +1 -0
- package/src/content/fields/slices/Slice/CompositeSliceContent.ts +19 -5
- package/src/content/fields/slices/Slice/RepeatableContent.ts +7 -2
- package/src/content/fields/slices/Slice/SharedSliceContent.ts +26 -19
- package/src/content/fields/slices/Slice/SimpleSliceContent.ts +1 -0
- package/src/content/fields/slices/SliceItem.ts +12 -3
- package/src/content/fields/slices/SlicesContent.ts +4 -1
- package/src/customtypes/CustomType.ts +6 -9
- package/src/customtypes/Section.ts +3 -9
- package/src/customtypes/widgets/Group.ts +20 -21
- package/src/customtypes/widgets/slices/CompositeSlice.ts +9 -22
- package/src/customtypes/widgets/slices/SharedSlice.ts +23 -38
- package/src/customtypes/widgets/slices/Slices.ts +9 -15
- package/lib/content/fields/RepeatableContent.d.ts +0 -162
- package/lib/content/fields/RepeatableContent.js +0 -93
- package/lib/content/fields/nestable/RichTextContent/TextBlock.d.ts +0 -727
- package/lib/content/fields/nestable/RichTextContent/TextBlock.js +0 -80
- package/lib/customtypes/widgets/slices/SliceWidget.d.ts +0 -327
- package/lib/customtypes/widgets/slices/SliceWidget.js +0 -8
|
@@ -20,6 +20,7 @@ const GeoPointLegacy = (ctx) => new t.Type("GeoPointLegacy", exports.isGeoPointC
|
|
|
20
20
|
}, (geo) => ({
|
|
21
21
|
content: { position: geo.position },
|
|
22
22
|
types: { [ctx.keyOfType]: "GeoPoint" },
|
|
23
|
+
keys: {},
|
|
23
24
|
}));
|
|
24
25
|
exports.GeoPointLegacy = GeoPointLegacy;
|
|
25
26
|
exports.GeoPointContent = t.intersection([
|
|
@@ -342,6 +342,7 @@ const LinkContentLegacy = (ctx) => new t.Type("LinkLegacy", exports.isLinkConten
|
|
|
342
342
|
key,
|
|
343
343
|
}),
|
|
344
344
|
types: { [ctx.keyOfType]: "Link" },
|
|
345
|
+
keys: {},
|
|
345
346
|
};
|
|
346
347
|
});
|
|
347
348
|
exports.LinkContentLegacy = LinkContentLegacy;
|
|
@@ -381,6 +382,7 @@ const FilledLinkContentLegacy = (ctx) => {
|
|
|
381
382
|
key,
|
|
382
383
|
}),
|
|
383
384
|
types: { [ctx.keyOfType]: "Link" },
|
|
385
|
+
keys: {},
|
|
384
386
|
};
|
|
385
387
|
});
|
|
386
388
|
};
|
|
@@ -55,6 +55,7 @@ const RepeatableLegacy = (ctx, fieldType) => {
|
|
|
55
55
|
return {
|
|
56
56
|
content: encodedItems.map((encodedItem) => encodedItem.content),
|
|
57
57
|
types: { [ctx.keyOfType]: `Repeatable.${fieldType}` },
|
|
58
|
+
keys: encodedItems.reduce((acc, item) => ({ ...acc, ...item.keys }), {}),
|
|
58
59
|
};
|
|
59
60
|
});
|
|
60
61
|
};
|
|
@@ -22,6 +22,7 @@ const RichTextLegacy = (ctx) => new t.Type("RichTextLegacy", exports.isRichTextC
|
|
|
22
22
|
return {
|
|
23
23
|
content: exports.RichTextLegacyContent.encode(r.value),
|
|
24
24
|
types: { [ctx.keyOfType]: "StructuredText" },
|
|
25
|
+
keys: {},
|
|
25
26
|
};
|
|
26
27
|
});
|
|
27
28
|
exports.RichTextLegacy = RichTextLegacy;
|
|
@@ -600,6 +600,7 @@ export declare const isCompositeSliceContent: (u: unknown) => u is {
|
|
|
600
600
|
};
|
|
601
601
|
repeat: {
|
|
602
602
|
__TYPE__: "GroupItemContent";
|
|
603
|
+
key: string;
|
|
603
604
|
value: [string, {
|
|
604
605
|
type: string;
|
|
605
606
|
__TYPE__: "EmptyContent";
|
|
@@ -1788,6 +1789,7 @@ export declare const CompositeSliceLegacy: (ctx: LegacyContentCtx) => t.Type<{
|
|
|
1788
1789
|
};
|
|
1789
1790
|
repeat: {
|
|
1790
1791
|
__TYPE__: "GroupItemContent";
|
|
1792
|
+
key: string;
|
|
1791
1793
|
value: [string, {
|
|
1792
1794
|
type: string;
|
|
1793
1795
|
__TYPE__: "EmptyContent";
|
|
@@ -3153,6 +3155,7 @@ export declare const CompositeSliceContent: t.ExactC<t.TypeC<{
|
|
|
3153
3155
|
}>>]>>;
|
|
3154
3156
|
repeat: t.ArrayC<t.ExactC<t.TypeC<{
|
|
3155
3157
|
__TYPE__: t.LiteralC<"GroupItemContent">;
|
|
3158
|
+
key: t.StringC;
|
|
3156
3159
|
value: t.ArrayC<t.TupleC<[t.StringC, t.UnionC<[t.UnionC<[t.ExactC<t.TypeC<{
|
|
3157
3160
|
type: t.StringC;
|
|
3158
3161
|
__TYPE__: t.LiteralC<"EmptyContent">;
|
|
@@ -23,14 +23,18 @@ const CompositeSliceLegacy = (ctx) => {
|
|
|
23
23
|
return new t.Type("CompositeSliceLegacy", exports.isCompositeSliceContent, (slice) => {
|
|
24
24
|
return (0, function_1.pipe)(legacyReader.decode(slice), fp_ts_1.either.map((parsedSlice) => {
|
|
25
25
|
const repeat = (() => {
|
|
26
|
-
const itemsCtx = (0, LegacyContentCtx_1.getFieldCtx)("repeat", ctx);
|
|
26
|
+
const itemsCtx = (0, LegacyContentCtx_1.getFieldCtx)({ fieldKey: "repeat", ctx });
|
|
27
27
|
const result = (0, RepeatableContent_1.RepeatableWidgetsLegacy)(itemsCtx).decode(parsedSlice.repeat);
|
|
28
28
|
if (!result || (0, Either_1.isLeft)(result))
|
|
29
29
|
return;
|
|
30
30
|
return result.right;
|
|
31
31
|
})() || [];
|
|
32
32
|
const nonRepeat = Object.entries(parsedSlice["non-repeat"] || {}).reduce((acc, [key, value]) => {
|
|
33
|
-
const fieldCtx = (0, LegacyContentCtx_1.getFieldCtx)(
|
|
33
|
+
const fieldCtx = (0, LegacyContentCtx_1.getFieldCtx)({
|
|
34
|
+
fieldKey: key,
|
|
35
|
+
ctx,
|
|
36
|
+
prefixes: ["non-repeat"],
|
|
37
|
+
});
|
|
34
38
|
if (!fieldCtx)
|
|
35
39
|
return acc;
|
|
36
40
|
const result = (0, nestable_1.NestableLegacy)(fieldCtx).decode(value);
|
|
@@ -48,17 +52,22 @@ const CompositeSliceLegacy = (ctx) => {
|
|
|
48
52
|
}));
|
|
49
53
|
}, (s) => {
|
|
50
54
|
const nonRepeat = Object.entries(s.nonRepeat).reduce((acc, [key, value]) => {
|
|
51
|
-
const FieldCtx = (0, LegacyContentCtx_1.getFieldCtx)(
|
|
55
|
+
const FieldCtx = (0, LegacyContentCtx_1.getFieldCtx)({
|
|
56
|
+
fieldKey: key,
|
|
57
|
+
ctx,
|
|
58
|
+
prefixes: ["non-repeat"],
|
|
59
|
+
});
|
|
52
60
|
const result = (0, nestable_1.NestableLegacy)(FieldCtx).encode(value);
|
|
53
61
|
if (!result)
|
|
54
62
|
return acc;
|
|
55
63
|
return {
|
|
56
64
|
content: { ...acc.content, [key]: result.content },
|
|
57
65
|
types: { ...acc.types, ...result.types },
|
|
66
|
+
keys: { ...acc.keys, ...result.keys },
|
|
58
67
|
};
|
|
59
|
-
}, { content: {}, types: {} });
|
|
68
|
+
}, { content: {}, types: {}, keys: {} });
|
|
60
69
|
const repeat = (() => {
|
|
61
|
-
const itemsCtx = (0, LegacyContentCtx_1.getFieldCtx)("repeat", ctx);
|
|
70
|
+
const itemsCtx = (0, LegacyContentCtx_1.getFieldCtx)({ fieldKey: "repeat", ctx });
|
|
62
71
|
const result = (0, RepeatableContent_1.RepeatableWidgetsLegacy)(itemsCtx).encode(s.repeat);
|
|
63
72
|
return result;
|
|
64
73
|
})() || [];
|
|
@@ -72,6 +81,10 @@ const CompositeSliceLegacy = (ctx) => {
|
|
|
72
81
|
...nonRepeat.types,
|
|
73
82
|
...repeat.reduce((acc, i) => ({ ...acc, ...i.types }), {}),
|
|
74
83
|
},
|
|
84
|
+
keys: {
|
|
85
|
+
...nonRepeat.keys,
|
|
86
|
+
...repeat.reduce((acc, i) => ({ ...acc, ...i.keys }), {}),
|
|
87
|
+
},
|
|
75
88
|
};
|
|
76
89
|
});
|
|
77
90
|
};
|
|
@@ -165,6 +178,7 @@ function migrateCompositeSlice(model, content) {
|
|
|
165
178
|
items: content.widget.repeat.map((groupItem) => {
|
|
166
179
|
return {
|
|
167
180
|
__TYPE__: "GroupItemContent",
|
|
181
|
+
key: groupItem.key,
|
|
168
182
|
value: groupItem.value.reduce((acc, [fieldKey, fieldContent]) => {
|
|
169
183
|
var _a;
|
|
170
184
|
if (!((_a = model.fields.items) === null || _a === void 0 ? void 0 : _a[fieldKey])) {
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import * as t from "io-ts";
|
|
2
|
-
import type { LegacyContentCtx } from "../../../LegacyContentCtx";
|
|
3
|
-
import { GroupContent } from "../../GroupContent";
|
|
4
|
-
export declare const RepeatableWidgetsLegacy: (ctx: LegacyContentCtx) => t.
|
|
2
|
+
import type { LegacyContentCtx, WithTypes } from "../../../LegacyContentCtx";
|
|
3
|
+
import { GroupContent, GroupItemContent } from "../../GroupContent";
|
|
4
|
+
export declare const RepeatableWidgetsLegacy: (ctx: LegacyContentCtx) => t.Type<GroupItemContent[], WithTypes<{
|
|
5
5
|
[x: string]: unknown;
|
|
6
|
-
}
|
|
6
|
+
}>[], unknown>;
|
|
7
7
|
export declare const RepeatableWidgets: t.ArrayC<t.ExactC<t.TypeC<{
|
|
8
8
|
__TYPE__: t.LiteralC<"GroupItemContent">;
|
|
9
|
+
key: t.StringC;
|
|
9
10
|
value: t.ArrayC<t.TupleC<[t.StringC, t.UnionC<[t.UnionC<[t.ExactC<t.TypeC<{
|
|
10
11
|
type: t.StringC;
|
|
11
12
|
__TYPE__: t.LiteralC<"EmptyContent">;
|
|
@@ -6,7 +6,7 @@ const t = (0, tslib_1.__importStar)(require("io-ts"));
|
|
|
6
6
|
const GroupContent_1 = require("../../GroupContent");
|
|
7
7
|
const nestable_1 = require("../../nestable");
|
|
8
8
|
const RepeatableWidgetsLegacy = (ctx) => {
|
|
9
|
-
return
|
|
9
|
+
return (0, GroupContent_1.arrayWithIndexCodec)((index) => (0, GroupContent_1.GroupItemLegacy)(ctx, index));
|
|
10
10
|
};
|
|
11
11
|
exports.RepeatableWidgetsLegacy = RepeatableWidgetsLegacy;
|
|
12
12
|
const RepeatableWidget = t.tuple([
|
|
@@ -15,6 +15,7 @@ const RepeatableWidget = t.tuple([
|
|
|
15
15
|
]);
|
|
16
16
|
const RepeatableWidgetsBlock = t.strict({
|
|
17
17
|
__TYPE__: t.literal(GroupContent_1.GroupItemContentType),
|
|
18
|
+
key: t.string,
|
|
18
19
|
value: t.array(RepeatableWidget),
|
|
19
20
|
});
|
|
20
21
|
exports.RepeatableWidgets = t.array(RepeatableWidgetsBlock);
|
|
@@ -601,6 +601,7 @@ export declare const isSharedSliceContent: (u: unknown) => u is {
|
|
|
601
601
|
};
|
|
602
602
|
items: {
|
|
603
603
|
__TYPE__: "GroupItemContent";
|
|
604
|
+
key: string;
|
|
604
605
|
value: [string, {
|
|
605
606
|
type: string;
|
|
606
607
|
__TYPE__: "EmptyContent";
|
|
@@ -1790,6 +1791,7 @@ export declare const SharedSliceLegacy: (ctx: LegacyContentCtx) => t.Type<{
|
|
|
1790
1791
|
};
|
|
1791
1792
|
items: {
|
|
1792
1793
|
__TYPE__: "GroupItemContent";
|
|
1794
|
+
key: string;
|
|
1793
1795
|
value: [string, {
|
|
1794
1796
|
type: string;
|
|
1795
1797
|
__TYPE__: "EmptyContent";
|
|
@@ -3157,6 +3159,7 @@ export declare const SharedSliceContent: t.ExactC<t.TypeC<{
|
|
|
3157
3159
|
}>>]>, t.Type<import("../../GroupContent").GroupContent, import("../../GroupContent").GroupContent, unknown>]>>;
|
|
3158
3160
|
items: t.ArrayC<t.ExactC<t.TypeC<{
|
|
3159
3161
|
__TYPE__: t.LiteralC<"GroupItemContent">;
|
|
3162
|
+
key: t.StringC;
|
|
3160
3163
|
value: t.ArrayC<t.TupleC<[t.StringC, t.UnionC<[t.UnionC<[t.ExactC<t.TypeC<{
|
|
3161
3164
|
type: t.StringC;
|
|
3162
3165
|
__TYPE__: t.LiteralC<"EmptyContent">;
|
|
@@ -27,21 +27,22 @@ const SharedSliceLegacy = (ctx) => {
|
|
|
27
27
|
return new t.Type("SharedSliceLegacy", exports.isSharedSliceContent, (slice) => {
|
|
28
28
|
return (0, function_1.pipe)(legacyReader.decode(slice), fp_ts_1.either.map((parsedSlice) => {
|
|
29
29
|
const items = (() => {
|
|
30
|
-
const itemsCtx = (0, LegacyContentCtx_1.getFieldCtx)(
|
|
31
|
-
"
|
|
32
|
-
|
|
33
|
-
|
|
30
|
+
const itemsCtx = (0, LegacyContentCtx_1.getFieldCtx)({
|
|
31
|
+
fieldKey: "items",
|
|
32
|
+
ctx,
|
|
33
|
+
prefixes: ["variations", parsedSlice.variation],
|
|
34
|
+
});
|
|
34
35
|
const result = (0, RepeatableContent_1.RepeatableWidgetsLegacy)(itemsCtx).decode(parsedSlice.items);
|
|
35
36
|
if (!result || (0, Either_1.isLeft)(result))
|
|
36
37
|
return;
|
|
37
38
|
return result.right;
|
|
38
39
|
})() || [];
|
|
39
40
|
const primary = Object.entries(parsedSlice.primary).reduce((acc, [key, value]) => {
|
|
40
|
-
const FieldCtx = (0, LegacyContentCtx_1.getFieldCtx)(
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
"primary",
|
|
44
|
-
|
|
41
|
+
const FieldCtx = (0, LegacyContentCtx_1.getFieldCtx)({
|
|
42
|
+
fieldKey: key,
|
|
43
|
+
ctx,
|
|
44
|
+
prefixes: ["variations", parsedSlice.variation, "primary"],
|
|
45
|
+
});
|
|
45
46
|
const result = (0, SlicePrimaryContent_1.SlicePrimaryLegacy)(FieldCtx).decode(value);
|
|
46
47
|
if (!result)
|
|
47
48
|
return acc;
|
|
@@ -58,24 +59,26 @@ const SharedSliceLegacy = (ctx) => {
|
|
|
58
59
|
}));
|
|
59
60
|
}, (s) => {
|
|
60
61
|
const primary = Object.entries(s.primary).reduce((acc, [key, value]) => {
|
|
61
|
-
const FieldCtx = (0, LegacyContentCtx_1.getFieldCtx)(
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
"primary",
|
|
65
|
-
|
|
62
|
+
const FieldCtx = (0, LegacyContentCtx_1.getFieldCtx)({
|
|
63
|
+
fieldKey: key,
|
|
64
|
+
ctx,
|
|
65
|
+
prefixes: ["variations", s.variation, "primary"],
|
|
66
|
+
});
|
|
66
67
|
const result = (0, SlicePrimaryContent_1.SlicePrimaryLegacy)(FieldCtx).encode(value);
|
|
67
68
|
if (!result)
|
|
68
69
|
return acc;
|
|
69
70
|
return {
|
|
70
71
|
content: { ...acc.content, [key]: result.content },
|
|
71
72
|
types: { ...acc.types, ...result.types },
|
|
73
|
+
keys: { ...acc.keys, ...result.keys },
|
|
72
74
|
};
|
|
73
|
-
}, { content: {}, types: {} });
|
|
75
|
+
}, { content: {}, types: {}, keys: {} });
|
|
74
76
|
const items = (() => {
|
|
75
|
-
const itemsCtx = (0, LegacyContentCtx_1.getFieldCtx)(
|
|
76
|
-
"
|
|
77
|
-
|
|
78
|
-
|
|
77
|
+
const itemsCtx = (0, LegacyContentCtx_1.getFieldCtx)({
|
|
78
|
+
fieldKey: "items",
|
|
79
|
+
ctx,
|
|
80
|
+
prefixes: ["variations", s.variation],
|
|
81
|
+
});
|
|
79
82
|
const result = (0, RepeatableContent_1.RepeatableWidgetsLegacy)(itemsCtx).encode(s.items);
|
|
80
83
|
return result;
|
|
81
84
|
})() || [];
|
|
@@ -90,6 +93,10 @@ const SharedSliceLegacy = (ctx) => {
|
|
|
90
93
|
...primary.types,
|
|
91
94
|
...items.reduce((acc, i) => ({ ...acc, ...i.types }), {}),
|
|
92
95
|
},
|
|
96
|
+
keys: {
|
|
97
|
+
...primary.keys,
|
|
98
|
+
...items.reduce((acc, i) => ({ ...acc, ...i.keys }), {}),
|
|
99
|
+
},
|
|
93
100
|
};
|
|
94
101
|
});
|
|
95
102
|
};
|
|
@@ -101,6 +101,7 @@ function migrateSimpleSlice(model, content) {
|
|
|
101
101
|
items: content.widget.value.map((groupItem) => {
|
|
102
102
|
return {
|
|
103
103
|
__TYPE__: "GroupItemContent",
|
|
104
|
+
key: groupItem.key,
|
|
104
105
|
value: groupItem.value.reduce((acc, [fieldKey, fieldContent]) => {
|
|
105
106
|
var _a;
|
|
106
107
|
return ((_a = model.fields.items) === null || _a === void 0 ? void 0 : _a[fieldKey])
|
|
@@ -1186,6 +1186,7 @@ export declare const SliceLegacy: (ctx: LegacyContentCtx) => {
|
|
|
1186
1186
|
};
|
|
1187
1187
|
repeat: {
|
|
1188
1188
|
__TYPE__: "GroupItemContent";
|
|
1189
|
+
key: string;
|
|
1189
1190
|
value: [string, {
|
|
1190
1191
|
type: string;
|
|
1191
1192
|
__TYPE__: "EmptyContent";
|
|
@@ -2374,6 +2375,7 @@ export declare const SliceLegacy: (ctx: LegacyContentCtx) => {
|
|
|
2374
2375
|
};
|
|
2375
2376
|
items: {
|
|
2376
2377
|
__TYPE__: "GroupItemContent";
|
|
2378
|
+
key: string;
|
|
2377
2379
|
value: [string, {
|
|
2378
2380
|
type: string;
|
|
2379
2381
|
__TYPE__: "EmptyContent";
|
|
@@ -3736,6 +3738,7 @@ export declare const SliceContent: t.UnionC<[t.ExactC<t.TypeC<{
|
|
|
3736
3738
|
}>>]>>;
|
|
3737
3739
|
repeat: t.ArrayC<t.ExactC<t.TypeC<{
|
|
3738
3740
|
__TYPE__: t.LiteralC<"GroupItemContent">;
|
|
3741
|
+
key: t.StringC;
|
|
3739
3742
|
value: t.ArrayC<t.TupleC<[t.StringC, t.UnionC<[t.UnionC<[t.ExactC<t.TypeC<{
|
|
3740
3743
|
type: t.StringC;
|
|
3741
3744
|
__TYPE__: t.LiteralC<"EmptyContent">;
|
|
@@ -5270,6 +5273,7 @@ export declare const SliceContent: t.UnionC<[t.ExactC<t.TypeC<{
|
|
|
5270
5273
|
}>>]>, t.Type<import("../..").GroupContent, import("../..").GroupContent, unknown>]>>;
|
|
5271
5274
|
items: t.ArrayC<t.ExactC<t.TypeC<{
|
|
5272
5275
|
__TYPE__: t.LiteralC<"GroupItemContent">;
|
|
5276
|
+
key: t.StringC;
|
|
5273
5277
|
value: t.ArrayC<t.TupleC<[t.StringC, t.UnionC<[t.UnionC<[t.ExactC<t.TypeC<{
|
|
5274
5278
|
type: t.StringC;
|
|
5275
5279
|
__TYPE__: t.LiteralC<"EmptyContent">;
|
|
@@ -778,6 +778,7 @@ export declare const SliceItemContent: t.TypeC<{
|
|
|
778
778
|
}>>]>>;
|
|
779
779
|
repeat: t.ArrayC<t.ExactC<t.TypeC<{
|
|
780
780
|
__TYPE__: t.LiteralC<"GroupItemContent">;
|
|
781
|
+
key: t.StringC;
|
|
781
782
|
value: t.ArrayC<t.TupleC<[t.StringC, t.UnionC<[t.UnionC<[t.ExactC<t.TypeC<{
|
|
782
783
|
type: t.StringC;
|
|
783
784
|
__TYPE__: t.LiteralC<"EmptyContent">;
|
|
@@ -2312,6 +2313,7 @@ export declare const SliceItemContent: t.TypeC<{
|
|
|
2312
2313
|
}>>]>, t.Type<import("../GroupContent").GroupContent, import("../GroupContent").GroupContent, unknown>]>>;
|
|
2313
2314
|
items: t.ArrayC<t.ExactC<t.TypeC<{
|
|
2314
2315
|
__TYPE__: t.LiteralC<"GroupItemContent">;
|
|
2316
|
+
key: t.StringC;
|
|
2315
2317
|
value: t.ArrayC<t.TupleC<[t.StringC, t.UnionC<[t.UnionC<[t.ExactC<t.TypeC<{
|
|
2316
2318
|
type: t.StringC;
|
|
2317
2319
|
__TYPE__: t.LiteralC<"EmptyContent">;
|
|
@@ -3856,6 +3858,13 @@ export declare type SimpleSliceItemContent = Omit<SliceItemContent, "widget"> &
|
|
|
3856
3858
|
};
|
|
3857
3859
|
export declare function isSimpleSliceItemContent(item: SliceItemContent): item is SimpleSliceItemContent;
|
|
3858
3860
|
export declare function sliceItemContentWithDefaultValues(customType: StaticSlice, content: SliceContent): SliceContent;
|
|
3861
|
+
declare const itemLegacyReader: t.ExactC<t.IntersectionC<[t.TypeC<{
|
|
3862
|
+
key: t.StringC;
|
|
3863
|
+
value: t.UnknownC;
|
|
3864
|
+
}>, t.PartialC<{
|
|
3865
|
+
label: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
|
|
3866
|
+
}>]>>;
|
|
3867
|
+
export declare type SliceItemLegacy = t.TypeOf<typeof itemLegacyReader>;
|
|
3859
3868
|
export declare const SlicesItemLegacy: (ctx: LegacyContentCtx) => t.Type<{
|
|
3860
3869
|
key: string;
|
|
3861
3870
|
name: string;
|
|
@@ -5045,6 +5054,7 @@ export declare const SlicesItemLegacy: (ctx: LegacyContentCtx) => t.Type<{
|
|
|
5045
5054
|
};
|
|
5046
5055
|
repeat: {
|
|
5047
5056
|
__TYPE__: "GroupItemContent";
|
|
5057
|
+
key: string;
|
|
5048
5058
|
value: [string, {
|
|
5049
5059
|
type: string;
|
|
5050
5060
|
__TYPE__: "EmptyContent";
|
|
@@ -6233,6 +6243,7 @@ export declare const SlicesItemLegacy: (ctx: LegacyContentCtx) => t.Type<{
|
|
|
6233
6243
|
};
|
|
6234
6244
|
items: {
|
|
6235
6245
|
__TYPE__: "GroupItemContent";
|
|
6246
|
+
key: string;
|
|
6236
6247
|
value: [string, {
|
|
6237
6248
|
type: string;
|
|
6238
6249
|
__TYPE__: "EmptyContent";
|
|
@@ -6832,3 +6843,4 @@ export declare const SlicesItemLegacy: (ctx: LegacyContentCtx) => t.Type<{
|
|
|
6832
6843
|
label?: string | null | undefined;
|
|
6833
6844
|
}>, unknown>;
|
|
6834
6845
|
export declare const migrateSliceItem: TraverseSliceContentFn;
|
|
6846
|
+
export {};
|
|
@@ -72,7 +72,11 @@ const SlicesItemLegacy = (ctx) => {
|
|
|
72
72
|
var _a;
|
|
73
73
|
const stopIdx = parsedSlice.key.indexOf("$");
|
|
74
74
|
const sliceName = parsedSlice.key.substring(0, stopIdx > 0 ? stopIdx : undefined);
|
|
75
|
-
const itemCtx = (0, LegacyContentCtx_1.getFieldCtx)(
|
|
75
|
+
const itemCtx = (0, LegacyContentCtx_1.getFieldCtx)({
|
|
76
|
+
fieldKey: sliceName,
|
|
77
|
+
contentKey: parsedSlice.key,
|
|
78
|
+
ctx,
|
|
79
|
+
});
|
|
76
80
|
const item = (0, Slice_1.SliceLegacy)(itemCtx).decode(parsedSlice.value);
|
|
77
81
|
if (!item || (0, Either_1.isLeft)(item))
|
|
78
82
|
return t.failure(sliceItem, context);
|
|
@@ -84,7 +88,11 @@ const SlicesItemLegacy = (ctx) => {
|
|
|
84
88
|
});
|
|
85
89
|
}));
|
|
86
90
|
}, (sItem) => {
|
|
87
|
-
const itemCtx = (0, LegacyContentCtx_1.getFieldCtx)(
|
|
91
|
+
const itemCtx = (0, LegacyContentCtx_1.getFieldCtx)({
|
|
92
|
+
fieldKey: sItem.name,
|
|
93
|
+
contentKey: sItem.key,
|
|
94
|
+
ctx,
|
|
95
|
+
});
|
|
88
96
|
const result = (0, Slice_1.SliceLegacy)(itemCtx).encode(sItem.widget);
|
|
89
97
|
return {
|
|
90
98
|
content: {
|
|
@@ -93,6 +101,7 @@ const SlicesItemLegacy = (ctx) => {
|
|
|
93
101
|
value: (result === null || result === void 0 ? void 0 : result.content) || {},
|
|
94
102
|
},
|
|
95
103
|
types: (result === null || result === void 0 ? void 0 : result.types) || {},
|
|
104
|
+
keys: (result === null || result === void 0 ? void 0 : result.keys) || {},
|
|
96
105
|
};
|
|
97
106
|
});
|
|
98
107
|
};
|
|
@@ -1194,6 +1194,7 @@ export declare const isSlicesContent: (u: unknown) => u is {
|
|
|
1194
1194
|
};
|
|
1195
1195
|
repeat: {
|
|
1196
1196
|
__TYPE__: "GroupItemContent";
|
|
1197
|
+
key: string;
|
|
1197
1198
|
value: [string, {
|
|
1198
1199
|
type: string;
|
|
1199
1200
|
__TYPE__: "EmptyContent";
|
|
@@ -2382,6 +2383,7 @@ export declare const isSlicesContent: (u: unknown) => u is {
|
|
|
2382
2383
|
};
|
|
2383
2384
|
items: {
|
|
2384
2385
|
__TYPE__: "GroupItemContent";
|
|
2386
|
+
key: string;
|
|
2385
2387
|
value: [string, {
|
|
2386
2388
|
type: string;
|
|
2387
2389
|
__TYPE__: "EmptyContent";
|
|
@@ -4168,6 +4170,7 @@ export declare const SlicesLegacy: (ctx: LegacyContentCtx) => t.Type<{
|
|
|
4168
4170
|
};
|
|
4169
4171
|
repeat: {
|
|
4170
4172
|
__TYPE__: "GroupItemContent";
|
|
4173
|
+
key: string;
|
|
4171
4174
|
value: [string, {
|
|
4172
4175
|
type: string;
|
|
4173
4176
|
__TYPE__: "EmptyContent";
|
|
@@ -5356,6 +5359,7 @@ export declare const SlicesLegacy: (ctx: LegacyContentCtx) => t.Type<{
|
|
|
5356
5359
|
};
|
|
5357
5360
|
items: {
|
|
5358
5361
|
__TYPE__: "GroupItemContent";
|
|
5362
|
+
key: string;
|
|
5359
5363
|
value: [string, {
|
|
5360
5364
|
type: string;
|
|
5361
5365
|
__TYPE__: "EmptyContent";
|
|
@@ -6724,6 +6728,7 @@ export declare const SlicesContent: t.TypeC<{
|
|
|
6724
6728
|
}>>]>>;
|
|
6725
6729
|
repeat: t.ArrayC<t.ExactC<t.TypeC<{
|
|
6726
6730
|
__TYPE__: t.LiteralC<"GroupItemContent">;
|
|
6731
|
+
key: t.StringC;
|
|
6727
6732
|
value: t.ArrayC<t.TupleC<[t.StringC, t.UnionC<[t.UnionC<[t.ExactC<t.TypeC<{
|
|
6728
6733
|
type: t.StringC;
|
|
6729
6734
|
__TYPE__: t.LiteralC<"EmptyContent">;
|
|
@@ -8258,6 +8263,7 @@ export declare const SlicesContent: t.TypeC<{
|
|
|
8258
8263
|
}>>]>, t.Type<import("..").GroupContent, import("..").GroupContent, unknown>]>>;
|
|
8259
8264
|
items: t.ArrayC<t.ExactC<t.TypeC<{
|
|
8260
8265
|
__TYPE__: t.LiteralC<"GroupItemContent">;
|
|
8266
|
+
key: t.StringC;
|
|
8261
8267
|
value: t.ArrayC<t.TupleC<[t.StringC, t.UnionC<[t.UnionC<[t.ExactC<t.TypeC<{
|
|
8262
8268
|
type: t.StringC;
|
|
8263
8269
|
__TYPE__: t.LiteralC<"EmptyContent">;
|
|
@@ -29,6 +29,7 @@ const SlicesLegacy = (ctx) => {
|
|
|
29
29
|
return {
|
|
30
30
|
content: result.map((s) => s.content),
|
|
31
31
|
types: result.reduce((acc, s) => ({ ...acc, ...s.types }), { [ctx.keyOfType]: "Slices" }),
|
|
32
|
+
keys: result.reduce((acc, s) => ({ ...acc, ...s.keys }), {}),
|
|
32
33
|
};
|
|
33
34
|
});
|
|
34
35
|
};
|
|
@@ -165,20 +165,17 @@ function collectSharedSlices(customType) {
|
|
|
165
165
|
exports.collectSharedSlices = collectSharedSlices;
|
|
166
166
|
function traverseCustomType(args) {
|
|
167
167
|
const { customType, onField } = args;
|
|
168
|
-
|
|
168
|
+
const json = {};
|
|
169
169
|
for (const [key, section] of Object.entries(customType.json)) {
|
|
170
|
-
|
|
170
|
+
json[key] = (0, Section_1.traverseSection)({
|
|
171
171
|
path: [key],
|
|
172
172
|
section,
|
|
173
173
|
onField,
|
|
174
174
|
});
|
|
175
|
-
if (newSection !== section) {
|
|
176
|
-
if (!json)
|
|
177
|
-
json = { ...customType.json };
|
|
178
|
-
json[key] = newSection;
|
|
179
|
-
}
|
|
180
175
|
}
|
|
181
|
-
|
|
182
|
-
|
|
176
|
+
return {
|
|
177
|
+
...customType,
|
|
178
|
+
json,
|
|
179
|
+
};
|
|
183
180
|
}
|
|
184
181
|
exports.traverseCustomType = traverseCustomType;
|
|
@@ -22,7 +22,7 @@ exports.Sections = {
|
|
|
22
22
|
};
|
|
23
23
|
function traverseSection(args) {
|
|
24
24
|
const { path: prevPath, section: prevSection, onField } = args;
|
|
25
|
-
|
|
25
|
+
const section = { ...prevSection };
|
|
26
26
|
for (const [key, prevModel] of Object.entries(prevSection)) {
|
|
27
27
|
const path = [...prevPath, key];
|
|
28
28
|
let model;
|
|
@@ -54,13 +54,8 @@ function traverseSection(args) {
|
|
|
54
54
|
});
|
|
55
55
|
break;
|
|
56
56
|
}
|
|
57
|
-
|
|
58
|
-
if (!section)
|
|
59
|
-
section = { ...prevSection };
|
|
60
|
-
section[key] = model;
|
|
61
|
-
}
|
|
57
|
+
section[key] = model;
|
|
62
58
|
}
|
|
63
|
-
|
|
64
|
-
return section !== null && section !== void 0 ? section : prevSection;
|
|
59
|
+
return section;
|
|
65
60
|
}
|
|
66
61
|
exports.traverseSection = traverseSection;
|
|
@@ -36,22 +36,22 @@ function traverseNestedGroup(args) {
|
|
|
36
36
|
const { path: prevPath, group, onField } = args;
|
|
37
37
|
if (!((_a = group.config) === null || _a === void 0 ? void 0 : _a.fields))
|
|
38
38
|
return group;
|
|
39
|
-
|
|
40
|
-
for (const [key,
|
|
39
|
+
const fields = {};
|
|
40
|
+
for (const [key, prevField] of Object.entries(group.config.fields)) {
|
|
41
41
|
const path = [...prevPath, key];
|
|
42
|
-
|
|
42
|
+
fields[key] = onField({
|
|
43
43
|
path,
|
|
44
44
|
key,
|
|
45
|
-
field,
|
|
45
|
+
field: prevField,
|
|
46
46
|
});
|
|
47
|
-
if (field !== newField) {
|
|
48
|
-
if (!fields)
|
|
49
|
-
fields = { ...group.config.fields };
|
|
50
|
-
fields[key] = newField;
|
|
51
|
-
}
|
|
52
47
|
}
|
|
53
|
-
|
|
54
|
-
|
|
48
|
+
return {
|
|
49
|
+
...group,
|
|
50
|
+
config: {
|
|
51
|
+
...group.config,
|
|
52
|
+
fields,
|
|
53
|
+
},
|
|
54
|
+
};
|
|
55
55
|
}
|
|
56
56
|
exports.traverseNestedGroup = traverseNestedGroup;
|
|
57
57
|
function traverseGroup(args) {
|
|
@@ -59,7 +59,7 @@ function traverseGroup(args) {
|
|
|
59
59
|
const { path: prevPath, group, onField } = args;
|
|
60
60
|
if (!((_a = group.config) === null || _a === void 0 ? void 0 : _a.fields))
|
|
61
61
|
return group;
|
|
62
|
-
|
|
62
|
+
const fields = {};
|
|
63
63
|
for (const [key, prevField] of Object.entries(group.config.fields)) {
|
|
64
64
|
const path = [...prevPath, key];
|
|
65
65
|
let field;
|
|
@@ -75,18 +75,18 @@ function traverseGroup(args) {
|
|
|
75
75
|
field = prevField;
|
|
76
76
|
break;
|
|
77
77
|
}
|
|
78
|
-
|
|
78
|
+
fields[key] = onField({
|
|
79
79
|
path,
|
|
80
80
|
key,
|
|
81
81
|
field,
|
|
82
82
|
});
|
|
83
|
-
if (field !== newField) {
|
|
84
|
-
if (!fields)
|
|
85
|
-
fields = { ...group.config.fields };
|
|
86
|
-
fields[key] = newField;
|
|
87
|
-
}
|
|
88
83
|
}
|
|
89
|
-
|
|
90
|
-
|
|
84
|
+
return {
|
|
85
|
+
...group,
|
|
86
|
+
config: {
|
|
87
|
+
...group.config,
|
|
88
|
+
fields,
|
|
89
|
+
},
|
|
90
|
+
};
|
|
91
91
|
}
|
|
92
92
|
exports.traverseGroup = traverseGroup;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NestableWidget = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
exports.NestableWidget = zod_1.z.object({
|
|
6
|
+
type: zod_1.z.union([
|
|
7
|
+
zod_1.z.literal("Color"),
|
|
8
|
+
zod_1.z.literal("Boolean"),
|
|
9
|
+
zod_1.z.literal("Number"),
|
|
10
|
+
zod_1.z.literal("Text"),
|
|
11
|
+
zod_1.z.literal("Select"),
|
|
12
|
+
zod_1.z.literal("Range"),
|
|
13
|
+
zod_1.z.literal("Link"),
|
|
14
|
+
zod_1.z.literal("Image"),
|
|
15
|
+
zod_1.z.literal("Media"),
|
|
16
|
+
zod_1.z.literal("Embed"),
|
|
17
|
+
zod_1.z.literal("GeoPoint"),
|
|
18
|
+
zod_1.z.literal("Integration"),
|
|
19
|
+
zod_1.z.literal("ContentRelationship"),
|
|
20
|
+
zod_1.z.literal("Group"),
|
|
21
|
+
zod_1.z.literal("Slices"),
|
|
22
|
+
zod_1.z.literal("UID"),
|
|
23
|
+
]),
|
|
24
|
+
fieldset: zod_1.z.string().nullable().optional(),
|
|
25
|
+
config: zod_1.z.object({
|
|
26
|
+
label: zod_1.z.string().nullable().optional(),
|
|
27
|
+
placeholder: zod_1.z.string().optional(),
|
|
28
|
+
}).optional(),
|
|
29
|
+
}).strict();
|