@classytic/arc 1.1.0 → 2.1.3

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 (200) hide show
  1. package/README.md +247 -794
  2. package/bin/arc.js +91 -52
  3. package/dist/EventTransport-BkUDYZEb.d.mts +99 -0
  4. package/dist/HookSystem-BsGV-j2l.mjs +404 -0
  5. package/dist/ResourceRegistry-7Ic20ZMw.mjs +249 -0
  6. package/dist/adapters/index.d.mts +5 -0
  7. package/dist/adapters/index.mjs +3 -0
  8. package/dist/audit/index.d.mts +81 -0
  9. package/dist/audit/index.mjs +275 -0
  10. package/dist/audit/mongodb.d.mts +5 -0
  11. package/dist/audit/mongodb.mjs +3 -0
  12. package/dist/audited-CGdLiSlE.mjs +140 -0
  13. package/dist/auth/index.d.mts +188 -0
  14. package/dist/auth/index.mjs +1096 -0
  15. package/dist/auth/redis-session.d.mts +43 -0
  16. package/dist/auth/redis-session.mjs +75 -0
  17. package/dist/betterAuthOpenApi-DjWDddNc.mjs +249 -0
  18. package/dist/cache/index.d.mts +145 -0
  19. package/dist/cache/index.mjs +91 -0
  20. package/dist/caching-GSDJcA6-.mjs +93 -0
  21. package/dist/chunk-C7Uep-_p.mjs +20 -0
  22. package/dist/circuitBreaker-DYhWBW_D.mjs +1096 -0
  23. package/dist/cli/commands/describe.d.mts +18 -0
  24. package/dist/cli/commands/describe.mjs +238 -0
  25. package/dist/cli/commands/docs.d.mts +13 -0
  26. package/dist/cli/commands/docs.mjs +52 -0
  27. package/dist/cli/commands/{generate.d.ts → generate.d.mts} +3 -2
  28. package/dist/cli/commands/generate.mjs +357 -0
  29. package/dist/cli/commands/{init.d.ts → init.d.mts} +11 -8
  30. package/dist/cli/commands/{init.js → init.mjs} +807 -617
  31. package/dist/cli/commands/introspect.d.mts +10 -0
  32. package/dist/cli/commands/introspect.mjs +75 -0
  33. package/dist/cli/index.d.mts +16 -0
  34. package/dist/cli/index.mjs +156 -0
  35. package/dist/constants-DdXFXQtN.mjs +84 -0
  36. package/dist/core/index.d.mts +5 -0
  37. package/dist/core/index.mjs +4 -0
  38. package/dist/createApp-D2D5XXaV.mjs +559 -0
  39. package/dist/defineResource-PXzSJ15_.mjs +2197 -0
  40. package/dist/discovery/index.d.mts +46 -0
  41. package/dist/discovery/index.mjs +109 -0
  42. package/dist/docs/index.d.mts +162 -0
  43. package/dist/docs/index.mjs +74 -0
  44. package/dist/elevation-DGo5shaX.d.mts +87 -0
  45. package/dist/elevation-DSTbVvYj.mjs +113 -0
  46. package/dist/errorHandler-C3GY3_ow.mjs +108 -0
  47. package/dist/errorHandler-CW3OOeYq.d.mts +72 -0
  48. package/dist/errors-DAWRdiYP.d.mts +124 -0
  49. package/dist/errors-DBANPbGr.mjs +211 -0
  50. package/dist/eventPlugin-BEOvaDqo.mjs +229 -0
  51. package/dist/eventPlugin-H6wDDjGO.d.mts +124 -0
  52. package/dist/events/index.d.mts +53 -0
  53. package/dist/events/index.mjs +51 -0
  54. package/dist/events/transports/redis-stream-entry.d.mts +2 -0
  55. package/dist/events/transports/redis-stream-entry.mjs +177 -0
  56. package/dist/events/transports/redis.d.mts +76 -0
  57. package/dist/events/transports/redis.mjs +124 -0
  58. package/dist/externalPaths-SyPF2tgK.d.mts +50 -0
  59. package/dist/factory/index.d.mts +63 -0
  60. package/dist/factory/index.mjs +3 -0
  61. package/dist/fastifyAdapter-C8DlE0YH.d.mts +216 -0
  62. package/dist/fields-Bi_AVKSo.d.mts +109 -0
  63. package/dist/fields-CTd_CrKr.mjs +114 -0
  64. package/dist/hooks/index.d.mts +4 -0
  65. package/dist/hooks/index.mjs +3 -0
  66. package/dist/idempotency/index.d.mts +96 -0
  67. package/dist/idempotency/index.mjs +319 -0
  68. package/dist/idempotency/mongodb.d.mts +2 -0
  69. package/dist/idempotency/mongodb.mjs +114 -0
  70. package/dist/idempotency/redis.d.mts +2 -0
  71. package/dist/idempotency/redis.mjs +103 -0
  72. package/dist/index.d.mts +260 -0
  73. package/dist/index.mjs +104 -0
  74. package/dist/integrations/event-gateway.d.mts +46 -0
  75. package/dist/integrations/event-gateway.mjs +43 -0
  76. package/dist/integrations/index.d.mts +5 -0
  77. package/dist/integrations/index.mjs +1 -0
  78. package/dist/integrations/jobs.d.mts +103 -0
  79. package/dist/integrations/jobs.mjs +123 -0
  80. package/dist/integrations/streamline.d.mts +60 -0
  81. package/dist/integrations/streamline.mjs +125 -0
  82. package/dist/integrations/websocket.d.mts +82 -0
  83. package/dist/integrations/websocket.mjs +288 -0
  84. package/dist/interface-CSNjltAc.d.mts +77 -0
  85. package/dist/interface-DTbsvIWe.d.mts +54 -0
  86. package/dist/interface-e9XfSsUV.d.mts +1097 -0
  87. package/dist/introspectionPlugin-B3JkrjwU.mjs +53 -0
  88. package/dist/keys-DhqDRxv3.mjs +42 -0
  89. package/dist/logger-ByrvQWZO.mjs +78 -0
  90. package/dist/memory-B2v7KrCB.mjs +143 -0
  91. package/dist/migrations/index.d.mts +156 -0
  92. package/dist/migrations/index.mjs +260 -0
  93. package/dist/mongodb-ClykrfGo.d.mts +118 -0
  94. package/dist/mongodb-DNKEExbf.mjs +93 -0
  95. package/dist/mongodb-Dg8O_gvd.d.mts +71 -0
  96. package/dist/openapi-9nB_kiuR.mjs +525 -0
  97. package/dist/org/index.d.mts +68 -0
  98. package/dist/org/index.mjs +513 -0
  99. package/dist/org/types.d.mts +82 -0
  100. package/dist/org/types.mjs +1 -0
  101. package/dist/permissions/index.d.mts +278 -0
  102. package/dist/permissions/index.mjs +579 -0
  103. package/dist/plugins/index.d.mts +172 -0
  104. package/dist/plugins/index.mjs +522 -0
  105. package/dist/plugins/response-cache.d.mts +87 -0
  106. package/dist/plugins/response-cache.mjs +283 -0
  107. package/dist/plugins/tracing-entry.d.mts +2 -0
  108. package/dist/plugins/tracing-entry.mjs +185 -0
  109. package/dist/pluralize-CM-jZg7p.mjs +86 -0
  110. package/dist/policies/{index.d.ts → index.d.mts} +204 -170
  111. package/dist/policies/index.mjs +321 -0
  112. package/dist/presets/{index.d.ts → index.d.mts} +62 -131
  113. package/dist/presets/index.mjs +143 -0
  114. package/dist/presets/multiTenant.d.mts +24 -0
  115. package/dist/presets/multiTenant.mjs +113 -0
  116. package/dist/presets-BTeYbw7h.d.mts +57 -0
  117. package/dist/presets-CeFtfDR8.mjs +119 -0
  118. package/dist/prisma-C3iornoK.d.mts +274 -0
  119. package/dist/prisma-DJbMt3yf.mjs +627 -0
  120. package/dist/queryCachePlugin-B6R0d4av.mjs +138 -0
  121. package/dist/queryCachePlugin-Q6SYuHZ6.d.mts +71 -0
  122. package/dist/redis-UwjEp8Ea.d.mts +49 -0
  123. package/dist/redis-stream-CBg0upHI.d.mts +103 -0
  124. package/dist/registry/index.d.mts +11 -0
  125. package/dist/registry/index.mjs +4 -0
  126. package/dist/requestContext-xi6OKBL-.mjs +55 -0
  127. package/dist/schemaConverter-Dtg0Kt9T.mjs +98 -0
  128. package/dist/schemas/index.d.mts +63 -0
  129. package/dist/schemas/index.mjs +82 -0
  130. package/dist/scope/index.d.mts +21 -0
  131. package/dist/scope/index.mjs +65 -0
  132. package/dist/sessionManager-D_iEHjQl.d.mts +186 -0
  133. package/dist/sse-DkqQ1uxb.mjs +123 -0
  134. package/dist/testing/index.d.mts +907 -0
  135. package/dist/testing/index.mjs +1976 -0
  136. package/dist/tracing-8CEbhF0w.d.mts +70 -0
  137. package/dist/typeGuards-DwxA1t_L.mjs +9 -0
  138. package/dist/types/index.d.mts +946 -0
  139. package/dist/types/index.mjs +14 -0
  140. package/dist/types-B0dhNrnd.d.mts +445 -0
  141. package/dist/types-Beqn1Un7.mjs +38 -0
  142. package/dist/types-DelU6kln.mjs +25 -0
  143. package/dist/types-RLkFVgaw.d.mts +101 -0
  144. package/dist/utils/index.d.mts +747 -0
  145. package/dist/utils/index.mjs +6 -0
  146. package/package.json +194 -68
  147. package/dist/BaseController-DVAiHxEQ.d.ts +0 -233
  148. package/dist/adapters/index.d.ts +0 -237
  149. package/dist/adapters/index.js +0 -668
  150. package/dist/arcCorePlugin-CsShQdyP.d.ts +0 -273
  151. package/dist/audit/index.d.ts +0 -195
  152. package/dist/audit/index.js +0 -319
  153. package/dist/auth/index.d.ts +0 -47
  154. package/dist/auth/index.js +0 -174
  155. package/dist/cli/commands/docs.d.ts +0 -11
  156. package/dist/cli/commands/docs.js +0 -474
  157. package/dist/cli/commands/generate.js +0 -334
  158. package/dist/cli/commands/introspect.d.ts +0 -8
  159. package/dist/cli/commands/introspect.js +0 -338
  160. package/dist/cli/index.d.ts +0 -4
  161. package/dist/cli/index.js +0 -3269
  162. package/dist/core/index.d.ts +0 -220
  163. package/dist/core/index.js +0 -2786
  164. package/dist/createApp-Ce9wl8W9.d.ts +0 -77
  165. package/dist/docs/index.d.ts +0 -166
  166. package/dist/docs/index.js +0 -658
  167. package/dist/errors-8WIxGS_6.d.ts +0 -122
  168. package/dist/events/index.d.ts +0 -117
  169. package/dist/events/index.js +0 -89
  170. package/dist/factory/index.d.ts +0 -38
  171. package/dist/factory/index.js +0 -1652
  172. package/dist/hooks/index.d.ts +0 -4
  173. package/dist/hooks/index.js +0 -199
  174. package/dist/idempotency/index.d.ts +0 -323
  175. package/dist/idempotency/index.js +0 -500
  176. package/dist/index-B4t03KQ0.d.ts +0 -1366
  177. package/dist/index.d.ts +0 -135
  178. package/dist/index.js +0 -4756
  179. package/dist/migrations/index.d.ts +0 -185
  180. package/dist/migrations/index.js +0 -274
  181. package/dist/org/index.d.ts +0 -129
  182. package/dist/org/index.js +0 -220
  183. package/dist/permissions/index.d.ts +0 -144
  184. package/dist/permissions/index.js +0 -103
  185. package/dist/plugins/index.d.ts +0 -46
  186. package/dist/plugins/index.js +0 -1069
  187. package/dist/policies/index.js +0 -196
  188. package/dist/presets/index.js +0 -384
  189. package/dist/presets/multiTenant.d.ts +0 -39
  190. package/dist/presets/multiTenant.js +0 -112
  191. package/dist/registry/index.d.ts +0 -16
  192. package/dist/registry/index.js +0 -253
  193. package/dist/testing/index.d.ts +0 -618
  194. package/dist/testing/index.js +0 -48020
  195. package/dist/types/index.d.ts +0 -4
  196. package/dist/types/index.js +0 -8
  197. package/dist/types-B99TBmFV.d.ts +0 -76
  198. package/dist/types-BvckRbs2.d.ts +0 -143
  199. package/dist/utils/index.d.ts +0 -679
  200. package/dist/utils/index.js +0 -931
