@schorts/shared-kernel 1.2.3 → 1.3.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.
Files changed (45) hide show
  1. package/CHANGELOG +16 -0
  2. package/README.md +4 -0
  3. package/dist/cjs/index.js +2 -0
  4. package/dist/cjs/index.js.map +1 -1
  5. package/dist/cjs/result/index.js +6 -0
  6. package/dist/cjs/result/index.js.map +1 -0
  7. package/dist/cjs/result/result.js +33 -0
  8. package/dist/cjs/result/result.js.map +1 -0
  9. package/dist/cjs/value-objects/exceptions/index.js +6 -0
  10. package/dist/cjs/value-objects/exceptions/index.js.map +1 -0
  11. package/dist/cjs/value-objects/exceptions/values-not-valid.js +12 -0
  12. package/dist/cjs/value-objects/exceptions/values-not-valid.js.map +1 -0
  13. package/dist/cjs/value-objects/index.js +15 -0
  14. package/dist/cjs/value-objects/index.js.map +1 -1
  15. package/dist/esm/index.js +2 -0
  16. package/dist/esm/index.js.map +1 -1
  17. package/dist/esm/result/index.js +6 -0
  18. package/dist/esm/result/index.js.map +1 -0
  19. package/dist/esm/result/result.js +33 -0
  20. package/dist/esm/result/result.js.map +1 -0
  21. package/dist/esm/value-objects/exceptions/index.js +6 -0
  22. package/dist/esm/value-objects/exceptions/index.js.map +1 -0
  23. package/dist/esm/value-objects/exceptions/values-not-valid.js +12 -0
  24. package/dist/esm/value-objects/exceptions/values-not-valid.js.map +1 -0
  25. package/dist/esm/value-objects/index.js +15 -0
  26. package/dist/esm/value-objects/index.js.map +1 -1
  27. package/dist/types/index.d.ts +2 -0
  28. package/dist/types/index.d.ts.map +1 -1
  29. package/dist/types/result/index.d.ts +2 -0
  30. package/dist/types/result/index.d.ts.map +1 -0
  31. package/dist/types/result/result.d.ts +13 -0
  32. package/dist/types/result/result.d.ts.map +1 -0
  33. package/dist/types/value-objects/exceptions/index.d.ts +2 -0
  34. package/dist/types/value-objects/exceptions/index.d.ts.map +1 -0
  35. package/dist/types/value-objects/exceptions/values-not-valid.d.ts +5 -0
  36. package/dist/types/value-objects/exceptions/values-not-valid.d.ts.map +1 -0
  37. package/dist/types/value-objects/index.d.ts +1 -0
  38. package/dist/types/value-objects/index.d.ts.map +1 -1
  39. package/package.json +16 -6
  40. package/src/index.ts +2 -0
  41. package/src/result/index.ts +1 -0
  42. package/src/result/result.ts +35 -0
  43. package/src/value-objects/exceptions/index.ts +1 -0
  44. package/src/value-objects/exceptions/values-not-valid.ts +9 -0
  45. package/src/value-objects/index.ts +1 -0
package/CHANGELOG CHANGED
@@ -5,6 +5,22 @@ 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
+ ## [1.3.1] - 2025-10-04
9
+
10
+ ### Added
11
+
12
+ - Added `ValuesNotValid` exception to have a central error for value objects.
13
+
14
+ ## [1.3.0] - 2025-10-04
15
+
16
+ ### Added
17
+
18
+ - Added `Result` to have more controlled results in application services.
19
+
20
+ ### Fixed
21
+
22
+ - Added missed exports for `i18n` module.
23
+
8
24
  ## [1.2.3] - 2025-10-03
9
25
 
10
26
  ### Changed
package/README.md CHANGED
@@ -50,6 +50,10 @@ Translation keys are centralized in registries for discoverability and tooling,
50
50
 
51
51
  - **BaseModel:** Base class for serializable, type-safe models.
