@cullet/erp-core 1.0.5 → 1.0.7
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/dist/gate-engine-registry.js.map +1 -1
- package/dist/gate-types.d.ts +1 -1
- package/dist/gate-v1-payload.schema.js +43 -0
- package/dist/gate-v1-payload.schema.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +9 -3
- package/dist/index.js.map +1 -1
- package/dist/outcome.js.map +1 -1
- package/dist/policies/engines/v1/gate/index.d.ts +4 -0
- package/dist/policies/engines/v1/gate/index.js.map +1 -1
- package/dist/policy-service.js +14 -11
- package/dist/policy-service.js.map +1 -1
- package/dist/validation-code.js +43 -9
- package/dist/validation-code.js.map +1 -1
- package/dist/validation-error.d.ts +15 -1
- package/dist/validation-error.js.map +1 -1
- package/meta.json +2 -2
- package/package.json +1 -1
- package/src/core/application/commands/command.ts +4 -4
- package/src/core/application/commands/index.ts +2 -2
- package/src/core/application/commands/requested-by.ts +3 -3
- package/src/core/application/index.ts +8 -8
- package/src/core/application/policy-error-mapper.ts +2 -2
- package/src/core/application/ports/index.ts +10 -6
- package/src/core/application/ports/policy-port.ts +6 -3
- package/src/core/application/ports/temporal-repository.port.ts +2 -2
- package/src/core/application/queries/index.ts +2 -2
- package/src/core/application/queries/query.ts +4 -4
- package/src/core/application/temporal/index.ts +2 -2
- package/src/core/application/temporal/temporal-context.ts +2 -2
- package/src/core/application/temporal/temporal-use-case.ts +4 -4
- package/src/core/application/use-case.ts +3 -3
- package/src/core/config/core-config.instance.ts +2 -2
- package/src/core/config/core-config.ts +3 -3
- package/src/core/config/index.ts +8 -5
- package/src/core/config/policy-reporter.ts +3 -3
- package/src/core/config/silent-policy-reporter.ts +1 -1
- package/src/core/domain/entity.ts +11 -5
- package/src/core/domain/rulesets/entity-ruleset.contracts.ts +2 -2
- package/src/core/domain/rulesets/ruleset-registry.ts +2 -2
- package/src/core/domain/rulesets/value-object-ruleset.contracts.ts +2 -2
- package/src/core/domain/temporal/index.ts +4 -4
- package/src/core/domain/temporal/temporal-range.ts +2 -2
- package/src/core/domain/temporal/temporal-snapshot.ts +3 -3
- package/src/core/domain/temporal/transaction-time.ts +3 -3
- package/src/core/domain/temporal/valid-time.ts +3 -3
- package/src/core/domain/value-object.ts +3 -3
- package/src/core/errors/app-error.ts +6 -2
- package/src/core/errors/authentication-error.ts +3 -3
- package/src/core/errors/authorization-error.ts +3 -3
- package/src/core/errors/business-rule-violation-error.ts +3 -3
- package/src/core/errors/conflict-error.ts +3 -3
- package/src/core/errors/idempotency-error.ts +3 -3
- package/src/core/errors/index.ts +23 -23
- package/src/core/errors/integration-error.ts +3 -3
- package/src/core/errors/legacy-incompatible-error.ts +3 -3
- package/src/core/errors/not-found-error.ts +3 -3
- package/src/core/errors/serialization-error.ts +3 -3
- package/src/core/errors/temporal-error.ts +3 -3
- package/src/core/errors/unexpected-error.ts +3 -3
- package/src/core/errors/utils/index.ts +2 -1
- package/src/core/errors/utils/json-safe.ts +25 -7
- package/src/core/errors/validation-error.ts +5 -5
- package/src/core/exceptions/business-rule-violation-exception.ts +1 -1
- package/src/core/exceptions/entity-not-found-exception.ts +1 -1
- package/src/core/exceptions/invalid-state-transition-exception.ts +1 -1
- package/src/core/exceptions/invariant-violation-exception.ts +1 -1
- package/src/core/exceptions/validation-exception.ts +3 -3
- package/src/core/index.ts +7 -7
- package/src/core/policies/asof/asof.ts +4 -4
- package/src/core/policies/asof/index.ts +2 -2
- package/src/core/policies/catalog/catalog.instance.ts +3 -3
- package/src/core/policies/catalog/index.ts +6 -6
- package/src/core/policies/catalog/policy-catalog-entry.ts +3 -3
- package/src/core/policies/catalog/policy-catalog.ts +3 -3
- package/src/core/policies/catalog/policy-key.ts +1 -1
- package/src/core/policies/context/context-builder.ts +5 -5
- package/src/core/policies/context/context-registry.instance.ts +3 -3
- package/src/core/policies/context/context-registry.ts +2 -2
- package/src/core/policies/context/context-resolver.ts +2 -2
- package/src/core/policies/context/context-seed.ts +2 -2
- package/src/core/policies/context/index.ts +9 -9
- package/src/core/policies/context/path.ts +1 -1
- package/src/core/policies/defs/in-memory-policy-definition-repo.ts +3 -3
- package/src/core/policies/defs/index.ts +8 -8
- package/src/core/policies/defs/policy-definition-repository.ts +1 -1
- package/src/core/policies/defs/policy-definition.ts +6 -6
- package/src/core/policies/defs/policy-payload.contracts.ts +1 -1
- package/src/core/policies/defs/policy-scope.ts +2 -2
- package/src/core/policies/defs/policy-semver.ts +12 -5
- package/src/core/policies/engines/compute-engine-registry.ts +9 -6
- package/src/core/policies/engines/compute-evaluator-registry.ts +1 -1
- package/src/core/policies/engines/compute-payload.ts +1 -1
- package/src/core/policies/engines/compute-registry.ts +7 -7
- package/src/core/policies/engines/compute-types.ts +4 -4
- package/src/core/policies/engines/condition-evaluator-reporter.ts +2 -0
- package/src/core/policies/engines/gate-engine-registry.ts +3 -3
- package/src/core/policies/engines/gate-payload.ts +1 -1
- package/src/core/policies/engines/gate-types.ts +3 -3
- package/src/core/policies/engines/index.ts +14 -14
- package/src/core/policies/engines/parse-compute-payload.ts +4 -4
- package/src/core/policies/engines/parse-gate-payload.ts +4 -4
- package/src/core/policies/engines/v1/compute/compute-engine-v1.ts +6 -6
- package/src/core/policies/engines/v1/compute/compute-payload.schema.ts +3 -3
- package/src/core/policies/engines/v1/compute/index.ts +4 -4
- package/src/core/policies/engines/v1/compute/resolve-decision-table-v1.ts +4 -4
- package/src/core/policies/engines/v1/condition-evaluator.ts +90 -6
- package/src/core/policies/engines/v1/condition-schema.ts +1 -1
- package/src/core/policies/engines/v1/gate/gate-engine-v1.ts +7 -7
- package/src/core/policies/engines/v1/gate/gate-types-v1.ts +1 -1
- package/src/core/policies/engines/v1/gate/gate-v1-payload.schema.ts +3 -3
- package/src/core/policies/engines/v1/gate/index.ts +4 -4
- package/src/core/policies/engines/v1/index.ts +3 -3
- package/src/core/policies/index.ts +30 -23
- package/src/core/policies/package/policy-package.ts +3 -3
- package/src/core/policies/policy-ids.ts +3 -3
- package/src/core/policies/resolver/index.ts +1 -1
- package/src/core/policies/resolver/policy-resolver.ts +4 -4
- package/src/core/policies/service/index.ts +3 -3
- package/src/core/policies/service/policy-evaluation-error.ts +1 -1
- package/src/core/policies/service/policy-service.ts +21 -14
- package/src/core/policies/utils/date.ts +1 -1
- package/src/core/policies/utils/hash.ts +23 -11
- package/src/core/policies/utils/index.ts +3 -3
- package/src/core/policies/utils/result.ts +1 -1
- package/src/core/result/outcome.ts +1 -1
- package/src/core/shared/aggregate-version.ts +1 -1
- package/src/core/shared/hashing.ts +33 -4
- package/src/core/shared/immutable.ts +13 -2
- package/src/core/shared/temporal-guards.ts +1 -1
- package/src/core/versioning/domain-event-contracts.ts +5 -5
- package/src/examples/rulesets/entity/order-creation-rules-v1.ts +2 -2
- package/src/examples/rulesets/entity/order-invariants-v1.ts +2 -2
- package/src/examples/rulesets/entity/order-invariants-v2.ts +3 -3
- package/src/examples/rulesets/entity/order.ts +1 -1
- package/src/examples/rulesets/value-object/cpf-rules-v1.ts +1 -1
- package/src/examples/rulesets/value-object/cpf-rules-v2.ts +2 -2
- package/src/examples/rulesets/value-object/cpf.ts +1 -1
- package/src/examples/rulesets/value-object/customer.ts +3 -3
- package/src/examples/rulesets/value-object/person-name-rules-v1.ts +1 -1
- package/src/examples/rulesets/value-object/person-name-rules-v2.ts +2 -2
- package/src/examples/rulesets/value-object/person-name.ts +1 -1
- package/src/version.ts +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { Outcome } from "../../result/outcome";
|
|
2
|
-
import type { Result } from "../../result/result";
|
|
1
|
+
import type { Outcome } from "../../result/outcome.js";
|
|
2
|
+
import type { Result } from "../../result/result.js";
|
|
3
3
|
|
|
4
|
-
import type { GatePayload } from "./gate-payload";
|
|
4
|
+
import type { GatePayload } from "./gate-payload.js";
|
|
5
5
|
|
|
6
6
|
// ─── Shared gate types (version-agnostic) ───────────────────────────────────
|
|
7
7
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type { ComputePayload, ComputePayloadV1 } from "./compute-payload";
|
|
1
|
+
export type { ComputePayload, ComputePayloadV1 } from "./compute-payload.js";
|
|
2
2
|
export type {
|
|
3
3
|
ComputeEvaluator,
|
|
4
4
|
ComputeEvaluatorRegistration,
|
|
@@ -6,7 +6,7 @@ export type {
|
|
|
6
6
|
ComputeOutcomeData,
|
|
7
7
|
ComputeStatus,
|
|
8
8
|
VersionedComputeEngine,
|
|
9
|
-
} from "./compute-types";
|
|
9
|
+
} from "./compute-types.js";
|
|
10
10
|
export type {
|
|
11
11
|
ConditionEvaluationCause,
|
|
12
12
|
ConditionEvaluationOptions,
|
|
@@ -14,12 +14,12 @@ export type {
|
|
|
14
14
|
ConditionEvaluationReportLevel,
|
|
15
15
|
ConditionEvaluationReportTag,
|
|
16
16
|
ConditionEvaluatorReporter,
|
|
17
|
-
} from "./condition-evaluator-reporter";
|
|
18
|
-
export { ComputeEngineRegistry } from "./compute-engine-registry";
|
|
19
|
-
export { ComputeEvaluatorRegistry } from "./compute-evaluator-registry";
|
|
20
|
-
export { ComputeRegistry } from "./compute-registry";
|
|
21
|
-
export { GateEngineRegistry } from "./gate-engine-registry";
|
|
22
|
-
export type { GatePayload, GatePayloadV1 } from "./gate-payload";
|
|
17
|
+
} from "./condition-evaluator-reporter.js";
|
|
18
|
+
export { ComputeEngineRegistry } from "./compute-engine-registry.js";
|
|
19
|
+
export { ComputeEvaluatorRegistry } from "./compute-evaluator-registry.js";
|
|
20
|
+
export { ComputeRegistry } from "./compute-registry.js";
|
|
21
|
+
export { GateEngineRegistry } from "./gate-engine-registry.js";
|
|
22
|
+
export type { GatePayload, GatePayloadV1 } from "./gate-payload.js";
|
|
23
23
|
export type {
|
|
24
24
|
GateOutcome,
|
|
25
25
|
GateOutcomeData,
|
|
@@ -30,19 +30,19 @@ export type {
|
|
|
30
30
|
PolicyContext,
|
|
31
31
|
PolicyViolation,
|
|
32
32
|
VersionedGateEngine,
|
|
33
|
-
} from "./gate-types";
|
|
33
|
+
} from "./gate-types.js";
|
|
34
34
|
export {
|
|
35
35
|
ComputePayloadParsers,
|
|
36
36
|
ComputePayloadParserRegistry,
|
|
37
|
-
} from "./parse-compute-payload";
|
|
38
|
-
export type { ComputePayloadParser } from "./parse-compute-payload";
|
|
37
|
+
} from "./parse-compute-payload.js";
|
|
38
|
+
export type { ComputePayloadParser } from "./parse-compute-payload.js";
|
|
39
39
|
export {
|
|
40
40
|
GatePayloadParsers,
|
|
41
41
|
GatePayloadParserRegistry,
|
|
42
|
-
} from "./parse-gate-payload";
|
|
43
|
-
export type { GatePayloadParser } from "./parse-gate-payload";
|
|
42
|
+
} from "./parse-gate-payload.js";
|
|
43
|
+
export type { GatePayloadParser } from "./parse-gate-payload.js";
|
|
44
44
|
export type {
|
|
45
45
|
ComputeDecisionTablePayload,
|
|
46
46
|
ComputeDecisionTableRule,
|
|
47
47
|
ComputeParamsPayload,
|
|
48
|
-
} from "./v1/compute";
|
|
48
|
+
} from "./v1/compute/index.js";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type { Result as ResultType } from "../../result/result";
|
|
2
|
-
import { Result } from "../../result/result";
|
|
1
|
+
import type { Result as ResultType } from "../../result/result.js";
|
|
2
|
+
import { Result } from "../../result/result.js";
|
|
3
3
|
|
|
4
|
-
import type { ComputePayload } from "./compute-payload";
|
|
5
|
-
import { ComputePayloadSchemaV1 } from "./v1/compute/compute-payload.schema";
|
|
4
|
+
import type { ComputePayload } from "./compute-payload.js";
|
|
5
|
+
import { ComputePayloadSchemaV1 } from "./v1/compute/compute-payload.schema.js";
|
|
6
6
|
|
|
7
7
|
export type ComputePayloadParser = (
|
|
8
8
|
payload: unknown,
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type { Result as ResultType } from "../../result/result";
|
|
2
|
-
import { Result } from "../../result/result";
|
|
1
|
+
import type { Result as ResultType } from "../../result/result.js";
|
|
2
|
+
import { Result } from "../../result/result.js";
|
|
3
3
|
|
|
4
|
-
import type { GatePayload } from "./gate-payload";
|
|
5
|
-
import { GatePayloadSchemaV1 } from "./v1/gate/gate-v1-payload.schema";
|
|
4
|
+
import type { GatePayload } from "./gate-payload.js";
|
|
5
|
+
import { GatePayloadSchemaV1 } from "./v1/gate/gate-v1-payload.schema.js";
|
|
6
6
|
|
|
7
7
|
export type GatePayloadParser = (
|
|
8
8
|
payload: unknown,
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { type CoreConfig, coreConfig } from "../../../../config";
|
|
2
|
-
import { Result } from "../../../../result/result";
|
|
1
|
+
import { type CoreConfig, coreConfig } from "../../../../config/index.js";
|
|
2
|
+
import { Result } from "../../../../result/result.js";
|
|
3
3
|
|
|
4
|
-
import type { ComputePayloadV1 as ComputePayload } from "./compute-payload.schema";
|
|
5
|
-
import { DecisionTableResolverV1 } from "./resolve-decision-table-v1";
|
|
4
|
+
import type { ComputePayloadV1 as ComputePayload } from "./compute-payload.schema.js";
|
|
5
|
+
import { DecisionTableResolverV1 } from "./resolve-decision-table-v1.js";
|
|
6
6
|
import type {
|
|
7
7
|
ComputeEvaluator,
|
|
8
8
|
ComputeOutcome,
|
|
9
9
|
VersionedComputeEngine,
|
|
10
|
-
} from "../../compute-types";
|
|
11
|
-
import type { PolicyContext } from "../../gate-types";
|
|
10
|
+
} from "../../compute-types.js";
|
|
11
|
+
import type { PolicyContext } from "../../gate-types.js";
|
|
12
12
|
|
|
13
13
|
// ─── Compute engine v1 ───────────────────────────────────────────────────────
|
|
14
14
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
|
|
3
|
-
import { Result } from "../../../../result/result";
|
|
3
|
+
import { Result } from "../../../../result/result.js";
|
|
4
4
|
|
|
5
|
-
import { conditionNodeSchema } from "../condition-schema";
|
|
6
|
-
import type { ConditionNode } from "../condition-types";
|
|
5
|
+
import { conditionNodeSchema } from "../condition-schema.js";
|
|
6
|
+
import type { ConditionNode } from "../condition-types.js";
|
|
7
7
|
|
|
8
8
|
// ─── Pattern 1: Params ──────────────────────────────────────────────────────
|
|
9
9
|
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
export { ComputeEngineV1 } from "./compute-engine-v1";
|
|
1
|
+
export { ComputeEngineV1 } from "./compute-engine-v1.js";
|
|
2
2
|
export type {
|
|
3
3
|
ComputeDecisionTablePayload,
|
|
4
4
|
ComputeDecisionTableRule,
|
|
5
5
|
ComputeParamsPayload,
|
|
6
6
|
ComputePayloadV1,
|
|
7
|
-
} from "./compute-payload.schema";
|
|
7
|
+
} from "./compute-payload.schema.js";
|
|
8
8
|
export {
|
|
9
9
|
computePayloadSchema,
|
|
10
10
|
ComputePayloadSchemaV1,
|
|
11
|
-
} from "./compute-payload.schema";
|
|
12
|
-
export { DecisionTableResolverV1 } from "./resolve-decision-table-v1";
|
|
11
|
+
} from "./compute-payload.schema.js";
|
|
12
|
+
export { DecisionTableResolverV1 } from "./resolve-decision-table-v1.js";
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { Result } from "../../../../result/result";
|
|
1
|
+
import { Result } from "../../../../result/result.js";
|
|
2
2
|
|
|
3
|
-
import type { ConditionEvaluationOptions } from "../../condition-evaluator-reporter";
|
|
3
|
+
import type { ConditionEvaluationOptions } from "../../condition-evaluator-reporter.js";
|
|
4
4
|
|
|
5
|
-
import { ConditionEvaluatorV1 } from "../condition-evaluator";
|
|
6
|
-
import type { ComputeDecisionTablePayload } from "./compute-payload.schema";
|
|
5
|
+
import { ConditionEvaluatorV1 } from "../condition-evaluator.js";
|
|
6
|
+
import type { ComputeDecisionTablePayload } from "./compute-payload.schema.js";
|
|
7
7
|
|
|
8
8
|
const COMPUTE_CONDITION_EVAL_FAILED_TAG = "COMPUTE_CONDITION_EVAL_FAILED";
|
|
9
9
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { PolicyContextPath } from "../../context";
|
|
2
|
-
import { PolicyDateUtils } from "../../utils";
|
|
3
|
-
import { Result } from "../../../result/result";
|
|
1
|
+
import { PolicyContextPath } from "../../context/index.js";
|
|
2
|
+
import { PolicyDateUtils } from "../../utils/index.js";
|
|
3
|
+
import { Result } from "../../../result/result.js";
|
|
4
4
|
|
|
5
5
|
import type {
|
|
6
6
|
ConditionAndNode,
|
|
@@ -9,18 +9,20 @@ import type {
|
|
|
9
9
|
ConditionNotNode,
|
|
10
10
|
ConditionOp,
|
|
11
11
|
ConditionOrNode,
|
|
12
|
-
} from "./condition-types";
|
|
12
|
+
} from "./condition-types.js";
|
|
13
13
|
import type {
|
|
14
14
|
ConditionEvaluationOptions,
|
|
15
15
|
ConditionEvaluationReport,
|
|
16
|
-
} from "../condition-evaluator-reporter";
|
|
17
|
-
import type { PolicyContext } from "../gate-types";
|
|
16
|
+
} from "../condition-evaluator-reporter.js";
|
|
17
|
+
import type { PolicyContext } from "../gate-types.js";
|
|
18
18
|
|
|
19
19
|
const CONDITION_EVAL_THROWN_TAG = "CONDITION_EVAL_THREW";
|
|
20
20
|
const NULLISH_NUMERIC_OPERAND_NOT_ALLOWED_TAG =
|
|
21
21
|
"NULLISH_NUMERIC_OPERAND_NOT_ALLOWED";
|
|
22
22
|
const NULLISH_DATE_OPERAND_NOT_ALLOWED_TAG = "NULLISH_DATE_OPERAND_NOT_ALLOWED";
|
|
23
23
|
const INVALID_DATE_OPERAND_TAG = "INVALID_DATE_OPERAND";
|
|
24
|
+
const INVALID_NUMERIC_OPERAND_TAG = "INVALID_NUMERIC_OPERAND";
|
|
25
|
+
const INVALID_SET_OPERAND_TAG = "INVALID_SET_OPERAND";
|
|
24
26
|
const EMPTY_OR_CONDITION_TAG = "EMPTY_OR_CONDITION";
|
|
25
27
|
const EMPTY_AND_CONDITION_TAG = "EMPTY_AND_CONDITION";
|
|
26
28
|
const ISO_8601_UTC_DATE_PATTERN =
|
|
@@ -110,6 +112,18 @@ export class ConditionEvaluatorV1 {
|
|
|
110
112
|
return `${INVALID_DATE_OPERAND_TAG}: "${node.field}" with operator "${node.op}" requires Date or ISO 8601 UTC string operands`;
|
|
111
113
|
}
|
|
112
114
|
|
|
115
|
+
private static buildInvalidNumericOperandMessage(
|
|
116
|
+
node: ConditionLeafNode,
|
|
117
|
+
): string {
|
|
118
|
+
return `${INVALID_NUMERIC_OPERAND_TAG}: "${node.field}" with operator "${node.op}" requires numeric operands`;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
private static buildInvalidSetOperandMessage(
|
|
122
|
+
node: ConditionLeafNode,
|
|
123
|
+
): string {
|
|
124
|
+
return `${INVALID_SET_OPERAND_TAG}: "${node.field}" with operator "${node.op}" requires an array operand`;
|
|
125
|
+
}
|
|
126
|
+
|
|
113
127
|
private static buildEmptyOrConditionMessage(): string {
|
|
114
128
|
return `${EMPTY_OR_CONDITION_TAG}: OR nodes must contain at least one child condition`;
|
|
115
129
|
}
|
|
@@ -224,6 +238,56 @@ export class ConditionEvaluatorV1 {
|
|
|
224
238
|
return Result.err(message);
|
|
225
239
|
}
|
|
226
240
|
|
|
241
|
+
private reportInvalidNumericOperand(
|
|
242
|
+
node: ConditionLeafNode,
|
|
243
|
+
actual: unknown,
|
|
244
|
+
): Result<boolean, string> {
|
|
245
|
+
const message =
|
|
246
|
+
ConditionEvaluatorV1.buildInvalidNumericOperandMessage(node);
|
|
247
|
+
|
|
248
|
+
this.options.reporter.error(
|
|
249
|
+
this.buildReport({
|
|
250
|
+
level: "error",
|
|
251
|
+
tag: INVALID_NUMERIC_OPERAND_TAG,
|
|
252
|
+
message,
|
|
253
|
+
details: {
|
|
254
|
+
field: node.field,
|
|
255
|
+
op: node.op,
|
|
256
|
+
actual,
|
|
257
|
+
expected: node.value,
|
|
258
|
+
node,
|
|
259
|
+
},
|
|
260
|
+
}),
|
|
261
|
+
);
|
|
262
|
+
|
|
263
|
+
return Result.err(message);
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
private reportInvalidSetOperand(
|
|
267
|
+
node: ConditionLeafNode,
|
|
268
|
+
actual: unknown,
|
|
269
|
+
): Result<boolean, string> {
|
|
270
|
+
const message =
|
|
271
|
+
ConditionEvaluatorV1.buildInvalidSetOperandMessage(node);
|
|
272
|
+
|
|
273
|
+
this.options.reporter.error(
|
|
274
|
+
this.buildReport({
|
|
275
|
+
level: "error",
|
|
276
|
+
tag: INVALID_SET_OPERAND_TAG,
|
|
277
|
+
message,
|
|
278
|
+
details: {
|
|
279
|
+
field: node.field,
|
|
280
|
+
op: node.op,
|
|
281
|
+
actual,
|
|
282
|
+
expected: node.value,
|
|
283
|
+
node,
|
|
284
|
+
},
|
|
285
|
+
}),
|
|
286
|
+
);
|
|
287
|
+
|
|
288
|
+
return Result.err(message);
|
|
289
|
+
}
|
|
290
|
+
|
|
227
291
|
private evaluateDateRelationalNode(
|
|
228
292
|
node: ConditionLeafNode,
|
|
229
293
|
actual: unknown,
|
|
@@ -406,6 +470,19 @@ export class ConditionEvaluatorV1 {
|
|
|
406
470
|
return Result.err(message);
|
|
407
471
|
}
|
|
408
472
|
|
|
473
|
+
// null + allowNull: a relational comparison against a missing value
|
|
474
|
+
// never matches.
|
|
475
|
+
if (actual === null) {
|
|
476
|
+
return Result.ok(false);
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
// Both operands must be numbers. A present but wrong-typed operand is a
|
|
480
|
+
// context/configuration error, surfaced like the date path instead of
|
|
481
|
+
// silently collapsing to "no match".
|
|
482
|
+
if (typeof actual !== "number" || typeof node.value !== "number") {
|
|
483
|
+
return this.reportInvalidNumericOperand(node, actual);
|
|
484
|
+
}
|
|
485
|
+
|
|
409
486
|
return Result.ok(this.evaluateOperator(actual, node.op, node.value));
|
|
410
487
|
}
|
|
411
488
|
|
|
@@ -443,6 +520,13 @@ export class ConditionEvaluatorV1 {
|
|
|
443
520
|
return this.evaluateNumericRelationalNode(node, actual);
|
|
444
521
|
}
|
|
445
522
|
|
|
523
|
+
if (
|
|
524
|
+
(node.op === "in" || node.op === "notIn") &&
|
|
525
|
+
!Array.isArray(node.value)
|
|
526
|
+
) {
|
|
527
|
+
return this.reportInvalidSetOperand(node, actual);
|
|
528
|
+
}
|
|
529
|
+
|
|
446
530
|
return Result.ok(
|
|
447
531
|
this.evaluateOperator(actual, node.op, node.value),
|
|
448
532
|
);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
|
|
3
|
-
import type { ConditionLeafNode, ConditionNode } from "./condition-types";
|
|
3
|
+
import type { ConditionLeafNode, ConditionNode } from "./condition-types.js";
|
|
4
4
|
|
|
5
5
|
// ─── Shared v1 condition Zod schemas ─────────────────────────────────────────
|
|
6
6
|
// Extracted from gate/v1 so both gate/v1 and compute/v1 can validate
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { type CoreConfig, coreConfig } from "../../../../config";
|
|
2
|
-
import { Outcome } from "../../../../result/outcome";
|
|
3
|
-
import { Result } from "../../../../result/result";
|
|
1
|
+
import { type CoreConfig, coreConfig } from "../../../../config/index.js";
|
|
2
|
+
import { Outcome } from "../../../../result/outcome.js";
|
|
3
|
+
import { Result } from "../../../../result/result.js";
|
|
4
4
|
|
|
5
5
|
import {
|
|
6
6
|
ConditionEvaluatorV1,
|
|
7
7
|
type TracedConditionEvaluation,
|
|
8
|
-
} from "../condition-evaluator";
|
|
9
|
-
import type { ConditionLeafNode, ConditionNode } from "../condition-types";
|
|
10
|
-
import type { GatePayload } from "../../gate-payload";
|
|
8
|
+
} from "../condition-evaluator.js";
|
|
9
|
+
import type { ConditionLeafNode, ConditionNode } from "../condition-types.js";
|
|
10
|
+
import type { GatePayload } from "../../gate-payload.js";
|
|
11
11
|
import type {
|
|
12
12
|
GateOutcome,
|
|
13
13
|
GateStatus,
|
|
@@ -16,7 +16,7 @@ import type {
|
|
|
16
16
|
PolicyContext,
|
|
17
17
|
PolicyViolation,
|
|
18
18
|
VersionedGateEngine,
|
|
19
|
-
} from "../../gate-types";
|
|
19
|
+
} from "../../gate-types.js";
|
|
20
20
|
|
|
21
21
|
// ─── Gate engine v1 ─────────────────────────────────────────────────────────
|
|
22
22
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// The condition-tree DSL types are shared across the v1 engine family and live
|
|
3
3
|
// in engines/v1. Imported here for the GatePayloadV1 definition only — not
|
|
4
4
|
// re-exported; consumers should import condition types from engines/v1.
|
|
5
|
-
import type { ConditionNode } from "../condition-types";
|
|
5
|
+
import type { ConditionNode } from "../condition-types.js";
|
|
6
6
|
|
|
7
7
|
export type GatePayloadV1 =
|
|
8
8
|
| { readonly condition: ConditionNode }
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
|
|
3
|
-
import { Result } from "../../../../result/result";
|
|
3
|
+
import { Result } from "../../../../result/result.js";
|
|
4
4
|
|
|
5
|
-
import type { GatePayloadV1 } from "./gate-types-v1";
|
|
5
|
+
import type { GatePayloadV1 } from "./gate-types-v1.js";
|
|
6
6
|
import {
|
|
7
7
|
conditionLeafNodeSchema,
|
|
8
8
|
conditionNodeSchema,
|
|
9
|
-
} from "../condition-schema";
|
|
9
|
+
} from "../condition-schema.js";
|
|
10
10
|
|
|
11
11
|
// Re-export so gate/v1 public API remains unchanged.
|
|
12
12
|
export { conditionLeafNodeSchema, conditionNodeSchema };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export { ConditionEvaluatorV1 } from "../condition-evaluator";
|
|
2
|
-
export { GateEngineV1 } from "./gate-engine-v1";
|
|
3
|
-
export type { GatePayloadV1 } from "./gate-types-v1";
|
|
1
|
+
export { ConditionEvaluatorV1 } from "../condition-evaluator.js";
|
|
2
|
+
export { GateEngineV1 } from "./gate-engine-v1.js";
|
|
3
|
+
export type { GatePayloadV1 } from "./gate-types-v1.js";
|
|
4
4
|
export {
|
|
5
5
|
conditionLeafNodeSchema,
|
|
6
6
|
conditionNodeSchema,
|
|
7
7
|
gatePayloadSchema,
|
|
8
8
|
GatePayloadSchemaV1,
|
|
9
|
-
} from "./gate-v1-payload.schema";
|
|
9
|
+
} from "./gate-v1-payload.schema.js";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export { ConditionEvaluatorV1 } from "./condition-evaluator";
|
|
1
|
+
export { ConditionEvaluatorV1 } from "./condition-evaluator.js";
|
|
2
2
|
export {
|
|
3
3
|
conditionLeafNodeSchema,
|
|
4
4
|
conditionNodeSchema,
|
|
5
|
-
} from "./condition-schema";
|
|
5
|
+
} from "./condition-schema.js";
|
|
6
6
|
export type {
|
|
7
7
|
ConditionAndNode,
|
|
8
8
|
ConditionLeafNode,
|
|
@@ -10,4 +10,4 @@ export type {
|
|
|
10
10
|
ConditionNotNode,
|
|
11
11
|
ConditionOp,
|
|
12
12
|
ConditionOrNode,
|
|
13
|
-
} from "./condition-types";
|
|
13
|
+
} from "./condition-types.js";
|
|
@@ -2,30 +2,33 @@
|
|
|
2
2
|
// Re-exports all public types, classes and utilities.
|
|
3
3
|
|
|
4
4
|
// ─── Core Config ────────────────────────────────────────────────────────────
|
|
5
|
-
export type {
|
|
6
|
-
|
|
5
|
+
export type {
|
|
6
|
+
CoreConfigOptions,
|
|
7
|
+
CoreObservabilityConfig,
|
|
8
|
+
} from "../config/index.js";
|
|
9
|
+
export { CoreConfig, coreConfig } from "../config/index.js";
|
|
7
10
|
|
|
8
11
|
// ─── Result (technical execution) ───────────────────────────────────────────
|
|
9
|
-
export { Err, Ok, Result } from "../result/result";
|
|
12
|
+
export { Err, Ok, Result } from "../result/result.js";
|
|
10
13
|
|
|
11
14
|
// ─── Outcome (business decision) ───────────────────────────────────────────
|
|
12
|
-
export type { CommonOutcomeStatus } from "../result/outcome";
|
|
13
|
-
export { Outcome } from "../result/outcome";
|
|
15
|
+
export type { CommonOutcomeStatus } from "../result/outcome.js";
|
|
16
|
+
export { Outcome } from "../result/outcome.js";
|
|
14
17
|
|
|
15
18
|
// ─── Utils ──────────────────────────────────────────────────────────────────
|
|
16
|
-
export { PolicyHashing } from "./utils";
|
|
19
|
+
export { PolicyHashing } from "./utils/index.js";
|
|
17
20
|
export type {
|
|
18
21
|
PolicyDecisionId,
|
|
19
22
|
PolicyDefinitionId,
|
|
20
23
|
SchoolId,
|
|
21
24
|
TenantId,
|
|
22
|
-
} from "./policy-ids";
|
|
25
|
+
} from "./policy-ids.js";
|
|
23
26
|
export {
|
|
24
27
|
asPolicyDecisionId,
|
|
25
28
|
asPolicyDefinitionId,
|
|
26
29
|
asSchoolId,
|
|
27
30
|
asTenantId,
|
|
28
|
-
} from "./policy-ids";
|
|
31
|
+
} from "./policy-ids.js";
|
|
29
32
|
|
|
30
33
|
// ─── Catalog ────────────────────────────────────────────────────────────────
|
|
31
34
|
export type {
|
|
@@ -34,8 +37,12 @@ export type {
|
|
|
34
37
|
PolicyKind,
|
|
35
38
|
PolicyOwner,
|
|
36
39
|
PolicyScopeLevel,
|
|
37
|
-
} from "./catalog";
|
|
38
|
-
export {
|
|
40
|
+
} from "./catalog/index.js";
|
|
41
|
+
export {
|
|
42
|
+
PolicyCatalog,
|
|
43
|
+
PolicyCatalogFactory,
|
|
44
|
+
PolicyKey,
|
|
45
|
+
} from "./catalog/index.js";
|
|
39
46
|
|
|
40
47
|
// ─── Definitions ────────────────────────────────────────────────────────────
|
|
41
48
|
export type {
|
|
@@ -47,12 +54,12 @@ export type {
|
|
|
47
54
|
PolicyDefinitionStatus,
|
|
48
55
|
PolicyScope,
|
|
49
56
|
ScopeChain,
|
|
50
|
-
} from "./defs";
|
|
57
|
+
} from "./defs/index.js";
|
|
51
58
|
export {
|
|
52
59
|
InMemoryPolicyDefinitionRepository,
|
|
53
60
|
PolicyDefinition,
|
|
54
61
|
PolicyScopeMatcher,
|
|
55
|
-
} from "./defs";
|
|
62
|
+
} from "./defs/index.js";
|
|
56
63
|
|
|
57
64
|
// ─── Context ────────────────────────────────────────────────────────────────
|
|
58
65
|
export type {
|
|
@@ -62,7 +69,7 @@ export type {
|
|
|
62
69
|
ContextSeed,
|
|
63
70
|
ContextValueResolver,
|
|
64
71
|
PolicyContextBuilderOptions,
|
|
65
|
-
} from "./context";
|
|
72
|
+
} from "./context/index.js";
|
|
66
73
|
export {
|
|
67
74
|
ContextSeedValidator,
|
|
68
75
|
ContextResolverRegistry,
|
|
@@ -71,11 +78,11 @@ export {
|
|
|
71
78
|
PolicyContextPath,
|
|
72
79
|
registerNamespacedContextResolvers,
|
|
73
80
|
registerNamespacedContextResolversIn,
|
|
74
|
-
} from "./context";
|
|
81
|
+
} from "./context/index.js";
|
|
75
82
|
|
|
76
83
|
// ─── AsOf ───────────────────────────────────────────────────────────────────
|
|
77
|
-
export type { DeriveAsOfOptions } from "./asof";
|
|
78
|
-
export { PolicyAsOfResolver } from "./asof";
|
|
84
|
+
export type { DeriveAsOfOptions } from "./asof/index.js";
|
|
85
|
+
export { PolicyAsOfResolver } from "./asof/index.js";
|
|
79
86
|
|
|
80
87
|
// ─── Engines ────────────────────────────────────────────────────────────────
|
|
81
88
|
export type {
|
|
@@ -95,7 +102,7 @@ export type {
|
|
|
95
102
|
PolicyContext,
|
|
96
103
|
PolicyViolation,
|
|
97
104
|
VersionedGateEngine,
|
|
98
|
-
} from "./engines";
|
|
105
|
+
} from "./engines/index.js";
|
|
99
106
|
export type {
|
|
100
107
|
ComputeEvaluator,
|
|
101
108
|
ComputeEvaluatorRegistration,
|
|
@@ -103,7 +110,7 @@ export type {
|
|
|
103
110
|
ComputeOutcomeData,
|
|
104
111
|
ComputeStatus,
|
|
105
112
|
VersionedComputeEngine,
|
|
106
|
-
} from "./engines";
|
|
113
|
+
} from "./engines/index.js";
|
|
107
114
|
export {
|
|
108
115
|
ComputeEngineRegistry,
|
|
109
116
|
ComputeEvaluatorRegistry,
|
|
@@ -112,10 +119,10 @@ export {
|
|
|
112
119
|
ComputeRegistry,
|
|
113
120
|
GateEngineRegistry,
|
|
114
121
|
GatePayloadParsers,
|
|
115
|
-
} from "./engines";
|
|
122
|
+
} from "./engines/index.js";
|
|
116
123
|
|
|
117
124
|
// ─── Resolver ───────────────────────────────────────────────────────────────
|
|
118
|
-
export { PolicyResolver } from "./resolver";
|
|
125
|
+
export { PolicyResolver } from "./resolver/index.js";
|
|
119
126
|
|
|
120
127
|
// ─── Service ────────────────────────────────────────────────────────────────
|
|
121
128
|
export type {
|
|
@@ -125,8 +132,8 @@ export type {
|
|
|
125
132
|
PolicyEvaluationResult,
|
|
126
133
|
PolicyServiceParams,
|
|
127
134
|
PolicyServiceOptions,
|
|
128
|
-
} from "./service";
|
|
129
|
-
export { PolicyEvaluationErrors, PolicyService } from "./service";
|
|
135
|
+
} from "./service/index.js";
|
|
136
|
+
export { PolicyEvaluationErrors, PolicyService } from "./service/index.js";
|
|
130
137
|
|
|
131
138
|
// ─── Package (contribution protocol) ────────────────────────────────────────
|
|
132
|
-
export type { PolicyPackage } from "./package/policy-package";
|
|
139
|
+
export type { PolicyPackage } from "./package/policy-package.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { PolicyCatalogEntryProps } from "../catalog";
|
|
2
|
-
import type { PolicyDefinition } from "../defs";
|
|
3
|
-
import type { ComputeEvaluatorRegistration } from "../engines";
|
|
1
|
+
import type { PolicyCatalogEntryProps } from "../catalog/index.js";
|
|
2
|
+
import type { PolicyDefinition } from "../defs/index.js";
|
|
3
|
+
import type { ComputeEvaluatorRegistration } from "../engines/index.js";
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Protocol of contribution: a module declares what it wants to add to the
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { ValidationCode } from "../exceptions/validation-code";
|
|
2
|
-
import { InvalidValueException } from "../exceptions/validation-exception";
|
|
3
|
-
import { ValidationField } from "../exceptions/validation-field";
|
|
1
|
+
import { ValidationCode } from "../exceptions/validation-code.js";
|
|
2
|
+
import { InvalidValueException } from "../exceptions/validation-exception.js";
|
|
3
|
+
import { ValidationField } from "../exceptions/validation-field.js";
|
|
4
4
|
|
|
5
5
|
type Brand<TValue, TBrand extends string> = TValue & {
|
|
6
6
|
readonly __brand: TBrand;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { PolicyResolver } from "./policy-resolver";
|
|
1
|
+
export { PolicyResolver } from "./policy-resolver.js";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { PolicyDefinition } from "../defs";
|
|
2
|
-
import { PolicyScopeMatcher } from "../defs";
|
|
3
|
-
import { comparePolicySemver } from "../defs/policy-semver";
|
|
4
|
-
import { Result } from "../../result/result";
|
|
1
|
+
import type { PolicyDefinition } from "../defs/index.js";
|
|
2
|
+
import { PolicyScopeMatcher } from "../defs/index.js";
|
|
3
|
+
import { comparePolicySemver } from "../defs/policy-semver.js";
|
|
4
|
+
import { Result } from "../../result/result.js";
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Selects the best policy definition from a list of already-filtered candidates.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { PolicyService } from "./policy-service";
|
|
2
|
-
export { PolicyEvaluationErrors } from "./policy-evaluation-error";
|
|
1
|
+
export { PolicyService } from "./policy-service.js";
|
|
2
|
+
export { PolicyEvaluationErrors } from "./policy-evaluation-error.js";
|
|
3
3
|
export type {
|
|
4
4
|
EvaluateInput,
|
|
5
5
|
PolicyDecision,
|
|
@@ -7,4 +7,4 @@ export type {
|
|
|
7
7
|
PolicyEvaluationResult,
|
|
8
8
|
PolicyServiceOptions,
|
|
9
9
|
PolicyServiceParams,
|
|
10
|
-
} from "./policy-service";
|
|
10
|
+
} from "./policy-service.js";
|