@afora/core 0.0.7 → 0.0.9

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 (99) hide show
  1. package/README.md +157 -25
  2. package/dist/adapters.d.ts +25 -0
  3. package/dist/adapters.js +56 -0
  4. package/dist/core/application/exceptions.d.ts +17 -0
  5. package/dist/core/application/migrate.d.ts +19 -0
  6. package/dist/core/application/schema.d.ts +30 -0
  7. package/dist/core/application/start.d.ts +7 -0
  8. package/dist/core/application/types/application.interface.d.ts +73 -2
  9. package/dist/core/auth/jwt.d.ts +30 -0
  10. package/dist/core/auth/types/jwt.interface.d.ts +66 -0
  11. package/dist/core/blueprint/exceptions.d.ts +5 -0
  12. package/dist/core/blueprint/optional.d.ts +3 -1
  13. package/dist/core/blueprint/types/blueprint.interface.d.ts +79 -5
  14. package/dist/core/blueprint/variant.d.ts +32 -0
  15. package/dist/core/command/types/command.interface.d.ts +7 -0
  16. package/dist/core/entity/abstract-entity.d.ts +33 -1
  17. package/dist/core/entity/entity.d.ts +1 -1
  18. package/dist/core/entity/event.d.ts +13 -2
  19. package/dist/core/entity/exceptions.d.ts +17 -0
  20. package/dist/core/entity/trust.d.ts +24 -0
  21. package/dist/core/entity/types/entity.interface.d.ts +96 -2
  22. package/dist/core/entity/version.d.ts +13 -0
  23. package/dist/core/event-policy/event-policy.d.ts +25 -0
  24. package/dist/core/event-policy/exceptions.d.ts +11 -0
  25. package/dist/core/event-policy/publish.d.ts +17 -0
  26. package/dist/core/event-policy/publishers.d.ts +18 -0
  27. package/dist/core/event-policy/types/event-policy.interface.d.ts +72 -0
  28. package/dist/core/output/access.d.ts +16 -0
  29. package/dist/core/output/coerce.d.ts +9 -0
  30. package/dist/core/output/exceptions.d.ts +16 -0
  31. package/dist/core/output/http.d.ts +36 -0
  32. package/dist/core/output/openapi-sink.d.ts +160 -39
  33. package/dist/core/output/stage.d.ts +7 -2
  34. package/dist/core/output/status.d.ts +2 -2
  35. package/dist/core/output/types/http.interface.d.ts +130 -0
  36. package/dist/core/output/types/output.interface.d.ts +25 -5
  37. package/dist/core/parse/issue.d.ts +28 -3
  38. package/dist/core/parse/parse.d.ts +19 -0
  39. package/dist/core/parse/strip.d.ts +13 -0
  40. package/dist/core/property/abstract-property.d.ts +9 -0
  41. package/dist/core/property/define-property.d.ts +34 -6
  42. package/dist/core/property/types/property-options.interface.d.ts +10 -0
  43. package/dist/core/property/types/property-type.interface.d.ts +4 -0
  44. package/dist/core/record/abstract-record.d.ts +7 -0
  45. package/dist/core/record/types/record.interface.d.ts +12 -1
  46. package/dist/core/repository/exceptions.d.ts +43 -0
  47. package/dist/core/repository/in-memory.d.ts +16 -3
  48. package/dist/core/repository/migrate.d.ts +20 -0
  49. package/dist/core/repository/plan.d.ts +20 -0
  50. package/dist/core/repository/provider.d.ts +1 -1
  51. package/dist/core/repository/query.d.ts +9 -2
  52. package/dist/core/repository/repository.d.ts +40 -8
  53. package/dist/core/repository/state.d.ts +32 -2
  54. package/dist/core/repository/types/query.interface.d.ts +106 -5
  55. package/dist/core/repository/types/repository.interface.d.ts +139 -7
  56. package/dist/core/repository/types/schema.interface.d.ts +126 -0
  57. package/dist/core/repository/upcast.d.ts +64 -0
  58. package/dist/core/schema/schema.d.ts +28 -0
  59. package/dist/core/symbols/kind.d.ts +1 -1
  60. package/dist/core/use-case/access.d.ts +12 -0
  61. package/dist/core/use-case/decorators.d.ts +40 -0
  62. package/dist/core/use-case/route.d.ts +18 -0
  63. package/dist/core/use-case/steps/types/check.interface.d.ts +214 -0
  64. package/dist/core/use-case/types/access.interface.d.ts +39 -0
  65. package/dist/core/use-case/types/route.interface.d.ts +66 -0
  66. package/dist/core/use-case/use-case.d.ts +52 -2
  67. package/dist/experimental.d.ts +13 -1
  68. package/dist/experimental.js +64 -26
  69. package/dist/index-3aae5jfq.js +2997 -0
  70. package/dist/index-hg1z2s2v.js +1055 -0
  71. package/dist/index-ny3as79r.js +4567 -0
  72. package/dist/index-xegv6a1p.js +4291 -0
  73. package/dist/index-y280ew0k.js +396 -0
  74. package/dist/index.d.ts +55 -48
  75. package/dist/index.js +141 -169
  76. package/dist/std/blueprint-plugin.d.ts +6 -2
  77. package/dist/std/blueprint.d.ts +3 -0
  78. package/dist/std/entity.d.ts +2 -1
  79. package/dist/std/event-policies.d.ts +2 -0
  80. package/dist/std/properties/exceptions.d.ts +11 -0
  81. package/dist/std/properties/json.d.ts +54 -0
  82. package/dist/std/properties/password.d.ts +0 -2
  83. package/dist/std/properties/time.d.ts +4 -0
  84. package/dist/std/record-plugins.d.ts +2 -2
  85. package/dist/std/resource.d.ts +31 -0
  86. package/dist/std/runtime.d.ts +6 -0
  87. package/dist/std/use-cases/auth.d.ts +5 -1
  88. package/dist/std/use-cases/crud.d.ts +6 -4
  89. package/dist/std/use-cases/index.d.ts +1 -1
  90. package/dist/std/use-cases/shared.d.ts +34 -6
  91. package/dist/std/use-cases/types.d.ts +197 -22
  92. package/dist/testing/http-provider-contract.d.ts +32 -0
  93. package/dist/testing/index.d.ts +4 -0
  94. package/dist/testing/index.js +839 -3
  95. package/dist/testing/memory-publisher.d.ts +16 -0
  96. package/dist/testing/provider-contract.d.ts +31 -1
  97. package/package.json +17 -3
  98. package/dist/index-q6hggpzw.js +0 -6667
  99. package/dist/index-r78dsvtc.js +0 -1721