52
52
 
53
+ ### 🎯 Result
54
+
55
+ - **Result:** Type-safe wrapper for success/failure outcomes. Encapsulates either a value or an error, enforcing disciplined error handling without exceptions. Includes static factories (`success`, `error`), accessors (`getValue`, `getError`), and guards (`isSuccess`, `isFailure`).
56
+
53
57
  ### 🛠 Persistence
54
58
 
55
59
  - **DAO:** Generic interface defining data access operations for domain entities.
package/dist/cjs/index.js CHANGED
@@ -21,9 +21,11 @@ __exportStar(require("./domain-events"), exports);
21
21
  __exportStar(require("./entities"), exports);
22
22
  __exportStar(require("./formatters"), exports);
23
23
  __exportStar(require("./http"), exports);
24
+ __exportStar(require("./i18n"), exports);
24
25
  __exportStar(require("./json-api"), exports);
25
26
  __exportStar(require("./messages"), exports);
26
27
  __exportStar(require("./models"), exports);
28
+ __exportStar(require("./result"), exports);
27
29
  __exportStar(require("./state-manager"), exports);
28
30
  __exportStar(require("./unit-of-work"), exports);
29
31
  __exportStar(require("./utils"), exports);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,yCAAuB;AACvB,6CAA2B;AAC3B,wCAAsB;AACtB,kDAAgC;AAChC,6CAA2B;AAC3B,+CAA6B;AAC7B,yCAAuB;AACvB,6CAA2B;AAC3B,6CAA2B;AAC3B,2CAAyB;AACzB,kDAAgC;AAChC,iDAA+B;AAC/B,0CAAwB;AACxB,kDAAgC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,yCAAuB;AACvB,6CAA2B;AAC3B,wCAAsB;AACtB,kDAAgC;AAChC,6CAA2B;AAC3B,+CAA6B;AAC7B,yCAAuB;AACvB,yCAAuB;AACvB,6CAA2B;AAC3B,6CAA2B;AAC3B,2CAAyB;AACzB,2CAAyB;AACzB,kDAAgC;AAChC,iDAA+B;AAC/B,0CAAwB;AACxB,kDAAgC"}
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Result = void 0;
4
+ var result_1 = require("./result");
5
+ Object.defineProperty(exports, "Result", { enumerable: true, get: function () { return result_1.Result; } });
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/result/index.ts"],"names":[],"mappings":";;;AAAA,mCAAkC;AAAzB,gGAAA,MAAM,OAAA"}
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Result = void 0;
4
+ class Result {
5
+ success;
6
+ value;
7
+ error;
8
+ constructor(success, value, error) {
9
+ this.success = success;
10
+ this.value = value;
11
+ this.error = error;
12
+ }
13
+ static success(value) {
14
+ return new Result(true, value);
15
+ }
16
+ static error(error) {
17
+ return new Result(false, undefined, error);
18
+ }
19
+ isSuccess() {
20
+ return this.success;
21
+ }
22
+ isFailure() {
23
+ return !this.isSuccess();
24
+ }
25
+ getValue() {
26
+ return this.value;
27
+ }
28
+ getError() {
29
+ return this.error;
30
+ }
31
+ }
32
+ exports.Result = Result;
33
+ //# sourceMappingURL=result.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"result.js","sourceRoot":"","sources":["../../../src/result/result.ts"],"names":[],"mappings":";;;AAAA,MAAa,MAAM;IACA,OAAO,CAAU;IACjB,KAAK,CAAmB;IACxB,KAAK,CAAoB;IAE1C,YAAoB,OAAgB,EAAE,KAAY,EAAE,KAAa;QAC/D,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;IAED,MAAM,CAAC,OAAO,CAAO,KAAW;QAC9B,OAAO,IAAI,MAAM,CAAO,IAAI,EAAE,KAAK,CAAC,CAAC;IACvC,CAAC;IAED,MAAM,CAAC,KAAK,CAAO,KAAY;QAC7B,OAAO,IAAI,MAAM,CAAO,KAAK,EAAE,SAAS,EAAE,KAAK,CAAC,CAAC;IACnD,CAAC;IAED,SAAS;QACP,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAED,SAAS;QACP,OAAO,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC;IAC3B,CAAC;IAED,QAAQ;QACN,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;IAED,QAAQ;QACN,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;CACF;AAlCD,wBAkCC"}
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ValuesNotValid = void 0;
4
+ var values_not_valid_1 = require("./values-not-valid");
5
+ Object.defineProperty(exports, "ValuesNotValid", { enumerable: true, get: function () { return values_not_valid_1.ValuesNotValid; } });
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/value-objects/exceptions/index.ts"],"names":[],"mappings":";;;AAAA,uDAAoD;AAA3C,kHAAA,cAAc,OAAA"}
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ValuesNotValid = void 0;
4
+ class ValuesNotValid extends Error {
5
+ errors;
6
+ constructor(errors) {
7
+ super();
8
+ this.errors = errors;
9
+ }
10
+ }
11
+ exports.ValuesNotValid = ValuesNotValid;
12
+ //# sourceMappingURL=values-not-valid.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"values-not-valid.js","sourceRoot":"","sources":["../../../../src/value-objects/exceptions/values-not-valid.ts"],"names":[],"mappings":";;;AAAA,MAAa,cAAe,SAAQ,KAAK;IAC9B,MAAM,CAAe;IAE9B,YAAY,MAAoB;QAC9B,KAAK,EAAE,CAAC;QAER,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;CACF;AARD,wCAQC"}
@@ -1,4 +1,18 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
2
16
  Object.defineProperty(exports, "__esModule", { value: true });
