@prismicio/types-internal 3.3.0 → 3.4.0-alpha.1
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 +1 -1
- package/lib/content/LegacyContentCtx.d.ts +1 -0
- package/lib/content/fields/RepeatableContent.d.ts +78 -4
- package/lib/content/fields/RepeatableContent.js +14 -10
- package/lib/content/fields/nestable/TableContent.d.ts +1097 -0
- package/lib/content/fields/nestable/TableContent.js +43 -0
- package/lib/content/fields/nestable/index.d.ts +1 -0
- package/lib/content/fields/nestable/index.js +1 -0
- package/lib/customtypes/widgets/Widget.d.ts +1 -0
- package/lib/customtypes/widgets/Widget.js +1 -0
- package/lib/customtypes/widgets/nestable/Table.d.ts +15 -0
- package/lib/customtypes/widgets/nestable/Table.js +18 -0
- package/lib/customtypes/widgets/nestable/index.d.ts +1 -0
- package/lib/customtypes/widgets/nestable/index.js +1 -0
- package/package.json +1 -1
- package/src/content/fields/nestable/TableContent.ts +66 -0
- package/src/content/fields/nestable/index.ts +1 -0
- package/src/customtypes/widgets/Widget.ts +2 -0
- package/src/customtypes/widgets/nestable/Table.ts +25 -0
- package/src/customtypes/widgets/nestable/index.ts +1 -0
- package/lib/content/fields/nestable/RichTextContent/TextBlock.d.ts +0 -727
- package/lib/content/fields/nestable/RichTextContent/TextBlock.js +0 -80
- package/lib/customtypes/widgets/slices/SliceWidget.d.ts +0 -327
- package/lib/customtypes/widgets/slices/SliceWidget.js +0 -8
|
@@ -3102,7 +3102,7 @@ declare function parseLegacyDocument(legacyDoc: unknown, customType: StaticCusto
|
|
|
3102
3102
|
}): Document | undefined;
|
|
3103
3103
|
declare function encodeToLegacyDocument(document: Document): DocumentLegacy;
|
|
3104
3104
|
export declare const DocumentLegacy: {
|
|
3105
|
-
_codec: (allTypes?: Map<string, "Boolean" | "Color" | "Date" | "Embed" | "GeoPoint" | "Image" | "IntegrationFields" | "Link" | "Number" | "Range" | "StructuredText" | "Select" | "Separator" | "Text" | "Timestamp" | "Group" | "Slice" | "SharedSlice" | "Choice" | "Slices" | "UID" | "Repeatable.Link"> | undefined) => t.Type<{
|
|
3105
|
+
_codec: (allTypes?: Map<string, "Boolean" | "Color" | "Date" | "Embed" | "GeoPoint" | "Image" | "IntegrationFields" | "Link" | "Number" | "Range" | "StructuredText" | "Select" | "Separator" | "Text" | "Timestamp" | "Group" | "Slice" | "SharedSlice" | "Table" | "Choice" | "Slices" | "UID" | "Repeatable.Link"> | undefined) => t.Type<{
|
|
3106
3106
|
[x: string]: {
|
|
3107
3107
|
type: string;
|
|
3108
3108
|
__TYPE__: "EmptyContent";
|
|
@@ -1,10 +1,84 @@
|
|
|
1
1
|
import * as t from "io-ts";
|
|
2
2
|
import type { ContentPath, TraverseWidgetContentFn } from "../../_internal/utils";
|
|
3
|
-
import type
|
|
3
|
+
import { type Link, NestableFieldTypes, NestableWidget } from "../../customtypes";
|
|
4
4
|
import type { LegacyContentCtx, WithTypes } from "../LegacyContentCtx";
|
|
5
|
+
export declare const RepeatableContentType: "RepeatableContent";
|
|
6
|
+
export declare const RepeatableFieldType: "Repeatable";
|
|
7
|
+
export declare const RepeatableItemContent: t.ExactC<t.TypeC<{
|
|
8
|
+
__TYPE__: t.LiteralC<"LinkContent">;
|
|
9
|
+
value: t.UnionC<[t.IntersectionC<[t.ExactC<t.TypeC<{
|
|
10
|
+
__TYPE__: t.LiteralC<"ImageLink">;
|
|
11
|
+
}>>, t.UnionC<[t.IntersectionC<[t.IntersectionC<[t.ExactC<t.TypeC<{
|
|
12
|
+
kind: t.StringC;
|
|
13
|
+
id: t.StringC;
|
|
14
|
+
url: t.StringC;
|
|
15
|
+
height: t.StringC;
|
|
16
|
+
width: t.StringC;
|
|
17
|
+
size: t.StringC;
|
|
18
|
+
name: t.StringC;
|
|
19
|
+
}>>, t.ExactC<t.PartialC<{
|
|
20
|
+
date: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
|
|
21
|
+
}>>]>, t.ExactC<t.PartialC<{
|
|
22
|
+
text: t.StringC;
|
|
23
|
+
}>>]>, t.ExactC<t.TypeC<{
|
|
24
|
+
kind: t.LiteralC<"image">;
|
|
25
|
+
text: t.StringC;
|
|
26
|
+
}>>]>]>, t.IntersectionC<[t.ExactC<t.TypeC<{
|
|
27
|
+
__TYPE__: t.LiteralC<"FileLink">;
|
|
28
|
+
}>>, t.UnionC<[t.IntersectionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
|
|
29
|
+
kind: t.StringC;
|
|
30
|
+
id: t.StringC;
|
|
31
|
+
url: t.StringC;
|
|
32
|
+
name: t.StringC;
|
|
33
|
+
size: t.StringC;
|
|
34
|
+
}>, t.PartialC<{
|
|
35
|
+
date: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
|
|
36
|
+
}>]>>, t.ExactC<t.PartialC<{
|
|
37
|
+
text: t.StringC;
|
|
38
|
+
}>>]>, t.ExactC<t.TypeC<{
|
|
39
|
+
kind: t.LiteralC<"file">;
|
|
40
|
+
text: t.StringC;
|
|
41
|
+
}>>]>]>, t.IntersectionC<[t.ExactC<t.TypeC<{
|
|
42
|
+
__TYPE__: t.LiteralC<"DocumentLink">;
|
|
43
|
+
}>>, t.UnionC<[t.IntersectionC<[t.ExactC<t.TypeC<{
|
|
44
|
+
id: t.Type<string, string, unknown>;
|
|
45
|
+
}>>, t.ExactC<t.PartialC<{
|
|
46
|
+
text: t.StringC;
|
|
47
|
+
}>>]>, t.ExactC<t.TypeC<{
|
|
48
|
+
kind: t.LiteralC<"document">;
|
|
49
|
+
text: t.StringC;
|
|
50
|
+
}>>]>]>, t.IntersectionC<[t.ExactC<t.TypeC<{
|
|
51
|
+
__TYPE__: t.LiteralC<"ExternalLink">;
|
|
52
|
+
}>>, t.UnionC<[t.IntersectionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
|
|
53
|
+
url: t.StringC;
|
|
54
|
+
}>, t.PartialC<{
|
|
55
|
+
kind: t.LiteralC<"web">;
|
|
56
|
+
target: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
|
|
57
|
+
preview: t.UnionC<[t.Type<{
|
|
58
|
+
title?: string;
|
|
59
|
+
}, {
|
|
60
|
+
title?: string;
|
|
61
|
+
}, unknown>, t.NullC, t.UndefinedC]>;
|
|
62
|
+
}>]>>, t.ExactC<t.PartialC<{
|
|
63
|
+
text: t.StringC;
|
|
64
|
+
}>>]>, t.ExactC<t.TypeC<{
|
|
65
|
+
kind: t.LiteralC<"web">;
|
|
66
|
+
text: t.StringC;
|
|
67
|
+
}>>]>]>, t.IntersectionC<[t.ExactC<t.TypeC<{
|
|
68
|
+
__TYPE__: t.LiteralC<"MediaLink">;
|
|
69
|
+
}>>, t.ExactC<t.TypeC<{
|
|
70
|
+
kind: t.LiteralC<"media">;
|
|
71
|
+
text: t.StringC;
|
|
72
|
+
}>>]>, t.IntersectionC<[t.ExactC<t.TypeC<{
|
|
73
|
+
__TYPE__: t.LiteralC<"AnyLink">;
|
|
74
|
+
}>>, t.ExactC<t.TypeC<{
|
|
75
|
+
text: t.StringC;
|
|
76
|
+
}>>]>]>;
|
|
77
|
+
}>>;
|
|
78
|
+
export declare type RepeatableItemContent = t.TypeOf<typeof RepeatableItemContent>;
|
|
5
79
|
export declare const RepeatableContent: t.ExactC<t.TypeC<{
|
|
6
80
|
__TYPE__: t.LiteralC<"RepeatableContent">;
|
|
7
|
-
type: t.LiteralC<"Link">;
|
|
81
|
+
type: t.UnionC<[t.LiteralC<"Color">, t.LiteralC<"Boolean">, t.LiteralC<"Embed">, t.LiteralC<"GeoPoint">, t.LiteralC<"Date">, t.LiteralC<"Number">, t.LiteralC<"Range">, t.LiteralC<"StructuredText">, t.LiteralC<"Select">, t.LiteralC<"Separator">, t.LiteralC<"Text">, t.LiteralC<"Timestamp">, t.LiteralC<"Link">, t.LiteralC<"Image">, t.LiteralC<"IntegrationFields">]>;
|
|
8
82
|
value: t.ArrayC<t.ExactC<t.TypeC<{
|
|
9
83
|
__TYPE__: t.LiteralC<"LinkContent">;
|
|
10
84
|
value: t.UnionC<[t.IntersectionC<[t.ExactC<t.TypeC<{
|
|
@@ -80,7 +154,7 @@ export declare const RepeatableContent: t.ExactC<t.TypeC<{
|
|
|
80
154
|
export declare type RepeatableContent = t.TypeOf<typeof RepeatableContent>;
|
|
81
155
|
export declare const isRepeatableContent: t.Is<{
|
|
82
156
|
__TYPE__: "RepeatableContent";
|
|
83
|
-
type: "Link";
|
|
157
|
+
type: "Boolean" | "Color" | "Date" | "Embed" | "GeoPoint" | "Image" | "IntegrationFields" | "Link" | "Number" | "Range" | "StructuredText" | "Select" | "Separator" | "Text" | "Timestamp";
|
|
84
158
|
value: {
|
|
85
159
|
__TYPE__: "LinkContent";
|
|
86
160
|
value: ({
|
|
@@ -151,7 +225,7 @@ export declare const isRepeatableContent: t.Is<{
|
|
|
151
225
|
});
|
|
152
226
|
}[];
|
|
153
227
|
}>;
|
|
154
|
-
export declare const RepeatableLegacy: (ctx: LegacyContentCtx, fieldType:
|
|
228
|
+
export declare const RepeatableLegacy: (ctx: LegacyContentCtx, fieldType: NestableFieldTypes) => t.Type<RepeatableContent, WithTypes<Array<unknown>>, unknown>;
|
|
155
229
|
export declare type RepeatableCustomType = Link;
|
|
156
230
|
export declare function traverseRepeatableContent({ path, key, apiId, model, content, }: {
|
|
157
231
|
path: ContentPath;
|
|
@@ -1,21 +1,28 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.traverseRepeatableContent = exports.RepeatableLegacy = exports.isRepeatableContent = exports.RepeatableContent = void 0;
|
|
3
|
+
exports.traverseRepeatableContent = exports.RepeatableLegacy = exports.isRepeatableContent = exports.RepeatableContent = exports.RepeatableItemContent = exports.RepeatableFieldType = exports.RepeatableContentType = 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");
|
|
7
7
|
const function_1 = require("fp-ts/lib/function");
|
|
8
8
|
const t = (0, tslib_1.__importStar)(require("io-ts"));
|
|
9
|
+
const customtypes_1 = require("../../customtypes");
|
|
9
10
|
const nestable_1 = require("./nestable");
|
|
11
|
+
exports.RepeatableContentType = "RepeatableContent";
|
|
12
|
+
exports.RepeatableFieldType = "Repeatable";
|
|
13
|
+
exports.RepeatableItemContent = nestable_1.LinkContent;
|
|
10
14
|
exports.RepeatableContent = t.strict({
|
|
11
|
-
__TYPE__: t.literal(
|
|
12
|
-
type:
|
|
13
|
-
|
|
15
|
+
__TYPE__: t.literal(exports.RepeatableContentType),
|
|
16
|
+
type: customtypes_1.NestableFieldTypes,
|
|
17
|
+
// TODO: How to ensure it's an array of only one type
|
|
18
|
+
value: t.array(exports.RepeatableItemContent),
|
|
14
19
|
});
|
|
15
20
|
exports.isRepeatableContent = exports.RepeatableContent.is;
|
|
16
21
|
const RepeatableLegacy = (ctx, fieldType) => {
|
|
22
|
+
const codecDecode = t.array(t.unknown);
|
|
23
|
+
const codecEncode = t.array(exports.RepeatableItemContent);
|
|
17
24
|
return new t.Type("RepeatableLegacy", exports.isRepeatableContent, (items) => {
|
|
18
|
-
const parsed = (0, function_1.pipe)(
|
|
25
|
+
const parsed = (0, function_1.pipe)(codecDecode.decode(items), fp_ts_1.either.map((items) => {
|
|
19
26
|
const parsedItems = items.reduce((acc, item) => {
|
|
20
27
|
let result;
|
|
21
28
|
switch (fieldType) {
|
|
@@ -32,12 +39,12 @@ const RepeatableLegacy = (ctx, fieldType) => {
|
|
|
32
39
|
return {
|
|
33
40
|
value: parsedItems,
|
|
34
41
|
type: fieldType,
|
|
35
|
-
__TYPE__:
|
|
42
|
+
__TYPE__: exports.RepeatableContentType,
|
|
36
43
|
};
|
|
37
44
|
}));
|
|
38
45
|
return parsed;
|
|
39
46
|
}, (r) => {
|
|
40
|
-
const res =
|
|
47
|
+
const res = codecEncode.encode(r.value);
|
|
41
48
|
const encodedItems = res.reduce((acc, item) => {
|
|
42
49
|
let encoded;
|
|
43
50
|
switch (item.__TYPE__) {
|
|
@@ -72,9 +79,6 @@ function traverseRepeatableContent({ path, key, apiId, model, content, }) {
|
|
|
72
79
|
// Can happen if the transform function returns undefined to filter out a field
|
|
73
80
|
if (!transformedField)
|
|
74
81
|
return acc;
|
|
75
|
-
// If the transformed field is not a link content, we don't include it
|
|
76
|
-
if (!(0, nestable_1.isLinkContent)(transformedField))
|
|
77
|
-
return acc;
|
|
78
82
|
return acc.concat(transformedField);
|
|
79
83
|
}, []);
|
|
80
84
|
return transform({
|