@prismicio/types-internal 2.5.0-alpha.4 → 2.6.0

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/README.md CHANGED
@@ -1,15 +1,3 @@
1
- <!--
2
-
3
- TODO: Go through all "TODO" comments in the project
4
-
5
- TODO: Replace all on all files (README.md, CONTRIBUTING.md, bug_report.md, package.json):
6
- - package_name
7
- - package_description
8
- - github_org_slash_github_repo
9
- - github_repo
10
-
11
- -->
12
-
13
1
  # @prismicio/types-internal
14
2
 
15
3
  [![npm version][npm-version-src]][npm-version-href]
@@ -19,21 +7,7 @@ TODO: Replace all on all files (README.md, CONTRIBUTING.md, bug_report.md, packa
19
7
  [![Conventional Commits][conventional-commits-src]][conventional-commits-href]
20
8
  [![License][license-src]][license-href]
21
9
 
22
- <!-- TODO: Replacing link to Prismic with [Prismic][prismic] is useful here -->
23
-
24
- Prismic types for Custom Types and Prismic Data.
25
-
26
- <!--
27
-
28
- TODO: Create a small list of package features:
29
-
30
- - 🤔 &nbsp;A useful feature;
31
- - 🥴 &nbsp;Another useful feature;
32
- - 🙃 &nbsp;A final useful feature.
33
-
34
- Non-breaking space: &nbsp; are here on purpose to fix emoji rendering on certain systems.
35
-
36
- -->
10
+ A library that provides TypeScript types and runtime parsers for Prismic data. It handles models and content in the editor format. It is used in many Prismic TypeScript packages.
37
11
 
38
12
  ## Install
39
13
 
@@ -43,38 +17,36 @@ npm install @prismicio/types-internal
43
17
 
44
18
  ## Documentation
45
19
 
46
- To discover what's new on this package check out [the changelog][changelog]. For full documentation, visit the [official Prismic documentation][prismic-docs].
20
+ To discover what's new on this package check out [the changelog][changelog].
47
21
 
48
22
  ## Contributing
49
23
 
50
24
  Whether you're helping us fix bugs, improve the docs, or spread the word, we'd love to have you as part of the Prismic developer community!
51
25
 
52
- **Asking a question**: [Open a new topic][forum-question] on our community forum explaining what you want to achieve / your question. Our support team will get back to you shortly.
53
-
54
26
  **Reporting a bug**: [Open an issue][repo-bug-report] explaining your application's setup and the bug you're encountering.
55
27
 
56
28
  **Suggesting an improvement**: [Open an issue][repo-feature-request] explaining your improvement or feature so we can discuss and learn more.
57
29
 
58
30
  **Submitting code changes**: For small fixes, feel free to [open a pull request][repo-pull-requests] with a description of your changes. For large changes, please first [open an issue][repo-feature-request] so we can discuss if and how the changes should be implemented.
59
31
 
60
- For more clarity on this project and its structure you can also check out the detailed [CONTRIBUTING.md][contributing] document.
32
+ For more clarity on this project, check out the detailed [CONTRIBUTING.md][contributing] document.
61
33
 
62
34
  ## License
63
35
 
64
36
  ```
65
- Copyright 2013-2021 Prismic <contact@prismic.io> (https://prismic.io)
37
+ Copyright 2013-2024 Prismic <contact@prismic.io> (https://prismic.io)
66
38
 
67
- Licensed under the Apache License, Version 2.0 (the "License");
68
- you may not use this file except in compliance with the License.
69
- You may obtain a copy of the License at
39
+ Licensed under the Apache License, Version 2.0 (the "License");
40
+ you may not use this file except in compliance with the License.
41
+ You may obtain a copy of the License at
70
42
 
71
- http://www.apache.org/licenses/LICENSE-2.0
43
+ http://www.apache.org/licenses/LICENSE-2.0
72
44
 
73
- Unless required by applicable law or agreed to in writing, software
74
- distributed under the License is distributed on an "AS IS" BASIS,
75
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
76
- See the License for the specific language governing permissions and
77
- limitations under the License.
45
+ Unless required by applicable law or agreed to in writing, software
46
+ distributed under the License is distributed on an "AS IS" BASIS,
47
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
48
+ See the License for the specific language governing permissions and
49
+ limitations under the License.
78
50
  ```
79
51
 
80
52
  <!-- Links -->
@@ -15,7 +15,7 @@ export declare type GroupContent = {
15
15
  __TYPE__: typeof GroupContentType;
16
16
  value: GroupItemContent[];
17
17
  };
18
- export declare const isGroupContent: (u: unknown) => u is GroupContent;
18
+ export declare const isGroupContent: t.Is<GroupContent>;
19
19
  export declare const GroupContentDefaultValue: GroupContent;
20
20
  declare const itemLegacyReader: t.RecordC<t.StringC, t.UnknownC>;
21
21
  declare type GroupItemLegacy = t.TypeOf<typeof itemLegacyReader>;
@@ -21,10 +21,7 @@ exports.GroupContent = t.recursion("GroupContent", () => t.strict({
21
21
  __TYPE__: t.literal(exports.GroupContentType),
22
22
  value: t.array(exports.GroupItemContent),
23
23
  }));
24
- const isGroupContent = (u) => (0, utils_1.hasContentType)(u) &&
25
- u.__TYPE__ === exports.GroupContentType &&
26
- exports.GroupContent.decode(u)._tag === "Right";
27
- exports.isGroupContent = isGroupContent;
24
+ exports.isGroupContent = exports.GroupContent.is;
28
25
  exports.GroupContentDefaultValue = {
29
26
  __TYPE__: exports.GroupContentType,
30
27
  value: [],
@@ -0,0 +1,727 @@
1
+ import * as t from "io-ts";
2
+ export declare const Span: t.UnionC<[t.ExactC<t.TypeC<{
3
+ data: t.UnionC<[t.IntersectionC<[t.ExactC<t.TypeC<{
4
+ __TYPE__: t.LiteralC<"ImageLink">;
5
+ }>>, t.ExactC<t.IntersectionC<[t.TypeC<{
6
+ id: t.StringC;
7
+ url: t.StringC;
8
+ height: t.StringC;
9
+ width: t.StringC;
10
+ size: t.StringC;
11
+ name: t.StringC;
12
+ kind: t.StringC;
13
+ }>, t.PartialC<{
14
+ date: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
15
+ }>]>>]>, t.IntersectionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
16
+ id: t.StringC;
17
+ url: t.StringC;
18
+ name: t.StringC;
19
+ kind: t.StringC;
20
+ size: t.StringC;
21
+ }>, t.PartialC<{
22
+ date: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
23
+ }>]>>, t.ExactC<t.IntersectionC<[t.TypeC<{
24
+ __TYPE__: t.LiteralC<"FileLink">;
25
+ }>, t.PartialC<{
26
+ size: t.StringC;
27
+ }>]>>]>, t.IntersectionC<[t.ExactC<t.TypeC<{
28
+ __TYPE__: t.LiteralC<"DocumentLink">;
29
+ }>>, t.ExactC<t.TypeC<{
30
+ id: t.Type<string, string, unknown>;
31
+ }>>]>, t.IntersectionC<[t.ExactC<t.TypeC<{
32
+ __TYPE__: t.LiteralC<"ExternalLink">;
33
+ }>>, t.ExactC<t.IntersectionC<[t.TypeC<{
34
+ url: t.StringC;
35
+ }>, t.PartialC<{
36
+ kind: t.LiteralC<"web">;
37
+ target: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
38
+ preview: t.UnionC<[t.Type<{
39
+ title?: string;
40
+ }, {
41
+ title?: string;
42
+ }, unknown>, t.NullC, t.UndefinedC]>;
43
+ }>]>>]>]> | t.UnionC<[t.Type<{
44
+ __TYPE__: "ImageLink";
45
+ } & {
46
+ id: string;
47
+ url: string;
48
+ height: string;
49
+ width: string;
50
+ size: string;
51
+ name: string;
52
+ kind: string;
53
+ } & {
54
+ date?: string | null | undefined;
55
+ }, {
56
+ id: string;
57
+ url: string;
58
+ height: string;
59
+ width: string;
60
+ size: string;
61
+ name: string;
62
+ kind: string;
63
+ } & {
64
+ date?: string | null | undefined;
65
+ }, unknown>, t.Type<{
66
+ id: string;
67
+ url: string;
68
+ name: string;
69
+ kind: string;
70
+ size: string;
71
+ } & {
72
+ date?: string | null | undefined;
73
+ } & {
74
+ __TYPE__: "FileLink";
75
+ } & {
76
+ size?: string;
77
+ }, {
78
+ id: string;
79
+ url: string;
80
+ name: string;
81
+ kind: string;
82
+ size: string;
83
+ } & {
84
+ date?: string | null | undefined;
85
+ }, unknown>, t.Type<{
86
+ __TYPE__: "DocumentLink";
87
+ } & {
88
+ id: string;
89
+ }, {
90
+ id: string;
91
+ }, unknown>, t.Type<{
92
+ __TYPE__: "ExternalLink";
93
+ } & {
94
+ url: string;
95
+ } & {
96
+ kind?: "web";
97
+ target?: string | null | undefined;
98
+ preview?: {
99
+ title?: string;
100
+ } | null | undefined;
101
+ }, {
102
+ url: string;
103
+ } & {
104
+ kind?: "web";
105
+ target?: string | null | undefined;
106
+ preview?: {
107
+ title?: string;
108
+ } | null | undefined;
109
+ }, unknown>]>;
110
+ start: t.NumberC;
111
+ end: t.NumberC;
112
+ type: t.LiteralC<"hyperlink">;
113
+ }>>, t.ExactC<t.TypeC<{
114
+ data: t.StringC;
115
+ start: t.NumberC;
116
+ end: t.NumberC;
117
+ type: t.LiteralC<"label">;
118
+ }>>, t.ExactC<t.TypeC<{
119
+ start: t.NumberC;
120
+ end: t.NumberC;
121
+ type: t.KeyofC<{
122
+ strong: null;
123
+ em: null;
124
+ "list-item": null;
125
+ }>;
126
+ }>>]>;
127
+ export declare type Span = t.TypeOf<typeof Span>;
128
+ export declare const SpanLegacy: t.UnionC<[t.ExactC<t.TypeC<{
129
+ data: t.UnionC<[t.IntersectionC<[t.ExactC<t.TypeC<{
130
+ __TYPE__: t.LiteralC<"ImageLink">;
131
+ }>>, t.ExactC<t.IntersectionC<[t.TypeC<{
132
+ id: t.StringC;
133
+ url: t.StringC;
134
+ height: t.StringC;
135
+ width: t.StringC;
136
+ size: t.StringC;
137
+ name: t.StringC;
138
+ kind: t.StringC;
139
+ }>, t.PartialC<{
140
+ date: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
141
+ }>]>>]>, t.IntersectionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
142
+ id: t.StringC;
143
+ url: t.StringC;
144
+ name: t.StringC;
145
+ kind: t.StringC;
146
+ size: t.StringC;
147
+ }>, t.PartialC<{
148
+ date: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
149
+ }>]>>, t.ExactC<t.IntersectionC<[t.TypeC<{
150
+ __TYPE__: t.LiteralC<"FileLink">;
151
+ }>, t.PartialC<{
152
+ size: t.StringC;
153
+ }>]>>]>, t.IntersectionC<[t.ExactC<t.TypeC<{
154
+ __TYPE__: t.LiteralC<"DocumentLink">;
155
+ }>>, t.ExactC<t.TypeC<{
156
+ id: t.Type<string, string, unknown>;
157
+ }>>]>, t.IntersectionC<[t.ExactC<t.TypeC<{
158
+ __TYPE__: t.LiteralC<"ExternalLink">;
159
+ }>>, t.ExactC<t.IntersectionC<[t.TypeC<{
160
+ url: t.StringC;
161
+ }>, t.PartialC<{
162
+ kind: t.LiteralC<"web">;
163
+ target: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
164
+ preview: t.UnionC<[t.Type<{
165
+ title?: string;
166
+ }, {
167
+ title?: string;
168
+ }, unknown>, t.NullC, t.UndefinedC]>;
169
+ }>]>>]>]> | t.UnionC<[t.Type<{
170
+ __TYPE__: "ImageLink";
171
+ } & {
172
+ id: string;
173
+ url: string;
174
+ height: string;
175
+ width: string;
176
+ size: string;
177
+ name: string;
178
+ kind: string;
179
+ } & {
180
+ date?: string | null | undefined;
181
+ }, {
182
+ id: string;
183
+ url: string;
184
+ height: string;
185
+ width: string;
186
+ size: string;
187
+ name: string;
188
+ kind: string;
189
+ } & {
190
+ date?: string | null | undefined;
191
+ }, unknown>, t.Type<{
192
+ id: string;
193
+ url: string;
194
+ name: string;
195
+ kind: string;
196
+ size: string;
197
+ } & {
198
+ date?: string | null | undefined;
199
+ } & {
200
+ __TYPE__: "FileLink";
201
+ } & {
202
+ size?: string;
203
+ }, {
204
+ id: string;
205
+ url: string;
206
+ name: string;
207
+ kind: string;
208
+ size: string;
209
+ } & {
210
+ date?: string | null | undefined;
211
+ }, unknown>, t.Type<{
212
+ __TYPE__: "DocumentLink";
213
+ } & {
214
+ id: string;
215
+ }, {
216
+ id: string;
217
+ }, unknown>, t.Type<{
218
+ __TYPE__: "ExternalLink";
219
+ } & {
220
+ url: string;
221
+ } & {
222
+ kind?: "web";
223
+ target?: string | null | undefined;
224
+ preview?: {
225
+ title?: string;
226
+ } | null | undefined;
227
+ }, {
228
+ url: string;
229
+ } & {
230
+ kind?: "web";
231
+ target?: string | null | undefined;
232
+ preview?: {
233
+ title?: string;
234
+ } | null | undefined;
235
+ }, unknown>]>;
236
+ start: t.NumberC;
237
+ end: t.NumberC;
238
+ type: t.LiteralC<"hyperlink">;
239
+ }>>, t.ExactC<t.TypeC<{
240
+ data: t.StringC;
241
+ start: t.NumberC;
242
+ end: t.NumberC;
243
+ type: t.LiteralC<"label">;
244
+ }>>, t.ExactC<t.TypeC<{
245
+ start: t.NumberC;
246
+ end: t.NumberC;
247
+ type: t.KeyofC<{
248
+ strong: null;
249
+ em: null;
250
+ "list-item": null;
251
+ }>;
252
+ }>>]>;
253
+ export declare type SpanLegacy = t.TypeOf<typeof SpanLegacy>;
254
+ export declare const ValidatedSpans: <C extends t.UnionC<[t.ExactC<t.TypeC<{
255
+ data: t.UnionC<[t.IntersectionC<[t.ExactC<t.TypeC<{
256
+ __TYPE__: t.LiteralC<"ImageLink">;
257
+ }>>, t.ExactC<t.IntersectionC<[t.TypeC<{
258
+ id: t.StringC;
259
+ url: t.StringC;
260
+ height: t.StringC;
261
+ width: t.StringC;
262
+ size: t.StringC;
263
+ name: t.StringC;
264
+ kind: t.StringC;
265
+ }>, t.PartialC<{
266
+ date: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
267
+ }>]>>]>, t.IntersectionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
268
+ id: t.StringC;
269
+ url: t.StringC;
270
+ name: t.StringC;
271
+ kind: t.StringC;
272
+ size: t.StringC;
273
+ }>, t.PartialC<{
274
+ date: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
275
+ }>]>>, t.ExactC<t.IntersectionC<[t.TypeC<{
276
+ __TYPE__: t.LiteralC<"FileLink">;
277
+ }>, t.PartialC<{
278
+ size: t.StringC;
279
+ }>]>>]>, t.IntersectionC<[t.ExactC<t.TypeC<{
280
+ __TYPE__: t.LiteralC<"DocumentLink">;
281
+ }>>, t.ExactC<t.TypeC<{
282
+ id: t.Type<string, string, unknown>;
283
+ }>>]>, t.IntersectionC<[t.ExactC<t.TypeC<{
284
+ __TYPE__: t.LiteralC<"ExternalLink">;
285
+ }>>, t.ExactC<t.IntersectionC<[t.TypeC<{
286
+ url: t.StringC;
287
+ }>, t.PartialC<{
288
+ kind: t.LiteralC<"web">;
289
+ target: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
290
+ preview: t.UnionC<[t.Type<{
291
+ title?: string;
292
+ }, {
293
+ title?: string;
294
+ }, unknown>, t.NullC, t.UndefinedC]>;
295
+ }>]>>]>]> | t.UnionC<[t.Type<{
296
+ __TYPE__: "ImageLink";
297
+ } & {
298
+ id: string;
299
+ url: string;
300
+ height: string;
301
+ width: string;
302
+ size: string;
303
+ name: string;
304
+ kind: string;
305
+ } & {
306
+ date?: string | null | undefined;
307
+ }, {
308
+ id: string;
309
+ url: string;
310
+ height: string;
311
+ width: string;
312
+ size: string;
313
+ name: string;
314
+ kind: string;
315
+ } & {
316
+ date?: string | null | undefined;
317
+ }, unknown>, t.Type<{
318
+ id: string;
319
+ url: string;
320
+ name: string;
321
+ kind: string;
322
+ size: string;
323
+ } & {
324
+ date?: string | null | undefined;
325
+ } & {
326
+ __TYPE__: "FileLink";
327
+ } & {
328
+ size?: string;
329
+ }, {
330
+ id: string;
331
+ url: string;
332
+ name: string;
333
+ kind: string;
334
+ size: string;
335
+ } & {
336
+ date?: string | null | undefined;
337
+ }, unknown>, t.Type<{
338
+ __TYPE__: "DocumentLink";
339
+ } & {
340
+ id: string;
341
+ }, {
342
+ id: string;
343
+ }, unknown>, t.Type<{
344
+ __TYPE__: "ExternalLink";
345
+ } & {
346
+ url: string;
347
+ } & {
348
+ kind?: "web";
349
+ target?: string | null | undefined;
350
+ preview?: {
351
+ title?: string;
352
+ } | null | undefined;
353
+ }, {
354
+ url: string;
355
+ } & {
356
+ kind?: "web";
357
+ target?: string | null | undefined;
358
+ preview?: {
359
+ title?: string;
360
+ } | null | undefined;
361
+ }, unknown>]>;
362
+ start: t.NumberC;
363
+ end: t.NumberC;
364
+ type: t.LiteralC<"hyperlink">;
365
+ }>>, t.ExactC<t.TypeC<{
366
+ data: t.StringC;
367
+ start: t.NumberC;
368
+ end: t.NumberC;
369
+ type: t.LiteralC<"label">;
370
+ }>>, t.ExactC<t.TypeC<{
371
+ start: t.NumberC;
372
+ end: t.NumberC;
373
+ type: t.KeyofC<{
374
+ strong: null;
375
+ em: null;
376
+ "list-item": null;
377
+ }>;
378
+ }>>]>>(spanCodec: C) => t.Type<t.TypeOf<C>[], t.TypeOf<C>[], unknown>;
379
+ export declare const TextBlock: t.ExactC<t.IntersectionC<[t.TypeC<{
380
+ type: t.Type<"image" | "paragraph" | "heading1" | "heading2" | "heading3" | "heading4" | "heading5" | "heading6" | "strong" | "em" | "preformatted" | "hyperlink" | "embed" | "list-item" | "o-list-item" | "rtl", "image" | "paragraph" | "heading1" | "heading2" | "heading3" | "heading4" | "heading5" | "heading6" | "strong" | "em" | "preformatted" | "hyperlink" | "embed" | "list-item" | "o-list-item" | "rtl", unknown>;
381
+ content: t.IntersectionC<[t.TypeC<{
382
+ text: t.StringC;
383
+ }>, t.PartialC<{
384
+ spans: t.Type<({
385
+ data: ({
386
+ __TYPE__: "ImageLink";
387
+ } & {
388
+ id: string;
389
+ url: string;
390
+ height: string;
391
+ width: string;
392
+ size: string;
393
+ name: string;
394
+ kind: string;
395
+ } & {
396
+ date?: string | null | undefined;
397
+ }) | ({
398
+ id: string;
399
+ url: string;
400
+ name: string;
401
+ kind: string;
402
+ size: string;
403
+ } & {
404
+ date?: string | null | undefined;
405
+ } & {
406
+ __TYPE__: "FileLink";
407
+ } & {
408
+ size?: string;
409
+ }) | ({
410
+ __TYPE__: "DocumentLink";
411
+ } & {
412
+ id: string;
413
+ }) | ({
414
+ __TYPE__: "ExternalLink";
415
+ } & {
416
+ url: string;
417
+ } & {
418
+ kind?: "web";
419
+ target?: string | null | undefined;
420
+ preview?: {
421
+ title?: string;
422
+ } | null | undefined;
423
+ });
424
+ start: number;
425
+ end: number;
426
+ type: "hyperlink";
427
+ } | {
428
+ data: string;
429
+ start: number;
430
+ end: number;
431
+ type: "label";
432
+ } | {
433
+ start: number;
434
+ end: number;
435
+ type: "strong" | "em" | "list-item";
436
+ })[], ({
437
+ data: ({
438
+ __TYPE__: "ImageLink";
439
+ } & {
440
+ id: string;
441
+ url: string;
442
+ height: string;
443
+ width: string;
444
+ size: string;
445
+ name: string;
446
+ kind: string;
447
+ } & {
448
+ date?: string | null | undefined;
449
+ }) | ({
450
+ id: string;
451
+ url: string;
452
+ name: string;
453
+ kind: string;
454
+ size: string;
455
+ } & {
456
+ date?: string | null | undefined;
457
+ } & {
458
+ __TYPE__: "FileLink";
459
+ } & {
460
+ size?: string;
461
+ }) | ({
462
+ __TYPE__: "DocumentLink";
463
+ } & {
464
+ id: string;
465
+ }) | ({
466
+ __TYPE__: "ExternalLink";
467
+ } & {
468
+ url: string;
469
+ } & {
470
+ kind?: "web";
471
+ target?: string | null | undefined;
472
+ preview?: {
473
+ title?: string;
474
+ } | null | undefined;
475
+ });
476
+ start: number;
477
+ end: number;
478
+ type: "hyperlink";
479
+ } | {
480
+ data: string;
481
+ start: number;
482
+ end: number;
483
+ type: "label";
484
+ } | {
485
+ start: number;
486
+ end: number;
487
+ type: "strong" | "em" | "list-item";
488
+ })[], unknown>;
489
+ }>]>;
490
+ }>, t.PartialC<{
491
+ label: t.StringC;
492
+ direction: t.StringC;
493
+ }>]>>;
494
+ export declare type TextBlock = t.TypeOf<typeof TextBlock>;
495
+ /** A paragraph Text block. Paragraphs may contain spans. */
496
+ export declare const ParagraphBlock: t.ExactC<t.IntersectionC<[t.TypeC<{
497
+ type: t.Type<"image" | "paragraph" | "heading1" | "heading2" | "heading3" | "heading4" | "heading5" | "heading6" | "strong" | "em" | "preformatted" | "hyperlink" | "embed" | "list-item" | "o-list-item" | "rtl", "image" | "paragraph" | "heading1" | "heading2" | "heading3" | "heading4" | "heading5" | "heading6" | "strong" | "em" | "preformatted" | "hyperlink" | "embed" | "list-item" | "o-list-item" | "rtl", unknown>;
498
+ content: t.IntersectionC<[t.TypeC<{
499
+ text: t.StringC;
500
+ }>, t.PartialC<{
501
+ spans: t.Type<({
502
+ data: ({
503
+ __TYPE__: "ImageLink";
504
+ } & {
505
+ id: string;
506
+ url: string;
507
+ height: string;
508
+ width: string;
509
+ size: string;
510
+ name: string;
511
+ kind: string;
512
+ } & {
513
+ date?: string | null | undefined;
514
+ }) | ({
515
+ id: string;
516
+ url: string;
517
+ name: string;
518
+ kind: string;
519
+ size: string;
520
+ } & {
521
+ date?: string | null | undefined;
522
+ } & {
523
+ __TYPE__: "FileLink";
524
+ } & {
525
+ size?: string;
526
+ }) | ({
527
+ __TYPE__: "DocumentLink";
528
+ } & {
529
+ id: string;
530
+ }) | ({
531
+ __TYPE__: "ExternalLink";
532
+ } & {
533
+ url: string;
534
+ } & {
535
+ kind?: "web";
536
+ target?: string | null | undefined;
537
+ preview?: {
538
+ title?: string;
539
+ } | null | undefined;
540
+ });
541
+ start: number;
542
+ end: number;
543
+ type: "hyperlink";
544
+ } | {
545
+ data: string;
546
+ start: number;
547
+ end: number;
548
+ type: "label";
549
+ } | {
550
+ start: number;
551
+ end: number;
552
+ type: "strong" | "em" | "list-item";
553
+ })[], ({
554
+ data: ({
555
+ __TYPE__: "ImageLink";
556
+ } & {
557
+ id: string;
558
+ url: string;
559
+ height: string;
560
+ width: string;
561
+ size: string;
562
+ name: string;
563
+ kind: string;
564
+ } & {
565
+ date?: string | null | undefined;
566
+ }) | ({
567
+ id: string;
568
+ url: string;
569
+ name: string;
570
+ kind: string;
571
+ size: string;
572
+ } & {
573
+ date?: string | null | undefined;
574
+ } & {
575
+ __TYPE__: "FileLink";
576
+ } & {
577
+ size?: string;
578
+ }) | ({
579
+ __TYPE__: "DocumentLink";
580
+ } & {
581
+ id: string;
582
+ }) | ({
583
+ __TYPE__: "ExternalLink";
584
+ } & {
585
+ url: string;
586
+ } & {
587
+ kind?: "web";
588
+ target?: string | null | undefined;
589
+ preview?: {
590
+ title?: string;
591
+ } | null | undefined;
592
+ });
593
+ start: number;
594
+ end: number;
595
+ type: "hyperlink";
596
+ } | {
597
+ data: string;
598
+ start: number;
599
+ end: number;
600
+ type: "label";
601
+ } | {
602
+ start: number;
603
+ end: number;
604
+ type: "strong" | "em" | "list-item";
605
+ })[], unknown>;
606
+ }>]>;
607
+ }>, t.PartialC<{
608
+ label: t.StringC;
609
+ direction: t.StringC;
610
+ }>]>>;
611
+ export declare type ParagraphBlock = t.TypeOf<typeof ParagraphBlock>;
612
+ export declare const TextBlockLegacy: t.ExactC<t.IntersectionC<[t.TypeC<{
613
+ type: t.Type<"image" | "paragraph" | "heading1" | "heading2" | "heading3" | "heading4" | "heading5" | "heading6" | "strong" | "em" | "preformatted" | "hyperlink" | "embed" | "list-item" | "o-list-item" | "rtl", "image" | "paragraph" | "heading1" | "heading2" | "heading3" | "heading4" | "heading5" | "heading6" | "strong" | "em" | "preformatted" | "hyperlink" | "embed" | "list-item" | "o-list-item" | "rtl", unknown>;
614
+ content: t.IntersectionC<[t.TypeC<{
615
+ text: t.StringC;
616
+ }>, t.PartialC<{
617
+ spans: t.Type<({
618
+ data: ({
619
+ __TYPE__: "ImageLink";
620
+ } & {
621
+ id: string;
622
+ url: string;
623
+ height: string;
624
+ width: string;
625
+ size: string;
626
+ name: string;
627
+ kind: string;
628
+ } & {
629
+ date?: string | null | undefined;
630
+ }) | ({
631
+ id: string;
632
+ url: string;
633
+ name: string;
634
+ kind: string;
635
+ size: string;
636
+ } & {
637
+ date?: string | null | undefined;
638
+ } & {
639
+ __TYPE__: "FileLink";
640
+ } & {
641
+ size?: string;
642
+ }) | ({
643
+ __TYPE__: "DocumentLink";
644
+ } & {
645
+ id: string;
646
+ }) | ({
647
+ __TYPE__: "ExternalLink";
648
+ } & {
649
+ url: string;
650
+ } & {
651
+ kind?: "web";
652
+ target?: string | null | undefined;
653
+ preview?: {
654
+ title?: string;
655
+ } | null | undefined;
656
+ });
657
+ start: number;
658
+ end: number;
659
+ type: "hyperlink";
660
+ } | {
661
+ data: string;
662
+ start: number;
663
+ end: number;
664
+ type: "label";
665
+ } | {
666
+ start: number;
667
+ end: number;
668
+ type: "strong" | "em" | "list-item";
669
+ })[], ({
670
+ data: ({
671
+ __TYPE__: "ImageLink";
672
+ } & {
673
+ id: string;
674
+ url: string;
675
+ height: string;
676
+ width: string;
677
+ size: string;
678
+ name: string;
679
+ kind: string;
680
+ } & {
681
+ date?: string | null | undefined;
682
+ }) | ({
683
+ id: string;
684
+ url: string;
685
+ name: string;
686
+ kind: string;
687
+ size: string;
688
+ } & {
689
+ date?: string | null | undefined;
690
+ } & {
691
+ __TYPE__: "FileLink";
692
+ } & {
693
+ size?: string;
694
+ }) | ({
695
+ __TYPE__: "DocumentLink";
696
+ } & {
697
+ id: string;
698
+ }) | ({
699
+ __TYPE__: "ExternalLink";
700
+ } & {
701
+ url: string;
702
+ } & {
703
+ kind?: "web";
704
+ target?: string | null | undefined;
705
+ preview?: {
706
+ title?: string;
707
+ } | null | undefined;
708
+ });
709
+ start: number;
710
+ end: number;
711
+ type: "hyperlink";
712
+ } | {
713
+ data: string;
714
+ start: number;
715
+ end: number;
716
+ type: "label";
717
+ } | {
718
+ start: number;
719
+ end: number;
720
+ type: "strong" | "em" | "list-item";
721
+ })[], unknown>;
722
+ }>]>;
723
+ }>, t.PartialC<{
724
+ label: t.StringC;
725
+ direction: t.StringC;
726
+ }>]>>;
727
+ export declare type TextBlockLegacy = t.TypeOf<typeof TextBlockLegacy>;
@@ -0,0 +1,80 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TextBlockLegacy = exports.ParagraphBlock = exports.TextBlock = exports.ValidatedSpans = exports.SpanLegacy = exports.Span = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const Either_1 = require("fp-ts/lib/Either");
6
+ const t = (0, tslib_1.__importStar)(require("io-ts"));
7
+ const io_ts_types_1 = require("io-ts-types");
8
+ const nestable_1 = require("../../../../customtypes/widgets/nestable");
9
+ const function_1 = require("../../../../validators/function");
10
+ const LinkContent_1 = require("../LinkContent");
11
+ const linkSpan = (linkCodec) => t.strict({
12
+ data: linkCodec,
13
+ start: t.number,
14
+ end: t.number,
15
+ type: t.literal(nestable_1.RichTextNodeType.hyperlink),
16
+ });
17
+ const labelSpan = t.strict({
18
+ data: (0, io_ts_types_1.withFallback)(t.string, ""),
19
+ start: t.number,
20
+ end: t.number,
21
+ type: t.literal("label"),
22
+ });
23
+ const basicSpan = t.strict({
24
+ start: t.number,
25
+ end: t.number,
26
+ type: t.keyof({
27
+ [nestable_1.RichTextNodeType.strong]: null,
28
+ [nestable_1.RichTextNodeType.em]: null,
29
+ "list-item": null, // legacy case that should not happen, we shouldn't support this in new page builder or migration API
30
+ }),
31
+ });
32
+ exports.Span = t.union([linkSpan(LinkContent_1.Link), labelSpan, basicSpan]);
33
+ exports.SpanLegacy = t.union([linkSpan(LinkContent_1.LinkLegacy), labelSpan, basicSpan]);
34
+ const ValidatedSpans = (spanCodec) => {
35
+ return new t.Type("ValidatedSpans", (spans) => Array.isArray(spans) && spans.every(spanCodec.is), (spans, c) => {
36
+ if (Array.isArray(spans)) {
37
+ const res = spans
38
+ .reduce((acc, maybeSpan) => {
39
+ const decodedSpan = spanCodec.decode(maybeSpan);
40
+ if ((0, Either_1.isLeft)(decodedSpan))
41
+ return acc;
42
+ return [...acc, decodedSpan.right];
43
+ }, [])
44
+ .sort((m1, m2) => m1.start - m2.start);
45
+ return t.success(res);
46
+ }
47
+ else
48
+ return t.failure(spans, c);
49
+ }, (m) => {
50
+ return m.reduce((acc, meta) => {
51
+ const encoded = spanCodec.encode(meta);
52
+ return [...acc, encoded];
53
+ }, []);
54
+ });
55
+ };
56
+ exports.ValidatedSpans = ValidatedSpans;
57
+ const TextBlockCodec = (spanCodec, nodeFilter) => t.exact(t.intersection([
58
+ t.type({
59
+ type: nodeFilter
60
+ ? (0, function_1.refineType)(nestable_1.RichTextNodeTypeCodec, `string which isn't ${nestable_1.RichTextNodeType.image} ${nestable_1.RichTextNodeType.embed}`, nodeFilter)
61
+ : nestable_1.RichTextNodeTypeCodec,
62
+ content: t.intersection([
63
+ t.type({
64
+ text: t.string,
65
+ }),
66
+ t.partial({
67
+ spans: (0, exports.ValidatedSpans)(spanCodec),
68
+ }),
69
+ ]),
70
+ }),
71
+ t.partial({
72
+ label: t.string,
73
+ direction: t.string,
74
+ }),
75
+ ]));
76
+ /* These Text block will decode codec A and encode from codec B to A */
77
+ exports.TextBlock = TextBlockCodec(exports.Span, (nodeType) => nodeType !== nestable_1.RichTextNodeType.image && nodeType !== nestable_1.RichTextNodeType.embed);
78
+ /** A paragraph Text block. Paragraphs may contain spans. */
79
+ exports.ParagraphBlock = TextBlockCodec(exports.Span, (nodeType) => nodeType === nestable_1.RichTextNodeType.paragraph);
80
+ exports.TextBlockLegacy = TextBlockCodec(exports.SpanLegacy);
@@ -0,0 +1,327 @@
1
+ import * as t from "io-ts";
2
+ export declare const SliceWidget: t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
3
+ type: t.LiteralC<"Group">;
4
+ }>, t.PartialC<{
5
+ fieldset: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
6
+ icon: t.StringC;
7
+ description: t.StringC;
8
+ config: t.ExactC<t.PartialC<{
9
+ label: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
10
+ repeat: t.BooleanC;
11
+ fields: t.RecordC<t.Type<string, string, unknown>, t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
12
+ type: t.LiteralC<"Color">;
13
+ }>, t.PartialC<{
14
+ fieldset: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
15
+ config: t.ExactC<t.PartialC<{
16
+ label: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
17
+ placeholder: t.StringC;
18
+ }>>;
19
+ }>]>>, t.ExactC<t.IntersectionC<[t.TypeC<{
20
+ type: t.LiteralC<"Boolean">;
21
+ }>, t.PartialC<{
22
+ config: t.ExactC<t.PartialC<{
23
+ label: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
24
+ default_value: t.BooleanC;
25
+ placeholder_true: t.StringC;
26
+ placeholder_false: t.StringC;
27
+ }>>;
28
+ }>]>>, t.ExactC<t.IntersectionC<[t.TypeC<{
29
+ type: t.LiteralC<"Embed">;
30
+ }>, t.PartialC<{
31
+ fieldset: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
32
+ config: t.ExactC<t.PartialC<{
33
+ label: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
34
+ placeholder: t.StringC;
35
+ useAsTitle: t.BooleanC;
36
+ }>>;
37
+ }>]>>, t.ExactC<t.IntersectionC<[t.TypeC<{
38
+ type: t.LiteralC<"GeoPoint">;
39
+ }>, t.PartialC<{
40
+ fieldset: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
41
+ config: t.ExactC<t.PartialC<{
42
+ label: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
43
+ }>>;
44
+ }>]>>, t.ExactC<t.IntersectionC<[t.TypeC<{
45
+ type: t.LiteralC<"Date">;
46
+ }>, t.PartialC<{
47
+ fieldset: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
48
+ config: t.ExactC<t.PartialC<{
49
+ label: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
50
+ placeholder: t.StringC;
51
+ default: t.StringC;
52
+ }>>;
53
+ }>]>>, t.ExactC<t.IntersectionC<[t.TypeC<{
54
+ type: t.LiteralC<"Number">;
55
+ }>, t.PartialC<{
56
+ fieldset: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
57
+ config: t.ExactC<t.PartialC<{
58
+ label: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
59
+ placeholder: t.StringC;
60
+ min: t.UnionC<[t.NumberC, import("io-ts-types").NumberFromStringC]>;
61
+ max: t.UnionC<[t.NumberC, import("io-ts-types").NumberFromStringC]>;
62
+ step: t.UnionC<[t.NumberC, import("io-ts-types").NumberFromStringC]>;
63
+ }>>;
64
+ }>]>>, t.ExactC<t.IntersectionC<[t.TypeC<{
65
+ type: t.LiteralC<"Range">;
66
+ }>, t.PartialC<{
67
+ fieldset: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
68
+ config: t.ExactC<t.PartialC<{
69
+ label: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
70
+ placeholder: t.StringC;
71
+ min: t.UnionC<[t.NumberC, import("io-ts-types").NumberFromStringC]>;
72
+ max: t.UnionC<[t.NumberC, import("io-ts-types").NumberFromStringC]>;
73
+ step: t.UnionC<[t.NumberC, import("io-ts-types").NumberFromStringC]>;
74
+ }>>;
75
+ }>]>>, t.ExactC<t.IntersectionC<[t.TypeC<{
76
+ type: t.LiteralC<"StructuredText">;
77
+ }>, t.PartialC<{
78
+ fieldset: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
79
+ config: t.ExactC<t.PartialC<{
80
+ label: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
81
+ placeholder: t.StringC;
82
+ useAsTitle: t.BooleanC;
83
+ single: t.Type<string, string, unknown>;
84
+ multi: t.Type<string, string, unknown>;
85
+ imageConstraint: t.PartialC<{
86
+ width: t.Type<number | null, unknown, unknown>;
87
+ height: t.Type<number | null, unknown, unknown>;
88
+ }>;
89
+ labels: t.Type<readonly string[], object, unknown>;
90
+ allowTargetBlank: t.BooleanC;
91
+ }>>;
92
+ }>]>>, t.ExactC<t.IntersectionC<[t.TypeC<{
93
+ type: t.LiteralC<"Select">;
94
+ }>, t.PartialC<{
95
+ fieldset: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
96
+ config: t.ExactC<t.PartialC<{
97
+ label: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
98
+ placeholder: t.StringC;
99
+ default_value: t.StringC;
100
+ options: t.ReadonlyArrayC<t.UnionC<[t.StringC, t.Type<string, string, unknown>, t.Type<string, string, unknown>]>>;
101
+ }>>;
102
+ }>]>>, t.ExactC<t.IntersectionC<[t.TypeC<{
103
+ type: t.LiteralC<"Separator">;
104
+ }>, t.PartialC<{
105
+ config: t.ExactC<t.PartialC<{
106
+ label: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
107
+ }>>;
108
+ }>]>>, t.ExactC<t.IntersectionC<[t.TypeC<{
109
+ type: t.LiteralC<"Text">;
110
+ }>, t.PartialC<{
111
+ fieldset: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
112
+ config: t.ExactC<t.PartialC<{
113
+ label: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
114
+ useAsTitle: t.BooleanC;
115
+ placeholder: t.StringC;
116
+ }>>;
117
+ }>]>>, t.ExactC<t.IntersectionC<[t.TypeC<{
118
+ type: t.LiteralC<"Timestamp">;
119
+ }>, t.PartialC<{
120
+ fieldset: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
121
+ config: t.ExactC<t.PartialC<{
122
+ label: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
123
+ placeholder: t.StringC;
124
+ default: t.StringC;
125
+ }>>;
126
+ }>]>>, t.ExactC<t.IntersectionC<[t.TypeC<{
127
+ type: t.LiteralC<"Link">;
128
+ }>, t.PartialC<{
129
+ fieldset: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
130
+ config: t.ExactC<t.PartialC<{
131
+ label: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
132
+ useAsTitle: t.BooleanC;
133
+ placeholder: t.StringC;
134
+ select: t.UnionC<[t.LiteralC<"media">, t.LiteralC<"document">, t.LiteralC<"web">, t.NullC]>;
135
+ customtypes: t.ReadonlyArrayC<t.StringC>;
136
+ masks: t.Type<readonly string[], object, unknown>;
137
+ tags: t.Type<readonly string[], object, unknown>;
138
+ allowTargetBlank: t.BooleanC;
139
+ }>>;
140
+ }>]>>, t.ExactC<t.IntersectionC<[t.TypeC<{
141
+ type: t.LiteralC<"Image">;
142
+ }>, t.PartialC<{
143
+ fieldset: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
144
+ config: t.ExactC<t.PartialC<{
145
+ label: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
146
+ placeholder: t.StringC;
147
+ constraint: t.PartialC<{
148
+ width: t.Type<number | null, unknown, unknown>;
149
+ height: t.Type<number | null, unknown, unknown>;
150
+ }>;
151
+ thumbnails: t.ReadonlyArrayC<t.ExactC<t.IntersectionC<[t.TypeC<{
152
+ name: t.StringC;
153
+ }>, t.PartialC<{
154
+ width: t.Type<number | null, unknown, unknown>;
155
+ height: t.Type<number | null, unknown, unknown>;
156
+ }>]>>>;
157
+ }>>;
158
+ }>]>>, t.ExactC<t.IntersectionC<[t.TypeC<{
159
+ type: t.LiteralC<"IntegrationFields">;
160
+ }>, t.PartialC<{
161
+ fieldset: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
162
+ config: t.ExactC<t.PartialC<{
163
+ label: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
164
+ placeholder: t.StringC;
165
+ catalog: t.StringC;
166
+ }>>;
167
+ }>]>>]>>;
168
+ }>>;
169
+ }>]>>, t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
170
+ type: t.LiteralC<"Color">;
171
+ }>, t.PartialC<{
172
+ fieldset: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
173
+ config: t.ExactC<t.PartialC<{
174
+ label: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
175
+ placeholder: t.StringC;
176
+ }>>;
177
+ }>]>>, t.ExactC<t.IntersectionC<[t.TypeC<{
178
+ type: t.LiteralC<"Boolean">;
179
+ }>, t.PartialC<{
180
+ config: t.ExactC<t.PartialC<{
181
+ label: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
182
+ default_value: t.BooleanC;
183
+ placeholder_true: t.StringC;
184
+ placeholder_false: t.StringC;
185
+ }>>;
186
+ }>]>>, t.ExactC<t.IntersectionC<[t.TypeC<{
187
+ type: t.LiteralC<"Embed">;
188
+ }>, t.PartialC<{
189
+ fieldset: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
190
+ config: t.ExactC<t.PartialC<{
191
+ label: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
192
+ placeholder: t.StringC;
193
+ useAsTitle: t.BooleanC;
194
+ }>>;
195
+ }>]>>, t.ExactC<t.IntersectionC<[t.TypeC<{
196
+ type: t.LiteralC<"GeoPoint">;
197
+ }>, t.PartialC<{
198
+ fieldset: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
199
+ config: t.ExactC<t.PartialC<{
200
+ label: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
201
+ }>>;
202
+ }>]>>, t.ExactC<t.IntersectionC<[t.TypeC<{
203
+ type: t.LiteralC<"Date">;
204
+ }>, t.PartialC<{
205
+ fieldset: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
206
+ config: t.ExactC<t.PartialC<{
207
+ label: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
208
+ placeholder: t.StringC;
209
+ default: t.StringC;
210
+ }>>;
211
+ }>]>>, t.ExactC<t.IntersectionC<[t.TypeC<{
212
+ type: t.LiteralC<"Number">;
213
+ }>, t.PartialC<{
214
+ fieldset: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
215
+ config: t.ExactC<t.PartialC<{
216
+ label: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
217
+ placeholder: t.StringC;
218
+ min: t.UnionC<[t.NumberC, import("io-ts-types").NumberFromStringC]>;
219
+ max: t.UnionC<[t.NumberC, import("io-ts-types").NumberFromStringC]>;
220
+ step: t.UnionC<[t.NumberC, import("io-ts-types").NumberFromStringC]>;
221
+ }>>;
222
+ }>]>>, t.ExactC<t.IntersectionC<[t.TypeC<{
223
+ type: t.LiteralC<"Range">;
224
+ }>, t.PartialC<{
225
+ fieldset: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
226
+ config: t.ExactC<t.PartialC<{
227
+ label: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
228
+ placeholder: t.StringC;
229
+ min: t.UnionC<[t.NumberC, import("io-ts-types").NumberFromStringC]>;
230
+ max: t.UnionC<[t.NumberC, import("io-ts-types").NumberFromStringC]>;
231
+ step: t.UnionC<[t.NumberC, import("io-ts-types").NumberFromStringC]>;
232
+ }>>;
233
+ }>]>>, t.ExactC<t.IntersectionC<[t.TypeC<{
234
+ type: t.LiteralC<"StructuredText">;
235
+ }>, t.PartialC<{
236
+ fieldset: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
237
+ config: t.ExactC<t.PartialC<{
238
+ label: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
239
+ placeholder: t.StringC;
240
+ useAsTitle: t.BooleanC;
241
+ single: t.Type<string, string, unknown>;
242
+ multi: t.Type<string, string, unknown>;
243
+ imageConstraint: t.PartialC<{
244
+ width: t.Type<number | null, unknown, unknown>;
245
+ height: t.Type<number | null, unknown, unknown>;
246
+ }>;
247
+ labels: t.Type<readonly string[], object, unknown>;
248
+ allowTargetBlank: t.BooleanC;
249
+ }>>;
250
+ }>]>>, t.ExactC<t.IntersectionC<[t.TypeC<{
251
+ type: t.LiteralC<"Select">;
252
+ }>, t.PartialC<{
253
+ fieldset: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
254
+ config: t.ExactC<t.PartialC<{
255
+ label: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
256
+ placeholder: t.StringC;
257
+ default_value: t.StringC;
258
+ options: t.ReadonlyArrayC<t.UnionC<[t.StringC, t.Type<string, string, unknown>, t.Type<string, string, unknown>]>>;
259
+ }>>;
260
+ }>]>>, t.ExactC<t.IntersectionC<[t.TypeC<{
261
+ type: t.LiteralC<"Separator">;
262
+ }>, t.PartialC<{
263
+ config: t.ExactC<t.PartialC<{
264
+ label: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
265
+ }>>;
266
+ }>]>>, t.ExactC<t.IntersectionC<[t.TypeC<{
267
+ type: t.LiteralC<"Text">;
268
+ }>, t.PartialC<{
269
+ fieldset: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
270
+ config: t.ExactC<t.PartialC<{
271
+ label: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
272
+ useAsTitle: t.BooleanC;
273
+ placeholder: t.StringC;
274
+ }>>;
275
+ }>]>>, t.ExactC<t.IntersectionC<[t.TypeC<{
276
+ type: t.LiteralC<"Timestamp">;
277
+ }>, t.PartialC<{
278
+ fieldset: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
279
+ config: t.ExactC<t.PartialC<{
280
+ label: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
281
+ placeholder: t.StringC;
282
+ default: t.StringC;
283
+ }>>;
284
+ }>]>>, t.ExactC<t.IntersectionC<[t.TypeC<{
285
+ type: t.LiteralC<"Link">;
286
+ }>, t.PartialC<{
287
+ fieldset: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
288
+ config: t.ExactC<t.PartialC<{
289
+ label: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
290
+ useAsTitle: t.BooleanC;
291
+ placeholder: t.StringC;
292
+ select: t.UnionC<[t.LiteralC<"media">, t.LiteralC<"document">, t.LiteralC<"web">, t.NullC]>;
293
+ customtypes: t.ReadonlyArrayC<t.StringC>;
294
+ masks: t.Type<readonly string[], object, unknown>;
295
+ tags: t.Type<readonly string[], object, unknown>;
296
+ allowTargetBlank: t.BooleanC;
297
+ }>>;
298
+ }>]>>, t.ExactC<t.IntersectionC<[t.TypeC<{
299
+ type: t.LiteralC<"Image">;
300
+ }>, t.PartialC<{
301
+ fieldset: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
302
+ config: t.ExactC<t.PartialC<{
303
+ label: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
304
+ placeholder: t.StringC;
305
+ constraint: t.PartialC<{
306
+ width: t.Type<number | null, unknown, unknown>;
307
+ height: t.Type<number | null, unknown, unknown>;
308
+ }>;
309
+ thumbnails: t.ReadonlyArrayC<t.ExactC<t.IntersectionC<[t.TypeC<{
310
+ name: t.StringC;
311
+ }>, t.PartialC<{
312
+ width: t.Type<number | null, unknown, unknown>;
313
+ height: t.Type<number | null, unknown, unknown>;
314
+ }>]>>>;
315
+ }>>;
316
+ }>]>>, t.ExactC<t.IntersectionC<[t.TypeC<{
317
+ type: t.LiteralC<"IntegrationFields">;
318
+ }>, t.PartialC<{
319
+ fieldset: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
320
+ config: t.ExactC<t.PartialC<{
321
+ label: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
322
+ placeholder: t.StringC;
323
+ catalog: t.StringC;
324
+ }>>;
325
+ }>]>>]>]>;
326
+ export declare type SliceWidget = t.TypeOf<typeof SliceWidget>;
327
+ export declare type SliceFieldTypes = SliceWidget["type"];
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SliceWidget = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const t = (0, tslib_1.__importStar)(require("io-ts"));
6
+ const Group_1 = require("../Group");
7
+ const nestable_1 = require("../nestable");
8
+ exports.SliceWidget = t.union([Group_1.Group, nestable_1.NestableWidget]);
@@ -12,14 +12,7 @@ function nullable(c) {
12
12
  }
