@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.
Files changed (306) hide show
  1. package/KIT_CONTEXT.md +7 -1
  2. package/dist/abac/index.d.cts +2 -2
  3. package/dist/abac/index.d.ts +2 -2
  4. package/dist/aggregate-version.cjs +14 -0
  5. package/dist/aggregate-version.cjs.map +1 -0
  6. package/dist/aggregate-version.js +9 -0
  7. package/dist/aggregate-version.js.map +1 -0
  8. package/dist/app-error.cjs +21 -6
  9. package/dist/app-error.cjs.map +1 -1
  10. package/dist/app-error.js +21 -6
  11. package/dist/app-error.js.map +1 -1
  12. package/dist/application/index.cjs +8 -4
  13. package/dist/application/index.d.cts +2 -2
  14. package/dist/application/index.d.ts +2 -2
  15. package/dist/application/index.js +1 -2
  16. package/dist/authorization-error.cjs +67 -17
  17. package/dist/authorization-error.cjs.map +1 -1
  18. package/dist/authorization-error.d.cts +6 -2
  19. package/dist/authorization-error.d.ts +6 -2
  20. package/dist/authorization-error.js +50 -18
  21. package/dist/authorization-error.js.map +1 -1
  22. package/dist/authorizer.port.d.cts +18 -3
  23. package/dist/authorizer.port.d.ts +18 -3
  24. package/dist/composite-authorizer.d.cts +63 -10
  25. package/dist/composite-authorizer.d.ts +63 -10
  26. package/dist/condition-evaluator.cjs +117 -172
  27. package/dist/condition-evaluator.cjs.map +1 -1
  28. package/dist/condition-evaluator.js +118 -167
  29. package/dist/condition-evaluator.js.map +1 -1
  30. package/dist/core-config.d.cts +53 -6
  31. package/dist/core-config.d.ts +53 -6
  32. package/dist/decorate.cjs +14 -0
  33. package/dist/decorate.js +9 -0
  34. package/dist/domain/index.cjs +107 -2
  35. package/dist/domain/index.cjs.map +1 -0
  36. package/dist/domain/index.d.cts +25 -1
  37. package/dist/domain/index.d.ts +25 -1
  38. package/dist/domain/index.js +99 -3
  39. package/dist/domain/index.js.map +1 -0
  40. package/dist/domain-event-contracts.cjs +12 -8
  41. package/dist/domain-event-contracts.cjs.map +1 -1
  42. package/dist/domain-event-contracts.d.cts +29 -4
  43. package/dist/domain-event-contracts.d.ts +29 -4
  44. package/dist/domain-event-contracts.js +11 -7
  45. package/dist/domain-event-contracts.js.map +1 -1
  46. package/dist/domain-exception.cjs +2 -1
  47. package/dist/domain-exception.cjs.map +1 -1
  48. package/dist/domain-exception.js +2 -1
  49. package/dist/domain-exception.js.map +1 -1
  50. package/dist/errors/index.cjs +3 -2
  51. package/dist/errors/index.d.cts +1 -1
  52. package/dist/errors/index.d.ts +1 -1
  53. package/dist/errors/index.js +3 -2
  54. package/dist/exceptions/index.cjs +2 -2
  55. package/dist/exceptions/index.d.cts +1 -2
  56. package/dist/exceptions/index.d.ts +1 -2
  57. package/dist/exceptions/index.js +2 -2
  58. package/dist/gate-engine-registry.cjs.map +1 -1
  59. package/dist/gate-engine-registry.d.cts +1 -1
  60. package/dist/gate-engine-registry.d.ts +1 -1
  61. package/dist/gate-engine-registry.js.map +1 -1
  62. package/dist/gate-v1-payload.schema.cjs +11 -6
  63. package/dist/gate-v1-payload.schema.cjs.map +1 -1
  64. package/dist/gate-v1-payload.schema.js +11 -6
  65. package/dist/gate-v1-payload.schema.js.map +1 -1
  66. package/dist/hashing.cjs +2 -44
  67. package/dist/hashing.cjs.map +1 -1
  68. package/dist/hashing.js +3 -39
  69. package/dist/hashing.js.map +1 -1
  70. package/dist/immutable.cjs +25 -12
  71. package/dist/immutable.cjs.map +1 -1
  72. package/dist/immutable.js +24 -11
  73. package/dist/immutable.js.map +1 -1
  74. package/dist/index.cjs +15 -11
  75. package/dist/index.cjs.map +1 -1
  76. package/dist/index.d.cts +9 -10
  77. package/dist/index.d.ts +9 -10
  78. package/dist/index.js +8 -9
  79. package/dist/index.js.map +1 -1
  80. package/dist/invalid-state-transition-exception.cjs +6 -6
  81. package/dist/invalid-state-transition-exception.cjs.map +1 -1
  82. package/dist/invalid-state-transition-exception.js +6 -6
  83. package/dist/invalid-state-transition-exception.js.map +1 -1
  84. package/dist/invariant-violation-exception.cjs +2 -2
  85. package/dist/invariant-violation-exception.cjs.map +1 -1
  86. package/dist/invariant-violation-exception.js +2 -2
  87. package/dist/invariant-violation-exception.js.map +1 -1
  88. package/dist/not-found-error.cjs +6 -4
  89. package/dist/not-found-error.cjs.map +1 -1
  90. package/dist/not-found-error.js +6 -4
  91. package/dist/not-found-error.js.map +1 -1
  92. package/dist/outcome.cjs +5 -5
  93. package/dist/outcome.cjs.map +1 -1
  94. package/dist/outcome.js +5 -5
  95. package/dist/outcome.js.map +1 -1
  96. package/dist/parse-gate-payload.d.cts +1 -1
  97. package/dist/parse-gate-payload.d.ts +1 -1
  98. package/dist/path.d.cts +2 -2
  99. package/dist/path.d.ts +2 -2
  100. package/dist/plugin.cjs +23 -13
  101. package/dist/plugin.cjs.map +1 -1
  102. package/dist/plugin.d.cts +22 -8
  103. package/dist/plugin.d.ts +22 -8
  104. package/dist/plugin.js +23 -13
  105. package/dist/plugin.js.map +1 -1
  106. package/dist/policies/engines/index.d.cts +1 -1
  107. package/dist/policies/engines/index.d.ts +1 -1
  108. package/dist/policies/engines/v1/gate/index.d.cts +3 -13
  109. package/dist/policies/engines/v1/gate/index.d.ts +3 -13
  110. package/dist/policies/index.d.cts +1 -1
  111. package/dist/policies/index.d.ts +1 -1
  112. package/dist/policy-bridge.cjs +30 -2
  113. package/dist/policy-bridge.cjs.map +1 -1
  114. package/dist/policy-bridge.d.cts +18 -0
  115. package/dist/policy-bridge.d.ts +18 -0
  116. package/dist/policy-bridge.js +30 -2
  117. package/dist/policy-bridge.js.map +1 -1
  118. package/dist/policy-service.cjs +41 -46
  119. package/dist/policy-service.cjs.map +1 -1
  120. package/dist/policy-service.d.cts +72 -9
  121. package/dist/policy-service.d.ts +72 -9
  122. package/dist/policy-service.js +43 -48
  123. package/dist/policy-service.js.map +1 -1
  124. package/dist/requested-by.cjs +4 -4
  125. package/dist/requested-by.cjs.map +1 -1
  126. package/dist/requested-by.js +2 -2
  127. package/dist/requested-by.js.map +1 -1
  128. package/dist/result.cjs +29 -1
  129. package/dist/result.cjs.map +1 -1
  130. package/dist/result.d.cts +12 -0
  131. package/dist/result.d.ts +12 -0
  132. package/dist/result.js +29 -1
  133. package/dist/result.js.map +1 -1
  134. package/dist/rule.cjs +94 -24
  135. package/dist/rule.cjs.map +1 -1
  136. package/dist/rule.js +94 -24
  137. package/dist/rule.js.map +1 -1
  138. package/dist/ruleset-registry.cjs +19 -0
  139. package/dist/ruleset-registry.cjs.map +1 -1
  140. package/dist/ruleset-registry.js +19 -0
  141. package/dist/ruleset-registry.js.map +1 -1
  142. package/dist/stable-stringify.cjs +87 -0
  143. package/dist/stable-stringify.cjs.map +1 -0
  144. package/dist/stable-stringify.js +76 -0
  145. package/dist/stable-stringify.js.map +1 -0
  146. package/dist/temporal-snapshot.d.cts +87 -0
  147. package/dist/temporal-snapshot.d.ts +87 -0
  148. package/dist/temporal-use-case.cjs +174 -16
  149. package/dist/temporal-use-case.cjs.map +1 -1
  150. package/dist/temporal-use-case.d.cts +82 -44
  151. package/dist/temporal-use-case.d.ts +82 -44
  152. package/dist/temporal-use-case.js +167 -15
  153. package/dist/temporal-use-case.js.map +1 -1
  154. package/dist/unexpected-error.cjs +4 -2
  155. package/dist/unexpected-error.cjs.map +1 -1
  156. package/dist/unexpected-error.js +4 -2
  157. package/dist/unexpected-error.js.map +1 -1
  158. package/dist/uuid-identifier.cjs +141 -8
  159. package/dist/uuid-identifier.cjs.map +1 -1
  160. package/dist/uuid-identifier.d.cts +26 -7
  161. package/dist/uuid-identifier.d.ts +26 -7
  162. package/dist/uuid-identifier.js +135 -8
  163. package/dist/uuid-identifier.js.map +1 -1
  164. package/dist/uuid.cjs +23 -0
  165. package/dist/uuid.cjs.map +1 -0
  166. package/dist/uuid.js +18 -0
  167. package/dist/uuid.js.map +1 -0
  168. package/dist/validation-code.cjs +9 -0
  169. package/dist/validation-code.cjs.map +1 -1
  170. package/dist/validation-code.d.cts +3 -0
  171. package/dist/validation-code.d.ts +3 -0
  172. package/dist/validation-code.js +9 -0
  173. package/dist/validation-code.js.map +1 -1
  174. package/dist/validation-error.cjs +42 -67
  175. package/dist/validation-error.cjs.map +1 -1
  176. package/dist/validation-error.d.cts +29 -8
  177. package/dist/validation-error.d.ts +29 -8
  178. package/dist/validation-error.js +41 -66
  179. package/dist/validation-error.js.map +1 -1
  180. package/dist/validation-exception.cjs +17 -6
  181. package/dist/validation-exception.cjs.map +1 -1
  182. package/dist/validation-exception.d.cts +33 -9
  183. package/dist/validation-exception.d.ts +33 -9
  184. package/dist/validation-exception.js +17 -6
  185. package/dist/validation-exception.js.map +1 -1
  186. package/dist/validation-field.cjs +3 -0
  187. package/dist/validation-field.cjs.map +1 -1
  188. package/dist/validation-field.d.cts +1 -0
  189. package/dist/validation-field.d.ts +1 -0
  190. package/dist/validation-field.js +3 -0
  191. package/dist/validation-field.js.map +1 -1
  192. package/dist/value-object-ruleset.contracts.d.cts +10 -0
  193. package/dist/value-object-ruleset.contracts.d.ts +10 -0
  194. package/dist/value-object.cjs +23 -4
  195. package/dist/value-object.cjs.map +1 -1
  196. package/dist/value-object.d.cts +25 -1
  197. package/dist/value-object.d.ts +25 -1
  198. package/dist/value-object.js +23 -4
  199. package/dist/value-object.js.map +1 -1
  200. package/dist/version.d.cts +27 -0
  201. package/dist/version.d.ts +27 -0
  202. package/dist/versioning/index.d.cts +2 -2
  203. package/dist/versioning/index.d.ts +2 -2
  204. package/meta.json +5 -2
  205. package/package.json +1 -1
  206. package/src/core/abac/authorizer.ts +60 -10
  207. package/src/core/abac/domain/policy-set.ts +52 -5
  208. package/src/core/abac/domain/rule.ts +28 -16
  209. package/src/core/abac/index.ts +7 -1
  210. package/src/core/application/commands/command.ts +14 -1
  211. package/src/core/application/commands/requested-by.ts +13 -5
  212. package/src/core/application/index.ts +2 -1
  213. package/src/core/application/policy-error-mapper.ts +6 -0
  214. package/src/core/application/ports/index.ts +7 -0
  215. package/src/core/application/ports/temporal-repository.port.ts +35 -2
  216. package/src/core/application/queries/index.ts +1 -1
  217. package/src/core/application/queries/query.ts +25 -3
  218. package/src/core/application/temporal/temporal-use-case.ts +31 -4
  219. package/src/core/application/use-case.ts +45 -8
  220. package/src/core/config/core-config.ts +46 -25
  221. package/src/core/config/index.ts +1 -0
  222. package/src/core/config/policy-reporter.ts +32 -1
  223. package/src/core/domain/entity.ts +51 -8
  224. package/src/core/domain/rulesets/entity-ruleset.contracts.ts +0 -2
  225. package/src/core/domain/rulesets/ruleset-registry.ts +24 -0
  226. package/src/core/domain/rulesets/value-object-ruleset.contracts.ts +1 -7
  227. package/src/core/domain/temporal/half-open-interval.ts +34 -0
  228. package/src/core/domain/temporal/temporal-snapshot.ts +13 -2
  229. package/src/core/domain/temporal/transaction-time.ts +19 -15
  230. package/src/core/domain/temporal/valid-time.ts +20 -15
  231. package/src/core/domain/uuid-identifier.ts +6 -11
  232. package/src/core/domain/value-object.ts +29 -3
  233. package/src/core/errors/authentication-error.ts +5 -31
  234. package/src/core/errors/authorization-error.ts +12 -20
  235. package/src/core/errors/business-rule-violation-error.ts +4 -1
  236. package/src/core/errors/idempotency-error.ts +5 -2
  237. package/src/core/errors/index.ts +4 -0
  238. package/src/core/errors/integration-error.ts +4 -24
  239. package/src/core/errors/legacy-incompatible-error.ts +1 -0
  240. package/src/core/errors/not-found-error.ts +4 -1
  241. package/src/core/errors/temporal-error.ts +22 -20
  242. package/src/core/errors/unexpected-error.ts +5 -1
  243. package/src/core/errors/utils/factory-helpers.ts +70 -0
  244. package/src/core/errors/utils/index.ts +5 -0
  245. package/src/core/errors/utils/json-safe.ts +35 -12
  246. package/src/core/errors/validation-error.ts +4 -1
  247. package/src/core/exceptions/business-rule-violation-exception.ts +2 -1
  248. package/src/core/exceptions/domain-exception.ts +9 -1
  249. package/src/core/exceptions/entity-not-found-exception.ts +5 -1
  250. package/src/core/exceptions/invalid-state-transition-exception.ts +5 -2
  251. package/src/core/exceptions/invariant-violation-exception.ts +2 -2
  252. package/src/core/exceptions/validation-code.ts +14 -0
  253. package/src/core/exceptions/validation-exception.ts +44 -5
  254. package/src/core/exceptions/validation-field.ts +11 -1
  255. package/src/core/plugins/plugin.ts +25 -15
  256. package/src/core/plugins/types.ts +4 -2
  257. package/src/core/policies/asof/asof.ts +12 -0
  258. package/src/core/policies/catalog/policy-catalog-entry.ts +3 -1
  259. package/src/core/policies/catalog/policy-catalog.ts +5 -1
  260. package/src/core/policies/context/context-builder.ts +20 -0
  261. package/src/core/policies/context/context-resolver.ts +5 -0
  262. package/src/core/policies/context/context-seed.ts +11 -0
  263. package/src/core/policies/defs/in-memory-policy-definition-repo.ts +0 -2
  264. package/src/core/policies/engines/parse-gate-payload.ts +9 -0
  265. package/src/core/policies/engines/v1/condition-date-operands.ts +112 -0
  266. package/src/core/policies/engines/v1/condition-evaluator.ts +120 -291
  267. package/src/core/policies/engines/v1/condition-schema.ts +23 -19
  268. package/src/core/policies/engines/v1/condition-types.ts +18 -11
  269. package/src/core/policies/index.ts +4 -6
  270. package/src/core/policies/service/policy-service.ts +46 -35
  271. package/src/core/policies/utils/hash.ts +5 -69
  272. package/src/core/policies/utils/result.ts +1 -1
  273. package/src/core/rbac/access-request.ts +12 -2
  274. package/src/core/rbac/authorizer.ts +8 -1
  275. package/src/core/rbac/domain/role.ts +20 -0
  276. package/src/core/rbac/domain/scope.ts +6 -1
  277. package/src/core/result/index.ts +5 -0
  278. package/src/core/result/outcome.ts +5 -7
  279. package/src/core/result/result.ts +34 -1
  280. package/src/core/shared/hashing.ts +6 -57
  281. package/src/core/shared/immutable.ts +22 -4
  282. package/src/core/shared/stable-stringify.ts +144 -0
  283. package/src/core/shared/uuid.ts +16 -0
  284. package/src/core/versioning/domain-event-contracts.ts +43 -15
  285. package/src/core/versioning/index.ts +1 -0
  286. package/src/core/versioning/version.ts +30 -1
  287. package/src/domain/index.ts +5 -0
  288. package/src/examples/rulesets/entity/order-creation-rules-v1.ts +1 -1
  289. package/src/examples/rulesets/entity/order-invariants-v1.ts +2 -4
  290. package/src/examples/rulesets/entity/order-invariants-v2.ts +2 -4
  291. package/src/examples/rulesets/value-object/cpf-rules-v1.ts +2 -4
  292. package/src/examples/rulesets/value-object/cpf-rules-v2.ts +2 -4
  293. package/src/examples/rulesets/value-object/person-name-rules-v1.ts +2 -4
  294. package/src/examples/rulesets/value-object/person-name-rules-v2.ts +2 -4
  295. package/src/result/index.ts +7 -2
  296. package/src/version.ts +1 -1
  297. package/dist/domain-exception.d.cts +0 -7
  298. package/dist/domain-exception.d.ts +0 -7
  299. package/dist/entity.cjs +0 -126
  300. package/dist/entity.cjs.map +0 -1
  301. package/dist/entity.js +0 -115
  302. package/dist/entity.js.map +0 -1
  303. package/dist/use-case.cjs +0 -96
  304. package/dist/use-case.cjs.map +0 -1
  305. package/dist/use-case.js +0 -91
  306. package/dist/use-case.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"gate-v1-payload.schema.cjs","names":["z","z","Result"],"sources":["../src/core/policies/engines/v1/condition-schema.ts","../src/core/policies/engines/v1/gate/gate-v1-payload.schema.ts"],"sourcesContent":["import { z } from \"zod\";\n\nimport type { ConditionLeafNode, ConditionNode } from \"./condition-types.js\";\n\n// ─── Shared v1 condition Zod schemas ─────────────────────────────────────────\n// Extracted from gate/v1 so both gate/v1 and compute/v1 can validate\n// condition nodes without either engine depending on the other.\n\nconst conditionOpSchema = z.enum([\n \"eq\",\n \"neq\",\n \"gt\",\n \"gte\",\n \"lt\",\n \"lte\",\n \"in\",\n \"notIn\",\n \"isNull\",\n \"isNotNull\",\n]);\n\nexport const conditionLeafNodeSchema: z.ZodType<ConditionLeafNode> = z\n .object({\n field: z.string().min(1),\n op: conditionOpSchema,\n value: z.unknown(),\n allowNull: z.literal(true).optional(),\n })\n .strict() as z.ZodType<ConditionLeafNode>;\n\nexport const conditionNodeSchema: z.ZodType<ConditionNode> = z.lazy(() =>\n z.union([\n conditionLeafNodeSchema,\n z\n .object({\n and: z.array(conditionNodeSchema).min(1),\n })\n .strict(),\n z\n .object({\n or: z.array(conditionNodeSchema).min(1),\n })\n .strict(),\n z\n .object({\n not: conditionNodeSchema,\n })\n .strict(),\n ]),\n);\n","import { z } from \"zod\";\n\nimport { Result } from \"../../../../result/result.js\";\n\nimport type { GatePayloadV1 } from \"./gate-types-v1.js\";\nimport {\n conditionLeafNodeSchema,\n conditionNodeSchema,\n} from \"../condition-schema.js\";\n\n// Re-export so gate/v1 public API remains unchanged.\nexport { conditionLeafNodeSchema, conditionNodeSchema };\n\nexport class GatePayloadSchemaV1 {\n static readonly schema = z.union([\n z\n .object({\n condition: conditionNodeSchema,\n })\n .strict(),\n z\n .object({\n allowIf: conditionNodeSchema,\n defaultOutcome: z.enum([\"ALLOW\", \"DENY\"]),\n })\n .strict(),\n ]);\n\n static parse(payload: unknown): Result<GatePayloadV1, string> {\n const parsed = GatePayloadSchemaV1.schema.safeParse(payload);\n if (!parsed.success) {\n const details = parsed.error.issues\n .map((issue) => {\n const path = issue.path.join(\".\");\n return path.length > 0\n ? `${path}: ${issue.message}`\n : issue.message;\n })\n .join(\"; \");\n\n return Result.err(`Invalid gate payload: ${details}`);\n }\n\n return Result.ok(parsed.data as GatePayloadV1);\n }\n}\n\nexport const gatePayloadSchema = GatePayloadSchemaV1.schema;\n"],"mappings":";;;AAQA,MAAM,oBAAoBA,IAAAA,EAAE,KAAK;CAC7B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACJ,CAAC;AAED,MAAa,0BAAwDA,IAAAA,EAChE,OAAO;CACJ,OAAOA,IAAAA,EAAE,OAAO,EAAE,IAAI,CAAC;CACvB,IAAI;CACJ,OAAOA,IAAAA,EAAE,QAAQ;CACjB,WAAWA,IAAAA,EAAE,QAAQ,IAAI,EAAE,SAAS;AACxC,CAAC,EACA,OAAO;AAEZ,MAAa,sBAAgDA,IAAAA,EAAE,WAC3DA,IAAAA,EAAE,MAAM;CACJ;CACAA,IAAAA,EACK,OAAO,EACJ,KAAKA,IAAAA,EAAE,MAAM,mBAAmB,EAAE,IAAI,CAAC,EAC3C,CAAC,EACA,OAAO;CACZA,IAAAA,EACK,OAAO,EACJ,IAAIA,IAAAA,EAAE,MAAM,mBAAmB,EAAE,IAAI,CAAC,EAC1C,CAAC,EACA,OAAO;CACZA,IAAAA,EACK,OAAO,EACJ,KAAK,oBACT,CAAC,EACA,OAAO;AAChB,CAAC,CACL;;;ACpCA,IAAa,sBAAb,MAAa,oBAAoB;;gBACJC,IAAAA,EAAE,MAAM,CAC7BA,IAAAA,EACK,OAAO,EACJ,WAAW,oBACf,CAAC,EACA,OAAO,GACZA,IAAAA,EACK,OAAO;GACJ,SAAS;GACT,gBAAgBA,IAAAA,EAAE,KAAK,CAAC,SAAS,MAAM,CAAC;EAC5C,CAAC,EACA,OAAO,CAChB,CAAC;;CAED,OAAO,MAAM,SAAiD;EAC1D,MAAM,SAAS,oBAAoB,OAAO,UAAU,OAAO;EAC3D,IAAI,CAAC,OAAO,SAAS;GACjB,MAAM,UAAU,OAAO,MAAM,OACxB,KAAK,UAAU;IACZ,MAAM,OAAO,MAAM,KAAK,KAAK,GAAG;IAChC,OAAO,KAAK,SAAS,IACf,GAAG,KAAK,IAAI,MAAM,YAClB,MAAM;GAChB,CAAC,EACA,KAAK,IAAI;GAEd,OAAOC,eAAAA,OAAO,IAAI,yBAAyB,SAAS;EACxD;EAEA,OAAOA,eAAAA,OAAO,GAAG,OAAO,IAAqB;CACjD;AACJ;AAEA,MAAa,oBAAoB,oBAAoB"}
