@bluelibs/runner 5.1.0 → 5.2.1

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 (314) hide show
  1. package/README.md +25 -15
  2. package/dist/browser/index.cjs +851 -478
  3. package/dist/browser/index.cjs.map +1 -1
  4. package/dist/browser/index.mjs +849 -478
  5. package/dist/browser/index.mjs.map +1 -1
  6. package/dist/edge/index.cjs +851 -478
  7. package/dist/edge/index.cjs.map +1 -1
  8. package/dist/edge/index.mjs +849 -478
  9. package/dist/edge/index.mjs.map +1 -1
  10. package/dist/node/node.cjs +1305 -583
  11. package/dist/node/node.cjs.map +1 -1
  12. package/dist/node/node.mjs +1299 -583
  13. package/dist/node/node.mjs.map +1 -1
  14. package/dist/types/define.d.ts +9 -0
  15. package/dist/types/definers/builders/asyncContext/fluent-builder.d.ts +6 -0
  16. package/dist/types/definers/builders/asyncContext/fluent-builder.interface.d.ts +9 -0
  17. package/dist/types/definers/builders/asyncContext/index.d.ts +10 -0
  18. package/dist/types/definers/builders/asyncContext/types.d.ts +13 -0
  19. package/dist/types/definers/builders/asyncContext/utils.d.ts +5 -0
  20. package/dist/types/definers/builders/asyncContext.d.ts +1 -0
  21. package/dist/types/definers/builders/core.d.ts +30 -0
  22. package/dist/types/definers/builders/error/fluent-builder.d.ts +7 -0
  23. package/dist/types/definers/builders/error/fluent-builder.interface.d.ts +10 -0
  24. package/dist/types/definers/builders/error/index.d.ts +11 -0
  25. package/dist/types/definers/builders/error/types.d.ts +14 -0
  26. package/dist/types/definers/builders/error/utils.d.ts +6 -0
  27. package/dist/types/definers/builders/error.d.ts +1 -0
  28. package/dist/types/definers/builders/event/fluent-builder.d.ts +7 -0
  29. package/dist/types/definers/builders/event/fluent-builder.interface.d.ts +18 -0
  30. package/dist/types/definers/builders/event/index.d.ts +10 -0
  31. package/dist/types/definers/builders/event/types.d.ts +8 -0
  32. package/dist/types/definers/builders/event/utils.d.ts +9 -0
  33. package/dist/types/definers/builders/event.d.ts +1 -0
  34. package/dist/types/definers/builders/hook/fluent-builder.d.ts +8 -0
  35. package/dist/types/definers/builders/hook/fluent-builder.interface.d.ts +27 -0
  36. package/dist/types/definers/builders/hook/index.d.ts +12 -0
  37. package/dist/types/definers/builders/hook/types.d.ts +14 -0
  38. package/dist/types/definers/builders/hook/utils.d.ts +14 -0
  39. package/dist/types/definers/builders/hook.d.ts +1 -0
  40. package/dist/types/definers/builders/middleware/index.d.ts +19 -0
  41. package/dist/types/definers/builders/middleware/resource.d.ts +7 -0
  42. package/dist/types/definers/builders/middleware/resource.interface.d.ts +18 -0
  43. package/dist/types/definers/builders/middleware/task.d.ts +7 -0
  44. package/dist/types/definers/builders/middleware/task.interface.d.ts +18 -0
  45. package/dist/types/definers/builders/middleware/types.d.ts +13 -0
  46. package/dist/types/definers/builders/middleware/utils.d.ts +18 -0
  47. package/dist/types/definers/builders/middleware.d.ts +1 -0
  48. package/dist/types/definers/builders/override/hook.d.ts +16 -0
  49. package/dist/types/definers/builders/override/index.d.ts +11 -0
  50. package/dist/types/definers/builders/override/resource-middleware.d.ts +3 -0
  51. package/dist/types/definers/builders/override/resource.d.ts +3 -0
  52. package/dist/types/definers/builders/override/task-middleware.d.ts +3 -0
  53. package/dist/types/definers/builders/override/task.d.ts +3 -0
  54. package/dist/types/definers/builders/resource/fluent-builder.d.ts +8 -0
  55. package/dist/types/definers/builders/resource/fluent-builder.interface.d.ts +42 -0
  56. package/dist/types/definers/builders/resource/index.d.ts +13 -0
  57. package/dist/types/definers/builders/resource/types.d.ts +37 -0
  58. package/dist/types/definers/builders/resource/utils.d.ts +26 -0
  59. package/dist/types/definers/builders/resource.d.ts +1 -0
  60. package/dist/types/definers/builders/tag/fluent-builder.d.ts +6 -0
  61. package/dist/types/definers/builders/tag/fluent-builder.interface.d.ts +8 -0
  62. package/dist/types/definers/builders/tag/index.d.ts +10 -0
  63. package/dist/types/definers/builders/tag/types.d.ts +12 -0
  64. package/dist/types/definers/builders/tag/utils.d.ts +5 -0
  65. package/dist/types/definers/builders/tag.d.ts +1 -0
  66. package/dist/types/definers/builders/task/fluent-builder.d.ts +8 -0
  67. package/dist/types/definers/builders/task/fluent-builder.interface.d.ts +33 -0
  68. package/dist/types/definers/builders/task/index.d.ts +21 -0
  69. package/dist/types/definers/builders/task/phantom-builder.d.ts +8 -0
  70. package/dist/types/definers/builders/task/phantom-builder.interface.d.ts +31 -0
  71. package/dist/types/definers/builders/task/types.d.ts +34 -0
  72. package/dist/types/definers/builders/task/utils.d.ts +14 -0
  73. package/dist/types/definers/builders/task.d.ts +1 -0
  74. package/dist/types/definers/builders/task.phantom.d.ts +1 -0
  75. package/dist/types/definers/builders/utils.d.ts +4 -0
  76. package/dist/types/definers/defineAsyncContext.d.ts +15 -0
  77. package/dist/types/definers/defineError.d.ts +27 -0
  78. package/dist/types/definers/defineEvent.d.ts +2 -0
  79. package/dist/types/definers/defineHook.d.ts +6 -0
  80. package/dist/types/definers/defineOverride.d.ts +12 -0
  81. package/dist/types/definers/defineResource.d.ts +2 -0
  82. package/dist/types/definers/defineResourceMiddleware.d.ts +2 -0
  83. package/dist/types/definers/defineTag.d.ts +12 -0
  84. package/dist/types/definers/defineTask.d.ts +18 -0
  85. package/dist/types/definers/defineTaskMiddleware.d.ts +2 -0
  86. package/dist/types/definers/middlewareConfig.d.ts +1 -0
  87. package/dist/types/definers/resourceFork.d.ts +13 -0
  88. package/dist/types/definers/tools.d.ts +53 -0
  89. package/dist/types/defs.d.ts +33 -0
  90. package/dist/types/errors.d.ts +75 -0
  91. package/dist/types/globals/debug.d.ts +10 -0
  92. package/dist/types/globals/globalEvents.d.ts +8 -0
  93. package/dist/types/globals/globalMiddleware.d.ts +97 -0
  94. package/dist/types/globals/globalResources.d.ts +64 -0
  95. package/dist/types/globals/globalTags.d.ts +12 -0
  96. package/dist/types/globals/middleware/cache.middleware.d.ts +36 -0
  97. package/dist/types/globals/middleware/circuitBreaker.middleware.d.ts +56 -0
  98. package/dist/types/globals/middleware/concurrency.middleware.d.ts +47 -0
  99. package/dist/types/globals/middleware/fallback.middleware.d.ts +23 -0
  100. package/dist/types/globals/middleware/rateLimit.middleware.d.ts +47 -0
  101. package/dist/types/globals/middleware/requireContext.middleware.d.ts +5 -0
  102. package/dist/types/globals/middleware/retry.middleware.d.ts +31 -0
  103. package/dist/types/globals/middleware/temporal.middleware.d.ts +48 -0
  104. package/dist/types/globals/middleware/timeout.middleware.d.ts +24 -0
  105. package/dist/types/globals/middleware/tunnel.middleware.d.ts +3 -0
  106. package/dist/types/globals/resources/debug/debug.resource.d.ts +7 -0
  107. package/dist/types/globals/resources/debug/debug.tag.d.ts +2 -0
  108. package/dist/types/globals/resources/debug/debugConfig.resource.d.ts +22 -0
  109. package/dist/types/globals/resources/debug/executionTracker.middleware.d.ts +50 -0
  110. package/dist/types/globals/resources/debug/globalEvent.hook.d.ts +27 -0
  111. package/dist/types/globals/resources/debug/hook.hook.d.ts +30 -0
  112. package/dist/types/globals/resources/debug/index.d.ts +6 -0
  113. package/dist/types/globals/resources/debug/middleware.hook.d.ts +30 -0
  114. package/dist/types/globals/resources/debug/types.d.ts +25 -0
  115. package/dist/types/globals/resources/debug/utils.d.ts +2 -0
  116. package/dist/types/globals/resources/httpClientFactory.resource.d.ts +28 -0
  117. package/dist/types/globals/resources/queue.resource.d.ts +10 -0
  118. package/dist/types/globals/resources/tunnel/error-utils.d.ts +1 -0
  119. package/dist/types/globals/resources/tunnel/plan.d.ts +19 -0
  120. package/dist/types/globals/resources/tunnel/protocol.d.ts +48 -0
  121. package/dist/types/globals/resources/tunnel/tunnel.policy.tag.d.ts +26 -0
  122. package/dist/types/globals/resources/tunnel/tunnel.tag.d.ts +2 -0
  123. package/dist/types/globals/resources/tunnel/types.d.ts +48 -0
  124. package/dist/types/globals/tunnels/index.d.ts +23 -0
  125. package/dist/types/globals/types.d.ts +15 -0
  126. package/dist/types/http-client.d.ts +26 -0
  127. package/dist/types/http-fetch-tunnel.resource.d.ts +11 -0
  128. package/dist/types/index.d.ts +44 -0
  129. package/dist/types/models/DependencyProcessor.d.ts +46 -0
  130. package/dist/types/models/EventManager.d.ts +115 -0
  131. package/dist/types/models/ExecutionJournal.d.ts +35 -0
  132. package/dist/types/models/LogPrinter.d.ts +56 -0
  133. package/dist/types/models/Logger.d.ts +85 -0
  134. package/dist/types/models/MiddlewareManager.d.ts +73 -0
  135. package/dist/types/models/OverrideManager.d.ts +13 -0
  136. package/dist/types/models/Queue.d.ts +40 -0
  137. package/dist/types/models/ResourceInitializer.d.ts +20 -0
  138. package/dist/types/models/RunResult.d.ts +41 -0
  139. package/dist/types/models/Semaphore.d.ts +80 -0
  140. package/dist/types/models/Store.d.ts +76 -0
  141. package/dist/types/models/StoreRegistry.d.ts +49 -0
  142. package/dist/types/models/StoreValidator.d.ts +8 -0
  143. package/dist/types/models/TaskRunner.d.ts +28 -0
  144. package/dist/types/models/UnhandledError.d.ts +11 -0
  145. package/dist/types/models/event/CycleContext.d.ts +9 -0
  146. package/dist/types/models/event/EmissionExecutor.d.ts +11 -0
  147. package/dist/types/models/event/InterceptorPipeline.d.ts +5 -0
  148. package/dist/types/models/event/ListenerRegistry.d.ts +31 -0
  149. package/dist/types/models/event/types.d.ts +50 -0
  150. package/dist/types/models/index.d.ts +13 -0
  151. package/dist/types/models/middleware/InterceptorRegistry.d.ts +56 -0
  152. package/dist/types/models/middleware/MiddlewareResolver.d.ts +31 -0
  153. package/dist/types/models/middleware/ResourceMiddlewareComposer.d.ts +34 -0
  154. package/dist/types/models/middleware/TaskMiddlewareComposer.d.ts +44 -0
  155. package/dist/types/models/middleware/ValidationHelper.d.ts +20 -0
  156. package/dist/types/models/middleware/index.d.ts +6 -0
  157. package/dist/types/models/middleware/types.d.ts +10 -0
  158. package/dist/types/models/utils/findCircularDependencies.d.ts +16 -0
  159. package/dist/types/models/utils/safeStringify.d.ts +3 -0
  160. package/dist/types/node/durable/bus/MemoryEventBus.d.ts +7 -0
  161. package/dist/types/node/durable/bus/NoopEventBus.d.ts +6 -0
  162. package/dist/types/node/durable/bus/RedisEventBus.d.ts +30 -0
  163. package/dist/types/node/durable/core/CronParser.d.ts +15 -0
  164. package/dist/types/node/durable/core/DurableContext.d.ts +64 -0
  165. package/dist/types/node/durable/core/DurableOperator.d.ts +47 -0
  166. package/dist/types/node/durable/core/DurableResource.d.ts +80 -0
  167. package/dist/types/node/durable/core/DurableService.d.ts +73 -0
  168. package/dist/types/node/durable/core/DurableWorker.d.ts +19 -0
  169. package/dist/types/node/durable/core/StepBuilder.d.ts +23 -0
  170. package/dist/types/node/durable/core/audit.d.ts +152 -0
  171. package/dist/types/node/durable/core/createRunnerDurableRuntime.d.ts +18 -0
  172. package/dist/types/node/durable/core/durable-context/DurableContext.audit.d.ts +14 -0
  173. package/dist/types/node/durable/core/durable-context/DurableContext.determinism.d.ts +13 -0
  174. package/dist/types/node/durable/core/durable-context/DurableContext.emit.d.ts +16 -0
  175. package/dist/types/node/durable/core/durable-context/DurableContext.sleep.d.ts +16 -0
  176. package/dist/types/node/durable/core/durable-context/DurableContext.steps.d.ts +25 -0
  177. package/dist/types/node/durable/core/durable-context/DurableContext.switch.d.ts +22 -0
  178. package/dist/types/node/durable/core/durable-context/DurableContext.waitForSignal.d.ts +23 -0
  179. package/dist/types/node/durable/core/flowShape.d.ts +50 -0
  180. package/dist/types/node/durable/core/ids.d.ts +11 -0
  181. package/dist/types/node/durable/core/index.d.ts +11 -0
  182. package/dist/types/node/durable/core/interfaces/bus.d.ts +13 -0
  183. package/dist/types/node/durable/core/interfaces/context.d.ts +105 -0
  184. package/dist/types/node/durable/core/interfaces/queue.d.ts +17 -0
  185. package/dist/types/node/durable/core/interfaces/service.d.ts +146 -0
  186. package/dist/types/node/durable/core/interfaces/store.d.ts +66 -0
  187. package/dist/types/node/durable/core/managers/AuditLogger.d.ts +29 -0
  188. package/dist/types/node/durable/core/managers/ExecutionManager.d.ts +48 -0
  189. package/dist/types/node/durable/core/managers/PollingManager.d.ts +48 -0
  190. package/dist/types/node/durable/core/managers/ScheduleManager.d.ts +33 -0
  191. package/dist/types/node/durable/core/managers/SignalHandler.d.ts +25 -0
  192. package/dist/types/node/durable/core/managers/TaskRegistry.d.ts +16 -0
  193. package/dist/types/node/durable/core/managers/WaitManager.d.ts +26 -0
  194. package/dist/types/node/durable/core/managers/index.d.ts +7 -0
  195. package/dist/types/node/durable/core/resource.d.ts +14 -0
  196. package/dist/types/node/durable/core/types.d.ts +84 -0
  197. package/dist/types/node/durable/core/utils.d.ts +28 -0
  198. package/dist/types/node/durable/dashboard/server.d.ts +20 -0
  199. package/dist/types/node/durable/emitters/runnerAuditEmitter.d.ts +6 -0
  200. package/dist/types/node/durable/events.d.ts +76 -0
  201. package/dist/types/node/durable/index.d.ts +34 -0
  202. package/dist/types/node/durable/optionalDeps/amqplib.d.ts +1 -0
  203. package/dist/types/node/durable/optionalDeps/ioredis.d.ts +1 -0
  204. package/dist/types/node/durable/queue/MemoryQueue.d.ts +12 -0
  205. package/dist/types/node/durable/queue/RabbitMQQueue.d.ts +30 -0
  206. package/dist/types/node/durable/resources/isolation.d.ts +15 -0
  207. package/dist/types/node/durable/resources/memoryDurableResource.d.ts +21 -0
  208. package/dist/types/node/durable/resources/redisDurableResource.d.ts +35 -0
  209. package/dist/types/node/durable/store/MemoryStore.d.ts +56 -0
  210. package/dist/types/node/durable/store/RedisStore.d.ts +89 -0
  211. package/dist/types/node/durable/test-utils.d.ts +29 -0
  212. package/dist/types/node/exposure/allowList.d.ts +3 -0
  213. package/dist/types/node/exposure/authenticator.d.ts +16 -0
  214. package/dist/types/node/exposure/cors.d.ts +4 -0
  215. package/dist/types/node/exposure/createNodeExposure.d.ts +2 -0
  216. package/dist/types/node/exposure/exposureServer.d.ts +18 -0
  217. package/dist/types/node/exposure/handlers/contextWrapper.d.ts +18 -0
  218. package/dist/types/node/exposure/handlers/errorHandlers.d.ts +23 -0
  219. package/dist/types/node/exposure/handlers/eventHandler.d.ts +20 -0
  220. package/dist/types/node/exposure/handlers/taskHandler.d.ts +24 -0
  221. package/dist/types/node/exposure/httpResponse.d.ts +10 -0
  222. package/dist/types/node/exposure/index.d.ts +3 -0
  223. package/dist/types/node/exposure/logging.d.ts +4 -0
  224. package/dist/types/node/exposure/multipart.d.ts +36 -0
  225. package/dist/types/node/exposure/requestBody.d.ts +11 -0
  226. package/dist/types/node/exposure/requestContext.d.ts +17 -0
  227. package/dist/types/node/exposure/requestHandlers.d.ts +29 -0
  228. package/dist/types/node/exposure/resource.d.ts +12 -0
  229. package/dist/types/node/exposure/resourceTypes.d.ts +73 -0
  230. package/dist/types/node/exposure/router.d.ts +17 -0
  231. package/dist/types/node/exposure/serverLifecycle.d.ts +13 -0
  232. package/dist/types/node/exposure/types.d.ts +45 -0
  233. package/dist/types/node/exposure/utils.d.ts +17 -0
  234. package/dist/types/node/files/createNodeFile.d.ts +9 -0
  235. package/dist/types/node/files/index.d.ts +4 -0
  236. package/dist/types/node/files/inputFile.model.d.ts +22 -0
  237. package/dist/types/node/files/inputFile.utils.d.ts +14 -0
  238. package/dist/types/node/http/http-mixed-client.d.ts +45 -0
  239. package/dist/types/node/http/http-mixed-client.factory.resource.d.ts +17 -0
  240. package/dist/types/node/http/http-smart-client.factory.resource.d.ts +16 -0
  241. package/dist/types/node/http/http-smart-client.model.d.ts +27 -0
  242. package/dist/types/node/http/index.d.ts +4 -0
  243. package/dist/types/node/index.d.ts +1 -0
  244. package/dist/types/node/node.d.ts +193 -0
  245. package/dist/types/node/platform/createFile.d.ts +9 -0
  246. package/dist/types/node/tunnel/allowlist.d.ts +7 -0
  247. package/dist/types/node/tunnel/index.d.ts +2 -0
  248. package/dist/types/node/upload/manifest.d.ts +23 -0
  249. package/dist/types/platform/adapters/browser.d.ts +14 -0
  250. package/dist/types/platform/adapters/edge.d.ts +5 -0
  251. package/dist/types/platform/adapters/node-als.d.ts +1 -0
  252. package/dist/types/platform/adapters/node.d.ts +15 -0
  253. package/dist/types/platform/adapters/universal-generic.d.ts +14 -0
  254. package/dist/types/platform/adapters/universal.d.ts +18 -0
  255. package/dist/types/platform/createFile.d.ts +10 -0
  256. package/dist/types/platform/createWebFile.d.ts +11 -0
  257. package/dist/types/platform/factory.d.ts +2 -0
  258. package/dist/types/platform/index.d.ts +27 -0
  259. package/dist/types/platform/types.d.ts +31 -0
  260. package/dist/types/processHooks.d.ts +2 -0
  261. package/dist/types/public-types.d.ts +13 -0
  262. package/dist/types/public.d.ts +210 -0
  263. package/dist/types/run.d.ts +14 -0
  264. package/dist/types/serializer/Serializer.d.ts +84 -0
  265. package/dist/types/serializer/binary-builtins.d.ts +5 -0
  266. package/dist/types/serializer/builtins.d.ts +47 -0
  267. package/dist/types/serializer/deserializer.d.ts +27 -0
  268. package/dist/types/serializer/error-url-builtins.d.ts +13 -0
  269. package/dist/types/serializer/graph-serializer.d.ts +27 -0
  270. package/dist/types/serializer/index.d.ts +6 -0
  271. package/dist/types/serializer/option-normalizers.d.ts +2 -0
  272. package/dist/types/serializer/regexp-validator.d.ts +34 -0
  273. package/dist/types/serializer/serialize-utils.d.ts +15 -0
  274. package/dist/types/serializer/special-values.d.ts +20 -0
  275. package/dist/types/serializer/tree-serializer.d.ts +20 -0
  276. package/dist/types/serializer/type-registry.d.ts +58 -0
  277. package/dist/types/serializer/types.d.ts +126 -0
  278. package/dist/types/serializer/validation.d.ts +34 -0
  279. package/dist/types/testing.d.ts +19 -0
  280. package/dist/types/tools/detectRunnerMode.d.ts +9 -0
  281. package/dist/types/tools/getCallerFile.d.ts +1 -0
  282. package/dist/types/tools/throws.d.ts +7 -0
  283. package/dist/types/tunnels/buildUniversalManifest.d.ts +24 -0
  284. package/dist/types/types/asyncContext.d.ts +41 -0
  285. package/dist/types/types/contracts.d.ts +62 -0
  286. package/dist/types/types/error.d.ts +39 -0
  287. package/dist/types/types/event.d.ts +79 -0
  288. package/dist/types/types/executionJournal.d.ts +29 -0
  289. package/dist/types/types/hook.d.ts +23 -0
  290. package/dist/types/types/inputFile.d.ts +34 -0
  291. package/dist/types/types/meta.d.ts +22 -0
  292. package/dist/types/types/resource.d.ts +133 -0
  293. package/dist/types/types/resourceMiddleware.d.ts +48 -0
  294. package/dist/types/types/runner.d.ts +68 -0
  295. package/dist/types/types/storeTypes.d.ts +46 -0
  296. package/dist/types/types/symbols.d.ts +34 -0
  297. package/dist/types/types/tag.d.ts +45 -0
  298. package/dist/types/types/task.d.ts +76 -0
  299. package/dist/types/types/taskMiddleware.d.ts +55 -0
  300. package/dist/types/types/utilities.d.ts +125 -0
  301. package/dist/universal/index.cjs +851 -476
  302. package/dist/universal/index.cjs.map +1 -1
  303. package/dist/universal/index.mjs +849 -476
  304. package/dist/universal/index.mjs.map +1 -1
  305. package/package.json +15 -14
  306. package/readmes/AI.md +30 -9
  307. package/dist/browser/index.d.mts +0 -2919
  308. package/dist/browser/index.d.ts +0 -2919
  309. package/dist/edge/index.d.mts +0 -2919
  310. package/dist/edge/index.d.ts +0 -2919
  311. package/dist/node/node.d.mts +0 -4622
  312. package/dist/node/node.d.ts +0 -4622
  313. package/dist/universal/index.d.mts +0 -2919
  314. package/dist/universal/index.d.ts +0 -2919
