@ddd-ts/shape 0.0.0-compute-timeout-on-process.8 → 0.0.0-compute-timeout-on-process.10
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/_.d.ts +35 -34
- package/dist/_.d.ts.map +1 -1
- package/dist/_.mjs +1 -2
- package/dist/addons/microsecond-timestamp.d.ts +22 -25
- package/dist/addons/microsecond-timestamp.d.ts.map +1 -1
- package/dist/addons/microsecond-timestamp.mjs +1 -2
- package/dist/choice.d.ts +28 -26
- package/dist/choice.d.ts.map +1 -1
- package/dist/choice.mjs +1 -2
- package/dist/choice.spec.d.ts +2 -0
- package/dist/choice.spec.d.ts.map +1 -0
- package/dist/class.d.ts +16 -20
- package/dist/class.d.ts.map +1 -1
- package/dist/class.mjs +1 -2
- package/dist/class.spec.d.ts +2 -0
- package/dist/class.spec.d.ts.map +1 -0
- package/dist/dict.d.ts +35 -30
- package/dist/dict.d.ts.map +1 -1
- package/dist/dict.mjs +1 -2
- package/dist/dict.spec.d.ts +2 -0
- package/dist/dict.spec.d.ts.map +1 -0
- package/dist/discriminated-union.d.ts +48 -37
- package/dist/discriminated-union.d.ts.map +1 -1
- package/dist/discriminated-union.mjs +1 -2
- package/dist/discriminated-union.spec.d.ts +2 -0
- package/dist/discriminated-union.spec.d.ts.map +1 -0
- package/dist/either.d.ts +71 -66
- package/dist/either.d.ts.map +1 -1
- package/dist/either.mjs +1 -2
- package/dist/either.spec.d.ts +2 -0
- package/dist/either.spec.d.ts.map +1 -0
- package/dist/index.d.ts +14 -14
- package/dist/index.d.ts.map +1 -0
- package/dist/literal.d.ts +12 -16
- package/dist/literal.d.ts.map +1 -1
- package/dist/literal.mjs +1 -2
- package/dist/literal.spec.d.ts +2 -0
- package/dist/literal.spec.d.ts.map +1 -0
- package/dist/mapping.d.ts +34 -25
- package/dist/mapping.d.ts.map +1 -1
- package/dist/mapping.mjs +1 -2
- package/dist/mapping.spec.d.ts +2 -0
- package/dist/mapping.spec.d.ts.map +1 -0
- package/dist/multiple.d.ts +15 -18
- package/dist/multiple.d.ts.map +1 -1
- package/dist/multiple.mjs +1 -2
- package/dist/multiple.spec.d.ts +2 -0
- package/dist/multiple.spec.d.ts.map +1 -0
- package/dist/nothing.d.ts +10 -14
- package/dist/nothing.d.ts.map +1 -1
- package/dist/nothing.mjs +1 -2
- package/dist/nothing.spec.d.ts +2 -0
- package/dist/nothing.spec.d.ts.map +1 -0
- package/dist/optional.d.ts +19 -22
- package/dist/optional.d.ts.map +1 -1
- package/dist/optional.mjs +1 -2
- package/dist/optional.spec.d.ts +2 -0
- package/dist/optional.spec.d.ts.map +1 -0
- package/dist/primitive.d.ts +34 -17
- package/dist/primitive.d.ts.map +1 -1
- package/dist/primitive.mjs +1 -2
- package/dist/primitive.spec.d.ts +2 -0
- package/dist/primitive.spec.d.ts.map +1 -0
- package/dist/test.d.ts +36 -0
- package/dist/test.d.ts.map +1 -0
- package/package.json +7 -7
- package/dist/_.mjs.map +0 -1
- package/dist/addons/microsecond-timestamp.mjs.map +0 -1
- package/dist/choice.mjs.map +0 -1
- package/dist/class.mjs.map +0 -1
- package/dist/dict.mjs.map +0 -1
- package/dist/discriminated-union.mjs.map +0 -1
- package/dist/either.mjs.map +0 -1
- package/dist/literal.mjs.map +0 -1
- package/dist/mapping.mjs.map +0 -1
- package/dist/multiple.mjs.map +0 -1
- package/dist/nothing.mjs.map +0 -1
- package/dist/optional.mjs.map +0 -1
- package/dist/primitive.mjs.map +0 -1
package/dist/_.d.ts
CHANGED
|
@@ -1,38 +1,39 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { Primitive, PrimitiveShorthand } from "./primitive
|
|
4
|
-
import { IMultiple, MultipleShorthand } from "./multiple
|
|
5
|
-
import { Nothing, NothingShorthand } from "./nothing
|
|
6
|
-
import { ILiteral, LiteralShorthand } from "./literal
|
|
7
|
-
|
|
8
|
-
//#region src/_.d.ts
|
|
9
|
-
declare abstract class Empty {}
|
|
10
|
-
interface Constructor<T = any, P extends any[] = any[]> {
|
|
11
|
-
new (...args: P): T;
|
|
1
|
+
import { type IClass, type ClassShorthand } from "./class";
|
|
2
|
+
import { type IDict, type DictShorthand } from "./dict";
|
|
3
|
+
import { Primitive, type PrimitiveShorthand } from "./primitive";
|
|
4
|
+
import { type IMultiple, type MultipleShorthand } from "./multiple";
|
|
5
|
+
import { Nothing, type NothingShorthand } from "./nothing";
|
|
6
|
+
import { type ILiteral, type LiteralShorthand } from "./literal";
|
|
7
|
+
export declare abstract class Empty {
|
|
12
8
|
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
$shape: string;
|
|
16
|
-
$inline: any;
|
|
17
|
-
$serialize(value: any): any;
|
|
18
|
-
$deserialize(value: any): any;
|
|
9
|
+
export interface Constructor<T = any, P extends any[] = any[]> {
|
|
10
|
+
new (...args: P): T;
|
|
19
11
|
}
|
|
20
|
-
type
|
|
21
|
-
|
|
22
|
-
|
|
12
|
+
export type AbstractConstructor<T = any, P extends any[] = any[]> = abstract new (...args: P) => T;
|
|
13
|
+
export interface Definition {
|
|
14
|
+
$shape: string;
|
|
15
|
+
$inline: any;
|
|
16
|
+
$serialize(value: any): any;
|
|
17
|
+
$deserialize(value: any): any;
|
|
18
|
+
}
|
|
19
|
+
export type MakeAbstract<T> = T extends new (...params: infer P) => infer R ? Omit<T, ""> & (abstract new (...params: P) => R) : never;
|
|
20
|
+
export type Concrete<T extends AbstractConstructor<any>> = T extends abstract new (...params: infer P) => infer R ? Omit<T, ""> & {
|
|
21
|
+
new (...params: P): R;
|
|
23
22
|
} : never;
|
|
24
|
-
type Shorthand = Definition | DictShorthand | PrimitiveShorthand | MultipleShorthand | NothingShorthand | ClassShorthand | LiteralShorthand;
|
|
25
|
-
type DefinitionOf<T extends Shorthand | Definition, B extends AbstractConstructor<{}> = typeof Empty> = T extends LiteralShorthand ? ILiteral<T, B> : T extends undefined ? ReturnType<typeof Nothing<B>> : T extends PrimitiveShorthand ? ReturnType<typeof Primitive<T, B>> : T extends MultipleShorthand ? IMultiple<T[0], B> : T extends ClassShorthand ? IClass<T, B> : T extends Definition ? T : T extends DictShorthand ? IDict<T, B> : never;
|
|
26
|
-
declare function Shape<const S extends Definition | Shorthand, B extends AbstractConstructor<{}> = typeof Empty>(shorthand: S, base?: B): DefinitionOf<S, B>;
|
|
27
|
-
type Expand<T> = T extends {
|
|
28
|
-
|
|
29
|
-
} ? T : T extends Date ? T : T extends Record<string, any> ? {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
23
|
+
export type Shorthand = Definition | DictShorthand | PrimitiveShorthand | MultipleShorthand | NothingShorthand | ClassShorthand | LiteralShorthand;
|
|
24
|
+
export type DefinitionOf<T extends Shorthand | Definition, B extends AbstractConstructor<{}> = typeof Empty> = T extends LiteralShorthand ? ILiteral<T, B> : T extends undefined ? ReturnType<typeof Nothing<B>> : T extends PrimitiveShorthand ? ReturnType<typeof Primitive<T, B>> : T extends MultipleShorthand ? IMultiple<T[0], B> : T extends ClassShorthand ? IClass<T, B> : T extends Definition ? T : T extends DictShorthand ? IDict<T, B> : never;
|
|
25
|
+
export declare function Shape<const S extends Definition | Shorthand, B extends AbstractConstructor<{}> = typeof Empty>(shorthand: S, base?: B): DefinitionOf<S, B>;
|
|
26
|
+
export type Expand<T> = T extends {
|
|
27
|
+
serialize(): any;
|
|
28
|
+
} ? T : T extends Date ? T : T extends Record<string, any> ? {
|
|
29
|
+
[key in keyof T]: Expand<T[key]>;
|
|
30
|
+
} : T;
|
|
31
|
+
export declare function forward<T extends AbstractConstructor<{
|
|
32
|
+
value: any;
|
|
33
|
+
}>, const Forward extends T extends AbstractConstructor<{
|
|
34
|
+
value: infer U;
|
|
35
|
+
}> ? (keyof U)[] : never>(base: T, forward: Forward): MakeAbstract<T & (new (...args: ConstructorParameters<T>) => InstanceType<T> & {
|
|
36
|
+
[K in Forward[number]]: InstanceType<T>["value"][K];
|
|
37
|
+
})>;
|
|
38
|
+
export type MergeClasses<B extends AbstractConstructor, Current extends AbstractConstructor> = abstract new (...args: ConstructorParameters<Current>) => InstanceType<B> & InstanceType<Current>;
|
|
38
39
|
//# sourceMappingURL=_.d.ts.map
|
package/dist/_.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_.d.ts","
|
|
1
|
+
{"version":3,"file":"_.d.ts","sourceRoot":"","sources":["../src/_.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,KAAK,MAAM,EAAE,KAAK,cAAc,EAAE,MAAM,SAAS,CAAC;AAClE,OAAO,EAAQ,KAAK,KAAK,EAAE,KAAK,aAAa,EAAE,MAAM,QAAQ,CAAC;AAC9D,OAAO,EAAE,SAAS,EAAE,KAAK,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACjE,OAAO,EAAY,KAAK,SAAS,EAAE,KAAK,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAC9E,OAAO,EAAE,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAC3D,OAAO,EAAW,KAAK,QAAQ,EAAE,KAAK,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAE1E,8BAAsB,KAAK;CAAG;AAE9B,MAAM,WAAW,WAAW,CAAC,CAAC,GAAG,GAAG,EAAE,CAAC,SAAS,GAAG,EAAE,GAAG,GAAG,EAAE;IAC3D,KAAK,GAAG,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC;CACrB;AACD,MAAM,MAAM,mBAAmB,CAC7B,CAAC,GAAG,GAAG,EACP,CAAC,SAAS,GAAG,EAAE,GAAG,GAAG,EAAE,IACrB,QAAQ,MAAM,GAAG,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC;AAEnC,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,GAAG,CAAC;IACb,UAAU,CAAC,KAAK,EAAE,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mBAAmB,EAC7B,OAAO,SAAS,mBAAmB,IACjC,QAAQ,MACV,GAAG,IAAI,EAAE,qBAAqB,CAAC,OAAO,CAAC,KACpC,YAAY,CAAC,CAAC,CAAC,GAAG,YAAY,CAAC,OAAO,CAAC,CAAC"}
|
package/dist/_.mjs
CHANGED
|
@@ -1,27 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
static sort(left: MicrosecondTimestamp, right: MicrosecondTimestamp): number;
|
|
1
|
+
export declare class MicrosecondTimestamp {
|
|
2
|
+
readonly micros: bigint;
|
|
3
|
+
static MILLISECOND: MicrosecondTimestamp;
|
|
4
|
+
static SECOND: MicrosecondTimestamp;
|
|
5
|
+
static MINUTE: MicrosecondTimestamp;
|
|
6
|
+
static HOUR: MicrosecondTimestamp;
|
|
7
|
+
static DAY: MicrosecondTimestamp;
|
|
8
|
+
static WEEK: MicrosecondTimestamp;
|
|
9
|
+
static MONTH: MicrosecondTimestamp;
|
|
10
|
+
constructor(micros: bigint);
|
|
11
|
+
isAfter(other: MicrosecondTimestamp): boolean;
|
|
12
|
+
equals(other: MicrosecondTimestamp): boolean;
|
|
13
|
+
isBefore(other: MicrosecondTimestamp): boolean;
|
|
14
|
+
add(micros: bigint | MicrosecondTimestamp): MicrosecondTimestamp;
|
|
15
|
+
sub(micros: bigint | MicrosecondTimestamp): MicrosecondTimestamp;
|
|
16
|
+
mult(factor: number): MicrosecondTimestamp;
|
|
17
|
+
static now(): MicrosecondTimestamp;
|
|
18
|
+
static fromNanoseconds(nanoseconds: bigint): MicrosecondTimestamp;
|
|
19
|
+
static fromMicroseconds(microseconds: bigint): MicrosecondTimestamp;
|
|
20
|
+
static deserialize(serialized: Date | MicrosecondTimestamp | bigint): MicrosecondTimestamp;
|
|
21
|
+
serialize(): Date;
|
|
22
|
+
static sort(left: MicrosecondTimestamp, right: MicrosecondTimestamp): number;
|
|
24
23
|
}
|
|
25
|
-
//#endregion
|
|
26
|
-
export { MicrosecondTimestamp };
|
|
27
24
|
//# sourceMappingURL=microsecond-timestamp.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"microsecond-timestamp.d.ts","
|
|
1
|
+
{"version":3,"file":"microsecond-timestamp.d.ts","sourceRoot":"","sources":["../../src/addons/microsecond-timestamp.ts"],"names":[],"mappings":"AAAA,qBAAa,oBAAoB;IASnB,QAAQ,CAAC,MAAM,EAAE,MAAM;IARnC,MAAM,CAAC,WAAW,uBAA2C;IAC7D,MAAM,CAAC,MAAM,uBAA+B;IAC5C,MAAM,CAAC,MAAM,uBAAwB;IACrC,MAAM,CAAC,IAAI,uBAAwB;IACnC,MAAM,CAAC,GAAG,uBAAsB;IAChC,MAAM,CAAC,IAAI,uBAAoB;IAC/B,MAAM,CAAC,KAAK,uBAAqB;gBAEZ,MAAM,EAAE,MAAM;IAEnC,OAAO,CAAC,KAAK,EAAE,oBAAoB,GAAG,OAAO;IAI7C,MAAM,CAAC,KAAK,EAAE,oBAAoB,GAAG,OAAO;IAI5C,QAAQ,CAAC,KAAK,EAAE,oBAAoB,GAAG,OAAO;IAI9C,GAAG,CAAC,MAAM,EAAE,MAAM,GAAG,oBAAoB,GAAG,oBAAoB;IAMhE,GAAG,CAAC,MAAM,EAAE,MAAM,GAAG,oBAAoB,GAAG,oBAAoB;IAMhE,IAAI,CAAC,MAAM,EAAE,MAAM,GAAG,oBAAoB;IAI1C,MAAM,CAAC,GAAG,IAAI,oBAAoB;IAIlC,MAAM,CAAC,eAAe,CAAC,WAAW,EAAE,MAAM,GAAG,oBAAoB;IAIjE,MAAM,CAAC,gBAAgB,CAAC,YAAY,EAAE,MAAM,GAAG,oBAAoB;IAInE,MAAM,CAAC,WAAW,CAChB,UAAU,EAAE,IAAI,GAAG,oBAAoB,GAAG,MAAM,GAC/C,oBAAoB;IAmBvB,SAAS;IAMT,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,oBAAoB,EAAE,KAAK,EAAE,oBAAoB,GAAG,MAAM;CAS7E"}
|
package/dist/choice.d.ts
CHANGED
|
@@ -1,28 +1,30 @@
|
|
|
1
|
-
import { AbstractConstructor,
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
} & {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
type
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
1
|
+
import { type AbstractConstructor, Empty, type Constructor } from "./_";
|
|
2
|
+
export type ChoiceMatcher<S extends string[]> = {
|
|
3
|
+
[key in S[number]]: () => any;
|
|
4
|
+
} | ({
|
|
5
|
+
_: () => any;
|
|
6
|
+
} & {
|
|
7
|
+
[key in S[number]]?: () => any;
|
|
8
|
+
});
|
|
9
|
+
export type ChoiceMatcherResult<M extends ChoiceMatcher<any>> = M[keyof M] extends () => infer R ? R : never;
|
|
10
|
+
export declare const Choice: <const S extends string[], B extends AbstractConstructor<{}> = typeof Empty>(config: S, base?: B) => IChoice<S, B>;
|
|
11
|
+
export type IChoice<S extends string[], B extends AbstractConstructor<{}> = typeof Empty> = Omit<B, ""> & {
|
|
12
|
+
$shape: "choice";
|
|
13
|
+
$of: S;
|
|
14
|
+
values: S;
|
|
15
|
+
deserialize<T extends Constructor>(this: T, value: S[number]): InstanceType<T>;
|
|
16
|
+
$deserialize<T>(this: T, value: S[number]): S[number];
|
|
17
|
+
$serialize<T>(this: T, value: S[number]): S[number];
|
|
18
|
+
$inline: S[number];
|
|
17
19
|
} & (abstract new (value: S[number]) => InstanceType<B> & {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}) & {
|
|
26
|
-
|
|
27
|
-
|
|
20
|
+
value: S[number];
|
|
21
|
+
is<TH, T extends S[number]>(this: TH, value: T): this is Omit<TH, "serialize" | "value"> & {
|
|
22
|
+
value: T;
|
|
23
|
+
serialize(): T;
|
|
24
|
+
};
|
|
25
|
+
match<M extends ChoiceMatcher<S>>(matcher: M): ChoiceMatcherResult<M>;
|
|
26
|
+
serialize(): S[number];
|
|
27
|
+
}) & {
|
|
28
|
+
[K in S[number]]: <T extends Constructor>(this: T) => InstanceType<T>;
|
|
29
|
+
};
|
|
28
30
|
//# sourceMappingURL=choice.d.ts.map
|
package/dist/choice.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"choice.d.ts","
|
|
1
|
+
{"version":3,"file":"choice.d.ts","sourceRoot":"","sources":["../src/choice.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,mBAAmB,EAAE,KAAK,EAAe,KAAK,WAAW,EAAE,MAAM,KAAK,CAAC;AAErF,MAAM,MAAM,aAAa,CAAC,CAAC,SAAS,MAAM,EAAE,IACxC;KACG,GAAG,IAAI,CAAC,CAAC,MAAM,CAAC,GAAG,MAAM,GAAG;CAC9B,GACD,CAAC;IACC,CAAC,EAAE,MAAM,GAAG,CAAC;CACd,GAAG;KACD,GAAG,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,GAAG;CAC/B,CAAC,CAAC;AAEP,MAAM,MAAM,mBAAmB,CAAC,CAAC,SAAS,aAAa,CAAC,GAAG,CAAC,IAC1D,CAAC,CAAC,MAAM,CAAC,CAAC,SAAS,MAAM,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;AAE/C,eAAO,MAAM,MAAM,SACX,CAAC,SAAS,MAAM,EAAE,EACxB,CAAC,SAAS,mBAAmB,CAAC,EAAE,CAAC,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OAAO,EAAE,CAAC,GAAG,mBAAmB,CAAC,CAAC,CAAC,CAAC;IACtE,SAAS,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC;CACxB,CAAC,GAAG;KACF,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,SAAS,WAAW,EAAE,IAAI,EAAE,CAAC,KAAK,YAAY,CAAC,CAAC,CAAC;CACtE,CAAC"}
|
package/dist/choice.mjs
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"choice.spec.d.ts","sourceRoot":"","sources":["../src/choice.spec.ts"],"names":[],"mappings":""}
|
package/dist/class.d.ts
CHANGED
|
@@ -1,27 +1,23 @@
|
|
|
1
|
-
import { AbstractConstructor,
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
type ClassShorthand = Constructor<{
|
|
5
|
-
serialize(): any;
|
|
1
|
+
import { type AbstractConstructor, Empty, type Constructor, type Expand } from "./_";
|
|
2
|
+
export type ClassShorthand = Constructor<{
|
|
3
|
+
serialize(): any;
|
|
6
4
|
}> & {
|
|
7
|
-
|
|
5
|
+
deserialize(value: any): any;
|
|
8
6
|
};
|
|
9
|
-
declare const Class: <S extends Constructor<{
|
|
10
|
-
|
|
7
|
+
export declare const Class: <S extends Constructor<{
|
|
8
|
+
serialize(): any;
|
|
11
9
|
}> & {
|
|
12
|
-
|
|
10
|
+
deserialize(value: any): any;
|
|
13
11
|
}, B extends AbstractConstructor<any> = typeof Empty>(of: S, base?: typeof Empty) => IClass<S, B>;
|
|
14
|
-
type IClass<S extends ClassShorthand, B extends AbstractConstructor<any> = typeof Empty> = (abstract new (value: InstanceType<B>) => {
|
|
15
|
-
|
|
16
|
-
|
|
12
|
+
export type IClass<S extends ClassShorthand, B extends AbstractConstructor<any> = typeof Empty> = (abstract new (value: InstanceType<B>) => {
|
|
13
|
+
value: InstanceType<B>;
|
|
14
|
+
serialize<T>(this: T): Expand<ReturnType<InstanceType<S>["serialize"]>>;
|
|
17
15
|
}) & {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
16
|
+
$shape: "class";
|
|
17
|
+
$of: S;
|
|
18
|
+
deserialize<T extends Constructor<any>>(this: T, value: Expand<Parameters<S["deserialize"]>[0]>): InstanceType<T>;
|
|
19
|
+
$deserialize(value: Parameters<S["deserialize"]>[0]): InstanceType<S>;
|
|
20
|
+
$serialize<T>(this: T, value: InstanceType<S>): ReturnType<InstanceType<S>["serialize"]>;
|
|
21
|
+
$inline: InstanceType<S>;
|
|
24
22
|
};
|
|
25
|
-
//#endregion
|
|
26
|
-
export { Class, ClassShorthand, IClass };
|
|
27
23
|
//# sourceMappingURL=class.d.ts.map
|
package/dist/class.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"class.d.ts","
|
|
1
|
+
{"version":3,"file":"class.d.ts","sourceRoot":"","sources":["../src/class.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,mBAAmB,EAAE,KAAK,EAAE,KAAK,WAAW,EAAE,KAAK,MAAM,EAAE,MAAM,KAAK,CAAC;AAErF,MAAM,MAAM,cAAc,GAAG,WAAW,CAAC;IAAE,SAAS,IAAI,GAAG,CAAA;CAAE,CAAC,GAAG;IAC/D,WAAW,CAAC,KAAK,EAAE,GAAG,GAAG,GAAG,CAAC;CAC9B,CAAC;AAEF,eAAO,MAAM,KAAK,GAChB,CAAC,SAAS,WAAW,CAAC;IAAE,SAAS,IAAI,GAAG,CAAA;CAAE,CAAC,GAAG;IAC5C,WAAW,CAAC,KAAK,EAAE,GAAG,GAAG,GAAG,CAAC;CAC9B,EACD,CAAC,SAAS,mBAAmB,CAAC,GAAG,CAAC,qBAE9B,CAAC,0BAEJ,MAAM,CAAC,CAAC,EAAE,CAAC,CAsCb,CAAC;AAEF,MAAM,MAAM,MAAM,CAChB,CAAC,SAAS,cAAc,EACxB,CAAC,SAAS,mBAAmB,CAAC,GAAG,CAAC,GAAG,OAAO,KAAK,IAC/C,CAAC,QAAQ,MACX,KAAK,EAAE,YAAY,CAAC,CAAC,CAAC,KACnB;IACH,KAAK,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC;IACvB,SAAS,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,GAAG,MAAM,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;CACzE,CAAC,GAAG;IACH,MAAM,EAAE,OAAO,CAAC;IAChB,GAAG,EAAE,CAAC,CAAC;IACP,WAAW,CAAC,CAAC,SAAS,WAAW,CAAC,GAAG,CAAC,EACpC,IAAI,EAAE,CAAC,EACP,KAAK,EAAE,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAC7C,YAAY,CAAC,CAAC,CAAC,CAAC;IACnB,YAAY,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,YAAY,CAAC,CAAC,CAAC,CAAC;IACtE,UAAU,CAAC,CAAC,EACV,IAAI,EAAE,CAAC,EACP,KAAK,EAAE,YAAY,CAAC,CAAC,CAAC,GACrB,UAAU,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC;IAC5C,OAAO,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC;CAC1B,CAAC"}
|
package/dist/class.mjs
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"class.spec.d.ts","sourceRoot":"","sources":["../src/class.spec.ts"],"names":[],"mappings":""}
|
package/dist/dict.d.ts
CHANGED
|
@@ -1,38 +1,43 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
type DictShorthand = {
|
|
5
|
-
[key: string]: Shorthand;
|
|
1
|
+
import { type DefinitionOf, type Shorthand, type Expand, type AbstractConstructor, type Constructor, Empty } from "./_";
|
|
2
|
+
export type DictShorthand = {
|
|
3
|
+
[key: string]: Shorthand;
|
|
6
4
|
};
|
|
7
5
|
type Internal<S extends DictShorthand, B extends AbstractConstructor<{}>> = {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
6
|
+
Definition: {
|
|
7
|
+
-readonly [K in keyof S]: DefinitionOf<S[K]>;
|
|
8
|
+
};
|
|
9
|
+
Serialized: (B extends {
|
|
10
|
+
$name: infer U;
|
|
11
|
+
} ? {
|
|
12
|
+
$name: U;
|
|
13
|
+
} : {}) & {
|
|
14
|
+
-readonly [K in keyof S]: ReturnType<DefinitionOf<S[K]>["$serialize"]>;
|
|
15
|
+
};
|
|
16
|
+
Deserializing: (B extends {
|
|
17
|
+
$name: infer U;
|
|
18
|
+
} ? {
|
|
19
|
+
$name: U;
|
|
20
|
+
} : {}) & {
|
|
21
|
+
-readonly [K in keyof S]: Parameters<DefinitionOf<S[K]>["$deserialize"]>[0];
|
|
22
|
+
};
|
|
23
|
+
Inline: {
|
|
24
|
+
-readonly [K in keyof S]: DefinitionOf<S[K]>["$inline"];
|
|
25
|
+
};
|
|
20
26
|
};
|
|
21
|
-
declare const Dict: <const S extends {
|
|
22
|
-
|
|
27
|
+
export declare const Dict: <const S extends {
|
|
28
|
+
[key: string]: any;
|
|
23
29
|
}, B extends AbstractConstructor<{}> = typeof Empty>(of: S, base?: B) => IDict<S, B>;
|
|
24
|
-
type IDict<S extends {
|
|
25
|
-
|
|
30
|
+
export type IDict<S extends {
|
|
31
|
+
[key: string]: any;
|
|
26
32
|
}, B extends AbstractConstructor<{}> = typeof Empty> = Omit<B, ""> & {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
+
$shape: "dict";
|
|
34
|
+
$of: S;
|
|
35
|
+
deserialize<T extends Constructor>(this: T, value: Expand<Internal<S, B>["Serialized"]>): InstanceType<T>;
|
|
36
|
+
$deserialize<T>(this: T, value: Internal<S, B>["Deserializing"]): Internal<S, B>["Inline"];
|
|
37
|
+
$serialize<T extends Constructor>(this: T, value: InstanceType<T>): Internal<S, B>["Serialized"];
|
|
38
|
+
$inline: Internal<S, B>["Inline"];
|
|
33
39
|
} & (abstract new (value: Expand<Internal<S, B>["Inline"]>) => InstanceType<B> & {
|
|
34
|
-
|
|
40
|
+
serialize(): Expand<Internal<S, B>["Serialized"]>;
|
|
35
41
|
} & Internal<S, B>["Inline"]);
|
|
36
|
-
|
|
37
|
-
export { Dict, DictShorthand, IDict };
|
|
42
|
+
export {};
|
|
38
43
|
//# sourceMappingURL=dict.d.ts.map
|
package/dist/dict.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dict.d.ts","
|
|
1
|
+
{"version":3,"file":"dict.d.ts","sourceRoot":"","sources":["../src/dict.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,SAAS,EAEd,KAAK,MAAM,EACX,KAAK,mBAAmB,EACxB,KAAK,WAAW,EAChB,KAAK,EACN,MAAM,KAAK,CAAC;AAEb,MAAM,MAAM,aAAa,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,CAAC;AAEzD,KAAK,QAAQ,CAAC,CAAC,SAAS,aAAa,EAAE,CAAC,SAAS,mBAAmB,CAAC,EAAE,CAAC,IAAI;IAC1E,UAAU,EAAE;QAAE,CAAC,UAAU,CAAC,IAAI,MAAM,CAAC,GAAG,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;KAAE,CAAC;IAC7D,UAAU,EAAE,CAAC,CAAC,SAAS;QAAE,KAAK,EAAE,MAAM,CAAC,CAAA;KAAE,GAAG;QAAE,KAAK,EAAE,CAAC,CAA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AY,CAAC,CAAC,GAC1C,YAAY,CAAC,CAAC,CAAC,CAAC;IACnB,YAAY,CAAC,CAAC,EACZ,IAAI,EAAE,CAAC,EACP,KAAK,EAAE,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,eAAe,CAAC,GACrC,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC;IAC5B,UAAU,CAAC,CAAC,SAAS,WAAW,EAC9B,IAAI,EAAE,CAAC,EACP,KAAK,EAAE,YAAY,CAAC,CAAC,CAAC,GACrB,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC;IAChC,OAAO,EAAE,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC;CACnC,GAAG,CAAC,QAAQ,MACT,KAAK,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,KACpC,YAAY,CAAC,CAAC,CAAC,GAAG;IACrB,SAAS,IAAI,MAAM,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC;CACnD,GAAG,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC"}
|
package/dist/dict.mjs
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dict.spec.d.ts","sourceRoot":"","sources":["../src/dict.spec.ts"],"names":[],"mappings":""}
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
type UnionToIntersection<U> = (U extends unknown ? (k: U) => void : never) extends ((k: infer I) => void) ? I : never;
|
|
7
|
-
type PopUnion<U> = UnionToOvlds<U> extends ((a: infer A) => void) ? A : never;
|
|
1
|
+
import { type Expand, type DefinitionOf, type AbstractConstructor, Empty, type Shorthand, type Definition } from "./_";
|
|
2
|
+
import type { ClassShorthand } from "./class";
|
|
3
|
+
import { type DictShorthand } from "./dict";
|
|
4
|
+
type UnionToIntersection<U> = (U extends unknown ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
|
|
5
|
+
type PopUnion<U> = UnionToOvlds<U> extends (a: infer A) => void ? A : never;
|
|
8
6
|
type UnionToArray<T, A extends unknown[] = []> = IsUnion<T> extends true ? UnionToArray<Exclude<T, PopUnion<T>>, [PopUnion<T>, ...A]> : [T, ...A];
|
|
9
7
|
type IsUnion<T> = [T] extends [UnionToIntersection<T>] ? false : true;
|
|
10
8
|
type CountUnion<T> = UnionToArray<T> extends infer U extends any[] ? U["length"] : never;
|
|
@@ -13,51 +11,64 @@ type UnionToOvlds<U> = UnionToIntersection<U extends any ? (f: U) => void : neve
|
|
|
13
11
|
type IsStringLiteral<T> = T extends string ? string extends T ? false : true : false;
|
|
14
12
|
type FindBestKeyForMatching<FromUnion> = UnshiftUnion<keyof FromUnion extends infer K ? K extends keyof FromUnion ? CountUnion<Pick<FromUnion, K>[K]> extends CountUnion<FromUnion> ? [IsStringLiteral<FromUnion[K]>] extends [true] ? K : never : never : never : never>;
|
|
15
13
|
type MatcherConfig = {
|
|
16
|
-
|
|
14
|
+
[key: string]: any;
|
|
17
15
|
};
|
|
18
|
-
type ExhaustiveMatcher<C> = C extends MatcherConfig ? {
|
|
19
|
-
|
|
20
|
-
|
|
16
|
+
type ExhaustiveMatcher<C> = C extends MatcherConfig ? {
|
|
17
|
+
[key in keyof C]: (value: Expand<DefinitionOf<C[key]>["$inline"]>) => any;
|
|
18
|
+
} : never;
|
|
19
|
+
type UnsafeFallthroughMatcher<C> = C extends MatcherConfig ? {
|
|
20
|
+
[key in keyof C]?: (value: Expand<DefinitionOf<C[key]>["$inline"]>) => any;
|
|
21
|
+
} & {
|
|
22
|
+
_: (value: Expand<DefinitionOf<C[keyof C]>["$inline"]>) => any;
|
|
23
|
+
} : never;
|
|
24
|
+
type PartialMatcher<C> = C extends MatcherConfig ? {
|
|
25
|
+
[key in keyof C]?: (value: Expand<DefinitionOf<C[key]>["$inline"]>) => any;
|
|
21
26
|
} : never;
|
|
22
|
-
type PartialMatcher<C> = C extends MatcherConfig ? { [key in keyof C]?: (value: Expand<DefinitionOf<C[key]>["$inline"]>) => any } : never;
|
|
23
27
|
type Matcher<C> = C extends MatcherConfig ? ExhaustiveMatcher<C> | UnsafeFallthroughMatcher<C> | PartialMatcher<C> : never;
|
|
24
28
|
type Config = DictShorthandInput | ClassInput | ClassDictInput | DictInput;
|
|
25
29
|
type ClassInput = ClassShorthand;
|
|
26
30
|
type ClassDictInput = ClassShorthand & {
|
|
27
|
-
|
|
31
|
+
$of: {};
|
|
28
32
|
};
|
|
29
33
|
type DictInput = {
|
|
30
|
-
|
|
34
|
+
$of: {};
|
|
31
35
|
};
|
|
32
36
|
type DictShorthandInput = DictShorthand;
|
|
33
37
|
type Access<T, K> = K extends keyof T ? T[K] : never;
|
|
34
|
-
type Entries<T extends readonly any[], K> = UnionToIntersection<{
|
|
38
|
+
type Entries<T extends readonly any[], K> = UnionToIntersection<{
|
|
39
|
+
[i in keyof T]: Access<GetShape<T[i]>, K> extends infer U extends string ? IsStringLiteral<U> extends true ? {
|
|
40
|
+
[key in U]: T[i] extends DictShorthandInput ? DefinitionOf<T[i]> : T[i];
|
|
41
|
+
} : never : never;
|
|
42
|
+
}[number]>;
|
|
35
43
|
type GetShape<S extends Config> = S extends DictInput ? S["$of"] : S extends ClassInput ? Access<S, "prototype"> : S;
|
|
36
|
-
type BestKey<S extends readonly Config[]> = {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
44
|
+
export type BestKey<S extends readonly Config[]> = {
|
|
45
|
+
[key in keyof S]: GetShape<S[key]>;
|
|
46
|
+
}[number] extends infer U ? FindBestKeyForMatching<U> : never;
|
|
47
|
+
export type DiscriminatedUnionConfiguration = readonly Config[];
|
|
48
|
+
export declare function findBestKey(config: DiscriminatedUnionConfiguration): string;
|
|
49
|
+
export declare function prepareShapeMap(config: DiscriminatedUnionConfiguration, key: string): {
|
|
50
|
+
[key: string]: Definition;
|
|
41
51
|
};
|
|
42
52
|
type Internal<S extends DiscriminatedUnionConfiguration, K extends BestKey<S>> = {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
53
|
+
Map: Entries<S, K>;
|
|
54
|
+
Serialized: ReturnType<DefinitionOf<S[number]>["$serialize"]>;
|
|
55
|
+
Inline: DefinitionOf<S[number]>["$inline"];
|
|
46
56
|
};
|
|
47
|
-
declare const DiscriminatedUnion: <S extends DiscriminatedUnionConfiguration, K extends BestKey<S>, const B extends AbstractConstructor = typeof Empty>(of: S, base?: B | undefined) => IDiscriminatedUnion<S, K, B>;
|
|
48
|
-
type IDiscriminatedUnion<S extends DiscriminatedUnionConfiguration, K extends BestKey<S>, B extends AbstractConstructor = typeof Empty> = Omit<B, "prototype"> & {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
57
|
+
export declare const DiscriminatedUnion: <S extends DiscriminatedUnionConfiguration, K extends BestKey<S>, const B extends AbstractConstructor = typeof Empty>(of: S, base?: B | undefined) => IDiscriminatedUnion<S, K, B>;
|
|
58
|
+
export type IDiscriminatedUnion<S extends DiscriminatedUnionConfiguration, K extends BestKey<S>, B extends AbstractConstructor = typeof Empty> = Omit<B, "prototype"> & {
|
|
59
|
+
$shape: "discriminated-union";
|
|
60
|
+
$of: S;
|
|
61
|
+
serialized: Internal<S, K>["Serialized"];
|
|
62
|
+
deserialize<T>(this: T, value: Expand<Internal<S, K>["Serialized"]>): T extends AbstractConstructor ? InstanceType<T> : any;
|
|
63
|
+
$deserialize<T>(this: T, value: Internal<S, K>["Serialized"]): Internal<S, K>["Inline"];
|
|
64
|
+
$serialize<T extends AbstractConstructor>(this: T, value: InstanceType<T>): Internal<S, K>["Serialized"];
|
|
65
|
+
$inline: Internal<S, K>["Inline"];
|
|
56
66
|
} & (abstract new (value: Internal<S, K>["Inline"]) => InstanceType<B> & {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
67
|
+
value: Internal<S, K>["Inline"];
|
|
68
|
+
serialize(): Internal<S, K>["Serialized"];
|
|
69
|
+
match<M extends Matcher<Internal<S, K>["Map"]>, F extends M extends ExhaustiveMatcher<Internal<S, K>["Map"]> ? [] : M extends UnsafeFallthroughMatcher<Internal<S, K>["Map"]> ? [] : M extends PartialMatcher<Internal<S, K>["Map"]> ? [
|
|
70
|
+
fallback: (value: Omit<Internal<S, K>["Map"], keyof M>[keyof Omit<Internal<S, K>["Map"], keyof M>] extends infer U extends Shorthand ? Expand<DefinitionOf<U>["$inline"]> : never) => any
|
|
71
|
+
] : []>(matcher: M, ...fallback_n: F): (M[keyof M] extends (...args: any[]) => any ? ReturnType<M[keyof M]> : never) | (F[0] extends (...args: any[]) => any ? ReturnType<F[0]> : never);
|
|
60
72
|
});
|
|
61
|
-
|
|
62
|
-
export { BestKey, DiscriminatedUnion, DiscriminatedUnionConfiguration, IDiscriminatedUnion, findBestKey, prepareShapeMap };
|
|
73
|
+
export {};
|
|
63
74
|
//# sourceMappingURL=discriminated-union.d.ts.map
|