@prismicio/types-internal 0.2.9 → 0.2.10
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/documents/widgets/GroupContent.js +3 -2
- package/lib/documents/widgets/UIDContent.js +1 -1
- package/lib/documents/widgets/nestable/BooleanContent.js +1 -1
- package/lib/documents/widgets/nestable/IntegrationFieldsContent.js +1 -1
- package/lib/documents/widgets/nestable/Link/LinkContent.js +2 -1
- package/lib/documents/widgets/nestable/StructuredTextContent/index.js +1 -1
- package/lib/documents/widgets/slices/CompositeSliceContent.js +5 -3
- package/lib/documents/widgets/slices/SharedSliceContent.js +3 -2
- package/lib/documents/widgets/slices/SlicesContent.js +2 -1
- package/package.json +1 -1
|
@@ -14,8 +14,9 @@ exports.GroupContent = Object.freeze({
|
|
|
14
14
|
return jsItems.map((jsItem) => {
|
|
15
15
|
if (typeof jsItem === "object" && jsItem !== null) {
|
|
16
16
|
const sorted = Object.entries(jsItem).sort(([k1], [k2]) => {
|
|
17
|
-
|
|
18
|
-
const
|
|
17
|
+
var _a, _b;
|
|
18
|
+
const p1 = (_a = fieldPositions.get(`${prefixedKey}.${k1}`)) !== null && _a !== void 0 ? _a : 10000;
|
|
19
|
+
const p2 = (_b = fieldPositions.get(`${prefixedKey}.${k2}`)) !== null && _b !== void 0 ? _b : 10000;
|
|
19
20
|
return p1 - p2;
|
|
20
21
|
});
|
|
21
22
|
const w = sorted.map(([k, v]) => {
|
|
@@ -5,6 +5,6 @@ const tslib_1 = require("tslib");
|
|
|
5
5
|
const Either_1 = require("fp-ts/Either");
|
|
6
6
|
const t = (0, tslib_1.__importStar)(require("io-ts"));
|
|
7
7
|
exports.UIDContentType = "UIDContent";
|
|
8
|
-
exports.UIDContent = new t.Type("UIDContent", (u) => u
|
|
8
|
+
exports.UIDContent = new t.Type("UIDContent", (u) => { var _a; return ((_a = u) === null || _a === void 0 ? void 0 : _a.__TYPE__) === exports.UIDContentType; }, (u, c) => Either_1.Chain.chain(t.string.validate(u, c), (u) => {
|
|
9
9
|
return t.success({ value: u, __TYPE__: "UIDContent" });
|
|
10
10
|
}), (uidContent) => uidContent.value);
|
|
@@ -5,7 +5,7 @@ const tslib_1 = require("tslib");
|
|
|
5
5
|
const Either_1 = require("fp-ts/Either");
|
|
6
6
|
const t = (0, tslib_1.__importStar)(require("io-ts"));
|
|
7
7
|
exports.BooleanContentType = "BooleanContent";
|
|
8
|
-
const BooleanContent = new t.Type("BooleanContent", (u) => u
|
|
8
|
+
const BooleanContent = new t.Type("BooleanContent", (u) => { var _a; return ((_a = u) === null || _a === void 0 ? void 0 : _a.__TYPE__) === exports.BooleanContentType; }, (u, c) => Either_1.Chain.chain(t.boolean.validate(u, c), (u) => {
|
|
9
9
|
return t.success({ value: u, __TYPE__: exports.BooleanContentType });
|
|
10
10
|
}), (booleanContent) => t.boolean.encode(booleanContent.value));
|
|
11
11
|
exports.default = BooleanContent;
|
|
@@ -5,7 +5,7 @@ const tslib_1 = require("tslib");
|
|
|
5
5
|
const Either_1 = require("fp-ts/Either");
|
|
6
6
|
const t = (0, tslib_1.__importStar)(require("io-ts"));
|
|
7
7
|
exports.IntegrationFieldsContentType = "IntegrationFieldsContent";
|
|
8
|
-
const IntegrationFieldsContent = new t.Type("IntegrationFieldsContent", (u) => u
|
|
8
|
+
const IntegrationFieldsContent = new t.Type("IntegrationFieldsContent", (u) => { var _a; return ((_a = u) === null || _a === void 0 ? void 0 : _a.__TYPE__) === exports.IntegrationFieldsContentType; }, (u, c) => Either_1.Chain.chain(t.string.validate(u, c), (u) => {
|
|
9
9
|
return t.success({
|
|
10
10
|
value: u,
|
|
11
11
|
__TYPE__: exports.IntegrationFieldsContentType,
|
|
@@ -7,7 +7,8 @@ const t = (0, tslib_1.__importStar)(require("io-ts"));
|
|
|
7
7
|
const index_1 = require("./index");
|
|
8
8
|
exports.LinkContentType = "LinkContent";
|
|
9
9
|
exports.LinkContent = new t.Type("LinkContent", (u) => {
|
|
10
|
-
|
|
10
|
+
var _a;
|
|
11
|
+
return index_1.Link.is((_a = u) === null || _a === void 0 ? void 0 : _a.value);
|
|
11
12
|
}, (u, c) => Either_1.Chain.chain(index_1.Link.validate(u, c), (u) => {
|
|
12
13
|
return t.success({ value: u, __TYPE__: exports.LinkContentType });
|
|
13
14
|
}), (linkContent) => index_1.Link.encode(linkContent.value));
|
|
@@ -6,7 +6,7 @@ const Either_1 = require("fp-ts/Either");
|
|
|
6
6
|
const t = (0, tslib_1.__importStar)(require("io-ts"));
|
|
7
7
|
const Block_1 = require("./Block");
|
|
8
8
|
exports.StructuredTextContentType = "StructuredTextContent";
|
|
9
|
-
exports.StructuredTextContent = new t.Type(exports.StructuredTextContentType, (u) => u
|
|
9
|
+
exports.StructuredTextContent = new t.Type(exports.StructuredTextContentType, (u) => { var _a; return ((_a = u) === null || _a === void 0 ? void 0 : _a.__TYPE__) === exports.StructuredTextContentType; }, (u, c) => Either_1.Chain.chain(t.array(Block_1.Block).validate(u, c), (u) => {
|
|
10
10
|
return t.success({ value: u, __TYPE__: exports.StructuredTextContentType });
|
|
11
11
|
}), () => {
|
|
12
12
|
throw new Error("NotImplementedError: Not relevant method");
|
|
@@ -13,17 +13,19 @@ const codec = t.exact(t.partial({
|
|
|
13
13
|
}));
|
|
14
14
|
exports.CompositeSliceContent = {
|
|
15
15
|
fromJson: (prefixes, key, value, fieldTypes, fieldPositions) => {
|
|
16
|
+
var _a;
|
|
16
17
|
const prefixedRepeatKey = Array.of(prefixes, [key, "repeat"])
|
|
17
18
|
.flat()
|
|
18
19
|
.join(".");
|
|
19
20
|
const decodedValue = codec.decode(value);
|
|
20
21
|
if ((0, Either_1.isRight)(decodedValue)) {
|
|
21
22
|
const repeatObj = decodedValue.right.repeat;
|
|
22
|
-
const nonRepeatObj = decodedValue.right["non-repeat"]
|
|
23
|
+
const nonRepeatObj = (_a = decodedValue.right["non-repeat"]) !== null && _a !== void 0 ? _a : {};
|
|
23
24
|
const groupItemsContentsRepeat = index_1.GroupContent.itemsContentsFromJson(prefixedRepeatKey, repeatObj, fieldTypes, fieldPositions);
|
|
24
25
|
const sortedFields = Object.entries(nonRepeatObj).sort(([k1], [k2]) => {
|
|
25
|
-
|
|
26
|
-
const
|
|
26
|
+
var _a, _b;
|
|
27
|
+
const p1 = (_a = fieldPositions.get(`${Array.of(prefixes, [key]).flat().join(".")}.${k1}`)) !== null && _a !== void 0 ? _a : 10000;
|
|
28
|
+
const p2 = (_b = fieldPositions.get(`${Array.of(prefixes, [key]).flat().join(".")}.${k2}`)) !== null && _b !== void 0 ? _b : 10000;
|
|
27
29
|
return p1 - p2;
|
|
28
30
|
});
|
|
29
31
|
const nonRepeat = sortedFields.reduce((acc, [k, v]) => {
|
|
@@ -26,8 +26,9 @@ exports.SharedSliceContent = {
|
|
|
26
26
|
.join(".");
|
|
27
27
|
const groupItemsContents = index_1.GroupContent.itemsContentsFromJson(prefixedItemsKey, v.items, fieldTypes, fieldPositions);
|
|
28
28
|
const sortedFields = Object.entries(v.primary).sort(([k1], [k2]) => {
|
|
29
|
-
|
|
30
|
-
const
|
|
29
|
+
var _a, _b;
|
|
30
|
+
const p1 = (_a = fieldPositions.get(`${Array.of(prefixes, [key]).flat().join(".")}.${k1}`)) !== null && _a !== void 0 ? _a : 10000;
|
|
31
|
+
const p2 = (_b = fieldPositions.get(`${Array.of(prefixes, [key]).flat().join(".")}.${k2}`)) !== null && _b !== void 0 ? _b : 10000;
|
|
31
32
|
return p1 - p2;
|
|
32
33
|
});
|
|
33
34
|
const primary = sortedFields.reduce((acc, [k, w]) => {
|
|
@@ -25,10 +25,11 @@ exports.SlicesContent = {
|
|
|
25
25
|
const name = r.key.substring(0, stopIdx > 0 ? stopIdx : undefined);
|
|
26
26
|
const maybeWidget = codecWidget(name, r.value);
|
|
27
27
|
return O.map((widget) => {
|
|
28
|
+
var _a;
|
|
28
29
|
return {
|
|
29
30
|
key: r.key,
|
|
30
31
|
name,
|
|
31
|
-
maybeLabel: r.label
|
|
32
|
+
maybeLabel: (_a = r.label) !== null && _a !== void 0 ? _a : undefined,
|
|
32
33
|
widget: widget,
|
|
33
34
|
};
|
|
34
35
|
})(maybeWidget);
|