1
+ {"version":3,"file":"gate-v1-payload.schema.cjs","names":["z","z","Result"],"sources":["../src/core/policies/engines/v1/condition-schema.ts","../src/core/policies/engines/v1/gate/gate-v1-payload.schema.ts"],"sourcesContent":["import { z } from \"zod\";\n\nimport type { ConditionLeafNode, ConditionNode } from \"./condition-types.js\";\n\n// ─── Shared v1 condition Zod schemas ─────────────────────────────────────────\n// Extracted from gate/v1 so both gate/v1 and compute/v1 can validate\n// condition nodes without either engine depending on the other.\n\nconst conditionOpSchema = z.enum([\n \"eq\",\n \"neq\",\n \"gt\",\n \"gte\",\n \"lt\",\n \"lte\",\n \"in\",\n \"notIn\",\n \"isNull\",\n \"isNotNull\",\n]);\n\nexport const conditionLeafNodeSchema: z.ZodType<ConditionLeafNode> = z\n .object({\n field: z.string().min(1),\n op: conditionOpSchema,\n value: z.unknown(),\n allowNull: z.literal(true).optional(),\n })\n .strict() as z.ZodType<ConditionLeafNode>;\n\n// Cap nesting depth so an adversarially deep payload fails validation instead\n// of overflowing the stack during parse: zod recurses once per level, and the\n// old `z.lazy` schema was unbounded. The schema is built to exactly this depth\n// (leaf-only past it), so a too-deep tree is rejected at the boundary without\n// deep recursion. 32 is far beyond any hand-written policy — raise it only with\n// a matching stack-safety review.\nexport const MAX_CONDITION_DEPTH = 32;\n\nfunction boundedConditionNodeSchema(depth: number): z.ZodType<ConditionNode> {\n if (depth <= 1) {\n return conditionLeafNodeSchema;\n }\n\n const child = boundedConditionNodeSchema(depth - 1);\n return z.union([\n conditionLeafNodeSchema,\n z.object({ and: z.array(child).min(1) }).strict(),\n z.object({ or: z.array(child).min(1) }).strict(),\n z.object({ not: child }).strict(),\n ]) as z.ZodType<ConditionNode>;\n}\n\nexport const conditionNodeSchema: z.ZodType<ConditionNode> =\n boundedConditionNodeSchema(MAX_CONDITION_DEPTH);\n","import { z } from \"zod\";\n\nimport { Result } from \"../../../../result/result.js\";\n\nimport type { GatePayloadV1 } from \"./gate-types-v1.js\";\nimport {\n conditionLeafNodeSchema,\n conditionNodeSchema,\n} from \"../condition-schema.js\";\n\n// Re-export so gate/v1 public API remains unchanged.\nexport { conditionLeafNodeSchema, conditionNodeSchema };\n\nexport class GatePayloadSchemaV1 {\n static readonly schema = z.union([\n z\n .object({\n condition: conditionNodeSchema,\n })\n .strict(),\n z\n .object({\n allowIf: conditionNodeSchema,\n defaultOutcome: z.enum([\"ALLOW\", \"DENY\"]),\n })\n .strict(),\n ]);\n\n static parse(payload: unknown): Result<GatePayloadV1, string> {\n const parsed = GatePayloadSchemaV1.schema.safeParse(payload);\n if (!parsed.success) {\n const details = parsed.error.issues\n .map((issue) => {\n const path = issue.path.join(\".\");\n return path.length > 0\n ? `${path}: ${issue.message}`\n : issue.message;\n })\n .join(\"; \");\n\n return Result.err(`Invalid gate payload: ${details}`);\n }\n\n return Result.ok(parsed.data as GatePayloadV1);\n }\n}\n\nexport const gatePayloadSchema = GatePayloadSchemaV1.schema;\n"],"mappings":";;;AAQA,MAAM,oBAAoBA,IAAAA,EAAE,KAAK;CAC7B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACJ,CAAC;AAED,MAAa,0BAAwDA,IAAAA,EAChE,OAAO;CACJ,OAAOA,IAAAA,EAAE,OAAO,EAAE,IAAI,CAAC;CACvB,IAAI;CACJ,OAAOA,IAAAA,EAAE,QAAQ;CACjB,WAAWA,IAAAA,EAAE,QAAQ,IAAI,EAAE,SAAS;AACxC,CAAC,EACA,OAAO;AAUZ,SAAS,2BAA2B,OAAyC;CACzE,IAAI,SAAS,GACT,OAAO;CAGX,MAAM,QAAQ,2BAA2B,QAAQ,CAAC;CAClD,OAAOA,IAAAA,EAAE,MAAM;EACX;EACAA,IAAAA,EAAE,OAAO,EAAE,KAAKA,IAAAA,EAAE,MAAM,KAAK,EAAE,IAAI,CAAC,EAAE,CAAC,EAAE,OAAO;EAChDA,IAAAA,EAAE,OAAO,EAAE,IAAIA,IAAAA,EAAE,MAAM,KAAK,EAAE,IAAI,CAAC,EAAE,CAAC,EAAE,OAAO;EAC/CA,IAAAA,EAAE,OAAO,EAAE,KAAK,MAAM,CAAC,EAAE,OAAO;CACpC,CAAC;AACL;AAEA,MAAa,sBACT,2BAAA,EAA8C;;;ACxClD,IAAa,sBAAb,MAAa,oBAAoB;;gBACJC,IAAAA,EAAE,MAAM,CAC7BA,IAAAA,EACK,OAAO,EACJ,WAAW,oBACf,CAAC,EACA,OAAO,GACZA,IAAAA,EACK,OAAO;GACJ,SAAS;GACT,gBAAgBA,IAAAA,EAAE,KAAK,CAAC,SAAS,MAAM,CAAC;EAC5C,CAAC,EACA,OAAO,CAChB,CAAC;;CAED,OAAO,MAAM,SAAiD;EAC1D,MAAM,SAAS,oBAAoB,OAAO,UAAU,OAAO;EAC3D,IAAI,CAAC,OAAO,SAAS;GACjB,MAAM,UAAU,OAAO,MAAM,OACxB,KAAK,UAAU;IACZ,MAAM,OAAO,MAAM,KAAK,KAAK,GAAG;IAChC,OAAO,KAAK,SAAS,IACf,GAAG,KAAK,IAAI,MAAM,YAClB,MAAM;GAChB,CAAC,EACA,KAAK,IAAI;GAEd,OAAOC,eAAAA,OAAO,IAAI,yBAAyB,SAAS;EACxD;EAEA,OAAOA,eAAAA,OAAO,GAAG,OAAO,IAAqB;CACjD;AACJ;AAEA,MAAa,oBAAoB,oBAAoB"}
@@ -19,12 +19,17 @@ const conditionLeafNodeSchema = z.object({
19
19
  value: z.unknown(),
20
20
  allowNull: z.literal(true).optional()
21
21
  }).strict();