@@ -0,0 +1,16 @@
1
+ import type { IEventPublisher, PublishedEvent } from "../core/event-policy/types/event-policy.interface.js";
2
+ /** A publisher that keeps what it is given, for tests. */
3
+ export interface MemoryPublisher extends IEventPublisher {
4
+ /** Each publish, in order. */
5
+ readonly published: readonly {
6
+ readonly topic: string;
7
+ readonly event: PublishedEvent;
8
+ }[];
9
+ /** Forgets what was published. */
10
+ clear(): void;
11
+ }
12
+ /**
13
+ * A publisher for `applicationOf({ publishers })` in tests: it keeps each
14
+ * `{ topic, event }` it is given in `published`.
15
+ */
16
+ export declare function memoryPublisher(): MemoryPublisher;
@@ -1,4 +1,4 @@
1
- import { type IRepositoryProvider } from "../index.js";
1
+ import { type IRepositoryProvider } from "../adapters.js";
2
2
  /** The parts of a test runner the kit uses; `bun:test`, vitest and jest fit. */
3
3
  export interface ContractRunner {
4
4
  describe(name: string, body: () => void): void;
@@ -18,6 +18,36 @@ export interface ProviderContractOptions {
18
18
  * to `provider.capabilities?.keyset`.
19
19
  */
20
20
  readonly keyset?: boolean;
21
+ /**
22
+ * Run the cases of declared indexes (`context.indexes`, `query.index`).
23
+ * Defaults to `provider.capabilities?.indexes`.
24
+ */
25
+ readonly indexes?: boolean;
26
+ /**
27
+ * Run the cases of an expected `version` on `update`. Defaults to
28
+ * `provider.capabilities?.versioning`.
29
+ */
30
+ readonly versioning?: boolean;
31
+ /** Run the cases of `increment`. Defaults to `provider.capabilities?.atomic`. */
32
+ readonly atomic?: boolean;
33
+ /** Run the cases of expired records. Defaults to `provider.capabilities?.expiry`. */
34
+ readonly expiry?: boolean;
35
+ /**
36
+ * Run the cases of schema evolution, through repositories and
37
+ * `app.migrate` over the basic methods: an old row read back upgraded,
38
+ * the backfill in check and apply, rows moved from a previous name.
39
+ * Default `true`. Their entities are named `Accounts` (and `One`, the
40
+ * previous name), with the keys of the other cases; `createdAt` and
41
+ * `updatedAt` are never written.
42
+ */
43
+ readonly schemaEvolution?: boolean;
44
+ /**
45
+ * Run the schema evolution cases that store the version key
46
+ * (`SCHEMA_VERSION_KEY`, `"$v"`) in rows, for an entity declared with
47
+ * `schemaVersion`. Default `true`; a provider with a fixed set of
48
+ * columns needs one for it (or maps `context.schema.key` to its own).
49
+ */
50
+ readonly schemaVersionKey?: boolean;
21
51
  }
22
52
  /**
23
53
  * Registers the behavior every `IRepositoryProvider` v2 must have. Pass the
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@afora/core",
3
- "version": "0.0.7",
3
+ "version": "0.0.9",
4
4
  "description": "Domain modeling on TypeBox: entities with invariants, repositories, use cases, sensitive data masking and layered exceptions, usable by any Standard Schema consumer.",
5
5
  "keywords": [
6
6
  "domain-driven-design",
@@ -40,6 +40,11 @@
40
40
  "import": "./dist/index.js",
41
41
  "default": "./dist/index.js"
42
42
  },
43
+ "./adapters": {
44
+ "types": "./dist/adapters.d.ts",
45
+ "import": "./dist/adapters.js",
46
+ "default": "./dist/adapters.js"
47
+ },
43
48
  "./experimental": {
44
49
  "types": "./dist/experimental.d.ts",
45
50
  "import": "./dist/experimental.js",
@@ -68,9 +73,11 @@
68
73
  "lint": "biome lint .",
69
74
  "fmt": "biome check --write .",
70
75
  "knip": "knip",
71
- "build": "rm -rf dist && bun build ./src/index.ts ./src/experimental.ts ./src/testing/index.ts --outdir ./dist --target node --format esm --splitting --packages external && tsc -p tsconfig.build.json",
76
+ "build": "rm -rf dist && bun build ./src/index.ts ./src/adapters.ts ./src/experimental.ts ./src/testing/index.ts --outdir ./dist --target node --format esm --splitting --packages external && tsc -p tsconfig.build.json",
72
77
  "postbuild": "bun scripts/add-dts-extensions.ts",
73
78
  "bench": "cd bench && bun install && bun run.ts",
79
+ "bench:guard": "cd bench && bun install && bun run.ts --guard",
80
+ "bench:check": "cd bench && bun install && bun run.ts --check",
74
81
  "smoke": "bun run build && node scripts/smoke.mjs",
75
82
  "test:types": "bun run build && bun tests/types-compat/run.ts",
76
83
  "test:type-perf": "bun run build && bun test ./tests/type-perf",
@@ -78,14 +85,21 @@
78
85
  "docs:links": "bun scripts/check-doc-links.ts",
79
86
  "test:interop": "cd examples/interop && bun install && bun test",
80
87
  "test:blog": "cd examples/blog && bun install && bun test",
88
+ "test:agent-built": "cd examples/agent-built && bun install && bun check && bun test",
89
+ "eval:agent-built": "cd examples/agent-built && bun install && bun run eval:all",
81
90
  "prepare": "husky",
82
91
  "prepublishOnly": "bun run typecheck && bun test && bun run smoke",
83
92
  "test:codegen": "bun run --cwd packages/codegen test",
84
93
  "test:roundtrip": "bun run --cwd packages/codegen test:roundtrip",
85
94
  "test:mcp": "bun test --cwd packages/mcp",
86
95
  "test:hono": "bun test --cwd packages/hono",
96
+ "test:fastify": "bun test --cwd packages/fastify",
97
+ "test:express": "bun test --cwd packages/express",
98
+ "test:elysia": "bun test --cwd packages/elysia",
99
+ "test:ws": "bun test --cwd packages/ws",
87
100
  "test:drizzle": "bun test --cwd packages/drizzle",
88
- "build:packages": "bun run build && bun run --cwd packages/codegen build && bun run --cwd packages/mcp build && bun run --cwd packages/hono build && bun run --cwd packages/drizzle build"
101
+ "test:dynamodb": "bun test --cwd packages/dynamodb",
102
+ "build:packages": "bun run build && bun run --cwd packages/codegen build && bun run --cwd packages/mcp build && bun run --cwd packages/hono build && bun run --cwd packages/fastify build && bun run --cwd packages/express build && bun run --cwd packages/elysia build && bun run --cwd packages/ws build && bun run --cwd packages/drizzle build && bun run --cwd packages/dynamodb build"
89
103
  },
90
104
  "dependencies": {
91
105
  "slugify": "^1.6.9"