@douglasneuroinformatics/libjs 2.8.1 → 3.0.0
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/dist/datetime.d.ts +1 -1
- package/dist/datetime.d.ts.map +1 -1
- package/dist/datetime.js +1 -1
- package/dist/exception.d.ts +3 -3
- package/dist/exception.d.ts.map +1 -1
- package/dist/exception.js +1 -1
- package/dist/http.d.ts +1 -1
- package/dist/http.d.ts.map +1 -1
- package/dist/http.js +1 -1
- package/dist/number.d.ts +1 -0
- package/dist/number.d.ts.map +1 -1
- package/dist/number.js +16 -0
- package/dist/random.d.ts +1 -1
- package/dist/random.d.ts.map +1 -1
- package/dist/random.js +1 -1
- package/dist/range.d.ts +1 -1
- package/dist/range.d.ts.map +1 -1
- package/dist/range.js +1 -1
- package/dist/result.d.ts +2 -1
- package/dist/result.d.ts.map +1 -1
- package/dist/result.js +7 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/zod.d.ts +49 -9
- package/dist/zod.d.ts.map +1 -1
- package/dist/zod.js +34 -13
- package/package.json +2 -6
- package/dist/vendor/neverthrow.d.ts +0 -12
- package/dist/vendor/neverthrow.d.ts.map +0 -1
- package/dist/vendor/neverthrow.js +0 -14
package/dist/datetime.d.ts
CHANGED
package/dist/datetime.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"datetime.d.ts","sourceRoot":"","sources":["../src/datetime.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"datetime.d.ts","sourceRoot":"","sources":["../src/datetime.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAEzC,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAErD,MAAM,MAAM,QAAQ,GAAG;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,uFAAuF;AACvF,eAAO,MAAM,QAAQ,mEAMV,CAAC;AAEZ;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,CAEnD;AAED;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,CAEnD;AAED;;;;;;;;GAQG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,CAE9C;AAED;;;;;;GAMG;AACH,wBAAsB,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAE1D;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,CAAC,QAAQ,EAAE,OAAO,mBAAmB,CAAC,QAAQ,CAAC,CAYzG"}
|
package/dist/datetime.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { err, ok } from 'neverthrow';
|
|
1
2
|
import { OutOfRangeException } from './exception.js';
|
|
2
|
-
import { err, ok } from './vendor/neverthrow.js';
|
|
3
3
|
/** A map that associates time units with their corresponding values in milliseconds */
|
|
4
4
|
export const TIME_MAP = new Map([
|
|
5
5
|
['day', 24 * 60 * 60 * 1000],
|
package/dist/exception.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { Result, ResultAsync } from 'neverthrow';
|
|
1
2
|
import { serializeError } from 'serialize-error';
|
|
2
3
|
import type { IsNever, RequiredKeysOf } from 'type-fest';
|
|
3
|
-
import type { z } from 'zod';
|
|
4
|
-
import { Result, ResultAsync } from './vendor/neverthrow.js';
|
|
4
|
+
import type { z } from 'zod/v4';
|
|
5
5
|
import type { SingleKeyMap, ToAbstractConstructor } from './types.js';
|
|
6
6
|
type ExceptionName = `${string}Exception`;
|
|
7
7
|
type ExceptionOptions = {
|
|
@@ -124,7 +124,7 @@ export declare const ValidationException: ExceptionType<{
|
|
|
124
124
|
}, {
|
|
125
125
|
details: {
|
|
126
126
|
data: unknown;
|
|
127
|
-
issues: z.ZodIssue[];
|
|
127
|
+
issues: z.core.$ZodIssue[];
|
|
128
128
|
};
|
|
129
129
|
}, {
|
|
130
130
|
[key: string]: unknown;
|
package/dist/exception.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exception.d.ts","sourceRoot":"","sources":["../src/exception.ts"],"names":[],"mappings":"AAMA,OAAO,EAAe,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAE9D,OAAO,KAAK,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AACzD,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"exception.d.ts","sourceRoot":"","sources":["../src/exception.ts"],"names":[],"mappings":"AAMA,OAAO,EAAiB,MAAM,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAChE,OAAO,EAAe,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAE9D,OAAO,KAAK,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AACzD,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAC;AAKhC,OAAO,KAAK,EAAE,YAAY,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAEtE,KAAK,aAAa,GAAG,GAAG,MAAM,WAAW,CAAC;AAE1C,KAAK,gBAAgB,GAAG;IACtB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,OAAO,CAAC,EAAE;QACR,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;KACxB,CAAC;CACH,CAAC;AAEF,KAAK,eAAe,CAAC,QAAQ,GAAG,GAAG,IAAI;IACrC,OAAO,CAAC,EAAE,CAAC,CAAC,OAAO,EAAE,QAAQ,KAAK,MAAM,CAAC,GAAG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AyE,CAAC;AAEhG,QAAA,MAAQ,mBAAmB;;aAES,MAAM;aAAO,MAAM;eAAS,MAAM;;;;aAAzC;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE;;;;;;iBAApC,MAAM;iBAAO,MAAM;mBAAS,MAAM;;;;iBAAzC;YAAE,GAAG,EAAE,MAAM,CAAC;YAAC,GAAG,EAAE,MAAM,CAAC;YAAC,KAAK,EAAE,MAAM,CAAA;SAAE;eAKlB,MAAM;;iBALxB,MAAM;iBAAO,MAAM;mBAAS,MAAM;;;;iBAAzC;YAAE,GAAG,EAAE,MAAM,CAAC;YAAC,GAAG,EAAE,MAAM,CAAC;YAAC,KAAK,EAAE,MAAM,CAAA;SAAE;;EAQ9D,CAAC;AAEX,eAAO,MAAQ,mBAAmB;;;;aACL;QAAE,IAAI,EAAE,OAAO,CAAC;QAAC,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,SAAS,EAAE,CAAA;KAAE;;;EAEhE,CAAC;AAEX,YAAY,EACV,oBAAoB,EACpB,wBAAwB,EACxB,aAAa,EACb,aAAa,EACb,gBAAgB,EAChB,eAAe,EACf,eAAe,EACf,aAAa,EACd,CAAC;AAEF,OAAO,EACL,aAAa,EACb,WAAW,EACX,gBAAgB,EAChB,mBAAmB,EACnB,UAAU,EACV,gBAAgB,EAChB,cAAc,EACd,cAAc,EACf,CAAC"}
|
package/dist/exception.js
CHANGED
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
/* eslint-disable no-dupe-class-members */
|
|
4
4
|
import cleanStack from 'clean-stack';
|
|
5
5
|
import extractStack from 'extract-stack';
|
|
6
|
+
import { err, errAsync, Result, ResultAsync } from 'neverthrow';
|
|
6
7
|
import { isErrorLike, serializeError } from 'serialize-error';
|
|
7
8
|
import stringifyObject from 'stringify-object';
|
|
8
9
|
import { objectify } from './object.js';
|
|
9
10
|
import { indentLines } from './string.js';
|
|
10
|
-
import { err, errAsync, Result, ResultAsync } from './vendor/neverthrow.js';
|
|
11
11
|
function parseStack(errorOrStack) {
|
|
12
12
|
const stack = typeof errorOrStack === 'string' ? errorOrStack : errorOrStack?.stack;
|
|
13
13
|
return extractStack.lines(cleanStack(stack, { pretty: true }));
|
package/dist/http.d.ts
CHANGED
package/dist/http.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../src/http.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../src/http.ts"],"names":[],"mappings":"AAAA,OAAO,EAAM,WAAW,EAAE,MAAM,YAAY,CAAC;AAM7C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAEpD,KAAK,mBAAmB,GAAG;IACzB,KAAK,EAAE,OAAO,CAAC;IACf,OAAO,EAAE;QACP,IAAI,EAAE,eAAe,CAAC;QACtB,GAAG,EAAE,MAAM,CAAC;KACb,CAAC;CACH,CAAC;AAEF,KAAK,gBAAgB,GAAG;IACtB,OAAO,EAAE;QACP,IAAI,EAAE,YAAY,CAAC;QACnB,MAAM,EAAE,MAAM,CAAC;QACf,UAAU,EAAE,MAAM,CAAC;QACnB,GAAG,EAAE,MAAM,CAAC;KACb,CAAC;CACH,CAAC;AAEF,eAAO,MAAQ,cAAc;;cAdnB,eAAe;aAChB,MAAM;;cAML,YAAY;gBACV,MAAM;oBACF,MAAM;aACb,MAAM;;;;;EAUL,CAAC;AAEX,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,WAAW,GAAG,WAAW,CAAC,QAAQ,EAAE,OAAO,cAAc,CAAC,QAAQ,CAAC,CAyB/G;AAED,wBAAgB,aAAa,CAC3B,GAAG,EAAE,MAAM,EACX,EAAE,QAAY,EAAE,OAAY,EAAE,GAAE;IAAE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAO,GAC3E,WAAW,CAAC,IAAI,EAAE,aAAa,CAAC,CAmBlC"}
|
package/dist/http.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { ok, ResultAsync } from 'neverthrow';
|
|
1
2
|
import { sleep } from './datetime.js';
|
|
2
3
|
import { ExceptionBuilder, RuntimeException } from './exception.js';
|
|
3
4
|
import { asyncResultify } from './result.js';
|
|
4
|
-
import { ok, ResultAsync } from './vendor/neverthrow.js';
|
|
5
5
|
export const { FetchException } = new ExceptionBuilder()
|
|
6
6
|
.setOptionsType()
|
|
7
7
|
.setParams({
|
package/dist/number.d.ts
CHANGED
|
@@ -4,4 +4,5 @@ export declare function isStringNumber(value: string): boolean;
|
|
|
4
4
|
export declare function isNumberLike(value: unknown): value is number | string;
|
|
5
5
|
/** Returns `value` as a number if it is a number or string representation of a number, otherwise returns `NaN` */
|
|
6
6
|
export declare function parseNumber(value: unknown): number;
|
|
7
|
+
export declare function formatByteSize(bytes: number, si?: boolean, dp?: number): string;
|
|
7
8
|
//# sourceMappingURL=number.d.ts.map
|
package/dist/number.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"number.d.ts","sourceRoot":"","sources":["../src/number.ts"],"names":[],"mappings":"AAAA,yEAAyE;AACzE,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAKrD;AAED,mFAAmF;AACnF,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,GAAG,MAAM,CAOrE;AAED,kHAAkH;AAClH,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAElD"}
|
|
1
|
+
{"version":3,"file":"number.d.ts","sourceRoot":"","sources":["../src/number.ts"],"names":[],"mappings":"AAAA,yEAAyE;AACzE,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAKrD;AAED,mFAAmF;AACnF,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,GAAG,MAAM,CAOrE;AAED,kHAAkH;AAClH,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAElD;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,UAAQ,EAAE,EAAE,SAAI,GAAG,MAAM,CAoBxE"}
|
package/dist/number.js
CHANGED
|
@@ -19,3 +19,19 @@ export function isNumberLike(value) {
|
|
|
19
19
|
export function parseNumber(value) {
|
|
20
20
|
return isNumberLike(value) ? Number(value) : NaN;
|
|
21
21
|
}
|
|
22
|
+
export function formatByteSize(bytes, si = false, dp = 1) {
|
|
23
|
+
const thresh = si ? 1000 : 1024;
|
|
24
|
+
if (Math.abs(bytes) < thresh) {
|
|
25
|
+
return bytes + ' B';
|
|
26
|
+
}
|
|
27
|
+
const units = si
|
|
28
|
+
? ['KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']
|
|
29
|
+
: ['KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB'];
|
|
30
|
+
let u = -1;
|
|
31
|
+
const r = 10 ** dp;
|
|
32
|
+
do {
|
|
33
|
+
bytes /= thresh;
|
|
34
|
+
++u;
|
|
35
|
+
} while (Math.round(Math.abs(bytes) * r) / r >= thresh && u < units.length - 1);
|
|
36
|
+
return bytes.toFixed(dp) + ' ' + units[u];
|
|
37
|
+
}
|
package/dist/random.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import type { Result } from 'neverthrow';
|
|
1
2
|
import { ValueException } from './exception.js';
|
|
2
|
-
import type { Result } from './vendor/neverthrow.js';
|
|
3
3
|
/** Returns a random integer between `min` (inclusive) and `max` (not inclusive) */
|
|
4
4
|
export declare function randomInt(min: number, max: number): Result<number, typeof ValueException.Instance>;
|
|
5
5
|
/** Returns a random date between `start` and `end` (both inclusive) */
|
package/dist/random.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"random.d.ts","sourceRoot":"","sources":["../src/random.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"random.d.ts","sourceRoot":"","sources":["../src/random.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAEzC,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAEhD,mFAAmF;AACnF,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,cAAc,CAAC,QAAQ,CAAC,CAKlG;AAED,uEAAuE;AACvE,wBAAgB,UAAU,CAAC,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,GAAG,MAAM,CAAC,IAAI,EAAE,OAAO,cAAc,CAAC,QAAQ,CAAC,CAO/F;AAED,4CAA4C;AAC5C,wBAAgB,WAAW,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,MAAM,CAAC,CAAC,EAAE,OAAO,cAAc,CAAC,QAAQ,CAAC,CAKlF"}
|
package/dist/random.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { ok } from 'neverthrow';
|
|
1
2
|
import { ValueException } from './exception.js';
|
|
2
|
-
import { ok } from './vendor/neverthrow.js';
|
|
3
3
|
/** Returns a random integer between `min` (inclusive) and `max` (not inclusive) */
|
|
4
4
|
export function randomInt(min, max) {
|
|
5
5
|
if (min >= max) {
|
package/dist/range.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import type { Result } from 'neverthrow';
|
|
1
2
|
import { ValueException } from './exception.js';
|
|
2
|
-
import type { Result } from './vendor/neverthrow.js';
|
|
3
3
|
/** Return an array of integers between 0 (inclusive) and `end` (not inclusive) */
|
|
4
4
|
export declare function range(end: number): Result<readonly number[], typeof ValueException.Instance>;
|
|
5
5
|
/** Return an array of integers between `start` (inclusive) and `end` (not inclusive) */
|
package/dist/range.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"range.d.ts","sourceRoot":"","sources":["../src/range.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"range.d.ts","sourceRoot":"","sources":["../src/range.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAEzC,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAEhD,kFAAkF;AAClF,wBAAgB,KAAK,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC,SAAS,MAAM,EAAE,EAAE,OAAO,cAAc,CAAC,QAAQ,CAAC,CAAC;AAE9F,wFAAwF;AACxF,wBAAgB,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC,SAAS,MAAM,EAAE,EAAE,OAAO,cAAc,CAAC,QAAQ,CAAC,CAAC"}
|
package/dist/range.js
CHANGED
package/dist/result.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
import { Result, ResultAsync } from '
|
|
1
|
+
import { Result, ResultAsync } from 'neverthrow';
|
|
2
2
|
export declare function asyncResultify<T, E>(fn: () => Promise<Result<T, E>>): ResultAsync<T, E>;
|
|
3
|
+
export declare function unwrap<T, E extends Error>(result: Result<T, E>): any;
|
|
3
4
|
//# sourceMappingURL=result.d.ts.map
|
package/dist/result.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"result.d.ts","sourceRoot":"","sources":["../src/result.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"result.d.ts","sourceRoot":"","sources":["../src/result.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAEjD,wBAAgB,cAAc,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,WAAW,CAAC,CAAC,EAAE,CAAC,CAAC,CAEvF;AAED,wBAAgB,MAAM,CAAC,CAAC,EAAE,CAAC,SAAS,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,GAAG,CAKpE"}
|
package/dist/result.js
CHANGED
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
import { Result, ResultAsync } from '
|
|
1
|
+
import { Result, ResultAsync } from 'neverthrow';
|
|
2
2
|
export function asyncResultify(fn) {
|
|
3
3
|
return new ResultAsync(fn());
|
|
4
4
|
}
|
|
5
|
+
export function unwrap(result) {
|
|
6
|
+
if (result.isErr()) {
|
|
7
|
+
throw result.error;
|
|
8
|
+
}
|
|
9
|
+
return result.value;
|
|
10
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"root":["../src/array.ts","../src/datetime.ts","../src/exception.ts","../src/http.ts","../src/index.ts","../src/json.ts","../src/number.ts","../src/object.ts","../src/random.ts","../src/range.ts","../src/result.ts","../src/string.ts","../src/types.ts","../src/zod.ts"
|
|
1
|
+
{"root":["../src/array.ts","../src/datetime.ts","../src/exception.ts","../src/http.ts","../src/index.ts","../src/json.ts","../src/number.ts","../src/object.ts","../src/random.ts","../src/range.ts","../src/result.ts","../src/string.ts","../src/types.ts","../src/zod.ts"],"version":"5.6.3"}
|
package/dist/zod.d.ts
CHANGED
|
@@ -1,11 +1,51 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { Result } from 'neverthrow';
|
|
2
|
+
import type { z as z3 } from 'zod/v3';
|
|
3
|
+
import { z as z4 } from 'zod/v4';
|
|
2
4
|
import { ValidationException } from './exception.js';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
5
|
+
type ZodIssueLike = {
|
|
6
|
+
[key: string]: any;
|
|
7
|
+
readonly code: string;
|
|
8
|
+
readonly message: string;
|
|
9
|
+
readonly path: PropertyKey[];
|
|
10
|
+
};
|
|
11
|
+
type ZodErrorLike = {
|
|
12
|
+
cause?: unknown;
|
|
13
|
+
issues: ZodIssueLike[];
|
|
14
|
+
name: string;
|
|
15
|
+
};
|
|
16
|
+
type ZodSafeParseSuccessLike<TOutput> = {
|
|
17
|
+
data: TOutput;
|
|
18
|
+
error?: never;
|
|
19
|
+
success: true;
|
|
20
|
+
};
|
|
21
|
+
type ZodSafeParseErrorLike = {
|
|
22
|
+
data?: never;
|
|
23
|
+
error: ZodErrorLike;
|
|
24
|
+
success: false;
|
|
25
|
+
};
|
|
26
|
+
type ZodSafeParseResultLike<T> = ZodSafeParseErrorLike | ZodSafeParseSuccessLike<T>;
|
|
27
|
+
type ZodTypeLike<TOutput, TInput = unknown> = {
|
|
28
|
+
[key: string]: any;
|
|
29
|
+
readonly _input: TInput;
|
|
30
|
+
readonly _output: TOutput;
|
|
31
|
+
safeParseAsync: (data: unknown) => Promise<ZodSafeParseResultLike<TOutput>>;
|
|
32
|
+
'~standard': {
|
|
33
|
+
[key: string]: any;
|
|
34
|
+
vendor: string;
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
declare function isZodTypeLike(arg: unknown): arg is ZodTypeLike<unknown>;
|
|
38
|
+
declare function isZodType(arg: unknown, options: {
|
|
39
|
+
version: 3;
|
|
40
|
+
}): arg is z3.ZodTypeAny;
|
|
41
|
+
declare function isZodType(arg: unknown, options: {
|
|
42
|
+
version: 4;
|
|
43
|
+
}): arg is z4.ZodType;
|
|
44
|
+
export declare const $BooleanLike: z4.ZodType<boolean>;
|
|
45
|
+
export declare const $NumberLike: z4.ZodType<number>;
|
|
46
|
+
export declare const $UrlLike: z4.ZodType<URL>;
|
|
47
|
+
export declare const $Uint8ArrayLike: z4.ZodType<Uint8Array>;
|
|
48
|
+
export declare function safeParse<TSchema extends z4.ZodTypeAny>(data: unknown, $Schema: TSchema): Result<z4.infer<TSchema>, typeof ValidationException.Instance>;
|
|
49
|
+
export { isZodType, isZodTypeLike };
|
|
50
|
+
export type { ZodErrorLike, ZodIssueLike, ZodSafeParseErrorLike, ZodSafeParseResultLike, ZodSafeParseSuccessLike, ZodTypeLike };
|
|
11
51
|
//# sourceMappingURL=zod.d.ts.map
|
package/dist/zod.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"zod.d.ts","sourceRoot":"","sources":["../src/zod.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"zod.d.ts","sourceRoot":"","sources":["../src/zod.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AACzC,OAAO,KAAK,EAAE,CAAC,IAAI,EAAE,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,EAAE,CAAC,IAAI,EAAE,EAAE,MAAM,QAAQ,CAAC;AAEjC,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAIrD,KAAK,YAAY,GAAG;IAClB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;IACnB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,IAAI,EAAE,WAAW,EAAE,CAAC;CAC9B,CAAC;AAEF,KAAK,YAAY,GAAG;IAClB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,MAAM,EAAE,YAAY,EAAE,CAAC;IACvB,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,KAAK,uBAAuB,CAAC,OAAO,IAAI;IACtC,IAAI,EAAE,OAAO,CAAC;IACd,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,OAAO,EAAE,IAAI,CAAC;CACf,CAAC;AAEF,KAAK,qBAA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AM,eAAe,EAAE,EAAE,CAAC,OAAO,CAAC,UAAU,CAO/C,CAAC;AAEL,wBAAgB,SAAS,CAAC,OAAO,SAAS,EAAE,CAAC,UAAU,EACrD,IAAI,EAAE,OAAO,EACb,OAAO,EAAE,OAAO,GACf,MAAM,CAAC,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,OAAO,mBAAmB,CAAC,QAAQ,CAAC,CAWhE;AAED,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,CAAC;AACpC,YAAY,EACV,YAAY,EACZ,YAAY,EACZ,qBAAqB,EACrB,sBAAsB,EACtB,uBAAuB,EACvB,WAAW,EACZ,CAAC"}
|
package/dist/zod.js
CHANGED
|
@@ -1,17 +1,37 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ok } from 'neverthrow';
|
|
2
|
+
import { z as z4 } from 'zod/v4';
|
|
2
3
|
import { ValidationException } from './exception.js';
|
|
3
4
|
import { isNumberLike, parseNumber } from './number.js';
|
|
4
|
-
import { isObject } from './object.js';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
import { isObject, isObjectLike, isPlainObject } from './object.js';
|
|
6
|
+
function isZodTypeLike(arg) {
|
|
7
|
+
if (!isObjectLike(arg)) {
|
|
8
|
+
return false;
|
|
9
|
+
}
|
|
10
|
+
const standardSchema = Reflect.get(arg, '~standard');
|
|
11
|
+
return isPlainObject(standardSchema) && standardSchema.vendor === 'zod';
|
|
12
|
+
}
|
|
13
|
+
function isZodV3Type(arg) {
|
|
8
14
|
let prototype = null;
|
|
9
15
|
if (isObject(arg) && isObject(arg.constructor)) {
|
|
10
16
|
prototype = Reflect.getPrototypeOf(arg.constructor);
|
|
11
17
|
}
|
|
12
18
|
return Boolean(prototype && Reflect.get(prototype, 'name') === 'ZodType');
|
|
13
19
|
}
|
|
14
|
-
|
|
20
|
+
function isZodV4Type(arg) {
|
|
21
|
+
if (!isZodTypeLike(arg)) {
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
const zod = arg._zod;
|
|
25
|
+
if (!isPlainObject(zod)) {
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
const version = zod.version;
|
|
29
|
+
return isPlainObject(version) && version.major === 4;
|
|
30
|
+
}
|
|
31
|
+
function isZodType(arg, options) {
|
|
32
|
+
return options.version === 3 ? isZodV3Type(arg) : isZodV4Type(arg);
|
|
33
|
+
}
|
|
34
|
+
export const $BooleanLike = z4.preprocess((arg) => {
|
|
15
35
|
if (typeof arg === 'string') {
|
|
16
36
|
if (arg.trim().toLowerCase() === 'true') {
|
|
17
37
|
return true;
|
|
@@ -21,24 +41,24 @@ export const $BooleanLike = z.preprocess((arg) => {
|
|
|
21
41
|
}
|
|
22
42
|
}
|
|
23
43
|
return arg;
|
|
24
|
-
},
|
|
25
|
-
export const $NumberLike =
|
|
44
|
+
}, z4.boolean());
|
|
45
|
+
export const $NumberLike = z4.preprocess((arg) => {
|
|
26
46
|
if (isNumberLike(arg)) {
|
|
27
47
|
return parseNumber(arg);
|
|
28
48
|
}
|
|
29
49
|
return arg;
|
|
30
|
-
},
|
|
31
|
-
export const $UrlLike =
|
|
50
|
+
}, z4.number());
|
|
51
|
+
export const $UrlLike = z4.preprocess((arg) => {
|
|
32
52
|
if (arg instanceof URL) {
|
|
33
53
|
return arg.href;
|
|
34
54
|
}
|
|
35
55
|
return arg;
|
|
36
|
-
},
|
|
56
|
+
}, z4
|
|
37
57
|
.string()
|
|
38
58
|
.url()
|
|
39
59
|
.transform((arg) => new URL(arg)));
|
|
40
|
-
export const $Uint8ArrayLike =
|
|
41
|
-
.union([
|
|
60
|
+
export const $Uint8ArrayLike = z4
|
|
61
|
+
.union([z4.array(z4.number().int().min(0).max(255)), z4.instanceof(Uint8Array), z4.instanceof(ArrayBuffer)])
|
|
42
62
|
.transform((arg) => {
|
|
43
63
|
if (!(arg instanceof Uint8Array)) {
|
|
44
64
|
return new Uint8Array(arg);
|
|
@@ -57,3 +77,4 @@ export function safeParse(data, $Schema) {
|
|
|
57
77
|
}
|
|
58
78
|
return ok(result.data);
|
|
59
79
|
}
|
|
80
|
+
export { isZodType, isZodTypeLike };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@douglasneuroinformatics/libjs",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "3.0.0",
|
|
5
5
|
"packageManager": "pnpm@10.3.0",
|
|
6
6
|
"description": "A collection of utility functions and types for Node.js and the browser",
|
|
7
7
|
"author": "Joshua Unrau",
|
|
@@ -18,10 +18,6 @@
|
|
|
18
18
|
".": {
|
|
19
19
|
"types": "./dist/index.d.ts",
|
|
20
20
|
"import": "./dist/index.js"
|
|
21
|
-
},
|
|
22
|
-
"./vendor/*": {
|
|
23
|
-
"types": "./dist/vendor/*.d.ts",
|
|
24
|
-
"import": "./dist/vendor/*.js"
|
|
25
21
|
}
|
|
26
22
|
},
|
|
27
23
|
"files": [
|
|
@@ -39,7 +35,7 @@
|
|
|
39
35
|
},
|
|
40
36
|
"peerDependencies": {
|
|
41
37
|
"neverthrow": "^8.2.0",
|
|
42
|
-
"zod": "^3.
|
|
38
|
+
"zod": "^3.25.x"
|
|
43
39
|
},
|
|
44
40
|
"dependencies": {
|
|
45
41
|
"clean-stack": "^5.2.0",
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { Err, Ok } from 'neverthrow';
|
|
2
|
-
declare module 'neverthrow' {
|
|
3
|
-
interface Err<T, E> {
|
|
4
|
-
unwrap(): T;
|
|
5
|
-
}
|
|
6
|
-
interface Ok<T, E> {
|
|
7
|
-
unwrap(): T;
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
export { Err, Ok };
|
|
11
|
-
export { err, errAsync, fromAsyncThrowable, fromPromise, fromSafePromise, fromThrowable, ok, okAsync, Result, ResultAsync, safeTry } from 'neverthrow';
|
|
12
|
-
//# sourceMappingURL=neverthrow.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"neverthrow.d.ts","sourceRoot":"","sources":["../../src/vendor/neverthrow.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,GAAG,EAAE,EAAE,EAAU,MAAM,YAAY,CAAC;AAE7C,OAAO,QAAQ,YAAY,CAAC;IAC1B,UAAU,GAAG,CAAC,CAAC,EAAE,CAAC;QAChB,MAAM,IAAI,CAAC,CAAC;KACb;IACD,UAAU,EAAE,CAAC,CAAC,EAAE,CAAC;QACf,MAAM,IAAI,CAAC,CAAC;KACb;CACF;AAYD,OAAO,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC;AAEnB,OAAO,EACL,GAAG,EACH,QAAQ,EACR,kBAAkB,EAClB,WAAW,EACX,eAAe,EACf,aAAa,EACb,EAAE,EACF,OAAO,EACP,MAAM,EACN,WAAW,EACX,OAAO,EACR,MAAM,YAAY,CAAC"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/only-throw-error */
|
|
2
|
-
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
3
|
-
/* eslint-disable @typescript-eslint/consistent-type-definitions */
|
|
4
|
-
import { Err, Ok, Result } from 'neverthrow';
|
|
5
|
-
function unwrap() {
|
|
6
|
-
if (this.isErr()) {
|
|
7
|
-
throw this.error;
|
|
8
|
-
}
|
|
9
|
-
return this.value;
|
|
10
|
-
}
|
|
11
|
-
Err.prototype.unwrap = unwrap;
|
|
12
|
-
Ok.prototype.unwrap = unwrap;
|
|
13
|
-
export { Err, Ok };
|
|
14
|
-
export { err, errAsync, fromAsyncThrowable, fromPromise, fromSafePromise, fromThrowable, ok, okAsync, Result, ResultAsync, safeTry } from 'neverthrow';
|