@ddd-ts/shape 0.0.0-compute-timeout-on-process.3 → 0.0.0-compute-timeout-on-process.4
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 +38 -0
- package/dist/_.d.ts.map +1 -0
- package/dist/_.js +37 -0
- package/dist/_.js.map +1 -0
- package/dist/addons/microsecond-timestamp.d.ts +27 -0
- package/dist/addons/microsecond-timestamp.d.ts.map +1 -0
- package/dist/addons/microsecond-timestamp.js +62 -0
- package/dist/addons/microsecond-timestamp.js.map +1 -0
- package/dist/choice.d.ts +28 -0
- package/dist/choice.d.ts.map +1 -0
- package/dist/choice.js +45 -0
- package/dist/choice.js.map +1 -0
- package/dist/class.d.ts +27 -0
- package/dist/class.d.ts.map +1 -0
- package/dist/class.js +31 -0
- package/dist/class.js.map +1 -0
- package/dist/dict.d.ts +38 -0
- package/dist/dict.d.ts.map +1 -0
- package/dist/dict.js +42 -0
- package/dist/dict.js.map +1 -0
- package/dist/discriminated-union.d.ts +63 -0
- package/dist/discriminated-union.d.ts.map +1 -0
- package/dist/discriminated-union.js +65 -0
- package/dist/discriminated-union.js.map +1 -0
- package/dist/either.d.ts +79 -0
- package/dist/either.d.ts.map +1 -0
- package/dist/either.js +52 -0
- package/dist/either.js.map +1 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.js +15 -0
- package/dist/literal.d.ts +19 -0
- package/dist/literal.d.ts.map +1 -0
- package/dist/literal.js +28 -0
- package/dist/literal.js.map +1 -0
- package/dist/mapping.d.ts +34 -0
- package/dist/mapping.d.ts.map +1 -0
- package/dist/mapping.js +46 -0
- package/dist/mapping.js.map +1 -0
- package/dist/multiple.d.ts +23 -0
- package/dist/multiple.d.ts.map +1 -0
- package/dist/multiple.js +120 -0
- package/dist/multiple.js.map +1 -0
- package/dist/nothing.d.ts +18 -0
- package/dist/nothing.d.ts.map +1 -0
- package/dist/nothing.js +20 -0
- package/dist/nothing.js.map +1 -0
- package/dist/optional.d.ts +29 -0
- package/dist/optional.d.ts.map +1 -0
- package/dist/optional.js +35 -0
- package/dist/optional.js.map +1 -0
- package/dist/primitive.d.ts +21 -0
- package/dist/primitive.d.ts.map +1 -0
- package/dist/primitive.js +31 -0
- package/dist/primitive.js.map +1 -0
- package/package.json +7 -4
package/dist/optional.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { Empty, Shape } from "./_.js";
|
|
2
|
+
|
|
3
|
+
//#region src/optional.ts
|
|
4
|
+
const Optional = (of, base = Empty) => {
|
|
5
|
+
class $Optional extends base {
|
|
6
|
+
constructor(value) {
|
|
7
|
+
super();
|
|
8
|
+
this.value = value;
|
|
9
|
+
}
|
|
10
|
+
static $shape = "optional";
|
|
11
|
+
serialize() {
|
|
12
|
+
return $Optional.$serialize(this.value);
|
|
13
|
+
}
|
|
14
|
+
match(config) {
|
|
15
|
+
if (this.value === void 0) return config.none();
|
|
16
|
+
return config.some(this.value);
|
|
17
|
+
}
|
|
18
|
+
static deserialize(value) {
|
|
19
|
+
return new this(this.$deserialize(value));
|
|
20
|
+
}
|
|
21
|
+
static $deserialize(value) {
|
|
22
|
+
if (value === void 0) return;
|
|
23
|
+
return Shape(of).$deserialize(value);
|
|
24
|
+
}
|
|
25
|
+
static $serialize(value) {
|
|
26
|
+
return value === void 0 ? void 0 : Shape(of).$serialize(value);
|
|
27
|
+
}
|
|
28
|
+
static $inline;
|
|
29
|
+
}
|
|
30
|
+
return $Optional;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
//#endregion
|
|
34
|
+
export { Optional };
|
|
35
|
+
//# sourceMappingURL=optional.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"optional.js","names":[],"sources":["../src/optional.ts"],"sourcesContent":["import {\n Definition,\n Expand,\n Shorthand,\n DefinitionOf,\n Shape,\n Constructor,\n AbstractConstructor,\n Empty,\n} from \"./_\";\n\nexport type OptionalConfiguration = Definition | Shorthand;\n\ntype Matcher<V> = { some: (value: V) => any; none: () => any };\n\ntype Internal<S extends Definition | Shorthand> = {\n Serialized: ReturnType<DefinitionOf<S>[\"$serialize\"]> | undefined;\n Deserializing: Parameters<DefinitionOf<S>[\"$deserialize\"]>[0] | undefined;\n Inline: Expand<DefinitionOf<S>[\"$inline\"]> | undefined;\n Required: Expand<DefinitionOf<S>[\"$inline\"]>;\n};\n\nexport const Optional = <\n S extends Definition | Shorthand,\n B extends AbstractConstructor<{}> = typeof Empty,\n>(\n of: S,\n base: B = Empty as any,\n): IOptional<S, B> => {\n abstract class $Optional extends (base as any as Constructor<{}>) {\n constructor(public value: any) {\n super();\n }\n\n static $shape = \"optional\" as const;\n\n serialize() {\n return $Optional.$serialize((this as any).value) as any;\n }\n\n match(config: any) {\n if ((this as any).value === undefined) {\n return config.none();\n }\n return config.some((this as any).value);\n }\n\n static deserialize<T extends Constructor>(\n this: T,\n value: any,\n ): InstanceType<T> {\n return new (this as any)((this as any).$deserialize(value)) as any;\n }\n\n static $deserialize(value: any): any {\n if (value === undefined) {\n return undefined;\n }\n return (Shape(of) as any).$deserialize(value);\n }\n\n static $serialize<T extends typeof $Optional>(this: T, value: any): any {\n return value === undefined\n ? undefined\n : (Shape(of) as any).$serialize(value);\n }\n\n static $inline: any;\n }\n\n return $Optional as any;\n};\n\nexport type IOptional<\n S extends Definition | Shorthand,\n B extends AbstractConstructor<{}> = typeof Object,\n> = Omit<B, \"prototype\"> & {\n $shape: \"optional\";\n deserialize<T extends Constructor>(\n this: T,\n value: Internal<S>[\"Deserializing\"],\n ): InstanceType<T>;\n $deserialize(value: Internal<S>[\"Deserializing\"]): Definition[\"$inline\"];\n $serialize<T>(\n this: T,\n value: Internal<S>[\"Inline\"],\n ): Internal<S>[\"Serialized\"];\n $inline: Internal<S>[\"Inline\"];\n} & (abstract new (\n value: Internal<S>[\"Inline\"],\n ) => InstanceType<B> & {\n value: Internal<S>[\"Inline\"];\n serialize(): Expand<Internal<S>[\"Serialized\"]>;\n match<M extends Matcher<Expand<Internal<S>[\"Required\"]>>>(\n config: M,\n ): ReturnType<M[\"some\"]> | ReturnType<M[\"none\"]>;\n });\n"],"mappings":";;;AAsBA,MAAa,YAIX,IACA,OAAU,UACU;CACpB,MAAe,kBAAmB,KAAgC;EAChE,YAAY,AAAO,OAAY;AAC7B,UAAO;GADU;;EAInB,OAAO,SAAS;EAEhB,YAAY;AACV,UAAO,UAAU,WAAY,KAAa,MAAM;;EAGlD,MAAM,QAAa;AACjB,OAAK,KAAa,UAAU,OAC1B,QAAO,OAAO,MAAM;AAEtB,UAAO,OAAO,KAAM,KAAa,MAAM;;EAGzC,OAAO,YAEL,OACiB;AACjB,UAAO,IAAK,KAAc,KAAa,aAAa,MAAM,CAAC;;EAG7D,OAAO,aAAa,OAAiB;AACnC,OAAI,UAAU,OACZ;AAEF,UAAQ,MAAM,GAAG,CAAS,aAAa,MAAM;;EAG/C,OAAO,WAAgD,OAAiB;AACtE,UAAO,UAAU,SACb,SACC,MAAM,GAAG,CAAS,WAAW,MAAM;;EAG1C,OAAO;;AAGT,QAAO"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { AbstractConstructor, Constructor, Empty, Expand } from "./_.js";
|
|
2
|
+
|
|
3
|
+
//#region src/primitive.d.ts
|
|
4
|
+
type PrimitiveMap = [[StringConstructor, string], [NumberConstructor, number], [DateConstructor, Date], [BooleanConstructor, boolean]];
|
|
5
|
+
type PrimitiveConstructor = PrimitiveMap[number][0];
|
|
6
|
+
type PrimitiveFromConstructor<S> = Extract<PrimitiveMap[number], [S, any]>[1];
|
|
7
|
+
type PrimitiveShorthand = PrimitiveConstructor;
|
|
8
|
+
type IPrimitive<S extends PrimitiveConstructor, B extends AbstractConstructor<{}> = typeof Empty> = Omit<B, ""> & (abstract new (value: Expand<PrimitiveFromConstructor<S>>) => InstanceType<B> & {
|
|
9
|
+
readonly value: Expand<PrimitiveFromConstructor<S>>;
|
|
10
|
+
serialize(): PrimitiveFromConstructor<S>;
|
|
11
|
+
}) & {
|
|
12
|
+
$shape: "primitive";
|
|
13
|
+
deserialize<T extends Constructor<any>>(this: T, value: PrimitiveFromConstructor<S>): InstanceType<T>;
|
|
14
|
+
$serialize(value: PrimitiveFromConstructor<S>): PrimitiveFromConstructor<S>;
|
|
15
|
+
$deserialize(value: PrimitiveFromConstructor<S>): PrimitiveFromConstructor<S>;
|
|
16
|
+
$inline: Expand<PrimitiveFromConstructor<S>>;
|
|
17
|
+
};
|
|
18
|
+
declare const Primitive: <S extends PrimitiveConstructor, B extends AbstractConstructor<{}> = typeof Empty>(of: S, base?: B) => IPrimitive<S, B>;
|
|
19
|
+
//#endregion
|
|
20
|
+
export { IPrimitive, Primitive, PrimitiveFromConstructor, PrimitiveShorthand };
|
|
21
|
+
//# sourceMappingURL=primitive.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"primitive.d.ts","names":[],"sources":["../src/primitive.ts"],"mappings":";;;KAEK,YAAA,KACF,iBAAA,YACA,iBAAA,YACA,eAAA,EAAiB,IAAA,IACjB,kBAAA;AAAA,KAGE,oBAAA,GAAuB,YAAA;AAAA,KAChB,wBAAA,MAA8B,OAAA,CACxC,YAAA,WACC,CAAA;AAAA,KAGS,kBAAA,GAAqB,oBAAA;AAAA,KAErB,UAAA,WACA,oBAAA,YACA,mBAAA,cAAiC,KAAA,IACzC,IAAA,CAAK,CAAA,uBAEL,KAAA,EAAO,MAAA,CAAO,wBAAA,CAAyB,CAAA,OACpC,YAAA,CAAa,CAAA;EAAA,SACP,KAAA,EAAO,MAAA,CAAO,wBAAA,CAAyB,CAAA;EAChD,SAAA,IAAa,wBAAA,CAAyB,CAAA;AAAA;EAEtC,MAAA;EACA,WAAA,WAAsB,WAAA,OACpB,IAAA,EAAM,CAAA,EACN,KAAA,EAAO,wBAAA,CAAyB,CAAA,IAC/B,YAAA,CAAa,CAAA;EAChB,UAAA,CAAW,KAAA,EAAO,wBAAA,CAAyB,CAAA,IAAK,wBAAA,CAAyB,CAAA;EACzE,YAAA,CACE,KAAA,EAAO,wBAAA,CAAyB,CAAA,IAC/B,wBAAA,CAAyB,CAAA;EAC5B,OAAA,EAAS,MAAA,CAAO,wBAAA,CAAyB,CAAA;AAAA;AAAA,cAGhC,SAAA,aACD,oBAAA,YACA,mBAAA,cAAuB,KAAA,EAAA,EAAA,EAE7B,CAAA,EAAC,IAAA,GACC,CAAA,KACL,UAAA,CAAW,CAAA,EAAG,CAAA"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Empty } from "./_.js";
|
|
2
|
+
|
|
3
|
+
//#region src/primitive.ts
|
|
4
|
+
const Primitive = (of, base = Empty) => {
|
|
5
|
+
class $Primitive extends base {
|
|
6
|
+
constructor(value) {
|
|
7
|
+
super();
|
|
8
|
+
this.value = value;
|
|
9
|
+
}
|
|
10
|
+
static $shape = "primitive";
|
|
11
|
+
serialize() {
|
|
12
|
+
return this.value;
|
|
13
|
+
}
|
|
14
|
+
static deserialize(value) {
|
|
15
|
+
return new this(this.$deserialize(value));
|
|
16
|
+
}
|
|
17
|
+
static $serialize(value) {
|
|
18
|
+
return value;
|
|
19
|
+
}
|
|
20
|
+
static $deserialize(value) {
|
|
21
|
+
if (of === Date && typeof value === "string") return new Date(value);
|
|
22
|
+
return value;
|
|
23
|
+
}
|
|
24
|
+
static $inline;
|
|
25
|
+
}
|
|
26
|
+
return $Primitive;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
//#endregion
|
|
30
|
+
export { Primitive };
|
|
31
|
+
//# sourceMappingURL=primitive.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"primitive.js","names":[],"sources":["../src/primitive.ts"],"sourcesContent":["import { AbstractConstructor, Concrete, Constructor, Empty, Expand } from \"./_\";\n\ntype PrimitiveMap = [\n [StringConstructor, string],\n [NumberConstructor, number],\n [DateConstructor, Date],\n [BooleanConstructor, boolean],\n];\n\ntype PrimitiveConstructor = PrimitiveMap[number][0];\nexport type PrimitiveFromConstructor<S> = Extract<\n PrimitiveMap[number],\n [S, any]\n>[1];\n\nexport type PrimitiveShorthand = PrimitiveConstructor;\n\nexport type IPrimitive<\n S extends PrimitiveConstructor,\n B extends AbstractConstructor<{}> = typeof Empty,\n> = Omit<B, \"\"> &\n (abstract new (\n value: Expand<PrimitiveFromConstructor<S>>,\n ) => InstanceType<B> & {\n readonly value: Expand<PrimitiveFromConstructor<S>>;\n serialize(): PrimitiveFromConstructor<S>;\n }) & {\n $shape: \"primitive\";\n deserialize<T extends Constructor<any>>(\n this: T,\n value: PrimitiveFromConstructor<S>,\n ): InstanceType<T>;\n $serialize(value: PrimitiveFromConstructor<S>): PrimitiveFromConstructor<S>;\n $deserialize(\n value: PrimitiveFromConstructor<S>,\n ): PrimitiveFromConstructor<S>;\n $inline: Expand<PrimitiveFromConstructor<S>>;\n };\n\nexport const Primitive = <\n S extends PrimitiveConstructor,\n B extends AbstractConstructor<{}> = typeof Empty,\n>(\n of: S,\n base: B = Empty as any,\n): IPrimitive<S, B> => {\n type Inline = PrimitiveFromConstructor<S>;\n\n abstract class $Primitive extends (base as any as Constructor<{}>) {\n constructor(public readonly value: Expand<Inline>) {\n super();\n }\n\n static $shape = \"primitive\" as const;\n\n serialize(): Inline {\n return this.value;\n }\n\n static deserialize<T extends typeof $Primitive>(\n this: T,\n value: Inline,\n ): InstanceType<T> {\n return new (this as any)(this.$deserialize(value)) as InstanceType<T>;\n }\n\n static $serialize(value: Inline): Inline {\n return value;\n }\n\n static $deserialize(value: Inline): Inline {\n if (of === Date && typeof value === \"string\") {\n return new Date(value);\n }\n return value;\n }\n\n static $inline: Expand<Inline>;\n }\n\n type PrimitiveConstructor = abstract new (\n value: Expand<Inline>,\n ) => InstanceType<B> & $Primitive;\n\n type Primitive = Omit<B, \"prototype\"> &\n Omit<typeof $Primitive, \"prototype\"> &\n PrimitiveConstructor;\n\n return $Primitive as any;\n};\n"],"mappings":";;;AAuCA,MAAa,aAIX,IACA,OAAU,UACW;CAGrB,MAAe,mBAAoB,KAAgC;EACjE,YAAY,AAAgB,OAAuB;AACjD,UAAO;GADmB;;EAI5B,OAAO,SAAS;EAEhB,YAAoB;AAClB,UAAO,KAAK;;EAGd,OAAO,YAEL,OACiB;AACjB,UAAO,IAAK,KAAa,KAAK,aAAa,MAAM,CAAC;;EAGpD,OAAO,WAAW,OAAuB;AACvC,UAAO;;EAGT,OAAO,aAAa,OAAuB;AACzC,OAAI,OAAO,QAAQ,OAAO,UAAU,SAClC,QAAO,IAAI,KAAK,MAAM;AAExB,UAAO;;EAGT,OAAO;;AAWT,QAAO"}
|
package/package.json
CHANGED
|
@@ -1,21 +1,24 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ddd-ts/shape",
|
|
3
|
-
"version": "0.0.0-compute-timeout-on-process.
|
|
3
|
+
"version": "0.0.0-compute-timeout-on-process.4",
|
|
4
4
|
"types": "dist/index.d.ts",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
7
7
|
"url": "git+https://github.com/ddd-ts/monorepo"
|
|
8
8
|
},
|
|
9
|
+
"files": [
|
|
10
|
+
"dist"
|
|
11
|
+
],
|
|
9
12
|
"scripts": {
|
|
10
13
|
"build": "tsdown --config node_modules/@ddd-ts/tools/tsdown.config.js",
|
|
11
14
|
"test": "jest --config node_modules/@ddd-ts/tools/jest.config.js"
|
|
12
15
|
},
|
|
13
16
|
"dependencies": {
|
|
14
|
-
"@ddd-ts/traits": "0.0.0-compute-timeout-on-process.
|
|
17
|
+
"@ddd-ts/traits": "0.0.0-compute-timeout-on-process.4"
|
|
15
18
|
},
|
|
16
19
|
"devDependencies": {
|
|
17
|
-
"@ddd-ts/tools": "0.0.0-compute-timeout-on-process.
|
|
18
|
-
"@ddd-ts/types": "0.0.0-compute-timeout-on-process.
|
|
20
|
+
"@ddd-ts/tools": "0.0.0-compute-timeout-on-process.4",
|
|
21
|
+
"@ddd-ts/types": "0.0.0-compute-timeout-on-process.4",
|
|
19
22
|
"@types/jest": "^29.5.1"
|
|
20
23
|
},
|
|
21
24
|
"exports": {
|