3
17
  exports.CoordinatesValue = exports.IntegerValue = exports.SlugValue = exports.PhoneValue = exports.EmailValue = exports.EnumValue = exports.StringValue = exports.UUIDValue = void 0;
4
18
  var uuid_value_1 = require("./uuid-value");
@@ -17,4 +31,5 @@ var integer_value_1 = require("./integer-value");
17
31
  Object.defineProperty(exports, "IntegerValue", { enumerable: true, get: function () { return integer_value_1.IntegerValue; } });
18
32
  var coordinates_value_1 = require("./coordinates-value");
19
33
  Object.defineProperty(exports, "CoordinatesValue", { enumerable: true, get: function () { return coordinates_value_1.CoordinatesValue; } });
34
+ __exportStar(require("./exceptions"), exports);
20
35
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/value-objects/index.ts"],"names":[],"mappings":";;;AAEA,2CAAyC;AAAhC,uGAAA,SAAS,OAAA;AAClB,+CAA6C;AAApC,2GAAA,WAAW,OAAA;AACpB,2CAAyC;AAAhC,uGAAA,SAAS,OAAA;AAClB,6CAA2C;AAAlC,yGAAA,UAAU,OAAA;AACnB,6CAA2C;AAAlC,yGAAA,UAAU,OAAA;AACnB,2CAAyC;AAAhC,uGAAA,SAAS,OAAA;AAClB,iDAA+C;AAAtC,6GAAA,YAAY,OAAA;AACrB,yDAAuD;AAA9C,qHAAA,gBAAgB,OAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/value-objects/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAEA,2CAAyC;AAAhC,uGAAA,SAAS,OAAA;AAClB,+CAA6C;AAApC,2GAAA,WAAW,OAAA;AACpB,2CAAyC;AAAhC,uGAAA,SAAS,OAAA;AAClB,6CAA2C;AAAlC,yGAAA,UAAU,OAAA;AACnB,6CAA2C;AAAlC,yGAAA,UAAU,OAAA;AACnB,2CAAyC;AAAhC,uGAAA,SAAS,OAAA;AAClB,iDAA+C;AAAtC,6GAAA,YAAY,OAAA;AACrB,yDAAuD;AAA9C,qHAAA,gBAAgB,OAAA;AACzB,+CAA6B"}
package/dist/esm/index.js CHANGED
@@ -21,9 +21,11 @@ __exportStar(require("./domain-events"), exports);
21
21
  __exportStar(require("./entities"), exports);
