@prismicio/types-internal 2.9.0-alpha.0 → 2.9.0-alpha.2
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/content/Document.d.ts +19 -19
- package/lib/content/Document.js +11 -0
- package/lib/content/LegacyContentCtx.d.ts +2 -17
- package/lib/content/LegacyContentCtx.js +4 -1
- package/lib/content/fields/GroupContent.js +13 -0
- package/lib/content/fields/RepeatableContent.d.ts +4 -78
- package/lib/content/fields/RepeatableContent.js +10 -14
- package/lib/content/fields/WidgetContent.d.ts +18 -18
- package/lib/content/fields/index.d.ts +1 -0
- package/lib/content/fields/index.js +1 -0
- package/lib/content/fields/nestable/NestableContent.d.ts +6 -6
- package/lib/content/fields/nestable/NestableContent.js +5 -17
- 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/slices/Slice/CompositeSliceContent.d.ts +6 -6
- package/lib/content/fields/slices/Slice/RepeatableContent.d.ts +1 -1
- package/lib/content/fields/slices/Slice/SharedSliceContent.d.ts +6 -6
- package/lib/content/fields/slices/Slice/SharedSliceContent.js +20 -4
- package/lib/content/fields/slices/Slice/SimpleSliceContent.d.ts +5 -5
- package/lib/content/fields/slices/Slice/SlicePrimaryContent.d.ts +5 -5
- package/lib/content/fields/slices/Slice/index.d.ts +10 -10
- package/lib/content/fields/slices/SliceItem.d.ts +10 -10
- package/lib/content/fields/slices/SlicesContent.d.ts +15 -15
- package/lib/customtypes/widgets/Widget.d.ts +0 -15
- package/lib/customtypes/widgets/Widget.js +0 -15
- package/lib/customtypes/widgets/nestable/Link.d.ts +8 -0
- package/lib/customtypes/widgets/nestable/Link.js +6 -5
- package/lib/customtypes/widgets/nestable/NestableWidget.d.ts +1 -2
- package/lib/customtypes/widgets/nestable/NestableWidget.js +1 -18
- 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/content/Document.ts +12 -0
- package/src/content/LegacyContentCtx.ts +4 -1
- package/src/content/fields/GroupContent.ts +13 -0
- package/src/content/fields/RepeatableContent.ts +29 -38
- package/src/content/fields/index.ts +1 -0
- package/src/content/fields/nestable/NestableContent.ts +6 -20
- package/src/content/fields/slices/Slice/SharedSliceContent.ts +18 -0
- package/src/customtypes/widgets/Widget.ts +0 -15
- package/src/customtypes/widgets/nestable/Link.ts +7 -5
- package/src/customtypes/widgets/nestable/NestableWidget.ts +16 -34
|
@@ -427,7 +427,7 @@ export declare const Document: t.RecordC<t.Type<string, string, unknown>, t.Unio
|
|
|
427
427
|
__TYPE__: t.LiteralC<"SeparatorContent">;
|
|
428
428
|
}>>, t.ExactC<t.TypeC<{
|
|
429
429
|
__TYPE__: t.LiteralC<"RepeatableContent">;
|
|
430
|
-
type: t.
|
|
430
|
+
type: t.LiteralC<"Link">;
|
|
431
431
|
value: t.ArrayC<t.ExactC<t.TypeC<{
|
|
432
432
|
__TYPE__: t.LiteralC<"LinkContent">;
|
|
433
433
|
value: t.UnionC<[t.IntersectionC<[t.ExactC<t.TypeC<{
|
|
@@ -933,7 +933,7 @@ export declare const Document: t.RecordC<t.Type<string, string, unknown>, t.Unio
|
|
|
933
933
|
__TYPE__: t.LiteralC<"SeparatorContent">;
|
|
934
934
|
}>>, t.ExactC<t.TypeC<{
|
|
935
935
|
__TYPE__: t.LiteralC<"RepeatableContent">;
|
|
936
|
-
type: t.
|
|
936
|
+
type: t.LiteralC<"Link">;
|
|
937
937
|
value: t.ArrayC<t.ExactC<t.TypeC<{
|
|
938
938
|
__TYPE__: t.LiteralC<"LinkContent">;
|
|
939
939
|
value: t.UnionC<[t.IntersectionC<[t.ExactC<t.TypeC<{
|
|
@@ -1431,7 +1431,7 @@ export declare const Document: t.RecordC<t.Type<string, string, unknown>, t.Unio
|
|
|
1431
1431
|
__TYPE__: t.LiteralC<"SeparatorContent">;
|
|
1432
1432
|
}>>, t.ExactC<t.TypeC<{
|
|
1433
1433
|
__TYPE__: t.LiteralC<"RepeatableContent">;
|
|
1434
|
-
type: t.
|
|
1434
|
+
type: t.LiteralC<"Link">;
|
|
1435
1435
|
value: t.ArrayC<t.ExactC<t.TypeC<{
|
|
1436
1436
|
__TYPE__: t.LiteralC<"LinkContent">;
|
|
1437
1437
|
value: t.UnionC<[t.IntersectionC<[t.ExactC<t.TypeC<{
|
|
@@ -1931,7 +1931,7 @@ export declare const Document: t.RecordC<t.Type<string, string, unknown>, t.Unio
|
|
|
1931
1931
|
__TYPE__: t.LiteralC<"SeparatorContent">;
|
|
1932
1932
|
}>>, t.ExactC<t.TypeC<{
|
|
1933
1933
|
__TYPE__: t.LiteralC<"RepeatableContent">;
|
|
1934
|
-
type: t.
|
|
1934
|
+
type: t.LiteralC<"Link">;
|
|
1935
1935
|
value: t.ArrayC<t.ExactC<t.TypeC<{
|
|
1936
1936
|
__TYPE__: t.LiteralC<"LinkContent">;
|
|
1937
1937
|
value: t.UnionC<[t.IntersectionC<[t.ExactC<t.TypeC<{
|
|
@@ -2429,7 +2429,7 @@ export declare const Document: t.RecordC<t.Type<string, string, unknown>, t.Unio
|
|
|
2429
2429
|
__TYPE__: t.LiteralC<"SeparatorContent">;
|
|
2430
2430
|
}>>, t.ExactC<t.TypeC<{
|
|
2431
2431
|
__TYPE__: t.LiteralC<"RepeatableContent">;
|
|
2432
|
-
type: t.
|
|
2432
|
+
type: t.LiteralC<"Link">;
|
|
2433
2433
|
value: t.ArrayC<t.ExactC<t.TypeC<{
|
|
2434
2434
|
__TYPE__: t.LiteralC<"LinkContent">;
|
|
2435
2435
|
value: t.UnionC<[t.IntersectionC<[t.ExactC<t.TypeC<{
|
|
@@ -2926,7 +2926,7 @@ export declare const Document: t.RecordC<t.Type<string, string, unknown>, t.Unio
|
|
|
2926
2926
|
__TYPE__: t.LiteralC<"SeparatorContent">;
|
|
2927
2927
|
}>>, t.ExactC<t.TypeC<{
|
|
2928
2928
|
__TYPE__: t.LiteralC<"RepeatableContent">;
|
|
2929
|
-
type: t.
|
|
2929
|
+
type: t.LiteralC<"Link">;
|
|
2930
2930
|
value: t.ArrayC<t.ExactC<t.TypeC<{
|
|
2931
2931
|
__TYPE__: t.LiteralC<"LinkContent">;
|
|
2932
2932
|
value: t.UnionC<[t.IntersectionC<[t.ExactC<t.TypeC<{
|
|
@@ -3018,7 +3018,7 @@ declare function parseLegacyDocument(legacyDoc: unknown, customType: StaticCusto
|
|
|
3018
3018
|
}): Document | undefined;
|
|
3019
3019
|
declare function encodeToLegacyDocument(document: Document): DocumentLegacy;
|
|
3020
3020
|
export declare const DocumentLegacy: {
|
|
3021
|
-
_codec: (allTypes?: Map<string, "Boolean" | "Color" | "Date" | "Embed" | "GeoPoint" | "Image" | "IntegrationFields" | "Link" | "Number" | "Range" | "StructuredText" | "Select" | "Separator" | "Text" | "Timestamp" | "Group" | "Slice" | "SharedSlice" | "Choice" | "Slices" | "UID" | "Repeatable.
|
|
3021
|
+
_codec: (allTypes?: Map<string, "Boolean" | "Color" | "Date" | "Embed" | "GeoPoint" | "Image" | "IntegrationFields" | "Link" | "Number" | "Range" | "StructuredText" | "Select" | "Separator" | "Text" | "Timestamp" | "Group" | "Slice" | "SharedSlice" | "Choice" | "Slices" | "UID" | "Repeatable.Link"> | undefined) => t.Type<{
|
|
3022
3022
|
[x: string]: {
|
|
3023
3023
|
type: string;
|
|
3024
3024
|
__TYPE__: "EmptyContent";
|
|
@@ -3201,7 +3201,7 @@ export declare const DocumentLegacy: {
|
|
|
3201
3201
|
});
|
|
3202
3202
|
} | {
|
|
3203
3203
|
__TYPE__: "RepeatableContent";
|
|
3204
|
-
type: "
|
|
3204
|
+
type: "Link";
|
|
3205
3205
|
value: {
|
|
3206
3206
|
__TYPE__: "LinkContent";
|
|
3207
3207
|
value: ({
|
|
@@ -3617,7 +3617,7 @@ export declare const DocumentLegacy: {
|
|
|
3617
3617
|
});
|
|
3618
3618
|
} | {
|
|
3619
3619
|
__TYPE__: "RepeatableContent";
|
|
3620
|
-
type: "
|
|
3620
|
+
type: "Link";
|
|
3621
3621
|
value: {
|
|
3622
3622
|
__TYPE__: "LinkContent";
|
|
3623
3623
|
value: ({
|
|
@@ -4027,7 +4027,7 @@ export declare const DocumentLegacy: {
|
|
|
4027
4027
|
});
|
|
4028
4028
|
} | {
|
|
4029
4029
|
__TYPE__: "RepeatableContent";
|
|
4030
|
-
type: "
|
|
4030
|
+
type: "Link";
|
|
4031
4031
|
value: {
|
|
4032
4032
|
__TYPE__: "LinkContent";
|
|
4033
4033
|
value: ({
|
|
@@ -4438,7 +4438,7 @@ export declare const DocumentLegacy: {
|
|
|
4438
4438
|
});
|
|
4439
4439
|
} | {
|
|
4440
4440
|
__TYPE__: "RepeatableContent";
|
|
4441
|
-
type: "
|
|
4441
|
+
type: "Link";
|
|
4442
4442
|
value: {
|
|
4443
4443
|
__TYPE__: "LinkContent";
|
|
4444
4444
|
value: ({
|
|
@@ -4851,7 +4851,7 @@ export declare const DocumentLegacy: {
|
|
|
4851
4851
|
});
|
|
4852
4852
|
} | {
|
|
4853
4853
|
__TYPE__: "RepeatableContent";
|
|
4854
|
-
type: "
|
|
4854
|
+
type: "Link";
|
|
4855
4855
|
value: {
|
|
4856
4856
|
__TYPE__: "LinkContent";
|
|
4857
4857
|
value: ({
|
|
@@ -5262,7 +5262,7 @@ export declare const DocumentLegacy: {
|
|
|
5262
5262
|
});
|
|
5263
5263
|
} | {
|
|
5264
5264
|
__TYPE__: "RepeatableContent";
|
|
5265
|
-
type: "
|
|
5265
|
+
type: "Link";
|
|
5266
5266
|
value: {
|
|
5267
5267
|
__TYPE__: "LinkContent";
|
|
5268
5268
|
value: ({
|
|
@@ -5709,7 +5709,7 @@ export declare function migrateDocument(document: Document, customType: StaticCu
|
|
|
5709
5709
|
});
|
|
5710
5710
|
} | {
|
|
5711
5711
|
__TYPE__: "RepeatableContent";
|
|
5712
|
-
type: "
|
|
5712
|
+
type: "Link";
|
|
5713
5713
|
value: {
|
|
5714
5714
|
__TYPE__: "LinkContent";
|
|
5715
5715
|
value: ({
|
|
@@ -6125,7 +6125,7 @@ export declare function migrateDocument(document: Document, customType: StaticCu
|
|
|
6125
6125
|
});
|
|
6126
6126
|
} | {
|
|
6127
6127
|
__TYPE__: "RepeatableContent";
|
|
6128
|
-
type: "
|
|
6128
|
+
type: "Link";
|
|
6129
6129
|
value: {
|
|
6130
6130
|
__TYPE__: "LinkContent";
|
|
6131
6131
|
value: ({
|
|
@@ -6535,7 +6535,7 @@ export declare function migrateDocument(document: Document, customType: StaticCu
|
|
|
6535
6535
|
});
|
|
6536
6536
|
} | {
|
|
6537
6537
|
__TYPE__: "RepeatableContent";
|
|
6538
|
-
type: "
|
|
6538
|
+
type: "Link";
|
|
6539
6539
|
value: {
|
|
6540
6540
|
__TYPE__: "LinkContent";
|
|
6541
6541
|
value: ({
|
|
@@ -6946,7 +6946,7 @@ export declare function migrateDocument(document: Document, customType: StaticCu
|
|
|
6946
6946
|
});
|
|
6947
6947
|
} | {
|
|
6948
6948
|
__TYPE__: "RepeatableContent";
|
|
6949
|
-
type: "
|
|
6949
|
+
type: "Link";
|
|
6950
6950
|
value: {
|
|
6951
6951
|
__TYPE__: "LinkContent";
|
|
6952
6952
|
value: ({
|
|
@@ -7359,7 +7359,7 @@ export declare function migrateDocument(document: Document, customType: StaticCu
|
|
|
7359
7359
|
});
|
|
7360
7360
|
} | {
|
|
7361
7361
|
__TYPE__: "RepeatableContent";
|
|
7362
|
-
type: "
|
|
7362
|
+
type: "Link";
|
|
7363
7363
|
value: {
|
|
7364
7364
|
__TYPE__: "LinkContent";
|
|
7365
7365
|
value: ({
|
|
@@ -7770,7 +7770,7 @@ export declare function migrateDocument(document: Document, customType: StaticCu
|
|
|
7770
7770
|
});
|
|
7771
7771
|
} | {
|
|
7772
7772
|
__TYPE__: "RepeatableContent";
|
|
7773
|
-
type: "
|
|
7773
|
+
type: "Link";
|
|
7774
7774
|
value: {
|
|
7775
7775
|
__TYPE__: "LinkContent";
|
|
7776
7776
|
value: ({
|
package/lib/content/Document.js
CHANGED
|
@@ -158,6 +158,7 @@ function traverseDocument({ document, customType, }) {
|
|
|
158
158
|
{ key, type: "Widget" },
|
|
159
159
|
]);
|
|
160
160
|
const transformedWidget = (() => {
|
|
161
|
+
var _a;
|
|
161
162
|
switch (content.__TYPE__) {
|
|
162
163
|
case "SliceContentType":
|
|
163
164
|
return (0, fields_1.traverseSlices)({
|
|
@@ -176,6 +177,16 @@ function traverseDocument({ document, customType, }) {
|
|
|
176
177
|
model: (fieldModel === null || fieldModel === void 0 ? void 0 : fieldModel.type) === "Group" ? fieldModel : undefined,
|
|
177
178
|
content,
|
|
178
179
|
})(transformWidget);
|
|
180
|
+
case "RepeatableContent":
|
|
181
|
+
return (0, fields_1.traverseRepeatableContent)({
|
|
182
|
+
path,
|
|
183
|
+
key,
|
|
184
|
+
apiId: key,
|
|
185
|
+
model: (fieldModel === null || fieldModel === void 0 ? void 0 : fieldModel.type) === "Link" && ((_a = fieldModel.config) === null || _a === void 0 ? void 0 : _a.repeat)
|
|
186
|
+
? fieldModel
|
|
187
|
+
: undefined,
|
|
188
|
+
content,
|
|
189
|
+
})(transformWidget);
|
|
179
190
|
default:
|
|
180
191
|
return transformWidget({
|
|
181
192
|
path,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as t from "io-ts";
|
|
2
|
-
export declare const FieldOrSliceType: t.UnionC<[t.KeyofC<{
|
|
2
|
+
export declare const FieldOrSliceType: t.UnionC<[t.UnionC<[t.KeyofC<{
|
|
3
3
|
Color: null;
|
|
4
4
|
Boolean: null;
|
|
5
5
|
Number: null;
|
|
@@ -19,25 +19,10 @@ export declare const FieldOrSliceType: t.UnionC<[t.KeyofC<{
|
|
|
19
19
|
Group: null;
|
|
20
20
|
Slices: null;
|
|
21
21
|
Choice: null;
|
|
22
|
-
"Repeatable.Color": null;
|
|
23
|
-
"Repeatable.Boolean": null;
|
|
24
|
-
"Repeatable.Number": null;
|
|
25
|
-
"Repeatable.Embed": null;
|
|
26
|
-
"Repeatable.GeoPoint": null;
|
|
27
|
-
"Repeatable.Date": null;
|
|
28
|
-
"Repeatable.Range": null;
|
|
29
|
-
"Repeatable.StructuredText": null;
|
|
30
|
-
"Repeatable.Select": null;
|
|
31
|
-
"Repeatable.Separator": null;
|
|
32
|
-
"Repeatable.Text": null;
|
|
33
|
-
"Repeatable.Timestamp": null;
|
|
34
|
-
"Repeatable.Link": null;
|
|
35
|
-
"Repeatable.Image": null;
|
|
36
|
-
"Repeatable.IntegrationFields": null;
|
|
37
22
|
}>, t.KeyofC<{
|
|
38
23
|
Slice: null;
|
|
39
24
|
SharedSlice: null;
|
|
40
|
-
}>]>;
|
|
25
|
+
}>]>, t.LiteralC<"Repeatable.Link">]>;
|
|
41
26
|
export declare type FieldOrSliceType = t.TypeOf<typeof FieldOrSliceType>;
|
|
42
27
|
export declare class LegacyContentCtx {
|
|
43
28
|
fieldKey: string;
|
|
@@ -4,7 +4,10 @@ exports.defaultCtx = exports.getFieldCtx = exports.LegacyContentCtx = exports.Fi
|
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const t = (0, tslib_1.__importStar)(require("io-ts"));
|
|
6
6
|
const widgets_1 = require("../customtypes/widgets");
|
|
7
|
-
exports.FieldOrSliceType = t.union([
|
|
7
|
+
exports.FieldOrSliceType = t.union([
|
|
8
|
+
t.union([widgets_1.FieldType, widgets_1.SlicesTypes]),
|
|
9
|
+
t.literal("Repeatable.Link"),
|
|
10
|
+
]);
|
|
8
11
|
class LegacyContentCtx {
|
|
9
12
|
constructor(fieldKey, fieldPath, allTypes) {
|
|
10
13
|
Object.defineProperty(this, "fieldKey", {
|
|
@@ -10,6 +10,7 @@ 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");
|
|
13
14
|
const withDefaultValues_1 = require("./withDefaultValues");
|
|
14
15
|
exports.GroupItemContentType = "GroupItemContent";
|
|
15
16
|
exports.GroupContentType = "GroupContentType";
|
|
@@ -129,6 +130,7 @@ function traverseGroupItemsContent({ path, model, content, }) {
|
|
|
129
130
|
{ key: index.toString(), type: "GroupItem" },
|
|
130
131
|
]);
|
|
131
132
|
const groupItemFields = groupItem.value.reduce((acc, [fieldKey, fieldContent]) => {
|
|
133
|
+
var _a;
|
|
132
134
|
const fieldDef = model === null || model === void 0 ? void 0 : model[fieldKey];
|
|
133
135
|
let transformedField;
|
|
134
136
|
if ((!fieldDef || (fieldDef === null || fieldDef === void 0 ? void 0 : fieldDef.type) === customtypes_1.GroupFieldType) &&
|
|
@@ -141,6 +143,17 @@ function traverseGroupItemsContent({ path, model, content, }) {
|
|
|
141
143
|
content: fieldContent,
|
|
142
144
|
})(transform);
|
|
143
145
|
}
|
|
146
|
+
else if ((!fieldDef ||
|
|
147
|
+
((fieldDef === null || fieldDef === void 0 ? void 0 : fieldDef.type) === "Link" && ((_a = fieldDef.config) === null || _a === void 0 ? void 0 : _a.repeat))) &&
|
|
148
|
+
fieldContent.__TYPE__ === "RepeatableContent") {
|
|
149
|
+
transformedField = (0, RepeatableContent_1.traverseRepeatableContent)({
|
|
150
|
+
path: groupItemPath.concat([{ key: fieldKey, type: "Widget" }]),
|
|
151
|
+
key: fieldKey,
|
|
152
|
+
apiId: fieldKey,
|
|
153
|
+
model: fieldDef,
|
|
154
|
+
content: fieldContent,
|
|
155
|
+
})(transform);
|
|
156
|
+
}
|
|
144
157
|
else {
|
|
145
158
|
transformedField = transform({
|
|
146
159
|
path: groupItemPath.concat([{ key: fieldKey, type: "Widget" }]),
|
|
@@ -1,84 +1,10 @@
|
|
|
1
1
|
import * as t from "io-ts";
|
|
2
2
|
import type { ContentPath, TraverseWidgetContentFn } from "../../_internal/utils";
|
|
3
|
-
import {
|
|
3
|
+
import type { Link, NestableWidget } from "../../customtypes";
|
|
4
4
|
import type { LegacyContentCtx, WithTypes } from "../LegacyContentCtx";
|
|
5
|
-
export declare const RepeatableContentType: "RepeatableContent";
|
|
6
|
-
export declare const RepeatableFieldType: "Repeatable";
|
|
7
|
-
export declare const RepeatableItemContent: t.ExactC<t.TypeC<{
|
|
8
|
-
__TYPE__: t.LiteralC<"LinkContent">;
|
|
9
|
-
value: t.UnionC<[t.IntersectionC<[t.ExactC<t.TypeC<{
|
|
10
|
-
__TYPE__: t.LiteralC<"ImageLink">;
|
|
11
|
-
}>>, t.UnionC<[t.IntersectionC<[t.IntersectionC<[t.ExactC<t.TypeC<{
|
|
12
|
-
kind: t.StringC;
|
|
13
|
-
id: t.StringC;
|
|
14
|
-
url: t.StringC;
|
|
15
|
-
height: t.StringC;
|
|
16
|
-
width: t.StringC;
|
|
17
|
-
size: t.StringC;
|
|
18
|
-
name: t.StringC;
|
|
19
|
-
}>>, t.ExactC<t.PartialC<{
|
|
20
|
-
date: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
|
|
21
|
-
}>>]>, t.ExactC<t.PartialC<{
|
|
22
|
-
text: t.StringC;
|
|
23
|
-
}>>]>, t.ExactC<t.TypeC<{
|
|
24
|
-
kind: t.LiteralC<"image">;
|
|
25
|
-
text: t.StringC;
|
|
26
|
-
}>>]>]>, t.IntersectionC<[t.ExactC<t.TypeC<{
|
|
27
|
-
__TYPE__: t.LiteralC<"FileLink">;
|
|
28
|
-
}>>, t.UnionC<[t.IntersectionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
|
|
29
|
-
kind: t.StringC;
|
|
30
|
-
id: t.StringC;
|
|
31
|
-
url: t.StringC;
|
|
32
|
-
name: t.StringC;
|
|
33
|
-
size: t.StringC;
|
|
34
|
-
}>, t.PartialC<{
|
|
35
|
-
date: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
|
|
36
|
-
}>]>>, t.ExactC<t.PartialC<{
|
|
37
|
-
text: t.StringC;
|
|
38
|
-
}>>]>, t.ExactC<t.TypeC<{
|
|
39
|
-
kind: t.LiteralC<"file">;
|
|
40
|
-
text: t.StringC;
|
|
41
|
-
}>>]>]>, t.IntersectionC<[t.ExactC<t.TypeC<{
|
|
42
|
-
__TYPE__: t.LiteralC<"DocumentLink">;
|
|
43
|
-
}>>, t.UnionC<[t.IntersectionC<[t.ExactC<t.TypeC<{
|
|
44
|
-
id: t.Type<string, string, unknown>;
|
|
45
|
-
}>>, t.ExactC<t.PartialC<{
|
|
46
|
-
text: t.StringC;
|
|
47
|
-
}>>]>, t.ExactC<t.TypeC<{
|
|
48
|
-
kind: t.LiteralC<"document">;
|
|
49
|
-
text: t.StringC;
|
|
50
|
-
}>>]>]>, t.IntersectionC<[t.ExactC<t.TypeC<{
|
|
51
|
-
__TYPE__: t.LiteralC<"ExternalLink">;
|
|
52
|
-
}>>, t.UnionC<[t.IntersectionC<[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.PartialC<{
|
|
63
|
-
text: t.StringC;
|
|
64
|
-
}>>]>, t.ExactC<t.TypeC<{
|
|
65
|
-
kind: t.LiteralC<"web">;
|
|
66
|
-
text: t.StringC;
|
|
67
|
-
}>>]>]>, t.IntersectionC<[t.ExactC<t.TypeC<{
|
|
68
|
-
__TYPE__: t.LiteralC<"MediaLink">;
|
|
69
|
-
}>>, t.ExactC<t.TypeC<{
|
|
70
|
-
kind: t.LiteralC<"media">;
|
|
71
|
-
text: t.StringC;
|
|
72
|
-
}>>]>, t.IntersectionC<[t.ExactC<t.TypeC<{
|
|
73
|
-
__TYPE__: t.LiteralC<"AnyLink">;
|
|
74
|
-
}>>, t.ExactC<t.TypeC<{
|
|
75
|
-
text: t.StringC;
|
|
76
|
-
}>>]>]>;
|
|
77
|
-
}>>;
|
|
78
|
-
export declare type RepeatableItemContent = t.TypeOf<typeof RepeatableItemContent>;
|
|
79
5
|
export declare const RepeatableContent: t.ExactC<t.TypeC<{
|
|
80
6
|
__TYPE__: t.LiteralC<"RepeatableContent">;
|
|
81
|
-
type: t.
|
|
7
|
+
type: t.LiteralC<"Link">;
|
|
82
8
|
value: t.ArrayC<t.ExactC<t.TypeC<{
|
|
83
9
|
__TYPE__: t.LiteralC<"LinkContent">;
|
|
84
10
|
value: t.UnionC<[t.IntersectionC<[t.ExactC<t.TypeC<{
|
|
@@ -154,7 +80,7 @@ export declare const RepeatableContent: t.ExactC<t.TypeC<{
|
|
|
154
80
|
export declare type RepeatableContent = t.TypeOf<typeof RepeatableContent>;
|
|
155
81
|
export declare const isRepeatableContent: t.Is<{
|
|
156
82
|
__TYPE__: "RepeatableContent";
|
|
157
|
-
type: "
|
|
83
|
+
type: "Link";
|
|
158
84
|
value: {
|
|
159
85
|
__TYPE__: "LinkContent";
|
|
160
86
|
value: ({
|
|
@@ -225,7 +151,7 @@ export declare const isRepeatableContent: t.Is<{
|
|
|
225
151
|
});
|
|
226
152
|
}[];
|
|
227
153
|
}>;
|
|
228
|
-
export declare const RepeatableLegacy: (ctx: LegacyContentCtx, fieldType:
|
|
154
|
+
export declare const RepeatableLegacy: (ctx: LegacyContentCtx, fieldType: "Link") => t.Type<RepeatableContent, WithTypes<Array<unknown>>, unknown>;
|
|
229
155
|
export declare type RepeatableCustomType = Link;
|
|
230
156
|
export declare function traverseRepeatableContent({ path, key, apiId, model, content, }: {
|
|
231
157
|
path: ContentPath;
|
|
@@ -1,28 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.traverseRepeatableContent = exports.RepeatableLegacy = exports.isRepeatableContent = exports.RepeatableContent =
|
|
3
|
+
exports.traverseRepeatableContent = exports.RepeatableLegacy = exports.isRepeatableContent = exports.RepeatableContent = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const fp_ts_1 = require("fp-ts");
|
|
6
6
|
const Either_1 = require("fp-ts/lib/Either");
|
|
7
7
|
const function_1 = require("fp-ts/lib/function");
|
|
8
8
|
const t = (0, tslib_1.__importStar)(require("io-ts"));
|
|
9
|
-
const customtypes_1 = require("../../customtypes");
|
|
10
9
|
const nestable_1 = require("./nestable");
|
|
11
|
-
exports.RepeatableContentType = "RepeatableContent";
|
|
12
|
-
exports.RepeatableFieldType = "Repeatable";
|
|
13
|
-
exports.RepeatableItemContent = nestable_1.LinkContent;
|
|
14
10
|
exports.RepeatableContent = t.strict({
|
|
15
|
-
__TYPE__: t.literal(
|
|
16
|
-
type:
|
|
17
|
-
|
|
18
|
-
value: t.array(exports.RepeatableItemContent),
|
|
11
|
+
__TYPE__: t.literal("RepeatableContent"),
|
|
12
|
+
type: t.literal("Link"),
|
|
13
|
+
value: t.array(nestable_1.LinkContent),
|
|
19
14
|
});
|
|
20
15
|
exports.isRepeatableContent = exports.RepeatableContent.is;
|
|
21
16
|
const RepeatableLegacy = (ctx, fieldType) => {
|
|
22
|
-
const codecDecode = t.array(t.unknown);
|
|
23
|
-
const codecEncode = t.array(exports.RepeatableItemContent);
|
|
24
17
|
return new t.Type("RepeatableLegacy", exports.isRepeatableContent, (items) => {
|
|
25
|
-
const parsed = (0, function_1.pipe)(
|
|
18
|
+
const parsed = (0, function_1.pipe)(t.array(t.unknown).decode(items), fp_ts_1.either.map((items) => {
|
|
26
19
|
const parsedItems = items.reduce((acc, item) => {
|
|
27
20
|
let result;
|
|
28
21
|
switch (fieldType) {
|
|
@@ -39,12 +32,12 @@ const RepeatableLegacy = (ctx, fieldType) => {
|
|
|
39
32
|
return {
|
|
40
33
|
value: parsedItems,
|
|
41
34
|
type: fieldType,
|
|
42
|
-
__TYPE__:
|
|
35
|
+
__TYPE__: "RepeatableContent",
|
|
43
36
|
};
|
|
44
37
|
}));
|
|
45
38
|
return parsed;
|
|
46
39
|
}, (r) => {
|
|
47
|
-
const res =
|
|
40
|
+
const res = t.array(nestable_1.LinkContent).encode(r.value);
|
|
48
41
|
const encodedItems = res.reduce((acc, item) => {
|
|
49
42
|
let encoded;
|
|
50
43
|
switch (item.__TYPE__) {
|
|
@@ -79,6 +72,9 @@ function traverseRepeatableContent({ path, key, apiId, model, content, }) {
|
|
|
79
72
|
// Can happen if the transform function returns undefined to filter out a field
|
|
80
73
|
if (!transformedField)
|
|
81
74
|
return acc;
|
|
75
|
+
// If the transformed field is not a link content, we don't include it
|
|
76
|
+
if (!(0, nestable_1.isLinkContent)(transformedField))
|
|
77
|
+
return acc;
|
|
82
78
|
return acc.concat(transformedField);
|
|
83
79
|
}, []);
|
|
84
80
|
return transform({
|
|
@@ -424,7 +424,7 @@ export declare const WidgetContent: t.UnionC<[t.Type<GroupContent, GroupContent,
|
|
|
424
424
|
__TYPE__: t.LiteralC<"SeparatorContent">;
|
|
425
425
|
}>>, t.ExactC<t.TypeC<{
|
|
426
426
|
__TYPE__: t.LiteralC<"RepeatableContent">;
|
|
427
|
-
type: t.
|
|
427
|
+
type: t.LiteralC<"Link">;
|
|
428
428
|
value: t.ArrayC<t.ExactC<t.TypeC<{
|
|
429
429
|
__TYPE__: t.LiteralC<"LinkContent">;
|
|
430
430
|
value: t.UnionC<[t.IntersectionC<[t.ExactC<t.TypeC<{
|
|
@@ -930,7 +930,7 @@ export declare const WidgetContent: t.UnionC<[t.Type<GroupContent, GroupContent,
|
|
|
930
930
|
__TYPE__: t.LiteralC<"SeparatorContent">;
|
|
931
931
|
}>>, t.ExactC<t.TypeC<{
|
|
932
932
|
__TYPE__: t.LiteralC<"RepeatableContent">;
|
|
933
|
-
type: t.
|
|
933
|
+
type: t.LiteralC<"Link">;
|
|
934
934
|
value: t.ArrayC<t.ExactC<t.TypeC<{
|
|
935
935
|
__TYPE__: t.LiteralC<"LinkContent">;
|
|
936
936
|
value: t.UnionC<[t.IntersectionC<[t.ExactC<t.TypeC<{
|
|
@@ -1428,7 +1428,7 @@ export declare const WidgetContent: t.UnionC<[t.Type<GroupContent, GroupContent,
|
|
|
1428
1428
|
__TYPE__: t.LiteralC<"SeparatorContent">;
|
|
1429
1429
|
}>>, t.ExactC<t.TypeC<{
|
|
1430
1430
|
__TYPE__: t.LiteralC<"RepeatableContent">;
|
|
1431
|
-
type: t.
|
|
1431
|
+
type: t.LiteralC<"Link">;
|
|
1432
1432
|
value: t.ArrayC<t.ExactC<t.TypeC<{
|
|
1433
1433
|
__TYPE__: t.LiteralC<"LinkContent">;
|
|
1434
1434
|
value: t.UnionC<[t.IntersectionC<[t.ExactC<t.TypeC<{
|
|
@@ -1928,7 +1928,7 @@ export declare const WidgetContent: t.UnionC<[t.Type<GroupContent, GroupContent,
|
|
|
1928
1928
|
__TYPE__: t.LiteralC<"SeparatorContent">;
|
|
1929
1929
|
}>>, t.ExactC<t.TypeC<{
|
|
1930
1930
|
__TYPE__: t.LiteralC<"RepeatableContent">;
|
|
1931
|
-
type: t.
|
|
1931
|
+
type: t.LiteralC<"Link">;
|
|
1932
1932
|
value: t.ArrayC<t.ExactC<t.TypeC<{
|
|
1933
1933
|
__TYPE__: t.LiteralC<"LinkContent">;
|
|
1934
1934
|
value: t.UnionC<[t.IntersectionC<[t.ExactC<t.TypeC<{
|
|
@@ -2426,7 +2426,7 @@ export declare const WidgetContent: t.UnionC<[t.Type<GroupContent, GroupContent,
|
|
|
2426
2426
|
__TYPE__: t.LiteralC<"SeparatorContent">;
|
|
2427
2427
|
}>>, t.ExactC<t.TypeC<{
|
|
2428
2428
|
__TYPE__: t.LiteralC<"RepeatableContent">;
|
|
2429
|
-
type: t.
|
|
2429
|
+
type: t.LiteralC<"Link">;
|
|
2430
2430
|
value: t.ArrayC<t.ExactC<t.TypeC<{
|
|
2431
2431
|
__TYPE__: t.LiteralC<"LinkContent">;
|
|
2432
2432
|
value: t.UnionC<[t.IntersectionC<[t.ExactC<t.TypeC<{
|
|
@@ -2923,7 +2923,7 @@ export declare const WidgetContent: t.UnionC<[t.Type<GroupContent, GroupContent,
|
|
|
2923
2923
|
__TYPE__: t.LiteralC<"SeparatorContent">;
|
|
2924
2924
|
}>>, t.ExactC<t.TypeC<{
|
|
2925
2925
|
__TYPE__: t.LiteralC<"RepeatableContent">;
|
|
2926
|
-
type: t.
|
|
2926
|
+
type: t.LiteralC<"Link">;
|
|
2927
2927
|
value: t.ArrayC<t.ExactC<t.TypeC<{
|
|
2928
2928
|
__TYPE__: t.LiteralC<"LinkContent">;
|
|
2929
2929
|
value: t.UnionC<[t.IntersectionC<[t.ExactC<t.TypeC<{
|
|
@@ -3180,7 +3180,7 @@ export declare const isWidgetContent: (u: unknown) => u is {
|
|
|
3180
3180
|
});
|
|
3181
3181
|
} | {
|
|
3182
3182
|
__TYPE__: "RepeatableContent";
|
|
3183
|
-
type: "
|
|
3183
|
+
type: "Link";
|
|
3184
3184
|
value: {
|
|
3185
3185
|
__TYPE__: "LinkContent";
|
|
3186
3186
|
value: ({
|
|
@@ -3596,7 +3596,7 @@ export declare const isWidgetContent: (u: unknown) => u is {
|
|
|
3596
3596
|
});
|
|
3597
3597
|
} | {
|
|
3598
3598
|
__TYPE__: "RepeatableContent";
|
|
3599
|
-
type: "
|
|
3599
|
+
type: "Link";
|
|
3600
3600
|
value: {
|
|
3601
3601
|
__TYPE__: "LinkContent";
|
|
3602
3602
|
value: ({
|
|
@@ -4006,7 +4006,7 @@ export declare const isWidgetContent: (u: unknown) => u is {
|
|
|
4006
4006
|
});
|
|
4007
4007
|
} | {
|
|
4008
4008
|
__TYPE__: "RepeatableContent";
|
|
4009
|
-
type: "
|
|
4009
|
+
type: "Link";
|
|
4010
4010
|
value: {
|
|
4011
4011
|
__TYPE__: "LinkContent";
|
|
4012
4012
|
value: ({
|
|
@@ -4417,7 +4417,7 @@ export declare const isWidgetContent: (u: unknown) => u is {
|
|
|
4417
4417
|
});
|
|
4418
4418
|
} | {
|
|
4419
4419
|
__TYPE__: "RepeatableContent";
|
|
4420
|
-
type: "
|
|
4420
|
+
type: "Link";
|
|
4421
4421
|
value: {
|
|
4422
4422
|
__TYPE__: "LinkContent";
|
|
4423
4423
|
value: ({
|
|
@@ -4830,7 +4830,7 @@ export declare const isWidgetContent: (u: unknown) => u is {
|
|
|
4830
4830
|
});
|
|
4831
4831
|
} | {
|
|
4832
4832
|
__TYPE__: "RepeatableContent";
|
|
4833
|
-
type: "
|
|
4833
|
+
type: "Link";
|
|
4834
4834
|
value: {
|
|
4835
4835
|
__TYPE__: "LinkContent";
|
|
4836
4836
|
value: ({
|
|
@@ -5241,7 +5241,7 @@ export declare const isWidgetContent: (u: unknown) => u is {
|
|
|
5241
5241
|
});
|
|
5242
5242
|
} | {
|
|
5243
5243
|
__TYPE__: "RepeatableContent";
|
|
5244
|
-
type: "
|
|
5244
|
+
type: "Link";
|
|
5245
5245
|
value: {
|
|
5246
5246
|
__TYPE__: "LinkContent";
|
|
5247
5247
|
value: ({
|
|
@@ -5656,7 +5656,7 @@ export declare const WidgetLegacy: (ctx: LegacyContentCtx) => {
|
|
|
5656
5656
|
});
|
|
5657
5657
|
}> | import("fp-ts/lib/Either").Right<{
|
|
5658
5658
|
__TYPE__: "RepeatableContent";
|
|
5659
|
-
type: "
|
|
5659
|
+
type: "Link";
|
|
5660
5660
|
value: {
|
|
5661
5661
|
__TYPE__: "LinkContent";
|
|
5662
5662
|
value: ({
|
|
@@ -6072,7 +6072,7 @@ export declare const WidgetLegacy: (ctx: LegacyContentCtx) => {
|
|
|
6072
6072
|
});
|
|
6073
6073
|
} | {
|
|
6074
6074
|
__TYPE__: "RepeatableContent";
|
|
6075
|
-
type: "
|
|
6075
|
+
type: "Link";
|
|
6076
6076
|
value: {
|
|
6077
6077
|
__TYPE__: "LinkContent";
|
|
6078
6078
|
value: ({
|
|
@@ -6482,7 +6482,7 @@ export declare const WidgetLegacy: (ctx: LegacyContentCtx) => {
|
|
|
6482
6482
|
});
|
|
6483
6483
|
} | {
|
|
6484
6484
|
__TYPE__: "RepeatableContent";
|
|
6485
|
-
type: "
|
|
6485
|
+
type: "Link";
|
|
6486
6486
|
value: {
|
|
6487
6487
|
__TYPE__: "LinkContent";
|
|
6488
6488
|
value: ({
|
|
@@ -6893,7 +6893,7 @@ export declare const WidgetLegacy: (ctx: LegacyContentCtx) => {
|
|
|
6893
6893
|
});
|
|
6894
6894
|
} | {
|
|
6895
6895
|
__TYPE__: "RepeatableContent";
|
|
6896
|
-
type: "
|
|
6896
|
+
type: "Link";
|
|
6897
6897
|
value: {
|
|
6898
6898
|
__TYPE__: "LinkContent";
|
|
6899
6899
|
value: ({
|
|
@@ -7306,7 +7306,7 @@ export declare const WidgetLegacy: (ctx: LegacyContentCtx) => {
|
|
|
7306
7306
|
});
|
|
7307
7307
|
} | {
|
|
7308
7308
|
__TYPE__: "RepeatableContent";
|
|
7309
|
-
type: "
|
|
7309
|
+
type: "Link";
|
|
7310
7310
|
value: {
|
|
7311
7311
|
__TYPE__: "LinkContent";
|
|
7312
7312
|
value: ({
|
|
@@ -7717,7 +7717,7 @@ export declare const WidgetLegacy: (ctx: LegacyContentCtx) => {
|
|
|
7717
7717
|
});
|
|
7718
7718
|
} | {
|
|
7719
7719
|
__TYPE__: "RepeatableContent";
|
|
7720
|
-
type: "
|
|
7720
|
+
type: "Link";
|
|
7721
7721
|
value: {
|
|
7722
7722
|
__TYPE__: "LinkContent";
|
|
7723
7723
|
value: ({
|
|
@@ -4,6 +4,7 @@ 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);
|
|
7
8
|
(0, tslib_1.__exportStar)(require("./slices"), exports);
|
|
8
9
|
(0, tslib_1.__exportStar)(require("./UIDContent"), exports);
|
|
9
10
|
(0, tslib_1.__exportStar)(require("./WidgetContent"), exports);
|