@ts-runtypes/core 0.9.0 → 0.9.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/dist/cjs/createRTFBinary.d.ts +36 -0
- package/dist/cjs/createRTFunctions.d.ts +85 -0
- package/dist/cjs/createRTFunctions.js +5 -0
- package/dist/cjs/enrich/createFriendlyText.d.ts +25 -0
- package/dist/cjs/enrich/friendlyText.d.ts +50 -0
- package/dist/cjs/enrich/mockData.d.ts +46 -0
- package/dist/cjs/formats/bigintFormats.d.ts +37 -0
- package/dist/cjs/formats/datetime/dateFormats.d.ts +10 -0
- package/dist/cjs/formats/datetime/dateTime-pure-fns.d.ts +1 -0
- package/dist/cjs/formats/datetime/dateTimeParams.d.ts +10 -0
- package/dist/cjs/formats/datetime/stringDateTimeFormats.d.ts +33 -0
- package/dist/cjs/formats/datetime/temporalFormats.d.ts +70 -0
- package/dist/cjs/formats/datetime/temporalFormats.js +1 -1
- package/dist/cjs/formats/index.d.ts +16 -0
- package/dist/cjs/formats/numberFormats.d.ts +77 -0
- package/dist/cjs/formats/scalars.d.ts +32 -0
- package/dist/cjs/formats/string/string-formats-pure-fns.d.ts +1 -0
- package/dist/cjs/formats/string/string-patterns.d.ts +59 -0
- package/dist/cjs/formats/string/stringFormats.d.ts +273 -0
- package/dist/cjs/getRunType.d.ts +4 -0
- package/dist/cjs/index.d.ts +29 -0
- package/dist/cjs/index.js +3 -1
- package/dist/cjs/markers.d.ts +17 -0
- package/dist/cjs/mocking/binarySize.d.ts +10 -0
- package/dist/cjs/mocking/constants.mock.d.ts +7 -0
- package/dist/cjs/mocking/createMockData.d.ts +5 -0
- package/dist/cjs/mocking/mockBigIntFormat.d.ts +1 -0
- package/dist/cjs/mocking/mockDateTimeBounds.d.ts +12 -0
- package/dist/cjs/mocking/mockInvalid.d.ts +14 -0
- package/dist/cjs/mocking/mockNumberFormat.d.ts +1 -0
- package/dist/cjs/mocking/mockOversized.d.ts +3 -0
- package/dist/cjs/mocking/mockRegistry.d.ts +5 -0
- package/dist/cjs/mocking/mockStringFormat.d.ts +1 -0
- package/dist/cjs/mocking/mockStringFormat.js +8 -3
- package/dist/cjs/mocking/mockTemporal.d.ts +12 -0
- package/dist/cjs/mocking/mockType.d.ts +3 -0
- package/dist/cjs/mocking/mockType.js +2 -2
- package/dist/cjs/mocking/mockTypes.d.ts +58 -0
- package/dist/cjs/mocking/mockUtils.d.ts +10 -0
- package/dist/cjs/overrideRTFunctions.d.ts +15 -0
- package/dist/cjs/runTypeKind.d.ts +61 -0
- package/dist/cjs/runtypes/builderCore.d.ts +7 -0
- package/dist/cjs/runtypes/builderTypes.d.ts +49 -0
- package/dist/cjs/runtypes/circular.d.ts +11 -0
- package/dist/cjs/runtypes/classSerializerRegistry.d.ts +28 -0
- package/dist/cjs/runtypes/classSerializerRegistry.js +65 -19
- package/dist/cjs/runtypes/dataOnly.d.ts +13 -0
- package/dist/cjs/runtypes/dataView.d.ts +103 -0
- package/dist/cjs/runtypes/entryTuple.d.ts +90 -0
- package/dist/cjs/runtypes/entryTuple.js +1 -0
- package/dist/cjs/runtypes/formatAnnotation.d.ts +4 -0
- package/dist/cjs/runtypes/formatPattern.d.ts +17 -0
- package/dist/cjs/runtypes/pure-fns-utils.d.ts +6 -0
- package/dist/cjs/runtypes/pureFn.d.ts +4 -0
- package/dist/cjs/runtypes/rtUtils.d.ts +40 -0
- package/dist/cjs/runtypes/rtUtils.js +15 -2
- package/dist/cjs/runtypes/typeFormat.d.ts +8 -0
- package/dist/cjs/runtypes/types.d.ts +110 -0
- package/dist/cjs/schema/atomic.d.ts +12 -0
- package/dist/cjs/schema/compose.d.ts +36 -0
- package/dist/cjs/schema/index.d.ts +5 -0
- package/dist/cjs/schema/static.d.ts +87 -0
- package/dist/cjs/schema/utility.d.ts +12 -0
- package/dist/cjs/standard/createStandardSchema.d.ts +17 -0
- package/dist/cjs/standard/issueMapping.d.ts +12 -0
- package/dist/cjs/standard/spec.d.ts +30 -0
- package/dist/createRTFunctions.d.ts +23 -0
- package/dist/createRTFunctions.d.ts.map +1 -1
- package/dist/createRTFunctions.js +4 -0
- package/dist/createRTFunctions.js.map +1 -1
- package/dist/formats/datetime/temporalFormats.d.ts +39 -27
- package/dist/formats/datetime/temporalFormats.d.ts.map +1 -1
- package/dist/formats/datetime/temporalFormats.js +1 -1
- package/dist/formats/datetime/temporalFormats.js.map +1 -1
- package/dist/formats/string/stringFormats.d.ts +1 -0
- package/dist/formats/string/stringFormats.d.ts.map +1 -1
- package/dist/formats/string/stringFormats.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/markers.d.ts +2 -2
- package/dist/markers.d.ts.map +1 -1
- package/dist/markers.js.map +1 -1
- package/dist/mocking/mockStringFormat.d.ts.map +1 -1
- package/dist/mocking/mockStringFormat.js +8 -3
- package/dist/mocking/mockStringFormat.js.map +1 -1
- package/dist/mocking/mockType.js +2 -2
- package/dist/mocking/mockType.js.map +1 -1
- package/dist/runtypes/builderTypes.d.ts +3 -0
- package/dist/runtypes/builderTypes.d.ts.map +1 -1
- package/dist/runtypes/classSerializerRegistry.d.ts +1 -1
- package/dist/runtypes/classSerializerRegistry.d.ts.map +1 -1
- package/dist/runtypes/classSerializerRegistry.js +65 -19
- package/dist/runtypes/classSerializerRegistry.js.map +1 -1
- package/dist/runtypes/dataOnly.d.ts.map +1 -1
- package/dist/runtypes/entryTuple.d.ts +2 -2
- package/dist/runtypes/entryTuple.d.ts.map +1 -1
- package/dist/runtypes/entryTuple.js +1 -0
- package/dist/runtypes/entryTuple.js.map +1 -1
- package/dist/runtypes/rtUtils.d.ts +2 -1
- package/dist/runtypes/rtUtils.d.ts.map +1 -1
- package/dist/runtypes/rtUtils.js +15 -2
- package/dist/runtypes/rtUtils.js.map +1 -1
- package/dist/runtypes/types.d.ts +1 -0
- package/dist/runtypes/types.d.ts.map +1 -1
- package/package.json +37 -32
- package/src/createRTFBinary.ts +294 -0
- package/src/createRTFunctions.ts +488 -0
- package/src/enrich/createFriendlyText.ts +474 -0
- package/src/enrich/friendlyText.ts +169 -0
- package/src/enrich/mockData.ts +74 -0
- package/src/formats/bigintFormats.ts +66 -0
- package/src/formats/datetime/dateFormats.ts +44 -0
- package/src/formats/datetime/dateTime-pure-fns.ts +370 -0
- package/src/formats/datetime/dateTimeParams.ts +41 -0
- package/src/formats/datetime/stringDateTimeFormats.ts +69 -0
- package/src/formats/datetime/temporalFormats.ts +193 -0
- package/src/formats/index.ts +86 -0
- package/src/formats/numberFormats.ts +106 -0
- package/src/formats/scalars.ts +152 -0
- package/src/formats/string/string-formats-pure-fns.ts +134 -0
- package/src/formats/string/string-patterns.ts +86 -0
- package/src/formats/string/stringFormats.ts +425 -0
- package/src/getRunType.ts +55 -0
- package/src/index.ts +248 -0
- package/src/markers.ts +219 -0
- package/src/mocking/binarySize.ts +77 -0
- package/src/mocking/constants.mock.ts +93 -0
- package/src/mocking/createMockData.ts +85 -0
- package/src/mocking/mockBigIntFormat.ts +62 -0
- package/src/mocking/mockDateTimeBounds.ts +389 -0
- package/src/mocking/mockInvalid.ts +320 -0
- package/src/mocking/mockNumberFormat.ts +66 -0
- package/src/mocking/mockOversized.ts +112 -0
- package/src/mocking/mockRegistry.ts +29 -0
- package/src/mocking/mockStringFormat.ts +277 -0
- package/src/mocking/mockTemporal.ts +347 -0
- package/src/mocking/mockType.ts +578 -0
- package/src/mocking/mockTypes.ts +152 -0
- package/src/mocking/mockUtils.ts +64 -0
- package/src/overrideRTFunctions.ts +118 -0
- package/src/runTypeKind.ts +86 -0
- package/src/runtypes/builderCore.ts +84 -0
- package/src/runtypes/builderTypes.ts +173 -0
- package/src/runtypes/circular.ts +318 -0
- package/src/runtypes/classSerializerRegistry.ts +305 -0
- package/src/runtypes/dataOnly.ts +206 -0
- package/src/runtypes/dataView.ts +784 -0
- package/src/runtypes/entryTuple.ts +821 -0
- package/src/runtypes/formatAnnotation.ts +8 -0
- package/src/runtypes/formatPattern.ts +76 -0
- package/src/runtypes/pure-fns-utils.ts +118 -0
- package/src/runtypes/pureFn.ts +90 -0
- package/src/runtypes/rtUtils.ts +296 -0
- package/src/runtypes/typeFormat.ts +62 -0
- package/src/runtypes/types.ts +236 -0
- package/src/schema/atomic.ts +135 -0
- package/src/schema/compose.ts +423 -0
- package/src/schema/index.ts +88 -0
- package/src/schema/static.ts +292 -0
- package/src/schema/utility.ts +109 -0
- package/src/standard/createStandardSchema.ts +117 -0
- package/src/standard/issueMapping.ts +78 -0
- package/src/standard/spec.ts +74 -0
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { RunType } from './runtypes/types.ts';
|
|
2
|
+
import { type DataViewSerializer, type DataViewDeserializer, type BinaryInput } from './runtypes/dataView.ts';
|
|
3
|
+
import type { InjectTypeFnArgs } from './index.ts';
|
|
4
|
+
import type { DataOnly } from './runtypes/dataOnly.ts';
|
|
5
|
+
export type ToBinaryFn = (value: unknown, Ser: DataViewSerializer) => DataViewSerializer;
|
|
6
|
+
export type FromBinaryFn<T = unknown> = (ret: unknown, Des: DataViewDeserializer) => T;
|
|
7
|
+
export type BinaryEncoderFn = (value: unknown) => Uint8Array;
|
|
8
|
+
export type BinaryEncoderSizeFn = (value: unknown, size: number) => Uint8Array;
|
|
9
|
+
export type BinaryEncoderIntoFn = (value: unknown, into: ArrayBuffer) => Uint8Array;
|
|
10
|
+
type InitialSizeOptions = BinaryEncoderOptions & {
|
|
11
|
+
sizeStrategy: 'initialSize';
|
|
12
|
+
};
|
|
13
|
+
type IntoBufferOptions = BinaryEncoderOptions & {
|
|
14
|
+
sizeStrategy: 'intoBuffer';
|
|
15
|
+
};
|
|
16
|
+
export type BinaryDecoderFn<T = unknown> = (input: BinaryInput | DataViewDeserializer) => T;
|
|
17
|
+
export interface BinaryEncoderOptions {
|
|
18
|
+
cacheKey?: string;
|
|
19
|
+
rejectCircularRefs?: boolean;
|
|
20
|
+
sizeStrategy?: 'dynamic' | 'precalculate' | 'initialSize' | 'intoBuffer';
|
|
21
|
+
}
|
|
22
|
+
export interface BinaryDecoderOptions {
|
|
23
|
+
cacheKey?: string;
|
|
24
|
+
}
|
|
25
|
+
export declare function createBinaryEncoder<T>(schema: RunType<T>, options: InitialSizeOptions, id?: InjectTypeFnArgs<T, 'tb'>): BinaryEncoderSizeFn;
|
|
26
|
+
export declare function createBinaryEncoder<T>(val: T | undefined, options: InitialSizeOptions, id?: InjectTypeFnArgs<T, 'tb'>): BinaryEncoderSizeFn;
|
|
27
|
+
export declare function createBinaryEncoder<T>(schema: RunType<T>, options: IntoBufferOptions, id?: InjectTypeFnArgs<T, 'tb'>): BinaryEncoderIntoFn;
|
|
28
|
+
export declare function createBinaryEncoder<T>(val: T | undefined, options: IntoBufferOptions, id?: InjectTypeFnArgs<T, 'tb'>): BinaryEncoderIntoFn;
|
|
29
|
+
export declare function createBinaryEncoder<T>(schema: RunType<T>, options?: BinaryEncoderOptions, id?: InjectTypeFnArgs<T, 'tb'>): BinaryEncoderFn;
|
|
30
|
+
export declare function createBinaryEncoder<T>(val?: T, options?: BinaryEncoderOptions, id?: InjectTypeFnArgs<T, 'tb'>): BinaryEncoderFn;
|
|
31
|
+
export type BinarySizerFn = (value: unknown) => number;
|
|
32
|
+
export declare function createBinarySizer<T>(schema: RunType<T>, id?: InjectTypeFnArgs<T, 'tb'>): BinarySizerFn;
|
|
33
|
+
export declare function createBinarySizer<T>(val?: T, id?: InjectTypeFnArgs<T, 'tb'>): BinarySizerFn;
|
|
34
|
+
export declare function createBinaryDecoder<T>(schema: RunType<T>, options?: BinaryDecoderOptions, id?: InjectTypeFnArgs<T, 'fb'>): BinaryDecoderFn<DataOnly<T>>;
|
|
35
|
+
export declare function createBinaryDecoder<T>(val?: T, options?: BinaryDecoderOptions, id?: InjectTypeFnArgs<T, 'fb'>): BinaryDecoderFn<DataOnly<T>>;
|
|
36
|
+
export {};
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import type { RunType } from './runtypes/types.ts';
|
|
2
|
+
import type { DataOnly } from './runtypes/dataOnly.ts';
|
|
3
|
+
import type { CompTimeFnArgs, InjectTypeFnArgs } from './index.ts';
|
|
4
|
+
import type { ToBinaryFn, FromBinaryFn } from './createRTFBinary.ts';
|
|
5
|
+
export interface ValidateOptions {
|
|
6
|
+
noLiterals?: boolean;
|
|
7
|
+
noIsArrayCheck?: boolean;
|
|
8
|
+
rejectCircularRefs?: boolean;
|
|
9
|
+
}
|
|
10
|
+
export type ValidateFn<T = unknown> = (value: unknown) => value is DataOnly<T>;
|
|
11
|
+
export interface RTPathSegment {
|
|
12
|
+
key: number;
|
|
13
|
+
failed?: 'mapKey' | 'mapValue' | 'setKey';
|
|
14
|
+
}
|
|
15
|
+
export type RTValidationErrorPathSegment = string | number | RTPathSegment;
|
|
16
|
+
export interface TypeFormatError {
|
|
17
|
+
name: string;
|
|
18
|
+
val: RTValidationErrorPathSegment | boolean | bigint | (RTValidationErrorPathSegment | boolean | bigint)[];
|
|
19
|
+
formatPath: (string | number)[];
|
|
20
|
+
isCurrency?: boolean;
|
|
21
|
+
}
|
|
22
|
+
export interface RTValidationError {
|
|
23
|
+
path: RTValidationErrorPathSegment[];
|
|
24
|
+
expected: string;
|
|
25
|
+
format?: TypeFormatError;
|
|
26
|
+
}
|
|
27
|
+
export type GetValidationErrorsFn = (value: unknown, path?: RTValidationErrorPathSegment[], errors?: RTValidationError[]) => RTValidationError[];
|
|
28
|
+
export interface HasUnknownKeysOptions {
|
|
29
|
+
checkNonRTProps?: boolean;
|
|
30
|
+
}
|
|
31
|
+
export type HasUnknownKeysFn = (value: unknown, options?: HasUnknownKeysOptions) => boolean;
|
|
32
|
+
export type StripUnknownKeysFn = (value: unknown) => unknown;
|
|
33
|
+
export type UnknownKeyErrorsFn = (value: unknown, path?: RTValidationErrorPathSegment[], errors?: RTValidationError[]) => RTValidationError[];
|
|
34
|
+
export type UnknownKeysToUndefinedFn = (value: unknown) => unknown;
|
|
35
|
+
export type FormatTransformValue<T> = T extends string ? string : T extends number ? number : T extends boolean ? boolean : T extends readonly (infer E)[] ? FormatTransformValue<E>[] : T extends object ? {
|
|
36
|
+
[K in keyof T]: FormatTransformValue<T[K]>;
|
|
37
|
+
} : T;
|
|
38
|
+
export type FormatTransformFn<T> = (value: FormatTransformValue<T>) => FormatTransformValue<T>;
|
|
39
|
+
export type PrepareForJsonFn = (value: unknown) => unknown;
|
|
40
|
+
export type RestoreFromJsonFn = (value: unknown) => unknown;
|
|
41
|
+
export type StringifyJsonFn = (value: unknown) => string | undefined;
|
|
42
|
+
export type JsonEncoderFn = (value: unknown) => string | undefined;
|
|
43
|
+
export type JsonDecoderFn<T = unknown> = (serialized: string) => T;
|
|
44
|
+
export type JsonEncoderStrategy = 'clone' | 'mutate' | 'direct' | 'compact';
|
|
45
|
+
export type JsonEncoderOptions = {
|
|
46
|
+
strategy?: JsonEncoderStrategy;
|
|
47
|
+
rejectCircularRefs?: boolean;
|
|
48
|
+
};
|
|
49
|
+
export type JsonDecoderStrategy = 'strip' | 'preserve' | 'compact';
|
|
50
|
+
export type JsonDecoderOptions = {
|
|
51
|
+
strategy?: JsonDecoderStrategy;
|
|
52
|
+
};
|
|
53
|
+
export declare const createValidate: (<T>(schema: RunType<T>, options?: CompTimeFnArgs<ValidateOptions>, id?: InjectTypeFnArgs<T, "val">) => ValidateFn<T>) & (<T>(val?: T, options?: CompTimeFnArgs<ValidateOptions>, id?: InjectTypeFnArgs<T, "val">) => ValidateFn<T>);
|
|
54
|
+
export declare const createGetValidationErrors: (<T>(schema: RunType<T>, options?: CompTimeFnArgs<ValidateOptions>, id?: InjectTypeFnArgs<T, "verr">) => GetValidationErrorsFn) & (<T>(val?: T, options?: CompTimeFnArgs<ValidateOptions>, id?: InjectTypeFnArgs<T, "verr">) => GetValidationErrorsFn);
|
|
55
|
+
export declare const createHasUnknownKeys: (<T>(schema: RunType<T>, id?: InjectTypeFnArgs<T, "huk">) => HasUnknownKeysFn) & (<T>(val?: T, id?: InjectTypeFnArgs<T, "huk">) => HasUnknownKeysFn);
|
|
56
|
+
export declare const createStripUnknownKeys: (<T>(schema: RunType<T>, id?: InjectTypeFnArgs<T, "suk">) => StripUnknownKeysFn) & (<T>(val?: T, id?: InjectTypeFnArgs<T, "suk">) => StripUnknownKeysFn);
|
|
57
|
+
export declare const createUnknownKeyErrors: (<T>(schema: RunType<T>, id?: InjectTypeFnArgs<T, "uke">) => UnknownKeyErrorsFn) & (<T>(val?: T, id?: InjectTypeFnArgs<T, "uke">) => UnknownKeyErrorsFn);
|
|
58
|
+
export declare const createUnknownKeysToUndefined: (<T>(schema: RunType<T>, id?: InjectTypeFnArgs<T, "uku">) => UnknownKeysToUndefinedFn) & (<T>(val?: T, id?: InjectTypeFnArgs<T, "uku">) => UnknownKeysToUndefinedFn);
|
|
59
|
+
export declare const createFormatTransform: (<T>(schema: RunType<T>, id?: InjectTypeFnArgs<T, "fmt">) => FormatTransformFn<T>) & (<T>(val?: T, id?: InjectTypeFnArgs<T, "fmt">) => FormatTransformFn<T>);
|
|
60
|
+
export declare function createJsonEncoder<T>(schema: RunType<T>, options?: CompTimeFnArgs<JsonEncoderOptions>, id?: InjectTypeFnArgs<T, 'jsonEncoder'>): JsonEncoderFn;
|
|
61
|
+
export declare function createJsonEncoder<T>(val?: T, options?: CompTimeFnArgs<JsonEncoderOptions>, id?: InjectTypeFnArgs<T, 'jsonEncoder'>): JsonEncoderFn;
|
|
62
|
+
export declare function createJsonDecoder<T>(schema: RunType<T>, options?: CompTimeFnArgs<JsonDecoderOptions>, id?: InjectTypeFnArgs<T, 'jsonDecoder'>): JsonDecoderFn<DataOnly<T>>;
|
|
63
|
+
export declare function createJsonDecoder<T>(val?: T, options?: CompTimeFnArgs<JsonDecoderOptions>, id?: InjectTypeFnArgs<T, 'jsonDecoder'>): JsonDecoderFn<DataOnly<T>>;
|
|
64
|
+
export interface RTFunctionByKey {
|
|
65
|
+
val: ValidateFn;
|
|
66
|
+
verr: GetValidationErrorsFn;
|
|
67
|
+
huk: HasUnknownKeysFn;
|
|
68
|
+
suk: StripUnknownKeysFn;
|
|
69
|
+
uke: UnknownKeyErrorsFn;
|
|
70
|
+
uku: UnknownKeysToUndefinedFn;
|
|
71
|
+
fmt: FormatTransformFn<unknown>;
|
|
72
|
+
jsonEncoder: JsonEncoderFn;
|
|
73
|
+
jsonDecoder: JsonDecoderFn;
|
|
74
|
+
tb: ToBinaryFn;
|
|
75
|
+
fb: FromBinaryFn;
|
|
76
|
+
pj: PrepareForJsonFn;
|
|
77
|
+
pjs: PrepareForJsonFn;
|
|
78
|
+
rj: RestoreFromJsonFn;
|
|
79
|
+
sj: StringifyJsonFn;
|
|
80
|
+
ukuw: RestoreFromJsonFn;
|
|
81
|
+
cj: PrepareForJsonFn;
|
|
82
|
+
cjr: RestoreFromJsonFn;
|
|
83
|
+
}
|
|
84
|
+
export type RTFunctionKey = keyof RTFunctionByKey;
|
|
85
|
+
export declare function getRTFunction<K extends RTFunctionKey>(injected: unknown, fallback?: RTFunctionByKey[K]): RTFunctionByKey[K];
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.createFormatTransform = exports.createUnknownKeysToUndefined = exports.createUnknownKeyErrors = exports.createStripUnknownKeys = exports.createHasUnknownKeys = exports.createGetValidationErrors = exports.createValidate = void 0;
|
|
4
4
|
exports.createJsonEncoder = createJsonEncoder;
|
|
5
5
|
exports.createJsonDecoder = createJsonDecoder;
|
|
6
|
+
exports.getRTFunction = getRTFunction;
|
|
6
7
|
const rtUtils_ts_1 = require("./runtypes/rtUtils.js");
|
|
7
8
|
const entryTuple_ts_1 = require("./runtypes/entryTuple.js");
|
|
8
9
|
function resolveTupleEntry(fnName, identityFn, val, args, rejectCircularRefs) {
|
|
@@ -36,3 +37,7 @@ function createJsonEncoder(valOrSchema, options, id) {
|
|
|
36
37
|
function createJsonDecoder(valOrSchema, options, id) {
|
|
37
38
|
return resolveTupleEntry('createJsonDecoder', jsonParseFallback, valOrSchema, id);
|
|
38
39
|
}
|
|
40
|
+
function getRTFunction(injected, fallback) {
|
|
41
|
+
const identityFn = (fallback ?? ((value) => value));
|
|
42
|
+
return (0, entryTuple_ts_1.resolveEntryTupleFn)('getRTFunction', identityFn, undefined, injected);
|
|
43
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { RTValidationError, RTValidationErrorPathSegment } from '../createRTFunctions.ts';
|
|
2
|
+
import type { FriendlyText } from './friendlyText.ts';
|
|
3
|
+
export interface FriendlyMessage {
|
|
4
|
+
path: string;
|
|
5
|
+
label: string;
|
|
6
|
+
message: string;
|
|
7
|
+
}
|
|
8
|
+
export interface FriendlyRenderer {
|
|
9
|
+
label(path: string | RTValidationErrorPathSegment[]): string;
|
|
10
|
+
errors(errs: RTValidationError[]): FriendlyMessage[];
|
|
11
|
+
}
|
|
12
|
+
export declare function createFriendlyText<T>(map: FriendlyText<T>): FriendlyRenderer;
|
|
13
|
+
export interface FriendlyI18nOptions<T> {
|
|
14
|
+
locale: string | {
|
|
15
|
+
readonly value: string;
|
|
16
|
+
};
|
|
17
|
+
translations: Partial<Record<string, FriendlyText<T>>>;
|
|
18
|
+
currency?: string | {
|
|
19
|
+
readonly value: string;
|
|
20
|
+
};
|
|
21
|
+
sourceLocale?: string;
|
|
22
|
+
strict?: boolean;
|
|
23
|
+
}
|
|
24
|
+
export declare function resolveLocale<T>(locale: string, translations: Partial<Record<string, FriendlyText<T>>>): string | undefined;
|
|
25
|
+
export declare function createFriendlyTextI18n<T>(source: FriendlyText<T>, options: FriendlyI18nOptions<T>): FriendlyRenderer;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
export type FriendlyTemplate = string;
|
|
2
|
+
export type PluralCategory = 'zero' | 'one' | 'two' | 'few' | 'many' | 'other';
|
|
3
|
+
export type PluralTemplate = {
|
|
4
|
+
other: FriendlyTemplate;
|
|
5
|
+
} & Partial<Record<PluralCategory, FriendlyTemplate>>;
|
|
6
|
+
export type TemplateLeaf = FriendlyTemplate | PluralTemplate;
|
|
7
|
+
type NonFailingParams = 'isCurrency' | 'mockSamples' | 'trim' | 'lowercase' | 'uppercase' | 'capitalize' | 'replace' | 'replaceAll';
|
|
8
|
+
type CountBearingKeys = 'minLength' | 'maxLength' | 'min' | 'max' | 'lt' | 'gt';
|
|
9
|
+
type ConstraintTemplates<P> = {
|
|
10
|
+
type: FriendlyTemplate;
|
|
11
|
+
} & {
|
|
12
|
+
[K in Exclude<keyof P & string, NonFailingParams>]: K extends CountBearingKeys ? TemplateLeaf : FriendlyTemplate;
|
|
13
|
+
} & {
|
|
14
|
+
rt$default?: never;
|
|
15
|
+
};
|
|
16
|
+
type DefaultOnlyTemplates = {
|
|
17
|
+
rt$default: FriendlyTemplate;
|
|
18
|
+
type?: never;
|
|
19
|
+
};
|
|
20
|
+
type BareTemplates = DefaultOnlyTemplates | ({
|
|
21
|
+
type: FriendlyTemplate;
|
|
22
|
+
} & {
|
|
23
|
+
rt$default?: never;
|
|
24
|
+
});
|
|
25
|
+
export type ErrorTemplates<F = never> = [F] extends [never] ? BareTemplates : F extends {
|
|
26
|
+
readonly __rtFormatParams?: infer P;
|
|
27
|
+
} ? [NonNullable<P>] extends [object] ? DefaultOnlyTemplates | ConstraintTemplates<NonNullable<P>> : BareTemplates : BareTemplates;
|
|
28
|
+
export interface FriendlyMeta<F = never> {
|
|
29
|
+
rt$label: string;
|
|
30
|
+
rt$errors: ErrorTemplates<F>;
|
|
31
|
+
rt$typeName?: string;
|
|
32
|
+
}
|
|
33
|
+
type FriendlyLeaf = string | number | boolean | bigint | null | undefined | Date | RegExp;
|
|
34
|
+
type _FriendlyDepth = [never, 0, 1, 2, 3, 4, 5, 6, 7, 8];
|
|
35
|
+
export type FriendlyNode<T, Depth extends number = 8> = Depth extends 0 ? FriendlyMeta : T extends FriendlyLeaf ? FriendlyMeta<T> : T extends ReadonlyMap<any, any> ? T extends ReadonlyMap<infer K, infer V> ? FriendlyMeta & {
|
|
36
|
+
rt$keys: FriendlyNode<K, _FriendlyDepth[Depth]>;
|
|
37
|
+
rt$values: FriendlyNode<V, _FriendlyDepth[Depth]>;
|
|
38
|
+
} : FriendlyMeta : T extends ReadonlySet<any> ? T extends ReadonlySet<infer U> ? FriendlyMeta & {
|
|
39
|
+
rt$values: FriendlyNode<U, _FriendlyDepth[Depth]>;
|
|
40
|
+
} : FriendlyMeta : T extends readonly unknown[] ? number extends T['length'] ? FriendlyMeta & {
|
|
41
|
+
rt$items: FriendlyNode<T[number], _FriendlyDepth[Depth]>;
|
|
42
|
+
} : FriendlyMeta & {
|
|
43
|
+
rt$slots: {
|
|
44
|
+
[K in keyof T]: FriendlyNode<T[K], _FriendlyDepth[Depth]>;
|
|
45
|
+
};
|
|
46
|
+
} : T extends object ? FriendlyMeta & {
|
|
47
|
+
[K in keyof T]-?: FriendlyNode<T[K], _FriendlyDepth[Depth]>;
|
|
48
|
+
} : FriendlyMeta;
|
|
49
|
+
export type FriendlyText<T> = FriendlyNode<T>;
|
|
50
|
+
export {};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
type _MockDepth = [never, 0, 1, 2, 3, 4, 5, 6, 7, 8];
|
|
2
|
+
export type MockNode<T, Depth extends number = 8> = Depth extends 0 ? {
|
|
3
|
+
pool: T[];
|
|
4
|
+
} : T extends ReadonlyMap<any, any> ? T extends ReadonlyMap<infer K, infer V> ? {
|
|
5
|
+
rt$keys: MockNode<K, _MockDepth[Depth]>;
|
|
6
|
+
rt$values: MockNode<V, _MockDepth[Depth]>;
|
|
7
|
+
rt$size?: number | [number, number];
|
|
8
|
+
} : {
|
|
9
|
+
pool: T[];
|
|
10
|
+
} : T extends ReadonlySet<any> ? T extends ReadonlySet<infer U> ? {
|
|
11
|
+
rt$values: MockNode<U, _MockDepth[Depth]>;
|
|
12
|
+
rt$size?: number | [number, number];
|
|
13
|
+
} : {
|
|
14
|
+
pool: T[];
|
|
15
|
+
} : T extends readonly unknown[] ? number extends T['length'] ? {
|
|
16
|
+
rt$items: MockNode<T[number], _MockDepth[Depth]>;
|
|
17
|
+
rt$length?: number | [number, number];
|
|
18
|
+
} : {
|
|
19
|
+
rt$slots: {
|
|
20
|
+
[K in keyof T]: MockNode<T[K], _MockDepth[Depth]>;
|
|
21
|
+
};
|
|
22
|
+
} : T extends number ? {
|
|
23
|
+
pool: number[];
|
|
24
|
+
min?: number;
|
|
25
|
+
max?: number;
|
|
26
|
+
} : T extends string ? {
|
|
27
|
+
pool: string[];
|
|
28
|
+
} : T extends Date ? {
|
|
29
|
+
pool: Date[];
|
|
30
|
+
min?: Date;
|
|
31
|
+
max?: Date;
|
|
32
|
+
} : T extends RegExp ? {
|
|
33
|
+
pool: RegExp[];
|
|
34
|
+
} : T extends boolean ? {
|
|
35
|
+
pool: boolean[];
|
|
36
|
+
} : T extends bigint ? {
|
|
37
|
+
pool: bigint[];
|
|
38
|
+
} : T extends object ? {
|
|
39
|
+
[K in keyof T]-?: MockNode<T[K], _MockDepth[Depth]>;
|
|
40
|
+
} & {
|
|
41
|
+
rt$optional?: number;
|
|
42
|
+
} : {
|
|
43
|
+
pool: T[];
|
|
44
|
+
};
|
|
45
|
+
export type MockData<T> = MockNode<T>;
|
|
46
|
+
export {};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { TypeFormat } from '../runtypes/typeFormat.ts';
|
|
2
|
+
export interface BigIntParams {
|
|
3
|
+
min?: bigint;
|
|
4
|
+
max?: bigint;
|
|
5
|
+
lt?: bigint;
|
|
6
|
+
gt?: bigint;
|
|
7
|
+
multipleOf?: bigint;
|
|
8
|
+
}
|
|
9
|
+
export type BigInt<P extends BigIntParams = {}, BrandName extends string = never> = TypeFormat<bigint, 'bigintFormat', P, BrandName>;
|
|
10
|
+
export type BigPositive = BigInt<{
|
|
11
|
+
min: 0n;
|
|
12
|
+
}>;
|
|
13
|
+
export type BigNegative = BigInt<{
|
|
14
|
+
max: 0n;
|
|
15
|
+
}>;
|
|
16
|
+
export type BigPositiveInt = BigInt<{
|
|
17
|
+
min: 0n;
|
|
18
|
+
multipleOf: 1n;
|
|
19
|
+
}>;
|
|
20
|
+
export type BigNegativeInt = BigInt<{
|
|
21
|
+
max: 0n;
|
|
22
|
+
multipleOf: 1n;
|
|
23
|
+
}>;
|
|
24
|
+
export type BigInt64 = BigInt<{
|
|
25
|
+
min: -9223372036854775808n;
|
|
26
|
+
max: 9223372036854775807n;
|
|
27
|
+
}>;
|
|
28
|
+
export type BigUInt64 = BigInt<{
|
|
29
|
+
min: 0n;
|
|
30
|
+
max: 18446744073709551615n;
|
|
31
|
+
}>;
|
|
32
|
+
export declare const bigPositive: (id?: import("../markers.ts").InjectRunTypeId<BigPositive> | undefined) => import("../index.ts").RunType<BigPositive>;
|
|
33
|
+
export declare const bigNegative: (id?: import("../markers.ts").InjectRunTypeId<BigNegative> | undefined) => import("../index.ts").RunType<BigNegative>;
|
|
34
|
+
export declare const bigPositiveInt: (id?: import("../markers.ts").InjectRunTypeId<BigPositiveInt> | undefined) => import("../index.ts").RunType<BigPositiveInt>;
|
|
35
|
+
export declare const bigNegativeInt: (id?: import("../markers.ts").InjectRunTypeId<BigNegativeInt> | undefined) => import("../index.ts").RunType<BigNegativeInt>;
|
|
36
|
+
export declare const bigInt64: (id?: import("../markers.ts").InjectRunTypeId<BigInt64> | undefined) => import("../index.ts").RunType<BigInt64>;
|
|
37
|
+
export declare const bigUInt64: (id?: import("../markers.ts").InjectRunTypeId<BigUInt64> | undefined) => import("../index.ts").RunType<BigUInt64>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { TypeFormat } from '../../runtypes/typeFormat.ts';
|
|
2
|
+
import type { MinMax, DateTimeBound } from './dateTimeParams.ts';
|
|
3
|
+
export type NativeDateParams = MinMax<DateTimeBound>;
|
|
4
|
+
export type Date<P extends NativeDateParams = {}, BrandName extends string = never> = TypeFormat<globalThis.Date, 'nativeDate', P, BrandName>;
|
|
5
|
+
export type DateFuture = Date<{
|
|
6
|
+
min: 'now';
|
|
7
|
+
}>;
|
|
8
|
+
export type DatePast = Date<{
|
|
9
|
+
max: 'now';
|
|
10
|
+
}>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export type RelativeNow = 'now' | `now+P${string}` | `now-P${string}`;
|
|
2
|
+
export type DateBound = string;
|
|
3
|
+
export type TimeBound = string;
|
|
4
|
+
export type DateTimeBound = string;
|
|
5
|
+
export interface MinMax<Bound extends string = string> {
|
|
6
|
+
min?: Bound;
|
|
7
|
+
max?: Bound;
|
|
8
|
+
gt?: Bound;
|
|
9
|
+
lt?: Bound;
|
|
10
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { TypeFormat } from '../../runtypes/typeFormat.ts';
|
|
2
|
+
import type { MinMax, DateBound, TimeBound, DateTimeBound } from './dateTimeParams.ts';
|
|
3
|
+
export type DateFmt = 'ISO' | 'YYYY-MM-DD' | 'DD-MM-YYYY' | 'MM-DD-YYYY' | 'YYYY-MM' | 'MM-DD' | 'DD-MM';
|
|
4
|
+
export interface DateParams extends MinMax<DateBound> {
|
|
5
|
+
format: DateFmt;
|
|
6
|
+
}
|
|
7
|
+
export type DEFAULT_DATE_PARAMS = {
|
|
8
|
+
format: 'ISO';
|
|
9
|
+
};
|
|
10
|
+
export type StringDate<P extends Partial<DateParams> = DEFAULT_DATE_PARAMS> = TypeFormat<string, 'date', P, never>;
|
|
11
|
+
export type TimeFmt = 'ISO' | 'HH:mm:ss[.mmm]TZ' | 'HH:mm:ss[.mmm]' | 'HH:mm:ss' | 'HH:mm' | 'mm:ss' | 'HH' | 'mm' | 'ss';
|
|
12
|
+
export interface TimeParams extends MinMax<TimeBound> {
|
|
13
|
+
format: TimeFmt;
|
|
14
|
+
}
|
|
15
|
+
export type DEFAULT_TIME_FORMAT_PARAMS = {
|
|
16
|
+
format: 'ISO';
|
|
17
|
+
};
|
|
18
|
+
export type StringTime<P extends Partial<TimeParams> = DEFAULT_TIME_FORMAT_PARAMS> = TypeFormat<string, 'time', P, never>;
|
|
19
|
+
export interface DateTimeParams extends MinMax<DateTimeBound> {
|
|
20
|
+
date: DateParams;
|
|
21
|
+
time: TimeParams;
|
|
22
|
+
splitChar: string;
|
|
23
|
+
}
|
|
24
|
+
export type DEFAULT_DATE_TIME_PARAMS = {
|
|
25
|
+
date: {
|
|
26
|
+
format: 'ISO';
|
|
27
|
+
};
|
|
28
|
+
time: {
|
|
29
|
+
format: 'ISO';
|
|
30
|
+
};
|
|
31
|
+
splitChar: 'T';
|
|
32
|
+
};
|
|
33
|
+
export type StringDateTime<P extends Partial<DateTimeParams> = DEFAULT_DATE_TIME_PARAMS> = TypeFormat<string, 'dateTime', P, never>;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import type { MinMax } from './dateTimeParams.ts';
|
|
2
|
+
import type { TemporalBuilderFn, TemporalInstanceBuilderFn } from '../../runtypes/builderTypes.ts';
|
|
3
|
+
type TemporalInstanceOf<K extends string> = typeof globalThis extends {
|
|
4
|
+
Temporal: Record<K, {
|
|
5
|
+
prototype: infer I;
|
|
6
|
+
}>;
|
|
7
|
+
} ? I : unknown;
|
|
8
|
+
type TInstant = TemporalInstanceOf<'Instant'>;
|
|
9
|
+
type TZonedDateTime = TemporalInstanceOf<'ZonedDateTime'>;
|
|
10
|
+
type TPlainDate = TemporalInstanceOf<'PlainDate'>;
|
|
11
|
+
type TPlainTime = TemporalInstanceOf<'PlainTime'>;
|
|
12
|
+
type TPlainDateTime = TemporalInstanceOf<'PlainDateTime'>;
|
|
13
|
+
type TPlainYearMonth = TemporalInstanceOf<'PlainYearMonth'>;
|
|
14
|
+
type TPlainMonthDay = TemporalInstanceOf<'PlainMonthDay'>;
|
|
15
|
+
type TDuration = TemporalInstanceOf<'Duration'>;
|
|
16
|
+
export type Instant<P extends MinMax = MinMax> = TInstant & {
|
|
17
|
+
readonly __rtFormatName?: 'temporalInstant';
|
|
18
|
+
readonly __rtFormatParams?: P;
|
|
19
|
+
};
|
|
20
|
+
export type ZonedDateTime<P extends MinMax = MinMax> = TZonedDateTime & {
|
|
21
|
+
readonly __rtFormatName?: 'temporalZonedDateTime';
|
|
22
|
+
readonly __rtFormatParams?: P;
|
|
23
|
+
};
|
|
24
|
+
export type PlainDate<P extends MinMax = MinMax> = TPlainDate & {
|
|
25
|
+
readonly __rtFormatName?: 'temporalPlainDate';
|
|
26
|
+
readonly __rtFormatParams?: P;
|
|
27
|
+
};
|
|
28
|
+
export type PlainTime<P extends MinMax = MinMax> = TPlainTime & {
|
|
29
|
+
readonly __rtFormatName?: 'temporalPlainTime';
|
|
30
|
+
readonly __rtFormatParams?: P;
|
|
31
|
+
};
|
|
32
|
+
export type PlainDateTime<P extends MinMax = MinMax> = TPlainDateTime & {
|
|
33
|
+
readonly __rtFormatName?: 'temporalPlainDateTime';
|
|
34
|
+
readonly __rtFormatParams?: P;
|
|
35
|
+
};
|
|
36
|
+
export type PlainYearMonth<P extends MinMax = MinMax> = TPlainYearMonth & {
|
|
37
|
+
readonly __rtFormatName?: 'temporalPlainYearMonth';
|
|
38
|
+
readonly __rtFormatParams?: P;
|
|
39
|
+
};
|
|
40
|
+
export interface TemporalBaseByFormatName {
|
|
41
|
+
temporalInstant: TInstant;
|
|
42
|
+
temporalZonedDateTime: TZonedDateTime;
|
|
43
|
+
temporalPlainDate: TPlainDate;
|
|
44
|
+
temporalPlainTime: TPlainTime;
|
|
45
|
+
temporalPlainDateTime: TPlainDateTime;
|
|
46
|
+
temporalPlainYearMonth: TPlainYearMonth;
|
|
47
|
+
temporalPlainMonthDay: TPlainMonthDay;
|
|
48
|
+
temporalDuration: TDuration;
|
|
49
|
+
}
|
|
50
|
+
declare module '../../runtypes/dataOnly.ts' {
|
|
51
|
+
interface DataOnlyNativeExtra {
|
|
52
|
+
temporalInstant: TInstant;
|
|
53
|
+
temporalZonedDateTime: TZonedDateTime;
|
|
54
|
+
temporalPlainDate: TPlainDate;
|
|
55
|
+
temporalPlainTime: TPlainTime;
|
|
56
|
+
temporalPlainDateTime: TPlainDateTime;
|
|
57
|
+
temporalPlainYearMonth: TPlainYearMonth;
|
|
58
|
+
temporalPlainMonthDay: TPlainMonthDay;
|
|
59
|
+
temporalDuration: TDuration;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
export declare const instant: TemporalBuilderFn<"temporal.instant">;
|
|
63
|
+
export declare const zonedDateTime: TemporalBuilderFn<"temporal.zonedDateTime">;
|
|
64
|
+
export declare const plainDate: TemporalBuilderFn<"temporal.plainDate">;
|
|
65
|
+
export declare const plainTime: TemporalBuilderFn<"temporal.plainTime">;
|
|
66
|
+
export declare const plainDateTime: TemporalBuilderFn<"temporal.plainDateTime">;
|
|
67
|
+
export declare const plainYearMonth: TemporalBuilderFn<"temporal.plainYearMonth">;
|
|
68
|
+
export declare const plainMonthDay: TemporalInstanceBuilderFn<"temporal.plainMonthDay">;
|
|
69
|
+
export declare const duration: TemporalInstanceBuilderFn<"temporal.duration">;
|
|
70
|
+
export {};
|
|
@@ -11,7 +11,7 @@ function temporalBuilder(tag) {
|
|
|
11
11
|
return build;
|
|
12
12
|
}
|
|
13
13
|
function temporalInstanceBuilder(tag) {
|
|
14
|
-
return (id) => (0, builderCore_ts_1.builderResult)(id, { type: tag, formatParams: {} });
|
|
14
|
+
return ((id) => (0, builderCore_ts_1.builderResult)(id, { type: tag, formatParams: {} }));
|
|
15
15
|
}
|
|
16
16
|
exports.instant = temporalBuilder('temporal.instant');
|
|
17
17
|
exports.zonedDateTime = temporalBuilder('temporal.zonedDateTime');
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import './string/string-formats-pure-fns.ts';
|
|
2
|
+
import './datetime/dateTime-pure-fns.ts';
|
|
3
|
+
import '../mocking/mockStringFormat.ts';
|
|
4
|
+
import '../mocking/mockNumberFormat.ts';
|
|
5
|
+
import '../mocking/mockBigIntFormat.ts';
|
|
6
|
+
import './string/string-patterns.ts';
|
|
7
|
+
export type * from './string/stringFormats.ts';
|
|
8
|
+
export type * from './datetime/dateTimeParams.ts';
|
|
9
|
+
export type * from './datetime/stringDateTimeFormats.ts';
|
|
10
|
+
export type * from './datetime/dateFormats.ts';
|
|
11
|
+
export type * from './numberFormats.ts';
|
|
12
|
+
export type * from './bigintFormats.ts';
|
|
13
|
+
export { string, number, currency, bigInt, date, brand } from './scalars.ts';
|
|
14
|
+
export { alpha, alphaNumeric, numeric, lowercase, uppercase, capitalize, uuidv4, uuidv7, ip, ipv4, ipv6, ipWithPort, ipv4WithPort, ipv6WithPort, domain, domainUnicode, domainPunycode, domainStrict, email, emailPunycode, emailStrict, url, urlHttp, urlFile, stringDate, stringTime, stringDateTime, } from './string/stringFormats.ts';
|
|
15
|
+
export { integer, float, positive, negative, positiveInt, negativeInt, int8, int16, int32, uint8, uint16, uint32, } from './numberFormats.ts';
|
|
16
|
+
export { bigPositive, bigNegative, bigPositiveInt, bigNegativeInt, bigInt64, bigUInt64 } from './bigintFormats.ts';
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { TypeFormat } from '../runtypes/typeFormat.ts';
|
|
2
|
+
export interface NumberParams {
|
|
3
|
+
integer?: boolean;
|
|
4
|
+
float?: boolean;
|
|
5
|
+
min?: number;
|
|
6
|
+
max?: number;
|
|
7
|
+
lt?: number;
|
|
8
|
+
gt?: number;
|
|
9
|
+
multipleOf?: number;
|
|
10
|
+
isCurrency?: boolean;
|
|
11
|
+
}
|
|
12
|
+
export type Number<P extends NumberParams = {}, BrandName extends string = never> = TypeFormat<number, 'numberFormat', P, BrandName>;
|
|
13
|
+
export type Currency<P extends NumberParams = {}, BrandName extends string = never> = Number<P & {
|
|
14
|
+
isCurrency: true;
|
|
15
|
+
}, BrandName>;
|
|
16
|
+
export type Integer = Number<{
|
|
17
|
+
integer: true;
|
|
18
|
+
}>;
|
|
19
|
+
export type Float = Number<{
|
|
20
|
+
float: true;
|
|
21
|
+
}>;
|
|
22
|
+
export type Positive = Number<{
|
|
23
|
+
min: 0;
|
|
24
|
+
}>;
|
|
25
|
+
export type Negative = Number<{
|
|
26
|
+
max: 0;
|
|
27
|
+
}>;
|
|
28
|
+
export type PositiveInt = Number<{
|
|
29
|
+
min: 0;
|
|
30
|
+
integer: true;
|
|
31
|
+
}>;
|
|
32
|
+
export type NegativeInt = Number<{
|
|
33
|
+
max: 0;
|
|
34
|
+
integer: true;
|
|
35
|
+
}>;
|
|
36
|
+
export type Int8 = Number<{
|
|
37
|
+
integer: true;
|
|
38
|
+
min: -128;
|
|
39
|
+
max: 127;
|
|
40
|
+
}>;
|
|
41
|
+
export type Int16 = Number<{
|
|
42
|
+
integer: true;
|
|
43
|
+
min: -32768;
|
|
44
|
+
max: 32767;
|
|
45
|
+
}>;
|
|
46
|
+
export type Int32 = Number<{
|
|
47
|
+
integer: true;
|
|
48
|
+
min: -2147483648;
|
|
49
|
+
max: 2147483647;
|
|
50
|
+
}>;
|
|
51
|
+
export type UInt8 = Number<{
|
|
52
|
+
integer: true;
|
|
53
|
+
min: 0;
|
|
54
|
+
max: 255;
|
|
55
|
+
}>;
|
|
56
|
+
export type UInt16 = Number<{
|
|
57
|
+
integer: true;
|
|
58
|
+
min: 0;
|
|
59
|
+
max: 65535;
|
|
60
|
+
}>;
|
|
61
|
+
export type UInt32 = Number<{
|
|
62
|
+
integer: true;
|
|
63
|
+
min: 0;
|
|
64
|
+
max: 4294967295;
|
|
65
|
+
}>;
|
|
66
|
+
export declare const integer: (id?: import("../markers.ts").InjectRunTypeId<Integer> | undefined) => import("../index.ts").RunType<Integer>;
|
|
67
|
+
export declare const float: (id?: import("../markers.ts").InjectRunTypeId<Float> | undefined) => import("../index.ts").RunType<Float>;
|
|
68
|
+
export declare const positive: (id?: import("../markers.ts").InjectRunTypeId<Positive> | undefined) => import("../index.ts").RunType<Positive>;
|
|
69
|
+
export declare const negative: (id?: import("../markers.ts").InjectRunTypeId<Negative> | undefined) => import("../index.ts").RunType<Negative>;
|
|
70
|
+
export declare const positiveInt: (id?: import("../markers.ts").InjectRunTypeId<PositiveInt> | undefined) => import("../index.ts").RunType<PositiveInt>;
|
|
71
|
+
export declare const negativeInt: (id?: import("../markers.ts").InjectRunTypeId<NegativeInt> | undefined) => import("../index.ts").RunType<NegativeInt>;
|
|
72
|
+
export declare const int8: (id?: import("../markers.ts").InjectRunTypeId<Int8> | undefined) => import("../index.ts").RunType<Int8>;
|
|
73
|
+
export declare const int16: (id?: import("../markers.ts").InjectRunTypeId<Int16> | undefined) => import("../index.ts").RunType<Int16>;
|
|
74
|
+
export declare const int32: (id?: import("../markers.ts").InjectRunTypeId<Int32> | undefined) => import("../index.ts").RunType<Int32>;
|
|
75
|
+
export declare const uint8: (id?: import("../markers.ts").InjectRunTypeId<UInt8> | undefined) => import("../index.ts").RunType<UInt8>;
|
|
76
|
+
export declare const uint16: (id?: import("../markers.ts").InjectRunTypeId<UInt16> | undefined) => import("../index.ts").RunType<UInt16>;
|
|
77
|
+
export declare const uint32: (id?: import("../markers.ts").InjectRunTypeId<UInt32> | undefined) => import("../index.ts").RunType<UInt32>;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { brand } from '../runtypes/builderCore.ts';
|
|
2
|
+
import type { RunType } from '../runtypes/types.ts';
|
|
3
|
+
import type { InjectRunTypeId, CompTimeArgs } from '../markers.ts';
|
|
4
|
+
import type { LeafType, BrandArg, ExactParams } from '../runtypes/builderTypes.ts';
|
|
5
|
+
import type { StringParamsValueFirst } from './string/stringFormats.ts';
|
|
6
|
+
import type { NumberParams, Currency } from './numberFormats.ts';
|
|
7
|
+
import type { BigIntParams } from './bigintFormats.ts';
|
|
8
|
+
import type { NativeDateParams } from './datetime/dateFormats.ts';
|
|
9
|
+
export { brand };
|
|
10
|
+
export declare function string(id?: InjectRunTypeId<string>): RunType<string>;
|
|
11
|
+
export declare function string<const P extends StringParamsValueFirst>(formatParams: CompTimeArgs<ExactParams<P, StringParamsValueFirst>>, id?: InjectRunTypeId<LeafType<'stringFormat', P>>): RunType<LeafType<'stringFormat', P>>;
|
|
12
|
+
export declare function string<const P extends StringParamsValueFirst, const B extends string>(formatParams: CompTimeArgs<ExactParams<P, StringParamsValueFirst>>, brandTag: BrandArg<B>, id?: InjectRunTypeId<LeafType<'stringFormat', P, B>>): RunType<LeafType<'stringFormat', P, B>>;
|
|
13
|
+
export declare function number(id?: InjectRunTypeId<number>): RunType<number>;
|
|
14
|
+
export declare function number<const P extends NumberParams>(formatParams: CompTimeArgs<ExactParams<P, NumberParams>>, id?: InjectRunTypeId<LeafType<'numberFormat', P>>): RunType<LeafType<'numberFormat', P>>;
|
|
15
|
+
export declare function number<const P extends NumberParams, const B extends string>(formatParams: CompTimeArgs<ExactParams<P, NumberParams>>, brandTag: BrandArg<B>, id?: InjectRunTypeId<LeafType<'numberFormat', P, B>>): RunType<LeafType<'numberFormat', P, B>>;
|
|
16
|
+
export declare function currency(id?: InjectRunTypeId<Currency>): RunType<Currency>;
|
|
17
|
+
export declare function currency<const P extends NumberParams>(formatParams: CompTimeArgs<ExactParams<P, NumberParams>>, id?: InjectRunTypeId<LeafType<'numberFormat', P & {
|
|
18
|
+
isCurrency: true;
|
|
19
|
+
}>>): RunType<LeafType<'numberFormat', P & {
|
|
20
|
+
isCurrency: true;
|
|
21
|
+
}>>;
|
|
22
|
+
export declare function currency<const P extends NumberParams, const B extends string>(formatParams: CompTimeArgs<ExactParams<P, NumberParams>>, brandTag: BrandArg<B>, id?: InjectRunTypeId<LeafType<'numberFormat', P & {
|
|
23
|
+
isCurrency: true;
|
|
24
|
+
}, B>>): RunType<LeafType<'numberFormat', P & {
|
|
25
|
+
isCurrency: true;
|
|
26
|
+
}, B>>;
|
|
27
|
+
export declare function bigInt(id?: InjectRunTypeId<bigint>): RunType<bigint>;
|
|
28
|
+
export declare function bigInt<const P extends BigIntParams>(formatParams: CompTimeArgs<ExactParams<P, BigIntParams>>, id?: InjectRunTypeId<LeafType<'bigintFormat', P>>): RunType<LeafType<'bigintFormat', P>>;
|
|
29
|
+
export declare function bigInt<const P extends BigIntParams, const B extends string>(formatParams: CompTimeArgs<ExactParams<P, BigIntParams>>, brandTag: BrandArg<B>, id?: InjectRunTypeId<LeafType<'bigintFormat', P, B>>): RunType<LeafType<'bigintFormat', P, B>>;
|
|
30
|
+
export declare function date(id?: InjectRunTypeId<Date>): RunType<Date>;
|
|
31
|
+
export declare function date<const P extends NativeDateParams>(formatParams: CompTimeArgs<ExactParams<P, NativeDateParams>>, id?: InjectRunTypeId<LeafType<'nativeDate', P>>): RunType<LeafType<'nativeDate', P>>;
|
|
32
|
+
export declare function date<const P extends NativeDateParams, const B extends string>(formatParams: CompTimeArgs<ExactParams<P, NativeDateParams>>, brandTag: BrandArg<B>, id?: InjectRunTypeId<LeafType<'nativeDate', P, B>>): RunType<LeafType<'nativeDate', P, B>>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
export declare const DOMAIN_PATTERN: import("../../runtypes/formatPattern.ts").FormatPattern<{
|
|
2
|
+
readonly source: "^(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\\.)+[a-zA-Z]{2,63}$";
|
|
3
|
+
readonly mockSamples: readonly ["mion.io", "example.com", "mionkit.io", "sub.example.co.uk", "wiki.org"];
|
|
4
|
+
}>;
|
|
5
|
+
export declare const DOMAIN_UNICODE_PATTERN: import("../../runtypes/formatPattern.ts").FormatPattern<{
|
|
6
|
+
readonly source: "^(?:[\\p{L}\\p{N}](?:[\\p{L}\\p{N}-]{0,61}[\\p{L}\\p{N}])?\\.)+[a-zA-Z]{2,63}$";
|
|
7
|
+
readonly flags: "u";
|
|
8
|
+
readonly mockSamples: readonly ["mion.io", "example.com", "mionkit.io", "sub.example.co.uk", "wiki.org"];
|
|
9
|
+
}>;
|
|
10
|
+
export declare const DOMAIN_PUNYCODE_PATTERN: import("../../runtypes/formatPattern.ts").FormatPattern<{
|
|
11
|
+
readonly source: "^(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\\.)+[a-zA-Z0-9-]{2,63}$";
|
|
12
|
+
readonly mockSamples: readonly ["xn--e1afmkfd.xn--p1ai", "example.com"];
|
|
13
|
+
}>;
|
|
14
|
+
export declare const DOMAIN_NAME_PATTERN: import("../../runtypes/formatPattern.ts").FormatPattern<{
|
|
15
|
+
readonly source: "^[a-zA-Z0-9-]+$";
|
|
16
|
+
readonly mockSamples: readonly ["domain", "mion", "example", "wiki", "mionkit"];
|
|
17
|
+
}>;
|
|
18
|
+
export declare const DOMAIN_TLD_PATTERN: import("../../runtypes/formatPattern.ts").FormatPattern<{
|
|
19
|
+
readonly source: "^[a-zA-Z]+(\\.[a-zA-Z]+)?$";
|
|
20
|
+
readonly mockSamples: readonly ["com", "org", "net", "io"];
|
|
21
|
+
}>;
|
|
22
|
+
export declare const EMAIL_PATTERN: import("../../runtypes/formatPattern.ts").FormatPattern<{
|
|
23
|
+
readonly source: "^[^\\s@]{1,64}@(?:[a-zA-Z0-9-]{1,63}\\.)+[a-zA-Z]{2,63}$";
|
|
24
|
+
readonly mockSamples: readonly ["john@example.com", "jane.doe@mion.io", "contact@test.org"];
|
|
25
|
+
}>;
|
|
26
|
+
export declare const EMAIL_PUNYCODE_PATTERN: import("../../runtypes/formatPattern.ts").FormatPattern<{
|
|
27
|
+
readonly source: "^[^\\s@]{1,64}@(?:[a-zA-Z0-9-]{1,63}\\.)+[a-zA-Z0-9-]{2,63}$";
|
|
28
|
+
readonly mockSamples: readonly ["john@example.xn--fiqs8s"];
|
|
29
|
+
}>;
|
|
30
|
+
export declare const URL_PATTERN: import("../../runtypes/formatPattern.ts").FormatPattern<{
|
|
31
|
+
readonly source: "^(?:https?|ftps?|wss?):\\/\\/[^\\s/$.?#-][^\\s]*$";
|
|
32
|
+
readonly flags: "i";
|
|
33
|
+
readonly mockSamples: readonly ["https://example.com", "http://mion.io/path", "ftp://files.example.org"];
|
|
34
|
+
}>;
|
|
35
|
+
export declare const URL_HTTP_PATTERN: import("../../runtypes/formatPattern.ts").FormatPattern<{
|
|
36
|
+
readonly source: "^https?:\\/\\/[^\\s/$.?#-][^\\s]*$";
|
|
37
|
+
readonly flags: "i";
|
|
38
|
+
readonly mockSamples: readonly ["https://example.com", "http://mion.io/a/b"];
|
|
39
|
+
}>;
|
|
40
|
+
export declare const URL_FILE_PATTERN: import("../../runtypes/formatPattern.ts").FormatPattern<{
|
|
41
|
+
readonly source: "^file:\\/\\/\\/?(?:[a-zA-Z]:)?[^\\s/$.?#-][^\\s]*$";
|
|
42
|
+
readonly flags: "i";
|
|
43
|
+
readonly mockSamples: readonly ["file:///etc/hosts", "file:///var/log/app.log"];
|
|
44
|
+
}>;
|
|
45
|
+
export declare const ALPHA_PATTERN: import("../../runtypes/formatPattern.ts").FormatPattern<{
|
|
46
|
+
readonly source: "^[\\p{L}]+$";
|
|
47
|
+
readonly flags: "u";
|
|
48
|
+
readonly mockSamples: readonly ["abc", "Hello", "World"];
|
|
49
|
+
}>;
|
|
50
|
+
export declare const ALPHANUMERIC_PATTERN: import("../../runtypes/formatPattern.ts").FormatPattern<{
|
|
51
|
+
readonly source: "^[\\p{L}\\p{N}]+$";
|
|
52
|
+
readonly flags: "u";
|
|
53
|
+
readonly mockSamples: readonly ["abc123", "Test42", "XYZ0"];
|
|
54
|
+
}>;
|
|
55
|
+
export declare const NUMERIC_PATTERN: import("../../runtypes/formatPattern.ts").FormatPattern<{
|
|
56
|
+
readonly source: "^[\\p{N}]+$";
|
|
57
|
+
readonly flags: "u";
|
|
58
|
+
readonly mockSamples: readonly ["123", "007", "42"];
|
|
59
|
+
}>;
|