@prismicio/types-internal 2.5.0-alpha.2 → 2.5.0-alpha.4
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 +957 -45
- package/lib/content/fields/GroupContent.d.ts +8 -8
- package/lib/content/fields/GroupContent.js +14 -32
- package/lib/content/fields/WidgetContent.d.ts +957 -45
- package/lib/content/fields/nestable/NestableContent.d.ts +155 -3
- package/lib/content/fields/nestable/RichTextContent/Blocks.d.ts +232 -4
- package/lib/content/fields/nestable/RichTextContent/Blocks.js +5 -2
- package/lib/content/fields/nestable/RichTextContent/index.d.ts +194 -4
- package/lib/content/fields/slices/Slice/CompositeSliceContent.d.ts +314 -10
- package/lib/content/fields/slices/Slice/CompositeSliceContent.js +0 -3
- package/lib/content/fields/slices/Slice/RepeatableContent.d.ts +80 -3
- package/lib/content/fields/slices/Slice/RepeatableContent.js +4 -1
- package/lib/content/fields/slices/Slice/SharedSliceContent.d.ts +314 -10
- package/lib/content/fields/slices/Slice/SharedSliceContent.js +0 -2
- package/lib/content/fields/slices/Slice/SimpleSliceContent.d.ts +155 -3
- package/lib/content/fields/slices/Slice/SimpleSliceContent.js +0 -1
- package/lib/content/fields/slices/Slice/SlicePrimaryContent.d.ts +155 -3
- package/lib/content/fields/slices/Slice/index.d.ts +586 -16
- package/lib/content/fields/slices/SliceItem.d.ts +586 -16
- package/lib/content/fields/slices/SlicesContent.d.ts +817 -57
- package/lib/customtypes/CustomType.d.ts +2042 -690
- package/lib/customtypes/Section.d.ts +2028 -676
- package/lib/customtypes/diff/SharedSlice.d.ts +678 -2
- package/lib/customtypes/diff/Variation.d.ts +678 -3
- package/lib/customtypes/widgets/Group.d.ts +996 -15
- package/lib/customtypes/widgets/Group.js +15 -27
- package/lib/customtypes/widgets/Widget.d.ts +1684 -7
- package/lib/customtypes/widgets/slices/LegacySlice.d.ts +168 -2
- package/lib/customtypes/widgets/slices/LegacySlice.js +1 -1
- package/lib/customtypes/widgets/slices/SharedSlice.d.ts +670 -2
- package/lib/customtypes/widgets/slices/SlicePrimaryWidget.d.ts +674 -3
- package/lib/customtypes/widgets/slices/Slices.d.ts +1522 -7
- package/package.json +1 -1
- package/src/content/fields/GroupContent.ts +24 -48
- package/src/content/fields/nestable/RichTextContent/Blocks.ts +6 -3
- package/src/content/fields/slices/Slice/CompositeSliceContent.ts +4 -7
- package/src/content/fields/slices/Slice/RepeatableContent.ts +9 -2
- package/src/content/fields/slices/Slice/SharedSliceContent.ts +3 -5
- package/src/content/fields/slices/Slice/SimpleSliceContent.ts +1 -3
- package/src/customtypes/widgets/Group.ts +34 -61
- package/src/customtypes/widgets/slices/LegacySlice.ts +2 -2
|
@@ -3,19 +3,20 @@ import type { ContentPath, TraverseWidgetContentFn } from "../../_internal/utils
|
|
|
3
3
|
import { type Group, type NestableWidget } from "../../customtypes";
|
|
4
4
|
import { LegacyContentCtx, WithTypes } from "../LegacyContentCtx";
|
|
5
5
|
import { NestableContent } from "./nestable";
|
|
6
|
-
export declare const GroupContentType: "GroupContentType";
|
|
7
|
-
export declare const isGroupContent: (u: unknown) => u is GroupContent;
|
|
8
|
-
export declare const GroupContent: t.Type<GroupContent>;
|
|
9
|
-
export declare type GroupContent = {
|
|
10
|
-
__TYPE__: typeof GroupContentType;
|
|
11
|
-
value: GroupItemContent[];
|
|
12
|
-
};
|
|
13
6
|
export declare const GroupItemContentType: "GroupItemContent";
|
|
7
|
+
export declare const GroupContentType: "GroupContentType";
|
|
14
8
|
export declare const GroupItemContent: t.Type<GroupItemContent>;
|
|
15
9
|
export declare type GroupItemContent = {
|
|
16
10
|
__TYPE__: typeof GroupItemContentType;
|
|
17
11
|
value: [string, NestableContent | GroupContent][];
|
|
18
12
|
};
|
|
13
|
+
export declare const GroupContent: t.Type<GroupContent>;
|
|
14
|
+
export declare type GroupContent = {
|
|
15
|
+
__TYPE__: typeof GroupContentType;
|
|
16
|
+
value: GroupItemContent[];
|
|
17
|
+
};
|
|
18
|
+
export declare const isGroupContent: (u: unknown) => u is GroupContent;
|
|
19
|
+
export declare const GroupContentDefaultValue: GroupContent;
|
|
19
20
|
declare const itemLegacyReader: t.RecordC<t.StringC, t.UnknownC>;
|
|
20
21
|
declare type GroupItemLegacy = t.TypeOf<typeof itemLegacyReader>;
|
|
21
22
|
export declare const GroupItemLegacy: (ctx: LegacyContentCtx) => t.Type<GroupItemContent, WithTypes<{
|
|
@@ -23,7 +24,6 @@ export declare const GroupItemLegacy: (ctx: LegacyContentCtx) => t.Type<GroupIte
|
|
|
23
24
|
}>, unknown>;
|
|
24
25
|
declare type GroupLegacy = Array<GroupItemLegacy>;
|
|
25
26
|
export declare const GroupLegacy: (ctx: LegacyContentCtx) => t.Type<GroupContent, WithTypes<GroupLegacy>, unknown>;
|
|
26
|
-
export declare const GroupContentDefaultValue: GroupContent;
|
|
27
27
|
export declare function groupContentWithDefaultValues(customType: Group, content: GroupContent): GroupContent;
|
|
28
28
|
export declare function traverseGroupContent({ path, key, apiId, model, content, }: {
|
|
29
29
|
path: ContentPath;
|
|
@@ -1,48 +1,34 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.traverseGroupItemsContent = exports.traverseGroupContent = exports.groupContentWithDefaultValues = exports.
|
|
3
|
+
exports.traverseGroupItemsContent = exports.traverseGroupContent = exports.groupContentWithDefaultValues = exports.GroupLegacy = exports.GroupItemLegacy = exports.GroupContentDefaultValue = exports.isGroupContent = exports.GroupContent = exports.GroupItemContent = exports.GroupContentType = exports.GroupItemContentType = 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
9
|
const customtypes_1 = require("../../customtypes");
|
|
10
|
-
const function_2 = require("../../validators/function");
|
|
11
10
|
const LegacyContentCtx_1 = require("../LegacyContentCtx");
|
|
12
11
|
const utils_1 = require("../utils");
|
|
13
12
|
const nestable_1 = require("./nestable");
|
|
14
13
|
const withDefaultValues_1 = require("./withDefaultValues");
|
|
15
|
-
exports.GroupContentType = "GroupContentType";
|
|
16
|
-
const isGroupContent = (u) => (0, utils_1.hasContentType)(u) && u.__TYPE__ === exports.GroupContentType;
|
|
17
|
-
exports.isGroupContent = isGroupContent;
|
|
18
|
-
const MAX_GROUP_DEPTH = 1;
|
|
19
|
-
const getGroupDepth = (group, depth = 0) => {
|
|
20
|
-
// Stop searching when we're over limit
|
|
21
|
-
if (depth > MAX_GROUP_DEPTH)
|
|
22
|
-
return depth;
|
|
23
|
-
for (const item of group.value) {
|
|
24
|
-
for (const [_key, widget] of item.value) {
|
|
25
|
-
if ((0, exports.isGroupContent)(widget)) {
|
|
26
|
-
depth = Math.max(depth, getGroupDepth(widget, depth + 1));
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
return depth;
|
|
31
|
-
};
|
|
32
|
-
exports.GroupContent = (0, function_2.refineType)(t.recursion("GroupContent", () => t.strict({
|
|
33
|
-
__TYPE__: t.literal(exports.GroupContentType),
|
|
34
|
-
value: t.array(exports.GroupItemContent),
|
|
35
|
-
})), "GroupContent", (g) => {
|
|
36
|
-
if (getGroupDepth(g) > MAX_GROUP_DEPTH) {
|
|
37
|
-
throw new Error(`GroupContent is nested too deeply (max ${MAX_GROUP_DEPTH} level)`);
|
|
38
|
-
}
|
|
39
|
-
return true;
|
|
40
|
-
});
|
|
41
14
|
exports.GroupItemContentType = "GroupItemContent";
|
|
15
|
+
exports.GroupContentType = "GroupContentType";
|
|
42
16
|
exports.GroupItemContent = t.recursion("GroupItemContent", () => t.strict({
|
|
43
17
|
__TYPE__: t.literal(exports.GroupItemContentType),
|
|
44
18
|
value: t.array(t.tuple([t.string, t.union([nestable_1.NestableContent, exports.GroupContent])])),
|
|
45
19
|
}));
|
|
20
|
+
exports.GroupContent = t.recursion("GroupContent", () => t.strict({
|
|
21
|
+
__TYPE__: t.literal(exports.GroupContentType),
|
|
22
|
+
value: t.array(exports.GroupItemContent),
|
|
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;
|
|
28
|
+
exports.GroupContentDefaultValue = {
|
|
29
|
+
__TYPE__: exports.GroupContentType,
|
|
30
|
+
value: [],
|
|
31
|
+
};
|
|
46
32
|
const itemLegacyReader = t.record(t.string, t.unknown);
|
|
47
33
|
const GroupItemLegacy = (ctx) => {
|
|
48
34
|
return new t.Type("GroupItemLegacy", (u) => (0, utils_1.hasContentType)(u) && u.__TYPE__ === exports.GroupItemContentType, (u) => {
|
|
@@ -107,10 +93,6 @@ const GroupLegacy = (ctx) => {
|
|
|
107
93
|
});
|
|
108
94
|
};
|
|
109
95
|
exports.GroupLegacy = GroupLegacy;
|
|
110
|
-
exports.GroupContentDefaultValue = {
|
|
111
|
-
__TYPE__: exports.GroupContentType,
|
|
112
|
-
value: [],
|
|
113
|
-
};
|
|
114
96
|
function groupContentWithDefaultValues(customType, content) {
|
|
115
97
|
var _a;
|
|
116
98
|
const fields = (_a = customType.config) === null || _a === void 0 ? void 0 : _a.fields;
|