@prismicio/types-internal 3.12.0 → 3.13.0
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 +836 -0
- package/lib/content/Document.d.ts +24 -18
- package/lib/content/fields/GroupContent.d.ts +1 -1
- package/lib/content/fields/GroupContent.js +18 -9
- package/lib/content/fields/WidgetContent.d.ts +24 -18
- package/lib/content/fields/slices/Slice/CompositeSliceContent.d.ts +12 -9
- package/lib/content/fields/slices/Slice/CompositeSliceContent.js +1 -1
- package/lib/content/fields/slices/Slice/RepeatableContent.d.ts +4 -3
- package/lib/content/fields/slices/Slice/RepeatableContent.js +9 -5
- package/lib/content/fields/slices/Slice/SharedSliceContent.d.ts +12 -9
- package/lib/content/fields/slices/Slice/SimpleSliceContent.js +1 -1
- package/lib/content/fields/slices/Slice/index.d.ts +16 -12
- package/lib/content/fields/slices/SliceItem.d.ts +16 -12
- package/lib/content/fields/slices/SlicesContent.d.ts +24 -18
- package/package.json +1 -1
- package/src/content/fields/GroupContent.ts +23 -12
- package/src/content/fields/slices/Slice/CompositeSliceContent.ts +1 -1
- package/src/content/fields/slices/Slice/RepeatableContent.ts +11 -5
- package/src/content/fields/slices/Slice/SimpleSliceContent.ts +1 -1
|
@@ -776,9 +776,8 @@ export declare const SliceItemContent: t.TypeC<{
|
|
|
776
776
|
}>]>>]>]>;
|
|
777
777
|
}>>]>>;
|
|
778
778
|
}>>]>>;
|
|
779
|
-
repeat: t.ArrayC<t.ExactC<t.TypeC<{
|
|
779
|
+
repeat: t.ArrayC<t.ExactC<t.IntersectionC<[t.TypeC<{
|
|
780
780
|
__TYPE__: t.LiteralC<"GroupItemContent">;
|
|
781
|
-
key: t.StringC;
|
|
782
781
|
value: t.ArrayC<t.TupleC<[t.StringC, t.UnionC<[t.UnionC<[t.ExactC<t.TypeC<{
|
|
783
782
|
type: t.StringC;
|
|
784
783
|
__TYPE__: t.LiteralC<"EmptyContent">;
|
|
@@ -1543,7 +1542,9 @@ export declare const SliceItemContent: t.TypeC<{
|
|
|
1543
1542
|
}>]>>]>]>;
|
|
1544
1543
|
}>>]>>;
|
|
1545
1544
|
}>>]>, t.Type<import("../GroupContent").GroupContent, import("../GroupContent").GroupContent, unknown>]>]>>;
|
|
1546
|
-
}
|
|
1545
|
+
}>, t.PartialC<{
|
|
1546
|
+
key: t.StringC;
|
|
1547
|
+
}>]>>>;
|
|
1547
1548
|
}>>, t.ExactC<t.TypeC<{
|
|
1548
1549
|
__TYPE__: t.LiteralC<"SharedSliceContent">;
|
|
1549
1550
|
variation: t.StringC;
|
|
@@ -2311,9 +2312,8 @@ export declare const SliceItemContent: t.TypeC<{
|
|
|
2311
2312
|
}>]>>]>]>;
|
|
2312
2313
|
}>>]>>;
|
|
2313
2314
|
}>>]>, t.Type<import("../GroupContent").GroupContent, import("../GroupContent").GroupContent, unknown>]>>;
|
|
2314
|
-
items: t.ArrayC<t.ExactC<t.TypeC<{
|
|
2315
|
+
items: t.ArrayC<t.ExactC<t.IntersectionC<[t.TypeC<{
|
|
2315
2316
|
__TYPE__: t.LiteralC<"GroupItemContent">;
|
|
2316
|
-
key: t.StringC;
|
|
2317
2317
|
value: t.ArrayC<t.TupleC<[t.StringC, t.UnionC<[t.UnionC<[t.ExactC<t.TypeC<{
|
|
2318
2318
|
type: t.StringC;
|
|
2319
2319
|
__TYPE__: t.LiteralC<"EmptyContent">;
|
|
@@ -3078,7 +3078,9 @@ export declare const SliceItemContent: t.TypeC<{
|
|
|
3078
3078
|
}>]>>]>]>;
|
|
3079
3079
|
}>>]>>;
|
|
3080
3080
|
}>>]>, t.Type<import("../GroupContent").GroupContent, import("../GroupContent").GroupContent, unknown>]>]>>;
|
|
3081
|
-
}
|
|
3081
|
+
}>, t.PartialC<{
|
|
3082
|
+
key: t.StringC;
|
|
3083
|
+
}>]>>>;
|
|
3082
3084
|
}>>, t.UnionC<[t.UnionC<[t.ExactC<t.TypeC<{
|
|
3083
3085
|
type: t.StringC;
|
|
3084
3086
|
__TYPE__: t.LiteralC<"EmptyContent">;
|
|
@@ -5052,9 +5054,8 @@ export declare const SlicesItemLegacy: (ctx: LegacyContentCtx) => t.Type<{
|
|
|
5052
5054
|
})[];
|
|
5053
5055
|
};
|
|
5054
5056
|
};
|
|
5055
|
-
repeat: {
|
|
5057
|
+
repeat: ({
|
|
5056
5058
|
__TYPE__: "GroupItemContent";
|
|
5057
|
-
key: string;
|
|
5058
5059
|
value: [string, {
|
|
5059
5060
|
type: string;
|
|
5060
5061
|
__TYPE__: "EmptyContent";
|
|
@@ -5645,7 +5646,9 @@ export declare const SlicesItemLegacy: (ctx: LegacyContentCtx) => t.Type<{
|
|
|
5645
5646
|
})[];
|
|
5646
5647
|
})[];
|
|
5647
5648
|
}][];
|
|
5648
|
-
}
|
|
5649
|
+
} & {
|
|
5650
|
+
key?: string;
|
|
5651
|
+
})[];
|
|
5649
5652
|
} | {
|
|
5650
5653
|
__TYPE__: "SharedSliceContent";
|
|
5651
5654
|
variation: string;
|
|
@@ -6241,9 +6244,8 @@ export declare const SlicesItemLegacy: (ctx: LegacyContentCtx) => t.Type<{
|
|
|
6241
6244
|
})[];
|
|
6242
6245
|
};
|
|
6243
6246
|
};
|
|
6244
|
-
items: {
|
|
6247
|
+
items: ({
|
|
6245
6248
|
__TYPE__: "GroupItemContent";
|
|
6246
|
-
key: string;
|
|
6247
6249
|
value: [string, {
|
|
6248
6250
|
type: string;
|
|
6249
6251
|
__TYPE__: "EmptyContent";
|
|
@@ -6834,7 +6836,9 @@ export declare const SlicesItemLegacy: (ctx: LegacyContentCtx) => t.Type<{
|
|
|
6834
6836
|
})[];
|
|
6835
6837
|
})[];
|
|
6836
6838
|
}][];
|
|
6837
|
-
}
|
|
6839
|
+
} & {
|
|
6840
|
+
key?: string;
|
|
6841
|
+
})[];
|
|
6838
6842
|
};
|
|
6839
6843
|
}, WithTypes<{
|
|
6840
6844
|
key: string;
|
|
@@ -1192,9 +1192,8 @@ export declare const isSlicesContent: (u: unknown) => u is {
|
|
|
1192
1192
|
})[];
|
|
1193
1193
|
};
|
|
1194
1194
|
};
|
|
1195
|
-
repeat: {
|
|
1195
|
+
repeat: ({
|
|
1196
1196
|
__TYPE__: "GroupItemContent";
|
|
1197
|
-
key: string;
|
|
1198
1197
|
value: [string, {
|
|
1199
1198
|
type: string;
|
|
1200
1199
|
__TYPE__: "EmptyContent";
|
|
@@ -1785,7 +1784,9 @@ export declare const isSlicesContent: (u: unknown) => u is {
|
|
|
1785
1784
|
})[];
|
|
1786
1785
|
})[];
|
|
1787
1786
|
}][];
|
|
1788
|
-
}
|
|
1787
|
+
} & {
|
|
1788
|
+
key?: string;
|
|
1789
|
+
})[];
|
|
1789
1790
|
} | {
|
|
1790
1791
|
__TYPE__: "SharedSliceContent";
|
|
1791
1792
|
variation: string;
|
|
@@ -2381,9 +2382,8 @@ export declare const isSlicesContent: (u: unknown) => u is {
|
|
|
2381
2382
|
})[];
|
|
2382
2383
|
};
|
|
2383
2384
|
};
|
|
2384
|
-
items: {
|
|
2385
|
+
items: ({
|
|
2385
2386
|
__TYPE__: "GroupItemContent";
|
|
2386
|
-
key: string;
|
|
2387
2387
|
value: [string, {
|
|
2388
2388
|
type: string;
|
|
2389
2389
|
__TYPE__: "EmptyContent";
|
|
@@ -2974,7 +2974,9 @@ export declare const isSlicesContent: (u: unknown) => u is {
|
|
|
2974
2974
|
})[];
|
|
2975
2975
|
})[];
|
|
2976
2976
|
}][];
|
|
2977
|
-
}
|
|
2977
|
+
} & {
|
|
2978
|
+
key?: string;
|
|
2979
|
+
})[];
|
|
2978
2980
|
};
|
|
2979
2981
|
}[];
|
|
2980
2982
|
};
|
|
@@ -4168,9 +4170,8 @@ export declare const SlicesLegacy: (ctx: LegacyContentCtx) => t.Type<{
|
|
|
4168
4170
|
})[];
|
|
4169
4171
|
};
|
|
4170
4172
|
};
|
|
4171
|
-
repeat: {
|
|
4173
|
+
repeat: ({
|
|
4172
4174
|
__TYPE__: "GroupItemContent";
|
|
4173
|
-
key: string;
|
|
4174
4175
|
value: [string, {
|
|
4175
4176
|
type: string;
|
|
4176
4177
|
__TYPE__: "EmptyContent";
|
|
@@ -4761,7 +4762,9 @@ export declare const SlicesLegacy: (ctx: LegacyContentCtx) => t.Type<{
|
|
|
4761
4762
|
})[];
|
|
4762
4763
|
})[];
|
|
4763
4764
|
}][];
|
|
4764
|
-
}
|
|
4765
|
+
} & {
|
|
4766
|
+
key?: string;
|
|
4767
|
+
})[];
|
|
4765
4768
|
} | {
|
|
4766
4769
|
__TYPE__: "SharedSliceContent";
|
|
4767
4770
|
variation: string;
|
|
@@ -5357,9 +5360,8 @@ export declare const SlicesLegacy: (ctx: LegacyContentCtx) => t.Type<{
|
|
|
5357
5360
|
})[];
|
|
5358
5361
|
};
|
|
5359
5362
|
};
|
|
5360
|
-
items: {
|
|
5363
|
+
items: ({
|
|
5361
5364
|
__TYPE__: "GroupItemContent";
|
|
5362
|
-
key: string;
|
|
5363
5365
|
value: [string, {
|
|
5364
5366
|
type: string;
|
|
5365
5367
|
__TYPE__: "EmptyContent";
|
|
@@ -5950,7 +5952,9 @@ export declare const SlicesLegacy: (ctx: LegacyContentCtx) => t.Type<{
|
|
|
5950
5952
|
})[];
|
|
5951
5953
|
})[];
|
|
5952
5954
|
}][];
|
|
5953
|
-
}
|
|
5955
|
+
} & {
|
|
5956
|
+
key?: string;
|
|
5957
|
+
})[];
|
|
5954
5958
|
};
|
|
5955
5959
|
}[];
|
|
5956
5960
|
}, WithTypes<SlicesLegacy>, unknown>;
|
|
@@ -6726,9 +6730,8 @@ export declare const SlicesContent: t.TypeC<{
|
|
|
6726
6730
|
}>]>>]>]>;
|
|
6727
6731
|
}>>]>>;
|
|
6728
6732
|
}>>]>>;
|
|
6729
|
-
repeat: t.ArrayC<t.ExactC<t.TypeC<{
|
|
6733
|
+
repeat: t.ArrayC<t.ExactC<t.IntersectionC<[t.TypeC<{
|
|
6730
6734
|
__TYPE__: t.LiteralC<"GroupItemContent">;
|
|
6731
|
-
key: t.StringC;
|
|
6732
6735
|
value: t.ArrayC<t.TupleC<[t.StringC, t.UnionC<[t.UnionC<[t.ExactC<t.TypeC<{
|
|
6733
6736
|
type: t.StringC;
|
|
6734
6737
|
__TYPE__: t.LiteralC<"EmptyContent">;
|
|
@@ -7493,7 +7496,9 @@ export declare const SlicesContent: t.TypeC<{
|
|
|
7493
7496
|
}>]>>]>]>;
|
|
7494
7497
|
}>>]>>;
|
|
7495
7498
|
}>>]>, t.Type<import("..").GroupContent, import("..").GroupContent, unknown>]>]>>;
|
|
7496
|
-
}
|
|
7499
|
+
}>, t.PartialC<{
|
|
7500
|
+
key: t.StringC;
|
|
7501
|
+
}>]>>>;
|
|
7497
7502
|
}>>, t.ExactC<t.TypeC<{
|
|
7498
7503
|
__TYPE__: t.LiteralC<"SharedSliceContent">;
|
|
7499
7504
|
variation: t.StringC;
|
|
@@ -8261,9 +8266,8 @@ export declare const SlicesContent: t.TypeC<{
|
|
|
8261
8266
|
}>]>>]>]>;
|
|
8262
8267
|
}>>]>>;
|
|
8263
8268
|
}>>]>, t.Type<import("..").GroupContent, import("..").GroupContent, unknown>]>>;
|
|
8264
|
-
items: t.ArrayC<t.ExactC<t.TypeC<{
|
|
8269
|
+
items: t.ArrayC<t.ExactC<t.IntersectionC<[t.TypeC<{
|
|
8265
8270
|
__TYPE__: t.LiteralC<"GroupItemContent">;
|
|
8266
|
-
key: t.StringC;
|
|
8267
8271
|
value: t.ArrayC<t.TupleC<[t.StringC, t.UnionC<[t.UnionC<[t.ExactC<t.TypeC<{
|
|
8268
8272
|
type: t.StringC;
|
|
8269
8273
|
__TYPE__: t.LiteralC<"EmptyContent">;
|
|
@@ -9028,7 +9032,9 @@ export declare const SlicesContent: t.TypeC<{
|
|
|
9028
9032
|
}>]>>]>]>;
|
|
9029
9033
|
}>>]>>;
|
|
9030
9034
|
}>>]>, t.Type<import("..").GroupContent, import("..").GroupContent, unknown>]>]>>;
|
|
9031
|
-
}
|
|
9035
|
+
}>, t.PartialC<{
|
|
9036
|
+
key: t.StringC;
|
|
9037
|
+
}>]>>>;
|
|
9032
9038
|
}>>, t.UnionC<[t.UnionC<[t.ExactC<t.TypeC<{
|
|
9033
9039
|
type: t.StringC;
|
|
9034
9040
|
__TYPE__: t.LiteralC<"EmptyContent">;
|
package/package.json
CHANGED
|
@@ -36,17 +36,24 @@ export const GroupContentType = "GroupContentType" as const
|
|
|
36
36
|
export const GroupItemContent: t.Type<GroupItemContent> = t.recursion(
|
|
37
37
|
"GroupItemContent",
|
|
38
38
|
() =>
|
|
39
|
-
t.
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
39
|
+
t.exact(
|
|
40
|
+
t.intersection([
|
|
41
|
+
t.type({
|
|
42
|
+
__TYPE__: t.literal(GroupItemContentType),
|
|
43
|
+
value: t.array(
|
|
44
|
+
t.tuple([t.string, t.union([NestableContent, GroupContent])]),
|
|
45
|
+
),
|
|
46
|
+
}),
|
|
47
|
+
t.partial({
|
|
48
|
+
key: t.string,
|
|
49
|
+
}),
|
|
50
|
+
]),
|
|
51
|
+
),
|
|
46
52
|
)
|
|
53
|
+
|
|
47
54
|
export type GroupItemContent = {
|
|
48
55
|
__TYPE__: typeof GroupItemContentType
|
|
49
|
-
key
|
|
56
|
+
key?: string
|
|
50
57
|
value: [string, NestableContent | GroupContent][]
|
|
51
58
|
}
|
|
52
59
|
|
|
@@ -129,7 +136,11 @@ export const GroupItemLegacy = (ctx: LegacyContentCtx, index: number) => {
|
|
|
129
136
|
keys: { ...acc.keys, ...encoded.keys },
|
|
130
137
|
}
|
|
131
138
|
},
|
|
132
|
-
{
|
|
139
|
+
{
|
|
140
|
+
content: {},
|
|
141
|
+
types: {},
|
|
142
|
+
keys: item.key ? { [groupItemCtx.keyOfKey]: item.key } : {},
|
|
143
|
+
},
|
|
133
144
|
)
|
|
134
145
|
},
|
|
135
146
|
)
|
|
@@ -264,9 +275,9 @@ export function traverseGroupItemsContent({
|
|
|
264
275
|
model?: Record<string, Group | NestableWidget> | undefined
|
|
265
276
|
}) {
|
|
266
277
|
return (transform: TraverseWidgetContentFn): Array<GroupItemContent> => {
|
|
267
|
-
return content.map((groupItem) => {
|
|
278
|
+
return content.map((groupItem, index) => {
|
|
268
279
|
const groupItemPath = path.concat([
|
|
269
|
-
{ key: groupItem.key, type: "GroupItem" },
|
|
280
|
+
{ key: groupItem.key ?? index.toString(), type: "GroupItem" },
|
|
270
281
|
])
|
|
271
282
|
|
|
272
283
|
const groupItemFields = groupItem.value.reduce<GroupItemContent["value"]>(
|
|
@@ -325,8 +336,8 @@ export function traverseGroupItemsContent({
|
|
|
325
336
|
|
|
326
337
|
return {
|
|
327
338
|
__TYPE__: groupItem.__TYPE__,
|
|
328
|
-
key: groupItem.key,
|
|
329
339
|
value: groupItemFields,
|
|
340
|
+
...(groupItem.key && { key: groupItem.key }),
|
|
330
341
|
}
|
|
331
342
|
})
|
|
332
343
|
}
|
|
@@ -273,7 +273,7 @@ export function migrateCompositeSlice(
|
|
|
273
273
|
items: content.widget.repeat.map((groupItem) => {
|
|
274
274
|
return {
|
|
275
275
|
__TYPE__: "GroupItemContent",
|
|
276
|
-
key: groupItem.key,
|
|
276
|
+
...(groupItem.key && { key: groupItem.key }),
|
|
277
277
|
value: groupItem.value.reduce<GroupItemContent["value"]>(
|
|
278
278
|
(acc, [fieldKey, fieldContent]) => {
|
|
279
279
|
if (!model.fields.items?.[fieldKey]) {
|
|
@@ -20,10 +20,16 @@ const RepeatableWidget = t.tuple([
|
|
|
20
20
|
t.string,
|
|
21
21
|
t.union([NestableContent, GroupContent]),
|
|
22
22
|
])
|
|
23
|
-
const RepeatableWidgetsBlock = t.
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
23
|
+
const RepeatableWidgetsBlock = t.exact(
|
|
24
|
+
t.intersection([
|
|
25
|
+
t.type({
|
|
26
|
+
__TYPE__: t.literal(GroupItemContentType),
|
|
27
|
+
value: t.array(RepeatableWidget),
|
|
28
|
+
}),
|
|
29
|
+
t.partial({
|
|
30
|
+
key: t.string,
|
|
31
|
+
}),
|
|
32
|
+
]),
|
|
33
|
+
)
|
|
28
34
|
|
|
29
35
|
export const RepeatableWidgets = t.array(RepeatableWidgetsBlock)
|
|
@@ -150,7 +150,7 @@ export function migrateSimpleSlice(
|
|
|
150
150
|
items: content.widget.value.map((groupItem) => {
|
|
151
151
|
return {
|
|
152
152
|
__TYPE__: "GroupItemContent",
|
|
153
|
-
key: groupItem.key,
|
|
153
|
+
...(groupItem.key && { key: groupItem.key }),
|
|
154
154
|
value: groupItem.value.reduce<GroupItemContent["value"]>(
|
|
155
155
|
(acc, [fieldKey, fieldContent]) => {
|
|
156
156
|
return model.fields.items?.[fieldKey]
|