@@ -0,0 +1,34 @@
1
+ /**
2
+ * RegExp pattern safety validation for ReDoS protection.
3
+ * Extracted from Serializer.ts as a standalone module.
4
+ */
5
+ export interface RegExpPayload {
6
+ pattern: string;
7
+ flags: string;
8
+ }
9
+ export interface RegExpValidatorOptions {
10
+ maxPatternLength: number;
11
+ allowUnsafe: boolean;
12
+ }
13
+ /**
14
+ * Check if a character is a quantifier at the given position.
15
+ */
16
+ export declare const isQuantifierAt: (pattern: string, index: number) => boolean;
17
+ /**
18
+ * Check if a character represents a quantifier (*, +, ?, {n,m}).
19
+ */
20
+ export declare const isQuantifierChar: (char: string, pattern: string, index: number) => boolean;
21
+ /**
22
+ * Check if the pattern contains a bounded quantifier at the given position.
23
+ */
24
+ export declare const isBoundedQuantifier: (pattern: string, index: number) => boolean;
25
+ /**
26
+ * Check if a RegExp pattern is safe from ReDoS attacks.
27
+ * Detects nested quantifiers which are a common ReDoS vector.
28
+ */
29
+ export declare const isRegExpPatternSafe: (pattern: string) => boolean;
30
+ /**
31
+ * Validate and extract a RegExp payload from unknown data.
32
+ * Enforces pattern length limits and optional safety checks.
33
+ */
34
+ export declare const assertRegExpPayload: (value: unknown, options: RegExpValidatorOptions) => RegExpPayload;
@@ -0,0 +1,15 @@
1
+ import type { TypeDefinition } from "./types";
2
+ import type { SerializedTypeRecord, SerializedValue } from "./types";
3
+ import type { TypeRegistry } from "./type-registry";
4
+ export declare const serializeArrayItems: <TSerializedValue>(source: readonly unknown[], serializeNested: (value: unknown) => TSerializedValue) => TSerializedValue[];
5
+ export declare const serializeRecordEntries: <TSerializedValue>(source: Record<string, unknown>, unsafeKeys: ReadonlySet<string>, serializeNested: (value: unknown) => TSerializedValue) => Record<string, TSerializedValue>;
6
+ export declare function serializeTypeRecord(typeDef: TypeDefinition<unknown, unknown>, value: unknown, excludedTypeIds: string[], serializeNested: (value: unknown) => SerializedValue): SerializedTypeRecord;
7
+ export declare function serializeTypeRecord<TSerializedValue>(typeDef: TypeDefinition<unknown, unknown>, value: unknown, excludedTypeIds: string[], serializeNested: (value: unknown) => TSerializedValue): {
8
+ __type: string;
9
+ value: TSerializedValue;
10
+ };
11
+ export declare function serializeSymbolValue(value: symbol, excludedTypeIds: string[], typeRegistry: TypeRegistry, serializeNested: (value: unknown) => SerializedValue): SerializedValue;
12
+ export declare function serializeSymbolValue<TSerializedValue>(value: symbol, excludedTypeIds: string[], typeRegistry: TypeRegistry, serializeNested: (value: unknown) => TSerializedValue): {
13
+ __type: string;
14
+ value: TSerializedValue;
15
+ };
@@ -0,0 +1,20 @@
1
+ import type { SerializedValue } from "./types";
2
+ export declare enum SpecialTypeId {
3
+ Undefined = "Undefined",
4
+ NonFiniteNumber = "NonFiniteNumber",
5
+ BigInt = "BigInt",
6
+ Symbol = "Symbol"
7
+ }
8
+ export declare enum NonFiniteNumberTag {
9
+ NaN = "NaN",
10
+ Infinity = "Infinity",
11
+ NegativeInfinity = "-Infinity"
12
+ }
13
+ export declare const serializeUndefined: () => SerializedValue;
14
+ export type BigIntPayload = string;
15
+ export declare const serializeBigIntPayload: (value: bigint) => BigIntPayload;
16
+ export declare const assertBigIntPayload: (value: unknown) => BigIntPayload;
17
+ export declare const serializeBigInt: (value: bigint) => SerializedValue;
18
+ export declare const getNonFiniteNumberTag: (value: number) => NonFiniteNumberTag | null;
19
+ export declare const serializeNonFiniteNumber: (value: number) => SerializedValue;
20
+ export declare const assertNonFiniteNumberTag: (value: unknown) => NonFiniteNumberTag;
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Tree-mode serialization without circular reference support.
3
+ * Used by stringify() for simple JSON-compatible output.
4
+ * Extracted from Serializer.ts as a standalone module.
5
+ */
6
+ import type { TypeRegistry } from "./type-registry";
7
+ export interface TreeSerializeContext {
8
+ stack: WeakSet<object>;
9
+ serializingValueTypes: WeakSet<object>;
10
+ excludedTypeIds: string[];
11
+ }
12
+ export interface TreeSerializerOptions {
13
+ maxDepth: number;
14
+ unsafeKeys: ReadonlySet<string>;
15
+ typeRegistry: TypeRegistry;
16
+ }
17
+ /**
18
+ * Serialize a value in tree mode (throws on circular references).
19
+ */
20
+ export declare const serializeTreeValue: (value: unknown, context: TreeSerializeContext, depth: number, options: TreeSerializerOptions) => unknown;
@@ -0,0 +1,58 @@
1
+ /**
2
+ * Type registry for managing custom serialization types.
3
+ * Extracted from Serializer.ts as a standalone module.
4
+ */
5
+ import type { TypeDefinition } from "./types";
6
+ import { SymbolPolicy } from "./types";
7
+ import { type RegExpValidatorOptions } from "./regexp-validator";
8
+ export interface TypeRegistryOptions {
9
+ allowedTypes: ReadonlySet<string> | null;
10
+ regExpValidator: RegExpValidatorOptions;
11
+ symbolPolicy: SymbolPolicy;
12
+ }
13
+ /**
14
+ * Registry for managing custom type definitions.
15
+ */
16
+ export declare class TypeRegistry {
17
+ private readonly typeRegistry;
18
+ private readonly typeMap;
19
+ private typeList;
20
+ private readonly allowedTypes;
21
+ private readonly regExpOptions;
22
+ private readonly symbolPolicy;
23
+ constructor(options: TypeRegistryOptions);
24
+ /**
25
+ * Get the list of registered types for iteration.
26
+ */
27
+ getTypeList(): readonly TypeDefinition<unknown, unknown>[];
28
+ /**
29
+ * @internal - Map-like get() for test compatibility.
30
+ */
31
+ get(typeId: string): TypeDefinition<unknown, unknown> | undefined;
32
+ /**
33
+ * Register a custom type definition.
34
+ */
35
+ addType<TInstance, TSerialized>(typeDef: TypeDefinition<TInstance, TSerialized>): void;
36
+ addType<TJson = unknown, TInstance = unknown>(name: string, factory: (json: TJson) => TInstance): void;
37
+ /**
38
+ * Find a type definition that matches the given value.
39
+ */
40
+ findTypeDefinition(value: unknown, excludedTypeIds: readonly string[]): TypeDefinition<unknown, unknown> | undefined;
41
+ /**
42
+ * Get a type definition by ID with allowed types enforcement.
43
+ */
44
+ getTypeDefinition(typeId: string): TypeDefinition<unknown, unknown>;
45
+ /**
46
+ * Deserialize typed data with special handling for RegExp.
47
+ */
48
+ deserializeType(typeDef: TypeDefinition<unknown, unknown>, typeId: string, data: unknown): unknown;
49
+ /**
50
+ * Check if a type's serialized payload matches the type itself.
51
+ * Used to prevent recursive type application.
52
+ */
53
+ shouldExcludeTypeFromPayload(typeDef: TypeDefinition<unknown, unknown>, serializedPayload: unknown): boolean;
54
+ private registerBuiltInTypes;
55
+ private refreshTypeCache;
56
+ private assertSymbolPolicyValue;
57
+ private assertSymbolPolicy;
58
+ }
@@ -0,0 +1,126 @@
1
+ /**
2
+ * Type definitions for the Serializer class
3
+ */
4
+ /**
5
+ * Definition for a custom type that can be serialized/deserialized
6
+ */
7
+ export interface TypeDefinition<TInstance = unknown, TSerialized = unknown> {
8
+ /** Unique identifier for the type */
9
+ id: string;
10
+ /** Predicate function to check if an object matches this type */
11
+ is: (obj: unknown) => obj is TInstance;
12
+ /** Function to serialize the object */
13
+ serialize: (obj: TInstance) => TSerialized;
14
+ /** Function to deserialize the data back to the original object */
15
+ deserialize: (data: TSerialized) => TInstance;
16
+ /** Optional factory used to create a placeholder during deserialization */
17
+ create?: () => TInstance;
18
+ /** Serialization strategy: 'value' (inline, no identity) or 'ref' (graph node, identity preserved). Default: 'ref' */
19
+ strategy?: "value" | "ref";
20
+ }
21
+ /** Reference to another object in the serialization */
22
+ export interface ObjectReference {
23
+ /** Reference to object ID */
24
+ __ref: string;
25
+ }
26
+ /**
27
+ * Discriminated union describing the serialized graph payload.
28
+ * Each node captures either an array, plain object, or typed payload.
29
+ */
30
+ export type SerializedNode = {
31
+ kind: "array";
32
+ value: SerializedValue[];
33
+ } | {
34
+ kind: "object";
35
+ value: Record<string, SerializedValue>;
36
+ } | {
37
+ kind: "type";
38
+ type: string;
39
+ value: SerializedValue;
40
+ };
41
+ /**
42
+ * Serialization context for tracking object references
43
+ */
44
+ export interface SerializationContext {
45
+ /** Map of objects to their IDs */
46
+ objectIds: WeakMap<object, string>;
47
+ /** Counter for generating unique IDs */
48
+ idCounter: number;
49
+ /** Number of graph nodes recorded */
50
+ nodeCount: number;
51
+ /** Nodes collected during serialization (id -> serialized node) */
52
+ nodes: Record<string, SerializedNode>;
53
+ }
54
+ /**
55
+ * Deserialization context used when materialising a graph payload.
56
+ */
57
+ export interface DeserializationContext {
58
+ nodes: Record<string, SerializedNode>;
59
+ resolved: Map<string, unknown>;
60
+ resolving: Set<string>;
61
+ /**
62
+ * Tracks reference ids that were requested while still being resolved.
63
+ * Used to detect circular references that rely on placeholders.
64
+ */
65
+ resolvingRefs: Set<string>;
66
+ }
67
+ /**
68
+ * Union type for serialized values
69
+ */
70
+ export type JsonPrimitive = string | number | boolean | null;
71
+ export type JsonValue = JsonPrimitive | JsonValue[] | {
72
+ [key: string]: JsonValue;
73
+ };
74
+ export interface SerializedTypeRecord {
75
+ __type: string;
76
+ value: SerializedValue;
77
+ }
78
+ export type SerializedValue = JsonPrimitive | ObjectReference | SerializedTypeRecord | SerializedValue[] | {
79
+ [key: string]: SerializedValue;
80
+ };
81
+ /**
82
+ * Envelope saved to disk/wire when serialising a graph payload.
83
+ */
84
+ export interface SerializedGraph {
85
+ __graph: true;
86
+ version: number;
87
+ root: SerializedValue;
88
+ nodes: Record<string, SerializedNode>;
89
+ }
90
+ export declare enum SymbolPolicy {
91
+ AllowAll = "AllowAll",
92
+ WellKnownOnly = "WellKnownOnly",
93
+ Disabled = "Disabled"
94
+ }
95
+ export declare enum SymbolPolicyErrorMessage {
96
+ GlobalSymbolsNotAllowed = "Global symbols are not allowed",
97
+ SymbolsNotAllowed = "Symbols are not allowed",
98
+ UnsupportedSymbolPolicy = "Unsupported symbol policy"
99
+ }
100
+ /**
101
+ * Main serializer options
102
+ */
103
+ export interface SerializerOptions {
104
+ /** Whether to pretty-print JSON (for debugging) */
105
+ pretty?: boolean;
106
+ /** Maximum recursion depth allowed during serialize/deserialize */
107
+ maxDepth?: number;
108
+ /** Restrict deserialization to this list of type IDs */
109
+ allowedTypes?: readonly string[];
110
+ /** Controls which Symbol payloads may be deserialized */
111
+ symbolPolicy?: SymbolPolicy;
112
+ /** Maximum accepted RegExp pattern length during deserialization */
113
+ maxRegExpPatternLength?: number;
114
+ /** Allow RegExp patterns that fail the safety heuristic */
115
+ allowUnsafeRegExp?: boolean;
116
+ }
117
+ /**
118
+ * Minimal serializer contract used across transports and persistence.
119
+ * Implementations must be able to round-trip JSON-compatible payloads and
120
+ * should support custom value types via `addType`.
121
+ */
122
+ export interface SerializerLike {
123
+ stringify(value: unknown): string;
124
+ parse<T = unknown>(text: string): T;
125
+ addType?<TJson = unknown, TInstance = unknown>(name: string, factory: (json: TJson) => TInstance): void;
126
+ }
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Validation helpers and type guards for serialization.
3
+ * Extracted from Serializer.ts as a standalone module.
4
+ */
5
+ import type { ObjectReference, SerializedGraph, SerializedNode } from "./types";
6
+ /** Default keys to block for prototype pollution protection */
7
+ export declare const DEFAULT_UNSAFE_KEYS: Set<string>;
8
+ /**
9
+ * Check if a key is unsafe (can lead to prototype pollution).
10
+ */
11
+ export declare const isUnsafeKey: (key: string, unsafeKeys?: ReadonlySet<string>) => boolean;
12
+ /**
13
+ * Check if a value is an object reference (has __ref property).
14
+ */
15
+ export declare const isObjectReference: (value: unknown) => value is ObjectReference;
16
+ /**
17
+ * Check if a value is a serialized graph payload.
18
+ */
19
+ export declare const isGraphPayload: (value: unknown) => value is SerializedGraph;
20
+ /**
21
+ * Check if a value is a serialized type record ({ __type, value }).
22
+ */
23
+ export declare const isSerializedTypeRecord: (value: unknown) => value is {
24
+ __type: string;
25
+ value: unknown;
26
+ };
27
+ /**
28
+ * Convert nodes object to a safe record with null prototype.
29
+ */
30
+ export declare const toNodeRecord: (nodes: Record<string, SerializedNode>, unsafeKeys?: ReadonlySet<string>) => Record<string, SerializedNode>;
31
+ /**
32
+ * Assert that recursion depth is within limits.
33
+ */
34
+ export declare const assertDepth: (depth: number, maxDepth: number) => void;
@@ -0,0 +1,19 @@
1
+ import { IResource, IResourceWithConfig, ITaskMiddleware, IResourceMiddleware, ITask, RegisterableItems, DependencyMapType } from "./defs";
2
+ import { EventManager, Logger, Store, TaskRunner } from "./models";
3
+ export interface TestFacade {
4
+ runTask: <I, O extends Promise<any>, D extends DependencyMapType>(task: ITask<I, O, D>, ...args: I extends undefined ? [] : [I]) => Promise<Awaited<O> | undefined>;
5
+ getResource: (id: string) => unknown;
6
+ taskRunner: TaskRunner;
7
+ store: Store;
8
+ logger: Logger;
9
+ eventManager: EventManager;
10
+ }
11
+ /**
12
+ * Helper to create a minimal test harness resource that wraps a root app (or any registerable)
13
+ * and exposes convenient testing utilities while running the full ecosystem
14
+ * (registration, overrides, middleware, events) without modifying the core API.
15
+ * @deprecated Use `run` instead with your testResource, as it provides the necessary toolkit.
16
+ */
17
+ export declare function createTestResource(root: RegisterableItems, options?: {
18
+ overrides?: Array<IResource | ITask | ITaskMiddleware | IResourceMiddleware | IResourceWithConfig>;
19
+ }): IResource<void, Promise<TestFacade>>;
@@ -0,0 +1,9 @@
1
+ import { RunnerMode } from "../types/runner";
2
+ /**
3
+ * Detects the runner mode based on environment variables.
4
+ * If no mode is explicitly provided, it will auto-detect from NODE_ENV.
5
+ *
6
+ * @param explicitMode - Optional mode to use if provided (takes precedence over environment)
7
+ * @returns The detected runner mode
8
+ */
9
+ export declare function detectRunnerMode(explicitMode?: RunnerMode): RunnerMode;
@@ -0,0 +1 @@
1
+ export declare function getCallerFile(): string;
@@ -0,0 +1,7 @@
1
+ import type { ThrowsList } from "../types/error";
2
+ type ThrowOwner = {
3
+ kind: "task" | "resource";
4
+ id: string;
5
+ };
6
+ export declare function normalizeThrows(owner: ThrowOwner, throwsList: ThrowsList | undefined): readonly string[] | undefined;
7
+ export {};
@@ -0,0 +1,24 @@
1
+ import type { Readable } from "stream";
2
+ import type { InputFileMeta } from "../types/inputFile";
3
+ export interface NodeCollectedFile {
4
+ id: string;
5
+ meta: InputFileMeta;
6
+ source: {
7
+ type: "buffer";
8
+ buffer: Buffer;
9
+ } | {
10
+ type: "stream";
11
+ stream: Readable;
12
+ };
13
+ }
14
+ export interface WebCollectedFile {
15
+ id: string;
16
+ meta: InputFileMeta;
17
+ blob: Blob;
18
+ }
19
+ export interface BuiltUniversalManifest<T = unknown> {
20
+ input: T;
21
+ nodeFiles: NodeCollectedFile[];
22
+ webFiles: WebCollectedFile[];
23
+ }
24
+ export declare function buildUniversalManifest<T = unknown>(input: T): BuiltUniversalManifest<T>;
@@ -0,0 +1,41 @@
1
+ import { symbolAsyncContext, symbolFilePath } from "./symbols";
2
+ import { ITaskMiddlewareConfigured } from "./taskMiddleware";
3
+ import type { IValidationSchema, IOptionalDependency } from "./utilities";
4
+ import type { IAsyncContextMeta } from "./meta";
5
+ export interface IAsyncContextDefinition<T> {
6
+ id: string;
7
+ serialize?(data: T): string;
8
+ parse?(data: string): T;
9
+ /**
10
+ * When provided, context values will be validated when provide() is called.
11
+ */
12
+ configSchema?: IValidationSchema<T>;
13
+ meta?: IAsyncContextMeta;
14
+ }
15
+ /**
16
+ * The generic AsyncContext object returned by `defineAsyncContext`.
17
+ */
18
+ export interface IAsyncContext<T> {
19
+ /** unique symbol used as key in the AsyncLocalStorage map */
20
+ readonly id: string;
21
+ /** Brand marker for registration and runtime checks */
22
+ [symbolAsyncContext]: true;
23
+ /** Retrieve the current context value or throw */
24
+ use(): T;
25
+ /**
26
+ * Provide a value for this context during the lifetime of `fn()`
27
+ */
28
+ provide<R>(value: T, fn: () => Promise<R> | R): Promise<R> | R;
29
+ /**
30
+ * Generates a middleware that guarantees the context exists.
31
+ */
32
+ require(): ITaskMiddlewareConfigured<{
33
+ context: IAsyncContext<T>;
34
+ }>;
35
+ serialize(data: T): string;
36
+ parse(data: string): T;
37
+ /** Return an optional dependency wrapper for this context */
38
+ optional(): IOptionalDependency<IAsyncContext<T>>;
39
+ /** File path where this async context was defined */
40
+ [symbolFilePath]: string;
41
+ }
@@ -0,0 +1,62 @@
1
+ import { TagType } from "./tag";
2
+ import type { UnionToIntersection } from "./utilities";
3
+ export declare const CONTRACT: unique symbol;
4
+ export type CONTRACT = typeof CONTRACT;
5
+ export interface IContractable<TConfig = any, TInput = void, TOutput = void> {
6
+ readonly __containsContract: true;
7
+ readonly [CONTRACT]: {
8
+ config: TConfig;
9
+ input: TInput;
10
+ output: TOutput;
11
+ };
12
+ }
13
+ export type NonVoid<T> = [T] extends [void] ? never : T;
14
+ export type IsTuple<T extends readonly unknown[]> = number extends T["length"] ? false : true;
15
+ export type Simplify<T> = {
16
+ [K in keyof T]: T[K];
17
+ } & {};
18
+ export type IsUnknown<T> = unknown extends T ? [T] extends [unknown] ? true : false : false;
19
+ export type UnknownToNever<T> = IsUnknown<T> extends true ? never : T;
20
+ export type ExtractContractOf<T, Kind extends "input" | "output"> = T extends IContractable<any, infer I, infer O> ? UnknownToNever<Kind extends "input" ? NonVoid<I> : NonVoid<O>> : never;
21
+ export type FilterContractsKind<TItems extends readonly unknown[], Kind extends "input" | "output", Acc extends readonly unknown[] = []> = TItems extends readonly [infer H, ...infer R] ? ExtractContractOf<H, Kind> extends never ? FilterContractsKind<R, Kind, Acc> : FilterContractsKind<R, Kind, [...Acc, ExtractContractOf<H, Kind>]> : Acc;
22
+ export type ExtractContractsFromCollection<TItems extends readonly unknown[], Kind extends "input" | "output"> = IsTuple<TItems> extends true ? FilterContractsKind<TItems, Kind> : Array<ExtractContractOf<TItems[number], Kind>>;
23
+ export type ExtractInputTypeFromContracts<TItems extends readonly unknown[]> = ExtractContractsFromCollection<TItems, "input">;
24
+ export type ExtractOutputTypeFromContracts<TItems extends readonly unknown[]> = ExtractContractsFromCollection<TItems, "output">;
25
+ export type ContractsUnionInputs<TItems extends readonly unknown[]> = ExtractInputTypeFromContracts<TItems> extends readonly (infer U)[] ? U : never;
26
+ export type ContractsUnionOutputs<TItems extends readonly unknown[]> = ExtractOutputTypeFromContracts<TItems> extends readonly (infer U)[] ? U : never;
27
+ export type ContractsIntersectionInputs<TItems extends readonly unknown[]> = UnionToIntersection<ContractsUnionInputs<TItems>>;
28
+ export type ContractsIntersectionOutputs<TItems extends readonly unknown[]> = UnionToIntersection<ContractsUnionOutputs<TItems>>;
29
+ export type HasInputContracts<TItems extends readonly unknown[]> = [
30
+ ContractsUnionInputs<TItems>
31
+ ] extends [never] ? false : true;
32
+ export type HasOutputContracts<TItems extends readonly unknown[]> = [
33
+ ContractsUnionOutputs<TItems>
34
+ ] extends [never] ? false : true;
35
+ export type IsNever<T> = [T] extends [never] ? true : false;
36
+ export type KeysWithNever<T> = T extends object ? {
37
+ [K in keyof T]-?: [T[K]] extends [never] ? K : never;
38
+ }[keyof T] : never;
39
+ export type HasNeverProperty<T> = KeysWithNever<T> extends never ? false : true;
40
+ export type IsImpossibleIntersection<T> = IsNever<T> extends true ? true : HasNeverProperty<T> extends true ? true : false;
41
+ export type InputContractViolationError<TItems extends readonly unknown[], TActual> = {
42
+ message: "Value does not satisfy all input contracts";
43
+ expected: Simplify<ContractsIntersectionInputs<TItems>>;
44
+ received: TActual;
45
+ };
46
+ export type OutputContractViolationError<TItems extends readonly unknown[], TActual> = {
47
+ message: "Value does not satisfy all output contracts";
48
+ expected: Simplify<ContractsIntersectionOutputs<TItems>>;
49
+ received: TActual;
50
+ };
51
+ export type EnsureInputSatisfiesContracts<TItems extends readonly unknown[], TValue> = [ContractsUnionInputs<TItems>] extends [never] ? TValue : TValue extends Promise<infer U> ? Promise<U extends ContractsIntersectionInputs<TItems> ? U : InputContractViolationError<TItems, U>> : TValue extends ContractsIntersectionInputs<TItems> ? TValue : InputContractViolationError<TItems, TValue>;
52
+ export type EnsureOutputSatisfiesContracts<TItems extends readonly unknown[], TResponse> = [ContractsUnionOutputs<TItems>] extends [never] ? TResponse : TResponse extends Promise<infer U> ? Promise<U extends ContractsIntersectionOutputs<TItems> ? U : OutputContractViolationError<TItems, U>> : TResponse extends ContractsIntersectionOutputs<TItems> ? TResponse : OutputContractViolationError<TItems, TResponse>;
53
+ export type InferInputOrViolationFromContracts<TItems extends readonly unknown[]> = HasInputContracts<TItems> extends false ? void : ContractsIntersectionInputs<TItems> extends infer I ? IsImpossibleIntersection<I> extends true ? InputContractViolationError<TItems, Simplify<I extends never ? never : I>> : Simplify<I> : never;
54
+ export type InputArg<TItems extends readonly unknown[]> = [
55
+ InferInputOrViolationFromContracts<TItems>
56
+ ] extends [void] ? [] : [InferInputOrViolationFromContracts<TItems>];
57
+ export type InputCollisionGuard<TItems extends readonly unknown[]> = IsImpossibleIntersection<ContractsIntersectionInputs<TItems>> extends true ? InputContractViolationError<TItems, Simplify<ContractsIntersectionInputs<TItems>>> : unknown;
58
+ export type InferOutputOrViolationFromContracts<TItems extends readonly unknown[]> = HasOutputContracts<TItems> extends false ? unknown : ContractsIntersectionOutputs<TItems> extends infer O ? IsImpossibleIntersection<O> extends true ? OutputContractViolationError<TItems, Simplify<O extends never ? never : O>> : Simplify<O> : never;
59
+ /** @deprecated Use ExtractOutputTypeFromContracts instead */
60
+ export type ExtractTagsWithNonVoidReturnTypeFromTags<TTags extends TagType[]> = ExtractOutputTypeFromContracts<TTags>;
61
+ /** @deprecated Use EnsureOutputSatisfiesContracts instead */
62
+ export type EnsureResponseSatisfiesContracts<TTags extends TagType[], TResponse> = EnsureOutputSatisfiesContracts<TTags, TResponse>;
@@ -0,0 +1,39 @@
1
+ import { symbolError, symbolFilePath } from "./symbols";
2
+ import type { IOptionalDependency } from "./utilities";
3
+ import type { IValidationSchema } from "./utilities";
4
+ import type { IErrorMeta } from "./meta";
5
+ export type ErrorReference = string | IErrorHelper<any>;
6
+ export type ThrowsList = ReadonlyArray<ErrorReference>;
7
+ export interface IErrorDefinition<TData extends DefaultErrorType = DefaultErrorType> {
8
+ id: string;
9
+ serialize?: (data: TData) => string;
10
+ parse?: (data: string) => TData;
11
+ format?: (data: TData) => string;
12
+ /**
13
+ * Validate error data on throw(). If provided, data is parsed first.
14
+ */
15
+ dataSchema?: IValidationSchema<TData>;
16
+ meta?: IErrorMeta;
17
+ }
18
+ export interface IErrorDefinitionFinal<TData extends DefaultErrorType> extends IErrorDefinition<TData> {
19
+ format: (data: TData) => string;
20
+ }
21
+ export type DefaultErrorType = Record<string, unknown>;
22
+ /**
23
+ * Runtime helper returned by defineError()/r.error().
24
+ * Contains helpers to throw typed errors and perform type-safe checks.
25
+ */
26
+ export interface IErrorHelper<TData extends DefaultErrorType = DefaultErrorType> {
27
+ /** Unique id for registration and DI */
28
+ id: string;
29
+ /** Throw a typed error with the given data */
30
+ throw(data: TData): never;
31
+ /** Type guard for checking if an unknown error is this error */
32
+ is(error: unknown): boolean;
33
+ /** Brand symbol for runtime detection */
34
+ [symbolError]: true;
35
+ /** Return an optional dependency wrapper for this error */
36
+ optional(): IOptionalDependency<IErrorHelper<TData>>;
37
+ /** File path where this error was defined */
38
+ [symbolFilePath]: string;
39
+ }
@@ -0,0 +1,79 @@
1
+ import { IOptionalDependency, IValidationSchema } from "./utilities";
2
+ import { TagType } from "./tag";
3
+ import { IEventMeta } from "./meta";
4
+ import { CommonPayload, symbolEvent, symbolFilePath } from "./utilities";
5
+ export type EventHandlerType<T = any> = (event: IEventEmission<T>) => any | Promise<any>;
6
+ export declare function onAnyOf<T extends readonly IEventDefinition<any>[]>(...defs: T): T;
7
+ /**
8
+ * Runtime guard that checks if an emission belongs to one of the given event defs.
9
+ * Narrows payload type to the intersection of the provided events' payloads.
10
+ */
11
+ export declare function isOneOf<TDefs extends readonly IEventDefinition<any>[]>(emission: IEventEmission<any>, defs: TDefs): emission is IEventEmission<CommonPayload<TDefs>>;
12
+ export interface IEventDefinition<TPayload = void> {
13
+ id: string;
14
+ meta?: IEventMeta;
15
+ /**
16
+ * Optional validation schema for runtime payload validation.
17
+ * When provided, event payload will be validated when emitted.
18
+ */
19
+ payloadSchema?: IValidationSchema<TPayload>;
20
+ tags?: TagType[];
21
+ /**
22
+ * If true, listeners with the same priority run concurrently within a batch.
23
+ * Batches (grouped by order) still execute sequentially in priority order.
24
+ */
25
+ parallel?: boolean;
26
+ }
27
+ /**
28
+ * The definioten of the event.
29
+ * This is different from the event emission.
30
+ */
31
+ export interface IEvent<TPayload = any> extends IEventDefinition<TPayload> {
32
+ id: string;
33
+ /**
34
+ * We use this event to discriminate between resources with just 'id' and 'events' as they collide. This is a workaround, should be redone using classes and instanceof.
35
+ */
36
+ [symbolEvent]: true;
37
+ [symbolFilePath]: string;
38
+ /** Return an optional dependency wrapper for this event. */
39
+ optional: () => IOptionalDependency<IEvent<TPayload>>;
40
+ tags: TagType[];
41
+ }
42
+ /**
43
+ * This represents the object that is passed to event handlers
44
+ */
45
+ export interface IEventEmission<TPayload = any> {
46
+ /**
47
+ * The ID of the event. This is the same as the event's ID.
48
+ * This is useful for global event listeners.
49
+ */
50
+ id: string;
51
+ /**
52
+ * The data that the event carries. It can be anything.
53
+ */
54
+ data: TPayload;
55
+ /**
56
+ * The timestamp when the event was created.
57
+ */
58
+ timestamp: Date;
59
+ /**
60
+ * The source of the event. This can be useful for debugging.
61
+ */
62
+ source: string;
63
+ /**
64
+ * Metadata associated with the event definition.
65
+ */
66
+ meta: IEventMeta;
67
+ /**
68
+ * Stops propagation to remaining event listeners.
69
+ */
70
+ stopPropagation(): void;
71
+ /**
72
+ * Returns true if propagation has been stopped.
73
+ */
74
+ isPropagationStopped(): boolean;
75
+ /**
76
+ * The tags that the event carries.
77
+ */
78
+ tags: TagType[];
79
+ }
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Typed key used to store/retrieve values from an ExecutionJournal.
3
+ * The `id` is used as the storage slot.
4
+ */
5
+ declare const journalKeyBrand: unique symbol;
6
+ export type JournalKey<T> = {
7
+ readonly id: string;
8
+ readonly [journalKeyBrand]?: (value: T) => T;
9
+ };
10
+ /**
11
+ * Options for setting values in the journal.
12
+ */
13
+ export interface JournalSetOptions {
14
+ /**
15
+ * If true, allows overwriting an existing value.
16
+ * By default, attempting to set a key that already exists will throw an error.
17
+ */
18
+ override?: boolean;
19
+ }
20
+ /**
21
+ * Per-execution registry that allows middleware and tasks to share state.
22
+ * A new journal is created for each top-level task execution unless explicitly forwarded.
23
+ */
24
+ export interface ExecutionJournal {
25
+ set<T>(key: JournalKey<T>, value: T, options?: JournalSetOptions): void;
26
+ get<T>(key: JournalKey<T>): T | undefined;
27
+ has<T>(key: JournalKey<T>): boolean;
28
+ }
29
+ export {};
@@ -0,0 +1,23 @@
1
+ import { DependencyMapType, DependencyValuesType, ExtractEventPayload } from "./utilities";
2
+ import { IEventDefinition, IEventEmission } from "./event";
3
+ import { TagType } from "./tag";
4
+ import { ITaskMeta } from "./meta";
5
+ import { CommonPayload, symbolFilePath, symbolHook } from "./utilities";
6
+ export type OnType = "*" | IEventDefinition<any> | readonly IEventDefinition<any>[];
7
+ export interface IHookDefinition<TDependencies extends DependencyMapType = {}, TOn extends OnType = any, TMeta extends ITaskMeta = any> {
8
+ id: string;
9
+ dependencies?: TDependencies | (() => TDependencies);
10
+ on: TOn;
11
+ /** Listener execution order. Lower numbers run first. */
12
+ order?: number;
13
+ meta?: TMeta;
14
+ run: (event: IEventEmission<TOn extends "*" ? any : TOn extends readonly IEventDefinition<any>[] ? CommonPayload<TOn> : ExtractEventPayload<TOn>>, dependencies: DependencyValuesType<TDependencies>) => Promise<any>;
15
+ tags?: TagType[];
16
+ }
17
+ export interface IHook<TDependencies extends DependencyMapType = {}, TOn extends OnType = any, TMeta extends ITaskMeta = any> extends IHookDefinition<TDependencies, TOn, TMeta> {
18
+ id: string;
19
+ dependencies: TDependencies | (() => TDependencies);
20
+ [symbolFilePath]: string;
21
+ [symbolHook]: true;
22
+ tags: TagType[];
23
+ }