@prismicio/types-internal 0.2.2 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/customtypes/CustomType.d.ts +2 -20
- package/lib/customtypes/CustomType.js +33 -25
- package/lib/customtypes/Format.js +5 -2
- package/lib/customtypes/Section.d.ts +3 -30
- package/lib/customtypes/Section.js +14 -9
- package/lib/customtypes/index.js +9 -4
- package/lib/customtypes/widgets/Group.js +12 -9
- package/lib/customtypes/widgets/UID.js +10 -7
- package/lib/customtypes/widgets/Widget.d.ts +3 -30
- package/lib/customtypes/widgets/Widget.js +19 -14
- package/lib/customtypes/widgets/WidgetTypes.js +3 -1
- package/lib/customtypes/widgets/index.js +14 -7
- package/lib/customtypes/widgets/nestable/BooleanField.js +9 -6
- package/lib/customtypes/widgets/nestable/Color.js +10 -7
- package/lib/customtypes/widgets/nestable/Date.js +10 -7
- package/lib/customtypes/widgets/nestable/Embed.js +10 -7
- package/lib/customtypes/widgets/nestable/GeoPoint.js +10 -7
- package/lib/customtypes/widgets/nestable/Image.js +13 -10
- package/lib/customtypes/widgets/nestable/IntegrationField.js +10 -7
- package/lib/customtypes/widgets/nestable/Link.js +14 -11
- package/lib/customtypes/widgets/nestable/NestableWidget.js +35 -32
- package/lib/customtypes/widgets/nestable/Number.js +14 -11
- package/lib/customtypes/widgets/nestable/Range.js +14 -11
- package/lib/customtypes/widgets/nestable/RichText.js +15 -12
- package/lib/customtypes/widgets/nestable/Select.js +11 -8
- package/lib/customtypes/widgets/nestable/Separator.js +9 -6
- package/lib/customtypes/widgets/nestable/Text.js +10 -7
- package/lib/customtypes/widgets/nestable/Timestamp.js +10 -7
- package/lib/customtypes/widgets/nestable/index.js +36 -15
- package/lib/customtypes/widgets/shared/ImageConstraint.js +12 -9
- package/lib/customtypes/widgets/shared/index.js +8 -1
- package/lib/customtypes/widgets/slices/CompositeSlice.js +13 -10
- package/lib/customtypes/widgets/slices/LegacySlice.d.ts +1 -10
- package/lib/customtypes/widgets/slices/LegacySlice.js +8 -6
- package/lib/customtypes/widgets/slices/SharedSlice.js +12 -9
- package/lib/customtypes/widgets/slices/SharedSliceRef.js +7 -4
- package/lib/customtypes/widgets/slices/Slice.js +2 -1
- package/lib/customtypes/widgets/slices/Slices.d.ts +6 -60
- package/lib/customtypes/widgets/slices/Slices.js +33 -27
- package/lib/customtypes/widgets/slices/SlicesTypes.js +3 -1
- package/lib/customtypes/widgets/slices/index.js +16 -7
- package/lib/documents/DocumentData.js +7 -4
- package/lib/documents/index.js +7 -2
- package/lib/documents/widgets/EmptyContent.js +6 -3
- package/lib/documents/widgets/GroupContent.js +14 -10
- package/lib/documents/widgets/SimpleWidgetContent.js +32 -27
- package/lib/documents/widgets/StaticWidgetContent.js +11 -8
- package/lib/documents/widgets/UIDContent.js +8 -4
- package/lib/documents/widgets/index.js +27 -22
- package/lib/documents/widgets/nestable/BooleanContent.js +10 -6
- package/lib/documents/widgets/nestable/EmbedContent.js +24 -20
- package/lib/documents/widgets/nestable/FieldContent.js +10 -6
- package/lib/documents/widgets/nestable/GeoPointContent.js +9 -5
- package/lib/documents/widgets/nestable/ImageContent.js +16 -12
- package/lib/documents/widgets/nestable/IntegrationFieldsContent.js +10 -6
- package/lib/documents/widgets/nestable/Link/DocumentLink.js +12 -7
- package/lib/documents/widgets/nestable/Link/ExternalLink.js +15 -10
- package/lib/documents/widgets/nestable/Link/FileLink.js +15 -10
- package/lib/documents/widgets/nestable/Link/ImageLink.js +14 -9
- package/lib/documents/widgets/nestable/Link/LinkContent.js +13 -9
- package/lib/documents/widgets/nestable/Link/index.js +33 -24
- package/lib/documents/widgets/nestable/SeparatorContent.js +5 -2
- package/lib/documents/widgets/nestable/StructuredTextContent/Block.js +39 -33
- package/lib/documents/widgets/nestable/StructuredTextContent/index.js +11 -7
- package/lib/documents/widgets/nestable/index.js +39 -28
- package/lib/documents/widgets/slices/CompositeSliceContent.js +13 -9
- package/lib/documents/widgets/slices/SharedSliceContent.js +16 -12
- package/lib/documents/widgets/slices/SimpleSliceContent.js +6 -2
- package/lib/documents/widgets/slices/SliceWidgetContent.js +12 -8
- package/lib/documents/widgets/slices/SlicesContent.js +17 -13
- package/lib/documents/widgets/slices/index.js +8 -5
- package/lib/index.js +7 -3
- package/lib/validators/DateFromString.js +7 -4
- package/lib/validators/DateFromStringOrNumber.js +7 -4
- package/lib/validators/DateFromTsMs.js +7 -4
- package/lib/validators/IntFromNumber.js +7 -4
- package/lib/validators/IntFromPixels.js +7 -4
- package/lib/validators/NonEmptyString.js +6 -3
- package/lib/validators/NonEmptyStringOrNull.js +10 -7
- package/lib/validators/NumberOrNull.js +6 -3
- package/lib/validators/StringFromBoolean.js +7 -4
- package/lib/validators/StringFromNumber.js +7 -4
- package/lib/validators/StringOrNull.js +6 -3
- package/lib/validators/function.js +28 -15
- package/lib/validators/index.js +27 -12
- package/package.json +1 -1
- package/src/customtypes/widgets/slices/LegacySlice.ts +1 -2
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
|
|
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) => u?.__TYPE__ === exports.BooleanContentType, (u, c) => Either_1.Chain.chain(t.boolean.validate(u, c), (u) => {
|
|
9
|
+
return t.success({ value: u, __TYPE__: exports.BooleanContentType });
|
|
6
10
|
}), (booleanContent) => t.boolean.encode(booleanContent.value));
|
|
7
|
-
|
|
11
|
+
exports.default = BooleanContent;
|
|
@@ -1,32 +1,36 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
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
|
+
const EmbedContent = new t.Type("EmbedContent", (u) => u.__TYPE__ === exports.EmbedContentType, (u) => {
|
|
12
|
+
return (0, function_1.pipe)(EmbedContentC.decode(u), fp_ts_1.either.map((s) => ({
|
|
9
13
|
...EmbedContentC.encode(s),
|
|
10
14
|
all: u,
|
|
11
15
|
})));
|
|
12
16
|
}, (ec) => EmbedContentC.encode(ec));
|
|
13
|
-
const EmbedContentC = addType(t.exact(t.intersection([
|
|
17
|
+
const EmbedContentC = (0, function_2.addType)(t.exact(t.intersection([
|
|
14
18
|
t.type({
|
|
15
19
|
embed_url: t.string,
|
|
16
20
|
type: t.string,
|
|
17
21
|
}),
|
|
18
22
|
t.partial({
|
|
19
23
|
version: t.union([t.string, t.number, t.null]),
|
|
20
|
-
title: StringOrNull,
|
|
21
|
-
author_name: StringOrNull,
|
|
22
|
-
author_url: StringOrNull,
|
|
23
|
-
provider_name: StringOrNull,
|
|
24
|
-
provider_url: StringOrNull,
|
|
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,
|
|
25
29
|
cache_age: t.union([t.string, t.number, t.null]),
|
|
26
|
-
thumbnail_url: StringOrNull,
|
|
27
|
-
thumbnail_width: NumberOrNull,
|
|
28
|
-
thumbnail_height: NumberOrNull,
|
|
29
|
-
html: StringOrNull,
|
|
30
|
+
thumbnail_url: validators_1.StringOrNull,
|
|
31
|
+
thumbnail_width: validators_1.NumberOrNull,
|
|
32
|
+
thumbnail_height: validators_1.NumberOrNull,
|
|
33
|
+
html: validators_1.StringOrNull,
|
|
30
34
|
}),
|
|
31
|
-
])), EmbedContentType);
|
|
32
|
-
|
|
35
|
+
])), exports.EmbedContentType);
|
|
36
|
+
exports.default = EmbedContent;
|
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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";
|
|
5
9
|
//we do that instead of idiomatic .trim()
|
|
6
10
|
//because we need to have the exact same behaviour than scala/java .trim()
|
|
7
11
|
//in other world only trim space and not non-breaking space or tab
|
|
@@ -21,7 +25,7 @@ function trimScalaStyle(s) {
|
|
|
21
25
|
const FieldContent = {
|
|
22
26
|
types: ["Text", "Date", "Timestamp", "Color", "Number", "Range", "Select"],
|
|
23
27
|
forType: (type, value) => {
|
|
24
|
-
return pipe(O.fromEither(t.string.decode(value)), O.map((r) => {
|
|
28
|
+
return (0, function_1.pipe)(O.fromEither(t.string.decode(value)), O.map((r) => {
|
|
25
29
|
return {
|
|
26
30
|
value: trimScalaStyle(r),
|
|
27
31
|
type,
|
|
@@ -30,4 +34,4 @@ const FieldContent = {
|
|
|
30
34
|
}));
|
|
31
35
|
},
|
|
32
36
|
};
|
|
33
|
-
|
|
37
|
+
exports.default = FieldContent;
|
|
@@ -1,9 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GeoPointContent = exports.GeoPointContentType = 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
|
+
exports.GeoPointContentType = "GeoPointContent";
|
|
8
|
+
exports.GeoPointContent = (0, function_1.addType)(t.strict({
|
|
5
9
|
position: t.strict({
|
|
6
10
|
lat: t.number,
|
|
7
11
|
lng: t.number,
|
|
8
12
|
}),
|
|
9
|
-
}), GeoPointContentType);
|
|
13
|
+
}), exports.GeoPointContentType);
|
|
@@ -1,13 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ImageContent = exports.ImageContentType = exports.ImageContentView = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const t = (0, tslib_1.__importStar)(require("io-ts"));
|
|
6
|
+
const validators_1 = require("../../../validators");
|
|
7
|
+
const function_1 = require("../../../validators/function");
|
|
4
8
|
const Origin = t.exact(t.type({
|
|
5
9
|
id: t.string,
|
|
6
10
|
url: t.string,
|
|
7
11
|
width: t.number,
|
|
8
12
|
height: t.number,
|
|
9
13
|
}));
|
|
10
|
-
|
|
14
|
+
exports.ImageContentView = t.exact(t.intersection([
|
|
11
15
|
t.type({
|
|
12
16
|
origin: Origin,
|
|
13
17
|
width: t.number,
|
|
@@ -23,15 +27,15 @@ export const ImageContentView = t.exact(t.intersection([
|
|
|
23
27
|
}),
|
|
24
28
|
t.partial({
|
|
25
29
|
url: t.string,
|
|
26
|
-
credits: NonEmptyStringOrNull,
|
|
27
|
-
alt: NonEmptyStringOrNull,
|
|
28
|
-
provider: StringOrNull,
|
|
30
|
+
credits: validators_1.NonEmptyStringOrNull,
|
|
31
|
+
alt: validators_1.NonEmptyStringOrNull,
|
|
32
|
+
provider: validators_1.StringOrNull,
|
|
29
33
|
}),
|
|
30
34
|
]));
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
ImageContentView,
|
|
35
|
+
exports.ImageContentType = "ImageContent";
|
|
36
|
+
exports.ImageContent = (0, function_1.addType)(t.intersection([
|
|
37
|
+
exports.ImageContentView,
|
|
34
38
|
t.partial({
|
|
35
|
-
thumbnails: t.record(t.string, ImageContentView),
|
|
39
|
+
thumbnails: t.record(t.string, exports.ImageContentView),
|
|
36
40
|
}),
|
|
37
|
-
]), ImageContentType);
|
|
41
|
+
]), exports.ImageContentType);
|
|
@@ -1,12 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.IntegrationFieldsContentType = 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.IntegrationFieldsContentType = "IntegrationFieldsContent";
|
|
8
|
+
const IntegrationFieldsContent = new t.Type("IntegrationFieldsContent", (u) => u?.__TYPE__ === exports.IntegrationFieldsContentType, (u, c) => Either_1.Chain.chain(t.string.validate(u, c), (u) => {
|
|
5
9
|
return t.success({
|
|
6
10
|
value: u,
|
|
7
|
-
__TYPE__: IntegrationFieldsContentType,
|
|
11
|
+
__TYPE__: exports.IntegrationFieldsContentType,
|
|
8
12
|
});
|
|
9
13
|
}), () => {
|
|
10
14
|
throw new Error("Not implemented - Not used - Not relevant");
|
|
11
15
|
});
|
|
12
|
-
|
|
16
|
+
exports.default = IntegrationFieldsContent;
|
|
@@ -1,8 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isDocumentLink = exports.DocumentLink = exports.DocumentLinkType = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const t = (0, tslib_1.__importStar)(require("io-ts"));
|
|
6
|
+
const validators_1 = require("../../../../validators");
|
|
7
|
+
const function_1 = require("../../../../validators/function");
|
|
8
|
+
exports.DocumentLinkType = "DocumentLink";
|
|
9
|
+
exports.DocumentLink = (0, function_1.addType)(t.strict({ id: validators_1.NonEmptyString }), exports.DocumentLinkType);
|
|
10
|
+
function isDocumentLink(u) {
|
|
11
|
+
return u.__TYPE__ === exports.DocumentLinkType;
|
|
8
12
|
}
|
|
13
|
+
exports.isDocumentLink = isDocumentLink;
|
|
@@ -1,19 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isExternalLink = exports.ExternalLink = exports.ExternalLinkType = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const t = (0, tslib_1.__importStar)(require("io-ts"));
|
|
6
|
+
const validators_1 = require("../../../../validators");
|
|
7
|
+
const function_1 = require("../../../../validators/function");
|
|
8
|
+
exports.ExternalLinkType = "ExternalLink";
|
|
9
|
+
exports.ExternalLink = (0, function_1.addType)(t.exact(t.intersection([
|
|
6
10
|
t.type({
|
|
7
11
|
url: t.string,
|
|
8
12
|
}),
|
|
9
13
|
t.partial({
|
|
10
14
|
kind: t.literal("web"),
|
|
11
|
-
target: StringOrNull,
|
|
12
|
-
preview: nullable(t.partial({
|
|
15
|
+
target: validators_1.StringOrNull,
|
|
16
|
+
preview: (0, function_1.nullable)(t.partial({
|
|
13
17
|
title: t.string,
|
|
14
18
|
})),
|
|
15
19
|
}),
|
|
16
|
-
])), ExternalLinkType);
|
|
17
|
-
|
|
18
|
-
return u.__TYPE__ === ExternalLinkType;
|
|
20
|
+
])), exports.ExternalLinkType);
|
|
21
|
+
function isExternalLink(u) {
|
|
22
|
+
return u.__TYPE__ === exports.ExternalLinkType;
|
|
19
23
|
}
|
|
24
|
+
exports.isExternalLink = isExternalLink;
|
|
@@ -1,8 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isFileLink = exports.FileLink = exports.FileLinkType = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const t = (0, tslib_1.__importStar)(require("io-ts"));
|
|
6
|
+
const mapOutput_1 = require("io-ts-types/lib/mapOutput");
|
|
7
|
+
const function_1 = require("../../../../validators/function");
|
|
8
|
+
exports.FileLinkType = "FileLink";
|
|
9
|
+
exports.FileLink = (0, mapOutput_1.mapOutput)(t.exact(t.intersection([
|
|
6
10
|
t.type({
|
|
7
11
|
id: t.string,
|
|
8
12
|
url: t.string,
|
|
@@ -10,10 +14,11 @@ export const FileLink = mapOutput(t.exact(t.intersection([
|
|
|
10
14
|
kind: t.string,
|
|
11
15
|
}),
|
|
12
16
|
t.partial({
|
|
13
|
-
date: nullable(t.string),
|
|
14
|
-
size: nullable(t.string),
|
|
17
|
+
date: (0, function_1.nullable)(t.string),
|
|
18
|
+
size: (0, function_1.nullable)(t.string),
|
|
15
19
|
}),
|
|
16
|
-
])), (o) => ({ ...o, size: o.size || "0", __TYPE__: FileLinkType }));
|
|
17
|
-
|
|
18
|
-
return u.__TYPE__ === FileLinkType;
|
|
20
|
+
])), (o) => ({ ...o, size: o.size || "0", __TYPE__: exports.FileLinkType }));
|
|
21
|
+
function isFileLink(u) {
|
|
22
|
+
return u.__TYPE__ === exports.FileLinkType;
|
|
19
23
|
}
|
|
24
|
+
exports.isFileLink = isFileLink;
|
|
@@ -1,8 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isImageLink = exports.ImageLink = exports.ImageLinkType = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const t = (0, tslib_1.__importStar)(require("io-ts"));
|
|
6
|
+
const validators_1 = require("../../../../validators");
|
|
7
|
+
const function_1 = require("../../../../validators/function");
|
|
8
|
+
exports.ImageLinkType = "ImageLink";
|
|
9
|
+
exports.ImageLink = (0, function_1.addType)(t.exact(t.intersection([
|
|
6
10
|
t.type({
|
|
7
11
|
id: t.string,
|
|
8
12
|
url: t.string,
|
|
@@ -13,9 +17,10 @@ export const ImageLink = addType(t.exact(t.intersection([
|
|
|
13
17
|
kind: t.string,
|
|
14
18
|
}),
|
|
15
19
|
t.partial({
|
|
16
|
-
date: StringOrNull,
|
|
20
|
+
date: validators_1.StringOrNull,
|
|
17
21
|
}),
|
|
18
|
-
])), ImageLinkType);
|
|
19
|
-
|
|
20
|
-
return u.__TYPE__ === ImageLinkType;
|
|
22
|
+
])), exports.ImageLinkType);
|
|
23
|
+
function isImageLink(u) {
|
|
24
|
+
return u.__TYPE__ === exports.ImageLinkType;
|
|
21
25
|
}
|
|
26
|
+
exports.isImageLink = isImageLink;
|
|
@@ -1,9 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LinkContent = exports.LinkContentType = 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
|
+
const index_1 = require("./index");
|
|
8
|
+
exports.LinkContentType = "LinkContent";
|
|
9
|
+
exports.LinkContent = new t.Type("LinkContent", (u) => {
|
|
10
|
+
return index_1.Link.is(u?.value);
|
|
11
|
+
}, (u, c) => Either_1.Chain.chain(index_1.Link.validate(u, c), (u) => {
|
|
12
|
+
return t.success({ value: u, __TYPE__: exports.LinkContentType });
|
|
13
|
+
}), (linkContent) => index_1.Link.encode(linkContent.value));
|
|
@@ -1,26 +1,35 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LinksTypes = exports.is = exports.BROKEN_CUSTOM_TYPE = exports.LinkContent = exports.ImageLink = exports.FileLink = exports.ExternalLink = exports.DocumentLink = exports.Link = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const t = (0, tslib_1.__importStar)(require("io-ts"));
|
|
6
|
+
const DocumentLink_1 = require("./DocumentLink");
|
|
7
|
+
const ExternalLink_1 = require("./ExternalLink");
|
|
8
|
+
const FileLink_1 = require("./FileLink");
|
|
9
|
+
const ImageLink_1 = require("./ImageLink");
|
|
10
|
+
const LinkContent_1 = require("./LinkContent");
|
|
11
|
+
exports.Link = t.union([ImageLink_1.ImageLink, FileLink_1.FileLink, DocumentLink_1.DocumentLink, ExternalLink_1.ExternalLink]);
|
|
12
|
+
var DocumentLink_2 = require("./DocumentLink");
|
|
13
|
+
Object.defineProperty(exports, "DocumentLink", { enumerable: true, get: function () { return DocumentLink_2.DocumentLink; } });
|
|
14
|
+
var ExternalLink_2 = require("./ExternalLink");
|
|
15
|
+
Object.defineProperty(exports, "ExternalLink", { enumerable: true, get: function () { return ExternalLink_2.ExternalLink; } });
|
|
16
|
+
var FileLink_2 = require("./FileLink");
|
|
17
|
+
Object.defineProperty(exports, "FileLink", { enumerable: true, get: function () { return FileLink_2.FileLink; } });
|
|
18
|
+
var ImageLink_2 = require("./ImageLink");
|
|
19
|
+
Object.defineProperty(exports, "ImageLink", { enumerable: true, get: function () { return ImageLink_2.ImageLink; } });
|
|
20
|
+
var LinkContent_2 = require("./LinkContent");
|
|
21
|
+
Object.defineProperty(exports, "LinkContent", { enumerable: true, get: function () { return LinkContent_2.LinkContent; } });
|
|
22
|
+
exports.BROKEN_CUSTOM_TYPE = "broken_type";
|
|
23
|
+
exports.is = {
|
|
24
|
+
documentLink: DocumentLink_1.isDocumentLink,
|
|
25
|
+
fileLink: FileLink_1.isFileLink,
|
|
26
|
+
externalLink: ExternalLink_1.isExternalLink,
|
|
27
|
+
imageLink: ImageLink_1.isImageLink,
|
|
19
28
|
};
|
|
20
|
-
|
|
21
|
-
DocumentLink: DocumentLinkType,
|
|
22
|
-
FileLink: FileLinkType,
|
|
23
|
-
ExternalLink: ExternalLinkType,
|
|
24
|
-
ImageLink: ImageLinkType,
|
|
25
|
-
LinkContent: LinkContentType,
|
|
29
|
+
exports.LinksTypes = {
|
|
30
|
+
DocumentLink: DocumentLink_1.DocumentLinkType,
|
|
31
|
+
FileLink: FileLink_1.FileLinkType,
|
|
32
|
+
ExternalLink: ExternalLink_1.ExternalLinkType,
|
|
33
|
+
ImageLink: ImageLink_1.ImageLinkType,
|
|
34
|
+
LinkContent: LinkContent_1.LinkContentType,
|
|
26
35
|
};
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SeparatorContent = exports.SeparatorContentType = void 0;
|
|
4
|
+
exports.SeparatorContentType = "SeparatorContent";
|
|
5
|
+
exports.SeparatorContent = {
|
|
3
6
|
is(value) {
|
|
4
7
|
const asFieldContent = value;
|
|
5
8
|
return asFieldContent.__TYPE__ === "SeparatorContent";
|
|
@@ -1,11 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Block = exports.TextBlock = exports.checkEmbedBlock = exports.EmbedBlock = exports.EmbedBlockType = exports.checkImageBlock = exports.ImageBlock = exports.ImageBlockType = exports.ValidatedMetas = exports.Meta = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const E = (0, tslib_1.__importStar)(require("fp-ts/lib/Either"));
|
|
6
|
+
const t = (0, tslib_1.__importStar)(require("io-ts"));
|
|
7
|
+
const validators_1 = require("../../../../validators");
|
|
8
|
+
const function_1 = require("../../../../validators/function");
|
|
9
|
+
const EmbedContent_1 = (0, tslib_1.__importDefault)(require("../EmbedContent"));
|
|
10
|
+
const ImageContent_1 = require("../ImageContent");
|
|
11
|
+
const Link_1 = require("../Link");
|
|
12
|
+
exports.Meta = t.exact(t.intersection([
|
|
9
13
|
t.partial({
|
|
10
14
|
data: t.unknown,
|
|
11
15
|
}),
|
|
@@ -15,17 +19,17 @@ export const Meta = t.exact(t.intersection([
|
|
|
15
19
|
type: t.string,
|
|
16
20
|
}),
|
|
17
21
|
]));
|
|
18
|
-
|
|
22
|
+
exports.ValidatedMetas = new t.Type("ValidatedMetas", (metas) => Array.isArray(metas) && metas.every(exports.Meta.is), (metas, c) => {
|
|
19
23
|
if (Array.isArray(metas)) {
|
|
20
24
|
const res = metas
|
|
21
25
|
.reduce((acc, maybeMeta) => {
|
|
22
|
-
const maybeDecodedMeta = Meta.decode(maybeMeta);
|
|
26
|
+
const maybeDecodedMeta = exports.Meta.decode(maybeMeta);
|
|
23
27
|
if (E.isRight(maybeDecodedMeta)) {
|
|
24
28
|
const meta = maybeDecodedMeta.right;
|
|
25
29
|
// if it's an hyperlink it should have data validated as link otherwise we don't care and keep the meta
|
|
26
30
|
if ((meta.data &&
|
|
27
31
|
meta.type === "hyperlink" &&
|
|
28
|
-
E.isRight(Link.validate(meta.data, c))) ||
|
|
32
|
+
E.isRight(Link_1.Link.validate(meta.data, c))) ||
|
|
29
33
|
meta.type !== "hyperlink") {
|
|
30
34
|
return [...acc, meta];
|
|
31
35
|
}
|
|
@@ -37,49 +41,51 @@ export const ValidatedMetas = new t.Type("ValidatedMetas", (metas) => Array.isAr
|
|
|
37
41
|
}
|
|
38
42
|
else
|
|
39
43
|
return t.failure(metas, c);
|
|
40
|
-
}, (m) => t.array(Meta).encode(m));
|
|
41
|
-
|
|
42
|
-
|
|
44
|
+
}, (m) => t.array(exports.Meta).encode(m));
|
|
45
|
+
exports.ImageBlockType = "image";
|
|
46
|
+
exports.ImageBlock = t.exact(t.intersection([
|
|
43
47
|
t.type({
|
|
44
|
-
type: t.literal(ImageBlockType),
|
|
48
|
+
type: t.literal(exports.ImageBlockType),
|
|
45
49
|
data: t.intersection([
|
|
46
|
-
ImageContentView,
|
|
50
|
+
ImageContent_1.ImageContentView,
|
|
47
51
|
t.partial({
|
|
48
|
-
linkTo: nullable(Link),
|
|
52
|
+
linkTo: (0, function_1.nullable)(Link_1.Link),
|
|
49
53
|
}),
|
|
50
54
|
]),
|
|
51
55
|
}),
|
|
52
56
|
t.partial({
|
|
53
|
-
label: StringOrNull,
|
|
54
|
-
direction: StringOrNull,
|
|
57
|
+
label: validators_1.StringOrNull,
|
|
58
|
+
direction: validators_1.StringOrNull,
|
|
55
59
|
}),
|
|
56
60
|
]));
|
|
57
|
-
|
|
58
|
-
return block.type === ImageBlockType;
|
|
61
|
+
function checkImageBlock(block) {
|
|
62
|
+
return block.type === exports.ImageBlockType;
|
|
59
63
|
}
|
|
60
|
-
|
|
61
|
-
|
|
64
|
+
exports.checkImageBlock = checkImageBlock;
|
|
65
|
+
exports.EmbedBlockType = "embed";
|
|
66
|
+
exports.EmbedBlock = t.exact(t.intersection([
|
|
62
67
|
t.type({
|
|
63
|
-
type: t.literal(EmbedBlockType),
|
|
64
|
-
data:
|
|
68
|
+
type: t.literal(exports.EmbedBlockType),
|
|
69
|
+
data: EmbedContent_1.default,
|
|
65
70
|
}),
|
|
66
71
|
t.partial({
|
|
67
|
-
label: StringOrNull,
|
|
68
|
-
direction: StringOrNull,
|
|
72
|
+
label: validators_1.StringOrNull,
|
|
73
|
+
direction: validators_1.StringOrNull,
|
|
69
74
|
}),
|
|
70
75
|
]));
|
|
71
|
-
|
|
72
|
-
return block.type === EmbedBlockType;
|
|
76
|
+
function checkEmbedBlock(block) {
|
|
77
|
+
return block.type === exports.EmbedBlockType;
|
|
73
78
|
}
|
|
74
|
-
|
|
79
|
+
exports.checkEmbedBlock = checkEmbedBlock;
|
|
80
|
+
exports.TextBlock = t.exact(t.intersection([
|
|
75
81
|
t.type({
|
|
76
|
-
type: refineType(t.string, `string which isn't ${ImageBlockType} ${EmbedBlockType}`, (s) => s !== ImageBlockType && s !== EmbedBlockType),
|
|
82
|
+
type: (0, function_1.refineType)(t.string, `string which isn't ${exports.ImageBlockType} ${exports.EmbedBlockType}`, (s) => s !== exports.ImageBlockType && s !== exports.EmbedBlockType),
|
|
77
83
|
content: t.intersection([
|
|
78
84
|
t.type({
|
|
79
85
|
text: t.string,
|
|
80
86
|
}),
|
|
81
87
|
t.partial({
|
|
82
|
-
spans: ValidatedMetas,
|
|
88
|
+
spans: exports.ValidatedMetas,
|
|
83
89
|
}),
|
|
84
90
|
]),
|
|
85
91
|
}),
|
|
@@ -88,4 +94,4 @@ export const TextBlock = t.exact(t.intersection([
|
|
|
88
94
|
direction: t.string,
|
|
89
95
|
}),
|
|
90
96
|
]));
|
|
91
|
-
|
|
97
|
+
exports.Block = t.union([exports.ImageBlock, exports.EmbedBlock, exports.TextBlock]);
|
|
@@ -1,10 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Blocks = exports.StructuredTextContent = exports.StructuredTextContentType = 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
|
+
const Block_1 = require("./Block");
|
|
8
|
+
exports.StructuredTextContentType = "StructuredTextContent";
|
|
9
|
+
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) => {
|
|
10
|
+
return t.success({ value: u, __TYPE__: exports.StructuredTextContentType });
|
|
7
11
|
}), () => {
|
|
8
12
|
throw new Error("NotImplementedError: Not relevant method");
|
|
9
13
|
});
|
|
10
|
-
|
|
14
|
+
exports.Blocks = (0, tslib_1.__importStar)(require("./Block"));
|