@prismicio/types-internal 2.2.0-alpha.21 → 2.2.0-alpha.23
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/content/Document.d.ts +936 -24
- package/lib/content/fields/GroupContent.d.ts +273 -7
- package/lib/content/fields/WidgetContent.d.ts +1248 -32
- package/lib/content/fields/nestable/NestableContent.d.ts +156 -4
- package/lib/content/fields/nestable/RichTextContent/Blocks.d.ts +582 -51
- package/lib/content/fields/nestable/RichTextContent/Blocks.js +32 -49
- package/lib/content/fields/nestable/RichTextContent/index.d.ts +195 -5
- package/lib/content/fields/slices/Slice/CompositeSliceContent.d.ts +312 -8
- package/lib/content/fields/slices/Slice/RepeatableContent.d.ts +117 -3
- package/lib/content/fields/slices/Slice/SharedSliceContent.d.ts +312 -8
- package/lib/content/fields/slices/Slice/SimpleSliceContent.d.ts +312 -8
- package/lib/content/fields/slices/Slice/index.d.ts +702 -18
- package/lib/content/fields/slices/SliceItem.d.ts +702 -18
- package/lib/content/fields/slices/SlicesContent.d.ts +936 -24
- package/lib/import/converters/fields/nestable/Image.d.ts +24 -2
- package/lib/import/converters/fields/nestable/Image.js +16 -17
- package/lib/import/converters/fields/nestable/RichText/textBlock.js +21 -14
- package/lib/import/validators/fields/nestable/ImportRichText/blocks/ImportImageBlock.d.ts +16 -2
- package/lib/import/validators/fields/nestable/ImportRichText/blocks/ImportImageBlock.js +7 -5
- package/package.json +1 -1
- package/src/content/fields/nestable/RichTextContent/Blocks.ts +48 -58
- package/src/import/converters/fields/nestable/Image.ts +9 -11
- package/src/import/converters/fields/nestable/RichText/embedBlock.ts +14 -11
- package/src/import/converters/fields/nestable/RichText/imageBlock.ts +15 -12
- package/src/import/converters/fields/nestable/RichText/index.ts +4 -4
- package/src/import/converters/fields/nestable/RichText/textBlock.ts +39 -26
- package/src/import/validators/fields/nestable/ImportRichText/blocks/ImportImageBlock.ts +9 -5
- package/lib/import/converters/fields/nestable/GeooPoint.d.ts +0 -3
- package/lib/import/converters/fields/nestable/GeooPoint.js +0 -15
- package/lib/import/converters/fields/nestable/RichText.d.ts +0 -4
- package/lib/import/converters/fields/nestable/RichText.js +0 -55
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Block = exports.BlockLegacy = exports.
|
|
3
|
+
exports.Block = exports.BlockLegacy = exports.TextBlock = exports.checkEmbedBlock = exports.EmbedBlock = exports.checkImageBlock = exports.ImageBlock = exports.ValidatedSpans = exports.SpanLegacy = exports.Span = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const fp_ts_1 = require("fp-ts");
|
|
6
6
|
const Either_1 = require("fp-ts/lib/Either");
|
|
@@ -12,9 +12,9 @@ const function_2 = require("../../../../validators/function");
|
|
|
12
12
|
const EmbedContent_1 = require("../EmbedContent");
|
|
13
13
|
const ImageContent_1 = require("../ImageContent");
|
|
14
14
|
const LinkContent_1 = require("../LinkContent");
|
|
15
|
-
|
|
15
|
+
const SpanFn = (linkCodec) => t.exact(t.intersection([
|
|
16
16
|
t.partial({
|
|
17
|
-
data:
|
|
17
|
+
data: linkCodec,
|
|
18
18
|
}),
|
|
19
19
|
t.type({
|
|
20
20
|
start: t.number,
|
|
@@ -22,46 +22,28 @@ exports.Meta = t.exact(t.intersection([
|
|
|
22
22
|
type: t.union([nestable_1.RichTextNodeTypeCodec, t.literal("label")]),
|
|
23
23
|
}),
|
|
24
24
|
]));
|
|
25
|
-
|
|
26
|
-
exports.
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
if ((0, Either_1.isLeft)(decoded))
|
|
38
|
-
return acc;
|
|
39
|
-
return [...acc, { ...meta, data: decoded.right }];
|
|
40
|
-
}
|
|
41
|
-
else if (meta.type !== "hyperlink") {
|
|
42
|
-
return [...acc, meta];
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
return acc;
|
|
46
|
-
}, [])
|
|
47
|
-
.sort((m1, m2) => m1.start - m2.start);
|
|
48
|
-
return t.success(res);
|
|
49
|
-
}
|
|
50
|
-
else
|
|
51
|
-
return t.failure(metas, c);
|
|
52
|
-
}, (m) => {
|
|
53
|
-
return m.reduce((acc, meta) => {
|
|
54
|
-
if (meta.type === "hyperlink" && meta.data) {
|
|
55
|
-
// since the Span data are typed as unknown we have to redecode for type safety and then encode to either new format or legacy.
|
|
56
|
-
const decoded = linkCodec.decode(meta.data);
|
|
57
|
-
if ((0, Either_1.isLeft)(decoded))
|
|
58
|
-
return acc;
|
|
59
|
-
return [...acc, { ...meta, data: linkCodec.encode(decoded.right) }];
|
|
25
|
+
exports.Span = SpanFn(LinkContent_1.Link);
|
|
26
|
+
exports.SpanLegacy = SpanFn(LinkContent_1.LinkLegacy);
|
|
27
|
+
const ValidatedSpans = (spanCodec) => {
|
|
28
|
+
return new t.Type("ValidatedSpans", (spans) => Array.isArray(spans) && spans.every(spanCodec.is), (spans, c) => {
|
|
29
|
+
if (Array.isArray(spans)) {
|
|
30
|
+
const res = spans
|
|
31
|
+
.reduce((acc, maybeSpan) => {
|
|
32
|
+
const decodedSpan = spanCodec.decode(maybeSpan);
|
|
33
|
+
return (0, Either_1.isRight)(decodedSpan) ? [...acc, decodedSpan.right] : acc;
|
|
34
|
+
}, [])
|
|
35
|
+
.sort((m1, m2) => m1.start - m2.start);
|
|
36
|
+
return t.success(res);
|
|
60
37
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
})
|
|
64
|
-
|
|
38
|
+
else
|
|
39
|
+
return t.failure(spans, c);
|
|
40
|
+
}, (m) => {
|
|
41
|
+
return m.reduce((acc, meta) => {
|
|
42
|
+
return [...acc, spanCodec.encode(meta)];
|
|
43
|
+
}, []);
|
|
44
|
+
});
|
|
45
|
+
};
|
|
46
|
+
exports.ValidatedSpans = ValidatedSpans;
|
|
65
47
|
const ImageBlockCodec = (linkCodec) => t.exact(t.intersection([
|
|
66
48
|
t.type({
|
|
67
49
|
type: t.literal(nestable_1.RichTextNodeType.image),
|
|
@@ -126,7 +108,7 @@ function checkEmbedBlock(block) {
|
|
|
126
108
|
return block.type === nestable_1.RichTextNodeType.embed;
|
|
127
109
|
}
|
|
128
110
|
exports.checkEmbedBlock = checkEmbedBlock;
|
|
129
|
-
const TextBlockCodec = (
|
|
111
|
+
const TextBlockCodec = (spanCodec) => t.exact(t.intersection([
|
|
130
112
|
t.type({
|
|
131
113
|
type: (0, function_2.refineType)(nestable_1.RichTextNodeTypeCodec, `string which isn't ${nestable_1.RichTextNodeType.image} ${nestable_1.RichTextNodeType.embed}`, (s) => s !== nestable_1.RichTextNodeType.image && s !== nestable_1.RichTextNodeType.embed),
|
|
132
114
|
content: t.intersection([
|
|
@@ -134,7 +116,7 @@ const TextBlockCodec = (linkCodec) => t.exact(t.intersection([
|
|
|
134
116
|
text: t.string,
|
|
135
117
|
}),
|
|
136
118
|
t.partial({
|
|
137
|
-
spans: (0, exports.
|
|
119
|
+
spans: (0, exports.ValidatedSpans)(spanCodec),
|
|
138
120
|
}),
|
|
139
121
|
]),
|
|
140
122
|
}),
|
|
@@ -143,21 +125,22 @@ const TextBlockCodec = (linkCodec) => t.exact(t.intersection([
|
|
|
143
125
|
direction: t.string,
|
|
144
126
|
}),
|
|
145
127
|
]));
|
|
146
|
-
|
|
147
|
-
exports.
|
|
128
|
+
/* These Text block will decode codec A and encode from codec B to A */
|
|
129
|
+
exports.TextBlock = TextBlockCodec(exports.Span);
|
|
130
|
+
const TextBlockLegacy = TextBlockCodec(exports.SpanLegacy);
|
|
148
131
|
const legacyBlockCodec = t.union([
|
|
149
132
|
EmbedBlockLegacy,
|
|
150
133
|
ImageBlockLegacy,
|
|
151
|
-
|
|
134
|
+
TextBlockLegacy,
|
|
152
135
|
]);
|
|
153
|
-
exports.BlockLegacy = new t.Type("BlockLegacy", (u) => EmbedBlockLegacy.is(u) || ImageBlockLegacy.is(u) ||
|
|
136
|
+
exports.BlockLegacy = new t.Type("BlockLegacy", (u) => EmbedBlockLegacy.is(u) || ImageBlockLegacy.is(u) || TextBlockLegacy.is(u), (legacyBlock) => legacyBlockCodec.decode(legacyBlock), (block) => {
|
|
154
137
|
return (() => {
|
|
155
138
|
if (exports.ImageBlock.is(block))
|
|
156
139
|
return ImageBlockLegacy.encode(block);
|
|
157
140
|
else if (exports.EmbedBlock.is(block))
|
|
158
141
|
return EmbedBlockLegacy.encode(block);
|
|
159
142
|
else
|
|
160
|
-
return
|
|
143
|
+
return TextBlockLegacy.encode(block);
|
|
161
144
|
})();
|
|
162
145
|
});
|
|
163
146
|
exports.Block = t.union([exports.ImageBlock, exports.EmbedBlock, exports.TextBlock]);
|
|
@@ -101,7 +101,45 @@ export declare const isRichTextContent: (u: unknown) => u is {
|
|
|
101
101
|
text: string;
|
|
102
102
|
} & {
|
|
103
103
|
spans?: ({
|
|
104
|
-
data?:
|
|
104
|
+
data?: ({
|
|
105
|
+
__TYPE__: "ImageLink";
|
|
106
|
+
} & {
|
|
107
|
+
id: string;
|
|
108
|
+
url: string;
|
|
109
|
+
height: string;
|
|
110
|
+
width: string;
|
|
111
|
+
size: string;
|
|
112
|
+
name: string;
|
|
113
|
+
kind: string;
|
|
114
|
+
} & {
|
|
115
|
+
date?: string | null | undefined;
|
|
116
|
+
}) | ({
|
|
117
|
+
id: string;
|
|
118
|
+
url: string;
|
|
119
|
+
name: string;
|
|
120
|
+
kind: string;
|
|
121
|
+
size: string;
|
|
122
|
+
} & {
|
|
123
|
+
date?: string | null | undefined;
|
|
124
|
+
} & {
|
|
125
|
+
__TYPE__: "FileLink";
|
|
126
|
+
} & {
|
|
127
|
+
size?: string;
|
|
128
|
+
}) | ({
|
|
129
|
+
__TYPE__: "DocumentLink";
|
|
130
|
+
} & {
|
|
131
|
+
id: string;
|
|
132
|
+
}) | ({
|
|
133
|
+
__TYPE__: "ExternalLink";
|
|
134
|
+
} & {
|
|
135
|
+
url: string;
|
|
136
|
+
} & {
|
|
137
|
+
kind?: "web";
|
|
138
|
+
target?: string | null | undefined;
|
|
139
|
+
preview?: {
|
|
140
|
+
title?: string;
|
|
141
|
+
} | null | undefined;
|
|
142
|
+
});
|
|
105
143
|
} & {
|
|
106
144
|
start: number;
|
|
107
145
|
end: number;
|
|
@@ -241,13 +279,89 @@ export declare const RichTextContent: t.ExactC<t.TypeC<{
|
|
|
241
279
|
text: t.StringC;
|
|
242
280
|
}>, t.PartialC<{
|
|
243
281
|
spans: t.Type<({
|
|
244
|
-
data?:
|
|
282
|
+
data?: ({
|
|
283
|
+
__TYPE__: "ImageLink";
|
|
284
|
+
} & {
|
|
285
|
+
id: string;
|
|
286
|
+
url: string;
|
|
287
|
+
height: string;
|
|
288
|
+
width: string;
|
|
289
|
+
size: string;
|
|
290
|
+
name: string;
|
|
291
|
+
kind: string;
|
|
292
|
+
} & {
|
|
293
|
+
date?: string | null | undefined;
|
|
294
|
+
}) | ({
|
|
295
|
+
id: string;
|
|
296
|
+
url: string;
|
|
297
|
+
name: string;
|
|
298
|
+
kind: string;
|
|
299
|
+
size: string;
|
|
300
|
+
} & {
|
|
301
|
+
date?: string | null | undefined;
|
|
302
|
+
} & {
|
|
303
|
+
__TYPE__: "FileLink";
|
|
304
|
+
} & {
|
|
305
|
+
size?: string;
|
|
306
|
+
}) | ({
|
|
307
|
+
__TYPE__: "DocumentLink";
|
|
308
|
+
} & {
|
|
309
|
+
id: string;
|
|
310
|
+
}) | ({
|
|
311
|
+
__TYPE__: "ExternalLink";
|
|
312
|
+
} & {
|
|
313
|
+
url: string;
|
|
314
|
+
} & {
|
|
315
|
+
kind?: "web";
|
|
316
|
+
target?: string | null | undefined;
|
|
317
|
+
preview?: {
|
|
318
|
+
title?: string;
|
|
319
|
+
} | null | undefined;
|
|
320
|
+
});
|
|
245
321
|
} & {
|
|
246
322
|
start: number;
|
|
247
323
|
end: number;
|
|
248
324
|
type: "image" | "label" | "paragraph" | "heading1" | "heading2" | "heading3" | "heading4" | "heading5" | "heading6" | "strong" | "em" | "preformatted" | "hyperlink" | "embed" | "list-item" | "o-list-item" | "rtl";
|
|
249
325
|
})[], ({
|
|
250
|
-
data?:
|
|
326
|
+
data?: ({
|
|
327
|
+
__TYPE__: "ImageLink";
|
|
328
|
+
} & {
|
|
329
|
+
id: string;
|
|
330
|
+
url: string;
|
|
331
|
+
height: string;
|
|
332
|
+
width: string;
|
|
333
|
+
size: string;
|
|
334
|
+
name: string;
|
|
335
|
+
kind: string;
|
|
336
|
+
} & {
|
|
337
|
+
date?: string | null | undefined;
|
|
338
|
+
}) | ({
|
|
339
|
+
id: string;
|
|
340
|
+
url: string;
|
|
341
|
+
name: string;
|
|
342
|
+
kind: string;
|
|
343
|
+
size: string;
|
|
344
|
+
} & {
|
|
345
|
+
date?: string | null | undefined;
|
|
346
|
+
} & {
|
|
347
|
+
__TYPE__: "FileLink";
|
|
348
|
+
} & {
|
|
349
|
+
size?: string;
|
|
350
|
+
}) | ({
|
|
351
|
+
__TYPE__: "DocumentLink";
|
|
352
|
+
} & {
|
|
353
|
+
id: string;
|
|
354
|
+
}) | ({
|
|
355
|
+
__TYPE__: "ExternalLink";
|
|
356
|
+
} & {
|
|
357
|
+
url: string;
|
|
358
|
+
} & {
|
|
359
|
+
kind?: "web";
|
|
360
|
+
target?: string | null | undefined;
|
|
361
|
+
preview?: {
|
|
362
|
+
title?: string;
|
|
363
|
+
} | null | undefined;
|
|
364
|
+
});
|
|
251
365
|
} & {
|
|
252
366
|
start: number;
|
|
253
367
|
end: number;
|
|
@@ -361,7 +475,45 @@ export declare const RichTextLegacy: (ctx: LegacyContentCtx) => t.Type<{
|
|
|
361
475
|
text: string;
|
|
362
476
|
} & {
|
|
363
477
|
spans?: ({
|
|
364
|
-
data?:
|
|
478
|
+
data?: ({
|
|
479
|
+
__TYPE__: "ImageLink";
|
|
480
|
+
} & {
|
|
481
|
+
id: string;
|
|
482
|
+
url: string;
|
|
483
|
+
height: string;
|
|
484
|
+
width: string;
|
|
485
|
+
size: string;
|
|
486
|
+
name: string;
|
|
487
|
+
kind: string;
|
|
488
|
+
} & {
|
|
489
|
+
date?: string | null | undefined;
|
|
490
|
+
}) | ({
|
|
491
|
+
id: string;
|
|
492
|
+
url: string;
|
|
493
|
+
name: string;
|
|
494
|
+
kind: string;
|
|
495
|
+
size: string;
|
|
496
|
+
} & {
|
|
497
|
+
date?: string | null | undefined;
|
|
498
|
+
} & {
|
|
499
|
+
__TYPE__: "FileLink";
|
|
500
|
+
} & {
|
|
501
|
+
size?: string;
|
|
502
|
+
}) | ({
|
|
503
|
+
__TYPE__: "DocumentLink";
|
|
504
|
+
} & {
|
|
505
|
+
id: string;
|
|
506
|
+
}) | ({
|
|
507
|
+
__TYPE__: "ExternalLink";
|
|
508
|
+
} & {
|
|
509
|
+
url: string;
|
|
510
|
+
} & {
|
|
511
|
+
kind?: "web";
|
|
512
|
+
target?: string | null | undefined;
|
|
513
|
+
preview?: {
|
|
514
|
+
title?: string;
|
|
515
|
+
} | null | undefined;
|
|
516
|
+
});
|
|
365
517
|
} & {
|
|
366
518
|
start: number;
|
|
367
519
|
end: number;
|
|
@@ -470,7 +622,45 @@ export declare const RichTextLegacy: (ctx: LegacyContentCtx) => t.Type<{
|
|
|
470
622
|
text: string;
|
|
471
623
|
} & {
|
|
472
624
|
spans?: ({
|
|
473
|
-
data?:
|
|
625
|
+
data?: ({
|
|
626
|
+
__TYPE__: "ImageLink";
|
|
627
|
+
} & {
|
|
628
|
+
id: string;
|
|
629
|
+
url: string;
|
|
630
|
+
height: string;
|
|
631
|
+
width: string;
|
|
632
|
+
size: string;
|
|
633
|
+
name: string;
|
|
634
|
+
kind: string;
|
|
635
|
+
} & {
|
|
636
|
+
date?: string | null | undefined;
|
|
637
|
+
}) | ({
|
|
638
|
+
id: string;
|
|
639
|
+
url: string;
|
|
640
|
+
name: string;
|
|
641
|
+
kind: string;
|
|
642
|
+
size: string;
|
|
643
|
+
} & {
|
|
644
|
+
date?: string | null | undefined;
|
|
645
|
+
} & {
|
|
646
|
+
__TYPE__: "FileLink";
|
|
647
|
+
} & {
|
|
648
|
+
size?: string;
|
|
649
|
+
}) | ({
|
|
650
|
+
__TYPE__: "DocumentLink";
|
|
651
|
+
} & {
|
|
652
|
+
id: string;
|
|
653
|
+
}) | ({
|
|
654
|
+
__TYPE__: "ExternalLink";
|
|
655
|
+
} & {
|
|
656
|
+
url: string;
|
|
657
|
+
} & {
|
|
658
|
+
kind?: "web";
|
|
659
|
+
target?: string | null | undefined;
|
|
660
|
+
preview?: {
|
|
661
|
+
title?: string;
|
|
662
|
+
} | null | undefined;
|
|
663
|
+
});
|
|
474
664
|
} & {
|
|
475
665
|
start: number;
|
|
476
666
|
end: number;
|