@prismicio/types-internal 1.0.0-alpha.0 → 1.0.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 +666 -666
- package/lib/customtypes/CustomType.js +6 -6
- package/lib/customtypes/Section.d.ts +667 -667
- package/lib/customtypes/Section.js +1 -1
- package/lib/customtypes/widgets/Group.js +2 -2
- package/lib/customtypes/widgets/UID.js +2 -2
- package/lib/customtypes/widgets/Widget.d.ts +666 -666
- package/lib/customtypes/widgets/Widget.js +3 -3
- package/lib/customtypes/widgets/WidgetTypes.d.ts +2 -2
- package/lib/customtypes/widgets/WidgetTypes.js +2 -2
- package/lib/customtypes/widgets/index.d.ts +1 -1
- package/lib/customtypes/widgets/index.js +1 -1
- package/lib/customtypes/widgets/nestable/BooleanField.js +2 -2
- package/lib/customtypes/widgets/nestable/Color.js +2 -2
- package/lib/customtypes/widgets/nestable/Date.js +2 -2
- package/lib/customtypes/widgets/nestable/Embed.js +2 -2
- package/lib/customtypes/widgets/nestable/GeoPoint.js +2 -2
- package/lib/customtypes/widgets/nestable/Image.js +2 -2
- package/lib/customtypes/widgets/nestable/IntegrationField.js +2 -2
- package/lib/customtypes/widgets/nestable/Link.js +2 -2
- package/lib/customtypes/widgets/nestable/Number.js +2 -2
- package/lib/customtypes/widgets/nestable/Range.js +2 -2
- package/lib/customtypes/widgets/nestable/RichText.d.ts +1 -0
- package/lib/customtypes/widgets/nestable/RichText.js +2 -2
- package/lib/customtypes/widgets/nestable/Select.js +2 -2
- package/lib/customtypes/widgets/nestable/Separator.js +2 -2
- package/lib/customtypes/widgets/nestable/Text.js +2 -2
- package/lib/customtypes/widgets/nestable/Timestamp.js +2 -2
- package/lib/customtypes/widgets/slices/CompositeSlice.js +2 -2
- package/lib/customtypes/widgets/slices/SharedSlice.js +2 -2
- package/lib/customtypes/widgets/slices/SharedSliceRef.js +2 -2
- package/lib/customtypes/widgets/slices/Slices.d.ts +696 -696
- package/lib/customtypes/widgets/slices/Slices.js +5 -5
- package/lib/customtypes/widgets/slices/SlicesTypes.d.ts +2 -2
- package/lib/customtypes/widgets/slices/SlicesTypes.js +2 -2
- package/lib/customtypes/widgets/slices/index.d.ts +1 -1
- package/lib/customtypes/widgets/slices/index.js +1 -1
- package/lib/documents/widgets/index.d.ts +2 -1
- package/lib/documents/widgets/index.js +3 -3
- package/lib/documents/widgets/nestable/Link/index.d.ts +1 -0
- package/lib/documents/widgets/nestable/StructuredTextContent/Block.js +1 -1
- package/package.json +1 -1
- package/src/customtypes/CustomType.ts +3 -3
- package/src/customtypes/Section.ts +2 -2
- package/src/customtypes/widgets/Group.ts +1 -1
- package/src/customtypes/widgets/UID.ts +1 -1
- package/src/customtypes/widgets/Widget.ts +1 -1
- package/src/customtypes/widgets/WidgetTypes.ts +2 -2
- package/src/customtypes/widgets/index.ts +1 -1
- package/src/customtypes/widgets/nestable/BooleanField.ts +1 -1
- package/src/customtypes/widgets/nestable/Color.ts +1 -1
- package/src/customtypes/widgets/nestable/Date.ts +1 -1
- package/src/customtypes/widgets/nestable/Embed.ts +1 -1
- package/src/customtypes/widgets/nestable/GeoPoint.ts +1 -1
- package/src/customtypes/widgets/nestable/Image.ts +1 -1
- package/src/customtypes/widgets/nestable/IntegrationField.ts +1 -1
- package/src/customtypes/widgets/nestable/Link.ts +1 -1
- package/src/customtypes/widgets/nestable/Number.ts +1 -1
- package/src/customtypes/widgets/nestable/Range.ts +1 -1
- package/src/customtypes/widgets/nestable/RichText.ts +3 -1
- package/src/customtypes/widgets/nestable/Select.ts +1 -1
- package/src/customtypes/widgets/nestable/Separator.ts +1 -1
- package/src/customtypes/widgets/nestable/Text.ts +1 -1
- package/src/customtypes/widgets/nestable/Timestamp.ts +1 -1
- package/src/customtypes/widgets/slices/CompositeSlice.ts +1 -1
- package/src/customtypes/widgets/slices/SharedSlice.ts +1 -1
- package/src/customtypes/widgets/slices/SharedSliceRef.ts +1 -1
- package/src/customtypes/widgets/slices/Slices.ts +2 -2
- package/src/customtypes/widgets/slices/SlicesTypes.ts +2 -2
- package/src/customtypes/widgets/slices/index.ts +1 -1
- package/src/documents/widgets/index.ts +4 -1
- package/src/documents/widgets/nestable/Link/index.ts +2 -0
- package/src/documents/widgets/nestable/StructuredTextContent/Block.ts +1 -1
|
@@ -4,12 +4,12 @@ exports.Slices = exports.DynamicSlices = exports.StaticSlices = exports.slicesRe
|
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const t = (0, tslib_1.__importStar)(require("io-ts"));
|
|
6
6
|
const validators_1 = require("../../../validators");
|
|
7
|
-
const WidgetTypes_1 =
|
|
7
|
+
const WidgetTypes_1 = require("../WidgetTypes");
|
|
8
8
|
const CompositeSlice_1 = (0, tslib_1.__importDefault)(require("./CompositeSlice"));
|
|
9
9
|
const LegacySlice_1 = (0, tslib_1.__importDefault)(require("./LegacySlice"));
|
|
10
10
|
const SharedSlice_1 = require("./SharedSlice");
|
|
11
11
|
const SharedSliceRef_1 = (0, tslib_1.__importDefault)(require("./SharedSliceRef"));
|
|
12
|
-
const SlicesTypes_1 =
|
|
12
|
+
const SlicesTypes_1 = require("./SlicesTypes");
|
|
13
13
|
exports.SlicesLabels = t.union([
|
|
14
14
|
t.record(t.string, t.readonlyArray(t.exact(t.intersection([
|
|
15
15
|
t.type({
|
|
@@ -34,7 +34,7 @@ exports.DynamicSlicesConfig = slicesConfigReader(SharedSliceRef_1.default);
|
|
|
34
34
|
const SlicesConfig = {
|
|
35
35
|
toStatic(config, sharedSlices) {
|
|
36
36
|
const choices = Object.entries(config.choices || {}).reduce((acc, [ref, slice]) => {
|
|
37
|
-
if (slice.type === SlicesTypes_1.
|
|
37
|
+
if (slice.type === SlicesTypes_1.SlicesTypes.SharedSlice) {
|
|
38
38
|
const sharedSlice = sharedSlices.get(ref);
|
|
39
39
|
if (sharedSlice)
|
|
40
40
|
return { ...acc, [ref]: sharedSlice };
|
|
@@ -52,8 +52,8 @@ function slicesReader(codec) {
|
|
|
52
52
|
return t.exact(t.intersection([
|
|
53
53
|
t.type({
|
|
54
54
|
type: t.union([
|
|
55
|
-
t.literal(WidgetTypes_1.
|
|
56
|
-
t.literal(WidgetTypes_1.
|
|
55
|
+
t.literal(WidgetTypes_1.WidgetTypes.Slices),
|
|
56
|
+
t.literal(WidgetTypes_1.WidgetTypes.LegacySlices),
|
|
57
57
|
]),
|
|
58
58
|
}),
|
|
59
59
|
t.partial({
|
|
@@ -4,4 +4,4 @@ export * from "./SharedSlice";
|
|
|
4
4
|
export { default as SharedSliceRef } from "./SharedSliceRef";
|
|
5
5
|
export * as Slice from "./Slice";
|
|
6
6
|
export * as SliceZone from "./Slices";
|
|
7
|
-
export {
|
|
7
|
+
export { SlicesTypes } from "./SlicesTypes";
|
|
@@ -12,4 +12,4 @@ Object.defineProperty(exports, "SharedSliceRef", { enumerable: true, get: functi
|
|
|
12
12
|
exports.Slice = (0, tslib_1.__importStar)(require("./Slice"));
|
|
13
13
|
exports.SliceZone = (0, tslib_1.__importStar)(require("./Slices"));
|
|
14
14
|
var SlicesTypes_1 = require("./SlicesTypes");
|
|
15
|
-
Object.defineProperty(exports, "SlicesTypes", { enumerable: true, get: function () { return
|
|
15
|
+
Object.defineProperty(exports, "SlicesTypes", { enumerable: true, get: function () { return SlicesTypes_1.SlicesTypes; } });
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SlicesContent } from "./slices
|
|
1
|
+
import { SlicesContent } from "./slices";
|
|
2
2
|
import StaticWidgetContent from "./StaticWidgetContent";
|
|
3
3
|
export * from "./EmptyContent";
|
|
4
4
|
export * from "./GroupContent";
|
|
@@ -28,6 +28,7 @@ export declare const WidgetTypes: {
|
|
|
28
28
|
readonly IntegrationFields: "IntegrationFieldsContent";
|
|
29
29
|
readonly Separator: "SeparatorContent";
|
|
30
30
|
};
|
|
31
|
+
export declare type WidgetTypes = typeof WidgetTypes[keyof typeof WidgetTypes];
|
|
31
32
|
export declare type WidgetKey = string;
|
|
32
33
|
export declare type WidgetContent = SlicesContent | StaticWidgetContent;
|
|
33
34
|
export declare const Widget: {
|
|
@@ -5,7 +5,7 @@ const tslib_1 = require("tslib");
|
|
|
5
5
|
const EmptyContent_1 = require("./EmptyContent");
|
|
6
6
|
const GroupContent_1 = require("./GroupContent");
|
|
7
7
|
const nestable_1 = require("./nestable");
|
|
8
|
-
const
|
|
8
|
+
const slices_1 = require("./slices");
|
|
9
9
|
const StaticWidgetContent_1 = (0, tslib_1.__importDefault)(require("./StaticWidgetContent"));
|
|
10
10
|
const UIDContent_1 = require("./UIDContent");
|
|
11
11
|
(0, tslib_1.__exportStar)(require("./EmptyContent"), exports);
|
|
@@ -21,13 +21,13 @@ exports.WidgetTypes = {
|
|
|
21
21
|
Empty: EmptyContent_1.EmptyContentType,
|
|
22
22
|
UID: UIDContent_1.UIDContentType,
|
|
23
23
|
Group: GroupContent_1.GroupContentType,
|
|
24
|
-
slices:
|
|
24
|
+
slices: slices_1.SlicesContentType,
|
|
25
25
|
};
|
|
26
26
|
exports.Widget = {
|
|
27
27
|
fromJson(widgetKey, widgetValue, widgetTypes, widgetPositions) {
|
|
28
28
|
const fieldType = widgetTypes.get(widgetKey);
|
|
29
29
|
if (fieldType === "Slices") {
|
|
30
|
-
return
|
|
30
|
+
return slices_1.SlicesContent.fromJson(widgetKey, widgetValue, widgetTypes, widgetPositions);
|
|
31
31
|
}
|
|
32
32
|
else {
|
|
33
33
|
return StaticWidgetContent_1.default.fromJson([], widgetKey, widgetValue, widgetTypes, widgetPositions);
|
|
@@ -17,7 +17,7 @@ exports.Meta = t.exact(t.intersection([
|
|
|
17
17
|
t.type({
|
|
18
18
|
start: t.number,
|
|
19
19
|
end: t.number,
|
|
20
|
-
type: t.union([nestable_1.RichTextNodeTypeCodec, t.literal(
|
|
20
|
+
type: t.union([nestable_1.RichTextNodeTypeCodec, t.literal("label")]),
|
|
21
21
|
}),
|
|
22
22
|
]));
|
|
23
23
|
// export alias for code clarity
|
package/package.json
CHANGED
|
@@ -7,9 +7,9 @@ import { DynamicSection, Sections, StaticSection } from "./Section"
|
|
|
7
7
|
import type { SharedSlice } from "./widgets/slices/SharedSlice"
|
|
8
8
|
import type { DynamicSlice } from "./widgets/slices/Slice"
|
|
9
9
|
import type { DynamicSlices } from "./widgets/slices/Slices"
|
|
10
|
-
import SlicesTypes from "./widgets/slices/SlicesTypes"
|
|
10
|
+
import { SlicesTypes } from "./widgets/slices/SlicesTypes"
|
|
11
11
|
import type { DynamicWidget } from "./widgets/Widget"
|
|
12
|
-
import WidgetTypes from "./widgets/WidgetTypes"
|
|
12
|
+
import { WidgetTypes } from "./widgets/WidgetTypes"
|
|
13
13
|
|
|
14
14
|
class CustomTypeSlicesError extends Error {
|
|
15
15
|
slices: Array<string>
|
|
@@ -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,12 @@
|
|
|
1
1
|
import * as t from "io-ts"
|
|
2
2
|
|
|
3
|
-
import type { SharedSlice } from "./widgets/slices
|
|
3
|
+
import type { SharedSlice } from "./widgets/slices"
|
|
4
4
|
import { DynamicWidget, StaticWidget, Widgets } from "./widgets/Widget"
|
|
5
5
|
|
|
6
6
|
export function sectionReader<T extends StaticWidget | DynamicWidget>(
|
|
7
7
|
codec: t.Type<T, unknown>,
|
|
8
8
|
) {
|
|
9
|
-
return t.record(t.string, codec)
|
|
9
|
+
return t.record(t.string, codec) // WidgetId -> Widget Data
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
export const StaticSection = sectionReader(StaticWidget)
|
|
@@ -2,7 +2,7 @@ import * as t from "io-ts"
|
|
|
2
2
|
|
|
3
3
|
import { StringOrNull } from "../../validators"
|
|
4
4
|
import NestableWidget from "./nestable/NestableWidget"
|
|
5
|
-
import WidgetTypes from "./WidgetTypes"
|
|
5
|
+
import { WidgetTypes } from "./WidgetTypes"
|
|
6
6
|
|
|
7
7
|
const GroupConfig = t.exact(
|
|
8
8
|
t.partial({
|
|
@@ -5,7 +5,7 @@ import NestableWidget from "./nestable/NestableWidget"
|
|
|
5
5
|
import type { SharedSlice } from "./slices/SharedSlice"
|
|
6
6
|
import { DynamicSlices, Slices, StaticSlices } from "./slices/Slices"
|
|
7
7
|
import UID from "./UID"
|
|
8
|
-
import WidgetTypes from "./WidgetTypes"
|
|
8
|
+
import { WidgetTypes } from "./WidgetTypes"
|
|
9
9
|
|
|
10
10
|
export function widgetReader<T extends StaticSlices | DynamicSlices>(
|
|
11
11
|
codec: t.Type<T, unknown>,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const WidgetTypes = {
|
|
1
|
+
export const WidgetTypes = {
|
|
2
2
|
Text: "Text",
|
|
3
3
|
RichText: "StructuredText",
|
|
4
4
|
Color: "Color",
|
|
@@ -21,4 +21,4 @@ const WidgetTypes = {
|
|
|
21
21
|
LegacySlices: "Choice",
|
|
22
22
|
} as const
|
|
23
23
|
|
|
24
|
-
export
|
|
24
|
+
export type WidgetTypes = typeof WidgetTypes[keyof typeof WidgetTypes]
|
|
@@ -2,7 +2,7 @@ import * as t from "io-ts"
|
|
|
2
2
|
|
|
3
3
|
import { StringOrNull } from "../../../validators"
|
|
4
4
|
import ImageConstraint from "../shared/ImageConstraint"
|
|
5
|
-
import WidgetTypes from "../WidgetTypes"
|
|
5
|
+
import { WidgetTypes } from "../WidgetTypes"
|
|
6
6
|
|
|
7
7
|
const Thumbnail = t.exact(
|
|
8
8
|
t.intersection([
|
|
@@ -3,7 +3,7 @@ import * as t from "io-ts"
|
|
|
3
3
|
import { withFallback } from "io-ts-types/lib/withFallback"
|
|
4
4
|
|
|
5
5
|
import { StringOrNull } from "../../../validators"
|
|
6
|
-
import WidgetTypes from "../WidgetTypes"
|
|
6
|
+
import { WidgetTypes } from "../WidgetTypes"
|
|
7
7
|
|
|
8
8
|
const arrayString = (
|
|
9
9
|
entries:
|
|
@@ -2,7 +2,7 @@ import * as t from "io-ts"
|
|
|
2
2
|
import { NumberFromString } from "io-ts-types/lib/NumberFromString"
|
|
3
3
|
|
|
4
4
|
import { StringOrNull } from "../../../validators"
|
|
5
|
-
import WidgetTypes from "../WidgetTypes"
|
|
5
|
+
import { WidgetTypes } from "../WidgetTypes"
|
|
6
6
|
|
|
7
7
|
const NumberConfig = t.exact(
|
|
8
8
|
t.partial({
|
|
@@ -2,7 +2,7 @@ import * as t from "io-ts"
|
|
|
2
2
|
import { NumberFromString } from "io-ts-types/lib/NumberFromString"
|
|
3
3
|
|
|
4
4
|
import { StringOrNull } from "../../../validators"
|
|
5
|
-
import WidgetTypes from "../WidgetTypes"
|
|
5
|
+
import { WidgetTypes } from "../WidgetTypes"
|
|
6
6
|
|
|
7
7
|
const RangeConfig = t.exact(
|
|
8
8
|
t.partial({
|
|
@@ -3,10 +3,12 @@ import * as t from "io-ts"
|
|
|
3
3
|
|
|
4
4
|
import { StringOrNull } from "../../../validators"
|
|
5
5
|
import ImageConstraint from "../shared/ImageConstraint"
|
|
6
|
-
import WidgetTypes from "../WidgetTypes"
|
|
6
|
+
import { WidgetTypes } from "../WidgetTypes"
|
|
7
7
|
|
|
8
8
|
export const DEFAULT_OPTION = "paragraph"
|
|
9
9
|
|
|
10
|
+
export type RichTextNodeType =
|
|
11
|
+
typeof RichTextNodeType[keyof typeof RichTextNodeType]
|
|
10
12
|
export const RichTextNodeType = {
|
|
11
13
|
heading1: "heading1",
|
|
12
14
|
heading2: "heading2",
|
|
@@ -2,7 +2,7 @@ import * as t from "io-ts"
|
|
|
2
2
|
|
|
3
3
|
import { StringOrNull } from "../../../validators"
|
|
4
4
|
import NestableWidget from "../nestable/NestableWidget"
|
|
5
|
-
import SlicesTypes from "./SlicesTypes"
|
|
5
|
+
import { SlicesTypes } from "./SlicesTypes"
|
|
6
6
|
|
|
7
7
|
const CompositeSliceConfig = t.exact(
|
|
8
8
|
t.partial({
|
|
@@ -2,7 +2,7 @@ import * as t from "io-ts"
|
|
|
2
2
|
import { withFallback } from "io-ts-types/lib/withFallback"
|
|
3
3
|
|
|
4
4
|
import NestableWidget from "../nestable/NestableWidget"
|
|
5
|
-
import SlicesTypes from "./SlicesTypes"
|
|
5
|
+
import { SlicesTypes } from "./SlicesTypes"
|
|
6
6
|
|
|
7
7
|
const IMAGE_PLACEHOLDER_URL =
|
|
8
8
|
"https://images.prismic.io/slice-machine/621a5ec4-0387-4bc5-9860-2dd46cbc07cd_default_ss.png?auto=compress,format"
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import * as t from "io-ts"
|
|
2
2
|
|
|
3
3
|
import { StringOrNull } from "../../../validators"
|
|
4
|
-
import WidgetTypes from "../WidgetTypes"
|
|
4
|
+
import { WidgetTypes } from "../WidgetTypes"
|
|
5
5
|
import CompositeSlice from "./CompositeSlice"
|
|
6
6
|
import LegacySlice from "./LegacySlice"
|
|
7
7
|
import { SharedSlice } from "./SharedSlice"
|
|
8
8
|
import SharedSliceRef from "./SharedSliceRef"
|
|
9
|
-
import SlicesTypes from "./SlicesTypes"
|
|
9
|
+
import { SlicesTypes } from "./SlicesTypes"
|
|
10
10
|
|
|
11
11
|
export const SlicesLabels = t.union([
|
|
12
12
|
t.record(
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { EmptyContentType } from "./EmptyContent"
|
|
2
2
|
import { GroupContentType } from "./GroupContent"
|
|
3
3
|
import { NestableTypes } from "./nestable"
|
|
4
|
-
import { SlicesContent, SlicesContentType } from "./slices
|
|
4
|
+
import { SlicesContent, SlicesContentType } from "./slices"
|
|
5
5
|
import StaticWidgetContent from "./StaticWidgetContent"
|
|
6
6
|
import { UIDContentType } from "./UIDContent"
|
|
7
7
|
|
|
@@ -24,7 +24,10 @@ export const WidgetTypes = {
|
|
|
24
24
|
slices: SlicesContentType,
|
|
25
25
|
} as const
|
|
26
26
|
|
|
27
|
+
export type WidgetTypes = typeof WidgetTypes[keyof typeof WidgetTypes]
|
|
28
|
+
|
|
27
29
|
export type WidgetKey = string
|
|
30
|
+
|
|
28
31
|
export type WidgetContent = SlicesContent | StaticWidgetContent
|
|
29
32
|
|
|
30
33
|
export const Widget = {
|