@prismicio/types-internal 2.1.0-alpha.1 → 2.1.0-alpha.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/content/Document.js
CHANGED
|
@@ -62,12 +62,7 @@ function extractMetadata(data) {
|
|
|
62
62
|
widgets: {},
|
|
63
63
|
});
|
|
64
64
|
const slugs = data["slugs_INTERNAL"] || [];
|
|
65
|
-
const uid =
|
|
66
|
-
const rawUID = data["uid"];
|
|
67
|
-
if ((0, fields_1.isUIDContent)(rawUID))
|
|
68
|
-
return rawUID.value;
|
|
69
|
-
return;
|
|
70
|
-
})();
|
|
65
|
+
const uid = data["uid"];
|
|
71
66
|
return {
|
|
72
67
|
widgets,
|
|
73
68
|
types,
|
package/package.json
CHANGED
package/src/content/Document.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { pipe } from "fp-ts/lib/function"
|
|
|
4
4
|
import * as t from "io-ts"
|
|
5
5
|
|
|
6
6
|
import { WidgetKey } from "../common"
|
|
7
|
-
import {
|
|
7
|
+
import { WidgetContent, WidgetLegacy } from "./fields"
|
|
8
8
|
import {
|
|
9
9
|
defaultCtx,
|
|
10
10
|
FieldOrSliceType,
|
|
@@ -97,11 +97,7 @@ function extractMetadata(data: { [p: string]: unknown }): {
|
|
|
97
97
|
)
|
|
98
98
|
|
|
99
99
|
const slugs = (data["slugs_INTERNAL"] as string[]) || []
|
|
100
|
-
const uid =
|
|
101
|
-
const rawUID = data["uid"]
|
|
102
|
-
if (isUIDContent(rawUID)) return rawUID.value
|
|
103
|
-
return
|
|
104
|
-
})()
|
|
100
|
+
const uid = data["uid"] as string | undefined
|
|
105
101
|
|
|
106
102
|
return {
|
|
107
103
|
widgets,
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import * as t from "io-ts";
|
|
2
|
-
export declare const LinkFieldType = "Link";
|
|
3
|
-
export declare const LinkConfig: t.ExactC<t.PartialC<{
|
|
4
|
-
label: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
|
|
5
|
-
useAsTitle: t.BooleanC;
|
|
6
|
-
placeholder: t.StringC;
|
|
7
|
-
select: t.UnionC<[t.LiteralC<"media">, t.LiteralC<"document">, t.LiteralC<"web">, t.NullC]>;
|
|
8
|
-
customtypes: t.ReadonlyArrayC<t.StringC>;
|
|
9
|
-
masks: t.Type<readonly string[], object, unknown>;
|
|
10
|
-
tags: t.Type<readonly string[], object, unknown>;
|
|
11
|
-
allowTargetBlank: t.BooleanC;
|
|
12
|
-
}>>;
|
|
13
|
-
export declare type LinkConfig = t.TypeOf<typeof LinkConfig>;
|
|
14
|
-
export declare const Link: t.ExactC<t.IntersectionC<[t.TypeC<{
|
|
15
|
-
type: t.LiteralC<"Link">;
|
|
16
|
-
}>, t.PartialC<{
|
|
17
|
-
fieldset: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
|
|
18
|
-
config: t.ExactC<t.PartialC<{
|
|
19
|
-
label: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
|
|
20
|
-
useAsTitle: t.BooleanC;
|
|
21
|
-
placeholder: t.StringC;
|
|
22
|
-
select: t.UnionC<[t.LiteralC<"media">, t.LiteralC<"document">, t.LiteralC<"web">, t.NullC]>;
|
|
23
|
-
customtypes: t.ReadonlyArrayC<t.StringC>;
|
|
24
|
-
masks: t.Type<readonly string[], object, unknown>;
|
|
25
|
-
tags: t.Type<readonly string[], object, unknown>;
|
|
26
|
-
allowTargetBlank: t.BooleanC;
|
|
27
|
-
}>>;
|
|
28
|
-
}>]>>;
|
|
29
|
-
export declare type Link = t.TypeOf<typeof Link>;
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Link = exports.LinkConfig = exports.LinkFieldType = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const Either_1 = require("fp-ts/lib/Either");
|
|
6
|
-
const t = (0, tslib_1.__importStar)(require("io-ts"));
|
|
7
|
-
const withFallback_1 = require("io-ts-types/lib/withFallback");
|
|
8
|
-
const validators_1 = require("../../../validators");
|
|
9
|
-
const arrayString = (entries) => {
|
|
10
|
-
if (entries instanceof Array) {
|
|
11
|
-
const isValidEntries = entries.reduce((acc, l) => acc && typeof l === "string", true);
|
|
12
|
-
if (isValidEntries)
|
|
13
|
-
return t.success(entries);
|
|
14
|
-
}
|
|
15
|
-
return;
|
|
16
|
-
};
|
|
17
|
-
const plainString = (entries) => {
|
|
18
|
-
if (typeof entries === "string") {
|
|
19
|
-
return t.success([entries]);
|
|
20
|
-
}
|
|
21
|
-
return;
|
|
22
|
-
};
|
|
23
|
-
const MasksArrayString = new t.Type("MasksArrayString", (u) => {
|
|
24
|
-
return u instanceof Array;
|
|
25
|
-
}, (u, context) => {
|
|
26
|
-
return Either_1.either.chain(t.union([t.array(t.string), t.string]).validate(u, context), (masks) => {
|
|
27
|
-
return arrayString(masks) || plainString(masks) || t.failure(u, context);
|
|
28
|
-
});
|
|
29
|
-
}, (res) => res);
|
|
30
|
-
exports.LinkFieldType = "Link";
|
|
31
|
-
exports.LinkConfig = t.exact(t.partial({
|
|
32
|
-
label: validators_1.StringOrNull,
|
|
33
|
-
useAsTitle: t.boolean,
|
|
34
|
-
placeholder: t.string,
|
|
35
|
-
select: (0, withFallback_1.withFallback)(t.union([
|
|
36
|
-
t.literal("media"),
|
|
37
|
-
t.literal("document"),
|
|
38
|
-
t.literal("web"),
|
|
39
|
-
t.null,
|
|
40
|
-
]), null),
|
|
41
|
-
customtypes: t.readonlyArray(t.string),
|
|
42
|
-
masks: MasksArrayString,
|
|
43
|
-
tags: MasksArrayString,
|
|
44
|
-
allowTargetBlank: t.boolean,
|
|
45
|
-
}));
|
|
46
|
-
exports.Link = t.exact(t.intersection([
|
|
47
|
-
t.type({
|
|
48
|
-
type: t.literal(exports.LinkFieldType),
|
|
49
|
-
}),
|
|
50
|
-
t.partial({
|
|
51
|
-
fieldset: validators_1.StringOrNull,
|
|
52
|
-
config: exports.LinkConfig,
|
|
53
|
-
}),
|
|
54
|
-
]));
|