@prismicio/types-internal 2.2.1 → 2.3.0
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/content/Document.d.ts +10 -4
- package/lib/content/Document.js +45 -11
- package/lib/content/fields/GroupContent.d.ts +1 -0
- package/lib/content/fields/GroupContent.js +13 -1
- package/lib/content/fields/nestable/BooleanContent.d.ts +2 -0
- package/lib/content/fields/nestable/BooleanContent.js +11 -1
- package/lib/content/fields/nestable/FieldContent/SelectContent.d.ts +2 -0
- package/lib/content/fields/nestable/FieldContent/SelectContent.js +12 -1
- package/lib/content/fields/nestable/NestableContent.d.ts +2 -0
- package/lib/content/fields/nestable/NestableContent.js +12 -1
- package/lib/content/fields/slices/Slice/CompositeSliceContent.d.ts +1 -0
- package/lib/content/fields/slices/Slice/CompositeSliceContent.js +13 -1
- package/lib/content/fields/slices/Slice/SharedSliceContent.d.ts +2 -1
- package/lib/content/fields/slices/Slice/SharedSliceContent.js +16 -1
- package/lib/content/fields/slices/SliceItem.d.ts +3 -0
- package/lib/content/fields/slices/SliceItem.js +24 -1
- package/lib/content/fields/slices/SlicesContent.d.ts +1 -0
- package/lib/content/fields/slices/SlicesContent.js +23 -1
- package/lib/content/fields/withDefaultValues.d.ts +6 -0
- package/lib/content/fields/withDefaultValues.js +38 -0
- package/lib/import/converters/Document.d.ts +4 -0
- package/lib/import/converters/Document.js +21 -0
- package/lib/import/converters/fields/Group.d.ts +4 -0
- package/lib/import/converters/fields/Group.js +14 -0
- package/lib/import/converters/fields/RepeatableZone.d.ts +317 -0
- package/lib/import/converters/fields/RepeatableZone.js +15 -0
- package/lib/import/converters/fields/RepeatableZoneItem.d.ts +11 -0
- package/lib/import/converters/fields/RepeatableZoneItem.js +19 -0
- package/lib/import/converters/fields/Slices/SharedSlice.d.ts +4 -0
- package/lib/import/converters/fields/Slices/SharedSlice.js +19 -0
- package/lib/import/converters/fields/Slices/SharedSliceContent.d.ts +10 -0
- package/lib/import/converters/fields/Slices/SharedSliceContent.js +23 -0
- package/lib/import/converters/fields/Slices/Slices.d.ts +4 -0
- package/lib/import/converters/fields/Slices/Slices.js +16 -0
- package/lib/import/converters/fields/Slices/index.d.ts +1 -0
- package/lib/import/converters/fields/Slices/index.js +4 -0
- package/lib/import/converters/fields/UID.d.ts +3 -0
- package/lib/import/converters/fields/UID.js +10 -0
- package/lib/import/converters/fields/index.d.ts +4 -0
- package/lib/import/converters/fields/index.js +7 -0
- package/lib/import/converters/fields/nestable/Boolean.d.ts +3 -0
- package/lib/import/converters/fields/nestable/Boolean.js +12 -0
- package/lib/import/converters/fields/nestable/Color.d.ts +3 -0
- package/lib/import/converters/fields/nestable/Color.js +13 -0
- package/lib/import/converters/fields/nestable/Date.d.ts +3 -0
- package/lib/import/converters/fields/nestable/Date.js +15 -0
- package/lib/import/converters/fields/nestable/Embed.d.ts +4 -0
- package/lib/import/converters/fields/nestable/Embed.js +32 -0
- package/lib/import/converters/fields/nestable/GeoPoint.d.ts +3 -0
- package/lib/import/converters/fields/nestable/GeoPoint.js +15 -0
- package/lib/import/converters/fields/nestable/Image.d.ts +28 -0
- package/lib/import/converters/fields/nestable/Image.js +67 -0
- package/lib/import/converters/fields/nestable/Link.d.ts +4 -0
- package/lib/import/converters/fields/nestable/Link.js +70 -0
- package/lib/import/converters/fields/nestable/Nestable.d.ts +5 -0
- package/lib/import/converters/fields/nestable/Nestable.js +35 -0
- package/lib/import/converters/fields/nestable/Number.d.ts +3 -0
- package/lib/import/converters/fields/nestable/Number.js +13 -0
- package/lib/import/converters/fields/nestable/RichText/embedBlock.d.ts +4 -0
- package/lib/import/converters/fields/nestable/RichText/embedBlock.js +14 -0
- package/lib/import/converters/fields/nestable/RichText/imageBlock.d.ts +4 -0
- package/lib/import/converters/fields/nestable/RichText/imageBlock.js +12 -0
- package/lib/import/converters/fields/nestable/RichText/index.d.ts +4 -0
- package/lib/import/converters/fields/nestable/RichText/index.js +22 -0
- package/lib/import/converters/fields/nestable/RichText/textBlock.d.ts +4 -0
- package/lib/import/converters/fields/nestable/RichText/textBlock.js +54 -0
- package/lib/import/converters/fields/nestable/Select.d.ts +3 -0
- package/lib/import/converters/fields/nestable/Select.js +13 -0
- package/lib/import/converters/fields/nestable/Text.d.ts +3 -0
- package/lib/import/converters/fields/nestable/Text.js +13 -0
- package/lib/import/converters/fields/nestable/Timestamp.d.ts +3 -0
- package/lib/import/converters/fields/nestable/Timestamp.js +13 -0
- package/lib/import/converters/fields/nestable/index.d.ts +13 -0
- package/lib/import/converters/fields/nestable/index.js +16 -0
- package/lib/import/converters/index.d.ts +2 -0
- package/lib/import/converters/index.js +5 -0
- package/lib/import/index.d.ts +2 -0
- package/lib/import/index.js +5 -0
- package/lib/import/validators/Document.d.ts +6 -0
- package/lib/import/validators/Document.js +64 -0
- package/lib/import/validators/fields/ImportContent.d.ts +5 -0
- package/lib/import/validators/fields/ImportContent.js +21 -0
- package/lib/import/validators/fields/ImportField.d.ts +141 -0
- package/lib/import/validators/fields/ImportField.js +33 -0
- package/lib/import/validators/fields/ImportGroup.d.ts +345 -0
- package/lib/import/validators/fields/ImportGroup.js +27 -0
- package/lib/import/validators/fields/ImportSlices/ImportSlices.d.ts +8 -0
- package/lib/import/validators/fields/ImportSlices/ImportSlices.js +30 -0
- package/lib/import/validators/fields/ImportSlices/SharedSlice/SharedSlice.d.ts +16 -0
- package/lib/import/validators/fields/ImportSlices/SharedSlice/SharedSlice.js +61 -0
- package/lib/import/validators/fields/ImportSlices/SharedSlice/errors.d.ts +4 -0
- package/lib/import/validators/fields/ImportSlices/SharedSlice/errors.js +7 -0
- package/lib/import/validators/fields/ImportSlices/SharedSlice/fields/OptionalSharedSliceId.d.ts +2 -0
- package/lib/import/validators/fields/ImportSlices/SharedSlice/fields/OptionalSharedSliceId.js +15 -0
- package/lib/import/validators/fields/ImportSlices/SharedSlice/fields/SharedSliceId.d.ts +9 -0
- package/lib/import/validators/fields/ImportSlices/SharedSlice/fields/SharedSliceId.js +39 -0
- package/lib/import/validators/fields/ImportSlices/SharedSlice/fields/SharedSliceType.d.ts +11 -0
- package/lib/import/validators/fields/ImportSlices/SharedSlice/fields/SharedSliceType.js +24 -0
- package/lib/import/validators/fields/ImportSlices/SharedSlice/fields/SharedSliceVariation.d.ts +11 -0
- package/lib/import/validators/fields/ImportSlices/SharedSlice/fields/SharedSliceVariation.js +24 -0
- package/lib/import/validators/fields/ImportSlices/SharedSlice/fields/index.d.ts +4 -0
- package/lib/import/validators/fields/ImportSlices/SharedSlice/fields/index.js +7 -0
- package/lib/import/validators/fields/ImportSlices/SharedSlice/index.d.ts +3 -0
- package/lib/import/validators/fields/ImportSlices/SharedSlice/index.js +6 -0
- package/lib/import/validators/fields/ImportSlices/SharedSlice/utils.d.ts +342 -0
- package/lib/import/validators/fields/ImportSlices/SharedSlice/utils.js +11 -0
- package/lib/import/validators/fields/ImportSlices/index.d.ts +1 -0
- package/lib/import/validators/fields/ImportSlices/index.js +4 -0
- package/lib/import/validators/fields/ImportSlices/utils.d.ts +4 -0
- package/lib/import/validators/fields/ImportSlices/utils.js +35 -0
- package/lib/import/validators/fields/RepeatableZone.d.ts +11 -0
- package/lib/import/validators/fields/RepeatableZone.js +14 -0
- package/lib/import/validators/fields/RepeatableZoneItem.d.ts +11 -0
- package/lib/import/validators/fields/RepeatableZoneItem.js +39 -0
- package/lib/import/validators/fields/UID.d.ts +6 -0
- package/lib/import/validators/fields/UID.js +15 -0
- package/lib/import/validators/fields/index.d.ts +4 -0
- package/lib/import/validators/fields/index.js +7 -0
- package/lib/import/validators/fields/nestable/Boolean.d.ts +6 -0
- package/lib/import/validators/fields/nestable/Boolean.js +6 -0
- package/lib/import/validators/fields/nestable/Color.d.ts +6 -0
- package/lib/import/validators/fields/nestable/Color.js +15 -0
- package/lib/import/validators/fields/nestable/Date.d.ts +6 -0
- package/lib/import/validators/fields/nestable/Date.js +19 -0
- package/lib/import/validators/fields/nestable/Embed.d.ts +13 -0
- package/lib/import/validators/fields/nestable/Embed.js +31 -0
- package/lib/import/validators/fields/nestable/GeoPoint.d.ts +13 -0
- package/lib/import/validators/fields/nestable/GeoPoint.js +13 -0
- package/lib/import/validators/fields/nestable/Image/default.d.ts +22 -0
- package/lib/import/validators/fields/nestable/Image/default.js +19 -0
- package/lib/import/validators/fields/nestable/Image/index.d.ts +26 -0
- package/lib/import/validators/fields/nestable/Image/index.js +32 -0
- package/lib/import/validators/fields/nestable/Image/merge.d.ts +23 -0
- package/lib/import/validators/fields/nestable/Image/merge.js +44 -0
- package/lib/import/validators/fields/nestable/Image/model.d.ts +18 -0
- package/lib/import/validators/fields/nestable/Image/model.js +2 -0
- package/lib/import/validators/fields/nestable/Image/validators.d.ts +132 -0
- package/lib/import/validators/fields/nestable/Image/validators.js +43 -0
- package/lib/import/validators/fields/nestable/ImportRichText/ImportBlock.d.ts +6 -0
- package/lib/import/validators/fields/nestable/ImportRichText/ImportBlock.js +25 -0
- package/lib/import/validators/fields/nestable/ImportRichText/ImportRichText.d.ts +24 -0
- package/lib/import/validators/fields/nestable/ImportRichText/ImportRichText.js +32 -0
- package/lib/import/validators/fields/nestable/ImportRichText/blocks/ImportBlockType.d.ts +6 -0
- package/lib/import/validators/fields/nestable/ImportRichText/blocks/ImportBlockType.js +18 -0
- package/lib/import/validators/fields/nestable/ImportRichText/blocks/ImportEmbedBlock.d.ts +10 -0
- package/lib/import/validators/fields/nestable/ImportRichText/blocks/ImportEmbedBlock.js +11 -0
- package/lib/import/validators/fields/nestable/ImportRichText/blocks/ImportImageBlock.d.ts +22 -0
- package/lib/import/validators/fields/nestable/ImportRichText/blocks/ImportImageBlock.js +13 -0
- package/lib/import/validators/fields/nestable/ImportRichText/blocks/ImportTextBlock.d.ts +78 -0
- package/lib/import/validators/fields/nestable/ImportRichText/blocks/ImportTextBlock.js +43 -0
- package/lib/import/validators/fields/nestable/ImportRichText/blocks/Span.d.ts +79 -0
- package/lib/import/validators/fields/nestable/ImportRichText/blocks/Span.js +27 -0
- package/lib/import/validators/fields/nestable/ImportRichText/blocks/index.d.ts +4 -0
- package/lib/import/validators/fields/nestable/ImportRichText/blocks/index.js +7 -0
- package/lib/import/validators/fields/nestable/ImportRichText/blocks/spans/HyperlinkSpan.d.ts +24 -0
- package/lib/import/validators/fields/nestable/ImportRichText/blocks/spans/HyperlinkSpan.js +18 -0
- package/lib/import/validators/fields/nestable/ImportRichText/blocks/spans/LabelSpan.d.ts +12 -0
- package/lib/import/validators/fields/nestable/ImportRichText/blocks/spans/LabelSpan.js +16 -0
- package/lib/import/validators/fields/nestable/ImportRichText/blocks/spans/SpanLocation.d.ts +5 -0
- package/lib/import/validators/fields/nestable/ImportRichText/blocks/spans/SpanLocation.js +10 -0
- package/lib/import/validators/fields/nestable/ImportRichText/blocks/spans/TextSpan.d.ts +15 -0
- package/lib/import/validators/fields/nestable/ImportRichText/blocks/spans/TextSpan.js +20 -0
- package/lib/import/validators/fields/nestable/ImportRichText/blocks/spans/index.d.ts +2 -0
- package/lib/import/validators/fields/nestable/ImportRichText/blocks/spans/index.js +5 -0
- package/lib/import/validators/fields/nestable/ImportRichText/index.d.ts +2 -0
- package/lib/import/validators/fields/nestable/ImportRichText/index.js +7 -0
- package/lib/import/validators/fields/nestable/Link.d.ts +53 -0
- package/lib/import/validators/fields/nestable/Link.js +35 -0
- package/lib/import/validators/fields/nestable/Nestable.d.ts +192 -0
- package/lib/import/validators/fields/nestable/Nestable.js +71 -0
- package/lib/import/validators/fields/nestable/Number.d.ts +17 -0
- package/lib/import/validators/fields/nestable/Number.js +17 -0
- package/lib/import/validators/fields/nestable/Select.d.ts +16 -0
- package/lib/import/validators/fields/nestable/Select.js +19 -0
- package/lib/import/validators/fields/nestable/Text.d.ts +6 -0
- package/lib/import/validators/fields/nestable/Text.js +6 -0
- package/lib/import/validators/fields/nestable/Timestamp.d.ts +7 -0
- package/lib/import/validators/fields/nestable/Timestamp.js +19 -0
- package/lib/import/validators/fields/nestable/index.d.ts +14 -0
- package/lib/import/validators/fields/nestable/index.js +19 -0
- package/lib/import/validators/index.d.ts +2 -0
- package/lib/import/validators/index.js +5 -0
- package/package.json +1 -1
- package/src/content/Document.ts +68 -14
- package/src/content/fields/GroupContent.ts +16 -0
- package/src/content/fields/nestable/BooleanContent.ts +11 -0
- package/src/content/fields/nestable/FieldContent/SelectContent.ts +12 -1
- package/src/content/fields/nestable/NestableContent.ts +16 -0
- package/src/content/fields/slices/Slice/CompositeSliceContent.ts +25 -0
- package/src/content/fields/slices/Slice/SharedSliceContent.ts +32 -1
- package/src/content/fields/slices/SliceItem.ts +43 -1
- package/src/content/fields/slices/SlicesContent.ts +30 -0
- package/src/content/fields/withDefaultValues.ts +48 -0
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import * as t from "io-ts";
|
|
2
|
+
import { ImportEmbedBlockType } from "./ImportEmbedBlock";
|
|
3
|
+
import { ImportImageBlockType } from "./ImportImageBlock";
|
|
4
|
+
import { ImportTextBlockType } from "./ImportTextBlock";
|
|
5
|
+
export declare type ImportBlockType = ImportTextBlockType | ImportImageBlockType | ImportEmbedBlockType;
|
|
6
|
+
export declare const ImportBlockType: (allowedBlockTypes: string[]) => t.Type<ImportBlockType, ImportBlockType, unknown>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ImportBlockType = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const E = (0, tslib_1.__importStar)(require("fp-ts/Either"));
|
|
6
|
+
const function_1 = require("fp-ts/function");
|
|
7
|
+
const t = (0, tslib_1.__importStar)(require("io-ts"));
|
|
8
|
+
const function_2 = require("../../../../../../validators/function");
|
|
9
|
+
const ImportEmbedBlock_1 = require("./ImportEmbedBlock");
|
|
10
|
+
const ImportImageBlock_1 = require("./ImportImageBlock");
|
|
11
|
+
const ImportTextBlock_1 = require("./ImportTextBlock");
|
|
12
|
+
const ImportBlockTypeValidator = (0, function_2.withCustomError)(t.union([ImportTextBlock_1.ImportTextBlockType, ImportImageBlock_1.ImportImageBlockType, ImportEmbedBlock_1.ImportEmbedBlockType]), () => `Invalid block type. Supported block types are: ${Object.keys(ImportTextBlock_1.ImportTextBlockType.keys).join(", ")}, ${ImportImageBlock_1.ImportImageBlockType.value}, ${ImportEmbedBlock_1.ImportEmbedBlockType.value}`);
|
|
13
|
+
const ImportBlockType = (allowedBlockTypes) => new t.Type("ImportBlockType", (u) => ImportBlockTypeValidator.is(u), (u, c) => {
|
|
14
|
+
return (0, function_1.pipe)(ImportBlockTypeValidator.validate(u, c), E.chain((validBlockType) => allowedBlockTypes.includes(validBlockType)
|
|
15
|
+
? t.success(validBlockType)
|
|
16
|
+
: t.failure(u, c, `The block type '${validBlockType}' is not allowed in your document type. Enable the type for this rich text field to create the document.`)));
|
|
17
|
+
}, t.identity);
|
|
18
|
+
exports.ImportBlockType = ImportBlockType;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as t from "io-ts";
|
|
2
|
+
export declare const ImportEmbedBlockType: t.LiteralC<"embed">;
|
|
3
|
+
export declare type ImportEmbedBlockType = t.TypeOf<typeof ImportEmbedBlockType>;
|
|
4
|
+
export declare const ImportEmbedBlock: t.ExactC<t.TypeC<{
|
|
5
|
+
type: t.LiteralC<"embed">;
|
|
6
|
+
oembed: t.ExactC<t.TypeC<{
|
|
7
|
+
embed_url: t.Type<string, string, unknown>;
|
|
8
|
+
}>>;
|
|
9
|
+
}>>;
|
|
10
|
+
export declare type ImportEmbedBlock = t.TypeOf<typeof ImportEmbedBlock>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ImportEmbedBlock = exports.ImportEmbedBlockType = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const t = (0, tslib_1.__importStar)(require("io-ts"));
|
|
6
|
+
const Embed_1 = require("../../Embed");
|
|
7
|
+
exports.ImportEmbedBlockType = t.literal("embed");
|
|
8
|
+
exports.ImportEmbedBlock = t.strict({
|
|
9
|
+
type: exports.ImportEmbedBlockType,
|
|
10
|
+
oembed: Embed_1.ImportEmbedValue,
|
|
11
|
+
});
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import * as t from "io-ts";
|
|
2
|
+
export declare const ImportImageBlockType: t.LiteralC<"image">;
|
|
3
|
+
export declare type ImportImageBlockType = t.TypeOf<typeof ImportImageBlockType>;
|
|
4
|
+
export declare const ImportImageBlock: t.ExactC<t.IntersectionC<[t.TypeC<{
|
|
5
|
+
type: t.LiteralC<"image">;
|
|
6
|
+
}>, t.IntersectionC<[t.TypeC<{
|
|
7
|
+
id: t.StringC;
|
|
8
|
+
}>, t.PartialC<{
|
|
9
|
+
dimensions: t.PartialC<{
|
|
10
|
+
width: t.NumberC;
|
|
11
|
+
height: t.NumberC;
|
|
12
|
+
}>;
|
|
13
|
+
edit: t.PartialC<{
|
|
14
|
+
x: t.NumberC;
|
|
15
|
+
y: t.NumberC;
|
|
16
|
+
zoom: t.NumberC;
|
|
17
|
+
background: t.StringC;
|
|
18
|
+
}>;
|
|
19
|
+
copyright: t.UnionC<[t.StringC, t.NullC]>;
|
|
20
|
+
alt: t.UnionC<[t.StringC, t.NullC]>;
|
|
21
|
+
}>]>]>>;
|
|
22
|
+
export declare type ImportImageBlock = t.TypeOf<typeof ImportImageBlock>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ImportImageBlock = exports.ImportImageBlockType = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const t = (0, tslib_1.__importStar)(require("io-ts"));
|
|
6
|
+
const validators_1 = require("../../Image/validators");
|
|
7
|
+
exports.ImportImageBlockType = t.literal("image");
|
|
8
|
+
exports.ImportImageBlock = t.exact(t.intersection([
|
|
9
|
+
t.type({
|
|
10
|
+
type: exports.ImportImageBlockType,
|
|
11
|
+
}),
|
|
12
|
+
validators_1.ImportImageView,
|
|
13
|
+
]));
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import * as t from "io-ts";
|
|
2
|
+
export declare const ImportTextBlockTypes: {
|
|
3
|
+
readonly Paragraph: "paragraph";
|
|
4
|
+
readonly OListItem: "o-list-item";
|
|
5
|
+
readonly ListItem: "list-item";
|
|
6
|
+
readonly Heading1: "heading1";
|
|
7
|
+
readonly Heading2: "heading2";
|
|
8
|
+
readonly Heading3: "heading3";
|
|
9
|
+
readonly Heading4: "heading4";
|
|
10
|
+
readonly Heading5: "heading5";
|
|
11
|
+
readonly Heading6: "heading6";
|
|
12
|
+
readonly Preformatted: "preformatted";
|
|
13
|
+
};
|
|
14
|
+
export declare const ImportTextBlockType: t.KeyofC<{
|
|
15
|
+
paragraph: null;
|
|
16
|
+
"o-list-item": null;
|
|
17
|
+
"list-item": null;
|
|
18
|
+
heading1: null;
|
|
19
|
+
heading2: null;
|
|
20
|
+
heading3: null;
|
|
21
|
+
heading4: null;
|
|
22
|
+
heading5: null;
|
|
23
|
+
heading6: null;
|
|
24
|
+
preformatted: null;
|
|
25
|
+
}>;
|
|
26
|
+
export declare type ImportTextBlockType = t.TypeOf<typeof ImportTextBlockType>;
|
|
27
|
+
export declare const ImportTextBlock: t.ExactC<t.IntersectionC<[t.TypeC<{
|
|
28
|
+
type: t.KeyofC<{
|
|
29
|
+
paragraph: null;
|
|
30
|
+
"o-list-item": null;
|
|
31
|
+
"list-item": null;
|
|
32
|
+
heading1: null;
|
|
33
|
+
heading2: null;
|
|
34
|
+
heading3: null;
|
|
35
|
+
heading4: null;
|
|
36
|
+
heading5: null;
|
|
37
|
+
heading6: null;
|
|
38
|
+
preformatted: null;
|
|
39
|
+
}>;
|
|
40
|
+
text: t.StringC;
|
|
41
|
+
}>, t.PartialC<{
|
|
42
|
+
spans: t.ArrayC<t.Type<({
|
|
43
|
+
type: "hyperlink";
|
|
44
|
+
} & {
|
|
45
|
+
start: number;
|
|
46
|
+
end: number;
|
|
47
|
+
} & {
|
|
48
|
+
data: ({
|
|
49
|
+
link_type: "Web";
|
|
50
|
+
url: string;
|
|
51
|
+
} & {
|
|
52
|
+
target?: string;
|
|
53
|
+
}) | {
|
|
54
|
+
link_type: "Document";
|
|
55
|
+
id: string;
|
|
56
|
+
} | {
|
|
57
|
+
link_type: "Media";
|
|
58
|
+
id: string;
|
|
59
|
+
};
|
|
60
|
+
}) | ({
|
|
61
|
+
type: "strong" | "em";
|
|
62
|
+
} & {
|
|
63
|
+
start: number;
|
|
64
|
+
end: number;
|
|
65
|
+
}) | ({
|
|
66
|
+
type: "label";
|
|
67
|
+
data: {
|
|
68
|
+
label: string;
|
|
69
|
+
};
|
|
70
|
+
} & {
|
|
71
|
+
start: number;
|
|
72
|
+
end: number;
|
|
73
|
+
}), {
|
|
74
|
+
type: "label" | "strong" | "em" | "hyperlink";
|
|
75
|
+
}, unknown>>;
|
|
76
|
+
direction: t.UnionC<[t.LiteralC<"ltr">, t.LiteralC<"rtl">]>;
|
|
77
|
+
}>]>>;
|
|
78
|
+
export declare type ImportTextBlock = t.TypeOf<typeof ImportTextBlock>;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ImportTextBlock = exports.ImportTextBlockType = exports.ImportTextBlockTypes = 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
|
+
const Span_1 = require("./Span");
|
|
9
|
+
exports.ImportTextBlockTypes = {
|
|
10
|
+
Paragraph: "paragraph",
|
|
11
|
+
OListItem: "o-list-item",
|
|
12
|
+
ListItem: "list-item",
|
|
13
|
+
Heading1: "heading1",
|
|
14
|
+
Heading2: "heading2",
|
|
15
|
+
Heading3: "heading3",
|
|
16
|
+
Heading4: "heading4",
|
|
17
|
+
Heading5: "heading5",
|
|
18
|
+
Heading6: "heading6",
|
|
19
|
+
Preformatted: "preformatted",
|
|
20
|
+
};
|
|
21
|
+
exports.ImportTextBlockType = t.keyof({
|
|
22
|
+
[exports.ImportTextBlockTypes.Paragraph]: null,
|
|
23
|
+
[exports.ImportTextBlockTypes.OListItem]: null,
|
|
24
|
+
[exports.ImportTextBlockTypes.ListItem]: null,
|
|
25
|
+
[exports.ImportTextBlockTypes.Heading1]: null,
|
|
26
|
+
[exports.ImportTextBlockTypes.Heading2]: null,
|
|
27
|
+
[exports.ImportTextBlockTypes.Heading3]: null,
|
|
28
|
+
[exports.ImportTextBlockTypes.Heading4]: null,
|
|
29
|
+
[exports.ImportTextBlockTypes.Heading5]: null,
|
|
30
|
+
[exports.ImportTextBlockTypes.Heading6]: null,
|
|
31
|
+
[exports.ImportTextBlockTypes.Preformatted]: null,
|
|
32
|
+
});
|
|
33
|
+
const TextDirection = (0, function_1.withCustomError)(t.union([t.literal("ltr"), t.literal("rtl")]), () => "The 'direction' property must be one of the following: ltr, rtl");
|
|
34
|
+
exports.ImportTextBlock = t.exact(t.intersection([
|
|
35
|
+
t.type({
|
|
36
|
+
type: exports.ImportTextBlockType,
|
|
37
|
+
text: validators_1.String,
|
|
38
|
+
}),
|
|
39
|
+
t.partial({
|
|
40
|
+
spans: (0, function_1.withCustomError)(t.array(Span_1.Span), () => "The 'spans' field must be an array"),
|
|
41
|
+
direction: TextDirection,
|
|
42
|
+
}),
|
|
43
|
+
]));
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import * as t from "io-ts";
|
|
2
|
+
declare const SpanType: t.UnionC<[t.LiteralC<"hyperlink">, t.KeyofC<{
|
|
3
|
+
strong: null;
|
|
4
|
+
em: null;
|
|
5
|
+
}>, t.LiteralC<"label">]>;
|
|
6
|
+
export declare type SpanType = t.TypeOf<typeof SpanType>;
|
|
7
|
+
declare const SpanShape: t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
|
|
8
|
+
type: t.LiteralC<"hyperlink">;
|
|
9
|
+
}>, t.TypeC<{
|
|
10
|
+
start: t.NumberC;
|
|
11
|
+
end: t.NumberC;
|
|
12
|
+
}>, t.TypeC<{
|
|
13
|
+
data: t.Type<({
|
|
14
|
+
link_type: "Web";
|
|
15
|
+
url: string;
|
|
16
|
+
} & {
|
|
17
|
+
target?: string;
|
|
18
|
+
}) | {
|
|
19
|
+
link_type: "Document";
|
|
20
|
+
id: string;
|
|
21
|
+
} | {
|
|
22
|
+
link_type: "Media";
|
|
23
|
+
id: string;
|
|
24
|
+
}, {
|
|
25
|
+
link_type: "Document" | "Web" | "Media";
|
|
26
|
+
}, unknown>;
|
|
27
|
+
}>]>>, t.ExactC<t.IntersectionC<[t.TypeC<{
|
|
28
|
+
type: t.KeyofC<{
|
|
29
|
+
strong: null;
|
|
30
|
+
em: null;
|
|
31
|
+
}>;
|
|
32
|
+
}>, t.TypeC<{
|
|
33
|
+
start: t.NumberC;
|
|
34
|
+
end: t.NumberC;
|
|
35
|
+
}>]>>, t.ExactC<t.IntersectionC<[t.TypeC<{
|
|
36
|
+
type: t.LiteralC<"label">;
|
|
37
|
+
data: t.ExactC<t.TypeC<{
|
|
38
|
+
label: t.StringC;
|
|
39
|
+
}>>;
|
|
40
|
+
}>, t.TypeC<{
|
|
41
|
+
start: t.NumberC;
|
|
42
|
+
end: t.NumberC;
|
|
43
|
+
}>]>>]>;
|
|
44
|
+
export declare type Span = t.TypeOf<typeof SpanShape>;
|
|
45
|
+
export declare const Span: t.Type<({
|
|
46
|
+
type: "hyperlink";
|
|
47
|
+
} & {
|
|
48
|
+
start: number;
|
|
49
|
+
end: number;
|
|
50
|
+
} & {
|
|
51
|
+
data: ({
|
|
52
|
+
link_type: "Web";
|
|
53
|
+
url: string;
|
|
54
|
+
} & {
|
|
55
|
+
target?: string;
|
|
56
|
+
}) | {
|
|
57
|
+
link_type: "Document";
|
|
58
|
+
id: string;
|
|
59
|
+
} | {
|
|
60
|
+
link_type: "Media";
|
|
61
|
+
id: string;
|
|
62
|
+
};
|
|
63
|
+
}) | ({
|
|
64
|
+
type: "strong" | "em";
|
|
65
|
+
} & {
|
|
66
|
+
start: number;
|
|
67
|
+
end: number;
|
|
68
|
+
}) | ({
|
|
69
|
+
type: "label";
|
|
70
|
+
data: {
|
|
71
|
+
label: string;
|
|
72
|
+
};
|
|
73
|
+
} & {
|
|
74
|
+
start: number;
|
|
75
|
+
end: number;
|
|
76
|
+
}), {
|
|
77
|
+
type: "label" | "strong" | "em" | "hyperlink";
|
|
78
|
+
}, unknown>;
|
|
79
|
+
export {};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Span = 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 spans_1 = require("./spans");
|
|
8
|
+
const LabelSpan_1 = require("./spans/LabelSpan");
|
|
9
|
+
const SpanType = (0, function_1.withCustomError)(t.union([spans_1.HyperlinkSpanType, spans_1.TextSpanType, LabelSpan_1.LabelSpanType]), () => `Span 'type' field must be specified and have one of the following values: ${[
|
|
10
|
+
...Object.keys(spans_1.TextSpanType.keys),
|
|
11
|
+
LabelSpan_1.LabelSpanType.value,
|
|
12
|
+
].join(", ")} or ${spans_1.HyperlinkSpanType.value}`);
|
|
13
|
+
const SpanTypeValidator = (0, function_1.withCustomError)(t.type({
|
|
14
|
+
type: SpanType,
|
|
15
|
+
}), () => "Span must be an object");
|
|
16
|
+
const SpanShape = t.union([spans_1.HyperlinkSpan, spans_1.TextSpan, LabelSpan_1.LabelSpan]);
|
|
17
|
+
exports.Span = SpanTypeValidator.pipe(new t.Type("Span", (u) => SpanShape.is(u), (u, c) => {
|
|
18
|
+
if (spans_1.HyperlinkSpanType.is(u.type)) {
|
|
19
|
+
return spans_1.HyperlinkSpan.validate(u, c);
|
|
20
|
+
}
|
|
21
|
+
else if (LabelSpan_1.LabelSpanType.is(u.type)) {
|
|
22
|
+
return LabelSpan_1.LabelSpan.validate(u, c);
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
return spans_1.TextSpan.validate(u, c);
|
|
26
|
+
}
|
|
27
|
+
}, t.identity));
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
(0, tslib_1.__exportStar)(require("./ImportBlockType"), exports);
|
|
5
|
+
(0, tslib_1.__exportStar)(require("./ImportEmbedBlock"), exports);
|
|
6
|
+
(0, tslib_1.__exportStar)(require("./ImportImageBlock"), exports);
|
|
7
|
+
(0, tslib_1.__exportStar)(require("./ImportTextBlock"), exports);
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import * as t from "io-ts";
|
|
2
|
+
export declare const HyperlinkSpanType: t.LiteralC<"hyperlink">;
|
|
3
|
+
export declare type HyperlinkSpanType = t.TypeOf<typeof HyperlinkSpanType>;
|
|
4
|
+
export declare const HyperlinkSpan: t.ExactC<t.IntersectionC<[t.TypeC<{
|
|
5
|
+
type: t.LiteralC<"hyperlink">;
|
|
6
|
+
}>, t.TypeC<{
|
|
7
|
+
start: t.NumberC;
|
|
8
|
+
end: t.NumberC;
|
|
9
|
+
}>, t.TypeC<{
|
|
10
|
+
data: t.Type<({
|
|
11
|
+
link_type: "Web";
|
|
12
|
+
url: string;
|
|
13
|
+
} & {
|
|
14
|
+
target?: string;
|
|
15
|
+
}) | {
|
|
16
|
+
link_type: "Document";
|
|
17
|
+
id: string;
|
|
18
|
+
} | {
|
|
19
|
+
link_type: "Media";
|
|
20
|
+
id: string;
|
|
21
|
+
}, {
|
|
22
|
+
link_type: "Document" | "Web" | "Media";
|
|
23
|
+
}, unknown>;
|
|
24
|
+
}>]>>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.HyperlinkSpan = exports.HyperlinkSpanType = 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 Link_1 = require("../../../Link");
|
|
8
|
+
const SpanLocation_1 = require("./SpanLocation");
|
|
9
|
+
exports.HyperlinkSpanType = t.literal("hyperlink");
|
|
10
|
+
exports.HyperlinkSpan = t.exact(t.intersection([
|
|
11
|
+
t.type({
|
|
12
|
+
type: exports.HyperlinkSpanType,
|
|
13
|
+
}),
|
|
14
|
+
SpanLocation_1.SpanLocation,
|
|
15
|
+
(0, function_1.withCustomError)(t.type({
|
|
16
|
+
data: Link_1.Link,
|
|
17
|
+
}), () => "Hyperlink span must contain a 'data' field with link data"),
|
|
18
|
+
]));
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import * as t from "io-ts";
|
|
2
|
+
export declare const LabelSpanType: t.LiteralC<"label">;
|
|
3
|
+
export declare const LabelSpan: t.ExactC<t.IntersectionC<[t.TypeC<{
|
|
4
|
+
type: t.LiteralC<"label">;
|
|
5
|
+
data: t.ExactC<t.TypeC<{
|
|
6
|
+
label: t.StringC;
|
|
7
|
+
}>>;
|
|
8
|
+
}>, t.TypeC<{
|
|
9
|
+
start: t.NumberC;
|
|
10
|
+
end: t.NumberC;
|
|
11
|
+
}>]>>;
|
|
12
|
+
export declare type LabelSpan = t.TypeOf<typeof LabelSpan>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LabelSpan = exports.LabelSpanType = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const t = (0, tslib_1.__importStar)(require("io-ts"));
|
|
6
|
+
const SpanLocation_1 = require("./SpanLocation");
|
|
7
|
+
exports.LabelSpanType = t.literal("label");
|
|
8
|
+
exports.LabelSpan = t.exact(t.intersection([
|
|
9
|
+
t.type({
|
|
10
|
+
type: exports.LabelSpanType,
|
|
11
|
+
data: t.strict({
|
|
12
|
+
label: t.string,
|
|
13
|
+
}),
|
|
14
|
+
}),
|
|
15
|
+
SpanLocation_1.SpanLocation,
|
|
16
|
+
]));
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SpanLocation = 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
|
+
exports.SpanLocation = t.type({
|
|
8
|
+
start: validators_1.Number,
|
|
9
|
+
end: validators_1.Number,
|
|
10
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import * as t from "io-ts";
|
|
2
|
+
export declare const TextSpanType: t.KeyofC<{
|
|
3
|
+
strong: null;
|
|
4
|
+
em: null;
|
|
5
|
+
}>;
|
|
6
|
+
export declare const TextSpan: t.ExactC<t.IntersectionC<[t.TypeC<{
|
|
7
|
+
type: t.KeyofC<{
|
|
8
|
+
strong: null;
|
|
9
|
+
em: null;
|
|
10
|
+
}>;
|
|
11
|
+
}>, t.TypeC<{
|
|
12
|
+
start: t.NumberC;
|
|
13
|
+
end: t.NumberC;
|
|
14
|
+
}>]>>;
|
|
15
|
+
export declare type TextSpan = t.TypeOf<typeof TextSpan>;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TextSpan = exports.TextSpanType = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const t = (0, tslib_1.__importStar)(require("io-ts"));
|
|
6
|
+
const SpanLocation_1 = require("./SpanLocation");
|
|
7
|
+
const TextSpanTypes = {
|
|
8
|
+
Strong: "strong",
|
|
9
|
+
Em: "em",
|
|
10
|
+
};
|
|
11
|
+
exports.TextSpanType = t.keyof({
|
|
12
|
+
[TextSpanTypes.Strong]: null,
|
|
13
|
+
[TextSpanTypes.Em]: null,
|
|
14
|
+
});
|
|
15
|
+
exports.TextSpan = t.exact(t.intersection([
|
|
16
|
+
t.type({
|
|
17
|
+
type: exports.TextSpanType,
|
|
18
|
+
}),
|
|
19
|
+
SpanLocation_1.SpanLocation,
|
|
20
|
+
]));
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ImportRichText = exports.ImportBlock = void 0;
|
|
4
|
+
var ImportBlock_1 = require("./ImportBlock");
|
|
5
|
+
Object.defineProperty(exports, "ImportBlock", { enumerable: true, get: function () { return ImportBlock_1.ImportBlock; } });
|
|
6
|
+
var ImportRichText_1 = require("./ImportRichText");
|
|
7
|
+
Object.defineProperty(exports, "ImportRichText", { enumerable: true, get: function () { return ImportRichText_1.ImportRichText; } });
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { TypeOf } from "io-ts";
|
|
2
|
+
import * as t from "io-ts";
|
|
3
|
+
declare const WebLink: t.ExactC<t.IntersectionC<[t.TypeC<{
|
|
4
|
+
link_type: t.LiteralC<"Web">;
|
|
5
|
+
url: t.StringC;
|
|
6
|
+
}>, t.PartialC<{
|
|
7
|
+
target: t.StringC;
|
|
8
|
+
}>]>>;
|
|
9
|
+
export declare type WebLink = t.TypeOf<typeof WebLink>;
|
|
10
|
+
declare const DocumentLink: t.ExactC<t.TypeC<{
|
|
11
|
+
link_type: t.LiteralC<"Document">;
|
|
12
|
+
id: t.Type<string, string, unknown>;
|
|
13
|
+
}>>;
|
|
14
|
+
export declare type DocumentLink = t.TypeOf<typeof DocumentLink>;
|
|
15
|
+
declare const MediaLink: t.ExactC<t.TypeC<{
|
|
16
|
+
link_type: t.LiteralC<"Media">;
|
|
17
|
+
id: t.StringC;
|
|
18
|
+
}>>;
|
|
19
|
+
export declare type MediaLink = t.TypeOf<typeof MediaLink>;
|
|
20
|
+
export declare const Link: t.Type<({
|
|
21
|
+
link_type: "Web";
|
|
22
|
+
url: string;
|
|
23
|
+
} & {
|
|
24
|
+
target?: string;
|
|
25
|
+
}) | {
|
|
26
|
+
link_type: "Document";
|
|
27
|
+
id: string;
|
|
28
|
+
} | {
|
|
29
|
+
link_type: "Media";
|
|
30
|
+
id: string;
|
|
31
|
+
}, {
|
|
32
|
+
link_type: "Document" | "Web" | "Media";
|
|
33
|
+
}, unknown>;
|
|
34
|
+
export declare type Link = TypeOf<typeof Link>;
|
|
35
|
+
export declare const ImportLink: t.Type<{
|
|
36
|
+
type: "Link";
|
|
37
|
+
value: ({
|
|
38
|
+
link_type: "Web";
|
|
39
|
+
url: string;
|
|
40
|
+
} & {
|
|
41
|
+
target?: string;
|
|
42
|
+
}) | {
|
|
43
|
+
link_type: "Document";
|
|
44
|
+
id: string;
|
|
45
|
+
} | {
|
|
46
|
+
link_type: "Media";
|
|
47
|
+
id: string;
|
|
48
|
+
} | null;
|
|
49
|
+
}, {
|
|
50
|
+
link_type: "Document" | "Web" | "Media";
|
|
51
|
+
} | undefined, unknown>;
|
|
52
|
+
export declare type ImportLink = TypeOf<typeof ImportLink>;
|
|
53
|
+
export {};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ImportLink = exports.Link = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const t = (0, tslib_1.__importStar)(require("io-ts"));
|
|
6
|
+
const DocumentId_1 = require("../../../../utils/DocumentId");
|
|
7
|
+
const validators_1 = require("../../../../validators");
|
|
8
|
+
const function_1 = require("../../../../validators/function");
|
|
9
|
+
const ImportContent_1 = require("../ImportContent");
|
|
10
|
+
const LinkTypeValidator = t.type({
|
|
11
|
+
link_type: (0, function_1.withCustomError)(t.union([t.literal("Web"), t.literal("Document"), t.literal("Media")]), () => "The value must be `Web`, `Document` or `Media`"),
|
|
12
|
+
});
|
|
13
|
+
const WebLink = t.exact(t.intersection([
|
|
14
|
+
t.type({
|
|
15
|
+
link_type: t.literal("Web"),
|
|
16
|
+
url: validators_1.String,
|
|
17
|
+
}),
|
|
18
|
+
t.partial({
|
|
19
|
+
target: validators_1.String,
|
|
20
|
+
}),
|
|
21
|
+
]));
|
|
22
|
+
const DocumentLink = t.strict({
|
|
23
|
+
link_type: t.literal("Document"),
|
|
24
|
+
id: DocumentId_1.DocumentId,
|
|
25
|
+
});
|
|
26
|
+
const MediaLink = t.strict({
|
|
27
|
+
link_type: t.literal("Media"),
|
|
28
|
+
id: validators_1.String,
|
|
29
|
+
});
|
|
30
|
+
exports.Link = LinkTypeValidator.pipe(t.union([WebLink, DocumentLink, MediaLink]));
|
|
31
|
+
// This is the default value for the link
|
|
32
|
+
const AnyLink = t.strict({
|
|
33
|
+
link_type: t.literal("Any"),
|
|
34
|
+
});
|
|
35
|
+
exports.ImportLink = (0, ImportContent_1.ImportContent)("Link", (0, validators_1.DefaultOrElse)(AnyLink)(exports.Link));
|