13
13
  exports.nullable = nullable;
14
14
  function refineType(type, newName, pred) {
15
- return new t.Type(newName, type.is, (u, c) => (0, function_1.pipe)(type.validate(u, c), fp_ts_1.either.chain((v) => {
16
- try {
17
- return pred(v) ? t.success(v) : t.failure(u, c);
18
- }
19
- catch (error) {
20
- return t.failure(u, c, error instanceof Error ? error.message : String(error));
21
- }
22
- })), type.encode);
15
+ return new t.Type(newName, type.is, (u, c) => (0, function_1.pipe)(type.validate(u, c), fp_ts_1.either.chain((v) => (pred(v) ? t.success(v) : t.failure(u, c)))), type.encode);
23
16
  }
24
17
  exports.refineType = refineType;
25
18
  function filterDouble(value) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prismicio/types-internal",
3
- "version": "2.5.0-alpha.4",
3
+ "version": "2.6.0",
4
4
  "description": "Prismic types for Custom Types and Prismic Data",
5
5
  "keywords": [
6
6
  "typescript",
@@ -53,10 +53,7 @@ export type GroupContent = {
53
53
  value: GroupItemContent[]
54
54
  }
55
55
 
56
- export const isGroupContent = (u: unknown): u is GroupContent =>
57
- hasContentType(u) &&
58
- u.__TYPE__ === GroupContentType &&
59
- GroupContent.decode(u)._tag === "Right"
56
+ export const isGroupContent = GroupContent.is
60
57
 
61
58
  export const GroupContentDefaultValue: GroupContent = {
62
59
  __TYPE__: GroupContentType,
@@ -19,17 +19,7 @@ export function refineType<A, O, I>(
19
19
  (u, c) =>
20
20
  pipe(
21
21
  type.validate(u, c),
22
- either.chain((v) => {
23
- try {
24
- return pred(v) ? t.success(v) : t.failure(u, c)
25
- } catch (error) {
26
- return t.failure(
27
- u,
28
- c,
29
- error instanceof Error ? error.message : String(error),
30
- )
31
- }
32
- }),
22
+ either.chain((v) => (pred(v) ? t.success(v) : t.failure(u, c))),
33
23
  ),
34
24
  type.encode,
35
25
  )