valleyed 4.5.7 → 4.5.9
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/CHANGELOG.md +9 -0
- package/dist/cjs/api/arrays.cjs +88 -0
- package/dist/cjs/api/arrays.cjs.map +1 -0
- package/dist/cjs/api/arrays.min.cjs +2 -0
- package/dist/cjs/api/arrays.min.cjs.map +1 -0
- package/dist/cjs/api/base/errors.cjs +75 -0
- package/dist/cjs/api/base/errors.cjs.map +1 -0
- package/dist/cjs/api/base/errors.min.cjs +3 -0
- package/dist/cjs/api/base/errors.min.cjs.map +1 -0
- package/dist/cjs/api/base/index.cjs +25 -0
- package/dist/cjs/api/base/index.cjs.map +1 -0
- package/dist/cjs/api/base/index.min.cjs +2 -0
- package/dist/cjs/api/base/index.min.cjs.map +1 -0
- package/dist/cjs/api/base/pipes.cjs +120 -0
- package/dist/cjs/api/base/pipes.cjs.map +1 -0
- package/dist/cjs/api/base/pipes.min.cjs +2 -0
- package/dist/cjs/api/base/pipes.min.cjs.map +1 -0
- package/dist/cjs/api/base/types.cjs +17 -0
- package/dist/cjs/api/base/types.cjs.map +1 -0
- package/dist/cjs/api/base/types.min.cjs +2 -0
- package/dist/cjs/api/base/types.min.cjs.map +1 -0
- package/dist/cjs/api/coerce.cjs +41 -0
- package/dist/cjs/api/coerce.cjs.map +1 -0
- package/dist/cjs/api/coerce.min.cjs +2 -0
- package/dist/cjs/api/coerce.min.cjs.map +1 -0
- package/dist/cjs/api/core.cjs +134 -0
- package/dist/cjs/api/core.cjs.map +1 -0
- package/dist/cjs/api/core.min.cjs +2 -0
- package/dist/cjs/api/core.min.cjs.map +1 -0
- package/dist/cjs/api/externals.cjs +45 -0
- package/dist/cjs/api/externals.cjs.map +1 -0
- package/dist/cjs/api/externals.min.cjs +2 -0
- package/dist/cjs/api/externals.min.cjs.map +1 -0
- package/dist/cjs/api/files.cjs +68 -0
- package/dist/cjs/api/files.cjs.map +1 -0
- package/dist/cjs/api/files.min.cjs +2 -0
- package/dist/cjs/api/files.min.cjs.map +1 -0
- package/dist/cjs/api/index.cjs +39 -0
- package/dist/cjs/api/index.cjs.map +1 -0
- package/dist/cjs/api/index.min.cjs +2 -0
- package/dist/cjs/api/index.min.cjs.map +1 -0
- package/dist/cjs/api/junctions.cjs +93 -0
- package/dist/cjs/api/junctions.cjs.map +1 -0
- package/dist/cjs/api/junctions.min.cjs +2 -0
- package/dist/cjs/api/junctions.min.cjs.map +1 -0
- package/dist/cjs/api/numbers.cjs +81 -0
- package/dist/cjs/api/numbers.cjs.map +1 -0
- package/dist/cjs/api/numbers.min.cjs +2 -0
- package/dist/cjs/api/numbers.min.cjs.map +1 -0
- package/dist/cjs/api/optionals.cjs +88 -0
- package/dist/cjs/api/optionals.cjs.map +1 -0
- package/dist/cjs/api/optionals.min.cjs +2 -0
- package/dist/cjs/api/optionals.min.cjs.map +1 -0
- package/dist/cjs/api/records.cjs +112 -0
- package/dist/cjs/api/records.cjs.map +1 -0
- package/dist/cjs/api/records.min.cjs +2 -0
- package/dist/cjs/api/records.min.cjs.map +1 -0
- package/dist/cjs/api/strings.cjs +90 -0
- package/dist/cjs/api/strings.cjs.map +1 -0
- package/dist/cjs/api/strings.min.cjs +2 -0
- package/dist/cjs/api/strings.min.cjs.map +1 -0
- package/dist/cjs/api/times.cjs +68 -0
- package/dist/cjs/api/times.cjs.map +1 -0
- package/dist/cjs/api/times.min.cjs +2 -0
- package/dist/cjs/api/times.min.cjs.map +1 -0
- package/dist/cjs/api/types.cjs +83 -0
- package/dist/cjs/api/types.cjs.map +1 -0
- package/dist/cjs/api/types.min.cjs +2 -0
- package/dist/cjs/api/types.min.cjs.map +1 -0
- package/dist/cjs/index.cjs +53 -0
- package/dist/cjs/index.cjs.map +1 -0
- package/dist/cjs/index.min.cjs +2 -0
- package/dist/cjs/index.min.cjs.map +1 -0
- package/dist/cjs/utils/classes.cjs +100 -0
- package/dist/cjs/utils/classes.cjs.map +1 -0
- package/dist/cjs/utils/classes.min.cjs +2 -0
- package/dist/cjs/utils/classes.min.cjs.map +1 -0
- package/dist/cjs/utils/differ.cjs +131 -0
- package/dist/cjs/utils/differ.cjs.map +1 -0
- package/dist/cjs/utils/differ.min.cjs +2 -0
- package/dist/cjs/utils/differ.min.cjs.map +1 -0
- package/dist/cjs/utils/functions/index.cjs +177 -0
- package/dist/cjs/utils/functions/index.cjs.map +1 -0
- package/dist/cjs/utils/functions/index.min.cjs +2 -0
- package/dist/cjs/utils/functions/index.min.cjs.map +1 -0
- package/dist/cjs/utils/functions/urls/normalize.cjs +93 -0
- package/dist/cjs/utils/functions/urls/normalize.cjs.map +1 -0
- package/dist/cjs/utils/functions/urls/normalize.min.cjs +2 -0
- package/dist/cjs/utils/functions/urls/normalize.min.cjs.map +1 -0
- package/dist/cjs/utils/geohash.cjs +144 -0
- package/dist/cjs/utils/geohash.cjs.map +1 -0
- package/dist/cjs/utils/geohash.min.cjs +2 -0
- package/dist/cjs/utils/geohash.min.cjs.map +1 -0
- package/dist/cjs/utils/regexes.cjs +43 -0
- package/dist/cjs/utils/regexes.cjs.map +1 -0
- package/dist/cjs/utils/regexes.min.cjs +2 -0
- package/dist/cjs/utils/regexes.min.cjs.map +1 -0
- package/dist/cjs/utils/types.cjs +17 -0
- package/dist/cjs/utils/types.cjs.map +1 -0
- package/dist/cjs/utils/types.min.cjs +2 -0
- package/dist/cjs/utils/types.min.cjs.map +1 -0
- package/dist/esm/api/arrays.min.mjs +2 -0
- package/dist/esm/api/arrays.min.mjs.map +1 -0
- package/dist/esm/api/arrays.mjs +62 -0
- package/dist/esm/api/arrays.mjs.map +1 -0
- package/dist/esm/api/base/errors.min.mjs +3 -0
- package/dist/esm/api/base/errors.min.mjs.map +1 -0
- package/dist/esm/api/base/errors.mjs +51 -0
- package/dist/esm/api/base/errors.mjs.map +1 -0
- package/dist/esm/api/base/index.min.mjs +2 -0
- package/dist/esm/api/base/index.min.mjs.map +1 -0
- package/dist/esm/api/base/index.mjs +3 -0
- package/dist/esm/api/base/index.mjs.map +1 -0
- package/dist/esm/api/base/pipes.min.mjs +2 -0
- package/dist/esm/api/base/pipes.min.mjs.map +1 -0
- package/dist/esm/api/base/pipes.mjs +89 -0
- package/dist/esm/api/base/pipes.mjs.map +1 -0
- package/dist/esm/api/base/types.min.mjs +1 -0
- package/dist/esm/api/base/types.min.mjs.map +1 -0
- package/dist/esm/api/base/types.mjs +1 -0
- package/dist/esm/api/base/types.mjs.map +1 -0
- package/dist/esm/api/coerce.min.mjs +2 -0
- package/dist/esm/api/coerce.min.mjs.map +1 -0
- package/dist/esm/api/coerce.mjs +14 -0
- package/dist/esm/api/coerce.mjs.map +1 -0
- package/dist/esm/api/core.min.mjs +2 -0
- package/dist/esm/api/core.min.mjs.map +1 -0
- package/dist/esm/api/core.mjs +102 -0
- package/dist/esm/api/core.mjs.map +1 -0
- package/dist/esm/api/externals.min.mjs +2 -0
- package/dist/esm/api/externals.min.mjs.map +1 -0
- package/dist/esm/api/externals.mjs +13 -0
- package/dist/esm/api/externals.mjs.map +1 -0
- package/dist/esm/api/files.min.mjs +2 -0
- package/dist/esm/api/files.min.mjs.map +1 -0
- package/dist/esm/api/files.mjs +40 -0
- package/dist/esm/api/files.mjs.map +1 -0
- package/dist/esm/api/index.min.mjs +2 -0
- package/dist/esm/api/index.min.mjs.map +1 -0
- package/dist/esm/api/index.mjs +5 -0
- package/dist/esm/api/index.mjs.map +1 -0
- package/dist/esm/api/junctions.min.mjs +2 -0
- package/dist/esm/api/junctions.min.mjs.map +1 -0
- package/dist/esm/api/junctions.mjs +65 -0
- package/dist/esm/api/junctions.mjs.map +1 -0
- package/dist/esm/api/numbers.min.mjs +2 -0
- package/dist/esm/api/numbers.min.mjs.map +1 -0
- package/dist/esm/api/numbers.mjs +52 -0
- package/dist/esm/api/numbers.mjs.map +1 -0
- package/dist/esm/api/optionals.min.mjs +2 -0
- package/dist/esm/api/optionals.min.mjs.map +1 -0
- package/dist/esm/api/optionals.mjs +59 -0
- package/dist/esm/api/optionals.mjs.map +1 -0
- package/dist/esm/api/records.min.mjs +2 -0
- package/dist/esm/api/records.min.mjs.map +1 -0
- package/dist/esm/api/records.mjs +84 -0
- package/dist/esm/api/records.mjs.map +1 -0
- package/dist/esm/api/strings.min.mjs +2 -0
- package/dist/esm/api/strings.min.mjs.map +1 -0
- package/dist/esm/api/strings.mjs +48 -0
- package/dist/esm/api/strings.mjs.map +1 -0
- package/dist/esm/api/times.min.mjs +2 -0
- package/dist/esm/api/times.min.mjs.map +1 -0
- package/dist/esm/api/times.mjs +40 -0
- package/dist/esm/api/times.mjs.map +1 -0
- package/dist/esm/api/types.min.mjs +2 -0
- package/dist/esm/api/types.min.mjs.map +1 -0
- package/dist/esm/api/types.mjs +53 -0
- package/dist/esm/api/types.mjs.map +1 -0
- package/dist/esm/index.min.mjs +2 -0
- package/dist/esm/index.min.mjs.map +1 -0
- package/dist/esm/index.mjs +12 -0
- package/dist/esm/index.mjs.map +1 -0
- package/dist/esm/utils/classes.min.mjs +2 -0
- package/dist/esm/utils/classes.min.mjs.map +1 -0
- package/dist/esm/utils/classes.mjs +66 -0
- package/dist/esm/utils/classes.mjs.map +1 -0
- package/dist/esm/utils/differ.min.mjs +2 -0
- package/dist/esm/utils/differ.min.mjs.map +1 -0
- package/dist/esm/utils/differ.mjs +104 -0
- package/dist/esm/utils/differ.mjs.map +1 -0
- package/dist/esm/utils/functions/index.min.mjs +2 -0
- package/dist/esm/utils/functions/index.min.mjs.map +1 -0
- package/dist/esm/utils/functions/index.mjs +136 -0
- package/dist/esm/utils/functions/index.mjs.map +1 -0
- package/dist/esm/utils/functions/urls/normalize.min.mjs +2 -0
- package/dist/esm/utils/functions/urls/normalize.min.mjs.map +1 -0
- package/dist/esm/utils/functions/urls/normalize.mjs +69 -0
- package/dist/esm/utils/functions/urls/normalize.mjs.map +1 -0
- package/dist/esm/utils/geohash.min.mjs +2 -0
- package/dist/esm/utils/geohash.min.mjs.map +1 -0
- package/dist/esm/utils/geohash.mjs +118 -0
- package/dist/esm/utils/geohash.mjs.map +1 -0
- package/dist/esm/utils/regexes.min.mjs +2 -0
- package/dist/esm/utils/regexes.min.mjs.map +1 -0
- package/dist/esm/utils/regexes.mjs +8 -0
- package/dist/esm/utils/regexes.mjs.map +1 -0
- package/dist/esm/utils/types.min.mjs +1 -0
- package/dist/esm/utils/types.min.mjs.map +1 -0
- package/dist/esm/utils/types.mjs +1 -0
- package/dist/esm/utils/types.mjs.map +1 -0
- package/dist/types/api/arrays.d.ts +10 -0
- package/dist/types/api/arrays.js +61 -0
- package/dist/types/api/base/errors.d.ts +20 -0
- package/dist/types/api/base/errors.js +50 -0
- package/dist/types/api/base/index.d.ts +5 -0
- package/dist/types/api/base/index.js +2 -0
- package/dist/types/api/base/pipes.d.ts +28 -0
- package/dist/types/api/base/pipes.js +88 -0
- package/dist/types/api/base/types.d.ts +4 -0
- package/dist/types/api/base/types.js +0 -0
- package/dist/types/api/coerce.d.ts +11 -0
- package/dist/types/api/coerce.js +13 -0
- package/dist/types/api/core.d.ts +22 -0
- package/dist/types/api/core.js +101 -0
- package/dist/types/api/externals.d.ts +16 -0
- package/dist/types/api/externals.js +12 -0
- package/dist/types/api/files.d.ts +15 -0
- package/dist/types/api/files.js +39 -0
- package/dist/types/api/index.d.ts +87 -0
- package/dist/types/api/index.js +4 -0
- package/dist/types/api/junctions.d.ts +12 -0
- package/dist/types/api/junctions.js +64 -0
- package/dist/types/api/numbers.d.ts +13 -0
- package/dist/types/api/numbers.js +51 -0
- package/dist/types/api/optionals.d.ts +14 -0
- package/dist/types/api/optionals.js +58 -0
- package/dist/types/api/records.d.ts +17 -0
- package/dist/types/api/records.js +83 -0
- package/dist/types/api/strings.d.ts +16 -0
- package/dist/types/api/strings.js +47 -0
- package/dist/types/api/times.d.ts +4 -0
- package/dist/types/api/times.js +39 -0
- package/dist/types/api/types.d.ts +14 -0
- package/dist/types/api/types.js +52 -0
- package/dist/types/differ-oxbwYLvl.d.ts +14 -0
- package/dist/types/geohash-BCD6jCDO.d.ts +21 -0
- package/dist/types/index.d.ts +20 -0
- package/dist/types/index.js +11 -0
- package/dist/types/types-jAKLLJny.d.ts +56 -0
- package/dist/types/utils/classes.d.ts +18 -0
- package/dist/types/utils/classes.js +65 -0
- package/dist/types/utils/differ.d.ts +1 -0
- package/dist/types/utils/differ.js +103 -0
- package/dist/types/utils/functions/index.d.ts +27 -0
- package/dist/types/utils/functions/index.js +135 -0
- package/dist/types/utils/functions/urls/normalize.d.ts +3 -0
- package/dist/types/utils/functions/urls/normalize.js +68 -0
- package/dist/types/utils/geohash.d.ts +1 -0
- package/dist/types/utils/geohash.js +117 -0
- package/dist/types/utils/regexes.d.ts +4 -0
- package/dist/types/utils/regexes.js +7 -0
- package/dist/types/utils/types.d.ts +71 -0
- package/dist/types/utils/types.js +0 -0
- package/package.json +4 -4
- package/dist/index.cjs +0 -1276
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
### [4.5.9](https://github.com/kevinand11/valleyed/compare/v4.5.8...v4.5.9) (2025-06-27)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* do not bundle ([bbeff07](https://github.com/kevinand11/valleyed/commit/bbeff07ed071ef316db0172557c7ff59d1336cbe))
|
|
11
|
+
|
|
12
|
+
### [4.5.8](https://github.com/kevinand11/valleyed/compare/v4.5.7...v4.5.8) (2025-06-26)
|
|
13
|
+
|
|
5
14
|
### [4.5.7](https://github.com/kevinand11/valleyed/compare/v4.5.6...v4.5.7) (2025-06-26)
|
|
6
15
|
|
|
7
16
|
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var arrays_exports = {};
|
|
20
|
+
__export(arrays_exports, {
|
|
21
|
+
array: () => array,
|
|
22
|
+
asSet: () => asSet,
|
|
23
|
+
tuple: () => tuple
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(arrays_exports);
|
|
26
|
+
var import_base = require('./base/index.cjs');
|
|
27
|
+
var import_pipes = require('./base/pipes.cjs');
|
|
28
|
+
const array = (pipeSchema, err = "is not an array") => (0, import_pipes.pipe)(
|
|
29
|
+
(input) => {
|
|
30
|
+
if (!Array.isArray(input)) throw import_base.PipeError.root(err, input);
|
|
31
|
+
if (input.length === 0) return input;
|
|
32
|
+
const res = input.map((i, idx) => {
|
|
33
|
+
const validity = (0, import_pipes.validate)(pipeSchema, i);
|
|
34
|
+
if (!validity.valid) return import_base.PipeError.path(idx, validity.error, i);
|
|
35
|
+
return validity.value;
|
|
36
|
+
});
|
|
37
|
+
if (res.some((r) => r instanceof import_base.PipeError))
|
|
38
|
+
throw import_base.PipeError.rootFrom(
|
|
39
|
+
res.filter((r) => r instanceof import_base.PipeError),
|
|
40
|
+
input
|
|
41
|
+
);
|
|
42
|
+
return res;
|
|
43
|
+
},
|
|
44
|
+
{ schema: () => ({ type: "array", items: (0, import_pipes.schema)(pipeSchema) }) }
|
|
45
|
+
);
|
|
46
|
+
const tuple = (pipes, err = "is not an array") => (0, import_pipes.pipe)(
|
|
47
|
+
(input) => {
|
|
48
|
+
if (!Array.isArray(input)) throw import_base.PipeError.root(err, input);
|
|
49
|
+
if (pipes.length === 0) return input;
|
|
50
|
+
const res = pipes.map((pipe2, idx) => {
|
|
51
|
+
const validitity = (0, import_pipes.validate)(pipe2, input[idx]);
|
|
52
|
+
if ("error" in validitity) return import_base.PipeError.path(idx, validitity.error, input[idx]);
|
|
53
|
+
return validitity.value;
|
|
54
|
+
});
|
|
55
|
+
if (res.some((r) => r instanceof import_base.PipeError))
|
|
56
|
+
throw import_base.PipeError.rootFrom(
|
|
57
|
+
res.filter((r) => r instanceof import_base.PipeError),
|
|
58
|
+
input
|
|
59
|
+
);
|
|
60
|
+
return res;
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
schema: () => ({
|
|
64
|
+
type: "array",
|
|
65
|
+
items: pipes.map((pipe2) => (0, import_pipes.schema)(pipe2)),
|
|
66
|
+
minItems: pipes.length,
|
|
67
|
+
maxItems: pipes.length
|
|
68
|
+
})
|
|
69
|
+
}
|
|
70
|
+
);
|
|
71
|
+
const asSet = (keyFn = (v) => v) => (0, import_pipes.pipe)((input) => {
|
|
72
|
+
const obj = {};
|
|
73
|
+
return input.reduce((acc, cur) => {
|
|
74
|
+
const key = keyFn(cur);
|
|
75
|
+
if (!obj[key]) {
|
|
76
|
+
obj[key] = true;
|
|
77
|
+
acc.push(cur);
|
|
78
|
+
}
|
|
79
|
+
return acc;
|
|
80
|
+
}, []);
|
|
81
|
+
});
|
|
82
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
83
|
+
0 && (module.exports = {
|
|
84
|
+
array,
|
|
85
|
+
asSet,
|
|
86
|
+
tuple
|
|
87
|
+
});
|
|
88
|
+
//# sourceMappingURL=arrays.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/api/arrays.ts"],"sourcesContent":["import { PipeError, PipeInput, type Pipe, type PipeOutput } from './base'\nimport { pipe, schema, validate } from './base/pipes'\n\nexport const array = <T extends Pipe<any, any, any>>(pipeSchema: T, err = 'is not an array') =>\n\tpipe<PipeInput<T>[], PipeOutput<T>[], any>(\n\t\t(input: unknown) => {\n\t\t\tif (!Array.isArray(input)) throw PipeError.root(err, input)\n\t\t\tif (input.length === 0) return input\n\t\t\tconst res = input.map((i, idx) => {\n\t\t\t\tconst validity = validate(pipeSchema, i)\n\t\t\t\tif (!validity.valid) return PipeError.path(idx, validity.error, i)\n\t\t\t\treturn validity.value\n\t\t\t})\n\t\t\tif (res.some((r) => r instanceof PipeError))\n\t\t\t\tthrow PipeError.rootFrom(\n\t\t\t\t\tres.filter((r) => r instanceof PipeError),\n\t\t\t\t\tinput,\n\t\t\t\t)\n\t\t\treturn res\n\t\t},\n\t\t{ schema: () => ({ type: 'array', items: schema(pipeSchema) }) },\n\t)\n\nexport const tuple = <T extends ReadonlyArray<Pipe<any, any, any>>>(pipes: readonly [...T], err = 'is not an array') =>\n\tpipe<{ [K in keyof T]: PipeInput<T[K]> }, { [K in keyof T]: PipeOutput<T[K]> }, any>(\n\t\t(input: unknown) => {\n\t\t\tif (!Array.isArray(input)) throw PipeError.root(err, input)\n\t\t\tif (pipes.length === 0) return input as any\n\t\t\tconst res = pipes.map((pipe, idx) => {\n\t\t\t\tconst validitity = validate(pipe, input[idx])\n\t\t\t\tif ('error' in validitity) return PipeError.path(idx, validitity.error, input[idx])\n\t\t\t\treturn validitity.value\n\t\t\t})\n\t\t\tif (res.some((r) => r instanceof PipeError))\n\t\t\t\tthrow PipeError.rootFrom(\n\t\t\t\t\tres.filter((r) => r instanceof PipeError),\n\t\t\t\t\tinput,\n\t\t\t\t)\n\t\t\treturn res\n\t\t},\n\t\t{\n\t\t\tschema: () => ({\n\t\t\t\ttype: 'array',\n\t\t\t\titems: pipes.map((pipe) => schema(pipe)),\n\t\t\t\tminItems: pipes.length,\n\t\t\t\tmaxItems: pipes.length,\n\t\t\t}),\n\t\t},\n\t)\n\nexport const asSet = <T>(keyFn: (i: T) => PropertyKey = (v) => v as string) =>\n\tpipe<T[], T[], any>((input) => {\n\t\tconst obj: Record<PropertyKey, boolean> = {}\n\t\treturn input.reduce<T[]>((acc, cur) => {\n\t\t\tconst key = keyFn(cur)\n\t\t\tif (!obj[key]) {\n\t\t\t\tobj[key] = true\n\t\t\t\tacc.push(cur)\n\t\t\t}\n\t\t\treturn acc\n\t\t}, [])\n\t})\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiE;AACjE,mBAAuC;AAEhC,MAAM,QAAQ,CAAgC,YAAe,MAAM,0BACzE;AAAA,EACC,CAAC,UAAmB;AACnB,QAAI,CAAC,MAAM,QAAQ,KAAK,EAAG,OAAM,sBAAU,KAAK,KAAK,KAAK;AAC1D,QAAI,MAAM,WAAW,EAAG,QAAO;AAC/B,UAAM,MAAM,MAAM,IAAI,CAAC,GAAG,QAAQ;AACjC,YAAM,eAAW,uBAAS,YAAY,CAAC;AACvC,UAAI,CAAC,SAAS,MAAO,QAAO,sBAAU,KAAK,KAAK,SAAS,OAAO,CAAC;AACjE,aAAO,SAAS;AAAA,IACjB,CAAC;AACD,QAAI,IAAI,KAAK,CAAC,MAAM,aAAa,qBAAS;AACzC,YAAM,sBAAU;AAAA,QACf,IAAI,OAAO,CAAC,MAAM,aAAa,qBAAS;AAAA,QACxC;AAAA,MACD;AACD,WAAO;AAAA,EACR;AAAA,EACA,EAAE,QAAQ,OAAO,EAAE,MAAM,SAAS,WAAO,qBAAO,UAAU,EAAE,GAAG;AAChE;AAEM,MAAM,QAAQ,CAA+C,OAAwB,MAAM,0BACjG;AAAA,EACC,CAAC,UAAmB;AACnB,QAAI,CAAC,MAAM,QAAQ,KAAK,EAAG,OAAM,sBAAU,KAAK,KAAK,KAAK;AAC1D,QAAI,MAAM,WAAW,EAAG,QAAO;AAC/B,UAAM,MAAM,MAAM,IAAI,CAACA,OAAM,QAAQ;AACpC,YAAM,iBAAa,uBAASA,OAAM,MAAM,GAAG,CAAC;AAC5C,UAAI,WAAW,WAAY,QAAO,sBAAU,KAAK,KAAK,WAAW,OAAO,MAAM,GAAG,CAAC;AAClF,aAAO,WAAW;AAAA,IACnB,CAAC;AACD,QAAI,IAAI,KAAK,CAAC,MAAM,aAAa,qBAAS;AACzC,YAAM,sBAAU;AAAA,QACf,IAAI,OAAO,CAAC,MAAM,aAAa,qBAAS;AAAA,QACxC;AAAA,MACD;AACD,WAAO;AAAA,EACR;AAAA,EACA;AAAA,IACC,QAAQ,OAAO;AAAA,MACd,MAAM;AAAA,MACN,OAAO,MAAM,IAAI,CAACA,cAAS,qBAAOA,KAAI,CAAC;AAAA,MACvC,UAAU,MAAM;AAAA,MAChB,UAAU,MAAM;AAAA,IACjB;AAAA,EACD;AACD;AAEM,MAAM,QAAQ,CAAI,QAA+B,CAAC,MAAM,UAC9D,mBAAoB,CAAC,UAAU;AAC9B,QAAM,MAAoC,CAAC;AAC3C,SAAO,MAAM,OAAY,CAAC,KAAK,QAAQ;AACtC,UAAM,MAAM,MAAM,GAAG;AACrB,QAAI,CAAC,IAAI,GAAG,GAAG;AACd,UAAI,GAAG,IAAI;AACX,UAAI,KAAK,GAAG;AAAA,IACb;AACA,WAAO;AAAA,EACR,GAAG,CAAC,CAAC;AACN,CAAC;","names":["pipe"]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var f=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var l=Object.getOwnPropertyNames;var p=Object.prototype.hasOwnProperty;var u=(t,n)=>{for(var r in n)f(t,r,{get:n[r],enumerable:!0})},T=(t,n,r,o)=>{if(n&&typeof n=="object"||typeof n=="function")for(let e of l(n))!p.call(t,e)&&e!==r&&f(t,e,{get:()=>n[e],enumerable:!(o=m(n,e))||o.enumerable});return t};var c=t=>T(f({},"__esModule",{value:!0}),t);var v={};u(v,{array:()=>h,asSet:()=>d,tuple:()=>P});module.exports=c(v);var a=require('./base/index.min.cjs'),y=require('./base/pipes.min.cjs');const h=(t,n="is not an array")=>(0,y.pipe)(r=>{if(!Array.isArray(r))throw a.PipeError.root(n,r);if(r.length===0)return r;const o=r.map((e,s)=>{const i=(0,y.validate)(t,e);return i.valid?i.value:a.PipeError.path(s,i.error,e)});if(o.some(e=>e instanceof a.PipeError))throw a.PipeError.rootFrom(o.filter(e=>e instanceof a.PipeError),r);return o},{schema:()=>({type:"array",items:(0,y.schema)(t)})}),P=(t,n="is not an array")=>(0,y.pipe)(r=>{if(!Array.isArray(r))throw a.PipeError.root(n,r);if(t.length===0)return r;const o=t.map((e,s)=>{const i=(0,y.validate)(e,r[s]);return"error"in i?a.PipeError.path(s,i.error,r[s]):i.value});if(o.some(e=>e instanceof a.PipeError))throw a.PipeError.rootFrom(o.filter(e=>e instanceof a.PipeError),r);return o},{schema:()=>({type:"array",items:t.map(r=>(0,y.schema)(r)),minItems:t.length,maxItems:t.length})}),d=(t=n=>n)=>(0,y.pipe)(n=>{const r={};return n.reduce((o,e)=>{const s=t(e);return r[s]||(r[s]=!0,o.push(e)),o},[])});0&&(module.exports={array,asSet,tuple});
|
|
2
|
+
//# sourceMappingURL=arrays.min.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/api/arrays.ts"],"sourcesContent":["import { PipeError, PipeInput, type Pipe, type PipeOutput } from './base'\nimport { pipe, schema, validate } from './base/pipes'\n\nexport const array = <T extends Pipe<any, any, any>>(pipeSchema: T, err = 'is not an array') =>\n\tpipe<PipeInput<T>[], PipeOutput<T>[], any>(\n\t\t(input: unknown) => {\n\t\t\tif (!Array.isArray(input)) throw PipeError.root(err, input)\n\t\t\tif (input.length === 0) return input\n\t\t\tconst res = input.map((i, idx) => {\n\t\t\t\tconst validity = validate(pipeSchema, i)\n\t\t\t\tif (!validity.valid) return PipeError.path(idx, validity.error, i)\n\t\t\t\treturn validity.value\n\t\t\t})\n\t\t\tif (res.some((r) => r instanceof PipeError))\n\t\t\t\tthrow PipeError.rootFrom(\n\t\t\t\t\tres.filter((r) => r instanceof PipeError),\n\t\t\t\t\tinput,\n\t\t\t\t)\n\t\t\treturn res\n\t\t},\n\t\t{ schema: () => ({ type: 'array', items: schema(pipeSchema) }) },\n\t)\n\nexport const tuple = <T extends ReadonlyArray<Pipe<any, any, any>>>(pipes: readonly [...T], err = 'is not an array') =>\n\tpipe<{ [K in keyof T]: PipeInput<T[K]> }, { [K in keyof T]: PipeOutput<T[K]> }, any>(\n\t\t(input: unknown) => {\n\t\t\tif (!Array.isArray(input)) throw PipeError.root(err, input)\n\t\t\tif (pipes.length === 0) return input as any\n\t\t\tconst res = pipes.map((pipe, idx) => {\n\t\t\t\tconst validitity = validate(pipe, input[idx])\n\t\t\t\tif ('error' in validitity) return PipeError.path(idx, validitity.error, input[idx])\n\t\t\t\treturn validitity.value\n\t\t\t})\n\t\t\tif (res.some((r) => r instanceof PipeError))\n\t\t\t\tthrow PipeError.rootFrom(\n\t\t\t\t\tres.filter((r) => r instanceof PipeError),\n\t\t\t\t\tinput,\n\t\t\t\t)\n\t\t\treturn res\n\t\t},\n\t\t{\n\t\t\tschema: () => ({\n\t\t\t\ttype: 'array',\n\t\t\t\titems: pipes.map((pipe) => schema(pipe)),\n\t\t\t\tminItems: pipes.length,\n\t\t\t\tmaxItems: pipes.length,\n\t\t\t}),\n\t\t},\n\t)\n\nexport const asSet = <T>(keyFn: (i: T) => PropertyKey = (v) => v as string) =>\n\tpipe<T[], T[], any>((input) => {\n\t\tconst obj: Record<PropertyKey, boolean> = {}\n\t\treturn input.reduce<T[]>((acc, cur) => {\n\t\t\tconst key = keyFn(cur)\n\t\t\tif (!obj[key]) {\n\t\t\t\tobj[key] = true\n\t\t\t\tacc.push(cur)\n\t\t\t}\n\t\t\treturn acc\n\t\t}, [])\n\t})\n"],"mappings":"yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,WAAAE,EAAA,UAAAC,EAAA,UAAAC,IAAA,eAAAC,EAAAL,GAAA,IAAAM,EAAiE,kBACjEC,EAAuC,wBAEhC,MAAML,EAAQ,CAAgCM,EAAeC,EAAM,uBACzE,QACEC,GAAmB,CACnB,GAAI,CAAC,MAAM,QAAQA,CAAK,EAAG,MAAM,YAAU,KAAKD,EAAKC,CAAK,EAC1D,GAAIA,EAAM,SAAW,EAAG,OAAOA,EAC/B,MAAMC,EAAMD,EAAM,IAAI,CAACE,EAAGC,IAAQ,CACjC,MAAMC,KAAW,YAASN,EAAYI,CAAC,EACvC,OAAKE,EAAS,MACPA,EAAS,MADY,YAAU,KAAKD,EAAKC,EAAS,MAAOF,CAAC,CAElE,CAAC,EACD,GAAID,EAAI,KAAMI,GAAMA,aAAa,WAAS,EACzC,MAAM,YAAU,SACfJ,EAAI,OAAQI,GAAMA,aAAa,WAAS,EACxCL,CACD,EACD,OAAOC,CACR,EACA,CAAE,OAAQ,KAAO,CAAE,KAAM,QAAS,SAAO,UAAOH,CAAU,CAAE,EAAG,CAChE,EAEYJ,EAAQ,CAA+CY,EAAwBP,EAAM,uBACjG,QACEC,GAAmB,CACnB,GAAI,CAAC,MAAM,QAAQA,CAAK,EAAG,MAAM,YAAU,KAAKD,EAAKC,CAAK,EAC1D,GAAIM,EAAM,SAAW,EAAG,OAAON,EAC/B,MAAMC,EAAMK,EAAM,IAAI,CAACC,EAAMJ,IAAQ,CACpC,MAAMK,KAAa,YAASD,EAAMP,EAAMG,CAAG,CAAC,EAC5C,MAAI,UAAWK,EAAmB,YAAU,KAAKL,EAAKK,EAAW,MAAOR,EAAMG,CAAG,CAAC,EAC3EK,EAAW,KACnB,CAAC,EACD,GAAIP,EAAI,KAAMI,GAAMA,aAAa,WAAS,EACzC,MAAM,YAAU,SACfJ,EAAI,OAAQI,GAAMA,aAAa,WAAS,EACxCL,CACD,EACD,OAAOC,CACR,EACA,CACC,OAAQ,KAAO,CACd,KAAM,QACN,MAAOK,EAAM,IAAKC,MAAS,UAAOA,CAAI,CAAC,EACvC,SAAUD,EAAM,OAChB,SAAUA,EAAM,MACjB,EACD,CACD,EAEYb,EAAQ,CAAIgB,EAAgCC,GAAMA,OAC9D,QAAqBV,GAAU,CAC9B,MAAMW,EAAoC,CAAC,EAC3C,OAAOX,EAAM,OAAY,CAACY,EAAKC,IAAQ,CACtC,MAAMC,EAAML,EAAMI,CAAG,EACrB,OAAKF,EAAIG,CAAG,IACXH,EAAIG,CAAG,EAAI,GACXF,EAAI,KAAKC,CAAG,GAEND,CACR,EAAG,CAAC,CAAC,CACN,CAAC","names":["arrays_exports","__export","array","asSet","tuple","__toCommonJS","import_base","import_pipes","pipeSchema","err","input","res","i","idx","validity","r","pipes","pipe","validitity","keyFn","v","obj","acc","cur","key"]}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var errors_exports = {};
|
|
20
|
+
__export(errors_exports, {
|
|
21
|
+
PipeError: () => PipeError
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(errors_exports);
|
|
24
|
+
function flatArray(arr) {
|
|
25
|
+
return Array.isArray(arr) ? arr : [arr];
|
|
26
|
+
}
|
|
27
|
+
function formatError(message) {
|
|
28
|
+
return `${message.path ? `${message.path}: ` : ""}${message.message}`;
|
|
29
|
+
}
|
|
30
|
+
class PipeError extends Error {
|
|
31
|
+
constructor(messages, value, stopped, cause) {
|
|
32
|
+
const message = messages[0];
|
|
33
|
+
super(message ? formatError(message) : "Pipe validation error", { cause });
|
|
34
|
+
this.messages = messages;
|
|
35
|
+
this.value = value;
|
|
36
|
+
this.stopped = stopped;
|
|
37
|
+
}
|
|
38
|
+
toString() {
|
|
39
|
+
return this.messages.map(formatError).join("\n");
|
|
40
|
+
}
|
|
41
|
+
static root(messages, value, cause) {
|
|
42
|
+
return new PipeError(
|
|
43
|
+
flatArray(messages).map((message) => ({ message })),
|
|
44
|
+
value,
|
|
45
|
+
false,
|
|
46
|
+
cause
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
static rootFrom(errors, value, cause) {
|
|
50
|
+
return new PipeError(
|
|
51
|
+
flatArray(errors).flatMap((error) => error.messages),
|
|
52
|
+
value,
|
|
53
|
+
false,
|
|
54
|
+
cause
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
static path(path, errors, value, cause) {
|
|
58
|
+
return new PipeError(
|
|
59
|
+
flatArray(errors).flatMap(
|
|
60
|
+
(error) => error.messages.map((message) => ({ ...message, path: `${path.toString()}${message.path ? `.${message.path}` : ""}` }))
|
|
61
|
+
),
|
|
62
|
+
value,
|
|
63
|
+
false,
|
|
64
|
+
cause
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
static stop(value) {
|
|
68
|
+
return new PipeError([], value, true);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
72
|
+
0 && (module.exports = {
|
|
73
|
+
PipeError
|
|
74
|
+
});
|
|
75
|
+
//# sourceMappingURL=errors.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/api/base/errors.ts"],"sourcesContent":["type Arrayable<T> = T | T[]\n\nfunction flatArray<T>(arr: Arrayable<T>): T[] {\n\treturn Array.isArray(arr) ? arr : [arr]\n}\n\nfunction formatError(message: { message: string; path?: string }) {\n\treturn `${message.path ? `${message.path}: ` : ''}${message.message}`\n}\n\nexport class PipeError extends Error {\n\tconstructor(\n\t\tpublic messages: { message: string; path?: string }[],\n\t\treadonly value: unknown,\n\t\treadonly stopped: boolean,\n\t\tcause?: unknown,\n\t) {\n\t\tconst message = messages[0]\n\t\tsuper(message ? formatError(message) : 'Pipe validation error', { cause })\n\t}\n\n\ttoString() {\n\t\treturn this.messages.map(formatError).join('\\n')\n\t}\n\n\tstatic root(messages: Arrayable<string>, value: unknown, cause?: unknown) {\n\t\treturn new PipeError(\n\t\t\tflatArray(messages).map((message) => ({ message })),\n\t\t\tvalue,\n\t\t\tfalse,\n\t\t\tcause,\n\t\t)\n\t}\n\n\tstatic rootFrom(errors: Arrayable<PipeError>, value: unknown, cause?: unknown) {\n\t\treturn new PipeError(\n\t\t\tflatArray(errors).flatMap((error) => error.messages),\n\t\t\tvalue,\n\t\t\tfalse,\n\t\t\tcause,\n\t\t)\n\t}\n\n\tstatic path(path: PropertyKey, errors: Arrayable<PipeError>, value: unknown, cause?: unknown) {\n\t\treturn new PipeError(\n\t\t\tflatArray(errors).flatMap((error) =>\n\t\t\t\terror.messages.map((message) => ({ ...message, path: `${path.toString()}${message.path ? `.${message.path}` : ''}` })),\n\t\t\t),\n\t\t\tvalue,\n\t\t\tfalse,\n\t\t\tcause,\n\t\t)\n\t}\n\n\tstatic stop(value: unknown) {\n\t\treturn new PipeError([], value, true)\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,SAAS,UAAa,KAAwB;AAC7C,SAAO,MAAM,QAAQ,GAAG,IAAI,MAAM,CAAC,GAAG;AACvC;AAEA,SAAS,YAAY,SAA6C;AACjE,SAAO,GAAG,QAAQ,OAAO,GAAG,QAAQ,IAAI,OAAO,EAAE,GAAG,QAAQ,OAAO;AACpE;AAEO,MAAM,kBAAkB,MAAM;AAAA,EACpC,YACQ,UACE,OACA,SACT,OACC;AACD,UAAM,UAAU,SAAS,CAAC;AAC1B,UAAM,UAAU,YAAY,OAAO,IAAI,yBAAyB,EAAE,MAAM,CAAC;AANlE;AACE;AACA;AAAA,EAKV;AAAA,EAEA,WAAW;AACV,WAAO,KAAK,SAAS,IAAI,WAAW,EAAE,KAAK,IAAI;AAAA,EAChD;AAAA,EAEA,OAAO,KAAK,UAA6B,OAAgB,OAAiB;AACzE,WAAO,IAAI;AAAA,MACV,UAAU,QAAQ,EAAE,IAAI,CAAC,aAAa,EAAE,QAAQ,EAAE;AAAA,MAClD;AAAA,MACA;AAAA,MACA;AAAA,IACD;AAAA,EACD;AAAA,EAEA,OAAO,SAAS,QAA8B,OAAgB,OAAiB;AAC9E,WAAO,IAAI;AAAA,MACV,UAAU,MAAM,EAAE,QAAQ,CAAC,UAAU,MAAM,QAAQ;AAAA,MACnD;AAAA,MACA;AAAA,MACA;AAAA,IACD;AAAA,EACD;AAAA,EAEA,OAAO,KAAK,MAAmB,QAA8B,OAAgB,OAAiB;AAC7F,WAAO,IAAI;AAAA,MACV,UAAU,MAAM,EAAE;AAAA,QAAQ,CAAC,UAC1B,MAAM,SAAS,IAAI,CAAC,aAAa,EAAE,GAAG,SAAS,MAAM,GAAG,KAAK,SAAS,CAAC,GAAG,QAAQ,OAAO,IAAI,QAAQ,IAAI,KAAK,EAAE,GAAG,EAAE;AAAA,MACtH;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACD;AAAA,EACD;AAAA,EAEA,OAAO,KAAK,OAAgB;AAC3B,WAAO,IAAI,UAAU,CAAC,GAAG,OAAO,IAAI;AAAA,EACrC;AACD;","names":[]}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
"use strict";var i=Object.defineProperty;var y=Object.getOwnPropertyDescriptor;var c=Object.getOwnPropertyNames;var g=Object.prototype.hasOwnProperty;var f=(n,a)=>{for(var r in a)i(n,r,{get:a[r],enumerable:!0})},h=(n,a,r,e)=>{if(a&&typeof a=="object"||typeof a=="function")for(let t of c(a))!g.call(n,t)&&t!==r&&i(n,t,{get:()=>a[t],enumerable:!(e=y(a,t))||e.enumerable});return n};var k=n=>h(i({},"__esModule",{value:!0}),n);var m={};f(m,{PipeError:()=>s});module.exports=k(m);function l(n){return Array.isArray(n)?n:[n]}function w(n){return`${n.path?`${n.path}: `:""}${n.message}`}class s extends Error{constructor(r,e,t,o){const u=r[0];super(u?w(u):"Pipe validation error",{cause:o});this.messages=r;this.value=e;this.stopped=t}toString(){return this.messages.map(w).join(`
|
|
2
|
+
`)}static root(r,e,t){return new s(l(r).map(o=>({message:o})),e,!1,t)}static rootFrom(r,e,t){return new s(l(r).flatMap(o=>o.messages),e,!1,t)}static path(r,e,t,o){return new s(l(e).flatMap(u=>u.messages.map(p=>({...p,path:`${r.toString()}${p.path?`.${p.path}`:""}`}))),t,!1,o)}static stop(r){return new s([],r,!0)}}0&&(module.exports={PipeError});
|
|
3
|
+
//# sourceMappingURL=errors.min.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/api/base/errors.ts"],"sourcesContent":["type Arrayable<T> = T | T[]\n\nfunction flatArray<T>(arr: Arrayable<T>): T[] {\n\treturn Array.isArray(arr) ? arr : [arr]\n}\n\nfunction formatError(message: { message: string; path?: string }) {\n\treturn `${message.path ? `${message.path}: ` : ''}${message.message}`\n}\n\nexport class PipeError extends Error {\n\tconstructor(\n\t\tpublic messages: { message: string; path?: string }[],\n\t\treadonly value: unknown,\n\t\treadonly stopped: boolean,\n\t\tcause?: unknown,\n\t) {\n\t\tconst message = messages[0]\n\t\tsuper(message ? formatError(message) : 'Pipe validation error', { cause })\n\t}\n\n\ttoString() {\n\t\treturn this.messages.map(formatError).join('\\n')\n\t}\n\n\tstatic root(messages: Arrayable<string>, value: unknown, cause?: unknown) {\n\t\treturn new PipeError(\n\t\t\tflatArray(messages).map((message) => ({ message })),\n\t\t\tvalue,\n\t\t\tfalse,\n\t\t\tcause,\n\t\t)\n\t}\n\n\tstatic rootFrom(errors: Arrayable<PipeError>, value: unknown, cause?: unknown) {\n\t\treturn new PipeError(\n\t\t\tflatArray(errors).flatMap((error) => error.messages),\n\t\t\tvalue,\n\t\t\tfalse,\n\t\t\tcause,\n\t\t)\n\t}\n\n\tstatic path(path: PropertyKey, errors: Arrayable<PipeError>, value: unknown, cause?: unknown) {\n\t\treturn new PipeError(\n\t\t\tflatArray(errors).flatMap((error) =>\n\t\t\t\terror.messages.map((message) => ({ ...message, path: `${path.toString()}${message.path ? `.${message.path}` : ''}` })),\n\t\t\t),\n\t\t\tvalue,\n\t\t\tfalse,\n\t\t\tcause,\n\t\t)\n\t}\n\n\tstatic stop(value: unknown) {\n\t\treturn new PipeError([], value, true)\n\t}\n}\n"],"mappings":"yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,eAAAE,IAAA,eAAAC,EAAAH,GAEA,SAASI,EAAaC,EAAwB,CAC7C,OAAO,MAAM,QAAQA,CAAG,EAAIA,EAAM,CAACA,CAAG,CACvC,CAEA,SAASC,EAAYC,EAA6C,CACjE,MAAO,GAAGA,EAAQ,KAAO,GAAGA,EAAQ,IAAI,KAAO,EAAE,GAAGA,EAAQ,OAAO,EACpE,CAEO,MAAML,UAAkB,KAAM,CACpC,YACQM,EACEC,EACAC,EACTC,EACC,CACD,MAAMJ,EAAUC,EAAS,CAAC,EAC1B,MAAMD,EAAUD,EAAYC,CAAO,EAAI,wBAAyB,CAAE,MAAAI,CAAM,CAAC,EANlE,cAAAH,EACE,WAAAC,EACA,aAAAC,CAKV,CAEA,UAAW,CACV,OAAO,KAAK,SAAS,IAAIJ,CAAW,EAAE,KAAK;AAAA,CAAI,CAChD,CAEA,OAAO,KAAKE,EAA6BC,EAAgBE,EAAiB,CACzE,OAAO,IAAIT,EACVE,EAAUI,CAAQ,EAAE,IAAKD,IAAa,CAAE,QAAAA,CAAQ,EAAE,EAClDE,EACA,GACAE,CACD,CACD,CAEA,OAAO,SAASC,EAA8BH,EAAgBE,EAAiB,CAC9E,OAAO,IAAIT,EACVE,EAAUQ,CAAM,EAAE,QAASC,GAAUA,EAAM,QAAQ,EACnDJ,EACA,GACAE,CACD,CACD,CAEA,OAAO,KAAKG,EAAmBF,EAA8BH,EAAgBE,EAAiB,CAC7F,OAAO,IAAIT,EACVE,EAAUQ,CAAM,EAAE,QAASC,GAC1BA,EAAM,SAAS,IAAKN,IAAa,CAAE,GAAGA,EAAS,KAAM,GAAGO,EAAK,SAAS,CAAC,GAAGP,EAAQ,KAAO,IAAIA,EAAQ,IAAI,GAAK,EAAE,EAAG,EAAE,CACtH,EACAE,EACA,GACAE,CACD,CACD,CAEA,OAAO,KAAKF,EAAgB,CAC3B,OAAO,IAAIP,EAAU,CAAC,EAAGO,EAAO,EAAI,CACrC,CACD","names":["errors_exports","__export","PipeError","__toCommonJS","flatArray","arr","formatError","message","messages","value","stopped","cause","errors","error","path"]}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
15
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
16
|
+
var base_exports = {};
|
|
17
|
+
module.exports = __toCommonJS(base_exports);
|
|
18
|
+
__reExport(base_exports, require('./errors.cjs'), module.exports);
|
|
19
|
+
__reExport(base_exports, require('./types.cjs'), module.exports);
|
|
20
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
21
|
+
0 && (module.exports = {
|
|
22
|
+
...require('./errors.cjs'),
|
|
23
|
+
...require('./types.cjs')
|
|
24
|
+
});
|
|
25
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/api/base/index.ts"],"sourcesContent":["export * from './errors'\nexport * from './types'\n"],"mappings":";;;;;;;;;;;;;;;AAAA;AAAA;AAAA,yBAAc,qBAAd;AACA,yBAAc,oBADd;","names":[]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var a=Object.defineProperty;var b=Object.getOwnPropertyDescriptor;var c=Object.getOwnPropertyNames;var d=Object.prototype.hasOwnProperty;var t=(r,o,p,x)=>{if(o&&typeof o=="object"||typeof o=="function")for(let m of c(o))!d.call(r,m)&&m!==p&&a(r,m,{get:()=>o[m],enumerable:!(x=b(o,m))||x.enumerable});return r},f=(r,o,p)=>(t(r,o,"default"),p&&t(p,o,"default"));var g=r=>t(a({},"__esModule",{value:!0}),r);var e={};module.exports=g(e);f(e,require('./errors.min.cjs'),module.exports);f(e,require('./types.min.cjs'),module.exports);0&&(module.exports={...require('./errors.min.cjs'),...require('./types.min.cjs')});
|
|
2
|
+
//# sourceMappingURL=index.min.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/api/base/index.ts"],"sourcesContent":["export * from './errors'\nexport * from './types'\n"],"mappings":"iaAAA,IAAAA,EAAA,kBAAAC,EAAAD,GAAAE,EAAAF,EAAc,oBAAd,gBACAE,EAAAF,EAAc,mBADd","names":["base_exports","__toCommonJS","__reExport"]}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var pipes_exports = {};
|
|
20
|
+
__export(pipes_exports, {
|
|
21
|
+
assert: () => assert,
|
|
22
|
+
branch: () => branch,
|
|
23
|
+
context: () => context,
|
|
24
|
+
meta: () => meta,
|
|
25
|
+
pipe: () => pipe,
|
|
26
|
+
schema: () => schema,
|
|
27
|
+
validate: () => validate,
|
|
28
|
+
walk: () => walk
|
|
29
|
+
});
|
|
30
|
+
module.exports = __toCommonJS(pipes_exports);
|
|
31
|
+
var import_errors = require('./errors.cjs');
|
|
32
|
+
function walk(pipe2, init, nodeFn) {
|
|
33
|
+
let acc = init;
|
|
34
|
+
while (pipe2) {
|
|
35
|
+
acc = nodeFn(pipe2, acc);
|
|
36
|
+
pipe2 = pipe2.next;
|
|
37
|
+
}
|
|
38
|
+
return acc;
|
|
39
|
+
}
|
|
40
|
+
function context(pipe2) {
|
|
41
|
+
return walk(pipe2, {}, (p, acc) => ({ ...acc, ...p.context() }));
|
|
42
|
+
}
|
|
43
|
+
function assert(pipe2, input) {
|
|
44
|
+
try {
|
|
45
|
+
const cont = context(pipe2);
|
|
46
|
+
return walk(pipe2, input, (p, acc) => p.fn(acc, cont));
|
|
47
|
+
} catch (error) {
|
|
48
|
+
if (error instanceof import_errors.PipeError) {
|
|
49
|
+
if (error.stopped) return error.value;
|
|
50
|
+
throw error;
|
|
51
|
+
}
|
|
52
|
+
throw import_errors.PipeError.root(error instanceof Error ? error.message : `${error}`, input, error);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
function validate(pipe2, input) {
|
|
56
|
+
try {
|
|
57
|
+
const value = assert(pipe2, input);
|
|
58
|
+
return { value, valid: true };
|
|
59
|
+
} catch (error) {
|
|
60
|
+
if (error instanceof import_errors.PipeError) return { error, valid: false };
|
|
61
|
+
throw import_errors.PipeError.root(error instanceof Error ? error.message : `${error}`, input, error);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
function schema(pipe2, schema2 = {}) {
|
|
65
|
+
const cont = context(pipe2);
|
|
66
|
+
return walk(pipe2, schema2, (p, acc) => ({ ...acc, ...p.schema(cont) }));
|
|
67
|
+
}
|
|
68
|
+
function meta(p, meta2) {
|
|
69
|
+
return p.pipe(pipe((i) => i, { schema: () => meta2 }));
|
|
70
|
+
}
|
|
71
|
+
function pipe(func, config = {}) {
|
|
72
|
+
const piper = {
|
|
73
|
+
fn: func,
|
|
74
|
+
context: () => config.context?.() ?? {},
|
|
75
|
+
schema: (context2) => config.schema?.(context2) ?? {},
|
|
76
|
+
pipe: (...entries) => {
|
|
77
|
+
for (const cur of entries) {
|
|
78
|
+
const p = typeof cur === "function" ? pipe(cur, config) : cur;
|
|
79
|
+
if (!piper.next) piper.next = p;
|
|
80
|
+
if (piper.last) piper.last.next = p;
|
|
81
|
+
piper.last = p.last ?? p;
|
|
82
|
+
}
|
|
83
|
+
return piper;
|
|
84
|
+
},
|
|
85
|
+
"~standard": {
|
|
86
|
+
version: 1,
|
|
87
|
+
vendor: "valleyed",
|
|
88
|
+
validate(value) {
|
|
89
|
+
const validity = validate(piper, value);
|
|
90
|
+
if (validity.valid) return { value: validity.value };
|
|
91
|
+
return {
|
|
92
|
+
issues: validity.error.messages.map(({ message, path }) => ({
|
|
93
|
+
message,
|
|
94
|
+
path: path ? path.split(".") : void 0
|
|
95
|
+
}))
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
return piper;
|
|
101
|
+
}
|
|
102
|
+
function branch(branch2, fn, config) {
|
|
103
|
+
return pipe(fn, {
|
|
104
|
+
...config,
|
|
105
|
+
context: () => config.context(context(branch2)),
|
|
106
|
+
schema: (context2) => ({ ...config.schema(schema(branch2), context2) })
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
110
|
+
0 && (module.exports = {
|
|
111
|
+
assert,
|
|
112
|
+
branch,
|
|
113
|
+
context,
|
|
114
|
+
meta,
|
|
115
|
+
pipe,
|
|
116
|
+
schema,
|
|
117
|
+
validate,
|
|
118
|
+
walk
|
|
119
|
+
});
|
|
120
|
+
//# sourceMappingURL=pipes.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/api/base/pipes.ts"],"sourcesContent":["import { PipeError } from './errors'\nimport { PipeFn, Context, JsonSchemaBuilder, PipeMeta, Pipe, Entry, PipeOutput, PipeContext } from './types'\nimport { JsonSchema } from '../../utils/types'\n\nexport function walk<T>(pipe: Pipe<any, any, any>, init: T, nodeFn: (cur: Pipe<any, any, any>, acc: T) => T) {\n\tlet acc: T = init\n\twhile (pipe) {\n\t\tacc = nodeFn(pipe, acc)\n\t\tpipe = pipe.next!\n\t}\n\treturn acc\n}\n\nexport function context<T extends Pipe<any, any, any>>(pipe: T): Context<PipeContext<T>> {\n\treturn walk(pipe, {} as Context<PipeContext<T>>, (p, acc) => ({ ...acc, ...p.context() }))\n}\n\nexport function assert<T extends Pipe<any, any, any>>(pipe: T, input: unknown): PipeOutput<T> {\n\ttry {\n\t\tconst cont = context(pipe)\n\t\treturn walk(pipe, input as PipeOutput<T>, (p, acc) => p.fn(acc, cont))\n\t} catch (error) {\n\t\tif (error instanceof PipeError) {\n\t\t\tif (error.stopped) return error.value as PipeOutput<T>\n\t\t\tthrow error\n\t\t}\n\t\tthrow PipeError.root(error instanceof Error ? error.message : `${error}`, input, error)\n\t}\n}\n\nexport function validate<T extends Pipe<any, any, any>>(\n\tpipe: T,\n\tinput: unknown,\n): { value: PipeOutput<T>; valid: true } | { error: PipeError; valid: false } {\n\ttry {\n\t\tconst value = assert(pipe, input)\n\t\treturn { value, valid: true }\n\t} catch (error) {\n\t\tif (error instanceof PipeError) return { error, valid: false }\n\t\tthrow PipeError.root(error instanceof Error ? error.message : `${error}`, input, error)\n\t}\n}\n\nexport function schema<T extends Pipe<any, any, any>>(pipe: T, schema: JsonSchema = {}): JsonSchema {\n\tconst cont = context(pipe)\n\treturn walk(pipe, schema, (p, acc) => ({ ...acc, ...p.schema(cont) }))\n}\n\nexport function meta<T extends Pipe<any, any, any>>(p: T, meta: PipeMeta): T {\n\treturn p.pipe(pipe((i) => i, { schema: () => meta })) as T\n}\n\nexport function pipe<I, O, C>(\n\tfunc: PipeFn<I, O, C>,\n\tconfig: {\n\t\tcontext?: () => Context<C>\n\t\tschema?: (context: Context<C>) => JsonSchemaBuilder\n\t} = {},\n): Pipe<I, O, C> {\n\tconst piper: Pipe<I, O, C> = {\n\t\tfn: func,\n\t\tcontext: () => config.context?.() ?? ({} as any),\n\t\tschema: (context: Context<C>) => config.schema?.(context) ?? ({} as any),\n\t\tpipe: (...entries: Entry<any, any, any>[]) => {\n\t\t\tfor (const cur of entries) {\n\t\t\t\tconst p = typeof cur === 'function' ? pipe(cur, config) : cur\n\t\t\t\tif (!piper.next) piper.next = p\n\t\t\t\tif (piper.last) piper.last.next = p\n\t\t\t\tpiper.last = p.last ?? p\n\t\t\t}\n\t\t\treturn piper\n\t\t},\n\t\t'~standard': {\n\t\t\tversion: 1,\n\t\t\tvendor: 'valleyed',\n\t\t\tvalidate(value) {\n\t\t\t\tconst validity = validate(piper, value)\n\t\t\t\tif (validity.valid) return { value: validity.value }\n\t\t\t\treturn {\n\t\t\t\t\tissues: validity.error.messages.map(({ message, path }) => ({\n\t\t\t\t\t\tmessage,\n\t\t\t\t\t\tpath: path ? path.split('.') : undefined,\n\t\t\t\t\t})),\n\t\t\t\t}\n\t\t\t},\n\t\t},\n\t}\n\treturn piper\n}\n\nexport function branch<P extends Pipe<any, any, any>, I, O, C>(\n\tbranch: P,\n\tfn: PipeFn<I, O, C>,\n\tconfig: {\n\t\tcontext: (context: Context<C>) => Context<C>\n\t\tschema: (schema: JsonSchemaBuilder, context: Context<C>) => JsonSchemaBuilder\n\t},\n) {\n\treturn pipe(fn, {\n\t\t...config,\n\t\tcontext: () => config.context(context(branch) as any),\n\t\tschema: (context) => ({ ...config.schema(schema(branch), context) }),\n\t})\n}\n"],"mappings":"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","names":["pipe","schema","meta","context","branch"]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var p=Object.defineProperty;var P=Object.getOwnPropertyDescriptor;var f=Object.getOwnPropertyNames;var d=Object.prototype.hasOwnProperty;var C=(t,n)=>{for(var e in n)p(t,e,{get:n[e],enumerable:!0})},h=(t,n,e,a)=>{if(n&&typeof n=="object"||typeof n=="function")for(let r of f(n))!d.call(t,r)&&r!==e&&p(t,r,{get:()=>n[r],enumerable:!(a=P(n,r))||a.enumerable});return t};var T=t=>h(p({},"__esModule",{value:!0}),t);var w={};C(w,{assert:()=>y,branch:()=>O,context:()=>c,meta:()=>v,pipe:()=>u,schema:()=>m,validate:()=>l,walk:()=>i});module.exports=T(w);var s=require('./errors.min.cjs');function i(t,n,e){let a=n;for(;t;)a=e(t,a),t=t.next;return a}function c(t){return i(t,{},(n,e)=>({...e,...n.context()}))}function y(t,n){try{const e=c(t);return i(t,n,(a,r)=>a.fn(r,e))}catch(e){if(e instanceof s.PipeError){if(e.stopped)return e.value;throw e}throw s.PipeError.root(e instanceof Error?e.message:`${e}`,n,e)}}function l(t,n){try{return{value:y(t,n),valid:!0}}catch(e){if(e instanceof s.PipeError)return{error:e,valid:!1};throw s.PipeError.root(e instanceof Error?e.message:`${e}`,n,e)}}function m(t,n={}){const e=c(t);return i(t,n,(a,r)=>({...r,...a.schema(e)}))}function v(t,n){return t.pipe(u(e=>e,{schema:()=>n}))}function u(t,n={}){const e={fn:t,context:()=>n.context?.()??{},schema:a=>n.schema?.(a)??{},pipe:(...a)=>{for(const r of a){const o=typeof r=="function"?u(r,n):r;e.next||(e.next=o),e.last&&(e.last.next=o),e.last=o.last??o}return e},"~standard":{version:1,vendor:"valleyed",validate(a){const r=l(e,a);return r.valid?{value:r.value}:{issues:r.error.messages.map(({message:o,path:x})=>({message:o,path:x?x.split("."):void 0}))}}}};return e}function O(t,n,e){return u(n,{...e,context:()=>e.context(c(t)),schema:a=>({...e.schema(m(t),a)})})}0&&(module.exports={assert,branch,context,meta,pipe,schema,validate,walk});
|
|
2
|
+
//# sourceMappingURL=pipes.min.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/api/base/pipes.ts"],"sourcesContent":["import { PipeError } from './errors'\nimport { PipeFn, Context, JsonSchemaBuilder, PipeMeta, Pipe, Entry, PipeOutput, PipeContext } from './types'\nimport { JsonSchema } from '../../utils/types'\n\nexport function walk<T>(pipe: Pipe<any, any, any>, init: T, nodeFn: (cur: Pipe<any, any, any>, acc: T) => T) {\n\tlet acc: T = init\n\twhile (pipe) {\n\t\tacc = nodeFn(pipe, acc)\n\t\tpipe = pipe.next!\n\t}\n\treturn acc\n}\n\nexport function context<T extends Pipe<any, any, any>>(pipe: T): Context<PipeContext<T>> {\n\treturn walk(pipe, {} as Context<PipeContext<T>>, (p, acc) => ({ ...acc, ...p.context() }))\n}\n\nexport function assert<T extends Pipe<any, any, any>>(pipe: T, input: unknown): PipeOutput<T> {\n\ttry {\n\t\tconst cont = context(pipe)\n\t\treturn walk(pipe, input as PipeOutput<T>, (p, acc) => p.fn(acc, cont))\n\t} catch (error) {\n\t\tif (error instanceof PipeError) {\n\t\t\tif (error.stopped) return error.value as PipeOutput<T>\n\t\t\tthrow error\n\t\t}\n\t\tthrow PipeError.root(error instanceof Error ? error.message : `${error}`, input, error)\n\t}\n}\n\nexport function validate<T extends Pipe<any, any, any>>(\n\tpipe: T,\n\tinput: unknown,\n): { value: PipeOutput<T>; valid: true } | { error: PipeError; valid: false } {\n\ttry {\n\t\tconst value = assert(pipe, input)\n\t\treturn { value, valid: true }\n\t} catch (error) {\n\t\tif (error instanceof PipeError) return { error, valid: false }\n\t\tthrow PipeError.root(error instanceof Error ? error.message : `${error}`, input, error)\n\t}\n}\n\nexport function schema<T extends Pipe<any, any, any>>(pipe: T, schema: JsonSchema = {}): JsonSchema {\n\tconst cont = context(pipe)\n\treturn walk(pipe, schema, (p, acc) => ({ ...acc, ...p.schema(cont) }))\n}\n\nexport function meta<T extends Pipe<any, any, any>>(p: T, meta: PipeMeta): T {\n\treturn p.pipe(pipe((i) => i, { schema: () => meta })) as T\n}\n\nexport function pipe<I, O, C>(\n\tfunc: PipeFn<I, O, C>,\n\tconfig: {\n\t\tcontext?: () => Context<C>\n\t\tschema?: (context: Context<C>) => JsonSchemaBuilder\n\t} = {},\n): Pipe<I, O, C> {\n\tconst piper: Pipe<I, O, C> = {\n\t\tfn: func,\n\t\tcontext: () => config.context?.() ?? ({} as any),\n\t\tschema: (context: Context<C>) => config.schema?.(context) ?? ({} as any),\n\t\tpipe: (...entries: Entry<any, any, any>[]) => {\n\t\t\tfor (const cur of entries) {\n\t\t\t\tconst p = typeof cur === 'function' ? pipe(cur, config) : cur\n\t\t\t\tif (!piper.next) piper.next = p\n\t\t\t\tif (piper.last) piper.last.next = p\n\t\t\t\tpiper.last = p.last ?? p\n\t\t\t}\n\t\t\treturn piper\n\t\t},\n\t\t'~standard': {\n\t\t\tversion: 1,\n\t\t\tvendor: 'valleyed',\n\t\t\tvalidate(value) {\n\t\t\t\tconst validity = validate(piper, value)\n\t\t\t\tif (validity.valid) return { value: validity.value }\n\t\t\t\treturn {\n\t\t\t\t\tissues: validity.error.messages.map(({ message, path }) => ({\n\t\t\t\t\t\tmessage,\n\t\t\t\t\t\tpath: path ? path.split('.') : undefined,\n\t\t\t\t\t})),\n\t\t\t\t}\n\t\t\t},\n\t\t},\n\t}\n\treturn piper\n}\n\nexport function branch<P extends Pipe<any, any, any>, I, O, C>(\n\tbranch: P,\n\tfn: PipeFn<I, O, C>,\n\tconfig: {\n\t\tcontext: (context: Context<C>) => Context<C>\n\t\tschema: (schema: JsonSchemaBuilder, context: Context<C>) => JsonSchemaBuilder\n\t},\n) {\n\treturn pipe(fn, {\n\t\t...config,\n\t\tcontext: () => config.context(context(branch) as any),\n\t\tschema: (context) => ({ ...config.schema(schema(branch), context) }),\n\t})\n}\n"],"mappings":"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","names":["pipes_exports","__export","assert","branch","context","meta","pipe","schema","validate","walk","__toCommonJS","import_errors","init","nodeFn","acc","p","input","cont","error","i","func","config","piper","entries","cur","value","validity","message","path","fn"]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
var types_exports = {};
|
|
16
|
+
module.exports = __toCommonJS(types_exports);
|
|
17
|
+
//# sourceMappingURL=types.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/api/base/types.ts"],"sourcesContent":["import { StandardSchemaV1 } from '@standard-schema/spec'\n\nimport { ValueFunction } from '../../utils/functions'\nimport { JsonSchema } from '../../utils/types'\nimport type { Timeable } from '../times'\n\nexport type PipeFn<I, O, C> = (input: I, context: Context<C>) => O\nexport type PipeInput<T> = T extends Pipe<infer I, any, any> ? I : never\nexport type PipeOutput<T> = T extends Pipe<any, infer O, any> ? O : never\nexport type PipeContext<T> = T extends Pipe<any, any, infer C> ? C : never\nexport type Context<C> = C &\n\tReadonly<{\n\t\toptional?: boolean\n\t\tobjectKeys?: string[]\n\t\teq?: ValueFunction<unknown>\n\t\tne?: ValueFunction<unknown>\n\t\tin?: ValueFunction<Readonly<unknown[]>>\n\t\tnin?: ValueFunction<Readonly<unknown[]>>\n\t\thas?: ValueFunction<number>\n\t\tmin?: ValueFunction<number>\n\t\tmax?: ValueFunction<number>\n\t\tfileTypes?: ValueFunction<string | string[]>\n\t\tdefaults?: ValueFunction<unknown>\n\t\tcatch?: ValueFunction<unknown>\n\t\tafter?: ValueFunction<Timeable>\n\t\tbefore?: ValueFunction<Timeable>\n\t}>\nexport type PipeMeta = Pick<JsonSchema, '$refId' | 'title' | 'description' | 'examples' | 'default'>\nexport type JsonSchemaBuilder = JsonSchema\n\nexport type Entry<I, O, C> = Pipe<I, O, C> | PipeFn<I, O, C>\ntype PipeChain<I, O, C> = {\n\t<T1>(fn1: Entry<O, T1, C>): Pipe<I, T1, C>\n\t<T1, T2>(fn1: Entry<O, T1, C>, fn2: Entry<T1, T2, C>): Pipe<I, T2, C>\n\t<T1, T2, T3>(fn1: Entry<O, T1, C>, fn2: Entry<T1, T2, C>, f3: Entry<T2, T3, C>): Pipe<I, T3, C>\n\t<T1, T2, T3, T4>(fn1: Entry<O, T1, C>, fn2: Entry<T1, T2, C>, f3: Entry<T2, T3, C>, f4: Entry<T3, T4, C>): Pipe<I, T4, C>\n\t<T1, T2, T3, T4, T5>(\n\t\tfn1: Entry<O, T1, C>,\n\t\tfn2: Entry<T1, T2, C>,\n\t\tf3: Entry<T2, T3, C>,\n\t\tf4: Entry<T3, T4, C>,\n\t\tf5: Entry<T4, T5, C>,\n\t): Pipe<I, T5, C>\n\t<T1, T2, T3, T4, T5, T6>(\n\t\tfn1: Entry<O, T1, C>,\n\t\tfn2: Entry<T1, T2, C>,\n\t\tf3: Entry<T2, T3, C>,\n\t\tf4: Entry<T3, T4, C>,\n\t\tf5: Entry<T4, T5, C>,\n\t\tf6: Entry<T5, T6, C>,\n\t): Pipe<I, T6, C>\n\t<T1, T2, T3, T4, T5, T6, T7>(\n\t\tfn1: Entry<O, T1, C>,\n\t\tfn2: Entry<T1, T2, C>,\n\t\tf3: Entry<T2, T3, C>,\n\t\tf4: Entry<T3, T4, C>,\n\t\tf5: Entry<T4, T5, C>,\n\t\tf6: Entry<T5, T6, C>,\n\t\tf7: Entry<T6, T7, C>,\n\t): Pipe<I, T7, C>\n\t<T1, T2, T3, T4, T5, T6, T7, T8>(\n\t\tfn1: Entry<O, T1, C>,\n\t\tfn2: Entry<T1, T2, C>,\n\t\tf3: Entry<T2, T3, C>,\n\t\tf4: Entry<T3, T4, C>,\n\t\tf5: Entry<T4, T5, C>,\n\t\tf6: Entry<T5, T6, C>,\n\t\tf7: Entry<T6, T7, C>,\n\t\tf8: Entry<T7, T8, C>,\n\t): Pipe<I, T8, C>\n\t<T1, T2, T3, T4, T5, T6, T7, T8, T9>(\n\t\tfn1: Entry<O, T1, C>,\n\t\tfn2: Entry<T1, T2, C>,\n\t\tf3: Entry<T2, T3, C>,\n\t\tf4: Entry<T3, T4, C>,\n\t\tf5: Entry<T4, T5, C>,\n\t\tf6: Entry<T5, T6, C>,\n\t\tf7: Entry<T6, T7, C>,\n\t\tf8: Entry<T7, T8, C>,\n\t\tf9: Entry<T8, T9, C>,\n\t): Pipe<I, T9, C>\n\t<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(\n\t\tfn1: Entry<O, T1, C>,\n\t\tfn2: Entry<T1, T2, C>,\n\t\tf3: Entry<T2, T3, C>,\n\t\tf4: Entry<T3, T4, C>,\n\t\tf5: Entry<T4, T5, C>,\n\t\tf6: Entry<T5, T6, C>,\n\t\tf7: Entry<T6, T7, C>,\n\t\tf8: Entry<T7, T8, C>,\n\t\tf9: Entry<T8, T9, C>,\n\t\tf10: Entry<T9, T10, C>,\n\t): Pipe<I, T10, C>\n}\n\nexport interface Pipe<I, O, C> extends StandardSchemaV1<I, O> {\n\treadonly fn: PipeFn<any, any, any>\n\treadonly context: () => Context<any>\n\treadonly schema: (context: Context<any>) => JsonSchema\n\treadonly pipe: PipeChain<I, O, C>\n\tnext?: Pipe<any, any, any>\n\tlast?: Pipe<any, any, any>\n}\n"],"mappings":";;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var r=Object.defineProperty;var C=Object.getOwnPropertyDescriptor;var f=Object.getOwnPropertyNames;var i=Object.prototype.hasOwnProperty;var a=(T,n,y,e)=>{if(n&&typeof n=="object"||typeof n=="function")for(let t of f(n))!i.call(T,t)&&t!==y&&r(T,t,{get:()=>n[t],enumerable:!(e=C(n,t))||e.enumerable});return T};var o=T=>a(r({},"__esModule",{value:!0}),T);var p={};module.exports=o(p);
|
|
2
|
+
//# sourceMappingURL=types.min.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/api/base/types.ts"],"sourcesContent":["import { StandardSchemaV1 } from '@standard-schema/spec'\n\nimport { ValueFunction } from '../../utils/functions'\nimport { JsonSchema } from '../../utils/types'\nimport type { Timeable } from '../times'\n\nexport type PipeFn<I, O, C> = (input: I, context: Context<C>) => O\nexport type PipeInput<T> = T extends Pipe<infer I, any, any> ? I : never\nexport type PipeOutput<T> = T extends Pipe<any, infer O, any> ? O : never\nexport type PipeContext<T> = T extends Pipe<any, any, infer C> ? C : never\nexport type Context<C> = C &\n\tReadonly<{\n\t\toptional?: boolean\n\t\tobjectKeys?: string[]\n\t\teq?: ValueFunction<unknown>\n\t\tne?: ValueFunction<unknown>\n\t\tin?: ValueFunction<Readonly<unknown[]>>\n\t\tnin?: ValueFunction<Readonly<unknown[]>>\n\t\thas?: ValueFunction<number>\n\t\tmin?: ValueFunction<number>\n\t\tmax?: ValueFunction<number>\n\t\tfileTypes?: ValueFunction<string | string[]>\n\t\tdefaults?: ValueFunction<unknown>\n\t\tcatch?: ValueFunction<unknown>\n\t\tafter?: ValueFunction<Timeable>\n\t\tbefore?: ValueFunction<Timeable>\n\t}>\nexport type PipeMeta = Pick<JsonSchema, '$refId' | 'title' | 'description' | 'examples' | 'default'>\nexport type JsonSchemaBuilder = JsonSchema\n\nexport type Entry<I, O, C> = Pipe<I, O, C> | PipeFn<I, O, C>\ntype PipeChain<I, O, C> = {\n\t<T1>(fn1: Entry<O, T1, C>): Pipe<I, T1, C>\n\t<T1, T2>(fn1: Entry<O, T1, C>, fn2: Entry<T1, T2, C>): Pipe<I, T2, C>\n\t<T1, T2, T3>(fn1: Entry<O, T1, C>, fn2: Entry<T1, T2, C>, f3: Entry<T2, T3, C>): Pipe<I, T3, C>\n\t<T1, T2, T3, T4>(fn1: Entry<O, T1, C>, fn2: Entry<T1, T2, C>, f3: Entry<T2, T3, C>, f4: Entry<T3, T4, C>): Pipe<I, T4, C>\n\t<T1, T2, T3, T4, T5>(\n\t\tfn1: Entry<O, T1, C>,\n\t\tfn2: Entry<T1, T2, C>,\n\t\tf3: Entry<T2, T3, C>,\n\t\tf4: Entry<T3, T4, C>,\n\t\tf5: Entry<T4, T5, C>,\n\t): Pipe<I, T5, C>\n\t<T1, T2, T3, T4, T5, T6>(\n\t\tfn1: Entry<O, T1, C>,\n\t\tfn2: Entry<T1, T2, C>,\n\t\tf3: Entry<T2, T3, C>,\n\t\tf4: Entry<T3, T4, C>,\n\t\tf5: Entry<T4, T5, C>,\n\t\tf6: Entry<T5, T6, C>,\n\t): Pipe<I, T6, C>\n\t<T1, T2, T3, T4, T5, T6, T7>(\n\t\tfn1: Entry<O, T1, C>,\n\t\tfn2: Entry<T1, T2, C>,\n\t\tf3: Entry<T2, T3, C>,\n\t\tf4: Entry<T3, T4, C>,\n\t\tf5: Entry<T4, T5, C>,\n\t\tf6: Entry<T5, T6, C>,\n\t\tf7: Entry<T6, T7, C>,\n\t): Pipe<I, T7, C>\n\t<T1, T2, T3, T4, T5, T6, T7, T8>(\n\t\tfn1: Entry<O, T1, C>,\n\t\tfn2: Entry<T1, T2, C>,\n\t\tf3: Entry<T2, T3, C>,\n\t\tf4: Entry<T3, T4, C>,\n\t\tf5: Entry<T4, T5, C>,\n\t\tf6: Entry<T5, T6, C>,\n\t\tf7: Entry<T6, T7, C>,\n\t\tf8: Entry<T7, T8, C>,\n\t): Pipe<I, T8, C>\n\t<T1, T2, T3, T4, T5, T6, T7, T8, T9>(\n\t\tfn1: Entry<O, T1, C>,\n\t\tfn2: Entry<T1, T2, C>,\n\t\tf3: Entry<T2, T3, C>,\n\t\tf4: Entry<T3, T4, C>,\n\t\tf5: Entry<T4, T5, C>,\n\t\tf6: Entry<T5, T6, C>,\n\t\tf7: Entry<T6, T7, C>,\n\t\tf8: Entry<T7, T8, C>,\n\t\tf9: Entry<T8, T9, C>,\n\t): Pipe<I, T9, C>\n\t<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(\n\t\tfn1: Entry<O, T1, C>,\n\t\tfn2: Entry<T1, T2, C>,\n\t\tf3: Entry<T2, T3, C>,\n\t\tf4: Entry<T3, T4, C>,\n\t\tf5: Entry<T4, T5, C>,\n\t\tf6: Entry<T5, T6, C>,\n\t\tf7: Entry<T6, T7, C>,\n\t\tf8: Entry<T7, T8, C>,\n\t\tf9: Entry<T8, T9, C>,\n\t\tf10: Entry<T9, T10, C>,\n\t): Pipe<I, T10, C>\n}\n\nexport interface Pipe<I, O, C> extends StandardSchemaV1<I, O> {\n\treadonly fn: PipeFn<any, any, any>\n\treadonly context: () => Context<any>\n\treadonly schema: (context: Context<any>) => JsonSchema\n\treadonly pipe: PipeChain<I, O, C>\n\tnext?: Pipe<any, any, any>\n\tlast?: Pipe<any, any, any>\n}\n"],"mappings":"+WAAA,IAAAA,EAAA,kBAAAC,EAAAD","names":["types_exports","__toCommonJS"]}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var coerce_exports = {};
|
|
20
|
+
__export(coerce_exports, {
|
|
21
|
+
coerceBoolean: () => coerceBoolean,
|
|
22
|
+
coerceNumber: () => coerceNumber,
|
|
23
|
+
coerceString: () => coerceString,
|
|
24
|
+
coerceTime: () => coerceTime
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(coerce_exports);
|
|
27
|
+
var import_pipes = require('./base/pipes.cjs');
|
|
28
|
+
var import_times = require('./times.cjs');
|
|
29
|
+
var import_types = require('./types.cjs');
|
|
30
|
+
const coerceString = () => (0, import_pipes.pipe)((input) => String(input).toString()).pipe((0, import_types.string)());
|
|
31
|
+
const coerceNumber = () => (0, import_pipes.pipe)((input) => Number(input)).pipe((0, import_types.number)());
|
|
32
|
+
const coerceBoolean = () => (0, import_pipes.pipe)((input) => Boolean(input)).pipe((0, import_types.boolean)());
|
|
33
|
+
const coerceTime = () => (0, import_pipes.pipe)((input) => new Date(input)).pipe((0, import_times.time)());
|
|
34
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
35
|
+
0 && (module.exports = {
|
|
36
|
+
coerceBoolean,
|
|
37
|
+
coerceNumber,
|
|
38
|
+
coerceString,
|
|
39
|
+
coerceTime
|
|
40
|
+
});
|
|
41
|
+
//# sourceMappingURL=coerce.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/api/coerce.ts"],"sourcesContent":["import { pipe } from './base/pipes'\nimport { time, Timeable } from './times'\nimport { boolean, number, string } from './types'\n\nexport const coerceString = () => pipe<string, string, any>((input: unknown) => String(input).toString()).pipe(string())\nexport const coerceNumber = () => pipe<number, number, any>((input: unknown) => Number(input)).pipe(number())\nexport const coerceBoolean = () => pipe<boolean, boolean, any>((input: unknown) => Boolean(input)).pipe(boolean())\nexport const coerceTime = () => pipe<Date, Timeable, any>((input: unknown) => new Date(input as any)).pipe(time())\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAqB;AACrB,mBAA+B;AAC/B,mBAAwC;AAEjC,MAAM,eAAe,UAAM,mBAA0B,CAAC,UAAmB,OAAO,KAAK,EAAE,SAAS,CAAC,EAAE,SAAK,qBAAO,CAAC;AAChH,MAAM,eAAe,UAAM,mBAA0B,CAAC,UAAmB,OAAO,KAAK,CAAC,EAAE,SAAK,qBAAO,CAAC;AACrG,MAAM,gBAAgB,UAAM,mBAA4B,CAAC,UAAmB,QAAQ,KAAK,CAAC,EAAE,SAAK,sBAAQ,CAAC;AAC1G,MAAM,aAAa,UAAM,mBAA0B,CAAC,UAAmB,IAAI,KAAK,KAAY,CAAC,EAAE,SAAK,mBAAK,CAAC;","names":[]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var p=Object.defineProperty;var c=Object.getOwnPropertyDescriptor;var b=Object.getOwnPropertyNames;var u=Object.prototype.hasOwnProperty;var s=(e,n)=>{for(var i in n)p(e,i,{get:n[i],enumerable:!0})},l=(e,n,i,a)=>{if(n&&typeof n=="object"||typeof n=="function")for(let r of b(n))!u.call(e,r)&&r!==i&&p(e,r,{get:()=>n[r],enumerable:!(a=c(n,r))||a.enumerable});return e};var g=e=>l(p({},"__esModule",{value:!0}),e);var f={};s(f,{coerceBoolean:()=>k,coerceNumber:()=>y,coerceString:()=>w,coerceTime:()=>x});module.exports=g(f);var t=require('./base/pipes.min.cjs'),m=require('./times.min.cjs'),o=require('./types.min.cjs');const w=()=>(0,t.pipe)(e=>String(e).toString()).pipe((0,o.string)()),y=()=>(0,t.pipe)(e=>Number(e)).pipe((0,o.number)()),k=()=>(0,t.pipe)(e=>!!e).pipe((0,o.boolean)()),x=()=>(0,t.pipe)(e=>new Date(e)).pipe((0,m.time)());0&&(module.exports={coerceBoolean,coerceNumber,coerceString,coerceTime});
|
|
2
|
+
//# sourceMappingURL=coerce.min.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/api/coerce.ts"],"sourcesContent":["import { pipe } from './base/pipes'\nimport { time, Timeable } from './times'\nimport { boolean, number, string } from './types'\n\nexport const coerceString = () => pipe<string, string, any>((input: unknown) => String(input).toString()).pipe(string())\nexport const coerceNumber = () => pipe<number, number, any>((input: unknown) => Number(input)).pipe(number())\nexport const coerceBoolean = () => pipe<boolean, boolean, any>((input: unknown) => Boolean(input)).pipe(boolean())\nexport const coerceTime = () => pipe<Date, Timeable, any>((input: unknown) => new Date(input as any)).pipe(time())\n"],"mappings":"yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,mBAAAE,EAAA,iBAAAC,EAAA,iBAAAC,EAAA,eAAAC,IAAA,eAAAC,EAAAN,GAAA,IAAAO,EAAqB,wBACrBC,EAA+B,mBAC/BC,EAAwC,mBAEjC,MAAML,EAAe,OAAM,QAA2BM,GAAmB,OAAOA,CAAK,EAAE,SAAS,CAAC,EAAE,QAAK,UAAO,CAAC,EAC1GP,EAAe,OAAM,QAA2BO,GAAmB,OAAOA,CAAK,CAAC,EAAE,QAAK,UAAO,CAAC,EAC/FR,EAAgB,OAAM,QAA6BQ,GAAmB,EAAQA,CAAM,EAAE,QAAK,WAAQ,CAAC,EACpGL,EAAa,OAAM,QAA2BK,GAAmB,IAAI,KAAKA,CAAY,CAAC,EAAE,QAAK,QAAK,CAAC","names":["coerce_exports","__export","coerceBoolean","coerceNumber","coerceString","coerceTime","__toCommonJS","import_pipes","import_times","import_types","input"]}
|