@cullet/erp-core 1.4.0 → 2.0.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 +7 -1
- package/dist/abac/index.d.cts +2 -2
- package/dist/abac/index.d.ts +2 -2
- package/dist/aggregate-version.cjs +14 -0
- package/dist/aggregate-version.cjs.map +1 -0
- package/dist/aggregate-version.js +9 -0
- package/dist/aggregate-version.js.map +1 -0
- package/dist/app-error.cjs +21 -6
- package/dist/app-error.cjs.map +1 -1
- package/dist/app-error.js +21 -6
- package/dist/app-error.js.map +1 -1
- package/dist/application/index.cjs +8 -4
- package/dist/application/index.d.cts +2 -2
- package/dist/application/index.d.ts +2 -2
- package/dist/application/index.js +1 -2
- package/dist/authorization-error.cjs +67 -17
- package/dist/authorization-error.cjs.map +1 -1
- package/dist/authorization-error.d.cts +6 -2
- package/dist/authorization-error.d.ts +6 -2
- package/dist/authorization-error.js +50 -18
- package/dist/authorization-error.js.map +1 -1
- package/dist/authorizer.port.d.cts +18 -3
- package/dist/authorizer.port.d.ts +18 -3
- package/dist/composite-authorizer.d.cts +63 -10
- package/dist/composite-authorizer.d.ts +63 -10
- package/dist/condition-evaluator.cjs +117 -172
- package/dist/condition-evaluator.cjs.map +1 -1
- package/dist/condition-evaluator.js +118 -167
- package/dist/condition-evaluator.js.map +1 -1
- package/dist/core-config.d.cts +53 -6
- package/dist/core-config.d.ts +53 -6
- package/dist/decorate.cjs +14 -0
- package/dist/decorate.js +9 -0
- package/dist/domain/index.cjs +107 -2
- package/dist/domain/index.cjs.map +1 -0
- package/dist/domain/index.d.cts +25 -1
- package/dist/domain/index.d.ts +25 -1
- package/dist/domain/index.js +99 -3
- package/dist/domain/index.js.map +1 -0
- package/dist/domain-event-contracts.cjs +12 -8
- package/dist/domain-event-contracts.cjs.map +1 -1
- package/dist/domain-event-contracts.d.cts +29 -4
- package/dist/domain-event-contracts.d.ts +29 -4
- package/dist/domain-event-contracts.js +11 -7
- package/dist/domain-event-contracts.js.map +1 -1
- package/dist/domain-exception.cjs +2 -1
- package/dist/domain-exception.cjs.map +1 -1
- package/dist/domain-exception.js +2 -1
- package/dist/domain-exception.js.map +1 -1
- package/dist/errors/index.cjs +3 -2
- package/dist/errors/index.d.cts +1 -1
- package/dist/errors/index.d.ts +1 -1
- package/dist/errors/index.js +3 -2
- package/dist/exceptions/index.cjs +2 -2
- package/dist/exceptions/index.d.cts +1 -2
- package/dist/exceptions/index.d.ts +1 -2
- package/dist/exceptions/index.js +2 -2
- package/dist/gate-engine-registry.cjs.map +1 -1
- package/dist/gate-engine-registry.d.cts +1 -1
- package/dist/gate-engine-registry.d.ts +1 -1
- package/dist/gate-engine-registry.js.map +1 -1
- package/dist/gate-v1-payload.schema.cjs +11 -6
- package/dist/gate-v1-payload.schema.cjs.map +1 -1
- package/dist/gate-v1-payload.schema.js +11 -6
- package/dist/gate-v1-payload.schema.js.map +1 -1
- package/dist/hashing.cjs +2 -44
- package/dist/hashing.cjs.map +1 -1
- package/dist/hashing.js +3 -39
- package/dist/hashing.js.map +1 -1
- package/dist/immutable.cjs +25 -12
- package/dist/immutable.cjs.map +1 -1
- package/dist/immutable.js +24 -11
- package/dist/immutable.js.map +1 -1
- package/dist/index.cjs +15 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +9 -10
- package/dist/index.d.ts +9 -10
- package/dist/index.js +8 -9
- package/dist/index.js.map +1 -1
- package/dist/invalid-state-transition-exception.cjs +6 -6
- package/dist/invalid-state-transition-exception.cjs.map +1 -1
- package/dist/invalid-state-transition-exception.js +6 -6
- package/dist/invalid-state-transition-exception.js.map +1 -1
- package/dist/invariant-violation-exception.cjs +2 -2
- package/dist/invariant-violation-exception.cjs.map +1 -1
- package/dist/invariant-violation-exception.js +2 -2
- package/dist/invariant-violation-exception.js.map +1 -1
- package/dist/not-found-error.cjs +6 -4
- package/dist/not-found-error.cjs.map +1 -1
- package/dist/not-found-error.js +6 -4
- package/dist/not-found-error.js.map +1 -1
- package/dist/outcome.cjs +5 -5
- package/dist/outcome.cjs.map +1 -1
- package/dist/outcome.js +5 -5
- package/dist/outcome.js.map +1 -1
- package/dist/parse-gate-payload.d.cts +1 -1
- package/dist/parse-gate-payload.d.ts +1 -1
- package/dist/path.d.cts +2 -2
- package/dist/path.d.ts +2 -2
- package/dist/plugin.cjs +23 -13
- package/dist/plugin.cjs.map +1 -1
- package/dist/plugin.d.cts +22 -8
- package/dist/plugin.d.ts +22 -8
- package/dist/plugin.js +23 -13
- package/dist/plugin.js.map +1 -1
- package/dist/policies/engines/index.d.cts +1 -1
- package/dist/policies/engines/index.d.ts +1 -1
- package/dist/policies/engines/v1/gate/index.d.cts +3 -13
- package/dist/policies/engines/v1/gate/index.d.ts +3 -13
- package/dist/policies/index.d.cts +1 -1
- package/dist/policies/index.d.ts +1 -1
- package/dist/policy-bridge.cjs +30 -2
- package/dist/policy-bridge.cjs.map +1 -1
- package/dist/policy-bridge.d.cts +18 -0
- package/dist/policy-bridge.d.ts +18 -0
- package/dist/policy-bridge.js +30 -2
- package/dist/policy-bridge.js.map +1 -1
- package/dist/policy-service.cjs +41 -46
- package/dist/policy-service.cjs.map +1 -1
- package/dist/policy-service.d.cts +72 -9
- package/dist/policy-service.d.ts +72 -9
- package/dist/policy-service.js +43 -48
- package/dist/policy-service.js.map +1 -1
- package/dist/requested-by.cjs +4 -4
- package/dist/requested-by.cjs.map +1 -1
- package/dist/requested-by.js +2 -2
- package/dist/requested-by.js.map +1 -1
- package/dist/result.cjs +29 -1
- package/dist/result.cjs.map +1 -1
- package/dist/result.d.cts +12 -0
- package/dist/result.d.ts +12 -0
- package/dist/result.js +29 -1
- package/dist/result.js.map +1 -1
- package/dist/rule.cjs +94 -24
- package/dist/rule.cjs.map +1 -1
- package/dist/rule.js +94 -24
- package/dist/rule.js.map +1 -1
- package/dist/ruleset-registry.cjs +19 -0
- package/dist/ruleset-registry.cjs.map +1 -1
- package/dist/ruleset-registry.js +19 -0
- package/dist/ruleset-registry.js.map +1 -1
- package/dist/stable-stringify.cjs +87 -0
- package/dist/stable-stringify.cjs.map +1 -0
- package/dist/stable-stringify.js +76 -0
- package/dist/stable-stringify.js.map +1 -0
- package/dist/temporal-snapshot.d.cts +87 -0
- package/dist/temporal-snapshot.d.ts +87 -0
- package/dist/temporal-use-case.cjs +174 -16
- package/dist/temporal-use-case.cjs.map +1 -1
- package/dist/temporal-use-case.d.cts +82 -44
- package/dist/temporal-use-case.d.ts +82 -44
- package/dist/temporal-use-case.js +167 -15
- package/dist/temporal-use-case.js.map +1 -1
- package/dist/unexpected-error.cjs +4 -2
- package/dist/unexpected-error.cjs.map +1 -1
- package/dist/unexpected-error.js +4 -2
- package/dist/unexpected-error.js.map +1 -1
- package/dist/uuid-identifier.cjs +141 -8
- package/dist/uuid-identifier.cjs.map +1 -1
- package/dist/uuid-identifier.d.cts +26 -7
- package/dist/uuid-identifier.d.ts +26 -7
- package/dist/uuid-identifier.js +135 -8
- package/dist/uuid-identifier.js.map +1 -1
- package/dist/uuid.cjs +23 -0
- package/dist/uuid.cjs.map +1 -0
- package/dist/uuid.js +18 -0
- package/dist/uuid.js.map +1 -0
- package/dist/validation-code.cjs +9 -0
- package/dist/validation-code.cjs.map +1 -1
- package/dist/validation-code.d.cts +3 -0
- package/dist/validation-code.d.ts +3 -0
- package/dist/validation-code.js +9 -0
- package/dist/validation-code.js.map +1 -1
- package/dist/validation-error.cjs +42 -67
- package/dist/validation-error.cjs.map +1 -1
- package/dist/validation-error.d.cts +29 -8
- package/dist/validation-error.d.ts +29 -8
- package/dist/validation-error.js +41 -66
- package/dist/validation-error.js.map +1 -1
- package/dist/validation-exception.cjs +17 -6
- package/dist/validation-exception.cjs.map +1 -1
- package/dist/validation-exception.d.cts +33 -9
- package/dist/validation-exception.d.ts +33 -9
- package/dist/validation-exception.js +17 -6
- package/dist/validation-exception.js.map +1 -1
- package/dist/validation-field.cjs +3 -0
- package/dist/validation-field.cjs.map +1 -1
- package/dist/validation-field.d.cts +1 -0
- package/dist/validation-field.d.ts +1 -0
- package/dist/validation-field.js +3 -0
- package/dist/validation-field.js.map +1 -1
- package/dist/value-object-ruleset.contracts.d.cts +10 -0
- package/dist/value-object-ruleset.contracts.d.ts +10 -0
- package/dist/value-object.cjs +23 -4
- package/dist/value-object.cjs.map +1 -1
- package/dist/value-object.d.cts +25 -1
- package/dist/value-object.d.ts +25 -1
- package/dist/value-object.js +23 -4
- package/dist/value-object.js.map +1 -1
- package/dist/version.d.cts +27 -0
- package/dist/version.d.ts +27 -0
- package/dist/versioning/index.d.cts +2 -2
- package/dist/versioning/index.d.ts +2 -2
- package/meta.json +5 -2
- package/package.json +1 -1
- package/src/core/abac/authorizer.ts +60 -10
- package/src/core/abac/domain/policy-set.ts +52 -5
- package/src/core/abac/domain/rule.ts +28 -16
- package/src/core/abac/index.ts +7 -1
- package/src/core/application/commands/command.ts +14 -1
- package/src/core/application/commands/requested-by.ts +13 -5
- package/src/core/application/index.ts +2 -1
- package/src/core/application/policy-error-mapper.ts +6 -0
- package/src/core/application/ports/index.ts +7 -0
- package/src/core/application/ports/temporal-repository.port.ts +35 -2
- package/src/core/application/queries/index.ts +1 -1
- package/src/core/application/queries/query.ts +25 -3
- package/src/core/application/temporal/temporal-use-case.ts +31 -4
- package/src/core/application/use-case.ts +45 -8
- package/src/core/config/core-config.ts +46 -25
- package/src/core/config/index.ts +1 -0
- package/src/core/config/policy-reporter.ts +32 -1
- package/src/core/domain/entity.ts +51 -8
- package/src/core/domain/rulesets/entity-ruleset.contracts.ts +0 -2
- package/src/core/domain/rulesets/ruleset-registry.ts +24 -0
- package/src/core/domain/rulesets/value-object-ruleset.contracts.ts +1 -7
- package/src/core/domain/temporal/half-open-interval.ts +34 -0
- package/src/core/domain/temporal/temporal-snapshot.ts +13 -2
- package/src/core/domain/temporal/transaction-time.ts +19 -15
- package/src/core/domain/temporal/valid-time.ts +20 -15
- package/src/core/domain/uuid-identifier.ts +6 -11
- package/src/core/domain/value-object.ts +29 -3
- package/src/core/errors/authentication-error.ts +5 -31
- package/src/core/errors/authorization-error.ts +12 -20
- package/src/core/errors/business-rule-violation-error.ts +4 -1
- package/src/core/errors/idempotency-error.ts +5 -2
- package/src/core/errors/index.ts +4 -0
- package/src/core/errors/integration-error.ts +4 -24
- package/src/core/errors/legacy-incompatible-error.ts +1 -0
- package/src/core/errors/not-found-error.ts +4 -1
- package/src/core/errors/temporal-error.ts +22 -20
- package/src/core/errors/unexpected-error.ts +5 -1
- package/src/core/errors/utils/factory-helpers.ts +70 -0
- package/src/core/errors/utils/index.ts +5 -0
- package/src/core/errors/utils/json-safe.ts +35 -12
- package/src/core/errors/validation-error.ts +4 -1
- package/src/core/exceptions/business-rule-violation-exception.ts +2 -1
- package/src/core/exceptions/domain-exception.ts +9 -1
- package/src/core/exceptions/entity-not-found-exception.ts +5 -1
- package/src/core/exceptions/invalid-state-transition-exception.ts +5 -2
- package/src/core/exceptions/invariant-violation-exception.ts +2 -2
- package/src/core/exceptions/validation-code.ts +14 -0
- package/src/core/exceptions/validation-exception.ts +44 -5
- package/src/core/exceptions/validation-field.ts +11 -1
- package/src/core/plugins/plugin.ts +25 -15
- package/src/core/plugins/types.ts +4 -2
- package/src/core/policies/asof/asof.ts +12 -0
- package/src/core/policies/catalog/policy-catalog-entry.ts +3 -1
- package/src/core/policies/catalog/policy-catalog.ts +5 -1
- package/src/core/policies/context/context-builder.ts +20 -0
- package/src/core/policies/context/context-resolver.ts +5 -0
- package/src/core/policies/context/context-seed.ts +11 -0
- package/src/core/policies/defs/in-memory-policy-definition-repo.ts +0 -2
- package/src/core/policies/engines/parse-gate-payload.ts +9 -0
- package/src/core/policies/engines/v1/condition-date-operands.ts +112 -0
- package/src/core/policies/engines/v1/condition-evaluator.ts +120 -291
- package/src/core/policies/engines/v1/condition-schema.ts +23 -19
- package/src/core/policies/engines/v1/condition-types.ts +18 -11
- package/src/core/policies/index.ts +4 -6
- package/src/core/policies/service/policy-service.ts +46 -35
- package/src/core/policies/utils/hash.ts +5 -69
- package/src/core/policies/utils/result.ts +1 -1
- package/src/core/rbac/access-request.ts +12 -2
- package/src/core/rbac/authorizer.ts +8 -1
- package/src/core/rbac/domain/role.ts +20 -0
- package/src/core/rbac/domain/scope.ts +6 -1
- package/src/core/result/index.ts +5 -0
- package/src/core/result/outcome.ts +5 -7
- package/src/core/result/result.ts +34 -1
- package/src/core/shared/hashing.ts +6 -57
- package/src/core/shared/immutable.ts +22 -4
- package/src/core/shared/stable-stringify.ts +144 -0
- package/src/core/shared/uuid.ts +16 -0
- package/src/core/versioning/domain-event-contracts.ts +43 -15
- package/src/core/versioning/index.ts +1 -0
- package/src/core/versioning/version.ts +30 -1
- package/src/domain/index.ts +5 -0
- package/src/examples/rulesets/entity/order-creation-rules-v1.ts +1 -1
- package/src/examples/rulesets/entity/order-invariants-v1.ts +2 -4
- package/src/examples/rulesets/entity/order-invariants-v2.ts +2 -4
- package/src/examples/rulesets/value-object/cpf-rules-v1.ts +2 -4
- package/src/examples/rulesets/value-object/cpf-rules-v2.ts +2 -4
- package/src/examples/rulesets/value-object/person-name-rules-v1.ts +2 -4
- package/src/examples/rulesets/value-object/person-name-rules-v2.ts +2 -4
- package/src/result/index.ts +7 -2
- package/src/version.ts +1 -1
- package/dist/domain-exception.d.cts +0 -7
- package/dist/domain-exception.d.ts +0 -7
- package/dist/entity.cjs +0 -126
- package/dist/entity.cjs.map +0 -1
- package/dist/entity.js +0 -115
- package/dist/entity.js.map +0 -1
- package/dist/use-case.cjs +0 -96
- package/dist/use-case.cjs.map +0 -1
- package/dist/use-case.js +0 -91
- package/dist/use-case.js.map +0 -1
|
@@ -6,14 +6,23 @@ var SilentPolicyReporter = class {
|
|
|
6
6
|
};
|
|
7
7
|
//#endregion
|
|
8
8
|
//#region src/core/config/core-config.ts
|
|
9
|
-
|
|
9
|
+
/** Reports an event without letting a throwing reporter abort the caller. */
|
|
10
|
+
function safeReport(policyReporter, event) {
|
|
10
11
|
try {
|
|
11
12
|
policyReporter.report(event);
|
|
12
13
|
} catch {}
|
|
13
14
|
}
|
|
14
15
|
/**
|
|
15
|
-
*
|
|
16
|
-
*
|
|
16
|
+
* The core's config namespace. Today it holds a single section —
|
|
17
|
+
* `observability` — whose whole job is to decide *where policy telemetry goes*
|
|
18
|
+
* while guaranteeing telemetry is best-effort (a throwing reporter can never
|
|
19
|
+
* abort a domain flow). App config (env, settings, feature flags) is
|
|
20
|
+
* deliberately absent for now: when the core needs it, it joins here as a
|
|
21
|
+
* sibling section rather than a new module — which is why this is `config`,
|
|
22
|
+
* not `observability`. It holds the active {@link PolicyReporter} (silent by
|
|
23
|
+
* default, so the core carries no logging dependency), bridges it to the
|
|
24
|
+
* engines' {@link ConditionEvaluatorReporter}, and offers `reportSafely` as
|
|
25
|
+
* the single guarded emit path shared with {@link PolicyService}.
|
|
17
26
|
*/
|
|
18
27
|
var CoreConfig = class {
|
|
19
28
|
#initialReporter;
|
|
@@ -23,17 +32,23 @@ var CoreConfig = class {
|
|
|
23
32
|
this.#initialReporter = reporter;
|
|
24
33
|
this.#currentReporter = reporter;
|
|
25
34
|
}
|
|
35
|
+
/**
|
|
36
|
+
* Swaps the active reporter. Pass `observability.reporter` to enable
|
|
37
|
+
* telemetry, or set it explicitly to `undefined` to go silent again.
|
|
38
|
+
* Omitting `observability` (or its `reporter` key) is a no-op.
|
|
39
|
+
*/
|
|
26
40
|
configure(options) {
|
|
27
|
-
const
|
|
28
|
-
if (reporter) this.#currentReporter = reporter;
|
|
41
|
+
const observability = options.observability;
|
|
42
|
+
if (observability && "reporter" in observability) this.#currentReporter = observability.reporter ?? new SilentPolicyReporter();
|
|
29
43
|
return this;
|
|
30
44
|
}
|
|
31
45
|
reset() {
|
|
32
46
|
this.#currentReporter = this.#initialReporter;
|
|
33
47
|
return this;
|
|
34
48
|
}
|
|
35
|
-
|
|
36
|
-
|
|
49
|
+
/** Emits a policy event through the active reporter, best-effort. */
|
|
50
|
+
reportSafely(event) {
|
|
51
|
+
safeReport(this.#currentReporter, event);
|
|
37
52
|
}
|
|
38
53
|
getConditionEvaluationOptions(engineVersion) {
|
|
39
54
|
return {
|
|
@@ -42,19 +57,16 @@ var CoreConfig = class {
|
|
|
42
57
|
};
|
|
43
58
|
}
|
|
44
59
|
#bridgeToConditionReporter(policyReporter) {
|
|
60
|
+
const emit = (level, report) => {
|
|
61
|
+
safeReport(policyReporter, {
|
|
62
|
+
kind: "condition-eval",
|
|
63
|
+
...report,
|
|
64
|
+
level
|
|
65
|
+
});
|
|
66
|
+
};
|
|
45
67
|
return {
|
|
46
|
-
warn(report)
|
|
47
|
-
|
|
48
|
-
kind: "condition-eval",
|
|
49
|
-
...report
|
|
50
|
-
});
|
|
51
|
-
},
|
|
52
|
-
error(report) {
|
|
53
|
-
reportSafely(policyReporter, {
|
|
54
|
-
kind: "condition-eval",
|
|
55
|
-
...report
|
|
56
|
-
});
|
|
57
|
-
}
|
|
68
|
+
warn: (report) => emit("warn", report),
|
|
69
|
+
error: (report) => emit("error", report)
|
|
58
70
|
};
|
|
59
71
|
}
|
|
60
72
|
};
|
|
@@ -159,6 +171,54 @@ var PolicyDateUtils = class {
|
|
|
159
171
|
}
|
|
160
172
|
};
|
|
161
173
|
//#endregion
|
|
174
|
+
//#region src/core/policies/engines/v1/condition-date-operands.ts
|
|
175
|
+
/**
|
|
176
|
+
* The one instant format condition date operands may use. Strict on purpose
|
|
177
|
+
* (UTC, milliseconds) so comparisons are unambiguous across time zones — and
|
|
178
|
+
* so a malformed operand fails loudly instead of comparing wrong.
|
|
179
|
+
*/
|
|
180
|
+
const CANONICAL_UTC_DATE_FORMAT = "YYYY-MM-DDTHH:mm:ss.SSSZ";
|
|
181
|
+
const ISO_8601_UTC_DATE_PATTERN = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/;
|
|
182
|
+
const ISO_8601_DATE_LIKE_PATTERN = /^\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}/;
|
|
183
|
+
/**
|
|
184
|
+
* Parses a value used as a date operand:
|
|
185
|
+
* - `Result.ok(Date)` for a valid Date or a canonical ISO-8601 UTC string;
|
|
186
|
+
* - `Result.err` when it is date-shaped but malformed (invalid Date, or a
|
|
187
|
+
* date-like string that isn't canonical UTC) — a configuration error worth
|
|
188
|
+
* surfacing rather than silently treating as "not a date";
|
|
189
|
+
* - `null` when the value isn't date-shaped at all, so the caller can fall
|
|
190
|
+
* through to a numeric comparison.
|
|
191
|
+
*/
|
|
192
|
+
function parseComparableDate(value) {
|
|
193
|
+
if (value instanceof Date) return PolicyDateUtils.isValid(value) ? Result.ok(value) : Result.err("Invalid Date instance");
|
|
194
|
+
if (typeof value !== "string") return null;
|
|
195
|
+
if (ISO_8601_UTC_DATE_PATTERN.test(value)) {
|
|
196
|
+
const parsed = new Date(value);
|
|
197
|
+
if (!PolicyDateUtils.isValid(parsed) || parsed.toISOString() !== value) return Result.err("Invalid ISO 8601 UTC date string");
|
|
198
|
+
return Result.ok(parsed);
|
|
199
|
+
}
|
|
200
|
+
if (ISO_8601_DATE_LIKE_PATTERN.test(value)) return Result.err(`date operand must be canonical ISO 8601 UTC (${CANONICAL_UTC_DATE_FORMAT})`);
|
|
201
|
+
return null;
|
|
202
|
+
}
|
|
203
|
+
function evaluateRelationalNumbers(actual, op, expected) {
|
|
204
|
+
switch (op) {
|
|
205
|
+
case "gt": return actual > expected;
|
|
206
|
+
case "gte": return actual >= expected;
|
|
207
|
+
case "lt": return actual < expected;
|
|
208
|
+
case "lte": return actual <= expected;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
function containsInvalidDate(value) {
|
|
212
|
+
if (value instanceof Date) return !PolicyDateUtils.isValid(value);
|
|
213
|
+
if (Array.isArray(value)) return value.some((item) => containsInvalidDate(item));
|
|
214
|
+
return false;
|
|
215
|
+
}
|
|
216
|
+
function normalizeDateOperand(value) {
|
|
217
|
+
if (value instanceof Date) return value.toISOString();
|
|
218
|
+
if (Array.isArray(value)) return value.map((item) => normalizeDateOperand(item));
|
|
219
|
+
return value;
|
|
220
|
+
}
|
|
221
|
+
//#endregion
|
|
162
222
|
//#region src/core/policies/engines/v1/condition-evaluator.ts
|
|
163
223
|
const CONDITION_EVAL_THROWN_TAG = "CONDITION_EVAL_THREW";
|
|
164
224
|
const NULLISH_NUMERIC_OPERAND_NOT_ALLOWED_TAG = "NULLISH_NUMERIC_OPERAND_NOT_ALLOWED";
|
|
@@ -168,7 +228,6 @@ const INVALID_NUMERIC_OPERAND_TAG = "INVALID_NUMERIC_OPERAND";
|
|
|
168
228
|
const INVALID_SET_OPERAND_TAG = "INVALID_SET_OPERAND";
|
|
169
229
|
const EMPTY_OR_CONDITION_TAG = "EMPTY_OR_CONDITION";
|
|
170
230
|
const EMPTY_AND_CONDITION_TAG = "EMPTY_AND_CONDITION";
|
|
171
|
-
const ISO_8601_UTC_DATE_PATTERN = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/;
|
|
172
231
|
var ConditionEvaluatorV1 = class ConditionEvaluatorV1 {
|
|
173
232
|
constructor(context, options) {
|
|
174
233
|
this.context = context;
|
|
@@ -199,46 +258,8 @@ var ConditionEvaluatorV1 = class ConditionEvaluatorV1 {
|
|
|
199
258
|
message: String(error)
|
|
200
259
|
};
|
|
201
260
|
}
|
|
202
|
-
static
|
|
203
|
-
|
|
204
|
-
return `${NULLISH_NUMERIC_OPERAND_NOT_ALLOWED_TAG}: "${node.field}" resolved to ${resolvedValue} for numeric operator "${node.op}"`;
|
|
205
|
-
}
|
|
206
|
-
static buildNullishDateOperandMessage(node, actual) {
|
|
207
|
-
const resolvedValue = actual === null ? "null" : "undefined";
|
|
208
|
-
return `${NULLISH_DATE_OPERAND_NOT_ALLOWED_TAG}: "${node.field}" resolved to ${resolvedValue} for date comparison operator "${node.op}"`;
|
|
209
|
-
}
|
|
210
|
-
static buildInvalidDateOperandMessage(node) {
|
|
211
|
-
return `${INVALID_DATE_OPERAND_TAG}: "${node.field}" with operator "${node.op}" requires Date or ISO 8601 UTC string operands`;
|
|
212
|
-
}
|
|
213
|
-
static buildInvalidNumericOperandMessage(node) {
|
|
214
|
-
return `${INVALID_NUMERIC_OPERAND_TAG}: "${node.field}" with operator "${node.op}" requires numeric operands`;
|
|
215
|
-
}
|
|
216
|
-
static buildInvalidSetOperandMessage(node) {
|
|
217
|
-
return `${INVALID_SET_OPERAND_TAG}: "${node.field}" with operator "${node.op}" requires an array operand`;
|
|
218
|
-
}
|
|
219
|
-
static buildEmptyOrConditionMessage() {
|
|
220
|
-
return `${EMPTY_OR_CONDITION_TAG}: OR nodes must contain at least one child condition`;
|
|
221
|
-
}
|
|
222
|
-
static buildEmptyAndConditionMessage() {
|
|
223
|
-
return `${EMPTY_AND_CONDITION_TAG}: AND nodes must contain at least one child condition`;
|
|
224
|
-
}
|
|
225
|
-
static parseComparableDate(value) {
|
|
226
|
-
if (value instanceof Date) {
|
|
227
|
-
if (!PolicyDateUtils.isValid(value)) return Result.err("Invalid Date instance");
|
|
228
|
-
return Result.ok(value);
|
|
229
|
-
}
|
|
230
|
-
if (typeof value !== "string" || !ISO_8601_UTC_DATE_PATTERN.test(value)) return null;
|
|
231
|
-
const parsed = new Date(value);
|
|
232
|
-
if (!PolicyDateUtils.isValid(parsed) || parsed.toISOString() !== value) return Result.err("Invalid ISO 8601 UTC date string");
|
|
233
|
-
return Result.ok(parsed);
|
|
234
|
-
}
|
|
235
|
-
static evaluateRelationalNumbers(actual, op, expected) {
|
|
236
|
-
switch (op) {
|
|
237
|
-
case "gt": return actual > expected;
|
|
238
|
-
case "gte": return actual >= expected;
|
|
239
|
-
case "lt": return actual < expected;
|
|
240
|
-
case "lte": return actual <= expected;
|
|
241
|
-
}
|
|
261
|
+
static invalidDateOperandMessage(node) {
|
|
262
|
+
return `${INVALID_DATE_OPERAND_TAG}: "${node.field}" with operator "${node.op}" requires Date or ISO 8601 UTC (${CANONICAL_UTC_DATE_FORMAT}) string operands`;
|
|
242
263
|
}
|
|
243
264
|
buildReport(params) {
|
|
244
265
|
return {
|
|
@@ -250,162 +271,88 @@ var ConditionEvaluatorV1 = class ConditionEvaluatorV1 {
|
|
|
250
271
|
details: params.details
|
|
251
272
|
};
|
|
252
273
|
}
|
|
253
|
-
|
|
254
|
-
const cause = ConditionEvaluatorV1.describeError(error);
|
|
255
|
-
const message = `${CONDITION_EVAL_THROWN_TAG}: ${cause.name}: ${cause.message}`;
|
|
256
|
-
this.options.reporter.error(this.buildReport({
|
|
257
|
-
level: "error",
|
|
258
|
-
tag: CONDITION_EVAL_THROWN_TAG,
|
|
259
|
-
message,
|
|
260
|
-
details: {
|
|
261
|
-
node,
|
|
262
|
-
cause
|
|
263
|
-
}
|
|
264
|
-
}));
|
|
265
|
-
return Result.err(message);
|
|
266
|
-
}
|
|
267
|
-
reportDateOperandError(node, actual) {
|
|
268
|
-
const message = ConditionEvaluatorV1.buildInvalidDateOperandMessage(node);
|
|
274
|
+
reportLeafError(tag, message, node, actual, extra) {
|
|
269
275
|
this.options.reporter.error(this.buildReport({
|
|
270
276
|
level: "error",
|
|
271
|
-
tag
|
|
277
|
+
tag,
|
|
272
278
|
message,
|
|
273
279
|
details: {
|
|
274
280
|
field: node.field,
|
|
275
281
|
op: node.op,
|
|
276
282
|
actual,
|
|
277
283
|
expected: node.value,
|
|
284
|
+
...extra,
|
|
278
285
|
node
|
|
279
286
|
}
|
|
280
287
|
}));
|
|
281
288
|
return Result.err(message);
|
|
282
289
|
}
|
|
283
|
-
|
|
284
|
-
const
|
|
285
|
-
|
|
286
|
-
level: "error",
|
|
287
|
-
tag: INVALID_NUMERIC_OPERAND_TAG,
|
|
288
|
-
message,
|
|
289
|
-
details: {
|
|
290
|
-
field: node.field,
|
|
291
|
-
op: node.op,
|
|
292
|
-
actual,
|
|
293
|
-
expected: node.value,
|
|
294
|
-
node
|
|
295
|
-
}
|
|
296
|
-
}));
|
|
297
|
-
return Result.err(message);
|
|
298
|
-
}
|
|
299
|
-
reportInvalidSetOperand(node, actual) {
|
|
300
|
-
const message = ConditionEvaluatorV1.buildInvalidSetOperandMessage(node);
|
|
290
|
+
conditionEvalErr(node, error) {
|
|
291
|
+
const cause = ConditionEvaluatorV1.describeError(error);
|
|
292
|
+
const message = `${CONDITION_EVAL_THROWN_TAG}: ${cause.name}: ${cause.message}`;
|
|
301
293
|
this.options.reporter.error(this.buildReport({
|
|
302
294
|
level: "error",
|
|
303
|
-
tag:
|
|
295
|
+
tag: CONDITION_EVAL_THROWN_TAG,
|
|
304
296
|
message,
|
|
305
297
|
details: {
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
actual,
|
|
309
|
-
expected: node.value,
|
|
310
|
-
node
|
|
298
|
+
node,
|
|
299
|
+
cause
|
|
311
300
|
}
|
|
312
301
|
}));
|
|
313
302
|
return Result.err(message);
|
|
314
303
|
}
|
|
315
304
|
evaluateDateRelationalNode(node, actual) {
|
|
316
305
|
if (!ConditionEvaluatorV1.isRelationalOperator(node.op)) return null;
|
|
317
|
-
const
|
|
318
|
-
const
|
|
319
|
-
if (
|
|
306
|
+
const actualDate = parseComparableDate(actual);
|
|
307
|
+
const expectedDate = parseComparableDate(node.value);
|
|
308
|
+
if (actualDate === null && expectedDate === null) return null;
|
|
320
309
|
const allowsNull = node.allowNull === true;
|
|
321
|
-
if (actual === null)
|
|
322
|
-
|
|
323
|
-
const
|
|
324
|
-
this.
|
|
325
|
-
level: "error",
|
|
326
|
-
tag: NULLISH_DATE_OPERAND_NOT_ALLOWED_TAG,
|
|
327
|
-
message,
|
|
328
|
-
details: {
|
|
329
|
-
field: node.field,
|
|
330
|
-
op: node.op,
|
|
331
|
-
actual,
|
|
332
|
-
expected: node.value,
|
|
333
|
-
allowNull: allowsNull,
|
|
334
|
-
node
|
|
335
|
-
}
|
|
336
|
-
}));
|
|
337
|
-
return Result.err(message);
|
|
338
|
-
}
|
|
339
|
-
if (actual === void 0) {
|
|
340
|
-
const message = ConditionEvaluatorV1.buildNullishDateOperandMessage(node, actual);
|
|
341
|
-
this.options.reporter.error(this.buildReport({
|
|
342
|
-
level: "error",
|
|
343
|
-
tag: NULLISH_DATE_OPERAND_NOT_ALLOWED_TAG,
|
|
344
|
-
message,
|
|
345
|
-
details: {
|
|
346
|
-
field: node.field,
|
|
347
|
-
op: node.op,
|
|
348
|
-
actual,
|
|
349
|
-
expected: node.value,
|
|
350
|
-
allowNull: allowsNull,
|
|
351
|
-
node
|
|
352
|
-
}
|
|
353
|
-
}));
|
|
354
|
-
return Result.err(message);
|
|
310
|
+
if (actual === null && allowsNull) return Result.ok(false);
|
|
311
|
+
if (actual === null || actual === void 0) {
|
|
312
|
+
const resolved = actual === null ? "null" : "undefined";
|
|
313
|
+
return this.reportLeafError(NULLISH_DATE_OPERAND_NOT_ALLOWED_TAG, `${NULLISH_DATE_OPERAND_NOT_ALLOWED_TAG}: "${node.field}" resolved to ${resolved} for date comparison operator "${node.op}"`, node, actual, { allowNull: allowsNull });
|
|
355
314
|
}
|
|
356
|
-
if (
|
|
357
|
-
return Result.ok(
|
|
315
|
+
if (actualDate === null || actualDate.isErr() || expectedDate === null || expectedDate.isErr()) return this.reportLeafError(INVALID_DATE_OPERAND_TAG, ConditionEvaluatorV1.invalidDateOperandMessage(node), node, actual);
|
|
316
|
+
return Result.ok(evaluateRelationalNumbers(actualDate.getOrNull().getTime(), node.op, expectedDate.getOrNull().getTime()));
|
|
358
317
|
}
|
|
359
318
|
evaluateOperator(actual, op, expected) {
|
|
360
319
|
switch (op) {
|
|
361
320
|
case "eq": return actual === expected;
|
|
362
321
|
case "neq": return actual !== expected;
|
|
363
|
-
case "gt":
|
|
364
|
-
case "gte":
|
|
365
|
-
case "lt":
|
|
366
|
-
case "lte": return typeof actual === "number" && typeof expected === "number" &&
|
|
322
|
+
case "gt":
|
|
323
|
+
case "gte":
|
|
324
|
+
case "lt":
|
|
325
|
+
case "lte": return typeof actual === "number" && typeof expected === "number" && evaluateRelationalNumbers(actual, op, expected);
|
|
367
326
|
case "in": return Array.isArray(expected) && expected.includes(actual);
|
|
368
327
|
case "notIn": return Array.isArray(expected) && !expected.includes(actual);
|
|
369
|
-
case "isNull": return actual === null;
|
|
328
|
+
case "isNull": return actual === null || actual === void 0;
|
|
370
329
|
case "isNotNull": return actual !== null && actual !== void 0;
|
|
371
330
|
}
|
|
372
331
|
}
|
|
373
332
|
evaluateNumericRelationalNode(node, actual) {
|
|
374
333
|
const allowsNull = node.allowNull === true;
|
|
375
334
|
if (actual === void 0 || actual === null && !allowsNull) {
|
|
376
|
-
const
|
|
377
|
-
this.
|
|
378
|
-
level: "error",
|
|
379
|
-
tag: NULLISH_NUMERIC_OPERAND_NOT_ALLOWED_TAG,
|
|
380
|
-
message,
|
|
381
|
-
details: {
|
|
382
|
-
field: node.field,
|
|
383
|
-
op: node.op,
|
|
384
|
-
actual,
|
|
385
|
-
expected: node.value,
|
|
386
|
-
allowNull: allowsNull,
|
|
387
|
-
node
|
|
388
|
-
}
|
|
389
|
-
}));
|
|
390
|
-
return Result.err(message);
|
|
335
|
+
const resolved = actual === null ? "null" : "undefined";
|
|
336
|
+
return this.reportLeafError(NULLISH_NUMERIC_OPERAND_NOT_ALLOWED_TAG, `${NULLISH_NUMERIC_OPERAND_NOT_ALLOWED_TAG}: "${node.field}" resolved to ${resolved} for numeric operator "${node.op}"`, node, actual, { allowNull: allowsNull });
|
|
391
337
|
}
|
|
392
338
|
if (actual === null) return Result.ok(false);
|
|
393
|
-
if (typeof actual !== "number" || typeof node.value !== "number") return this.
|
|
339
|
+
if (typeof actual !== "number" || Number.isNaN(actual) || typeof node.value !== "number" || Number.isNaN(node.value)) return this.reportLeafError(INVALID_NUMERIC_OPERAND_TAG, `${INVALID_NUMERIC_OPERAND_TAG}: "${node.field}" with operator "${node.op}" requires numeric operands`, node, actual);
|
|
394
340
|
return Result.ok(this.evaluateOperator(actual, node.op, node.value));
|
|
395
341
|
}
|
|
396
342
|
evaluateLeafNode(node) {
|
|
397
343
|
const actualResult = PolicyContextPath.getOrAbsent(this.context, node.field);
|
|
398
344
|
if (actualResult.isErr()) {
|
|
345
|
+
const message = `MISSING_CONTEXT_FIELD: "${node.field}" not found in context`;
|
|
399
346
|
this.options.reporter.warn(this.buildReport({
|
|
400
347
|
level: "warn",
|
|
401
348
|
tag: "MISSING_CONTEXT_FIELD",
|
|
402
|
-
message
|
|
349
|
+
message,
|
|
403
350
|
details: {
|
|
404
351
|
field: node.field,
|
|
405
352
|
node
|
|
406
353
|
}
|
|
407
354
|
}));
|
|
408
|
-
return Result.err(
|
|
355
|
+
return Result.err(message);
|
|
409
356
|
}
|
|
410
357
|
try {
|
|
411
358
|
const actual = actualResult.getOrThrow();
|
|
@@ -414,7 +361,11 @@ var ConditionEvaluatorV1 = class ConditionEvaluatorV1 {
|
|
|
414
361
|
if (dateResult !== null) return dateResult;
|
|
415
362
|
return this.evaluateNumericRelationalNode(node, actual);
|
|
416
363
|
}
|
|
417
|
-
if ((node.op === "in" || node.op === "notIn") && !Array.isArray(node.value)) return this.
|
|
364
|
+
if ((node.op === "in" || node.op === "notIn") && !Array.isArray(node.value)) return this.reportLeafError(INVALID_SET_OPERAND_TAG, `${INVALID_SET_OPERAND_TAG}: "${node.field}" with operator "${node.op}" requires an array operand`, node, actual);
|
|
365
|
+
if (node.op === "eq" || node.op === "neq" || node.op === "in" || node.op === "notIn") {
|
|
366
|
+
if (containsInvalidDate(actual) || containsInvalidDate(node.value)) return this.reportLeafError(INVALID_DATE_OPERAND_TAG, ConditionEvaluatorV1.invalidDateOperandMessage(node), node, actual);
|
|
367
|
+
return Result.ok(this.evaluateOperator(normalizeDateOperand(actual), node.op, normalizeDateOperand(node.value)));
|
|
368
|
+
}
|
|
418
369
|
return Result.ok(this.evaluateOperator(actual, node.op, node.value));
|
|
419
370
|
} catch (error) {
|
|
420
371
|
return this.conditionEvalErr(node, error);
|
|
@@ -446,7 +397,7 @@ var ConditionEvaluatorV1 = class ConditionEvaluatorV1 {
|
|
|
446
397
|
});
|
|
447
398
|
}
|
|
448
399
|
if (ConditionEvaluatorV1.isAndNode(node)) {
|
|
449
|
-
if (node.and.length === 0) return Result.err(
|
|
400
|
+
if (node.and.length === 0) return Result.err(`${EMPTY_AND_CONDITION_TAG}: AND nodes must contain at least one child condition`);
|
|
450
401
|
let lastTracedChild = null;
|
|
451
402
|
for (const [index, child] of node.and.entries()) {
|
|
452
403
|
const childPath = `${path}.and[${index}]`;
|
|
@@ -482,7 +433,7 @@ var ConditionEvaluatorV1 = class ConditionEvaluatorV1 {
|
|
|
482
433
|
trace: tracedChild.trace
|
|
483
434
|
});
|
|
484
435
|
}
|
|
485
|
-
if (lastTrace === null) return Result.err(
|
|
436
|
+
if (lastTrace === null) return Result.err(`${EMPTY_OR_CONDITION_TAG}: OR nodes must contain at least one child condition`);
|
|
486
437
|
return Result.ok({
|
|
487
438
|
matched: false,
|
|
488
439
|
trace: lastTrace
|
|
@@ -531,6 +482,6 @@ var ConditionEvaluatorV1 = class ConditionEvaluatorV1 {
|
|
|
531
482
|
}
|
|
532
483
|
};
|
|
533
484
|
//#endregion
|
|
534
|
-
export {
|
|
485
|
+
export { CoreConfig as i, PolicyContextPath as n, coreConfig as r, ConditionEvaluatorV1 as t };
|
|
535
486
|
|
|
536
487
|
//# sourceMappingURL=condition-evaluator.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"condition-evaluator.js","names":["#initialReporter","#currentReporter","#bridgeToConditionReporter"],"sources":["../src/core/config/silent-policy-reporter.ts","../src/core/config/core-config.ts","../src/core/config/core-config.instance.ts","../src/core/policies/context/path.ts","../src/core/policies/utils/date.ts","../src/core/policies/engines/v1/condition-evaluator.ts"],"sourcesContent":["import type { PolicyReporter } from \"./policy-reporter.js\";\n\nexport class SilentPolicyReporter implements PolicyReporter {\n report(_event: Parameters<PolicyReporter[\"report\"]>[0]): void {}\n}\n","import type {\n ConditionEvaluationOptions,\n ConditionEvaluatorReporter,\n} from \"../policies/engines/condition-evaluator-reporter.js\";\nimport type { PolicyEvent, PolicyReporter } from \"./policy-reporter.js\";\nimport { SilentPolicyReporter } from \"./silent-policy-reporter.js\";\n\nexport interface CoreObservabilityConfig {\n readonly reporter?: PolicyReporter;\n}\n\nexport interface CoreConfigOptions {\n readonly observability?: CoreObservabilityConfig;\n}\n\nfunction reportSafely(\n policyReporter: PolicyReporter,\n event: PolicyEvent,\n): void {\n try {\n policyReporter.report(event);\n } catch {\n // Falhas de telemetria nao podem interromper o fluxo de dominio.\n }\n}\n\n/**\n * Centraliza a configuracao pura do core sem depender de implementacoes\n * concretas de logging, tracing ou report.\n */\nexport class CoreConfig {\n readonly #initialReporter: PolicyReporter;\n #currentReporter: PolicyReporter;\n\n constructor(options: CoreConfigOptions = {}) {\n const reporter =\n options.observability?.reporter ?? new SilentPolicyReporter();\n this.#initialReporter = reporter;\n this.#currentReporter = reporter;\n }\n\n configure(options: CoreConfigOptions): this {\n const reporter = options.observability?.reporter;\n if (reporter) {\n this.#currentReporter = reporter;\n }\n return this;\n }\n\n // Restores the reporter captured at construction time.\n reset(): this {\n this.#currentReporter = this.#initialReporter;\n return this;\n }\n\n getPolicyReporter(): PolicyReporter {\n return this.#currentReporter;\n }\n\n getConditionEvaluationOptions(\n engineVersion: number,\n ): ConditionEvaluationOptions {\n return {\n reporter: this.#bridgeToConditionReporter(this.#currentReporter),\n engineVersion,\n };\n }\n\n #bridgeToConditionReporter(\n policyReporter: PolicyReporter,\n ): ConditionEvaluatorReporter {\n return {\n warn(report) {\n reportSafely(policyReporter, {\n kind: \"condition-eval\",\n ...report,\n } satisfies PolicyEvent);\n },\n error(report) {\n reportSafely(policyReporter, {\n kind: \"condition-eval\",\n ...report,\n } satisfies PolicyEvent);\n },\n };\n }\n}\n","import { CoreConfig } from \"./core-config.js\";\nimport { SilentPolicyReporter } from \"./silent-policy-reporter.js\";\n\n/**\n * Shared instance for the application composition root.\n * Use `new CoreConfig()` for isolated runtimes, tests, or multi-tenant hosts.\n *\n * The default reporter is silent so the core has no runtime logging dependency.\n * Hosts can swap in their own `PolicyReporter` via\n * `coreConfig.configure({ observability: { reporter } })`.\n */\nexport const coreConfig = new CoreConfig({\n observability: { reporter: new SilentPolicyReporter() },\n});\n","/**\n * Utilities for reading/writing values at dot-separated paths\n * in plain objects, e.g. \"installment.dueDate\".\n */\n\nimport { Result } from \"../../result/result.js\";\n\nexport class PolicyContextPath {\n private static readonly FORBIDDEN_SEGMENTS = new Set([\n \"__proto__\",\n \"prototype\",\n \"constructor\",\n ]);\n\n private static resolve(\n obj: Record<string, unknown>,\n path: string,\n ): Result<\n {\n readonly found: boolean;\n readonly value: unknown;\n },\n string\n > {\n const segmentsResult = PolicyContextPath.parseSegments(path);\n if (segmentsResult.isErr()) {\n return Result.err(segmentsResult.errorOrNull()!);\n }\n\n const segments = segmentsResult.getOrNull()!;\n let current: unknown = obj;\n\n for (const segment of segments) {\n if (\n current === null ||\n current === undefined ||\n typeof current !== \"object\"\n ) {\n return Result.ok({ found: false, value: undefined });\n }\n\n const record = current as Record<string, unknown>;\n if (!Object.prototype.hasOwnProperty.call(record, segment)) {\n return Result.ok({ found: false, value: undefined });\n }\n\n current = record[segment];\n }\n\n return Result.ok({ found: true, value: current });\n }\n\n private static parseSegments(\n path: string,\n ): Result<readonly string[], string> {\n if (path.trim().length === 0) {\n return Result.err(\"Path cannot be empty\");\n }\n\n const segments = path.split(\".\");\n if (segments.some((segment) => segment.length === 0)) {\n return Result.err(`Path \"${path}\" contains an empty segment`);\n }\n\n const forbiddenSegment = segments.find((segment) =>\n PolicyContextPath.FORBIDDEN_SEGMENTS.has(segment),\n );\n if (forbiddenSegment !== undefined) {\n return Result.err(\n `Path \"${path}\" contains forbidden segment \"${forbiddenSegment}\"`,\n );\n }\n\n return Result.ok(segments);\n }\n\n private static isPlainRecord(\n value: unknown,\n ): value is Record<string, unknown> {\n if (\n typeof value !== \"object\" ||\n value === null ||\n Array.isArray(value)\n ) {\n return false;\n }\n\n const prototype = Object.getPrototypeOf(value);\n return prototype === Object.prototype || prototype === null;\n }\n\n static getOrAbsent(\n obj: Record<string, unknown>,\n path: string,\n ): Result<unknown, \"absent\"> {\n const resolvedPath = PolicyContextPath.resolve(obj, path);\n if (resolvedPath.isErr()) {\n return Result.err(\"absent\");\n }\n\n const { found, value } = resolvedPath.getOrNull()!;\n if (!found) {\n return Result.err(\"absent\");\n }\n\n return Result.ok(value);\n }\n\n static has(obj: Record<string, unknown>, path: string): boolean {\n const resolvedPath = PolicyContextPath.resolve(obj, path);\n if (resolvedPath.isErr()) {\n return false;\n }\n\n return resolvedPath.getOrNull()!.found;\n }\n\n static set(\n obj: Record<string, unknown>,\n path: string,\n value: unknown,\n ): Result<void, string> {\n const segmentsResult = PolicyContextPath.parseSegments(path);\n if (segmentsResult.isErr()) {\n return Result.err(segmentsResult.errorOrNull()!);\n }\n\n const segments = segmentsResult.getOrNull()!;\n let current: Record<string, unknown> = obj;\n\n for (let i = 0; i < segments.length - 1; i++) {\n const seg = segments[i];\n const next = current[seg];\n\n if (next === undefined) {\n const container = Object.create(null) as Record<\n string,\n unknown\n >;\n current[seg] = container;\n current = container;\n continue;\n }\n\n if (!PolicyContextPath.isPlainRecord(next)) {\n return Result.err(\n `Cannot create nested path \"${path}\" because \"${segments\n .slice(0, i + 1)\n .join(\".\")}\" already contains a non-plain object`,\n );\n }\n\n current = next;\n }\n\n current[segments[segments.length - 1]] = value;\n return Result.ok(undefined);\n }\n}\n","import { isValidDate } from \"../../shared/temporal-guards.js\";\n\nexport class PolicyDateUtils {\n static isValid(value: Date): boolean {\n return isValidDate(value);\n }\n}\n","import { PolicyContextPath } from \"../../context/index.js\";\nimport { PolicyDateUtils } from \"../../utils/index.js\";\nimport { Result } from \"../../../result/result.js\";\n\nimport type {\n ConditionAndNode,\n ConditionLeafNode,\n ConditionNode,\n ConditionNotNode,\n ConditionOp,\n ConditionOrNode,\n} from \"./condition-types.js\";\nimport type {\n ConditionEvaluationOptions,\n ConditionEvaluationReport,\n} from \"../condition-evaluator-reporter.js\";\nimport type { PolicyContext } from \"../gate-types.js\";\n\nconst CONDITION_EVAL_THROWN_TAG = \"CONDITION_EVAL_THREW\";\nconst NULLISH_NUMERIC_OPERAND_NOT_ALLOWED_TAG =\n \"NULLISH_NUMERIC_OPERAND_NOT_ALLOWED\";\nconst NULLISH_DATE_OPERAND_NOT_ALLOWED_TAG = \"NULLISH_DATE_OPERAND_NOT_ALLOWED\";\nconst INVALID_DATE_OPERAND_TAG = \"INVALID_DATE_OPERAND\";\nconst INVALID_NUMERIC_OPERAND_TAG = \"INVALID_NUMERIC_OPERAND\";\nconst INVALID_SET_OPERAND_TAG = \"INVALID_SET_OPERAND\";\nconst EMPTY_OR_CONDITION_TAG = \"EMPTY_OR_CONDITION\";\nconst EMPTY_AND_CONDITION_TAG = \"EMPTY_AND_CONDITION\";\nconst ISO_8601_UTC_DATE_PATTERN =\n /^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{3}Z$/;\n\nexport interface ConditionEvaluationTrace {\n readonly conditionPath: string;\n readonly decisiveNode: ConditionNode;\n readonly lastEvaluatedLeaf: ConditionLeafNode;\n readonly lastEvaluatedLeafPath: string;\n readonly lastEvaluatedLeafResult: boolean;\n}\n\nexport interface TracedConditionEvaluation {\n readonly matched: boolean;\n readonly trace: ConditionEvaluationTrace;\n}\n\ntype RelationalOperator = Extract<ConditionOp, \"gt\" | \"gte\" | \"lt\" | \"lte\">;\n\nexport class ConditionEvaluatorV1 {\n constructor(\n private readonly context: PolicyContext,\n private readonly options: ConditionEvaluationOptions,\n ) {}\n\n private static isLeafNode(node: ConditionNode): node is ConditionLeafNode {\n return \"field\" in node && \"op\" in node;\n }\n\n private static isAndNode(node: ConditionNode): node is ConditionAndNode {\n return \"and\" in node;\n }\n\n private static isOrNode(node: ConditionNode): node is ConditionOrNode {\n return \"or\" in node;\n }\n\n private static isNotNode(node: ConditionNode): node is ConditionNotNode {\n return \"not\" in node;\n }\n\n private static isRelationalOperator(\n op: ConditionOp,\n ): op is RelationalOperator {\n return op === \"gt\" || op === \"gte\" || op === \"lt\" || op === \"lte\";\n }\n\n private static describeError(error: unknown): {\n name: string;\n message: string;\n } {\n if (error instanceof Error) {\n return {\n name: error.name,\n message: error.message,\n };\n }\n\n return {\n name: \"NonErrorThrown\",\n message: String(error),\n };\n }\n\n private static buildNullishNumericOperandMessage(\n node: ConditionLeafNode,\n actual: null | undefined,\n ): string {\n const resolvedValue = actual === null ? \"null\" : \"undefined\";\n\n return `${NULLISH_NUMERIC_OPERAND_NOT_ALLOWED_TAG}: \"${node.field}\" resolved to ${resolvedValue} for numeric operator \"${node.op}\"`;\n }\n\n private static buildNullishDateOperandMessage(\n node: ConditionLeafNode,\n actual: null | undefined,\n ): string {\n const resolvedValue = actual === null ? \"null\" : \"undefined\";\n\n return `${NULLISH_DATE_OPERAND_NOT_ALLOWED_TAG}: \"${node.field}\" resolved to ${resolvedValue} for date comparison operator \"${node.op}\"`;\n }\n\n private static buildInvalidDateOperandMessage(\n node: ConditionLeafNode,\n ): string {\n return `${INVALID_DATE_OPERAND_TAG}: \"${node.field}\" with operator \"${node.op}\" requires Date or ISO 8601 UTC string operands`;\n }\n\n private static buildInvalidNumericOperandMessage(\n node: ConditionLeafNode,\n ): string {\n return `${INVALID_NUMERIC_OPERAND_TAG}: \"${node.field}\" with operator \"${node.op}\" requires numeric operands`;\n }\n\n private static buildInvalidSetOperandMessage(\n node: ConditionLeafNode,\n ): string {\n return `${INVALID_SET_OPERAND_TAG}: \"${node.field}\" with operator \"${node.op}\" requires an array operand`;\n }\n\n private static buildEmptyOrConditionMessage(): string {\n return `${EMPTY_OR_CONDITION_TAG}: OR nodes must contain at least one child condition`;\n }\n\n private static buildEmptyAndConditionMessage(): string {\n return `${EMPTY_AND_CONDITION_TAG}: AND nodes must contain at least one child condition`;\n }\n\n private static parseComparableDate(\n value: unknown,\n ): Result<Date, string> | null {\n if (value instanceof Date) {\n if (!PolicyDateUtils.isValid(value)) {\n return Result.err(\"Invalid Date instance\");\n }\n\n return Result.ok(value);\n }\n\n if (\n typeof value !== \"string\" ||\n !ISO_8601_UTC_DATE_PATTERN.test(value)\n ) {\n return null;\n }\n\n const parsed = new Date(value);\n if (\n !PolicyDateUtils.isValid(parsed) ||\n parsed.toISOString() !== value\n ) {\n return Result.err(\"Invalid ISO 8601 UTC date string\");\n }\n\n return Result.ok(parsed);\n }\n\n private static evaluateRelationalNumbers(\n actual: number,\n op: RelationalOperator,\n expected: number,\n ): boolean {\n switch (op) {\n case \"gt\":\n return actual > expected;\n case \"gte\":\n return actual >= expected;\n case \"lt\":\n return actual < expected;\n case \"lte\":\n return actual <= expected;\n }\n }\n\n private buildReport(params: {\n readonly level: ConditionEvaluationReport[\"level\"];\n readonly tag: ConditionEvaluationReport[\"tag\"];\n readonly message: string;\n readonly details: Readonly<Record<string, unknown>>;\n }): ConditionEvaluationReport {\n return {\n occurredAt: new Date(),\n level: params.level,\n tag: params.tag,\n message: params.message,\n engineVersion: this.options.engineVersion,\n details: params.details,\n };\n }\n\n private conditionEvalErr<TValue>(\n node: ConditionNode,\n error: unknown,\n ): Result<TValue, string> {\n const cause = ConditionEvaluatorV1.describeError(error);\n const message = `${CONDITION_EVAL_THROWN_TAG}: ${cause.name}: ${cause.message}`;\n\n this.options.reporter.error(\n this.buildReport({\n level: \"error\",\n tag: CONDITION_EVAL_THROWN_TAG,\n message,\n details: { node, cause },\n }),\n );\n\n return Result.err(message);\n }\n\n private reportDateOperandError(\n node: ConditionLeafNode,\n actual: unknown,\n ): Result<boolean, string> {\n const message =\n ConditionEvaluatorV1.buildInvalidDateOperandMessage(node);\n\n this.options.reporter.error(\n this.buildReport({\n level: \"error\",\n tag: INVALID_DATE_OPERAND_TAG,\n message,\n details: {\n field: node.field,\n op: node.op,\n actual,\n expected: node.value,\n node,\n },\n }),\n );\n\n return Result.err(message);\n }\n\n private reportInvalidNumericOperand(\n node: ConditionLeafNode,\n actual: unknown,\n ): Result<boolean, string> {\n const message =\n ConditionEvaluatorV1.buildInvalidNumericOperandMessage(node);\n\n this.options.reporter.error(\n this.buildReport({\n level: \"error\",\n tag: INVALID_NUMERIC_OPERAND_TAG,\n message,\n details: {\n field: node.field,\n op: node.op,\n actual,\n expected: node.value,\n node,\n },\n }),\n );\n\n return Result.err(message);\n }\n\n private reportInvalidSetOperand(\n node: ConditionLeafNode,\n actual: unknown,\n ): Result<boolean, string> {\n const message =\n ConditionEvaluatorV1.buildInvalidSetOperandMessage(node);\n\n this.options.reporter.error(\n this.buildReport({\n level: \"error\",\n tag: INVALID_SET_OPERAND_TAG,\n message,\n details: {\n field: node.field,\n op: node.op,\n actual,\n expected: node.value,\n node,\n },\n }),\n );\n\n return Result.err(message);\n }\n\n private evaluateDateRelationalNode(\n node: ConditionLeafNode,\n actual: unknown,\n ): Result<boolean, string> | null {\n if (!ConditionEvaluatorV1.isRelationalOperator(node.op)) {\n return null;\n }\n\n const actualDateResult =\n ConditionEvaluatorV1.parseComparableDate(actual);\n const expectedDateResult = ConditionEvaluatorV1.parseComparableDate(\n node.value,\n );\n\n if (actualDateResult === null && expectedDateResult === null) {\n return null;\n }\n\n const allowsNull = node.allowNull === true;\n\n if (actual === null) {\n if (allowsNull) {\n return Result.ok(false);\n }\n\n const message = ConditionEvaluatorV1.buildNullishDateOperandMessage(\n node,\n actual,\n );\n this.options.reporter.error(\n this.buildReport({\n level: \"error\",\n tag: NULLISH_DATE_OPERAND_NOT_ALLOWED_TAG,\n message,\n details: {\n field: node.field,\n op: node.op,\n actual,\n expected: node.value,\n allowNull: allowsNull,\n node,\n },\n }),\n );\n\n return Result.err(message);\n }\n\n if (actual === undefined) {\n const message = ConditionEvaluatorV1.buildNullishDateOperandMessage(\n node,\n actual,\n );\n this.options.reporter.error(\n this.buildReport({\n level: \"error\",\n tag: NULLISH_DATE_OPERAND_NOT_ALLOWED_TAG,\n message,\n details: {\n field: node.field,\n op: node.op,\n actual,\n expected: node.value,\n allowNull: allowsNull,\n node,\n },\n }),\n );\n\n return Result.err(message);\n }\n\n if (\n actualDateResult === null ||\n actualDateResult.isErr() ||\n expectedDateResult === null ||\n expectedDateResult.isErr()\n ) {\n return this.reportDateOperandError(node, actual);\n }\n\n return Result.ok(\n ConditionEvaluatorV1.evaluateRelationalNumbers(\n actualDateResult.getOrNull()!.getTime(),\n node.op,\n expectedDateResult.getOrNull()!.getTime(),\n ),\n );\n }\n\n private evaluateOperator(\n actual: unknown,\n op: ConditionOp,\n expected: unknown,\n ): boolean {\n switch (op) {\n case \"eq\":\n return actual === expected;\n case \"neq\":\n return actual !== expected;\n case \"gt\":\n return (\n typeof actual === \"number\" &&\n typeof expected === \"number\" &&\n ConditionEvaluatorV1.evaluateRelationalNumbers(\n actual,\n op,\n expected,\n )\n );\n case \"gte\":\n return (\n typeof actual === \"number\" &&\n typeof expected === \"number\" &&\n ConditionEvaluatorV1.evaluateRelationalNumbers(\n actual,\n op,\n expected,\n )\n );\n case \"lt\":\n return (\n typeof actual === \"number\" &&\n typeof expected === \"number\" &&\n ConditionEvaluatorV1.evaluateRelationalNumbers(\n actual,\n op,\n expected,\n )\n );\n case \"lte\":\n return (\n typeof actual === \"number\" &&\n typeof expected === \"number\" &&\n ConditionEvaluatorV1.evaluateRelationalNumbers(\n actual,\n op,\n expected,\n )\n );\n case \"in\":\n return Array.isArray(expected) && expected.includes(actual);\n case \"notIn\":\n return Array.isArray(expected) && !expected.includes(actual);\n case \"isNull\":\n return actual === null;\n case \"isNotNull\":\n return actual !== null && actual !== undefined;\n }\n }\n\n private evaluateNumericRelationalNode(\n node: ConditionLeafNode,\n actual: unknown,\n ): Result<boolean, string> {\n const allowsNull = node.allowNull === true;\n if (actual === undefined || (actual === null && !allowsNull)) {\n const message =\n ConditionEvaluatorV1.buildNullishNumericOperandMessage(\n node,\n actual as null | undefined,\n );\n\n this.options.reporter.error(\n this.buildReport({\n level: \"error\",\n tag: NULLISH_NUMERIC_OPERAND_NOT_ALLOWED_TAG,\n message,\n details: {\n field: node.field,\n op: node.op,\n actual,\n expected: node.value,\n allowNull: allowsNull,\n node,\n },\n }),\n );\n\n return Result.err(message);\n }\n\n // null + allowNull: a relational comparison against a missing value\n // never matches.\n if (actual === null) {\n return Result.ok(false);\n }\n\n // Both operands must be numbers. A present but wrong-typed operand is a\n // context/configuration error, surfaced like the date path instead of\n // silently collapsing to \"no match\".\n if (typeof actual !== \"number\" || typeof node.value !== \"number\") {\n return this.reportInvalidNumericOperand(node, actual);\n }\n\n return Result.ok(this.evaluateOperator(actual, node.op, node.value));\n }\n\n private evaluateLeafNode(node: ConditionLeafNode): Result<boolean, string> {\n const actualResult = PolicyContextPath.getOrAbsent(\n this.context,\n node.field,\n );\n if (actualResult.isErr()) {\n this.options.reporter.warn(\n this.buildReport({\n level: \"warn\",\n tag: \"MISSING_CONTEXT_FIELD\",\n message: `MISSING_CONTEXT_FIELD: \"${node.field}\" not found in context`,\n details: { field: node.field, node },\n }),\n );\n\n return Result.err(\n `MISSING_CONTEXT_FIELD: \"${node.field}\" not found in context`,\n );\n }\n\n try {\n const actual = actualResult.getOrThrow();\n if (ConditionEvaluatorV1.isRelationalOperator(node.op)) {\n const dateResult = this.evaluateDateRelationalNode(\n node,\n actual,\n );\n if (dateResult !== null) {\n return dateResult;\n }\n\n return this.evaluateNumericRelationalNode(node, actual);\n }\n\n if (\n (node.op === \"in\" || node.op === \"notIn\") &&\n !Array.isArray(node.value)\n ) {\n return this.reportInvalidSetOperand(node, actual);\n }\n\n return Result.ok(\n this.evaluateOperator(actual, node.op, node.value),\n );\n } catch (error) {\n return this.conditionEvalErr(node, error);\n }\n }\n\n private buildTrace(params: {\n readonly conditionPath: string;\n readonly decisiveNode: ConditionNode;\n readonly lastEvaluatedLeaf: ConditionLeafNode;\n readonly lastEvaluatedLeafPath: string;\n readonly lastEvaluatedLeafResult: boolean;\n }): ConditionEvaluationTrace {\n return {\n conditionPath: params.conditionPath,\n decisiveNode: params.decisiveNode,\n lastEvaluatedLeaf: params.lastEvaluatedLeaf,\n lastEvaluatedLeafPath: params.lastEvaluatedLeafPath,\n lastEvaluatedLeafResult: params.lastEvaluatedLeafResult,\n };\n }\n\n private evaluateWithTraceInternal(\n node: ConditionNode,\n path: string,\n ): Result<TracedConditionEvaluation, string> {\n if (ConditionEvaluatorV1.isLeafNode(node)) {\n const leafResult = this.evaluateLeafNode(node);\n if (leafResult.isErr()) {\n return Result.err(leafResult.errorOrNull()!);\n }\n\n const matched = leafResult.getOrNull()!;\n return Result.ok({\n matched,\n trace: this.buildTrace({\n conditionPath: path,\n decisiveNode: node,\n lastEvaluatedLeaf: node,\n lastEvaluatedLeafPath: path,\n lastEvaluatedLeafResult: matched,\n }),\n });\n }\n\n if (ConditionEvaluatorV1.isAndNode(node)) {\n if (node.and.length === 0) {\n return Result.err(\n ConditionEvaluatorV1.buildEmptyAndConditionMessage(),\n );\n }\n\n let lastTracedChild: TracedConditionEvaluation | null = null;\n\n for (const [index, child] of node.and.entries()) {\n const childPath = `${path}.and[${index}]`;\n const childResult = this.evaluateWithTraceInternal(\n child,\n childPath,\n );\n if (childResult.isErr()) {\n return Result.err(childResult.errorOrNull()!);\n }\n\n const tracedChild = childResult.getOrNull()!;\n lastTracedChild = tracedChild;\n if (!tracedChild.matched) {\n return Result.ok({\n matched: false,\n trace: this.buildTrace({\n conditionPath: childPath,\n decisiveNode: child,\n lastEvaluatedLeaf:\n tracedChild.trace.lastEvaluatedLeaf,\n lastEvaluatedLeafPath:\n tracedChild.trace.lastEvaluatedLeafPath,\n lastEvaluatedLeafResult:\n tracedChild.trace.lastEvaluatedLeafResult,\n }),\n });\n }\n }\n\n return Result.ok({\n matched: true,\n trace: lastTracedChild!.trace,\n });\n }\n\n if (ConditionEvaluatorV1.isOrNode(node)) {\n let lastTrace: ConditionEvaluationTrace | null = null;\n\n for (const [index, child] of node.or.entries()) {\n const childResult = this.evaluateWithTraceInternal(\n child,\n `${path}.or[${index}]`,\n );\n if (childResult.isErr()) {\n return Result.err(childResult.errorOrNull()!);\n }\n\n const tracedChild = childResult.getOrNull()!;\n lastTrace = tracedChild.trace;\n if (tracedChild.matched) {\n return Result.ok({\n matched: true,\n trace: tracedChild.trace,\n });\n }\n }\n\n if (lastTrace === null) {\n return Result.err(\n ConditionEvaluatorV1.buildEmptyOrConditionMessage(),\n );\n }\n\n return Result.ok({ matched: false, trace: lastTrace! });\n }\n\n if (ConditionEvaluatorV1.isNotNode(node)) {\n const childPath = `${path}.not`;\n const childResult = this.evaluateWithTraceInternal(\n node.not,\n childPath,\n );\n if (childResult.isErr()) {\n return Result.err(childResult.errorOrNull()!);\n }\n\n const tracedChild = childResult.getOrNull()!;\n return Result.ok({\n matched: !tracedChild.matched,\n trace: this.buildTrace({\n conditionPath: path,\n decisiveNode: node,\n lastEvaluatedLeaf: tracedChild.trace.lastEvaluatedLeaf,\n lastEvaluatedLeafPath:\n tracedChild.trace.lastEvaluatedLeafPath,\n lastEvaluatedLeafResult:\n tracedChild.trace.lastEvaluatedLeafResult,\n }),\n });\n }\n\n return this.conditionEvalErr(\n node,\n new TypeError(\"Invalid condition node shape\"),\n );\n }\n\n evaluate(node: ConditionNode): Result<boolean, string> {\n try {\n const result = this.evaluateWithTraceInternal(node, \"$\");\n if (result.isErr()) {\n return Result.err(result.errorOrNull()!);\n }\n\n return Result.ok(result.getOrNull()!.matched);\n } catch (error) {\n return this.conditionEvalErr(node, error);\n }\n }\n\n evaluateWithTrace(\n node: ConditionNode,\n ): Result<TracedConditionEvaluation, string> {\n try {\n return this.evaluateWithTraceInternal(node, \"$\");\n } catch (error) {\n return this.conditionEvalErr(node, error);\n }\n }\n\n static extractFields(node: ConditionNode): string[] {\n if (ConditionEvaluatorV1.isLeafNode(node)) {\n return [node.field];\n }\n\n if (ConditionEvaluatorV1.isAndNode(node)) {\n return node.and.flatMap((child) =>\n ConditionEvaluatorV1.extractFields(child),\n );\n }\n\n if (ConditionEvaluatorV1.isOrNode(node)) {\n return node.or.flatMap((child) =>\n ConditionEvaluatorV1.extractFields(child),\n );\n }\n\n if (ConditionEvaluatorV1.isNotNode(node)) {\n return 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GACZ,OAAO,KAAK,iBAAiB,MAAM,KAAK;EAC5C;CACJ;CAEA,OAAO,cAAc,MAA+B;EAChD,IAAI,qBAAqB,WAAW,IAAI,GACpC,OAAO,CAAC,KAAK,KAAK;EAGtB,IAAI,qBAAqB,UAAU,IAAI,GACnC,OAAO,KAAK,IAAI,SAAS,UACrB,qBAAqB,cAAc,KAAK,CAC5C;EAGJ,IAAI,qBAAqB,SAAS,IAAI,GAClC,OAAO,KAAK,GAAG,SAAS,UACpB,qBAAqB,cAAc,KAAK,CAC5C;EAGJ,IAAI,qBAAqB,UAAU,IAAI,GACnC,OAAO,qBAAqB,cAAc,KAAK,GAAG;EAGtD,OAAO,CAAC;CACZ;AACJ"}
|
|
1
|
+
{"version":3,"file":"condition-evaluator.js","names":["#initialReporter","#currentReporter","#bridgeToConditionReporter"],"sources":["../src/core/config/silent-policy-reporter.ts","../src/core/config/core-config.ts","../src/core/config/core-config.instance.ts","../src/core/policies/context/path.ts","../src/core/policies/utils/date.ts","../src/core/policies/engines/v1/condition-date-operands.ts","../src/core/policies/engines/v1/condition-evaluator.ts"],"sourcesContent":["import type { PolicyReporter } from \"./policy-reporter.js\";\n\nexport class SilentPolicyReporter implements PolicyReporter {\n report(_event: Parameters<PolicyReporter[\"report\"]>[0]): void {}\n}\n","import type {\n ConditionEvaluationOptions,\n ConditionEvaluationReport,\n ConditionEvaluationReportLevel,\n ConditionEvaluatorReporter,\n} from \"../policies/engines/condition-evaluator-reporter.js\";\nimport type { PolicyEvent, PolicyReporter } from \"./policy-reporter.js\";\nimport { SilentPolicyReporter } from \"./silent-policy-reporter.js\";\n\nexport interface CoreObservabilityConfig {\n readonly reporter?: PolicyReporter;\n}\n\nexport interface CoreConfigOptions {\n // `observability` is today's only section. Future core config (settings,\n // feature flags) joins here as sibling keys — that umbrella is why the\n // reporter is nested under `observability` instead of living at the root.\n readonly observability?: CoreObservabilityConfig;\n}\n\n/** Reports an event without letting a throwing reporter abort the caller. */\nfunction safeReport(policyReporter: PolicyReporter, event: PolicyEvent): void {\n try {\n policyReporter.report(event);\n } catch {\n // Telemetry failures must never interrupt the domain flow.\n }\n}\n\n/**\n * The core's config namespace. Today it holds a single section —\n * `observability` — whose whole job is to decide *where policy telemetry goes*\n * while guaranteeing telemetry is best-effort (a throwing reporter can never\n * abort a domain flow). App config (env, settings, feature flags) is\n * deliberately absent for now: when the core needs it, it joins here as a\n * sibling section rather than a new module — which is why this is `config`,\n * not `observability`. It holds the active {@link PolicyReporter} (silent by\n * default, so the core carries no logging dependency), bridges it to the\n * engines' {@link ConditionEvaluatorReporter}, and offers `reportSafely` as\n * the single guarded emit path shared with {@link PolicyService}.\n */\nexport class CoreConfig {\n readonly #initialReporter: PolicyReporter;\n #currentReporter: PolicyReporter;\n\n constructor(options: CoreConfigOptions = {}) {\n const reporter =\n options.observability?.reporter ?? new SilentPolicyReporter();\n this.#initialReporter = reporter;\n this.#currentReporter = reporter;\n }\n\n /**\n * Swaps the active reporter. Pass `observability.reporter` to enable\n * telemetry, or set it explicitly to `undefined` to go silent again.\n * Omitting `observability` (or its `reporter` key) is a no-op.\n */\n configure(options: CoreConfigOptions): this {\n const observability = options.observability;\n if (observability && \"reporter\" in observability) {\n this.#currentReporter =\n observability.reporter ?? new SilentPolicyReporter();\n }\n return this;\n }\n\n // Restores the reporter captured at construction time — which is silent\n // only if this instance was built without one.\n reset(): this {\n this.#currentReporter = this.#initialReporter;\n return this;\n }\n\n /** Emits a policy event through the active reporter, best-effort. */\n reportSafely(event: PolicyEvent): void {\n safeReport(this.#currentReporter, event);\n }\n\n getConditionEvaluationOptions(\n engineVersion: number,\n ): ConditionEvaluationOptions {\n return {\n reporter: this.#bridgeToConditionReporter(this.#currentReporter),\n engineVersion,\n };\n }\n\n #bridgeToConditionReporter(\n policyReporter: PolicyReporter,\n ): ConditionEvaluatorReporter {\n // Capture the reporter now so a mid-evaluation reconfigure never splits\n // a single evaluation's reports across two reporters (intentional).\n const emit = (\n level: ConditionEvaluationReportLevel,\n report: ConditionEvaluationReport,\n ): void => {\n safeReport(policyReporter, {\n kind: \"condition-eval\",\n ...report,\n level,\n });\n };\n return {\n warn: (report) => emit(\"warn\", report),\n error: (report) => emit(\"error\", report),\n };\n }\n}\n","import { CoreConfig } from \"./core-config.js\";\nimport { SilentPolicyReporter } from \"./silent-policy-reporter.js\";\n\n/**\n * Shared instance for the application composition root.\n * Use `new CoreConfig()` for isolated runtimes, tests, or multi-tenant hosts.\n *\n * The default reporter is silent so the core has no runtime logging dependency.\n * Hosts can swap in their own `PolicyReporter` via\n * `coreConfig.configure({ observability: { reporter } })`.\n */\nexport const coreConfig = new CoreConfig({\n observability: { reporter: new SilentPolicyReporter() },\n});\n","/**\n * Utilities for reading/writing values at dot-separated paths\n * in plain objects, e.g. \"installment.dueDate\".\n */\n\nimport { Result } from \"../../result/result.js\";\n\nexport class PolicyContextPath {\n private static readonly FORBIDDEN_SEGMENTS = new Set([\n \"__proto__\",\n \"prototype\",\n \"constructor\",\n ]);\n\n private static resolve(\n obj: Record<string, unknown>,\n path: string,\n ): Result<\n {\n readonly found: boolean;\n readonly value: unknown;\n },\n string\n > {\n const segmentsResult = PolicyContextPath.parseSegments(path);\n if (segmentsResult.isErr()) {\n return Result.err(segmentsResult.errorOrNull()!);\n }\n\n const segments = segmentsResult.getOrNull()!;\n let current: unknown = obj;\n\n for (const segment of segments) {\n if (\n current === null ||\n current === undefined ||\n typeof current !== \"object\"\n ) {\n return Result.ok({ found: false, value: undefined });\n }\n\n const record = current as Record<string, unknown>;\n if (!Object.prototype.hasOwnProperty.call(record, segment)) {\n return Result.ok({ found: false, value: undefined });\n }\n\n current = record[segment];\n }\n\n return Result.ok({ found: true, value: current });\n }\n\n private static parseSegments(\n path: string,\n ): Result<readonly string[], string> {\n if (path.trim().length === 0) {\n return Result.err(\"Path cannot be empty\");\n }\n\n const segments = path.split(\".\");\n if (segments.some((segment) => segment.length === 0)) {\n return Result.err(`Path \"${path}\" contains an empty segment`);\n }\n\n const forbiddenSegment = segments.find((segment) =>\n PolicyContextPath.FORBIDDEN_SEGMENTS.has(segment),\n );\n if (forbiddenSegment !== undefined) {\n return Result.err(\n `Path \"${path}\" contains forbidden segment \"${forbiddenSegment}\"`,\n );\n }\n\n return Result.ok(segments);\n }\n\n private static isPlainRecord(\n value: unknown,\n ): value is Record<string, unknown> {\n if (\n typeof value !== \"object\" ||\n value === null ||\n Array.isArray(value)\n ) {\n return false;\n }\n\n const prototype = Object.getPrototypeOf(value);\n return prototype === Object.prototype || prototype === null;\n }\n\n static getOrAbsent(\n obj: Record<string, unknown>,\n path: string,\n ): Result<unknown, \"absent\"> {\n const resolvedPath = PolicyContextPath.resolve(obj, path);\n if (resolvedPath.isErr()) {\n return Result.err(\"absent\");\n }\n\n const { found, value } = resolvedPath.getOrNull()!;\n if (!found) {\n return Result.err(\"absent\");\n }\n\n return Result.ok(value);\n }\n\n static has(obj: Record<string, unknown>, path: string): boolean {\n const resolvedPath = PolicyContextPath.resolve(obj, path);\n if (resolvedPath.isErr()) {\n return false;\n }\n\n return resolvedPath.getOrNull()!.found;\n }\n\n static set(\n obj: Record<string, unknown>,\n path: string,\n value: unknown,\n ): Result<void, string> {\n const segmentsResult = PolicyContextPath.parseSegments(path);\n if (segmentsResult.isErr()) {\n return Result.err(segmentsResult.errorOrNull()!);\n }\n\n const segments = segmentsResult.getOrNull()!;\n let current: Record<string, unknown> = obj;\n\n for (let i = 0; i < segments.length - 1; i++) {\n const seg = segments[i];\n const next = current[seg];\n\n if (next === undefined) {\n const container = Object.create(null) as Record<\n string,\n unknown\n >;\n current[seg] = container;\n current = container;\n continue;\n }\n\n if (!PolicyContextPath.isPlainRecord(next)) {\n return Result.err(\n `Cannot create nested path \"${path}\" because \"${segments\n .slice(0, i + 1)\n .join(\".\")}\" already contains a non-plain object`,\n );\n }\n\n current = next;\n }\n\n current[segments[segments.length - 1]] = value;\n return Result.ok(undefined);\n }\n}\n","import { isValidDate } from \"../../shared/temporal-guards.js\";\n\nexport class PolicyDateUtils {\n static isValid(value: Date): boolean {\n return isValidDate(value);\n }\n}\n","// Pure helpers for treating condition operands as instants. Extracted from\n// condition-evaluator.ts to keep that file under the kit's size limit and to\n// isolate the (zod-free) date logic the ./abac subpath re-uses. Import the date\n// util directly (not the utils barrel): the barrel re-exports PolicyHashing,\n// whose node:crypto import would needlessly drag a Node-only API into the\n// zod-free ./abac subpath.\nimport { PolicyDateUtils } from \"../../utils/date.js\";\nimport { Result } from \"../../../result/result.js\";\n\nimport type { ConditionOp } from \"./condition-types.js\";\n\nexport type RelationalOperator = Extract<\n ConditionOp,\n \"gt\" | \"gte\" | \"lt\" | \"lte\"\n>;\n\n/**\n * The one instant format condition date operands may use. Strict on purpose\n * (UTC, milliseconds) so comparisons are unambiguous across time zones — and\n * so a malformed operand fails loudly instead of comparing wrong.\n */\nexport const CANONICAL_UTC_DATE_FORMAT = \"YYYY-MM-DDTHH:mm:ss.SSSZ\";\n\nconst ISO_8601_UTC_DATE_PATTERN =\n /^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{3}Z$/;\n// A value that is clearly meant to be a date-time but isn't canonical UTC\n// (missing milliseconds, a non-UTC offset, a space separator…). Lets the\n// caller report a \"malformed date\" error instead of a misleading \"not a\n// number\" one.\nconst ISO_8601_DATE_LIKE_PATTERN = /^\\d{4}-\\d{2}-\\d{2}[T ]\\d{2}:\\d{2}/;\n\n/**\n * Parses a value used as a date operand:\n * - `Result.ok(Date)` for a valid Date or a canonical ISO-8601 UTC string;\n * - `Result.err` when it is date-shaped but malformed (invalid Date, or a\n * date-like string that isn't canonical UTC) — a configuration error worth\n * surfacing rather than silently treating as \"not a date\";\n * - `null` when the value isn't date-shaped at all, so the caller can fall\n * through to a numeric comparison.\n */\nexport function parseComparableDate(\n value: unknown,\n): Result<Date, string> | null {\n if (value instanceof Date) {\n return PolicyDateUtils.isValid(value)\n ? Result.ok(value)\n : Result.err(\"Invalid Date instance\");\n }\n\n if (typeof value !== \"string\") {\n return null;\n }\n\n if (ISO_8601_UTC_DATE_PATTERN.test(value)) {\n const parsed = new Date(value);\n if (\n !PolicyDateUtils.isValid(parsed) ||\n parsed.toISOString() !== value\n ) {\n return Result.err(\"Invalid ISO 8601 UTC date string\");\n }\n\n return Result.ok(parsed);\n }\n\n if (ISO_8601_DATE_LIKE_PATTERN.test(value)) {\n return Result.err(\n `date operand must be canonical ISO 8601 UTC (${CANONICAL_UTC_DATE_FORMAT})`,\n );\n }\n\n return null;\n}\n\nexport function evaluateRelationalNumbers(\n actual: number,\n op: RelationalOperator,\n expected: number,\n): boolean {\n switch (op) {\n case \"gt\":\n return actual > expected;\n case \"gte\":\n return actual >= expected;\n case \"lt\":\n return actual < expected;\n case \"lte\":\n return actual <= expected;\n }\n}\n\nexport function containsInvalidDate(value: unknown): boolean {\n if (value instanceof Date) {\n return !PolicyDateUtils.isValid(value);\n }\n if (Array.isArray(value)) {\n return value.some((item) => containsInvalidDate(item));\n }\n return false;\n}\n\n// Valid Dates become their ISO string so equality/set operators compare\n// instants instead of references; every other value passes through.\nexport function normalizeDateOperand(value: unknown): unknown {\n if (value instanceof Date) {\n return value.toISOString();\n }\n if (Array.isArray(value)) {\n return value.map((item) => normalizeDateOperand(item));\n }\n return value;\n}\n","import { PolicyContextPath } from \"../../context/index.js\";\nimport { Result } from \"../../../result/result.js\";\n\nimport {\n CANONICAL_UTC_DATE_FORMAT,\n containsInvalidDate,\n evaluateRelationalNumbers,\n normalizeDateOperand,\n parseComparableDate,\n type RelationalOperator,\n} from \"./condition-date-operands.js\";\nimport type {\n ConditionAndNode,\n ConditionLeafNode,\n ConditionNode,\n ConditionNotNode,\n ConditionOp,\n ConditionOrNode,\n} from \"./condition-types.js\";\nimport type {\n ConditionEvaluationOptions,\n ConditionEvaluationReport,\n} from \"../condition-evaluator-reporter.js\";\nimport type { PolicyContext } from \"../gate-types.js\";\n\nconst CONDITION_EVAL_THROWN_TAG = \"CONDITION_EVAL_THREW\";\nconst NULLISH_NUMERIC_OPERAND_NOT_ALLOWED_TAG =\n \"NULLISH_NUMERIC_OPERAND_NOT_ALLOWED\";\nconst NULLISH_DATE_OPERAND_NOT_ALLOWED_TAG = \"NULLISH_DATE_OPERAND_NOT_ALLOWED\";\nconst INVALID_DATE_OPERAND_TAG = \"INVALID_DATE_OPERAND\";\nconst INVALID_NUMERIC_OPERAND_TAG = \"INVALID_NUMERIC_OPERAND\";\nconst INVALID_SET_OPERAND_TAG = \"INVALID_SET_OPERAND\";\nconst EMPTY_OR_CONDITION_TAG = \"EMPTY_OR_CONDITION\";\nconst EMPTY_AND_CONDITION_TAG = \"EMPTY_AND_CONDITION\";\n\nexport interface ConditionEvaluationTrace {\n readonly conditionPath: string;\n readonly decisiveNode: ConditionNode;\n readonly lastEvaluatedLeaf: ConditionLeafNode;\n readonly lastEvaluatedLeafPath: string;\n readonly lastEvaluatedLeafResult: boolean;\n}\n\nexport interface TracedConditionEvaluation {\n readonly matched: boolean;\n readonly trace: ConditionEvaluationTrace;\n}\n\nexport class ConditionEvaluatorV1 {\n constructor(\n private readonly context: PolicyContext,\n private readonly options: ConditionEvaluationOptions,\n ) {}\n\n private static isLeafNode(node: ConditionNode): node is ConditionLeafNode {\n return \"field\" in node && \"op\" in node;\n }\n\n private static isAndNode(node: ConditionNode): node is ConditionAndNode {\n return \"and\" in node;\n }\n\n private static isOrNode(node: ConditionNode): node is ConditionOrNode {\n return \"or\" in node;\n }\n\n private static isNotNode(node: ConditionNode): node is ConditionNotNode {\n return \"not\" in node;\n }\n\n private static isRelationalOperator(\n op: ConditionOp,\n ): op is RelationalOperator {\n return op === \"gt\" || op === \"gte\" || op === \"lt\" || op === \"lte\";\n }\n\n private static describeError(error: unknown): {\n name: string;\n message: string;\n } {\n if (error instanceof Error) {\n return { name: error.name, message: error.message };\n }\n\n return { name: \"NonErrorThrown\", message: String(error) };\n }\n\n private static invalidDateOperandMessage(node: ConditionLeafNode): string {\n return `${INVALID_DATE_OPERAND_TAG}: \"${node.field}\" with operator \"${node.op}\" requires Date or ISO 8601 UTC (${CANONICAL_UTC_DATE_FORMAT}) string operands`;\n }\n\n private buildReport(params: {\n readonly level: ConditionEvaluationReport[\"level\"];\n readonly tag: ConditionEvaluationReport[\"tag\"];\n readonly message: string;\n readonly details: Readonly<Record<string, unknown>>;\n }): ConditionEvaluationReport {\n return {\n occurredAt: new Date(),\n level: params.level,\n tag: params.tag,\n message: params.message,\n engineVersion: this.options.engineVersion,\n details: params.details,\n };\n }\n\n // Single reporting seam for every leaf-level operand error. Collapses the\n // formerly per-tag report methods, whose only real difference was the tag,\n // message, and (for the nullish cases) an `allowNull` detail.\n private reportLeafError(\n tag: ConditionEvaluationReport[\"tag\"],\n message: string,\n node: ConditionLeafNode,\n actual: unknown,\n extra?: Readonly<Record<string, unknown>>,\n ): Result<boolean, string> {\n this.options.reporter.error(\n this.buildReport({\n level: \"error\",\n tag,\n message,\n details: {\n field: node.field,\n op: node.op,\n actual,\n expected: node.value,\n ...extra,\n node,\n },\n }),\n );\n\n return Result.err(message);\n }\n\n private conditionEvalErr<TValue>(\n node: ConditionNode,\n error: unknown,\n ): Result<TValue, string> {\n const cause = ConditionEvaluatorV1.describeError(error);\n const message = `${CONDITION_EVAL_THROWN_TAG}: ${cause.name}: ${cause.message}`;\n\n this.options.reporter.error(\n this.buildReport({\n level: \"error\",\n tag: CONDITION_EVAL_THROWN_TAG,\n message,\n details: { node, cause },\n }),\n );\n\n return Result.err(message);\n }\n\n private evaluateDateRelationalNode(\n node: ConditionLeafNode,\n actual: unknown,\n ): Result<boolean, string> | null {\n if (!ConditionEvaluatorV1.isRelationalOperator(node.op)) {\n return null;\n }\n\n const actualDate = parseComparableDate(actual);\n const expectedDate = parseComparableDate(node.value);\n\n // Neither operand is date-shaped: let the numeric path handle it.\n if (actualDate === null && expectedDate === null) {\n return null;\n }\n\n const allowsNull = node.allowNull === true;\n if (actual === null && allowsNull) {\n return Result.ok(false);\n }\n\n if (actual === null || actual === undefined) {\n const resolved = actual === null ? \"null\" : \"undefined\";\n return this.reportLeafError(\n NULLISH_DATE_OPERAND_NOT_ALLOWED_TAG,\n `${NULLISH_DATE_OPERAND_NOT_ALLOWED_TAG}: \"${node.field}\" resolved to ${resolved} for date comparison operator \"${node.op}\"`,\n node,\n actual,\n { allowNull: allowsNull },\n );\n }\n\n if (\n actualDate === null ||\n actualDate.isErr() ||\n expectedDate === null ||\n expectedDate.isErr()\n ) {\n return this.reportLeafError(\n INVALID_DATE_OPERAND_TAG,\n ConditionEvaluatorV1.invalidDateOperandMessage(node),\n node,\n actual,\n );\n }\n\n return Result.ok(\n evaluateRelationalNumbers(\n actualDate.getOrNull()!.getTime(),\n node.op,\n expectedDate.getOrNull()!.getTime(),\n ),\n );\n }\n\n private evaluateOperator(\n actual: unknown,\n op: ConditionOp,\n expected: unknown,\n ): boolean {\n switch (op) {\n case \"eq\":\n return actual === expected;\n case \"neq\":\n return actual !== expected;\n case \"gt\":\n case \"gte\":\n case \"lt\":\n case \"lte\":\n return (\n typeof actual === \"number\" &&\n typeof expected === \"number\" &&\n evaluateRelationalNumbers(actual, op, expected)\n );\n case \"in\":\n return Array.isArray(expected) && expected.includes(actual);\n case \"notIn\":\n return Array.isArray(expected) && !expected.includes(actual);\n case \"isNull\":\n return actual === null || actual === undefined;\n case \"isNotNull\":\n return actual !== null && actual !== undefined;\n }\n }\n\n private evaluateNumericRelationalNode(\n node: ConditionLeafNode,\n actual: unknown,\n ): Result<boolean, string> {\n const allowsNull = node.allowNull === true;\n if (actual === undefined || (actual === null && !allowsNull)) {\n const resolved = actual === null ? \"null\" : \"undefined\";\n return this.reportLeafError(\n NULLISH_NUMERIC_OPERAND_NOT_ALLOWED_TAG,\n `${NULLISH_NUMERIC_OPERAND_NOT_ALLOWED_TAG}: \"${node.field}\" resolved to ${resolved} for numeric operator \"${node.op}\"`,\n node,\n actual,\n { allowNull: allowsNull },\n );\n }\n\n // null + allowNull: a relational comparison against a missing value\n // never matches.\n if (actual === null) {\n return Result.ok(false);\n }\n\n // Both operands must be finite numbers. A present but wrong-typed or\n // NaN operand is a context/configuration error, surfaced like the date\n // path instead of silently collapsing to \"no match\".\n if (\n typeof actual !== \"number\" ||\n Number.isNaN(actual) ||\n typeof node.value !== \"number\" ||\n Number.isNaN(node.value)\n ) {\n return this.reportLeafError(\n INVALID_NUMERIC_OPERAND_TAG,\n `${INVALID_NUMERIC_OPERAND_TAG}: \"${node.field}\" with operator \"${node.op}\" requires numeric operands`,\n node,\n actual,\n );\n }\n\n return Result.ok(this.evaluateOperator(actual, node.op, node.value));\n }\n\n private evaluateLeafNode(node: ConditionLeafNode): Result<boolean, string> {\n const actualResult = PolicyContextPath.getOrAbsent(\n this.context,\n node.field,\n );\n if (actualResult.isErr()) {\n const message = `MISSING_CONTEXT_FIELD: \"${node.field}\" not found in context`;\n this.options.reporter.warn(\n this.buildReport({\n level: \"warn\",\n tag: \"MISSING_CONTEXT_FIELD\",\n message,\n details: { field: node.field, node },\n }),\n );\n\n return Result.err(message);\n }\n\n try {\n const actual = actualResult.getOrThrow();\n if (ConditionEvaluatorV1.isRelationalOperator(node.op)) {\n const dateResult = this.evaluateDateRelationalNode(\n node,\n actual,\n );\n if (dateResult !== null) {\n return dateResult;\n }\n\n return this.evaluateNumericRelationalNode(node, actual);\n }\n\n if (\n (node.op === \"in\" || node.op === \"notIn\") &&\n !Array.isArray(node.value)\n ) {\n return this.reportLeafError(\n INVALID_SET_OPERAND_TAG,\n `${INVALID_SET_OPERAND_TAG}: \"${node.field}\" with operator \"${node.op}\" requires an array operand`,\n node,\n actual,\n );\n }\n\n if (\n node.op === \"eq\" ||\n node.op === \"neq\" ||\n node.op === \"in\" ||\n node.op === \"notIn\"\n ) {\n // A Date operand would otherwise compare by reference and\n // silently never match. Normalize valid Dates (either side,\n // including set items) to their ISO string; an invalid Date is\n // a context/configuration error, like the relational path.\n if (\n containsInvalidDate(actual) ||\n containsInvalidDate(node.value)\n ) {\n return this.reportLeafError(\n INVALID_DATE_OPERAND_TAG,\n ConditionEvaluatorV1.invalidDateOperandMessage(node),\n node,\n actual,\n );\n }\n\n return Result.ok(\n this.evaluateOperator(\n normalizeDateOperand(actual),\n node.op,\n normalizeDateOperand(node.value),\n ),\n );\n }\n\n return Result.ok(\n this.evaluateOperator(actual, node.op, node.value),\n );\n } catch (error) {\n return this.conditionEvalErr(node, error);\n }\n }\n\n private buildTrace(params: {\n readonly conditionPath: string;\n readonly decisiveNode: ConditionNode;\n readonly lastEvaluatedLeaf: ConditionLeafNode;\n readonly lastEvaluatedLeafPath: string;\n readonly lastEvaluatedLeafResult: boolean;\n }): ConditionEvaluationTrace {\n return {\n conditionPath: params.conditionPath,\n decisiveNode: params.decisiveNode,\n lastEvaluatedLeaf: params.lastEvaluatedLeaf,\n lastEvaluatedLeafPath: params.lastEvaluatedLeafPath,\n lastEvaluatedLeafResult: params.lastEvaluatedLeafResult,\n };\n }\n\n private evaluateWithTraceInternal(\n node: ConditionNode,\n path: string,\n ): Result<TracedConditionEvaluation, string> {\n if (ConditionEvaluatorV1.isLeafNode(node)) {\n const leafResult = this.evaluateLeafNode(node);\n if (leafResult.isErr()) {\n return Result.err(leafResult.errorOrNull()!);\n }\n\n const matched = leafResult.getOrNull()!;\n return Result.ok({\n matched,\n trace: this.buildTrace({\n conditionPath: path,\n decisiveNode: node,\n lastEvaluatedLeaf: node,\n lastEvaluatedLeafPath: path,\n lastEvaluatedLeafResult: matched,\n }),\n });\n }\n\n if (ConditionEvaluatorV1.isAndNode(node)) {\n if (node.and.length === 0) {\n return Result.err(\n `${EMPTY_AND_CONDITION_TAG}: AND nodes must contain at least one child condition`,\n );\n }\n\n let lastTracedChild: TracedConditionEvaluation | null = null;\n\n for (const [index, child] of node.and.entries()) {\n const childPath = `${path}.and[${index}]`;\n const childResult = this.evaluateWithTraceInternal(\n child,\n childPath,\n );\n if (childResult.isErr()) {\n return Result.err(childResult.errorOrNull()!);\n }\n\n const tracedChild = childResult.getOrNull()!;\n lastTracedChild = tracedChild;\n if (!tracedChild.matched) {\n return Result.ok({\n matched: false,\n trace: this.buildTrace({\n conditionPath: childPath,\n decisiveNode: child,\n lastEvaluatedLeaf:\n tracedChild.trace.lastEvaluatedLeaf,\n lastEvaluatedLeafPath:\n tracedChild.trace.lastEvaluatedLeafPath,\n lastEvaluatedLeafResult:\n tracedChild.trace.lastEvaluatedLeafResult,\n }),\n });\n }\n }\n\n return Result.ok({\n matched: true,\n trace: lastTracedChild!.trace,\n });\n }\n\n if (ConditionEvaluatorV1.isOrNode(node)) {\n let lastTrace: ConditionEvaluationTrace | null = null;\n\n for (const [index, child] of node.or.entries()) {\n const childResult = this.evaluateWithTraceInternal(\n child,\n `${path}.or[${index}]`,\n );\n if (childResult.isErr()) {\n return Result.err(childResult.errorOrNull()!);\n }\n\n const tracedChild = childResult.getOrNull()!;\n lastTrace = tracedChild.trace;\n if (tracedChild.matched) {\n return Result.ok({\n matched: true,\n trace: tracedChild.trace,\n });\n }\n }\n\n if (lastTrace === null) {\n return Result.err(\n `${EMPTY_OR_CONDITION_TAG}: OR nodes must contain at least one child condition`,\n );\n }\n\n return Result.ok({ matched: false, trace: lastTrace! });\n }\n\n if (ConditionEvaluatorV1.isNotNode(node)) {\n const childPath = `${path}.not`;\n const childResult = this.evaluateWithTraceInternal(\n node.not,\n childPath,\n );\n if (childResult.isErr()) {\n return Result.err(childResult.errorOrNull()!);\n }\n\n const tracedChild = childResult.getOrNull()!;\n return Result.ok({\n matched: !tracedChild.matched,\n trace: this.buildTrace({\n conditionPath: path,\n decisiveNode: node,\n lastEvaluatedLeaf: tracedChild.trace.lastEvaluatedLeaf,\n lastEvaluatedLeafPath:\n tracedChild.trace.lastEvaluatedLeafPath,\n lastEvaluatedLeafResult:\n tracedChild.trace.lastEvaluatedLeafResult,\n }),\n });\n }\n\n return this.conditionEvalErr(\n node,\n new TypeError(\"Invalid condition node shape\"),\n );\n }\n\n evaluate(node: ConditionNode): Result<boolean, string> {\n try {\n const result = this.evaluateWithTraceInternal(node, \"$\");\n if (result.isErr()) {\n return Result.err(result.errorOrNull()!);\n }\n\n return Result.ok(result.getOrNull()!.matched);\n } catch (error) {\n return this.conditionEvalErr(node, error);\n }\n }\n\n evaluateWithTrace(\n node: ConditionNode,\n ): Result<TracedConditionEvaluation, string> {\n try {\n return this.evaluateWithTraceInternal(node, \"$\");\n } catch (error) {\n return this.conditionEvalErr(node, error);\n }\n }\n\n static extractFields(node: ConditionNode): string[] {\n if (ConditionEvaluatorV1.isLeafNode(node)) {\n return [node.field];\n }\n\n if (ConditionEvaluatorV1.isAndNode(node)) {\n return node.and.flatMap((child) =>\n ConditionEvaluatorV1.extractFields(child),\n );\n }\n\n if (ConditionEvaluatorV1.isOrNode(node)) {\n return node.or.flatMap((child) =>\n ConditionEvaluatorV1.extractFields(child),\n );\n }\n\n if (ConditionEvaluatorV1.isNotNode(node)) {\n return ConditionEvaluatorV1.extractFields(node.not);\n }\n\n return [];\n }\n}\n"],"mappings":";;;AAEA,IAAa,uBAAb,MAA4D;CACxD,OAAO,QAAuD,CAAC;AACnE;;;;ACiBA,SAAS,WAAW,gBAAgC,OAA0B;CAC1E,IAAI;EACA,eAAe,OAAO,KAAK;CAC/B,QAAQ,CAER;AACJ;;;;;;;;;;;;;AAcA,IAAa,aAAb,MAAwB;CACpB;CACA;CAEA,YAAY,UAA6B,CAAC,GAAG;EACzC,MAAM,WACF,QAAQ,eAAe,YAAY,IAAI,qBAAqB;EAChE,KAAKA,mBAAmB;EACxB,KAAKC,mBAAmB;CAC5B;;;;;;CAOA,UAAU,SAAkC;EACxC,MAAM,gBAAgB,QAAQ;EAC9B,IAAI,iBAAiB,cAAc,eAC/B,KAAKA,mBACD,cAAc,YAAY,IAAI,qBAAqB;EAE3D,OAAO;CACX;CAIA,QAAc;EACV,KAAKA,mBAAmB,KAAKD;EAC7B,OAAO;CACX;;CAGA,aAAa,OAA0B;EACnC,WAAW,KAAKC,kBAAkB,KAAK;CAC3C;CAEA,8BACI,eAC0B;EAC1B,OAAO;GACH,UAAU,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