@cullet/erp-core 1.1.0 → 1.2.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.
- package/KIT_CONTEXT.md +1 -67
- package/dist/application/index.d.ts +1 -1
- package/dist/application/index.js +2 -1
- package/dist/domain/index.d.ts +3 -0
- package/dist/domain/index.js +3 -0
- package/dist/domain-event-contracts.d.ts +27 -0
- package/dist/domain-event-contracts.js +22 -0
- package/dist/domain-event-contracts.js.map +1 -0
- package/dist/domain-exception.d.ts +7 -0
- package/dist/domain-exception.js +12 -0
- package/dist/domain-exception.js.map +1 -0
- package/dist/errors/index.js +1 -1
- package/dist/exceptions/index.d.ts +5 -0
- package/dist/exceptions/index.js +7 -0
- package/dist/gate-engine-registry.d.ts +2 -1
- package/dist/gate-engine-registry.js +2 -1
- package/dist/gate-engine-registry.js.map +1 -1
- package/dist/gate-types.d.ts +3 -139
- package/dist/gate-v1-payload.schema.js +2 -116
- package/dist/gate-v1-payload.schema.js.map +1 -1
- package/dist/immutable.d.ts +6 -0
- package/dist/immutable.js +54 -0
- package/dist/immutable.js.map +1 -0
- package/dist/index.d.ts +15 -160
- package/dist/index.js +19 -176
- package/dist/index.js.map +1 -1
- package/dist/invalid-state-transition-exception.js +30 -0
- package/dist/invalid-state-transition-exception.js.map +1 -0
- package/dist/invariant-violation-exception.js +11 -0
- package/dist/invariant-violation-exception.js.map +1 -0
- package/dist/not-found-error.js +1 -1
- package/dist/outcome.d.ts +140 -0
- package/dist/outcome.js +1 -1
- package/dist/parse-gate-payload.d.ts +2 -1
- package/dist/path.d.ts +2 -1
- package/dist/plugin.d.ts +85 -0
- package/dist/plugin.js +74 -0
- package/dist/plugin.js.map +1 -0
- package/dist/plugins/index.d.ts +2 -0
- package/dist/plugins/index.js +2 -0
- package/dist/policies/engines/index.d.ts +1 -1
- package/dist/policies/engines/v1/gate/index.d.ts +2 -1
- package/dist/policies/engines/v1/gate/index.js +2 -1
- package/dist/policies/engines/v1/gate/index.js.map +1 -1
- package/dist/policies/index.d.ts +2 -1
- package/dist/policies/index.js +2 -1
- package/dist/policy-service.d.ts +2 -1
- package/dist/policy-service.js +6 -3
- package/dist/policy-service.js.map +1 -1
- package/dist/result/index.d.ts +2 -0
- package/dist/result/index.js +3 -0
- package/dist/result.js +118 -0
- package/dist/result.js.map +1 -0
- package/dist/ruleset-registry.js +42 -0
- package/dist/ruleset-registry.js.map +1 -0
- package/dist/rulesets/index.d.ts +2 -0
- package/dist/rulesets/index.js +2 -0
- package/dist/temporal-guards.js +2 -17
- package/dist/temporal-guards.js.map +1 -1
- package/dist/temporal-use-case.d.ts +4 -9
- package/dist/temporal-use-case.js +6 -140
- package/dist/temporal-use-case.js.map +1 -1
- package/dist/unexpected-error.js +179 -0
- package/dist/unexpected-error.js.map +1 -0
- package/dist/use-case.js +91 -0
- package/dist/use-case.js.map +1 -0
- package/dist/uuid-identifier.d.ts +230 -0
- package/dist/uuid-identifier.js +60 -0
- package/dist/uuid-identifier.js.map +1 -0
- package/dist/validation-code.d.ts +23 -0
- package/dist/validation-code.js +1 -177
- package/dist/validation-code.js.map +1 -1
- package/dist/validation-error.d.ts +1 -21
- package/dist/validation-error.js +1 -1
- package/dist/validation-exception.d.ts +50 -0
- package/dist/validation-exception.js +8 -2
- package/dist/validation-exception.js.map +1 -1
- package/dist/value-object-ruleset.contracts.d.ts +36 -0
- package/dist/value-object.js +191 -0
- package/dist/value-object.js.map +1 -0
- package/dist/version.d.ts +10 -0
- package/dist/versioning/index.d.ts +3 -0
- package/dist/versioning/index.js +3 -0
- package/meta.json +17 -3
- package/package.json +33 -4
- package/src/core/domain/rulesets/index.ts +7 -0
- package/src/core/domain/uuid-identifier.ts +72 -0
- package/src/core/domain/value-object.ts +37 -5
- package/src/core/exceptions/index.ts +13 -0
- package/src/core/index.ts +14 -2
- package/src/core/plugins/index.ts +7 -0
- package/src/core/plugins/plugin.ts +99 -0
- package/src/core/plugins/types.ts +53 -0
- package/src/core/versioning/index.ts +14 -0
- package/src/domain/index.ts +7 -0
- package/src/exceptions/index.ts +1 -0
- package/src/plugins/index.ts +1 -0
- package/src/result/index.ts +2 -0
- package/src/rulesets/index.ts +1 -0
- package/src/version.ts +1 -1
- package/src/versioning/index.ts +1 -0
package/dist/validation-code.js
CHANGED
|
@@ -1,179 +1,3 @@
|
|
|
1
|
-
//#region src/core/errors/error-codes.ts
|
|
2
|
-
const ErrorCodes = {
|
|
3
|
-
authentication: {
|
|
4
|
-
missingToken: "sec.authn.missing_token",
|
|
5
|
-
invalidToken: "sec.authn.invalid_token",
|
|
6
|
-
expiredToken: "sec.authn.expired_token",
|
|
7
|
-
invalidCredentials: "sec.authn.invalid_credentials"
|
|
8
|
-
},
|
|
9
|
-
authorization: {
|
|
10
|
-
forbidden: "sec.authz.forbidden",
|
|
11
|
-
policyDenied: "sec.authz.policy_denied",
|
|
12
|
-
missingCapability: "sec.authz.missing_capability",
|
|
13
|
-
outOfScope: "sec.authz.out_of_scope"
|
|
14
|
-
},
|
|
15
|
-
businessRuleViolation: "business_rule_violation",
|
|
16
|
-
conflict: {
|
|
17
|
-
alreadyExists: "conf.already_exists",
|
|
18
|
-
duplicate: "conf.duplicate",
|
|
19
|
-
uniqueViolation: "conf.unique_violation"
|
|
20
|
-
},
|
|
21
|
-
idempotency: {
|
|
22
|
-
keyMissing: "idemp.key_missing",
|
|
23
|
-
inProgress: "idemp.in_progress",
|
|
24
|
-
payloadMismatch: "idemp.payload_mismatch",
|
|
25
|
-
replayNotSupported: "idemp.replay_not_supported"
|
|
26
|
-
},
|
|
27
|
-
integration: {
|
|
28
|
-
timeout: "int.timeout",
|
|
29
|
-
unreachable: "int.unreachable",
|
|
30
|
-
badResponse: "int.bad_response"
|
|
31
|
-
},
|
|
32
|
-
legacyIncompatible: "legacy_incompatible",
|
|
33
|
-
notFound: "not_found",
|
|
34
|
-
serialization: {
|
|
35
|
-
deserializePrefix: "ser.des",
|
|
36
|
-
serializePrefix: "ser.ser"
|
|
37
|
-
},
|
|
38
|
-
temporal: {
|
|
39
|
-
expired: "tmp.expired",
|
|
40
|
-
notYetValid: "tmp.not_yet_valid"
|
|
41
|
-
},
|
|
42
|
-
unexpected: "unexpected",
|
|
43
|
-
validation: "validation_error"
|
|
44
|
-
};
|
|
45
|
-
function serializationErrorCode(direction, category) {
|
|
46
|
-
return `${direction === "deserialize" ? ErrorCodes.serialization.deserializePrefix : ErrorCodes.serialization.serializePrefix}.${category}`;
|
|
47
|
-
}
|
|
48
|
-
//#endregion
|
|
49
|
-
//#region src/core/errors/utils/json-safe.ts
|
|
50
|
-
const NON_SERIALIZABLE_PLACEHOLDER = "[NonSerializable]";
|
|
51
|
-
const CIRCULAR_REFERENCE_PLACEHOLDER = "[Circular]";
|
|
52
|
-
function isPlainObject(value) {
|
|
53
|
-
if (value === null || typeof value !== "object") return false;
|
|
54
|
-
const proto = Object.getPrototypeOf(value);
|
|
55
|
-
return proto === Object.prototype || proto === null;
|
|
56
|
-
}
|
|
57
|
-
function sanitizeValue(value, seen) {
|
|
58
|
-
if (value === null) return null;
|
|
59
|
-
const type = typeof value;
|
|
60
|
-
if (type === "string" || type === "number" || type === "boolean") return value;
|
|
61
|
-
if (type === "bigint" || type === "function" || type === "symbol" || value === void 0) return NON_SERIALIZABLE_PLACEHOLDER;
|
|
62
|
-
if (Array.isArray(value)) {
|
|
63
|
-
if (seen.has(value)) return CIRCULAR_REFERENCE_PLACEHOLDER;
|
|
64
|
-
seen.add(value);
|
|
65
|
-
const sanitized = value.map((item) => sanitizeValue(item, seen));
|
|
66
|
-
seen.delete(value);
|
|
67
|
-
return sanitized;
|
|
68
|
-
}
|
|
69
|
-
if (value instanceof Date) return NON_SERIALIZABLE_PLACEHOLDER;
|
|
70
|
-
if (!isPlainObject(value)) return NON_SERIALIZABLE_PLACEHOLDER;
|
|
71
|
-
if (seen.has(value)) return CIRCULAR_REFERENCE_PLACEHOLDER;
|
|
72
|
-
seen.add(value);
|
|
73
|
-
const result = {};
|
|
74
|
-
for (const [key, val] of Object.entries(value)) result[key] = sanitizeValue(val, seen);
|
|
75
|
-
seen.delete(value);
|
|
76
|
-
return result;
|
|
77
|
-
}
|
|
78
|
-
/**
|
|
79
|
-
* Ensures metadata is JSON-serializable.
|
|
80
|
-
*
|
|
81
|
-
* **Allowed:** string, number, boolean, null, arrays, and plain objects.
|
|
82
|
-
*
|
|
83
|
-
* **Converted to placeholder:** Date, BigInt, class instances, functions,
|
|
84
|
-
* symbols, undefined, and circular references (which would otherwise make
|
|
85
|
-
* `JSON.stringify` throw).
|
|
86
|
-
*
|
|
87
|
-
* @throws {TypeError} If `input` is not a plain object at the root level.
|
|
88
|
-
*/
|
|
89
|
-
function assertJsonSafeMetadata(input) {
|
|
90
|
-
if (input === void 0) return {};
|
|
91
|
-
if (!isPlainObject(input)) throw new TypeError("metadata must be a plain object (Record<string, unknown>).");
|
|
92
|
-
return sanitizeValue(input, /* @__PURE__ */ new WeakSet());
|
|
93
|
-
}
|
|
94
|
-
//#endregion
|
|
95
|
-
//#region src/core/errors/app-error.ts
|
|
96
|
-
/**
|
|
97
|
-
* Root of the application/domain error hierarchy. Every error the system raises
|
|
98
|
-
* on purpose extends `AppError`, which gives callers a single `instanceof` to
|
|
99
|
-
* catch and a uniform, serializable shape to log and transport.
|
|
100
|
-
*
|
|
101
|
-
* Beyond the native `Error` message it carries a stable `code` (the contract the
|
|
102
|
-
* outside world matches on), an optional non-leaking `publicMessage`, a
|
|
103
|
-
* severity, JSON-safe `metadata`, and the correlation/request/command ids that
|
|
104
|
-
* stitch an error back to the request that produced it. The metadata is
|
|
105
|
-
* validated as JSON-safe on construction, so a logger can serialize any
|
|
106
|
-
* `AppError` without hitting a circular reference or a non-serializable value.
|
|
107
|
-
*
|
|
108
|
-
* Abstract on purpose: callers should throw a specific subclass (e.g.
|
|
109
|
-
* {@link ValidationError}, {@link NotFoundError}) so the `code` and shape are
|
|
110
|
-
* meaningful, never a bare `AppError`.
|
|
111
|
-
*/
|
|
112
|
-
var AppError = class extends Error {
|
|
113
|
-
/**
|
|
114
|
-
* Builds the common error envelope shared by every subclass.
|
|
115
|
-
*
|
|
116
|
-
* `name` is taken from `new.target` so the thrown instance reports its
|
|
117
|
-
* concrete subclass name (not `"AppError"`), and the prototype is re-pinned
|
|
118
|
-
* via `setPrototypeOf` so `instanceof` keeps working after transpilation to
|
|
119
|
-
* older targets where extending built-ins breaks the chain. `createdAtIso`
|
|
120
|
-
* defaults to now, and `metadata` is validated as JSON-safe so the error is
|
|
121
|
-
* always serializable.
|
|
122
|
-
*
|
|
123
|
-
* Declared `protected`: instantiate a concrete subclass, never `AppError`.
|
|
124
|
-
*
|
|
125
|
-
* @param message - The internal, developer-facing message.
|
|
126
|
-
* @param code - The stable machine-readable code callers match on.
|
|
127
|
-
* @param options - Optional cause, metadata, severity, and correlation ids.
|
|
128
|
-
* @throws When `options.metadata` contains a value that is not JSON-safe.
|
|
129
|
-
*/
|
|
130
|
-
constructor(message, code, options) {
|
|
131
|
-
super(message);
|
|
132
|
-
this.name = new.target.name;
|
|
133
|
-
this.code = code;
|
|
134
|
-
this.cause = options?.cause;
|
|
135
|
-
this.type = options?.type;
|
|
136
|
-
this.severity = options?.severity;
|
|
137
|
-
this.correlationId = options?.correlationId;
|
|
138
|
-
this.requestId = options?.requestId;
|
|
139
|
-
this.commandId = options?.commandId;
|
|
140
|
-
this.createdAtIso = options?.createdAtIso ?? (/* @__PURE__ */ new Date()).toISOString();
|
|
141
|
-
this.publicMessage = options?.publicMessage;
|
|
142
|
-
this.metadata = options?.metadata ? assertJsonSafeMetadata(options.metadata) : void 0;
|
|
143
|
-
Object.setPrototypeOf(this, new.target.prototype);
|
|
144
|
-
}
|
|
145
|
-
/**
|
|
146
|
-
* Returns a JSON-safe representation of the error.
|
|
147
|
-
* Does NOT include `cause` by default (to avoid leaking internal details).
|
|
148
|
-
*/
|
|
149
|
-
toJSON() {
|
|
150
|
-
const payload = {
|
|
151
|
-
name: this.name,
|
|
152
|
-
code: this.code,
|
|
153
|
-
message: this.message,
|
|
154
|
-
createdAtIso: this.createdAtIso
|
|
155
|
-
};
|
|
156
|
-
if (this.type !== void 0) payload.type = this.type;
|
|
157
|
-
if (this.severity !== void 0) payload.severity = this.severity;
|
|
158
|
-
if (this.publicMessage !== void 0) payload.publicMessage = this.publicMessage;
|
|
159
|
-
if (this.metadata !== void 0) payload.metadata = this.metadata;
|
|
160
|
-
if (this.correlationId !== void 0) payload.correlationId = this.correlationId;
|
|
161
|
-
if (this.requestId !== void 0) payload.requestId = this.requestId;
|
|
162
|
-
if (this.commandId !== void 0) payload.commandId = this.commandId;
|
|
163
|
-
return payload;
|
|
164
|
-
}
|
|
165
|
-
};
|
|
166
|
-
//#endregion
|
|
167
|
-
//#region src/core/errors/unexpected-error.ts
|
|
168
|
-
var UnexpectedError = class extends AppError {
|
|
169
|
-
constructor(message = "Unexpected error", cause, options) {
|
|
170
|
-
super(message, ErrorCodes.unexpected, {
|
|
171
|
-
cause,
|
|
172
|
-
...options
|
|
173
|
-
});
|
|
174
|
-
}
|
|
175
|
-
};
|
|
176
|
-
//#endregion
|
|
177
1
|
//#region src/core/exceptions/validation-code.ts
|
|
178
2
|
var ValidationCode = class ValidationCode {
|
|
179
3
|
constructor(value) {
|
|
@@ -226,6 +50,6 @@ var ValidationCode = class ValidationCode {
|
|
|
226
50
|
}
|
|
227
51
|
};
|
|
228
52
|
//#endregion
|
|
229
|
-
export {
|
|
53
|
+
export { ValidationCode as t };
|
|
230
54
|
|
|
231
55
|
//# sourceMappingURL=validation-code.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validation-code.js","names":[],"sources":["../src/core/errors/error-codes.ts","../src/core/errors/utils/json-safe.ts","../src/core/errors/app-error.ts","../src/core/errors/unexpected-error.ts","../src/core/exceptions/validation-code.ts"],"sourcesContent":["const ErrorCodes = {\n authentication: {\n missingToken: \"sec.authn.missing_token\",\n invalidToken: \"sec.authn.invalid_token\",\n expiredToken: \"sec.authn.expired_token\",\n invalidCredentials: \"sec.authn.invalid_credentials\",\n },\n authorization: {\n forbidden: \"sec.authz.forbidden\",\n policyDenied: \"sec.authz.policy_denied\",\n missingCapability: \"sec.authz.missing_capability\",\n outOfScope: \"sec.authz.out_of_scope\",\n },\n businessRuleViolation: \"business_rule_violation\",\n conflict: {\n alreadyExists: \"conf.already_exists\",\n duplicate: \"conf.duplicate\",\n uniqueViolation: \"conf.unique_violation\",\n },\n idempotency: {\n keyMissing: \"idemp.key_missing\",\n inProgress: \"idemp.in_progress\",\n payloadMismatch: \"idemp.payload_mismatch\",\n replayNotSupported: \"idemp.replay_not_supported\",\n },\n integration: {\n timeout: \"int.timeout\",\n unreachable: \"int.unreachable\",\n badResponse: \"int.bad_response\",\n },\n legacyIncompatible: \"legacy_incompatible\",\n notFound: \"not_found\",\n serialization: {\n deserializePrefix: \"ser.des\",\n serializePrefix: \"ser.ser\",\n },\n temporal: {\n expired: \"tmp.expired\",\n notYetValid: \"tmp.not_yet_valid\",\n },\n unexpected: \"unexpected\",\n validation: \"validation_error\",\n} as const;\n\ntype SerializationCodeDirection = \"deserialize\" | \"serialize\";\n\nfunction serializationErrorCode(\n direction: SerializationCodeDirection,\n category: string,\n): string {\n const prefix =\n direction === \"deserialize\"\n ? ErrorCodes.serialization.deserializePrefix\n : ErrorCodes.serialization.serializePrefix;\n\n return `${prefix}.${category}`;\n}\n\nexport { ErrorCodes, serializationErrorCode };\nexport type { SerializationCodeDirection };\n","// Utilities for ensuring metadata is JSON-serializable.\n\nimport type { JsonSafeRecord, JsonSafeValue } from \"../types.js\";\n\n// ─────────────────────────────────────────────────────────────────────────────\n// Constants\n// ─────────────────────────────────────────────────────────────────────────────\n\nconst NON_SERIALIZABLE_PLACEHOLDER = \"[NonSerializable]\";\nconst CIRCULAR_REFERENCE_PLACEHOLDER = \"[Circular]\";\n\n// ─────────────────────────────────────────────────────────────────────────────\n// Internal helpers\n// ─────────────────────────────────────────────────────────────────────────────\n\nfunction isPlainObject(value: unknown): value is Record<string, unknown> {\n if (value === null || typeof value !== \"object\") return false;\n const proto = Object.getPrototypeOf(value);\n return proto === Object.prototype || proto === null;\n}\n\n// `seen` tracks the ancestors on the current traversal branch (a DFS path), not\n// every object visited. This collapses true circular references to a placeholder\n// while still serializing the same object referenced more than once across\n// sibling branches (a DAG) — matching `JSON.stringify`, which only rejects\n// cycles, not shared references.\nfunction sanitizeValue(value: unknown, seen: WeakSet<object>): JsonSafeValue {\n // Null passthrough\n if (value === null) return null;\n\n const type = typeof value;\n\n // Primitives\n if (type === \"string\" || type === \"number\" || type === \"boolean\") {\n return value as JsonSafeValue;\n }\n\n // Non-serializable primitives\n if (\n type === \"bigint\" ||\n type === \"function\" ||\n type === \"symbol\" ||\n value === undefined\n ) {\n return NON_SERIALIZABLE_PLACEHOLDER;\n }\n\n // Arrays (recursive)\n if (Array.isArray(value)) {\n if (seen.has(value)) return CIRCULAR_REFERENCE_PLACEHOLDER;\n seen.add(value);\n const sanitized = value.map((item) => sanitizeValue(item, seen));\n seen.delete(value);\n return sanitized;\n }\n\n // Date → placeholder (could also use .toISOString() if preferred)\n if (value instanceof Date) {\n return NON_SERIALIZABLE_PLACEHOLDER;\n }\n\n // Class instances and non-plain objects → placeholder\n if (!isPlainObject(value)) {\n return NON_SERIALIZABLE_PLACEHOLDER;\n }\n\n // Plain object (recursive)\n if (seen.has(value)) return CIRCULAR_REFERENCE_PLACEHOLDER;\n seen.add(value);\n const result: Record<string, JsonSafeValue> = {};\n for (const [key, val] of Object.entries(value)) {\n result[key] = sanitizeValue(val, seen);\n }\n seen.delete(value);\n return result;\n}\n\n// ─────────────────────────────────────────────────────────────────────────────\n// Public API\n// ─────────────────────────────────────────────────────────────────────────────\n\n/**\n * Ensures metadata is JSON-serializable.\n *\n * **Allowed:** string, number, boolean, null, arrays, and plain objects.\n *\n * **Converted to placeholder:** Date, BigInt, class instances, functions,\n * symbols, undefined, and circular references (which would otherwise make\n * `JSON.stringify` throw).\n *\n * @throws {TypeError} If `input` is not a plain object at the root level.\n */\nfunction assertJsonSafeMetadata(input: unknown): JsonSafeRecord {\n if (input === undefined) {\n return {};\n }\n\n if (!isPlainObject(input)) {\n throw new TypeError(\n \"metadata must be a plain object (Record<string, unknown>).\",\n );\n }\n\n return sanitizeValue(input, new WeakSet<object>()) as JsonSafeRecord;\n}\n\nexport {\n assertJsonSafeMetadata,\n CIRCULAR_REFERENCE_PLACEHOLDER,\n NON_SERIALIZABLE_PLACEHOLDER,\n};\n","// Base application error for the domain/application layer.\n// Encapsulates a code, optional cause, and JSON-safe metadata.\n\nimport type {\n AppErrorOptions,\n ErrorSeverity,\n JsonSafeRecord,\n} from \"./types.js\";\nimport { assertJsonSafeMetadata } from \"./utils/index.js\";\n\n// ─────────────────────────────────────────────────────────────────────────────\n// AppError (abstract base class)\n// ─────────────────────────────────────────────────────────────────────────────\n\n/**\n * Root of the application/domain error hierarchy. Every error the system raises\n * on purpose extends `AppError`, which gives callers a single `instanceof` to\n * catch and a uniform, serializable shape to log and transport.\n *\n * Beyond the native `Error` message it carries a stable `code` (the contract the\n * outside world matches on), an optional non-leaking `publicMessage`, a\n * severity, JSON-safe `metadata`, and the correlation/request/command ids that\n * stitch an error back to the request that produced it. The metadata is\n * validated as JSON-safe on construction, so a logger can serialize any\n * `AppError` without hitting a circular reference or a non-serializable value.\n *\n * Abstract on purpose: callers should throw a specific subclass (e.g.\n * {@link ValidationError}, {@link NotFoundError}) so the `code` and shape are\n * meaningful, never a bare `AppError`.\n */\nabstract class AppError extends Error {\n public readonly code: string;\n public readonly cause?: unknown;\n public readonly metadata?: JsonSafeRecord;\n public readonly type?: string;\n public readonly severity?: ErrorSeverity;\n public readonly createdAtIso: string;\n public readonly publicMessage?: string;\n /**\n * Identifies a single execution \"story\" in the system. All operations\n * related to the same logical flow must share the same correlationId.\n */\n public readonly correlationId?: string;\n /**\n * Identifies a specific technical request attempt (each retry may produce\n * a new requestId), even when the correlationId stays the same.\n */\n public readonly requestId?: string;\n /**\n * Marks the business intent / idempotency key; stays the same across\n * technical retries and multiple requests that represent the same intent.\n */\n public readonly commandId?: string;\n\n /**\n * Builds the common error envelope shared by every subclass.\n *\n * `name` is taken from `new.target` so the thrown instance reports its\n * concrete subclass name (not `\"AppError\"`), and the prototype is re-pinned\n * via `setPrototypeOf` so `instanceof` keeps working after transpilation to\n * older targets where extending built-ins breaks the chain. `createdAtIso`\n * defaults to now, and `metadata` is validated as JSON-safe so the error is\n * always serializable.\n *\n * Declared `protected`: instantiate a concrete subclass, never `AppError`.\n *\n * @param message - The internal, developer-facing message.\n * @param code - The stable machine-readable code callers match on.\n * @param options - Optional cause, metadata, severity, and correlation ids.\n * @throws When `options.metadata` contains a value that is not JSON-safe.\n */\n protected constructor(\n message: string,\n code: string,\n options?: AppErrorOptions,\n ) {\n super(message);\n\n this.name = new.target.name;\n this.code = code;\n this.cause = options?.cause;\n this.type = options?.type;\n this.severity = options?.severity;\n this.correlationId = options?.correlationId;\n this.requestId = options?.requestId;\n this.commandId = options?.commandId;\n this.createdAtIso = options?.createdAtIso ?? new Date().toISOString();\n this.publicMessage = options?.publicMessage;\n\n this.metadata = options?.metadata\n ? assertJsonSafeMetadata(options.metadata)\n : undefined;\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n\n /**\n * Returns a JSON-safe representation of the error.\n * Does NOT include `cause` by default (to avoid leaking internal details).\n */\n public toJSON(): Record<string, unknown> {\n const payload: Record<string, unknown> = {\n name: this.name,\n code: this.code,\n message: this.message,\n createdAtIso: this.createdAtIso,\n };\n\n // Optional fields are emitted only when defined, so the serialized\n // shape never carries `undefined`-valued keys (consistent with how the\n // correlation/request/command ids are handled).\n if (this.type !== undefined) payload.type = this.type;\n if (this.severity !== undefined) payload.severity = this.severity;\n if (this.publicMessage !== undefined)\n payload.publicMessage = this.publicMessage;\n if (this.metadata !== undefined) payload.metadata = this.metadata;\n if (this.correlationId !== undefined)\n payload.correlationId = this.correlationId;\n if (this.requestId !== undefined) payload.requestId = this.requestId;\n if (this.commandId !== undefined) payload.commandId = this.commandId;\n\n return payload;\n }\n}\n\nexport { AppError };\n","import { AppError } from \"./app-error.js\";\nimport { ErrorCodes } from \"./error-codes.js\";\nimport type { AppErrorOptions } from \"./types.js\";\n\n// ─────────────────────────────────────────────────────────────────────────────\n// UnexpectedError\n// ─────────────────────────────────────────────────────────────────────────────\n\nclass UnexpectedError extends AppError {\n constructor(\n message = \"Unexpected error\",\n cause?: unknown,\n options?: Omit<AppErrorOptions, \"cause\">,\n ) {\n super(message, ErrorCodes.unexpected, {\n cause,\n ...options,\n });\n }\n}\n\nexport { UnexpectedError };\n","// Object-oriented representation of validation codes (similar to Kotlin inline class).\n// Provides common reusable codes while allowing custom codes via `of`.\n\nclass ValidationCode {\n public readonly value: string;\n\n private constructor(value: string) {\n this.value = value;\n }\n\n // Factory for custom codes\n public static of(value: string): ValidationCode {\n return new ValidationCode(value);\n }\n\n // Common, domain-friendly codes\n public static readonly BLANK = new ValidationCode(\"blank\");\n public static readonly REQUIRED = new ValidationCode(\"required\");\n public static readonly INVALID_FORMAT = new ValidationCode(\n \"invalid_format\",\n );\n public static readonly INVALID_CHARACTERS = new ValidationCode(\n \"invalid_characters\",\n );\n public static readonly INVALID_LENGTH = new ValidationCode(\n \"invalid_length\",\n );\n public static readonly TOO_SHORT = new ValidationCode(\"too_short\");\n public static readonly TOO_LONG = new ValidationCode(\"too_long\");\n public static readonly OUT_OF_RANGE = new ValidationCode(\"out_of_range\");\n public static readonly INVALID_CHECKSUM = new ValidationCode(\n \"invalid_checksum\",\n );\n public static readonly INVALID_CHECKING_DIGIT = new ValidationCode(\n \"invalid_checking_digit\",\n );\n public static readonly ALREADY_EXISTS = new ValidationCode(\n \"already_exists\",\n );\n public static readonly NOT_FOUND = new ValidationCode(\"not_found\");\n public static readonly NOT_ALLOWED = new ValidationCode(\"not_allowed\");\n public static readonly UNEXPECTED = new ValidationCode(\"unexpected\");\n}\n\nexport { ValidationCode };\n"],"mappings":"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"}
|
|
1
|
+
{"version":3,"file":"validation-code.js","names":[],"sources":["../src/core/exceptions/validation-code.ts"],"sourcesContent":["// Object-oriented representation of validation codes (similar to Kotlin inline class).\n// Provides common reusable codes while allowing custom codes via `of`.\n\nclass ValidationCode {\n public readonly value: string;\n\n private constructor(value: string) {\n this.value = value;\n }\n\n // Factory for custom codes\n public static of(value: string): ValidationCode {\n return new ValidationCode(value);\n }\n\n // Common, domain-friendly codes\n public static readonly BLANK = new ValidationCode(\"blank\");\n public static readonly REQUIRED = new ValidationCode(\"required\");\n public static readonly INVALID_FORMAT = new ValidationCode(\n \"invalid_format\",\n );\n public static readonly INVALID_CHARACTERS = new ValidationCode(\n \"invalid_characters\",\n );\n public static readonly INVALID_LENGTH = new ValidationCode(\n \"invalid_length\",\n );\n public static readonly TOO_SHORT = new ValidationCode(\"too_short\");\n public static readonly TOO_LONG = new ValidationCode(\"too_long\");\n public static readonly OUT_OF_RANGE = new ValidationCode(\"out_of_range\");\n public static readonly INVALID_CHECKSUM = new ValidationCode(\n \"invalid_checksum\",\n );\n public static readonly INVALID_CHECKING_DIGIT = new ValidationCode(\n \"invalid_checking_digit\",\n );\n public static readonly ALREADY_EXISTS = new ValidationCode(\n \"already_exists\",\n );\n public static readonly NOT_FOUND = new ValidationCode(\"not_found\");\n public static readonly NOT_ALLOWED = new ValidationCode(\"not_allowed\");\n public static readonly UNEXPECTED = new ValidationCode(\"unexpected\");\n}\n\nexport { ValidationCode };\n"],"mappings":";AAGA,IAAM,iBAAN,MAAM,eAAe;CAGjB,YAAoB,OAAe;EAC/B,KAAK,QAAQ;CACjB;CAGA,OAAc,GAAG,OAA+B;EAC5C,OAAO,IAAI,eAAe,KAAK;CACnC;;eAG+B,IAAI,eAAe,OAAO;;;kBACvB,IAAI,eAAe,UAAU;;;wBACvB,IAAI,eACxC,gBACJ;;;4BAC4C,IAAI,eAC5C,oBACJ;;;wBACwC,IAAI,eACxC,gBACJ;;;mBACmC,IAAI,eAAe,WAAW;;;kBAC/B,IAAI,eAAe,UAAU;;;sBACzB,IAAI,eAAe,cAAc;;;0BAC7B,IAAI,eAC1C,kBACJ;;;gCACgD,IAAI,eAChD,wBACJ;;;wBACwC,IAAI,eACxC,gBACJ;;;mBACmC,IAAI,eAAe,WAAW;;;qBAC5B,IAAI,eAAe,aAAa;;;oBACjC,IAAI,eAAe,YAAY;;AACvE"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { a as JsonSafeRecord, n as AppErrorOptions, r as ErrorSeverity, t as AppError } from "./app-error.js";
|
|
2
|
+
import { t as ValidationCode } from "./validation-code.js";
|
|
2
3
|
import { t as ValidationField } from "./validation-field.js";
|
|
3
4
|
|
|
4
5
|
//#region src/core/errors/error-codes.d.ts
|
|
@@ -749,27 +750,6 @@ declare class UnexpectedError extends AppError {
|
|
|
749
750
|
constructor(message?: string, cause?: unknown, options?: Omit<AppErrorOptions, "cause">);
|
|
750
751
|
}
|
|
751
752
|
//#endregion
|
|
752
|
-
//#region src/core/exceptions/validation-code.d.ts
|
|
753
|
-
declare class ValidationCode {
|
|
754
|
-
readonly value: string;
|
|
755
|
-
private constructor();
|
|
756
|
-
static of(value: string): ValidationCode;
|
|
757
|
-
static readonly BLANK: ValidationCode;
|
|
758
|
-
static readonly REQUIRED: ValidationCode;
|
|
759
|
-
static readonly INVALID_FORMAT: ValidationCode;
|
|
760
|
-
static readonly INVALID_CHARACTERS: ValidationCode;
|
|
761
|
-
static readonly INVALID_LENGTH: ValidationCode;
|
|
762
|
-
static readonly TOO_SHORT: ValidationCode;
|
|
763
|
-
static readonly TOO_LONG: ValidationCode;
|
|
764
|
-
static readonly OUT_OF_RANGE: ValidationCode;
|
|
765
|
-
static readonly INVALID_CHECKSUM: ValidationCode;
|
|
766
|
-
static readonly INVALID_CHECKING_DIGIT: ValidationCode;
|
|
767
|
-
static readonly ALREADY_EXISTS: ValidationCode;
|
|
768
|
-
static readonly NOT_FOUND: ValidationCode;
|
|
769
|
-
static readonly NOT_ALLOWED: ValidationCode;
|
|
770
|
-
static readonly UNEXPECTED: ValidationCode;
|
|
771
|
-
}
|
|
772
|
-
//#endregion
|
|
773
753
|
//#region src/core/errors/validation-error.d.ts
|
|
774
754
|
/**
|
|
775
755
|
* Raised when a single input fails a validation rule — the canonical
|
package/dist/validation-error.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as
|
|
1
|
+
import { a as serializationErrorCode, i as ErrorCodes, n as AppError } from "./unexpected-error.js";
|
|
2
2
|
//#region src/core/errors/authentication-error.ts
|
|
3
3
|
var AuthenticationError = class AuthenticationError extends AppError {
|
|
4
4
|
constructor(params) {
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { t as ValidationCode } from "./validation-code.js";
|
|
2
|
+
import { t as ValidationField } from "./validation-field.js";
|
|
3
|
+
import { t as DomainException } from "./domain-exception.js";
|
|
4
|
+
|
|
5
|
+
//#region src/core/exceptions/business-rule-violation-exception.d.ts
|
|
6
|
+
declare class BusinessRuleViolationException extends DomainException {
|
|
7
|
+
readonly rule: string;
|
|
8
|
+
constructor(rule: string, message: string);
|
|
9
|
+
}
|
|
10
|
+
//#endregion
|
|
11
|
+
//#region src/core/exceptions/entity-not-found-exception.d.ts
|
|
12
|
+
declare class EntityNotFoundException extends DomainException {
|
|
13
|
+
readonly entityName: string;
|
|
14
|
+
readonly identifier: string;
|
|
15
|
+
constructor(entityName: string, identifier: string);
|
|
16
|
+
}
|
|
17
|
+
//#endregion
|
|
18
|
+
//#region src/core/exceptions/invalid-state-transition-exception.d.ts
|
|
19
|
+
declare class InvalidStateTransitionException<TState extends string = string> extends DomainException {
|
|
20
|
+
readonly from: TState;
|
|
21
|
+
readonly to: TState;
|
|
22
|
+
constructor(from: TState, to: TState, message: string);
|
|
23
|
+
}
|
|
24
|
+
//#endregion
|
|
25
|
+
//#region src/core/exceptions/invariant-violation-exception.d.ts
|
|
26
|
+
declare class InvariantViolationException extends DomainException {
|
|
27
|
+
constructor(message: string);
|
|
28
|
+
}
|
|
29
|
+
//#endregion
|
|
30
|
+
//#region src/core/exceptions/validation-exception.d.ts
|
|
31
|
+
interface ValidationViolation {
|
|
32
|
+
readonly field: ValidationField;
|
|
33
|
+
readonly code: ValidationCode;
|
|
34
|
+
readonly message: string;
|
|
35
|
+
}
|
|
36
|
+
declare class ValidationException extends DomainException {
|
|
37
|
+
readonly field: ValidationField;
|
|
38
|
+
readonly code: ValidationCode;
|
|
39
|
+
constructor(field: ValidationField, code: ValidationCode, message: string);
|
|
40
|
+
}
|
|
41
|
+
declare class MultipleValidationException extends DomainException {
|
|
42
|
+
readonly violations: readonly ValidationViolation[];
|
|
43
|
+
constructor(violations: readonly ValidationViolation[]);
|
|
44
|
+
}
|
|
45
|
+
declare class InvalidValueException extends ValidationException {
|
|
46
|
+
constructor(field: ValidationField, code: ValidationCode, message: string);
|
|
47
|
+
}
|
|
48
|
+
//#endregion
|
|
49
|
+
export { InvariantViolationException as a, BusinessRuleViolationException as c, ValidationViolation as i, MultipleValidationException as n, InvalidStateTransitionException as o, ValidationException as r, EntityNotFoundException as s, InvalidValueException as t };
|
|
50
|
+
//# sourceMappingURL=validation-exception.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { t as DomainException } from "./domain-exception.js";
|
|
2
2
|
//#region src/core/exceptions/validation-exception.ts
|
|
3
3
|
var ValidationException = class extends DomainException {
|
|
4
4
|
constructor(field, code, message) {
|
|
@@ -7,12 +7,18 @@ var ValidationException = class extends DomainException {
|
|
|
7
7
|
this.code = code;
|
|
8
8
|
}
|
|
9
9
|
};
|
|
10
|
+
var MultipleValidationException = class extends DomainException {
|
|
11
|
+
constructor(violations) {
|
|
12
|
+
super(violations.map((v) => v.message).join("; "));
|
|
13
|
+
this.violations = violations;
|
|
14
|
+
}
|
|
15
|
+
};
|
|
10
16
|
var InvalidValueException = class extends ValidationException {
|
|
11
17
|
constructor(field, code, message) {
|
|
12
18
|
super(field, code, message);
|
|
13
19
|
}
|
|
14
20
|
};
|
|
15
21
|
//#endregion
|
|
16
|
-
export { InvalidValueException as t };
|
|
22
|
+
export { MultipleValidationException as n, ValidationException as r, InvalidValueException as t };
|
|
17
23
|
|
|
18
24
|
//# sourceMappingURL=validation-exception.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validation-exception.js","names":[],"sources":["../src/core/exceptions/validation-exception.ts"],"sourcesContent":["import { DomainException } from \"./domain-exception.js\";\nimport { ValidationCode } from \"./validation-code.js\";\nimport { ValidationField } from \"./validation-field.js\";\n\nexport interface ValidationViolation {\n readonly field: ValidationField;\n readonly code: ValidationCode;\n readonly message: string;\n}\n\nclass ValidationException extends DomainException {\n constructor(\n public readonly field: ValidationField,\n public readonly code: ValidationCode,\n message: string,\n ) {\n super(message);\n }\n}\n\n// Carries multiple validation violations from a single operation (e.g. bulk validation).\n// Use when you need to report all field errors at once rather than failing on the first.\nclass MultipleValidationException extends DomainException {\n constructor(public readonly violations: readonly ValidationViolation[]) {\n super(violations.map((v) => v.message).join(\"; \"));\n }\n}\n\nclass InvalidValueException extends ValidationException {\n constructor(field: ValidationField, code: ValidationCode, message: string) {\n super(field, code, message);\n }\n}\n\nexport {\n InvalidValueException,\n MultipleValidationException,\n ValidationException,\n};\n"],"mappings":";;AAUA,IAAM,sBAAN,cAAkC,gBAAgB;CAC9C,YACI,OACA,MACA,SACF;EACE,MAAM,OAAO;EAJG,KAAA,QAAA;EACA,KAAA,OAAA;CAIpB;AACJ;
|
|
1
|
+
{"version":3,"file":"validation-exception.js","names":[],"sources":["../src/core/exceptions/validation-exception.ts"],"sourcesContent":["import { DomainException } from \"./domain-exception.js\";\nimport { ValidationCode } from \"./validation-code.js\";\nimport { ValidationField } from \"./validation-field.js\";\n\nexport interface ValidationViolation {\n readonly field: ValidationField;\n readonly code: ValidationCode;\n readonly message: string;\n}\n\nclass ValidationException extends DomainException {\n constructor(\n public readonly field: ValidationField,\n public readonly code: ValidationCode,\n message: string,\n ) {\n super(message);\n }\n}\n\n// Carries multiple validation violations from a single operation (e.g. bulk validation).\n// Use when you need to report all field errors at once rather than failing on the first.\nclass MultipleValidationException extends DomainException {\n constructor(public readonly violations: readonly ValidationViolation[]) {\n super(violations.map((v) => v.message).join(\"; \"));\n }\n}\n\nclass InvalidValueException extends ValidationException {\n constructor(field: ValidationField, code: ValidationCode, message: string) {\n super(field, code, message);\n }\n}\n\nexport {\n InvalidValueException,\n MultipleValidationException,\n ValidationException,\n};\n"],"mappings":";;AAUA,IAAM,sBAAN,cAAkC,gBAAgB;CAC9C,YACI,OACA,MACA,SACF;EACE,MAAM,OAAO;EAJG,KAAA,QAAA;EACA,KAAA,OAAA;CAIpB;AACJ;AAIA,IAAM,8BAAN,cAA0C,gBAAgB;CACtD,YAAY,YAA4D;EACpE,MAAM,WAAW,KAAK,MAAM,EAAE,OAAO,EAAE,KAAK,IAAI,CAAC;EADzB,KAAA,aAAA;CAE5B;AACJ;AAEA,IAAM,wBAAN,cAAoC,oBAAoB;CACpD,YAAY,OAAwB,MAAsB,SAAiB;EACvE,MAAM,OAAO,MAAM,OAAO;CAC9B;AACJ"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
//#region src/core/domain/rulesets/ruleset.contracts.d.ts
|
|
2
|
+
type RulesetId = `${string}@${number}.${number}`;
|
|
3
|
+
interface Ruleset {
|
|
4
|
+
readonly id: RulesetId;
|
|
5
|
+
readonly description: string;
|
|
6
|
+
}
|
|
7
|
+
interface RulesetRegistry$1 {
|
|
8
|
+
register(ruleset: Ruleset): void;
|
|
9
|
+
seal(): void;
|
|
10
|
+
get<T extends Ruleset>(id: string): T;
|
|
11
|
+
getCurrent<T extends Ruleset>(prefix: string): T;
|
|
12
|
+
}
|
|
13
|
+
//#endregion
|
|
14
|
+
//#region src/core/domain/rulesets/entity-ruleset.contracts.d.ts
|
|
15
|
+
interface CreationRuleset<TData> extends Ruleset {
|
|
16
|
+
validate(data: TData): void;
|
|
17
|
+
}
|
|
18
|
+
type InvariantRuleset = Ruleset;
|
|
19
|
+
//#endregion
|
|
20
|
+
//#region src/core/domain/rulesets/ruleset-registry.d.ts
|
|
21
|
+
declare class RulesetRegistry implements RulesetRegistry$1 {
|
|
22
|
+
private readonly _store;
|
|
23
|
+
private _sealed;
|
|
24
|
+
register(ruleset: Ruleset): void;
|
|
25
|
+
seal(): void;
|
|
26
|
+
get<T extends Ruleset>(id: string): T;
|
|
27
|
+
getCurrent<T extends Ruleset>(prefix: string): T;
|
|
28
|
+
}
|
|
29
|
+
//#endregion
|
|
30
|
+
//#region src/core/domain/rulesets/value-object-ruleset.contracts.d.ts
|
|
31
|
+
interface ValueObjectRuleset<T> extends Ruleset {
|
|
32
|
+
validate(value: T): void;
|
|
33
|
+
}
|
|
34
|
+
//#endregion
|
|
35
|
+
export { Ruleset as a, InvariantRuleset as i, RulesetRegistry as n, RulesetId as o, CreationRuleset as r, ValueObjectRuleset as t };
|
|
36
|
+
//# sourceMappingURL=value-object-ruleset.contracts.d.ts.map
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import { t as InvariantViolationException } from "./invariant-violation-exception.js";
|
|
2
|
+
import { i as version, n as __decorate, t as makeImmutable } from "./immutable.js";
|
|
3
|
+
import { n as cloneDate, t as assertValidDate } from "./temporal-guards.js";
|
|
4
|
+
import { t as PluginManager } from "./plugin.js";
|
|
5
|
+
//#region src/core/shared/aggregate-version.ts
|
|
6
|
+
function assertValidAggregateVersion(aggregateVersion) {
|
|
7
|
+
if (!Number.isInteger(aggregateVersion) || aggregateVersion < 0) throw new InvariantViolationException(`aggregateVersion must be a non-negative integer. Received: ${aggregateVersion}`);
|
|
8
|
+
}
|
|
9
|
+
//#endregion
|
|
10
|
+
//#region src/core/domain/entity.ts
|
|
11
|
+
var _Entity;
|
|
12
|
+
/**
|
|
13
|
+
* Base class for domain entities — objects defined by a stable identity rather
|
|
14
|
+
* than by their attributes. Two entities are "the same" when their `id`
|
|
15
|
+
* matches, even if every other field differs; this is the opposite of a
|
|
16
|
+
* {@link ValueObject}, which is defined entirely by its contents.
|
|
17
|
+
*
|
|
18
|
+
* The class owns the bookkeeping common to every aggregate root: a creation
|
|
19
|
+
* timestamp that never changes, a last-modified timestamp, and an
|
|
20
|
+
* `aggregateVersion` counter used for optimistic concurrency control. All three
|
|
21
|
+
* are validated on construction and the dates are defensively cloned, so an
|
|
22
|
+
* entity can never be built into — or leak — an inconsistent temporal state.
|
|
23
|
+
*
|
|
24
|
+
* @typeParam TIdentifier - The identity type (e.g. a branded string id or a VO).
|
|
25
|
+
*/
|
|
26
|
+
let Entity = class Entity {
|
|
27
|
+
static {
|
|
28
|
+
_Entity = this;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Reconstitutes an entity from its persisted {@link EntityState}.
|
|
32
|
+
*
|
|
33
|
+
* Validates the temporal invariants up front so an invalid entity is
|
|
34
|
+
* impossible to construct: both dates must be valid, the aggregate version
|
|
35
|
+
* must be a non-negative integer, and `updatedAt` may not predate
|
|
36
|
+
* `createdAt`. Both dates are cloned on the way in so a later mutation of
|
|
37
|
+
* the caller's `Date` objects cannot reach into the entity's internal state.
|
|
38
|
+
*
|
|
39
|
+
* Declared `protected` because entities are reconstituted through a
|
|
40
|
+
* subclass factory, never instantiated directly by application code.
|
|
41
|
+
*
|
|
42
|
+
* @throws {InvariantViolationException} When `updatedAt` is earlier than `createdAt`.
|
|
43
|
+
*/
|
|
44
|
+
constructor(state) {
|
|
45
|
+
assertValidDate("createdAt", state.createdAt);
|
|
46
|
+
assertValidDate("updatedAt", state.updatedAt);
|
|
47
|
+
assertValidAggregateVersion(state.aggregateVersion);
|
|
48
|
+
if (state.updatedAt.getTime() < state.createdAt.getTime()) throw new InvariantViolationException("updatedAt cannot be earlier than createdAt");
|
|
49
|
+
this._id = state.id;
|
|
50
|
+
this._createdAt = cloneDate(state.createdAt);
|
|
51
|
+
this._updatedAt = cloneDate(state.updatedAt);
|
|
52
|
+
this._aggregateVersion = state.aggregateVersion;
|
|
53
|
+
}
|
|
54
|
+
/** The entity's stable identity — the basis for equality between entities. */
|
|
55
|
+
get id() {
|
|
56
|
+
return this._id;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* When the entity was first created.
|
|
60
|
+
*
|
|
61
|
+
* Returns a clone so callers cannot mutate the entity's internal `Date`;
|
|
62
|
+
* the value is fixed at construction and never changes thereafter.
|
|
63
|
+
*/
|
|
64
|
+
get createdAt() {
|
|
65
|
+
return cloneDate(this._createdAt);
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* When the entity was last modified.
|
|
69
|
+
*
|
|
70
|
+
* Returns a clone for the same encapsulation reason as {@link createdAt};
|
|
71
|
+
* the underlying value advances only through {@link markAsModified}.
|
|
72
|
+
*/
|
|
73
|
+
get updatedAt() {
|
|
74
|
+
return cloneDate(this._updatedAt);
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Monotonic counter incremented on every mutation, used for optimistic
|
|
78
|
+
* concurrency control: a writer reads this value, and the persistence layer
|
|
79
|
+
* rejects the write if the stored version has moved on in the meantime.
|
|
80
|
+
*/
|
|
81
|
+
get aggregateVersion() {
|
|
82
|
+
return this._aggregateVersion;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* The schema/contract version stamped on this entity type by the
|
|
86
|
+
* `@version` decorator — used to detect and migrate state persisted under
|
|
87
|
+
* an older shape.
|
|
88
|
+
*/
|
|
89
|
+
get contractVersion() {
|
|
90
|
+
return _Entity.CONTRACT_VERSION;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* The single seam through which an entity records a mutation: it advances
|
|
94
|
+
* `updatedAt` and bumps {@link aggregateVersion} by one. Subclasses must
|
|
95
|
+
* call this from every state-changing method so the version counter stays
|
|
96
|
+
* an accurate optimistic-lock token.
|
|
97
|
+
*
|
|
98
|
+
* @param updatedAt - The modification instant; defaults to now. Validated
|
|
99
|
+
* and required not to predate `createdAt`, preserving the same invariant
|
|
100
|
+
* the constructor enforces.
|
|
101
|
+
* @returns The new aggregate version after the increment.
|
|
102
|
+
* @throws {InvariantViolationException} When `updatedAt` is earlier than `createdAt`.
|
|
103
|
+
*/
|
|
104
|
+
markAsModified(updatedAt = /* @__PURE__ */ new Date()) {
|
|
105
|
+
assertValidDate("updatedAt", updatedAt);
|
|
106
|
+
if (updatedAt.getTime() < this._createdAt.getTime()) throw new InvariantViolationException("updatedAt cannot be earlier than createdAt");
|
|
107
|
+
this._updatedAt = cloneDate(updatedAt);
|
|
108
|
+
this._aggregateVersion += 1;
|
|
109
|
+
return this._aggregateVersion;
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
Entity = _Entity = __decorate([version("1.0")], Entity);
|
|
113
|
+
//#endregion
|
|
114
|
+
//#region src/core/domain/value-object.ts
|
|
115
|
+
var _ValueObject;
|
|
116
|
+
/**
|
|
117
|
+
* Base class for value objects — domain concepts defined entirely by their
|
|
118
|
+
* contents, with no identity of their own. Two value objects are
|
|
119
|
+
* interchangeable when they hold equal data, which is the opposite of an
|
|
120
|
+
* {@link Entity} (compared by id). Money, a CPF, a date range: replacing one
|
|
121
|
+
* instance with an equal one changes nothing about the model.
|
|
122
|
+
*
|
|
123
|
+
* Immutability is the defining guarantee here. The wrapped `value` is
|
|
124
|
+
* deep-frozen on construction, so a value object can be shared freely without
|
|
125
|
+
* any risk of a consumer mutating shared state. Subclasses seal the instance
|
|
126
|
+
* itself with {@link finalize} once their own fields are set.
|
|
127
|
+
*
|
|
128
|
+
* @typeParam T - The shape of the wrapped data.
|
|
129
|
+
* @typeParam P - The primitive form produced by {@link toPrimitive} / {@link toJSON}.
|
|
130
|
+
*/
|
|
131
|
+
let ValueObject = class ValueObject {
|
|
132
|
+
static {
|
|
133
|
+
_ValueObject = this;
|
|
134
|
+
}
|
|
135
|
+
static {
|
|
136
|
+
this.plugins = new PluginManager();
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Wraps `value`, deep-freezing it so the value object is immutable from the
|
|
140
|
+
* moment it exists. Declared `protected` because value objects are built
|
|
141
|
+
* through a validating subclass factory, never instantiated directly.
|
|
142
|
+
*/
|
|
143
|
+
constructor(value) {
|
|
144
|
+
this.value = makeImmutable(value);
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* The schema/contract version stamped on this value-object type by the
|
|
148
|
+
* `@version` decorator — used to detect state persisted under an older shape.
|
|
149
|
+
*/
|
|
150
|
+
get contractVersion() {
|
|
151
|
+
return _ValueObject.CONTRACT_VERSION;
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Freezes the instance shell, blocking reassignment of any own field.
|
|
155
|
+
*
|
|
156
|
+
* `value` is already deep-frozen by the constructor, so the wrapped data is
|
|
157
|
+
* immutable regardless. The instance itself is NOT frozen automatically
|
|
158
|
+
* because a subclass may still need to assign its own fields after
|
|
159
|
+
* `super(value)` runs. Call `finalize()` at the very end of the subclass
|
|
160
|
+
* constructor (after all fields are set) to make the whole value object
|
|
161
|
+
* immutable.
|
|
162
|
+
*/
|
|
163
|
+
finalize() {
|
|
164
|
+
Object.freeze(this);
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Hook for `JSON.stringify`. Delegates to {@link toPrimitive} so a value
|
|
168
|
+
* object serializes to its primitive form rather than exposing the internal
|
|
169
|
+
* `value` wrapper.
|
|
170
|
+
*/
|
|
171
|
+
toJSON() {
|
|
172
|
+
return this.toPrimitive();
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Compares this value object with another by content. Because value objects
|
|
176
|
+
* carry no identity, two independently constructed instances holding the
|
|
177
|
+
* same data are considered equal.
|
|
178
|
+
*
|
|
179
|
+
* Delegates to the registered equality {@link plugins}; with no plugin
|
|
180
|
+
* registered it falls back to comparing the serialized wrapped `value`.
|
|
181
|
+
* Subclasses may still override for a faster or domain-specific comparison.
|
|
182
|
+
*/
|
|
183
|
+
equals(other) {
|
|
184
|
+
return _ValueObject.plugins.invoke("equals", [this, other], { fallback: (a, b) => JSON.stringify(a.value) === JSON.stringify(b.value) });
|
|
185
|
+
}
|
|
186
|
+
};
|
|
187
|
+
ValueObject = _ValueObject = __decorate([version("1.0")], ValueObject);
|
|
188
|
+
//#endregion
|
|
189
|
+
export { Entity as n, assertValidAggregateVersion as r, ValueObject as t };
|
|
190
|
+
|
|
191
|
+
//# sourceMappingURL=value-object.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"value-object.js","names":[],"sources":["../src/core/shared/aggregate-version.ts","../src/core/domain/entity.ts","../src/core/domain/value-object.ts"],"sourcesContent":["import { InvariantViolationException } from \"../exceptions/invariant-violation-exception.js\";\n\nfunction assertValidAggregateVersion(aggregateVersion: number): void {\n if (!Number.isInteger(aggregateVersion) || aggregateVersion < 0) {\n throw new InvariantViolationException(\n `aggregateVersion must be a non-negative integer. Received: ${aggregateVersion}`,\n );\n }\n}\n\nexport { assertValidAggregateVersion };\n","import { InvariantViolationException } from \"../exceptions/invariant-violation-exception.js\";\nimport { assertValidAggregateVersion } from \"../shared/aggregate-version.js\";\nimport { assertValidDate, cloneDate } from \"../shared/temporal-guards.js\";\nimport { type ContractVersion, version } from \"../versioning/version.js\";\n\n/**\n * The minimal persisted shape needed to reconstitute an {@link Entity}.\n *\n * This is the contract between storage and the domain: a repository maps a row\n * (or document) onto these four fields and hands them to a subclass constructor.\n * `aggregateVersion` travels with the state so optimistic-concurrency checks\n * survive a round-trip through the database.\n */\ninterface EntityState<TIdentifier> {\n readonly id: TIdentifier;\n readonly createdAt: Date;\n readonly updatedAt: Date;\n readonly aggregateVersion: number;\n}\n\n/**\n * Base class for domain entities — objects defined by a stable identity rather\n * than by their attributes. Two entities are \"the same\" when their `id`\n * matches, even if every other field differs; this is the opposite of a\n * {@link ValueObject}, which is defined entirely by its contents.\n *\n * The class owns the bookkeeping common to every aggregate root: a creation\n * timestamp that never changes, a last-modified timestamp, and an\n * `aggregateVersion` counter used for optimistic concurrency control. All three\n * are validated on construction and the dates are defensively cloned, so an\n * entity can never be built into — or leak — an inconsistent temporal state.\n *\n * @typeParam TIdentifier - The identity type (e.g. a branded string id or a VO).\n */\n@version(\"1.0\")\nabstract class Entity<TIdentifier> {\n declare public static readonly CONTRACT_VERSION: ContractVersion;\n\n private readonly _id: TIdentifier;\n private readonly _createdAt: Date;\n private _updatedAt: Date;\n private _aggregateVersion: number;\n\n /**\n * Reconstitutes an entity from its persisted {@link EntityState}.\n *\n * Validates the temporal invariants up front so an invalid entity is\n * impossible to construct: both dates must be valid, the aggregate version\n * must be a non-negative integer, and `updatedAt` may not predate\n * `createdAt`. Both dates are cloned on the way in so a later mutation of\n * the caller's `Date` objects cannot reach into the entity's internal state.\n *\n * Declared `protected` because entities are reconstituted through a\n * subclass factory, never instantiated directly by application code.\n *\n * @throws {InvariantViolationException} When `updatedAt` is earlier than `createdAt`.\n */\n protected constructor(state: EntityState<TIdentifier>) {\n assertValidDate(\"createdAt\", state.createdAt);\n assertValidDate(\"updatedAt\", state.updatedAt);\n assertValidAggregateVersion(state.aggregateVersion);\n\n if (state.updatedAt.getTime() < state.createdAt.getTime()) {\n throw new InvariantViolationException(\n \"updatedAt cannot be earlier than createdAt\",\n );\n }\n\n this._id = state.id;\n this._createdAt = cloneDate(state.createdAt);\n this._updatedAt = cloneDate(state.updatedAt);\n this._aggregateVersion = state.aggregateVersion;\n }\n\n /** The entity's stable identity — the basis for equality between entities. */\n public get id(): TIdentifier {\n return this._id;\n }\n\n /**\n * When the entity was first created.\n *\n * Returns a clone so callers cannot mutate the entity's internal `Date`;\n * the value is fixed at construction and never changes thereafter.\n */\n public get createdAt(): Date {\n return cloneDate(this._createdAt);\n }\n\n /**\n * When the entity was last modified.\n *\n * Returns a clone for the same encapsulation reason as {@link createdAt};\n * the underlying value advances only through {@link markAsModified}.\n */\n public get updatedAt(): Date {\n return cloneDate(this._updatedAt);\n }\n\n /**\n * Monotonic counter incremented on every mutation, used for optimistic\n * concurrency control: a writer reads this value, and the persistence layer\n * rejects the write if the stored version has moved on in the meantime.\n */\n public get aggregateVersion(): number {\n return this._aggregateVersion;\n }\n\n /**\n * The schema/contract version stamped on this entity type by the\n * `@version` decorator — used to detect and migrate state persisted under\n * an older shape.\n */\n public get contractVersion(): ContractVersion {\n return Entity.CONTRACT_VERSION;\n }\n\n /**\n * The single seam through which an entity records a mutation: it advances\n * `updatedAt` and bumps {@link aggregateVersion} by one. Subclasses must\n * call this from every state-changing method so the version counter stays\n * an accurate optimistic-lock token.\n *\n * @param updatedAt - The modification instant; defaults to now. Validated\n * and required not to predate `createdAt`, preserving the same invariant\n * the constructor enforces.\n * @returns The new aggregate version after the increment.\n * @throws {InvariantViolationException} When `updatedAt` is earlier than `createdAt`.\n */\n protected markAsModified(updatedAt: Date = new Date()): number {\n assertValidDate(\"updatedAt\", updatedAt);\n\n if (updatedAt.getTime() < this._createdAt.getTime()) {\n throw new InvariantViolationException(\n \"updatedAt cannot be earlier than createdAt\",\n );\n }\n\n this._updatedAt = cloneDate(updatedAt);\n this._aggregateVersion += 1;\n\n return this._aggregateVersion;\n }\n}\n\nexport { Entity, type EntityState };\n","import { PluginManager } from \"../plugins/index.js\";\nimport { type DeepReadonly, makeImmutable } from \"../shared/immutable.js\";\nimport { type ContractVersion, version } from \"../versioning/version.js\";\n\n/**\n * Extension point for value-object equality. A plugin implementing this\n * contract overrides how any two value objects are compared, letting the host\n * application swap in a structural comparator (e.g. `lodash.isEqual` over the\n * wrapped `value`) without every value object having to implement `equals` by\n * hand.\n */\ntype ValueObjectPluginContract = {\n equals: (\n a: ValueObject<unknown, unknown>,\n b: ValueObject<unknown, unknown>,\n ) => boolean;\n};\n\n/**\n * Base class for value objects — domain concepts defined entirely by their\n * contents, with no identity of their own. Two value objects are\n * interchangeable when they hold equal data, which is the opposite of an\n * {@link Entity} (compared by id). Money, a CPF, a date range: replacing one\n * instance with an equal one changes nothing about the model.\n *\n * Immutability is the defining guarantee here. The wrapped `value` is\n * deep-frozen on construction, so a value object can be shared freely without\n * any risk of a consumer mutating shared state. Subclasses seal the instance\n * itself with {@link finalize} once their own fields are set.\n *\n * @typeParam T - The shape of the wrapped data.\n * @typeParam P - The primitive form produced by {@link toPrimitive} / {@link toJSON}.\n */\n@version(\"1.0\")\nabstract class ValueObject<T, P> {\n declare public static readonly CONTRACT_VERSION: ContractVersion;\n\n /**\n * Registry of equality plugins shared by every value object. Empty by\n * default — when nothing is registered, {@link equals} falls back to a\n * structural comparison of the wrapped `value`. Hosts register a plugin\n * (e.g. `lodash.isEqual`) once at startup to customise equality globally.\n */\n public static readonly plugins =\n new PluginManager<ValueObjectPluginContract>();\n\n /** The wrapped data, deep-frozen so it can never be mutated after construction. */\n public readonly value: DeepReadonly<T>;\n\n /**\n * Wraps `value`, deep-freezing it so the value object is immutable from the\n * moment it exists. Declared `protected` because value objects are built\n * through a validating subclass factory, never instantiated directly.\n */\n protected constructor(value: T) {\n this.value = makeImmutable(value);\n }\n\n /**\n * The schema/contract version stamped on this value-object type by the\n * `@version` decorator — used to detect state persisted under an older shape.\n */\n public get contractVersion(): ContractVersion {\n return ValueObject.CONTRACT_VERSION;\n }\n\n /**\n * Freezes the instance shell, blocking reassignment of any own field.\n *\n * `value` is already deep-frozen by the constructor, so the wrapped data is\n * immutable regardless. The instance itself is NOT frozen automatically\n * because a subclass may still need to assign its own fields after\n * `super(value)` runs. Call `finalize()` at the very end of the subclass\n * constructor (after all fields are set) to make the whole value object\n * immutable.\n */\n protected finalize(): void {\n Object.freeze(this);\n }\n\n /**\n * Hook for `JSON.stringify`. Delegates to {@link toPrimitive} so a value\n * object serializes to its primitive form rather than exposing the internal\n * `value` wrapper.\n */\n public toJSON(): P {\n return this.toPrimitive();\n }\n\n /**\n * Compares this value object with another by content. Because value objects\n * carry no identity, two independently constructed instances holding the\n * same data are considered equal.\n *\n * Delegates to the registered equality {@link plugins}; with no plugin\n * registered it falls back to comparing the serialized wrapped `value`.\n * Subclasses may still override for a faster or domain-specific comparison.\n */\n public equals(other: this): boolean {\n return ValueObject.plugins.invoke(\"equals\", [this, other], {\n fallback: (a, b) =>\n JSON.stringify(a.value) === JSON.stringify(b.value),\n });\n }\n\n /**\n * Projects the value object down to a plain, serializable primitive form —\n * the representation suitable for persistence, transport, or comparison.\n */\n public abstract toPrimitive(): P;\n}\n\nexport { type DeepReadonly, ValueObject, type ValueObjectPluginContract };\n"],"mappings":";;;;;AAEA,SAAS,4BAA4B,kBAAgC;CACjE,IAAI,CAAC,OAAO,UAAU,gBAAgB,KAAK,mBAAmB,GAC1D,MAAM,IAAI,4BACN,8DAA8D,kBAClE;AAER;;;;;;;;;;;;;;;;;;AC0BA,IAAA,SAAA,MACe,OAAoB;;;;;;;;;;;;;;;;;;CAsB/B,YAAsB,OAAiC;EACnD,gBAAgB,aAAa,MAAM,SAAS;EAC5C,gBAAgB,aAAa,MAAM,SAAS;EAC5C,4BAA4B,MAAM,gBAAgB;EAElD,IAAI,MAAM,UAAU,QAAQ,IAAI,MAAM,UAAU,QAAQ,GACpD,MAAM,IAAI,4BACN,4CACJ;EAGJ,KAAK,MAAM,MAAM;EACjB,KAAK,aAAa,UAAU,MAAM,SAAS;EAC3C,KAAK,aAAa,UAAU,MAAM,SAAS;EAC3C,KAAK,oBAAoB,MAAM;CACnC;;CAGA,IAAW,KAAkB;EACzB,OAAO,KAAK;CAChB;;;;;;;CAQA,IAAW,YAAkB;EACzB,OAAO,UAAU,KAAK,UAAU;CACpC;;;;;;;CAQA,IAAW,YAAkB;EACzB,OAAO,UAAU,KAAK,UAAU;CACpC;;;;;;CAOA,IAAW,mBAA2B;EAClC,OAAO,KAAK;CAChB;;;;;;CAOA,IAAW,kBAAmC;EAC1C,OAAA,QAAc;CAClB;;;;;;;;;;;;;CAcA,eAAyB,4BAAkB,IAAI,KAAK,GAAW;EAC3D,gBAAgB,aAAa,SAAS;EAEtC,IAAI,UAAU,QAAQ,IAAI,KAAK,WAAW,QAAQ,GAC9C,MAAM,IAAI,4BACN,4CACJ;EAGJ,KAAK,aAAa,UAAU,SAAS;EACrC,KAAK,qBAAqB;EAE1B,OAAO,KAAK;CAChB;AACJ;+BA7GC,QAAQ,KAAK,CAAA,GAAA,MAAA;;;;;;;;;;;;;;;;;;;ACDd,IAAA,cAAA,MACe,YAAkB;;;;;iBAUzB,IAAI,cAAyC;;;;;;;CAUjD,YAAsB,OAAU;EAC5B,KAAK,QAAQ,cAAc,KAAK;CACpC;;;;;CAMA,IAAW,kBAAmC;EAC1C,OAAA,aAAmB;CACvB;;;;;;;;;;;CAYA,WAA2B;EACvB,OAAO,OAAO,IAAI;CACtB;;;;;;CAOA,SAAmB;EACf,OAAO,KAAK,YAAY;CAC5B;;;;;;;;;;CAWA,OAAc,OAAsB;EAChC,OAAA,aAAmB,QAAQ,OAAO,UAAU,CAAC,MAAM,KAAK,GAAG,EACvD,WAAW,GAAG,MACV,KAAK,UAAU,EAAE,KAAK,MAAM,KAAK,UAAU,EAAE,KAAK,EAC1D,CAAC;CACL;AAOJ;yCA7EC,QAAQ,KAAK,CAAA,GAAA,WAAA"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
//#region src/core/versioning/version.d.ts
|
|
2
|
+
type ContractVersion = `${number}.${number}`;
|
|
3
|
+
type VersionedTarget = {
|
|
4
|
+
readonly prototype: object;
|
|
5
|
+
};
|
|
6
|
+
declare const CONTRACT_VERSION_PROPERTY: "CONTRACT_VERSION";
|
|
7
|
+
declare function version<const TVersion extends ContractVersion>(contractVersion: TVersion): (target: VersionedTarget) => void;
|
|
8
|
+
//#endregion
|
|
9
|
+
export { version as i, ContractVersion as n, VersionedTarget as r, CONTRACT_VERSION_PROPERTY as t };
|
|
10
|
+
//# sourceMappingURL=version.d.ts.map
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { i as version, n as ContractVersion, r as VersionedTarget, t as CONTRACT_VERSION_PROPERTY } from "../version.js";
|
|
2
|
+
import { a as buildDomainEventContractVersions, i as DomainEventEnvelope, n as DomainEventContractSelection, o as createDomainEventEnvelope, r as DomainEventContractVersions, t as CreateDomainEventEnvelopeInput } from "../domain-event-contracts.js";
|
|
3
|
+
export { CONTRACT_VERSION_PROPERTY, ContractVersion, CreateDomainEventEnvelopeInput, DomainEventContractSelection, DomainEventContractVersions, DomainEventEnvelope, VersionedTarget, buildDomainEventContractVersions, createDomainEventEnvelope, version };
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { i as version, r as CONTRACT_VERSION_PROPERTY } from "../immutable.js";
|
|
2
|
+
import { n as createDomainEventEnvelope, t as buildDomainEventContractVersions } from "../domain-event-contracts.js";
|
|
3
|
+
export { CONTRACT_VERSION_PROPERTY, buildDomainEventContractVersions, createDomainEventEnvelope, version };
|