22
22
  __exportStar(require("./formatters"), exports);
23
23
  __exportStar(require("./http"), exports);
24
+ __exportStar(require("./i18n"), exports);
24
25
  __exportStar(require("./json-api"), exports);
25
26
  __exportStar(require("./messages"), exports);
26
27
  __exportStar(require("./models"), exports);
28
+ __exportStar(require("./result"), exports);
27
29
  __exportStar(require("./state-manager"), exports);
28
30
  __exportStar(require("./unit-of-work"), exports);
29
31
  __exportStar(require("./utils"), exports);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,yCAAuB;AACvB,6CAA2B;AAC3B,wCAAsB;AACtB,kDAAgC;AAChC,6CAA2B;AAC3B,+CAA6B;AAC7B,yCAAuB;AACvB,6CAA2B;AAC3B,6CAA2B;AAC3B,2CAAyB;AACzB,kDAAgC;AAChC,iDAA+B;AAC/B,0CAAwB;AACxB,kDAAgC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,yCAAuB;AACvB,6CAA2B;AAC3B,wCAAsB;AACtB,kDAAgC;AAChC,6CAA2B;AAC3B,+CAA6B;AAC7B,yCAAuB;AACvB,yCAAuB;AACvB,6CAA2B;AAC3B,6CAA2B;AAC3B,2CAAyB;AACzB,2CAAyB;AACzB,kDAAgC;AAChC,iDAA+B;AAC/B,0CAAwB;AACxB,kDAAgC"}
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Result = void 0;
4
+ var result_1 = require("./result");
5
+ Object.defineProperty(exports, "Result", { enumerable: true, get: function () { return result_1.Result; } });
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/result/index.ts"],"names":[],"mappings":";;;AAAA,mCAAkC;AAAzB,gGAAA,MAAM,OAAA"}
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Result = void 0;
4
+ class Result {
5
+ success;
6
+ value;
7
+ error;
8
+ constructor(success, value, error) {
9
+ this.success = success;
10
+ this.value = value;
11
+ this.error = error;
12
+ }
13
+ static success(value) {
14
+ return new Result(true, value);
15
+ }
16
+ static error(error) {
17
+ return new Result(false, undefined, error);
18
+ }
19
+ isSuccess() {
20
+ return this.success;
21
+ }
22
+ isFailure() {
23
+ return !this.isSuccess();
24
+ }
25
+ getValue() {
26
+ return this.value;
27
+ }
28
+ getError() {
29
+ return this.error;
30
+ }
31
+ }
32
+ exports.Result = Result;
33
+ //# sourceMappingURL=result.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"result.js","sourceRoot":"","sources":["../../../src/result/result.ts"],"names":[],"mappings":";;;AAAA,MAAa,MAAM;IACA,OAAO,CAAU;IACjB,KAAK,CAAmB;IACxB,KAAK,CAAoB;IAE1C,YAAoB,OAAgB,EAAE,KAAY,EAAE,KAAa;QAC/D,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;IAED,MAAM,CAAC,OAAO,CAAO,KAAW;QAC9B,OAAO,IAAI,MAAM,CAAO,IAAI,EAAE,KAAK,CAAC,CAAC;IACvC,CAAC;IAED,MAAM,CAAC,KAAK,CAAO,KAAY;QAC7B,OAAO,IAAI,MAAM,CAAO,KAAK,EAAE,SAAS,EAAE,KAAK,CAAC,CAAC;IACnD,CAAC;IAED,SAAS;QACP,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAED,SAAS;QACP,OAAO,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC;IAC3B,CAAC;IAED,QAAQ;QACN,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;IAED,QAAQ;QACN,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;CACF;AAlCD,wBAkCC"}
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ValuesNotValid = void 0;
4
+ var values_not_valid_1 = require("./values-not-valid");
5
+ Object.defineProperty(exports, "ValuesNotValid", { enumerable: true, get: function () { return values_not_valid_1.ValuesNotValid; } });
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/value-objects/exceptions/index.ts"],"names":[],"mappings":";;;AAAA,uDAAoD;AAA3C,kHAAA,cAAc,OAAA"}
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ValuesNotValid = void 0;
4
+ class ValuesNotValid extends Error {
5
+ errors;
6
+ constructor(errors) {
7
+ super();
8
+ this.errors = errors;
9
+ }
10
+ }
11
+ exports.ValuesNotValid = ValuesNotValid;
12
+ //# sourceMappingURL=values-not-valid.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"values-not-valid.js","sourceRoot":"","sources":["../../../../src/value-objects/exceptions/values-not-valid.ts"],"names":[],"mappings":";;;AAAA,MAAa,cAAe,SAAQ,KAAK;IAC9B,MAAM,CAAe;IAE9B,YAAY,MAAoB;QAC9B,KAAK,EAAE,CAAC;QAER,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;CACF;AARD,wCAQC"}
@@ -1,4 +1,18 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
2
16
  Object.defineProperty(exports, "__esModule", { value: true });
