@prismicio/types-internal 3.1.0-alpha.5 → 3.1.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/lib/_internal/utils.d.ts +1 -2
- package/lib/content/fields/GroupContent.js +1 -2
- package/lib/content/fields/RepeatableContent.d.ts +45 -47
- package/lib/content/fields/index.d.ts +0 -1
- package/lib/content/fields/index.js +0 -1
- package/lib/content/fields/nestable/NestableContent.js +1 -1
- package/lib/content/fields/nestable/RepeatableContent.d.ts +164 -0
- package/lib/content/fields/nestable/RepeatableContent.js +93 -0
- package/lib/content/fields/nestable/RichTextContent/TextBlock.d.ts +727 -0
- package/lib/content/fields/nestable/RichTextContent/TextBlock.js +80 -0
- package/lib/content/fields/nestable/index.d.ts +1 -0
- package/lib/content/fields/nestable/index.js +1 -0
- package/lib/content/fields/slices/Slice/SharedSliceContent.js +6 -7
- package/lib/customtypes/widgets/slices/SliceWidget.d.ts +327 -0
- package/lib/customtypes/widgets/slices/SliceWidget.js +8 -0
- package/package.json +1 -1
- package/src/_internal/utils.ts +1 -1
- package/src/content/fields/GroupContent.ts +6 -2
- package/src/content/fields/index.ts +0 -1
- package/src/content/fields/nestable/NestableContent.ts +5 -5
- package/src/content/fields/{RepeatableContent.ts → nestable/RepeatableContent.ts} +4 -4
- package/src/content/fields/nestable/index.ts +1 -0
- package/src/content/fields/slices/Slice/SharedSliceContent.ts +2 -2
package/lib/_internal/utils.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import type { SharedSliceItemContent, SliceItemContent, WidgetContent } from "../content";
|
|
2
|
-
import type { RepeatableContent } from "../content/fields/RepeatableContent";
|
|
1
|
+
import type { RepeatableContent, SharedSliceItemContent, SliceItemContent, WidgetContent } from "../content";
|
|
3
2
|
import type { CompositeSlice, Group, NestableWidget, StaticSlices, UID, VariationFields } from "../customtypes";
|
|
4
3
|
export declare type TraverseSliceContentFn = <S extends SliceItemContent | SharedSliceItemContent, D extends VariationFields | CompositeSlice | Group | NestableWidget>({ path, key, apiId, model, content, }: {
|
|
5
4
|
path: ContentPath;
|
|
@@ -10,7 +10,6 @@ const customtypes_1 = require("../../customtypes");
|
|
|
10
10
|
const LegacyContentCtx_1 = require("../LegacyContentCtx");
|
|
11
11
|
const utils_1 = require("../utils");
|
|
12
12
|
const nestable_1 = require("./nestable");
|
|
13
|
-
const RepeatableContent_1 = require("./RepeatableContent");
|
|
14
13
|
const withDefaultValues_1 = require("./withDefaultValues");
|
|
15
14
|
exports.GroupItemContentType = "GroupItemContent";
|
|
16
15
|
exports.GroupContentType = "GroupContentType";
|
|
@@ -146,7 +145,7 @@ function traverseGroupItemsContent({ path, model, content, }) {
|
|
|
146
145
|
else if ((!fieldDef ||
|
|
147
146
|
((fieldDef === null || fieldDef === void 0 ? void 0 : fieldDef.type) === "Link" && ((_a = fieldDef.config) === null || _a === void 0 ? void 0 : _a.repeat))) &&
|
|
148
147
|
fieldContent.__TYPE__ === "RepeatableContent") {
|
|
149
|
-
transformedField = (0,
|
|
148
|
+
transformedField = (0, nestable_1.traverseRepeatableContent)({
|
|
150
149
|
path: groupItemPath.concat([{ key: fieldKey, type: "Widget" }]),
|
|
151
150
|
key: fieldKey,
|
|
152
151
|
apiId: fieldKey,
|
|
@@ -5,14 +5,12 @@ import type { LegacyContentCtx, WithTypes } from "../LegacyContentCtx";
|
|
|
5
5
|
export declare const RepeatableContent: t.ExactC<t.TypeC<{
|
|
6
6
|
__TYPE__: t.LiteralC<"RepeatableContent">;
|
|
7
7
|
type: t.LiteralC<"Link">;
|
|
8
|
-
value: t.ArrayC<t.
|
|
9
|
-
key: t.Type<string, string, unknown>;
|
|
10
|
-
}>>, t.ExactC<t.TypeC<{
|
|
8
|
+
value: t.ArrayC<t.ExactC<t.TypeC<{
|
|
11
9
|
__TYPE__: t.LiteralC<"LinkContent">;
|
|
12
10
|
value: t.UnionC<[t.IntersectionC<[t.ExactC<t.TypeC<{
|
|
13
11
|
__TYPE__: t.LiteralC<"ImageLink">;
|
|
14
|
-
}>>, t.
|
|
15
|
-
kind: t.
|
|
12
|
+
}>>, t.UnionC<[t.IntersectionC<[t.IntersectionC<[t.ExactC<t.TypeC<{
|
|
13
|
+
kind: t.StringC;
|
|
16
14
|
id: t.StringC;
|
|
17
15
|
url: t.StringC;
|
|
18
16
|
height: t.StringC;
|
|
@@ -21,35 +19,38 @@ export declare const RepeatableContent: t.ExactC<t.TypeC<{
|
|
|
21
19
|
name: t.StringC;
|
|
22
20
|
}>>, t.ExactC<t.PartialC<{
|
|
23
21
|
date: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
|
|
22
|
+
}>>]>, t.ExactC<t.PartialC<{
|
|
23
|
+
text: t.StringC;
|
|
24
24
|
}>>]>, t.ExactC<t.TypeC<{
|
|
25
25
|
kind: t.LiteralC<"image">;
|
|
26
|
-
}>>]>, t.ExactC<t.PartialC<{
|
|
27
26
|
text: t.StringC;
|
|
28
27
|
}>>]>]>, t.IntersectionC<[t.ExactC<t.TypeC<{
|
|
29
28
|
__TYPE__: t.LiteralC<"FileLink">;
|
|
30
|
-
}>>, t.
|
|
31
|
-
kind: t.
|
|
29
|
+
}>>, t.UnionC<[t.IntersectionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
|
|
30
|
+
kind: t.StringC;
|
|
32
31
|
id: t.StringC;
|
|
33
32
|
url: t.StringC;
|
|
34
33
|
name: t.StringC;
|
|
35
34
|
size: t.StringC;
|
|
36
35
|
}>, t.PartialC<{
|
|
37
36
|
date: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
|
|
38
|
-
}>]>>, t.ExactC<t.
|
|
37
|
+
}>]>>, t.ExactC<t.PartialC<{
|
|
38
|
+
text: t.StringC;
|
|
39
|
+
}>>]>, t.ExactC<t.TypeC<{
|
|
39
40
|
kind: t.LiteralC<"file">;
|
|
40
|
-
}>>]>, t.ExactC<t.PartialC<{
|
|
41
41
|
text: t.StringC;
|
|
42
42
|
}>>]>]>, t.IntersectionC<[t.ExactC<t.TypeC<{
|
|
43
43
|
__TYPE__: t.LiteralC<"DocumentLink">;
|
|
44
|
-
}>>, t.
|
|
44
|
+
}>>, t.UnionC<[t.IntersectionC<[t.ExactC<t.TypeC<{
|
|
45
45
|
id: t.Type<string, string, unknown>;
|
|
46
|
-
}>>, t.ExactC<t.
|
|
46
|
+
}>>, t.ExactC<t.PartialC<{
|
|
47
|
+
text: t.StringC;
|
|
48
|
+
}>>]>, t.ExactC<t.TypeC<{
|
|
47
49
|
kind: t.LiteralC<"document">;
|
|
48
|
-
}>>]>, t.ExactC<t.PartialC<{
|
|
49
50
|
text: t.StringC;
|
|
50
51
|
}>>]>]>, t.IntersectionC<[t.ExactC<t.TypeC<{
|
|
51
52
|
__TYPE__: t.LiteralC<"ExternalLink">;
|
|
52
|
-
}>>, t.
|
|
53
|
+
}>>, t.UnionC<[t.IntersectionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
|
|
53
54
|
url: t.StringC;
|
|
54
55
|
}>, t.PartialC<{
|
|
55
56
|
kind: t.LiteralC<"web">;
|
|
@@ -59,37 +60,33 @@ export declare const RepeatableContent: t.ExactC<t.TypeC<{
|
|
|
59
60
|
}, {
|
|
60
61
|
title?: string;
|
|
61
62
|
}, unknown>, t.NullC, t.UndefinedC]>;
|
|
62
|
-
}>]>>, t.ExactC<t.
|
|
63
|
+
}>]>>, t.ExactC<t.PartialC<{
|
|
64
|
+
text: t.StringC;
|
|
65
|
+
}>>]>, t.ExactC<t.TypeC<{
|
|
63
66
|
kind: t.LiteralC<"web">;
|
|
64
|
-
}>>]>, t.ExactC<t.PartialC<{
|
|
65
67
|
text: t.StringC;
|
|
66
68
|
}>>]>]>, t.IntersectionC<[t.ExactC<t.TypeC<{
|
|
67
69
|
__TYPE__: t.LiteralC<"MediaLink">;
|
|
68
|
-
}>>, t.
|
|
70
|
+
}>>, t.ExactC<t.TypeC<{
|
|
69
71
|
kind: t.LiteralC<"media">;
|
|
70
|
-
}>>, t.ExactC<t.PartialC<{
|
|
71
72
|
text: t.StringC;
|
|
72
|
-
}>>]
|
|
73
|
+
}>>]>, t.IntersectionC<[t.ExactC<t.TypeC<{
|
|
73
74
|
__TYPE__: t.LiteralC<"AnyLink">;
|
|
74
|
-
}>>, t.ExactC<t.
|
|
75
|
-
kind: t.LiteralC<"any">;
|
|
76
|
-
}>, t.PartialC<{
|
|
75
|
+
}>>, t.ExactC<t.TypeC<{
|
|
77
76
|
text: t.StringC;
|
|
78
|
-
}
|
|
79
|
-
}
|
|
77
|
+
}>>]>]>;
|
|
78
|
+
}>>>;
|
|
80
79
|
}>>;
|
|
81
80
|
export declare type RepeatableContent = t.TypeOf<typeof RepeatableContent>;
|
|
82
81
|
export declare const isRepeatableContent: t.Is<{
|
|
83
82
|
__TYPE__: "RepeatableContent";
|
|
84
83
|
type: "Link";
|
|
85
|
-
value:
|
|
86
|
-
key: string;
|
|
87
|
-
} & {
|
|
84
|
+
value: {
|
|
88
85
|
__TYPE__: "LinkContent";
|
|
89
86
|
value: ({
|
|
90
87
|
__TYPE__: "ImageLink";
|
|
91
|
-
} & ((
|
|
92
|
-
kind:
|
|
88
|
+
} & (({
|
|
89
|
+
kind: string;
|
|
93
90
|
id: string;
|
|
94
91
|
url: string;
|
|
95
92
|
height: string;
|
|
@@ -98,41 +95,43 @@ export declare const isRepeatableContent: t.Is<{
|
|
|
98
95
|
name: string;
|
|
99
96
|
} & {
|
|
100
97
|
date?: string | null | undefined;
|
|
98
|
+
} & {
|
|
99
|
+
text?: string;
|
|
101
100
|
}) | {
|
|
102
101
|
kind: "image";
|
|
103
|
-
|
|
104
|
-
text?: string;
|
|
102
|
+
text: string;
|
|
105
103
|
})) | ({
|
|
106
104
|
__TYPE__: "FileLink";
|
|
107
|
-
} & ((
|
|
108
|
-
kind:
|
|
105
|
+
} & (({
|
|
106
|
+
kind: string;
|
|
109
107
|
id: string;
|
|
110
108
|
url: string;
|
|
111
109
|
name: string;
|
|
112
110
|
size: string;
|
|
113
111
|
} & {
|
|
114
112
|
date?: string | null | undefined;
|
|
113
|
+
} & {
|
|
114
|
+
text?: string;
|
|
115
115
|
}) | {
|
|
116
116
|
kind: "file";
|
|
117
|
-
|
|
118
|
-
text?: string;
|
|
117
|
+
text: string;
|
|
119
118
|
})) | ({
|
|
120
119
|
__TYPE__: "MediaLink";
|
|
121
120
|
} & {
|
|
122
121
|
kind: "media";
|
|
123
|
-
|
|
124
|
-
text?: string;
|
|
122
|
+
text: string;
|
|
125
123
|
}) | ({
|
|
126
124
|
__TYPE__: "DocumentLink";
|
|
127
125
|
} & (({
|
|
128
126
|
id: string;
|
|
129
|
-
}
|
|
130
|
-
kind: "document";
|
|
131
|
-
}) & {
|
|
127
|
+
} & {
|
|
132
128
|
text?: string;
|
|
129
|
+
}) | {
|
|
130
|
+
kind: "document";
|
|
131
|
+
text: string;
|
|
133
132
|
})) | ({
|
|
134
133
|
__TYPE__: "ExternalLink";
|
|
135
|
-
} & ((
|
|
134
|
+
} & (({
|
|
136
135
|
url: string;
|
|
137
136
|
} & {
|
|
138
137
|
kind?: "web";
|
|
@@ -140,18 +139,17 @@ export declare const isRepeatableContent: t.Is<{
|
|
|
140
139
|
preview?: {
|
|
141
140
|
title?: string;
|
|
142
141
|
} | null | undefined;
|
|
142
|
+
} & {
|
|
143
|
+
text?: string;
|
|
143
144
|
}) | {
|
|
144
145
|
kind: "web";
|
|
145
|
-
|
|
146
|
-
text?: string;
|
|
146
|
+
text: string;
|
|
147
147
|
})) | ({
|
|
148
148
|
__TYPE__: "AnyLink";
|
|
149
149
|
} & {
|
|
150
|
-
|
|
151
|
-
} & {
|
|
152
|
-
text?: string;
|
|
150
|
+
text: string;
|
|
153
151
|
});
|
|
154
|
-
}
|
|
152
|
+
}[];
|
|
155
153
|
}>;
|
|
156
154
|
export declare const RepeatableLegacy: (ctx: LegacyContentCtx, fieldType: "Link") => t.Type<RepeatableContent, WithTypes<Array<unknown>>, unknown>;
|
|
157
155
|
export declare type RepeatableCustomType = Link;
|
|
@@ -4,7 +4,6 @@ const tslib_1 = require("tslib");
|
|
|
4
4
|
(0, tslib_1.__exportStar)(require("./EmptyContent"), exports);
|
|
5
5
|
(0, tslib_1.__exportStar)(require("./GroupContent"), exports);
|
|
6
6
|
(0, tslib_1.__exportStar)(require("./nestable"), exports);
|
|
7
|
-
(0, tslib_1.__exportStar)(require("./RepeatableContent"), exports);
|
|
8
7
|
(0, tslib_1.__exportStar)(require("./slices"), exports);
|
|
9
8
|
(0, tslib_1.__exportStar)(require("./UIDContent"), exports);
|
|
10
9
|
(0, tslib_1.__exportStar)(require("./WidgetContent"), exports);
|
|
@@ -5,7 +5,6 @@ const tslib_1 = require("tslib");
|
|
|
5
5
|
const Either_1 = require("fp-ts/lib/Either");
|
|
6
6
|
const t = (0, tslib_1.__importStar)(require("io-ts"));
|
|
7
7
|
const EmptyContent_1 = require("../EmptyContent");
|
|
8
|
-
const RepeatableContent_1 = require("../RepeatableContent");
|
|
9
8
|
const BooleanContent_1 = require("./BooleanContent");
|
|
10
9
|
const EmbedContent_1 = require("./EmbedContent");
|
|
11
10
|
const FieldContent_1 = require("./FieldContent");
|
|
@@ -14,6 +13,7 @@ const GeoPointContent_1 = require("./GeoPointContent");
|
|
|
14
13
|
const ImageContent_1 = require("./ImageContent");
|
|
15
14
|
const IntegrationFieldContent_1 = require("./IntegrationFieldContent");
|
|
16
15
|
const LinkContent_1 = require("./LinkContent");
|
|
16
|
+
const RepeatableContent_1 = require("./RepeatableContent");
|
|
17
17
|
const RichTextContent_1 = require("./RichTextContent");
|
|
18
18
|
const SeparatorContent_1 = require("./SeparatorContent");
|
|
19
19
|
exports.NestableContent = t.union([
|
|
@@ -0,0 +1,164 @@
|
|
|
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.IntersectionC<[t.ExactC<t.TypeC<{
|
|
9
|
+
key: t.Type<string, string, unknown>;
|
|
10
|
+
}>>, t.ExactC<t.TypeC<{
|
|
11
|
+
__TYPE__: t.LiteralC<"LinkContent">;
|
|
12
|
+
value: t.UnionC<[t.IntersectionC<[t.ExactC<t.TypeC<{
|
|
13
|
+
__TYPE__: t.LiteralC<"ImageLink">;
|
|
14
|
+
}>>, t.IntersectionC<[t.UnionC<[t.IntersectionC<[t.ExactC<t.TypeC<{
|
|
15
|
+
kind: t.Type<"image", "image", unknown>;
|
|
16
|
+
id: t.StringC;
|
|
17
|
+
url: t.StringC;
|
|
18
|
+
height: t.StringC;
|
|
19
|
+
width: t.StringC;
|
|
20
|
+
size: t.StringC;
|
|
21
|
+
name: t.StringC;
|
|
22
|
+
}>>, t.ExactC<t.PartialC<{
|
|
23
|
+
date: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
|
|
24
|
+
}>>]>, t.ExactC<t.TypeC<{
|
|
25
|
+
kind: t.LiteralC<"image">;
|
|
26
|
+
}>>]>, t.ExactC<t.PartialC<{
|
|
27
|
+
text: t.StringC;
|
|
28
|
+
}>>]>]>, t.IntersectionC<[t.ExactC<t.TypeC<{
|
|
29
|
+
__TYPE__: t.LiteralC<"FileLink">;
|
|
30
|
+
}>>, t.IntersectionC<[t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
|
|
31
|
+
kind: t.Type<"file", "file", unknown>;
|
|
32
|
+
id: t.StringC;
|
|
33
|
+
url: t.StringC;
|
|
34
|
+
name: t.StringC;
|
|
35
|
+
size: t.StringC;
|
|
36
|
+
}>, t.PartialC<{
|
|
37
|
+
date: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
|
|
38
|
+
}>]>>, t.ExactC<t.TypeC<{
|
|
39
|
+
kind: t.LiteralC<"file">;
|
|
40
|
+
}>>]>, t.ExactC<t.PartialC<{
|
|
41
|
+
text: t.StringC;
|
|
42
|
+
}>>]>]>, t.IntersectionC<[t.ExactC<t.TypeC<{
|
|
43
|
+
__TYPE__: t.LiteralC<"DocumentLink">;
|
|
44
|
+
}>>, t.IntersectionC<[t.UnionC<[t.ExactC<t.TypeC<{
|
|
45
|
+
id: t.Type<string, string, unknown>;
|
|
46
|
+
}>>, t.ExactC<t.TypeC<{
|
|
47
|
+
kind: t.LiteralC<"document">;
|
|
48
|
+
}>>]>, t.ExactC<t.PartialC<{
|
|
49
|
+
text: t.StringC;
|
|
50
|
+
}>>]>]>, t.IntersectionC<[t.ExactC<t.TypeC<{
|
|
51
|
+
__TYPE__: t.LiteralC<"ExternalLink">;
|
|
52
|
+
}>>, t.IntersectionC<[t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
|
|
53
|
+
url: t.StringC;
|
|
54
|
+
}>, t.PartialC<{
|
|
55
|
+
kind: t.LiteralC<"web">;
|
|
56
|
+
target: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
|
|
57
|
+
preview: t.UnionC<[t.Type<{
|
|
58
|
+
title?: string;
|
|
59
|
+
}, {
|
|
60
|
+
title?: string;
|
|
61
|
+
}, unknown>, t.NullC, t.UndefinedC]>;
|
|
62
|
+
}>]>>, t.ExactC<t.TypeC<{
|
|
63
|
+
kind: t.LiteralC<"web">;
|
|
64
|
+
}>>]>, t.ExactC<t.PartialC<{
|
|
65
|
+
text: t.StringC;
|
|
66
|
+
}>>]>]>, t.IntersectionC<[t.ExactC<t.TypeC<{
|
|
67
|
+
__TYPE__: t.LiteralC<"MediaLink">;
|
|
68
|
+
}>>, t.IntersectionC<[t.ExactC<t.TypeC<{
|
|
69
|
+
kind: t.LiteralC<"media">;
|
|
70
|
+
}>>, t.ExactC<t.PartialC<{
|
|
71
|
+
text: t.StringC;
|
|
72
|
+
}>>]>]>, t.IntersectionC<[t.ExactC<t.TypeC<{
|
|
73
|
+
__TYPE__: t.LiteralC<"AnyLink">;
|
|
74
|
+
}>>, t.ExactC<t.IntersectionC<[t.TypeC<{
|
|
75
|
+
kind: t.LiteralC<"any">;
|
|
76
|
+
}>, t.PartialC<{
|
|
77
|
+
text: t.StringC;
|
|
78
|
+
}>]>>]>]>;
|
|
79
|
+
}>>]>>;
|
|
80
|
+
}>>;
|
|
81
|
+
export declare type RepeatableContent = t.TypeOf<typeof RepeatableContent>;
|
|
82
|
+
export declare const isRepeatableContent: t.Is<{
|
|
83
|
+
__TYPE__: "RepeatableContent";
|
|
84
|
+
type: "Link";
|
|
85
|
+
value: ({
|
|
86
|
+
key: string;
|
|
87
|
+
} & {
|
|
88
|
+
__TYPE__: "LinkContent";
|
|
89
|
+
value: ({
|
|
90
|
+
__TYPE__: "ImageLink";
|
|
91
|
+
} & ((({
|
|
92
|
+
kind: "image";
|
|
93
|
+
id: string;
|
|
94
|
+
url: string;
|
|
95
|
+
height: string;
|
|
96
|
+
width: string;
|
|
97
|
+
size: string;
|
|
98
|
+
name: string;
|
|
99
|
+
} & {
|
|
100
|
+
date?: string | null | undefined;
|
|
101
|
+
}) | {
|
|
102
|
+
kind: "image";
|
|
103
|
+
}) & {
|
|
104
|
+
text?: string;
|
|
105
|
+
})) | ({
|
|
106
|
+
__TYPE__: "FileLink";
|
|
107
|
+
} & ((({
|
|
108
|
+
kind: "file";
|
|
109
|
+
id: string;
|
|
110
|
+
url: string;
|
|
111
|
+
name: string;
|
|
112
|
+
size: string;
|
|
113
|
+
} & {
|
|
114
|
+
date?: string | null | undefined;
|
|
115
|
+
}) | {
|
|
116
|
+
kind: "file";
|
|
117
|
+
}) & {
|
|
118
|
+
text?: string;
|
|
119
|
+
})) | ({
|
|
120
|
+
__TYPE__: "MediaLink";
|
|
121
|
+
} & {
|
|
122
|
+
kind: "media";
|
|
123
|
+
} & {
|
|
124
|
+
text?: string;
|
|
125
|
+
}) | ({
|
|
126
|
+
__TYPE__: "DocumentLink";
|
|
127
|
+
} & (({
|
|
128
|
+
id: string;
|
|
129
|
+
} | {
|
|
130
|
+
kind: "document";
|
|
131
|
+
}) & {
|
|
132
|
+
text?: string;
|
|
133
|
+
})) | ({
|
|
134
|
+
__TYPE__: "ExternalLink";
|
|
135
|
+
} & ((({
|
|
136
|
+
url: string;
|
|
137
|
+
} & {
|
|
138
|
+
kind?: "web";
|
|
139
|
+
target?: string | null | undefined;
|
|
140
|
+
preview?: {
|
|
141
|
+
title?: string;
|
|
142
|
+
} | null | undefined;
|
|
143
|
+
}) | {
|
|
144
|
+
kind: "web";
|
|
145
|
+
}) & {
|
|
146
|
+
text?: string;
|
|
147
|
+
})) | ({
|
|
148
|
+
__TYPE__: "AnyLink";
|
|
149
|
+
} & {
|
|
150
|
+
kind: "any";
|
|
151
|
+
} & {
|
|
152
|
+
text?: string;
|
|
153
|
+
});
|
|
154
|
+
})[];
|
|
155
|
+
}>;
|
|
156
|
+
export declare const RepeatableLegacy: (ctx: LegacyContentCtx, fieldType: "Link") => t.Type<RepeatableContent, WithTypes<Array<unknown>>, unknown>;
|
|
157
|
+
export declare type RepeatableCustomType = Link;
|
|
158
|
+
export declare function traverseRepeatableContent({ path, key, apiId, model, content, }: {
|
|
159
|
+
path: ContentPath;
|
|
160
|
+
key: string;
|
|
161
|
+
apiId: string;
|
|
162
|
+
content: RepeatableContent;
|
|
163
|
+
model?: NestableWidget | undefined;
|
|
164
|
+
}): (transform: TraverseWidgetContentFn) => RepeatableContent | undefined;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.traverseRepeatableContent = exports.RepeatableLegacy = exports.isRepeatableContent = exports.RepeatableContent = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const fp_ts_1 = require("fp-ts");
|
|
6
|
+
const Either_1 = require("fp-ts/lib/Either");
|
|
7
|
+
const function_1 = require("fp-ts/lib/function");
|
|
8
|
+
const t = (0, tslib_1.__importStar)(require("io-ts"));
|
|
9
|
+
const LinkContent_1 = require("./LinkContent");
|
|
10
|
+
exports.RepeatableContent = t.strict({
|
|
11
|
+
__TYPE__: t.literal("RepeatableContent"),
|
|
12
|
+
type: t.literal("Link"),
|
|
13
|
+
value: t.array(LinkContent_1.LinkContent),
|
|
14
|
+
});
|
|
15
|
+
exports.isRepeatableContent = exports.RepeatableContent.is;
|
|
16
|
+
const RepeatableLegacy = (ctx, fieldType) => {
|
|
17
|
+
return new t.Type("RepeatableLegacy", exports.isRepeatableContent, (items) => {
|
|
18
|
+
const parsed = (0, function_1.pipe)(t.array(t.unknown).decode(items), fp_ts_1.either.map((items) => {
|
|
19
|
+
const parsedItems = items.reduce((acc, item) => {
|
|
20
|
+
let result;
|
|
21
|
+
switch (fieldType) {
|
|
22
|
+
case "Link":
|
|
23
|
+
result = (0, LinkContent_1.LinkContentLegacy)(ctx).decode(item);
|
|
24
|
+
break;
|
|
25
|
+
}
|
|
26
|
+
if (!result)
|
|
27
|
+
return acc;
|
|
28
|
+
if ((0, Either_1.isLeft)(result))
|
|
29
|
+
return acc;
|
|
30
|
+
return [...acc, result.right];
|
|
31
|
+
}, []);
|
|
32
|
+
return {
|
|
33
|
+
value: parsedItems,
|
|
34
|
+
type: fieldType,
|
|
35
|
+
__TYPE__: "RepeatableContent",
|
|
36
|
+
};
|
|
37
|
+
}));
|
|
38
|
+
return parsed;
|
|
39
|
+
}, (r) => {
|
|
40
|
+
const res = t.array(LinkContent_1.LinkContent).encode(r.value);
|
|
41
|
+
const encodedItems = res.reduce((acc, item) => {
|
|
42
|
+
let encoded;
|
|
43
|
+
switch (item.__TYPE__) {
|
|
44
|
+
case LinkContent_1.LinkContentType:
|
|
45
|
+
encoded = (0, LinkContent_1.LinkContentLegacy)(ctx).encode(item);
|
|
46
|
+
break;
|
|
47
|
+
}
|
|
48
|
+
if (!encoded)
|
|
49
|
+
return acc;
|
|
50
|
+
return [...acc, encoded];
|
|
51
|
+
}, []);
|
|
52
|
+
return {
|
|
53
|
+
content: encodedItems.map((encodedItem) => encodedItem.content),
|
|
54
|
+
types: { [ctx.keyOfType]: `Repeatable.${fieldType}` },
|
|
55
|
+
};
|
|
56
|
+
});
|
|
57
|
+
};
|
|
58
|
+
exports.RepeatableLegacy = RepeatableLegacy;
|
|
59
|
+
function traverseRepeatableContent({ path, key, apiId, model, content, }) {
|
|
60
|
+
return (transform) => {
|
|
61
|
+
const items = content.value.reduce((acc, fieldContent, index) => {
|
|
62
|
+
const itemPath = path.concat([
|
|
63
|
+
{ key: index.toString(), type: "Widget" },
|
|
64
|
+
]);
|
|
65
|
+
const transformedField = transform({
|
|
66
|
+
path: itemPath,
|
|
67
|
+
key: key,
|
|
68
|
+
apiId: apiId,
|
|
69
|
+
model: model,
|
|
70
|
+
content: fieldContent,
|
|
71
|
+
});
|
|
72
|
+
// Can happen if the transform function returns undefined to filter out a field
|
|
73
|
+
if (!transformedField)
|
|
74
|
+
return acc;
|
|
75
|
+
// If the transformed field is not a link content, we don't include it
|
|
76
|
+
if (!(0, LinkContent_1.isLinkContent)(transformedField))
|
|
77
|
+
return acc;
|
|
78
|
+
return acc.concat(transformedField);
|
|
79
|
+
}, []);
|
|
80
|
+
return transform({
|
|
81
|
+
path,
|
|
82
|
+
key,
|
|
83
|
+
apiId,
|
|
84
|
+
model,
|
|
85
|
+
content: {
|
|
86
|
+
__TYPE__: content.__TYPE__,
|
|
87
|
+
type: content.type,
|
|
88
|
+
value: items,
|
|
89
|
+
},
|
|
90
|
+
});
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
exports.traverseRepeatableContent = traverseRepeatableContent;
|