@prismicio/types-internal 0.2.4 → 0.2.8
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 +2 -1
- package/lib/customtypes/CustomType.js +7 -4
- package/lib/customtypes/Section.d.ts +1 -1
- package/lib/customtypes/widgets/Widget.d.ts +1 -1
- package/lib/customtypes/widgets/nestable/NestableWidget.js +2 -2
- package/lib/customtypes/widgets/nestable/RichText.d.ts +22 -3
- package/lib/customtypes/widgets/nestable/RichText.js +64 -24
- package/lib/customtypes/widgets/nestable/index.d.ts +2 -1
- package/lib/customtypes/widgets/nestable/index.js +19 -20
- package/lib/customtypes/widgets/slices/SharedSlice.d.ts +327 -3
- package/lib/customtypes/widgets/slices/SharedSlice.js +4 -4
- package/lib/customtypes/widgets/slices/Slice.d.ts +1 -1
- package/lib/customtypes/widgets/slices/Slices.d.ts +7 -1
- package/lib/customtypes/widgets/slices/Slices.js +5 -5
- package/lib/customtypes/widgets/slices/index.d.ts +1 -1
- package/lib/customtypes/widgets/slices/index.js +2 -3
- package/lib/documents/DocumentData.d.ts +9 -0
- package/lib/documents/DocumentData.js +42 -0
- package/lib/documents/widgets/SimpleWidgetContent.d.ts +2 -2
- package/lib/documents/widgets/SimpleWidgetContent.js +2 -2
- package/lib/documents/widgets/index.d.ts +13 -13
- package/lib/documents/widgets/nestable/EmbedContent.d.ts +6 -3
- package/lib/documents/widgets/nestable/EmbedContent.js +2 -3
- package/lib/documents/widgets/nestable/FieldContent.d.ts +3 -2
- package/lib/documents/widgets/nestable/StructuredTextContent/Block.d.ts +2 -3
- package/lib/documents/widgets/nestable/StructuredTextContent/Block.js +2 -2
- package/lib/documents/widgets/nestable/index.d.ts +1 -1
- package/lib/documents/widgets/nestable/index.js +2 -3
- package/package.json +1 -1
- package/src/customtypes/CustomType.ts +8 -7
- package/src/customtypes/Section.ts +1 -1
- package/src/customtypes/widgets/Widget.ts +1 -1
- package/src/customtypes/widgets/nestable/NestableWidget.ts +1 -1
- package/src/customtypes/widgets/nestable/RichText.ts +64 -24
- package/src/customtypes/widgets/nestable/index.ts +2 -1
- package/src/customtypes/widgets/slices/SharedSlice.ts +4 -6
- package/src/customtypes/widgets/slices/Slice.ts +1 -1
- package/src/customtypes/widgets/slices/Slices.ts +3 -3
- package/src/customtypes/widgets/slices/index.ts +1 -1
- package/src/documents/DocumentData.ts +58 -0
- package/src/documents/widgets/SimpleWidgetContent.ts +4 -4
- package/src/documents/widgets/index.ts +1 -1
- package/src/documents/widgets/nestable/EmbedContent.ts +8 -6
- package/src/documents/widgets/nestable/FieldContent.ts +10 -2
- package/src/documents/widgets/nestable/StructuredTextContent/Block.ts +1 -1
- package/src/documents/widgets/nestable/index.ts +1 -1
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SharedSlice = exports.Variation = void 0;
|
|
3
4
|
const tslib_1 = require("tslib");
|
|
4
5
|
const t = (0, tslib_1.__importStar)(require("io-ts"));
|
|
5
6
|
const withFallback_1 = require("io-ts-types/lib/withFallback");
|
|
6
7
|
const NestableWidget_1 = (0, tslib_1.__importDefault)(require("../nestable/NestableWidget"));
|
|
7
8
|
const SlicesTypes_1 = (0, tslib_1.__importDefault)(require("./SlicesTypes"));
|
|
8
9
|
const IMAGE_PLACEHOLDER_URL = "https://images.prismic.io/slice-machine/621a5ec4-0387-4bc5-9860-2dd46cbc07cd_default_ss.png?auto=compress,format";
|
|
9
|
-
|
|
10
|
+
exports.Variation = t.exact(t.intersection([
|
|
10
11
|
t.type({
|
|
11
12
|
id: t.string,
|
|
12
13
|
name: t.string,
|
|
@@ -21,15 +22,14 @@ const Variation = t.exact(t.intersection([
|
|
|
21
22
|
items: t.record(t.string, NestableWidget_1.default),
|
|
22
23
|
}),
|
|
23
24
|
]));
|
|
24
|
-
|
|
25
|
+
exports.SharedSlice = t.exact(t.intersection([
|
|
25
26
|
t.type({
|
|
26
27
|
id: t.string,
|
|
27
28
|
type: t.literal(SlicesTypes_1.default.SharedSlice),
|
|
28
29
|
name: t.string,
|
|
29
|
-
variations: t.array(Variation),
|
|
30
|
+
variations: t.array(exports.Variation),
|
|
30
31
|
}),
|
|
31
32
|
t.partial({
|
|
32
33
|
description: t.string,
|
|
33
34
|
}),
|
|
34
35
|
]));
|
|
35
|
-
exports.default = SharedSlice;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type CompositeSlice from "./CompositeSlice";
|
|
2
2
|
import type LegacySlice from "./LegacySlice";
|
|
3
|
-
import type SharedSlice from "./SharedSlice";
|
|
3
|
+
import type { SharedSlice } from "./SharedSlice";
|
|
4
4
|
import type SharedSliceRef from "./SharedSliceRef";
|
|
5
5
|
export declare type DynamicSlice = CompositeSlice | LegacySlice | SharedSliceRef;
|
|
6
6
|
export declare type StaticSlice = CompositeSlice | LegacySlice | SharedSlice;
|
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
import * as t from "io-ts";
|
|
2
2
|
import { Format } from "../../Format";
|
|
3
3
|
import WidgetTypes from "../WidgetTypes";
|
|
4
|
-
import SharedSlice from "./SharedSlice";
|
|
4
|
+
import { SharedSlice } from "./SharedSlice";
|
|
5
5
|
import SlicesTypes from "./SlicesTypes";
|
|
6
|
+
export declare const SlicesLabels: t.UnionC<[t.RecordC<t.StringC, t.ArrayC<t.ExactC<t.IntersectionC<[t.TypeC<{
|
|
7
|
+
name: t.StringC;
|
|
8
|
+
}>, t.PartialC<{
|
|
9
|
+
display: t.StringC;
|
|
10
|
+
}>]>>>>, t.NullC]>;
|
|
11
|
+
export declare type SlicesLabels = t.TypeOf<typeof SlicesLabels>;
|
|
6
12
|
export declare function slicesConfigReader<F extends Format>(format: F): t.ExactC<t.PartialC<{
|
|
7
13
|
label: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
|
|
8
14
|
labels: t.UnionC<[t.RecordC<t.StringC, t.ArrayC<t.ExactC<t.IntersectionC<[t.TypeC<{
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Slices = exports.DynamicSlices = exports.StaticSlices = exports.slicesReader = exports.DynamicSlicesConfig = exports.StaticSlicesConfig = exports.slicesConfigReader = void 0;
|
|
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
6
|
const validators_1 = require("../../../validators");
|
|
@@ -8,10 +8,10 @@ const Format_1 = require("../../Format");
|
|
|
8
8
|
const WidgetTypes_1 = (0, tslib_1.__importDefault)(require("../WidgetTypes"));
|
|
9
9
|
const CompositeSlice_1 = (0, tslib_1.__importDefault)(require("./CompositeSlice"));
|
|
10
10
|
const LegacySlice_1 = (0, tslib_1.__importDefault)(require("./LegacySlice"));
|
|
11
|
-
const SharedSlice_1 =
|
|
11
|
+
const SharedSlice_1 = require("./SharedSlice");
|
|
12
12
|
const SharedSliceRef_1 = (0, tslib_1.__importDefault)(require("./SharedSliceRef"));
|
|
13
13
|
const SlicesTypes_1 = (0, tslib_1.__importDefault)(require("./SlicesTypes"));
|
|
14
|
-
|
|
14
|
+
exports.SlicesLabels = t.union([
|
|
15
15
|
t.record(t.string, t.array(t.exact(t.intersection([
|
|
16
16
|
t.type({
|
|
17
17
|
name: t.string,
|
|
@@ -25,14 +25,14 @@ const SlicesLabels = t.union([
|
|
|
25
25
|
function slicesConfigReader(format) {
|
|
26
26
|
return t.exact(t.partial({
|
|
27
27
|
label: validators_1.StringOrNull,
|
|
28
|
-
labels: SlicesLabels,
|
|
28
|
+
labels: exports.SlicesLabels,
|
|
29
29
|
choices: t.record(t.string, t.union([
|
|
30
30
|
LegacySlice_1.default,
|
|
31
31
|
CompositeSlice_1.default,
|
|
32
32
|
(() => {
|
|
33
33
|
switch (format) {
|
|
34
34
|
case Format_1.Format.Static:
|
|
35
|
-
return SharedSlice_1.
|
|
35
|
+
return SharedSlice_1.SharedSlice;
|
|
36
36
|
case Format_1.Format.Dynamic:
|
|
37
37
|
return SharedSliceRef_1.default;
|
|
38
38
|
default:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { default as CompositeSlice } from "./CompositeSlice";
|
|
2
2
|
export { default as LegacySlice } from "./LegacySlice";
|
|
3
|
-
export
|
|
3
|
+
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";
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SlicesTypes = exports.SliceZone = exports.Slice = exports.SharedSliceRef = exports.
|
|
3
|
+
exports.SlicesTypes = exports.SliceZone = exports.Slice = exports.SharedSliceRef = exports.LegacySlice = exports.CompositeSlice = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
var CompositeSlice_1 = require("./CompositeSlice");
|
|
6
6
|
Object.defineProperty(exports, "CompositeSlice", { enumerable: true, get: function () { return (0, tslib_1.__importDefault)(CompositeSlice_1).default; } });
|
|
7
7
|
var LegacySlice_1 = require("./LegacySlice");
|
|
8
8
|
Object.defineProperty(exports, "LegacySlice", { enumerable: true, get: function () { return (0, tslib_1.__importDefault)(LegacySlice_1).default; } });
|
|
9
|
-
|
|
10
|
-
Object.defineProperty(exports, "SharedSlice", { enumerable: true, get: function () { return (0, tslib_1.__importDefault)(SharedSlice_1).default; } });
|
|
9
|
+
(0, tslib_1.__exportStar)(require("./SharedSlice"), exports);
|
|
11
10
|
var SharedSliceRef_1 = require("./SharedSliceRef");
|
|
12
11
|
Object.defineProperty(exports, "SharedSliceRef", { enumerable: true, get: function () { return (0, tslib_1.__importDefault)(SharedSliceRef_1).default; } });
|
|
13
12
|
exports.Slice = (0, tslib_1.__importStar)(require("./Slice"));
|
|
@@ -4,5 +4,14 @@ declare type DocumentData = Map<WidgetKey, O.Option<WidgetContent>>;
|
|
|
4
4
|
declare const DocumentData: {
|
|
5
5
|
getWidget(key: WidgetKey, widgets: Map<WidgetKey, unknown>, widgetTypes: Map<WidgetKey, string>, widgetPositions: Map<WidgetKey, number>, parsed: Map<string, O.Option<WidgetContent>>): O.Option<WidgetContent>;
|
|
6
6
|
fromJson(widgets: Map<WidgetKey, unknown>, widgetTypes: Map<WidgetKey, string>, widgetPositions: Map<WidgetKey, number>): DocumentData;
|
|
7
|
+
partitionData(data: {
|
|
8
|
+
[p: string]: unknown;
|
|
9
|
+
}): {
|
|
10
|
+
types: Map<string, string>;
|
|
11
|
+
positions: Map<string, number>;
|
|
12
|
+
widgets: Map<WidgetKey, unknown>;
|
|
13
|
+
slugs: ReadonlyArray<string>;
|
|
14
|
+
uid: string | undefined;
|
|
15
|
+
};
|
|
7
16
|
};
|
|
8
17
|
export default DocumentData;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
|
+
const Either_1 = require("fp-ts/lib/Either");
|
|
4
5
|
const O = (0, tslib_1.__importStar)(require("fp-ts/lib/Option"));
|
|
6
|
+
const t = (0, tslib_1.__importStar)(require("io-ts"));
|
|
5
7
|
const widgets_1 = require("./widgets");
|
|
6
8
|
function computeWidget(key, widgets, widgetTypes, widgetPositions) {
|
|
7
9
|
const widget = widgets.get(key);
|
|
@@ -24,5 +26,45 @@ const DocumentData = {
|
|
|
24
26
|
return new Map([...Array.from(acc.entries()), [widgetKey, parsedWidget]]);
|
|
25
27
|
}, new Map());
|
|
26
28
|
},
|
|
29
|
+
partitionData(data) {
|
|
30
|
+
const fields = Object.entries(data);
|
|
31
|
+
const { types, positions, widgets } = fields.reduce((acc, [k, v]) => {
|
|
32
|
+
if (k.endsWith("_TYPE")) {
|
|
33
|
+
const decodedValue = t.string.decode(v);
|
|
34
|
+
if ((0, Either_1.isRight)(decodedValue)) {
|
|
35
|
+
return {
|
|
36
|
+
...acc,
|
|
37
|
+
types: acc.types.set(k.substring(0, k.length - 5), decodedValue.right),
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
if (k.endsWith("_POSITION") && typeof v === "number") {
|
|
42
|
+
return {
|
|
43
|
+
...acc,
|
|
44
|
+
positions: acc.positions.set(k.substring(0, k.length - 9), v),
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
if (!k.endsWith("_POSITION") && !k.endsWith("_TYPE")) {
|
|
48
|
+
return {
|
|
49
|
+
...acc,
|
|
50
|
+
widgets: acc.widgets.set(k, v),
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
return acc;
|
|
54
|
+
}, {
|
|
55
|
+
types: new Map(),
|
|
56
|
+
positions: new Map(),
|
|
57
|
+
widgets: new Map(),
|
|
58
|
+
});
|
|
59
|
+
const slugs = data["slugs_INTERNAL"] || [];
|
|
60
|
+
const uid = data["uid"];
|
|
61
|
+
return {
|
|
62
|
+
widgets,
|
|
63
|
+
types,
|
|
64
|
+
positions,
|
|
65
|
+
uid,
|
|
66
|
+
slugs,
|
|
67
|
+
};
|
|
68
|
+
},
|
|
27
69
|
};
|
|
28
70
|
exports.default = DocumentData;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as O from "fp-ts/Option";
|
|
2
2
|
import type { EmptyContent } from "./EmptyContent";
|
|
3
3
|
import BooleanContent from "./nestable/BooleanContent";
|
|
4
|
-
import
|
|
4
|
+
import { EmbedContentO } from "./nestable/EmbedContent";
|
|
5
5
|
import FieldContent from "./nestable/FieldContent";
|
|
6
6
|
import { GeoPointContentO } from "./nestable/GeoPointContent";
|
|
7
7
|
import { ImageContentO } from "./nestable/ImageContent";
|
|
@@ -11,7 +11,7 @@ import type { SeparatorContent } from "./nestable/SeparatorContent";
|
|
|
11
11
|
import { StructuredTextContent } from "./nestable/StructuredTextContent";
|
|
12
12
|
import { UIDContent } from "./UIDContent";
|
|
13
13
|
export declare const SimpleWidgetContentType: string[];
|
|
14
|
-
export declare type NonEmptySimpleWidgetContent = IntegrationFieldsContent | StructuredTextContent | ImageContentO | GeoPointContentO |
|
|
14
|
+
export declare type NonEmptySimpleWidgetContent = IntegrationFieldsContent | StructuredTextContent | ImageContentO | GeoPointContentO | EmbedContentO | LinkContent | UIDContent | SeparatorContent | FieldContent | BooleanContent;
|
|
15
15
|
export declare type SimpleWidgetContent = NonEmptySimpleWidgetContent | EmptyContent;
|
|
16
16
|
export declare function is(value: unknown): value is SimpleWidgetContent;
|
|
17
17
|
export declare const SimpleWidgetContent: {
|
|
@@ -6,7 +6,7 @@ const function_1 = require("fp-ts/function");
|
|
|
6
6
|
const O = (0, tslib_1.__importStar)(require("fp-ts/Option"));
|
|
7
7
|
const t = (0, tslib_1.__importStar)(require("io-ts"));
|
|
8
8
|
const BooleanContent_1 = (0, tslib_1.__importDefault)(require("./nestable/BooleanContent"));
|
|
9
|
-
const EmbedContent_1 =
|
|
9
|
+
const EmbedContent_1 = require("./nestable/EmbedContent");
|
|
10
10
|
const FieldContent_1 = (0, tslib_1.__importDefault)(require("./nestable/FieldContent"));
|
|
11
11
|
const GeoPointContent_1 = require("./nestable/GeoPointContent");
|
|
12
12
|
const ImageContent_1 = require("./nestable/ImageContent");
|
|
@@ -52,7 +52,7 @@ exports.SimpleWidgetContent = {
|
|
|
52
52
|
case "GeoPoint":
|
|
53
53
|
return (0, function_1.pipe)(O.fromEither(GeoPointContent_1.GeoPointContent.decode(content)), O.map((geopointContent) => GeoPointContent_1.GeoPointContent.encode(geopointContent)));
|
|
54
54
|
case "Embed":
|
|
55
|
-
return O.fromEither(EmbedContent_1.
|
|
55
|
+
return O.fromEither(EmbedContent_1.EmbedContent.decode(content));
|
|
56
56
|
case "Link":
|
|
57
57
|
return O.fromEither(Link_1.LinkContent.decode(content));
|
|
58
58
|
case "UID":
|
|
@@ -8,25 +8,25 @@ export * as Slices from "./slices";
|
|
|
8
8
|
export { type NonEmptyStaticWidgetContent, default as StaticWidgetContent, } from "./StaticWidgetContent";
|
|
9
9
|
export * from "./UIDContent";
|
|
10
10
|
export declare const WidgetTypes: {
|
|
11
|
-
Empty:
|
|
12
|
-
UID:
|
|
13
|
-
Group:
|
|
14
|
-
slices:
|
|
15
|
-
Links: {
|
|
11
|
+
readonly Empty: "EmptyContent";
|
|
12
|
+
readonly UID: "UIDContent";
|
|
13
|
+
readonly Group: "GroupContentType";
|
|
14
|
+
readonly slices: "SliceContentType";
|
|
15
|
+
readonly Links: {
|
|
16
16
|
readonly DocumentLink: "DocumentLink";
|
|
17
17
|
readonly FileLink: "FileLink";
|
|
18
18
|
readonly ExternalLink: "ExternalLink";
|
|
19
19
|
readonly ImageLink: "ImageLink";
|
|
20
20
|
readonly LinkContent: "LinkContent";
|
|
21
21
|
};
|
|
22
|
-
StructuredText: "StructuredTextContent";
|
|
23
|
-
Boolean: "BooleanContent";
|
|
24
|
-
Embed: "EmbedContent";
|
|
25
|
-
Field: "FieldContent";
|
|
26
|
-
GeoPoint: "GeoPointContent";
|
|
27
|
-
Image: "ImageContent";
|
|
28
|
-
IntegrationFields: "IntegrationFieldsContent";
|
|
29
|
-
Separator: "SeparatorContent";
|
|
22
|
+
readonly StructuredText: "StructuredTextContent";
|
|
23
|
+
readonly Boolean: "BooleanContent";
|
|
24
|
+
readonly Embed: "EmbedContent";
|
|
25
|
+
readonly Field: "FieldContent";
|
|
26
|
+
readonly GeoPoint: "GeoPointContent";
|
|
27
|
+
readonly Image: "ImageContent";
|
|
28
|
+
readonly IntegrationFields: "IntegrationFieldsContent";
|
|
29
|
+
readonly Separator: "SeparatorContent";
|
|
30
30
|
};
|
|
31
31
|
export declare type WidgetKey = string;
|
|
32
32
|
export declare type WidgetContent = SlicesContent | StaticWidgetContent;
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import * as t from "io-ts";
|
|
2
2
|
export declare const EmbedContentType = "EmbedContent";
|
|
3
|
-
declare type EmbedContent = t.
|
|
3
|
+
export declare type EmbedContent = t.TypeOf<typeof EmbedContentC> & {
|
|
4
4
|
all: unknown;
|
|
5
5
|
};
|
|
6
|
-
declare
|
|
6
|
+
export declare type EmbedContentO = t.OutputOf<typeof EmbedContentC> & {
|
|
7
|
+
all: unknown;
|
|
8
|
+
};
|
|
9
|
+
export declare const EmbedContent: t.Type<EmbedContentO, unknown, unknown>;
|
|
7
10
|
declare const EmbedContentC: t.Type<{
|
|
8
11
|
embed_url: string;
|
|
9
12
|
type: string;
|
|
@@ -37,4 +40,4 @@ declare const EmbedContentC: t.Type<{
|
|
|
37
40
|
} & {
|
|
38
41
|
__TYPE__: "EmbedContent";
|
|
39
42
|
}, unknown>;
|
|
40
|
-
export
|
|
43
|
+
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.EmbedContentType = void 0;
|
|
3
|
+
exports.EmbedContent = exports.EmbedContentType = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const fp_ts_1 = require("fp-ts");
|
|
6
6
|
const function_1 = require("fp-ts/function");
|
|
@@ -8,7 +8,7 @@ const t = (0, tslib_1.__importStar)(require("io-ts"));
|
|
|
8
8
|
const validators_1 = require("../../../validators");
|
|
9
9
|
const function_2 = require("../../../validators/function");
|
|
10
10
|
exports.EmbedContentType = "EmbedContent";
|
|
11
|
-
|
|
11
|
+
exports.EmbedContent = new t.Type("EmbedContent", (u) => u.__TYPE__ === exports.EmbedContentType, (u) => {
|
|
12
12
|
return (0, function_1.pipe)(EmbedContentC.decode(u), fp_ts_1.either.map((s) => ({
|
|
13
13
|
...EmbedContentC.encode(s),
|
|
14
14
|
all: u,
|
|
@@ -33,4 +33,3 @@ const EmbedContentC = (0, function_2.addType)(t.exact(t.intersection([
|
|
|
33
33
|
html: validators_1.StringOrNull,
|
|
34
34
|
}),
|
|
35
35
|
])), exports.EmbedContentType);
|
|
36
|
-
exports.default = EmbedContent;
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import * as O from "fp-ts/Option";
|
|
2
|
+
export declare type FieldType = "Text" | "Date" | "Timestamp" | "Color" | "Number" | "Range" | "Select";
|
|
2
3
|
export declare const FieldContentType = "FieldContent";
|
|
3
4
|
declare type FieldContent = {
|
|
4
5
|
value: string;
|
|
5
|
-
type:
|
|
6
|
+
type: FieldType;
|
|
6
7
|
__TYPE__: typeof FieldContentType;
|
|
7
8
|
};
|
|
8
9
|
declare const FieldContent: {
|
|
9
10
|
types: string[];
|
|
10
|
-
forType: (type:
|
|
11
|
+
forType: (type: FieldType, value: unknown) => O.Option<FieldContent>;
|
|
11
12
|
};
|
|
12
13
|
export default FieldContent;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import * as t from "io-ts";
|
|
2
|
-
import EmbedContent from "../EmbedContent";
|
|
3
2
|
export declare const Meta: t.ExactC<t.IntersectionC<[t.PartialC<{
|
|
4
3
|
data: t.UnknownC;
|
|
5
4
|
}>, t.TypeC<{
|
|
@@ -119,7 +118,7 @@ export declare function checkImageBlock(block: Block): block is ImageBlock;
|
|
|
119
118
|
export declare const EmbedBlockType = "embed";
|
|
120
119
|
export declare const EmbedBlock: t.ExactC<t.IntersectionC<[t.TypeC<{
|
|
121
120
|
type: t.LiteralC<"embed">;
|
|
122
|
-
data: t.Type<EmbedContent, unknown, unknown>;
|
|
121
|
+
data: t.Type<import("../EmbedContent").EmbedContentO, unknown, unknown>;
|
|
123
122
|
}>, t.PartialC<{
|
|
124
123
|
label: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
|
|
125
124
|
direction: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
|
|
@@ -244,7 +243,7 @@ export declare const Block: t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
|
|
|
244
243
|
direction: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
|
|
245
244
|
}>]>>, t.ExactC<t.IntersectionC<[t.TypeC<{
|
|
246
245
|
type: t.LiteralC<"embed">;
|
|
247
|
-
data: t.Type<EmbedContent, unknown, unknown>;
|
|
246
|
+
data: t.Type<import("../EmbedContent").EmbedContentO, unknown, unknown>;
|
|
248
247
|
}>, t.PartialC<{
|
|
249
248
|
label: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
|
|
250
249
|
direction: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
|
|
@@ -6,7 +6,7 @@ const E = (0, tslib_1.__importStar)(require("fp-ts/lib/Either"));
|
|
|
6
6
|
const t = (0, tslib_1.__importStar)(require("io-ts"));
|
|
7
7
|
const validators_1 = require("../../../../validators");
|
|
8
8
|
const function_1 = require("../../../../validators/function");
|
|
9
|
-
const EmbedContent_1 =
|
|
9
|
+
const EmbedContent_1 = require("../EmbedContent");
|
|
10
10
|
const ImageContent_1 = require("../ImageContent");
|
|
11
11
|
const Link_1 = require("../Link");
|
|
12
12
|
exports.Meta = t.exact(t.intersection([
|
|
@@ -66,7 +66,7 @@ exports.EmbedBlockType = "embed";
|
|
|
66
66
|
exports.EmbedBlock = t.exact(t.intersection([
|
|
67
67
|
t.type({
|
|
68
68
|
type: t.literal(exports.EmbedBlockType),
|
|
69
|
-
data: EmbedContent_1.
|
|
69
|
+
data: EmbedContent_1.EmbedContent,
|
|
70
70
|
}),
|
|
71
71
|
t.partial({
|
|
72
72
|
label: validators_1.StringOrNull,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { default as BooleanContent } from "./BooleanContent";
|
|
2
|
-
export
|
|
2
|
+
export * from "./EmbedContent";
|
|
3
3
|
export { default as FieldContent } from "./FieldContent";
|
|
4
4
|
export { type GeoPointContentO, GeoPointContent } from "./GeoPointContent";
|
|
5
5
|
export { type ImageContentO, ImageContent, ImageContentView, } from "./ImageContent";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.NestableTypes = exports.Links = exports.IntegrationFieldsContent = exports.ImageContentView = exports.ImageContent = exports.GeoPointContent = exports.FieldContent = exports.
|
|
3
|
+
exports.NestableTypes = exports.Links = exports.IntegrationFieldsContent = exports.ImageContentView = exports.ImageContent = exports.GeoPointContent = exports.FieldContent = exports.BooleanContent = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const BooleanContent_1 = require("./BooleanContent");
|
|
6
6
|
const EmbedContent_1 = require("./EmbedContent");
|
|
@@ -13,8 +13,7 @@ const SeparatorContent_1 = require("./SeparatorContent");
|
|
|
13
13
|
const StructuredTextContent_1 = require("./StructuredTextContent");
|
|
14
14
|
var BooleanContent_2 = require("./BooleanContent");
|
|
15
15
|
Object.defineProperty(exports, "BooleanContent", { enumerable: true, get: function () { return (0, tslib_1.__importDefault)(BooleanContent_2).default; } });
|
|
16
|
-
|
|
17
|
-
Object.defineProperty(exports, "EmbedContent", { enumerable: true, get: function () { return (0, tslib_1.__importDefault)(EmbedContent_2).default; } });
|
|
16
|
+
(0, tslib_1.__exportStar)(require("./EmbedContent"), exports);
|
|
18
17
|
var FieldContent_2 = require("./FieldContent");
|
|
19
18
|
Object.defineProperty(exports, "FieldContent", { enumerable: true, get: function () { return (0, tslib_1.__importDefault)(FieldContent_2).default; } });
|
|
20
19
|
var GeoPointContent_2 = require("./GeoPointContent");
|
package/package.json
CHANGED
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
Sections,
|
|
11
11
|
StaticSection,
|
|
12
12
|
} from "./Section"
|
|
13
|
-
import type SharedSlice from "./widgets/slices/SharedSlice"
|
|
13
|
+
import type { SharedSlice } from "./widgets/slices/SharedSlice"
|
|
14
14
|
import type { DynamicSlice } from "./widgets/slices/Slice"
|
|
15
15
|
import type { DynamicSlices } from "./widgets/slices/Slices"
|
|
16
16
|
import SlicesTypes from "./widgets/slices/SlicesTypes"
|
|
@@ -58,10 +58,10 @@ export type StaticCustomType = t.TypeOf<typeof StaticCustomType>
|
|
|
58
58
|
export const CustomType = customTypeReader(Format.Dynamic)
|
|
59
59
|
export type CustomType = t.TypeOf<typeof CustomType>
|
|
60
60
|
|
|
61
|
-
function
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
).reduce(
|
|
61
|
+
export function flattenWidgets(
|
|
62
|
+
customType: CustomType,
|
|
63
|
+
): Array<[string, DynamicWidget]> {
|
|
64
|
+
return Object.entries(customType.json).reduce(
|
|
65
65
|
(
|
|
66
66
|
acc: Array<[string, DynamicWidget]>,
|
|
67
67
|
[, section]: [string, DynamicSection],
|
|
@@ -72,8 +72,9 @@ function _retrieveSharedSlicesRef(customType: CustomType): Array<string> {
|
|
|
72
72
|
},
|
|
73
73
|
[],
|
|
74
74
|
)
|
|
75
|
-
|
|
76
|
-
|
|
75
|
+
}
|
|
76
|
+
function _retrieveSharedSlicesRef(customType: CustomType): Array<string> {
|
|
77
|
+
const slicezones = flattenWidgets(customType).filter(
|
|
77
78
|
([, widget]: [string, DynamicWidget]) => widget.type === WidgetTypes.Slices,
|
|
78
79
|
) as Array<[string, DynamicSlices]>
|
|
79
80
|
|
|
@@ -3,7 +3,7 @@ import * as t from "io-ts"
|
|
|
3
3
|
import { Format } from "../Format"
|
|
4
4
|
import Group from "./Group"
|
|
5
5
|
import NestableWidget from "./nestable/NestableWidget"
|
|
6
|
-
import type SharedSlice from "./slices/SharedSlice"
|
|
6
|
+
import type { SharedSlice } from "./slices/SharedSlice"
|
|
7
7
|
import { Slices, slicesReader } from "./slices/Slices"
|
|
8
8
|
import UID from "./UID"
|
|
9
9
|
import WidgetTypes from "./WidgetTypes"
|
|
@@ -10,7 +10,7 @@ import IntegrationField from "./IntegrationField"
|
|
|
10
10
|
import Link from "./Link"
|
|
11
11
|
import Number from "./Number"
|
|
12
12
|
import Range from "./Range"
|
|
13
|
-
import RichText from "./RichText"
|
|
13
|
+
import { RichText } from "./RichText"
|
|
14
14
|
import Select from "./Select"
|
|
15
15
|
import Separator from "./Separator"
|
|
16
16
|
import Text from "./Text"
|
|
@@ -5,25 +5,67 @@ import { StringOrNull } from "../../../validators"
|
|
|
5
5
|
import ImageConstraint from "../shared/ImageConstraint"
|
|
6
6
|
import WidgetTypes from "../WidgetTypes"
|
|
7
7
|
|
|
8
|
-
const DEFAULT_OPTION = "paragraph"
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
"
|
|
12
|
-
"
|
|
13
|
-
"
|
|
14
|
-
"
|
|
15
|
-
"
|
|
16
|
-
"
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
"
|
|
21
|
-
"
|
|
22
|
-
"
|
|
23
|
-
"
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
|
|
8
|
+
export const DEFAULT_OPTION = "paragraph"
|
|
9
|
+
|
|
10
|
+
export enum RichTextNodeType {
|
|
11
|
+
heading1 = "heading1",
|
|
12
|
+
heading2 = "heading2",
|
|
13
|
+
heading3 = "heading3",
|
|
14
|
+
heading4 = "heading4",
|
|
15
|
+
heading5 = "heading5",
|
|
16
|
+
heading6 = "heading6",
|
|
17
|
+
paragraph = "paragraph",
|
|
18
|
+
strong = "strong",
|
|
19
|
+
em = "em",
|
|
20
|
+
preformatted = "preformatted",
|
|
21
|
+
hyperlink = "hyperlink",
|
|
22
|
+
image = "image",
|
|
23
|
+
embed = "embed",
|
|
24
|
+
list = "list-item",
|
|
25
|
+
orderedList = "o-list-item",
|
|
26
|
+
rtl = "rtl",
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function parseRichTextNodeType(
|
|
30
|
+
str: string,
|
|
31
|
+
): RichTextNodeType | undefined {
|
|
32
|
+
switch (str) {
|
|
33
|
+
case RichTextNodeType.heading1:
|
|
34
|
+
return RichTextNodeType.heading1
|
|
35
|
+
case RichTextNodeType.heading2:
|
|
36
|
+
return RichTextNodeType.heading2
|
|
37
|
+
case RichTextNodeType.heading3:
|
|
38
|
+
return RichTextNodeType.heading3
|
|
39
|
+
case RichTextNodeType.heading4:
|
|
40
|
+
return RichTextNodeType.heading4
|
|
41
|
+
case RichTextNodeType.heading5:
|
|
42
|
+
return RichTextNodeType.heading5
|
|
43
|
+
case RichTextNodeType.heading6:
|
|
44
|
+
return RichTextNodeType.heading6
|
|
45
|
+
case RichTextNodeType.paragraph:
|
|
46
|
+
return RichTextNodeType.paragraph
|
|
47
|
+
case RichTextNodeType.strong:
|
|
48
|
+
return RichTextNodeType.strong
|
|
49
|
+
case RichTextNodeType.em:
|
|
50
|
+
return RichTextNodeType.em
|
|
51
|
+
case RichTextNodeType.preformatted:
|
|
52
|
+
return RichTextNodeType.preformatted
|
|
53
|
+
case RichTextNodeType.hyperlink:
|
|
54
|
+
return RichTextNodeType.hyperlink
|
|
55
|
+
case RichTextNodeType.image:
|
|
56
|
+
return RichTextNodeType.image
|
|
57
|
+
case RichTextNodeType.embed:
|
|
58
|
+
return RichTextNodeType.embed
|
|
59
|
+
case RichTextNodeType.list:
|
|
60
|
+
return RichTextNodeType.list
|
|
61
|
+
case RichTextNodeType.orderedList:
|
|
62
|
+
return RichTextNodeType.orderedList
|
|
63
|
+
case RichTextNodeType.rtl:
|
|
64
|
+
return RichTextNodeType.rtl
|
|
65
|
+
default:
|
|
66
|
+
return
|
|
67
|
+
}
|
|
68
|
+
}
|
|
27
69
|
|
|
28
70
|
const RichTextOptions = new t.Type<string, string, unknown>(
|
|
29
71
|
"RichTextOptions",
|
|
@@ -34,7 +76,7 @@ const RichTextOptions = new t.Type<string, string, unknown>(
|
|
|
34
76
|
(s: string | null) => {
|
|
35
77
|
if (!s) return t.success(DEFAULT_OPTION)
|
|
36
78
|
const entries = s.split(",").map((e: string) => e.trim())
|
|
37
|
-
const filtered = entries.filter((entry) =>
|
|
79
|
+
const filtered = entries.filter((entry) => parseRichTextNodeType(entry))
|
|
38
80
|
if (!filtered.length) return t.success(DEFAULT_OPTION)
|
|
39
81
|
|
|
40
82
|
return t.success(filtered.join(","))
|
|
@@ -174,7 +216,7 @@ const RichTextConfig = t.exact(
|
|
|
174
216
|
)
|
|
175
217
|
type RichTextConfig = t.TypeOf<typeof RichTextConfig>
|
|
176
218
|
|
|
177
|
-
const RichText = t.exact(
|
|
219
|
+
export const RichText = t.exact(
|
|
178
220
|
t.intersection([
|
|
179
221
|
t.type({
|
|
180
222
|
type: t.literal(WidgetTypes.RichText),
|
|
@@ -185,6 +227,4 @@ const RichText = t.exact(
|
|
|
185
227
|
}),
|
|
186
228
|
]),
|
|
187
229
|
)
|
|
188
|
-
type RichText = t.TypeOf<typeof RichText>
|
|
189
|
-
|
|
190
|
-
export default RichText
|
|
230
|
+
export type RichText = t.TypeOf<typeof RichText>
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export { default as BooleanField } from "./BooleanField"
|
|
2
2
|
export { default as Color } from "./Color"
|
|
3
3
|
export { default as Date } from "./Date"
|
|
4
|
+
export { default as Embed } from "./Embed"
|
|
4
5
|
export { default as GeoPoint } from "./GeoPoint"
|
|
5
6
|
export { default as Image } from "./Image"
|
|
6
7
|
export { default as IntegrationField } from "./IntegrationField"
|
|
@@ -8,7 +9,7 @@ export { default as Link } from "./Link"
|
|
|
8
9
|
export { default as NestableWidget } from "./NestableWidget"
|
|
9
10
|
export { default as Number } from "./Number"
|
|
10
11
|
export { default as Range } from "./Range"
|
|
11
|
-
export
|
|
12
|
+
export * from "./RichText"
|
|
12
13
|
export { default as Select } from "./Select"
|
|
13
14
|
export { default as Separator } from "./Separator"
|
|
14
15
|
export { default as Text } from "./Text"
|
|
@@ -7,7 +7,7 @@ import SlicesTypes from "./SlicesTypes"
|
|
|
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"
|
|
9
9
|
|
|
10
|
-
const Variation = t.exact(
|
|
10
|
+
export const Variation = t.exact(
|
|
11
11
|
t.intersection([
|
|
12
12
|
t.type({
|
|
13
13
|
id: t.string,
|
|
@@ -25,9 +25,9 @@ const Variation = t.exact(
|
|
|
25
25
|
]),
|
|
26
26
|
)
|
|
27
27
|
|
|
28
|
-
type Variation = t.TypeOf<typeof Variation>
|
|
28
|
+
export type Variation = t.TypeOf<typeof Variation>
|
|
29
29
|
|
|
30
|
-
const SharedSlice = t.exact(
|
|
30
|
+
export const SharedSlice = t.exact(
|
|
31
31
|
t.intersection([
|
|
32
32
|
t.type({
|
|
33
33
|
id: t.string,
|
|
@@ -41,6 +41,4 @@ const SharedSlice = t.exact(
|
|
|
41
41
|
]),
|
|
42
42
|
)
|
|
43
43
|
|
|
44
|
-
type SharedSlice = t.TypeOf<typeof SharedSlice>
|
|
45
|
-
|
|
46
|
-
export default SharedSlice
|
|
44
|
+
export type SharedSlice = t.TypeOf<typeof SharedSlice>
|