@prismicio/types-internal 0.2.0 → 0.2.2
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 -2
- package/lib/customtypes/CustomType.js +38 -56
- package/lib/customtypes/Format.js +2 -5
- package/lib/customtypes/Section.d.ts +1 -1
- package/lib/customtypes/Section.js +9 -32
- package/lib/customtypes/index.js +4 -30
- package/lib/customtypes/widgets/Group.js +9 -33
- package/lib/customtypes/widgets/UID.js +7 -31
- package/lib/customtypes/widgets/Widget.d.ts +1 -1
- package/lib/customtypes/widgets/Widget.js +14 -40
- package/lib/customtypes/widgets/WidgetTypes.js +1 -3
- package/lib/customtypes/widgets/index.js +7 -35
- package/lib/customtypes/widgets/nestable/BooleanField.js +6 -30
- package/lib/customtypes/widgets/nestable/Color.js +7 -31
- package/lib/customtypes/widgets/nestable/Date.js +7 -31
- package/lib/customtypes/widgets/nestable/Embed.js +7 -31
- package/lib/customtypes/widgets/nestable/GeoPoint.js +7 -31
- package/lib/customtypes/widgets/nestable/Image.js +10 -34
- package/lib/customtypes/widgets/nestable/IntegrationField.js +7 -31
- package/lib/customtypes/widgets/nestable/Link.js +13 -35
- package/lib/customtypes/widgets/nestable/NestableWidget.js +32 -56
- package/lib/customtypes/widgets/nestable/Number.js +11 -35
- package/lib/customtypes/widgets/nestable/Range.js +11 -35
- package/lib/customtypes/widgets/nestable/RichText.js +16 -36
- package/lib/customtypes/widgets/nestable/Select.js +8 -32
- package/lib/customtypes/widgets/nestable/Separator.js +6 -30
- package/lib/customtypes/widgets/nestable/Text.js +7 -31
- package/lib/customtypes/widgets/nestable/Timestamp.js +7 -31
- package/lib/customtypes/widgets/nestable/index.js +15 -36
- package/lib/customtypes/widgets/shared/ImageConstraint.js +9 -30
- package/lib/customtypes/widgets/shared/index.js +1 -8
- package/lib/customtypes/widgets/slices/CompositeSlice.js +10 -34
- package/lib/customtypes/widgets/slices/LegacySlice.js +6 -30
- package/lib/customtypes/widgets/slices/SharedSlice.js +9 -33
- package/lib/customtypes/widgets/slices/SharedSliceRef.js +4 -28
- package/lib/customtypes/widgets/slices/Slice.d.ts +4 -4
- package/lib/customtypes/widgets/slices/Slice.js +1 -2
- package/lib/customtypes/widgets/slices/Slices.js +27 -54
- package/lib/customtypes/widgets/slices/SlicesTypes.js +1 -3
- package/lib/customtypes/widgets/slices/index.js +7 -37
- package/lib/documents/DocumentData.js +4 -25
- package/lib/documents/index.js +2 -28
- package/lib/documents/widgets/EmptyContent.js +3 -6
- package/lib/documents/widgets/GroupContent.js +10 -32
- package/lib/documents/widgets/SimpleWidgetContent.d.ts +2 -2
- package/lib/documents/widgets/SimpleWidgetContent.js +27 -53
- package/lib/documents/widgets/StaticWidgetContent.js +8 -29
- package/lib/documents/widgets/UIDContent.js +4 -26
- package/lib/documents/widgets/index.js +22 -51
- package/lib/documents/widgets/nestable/BooleanContent.js +6 -28
- package/lib/documents/widgets/nestable/EmbedContent.d.ts +4 -4
- package/lib/documents/widgets/nestable/EmbedContent.js +20 -42
- package/lib/documents/widgets/nestable/FieldContent.js +8 -28
- package/lib/documents/widgets/nestable/GeoPointContent.js +5 -27
- package/lib/documents/widgets/nestable/ImageContent.d.ts +14 -14
- package/lib/documents/widgets/nestable/ImageContent.js +12 -34
- package/lib/documents/widgets/nestable/IntegrationFieldsContent.js +6 -28
- package/lib/documents/widgets/nestable/Link/DocumentLink.js +7 -30
- package/lib/documents/widgets/nestable/Link/ExternalLink.d.ts +4 -4
- package/lib/documents/widgets/nestable/Link/ExternalLink.js +10 -33
- package/lib/documents/widgets/nestable/Link/FileLink.js +10 -33
- package/lib/documents/widgets/nestable/Link/ImageLink.js +9 -32
- package/lib/documents/widgets/nestable/Link/LinkContent.d.ts +2 -2
- package/lib/documents/widgets/nestable/Link/LinkContent.js +9 -31
- package/lib/documents/widgets/nestable/Link/index.d.ts +8 -8
- package/lib/documents/widgets/nestable/Link/index.js +24 -51
- package/lib/documents/widgets/nestable/SeparatorContent.js +2 -5
- package/lib/documents/widgets/nestable/StructuredTextContent/Block.d.ts +8 -8
- package/lib/documents/widgets/nestable/StructuredTextContent/Block.js +33 -60
- package/lib/documents/widgets/nestable/StructuredTextContent/index.js +7 -29
- package/lib/documents/widgets/nestable/index.d.ts +2 -2
- package/lib/documents/widgets/nestable/index.js +28 -63
- package/lib/documents/widgets/slices/CompositeSliceContent.d.ts +1 -1
- package/lib/documents/widgets/slices/CompositeSliceContent.js +9 -31
- package/lib/documents/widgets/slices/SharedSliceContent.d.ts +1 -1
- package/lib/documents/widgets/slices/SharedSliceContent.js +12 -34
- package/lib/documents/widgets/slices/SimpleSliceContent.js +2 -8
- package/lib/documents/widgets/slices/SliceWidgetContent.d.ts +1 -1
- package/lib/documents/widgets/slices/SliceWidgetContent.js +8 -33
- package/lib/documents/widgets/slices/SlicesContent.js +13 -35
- package/lib/documents/widgets/slices/index.js +5 -17
- package/lib/index.js +3 -25
- package/lib/validators/DateFromString.js +4 -25
- package/lib/validators/DateFromStringOrNumber.js +4 -25
- package/lib/validators/DateFromTsMs.js +4 -25
- package/lib/validators/IntFromNumber.js +4 -25
- package/lib/validators/IntFromPixels.js +7 -29
- package/lib/validators/NonEmptyString.js +3 -24
- package/lib/validators/NonEmptyStringOrNull.js +7 -12
- package/lib/validators/NumberOrNull.js +3 -24
- package/lib/validators/StringFromBoolean.js +4 -25
- package/lib/validators/StringFromNumber.js +4 -25
- package/lib/validators/StringOrNull.js +3 -24
- package/lib/validators/function.js +17 -47
- package/lib/validators/index.js +12 -48
- package/package.json +1 -1
- package/lib/documents/widgets/Widget.d.ts +0 -0
- package/lib/documents/widgets/Widget.js +0 -1
|
@@ -1,77 +1,47 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
if (k2 === undefined) k2 = k;
|
|
7
|
-
o[k2] = m[k];
|
|
8
|
-
}));
|
|
9
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
-
}) : function(o, v) {
|
|
12
|
-
o["default"] = v;
|
|
13
|
-
});
|
|
14
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
-
if (mod && mod.__esModule) return mod;
|
|
16
|
-
var result = {};
|
|
17
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
-
__setModuleDefault(result, mod);
|
|
19
|
-
return result;
|
|
20
|
-
};
|
|
21
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
-
exports.addType = exports.isEmpty = exports.objectToMap = exports.grouped = exports.formatDate = exports.formatDateTime = exports.filterDouble = exports.refineType = exports.nullable = void 0;
|
|
23
|
-
const fp_ts_1 = require("fp-ts");
|
|
24
|
-
const function_1 = require("fp-ts/function");
|
|
25
|
-
const t = __importStar(require("io-ts"));
|
|
26
|
-
const mapOutput_1 = require("io-ts-types/mapOutput");
|
|
27
|
-
function nullable(c) {
|
|
1
|
+
import { either } from "fp-ts";
|
|
2
|
+
import { pipe } from "fp-ts/function";
|
|
3
|
+
import * as t from "io-ts";
|
|
4
|
+
import { mapOutput } from "io-ts-types/mapOutput";
|
|
5
|
+
export function nullable(c) {
|
|
28
6
|
return t.union([c, t.null, t.undefined]);
|
|
29
7
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
return new t.Type(newName, type.is, (u, c) => (0, function_1.pipe)(type.validate(u, c), fp_ts_1.either.chain((v) => (pred(v) ? t.success(v) : t.failure(u, c)))), type.encode);
|
|
8
|
+
export function refineType(type, newName, pred) {
|
|
9
|
+
return new t.Type(newName, type.is, (u, c) => pipe(type.validate(u, c), either.chain((v) => (pred(v) ? t.success(v) : t.failure(u, c)))), type.encode);
|
|
33
10
|
}
|
|
34
|
-
|
|
35
|
-
function filterDouble(value) {
|
|
11
|
+
export function filterDouble(value) {
|
|
36
12
|
if (value === "") {
|
|
37
13
|
return null;
|
|
38
14
|
}
|
|
39
15
|
const result = Number(value);
|
|
40
16
|
return Number.isNaN(result) ? null : result;
|
|
41
17
|
}
|
|
42
|
-
|
|
43
|
-
function formatDateTime(date) {
|
|
18
|
+
export function formatDateTime(date) {
|
|
44
19
|
return date.toISOString().replace(/\.\d{3}Z$/, "+0000");
|
|
45
20
|
}
|
|
46
|
-
|
|
47
|
-
function formatDate(date) {
|
|
21
|
+
export function formatDate(date) {
|
|
48
22
|
return date.toISOString().replace(/T.*/, "");
|
|
49
23
|
}
|
|
50
|
-
|
|
51
|
-
function grouped(array, n) {
|
|
24
|
+
export function grouped(array, n) {
|
|
52
25
|
return array.reduce((acc, curr, idx) => {
|
|
53
26
|
if (idx % n === 0) {
|
|
54
27
|
acc.push([curr]);
|
|
55
28
|
}
|
|
56
29
|
else {
|
|
30
|
+
/* eslint-disable @typescript-eslint/no-non-null-assertion */
|
|
57
31
|
acc[Math.floor(idx / n)].push(curr);
|
|
58
32
|
}
|
|
59
33
|
return acc;
|
|
60
34
|
}, new Array());
|
|
61
35
|
}
|
|
62
|
-
|
|
63
|
-
function objectToMap(object) {
|
|
36
|
+
export function objectToMap(object) {
|
|
64
37
|
return new Map(Object.entries(object));
|
|
65
38
|
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
for (const x in obj) {
|
|
39
|
+
export function isEmpty(obj) {
|
|
40
|
+
for (const _x in obj) {
|
|
69
41
|
return false;
|
|
70
42
|
}
|
|
71
43
|
return true;
|
|
72
44
|
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
return (0, mapOutput_1.mapOutput)(codec, (o) => ({ ...o, __TYPE__: t }));
|
|
45
|
+
export function addType(codec, t) {
|
|
46
|
+
return mapOutput(codec, (o) => ({ ...o, __TYPE__: t }));
|
|
76
47
|
}
|
|
77
|
-
exports.addType = addType;
|
package/lib/validators/index.js
CHANGED
|
@@ -1,48 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
});
|
|
14
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
-
if (mod && mod.__esModule) return mod;
|
|
16
|
-
var result = {};
|
|
17
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
-
__setModuleDefault(result, mod);
|
|
19
|
-
return result;
|
|
20
|
-
};
|
|
21
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
22
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
23
|
-
};
|
|
24
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
-
exports.StringOrNull = exports.StringFromNumber = exports.StringFromBoolean = exports.NumberOrNull = exports.NonEmptyStringOrNull = exports.NonEmptyString = exports.IntFromPixels = exports.IntFromNumber = exports.Function = exports.DateFromTsMs = exports.DateFromStringOrNumber = exports.DateFromString = void 0;
|
|
26
|
-
var DateFromString_1 = require("./DateFromString");
|
|
27
|
-
Object.defineProperty(exports, "DateFromString", { enumerable: true, get: function () { return __importDefault(DateFromString_1).default; } });
|
|
28
|
-
var DateFromStringOrNumber_1 = require("./DateFromStringOrNumber");
|
|
29
|
-
Object.defineProperty(exports, "DateFromStringOrNumber", { enumerable: true, get: function () { return __importDefault(DateFromStringOrNumber_1).default; } });
|
|
30
|
-
var DateFromTsMs_1 = require("./DateFromTsMs");
|
|
31
|
-
Object.defineProperty(exports, "DateFromTsMs", { enumerable: true, get: function () { return __importDefault(DateFromTsMs_1).default; } });
|
|
32
|
-
exports.Function = __importStar(require("./function"));
|
|
33
|
-
var IntFromNumber_1 = require("./IntFromNumber");
|
|
34
|
-
Object.defineProperty(exports, "IntFromNumber", { enumerable: true, get: function () { return __importDefault(IntFromNumber_1).default; } });
|
|
35
|
-
var IntFromPixels_1 = require("./IntFromPixels");
|
|
36
|
-
Object.defineProperty(exports, "IntFromPixels", { enumerable: true, get: function () { return __importDefault(IntFromPixels_1).default; } });
|
|
37
|
-
var NonEmptyString_1 = require("./NonEmptyString");
|
|
38
|
-
Object.defineProperty(exports, "NonEmptyString", { enumerable: true, get: function () { return __importDefault(NonEmptyString_1).default; } });
|
|
39
|
-
var NonEmptyStringOrNull_1 = require("./NonEmptyStringOrNull");
|
|
40
|
-
Object.defineProperty(exports, "NonEmptyStringOrNull", { enumerable: true, get: function () { return __importDefault(NonEmptyStringOrNull_1).default; } });
|
|
41
|
-
var NumberOrNull_1 = require("./NumberOrNull");
|
|
42
|
-
Object.defineProperty(exports, "NumberOrNull", { enumerable: true, get: function () { return __importDefault(NumberOrNull_1).default; } });
|
|
43
|
-
var StringFromBoolean_1 = require("./StringFromBoolean");
|
|
44
|
-
Object.defineProperty(exports, "StringFromBoolean", { enumerable: true, get: function () { return __importDefault(StringFromBoolean_1).default; } });
|
|
45
|
-
var StringFromNumber_1 = require("./StringFromNumber");
|
|
46
|
-
Object.defineProperty(exports, "StringFromNumber", { enumerable: true, get: function () { return __importDefault(StringFromNumber_1).default; } });
|
|
47
|
-
var StringOrNull_1 = require("./StringOrNull");
|
|
48
|
-
Object.defineProperty(exports, "StringOrNull", { enumerable: true, get: function () { return __importDefault(StringOrNull_1).default; } });
|
|
1
|
+
export { default as DateFromString } from "./DateFromString";
|
|
2
|
+
export { default as DateFromStringOrNumber } from "./DateFromStringOrNumber";
|
|
3
|
+
export { default as DateFromTsMs } from "./DateFromTsMs";
|
|
4
|
+
export * as Function from "./function";
|
|
5
|
+
export { default as IntFromNumber } from "./IntFromNumber";
|
|
6
|
+
export { default as IntFromPixels } from "./IntFromPixels";
|
|
7
|
+
export { default as NonEmptyString } from "./NonEmptyString";
|
|
8
|
+
export { default as NonEmptyStringOrNull } from "./NonEmptyStringOrNull";
|
|
9
|
+
export { default as NumberOrNull } from "./NumberOrNull";
|
|
10
|
+
export { default as StringFromBoolean } from "./StringFromBoolean";
|
|
11
|
+
export { default as StringFromNumber } from "./StringFromNumber";
|
|
12
|
+
export { default as StringOrNull } from "./StringOrNull";
|
package/package.json
CHANGED
|
File without changes
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";
|