@prismicio/types-internal 0.2.2 → 0.2.3
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 +2 -20
- package/lib/customtypes/CustomType.js +33 -25
- package/lib/customtypes/Format.js +5 -2
- package/lib/customtypes/Section.d.ts +3 -30
- package/lib/customtypes/Section.js +14 -9
- package/lib/customtypes/index.js +9 -4
- package/lib/customtypes/widgets/Group.js +12 -9
- package/lib/customtypes/widgets/UID.js +10 -7
- package/lib/customtypes/widgets/Widget.d.ts +3 -30
- package/lib/customtypes/widgets/Widget.js +19 -14
- package/lib/customtypes/widgets/WidgetTypes.js +3 -1
- package/lib/customtypes/widgets/index.js +14 -7
- package/lib/customtypes/widgets/nestable/BooleanField.js +9 -6
- package/lib/customtypes/widgets/nestable/Color.js +10 -7
- package/lib/customtypes/widgets/nestable/Date.js +10 -7
- package/lib/customtypes/widgets/nestable/Embed.js +10 -7
- package/lib/customtypes/widgets/nestable/GeoPoint.js +10 -7
- package/lib/customtypes/widgets/nestable/Image.js +13 -10
- package/lib/customtypes/widgets/nestable/IntegrationField.js +10 -7
- package/lib/customtypes/widgets/nestable/Link.js +14 -11
- package/lib/customtypes/widgets/nestable/NestableWidget.js +35 -32
- package/lib/customtypes/widgets/nestable/Number.js +14 -11
- package/lib/customtypes/widgets/nestable/Range.js +14 -11
- package/lib/customtypes/widgets/nestable/RichText.js +15 -12
- package/lib/customtypes/widgets/nestable/Select.js +11 -8
- package/lib/customtypes/widgets/nestable/Separator.js +9 -6
- package/lib/customtypes/widgets/nestable/Text.js +10 -7
- package/lib/customtypes/widgets/nestable/Timestamp.js +10 -7
- package/lib/customtypes/widgets/nestable/index.js +36 -15
- package/lib/customtypes/widgets/shared/ImageConstraint.js +12 -9
- package/lib/customtypes/widgets/shared/index.js +8 -1
- package/lib/customtypes/widgets/slices/CompositeSlice.js +13 -10
- package/lib/customtypes/widgets/slices/LegacySlice.d.ts +1 -10
- package/lib/customtypes/widgets/slices/LegacySlice.js +8 -6
- package/lib/customtypes/widgets/slices/SharedSlice.js +12 -9
- package/lib/customtypes/widgets/slices/SharedSliceRef.js +7 -4
- package/lib/customtypes/widgets/slices/Slice.js +2 -1
- package/lib/customtypes/widgets/slices/Slices.d.ts +6 -60
- package/lib/customtypes/widgets/slices/Slices.js +33 -27
- package/lib/customtypes/widgets/slices/SlicesTypes.js +3 -1
- package/lib/customtypes/widgets/slices/index.js +16 -7
- package/lib/documents/DocumentData.js +7 -4
- package/lib/documents/index.js +7 -2
- package/lib/documents/widgets/EmptyContent.js +6 -3
- package/lib/documents/widgets/GroupContent.js +14 -10
- package/lib/documents/widgets/SimpleWidgetContent.js +32 -27
- package/lib/documents/widgets/StaticWidgetContent.js +11 -8
- package/lib/documents/widgets/UIDContent.js +8 -4
- package/lib/documents/widgets/index.js +27 -22
- package/lib/documents/widgets/nestable/BooleanContent.js +10 -6
- package/lib/documents/widgets/nestable/EmbedContent.js +24 -20
- package/lib/documents/widgets/nestable/FieldContent.js +10 -6
- package/lib/documents/widgets/nestable/GeoPointContent.js +9 -5
- package/lib/documents/widgets/nestable/ImageContent.js +16 -12
- package/lib/documents/widgets/nestable/IntegrationFieldsContent.js +10 -6
- package/lib/documents/widgets/nestable/Link/DocumentLink.js +12 -7
- package/lib/documents/widgets/nestable/Link/ExternalLink.js +15 -10
- package/lib/documents/widgets/nestable/Link/FileLink.js +15 -10
- package/lib/documents/widgets/nestable/Link/ImageLink.js +14 -9
- package/lib/documents/widgets/nestable/Link/LinkContent.js +13 -9
- package/lib/documents/widgets/nestable/Link/index.js +33 -24
- package/lib/documents/widgets/nestable/SeparatorContent.js +5 -2
- package/lib/documents/widgets/nestable/StructuredTextContent/Block.js +39 -33
- package/lib/documents/widgets/nestable/StructuredTextContent/index.js +11 -7
- package/lib/documents/widgets/nestable/index.js +39 -28
- package/lib/documents/widgets/slices/CompositeSliceContent.js +13 -9
- package/lib/documents/widgets/slices/SharedSliceContent.js +16 -12
- package/lib/documents/widgets/slices/SimpleSliceContent.js +6 -2
- package/lib/documents/widgets/slices/SliceWidgetContent.js +12 -8
- package/lib/documents/widgets/slices/SlicesContent.js +17 -13
- package/lib/documents/widgets/slices/index.js +8 -5
- package/lib/index.js +7 -3
- package/lib/validators/DateFromString.js +7 -4
- package/lib/validators/DateFromStringOrNumber.js +7 -4
- package/lib/validators/DateFromTsMs.js +7 -4
- package/lib/validators/IntFromNumber.js +7 -4
- package/lib/validators/IntFromPixels.js +7 -4
- package/lib/validators/NonEmptyString.js +6 -3
- package/lib/validators/NonEmptyStringOrNull.js +10 -7
- package/lib/validators/NumberOrNull.js +6 -3
- package/lib/validators/StringFromBoolean.js +7 -4
- package/lib/validators/StringFromNumber.js +7 -4
- package/lib/validators/StringOrNull.js +6 -3
- package/lib/validators/function.js +28 -15
- package/lib/validators/index.js +27 -12
- package/package.json +1 -1
- package/src/customtypes/widgets/slices/LegacySlice.ts +1 -2
|
@@ -1,27 +1,30 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const t = (0, tslib_1.__importStar)(require("io-ts"));
|
|
5
|
+
const withFallback_1 = require("io-ts-types/lib/withFallback");
|
|
6
|
+
const NestableWidget_1 = (0, tslib_1.__importDefault)(require("../nestable/NestableWidget"));
|
|
7
|
+
const SlicesTypes_1 = (0, tslib_1.__importDefault)(require("./SlicesTypes"));
|
|
5
8
|
const IMAGE_PLACEHOLDER_URL = "https://images.prismic.io/slice-machine/621a5ec4-0387-4bc5-9860-2dd46cbc07cd_default_ss.png?auto=compress,format";
|
|
6
9
|
const Variation = t.exact(t.intersection([
|
|
7
10
|
t.type({
|
|
8
11
|
id: t.string,
|
|
9
12
|
name: t.string,
|
|
10
13
|
description: t.string,
|
|
11
|
-
imageUrl: withFallback(t.string, IMAGE_PLACEHOLDER_URL),
|
|
14
|
+
imageUrl: (0, withFallback_1.withFallback)(t.string, IMAGE_PLACEHOLDER_URL),
|
|
12
15
|
docURL: t.string,
|
|
13
16
|
version: t.string,
|
|
14
17
|
}),
|
|
15
18
|
t.partial({
|
|
16
19
|
display: t.string,
|
|
17
|
-
primary: t.record(t.string,
|
|
18
|
-
items: t.record(t.string,
|
|
20
|
+
primary: t.record(t.string, NestableWidget_1.default),
|
|
21
|
+
items: t.record(t.string, NestableWidget_1.default),
|
|
19
22
|
}),
|
|
20
23
|
]));
|
|
21
24
|
const SharedSlice = t.exact(t.intersection([
|
|
22
25
|
t.type({
|
|
23
26
|
id: t.string,
|
|
24
|
-
type: t.literal(
|
|
27
|
+
type: t.literal(SlicesTypes_1.default.SharedSlice),
|
|
25
28
|
name: t.string,
|
|
26
29
|
variations: t.array(Variation),
|
|
27
30
|
}),
|
|
@@ -29,4 +32,4 @@ const SharedSlice = t.exact(t.intersection([
|
|
|
29
32
|
description: t.string,
|
|
30
33
|
}),
|
|
31
34
|
]));
|
|
32
|
-
|
|
35
|
+
exports.default = SharedSlice;
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const t = (0, tslib_1.__importStar)(require("io-ts"));
|
|
5
|
+
const SlicesTypes_1 = (0, tslib_1.__importDefault)(require("./SlicesTypes"));
|
|
3
6
|
const SharedSliceRef = t.exact(t.type({
|
|
4
|
-
type: t.literal(
|
|
7
|
+
type: t.literal(SlicesTypes_1.default.SharedSlice),
|
|
5
8
|
}));
|
|
6
|
-
|
|
9
|
+
exports.default = SharedSliceRef;
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -10,16 +10,7 @@ export declare function slicesConfigReader<F extends Format>(format: F): t.Exact
|
|
|
10
10
|
}>, t.PartialC<{
|
|
11
11
|
display: t.StringC;
|
|
12
12
|
}>]>>>>, t.NullC]>;
|
|
13
|
-
choices: t.RecordC<t.StringC, t.UnionC<[t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
|
|
14
|
-
type: t.LiteralC<WidgetTypes.UID>;
|
|
15
|
-
}>, t.PartialC<{
|
|
16
|
-
fieldset: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
|
|
17
|
-
config: t.ExactC<t.PartialC<{
|
|
18
|
-
label: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
|
|
19
|
-
useAsTitle: t.BooleanC;
|
|
20
|
-
placeholder: t.StringC;
|
|
21
|
-
}>>;
|
|
22
|
-
}>]>>, t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
|
|
13
|
+
choices: t.RecordC<t.StringC, t.UnionC<[t.UnionC<[t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
|
|
23
14
|
type: t.LiteralC<WidgetTypes.Color>;
|
|
24
15
|
}>, t.PartialC<{
|
|
25
16
|
fieldset: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
|
|
@@ -1007,16 +998,7 @@ export declare const StaticSlicesConfig: t.ExactC<t.PartialC<{
|
|
|
1007
998
|
}>, t.PartialC<{
|
|
1008
999
|
display: t.StringC;
|
|
1009
1000
|
}>]>>>>, t.NullC]>;
|
|
1010
|
-
choices: t.RecordC<t.StringC, t.UnionC<[t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
|
|
1011
|
-
type: t.LiteralC<WidgetTypes.UID>;
|
|
1012
|
-
}>, t.PartialC<{
|
|
1013
|
-
fieldset: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
|
|
1014
|
-
config: t.ExactC<t.PartialC<{
|
|
1015
|
-
label: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
|
|
1016
|
-
useAsTitle: t.BooleanC;
|
|
1017
|
-
placeholder: t.StringC;
|
|
1018
|
-
}>>;
|
|
1019
|
-
}>]>>, t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
|
|
1001
|
+
choices: t.RecordC<t.StringC, t.UnionC<[t.UnionC<[t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
|
|
1020
1002
|
type: t.LiteralC<WidgetTypes.Color>;
|
|
1021
1003
|
}>, t.PartialC<{
|
|
1022
1004
|
fieldset: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
|
|
@@ -2005,16 +1987,7 @@ export declare const DynamicSlicesConfig: t.ExactC<t.PartialC<{
|
|
|
2005
1987
|
}>, t.PartialC<{
|
|
2006
1988
|
display: t.StringC;
|
|
2007
1989
|
}>]>>>>, t.NullC]>;
|
|
2008
|
-
choices: t.RecordC<t.StringC, t.UnionC<[t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
|
|
2009
|
-
type: t.LiteralC<WidgetTypes.UID>;
|
|
2010
|
-
}>, t.PartialC<{
|
|
2011
|
-
fieldset: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
|
|
2012
|
-
config: t.ExactC<t.PartialC<{
|
|
2013
|
-
label: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
|
|
2014
|
-
useAsTitle: t.BooleanC;
|
|
2015
|
-
placeholder: t.StringC;
|
|
2016
|
-
}>>;
|
|
2017
|
-
}>]>>, t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
|
|
1990
|
+
choices: t.RecordC<t.StringC, t.UnionC<[t.UnionC<[t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
|
|
2018
1991
|
type: t.LiteralC<WidgetTypes.Color>;
|
|
2019
1992
|
}>, t.PartialC<{
|
|
2020
1993
|
fieldset: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
|
|
@@ -3007,16 +2980,7 @@ export declare function slicesReader<F extends Format>(format: F): t.ExactC<t.In
|
|
|
3007
2980
|
}>, t.PartialC<{
|
|
3008
2981
|
display: t.StringC;
|
|
3009
2982
|
}>]>>>>, t.NullC]>;
|
|
3010
|
-
choices: t.RecordC<t.StringC, t.UnionC<[t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
|
|
3011
|
-
type: t.LiteralC<WidgetTypes.UID>;
|
|
3012
|
-
}>, t.PartialC<{
|
|
3013
|
-
fieldset: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
|
|
3014
|
-
config: t.ExactC<t.PartialC<{
|
|
3015
|
-
label: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
|
|
3016
|
-
useAsTitle: t.BooleanC;
|
|
3017
|
-
placeholder: t.StringC;
|
|
3018
|
-
}>>;
|
|
3019
|
-
}>]>>, t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
|
|
2983
|
+
choices: t.RecordC<t.StringC, t.UnionC<[t.UnionC<[t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
|
|
3020
2984
|
type: t.LiteralC<WidgetTypes.Color>;
|
|
3021
2985
|
}>, t.PartialC<{
|
|
3022
2986
|
fieldset: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
|
|
@@ -4009,16 +3973,7 @@ export declare const StaticSlices: t.ExactC<t.IntersectionC<[t.TypeC<{
|
|
|
4009
3973
|
}>, t.PartialC<{
|
|
4010
3974
|
display: t.StringC;
|
|
4011
3975
|
}>]>>>>, t.NullC]>;
|
|
4012
|
-
choices: t.RecordC<t.StringC, t.UnionC<[t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
|
|
4013
|
-
type: t.LiteralC<WidgetTypes.UID>;
|
|
4014
|
-
}>, t.PartialC<{
|
|
4015
|
-
fieldset: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
|
|
4016
|
-
config: t.ExactC<t.PartialC<{
|
|
4017
|
-
label: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
|
|
4018
|
-
useAsTitle: t.BooleanC;
|
|
4019
|
-
placeholder: t.StringC;
|
|
4020
|
-
}>>;
|
|
4021
|
-
}>]>>, t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
|
|
3976
|
+
choices: t.RecordC<t.StringC, t.UnionC<[t.UnionC<[t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
|
|
4022
3977
|
type: t.LiteralC<WidgetTypes.Color>;
|
|
4023
3978
|
}>, t.PartialC<{
|
|
4024
3979
|
fieldset: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
|
|
@@ -5012,16 +4967,7 @@ export declare const DynamicSlices: t.ExactC<t.IntersectionC<[t.TypeC<{
|
|
|
5012
4967
|
}>, t.PartialC<{
|
|
5013
4968
|
display: t.StringC;
|
|
5014
4969
|
}>]>>>>, t.NullC]>;
|
|
5015
|
-
choices: t.RecordC<t.StringC, t.UnionC<[t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
|
|
5016
|
-
type: t.LiteralC<WidgetTypes.UID>;
|
|
5017
|
-
}>, t.PartialC<{
|
|
5018
|
-
fieldset: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
|
|
5019
|
-
config: t.ExactC<t.PartialC<{
|
|
5020
|
-
label: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
|
|
5021
|
-
useAsTitle: t.BooleanC;
|
|
5022
|
-
placeholder: t.StringC;
|
|
5023
|
-
}>>;
|
|
5024
|
-
}>]>>, t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
|
|
4970
|
+
choices: t.RecordC<t.StringC, t.UnionC<[t.UnionC<[t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
|
|
5025
4971
|
type: t.LiteralC<WidgetTypes.Color>;
|
|
5026
4972
|
}>, t.PartialC<{
|
|
5027
4973
|
fieldset: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
|
|
@@ -1,12 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Slices = exports.DynamicSlices = exports.StaticSlices = exports.slicesReader = exports.DynamicSlicesConfig = exports.StaticSlicesConfig = exports.slicesConfigReader = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const t = (0, tslib_1.__importStar)(require("io-ts"));
|
|
6
|
+
const validators_1 = require("../../../validators");
|
|
7
|
+
const Format_1 = require("../../Format");
|
|
8
|
+
const WidgetTypes_1 = (0, tslib_1.__importDefault)(require("../WidgetTypes"));
|
|
9
|
+
const CompositeSlice_1 = (0, tslib_1.__importDefault)(require("./CompositeSlice"));
|
|
10
|
+
const LegacySlice_1 = (0, tslib_1.__importDefault)(require("./LegacySlice"));
|
|
11
|
+
const SharedSlice_1 = (0, tslib_1.__importDefault)(require("./SharedSlice"));
|
|
12
|
+
const SharedSliceRef_1 = (0, tslib_1.__importDefault)(require("./SharedSliceRef"));
|
|
13
|
+
const SlicesTypes_1 = (0, tslib_1.__importDefault)(require("./SlicesTypes"));
|
|
10
14
|
const SlicesLabels = t.union([
|
|
11
15
|
t.record(t.string, t.array(t.exact(t.intersection([
|
|
12
16
|
t.type({
|
|
@@ -18,19 +22,19 @@ const SlicesLabels = t.union([
|
|
|
18
22
|
])))),
|
|
19
23
|
t.null,
|
|
20
24
|
]);
|
|
21
|
-
|
|
25
|
+
function slicesConfigReader(format) {
|
|
22
26
|
return t.exact(t.partial({
|
|
23
|
-
label: StringOrNull,
|
|
27
|
+
label: validators_1.StringOrNull,
|
|
24
28
|
labels: SlicesLabels,
|
|
25
29
|
choices: t.record(t.string, t.union([
|
|
26
|
-
|
|
27
|
-
|
|
30
|
+
LegacySlice_1.default,
|
|
31
|
+
CompositeSlice_1.default,
|
|
28
32
|
(() => {
|
|
29
33
|
switch (format) {
|
|
30
|
-
case Format.Static:
|
|
31
|
-
return
|
|
32
|
-
case Format.Dynamic:
|
|
33
|
-
return
|
|
34
|
+
case Format_1.Format.Static:
|
|
35
|
+
return SharedSlice_1.default;
|
|
36
|
+
case Format_1.Format.Dynamic:
|
|
37
|
+
return SharedSliceRef_1.default;
|
|
34
38
|
default:
|
|
35
39
|
throw new Error(`Invalid Format Exception: ${format} doesn't exist`);
|
|
36
40
|
}
|
|
@@ -38,12 +42,13 @@ export function slicesConfigReader(format) {
|
|
|
38
42
|
])),
|
|
39
43
|
}));
|
|
40
44
|
}
|
|
41
|
-
|
|
42
|
-
|
|
45
|
+
exports.slicesConfigReader = slicesConfigReader;
|
|
46
|
+
exports.StaticSlicesConfig = slicesConfigReader(Format_1.Format.Static);
|
|
47
|
+
exports.DynamicSlicesConfig = slicesConfigReader(Format_1.Format.Dynamic);
|
|
43
48
|
const SlicesConfig = {
|
|
44
49
|
toStatic(config, sharedSlices) {
|
|
45
50
|
const choices = Object.entries(config.choices || {}).reduce((acc, [ref, slice]) => {
|
|
46
|
-
if (slice.type ===
|
|
51
|
+
if (slice.type === SlicesTypes_1.default.SharedSlice) {
|
|
47
52
|
const sharedSlice = sharedSlices.get(ref);
|
|
48
53
|
if (sharedSlice)
|
|
49
54
|
return { ...acc, [ref]: sharedSlice };
|
|
@@ -57,23 +62,24 @@ const SlicesConfig = {
|
|
|
57
62
|
return { ...config, choices };
|
|
58
63
|
},
|
|
59
64
|
};
|
|
60
|
-
|
|
65
|
+
function slicesReader(format) {
|
|
61
66
|
return t.exact(t.intersection([
|
|
62
67
|
t.type({
|
|
63
68
|
type: t.union([
|
|
64
|
-
t.literal(
|
|
65
|
-
t.literal(
|
|
69
|
+
t.literal(WidgetTypes_1.default.Slices),
|
|
70
|
+
t.literal(WidgetTypes_1.default.LegacySlices),
|
|
66
71
|
]),
|
|
67
72
|
}),
|
|
68
73
|
t.partial({
|
|
69
|
-
fieldset: StringOrNull,
|
|
74
|
+
fieldset: validators_1.StringOrNull,
|
|
70
75
|
config: slicesConfigReader(format),
|
|
71
76
|
}),
|
|
72
77
|
]));
|
|
73
78
|
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
79
|
+
exports.slicesReader = slicesReader;
|
|
80
|
+
exports.StaticSlices = slicesReader(Format_1.Format.Static);
|
|
81
|
+
exports.DynamicSlices = slicesReader(Format_1.Format.Dynamic);
|
|
82
|
+
exports.Slices = {
|
|
77
83
|
toStatic(slices, sharedSlices) {
|
|
78
84
|
if (!slices.config)
|
|
79
85
|
return slices;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
3
|
var SlicesTypes;
|
|
2
4
|
(function (SlicesTypes) {
|
|
3
5
|
SlicesTypes["Slice"] = "Slice";
|
|
4
6
|
SlicesTypes["SharedSlice"] = "SharedSlice";
|
|
5
7
|
})(SlicesTypes || (SlicesTypes = {}));
|
|
6
|
-
|
|
8
|
+
exports.default = SlicesTypes;
|
|
@@ -1,7 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SlicesTypes = exports.SliceZone = exports.Slice = exports.SharedSliceRef = exports.SharedSlice = exports.LegacySlice = exports.CompositeSlice = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
var CompositeSlice_1 = require("./CompositeSlice");
|
|
6
|
+
Object.defineProperty(exports, "CompositeSlice", { enumerable: true, get: function () { return (0, tslib_1.__importDefault)(CompositeSlice_1).default; } });
|
|
7
|
+
var LegacySlice_1 = require("./LegacySlice");
|
|
8
|
+
Object.defineProperty(exports, "LegacySlice", { enumerable: true, get: function () { return (0, tslib_1.__importDefault)(LegacySlice_1).default; } });
|
|
9
|
+
var SharedSlice_1 = require("./SharedSlice");
|
|
10
|
+
Object.defineProperty(exports, "SharedSlice", { enumerable: true, get: function () { return (0, tslib_1.__importDefault)(SharedSlice_1).default; } });
|
|
11
|
+
var SharedSliceRef_1 = require("./SharedSliceRef");
|
|
12
|
+
Object.defineProperty(exports, "SharedSliceRef", { enumerable: true, get: function () { return (0, tslib_1.__importDefault)(SharedSliceRef_1).default; } });
|
|
13
|
+
exports.Slice = (0, tslib_1.__importStar)(require("./Slice"));
|
|
14
|
+
exports.SliceZone = (0, tslib_1.__importStar)(require("./Slices"));
|
|
15
|
+
var SlicesTypes_1 = require("./SlicesTypes");
|
|
16
|
+
Object.defineProperty(exports, "SlicesTypes", { enumerable: true, get: function () { return (0, tslib_1.__importDefault)(SlicesTypes_1).default; } });
|
|
@@ -1,11 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const O = (0, tslib_1.__importStar)(require("fp-ts/lib/Option"));
|
|
5
|
+
const widgets_1 = require("./widgets");
|
|
3
6
|
function computeWidget(key, widgets, widgetTypes, widgetPositions) {
|
|
4
7
|
const widget = widgets.get(key);
|
|
5
8
|
if (widget === undefined) {
|
|
6
9
|
return O.none;
|
|
7
10
|
}
|
|
8
|
-
return Widget.fromJson(key, widget, widgetTypes, widgetPositions);
|
|
11
|
+
return widgets_1.Widget.fromJson(key, widget, widgetTypes, widgetPositions);
|
|
9
12
|
}
|
|
10
13
|
const DocumentData = {
|
|
11
14
|
getWidget(key, widgets, widgetTypes, widgetPositions, parsed) {
|
|
@@ -22,4 +25,4 @@ const DocumentData = {
|
|
|
22
25
|
}, new Map());
|
|
23
26
|
},
|
|
24
27
|
};
|
|
25
|
-
|
|
28
|
+
exports.default = DocumentData;
|
package/lib/documents/index.js
CHANGED
|
@@ -1,2 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Widgets = exports.DocumentData = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
var DocumentData_1 = require("./DocumentData");
|
|
6
|
+
Object.defineProperty(exports, "DocumentData", { enumerable: true, get: function () { return (0, tslib_1.__importDefault)(DocumentData_1).default; } });
|
|
7
|
+
exports.Widgets = (0, tslib_1.__importStar)(require("./widgets"));
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EmptyContent = exports.EmptyContentType = void 0;
|
|
4
|
+
exports.EmptyContentType = "EmptyContent";
|
|
5
|
+
exports.EmptyContent = {
|
|
3
6
|
is: (value) => {
|
|
4
|
-
return value.__TYPE__ === EmptyContentType;
|
|
7
|
+
return value.__TYPE__ === exports.EmptyContentType;
|
|
5
8
|
},
|
|
6
9
|
};
|
|
@@ -1,10 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GroupContent = exports.GroupContentType = exports.GroupItemContentType = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const A = (0, tslib_1.__importStar)(require("fp-ts/Array"));
|
|
6
|
+
const O = (0, tslib_1.__importStar)(require("fp-ts/Option"));
|
|
7
|
+
const t = (0, tslib_1.__importStar)(require("io-ts"));
|
|
8
|
+
const SimpleWidgetContent_1 = require("./SimpleWidgetContent");
|
|
9
|
+
exports.GroupItemContentType = "GroupItemContent";
|
|
10
|
+
exports.GroupContentType = "GroupContentType";
|
|
11
|
+
exports.GroupContent = Object.freeze({
|
|
8
12
|
itemsContentsFromJson: (prefixedKey, jsItems, fieldTypes, fieldPositions) => {
|
|
9
13
|
if (jsItems) {
|
|
10
14
|
return jsItems.map((jsItem) => {
|
|
@@ -19,7 +23,7 @@ export const GroupContent = Object.freeze({
|
|
|
19
23
|
if (kind) {
|
|
20
24
|
return O.map((content) => {
|
|
21
25
|
return [k, content];
|
|
22
|
-
})(SimpleWidgetContent.from(kind, v));
|
|
26
|
+
})(SimpleWidgetContent_1.SimpleWidgetContent.from(kind, v));
|
|
23
27
|
}
|
|
24
28
|
else {
|
|
25
29
|
return O.none;
|
|
@@ -47,8 +51,8 @@ export const GroupContent = Object.freeze({
|
|
|
47
51
|
const maybeJsItems = O.fromEither(t.array(t.unknown).decode(value));
|
|
48
52
|
return O.map((items) => {
|
|
49
53
|
return {
|
|
50
|
-
value: GroupContent.itemsContentsFromJson(prefixedKey, items, fieldTypes, fieldPositions),
|
|
51
|
-
__TYPE__: GroupContentType,
|
|
54
|
+
value: exports.GroupContent.itemsContentsFromJson(prefixedKey, items, fieldTypes, fieldPositions),
|
|
55
|
+
__TYPE__: exports.GroupContentType,
|
|
52
56
|
};
|
|
53
57
|
})(maybeJsItems);
|
|
54
58
|
},
|
|
@@ -1,17 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SimpleWidgetContent = exports.is = exports.SimpleWidgetContentType = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const function_1 = require("fp-ts/function");
|
|
6
|
+
const O = (0, tslib_1.__importStar)(require("fp-ts/Option"));
|
|
7
|
+
const t = (0, tslib_1.__importStar)(require("io-ts"));
|
|
8
|
+
const BooleanContent_1 = (0, tslib_1.__importDefault)(require("./nestable/BooleanContent"));
|
|
9
|
+
const EmbedContent_1 = (0, tslib_1.__importDefault)(require("./nestable/EmbedContent"));
|
|
10
|
+
const FieldContent_1 = (0, tslib_1.__importDefault)(require("./nestable/FieldContent"));
|
|
11
|
+
const GeoPointContent_1 = require("./nestable/GeoPointContent");
|
|
12
|
+
const ImageContent_1 = require("./nestable/ImageContent");
|
|
13
|
+
const IntegrationFieldsContent_1 = (0, tslib_1.__importDefault)(require("./nestable/IntegrationFieldsContent"));
|
|
14
|
+
const Link_1 = require("./nestable/Link");
|
|
15
|
+
const StructuredTextContent_1 = require("./nestable/StructuredTextContent");
|
|
16
|
+
const UIDContent_1 = require("./UIDContent");
|
|
13
17
|
//TODO: rework that using import such as EmptyContentType
|
|
14
|
-
|
|
18
|
+
exports.SimpleWidgetContentType = [
|
|
15
19
|
"EmptyContent",
|
|
16
20
|
"ImageContent",
|
|
17
21
|
"GeoPointContent",
|
|
@@ -24,14 +28,15 @@ export const SimpleWidgetContentType = [
|
|
|
24
28
|
"SeparatorContent",
|
|
25
29
|
"FieldContent",
|
|
26
30
|
];
|
|
27
|
-
|
|
31
|
+
function is(value) {
|
|
28
32
|
const asSwc = value;
|
|
29
|
-
return SimpleWidgetContentType.includes(asSwc.__TYPE__);
|
|
33
|
+
return exports.SimpleWidgetContentType.includes(asSwc.__TYPE__);
|
|
30
34
|
}
|
|
35
|
+
exports.is = is;
|
|
31
36
|
const valueNullCodec = t.type({
|
|
32
37
|
value: t.null,
|
|
33
38
|
});
|
|
34
|
-
|
|
39
|
+
exports.SimpleWidgetContent = {
|
|
35
40
|
from: (type, content) => {
|
|
36
41
|
if (content === null || valueNullCodec.is(content)) {
|
|
37
42
|
const result = { type: type, __TYPE__: "EmptyContent" };
|
|
@@ -39,26 +44,26 @@ export const SimpleWidgetContent = {
|
|
|
39
44
|
}
|
|
40
45
|
switch (type) {
|
|
41
46
|
case "StructuredText":
|
|
42
|
-
return O.fromEither(StructuredTextContent.decode(content));
|
|
47
|
+
return O.fromEither(StructuredTextContent_1.StructuredTextContent.decode(content));
|
|
43
48
|
case "IntegrationFields":
|
|
44
|
-
return O.fromEither(
|
|
49
|
+
return O.fromEither(IntegrationFieldsContent_1.default.decode(content));
|
|
45
50
|
case "Image":
|
|
46
|
-
return pipe(O.fromEither(ImageContent.decode(content)), O.map((imageContent) => ImageContent.encode(imageContent)));
|
|
51
|
+
return (0, function_1.pipe)(O.fromEither(ImageContent_1.ImageContent.decode(content)), O.map((imageContent) => ImageContent_1.ImageContent.encode(imageContent)));
|
|
47
52
|
case "GeoPoint":
|
|
48
|
-
return pipe(O.fromEither(GeoPointContent.decode(content)), O.map((geopointContent) => GeoPointContent.encode(geopointContent)));
|
|
53
|
+
return (0, function_1.pipe)(O.fromEither(GeoPointContent_1.GeoPointContent.decode(content)), O.map((geopointContent) => GeoPointContent_1.GeoPointContent.encode(geopointContent)));
|
|
49
54
|
case "Embed":
|
|
50
|
-
return O.fromEither(
|
|
55
|
+
return O.fromEither(EmbedContent_1.default.decode(content));
|
|
51
56
|
case "Link":
|
|
52
|
-
return O.fromEither(LinkContent.decode(content));
|
|
57
|
+
return O.fromEither(Link_1.LinkContent.decode(content));
|
|
53
58
|
case "UID":
|
|
54
|
-
return O.fromEither(UIDContent.decode(content));
|
|
59
|
+
return O.fromEither(UIDContent_1.UIDContent.decode(content));
|
|
55
60
|
case "Separator":
|
|
56
61
|
return O.some({ __TYPE__: "SeparatorContent" });
|
|
57
62
|
case "Boolean":
|
|
58
|
-
return O.fromEither(
|
|
63
|
+
return O.fromEither(BooleanContent_1.default.decode(content));
|
|
59
64
|
default:
|
|
60
|
-
if (
|
|
61
|
-
return
|
|
65
|
+
if (FieldContent_1.default.types.includes(type)) {
|
|
66
|
+
return FieldContent_1.default.forType(type, content);
|
|
62
67
|
}
|
|
63
68
|
else {
|
|
64
69
|
return O.none;
|
|
@@ -66,5 +71,5 @@ export const SimpleWidgetContent = {
|
|
|
66
71
|
}
|
|
67
72
|
},
|
|
68
73
|
//TODO: rework that
|
|
69
|
-
is: (value) => SimpleWidgetContentType.includes(value.__TYPE__),
|
|
74
|
+
is: (value) => exports.SimpleWidgetContentType.includes(value.__TYPE__),
|
|
70
75
|
};
|
|
@@ -1,23 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const O = (0, tslib_1.__importStar)(require("fp-ts/Option"));
|
|
5
|
+
const GroupContent_1 = require("./GroupContent");
|
|
6
|
+
const SimpleWidgetContent_1 = require("./SimpleWidgetContent");
|
|
4
7
|
const StaticWidgetContent = {
|
|
5
8
|
fromJson: (prefixes, key, value, fieldTypes, fieldPositions) => {
|
|
6
9
|
const prefixedKey = Array.of(prefixes, [key]).flat().join(".");
|
|
7
10
|
const type = fieldTypes.get(prefixedKey);
|
|
8
11
|
if (type === "Group") {
|
|
9
|
-
return GroupContent.fromJson(prefixes, key, value, fieldTypes, fieldPositions);
|
|
12
|
+
return GroupContent_1.GroupContent.fromJson(prefixes, key, value, fieldTypes, fieldPositions);
|
|
10
13
|
}
|
|
11
14
|
else if (type) {
|
|
12
|
-
return SimpleWidgetContent.from(type, value);
|
|
15
|
+
return SimpleWidgetContent_1.SimpleWidgetContent.from(type, value);
|
|
13
16
|
}
|
|
14
17
|
else {
|
|
15
18
|
return O.none;
|
|
16
19
|
}
|
|
17
20
|
},
|
|
18
21
|
is: (value) => {
|
|
19
|
-
return (SimpleWidgetContent.is(value) ||
|
|
20
|
-
GroupContentType === value.__TYPE__);
|
|
22
|
+
return (SimpleWidgetContent_1.SimpleWidgetContent.is(value) ||
|
|
23
|
+
GroupContent_1.GroupContentType === value.__TYPE__);
|
|
21
24
|
},
|
|
22
25
|
};
|
|
23
|
-
|
|
26
|
+
exports.default = StaticWidgetContent;
|
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UIDContent = exports.UIDContentType = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const Either_1 = require("fp-ts/Either");
|
|
6
|
+
const t = (0, tslib_1.__importStar)(require("io-ts"));
|
|
7
|
+
exports.UIDContentType = "UIDContent";
|
|
8
|
+
exports.UIDContent = new t.Type("UIDContent", (u) => u?.__TYPE__ === exports.UIDContentType, (u, c) => Either_1.Chain.chain(t.string.validate(u, c), (u) => {
|
|
5
9
|
return t.success({ value: u, __TYPE__: "UIDContent" });
|
|
6
10
|
}), (uidContent) => uidContent.value);
|
|
@@ -1,31 +1,36 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Widget = exports.WidgetTypes = exports.StaticWidgetContent = exports.Slices = exports.Nestable = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const EmptyContent_1 = require("./EmptyContent");
|
|
6
|
+
const GroupContent_1 = require("./GroupContent");
|
|
7
|
+
const nestable_1 = require("./nestable");
|
|
8
|
+
const SlicesContent_1 = require("./slices/SlicesContent");
|
|
9
|
+
const StaticWidgetContent_1 = (0, tslib_1.__importDefault)(require("./StaticWidgetContent"));
|
|
10
|
+
const UIDContent_1 = require("./UIDContent");
|
|
11
|
+
(0, tslib_1.__exportStar)(require("./EmptyContent"), exports);
|
|
12
|
+
(0, tslib_1.__exportStar)(require("./GroupContent"), exports);
|
|
13
|
+
exports.Nestable = (0, tslib_1.__importStar)(require("./nestable"));
|
|
14
|
+
(0, tslib_1.__exportStar)(require("./SimpleWidgetContent"), exports);
|
|
15
|
+
exports.Slices = (0, tslib_1.__importStar)(require("./slices"));
|
|
16
|
+
var StaticWidgetContent_2 = require("./StaticWidgetContent");
|
|
17
|
+
Object.defineProperty(exports, "StaticWidgetContent", { enumerable: true, get: function () { return (0, tslib_1.__importDefault)(StaticWidgetContent_2).default; } });
|
|
18
|
+
(0, tslib_1.__exportStar)(require("./UIDContent"), exports);
|
|
19
|
+
exports.WidgetTypes = {
|
|
20
|
+
...nestable_1.NestableTypes,
|
|
21
|
+
Empty: EmptyContent_1.EmptyContentType,
|
|
22
|
+
UID: UIDContent_1.UIDContentType,
|
|
23
|
+
Group: GroupContent_1.GroupContentType,
|
|
24
|
+
slices: SlicesContent_1.SlicesContentType,
|
|
20
25
|
};
|
|
21
|
-
|
|
26
|
+
exports.Widget = {
|
|
22
27
|
fromJson(widgetKey, widgetValue, widgetTypes, widgetPositions) {
|
|
23
28
|
const fieldType = widgetTypes.get(widgetKey);
|
|
24
29
|
if (fieldType === "Slices") {
|
|
25
|
-
return SlicesContent.fromJson(widgetKey, widgetValue, widgetTypes, widgetPositions);
|
|
30
|
+
return SlicesContent_1.SlicesContent.fromJson(widgetKey, widgetValue, widgetTypes, widgetPositions);
|
|
26
31
|
}
|
|
27
32
|
else {
|
|
28
|
-
return
|
|
33
|
+
return StaticWidgetContent_1.default.fromJson([], widgetKey, widgetValue, widgetTypes, widgetPositions);
|
|
29
34
|
}
|
|
30
35
|
},
|
|
31
36
|
};
|