@prismicio/types-internal 3.14.0 → 3.15.0-alpha.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 +868 -0
- package/lib/content/Document.d.ts +18 -24
- package/lib/content/fields/GroupContent.d.ts +1 -1
- package/lib/content/fields/GroupContent.js +9 -18
- package/lib/content/fields/WidgetContent.d.ts +18 -24
- package/lib/content/fields/slices/Slice/CompositeSliceContent.d.ts +9 -12
- package/lib/content/fields/slices/Slice/CompositeSliceContent.js +1 -1
- package/lib/content/fields/slices/Slice/RepeatableContent.d.ts +3 -4
- package/lib/content/fields/slices/Slice/RepeatableContent.js +5 -9
- package/lib/content/fields/slices/Slice/SharedSliceContent.d.ts +9 -12
- package/lib/content/fields/slices/Slice/SimpleSliceContent.js +1 -1
- package/lib/content/fields/slices/Slice/index.d.ts +12 -16
- package/lib/content/fields/slices/SliceItem.d.ts +12 -16
- package/lib/content/fields/slices/SlicesContent.d.ts +18 -24
- package/lib/customtypes/widgets/nestable/NestableWidgetZ.d.ts +3 -0
- package/lib/customtypes/widgets/nestable/NestableWidgetZ.js +29 -0
- 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/package.json +1 -1
- package/src/content/fields/GroupContent.ts +12 -23
- package/src/content/fields/slices/Slice/CompositeSliceContent.ts +1 -1
- package/src/content/fields/slices/Slice/RepeatableContent.ts +5 -11
- package/src/content/fields/slices/Slice/SimpleSliceContent.ts +1 -1
- 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
|
@@ -776,8 +776,9 @@ export declare const SliceItemContent: t.TypeC<{
|
|
|
776
776
|
}>]>>]>]>;
|
|
777
777
|
}>>]>>;
|
|
778
778
|
}>>]>>;
|
|
779
|
-
repeat: t.ArrayC<t.ExactC<t.
|
|
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">;
|
|
@@ -1542,9 +1543,7 @@ export declare const SliceItemContent: t.TypeC<{
|
|
|
1542
1543
|
}>]>>]>]>;
|
|
1543
1544
|
}>>]>>;
|
|
1544
1545
|
}>>]>, t.Type<import("../GroupContent").GroupContent, import("../GroupContent").GroupContent, unknown>]>]>>;
|
|
1545
|
-
}
|
|
1546
|
-
key: t.StringC;
|
|
1547
|
-
}>]>>>;
|
|
1546
|
+
}>>>;
|
|
1548
1547
|
}>>, t.ExactC<t.TypeC<{
|
|
1549
1548
|
__TYPE__: t.LiteralC<"SharedSliceContent">;
|
|
1550
1549
|
variation: t.StringC;
|
|
@@ -2312,8 +2311,9 @@ export declare const SliceItemContent: t.TypeC<{
|
|
|
2312
2311
|
}>]>>]>]>;
|
|
2313
2312
|
}>>]>>;
|
|
2314
2313
|
}>>]>, t.Type<import("../GroupContent").GroupContent, import("../GroupContent").GroupContent, unknown>]>>;
|
|
2315
|
-
items: t.ArrayC<t.ExactC<t.
|
|
2314
|
+
items: t.ArrayC<t.ExactC<t.TypeC<{
|
|
2316
2315
|
__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,9 +3078,7 @@ export declare const SliceItemContent: t.TypeC<{
|
|
|
3078
3078
|
}>]>>]>]>;
|
|
3079
3079
|
}>>]>>;
|
|
3080
3080
|
}>>]>, t.Type<import("../GroupContent").GroupContent, import("../GroupContent").GroupContent, unknown>]>]>>;
|
|
3081
|
-
}
|
|
3082
|
-
key: t.StringC;
|
|
3083
|
-
}>]>>>;
|
|
3081
|
+
}>>>;
|
|
3084
3082
|
}>>, t.UnionC<[t.UnionC<[t.ExactC<t.TypeC<{
|
|
3085
3083
|
type: t.StringC;
|
|
3086
3084
|
__TYPE__: t.LiteralC<"EmptyContent">;
|
|
@@ -5054,8 +5052,9 @@ export declare const SlicesItemLegacy: (ctx: LegacyContentCtx) => t.Type<{
|
|
|
5054
5052
|
})[];
|
|
5055
5053
|
};
|
|
5056
5054
|
};
|
|
5057
|
-
repeat:
|
|
5055
|
+
repeat: {
|
|
5058
5056
|
__TYPE__: "GroupItemContent";
|
|
5057
|
+
key: string;
|
|
5059
5058
|
value: [string, {
|
|
5060
5059
|
type: string;
|
|
5061
5060
|
__TYPE__: "EmptyContent";
|
|
@@ -5646,9 +5645,7 @@ export declare const SlicesItemLegacy: (ctx: LegacyContentCtx) => t.Type<{
|
|
|
5646
5645
|
})[];
|
|
5647
5646
|
})[];
|
|
5648
5647
|
}][];
|
|
5649
|
-
}
|
|
5650
|
-
key?: string;
|
|
5651
|
-
})[];
|
|
5648
|
+
}[];
|
|
5652
5649
|
} | {
|
|
5653
5650
|
__TYPE__: "SharedSliceContent";
|
|
5654
5651
|
variation: string;
|
|
@@ -6244,8 +6241,9 @@ export declare const SlicesItemLegacy: (ctx: LegacyContentCtx) => t.Type<{
|
|
|
6244
6241
|
})[];
|
|
6245
6242
|
};
|
|
6246
6243
|
};
|
|
6247
|
-
items:
|
|
6244
|
+
items: {
|
|
6248
6245
|
__TYPE__: "GroupItemContent";
|
|
6246
|
+
key: string;
|
|
6249
6247
|
value: [string, {
|
|
6250
6248
|
type: string;
|
|
6251
6249
|
__TYPE__: "EmptyContent";
|
|
@@ -6836,9 +6834,7 @@ export declare const SlicesItemLegacy: (ctx: LegacyContentCtx) => t.Type<{
|
|
|
6836
6834
|
})[];
|
|
6837
6835
|
})[];
|
|
6838
6836
|
}][];
|
|
6839
|
-
}
|
|
6840
|
-
key?: string;
|
|
6841
|
-
})[];
|
|
6837
|
+
}[];
|
|
6842
6838
|
};
|
|
6843
6839
|
}, WithTypes<{
|
|
6844
6840
|
key: string;
|
|
@@ -1192,8 +1192,9 @@ 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;
|
|
1197
1198
|
value: [string, {
|
|
1198
1199
|
type: string;
|
|
1199
1200
|
__TYPE__: "EmptyContent";
|
|
@@ -1784,9 +1785,7 @@ export declare const isSlicesContent: (u: unknown) => u is {
|
|
|
1784
1785
|
})[];
|
|
1785
1786
|
})[];
|
|
1786
1787
|
}][];
|
|
1787
|
-
}
|
|
1788
|
-
key?: string;
|
|
1789
|
-
})[];
|
|
1788
|
+
}[];
|
|
1790
1789
|
} | {
|
|
1791
1790
|
__TYPE__: "SharedSliceContent";
|
|
1792
1791
|
variation: string;
|
|
@@ -2382,8 +2381,9 @@ export declare const isSlicesContent: (u: unknown) => u is {
|
|
|
2382
2381
|
})[];
|
|
2383
2382
|
};
|
|
2384
2383
|
};
|
|
2385
|
-
items:
|
|
2384
|
+
items: {
|
|
2386
2385
|
__TYPE__: "GroupItemContent";
|
|
2386
|
+
key: string;
|
|
2387
2387
|
value: [string, {
|
|
2388
2388
|
type: string;
|
|
2389
2389
|
__TYPE__: "EmptyContent";
|
|
@@ -2974,9 +2974,7 @@ export declare const isSlicesContent: (u: unknown) => u is {
|
|
|
2974
2974
|
})[];
|
|
2975
2975
|
})[];
|
|
2976
2976
|
}][];
|
|
2977
|
-
}
|
|
2978
|
-
key?: string;
|
|
2979
|
-
})[];
|
|
2977
|
+
}[];
|
|
2980
2978
|
};
|
|
2981
2979
|
}[];
|
|
2982
2980
|
};
|
|
@@ -4170,8 +4168,9 @@ export declare const SlicesLegacy: (ctx: LegacyContentCtx) => t.Type<{
|
|
|
4170
4168
|
})[];
|
|
4171
4169
|
};
|
|
4172
4170
|
};
|
|
4173
|
-
repeat:
|
|
4171
|
+
repeat: {
|
|
4174
4172
|
__TYPE__: "GroupItemContent";
|
|
4173
|
+
key: string;
|
|
4175
4174
|
value: [string, {
|
|
4176
4175
|
type: string;
|
|
4177
4176
|
__TYPE__: "EmptyContent";
|
|
@@ -4762,9 +4761,7 @@ export declare const SlicesLegacy: (ctx: LegacyContentCtx) => t.Type<{
|
|
|
4762
4761
|
})[];
|
|
4763
4762
|
})[];
|
|
4764
4763
|
}][];
|
|
4765
|
-
}
|
|
4766
|
-
key?: string;
|
|
4767
|
-
})[];
|
|
4764
|
+
}[];
|
|
4768
4765
|
} | {
|
|
4769
4766
|
__TYPE__: "SharedSliceContent";
|
|
4770
4767
|
variation: string;
|
|
@@ -5360,8 +5357,9 @@ export declare const SlicesLegacy: (ctx: LegacyContentCtx) => t.Type<{
|
|
|
5360
5357
|
})[];
|
|
5361
5358
|
};
|
|
5362
5359
|
};
|
|
5363
|
-
items:
|
|
5360
|
+
items: {
|
|
5364
5361
|
__TYPE__: "GroupItemContent";
|
|
5362
|
+
key: string;
|
|
5365
5363
|
value: [string, {
|
|
5366
5364
|
type: string;
|
|
5367
5365
|
__TYPE__: "EmptyContent";
|
|
@@ -5952,9 +5950,7 @@ export declare const SlicesLegacy: (ctx: LegacyContentCtx) => t.Type<{
|
|
|
5952
5950
|
})[];
|
|
5953
5951
|
})[];
|
|
5954
5952
|
}][];
|
|
5955
|
-
}
|
|
5956
|
-
key?: string;
|
|
5957
|
-
})[];
|
|
5953
|
+
}[];
|
|
5958
5954
|
};
|
|
5959
5955
|
}[];
|
|
5960
5956
|
}, WithTypes<SlicesLegacy>, unknown>;
|
|
@@ -6730,8 +6726,9 @@ export declare const SlicesContent: t.TypeC<{
|
|
|
6730
6726
|
}>]>>]>]>;
|
|
6731
6727
|
}>>]>>;
|
|
6732
6728
|
}>>]>>;
|
|
6733
|
-
repeat: t.ArrayC<t.ExactC<t.
|
|
6729
|
+
repeat: t.ArrayC<t.ExactC<t.TypeC<{
|
|
6734
6730
|
__TYPE__: t.LiteralC<"GroupItemContent">;
|
|
6731
|
+
key: t.StringC;
|
|
6735
6732
|
value: t.ArrayC<t.TupleC<[t.StringC, t.UnionC<[t.UnionC<[t.ExactC<t.TypeC<{
|
|
6736
6733
|
type: t.StringC;
|
|
6737
6734
|
__TYPE__: t.LiteralC<"EmptyContent">;
|
|
@@ -7496,9 +7493,7 @@ export declare const SlicesContent: t.TypeC<{
|
|
|
7496
7493
|
}>]>>]>]>;
|
|
7497
7494
|
}>>]>>;
|
|
7498
7495
|
}>>]>, t.Type<import("..").GroupContent, import("..").GroupContent, unknown>]>]>>;
|
|
7499
|
-
}
|
|
7500
|
-
key: t.StringC;
|
|
7501
|
-
}>]>>>;
|
|
7496
|
+
}>>>;
|
|
7502
7497
|
}>>, t.ExactC<t.TypeC<{
|
|
7503
7498
|
__TYPE__: t.LiteralC<"SharedSliceContent">;
|
|
7504
7499
|
variation: t.StringC;
|
|
@@ -8266,8 +8261,9 @@ export declare const SlicesContent: t.TypeC<{
|
|
|
8266
8261
|
}>]>>]>]>;
|
|
8267
8262
|
}>>]>>;
|
|
8268
8263
|
}>>]>, t.Type<import("..").GroupContent, import("..").GroupContent, unknown>]>>;
|
|
8269
|
-
items: t.ArrayC<t.ExactC<t.
|
|
8264
|
+
items: t.ArrayC<t.ExactC<t.TypeC<{
|
|
8270
8265
|
__TYPE__: t.LiteralC<"GroupItemContent">;
|
|
8266
|
+
key: t.StringC;
|
|
8271
8267
|
value: t.ArrayC<t.TupleC<[t.StringC, t.UnionC<[t.UnionC<[t.ExactC<t.TypeC<{
|
|
8272
8268
|
type: t.StringC;
|
|
8273
8269
|
__TYPE__: t.LiteralC<"EmptyContent">;
|
|
@@ -9032,9 +9028,7 @@ export declare const SlicesContent: t.TypeC<{
|
|
|
9032
9028
|
}>]>>]>]>;
|
|
9033
9029
|
}>>]>>;
|
|
9034
9030
|
}>>]>, t.Type<import("..").GroupContent, import("..").GroupContent, unknown>]>]>>;
|
|
9035
|
-
}
|
|
9036
|
-
key: t.StringC;
|
|
9037
|
-
}>]>>>;
|
|
9031
|
+
}>>>;
|
|
9038
9032
|
}>>, t.UnionC<[t.UnionC<[t.ExactC<t.TypeC<{
|
|
9039
9033
|
type: t.StringC;
|
|
9040
9034
|
__TYPE__: t.LiteralC<"EmptyContent">;
|
|
@@ -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();
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { SharedSliceRef } from "./SharedSliceRef";
|
|
3
|
+
import type { DynamicSlice, StaticSlice } from "./Slice";
|
|
4
|
+
export declare const Variation: any;
|
|
5
|
+
export declare type Variation = z.infer<typeof Variation>;
|
|
6
|
+
export declare type VariationFields = {
|
|
7
|
+
type: "SharedSlice";
|
|
8
|
+
sliceName: string;
|
|
9
|
+
variationId: string;
|
|
10
|
+
fields: Pick<Variation, "primary" | "items">;
|
|
11
|
+
};
|
|
12
|
+
export declare const SharedSliceType: "SharedSlice";
|
|
13
|
+
export declare const SharedSlice: any;
|
|
14
|
+
export declare type SharedSlice = z.infer<typeof SharedSlice>;
|
|
15
|
+
export declare function isStaticSharedSlice(slice: StaticSlice): slice is SharedSlice;
|
|
16
|
+
export declare function isDynamicSharedSlice(slice: DynamicSlice): slice is SharedSliceRef;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isDynamicSharedSlice = exports.isStaticSharedSlice = exports.SharedSlice = exports.SharedSliceType = exports.Variation = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const NestableWidgetZ_1 = require("../nestable/NestableWidgetZ");
|
|
6
|
+
const SlicePrimaryWidgetZ_1 = require("./SlicePrimaryWidgetZ");
|
|
7
|
+
const IMAGE_PLACEHOLDER_URL = "https://images.prismic.io/slice-machine/621a5ec4-0387-4bc5-9860-2dd46cbc07cd_default_ss.png?auto=compress,format";
|
|
8
|
+
// Helper for WidgetKey validation
|
|
9
|
+
const WidgetKeySchema = zod_1.z.string().refine((val) => true, {
|
|
10
|
+
message: "Invalid widget key",
|
|
11
|
+
});
|
|
12
|
+
exports.Variation = zod_1.z.object({
|
|
13
|
+
id: zod_1.z.string(),
|
|
14
|
+
name: zod_1.z.string(),
|
|
15
|
+
description: zod_1.z.string(),
|
|
16
|
+
imageUrl: zod_1.z.string().default(IMAGE_PLACEHOLDER_URL),
|
|
17
|
+
docURL: zod_1.z.string(),
|
|
18
|
+
version: zod_1.z.string(),
|
|
19
|
+
display: zod_1.z.string().optional(),
|
|
20
|
+
primary: zod_1.z.record(WidgetKeySchema, SlicePrimaryWidgetZ_1.SlicePrimaryWidget).optional(),
|
|
21
|
+
items: zod_1.z.record(WidgetKeySchema, NestableWidgetZ_1.NestableWidget).optional(),
|
|
22
|
+
}).strict();
|
|
23
|
+
exports.SharedSliceType = "SharedSlice";
|
|
24
|
+
exports.SharedSlice = zod_1.z.object({
|
|
25
|
+
id: zod_1.z.string(),
|
|
26
|
+
type: zod_1.z.literal(exports.SharedSliceType),
|
|
27
|
+
name: zod_1.z.string(),
|
|
28
|
+
variations: zod_1.z.array(exports.Variation).readonly(),
|
|
29
|
+
description: zod_1.z.string().optional(),
|
|
30
|
+
legacyPaths: zod_1.z.record(zod_1.z.string(), zod_1.z.string()).optional(),
|
|
31
|
+
}).strict();
|
|
32
|
+
function isStaticSharedSlice(slice) {
|
|
33
|
+
return slice.type === "SharedSlice";
|
|
34
|
+
}
|
|
35
|
+
exports.isStaticSharedSlice = isStaticSharedSlice;
|
|
36
|
+
function isDynamicSharedSlice(slice) {
|
|
37
|
+
return slice.type === "SharedSlice";
|
|
38
|
+
}
|
|
39
|
+
exports.isDynamicSharedSlice = isDynamicSharedSlice;
|
package/package.json
CHANGED
|
@@ -36,24 +36,17 @@ export const GroupContentType = "GroupContentType" as const
|
|
|
36
36
|
export const GroupItemContent: t.Type<GroupItemContent> = t.recursion(
|
|
37
37
|
"GroupItemContent",
|
|
38
38
|
() =>
|
|
39
|
-
t.
|
|
40
|
-
t.
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}),
|
|
47
|
-
t.partial({
|
|
48
|
-
key: t.string,
|
|
49
|
-
}),
|
|
50
|
-
]),
|
|
51
|
-
),
|
|
39
|
+
t.strict({
|
|
40
|
+
__TYPE__: t.literal(GroupItemContentType),
|
|
41
|
+
key: t.string,
|
|
42
|
+
value: t.array(
|
|
43
|
+
t.tuple([t.string, t.union([NestableContent, GroupContent])]),
|
|
44
|
+
),
|
|
45
|
+
}),
|
|
52
46
|
)
|
|
53
|
-
|
|
54
47
|
export type GroupItemContent = {
|
|
55
48
|
__TYPE__: typeof GroupItemContentType
|
|
56
|
-
key
|
|
49
|
+
key: string
|
|
57
50
|
value: [string, NestableContent | GroupContent][]
|
|
58
51
|
}
|
|
59
52
|
|
|
@@ -136,11 +129,7 @@ export const GroupItemLegacy = (ctx: LegacyContentCtx, index: number) => {
|
|
|
136
129
|
keys: { ...acc.keys, ...encoded.keys },
|
|
137
130
|
}
|
|
138
131
|
},
|
|
139
|
-
{
|
|
140
|
-
content: {},
|
|
141
|
-
types: {},
|
|
142
|
-
keys: item.key ? { [groupItemCtx.keyOfKey]: item.key } : {},
|
|
143
|
-
},
|
|
132
|
+
{ content: {}, types: {}, keys: { [groupItemCtx.keyOfKey]: item.key } },
|
|
144
133
|
)
|
|
145
134
|
},
|
|
146
135
|
)
|
|
@@ -275,9 +264,9 @@ export function traverseGroupItemsContent({
|
|
|
275
264
|
model?: Record<string, Group | NestableWidget> | undefined
|
|
276
265
|
}) {
|
|
277
266
|
return (transform: TraverseWidgetContentFn): Array<GroupItemContent> => {
|
|
278
|
-
return content.map((groupItem
|
|
267
|
+
return content.map((groupItem) => {
|
|
279
268
|
const groupItemPath = path.concat([
|
|
280
|
-
{ key: groupItem.key
|
|
269
|
+
{ key: groupItem.key, type: "GroupItem" },
|
|
281
270
|
])
|
|
282
271
|
|
|
283
272
|
const groupItemFields = groupItem.value.reduce<GroupItemContent["value"]>(
|
|
@@ -336,8 +325,8 @@ export function traverseGroupItemsContent({
|
|
|
336
325
|
|
|
337
326
|
return {
|
|
338
327
|
__TYPE__: groupItem.__TYPE__,
|
|
328
|
+
key: groupItem.key,
|
|
339
329
|
value: groupItemFields,
|
|
340
|
-
...(groupItem.key && { key: groupItem.key }),
|
|
341
330
|
}
|
|
342
331
|
})
|
|
343
332
|
}
|
|
@@ -273,7 +273,7 @@ export function migrateCompositeSlice(
|
|
|
273
273
|
items: content.widget.repeat.map((groupItem) => {
|
|
274
274
|
return {
|
|
275
275
|
__TYPE__: "GroupItemContent",
|
|
276
|
-
|
|
276
|
+
key: groupItem.key,
|
|
277
277
|
value: groupItem.value.reduce<GroupItemContent["value"]>(
|
|
278
278
|
(acc, [fieldKey, fieldContent]) => {
|
|
279
279
|
if (!model.fields.items?.[fieldKey]) {
|
|
@@ -20,16 +20,10 @@ const RepeatableWidget = t.tuple([
|
|
|
20
20
|
t.string,
|
|
21
21
|
t.union([NestableContent, GroupContent]),
|
|
22
22
|
])
|
|
23
|
-
const RepeatableWidgetsBlock = t.
|
|
24
|
-
t.
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}),
|
|
29
|
-
t.partial({
|
|
30
|
-
key: t.string,
|
|
31
|
-
}),
|
|
32
|
-
]),
|
|
33
|
-
)
|
|
23
|
+
const RepeatableWidgetsBlock = t.strict({
|
|
24
|
+
__TYPE__: t.literal(GroupItemContentType),
|
|
25
|
+
key: t.string,
|
|
26
|
+
value: t.array(RepeatableWidget),
|
|
27
|
+
})
|
|
34
28
|
|
|
35
29
|
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
|
-
|
|
153
|
+
key: groupItem.key,
|
|
154
154
|
value: groupItem.value.reduce<GroupItemContent["value"]>(
|
|
155
155
|
(acc, [fieldKey, fieldContent]) => {
|
|
156
156
|
return model.fields.items?.[fieldKey]
|
|
@@ -1,162 +0,0 @@
|
|
|
1
|
-
import * as t from "io-ts";
|
|
2
|
-
import type { ContentPath, TraverseWidgetContentFn } from "../../_internal/utils";
|
|
3
|
-
import type { Link, NestableWidget } from "../../customtypes";
|
|
4
|
-
import type { LegacyContentCtx, WithTypes } from "../LegacyContentCtx";
|
|
5
|
-
export declare const RepeatableContent: t.ExactC<t.TypeC<{
|
|
6
|
-
__TYPE__: t.LiteralC<"RepeatableContent">;
|
|
7
|
-
type: t.LiteralC<"Link">;
|
|
8
|
-
value: t.ArrayC<t.ExactC<t.TypeC<{
|
|
9
|
-
__TYPE__: t.LiteralC<"LinkContent">;
|
|
10
|
-
value: t.UnionC<[t.IntersectionC<[t.ExactC<t.TypeC<{
|
|
11
|
-
__TYPE__: t.LiteralC<"ImageLink">;
|
|
12
|
-
}>>, t.UnionC<[t.IntersectionC<[t.IntersectionC<[t.ExactC<t.TypeC<{
|
|
13
|
-
kind: t.StringC;
|
|
14
|
-
id: t.StringC;
|
|
15
|
-
url: t.StringC;
|
|
16
|
-
height: t.StringC;
|
|
17
|
-
width: t.StringC;
|
|
18
|
-
size: t.StringC;
|
|
19
|
-
name: t.StringC;
|
|
20
|
-
}>>, t.ExactC<t.PartialC<{
|
|
21
|
-
date: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
|
|
22
|
-
}>>]>, t.ExactC<t.PartialC<{
|
|
23
|
-
text: t.StringC;
|
|
24
|
-
}>>]>, t.ExactC<t.TypeC<{
|
|
25
|
-
kind: t.LiteralC<"image">;
|
|
26
|
-
text: t.StringC;
|
|
27
|
-
}>>]>]>, t.IntersectionC<[t.ExactC<t.TypeC<{
|
|
28
|
-
__TYPE__: t.LiteralC<"FileLink">;
|
|
29
|
-
}>>, t.UnionC<[t.IntersectionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
|
|
30
|
-
kind: t.StringC;
|
|
31
|
-
id: t.StringC;
|
|
32
|
-
url: t.StringC;
|
|
33
|
-
name: t.StringC;
|
|
34
|
-
size: t.StringC;
|
|
35
|
-
}>, t.PartialC<{
|
|
36
|
-
date: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
|
|
37
|
-
}>]>>, t.ExactC<t.PartialC<{
|
|
38
|
-
text: t.StringC;
|
|
39
|
-
}>>]>, t.ExactC<t.TypeC<{
|
|
40
|
-
kind: t.LiteralC<"file">;
|
|
41
|
-
text: t.StringC;
|
|
42
|
-
}>>]>]>, t.IntersectionC<[t.ExactC<t.TypeC<{
|
|
43
|
-
__TYPE__: t.LiteralC<"DocumentLink">;
|
|
44
|
-
}>>, t.UnionC<[t.IntersectionC<[t.ExactC<t.TypeC<{
|
|
45
|
-
id: t.Type<string, string, unknown>;
|
|
46
|
-
}>>, t.ExactC<t.PartialC<{
|
|
47
|
-
text: t.StringC;
|
|
48
|
-
}>>]>, t.ExactC<t.TypeC<{
|
|
49
|
-
kind: t.LiteralC<"document">;
|
|
50
|
-
text: t.StringC;
|
|
51
|
-
}>>]>]>, t.IntersectionC<[t.ExactC<t.TypeC<{
|
|
52
|
-
__TYPE__: t.LiteralC<"ExternalLink">;
|
|
53
|
-
}>>, t.UnionC<[t.IntersectionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
|
|
54
|
-
url: t.StringC;
|
|
55
|
-
}>, t.PartialC<{
|
|
56
|
-
kind: t.LiteralC<"web">;
|
|
57
|
-
target: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
|
|
58
|
-
preview: t.UnionC<[t.Type<{
|
|
59
|
-
title?: string;
|
|
60
|
-
}, {
|
|
61
|
-
title?: string;
|
|
62
|
-
}, unknown>, t.NullC, t.UndefinedC]>;
|
|
63
|
-
}>]>>, t.ExactC<t.PartialC<{
|
|
64
|
-
text: t.StringC;
|
|
65
|
-
}>>]>, t.ExactC<t.TypeC<{
|
|
66
|
-
kind: t.LiteralC<"web">;
|
|
67
|
-
text: t.StringC;
|
|
68
|
-
}>>]>]>, t.IntersectionC<[t.ExactC<t.TypeC<{
|
|
69
|
-
__TYPE__: t.LiteralC<"MediaLink">;
|
|
70
|
-
}>>, t.ExactC<t.TypeC<{
|
|
71
|
-
kind: t.LiteralC<"media">;
|
|
72
|
-
text: t.StringC;
|
|
73
|
-
}>>]>, t.IntersectionC<[t.ExactC<t.TypeC<{
|
|
74
|
-
__TYPE__: t.LiteralC<"AnyLink">;
|
|
75
|
-
}>>, t.ExactC<t.TypeC<{
|
|
76
|
-
text: t.StringC;
|
|
77
|
-
}>>]>]>;
|
|
78
|
-
}>>>;
|
|
79
|
-
}>>;
|
|
80
|
-
export declare type RepeatableContent = t.TypeOf<typeof RepeatableContent>;
|
|
81
|
-
export declare const isRepeatableContent: t.Is<{
|
|
82
|
-
__TYPE__: "RepeatableContent";
|
|
83
|
-
type: "Link";
|
|
84
|
-
value: {
|
|
85
|
-
__TYPE__: "LinkContent";
|
|
86
|
-
value: ({
|
|
87
|
-
__TYPE__: "ImageLink";
|
|
88
|
-
} & (({
|
|
89
|
-
kind: string;
|
|
90
|
-
id: string;
|
|
91
|
-
url: string;
|
|
92
|
-
height: string;
|
|
93
|
-
width: string;
|
|
94
|
-
size: string;
|
|
95
|
-
name: string;
|
|
96
|
-
} & {
|
|
97
|
-
date?: string | null | undefined;
|
|
98
|
-
} & {
|
|
99
|
-
text?: string;
|
|
100
|
-
}) | {
|
|
101
|
-
kind: "image";
|
|
102
|
-
text: string;
|
|
103
|
-
})) | ({
|
|
104
|
-
__TYPE__: "FileLink";
|
|
105
|
-
} & (({
|
|
106
|
-
kind: string;
|
|
107
|
-
id: string;
|
|
108
|
-
url: string;
|
|
109
|
-
name: string;
|
|
110
|
-
size: string;
|
|
111
|
-
} & {
|
|
112
|
-
date?: string | null | undefined;
|
|
113
|
-
} & {
|
|
114
|
-
text?: string;
|
|
115
|
-
}) | {
|
|
116
|
-
kind: "file";
|
|
117
|
-
text: string;
|
|
118
|
-
})) | ({
|
|
119
|
-
__TYPE__: "MediaLink";
|
|
120
|
-
} & {
|
|
121
|
-
kind: "media";
|
|
122
|
-
text: string;
|
|
123
|
-
}) | ({
|
|
124
|
-
__TYPE__: "DocumentLink";
|
|
125
|
-
} & (({
|
|
126
|
-
id: string;
|
|
127
|
-
} & {
|
|
128
|
-
text?: string;
|
|
129
|
-
}) | {
|
|
130
|
-
kind: "document";
|
|
131
|
-
text: string;
|
|
132
|
-
})) | ({
|
|
133
|
-
__TYPE__: "ExternalLink";
|
|
134
|
-
} & (({
|
|
135
|
-
url: string;
|
|
136
|
-
} & {
|
|
137
|
-
kind?: "web";
|
|
138
|
-
target?: string | null | undefined;
|
|
139
|
-
preview?: {
|
|
140
|
-
title?: string;
|
|
141
|
-
} | null | undefined;
|
|
142
|
-
} & {
|
|
143
|
-
text?: string;
|
|
144
|
-
}) | {
|
|
145
|
-
kind: "web";
|
|
146
|
-
text: string;
|
|
147
|
-
})) | ({
|
|
148
|
-
__TYPE__: "AnyLink";
|
|
149
|
-
} & {
|
|
150
|
-
text: string;
|
|
151
|
-
});
|
|
152
|
-
}[];
|
|
153
|
-
}>;
|
|
154
|
-
export declare const RepeatableLegacy: (ctx: LegacyContentCtx, fieldType: "Link") => t.Type<RepeatableContent, WithTypes<Array<unknown>>, unknown>;
|
|
155
|
-
export declare type RepeatableCustomType = Link;
|
|
156
|
-
export declare function traverseRepeatableContent({ path, key, apiId, model, content, }: {
|
|
157
|
-
path: ContentPath;
|
|
158
|
-
key: string;
|
|
159
|
-
apiId: string;
|
|
160
|
-
content: RepeatableContent;
|
|
161
|
-
model?: NestableWidget | undefined;
|
|
162
|
-
}): (transform: TraverseWidgetContentFn) => RepeatableContent | undefined;
|