@need-code/nc-ddd 0.1.0 → 0.2.1
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.
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import * as v from "valibot";
|
|
2
2
|
import type { VO } from "@/core/vo";
|
|
3
|
-
export declare function voFactory<S extends v.BaseSchema<unknown, unknown, v.BaseIssue<unknown>>>(value: unknown, schema: S, constructorFn: (props: v.InferOutput<S>) => VO<S
|
|
3
|
+
export declare function voFactory<S extends v.BaseSchema<unknown, unknown, v.BaseIssue<unknown>>>(value: unknown, schema: S, constructorFn: (props: v.InferOutput<S>) => VO<S>, key?: string): import("@sweet-monads/either").Either<[string, ...string[]] | {
|
|
4
|
+
[key]: [string, ...string[]] | (Readonly<Partial<Record<S extends v.BaseSchema<unknown, unknown, v.BaseIssue<unknown>> | v.BaseSchemaAsync<unknown, unknown, v.BaseIssue<unknown>> ? v.IssueDotPath<S> : string, [string, ...string[]]>>> extends infer T ? { [TKey in keyof T]: T[TKey]; } : never) | undefined;
|
|
5
|
+
} | undefined, never> | import("@sweet-monads/either").Either<never, VO<S>>;
|
|
4
6
|
//# sourceMappingURL=vo-factory.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vo-factory.d.ts","sourceRoot":"","sources":["../../src/helpers/vo-factory.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAC;AAC7B,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,WAAW,CAAC;AAEpC,wBAAgB,SAAS,CAAC,CAAC,SAAS,CAAC,CAAC,UAAU,CAAC,OAAO,EAAE,OAAO,EAAE,CAAC,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,EACtF,KAAK,EAAE,OAAO,EACd,MAAM,EAAE,CAAC,EACT,aAAa,EAAE,CAAC,KAAK,EAAE,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,
|
|
1
|
+
{"version":3,"file":"vo-factory.d.ts","sourceRoot":"","sources":["../../src/helpers/vo-factory.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAC;AAC7B,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,WAAW,CAAC;AAEpC,wBAAgB,SAAS,CAAC,CAAC,SAAS,CAAC,CAAC,UAAU,CAAC,OAAO,EAAE,OAAO,EAAE,CAAC,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,EACtF,KAAK,EAAE,OAAO,EACd,MAAM,EAAE,CAAC,EACT,aAAa,EAAE,CAAC,KAAK,EAAE,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,EACjD,GAAG,CAAC,EAAE,MAAM;IASF,CAAC,GAAG,CAAC,4SAAW;4EAM3B"}
|
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
import { left, right } from "@sweet-monads/either";
|
|
2
2
|
import * as v from "valibot";
|
|
3
|
-
export function voFactory(value, schema, constructorFn) {
|
|
3
|
+
export function voFactory(value, schema, constructorFn, key) {
|
|
4
4
|
const parseResult = v.safeParse(schema, value);
|
|
5
5
|
if (!parseResult.success) {
|
|
6
6
|
const flattedErrors = v.flatten(parseResult.issues);
|
|
7
|
-
|
|
7
|
+
const errorsRes = flattedErrors.root || flattedErrors.nested || flattedErrors.other;
|
|
8
|
+
return left(key
|
|
9
|
+
? {
|
|
10
|
+
[key]: errorsRes,
|
|
11
|
+
}
|
|
12
|
+
: errorsRes);
|
|
8
13
|
}
|
|
9
14
|
return right(constructorFn(parseResult.output));
|
|
10
15
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vo-factory.js","sourceRoot":"","sources":["../../src/helpers/vo-factory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,KAAK,CAAC,MAAM,SAAS,CAAC;AAG7B,MAAM,UAAU,SAAS,CACvB,KAAc,EACd,MAAS,EACT,aAAiD;
|
|
1
|
+
{"version":3,"file":"vo-factory.js","sourceRoot":"","sources":["../../src/helpers/vo-factory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,KAAK,CAAC,MAAM,SAAS,CAAC;AAG7B,MAAM,UAAU,SAAS,CACvB,KAAc,EACd,MAAS,EACT,aAAiD,EACjD,GAAY;IAEZ,MAAM,WAAW,GAAG,CAAC,CAAC,SAAS,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IAC/C,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE,CAAC;QACzB,MAAM,aAAa,GAAG,CAAC,CAAC,OAAO,CAAgB,WAAW,CAAC,MAAM,CAAC,CAAC;QACnE,MAAM,SAAS,GAAG,aAAa,CAAC,IAAI,IAAI,aAAa,CAAC,MAAM,IAAI,aAAa,CAAC,KAAK,CAAC;QACpF,OAAO,IAAI,CACT,GAAG;YACD,CAAC,CAAC;gBACE,CAAC,GAAG,CAAC,EAAE,SAAS;aACjB;YACH,CAAC,CAAC,SAAS,CACd,CAAC;IACJ,CAAC;IACD,OAAO,KAAK,CAAC,aAAa,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC;AAClD,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@need-code/nc-ddd",
|
|
3
|
-
"version": "0.1
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "A set of base classes for implementing Domain-Driven Design patterns.",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
|
-
"module": "./dist/index.js",
|
|
7
6
|
"types": "./dist/index.d.ts",
|
|
8
7
|
"files": [
|
|
9
8
|
"dist"
|
|
10
9
|
],
|
|
11
10
|
"exports": {
|
|
12
11
|
".": {
|
|
13
|
-
"import": "./dist/index.js",
|
|
14
12
|
"require": "./dist/index.js",
|
|
15
13
|
"types": "./dist/index.d.ts"
|
|
16
14
|
}
|