@cullet/erp-core 1.2.0 → 1.3.0

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 (101) hide show
  1. package/dist/app-error.d.cts +108 -0
  2. package/dist/application/index.cjs +26 -0
  3. package/dist/application/index.d.cts +2 -0
  4. package/dist/domain/index.cjs +16 -0
  5. package/dist/domain/index.d.cts +3 -0
  6. package/dist/domain-event-contracts.cjs +33 -0
  7. package/dist/domain-event-contracts.cjs.map +1 -0
  8. package/dist/domain-event-contracts.d.cts +27 -0
  9. package/dist/domain-exception.cjs +17 -0
  10. package/dist/domain-exception.cjs.map +1 -0
  11. package/dist/domain-exception.d.cts +7 -0
  12. package/dist/errors/index.cjs +41 -0
  13. package/dist/errors/index.d.cts +3 -0
  14. package/dist/exceptions/index.cjs +17 -0
  15. package/dist/exceptions/index.d.cts +5 -0
  16. package/dist/exceptions/validation-field.cjs +3 -0
  17. package/dist/exceptions/validation-field.d.cts +2 -0
  18. package/dist/gate-engine-registry.cjs +308 -0
  19. package/dist/gate-engine-registry.cjs.map +1 -0
  20. package/dist/gate-engine-registry.d.cts +81 -0
  21. package/dist/gate-types.d.cts +171 -0
  22. package/dist/gate-v1-payload.schema.cjs +638 -0
  23. package/dist/gate-v1-payload.schema.cjs.map +1 -0
  24. package/dist/hashing.cjs +66 -0
  25. package/dist/hashing.cjs.map +1 -0
  26. package/dist/immutable.cjs +77 -0
  27. package/dist/immutable.cjs.map +1 -0
  28. package/dist/immutable.d.cts +6 -0
  29. package/dist/index.cjs +163 -0
  30. package/dist/index.cjs.map +1 -0
  31. package/dist/index.d.cts +30 -0
  32. package/dist/index.d.ts +2 -2
  33. package/dist/index.js +1 -1
  34. package/dist/index.js.map +1 -1
  35. package/dist/invalid-state-transition-exception.cjs +47 -0
  36. package/dist/invalid-state-transition-exception.cjs.map +1 -0
  37. package/dist/invariant-violation-exception.cjs +16 -0
  38. package/dist/invariant-violation-exception.cjs.map +1 -0
  39. package/dist/not-found-error.cjs +65 -0
  40. package/dist/not-found-error.cjs.map +1 -0
  41. package/dist/outcome.cjs +97 -0
  42. package/dist/outcome.cjs.map +1 -0
  43. package/dist/outcome.d.cts +140 -0
  44. package/dist/parse-gate-payload.d.cts +62 -0
  45. package/dist/path.d.cts +90 -0
  46. package/dist/plugin.cjs +79 -0
  47. package/dist/plugin.cjs.map +1 -0
  48. package/dist/plugin.d.cts +85 -0
  49. package/dist/plugins/index.cjs +3 -0
  50. package/dist/plugins/index.d.cts +2 -0
  51. package/dist/policies/engines/index.cjs +10 -0
  52. package/dist/policies/engines/index.d.cts +4 -0
  53. package/dist/policies/engines/v1/gate/index.cjs +91 -0
  54. package/dist/policies/engines/v1/gate/index.cjs.map +1 -0
  55. package/dist/policies/engines/v1/gate/index.d.cts +121 -0
  56. package/dist/policies/index.cjs +41 -0
  57. package/dist/policies/index.d.cts +7 -0
  58. package/dist/policy-service.cjs +1190 -0
  59. package/dist/policy-service.cjs.map +1 -0
  60. package/dist/policy-service.d.cts +559 -0
  61. package/dist/result/index.cjs +7 -0
  62. package/dist/result/index.d.cts +2 -0
  63. package/dist/result.cjs +135 -0
  64. package/dist/result.cjs.map +1 -0
  65. package/dist/ruleset-registry.cjs +47 -0
  66. package/dist/ruleset-registry.cjs.map +1 -0
  67. package/dist/rulesets/index.cjs +3 -0
  68. package/dist/rulesets/index.d.cts +2 -0
  69. package/dist/temporal-guards.cjs +32 -0
  70. package/dist/temporal-guards.cjs.map +1 -0
  71. package/dist/temporal-use-case.cjs +191 -0
  72. package/dist/temporal-use-case.cjs.map +1 -0
  73. package/dist/temporal-use-case.d.cts +304 -0
  74. package/dist/unexpected-error.cjs +208 -0
  75. package/dist/unexpected-error.cjs.map +1 -0
  76. package/dist/use-case.cjs +96 -0
  77. package/dist/use-case.cjs.map +1 -0
  78. package/dist/uuid-identifier.cjs +65 -0
  79. package/dist/uuid-identifier.cjs.map +1 -0
  80. package/dist/uuid-identifier.d.cts +230 -0
  81. package/dist/validation-code.cjs +60 -0
  82. package/dist/validation-code.cjs.map +1 -0
  83. package/dist/validation-code.d.cts +23 -0
  84. package/dist/validation-error.cjs +1020 -0
  85. package/dist/validation-error.cjs.map +1 -0
  86. package/dist/validation-error.d.cts +777 -0
  87. package/dist/validation-exception.cjs +41 -0
  88. package/dist/validation-exception.cjs.map +1 -0
  89. package/dist/validation-exception.d.cts +50 -0
  90. package/dist/validation-field.cjs +28 -0
  91. package/dist/validation-field.cjs.map +1 -0
  92. package/dist/validation-field.d.cts +12 -0
  93. package/dist/value-object-ruleset.contracts.d.cts +36 -0
  94. package/dist/value-object.cjs +208 -0
  95. package/dist/value-object.cjs.map +1 -0
  96. package/dist/version.d.cts +10 -0
  97. package/dist/versioning/index.cjs +7 -0
  98. package/dist/versioning/index.d.cts +3 -0
  99. package/meta.json +3 -2
  100. package/package.json +147 -28
  101. package/src/version.ts +1 -1
