@prismicio/types-internal 2.2.0-alpha.11 → 2.2.0-alpha.12

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.
Files changed (49) hide show
  1. package/package.json +1 -1
  2. package/lib/import/converters/fields/Slices/SliceItem.d.ts +0 -4
  3. package/lib/import/converters/fields/Slices/SliceItem.js +0 -24
  4. package/lib/import/validators/fields/ImportSlices/ImportSliceId.d.ts +0 -9
  5. package/lib/import/validators/fields/ImportSlices/ImportSliceId.js +0 -43
  6. package/lib/import/validators/fields/ImportSlices/ImportSliceItem.d.ts +0 -24
  7. package/lib/import/validators/fields/ImportSlices/ImportSliceItem.js +0 -87
  8. package/lib/import/validators/fields/ImportSlices/ImportSliceItemContent.d.ts +0 -12
  9. package/lib/import/validators/fields/ImportSlices/ImportSliceItemContent.js +0 -41
  10. package/lib/import/validators/fields/Slices/SharedSlice/SharedSlice.d.ts +0 -14
  11. package/lib/import/validators/fields/Slices/SharedSlice/SharedSlice.js +0 -60
  12. package/lib/import/validators/fields/Slices/SharedSlice/errors.d.ts +0 -5
  13. package/lib/import/validators/fields/Slices/SharedSlice/errors.js +0 -8
  14. package/lib/import/validators/fields/Slices/SharedSlice/fields/OptionalSharedSliceId.d.ts +0 -2
  15. package/lib/import/validators/fields/Slices/SharedSlice/fields/OptionalSharedSliceId.js +0 -15
  16. package/lib/import/validators/fields/Slices/SharedSlice/fields/SharedSliceContent/SharedSliceContent.d.ts +0 -17
  17. package/lib/import/validators/fields/Slices/SharedSlice/fields/SharedSliceContent/SharedSliceContent.js +0 -38
  18. package/lib/import/validators/fields/Slices/SharedSlice/fields/SharedSliceContent/SharedSliceContentEntry.d.ts +0 -43
  19. package/lib/import/validators/fields/Slices/SharedSlice/fields/SharedSliceContent/SharedSliceContentEntry.js +0 -69
  20. package/lib/import/validators/fields/Slices/SharedSlice/fields/SharedSliceContent/errors.d.ts +0 -5
  21. package/lib/import/validators/fields/Slices/SharedSlice/fields/SharedSliceContent/errors.js +0 -9
  22. package/lib/import/validators/fields/Slices/SharedSlice/fields/SharedSliceContent/index.d.ts +0 -2
  23. package/lib/import/validators/fields/Slices/SharedSlice/fields/SharedSliceContent/index.js +0 -5
  24. package/lib/import/validators/fields/Slices/SharedSlice/fields/SharedSliceContent/types.d.ts +0 -1
  25. package/lib/import/validators/fields/Slices/SharedSlice/fields/SharedSliceContent/types.js +0 -2
  26. package/lib/import/validators/fields/Slices/SharedSlice/fields/SharedSliceId.d.ts +0 -9
  27. package/lib/import/validators/fields/Slices/SharedSlice/fields/SharedSliceId.js +0 -39
  28. package/lib/import/validators/fields/Slices/SharedSlice/fields/SharedSliceItems.d.ts +0 -11
  29. package/lib/import/validators/fields/Slices/SharedSlice/fields/SharedSliceItems.js +0 -25
  30. package/lib/import/validators/fields/Slices/SharedSlice/fields/SharedSliceType.d.ts +0 -11
  31. package/lib/import/validators/fields/Slices/SharedSlice/fields/SharedSliceType.js +0 -24
  32. package/lib/import/validators/fields/Slices/SharedSlice/fields/SharedSliceVariation.d.ts +0 -11
  33. package/lib/import/validators/fields/Slices/SharedSlice/fields/SharedSliceVariation.js +0 -24
  34. package/lib/import/validators/fields/Slices/SharedSlice/fields/index.d.ts +0 -6
  35. package/lib/import/validators/fields/Slices/SharedSlice/fields/index.js +0 -9
  36. package/lib/import/validators/fields/Slices/SharedSlice/index.d.ts +0 -3
  37. package/lib/import/validators/fields/Slices/SharedSlice/index.js +0 -6
  38. package/lib/import/validators/fields/Slices/SharedSlice/utils.d.ts +0 -339
  39. package/lib/import/validators/fields/Slices/SharedSlice/utils.js +0 -11
  40. package/lib/import/validators/fields/Slices/Slices.d.ts +0 -8
  41. package/lib/import/validators/fields/Slices/Slices.js +0 -29
  42. package/lib/import/validators/fields/Slices/index.d.ts +0 -1
  43. package/lib/import/validators/fields/Slices/index.js +0 -4
  44. package/lib/import/validators/fields/Slices/utils.d.ts +0 -4
  45. package/lib/import/validators/fields/Slices/utils.js +0 -35
  46. package/lib/import/validators/fields/Slices.d.ts +0 -4
  47. package/lib/import/validators/fields/Slices.js +0 -12
  48. package/lib/import/validators/fields/nestable/Image.d.ts +0 -45
  49. package/lib/import/validators/fields/nestable/Image.js +0 -45
@@ -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,6 +0,0 @@
1
- export * from "./OptionalSharedSliceId";
2
- export * from "./SharedSliceContent";
3
- export * from "./SharedSliceId";
4
- export * from "./SharedSliceItems";
5
- export * from "./SharedSliceType";
6
- export * from "./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,3 +0,0 @@
1
- export * from "./errors";
2
- export * from "./fields";
3
- export * from "./SharedSlice";
@@ -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;
@@ -1,8 +0,0 @@
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>>;
@@ -1,29 +0,0 @@
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;
@@ -1 +0,0 @@
1
- export * from "./Slices";
@@ -1,4 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- (0, tslib_1.__exportStar)(require("./Slices"), exports);
@@ -1,4 +0,0 @@
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[];
@@ -1,35 +0,0 @@
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;
@@ -1,4 +0,0 @@
1
- import * as t from "io-ts";
2
- import { UUID } from "io-ts-types";
3
- export declare type SliceId = `${string}$${UUID}`;
4
- export declare const SliceId: t.Type<string, string, unknown>;
@@ -1,12 +0,0 @@
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));