@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.
- package/README.md +52 -30
- package/dist/adapters.js +31 -55
- package/dist/core/application/application.d.ts +30 -0
- package/dist/core/application/application.js +1291 -0
- package/dist/core/application/exceptions.js +85 -0
- package/dist/core/application/migrate.js +67 -0
- package/dist/core/application/providers.js +108 -0
- package/dist/core/application/registry.js +23 -0
- package/dist/core/application/schema.js +398 -0
- package/dist/core/application/start.js +162 -0
- package/dist/core/application/types/application.interface.d.ts +23 -3
- package/dist/core/auth/jwt.js +200 -0
- package/dist/core/auth/types/jwt.interface.d.ts +10 -2
- package/dist/core/blueprint/blueprint-plugin.js +7 -0
- package/dist/core/blueprint/blueprint.js +146 -0
- package/dist/core/blueprint/callable.js +13 -0
- package/dist/core/blueprint/exceptions.js +20 -0
- package/dist/core/blueprint/is-blueprint.js +4 -0
- package/dist/core/blueprint/list.js +19 -0
- package/dist/core/blueprint/optional.js +69 -0
- package/dist/core/blueprint/record-field.js +14 -0
- package/dist/core/blueprint/slice.js +127 -0
- package/dist/core/blueprint/types/blueprint.interface.d.ts +16 -0
- package/dist/core/blueprint/variant.js +72 -0
- package/dist/core/command/command.js +428 -0
- package/dist/core/command/exceptions.js +30 -0
- package/dist/core/command/types/command.interface.d.ts +10 -1
- package/dist/core/entity/abstract-entity.d.ts +19 -0
- package/dist/core/entity/abstract-entity.js +181 -0
- package/dist/core/entity/entity.js +209 -0
- package/dist/core/entity/event.d.ts +39 -0
- package/dist/core/entity/event.js +80 -0
- package/dist/core/entity/exceptions.js +27 -0
- package/dist/core/entity/trust.js +7 -0
- package/dist/core/entity/version.js +13 -0
- package/dist/core/environment/environment.d.ts +26 -3
- package/dist/core/environment/environment.js +71 -0
- package/dist/core/event-policy/event-policy.js +76 -0
- package/dist/core/event-policy/exceptions.js +12 -0
- package/dist/core/event-policy/publish.js +98 -0
- package/dist/core/event-policy/publishers.js +18 -0
- package/dist/core/event-policy/types/event-policy.interface.d.ts +8 -2
- package/dist/core/exception/enums/exception-layers.js +15 -0
- package/dist/core/exception/exception.d.ts +15 -0
- package/dist/core/exception/exception.js +128 -0
- package/dist/core/exception/exported.js +49 -0
- package/dist/core/exception/guard.d.ts +20 -1
- package/dist/core/exception/guard.js +16 -0
- package/dist/core/exception/types/exception.interface.d.ts +13 -0
- package/dist/core/json.js +19 -0
- package/dist/core/logger/exceptions.js +7 -0
- package/dist/core/logger/logger.d.ts +14 -1
- package/dist/core/logger/logger.js +178 -0
- package/dist/core/openapi/exceptions.js +7 -0
- package/dist/core/openapi/openapi.js +132 -0
- package/dist/core/openapi/types/openapi.interface.d.ts +7 -1
- package/dist/core/output/access.js +66 -0
- package/dist/core/output/coerce.js +38 -0
- package/dist/core/output/exceptions.js +22 -0
- package/dist/{index-y280ew0k.js → core/output/http.js} +35 -80
- package/dist/core/output/openapi-sink.d.ts +10 -2
- package/dist/{index-hg1z2s2v.js → core/output/openapi-sink.js} +60 -544
- package/dist/core/output/output.js +192 -0
- package/dist/core/output/problem.js +30 -0
- package/dist/core/output/select.js +28 -0
- package/dist/core/output/stage.js +111 -0
- package/dist/core/output/status.js +52 -0
- package/dist/core/output/types/http.interface.d.ts +5 -1
- package/dist/core/output/types/output.interface.d.ts +24 -0
- package/dist/core/parse/issue.js +31 -0
- package/dist/core/parse/parse.d.ts +8 -1
- package/dist/core/parse/parse.js +323 -0
- package/dist/core/parse/strip.js +48 -0
- package/dist/core/property/abstract-property.js +37 -0
- package/dist/core/property/define-property.js +209 -0
- package/dist/core/property/enums/property-states.js +8 -0
- package/dist/core/property/exceptions.js +12 -0
- package/dist/core/property/input.js +10 -0
- package/dist/core/property/is-property.js +3 -0
- package/dist/core/property/lineage.js +8 -0
- package/dist/core/property/property.d.ts +27 -0
- package/dist/core/property/property.js +46 -0
- package/dist/core/property/refine.js +103 -0
- package/dist/core/record/abstract-record.d.ts +2 -1
- package/dist/core/record/abstract-record.js +307 -0
- package/dist/core/record/exceptions.js +49 -0
- package/dist/core/record/marks.js +7 -0
- package/dist/core/record/mask.js +60 -0
- package/dist/core/record/name.js +23 -0
- package/dist/core/record/plugin-catalog.js +115 -0
- package/dist/core/record/plugin.js +198 -0
- package/dist/core/record/record.js +117 -0
- package/dist/core/record/types/record.interface.d.ts +5 -0
- package/dist/core/repository/cursor.js +83 -0
- package/dist/core/repository/exceptions.js +72 -0
- package/dist/core/repository/in-memory.js +196 -0
- package/dist/core/repository/migrate.js +254 -0
- package/dist/core/repository/plan.js +27 -0
- package/dist/core/repository/provider.js +29 -0
- package/dist/core/repository/query.js +153 -0
- package/dist/core/repository/references.js +196 -0
- package/dist/core/repository/repository.d.ts +22 -2
- package/dist/core/repository/repository.js +720 -0
- package/dist/core/repository/state.js +138 -0
- package/dist/core/repository/types/query.interface.d.ts +13 -0
- package/dist/core/repository/types/repository.interface.d.ts +20 -8
- package/dist/core/repository/types/schema.interface.d.ts +8 -2
- package/dist/core/repository/upcast.js +179 -0
- package/dist/core/schema/schema.d.ts +9 -0
- package/dist/core/schema/schema.js +542 -0
- package/dist/core/standard/standard-schema.js +1 -0
- package/dist/core/standard/standard.js +23 -0
- package/dist/core/symbols/demo.d.ts +4 -0
- package/dist/core/symbols/demo.js +1 -0
- package/dist/core/symbols/kind.js +1 -0
- package/dist/core/symbols/meta.js +1 -0
- package/dist/core/symbols/state.d.ts +5 -0
- package/dist/core/symbols/state.js +1 -0
- package/dist/core/tracing/exceptions.d.ts +4 -0
- package/dist/core/tracing/exceptions.js +7 -0
- package/dist/core/tracing/tracing.d.ts +72 -0
- package/dist/core/tracing/tracing.js +101 -0
- package/dist/core/use-case/access.js +56 -0
- package/dist/core/use-case/decorators.js +65 -0
- package/dist/core/use-case/exceptions.d.ts +5 -1
- package/dist/core/use-case/exceptions.js +48 -0
- package/dist/core/use-case/plugin-catalog.js +68 -0
- package/dist/core/use-case/plugin.js +133 -0
- package/dist/core/use-case/route.js +200 -0
- package/dist/core/use-case/scope.d.ts +5 -0
- package/dist/core/use-case/scope.js +4 -0
- package/dist/core/use-case/steps/describe.d.ts +5 -1
- package/dist/core/use-case/steps/describe.js +24 -0
- package/dist/core/use-case/steps/references.js +105 -0
- package/dist/core/use-case/steps/run.js +139 -0
- package/dist/core/use-case/steps/types/check.interface.d.ts +27 -8
- package/dist/core/use-case/steps/types/steps.interface.d.ts +8 -1
- package/dist/core/use-case/steps/validate.js +368 -0
- package/dist/core/use-case/target.js +100 -0
- package/dist/core/use-case/types/route.interface.d.ts +25 -5
- package/dist/core/use-case/use-case.d.ts +77 -2
- package/dist/core/use-case/use-case.js +493 -0
- package/dist/experimental.d.ts +5 -0
- package/dist/experimental.js +18 -161
- package/dist/index.d.ts +7 -5
- package/dist/index.js +213 -367
- package/dist/std/blueprint-plugin.js +42 -0
- package/dist/std/blueprint.d.ts +21 -0
- package/dist/std/blueprint.js +3 -0
- package/dist/std/command.js +3 -0
- package/dist/std/entity.d.ts +20 -1
- package/dist/std/entity.js +30 -0
- package/dist/std/event-policies.js +3 -0
- package/dist/std/properties/contact.d.ts +3 -0
- package/dist/std/properties/contact.js +29 -0
- package/dist/std/properties/enum.js +26 -0
- package/dist/std/properties/exceptions.js +14 -0
- package/dist/std/properties/headless.js +45 -0
- package/dist/std/properties/identity.js +28 -0
- package/dist/std/properties/json.js +161 -0
- package/dist/std/properties/password.js +79 -0
- package/dist/std/properties/primitives.d.ts +4 -0
- package/dist/std/properties/primitives.js +28 -0
- package/dist/std/properties/time.js +55 -0
- package/dist/std/record-plugins.js +73 -0
- package/dist/std/record.d.ts +20 -1
- package/dist/std/record.js +3 -0
- package/dist/std/resource.js +39 -0
- package/dist/std/runtime.js +193 -0
- package/dist/std/stages.js +4 -0
- package/dist/std/use-cases/auth.js +193 -0
- package/dist/std/use-cases/crud.js +261 -0
- package/dist/std/use-cases/index.js +12 -0
- package/dist/std/use-cases/lifecycle.js +97 -0
- package/dist/std/use-cases/shared.js +232 -0
- package/dist/std/use-cases/types.d.ts +5 -1
- package/dist/std/use-cases/types.js +0 -0
- package/dist/testing/http-provider-contract.js +344 -0
- package/dist/testing/index.js +3 -1435
- package/dist/testing/memory-publisher.js +12 -0
- package/dist/testing/provider-contract.d.ts +12 -3
- package/dist/testing/provider-contract.js +1071 -0
- package/package.json +10 -3
- package/dist/index-3aae5jfq.js +0 -2997
- package/dist/index-ny3as79r.js +0 -4567
- 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
|