22
- const conditionNodeSchema = z.lazy(() => z.union([
23
- conditionLeafNodeSchema,
24
- z.object({ and: z.array(conditionNodeSchema).min(1) }).strict(),
25
- z.object({ or: z.array(conditionNodeSchema).min(1) }).strict(),
26
- z.object({ not: conditionNodeSchema }).strict()
27
- ]));
22
+ function boundedConditionNodeSchema(depth) {
23
+ if (depth <= 1) return conditionLeafNodeSchema;
24
+ const child = boundedConditionNodeSchema(depth - 1);
25
+ return z.union([
26
+ conditionLeafNodeSchema,
27
+ z.object({ and: z.array(child).min(1) }).strict(),
28
+ z.object({ or: z.array(child).min(1) }).strict(),
29
+ z.object({ not: child }).strict()
30
+ ]);
31
+ }
32
+ const conditionNodeSchema = boundedConditionNodeSchema(32);
28
33
  //#endregion
29
34
  //#region src/core/policies/engines/v1/gate/gate-v1-payload.schema.ts
30
35
  var GatePayloadSchemaV1 = class GatePayloadSchemaV1 {
@@ -1 +1 @@
1
- {"version":3,"file":"gate-v1-payload.schema.js","names":[],"sources":["../src/core/policies/engines/v1/condition-schema.ts","../src/core/policies/engines/v1/gate/gate-v1-payload.schema.ts"],"sourcesContent":["import { z } from \"zod\";\n\nimport type { ConditionLeafNode, ConditionNode } from \"./condition-types.js\";\n\n// ─── Shared v1 condition Zod schemas ─────────────────────────────────────────\n// Extracted from gate/v1 so both gate/v1 and compute/v1 can validate\n// condition nodes without either engine depending on the other.\n\nconst conditionOpSchema = z.enum([\n \"eq\",\n \"neq\",\n \"gt\",\n \"gte\",\n \"lt\",\n \"lte\",\n \"in\",\n \"notIn\",\n \"isNull\",\n \"isNotNull\",\n]);\n\nexport const conditionLeafNodeSchema: z.ZodType<ConditionLeafNode> = z\n .object({\n field: z.string().min(1),\n op: conditionOpSchema,\n value: z.unknown(),\n allowNull: z.literal(true).optional(),\n })\n .strict() as z.ZodType<ConditionLeafNode>;\n\nexport const conditionNodeSchema: z.ZodType<ConditionNode> = z.lazy(() =>\n z.union([\n conditionLeafNodeSchema,\n z\n .object({\n and: z.array(conditionNodeSchema).min(1),\n })\n .strict(),\n z\n .object({\n or: z.array(conditionNodeSchema).min(1),\n })\n .strict(),\n z\n .object({\n not: conditionNodeSchema,\n })\n .strict(),\n ]),\n);\n","import { z } from \"zod\";\n\nimport { Result } from \"../../../../result/result.js\";\n\nimport type { GatePayloadV1 } from \"./gate-types-v1.js\";\nimport {\n conditionLeafNodeSchema,\n conditionNodeSchema,\n} from \"../condition-schema.js\";\n\n// Re-export so gate/v1 public API remains unchanged.\nexport { conditionLeafNodeSchema, conditionNodeSchema };\n\nexport class GatePayloadSchemaV1 {\n static readonly schema = z.union([\n z\n .object({\n condition: conditionNodeSchema,\n })\n .strict(),\n z\n .object({\n allowIf: conditionNodeSchema,\n defaultOutcome: z.enum([\"ALLOW\", \"DENY\"]),\n })\n .strict(),\n ]);\n\n static parse(payload: unknown): Result<GatePayloadV1, string> {\n const parsed = GatePayloadSchemaV1.schema.safeParse(payload);\n if (!parsed.success) {\n const details = parsed.error.issues\n .map((issue) => {\n const path = issue.path.join(\".\");\n return path.length > 0\n ? `${path}: ${issue.message}`\n : issue.message;\n })\n .join(\"; \");\n\n return Result.err(`Invalid gate payload: ${details}`);\n }\n\n return Result.ok(parsed.data as GatePayloadV1);\n }\n}\n\nexport const gatePayloadSchema = GatePayloadSchemaV1.schema;\n"],"mappings":";;;AAQA,MAAM,oBAAoB,EAAE,KAAK;CAC7B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACJ,CAAC;AAED,MAAa,0BAAwD,EAChE,OAAO;CACJ,OAAO,EAAE,OAAO,EAAE,IAAI,CAAC;CACvB,IAAI;CACJ,OAAO,EAAE,QAAQ;CACjB,WAAW,EAAE,QAAQ,IAAI,EAAE,SAAS;AACxC,CAAC,EACA,OAAO;AAEZ,MAAa,sBAAgD,EAAE,WAC3D,EAAE,MAAM;CACJ;CACA,EACK,OAAO,EACJ,KAAK,EAAE,MAAM,mBAAmB,EAAE,IAAI,CAAC,EAC3C,CAAC,EACA,OAAO;CACZ,EACK,OAAO,EACJ,IAAI,EAAE,MAAM,mBAAmB,EAAE,IAAI,CAAC,EAC1C,CAAC,EACA,OAAO;CACZ,EACK,OAAO,EACJ,KAAK,oBACT,CAAC,EACA,OAAO;AAChB,CAAC,CACL;;;ACpCA,IAAa,sBAAb,MAAa,oBAAoB;;gBACJ,EAAE,MAAM,CAC7B,EACK,OAAO,EACJ,WAAW,oBACf,CAAC,EACA,OAAO,GACZ,EACK,OAAO;GACJ,SAAS;GACT,gBAAgB,EAAE,KAAK,CAAC,SAAS,MAAM,CAAC;EAC5C,CAAC,EACA,OAAO,CAChB,CAAC;;CAED,OAAO,MAAM,SAAiD;EAC1D,MAAM,SAAS,oBAAoB,OAAO,UAAU,OAAO;EAC3D,IAAI,CAAC,OAAO,SAAS;GACjB,MAAM,UAAU,OAAO,MAAM,OACxB,KAAK,UAAU;IACZ,MAAM,OAAO,MAAM,KAAK,KAAK,GAAG;IAChC,OAAO,KAAK,SAAS,IACf,GAAG,KAAK,IAAI,MAAM,YAClB,MAAM;GAChB,CAAC,EACA,KAAK,IAAI;GAEd,OAAO,OAAO,IAAI,yBAAyB,SAAS;EACxD;EAEA,OAAO,OAAO,GAAG,OAAO,IAAqB;CACjD;AACJ;AAEA,MAAa,oBAAoB,oBAAoB"}
1
+ {"version":3,"file":"gate-v1-payload.schema.js","names":[],"sources":["../src/core/policies/engines/v1/condition-schema.ts","../src/core/policies/engines/v1/gate/gate-v1-payload.schema.ts"],"sourcesContent":["import { z } from \"zod\";\n\nimport type { ConditionLeafNode, ConditionNode } from \"./condition-types.js\";\n\n// ─── Shared v1 condition Zod schemas ─────────────────────────────────────────\n// Extracted from gate/v1 so both gate/v1 and compute/v1 can validate\n// condition nodes without either engine depending on the other.\n\nconst conditionOpSchema = z.enum([\n \"eq\",\n \"neq\",\n \"gt\",\n \"gte\",\n \"lt\",\n \"lte\",\n \"in\",\n \"notIn\",\n \"isNull\",\n \"isNotNull\",\n]);\n\nexport const conditionLeafNodeSchema: z.ZodType<ConditionLeafNode> = z\n .object({\n field: z.string().min(1),\n op: conditionOpSchema,\n value: z.unknown(),\n allowNull: z.literal(true).optional(),\n })\n .strict() as z.ZodType<ConditionLeafNode>;\n\n// Cap nesting depth so an adversarially deep payload fails validation instead\n// of overflowing the stack during parse: zod recurses once per level, and the\n// old `z.lazy` schema was unbounded. The schema is built to exactly this depth\n// (leaf-only past it), so a too-deep tree is rejected at the boundary without\n// deep recursion. 32 is far beyond any hand-written policy — raise it only with\n// a matching stack-safety review.\nexport const MAX_CONDITION_DEPTH = 32;\n\nfunction boundedConditionNodeSchema(depth: number): z.ZodType<ConditionNode> {\n if (depth <= 1) {\n return conditionLeafNodeSchema;\n }\n\n const child = boundedConditionNodeSchema(depth - 1);\n return z.union([\n conditionLeafNodeSchema,\n z.object({ and: z.array(child).min(1) }).strict(),\n z.object({ or: z.array(child).min(1) }).strict(),\n z.object({ not: child }).strict(),\n ]) as z.ZodType<ConditionNode>;\n}\n\nexport const conditionNodeSchema: z.ZodType<ConditionNode> =\n boundedConditionNodeSchema(MAX_CONDITION_DEPTH);\n","import { z } from \"zod\";\n\nimport { Result } from \"../../../../result/result.js\";\n\nimport type { GatePayloadV1 } from \"./gate-types-v1.js\";\nimport {\n conditionLeafNodeSchema,\n conditionNodeSchema,\n} from \"../condition-schema.js\";\n\n// Re-export so gate/v1 public API remains unchanged.\nexport { conditionLeafNodeSchema, conditionNodeSchema };\n\nexport class GatePayloadSchemaV1 {\n static readonly schema = z.union([\n z\n .object({\n condition: conditionNodeSchema,\n })\n .strict(),\n z\n .object({\n allowIf: conditionNodeSchema,\n defaultOutcome: z.enum([\"ALLOW\", \"DENY\"]),\n })\n .strict(),\n ]);\n\n static parse(payload: unknown): Result<GatePayloadV1, string> {\n const parsed = GatePayloadSchemaV1.schema.safeParse(payload);\n if (!parsed.success) {\n const details = parsed.error.issues\n .map((issue) => {\n const path = issue.path.join(\".\");\n return path.length > 0\n ? `${path}: ${issue.message}`\n : issue.message;\n })\n .join(\"; \");\n\n return Result.err(`Invalid gate payload: ${details}`);\n }\n\n return Result.ok(parsed.data as GatePayloadV1);\n }\n}\n\nexport const gatePayloadSchema = GatePayloadSchemaV1.schema;\n"],"mappings":";;;AAQA,MAAM,oBAAoB,EAAE,KAAK;CAC7B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACJ,CAAC;AAED,MAAa,0BAAwD,EAChE,OAAO;CACJ,OAAO,EAAE,OAAO,EAAE,IAAI,CAAC;CACvB,IAAI;CACJ,OAAO,EAAE,QAAQ;CACjB,WAAW,EAAE,QAAQ,IAAI,EAAE,SAAS;AACxC,CAAC,EACA,OAAO;AAUZ,SAAS,2BAA2B,OAAyC;CACzE,IAAI,SAAS,GACT,OAAO;CAGX,MAAM,QAAQ,2BAA2B,QAAQ,CAAC;CAClD,OAAO,EAAE,MAAM;EACX;EACA,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,KAAK,EAAE,IAAI,CAAC,EAAE,CAAC,EAAE,OAAO;EAChD,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,KAAK,EAAE,IAAI,CAAC,EAAE,CAAC,EAAE,OAAO;EAC/C,EAAE,OAAO,EAAE,KAAK,MAAM,CAAC,EAAE,OAAO;CACpC,CAAC;AACL;AAEA,MAAa,sBACT,2BAAA,EAA8C;;;ACxClD,IAAa,sBAAb,MAAa,oBAAoB;;gBACJ,EAAE,MAAM,CAC7B,EACK,OAAO,EACJ,WAAW,oBACf,CAAC,EACA,OAAO,GACZ,EACK,OAAO;GACJ,SAAS;GACT,gBAAgB,EAAE,KAAK,CAAC,SAAS,MAAM,CAAC;EAC5C,CAAC,EACA,OAAO,CAChB,CAAC;;CAED,OAAO,MAAM,SAAiD;EAC1D,MAAM,SAAS,oBAAoB,OAAO,UAAU,OAAO;EAC3D,IAAI,CAAC,OAAO,SAAS;GACjB,MAAM,UAAU,OAAO,MAAM,OACxB,KAAK,UAAU;IACZ,MAAM,OAAO,MAAM,KAAK,KAAK,GAAG;IAChC,OAAO,KAAK,SAAS,IACf,GAAG,KAAK,IAAI,MAAM,YAClB,MAAM;GAChB,CAAC,EACA,KAAK,IAAI;GAEd,OAAO,OAAO,IAAI,yBAAyB,SAAS;EACxD;EAEA,OAAO,OAAO,GAAG,OAAO,IAAqB;CACjD;AACJ;AAEA,MAAa,oBAAoB,oBAAoB"}
package/dist/hashing.cjs CHANGED
@@ -1,47 +1,11 @@
1
+ const require_stable_stringify = require("./stable-stringify.cjs");
1
2
  let node_crypto = require("node:crypto");
2
3
  //#region src/core/shared/hashing.ts
3
- const CIRCULAR_STRUCTURE_MESSAGE = "Cannot stably stringify a circular structure";
4
4
  function sha256Hex(value) {
5
5
  return (0, node_crypto.createHash)("sha256").update(value, "utf8").digest("hex");
6
6
  }
7
- function sortKeysDeep(value, seen) {
8
- if (Array.isArray(value)) {
9
- if (seen.has(value)) throw new TypeError(CIRCULAR_STRUCTURE_MESSAGE);
10
- seen.add(value);
11
- const mapped = value.map((item) => sortKeysDeep(item, seen));
12
- seen.delete(value);
13
- return mapped;
14
- }
15
- if (value instanceof Date) return value;
16
- if (value && typeof value === "object") {
17
- if (seen.has(value)) throw new TypeError(CIRCULAR_STRUCTURE_MESSAGE);
18
- seen.add(value);
19
- const record = value;
20
- const ordered = Object.create(null);
21
- for (const key of Object.keys(record).sort()) ordered[key] = sortKeysDeep(record[key], seen);
22
- seen.delete(value);
23
- return ordered;
24
- }
25
- return value;
26
- }
27
- /**
28
- * Deterministic JSON string with object keys sorted recursively, so key order
29
- * does not affect the output.
30
- *
31
- * Follows `JSON.stringify` semantics for the values it serializes: `undefined`,
32
- * functions and symbols are dropped, non-finite numbers become `null`, `bigint`
33
- * throws, and `Map`/`Set` serialize as `{}`. Distinct payloads can therefore
34
- * collapse to the same string — for collision-resistant hashing use
35
- * `PolicyHashing.canonicalJson` (policies/utils), which rejects those values
36
- * up front.
37
- *
38
- * @throws {TypeError} On circular references (mirroring `JSON.stringify`).
39
- */
40
- function stableStringify(value) {
41
- return JSON.stringify(sortKeysDeep(value, /* @__PURE__ */ new WeakSet()));
42
- }
43
7
  function payloadHash(value) {
44
- return sha256Hex(stableStringify(value));
8
+ return sha256Hex(require_stable_stringify.canonicalStringify(value));
45
9
  }
46
10
  //#endregion
47
11
  Object.defineProperty(exports, "payloadHash", {
@@ -56,11 +20,5 @@ Object.defineProperty(exports, "sha256Hex", {
56
20
  return sha256Hex;
57
21
  }
58
22
  });
59
- Object.defineProperty(exports, "stableStringify", {
60
- enumerable: true,
61
- get: function() {
62
- return stableStringify;
63
- }
64
- });
65
23
 
66
24
  //# sourceMappingURL=hashing.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"hashing.cjs","names":[],"sources":["../src/core/shared/hashing.ts"],"sourcesContent":["import { createHash } from \"node:crypto\";\n\nconst CIRCULAR_STRUCTURE_MESSAGE =\n \"Cannot stably stringify a circular structure\";\n\nfunction sha256Hex(value: string): string {\n return createHash(\"sha256\").update(value, \"utf8\").digest(\"hex\");\n}\n\n// `seen` holds the current traversal branch so true cycles are rejected while\n// repeated (acyclic) references are still serialized — matching JSON.stringify.\nfunction sortKeysDeep(value: unknown, seen: WeakSet<object>): unknown {\n if (Array.isArray(value)) {\n if (seen.has(value)) {\n throw new TypeError(CIRCULAR_STRUCTURE_MESSAGE);\n }\n seen.add(value);\n const mapped = value.map((item) => sortKeysDeep(item, seen));\n seen.delete(value);\n return mapped;\n }\n\n if (value instanceof Date) {\n return value;\n }\n\n if (value && typeof value === \"object\") {\n if (seen.has(value)) {\n throw new TypeError(CIRCULAR_STRUCTURE_MESSAGE);\n }\n seen.add(value);\n const record = value as Record<string, unknown>;\n const ordered = Object.create(null) as Record<string, unknown>;\n\n for (const key of Object.keys(record).sort()) {\n ordered[key] = sortKeysDeep(record[key], seen);\n }\n seen.delete(value);\n\n return ordered;\n }\n\n return value;\n}\n\n/**\n * Deterministic JSON string with object keys sorted recursively, so key order\n * does not affect the output.\n *\n * Follows `JSON.stringify` semantics for the values it serializes: `undefined`,\n * functions and symbols are dropped, non-finite numbers become `null`, `bigint`\n * throws, and `Map`/`Set` serialize as `{}`. Distinct payloads can therefore\n * collapse to the same string — for collision-resistant hashing use\n * `PolicyHashing.canonicalJson` (policies/utils), which rejects those values\n * up front.\n *\n * @throws {TypeError} On circular references (mirroring `JSON.stringify`).\n */\nfunction stableStringify(value: unknown): string {\n return JSON.stringify(sortKeysDeep(value, new WeakSet<object>()));\n}\n\nfunction payloadHash(value: unknown): string {\n return sha256Hex(stableStringify(value));\n}\n\nexport { payloadHash, sha256Hex, stableStringify };\n"],"mappings":";;AAEA,MAAM,6BACF;AAEJ,SAAS,UAAU,OAAuB;CACtC,QAAA,GAAA,YAAA,YAAkB,QAAQ,EAAE,OAAO,OAAO,MAAM,EAAE,OAAO,KAAK;AAClE;AAIA,SAAS,aAAa,OAAgB,MAAgC;CAClE,IAAI,MAAM,QAAQ,KAAK,GAAG;EACtB,IAAI,KAAK,IAAI,KAAK,GACd,MAAM,IAAI,UAAU,0BAA0B;EAElD,KAAK,IAAI,KAAK;EACd,MAAM,SAAS,MAAM,KAAK,SAAS,aAAa,MAAM,IAAI,CAAC;EAC3D,KAAK,OAAO,KAAK;EACjB,OAAO;CACX;CAEA,IAAI,iBAAiB,MACjB,OAAO;CAGX,IAAI,SAAS,OAAO,UAAU,UAAU;EACpC,IAAI,KAAK,IAAI,KAAK,GACd,MAAM,IAAI,UAAU,0BAA0B;EAElD,KAAK,IAAI,KAAK;EACd,MAAM,SAAS;EACf,MAAM,UAAU,OAAO,OAAO,IAAI;EAElC,KAAK,MAAM,OAAO,OAAO,KAAK,MAAM,EAAE,KAAK,GACvC,QAAQ,OAAO,aAAa,OAAO,MAAM,IAAI;EAEjD,KAAK,OAAO,KAAK;EAEjB,OAAO;CACX;CAEA,OAAO;AACX;;;;;;;;;;;;;;AAeA,SAAS,gBAAgB,OAAwB;CAC7C,OAAO,KAAK,UAAU,aAAa,uBAAO,IAAI,QAAgB,CAAC,CAAC;AACpE;AAEA,SAAS,YAAY,OAAwB;CACzC,OAAO,UAAU,gBAAgB,KAAK,CAAC;AAC3C"}
1
+ {"version":3,"file":"hashing.cjs","names":["canonicalStringify"],"sources":["../src/core/shared/hashing.ts"],"sourcesContent":["import { createHash } from \"node:crypto\";\n\nimport { canonicalStringify } from \"./stable-stringify.js\";\n\nfunction sha256Hex(value: string): string {\n return createHash(\"sha256\").update(value, \"utf8\").digest(\"hex\");\n}\n\n// Strict by design: hashes the collision-resistant canonical form, so payloads\n// that differ only in values `JSON.stringify` would drop (undefined, NaN, )\n// produce distinct digests instead of silently colliding.\nfunction payloadHash(value: unknown): string {\n return sha256Hex(canonicalStringify(value));\n}\n\nexport { payloadHash, sha256Hex };\n"],"mappings":";;;AAIA,SAAS,UAAU,OAAuB;CACtC,QAAA,GAAA,YAAA,YAAkB,QAAQ,EAAE,OAAO,OAAO,MAAM,EAAE,OAAO,KAAK;AAClE;AAKA,SAAS,YAAY,OAAwB;CACzC,OAAO,UAAUA,yBAAAA,mBAAmB,KAAK,CAAC;AAC9C"}
package/dist/hashing.js CHANGED
@@ -1,49 +1,13 @@
1
+ import { t as canonicalStringify } from "./stable-stringify.js";
1
2
  import { createHash } from "node:crypto";
2
3
  //#region src/core/shared/hashing.ts
3
- const CIRCULAR_STRUCTURE_MESSAGE = "Cannot stably stringify a circular structure";
4
4
  function sha256Hex(value) {
5
5
  return createHash("sha256").update(value, "utf8").digest("hex");
6
6
  }
7
- function sortKeysDeep(value, seen) {
8
- if (Array.isArray(value)) {
9
- if (seen.has(value)) throw new TypeError(CIRCULAR_STRUCTURE_MESSAGE);
10
- seen.add(value);
11
- const mapped = value.map((item) => sortKeysDeep(item, seen));
12
- seen.delete(value);
13
- return mapped;
14
- }
15
- if (value instanceof Date) return value;
16
- if (value && typeof value === "object") {
17
- if (seen.has(value)) throw new TypeError(CIRCULAR_STRUCTURE_MESSAGE);
18
- seen.add(value);
19
- const record = value;
20
- const ordered = Object.create(null);
21
- for (const key of Object.keys(record).sort()) ordered[key] = sortKeysDeep(record[key], seen);
22
- seen.delete(value);
23
- return ordered;
24
- }
25
- return value;
26
- }
27
- /**
28
- * Deterministic JSON string with object keys sorted recursively, so key order
29
- * does not affect the output.
30
- *
31
- * Follows `JSON.stringify` semantics for the values it serializes: `undefined`,
32
- * functions and symbols are dropped, non-finite numbers become `null`, `bigint`
33
- * throws, and `Map`/`Set` serialize as `{}`. Distinct payloads can therefore
34
- * collapse to the same string — for collision-resistant hashing use
35
- * `PolicyHashing.canonicalJson` (policies/utils), which rejects those values
36
- * up front.
37
- *
38
- * @throws {TypeError} On circular references (mirroring `JSON.stringify`).
39
- */
40
- function stableStringify(value) {
41
- return JSON.stringify(sortKeysDeep(value, /* @__PURE__ */ new WeakSet()));
42
- }
43
7
  function payloadHash(value) {
44
- return sha256Hex(stableStringify(value));
8
+ return sha256Hex(canonicalStringify(value));
45
9
  }
46
10
  //#endregion
47
- export { sha256Hex as n, stableStringify as r, payloadHash as t };
11
+ export { sha256Hex as n, payloadHash as t };
48
12
 
49
13
  //# sourceMappingURL=hashing.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"hashing.js","names":[],"sources":["../src/core/shared/hashing.ts"],"sourcesContent":["import { createHash } from \"node:crypto\";\n\nconst CIRCULAR_STRUCTURE_MESSAGE =\n \"Cannot stably stringify a circular structure\";\n\nfunction sha256Hex(value: string): string {\n return createHash(\"sha256\").update(value, \"utf8\").digest(\"hex\");\n}\n\n// `seen` holds the current traversal branch so true cycles are rejected while\n// repeated (acyclic) references are still serialized — matching JSON.stringify.\nfunction sortKeysDeep(value: unknown, seen: WeakSet<object>): unknown {\n if (Array.isArray(value)) {\n if (seen.has(value)) {\n throw new TypeError(CIRCULAR_STRUCTURE_MESSAGE);\n }\n seen.add(value);\n const mapped = value.map((item) => sortKeysDeep(item, seen));\n seen.delete(value);\n return mapped;\n }\n\n if (value instanceof Date) {\n return value;\n }\n\n if (value && typeof value === \"object\") {\n if (seen.has(value)) {\n throw new TypeError(CIRCULAR_STRUCTURE_MESSAGE);\n }\n seen.add(value);\n const record = value as Record<string, unknown>;\n const ordered = Object.create(null) as Record<string, unknown>;\n\n for (const key of Object.keys(record).sort()) {\n ordered[key] = sortKeysDeep(record[key], seen);\n }\n seen.delete(value);\n\n return ordered;\n }\n\n return value;\n}\n\n/**\n * Deterministic JSON string with object keys sorted recursively, so key order\n * does not affect the output.\n *\n * Follows `JSON.stringify` semantics for the values it serializes: `undefined`,\n * functions and symbols are dropped, non-finite numbers become `null`, `bigint`\n * throws, and `Map`/`Set` serialize as `{}`. Distinct payloads can therefore\n * collapse to the same string — for collision-resistant hashing use\n * `PolicyHashing.canonicalJson` (policies/utils), which rejects those values\n * up front.\n *\n * @throws {TypeError} On circular references (mirroring `JSON.stringify`).\n */\nfunction stableStringify(value: unknown): string {\n return JSON.stringify(sortKeysDeep(value, new WeakSet<object>()));\n}\n\nfunction payloadHash(value: unknown): string {\n return sha256Hex(stableStringify(value));\n}\n\nexport { payloadHash, sha256Hex, stableStringify };\n"],"mappings":";;AAEA,MAAM,6BACF;AAEJ,SAAS,UAAU,OAAuB;CACtC,OAAO,WAAW,QAAQ,EAAE,OAAO,OAAO,MAAM,EAAE,OAAO,KAAK;AAClE;AAIA,SAAS,aAAa,OAAgB,MAAgC;CAClE,IAAI,MAAM,QAAQ,KAAK,GAAG;EACtB,IAAI,KAAK,IAAI,KAAK,GACd,MAAM,IAAI,UAAU,0BAA0B;EAElD,KAAK,IAAI,KAAK;EACd,MAAM,SAAS,MAAM,KAAK,SAAS,aAAa,MAAM,IAAI,CAAC;EAC3D,KAAK,OAAO,KAAK;EACjB,OAAO;CACX;CAEA,IAAI,iBAAiB,MACjB,OAAO;CAGX,IAAI,SAAS,OAAO,UAAU,UAAU;EACpC,IAAI,KAAK,IAAI,KAAK,GACd,MAAM,IAAI,UAAU,0BAA0B;EAElD,KAAK,IAAI,KAAK;EACd,MAAM,SAAS;EACf,MAAM,UAAU,OAAO,OAAO,IAAI;EAElC,KAAK,MAAM,OAAO,OAAO,KAAK,MAAM,EAAE,KAAK,GACvC,QAAQ,OAAO,aAAa,OAAO,MAAM,IAAI;EAEjD,KAAK,OAAO,KAAK;EAEjB,OAAO;CACX;CAEA,OAAO;AACX;;;;;;;;;;;;;;AAeA,SAAS,gBAAgB,OAAwB;CAC7C,OAAO,KAAK,UAAU,aAAa,uBAAO,IAAI,QAAgB,CAAC,CAAC;AACpE;AAEA,SAAS,YAAY,OAAwB;CACzC,OAAO,UAAU,gBAAgB,KAAK,CAAC;AAC3C"}
1
+ {"version":3,"file":"hashing.js","names":[],"sources":["../src/core/shared/hashing.ts"],"sourcesContent":["import { createHash } from \"node:crypto\";\n\nimport { canonicalStringify } from \"./stable-stringify.js\";\n\nfunction sha256Hex(value: string): string {\n return createHash(\"sha256\").update(value, \"utf8\").digest(\"hex\");\n}\n\n// Strict by design: hashes the collision-resistant canonical form, so payloads\n// that differ only in values `JSON.stringify` would drop (undefined, NaN, )\n// produce distinct digests instead of silently colliding.\nfunction payloadHash(value: unknown): string {\n return sha256Hex(canonicalStringify(value));\n}\n\nexport { payloadHash, sha256Hex };\n"],"mappings":";;;AAIA,SAAS,UAAU,OAAuB;CACtC,OAAO,WAAW,QAAQ,EAAE,OAAO,OAAO,MAAM,EAAE,OAAO,KAAK;AAClE;AAKA,SAAS,YAAY,OAAwB;CACzC,OAAO,UAAU,mBAAmB,KAAK,CAAC;AAC9C"}
@@ -2,8 +2,26 @@ const require_invariant_violation_exception = require("./invariant-violation-exc
2
2
  //#region src/core/versioning/version.ts
3
3
  const CONTRACT_VERSION_PROPERTY = "CONTRACT_VERSION";
4
4
  const CONTRACT_VERSION_PATTERN = /^\d+\.\d+$/;
5
+ /**
6
+ * Class decorator that stamps a `MAJOR.MINOR` structural contract version onto
7
+ * the class as a static `CONTRACT_VERSION` property.
8
+ *
9
+ * The property is defined **non-writable, non-configurable and non-enumerable**
10
+ * on purpose: it must not be reassigned or redefined (tampering with a contract
11
+ * version silently corrupts migration decisions), and keeping it off enumeration
12
+ * excludes it from `JSON.stringify`/`for..in`. A consequence of
13
+ * `configurable: false` is that decorating the same class twice throws
14
+ * `TypeError: Cannot redefine property` — a deliberate fail-fast.
15
+ *
16
+ * Note on inheritance: a subclass that is not re-decorated inherits its base's
17
+ * `CONTRACT_VERSION` through the static prototype chain. Re-decorate any
18
+ * subclass whose persisted shape diverges from its base.
19
+ *
20
+ * @throws {InvariantViolationException} When `contractVersion` is not
21
+ * `MAJOR.MINOR` (validated at module-load time, when the decorator runs).
22
+ */
5
23
  function version(contractVersion) {
6
- if (!CONTRACT_VERSION_PATTERN.test(contractVersion)) throw new TypeError(`Invalid contract version "${contractVersion}". Expected MAJOR.MINOR.`);
24
+ if (!CONTRACT_VERSION_PATTERN.test(contractVersion)) throw new require_invariant_violation_exception.InvariantViolationException(`Invalid contract version "${contractVersion}". Expected MAJOR.MINOR.`);
7
25
  return (target) => {
8
26
  Object.defineProperty(target, CONTRACT_VERSION_PROPERTY, {
9
27
  value: contractVersion,
@@ -14,14 +32,6 @@ function version(contractVersion) {
14
32
  };
15
33
  }
16
34
  //#endregion
17
- //#region \0@oxc-project+runtime@0.132.0/helpers/decorate.js
18
- function __decorate(decorators, target, key, desc) {
19
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
20
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
21
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
22
- return c > 3 && r && Object.defineProperty(target, key, r), r;
23
- }
24
- //#endregion
25
35
  //#region src/core/shared/immutable.ts
26
36
  function deepFreeze(value) {
27
37
  return deepFreezeInternal(value, /* @__PURE__ */ new WeakSet());
@@ -35,7 +45,10 @@ function deepFreezeInternal(value, seen) {
35
45
  return Object.freeze(value);
36
46
  }
37
47
  const objectValue = value;
38
- for (const propertyKey of Reflect.ownKeys(objectValue)) deepFreezeInternal(objectValue[propertyKey], seen);
48
+ for (const propertyKey of Reflect.ownKeys(objectValue)) {
49
+ const descriptor = Object.getOwnPropertyDescriptor(objectValue, propertyKey);
50
+ if (descriptor && "value" in descriptor) deepFreezeInternal(descriptor.value, seen);
51
+ }
39
52
  return Object.freeze(value);
40
53
  }
41
54
  function makeImmutable(value) {
@@ -55,10 +68,10 @@ Object.defineProperty(exports, "CONTRACT_VERSION_PROPERTY", {
55
68
  return CONTRACT_VERSION_PROPERTY;
56
69
  }
57
70
  });
58
- Object.defineProperty(exports, "__decorate", {
71
+ Object.defineProperty(exports, "deepFreeze", {
59
72
  enumerable: true,
60
73
  get: function() {
61
- return __decorate;
74
+ return deepFreeze;
62
75
  }
63
76
  });
64
77
  Object.defineProperty(exports, "makeImmutable", {
@@ -1 +1 @@
1
- {"version":3,"file":"immutable.cjs","names":["InvariantViolationException"],"sources":["../src/core/versioning/version.ts","../src/core/shared/immutable.ts"],"sourcesContent":["type ContractVersion = `${number}.${number}`;\n\ntype VersionedTarget = {\n readonly prototype: object;\n};\n\nconst CONTRACT_VERSION_PROPERTY = \"CONTRACT_VERSION\" as const;\nconst CONTRACT_VERSION_PATTERN = /^\\d+\\.\\d+$/;\n\nfunction version<const TVersion extends ContractVersion>(\n contractVersion: TVersion,\n) {\n if (!CONTRACT_VERSION_PATTERN.test(contractVersion)) {\n throw new TypeError(\n `Invalid contract version \"${contractVersion}\". Expected MAJOR.MINOR.`,\n );\n }\n\n return (target: VersionedTarget): void => {\n Object.defineProperty(target, CONTRACT_VERSION_PROPERTY, {\n value: contractVersion,\n writable: false,\n configurable: false,\n enumerable: false,\n });\n };\n}\n\nexport {\n CONTRACT_VERSION_PROPERTY,\n type ContractVersion,\n version,\n type VersionedTarget,\n};\n","import { InvariantViolationException } from \"../exceptions/invariant-violation-exception.js\";\n\ntype PrimitiveValue =\n | bigint\n | boolean\n | null\n | number\n | string\n | symbol\n | undefined;\n\ntype DeepReadonly<T> = T extends PrimitiveValue | Date\n ? T\n : T extends readonly (infer TItem)[]\n ? readonly DeepReadonly<TItem>[]\n : { readonly [TKey in keyof T]: DeepReadonly<T[TKey]> };\n\nfunction deepFreeze<T>(value: T): T {\n return deepFreezeInternal(value, new WeakSet<object>());\n}\n\nfunction deepFreezeInternal<T>(value: T, seen: WeakSet<object>): T {\n // Primitives and `null` need no freezing. `Date` is intentionally returned\n // as-is: `Object.freeze` cannot stop a Date's mutators (`setTime`,\n // `setFullYear`, …) because they write an internal slot, not an own\n // property — freezing it is a no-op against mutation. `makeImmutable`\n // already hands us a `structuredClone` copy, so the caller's original Date\n // is never aliased; deep-freezing of nested Dates is deliberately skipped.\n if (typeof value !== \"object\" || value === null || value instanceof Date) {\n return value;\n }\n\n // A value already on `seen` has been visited on this pass (cyclic graph or a\n // shared reference); revisiting it would recurse forever.\n if (seen.has(value)) {\n return value;\n }\n seen.add(value);\n\n if (Array.isArray(value)) {\n for (const item of value) {\n deepFreezeInternal(item, seen);\n }\n\n return Object.freeze(value);\n }\n\n const objectValue = value as Record<PropertyKey, object | PrimitiveValue>;\n\n for (const propertyKey of Reflect.ownKeys(objectValue)) {\n deepFreezeInternal(objectValue[propertyKey], seen);\n }\n\n return Object.freeze(value);\n}\n\nfunction makeImmutable<T>(value: T): DeepReadonly<T> {\n if (typeof value !== \"object\" || value === null) {\n return value as DeepReadonly<T>;\n }\n\n let snapshot: T;\n try {\n snapshot = structuredClone(value);\n } catch (error) {\n // `structuredClone` throws `DataCloneError` for functions, symbols and\n // class instances. Surface it as a domain invariant instead of leaking\n // a host-specific runtime error to callers building value objects.\n throw new InvariantViolationException(\n `makeImmutable requires a structured-cloneable value: ${\n error instanceof Error ? error.message : String(error)\n }`,\n );\n }\n\n return deepFreeze(snapshot) as DeepReadonly<T>;\n}\n\nexport { deepFreeze, makeImmutable, type DeepReadonly };\n"],"mappings":";;AAMA,MAAM,4BAA4B;AAClC,MAAM,2BAA2B;AAEjC,SAAS,QACL,iBACF;CACE,IAAI,CAAC,yBAAyB,KAAK,eAAe,GAC9C,MAAM,IAAI,UACN,6BAA6B,gBAAgB,yBACjD;CAGJ,QAAQ,WAAkC;EACtC,OAAO,eAAe,QAAQ,2BAA2B;GACrD,OAAO;GACP,UAAU;GACV,cAAc;GACd,YAAY;EAChB,CAAC;CACL;AACJ;;;;;;;;;;;ACTA,SAAS,WAAc,OAAa;CAChC,OAAO,mBAAmB,uBAAO,IAAI,QAAgB,CAAC;AAC1D;AAEA,SAAS,mBAAsB,OAAU,MAA0B;CAO/D,IAAI,OAAO,UAAU,YAAY,UAAU,QAAQ,iBAAiB,MAChE,OAAO;CAKX,IAAI,KAAK,IAAI,KAAK,GACd,OAAO;CAEX,KAAK,IAAI,KAAK;CAEd,IAAI,MAAM,QAAQ,KAAK,GAAG;EACtB,KAAK,MAAM,QAAQ,OACf,mBAAmB,MAAM,IAAI;EAGjC,OAAO,OAAO,OAAO,KAAK;CAC9B;CAEA,MAAM,cAAc;CAEpB,KAAK,MAAM,eAAe,QAAQ,QAAQ,WAAW,GACjD,mBAAmB,YAAY,cAAc,IAAI;CAGrD,OAAO,OAAO,OAAO,KAAK;AAC9B;AAEA,SAAS,cAAiB,OAA2B;CACjD,IAAI,OAAO,UAAU,YAAY,UAAU,MACvC,OAAO;CAGX,IAAI;CACJ,IAAI;EACA,WAAW,gBAAgB,KAAK;CACpC,SAAS,OAAO;EAIZ,MAAM,IAAIA,sCAAAA,4BACN,wDACI,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,GAE7D;CACJ;CAEA,OAAO,WAAW,QAAQ;AAC9B"}
1
+ {"version":3,"file":"immutable.cjs","names":["InvariantViolationException","InvariantViolationException"],"sources":["../src/core/versioning/version.ts","../src/core/shared/immutable.ts"],"sourcesContent":["import { InvariantViolationException } from \"../exceptions/invariant-violation-exception.js\";\n\n/**\n * A structural contract version in `MAJOR.MINOR` form (e.g. `\"1.0\"`, `\"2.5\"`).\n *\n * The template-literal type is intentionally loose — it also accepts strings\n * the module rejects at runtime (e.g. `\"1.0.0\"` matches as `1` · `.` · `0.0`).\n * The runtime regex in {@link version} is the real guard; the type is only a\n * light hint.\n */\ntype ContractVersion = `${number}.${number}`;\n\n/** Anything a class decorator can stamp a static property onto. */\ntype VersionedTarget = {\n readonly prototype: object;\n};\n\nconst CONTRACT_VERSION_PROPERTY = \"CONTRACT_VERSION\" as const;\nconst CONTRACT_VERSION_PATTERN = /^\\d+\\.\\d+$/;\n\n/**\n * Class decorator that stamps a `MAJOR.MINOR` structural contract version onto\n * the class as a static `CONTRACT_VERSION` property.\n *\n * The property is defined **non-writable, non-configurable and non-enumerable**\n * on purpose: it must not be reassigned or redefined (tampering with a contract\n * version silently corrupts migration decisions), and keeping it off enumeration\n * excludes it from `JSON.stringify`/`for..in`. A consequence of\n * `configurable: false` is that decorating the same class twice throws\n * `TypeError: Cannot redefine property` — a deliberate fail-fast.\n *\n * Note on inheritance: a subclass that is not re-decorated inherits its base's\n * `CONTRACT_VERSION` through the static prototype chain. Re-decorate any\n * subclass whose persisted shape diverges from its base.\n *\n * @throws {InvariantViolationException} When `contractVersion` is not\n * `MAJOR.MINOR` (validated at module-load time, when the decorator runs).\n */\nfunction version<const TVersion extends ContractVersion>(\n contractVersion: TVersion,\n) {\n if (!CONTRACT_VERSION_PATTERN.test(contractVersion)) {\n throw new InvariantViolationException(\n `Invalid contract version \"${contractVersion}\". Expected MAJOR.MINOR.`,\n );\n }\n\n return (target: VersionedTarget): void => {\n Object.defineProperty(target, CONTRACT_VERSION_PROPERTY, {\n value: contractVersion,\n writable: false,\n configurable: false,\n enumerable: false,\n });\n };\n}\n\nexport {\n CONTRACT_VERSION_PROPERTY,\n type ContractVersion,\n version,\n type VersionedTarget,\n};\n","import { InvariantViolationException } from \"../exceptions/invariant-violation-exception.js\";\n\ntype PrimitiveValue =\n | bigint\n | boolean\n | null\n | number\n | string\n | symbol\n | undefined;\n\ntype DeepReadonly<T> = T extends PrimitiveValue | Date\n ? T\n : T extends readonly (infer TItem)[]\n ? readonly DeepReadonly<TItem>[]\n : { readonly [TKey in keyof T]: DeepReadonly<T[TKey]> };\n\nfunction deepFreeze<T>(value: T): T {\n return deepFreezeInternal(value, new WeakSet<object>());\n}\n\nfunction deepFreezeInternal<T>(value: T, seen: WeakSet<object>): T {\n // Primitives and `null` need no freezing. `Date` is intentionally returned\n // as-is: `Object.freeze` cannot stop a Date's mutators (`setTime`,\n // `setFullYear`, …) because they write an internal slot, not an own\n // property — freezing it is a no-op against mutation. `makeImmutable`\n // already hands us a `structuredClone` copy, so the caller's original Date\n // is never aliased; deep-freezing of nested Dates is deliberately skipped.\n //\n // The same no-op caveat applies to `Map`/`Set`: `Object.freeze` locks the\n // wrapper's own properties but not `.set`/`.delete`/`.clear`, which mutate\n // internal slots. A frozen Map is still mutable through its methods. We do\n // not neuter those methods here (no value object wraps a Map today); if one\n // ever does, its immutability guarantee would be false — handle it there.\n if (typeof value !== \"object\" || value === null || value instanceof Date) {\n return value;\n }\n\n // A value already on `seen` has been visited on this pass (cyclic graph or a\n // shared reference); revisiting it would recurse forever.\n if (seen.has(value)) {\n return value;\n }\n seen.add(value);\n\n if (Array.isArray(value)) {\n for (const item of value) {\n deepFreezeInternal(item, seen);\n }\n\n return Object.freeze(value);\n }\n\n const objectValue = value as Record<PropertyKey, object | PrimitiveValue>;\n\n for (const propertyKey of Reflect.ownKeys(objectValue)) {\n // Read through the descriptor rather than `objectValue[propertyKey]` so\n // accessor properties are not invoked — a getter could have side effects\n // or throw, and its computed result can't be frozen anyway. Only data\n // properties hold a nested value worth recursing into.\n const descriptor = Object.getOwnPropertyDescriptor(\n objectValue,\n propertyKey,\n );\n if (descriptor && \"value\" in descriptor) {\n deepFreezeInternal(descriptor.value, seen);\n }\n }\n\n return Object.freeze(value);\n}\n\nfunction makeImmutable<T>(value: T): DeepReadonly<T> {\n if (typeof value !== \"object\" || value === null) {\n return value as DeepReadonly<T>;\n }\n\n let snapshot: T;\n try {\n snapshot = structuredClone(value);\n } catch (error) {\n // `structuredClone` throws `DataCloneError` for functions and symbols.\n // (Class instances do NOT throw — they are silently flattened to plain\n // objects, prototype lost.) Surface the error as a domain invariant\n // instead of leaking a host-specific runtime error to callers building\n // value objects.\n throw new InvariantViolationException(\n `makeImmutable requires a structured-cloneable value: ${\n error instanceof Error ? error.message : String(error)\n }`,\n );\n }\n\n return deepFreeze(snapshot) as DeepReadonly<T>;\n}\n\nexport { deepFreeze, makeImmutable, type DeepReadonly };\n"],"mappings":";;AAiBA,MAAM,4BAA4B;AAClC,MAAM,2BAA2B;;;;;;;;;;;;;;;;;;;AAoBjC,SAAS,QACL,iBACF;CACE,IAAI,CAAC,yBAAyB,KAAK,eAAe,GAC9C,MAAM,IAAIA,sCAAAA,4BACN,6BAA6B,gBAAgB,yBACjD;CAGJ,QAAQ,WAAkC;EACtC,OAAO,eAAe,QAAQ,2BAA2B;GACrD,OAAO;GACP,UAAU;GACV,cAAc;GACd,YAAY;EAChB,CAAC;CACL;AACJ;;;ACtCA,SAAS,WAAc,OAAa;CAChC,OAAO,mBAAmB,uBAAO,IAAI,QAAgB,CAAC;AAC1D;AAEA,SAAS,mBAAsB,OAAU,MAA0B;CAa/D,IAAI,OAAO,UAAU,YAAY,UAAU,QAAQ,iBAAiB,MAChE,OAAO;CAKX,IAAI,KAAK,IAAI,KAAK,GACd,OAAO;CAEX,KAAK,IAAI,KAAK;CAEd,IAAI,MAAM,QAAQ,KAAK,GAAG;EACtB,KAAK,MAAM,QAAQ,OACf,mBAAmB,MAAM,IAAI;EAGjC,OAAO,OAAO,OAAO,KAAK;CAC9B;CAEA,MAAM,cAAc;CAEpB,KAAK,MAAM,eAAe,QAAQ,QAAQ,WAAW,GAAG;EAKpD,MAAM,aAAa,OAAO,yBACtB,aACA,WACJ;EACA,IAAI,cAAc,WAAW,YACzB,mBAAmB,WAAW,OAAO,IAAI;CAEjD;CAEA,OAAO,OAAO,OAAO,KAAK;AAC9B;AAEA,SAAS,cAAiB,OAA2B;CACjD,IAAI,OAAO,UAAU,YAAY,UAAU,MACvC,OAAO;CAGX,IAAI;CACJ,IAAI;EACA,WAAW,gBAAgB,KAAK;CACpC,SAAS,OAAO;EAMZ,MAAM,IAAIC,sCAAAA,4BACN,wDACI,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,GAE7D;CACJ;CAEA,OAAO,WAAW,QAAQ;AAC9B"}
package/dist/immutable.js CHANGED
@@ -2,8 +2,26 @@ import { t as InvariantViolationException } from "./invariant-violation-exceptio
2
2
  //#region src/core/versioning/version.ts
3
3
  const CONTRACT_VERSION_PROPERTY = "CONTRACT_VERSION";
4
4
  const CONTRACT_VERSION_PATTERN = /^\d+\.\d+$/;
5
+ /**
6
+ * Class decorator that stamps a `MAJOR.MINOR` structural contract version onto
7
+ * the class as a static `CONTRACT_VERSION` property.
8
+ *
9
+ * The property is defined **non-writable, non-configurable and non-enumerable**
10
+ * on purpose: it must not be reassigned or redefined (tampering with a contract
11
+ * version silently corrupts migration decisions), and keeping it off enumeration
12
+ * excludes it from `JSON.stringify`/`for..in`. A consequence of
13
+ * `configurable: false` is that decorating the same class twice throws
14
+ * `TypeError: Cannot redefine property` — a deliberate fail-fast.
15
+ *
16
+ * Note on inheritance: a subclass that is not re-decorated inherits its base's
17
+ * `CONTRACT_VERSION` through the static prototype chain. Re-decorate any
18
+ * subclass whose persisted shape diverges from its base.
19
+ *
20
+ * @throws {InvariantViolationException} When `contractVersion` is not
21
+ * `MAJOR.MINOR` (validated at module-load time, when the decorator runs).
22
+ */
5
23
  function version(contractVersion) {
6
- if (!CONTRACT_VERSION_PATTERN.test(contractVersion)) throw new TypeError(`Invalid contract version "${contractVersion}". Expected MAJOR.MINOR.`);
24
+ if (!CONTRACT_VERSION_PATTERN.test(contractVersion)) throw new InvariantViolationException(`Invalid contract version "${contractVersion}". Expected MAJOR.MINOR.`);
7
25
  return (target) => {
8
26
  Object.defineProperty(target, CONTRACT_VERSION_PROPERTY, {
9
27
  value: contractVersion,
@@ -14,14 +32,6 @@ function version(contractVersion) {
14
32
  };
15
33
  }
16
34
  //#endregion
17
- //#region \0@oxc-project+runtime@0.132.0/helpers/decorate.js
18
- function __decorate(decorators, target, key, desc) {
19
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
20
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
21
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
22
- return c > 3 && r && Object.defineProperty(target, key, r), r;
23
- }
24
- //#endregion
25
35
  //#region src/core/shared/immutable.ts
26
36
  function deepFreeze(value) {
27
37
  return deepFreezeInternal(value, /* @__PURE__ */ new WeakSet());
@@ -35,7 +45,10 @@ function deepFreezeInternal(value, seen) {
35
45
  return Object.freeze(value);
36
46
  }
37
47
  const objectValue = value;
38
- for (const propertyKey of Reflect.ownKeys(objectValue)) deepFreezeInternal(objectValue[propertyKey], seen);
48
+ for (const propertyKey of Reflect.ownKeys(objectValue)) {
49
+ const descriptor = Object.getOwnPropertyDescriptor(objectValue, propertyKey);
50
+ if (descriptor && "value" in descriptor) deepFreezeInternal(descriptor.value, seen);
51
+ }
39
52
  return Object.freeze(value);
40
53
  }
41
54
  function makeImmutable(value) {
@@ -49,6 +62,6 @@ function makeImmutable(value) {
49
62
  return deepFreeze(snapshot);
50
63
  }
51
64
  //#endregion
52
- export { version as i, __decorate as n, CONTRACT_VERSION_PROPERTY as r, makeImmutable as t };
65
+ export { version as i, makeImmutable as n, CONTRACT_VERSION_PROPERTY as r, deepFreeze as t };
53
66
 
54
67
  //# sourceMappingURL=immutable.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"immutable.js","names":[],"sources":["../src/core/versioning/version.ts","../src/core/shared/immutable.ts"],"sourcesContent":["type ContractVersion = `${number}.${number}`;\n\ntype VersionedTarget = {\n readonly prototype: object;\n};\n\nconst CONTRACT_VERSION_PROPERTY = \"CONTRACT_VERSION\" as const;\nconst CONTRACT_VERSION_PATTERN = /^\\d+\\.\\d+$/;\n\nfunction version<const TVersion extends ContractVersion>(\n contractVersion: TVersion,\n) {\n if (!CONTRACT_VERSION_PATTERN.test(contractVersion)) {\n throw new TypeError(\n `Invalid contract version \"${contractVersion}\". Expected MAJOR.MINOR.`,\n );\n }\n\n return (target: VersionedTarget): void => {\n Object.defineProperty(target, CONTRACT_VERSION_PROPERTY, {\n value: contractVersion,\n writable: false,\n configurable: false,\n enumerable: false,\n });\n };\n}\n\nexport {\n CONTRACT_VERSION_PROPERTY,\n type ContractVersion,\n version,\n type VersionedTarget,\n};\n","import { InvariantViolationException } from \"../exceptions/invariant-violation-exception.js\";\n\ntype PrimitiveValue =\n | bigint\n | boolean\n | null\n | number\n | string\n | symbol\n | undefined;\n\ntype DeepReadonly<T> = T extends PrimitiveValue | Date\n ? T\n : T extends readonly (infer TItem)[]\n ? readonly DeepReadonly<TItem>[]\n : { readonly [TKey in keyof T]: DeepReadonly<T[TKey]> };\n\nfunction deepFreeze<T>(value: T): T {\n return deepFreezeInternal(value, new WeakSet<object>());\n}\n\nfunction deepFreezeInternal<T>(value: T, seen: WeakSet<object>): T {\n // Primitives and `null` need no freezing. `Date` is intentionally returned\n // as-is: `Object.freeze` cannot stop a Date's mutators (`setTime`,\n // `setFullYear`, …) because they write an internal slot, not an own\n // property — freezing it is a no-op against mutation. `makeImmutable`\n // already hands us a `structuredClone` copy, so the caller's original Date\n // is never aliased; deep-freezing of nested Dates is deliberately skipped.\n if (typeof value !== \"object\" || value === null || value instanceof Date) {\n return value;\n }\n\n // A value already on `seen` has been visited on this pass (cyclic graph or a\n // shared reference); revisiting it would recurse forever.\n if (seen.has(value)) {\n return value;\n }\n seen.add(value);\n\n if (Array.isArray(value)) {\n for (const item of value) {\n deepFreezeInternal(item, seen);\n }\n\n return Object.freeze(value);\n }\n\n const objectValue = value as Record<PropertyKey, object | PrimitiveValue>;\n\n for (const propertyKey of Reflect.ownKeys(objectValue)) {\n deepFreezeInternal(objectValue[propertyKey], seen);\n }\n\n return Object.freeze(value);\n}\n\nfunction makeImmutable<T>(value: T): DeepReadonly<T> {\n if (typeof value !== \"object\" || value === null) {\n return value as DeepReadonly<T>;\n }\n\n let snapshot: T;\n try {\n snapshot = structuredClone(value);\n } catch (error) {\n // `structuredClone` throws `DataCloneError` for functions, symbols and\n // class instances. Surface it as a domain invariant instead of leaking\n // a host-specific runtime error to callers building value objects.\n throw new InvariantViolationException(\n `makeImmutable requires a structured-cloneable value: ${\n error instanceof Error ? error.message : String(error)\n }`,\n );\n }\n\n return deepFreeze(snapshot) as DeepReadonly<T>;\n}\n\nexport { deepFreeze, makeImmutable, type DeepReadonly };\n"],"mappings":";;AAMA,MAAM,4BAA4B;AAClC,MAAM,2BAA2B;AAEjC,SAAS,QACL,iBACF;CACE,IAAI,CAAC,yBAAyB,KAAK,eAAe,GAC9C,MAAM,IAAI,UACN,6BAA6B,gBAAgB,yBACjD;CAGJ,QAAQ,WAAkC;EACtC,OAAO,eAAe,QAAQ,2BAA2B;GACrD,OAAO;GACP,UAAU;GACV,cAAc;GACd,YAAY;EAChB,CAAC;CACL;AACJ;;;;;;;;;;;ACTA,SAAS,WAAc,OAAa;CAChC,OAAO,mBAAmB,uBAAO,IAAI,QAAgB,CAAC;AAC1D;AAEA,SAAS,mBAAsB,OAAU,MAA0B;CAO/D,IAAI,OAAO,UAAU,YAAY,UAAU,QAAQ,iBAAiB,MAChE,OAAO;CAKX,IAAI,KAAK,IAAI,KAAK,GACd,OAAO;CAEX,KAAK,IAAI,KAAK;CAEd,IAAI,MAAM,QAAQ,KAAK,GAAG;EACtB,KAAK,MAAM,QAAQ,OACf,mBAAmB,MAAM,IAAI;EAGjC,OAAO,OAAO,OAAO,KAAK;CAC9B;CAEA,MAAM,cAAc;CAEpB,KAAK,MAAM,eAAe,QAAQ,QAAQ,WAAW,GACjD,mBAAmB,YAAY,cAAc,IAAI;CAGrD,OAAO,OAAO,OAAO,KAAK;AAC9B;AAEA,SAAS,cAAiB,OAA2B;CACjD,IAAI,OAAO,UAAU,YAAY,UAAU,MACvC,OAAO;CAGX,IAAI;CACJ,IAAI;EACA,WAAW,gBAAgB,KAAK;CACpC,SAAS,OAAO;EAIZ,MAAM,IAAI,4BACN,wDACI,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,GAE7D;CACJ;CAEA,OAAO,WAAW,QAAQ;AAC9B"}
1
+ {"version":3,"file":"immutable.js","names":[],"sources":["../src/core/versioning/version.ts","../src/core/shared/immutable.ts"],"sourcesContent":["import { InvariantViolationException } from \"../exceptions/invariant-violation-exception.js\";\n\n/**\n * A structural contract version in `MAJOR.MINOR` form (e.g. `\"1.0\"`, `\"2.5\"`).\n *\n * The template-literal type is intentionally loose — it also accepts strings\n * the module rejects at runtime (e.g. `\"1.0.0\"` matches as `1` · `.` · `0.0`).\n * The runtime regex in {@link version} is the real guard; the type is only a\n * light hint.\n */\ntype ContractVersion = `${number}.${number}`;\n\n/** Anything a class decorator can stamp a static property onto. */\ntype VersionedTarget = {\n readonly prototype: object;\n};\n\nconst CONTRACT_VERSION_PROPERTY = \"CONTRACT_VERSION\" as const;\nconst CONTRACT_VERSION_PATTERN = /^\\d+\\.\\d+$/;\n\n/**\n * Class decorator that stamps a `MAJOR.MINOR` structural contract version onto\n * the class as a static `CONTRACT_VERSION` property.\n *\n * The property is defined **non-writable, non-configurable and non-enumerable**\n * on purpose: it must not be reassigned or redefined (tampering with a contract\n * version silently corrupts migration decisions), and keeping it off enumeration\n * excludes it from `JSON.stringify`/`for..in`. A consequence of\n * `configurable: false` is that decorating the same class twice throws\n * `TypeError: Cannot redefine property` — a deliberate fail-fast.\n *\n * Note on inheritance: a subclass that is not re-decorated inherits its base's\n * `CONTRACT_VERSION` through the static prototype chain. Re-decorate any\n * subclass whose persisted shape diverges from its base.\n *\n * @throws {InvariantViolationException} When `contractVersion` is not\n * `MAJOR.MINOR` (validated at module-load time, when the decorator runs).\n */\nfunction version<const TVersion extends ContractVersion>(\n contractVersion: TVersion,\n) {\n if (!CONTRACT_VERSION_PATTERN.test(contractVersion)) {\n throw new InvariantViolationException(\n `Invalid contract version \"${contractVersion}\". Expected MAJOR.MINOR.`,\n );\n }\n\n return (target: VersionedTarget): void => {\n Object.defineProperty(target, CONTRACT_VERSION_PROPERTY, {\n value: contractVersion,\n writable: false,\n configurable: false,\n enumerable: false,\n });\n };\n}\n\nexport {\n CONTRACT_VERSION_PROPERTY,\n type ContractVersion,\n version,\n type VersionedTarget,\n};\n","import { InvariantViolationException } from \"../exceptions/invariant-violation-exception.js\";\n\ntype PrimitiveValue =\n | bigint\n | boolean\n | null\n | number\n | string\n | symbol\n | undefined;\n\ntype DeepReadonly<T> = T extends PrimitiveValue | Date\n ? T\n : T extends readonly (infer TItem)[]\n ? readonly DeepReadonly<TItem>[]\n : { readonly [TKey in keyof T]: DeepReadonly<T[TKey]> };\n\nfunction deepFreeze<T>(value: T): T {\n return deepFreezeInternal(value, new WeakSet<object>());\n}\n\nfunction deepFreezeInternal<T>(value: T, seen: WeakSet<object>): T {\n // Primitives and `null` need no freezing. `Date` is intentionally returned\n // as-is: `Object.freeze` cannot stop a Date's mutators (`setTime`,\n // `setFullYear`, …) because they write an internal slot, not an own\n // property — freezing it is a no-op against mutation. `makeImmutable`\n // already hands us a `structuredClone` copy, so the caller's original Date\n // is never aliased; deep-freezing of nested Dates is deliberately skipped.\n //\n // The same no-op caveat applies to `Map`/`Set`: `Object.freeze` locks the\n // wrapper's own properties but not `.set`/`.delete`/`.clear`, which mutate\n // internal slots. A frozen Map is still mutable through its methods. We do\n // not neuter those methods here (no value object wraps a Map today); if one\n // ever does, its immutability guarantee would be false — handle it there.\n if (typeof value !== \"object\" || value === null || value instanceof Date) {\n return value;\n }\n\n // A value already on `seen` has been visited on this pass (cyclic graph or a\n // shared reference); revisiting it would recurse forever.\n if (seen.has(value)) {\n return value;\n }\n seen.add(value);\n\n if (Array.isArray(value)) {\n for (const item of value) {\n deepFreezeInternal(item, seen);\n }\n\n return Object.freeze(value);\n }\n\n const objectValue = value as Record<PropertyKey, object | PrimitiveValue>;\n\n for (const propertyKey of Reflect.ownKeys(objectValue)) {\n // Read through the descriptor rather than `objectValue[propertyKey]` so\n // accessor properties are not invoked — a getter could have side effects\n // or throw, and its computed result can't be frozen anyway. Only data\n // properties hold a nested value worth recursing into.\n const descriptor = Object.getOwnPropertyDescriptor(\n objectValue,\n propertyKey,\n );\n if (descriptor && \"value\" in descriptor) {\n deepFreezeInternal(descriptor.value, seen);\n }\n }\n\n return Object.freeze(value);\n}\n\nfunction makeImmutable<T>(value: T): DeepReadonly<T> {\n if (typeof value !== \"object\" || value === null) {\n return value as DeepReadonly<T>;\n }\n\n let snapshot: T;\n try {\n snapshot = structuredClone(value);\n } catch (error) {\n // `structuredClone` throws `DataCloneError` for functions and symbols.\n // (Class instances do NOT throw — they are silently flattened to plain\n // objects, prototype lost.) Surface the error as a domain invariant\n // instead of leaking a host-specific runtime error to callers building\n // value objects.\n throw new InvariantViolationException(\n `makeImmutable requires a structured-cloneable value: ${\n error instanceof Error ? error.message : String(error)\n }`,\n );\n }\n\n return deepFreeze(snapshot) as DeepReadonly<T>;\n}\n\nexport { deepFreeze, makeImmutable, type DeepReadonly };\n"],"mappings":";;AAiBA,MAAM,4BAA4B;AAClC,MAAM,2BAA2B;;;;;;;;;;;;;;;;;;;AAoBjC,SAAS,QACL,iBACF;CACE,IAAI,CAAC,yBAAyB,KAAK,eAAe,GAC9C,MAAM,IAAI,4BACN,6BAA6B,gBAAgB,yBACjD;CAGJ,QAAQ,WAAkC;EACtC,OAAO,eAAe,QAAQ,2BAA2B;GACrD,OAAO;GACP,UAAU;GACV,cAAc;GACd,YAAY;EAChB,CAAC;CACL;AACJ;;;ACtCA,SAAS,WAAc,OAAa;CAChC,OAAO,mBAAmB,uBAAO,IAAI,QAAgB,CAAC;AAC1D;AAEA,SAAS,mBAAsB,OAAU,MAA0B;CAa/D,IAAI,OAAO,UAAU,YAAY,UAAU,QAAQ,iBAAiB,MAChE,OAAO;CAKX,IAAI,KAAK,IAAI,KAAK,GACd,OAAO;CAEX,KAAK,IAAI,KAAK;CAEd,IAAI,MAAM,QAAQ,KAAK,GAAG;EACtB,KAAK,MAAM,QAAQ,OACf,mBAAmB,MAAM,IAAI;EAGjC,OAAO,OAAO,OAAO,KAAK;CAC9B;CAEA,MAAM,cAAc;CAEpB,KAAK,MAAM,eAAe,QAAQ,QAAQ,WAAW,GAAG;EAKpD,MAAM,aAAa,OAAO,yBACtB,aACA,WACJ;EACA,IAAI,cAAc,WAAW,YACzB,mBAAmB,WAAW,OAAO,IAAI;CAEjD;CAEA,OAAO,OAAO,OAAO,KAAK;AAC9B;AAEA,SAAS,cAAiB,OAA2B;CACjD,IAAI,OAAO,UAAU,YAAY,UAAU,MACvC,OAAO;CAGX,IAAI;CACJ,IAAI;EACA,WAAW,gBAAgB,KAAK;CACpC,SAAS,OAAO;EAMZ,MAAM,IAAI,4BACN,wDACI,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,GAE7D;CACJ;CAEA,OAAO,WAAW,QAAQ;AAC9B"}
package/dist/index.cjs CHANGED
@@ -1,21 +1,20 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_app_error = require("./app-error.cjs");
3
- const require_validation_error = require("./validation-error.cjs");
4
3
  const require_authorization_error = require("./authorization-error.cjs");
4
+ const require_validation_error = require("./validation-error.cjs");
5
5
  const require_not_found_error = require("./not-found-error.cjs");
6
+ const require_domain_exception = require("./domain-exception.cjs");
7
+ const require_invariant_violation_exception = require("./invariant-violation-exception.cjs");
8
+ const require_stable_stringify = require("./stable-stringify.cjs");
6
9
  const require_hashing = require("./hashing.cjs");
7
10
  const require_unexpected_error = require("./unexpected-error.cjs");
8
11
  const require_validation_code = require("./validation-code.cjs");
9
12
  const require_validation_field = require("./validation-field.cjs");
10
- const require_domain_exception = require("./domain-exception.cjs");
11
13
  const require_invalid_state_transition_exception = require("./invalid-state-transition-exception.cjs");
12
- const require_invariant_violation_exception = require("./invariant-violation-exception.cjs");
13
14
  const require_validation_exception = require("./validation-exception.cjs");
14
15
  const require_immutable = require("./immutable.cjs");
15
- const require_use_case = require("./use-case.cjs");
16
- const require_requested_by = require("./requested-by.cjs");
17
16
  const require_temporal_use_case = require("./temporal-use-case.cjs");
18
- const require_entity = require("./entity.cjs");
17
+ const require_requested_by = require("./requested-by.cjs");
19
18
  const require_plugin = require("./plugin.cjs");
20
19
  const require_value_object = require("./value-object.cjs");
21
20
  const require_uuid_identifier = require("./uuid-identifier.cjs");
@@ -29,7 +28,7 @@ const require_domain_event_contracts = require("./domain-event-contracts.cjs");
29
28
  const require_outcome = require("./outcome.cjs");
30
29
  const require_gate_engine_registry = require("./gate-engine-registry.cjs");
31
30
  //#region src/version.ts
32
- const version$1 = "1.4.0";
31
+ const version$1 = "2.0.0";
33
32
  //#endregion
34
33
  //#region src/index.ts
35
34
  const ERP_CORE_NAME = "erp-core";
@@ -73,7 +72,7 @@ exports.ERP_CORE_VERSION = ERP_CORE_VERSION;
73
72
  Object.defineProperty(exports, "Entity", {
74
73
  enumerable: true,
75
74
  get: function() {
76
- return require_entity.Entity;
75
+ return require_uuid_identifier.Entity;
77
76
  }
78
77
  });
79
78
  exports.EntityNotFoundException = require_invalid_state_transition_exception.EntityNotFoundException;
@@ -132,13 +131,18 @@ exports.SerializationInError = require_validation_error.SerializationInError;
132
131
  exports.SerializationMessages = require_validation_error.SerializationMessages;
133
132
  exports.SerializationOutError = require_validation_error.SerializationOutError;
134
133
  exports.TemporalError = require_validation_error.TemporalError;
135
- exports.TemporalUseCase = require_temporal_use_case.TemporalUseCase;
134
+ Object.defineProperty(exports, "TemporalUseCase", {
135
+ enumerable: true,
136
+ get: function() {
137
+ return require_temporal_use_case.TemporalUseCase;
138
+ }
139
+ });
136
140
  exports.UnexpectedError = require_unexpected_error.UnexpectedError;
137
141
  exports.UniqueConstraintViolationError = require_validation_error.UniqueConstraintViolationError;
138
142
  Object.defineProperty(exports, "UseCase", {
139
143
  enumerable: true,
140
144
  get: function() {
141
- return require_use_case.UseCase;
145
+ return require_temporal_use_case.UseCase;
142
146
  }
143
147
  });
144
148
  exports.UuidIdentifier = require_uuid_identifier.UuidIdentifier;
@@ -174,7 +178,7 @@ exports.registerNamespacedContextResolversIn = require_policy_service.registerNa
174
178
  exports.safePreview = require_validation_error.safePreview;
175
179
  exports.serializationErrorCode = require_app_error.serializationErrorCode;
176
180
  exports.sha256Hex = require_hashing.sha256Hex;
177
- exports.stableStringify = require_hashing.stableStringify;
181
+ exports.stableStringify = require_stable_stringify.stableStringify;
178
182
  exports.translateUniqueViolationToDuplicate = require_validation_error.translateUniqueViolationToDuplicate;
179
183
  exports.version = require_immutable.version;
180
184
 
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","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.4.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
+ {"version":3,"file":"index.cjs","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"}
package/dist/index.d.cts CHANGED
@@ -1,37 +1,36 @@
1
1
  import { n as RequestedByKind, t as RequestedBy } from "./requested-by.cjs";
2
- import { a as AbacPolicySet, c as AbacRuleProps, d as AbacAuthorizerPort, f as AbacAttributes, i as AbacDecision, l as RuleEffect, n as CompositeAuthorizer, o as CombiningAlgorithm, p as AbacRequest, r as AbacAuthorizer, s as AbacRule, t as CompositeAccessRequest, u as abacContext } from "./composite-authorizer.cjs";
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.cjs";
3
3
  import { a as JsonSafeRecord, i as JsonSafePrimitive, n as AppErrorOptions, o as JsonSafeValue, r as ErrorSeverity, t as AppError } from "./app-error.cjs";
4
4
  import { i as AuthorizationRequirement, n as AuthorizationErrorMetadata, r as AuthorizationErrorReason, t as AuthorizationError } from "./authorization-error.cjs";
5
5
  import { n as Ok, r as Result, t as Err } from "./result.cjs";
6
6
  import { n as Outcome, t as CommonOutcomeStatus } from "./outcome.cjs";
7
- import { C as GateTraceNodeSnapshot, D as VersionedGateEngine, E as PolicyViolation, O as GatePayload, S as GateTraceLeafSnapshot, T as PolicyContext, _ as ConditionEvaluationReportTag, a as PolicyDecisionId, b as GateOutcomeData, c as TenantId, d as asSchoolId, f as asTenantId, g as ConditionEvaluationReportLevel, h as ConditionEvaluationReport, l as asPolicyDecisionId, m as ConditionEvaluationOptions, n as CoreConfigOptions, o as PolicyDefinitionId, p as ConditionEvaluationCause, r as CoreObservabilityConfig, s as SchoolId, t as CoreConfig, u as asPolicyDefinitionId, v as ConditionEvaluatorReporter, w as GateViolationTrace, x as GateStatus, y as GateOutcome } from "./core-config.cjs";
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.cjs";
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.cjs";
9
9
  import { a as PluginContract, i as PipelineReducer, n as BasePlugin, r as InvokeOptions, t as PluginManager } from "./plugin.cjs";
10
10
  import { t as DeepReadonly } from "./immutable.cjs";
11
11
  import { i as version, n as ContractVersion, r as VersionedTarget, t as CONTRACT_VERSION_PROPERTY } from "./version.cjs";
12
12
  import { n as ValueObjectPluginContract, t as ValueObject } from "./value-object.cjs";
13
13
  import { a as Permission, i as ScopeProps, n as AccessRequest, o as PermissionProps, r as Scope, t as AuthorizerPort } from "./authorizer.port.cjs";
14
- import { A as LogPayload, C as UseCase, D as TracerPort, E as TraceSpan, O as MetricLabels, S as MaybePromise, T as TraceAttributeValue, _ as PolicyEvaluationOutput, a as TemporalContext, b as Command, c as CacheStrategy, d as mapPolicyEvaluationError, f as TemporalHistory, g as PolicyEvaluationInput, h as ResultRepository, i as CreateTemporalContextInput, j as LoggerPort, k as MetricsPort, l as Page, m as Repository, n as TemporalUseCaseInput, o as assertTemporalContext, p as TemporalRepository, r as TemporalizedContextSeed, s as createTemporalContext, t as TemporalUseCase, u as Query, v as PolicyPort, w as UseCaseObservability, x as CommandInput, y as PolicyPortError } from "./temporal-use-case.cjs";
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 payloadHash, N as sha256Hex, O as IdempotencyInProgressError, P as stableStringify, 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.cjs";
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.cjs";
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.cjs";
16
16
  import { t as ValidationCode } from "./validation-code.cjs";
17
17
  import { t as ValidationField } from "./validation-field.cjs";
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.cjs";
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.cjs";
20
20
  import { a as ComputePayloadParserRegistry, c as ComputeEvaluatorRegistry, o as ComputePayloadParsers, r as GatePayloadParsers, s as ComputeEngineRegistry } from "./parse-gate-payload.cjs";
21
21
  import { n as Entity, r as EntityState, t as UuidIdentifier } from "./uuid-identifier.cjs";
22
- import { t as DomainException } from "./domain-exception.cjs";
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.cjs";
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.cjs";
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.cjs";
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.cjs";
26
- import { a as buildDomainEventContractVersions, i as DomainEventEnvelope, n as DomainEventContractSelection, o as createDomainEventEnvelope, r as DomainEventContractVersions, t as CreateDomainEventEnvelopeInput } from "./domain-event-contracts.cjs";
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.cjs";
27
26
 
28
27
  //#region src/index.d.ts
29
28
  declare const ERP_CORE_NAME = "erp-core";
30
- declare const ERP_CORE_VERSION = "1.4.0";
29
+ declare const ERP_CORE_VERSION = "2.0.0";
31
30
  declare const erpCoreRelease: {
32
31
  readonly name: "erp-core";
33
- readonly version: "1.4.0";
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.cts.map