@prismicio/types-internal 0.3.0 → 0.3.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/customtypes/CustomType.d.ts +679 -679
- package/lib/customtypes/Section.d.ts +683 -683
- package/lib/customtypes/Section.js +2 -1
- package/lib/customtypes/widgets/Group.d.ts +1 -1
- package/lib/customtypes/widgets/Group.js +2 -1
- package/lib/customtypes/widgets/Widget.d.ts +678 -678
- package/lib/customtypes/widgets/slices/CompositeSlice.d.ts +2 -2
- package/lib/customtypes/widgets/slices/CompositeSlice.js +3 -2
- package/lib/customtypes/widgets/slices/LegacySlice.d.ts +1 -1
- package/lib/customtypes/widgets/slices/SharedSlice.d.ts +4 -4
- package/lib/customtypes/widgets/slices/SharedSlice.js +3 -2
- package/lib/customtypes/widgets/slices/Slices.d.ts +720 -720
- package/lib/customtypes/widgets/slices/Slices.js +2 -1
- package/lib/documents/widgets/index.d.ts +4 -2
- package/lib/documents/widgets/index.js +8 -4
- package/package.json +1 -1
- package/src/customtypes/CustomType.ts +1 -1
- package/src/customtypes/Section.ts +3 -2
- package/src/customtypes/widgets/Group.ts +2 -1
- package/src/customtypes/widgets/slices/CompositeSlice.ts +3 -2
- package/src/customtypes/widgets/slices/SharedSlice.ts +3 -2
- package/src/customtypes/widgets/slices/Slices.ts +2 -1
- package/src/documents/widgets/index.ts +10 -2
- package/lib/customtypes/Format.d.ts +0 -4
- package/lib/customtypes/Format.js +0 -8
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.Slices = exports.DynamicSlices = exports.StaticSlices = exports.slicesReader = exports.DynamicSlicesConfig = exports.StaticSlicesConfig = exports.slicesConfigReader = exports.SlicesLabels = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const t = (0, tslib_1.__importStar)(require("io-ts"));
|
|
6
|
+
const widgets_1 = require("../../../documents/widgets");
|
|
6
7
|
const validators_1 = require("../../../validators");
|
|
7
8
|
const WidgetTypes_1 = (0, tslib_1.__importDefault)(require("../WidgetTypes"));
|
|
8
9
|
const CompositeSlice_1 = (0, tslib_1.__importDefault)(require("./CompositeSlice"));
|
|
@@ -25,7 +26,7 @@ function slicesConfigReader(codec) {
|
|
|
25
26
|
return t.exact(t.partial({
|
|
26
27
|
label: validators_1.StringOrNull,
|
|
27
28
|
labels: exports.SlicesLabels,
|
|
28
|
-
choices: t.record(
|
|
29
|
+
choices: t.record(widgets_1.WidgetKey, t.union([LegacySlice_1.default, CompositeSlice_1.default, codec])),
|
|
29
30
|
}));
|
|
30
31
|
}
|
|
31
32
|
exports.slicesConfigReader = slicesConfigReader;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as t from "io-ts";
|
|
2
|
+
import { SlicesContent } from "./slices";
|
|
2
3
|
import StaticWidgetContent from "./StaticWidgetContent";
|
|
3
4
|
export * from "./EmptyContent";
|
|
4
5
|
export * from "./GroupContent";
|
|
@@ -28,7 +29,8 @@ export declare const WidgetTypes: {
|
|
|
28
29
|
readonly IntegrationFields: "IntegrationFieldsContent";
|
|
29
30
|
readonly Separator: "SeparatorContent";
|
|
30
31
|
};
|
|
31
|
-
export declare
|
|
32
|
+
export declare const WidgetKey: t.Type<string, string, unknown>;
|
|
33
|
+
export declare type WidgetKey = t.TypeOf<typeof WidgetKey>;
|
|
32
34
|
export declare type WidgetContent = SlicesContent | StaticWidgetContent;
|
|
33
35
|
export declare const Widget: {
|
|
34
36
|
fromJson(widgetKey: WidgetKey, widgetValue: unknown, widgetTypes: Map<WidgetKey, string>, widgetPositions: Map<WidgetKey, number>): import("fp-ts/lib/Option").None | import("fp-ts/lib/Option").Some<StaticWidgetContent> | import("fp-ts/lib/Option").Some<SlicesContent>;
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Widget = exports.WidgetTypes = exports.StaticWidgetContent = exports.Slices = exports.Nestable = void 0;
|
|
3
|
+
exports.Widget = exports.WidgetKey = exports.WidgetTypes = exports.StaticWidgetContent = exports.Slices = exports.Nestable = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
+
const t = (0, tslib_1.__importStar)(require("io-ts"));
|
|
6
|
+
const function_1 = require("../../validators/function");
|
|
5
7
|
const EmptyContent_1 = require("./EmptyContent");
|
|
6
8
|
const GroupContent_1 = require("./GroupContent");
|
|
7
9
|
const nestable_1 = require("./nestable");
|
|
8
|
-
const
|
|
10
|
+
const slices_1 = require("./slices");
|
|
9
11
|
const StaticWidgetContent_1 = (0, tslib_1.__importDefault)(require("./StaticWidgetContent"));
|
|
10
12
|
const UIDContent_1 = require("./UIDContent");
|
|
11
13
|
(0, tslib_1.__exportStar)(require("./EmptyContent"), exports);
|
|
@@ -21,13 +23,15 @@ exports.WidgetTypes = {
|
|
|
21
23
|
Empty: EmptyContent_1.EmptyContentType,
|
|
22
24
|
UID: UIDContent_1.UIDContentType,
|
|
23
25
|
Group: GroupContent_1.GroupContentType,
|
|
24
|
-
slices:
|
|
26
|
+
slices: slices_1.SlicesContentType,
|
|
25
27
|
};
|
|
28
|
+
const widgetKeyRegex = new RegExp("^[^<>]+$");
|
|
29
|
+
exports.WidgetKey = (0, function_1.refineType)(t.string, "WidgetKey", (s) => widgetKeyRegex.test(s));
|
|
26
30
|
exports.Widget = {
|
|
27
31
|
fromJson(widgetKey, widgetValue, widgetTypes, widgetPositions) {
|
|
28
32
|
const fieldType = widgetTypes.get(widgetKey);
|
|
29
33
|
if (fieldType === "Slices") {
|
|
30
|
-
return
|
|
34
|
+
return slices_1.SlicesContent.fromJson(widgetKey, widgetValue, widgetTypes, widgetPositions);
|
|
31
35
|
}
|
|
32
36
|
else {
|
|
33
37
|
return StaticWidgetContent_1.default.fromJson([], widgetKey, widgetValue, widgetTypes, widgetPositions);
|
package/package.json
CHANGED
|
@@ -38,7 +38,7 @@ function customTypeReader<T extends StaticSection | DynamicSection>(
|
|
|
38
38
|
id: t.string,
|
|
39
39
|
label: StringOrNull,
|
|
40
40
|
repeatable: withFallback(t.boolean, true),
|
|
41
|
-
json: t.record(t.string, codec),
|
|
41
|
+
json: t.record(t.string, codec), //tab name => tab data
|
|
42
42
|
status: withFallback(t.boolean, true),
|
|
43
43
|
}),
|
|
44
44
|
t.partial({
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import * as t from "io-ts"
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import { WidgetKey } from "../documents/widgets"
|
|
4
|
+
import type { SharedSlice } from "./widgets/slices"
|
|
4
5
|
import { DynamicWidget, StaticWidget, Widgets } from "./widgets/Widget"
|
|
5
6
|
|
|
6
7
|
export function sectionReader<T extends StaticWidget | DynamicWidget>(
|
|
7
8
|
codec: t.Type<T, unknown>,
|
|
8
9
|
) {
|
|
9
|
-
return t.record(
|
|
10
|
+
return t.record(WidgetKey, codec) // WidgetId -> Widget Data
|
|
10
11
|
}
|
|
11
12
|
|
|
12
13
|
export const StaticSection = sectionReader(StaticWidget)
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as t from "io-ts"
|
|
2
2
|
|
|
3
|
+
import { WidgetKey } from "../../documents/widgets"
|
|
3
4
|
import { StringOrNull } from "../../validators"
|
|
4
5
|
import NestableWidget from "./nestable/NestableWidget"
|
|
5
6
|
import WidgetTypes from "./WidgetTypes"
|
|
@@ -8,7 +9,7 @@ const GroupConfig = t.exact(
|
|
|
8
9
|
t.partial({
|
|
9
10
|
label: StringOrNull,
|
|
10
11
|
repeat: t.boolean,
|
|
11
|
-
fields: t.record(
|
|
12
|
+
fields: t.record(WidgetKey, NestableWidget),
|
|
12
13
|
}),
|
|
13
14
|
)
|
|
14
15
|
type GroupConfig = t.TypeOf<typeof GroupConfig>
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as t from "io-ts"
|
|
2
2
|
|
|
3
|
+
import { WidgetKey } from "../../../documents/widgets"
|
|
3
4
|
import { StringOrNull } from "../../../validators"
|
|
4
5
|
import NestableWidget from "../nestable/NestableWidget"
|
|
5
6
|
import SlicesTypes from "./SlicesTypes"
|
|
@@ -21,8 +22,8 @@ const CompositeSlice = t.exact(
|
|
|
21
22
|
description: t.string,
|
|
22
23
|
icon: t.string,
|
|
23
24
|
display: t.string,
|
|
24
|
-
"non-repeat": t.record(
|
|
25
|
-
repeat: t.record(
|
|
25
|
+
"non-repeat": t.record(WidgetKey, NestableWidget),
|
|
26
|
+
repeat: t.record(WidgetKey, NestableWidget),
|
|
26
27
|
config: CompositeSliceConfig,
|
|
27
28
|
}),
|
|
28
29
|
]),
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as t from "io-ts"
|
|
2
2
|
import { withFallback } from "io-ts-types/lib/withFallback"
|
|
3
3
|
|
|
4
|
+
import { WidgetKey } from "../../../documents/widgets"
|
|
4
5
|
import NestableWidget from "../nestable/NestableWidget"
|
|
5
6
|
import SlicesTypes from "./SlicesTypes"
|
|
6
7
|
|
|
@@ -19,8 +20,8 @@ export const Variation = t.exact(
|
|
|
19
20
|
}),
|
|
20
21
|
t.partial({
|
|
21
22
|
display: t.string,
|
|
22
|
-
primary: t.record(
|
|
23
|
-
items: t.record(
|
|
23
|
+
primary: t.record(WidgetKey, NestableWidget),
|
|
24
|
+
items: t.record(WidgetKey, NestableWidget),
|
|
24
25
|
}),
|
|
25
26
|
]),
|
|
26
27
|
)
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as t from "io-ts"
|
|
2
2
|
|
|
3
|
+
import { WidgetKey } from "../../../documents/widgets"
|
|
3
4
|
import { StringOrNull } from "../../../validators"
|
|
4
5
|
import WidgetTypes from "../WidgetTypes"
|
|
5
6
|
import CompositeSlice from "./CompositeSlice"
|
|
@@ -36,7 +37,7 @@ export function slicesConfigReader<T extends SharedSlice | SharedSliceRef>(
|
|
|
36
37
|
label: StringOrNull,
|
|
37
38
|
labels: SlicesLabels,
|
|
38
39
|
choices: t.record(
|
|
39
|
-
|
|
40
|
+
WidgetKey,
|
|
40
41
|
t.union([LegacySlice, CompositeSlice, codec]),
|
|
41
42
|
),
|
|
42
43
|
}),
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
+
import * as t from "io-ts"
|
|
2
|
+
|
|
3
|
+
import { refineType } from "../../validators/function"
|
|
1
4
|
import { EmptyContentType } from "./EmptyContent"
|
|
2
5
|
import { GroupContentType } from "./GroupContent"
|
|
3
6
|
import { NestableTypes } from "./nestable"
|
|
4
|
-
import { SlicesContent, SlicesContentType } from "./slices
|
|
7
|
+
import { SlicesContent, SlicesContentType } from "./slices"
|
|
5
8
|
import StaticWidgetContent from "./StaticWidgetContent"
|
|
6
9
|
import { UIDContentType } from "./UIDContent"
|
|
7
10
|
|
|
@@ -24,7 +27,12 @@ export const WidgetTypes = {
|
|
|
24
27
|
slices: SlicesContentType,
|
|
25
28
|
} as const
|
|
26
29
|
|
|
27
|
-
|
|
30
|
+
const widgetKeyRegex = new RegExp("^[^<>]+$")
|
|
31
|
+
export const WidgetKey = refineType(t.string, "WidgetKey", (s: string) =>
|
|
32
|
+
widgetKeyRegex.test(s),
|
|
33
|
+
)
|
|
34
|
+
export type WidgetKey = t.TypeOf<typeof WidgetKey>
|
|
35
|
+
|
|
28
36
|
export type WidgetContent = SlicesContent | StaticWidgetContent
|
|
29
37
|
|
|
30
38
|
export const Widget = {
|