3
17
  exports.CoordinatesValue = exports.IntegerValue = exports.SlugValue = exports.PhoneValue = exports.EmailValue = exports.EnumValue = exports.StringValue = exports.UUIDValue = void 0;
4
18
  var uuid_value_1 = require("./uuid-value");
@@ -17,4 +31,5 @@ var integer_value_1 = require("./integer-value");
17
31
  Object.defineProperty(exports, "IntegerValue", { enumerable: true, get: function () { return integer_value_1.IntegerValue; } });
18
32
  var coordinates_value_1 = require("./coordinates-value");
19
33
  Object.defineProperty(exports, "CoordinatesValue", { enumerable: true, get: function () { return coordinates_value_1.CoordinatesValue; } });
34
+ __exportStar(require("./exceptions"), exports);
20
35
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/value-objects/index.ts"],"names":[],"mappings":";;;AAEA,2CAAyC;AAAhC,uGAAA,SAAS,OAAA;AAClB,+CAA6C;AAApC,2GAAA,WAAW,OAAA;AACpB,2CAAyC;AAAhC,uGAAA,SAAS,OAAA;AAClB,6CAA2C;AAAlC,yGAAA,UAAU,OAAA;AACnB,6CAA2C;AAAlC,yGAAA,UAAU,OAAA;AACnB,2CAAyC;AAAhC,uGAAA,SAAS,OAAA;AAClB,iDAA+C;AAAtC,6GAAA,YAAY,OAAA;AACrB,yDAAuD;AAA9C,qHAAA,gBAAgB,OAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/value-objects/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAEA,2CAAyC;AAAhC,uGAAA,SAAS,OAAA;AAClB,+CAA6C;AAApC,2GAAA,WAAW,OAAA;AACpB,2CAAyC;AAAhC,uGAAA,SAAS,OAAA;AAClB,6CAA2C;AAAlC,yGAAA,UAAU,OAAA;AACnB,6CAA2C;AAAlC,yGAAA,UAAU,OAAA;AACnB,2CAAyC;AAAhC,uGAAA,SAAS,OAAA;AAClB,iDAA+C;AAAtC,6GAAA,YAAY,OAAA;AACrB,yDAAuD;AAA9C,qHAAA,gBAAgB,OAAA;AACzB,+CAA6B"}
@@ -5,9 +5,11 @@ export * from "./domain-events";
5
5
  export * from "./entities";
6
6
  export * from "./formatters";
