@prismicio/types-internal 2.2.0-alpha.1 → 2.2.0-alpha.11
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/GroupContent.js +11 -4
- 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 +12 -12
- 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/customtypes/widgets/nestable/NestableWidget.d.ts +0 -157
- package/lib/customtypes/widgets/nestable/NestableWidget.js +1 -17
- package/lib/import/converters/Document.d.ts +3 -2
- package/lib/import/converters/Document.js +11 -7
- 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/SliceItem.d.ts +4 -0
- package/lib/import/converters/fields/Slices/SliceItem.js +24 -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 +12 -0
- package/lib/import/converters/fields/index.d.ts +2 -0
- package/lib/import/converters/fields/index.js +2 -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.js +9 -6
- package/lib/import/converters/fields/nestable/Date.d.ts +1 -1
- package/lib/import/converters/fields/nestable/Date.js +5 -5
- 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/GeooPoint.d.ts +3 -0
- package/lib/import/converters/fields/nestable/GeooPoint.js +15 -0
- package/lib/import/converters/fields/nestable/Image.d.ts +4 -0
- package/lib/import/converters/fields/nestable/Image.js +55 -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 +4 -2
- package/lib/import/converters/fields/nestable/Nestable.js +11 -1
- package/lib/import/converters/fields/nestable/Number.js +9 -6
- package/lib/import/converters/fields/nestable/Select.js +9 -6
- package/lib/import/converters/fields/nestable/Text.js +9 -6
- package/lib/import/converters/fields/nestable/Timestamp.d.ts +1 -1
- package/lib/import/converters/fields/nestable/Timestamp.js +9 -6
- package/lib/import/converters/fields/nestable/index.d.ts +5 -0
- package/lib/import/converters/fields/nestable/index.js +5 -0
- package/lib/import/validators/Document.d.ts +4 -4
- package/lib/import/validators/Document.js +38 -46
- 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 +135 -0
- package/lib/import/validators/fields/ImportField.js +29 -0
- package/lib/import/validators/fields/ImportSlices/ImportSliceId.d.ts +9 -0
- package/lib/import/validators/fields/ImportSlices/ImportSliceId.js +43 -0
- package/lib/import/validators/fields/ImportSlices/ImportSliceItem.d.ts +24 -0
- package/lib/import/validators/fields/ImportSlices/ImportSliceItem.js +87 -0
- package/lib/import/validators/fields/ImportSlices/ImportSliceItemContent.d.ts +12 -0
- package/lib/import/validators/fields/ImportSlices/ImportSliceItemContent.js +41 -0
- 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 +60 -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/Slices/SharedSlice/SharedSlice.d.ts +14 -0
- package/lib/import/validators/fields/Slices/SharedSlice/SharedSlice.js +60 -0
- package/lib/import/validators/fields/Slices/SharedSlice/errors.d.ts +5 -0
- package/lib/import/validators/fields/Slices/SharedSlice/errors.js +8 -0
- package/lib/import/validators/fields/Slices/SharedSlice/fields/OptionalSharedSliceId.d.ts +2 -0
- package/lib/import/validators/fields/Slices/SharedSlice/fields/OptionalSharedSliceId.js +15 -0
- package/lib/import/validators/fields/Slices/SharedSlice/fields/SharedSliceContent/SharedSliceContent.d.ts +17 -0
- package/lib/import/validators/fields/Slices/SharedSlice/fields/SharedSliceContent/SharedSliceContent.js +38 -0
- package/lib/import/validators/fields/Slices/SharedSlice/fields/SharedSliceContent/SharedSliceContentEntry.d.ts +43 -0
- package/lib/import/validators/fields/Slices/SharedSlice/fields/SharedSliceContent/SharedSliceContentEntry.js +69 -0
- package/lib/import/validators/fields/Slices/SharedSlice/fields/SharedSliceContent/errors.d.ts +5 -0
- package/lib/import/validators/fields/Slices/SharedSlice/fields/SharedSliceContent/errors.js +9 -0
- package/lib/import/validators/fields/Slices/SharedSlice/fields/SharedSliceContent/index.d.ts +2 -0
- package/lib/import/validators/fields/Slices/SharedSlice/fields/SharedSliceContent/index.js +5 -0
- package/lib/import/validators/fields/Slices/SharedSlice/fields/SharedSliceContent/types.d.ts +1 -0
- package/lib/import/validators/fields/Slices/SharedSlice/fields/SharedSliceContent/types.js +2 -0
- package/lib/import/validators/fields/Slices/SharedSlice/fields/SharedSliceId.d.ts +9 -0
- package/lib/import/validators/fields/Slices/SharedSlice/fields/SharedSliceId.js +39 -0
- package/lib/import/validators/fields/Slices/SharedSlice/fields/SharedSliceItems.d.ts +11 -0
- package/lib/import/validators/fields/Slices/SharedSlice/fields/SharedSliceItems.js +25 -0
- package/lib/import/validators/fields/Slices/SharedSlice/fields/SharedSliceType.d.ts +11 -0
- package/lib/import/validators/fields/Slices/SharedSlice/fields/SharedSliceType.js +24 -0
- package/lib/import/validators/fields/Slices/SharedSlice/fields/SharedSliceVariation.d.ts +11 -0
- package/lib/import/validators/fields/Slices/SharedSlice/fields/SharedSliceVariation.js +24 -0
- package/lib/import/validators/fields/Slices/SharedSlice/fields/index.d.ts +6 -0
- package/lib/import/validators/fields/Slices/SharedSlice/fields/index.js +9 -0
- package/lib/import/validators/fields/Slices/SharedSlice/index.d.ts +3 -0
- package/lib/import/validators/fields/Slices/SharedSlice/index.js +6 -0
- package/lib/import/validators/fields/Slices/SharedSlice/utils.d.ts +339 -0
- package/lib/import/validators/fields/Slices/SharedSlice/utils.js +11 -0
- package/lib/import/validators/fields/Slices/Slices.d.ts +8 -0
- package/lib/import/validators/fields/Slices/Slices.js +29 -0
- package/lib/import/validators/fields/Slices/index.d.ts +1 -0
- package/lib/import/validators/fields/Slices/index.js +4 -0
- package/lib/import/validators/fields/Slices/utils.d.ts +4 -0
- package/lib/import/validators/fields/Slices/utils.js +35 -0
- package/lib/import/validators/fields/Slices.d.ts +4 -0
- package/lib/import/validators/fields/Slices.js +12 -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 +1 -5
- package/lib/import/validators/fields/index.js +1 -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 +5 -4
- package/lib/import/validators/fields/nestable/Color.js +4 -4
- package/lib/import/validators/fields/nestable/Date.d.ts +5 -3
- package/lib/import/validators/fields/nestable/Date.js +4 -2
- package/lib/import/validators/fields/nestable/Embed.d.ts +10 -0
- package/lib/import/validators/fields/nestable/Embed.js +36 -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/Decoder.d.ts +26 -0
- package/lib/import/validators/fields/nestable/Image/Decoder.js +40 -0
- package/lib/import/validators/fields/nestable/Image/Validator.d.ts +37 -0
- package/lib/import/validators/fields/nestable/Image/Validator.js +26 -0
- package/lib/import/validators/fields/nestable/Image/index.d.ts +26 -0
- package/lib/import/validators/fields/nestable/Image/index.js +28 -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.d.ts +45 -0
- package/lib/import/validators/fields/nestable/Image.js +45 -0
- package/lib/import/validators/fields/nestable/Link.d.ts +38 -0
- package/lib/import/validators/fields/nestable/Link.js +35 -0
- package/lib/import/validators/fields/nestable/Nestable.d.ts +120 -4
- package/lib/import/validators/fields/nestable/Nestable.js +59 -28
- package/lib/import/validators/fields/nestable/Number.d.ts +16 -9
- package/lib/import/validators/fields/nestable/Number.js +5 -4
- package/lib/import/validators/fields/nestable/Select.d.ts +15 -8
- package/lib/import/validators/fields/nestable/Select.js +4 -2
- package/lib/import/validators/fields/nestable/Text.d.ts +6 -3
- package/lib/import/validators/fields/nestable/Text.js +2 -1
- package/lib/import/validators/fields/nestable/Timestamp.d.ts +5 -3
- package/lib/import/validators/fields/nestable/Timestamp.js +4 -2
- package/lib/import/validators/fields/nestable/index.d.ts +6 -0
- package/lib/import/validators/fields/nestable/index.js +6 -0
- package/lib/utils/DocumentId.d.ts +1 -0
- package/lib/utils/DocumentId.js +7 -0
- package/lib/utils/Objects.d.ts +1 -0
- package/lib/utils/Objects.js +5 -1
- package/lib/utils/io-ts.d.ts +2 -0
- package/lib/utils/io-ts.js +22 -0
- package/lib/validators/BasicTypes.d.ts +9 -0
- package/lib/validators/BasicTypes.js +20 -1
- package/lib/validators/DefaultOrElse.d.ts +5 -0
- package/lib/validators/DefaultOrElse.js +21 -0
- package/lib/validators/NonEmptyString.js +2 -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 +2 -1
- package/lib/validators/index.js +4 -2
- package/package.json +6 -3
- package/src/common/Asset.ts +25 -0
- package/src/common/Embed.ts +22 -0
- package/src/common/UUID.ts +18 -0
- package/src/common/index.ts +2 -0
- package/src/content/fields/GroupContent.ts +9 -5
- package/src/content/fields/slices/Slice/RepeatableContent.ts +0 -1
- package/src/customtypes/CustomType.ts +13 -0
- package/src/customtypes/widgets/nestable/NestableWidget.ts +0 -17
- package/src/import/converters/Document.ts +26 -10
- 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 +13 -0
- package/src/import/converters/fields/index.ts +2 -0
- package/src/import/converters/fields/nestable/Boolean.ts +13 -0
- package/src/import/converters/fields/nestable/Color.ts +7 -5
- package/src/import/converters/fields/nestable/Date.ts +12 -13
- package/src/import/converters/fields/nestable/Embed.ts +37 -0
- package/src/import/converters/fields/nestable/GeooPoint.ts +16 -0
- package/src/import/converters/fields/nestable/Image.ts +73 -0
- package/src/import/converters/fields/nestable/Link.ts +77 -0
- package/src/import/converters/fields/nestable/Nestable.ts +21 -2
- package/src/import/converters/fields/nestable/Number.ts +7 -5
- package/src/import/converters/fields/nestable/Select.ts +7 -5
- package/src/import/converters/fields/nestable/Text.ts +7 -5
- package/src/import/converters/fields/nestable/Timestamp.ts +8 -6
- package/src/import/converters/fields/nestable/index.ts +5 -0
- package/src/import/validators/Document.ts +86 -79
- package/src/import/validators/fields/ImportContent.ts +30 -0
- package/src/import/validators/fields/ImportField.ts +30 -0
- package/src/import/validators/fields/ImportSlices/ImportSlices.ts +54 -0
- package/src/import/validators/fields/ImportSlices/SharedSlice/SharedSlice.ts +114 -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 +61 -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 +27 -0
- package/src/import/validators/fields/index.ts +1 -7
- package/src/import/validators/fields/nestable/Boolean.ts +7 -0
- package/src/import/validators/fields/nestable/Color.ts +23 -23
- package/src/import/validators/fields/nestable/Date.ts +26 -27
- package/src/import/validators/fields/nestable/Embed.ts +54 -0
- package/src/import/validators/fields/nestable/GeoPoint.ts +21 -0
- package/src/import/validators/fields/nestable/Image/Decoder.ts +61 -0
- package/src/import/validators/fields/nestable/Image/Validator.ts +35 -0
- package/src/import/validators/fields/nestable/Image/index.ts +45 -0
- package/src/import/validators/fields/nestable/Image/model.ts +18 -0
- package/src/import/validators/fields/nestable/Link.ts +54 -0
- package/src/import/validators/fields/nestable/Nestable.ts +65 -26
- package/src/import/validators/fields/nestable/Number.ts +32 -30
- package/src/import/validators/fields/nestable/Select.ts +32 -30
- package/src/import/validators/fields/nestable/Text.ts +6 -6
- package/src/import/validators/fields/nestable/Timestamp.ts +29 -26
- package/src/import/validators/fields/nestable/index.ts +6 -0
- package/src/utils/DocumentId.ts +9 -0
- package/src/utils/Objects.ts +10 -0
- package/src/utils/io-ts.ts +29 -0
- package/src/validators/BasicTypes.ts +53 -0
- package/src/validators/DefaultOrElse.ts +24 -0
- package/src/validators/NonEmptyString.ts +4 -4
- package/src/validators/NumberRange.ts +51 -0
- package/src/validators/function.ts +44 -0
- package/src/validators/index.ts +2 -1
- package/lib/import/converters/fields/utils.d.ts +0 -1
- package/lib/import/converters/fields/utils.js +0 -10
- package/lib/validators/NullOrT.d.ts +0 -2
- package/lib/validators/NullOrT.js +0 -13
- package/src/import/converters/fields/utils.ts +0 -7
- package/src/validators/NullOrT.ts +0 -18
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import * as t from "io-ts";
|
|
2
|
+
import type { StaticSlices } from "../../../../customtypes";
|
|
3
|
+
import { SharedSlice } from "./SharedSlice";
|
|
4
|
+
export declare const Slices: (staticSlices: StaticSlices) => t.Type<{
|
|
5
|
+
type: "Slices";
|
|
6
|
+
value: SharedSlice[] | null;
|
|
7
|
+
}, SharedSlice[] | undefined, unknown>;
|
|
8
|
+
export declare type Slices = t.TypeOf<ReturnType<typeof Slices>>;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Slices = 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 validators_1 = require("../../../../validators");
|
|
9
|
+
const ImportContent_1 = require("../ImportContent");
|
|
10
|
+
const SharedSlice_1 = require("./SharedSlice");
|
|
11
|
+
const utils_1 = require("./utils");
|
|
12
|
+
const Slices = (staticSlices) => {
|
|
13
|
+
const supportedSlices = (0, utils_1.extractSupportedSlices)(staticSlices);
|
|
14
|
+
// For now we only support the SharedSlice, however if we want to support more in the future
|
|
15
|
+
// we would have to change the codec here to something like this: t.array(t.union([ImportSharedSlice(sharedSlices), NewSliceCodec(newSliceCustomTypes)])).
|
|
16
|
+
const SlicesArrayCodec = t.array((0, SharedSlice_1.SharedSlice)(supportedSlices));
|
|
17
|
+
return (0, ImportContent_1.ImportContent)("Slices", (0, validators_1.EmptyObjectOrElse)(new t.Type("ImportSlices", (u) => SlicesArrayCodec.is(u), (u, c) => {
|
|
18
|
+
return (0, function_1.pipe)(SlicesArrayCodec.validate(u, c), E.chain((slices) => {
|
|
19
|
+
// This part might not make sense for all Slice types in the future, but for now we only support the SharedSlice
|
|
20
|
+
// In case we support more in the future, we would have to filter only the relevant type for this check
|
|
21
|
+
const sharedSliceDuplicates = (0, utils_1.findImportSharedSliceDuplicateIds)(slices);
|
|
22
|
+
if (sharedSliceDuplicates.length > 0) {
|
|
23
|
+
return t.failure(slices, [], `Duplicate slice IDs detected: ${sharedSliceDuplicates.join(", ")}`);
|
|
24
|
+
}
|
|
25
|
+
return t.success(slices);
|
|
26
|
+
}));
|
|
27
|
+
}, t.identity)));
|
|
28
|
+
};
|
|
29
|
+
exports.Slices = Slices;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./Slices";
|
|
@@ -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;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SliceId = 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 io_ts_types_1 = require("io-ts-types");
|
|
9
|
+
exports.SliceId = t.string.pipe(new t.Type("SliceId", (u) => typeof u === "string", (u, c) => {
|
|
10
|
+
const [sliceType, uuid] = u.split("$");
|
|
11
|
+
return (0, function_1.pipe)(t.string.validate(sliceType, c), E.chain((sliceType) => (0, function_1.pipe)(io_ts_types_1.UUID.validate(uuid, c), E.map((decodedUUID) => `${sliceType}$${decodedUUID}`))));
|
|
12
|
+
}, t.identity));
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ImportUID = 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 ImportContent_1 = require("./ImportContent");
|
|
8
|
+
const regex = /^[a-z0-9-_.]+$/;
|
|
9
|
+
const uidValue = validators_1.String.pipe(new t.Type("ImportUIDField", (u) => validators_1.String.is(u), (n, c) => {
|
|
10
|
+
if (regex.test(n)) {
|
|
11
|
+
return t.success(n);
|
|
12
|
+
}
|
|
13
|
+
return t.failure(n, c, "UID can only contain alphanumeric characters, dashes, underscores, and dots");
|
|
14
|
+
}, t.identity));
|
|
15
|
+
exports.ImportUID = (0, ImportContent_1.ImportContent)("UID", (0, validators_1.NullOrElse)(uidValue));
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ImportBoolean = void 0;
|
|
4
|
+
const validators_1 = require("../../../../validators");
|
|
5
|
+
const ImportContent_1 = require("../ImportContent");
|
|
6
|
+
exports.ImportBoolean = (0, ImportContent_1.ImportContent)("Boolean", (0, validators_1.NullOrElse)(validators_1.Boolean));
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as t from "io-ts";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
export declare const ImportColor: t.Type<{
|
|
3
|
+
type: "Color";
|
|
4
|
+
value: `#${string}` | null;
|
|
5
|
+
}, string | undefined, unknown>;
|
|
6
|
+
export declare type ImportColor = t.TypeOf<typeof ImportColor>;
|
|
@@ -5,11 +5,11 @@ const tslib_1 = require("tslib");
|
|
|
5
5
|
const t = (0, tslib_1.__importStar)(require("io-ts"));
|
|
6
6
|
const HexaColorCode_1 = require("../../../../common/HexaColorCode");
|
|
7
7
|
const validators_1 = require("../../../../validators");
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
validators_1.String.pipe(new t.Type("ImportColorField", (u) => validators_1.String.is(u) && HexaColorCode_1.HexaColor.is(u), (s, c) => {
|
|
8
|
+
const ImportContent_1 = require("../ImportContent");
|
|
9
|
+
const colorValue = new t.Type("ImportColorValue", (u) => validators_1.String.is(u) && HexaColorCode_1.HexaColor.is(u), (s, c) => {
|
|
11
10
|
if (!HexaColorCode_1.HexaColor.is(s)) {
|
|
12
11
|
return t.failure(s, c, "The color value must be an hexadecimal color code");
|
|
13
12
|
}
|
|
14
13
|
return t.success(s);
|
|
15
|
-
}, t.identity)
|
|
14
|
+
}, t.identity);
|
|
15
|
+
exports.ImportColor = (0, ImportContent_1.ImportContent)("Color", (0, validators_1.NullOrElse)(validators_1.String.pipe(colorValue)));
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import * as t from "io-ts";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
export declare const ImportDate: t.Type<{
|
|
3
|
+
type: "Date";
|
|
4
|
+
value: Date | null;
|
|
5
|
+
}, Date | undefined, unknown>;
|
|
6
|
+
export declare type ImportDate = t.TypeOf<typeof ImportDate>;
|
|
@@ -6,12 +6,14 @@ const Either_1 = require("fp-ts/Either");
|
|
|
6
6
|
const function_1 = require("fp-ts/function");
|
|
7
7
|
const t = (0, tslib_1.__importStar)(require("io-ts"));
|
|
8
8
|
const validators_1 = require("../../../../validators");
|
|
9
|
+
const ImportContent_1 = require("../ImportContent");
|
|
9
10
|
const DATE_INPUT_REGEX = /^(\d{1,4})-(\d{1,2})-(\d{1,2})$/;
|
|
10
|
-
|
|
11
|
+
const dateValue = new t.Type("ImportNumberValue", (u) => u instanceof Date, (u, c) => (0, function_1.pipe)(validators_1.String.validate(u, c), (0, Either_1.chain)((s) => {
|
|
11
12
|
const date = new Date(s);
|
|
12
13
|
const isInvalidDate = isNaN(date.getTime());
|
|
13
14
|
if (isInvalidDate || !DATE_INPUT_REGEX.test(s)) {
|
|
14
15
|
return t.failure(u, c, "The value must be a Date in the format YYYY-MM-DD");
|
|
15
16
|
}
|
|
16
17
|
return t.success(date);
|
|
17
|
-
})), t.identity)
|
|
18
|
+
})), t.identity);
|
|
19
|
+
exports.ImportDate = (0, ImportContent_1.ImportContent)("Date", (0, validators_1.NullOrElse)(dateValue));
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ImportEmbed = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const Either = (0, tslib_1.__importStar)(require("fp-ts/Either"));
|
|
6
|
+
const function_1 = require("fp-ts/lib/function");
|
|
7
|
+
const t = (0, tslib_1.__importStar)(require("io-ts"));
|
|
8
|
+
const validators_1 = require("../../../../validators");
|
|
9
|
+
const ImportContent_1 = require("../ImportContent");
|
|
10
|
+
function isValidHttpUrl(param) {
|
|
11
|
+
try {
|
|
12
|
+
if (typeof param !== "string") {
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
const url = new URL(param);
|
|
16
|
+
return ["http:", "https:"].includes(url.protocol);
|
|
17
|
+
}
|
|
18
|
+
catch (err) {
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
const EmbedUrl = new t.Type("EmbedUrl", (u) => isValidHttpUrl(u), (u, c) => {
|
|
23
|
+
if (isValidHttpUrl(u)) {
|
|
24
|
+
return t.success(u);
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
return t.failure(u, c, "The value must be a valid http/https url");
|
|
28
|
+
}
|
|
29
|
+
}, t.identity);
|
|
30
|
+
const EmbedProto = t.type({
|
|
31
|
+
embed_url: EmbedUrl,
|
|
32
|
+
});
|
|
33
|
+
const Embed = new t.Type("ImportEmbedValue", (u) => EmbedProto.is(u), (u) => {
|
|
34
|
+
return (0, function_1.pipe)(EmbedProto.decode(u), Either.map((parsed) => ({ embed_url: parsed.embed_url })));
|
|
35
|
+
}, t.identity);
|
|
36
|
+
exports.ImportEmbed = (0, ImportContent_1.ImportContent)("Embed", (0, validators_1.EmptyObjectOrElse)(Embed));
|
|
@@ -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 GeooPoint = (0, function_1.withFallbackMessage)(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)(GeooPoint));
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { TypeOf } from "io-ts";
|
|
2
|
+
import type { ImageField } from "./model";
|
|
3
|
+
import type { ImageFieldValidator, ThumbnailsValidator } from "./Validator";
|
|
4
|
+
export declare const decodeImageField: (image: TypeOf<typeof ImageFieldValidator> | undefined, mainImage: TypeOf<typeof ImageFieldValidator>, constraints?: {
|
|
5
|
+
width?: number | null;
|
|
6
|
+
height?: number | null;
|
|
7
|
+
} | undefined) => ImageField;
|
|
8
|
+
export declare const decodeThumbnails: (mainImage: TypeOf<typeof ImageFieldValidator>, thumbnails: TypeOf<typeof ThumbnailsValidator>, field?: ({
|
|
9
|
+
type: "Image";
|
|
10
|
+
} & {
|
|
11
|
+
fieldset?: string | null | undefined;
|
|
12
|
+
config?: {
|
|
13
|
+
label?: string | null | undefined;
|
|
14
|
+
placeholder?: string;
|
|
15
|
+
constraint?: {
|
|
16
|
+
width?: number | null;
|
|
17
|
+
height?: number | null;
|
|
18
|
+
};
|
|
19
|
+
thumbnails?: readonly ({
|
|
20
|
+
name: string;
|
|
21
|
+
} & {
|
|
22
|
+
width?: number | null;
|
|
23
|
+
height?: number | null;
|
|
24
|
+
})[];
|
|
25
|
+
};
|
|
26
|
+
}) | undefined) => {};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.decodeThumbnails = exports.decodeImageField = void 0;
|
|
4
|
+
// This function merges user input with custom type constraints.
|
|
5
|
+
// If `image` is missing, `mainImage` is used for the encoding
|
|
6
|
+
// (case when user input lacks thumbnail definition)
|
|
7
|
+
const decodeImageField = (image, mainImage, constraints) => {
|
|
8
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
|
|
9
|
+
const background = (_a = image === null || image === void 0 ? void 0 : image.edit) === null || _a === void 0 ? void 0 : _a.background;
|
|
10
|
+
const width = (_d = (_b = constraints === null || constraints === void 0 ? void 0 : constraints.width) !== null && _b !== void 0 ? _b : (_c = image === null || image === void 0 ? void 0 : image.dimensions) === null || _c === void 0 ? void 0 : _c.width) !== null && _d !== void 0 ? _d : (_e = mainImage.dimensions) === null || _e === void 0 ? void 0 : _e.width;
|
|
11
|
+
const height = (_h = (_f = constraints === null || constraints === void 0 ? void 0 : constraints.height) !== null && _f !== void 0 ? _f : (_g = image === null || image === void 0 ? void 0 : image.dimensions) === null || _g === void 0 ? void 0 : _g.height) !== null && _h !== void 0 ? _h : (_j = mainImage.dimensions) === null || _j === void 0 ? void 0 : _j.height;
|
|
12
|
+
const alt = image === null || image === void 0 ? void 0 : image.alt;
|
|
13
|
+
const credit = image === null || image === void 0 ? void 0 : image.credit;
|
|
14
|
+
return {
|
|
15
|
+
id: (_k = image === null || image === void 0 ? void 0 : image.id) !== null && _k !== void 0 ? _k : mainImage === null || mainImage === void 0 ? void 0 : mainImage.id,
|
|
16
|
+
edit: {
|
|
17
|
+
x: (_m = (_l = image === null || image === void 0 ? void 0 : image.edit) === null || _l === void 0 ? void 0 : _l.x) !== null && _m !== void 0 ? _m : 0,
|
|
18
|
+
y: (_p = (_o = image === null || image === void 0 ? void 0 : image.edit) === null || _o === void 0 ? void 0 : _o.y) !== null && _p !== void 0 ? _p : 0,
|
|
19
|
+
zoom: (_r = (_q = image === null || image === void 0 ? void 0 : image.edit) === null || _q === void 0 ? void 0 : _q.zoom) !== null && _r !== void 0 ? _r : 1,
|
|
20
|
+
...(background !== undefined ? { background } : {}),
|
|
21
|
+
},
|
|
22
|
+
dimensions: {
|
|
23
|
+
...(width !== undefined ? { width } : {}),
|
|
24
|
+
...(height !== undefined ? { height } : {}),
|
|
25
|
+
},
|
|
26
|
+
...(alt !== undefined ? { alt } : {}),
|
|
27
|
+
...(credit !== undefined ? { credit } : {}),
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
exports.decodeImageField = decodeImageField;
|
|
31
|
+
// Merges provided thumbnails with custom type constraints.
|
|
32
|
+
// If any thumbnail is missing, it is created using the origin image (`mainImage`)
|
|
33
|
+
const decodeThumbnails = (mainImage, thumbnails, field) => {
|
|
34
|
+
var _a, _b, _c;
|
|
35
|
+
return (_c = (_b = (_a = field === null || field === void 0 ? void 0 : field.config) === null || _a === void 0 ? void 0 : _a.thumbnails) === null || _b === void 0 ? void 0 : _b.reduce((acc, thumbnail) => ({
|
|
36
|
+
...acc,
|
|
37
|
+
[thumbnail.name]: (0, exports.decodeImageField)(thumbnails[thumbnail.name], mainImage, thumbnail),
|
|
38
|
+
}), {})) !== null && _c !== void 0 ? _c : {};
|
|
39
|
+
};
|
|
40
|
+
exports.decodeThumbnails = decodeThumbnails;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import * as t from "io-ts";
|
|
2
|
+
export declare const ImageFieldValidator: t.Type<{
|
|
3
|
+
id: string;
|
|
4
|
+
} & {
|
|
5
|
+
dimensions?: {
|
|
6
|
+
width?: number;
|
|
7
|
+
height?: number;
|
|
8
|
+
};
|
|
9
|
+
edit?: {
|
|
10
|
+
x?: number;
|
|
11
|
+
y?: number;
|
|
12
|
+
zoom?: number;
|
|
13
|
+
background?: string;
|
|
14
|
+
};
|
|
15
|
+
credit?: string | null;
|
|
16
|
+
alt?: string | null;
|
|
17
|
+
}, {
|
|
18
|
+
[x: string]: unknown;
|
|
19
|
+
}, unknown>;
|
|
20
|
+
export declare const ThumbnailsValidator: t.RecordC<t.StringC, t.Type<{
|
|
21
|
+
id: string;
|
|
22
|
+
} & {
|
|
23
|
+
dimensions?: {
|
|
24
|
+
width?: number;
|
|
25
|
+
height?: number;
|
|
26
|
+
};
|
|
27
|
+
edit?: {
|
|
28
|
+
x?: number;
|
|
29
|
+
y?: number;
|
|
30
|
+
zoom?: number;
|
|
31
|
+
background?: string;
|
|
32
|
+
};
|
|
33
|
+
credit?: string | null;
|
|
34
|
+
alt?: string | null;
|
|
35
|
+
}, {
|
|
36
|
+
[x: string]: unknown;
|
|
37
|
+
}, unknown>>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ThumbnailsValidator = exports.ImageFieldValidator = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const t = (0, tslib_1.__importStar)(require("io-ts"));
|
|
6
|
+
const BasicTypes_1 = require("../../../../../validators/BasicTypes");
|
|
7
|
+
exports.ImageFieldValidator = BasicTypes_1.AnyObject.pipe(t.intersection([
|
|
8
|
+
t.type({
|
|
9
|
+
id: BasicTypes_1.String,
|
|
10
|
+
}),
|
|
11
|
+
t.partial({
|
|
12
|
+
dimensions: BasicTypes_1.AnyObject.pipe(t.partial({
|
|
13
|
+
width: BasicTypes_1.Number,
|
|
14
|
+
height: BasicTypes_1.Number,
|
|
15
|
+
})),
|
|
16
|
+
edit: BasicTypes_1.AnyObject.pipe(t.partial({
|
|
17
|
+
x: BasicTypes_1.Number,
|
|
18
|
+
y: BasicTypes_1.Number,
|
|
19
|
+
zoom: BasicTypes_1.Number,
|
|
20
|
+
background: BasicTypes_1.String,
|
|
21
|
+
})),
|
|
22
|
+
credit: BasicTypes_1.StringOrNull,
|
|
23
|
+
alt: BasicTypes_1.StringOrNull,
|
|
24
|
+
}),
|
|
25
|
+
]));
|
|
26
|
+
exports.ThumbnailsValidator = t.record(t.string, exports.ImageFieldValidator);
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import * as t from "io-ts";
|
|
2
|
+
import type { ImageFieldWithThumbnails } from "./model";
|
|
3
|
+
export declare const ImportImage: (field?: ({
|
|
4
|
+
type: "Image";
|
|
5
|
+
} & {
|
|
6
|
+
fieldset?: string | null | undefined;
|
|
7
|
+
config?: {
|
|
8
|
+
label?: string | null | undefined;
|
|
9
|
+
placeholder?: string;
|
|
10
|
+
constraint?: {
|
|
11
|
+
width?: number | null;
|
|
12
|
+
height?: number | null;
|
|
13
|
+
};
|
|
14
|
+
thumbnails?: readonly ({
|
|
15
|
+
name: string;
|
|
16
|
+
} & {
|
|
17
|
+
width?: number | null;
|
|
18
|
+
height?: number | null;
|
|
19
|
+
})[];
|
|
20
|
+
};
|
|
21
|
+
}) | undefined) => t.Type<{
|
|
22
|
+
type: "Image";
|
|
23
|
+
value: ImageFieldWithThumbnails | null;
|
|
24
|
+
}, ImageFieldWithThumbnails | undefined, unknown>;
|
|
25
|
+
export declare type ImportImage = t.TypeOf<ReturnType<typeof ImportImage>>;
|
|
26
|
+
export * from "./model";
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ImportImage = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const Either_1 = require("fp-ts/Either");
|
|
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 ImportContent_1 = require("../../ImportContent");
|
|
10
|
+
const Decoder_1 = require("./Decoder");
|
|
11
|
+
const Validator_1 = require("./Validator");
|
|
12
|
+
const ImageField = (field) => new t.Type("ImageField", (u) => Validator_1.ImageFieldValidator.is(u) &&
|
|
13
|
+
"thumbnails" in u &&
|
|
14
|
+
Validator_1.ThumbnailsValidator.is(u["thumbnails"]), (u, ctx) => {
|
|
15
|
+
return (0, function_1.pipe)(Validator_1.ImageFieldValidator.validate(u, ctx), (0, Either_1.chain)((mainImage) => {
|
|
16
|
+
const { id, dimensions, edit, credit, alt, ...maybeThumbnails } = mainImage;
|
|
17
|
+
return (0, function_1.pipe)(Validator_1.ThumbnailsValidator.validate(maybeThumbnails, ctx), (0, Either_1.map)((thumbnails) => {
|
|
18
|
+
var _a;
|
|
19
|
+
return ({
|
|
20
|
+
...(0, Decoder_1.decodeImageField)(mainImage, mainImage, (_a = field === null || field === void 0 ? void 0 : field.config) === null || _a === void 0 ? void 0 : _a.constraint),
|
|
21
|
+
thumbnails: (0, Decoder_1.decodeThumbnails)(mainImage, thumbnails, field),
|
|
22
|
+
});
|
|
23
|
+
}));
|
|
24
|
+
}));
|
|
25
|
+
}, t.identity);
|
|
26
|
+
const ImportImage = (field) => (0, ImportContent_1.ImportContent)("Image", (0, validators_1.NullOrElse)(ImageField(field)));
|
|
27
|
+
exports.ImportImage = ImportImage;
|
|
28
|
+
(0, tslib_1.__exportStar)(require("./model"), exports);
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export declare type ImageField = {
|
|
2
|
+
id: string;
|
|
3
|
+
edit: {
|
|
4
|
+
x: number;
|
|
5
|
+
y: number;
|
|
6
|
+
zoom: number;
|
|
7
|
+
background?: string;
|
|
8
|
+
};
|
|
9
|
+
dimensions: {
|
|
10
|
+
width?: number;
|
|
11
|
+
height?: number;
|
|
12
|
+
};
|
|
13
|
+
credit?: string | null;
|
|
14
|
+
alt?: string | null;
|
|
15
|
+
};
|
|
16
|
+
export declare type ImageFieldWithThumbnails = ImageField & {
|
|
17
|
+
thumbnails: Record<string, ImageField>;
|
|
18
|
+
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import * as t from "io-ts";
|
|
2
|
+
declare const ImageFieldCodec: t.Type<{
|
|
3
|
+
id: string;
|
|
4
|
+
} & {
|
|
5
|
+
edit?: {
|
|
6
|
+
x: number;
|
|
7
|
+
y: number;
|
|
8
|
+
width: number;
|
|
9
|
+
height: number;
|
|
10
|
+
zoom: number;
|
|
11
|
+
background: string;
|
|
12
|
+
};
|
|
13
|
+
credit?: string | null;
|
|
14
|
+
alt?: string | null;
|
|
15
|
+
}, {
|
|
16
|
+
[x: string]: unknown;
|
|
17
|
+
}, unknown>;
|
|
18
|
+
declare const ThumbnailsCodec: t.RecordC<t.StringC, t.Type<{
|
|
19
|
+
id: string;
|
|
20
|
+
} & {
|
|
21
|
+
edit?: {
|
|
22
|
+
x: number;
|
|
23
|
+
y: number;
|
|
24
|
+
width: number;
|
|
25
|
+
height: number;
|
|
26
|
+
zoom: number;
|
|
27
|
+
background: string;
|
|
28
|
+
};
|
|
29
|
+
credit?: string | null;
|
|
30
|
+
alt?: string | null;
|
|
31
|
+
}, {
|
|
32
|
+
[x: string]: unknown;
|
|
33
|
+
}, unknown>>;
|
|
34
|
+
declare type Thumbnails = t.TypeOf<typeof ThumbnailsCodec>;
|
|
35
|
+
export declare type ImageField = t.TypeOf<typeof ImageFieldCodec>;
|
|
36
|
+
declare type ImageFieldWithThumbnails = ImageField & {
|
|
37
|
+
thumbnails: Thumbnails;
|
|
38
|
+
};
|
|
39
|
+
declare const ImageFieldWithThumbnails: t.Type<ImageFieldWithThumbnails, ImageFieldWithThumbnails, unknown>;
|
|
40
|
+
export declare const ImportImage: t.Type<{
|
|
41
|
+
type: "Image";
|
|
42
|
+
value: ImageFieldWithThumbnails | null;
|
|
43
|
+
}, ImageFieldWithThumbnails | undefined, unknown>;
|
|
44
|
+
export declare type ImportImage = t.TypeOf<typeof ImportImage>;
|
|
45
|
+
export {};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ImportImage = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const Either_1 = require("fp-ts/Either");
|
|
6
|
+
const function_1 = require("fp-ts/lib/function");
|
|
7
|
+
const t = (0, tslib_1.__importStar)(require("io-ts"));
|
|
8
|
+
const Objects_1 = require("../../../../utils/Objects");
|
|
9
|
+
const validators_1 = require("../../../../validators");
|
|
10
|
+
const BasicTypes_1 = require("../../../../validators/BasicTypes");
|
|
11
|
+
const ImportContent_1 = require("../ImportContent");
|
|
12
|
+
const ImageFieldCodec = validators_1.AnyObject.pipe(t.intersection([
|
|
13
|
+
t.type({
|
|
14
|
+
id: BasicTypes_1.String,
|
|
15
|
+
}),
|
|
16
|
+
t.partial({
|
|
17
|
+
edit: validators_1.AnyObject.pipe(t.strict({
|
|
18
|
+
x: validators_1.Number,
|
|
19
|
+
y: validators_1.Number,
|
|
20
|
+
width: validators_1.Number,
|
|
21
|
+
height: validators_1.Number,
|
|
22
|
+
zoom: validators_1.Number,
|
|
23
|
+
background: BasicTypes_1.String,
|
|
24
|
+
})),
|
|
25
|
+
credit: BasicTypes_1.StringOrNull,
|
|
26
|
+
alt: BasicTypes_1.StringOrNull,
|
|
27
|
+
}),
|
|
28
|
+
]));
|
|
29
|
+
const ThumbnailsCodec = t.record(t.string, ImageFieldCodec);
|
|
30
|
+
const ImageFieldWithThumbnails = new t.Type("ImageFieldWithThumbnails", (u) => ImageFieldCodec.is(u) &&
|
|
31
|
+
"thumbnails" in u &&
|
|
32
|
+
ThumbnailsCodec.is(u["thumbnails"]), (u, ctx) => {
|
|
33
|
+
return (0, function_1.pipe)(ImageFieldCodec.validate(u, ctx), (0, Either_1.chain)((proto) => {
|
|
34
|
+
const { id, edit, credit, alt, ...maybeThumbnails } = proto;
|
|
35
|
+
return (0, function_1.pipe)(ThumbnailsCodec.validate(maybeThumbnails, ctx), (0, Either_1.map)((thumbnails) => (0, Objects_1.withOptionals)({
|
|
36
|
+
id,
|
|
37
|
+
thumbnails,
|
|
38
|
+
}, [
|
|
39
|
+
["edit", edit],
|
|
40
|
+
["credit", credit],
|
|
41
|
+
["alt", alt],
|
|
42
|
+
])));
|
|
43
|
+
}));
|
|
44
|
+
}, t.identity);
|
|
45
|
+
exports.ImportImage = (0, ImportContent_1.ImportContent)("Image", (0, validators_1.NullOrElse)(ImageFieldWithThumbnails));
|