@prismicio/types-internal 2.0.0-alpha.2 → 2.0.0-alpha.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/package.json +1 -1
- package/lib/content/CustomType.d.ts +0 -2972
- package/lib/content/CustomType.js +0 -15
- package/lib/content/fields/nestable/FieldContent.d.ts +0 -32
- package/lib/content/fields/nestable/FieldContent.js +0 -37
- package/lib/content/fields/nestable/Image.d.ts +0 -103
- package/lib/content/fields/nestable/Image.js +0 -13
- package/lib/content/fields/nestable/RichTextContent.d.ts +0 -376
- package/lib/content/fields/nestable/RichTextContent.js +0 -16
- package/lib/content/fields/slices/CompositeSliceContent.d.ts +0 -677
- package/lib/content/fields/slices/CompositeSliceContent.js +0 -14
- package/lib/content/fields/slices/RepeatableContent.d.ts +0 -338
- package/lib/content/fields/slices/RepeatableContent.js +0 -16
- package/lib/content/fields/slices/SharedSliceContent.d.ts +0 -678
- package/lib/content/fields/slices/SharedSliceContent.js +0 -15
- package/lib/content/fields/slices/SimpleSliceContent.d.ts +0 -675
- package/lib/content/fields/slices/SimpleSliceContent.js +0 -8
- package/lib/customtypes/Comparators/Changes.d.ts +0 -17
- package/lib/customtypes/Comparators/Changes.js +0 -9
- package/lib/customtypes/Comparators/SharedSlice.d.ts +0 -679
- package/lib/customtypes/Comparators/SharedSlice.js +0 -55
- package/lib/customtypes/Comparators/Variation.d.ts +0 -662
- package/lib/customtypes/Comparators/Variation.js +0 -75
- package/lib/customtypes/Comparators/index.d.ts +0 -3
- package/lib/customtypes/Comparators/index.js +0 -6
- package/lib/customtypes/Format.d.ts +0 -4
- package/lib/customtypes/Format.js +0 -8
- package/lib/customtypes/comp/Changes.d.ts +0 -17
- package/lib/customtypes/comp/Changes.js +0 -9
- package/lib/customtypes/comp/SharedSlice.d.ts +0 -679
- package/lib/customtypes/comp/SharedSlice.js +0 -55
- package/lib/customtypes/comp/Variation.d.ts +0 -662
- package/lib/customtypes/comp/Variation.js +0 -76
- package/lib/customtypes/comp/index.d.ts +0 -3
- package/lib/customtypes/comp/index.js +0 -6
- package/lib/customtypes/utils/Comparator.d.ts +0 -1353
- package/lib/customtypes/utils/Comparator.js +0 -59
- package/lib/customtypes/utils/index.d.ts +0 -1
- package/lib/customtypes/utils/index.js +0 -4
- package/lib/customtypes/widgets/WidgetTypes.d.ts +0 -22
- package/lib/customtypes/widgets/WidgetTypes.js +0 -25
- package/lib/documents/DocumentData.d.ts +0 -6
- package/lib/documents/DocumentData.js +0 -15
- package/lib/documents/index.d.ts +0 -2
- package/lib/documents/index.js +0 -7
- package/lib/documents/widgets/EmptyContent.d.ts +0 -8
- package/lib/documents/widgets/EmptyContent.js +0 -9
- package/lib/documents/widgets/GroupContent.d.ts +0 -16
- package/lib/documents/widgets/GroupContent.js +0 -60
- package/lib/documents/widgets/SimpleWidgetContent.d.ts +0 -20
- package/lib/documents/widgets/SimpleWidgetContent.js +0 -75
- package/lib/documents/widgets/StaticWidgetContent.d.ts +0 -10
- package/lib/documents/widgets/StaticWidgetContent.js +0 -26
- package/lib/documents/widgets/UIDContent.d.ts +0 -7
- package/lib/documents/widgets/UIDContent.js +0 -10
- package/lib/documents/widgets/index.d.ts +0 -38
- package/lib/documents/widgets/index.js +0 -40
- package/lib/documents/widgets/nestable/BooleanContent.d.ts +0 -8
- package/lib/documents/widgets/nestable/BooleanContent.js +0 -11
- package/lib/documents/widgets/nestable/EmbedContent.d.ts +0 -42
- package/lib/documents/widgets/nestable/EmbedContent.js +0 -35
- package/lib/documents/widgets/nestable/FieldContent.d.ts +0 -13
- package/lib/documents/widgets/nestable/FieldContent.js +0 -37
- package/lib/documents/widgets/nestable/GeoPointContent.d.ts +0 -17
- package/lib/documents/widgets/nestable/GeoPointContent.js +0 -13
- package/lib/documents/widgets/nestable/ImageContent.d.ts +0 -127
- package/lib/documents/widgets/nestable/ImageContent.js +0 -41
- package/lib/documents/widgets/nestable/IntegrationFieldsContent.d.ts +0 -8
- package/lib/documents/widgets/nestable/IntegrationFieldsContent.js +0 -16
- package/lib/documents/widgets/nestable/Link/DocumentLink.d.ts +0 -12
- package/lib/documents/widgets/nestable/Link/DocumentLink.js +0 -13
- package/lib/documents/widgets/nestable/Link/ExternalLink.d.ts +0 -24
- package/lib/documents/widgets/nestable/Link/ExternalLink.js +0 -24
- package/lib/documents/widgets/nestable/Link/FileLink.d.ts +0 -22
- package/lib/documents/widgets/nestable/Link/FileLink.js +0 -25
- package/lib/documents/widgets/nestable/Link/ImageLink.d.ts +0 -28
- package/lib/documents/widgets/nestable/Link/ImageLink.js +0 -26
- package/lib/documents/widgets/nestable/Link/LinkContent.d.ts +0 -42
- package/lib/documents/widgets/nestable/Link/LinkContent.js +0 -17
- package/lib/documents/widgets/nestable/Link/index.d.ts +0 -90
- package/lib/documents/widgets/nestable/Link/index.js +0 -35
- package/lib/documents/widgets/nestable/SeparatorContent.d.ts +0 -11
- package/lib/documents/widgets/nestable/SeparatorContent.js +0 -15
- package/lib/documents/widgets/nestable/StructuredTextContent/Block.d.ts +0 -314
- package/lib/documents/widgets/nestable/StructuredTextContent/Block.js +0 -98
- package/lib/documents/widgets/nestable/StructuredTextContent/index.d.ts +0 -9
- package/lib/documents/widgets/nestable/StructuredTextContent/index.js +0 -14
- package/lib/documents/widgets/nestable/index.d.ts +0 -26
- package/lib/documents/widgets/nestable/index.js +0 -39
- package/lib/documents/widgets/slices/CompositeSliceContent.d.ts +0 -14
- package/lib/documents/widgets/slices/CompositeSliceContent.js +0 -52
- package/lib/documents/widgets/slices/SharedSliceContent.d.ts +0 -15
- package/lib/documents/widgets/slices/SharedSliceContent.js +0 -63
- package/lib/documents/widgets/slices/SimpleSliceContent.d.ts +0 -6
- package/lib/documents/widgets/slices/SimpleSliceContent.js +0 -6
- package/lib/documents/widgets/slices/SliceWidgetContent.d.ts +0 -8
- package/lib/documents/widgets/slices/SliceWidgetContent.js +0 -26
- package/lib/documents/widgets/slices/SlicesContent.d.ts +0 -17
- package/lib/documents/widgets/slices/SlicesContent.js +0 -52
- package/lib/documents/widgets/slices/index.d.ts +0 -5
- package/lib/documents/widgets/slices/index.js +0 -8
- package/lib/index.d.ts +0 -3
- package/lib/index.js +0 -7
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SliceComparator = exports.DiffOperation = void 0;
|
|
4
|
-
const utils_1 = require("../../utils");
|
|
5
|
-
var DiffOperation;
|
|
6
|
-
(function (DiffOperation) {
|
|
7
|
-
DiffOperation["Added"] = "added";
|
|
8
|
-
DiffOperation["Removed"] = "removed";
|
|
9
|
-
DiffOperation["Updated"] = "updated";
|
|
10
|
-
})(DiffOperation = exports.DiffOperation || (exports.DiffOperation = {}));
|
|
11
|
-
function compareSliceMeta(sliceA, sliceB) {
|
|
12
|
-
const zippedSlices = utils_1.Objects.zipObjects(sliceA, sliceB);
|
|
13
|
-
return Object.entries(zippedSlices).reduce((acc, [key, value]) => {
|
|
14
|
-
if (key === `variations`)
|
|
15
|
-
return acc;
|
|
16
|
-
if ((value === null || value === void 0 ? void 0 : value.left) === (value === null || value === void 0 ? void 0 : value.right))
|
|
17
|
-
return acc;
|
|
18
|
-
return { ...acc, [key]: value === null || value === void 0 ? void 0 : value.right };
|
|
19
|
-
}, {});
|
|
20
|
-
}
|
|
21
|
-
exports.SliceComparator = {
|
|
22
|
-
compare(sliceA, sliceB) {
|
|
23
|
-
if (!sliceA && sliceB)
|
|
24
|
-
return {
|
|
25
|
-
op: DiffOperation.Added,
|
|
26
|
-
value: sliceB,
|
|
27
|
-
};
|
|
28
|
-
if (sliceA && !sliceB)
|
|
29
|
-
return {
|
|
30
|
-
op: DiffOperation.Removed,
|
|
31
|
-
};
|
|
32
|
-
const diffMeta = compareSliceMeta(sliceA, sliceB);
|
|
33
|
-
const zippedSlices = utils_1.Objects.zipObjects(sliceA && utils_1.Arrays.toRecord(sliceA.variations, (v) => v.id), sliceB && utils_1.Arrays.toRecord(sliceB.variations, (v) => v.id));
|
|
34
|
-
const diffVariations = Object.entries(zippedSlices).reduce((acc, [variationId, value]) => {
|
|
35
|
-
if (!value)
|
|
36
|
-
return acc;
|
|
37
|
-
const vDiff = VariationComparator.compare(value.left, value.right);
|
|
38
|
-
if (!vDiff)
|
|
39
|
-
return acc;
|
|
40
|
-
return {
|
|
41
|
-
...acc,
|
|
42
|
-
[variationId]: vDiff,
|
|
43
|
-
};
|
|
44
|
-
}, {});
|
|
45
|
-
const diffSlice = {
|
|
46
|
-
...diffMeta,
|
|
47
|
-
...(utils_1.Objects.isNotEmpty(diffVariations)
|
|
48
|
-
? { variations: diffVariations }
|
|
49
|
-
: {}),
|
|
50
|
-
};
|
|
51
|
-
if (utils_1.Objects.isNotEmpty(diffSlice)) {
|
|
52
|
-
return {
|
|
53
|
-
op: DiffOperation.Updated,
|
|
54
|
-
value: diffSlice,
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
return undefined;
|
|
58
|
-
},
|
|
59
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./Comparator";
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
export declare const WidgetTypes: {
|
|
2
|
-
readonly Text: "Text";
|
|
3
|
-
readonly RichText: "StructuredText";
|
|
4
|
-
readonly Color: "Color";
|
|
5
|
-
readonly Image: "Image";
|
|
6
|
-
readonly Date: "Date";
|
|
7
|
-
readonly Timestamp: "Timestamp";
|
|
8
|
-
readonly Number: "Number";
|
|
9
|
-
readonly Range: "Range";
|
|
10
|
-
readonly Select: "Select";
|
|
11
|
-
readonly Link: "Link";
|
|
12
|
-
readonly Embed: "Embed";
|
|
13
|
-
readonly GeoPoint: "GeoPoint";
|
|
14
|
-
readonly Separator: "Separator";
|
|
15
|
-
readonly UID: "UID";
|
|
16
|
-
readonly BooleanField: "Boolean";
|
|
17
|
-
readonly IntegrationField: "IntegrationFields";
|
|
18
|
-
readonly Group: "Group";
|
|
19
|
-
readonly Slices: "Slices";
|
|
20
|
-
readonly LegacySlices: "Choice";
|
|
21
|
-
};
|
|
22
|
-
export declare type WidgetTypes = typeof WidgetTypes[keyof typeof WidgetTypes];
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.WidgetTypes = void 0;
|
|
4
|
-
exports.WidgetTypes = {
|
|
5
|
-
Text: "Text",
|
|
6
|
-
RichText: "StructuredText",
|
|
7
|
-
Color: "Color",
|
|
8
|
-
Image: "Image",
|
|
9
|
-
Date: "Date",
|
|
10
|
-
Timestamp: "Timestamp",
|
|
11
|
-
Number: "Number",
|
|
12
|
-
Range: "Range",
|
|
13
|
-
Select: "Select",
|
|
14
|
-
Link: "Link",
|
|
15
|
-
Embed: "Embed",
|
|
16
|
-
GeoPoint: "GeoPoint",
|
|
17
|
-
Separator: "Separator",
|
|
18
|
-
UID: "UID",
|
|
19
|
-
BooleanField: "Boolean",
|
|
20
|
-
IntegrationField: "IntegrationFields",
|
|
21
|
-
Group: "Group",
|
|
22
|
-
Slices: "Slices",
|
|
23
|
-
// Legacy type for slices
|
|
24
|
-
LegacySlices: "Choice",
|
|
25
|
-
};
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { WidgetContent, WidgetKey } from "../content";
|
|
2
|
-
import type { FieldTypes } from "../customtypes/widgets";
|
|
3
|
-
declare const DocumentData: {
|
|
4
|
-
getWidget(key: WidgetKey, widgetTypes: Map<WidgetKey, FieldTypes>, parsed: Map<string, WidgetContent>): WidgetContent | undefined;
|
|
5
|
-
};
|
|
6
|
-
export default DocumentData;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const content_1 = require("../content");
|
|
4
|
-
const LegacyContentCtx_1 = require("../content/LegacyContentCtx");
|
|
5
|
-
const DocumentData = {
|
|
6
|
-
getWidget(key, widgetTypes, parsed) {
|
|
7
|
-
const widget = parsed.get(key);
|
|
8
|
-
if (widget === undefined) {
|
|
9
|
-
const res = (0, content_1.WidgetLegacy)((0, LegacyContentCtx_1.defaultCtx)(key, widgetTypes)).decode(parsed);
|
|
10
|
-
return !res || res._tag === "Left" ? undefined : res.right;
|
|
11
|
-
}
|
|
12
|
-
return widget;
|
|
13
|
-
},
|
|
14
|
-
};
|
|
15
|
-
exports.default = DocumentData;
|
package/lib/documents/index.d.ts
DELETED
package/lib/documents/index.js
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
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,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.EmptyContent = exports.EmptyContentType = void 0;
|
|
4
|
-
exports.EmptyContentType = "EmptyContent";
|
|
5
|
-
exports.EmptyContent = {
|
|
6
|
-
is: (value) => {
|
|
7
|
-
return value.__TYPE__ === exports.EmptyContentType;
|
|
8
|
-
},
|
|
9
|
-
};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import * as O from "fp-ts/Option";
|
|
2
|
-
import { SimpleWidgetContent } from "./SimpleWidgetContent";
|
|
3
|
-
export declare const GroupItemContentType = "GroupItemContent";
|
|
4
|
-
export interface GroupItemContent {
|
|
5
|
-
__TYPE__: typeof GroupItemContentType;
|
|
6
|
-
value: Array<[string, SimpleWidgetContent]>;
|
|
7
|
-
}
|
|
8
|
-
export declare const GroupContentType = "GroupContentType";
|
|
9
|
-
export interface GroupContent {
|
|
10
|
-
__TYPE__: typeof GroupContentType;
|
|
11
|
-
value: GroupItemContent[];
|
|
12
|
-
}
|
|
13
|
-
export declare const GroupContent: Readonly<{
|
|
14
|
-
itemsContentsFromJson: (prefixedKey: string, jsItems: Array<unknown> | undefined, fieldTypes: Map<string, string>, fieldPositions: Map<string, number>) => Array<GroupItemContent>;
|
|
15
|
-
fromJson: (prefixes: Array<string>, key: string, value: unknown, fieldTypes: Map<string, string>, fieldPositions: Map<string, number>) => O.Option<GroupContent>;
|
|
16
|
-
}>;
|
|
@@ -1,60 +0,0 @@
|
|
|
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({
|
|
12
|
-
itemsContentsFromJson: (prefixedKey, jsItems, fieldTypes, fieldPositions) => {
|
|
13
|
-
if (jsItems) {
|
|
14
|
-
return jsItems.map((jsItem) => {
|
|
15
|
-
if (typeof jsItem === "object" && jsItem !== null) {
|
|
16
|
-
const sorted = Object.entries(jsItem).sort(([k1], [k2]) => {
|
|
17
|
-
var _a, _b;
|
|
18
|
-
const p1 = (_a = fieldPositions.get(`${prefixedKey}.${k1}`)) !== null && _a !== void 0 ? _a : 10000;
|
|
19
|
-
const p2 = (_b = fieldPositions.get(`${prefixedKey}.${k2}`)) !== null && _b !== void 0 ? _b : 10000;
|
|
20
|
-
return p1 - p2;
|
|
21
|
-
});
|
|
22
|
-
const w = sorted.map(([k, v]) => {
|
|
23
|
-
const kind = fieldTypes.get(`${prefixedKey}.${k}`);
|
|
24
|
-
if (kind) {
|
|
25
|
-
return O.map((content) => {
|
|
26
|
-
return [k, content];
|
|
27
|
-
})(SimpleWidgetContent_1.SimpleWidgetContent.from(kind, v));
|
|
28
|
-
}
|
|
29
|
-
else {
|
|
30
|
-
return O.none;
|
|
31
|
-
}
|
|
32
|
-
});
|
|
33
|
-
return {
|
|
34
|
-
__TYPE__: "GroupItemContent",
|
|
35
|
-
value: A.compact(w),
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
else {
|
|
39
|
-
return {
|
|
40
|
-
__TYPE__: "GroupItemContent",
|
|
41
|
-
value: [],
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
else {
|
|
47
|
-
return [];
|
|
48
|
-
}
|
|
49
|
-
},
|
|
50
|
-
fromJson: (prefixes, key, value, fieldTypes, fieldPositions) => {
|
|
51
|
-
const prefixedKey = Array.of(prefixes, [key]).flat().join(".");
|
|
52
|
-
const maybeJsItems = O.fromEither(t.array(t.unknown).decode(value));
|
|
53
|
-
return O.map((items) => {
|
|
54
|
-
return {
|
|
55
|
-
value: exports.GroupContent.itemsContentsFromJson(prefixedKey, items, fieldTypes, fieldPositions),
|
|
56
|
-
__TYPE__: exports.GroupContentType,
|
|
57
|
-
};
|
|
58
|
-
})(maybeJsItems);
|
|
59
|
-
},
|
|
60
|
-
});
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import * as O from "fp-ts/Option";
|
|
2
|
-
import type { EmptyContent } from "./EmptyContent";
|
|
3
|
-
import BooleanContent from "./nestable/BooleanContent";
|
|
4
|
-
import { EmbedContentO } from "./nestable/EmbedContent";
|
|
5
|
-
import FieldContent from "./nestable/FieldContent";
|
|
6
|
-
import { GeoPointContentO } from "./nestable/GeoPointContent";
|
|
7
|
-
import { ImageContentO } from "./nestable/ImageContent";
|
|
8
|
-
import IntegrationFieldsContent from "./nestable/IntegrationFieldsContent";
|
|
9
|
-
import { LinkContent } from "./nestable/Link";
|
|
10
|
-
import type { SeparatorContent } from "./nestable/SeparatorContent";
|
|
11
|
-
import { StructuredTextContent } from "./nestable/StructuredTextContent";
|
|
12
|
-
import { UIDContent } from "./UIDContent";
|
|
13
|
-
export declare const SimpleWidgetContentType: string[];
|
|
14
|
-
export declare type NonEmptySimpleWidgetContent = IntegrationFieldsContent | StructuredTextContent | ImageContentO | GeoPointContentO | EmbedContentO | LinkContent | UIDContent | SeparatorContent | FieldContent | BooleanContent;
|
|
15
|
-
export declare type SimpleWidgetContent = NonEmptySimpleWidgetContent | EmptyContent;
|
|
16
|
-
export declare function is(value: unknown): value is SimpleWidgetContent;
|
|
17
|
-
export declare const SimpleWidgetContent: {
|
|
18
|
-
from: (type: string, content: unknown) => O.Option<SimpleWidgetContent>;
|
|
19
|
-
is: (value: unknown) => value is SimpleWidgetContent;
|
|
20
|
-
};
|
|
@@ -1,75 +0,0 @@
|
|
|
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 = 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");
|
|
17
|
-
//TODO: rework that using import such as EmptyContentType
|
|
18
|
-
exports.SimpleWidgetContentType = [
|
|
19
|
-
"EmptyContent",
|
|
20
|
-
"ImageContent",
|
|
21
|
-
"GeoPointContent",
|
|
22
|
-
"EmbedContent",
|
|
23
|
-
"BooleanContent",
|
|
24
|
-
"IntegrationFieldsContent",
|
|
25
|
-
"StructuredTextContent",
|
|
26
|
-
"LinkContent",
|
|
27
|
-
"UIDContent",
|
|
28
|
-
"SeparatorContent",
|
|
29
|
-
"FieldContent",
|
|
30
|
-
];
|
|
31
|
-
function is(value) {
|
|
32
|
-
const asSwc = value;
|
|
33
|
-
return exports.SimpleWidgetContentType.includes(asSwc.__TYPE__);
|
|
34
|
-
}
|
|
35
|
-
exports.is = is;
|
|
36
|
-
const valueNullCodec = t.type({
|
|
37
|
-
value: t.null,
|
|
38
|
-
});
|
|
39
|
-
exports.SimpleWidgetContent = {
|
|
40
|
-
from: (type, content) => {
|
|
41
|
-
if (content === null || valueNullCodec.is(content)) {
|
|
42
|
-
const result = { type: type, __TYPE__: "EmptyContent" };
|
|
43
|
-
return O.some(result);
|
|
44
|
-
}
|
|
45
|
-
switch (type) {
|
|
46
|
-
case "StructuredText":
|
|
47
|
-
return O.fromEither(StructuredTextContent_1.StructuredTextContent.decode(content));
|
|
48
|
-
case "IntegrationFields":
|
|
49
|
-
return O.fromEither(IntegrationFieldsContent_1.default.decode(content));
|
|
50
|
-
case "Image":
|
|
51
|
-
return (0, function_1.pipe)(O.fromEither(ImageContent_1.ImageContent.decode(content)), O.map((imageContent) => ImageContent_1.ImageContent.encode(imageContent)));
|
|
52
|
-
case "GeoPoint":
|
|
53
|
-
return (0, function_1.pipe)(O.fromEither(GeoPointContent_1.GeoPointContent.decode(content)), O.map((geopointContent) => GeoPointContent_1.GeoPointContent.encode(geopointContent)));
|
|
54
|
-
case "Embed":
|
|
55
|
-
return O.fromEither(EmbedContent_1.EmbedContent.decode(content));
|
|
56
|
-
case "Link":
|
|
57
|
-
return O.fromEither(Link_1.LinkContent.decode(content));
|
|
58
|
-
case "UID":
|
|
59
|
-
return O.fromEither(UIDContent_1.UIDContent.decode(content));
|
|
60
|
-
case "Separator":
|
|
61
|
-
return O.some({ __TYPE__: "SeparatorContent" });
|
|
62
|
-
case "Boolean":
|
|
63
|
-
return O.fromEither(BooleanContent_1.default.decode(content));
|
|
64
|
-
default:
|
|
65
|
-
if (FieldContent_1.default.types.includes(type)) {
|
|
66
|
-
return FieldContent_1.default.forType(type, content);
|
|
67
|
-
}
|
|
68
|
-
else {
|
|
69
|
-
return O.none;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
},
|
|
73
|
-
//TODO: rework that
|
|
74
|
-
is: (value) => exports.SimpleWidgetContentType.includes(value.__TYPE__),
|
|
75
|
-
};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import * as O from "fp-ts/Option";
|
|
2
|
-
import { GroupContent } from "./GroupContent";
|
|
3
|
-
import { NonEmptySimpleWidgetContent, SimpleWidgetContent } from "./SimpleWidgetContent";
|
|
4
|
-
declare type StaticWidgetContent = SimpleWidgetContent | GroupContent;
|
|
5
|
-
export declare type NonEmptyStaticWidgetContent = NonEmptySimpleWidgetContent | GroupContent;
|
|
6
|
-
declare const StaticWidgetContent: {
|
|
7
|
-
fromJson: (prefixes: Array<string>, key: string, value: unknown, fieldTypes: Map<string, string>, fieldPositions: Map<string, number>) => O.Option<StaticWidgetContent>;
|
|
8
|
-
is: (value: unknown) => value is StaticWidgetContent;
|
|
9
|
-
};
|
|
10
|
-
export default StaticWidgetContent;
|
|
@@ -1,26 +0,0 @@
|
|
|
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");
|
|
7
|
-
const StaticWidgetContent = {
|
|
8
|
-
fromJson: (prefixes, key, value, fieldTypes, fieldPositions) => {
|
|
9
|
-
const prefixedKey = Array.of(prefixes, [key]).flat().join(".");
|
|
10
|
-
const type = fieldTypes.get(prefixedKey);
|
|
11
|
-
if (type === "Group") {
|
|
12
|
-
return GroupContent_1.GroupContent.fromJson(prefixes, key, value, fieldTypes, fieldPositions);
|
|
13
|
-
}
|
|
14
|
-
else if (type) {
|
|
15
|
-
return SimpleWidgetContent_1.SimpleWidgetContent.from(type, value);
|
|
16
|
-
}
|
|
17
|
-
else {
|
|
18
|
-
return O.none;
|
|
19
|
-
}
|
|
20
|
-
},
|
|
21
|
-
is: (value) => {
|
|
22
|
-
return (SimpleWidgetContent_1.SimpleWidgetContent.is(value) ||
|
|
23
|
-
GroupContent_1.GroupContentType === value.__TYPE__);
|
|
24
|
-
},
|
|
25
|
-
};
|
|
26
|
-
exports.default = StaticWidgetContent;
|
|
@@ -1,10 +0,0 @@
|
|
|
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) => { var _a; return ((_a = u) === null || _a === void 0 ? void 0 : _a.__TYPE__) === exports.UIDContentType; }, (u, c) => Either_1.Chain.chain(t.string.validate(u, c), (u) => {
|
|
9
|
-
return t.success({ value: u, __TYPE__: "UIDContent" });
|
|
10
|
-
}), (uidContent) => uidContent.value);
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import * as t from "io-ts";
|
|
2
|
-
import { SlicesContent } from "./slices";
|
|
3
|
-
import StaticWidgetContent from "./StaticWidgetContent";
|
|
4
|
-
export * from "./EmptyContent";
|
|
5
|
-
export * from "./GroupContent";
|
|
6
|
-
export * as Nestable from "./nestable";
|
|
7
|
-
export * from "./SimpleWidgetContent";
|
|
8
|
-
export * as Slices from "./slices";
|
|
9
|
-
export { type NonEmptyStaticWidgetContent, default as StaticWidgetContent, } from "./StaticWidgetContent";
|
|
10
|
-
export * from "./UIDContent";
|
|
11
|
-
export declare const WidgetTypes: {
|
|
12
|
-
readonly Empty: "EmptyContent";
|
|
13
|
-
readonly UID: "UIDContent";
|
|
14
|
-
readonly Group: "GroupContentType";
|
|
15
|
-
readonly slices: "SliceContentType";
|
|
16
|
-
readonly Links: {
|
|
17
|
-
readonly DocumentLink: "DocumentLink";
|
|
18
|
-
readonly FileLink: "FileLink";
|
|
19
|
-
readonly ExternalLink: "ExternalLink";
|
|
20
|
-
readonly ImageLink: "ImageLink";
|
|
21
|
-
readonly LinkContent: "LinkContent";
|
|
22
|
-
};
|
|
23
|
-
readonly StructuredText: "StructuredTextContent";
|
|
24
|
-
readonly Boolean: "BooleanContent";
|
|
25
|
-
readonly Embed: "EmbedContent";
|
|
26
|
-
readonly Field: "FieldContent";
|
|
27
|
-
readonly GeoPoint: "GeoPointContent";
|
|
28
|
-
readonly Image: "ImageContent";
|
|
29
|
-
readonly IntegrationFields: "IntegrationFieldsContent";
|
|
30
|
-
readonly Separator: "SeparatorContent";
|
|
31
|
-
};
|
|
32
|
-
export declare type WidgetTypes = typeof WidgetTypes[keyof typeof WidgetTypes];
|
|
33
|
-
export declare const WidgetKey: t.Type<string, string, unknown>;
|
|
34
|
-
export declare type WidgetKey = t.TypeOf<typeof WidgetKey>;
|
|
35
|
-
export declare type WidgetContent = SlicesContent | StaticWidgetContent;
|
|
36
|
-
export declare const Widget: {
|
|
37
|
-
fromJson(widgetKey: WidgetKey, widgetValue: unknown, widgetTypes: Map<WidgetKey, string>, widgetPositions: Map<WidgetKey, number>): import("fp-ts/lib/Option").None | import("fp-ts/lib/Option").Some<StaticWidgetContent> | import("fp-ts/lib/Option").Some<SlicesContent>;
|
|
38
|
-
};
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Widget = exports.WidgetKey = exports.WidgetTypes = exports.StaticWidgetContent = exports.Slices = exports.Nestable = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const t = (0, tslib_1.__importStar)(require("io-ts"));
|
|
6
|
-
const function_1 = require("../../validators/function");
|
|
7
|
-
const EmptyContent_1 = require("./EmptyContent");
|
|
8
|
-
const GroupContent_1 = require("./GroupContent");
|
|
9
|
-
const nestable_1 = require("./nestable");
|
|
10
|
-
const slices_1 = require("./slices");
|
|
11
|
-
const StaticWidgetContent_1 = (0, tslib_1.__importDefault)(require("./StaticWidgetContent"));
|
|
12
|
-
const UIDContent_1 = require("./UIDContent");
|
|
13
|
-
(0, tslib_1.__exportStar)(require("./EmptyContent"), exports);
|
|
14
|
-
(0, tslib_1.__exportStar)(require("./GroupContent"), exports);
|
|
15
|
-
exports.Nestable = (0, tslib_1.__importStar)(require("./nestable"));
|
|
16
|
-
(0, tslib_1.__exportStar)(require("./SimpleWidgetContent"), exports);
|
|
17
|
-
exports.Slices = (0, tslib_1.__importStar)(require("./slices"));
|
|
18
|
-
var StaticWidgetContent_2 = require("./StaticWidgetContent");
|
|
19
|
-
Object.defineProperty(exports, "StaticWidgetContent", { enumerable: true, get: function () { return (0, tslib_1.__importDefault)(StaticWidgetContent_2).default; } });
|
|
20
|
-
(0, tslib_1.__exportStar)(require("./UIDContent"), exports);
|
|
21
|
-
exports.WidgetTypes = {
|
|
22
|
-
...nestable_1.NestableTypes,
|
|
23
|
-
Empty: EmptyContent_1.EmptyContentType,
|
|
24
|
-
UID: UIDContent_1.UIDContentType,
|
|
25
|
-
Group: GroupContent_1.GroupContentType,
|
|
26
|
-
slices: slices_1.SlicesContentType,
|
|
27
|
-
};
|
|
28
|
-
const widgetKeyRegex = new RegExp("^[^<>]+$");
|
|
29
|
-
exports.WidgetKey = (0, function_1.refineType)(t.string, "WidgetKey", (s) => s.length === 0 || widgetKeyRegex.test(s));
|
|
30
|
-
exports.Widget = {
|
|
31
|
-
fromJson(widgetKey, widgetValue, widgetTypes, widgetPositions) {
|
|
32
|
-
const fieldType = widgetTypes.get(widgetKey);
|
|
33
|
-
if (fieldType === "Slices") {
|
|
34
|
-
return slices_1.SlicesContent.fromJson(widgetKey, widgetValue, widgetTypes, widgetPositions);
|
|
35
|
-
}
|
|
36
|
-
else {
|
|
37
|
-
return StaticWidgetContent_1.default.fromJson([], widgetKey, widgetValue, widgetTypes, widgetPositions);
|
|
38
|
-
}
|
|
39
|
-
},
|
|
40
|
-
};
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import * as t from "io-ts";
|
|
2
|
-
declare type BooleanContent = {
|
|
3
|
-
__TYPE__: "BooleanContent";
|
|
4
|
-
value: boolean;
|
|
5
|
-
};
|
|
6
|
-
export declare const BooleanContentType = "BooleanContent";
|
|
7
|
-
declare const BooleanContent: t.Type<BooleanContent, boolean, unknown>;
|
|
8
|
-
export default BooleanContent;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BooleanContentType = 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.BooleanContentType = "BooleanContent";
|
|
8
|
-
const BooleanContent = new t.Type("BooleanContent", (u) => { var _a; return ((_a = u) === null || _a === void 0 ? void 0 : _a.__TYPE__) === exports.BooleanContentType; }, (u, c) => Either_1.Chain.chain(t.boolean.validate(u, c), (u) => {
|
|
9
|
-
return t.success({ value: u, __TYPE__: exports.BooleanContentType });
|
|
10
|
-
}), (booleanContent) => t.boolean.encode(booleanContent.value));
|
|
11
|
-
exports.default = BooleanContent;
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import * as t from "io-ts";
|
|
2
|
-
export declare const EmbedContentType = "EmbedContent";
|
|
3
|
-
export declare type EmbedContent = t.TypeOf<typeof EmbedContentC> & {
|
|
4
|
-
all: unknown;
|
|
5
|
-
};
|
|
6
|
-
export declare type EmbedContentO = t.OutputOf<typeof EmbedContentC> & {
|
|
7
|
-
all: unknown;
|
|
8
|
-
};
|
|
9
|
-
export declare const EmbedContent: t.Type<EmbedContentO, unknown, unknown>;
|
|
10
|
-
export declare const EmbedContentC: t.Type<{
|
|
11
|
-
embed_url: string;
|
|
12
|
-
type: string;
|
|
13
|
-
} & {
|
|
14
|
-
version?: string | number | null;
|
|
15
|
-
title?: string | null | undefined;
|
|
16
|
-
author_name?: string | null | undefined;
|
|
17
|
-
author_url?: string | null | undefined;
|
|
18
|
-
provider_name?: string | null | undefined;
|
|
19
|
-
provider_url?: string | null | undefined;
|
|
20
|
-
cache_age?: string | number | null;
|
|
21
|
-
thumbnail_url?: string | null | undefined;
|
|
22
|
-
thumbnail_width?: number | null | undefined;
|
|
23
|
-
thumbnail_height?: number | null | undefined;
|
|
24
|
-
html?: string | null | undefined;
|
|
25
|
-
}, {
|
|
26
|
-
embed_url: string;
|
|
27
|
-
type: string;
|
|
28
|
-
} & {
|
|
29
|
-
version?: string | number | null;
|
|
30
|
-
title?: string | null | undefined;
|
|
31
|
-
author_name?: string | null | undefined;
|
|
32
|
-
author_url?: string | null | undefined;
|
|
33
|
-
provider_name?: string | null | undefined;
|
|
34
|
-
provider_url?: string | null | undefined;
|
|
35
|
-
cache_age?: string | number | null;
|
|
36
|
-
thumbnail_url?: string | null | undefined;
|
|
37
|
-
thumbnail_width?: number | null | undefined;
|
|
38
|
-
thumbnail_height?: number | null | undefined;
|
|
39
|
-
html?: string | null | undefined;
|
|
40
|
-
} & {
|
|
41
|
-
__TYPE__: "EmbedContent";
|
|
42
|
-
}, unknown>;
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.EmbedContentC = exports.EmbedContent = exports.EmbedContentType = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const fp_ts_1 = require("fp-ts");
|
|
6
|
-
const function_1 = require("fp-ts/function");
|
|
7
|
-
const t = (0, tslib_1.__importStar)(require("io-ts"));
|
|
8
|
-
const validators_1 = require("../../../validators");
|
|
9
|
-
const function_2 = require("../../../validators/function");
|
|
10
|
-
exports.EmbedContentType = "EmbedContent";
|
|
11
|
-
exports.EmbedContent = new t.Type("EmbedContent", (u) => u.__TYPE__ === exports.EmbedContentType, (u) => {
|
|
12
|
-
return (0, function_1.pipe)(exports.EmbedContentC.decode(u), fp_ts_1.either.map((s) => ({
|
|
13
|
-
...exports.EmbedContentC.encode(s),
|
|
14
|
-
all: u,
|
|
15
|
-
})));
|
|
16
|
-
}, (ec) => exports.EmbedContentC.encode(ec));
|
|
17
|
-
exports.EmbedContentC = (0, function_2.addType)(t.exact(t.intersection([
|
|
18
|
-
t.type({
|
|
19
|
-
embed_url: t.string,
|
|
20
|
-
type: t.string,
|
|
21
|
-
}),
|
|
22
|
-
t.partial({
|
|
23
|
-
version: t.union([t.string, t.number, t.null]),
|
|
24
|
-
title: validators_1.StringOrNull,
|
|
25
|
-
author_name: validators_1.StringOrNull,
|
|
26
|
-
author_url: validators_1.StringOrNull,
|
|
27
|
-
provider_name: validators_1.StringOrNull,
|
|
28
|
-
provider_url: validators_1.StringOrNull,
|
|
29
|
-
cache_age: t.union([t.string, t.number, t.null]),
|
|
30
|
-
thumbnail_url: validators_1.StringOrNull,
|
|
31
|
-
thumbnail_width: validators_1.NumberOrNull,
|
|
32
|
-
thumbnail_height: validators_1.NumberOrNull,
|
|
33
|
-
html: validators_1.StringOrNull,
|
|
34
|
-
}),
|
|
35
|
-
])), exports.EmbedContentType);
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import * as O from "fp-ts/Option";
|
|
2
|
-
export declare type FieldType = "Text" | "Date" | "Timestamp" | "Color" | "Number" | "Range" | "Select";
|
|
3
|
-
export declare const FieldContentType = "FieldContent";
|
|
4
|
-
declare type FieldContent = {
|
|
5
|
-
value: string;
|
|
6
|
-
type: FieldType;
|
|
7
|
-
__TYPE__: typeof FieldContentType;
|
|
8
|
-
};
|
|
9
|
-
declare const FieldContent: {
|
|
10
|
-
types: string[];
|
|
11
|
-
forType: (type: FieldType, value: unknown) => O.Option<FieldContent>;
|
|
12
|
-
};
|
|
13
|
-
export default FieldContent;
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.FieldContentType = 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
|
-
exports.FieldContentType = "FieldContent";
|
|
9
|
-
//we do that instead of idiomatic .trim()
|
|
10
|
-
//because we need to have the exact same behaviour than scala/java .trim()
|
|
11
|
-
//in other world only trim space and not non-breaking space or tab
|
|
12
|
-
function trimScalaStyle(s) {
|
|
13
|
-
let startAt = 0;
|
|
14
|
-
/* eslint-disable @typescript-eslint/no-non-null-assertion */
|
|
15
|
-
while (startAt < s.length && s[startAt] <= " ") {
|
|
16
|
-
startAt++;
|
|
17
|
-
}
|
|
18
|
-
let endAt = s.length;
|
|
19
|
-
/* eslint-disable @typescript-eslint/no-non-null-assertion */
|
|
20
|
-
while (startAt < endAt && s[endAt - 1] <= " ") {
|
|
21
|
-
endAt--;
|
|
22
|
-
}
|
|
23
|
-
return s.substring(startAt, endAt);
|
|
24
|
-
}
|
|
25
|
-
const FieldContent = {
|
|
26
|
-
types: ["Text", "Date", "Timestamp", "Color", "Number", "Range", "Select"],
|
|
27
|
-
forType: (type, value) => {
|
|
28
|
-
return (0, function_1.pipe)(O.fromEither(t.string.decode(value)), O.map((r) => {
|
|
29
|
-
return {
|
|
30
|
-
value: trimScalaStyle(r),
|
|
31
|
-
type,
|
|
32
|
-
__TYPE__: "FieldContent",
|
|
33
|
-
};
|
|
34
|
-
}));
|
|
35
|
-
},
|
|
36
|
-
};
|
|
37
|
-
exports.default = FieldContent;
|