@prismicio/types-internal 2.2.0-alpha.9 → 2.2.0-traverse.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/_internal/utils.d.ts +17 -0
- package/lib/_internal/utils.js +9 -0
- package/lib/common/Asset.d.ts +3 -4
- package/lib/common/Embed.d.ts +1 -2
- package/lib/common/UUID.d.ts +7 -0
- package/lib/common/UUID.js +8 -0
- package/lib/common/index.d.ts +1 -0
- package/lib/common/index.js +1 -0
- package/lib/content/Document.d.ts +22 -3
- package/lib/content/Document.js +71 -1
- package/lib/content/fields/GroupContent.d.ts +12 -0
- package/lib/content/fields/GroupContent.js +46 -1
- package/lib/content/fields/WidgetContent.d.ts +6 -6
- package/lib/content/fields/nestable/NestableContent.d.ts +2 -0
- package/lib/content/fields/nestable/NestableContent.js +29 -1
- package/lib/content/fields/slices/Slice/CompositeSliceContent.d.ts +8 -0
- package/lib/content/fields/slices/Slice/CompositeSliceContent.js +38 -1
- package/lib/content/fields/slices/Slice/RepeatableContent.js +0 -1
- package/lib/content/fields/slices/Slice/SharedSliceContent.d.ts +8 -0
- package/lib/content/fields/slices/Slice/SharedSliceContent.js +40 -1
- package/lib/content/fields/slices/SlicesContent.d.ts +7 -0
- package/lib/content/fields/slices/SlicesContent.js +68 -1
- package/lib/customtypes/CustomType.d.ts +1 -0
- package/lib/customtypes/CustomType.js +8 -1
- package/lib/customtypes/widgets/slices/CompositeSlice.d.ts +2 -0
- package/lib/customtypes/widgets/slices/CompositeSlice.js +5 -1
- package/lib/customtypes/widgets/slices/LegacySlice.d.ts +2 -0
- package/lib/customtypes/widgets/slices/LegacySlice.js +5 -1
- package/lib/customtypes/widgets/slices/SharedSlice.d.ts +4 -0
- package/lib/customtypes/widgets/slices/SharedSlice.js +9 -1
- package/lib/import/converters/Document.d.ts +2 -2
- package/lib/import/converters/Document.js +6 -6
- package/lib/import/converters/fields/Slices/SharedSlice.d.ts +4 -0
- package/lib/import/converters/fields/Slices/SharedSlice.js +19 -0
- package/lib/import/converters/fields/Slices/SharedSliceContent.d.ts +10 -0
- package/lib/import/converters/fields/Slices/SharedSliceContent.js +58 -0
- package/lib/import/converters/fields/Slices/Slices.d.ts +4 -0
- package/lib/import/converters/fields/Slices/Slices.js +16 -0
- package/lib/import/converters/fields/Slices/index.d.ts +1 -0
- package/lib/import/converters/fields/Slices/index.js +4 -0
- package/lib/import/converters/fields/UID.d.ts +1 -1
- package/lib/import/converters/fields/UID.js +0 -2
- package/lib/import/converters/fields/index.d.ts +1 -0
- package/lib/import/converters/fields/index.js +1 -0
- package/lib/import/converters/fields/nestable/Embed.d.ts +2 -1
- package/lib/import/converters/fields/nestable/Embed.js +24 -5
- package/lib/import/converters/fields/nestable/Image.d.ts +2 -2
- package/lib/import/converters/fields/nestable/Image.js +1 -1
- package/lib/import/converters/fields/nestable/Link.d.ts +1 -1
- package/lib/import/converters/fields/nestable/Link.js +6 -6
- package/lib/import/converters/fields/nestable/Nestable.d.ts +4 -3
- package/lib/import/converters/fields/nestable/Nestable.js +2 -2
- package/lib/import/validators/Document.js +2 -2
- package/lib/import/validators/fields/ImportField.d.ts +17 -68
- package/lib/import/validators/fields/ImportField.js +8 -4
- package/lib/import/validators/fields/ImportSlices/ImportSlices.d.ts +8 -0
- package/lib/import/validators/fields/ImportSlices/ImportSlices.js +29 -0
- package/lib/import/validators/fields/ImportSlices/SharedSlice/SharedSlice.d.ts +14 -0
- package/lib/import/validators/fields/ImportSlices/SharedSlice/SharedSlice.js +61 -0
- package/lib/import/validators/fields/ImportSlices/SharedSlice/errors.d.ts +4 -0
- package/lib/import/validators/fields/ImportSlices/SharedSlice/errors.js +7 -0
- package/lib/import/validators/fields/ImportSlices/SharedSlice/fields/OptionalSharedSliceId.d.ts +2 -0
- package/lib/import/validators/fields/ImportSlices/SharedSlice/fields/OptionalSharedSliceId.js +15 -0
- package/lib/import/validators/fields/ImportSlices/SharedSlice/fields/SharedSliceContent/SharedSliceContent.d.ts +17 -0
- package/lib/import/validators/fields/ImportSlices/SharedSlice/fields/SharedSliceContent/SharedSliceContent.js +30 -0
- package/lib/import/validators/fields/ImportSlices/SharedSlice/fields/SharedSliceContent/SharedSliceContentEntry.d.ts +43 -0
- package/lib/import/validators/fields/ImportSlices/SharedSlice/fields/SharedSliceContent/SharedSliceContentEntry.js +69 -0
- package/lib/import/validators/fields/ImportSlices/SharedSlice/fields/SharedSliceContent/errors.d.ts +4 -0
- package/lib/import/validators/fields/ImportSlices/SharedSlice/fields/SharedSliceContent/errors.js +6 -0
- package/lib/import/validators/fields/ImportSlices/SharedSlice/fields/SharedSliceContent/index.d.ts +2 -0
- package/lib/import/validators/fields/ImportSlices/SharedSlice/fields/SharedSliceContent/index.js +5 -0
- package/lib/import/validators/fields/ImportSlices/SharedSlice/fields/SharedSliceContent/types.d.ts +1 -0
- package/lib/import/validators/fields/ImportSlices/SharedSlice/fields/SharedSliceContent/types.js +2 -0
- package/lib/import/validators/fields/ImportSlices/SharedSlice/fields/SharedSliceId.d.ts +9 -0
- package/lib/import/validators/fields/ImportSlices/SharedSlice/fields/SharedSliceId.js +39 -0
- package/lib/import/validators/fields/ImportSlices/SharedSlice/fields/SharedSliceType.d.ts +11 -0
- package/lib/import/validators/fields/ImportSlices/SharedSlice/fields/SharedSliceType.js +24 -0
- package/lib/import/validators/fields/ImportSlices/SharedSlice/fields/SharedSliceVariation.d.ts +11 -0
- package/lib/import/validators/fields/ImportSlices/SharedSlice/fields/SharedSliceVariation.js +24 -0
- package/lib/import/validators/fields/ImportSlices/SharedSlice/fields/index.d.ts +5 -0
- package/lib/import/validators/fields/ImportSlices/SharedSlice/fields/index.js +8 -0
- package/lib/import/validators/fields/ImportSlices/SharedSlice/index.d.ts +3 -0
- package/lib/import/validators/fields/ImportSlices/SharedSlice/index.js +6 -0
- package/lib/import/validators/fields/ImportSlices/SharedSlice/utils.d.ts +339 -0
- package/lib/import/validators/fields/ImportSlices/SharedSlice/utils.js +11 -0
- package/lib/import/validators/fields/ImportSlices/index.d.ts +1 -0
- package/lib/import/validators/fields/ImportSlices/index.js +4 -0
- package/lib/import/validators/fields/ImportSlices/utils.d.ts +4 -0
- package/lib/import/validators/fields/ImportSlices/utils.js +35 -0
- package/lib/import/validators/fields/UID.d.ts +2 -2
- package/lib/import/validators/fields/UID.js +1 -1
- package/lib/import/validators/fields/nestable/Embed.d.ts +6 -23
- package/lib/import/validators/fields/nestable/Embed.js +7 -25
- package/lib/import/validators/fields/nestable/GeoPoint.js +1 -1
- package/lib/import/validators/fields/nestable/Image/Decoder.d.ts +26 -0
- package/lib/import/validators/fields/nestable/Image/Decoder.js +40 -0
- package/lib/import/validators/fields/nestable/Image/Validator.d.ts +33 -0
- package/lib/import/validators/fields/nestable/Image/Validator.js +27 -0
- package/lib/import/validators/fields/nestable/Image/index.d.ts +26 -0
- package/lib/import/validators/fields/nestable/Image/index.js +41 -0
- package/lib/import/validators/fields/nestable/Image/model.d.ts +18 -0
- package/lib/import/validators/fields/nestable/Image/model.js +2 -0
- package/lib/import/validators/fields/nestable/Link.js +2 -2
- package/lib/import/validators/fields/nestable/Nestable.d.ts +9 -60
- package/lib/import/validators/fields/nestable/index.d.ts +1 -0
- package/lib/import/validators/fields/nestable/index.js +1 -0
- package/lib/utils/DocumentId.d.ts +2 -1
- package/lib/utils/DocumentId.js +3 -3
- package/lib/utils/io-ts.d.ts +2 -0
- package/lib/utils/io-ts.js +22 -0
- package/lib/validators/BasicTypes.d.ts +0 -1
- package/lib/validators/BasicTypes.js +7 -8
- package/lib/validators/DefaultOrElse.js +1 -1
- package/lib/validators/NonEmptyString.js +1 -1
- package/lib/validators/function.d.ts +4 -4
- package/lib/validators/function.js +6 -6
- package/package.json +4 -2
- package/src/_internal/utils.ts +39 -0
- package/src/common/Asset.ts +4 -5
- package/src/common/Embed.ts +22 -0
- package/src/common/UUID.ts +19 -0
- package/src/common/index.ts +1 -0
- package/src/content/Document.ts +96 -1
- package/src/content/fields/GroupContent.ts +68 -0
- package/src/content/fields/nestable/NestableContent.ts +32 -0
- package/src/content/fields/slices/Slice/CompositeSliceContent.ts +55 -0
- package/src/content/fields/slices/Slice/RepeatableContent.ts +0 -1
- package/src/content/fields/slices/Slice/SharedSliceContent.ts +60 -0
- package/src/content/fields/slices/SlicesContent.ts +94 -0
- package/src/customtypes/CustomType.ts +17 -0
- package/src/customtypes/widgets/slices/CompositeSlice.ts +7 -0
- package/src/customtypes/widgets/slices/LegacySlice.ts +7 -0
- package/src/customtypes/widgets/slices/SharedSlice.ts +12 -0
- package/src/import/converters/Document.ts +10 -8
- package/src/import/converters/fields/Slices/SharedSlice.ts +24 -0
- package/src/import/converters/fields/Slices/SharedSliceContent.ts +94 -0
- package/src/import/converters/fields/Slices/Slices.ts +20 -0
- package/src/import/converters/fields/Slices/index.ts +1 -0
- package/src/import/converters/fields/UID.ts +1 -5
- package/src/import/converters/fields/index.ts +1 -0
- package/src/import/converters/fields/nestable/Embed.ts +29 -7
- package/src/import/converters/fields/nestable/Image.ts +4 -4
- package/src/import/converters/fields/nestable/Link.ts +5 -5
- package/src/import/converters/fields/nestable/Nestable.ts +7 -5
- package/src/import/validators/Document.ts +3 -3
- package/src/import/validators/fields/ImportField.ts +12 -6
- package/src/import/validators/fields/ImportSlices/ImportSlices.ts +54 -0
- package/src/import/validators/fields/ImportSlices/SharedSlice/SharedSlice.ts +116 -0
- package/src/import/validators/fields/ImportSlices/SharedSlice/errors.ts +6 -0
- package/src/import/validators/fields/ImportSlices/SharedSlice/fields/OptionalSharedSliceId.ts +20 -0
- package/src/import/validators/fields/ImportSlices/SharedSlice/fields/SharedSliceContent/SharedSliceContent.ts +64 -0
- package/src/import/validators/fields/ImportSlices/SharedSlice/fields/SharedSliceContent/SharedSliceContentEntry.ts +100 -0
- package/src/import/validators/fields/ImportSlices/SharedSlice/fields/SharedSliceContent/errors.ts +10 -0
- package/src/import/validators/fields/ImportSlices/SharedSlice/fields/SharedSliceContent/index.ts +2 -0
- package/src/import/validators/fields/ImportSlices/SharedSlice/fields/SharedSliceContent/types.ts +1 -0
- package/src/import/validators/fields/ImportSlices/SharedSlice/fields/SharedSliceId.ts +65 -0
- package/src/import/validators/fields/ImportSlices/SharedSlice/fields/SharedSliceType.ts +45 -0
- package/src/import/validators/fields/ImportSlices/SharedSlice/fields/SharedSliceVariation.ts +45 -0
- package/src/import/validators/fields/ImportSlices/SharedSlice/fields/index.ts +5 -0
- package/src/import/validators/fields/ImportSlices/SharedSlice/index.ts +3 -0
- package/src/import/validators/fields/ImportSlices/SharedSlice/utils.ts +21 -0
- package/src/import/validators/fields/ImportSlices/index.ts +1 -0
- package/src/import/validators/fields/ImportSlices/utils.ts +43 -0
- package/src/import/validators/fields/UID.ts +2 -2
- package/src/import/validators/fields/nestable/Embed.ts +9 -41
- package/src/import/validators/fields/nestable/GeoPoint.ts +2 -2
- package/src/import/validators/fields/nestable/Image/Decoder.ts +61 -0
- package/src/import/validators/fields/nestable/Image/Validator.ts +38 -0
- package/src/import/validators/fields/nestable/Image/index.ts +75 -0
- package/src/import/validators/fields/nestable/Image/model.ts +18 -0
- package/src/import/validators/fields/nestable/Link.ts +2 -2
- package/src/import/validators/fields/nestable/index.ts +1 -0
- package/src/utils/DocumentId.ts +4 -5
- package/src/utils/io-ts.ts +29 -0
- package/src/validators/BasicTypes.ts +13 -11
- package/src/validators/DefaultOrElse.ts +1 -1
- package/src/validators/NonEmptyString.ts +4 -5
- package/src/validators/function.ts +4 -4
- package/lib/import/validators/fields/nestable/Image.d.ts +0 -62
- package/lib/import/validators/fields/nestable/Image.js +0 -76
- package/src/import/validators/fields/nestable/Image.ts +0 -147
|
@@ -2390,6 +2390,7 @@ export declare const CustomType: t.ExactC<t.IntersectionC<[t.TypeC<{
|
|
|
2390
2390
|
}>]>>;
|
|
2391
2391
|
export declare type CustomType = t.TypeOf<typeof CustomType>;
|
|
2392
2392
|
export declare function flattenWidgets(customType: CustomType): Array<[string, DynamicWidget]>;
|
|
2393
|
+
export declare function flattenStaticWidgets(customType: StaticCustomType): Array<[string, StaticWidget]>;
|
|
2393
2394
|
export declare function toStatic(customType: CustomType, sharedSlices: Map<string, SharedSlice>): StaticCustomType;
|
|
2394
2395
|
export declare function validateSlices(customType: CustomType, sharedSlices: Map<string, SharedSlice>): Either<CustomTypeSlicesError, CustomType>;
|
|
2395
2396
|
export declare function collectWidgets(customType: CustomType, f: (ref: string, widget: DynamicWidget) => DynamicWidget | undefined): CustomType;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.flattenCustomTypeFields = exports.filterMissingSharedSlices = exports.collectWidgets = exports.validateSlices = exports.toStatic = exports.flattenWidgets = exports.CustomType = exports.StaticCustomType = exports.CustomTypeFormat = void 0;
|
|
3
|
+
exports.flattenCustomTypeFields = exports.filterMissingSharedSlices = exports.collectWidgets = exports.validateSlices = exports.toStatic = exports.flattenStaticWidgets = exports.flattenWidgets = exports.CustomType = exports.StaticCustomType = exports.CustomTypeFormat = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const Either_1 = require("fp-ts/lib/Either");
|
|
6
6
|
const t = (0, tslib_1.__importStar)(require("io-ts"));
|
|
@@ -60,6 +60,13 @@ function flattenWidgets(customType) {
|
|
|
60
60
|
}, []);
|
|
61
61
|
}
|
|
62
62
|
exports.flattenWidgets = flattenWidgets;
|
|
63
|
+
function flattenStaticWidgets(customType) {
|
|
64
|
+
return Object.entries(customType.json).reduce((acc, [, section]) => {
|
|
65
|
+
const sectionWidgets = Object.entries(section);
|
|
66
|
+
return acc.concat(sectionWidgets);
|
|
67
|
+
}, []);
|
|
68
|
+
}
|
|
69
|
+
exports.flattenStaticWidgets = flattenStaticWidgets;
|
|
63
70
|
function _retrieveSharedSlicesRef(customType) {
|
|
64
71
|
const slicezones = flattenWidgets(customType).filter(([, widget]) => widget.type === "Slices");
|
|
65
72
|
const allSharedRefs = slicezones.reduce((acc, [, slicezone]) => {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as t from "io-ts";
|
|
2
|
+
import type { DynamicSlice, StaticSlice } from "./Slice";
|
|
2
3
|
export declare const CompositeSliceType = "Slice";
|
|
3
4
|
export declare const CompositeSliceConfig: t.ExactC<t.PartialC<{
|
|
4
5
|
label: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
|
|
@@ -330,3 +331,4 @@ export declare const CompositeSlice: t.ExactC<t.IntersectionC<[t.TypeC<{
|
|
|
330
331
|
}>>;
|
|
331
332
|
}>]>>;
|
|
332
333
|
export declare type CompositeSlice = t.TypeOf<typeof CompositeSlice>;
|
|
334
|
+
export declare function isCompositeSlice(slice: DynamicSlice | StaticSlice): slice is CompositeSlice;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CompositeSlice = exports.CompositeSliceConfig = exports.CompositeSliceType = void 0;
|
|
3
|
+
exports.isCompositeSlice = exports.CompositeSlice = exports.CompositeSliceConfig = exports.CompositeSliceType = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const t = (0, tslib_1.__importStar)(require("io-ts"));
|
|
6
6
|
const common_1 = require("../../../common");
|
|
@@ -24,3 +24,7 @@ exports.CompositeSlice = t.exact(t.intersection([
|
|
|
24
24
|
config: exports.CompositeSliceConfig,
|
|
25
25
|
}),
|
|
26
26
|
]));
|
|
27
|
+
function isCompositeSlice(slice) {
|
|
28
|
+
return slice.type === "Slice";
|
|
29
|
+
}
|
|
30
|
+
exports.isCompositeSlice = isCompositeSlice;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as t from "io-ts";
|
|
2
|
+
import type { DynamicSlice, StaticSlice } from "./Slice";
|
|
2
3
|
export declare const LegacySlice: t.UnionC<[t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
|
|
3
4
|
type: t.LiteralC<"Color">;
|
|
4
5
|
}>, t.PartialC<{
|
|
@@ -324,3 +325,4 @@ export declare const LegacySlice: t.UnionC<[t.UnionC<[t.ExactC<t.IntersectionC<[
|
|
|
324
325
|
}>>;
|
|
325
326
|
}>]>>]>;
|
|
326
327
|
export declare type LegacySlice = t.TypeOf<typeof LegacySlice>;
|
|
328
|
+
export declare function isLegacySlice(slice: DynamicSlice | StaticSlice): slice is LegacySlice;
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.LegacySlice = void 0;
|
|
3
|
+
exports.isLegacySlice = exports.LegacySlice = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const t = (0, tslib_1.__importStar)(require("io-ts"));
|
|
6
6
|
const Group_1 = require("../Group");
|
|
7
7
|
const NestableWidget_1 = require("../nestable/NestableWidget");
|
|
8
8
|
exports.LegacySlice = t.union([NestableWidget_1.NestableWidget, Group_1.Group]);
|
|
9
|
+
function isLegacySlice(slice) {
|
|
10
|
+
return slice.type !== "Slice" && slice.type !== "SharedSlice";
|
|
11
|
+
}
|
|
12
|
+
exports.isLegacySlice = isLegacySlice;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import * as t from "io-ts";
|
|
2
|
+
import type { SharedSliceRef } from "./SharedSliceRef";
|
|
3
|
+
import type { DynamicSlice, StaticSlice } from "./Slice";
|
|
2
4
|
export declare const Variation: t.ExactC<t.IntersectionC<[t.TypeC<{
|
|
3
5
|
id: t.StringC;
|
|
4
6
|
name: t.StringC;
|
|
@@ -657,3 +659,5 @@ export declare const SharedSlice: t.ExactC<t.IntersectionC<[t.TypeC<{
|
|
|
657
659
|
description: t.StringC;
|
|
658
660
|
}>]>>;
|
|
659
661
|
export declare type SharedSlice = t.TypeOf<typeof SharedSlice>;
|
|
662
|
+
export declare function isStaticSharedSlice(slice: StaticSlice): slice is SharedSlice;
|
|
663
|
+
export declare function isDynamicSharedSlice(slice: DynamicSlice): slice is SharedSliceRef;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SharedSlice = exports.SharedSliceType = exports.Variation = void 0;
|
|
3
|
+
exports.isDynamicSharedSlice = exports.isStaticSharedSlice = exports.SharedSlice = exports.SharedSliceType = exports.Variation = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const t = (0, tslib_1.__importStar)(require("io-ts"));
|
|
6
6
|
const withFallback_1 = require("io-ts-types/lib/withFallback");
|
|
@@ -34,3 +34,11 @@ exports.SharedSlice = t.exact(t.intersection([
|
|
|
34
34
|
description: t.string,
|
|
35
35
|
}),
|
|
36
36
|
]));
|
|
37
|
+
function isStaticSharedSlice(slice) {
|
|
38
|
+
return slice.type === "SharedSlice";
|
|
39
|
+
}
|
|
40
|
+
exports.isStaticSharedSlice = isStaticSharedSlice;
|
|
41
|
+
function isDynamicSharedSlice(slice) {
|
|
42
|
+
return slice.type === "SharedSlice";
|
|
43
|
+
}
|
|
44
|
+
exports.isDynamicSharedSlice = isDynamicSharedSlice;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Asset,
|
|
1
|
+
import type { Asset, Embed } from "../../common";
|
|
2
2
|
import type { Document } from "../../content";
|
|
3
3
|
import type { ImportDocument } from "../validators";
|
|
4
|
-
export declare function convertImportToContent(document: ImportDocument, assets: Record<
|
|
4
|
+
export declare function convertImportToContent(document: ImportDocument, assets: Record<Asset["id"], Asset | undefined>, embeds: Record<string, Embed | undefined>): Document;
|
|
@@ -2,18 +2,18 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.convertImportToContent = void 0;
|
|
4
4
|
const fields_1 = require("./fields");
|
|
5
|
-
function convertImportToContent(document, assets) {
|
|
5
|
+
function convertImportToContent(document, assets, embeds) {
|
|
6
6
|
return Object.entries(document).reduce((acc, [fieldKey, fieldValue]) => {
|
|
7
|
-
const newFieldValue = convertWidget(fieldValue, assets);
|
|
7
|
+
const newFieldValue = convertWidget(fieldValue, assets, embeds);
|
|
8
8
|
return newFieldValue ? { ...acc, [fieldKey]: newFieldValue } : acc;
|
|
9
9
|
}, {});
|
|
10
10
|
}
|
|
11
11
|
exports.convertImportToContent = convertImportToContent;
|
|
12
|
-
function convertWidget(field, assets) {
|
|
12
|
+
function convertWidget(field, assets, embeds) {
|
|
13
13
|
switch (field.type) {
|
|
14
|
-
case "
|
|
15
|
-
return (0, fields_1.
|
|
14
|
+
case "Slices":
|
|
15
|
+
return (0, fields_1.importSlicesConverter)(field.value, assets, embeds);
|
|
16
16
|
default:
|
|
17
|
-
return (0, fields_1.convertNestableWidget)(field, assets);
|
|
17
|
+
return (0, fields_1.convertNestableWidget)(field, assets, embeds);
|
|
18
18
|
}
|
|
19
19
|
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { Asset, Embed } from "../../../../common";
|
|
2
|
+
import type { SliceItemContent } from "../../../../content";
|
|
3
|
+
import type { SharedSlice as ImportSharedSlice } from "../../../validators/fields/ImportSlices/SharedSlice";
|
|
4
|
+
export declare const sharedSliceConverter: (slice: ImportSharedSlice, assets: Record<Asset["id"], Asset | undefined>, embeds: Record<string, Embed | undefined>) => SliceItemContent;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.sharedSliceConverter = void 0;
|
|
4
|
+
const uuid_1 = require("uuid");
|
|
5
|
+
const SharedSliceContent_1 = require("./SharedSliceContent");
|
|
6
|
+
// TODO should we put it together with SharedSliceId validator?
|
|
7
|
+
const buildSharedSliceId = (slice_type) => `${slice_type}$${(0, uuid_1.v4)()}`;
|
|
8
|
+
const sharedSliceConverter = (slice, assets, embeds) => {
|
|
9
|
+
var _a, _b;
|
|
10
|
+
// Right now we only support SharedSlices, if we support more types of slices in the future we'll need to select a correct converter here
|
|
11
|
+
const widget = (0, SharedSliceContent_1.importSharedSliceContentConverter)(slice, assets, embeds);
|
|
12
|
+
return {
|
|
13
|
+
key: (_a = slice.id) !== null && _a !== void 0 ? _a : buildSharedSliceId(slice.slice_type),
|
|
14
|
+
name: slice.slice_type,
|
|
15
|
+
maybeLabel: (_b = slice.slice_label) !== null && _b !== void 0 ? _b : undefined,
|
|
16
|
+
widget,
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
exports.sharedSliceConverter = sharedSliceConverter;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Asset, Embed } from "../../../../common";
|
|
2
|
+
import type { SharedSliceContent } from "../../../../content";
|
|
3
|
+
import type { SharedSlice as ImportSharedSlice } from "../../../validators/fields/ImportSlices/SharedSlice";
|
|
4
|
+
/**
|
|
5
|
+
* Builds SharedSliceContent model from ImportSharedSlice
|
|
6
|
+
* @param field ImportSharedSlice to be converted - a single slice from the slices array in the import document
|
|
7
|
+
* @param assets assets that are required for a conversion of a nestable widget
|
|
8
|
+
* @param embeds embeds that are required for a conversion of a nestable widget
|
|
9
|
+
*/
|
|
10
|
+
export declare const importSharedSliceContentConverter: (field: ImportSharedSlice, assets: Record<Asset["id"], Asset | undefined>, embeds: Record<string, Embed | undefined>) => SharedSliceContent;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.importSharedSliceContentConverter = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const function_1 = require("fp-ts/function");
|
|
6
|
+
const O = (0, tslib_1.__importStar)(require("fp-ts/Option"));
|
|
7
|
+
const R = (0, tslib_1.__importStar)(require("fp-ts/Record"));
|
|
8
|
+
const content_1 = require("../../../../content");
|
|
9
|
+
const nestable_1 = require("../nestable");
|
|
10
|
+
/**
|
|
11
|
+
* Converts the ImportSharedSliceContent which is a record of widget keys and ImportNestable values to a record of widget keys and NestableContent values.
|
|
12
|
+
*
|
|
13
|
+
* @param content a single ImportSharedSliceContent
|
|
14
|
+
* @param assets assets that are required for a conversion of a nestable widget
|
|
15
|
+
* @param embeds embeds that are required for a conversion of a nestable widget
|
|
16
|
+
*/
|
|
17
|
+
const sharedSliceContentConverter = (content, assets, embeds) => (0, function_1.pipe)(content,
|
|
18
|
+
// convertNestableWidget can theoretically return undefined, so we need to filter out those values
|
|
19
|
+
R.filterMap((contentValue) => (0, function_1.pipe)(contentValue, (content) => (0, nestable_1.convertNestableWidget)(content, assets, embeds), O.fromNullable)));
|
|
20
|
+
/**
|
|
21
|
+
* Converts a list of items to a list of repeatable widgets.
|
|
22
|
+
* Each ImportSharedSliceContent element is a record of fields, but in the content model it is represented as a list of tuples (key, value)
|
|
23
|
+
*
|
|
24
|
+
* For example, given the following slice content:
|
|
25
|
+
* {
|
|
26
|
+
* "slice_text": (ImportNestable),
|
|
27
|
+
* "slice_number": (ImportNestable),
|
|
28
|
+
* }
|
|
29
|
+
*
|
|
30
|
+
* has to be converted to:
|
|
31
|
+
*
|
|
32
|
+
* {
|
|
33
|
+
* __TYPE__: "GroupItemContentType",
|
|
34
|
+
* value: [
|
|
35
|
+
* ["slice_text", (NestableContent)],
|
|
36
|
+
* ["slice_number", (NestableContent)],
|
|
37
|
+
* ]
|
|
38
|
+
* }
|
|
39
|
+
*
|
|
40
|
+
* @param items list of items to be converted
|
|
41
|
+
* @param assets assets that are required for a conversion of a nestable widget
|
|
42
|
+
*/
|
|
43
|
+
const itemsConverter = (items, assets, embeds) => items.map((item) => (0, function_1.pipe)(sharedSliceContentConverter(item, assets, embeds), (record) => Object.entries(record), (entries) => ({ __TYPE__: content_1.GroupItemContentType, value: entries })));
|
|
44
|
+
/**
|
|
45
|
+
* Builds SharedSliceContent model from ImportSharedSlice
|
|
46
|
+
* @param field ImportSharedSlice to be converted - a single slice from the slices array in the import document
|
|
47
|
+
* @param assets assets that are required for a conversion of a nestable widget
|
|
48
|
+
* @param embeds embeds that are required for a conversion of a nestable widget
|
|
49
|
+
*/
|
|
50
|
+
const importSharedSliceContentConverter = (field, assets, embeds) => ({
|
|
51
|
+
__TYPE__: content_1.SharedSliceContentType,
|
|
52
|
+
primary: field.primary
|
|
53
|
+
? sharedSliceContentConverter(field.primary, assets, embeds)
|
|
54
|
+
: {},
|
|
55
|
+
items: field.items ? itemsConverter(field.items, assets, embeds) : [],
|
|
56
|
+
variation: field.variation,
|
|
57
|
+
});
|
|
58
|
+
exports.importSharedSliceContentConverter = importSharedSliceContentConverter;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { Asset, Embed } from "../../../../common";
|
|
2
|
+
import type { SlicesContent } from "../../../../content";
|
|
3
|
+
import type { ImportSlices } from "../../../validators/fields/ImportSlices";
|
|
4
|
+
export declare const importSlicesConverter: (field: ImportSlices["value"], assets: Record<Asset["id"], Asset | undefined>, embeds: Record<string, Embed | undefined>) => SlicesContent | undefined;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.importSlicesConverter = void 0;
|
|
4
|
+
const SharedSlice_1 = require("./SharedSlice");
|
|
5
|
+
const importSlicesConverter = (field, assets, embeds) => {
|
|
6
|
+
if (field === null)
|
|
7
|
+
return;
|
|
8
|
+
return {
|
|
9
|
+
value: field.map((slice) => {
|
|
10
|
+
// Right now we only support SharedSlices, if we support more types of slices in the future we'll need to select a correct converter here
|
|
11
|
+
return (0, SharedSlice_1.sharedSliceConverter)(slice, assets, embeds);
|
|
12
|
+
}),
|
|
13
|
+
__TYPE__: "SliceContentType",
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
exports.importSlicesConverter = importSlicesConverter;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./Slices";
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { UIDContent } from "../../../content";
|
|
2
2
|
import type { ImportUID } from "../../validators/fields/UID";
|
|
3
|
-
export declare const uidConverter: (field: ImportUID["value"]) => UIDContent
|
|
3
|
+
export declare const uidConverter: (field: ImportUID["value"]) => UIDContent;
|
|
@@ -2,4 +2,5 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
4
|
(0, tslib_1.__exportStar)(require("./nestable"), exports);
|
|
5
|
+
(0, tslib_1.__exportStar)(require("./Slices"), exports);
|
|
5
6
|
(0, tslib_1.__exportStar)(require("./UID"), exports);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { Embed } from "../../../../common";
|
|
1
2
|
import type { EmbedContent } from "../../../../content";
|
|
2
3
|
import type { ImportEmbed } from "../../../validators";
|
|
3
|
-
export declare const embedConverter: (field: ImportEmbed["value"]) => EmbedContent | undefined;
|
|
4
|
+
export declare const embedConverter: (field: ImportEmbed["value"], embeds: Record<string, Embed | undefined>) => EmbedContent | undefined;
|
|
@@ -1,13 +1,32 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.embedConverter = void 0;
|
|
4
|
-
const
|
|
4
|
+
const common_1 = require("../../../../common");
|
|
5
|
+
const Objects_1 = require("../../../../utils/Objects");
|
|
6
|
+
const embedConverter = (field, embeds) => {
|
|
5
7
|
if (field === null)
|
|
6
8
|
return;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
+
const embed = (0, common_1.getEmbedOrThrow)(embeds)(field.embed_url);
|
|
10
|
+
return (0, Objects_1.withOptionals)({
|
|
11
|
+
embed_url: field.embed_url,
|
|
12
|
+
type: embed.type,
|
|
13
|
+
all: {
|
|
14
|
+
embed_url: field.embed_url,
|
|
15
|
+
...embed,
|
|
16
|
+
},
|
|
9
17
|
__TYPE__: "EmbedContent",
|
|
10
|
-
}
|
|
11
|
-
|
|
18
|
+
}, [
|
|
19
|
+
["version", embed.version],
|
|
20
|
+
["title", embed.title],
|
|
21
|
+
["author_name", embed.author_name],
|
|
22
|
+
["author_url", embed.author_url],
|
|
23
|
+
["provider_name", embed.provider_name],
|
|
24
|
+
["provider_url", embed.provider_url],
|
|
25
|
+
["cache_age", embed.cache_age],
|
|
26
|
+
["thumbnail_url", embed.thumbnail_url],
|
|
27
|
+
["thumbnail_width", embed.thumbnail_width],
|
|
28
|
+
["thumbnail_height", embed.thumbnail_height],
|
|
29
|
+
["html", embed.html],
|
|
30
|
+
]);
|
|
12
31
|
};
|
|
13
32
|
exports.embedConverter = embedConverter;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Asset
|
|
1
|
+
import type { Asset } from "../../../../common";
|
|
2
2
|
import type { ImageContent } from "../../../../content";
|
|
3
3
|
import type { ImportImage } from "../../../validators";
|
|
4
|
-
export declare const imageConverter: (imageField: ImportImage["value"], assets: Record<
|
|
4
|
+
export declare const imageConverter: (imageField: ImportImage["value"], assets: Record<Asset["id"], Asset | undefined>) => ImageContent | undefined;
|
|
@@ -30,7 +30,7 @@ function convertImage(imageField, image) {
|
|
|
30
30
|
url: image.url,
|
|
31
31
|
}, [
|
|
32
32
|
["alt", (imageField === null || imageField === void 0 ? void 0 : imageField.alt) || image.alt],
|
|
33
|
-
["credits", (imageField === null || imageField === void 0 ? void 0 : imageField.
|
|
33
|
+
["credits", (imageField === null || imageField === void 0 ? void 0 : imageField.copyright) || image.credits],
|
|
34
34
|
]);
|
|
35
35
|
}
|
|
36
36
|
function convertThumbnails(imageField, assets) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { Asset } from "../../../../common";
|
|
2
2
|
import type { LinkContent } from "../../../../content";
|
|
3
3
|
import type { ImportLink } from "../../../validators";
|
|
4
|
-
export declare const linkConverter: (field: ImportLink["value"], assets: Record<string, Asset>) => LinkContent | undefined;
|
|
4
|
+
export declare const linkConverter: (field: ImportLink["value"], assets: Record<string, Asset | undefined>) => LinkContent | undefined;
|
|
@@ -18,30 +18,30 @@ const documentLinkConverter = (field) => ({
|
|
|
18
18
|
__TYPE__: "LinkContent",
|
|
19
19
|
});
|
|
20
20
|
const fileLinkConverter = (field, asset) => {
|
|
21
|
-
var _a
|
|
21
|
+
var _a;
|
|
22
22
|
return ({
|
|
23
23
|
value: {
|
|
24
24
|
id: field.id,
|
|
25
|
-
url: asset.
|
|
25
|
+
url: asset.origin_url,
|
|
26
26
|
name: (_a = asset.filename) !== null && _a !== void 0 ? _a : "unknown.jpg",
|
|
27
27
|
kind: asset.kind,
|
|
28
|
-
size:
|
|
28
|
+
size: asset.size ? String(asset.size) : "0",
|
|
29
29
|
__TYPE__: "FileLink",
|
|
30
30
|
},
|
|
31
31
|
__TYPE__: "LinkContent",
|
|
32
32
|
});
|
|
33
33
|
};
|
|
34
34
|
const imageLinkConverter = (field, asset) => {
|
|
35
|
-
var _a, _b, _c
|
|
35
|
+
var _a, _b, _c;
|
|
36
36
|
return ({
|
|
37
37
|
value: {
|
|
38
38
|
id: field.id,
|
|
39
|
-
url: asset.
|
|
39
|
+
url: asset.origin_url,
|
|
40
40
|
height: String((_a = asset.height) !== null && _a !== void 0 ? _a : 1),
|
|
41
41
|
width: String((_b = asset.width) !== null && _b !== void 0 ? _b : 1),
|
|
42
42
|
name: (_c = asset.filename) !== null && _c !== void 0 ? _c : "unknown.jpg",
|
|
43
43
|
kind: asset.kind,
|
|
44
|
-
size:
|
|
44
|
+
size: asset.size ? String(asset.size) : "0",
|
|
45
45
|
__TYPE__: "ImageLink",
|
|
46
46
|
},
|
|
47
47
|
__TYPE__: "LinkContent",
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type { Asset
|
|
2
|
-
import type {
|
|
1
|
+
import type { Asset } from "../../../../common";
|
|
2
|
+
import type { Embed } from "../../../../common/Embed";
|
|
3
|
+
import type { NestableContent } from "../../../../content";
|
|
3
4
|
import type { ImportNestable } from "../../../validators";
|
|
4
|
-
export declare function convertNestableWidget(field: ImportNestable, assets: Record<
|
|
5
|
+
export declare function convertNestableWidget(field: ImportNestable, assets: Record<Asset["id"], Asset | undefined>, embeds: Record<string, Embed | undefined>): NestableContent | undefined;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.convertNestableWidget = void 0;
|
|
4
4
|
const _1 = require(".");
|
|
5
|
-
function convertNestableWidget(field, assets) {
|
|
5
|
+
function convertNestableWidget(field, assets, embeds) {
|
|
6
6
|
switch (field.type) {
|
|
7
7
|
case "Boolean":
|
|
8
8
|
return (0, _1.booleanConverter)(field.value);
|
|
@@ -19,7 +19,7 @@ function convertNestableWidget(field, assets) {
|
|
|
19
19
|
case "Timestamp":
|
|
20
20
|
return (0, _1.timestampConverter)(field.value);
|
|
21
21
|
case "Embed":
|
|
22
|
-
return (0, _1.embedConverter)(field.value);
|
|
22
|
+
return (0, _1.embedConverter)(field.value, embeds);
|
|
23
23
|
case "GeoPoint":
|
|
24
24
|
return (0, _1.geopointConverter)(field.value);
|
|
25
25
|
case "Link":
|
|
@@ -6,11 +6,11 @@ const fp_ts_1 = require("fp-ts");
|
|
|
6
6
|
const Either_1 = require("fp-ts/Either");
|
|
7
7
|
const function_1 = require("fp-ts/lib/function");
|
|
8
8
|
const t = (0, tslib_1.__importStar)(require("io-ts"));
|
|
9
|
-
const io_ts_types_1 = require("io-ts-types");
|
|
10
9
|
const customtypes_1 = require("../../customtypes");
|
|
11
10
|
const Objects_1 = require("../../utils/Objects");
|
|
11
|
+
const function_2 = require("../../validators/function");
|
|
12
12
|
const ImportField_1 = require("./fields/ImportField");
|
|
13
|
-
const rawImportDocument = (0,
|
|
13
|
+
const rawImportDocument = (0, function_2.withCustomError)(t.UnknownRecord, () => "document is not an object");
|
|
14
14
|
function validateField(document, customType) {
|
|
15
15
|
return (key, content, model) => {
|
|
16
16
|
// the field is not defined in the custom type -> extra field or typo
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { StaticWidget } from "../../../customtypes";
|
|
2
|
+
import { ImportSlices } from "./ImportSlices";
|
|
2
3
|
import { ImportNestable } from "./nestable";
|
|
3
|
-
|
|
4
|
-
export declare type ImportField = ImportUID | ImportNestable;
|
|
4
|
+
export declare type ImportField = ImportSlices | ImportNestable;
|
|
5
5
|
export declare const ImportField: {
|
|
6
|
-
is(u: unknown): u is
|
|
6
|
+
is(u: unknown): u is ImportField;
|
|
7
7
|
decode: (field: StaticWidget) => (content: unknown) => {
|
|
8
8
|
codec: import("io-ts").Type<{
|
|
9
9
|
type: "Boolean";
|
|
@@ -16,42 +16,12 @@ export declare const ImportField: {
|
|
|
16
16
|
value: Date | null;
|
|
17
17
|
}, Date | undefined, unknown> | import("io-ts").Type<{
|
|
18
18
|
type: "Embed";
|
|
19
|
-
value:
|
|
19
|
+
value: {
|
|
20
20
|
embed_url: string;
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
version?: string | number | null;
|
|
24
|
-
title?: string;
|
|
25
|
-
author_name?: string | null;
|
|
26
|
-
author_url?: string | null;
|
|
27
|
-
provider_name?: string | null;
|
|
28
|
-
provider_url?: string | null;
|
|
29
|
-
cache_age?: string | number | null;
|
|
30
|
-
thumbnail_url?: string | null;
|
|
31
|
-
thumbnail_width?: number | null;
|
|
32
|
-
thumbnail_height?: number | null;
|
|
33
|
-
html?: string | null;
|
|
34
|
-
} & {
|
|
35
|
-
all: unknown;
|
|
36
|
-
}) | null;
|
|
37
|
-
}, ({
|
|
21
|
+
} | null;
|
|
22
|
+
}, {
|
|
38
23
|
embed_url: string;
|
|
39
|
-
|
|
40
|
-
} & {
|
|
41
|
-
version?: string | number | null;
|
|
42
|
-
title?: string;
|
|
43
|
-
author_name?: string | null;
|
|
44
|
-
author_url?: string | null;
|
|
45
|
-
provider_name?: string | null;
|
|
46
|
-
provider_url?: string | null;
|
|
47
|
-
cache_age?: string | number | null;
|
|
48
|
-
thumbnail_url?: string | null;
|
|
49
|
-
thumbnail_width?: number | null;
|
|
50
|
-
thumbnail_height?: number | null;
|
|
51
|
-
html?: string | null;
|
|
52
|
-
} & {
|
|
53
|
-
all: unknown;
|
|
54
|
-
}) | undefined, unknown> | import("io-ts").Type<{
|
|
24
|
+
} | undefined, unknown> | import("io-ts").Type<{
|
|
55
25
|
type: "GeoPoint";
|
|
56
26
|
value: {
|
|
57
27
|
latitude: number;
|
|
@@ -62,12 +32,8 @@ export declare const ImportField: {
|
|
|
62
32
|
longitude: number;
|
|
63
33
|
} | undefined, unknown> | import("io-ts").Type<{
|
|
64
34
|
type: "Image";
|
|
65
|
-
value:
|
|
66
|
-
|
|
67
|
-
}) | null;
|
|
68
|
-
}, (import("./nestable").ImageField & {
|
|
69
|
-
thumbnails: Record<string, import("./nestable").ImageField>;
|
|
70
|
-
}) | undefined, unknown> | import("io-ts").Type<{
|
|
35
|
+
value: import("./nestable").ImageFieldWithThumbnails | null;
|
|
36
|
+
}, import("./nestable").ImageFieldWithThumbnails | undefined, unknown> | import("io-ts").Type<{
|
|
71
37
|
type: "Link";
|
|
72
38
|
value: ({
|
|
73
39
|
link_type: "Web";
|
|
@@ -124,9 +90,7 @@ export declare const ImportField: {
|
|
|
124
90
|
} | null;
|
|
125
91
|
}> | import("fp-ts/lib/Either").Right<{
|
|
126
92
|
type: "Image";
|
|
127
|
-
value:
|
|
128
|
-
thumbnails: Record<string, import("./nestable").ImageField>;
|
|
129
|
-
}) | null;
|
|
93
|
+
value: import("./nestable").ImageFieldWithThumbnails | null;
|
|
130
94
|
}> | import("fp-ts/lib/Either").Right<{
|
|
131
95
|
type: "GeoPoint";
|
|
132
96
|
value: {
|
|
@@ -135,24 +99,9 @@ export declare const ImportField: {
|
|
|
135
99
|
} | null;
|
|
136
100
|
}> | import("fp-ts/lib/Either").Right<{
|
|
137
101
|
type: "Embed";
|
|
138
|
-
value:
|
|
102
|
+
value: {
|
|
139
103
|
embed_url: string;
|
|
140
|
-
|
|
141
|
-
} & {
|
|
142
|
-
version?: string | number | null;
|
|
143
|
-
title?: string;
|
|
144
|
-
author_name?: string | null;
|
|
145
|
-
author_url?: string | null;
|
|
146
|
-
provider_name?: string | null;
|
|
147
|
-
provider_url?: string | null;
|
|
148
|
-
cache_age?: string | number | null;
|
|
149
|
-
thumbnail_url?: string | null;
|
|
150
|
-
thumbnail_width?: number | null;
|
|
151
|
-
thumbnail_height?: number | null;
|
|
152
|
-
html?: string | null;
|
|
153
|
-
} & {
|
|
154
|
-
all: unknown;
|
|
155
|
-
}) | null;
|
|
104
|
+
} | null;
|
|
156
105
|
}> | import("fp-ts/lib/Either").Right<{
|
|
157
106
|
type: "Date";
|
|
158
107
|
value: Date | null;
|
|
@@ -165,12 +114,12 @@ export declare const ImportField: {
|
|
|
165
114
|
}>;
|
|
166
115
|
} | {
|
|
167
116
|
codec: import("io-ts").Type<{
|
|
168
|
-
type: "
|
|
169
|
-
value:
|
|
170
|
-
},
|
|
117
|
+
type: "Slices";
|
|
118
|
+
value: import("./ImportSlices/SharedSlice").SharedSlice[] | null;
|
|
119
|
+
}, import("./ImportSlices/SharedSlice").SharedSlice[] | undefined, unknown>;
|
|
171
120
|
result: import("io-ts").Validation<{
|
|
172
|
-
type: "
|
|
173
|
-
value:
|
|
121
|
+
type: "Slices";
|
|
122
|
+
value: import("./ImportSlices/SharedSlice").SharedSlice[] | null;
|
|
174
123
|
}>;
|
|
175
124
|
};
|
|
176
125
|
};
|
|
@@ -1,19 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ImportField = void 0;
|
|
4
|
+
const ImportSlices_1 = require("./ImportSlices");
|
|
4
5
|
const nestable_1 = require("./nestable");
|
|
5
|
-
const UID_1 = require("./UID");
|
|
6
6
|
exports.ImportField = {
|
|
7
7
|
is(u) {
|
|
8
|
-
return
|
|
8
|
+
return exports.ImportField.is(u);
|
|
9
9
|
},
|
|
10
10
|
decode: (field) => {
|
|
11
11
|
return (content) => {
|
|
12
12
|
switch (field.type) {
|
|
13
13
|
case "UID":
|
|
14
|
-
|
|
15
|
-
case "Choice":
|
|
14
|
+
throw new Error(`The field '${field.type}' should be put at the root level of the document`);
|
|
16
15
|
case "Slices":
|
|
16
|
+
return {
|
|
17
|
+
codec: (0, ImportSlices_1.ImportSlices)(field),
|
|
18
|
+
result: (0, ImportSlices_1.ImportSlices)(field).decode(content),
|
|
19
|
+
};
|
|
20
|
+
case "Choice":
|
|
17
21
|
case "Group":
|
|
18
22
|
throw new Error(`Unsupported type of field ${field.type}`);
|
|
19
23
|
default:
|