@afora/core 0.0.9 → 0.0.11

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 (186) hide show
  1. package/README.md +52 -30
  2. package/dist/adapters.js +31 -55
  3. package/dist/core/application/application.d.ts +30 -0
  4. package/dist/core/application/application.js +1291 -0
  5. package/dist/core/application/exceptions.js +85 -0
  6. package/dist/core/application/migrate.js +67 -0
  7. package/dist/core/application/providers.js +108 -0
  8. package/dist/core/application/registry.js +23 -0
  9. package/dist/core/application/schema.js +398 -0
  10. package/dist/core/application/start.js +162 -0
  11. package/dist/core/application/types/application.interface.d.ts +23 -3
  12. package/dist/core/auth/jwt.js +200 -0
  13. package/dist/core/auth/types/jwt.interface.d.ts +10 -2
  14. package/dist/core/blueprint/blueprint-plugin.js +7 -0
  15. package/dist/core/blueprint/blueprint.js +146 -0
  16. package/dist/core/blueprint/callable.js +13 -0
  17. package/dist/core/blueprint/exceptions.js +20 -0
  18. package/dist/core/blueprint/is-blueprint.js +4 -0
  19. package/dist/core/blueprint/list.js +19 -0
  20. package/dist/core/blueprint/optional.js +69 -0
  21. package/dist/core/blueprint/record-field.js +14 -0
  22. package/dist/core/blueprint/slice.js +127 -0
  23. package/dist/core/blueprint/types/blueprint.interface.d.ts +16 -0
  24. package/dist/core/blueprint/variant.js +72 -0
  25. package/dist/core/command/command.js +428 -0
  26. package/dist/core/command/exceptions.js +30 -0
  27. package/dist/core/command/types/command.interface.d.ts +10 -1
  28. package/dist/core/entity/abstract-entity.d.ts +19 -0
  29. package/dist/core/entity/abstract-entity.js +181 -0
  30. package/dist/core/entity/entity.js +209 -0
  31. package/dist/core/entity/event.d.ts +39 -0
  32. package/dist/core/entity/event.js +80 -0
  33. package/dist/core/entity/exceptions.js +27 -0
  34. package/dist/core/entity/trust.js +7 -0
  35. package/dist/core/entity/version.js +13 -0
  36. package/dist/core/environment/environment.d.ts +26 -3
  37. package/dist/core/environment/environment.js +71 -0
  38. package/dist/core/event-policy/event-policy.js +76 -0
  39. package/dist/core/event-policy/exceptions.js +12 -0
  40. package/dist/core/event-policy/publish.js +98 -0
  41. package/dist/core/event-policy/publishers.js +18 -0
  42. package/dist/core/event-policy/types/event-policy.interface.d.ts +8 -2
  43. package/dist/core/exception/enums/exception-layers.js +15 -0
  44. package/dist/core/exception/exception.d.ts +15 -0
  45. package/dist/core/exception/exception.js +128 -0
  46. package/dist/core/exception/exported.js +49 -0
  47. package/dist/core/exception/guard.d.ts +20 -1
  48. package/dist/core/exception/guard.js +16 -0
  49. package/dist/core/exception/types/exception.interface.d.ts +13 -0
  50. package/dist/core/json.js +19 -0
  51. package/dist/core/logger/exceptions.js +7 -0
  52. package/dist/core/logger/logger.d.ts +14 -1
  53. package/dist/core/logger/logger.js +178 -0
  54. package/dist/core/openapi/exceptions.js +7 -0
  55. package/dist/core/openapi/openapi.js +132 -0
  56. package/dist/core/openapi/types/openapi.interface.d.ts +7 -1
  57. package/dist/core/output/access.js +66 -0
  58. package/dist/core/output/coerce.js +38 -0
  59. package/dist/core/output/exceptions.js +22 -0
  60. package/dist/{index-y280ew0k.js → core/output/http.js} +35 -80
  61. package/dist/core/output/openapi-sink.d.ts +10 -2
  62. package/dist/{index-hg1z2s2v.js → core/output/openapi-sink.js} +60 -544
  63. package/dist/core/output/output.js +192 -0
  64. package/dist/core/output/problem.js +30 -0
  65. package/dist/core/output/select.js +28 -0
  66. package/dist/core/output/stage.js +111 -0
  67. package/dist/core/output/status.js +52 -0
  68. package/dist/core/output/types/http.interface.d.ts +5 -1
  69. package/dist/core/output/types/output.interface.d.ts +24 -0
  70. package/dist/core/parse/issue.js +31 -0
  71. package/dist/core/parse/parse.d.ts +8 -1
  72. package/dist/core/parse/parse.js +323 -0
  73. package/dist/core/parse/strip.js +48 -0
  74. package/dist/core/property/abstract-property.js +37 -0
  75. package/dist/core/property/define-property.js +209 -0
  76. package/dist/core/property/enums/property-states.js +8 -0
  77. package/dist/core/property/exceptions.js +12 -0
  78. package/dist/core/property/input.js +10 -0
  79. package/dist/core/property/is-property.js +3 -0
  80. package/dist/core/property/lineage.js +8 -0
  81. package/dist/core/property/property.d.ts +27 -0
  82. package/dist/core/property/property.js +46 -0
  83. package/dist/core/property/refine.js +103 -0
  84. package/dist/core/record/abstract-record.d.ts +2 -1
  85. package/dist/core/record/abstract-record.js +307 -0
  86. package/dist/core/record/exceptions.js +49 -0
  87. package/dist/core/record/marks.js +7 -0
  88. package/dist/core/record/mask.js +60 -0
  89. package/dist/core/record/name.js +23 -0
  90. package/dist/core/record/plugin-catalog.js +115 -0
  91. package/dist/core/record/plugin.js +198 -0
  92. package/dist/core/record/record.js +117 -0
  93. package/dist/core/record/types/record.interface.d.ts +5 -0
  94. package/dist/core/repository/cursor.js +83 -0
  95. package/dist/core/repository/exceptions.js +72 -0
  96. package/dist/core/repository/in-memory.js +196 -0
  97. package/dist/core/repository/migrate.js +254 -0
  98. package/dist/core/repository/plan.js +27 -0
  99. package/dist/core/repository/provider.js +29 -0
  100. package/dist/core/repository/query.js +153 -0
  101. package/dist/core/repository/references.js +196 -0
  102. package/dist/core/repository/repository.d.ts +22 -2
  103. package/dist/core/repository/repository.js +720 -0
  104. package/dist/core/repository/state.js +138 -0
  105. package/dist/core/repository/types/query.interface.d.ts +13 -0
  106. package/dist/core/repository/types/repository.interface.d.ts +20 -8
  107. package/dist/core/repository/types/schema.interface.d.ts +8 -2
  108. package/dist/core/repository/upcast.js +179 -0
  109. package/dist/core/schema/schema.d.ts +9 -0
  110. package/dist/core/schema/schema.js +542 -0
  111. package/dist/core/standard/standard-schema.js +1 -0
  112. package/dist/core/standard/standard.js +23 -0
  113. package/dist/core/symbols/demo.d.ts +4 -0
  114. package/dist/core/symbols/demo.js +1 -0
  115. package/dist/core/symbols/kind.js +1 -0
  116. package/dist/core/symbols/meta.js +1 -0
  117. package/dist/core/symbols/state.d.ts +5 -0
  118. package/dist/core/symbols/state.js +1 -0
  119. package/dist/core/tracing/exceptions.d.ts +4 -0
  120. package/dist/core/tracing/exceptions.js +7 -0
  121. package/dist/core/tracing/tracing.d.ts +72 -0
  122. package/dist/core/tracing/tracing.js +101 -0
  123. package/dist/core/use-case/access.js +56 -0
  124. package/dist/core/use-case/decorators.js +65 -0
  125. package/dist/core/use-case/exceptions.d.ts +5 -1
  126. package/dist/core/use-case/exceptions.js +48 -0
  127. package/dist/core/use-case/plugin-catalog.js +68 -0
  128. package/dist/core/use-case/plugin.js +133 -0
  129. package/dist/core/use-case/route.js +200 -0
  130. package/dist/core/use-case/scope.d.ts +5 -0
  131. package/dist/core/use-case/scope.js +4 -0
  132. package/dist/core/use-case/steps/describe.d.ts +5 -1
  133. package/dist/core/use-case/steps/describe.js +24 -0
  134. package/dist/core/use-case/steps/references.js +105 -0
  135. package/dist/core/use-case/steps/run.js +139 -0
  136. package/dist/core/use-case/steps/types/check.interface.d.ts +27 -8
  137. package/dist/core/use-case/steps/types/steps.interface.d.ts +8 -1
  138. package/dist/core/use-case/steps/validate.js +368 -0
  139. package/dist/core/use-case/target.js +100 -0
  140. package/dist/core/use-case/types/route.interface.d.ts +25 -5
  141. package/dist/core/use-case/use-case.d.ts +77 -2
  142. package/dist/core/use-case/use-case.js +493 -0
  143. package/dist/experimental.d.ts +5 -0
  144. package/dist/experimental.js +18 -161
  145. package/dist/index.d.ts +7 -5
  146. package/dist/index.js +213 -367
  147. package/dist/std/blueprint-plugin.js +42 -0
  148. package/dist/std/blueprint.d.ts +21 -0
  149. package/dist/std/blueprint.js +3 -0
  150. package/dist/std/command.js +3 -0
  151. package/dist/std/entity.d.ts +20 -1
  152. package/dist/std/entity.js +30 -0
  153. package/dist/std/event-policies.js +3 -0
  154. package/dist/std/properties/contact.d.ts +3 -0
  155. package/dist/std/properties/contact.js +29 -0
  156. package/dist/std/properties/enum.js +26 -0
  157. package/dist/std/properties/exceptions.js +14 -0
  158. package/dist/std/properties/headless.js +45 -0
  159. package/dist/std/properties/identity.js +28 -0
  160. package/dist/std/properties/json.js +161 -0
  161. package/dist/std/properties/password.js +79 -0
  162. package/dist/std/properties/primitives.d.ts +4 -0
  163. package/dist/std/properties/primitives.js +28 -0
  164. package/dist/std/properties/time.js +55 -0
  165. package/dist/std/record-plugins.js +73 -0
  166. package/dist/std/record.d.ts +20 -1
  167. package/dist/std/record.js +3 -0
  168. package/dist/std/resource.js +39 -0
  169. package/dist/std/runtime.js +193 -0
  170. package/dist/std/stages.js +4 -0
  171. package/dist/std/use-cases/auth.js +193 -0
  172. package/dist/std/use-cases/crud.js +261 -0
  173. package/dist/std/use-cases/index.js +12 -0
  174. package/dist/std/use-cases/lifecycle.js +97 -0
  175. package/dist/std/use-cases/shared.js +232 -0
  176. package/dist/std/use-cases/types.d.ts +5 -1
  177. package/dist/std/use-cases/types.js +0 -0
  178. package/dist/testing/http-provider-contract.js +344 -0
  179. package/dist/testing/index.js +3 -1435
  180. package/dist/testing/memory-publisher.js +12 -0
  181. package/dist/testing/provider-contract.d.ts +12 -3
  182. package/dist/testing/provider-contract.js +1071 -0
  183. package/package.json +10 -3
  184. package/dist/index-3aae5jfq.js +0 -2997
  185. package/dist/index-ny3as79r.js +0 -4567
  186. package/dist/index-xegv6a1p.js +0 -4291