7
7
  export * from "./http";
8
+ export * from "./i18n";
8
9
  export * from "./json-api";
9
10
  export * from "./messages";
10
11
  export * from "./models";
12
+ export * from "./result";
11
13
  export * from "./state-manager";
12
14
  export * from "./unit-of-work";
13
15
  export * from "./utils";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC;AACvB,cAAc,YAAY,CAAC;AAC3B,cAAc,OAAO,CAAC;AACtB,cAAc,iBAAiB,CAAC;AAChC,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,QAAQ,CAAC;AACvB,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,SAAS,CAAC;AACxB,cAAc,iBAAiB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC;AACvB,cAAc,YAAY,CAAC;AAC3B,cAAc,OAAO,CAAC;AACtB,cAAc,iBAAiB,CAAC;AAChC,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,SAAS,CAAC;AACxB,cAAc,iBAAiB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export { Result } from "./result";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/result/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC"}
@@ -0,0 +1,13 @@
1
+ export declare class Result<Type> {
2
+ private readonly success;
3
+ private readonly value;
4
+ private readonly error;
5
+ private constructor();
6
+ static success<Type>(value: Type): Result<Type>;
7
+ static error<Type>(error: Error): Result<Type>;
8
+ isSuccess(): boolean;
9
+ isFailure(): boolean;
10
+ getValue(): Type | undefined;
11
+ getError(): Error | undefined;
12
+ }
13
+ //# sourceMappingURL=result.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"result.d.ts","sourceRoot":"","sources":["../../../src/result/result.ts"],"names":[],"mappings":"AAAA,qBAAa,MAAM,CAAC,IAAI;IACtB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAU;IAClC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAmB;IACzC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAoB;IAE1C,OAAO;IAMP,MAAM,CAAC,OAAO,CAAC,IAAI,EAAE,KAAK,EAAE,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC;IAI/C,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC;IAI9C,SAAS,IAAI,OAAO;IAIpB,SAAS,IAAI,OAAO;IAIpB,QAAQ,IAAI,IAAI,GAAG,SAAS;IAI5B,QAAQ,IAAI,KAAK,GAAG,SAAS;CAG9B"}
@@ -0,0 +1,2 @@
1
+ export { ValuesNotValid } from "./values-not-valid";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/value-objects/exceptions/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC"}
@@ -0,0 +1,5 @@
1
+ export declare class ValuesNotValid extends Error {
2
+ readonly errors: Array<Error>;
3
+ constructor(errors: Array<Error>);
4
+ }
5
+ //# sourceMappingURL=values-not-valid.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"values-not-valid.d.ts","sourceRoot":"","sources":["../../../../src/value-objects/exceptions/values-not-valid.ts"],"names":[],"mappings":"AAAA,qBAAa,cAAe,SAAQ,KAAK;IACvC,QAAQ,CAAC,MAAM,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC;gBAElB,MAAM,EAAE,KAAK,CAAC,KAAK,CAAC;CAKjC"}
@@ -7,4 +7,5 @@ export { PhoneValue } from "./phone-value";
7
7
  export { SlugValue } from "./slug-value";
8
8
  export { IntegerValue } from "./integer-value";
9
9
  export { CoordinatesValue } from "./coordinates-value";
10
+ export * from "./exceptions";
10
11
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/value-objects/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAElD,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/value-objects/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAElD,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,cAAc,cAAc,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@schorts/shared-kernel",
3
- "version": "1.2.3",
3
+ "version": "1.3.1",
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",
@@ -46,6 +46,11 @@
46
46
  "require": "./dist/cjs/http/index.js",
47
47
  "types": "./dist/types/http/index.d.ts"
48
48
  },
