@prismicio/types-internal 2.2.0-alpha.2 → 2.2.0-alpha.21
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/common/Asset.d.ts +16 -0
- package/lib/common/Asset.js +11 -0
- package/lib/common/Embed.d.ts +15 -0
- package/lib/common/Embed.js +10 -0
- package/lib/common/UUID.d.ts +7 -0
- package/lib/common/UUID.js +8 -0
- package/lib/common/index.d.ts +2 -0
- package/lib/common/index.js +2 -0
- package/lib/content/Document.d.ts +40 -40
- package/lib/content/fields/GroupContent.d.ts +12 -12
- package/lib/content/fields/WidgetContent.d.ts +56 -56
- package/lib/content/fields/nestable/NestableContent.d.ts +7 -7
- package/lib/content/fields/nestable/RichTextContent/Blocks.d.ts +35 -12
- package/lib/content/fields/nestable/RichTextContent/Blocks.js +5 -5
- package/lib/content/fields/nestable/RichTextContent/index.d.ts +9 -9
- package/lib/content/fields/slices/Slice/CompositeSliceContent.d.ts +14 -14
- package/lib/content/fields/slices/Slice/RepeatableContent.d.ts +5 -5
- package/lib/content/fields/slices/Slice/RepeatableContent.js +0 -1
- package/lib/content/fields/slices/Slice/SharedSliceContent.d.ts +14 -14
- package/lib/content/fields/slices/Slice/SimpleSliceContent.d.ts +14 -14
- package/lib/content/fields/slices/Slice/index.d.ts +30 -30
- package/lib/content/fields/slices/SliceItem.d.ts +30 -30
- package/lib/content/fields/slices/SlicesContent.d.ts +42 -42
- package/lib/customtypes/CustomType.d.ts +2 -0
- package/lib/customtypes/CustomType.js +8 -1
- package/lib/import/converters/Document.d.ts +2 -2
- package/lib/import/converters/Document.js +6 -6
- 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 +58 -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 +1 -1
- package/lib/import/converters/fields/UID.js +0 -2
- package/lib/import/converters/fields/index.d.ts +1 -0
- package/lib/import/converters/fields/index.js +1 -0
- package/lib/import/converters/fields/nestable/Embed.d.ts +2 -1
- package/lib/import/converters/fields/nestable/Embed.js +24 -5
- 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/GeooPoint.d.ts +3 -0
- package/lib/import/converters/fields/nestable/GeooPoint.js +15 -0
- package/lib/import/converters/fields/nestable/Image.d.ts +6 -18
- package/lib/import/converters/fields/nestable/Image.js +47 -24
- package/lib/import/converters/fields/nestable/Link.d.ts +3 -2
- package/lib/import/converters/fields/nestable/Link.js +62 -11
- package/lib/import/converters/fields/nestable/Nestable.d.ts +4 -3
- package/lib/import/converters/fields/nestable/Nestable.js +9 -3
- 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 +34 -0
- package/lib/import/converters/fields/nestable/RichText.d.ts +4 -0
- package/lib/import/converters/fields/nestable/RichText.js +55 -0
- package/lib/import/converters/fields/nestable/index.d.ts +3 -0
- package/lib/import/converters/fields/nestable/index.js +3 -0
- package/lib/import/validators/Document.js +4 -9
- package/lib/import/validators/fields/ImportField.d.ts +68 -68
- package/lib/import/validators/fields/ImportField.js +8 -4
- package/lib/import/validators/fields/ImportSlices/ImportSlices.d.ts +8 -0
- package/lib/import/validators/fields/ImportSlices/ImportSlices.js +29 -0
- package/lib/import/validators/fields/ImportSlices/SharedSlice/SharedSlice.d.ts +14 -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/SharedSliceContent/SharedSliceContent.d.ts +17 -0
- package/lib/import/validators/fields/ImportSlices/SharedSlice/fields/SharedSliceContent/SharedSliceContent.js +30 -0
- package/lib/import/validators/fields/ImportSlices/SharedSlice/fields/SharedSliceContent/SharedSliceContentEntry.d.ts +43 -0
- package/lib/import/validators/fields/ImportSlices/SharedSlice/fields/SharedSliceContent/SharedSliceContentEntry.js +69 -0
- package/lib/import/validators/fields/ImportSlices/SharedSlice/fields/SharedSliceContent/errors.d.ts +4 -0
- package/lib/import/validators/fields/ImportSlices/SharedSlice/fields/SharedSliceContent/errors.js +6 -0
- package/lib/import/validators/fields/ImportSlices/SharedSlice/fields/SharedSliceContent/index.d.ts +2 -0
- package/lib/import/validators/fields/ImportSlices/SharedSlice/fields/SharedSliceContent/index.js +5 -0
- package/lib/import/validators/fields/ImportSlices/SharedSlice/fields/SharedSliceContent/types.d.ts +1 -0
- package/lib/import/validators/fields/ImportSlices/SharedSlice/fields/SharedSliceContent/types.js +2 -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 +5 -0
- package/lib/import/validators/fields/ImportSlices/SharedSlice/fields/index.js +8 -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 +339 -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/UID.d.ts +2 -2
- package/lib/import/validators/fields/UID.js +1 -1
- package/lib/import/validators/fields/nestable/Embed.d.ts +8 -22
- package/lib/import/validators/fields/nestable/Embed.js +5 -28
- 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 +45 -0
- package/lib/import/validators/fields/nestable/Image/index.js +41 -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 +35 -0
- package/lib/import/validators/fields/nestable/Image/validators.js +31 -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 +26 -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 +8 -0
- package/lib/import/validators/fields/nestable/ImportRichText/blocks/ImportImageBlock.js +11 -0
- package/lib/import/validators/fields/nestable/ImportRichText/blocks/ImportTextBlock.d.ts +70 -0
- package/lib/import/validators/fields/nestable/ImportRichText/blocks/ImportTextBlock.js +43 -0
- package/lib/import/validators/fields/nestable/ImportRichText/blocks/Span.d.ts +65 -0
- package/lib/import/validators/fields/nestable/ImportRichText/blocks/Span.js +20 -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/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 +17 -0
- package/lib/import/validators/fields/nestable/ImportRichText/blocks/spans/TextSpan.js +22 -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 +33 -0
- package/lib/import/validators/fields/nestable/Link.js +16 -11
- package/lib/import/validators/fields/nestable/Nestable.d.ts +65 -62
- package/lib/import/validators/fields/nestable/Nestable.js +18 -6
- package/lib/import/validators/fields/nestable/index.d.ts +5 -1
- package/lib/import/validators/fields/nestable/index.js +7 -1
- package/lib/utils/DocumentId.d.ts +2 -0
- package/lib/utils/DocumentId.js +7 -0
- package/lib/utils/Objects.d.ts +1 -1
- package/lib/utils/Objects.js +1 -1
- package/lib/utils/io-ts.d.ts +2 -0
- package/lib/utils/io-ts.js +22 -0
- package/lib/validators/BasicTypes.d.ts +0 -1
- package/lib/validators/BasicTypes.js +7 -8
- package/lib/validators/DefaultOrElse.js +1 -1
- package/lib/validators/NonEmptyString.js +1 -1
- package/lib/validators/NumberRange.d.ts +32 -0
- package/lib/validators/NumberRange.js +40 -0
- package/lib/validators/function.d.ts +20 -0
- package/lib/validators/function.js +41 -1
- package/lib/validators/index.d.ts +1 -0
- package/lib/validators/index.js +3 -1
- package/package.json +4 -2
- package/src/common/Asset.ts +25 -0
- package/src/common/Embed.ts +22 -0
- package/src/common/UUID.ts +19 -0
- package/src/common/index.ts +2 -0
- package/src/content/fields/nestable/RichTextContent/Blocks.ts +1 -1
- package/src/content/fields/slices/Slice/RepeatableContent.ts +0 -1
- package/src/customtypes/CustomType.ts +13 -0
- package/src/import/converters/Document.ts +10 -7
- package/src/import/converters/fields/Slices/SharedSlice.ts +24 -0
- package/src/import/converters/fields/Slices/SharedSliceContent.ts +94 -0
- package/src/import/converters/fields/Slices/Slices.ts +20 -0
- package/src/import/converters/fields/Slices/index.ts +1 -0
- package/src/import/converters/fields/UID.ts +1 -5
- package/src/import/converters/fields/index.ts +1 -0
- package/src/import/converters/fields/nestable/Embed.ts +29 -7
- package/src/import/converters/fields/nestable/GeoPoint.ts +16 -0
- package/src/import/converters/fields/nestable/Image.ts +69 -44
- package/src/import/converters/fields/nestable/Link.ts +77 -0
- package/src/import/converters/fields/nestable/Nestable.ts +17 -6
- package/src/import/converters/fields/nestable/RichText/embedBlock.ts +14 -0
- package/src/import/converters/fields/nestable/RichText/imageBlock.ts +14 -0
- package/src/import/converters/fields/nestable/RichText/index.ts +23 -0
- package/src/import/converters/fields/nestable/RichText/textBlock.ts +35 -0
- package/src/import/converters/fields/nestable/index.ts +3 -0
- package/src/import/validators/Document.ts +4 -12
- package/src/import/validators/fields/ImportField.ts +12 -6
- package/src/import/validators/fields/ImportSlices/ImportSlices.ts +54 -0
- package/src/import/validators/fields/ImportSlices/SharedSlice/SharedSlice.ts +116 -0
- package/src/import/validators/fields/ImportSlices/SharedSlice/errors.ts +6 -0
- package/src/import/validators/fields/ImportSlices/SharedSlice/fields/OptionalSharedSliceId.ts +20 -0
- package/src/import/validators/fields/ImportSlices/SharedSlice/fields/SharedSliceContent/SharedSliceContent.ts +64 -0
- package/src/import/validators/fields/ImportSlices/SharedSlice/fields/SharedSliceContent/SharedSliceContentEntry.ts +100 -0
- package/src/import/validators/fields/ImportSlices/SharedSlice/fields/SharedSliceContent/errors.ts +10 -0
- package/src/import/validators/fields/ImportSlices/SharedSlice/fields/SharedSliceContent/index.ts +2 -0
- package/src/import/validators/fields/ImportSlices/SharedSlice/fields/SharedSliceContent/types.ts +1 -0
- package/src/import/validators/fields/ImportSlices/SharedSlice/fields/SharedSliceId.ts +65 -0
- package/src/import/validators/fields/ImportSlices/SharedSlice/fields/SharedSliceType.ts +45 -0
- package/src/import/validators/fields/ImportSlices/SharedSlice/fields/SharedSliceVariation.ts +45 -0
- package/src/import/validators/fields/ImportSlices/SharedSlice/fields/index.ts +5 -0
- package/src/import/validators/fields/ImportSlices/SharedSlice/index.ts +3 -0
- package/src/import/validators/fields/ImportSlices/SharedSlice/utils.ts +21 -0
- package/src/import/validators/fields/ImportSlices/index.ts +1 -0
- package/src/import/validators/fields/ImportSlices/utils.ts +43 -0
- package/src/import/validators/fields/UID.ts +2 -2
- package/src/import/validators/fields/nestable/Embed.ts +6 -51
- package/src/import/validators/fields/nestable/GeoPoint.ts +21 -0
- package/src/import/validators/fields/nestable/Image/default.ts +25 -0
- package/src/import/validators/fields/nestable/Image/index.ts +73 -0
- package/src/import/validators/fields/nestable/Image/merge.ts +64 -0
- package/src/import/validators/fields/nestable/Image/model.ts +18 -0
- package/src/import/validators/fields/nestable/Image/validators.ts +45 -0
- package/src/import/validators/fields/nestable/ImportRichText/ImportBlock.ts +39 -0
- package/src/import/validators/fields/nestable/ImportRichText/ImportRichText.ts +41 -0
- package/src/import/validators/fields/nestable/ImportRichText/blocks/ImportBlockType.ts +44 -0
- package/src/import/validators/fields/nestable/ImportRichText/blocks/ImportEmbedBlock.ts +13 -0
- package/src/import/validators/fields/nestable/ImportRichText/blocks/ImportImageBlock.ts +13 -0
- package/src/import/validators/fields/nestable/ImportRichText/blocks/ImportTextBlock.ts +56 -0
- package/src/import/validators/fields/nestable/ImportRichText/blocks/Span.ts +44 -0
- package/src/import/validators/fields/nestable/ImportRichText/blocks/index.ts +4 -0
- package/src/import/validators/fields/nestable/ImportRichText/blocks/spans/HyperlinkSpan.ts +24 -0
- package/src/import/validators/fields/nestable/ImportRichText/blocks/spans/SpanLocation.ts +8 -0
- package/src/import/validators/fields/nestable/ImportRichText/blocks/spans/TextSpan.ts +26 -0
- package/src/import/validators/fields/nestable/ImportRichText/blocks/spans/index.ts +2 -0
- package/src/import/validators/fields/nestable/ImportRichText/index.ts +2 -0
- package/src/import/validators/fields/nestable/Link.ts +59 -0
- package/src/import/validators/fields/nestable/Nestable.ts +19 -4
- package/src/import/validators/fields/nestable/index.ts +5 -1
- package/src/utils/DocumentId.ts +8 -0
- package/src/utils/Objects.ts +2 -2
- package/src/utils/io-ts.ts +29 -0
- package/src/validators/BasicTypes.ts +13 -11
- package/src/validators/DefaultOrElse.ts +1 -1
- package/src/validators/NonEmptyString.ts +4 -5
- package/src/validators/NumberRange.ts +51 -0
- package/src/validators/function.ts +44 -0
- package/src/validators/index.ts +1 -0
- package/lib/import/validators/fields/nestable/Image.d.ts +0 -24
- package/lib/import/validators/fields/nestable/Image.js +0 -45
- package/src/import/validators/fields/nestable/Image.ts +0 -90
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SharedSliceType = 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 customtypes_1 = require("../../../../../../customtypes");
|
|
9
|
+
const validators_1 = require("../../../../../../validators");
|
|
10
|
+
const utils_1 = require("../utils");
|
|
11
|
+
/**
|
|
12
|
+
* slice_type - the validated slice_type
|
|
13
|
+
* slice - SharedSlice custom type data matching the slice_type. We return it alongside the validated slice_type, because it is needed to decode the 'variation' field in the SharedSlice (see SharedSliceVariation.ts)
|
|
14
|
+
*/
|
|
15
|
+
const SharedSliceTypeShape = t.strict({
|
|
16
|
+
slice_type: validators_1.NonEmptyString,
|
|
17
|
+
slice: customtypes_1.SharedSlice,
|
|
18
|
+
});
|
|
19
|
+
/**
|
|
20
|
+
* Builds the decoder for the 'slice_type' field in the SharedSlice. Alongside the decoded 'slice_type' it also returns the SharedSlice data matching the slice_type.
|
|
21
|
+
* @param slices all the SharedSlices from the custom type
|
|
22
|
+
*/
|
|
23
|
+
const SharedSliceType = (slices) => new t.Type("slice_type", (u) => SharedSliceTypeShape.is(u), (u, c) => (0, function_1.pipe)(validators_1.NonEmptyString.validate(u, c), E.chain((slice_type) => (0, function_1.pipe)((0, utils_1.findSlice)(slices)(slice_type), E.fold((err) => t.failure(u, c, err), (data) => t.success({ slice_type, data }))))), ({ slice_type }) => slice_type);
|
|
24
|
+
exports.SharedSliceType = SharedSliceType;
|
package/lib/import/validators/fields/ImportSlices/SharedSlice/fields/SharedSliceVariation.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import * as t from "io-ts";
|
|
2
|
+
import { SharedSlice, Variation } from "../../../../../../customtypes";
|
|
3
|
+
export declare type SharedSliceVariation = {
|
|
4
|
+
variation: string;
|
|
5
|
+
data: Variation;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* Builds the decoder for the 'variation' field in the SharedSlice. Alongside the decoded 'variation' it also returns the Variation data matching the variation custom type.
|
|
9
|
+
* @param slice SharedSlice from the custom type
|
|
10
|
+
*/
|
|
11
|
+
export declare const SharedSliceVariation: (slice: SharedSlice) => t.Type<SharedSliceVariation, string, unknown>;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SharedSliceVariation = 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 customtypes_1 = require("../../../../../../customtypes");
|
|
9
|
+
const validators_1 = require("../../../../../../validators");
|
|
10
|
+
const utils_1 = require("../utils");
|
|
11
|
+
/**
|
|
12
|
+
* variation - the validated variation of the slice
|
|
13
|
+
* data - Variation data matching the variation. We return it alongside the validated variation, because it is needed to decode the 'primary' and 'items' fields in the SharedSlice.
|
|
14
|
+
*/
|
|
15
|
+
const SharedSliceVariationShape = t.strict({
|
|
16
|
+
variation: validators_1.NonEmptyString,
|
|
17
|
+
data: customtypes_1.Variation,
|
|
18
|
+
});
|
|
19
|
+
/**
|
|
20
|
+
* Builds the decoder for the 'variation' field in the SharedSlice. Alongside the decoded 'variation' it also returns the Variation data matching the variation custom type.
|
|
21
|
+
* @param slice SharedSlice from the custom type
|
|
22
|
+
*/
|
|
23
|
+
const SharedSliceVariation = (slice) => new t.Type("variation", (u) => SharedSliceVariationShape.is(u), (u, c) => (0, function_1.pipe)(validators_1.NonEmptyString.validate(u, c), E.chain((variation) => (0, function_1.pipe)((0, utils_1.findSliceVariation)(slice)(variation), E.fold((err) => t.failure(u, c, err), (data) => t.success({ variation, data }))))), ({ variation }) => variation);
|
|
24
|
+
exports.SharedSliceVariation = SharedSliceVariation;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
(0, tslib_1.__exportStar)(require("./OptionalSharedSliceId"), exports);
|
|
5
|
+
(0, tslib_1.__exportStar)(require("./SharedSliceContent"), exports);
|
|
6
|
+
(0, tslib_1.__exportStar)(require("./SharedSliceId"), exports);
|
|
7
|
+
(0, tslib_1.__exportStar)(require("./SharedSliceType"), exports);
|
|
8
|
+
(0, tslib_1.__exportStar)(require("./SharedSliceVariation"), exports);
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
(0, tslib_1.__exportStar)(require("./errors"), exports);
|
|
5
|
+
(0, tslib_1.__exportStar)(require("./fields"), exports);
|
|
6
|
+
(0, tslib_1.__exportStar)(require("./SharedSlice"), exports);
|
|
@@ -0,0 +1,339 @@
|
|
|
1
|
+
import * as E from "fp-ts/Either";
|
|
2
|
+
import type { SharedSlice as SharedSliceCustomType } from "../../../../../customtypes";
|
|
3
|
+
import type { Variation } from "../../../../../customtypes";
|
|
4
|
+
export declare const findSlice: (slices: SharedSliceCustomType[]) => (sliceId: string) => E.Either<string, {
|
|
5
|
+
id: string;
|
|
6
|
+
type: "SharedSlice";
|
|
7
|
+
name: string;
|
|
8
|
+
variations: readonly ({
|
|
9
|
+
id: string;
|
|
10
|
+
name: string;
|
|
11
|
+
description: string;
|
|
12
|
+
imageUrl: string;
|
|
13
|
+
docURL: string;
|
|
14
|
+
version: string;
|
|
15
|
+
} & {
|
|
16
|
+
display?: string;
|
|
17
|
+
primary?: {
|
|
18
|
+
[x: string]: ({
|
|
19
|
+
type: "Boolean";
|
|
20
|
+
} & {
|
|
21
|
+
config?: {
|
|
22
|
+
label?: string | null | undefined;
|
|
23
|
+
default_value?: boolean;
|
|
24
|
+
placeholder_true?: string;
|
|
25
|
+
placeholder_false?: string;
|
|
26
|
+
};
|
|
27
|
+
}) | ({
|
|
28
|
+
type: "Color";
|
|
29
|
+
} & {
|
|
30
|
+
fieldset?: string | null | undefined;
|
|
31
|
+
config?: {
|
|
32
|
+
label?: string | null | undefined;
|
|
33
|
+
placeholder?: string;
|
|
34
|
+
};
|
|
35
|
+
}) | ({
|
|
36
|
+
type: "Date";
|
|
37
|
+
} & {
|
|
38
|
+
fieldset?: string | null | undefined;
|
|
39
|
+
config?: {
|
|
40
|
+
label?: string | null | undefined;
|
|
41
|
+
placeholder?: string;
|
|
42
|
+
default?: string;
|
|
43
|
+
};
|
|
44
|
+
}) | ({
|
|
45
|
+
type: "Embed";
|
|
46
|
+
} & {
|
|
47
|
+
fieldset?: string | null | undefined;
|
|
48
|
+
config?: {
|
|
49
|
+
label?: string | null | undefined;
|
|
50
|
+
placeholder?: string;
|
|
51
|
+
useAsTitle?: boolean;
|
|
52
|
+
};
|
|
53
|
+
}) | ({
|
|
54
|
+
type: "GeoPoint";
|
|
55
|
+
} & {
|
|
56
|
+
fieldset?: string | null | undefined;
|
|
57
|
+
config?: {
|
|
58
|
+
label?: string | null | undefined;
|
|
59
|
+
};
|
|
60
|
+
}) | ({
|
|
61
|
+
type: "Image";
|
|
62
|
+
} & {
|
|
63
|
+
fieldset?: string | null | undefined;
|
|
64
|
+
config?: {
|
|
65
|
+
label?: string | null | undefined;
|
|
66
|
+
placeholder?: string;
|
|
67
|
+
constraint?: {
|
|
68
|
+
width?: number | null;
|
|
69
|
+
height?: number | null;
|
|
70
|
+
};
|
|
71
|
+
thumbnails?: readonly ({
|
|
72
|
+
name: string;
|
|
73
|
+
} & {
|
|
74
|
+
width?: number | null;
|
|
75
|
+
height?: number | null;
|
|
76
|
+
})[];
|
|
77
|
+
};
|
|
78
|
+
}) | ({
|
|
79
|
+
type: "IntegrationFields";
|
|
80
|
+
} & {
|
|
81
|
+
fieldset?: string | null | undefined;
|
|
82
|
+
config?: {
|
|
83
|
+
label?: string | null | undefined;
|
|
84
|
+
placeholder?: string;
|
|
85
|
+
catalog?: string;
|
|
86
|
+
};
|
|
87
|
+
}) | ({
|
|
88
|
+
type: "Link";
|
|
89
|
+
} & {
|
|
90
|
+
fieldset?: string | null | undefined;
|
|
91
|
+
config?: {
|
|
92
|
+
label?: string | null | undefined;
|
|
93
|
+
useAsTitle?: boolean;
|
|
94
|
+
placeholder?: string;
|
|
95
|
+
select?: "media" | "document" | "web" | null;
|
|
96
|
+
customtypes?: readonly string[];
|
|
97
|
+
masks?: readonly string[];
|
|
98
|
+
tags?: readonly string[];
|
|
99
|
+
allowTargetBlank?: boolean;
|
|
100
|
+
};
|
|
101
|
+
}) | ({
|
|
102
|
+
type: "Number";
|
|
103
|
+
} & {
|
|
104
|
+
fieldset?: string | null | undefined;
|
|
105
|
+
config?: {
|
|
106
|
+
label?: string | null | undefined;
|
|
107
|
+
placeholder?: string;
|
|
108
|
+
min?: number;
|
|
109
|
+
max?: number;
|
|
110
|
+
step?: number;
|
|
111
|
+
};
|
|
112
|
+
}) | ({
|
|
113
|
+
type: "Range";
|
|
114
|
+
} & {
|
|
115
|
+
fieldset?: string | null | undefined;
|
|
116
|
+
config?: {
|
|
117
|
+
label?: string | null | undefined;
|
|
118
|
+
placeholder?: string;
|
|
119
|
+
min?: number;
|
|
120
|
+
max?: number;
|
|
121
|
+
step?: number;
|
|
122
|
+
};
|
|
123
|
+
}) | ({
|
|
124
|
+
type: "StructuredText";
|
|
125
|
+
} & {
|
|
126
|
+
fieldset?: string | null | undefined;
|
|
127
|
+
config?: {
|
|
128
|
+
label?: string | null | undefined;
|
|
129
|
+
placeholder?: string;
|
|
130
|
+
useAsTitle?: boolean;
|
|
131
|
+
single?: string;
|
|
132
|
+
multi?: string;
|
|
133
|
+
imageConstraint?: {
|
|
134
|
+
width?: number | null;
|
|
135
|
+
height?: number | null;
|
|
136
|
+
};
|
|
137
|
+
labels?: readonly string[];
|
|
138
|
+
allowTargetBlank?: boolean;
|
|
139
|
+
};
|
|
140
|
+
}) | ({
|
|
141
|
+
type: "Select";
|
|
142
|
+
} & {
|
|
143
|
+
fieldset?: string | null | undefined;
|
|
144
|
+
config?: {
|
|
145
|
+
label?: string | null | undefined;
|
|
146
|
+
placeholder?: string;
|
|
147
|
+
default_value?: string;
|
|
148
|
+
options?: readonly string[];
|
|
149
|
+
};
|
|
150
|
+
}) | ({
|
|
151
|
+
type: "Separator";
|
|
152
|
+
} & {
|
|
153
|
+
config?: {
|
|
154
|
+
label?: string | null | undefined;
|
|
155
|
+
};
|
|
156
|
+
}) | ({
|
|
157
|
+
type: "Text";
|
|
158
|
+
} & {
|
|
159
|
+
fieldset?: string | null | undefined;
|
|
160
|
+
config?: {
|
|
161
|
+
label?: string | null | undefined;
|
|
162
|
+
useAsTitle?: boolean;
|
|
163
|
+
placeholder?: string;
|
|
164
|
+
};
|
|
165
|
+
}) | ({
|
|
166
|
+
type: "Timestamp";
|
|
167
|
+
} & {
|
|
168
|
+
fieldset?: string | null | undefined;
|
|
169
|
+
config?: {
|
|
170
|
+
label?: string | null | undefined;
|
|
171
|
+
placeholder?: string;
|
|
172
|
+
default?: string;
|
|
173
|
+
};
|
|
174
|
+
});
|
|
175
|
+
};
|
|
176
|
+
items?: {
|
|
177
|
+
[x: string]: ({
|
|
178
|
+
type: "Boolean";
|
|
179
|
+
} & {
|
|
180
|
+
config?: {
|
|
181
|
+
label?: string | null | undefined;
|
|
182
|
+
default_value?: boolean;
|
|
183
|
+
placeholder_true?: string;
|
|
184
|
+
placeholder_false?: string;
|
|
185
|
+
};
|
|
186
|
+
}) | ({
|
|
187
|
+
type: "Color";
|
|
188
|
+
} & {
|
|
189
|
+
fieldset?: string | null | undefined;
|
|
190
|
+
config?: {
|
|
191
|
+
label?: string | null | undefined;
|
|
192
|
+
placeholder?: string;
|
|
193
|
+
};
|
|
194
|
+
}) | ({
|
|
195
|
+
type: "Date";
|
|
196
|
+
} & {
|
|
197
|
+
fieldset?: string | null | undefined;
|
|
198
|
+
config?: {
|
|
199
|
+
label?: string | null | undefined;
|
|
200
|
+
placeholder?: string;
|
|
201
|
+
default?: string;
|
|
202
|
+
};
|
|
203
|
+
}) | ({
|
|
204
|
+
type: "Embed";
|
|
205
|
+
} & {
|
|
206
|
+
fieldset?: string | null | undefined;
|
|
207
|
+
config?: {
|
|
208
|
+
label?: string | null | undefined;
|
|
209
|
+
placeholder?: string;
|
|
210
|
+
useAsTitle?: boolean;
|
|
211
|
+
};
|
|
212
|
+
}) | ({
|
|
213
|
+
type: "GeoPoint";
|
|
214
|
+
} & {
|
|
215
|
+
fieldset?: string | null | undefined;
|
|
216
|
+
config?: {
|
|
217
|
+
label?: string | null | undefined;
|
|
218
|
+
};
|
|
219
|
+
}) | ({
|
|
220
|
+
type: "Image";
|
|
221
|
+
} & {
|
|
222
|
+
fieldset?: string | null | undefined;
|
|
223
|
+
config?: {
|
|
224
|
+
label?: string | null | undefined;
|
|
225
|
+
placeholder?: string;
|
|
226
|
+
constraint?: {
|
|
227
|
+
width?: number | null;
|
|
228
|
+
height?: number | null;
|
|
229
|
+
};
|
|
230
|
+
thumbnails?: readonly ({
|
|
231
|
+
name: string;
|
|
232
|
+
} & {
|
|
233
|
+
width?: number | null;
|
|
234
|
+
height?: number | null;
|
|
235
|
+
})[];
|
|
236
|
+
};
|
|
237
|
+
}) | ({
|
|
238
|
+
type: "IntegrationFields";
|
|
239
|
+
} & {
|
|
240
|
+
fieldset?: string | null | undefined;
|
|
241
|
+
config?: {
|
|
242
|
+
label?: string | null | undefined;
|
|
243
|
+
placeholder?: string;
|
|
244
|
+
catalog?: string;
|
|
245
|
+
};
|
|
246
|
+
}) | ({
|
|
247
|
+
type: "Link";
|
|
248
|
+
} & {
|
|
249
|
+
fieldset?: string | null | undefined;
|
|
250
|
+
config?: {
|
|
251
|
+
label?: string | null | undefined;
|
|
252
|
+
useAsTitle?: boolean;
|
|
253
|
+
placeholder?: string;
|
|
254
|
+
select?: "media" | "document" | "web" | null;
|
|
255
|
+
customtypes?: readonly string[];
|
|
256
|
+
masks?: readonly string[];
|
|
257
|
+
tags?: readonly string[];
|
|
258
|
+
allowTargetBlank?: boolean;
|
|
259
|
+
};
|
|
260
|
+
}) | ({
|
|
261
|
+
type: "Number";
|
|
262
|
+
} & {
|
|
263
|
+
fieldset?: string | null | undefined;
|
|
264
|
+
config?: {
|
|
265
|
+
label?: string | null | undefined;
|
|
266
|
+
placeholder?: string;
|
|
267
|
+
min?: number;
|
|
268
|
+
max?: number;
|
|
269
|
+
step?: number;
|
|
270
|
+
};
|
|
271
|
+
}) | ({
|
|
272
|
+
type: "Range";
|
|
273
|
+
} & {
|
|
274
|
+
fieldset?: string | null | undefined;
|
|
275
|
+
config?: {
|
|
276
|
+
label?: string | null | undefined;
|
|
277
|
+
placeholder?: string;
|
|
278
|
+
min?: number;
|
|
279
|
+
max?: number;
|
|
280
|
+
step?: number;
|
|
281
|
+
};
|
|
282
|
+
}) | ({
|
|
283
|
+
type: "StructuredText";
|
|
284
|
+
} & {
|
|
285
|
+
fieldset?: string | null | undefined;
|
|
286
|
+
config?: {
|
|
287
|
+
label?: string | null | undefined;
|
|
288
|
+
placeholder?: string;
|
|
289
|
+
useAsTitle?: boolean;
|
|
290
|
+
single?: string;
|
|
291
|
+
multi?: string;
|
|
292
|
+
imageConstraint?: {
|
|
293
|
+
width?: number | null;
|
|
294
|
+
height?: number | null;
|
|
295
|
+
};
|
|
296
|
+
labels?: readonly string[];
|
|
297
|
+
allowTargetBlank?: boolean;
|
|
298
|
+
};
|
|
299
|
+
}) | ({
|
|
300
|
+
type: "Select";
|
|
301
|
+
} & {
|
|
302
|
+
fieldset?: string | null | undefined;
|
|
303
|
+
config?: {
|
|
304
|
+
label?: string | null | undefined;
|
|
305
|
+
placeholder?: string;
|
|
306
|
+
default_value?: string;
|
|
307
|
+
options?: readonly string[];
|
|
308
|
+
};
|
|
309
|
+
}) | ({
|
|
310
|
+
type: "Separator";
|
|
311
|
+
} & {
|
|
312
|
+
config?: {
|
|
313
|
+
label?: string | null | undefined;
|
|
314
|
+
};
|
|
315
|
+
}) | ({
|
|
316
|
+
type: "Text";
|
|
317
|
+
} & {
|
|
318
|
+
fieldset?: string | null | undefined;
|
|
319
|
+
config?: {
|
|
320
|
+
label?: string | null | undefined;
|
|
321
|
+
useAsTitle?: boolean;
|
|
322
|
+
placeholder?: string;
|
|
323
|
+
};
|
|
324
|
+
}) | ({
|
|
325
|
+
type: "Timestamp";
|
|
326
|
+
} & {
|
|
327
|
+
fieldset?: string | null | undefined;
|
|
328
|
+
config?: {
|
|
329
|
+
label?: string | null | undefined;
|
|
330
|
+
placeholder?: string;
|
|
331
|
+
default?: string;
|
|
332
|
+
};
|
|
333
|
+
});
|
|
334
|
+
};
|
|
335
|
+
})[];
|
|
336
|
+
} & {
|
|
337
|
+
description?: string;
|
|
338
|
+
}>;
|
|
339
|
+
export declare const findSliceVariation: (slice: SharedSliceCustomType) => (variation: string) => E.Either<string, Variation>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.findSliceVariation = exports.findSlice = 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 errors_1 = require("./errors");
|
|
8
|
+
const findSlice = (slices) => (sliceId) => (0, function_1.pipe)(slices.find((slice) => slice.id === sliceId), E.fromNullable(errors_1.SharedSliceErrors.SliceTypeNotFound(sliceId)));
|
|
9
|
+
exports.findSlice = findSlice;
|
|
10
|
+
const findSliceVariation = (slice) => (variation) => (0, function_1.pipe)(slice.variations.find((v) => v.id === variation), E.fromNullable(errors_1.SharedSliceErrors.VariationNotFound(variation, slice.id)));
|
|
11
|
+
exports.findSliceVariation = findSliceVariation;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./ImportSlices";
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { SharedSlice as SharedSliceCustomType, StaticSlices } from "../../../../customtypes";
|
|
2
|
+
import type { SharedSlice, SharedSliceId } from "./SharedSlice";
|
|
3
|
+
export declare const extractSupportedSlices: (staticSlices: StaticSlices) => SharedSliceCustomType[];
|
|
4
|
+
export declare const findImportSharedSliceDuplicateIds: (slices: SharedSlice[]) => SharedSliceId[];
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.findImportSharedSliceDuplicateIds = exports.extractSupportedSlices = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const A = (0, tslib_1.__importStar)(require("fp-ts/Array"));
|
|
6
|
+
const function_1 = require("fp-ts/function");
|
|
7
|
+
const O = (0, tslib_1.__importStar)(require("fp-ts/Option"));
|
|
8
|
+
const customtypes_1 = require("../../../../customtypes");
|
|
9
|
+
// Extracts all supported slices from the static slices object
|
|
10
|
+
// For now we only support the SharedSlice, if we want to support other slices in the future, we have to add them here
|
|
11
|
+
const extractSupportedSlices = (staticSlices) => {
|
|
12
|
+
var _a, _b;
|
|
13
|
+
return (0, function_1.pipe)(Object.values((_b = (_a = staticSlices.config) === null || _a === void 0 ? void 0 : _a.choices) !== null && _b !== void 0 ? _b : {}).map((slice) => (0, function_1.pipe)(customtypes_1.SharedSlice.decode(slice), O.fromEither)), A.compact);
|
|
14
|
+
};
|
|
15
|
+
exports.extractSupportedSlices = extractSupportedSlices;
|
|
16
|
+
const findImportSharedSliceDuplicateIds = (slices) => {
|
|
17
|
+
const duplicatesMap = slices.reduce((acc, { id }) => {
|
|
18
|
+
var _a;
|
|
19
|
+
if (id) {
|
|
20
|
+
const currentNumOfDuplicates = (_a = acc[id]) !== null && _a !== void 0 ? _a : 0;
|
|
21
|
+
return {
|
|
22
|
+
...acc,
|
|
23
|
+
[id]: acc[id] === undefined ? 0 : currentNumOfDuplicates + 1,
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
return acc;
|
|
27
|
+
}, {});
|
|
28
|
+
return Object.entries(duplicatesMap).flatMap(([id, numOfDuplicates]) => {
|
|
29
|
+
if (numOfDuplicates > 0) {
|
|
30
|
+
return [id];
|
|
31
|
+
}
|
|
32
|
+
return [];
|
|
33
|
+
});
|
|
34
|
+
};
|
|
35
|
+
exports.findImportSharedSliceDuplicateIds = findImportSharedSliceDuplicateIds;
|
|
@@ -12,4 +12,4 @@ const uidValue = validators_1.String.pipe(new t.Type("ImportUIDField", (u) => va
|
|
|
12
12
|
}
|
|
13
13
|
return t.failure(n, c, "UID can only contain alphanumeric characters, dashes, underscores, and dots");
|
|
14
14
|
}, t.identity));
|
|
15
|
-
exports.ImportUID = (0, ImportContent_1.ImportContent)("UID",
|
|
15
|
+
exports.ImportUID = (0, ImportContent_1.ImportContent)("UID", uidValue);
|
|
@@ -1,27 +1,13 @@
|
|
|
1
1
|
import * as t from "io-ts";
|
|
2
|
-
declare const
|
|
2
|
+
export declare const ImportEmbedValue: t.ExactC<t.TypeC<{
|
|
3
3
|
embed_url: t.Type<string, string, unknown>;
|
|
4
|
-
|
|
5
|
-
}>, t.PartialC<{
|
|
6
|
-
version: t.UnionC<[t.StringC, t.NumberC, t.NullC]>;
|
|
7
|
-
title: t.StringC;
|
|
8
|
-
author_name: t.UnionC<[t.StringC, t.NullC]>;
|
|
9
|
-
author_url: t.UnionC<[t.StringC, t.NullC]>;
|
|
10
|
-
provider_name: t.UnionC<[t.StringC, t.NullC]>;
|
|
11
|
-
provider_url: t.UnionC<[t.StringC, t.NullC]>;
|
|
12
|
-
cache_age: t.UnionC<[t.StringC, t.NumberC, t.NullC]>;
|
|
13
|
-
thumbnail_url: t.UnionC<[t.StringC, t.NullC]>;
|
|
14
|
-
thumbnail_width: t.UnionC<[t.NumberC, t.NullC]>;
|
|
15
|
-
thumbnail_height: t.UnionC<[t.NumberC, t.NullC]>;
|
|
16
|
-
html: t.UnionC<[t.StringC, t.NullC]>;
|
|
17
|
-
}>]>>;
|
|
18
|
-
declare type EmbedProto = t.TypeOf<typeof EmbedProto>;
|
|
19
|
-
declare type Embed = EmbedProto & {
|
|
20
|
-
all: unknown;
|
|
21
|
-
};
|
|
4
|
+
}>>;
|
|
22
5
|
export declare const ImportEmbed: t.Type<{
|
|
23
6
|
type: "Embed";
|
|
24
|
-
value:
|
|
25
|
-
|
|
7
|
+
value: {
|
|
8
|
+
embed_url: string;
|
|
9
|
+
} | null;
|
|
10
|
+
}, {
|
|
11
|
+
embed_url: string;
|
|
12
|
+
} | undefined, unknown>;
|
|
26
13
|
export declare type ImportEmbed = t.TypeOf<typeof ImportEmbed>;
|
|
27
|
-
export {};
|
|
@@ -1,13 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ImportEmbed = void 0;
|
|
3
|
+
exports.ImportEmbed = exports.ImportEmbedValue = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const Either = (0, tslib_1.__importStar)(require("fp-ts/lib/Either"));
|
|
6
|
-
const function_1 = require("fp-ts/lib/function");
|
|
7
5
|
const t = (0, tslib_1.__importStar)(require("io-ts"));
|
|
8
|
-
const io_ts_types_1 = require("io-ts-types");
|
|
9
6
|
const validators_1 = require("../../../../validators");
|
|
10
|
-
const BasicTypes_1 = require("../../../../validators/BasicTypes");
|
|
11
7
|
const ImportContent_1 = require("../ImportContent");
|
|
12
8
|
function isValidHttpUrl(param) {
|
|
13
9
|
try {
|
|
@@ -29,26 +25,7 @@ const EmbedUrl = new t.Type("EmbedUrl", (u) => isValidHttpUrl(u), (u, c) => {
|
|
|
29
25
|
return t.failure(u, c, "The value must be a valid http/https url");
|
|
30
26
|
}
|
|
31
27
|
}, t.identity);
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}),
|
|
37
|
-
t.partial({
|
|
38
|
-
version: (0, io_ts_types_1.withMessage)(t.union([t.string, t.number, t.null]), () => "The value must be either string, number or null"),
|
|
39
|
-
title: BasicTypes_1.String,
|
|
40
|
-
author_name: BasicTypes_1.StringOrNull,
|
|
41
|
-
author_url: BasicTypes_1.StringOrNull,
|
|
42
|
-
provider_name: BasicTypes_1.StringOrNull,
|
|
43
|
-
provider_url: BasicTypes_1.StringOrNull,
|
|
44
|
-
cache_age: (0, io_ts_types_1.withMessage)(t.union([t.string, t.number, t.null]), () => "The value must be either string, number or null"),
|
|
45
|
-
thumbnail_url: BasicTypes_1.StringOrNull,
|
|
46
|
-
thumbnail_width: BasicTypes_1.NumberOrNull,
|
|
47
|
-
thumbnail_height: BasicTypes_1.NumberOrNull,
|
|
48
|
-
html: BasicTypes_1.StringOrNull,
|
|
49
|
-
}),
|
|
50
|
-
]));
|
|
51
|
-
const embedValue = new t.Type("ImportEmbedValue", (u) => EmbedProto.is(u) && "all" in u, (u) => {
|
|
52
|
-
return (0, function_1.pipe)(EmbedProto.decode(u), Either.map((parsed) => ({ ...parsed, all: u })));
|
|
53
|
-
}, t.identity);
|
|
54
|
-
exports.ImportEmbed = (0, ImportContent_1.ImportContent)("Embed", (0, validators_1.EmptyObjectOrElse)(embedValue));
|
|
28
|
+
exports.ImportEmbedValue = t.strict({
|
|
29
|
+
embed_url: EmbedUrl,
|
|
30
|
+
});
|
|
31
|
+
exports.ImportEmbed = (0, ImportContent_1.ImportContent)("Embed", (0, validators_1.EmptyObjectOrElse)(exports.ImportEmbedValue));
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { TypeOf } from "io-ts";
|
|
2
|
+
import * as t from "io-ts";
|
|
3
|
+
export declare const ImportGeoPoint: t.Type<{
|
|
4
|
+
type: "GeoPoint";
|
|
5
|
+
value: {
|
|
6
|
+
latitude: number;
|
|
7
|
+
longitude: number;
|
|
8
|
+
} | null;
|
|
9
|
+
}, {
|
|
10
|
+
latitude: number;
|
|
11
|
+
longitude: number;
|
|
12
|
+
} | undefined, unknown>;
|
|
13
|
+
export declare type ImportGeoPoint = TypeOf<typeof ImportGeoPoint>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ImportGeoPoint = 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 ImportContent_1 = require("../ImportContent");
|
|
9
|
+
const GeoPoint = (0, function_1.withCustomError)(t.strict({
|
|
10
|
+
latitude: (0, validators_1.NumberRange)(-90, 90, "latitude"),
|
|
11
|
+
longitude: (0, validators_1.NumberRange)(-180, 180, "longitude"),
|
|
12
|
+
}), () => "GeoPoint must be an object with the properties `latitude` and `longitude` between the given ranges");
|
|
13
|
+
exports.ImportGeoPoint = (0, ImportContent_1.ImportContent)("GeoPoint", (0, validators_1.EmptyObjectOrElse)(GeoPoint));
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import * as t from "io-ts";
|
|
2
|
+
export declare const defaultImportImage: (field?: ({
|
|
3
|
+
type: "Image";
|
|
4
|
+
} & {
|
|
5
|
+
fieldset?: string | null | undefined;
|
|
6
|
+
config?: {
|
|
7
|
+
label?: string | null | undefined;
|
|
8
|
+
placeholder?: string;
|
|
9
|
+
constraint?: {
|
|
10
|
+
width?: number | null;
|
|
11
|
+
height?: number | null;
|
|
12
|
+
};
|
|
13
|
+
thumbnails?: readonly ({
|
|
14
|
+
name: string;
|
|
15
|
+
} & {
|
|
16
|
+
width?: number | null;
|
|
17
|
+
height?: number | null;
|
|
18
|
+
})[];
|
|
19
|
+
};
|
|
20
|
+
}) | undefined) => t.Type<Record<never, never>, {
|
|
21
|
+
[key: string]: unknown;
|
|
22
|
+
}, unknown>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.defaultImportImage = 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 defaultImportImage = (field) => {
|
|
9
|
+
var _a;
|
|
10
|
+
// If there is not thumbnails we expect an empty object
|
|
11
|
+
if (!((_a = field === null || field === void 0 ? void 0 : field.config) === null || _a === void 0 ? void 0 : _a.thumbnails) || !field.config.thumbnails.length)
|
|
12
|
+
return validators_1.EmptyObject;
|
|
13
|
+
// If there are thumbnails, we expect an object with thumbnails as empty objects
|
|
14
|
+
return (0, function_1.withCustomError)(t.strict(field.config.thumbnails.reduce((acc, thumbnail) => ({
|
|
15
|
+
...acc,
|
|
16
|
+
[thumbnail.name]: validators_1.EmptyObject,
|
|
17
|
+
}), {})), () => "The value must be an object");
|
|
18
|
+
};
|
|
19
|
+
exports.defaultImportImage = defaultImportImage;
|