@prismicio/types-internal 0.2.0 → 0.2.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/customtypes/CustomType.d.ts +2 -2
- package/lib/customtypes/CustomType.js +38 -56
- package/lib/customtypes/Format.js +2 -5
- package/lib/customtypes/Section.d.ts +1 -1
- package/lib/customtypes/Section.js +9 -32
- package/lib/customtypes/index.js +4 -30
- package/lib/customtypes/widgets/Group.js +9 -33
- package/lib/customtypes/widgets/UID.js +7 -31
- package/lib/customtypes/widgets/Widget.d.ts +1 -1
- package/lib/customtypes/widgets/Widget.js +14 -40
- package/lib/customtypes/widgets/WidgetTypes.js +1 -3
- package/lib/customtypes/widgets/index.js +7 -35
- package/lib/customtypes/widgets/nestable/BooleanField.js +6 -30
- package/lib/customtypes/widgets/nestable/Color.js +7 -31
- package/lib/customtypes/widgets/nestable/Date.js +7 -31
- package/lib/customtypes/widgets/nestable/Embed.js +7 -31
- package/lib/customtypes/widgets/nestable/GeoPoint.js +7 -31
- package/lib/customtypes/widgets/nestable/Image.js +10 -34
- package/lib/customtypes/widgets/nestable/IntegrationField.js +7 -31
- package/lib/customtypes/widgets/nestable/Link.js +13 -35
- package/lib/customtypes/widgets/nestable/NestableWidget.js +32 -56
- package/lib/customtypes/widgets/nestable/Number.js +11 -35
- package/lib/customtypes/widgets/nestable/Range.js +11 -35
- package/lib/customtypes/widgets/nestable/RichText.js +16 -36
- package/lib/customtypes/widgets/nestable/Select.js +8 -32
- package/lib/customtypes/widgets/nestable/Separator.js +6 -30
- package/lib/customtypes/widgets/nestable/Text.js +7 -31
- package/lib/customtypes/widgets/nestable/Timestamp.js +7 -31
- package/lib/customtypes/widgets/nestable/index.js +15 -36
- package/lib/customtypes/widgets/shared/ImageConstraint.js +9 -30
- package/lib/customtypes/widgets/shared/index.js +1 -8
- package/lib/customtypes/widgets/slices/CompositeSlice.js +10 -34
- package/lib/customtypes/widgets/slices/LegacySlice.js +6 -30
- package/lib/customtypes/widgets/slices/SharedSlice.js +9 -33
- package/lib/customtypes/widgets/slices/SharedSliceRef.js +4 -28
- package/lib/customtypes/widgets/slices/Slice.d.ts +4 -4
- package/lib/customtypes/widgets/slices/Slice.js +1 -2
- package/lib/customtypes/widgets/slices/Slices.js +27 -54
- package/lib/customtypes/widgets/slices/SlicesTypes.js +1 -3
- package/lib/customtypes/widgets/slices/index.js +7 -37
- package/lib/documents/DocumentData.js +4 -25
- package/lib/documents/index.js +2 -28
- package/lib/documents/widgets/EmptyContent.js +3 -6
- package/lib/documents/widgets/GroupContent.js +10 -32
- package/lib/documents/widgets/SimpleWidgetContent.d.ts +2 -2
- package/lib/documents/widgets/SimpleWidgetContent.js +27 -53
- package/lib/documents/widgets/StaticWidgetContent.js +8 -29
- package/lib/documents/widgets/UIDContent.js +4 -26
- package/lib/documents/widgets/index.js +22 -51
- package/lib/documents/widgets/nestable/BooleanContent.js +6 -28
- package/lib/documents/widgets/nestable/EmbedContent.d.ts +4 -4
- package/lib/documents/widgets/nestable/EmbedContent.js +20 -42
- package/lib/documents/widgets/nestable/FieldContent.js +8 -28
- package/lib/documents/widgets/nestable/GeoPointContent.js +5 -27
- package/lib/documents/widgets/nestable/ImageContent.d.ts +14 -14
- package/lib/documents/widgets/nestable/ImageContent.js +12 -34
- package/lib/documents/widgets/nestable/IntegrationFieldsContent.js +6 -28
- package/lib/documents/widgets/nestable/Link/DocumentLink.js +7 -30
- package/lib/documents/widgets/nestable/Link/ExternalLink.d.ts +4 -4
- package/lib/documents/widgets/nestable/Link/ExternalLink.js +10 -33
- package/lib/documents/widgets/nestable/Link/FileLink.js +10 -33
- package/lib/documents/widgets/nestable/Link/ImageLink.js +9 -32
- package/lib/documents/widgets/nestable/Link/LinkContent.d.ts +2 -2
- package/lib/documents/widgets/nestable/Link/LinkContent.js +9 -31
- package/lib/documents/widgets/nestable/Link/index.d.ts +8 -8
- package/lib/documents/widgets/nestable/Link/index.js +24 -51
- package/lib/documents/widgets/nestable/SeparatorContent.js +2 -5
- package/lib/documents/widgets/nestable/StructuredTextContent/Block.d.ts +8 -8
- package/lib/documents/widgets/nestable/StructuredTextContent/Block.js +33 -60
- package/lib/documents/widgets/nestable/StructuredTextContent/index.js +7 -29
- package/lib/documents/widgets/nestable/index.d.ts +2 -2
- package/lib/documents/widgets/nestable/index.js +28 -63
- package/lib/documents/widgets/slices/CompositeSliceContent.d.ts +1 -1
- package/lib/documents/widgets/slices/CompositeSliceContent.js +9 -31
- package/lib/documents/widgets/slices/SharedSliceContent.d.ts +1 -1
- package/lib/documents/widgets/slices/SharedSliceContent.js +12 -34
- package/lib/documents/widgets/slices/SimpleSliceContent.js +2 -8
- package/lib/documents/widgets/slices/SliceWidgetContent.d.ts +1 -1
- package/lib/documents/widgets/slices/SliceWidgetContent.js +8 -33
- package/lib/documents/widgets/slices/SlicesContent.js +13 -35
- package/lib/documents/widgets/slices/index.js +5 -17
- package/lib/index.js +3 -25
- package/lib/validators/DateFromString.js +4 -25
- package/lib/validators/DateFromStringOrNumber.js +4 -25
- package/lib/validators/DateFromTsMs.js +4 -25
- package/lib/validators/IntFromNumber.js +4 -25
- package/lib/validators/IntFromPixels.js +7 -29
- package/lib/validators/NonEmptyString.js +3 -24
- package/lib/validators/NonEmptyStringOrNull.js +7 -12
- package/lib/validators/NumberOrNull.js +3 -24
- package/lib/validators/StringFromBoolean.js +4 -25
- package/lib/validators/StringFromNumber.js +4 -25
- package/lib/validators/StringOrNull.js +3 -24
- package/lib/validators/function.js +17 -47
- package/lib/validators/index.js +12 -48
- package/package.json +1 -1
- package/lib/documents/widgets/Widget.d.ts +0 -0
- package/lib/documents/widgets/Widget.js +0 -1
|
@@ -1,37 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
-
}) : function(o, v) {
|
|
12
|
-
o["default"] = v;
|
|
13
|
-
});
|
|
14
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
-
if (mod && mod.__esModule) return mod;
|
|
16
|
-
var result = {};
|
|
17
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
-
__setModuleDefault(result, mod);
|
|
19
|
-
return result;
|
|
20
|
-
};
|
|
21
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
22
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
23
|
-
};
|
|
24
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
-
exports.Slices = exports.DynamicSlices = exports.StaticSlices = exports.slicesReader = exports.DynamicSlicesConfig = exports.StaticSlicesConfig = exports.slicesConfigReader = void 0;
|
|
26
|
-
const t = __importStar(require("io-ts"));
|
|
27
|
-
const validators_1 = require("../../../validators");
|
|
28
|
-
const Format_1 = require("../../Format");
|
|
29
|
-
const WidgetTypes_1 = __importDefault(require("../WidgetTypes"));
|
|
30
|
-
const CompositeSlice_1 = __importDefault(require("./CompositeSlice"));
|
|
31
|
-
const LegacySlice_1 = __importDefault(require("./LegacySlice"));
|
|
32
|
-
const SharedSlice_1 = __importDefault(require("./SharedSlice"));
|
|
33
|
-
const SharedSliceRef_1 = __importDefault(require("./SharedSliceRef"));
|
|
34
|
-
const SlicesTypes_1 = __importDefault(require("./SlicesTypes"));
|
|
1
|
+
import * as t from "io-ts";
|
|
2
|
+
import { StringOrNull } from "../../../validators";
|
|
3
|
+
import { Format } from "../../Format";
|
|
4
|
+
import WidgetTypes from "../WidgetTypes";
|
|
5
|
+
import CompositeSlice from "./CompositeSlice";
|
|
6
|
+
import LegacySlice from "./LegacySlice";
|
|
7
|
+
import SharedSlice from "./SharedSlice";
|
|
8
|
+
import SharedSliceRef from "./SharedSliceRef";
|
|
9
|
+
import SlicesTypes from "./SlicesTypes";
|
|
35
10
|
const SlicesLabels = t.union([
|
|
36
11
|
t.record(t.string, t.array(t.exact(t.intersection([
|
|
37
12
|
t.type({
|
|
@@ -43,19 +18,19 @@ const SlicesLabels = t.union([
|
|
|
43
18
|
])))),
|
|
44
19
|
t.null,
|
|
45
20
|
]);
|
|
46
|
-
function slicesConfigReader(format) {
|
|
21
|
+
export function slicesConfigReader(format) {
|
|
47
22
|
return t.exact(t.partial({
|
|
48
|
-
label:
|
|
23
|
+
label: StringOrNull,
|
|
49
24
|
labels: SlicesLabels,
|
|
50
25
|
choices: t.record(t.string, t.union([
|
|
51
|
-
|
|
52
|
-
|
|
26
|
+
LegacySlice,
|
|
27
|
+
CompositeSlice,
|
|
53
28
|
(() => {
|
|
54
29
|
switch (format) {
|
|
55
|
-
case
|
|
56
|
-
return
|
|
57
|
-
case
|
|
58
|
-
return
|
|
30
|
+
case Format.Static:
|
|
31
|
+
return SharedSlice;
|
|
32
|
+
case Format.Dynamic:
|
|
33
|
+
return SharedSliceRef;
|
|
59
34
|
default:
|
|
60
35
|
throw new Error(`Invalid Format Exception: ${format} doesn't exist`);
|
|
61
36
|
}
|
|
@@ -63,13 +38,12 @@ function slicesConfigReader(format) {
|
|
|
63
38
|
])),
|
|
64
39
|
}));
|
|
65
40
|
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
exports.DynamicSlicesConfig = slicesConfigReader(Format_1.Format.Dynamic);
|
|
41
|
+
export const StaticSlicesConfig = slicesConfigReader(Format.Static);
|
|
42
|
+
export const DynamicSlicesConfig = slicesConfigReader(Format.Dynamic);
|
|
69
43
|
const SlicesConfig = {
|
|
70
44
|
toStatic(config, sharedSlices) {
|
|
71
45
|
const choices = Object.entries(config.choices || {}).reduce((acc, [ref, slice]) => {
|
|
72
|
-
if (slice.type ===
|
|
46
|
+
if (slice.type === SlicesTypes.SharedSlice) {
|
|
73
47
|
const sharedSlice = sharedSlices.get(ref);
|
|
74
48
|
if (sharedSlice)
|
|
75
49
|
return { ...acc, [ref]: sharedSlice };
|
|
@@ -83,24 +57,23 @@ const SlicesConfig = {
|
|
|
83
57
|
return { ...config, choices };
|
|
84
58
|
},
|
|
85
59
|
};
|
|
86
|
-
function slicesReader(format) {
|
|
60
|
+
export function slicesReader(format) {
|
|
87
61
|
return t.exact(t.intersection([
|
|
88
62
|
t.type({
|
|
89
63
|
type: t.union([
|
|
90
|
-
t.literal(
|
|
91
|
-
t.literal(
|
|
64
|
+
t.literal(WidgetTypes.Slices),
|
|
65
|
+
t.literal(WidgetTypes.LegacySlices),
|
|
92
66
|
]),
|
|
93
67
|
}),
|
|
94
68
|
t.partial({
|
|
95
|
-
fieldset:
|
|
69
|
+
fieldset: StringOrNull,
|
|
96
70
|
config: slicesConfigReader(format),
|
|
97
71
|
}),
|
|
98
72
|
]));
|
|
99
73
|
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
exports.Slices = {
|
|
74
|
+
export const StaticSlices = slicesReader(Format.Static);
|
|
75
|
+
export const DynamicSlices = slicesReader(Format.Dynamic);
|
|
76
|
+
export const Slices = {
|
|
104
77
|
toStatic(slices, sharedSlices) {
|
|
105
78
|
if (!slices.config)
|
|
106
79
|
return slices;
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
1
|
var SlicesTypes;
|
|
4
2
|
(function (SlicesTypes) {
|
|
5
3
|
SlicesTypes["Slice"] = "Slice";
|
|
6
4
|
SlicesTypes["SharedSlice"] = "SharedSlice";
|
|
7
5
|
})(SlicesTypes || (SlicesTypes = {}));
|
|
8
|
-
|
|
6
|
+
export default SlicesTypes;
|
|
@@ -1,37 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}));
|
|
9
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
-
}) : function(o, v) {
|
|
12
|
-
o["default"] = v;
|
|
13
|
-
});
|
|
14
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
-
if (mod && mod.__esModule) return mod;
|
|
16
|
-
var result = {};
|
|
17
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
-
__setModuleDefault(result, mod);
|
|
19
|
-
return result;
|
|
20
|
-
};
|
|
21
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
22
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
23
|
-
};
|
|
24
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
-
exports.SlicesTypes = exports.SliceZone = exports.Slice = exports.SharedSliceRef = exports.SharedSlice = exports.LegacySlice = exports.CompositeSlice = void 0;
|
|
26
|
-
var CompositeSlice_1 = require("./CompositeSlice");
|
|
27
|
-
Object.defineProperty(exports, "CompositeSlice", { enumerable: true, get: function () { return __importDefault(CompositeSlice_1).default; } });
|
|
28
|
-
var LegacySlice_1 = require("./LegacySlice");
|
|
29
|
-
Object.defineProperty(exports, "LegacySlice", { enumerable: true, get: function () { return __importDefault(LegacySlice_1).default; } });
|
|
30
|
-
var SharedSlice_1 = require("./SharedSlice");
|
|
31
|
-
Object.defineProperty(exports, "SharedSlice", { enumerable: true, get: function () { return __importDefault(SharedSlice_1).default; } });
|
|
32
|
-
var SharedSliceRef_1 = require("./SharedSliceRef");
|
|
33
|
-
Object.defineProperty(exports, "SharedSliceRef", { enumerable: true, get: function () { return __importDefault(SharedSliceRef_1).default; } });
|
|
34
|
-
exports.Slice = __importStar(require("./Slice"));
|
|
35
|
-
exports.SliceZone = __importStar(require("./Slices"));
|
|
36
|
-
var SlicesTypes_1 = require("./SlicesTypes");
|
|
37
|
-
Object.defineProperty(exports, "SlicesTypes", { enumerable: true, get: function () { return __importDefault(SlicesTypes_1).default; } });
|
|
1
|
+
export { default as CompositeSlice } from "./CompositeSlice";
|
|
2
|
+
export { default as LegacySlice } from "./LegacySlice";
|
|
3
|
+
export { default as SharedSlice } from "./SharedSlice";
|
|
4
|
+
export { default as SharedSliceRef } from "./SharedSliceRef";
|
|
5
|
+
export * as Slice from "./Slice";
|
|
6
|
+
export * as SliceZone from "./Slices";
|
|
7
|
+
export { default as SlicesTypes } from "./SlicesTypes";
|
|
@@ -1,32 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
-
}) : (function(o, m, k, k2) {
|
|
6
|
-
if (k2 === undefined) k2 = k;
|
|
7
|
-
o[k2] = m[k];
|
|
8
|
-
}));
|
|
9
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
-
}) : function(o, v) {
|
|
12
|
-
o["default"] = v;
|
|
13
|
-
});
|
|
14
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
-
if (mod && mod.__esModule) return mod;
|
|
16
|
-
var result = {};
|
|
17
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
-
__setModuleDefault(result, mod);
|
|
19
|
-
return result;
|
|
20
|
-
};
|
|
21
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
-
const O = __importStar(require("fp-ts/lib/Option"));
|
|
23
|
-
const widgets_1 = require("./widgets");
|
|
1
|
+
import * as O from "fp-ts/lib/Option";
|
|
2
|
+
import { Widget } from "./widgets";
|
|
24
3
|
function computeWidget(key, widgets, widgetTypes, widgetPositions) {
|
|
25
4
|
const widget = widgets.get(key);
|
|
26
5
|
if (widget === undefined) {
|
|
27
6
|
return O.none;
|
|
28
7
|
}
|
|
29
|
-
return
|
|
8
|
+
return Widget.fromJson(key, widget, widgetTypes, widgetPositions);
|
|
30
9
|
}
|
|
31
10
|
const DocumentData = {
|
|
32
11
|
getWidget(key, widgets, widgetTypes, widgetPositions, parsed) {
|
|
@@ -43,4 +22,4 @@ const DocumentData = {
|
|
|
43
22
|
}, new Map());
|
|
44
23
|
},
|
|
45
24
|
};
|
|
46
|
-
|
|
25
|
+
export default DocumentData;
|
package/lib/documents/index.js
CHANGED
|
@@ -1,28 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
-
}) : (function(o, m, k, k2) {
|
|
6
|
-
if (k2 === undefined) k2 = k;
|
|
7
|
-
o[k2] = m[k];
|
|
8
|
-
}));
|
|
9
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
-
}) : function(o, v) {
|
|
12
|
-
o["default"] = v;
|
|
13
|
-
});
|
|
14
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
-
if (mod && mod.__esModule) return mod;
|
|
16
|
-
var result = {};
|
|
17
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
-
__setModuleDefault(result, mod);
|
|
19
|
-
return result;
|
|
20
|
-
};
|
|
21
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
22
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
23
|
-
};
|
|
24
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
-
exports.Widgets = exports.DocumentData = void 0;
|
|
26
|
-
var DocumentData_1 = require("./DocumentData");
|
|
27
|
-
Object.defineProperty(exports, "DocumentData", { enumerable: true, get: function () { return __importDefault(DocumentData_1).default; } });
|
|
28
|
-
exports.Widgets = __importStar(require("./widgets"));
|
|
1
|
+
export { default as DocumentData } from "./DocumentData";
|
|
2
|
+
export * as Widgets from "./widgets";
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.EmptyContent = exports.EmptyContentType = void 0;
|
|
4
|
-
exports.EmptyContentType = "EmptyContent";
|
|
5
|
-
exports.EmptyContent = {
|
|
1
|
+
export const EmptyContentType = "EmptyContent";
|
|
2
|
+
export const EmptyContent = {
|
|
6
3
|
is: (value) => {
|
|
7
|
-
return value.__TYPE__ ===
|
|
4
|
+
return value.__TYPE__ === EmptyContentType;
|
|
8
5
|
},
|
|
9
6
|
};
|
|
@@ -1,32 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}));
|
|
9
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
-
}) : function(o, v) {
|
|
12
|
-
o["default"] = v;
|
|
13
|
-
});
|
|
14
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
-
if (mod && mod.__esModule) return mod;
|
|
16
|
-
var result = {};
|
|
17
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
-
__setModuleDefault(result, mod);
|
|
19
|
-
return result;
|
|
20
|
-
};
|
|
21
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
-
exports.GroupContent = exports.GroupContentType = exports.GroupItemContentType = void 0;
|
|
23
|
-
const A = __importStar(require("fp-ts/Array"));
|
|
24
|
-
const O = __importStar(require("fp-ts/Option"));
|
|
25
|
-
const t = __importStar(require("io-ts"));
|
|
26
|
-
const SimpleWidgetContent_1 = require("./SimpleWidgetContent");
|
|
27
|
-
exports.GroupItemContentType = "GroupItemContent";
|
|
28
|
-
exports.GroupContentType = "GroupContentType";
|
|
29
|
-
exports.GroupContent = Object.freeze({
|
|
1
|
+
import * as A from "fp-ts/Array";
|
|
2
|
+
import * as O from "fp-ts/Option";
|
|
3
|
+
import * as t from "io-ts";
|
|
4
|
+
import { SimpleWidgetContent } from "./SimpleWidgetContent";
|
|
5
|
+
export const GroupItemContentType = "GroupItemContent";
|
|
6
|
+
export const GroupContentType = "GroupContentType";
|
|
7
|
+
export const GroupContent = Object.freeze({
|
|
30
8
|
itemsContentsFromJson: (prefixedKey, jsItems, fieldTypes, fieldPositions) => {
|
|
31
9
|
if (jsItems) {
|
|
32
10
|
return jsItems.map((jsItem) => {
|
|
@@ -41,7 +19,7 @@ exports.GroupContent = Object.freeze({
|
|
|
41
19
|
if (kind) {
|
|
42
20
|
return O.map((content) => {
|
|
43
21
|
return [k, content];
|
|
44
|
-
})(
|
|
22
|
+
})(SimpleWidgetContent.from(kind, v));
|
|
45
23
|
}
|
|
46
24
|
else {
|
|
47
25
|
return O.none;
|
|
@@ -69,8 +47,8 @@ exports.GroupContent = Object.freeze({
|
|
|
69
47
|
const maybeJsItems = O.fromEither(t.array(t.unknown).decode(value));
|
|
70
48
|
return O.map((items) => {
|
|
71
49
|
return {
|
|
72
|
-
value:
|
|
73
|
-
__TYPE__:
|
|
50
|
+
value: GroupContent.itemsContentsFromJson(prefixedKey, items, fieldTypes, fieldPositions),
|
|
51
|
+
__TYPE__: GroupContentType,
|
|
74
52
|
};
|
|
75
53
|
})(maybeJsItems);
|
|
76
54
|
},
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as O from "fp-ts/Option";
|
|
2
|
-
import { EmptyContent } from "./EmptyContent";
|
|
2
|
+
import type { EmptyContent } from "./EmptyContent";
|
|
3
3
|
import BooleanContent from "./nestable/BooleanContent";
|
|
4
4
|
import EmbedContent from "./nestable/EmbedContent";
|
|
5
5
|
import FieldContent from "./nestable/FieldContent";
|
|
@@ -7,7 +7,7 @@ import { GeoPointContentO } from "./nestable/GeoPointContent";
|
|
|
7
7
|
import { ImageContentO } from "./nestable/ImageContent";
|
|
8
8
|
import IntegrationFieldsContent from "./nestable/IntegrationFieldsContent";
|
|
9
9
|
import { LinkContent } from "./nestable/Link";
|
|
10
|
-
import { SeparatorContent } from "./nestable/SeparatorContent";
|
|
10
|
+
import type { SeparatorContent } from "./nestable/SeparatorContent";
|
|
11
11
|
import { StructuredTextContent } from "./nestable/StructuredTextContent";
|
|
12
12
|
import { UIDContent } from "./UIDContent";
|
|
13
13
|
export declare const SimpleWidgetContentType: string[];
|
|
@@ -1,42 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
});
|
|
14
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
-
if (mod && mod.__esModule) return mod;
|
|
16
|
-
var result = {};
|
|
17
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
-
__setModuleDefault(result, mod);
|
|
19
|
-
return result;
|
|
20
|
-
};
|
|
21
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
22
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
23
|
-
};
|
|
24
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
-
exports.SimpleWidgetContent = exports.is = exports.SimpleWidgetContentType = void 0;
|
|
26
|
-
const function_1 = require("fp-ts/function");
|
|
27
|
-
const O = __importStar(require("fp-ts/Option"));
|
|
28
|
-
const t = __importStar(require("io-ts"));
|
|
29
|
-
const BooleanContent_1 = __importDefault(require("./nestable/BooleanContent"));
|
|
30
|
-
const EmbedContent_1 = __importDefault(require("./nestable/EmbedContent"));
|
|
31
|
-
const FieldContent_1 = __importDefault(require("./nestable/FieldContent"));
|
|
32
|
-
const GeoPointContent_1 = require("./nestable/GeoPointContent");
|
|
33
|
-
const ImageContent_1 = require("./nestable/ImageContent");
|
|
34
|
-
const IntegrationFieldsContent_1 = __importDefault(require("./nestable/IntegrationFieldsContent"));
|
|
35
|
-
const Link_1 = require("./nestable/Link");
|
|
36
|
-
const StructuredTextContent_1 = require("./nestable/StructuredTextContent");
|
|
37
|
-
const UIDContent_1 = require("./UIDContent");
|
|
1
|
+
import { pipe } from "fp-ts/function";
|
|
2
|
+
import * as O from "fp-ts/Option";
|
|
3
|
+
import * as t from "io-ts";
|
|
4
|
+
import BooleanContent from "./nestable/BooleanContent";
|
|
5
|
+
import EmbedContent from "./nestable/EmbedContent";
|
|
6
|
+
import FieldContent from "./nestable/FieldContent";
|
|
7
|
+
import { GeoPointContent } from "./nestable/GeoPointContent";
|
|
8
|
+
import { ImageContent } from "./nestable/ImageContent";
|
|
9
|
+
import IntegrationFieldsContent from "./nestable/IntegrationFieldsContent";
|
|
10
|
+
import { LinkContent } from "./nestable/Link";
|
|
11
|
+
import { StructuredTextContent } from "./nestable/StructuredTextContent";
|
|
12
|
+
import { UIDContent } from "./UIDContent";
|
|
38
13
|
//TODO: rework that using import such as EmptyContentType
|
|
39
|
-
|
|
14
|
+
export const SimpleWidgetContentType = [
|
|
40
15
|
"EmptyContent",
|
|
41
16
|
"ImageContent",
|
|
42
17
|
"GeoPointContent",
|
|
@@ -49,15 +24,14 @@ exports.SimpleWidgetContentType = [
|
|
|
49
24
|
"SeparatorContent",
|
|
50
25
|
"FieldContent",
|
|
51
26
|
];
|
|
52
|
-
function is(value) {
|
|
27
|
+
export function is(value) {
|
|
53
28
|
const asSwc = value;
|
|
54
|
-
return
|
|
29
|
+
return SimpleWidgetContentType.includes(asSwc.__TYPE__);
|
|
55
30
|
}
|
|
56
|
-
exports.is = is;
|
|
57
31
|
const valueNullCodec = t.type({
|
|
58
32
|
value: t.null,
|
|
59
33
|
});
|
|
60
|
-
|
|
34
|
+
export const SimpleWidgetContent = {
|
|
61
35
|
from: (type, content) => {
|
|
62
36
|
if (content === null || valueNullCodec.is(content)) {
|
|
63
37
|
const result = { type: type, __TYPE__: "EmptyContent" };
|
|
@@ -65,26 +39,26 @@ exports.SimpleWidgetContent = {
|
|
|
65
39
|
}
|
|
66
40
|
switch (type) {
|
|
67
41
|
case "StructuredText":
|
|
68
|
-
return O.fromEither(
|
|
42
|
+
return O.fromEither(StructuredTextContent.decode(content));
|
|
69
43
|
case "IntegrationFields":
|
|
70
|
-
return O.fromEither(
|
|
44
|
+
return O.fromEither(IntegrationFieldsContent.decode(content));
|
|
71
45
|
case "Image":
|
|
72
|
-
return
|
|
46
|
+
return pipe(O.fromEither(ImageContent.decode(content)), O.map((imageContent) => ImageContent.encode(imageContent)));
|
|
73
47
|
case "GeoPoint":
|
|
74
|
-
return
|
|
48
|
+
return pipe(O.fromEither(GeoPointContent.decode(content)), O.map((geopointContent) => GeoPointContent.encode(geopointContent)));
|
|
75
49
|
case "Embed":
|
|
76
|
-
return O.fromEither(
|
|
50
|
+
return O.fromEither(EmbedContent.decode(content));
|
|
77
51
|
case "Link":
|
|
78
|
-
return O.fromEither(
|
|
52
|
+
return O.fromEither(LinkContent.decode(content));
|
|
79
53
|
case "UID":
|
|
80
|
-
return O.fromEither(
|
|
54
|
+
return O.fromEither(UIDContent.decode(content));
|
|
81
55
|
case "Separator":
|
|
82
56
|
return O.some({ __TYPE__: "SeparatorContent" });
|
|
83
57
|
case "Boolean":
|
|
84
|
-
return O.fromEither(
|
|
58
|
+
return O.fromEither(BooleanContent.decode(content));
|
|
85
59
|
default:
|
|
86
|
-
if (
|
|
87
|
-
return
|
|
60
|
+
if (FieldContent.types.includes(type)) {
|
|
61
|
+
return FieldContent.forType(type, content);
|
|
88
62
|
}
|
|
89
63
|
else {
|
|
90
64
|
return O.none;
|
|
@@ -92,5 +66,5 @@ exports.SimpleWidgetContent = {
|
|
|
92
66
|
}
|
|
93
67
|
},
|
|
94
68
|
//TODO: rework that
|
|
95
|
-
is: (value) =>
|
|
69
|
+
is: (value) => SimpleWidgetContentType.includes(value.__TYPE__),
|
|
96
70
|
};
|
|
@@ -1,44 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
-
}) : (function(o, m, k, k2) {
|
|
6
|
-
if (k2 === undefined) k2 = k;
|
|
7
|
-
o[k2] = m[k];
|
|
8
|
-
}));
|
|
9
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
-
}) : function(o, v) {
|
|
12
|
-
o["default"] = v;
|
|
13
|
-
});
|
|
14
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
-
if (mod && mod.__esModule) return mod;
|
|
16
|
-
var result = {};
|
|
17
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
-
__setModuleDefault(result, mod);
|
|
19
|
-
return result;
|
|
20
|
-
};
|
|
21
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
-
const O = __importStar(require("fp-ts/Option"));
|
|
23
|
-
const GroupContent_1 = require("./GroupContent");
|
|
24
|
-
const SimpleWidgetContent_1 = require("./SimpleWidgetContent");
|
|
1
|
+
import * as O from "fp-ts/Option";
|
|
2
|
+
import { GroupContent, GroupContentType } from "./GroupContent";
|
|
3
|
+
import { SimpleWidgetContent, } from "./SimpleWidgetContent";
|
|
25
4
|
const StaticWidgetContent = {
|
|
26
5
|
fromJson: (prefixes, key, value, fieldTypes, fieldPositions) => {
|
|
27
6
|
const prefixedKey = Array.of(prefixes, [key]).flat().join(".");
|
|
28
7
|
const type = fieldTypes.get(prefixedKey);
|
|
29
8
|
if (type === "Group") {
|
|
30
|
-
return
|
|
9
|
+
return GroupContent.fromJson(prefixes, key, value, fieldTypes, fieldPositions);
|
|
31
10
|
}
|
|
32
11
|
else if (type) {
|
|
33
|
-
return
|
|
12
|
+
return SimpleWidgetContent.from(type, value);
|
|
34
13
|
}
|
|
35
14
|
else {
|
|
36
15
|
return O.none;
|
|
37
16
|
}
|
|
38
17
|
},
|
|
39
18
|
is: (value) => {
|
|
40
|
-
return (
|
|
41
|
-
|
|
19
|
+
return (SimpleWidgetContent.is(value) ||
|
|
20
|
+
GroupContentType === value.__TYPE__);
|
|
42
21
|
},
|
|
43
22
|
};
|
|
44
|
-
|
|
23
|
+
export default StaticWidgetContent;
|
|
@@ -1,28 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
}) : (function(o, m, k, k2) {
|
|
6
|
-
if (k2 === undefined) k2 = k;
|
|
7
|
-
o[k2] = m[k];
|
|
8
|
-
}));
|
|
9
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
-
}) : function(o, v) {
|
|
12
|
-
o["default"] = v;
|
|
13
|
-
});
|
|
14
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
-
if (mod && mod.__esModule) return mod;
|
|
16
|
-
var result = {};
|
|
17
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
-
__setModuleDefault(result, mod);
|
|
19
|
-
return result;
|
|
20
|
-
};
|
|
21
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
-
exports.UIDContent = exports.UIDContentType = void 0;
|
|
23
|
-
const Either_1 = require("fp-ts/Either");
|
|
24
|
-
const t = __importStar(require("io-ts"));
|
|
25
|
-
exports.UIDContentType = "UIDContent";
|
|
26
|
-
exports.UIDContent = new t.Type("UIDContent", (u) => u?.__TYPE__ === exports.UIDContentType, (u, c) => Either_1.Chain.chain(t.string.validate(u, c), (u) => {
|
|
1
|
+
import { Chain } from "fp-ts/Either";
|
|
2
|
+
import * as t from "io-ts";
|
|
3
|
+
export const UIDContentType = "UIDContent";
|
|
4
|
+
export const UIDContent = new t.Type("UIDContent", (u) => u?.__TYPE__ === UIDContentType, (u, c) => Chain.chain(t.string.validate(u, c), (u) => {
|
|
27
5
|
return t.success({ value: u, __TYPE__: "UIDContent" });
|
|
28
6
|
}), (uidContent) => uidContent.value);
|
|
@@ -1,60 +1,31 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
1
|
+
import { EmptyContentType } from "./EmptyContent";
|
|
2
|
+
import { GroupContentType } from "./GroupContent";
|
|
3
|
+
import { NestableTypes } from "./nestable";
|
|
4
|
+
import { SlicesContent, SlicesContentType } from "./slices/SlicesContent";
|
|
5
|
+
import StaticWidgetContent from "./StaticWidgetContent";
|
|
6
|
+
import { UIDContentType } from "./UIDContent";
|
|
7
|
+
export * from "./EmptyContent";
|
|
8
|
+
export * from "./GroupContent";
|
|
9
|
+
export * as Nestable from "./nestable";
|
|
10
|
+
export * from "./SimpleWidgetContent";
|
|
11
|
+
export * as Slices from "./slices";
|
|
12
|
+
export { default as StaticWidgetContent, } from "./StaticWidgetContent";
|
|
13
|
+
export * from "./UIDContent";
|
|
14
|
+
export const WidgetTypes = {
|
|
15
|
+
...NestableTypes,
|
|
16
|
+
Empty: EmptyContentType,
|
|
17
|
+
UID: UIDContentType,
|
|
18
|
+
Group: GroupContentType,
|
|
19
|
+
slices: SlicesContentType,
|
|
16
20
|
};
|
|
17
|
-
|
|
18
|
-
if (mod && mod.__esModule) return mod;
|
|
19
|
-
var result = {};
|
|
20
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
21
|
-
__setModuleDefault(result, mod);
|
|
22
|
-
return result;
|
|
23
|
-
};
|
|
24
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
25
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
26
|
-
};
|
|
27
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
|
-
exports.Widget = exports.WidgetTypes = exports.StaticWidgetContent = exports.Slices = exports.Nestable = void 0;
|
|
29
|
-
const EmptyContent_1 = require("./EmptyContent");
|
|
30
|
-
const GroupContent_1 = require("./GroupContent");
|
|
31
|
-
const nestable_1 = require("./nestable");
|
|
32
|
-
const SlicesContent_1 = require("./slices/SlicesContent");
|
|
33
|
-
const StaticWidgetContent_1 = __importDefault(require("./StaticWidgetContent"));
|
|
34
|
-
const UIDContent_1 = require("./UIDContent");
|
|
35
|
-
__exportStar(require("./EmptyContent"), exports);
|
|
36
|
-
__exportStar(require("./GroupContent"), exports);
|
|
37
|
-
exports.Nestable = __importStar(require("./nestable"));
|
|
38
|
-
__exportStar(require("./SimpleWidgetContent"), exports);
|
|
39
|
-
exports.Slices = __importStar(require("./slices"));
|
|
40
|
-
var StaticWidgetContent_2 = require("./StaticWidgetContent");
|
|
41
|
-
Object.defineProperty(exports, "StaticWidgetContent", { enumerable: true, get: function () { return __importDefault(StaticWidgetContent_2).default; } });
|
|
42
|
-
__exportStar(require("./UIDContent"), exports);
|
|
43
|
-
exports.WidgetTypes = {
|
|
44
|
-
...nestable_1.NestableTypes,
|
|
45
|
-
Empty: EmptyContent_1.EmptyContentType,
|
|
46
|
-
UID: UIDContent_1.UIDContentType,
|
|
47
|
-
Group: GroupContent_1.GroupContentType,
|
|
48
|
-
slices: SlicesContent_1.SlicesContentType,
|
|
49
|
-
};
|
|
50
|
-
exports.Widget = {
|
|
21
|
+
export const Widget = {
|
|
51
22
|
fromJson(widgetKey, widgetValue, widgetTypes, widgetPositions) {
|
|
52
23
|
const fieldType = widgetTypes.get(widgetKey);
|
|
53
24
|
if (fieldType === "Slices") {
|
|
54
|
-
return
|
|
25
|
+
return SlicesContent.fromJson(widgetKey, widgetValue, widgetTypes, widgetPositions);
|
|
55
26
|
}
|
|
56
27
|
else {
|
|
57
|
-
return
|
|
28
|
+
return StaticWidgetContent.fromJson([], widgetKey, widgetValue, widgetTypes, widgetPositions);
|
|
58
29
|
}
|
|
59
30
|
},
|
|
60
31
|
};
|