49
+ "./i18n": {
50
+ "import": "./dist/esm/i18n/index.js",
51
+ "require": "./dist/cjs/i18n/index.js",
52
+ "types": "./dist/types/i18n/index.d.ts"
53
+ },
49
54
  "./json-api": {
50
55
  "import": "./dist/esm/json-api/index.js",
51
56
  "require": "./dist/cjs/json-api/index.js",
@@ -61,6 +66,16 @@
61
66
  "require": "./dist/cjs/models/index.js",
62
67
  "types": "./dist/types/models/index.d.ts"
63
68
  },
69
+ "./result": {
70
+ "import": "./dist/esm/result/index.js",
71
+ "require": "./dist/cjs/result/index.js",
72
+ "types": "./dist/types/result/index.d.ts"
73
+ },
74
+ "./state-manager": {
75
+ "import": "./dist/esm/state-manager/index.js",
76
+ "require": "./dist/cjs/state-manager/index.js",
77
+ "types": "./dist/types/state-manager/index.d.ts"
78
+ },
64
79
  "./unit-of-work": {
65
80
  "import": "./dist/esm/unit-of-work/index.js",
66
81
  "require": "./dist/cjs/unit-of-work/index.js",
@@ -71,11 +86,6 @@
71
86
  "require": "./dist/cjs/utils/index.js",
72
87
  "types": "./dist/types/utils/index.d.ts"
73
88
  },
74
- "./state-manager": {
75
- "import": "./dist/esm/state-manager/index.js",
76
- "require": "./dist/cjs/state-manager/index.js",
77
- "types": "./dist/types/state-manager/index.d.ts"
78
- },
79
89
  "./value-objects": {
80
90
  "import": "./dist/esm/value-objects/index.js",
81
91
  "require": "./dist/cjs/value-objects/index.js",
package/src/index.ts CHANGED
@@ -5,9 +5,11 @@ export * from "./domain-events";
5
5
  export * from "./entities";
6
6
  export * from "./formatters";
7
7
  export * from "./http";
8
+ export * from "./i18n";
8
9
  export * from "./json-api";
9
10
  export * from "./messages";
10
11
  export * from "./models";
12
+ export * from "./result";
11
13
  export * from "./state-manager";
12
14
  export * from "./unit-of-work";
13
15
  export * from "./utils";
@@ -0,0 +1 @@
1
+ export { Result } from "./result";
@@ -0,0 +1,35 @@
1
+ export class Result<Type> {
2
+ private readonly success: boolean;
3
+ private readonly value: Type | undefined;
4
+ private readonly error: Error | undefined;
5
+
6
+ private constructor(success: boolean, value?: Type, error?: Error) {
7
+ this.success = success;
8
+ this.value = value;
9
+ this.error = error;
10
+ }
11
+
12
+ static success<Type>(value: Type): Result<Type> {
13
+ return new Result<Type>(true, value);
14
+ }
15
+
16
+ static error<Type>(error: Error): Result<Type> {
17
+ return new Result<Type>(false, undefined, error);
18
+ }
19
+
20
+ isSuccess(): boolean {
21
+ return this.success;
22
+ }
23
+
24
+ isFailure(): boolean {
25
+ return !this.isSuccess();
26
+ }
27
+
28
+ getValue(): Type | undefined {
29
+ return this.value;
30
+ }
31
+
32
+ getError(): Error | undefined {
33
+ return this.error;
34
+ }
35
+ }
@@ -0,0 +1 @@
1
+ export { ValuesNotValid } from "./values-not-valid";
@@ -0,0 +1,9 @@
1
+ export class ValuesNotValid extends Error {
2
+ readonly errors: Array<Error>;
3
+
4
+ constructor(errors: Array<Error>) {
5
+ super();
6
+
7
+ this.errors = errors;
8
+ }
9
+ }
@@ -8,3 +8,4 @@ export { PhoneValue } from "./phone-value";
8
8
  export { SlugValue } from "./slug-value";
9
9
  export { IntegerValue } from "./integer-value";
10
10
  export { CoordinatesValue } from "./coordinates-value";
11
+ export * from "./exceptions";