package/README.md CHANGED
@@ -75,6 +75,7 @@ Requirements: [Bun](https://bun.sh) >= 1.4.4 or Node.js >= 22. TypeBox (`typebox
75
75
 
76
76
  `Password` hashes with argon2id: with `Bun.password` on Bun, with native `node:crypto` argon2 on a Node that has it (24.7+), and otherwise it throws `PasswordHasherRequired` until you call `configure({ hasher })`. `Id.generate()` makes a portable, monotonic UUID v7 on any runtime. afora imports no `node:crypto` (or `Buffer`) at load, so it loads in browsers and Workers; the native hasher is looked up on first use through `process.getBuiltinModule` (Node 22.3+). The native hasher derives argon2 version 19 only; a hash of another version throws `UnsupportedPasswordHash` (verify it with `Bun.password`, or `configure({ hasher })`).
77
77
 
78
+ <!-- docs:code skip: myArgon2 and myUuidV7 stand for your own libraries -->
78
79
  ```ts
79
80
  import { configure, type PasswordHasher } from "@afora/core";
80
81
 
@@ -148,6 +149,7 @@ class Register extends useCaseOf({
148
149
  response: blueprintOf(() => ({ user: User })),
149
150
  dependencies: { users: Users },
150
151
  errors: [UserAlreadyExists],
152
+ strictSteps: true, // TypeScript checks every reference, arg and the return
151
153
  steps: [
152
154
  { find: "users.findByEmail", args: ["$input.email"], as: "existing" },
153
155
  { ensure: "absent", value: "$existing", error: UserAlreadyExists },
@@ -328,6 +330,7 @@ bunx afora-codegen generate afora.json --stages ./stages.ts # writes src/domai
328
330
 
329
331
  and serve the application from `src/server.ts` (`bun src/server.ts`):
330
332
 
333
+ <!-- docs:code skip: src/server.ts of examples/interop/from-json; ./domain is what afora-codegen generates from the afora.json above -->
331
334
  ```ts
332
335
  import { App } from "./domain/index.ts";
333
336
 
@@ -377,6 +380,7 @@ Every field (a property, blueprint, list or record class) implements Standard Sc
377
380
  | [`@afora/ws`](packages/ws/README.md) | A `websocket` sink: operations over JSON messages on any runtime, with topic subscriptions that `publishEvents` feeds with domain events. |
378
381
  | [`@afora/drizzle`](packages/drizzle/README.md) | A repository provider on Drizzle ORM (SQLite and Postgres) that passes the provider contract kit. |
379
382
  | [`@afora/dynamodb`](packages/dynamodb/README.md) | A repository provider on one DynamoDB table (single-table layout, unique keys as marker items) that passes the provider contract kit on DynamoDB Local. |
383
+ | [`@afora/otel`](packages/otel/README.md) | OpenTelemetry tracing: `otelTracer()` gives an application a span per command, use case and repository call, with no value in any span. |
380
384
 
381
385
  ## Example
382
386
 
@@ -392,41 +396,58 @@ Every field (a property, blueprint, list or record class) implements Standard Sc
392
396
 
393
397
  ![Validations per second on the body of an API request, Node v24.22.2](bench/results/chart.svg)
394
398
 
395
- Time of each library as a multiple of afora `blueprint.safeParse` on the same case: above 1.00x it is slower than afora, below it is faster. TypeBox, Ajv and Typia only check, they do not transform. afora 0.0.8, Bun 1.4.4 and Node v24.22.2, AMD EPYC 9V45 96-Core Processor; generated from `bench/results/latest.json`.
399
+ Time of each library as a multiple of afora `blueprint.safeParse` on the same case: above 1.00x it is slower than afora, below it is faster. TypeBox, Ajv and Typia only check, they do not transform. afora 0.0.9, Bun 1.4.4, Node v22.23.4 and Node v24.22.2, AMD EPYC 7763 64-Core Processor; generated from `bench/results/latest.json`.
396
400
 
397
401
  | Node 24 | afora | TypeBox | Ajv | Typia | Zod | Valibot | ArkType | Effect Schema | Yup | Joi |
398
402
  | -------------------------------------------------------- | -------: | ------: | ----: | ----: | ----: | ------: | ------: | ------------: | -----: | -----: |
399
- | Small flat object, valid | 299.5 ns | 0.13x | 0.14x | 0.15x | 1.23x | 1.97x | 10.30x | 2.74x | 12.44x | 8.25x |
400
- | Small flat object, invalid | 474.6 ns | 9.50x | 0.13x | 0.58x | 3.22x | 2.71x | 27.57x | 4.04x | 68.43x | 7.66x |
401
- | Nested user (address, 5 tags max, 10 addresses), valid | 2036 ns | 0.12x | 0.17x | 0.13x | 1.27x | 1.02x | 14.85x | 3.24x | 22.52x | 6.67x |
402
- | Nested user (address, 5 tags max, 10 addresses), invalid | 2688 ns | 9.83x | 0.15x | 0.83x | 1.84x | 1.21x | 21.43x | 3.46x | 38.49x | 6.84x |
403
- | API request body (an order with 5 items), valid | 2518 ns | 0.35x | 0.35x | 0.24x | 1.21x | 1.16x | 9.55x | 2.46x | 17.06x | 5.63x |
404
- | API request body (an order with 5 items), invalid | 3540 ns | 5.17x | 0.12x | 0.86x | 1.90x | 1.10x | 14.67x | 2.50x | 30.63x | 5.11x |
405
- | List of 1,000 items, valid | 152.4 µs | 0.06x | 0.10x | 0.06x | 0.67x | 2.34x | 20.61x | 3.96x | 27.77x | 7.40x |
406
- | List of 1,000 items, invalid | 155.5 µs | 20.58x | 0.10x | 0.18x | 0.72x | 2.35x | 26.62x | 3.70x | 28.82x | 7.43x |
407
- | Union of 4 variants (12 events), valid | 579.7 ns | 0.47x | 0.59x | 0.51x | 3.90x | 14.54x | 1.54x | 13.42x | 91.04x | 94.11x |
408
- | Union of 4 variants (12 events), invalid | 55.0 µs | 0.64x | 0.01x | 0.03x | 0.09x | 0.19x | 0.34x | 0.17x | 1.44x | 1.69x |
409
- | 6 levels of nesting, valid | 829.3 ns | 0.06x | 0.09x | 0.06x | 0.78x | 1.13x | 14.16x | 4.12x | 19.31x | 5.65x |
410
- | 6 levels of nesting, invalid | 971.4 ns | 21.55x | 0.10x | 1.69x | 1.99x | 1.72x | 27.50x | 5.35x | 52.46x | 7.37x |
411
- | Small flat object, checks only, valid | 177.6 ns | 0.23x | 0.24x | 0.25x | 0.82x | 2.68x | 0.44x | 2.34x | 18.10x | 12.73x |
412
- | Small flat object, checks only, invalid | 424.3 ns | 10.48x | 0.15x | 0.68x | 2.94x | 2.85x | 22.80x | 3.92x | 74.92x | 8.39x |
403
+ | Small flat object, valid | 579.5 ns | 0.14x | 0.15x | 0.16x | 1.31x | 2.04x | 10.08x | 2.51x | 10.37x | 7.56x |
404
+ | Small flat object, invalid | 1017 ns | 7.65x | 0.12x | 0.63x | 2.53x | 2.22x | 23.82x | 3.43x | 61.39x | 6.48x |
405
+ | Nested user (address, 5 tags max, 10 addresses), valid | 4379 ns | 0.11x | 0.17x | 0.12x | 1.15x | 1.11x | 12.53x | 3.06x | 18.70x | 5.62x |
406
+ | Nested user (address, 5 tags max, 10 addresses), invalid | 5556 ns | 8.41x | 0.18x | 0.76x | 1.53x | 1.17x | 21.08x | 3.17x | 37.22x | 6.04x |
407
+ | API request body (an order with 5 items), valid | 5174 ns | 0.30x | 0.32x | 0.21x | 1.09x | 1.10x | 8.72x | 2.11x | 16.09x | 5.05x |
408
+ | API request body (an order with 5 items), invalid | 6434 ns | 4.79x | 0.16x | 0.85x | 1.75x | 1.12x | 15.93x | 2.53x | 33.94x | 5.43x |
409
+ | List of 1,000 items, valid | 339.2 µs | 0.05x | 0.08x | 0.05x | 0.62x | 2.45x | 17.10x | 3.03x | 21.78x | 6.44x |
410
+ | List of 1,000 items, invalid | 358.9 µs | 15.45x | 0.09x | 0.14x | 0.62x | 2.41x | 21.12x | 2.94x | 22.68x | 6.37x |
411
+ | Union of 4 variants (12 events), valid | 1068 ns | 0.51x | 0.66x | 0.52x | 4.52x | 16.14x | 1.87x | 13.23x | 94.83x | 93.28x |
412
+ | Union of 4 variants (12 events), invalid | 5145 ns | 11.93x | 0.17x | 0.65x | 1.49x | 3.92x | 6.74x | 3.25x | 32.25x | 36.19x |
413
+ | 6 levels of nesting, valid | 1609 ns | 0.06x | 0.09x | 0.07x | 0.80x | 1.27x | 13.88x | 3.68x | 17.45x | 5.29x |
414
+ | 6 levels of nesting, invalid | 2018 ns | 18.04x | 0.11x | 1.47x | 1.73x | 1.67x | 24.36x | 4.52x | 50.40x | 7.09x |
415
+ | Small flat object, checks only, valid | 430.2 ns | 0.20x | 0.20x | 0.21x | 0.79x | 2.16x | 0.40x | 2.05x | 12.75x | 9.22x |
416
+ | Small flat object, checks only, invalid | 934.7 ns | 8.47x | 0.13x | 0.68x | 2.32x | 2.59x | 19.81x | 3.18x | 65.32x | 6.90x |
413
417
 
414
418
  | Bun | afora | TypeBox | Ajv | Typia | Zod | Valibot | ArkType | Effect Schema | Yup | Joi |
415
419
  | -------------------------------------------------------- | -------: | ------: | ----: | ----: | ----: | ------: | ------: | ------------: | -----: | -----: |
416
- | Small flat object, valid | 195.7 ns | 0.15x | 0.18x | 0.17x | 1.63x | 0.95x | 10.95x | 2.58x | 22.27x | 10.44x |
417
- | Small flat object, invalid | 426.1 ns | 7.87x | 0.21x | 1.26x | 1.62x | 0.97x | 16.14x | 2.50x | 39.07x | 8.12x |
418
- | Nested user (address, 5 tags max, 10 addresses), valid | 3154 ns | 0.05x | 0.08x | 0.03x | 0.93x | 0.41x | 4.73x | 1.35x | 16.66x | 3.81x |
419
- | Nested user (address, 5 tags max, 10 addresses), invalid | 2260 ns | 8.15x | 0.16x | 0.99x | 1.64x | 0.91x | 13.57x | 2.40x | 39.16x | 6.88x |
420
- | API request body (an order with 5 items), valid | 2355 ns | 0.19x | 0.21x | 0.32x | 1.34x | 0.68x | 5.08x | 1.83x | 21.04x | 4.97x |
421
- | API request body (an order with 5 items), invalid | 2456 ns | 5.33x | 0.13x | 1.13x | 2.06x | 0.97x | 11.38x | 2.24x | 38.34x | 7.81x |
422
- | List of 1,000 items, valid | 185.7 µs | 0.02x | 0.05x | 0.01x | 1.05x | 0.45x | 7.61x | 1.53x | 29.36x | 5.07x |
423
- | List of 1,000 items, invalid | 92.7 µs | 23.63x | 0.12x | 0.45x | 2.25x | 0.96x | 23.45x | 3.00x | 65.59x | 11.20x |
424
- | Union of 4 variants (12 events), valid | 1627 ns | 0.11x | 0.14x | 0.20x | 1.83x | 1.97x | 0.26x | 2.06x | 39.17x | 27.28x |
425
- | Union of 4 variants (12 events), invalid | 41.8 µs | 0.64x | 0.01x | 0.04x | 0.10x | 0.11x | 0.21x | 0.11x | 1.81x | 2.01x |
426
- | 6 levels of nesting, valid | 528.2 ns | 0.02x | 0.10x | 0.06x | 1.98x | 1.54x | 11.94x | 2.87x | 39.56x | 7.63x |
427
- | 6 levels of nesting, invalid | 838.9 ns | 17.86x | 0.09x | 1.60x | 1.74x | 1.59x | 18.13x | 3.09x | 53.04x | 7.92x |
428
- | Small flat object, checks only, valid | 110.1 ns | 0.28x | 0.35x | 0.29x | 1.83x | 0.92x | 0.34x | 1.91x | 33.82x | 15.15x |
429
- | Small flat object, checks only, invalid | 414.7 ns | 7.74x | 0.21x | 1.25x | 1.52x | 0.86x | 11.63x | 2.06x | 39.99x | 7.60x |
420
+ | Small flat object, valid | 400.9 ns | 0.15x | 0.17x | 0.16x | 1.63x | 0.86x | 9.95x | 2.29x | 18.78x | 9.88x |
421
+ | Small flat object, invalid | 861.0 ns | 6.52x | 0.18x | 1.00x | 1.38x | 0.87x | 14.29x | 2.23x | 39.21x | 7.40x |
422
+ | Nested user (address, 5 tags max, 10 addresses), valid | 4965 ns | 0.06x | 0.10x | 0.04x | 1.06x | 0.48x | 5.57x | 1.79x | 20.03x | 4.31x |
423
+ | Nested user (address, 5 tags max, 10 addresses), invalid | 4125 ns | 7.60x | 0.17x | 0.89x | 1.58x | 0.92x | 14.61x | 2.76x | 41.12x | 7.68x |
424
+ | API request body (an order with 5 items), valid | 4326 ns | 0.22x | 0.23x | 0.27x | 1.27x | 0.69x | 5.31x | 1.83x | 23.20x | 5.40x |
425
+ | API request body (an order with 5 items), invalid | 4504 ns | 4.89x | 0.16x | 0.93x | 1.93x | 0.95x | 12.21x | 2.29x | 39.23x | 8.54x |
426
+ | List of 1,000 items, valid | 292.5 µs | 0.02x | 0.07x | 0.02x | 1.23x | 0.52x | 8.46x | 1.92x | 31.44x | 5.54x |
427
+ | List of 1,000 items, invalid | 180.8 µs | 19.55x | 0.12x | 0.38x | 2.07x | 0.88x | 21.94x | 3.18x | 52.78x | 9.34x |
428
+ | Union of 4 variants (12 events), valid | 2231 ns | 0.15x | 0.22x | 0.25x | 2.45x | 2.95x | 0.43x | 3.36x | 53.20x | 37.54x |
429
+ | Union of 4 variants (12 events), invalid | 3665 ns | 12.15x | 0.16x | 0.84x | 1.99x | 2.21x | 4.48x | 2.53x | 41.04x | 44.78x |
430
+ | 6 levels of nesting, valid | 903.4 ns | 0.03x | 0.11x | 0.06x | 2.05x | 1.42x | 13.08x | 3.43x | 41.87x | 8.52x |
431
+ | 6 levels of nesting, invalid | 1547 ns | 16.33x | 0.10x | 1.29x | 1.80x | 1.53x | 18.79x | 3.06x | 54.03x | 8.16x |
432
+ | Small flat object, checks only, valid | 224.4 ns | 0.28x | 0.30x | 0.28x | 1.86x | 0.88x | 0.32x | 1.99x | 29.54x | 13.13x |
433
+ | Small flat object, checks only, invalid | 824.2 ns | 6.87x | 0.19x | 1.05x | 1.29x | 0.80x | 10.67x | 1.82x | 37.79x | 6.91x |
434
+
435
+ | Node 22 | afora | TypeBox | Ajv | Typia | Zod | Valibot | ArkType | Effect Schema | Yup | Joi |
436
+ | -------------------------------------------------------- | -------: | ------: | ----: | ----: | ----: | ------: | ------: | ------------: | ------: | ------: |
437
+ | Small flat object, valid | 570.7 ns | 0.15x | 0.14x | 0.16x | 1.29x | 1.05x | 9.74x | 2.50x | 10.93x | 7.53x |
438
+ | Small flat object, invalid | 951.7 ns | 8.05x | 0.13x | 0.61x | 2.63x | 0.99x | 25.38x | 3.59x | 117.28x | 6.52x |
439
+ | Nested user (address, 5 tags max, 10 addresses), valid | 4313 ns | 0.11x | 0.18x | 0.11x | 1.14x | 1.06x | 12.83x | 2.70x | 21.85x | 5.47x |
440
+ | Nested user (address, 5 tags max, 10 addresses), invalid | 5472 ns | 8.29x | 0.18x | 0.75x | 1.63x | 1.16x | 20.80x | 3.07x | 57.50x | 5.97x |
441
+ | API request body (an order with 5 items), valid | 4984 ns | 0.28x | 0.35x | 0.20x | 1.14x | 1.10x | 9.27x | 2.20x | 19.37x | 5.38x |
442
+ | API request body (an order with 5 items), invalid | 6311 ns | 4.83x | 0.19x | 0.81x | 1.88x | 1.13x | 15.79x | 2.54x | 52.78x | 5.44x |
443
+ | List of 1,000 items, valid | 346.1 µs | 0.04x | 0.09x | 0.05x | 0.64x | 1.11x | 16.95x | 2.89x | 28.12x | 6.32x |
444
+ | List of 1,000 items, invalid | 347.0 µs | 15.48x | 0.10x | 0.15x | 0.66x | 1.06x | 21.82x | 2.87x | 30.03x | 6.29x |
445
+ | Union of 4 variants (12 events), valid | 969.6 ns | 0.53x | 0.77x | 0.61x | 4.86x | 9.94x | 2.46x | 13.66x | 125.51x | 105.95x |
446
+ | Union of 4 variants (12 events), invalid | 4865 ns | 12.44x | 0.18x | 0.68x | 1.68x | 2.33x | 7.17x | 3.24x | 44.16x | 37.49x |
447
+ | 6 levels of nesting, valid | 1454 ns | 0.06x | 0.10x | 0.07x | 0.86x | 1.34x | 15.58x | 3.86x | 23.21x | 5.99x |
448
+ | 6 levels of nesting, invalid | 1862 ns | 19.39x | 0.11x | 1.63x | 1.91x | 1.79x | 26.89x | 4.77x | 88.54x | 7.14x |
449
+ | Small flat object, checks only, valid | 399.9 ns | 0.21x | 0.21x | 0.23x | 0.81x | 1.02x | 0.51x | 2.03x | 14.22x | 9.91x |
450
+ | Small flat object, checks only, invalid | 892.3 ns | 8.72x | 0.14x | 0.70x | 2.40x | 0.98x | 21.21x | 3.29x | 119.51x | 6.98x |
430
451
 
431
452
  <!-- bench:end -->
432
453
 
@@ -493,7 +514,8 @@ bun run test:fastify # tests of packages/fastify (also test:express, test:elysi
493
514
  bun run test:ws # tests of packages/ws
494
515
  bun run test:drizzle # tests of packages/drizzle (SQLite and PGlite)
495
516
  bun run test:dynamodb # tests of packages/dynamodb (DynamoDB Local, with DYNAMODB_ENDPOINT)
496
- bun run build:packages # build the core, then packages/codegen, packages/mcp, packages/hono, packages/fastify, packages/express, packages/elysia, packages/ws, packages/drizzle and packages/dynamodb
517
+ bun run test:otel # tests of packages/otel
518
+ bun run build:packages # build the core, then packages/codegen, packages/mcp, packages/hono, packages/fastify, packages/express, packages/elysia, packages/ws, packages/drizzle, packages/dynamodb and packages/otel
497
519
  ```
498
520
 
499
521
  ## Versioning
package/dist/adapters.js CHANGED
@@ -1,56 +1,32 @@
1
- import {
2
- coerceTextValues2,
3
- HTTP_OPTION_KEYS2,
4
- httpOptionsIssue2,
5
- compileRoutes2
6
- } from "./index-y280ew0k.js";
7
- import {
8
- schemaLockOf2,
9
- diffSchemas2,
10
- schemaLockProblemsOf2,
11
- statusOf2,
12
- PROBLEM_MEDIA_TYPE2,
13
- problemOf2,
14
- outputValueOf2,
15
- ROUTE_OPTION_KEYS2,
16
- routeOptionsIssue2,
17
- requestIdHeaderOf2,
18
- operationRoutes2
19
- } from "./index-hg1z2s2v.js";
20
- import {
21
- Demo2,
22
- Kind2,
23
- RESERVED_RECORD_KEYS2,
24
- ENTITY_IDENTITY_KEYS2,
25
- RESERVED_ENTITY_KEYS2,
26
- SCHEMA_VERSION_KEY2,
27
- sinkOf2,
28
- stageKindOf2,
29
- stageCatalogOf2
30
- } from "./index-xegv6a1p.js";
31
1
  export {
32
- Demo2 as Demo,
33
- ENTITY_IDENTITY_KEYS2 as ENTITY_IDENTITY_KEYS,
34
- HTTP_OPTION_KEYS2 as HTTP_OPTION_KEYS,
35
- Kind2 as Kind,
36
- PROBLEM_MEDIA_TYPE2 as PROBLEM_MEDIA_TYPE,
37
- RESERVED_ENTITY_KEYS2 as RESERVED_ENTITY_KEYS,
38
- RESERVED_RECORD_KEYS2 as RESERVED_RECORD_KEYS,
39
- ROUTE_OPTION_KEYS2 as ROUTE_OPTION_KEYS,
40
- SCHEMA_VERSION_KEY2 as SCHEMA_VERSION_KEY,
41
- coerceTextValues2 as coerceTextValues,
42
- compileRoutes2 as compileRoutes,
43
- diffSchemas2 as diffSchemas,
44
- httpOptionsIssue2 as httpOptionsIssue,
45
- operationRoutes2 as operationRoutes,
46
- outputValueOf2 as outputValueOf,
47
- problemOf2 as problemOf,
48
- requestIdHeaderOf2 as requestIdHeaderOf,
49
- routeOptionsIssue2 as routeOptionsIssue,
50
- schemaLockOf2 as schemaLockOf,
51
- schemaLockProblemsOf2 as schemaLockProblemsOf,
52
- sinkOf2 as sinkOf,
53
- stageCatalogOf2 as stageCatalogOf,
54
- stageKindOf2 as stageKindOf,
55
- statusOf2 as statusOf
56
- };
2
+ diffSchemas,
3
+ schemaLockOf,
4
+ schemaLockProblemsOf
5
+ } from "./core/application/schema.js";
6
+ export {
7
+ ENTITY_IDENTITY_KEYS,
8
+ RESERVED_ENTITY_KEYS
9
+ } from "./core/entity/abstract-entity.js";
10
+ export { coerceTextValues } from "./core/output/coerce.js";
11
+ export {
12
+ compileRoutes,
13
+ HTTP_OPTION_KEYS,
14
+ httpOptionsIssue
15
+ } from "./core/output/http.js";
16
+ export {
17
+ operationRoutes,
18
+ ROUTE_OPTION_KEYS,
19
+ requestIdHeaderOf,
20
+ routeOptionsIssue
21
+ } from "./core/output/openapi-sink.js";
22
+ export {
23
+ outputValueOf,
24
+ PROBLEM_MEDIA_TYPE,
25
+ problemOf
26
+ } from "./core/output/problem.js";
27
+ export { sinkOf, stageCatalogOf, stageKindOf } from "./core/output/stage.js";
28
+ export { statusOf } from "./core/output/status.js";
29
+ export { RESERVED_RECORD_KEYS } from "./core/record/abstract-record.js";
30
+ export { SCHEMA_VERSION_KEY } from "./core/repository/state.js";
31
+ export { Demo } from "./core/symbols/demo.js";
32
+ export { Kind } from "./core/symbols/kind.js";
@@ -15,6 +15,36 @@ export declare function isApplication(value: unknown): value is AnyApplication;
15
15
  * under one name (or one object under two names) throw `ApplicationConflict`.
16
16
  * `describe()` gives the graph. With a `provider` (or that of the last
17
17
  * application extended that has one), `repositories` are bound to it.
18
+ *
19
+ * @throws {@link DuplicateApplicationDeclaration} when one object is registered under two names.
20
+ * @throws {@link ApplicationConflict} when extended applications register different objects under one name.
21
+ * @throws {@link InvalidApplicationDeclaration} when a declaration is not of the kind its collection holds.
22
+ * @throws {@link UnregisteredApplicationReference} when a registered declaration holds one that is not registered.
23
+ *
24
+ * @example
25
+ * ```ts
26
+ * import {
27
+ * applicationOf,
28
+ * blueprintOf,
29
+ * entityOf,
30
+ * inMemoryProvider,
31
+ * repositoryOf,
32
+ * } from "@afora/core";
33
+ *
34
+ * class User extends entityOf(blueprintOf((ctx) => ({ name: ctx.string }))) {}
35
+ * const Users = repositoryOf({ entity: User, actions: ["create"] });
36
+ *
37
+ * const Blog = applicationOf({
38
+ * name: "blog",
39
+ * entities: { User },
40
+ * repositories: { Users },
41
+ * provider: inMemoryProvider(), // the default of its repositories
42
+ * });
43
+ *
44
+ * await Blog.start();
45
+ * await Blog.repositories.Users.create({ name: "Ana" });
46
+ * await Blog.stop();
47
+ * ```
18
48
  */
19
49
  export declare function applicationOf<const Name extends string, const Extended extends readonly AnyApplication[] = readonly [], const Properties extends ApplicationCollections["properties"] = Record<never, never>, const Blueprints extends ApplicationCollections["blueprints"] = Record<never, never>, const Records extends ApplicationCollections["records"] = Record<never, never>, const Entities extends ApplicationCollections["entities"] = Record<never, never>, const Environments extends ApplicationCollections["environments"] = Record<never, never>, const Repositories extends ApplicationCollections["repositories"] = Record<never, never>, const UseCases extends ApplicationCollections["useCases"] = Record<never, never>, const Commands extends ApplicationCollections["commands"] = Record<never, never>, const Outputs extends ApplicationCollections["outputs"] = Record<never, never>, const Exceptions extends ApplicationCollections["exceptions"] = Record<never, never>>(settings: ApplicationSettings<Name, Extended, {
20
50
  properties: Properties;