@@ -0,0 +1,135 @@
1
+ //#region src/core/result/result.ts
2
+ /**
3
+ * Represents the outcome of an operation that may succeed or fail.
4
+ * Useful for avoiding excessive exceptions and making error flows explicit.
5
+ */
6
+ var Result = class Result {
7
+ constructor() {}
8
+ /**
9
+ * Creates a success result containing a value.
10
+ */
11
+ static ok(value) {
12
+ return new Ok(value);
13
+ }
14
+ /**
15
+ * Creates an error result containing an error object.
16
+ */
17
+ static err(error) {
18
+ return new Err(error);
19
+ }
20
+ /**
21
+ * Returns the value when this is success, or null when this is an error.
22
+ */
23
+ getOrNull() {
24
+ return this.match({
25
+ ok: (value) => value,
26
+ err: () => null
27
+ });
28
+ }
29
+ /**
30
+ * Returns the error when this is a failure, or null when this is a success.
31
+ */
32
+ errorOrNull() {
33
+ return this.match({
34
+ ok: () => null,
35
+ err: (error) => error
36
+ });
37
+ }
38
+ /**
39
+ * Returns the value when this is a success, or throws the error when this is a failure.
40
+ */
41
+ getOrThrow() {
42
+ return this.match({
43
+ ok: (value) => value,
44
+ err: (error) => {
45
+ throw error instanceof Error ? error : new Error(String(error));
46
+ }
47
+ });
48
+ }
49
+ /**
50
+ * Transforms the success value using the provided function. Keeps the error when this is a failure.
51
+ */
52
+ map(transform) {
53
+ return this.match({
54
+ ok: (value) => Result.ok(transform(value)),
55
+ err: (error) => Result.err(error)
56
+ });
57
+ }
58
+ /**
59
+ * Transforms the error using the provided function. Keeps the value when this is a success.
60
+ */
61
+ mapError(transform) {
62
+ return this.match({
63
+ ok: (value) => Result.ok(value),
64
+ err: (error) => Result.err(transform(error))
65
+ });
66
+ }
67
+ /**
68
+ * Chains another operation that returns a Result when this result is a success.
69
+ */
70
+ flatMap(transform) {
71
+ return this.match({
72
+ ok: (value) => transform(value),
73
+ err: (error) => Result.err(error)
74
+ });
75
+ }
76
+ };
77
+ /**
78
+ * Success variant of Result.
79
+ */
80
+ var Ok = class extends Result {
81
+ constructor(value) {
82
+ super();
83
+ this.value = value;
84
+ Object.freeze(this);
85
+ }
86
+ isOk() {
87
+ return true;
88
+ }
89
+ isErr() {
90
+ return false;
91
+ }
92
+ match(handlers) {
93
+ return handlers.ok(this.value);
94
+ }
95
+ };
96
+ /**
97
+ * Error variant of Result.
98
+ */
99
+ var Err = class extends Result {
100
+ constructor(error) {
101
+ super();
102
+ this.error = error;
103
+ Object.freeze(this);
104
+ }
105
+ isOk() {
106
+ return false;
107
+ }
108
+ isErr() {
109
+ return true;
110
+ }
111
+ match(handlers) {
112
+ return handlers.err(this.error);
113
+ }
114
+ };
115
+ //#endregion
116
+ Object.defineProperty(exports, "Err", {
117
+ enumerable: true,
118
+ get: function() {
119
+ return Err;
120
+ }
121
+ });
122
+ Object.defineProperty(exports, "Ok", {
123
+ enumerable: true,
124
+ get: function() {
125
+ return Ok;
126
+ }
127
+ });
128
+ Object.defineProperty(exports, "Result", {
129
+ enumerable: true,
130
+ get: function() {
131
+ return Result;
132
+ }
133
+ });
134
+
135
+ //# sourceMappingURL=result.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"result.cjs","names":[],"sources":["../src/core/result/result.ts"],"sourcesContent":["/**\n * Represents the outcome of an operation that may succeed or fail.\n * Useful for avoiding excessive exceptions and making error flows explicit.\n */\nexport abstract class Result<T, E> {\n protected constructor() {\n // prevent direct instantiation\n }\n\n /**\n * Creates a success result containing a value.\n */\n static ok<T>(value: T): Result<T, never> {\n return new Ok(value);\n }\n\n /**\n * Creates an error result containing an error object.\n */\n static err<E>(error: E): Result<never, E> {\n return new Err(error);\n }\n\n /**\n * Returns true when this is a success result.\n */\n abstract isOk(): this is Ok<T>;\n\n /**\n * Returns true when this is an error result.\n */\n abstract isErr(): this is Err<E>;\n\n /**\n * Runs a handler based on the result state (similar to pattern matching).\n */\n abstract match<R>(handlers: {\n ok: (value: T) => R;\n err: (error: E) => R;\n }): R;\n\n /**\n * Returns the value when this is success, or null when this is an error.\n */\n getOrNull(): T | null {\n return this.match({\n ok: (value) => value,\n err: () => null,\n });\n }\n\n /**\n * Returns the error when this is a failure, or null when this is a success.\n */\n errorOrNull(): E | null {\n return this.match({\n ok: () => null,\n err: (error) => error,\n });\n }\n\n /**\n * Returns the value when this is a success, or throws the error when this is a failure.\n */\n getOrThrow(): T {\n return this.match({\n ok: (value) => value,\n err: (error) => {\n throw error instanceof Error ? error : new Error(String(error));\n },\n });\n }\n\n /**\n * Transforms the success value using the provided function. Keeps the error when this is a failure.\n */\n map<R>(transform: (value: T) => R): Result<R, E> {\n return this.match<Result<R, E>>({\n ok: (value) => Result.ok(transform(value)),\n // TS does not \"see\" variance here; the cast is intentional and safe:\n // Err carries no T, so it can be widened to Result<R, E> safely.\n err: (error) => Result.err(error) as unknown as Result<R, E>,\n });\n }\n\n /**\n * Transforms the error using the provided function. Keeps the value when this is a success.\n */\n mapError<F>(transform: (error: E) => F): Result<T, F> {\n return this.match<Result<T, F>>({\n // Ok carries no E, so it can be widened to Result<T, F>.\n ok: (value) => Result.ok(value) as unknown as Result<T, F>,\n err: (error) => Result.err(transform(error)),\n });\n }\n\n /**\n * Chains another operation that returns a Result when this result is a success.\n */\n flatMap<R>(transform: (value: T) => Result<R, E>): Result<R, E> {\n return this.match<Result<R, E>>({\n ok: (value) => transform(value),\n err: (error) => Result.err(error) as unknown as Result<R, E>,\n });\n }\n}\n\n/**\n * Success variant of Result.\n */\nexport class Ok<T> extends Result<T, never> {\n public readonly value: T;\n\n constructor(value: T) {\n super();\n this.value = value;\n Object.freeze(this);\n }\n\n isOk(): this is Ok<T> {\n return true;\n }\n\n isErr(): this is Err<never> {\n return false;\n }\n\n match<R>(handlers: { ok: (value: T) => R; err: (error: never) => R }): R {\n return handlers.ok(this.value);\n }\n}\n\n/**\n * Error variant of Result.\n */\nexport class Err<E> extends Result<never, E> {\n public readonly error: E;\n\n constructor(error: E) {\n super();\n this.error = error;\n Object.freeze(this);\n }\n\n isOk(): this is Ok<never> {\n return false;\n }\n\n isErr(): this is Err<E> {\n return true;\n }\n\n match<R>(handlers: { ok: (value: never) => R; err: (error: E) => R }): R {\n return handlers.err(this.error);\n }\n}\n"],"mappings":";;;;;AAIA,IAAsB,SAAtB,MAAsB,OAAa;CAC/B,cAAwB,CAExB;;;;CAKA,OAAO,GAAM,OAA4B;EACrC,OAAO,IAAI,GAAG,KAAK;CACvB;;;;CAKA,OAAO,IAAO,OAA4B;EACtC,OAAO,IAAI,IAAI,KAAK;CACxB;;;;CAuBA,YAAsB;EAClB,OAAO,KAAK,MAAM;GACd,KAAK,UAAU;GACf,WAAW;EACf,CAAC;CACL;;;;CAKA,cAAwB;EACpB,OAAO,KAAK,MAAM;GACd,UAAU;GACV,MAAM,UAAU;EACpB,CAAC;CACL;;;;CAKA,aAAgB;EACZ,OAAO,KAAK,MAAM;GACd,KAAK,UAAU;GACf,MAAM,UAAU;IACZ,MAAM,iBAAiB,QAAQ,QAAQ,IAAI,MAAM,OAAO,KAAK,CAAC;GAClE;EACJ,CAAC;CACL;;;;CAKA,IAAO,WAA0C;EAC7C,OAAO,KAAK,MAAoB;GAC5B,KAAK,UAAU,OAAO,GAAG,UAAU,KAAK,CAAC;GAGzC,MAAM,UAAU,OAAO,IAAI,KAAK;EACpC,CAAC;CACL;;;;CAKA,SAAY,WAA0C;EAClD,OAAO,KAAK,MAAoB;GAE5B,KAAK,UAAU,OAAO,GAAG,KAAK;GAC9B,MAAM,UAAU,OAAO,IAAI,UAAU,KAAK,CAAC;EAC/C,CAAC;CACL;;;;CAKA,QAAW,WAAqD;EAC5D,OAAO,KAAK,MAAoB;GAC5B,KAAK,UAAU,UAAU,KAAK;GAC9B,MAAM,UAAU,OAAO,IAAI,KAAK;EACpC,CAAC;CACL;AACJ;;;;AAKA,IAAa,KAAb,cAA2B,OAAiB;CAGxC,YAAY,OAAU;EAClB,MAAM;EACN,KAAK,QAAQ;EACb,OAAO,OAAO,IAAI;CACtB;CAEA,OAAsB;EAClB,OAAO;CACX;CAEA,QAA4B;EACxB,OAAO;CACX;CAEA,MAAS,UAAgE;EACrE,OAAO,SAAS,GAAG,KAAK,KAAK;CACjC;AACJ;;;;AAKA,IAAa,MAAb,cAA4B,OAAiB;CAGzC,YAAY,OAAU;EAClB,MAAM;EACN,KAAK,QAAQ;EACb,OAAO,OAAO,IAAI;CACtB;CAEA,OAA0B;EACtB,OAAO;CACX;CAEA,QAAwB;EACpB,OAAO;CACX;CAEA,MAAS,UAAgE;EACrE,OAAO,SAAS,IAAI,KAAK,KAAK;CAClC;AACJ"}
@@ -0,0 +1,47 @@
1
+ const require_domain_exception = require("./domain-exception.cjs");
2
+ //#region src/core/domain/rulesets/ruleset-registry.ts
3
+ var RulesetRegistryError = class extends require_domain_exception.DomainException {};
4
+ function parseVersion(id) {
5
+ const atIdx = id.lastIndexOf("@");
6
+ const [major, minor] = id.slice(atIdx + 1).split(".").map(Number);
7
+ return [major, minor];
8
+ }
9
+ var RulesetRegistry = class {
10
+ constructor() {
11
+ this._store = /* @__PURE__ */ new Map();
12
+ this._sealed = false;
13
+ }
14
+ register(ruleset) {
15
+ if (this._sealed) throw new RulesetRegistryError("Registry is sealed. No new rulesets can be registered.");
16
+ if (this._store.has(ruleset.id)) throw new RulesetRegistryError(`Ruleset with id "${ruleset.id}" is already registered.`);
17
+ this._store.set(ruleset.id, ruleset);
18
+ }
19
+ seal() {
20
+ this._sealed = true;
21
+ }
22
+ get(id) {
23
+ const ruleset = this._store.get(id);
24
+ if (!ruleset) throw new RulesetRegistryError(`Ruleset "${id}" not found. Available: [${Array.from(this._store.keys()).join(", ")}]`);
25
+ return ruleset;
26
+ }
27
+ getCurrent(prefix) {
28
+ const matchingEntries = Array.from(this._store.entries()).filter(([key]) => key.startsWith(prefix + "@"));
29
+ if (matchingEntries.length === 0) throw new RulesetRegistryError(`No rulesets found with prefix "${prefix}".`);
30
+ const sorted = matchingEntries.sort(([a], [b]) => {
31
+ const [aMajor, aMinor] = parseVersion(a);
32
+ const [bMajor, bMinor] = parseVersion(b);
33
+ if (aMajor !== bMajor) return aMajor - bMajor;
34
+ return aMinor - bMinor;
35
+ });
36
+ return sorted[sorted.length - 1][1];
37
+ }
38
+ };
39
+ //#endregion
40
+ Object.defineProperty(exports, "RulesetRegistry", {
41
+ enumerable: true,
42
+ get: function() {
43
+ return RulesetRegistry;
44
+ }
45
+ });
46
+
47
+ //# sourceMappingURL=ruleset-registry.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ruleset-registry.cjs","names":["DomainException"],"sources":["../src/core/domain/rulesets/ruleset-registry.ts"],"sourcesContent":["import { DomainException } from \"../../exceptions/domain-exception.js\";\nimport {\n type Ruleset,\n type RulesetRegistry as RulesetRegistryContract,\n} from \"./ruleset.contracts.js\";\n\nclass RulesetRegistryError extends DomainException {}\n\nfunction parseVersion(id: string): [number, number] {\n const atIdx = id.lastIndexOf(\"@\");\n const versionStr = id.slice(atIdx + 1);\n const [major, minor] = versionStr.split(\".\").map(Number);\n return [major, minor];\n}\n\nclass RulesetRegistry implements RulesetRegistryContract {\n private readonly _store = new Map<string, Ruleset>();\n private _sealed = false;\n\n register(ruleset: Ruleset): void {\n if (this._sealed) {\n throw new RulesetRegistryError(\n \"Registry is sealed. No new rulesets can be registered.\",\n );\n }\n if (this._store.has(ruleset.id)) {\n throw new RulesetRegistryError(\n `Ruleset with id \"${ruleset.id}\" is already registered.`,\n );\n }\n this._store.set(ruleset.id, ruleset);\n }\n\n seal(): void {\n this._sealed = true;\n }\n\n get<T extends Ruleset>(id: string): T {\n const ruleset = this._store.get(id);\n if (!ruleset) {\n const available = Array.from(this._store.keys()).join(\", \");\n throw new RulesetRegistryError(\n `Ruleset \"${id}\" not found. Available: [${available}]`,\n );\n }\n return ruleset as T;\n }\n\n getCurrent<T extends Ruleset>(prefix: string): T {\n const matchingEntries = Array.from(this._store.entries()).filter(\n ([key]) => key.startsWith(prefix + \"@\"),\n );\n\n if (matchingEntries.length === 0) {\n throw new RulesetRegistryError(\n `No rulesets found with prefix \"${prefix}\".`,\n );\n }\n\n const sorted = matchingEntries.sort(([a], [b]) => {\n const [aMajor, aMinor] = parseVersion(a);\n const [bMajor, bMinor] = parseVersion(b);\n if (aMajor !== bMajor) return aMajor - bMajor;\n return aMinor - bMinor;\n });\n\n return sorted[sorted.length - 1][1] as T;\n }\n}\n\nexport { RulesetRegistry };\n"],"mappings":";;AAMA,IAAM,uBAAN,cAAmCA,yBAAAA,gBAAgB,CAAC;AAEpD,SAAS,aAAa,IAA8B;CAChD,MAAM,QAAQ,GAAG,YAAY,GAAG;CAEhC,MAAM,CAAC,OAAO,SADK,GAAG,MAAM,QAAQ,CACJ,EAAE,MAAM,GAAG,EAAE,IAAI,MAAM;CACvD,OAAO,CAAC,OAAO,KAAK;AACxB;AAEA,IAAM,kBAAN,MAAyD;;gCAC3B,IAAI,IAAqB;iBACjC;;CAElB,SAAS,SAAwB;EAC7B,IAAI,KAAK,SACL,MAAM,IAAI,qBACN,wDACJ;EAEJ,IAAI,KAAK,OAAO,IAAI,QAAQ,EAAE,GAC1B,MAAM,IAAI,qBACN,oBAAoB,QAAQ,GAAG,yBACnC;EAEJ,KAAK,OAAO,IAAI,QAAQ,IAAI,OAAO;CACvC;CAEA,OAAa;EACT,KAAK,UAAU;CACnB;CAEA,IAAuB,IAAe;EAClC,MAAM,UAAU,KAAK,OAAO,IAAI,EAAE;EAClC,IAAI,CAAC,SAED,MAAM,IAAI,qBACN,YAAY,GAAG,2BAFD,MAAM,KAAK,KAAK,OAAO,KAAK,CAAC,EAAE,KAAK,IAEA,EAAE,EACxD;EAEJ,OAAO;CACX;CAEA,WAA8B,QAAmB;EAC7C,MAAM,kBAAkB,MAAM,KAAK,KAAK,OAAO,QAAQ,CAAC,EAAE,QACrD,CAAC,SAAS,IAAI,WAAW,SAAS,GAAG,CAC1C;EAEA,IAAI,gBAAgB,WAAW,GAC3B,MAAM,IAAI,qBACN,kCAAkC,OAAO,GAC7C;EAGJ,MAAM,SAAS,gBAAgB,MAAM,CAAC,IAAI,CAAC,OAAO;GAC9C,MAAM,CAAC,QAAQ,UAAU,aAAa,CAAC;GACvC,MAAM,CAAC,QAAQ,UAAU,aAAa,CAAC;GACvC,IAAI,WAAW,QAAQ,OAAO,SAAS;GACvC,OAAO,SAAS;EACpB,CAAC;EAED,OAAO,OAAO,OAAO,SAAS,GAAG;CACrC;AACJ"}
@@ -0,0 +1,3 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_ruleset_registry = require("../ruleset-registry.cjs");
3
+ exports.RulesetRegistry = require_ruleset_registry.RulesetRegistry;
@@ -0,0 +1,2 @@
1
+ import { a as Ruleset, i as InvariantRuleset, n as RulesetRegistry, o as RulesetId, r as CreationRuleset, t as ValueObjectRuleset } from "../value-object-ruleset.contracts.cjs";
2
+ export { CreationRuleset, InvariantRuleset, Ruleset, RulesetId, RulesetRegistry, ValueObjectRuleset };
@@ -0,0 +1,32 @@
1
+ const require_invariant_violation_exception = require("./invariant-violation-exception.cjs");
2
+ //#region src/core/shared/temporal-guards.ts
3
+ function isValidDate(value) {
4
+ return value instanceof Date && !Number.isNaN(value.getTime());
5
+ }
6
+ function cloneDate(date) {
7
+ return new Date(date.getTime());
8
+ }
9
+ function assertValidDate(fieldName, value) {
10
+ if (!isValidDate(value)) throw new require_invariant_violation_exception.InvariantViolationException(`${fieldName} must be a valid Date instance`);
11
+ }
12
+ //#endregion
13
+ Object.defineProperty(exports, "assertValidDate", {
14
+ enumerable: true,
15
+ get: function() {
16
+ return assertValidDate;
17
+ }
18
+ });
19
+ Object.defineProperty(exports, "cloneDate", {
20
+ enumerable: true,
21
+ get: function() {
22
+ return cloneDate;
23
+ }
24
+ });
25
+ Object.defineProperty(exports, "isValidDate", {
26
+ enumerable: true,
27
+ get: function() {
28
+ return isValidDate;
29
+ }
30
+ });
31
+
32
+ //# sourceMappingURL=temporal-guards.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"temporal-guards.cjs","names":["InvariantViolationException"],"sources":["../src/core/shared/temporal-guards.ts"],"sourcesContent":["import { InvariantViolationException } from \"../exceptions/invariant-violation-exception.js\";\n\nfunction isValidDate(value: unknown): value is Date {\n return value instanceof Date && !Number.isNaN(value.getTime());\n}\n\nfunction cloneDate(date: Date): Date {\n return new Date(date.getTime());\n}\n\nfunction assertValidDate(\n fieldName: string,\n value: unknown,\n): asserts value is Date {\n if (!isValidDate(value)) {\n throw new InvariantViolationException(\n `${fieldName} must be a valid Date instance`,\n );\n }\n}\n\nexport { assertValidDate, cloneDate, isValidDate };\n"],"mappings":";;AAEA,SAAS,YAAY,OAA+B;CAChD,OAAO,iBAAiB,QAAQ,CAAC,OAAO,MAAM,MAAM,QAAQ,CAAC;AACjE;AAEA,SAAS,UAAU,MAAkB;CACjC,OAAO,IAAI,KAAK,KAAK,QAAQ,CAAC;AAClC;AAEA,SAAS,gBACL,WACA,OACqB;CACrB,IAAI,CAAC,YAAY,KAAK,GAClB,MAAM,IAAIA,sCAAAA,4BACN,GAAG,UAAU,+BACjB;AAER"}
@@ -0,0 +1,191 @@
1
+ const require_unexpected_error = require("./unexpected-error.cjs");
2
+ const require_not_found_error = require("./not-found-error.cjs");
3
+ const require_validation_code = require("./validation-code.cjs");
4
+ const require_validation_field = require("./validation-field.cjs");
5
+ const require_validation_exception = require("./validation-exception.cjs");
6
+ const require_immutable = require("./immutable.cjs");
7
+ const require_use_case = require("./use-case.cjs");
8
+ const require_temporal_guards = require("./temporal-guards.cjs");
9
+ //#region src/core/application/commands/requested-by.ts
10
+ const REQUESTED_BY_FIELD = require_validation_field.ValidationField.of("requestedBy");
11
+ const UUID_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
12
+ const SYSTEM_IDENTITY_PATTERN = /^system:[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/;
13
+ var RequestedBy = class RequestedBy {
14
+ constructor(kind, raw) {
15
+ this.kind = kind;
16
+ this.raw = raw;
17
+ Object.freeze(this);
18
+ }
19
+ /** Builds from a human user ID (must be a UUID). */
20
+ static fromUser(userId) {
21
+ if (!UUID_PATTERN.test(userId)) throw new require_validation_exception.InvalidValueException(REQUESTED_BY_FIELD, require_validation_code.ValidationCode.INVALID_FORMAT, `requestedBy: user identity must be a UUID, got "${userId}"`);
22
+ return new RequestedBy("user", userId);
23
+ }
24
+ /**
25
+ * Builds from a system identity.
26
+ * Only accepts the format "system:<job>", where <job> matches [a-z][a-z0-9]*(-[a-z0-9]+)*.
27
+ */
28
+ static fromSystem(systemIdentity) {
29
+ if (!SYSTEM_IDENTITY_PATTERN.test(systemIdentity)) throw new require_validation_exception.InvalidValueException(REQUESTED_BY_FIELD, require_validation_code.ValidationCode.INVALID_FORMAT, `requestedBy: system identity must match "system:<job>" (e.g. "system:late-fee-job"), got "${systemIdentity}"`);
30
+ return new RequestedBy("system", systemIdentity);
31
+ }
32
+ /**
33
+ * Infers the kind from the raw value.
34
+ * Use when the origin (user vs system) is not known at the call-site.
35
+ */
36
+ static parse(raw) {
37
+ if (UUID_PATTERN.test(raw)) return new RequestedBy("user", raw);
38
+ if (SYSTEM_IDENTITY_PATTERN.test(raw)) return new RequestedBy("system", raw);
39
+ throw new require_validation_exception.InvalidValueException(REQUESTED_BY_FIELD, require_validation_code.ValidationCode.INVALID_FORMAT, `requestedBy must be a UUID (user) or "system:<job>" (system), got "${raw}"`);
40
+ }
41
+ get isUser() {
42
+ return this.kind === "user";
43
+ }
44
+ get isSystem() {
45
+ return this.kind === "system";
46
+ }
47
+ toString() {
48
+ return this.raw;
49
+ }
50
+ };
51
+ //#endregion
52
+ //#region src/core/application/commands/command.ts
53
+ /**
54
+ * Base for use cases that **mutate state** (writes), following CQS.
55
+ *
56
+ * - `Input extends CommandInput` ensures every mutation records who triggered it.
57
+ * - `Output extends Result<unknown, unknown>` ensures business errors are
58
+ * explicit values, never thrown exceptions.
59
+ *
60
+ * The Command/Query distinction is semantic: the type declares the intent
61
+ * before any implementation exists, guiding code review and API contracts.
62
+ */
63
+ let Command = class Command extends require_use_case.UseCase {};
64
+ Command = require_immutable.__decorate([require_immutable.version("1.0")], Command);
65
+ //#endregion
66
+ //#region src/core/application/policy-error-mapper.ts
67
+ function mapPolicyEvaluationError(err) {
68
+ switch (err.kind) {
69
+ case "INVALID_CONTEXT": return new require_not_found_error.BusinessRuleViolationError(`policy.${err.stage.toLowerCase()}`, err.message, {
70
+ policyKey: err.policyKey,
71
+ stage: err.stage
72
+ }, { cause: err.cause });
73
+ case "INVALID_POLICY_KEY": return new require_not_found_error.BusinessRuleViolationError("policy.invalid_key", err.message, { rawPolicyKey: err.rawPolicyKey }, { cause: err.cause });
74
+ case "POLICY_NOT_FOUND": return new require_not_found_error.NotFoundError("Policy", { policyKey: err.policyKey }, { cause: err.cause });
75
+ case "POLICY_DEFINITION_NOT_FOUND": return new require_not_found_error.NotFoundError("PolicyDefinition", {
76
+ policyKey: err.policyKey,
77
+ contextVersion: err.contextVersion,
78
+ asOf: err.asOf.toISOString()
79
+ }, { cause: err.cause });
80
+ case "POLICY_VARIANT_NOT_FOUND": return new require_not_found_error.NotFoundError("PolicyVariant", {
81
+ policyKey: err.policyKey,
82
+ policyKind: err.policyKind,
83
+ payloadSchemaVersion: err.payloadSchemaVersion
84
+ }, { cause: err.cause });
85
+ case "ENGINE_FAILURE": return new require_unexpected_error.UnexpectedError(err.message, err.cause, { metadata: {
86
+ policyKey: err.policyKey,
87
+ engine: err.engine,
88
+ engineVersion: err.engineVersion
89
+ } });
90
+ }
91
+ }
92
+ //#endregion
93
+ //#region src/core/application/queries/query.ts
94
+ /**
95
+ * Base for use cases that **only read state**, with no side effects, following CQS.
96
+ *
97
+ * - `Data extends QueryOutput` prevents a query from declaring a `void` or
98
+ * `undefined` success payload, while still allowing primitive projections
99
+ * and `null` when that makes sense for the read. Failures stay explicit in
100
+ * `Result<T, E>`.
101
+ * - Override `cacheStrategy()` to declare how infrastructure should cache the
102
+ * result. By default, no cache is applied.
103
+ *
104
+ * A Query must never mutate persisted data — its execution must be idempotent
105
+ * and safe to call multiple times with the same input.
106
+ */
107
+ let Query = class Query extends require_use_case.UseCase {
108
+ cacheStrategy() {
109
+ return { kind: "NO_CACHE" };
110
+ }
111
+ };
112
+ Query = require_immutable.__decorate([require_immutable.version("1.0")], Query);
113
+ //#endregion
114
+ //#region src/core/application/temporal/temporal-context.ts
115
+ function assertTemporalContext(temporalContext, fieldName = "temporalContext") {
116
+ require_temporal_guards.assertValidDate(`${fieldName}.asOf`, temporalContext.asOf);
117
+ require_temporal_guards.assertValidDate(`${fieldName}.requestedAt`, temporalContext.requestedAt);
118
+ }
119
+ function createTemporalContext(input = {}) {
120
+ const requestedAt = input.requestedAt ?? /* @__PURE__ */ new Date();
121
+ const asOf = input.asOf ?? requestedAt;
122
+ assertTemporalContext({
123
+ asOf,
124
+ requestedAt
125
+ });
126
+ return require_immutable.makeImmutable({
127
+ asOf,
128
+ requestedAt
129
+ });
130
+ }
131
+ //#endregion
132
+ //#region src/core/application/temporal/temporal-use-case.ts
133
+ var TemporalUseCase = class extends require_use_case.UseCase {
134
+ resolveTemporalContext(input) {
135
+ return createTemporalContext(input.temporalContext);
136
+ }
137
+ buildPolicySeed(seed, temporalContext) {
138
+ return Object.freeze({
139
+ ...seed,
140
+ fields: {
141
+ ...seed.fields,
142
+ now: new Date(temporalContext.requestedAt.getTime())
143
+ }
144
+ });
145
+ }
146
+ };
147
+ //#endregion
148
+ Object.defineProperty(exports, "Command", {
149
+ enumerable: true,
150
+ get: function() {
151
+ return Command;
152
+ }
153
+ });
154
+ Object.defineProperty(exports, "Query", {
155
+ enumerable: true,
156
+ get: function() {
157
+ return Query;
158
+ }
159
+ });
160
+ Object.defineProperty(exports, "RequestedBy", {
161
+ enumerable: true,
162
+ get: function() {
163
+ return RequestedBy;
164
+ }
165
+ });
166
+ Object.defineProperty(exports, "TemporalUseCase", {
167
+ enumerable: true,
168
+ get: function() {
169
+ return TemporalUseCase;
170
+ }
171
+ });
172
+ Object.defineProperty(exports, "assertTemporalContext", {
173
+ enumerable: true,
174
+ get: function() {
175
+ return assertTemporalContext;
176
+ }
177
+ });
178
+ Object.defineProperty(exports, "createTemporalContext", {
179
+ enumerable: true,
180
+ get: function() {
181
+ return createTemporalContext;
182
+ }
183
+ });
184
+ Object.defineProperty(exports, "mapPolicyEvaluationError", {
185
+ enumerable: true,
186
+ get: function() {
187
+ return mapPolicyEvaluationError;
188
+ }
189
+ });
190
+
191
+ //# sourceMappingURL=temporal-use-case.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"temporal-use-case.cjs","names":["ValidationField","InvalidValueException","ValidationCode","UseCase","version","BusinessRuleViolationError","NotFoundError","UnexpectedError","UseCase","version","makeImmutable","UseCase"],"sources":["../src/core/application/commands/requested-by.ts","../src/core/application/commands/command.ts","../src/core/application/policy-error-mapper.ts","../src/core/application/queries/query.ts","../src/core/application/temporal/temporal-context.ts","../src/core/application/temporal/temporal-use-case.ts"],"sourcesContent":["import { ValidationCode } from \"../../exceptions/validation-code.js\";\nimport { InvalidValueException } from \"../../exceptions/validation-exception.js\";\nimport { ValidationField } from \"../../exceptions/validation-field.js\";\n\n// Identifies who triggered a Command.\n// Two valid formats:\n// - Human user: UUID v4 (e.g.: \"550e8400-e29b-41d4-a716-446655440000\")\n// - System identity: \"system:<job>\" where <job> is [a-z][a-z0-9]*(-[a-z0-9]+)*\n// (e.g.: \"system:late-fee-job\", \"system:email-sender\")\n//\n// The split between `fromUser` / `fromSystem` / `parse` exists to make intent\n// explicit at the call-site: whoever builds the value knows where it came from.\n\ntype RequestedByKind = \"user\" | \"system\";\n\nconst REQUESTED_BY_FIELD = ValidationField.of(\"requestedBy\");\n\nconst UUID_PATTERN =\n /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;\n\n// system:<job> where <job> starts with a lowercase letter and may have hyphens between segments\nconst SYSTEM_IDENTITY_PATTERN = /^system:[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/;\n\nclass RequestedBy {\n readonly kind: RequestedByKind;\n readonly raw: string;\n\n private constructor(kind: RequestedByKind, raw: string) {\n this.kind = kind;\n this.raw = raw;\n Object.freeze(this);\n }\n\n /** Builds from a human user ID (must be a UUID). */\n static fromUser(userId: string): RequestedBy {\n if (!UUID_PATTERN.test(userId)) {\n throw new InvalidValueException(\n REQUESTED_BY_FIELD,\n ValidationCode.INVALID_FORMAT,\n `requestedBy: user identity must be a UUID, got \"${userId}\"`,\n );\n }\n\n return new RequestedBy(\"user\", userId);\n }\n\n /**\n * Builds from a system identity.\n * Only accepts the format \"system:<job>\", where <job> matches [a-z][a-z0-9]*(-[a-z0-9]+)*.\n */\n static fromSystem(systemIdentity: string): RequestedBy {\n if (!SYSTEM_IDENTITY_PATTERN.test(systemIdentity)) {\n throw new InvalidValueException(\n REQUESTED_BY_FIELD,\n ValidationCode.INVALID_FORMAT,\n `requestedBy: system identity must match \"system:<job>\" (e.g. \"system:late-fee-job\"), got \"${systemIdentity}\"`,\n );\n }\n\n return new RequestedBy(\"system\", systemIdentity);\n }\n\n /**\n * Infers the kind from the raw value.\n * Use when the origin (user vs system) is not known at the call-site.\n */\n static parse(raw: string): RequestedBy {\n if (UUID_PATTERN.test(raw)) {\n return new RequestedBy(\"user\", raw);\n }\n\n if (SYSTEM_IDENTITY_PATTERN.test(raw)) {\n return new RequestedBy(\"system\", raw);\n }\n\n throw new InvalidValueException(\n REQUESTED_BY_FIELD,\n ValidationCode.INVALID_FORMAT,\n `requestedBy must be a UUID (user) or \"system:<job>\" (system), got \"${raw}\"`,\n );\n }\n\n get isUser(): boolean {\n return this.kind === \"user\";\n }\n\n get isSystem(): boolean {\n return this.kind === \"system\";\n }\n\n toString(): string {\n return this.raw;\n }\n}\n\nexport type { RequestedByKind };\nexport { RequestedBy };\n","import { UseCase } from \"../use-case.js\";\nimport { version } from \"../../versioning/version.js\";\nimport type { Result } from \"../../result/result.js\";\n\nimport { RequestedBy } from \"./requested-by.js\";\n\ninterface CommandInput {\n readonly requestedBy: RequestedBy;\n}\n\n/**\n * Base for use cases that **mutate state** (writes), following CQS.\n *\n * - `Input extends CommandInput` ensures every mutation records who triggered it.\n * - `Output extends Result<unknown, unknown>` ensures business errors are\n * explicit values, never thrown exceptions.\n *\n * The Command/Query distinction is semantic: the type declares the intent\n * before any implementation exists, guiding code review and API contracts.\n */\n@version(\"1.0\")\nabstract class Command<\n Input extends CommandInput,\n Output extends Result<unknown, unknown> = Result<void, never>,\n> extends UseCase<Input, Output> {}\n\nexport type { CommandInput };\nexport { Command };\n","import {\n type AppError,\n BusinessRuleViolationError,\n NotFoundError,\n UnexpectedError,\n} from \"../errors/index.js\";\nimport type { PolicyEvaluationError } from \"../policies/index.js\";\n\nexport function mapPolicyEvaluationError(err: PolicyEvaluationError): AppError {\n switch (err.kind) {\n case \"INVALID_CONTEXT\":\n return new BusinessRuleViolationError(\n `policy.${err.stage.toLowerCase()}`,\n err.message,\n { policyKey: err.policyKey, stage: err.stage },\n { cause: err.cause },\n );\n case \"INVALID_POLICY_KEY\":\n return new BusinessRuleViolationError(\n \"policy.invalid_key\",\n err.message,\n { rawPolicyKey: err.rawPolicyKey },\n { cause: err.cause },\n );\n case \"POLICY_NOT_FOUND\":\n return new NotFoundError(\n \"Policy\",\n { policyKey: err.policyKey },\n { cause: err.cause },\n );\n case \"POLICY_DEFINITION_NOT_FOUND\":\n return new NotFoundError(\n \"PolicyDefinition\",\n {\n policyKey: err.policyKey,\n contextVersion: err.contextVersion,\n asOf: err.asOf.toISOString(),\n },\n { cause: err.cause },\n );\n case \"POLICY_VARIANT_NOT_FOUND\":\n return new NotFoundError(\n \"PolicyVariant\",\n {\n policyKey: err.policyKey,\n policyKind: err.policyKind,\n payloadSchemaVersion: err.payloadSchemaVersion,\n },\n { cause: err.cause },\n );\n case \"ENGINE_FAILURE\":\n return new UnexpectedError(err.message, err.cause, {\n metadata: {\n policyKey: err.policyKey,\n engine: err.engine,\n engineVersion: err.engineVersion,\n },\n });\n }\n}\n","import { UseCase } from \"../use-case.js\";\nimport { version } from \"../../versioning/version.js\";\nimport type { AppError } from \"../../errors/index.js\";\nimport type { Result } from \"../../result/result.js\";\n\n/**\n * Paginated result of a list query.\n * Use as `Output` when the query returns a collection with pagination metadata.\n */\ninterface Page<T> {\n readonly items: readonly T[];\n readonly total: number;\n readonly page: number;\n readonly pageSize: number;\n}\n\n/**\n * Cache strategy declared by the query type.\n * Infrastructure reads this value to decide whether and how to cache the result.\n */\ntype CacheStrategy =\n | { readonly kind: \"NO_CACHE\" }\n | { readonly kind: \"TIME_TO_LIVE\"; readonly ttlMs: number }\n | { readonly kind: \"STALE_WHILE_REVALIDATE\"; readonly ttlMs: number };\n\ntype QueryOutput = object | string | number | boolean | bigint | symbol | null;\n\n/**\n * Base for use cases that **only read state**, with no side effects, following CQS.\n *\n * - `Data extends QueryOutput` prevents a query from declaring a `void` or\n * `undefined` success payload, while still allowing primitive projections\n * and `null` when that makes sense for the read. Failures stay explicit in\n * `Result<T, E>`.\n * - Override `cacheStrategy()` to declare how infrastructure should cache the\n * result. By default, no cache is applied.\n *\n * A Query must never mutate persisted data — its execution must be idempotent\n * and safe to call multiple times with the same input.\n */\n@version(\"1.0\")\nabstract class Query<\n Input = void,\n Data extends QueryOutput = never,\n Failure = AppError,\n> extends UseCase<Input, Result<Data, Failure>> {\n protected cacheStrategy(): CacheStrategy {\n return { kind: \"NO_CACHE\" };\n }\n}\n\nexport type { CacheStrategy, Page, QueryOutput };\nexport { Query };\n","import { makeImmutable } from \"../../shared/immutable.js\";\nimport { assertValidDate } from \"../../shared/temporal-guards.js\";\n\ninterface TemporalContext {\n readonly asOf: Date;\n readonly requestedAt: Date;\n}\n\ninterface CreateTemporalContextInput {\n readonly asOf?: Date;\n readonly requestedAt?: Date;\n}\n\nfunction assertTemporalContext(\n temporalContext: TemporalContext,\n fieldName: string = \"temporalContext\",\n): void {\n assertValidDate(`${fieldName}.asOf`, temporalContext.asOf);\n assertValidDate(`${fieldName}.requestedAt`, temporalContext.requestedAt);\n}\n\nfunction createTemporalContext(\n input: CreateTemporalContextInput = {},\n): TemporalContext {\n const requestedAt = input.requestedAt ?? new Date();\n const asOf = input.asOf ?? requestedAt;\n\n assertTemporalContext({ asOf, requestedAt });\n\n return makeImmutable({\n asOf,\n requestedAt,\n });\n}\n\nexport {\n assertTemporalContext,\n createTemporalContext,\n type CreateTemporalContextInput,\n type TemporalContext,\n};\n","import { UseCase } from \"../use-case.js\";\nimport type { ContextSeed } from \"../../policies/index.js\";\nimport type { Result } from \"../../result/result.js\";\n\nimport {\n createTemporalContext,\n type TemporalContext,\n} from \"./temporal-context.js\";\n\ninterface TemporalUseCaseInput {\n readonly temporalContext?: TemporalContext;\n}\n\n/**\n * A {@link ContextSeed} after temporal enrichment by\n * {@link TemporalUseCase.buildPolicySeed}: structurally identical to `TSeed`,\n * except `fields.now` is now guaranteed present as a `Date` (injected from the\n * resolved {@link TemporalContext}). Downstream policies can therefore read\n * `seed.fields.now` without a presence/type guard.\n */\ntype TemporalizedContextSeed<TSeed extends ContextSeed> = Omit<\n TSeed,\n \"fields\"\n> & {\n readonly fields: TSeed[\"fields\"] & { readonly now: Date };\n};\n\nabstract class TemporalUseCase<\n Input extends object,\n Output extends Result<unknown, unknown>,\n> extends UseCase<Input & TemporalUseCaseInput, Output> {\n protected resolveTemporalContext(\n input: Input & TemporalUseCaseInput,\n ): TemporalContext {\n return createTemporalContext(input.temporalContext);\n }\n\n protected buildPolicySeed<TSeed extends ContextSeed>(\n seed: TSeed,\n temporalContext: TemporalContext,\n ): TemporalizedContextSeed<TSeed> {\n return Object.freeze({\n ...seed,\n fields: {\n ...seed.fields,\n now: new Date(temporalContext.requestedAt.getTime()),\n },\n }) as TemporalizedContextSeed<TSeed>;\n }\n}\n\nexport type { TemporalizedContextSeed, TemporalUseCaseInput };\nexport { TemporalUseCase };\n"],"mappings":"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"}