|
|
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.
|
|
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 |
|
|
400
|
-
| Small flat object, invalid |
|
|
401
|
-
| Nested user (address, 5 tags max, 10 addresses), valid |
|
|
402
|
-
| Nested user (address, 5 tags max, 10 addresses), invalid |
|
|
403
|
-
| API request body (an order with 5 items), valid |
|
|
404
|
-
| API request body (an order with 5 items), invalid |
|
|
405
|
-
| List of 1,000 items, valid |
|
|
406
|
-
| List of 1,000 items, invalid |
|
|
407
|
-
| Union of 4 variants (12 events), valid |
|
|
408
|
-
| Union of 4 variants (12 events), invalid |
|
|
409
|
-
| 6 levels of nesting, valid |
|
|
410
|
-
| 6 levels of nesting, invalid |
|
|
411
|
-
| Small flat object, checks only, valid |
|
|
412
|
-
| Small flat object, checks only, invalid |
|
|
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 |
|
|
417
|
-
| Small flat object, invalid |
|
|
418
|
-
| Nested user (address, 5 tags max, 10 addresses), valid |
|
|
419
|
-
| Nested user (address, 5 tags max, 10 addresses), invalid |
|
|
420
|
-
| API request body (an order with 5 items), valid |
|
|
421
|
-
| API request body (an order with 5 items), invalid |
|
|
422
|
-
| List of 1,000 items, valid |
|
|
423
|
-
| List of 1,000 items, invalid |
|
|
424
|
-
| Union of 4 variants (12 events), valid |
|
|
425
|
-
| Union of 4 variants (12 events), invalid |
|
|
426
|
-
| 6 levels of nesting, valid |
|
|
427
|
-
| 6 levels of nesting, invalid |
|
|
428
|
-
| Small flat object, checks only, valid |
|
|
429
|
-
| Small flat object, checks only, invalid |
|
|
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
|
|
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
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
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;
|