@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,39 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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.SharedSliceContent = exports.SharedSliceContentType = void 0;
|
|
23
|
-
const Either_1 = require("fp-ts/Either");
|
|
24
|
-
const O = __importStar(require("fp-ts/Option"));
|
|
25
|
-
const t = __importStar(require("io-ts"));
|
|
26
|
-
const io_ts_types_1 = require("io-ts-types");
|
|
27
|
-
const index_1 = require("../index");
|
|
28
|
-
exports.SharedSliceContentType = "SharedSliceContent";
|
|
1
|
+
import { map } from "fp-ts/Either";
|
|
2
|
+
import * as O from "fp-ts/Option";
|
|
3
|
+
import * as t from "io-ts";
|
|
4
|
+
import { withFallback } from "io-ts-types";
|
|
5
|
+
import { GroupContent, SimpleWidgetContent } from "../index";
|
|
6
|
+
export const SharedSliceContentType = "SharedSliceContent";
|
|
29
7
|
const codec = t.exact(t.type({
|
|
30
8
|
variation: t.string,
|
|
31
|
-
items:
|
|
32
|
-
primary:
|
|
9
|
+
items: withFallback(t.array(t.unknown), []),
|
|
10
|
+
primary: withFallback(t.UnknownRecord, {}),
|
|
33
11
|
}));
|
|
34
|
-
|
|
12
|
+
export const SharedSliceContent = {
|
|
35
13
|
fromJson: (prefixes, key, value, fieldTypes, fieldPositions) => {
|
|
36
|
-
const r =
|
|
14
|
+
const r = map((v) => {
|
|
37
15
|
const prefixedItemsKey = Array.of(prefixes, [
|
|
38
16
|
key,
|
|
39
17
|
"variations",
|
|
@@ -42,7 +20,7 @@ exports.SharedSliceContent = {
|
|
|
42
20
|
])
|
|
43
21
|
.flat()
|
|
44
22
|
.join(".");
|
|
45
|
-
const groupItemsContents =
|
|
23
|
+
const groupItemsContents = GroupContent.itemsContentsFromJson(prefixedItemsKey, v.items, fieldTypes, fieldPositions);
|
|
46
24
|
const sortedFields = Object.entries(v.primary).sort(([k1], [k2]) => {
|
|
47
25
|
const p1 = fieldPositions.get(`${Array.of(prefixes, [key]).flat().join(".")}.${k1}`) ?? 10000;
|
|
48
26
|
const p2 = fieldPositions.get(`${Array.of(prefixes, [key]).flat().join(".")}.${k2}`) ?? 10000;
|
|
@@ -60,7 +38,7 @@ exports.SharedSliceContent = {
|
|
|
60
38
|
.join(".");
|
|
61
39
|
const kind = fieldTypes.get(kp);
|
|
62
40
|
if (kind) {
|
|
63
|
-
const maybeWidgetContent =
|
|
41
|
+
const maybeWidgetContent = SimpleWidgetContent.from(kind, w);
|
|
64
42
|
if (O.isSome(maybeWidgetContent)) {
|
|
65
43
|
acc[k] = maybeWidgetContent.value;
|
|
66
44
|
}
|
|
@@ -1,8 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.SimpleSliceContent = void 0;
|
|
7
|
-
const StaticWidgetContent_1 = __importDefault(require("../StaticWidgetContent"));
|
|
8
|
-
exports.SimpleSliceContent = StaticWidgetContent_1.default;
|
|
1
|
+
import StaticWidgetContent from "../StaticWidgetContent";
|
|
2
|
+
export const SimpleSliceContent = StaticWidgetContent;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as O from "fp-ts/Option";
|
|
2
2
|
import { CompositeSliceContent } from "./CompositeSliceContent";
|
|
3
3
|
import { SharedSliceContent } from "./SharedSliceContent";
|
|
4
|
-
import { SimpleSliceContent } from "./SimpleSliceContent";
|
|
4
|
+
import type { SimpleSliceContent } from "./SimpleSliceContent";
|
|
5
5
|
export declare type SliceWidgetContent = SimpleSliceContent | CompositeSliceContent | SharedSliceContent;
|
|
6
6
|
export declare const SliceWidgetContent: {
|
|
7
7
|
fromJson: (prefixes: Array<string>, key: string, value: unknown, fieldTypes: Map<string, string>, fieldPositions: Map<string, number>) => O.Option<SliceWidgetContent>;
|
|
@@ -1,44 +1,19 @@
|
|
|
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
|
-
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.SliceWidgetContent = void 0;
|
|
26
|
-
const O = __importStar(require("fp-ts/Option"));
|
|
27
|
-
const StaticWidgetContent_1 = __importDefault(require("../StaticWidgetContent"));
|
|
28
|
-
const CompositeSliceContent_1 = require("./CompositeSliceContent");
|
|
29
|
-
const SharedSliceContent_1 = require("./SharedSliceContent");
|
|
30
|
-
exports.SliceWidgetContent = {
|
|
1
|
+
import * as O from "fp-ts/Option";
|
|
2
|
+
import StaticWidgetContent from "../StaticWidgetContent";
|
|
3
|
+
import { CompositeSliceContent } from "./CompositeSliceContent";
|
|
4
|
+
import { SharedSliceContent } from "./SharedSliceContent";
|
|
5
|
+
export const SliceWidgetContent = {
|
|
31
6
|
fromJson: (prefixes, key, value, fieldTypes, fieldPositions) => {
|
|
32
7
|
const prefixedKey = Array.of(prefixes, [key]).flat().join(".");
|
|
33
8
|
const fieldType = fieldTypes.get(prefixedKey);
|
|
34
9
|
if (fieldType === "SharedSlice") {
|
|
35
|
-
return
|
|
10
|
+
return SharedSliceContent.fromJson(prefixes, key, value, fieldTypes, fieldPositions);
|
|
36
11
|
}
|
|
37
12
|
else if (fieldType === "Slice") {
|
|
38
|
-
return
|
|
13
|
+
return CompositeSliceContent.fromJson(prefixes, key, value, fieldTypes, fieldPositions);
|
|
39
14
|
}
|
|
40
15
|
else if (fieldType) {
|
|
41
|
-
return
|
|
16
|
+
return StaticWidgetContent.fromJson(prefixes, key, value, fieldTypes, fieldPositions);
|
|
42
17
|
}
|
|
43
18
|
else {
|
|
44
19
|
return O.none;
|
|
@@ -1,44 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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.SlicesContent = exports.SlicesContentType = void 0;
|
|
23
|
-
const A = __importStar(require("fp-ts/Array"));
|
|
24
|
-
const function_1 = require("fp-ts/function");
|
|
25
|
-
const O = __importStar(require("fp-ts/Option"));
|
|
26
|
-
const t = __importStar(require("io-ts"));
|
|
27
|
-
const function_2 = require("../../../validators/function");
|
|
28
|
-
const SliceWidgetContent_1 = require("./SliceWidgetContent");
|
|
29
|
-
exports.SlicesContentType = "SliceContentType";
|
|
1
|
+
import * as A from "fp-ts/Array";
|
|
2
|
+
import { pipe } from "fp-ts/function";
|
|
3
|
+
import * as O from "fp-ts/Option";
|
|
4
|
+
import * as t from "io-ts";
|
|
5
|
+
import { nullable } from "../../../validators/function";
|
|
6
|
+
import { SliceWidgetContent } from "./SliceWidgetContent";
|
|
7
|
+
export const SlicesContentType = "SliceContentType";
|
|
30
8
|
const codec = t.exact(t.intersection([
|
|
31
9
|
t.type({
|
|
32
10
|
key: t.string,
|
|
33
11
|
value: t.unknown,
|
|
34
12
|
}),
|
|
35
13
|
t.partial({
|
|
36
|
-
label:
|
|
14
|
+
label: nullable(t.string),
|
|
37
15
|
}),
|
|
38
16
|
]));
|
|
39
|
-
|
|
17
|
+
export const SlicesContent = {
|
|
40
18
|
itemsCodec: (value, codecWidget) => {
|
|
41
|
-
return
|
|
19
|
+
return pipe(codec.decode(value), O.fromEither, O.chain((r) => {
|
|
42
20
|
const stopIdx = r.key.indexOf("$");
|
|
43
21
|
const name = r.key.substring(0, stopIdx > 0 ? stopIdx : undefined);
|
|
44
22
|
const maybeWidget = codecWidget(name, r.value);
|
|
@@ -55,10 +33,10 @@ exports.SlicesContent = {
|
|
|
55
33
|
fromJson: (key, value, fieldTypes, fieldPositions) => {
|
|
56
34
|
if (fieldTypes.get(key) === "Slices") {
|
|
57
35
|
const jsItems = O.getOrElse(() => new Array())(O.fromEither(t.array(t.unknown).decode(value)));
|
|
58
|
-
const widgetCodec = (name, wValue) =>
|
|
36
|
+
const widgetCodec = (name, wValue) => SliceWidgetContent.fromJson([key], name, wValue, fieldTypes, fieldPositions);
|
|
59
37
|
return O.some({
|
|
60
|
-
value: A.compact(jsItems.map((jsItem) =>
|
|
61
|
-
__TYPE__:
|
|
38
|
+
value: A.compact(jsItems.map((jsItem) => SlicesContent.itemsCodec(jsItem, widgetCodec))),
|
|
39
|
+
__TYPE__: SlicesContentType,
|
|
62
40
|
});
|
|
63
41
|
}
|
|
64
42
|
else {
|
|
@@ -1,17 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
if (k2 === undefined) k2 = k;
|
|
7
|
-
o[k2] = m[k];
|
|
8
|
-
}));
|
|
9
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
-
};
|
|
12
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
__exportStar(require("./CompositeSliceContent"), exports);
|
|
14
|
-
__exportStar(require("./SharedSliceContent"), exports);
|
|
15
|
-
__exportStar(require("./SimpleSliceContent"), exports);
|
|
16
|
-
__exportStar(require("./SlicesContent"), exports);
|
|
17
|
-
__exportStar(require("./SliceWidgetContent"), exports);
|
|
1
|
+
export * from "./CompositeSliceContent";
|
|
2
|
+
export * from "./SharedSliceContent";
|
|
3
|
+
export * from "./SimpleSliceContent";
|
|
4
|
+
export * from "./SlicesContent";
|
|
5
|
+
export * from "./SliceWidgetContent";
|
package/lib/index.js
CHANGED
|
@@ -1,25 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
-
}) : (function(o, m, k, k2) {
|
|
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.Validators = exports.Documents = exports.CustomTypes = void 0;
|
|
23
|
-
exports.CustomTypes = __importStar(require("./customtypes"));
|
|
24
|
-
exports.Documents = __importStar(require("./documents"));
|
|
25
|
-
exports.Validators = __importStar(require("./validators"));
|
|
1
|
+
export * as CustomTypes from "./customtypes";
|
|
2
|
+
export * as Documents from "./documents";
|
|
3
|
+
export * as Validators from "./validators";
|
|
@@ -1,28 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
}) : (function(o, m, k, k2) {
|
|
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
|
-
const Either_1 = require("fp-ts/Either");
|
|
23
|
-
const function_1 = require("fp-ts/function");
|
|
24
|
-
const t = __importStar(require("io-ts"));
|
|
25
|
-
exports.default = new t.Type("dateFromString", (u) => u instanceof Date, (u, c) => (0, function_1.pipe)(t.string.validate(u, c), (0, Either_1.chain)((s) => {
|
|
1
|
+
import { chain } from "fp-ts/Either";
|
|
2
|
+
import { pipe } from "fp-ts/function";
|
|
3
|
+
import * as t from "io-ts";
|
|
4
|
+
export default new t.Type("dateFromString", (u) => u instanceof Date, (u, c) => pipe(t.string.validate(u, c), chain((s) => {
|
|
26
5
|
const d = new Date(s);
|
|
27
6
|
return isNaN(d.getTime()) ? t.failure(u, c) : t.success(d);
|
|
28
7
|
})), (date) => date.toISOString());
|
|
@@ -1,28 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
}) : (function(o, m, k, k2) {
|
|
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
|
-
const Either_1 = require("fp-ts/Either");
|
|
23
|
-
const function_1 = require("fp-ts/function");
|
|
24
|
-
const t = __importStar(require("io-ts"));
|
|
25
|
-
exports.default = new t.Type("dateFromStringOrNumber", (u) => u instanceof Date, (u, c) => (0, function_1.pipe)(t.union([t.number, t.string]).validate(u, c), (0, Either_1.chain)((s) => {
|
|
1
|
+
import { chain } from "fp-ts/Either";
|
|
2
|
+
import { pipe } from "fp-ts/function";
|
|
3
|
+
import * as t from "io-ts";
|
|
4
|
+
export default new t.Type("dateFromStringOrNumber", (u) => u instanceof Date, (u, c) => pipe(t.union([t.number, t.string]).validate(u, c), chain((s) => {
|
|
26
5
|
const d = new Date(s);
|
|
27
6
|
return isNaN(d.getTime()) ? t.failure(u, c) : t.success(d);
|
|
28
7
|
})), (date) => date);
|
|
@@ -1,28 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
}) : (function(o, m, k, k2) {
|
|
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
|
-
const Either_1 = require("fp-ts/Either");
|
|
23
|
-
const function_1 = require("fp-ts/function");
|
|
24
|
-
const t = __importStar(require("io-ts"));
|
|
25
|
-
exports.default = new t.Type("dateFromTsMs", (u) => u instanceof Date, (u, c) => (0, function_1.pipe)(t.number.validate(u, c), (0, Either_1.chain)((s) => {
|
|
1
|
+
import { chain } from "fp-ts/Either";
|
|
2
|
+
import { pipe } from "fp-ts/function";
|
|
3
|
+
import * as t from "io-ts";
|
|
4
|
+
export default new t.Type("dateFromTsMs", (u) => u instanceof Date, (u, c) => pipe(t.number.validate(u, c), chain((s) => {
|
|
26
5
|
const d = new Date(s);
|
|
27
6
|
return isNaN(d.getTime()) ? t.failure(u, c) : t.success(d);
|
|
28
7
|
})), (date) => date.getTime());
|
|
@@ -1,29 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
-
}) : (function(o, m, k, k2) {
|
|
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
|
-
const Either_1 = require("fp-ts/Either");
|
|
23
|
-
const function_1 = require("fp-ts/function");
|
|
24
|
-
const t = __importStar(require("io-ts"));
|
|
1
|
+
import { chain } from "fp-ts/Either";
|
|
2
|
+
import { pipe } from "fp-ts/function";
|
|
3
|
+
import * as t from "io-ts";
|
|
25
4
|
/** A codec that succeeds if a number can be parsed to an integer */
|
|
26
|
-
|
|
5
|
+
export default new t.Type("IntFromNumber", t.Int.is, (u, c) => pipe(t.number.validate(u, c), chain((n) => {
|
|
27
6
|
if (t.Int.is(n))
|
|
28
7
|
return t.success(n);
|
|
29
8
|
else {
|
|
@@ -1,41 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
-
}) : (function(o, m, k, k2) {
|
|
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
|
-
const Either_1 = require("fp-ts/Either");
|
|
23
|
-
const function_1 = require("fp-ts/function");
|
|
24
|
-
const t = __importStar(require("io-ts"));
|
|
1
|
+
import { chain } from "fp-ts/Either";
|
|
2
|
+
import { pipe } from "fp-ts/function";
|
|
3
|
+
import * as t from "io-ts";
|
|
25
4
|
const PixelsRegex = /^([0-9]+)px$/;
|
|
26
5
|
/**
|
|
27
6
|
* A codec that succeeds if a string representing pixels (eg: "200px") can be
|
|
28
7
|
* parsed to an integer
|
|
29
8
|
*/
|
|
30
|
-
|
|
9
|
+
export default new t.Type("IntFromPixels", t.Int.is, (u, c) => pipe(t.string.validate(u, c), chain((strPixels) => {
|
|
31
10
|
try {
|
|
32
11
|
const matched = strPixels.match(PixelsRegex);
|
|
33
12
|
if (!matched)
|
|
34
13
|
return t.failure(u, c);
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
14
|
+
/* eslint-disable @typescript-eslint/no-non-null-assertion */
|
|
15
|
+
const parsed = parseInt(matched[1]);
|
|
16
|
+
return t.success(parsed);
|
|
39
17
|
}
|
|
40
18
|
catch {
|
|
41
19
|
return t.failure(u, c);
|
|
@@ -1,24 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
-
}) : (function(o, m, k, k2) {
|
|
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
|
-
const t = __importStar(require("io-ts"));
|
|
23
|
-
const function_1 = require("./function");
|
|
24
|
-
exports.default = (0, function_1.refineType)(t.string, "nonEmptyString", (s) => s.trim().length > 0);
|
|
1
|
+
import * as t from "io-ts";
|
|
2
|
+
import { refineType } from "./function";
|
|
3
|
+
export default refineType(t.string, "nonEmptyString", (s) => s.trim().length > 0);
|
|
@@ -1,17 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const Either_1 = require("fp-ts/Either");
|
|
7
|
-
const function_1 = require("fp-ts/function");
|
|
8
|
-
const io_ts_1 = require("io-ts");
|
|
9
|
-
const StringOrNull_1 = __importDefault(require("./StringOrNull"));
|
|
10
|
-
exports.default = new io_ts_1.Type("nonEmptyStringOrNull", (u) => typeof u === "string" || u === null, (u, c) => (0, function_1.pipe)(StringOrNull_1.default.validate(u, c), (0, Either_1.chain)((s) => {
|
|
1
|
+
import { chain } from "fp-ts/Either";
|
|
2
|
+
import { pipe } from "fp-ts/function";
|
|
3
|
+
import { success, Type } from "io-ts";
|
|
4
|
+
import StringOrNull from "./StringOrNull";
|
|
5
|
+
export default new Type("nonEmptyStringOrNull", (u) => typeof u === "string" || u === null, (u, c) => pipe(StringOrNull.validate(u, c), chain((s) => {
|
|
11
6
|
if (typeof s === "string" && s.length > 0) {
|
|
12
|
-
return
|
|
7
|
+
return success(s);
|
|
13
8
|
}
|
|
14
9
|
else {
|
|
15
|
-
return
|
|
10
|
+
return success(null);
|
|
16
11
|
}
|
|
17
12
|
})), (s) => s);
|
|
@@ -1,24 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
-
}) : (function(o, m, k, k2) {
|
|
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
|
-
const t = __importStar(require("io-ts"));
|
|
23
|
-
const function_1 = require("./function");
|
|
24
|
-
exports.default = (0, function_1.nullable)(t.number);
|
|
1
|
+
import * as t from "io-ts";
|
|
2
|
+
import { nullable } from "./function";
|
|
3
|
+
export default nullable(t.number);
|
|
@@ -1,28 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
-
}) : (function(o, m, k, k2) {
|
|
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
|
-
const Either_1 = require("fp-ts/Either");
|
|
23
|
-
const function_1 = require("fp-ts/function");
|
|
24
|
-
const t = __importStar(require("io-ts"));
|
|
1
|
+
import { chain } from "fp-ts/Either";
|
|
2
|
+
import { pipe } from "fp-ts/function";
|
|
3
|
+
import * as t from "io-ts";
|
|
25
4
|
/** A codec that validates a Boolean and convert it as a string */
|
|
26
|
-
|
|
5
|
+
export default new t.Type("StringFromInt", t.string.is, (u, c) => pipe(t.boolean.validate(u, c), chain((i) => {
|
|
27
6
|
return t.success(i.toString());
|
|
28
7
|
})), (i) => i);
|
|
@@ -1,28 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
-
}) : (function(o, m, k, k2) {
|
|
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
|
-
const Either_1 = require("fp-ts/Either");
|
|
23
|
-
const function_1 = require("fp-ts/function");
|
|
24
|
-
const t = __importStar(require("io-ts"));
|
|
1
|
+
import { chain } from "fp-ts/Either";
|
|
2
|
+
import { pipe } from "fp-ts/function";
|
|
3
|
+
import * as t from "io-ts";
|
|
25
4
|
/** A codec that validates a number and convert it as a string */
|
|
26
|
-
|
|
5
|
+
export default new t.Type("StringFromInt", t.string.is, (u, c) => pipe(t.number.validate(u, c), chain((i) => {
|
|
27
6
|
return t.success(i.toString());
|
|
28
7
|
})), (i) => i);
|
|
@@ -1,24 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
-
}) : (function(o, m, k, k2) {
|
|
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
|
-
const t = __importStar(require("io-ts"));
|
|
23
|
-
const function_1 = require("./function");
|
|
24
|
-
exports.default = (0, function_1.nullable)(t.string);
|
|
1
|
+
import * as t from "io-ts";
|
|
2
|
+
import { nullable } from "./function";
|
|
3
|
+
export default nullable(t.string);
|