@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
package/dist/index.d.ts
CHANGED
|
@@ -1,37 +1,36 @@
|
|
|
1
1
|
import { n as RequestedByKind, t as RequestedBy } from "./requested-by.js";
|
|
2
|
-
import { a as AbacPolicySet, c as
|
|
2
|
+
import { a as AbacPolicySet, c as AbacRule, d as abacContext, f as AbacAuthorizerPort, i as AbacDecision, l as AbacRuleProps, m as AbacRequest, n as CompositeAuthorizer, o as OnEvaluationError, p as AbacAttributes, r as AbacAuthorizer, s as CombiningAlgorithm, t as CompositeAccessRequest, u as RuleEffect } from "./composite-authorizer.js";
|
|
3
3
|
import { a as JsonSafeRecord, i as JsonSafePrimitive, n as AppErrorOptions, o as JsonSafeValue, r as ErrorSeverity, t as AppError } from "./app-error.js";
|
|
4
4
|
import { i as AuthorizationRequirement, n as AuthorizationErrorMetadata, r as AuthorizationErrorReason, t as AuthorizationError } from "./authorization-error.js";
|
|
5
5
|
import { n as Ok, r as Result, t as Err } from "./result.js";
|
|
6
6
|
import { n as Outcome, t as CommonOutcomeStatus } from "./outcome.js";
|
|
7
|
-
import { C as
|
|
7
|
+
import { C as GateViolationTrace, D as GatePayload, E as VersionedGateEngine, S as GateTraceNodeSnapshot, T as PolicyViolation, _ as ConditionEvaluatorReporter, a as PolicyDefinitionId, b as GateStatus, c as asPolicyDecisionId, d as asTenantId, f as ConditionEvaluationCause, g as ConditionEvaluationReportTag, h as ConditionEvaluationReportLevel, i as PolicyDecisionId, l as asPolicyDefinitionId, m as ConditionEvaluationReport, n as CoreConfigOptions, o as SchoolId, p as ConditionEvaluationOptions, r as CoreObservabilityConfig, s as TenantId, t as CoreConfig, u as asSchoolId, v as GateOutcome, w as PolicyContext, x as GateTraceLeafSnapshot, y as GateOutcomeData } from "./core-config.js";
|
|
8
8
|
import { a as PolicyPackage, c as coreConfig, i as PolicyCatalogFactory, n as contextResolverRegistry, o as InMemoryPolicyDefinitionRepository, r as registerNamespacedContextResolvers, s as PolicyHashing, t as PolicyContextPath } from "./path.js";
|
|
9
9
|
import { a as PluginContract, i as PipelineReducer, n as BasePlugin, r as InvokeOptions, t as PluginManager } from "./plugin.js";
|
|
10
10
|
import { t as DeepReadonly } from "./immutable.js";
|
|
11
11
|
import { i as version, n as ContractVersion, r as VersionedTarget, t as CONTRACT_VERSION_PROPERTY } from "./version.js";
|
|
12
12
|
import { n as ValueObjectPluginContract, t as ValueObject } from "./value-object.js";
|
|
13
13
|
import { a as Permission, i as ScopeProps, n as AccessRequest, o as PermissionProps, r as Scope, t as AuthorizerPort } from "./authorizer.port.js";
|
|
14
|
-
import { A as
|
|
15
|
-
import { A as IdempotencyPayloadMismatchError, B as UniqueConstraintViolation, C as IntegrationErrorMetadata, D as IdempotencyFailureKind, E as IdempotencyErrorMetadata, F as AlreadyExistsError, G as AuthenticationErrorMetadata, H as translateUniqueViolationToDuplicate, I as ConflictError, J as ErrorCodes, K as AuthenticationErrorReason, L as ConflictErrorMetadata, M as
|
|
14
|
+
import { A as MetricLabels, C as CommandInput, D as TraceAttributeValue, E as UseCaseObservability, M as LogPayload, N as LoggerPort, O as TraceSpan, S as Command, T as UseCase, _ as ResultRepository, a as TemporalContext, b as PolicyPort, c as CacheStrategy, d as QueryOutput, f as mapPolicyEvaluationError, g as Repository, h as TemporalRepository, i as CreateTemporalContextInput, j as MetricsPort, k as TracerPort, l as Page, m as TemporalHistory, n as TemporalUseCaseInput, o as assertTemporalContext, p as ResultTemporalRepository, r as TemporalizedContextSeed, s as createTemporalContext, t as TemporalUseCase, u as Query, v as PolicyEvaluationInput, w as MaybePromise, x as PolicyPortError, y as PolicyEvaluationOutput } from "./temporal-use-case.js";
|
|
15
|
+
import { A as IdempotencyPayloadMismatchError, B as UniqueConstraintViolation, C as IntegrationErrorMetadata, D as IdempotencyFailureKind, E as IdempotencyErrorMetadata, F as AlreadyExistsError, G as AuthenticationErrorMetadata, H as translateUniqueViolationToDuplicate, I as ConflictError, J as ErrorCodes, K as AuthenticationErrorReason, L as ConflictErrorMetadata, M as stableStringify, N as payloadHash, O as IdempotencyInProgressError, P as sha256Hex, R as ConflictKind, S as IntegrationError, T as IdempotencyError, U as BusinessRuleViolationError, V as UniqueConstraintViolationError, W as AuthenticationError, Y as serializationErrorCode, _ as SerializationMessages, a as TemporalError, b as NotFoundError, c as TemporalPrecision, d as SerializationCodes, f as SerializationDirection, g as SerializationInError, h as SerializationFailureCategory, i as NotYetValidError, j as IdempotencyReplayNotSupportedError, k as IdempotencyKeyMissingError, l as evaluateTemporalWindow, m as SerializationErrorMetadata, n as UnexpectedError, o as TemporalErrorMetadata, p as SerializationError, q as assertJsonSafeMetadata, r as ExpiredError, s as TemporalKind, t as ValidationError, u as SerializationBoundary, v as SerializationOutError, w as IntegrationErrorReason, x as LegacyIncompatibleError, y as safePreview, z as DuplicateError } from "./validation-error.js";
|
|
16
16
|
import { t as ValidationCode } from "./validation-code.js";
|
|
17
17
|
import { t as ValidationField } from "./validation-field.js";
|
|
18
18
|
import { A as PolicyScope, C as BasePolicyDefinitionProps, D as PolicyDefinition, E as GatePolicyDefinitionProps, F as PolicyKey, I as AsOfSource, L as PolicyKind, M as ScopeChain, N as PolicyCatalog, O as PolicyDefinitionProps, P as PolicyCatalogEntryProps, R as PolicyOwner, T as FindCandidatesParams, _ as ContextResolverResilienceOptions, a as PolicyServiceOptions, b as ContextSeed, c as PolicyEvaluationErrors, d as PolicyAsOfResolver, f as PolicyContextBuilder, g as ContextResolverCircuitBreakerOptions, h as registerNamespacedContextResolversIn, i as PolicyService, j as PolicyScopeMatcher, k as PolicyDefinitionStatus, l as PolicyResolver, m as ContextResolverRegistry, n as PolicyDecision, o as PolicyServiceParams, p as PolicyContextBuilderOptions, r as PolicyEvaluationResult, s as PolicyEvaluationError, t as EvaluateInput, u as DeriveAsOfOptions, v as ContextResolverRetryOptions, w as ComputePolicyDefinitionProps, x as ContextSeedValidator, y as ContextValueResolver, z as PolicyScopeLevel } from "./policy-service.js";
|
|
19
19
|
import { a as ComputeOutcome, c as VersionedComputeEngine, i as ComputeEvaluatorRegistration, n as ComputeRegistry, o as ComputeOutcomeData, r as ComputeEvaluator, s as ComputeStatus, t as GateEngineRegistry } from "./gate-engine-registry.js";
|
|
20
20
|
import { a as ComputePayloadParserRegistry, c as ComputeEvaluatorRegistry, o as ComputePayloadParsers, r as GatePayloadParsers, s as ComputeEngineRegistry } from "./parse-gate-payload.js";
|
|
21
21
|
import { n as Entity, r as EntityState, t as UuidIdentifier } from "./uuid-identifier.js";
|
|
22
|
-
import {
|
|
23
|
-
import { a as InvariantViolationException, c as BusinessRuleViolationException, i as ValidationViolation, n as MultipleValidationException, o as InvalidStateTransitionException, r as ValidationException, s as EntityNotFoundException, t as InvalidValueException } from "./validation-exception.js";
|
|
22
|
+
import { a as InvariantViolationException, c as BusinessRuleViolationException, i as ValidationViolation, l as DomainException, n as MultipleValidationException, o as InvalidStateTransitionException, r as ValidationException, s as EntityNotFoundException, t as InvalidValueException } from "./validation-exception.js";
|
|
24
23
|
import { a as Ruleset, i as InvariantRuleset, n as RulesetRegistry, o as RulesetId, r as CreationRuleset, t as ValueObjectRuleset } from "./value-object-ruleset.contracts.js";
|
|
25
24
|
import { a as GrantProps, i as Grant, n as PermissionSet, o as Role, r as RbacAuthorizer, s as RoleProps, t as rbacContextFields } from "./policy-bridge.js";
|
|
26
|
-
import { a as
|
|
25
|
+
import { a as DomainEventEnvelope, i as DomainEventContractVersions, n as CreateDomainEventEnvelopeInput, o as buildDomainEventContractVersions, r as DomainEventContractSelection, s as createDomainEventEnvelope, t as ContractVersioned } from "./domain-event-contracts.js";
|
|
27
26
|
|
|
28
27
|
//#region src/index.d.ts
|
|
29
28
|
declare const ERP_CORE_NAME = "erp-core";
|
|
30
|
-
declare const ERP_CORE_VERSION = "
|
|
29
|
+
declare const ERP_CORE_VERSION = "2.0.0";
|
|
31
30
|
declare const erpCoreRelease: {
|
|
32
31
|
readonly name: "erp-core";
|
|
33
|
-
readonly version: "
|
|
32
|
+
readonly version: "2.0.0";
|
|
34
33
|
};
|
|
35
34
|
//#endregion
|
|
36
|
-
export { AbacAttributes, AbacAuthorizer, AbacAuthorizerPort, AbacDecision, AbacPolicySet, AbacRequest, AbacRule, AbacRuleProps, AccessRequest, AlreadyExistsError, AppError, AppErrorOptions, AsOfSource, AuthenticationError, AuthenticationErrorMetadata, AuthenticationErrorReason, AuthorizationError, AuthorizationErrorMetadata, AuthorizationErrorReason, AuthorizationRequirement, AuthorizerPort, BasePlugin, BasePolicyDefinitionProps, BusinessRuleViolationError, BusinessRuleViolationException, CONTRACT_VERSION_PROPERTY, CacheStrategy, CombiningAlgorithm, Command, CommandInput, CommonOutcomeStatus, CompositeAccessRequest, CompositeAuthorizer, ComputeEngineRegistry, ComputeEvaluator, ComputeEvaluatorRegistration, ComputeEvaluatorRegistry, ComputeOutcome, ComputeOutcomeData, ComputePayloadParserRegistry, ComputePayloadParsers, ComputePolicyDefinitionProps, ComputeRegistry, ComputeStatus, ConditionEvaluationCause, ConditionEvaluationOptions, ConditionEvaluationReport, ConditionEvaluationReportLevel, ConditionEvaluationReportTag, ConditionEvaluatorReporter, ConflictError, ConflictErrorMetadata, ConflictKind, ContextResolverCircuitBreakerOptions, ContextResolverRegistry, ContextResolverResilienceOptions, ContextResolverRetryOptions, ContextSeed, ContextSeedValidator, ContextValueResolver, ContractVersion, CoreConfig, CoreConfigOptions, CoreObservabilityConfig, CreateDomainEventEnvelopeInput, CreateTemporalContextInput, CreationRuleset, DeepReadonly, DeriveAsOfOptions, SerializationInError as DeserializationError, SerializationInError, DomainEventContractSelection, DomainEventContractVersions, DomainEventEnvelope, DomainException, DuplicateError, ERP_CORE_NAME, ERP_CORE_VERSION, Entity, EntityNotFoundException, EntityState, Err, ErrorCodes, ErrorSeverity, EvaluateInput, ExpiredError, TemporalErrorMetadata as ExpiredErrorMetadata, TemporalErrorMetadata, TemporalPrecision as ExpiredErrorPrecision, TemporalPrecision, FindCandidatesParams, GateEngineRegistry, GateOutcome, GateOutcomeData, GatePayload, GatePayloadParsers, GatePolicyDefinitionProps, GateStatus, GateTraceLeafSnapshot, GateTraceNodeSnapshot, GateViolationTrace, Grant, GrantProps, IdempotencyError, IdempotencyErrorMetadata, IdempotencyFailureKind, IdempotencyInProgressError, IdempotencyKeyMissingError, IdempotencyPayloadMismatchError, IdempotencyReplayNotSupportedError, InMemoryPolicyDefinitionRepository, IntegrationError, IntegrationErrorMetadata, IntegrationErrorReason, InvalidStateTransitionException, InvalidValueException, InvariantRuleset, InvariantViolationException, InvokeOptions, JsonSafePrimitive, JsonSafeRecord, JsonSafeValue, LegacyIncompatibleError, LogPayload, LoggerPort, MaybePromise, MetricLabels, MetricsPort, MultipleValidationException, NotFoundError, NotYetValidError, Ok, Outcome, Page, Permission, PermissionProps, PermissionSet, PipelineReducer, PluginContract, PluginManager, PolicyAsOfResolver, PolicyCatalog, PolicyCatalogEntryProps, PolicyCatalogFactory, PolicyContext, PolicyContextBuilder, PolicyContextBuilderOptions, PolicyContextPath, PolicyDecision, PolicyDecisionId, PolicyDefinition, PolicyDefinitionId, PolicyDefinitionProps, PolicyDefinitionStatus, PolicyEvaluationError, PolicyEvaluationErrors, PolicyEvaluationInput, PolicyEvaluationOutput, PolicyEvaluationResult, PolicyHashing, PolicyKey, PolicyKind, PolicyOwner, PolicyPackage, PolicyPort, PolicyPortError, PolicyResolver, PolicyScope, PolicyScopeLevel, PolicyScopeMatcher, PolicyService, PolicyServiceOptions, PolicyServiceParams, PolicyViolation, Query, RbacAuthorizer, Repository, RequestedBy, RequestedByKind, Result, ResultRepository, Role, RoleProps, RuleEffect, Ruleset, RulesetId, RulesetRegistry, SchoolId, Scope, ScopeChain, ScopeProps, SerializationBoundary, SerializationCodes, SerializationDirection, SerializationError, SerializationErrorMetadata, SerializationFailureCategory, SerializationMessages, SerializationOutError, TemporalContext, TemporalError, TemporalHistory, TemporalKind, TemporalRepository, TemporalUseCase, TemporalUseCaseInput, TemporalizedContextSeed, TenantId, TraceAttributeValue, TraceSpan, TracerPort, UnexpectedError, UniqueConstraintViolation, UniqueConstraintViolationError, UseCase, UseCaseObservability, UuidIdentifier, ValidationCode, ValidationError, ValidationException, ValidationField, ValidationViolation, ValueObject, ValueObjectPluginContract, ValueObjectRuleset, VersionedComputeEngine, VersionedGateEngine, VersionedTarget, abacContext, asPolicyDecisionId, asPolicyDefinitionId, asSchoolId, asTenantId, assertJsonSafeMetadata, assertTemporalContext, buildDomainEventContractVersions, contextResolverRegistry, coreConfig, createDomainEventEnvelope, createTemporalContext, erpCoreRelease, evaluateTemporalWindow, mapPolicyEvaluationError, payloadHash, rbacContextFields, registerNamespacedContextResolvers, registerNamespacedContextResolversIn, safePreview, serializationErrorCode, sha256Hex, stableStringify, translateUniqueViolationToDuplicate, version };
|
|
35
|
+
export { AbacAttributes, AbacAuthorizer, AbacAuthorizerPort, AbacDecision, AbacPolicySet, AbacRequest, AbacRule, AbacRuleProps, AccessRequest, AlreadyExistsError, AppError, AppErrorOptions, AsOfSource, AuthenticationError, AuthenticationErrorMetadata, AuthenticationErrorReason, AuthorizationError, AuthorizationErrorMetadata, AuthorizationErrorReason, AuthorizationRequirement, AuthorizerPort, BasePlugin, BasePolicyDefinitionProps, BusinessRuleViolationError, BusinessRuleViolationException, CONTRACT_VERSION_PROPERTY, CacheStrategy, CombiningAlgorithm, Command, CommandInput, CommonOutcomeStatus, CompositeAccessRequest, CompositeAuthorizer, ComputeEngineRegistry, ComputeEvaluator, ComputeEvaluatorRegistration, ComputeEvaluatorRegistry, ComputeOutcome, ComputeOutcomeData, ComputePayloadParserRegistry, ComputePayloadParsers, ComputePolicyDefinitionProps, ComputeRegistry, ComputeStatus, ConditionEvaluationCause, ConditionEvaluationOptions, ConditionEvaluationReport, ConditionEvaluationReportLevel, ConditionEvaluationReportTag, ConditionEvaluatorReporter, ConflictError, ConflictErrorMetadata, ConflictKind, ContextResolverCircuitBreakerOptions, ContextResolverRegistry, ContextResolverResilienceOptions, ContextResolverRetryOptions, ContextSeed, ContextSeedValidator, ContextValueResolver, ContractVersion, ContractVersioned, CoreConfig, CoreConfigOptions, CoreObservabilityConfig, CreateDomainEventEnvelopeInput, CreateTemporalContextInput, CreationRuleset, DeepReadonly, DeriveAsOfOptions, SerializationInError as DeserializationError, SerializationInError, DomainEventContractSelection, DomainEventContractVersions, DomainEventEnvelope, DomainException, DuplicateError, ERP_CORE_NAME, ERP_CORE_VERSION, Entity, EntityNotFoundException, EntityState, Err, ErrorCodes, ErrorSeverity, EvaluateInput, ExpiredError, TemporalErrorMetadata as ExpiredErrorMetadata, TemporalErrorMetadata, TemporalPrecision as ExpiredErrorPrecision, TemporalPrecision, FindCandidatesParams, GateEngineRegistry, GateOutcome, GateOutcomeData, GatePayload, GatePayloadParsers, GatePolicyDefinitionProps, GateStatus, GateTraceLeafSnapshot, GateTraceNodeSnapshot, GateViolationTrace, Grant, GrantProps, IdempotencyError, IdempotencyErrorMetadata, IdempotencyFailureKind, IdempotencyInProgressError, IdempotencyKeyMissingError, IdempotencyPayloadMismatchError, IdempotencyReplayNotSupportedError, InMemoryPolicyDefinitionRepository, IntegrationError, IntegrationErrorMetadata, IntegrationErrorReason, InvalidStateTransitionException, InvalidValueException, InvariantRuleset, InvariantViolationException, InvokeOptions, JsonSafePrimitive, JsonSafeRecord, JsonSafeValue, LegacyIncompatibleError, LogPayload, LoggerPort, MaybePromise, MetricLabels, MetricsPort, MultipleValidationException, NotFoundError, NotYetValidError, Ok, OnEvaluationError, Outcome, Page, Permission, PermissionProps, PermissionSet, PipelineReducer, PluginContract, PluginManager, PolicyAsOfResolver, PolicyCatalog, PolicyCatalogEntryProps, PolicyCatalogFactory, PolicyContext, PolicyContextBuilder, PolicyContextBuilderOptions, PolicyContextPath, PolicyDecision, PolicyDecisionId, PolicyDefinition, PolicyDefinitionId, PolicyDefinitionProps, PolicyDefinitionStatus, PolicyEvaluationError, PolicyEvaluationErrors, PolicyEvaluationInput, PolicyEvaluationOutput, PolicyEvaluationResult, PolicyHashing, PolicyKey, PolicyKind, PolicyOwner, PolicyPackage, PolicyPort, PolicyPortError, PolicyResolver, PolicyScope, PolicyScopeLevel, PolicyScopeMatcher, PolicyService, PolicyServiceOptions, PolicyServiceParams, PolicyViolation, Query, QueryOutput, RbacAuthorizer, Repository, RequestedBy, RequestedByKind, Result, ResultRepository, ResultTemporalRepository, Role, RoleProps, RuleEffect, Ruleset, RulesetId, RulesetRegistry, SchoolId, Scope, ScopeChain, ScopeProps, SerializationBoundary, SerializationCodes, SerializationDirection, SerializationError, SerializationErrorMetadata, SerializationFailureCategory, SerializationMessages, SerializationOutError, TemporalContext, TemporalError, TemporalHistory, TemporalKind, TemporalRepository, TemporalUseCase, TemporalUseCaseInput, TemporalizedContextSeed, TenantId, TraceAttributeValue, TraceSpan, TracerPort, UnexpectedError, UniqueConstraintViolation, UniqueConstraintViolationError, UseCase, UseCaseObservability, UuidIdentifier, ValidationCode, ValidationError, ValidationException, ValidationField, ValidationViolation, ValueObject, ValueObjectPluginContract, ValueObjectRuleset, VersionedComputeEngine, VersionedGateEngine, VersionedTarget, abacContext, asPolicyDecisionId, asPolicyDefinitionId, asSchoolId, asTenantId, assertJsonSafeMetadata, assertTemporalContext, buildDomainEventContractVersions, contextResolverRegistry, coreConfig, createDomainEventEnvelope, createTemporalContext, erpCoreRelease, evaluateTemporalWindow, mapPolicyEvaluationError, payloadHash, rbacContextFields, registerNamespacedContextResolvers, registerNamespacedContextResolversIn, safePreview, serializationErrorCode, sha256Hex, stableStringify, translateUniqueViolationToDuplicate, version };
|
|
37
36
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -1,23 +1,22 @@
|
|
|
1
1
|
import { i as serializationErrorCode, n as assertJsonSafeMetadata, r as ErrorCodes, t as AppError } from "./app-error.js";
|
|
2
|
-
import { C as translateUniqueViolationToDuplicate, S as UniqueConstraintViolationError, _ as IdempotencyPayloadMismatchError, a as evaluateTemporalWindow, b as ConflictError, c as SerializationInError, d as safePreview, f as LegacyIncompatibleError, g as IdempotencyKeyMissingError, h as IdempotencyInProgressError, i as TemporalError, l as SerializationMessages, m as IdempotencyError, n as ExpiredError, o as SerializationCodes, p as IntegrationError, r as NotYetValidError, s as SerializationError, t as ValidationError, u as SerializationOutError, v as IdempotencyReplayNotSupportedError, w as AuthenticationError, x as DuplicateError, y as AlreadyExistsError } from "./validation-error.js";
|
|
3
2
|
import { t as AuthorizationError } from "./authorization-error.js";
|
|
3
|
+
import { C as translateUniqueViolationToDuplicate, S as UniqueConstraintViolationError, _ as IdempotencyPayloadMismatchError, a as evaluateTemporalWindow, b as ConflictError, c as SerializationInError, d as safePreview, f as LegacyIncompatibleError, g as IdempotencyKeyMissingError, h as IdempotencyInProgressError, i as TemporalError, l as SerializationMessages, m as IdempotencyError, n as ExpiredError, o as SerializationCodes, p as IntegrationError, r as NotYetValidError, s as SerializationError, t as ValidationError, u as SerializationOutError, v as IdempotencyReplayNotSupportedError, w as AuthenticationError, x as DuplicateError, y as AlreadyExistsError } from "./validation-error.js";
|
|
4
4
|
import { n as BusinessRuleViolationError, t as NotFoundError } from "./not-found-error.js";
|
|
5
|
-
import {
|
|
5
|
+
import { t as DomainException } from "./domain-exception.js";
|
|
6
|
+
import { t as InvariantViolationException } from "./invariant-violation-exception.js";
|
|
7
|
+
import { n as stableStringify } from "./stable-stringify.js";
|
|
8
|
+
import { n as sha256Hex, t as payloadHash } from "./hashing.js";
|
|
6
9
|
import { t as UnexpectedError } from "./unexpected-error.js";
|
|
7
10
|
import { t as ValidationCode } from "./validation-code.js";
|
|
8
11
|
import { t as ValidationField } from "./validation-field.js";
|
|
9
|
-
import { t as DomainException } from "./domain-exception.js";
|
|
10
12
|
import { n as EntityNotFoundException, r as BusinessRuleViolationException, t as InvalidStateTransitionException } from "./invalid-state-transition-exception.js";
|
|
11
|
-
import { t as InvariantViolationException } from "./invariant-violation-exception.js";
|
|
12
13
|
import { n as MultipleValidationException, r as ValidationException, t as InvalidValueException } from "./validation-exception.js";
|
|
13
14
|
import { i as version, r as CONTRACT_VERSION_PROPERTY } from "./immutable.js";
|
|
14
|
-
import {
|
|
15
|
+
import { a as mapPolicyEvaluationError, i as Query, n as assertTemporalContext, o as Command, r as createTemporalContext, s as UseCase, t as TemporalUseCase } from "./temporal-use-case.js";
|
|
15
16
|
import { t as RequestedBy } from "./requested-by.js";
|
|
16
|
-
import { a as mapPolicyEvaluationError, i as Query, n as assertTemporalContext, o as Command, r as createTemporalContext, t as TemporalUseCase } from "./temporal-use-case.js";
|
|
17
|
-
import { t as Entity } from "./entity.js";
|
|
18
17
|
import { t as PluginManager } from "./plugin.js";
|
|
19
18
|
import { t as ValueObject } from "./value-object.js";
|
|
20
|
-
import { t as UuidIdentifier } from "./uuid-identifier.js";
|
|
19
|
+
import { n as Entity, t as UuidIdentifier } from "./uuid-identifier.js";
|
|
21
20
|
import { t as RulesetRegistry } from "./ruleset-registry.js";
|
|
22
21
|
import { n as Ok, r as Result, t as Err } from "./result.js";
|
|
23
22
|
import { a as Role, i as Scope, n as PermissionSet, o as Permission, r as Grant, s as RbacAuthorizer, t as rbacContextFields } from "./policy-bridge.js";
|
|
@@ -28,7 +27,7 @@ import { n as createDomainEventEnvelope, t as buildDomainEventContractVersions }
|
|
|
28
27
|
import { t as Outcome } from "./outcome.js";
|
|
29
28
|
import { a as ComputeEvaluatorRegistry, c as ComputePayloadParsers, i as ComputeRegistry, o as ComputeEngineRegistry, r as GatePayloadParsers, s as ComputePayloadParserRegistry, t as GateEngineRegistry } from "./gate-engine-registry.js";
|
|
30
29
|
//#region src/version.ts
|
|
31
|
-
const version$1 = "
|
|
30
|
+
const version$1 = "2.0.0";
|
|
32
31
|
//#endregion
|
|
33
32
|
//#region src/index.ts
|
|
34
33
|
const ERP_CORE_NAME = "erp-core";
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["version","version"],"sources":["../src/version.ts","../src/index.ts"],"sourcesContent":["// Versao do kit, sincronizada com package.json por scripts/sync-kit-version.mjs.\n// Nao edite a mao: rode `npm run sync-kit-version` (ou e regenerado no release).\n//\n// Mantemos a versao aqui, dentro de src/, para que a copia full-control seja\n// auto-contida: ao copiar so o conteudo de src/, o entry nao depende de um\n// `../package.json` que deixaria de existir no projeto consumidor.\nexport const version = \"
|
|
1
|
+
{"version":3,"file":"index.js","names":["version","version"],"sources":["../src/version.ts","../src/index.ts"],"sourcesContent":["// Versao do kit, sincronizada com package.json por scripts/sync-kit-version.mjs.\n// Nao edite a mao: rode `npm run sync-kit-version` (ou e regenerado no release).\n//\n// Mantemos a versao aqui, dentro de src/, para que a copia full-control seja\n// auto-contida: ao copiar so o conteudo de src/, o entry nao depende de um\n// `../package.json` que deixaria de existir no projeto consumidor.\nexport const version = \"2.0.0\";\n","import { version } from \"./version.js\";\n\nexport * from \"./core/index.js\";\n\nexport const ERP_CORE_NAME = \"erp-core\";\nexport const ERP_CORE_VERSION = version;\n\nexport const erpCoreRelease = {\n name: ERP_CORE_NAME,\n version: ERP_CORE_VERSION,\n} as const;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMA,MAAaA,YAAU;;;ACFvB,MAAa,gBAAgB;AAC7B,MAAa,mBAAmBC;AAEhC,MAAa,iBAAiB;CAC1B,MAAM;CACN,SAAS;AACb"}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
const require_domain_exception = require("./domain-exception.cjs");
|
|
2
2
|
//#region src/core/exceptions/business-rule-violation-exception.ts
|
|
3
3
|
var BusinessRuleViolationException = class extends require_domain_exception.DomainException {
|
|
4
|
-
constructor(rule, message) {
|
|
5
|
-
super(message);
|
|
4
|
+
constructor(rule, message, options) {
|
|
5
|
+
super(message, options);
|
|
6
6
|
this.rule = rule;
|
|
7
7
|
}
|
|
8
8
|
};
|
|
9
9
|
//#endregion
|
|
10
10
|
//#region src/core/exceptions/entity-not-found-exception.ts
|
|
11
11
|
var EntityNotFoundException = class extends require_domain_exception.DomainException {
|
|
12
|
-
constructor(entityName, identifier) {
|
|
13
|
-
super(`${entityName} with identifier ${identifier} was not found
|
|
12
|
+
constructor(entityName, identifier, options) {
|
|
13
|
+
super(`${entityName} with identifier ${identifier} was not found.`, options);
|
|
14
14
|
this.entityName = entityName;
|
|
15
15
|
this.identifier = identifier;
|
|
16
16
|
}
|
|
@@ -18,8 +18,8 @@ var EntityNotFoundException = class extends require_domain_exception.DomainExcep
|
|
|
18
18
|
//#endregion
|
|
19
19
|
//#region src/core/exceptions/invalid-state-transition-exception.ts
|
|
20
20
|
var InvalidStateTransitionException = class extends require_domain_exception.DomainException {
|
|
21
|
-
constructor(from, to, message) {
|
|
22
|
-
super(message);
|
|
21
|
+
constructor(from, to, message, options) {
|
|
22
|
+
super(message ?? `Cannot transition from ${from} to ${to}.`, options);
|
|
23
23
|
this.from = from;
|
|
24
24
|
this.to = to;
|
|
25
25
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"invalid-state-transition-exception.cjs","names":["DomainException","DomainException","DomainException"],"sources":["../src/core/exceptions/business-rule-violation-exception.ts","../src/core/exceptions/entity-not-found-exception.ts","../src/core/exceptions/invalid-state-transition-exception.ts"],"sourcesContent":["import { DomainException } from \"./domain-exception.js\";\n\nclass BusinessRuleViolationException extends DomainException {\n constructor(\n public readonly rule: string,\n message: string,\n ) {\n super(message);\n }\n}\n\nexport { BusinessRuleViolationException };\n","import { DomainException } from \"./domain-exception.js\";\n\nclass EntityNotFoundException extends DomainException {\n constructor(\n public readonly entityName: string,\n public readonly identifier: string,\n ) {\n super(`${entityName} with identifier ${identifier} was not found
|
|
1
|
+
{"version":3,"file":"invalid-state-transition-exception.cjs","names":["DomainException","DomainException","DomainException"],"sources":["../src/core/exceptions/business-rule-violation-exception.ts","../src/core/exceptions/entity-not-found-exception.ts","../src/core/exceptions/invalid-state-transition-exception.ts"],"sourcesContent":["import { DomainException } from \"./domain-exception.js\";\n\nclass BusinessRuleViolationException extends DomainException {\n constructor(\n public readonly rule: string,\n message: string,\n options?: { cause?: unknown },\n ) {\n super(message, options);\n }\n}\n\nexport { BusinessRuleViolationException };\n","import { DomainException } from \"./domain-exception.js\";\n\nclass EntityNotFoundException extends DomainException {\n constructor(\n public readonly entityName: string,\n public readonly identifier: string,\n options?: { cause?: unknown },\n ) {\n super(\n `${entityName} with identifier ${identifier} was not found.`,\n options,\n );\n }\n}\n\nexport { EntityNotFoundException };\n","import { DomainException } from \"./domain-exception.js\";\n\nclass InvalidStateTransitionException<\n TState extends string = string,\n> extends DomainException {\n constructor(\n public readonly from: TState,\n public readonly to: TState,\n message?: string,\n options?: { cause?: unknown },\n ) {\n // Compose a sensible default from `from`/`to` when no message is given,\n // mirroring how EntityNotFoundException builds its own message.\n super(message ?? `Cannot transition from ${from} to ${to}.`, options);\n }\n}\n\nexport { InvalidStateTransitionException };\n"],"mappings":";;AAEA,IAAM,iCAAN,cAA6CA,yBAAAA,gBAAgB;CACzD,YACI,MACA,SACA,SACF;EACE,MAAM,SAAS,OAAO;EAJN,KAAA,OAAA;CAKpB;AACJ;;;ACRA,IAAM,0BAAN,cAAsCC,yBAAAA,gBAAgB;CAClD,YACI,YACA,YACA,SACF;EACE,MACI,GAAG,WAAW,mBAAmB,WAAW,kBAC5C,OACJ;EAPgB,KAAA,aAAA;EACA,KAAA,aAAA;CAOpB;AACJ;;;ACXA,IAAM,kCAAN,cAEUC,yBAAAA,gBAAgB;CACtB,YACI,MACA,IACA,SACA,SACF;EAGE,MAAM,WAAW,0BAA0B,KAAK,MAAM,GAAG,IAAI,OAAO;EAPpD,KAAA,OAAA;EACA,KAAA,KAAA;CAOpB;AACJ"}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { t as DomainException } from "./domain-exception.js";
|
|
2
2
|
//#region src/core/exceptions/business-rule-violation-exception.ts
|
|
3
3
|
var BusinessRuleViolationException = class extends DomainException {
|
|
4
|
-
constructor(rule, message) {
|
|
5
|
-
super(message);
|
|
4
|
+
constructor(rule, message, options) {
|
|
5
|
+
super(message, options);
|
|
6
6
|
this.rule = rule;
|
|
7
7
|
}
|
|
8
8
|
};
|
|
9
9
|
//#endregion
|
|
10
10
|
//#region src/core/exceptions/entity-not-found-exception.ts
|
|
11
11
|
var EntityNotFoundException = class extends DomainException {
|
|
12
|
-
constructor(entityName, identifier) {
|
|
13
|
-
super(`${entityName} with identifier ${identifier} was not found
|
|
12
|
+
constructor(entityName, identifier, options) {
|
|
13
|
+
super(`${entityName} with identifier ${identifier} was not found.`, options);
|
|
14
14
|
this.entityName = entityName;
|
|
15
15
|
this.identifier = identifier;
|
|
16
16
|
}
|
|
@@ -18,8 +18,8 @@ var EntityNotFoundException = class extends DomainException {
|
|
|
18
18
|
//#endregion
|
|
19
19
|
//#region src/core/exceptions/invalid-state-transition-exception.ts
|
|
20
20
|
var InvalidStateTransitionException = class extends DomainException {
|
|
21
|
-
constructor(from, to, message) {
|
|
22
|
-
super(message);
|
|
21
|
+
constructor(from, to, message, options) {
|
|
22
|
+
super(message ?? `Cannot transition from ${from} to ${to}.`, options);
|
|
23
23
|
this.from = from;
|
|
24
24
|
this.to = to;
|
|
25
25
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"invalid-state-transition-exception.js","names":[],"sources":["../src/core/exceptions/business-rule-violation-exception.ts","../src/core/exceptions/entity-not-found-exception.ts","../src/core/exceptions/invalid-state-transition-exception.ts"],"sourcesContent":["import { DomainException } from \"./domain-exception.js\";\n\nclass BusinessRuleViolationException extends DomainException {\n constructor(\n public readonly rule: string,\n message: string,\n ) {\n super(message);\n }\n}\n\nexport { BusinessRuleViolationException };\n","import { DomainException } from \"./domain-exception.js\";\n\nclass EntityNotFoundException extends DomainException {\n constructor(\n public readonly entityName: string,\n public readonly identifier: string,\n ) {\n super(`${entityName} with identifier ${identifier} was not found
|
|
1
|
+
{"version":3,"file":"invalid-state-transition-exception.js","names":[],"sources":["../src/core/exceptions/business-rule-violation-exception.ts","../src/core/exceptions/entity-not-found-exception.ts","../src/core/exceptions/invalid-state-transition-exception.ts"],"sourcesContent":["import { DomainException } from \"./domain-exception.js\";\n\nclass BusinessRuleViolationException extends DomainException {\n constructor(\n public readonly rule: string,\n message: string,\n options?: { cause?: unknown },\n ) {\n super(message, options);\n }\n}\n\nexport { BusinessRuleViolationException };\n","import { DomainException } from \"./domain-exception.js\";\n\nclass EntityNotFoundException extends DomainException {\n constructor(\n public readonly entityName: string,\n public readonly identifier: string,\n options?: { cause?: unknown },\n ) {\n super(\n `${entityName} with identifier ${identifier} was not found.`,\n options,\n );\n }\n}\n\nexport { EntityNotFoundException };\n","import { DomainException } from \"./domain-exception.js\";\n\nclass InvalidStateTransitionException<\n TState extends string = string,\n> extends DomainException {\n constructor(\n public readonly from: TState,\n public readonly to: TState,\n message?: string,\n options?: { cause?: unknown },\n ) {\n // Compose a sensible default from `from`/`to` when no message is given,\n // mirroring how EntityNotFoundException builds its own message.\n super(message ?? `Cannot transition from ${from} to ${to}.`, options);\n }\n}\n\nexport { InvalidStateTransitionException };\n"],"mappings":";;AAEA,IAAM,iCAAN,cAA6C,gBAAgB;CACzD,YACI,MACA,SACA,SACF;EACE,MAAM,SAAS,OAAO;EAJN,KAAA,OAAA;CAKpB;AACJ;;;ACRA,IAAM,0BAAN,cAAsC,gBAAgB;CAClD,YACI,YACA,YACA,SACF;EACE,MACI,GAAG,WAAW,mBAAmB,WAAW,kBAC5C,OACJ;EAPgB,KAAA,aAAA;EACA,KAAA,aAAA;CAOpB;AACJ;;;ACXA,IAAM,kCAAN,cAEU,gBAAgB;CACtB,YACI,MACA,IACA,SACA,SACF;EAGE,MAAM,WAAW,0BAA0B,KAAK,MAAM,GAAG,IAAI,OAAO;EAPpD,KAAA,OAAA;EACA,KAAA,KAAA;CAOpB;AACJ"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
const require_domain_exception = require("./domain-exception.cjs");
|
|
2
2
|
//#region src/core/exceptions/invariant-violation-exception.ts
|
|
3
3
|
var InvariantViolationException = class extends require_domain_exception.DomainException {
|
|
4
|
-
constructor(message) {
|
|
5
|
-
super(message);
|
|
4
|
+
constructor(message, options) {
|
|
5
|
+
super(message, options);
|
|
6
6
|
}
|
|
7
7
|
};
|
|
8
8
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"invariant-violation-exception.cjs","names":["DomainException"],"sources":["../src/core/exceptions/invariant-violation-exception.ts"],"sourcesContent":["import { DomainException } from \"./domain-exception.js\";\n\nclass InvariantViolationException extends DomainException {\n constructor(message: string) {\n super(message);\n }\n}\n\nexport { InvariantViolationException };\n"],"mappings":";;AAEA,IAAM,8BAAN,cAA0CA,yBAAAA,gBAAgB;CACtD,YAAY,SAAiB;
|
|
1
|
+
{"version":3,"file":"invariant-violation-exception.cjs","names":["DomainException"],"sources":["../src/core/exceptions/invariant-violation-exception.ts"],"sourcesContent":["import { DomainException } from \"./domain-exception.js\";\n\nclass InvariantViolationException extends DomainException {\n constructor(message: string, options?: { cause?: unknown }) {\n super(message, options);\n }\n}\n\nexport { InvariantViolationException };\n"],"mappings":";;AAEA,IAAM,8BAAN,cAA0CA,yBAAAA,gBAAgB;CACtD,YAAY,SAAiB,SAA+B;EACxD,MAAM,SAAS,OAAO;CAC1B;AACJ"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { t as DomainException } from "./domain-exception.js";
|
|
2
2
|
//#region src/core/exceptions/invariant-violation-exception.ts
|
|
3
3
|
var InvariantViolationException = class extends DomainException {
|
|
4
|
-
constructor(message) {
|
|
5
|
-
super(message);
|
|
4
|
+
constructor(message, options) {
|
|
5
|
+
super(message, options);
|
|
6
6
|
}
|
|
7
7
|
};
|
|
8
8
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"invariant-violation-exception.js","names":[],"sources":["../src/core/exceptions/invariant-violation-exception.ts"],"sourcesContent":["import { DomainException } from \"./domain-exception.js\";\n\nclass InvariantViolationException extends DomainException {\n constructor(message: string) {\n super(message);\n }\n}\n\nexport { InvariantViolationException };\n"],"mappings":";;AAEA,IAAM,8BAAN,cAA0C,gBAAgB;CACtD,YAAY,SAAiB;
|
|
1
|
+
{"version":3,"file":"invariant-violation-exception.js","names":[],"sources":["../src/core/exceptions/invariant-violation-exception.ts"],"sourcesContent":["import { DomainException } from \"./domain-exception.js\";\n\nclass InvariantViolationException extends DomainException {\n constructor(message: string, options?: { cause?: unknown }) {\n super(message, options);\n }\n}\n\nexport { InvariantViolationException };\n"],"mappings":";;AAEA,IAAM,8BAAN,cAA0C,gBAAgB;CACtD,YAAY,SAAiB,SAA+B;EACxD,MAAM,SAAS,OAAO;CAC1B;AACJ"}
|
package/dist/not-found-error.cjs
CHANGED
|
@@ -7,13 +7,14 @@ var BusinessRuleViolationError = class extends require_app_error.AppError {
|
|
|
7
7
|
detail
|
|
8
8
|
} : { rule };
|
|
9
9
|
const mergedMetadata = options?.metadata ? {
|
|
10
|
-
...
|
|
11
|
-
...
|
|
10
|
+
...options.metadata,
|
|
11
|
+
...baseMetadata
|
|
12
12
|
} : baseMetadata;
|
|
13
13
|
super(message, require_app_error.ErrorCodes.businessRuleViolation, {
|
|
14
14
|
...options,
|
|
15
15
|
metadata: mergedMetadata
|
|
16
16
|
});
|
|
17
|
+
Object.freeze(this);
|
|
17
18
|
}
|
|
18
19
|
};
|
|
19
20
|
//#endregion
|
|
@@ -39,13 +40,14 @@ var NotFoundError = class extends require_app_error.AppError {
|
|
|
39
40
|
criteria
|
|
40
41
|
} : { resource };
|
|
41
42
|
const mergedMetadata = options?.metadata ? {
|
|
42
|
-
...
|
|
43
|
-
...
|
|
43
|
+
...options.metadata,
|
|
44
|
+
...baseMetadata
|
|
44
45
|
} : baseMetadata;
|
|
45
46
|
super(`${resource} not found`, require_app_error.ErrorCodes.notFound, {
|
|
46
47
|
...options,
|
|
47
48
|
metadata: mergedMetadata
|
|
48
49
|
});
|
|
50
|
+
Object.freeze(this);
|
|
49
51
|
}
|
|
50
52
|
};
|
|
51
53
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"not-found-error.cjs","names":["AppError","ErrorCodes","AppError","ErrorCodes"],"sources":["../src/core/errors/business-rule-violation-error.ts","../src/core/errors/not-found-error.ts"],"sourcesContent":["import { AppError } from \"./app-error.js\";\nimport { ErrorCodes } from \"./error-codes.js\";\nimport type { AppErrorOptions } from \"./types.js\";\n\n// ─────────────────────────────────────────────────────────────────────────────\n// BusinessRuleViolationError\n// ─────────────────────────────────────────────────────────────────────────────\n\nclass BusinessRuleViolationError extends AppError {\n constructor(\n rule: string,\n message: string,\n detail?: Record<string, unknown>,\n options?: AppErrorOptions,\n ) {\n const baseMetadata = detail ? { rule, detail } : { rule };\n const mergedMetadata = options?.metadata\n ? { ...
|
|
1
|
+
{"version":3,"file":"not-found-error.cjs","names":["AppError","ErrorCodes","AppError","ErrorCodes"],"sources":["../src/core/errors/business-rule-violation-error.ts","../src/core/errors/not-found-error.ts"],"sourcesContent":["import { AppError } from \"./app-error.js\";\nimport { ErrorCodes } from \"./error-codes.js\";\nimport type { AppErrorOptions } from \"./types.js\";\n\n// ─────────────────────────────────────────────────────────────────────────────\n// BusinessRuleViolationError\n// ─────────────────────────────────────────────────────────────────────────────\n\nclass BusinessRuleViolationError extends AppError {\n constructor(\n rule: string,\n message: string,\n detail?: Record<string, unknown>,\n options?: AppErrorOptions,\n ) {\n const baseMetadata = detail ? { rule, detail } : { rule };\n // Reserved keys (`rule`/`detail`) spread last so caller metadata cannot\n // clobber them.\n const mergedMetadata = options?.metadata\n ? { ...options.metadata, ...baseMetadata }\n : baseMetadata;\n\n super(message, ErrorCodes.businessRuleViolation, {\n ...options,\n metadata: mergedMetadata,\n });\n Object.freeze(this);\n }\n}\n\nexport { BusinessRuleViolationError };\n","import { AppError } from \"./app-error.js\";\nimport { ErrorCodes } from \"./error-codes.js\";\nimport type { AppErrorOptions } from \"./types.js\";\n\n// ─────────────────────────────────────────────────────────────────────────────\n// NotFoundError\n// ─────────────────────────────────────────────────────────────────────────────\n\n/**\n * Raised when a requested resource does not exist. Maps naturally onto an HTTP\n * 404 at the edge, but stays transport-agnostic here.\n *\n * The `resource` name builds the message (`\"<resource> not found\"`) and, with\n * the optional lookup `criteria`, lands in the metadata so logs show *what* was\n * searched for without the caller having to restate it in the message.\n */\nclass NotFoundError extends AppError {\n /**\n * @param resource - Human-readable name of the missing resource (e.g. `\"Order\"`).\n * @param criteria - Optional lookup keys used in the search; recorded in\n * metadata to aid debugging. Avoid putting sensitive values here.\n * @param options - Optional cause, correlation ids, and extra metadata.\n */\n constructor(\n resource: string,\n criteria?: Record<string, unknown>,\n options?: AppErrorOptions,\n ) {\n const baseMetadata = criteria ? { resource, criteria } : { resource };\n // Reserved keys (`resource`/`criteria`) spread last so caller metadata\n // can add to but never clobber them — as the docs promise.\n const mergedMetadata = options?.metadata\n ? { ...options.metadata, ...baseMetadata }\n : baseMetadata;\n\n super(`${resource} not found`, ErrorCodes.notFound, {\n ...options,\n metadata: mergedMetadata,\n });\n Object.freeze(this);\n }\n}\n\nexport { NotFoundError };\n"],"mappings":";;AAQA,IAAM,6BAAN,cAAyCA,kBAAAA,SAAS;CAC9C,YACI,MACA,SACA,QACA,SACF;EACE,MAAM,eAAe,SAAS;GAAE;GAAM;EAAO,IAAI,EAAE,KAAK;EAGxD,MAAM,iBAAiB,SAAS,WAC1B;GAAE,GAAG,QAAQ;GAAU,GAAG;EAAa,IACvC;EAEN,MAAM,SAASC,kBAAAA,WAAW,uBAAuB;GAC7C,GAAG;GACH,UAAU;EACd,CAAC;EACD,OAAO,OAAO,IAAI;CACtB;AACJ;;;;;;;;;;;ACZA,IAAM,gBAAN,cAA4BC,kBAAAA,SAAS;;;;;;;CAOjC,YACI,UACA,UACA,SACF;EACE,MAAM,eAAe,WAAW;GAAE;GAAU;EAAS,IAAI,EAAE,SAAS;EAGpE,MAAM,iBAAiB,SAAS,WAC1B;GAAE,GAAG,QAAQ;GAAU,GAAG;EAAa,IACvC;EAEN,MAAM,GAAG,SAAS,aAAaC,kBAAAA,WAAW,UAAU;GAChD,GAAG;GACH,UAAU;EACd,CAAC;EACD,OAAO,OAAO,IAAI;CACtB;AACJ"}
|
package/dist/not-found-error.js
CHANGED
|
@@ -7,13 +7,14 @@ var BusinessRuleViolationError = class extends AppError {
|
|
|
7
7
|
detail
|
|
8
8
|
} : { rule };
|
|
9
9
|
const mergedMetadata = options?.metadata ? {
|
|
10
|
-
...
|
|
11
|
-
...
|
|
10
|
+
...options.metadata,
|
|
11
|
+
...baseMetadata
|
|
12
12
|
} : baseMetadata;
|
|
13
13
|
super(message, ErrorCodes.businessRuleViolation, {
|
|
14
14
|
...options,
|
|
15
15
|
metadata: mergedMetadata
|
|
16
16
|
});
|
|
17
|
+
Object.freeze(this);
|
|
17
18
|
}
|
|
18
19
|
};
|
|
19
20
|
//#endregion
|
|
@@ -39,13 +40,14 @@ var NotFoundError = class extends AppError {
|
|
|
39
40
|
criteria
|
|
40
41
|
} : { resource };
|
|
41
42
|
const mergedMetadata = options?.metadata ? {
|
|
42
|
-
...
|
|
43
|
-
...
|
|
43
|
+
...options.metadata,
|
|
44
|
+
...baseMetadata
|
|
44
45
|
} : baseMetadata;
|
|
45
46
|
super(`${resource} not found`, ErrorCodes.notFound, {
|
|
46
47
|
...options,
|
|
47
48
|
metadata: mergedMetadata
|
|
48
49
|
});
|
|
50
|
+
Object.freeze(this);
|
|
49
51
|
}
|
|
50
52
|
};
|
|
51
53
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"not-found-error.js","names":[],"sources":["../src/core/errors/business-rule-violation-error.ts","../src/core/errors/not-found-error.ts"],"sourcesContent":["import { AppError } from \"./app-error.js\";\nimport { ErrorCodes } from \"./error-codes.js\";\nimport type { AppErrorOptions } from \"./types.js\";\n\n// ─────────────────────────────────────────────────────────────────────────────\n// BusinessRuleViolationError\n// ─────────────────────────────────────────────────────────────────────────────\n\nclass BusinessRuleViolationError extends AppError {\n constructor(\n rule: string,\n message: string,\n detail?: Record<string, unknown>,\n options?: AppErrorOptions,\n ) {\n const baseMetadata = detail ? { rule, detail } : { rule };\n const mergedMetadata = options?.metadata\n ? { ...
|
|
1
|
+
{"version":3,"file":"not-found-error.js","names":[],"sources":["../src/core/errors/business-rule-violation-error.ts","../src/core/errors/not-found-error.ts"],"sourcesContent":["import { AppError } from \"./app-error.js\";\nimport { ErrorCodes } from \"./error-codes.js\";\nimport type { AppErrorOptions } from \"./types.js\";\n\n// ─────────────────────────────────────────────────────────────────────────────\n// BusinessRuleViolationError\n// ─────────────────────────────────────────────────────────────────────────────\n\nclass BusinessRuleViolationError extends AppError {\n constructor(\n rule: string,\n message: string,\n detail?: Record<string, unknown>,\n options?: AppErrorOptions,\n ) {\n const baseMetadata = detail ? { rule, detail } : { rule };\n // Reserved keys (`rule`/`detail`) spread last so caller metadata cannot\n // clobber them.\n const mergedMetadata = options?.metadata\n ? { ...options.metadata, ...baseMetadata }\n : baseMetadata;\n\n super(message, ErrorCodes.businessRuleViolation, {\n ...options,\n metadata: mergedMetadata,\n });\n Object.freeze(this);\n }\n}\n\nexport { BusinessRuleViolationError };\n","import { AppError } from \"./app-error.js\";\nimport { ErrorCodes } from \"./error-codes.js\";\nimport type { AppErrorOptions } from \"./types.js\";\n\n// ─────────────────────────────────────────────────────────────────────────────\n// NotFoundError\n// ─────────────────────────────────────────────────────────────────────────────\n\n/**\n * Raised when a requested resource does not exist. Maps naturally onto an HTTP\n * 404 at the edge, but stays transport-agnostic here.\n *\n * The `resource` name builds the message (`\"<resource> not found\"`) and, with\n * the optional lookup `criteria`, lands in the metadata so logs show *what* was\n * searched for without the caller having to restate it in the message.\n */\nclass NotFoundError extends AppError {\n /**\n * @param resource - Human-readable name of the missing resource (e.g. `\"Order\"`).\n * @param criteria - Optional lookup keys used in the search; recorded in\n * metadata to aid debugging. Avoid putting sensitive values here.\n * @param options - Optional cause, correlation ids, and extra metadata.\n */\n constructor(\n resource: string,\n criteria?: Record<string, unknown>,\n options?: AppErrorOptions,\n ) {\n const baseMetadata = criteria ? { resource, criteria } : { resource };\n // Reserved keys (`resource`/`criteria`) spread last so caller metadata\n // can add to but never clobber them — as the docs promise.\n const mergedMetadata = options?.metadata\n ? { ...options.metadata, ...baseMetadata }\n : baseMetadata;\n\n super(`${resource} not found`, ErrorCodes.notFound, {\n ...options,\n metadata: mergedMetadata,\n });\n Object.freeze(this);\n }\n}\n\nexport { NotFoundError };\n"],"mappings":";;AAQA,IAAM,6BAAN,cAAyC,SAAS;CAC9C,YACI,MACA,SACA,QACA,SACF;EACE,MAAM,eAAe,SAAS;GAAE;GAAM;EAAO,IAAI,EAAE,KAAK;EAGxD,MAAM,iBAAiB,SAAS,WAC1B;GAAE,GAAG,QAAQ;GAAU,GAAG;EAAa,IACvC;EAEN,MAAM,SAAS,WAAW,uBAAuB;GAC7C,GAAG;GACH,UAAU;EACd,CAAC;EACD,OAAO,OAAO,IAAI;CACtB;AACJ;;;;;;;;;;;ACZA,IAAM,gBAAN,cAA4B,SAAS;;;;;;;CAOjC,YACI,UACA,UACA,SACF;EACE,MAAM,eAAe,WAAW;GAAE;GAAU;EAAS,IAAI,EAAE,SAAS;EAGpE,MAAM,iBAAiB,SAAS,WAC1B;GAAE,GAAG,QAAQ;GAAU,GAAG;EAAa,IACvC;EAEN,MAAM,GAAG,SAAS,aAAa,WAAW,UAAU;GAChD,GAAG;GACH,UAAU;EACd,CAAC;EACD,OAAO,OAAO,IAAI;CACtB;AACJ"}
|
package/dist/outcome.cjs
CHANGED
|
@@ -28,19 +28,19 @@ var Outcome = class Outcome {
|
|
|
28
28
|
return new Outcome(status, data, reason, Object.freeze({ ...metadata }));
|
|
29
29
|
}
|
|
30
30
|
static approved(data, reason) {
|
|
31
|
-
return
|
|
31
|
+
return Outcome.of("APPROVED", data, reason);
|
|
32
32
|
}
|
|
33
33
|
static rejected(data, reason) {
|
|
34
|
-
return
|
|
34
|
+
return Outcome.of("REJECTED", data, reason);
|
|
35
35
|
}
|
|
36
36
|
static noOp(data, reason) {
|
|
37
|
-
return
|
|
37
|
+
return Outcome.of("NO_OP", data, reason);
|
|
38
38
|
}
|
|
39
39
|
static deferred(data, reason) {
|
|
40
|
-
return
|
|
40
|
+
return Outcome.of("DEFERRED", data, reason);
|
|
41
41
|
}
|
|
42
42
|
static requiresReview(data, reason) {
|
|
43
|
-
return
|
|
43
|
+
return Outcome.of("REQUIRES_REVIEW", data, reason);
|
|
44
44
|
}
|
|
45
45
|
/**
|
|
46
46
|
* Narrows this Outcome to a specific status.
|
package/dist/outcome.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"outcome.cjs","names":["InvariantViolationException"],"sources":["../src/core/result/outcome.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"outcome.cjs","names":["InvariantViolationException"],"sources":["../src/core/result/outcome.ts"],"sourcesContent":["import { InvariantViolationException } from \"../exceptions/invariant-violation-exception.js\";\n\n/**\n * Outcome — Business decision abstraction.\n *\n * Represents the semantic result of a domain decision, policy evaluation,\n * or business rule. NOT for technical success/failure — use Result for that.\n *\n * Mental model:\n * \"What was the business decision?\"\n * NOT \"Did the operation succeed?\"\n *\n * The status axis represents valid business outcomes (APPROVED, REJECTED,\n * ALLOW, DENY, NO_OP, etc.), never technical Ok/Err.\n *\n * @typeParam S - Union of valid status literals for this outcome\n * @typeParam D - Shape of the decision data carried by this outcome\n */\nexport class Outcome<S extends string, D = undefined> {\n readonly status: S;\n readonly data: D;\n readonly reason: string | undefined;\n readonly metadata: Readonly<Record<string, unknown>>;\n\n private constructor(\n status: S,\n data: D,\n reason: string | undefined,\n metadata: Readonly<Record<string, unknown>>,\n ) {\n this.status = status;\n this.data = data;\n this.reason = reason;\n this.metadata = metadata;\n Object.freeze(this);\n }\n\n // ─── Generic factory ────────────────────────────────────────────────\n\n static of<S extends string, D = undefined>(\n status: S,\n data: D,\n reason?: string,\n metadata?: Record<string, unknown>,\n ): Outcome<S, D> {\n return new Outcome(\n status,\n data,\n reason,\n Object.freeze({ ...metadata }),\n );\n }\n\n // ─── Convenience factories for common business statuses ─────────────\n\n static approved<D = undefined>(\n data: D,\n reason?: string,\n ): Outcome<\"APPROVED\", D> {\n return Outcome.of(\"APPROVED\", data, reason);\n }\n\n static rejected<D = undefined>(\n data: D,\n reason: string,\n ): Outcome<\"REJECTED\", D> {\n return Outcome.of(\"REJECTED\", data, reason);\n }\n\n static noOp<D = undefined>(data: D, reason?: string): Outcome<\"NO_OP\", D> {\n return Outcome.of(\"NO_OP\", data, reason);\n }\n\n static deferred<D = undefined>(\n data: D,\n reason: string,\n ): Outcome<\"DEFERRED\", D> {\n return Outcome.of(\"DEFERRED\", data, reason);\n }\n\n static requiresReview<D = undefined>(\n data: D,\n reason: string,\n ): Outcome<\"REQUIRES_REVIEW\", D> {\n return Outcome.of(\"REQUIRES_REVIEW\", data, reason);\n }\n\n // ─── Type narrowing ────────────────────────────────────────────────\n\n /**\n * Narrows this Outcome to a specific status.\n *\n * @example\n * if (outcome.is('DENY')) {\n * outcome.data.violations // TS knows status is 'DENY'\n * }\n */\n is<T extends S>(status: T): this is Outcome<T, D> {\n return (this.status as string) === status;\n }\n\n // ─── Exhaustive match ──────────────────────────────────────────────\n\n /**\n * Exhaustive pattern match over all possible statuses.\n * TypeScript enforces that every status has a handler.\n *\n * @example\n * outcome.match({\n * ALLOW: (o) => handleAllow(o.data),\n * DENY: (o) => handleDeny(o.data.violations),\n * })\n */\n match<THandlers extends { [K in S]: (outcome: Outcome<K, D>) => unknown }>(\n handlers: THandlers,\n ): ReturnType<THandlers[S]> {\n const handler = (\n handlers as Partial<Record<string, (o: unknown) => unknown>>\n )[this.status];\n\n if (typeof handler !== \"function\") {\n const availableStatuses = Object.keys(handlers);\n throw new InvariantViolationException(\n `Outcome.match is missing a handler for runtime status \"${this.status}\". Available handlers: ${availableStatuses.join(\", \") || \"(none)\"}`,\n );\n }\n\n return handler(this) as ReturnType<THandlers[S]>;\n }\n\n // ─── Derived copies ────────────────────────────────────────────────\n\n withMetadata(extra: Record<string, unknown>): Outcome<S, D> {\n return new Outcome(\n this.status,\n this.data,\n this.reason,\n Object.freeze({ ...this.metadata, ...extra }),\n );\n }\n\n withReason(reason: string): Outcome<S, D> {\n return new Outcome(this.status, this.data, reason, this.metadata);\n }\n\n // ─── Debug ─────────────────────────────────────────────────────────\n\n toString(): string {\n const parts: string[] = [this.status];\n if (this.reason) parts.push(`reason=\"${this.reason}\"`);\n return `Outcome(${parts.join(\", \")})`;\n }\n}\n\n/** Common business outcome statuses. Extend per domain as needed. */\nexport type CommonOutcomeStatus =\n | \"APPROVED\"\n | \"REJECTED\"\n | \"NO_OP\"\n | \"DEFERRED\"\n | \"REQUIRES_REVIEW\";\n"],"mappings":";;;;;;;;;;;;;;;;;;AAkBA,IAAa,UAAb,MAAa,QAAyC;CAMlD,YACI,QACA,MACA,QACA,UACF;EACE,KAAK,SAAS;EACd,KAAK,OAAO;EACZ,KAAK,SAAS;EACd,KAAK,WAAW;EAChB,OAAO,OAAO,IAAI;CACtB;CAIA,OAAO,GACH,QACA,MACA,QACA,UACa;EACb,OAAO,IAAI,QACP,QACA,MACA,QACA,OAAO,OAAO,EAAE,GAAG,SAAS,CAAC,CACjC;CACJ;CAIA,OAAO,SACH,MACA,QACsB;EACtB,OAAO,QAAQ,GAAG,YAAY,MAAM,MAAM;CAC9C;CAEA,OAAO,SACH,MACA,QACsB;EACtB,OAAO,QAAQ,GAAG,YAAY,MAAM,MAAM;CAC9C;CAEA,OAAO,KAAoB,MAAS,QAAsC;EACtE,OAAO,QAAQ,GAAG,SAAS,MAAM,MAAM;CAC3C;CAEA,OAAO,SACH,MACA,QACsB;EACtB,OAAO,QAAQ,GAAG,YAAY,MAAM,MAAM;CAC9C;CAEA,OAAO,eACH,MACA,QAC6B;EAC7B,OAAO,QAAQ,GAAG,mBAAmB,MAAM,MAAM;CACrD;;;;;;;;;CAYA,GAAgB,QAAkC;EAC9C,OAAQ,KAAK,WAAsB;CACvC;;;;;;;;;;;CAcA,MACI,UACwB;EACxB,MAAM,UACF,SACF,KAAK;EAEP,IAAI,OAAO,YAAY,YAAY;GAC/B,MAAM,oBAAoB,OAAO,KAAK,QAAQ;GAC9C,MAAM,IAAIA,sCAAAA,4BACN,0DAA0D,KAAK,OAAO,yBAAyB,kBAAkB,KAAK,IAAI,KAAK,UACnI;EACJ;EAEA,OAAO,QAAQ,IAAI;CACvB;CAIA,aAAa,OAA+C;EACxD,OAAO,IAAI,QACP,KAAK,QACL,KAAK,MACL,KAAK,QACL,OAAO,OAAO;GAAE,GAAG,KAAK;GAAU,GAAG;EAAM,CAAC,CAChD;CACJ;CAEA,WAAW,QAA+B;EACtC,OAAO,IAAI,QAAQ,KAAK,QAAQ,KAAK,MAAM,QAAQ,KAAK,QAAQ;CACpE;CAIA,WAAmB;EACf,MAAM,QAAkB,CAAC,KAAK,MAAM;EACpC,IAAI,KAAK,QAAQ,MAAM,KAAK,WAAW,KAAK,OAAO,EAAE;EACrD,OAAO,WAAW,MAAM,KAAK,IAAI,EAAE;CACvC;AACJ"}
|
package/dist/outcome.js
CHANGED
|
@@ -28,19 +28,19 @@ var Outcome = class Outcome {
|
|
|
28
28
|
return new Outcome(status, data, reason, Object.freeze({ ...metadata }));
|
|
29
29
|
}
|
|
30
30
|
static approved(data, reason) {
|
|
31
|
-
return
|
|
31
|
+
return Outcome.of("APPROVED", data, reason);
|
|
32
32
|
}
|
|
33
33
|
static rejected(data, reason) {
|
|
34
|
-
return
|
|
34
|
+
return Outcome.of("REJECTED", data, reason);
|
|
35
35
|
}
|
|
36
36
|
static noOp(data, reason) {
|
|
37
|
-
return
|
|
37
|
+
return Outcome.of("NO_OP", data, reason);
|
|
38
38
|
}
|
|
39
39
|
static deferred(data, reason) {
|
|
40
|
-
return
|
|
40
|
+
return Outcome.of("DEFERRED", data, reason);
|
|
41
41
|
}
|
|
42
42
|
static requiresReview(data, reason) {
|
|
43
|
-
return
|
|
43
|
+
return Outcome.of("REQUIRES_REVIEW", data, reason);
|
|
44
44
|
}
|
|
45
45
|
/**
|
|
46
46
|
* Narrows this Outcome to a specific status.
|
package/dist/outcome.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"outcome.js","names":[],"sources":["../src/core/result/outcome.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"outcome.js","names":[],"sources":["../src/core/result/outcome.ts"],"sourcesContent":["import { InvariantViolationException } from \"../exceptions/invariant-violation-exception.js\";\n\n/**\n * Outcome — Business decision abstraction.\n *\n * Represents the semantic result of a domain decision, policy evaluation,\n * or business rule. NOT for technical success/failure — use Result for that.\n *\n * Mental model:\n * \"What was the business decision?\"\n * NOT \"Did the operation succeed?\"\n *\n * The status axis represents valid business outcomes (APPROVED, REJECTED,\n * ALLOW, DENY, NO_OP, etc.), never technical Ok/Err.\n *\n * @typeParam S - Union of valid status literals for this outcome\n * @typeParam D - Shape of the decision data carried by this outcome\n */\nexport class Outcome<S extends string, D = undefined> {\n readonly status: S;\n readonly data: D;\n readonly reason: string | undefined;\n readonly metadata: Readonly<Record<string, unknown>>;\n\n private constructor(\n status: S,\n data: D,\n reason: string | undefined,\n metadata: Readonly<Record<string, unknown>>,\n ) {\n this.status = status;\n this.data = data;\n this.reason = reason;\n this.metadata = metadata;\n Object.freeze(this);\n }\n\n // ─── Generic factory ────────────────────────────────────────────────\n\n static of<S extends string, D = undefined>(\n status: S,\n data: D,\n reason?: string,\n metadata?: Record<string, unknown>,\n ): Outcome<S, D> {\n return new Outcome(\n status,\n data,\n reason,\n Object.freeze({ ...metadata }),\n );\n }\n\n // ─── Convenience factories for common business statuses ─────────────\n\n static approved<D = undefined>(\n data: D,\n reason?: string,\n ): Outcome<\"APPROVED\", D> {\n return Outcome.of(\"APPROVED\", data, reason);\n }\n\n static rejected<D = undefined>(\n data: D,\n reason: string,\n ): Outcome<\"REJECTED\", D> {\n return Outcome.of(\"REJECTED\", data, reason);\n }\n\n static noOp<D = undefined>(data: D, reason?: string): Outcome<\"NO_OP\", D> {\n return Outcome.of(\"NO_OP\", data, reason);\n }\n\n static deferred<D = undefined>(\n data: D,\n reason: string,\n ): Outcome<\"DEFERRED\", D> {\n return Outcome.of(\"DEFERRED\", data, reason);\n }\n\n static requiresReview<D = undefined>(\n data: D,\n reason: string,\n ): Outcome<\"REQUIRES_REVIEW\", D> {\n return Outcome.of(\"REQUIRES_REVIEW\", data, reason);\n }\n\n // ─── Type narrowing ────────────────────────────────────────────────\n\n /**\n * Narrows this Outcome to a specific status.\n *\n * @example\n * if (outcome.is('DENY')) {\n * outcome.data.violations // TS knows status is 'DENY'\n * }\n */\n is<T extends S>(status: T): this is Outcome<T, D> {\n return (this.status as string) === status;\n }\n\n // ─── Exhaustive match ──────────────────────────────────────────────\n\n /**\n * Exhaustive pattern match over all possible statuses.\n * TypeScript enforces that every status has a handler.\n *\n * @example\n * outcome.match({\n * ALLOW: (o) => handleAllow(o.data),\n * DENY: (o) => handleDeny(o.data.violations),\n * })\n */\n match<THandlers extends { [K in S]: (outcome: Outcome<K, D>) => unknown }>(\n handlers: THandlers,\n ): ReturnType<THandlers[S]> {\n const handler = (\n handlers as Partial<Record<string, (o: unknown) => unknown>>\n )[this.status];\n\n if (typeof handler !== \"function\") {\n const availableStatuses = Object.keys(handlers);\n throw new InvariantViolationException(\n `Outcome.match is missing a handler for runtime status \"${this.status}\". Available handlers: ${availableStatuses.join(\", \") || \"(none)\"}`,\n );\n }\n\n return handler(this) as ReturnType<THandlers[S]>;\n }\n\n // ─── Derived copies ────────────────────────────────────────────────\n\n withMetadata(extra: Record<string, unknown>): Outcome<S, D> {\n return new Outcome(\n this.status,\n this.data,\n this.reason,\n Object.freeze({ ...this.metadata, ...extra }),\n );\n }\n\n withReason(reason: string): Outcome<S, D> {\n return new Outcome(this.status, this.data, reason, this.metadata);\n }\n\n // ─── Debug ─────────────────────────────────────────────────────────\n\n toString(): string {\n const parts: string[] = [this.status];\n if (this.reason) parts.push(`reason=\"${this.reason}\"`);\n return `Outcome(${parts.join(\", \")})`;\n }\n}\n\n/** Common business outcome statuses. Extend per domain as needed. */\nexport type CommonOutcomeStatus =\n | \"APPROVED\"\n | \"REJECTED\"\n | \"NO_OP\"\n | \"DEFERRED\"\n | \"REQUIRES_REVIEW\";\n"],"mappings":";;;;;;;;;;;;;;;;;;AAkBA,IAAa,UAAb,MAAa,QAAyC;CAMlD,YACI,QACA,MACA,QACA,UACF;EACE,KAAK,SAAS;EACd,KAAK,OAAO;EACZ,KAAK,SAAS;EACd,KAAK,WAAW;EAChB,OAAO,OAAO,IAAI;CACtB;CAIA,OAAO,GACH,QACA,MACA,QACA,UACa;EACb,OAAO,IAAI,QACP,QACA,MACA,QACA,OAAO,OAAO,EAAE,GAAG,SAAS,CAAC,CACjC;CACJ;CAIA,OAAO,SACH,MACA,QACsB;EACtB,OAAO,QAAQ,GAAG,YAAY,MAAM,MAAM;CAC9C;CAEA,OAAO,SACH,MACA,QACsB;EACtB,OAAO,QAAQ,GAAG,YAAY,MAAM,MAAM;CAC9C;CAEA,OAAO,KAAoB,MAAS,QAAsC;EACtE,OAAO,QAAQ,GAAG,SAAS,MAAM,MAAM;CAC3C;CAEA,OAAO,SACH,MACA,QACsB;EACtB,OAAO,QAAQ,GAAG,YAAY,MAAM,MAAM;CAC9C;CAEA,OAAO,eACH,MACA,QAC6B;EAC7B,OAAO,QAAQ,GAAG,mBAAmB,MAAM,MAAM;CACrD;;;;;;;;;CAYA,GAAgB,QAAkC;EAC9C,OAAQ,KAAK,WAAsB;CACvC;;;;;;;;;;;CAcA,MACI,UACwB;EACxB,MAAM,UACF,SACF,KAAK;EAEP,IAAI,OAAO,YAAY,YAAY;GAC/B,MAAM,oBAAoB,OAAO,KAAK,QAAQ;GAC9C,MAAM,IAAI,4BACN,0DAA0D,KAAK,OAAO,yBAAyB,kBAAkB,KAAK,IAAI,KAAK,UACnI;EACJ;EAEA,OAAO,QAAQ,IAAI;CACvB;CAIA,aAAa,OAA+C;EACxD,OAAO,IAAI,QACP,KAAK,QACL,KAAK,MACL,KAAK,QACL,OAAO,OAAO;GAAE,GAAG,KAAK;GAAU,GAAG;EAAM,CAAC,CAChD;CACJ;CAEA,WAAW,QAA+B;EACtC,OAAO,IAAI,QAAQ,KAAK,QAAQ,KAAK,MAAM,QAAQ,KAAK,QAAQ;CACpE;CAIA,WAAmB;EACf,MAAM,QAAkB,CAAC,KAAK,MAAM;EACpC,IAAI,KAAK,QAAQ,MAAM,KAAK,WAAW,KAAK,OAAO,EAAE;EACrD,OAAO,WAAW,MAAM,KAAK,IAAI,EAAE;CACvC;AACJ"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { r as Result } from "./result.cjs";
|
|
2
|
-
import {
|
|
2
|
+
import { D as GatePayload, O as GatePayloadV1, w as PolicyContext } from "./core-config.cjs";
|
|
3
3
|
import { a as ComputeOutcome, c as VersionedComputeEngine, i as ComputeEvaluatorRegistration, l as ComputePayload, p as ComputePayloadV1, r as ComputeEvaluator } from "./gate-engine-registry.cjs";
|
|
4
4
|
|
|
5
5
|
//#region src/core/policies/engines/compute-evaluator-registry.d.ts
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { r as Result } from "./result.js";
|
|
2
|
-
import {
|
|
2
|
+
import { D as GatePayload, O as GatePayloadV1, w as PolicyContext } from "./core-config.js";
|
|
3
3
|
import { a as ComputeOutcome, c as VersionedComputeEngine, i as ComputeEvaluatorRegistration, l as ComputePayload, p as ComputePayloadV1, r as ComputeEvaluator } from "./gate-engine-registry.js";
|
|
4
4
|
|
|
5
5
|
//#region src/core/policies/engines/compute-evaluator-registry.d.ts
|
package/dist/path.d.cts
CHANGED
|
@@ -22,20 +22,20 @@ declare const coreConfig: CoreConfig;
|
|
|
22
22
|
* Array item order is preserved on purpose; callers that treat arrays as sets
|
|
23
23
|
* must normalize or sort them before hashing.
|
|
24
24
|
*
|
|
25
|
+
* The strict canonical form is owned by `shared/stable-stringify`
|
|
26
|
+
* ({@link canonicalStringify}); this class just composes it with SHA-256.
|
|
25
27
|
* Values that JSON.stringify would silently drop or coerce (undefined,
|
|
26
28
|
* non-finite numbers, functions, symbols, bigint) are rejected up-front to
|
|
27
29
|
* prevent semantically different payloads from collapsing to the same hash.
|
|
28
30
|
*/
|
|
29
31
|
declare class PolicyHashing {
|
|
30
32
|
static sha256(input: string): string;
|
|
31
|
-
private static assertHashable;
|
|
32
33
|
static canonicalJson(value: unknown): string;
|
|
33
34
|
static computePayloadHash(payload: unknown, policyKey: string, policyVersion: string): string;
|
|
34
35
|
}
|
|
35
36
|
//#endregion
|
|
36
37
|
//#region src/core/policies/defs/in-memory-policy-definition-repo.d.ts
|
|
37
38
|
declare class InMemoryPolicyDefinitionRepository implements PolicyDefinitionRepository {
|
|
38
|
-
private readonly definitions;
|
|
39
39
|
private readonly definitionsByPolicyKey;
|
|
40
40
|
constructor(definitions: readonly PolicyDefinition[]);
|
|
41
41
|
findCandidates(params: FindCandidatesParams): PolicyDefinition[];
|
package/dist/path.d.ts
CHANGED
|
@@ -22,20 +22,20 @@ declare const coreConfig: CoreConfig;
|
|
|
22
22
|
* Array item order is preserved on purpose; callers that treat arrays as sets
|
|
23
23
|
* must normalize or sort them before hashing.
|
|
24
24
|
*
|
|
25
|
+
* The strict canonical form is owned by `shared/stable-stringify`
|
|
26
|
+
* ({@link canonicalStringify}); this class just composes it with SHA-256.
|
|
25
27
|
* Values that JSON.stringify would silently drop or coerce (undefined,
|
|
26
28
|
* non-finite numbers, functions, symbols, bigint) are rejected up-front to
|
|
27
29
|
* prevent semantically different payloads from collapsing to the same hash.
|
|
28
30
|
*/
|
|
29
31
|
declare class PolicyHashing {
|
|
30
32
|
static sha256(input: string): string;
|
|
31
|
-
private static assertHashable;
|
|
32
33
|
static canonicalJson(value: unknown): string;
|
|
33
34
|
static computePayloadHash(payload: unknown, policyKey: string, policyVersion: string): string;
|
|
34
35
|
}
|
|
35
36
|
//#endregion
|
|
36
37
|
//#region src/core/policies/defs/in-memory-policy-definition-repo.d.ts
|
|
37
38
|
declare class InMemoryPolicyDefinitionRepository implements PolicyDefinitionRepository {
|
|
38
|
-
private readonly definitions;
|
|
39
39
|
private readonly definitionsByPolicyKey;
|
|
40
40
|
constructor(definitions: readonly PolicyDefinition[]);
|
|
41
41
|
findCandidates(params: FindCandidatesParams): PolicyDefinition[];
|