@prismicio/types-internal 0.3.3 → 1.0.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/customtypes/CustomType.d.ts +309 -311
- package/lib/customtypes/CustomType.js +6 -6
- package/lib/customtypes/Format.d.ts +4 -0
- package/lib/customtypes/Format.js +8 -0
- package/lib/customtypes/Section.d.ts +309 -309
- package/lib/customtypes/widgets/Group.d.ts +22 -23
- package/lib/customtypes/widgets/Group.js +2 -2
- package/lib/customtypes/widgets/UID.d.ts +1 -2
- package/lib/customtypes/widgets/UID.js +2 -2
- package/lib/customtypes/widgets/Widget.d.ts +353 -354
- package/lib/customtypes/widgets/Widget.js +3 -3
- package/lib/customtypes/widgets/WidgetTypes.d.ts +22 -22
- package/lib/customtypes/widgets/WidgetTypes.js +22 -23
- package/lib/customtypes/widgets/index.d.ts +1 -1
- package/lib/customtypes/widgets/index.js +1 -1
- package/lib/customtypes/widgets/nestable/BooleanField.d.ts +1 -2
- package/lib/customtypes/widgets/nestable/BooleanField.js +2 -2
- package/lib/customtypes/widgets/nestable/Color.d.ts +1 -2
- package/lib/customtypes/widgets/nestable/Color.js +2 -2
- package/lib/customtypes/widgets/nestable/Date.d.ts +1 -2
- package/lib/customtypes/widgets/nestable/Date.js +2 -2
- package/lib/customtypes/widgets/nestable/Embed.d.ts +1 -2
- package/lib/customtypes/widgets/nestable/Embed.js +2 -2
- package/lib/customtypes/widgets/nestable/GeoPoint.d.ts +1 -2
- package/lib/customtypes/widgets/nestable/GeoPoint.js +2 -2
- package/lib/customtypes/widgets/nestable/Image.d.ts +2 -3
- package/lib/customtypes/widgets/nestable/Image.js +3 -3
- package/lib/customtypes/widgets/nestable/IntegrationField.d.ts +1 -2
- package/lib/customtypes/widgets/nestable/IntegrationField.js +2 -2
- package/lib/customtypes/widgets/nestable/Link.d.ts +4 -5
- package/lib/customtypes/widgets/nestable/Link.js +3 -3
- package/lib/customtypes/widgets/nestable/NestableWidget.d.ts +21 -21
- package/lib/customtypes/widgets/nestable/Number.d.ts +1 -2
- package/lib/customtypes/widgets/nestable/Number.js +2 -2
- package/lib/customtypes/widgets/nestable/Range.d.ts +1 -2
- package/lib/customtypes/widgets/nestable/Range.js +2 -2
- package/lib/customtypes/widgets/nestable/RichText.d.ts +22 -22
- package/lib/customtypes/widgets/nestable/RichText.js +38 -39
- package/lib/customtypes/widgets/nestable/Select.d.ts +2 -3
- package/lib/customtypes/widgets/nestable/Select.js +3 -3
- package/lib/customtypes/widgets/nestable/Separator.d.ts +1 -2
- package/lib/customtypes/widgets/nestable/Separator.js +2 -2
- package/lib/customtypes/widgets/nestable/Text.d.ts +1 -2
- package/lib/customtypes/widgets/nestable/Text.js +2 -2
- package/lib/customtypes/widgets/nestable/Timestamp.d.ts +1 -2
- package/lib/customtypes/widgets/nestable/Timestamp.js +2 -2
- package/lib/customtypes/widgets/slices/CompositeSlice.d.ts +43 -44
- package/lib/customtypes/widgets/slices/CompositeSlice.js +2 -2
- package/lib/customtypes/widgets/slices/LegacySlice.d.ts +43 -43
- package/lib/customtypes/widgets/slices/SharedSlice.d.ts +86 -87
- package/lib/customtypes/widgets/slices/SharedSlice.js +3 -3
- package/lib/customtypes/widgets/slices/SharedSliceRef.d.ts +1 -2
- package/lib/customtypes/widgets/slices/SharedSliceRef.js +2 -2
- package/lib/customtypes/widgets/slices/Slices.d.ts +529 -531
- package/lib/customtypes/widgets/slices/Slices.js +6 -6
- package/lib/customtypes/widgets/slices/SlicesTypes.d.ts +5 -5
- package/lib/customtypes/widgets/slices/SlicesTypes.js +5 -6
- package/lib/customtypes/widgets/slices/index.d.ts +1 -1
- package/lib/customtypes/widgets/slices/index.js +1 -1
- package/lib/documents/widgets/index.d.ts +1 -0
- package/lib/documents/widgets/nestable/Link/index.d.ts +1 -0
- package/lib/documents/widgets/nestable/StructuredTextContent/Block.d.ts +16 -17
- package/lib/documents/widgets/nestable/StructuredTextContent/Block.js +1 -1
- package/package.json +1 -1
- package/src/customtypes/CustomType.ts +2 -2
- package/src/customtypes/widgets/Group.ts +1 -1
- package/src/customtypes/widgets/UID.ts +1 -1
- package/src/customtypes/widgets/Widget.ts +1 -1
- package/src/customtypes/widgets/WidgetTypes.ts +22 -22
- package/src/customtypes/widgets/index.ts +1 -1
- package/src/customtypes/widgets/nestable/BooleanField.ts +1 -1
- package/src/customtypes/widgets/nestable/Color.ts +1 -1
- package/src/customtypes/widgets/nestable/Date.ts +1 -1
- package/src/customtypes/widgets/nestable/Embed.ts +1 -1
- package/src/customtypes/widgets/nestable/GeoPoint.ts +1 -1
- package/src/customtypes/widgets/nestable/Image.ts +2 -2
- package/src/customtypes/widgets/nestable/IntegrationField.ts +1 -1
- package/src/customtypes/widgets/nestable/Link.ts +4 -4
- package/src/customtypes/widgets/nestable/Number.ts +1 -1
- package/src/customtypes/widgets/nestable/Range.ts +1 -1
- package/src/customtypes/widgets/nestable/RichText.ts +37 -35
- package/src/customtypes/widgets/nestable/Select.ts +4 -2
- package/src/customtypes/widgets/nestable/Separator.ts +1 -1
- package/src/customtypes/widgets/nestable/Text.ts +1 -1
- package/src/customtypes/widgets/nestable/Timestamp.ts +1 -1
- package/src/customtypes/widgets/slices/CompositeSlice.ts +1 -1
- package/src/customtypes/widgets/slices/SharedSlice.ts +2 -2
- package/src/customtypes/widgets/slices/SharedSliceRef.ts +1 -1
- package/src/customtypes/widgets/slices/Slices.ts +3 -3
- package/src/customtypes/widgets/slices/SlicesTypes.ts +5 -5
- package/src/customtypes/widgets/slices/index.ts +1 -1
- package/src/documents/widgets/index.ts +1 -5
- package/src/documents/widgets/nestable/Link/index.ts +2 -0
- package/src/documents/widgets/nestable/StructuredTextContent/Block.ts +1 -1
|
@@ -4,14 +4,14 @@ exports.Slices = exports.DynamicSlices = exports.StaticSlices = exports.slicesRe
|
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const t = (0, tslib_1.__importStar)(require("io-ts"));
|
|
6
6
|
const validators_1 = require("../../../validators");
|
|
7
|
-
const WidgetTypes_1 =
|
|
7
|
+
const WidgetTypes_1 = require("../WidgetTypes");
|
|
8
8
|
const CompositeSlice_1 = (0, tslib_1.__importDefault)(require("./CompositeSlice"));
|
|
9
9
|
const LegacySlice_1 = (0, tslib_1.__importDefault)(require("./LegacySlice"));
|
|
10
10
|
const SharedSlice_1 = require("./SharedSlice");
|
|
11
11
|
const SharedSliceRef_1 = (0, tslib_1.__importDefault)(require("./SharedSliceRef"));
|
|
12
|
-
const SlicesTypes_1 =
|
|
12
|
+
const SlicesTypes_1 = require("./SlicesTypes");
|
|
13
13
|
exports.SlicesLabels = t.union([
|
|
14
|
-
t.record(t.string, t.
|
|
14
|
+
t.record(t.string, t.readonlyArray(t.exact(t.intersection([
|
|
15
15
|
t.type({
|
|
16
16
|
name: t.string,
|
|
17
17
|
}),
|
|
@@ -34,7 +34,7 @@ exports.DynamicSlicesConfig = slicesConfigReader(SharedSliceRef_1.default);
|
|
|
34
34
|
const SlicesConfig = {
|
|
35
35
|
toStatic(config, sharedSlices) {
|
|
36
36
|
const choices = Object.entries(config.choices || {}).reduce((acc, [ref, slice]) => {
|
|
37
|
-
if (slice.type === SlicesTypes_1.
|
|
37
|
+
if (slice.type === SlicesTypes_1.SlicesTypes.SharedSlice) {
|
|
38
38
|
const sharedSlice = sharedSlices.get(ref);
|
|
39
39
|
if (sharedSlice)
|
|
40
40
|
return { ...acc, [ref]: sharedSlice };
|
|
@@ -52,8 +52,8 @@ function slicesReader(codec) {
|
|
|
52
52
|
return t.exact(t.intersection([
|
|
53
53
|
t.type({
|
|
54
54
|
type: t.union([
|
|
55
|
-
t.literal(WidgetTypes_1.
|
|
56
|
-
t.literal(WidgetTypes_1.
|
|
55
|
+
t.literal(WidgetTypes_1.WidgetTypes.Slices),
|
|
56
|
+
t.literal(WidgetTypes_1.WidgetTypes.LegacySlices),
|
|
57
57
|
]),
|
|
58
58
|
}),
|
|
59
59
|
t.partial({
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
declare
|
|
2
|
-
Slice
|
|
3
|
-
SharedSlice
|
|
4
|
-
}
|
|
5
|
-
export
|
|
1
|
+
export declare const SlicesTypes: {
|
|
2
|
+
readonly Slice: "Slice";
|
|
3
|
+
readonly SharedSlice: "SharedSlice";
|
|
4
|
+
};
|
|
5
|
+
export declare type SlicesTypes = typeof SlicesTypes[keyof typeof SlicesTypes];
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
exports.default = SlicesTypes;
|
|
3
|
+
exports.SlicesTypes = void 0;
|
|
4
|
+
exports.SlicesTypes = {
|
|
5
|
+
Slice: "Slice",
|
|
6
|
+
SharedSlice: "SharedSlice",
|
|
7
|
+
};
|
|
@@ -4,4 +4,4 @@ export * from "./SharedSlice";
|
|
|
4
4
|
export { default as SharedSliceRef } from "./SharedSliceRef";
|
|
5
5
|
export * as Slice from "./Slice";
|
|
6
6
|
export * as SliceZone from "./Slices";
|
|
7
|
-
export {
|
|
7
|
+
export { SlicesTypes } from "./SlicesTypes";
|
|
@@ -12,4 +12,4 @@ Object.defineProperty(exports, "SharedSliceRef", { enumerable: true, get: functi
|
|
|
12
12
|
exports.Slice = (0, tslib_1.__importStar)(require("./Slice"));
|
|
13
13
|
exports.SliceZone = (0, tslib_1.__importStar)(require("./Slices"));
|
|
14
14
|
var SlicesTypes_1 = require("./SlicesTypes");
|
|
15
|
-
Object.defineProperty(exports, "SlicesTypes", { enumerable: true, get: function () { return
|
|
15
|
+
Object.defineProperty(exports, "SlicesTypes", { enumerable: true, get: function () { return SlicesTypes_1.SlicesTypes; } });
|
|
@@ -28,6 +28,7 @@ export declare const WidgetTypes: {
|
|
|
28
28
|
readonly IntegrationFields: "IntegrationFieldsContent";
|
|
29
29
|
readonly Separator: "SeparatorContent";
|
|
30
30
|
};
|
|
31
|
+
export declare type WidgetTypes = typeof WidgetTypes[keyof typeof WidgetTypes];
|
|
31
32
|
export declare type WidgetKey = string;
|
|
32
33
|
export declare type WidgetContent = SlicesContent | StaticWidgetContent;
|
|
33
34
|
export declare const Widget: {
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import * as t from "io-ts";
|
|
2
|
-
import { RichTextNodeType } from "../../../../customtypes/widgets/nestable";
|
|
3
2
|
export declare const Meta: t.ExactC<t.IntersectionC<[t.PartialC<{
|
|
4
3
|
data: t.UnknownC;
|
|
5
4
|
}>, t.TypeC<{
|
|
6
5
|
start: t.NumberC;
|
|
7
6
|
end: t.NumberC;
|
|
8
|
-
type: t.KeyofC<{
|
|
7
|
+
type: t.UnionC<[t.KeyofC<{
|
|
9
8
|
heading1: null;
|
|
10
9
|
heading2: null;
|
|
11
10
|
heading3: null;
|
|
@@ -22,7 +21,7 @@ export declare const Meta: t.ExactC<t.IntersectionC<[t.PartialC<{
|
|
|
22
21
|
"list-item": null;
|
|
23
22
|
"o-list-item": null;
|
|
24
23
|
rtl: null;
|
|
25
|
-
}>;
|
|
24
|
+
}>, t.LiteralC<"label">]>;
|
|
26
25
|
}>]>>;
|
|
27
26
|
export declare type Meta = t.TypeOf<typeof Meta>;
|
|
28
27
|
export declare const Span: t.ExactC<t.IntersectionC<[t.PartialC<{
|
|
@@ -30,7 +29,7 @@ export declare const Span: t.ExactC<t.IntersectionC<[t.PartialC<{
|
|
|
30
29
|
}>, t.TypeC<{
|
|
31
30
|
start: t.NumberC;
|
|
32
31
|
end: t.NumberC;
|
|
33
|
-
type: t.KeyofC<{
|
|
32
|
+
type: t.UnionC<[t.KeyofC<{
|
|
34
33
|
heading1: null;
|
|
35
34
|
heading2: null;
|
|
36
35
|
heading3: null;
|
|
@@ -47,7 +46,7 @@ export declare const Span: t.ExactC<t.IntersectionC<[t.PartialC<{
|
|
|
47
46
|
"list-item": null;
|
|
48
47
|
"o-list-item": null;
|
|
49
48
|
rtl: null;
|
|
50
|
-
}>;
|
|
49
|
+
}>, t.LiteralC<"label">]>;
|
|
51
50
|
}>]>>;
|
|
52
51
|
export declare type Span = Meta;
|
|
53
52
|
export declare const ValidatedMetas: t.Type<({
|
|
@@ -55,16 +54,16 @@ export declare const ValidatedMetas: t.Type<({
|
|
|
55
54
|
} & {
|
|
56
55
|
start: number;
|
|
57
56
|
end: number;
|
|
58
|
-
type:
|
|
57
|
+
type: "label" | "paragraph" | "heading1" | "heading2" | "heading3" | "heading4" | "heading5" | "heading6" | "strong" | "em" | "preformatted" | "hyperlink" | "image" | "embed" | "list-item" | "o-list-item" | "rtl";
|
|
59
58
|
})[], ({
|
|
60
59
|
data?: unknown;
|
|
61
60
|
} & {
|
|
62
61
|
start: number;
|
|
63
62
|
end: number;
|
|
64
|
-
type:
|
|
63
|
+
type: "label" | "paragraph" | "heading1" | "heading2" | "heading3" | "heading4" | "heading5" | "heading6" | "strong" | "em" | "preformatted" | "hyperlink" | "image" | "embed" | "list-item" | "o-list-item" | "rtl";
|
|
65
64
|
})[], unknown>;
|
|
66
65
|
export declare const ImageBlock: t.ExactC<t.IntersectionC<[t.TypeC<{
|
|
67
|
-
type: t.LiteralC<
|
|
66
|
+
type: t.LiteralC<"image">;
|
|
68
67
|
data: t.IntersectionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
|
|
69
68
|
origin: t.ExactC<t.TypeC<{
|
|
70
69
|
id: t.StringC;
|
|
@@ -159,7 +158,7 @@ export declare const ImageBlock: t.ExactC<t.IntersectionC<[t.TypeC<{
|
|
|
159
158
|
export declare type ImageBlock = t.TypeOf<typeof ImageBlock>;
|
|
160
159
|
export declare function checkImageBlock(block: Block): block is ImageBlock;
|
|
161
160
|
export declare const EmbedBlock: t.ExactC<t.IntersectionC<[t.TypeC<{
|
|
162
|
-
type: t.LiteralC<
|
|
161
|
+
type: t.LiteralC<"embed">;
|
|
163
162
|
data: t.Type<import("../EmbedContent").EmbedContentO, unknown, unknown>;
|
|
164
163
|
}>, t.PartialC<{
|
|
165
164
|
label: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
|
|
@@ -168,7 +167,7 @@ export declare const EmbedBlock: t.ExactC<t.IntersectionC<[t.TypeC<{
|
|
|
168
167
|
export declare type EmbedBlock = t.TypeOf<typeof EmbedBlock>;
|
|
169
168
|
export declare function checkEmbedBlock(block: Block): block is EmbedBlock;
|
|
170
169
|
export declare const TextBlock: t.ExactC<t.IntersectionC<[t.TypeC<{
|
|
171
|
-
type: t.Type<
|
|
170
|
+
type: t.Type<"paragraph" | "heading1" | "heading2" | "heading3" | "heading4" | "heading5" | "heading6" | "strong" | "em" | "preformatted" | "hyperlink" | "image" | "embed" | "list-item" | "o-list-item" | "rtl", "paragraph" | "heading1" | "heading2" | "heading3" | "heading4" | "heading5" | "heading6" | "strong" | "em" | "preformatted" | "hyperlink" | "image" | "embed" | "list-item" | "o-list-item" | "rtl", unknown>;
|
|
172
171
|
content: t.IntersectionC<[t.TypeC<{
|
|
173
172
|
text: t.StringC;
|
|
174
173
|
}>, t.PartialC<{
|
|
@@ -177,13 +176,13 @@ export declare const TextBlock: t.ExactC<t.IntersectionC<[t.TypeC<{
|
|
|
177
176
|
} & {
|
|
178
177
|
start: number;
|
|
179
178
|
end: number;
|
|
180
|
-
type:
|
|
179
|
+
type: "label" | "paragraph" | "heading1" | "heading2" | "heading3" | "heading4" | "heading5" | "heading6" | "strong" | "em" | "preformatted" | "hyperlink" | "image" | "embed" | "list-item" | "o-list-item" | "rtl";
|
|
181
180
|
})[], ({
|
|
182
181
|
data?: unknown;
|
|
183
182
|
} & {
|
|
184
183
|
start: number;
|
|
185
184
|
end: number;
|
|
186
|
-
type:
|
|
185
|
+
type: "label" | "paragraph" | "heading1" | "heading2" | "heading3" | "heading4" | "heading5" | "heading6" | "strong" | "em" | "preformatted" | "hyperlink" | "image" | "embed" | "list-item" | "o-list-item" | "rtl";
|
|
187
186
|
})[], unknown>;
|
|
188
187
|
}>]>;
|
|
189
188
|
}>, t.PartialC<{
|
|
@@ -192,7 +191,7 @@ export declare const TextBlock: t.ExactC<t.IntersectionC<[t.TypeC<{
|
|
|
192
191
|
}>]>>;
|
|
193
192
|
export declare type TextBlock = t.TypeOf<typeof TextBlock>;
|
|
194
193
|
export declare const Block: t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
|
|
195
|
-
type: t.LiteralC<
|
|
194
|
+
type: t.LiteralC<"image">;
|
|
196
195
|
data: t.IntersectionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
|
|
197
196
|
origin: t.ExactC<t.TypeC<{
|
|
198
197
|
id: t.StringC;
|
|
@@ -284,13 +283,13 @@ export declare const Block: t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
|
|
|
284
283
|
label: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
|
|
285
284
|
direction: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
|
|
286
285
|
}>]>>, t.ExactC<t.IntersectionC<[t.TypeC<{
|
|
287
|
-
type: t.LiteralC<
|
|
286
|
+
type: t.LiteralC<"embed">;
|
|
288
287
|
data: t.Type<import("../EmbedContent").EmbedContentO, unknown, unknown>;
|
|
289
288
|
}>, t.PartialC<{
|
|
290
289
|
label: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
|
|
291
290
|
direction: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
|
|
292
291
|
}>]>>, t.ExactC<t.IntersectionC<[t.TypeC<{
|
|
293
|
-
type: t.Type<
|
|
292
|
+
type: t.Type<"paragraph" | "heading1" | "heading2" | "heading3" | "heading4" | "heading5" | "heading6" | "strong" | "em" | "preformatted" | "hyperlink" | "image" | "embed" | "list-item" | "o-list-item" | "rtl", "paragraph" | "heading1" | "heading2" | "heading3" | "heading4" | "heading5" | "heading6" | "strong" | "em" | "preformatted" | "hyperlink" | "image" | "embed" | "list-item" | "o-list-item" | "rtl", unknown>;
|
|
294
293
|
content: t.IntersectionC<[t.TypeC<{
|
|
295
294
|
text: t.StringC;
|
|
296
295
|
}>, t.PartialC<{
|
|
@@ -299,13 +298,13 @@ export declare const Block: t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
|
|
|
299
298
|
} & {
|
|
300
299
|
start: number;
|
|
301
300
|
end: number;
|
|
302
|
-
type:
|
|
301
|
+
type: "label" | "paragraph" | "heading1" | "heading2" | "heading3" | "heading4" | "heading5" | "heading6" | "strong" | "em" | "preformatted" | "hyperlink" | "image" | "embed" | "list-item" | "o-list-item" | "rtl";
|
|
303
302
|
})[], ({
|
|
304
303
|
data?: unknown;
|
|
305
304
|
} & {
|
|
306
305
|
start: number;
|
|
307
306
|
end: number;
|
|
308
|
-
type:
|
|
307
|
+
type: "label" | "paragraph" | "heading1" | "heading2" | "heading3" | "heading4" | "heading5" | "heading6" | "strong" | "em" | "preformatted" | "hyperlink" | "image" | "embed" | "list-item" | "o-list-item" | "rtl";
|
|
309
308
|
})[], unknown>;
|
|
310
309
|
}>]>;
|
|
311
310
|
}>, t.PartialC<{
|
package/package.json
CHANGED
|
@@ -7,9 +7,9 @@ import { DynamicSection, Sections, StaticSection } from "./Section"
|
|
|
7
7
|
import type { SharedSlice } from "./widgets/slices/SharedSlice"
|
|
8
8
|
import type { DynamicSlice } from "./widgets/slices/Slice"
|
|
9
9
|
import type { DynamicSlices } from "./widgets/slices/Slices"
|
|
10
|
-
import SlicesTypes from "./widgets/slices/SlicesTypes"
|
|
10
|
+
import { SlicesTypes } from "./widgets/slices/SlicesTypes"
|
|
11
11
|
import type { DynamicWidget } from "./widgets/Widget"
|
|
12
|
-
import WidgetTypes from "./widgets/WidgetTypes"
|
|
12
|
+
import { WidgetTypes } from "./widgets/WidgetTypes"
|
|
13
13
|
|
|
14
14
|
class CustomTypeSlicesError extends Error {
|
|
15
15
|
slices: Array<string>
|
|
@@ -2,7 +2,7 @@ import * as t from "io-ts"
|
|
|
2
2
|
|
|
3
3
|
import { StringOrNull } from "../../validators"
|
|
4
4
|
import NestableWidget from "./nestable/NestableWidget"
|
|
5
|
-
import WidgetTypes from "./WidgetTypes"
|
|
5
|
+
import { WidgetTypes } from "./WidgetTypes"
|
|
6
6
|
|
|
7
7
|
const GroupConfig = t.exact(
|
|
8
8
|
t.partial({
|
|
@@ -5,7 +5,7 @@ import NestableWidget from "./nestable/NestableWidget"
|
|
|
5
5
|
import type { SharedSlice } from "./slices/SharedSlice"
|
|
6
6
|
import { DynamicSlices, Slices, StaticSlices } from "./slices/Slices"
|
|
7
7
|
import UID from "./UID"
|
|
8
|
-
import WidgetTypes from "./WidgetTypes"
|
|
8
|
+
import { WidgetTypes } from "./WidgetTypes"
|
|
9
9
|
|
|
10
10
|
export function widgetReader<T extends StaticSlices | DynamicSlices>(
|
|
11
11
|
codec: t.Type<T, unknown>,
|
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
Text
|
|
3
|
-
RichText
|
|
4
|
-
Color
|
|
5
|
-
Image
|
|
6
|
-
Date
|
|
7
|
-
Timestamp
|
|
8
|
-
Number
|
|
9
|
-
Range
|
|
10
|
-
Select
|
|
11
|
-
Link
|
|
12
|
-
Embed
|
|
13
|
-
GeoPoint
|
|
14
|
-
Separator
|
|
15
|
-
UID
|
|
16
|
-
BooleanField
|
|
17
|
-
IntegrationField
|
|
18
|
-
Group
|
|
19
|
-
Slices
|
|
1
|
+
export const WidgetTypes = {
|
|
2
|
+
Text: "Text",
|
|
3
|
+
RichText: "StructuredText",
|
|
4
|
+
Color: "Color",
|
|
5
|
+
Image: "Image",
|
|
6
|
+
Date: "Date",
|
|
7
|
+
Timestamp: "Timestamp",
|
|
8
|
+
Number: "Number",
|
|
9
|
+
Range: "Range",
|
|
10
|
+
Select: "Select",
|
|
11
|
+
Link: "Link",
|
|
12
|
+
Embed: "Embed",
|
|
13
|
+
GeoPoint: "GeoPoint",
|
|
14
|
+
Separator: "Separator",
|
|
15
|
+
UID: "UID",
|
|
16
|
+
BooleanField: "Boolean",
|
|
17
|
+
IntegrationField: "IntegrationFields",
|
|
18
|
+
Group: "Group",
|
|
19
|
+
Slices: "Slices",
|
|
20
20
|
// Legacy type for slices
|
|
21
|
-
LegacySlices
|
|
22
|
-
}
|
|
21
|
+
LegacySlices: "Choice",
|
|
22
|
+
} as const
|
|
23
23
|
|
|
24
|
-
export
|
|
24
|
+
export type WidgetTypes = typeof WidgetTypes[keyof typeof WidgetTypes]
|
|
@@ -2,7 +2,7 @@ import * as t from "io-ts"
|
|
|
2
2
|
|
|
3
3
|
import { StringOrNull } from "../../../validators"
|
|
4
4
|
import ImageConstraint from "../shared/ImageConstraint"
|
|
5
|
-
import WidgetTypes from "../WidgetTypes"
|
|
5
|
+
import { WidgetTypes } from "../WidgetTypes"
|
|
6
6
|
|
|
7
7
|
const Thumbnail = t.exact(
|
|
8
8
|
t.intersection([
|
|
@@ -19,7 +19,7 @@ const ImageConfig = t.exact(
|
|
|
19
19
|
label: StringOrNull,
|
|
20
20
|
placeholder: t.string,
|
|
21
21
|
constraint: ImageConstraint,
|
|
22
|
-
thumbnails: t.
|
|
22
|
+
thumbnails: t.readonlyArray(Thumbnail),
|
|
23
23
|
}),
|
|
24
24
|
)
|
|
25
25
|
type ImageConfig = t.TypeOf<typeof ImageConfig>
|
|
@@ -3,7 +3,7 @@ import * as t from "io-ts"
|
|
|
3
3
|
import { withFallback } from "io-ts-types/lib/withFallback"
|
|
4
4
|
|
|
5
5
|
import { StringOrNull } from "../../../validators"
|
|
6
|
-
import WidgetTypes from "../WidgetTypes"
|
|
6
|
+
import { WidgetTypes } from "../WidgetTypes"
|
|
7
7
|
|
|
8
8
|
const arrayString = (
|
|
9
9
|
entries:
|
|
@@ -43,9 +43,9 @@ const plainString = (
|
|
|
43
43
|
return
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
const MasksArrayString = new t.Type<
|
|
46
|
+
const MasksArrayString = new t.Type<ReadonlyArray<string>, object, unknown>(
|
|
47
47
|
"MasksArrayString",
|
|
48
|
-
(u: unknown): u is
|
|
48
|
+
(u: unknown): u is ReadonlyArray<string> => {
|
|
49
49
|
return u instanceof Array
|
|
50
50
|
},
|
|
51
51
|
(u: unknown, context: t.Context) => {
|
|
@@ -73,7 +73,7 @@ const LinkConfig = t.exact(
|
|
|
73
73
|
]),
|
|
74
74
|
null,
|
|
75
75
|
),
|
|
76
|
-
customtypes: t.
|
|
76
|
+
customtypes: t.readonlyArray(t.string), // `customtypes` and `masks` are alternatives
|
|
77
77
|
masks: MasksArrayString,
|
|
78
78
|
tags: MasksArrayString,
|
|
79
79
|
allowTargetBlank: t.boolean,
|
|
@@ -2,7 +2,7 @@ import * as t from "io-ts"
|
|
|
2
2
|
import { NumberFromString } from "io-ts-types/lib/NumberFromString"
|
|
3
3
|
|
|
4
4
|
import { StringOrNull } from "../../../validators"
|
|
5
|
-
import WidgetTypes from "../WidgetTypes"
|
|
5
|
+
import { WidgetTypes } from "../WidgetTypes"
|
|
6
6
|
|
|
7
7
|
const NumberConfig = t.exact(
|
|
8
8
|
t.partial({
|
|
@@ -2,7 +2,7 @@ import * as t from "io-ts"
|
|
|
2
2
|
import { NumberFromString } from "io-ts-types/lib/NumberFromString"
|
|
3
3
|
|
|
4
4
|
import { StringOrNull } from "../../../validators"
|
|
5
|
-
import WidgetTypes from "../WidgetTypes"
|
|
5
|
+
import { WidgetTypes } from "../WidgetTypes"
|
|
6
6
|
|
|
7
7
|
const RangeConfig = t.exact(
|
|
8
8
|
t.partial({
|
|
@@ -3,28 +3,30 @@ import * as t from "io-ts"
|
|
|
3
3
|
|
|
4
4
|
import { StringOrNull } from "../../../validators"
|
|
5
5
|
import ImageConstraint from "../shared/ImageConstraint"
|
|
6
|
-
import WidgetTypes from "../WidgetTypes"
|
|
6
|
+
import { WidgetTypes } from "../WidgetTypes"
|
|
7
7
|
|
|
8
8
|
export const DEFAULT_OPTION = "paragraph"
|
|
9
9
|
|
|
10
|
-
export
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
10
|
+
export type RichTextNodeType =
|
|
11
|
+
typeof RichTextNodeType[keyof typeof RichTextNodeType]
|
|
12
|
+
export const RichTextNodeType = {
|
|
13
|
+
heading1: "heading1",
|
|
14
|
+
heading2: "heading2",
|
|
15
|
+
heading3: "heading3",
|
|
16
|
+
heading4: "heading4",
|
|
17
|
+
heading5: "heading5",
|
|
18
|
+
heading6: "heading6",
|
|
19
|
+
paragraph: "paragraph",
|
|
20
|
+
strong: "strong",
|
|
21
|
+
em: "em",
|
|
22
|
+
preformatted: "preformatted",
|
|
23
|
+
hyperlink: "hyperlink",
|
|
24
|
+
image: "image",
|
|
25
|
+
embed: "embed",
|
|
26
|
+
list: "list-item",
|
|
27
|
+
orderedList: "o-list-item",
|
|
28
|
+
rtl: "rtl",
|
|
29
|
+
} as const
|
|
28
30
|
|
|
29
31
|
export const RichTextNodeTypeCodec = t.keyof({
|
|
30
32
|
[RichTextNodeType.heading1]: null,
|
|
@@ -71,11 +73,11 @@ const RichTextOptions = new t.Type<string, string, unknown>(
|
|
|
71
73
|
const NoLabels = (
|
|
72
74
|
labels:
|
|
73
75
|
| string
|
|
74
|
-
| string
|
|
76
|
+
| ReadonlyArray<string>
|
|
75
77
|
| {
|
|
76
|
-
[x: string]: {
|
|
78
|
+
[x: string]: ReadonlyArray<{
|
|
77
79
|
name: string
|
|
78
|
-
}
|
|
80
|
+
}>
|
|
79
81
|
}
|
|
80
82
|
| null,
|
|
81
83
|
) => {
|
|
@@ -86,11 +88,11 @@ const NoLabels = (
|
|
|
86
88
|
const LabelsAsObject = (
|
|
87
89
|
labels:
|
|
88
90
|
| string
|
|
89
|
-
| string
|
|
91
|
+
| ReadonlyArray<string>
|
|
90
92
|
| {
|
|
91
|
-
[x: string]: {
|
|
93
|
+
[x: string]: ReadonlyArray<{
|
|
92
94
|
name: string
|
|
93
|
-
}
|
|
95
|
+
}>
|
|
94
96
|
}
|
|
95
97
|
| null,
|
|
96
98
|
) => {
|
|
@@ -119,11 +121,11 @@ const LabelsAsObject = (
|
|
|
119
121
|
const LabelsAsArray = (
|
|
120
122
|
labels:
|
|
121
123
|
| string
|
|
122
|
-
| string
|
|
124
|
+
| ReadonlyArray<string>
|
|
123
125
|
| {
|
|
124
|
-
[x: string]: {
|
|
126
|
+
[x: string]: ReadonlyArray<{
|
|
125
127
|
name: string
|
|
126
|
-
}
|
|
128
|
+
}>
|
|
127
129
|
}
|
|
128
130
|
| null,
|
|
129
131
|
) => {
|
|
@@ -140,11 +142,11 @@ const LabelsAsArray = (
|
|
|
140
142
|
const LabelsAsString = (
|
|
141
143
|
labels:
|
|
142
144
|
| string
|
|
143
|
-
| string
|
|
145
|
+
| ReadonlyArray<string>
|
|
144
146
|
| {
|
|
145
|
-
[x: string]: {
|
|
147
|
+
[x: string]: ReadonlyArray<{
|
|
146
148
|
name: string
|
|
147
|
-
}
|
|
149
|
+
}>
|
|
148
150
|
}
|
|
149
151
|
| null,
|
|
150
152
|
) => {
|
|
@@ -154,17 +156,17 @@ const LabelsAsString = (
|
|
|
154
156
|
return
|
|
155
157
|
}
|
|
156
158
|
|
|
157
|
-
const RichTextLabels = new t.Type<
|
|
159
|
+
const RichTextLabels = new t.Type<ReadonlyArray<string>, object, unknown>(
|
|
158
160
|
"RichTextLabels",
|
|
159
|
-
(u: unknown): u is
|
|
161
|
+
(u: unknown): u is ReadonlyArray<string> => {
|
|
160
162
|
return u instanceof Array
|
|
161
163
|
},
|
|
162
164
|
(u: unknown, context: t.Context) => {
|
|
163
165
|
const legacyValidator = t.record(
|
|
164
166
|
t.string,
|
|
165
|
-
t.
|
|
167
|
+
t.readonlyArray(t.record(t.literal("name"), t.string)),
|
|
166
168
|
)
|
|
167
|
-
const validator = t.
|
|
169
|
+
const validator = t.readonlyArray(t.string)
|
|
168
170
|
|
|
169
171
|
return either.chain(
|
|
170
172
|
t
|
|
@@ -5,14 +5,16 @@ import {
|
|
|
5
5
|
StringFromNumber,
|
|
6
6
|
StringOrNull,
|
|
7
7
|
} from "../../../validators"
|
|
8
|
-
import WidgetTypes from "../WidgetTypes"
|
|
8
|
+
import { WidgetTypes } from "../WidgetTypes"
|
|
9
9
|
|
|
10
10
|
const SelectConfig = t.exact(
|
|
11
11
|
t.partial({
|
|
12
12
|
label: StringOrNull,
|
|
13
13
|
placeholder: t.string,
|
|
14
14
|
default_value: t.string,
|
|
15
|
-
options: t.
|
|
15
|
+
options: t.readonlyArray(
|
|
16
|
+
t.union([t.string, StringFromNumber, StringFromBoolean]),
|
|
17
|
+
),
|
|
16
18
|
}),
|
|
17
19
|
)
|
|
18
20
|
type SelectConfig = t.TypeOf<typeof SelectConfig>
|