@prismicio/types-internal 2.2.0-alpha.11 → 2.2.0-alpha.13
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/import/converters/fields/utils.d.ts +1 -0
- package/lib/import/converters/fields/utils.js +10 -0
- package/lib/import/validators/fields/nestable/Image/index.js +12 -1
- package/lib/validators/DefaultOrElse.js +1 -1
- package/lib/validators/NullOrT.d.ts +2 -0
- package/lib/validators/NullOrT.js +13 -0
- package/package.json +1 -1
- package/src/import/validators/fields/nestable/Image/index.ts +33 -2
- package/src/validators/DefaultOrElse.ts +1 -1
- package/lib/import/converters/fields/Slices/SliceItem.d.ts +0 -4
- package/lib/import/converters/fields/Slices/SliceItem.js +0 -24
- package/lib/import/validators/fields/ImportSlices/ImportSliceId.d.ts +0 -9
- package/lib/import/validators/fields/ImportSlices/ImportSliceId.js +0 -43
- package/lib/import/validators/fields/ImportSlices/ImportSliceItem.d.ts +0 -24
- package/lib/import/validators/fields/ImportSlices/ImportSliceItem.js +0 -87
- package/lib/import/validators/fields/ImportSlices/ImportSliceItemContent.d.ts +0 -12
- package/lib/import/validators/fields/ImportSlices/ImportSliceItemContent.js +0 -41
- package/lib/import/validators/fields/Slices/SharedSlice/SharedSlice.d.ts +0 -14
- package/lib/import/validators/fields/Slices/SharedSlice/SharedSlice.js +0 -60
- package/lib/import/validators/fields/Slices/SharedSlice/errors.d.ts +0 -5
- package/lib/import/validators/fields/Slices/SharedSlice/errors.js +0 -8
- package/lib/import/validators/fields/Slices/SharedSlice/fields/OptionalSharedSliceId.d.ts +0 -2
- package/lib/import/validators/fields/Slices/SharedSlice/fields/OptionalSharedSliceId.js +0 -15
- package/lib/import/validators/fields/Slices/SharedSlice/fields/SharedSliceContent/SharedSliceContent.d.ts +0 -17
- package/lib/import/validators/fields/Slices/SharedSlice/fields/SharedSliceContent/SharedSliceContent.js +0 -38
- package/lib/import/validators/fields/Slices/SharedSlice/fields/SharedSliceContent/SharedSliceContentEntry.d.ts +0 -43
- package/lib/import/validators/fields/Slices/SharedSlice/fields/SharedSliceContent/SharedSliceContentEntry.js +0 -69
- package/lib/import/validators/fields/Slices/SharedSlice/fields/SharedSliceContent/errors.d.ts +0 -5
- package/lib/import/validators/fields/Slices/SharedSlice/fields/SharedSliceContent/errors.js +0 -9
- package/lib/import/validators/fields/Slices/SharedSlice/fields/SharedSliceContent/index.d.ts +0 -2
- package/lib/import/validators/fields/Slices/SharedSlice/fields/SharedSliceContent/index.js +0 -5
- package/lib/import/validators/fields/Slices/SharedSlice/fields/SharedSliceContent/types.d.ts +0 -1
- package/lib/import/validators/fields/Slices/SharedSlice/fields/SharedSliceContent/types.js +0 -2
- package/lib/import/validators/fields/Slices/SharedSlice/fields/SharedSliceId.d.ts +0 -9
- package/lib/import/validators/fields/Slices/SharedSlice/fields/SharedSliceId.js +0 -39
- package/lib/import/validators/fields/Slices/SharedSlice/fields/SharedSliceItems.d.ts +0 -11
- package/lib/import/validators/fields/Slices/SharedSlice/fields/SharedSliceItems.js +0 -25
- package/lib/import/validators/fields/Slices/SharedSlice/fields/SharedSliceType.d.ts +0 -11
- package/lib/import/validators/fields/Slices/SharedSlice/fields/SharedSliceType.js +0 -24
- package/lib/import/validators/fields/Slices/SharedSlice/fields/SharedSliceVariation.d.ts +0 -11
- package/lib/import/validators/fields/Slices/SharedSlice/fields/SharedSliceVariation.js +0 -24
- package/lib/import/validators/fields/Slices/SharedSlice/fields/index.d.ts +0 -6
- package/lib/import/validators/fields/Slices/SharedSlice/fields/index.js +0 -9
- package/lib/import/validators/fields/Slices/SharedSlice/index.d.ts +0 -3
- package/lib/import/validators/fields/Slices/SharedSlice/index.js +0 -6
- package/lib/import/validators/fields/Slices/SharedSlice/utils.d.ts +0 -339
- package/lib/import/validators/fields/Slices/SharedSlice/utils.js +0 -11
- package/lib/import/validators/fields/Slices/Slices.d.ts +0 -8
- package/lib/import/validators/fields/Slices/Slices.js +0 -29
- package/lib/import/validators/fields/Slices/index.d.ts +0 -1
- package/lib/import/validators/fields/Slices/index.js +0 -4
- package/lib/import/validators/fields/Slices/utils.d.ts +0 -4
- package/lib/import/validators/fields/Slices/utils.js +0 -35
- package/lib/import/validators/fields/Slices.d.ts +0 -4
- package/lib/import/validators/fields/Slices.js +0 -12
- package/lib/import/validators/fields/nestable/Image.d.ts +0 -45
- package/lib/import/validators/fields/nestable/Image.js +0 -45
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SharedSliceContentEntry = 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 common_1 = require("../../../../../../../common");
|
|
9
|
-
const nestable_1 = require("../../../../nestable");
|
|
10
|
-
const errors_1 = require("./errors");
|
|
11
|
-
/**
|
|
12
|
-
* Represents a single entry in the 'primary' field or a single entry in an item in the 'items' array in the SharedSlice. It is used to build the SharedSliceContent type from entries of the import object.
|
|
13
|
-
*
|
|
14
|
-
* For example, given the following slice:
|
|
15
|
-
* {
|
|
16
|
-
* "slice_type": "my_slice",
|
|
17
|
-
* "variation": "default",
|
|
18
|
-
* "primary": {
|
|
19
|
-
* "slice_text": "abc", // This is one entry
|
|
20
|
-
* "slice_text2": "def: // This is another entry
|
|
21
|
-
* },
|
|
22
|
-
* "items": [
|
|
23
|
-
* {
|
|
24
|
-
* "slice_number1": 0, // This is one entry
|
|
25
|
-
* "slice_number2": 1 // And this is yet another entry
|
|
26
|
-
* }
|
|
27
|
-
* ]
|
|
28
|
-
* }
|
|
29
|
-
*
|
|
30
|
-
* The 'primary' object is converted to following entries to be decoded:
|
|
31
|
-
* [
|
|
32
|
-
* ["slice_text", "abc"],
|
|
33
|
-
* ["slice_text2", "def"]
|
|
34
|
-
* ]
|
|
35
|
-
* and the first item in the 'items' array is converted to following entries to be decoded:
|
|
36
|
-
* [
|
|
37
|
-
* ["slice_number1", 0],
|
|
38
|
-
* ["slice_number2", 1]
|
|
39
|
-
* ]
|
|
40
|
-
*
|
|
41
|
-
* We decode them as separate entries because each of the values might require a different codec as per what is specified in the SharedSlice custom type.
|
|
42
|
-
* In this way we save on the decoding performance in comparison to a scenario where we would decode the whole content object as a record with a union type decoder for each value.
|
|
43
|
-
*
|
|
44
|
-
* @param sliceName name of the slice - used for error reporting in order to know which slice is being decoded
|
|
45
|
-
* @param sliceContentField 'primary' or 'items' - used for error reporting in order to know which field of the slice is being decoded
|
|
46
|
-
* @param sliceFieldModels models of the fields of the slice from custom type - used to know which codec to use for decoding each value of the object
|
|
47
|
-
*/
|
|
48
|
-
const SharedSliceContentEntry = (sliceName, sliceContentField, sliceFieldModels) => new t.Type("SharedSliceContentEntry", (u) => t.tuple([common_1.WidgetKey, t.unknown]).is(u) && nestable_1.ImportNestable.is(u[1]), (u, c) => {
|
|
49
|
-
return (0, function_1.pipe)(t.tuple([common_1.WidgetKey, t.unknown]).validate(u, c), E.chain(([key, content]) => {
|
|
50
|
-
const model = sliceFieldModels[key];
|
|
51
|
-
if (!model) {
|
|
52
|
-
return t.failure([key, content], [...c, { key, actual: content, type: t.unknown }], errors_1.SharedSliceContentErrors.UnknownField(sliceName, sliceContentField, key));
|
|
53
|
-
}
|
|
54
|
-
const { codec, result } = nestable_1.ImportNestable.decode(model)(content);
|
|
55
|
-
return (0, function_1.pipe)(result, E.map((decodedContent) => [
|
|
56
|
-
key,
|
|
57
|
-
decodedContent,
|
|
58
|
-
]), E.mapLeft((errors) => errors.map((error) => {
|
|
59
|
-
const context = [
|
|
60
|
-
...c,
|
|
61
|
-
...error.context.filter(({ key }) => !!key),
|
|
62
|
-
{ key, actual: content, type: codec },
|
|
63
|
-
];
|
|
64
|
-
const updatedError = { ...error, context };
|
|
65
|
-
return updatedError;
|
|
66
|
-
})));
|
|
67
|
-
}));
|
|
68
|
-
}, t.identity);
|
|
69
|
-
exports.SharedSliceContentEntry = SharedSliceContentEntry;
|
package/lib/import/validators/fields/Slices/SharedSlice/fields/SharedSliceContent/errors.d.ts
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { SharedSliceContentField } from "./types";
|
|
2
|
-
export declare const SharedSliceContentErrors: {
|
|
3
|
-
readonly UnknownField: (sliceName: string, contentField: SharedSliceContentField, fieldName: string) => string;
|
|
4
|
-
readonly InvalidSliceItemContent: (sliceName: string, contentField: SharedSliceContentField) => string;
|
|
5
|
-
};
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SharedSliceContentErrors = void 0;
|
|
4
|
-
exports.SharedSliceContentErrors = {
|
|
5
|
-
UnknownField: (sliceName, contentField, fieldName) => `Unsupported field '${fieldName}'for '${contentField}' content in Shared Slice '${sliceName}'`,
|
|
6
|
-
InvalidSliceItemContent: (sliceName, contentField) => {
|
|
7
|
-
return `Invalid value for '${contentField}' content in Shared Slice '${sliceName}'. Must be a key-value record.`;
|
|
8
|
-
},
|
|
9
|
-
};
|
package/lib/import/validators/fields/Slices/SharedSlice/fields/SharedSliceContent/types.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare type SharedSliceContentField = "primary" | "items";
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import * as t from "io-ts";
|
|
2
|
-
import { UUID } from "../../../../../../common/UUID";
|
|
3
|
-
export declare type SharedSliceId = `${string}$${UUID}`;
|
|
4
|
-
export declare const SharedSliceIdValidationError: {
|
|
5
|
-
readonly Base: "Slice id must be a non empty string matching the following pattern 'slice_type$uuid'";
|
|
6
|
-
readonly IncorrectUUID: (uuid: string | undefined) => string;
|
|
7
|
-
readonly IncorrectSliceType: (sliceType: string | undefined) => string;
|
|
8
|
-
};
|
|
9
|
-
export declare const SharedSliceId: t.Type<string, string, unknown>;
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SharedSliceId = exports.SharedSliceIdValidationError = 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 UUID_1 = require("../../../../../../common/UUID");
|
|
9
|
-
const validators_1 = require("../../../../../../validators");
|
|
10
|
-
const baseErrorText = "Slice id must be a non empty string matching the following pattern 'slice_type$uuid'";
|
|
11
|
-
exports.SharedSliceIdValidationError = {
|
|
12
|
-
Base: baseErrorText,
|
|
13
|
-
IncorrectUUID: (uuid) => `Incorrect UUID: '${uuid}' - ${baseErrorText}`,
|
|
14
|
-
IncorrectSliceType: (sliceType) => `Incorrect slice_type: '${sliceType}' - ${baseErrorText}`,
|
|
15
|
-
};
|
|
16
|
-
exports.SharedSliceId = new t.Type("SharedSliceId", (u) => {
|
|
17
|
-
if (typeof u !== "string") {
|
|
18
|
-
return false;
|
|
19
|
-
}
|
|
20
|
-
const [sliceName, uuid] = u.split("$");
|
|
21
|
-
return validators_1.NonEmptyString.is(sliceName) && UUID_1.UUID.is(uuid);
|
|
22
|
-
}, (u, c) => (0, function_1.pipe)(validators_1.NonEmptyString.validate(u, c), E.mapLeft((errors) => errors.map((error) => ({
|
|
23
|
-
...error,
|
|
24
|
-
message: exports.SharedSliceIdValidationError.Base,
|
|
25
|
-
}))), E.chain((sliceId) => {
|
|
26
|
-
const [sliceName, uuid] = sliceId.split("$");
|
|
27
|
-
return (0, function_1.pipe)(t.tuple([validators_1.NonEmptyString, UUID_1.UUID]).validate([sliceName, uuid], c), E.mapLeft((errors) => errors.map((error) => {
|
|
28
|
-
const tupleErrorContext = error.context[error.context.length - 1];
|
|
29
|
-
return {
|
|
30
|
-
...error,
|
|
31
|
-
context: [
|
|
32
|
-
...error.context.slice(0, -1), // We don't want the tuple decoder error context
|
|
33
|
-
],
|
|
34
|
-
message: (tupleErrorContext === null || tupleErrorContext === void 0 ? void 0 : tupleErrorContext.key) === "0"
|
|
35
|
-
? exports.SharedSliceIdValidationError.IncorrectSliceType(sliceName)
|
|
36
|
-
: exports.SharedSliceIdValidationError.IncorrectUUID(uuid),
|
|
37
|
-
};
|
|
38
|
-
})));
|
|
39
|
-
}), E.map(([sliceName, uuid]) => `${sliceName}$${uuid}`)), (sliceId) => sliceId);
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import * as t from "io-ts";
|
|
2
|
-
import type { WidgetKey } from "../../../../../../common";
|
|
3
|
-
import type { NestableWidget } from "../../../../../../customtypes";
|
|
4
|
-
import { SharedSliceContent } from "./SharedSliceContent";
|
|
5
|
-
/**
|
|
6
|
-
* Build a codec for the 'items' array in the SharedSlice.
|
|
7
|
-
* @param sliceName name of the slice - used for error reporting in order to know which slice is being decoded
|
|
8
|
-
* @param model models of the fields for the 'items' from Slice's custom type - used to know which codec to use for decoding each value within each item
|
|
9
|
-
* @constructor
|
|
10
|
-
*/
|
|
11
|
-
export declare const SharedSliceItems: (sliceName: string, model: Record<WidgetKey, NestableWidget>) => t.Type<SharedSliceContent[], SharedSliceContent[], unknown>;
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SharedSliceItems = 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
|
-
const errors_1 = require("../errors");
|
|
10
|
-
const SharedSliceContent_1 = require("./SharedSliceContent");
|
|
11
|
-
/**
|
|
12
|
-
* Build a codec for the 'items' array in the SharedSlice.
|
|
13
|
-
* @param sliceName name of the slice - used for error reporting in order to know which slice is being decoded
|
|
14
|
-
* @param model models of the fields for the 'items' from Slice's custom type - used to know which codec to use for decoding each value within each item
|
|
15
|
-
* @constructor
|
|
16
|
-
*/
|
|
17
|
-
const SharedSliceItems = (sliceName, model) => {
|
|
18
|
-
const ContentCodec = (0, SharedSliceContent_1.SharedSliceContent)(sliceName, "items", model);
|
|
19
|
-
return new t.Type("SharedSliceItems", (u) => t.array(ContentCodec).is(u), (u, c) => (0, function_1.pipe)(
|
|
20
|
-
// We have to try to decode the array as an array of unknown first in order to get different error messages for the two cases.
|
|
21
|
-
// If we wrapped the whole t.array(ContentCodec) with 'withMessage' then the provided error message would override any error messages
|
|
22
|
-
// produced by the ContentCodec and we want to have a detailed inside into which field failed to validate.
|
|
23
|
-
(0, io_ts_types_1.withMessage)(t.array(t.unknown), () => errors_1.SharedSliceErrors.InvalidItemsArray(sliceName)).validate(u, c), E.chain((arr) => t.array(ContentCodec).validate(arr, c))), t.identity);
|
|
24
|
-
};
|
|
25
|
-
exports.SharedSliceItems = SharedSliceItems;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import * as t from "io-ts";
|
|
2
|
-
import { SharedSlice as SharedSliceCustomType } from "../../../../../../customtypes";
|
|
3
|
-
export declare type SharedSliceType = {
|
|
4
|
-
slice_type: string;
|
|
5
|
-
data: SharedSliceCustomType;
|
|
6
|
-
};
|
|
7
|
-
/**
|
|
8
|
-
* 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.
|
|
9
|
-
* @param slices all the SharedSlices from the custom type
|
|
10
|
-
*/
|
|
11
|
-
export declare const SharedSliceType: (slices: SharedSliceCustomType[]) => t.Type<SharedSliceType, string, unknown>;
|
|
@@ -1,24 +0,0 @@
|
|
|
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.type({
|
|
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;
|
|
@@ -1,11 +0,0 @@
|
|
|
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>;
|
|
@@ -1,24 +0,0 @@
|
|
|
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.type({
|
|
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;
|
|
@@ -1,9 +0,0 @@
|
|
|
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("./SharedSliceItems"), exports);
|
|
8
|
-
(0, tslib_1.__exportStar)(require("./SharedSliceType"), exports);
|
|
9
|
-
(0, tslib_1.__exportStar)(require("./SharedSliceVariation"), exports);
|
|
@@ -1,6 +0,0 @@
|
|
|
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);
|
|
@@ -1,339 +0,0 @@
|
|
|
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>;
|
|
@@ -1,11 +0,0 @@
|
|
|
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;
|