package/bin/arc.js CHANGED
@@ -9,7 +9,9 @@
9
9
  * arc generate controller <name> Generate a controller only
10
10
  * arc generate model <name> Generate a model only
11
11
  * arc introspect Show all registered resources
12
+ * arc describe <entry-file> Output JSON metadata for AI agents
12
13
  * arc docs [output-path] Export OpenAPI specification
14
+ * arc doctor Check environment and dependencies
13
15
  *
14
16
  * Examples:
15
17
  * arc init my-api
@@ -21,8 +23,6 @@
21
23
  */
22
24
 
23
25
  import { readFileSync } from 'node:fs';
24
- import { resolve } from 'node:path';
25
- import { pathToFileURL } from 'node:url';
26
26
 
27
27
  function getPackageVersion() {
28
28
  try {
@@ -78,11 +78,20 @@ async function main() {
78
78
  await handleIntrospect(rest);
79
79
  break;
80
80
 
81
+ case 'describe':
82
+ case 'desc':
83
+ await handleDescribe(subcommand ? [subcommand, ...rest] : rest);
84
+ break;
85
+
81
86
  case 'docs':
82
87
  case 'd':
83
88
  await handleDocs(subcommand ? [subcommand, ...rest] : rest);
84
89
  break;
85
90
 
91
+ case 'doctor':
92
+ await handleDoctor(subcommand ? [subcommand, ...rest] : rest);
93
+ break;
94
+
86
95
  default:
87
96
  console.error(`Unknown command: ${command}`);
88
97
  console.error('Run "arc --help" for usage');
@@ -103,7 +112,7 @@ async function main() {
103
112
 
104
113
  async function handleInit(args) {
105
114
  const options = parseInitOptions(args);
106
- const { init } = await import('../dist/cli/commands/init.js');
115
+ const { init } = await import('../dist/cli/commands/init.mjs');
107
116
  await init(options);
108
117
  }
109
118
 
@@ -146,72 +155,75 @@ async function handleGenerate(type, args) {
146
155
  }
147
156
 
148
157
  // Import and run
149
- const { generate } = await import('../dist/cli/commands/generate.js');
158
+ const { generate } = await import('../dist/cli/commands/generate.mjs');
150
159
  await generate(normalizedType, args);
151
160
  }
152
161
 
153
- async function handleIntrospect(args) {
154
- // Check for --entry flag
155
- const entryIndex = args.findIndex(arg => arg === '--entry' || arg === '-e');
156
- if (entryIndex !== -1 && args[entryIndex + 1]) {
157
- const entryPath = args[entryIndex + 1];
158
- // Resolve path relative to CWD and convert to file URL for ESM import
159
- const absolutePath = resolve(process.cwd(), entryPath);
160
- const fileUrl = pathToFileURL(absolutePath).href;
161
-
162
- console.log(`Loading resources from: ${entryPath}\n`);
163
- try {
164
- await import(fileUrl);
165
- } catch (err) {
166
- console.error(`Failed to load entry file: ${err.message}`);
167
- if (process.env.DEBUG) {
168
- console.error(err.stack);
169
- }
170
- process.exit(1);
171
- }
172
- }
162
+ async function handleIntrospect(rawArgs) {
163
+ const args = normalizeArgs(rawArgs);
164
+ const { entryPath, filteredArgs } = extractEntryArg(args);
173
165
 
174
- const { introspect } = await import('../dist/cli/commands/introspect.js');
175
- await introspect(args.filter((arg, i) => arg !== '--entry' && arg !== '-e' && i !== entryIndex + 1));
166
+ const { introspect } = await import('../dist/cli/commands/introspect.mjs');
167
+ await introspect(entryPath ? [entryPath, ...filteredArgs] : filteredArgs);
176
168
  }
177
169
 
178
- async function handleDocs(args) {
179
- // Check for --entry flag
180
- const entryIndex = args.findIndex(arg => arg === '--entry' || arg === '-e');
181
- if (entryIndex !== -1 && args[entryIndex + 1]) {
182
- const entryPath = args[entryIndex + 1];
183
- // Resolve path relative to CWD and convert to file URL for ESM import
184
- const absolutePath = resolve(process.cwd(), entryPath);
185
- const fileUrl = pathToFileURL(absolutePath).href;
186
-
187
- console.log(`Loading resources from: ${entryPath}\n`);
188
- try {
189
- await import(fileUrl);
190
- } catch (err) {
191
- console.error(`Failed to load entry file: ${err.message}`);
192
- if (process.env.DEBUG) {
193
- console.error(err.stack);
194
- }
195
- process.exit(1);
196
- }
197
- }
170
+ async function handleDescribe(rawArgs) {
171
+ const args = normalizeArgs(rawArgs);
172
+ const { describe } = await import('../dist/cli/commands/describe.mjs');
173
+ await describe(args);
174
+ }
175
+
176
+ async function handleDocs(rawArgs) {
177
+ const args = normalizeArgs(rawArgs);
178
+ const { entryPath, filteredArgs } = extractEntryArg(args);
179
+ const { exportDocs } = await import('../dist/cli/commands/docs.mjs');
180
+ await exportDocs(entryPath ? [entryPath, ...filteredArgs] : filteredArgs);
181
+ }
198
182
 
199
- const filteredArgs = args.filter((arg, i) => arg !== '--entry' && arg !== '-e' && i !== entryIndex + 1);
200
- const outputPath = filteredArgs[0] || './openapi.json';
201
- const { exportDocs } = await import('../dist/cli/commands/docs.js');
202
- await exportDocs([outputPath]);
183
+ async function handleDoctor(rawArgs) {
184
+ const { doctor } = await import('../dist/cli/commands/doctor.mjs');
185
+ await doctor(rawArgs);
203
186
  }
204
187
 
205
188
  // ============================================================================
206
189
  // Option Parsing
207
190
  // ============================================================================
208
191
 
209
- function parseInitOptions(args) {
192
+ // Mirrors src/cli/utils/normalizeArgs.ts — keep in sync
193
+ // (bin/arc.js is unbundled, can't import tree-shaken dist internals)
194
+ function normalizeArgs(raw) {
195
+ const out = [];
196
+ for (const arg of raw) {
197
+ if (arg.startsWith('--') && arg.includes('=')) {
198
+ const eqIdx = arg.indexOf('=');
199
+ out.push(arg.slice(0, eqIdx), arg.slice(eqIdx + 1));
200
+ } else {
201
+ out.push(arg);
202
+ }
203
+ }
204
+ return out;
205
+ }
206
+
207
+ function extractEntryArg(args) {
208
+ const entryIndex = args.findIndex(arg => arg === '--entry' || arg === '-e');
209
+ const hasEntry = entryIndex !== -1 && !!args[entryIndex + 1];
210
+ const entryPath = hasEntry ? args[entryIndex + 1] : undefined;
211
+ const filteredArgs = hasEntry
212
+ ? args.filter((arg, i) => i !== entryIndex && i !== entryIndex + 1)
213
+ : args;
214
+
215
+ return { entryPath, filteredArgs };
216
+ }
217
+
218
+ function parseInitOptions(rawArgs) {
219
+ const args = normalizeArgs(rawArgs);
220
+
210
221
  const opts = {
211
222
  name: undefined,
212
223
  adapter: undefined,
213
224
  tenant: undefined,
214
225
  typescript: undefined,
226
+ edge: undefined,
215
227
  skipInstall: false,
216
228
  force: false,
217
229
  };
@@ -261,6 +273,19 @@ function parseInitOptions(args) {
261
273
  opts.typescript = false;
262
274
  break;
263
275
 
276
+ case '--better-auth':
277
+ opts.auth = 'better-auth';
278
+ break;
279
+
280
+ case '--jwt':
281
+ opts.auth = 'jwt';
282
+ break;
283
+
284
+ case '--edge':
285
+ case '--serverless':
286
+ opts.edge = true;
287
+ break;
288
+
264
289
  case '--skip-install':
265
290
  opts.skipInstall = true;
266
291
  break;
@@ -291,7 +316,9 @@ COMMANDS
291
316
  init, new Initialize a new Arc project
292
317
  generate, g Generate resources, controllers, or models
293
318
  introspect, i Show all registered resources
319
+ describe, desc Output JSON metadata for AI agents
294
320
  docs, d Export OpenAPI specification
321
+ doctor Check environment and dependencies
295
322
 
296
323
  GLOBAL OPTIONS
297
324
  --entry, -e <path> Entry file to load before running command
@@ -302,10 +329,13 @@ GLOBAL OPTIONS
302
329
  INIT OPTIONS
303
330
  --mongokit Use MongoKit adapter (default, recommended)
304
331
  --custom Use custom adapter (empty template)
332
+ --better-auth Use Better Auth (default, recommended)
333
+ --jwt Use Arc built-in JWT auth
305
334
  --multi-tenant, --multi Multi-tenant mode (adds org scoping)
306
335
  --single-tenant, --single Single-tenant mode (default)
307
336
  --ts, --typescript Generate TypeScript (default)
308
337
  --js, --javascript Generate JavaScript
338
+ --edge, --serverless Target Edge/Serverless environments
309
339
  --force, -f Overwrite existing directory
310
340
  --skip-install Skip npm install after scaffolding
311
341
 
@@ -326,7 +356,10 @@ EXAMPLES
326
356
  arc init my-api
327
357
 
328
358
  # Initialize with all options (non-interactive)
329
- arc init my-api --mongokit --single --ts
359
+ arc init my-api --mongokit --better-auth --single --ts
360
+
361
+ # Initialize with JWT auth instead of Better Auth
362
+ arc init my-api --mongokit --jwt --single --ts
330
363
 
331
364
  # Initialize a JavaScript single-tenant app
332
365
  arc init my-api --mongokit --single --js
@@ -349,6 +382,12 @@ EXAMPLES
349
382
  # Show registered resources
350
383
  arc introspect --entry ./dist/index.js
351
384
 
385
+ # Output JSON metadata for AI agents
386
+ arc describe ./dist/resources.js --json
387
+
388
+ # Describe a single resource
389
+ arc describe ./dist/resources.js product
390
+
352
391
  MORE INFO
353
392
  Documentation: https://github.com/classytic/arc
354
393
  Issues: https://github.com/classytic/arc/issues
@@ -0,0 +1,99 @@
1
+ //#region src/events/EventTransport.d.ts
2
+ /**
3
+ * Event Transport Interface
4
+ *
5
+ * Defines contract for event delivery backends.
6
+ * Implement for durable transports (Redis, RabbitMQ, Kafka, etc.)
7
+ *
8
+ * @example
9
+ * // Redis Pub/Sub implementation
10
+ * class RedisEventTransport implements EventTransport {
11
+ * async publish(event) {
12
+ * await redis.publish(event.type, JSON.stringify(event));
13
+ * }
14
+ * async subscribe(pattern, handler) {
15
+ * redis.psubscribe(pattern);
16
+ * redis.on('pmessage', (p, channel, msg) => handler(JSON.parse(msg)));
17
+ * }
18
+ * }
19
+ */
20
+ interface DomainEvent<T = unknown> {
21
+ /** Event type (e.g., 'product.created', 'order.shipped') */
22
+ type: string;
23
+ /** Event payload */
24
+ payload: T;
25
+ /** Event metadata */
26
+ meta: {
27
+ /** Unique event ID */id: string; /** Event timestamp */
28
+ timestamp: Date; /** Source resource */
29
+ resource?: string; /** Resource ID */
30
+ resourceId?: string; /** User who triggered the event */
31
+ userId?: string; /** Organization context */
32
+ organizationId?: string; /** Correlation ID for tracing */
33
+ correlationId?: string;
34
+ };
35
+ }
36
+ type EventHandler<T = unknown> = (event: DomainEvent<T>) => void | Promise<void>;
37
+ /**
38
+ * Minimal logger interface for event transports.
39
+ * Compatible with `console`, `pino`, `fastify.log`, and any custom logger.
40
+ *
41
+ * @example
42
+ * ```typescript
43
+ * // Use Fastify's logger
44
+ * new MemoryEventTransport({ logger: fastify.log });
45
+ *
46
+ * // Use a custom logger
47
+ * new MemoryEventTransport({ logger: { warn: myWarn, error: myError } });
48
+ *
49
+ * // Default: console (no logger option needed)
50
+ * new MemoryEventTransport();
51
+ * ```
52
+ */
53
+ interface EventLogger {
54
+ warn(message: string, ...args: unknown[]): void;
55
+ error(message: string, ...args: unknown[]): void;
56
+ }
57
+ interface EventTransport {
58
+ /** Transport name for logging */
59
+ readonly name: string;
60
+ /**
61
+ * Publish an event to the transport
62
+ */
63
+ publish(event: DomainEvent): Promise<void>;
64
+ /**
65
+ * Subscribe to events matching a pattern
66
+ * @param pattern - Event type pattern (e.g., 'product.*', '*')
67
+ * @param handler - Handler function
68
+ * @returns Unsubscribe function
69
+ */
70
+ subscribe(pattern: string, handler: EventHandler): Promise<() => void>;
71
+ /**
72
+ * Close transport connections
73
+ */
74
+ close?(): Promise<void>;
75
+ }
76
+ interface MemoryEventTransportOptions {
77
+ /** Logger for error/warning messages (default: console) */
78
+ logger?: EventLogger;
79
+ }
80
+ /**
81
+ * In-memory event transport (default)
82
+ * Events are delivered synchronously within the process.
83
+ * Not suitable for multi-instance deployments.
84
+ */
85
+ declare class MemoryEventTransport implements EventTransport {
86
+ readonly name = "memory";
87
+ private handlers;
88
+ private logger;
89
+ constructor(options?: MemoryEventTransportOptions);
90
+ publish(event: DomainEvent): Promise<void>;
91
+ subscribe(pattern: string, handler: EventHandler): Promise<() => void>;
92
+ close(): Promise<void>;
93
+ }
94
+ /**
95
+ * Create a domain event with auto-generated metadata
96
+ */
97
+ declare function createEvent<T>(type: string, payload: T, meta?: Partial<DomainEvent['meta']>): DomainEvent<T>;
98
+ //#endregion
99
+ export { MemoryEventTransport as a, EventTransport as i, EventHandler as n, MemoryEventTransportOptions as o, EventLogger as r, createEvent as s, DomainEvent as t };