@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,31 +1,9 @@
|
|
|
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
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
-
exports.LinkContent = exports.LinkContentType = void 0;
|
|
23
|
-
const Either_1 = require("fp-ts/Either");
|
|
24
|
-
const t = __importStar(require("io-ts"));
|
|
25
|
-
const index_1 = require("./index");
|
|
26
|
-
exports.LinkContentType = "LinkContent";
|
|
27
|
-
exports.LinkContent = new t.Type("LinkContent", (u) => {
|
|
28
|
-
return index_1.Link.is(u?.value);
|
|
29
|
-
}, (u, c) => Either_1.Chain.chain(index_1.Link.validate(u, c), (u) => {
|
|
30
|
-
return t.success({ value: u, __TYPE__: exports.LinkContentType });
|
|
31
|
-
}), (linkContent) => index_1.Link.encode(linkContent.value));
|
|
1
|
+
import { Chain } from "fp-ts/Either";
|
|
2
|
+
import * as t from "io-ts";
|
|
3
|
+
import { Link } from "./index";
|
|
4
|
+
export const LinkContentType = "LinkContent";
|
|
5
|
+
export const LinkContent = new t.Type("LinkContent", (u) => {
|
|
6
|
+
return Link.is(u?.value);
|
|
7
|
+
}, (u, c) => Chain.chain(Link.validate(u, c), (u) => {
|
|
8
|
+
return t.success({ value: u, __TYPE__: LinkContentType });
|
|
9
|
+
}), (linkContent) => Link.encode(linkContent.value));
|
|
@@ -50,28 +50,28 @@ export declare const Link: t.UnionC<[t.Type<{
|
|
|
50
50
|
}, unknown>, t.Type<{
|
|
51
51
|
url: string;
|
|
52
52
|
} & {
|
|
53
|
-
kind?: "web"
|
|
53
|
+
kind?: "web";
|
|
54
54
|
target?: string | null | undefined;
|
|
55
55
|
preview?: {
|
|
56
|
-
title?: string
|
|
56
|
+
title?: string;
|
|
57
57
|
} | null | undefined;
|
|
58
58
|
}, {
|
|
59
59
|
url: string;
|
|
60
60
|
} & {
|
|
61
|
-
kind?: "web"
|
|
61
|
+
kind?: "web";
|
|
62
62
|
target?: string | null | undefined;
|
|
63
63
|
preview?: {
|
|
64
|
-
title?: string
|
|
64
|
+
title?: string;
|
|
65
65
|
} | null | undefined;
|
|
66
66
|
} & {
|
|
67
67
|
__TYPE__: "ExternalLink";
|
|
68
68
|
}, unknown>]>;
|
|
69
69
|
export declare type Link = t.TypeOf<typeof Link>;
|
|
70
70
|
export declare type LinkO = t.OutputOf<typeof Link>;
|
|
71
|
-
export {
|
|
72
|
-
export {
|
|
73
|
-
export {
|
|
74
|
-
export {
|
|
71
|
+
export { type DocumentLinkO, DocumentLink } from "./DocumentLink";
|
|
72
|
+
export { type ExternalLinkO, ExternalLink } from "./ExternalLink";
|
|
73
|
+
export { type FileLinkO, FileLink } from "./FileLink";
|
|
74
|
+
export { type ImageLinkO, ImageLink } from "./ImageLink";
|
|
75
75
|
export { LinkContent } from "./LinkContent";
|
|
76
76
|
export declare const BROKEN_CUSTOM_TYPE = "broken_type";
|
|
77
77
|
export declare const is: {
|
|
@@ -1,53 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
return result;
|
|
1
|
+
import * as t from "io-ts";
|
|
2
|
+
import { DocumentLink, DocumentLinkType, isDocumentLink } from "./DocumentLink";
|
|
3
|
+
import { ExternalLink, ExternalLinkType, isExternalLink } from "./ExternalLink";
|
|
4
|
+
import { FileLink, FileLinkType, isFileLink } from "./FileLink";
|
|
5
|
+
import { ImageLink, ImageLinkType, isImageLink } from "./ImageLink";
|
|
6
|
+
import { LinkContentType } from "./LinkContent";
|
|
7
|
+
export const Link = t.union([ImageLink, FileLink, DocumentLink, ExternalLink]);
|
|
8
|
+
export { DocumentLink } from "./DocumentLink";
|
|
9
|
+
export { ExternalLink } from "./ExternalLink";
|
|
10
|
+
export { FileLink } from "./FileLink";
|
|
11
|
+
export { ImageLink } from "./ImageLink";
|
|
12
|
+
export { LinkContent } from "./LinkContent";
|
|
13
|
+
export const BROKEN_CUSTOM_TYPE = "broken_type";
|
|
14
|
+
export const is = {
|
|
15
|
+
documentLink: isDocumentLink,
|
|
16
|
+
fileLink: isFileLink,
|
|
17
|
+
externalLink: isExternalLink,
|
|
18
|
+
imageLink: isImageLink,
|
|
20
19
|
};
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
const ImageLink_1 = require("./ImageLink");
|
|
28
|
-
const LinkContent_1 = require("./LinkContent");
|
|
29
|
-
exports.Link = t.union([ImageLink_1.ImageLink, FileLink_1.FileLink, DocumentLink_1.DocumentLink, ExternalLink_1.ExternalLink]);
|
|
30
|
-
var DocumentLink_2 = require("./DocumentLink");
|
|
31
|
-
Object.defineProperty(exports, "DocumentLink", { enumerable: true, get: function () { return DocumentLink_2.DocumentLink; } });
|
|
32
|
-
var ExternalLink_2 = require("./ExternalLink");
|
|
33
|
-
Object.defineProperty(exports, "ExternalLink", { enumerable: true, get: function () { return ExternalLink_2.ExternalLink; } });
|
|
34
|
-
var FileLink_2 = require("./FileLink");
|
|
35
|
-
Object.defineProperty(exports, "FileLink", { enumerable: true, get: function () { return FileLink_2.FileLink; } });
|
|
36
|
-
var ImageLink_2 = require("./ImageLink");
|
|
37
|
-
Object.defineProperty(exports, "ImageLink", { enumerable: true, get: function () { return ImageLink_2.ImageLink; } });
|
|
38
|
-
var LinkContent_2 = require("./LinkContent");
|
|
39
|
-
Object.defineProperty(exports, "LinkContent", { enumerable: true, get: function () { return LinkContent_2.LinkContent; } });
|
|
40
|
-
exports.BROKEN_CUSTOM_TYPE = "broken_type";
|
|
41
|
-
exports.is = {
|
|
42
|
-
documentLink: DocumentLink_1.isDocumentLink,
|
|
43
|
-
fileLink: FileLink_1.isFileLink,
|
|
44
|
-
externalLink: ExternalLink_1.isExternalLink,
|
|
45
|
-
imageLink: ImageLink_1.isImageLink,
|
|
46
|
-
};
|
|
47
|
-
exports.LinksTypes = {
|
|
48
|
-
DocumentLink: DocumentLink_1.DocumentLinkType,
|
|
49
|
-
FileLink: FileLink_1.FileLinkType,
|
|
50
|
-
ExternalLink: ExternalLink_1.ExternalLinkType,
|
|
51
|
-
ImageLink: ImageLink_1.ImageLinkType,
|
|
52
|
-
LinkContent: LinkContent_1.LinkContentType,
|
|
20
|
+
export const LinksTypes = {
|
|
21
|
+
DocumentLink: DocumentLinkType,
|
|
22
|
+
FileLink: FileLinkType,
|
|
23
|
+
ExternalLink: ExternalLinkType,
|
|
24
|
+
ImageLink: ImageLinkType,
|
|
25
|
+
LinkContent: LinkContentType,
|
|
53
26
|
};
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.SeparatorContent = exports.SeparatorContentType = void 0;
|
|
4
|
-
exports.SeparatorContentType = "SeparatorContent";
|
|
5
|
-
exports.SeparatorContent = {
|
|
1
|
+
export const SeparatorContentType = "SeparatorContent";
|
|
2
|
+
export const SeparatorContent = {
|
|
6
3
|
is(value) {
|
|
7
4
|
const asFieldContent = value;
|
|
8
5
|
return asFieldContent.__TYPE__ === "SeparatorContent";
|
|
@@ -51,10 +51,10 @@ export declare const ImageBlock: t.ExactC<t.IntersectionC<[t.TypeC<{
|
|
|
51
51
|
} | ({
|
|
52
52
|
url: string;
|
|
53
53
|
} & {
|
|
54
|
-
kind?: "web"
|
|
54
|
+
kind?: "web";
|
|
55
55
|
target?: string | null | undefined;
|
|
56
56
|
preview?: {
|
|
57
|
-
title?: string
|
|
57
|
+
title?: string;
|
|
58
58
|
} | null | undefined;
|
|
59
59
|
}) | ({
|
|
60
60
|
id: string;
|
|
@@ -81,10 +81,10 @@ export declare const ImageBlock: t.ExactC<t.IntersectionC<[t.TypeC<{
|
|
|
81
81
|
}) | ({
|
|
82
82
|
url: string;
|
|
83
83
|
} & {
|
|
84
|
-
kind?: "web"
|
|
84
|
+
kind?: "web";
|
|
85
85
|
target?: string | null | undefined;
|
|
86
86
|
preview?: {
|
|
87
|
-
title?: string
|
|
87
|
+
title?: string;
|
|
88
88
|
} | null | undefined;
|
|
89
89
|
} & {
|
|
90
90
|
__TYPE__: "ExternalLink";
|
|
@@ -180,10 +180,10 @@ export declare const Block: t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
|
|
|
180
180
|
} | ({
|
|
181
181
|
url: string;
|
|
182
182
|
} & {
|
|
183
|
-
kind?: "web"
|
|
183
|
+
kind?: "web";
|
|
184
184
|
target?: string | null | undefined;
|
|
185
185
|
preview?: {
|
|
186
|
-
title?: string
|
|
186
|
+
title?: string;
|
|
187
187
|
} | null | undefined;
|
|
188
188
|
}) | ({
|
|
189
189
|
id: string;
|
|
@@ -210,10 +210,10 @@ export declare const Block: t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
|
|
|
210
210
|
}) | ({
|
|
211
211
|
url: string;
|
|
212
212
|
} & {
|
|
213
|
-
kind?: "web"
|
|
213
|
+
kind?: "web";
|
|
214
214
|
target?: string | null | undefined;
|
|
215
215
|
preview?: {
|
|
216
|
-
title?: string
|
|
216
|
+
title?: string;
|
|
217
217
|
} | null | undefined;
|
|
218
218
|
} & {
|
|
219
219
|
__TYPE__: "ExternalLink";
|
|
@@ -1,36 +1,11 @@
|
|
|
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.Block = exports.TextBlock = exports.checkEmbedBlock = exports.EmbedBlock = exports.EmbedBlockType = exports.checkImageBlock = exports.ImageBlock = exports.ImageBlockType = exports.ValidatedMetas = exports.Meta = void 0;
|
|
26
|
-
const E = __importStar(require("fp-ts/lib/Either"));
|
|
27
|
-
const t = __importStar(require("io-ts"));
|
|
28
|
-
const validators_1 = require("../../../../validators");
|
|
29
|
-
const function_1 = require("../../../../validators/function");
|
|
30
|
-
const EmbedContent_1 = __importDefault(require("../EmbedContent"));
|
|
31
|
-
const ImageContent_1 = require("../ImageContent");
|
|
32
|
-
const Link_1 = require("../Link");
|
|
33
|
-
exports.Meta = t.exact(t.intersection([
|
|
1
|
+
import * as E from "fp-ts/lib/Either";
|
|
2
|
+
import * as t from "io-ts";
|
|
3
|
+
import { StringOrNull } from "../../../../validators";
|
|
4
|
+
import { nullable, refineType } from "../../../../validators/function";
|
|
5
|
+
import EmbedContent from "../EmbedContent";
|
|
6
|
+
import { ImageContentView } from "../ImageContent";
|
|
7
|
+
import { Link } from "../Link";
|
|
8
|
+
export const Meta = t.exact(t.intersection([
|
|
34
9
|
t.partial({
|
|
35
10
|
data: t.unknown,
|
|
36
11
|
}),
|
|
@@ -40,17 +15,17 @@ exports.Meta = t.exact(t.intersection([
|
|
|
40
15
|
type: t.string,
|
|
41
16
|
}),
|
|
42
17
|
]));
|
|
43
|
-
|
|
18
|
+
export const ValidatedMetas = new t.Type("ValidatedMetas", (metas) => Array.isArray(metas) && metas.every(Meta.is), (metas, c) => {
|
|
44
19
|
if (Array.isArray(metas)) {
|
|
45
20
|
const res = metas
|
|
46
21
|
.reduce((acc, maybeMeta) => {
|
|
47
|
-
const maybeDecodedMeta =
|
|
22
|
+
const maybeDecodedMeta = Meta.decode(maybeMeta);
|
|
48
23
|
if (E.isRight(maybeDecodedMeta)) {
|
|
49
24
|
const meta = maybeDecodedMeta.right;
|
|
50
25
|
// if it's an hyperlink it should have data validated as link otherwise we don't care and keep the meta
|
|
51
26
|
if ((meta.data &&
|
|
52
27
|
meta.type === "hyperlink" &&
|
|
53
|
-
E.isRight(
|
|
28
|
+
E.isRight(Link.validate(meta.data, c))) ||
|
|
54
29
|
meta.type !== "hyperlink") {
|
|
55
30
|
return [...acc, meta];
|
|
56
31
|
}
|
|
@@ -62,51 +37,49 @@ exports.ValidatedMetas = new t.Type("ValidatedMetas", (metas) => Array.isArray(m
|
|
|
62
37
|
}
|
|
63
38
|
else
|
|
64
39
|
return t.failure(metas, c);
|
|
65
|
-
}, (m) => t.array(
|
|
66
|
-
|
|
67
|
-
|
|
40
|
+
}, (m) => t.array(Meta).encode(m));
|
|
41
|
+
export const ImageBlockType = "image";
|
|
42
|
+
export const ImageBlock = t.exact(t.intersection([
|
|
68
43
|
t.type({
|
|
69
|
-
type: t.literal(
|
|
44
|
+
type: t.literal(ImageBlockType),
|
|
70
45
|
data: t.intersection([
|
|
71
|
-
|
|
46
|
+
ImageContentView,
|
|
72
47
|
t.partial({
|
|
73
|
-
linkTo:
|
|
48
|
+
linkTo: nullable(Link),
|
|
74
49
|
}),
|
|
75
50
|
]),
|
|
76
51
|
}),
|
|
77
52
|
t.partial({
|
|
78
|
-
label:
|
|
79
|
-
direction:
|
|
53
|
+
label: StringOrNull,
|
|
54
|
+
direction: StringOrNull,
|
|
80
55
|
}),
|
|
81
56
|
]));
|
|
82
|
-
function checkImageBlock(block) {
|
|
83
|
-
return block.type ===
|
|
57
|
+
export function checkImageBlock(block) {
|
|
58
|
+
return block.type === ImageBlockType;
|
|
84
59
|
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
exports.EmbedBlock = t.exact(t.intersection([
|
|
60
|
+
export const EmbedBlockType = "embed";
|
|
61
|
+
export const EmbedBlock = t.exact(t.intersection([
|
|
88
62
|
t.type({
|
|
89
|
-
type: t.literal(
|
|
90
|
-
data:
|
|
63
|
+
type: t.literal(EmbedBlockType),
|
|
64
|
+
data: EmbedContent,
|
|
91
65
|
}),
|
|
92
66
|
t.partial({
|
|
93
|
-
label:
|
|
94
|
-
direction:
|
|
67
|
+
label: StringOrNull,
|
|
68
|
+
direction: StringOrNull,
|
|
95
69
|
}),
|
|
96
70
|
]));
|
|
97
|
-
function checkEmbedBlock(block) {
|
|
98
|
-
return block.type ===
|
|
71
|
+
export function checkEmbedBlock(block) {
|
|
72
|
+
return block.type === EmbedBlockType;
|
|
99
73
|
}
|
|
100
|
-
|
|
101
|
-
exports.TextBlock = t.exact(t.intersection([
|
|
74
|
+
export const TextBlock = t.exact(t.intersection([
|
|
102
75
|
t.type({
|
|
103
|
-
type:
|
|
76
|
+
type: refineType(t.string, `string which isn't ${ImageBlockType} ${EmbedBlockType}`, (s) => s !== ImageBlockType && s !== EmbedBlockType),
|
|
104
77
|
content: t.intersection([
|
|
105
78
|
t.type({
|
|
106
79
|
text: t.string,
|
|
107
80
|
}),
|
|
108
81
|
t.partial({
|
|
109
|
-
spans:
|
|
82
|
+
spans: ValidatedMetas,
|
|
110
83
|
}),
|
|
111
84
|
]),
|
|
112
85
|
}),
|
|
@@ -115,4 +88,4 @@ exports.TextBlock = t.exact(t.intersection([
|
|
|
115
88
|
direction: t.string,
|
|
116
89
|
}),
|
|
117
90
|
]));
|
|
118
|
-
|
|
91
|
+
export const Block = t.union([ImageBlock, EmbedBlock, TextBlock]);
|
|
@@ -1,32 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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.Blocks = exports.StructuredTextContent = exports.StructuredTextContentType = void 0;
|
|
23
|
-
const Either_1 = require("fp-ts/Either");
|
|
24
|
-
const t = __importStar(require("io-ts"));
|
|
25
|
-
const Block_1 = require("./Block");
|
|
26
|
-
exports.StructuredTextContentType = "StructuredTextContent";
|
|
27
|
-
exports.StructuredTextContent = new t.Type(exports.StructuredTextContentType, (u) => u?.__TYPE__ === exports.StructuredTextContentType, (u, c) => Either_1.Chain.chain(t.array(Block_1.Block).validate(u, c), (u) => {
|
|
28
|
-
return t.success({ value: u, __TYPE__: exports.StructuredTextContentType });
|
|
1
|
+
import { Chain } from "fp-ts/Either";
|
|
2
|
+
import * as t from "io-ts";
|
|
3
|
+
import { Block } from "./Block";
|
|
4
|
+
export const StructuredTextContentType = "StructuredTextContent";
|
|
5
|
+
export const StructuredTextContent = new t.Type(StructuredTextContentType, (u) => u?.__TYPE__ === StructuredTextContentType, (u, c) => Chain.chain(t.array(Block).validate(u, c), (u) => {
|
|
6
|
+
return t.success({ value: u, __TYPE__: StructuredTextContentType });
|
|
29
7
|
}), () => {
|
|
30
8
|
throw new Error("NotImplementedError: Not relevant method");
|
|
31
9
|
});
|
|
32
|
-
|
|
10
|
+
export * as Blocks from "./Block";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export { default as BooleanContent } from "./BooleanContent";
|
|
2
2
|
export { default as EmbedContent } from "./EmbedContent";
|
|
3
3
|
export { default as FieldContent } from "./FieldContent";
|
|
4
|
-
export {
|
|
5
|
-
export {
|
|
4
|
+
export { type GeoPointContentO, GeoPointContent } from "./GeoPointContent";
|
|
5
|
+
export { type ImageContentO, ImageContent, ImageContentView, } from "./ImageContent";
|
|
6
6
|
export { default as IntegrationFieldsContent } from "./IntegrationFieldsContent";
|
|
7
7
|
export * as Links from "./Link";
|
|
8
8
|
export * from "./SeparatorContent";
|
|
@@ -1,64 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
const BooleanContent_1 = require("./BooleanContent");
|
|
30
|
-
const EmbedContent_1 = require("./EmbedContent");
|
|
31
|
-
const FieldContent_1 = require("./FieldContent");
|
|
32
|
-
const GeoPointContent_1 = require("./GeoPointContent");
|
|
33
|
-
const ImageContent_1 = require("./ImageContent");
|
|
34
|
-
const IntegrationFieldsContent_1 = require("./IntegrationFieldsContent");
|
|
35
|
-
const Link_1 = require("./Link");
|
|
36
|
-
const SeparatorContent_1 = require("./SeparatorContent");
|
|
37
|
-
const StructuredTextContent_1 = require("./StructuredTextContent");
|
|
38
|
-
var BooleanContent_2 = require("./BooleanContent");
|
|
39
|
-
Object.defineProperty(exports, "BooleanContent", { enumerable: true, get: function () { return __importDefault(BooleanContent_2).default; } });
|
|
40
|
-
var EmbedContent_2 = require("./EmbedContent");
|
|
41
|
-
Object.defineProperty(exports, "EmbedContent", { enumerable: true, get: function () { return __importDefault(EmbedContent_2).default; } });
|
|
42
|
-
var FieldContent_2 = require("./FieldContent");
|
|
43
|
-
Object.defineProperty(exports, "FieldContent", { enumerable: true, get: function () { return __importDefault(FieldContent_2).default; } });
|
|
44
|
-
var GeoPointContent_2 = require("./GeoPointContent");
|
|
45
|
-
Object.defineProperty(exports, "GeoPointContent", { enumerable: true, get: function () { return GeoPointContent_2.GeoPointContent; } });
|
|
46
|
-
var ImageContent_2 = require("./ImageContent");
|
|
47
|
-
Object.defineProperty(exports, "ImageContent", { enumerable: true, get: function () { return ImageContent_2.ImageContent; } });
|
|
48
|
-
Object.defineProperty(exports, "ImageContentView", { enumerable: true, get: function () { return ImageContent_2.ImageContentView; } });
|
|
49
|
-
var IntegrationFieldsContent_2 = require("./IntegrationFieldsContent");
|
|
50
|
-
Object.defineProperty(exports, "IntegrationFieldsContent", { enumerable: true, get: function () { return __importDefault(IntegrationFieldsContent_2).default; } });
|
|
51
|
-
exports.Links = __importStar(require("./Link"));
|
|
52
|
-
__exportStar(require("./SeparatorContent"), exports);
|
|
53
|
-
__exportStar(require("./StructuredTextContent"), exports);
|
|
54
|
-
exports.NestableTypes = {
|
|
55
|
-
Links: Link_1.LinksTypes,
|
|
56
|
-
StructuredText: StructuredTextContent_1.StructuredTextContentType,
|
|
57
|
-
Boolean: BooleanContent_1.BooleanContentType,
|
|
58
|
-
Embed: EmbedContent_1.EmbedContentType,
|
|
59
|
-
Field: FieldContent_1.FieldContentType,
|
|
60
|
-
GeoPoint: GeoPointContent_1.GeoPointContentType,
|
|
61
|
-
Image: ImageContent_1.ImageContentType,
|
|
62
|
-
IntegrationFields: IntegrationFieldsContent_1.IntegrationFieldsContentType,
|
|
63
|
-
Separator: SeparatorContent_1.SeparatorContentType,
|
|
1
|
+
import { BooleanContentType } from "./BooleanContent";
|
|
2
|
+
import { EmbedContentType } from "./EmbedContent";
|
|
3
|
+
import { FieldContentType } from "./FieldContent";
|
|
4
|
+
import { GeoPointContentType } from "./GeoPointContent";
|
|
5
|
+
import { ImageContentType } from "./ImageContent";
|
|
6
|
+
import { IntegrationFieldsContentType } from "./IntegrationFieldsContent";
|
|
7
|
+
import { LinksTypes } from "./Link";
|
|
8
|
+
import { SeparatorContentType } from "./SeparatorContent";
|
|
9
|
+
import { StructuredTextContentType } from "./StructuredTextContent";
|
|
10
|
+
export { default as BooleanContent } from "./BooleanContent";
|
|
11
|
+
export { default as EmbedContent } from "./EmbedContent";
|
|
12
|
+
export { default as FieldContent } from "./FieldContent";
|
|
13
|
+
export { GeoPointContent } from "./GeoPointContent";
|
|
14
|
+
export { ImageContent, ImageContentView, } from "./ImageContent";
|
|
15
|
+
export { default as IntegrationFieldsContent } from "./IntegrationFieldsContent";
|
|
16
|
+
export * as Links from "./Link";
|
|
17
|
+
export * from "./SeparatorContent";
|
|
18
|
+
export * from "./StructuredTextContent";
|
|
19
|
+
export const NestableTypes = {
|
|
20
|
+
Links: LinksTypes,
|
|
21
|
+
StructuredText: StructuredTextContentType,
|
|
22
|
+
Boolean: BooleanContentType,
|
|
23
|
+
Embed: EmbedContentType,
|
|
24
|
+
Field: FieldContentType,
|
|
25
|
+
GeoPoint: GeoPointContentType,
|
|
26
|
+
Image: ImageContentType,
|
|
27
|
+
IntegrationFields: IntegrationFieldsContentType,
|
|
28
|
+
Separator: SeparatorContentType,
|
|
64
29
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as O from "fp-ts/Option";
|
|
2
|
-
import { GroupItemContent } from "../GroupContent";
|
|
2
|
+
import type { GroupItemContent } from "../GroupContent";
|
|
3
3
|
import { SimpleWidgetContent } from "../index";
|
|
4
4
|
export declare const CompositeSliceContentType = "CompositeSliceContent";
|
|
5
5
|
export declare type CompositeSliceContent = {
|
|
@@ -1,44 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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.CompositeSliceContent = exports.CompositeSliceContentType = void 0;
|
|
23
|
-
const Either_1 = require("fp-ts/Either");
|
|
24
|
-
const O = __importStar(require("fp-ts/Option"));
|
|
25
|
-
const t = __importStar(require("io-ts"));
|
|
26
|
-
const index_1 = require("../index");
|
|
27
|
-
exports.CompositeSliceContentType = "CompositeSliceContent";
|
|
1
|
+
import { isRight } from "fp-ts/Either";
|
|
2
|
+
import * as O from "fp-ts/Option";
|
|
3
|
+
import * as t from "io-ts";
|
|
4
|
+
import { GroupContent, SimpleWidgetContent } from "../index";
|
|
5
|
+
export const CompositeSliceContentType = "CompositeSliceContent";
|
|
28
6
|
const codec = t.exact(t.partial({
|
|
29
7
|
repeat: t.array(t.unknown),
|
|
30
8
|
"non-repeat": t.UnknownRecord,
|
|
31
9
|
}));
|
|
32
|
-
|
|
10
|
+
export const CompositeSliceContent = {
|
|
33
11
|
fromJson: (prefixes, key, value, fieldTypes, fieldPositions) => {
|
|
34
12
|
const prefixedRepeatKey = Array.of(prefixes, [key, "repeat"])
|
|
35
13
|
.flat()
|
|
36
14
|
.join(".");
|
|
37
15
|
const decodedValue = codec.decode(value);
|
|
38
|
-
if (
|
|
16
|
+
if (isRight(decodedValue)) {
|
|
39
17
|
const repeatObj = decodedValue.right.repeat;
|
|
40
18
|
const nonRepeatObj = decodedValue.right["non-repeat"] ?? {};
|
|
41
|
-
const groupItemsContentsRepeat =
|
|
19
|
+
const groupItemsContentsRepeat = GroupContent.itemsContentsFromJson(prefixedRepeatKey, repeatObj, fieldTypes, fieldPositions);
|
|
42
20
|
const sortedFields = Object.entries(nonRepeatObj).sort(([k1], [k2]) => {
|
|
43
21
|
const p1 = fieldPositions.get(`${Array.of(prefixes, [key]).flat().join(".")}.${k1}`) ?? 10000;
|
|
44
22
|
const p2 = fieldPositions.get(`${Array.of(prefixes, [key]).flat().join(".")}.${k2}`) ?? 10000;
|
|
@@ -48,7 +26,7 @@ exports.CompositeSliceContent = {
|
|
|
48
26
|
const kp = Array.of(prefixes, [key, "non-repeat", k]).flat().join(".");
|
|
49
27
|
const kind = fieldTypes.get(kp);
|
|
50
28
|
if (kind) {
|
|
51
|
-
const mWidgetContent =
|
|
29
|
+
const mWidgetContent = SimpleWidgetContent.from(kind, v);
|
|
52
30
|
if (O.isSome(mWidgetContent)) {
|
|
53
31
|
acc[k] = mWidgetContent.value;
|
|
54
32
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as O from "fp-ts/Option";
|
|
2
|
-
import { GroupItemContent } from "../GroupContent";
|
|
2
|
+
import type { GroupItemContent } from "../GroupContent";
|
|
3
3
|
import { SimpleWidgetContent } from "../index";
|
|
4
4
|
export declare const SharedSliceContentType = "SharedSliceContent";
|
|
5
5
|
export declare type SharedSliceContent = {
|