@prismicio/types-internal 2.2.0-alpha.10 → 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/UUID.d.ts +7 -0
- package/lib/common/UUID.js +8 -0
- package/lib/content/fields/slices/Slice/RepeatableContent.js +0 -1
- package/lib/import/converters/Document.d.ts +1 -2
- package/lib/import/converters/Document.js +2 -0
- package/lib/import/converters/fields/Slices/SharedSlice.d.ts +4 -0
- package/lib/import/converters/fields/Slices/SharedSlice.js +19 -0
- package/lib/import/converters/fields/Slices/SharedSliceContent.d.ts +10 -0
- package/lib/import/converters/fields/Slices/SharedSliceContent.js +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/index.d.ts +1 -0
- package/lib/import/converters/fields/index.js +1 -0
- package/lib/import/converters/fields/nestable/Nestable.d.ts +2 -2
- package/lib/import/validators/fields/ImportField.d.ts +11 -1
- package/lib/import/validators/fields/ImportField.js +6 -1
- 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/nestable/Image.d.ts +30 -47
- package/lib/import/validators/fields/nestable/Image.js +22 -53
- package/lib/utils/io-ts.d.ts +2 -0
- package/lib/utils/io-ts.js +22 -0
- package/lib/validators/BasicTypes.d.ts +1 -0
- package/lib/validators/BasicTypes.js +2 -1
- package/lib/validators/NonEmptyString.js +2 -1
- package/package.json +4 -2
- package/src/common/UUID.ts +18 -0
- package/src/content/fields/slices/Slice/RepeatableContent.ts +0 -1
- package/src/import/converters/Document.ts +8 -3
- 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/index.ts +1 -0
- package/src/import/converters/fields/nestable/Nestable.ts +2 -2
- package/src/import/validators/fields/ImportField.ts +7 -2
- 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/utils/io-ts.ts +29 -0
- package/src/validators/BasicTypes.ts +5 -0
- package/src/validators/NonEmptyString.ts +4 -4
|
@@ -0,0 +1,339 @@
|
|
|
1
|
+
import * as E from "fp-ts/Either";
|
|
2
|
+
import type { SharedSlice as SharedSliceCustomType } from "../../../../../customtypes";
|
|
3
|
+
import type { Variation } from "../../../../../customtypes";
|
|
4
|
+
export declare const findSlice: (slices: SharedSliceCustomType[]) => (sliceId: string) => E.Either<string, {
|
|
5
|
+
id: string;
|
|
6
|
+
type: "SharedSlice";
|
|
7
|
+
name: string;
|
|
8
|
+
variations: readonly ({
|
|
9
|
+
id: string;
|
|
10
|
+
name: string;
|
|
11
|
+
description: string;
|
|
12
|
+
imageUrl: string;
|
|
13
|
+
docURL: string;
|
|
14
|
+
version: string;
|
|
15
|
+
} & {
|
|
16
|
+
display?: string;
|
|
17
|
+
primary?: {
|
|
18
|
+
[x: string]: ({
|
|
19
|
+
type: "Boolean";
|
|
20
|
+
} & {
|
|
21
|
+
config?: {
|
|
22
|
+
label?: string | null | undefined;
|
|
23
|
+
default_value?: boolean;
|
|
24
|
+
placeholder_true?: string;
|
|
25
|
+
placeholder_false?: string;
|
|
26
|
+
};
|
|
27
|
+
}) | ({
|
|
28
|
+
type: "Color";
|
|
29
|
+
} & {
|
|
30
|
+
fieldset?: string | null | undefined;
|
|
31
|
+
config?: {
|
|
32
|
+
label?: string | null | undefined;
|
|
33
|
+
placeholder?: string;
|
|
34
|
+
};
|
|
35
|
+
}) | ({
|
|
36
|
+
type: "Date";
|
|
37
|
+
} & {
|
|
38
|
+
fieldset?: string | null | undefined;
|
|
39
|
+
config?: {
|
|
40
|
+
label?: string | null | undefined;
|
|
41
|
+
placeholder?: string;
|
|
42
|
+
default?: string;
|
|
43
|
+
};
|
|
44
|
+
}) | ({
|
|
45
|
+
type: "Embed";
|
|
46
|
+
} & {
|
|
47
|
+
fieldset?: string | null | undefined;
|
|
48
|
+
config?: {
|
|
49
|
+
label?: string | null | undefined;
|
|
50
|
+
placeholder?: string;
|
|
51
|
+
useAsTitle?: boolean;
|
|
52
|
+
};
|
|
53
|
+
}) | ({
|
|
54
|
+
type: "GeoPoint";
|
|
55
|
+
} & {
|
|
56
|
+
fieldset?: string | null | undefined;
|
|
57
|
+
config?: {
|
|
58
|
+
label?: string | null | undefined;
|
|
59
|
+
};
|
|
60
|
+
}) | ({
|
|
61
|
+
type: "Image";
|
|
62
|
+
} & {
|
|
63
|
+
fieldset?: string | null | undefined;
|
|
64
|
+
config?: {
|
|
65
|
+
label?: string | null | undefined;
|
|
66
|
+
placeholder?: string;
|
|
67
|
+
constraint?: {
|
|
68
|
+
width?: number | null;
|
|
69
|
+
height?: number | null;
|
|
70
|
+
};
|
|
71
|
+
thumbnails?: readonly ({
|
|
72
|
+
name: string;
|
|
73
|
+
} & {
|
|
74
|
+
width?: number | null;
|
|
75
|
+
height?: number | null;
|
|
76
|
+
})[];
|
|
77
|
+
};
|
|
78
|
+
}) | ({
|
|
79
|
+
type: "IntegrationFields";
|
|
80
|
+
} & {
|
|
81
|
+
fieldset?: string | null | undefined;
|
|
82
|
+
config?: {
|
|
83
|
+
label?: string | null | undefined;
|
|
84
|
+
placeholder?: string;
|
|
85
|
+
catalog?: string;
|
|
86
|
+
};
|
|
87
|
+
}) | ({
|
|
88
|
+
type: "Link";
|
|
89
|
+
} & {
|
|
90
|
+
fieldset?: string | null | undefined;
|
|
91
|
+
config?: {
|
|
92
|
+
label?: string | null | undefined;
|
|
93
|
+
useAsTitle?: boolean;
|
|
94
|
+
placeholder?: string;
|
|
95
|
+
select?: "media" | "document" | "web" | null;
|
|
96
|
+
customtypes?: readonly string[];
|
|
97
|
+
masks?: readonly string[];
|
|
98
|
+
tags?: readonly string[];
|
|
99
|
+
allowTargetBlank?: boolean;
|
|
100
|
+
};
|
|
101
|
+
}) | ({
|
|
102
|
+
type: "Number";
|
|
103
|
+
} & {
|
|
104
|
+
fieldset?: string | null | undefined;
|
|
105
|
+
config?: {
|
|
106
|
+
label?: string | null | undefined;
|
|
107
|
+
placeholder?: string;
|
|
108
|
+
min?: number;
|
|
109
|
+
max?: number;
|
|
110
|
+
step?: number;
|
|
111
|
+
};
|
|
112
|
+
}) | ({
|
|
113
|
+
type: "Range";
|
|
114
|
+
} & {
|
|
115
|
+
fieldset?: string | null | undefined;
|
|
116
|
+
config?: {
|
|
117
|
+
label?: string | null | undefined;
|
|
118
|
+
placeholder?: string;
|
|
119
|
+
min?: number;
|
|
120
|
+
max?: number;
|
|
121
|
+
step?: number;
|
|
122
|
+
};
|
|
123
|
+
}) | ({
|
|
124
|
+
type: "StructuredText";
|
|
125
|
+
} & {
|
|
126
|
+
fieldset?: string | null | undefined;
|
|
127
|
+
config?: {
|
|
128
|
+
label?: string | null | undefined;
|
|
129
|
+
placeholder?: string;
|
|
130
|
+
useAsTitle?: boolean;
|
|
131
|
+
single?: string;
|
|
132
|
+
multi?: string;
|
|
133
|
+
imageConstraint?: {
|
|
134
|
+
width?: number | null;
|
|
135
|
+
height?: number | null;
|
|
136
|
+
};
|
|
137
|
+
labels?: readonly string[];
|
|
138
|
+
allowTargetBlank?: boolean;
|
|
139
|
+
};
|
|
140
|
+
}) | ({
|
|
141
|
+
type: "Select";
|
|
142
|
+
} & {
|
|
143
|
+
fieldset?: string | null | undefined;
|
|
144
|
+
config?: {
|
|
145
|
+
label?: string | null | undefined;
|
|
146
|
+
placeholder?: string;
|
|
147
|
+
default_value?: string;
|
|
148
|
+
options?: readonly string[];
|
|
149
|
+
};
|
|
150
|
+
}) | ({
|
|
151
|
+
type: "Separator";
|
|
152
|
+
} & {
|
|
153
|
+
config?: {
|
|
154
|
+
label?: string | null | undefined;
|
|
155
|
+
};
|
|
156
|
+
}) | ({
|
|
157
|
+
type: "Text";
|
|
158
|
+
} & {
|
|
159
|
+
fieldset?: string | null | undefined;
|
|
160
|
+
config?: {
|
|
161
|
+
label?: string | null | undefined;
|
|
162
|
+
useAsTitle?: boolean;
|
|
163
|
+
placeholder?: string;
|
|
164
|
+
};
|
|
165
|
+
}) | ({
|
|
166
|
+
type: "Timestamp";
|
|
167
|
+
} & {
|
|
168
|
+
fieldset?: string | null | undefined;
|
|
169
|
+
config?: {
|
|
170
|
+
label?: string | null | undefined;
|
|
171
|
+
placeholder?: string;
|
|
172
|
+
default?: string;
|
|
173
|
+
};
|
|
174
|
+
});
|
|
175
|
+
};
|
|
176
|
+
items?: {
|
|
177
|
+
[x: string]: ({
|
|
178
|
+
type: "Boolean";
|
|
179
|
+
} & {
|
|
180
|
+
config?: {
|
|
181
|
+
label?: string | null | undefined;
|
|
182
|
+
default_value?: boolean;
|
|
183
|
+
placeholder_true?: string;
|
|
184
|
+
placeholder_false?: string;
|
|
185
|
+
};
|
|
186
|
+
}) | ({
|
|
187
|
+
type: "Color";
|
|
188
|
+
} & {
|
|
189
|
+
fieldset?: string | null | undefined;
|
|
190
|
+
config?: {
|
|
191
|
+
label?: string | null | undefined;
|
|
192
|
+
placeholder?: string;
|
|
193
|
+
};
|
|
194
|
+
}) | ({
|
|
195
|
+
type: "Date";
|
|
196
|
+
} & {
|
|
197
|
+
fieldset?: string | null | undefined;
|
|
198
|
+
config?: {
|
|
199
|
+
label?: string | null | undefined;
|
|
200
|
+
placeholder?: string;
|
|
201
|
+
default?: string;
|
|
202
|
+
};
|
|
203
|
+
}) | ({
|
|
204
|
+
type: "Embed";
|
|
205
|
+
} & {
|
|
206
|
+
fieldset?: string | null | undefined;
|
|
207
|
+
config?: {
|
|
208
|
+
label?: string | null | undefined;
|
|
209
|
+
placeholder?: string;
|
|
210
|
+
useAsTitle?: boolean;
|
|
211
|
+
};
|
|
212
|
+
}) | ({
|
|
213
|
+
type: "GeoPoint";
|
|
214
|
+
} & {
|
|
215
|
+
fieldset?: string | null | undefined;
|
|
216
|
+
config?: {
|
|
217
|
+
label?: string | null | undefined;
|
|
218
|
+
};
|
|
219
|
+
}) | ({
|
|
220
|
+
type: "Image";
|
|
221
|
+
} & {
|
|
222
|
+
fieldset?: string | null | undefined;
|
|
223
|
+
config?: {
|
|
224
|
+
label?: string | null | undefined;
|
|
225
|
+
placeholder?: string;
|
|
226
|
+
constraint?: {
|
|
227
|
+
width?: number | null;
|
|
228
|
+
height?: number | null;
|
|
229
|
+
};
|
|
230
|
+
thumbnails?: readonly ({
|
|
231
|
+
name: string;
|
|
232
|
+
} & {
|
|
233
|
+
width?: number | null;
|
|
234
|
+
height?: number | null;
|
|
235
|
+
})[];
|
|
236
|
+
};
|
|
237
|
+
}) | ({
|
|
238
|
+
type: "IntegrationFields";
|
|
239
|
+
} & {
|
|
240
|
+
fieldset?: string | null | undefined;
|
|
241
|
+
config?: {
|
|
242
|
+
label?: string | null | undefined;
|
|
243
|
+
placeholder?: string;
|
|
244
|
+
catalog?: string;
|
|
245
|
+
};
|
|
246
|
+
}) | ({
|
|
247
|
+
type: "Link";
|
|
248
|
+
} & {
|
|
249
|
+
fieldset?: string | null | undefined;
|
|
250
|
+
config?: {
|
|
251
|
+
label?: string | null | undefined;
|
|
252
|
+
useAsTitle?: boolean;
|
|
253
|
+
placeholder?: string;
|
|
254
|
+
select?: "media" | "document" | "web" | null;
|
|
255
|
+
customtypes?: readonly string[];
|
|
256
|
+
masks?: readonly string[];
|
|
257
|
+
tags?: readonly string[];
|
|
258
|
+
allowTargetBlank?: boolean;
|
|
259
|
+
};
|
|
260
|
+
}) | ({
|
|
261
|
+
type: "Number";
|
|
262
|
+
} & {
|
|
263
|
+
fieldset?: string | null | undefined;
|
|
264
|
+
config?: {
|
|
265
|
+
label?: string | null | undefined;
|
|
266
|
+
placeholder?: string;
|
|
267
|
+
min?: number;
|
|
268
|
+
max?: number;
|
|
269
|
+
step?: number;
|
|
270
|
+
};
|
|
271
|
+
}) | ({
|
|
272
|
+
type: "Range";
|
|
273
|
+
} & {
|
|
274
|
+
fieldset?: string | null | undefined;
|
|
275
|
+
config?: {
|
|
276
|
+
label?: string | null | undefined;
|
|
277
|
+
placeholder?: string;
|
|
278
|
+
min?: number;
|
|
279
|
+
max?: number;
|
|
280
|
+
step?: number;
|
|
281
|
+
};
|
|
282
|
+
}) | ({
|
|
283
|
+
type: "StructuredText";
|
|
284
|
+
} & {
|
|
285
|
+
fieldset?: string | null | undefined;
|
|
286
|
+
config?: {
|
|
287
|
+
label?: string | null | undefined;
|
|
288
|
+
placeholder?: string;
|
|
289
|
+
useAsTitle?: boolean;
|
|
290
|
+
single?: string;
|
|
291
|
+
multi?: string;
|
|
292
|
+
imageConstraint?: {
|
|
293
|
+
width?: number | null;
|
|
294
|
+
height?: number | null;
|
|
295
|
+
};
|
|
296
|
+
labels?: readonly string[];
|
|
297
|
+
allowTargetBlank?: boolean;
|
|
298
|
+
};
|
|
299
|
+
}) | ({
|
|
300
|
+
type: "Select";
|
|
301
|
+
} & {
|
|
302
|
+
fieldset?: string | null | undefined;
|
|
303
|
+
config?: {
|
|
304
|
+
label?: string | null | undefined;
|
|
305
|
+
placeholder?: string;
|
|
306
|
+
default_value?: string;
|
|
307
|
+
options?: readonly string[];
|
|
308
|
+
};
|
|
309
|
+
}) | ({
|
|
310
|
+
type: "Separator";
|
|
311
|
+
} & {
|
|
312
|
+
config?: {
|
|
313
|
+
label?: string | null | undefined;
|
|
314
|
+
};
|
|
315
|
+
}) | ({
|
|
316
|
+
type: "Text";
|
|
317
|
+
} & {
|
|
318
|
+
fieldset?: string | null | undefined;
|
|
319
|
+
config?: {
|
|
320
|
+
label?: string | null | undefined;
|
|
321
|
+
useAsTitle?: boolean;
|
|
322
|
+
placeholder?: string;
|
|
323
|
+
};
|
|
324
|
+
}) | ({
|
|
325
|
+
type: "Timestamp";
|
|
326
|
+
} & {
|
|
327
|
+
fieldset?: string | null | undefined;
|
|
328
|
+
config?: {
|
|
329
|
+
label?: string | null | undefined;
|
|
330
|
+
placeholder?: string;
|
|
331
|
+
default?: string;
|
|
332
|
+
};
|
|
333
|
+
});
|
|
334
|
+
};
|
|
335
|
+
})[];
|
|
336
|
+
} & {
|
|
337
|
+
description?: string;
|
|
338
|
+
}>;
|
|
339
|
+
export declare const findSliceVariation: (slice: SharedSliceCustomType) => (variation: string) => E.Either<string, Variation>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.findSliceVariation = exports.findSlice = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const E = (0, tslib_1.__importStar)(require("fp-ts/Either"));
|
|
6
|
+
const function_1 = require("fp-ts/function");
|
|
7
|
+
const errors_1 = require("./errors");
|
|
8
|
+
const findSlice = (slices) => (sliceId) => (0, function_1.pipe)(slices.find((slice) => slice.id === sliceId), E.fromNullable(errors_1.SharedSliceErrors.SliceTypeNotFound(sliceId)));
|
|
9
|
+
exports.findSlice = findSlice;
|
|
10
|
+
const findSliceVariation = (slice) => (variation) => (0, function_1.pipe)(slice.variations.find((v) => v.id === variation), E.fromNullable(errors_1.SharedSliceErrors.VariationNotFound(variation, slice.id)));
|
|
11
|
+
exports.findSliceVariation = findSliceVariation;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./ImportSlices";
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { SharedSlice as SharedSliceCustomType, StaticSlices } from "../../../../customtypes";
|
|
2
|
+
import type { SharedSlice, SharedSliceId } from "./SharedSlice";
|
|
3
|
+
export declare const extractSupportedSlices: (staticSlices: StaticSlices) => SharedSliceCustomType[];
|
|
4
|
+
export declare const findImportSharedSliceDuplicateIds: (slices: SharedSlice[]) => SharedSliceId[];
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.findImportSharedSliceDuplicateIds = exports.extractSupportedSlices = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const A = (0, tslib_1.__importStar)(require("fp-ts/Array"));
|
|
6
|
+
const function_1 = require("fp-ts/function");
|
|
7
|
+
const O = (0, tslib_1.__importStar)(require("fp-ts/Option"));
|
|
8
|
+
const customtypes_1 = require("../../../../customtypes");
|
|
9
|
+
// Extracts all supported slices from the static slices object
|
|
10
|
+
// For now we only support the SharedSlice, if we want to support other slices in the future, we have to add them here
|
|
11
|
+
const extractSupportedSlices = (staticSlices) => {
|
|
12
|
+
var _a, _b;
|
|
13
|
+
return (0, function_1.pipe)(Object.values((_b = (_a = staticSlices.config) === null || _a === void 0 ? void 0 : _a.choices) !== null && _b !== void 0 ? _b : {}).map((slice) => (0, function_1.pipe)(customtypes_1.SharedSlice.decode(slice), O.fromEither)), A.compact);
|
|
14
|
+
};
|
|
15
|
+
exports.extractSupportedSlices = extractSupportedSlices;
|
|
16
|
+
const findImportSharedSliceDuplicateIds = (slices) => {
|
|
17
|
+
const duplicatesMap = slices.reduce((acc, { id }) => {
|
|
18
|
+
var _a;
|
|
19
|
+
if (id) {
|
|
20
|
+
const currentNumOfDuplicates = (_a = acc[id]) !== null && _a !== void 0 ? _a : 0;
|
|
21
|
+
return {
|
|
22
|
+
...acc,
|
|
23
|
+
[id]: acc[id] === undefined ? 0 : currentNumOfDuplicates + 1,
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
return acc;
|
|
27
|
+
}, {});
|
|
28
|
+
return Object.entries(duplicatesMap).flatMap(([id, numOfDuplicates]) => {
|
|
29
|
+
if (numOfDuplicates > 0) {
|
|
30
|
+
return [id];
|
|
31
|
+
}
|
|
32
|
+
return [];
|
|
33
|
+
});
|
|
34
|
+
};
|
|
35
|
+
exports.findImportSharedSliceDuplicateIds = findImportSharedSliceDuplicateIds;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import * as t from "io-ts";
|
|
2
|
+
import type { SharedSlice as SharedSliceCustomType } from "../../../../../customtypes";
|
|
3
|
+
import { SharedSliceContent, SharedSliceId } from "./fields";
|
|
4
|
+
export declare type SharedSlice = {
|
|
5
|
+
id: SharedSliceId | null | undefined;
|
|
6
|
+
slice_type: string;
|
|
7
|
+
name: string;
|
|
8
|
+
variation: string;
|
|
9
|
+
primary: SharedSliceContent | null | undefined;
|
|
10
|
+
items: SharedSliceContent[] | null | undefined;
|
|
11
|
+
slice_label: string | null | undefined;
|
|
12
|
+
version: string | null | undefined;
|
|
13
|
+
};
|
|
14
|
+
export declare const SharedSlice: (sharedSlices: SharedSliceCustomType[]) => t.Type<SharedSlice, SharedSlice, unknown>;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SharedSlice = 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 fields_1 = require("./fields");
|
|
10
|
+
const SharedSliceShape = t.type({
|
|
11
|
+
id: fields_1.OptionalSharedSliceId,
|
|
12
|
+
slice_type: validators_1.NonEmptyString,
|
|
13
|
+
name: validators_1.String,
|
|
14
|
+
variation: validators_1.NonEmptyString,
|
|
15
|
+
primary: t.union([t.undefined, t.null, t.record(validators_1.NonEmptyString, t.unknown)]),
|
|
16
|
+
items: t.union([
|
|
17
|
+
t.undefined,
|
|
18
|
+
t.null,
|
|
19
|
+
t.array(t.record(validators_1.NonEmptyString, t.unknown)),
|
|
20
|
+
]),
|
|
21
|
+
slice_label: t.union([t.undefined, t.null, validators_1.String]),
|
|
22
|
+
version: t.union([t.undefined, t.null, validators_1.String]),
|
|
23
|
+
});
|
|
24
|
+
const SharedSlice = (sharedSlices) => new t.Type("SharedSlice", (u) => SharedSliceShape.is(u), (u, c) => (0, function_1.pipe)(
|
|
25
|
+
// We validate the base fields that we can validate directly based on the provided 'sharedSlices'
|
|
26
|
+
t
|
|
27
|
+
.type({
|
|
28
|
+
id: fields_1.OptionalSharedSliceId,
|
|
29
|
+
slice_type: (0, fields_1.SharedSliceType)(sharedSlices),
|
|
30
|
+
slice_label: t.union([t.undefined, t.null, validators_1.String]),
|
|
31
|
+
version: t.union([t.undefined, t.null, validators_1.String]),
|
|
32
|
+
})
|
|
33
|
+
.validate(u, c), E.chain((decoded) => (0, function_1.pipe)(
|
|
34
|
+
// We validate the 'variation' field, for which we need the SharedSlice custom type retrieved in the first step
|
|
35
|
+
t
|
|
36
|
+
.type({
|
|
37
|
+
variation: (0, fields_1.SharedSliceVariation)(decoded.slice_type.data),
|
|
38
|
+
})
|
|
39
|
+
.validate(u, c), E.map(({ variation }) => ({ ...decoded, variation })))), E.chain((decoded) => {
|
|
40
|
+
var _a, _b;
|
|
41
|
+
return (0, function_1.pipe)(
|
|
42
|
+
// We validate the 'primary' and 'items' content fields, for which we need the Variation custom type retrieved in the previous step
|
|
43
|
+
t
|
|
44
|
+
.partial({
|
|
45
|
+
primary: (0, fields_1.SharedSliceContent)(decoded.slice_type.slice_type, "primary", (_a = decoded.variation.data.primary) !== null && _a !== void 0 ? _a : {}),
|
|
46
|
+
// We need to use this wrapper codec instead of using t.array(SharedSliceContent) directly in order to get proper custom error messages
|
|
47
|
+
items: (0, fields_1.SharedSliceItems)(decoded.slice_type.slice_type, (_b = decoded.variation.data.items) !== null && _b !== void 0 ? _b : {}),
|
|
48
|
+
})
|
|
49
|
+
.validate(u, c), E.map(({ primary, items }) => ({ ...decoded, primary, items })));
|
|
50
|
+
}), E.map(({ id, slice_type, variation, primary, items, slice_label, version, }) => ({
|
|
51
|
+
id,
|
|
52
|
+
slice_type: slice_type.slice_type,
|
|
53
|
+
name: slice_type.data.name,
|
|
54
|
+
variation: variation.variation,
|
|
55
|
+
primary,
|
|
56
|
+
items,
|
|
57
|
+
slice_label,
|
|
58
|
+
version: version !== null && version !== void 0 ? version : variation.data.version,
|
|
59
|
+
}))), t.identity);
|
|
60
|
+
exports.SharedSlice = SharedSlice;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SharedSliceErrors = void 0;
|
|
4
|
+
exports.SharedSliceErrors = {
|
|
5
|
+
SliceTypeNotFound: (slice_type) => `Shared slice '${slice_type}' not found in document's custom type`,
|
|
6
|
+
VariationNotFound: (variation, slice_type) => `Variation '${variation}' not found for Slice '${slice_type}'`,
|
|
7
|
+
InvalidItemsArray: (slice_type) => `Invalid value for 'items' array in Shared Slice '${slice_type}'. Must be an array of key-value records.`,
|
|
8
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OptionalSharedSliceId = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const t = (0, tslib_1.__importStar)(require("io-ts"));
|
|
6
|
+
const SharedSliceId_1 = require("./SharedSliceId");
|
|
7
|
+
// Wrapping the 'SharedSliceId' codec in an optional codec here for the sake of error reporting.
|
|
8
|
+
// When using t.union([t.undefined, t.null, SharedSliceId]) we get a nested error context
|
|
9
|
+
// with the actual decoding error at position 2 in the context array.
|
|
10
|
+
// To avoid mutating the error context we create this new wrapper codec so that the error context will always have desired depth.
|
|
11
|
+
exports.OptionalSharedSliceId = new t.Type("OptionalSharedSliceId", (u) => u === null || u === undefined || SharedSliceId_1.SharedSliceId.is(u), (u, c) => {
|
|
12
|
+
if (u === null || u === undefined)
|
|
13
|
+
return t.success(u);
|
|
14
|
+
return SharedSliceId_1.SharedSliceId.validate(u, c);
|
|
15
|
+
}, t.identity);
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import * as t from "io-ts";
|
|
2
|
+
import { WidgetKey } from "../../../../../../../common";
|
|
3
|
+
import type { NestableWidget } from "../../../../../../../customtypes";
|
|
4
|
+
import type { ImportNestable } from "../../../../nestable";
|
|
5
|
+
/**
|
|
6
|
+
* Represents the object in the 'primary' field or a single item in the 'items' array in the SharedSlice.
|
|
7
|
+
*/
|
|
8
|
+
export declare type SharedSliceContent = Record<WidgetKey, ImportNestable>;
|
|
9
|
+
/**
|
|
10
|
+
* Builds the decoder for a single entry in the 'primary' field or a single item in the 'items' array in the SharedSlice.
|
|
11
|
+
*
|
|
12
|
+
* @param sliceName name of the slice - used for error reporting in order to know which slice is being decoded
|
|
13
|
+
* @param sliceContentField 'primary' or 'items' - used for error reporting in order to know which field of the slice is being decoded
|
|
14
|
+
* @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
|
|
15
|
+
* @constructor
|
|
16
|
+
*/
|
|
17
|
+
export declare const SharedSliceContent: (sliceName: string, sliceContentField: "primary" | "items", sliceFieldModels: Record<WidgetKey, NestableWidget>) => t.Type<SharedSliceContent, SharedSliceContent, unknown>;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SharedSliceContent = 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/lib/function");
|
|
7
|
+
const t = (0, tslib_1.__importStar)(require("io-ts"));
|
|
8
|
+
const io_ts_types_1 = require("io-ts-types");
|
|
9
|
+
const common_1 = require("../../../../../../../common");
|
|
10
|
+
const io_ts_1 = require("../../../../../../../utils/io-ts");
|
|
11
|
+
const errors_1 = require("./errors");
|
|
12
|
+
const SharedSliceContentEntry_1 = require("./SharedSliceContentEntry");
|
|
13
|
+
/**
|
|
14
|
+
* Builds the decoder for the raw content object in the 'primary' field or a single item in the 'items' array in the SharedSlice.
|
|
15
|
+
*
|
|
16
|
+
* @param sliceName name of the slice - used for error reporting in order to know which slice is being decoded
|
|
17
|
+
* @param sliceContentField 'primary' or 'items' - used for error reporting in order to know which field of the slice is being decoded
|
|
18
|
+
*/
|
|
19
|
+
const RawContent = (sliceName, sliceContentField) => (0, io_ts_types_1.withMessage)(t.record(common_1.WidgetKey, t.unknown), () => errors_1.SharedSliceContentErrors.InvalidSliceItemContent(sliceName, sliceContentField));
|
|
20
|
+
/**
|
|
21
|
+
* Builds the decoder for a single entry in the 'primary' field or a single item in the 'items' array in the SharedSlice.
|
|
22
|
+
*
|
|
23
|
+
* @param sliceName name of the slice - used for error reporting in order to know which slice is being decoded
|
|
24
|
+
* @param sliceContentField 'primary' or 'items' - used for error reporting in order to know which field of the slice is being decoded
|
|
25
|
+
* @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
|
|
26
|
+
* @constructor
|
|
27
|
+
*/
|
|
28
|
+
const SharedSliceContent = (sliceName, sliceContentField, sliceFieldModels) => new t.Type("SharedSliceContent", (u) => t.record(common_1.WidgetKey, t.unknown).is(u), (u, c) => (0, function_1.pipe)(
|
|
29
|
+
// We first decode the raw content object in the shape of Record<WidgetKey, unknown>
|
|
30
|
+
RawContent(sliceName, sliceContentField).validate(u, c), E.chain((rawContent) => (0, function_1.pipe)(
|
|
31
|
+
// We split the object into entries because there is no easy other way to decode each value with a different codec
|
|
32
|
+
Object.entries(rawContent).map((entry) => (0, SharedSliceContentEntry_1.SharedSliceContentEntry)(sliceName, sliceContentField, sliceFieldModels).validate(entry, c)),
|
|
33
|
+
// We get a validation result for each entry in the content object (t.Validation<SharedSliceContentEntry>[]),
|
|
34
|
+
// however we want to get a single validation result for the whole array of entries (t.Validation<SharedSliceContentEntry[]>).
|
|
35
|
+
io_ts_1.combineValidationResults,
|
|
36
|
+
// We build the object back from entries if all decoded successfully
|
|
37
|
+
E.map((entries) => entries.reduce((acc, [key, value]) => ({ ...acc, [key]: value }), {}))))), t.identity);
|
|
38
|
+
exports.SharedSliceContent = SharedSliceContent;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import * as t from "io-ts";
|
|
2
|
+
import { WidgetKey } from "../../../../../../../common";
|
|
3
|
+
import type { NestableWidget } from "../../../../../../../customtypes";
|
|
4
|
+
import { ImportNestable } from "../../../../nestable";
|
|
5
|
+
export declare type SharedSliceContentEntry = [WidgetKey, ImportNestable];
|
|
6
|
+
/**
|
|
7
|
+
* 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.
|
|
8
|
+
*
|
|
9
|
+
* For example, given the following slice:
|
|
10
|
+
* {
|
|
11
|
+
* "slice_type": "my_slice",
|
|
12
|
+
* "variation": "default",
|
|
13
|
+
* "primary": {
|
|
14
|
+
* "slice_text": "abc", // This is one entry
|
|
15
|
+
* "slice_text2": "def: // This is another entry
|
|
16
|
+
* },
|
|
17
|
+
* "items": [
|
|
18
|
+
* {
|
|
19
|
+
* "slice_number1": 0, // This is one entry
|
|
20
|
+
* "slice_number2": 1 // And this is yet another entry
|
|
21
|
+
* }
|
|
22
|
+
* ]
|
|
23
|
+
* }
|
|
24
|
+
*
|
|
25
|
+
* The 'primary' object is converted to following entries to be decoded:
|
|
26
|
+
* [
|
|
27
|
+
* ["slice_text", "abc"],
|
|
28
|
+
* ["slice_text2", "def"]
|
|
29
|
+
* ]
|
|
30
|
+
* and the first item in the 'items' array is converted to following entries to be decoded:
|
|
31
|
+
* [
|
|
32
|
+
* ["slice_number1", 0],
|
|
33
|
+
* ["slice_number2", 1]
|
|
34
|
+
* ]
|
|
35
|
+
*
|
|
36
|
+
* 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.
|
|
37
|
+
* 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.
|
|
38
|
+
*
|
|
39
|
+
* @param sliceName name of the slice - used for error reporting in order to know which slice is being decoded
|
|
40
|
+
* @param sliceContentField 'primary' or 'items' - used for error reporting in order to know which field of the slice is being decoded
|
|
41
|
+
* @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
|
|
42
|
+
*/
|
|
43
|
+
export declare const SharedSliceContentEntry: (sliceName: string, sliceContentField: "primary" | "items", sliceFieldModels: Record<WidgetKey, NestableWidget>) => t.Type<SharedSliceContentEntry, SharedSliceContentEntry, unknown>;
|