ddd-node 15.0.0 → 15.0.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/core/enum.d.ts +2 -1
- package/dist/core/enum.js +7 -1
- package/package.json +1 -1
- package/tsconfig.json +1 -1
package/dist/core/enum.d.ts
CHANGED
|
@@ -7,7 +7,8 @@ export interface EnumProps {
|
|
|
7
7
|
}
|
|
8
8
|
export declare class EnumBase extends ModelBase<EnumProps> {
|
|
9
9
|
static values(): EnumBase[];
|
|
10
|
-
static
|
|
10
|
+
static parseSafe<T extends EnumBase>(this: EnumClass<T>, providedValue: EnumValue): T | undefined;
|
|
11
|
+
static parse<T extends EnumBase>(this: EnumClass<T>, providedValue: EnumValue): T;
|
|
11
12
|
constructor(value: EnumValue);
|
|
12
13
|
props(): EnumProps;
|
|
13
14
|
get value(): EnumValue;
|
package/dist/core/enum.js
CHANGED
|
@@ -3,7 +3,7 @@ export class EnumBase extends ModelBase {
|
|
|
3
3
|
static values() {
|
|
4
4
|
return Array.from(this.ownStaticValues().values()).map((staticValue) => staticValue.value);
|
|
5
5
|
}
|
|
6
|
-
static
|
|
6
|
+
static parseSafe(providedValue) {
|
|
7
7
|
let key;
|
|
8
8
|
this.ownStaticValues().forEach((staticValue, staticValueKey) => {
|
|
9
9
|
if (staticValue.value instanceof this) {
|
|
@@ -17,6 +17,12 @@ export class EnumBase extends ModelBase {
|
|
|
17
17
|
return this.ownStaticValues().get(key)?.value;
|
|
18
18
|
return undefined;
|
|
19
19
|
}
|
|
20
|
+
static parse(providedValue) {
|
|
21
|
+
const parsedEnum = this.parseSafe(providedValue);
|
|
22
|
+
if (!parsedEnum)
|
|
23
|
+
throw new Error(`Invalid provided value for enum ${this.modelName()}`);
|
|
24
|
+
return parsedEnum;
|
|
25
|
+
}
|
|
20
26
|
constructor(value) {
|
|
21
27
|
super();
|
|
22
28
|
this.initializeProps({ value });
|
package/package.json
CHANGED
package/tsconfig.json
CHANGED
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
/* Modules */
|
|
33
33
|
"module": "ES6" /* Specify what module code is generated. */,
|
|
34
34
|
"rootDir": "./" /* Specify the root folder within your source files. */,
|
|
35
|
-
"moduleResolution": "
|
|
35
|
+
"moduleResolution": "Bundler" /* Specify how TypeScript looks up a file from a given module specifier. */,
|
|
36
36
|
"baseUrl": "./" /* Specify the base directory to resolve non-relative module names. */,
|
|
37
37
|
// "paths": {
|
|
38
38
|
// "@ddd-node/core": ["./src/core"],
|