@schorts/shared-kernel 2.2.3 → 2.2.5
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/CHANGELOG +6 -0
- package/dist/cjs/value-objects/enum-value.js +5 -12
- package/dist/cjs/value-objects/enum-value.js.map +1 -1
- package/dist/esm/value-objects/enum-value.js +5 -12
- package/dist/esm/value-objects/enum-value.js.map +1 -1
- package/dist/types/value-objects/enum-value.d.ts +5 -6
- package/dist/types/value-objects/enum-value.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/value-objects/enum-value.ts +12 -15
package/CHANGELOG
CHANGED
|
@@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
### [2.2.4] - 2025-10-10
|
|
9
|
+
|
|
10
|
+
### Changed
|
|
11
|
+
|
|
12
|
+
- Remove `Optional` param in the `EnumValue`. Instead allow null values in the `allowedTypes` array.
|
|
13
|
+
|
|
8
14
|
### [2.2.3] - 2025-10-10
|
|
9
15
|
|
|
10
16
|
### Changed
|
|
@@ -4,26 +4,19 @@ exports.EnumValue = void 0;
|
|
|
4
4
|
class EnumValue {
|
|
5
5
|
valueType = 'Enum';
|
|
6
6
|
allowedValues;
|
|
7
|
-
optional;
|
|
8
7
|
value;
|
|
9
|
-
constructor(allowedValues, value
|
|
8
|
+
constructor(allowedValues, value) {
|
|
10
9
|
this.allowedValues = allowedValues;
|
|
11
|
-
this.optional = optional;
|
|
12
10
|
this.value = value;
|
|
13
11
|
}
|
|
14
12
|
get isValid() {
|
|
15
|
-
if (this.optional && this.value === null)
|
|
16
|
-
return true;
|
|
17
|
-
if (!this.optional && this.value === null)
|
|
18
|
-
return false;
|
|
19
13
|
return this.allowedValues.includes(this.value);
|
|
20
14
|
}
|
|
21
15
|
equals(valueObject) {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
return this.value === valueObject.value;
|
|
16
|
+
return (valueObject instanceof EnumValue &&
|
|
17
|
+
this.isValid &&
|
|
18
|
+
valueObject.isValid &&
|
|
19
|
+
this.value === valueObject.value);
|
|
27
20
|
}
|
|
28
21
|
}
|
|
29
22
|
exports.EnumValue = EnumValue;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"enum-value.js","sourceRoot":"","sources":["../../../src/value-objects/enum-value.ts"],"names":[],"mappings":";;;AAEA,MAAsB,SAAS;IACpB,SAAS,GAAG,MAAM,CAAC;IACnB,aAAa,
|
|
1
|
+
{"version":3,"file":"enum-value.js","sourceRoot":"","sources":["../../../src/value-objects/enum-value.ts"],"names":[],"mappings":";;;AAEA,MAAsB,SAAS;IACpB,SAAS,GAAG,MAAM,CAAC;IACnB,aAAa,CAAU;IACvB,KAAK,CAAkB;IAEhC,YAAY,aAAsB,EAAE,KAAsB;QACxD,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;QACnC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;IAED,IAAI,OAAO;QACT,OAAO,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACjD,CAAC;IAED,MAAM,CAAC,WAAoB;QACzB,OAAO,CACL,WAAW,YAAY,SAAS;YAChC,IAAI,CAAC,OAAO;YACZ,WAAW,CAAC,OAAO;YACnB,IAAI,CAAC,KAAK,KAAK,WAAW,CAAC,KAAK,CACjC,CAAC;IACJ,CAAC;CAGF;AAxBD,8BAwBC"}
|
|
@@ -4,26 +4,19 @@ exports.EnumValue = void 0;
|
|
|
4
4
|
class EnumValue {
|
|
5
5
|
valueType = 'Enum';
|
|
6
6
|
allowedValues;
|
|
7
|
-
optional;
|
|
8
7
|
value;
|
|
9
|
-
constructor(allowedValues, value
|
|
8
|
+
constructor(allowedValues, value) {
|
|
10
9
|
this.allowedValues = allowedValues;
|
|
11
|
-
this.optional = optional;
|
|
12
10
|
this.value = value;
|
|
13
11
|
}
|
|
14
12
|
get isValid() {
|
|
15
|
-
if (this.optional && this.value === null)
|
|
16
|
-
return true;
|
|
17
|
-
if (!this.optional && this.value === null)
|
|
18
|
-
return false;
|
|
19
13
|
return this.allowedValues.includes(this.value);
|
|
20
14
|
}
|
|
21
15
|
equals(valueObject) {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
return this.value === valueObject.value;
|
|
16
|
+
return (valueObject instanceof EnumValue &&
|
|
17
|
+
this.isValid &&
|
|
18
|
+
valueObject.isValid &&
|
|
19
|
+
this.value === valueObject.value);
|
|
27
20
|
}
|
|
28
21
|
}
|
|
29
22
|
exports.EnumValue = EnumValue;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"enum-value.js","sourceRoot":"","sources":["../../../src/value-objects/enum-value.ts"],"names":[],"mappings":";;;AAEA,MAAsB,SAAS;IACpB,SAAS,GAAG,MAAM,CAAC;IACnB,aAAa,
|
|
1
|
+
{"version":3,"file":"enum-value.js","sourceRoot":"","sources":["../../../src/value-objects/enum-value.ts"],"names":[],"mappings":";;;AAEA,MAAsB,SAAS;IACpB,SAAS,GAAG,MAAM,CAAC;IACnB,aAAa,CAAU;IACvB,KAAK,CAAkB;IAEhC,YAAY,aAAsB,EAAE,KAAsB;QACxD,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;QACnC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;IAED,IAAI,OAAO;QACT,OAAO,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACjD,CAAC;IAED,MAAM,CAAC,WAAoB;QACzB,OAAO,CACL,WAAW,YAAY,SAAS;YAChC,IAAI,CAAC,OAAO;YACZ,WAAW,CAAC,OAAO;YACnB,IAAI,CAAC,KAAK,KAAK,WAAW,CAAC,KAAK,CACjC,CAAC;IACJ,CAAC;CAGF;AAxBD,8BAwBC"}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { ValueObject } from
|
|
2
|
-
export declare abstract class EnumValue<
|
|
1
|
+
import { ValueObject } from "./value-object";
|
|
2
|
+
export declare abstract class EnumValue<Allowed extends readonly (string | null)[]> implements ValueObject {
|
|
3
3
|
readonly valueType = "Enum";
|
|
4
|
-
readonly allowedValues:
|
|
5
|
-
readonly
|
|
6
|
-
|
|
7
|
-
constructor(allowedValues: Type[], value: Type | null, optional?: boolean);
|
|
4
|
+
readonly allowedValues: Allowed;
|
|
5
|
+
readonly value: Allowed[number];
|
|
6
|
+
constructor(allowedValues: Allowed, value: Allowed[number]);
|
|
8
7
|
get isValid(): boolean;
|
|
9
8
|
equals(valueObject: unknown): boolean;
|
|
10
9
|
abstract readonly attributeName: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"enum-value.d.ts","sourceRoot":"","sources":["../../../src/value-objects/enum-value.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"enum-value.d.ts","sourceRoot":"","sources":["../../../src/value-objects/enum-value.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C,8BAAsB,SAAS,CAAC,OAAO,SAAS,SAAS,CAAC,MAAM,GAAG,IAAI,CAAC,EAAE,CAAE,YAAW,WAAW;IAChG,QAAQ,CAAC,SAAS,UAAU;IAC5B,QAAQ,CAAC,aAAa,EAAE,OAAO,CAAC;IAChC,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;gBAEpB,aAAa,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,CAAC,MAAM,CAAC;IAK1D,IAAI,OAAO,IAAI,OAAO,CAErB;IAED,MAAM,CAAC,WAAW,EAAE,OAAO,GAAG,OAAO;IASrC,QAAQ,CAAC,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;CACzC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@schorts/shared-kernel",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.5",
|
|
4
4
|
"description": "A modular, type-safe foundation for building expressive, maintainable applications. This package provides core abstractions for domain modeling, HTTP integration, authentication, state management, and more — designed to be framework-agnostic and highly extensible.",
|
|
5
5
|
"main": "./dist/cjs/index.js",
|
|
6
6
|
"module": "./dist/esm/index.js",
|
|
@@ -1,29 +1,26 @@
|
|
|
1
|
-
import { ValueObject } from
|
|
1
|
+
import { ValueObject } from "./value-object";
|
|
2
2
|
|
|
3
|
-
export abstract class EnumValue<
|
|
3
|
+
export abstract class EnumValue<Allowed extends readonly (string | null)[]> implements ValueObject {
|
|
4
4
|
readonly valueType = 'Enum';
|
|
5
|
-
readonly allowedValues:
|
|
6
|
-
readonly
|
|
7
|
-
readonly value: Type | null;
|
|
5
|
+
readonly allowedValues: Allowed;
|
|
6
|
+
readonly value: Allowed[number];
|
|
8
7
|
|
|
9
|
-
constructor(allowedValues:
|
|
8
|
+
constructor(allowedValues: Allowed, value: Allowed[number]) {
|
|
10
9
|
this.allowedValues = allowedValues;
|
|
11
|
-
this.optional = optional;
|
|
12
10
|
this.value = value;
|
|
13
11
|
}
|
|
14
12
|
|
|
15
13
|
get isValid(): boolean {
|
|
16
|
-
|
|
17
|
-
if (!this.optional && this.value === null) return false;
|
|
18
|
-
|
|
19
|
-
return this.allowedValues.includes(this.value as Type);
|
|
14
|
+
return this.allowedValues.includes(this.value);
|
|
20
15
|
}
|
|
21
16
|
|
|
22
17
|
equals(valueObject: unknown): boolean {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
18
|
+
return (
|
|
19
|
+
valueObject instanceof EnumValue &&
|
|
20
|
+
this.isValid &&
|
|
21
|
+
valueObject.isValid &&
|
|
22
|
+
this.value === valueObject.value
|
|
23
|
+
);
|
|
27
24
|
}
|
|
28
25
|
|
|
29
26
|
abstract readonly attributeName: string;
|