@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.
- package/README.md +25 -15
- package/dist/browser/index.cjs +851 -478
- package/dist/browser/index.cjs.map +1 -1
- package/dist/browser/index.mjs +849 -478
- package/dist/browser/index.mjs.map +1 -1
- package/dist/edge/index.cjs +851 -478
- package/dist/edge/index.cjs.map +1 -1
- package/dist/edge/index.mjs +849 -478
- package/dist/edge/index.mjs.map +1 -1
- package/dist/node/node.cjs +1305 -583
- package/dist/node/node.cjs.map +1 -1
- package/dist/node/node.mjs +1299 -583
- package/dist/node/node.mjs.map +1 -1
- package/dist/types/define.d.ts +9 -0
- package/dist/types/definers/builders/asyncContext/fluent-builder.d.ts +6 -0
- package/dist/types/definers/builders/asyncContext/fluent-builder.interface.d.ts +9 -0
- package/dist/types/definers/builders/asyncContext/index.d.ts +10 -0
- package/dist/types/definers/builders/asyncContext/types.d.ts +13 -0
- package/dist/types/definers/builders/asyncContext/utils.d.ts +5 -0
- package/dist/types/definers/builders/asyncContext.d.ts +1 -0
- package/dist/types/definers/builders/core.d.ts +30 -0
- package/dist/types/definers/builders/error/fluent-builder.d.ts +7 -0
- package/dist/types/definers/builders/error/fluent-builder.interface.d.ts +10 -0
- package/dist/types/definers/builders/error/index.d.ts +11 -0
- package/dist/types/definers/builders/error/types.d.ts +14 -0
- package/dist/types/definers/builders/error/utils.d.ts +6 -0
- package/dist/types/definers/builders/error.d.ts +1 -0
- package/dist/types/definers/builders/event/fluent-builder.d.ts +7 -0
- package/dist/types/definers/builders/event/fluent-builder.interface.d.ts +18 -0
- package/dist/types/definers/builders/event/index.d.ts +10 -0
- package/dist/types/definers/builders/event/types.d.ts +8 -0
- package/dist/types/definers/builders/event/utils.d.ts +9 -0
- package/dist/types/definers/builders/event.d.ts +1 -0
- package/dist/types/definers/builders/hook/fluent-builder.d.ts +8 -0
- package/dist/types/definers/builders/hook/fluent-builder.interface.d.ts +27 -0
- package/dist/types/definers/builders/hook/index.d.ts +12 -0
- package/dist/types/definers/builders/hook/types.d.ts +14 -0
- package/dist/types/definers/builders/hook/utils.d.ts +14 -0
- package/dist/types/definers/builders/hook.d.ts +1 -0
- package/dist/types/definers/builders/middleware/index.d.ts +19 -0
- package/dist/types/definers/builders/middleware/resource.d.ts +7 -0
- package/dist/types/definers/builders/middleware/resource.interface.d.ts +18 -0
- package/dist/types/definers/builders/middleware/task.d.ts +7 -0
- package/dist/types/definers/builders/middleware/task.interface.d.ts +18 -0
- package/dist/types/definers/builders/middleware/types.d.ts +13 -0
- package/dist/types/definers/builders/middleware/utils.d.ts +18 -0
- package/dist/types/definers/builders/middleware.d.ts +1 -0
- package/dist/types/definers/builders/override/hook.d.ts +16 -0
- package/dist/types/definers/builders/override/index.d.ts +11 -0
- package/dist/types/definers/builders/override/resource-middleware.d.ts +3 -0
- package/dist/types/definers/builders/override/resource.d.ts +3 -0
- package/dist/types/definers/builders/override/task-middleware.d.ts +3 -0
- package/dist/types/definers/builders/override/task.d.ts +3 -0
- package/dist/types/definers/builders/resource/fluent-builder.d.ts +8 -0
- package/dist/types/definers/builders/resource/fluent-builder.interface.d.ts +42 -0
- package/dist/types/definers/builders/resource/index.d.ts +13 -0
- package/dist/types/definers/builders/resource/types.d.ts +37 -0
- package/dist/types/definers/builders/resource/utils.d.ts +26 -0
- package/dist/types/definers/builders/resource.d.ts +1 -0
- package/dist/types/definers/builders/tag/fluent-builder.d.ts +6 -0
- package/dist/types/definers/builders/tag/fluent-builder.interface.d.ts +8 -0
- package/dist/types/definers/builders/tag/index.d.ts +10 -0
- package/dist/types/definers/builders/tag/types.d.ts +12 -0
- package/dist/types/definers/builders/tag/utils.d.ts +5 -0
- package/dist/types/definers/builders/tag.d.ts +1 -0
- package/dist/types/definers/builders/task/fluent-builder.d.ts +8 -0
- package/dist/types/definers/builders/task/fluent-builder.interface.d.ts +33 -0
- package/dist/types/definers/builders/task/index.d.ts +21 -0
- package/dist/types/definers/builders/task/phantom-builder.d.ts +8 -0
- package/dist/types/definers/builders/task/phantom-builder.interface.d.ts +31 -0
- package/dist/types/definers/builders/task/types.d.ts +34 -0
- package/dist/types/definers/builders/task/utils.d.ts +14 -0
- package/dist/types/definers/builders/task.d.ts +1 -0
- package/dist/types/definers/builders/task.phantom.d.ts +1 -0
- package/dist/types/definers/builders/utils.d.ts +4 -0
- package/dist/types/definers/defineAsyncContext.d.ts +15 -0
- package/dist/types/definers/defineError.d.ts +27 -0
- package/dist/types/definers/defineEvent.d.ts +2 -0
- package/dist/types/definers/defineHook.d.ts +6 -0
- package/dist/types/definers/defineOverride.d.ts +12 -0
- package/dist/types/definers/defineResource.d.ts +2 -0
- package/dist/types/definers/defineResourceMiddleware.d.ts +2 -0
- package/dist/types/definers/defineTag.d.ts +12 -0
- package/dist/types/definers/defineTask.d.ts +18 -0
- package/dist/types/definers/defineTaskMiddleware.d.ts +2 -0
- package/dist/types/definers/middlewareConfig.d.ts +1 -0
- package/dist/types/definers/resourceFork.d.ts +13 -0
- package/dist/types/definers/tools.d.ts +53 -0
- package/dist/types/defs.d.ts +33 -0
- package/dist/types/errors.d.ts +75 -0
- package/dist/types/globals/debug.d.ts +10 -0
- package/dist/types/globals/globalEvents.d.ts +8 -0
- package/dist/types/globals/globalMiddleware.d.ts +97 -0
- package/dist/types/globals/globalResources.d.ts +64 -0
- package/dist/types/globals/globalTags.d.ts +12 -0
- package/dist/types/globals/middleware/cache.middleware.d.ts +36 -0
- package/dist/types/globals/middleware/circuitBreaker.middleware.d.ts +56 -0
- package/dist/types/globals/middleware/concurrency.middleware.d.ts +47 -0
- package/dist/types/globals/middleware/fallback.middleware.d.ts +23 -0
- package/dist/types/globals/middleware/rateLimit.middleware.d.ts +47 -0
- package/dist/types/globals/middleware/requireContext.middleware.d.ts +5 -0
- package/dist/types/globals/middleware/retry.middleware.d.ts +31 -0
- package/dist/types/globals/middleware/temporal.middleware.d.ts +48 -0
- package/dist/types/globals/middleware/timeout.middleware.d.ts +24 -0
- package/dist/types/globals/middleware/tunnel.middleware.d.ts +3 -0
- package/dist/types/globals/resources/debug/debug.resource.d.ts +7 -0
- package/dist/types/globals/resources/debug/debug.tag.d.ts +2 -0
- package/dist/types/globals/resources/debug/debugConfig.resource.d.ts +22 -0
- package/dist/types/globals/resources/debug/executionTracker.middleware.d.ts +50 -0
- package/dist/types/globals/resources/debug/globalEvent.hook.d.ts +27 -0
- package/dist/types/globals/resources/debug/hook.hook.d.ts +30 -0
- package/dist/types/globals/resources/debug/index.d.ts +6 -0
- package/dist/types/globals/resources/debug/middleware.hook.d.ts +30 -0
- package/dist/types/globals/resources/debug/types.d.ts +25 -0
- package/dist/types/globals/resources/debug/utils.d.ts +2 -0
- package/dist/types/globals/resources/httpClientFactory.resource.d.ts +28 -0
- package/dist/types/globals/resources/queue.resource.d.ts +10 -0
- package/dist/types/globals/resources/tunnel/error-utils.d.ts +1 -0
- package/dist/types/globals/resources/tunnel/plan.d.ts +19 -0
- package/dist/types/globals/resources/tunnel/protocol.d.ts +48 -0
- package/dist/types/globals/resources/tunnel/tunnel.policy.tag.d.ts +26 -0
- package/dist/types/globals/resources/tunnel/tunnel.tag.d.ts +2 -0
- package/dist/types/globals/resources/tunnel/types.d.ts +48 -0
- package/dist/types/globals/tunnels/index.d.ts +23 -0
- package/dist/types/globals/types.d.ts +15 -0
- package/dist/types/http-client.d.ts +26 -0
- package/dist/types/http-fetch-tunnel.resource.d.ts +11 -0
- package/dist/types/index.d.ts +44 -0
- package/dist/types/models/DependencyProcessor.d.ts +46 -0
- package/dist/types/models/EventManager.d.ts +115 -0
- package/dist/types/models/ExecutionJournal.d.ts +35 -0
- package/dist/types/models/LogPrinter.d.ts +56 -0
- package/dist/types/models/Logger.d.ts +85 -0
- package/dist/types/models/MiddlewareManager.d.ts +73 -0
- package/dist/types/models/OverrideManager.d.ts +13 -0
- package/dist/types/models/Queue.d.ts +40 -0
- package/dist/types/models/ResourceInitializer.d.ts +20 -0
- package/dist/types/models/RunResult.d.ts +41 -0
- package/dist/types/models/Semaphore.d.ts +80 -0
- package/dist/types/models/Store.d.ts +76 -0
- package/dist/types/models/StoreRegistry.d.ts +49 -0
- package/dist/types/models/StoreValidator.d.ts +8 -0
- package/dist/types/models/TaskRunner.d.ts +28 -0
- package/dist/types/models/UnhandledError.d.ts +11 -0
- package/dist/types/models/event/CycleContext.d.ts +9 -0
- package/dist/types/models/event/EmissionExecutor.d.ts +11 -0
- package/dist/types/models/event/InterceptorPipeline.d.ts +5 -0
- package/dist/types/models/event/ListenerRegistry.d.ts +31 -0
- package/dist/types/models/event/types.d.ts +50 -0
- package/dist/types/models/index.d.ts +13 -0
- package/dist/types/models/middleware/InterceptorRegistry.d.ts +56 -0
- package/dist/types/models/middleware/MiddlewareResolver.d.ts +31 -0
- package/dist/types/models/middleware/ResourceMiddlewareComposer.d.ts +34 -0
- package/dist/types/models/middleware/TaskMiddlewareComposer.d.ts +44 -0
- package/dist/types/models/middleware/ValidationHelper.d.ts +20 -0
- package/dist/types/models/middleware/index.d.ts +6 -0
- package/dist/types/models/middleware/types.d.ts +10 -0
- package/dist/types/models/utils/findCircularDependencies.d.ts +16 -0
- package/dist/types/models/utils/safeStringify.d.ts +3 -0
- package/dist/types/node/durable/bus/MemoryEventBus.d.ts +7 -0
- package/dist/types/node/durable/bus/NoopEventBus.d.ts +6 -0
- package/dist/types/node/durable/bus/RedisEventBus.d.ts +30 -0
- package/dist/types/node/durable/core/CronParser.d.ts +15 -0
- package/dist/types/node/durable/core/DurableContext.d.ts +64 -0
- package/dist/types/node/durable/core/DurableOperator.d.ts +47 -0
- package/dist/types/node/durable/core/DurableResource.d.ts +80 -0
- package/dist/types/node/durable/core/DurableService.d.ts +73 -0
- package/dist/types/node/durable/core/DurableWorker.d.ts +19 -0
- package/dist/types/node/durable/core/StepBuilder.d.ts +23 -0
- package/dist/types/node/durable/core/audit.d.ts +152 -0
- package/dist/types/node/durable/core/createRunnerDurableRuntime.d.ts +18 -0
- package/dist/types/node/durable/core/durable-context/DurableContext.audit.d.ts +14 -0
- package/dist/types/node/durable/core/durable-context/DurableContext.determinism.d.ts +13 -0
- package/dist/types/node/durable/core/durable-context/DurableContext.emit.d.ts +16 -0
- package/dist/types/node/durable/core/durable-context/DurableContext.sleep.d.ts +16 -0
- package/dist/types/node/durable/core/durable-context/DurableContext.steps.d.ts +25 -0
- package/dist/types/node/durable/core/durable-context/DurableContext.switch.d.ts +22 -0
- package/dist/types/node/durable/core/durable-context/DurableContext.waitForSignal.d.ts +23 -0
- package/dist/types/node/durable/core/flowShape.d.ts +50 -0
- package/dist/types/node/durable/core/ids.d.ts +11 -0
- package/dist/types/node/durable/core/index.d.ts +11 -0
- package/dist/types/node/durable/core/interfaces/bus.d.ts +13 -0
- package/dist/types/node/durable/core/interfaces/context.d.ts +105 -0
- package/dist/types/node/durable/core/interfaces/queue.d.ts +17 -0
- package/dist/types/node/durable/core/interfaces/service.d.ts +146 -0
- package/dist/types/node/durable/core/interfaces/store.d.ts +66 -0
- package/dist/types/node/durable/core/managers/AuditLogger.d.ts +29 -0
- package/dist/types/node/durable/core/managers/ExecutionManager.d.ts +48 -0
- package/dist/types/node/durable/core/managers/PollingManager.d.ts +48 -0
- package/dist/types/node/durable/core/managers/ScheduleManager.d.ts +33 -0
- package/dist/types/node/durable/core/managers/SignalHandler.d.ts +25 -0
- package/dist/types/node/durable/core/managers/TaskRegistry.d.ts +16 -0
- package/dist/types/node/durable/core/managers/WaitManager.d.ts +26 -0
- package/dist/types/node/durable/core/managers/index.d.ts +7 -0
- package/dist/types/node/durable/core/resource.d.ts +14 -0
- package/dist/types/node/durable/core/types.d.ts +84 -0
- package/dist/types/node/durable/core/utils.d.ts +28 -0
- package/dist/types/node/durable/dashboard/server.d.ts +20 -0
- package/dist/types/node/durable/emitters/runnerAuditEmitter.d.ts +6 -0
- package/dist/types/node/durable/events.d.ts +76 -0
- package/dist/types/node/durable/index.d.ts +34 -0
- package/dist/types/node/durable/optionalDeps/amqplib.d.ts +1 -0
- package/dist/types/node/durable/optionalDeps/ioredis.d.ts +1 -0
- package/dist/types/node/durable/queue/MemoryQueue.d.ts +12 -0
- package/dist/types/node/durable/queue/RabbitMQQueue.d.ts +30 -0
- package/dist/types/node/durable/resources/isolation.d.ts +15 -0
- package/dist/types/node/durable/resources/memoryDurableResource.d.ts +21 -0
- package/dist/types/node/durable/resources/redisDurableResource.d.ts +35 -0
- package/dist/types/node/durable/store/MemoryStore.d.ts +56 -0
- package/dist/types/node/durable/store/RedisStore.d.ts +89 -0
- package/dist/types/node/durable/test-utils.d.ts +29 -0
- package/dist/types/node/exposure/allowList.d.ts +3 -0
- package/dist/types/node/exposure/authenticator.d.ts +16 -0
- package/dist/types/node/exposure/cors.d.ts +4 -0
- package/dist/types/node/exposure/createNodeExposure.d.ts +2 -0
- package/dist/types/node/exposure/exposureServer.d.ts +18 -0
- package/dist/types/node/exposure/handlers/contextWrapper.d.ts +18 -0
- package/dist/types/node/exposure/handlers/errorHandlers.d.ts +23 -0
- package/dist/types/node/exposure/handlers/eventHandler.d.ts +20 -0
- package/dist/types/node/exposure/handlers/taskHandler.d.ts +24 -0
- package/dist/types/node/exposure/httpResponse.d.ts +10 -0
- package/dist/types/node/exposure/index.d.ts +3 -0
- package/dist/types/node/exposure/logging.d.ts +4 -0
- package/dist/types/node/exposure/multipart.d.ts +36 -0
- package/dist/types/node/exposure/requestBody.d.ts +11 -0
- package/dist/types/node/exposure/requestContext.d.ts +17 -0
- package/dist/types/node/exposure/requestHandlers.d.ts +29 -0
- package/dist/types/node/exposure/resource.d.ts +12 -0
- package/dist/types/node/exposure/resourceTypes.d.ts +73 -0
- package/dist/types/node/exposure/router.d.ts +17 -0
- package/dist/types/node/exposure/serverLifecycle.d.ts +13 -0
- package/dist/types/node/exposure/types.d.ts +45 -0
- package/dist/types/node/exposure/utils.d.ts +17 -0
- package/dist/types/node/files/createNodeFile.d.ts +9 -0
- package/dist/types/node/files/index.d.ts +4 -0
- package/dist/types/node/files/inputFile.model.d.ts +22 -0
- package/dist/types/node/files/inputFile.utils.d.ts +14 -0
- package/dist/types/node/http/http-mixed-client.d.ts +45 -0
- package/dist/types/node/http/http-mixed-client.factory.resource.d.ts +17 -0
- package/dist/types/node/http/http-smart-client.factory.resource.d.ts +16 -0
- package/dist/types/node/http/http-smart-client.model.d.ts +27 -0
- package/dist/types/node/http/index.d.ts +4 -0
- package/dist/types/node/index.d.ts +1 -0
- package/dist/types/node/node.d.ts +193 -0
- package/dist/types/node/platform/createFile.d.ts +9 -0
- package/dist/types/node/tunnel/allowlist.d.ts +7 -0
- package/dist/types/node/tunnel/index.d.ts +2 -0
- package/dist/types/node/upload/manifest.d.ts +23 -0
- package/dist/types/platform/adapters/browser.d.ts +14 -0
- package/dist/types/platform/adapters/edge.d.ts +5 -0
- package/dist/types/platform/adapters/node-als.d.ts +1 -0
- package/dist/types/platform/adapters/node.d.ts +15 -0
- package/dist/types/platform/adapters/universal-generic.d.ts +14 -0
- package/dist/types/platform/adapters/universal.d.ts +18 -0
- package/dist/types/platform/createFile.d.ts +10 -0
- package/dist/types/platform/createWebFile.d.ts +11 -0
- package/dist/types/platform/factory.d.ts +2 -0
- package/dist/types/platform/index.d.ts +27 -0
- package/dist/types/platform/types.d.ts +31 -0
- package/dist/types/processHooks.d.ts +2 -0
- package/dist/types/public-types.d.ts +13 -0
- package/dist/types/public.d.ts +210 -0
- package/dist/types/run.d.ts +14 -0
- package/dist/types/serializer/Serializer.d.ts +84 -0
- package/dist/types/serializer/binary-builtins.d.ts +5 -0
- package/dist/types/serializer/builtins.d.ts +47 -0
- package/dist/types/serializer/deserializer.d.ts +27 -0
- package/dist/types/serializer/error-url-builtins.d.ts +13 -0
- package/dist/types/serializer/graph-serializer.d.ts +27 -0
- package/dist/types/serializer/index.d.ts +6 -0
- package/dist/types/serializer/option-normalizers.d.ts +2 -0
- package/dist/types/serializer/regexp-validator.d.ts +34 -0
- package/dist/types/serializer/serialize-utils.d.ts +15 -0
- package/dist/types/serializer/special-values.d.ts +20 -0
- package/dist/types/serializer/tree-serializer.d.ts +20 -0
- package/dist/types/serializer/type-registry.d.ts +58 -0
- package/dist/types/serializer/types.d.ts +126 -0
- package/dist/types/serializer/validation.d.ts +34 -0
- package/dist/types/testing.d.ts +19 -0
- package/dist/types/tools/detectRunnerMode.d.ts +9 -0
- package/dist/types/tools/getCallerFile.d.ts +1 -0
- package/dist/types/tools/throws.d.ts +7 -0
- package/dist/types/tunnels/buildUniversalManifest.d.ts +24 -0
- package/dist/types/types/asyncContext.d.ts +41 -0
- package/dist/types/types/contracts.d.ts +62 -0
- package/dist/types/types/error.d.ts +39 -0
- package/dist/types/types/event.d.ts +79 -0
- package/dist/types/types/executionJournal.d.ts +29 -0
- package/dist/types/types/hook.d.ts +23 -0
- package/dist/types/types/inputFile.d.ts +34 -0
- package/dist/types/types/meta.d.ts +22 -0
- package/dist/types/types/resource.d.ts +133 -0
- package/dist/types/types/resourceMiddleware.d.ts +48 -0
- package/dist/types/types/runner.d.ts +68 -0
- package/dist/types/types/storeTypes.d.ts +46 -0
- package/dist/types/types/symbols.d.ts +34 -0
- package/dist/types/types/tag.d.ts +45 -0
- package/dist/types/types/task.d.ts +76 -0
- package/dist/types/types/taskMiddleware.d.ts +55 -0
- package/dist/types/types/utilities.d.ts +125 -0
- package/dist/universal/index.cjs +851 -476
- package/dist/universal/index.cjs.map +1 -1
- package/dist/universal/index.mjs +849 -476
- package/dist/universal/index.mjs.map +1 -1
- package/package.json +15 -14
- package/readmes/AI.md +30 -9
- package/dist/browser/index.d.mts +0 -2919
- package/dist/browser/index.d.ts +0 -2919
- package/dist/edge/index.d.mts +0 -2919
- package/dist/edge/index.d.ts +0 -2919
- package/dist/node/node.d.mts +0 -4622
- package/dist/node/node.d.ts +0 -4622
- package/dist/universal/index.d.mts +0 -2919
- package/dist/universal/index.d.ts +0 -2919
|
@@ -1,2919 +0,0 @@
|
|
|
1
|
-
import * as lru_cache from 'lru-cache';
|
|
2
|
-
|
|
3
|
-
declare const CONTRACT: unique symbol;
|
|
4
|
-
type CONTRACT = typeof CONTRACT;
|
|
5
|
-
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
|
-
type NonVoid<T> = [T] extends [void] ? never : T;
|
|
14
|
-
type IsTuple<T extends readonly unknown[]> = number extends T["length"] ? false : true;
|
|
15
|
-
type UnionToIntersection$1<U> = (U extends any ? (arg: U) => void : never) extends (arg: infer I) => void ? I : never;
|
|
16
|
-
type Simplify<T> = {
|
|
17
|
-
[K in keyof T]: T[K];
|
|
18
|
-
} & {};
|
|
19
|
-
type IsUnknown<T> = unknown extends T ? [T] extends [unknown] ? true : false : false;
|
|
20
|
-
type UnknownToNever<T> = IsUnknown<T> extends true ? never : T;
|
|
21
|
-
type ExtractContractOf<T, Kind extends "input" | "output"> = T extends IContractable<any, infer I, infer O> ? UnknownToNever<Kind extends "input" ? NonVoid<I> : NonVoid<O>> : never;
|
|
22
|
-
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;
|
|
23
|
-
type ExtractContractsFromCollection<TItems extends readonly unknown[], Kind extends "input" | "output"> = IsTuple<TItems> extends true ? FilterContractsKind<TItems, Kind> : Array<ExtractContractOf<TItems[number], Kind>>;
|
|
24
|
-
type ExtractInputTypeFromContracts<TItems extends readonly unknown[]> = ExtractContractsFromCollection<TItems, "input">;
|
|
25
|
-
type ExtractOutputTypeFromContracts<TItems extends readonly unknown[]> = ExtractContractsFromCollection<TItems, "output">;
|
|
26
|
-
type ContractsUnionInputs<TItems extends readonly unknown[]> = ExtractInputTypeFromContracts<TItems> extends readonly (infer U)[] ? U : never;
|
|
27
|
-
type ContractsUnionOutputs<TItems extends readonly unknown[]> = ExtractOutputTypeFromContracts<TItems> extends readonly (infer U)[] ? U : never;
|
|
28
|
-
type ContractsIntersectionInputs<TItems extends readonly unknown[]> = UnionToIntersection$1<ContractsUnionInputs<TItems>>;
|
|
29
|
-
type ContractsIntersectionOutputs<TItems extends readonly unknown[]> = UnionToIntersection$1<ContractsUnionOutputs<TItems>>;
|
|
30
|
-
type HasInputContracts<TItems extends readonly unknown[]> = [
|
|
31
|
-
ContractsUnionInputs<TItems>
|
|
32
|
-
] extends [never] ? false : true;
|
|
33
|
-
type HasOutputContracts<TItems extends readonly unknown[]> = [
|
|
34
|
-
ContractsUnionOutputs<TItems>
|
|
35
|
-
] extends [never] ? false : true;
|
|
36
|
-
type IsNever<T> = [T] extends [never] ? true : false;
|
|
37
|
-
type KeysWithNever<T> = T extends object ? {
|
|
38
|
-
[K in keyof T]-?: [T[K]] extends [never] ? K : never;
|
|
39
|
-
}[keyof T] : never;
|
|
40
|
-
type HasNeverProperty<T> = KeysWithNever<T> extends never ? false : true;
|
|
41
|
-
type IsImpossibleIntersection<T> = IsNever<T> extends true ? true : HasNeverProperty<T> extends true ? true : false;
|
|
42
|
-
type InputContractViolationError<TItems extends readonly unknown[], TActual> = {
|
|
43
|
-
message: "Value does not satisfy all input contracts";
|
|
44
|
-
expected: Simplify<ContractsIntersectionInputs<TItems>>;
|
|
45
|
-
received: TActual;
|
|
46
|
-
};
|
|
47
|
-
type OutputContractViolationError<TItems extends readonly unknown[], TActual> = {
|
|
48
|
-
message: "Value does not satisfy all output contracts";
|
|
49
|
-
expected: Simplify<ContractsIntersectionOutputs<TItems>>;
|
|
50
|
-
received: TActual;
|
|
51
|
-
};
|
|
52
|
-
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>;
|
|
53
|
-
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>;
|
|
54
|
-
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;
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* Common metadata you can attach to tasks/resources/events/middleware.
|
|
58
|
-
* Useful for docs, filtering and middleware decisions.
|
|
59
|
-
*/
|
|
60
|
-
interface IMeta {
|
|
61
|
-
title?: string;
|
|
62
|
-
description?: string;
|
|
63
|
-
}
|
|
64
|
-
interface ITaskMeta extends IMeta {
|
|
65
|
-
}
|
|
66
|
-
interface IResourceMeta extends IMeta {
|
|
67
|
-
}
|
|
68
|
-
interface IEventMeta extends IMeta {
|
|
69
|
-
}
|
|
70
|
-
interface IMiddlewareMeta extends IMeta {
|
|
71
|
-
}
|
|
72
|
-
interface ITagMeta extends IMeta {
|
|
73
|
-
}
|
|
74
|
-
interface IErrorMeta extends IMeta {
|
|
75
|
-
}
|
|
76
|
-
interface IAsyncContextMeta extends IMeta {
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
interface ITaggable {
|
|
80
|
-
tags: TagType[];
|
|
81
|
-
}
|
|
82
|
-
interface ITagDefinition<TConfig = void, _TEnforceInputContract = void, _TEnforceOutputContract = void> {
|
|
83
|
-
id: string;
|
|
84
|
-
meta?: ITagMeta;
|
|
85
|
-
configSchema?: IValidationSchema<TConfig>;
|
|
86
|
-
/**
|
|
87
|
-
* Utilizing config at definition level stores its defaults
|
|
88
|
-
*/
|
|
89
|
-
config?: TConfig;
|
|
90
|
-
}
|
|
91
|
-
interface ITag<TConfig = void, TEnforceInputContract = void, TEnforceOutputContract = void> extends ITagDefinition<TConfig, TEnforceInputContract, TEnforceOutputContract>, IContractable<TConfig, TEnforceInputContract, TEnforceOutputContract> {
|
|
92
|
-
/**
|
|
93
|
-
* A special validation property.
|
|
94
|
-
* It resolves to `true` if TConfig only has optional keys, otherwise `false`.
|
|
95
|
-
*/
|
|
96
|
-
readonly __configHasOnlyOptionalKeys: RequiredKeys<TConfig> extends never ? true : false;
|
|
97
|
-
config?: TConfig;
|
|
98
|
-
/**
|
|
99
|
-
* Checks if the tag exists in a taggable or a list of tags.
|
|
100
|
-
*/
|
|
101
|
-
exists(target: ITaggable | TagType[]): boolean;
|
|
102
|
-
/**
|
|
103
|
-
* Creates a configured instance of the tag.
|
|
104
|
-
*/
|
|
105
|
-
with(config: TConfig): ITagConfigured<TConfig, TEnforceInputContract, TEnforceOutputContract>;
|
|
106
|
-
/**
|
|
107
|
-
* Extracts the configuration of the tag from a taggable or a list of tags.
|
|
108
|
-
*/
|
|
109
|
-
extract(target: ITaggable | TagType[]): TConfig | undefined;
|
|
110
|
-
[symbolFilePath]: string;
|
|
111
|
-
[symbolTag]: true;
|
|
112
|
-
}
|
|
113
|
-
type ITagWithOptionalConfig<_TValue, TEnforceInputContract, TEnforceOutputContract> = ITag<any, TEnforceInputContract, TEnforceOutputContract> & {
|
|
114
|
-
readonly __configHasOnlyOptionalKeys: true;
|
|
115
|
-
};
|
|
116
|
-
interface ITagConfigured<TConfig = void, TEnforceInputContract = void, TEnforceOutputContract = void> extends ITag<TConfig, TEnforceInputContract, TEnforceOutputContract> {
|
|
117
|
-
[symbolTagConfigured]: true;
|
|
118
|
-
config: TConfig;
|
|
119
|
-
}
|
|
120
|
-
type TagType = ITag<void, any, any> | ITagWithOptionalConfig<any, any, any> | ITagConfigured<any, any, any>;
|
|
121
|
-
|
|
122
|
-
/**
|
|
123
|
-
* Internal brand symbols used to tag created objects at runtime and help with
|
|
124
|
-
* type‑narrowing. Prefer the `isTask`/`isResource`/`isEvent`/`isMiddleware`
|
|
125
|
-
* helpers instead of touching these directly.
|
|
126
|
-
* @internal
|
|
127
|
-
*/
|
|
128
|
-
declare const symbolTask: unique symbol;
|
|
129
|
-
/** Marks a task as a phantom task (no-op run; meant to be tunneled/routed). */
|
|
130
|
-
declare const symbolPhantomTask: unique symbol;
|
|
131
|
-
declare const symbolResource: unique symbol;
|
|
132
|
-
/** @internal Marks forked resources and records fork provenance */
|
|
133
|
-
declare const symbolResourceForkedFrom: unique symbol;
|
|
134
|
-
declare const symbolResourceWithConfig: unique symbol;
|
|
135
|
-
declare const symbolEvent: unique symbol;
|
|
136
|
-
/** @internal Marks an error helper definition */
|
|
137
|
-
declare const symbolError: unique symbol;
|
|
138
|
-
declare const symbolMiddleware: unique symbol;
|
|
139
|
-
/** New brands for separated middleware kinds */
|
|
140
|
-
declare const symbolTaskMiddleware: unique symbol;
|
|
141
|
-
declare const symbolResourceMiddleware: unique symbol;
|
|
142
|
-
declare const symbolMiddlewareConfigured: unique symbol;
|
|
143
|
-
/** Records which tunnel resource owns the task patching (exclusivity). */
|
|
144
|
-
declare const symbolTunneledBy: unique symbol;
|
|
145
|
-
/** @internal Marks hook definitions (event listeners without middleware) */
|
|
146
|
-
declare const symbolHook: unique symbol;
|
|
147
|
-
/** @internal Marks a tag definition */
|
|
148
|
-
declare const symbolTag: unique symbol;
|
|
149
|
-
declare const symbolTagConfigured: unique symbol;
|
|
150
|
-
/** @internal Marks an optional dependency wrapper */
|
|
151
|
-
declare const symbolOptionalDependency: unique symbol;
|
|
152
|
-
/** @internal Path to aid anonymous id generation and error messages */
|
|
153
|
-
declare const symbolFilePath: unique symbol;
|
|
154
|
-
/** @internal Marks an async context definition */
|
|
155
|
-
declare const symbolAsyncContext: unique symbol;
|
|
156
|
-
|
|
157
|
-
interface IResourceMiddlewareDefinition<TConfig = any, TEnforceInputContract = void, TEnforceOutputContract = void, TDependencies extends DependencyMapType = any> {
|
|
158
|
-
id: string;
|
|
159
|
-
/** Static or lazy dependency map. */
|
|
160
|
-
dependencies?: TDependencies | ((config: TConfig) => TDependencies);
|
|
161
|
-
/**
|
|
162
|
-
* Optional validation schema for runtime config validation.
|
|
163
|
-
* When provided, middleware config will be validated when .with() is called.
|
|
164
|
-
*/
|
|
165
|
-
configSchema?: IValidationSchema<TConfig>;
|
|
166
|
-
/**
|
|
167
|
-
* The middleware body, called with resource execution input.
|
|
168
|
-
*/
|
|
169
|
-
run: (input: IResourceMiddlewareExecutionInput<TEnforceInputContract extends void ? any : TEnforceInputContract, TEnforceOutputContract extends void ? any : TEnforceOutputContract>, dependencies: DependencyValuesType<TDependencies>, config: TConfig) => Promise<any>;
|
|
170
|
-
meta?: IMiddlewareMeta;
|
|
171
|
-
tags?: TagType[];
|
|
172
|
-
everywhere?: boolean | ((resource: IResource<any, any, any, any, any>) => boolean);
|
|
173
|
-
}
|
|
174
|
-
interface IResourceMiddleware<TConfig = any, TEnforceInputContract = void, TEnforceOutputContract = void, TDependencies extends DependencyMapType = any> extends IResourceMiddlewareDefinition<TConfig, TEnforceInputContract, TEnforceOutputContract, TDependencies>, IContractable<TConfig, TEnforceInputContract, TEnforceOutputContract> {
|
|
175
|
-
[symbolResourceMiddleware]: true;
|
|
176
|
-
id: string;
|
|
177
|
-
dependencies: TDependencies | ((config: TConfig) => TDependencies);
|
|
178
|
-
/** Current configuration object (empty by default). */
|
|
179
|
-
config: TConfig;
|
|
180
|
-
/** Configure the middleware and return a marked, configured instance. */
|
|
181
|
-
with: (config: TConfig) => IResourceMiddlewareConfigured<TConfig, TEnforceInputContract, TEnforceOutputContract, TDependencies>;
|
|
182
|
-
[symbolFilePath]: string;
|
|
183
|
-
tags: TagType[];
|
|
184
|
-
}
|
|
185
|
-
interface IResourceMiddlewareConfigured<TConfig = any, TEnforceInputContract = void, TEnforceOutputContract = void, TDependencies extends DependencyMapType = any> extends IResourceMiddleware<TConfig, TEnforceInputContract, TEnforceOutputContract, TDependencies> {
|
|
186
|
-
[symbolMiddlewareConfigured]: true;
|
|
187
|
-
}
|
|
188
|
-
interface IResourceMiddlewareExecutionInput<TResourceConfig = any, TResourceOutput = any> {
|
|
189
|
-
/** Resource hook */
|
|
190
|
-
resource: {
|
|
191
|
-
definition: IResource<TResourceConfig, any, any, any, any>;
|
|
192
|
-
config: TResourceConfig;
|
|
193
|
-
};
|
|
194
|
-
next: (resourceConfig?: TResourceConfig) => Promise<TResourceOutput>;
|
|
195
|
-
}
|
|
196
|
-
type ResourceMiddlewareAttachmentType = IResourceMiddleware<void, any, any, any> | IResourceMiddleware<{
|
|
197
|
-
[K in any]?: any;
|
|
198
|
-
}, any, any, any> | IResourceMiddlewareConfigured<any, any, any, any>;
|
|
199
|
-
|
|
200
|
-
type ErrorReference = string | IErrorHelper<any>;
|
|
201
|
-
type ThrowsList = ReadonlyArray<ErrorReference>;
|
|
202
|
-
interface IErrorDefinition<TData extends DefaultErrorType = DefaultErrorType> {
|
|
203
|
-
id: string;
|
|
204
|
-
serialize?: (data: TData) => string;
|
|
205
|
-
parse?: (data: string) => TData;
|
|
206
|
-
format?: (data: TData) => string;
|
|
207
|
-
/**
|
|
208
|
-
* Validate error data on throw(). If provided, data is parsed first.
|
|
209
|
-
*/
|
|
210
|
-
dataSchema?: IValidationSchema<TData>;
|
|
211
|
-
meta?: IErrorMeta;
|
|
212
|
-
}
|
|
213
|
-
interface IErrorDefinitionFinal<TData extends DefaultErrorType> extends IErrorDefinition<TData> {
|
|
214
|
-
format: (data: TData) => string;
|
|
215
|
-
}
|
|
216
|
-
type DefaultErrorType = Record<string, unknown>;
|
|
217
|
-
/**
|
|
218
|
-
* Runtime helper returned by defineError()/r.error().
|
|
219
|
-
* Contains helpers to throw typed errors and perform type-safe checks.
|
|
220
|
-
*/
|
|
221
|
-
interface IErrorHelper<TData extends DefaultErrorType = DefaultErrorType> {
|
|
222
|
-
/** Unique id for registration and DI */
|
|
223
|
-
id: string;
|
|
224
|
-
/** Throw a typed error with the given data */
|
|
225
|
-
throw(data: TData): never;
|
|
226
|
-
/** Type guard for checking if an unknown error is this error */
|
|
227
|
-
is(error: unknown): boolean;
|
|
228
|
-
/** Brand symbol for runtime detection */
|
|
229
|
-
[symbolError]: true;
|
|
230
|
-
/** Return an optional dependency wrapper for this error */
|
|
231
|
-
optional(): IOptionalDependency<IErrorHelper<TData>>;
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
type ResourceForkRegisterMode = "keep" | "drop" | "deep";
|
|
235
|
-
interface ResourceForkOptions {
|
|
236
|
-
/**
|
|
237
|
-
* Control whether the fork keeps the base `register` list.
|
|
238
|
-
* - "keep" (default) keeps registration items
|
|
239
|
-
* - "drop" clears registration items
|
|
240
|
-
* - "deep" deep-forks registered resources with new ids (resource tree)
|
|
241
|
-
*/
|
|
242
|
-
register?: ResourceForkRegisterMode;
|
|
243
|
-
/**
|
|
244
|
-
* Used with `register: "deep"` to derive ids for deep-forked resources.
|
|
245
|
-
* Defaults to `(id) => \`\${newId}.\${id}\``.
|
|
246
|
-
*/
|
|
247
|
-
reId?: (id: string) => string;
|
|
248
|
-
}
|
|
249
|
-
interface ResourceForkInfo {
|
|
250
|
-
/** The id of the resource that was forked. */
|
|
251
|
-
readonly fromId: string;
|
|
252
|
-
/** Best-effort call-site file path for the fork operation. */
|
|
253
|
-
readonly forkedAtFilePath: string;
|
|
254
|
-
}
|
|
255
|
-
type IsAny<T> = 0 extends 1 & T ? true : false;
|
|
256
|
-
type IsUnspecified<T> = [T] extends [undefined] ? true : [T] extends [void] ? true : IsAny<T> extends true ? true : false;
|
|
257
|
-
interface IResourceDefinition<TConfig = any, TValue extends Promise<any> = Promise<any>, TDependencies extends DependencyMapType = {}, TContext = any, _THooks = any, _TRegisterableItems = any, TMeta extends IResourceMeta = any, TTags extends TagType[] = TagType[], TMiddleware extends ResourceMiddlewareAttachmentType[] = ResourceMiddlewareAttachmentType[]> {
|
|
258
|
-
/** Stable identifier. */
|
|
259
|
-
id: string;
|
|
260
|
-
/** Static or lazy dependency map. Receives `config` when provided. */
|
|
261
|
-
dependencies?: TDependencies | ((config: TConfig) => TDependencies);
|
|
262
|
-
/**
|
|
263
|
-
* Register other registerables (resources/tasks/middleware/events). Accepts a
|
|
264
|
-
* static array or a function of `config` to support dynamic wiring.
|
|
265
|
-
*/
|
|
266
|
-
register?: Array<RegisterableItems> | ((config: TConfig) => Array<RegisterableItems>);
|
|
267
|
-
/**
|
|
268
|
-
* Initialize and return the resource value. Called once during boot.
|
|
269
|
-
*/
|
|
270
|
-
init?: (config: HasInputContracts<[...TTags, ...TMiddleware]> extends true ? IsUnspecified<TConfig> extends true ? InferInputOrViolationFromContracts<[...TTags, ...TMiddleware]> : EnsureInputSatisfiesContracts<[...TTags, ...TMiddleware], TConfig> : TConfig, dependencies: ResourceDependencyValuesType<TDependencies>, context: TContext) => HasOutputContracts<[...TTags, ...TMiddleware]> extends true ? EnsureOutputSatisfiesContracts<[...TTags, ...TMiddleware], TValue> : TValue;
|
|
271
|
-
/**
|
|
272
|
-
* Optional validation schema for the resource's resolved value.
|
|
273
|
-
* When provided, the value will be validated immediately after `init` resolves,
|
|
274
|
-
* without considering middleware.
|
|
275
|
-
*/
|
|
276
|
-
resultSchema?: IValidationSchema<TValue extends Promise<infer U> ? U : TValue>;
|
|
277
|
-
/**
|
|
278
|
-
* Clean-up function for the resource. This is called when the resource is no longer needed.
|
|
279
|
-
*
|
|
280
|
-
* @param value The value of the resource (undefined if no init method)
|
|
281
|
-
* @param config The configuration it received
|
|
282
|
-
* @param dependencies The dependencies it needed
|
|
283
|
-
* @returns Promise<void>
|
|
284
|
-
*/
|
|
285
|
-
dispose?: (this: any, value: TValue extends Promise<infer U> ? U : TValue, config: TConfig, dependencies: ResourceDependencyValuesType<TDependencies>, context: TContext) => Promise<void>;
|
|
286
|
-
meta?: TMeta;
|
|
287
|
-
/**
|
|
288
|
-
* Declares which typed errors are part of this resource's contract.
|
|
289
|
-
*
|
|
290
|
-
* This is a declarative contract only:
|
|
291
|
-
* - It does not imply dependency injection
|
|
292
|
-
* - It does not enforce that only these errors can be thrown
|
|
293
|
-
*
|
|
294
|
-
* Use string ids or Error helpers.
|
|
295
|
-
*/
|
|
296
|
-
throws?: ThrowsList;
|
|
297
|
-
/**
|
|
298
|
-
* Optional validation schema for runtime config validation.
|
|
299
|
-
* When provided, resource config will be validated when .with() is called.
|
|
300
|
-
*/
|
|
301
|
-
configSchema?: IValidationSchema<TConfig>;
|
|
302
|
-
/**
|
|
303
|
-
* Safe overrides to swap behavior while preserving identities. See
|
|
304
|
-
* README: Overrides.
|
|
305
|
-
*/
|
|
306
|
-
overrides?: Array<OverridableElements>;
|
|
307
|
-
/** Middleware applied around init/dispose. */
|
|
308
|
-
middleware?: TMiddleware;
|
|
309
|
-
/**
|
|
310
|
-
* Create a private, mutable context shared between `init` and `dispose`.
|
|
311
|
-
*/
|
|
312
|
-
context?: () => TContext;
|
|
313
|
-
/**
|
|
314
|
-
* This is optional and used from an index resource to get the correct caller.
|
|
315
|
-
* This is the reason we allow it here as well.
|
|
316
|
-
*/
|
|
317
|
-
[symbolFilePath]?: string;
|
|
318
|
-
tags?: TTags;
|
|
319
|
-
}
|
|
320
|
-
/**
|
|
321
|
-
* Helper alias describing the canonical resource init call signature.
|
|
322
|
-
* Shared with fluent builders to keep init typing consistent.
|
|
323
|
-
*/
|
|
324
|
-
type ResourceInitFn<TConfig, TValue extends Promise<any>, TDependencies extends DependencyMapType, TContext, TMeta extends IResourceMeta, TTags extends TagType[], TMiddleware extends ResourceMiddlewareAttachmentType[]> = NonNullable<IResourceDefinition<TConfig, TValue, TDependencies, TContext, any, any, TMeta, TTags, TMiddleware>["init"]>;
|
|
325
|
-
interface IResource<TConfig = void, TValue extends Promise<any> = Promise<any>, TDependencies extends DependencyMapType = any, TContext = any, TMeta extends IResourceMeta = any, TTags extends TagType[] = TagType[], TMiddleware extends ResourceMiddlewareAttachmentType[] = ResourceMiddlewareAttachmentType[]> extends IResourceDefinition<TConfig, TValue, TDependencies, TContext, any, any, TMeta, TTags, TMiddleware> {
|
|
326
|
-
id: string;
|
|
327
|
-
with(config: HasInputContracts<[...TTags, ...TMiddleware]> extends true ? IsUnspecified<TConfig> extends true ? InferInputOrViolationFromContracts<[...TTags, ...TMiddleware]> : TConfig : TConfig): IResourceWithConfig<TConfig, TValue, TDependencies, TContext, TMeta, TTags, TMiddleware>;
|
|
328
|
-
register: Array<RegisterableItems> | ((config: TConfig) => Array<RegisterableItems>);
|
|
329
|
-
overrides: Array<OverridableElements>;
|
|
330
|
-
middleware: TMiddleware;
|
|
331
|
-
[symbolFilePath]: string;
|
|
332
|
-
[symbolResource]: true;
|
|
333
|
-
/** Present only on forked resources. */
|
|
334
|
-
[symbolResourceForkedFrom]?: ResourceForkInfo;
|
|
335
|
-
/** Normalized list of error ids declared via `throws`. */
|
|
336
|
-
throws?: readonly string[];
|
|
337
|
-
/** Return an optional dependency wrapper for this resource. */
|
|
338
|
-
optional: () => IOptionalDependency<IResource<TConfig, TValue, TDependencies, TContext, TMeta, TTags, TMiddleware>>;
|
|
339
|
-
tags: TTags;
|
|
340
|
-
/**
|
|
341
|
-
* Create a new resource with a different id but the same definition.
|
|
342
|
-
* Useful for creating multiple instances of a "template" resource.
|
|
343
|
-
* The forked resource should be exported and used as a dependency.
|
|
344
|
-
*/
|
|
345
|
-
fork(newId: string, options?: ResourceForkOptions): IResource<TConfig, TValue, TDependencies, TContext, TMeta, TTags, TMiddleware>;
|
|
346
|
-
}
|
|
347
|
-
interface IResourceWithConfig<TConfig = any, TValue extends Promise<any> = Promise<any>, TDependencies extends DependencyMapType = any, TContext = any, TMeta extends IResourceMeta = any, TTags extends TagType[] = TagType[], TMiddleware extends IResourceMiddleware<any, any, any, any>[] = IResourceMiddleware[]> {
|
|
348
|
-
[symbolResourceWithConfig]: true;
|
|
349
|
-
/** The id of the underlying resource. */
|
|
350
|
-
id: string;
|
|
351
|
-
/** The underlying resource definition. */
|
|
352
|
-
resource: IResource<TConfig, TValue, TDependencies, TContext, TMeta, TTags, TMiddleware>;
|
|
353
|
-
/** The configuration captured by `.with(config)`. */
|
|
354
|
-
config: TConfig;
|
|
355
|
-
}
|
|
356
|
-
|
|
357
|
-
/**
|
|
358
|
-
* Typed key used to store/retrieve values from an ExecutionJournal.
|
|
359
|
-
* The `id` is used as the storage slot.
|
|
360
|
-
*/
|
|
361
|
-
declare const journalKeyBrand: unique symbol;
|
|
362
|
-
type JournalKey<T> = {
|
|
363
|
-
readonly id: string;
|
|
364
|
-
readonly [journalKeyBrand]?: (value: T) => T;
|
|
365
|
-
};
|
|
366
|
-
/**
|
|
367
|
-
* Options for setting values in the journal.
|
|
368
|
-
*/
|
|
369
|
-
interface JournalSetOptions {
|
|
370
|
-
/**
|
|
371
|
-
* If true, allows overwriting an existing value.
|
|
372
|
-
* By default, attempting to set a key that already exists will throw an error.
|
|
373
|
-
*/
|
|
374
|
-
override?: boolean;
|
|
375
|
-
}
|
|
376
|
-
/**
|
|
377
|
-
* Per-execution registry that allows middleware and tasks to share state.
|
|
378
|
-
* A new journal is created for each top-level task execution unless explicitly forwarded.
|
|
379
|
-
*/
|
|
380
|
-
interface ExecutionJournal {
|
|
381
|
-
set<T>(key: JournalKey<T>, value: T, options?: JournalSetOptions): void;
|
|
382
|
-
get<T>(key: JournalKey<T>): T | undefined;
|
|
383
|
-
has<T>(key: JournalKey<T>): boolean;
|
|
384
|
-
}
|
|
385
|
-
|
|
386
|
-
interface ITaskMiddlewareDefinition<TConfig = any, TEnforceInputContract = void, TEnforceOutputContract = void, TDependencies extends DependencyMapType = any> {
|
|
387
|
-
id: string;
|
|
388
|
-
/** Static or lazy dependency map. */
|
|
389
|
-
dependencies?: TDependencies | ((config: TConfig) => TDependencies);
|
|
390
|
-
/**
|
|
391
|
-
* Optional validation schema for runtime config validation.
|
|
392
|
-
* When provided, middleware config will be validated when .with() is called.
|
|
393
|
-
*/
|
|
394
|
-
configSchema?: IValidationSchema<TConfig>;
|
|
395
|
-
/**
|
|
396
|
-
* The middleware body, called with task execution input.
|
|
397
|
-
*/
|
|
398
|
-
run: (input: ITaskMiddlewareExecutionInput<TEnforceInputContract extends void ? any : TEnforceInputContract, TEnforceOutputContract extends void ? any : TEnforceOutputContract>, dependencies: DependencyValuesType<TDependencies>, config: TConfig) => Promise<any>;
|
|
399
|
-
meta?: IMiddlewareMeta;
|
|
400
|
-
tags?: TagType[];
|
|
401
|
-
everywhere?: boolean | ((task: ITask<any, any, any, any>) => boolean);
|
|
402
|
-
}
|
|
403
|
-
interface ITaskMiddleware<TConfig = any, TEnforceInputContract = void, TEnforceOutputContract = void, TDependencies extends DependencyMapType = any> extends ITaskMiddlewareDefinition<TConfig, TEnforceInputContract, TEnforceOutputContract, TDependencies>, IContractable<TConfig, TEnforceInputContract, TEnforceOutputContract> {
|
|
404
|
-
[symbolTaskMiddleware]: true;
|
|
405
|
-
[symbolFilePath]: string;
|
|
406
|
-
id: string;
|
|
407
|
-
dependencies: TDependencies | ((config: TConfig) => TDependencies);
|
|
408
|
-
/** Current configuration object (empty by default). */
|
|
409
|
-
config: TConfig;
|
|
410
|
-
/** Configure the middleware and return a marked, configured instance. */
|
|
411
|
-
with: (config: TConfig) => ITaskMiddlewareConfigured<TConfig, TEnforceInputContract, TEnforceOutputContract, TDependencies>;
|
|
412
|
-
tags: TagType[];
|
|
413
|
-
}
|
|
414
|
-
interface ITaskMiddlewareConfigured<TConfig = any, TEnforceInputContract = void, TEnforceOutputContract = void, TDependencies extends DependencyMapType = any> extends ITaskMiddleware<TConfig, TEnforceInputContract, TEnforceOutputContract, TDependencies> {
|
|
415
|
-
[symbolMiddlewareConfigured]: true;
|
|
416
|
-
config: TConfig;
|
|
417
|
-
}
|
|
418
|
-
interface ITaskMiddlewareExecutionInput<TTaskInput = any, TTaskOutput = any> {
|
|
419
|
-
/** Task hook */
|
|
420
|
-
task: {
|
|
421
|
-
definition: ITask<TTaskInput, any, any, any>;
|
|
422
|
-
input: TTaskInput;
|
|
423
|
-
};
|
|
424
|
-
next: (taskInput?: TTaskInput) => Promise<TTaskOutput>;
|
|
425
|
-
/** Per-execution registry for sharing state between middleware and task */
|
|
426
|
-
journal: ExecutionJournal;
|
|
427
|
-
}
|
|
428
|
-
type TaskMiddlewareAttachmentType = ITaskMiddleware<void, any, any, any> | ITaskMiddleware<{
|
|
429
|
-
[K in any]?: any;
|
|
430
|
-
}, any, any, any> | ITaskMiddlewareConfigured<any, any, any, any>;
|
|
431
|
-
|
|
432
|
-
interface ITaskDefinition<TInput = undefined, TOutput extends Promise<any> = any, TDependencies extends DependencyMapType = {}, TMeta extends ITaskMeta = any, TTags extends TagType[] = TagType[], TMiddleware extends TaskMiddlewareAttachmentType[] = TaskMiddlewareAttachmentType[]> {
|
|
433
|
-
id: string;
|
|
434
|
-
/**
|
|
435
|
-
* Access other tasks/resources/events. Can be an object or a function when
|
|
436
|
-
* you need late or config‑dependent resolution.
|
|
437
|
-
*/
|
|
438
|
-
dependencies?: TDependencies | (() => TDependencies);
|
|
439
|
-
/** Middleware applied around task execution. */
|
|
440
|
-
middleware?: TMiddleware;
|
|
441
|
-
/** Optional metadata used for docs, filtering and tooling. */
|
|
442
|
-
meta?: TMeta;
|
|
443
|
-
/**
|
|
444
|
-
* Optional validation schema for runtime input validation.
|
|
445
|
-
* When provided, task input will be validated before execution.
|
|
446
|
-
*/
|
|
447
|
-
inputSchema?: IValidationSchema<TInput>;
|
|
448
|
-
/**
|
|
449
|
-
* Optional validation schema for the task result.
|
|
450
|
-
* When provided, the result will be validated immediately after the task's
|
|
451
|
-
* `run` resolves, without considering middleware.
|
|
452
|
-
*/
|
|
453
|
-
resultSchema?: IValidationSchema<TOutput extends Promise<infer U> ? U : never>;
|
|
454
|
-
/**
|
|
455
|
-
* Declares which typed errors are part of this task's contract.
|
|
456
|
-
*
|
|
457
|
-
* This is a declarative contract only:
|
|
458
|
-
* - It does not imply dependency injection
|
|
459
|
-
* - It does not enforce that only these errors can be thrown
|
|
460
|
-
*
|
|
461
|
-
* Use string ids or Error helpers.
|
|
462
|
-
*/
|
|
463
|
-
throws?: ThrowsList;
|
|
464
|
-
run: (input: HasInputContracts<[...TTags, ...TMiddleware]> extends true ? [TInput] extends [undefined] ? InferInputOrViolationFromContracts<[...TTags, ...TMiddleware]> : EnsureInputSatisfiesContracts<[...TTags, ...TMiddleware], TInput> : TInput, dependencies: DependencyValuesType<TDependencies>, context?: {
|
|
465
|
-
journal: ExecutionJournal;
|
|
466
|
-
}) => HasOutputContracts<[...TTags, ...TMiddleware]> extends true ? EnsureOutputSatisfiesContracts<[...TTags, ...TMiddleware], TOutput> : TOutput;
|
|
467
|
-
/**
|
|
468
|
-
* Tags applied to the task that might define its behvaiour or impact the systems.
|
|
469
|
-
*/
|
|
470
|
-
tags?: TTags;
|
|
471
|
-
}
|
|
472
|
-
interface ITask<TInput = any, TOutput extends Promise<any> = any, TDependencies extends DependencyMapType = {}, TMeta extends ITaskMeta = any, TTags extends TagType[] = TagType[], TMiddleware extends TaskMiddlewareAttachmentType[] = TaskMiddlewareAttachmentType[]> extends ITaskDefinition<TInput, TOutput, TDependencies, TMeta, TTags, TMiddleware> {
|
|
473
|
-
[symbolFilePath]: string;
|
|
474
|
-
[symbolTask]: true;
|
|
475
|
-
/** Present only for phantom tasks. */
|
|
476
|
-
[symbolPhantomTask]?: true;
|
|
477
|
-
/** Indicates if the task is tunneled through a tunnel client. */
|
|
478
|
-
isTunneled?: boolean;
|
|
479
|
-
/** Records which tunnel resource owns the task (exclusivity). */
|
|
480
|
-
[symbolTunneledBy]?: string;
|
|
481
|
-
id: string;
|
|
482
|
-
dependencies: TDependencies | (() => TDependencies);
|
|
483
|
-
computedDependencies?: DependencyValuesType<TDependencies>;
|
|
484
|
-
middleware: TMiddleware;
|
|
485
|
-
/** Normalized list of error ids declared via `throws`. */
|
|
486
|
-
throws?: readonly string[];
|
|
487
|
-
/** Return an optional dependency wrapper for this task. */
|
|
488
|
-
optional: () => IOptionalDependency<ITask<TInput, TOutput, TDependencies, TMeta, TTags, TMiddleware>>;
|
|
489
|
-
tags: TTags;
|
|
490
|
-
}
|
|
491
|
-
/** Narrowed type for phantom tasks (no-op run by default). */
|
|
492
|
-
type IPhantomTask<TInput = any, TResolved = any, TDependencies extends DependencyMapType = {}, TMeta extends ITaskMeta = any, TTags extends TagType[] = TagType[], TMiddleware extends TaskMiddlewareAttachmentType[] = TaskMiddlewareAttachmentType[]> = ITask<TInput, Promise<TResolved>, TDependencies, TMeta, TTags, TMiddleware> & {
|
|
493
|
-
[symbolPhantomTask]: true;
|
|
494
|
-
};
|
|
495
|
-
|
|
496
|
-
type EventHandlerType<T = any> = (event: IEventEmission<T>) => any | Promise<any>;
|
|
497
|
-
declare function onAnyOf<T extends readonly IEventDefinition<any>[]>(...defs: T): T;
|
|
498
|
-
/**
|
|
499
|
-
* Runtime guard that checks if an emission belongs to one of the given event defs.
|
|
500
|
-
* Narrows payload type to the intersection of the provided events' payloads.
|
|
501
|
-
*/
|
|
502
|
-
declare function isOneOf<TDefs extends readonly IEventDefinition<any>[]>(emission: IEventEmission<any>, defs: TDefs): emission is IEventEmission<CommonPayload<TDefs>>;
|
|
503
|
-
interface IEventDefinition<TPayload = void> {
|
|
504
|
-
id: string;
|
|
505
|
-
meta?: IEventMeta;
|
|
506
|
-
/**
|
|
507
|
-
* Optional validation schema for runtime payload validation.
|
|
508
|
-
* When provided, event payload will be validated when emitted.
|
|
509
|
-
*/
|
|
510
|
-
payloadSchema?: IValidationSchema<TPayload>;
|
|
511
|
-
tags?: TagType[];
|
|
512
|
-
/**
|
|
513
|
-
* If true, listeners with the same priority run concurrently within a batch.
|
|
514
|
-
* Batches (grouped by order) still execute sequentially in priority order.
|
|
515
|
-
*/
|
|
516
|
-
parallel?: boolean;
|
|
517
|
-
}
|
|
518
|
-
/**
|
|
519
|
-
* The definioten of the event.
|
|
520
|
-
* This is different from the event emission.
|
|
521
|
-
*/
|
|
522
|
-
interface IEvent<TPayload = any> extends IEventDefinition<TPayload> {
|
|
523
|
-
id: string;
|
|
524
|
-
/**
|
|
525
|
-
* 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.
|
|
526
|
-
*/
|
|
527
|
-
[symbolEvent]: true;
|
|
528
|
-
[symbolFilePath]: string;
|
|
529
|
-
/** Return an optional dependency wrapper for this event. */
|
|
530
|
-
optional: () => IOptionalDependency<IEvent<TPayload>>;
|
|
531
|
-
tags: TagType[];
|
|
532
|
-
}
|
|
533
|
-
/**
|
|
534
|
-
* This represents the object that is passed to event handlers
|
|
535
|
-
*/
|
|
536
|
-
interface IEventEmission<TPayload = any> {
|
|
537
|
-
/**
|
|
538
|
-
* The ID of the event. This is the same as the event's ID.
|
|
539
|
-
* This is useful for global event listeners.
|
|
540
|
-
*/
|
|
541
|
-
id: string;
|
|
542
|
-
/**
|
|
543
|
-
* The data that the event carries. It can be anything.
|
|
544
|
-
*/
|
|
545
|
-
data: TPayload;
|
|
546
|
-
/**
|
|
547
|
-
* The timestamp when the event was created.
|
|
548
|
-
*/
|
|
549
|
-
timestamp: Date;
|
|
550
|
-
/**
|
|
551
|
-
* The source of the event. This can be useful for debugging.
|
|
552
|
-
*/
|
|
553
|
-
source: string;
|
|
554
|
-
/**
|
|
555
|
-
* Metadata associated with the event definition.
|
|
556
|
-
*/
|
|
557
|
-
meta: IEventMeta;
|
|
558
|
-
/**
|
|
559
|
-
* Stops propagation to remaining event listeners.
|
|
560
|
-
*/
|
|
561
|
-
stopPropagation(): void;
|
|
562
|
-
/**
|
|
563
|
-
* Returns true if propagation has been stopped.
|
|
564
|
-
*/
|
|
565
|
-
isPropagationStopped(): boolean;
|
|
566
|
-
/**
|
|
567
|
-
* The tags that the event carries.
|
|
568
|
-
*/
|
|
569
|
-
tags: TagType[];
|
|
570
|
-
}
|
|
571
|
-
|
|
572
|
-
type OnType = "*" | IEventDefinition<any> | readonly IEventDefinition<any>[];
|
|
573
|
-
interface IHookDefinition<TDependencies extends DependencyMapType = {}, TOn extends OnType = any, TMeta extends ITaskMeta = any> {
|
|
574
|
-
id: string;
|
|
575
|
-
dependencies?: TDependencies | (() => TDependencies);
|
|
576
|
-
on: TOn;
|
|
577
|
-
/** Listener execution order. Lower numbers run first. */
|
|
578
|
-
order?: number;
|
|
579
|
-
meta?: TMeta;
|
|
580
|
-
run: (event: IEventEmission<TOn extends "*" ? any : TOn extends readonly IEventDefinition<any>[] ? CommonPayload<TOn> : ExtractEventPayload<TOn>>, dependencies: DependencyValuesType<TDependencies>) => Promise<any>;
|
|
581
|
-
tags?: TagType[];
|
|
582
|
-
}
|
|
583
|
-
interface IHook<TDependencies extends DependencyMapType = {}, TOn extends OnType = any, TMeta extends ITaskMeta = any> extends IHookDefinition<TDependencies, TOn, TMeta> {
|
|
584
|
-
id: string;
|
|
585
|
-
dependencies: TDependencies | (() => TDependencies);
|
|
586
|
-
[symbolFilePath]: string;
|
|
587
|
-
[symbolHook]: true;
|
|
588
|
-
tags: TagType[];
|
|
589
|
-
}
|
|
590
|
-
|
|
591
|
-
interface IAsyncContextDefinition<T> {
|
|
592
|
-
id: string;
|
|
593
|
-
serialize?(data: T): string;
|
|
594
|
-
parse?(data: string): T;
|
|
595
|
-
/**
|
|
596
|
-
* When provided, context values will be validated when provide() is called.
|
|
597
|
-
*/
|
|
598
|
-
configSchema?: IValidationSchema<T>;
|
|
599
|
-
meta?: IAsyncContextMeta;
|
|
600
|
-
}
|
|
601
|
-
/**
|
|
602
|
-
* The generic AsyncContext object returned by `defineAsyncContext`.
|
|
603
|
-
*/
|
|
604
|
-
interface IAsyncContext<T> {
|
|
605
|
-
/** unique symbol used as key in the AsyncLocalStorage map */
|
|
606
|
-
readonly id: string;
|
|
607
|
-
/** Brand marker for registration and runtime checks */
|
|
608
|
-
[symbolAsyncContext]: true;
|
|
609
|
-
/** Retrieve the current context value or throw */
|
|
610
|
-
use(): T;
|
|
611
|
-
/**
|
|
612
|
-
* Provide a value for this context during the lifetime of `fn()`
|
|
613
|
-
*/
|
|
614
|
-
provide<R>(value: T, fn: () => Promise<R> | R): Promise<R> | R;
|
|
615
|
-
/**
|
|
616
|
-
* Generates a middleware that guarantees the context exists (and optionally
|
|
617
|
-
* enforces that certain keys are present on the context object).
|
|
618
|
-
*/
|
|
619
|
-
require<K extends keyof T = never>(keys?: K[]): ITaskMiddlewareConfigured<{
|
|
620
|
-
context: IAsyncContext<T>;
|
|
621
|
-
}>;
|
|
622
|
-
serialize(data: T): string;
|
|
623
|
-
parse(data: string): T;
|
|
624
|
-
/** Return an optional dependency wrapper for this context */
|
|
625
|
-
optional(): IOptionalDependency<IAsyncContext<T>>;
|
|
626
|
-
}
|
|
627
|
-
|
|
628
|
-
/**
|
|
629
|
-
* Generic validation schema interface that can be implemented by any validation library.
|
|
630
|
-
* Compatible with Zod, Yup, Joi, and other validation libraries.
|
|
631
|
-
*/
|
|
632
|
-
interface IValidationSchema<T = any> {
|
|
633
|
-
/**
|
|
634
|
-
* Parse and validate the input data.
|
|
635
|
-
* Should throw an error if validation fails.
|
|
636
|
-
* Can transform the data if the schema supports transformations.
|
|
637
|
-
*/
|
|
638
|
-
parse(input: unknown): T;
|
|
639
|
-
}
|
|
640
|
-
/**
|
|
641
|
-
* Core public TypeScript types for BlueLibs Runner.
|
|
642
|
-
*
|
|
643
|
-
* This file contains the strongly-typed contract for tasks, resources, events
|
|
644
|
-
* and middleware. It mirrors the mental model described in the README:
|
|
645
|
-
* - Tasks are functions
|
|
646
|
-
* - Resources are singletons (with init/dispose hooks)
|
|
647
|
-
* - Events are simple, strongly-typed emissions
|
|
648
|
-
* - Middleware can target both tasks and resources
|
|
649
|
-
*
|
|
650
|
-
* DX goals:
|
|
651
|
-
* - Crystal‑clear generics and helper types that infer dependency shapes
|
|
652
|
-
* - Friendly JSDoc you can hover in editors to understand usage instantly
|
|
653
|
-
* - Safe overrides and strong typing around config and register mechanics
|
|
654
|
-
*/
|
|
655
|
-
type RequiredKeys<T> = {
|
|
656
|
-
[K in keyof T]-?: {} extends Pick<T, K> ? never : K;
|
|
657
|
-
}[keyof T];
|
|
658
|
-
/**
|
|
659
|
-
* The reason we accept null and undefined is because we want to be able to offer beautiful DX:
|
|
660
|
-
* overrides: [
|
|
661
|
-
* process.env.NODE_ENV === 'production' ? prodEmailer : null,
|
|
662
|
-
* ]
|
|
663
|
-
*/
|
|
664
|
-
type OverridableElements = IResource<any, any, any, any, any> | ITask<any, any, any, any> | ITaskMiddleware<any> | IResourceMiddleware<any, any> | IResourceWithConfig<any, any, any> | IHook<any, any> | undefined | null;
|
|
665
|
-
/**
|
|
666
|
-
* A mapping of dependency keys to Runner definitions. Used in `dependencies`
|
|
667
|
-
* for tasks and resources. Values are later transformed into the actual
|
|
668
|
-
* callable/value shape by `DependencyValuesType`.
|
|
669
|
-
*/
|
|
670
|
-
type DependencyMapType = Record<string, ITask<any, any, any, any, any, any> | IResource<any, any, any, any, any, any, any> | IEvent<any> | IErrorHelper<any> | IAsyncContext<any> | IOptionalDependency<ITask<any, any, any, any, any, any>> | IOptionalDependency<IResource<any, any, any, any, any, any, any>> | IOptionalDependency<IEvent<any>> | IOptionalDependency<IErrorHelper<any>> | IOptionalDependency<IAsyncContext<any>>>;
|
|
671
|
-
/** Wrapper type marking a dependency as optional at wiring time */
|
|
672
|
-
interface IOptionalDependency<T> {
|
|
673
|
-
/** The wrapped dependency definition */
|
|
674
|
-
inner: T;
|
|
675
|
-
/** Brand symbol for optional dependency */
|
|
676
|
-
[symbolOptionalDependency]: true;
|
|
677
|
-
}
|
|
678
|
-
type ExtractTaskInput<T> = T extends ITask<infer I, any, infer _D> ? I : never;
|
|
679
|
-
type ExtractTaskOutput<T> = T extends ITask<any, infer O, infer _D> ? O : never;
|
|
680
|
-
type ExtractResourceConfig<T> = T extends IResource<infer C, any, any> ? C : never;
|
|
681
|
-
type ExtractResourceValue<T> = T extends IResource<any, infer V, infer _D> ? V extends Promise<infer U> ? U : V : never;
|
|
682
|
-
type ExtractEventPayload<T> = T extends IEventDefinition<infer P> ? P : T extends IEvent<infer P> ? P : never;
|
|
683
|
-
type UnionToIntersection<U> = (U extends any ? (x: U) => any : never) extends (x: infer I) => any ? I : never;
|
|
684
|
-
type CommonPayload<T extends readonly IEventDefinition<any>[] | IEventDefinition<any>> = T extends readonly IEventDefinition<any>[] ? {
|
|
685
|
-
[K in keyof ExtractEventPayload<T[number]>]: UnionToIntersection<ExtractEventPayload<T[number]> extends any ? ExtractEventPayload<T[number]>[K] : never>;
|
|
686
|
-
} : ExtractEventPayload<T>;
|
|
687
|
-
/**
|
|
688
|
-
* Options that can be passed when calling a task dependency.
|
|
689
|
-
* Allows forwarding the execution journal to nested task calls.
|
|
690
|
-
*/
|
|
691
|
-
interface TaskCallOptions {
|
|
692
|
-
/** Optional journal to forward to the nested task */
|
|
693
|
-
journal?: ExecutionJournal;
|
|
694
|
-
}
|
|
695
|
-
/**
|
|
696
|
-
* Task dependencies transform into callable functions: call with the task input
|
|
697
|
-
* and you receive the task output. Optionally accepts TaskCallOptions for journal forwarding.
|
|
698
|
-
*/
|
|
699
|
-
type TaskDependency<I, O> = I extends null | void ? {
|
|
700
|
-
(options?: TaskCallOptions): O;
|
|
701
|
-
(input?: I, options?: TaskCallOptions): O;
|
|
702
|
-
} : (input: I, options?: TaskCallOptions) => O;
|
|
703
|
-
/**
|
|
704
|
-
* Resource dependencies resolve to the resource's value directly.
|
|
705
|
-
*/
|
|
706
|
-
type ResourceDependency<V> = V;
|
|
707
|
-
/**
|
|
708
|
-
* Event dependencies resolve to an emitter function. If the payload type is
|
|
709
|
-
* `void`, the function can be called with zero args (or an empty object).
|
|
710
|
-
*/
|
|
711
|
-
type EventDependency<P> = P extends void ? (() => Promise<void>) & ((input?: Record<string, never>) => Promise<void>) : (input: P) => Promise<void>;
|
|
712
|
-
/**
|
|
713
|
-
* Transforms a dependency definition into the usable shape inside `run`/`init`:
|
|
714
|
-
* - Task -> callable function
|
|
715
|
-
* - Resource -> resolved value
|
|
716
|
-
* - Event -> emit function
|
|
717
|
-
*/
|
|
718
|
-
type DependencyValueType<T> = T extends ITask<any, any, any> ? TaskDependency<ExtractTaskInput<T>, ExtractTaskOutput<T>> : T extends IResource<any, any> ? ResourceDependency<ExtractResourceValue<T>> : T extends IErrorHelper<any> ? T : T extends IAsyncContext<any> ? T : T extends IEventDefinition<any> ? EventDependency<ExtractEventPayload<T>> : T extends IOptionalDependency<infer U> ? DependencyValueType<U> | undefined : never;
|
|
719
|
-
type DependencyValuesType<T extends DependencyMapType> = {
|
|
720
|
-
[K in keyof T]: DependencyValueType<T[K]>;
|
|
721
|
-
};
|
|
722
|
-
type TaskLocalInterceptor<TInput, TOutput> = (next: (input: TInput) => TOutput, input: TInput) => TOutput;
|
|
723
|
-
type TaskDependencyWithIntercept<TInput, TOutput> = TaskDependency<TInput, TOutput> & {
|
|
724
|
-
intercept: (middleware: TaskLocalInterceptor<TInput, TOutput>) => void;
|
|
725
|
-
};
|
|
726
|
-
/** Resource-context dependency typing where tasks expose intercept() */
|
|
727
|
-
type ResourceDependencyValueType<T> = T extends ITask<any, any, any> ? TaskDependencyWithIntercept<ExtractTaskInput<T>, ExtractTaskOutput<T>> : T extends IResource<any, any> ? ResourceDependency<ExtractResourceValue<T>> : T extends IErrorHelper<any> ? T : T extends IAsyncContext<any> ? T : T extends IEventDefinition<any> ? EventDependency<ExtractEventPayload<T>> : T extends IOptionalDependency<infer U> ? ResourceDependencyValueType<U> | undefined : never;
|
|
728
|
-
type ResourceDependencyValuesType<T extends DependencyMapType> = {
|
|
729
|
-
[K in keyof T]: ResourceDependencyValueType<T[K]>;
|
|
730
|
-
};
|
|
731
|
-
/**
|
|
732
|
-
* Anything you can put inside a resource's `register: []`.
|
|
733
|
-
* - Resources (with or without `.with()`)
|
|
734
|
-
* - Tasks
|
|
735
|
-
* - Middleware
|
|
736
|
-
* - Events
|
|
737
|
-
*/
|
|
738
|
-
type RegisterableItems = IResourceWithConfig<any, any, any, any, any, any, any> | IResource<void, any, any, any, any, any, any> | IResource<{
|
|
739
|
-
[K in any]?: any;
|
|
740
|
-
}, any, any, any, any, any, any> | ITask<any, any, any, any, any, any> | IHook<any, any> | ITaskMiddleware<any, any, any, any> | IResourceMiddleware<any, any, any, any> | IEvent<any> | IAsyncContext<any> | IErrorHelper<any> | ITag<any, any, any>;
|
|
741
|
-
|
|
742
|
-
type DebugConfig = {
|
|
743
|
-
logResourceConfig: boolean;
|
|
744
|
-
logResourceValue: boolean;
|
|
745
|
-
logResourceBeforeRun: boolean;
|
|
746
|
-
logResourceAfterRun: boolean;
|
|
747
|
-
logTaskBeforeRun: boolean;
|
|
748
|
-
logTaskInput: boolean;
|
|
749
|
-
logTaskOutput: boolean;
|
|
750
|
-
logTaskAfterRun: boolean;
|
|
751
|
-
logMiddlewareBeforeRun: boolean;
|
|
752
|
-
logMiddlewareAfterRun: boolean;
|
|
753
|
-
logEventEmissionOnRun: boolean;
|
|
754
|
-
logEventEmissionInput: boolean;
|
|
755
|
-
logHookTriggered: boolean;
|
|
756
|
-
logHookCompleted: boolean;
|
|
757
|
-
};
|
|
758
|
-
declare const allFalse: DebugConfig;
|
|
759
|
-
declare const levelNormal: DebugConfig;
|
|
760
|
-
declare const levelVerbose: DebugConfig;
|
|
761
|
-
/**
|
|
762
|
-
* If you choose to specify your own config, all values will be set to false by default and extended by your config.
|
|
763
|
-
*/
|
|
764
|
-
type DebugFriendlyConfig = "normal" | "verbose" | Partial<DebugConfig>;
|
|
765
|
-
declare const getConfig: (config: DebugFriendlyConfig, taggable?: ITaggable) => DebugConfig;
|
|
766
|
-
|
|
767
|
-
type PrintStrategy$1 = "pretty" | "plain" | "json" | "json_pretty";
|
|
768
|
-
type LogLevels$1 = "trace" | "debug" | "info" | "warn" | "error" | "critical";
|
|
769
|
-
interface PrintableLog {
|
|
770
|
-
level: LogLevels$1;
|
|
771
|
-
source?: string;
|
|
772
|
-
message: any;
|
|
773
|
-
timestamp: Date;
|
|
774
|
-
error?: {
|
|
775
|
-
name: string;
|
|
776
|
-
message: string;
|
|
777
|
-
stack?: string;
|
|
778
|
-
};
|
|
779
|
-
data?: Record<string, any>;
|
|
780
|
-
context?: Record<string, any>;
|
|
781
|
-
}
|
|
782
|
-
type ColorTheme = {
|
|
783
|
-
trace: string;
|
|
784
|
-
debug: string;
|
|
785
|
-
info: string;
|
|
786
|
-
warn: string;
|
|
787
|
-
error: string;
|
|
788
|
-
critical: string;
|
|
789
|
-
reset: string;
|
|
790
|
-
bold: string;
|
|
791
|
-
dim: string;
|
|
792
|
-
blue: string;
|
|
793
|
-
cyan: string;
|
|
794
|
-
gray: string;
|
|
795
|
-
};
|
|
796
|
-
declare class LogPrinter {
|
|
797
|
-
private strategy;
|
|
798
|
-
private colors;
|
|
799
|
-
constructor(options: {
|
|
800
|
-
strategy: PrintStrategy$1;
|
|
801
|
-
useColors: boolean;
|
|
802
|
-
colorTheme?: Partial<ColorTheme>;
|
|
803
|
-
});
|
|
804
|
-
print(log: PrintableLog): void;
|
|
805
|
-
private pickWriter;
|
|
806
|
-
private formatTime;
|
|
807
|
-
private formatLevel;
|
|
808
|
-
private formatSource;
|
|
809
|
-
private formatMessage;
|
|
810
|
-
private formatError;
|
|
811
|
-
private formatData;
|
|
812
|
-
private formatContext;
|
|
813
|
-
private normalizeForJson;
|
|
814
|
-
private static NO_COLORS;
|
|
815
|
-
private static readonly DEFAULT_WRITERS;
|
|
816
|
-
private static writers;
|
|
817
|
-
static setWriters(writers: Partial<{
|
|
818
|
-
log: (msg: any) => void;
|
|
819
|
-
error?: (msg: any) => void;
|
|
820
|
-
}>): void;
|
|
821
|
-
static resetWriters(): void;
|
|
822
|
-
}
|
|
823
|
-
|
|
824
|
-
type LogLevels = "trace" | "debug" | "info" | "warn" | "error" | "critical";
|
|
825
|
-
interface ILogInfo {
|
|
826
|
-
source?: string;
|
|
827
|
-
error?: unknown | Error;
|
|
828
|
-
data?: Record<string, any>;
|
|
829
|
-
context?: Record<string, any>;
|
|
830
|
-
[key: string]: any;
|
|
831
|
-
}
|
|
832
|
-
interface ILog {
|
|
833
|
-
level: LogLevels;
|
|
834
|
-
source?: string;
|
|
835
|
-
message: any;
|
|
836
|
-
timestamp: Date;
|
|
837
|
-
error?: {
|
|
838
|
-
name: string;
|
|
839
|
-
message: string;
|
|
840
|
-
stack?: string;
|
|
841
|
-
};
|
|
842
|
-
data?: Record<string, any>;
|
|
843
|
-
context?: Record<string, any>;
|
|
844
|
-
}
|
|
845
|
-
type PrintStrategy = PrintStrategy$1;
|
|
846
|
-
declare class Logger {
|
|
847
|
-
private printThreshold;
|
|
848
|
-
private printStrategy;
|
|
849
|
-
private bufferLogs;
|
|
850
|
-
private buffer;
|
|
851
|
-
private boundContext;
|
|
852
|
-
private isLocked;
|
|
853
|
-
private useColors;
|
|
854
|
-
private printer;
|
|
855
|
-
private source?;
|
|
856
|
-
private rootLogger?;
|
|
857
|
-
localListeners: Array<(log: ILog) => void | Promise<void>>;
|
|
858
|
-
static Severity: {
|
|
859
|
-
trace: number;
|
|
860
|
-
debug: number;
|
|
861
|
-
info: number;
|
|
862
|
-
warn: number;
|
|
863
|
-
error: number;
|
|
864
|
-
critical: number;
|
|
865
|
-
};
|
|
866
|
-
constructor(options: {
|
|
867
|
-
printThreshold: null | LogLevels;
|
|
868
|
-
printStrategy: PrintStrategy;
|
|
869
|
-
bufferLogs: boolean;
|
|
870
|
-
useColors?: boolean;
|
|
871
|
-
}, boundContext?: Record<string, any>, source?: string, printer?: LogPrinter);
|
|
872
|
-
private detectColorSupport;
|
|
873
|
-
/**
|
|
874
|
-
* Creates a new logger instance with additional bound context
|
|
875
|
-
*/
|
|
876
|
-
with({ source, additionalContext: context, }: {
|
|
877
|
-
source?: string;
|
|
878
|
-
additionalContext?: Record<string, any>;
|
|
879
|
-
}): Logger;
|
|
880
|
-
/**
|
|
881
|
-
* Core logging method with structured LogInfo
|
|
882
|
-
*/
|
|
883
|
-
log(level: LogLevels, message: any, logInfo?: ILogInfo): Promise<void>;
|
|
884
|
-
private extractErrorInfo;
|
|
885
|
-
info(message: any, logInfo?: ILogInfo): Promise<void>;
|
|
886
|
-
error(message: any, logInfo?: ILogInfo): Promise<void>;
|
|
887
|
-
warn(message: any, logInfo?: ILogInfo): Promise<void>;
|
|
888
|
-
debug(message: any, logInfo?: ILogInfo): Promise<void>;
|
|
889
|
-
trace(message: any, logInfo?: ILogInfo): Promise<void>;
|
|
890
|
-
critical(message: any, logInfo?: ILogInfo): Promise<void>;
|
|
891
|
-
/**
|
|
892
|
-
* Direct print for tests and advanced scenarios. Delegates to LogPrinter.
|
|
893
|
-
*/
|
|
894
|
-
print(log: ILog): void;
|
|
895
|
-
/**
|
|
896
|
-
* @param listener - A listener that will be triggered for every log.
|
|
897
|
-
*/
|
|
898
|
-
onLog(listener: (log: ILog) => any): void;
|
|
899
|
-
/**
|
|
900
|
-
* Marks the logger as ready.
|
|
901
|
-
* This is used to trigger the local listeners and print the buffered logs (if they exists)
|
|
902
|
-
* @returns A promise that resolves when the logger is ready.
|
|
903
|
-
*/
|
|
904
|
-
lock(): Promise<void>;
|
|
905
|
-
private canPrint;
|
|
906
|
-
private triggerLogListeners;
|
|
907
|
-
}
|
|
908
|
-
|
|
909
|
-
type UnhandledErrorKind = "process" | "task" | "middleware" | "resourceInit" | "hook" | "run";
|
|
910
|
-
interface OnUnhandledErrorInfo {
|
|
911
|
-
error: unknown;
|
|
912
|
-
kind?: UnhandledErrorKind;
|
|
913
|
-
source?: string;
|
|
914
|
-
}
|
|
915
|
-
type OnUnhandledError = (info: OnUnhandledErrorInfo) => void | Promise<void>;
|
|
916
|
-
declare function createDefaultUnhandledError(logger: Logger): OnUnhandledError;
|
|
917
|
-
declare function bindProcessErrorHandler(handler: OnUnhandledError): (error: unknown, source: "uncaughtException" | "unhandledRejection") => void | Promise<void>;
|
|
918
|
-
declare function safeReportUnhandledError(handler: OnUnhandledError, info: OnUnhandledErrorInfo): Promise<void>;
|
|
919
|
-
|
|
920
|
-
type RunOptions = {
|
|
921
|
-
/**
|
|
922
|
-
* Defaults to undefined. If true, we introduce logging to the console.
|
|
923
|
-
*/
|
|
924
|
-
debug?: DebugFriendlyConfig;
|
|
925
|
-
/**
|
|
926
|
-
* Configure logging settings.
|
|
927
|
-
*/
|
|
928
|
-
logs?: {
|
|
929
|
-
/**
|
|
930
|
-
* Defaults to info. Use null to disable logging.
|
|
931
|
-
*/
|
|
932
|
-
printThreshold?: null | LogLevels;
|
|
933
|
-
/**
|
|
934
|
-
* Defaults to PRETTY. How to print the logs.
|
|
935
|
-
*/
|
|
936
|
-
printStrategy?: PrintStrategy;
|
|
937
|
-
/**
|
|
938
|
-
* Defaults to false. If true, we buffer logs until the root resource is ready.
|
|
939
|
-
* This provides you with the chance to see the logs before the root resource is ready.
|
|
940
|
-
*/
|
|
941
|
-
bufferLogs?: boolean;
|
|
942
|
-
};
|
|
943
|
-
/**
|
|
944
|
-
* When true (default), installs a central error boundary that catches uncaught errors
|
|
945
|
-
* from process-level events and routes them to `onUnhandledError`.
|
|
946
|
-
*/
|
|
947
|
-
errorBoundary?: boolean;
|
|
948
|
-
/**
|
|
949
|
-
* When true (default), installs SIGINT/SIGTERM handlers that call dispose() on the root allowing for graceful shutdown.
|
|
950
|
-
*/
|
|
951
|
-
shutdownHooks?: boolean;
|
|
952
|
-
/**
|
|
953
|
-
* Custom handler for any unhandled error caught by Runner. Defaults to logging via the created logger.
|
|
954
|
-
*/
|
|
955
|
-
onUnhandledError?: OnUnhandledError;
|
|
956
|
-
/**
|
|
957
|
-
* Defaults to false.
|
|
958
|
-
*
|
|
959
|
-
* Dry run mode. When true, the runner will setup the system, ensure there are no errors, but will not start the system.
|
|
960
|
-
* Your resources will not be initialized, and no events will be emitted. This is useful for testing and debugging.
|
|
961
|
-
*
|
|
962
|
-
* Note: this cannot catch init() errors that happen within resources.
|
|
963
|
-
*/
|
|
964
|
-
dryRun?: boolean;
|
|
965
|
-
/**
|
|
966
|
-
* Defaults to true.
|
|
967
|
-
* When set, forces runtime cycle detection for event emissions. Disable if you're sure
|
|
968
|
-
* you don't have event deadlocks to improve event emission performance.
|
|
969
|
-
*/
|
|
970
|
-
runtimeEventCycleDetection?: boolean;
|
|
971
|
-
/**
|
|
972
|
-
* Specify in which mode to run "dev", "prod" or "test".
|
|
973
|
-
* If inside Node this is automatically detected from the NODE_ENV environment variable if not provided.
|
|
974
|
-
*/
|
|
975
|
-
mode?: RunnerMode;
|
|
976
|
-
};
|
|
977
|
-
/**
|
|
978
|
-
* The mode in which the runner is operating
|
|
979
|
-
*/
|
|
980
|
-
declare enum RunnerMode {
|
|
981
|
-
TEST = "test",
|
|
982
|
-
DEV = "dev",
|
|
983
|
-
PROD = "prod"
|
|
984
|
-
}
|
|
985
|
-
|
|
986
|
-
interface ICacheInstance {
|
|
987
|
-
set(key: string, value: any): void;
|
|
988
|
-
get(key: string): any;
|
|
989
|
-
clear(): void;
|
|
990
|
-
/** Optional presence check to disambiguate cached undefined values */
|
|
991
|
-
has?(key: string): boolean;
|
|
992
|
-
}
|
|
993
|
-
|
|
994
|
-
type ResourceStoreElementType<C = any, V extends Promise<any> = any, D extends DependencyMapType = {}, TContext = any> = {
|
|
995
|
-
resource: IResource<C, V, D>;
|
|
996
|
-
computedDependencies?: ResourceDependencyValuesType<D>;
|
|
997
|
-
config: C;
|
|
998
|
-
value: V;
|
|
999
|
-
context: TContext;
|
|
1000
|
-
isInitialized?: boolean;
|
|
1001
|
-
};
|
|
1002
|
-
type TaskStoreElementType<Input = any, Output extends Promise<any> = any, D extends DependencyMapType = any> = {
|
|
1003
|
-
task: ITask<Input, Output, D>;
|
|
1004
|
-
computedDependencies: DependencyValuesType<D>;
|
|
1005
|
-
isInitialized: boolean;
|
|
1006
|
-
interceptors?: Array<TaskLocalInterceptor<any, any>>;
|
|
1007
|
-
};
|
|
1008
|
-
type HookStoreElementType<D extends DependencyMapType = any, TOn extends "*" | IEventDefinition = any> = {
|
|
1009
|
-
hook: IHook<D, TOn>;
|
|
1010
|
-
computedDependencies: DependencyValuesType<D>;
|
|
1011
|
-
};
|
|
1012
|
-
type TaskMiddlewareStoreElementType<TDeps extends DependencyMapType = any> = {
|
|
1013
|
-
middleware: ITaskMiddleware<any, TDeps>;
|
|
1014
|
-
computedDependencies: DependencyValuesType<TDeps>;
|
|
1015
|
-
isInitialized: boolean;
|
|
1016
|
-
};
|
|
1017
|
-
type ResourceMiddlewareStoreElementType<TDeps extends DependencyMapType = any> = {
|
|
1018
|
-
middleware: IResourceMiddleware<any, TDeps>;
|
|
1019
|
-
computedDependencies: DependencyValuesType<TDeps>;
|
|
1020
|
-
isInitialized: boolean;
|
|
1021
|
-
};
|
|
1022
|
-
type EventStoreElementType = {
|
|
1023
|
-
event: IEvent<any>;
|
|
1024
|
-
};
|
|
1025
|
-
|
|
1026
|
-
/**
|
|
1027
|
-
* Core public TypeScript types for BlueLibs Runner.
|
|
1028
|
-
*
|
|
1029
|
-
* This file contains the strongly-typed contract for tasks, resources, events
|
|
1030
|
-
* and middleware. It mirrors the mental model described in the README:
|
|
1031
|
-
* - Tasks are functions
|
|
1032
|
-
* - Resources are singletons (with init/dispose hooks)
|
|
1033
|
-
* - Hooks are event listeners without middleware
|
|
1034
|
-
* - Events are simple, strongly-typed emissions
|
|
1035
|
-
* - Middleware can target both tasks and resources (taskMiddleware, resourceMiddleware)
|
|
1036
|
-
*
|
|
1037
|
-
* DX goals:
|
|
1038
|
-
* - Crystal‑clear generics and helper types that infer dependency shapes
|
|
1039
|
-
* - Friendly JSDoc you can hover in editors to understand usage instantly
|
|
1040
|
-
* - Safe overrides and strong typing around config and register mechanics
|
|
1041
|
-
*/
|
|
1042
|
-
|
|
1043
|
-
type defs_CommonPayload<T extends readonly IEventDefinition<any>[] | IEventDefinition<any>> = CommonPayload<T>;
|
|
1044
|
-
type defs_DefaultErrorType = DefaultErrorType;
|
|
1045
|
-
type defs_DependencyMapType = DependencyMapType;
|
|
1046
|
-
type defs_DependencyValueType<T> = DependencyValueType<T>;
|
|
1047
|
-
type defs_DependencyValuesType<T extends DependencyMapType> = DependencyValuesType<T>;
|
|
1048
|
-
type defs_ErrorReference = ErrorReference;
|
|
1049
|
-
type defs_EventHandlerType<T = any> = EventHandlerType<T>;
|
|
1050
|
-
type defs_EventStoreElementType = EventStoreElementType;
|
|
1051
|
-
type defs_ExtractEventPayload<T> = ExtractEventPayload<T>;
|
|
1052
|
-
type defs_ExtractResourceConfig<T> = ExtractResourceConfig<T>;
|
|
1053
|
-
type defs_ExtractResourceValue<T> = ExtractResourceValue<T>;
|
|
1054
|
-
type defs_ExtractTaskInput<T> = ExtractTaskInput<T>;
|
|
1055
|
-
type defs_ExtractTaskOutput<T> = ExtractTaskOutput<T>;
|
|
1056
|
-
type defs_HookStoreElementType<D extends DependencyMapType = any, TOn extends "*" | IEventDefinition = any> = HookStoreElementType<D, TOn>;
|
|
1057
|
-
type defs_IAsyncContext<T> = IAsyncContext<T>;
|
|
1058
|
-
type defs_IAsyncContextDefinition<T> = IAsyncContextDefinition<T>;
|
|
1059
|
-
type defs_IAsyncContextMeta = IAsyncContextMeta;
|
|
1060
|
-
type defs_ICacheInstance = ICacheInstance;
|
|
1061
|
-
type defs_IErrorDefinition<TData extends DefaultErrorType = DefaultErrorType> = IErrorDefinition<TData>;
|
|
1062
|
-
type defs_IErrorDefinitionFinal<TData extends DefaultErrorType> = IErrorDefinitionFinal<TData>;
|
|
1063
|
-
type defs_IErrorHelper<TData extends DefaultErrorType = DefaultErrorType> = IErrorHelper<TData>;
|
|
1064
|
-
type defs_IErrorMeta = IErrorMeta;
|
|
1065
|
-
type defs_IEvent<TPayload = any> = IEvent<TPayload>;
|
|
1066
|
-
type defs_IEventDefinition<TPayload = void> = IEventDefinition<TPayload>;
|
|
1067
|
-
type defs_IEventEmission<TPayload = any> = IEventEmission<TPayload>;
|
|
1068
|
-
type defs_IEventMeta = IEventMeta;
|
|
1069
|
-
type defs_IHook<TDependencies extends DependencyMapType = {}, TOn extends OnType = any, TMeta extends ITaskMeta = any> = IHook<TDependencies, TOn, TMeta>;
|
|
1070
|
-
type defs_IHookDefinition<TDependencies extends DependencyMapType = {}, TOn extends OnType = any, TMeta extends ITaskMeta = any> = IHookDefinition<TDependencies, TOn, TMeta>;
|
|
1071
|
-
type defs_IMeta = IMeta;
|
|
1072
|
-
type defs_IMiddlewareMeta = IMiddlewareMeta;
|
|
1073
|
-
type defs_IOptionalDependency<T> = IOptionalDependency<T>;
|
|
1074
|
-
type defs_IPhantomTask<TInput = any, TResolved = any, TDependencies extends DependencyMapType = {}, TMeta extends ITaskMeta = any, TTags extends TagType[] = TagType[], TMiddleware extends TaskMiddlewareAttachmentType[] = TaskMiddlewareAttachmentType[]> = IPhantomTask<TInput, TResolved, TDependencies, TMeta, TTags, TMiddleware>;
|
|
1075
|
-
type defs_IResource<TConfig = void, TValue extends Promise<any> = Promise<any>, TDependencies extends DependencyMapType = any, TContext = any, TMeta extends IResourceMeta = any, TTags extends TagType[] = TagType[], TMiddleware extends ResourceMiddlewareAttachmentType[] = ResourceMiddlewareAttachmentType[]> = IResource<TConfig, TValue, TDependencies, TContext, TMeta, TTags, TMiddleware>;
|
|
1076
|
-
type defs_IResourceDefinition<TConfig = any, TValue extends Promise<any> = Promise<any>, TDependencies extends DependencyMapType = {}, TContext = any, _THooks = any, _TRegisterableItems = any, TMeta extends IResourceMeta = any, TTags extends TagType[] = TagType[], TMiddleware extends ResourceMiddlewareAttachmentType[] = ResourceMiddlewareAttachmentType[]> = IResourceDefinition<TConfig, TValue, TDependencies, TContext, _THooks, _TRegisterableItems, TMeta, TTags, TMiddleware>;
|
|
1077
|
-
type defs_IResourceMeta = IResourceMeta;
|
|
1078
|
-
type defs_IResourceMiddleware<TConfig = any, TEnforceInputContract = void, TEnforceOutputContract = void, TDependencies extends DependencyMapType = any> = IResourceMiddleware<TConfig, TEnforceInputContract, TEnforceOutputContract, TDependencies>;
|
|
1079
|
-
type defs_IResourceMiddlewareConfigured<TConfig = any, TEnforceInputContract = void, TEnforceOutputContract = void, TDependencies extends DependencyMapType = any> = IResourceMiddlewareConfigured<TConfig, TEnforceInputContract, TEnforceOutputContract, TDependencies>;
|
|
1080
|
-
type defs_IResourceMiddlewareDefinition<TConfig = any, TEnforceInputContract = void, TEnforceOutputContract = void, TDependencies extends DependencyMapType = any> = IResourceMiddlewareDefinition<TConfig, TEnforceInputContract, TEnforceOutputContract, TDependencies>;
|
|
1081
|
-
type defs_IResourceMiddlewareExecutionInput<TResourceConfig = any, TResourceOutput = any> = IResourceMiddlewareExecutionInput<TResourceConfig, TResourceOutput>;
|
|
1082
|
-
type defs_IResourceWithConfig<TConfig = any, TValue extends Promise<any> = Promise<any>, TDependencies extends DependencyMapType = any, TContext = any, TMeta extends IResourceMeta = any, TTags extends TagType[] = TagType[], TMiddleware extends IResourceMiddleware<any, any, any, any>[] = IResourceMiddleware[]> = IResourceWithConfig<TConfig, TValue, TDependencies, TContext, TMeta, TTags, TMiddleware>;
|
|
1083
|
-
type defs_ITag<TConfig = void, TEnforceInputContract = void, TEnforceOutputContract = void> = ITag<TConfig, TEnforceInputContract, TEnforceOutputContract>;
|
|
1084
|
-
type defs_ITagConfigured<TConfig = void, TEnforceInputContract = void, TEnforceOutputContract = void> = ITagConfigured<TConfig, TEnforceInputContract, TEnforceOutputContract>;
|
|
1085
|
-
type defs_ITagDefinition<TConfig = void, _TEnforceInputContract = void, _TEnforceOutputContract = void> = ITagDefinition<TConfig, _TEnforceInputContract, _TEnforceOutputContract>;
|
|
1086
|
-
type defs_ITagMeta = ITagMeta;
|
|
1087
|
-
type defs_ITaggable = ITaggable;
|
|
1088
|
-
type defs_ITask<TInput = any, TOutput extends Promise<any> = any, TDependencies extends DependencyMapType = {}, TMeta extends ITaskMeta = any, TTags extends TagType[] = TagType[], TMiddleware extends TaskMiddlewareAttachmentType[] = TaskMiddlewareAttachmentType[]> = ITask<TInput, TOutput, TDependencies, TMeta, TTags, TMiddleware>;
|
|
1089
|
-
type defs_ITaskDefinition<TInput = undefined, TOutput extends Promise<any> = any, TDependencies extends DependencyMapType = {}, TMeta extends ITaskMeta = any, TTags extends TagType[] = TagType[], TMiddleware extends TaskMiddlewareAttachmentType[] = TaskMiddlewareAttachmentType[]> = ITaskDefinition<TInput, TOutput, TDependencies, TMeta, TTags, TMiddleware>;
|
|
1090
|
-
type defs_ITaskMeta = ITaskMeta;
|
|
1091
|
-
type defs_ITaskMiddleware<TConfig = any, TEnforceInputContract = void, TEnforceOutputContract = void, TDependencies extends DependencyMapType = any> = ITaskMiddleware<TConfig, TEnforceInputContract, TEnforceOutputContract, TDependencies>;
|
|
1092
|
-
type defs_ITaskMiddlewareConfigured<TConfig = any, TEnforceInputContract = void, TEnforceOutputContract = void, TDependencies extends DependencyMapType = any> = ITaskMiddlewareConfigured<TConfig, TEnforceInputContract, TEnforceOutputContract, TDependencies>;
|
|
1093
|
-
type defs_ITaskMiddlewareDefinition<TConfig = any, TEnforceInputContract = void, TEnforceOutputContract = void, TDependencies extends DependencyMapType = any> = ITaskMiddlewareDefinition<TConfig, TEnforceInputContract, TEnforceOutputContract, TDependencies>;
|
|
1094
|
-
type defs_ITaskMiddlewareExecutionInput<TTaskInput = any, TTaskOutput = any> = ITaskMiddlewareExecutionInput<TTaskInput, TTaskOutput>;
|
|
1095
|
-
type defs_IValidationSchema<T = any> = IValidationSchema<T>;
|
|
1096
|
-
type defs_OverridableElements = OverridableElements;
|
|
1097
|
-
type defs_RegisterableItems = RegisterableItems;
|
|
1098
|
-
type defs_RequiredKeys<T> = RequiredKeys<T>;
|
|
1099
|
-
type defs_ResourceDependencyValueType<T> = ResourceDependencyValueType<T>;
|
|
1100
|
-
type defs_ResourceDependencyValuesType<T extends DependencyMapType> = ResourceDependencyValuesType<T>;
|
|
1101
|
-
type defs_ResourceForkInfo = ResourceForkInfo;
|
|
1102
|
-
type defs_ResourceForkOptions = ResourceForkOptions;
|
|
1103
|
-
type defs_ResourceForkRegisterMode = ResourceForkRegisterMode;
|
|
1104
|
-
type defs_ResourceInitFn<TConfig, TValue extends Promise<any>, TDependencies extends DependencyMapType, TContext, TMeta extends IResourceMeta, TTags extends TagType[], TMiddleware extends ResourceMiddlewareAttachmentType[]> = ResourceInitFn<TConfig, TValue, TDependencies, TContext, TMeta, TTags, TMiddleware>;
|
|
1105
|
-
type defs_ResourceMiddlewareAttachmentType = ResourceMiddlewareAttachmentType;
|
|
1106
|
-
type defs_ResourceMiddlewareStoreElementType<TDeps extends DependencyMapType = any> = ResourceMiddlewareStoreElementType<TDeps>;
|
|
1107
|
-
type defs_ResourceStoreElementType<C = any, V extends Promise<any> = any, D extends DependencyMapType = {}, TContext = any> = ResourceStoreElementType<C, V, D, TContext>;
|
|
1108
|
-
type defs_RunOptions = RunOptions;
|
|
1109
|
-
type defs_RunnerMode = RunnerMode;
|
|
1110
|
-
declare const defs_RunnerMode: typeof RunnerMode;
|
|
1111
|
-
type defs_TagType = TagType;
|
|
1112
|
-
type defs_TaskCallOptions = TaskCallOptions;
|
|
1113
|
-
type defs_TaskDependencyWithIntercept<TInput, TOutput> = TaskDependencyWithIntercept<TInput, TOutput>;
|
|
1114
|
-
type defs_TaskLocalInterceptor<TInput, TOutput> = TaskLocalInterceptor<TInput, TOutput>;
|
|
1115
|
-
type defs_TaskMiddlewareAttachmentType = TaskMiddlewareAttachmentType;
|
|
1116
|
-
type defs_TaskMiddlewareStoreElementType<TDeps extends DependencyMapType = any> = TaskMiddlewareStoreElementType<TDeps>;
|
|
1117
|
-
type defs_TaskStoreElementType<Input = any, Output extends Promise<any> = any, D extends DependencyMapType = any> = TaskStoreElementType<Input, Output, D>;
|
|
1118
|
-
type defs_ThrowsList = ThrowsList;
|
|
1119
|
-
type defs_UnionToIntersection<U> = UnionToIntersection<U>;
|
|
1120
|
-
declare const defs_isOneOf: typeof isOneOf;
|
|
1121
|
-
declare const defs_onAnyOf: typeof onAnyOf;
|
|
1122
|
-
declare const defs_symbolAsyncContext: typeof symbolAsyncContext;
|
|
1123
|
-
declare const defs_symbolError: typeof symbolError;
|
|
1124
|
-
declare const defs_symbolEvent: typeof symbolEvent;
|
|
1125
|
-
declare const defs_symbolFilePath: typeof symbolFilePath;
|
|
1126
|
-
declare const defs_symbolHook: typeof symbolHook;
|
|
1127
|
-
declare const defs_symbolMiddleware: typeof symbolMiddleware;
|
|
1128
|
-
declare const defs_symbolMiddlewareConfigured: typeof symbolMiddlewareConfigured;
|
|
1129
|
-
declare const defs_symbolOptionalDependency: typeof symbolOptionalDependency;
|
|
1130
|
-
declare const defs_symbolPhantomTask: typeof symbolPhantomTask;
|
|
1131
|
-
declare const defs_symbolResource: typeof symbolResource;
|
|
1132
|
-
declare const defs_symbolResourceForkedFrom: typeof symbolResourceForkedFrom;
|
|
1133
|
-
declare const defs_symbolResourceMiddleware: typeof symbolResourceMiddleware;
|
|
1134
|
-
declare const defs_symbolResourceWithConfig: typeof symbolResourceWithConfig;
|
|
1135
|
-
declare const defs_symbolTag: typeof symbolTag;
|
|
1136
|
-
declare const defs_symbolTagConfigured: typeof symbolTagConfigured;
|
|
1137
|
-
declare const defs_symbolTask: typeof symbolTask;
|
|
1138
|
-
declare const defs_symbolTaskMiddleware: typeof symbolTaskMiddleware;
|
|
1139
|
-
declare const defs_symbolTunneledBy: typeof symbolTunneledBy;
|
|
1140
|
-
declare namespace defs {
|
|
1141
|
-
export { type defs_CommonPayload as CommonPayload, type defs_DefaultErrorType as DefaultErrorType, type defs_DependencyMapType as DependencyMapType, type defs_DependencyValueType as DependencyValueType, type defs_DependencyValuesType as DependencyValuesType, type defs_ErrorReference as ErrorReference, type defs_EventHandlerType as EventHandlerType, type defs_EventStoreElementType as EventStoreElementType, type defs_ExtractEventPayload as ExtractEventPayload, type defs_ExtractResourceConfig as ExtractResourceConfig, type defs_ExtractResourceValue as ExtractResourceValue, type defs_ExtractTaskInput as ExtractTaskInput, type defs_ExtractTaskOutput as ExtractTaskOutput, type defs_HookStoreElementType as HookStoreElementType, type defs_IAsyncContext as IAsyncContext, type defs_IAsyncContextDefinition as IAsyncContextDefinition, type defs_IAsyncContextMeta as IAsyncContextMeta, type defs_ICacheInstance as ICacheInstance, type defs_IErrorDefinition as IErrorDefinition, type defs_IErrorDefinitionFinal as IErrorDefinitionFinal, type defs_IErrorHelper as IErrorHelper, type defs_IErrorMeta as IErrorMeta, type defs_IEvent as IEvent, type defs_IEventDefinition as IEventDefinition, type defs_IEventEmission as IEventEmission, type defs_IEventMeta as IEventMeta, type defs_IHook as IHook, type defs_IHookDefinition as IHookDefinition, type defs_IMeta as IMeta, type defs_IMiddlewareMeta as IMiddlewareMeta, type defs_IOptionalDependency as IOptionalDependency, type defs_IPhantomTask as IPhantomTask, type defs_IResource as IResource, type defs_IResourceDefinition as IResourceDefinition, type defs_IResourceMeta as IResourceMeta, type defs_IResourceMiddleware as IResourceMiddleware, type defs_IResourceMiddlewareConfigured as IResourceMiddlewareConfigured, type defs_IResourceMiddlewareDefinition as IResourceMiddlewareDefinition, type defs_IResourceMiddlewareExecutionInput as IResourceMiddlewareExecutionInput, type defs_IResourceWithConfig as IResourceWithConfig, type defs_ITag as ITag, type defs_ITagConfigured as ITagConfigured, type defs_ITagDefinition as ITagDefinition, type defs_ITagMeta as ITagMeta, type defs_ITaggable as ITaggable, type defs_ITask as ITask, type defs_ITaskDefinition as ITaskDefinition, type defs_ITaskMeta as ITaskMeta, type defs_ITaskMiddleware as ITaskMiddleware, type defs_ITaskMiddlewareConfigured as ITaskMiddlewareConfigured, type defs_ITaskMiddlewareDefinition as ITaskMiddlewareDefinition, type defs_ITaskMiddlewareExecutionInput as ITaskMiddlewareExecutionInput, type defs_IValidationSchema as IValidationSchema, type defs_OverridableElements as OverridableElements, type defs_RegisterableItems as RegisterableItems, type defs_RequiredKeys as RequiredKeys, type defs_ResourceDependencyValueType as ResourceDependencyValueType, type defs_ResourceDependencyValuesType as ResourceDependencyValuesType, type defs_ResourceForkInfo as ResourceForkInfo, type defs_ResourceForkOptions as ResourceForkOptions, type defs_ResourceForkRegisterMode as ResourceForkRegisterMode, type defs_ResourceInitFn as ResourceInitFn, type defs_ResourceMiddlewareAttachmentType as ResourceMiddlewareAttachmentType, type defs_ResourceMiddlewareStoreElementType as ResourceMiddlewareStoreElementType, type defs_ResourceStoreElementType as ResourceStoreElementType, type defs_RunOptions as RunOptions, defs_RunnerMode as RunnerMode, type defs_TagType as TagType, type defs_TaskCallOptions as TaskCallOptions, type defs_TaskDependencyWithIntercept as TaskDependencyWithIntercept, type defs_TaskLocalInterceptor as TaskLocalInterceptor, type defs_TaskMiddlewareAttachmentType as TaskMiddlewareAttachmentType, type defs_TaskMiddlewareStoreElementType as TaskMiddlewareStoreElementType, type defs_TaskStoreElementType as TaskStoreElementType, type defs_ThrowsList as ThrowsList, type defs_UnionToIntersection as UnionToIntersection, defs_isOneOf as isOneOf, defs_onAnyOf as onAnyOf, defs_symbolAsyncContext as symbolAsyncContext, defs_symbolError as symbolError, defs_symbolEvent as symbolEvent, defs_symbolFilePath as symbolFilePath, defs_symbolHook as symbolHook, defs_symbolMiddleware as symbolMiddleware, defs_symbolMiddlewareConfigured as symbolMiddlewareConfigured, defs_symbolOptionalDependency as symbolOptionalDependency, defs_symbolPhantomTask as symbolPhantomTask, defs_symbolResource as symbolResource, defs_symbolResourceForkedFrom as symbolResourceForkedFrom, defs_symbolResourceMiddleware as symbolResourceMiddleware, defs_symbolResourceWithConfig as symbolResourceWithConfig, defs_symbolTag as symbolTag, defs_symbolTagConfigured as symbolTagConfigured, defs_symbolTask as symbolTask, defs_symbolTaskMiddleware as symbolTaskMiddleware, defs_symbolTunneledBy as symbolTunneledBy };
|
|
1142
|
-
}
|
|
1143
|
-
|
|
1144
|
-
interface TaskMiddlewareFluentBuilder<C = any, In = void, Out = void, D extends DependencyMapType = {}> {
|
|
1145
|
-
id: string;
|
|
1146
|
-
dependencies<TNewDeps extends DependencyMapType>(deps: TNewDeps | ((config: C) => TNewDeps), options?: {
|
|
1147
|
-
override?: false;
|
|
1148
|
-
}): TaskMiddlewareFluentBuilder<C, In, Out, D & TNewDeps>;
|
|
1149
|
-
dependencies<TNewDeps extends DependencyMapType>(deps: TNewDeps | ((config: C) => TNewDeps), options: {
|
|
1150
|
-
override: true;
|
|
1151
|
-
}): TaskMiddlewareFluentBuilder<C, In, Out, TNewDeps>;
|
|
1152
|
-
configSchema<TNew>(schema: IValidationSchema<TNew>): TaskMiddlewareFluentBuilder<TNew, In, Out, D>;
|
|
1153
|
-
run(fn: ITaskMiddlewareDefinition<C, In, Out, D>["run"]): TaskMiddlewareFluentBuilder<C, In, Out, D>;
|
|
1154
|
-
meta<TNewMeta extends IMiddlewareMeta>(m: TNewMeta): TaskMiddlewareFluentBuilder<C, In, Out, D>;
|
|
1155
|
-
tags<TNewTags extends TagType[]>(t: TNewTags, options?: {
|
|
1156
|
-
override?: boolean;
|
|
1157
|
-
}): TaskMiddlewareFluentBuilder<C, In, Out, D>;
|
|
1158
|
-
everywhere(flag: boolean | ((task: ITask<any, any, any, any>) => boolean)): TaskMiddlewareFluentBuilder<C, In, Out, D>;
|
|
1159
|
-
build(): ITaskMiddleware<C, In, Out, D>;
|
|
1160
|
-
}
|
|
1161
|
-
|
|
1162
|
-
interface ResourceMiddlewareFluentBuilder<C = any, In = void, Out = void, D extends DependencyMapType = {}> {
|
|
1163
|
-
id: string;
|
|
1164
|
-
dependencies<TNewDeps extends DependencyMapType>(deps: TNewDeps | ((config: C) => TNewDeps), options?: {
|
|
1165
|
-
override?: false;
|
|
1166
|
-
}): ResourceMiddlewareFluentBuilder<C, In, Out, D & TNewDeps>;
|
|
1167
|
-
dependencies<TNewDeps extends DependencyMapType>(deps: TNewDeps | ((config: C) => TNewDeps), options: {
|
|
1168
|
-
override: true;
|
|
1169
|
-
}): ResourceMiddlewareFluentBuilder<C, In, Out, TNewDeps>;
|
|
1170
|
-
configSchema<TNew>(schema: IValidationSchema<TNew>): ResourceMiddlewareFluentBuilder<TNew, In, Out, D>;
|
|
1171
|
-
run(fn: IResourceMiddlewareDefinition<C, In, Out, D>["run"]): ResourceMiddlewareFluentBuilder<C, In, Out, D>;
|
|
1172
|
-
meta<TNewMeta extends IMiddlewareMeta>(m: TNewMeta): ResourceMiddlewareFluentBuilder<C, In, Out, D>;
|
|
1173
|
-
tags<TNewTags extends TagType[]>(t: TNewTags, options?: {
|
|
1174
|
-
override?: boolean;
|
|
1175
|
-
}): ResourceMiddlewareFluentBuilder<C, In, Out, D>;
|
|
1176
|
-
everywhere(flag: boolean | ((resource: IResource<any, any, any, any, any>) => boolean)): ResourceMiddlewareFluentBuilder<C, In, Out, D>;
|
|
1177
|
-
build(): IResourceMiddleware<C, In, Out, D>;
|
|
1178
|
-
}
|
|
1179
|
-
|
|
1180
|
-
/**
|
|
1181
|
-
* Entry point for creating a task middleware builder.
|
|
1182
|
-
*/
|
|
1183
|
-
declare function taskMiddlewareBuilder<C = void, In = void, Out = void, D extends DependencyMapType = {}>(id: string): TaskMiddlewareFluentBuilder<C, In, Out, D>;
|
|
1184
|
-
/**
|
|
1185
|
-
* Entry point for creating a resource middleware builder.
|
|
1186
|
-
*/
|
|
1187
|
-
declare function resourceMiddlewareBuilder<C = void, In = void, Out = void, D extends DependencyMapType = {}>(id: string): ResourceMiddlewareFluentBuilder<C, In, Out, D>;
|
|
1188
|
-
|
|
1189
|
-
interface ErrorFluentBuilder<TData extends DefaultErrorType = DefaultErrorType> {
|
|
1190
|
-
id: string;
|
|
1191
|
-
serialize(fn: (data: TData) => string): ErrorFluentBuilder<TData>;
|
|
1192
|
-
parse(fn: (raw: string) => TData): ErrorFluentBuilder<TData>;
|
|
1193
|
-
dataSchema(schema: IValidationSchema<TData>): ErrorFluentBuilder<TData>;
|
|
1194
|
-
build(): IErrorHelper<TData>;
|
|
1195
|
-
format(fn: (data: TData) => string): ErrorFluentBuilder<TData>;
|
|
1196
|
-
meta<TNewMeta extends IErrorMeta>(m: TNewMeta): ErrorFluentBuilder<TData>;
|
|
1197
|
-
}
|
|
1198
|
-
|
|
1199
|
-
/**
|
|
1200
|
-
* Entry point for creating an error builder.
|
|
1201
|
-
*/
|
|
1202
|
-
declare function errorBuilder<TData extends DefaultErrorType = DefaultErrorType>(id: string): ErrorFluentBuilder<TData>;
|
|
1203
|
-
|
|
1204
|
-
interface AsyncContextFluentBuilder<T = unknown> {
|
|
1205
|
-
id: string;
|
|
1206
|
-
serialize(fn: (data: T) => string): AsyncContextFluentBuilder<T>;
|
|
1207
|
-
parse(fn: (raw: string) => T): AsyncContextFluentBuilder<T>;
|
|
1208
|
-
configSchema(schema: IValidationSchema<T>): AsyncContextFluentBuilder<T>;
|
|
1209
|
-
meta<TNewMeta extends IAsyncContextMeta>(m: TNewMeta): AsyncContextFluentBuilder<T>;
|
|
1210
|
-
build(): IAsyncContext<T>;
|
|
1211
|
-
}
|
|
1212
|
-
|
|
1213
|
-
/**
|
|
1214
|
-
* Entry point for creating an async context builder.
|
|
1215
|
-
*/
|
|
1216
|
-
declare function asyncContextBuilder<T = unknown>(id: string): AsyncContextFluentBuilder<T>;
|
|
1217
|
-
|
|
1218
|
-
interface TagFluentBuilder<TConfig = void, TEnforceIn = void, TEnforceOut = void> {
|
|
1219
|
-
id: string;
|
|
1220
|
-
meta<TNewMeta extends ITagMeta>(m: TNewMeta): TagFluentBuilder<TConfig, TEnforceIn, TEnforceOut>;
|
|
1221
|
-
configSchema<TNewConfig>(schema: IValidationSchema<TNewConfig>): TagFluentBuilder<TNewConfig, TEnforceIn, TEnforceOut>;
|
|
1222
|
-
config<TNewConfig>(config: TNewConfig): TagFluentBuilder<TNewConfig, TEnforceIn, TEnforceOut>;
|
|
1223
|
-
build(): ITag<TConfig, TEnforceIn, TEnforceOut>;
|
|
1224
|
-
}
|
|
1225
|
-
|
|
1226
|
-
/**
|
|
1227
|
-
* Entry point for creating a tag builder.
|
|
1228
|
-
*/
|
|
1229
|
-
declare function tagBuilder<TConfig = void, TEnforceIn = void, TEnforceOut = void>(id: string): TagFluentBuilder<TConfig, TEnforceIn, TEnforceOut>;
|
|
1230
|
-
|
|
1231
|
-
/** Valid event targets for hook's .on() method */
|
|
1232
|
-
type ValidOnTarget = "*" | IEventDefinition<any> | readonly IEventDefinition<any>[];
|
|
1233
|
-
/** Resolved TOn when valid, or `any` when undefined (build will throw at runtime) */
|
|
1234
|
-
type ResolvedOn<TOn> = TOn extends ValidOnTarget ? TOn : any;
|
|
1235
|
-
interface HookFluentBuilder<TDeps extends DependencyMapType = {}, TOn extends ValidOnTarget | undefined = undefined, TMeta extends ITaskMeta = ITaskMeta> {
|
|
1236
|
-
id: string;
|
|
1237
|
-
on<TNewOn extends ValidOnTarget>(on: TNewOn): HookFluentBuilder<TDeps, TNewOn, TMeta>;
|
|
1238
|
-
order(order: number): HookFluentBuilder<TDeps, TOn, TMeta>;
|
|
1239
|
-
dependencies<TNewDeps extends DependencyMapType>(deps: TNewDeps | (() => TNewDeps), options?: {
|
|
1240
|
-
override?: false;
|
|
1241
|
-
}): HookFluentBuilder<TDeps & TNewDeps, TOn, TMeta>;
|
|
1242
|
-
dependencies<TNewDeps extends DependencyMapType>(deps: TNewDeps | (() => TNewDeps), options: {
|
|
1243
|
-
override: true;
|
|
1244
|
-
}): HookFluentBuilder<TNewDeps, TOn, TMeta>;
|
|
1245
|
-
tags<TNewTags extends TagType[]>(t: TNewTags, options?: {
|
|
1246
|
-
override?: boolean;
|
|
1247
|
-
}): HookFluentBuilder<TDeps, TOn, TMeta>;
|
|
1248
|
-
meta<TNewMeta extends ITaskMeta>(m: TNewMeta): HookFluentBuilder<TDeps, TOn, TNewMeta>;
|
|
1249
|
-
/** Set the hook's run handler. Required before build(). */
|
|
1250
|
-
run(fn: IHookDefinition<TDeps, ResolvedOn<TOn>, TMeta>["run"]): HookFluentBuilder<TDeps, TOn, TMeta>;
|
|
1251
|
-
/**
|
|
1252
|
-
* Build the hook definition. Requires .on() and .run() to be called first.
|
|
1253
|
-
* @throws {Error} if on or run are not set
|
|
1254
|
-
*/
|
|
1255
|
-
build(): IHook<TDeps, ResolvedOn<TOn>, TMeta>;
|
|
1256
|
-
}
|
|
1257
|
-
|
|
1258
|
-
/**
|
|
1259
|
-
* Entry point for creating a hook builder.
|
|
1260
|
-
* Requires calling .on() and .run() before .build().
|
|
1261
|
-
*/
|
|
1262
|
-
declare function hookBuilder(id: string): HookFluentBuilder<{}, undefined, ITaskMeta>;
|
|
1263
|
-
|
|
1264
|
-
interface EventFluentBuilder<TPayload = void> {
|
|
1265
|
-
id: string;
|
|
1266
|
-
payloadSchema<TNew>(schema: IValidationSchema<TNew>): EventFluentBuilder<TNew>;
|
|
1267
|
-
tags<TNewTags extends TagType[]>(t: TNewTags, options?: {
|
|
1268
|
-
override?: boolean;
|
|
1269
|
-
}): EventFluentBuilder<TPayload>;
|
|
1270
|
-
meta<TNewMeta extends IEventMeta>(m: TNewMeta): EventFluentBuilder<TPayload>;
|
|
1271
|
-
/**
|
|
1272
|
-
* Enable parallel execution for this event's listeners.
|
|
1273
|
-
* When enabled, listeners with the same `order` run concurrently within a batch.
|
|
1274
|
-
* Batches execute sequentially in ascending order priority.
|
|
1275
|
-
*
|
|
1276
|
-
* @param enabled - Whether to enable parallel execution (default: true)
|
|
1277
|
-
*/
|
|
1278
|
-
parallel(enabled?: boolean): EventFluentBuilder<TPayload>;
|
|
1279
|
-
build(): IEvent<TPayload>;
|
|
1280
|
-
}
|
|
1281
|
-
|
|
1282
|
-
/**
|
|
1283
|
-
* Entry point for creating an event builder.
|
|
1284
|
-
*/
|
|
1285
|
-
declare function eventBuilder<TPayload = void>(id: string): EventFluentBuilder<TPayload>;
|
|
1286
|
-
|
|
1287
|
-
type ShouldReplaceInput<T> = [T] extends [undefined] ? true : [T] extends [void] ? true : 0 extends 1 & T ? true : false;
|
|
1288
|
-
type ResolveInput<TExisting, TProposed> = ShouldReplaceInput<TExisting> extends true ? TProposed : TExisting;
|
|
1289
|
-
|
|
1290
|
-
/**
|
|
1291
|
-
* Fluent builder interface for constructing tasks.
|
|
1292
|
-
*/
|
|
1293
|
-
interface TaskFluentBuilder<TInput = undefined, TOutput extends Promise<any> = Promise<any>, TDeps extends DependencyMapType = {}, TMeta extends ITaskMeta = ITaskMeta, TTags extends TagType[] = TagType[], TMiddleware extends TaskMiddlewareAttachmentType[] = TaskMiddlewareAttachmentType[]> {
|
|
1294
|
-
id: string;
|
|
1295
|
-
dependencies<TNewDeps extends DependencyMapType>(deps: TNewDeps | (() => TNewDeps), options?: {
|
|
1296
|
-
override?: false;
|
|
1297
|
-
}): TaskFluentBuilder<TInput, TOutput, TDeps & TNewDeps, TMeta, TTags, TMiddleware>;
|
|
1298
|
-
dependencies<TNewDeps extends DependencyMapType>(deps: TNewDeps | (() => TNewDeps), options: {
|
|
1299
|
-
override: true;
|
|
1300
|
-
}): TaskFluentBuilder<TInput, TOutput, TNewDeps, TMeta, TTags, TMiddleware>;
|
|
1301
|
-
middleware<TNewMw extends TaskMiddlewareAttachmentType[]>(mw: TNewMw, options?: {
|
|
1302
|
-
override?: boolean;
|
|
1303
|
-
}): TaskFluentBuilder<TInput, TOutput, TDeps, TMeta, TTags, TNewMw>;
|
|
1304
|
-
tags<TNewTags extends TagType[]>(t: TNewTags, options?: {
|
|
1305
|
-
override?: false;
|
|
1306
|
-
}): TaskFluentBuilder<TInput, TOutput, TDeps, TMeta, [
|
|
1307
|
-
...TTags,
|
|
1308
|
-
...TNewTags
|
|
1309
|
-
], TMiddleware>;
|
|
1310
|
-
tags<TNewTags extends TagType[]>(t: TNewTags, options: {
|
|
1311
|
-
override: true;
|
|
1312
|
-
}): TaskFluentBuilder<TInput, TOutput, TDeps, TMeta, TNewTags, TMiddleware>;
|
|
1313
|
-
inputSchema<TNewInput>(schema: IValidationSchema<TNewInput>): TaskFluentBuilder<TNewInput, TOutput, TDeps, TMeta, TTags, TMiddleware>;
|
|
1314
|
-
resultSchema<TResolved>(schema: IValidationSchema<TResolved>): TaskFluentBuilder<TInput, Promise<TResolved>, TDeps, TMeta, TTags, TMiddleware>;
|
|
1315
|
-
run<TNewInput = TInput, TNewOutput extends Promise<any> = TOutput>(fn: NonNullable<ITaskDefinition<ResolveInput<TInput, TNewInput>, TNewOutput, TDeps, TMeta, TTags, TMiddleware>["run"]>): TaskFluentBuilder<ResolveInput<TInput, TNewInput>, TNewOutput, TDeps, TMeta, TTags, TMiddleware>;
|
|
1316
|
-
throws(list: ThrowsList): TaskFluentBuilder<TInput, TOutput, TDeps, TMeta, TTags, TMiddleware>;
|
|
1317
|
-
meta<TNewMeta extends ITaskMeta>(m: TNewMeta): TaskFluentBuilder<TInput, TOutput, TDeps, TNewMeta, TTags, TMiddleware>;
|
|
1318
|
-
build(): ITask<TInput, TOutput, TDeps, TMeta, TTags, TMiddleware>;
|
|
1319
|
-
}
|
|
1320
|
-
|
|
1321
|
-
/**
|
|
1322
|
-
* Fluent builder interface for constructing phantom tasks.
|
|
1323
|
-
*/
|
|
1324
|
-
interface PhantomTaskFluentBuilder<TInput = undefined, TResolved = any, TDeps extends DependencyMapType = {}, TMeta extends ITaskMeta = ITaskMeta, TTags extends TagType[] = TagType[], TMiddleware extends TaskMiddlewareAttachmentType[] = TaskMiddlewareAttachmentType[]> {
|
|
1325
|
-
id: string;
|
|
1326
|
-
dependencies<TNewDeps extends DependencyMapType>(deps: TNewDeps | (() => TNewDeps), options?: {
|
|
1327
|
-
override?: false;
|
|
1328
|
-
}): PhantomTaskFluentBuilder<TInput, TResolved, TDeps & TNewDeps, TMeta, TTags, TMiddleware>;
|
|
1329
|
-
dependencies<TNewDeps extends DependencyMapType>(deps: TNewDeps | (() => TNewDeps), options: {
|
|
1330
|
-
override: true;
|
|
1331
|
-
}): PhantomTaskFluentBuilder<TInput, TResolved, TNewDeps, TMeta, TTags, TMiddleware>;
|
|
1332
|
-
middleware<TNewMw extends TaskMiddlewareAttachmentType[]>(mw: TNewMw, options?: {
|
|
1333
|
-
override?: boolean;
|
|
1334
|
-
}): PhantomTaskFluentBuilder<TInput, TResolved, TDeps, TMeta, TTags, TNewMw>;
|
|
1335
|
-
tags<TNewTags extends TagType[]>(t: TNewTags, options?: {
|
|
1336
|
-
override?: false;
|
|
1337
|
-
}): PhantomTaskFluentBuilder<TInput, TResolved, TDeps, TMeta, [
|
|
1338
|
-
...TTags,
|
|
1339
|
-
...TNewTags
|
|
1340
|
-
], TMiddleware>;
|
|
1341
|
-
tags<TNewTags extends TagType[]>(t: TNewTags, options: {
|
|
1342
|
-
override: true;
|
|
1343
|
-
}): PhantomTaskFluentBuilder<TInput, TResolved, TDeps, TMeta, TNewTags, TMiddleware>;
|
|
1344
|
-
inputSchema<TNewInput>(schema: IValidationSchema<TNewInput>): PhantomTaskFluentBuilder<TNewInput, TResolved, TDeps, TMeta, TTags, TMiddleware>;
|
|
1345
|
-
resultSchema<TNewResolved>(schema: IValidationSchema<TNewResolved>): PhantomTaskFluentBuilder<TInput, TNewResolved, TDeps, TMeta, TTags, TMiddleware>;
|
|
1346
|
-
meta<TNewMeta extends ITaskMeta>(m: TNewMeta): PhantomTaskFluentBuilder<TInput, TResolved, TDeps, TNewMeta, TTags, TMiddleware>;
|
|
1347
|
-
throws(list: ThrowsList): PhantomTaskFluentBuilder<TInput, TResolved, TDeps, TMeta, TTags, TMiddleware>;
|
|
1348
|
-
build(): IPhantomTask<TInput, TResolved, TDeps, TMeta, TTags, TMiddleware>;
|
|
1349
|
-
}
|
|
1350
|
-
|
|
1351
|
-
/**
|
|
1352
|
-
* Entry point for creating a phantom task builder.
|
|
1353
|
-
*/
|
|
1354
|
-
declare function phantomTaskBuilder<TInput = undefined, TResolved = any>(id: string): PhantomTaskFluentBuilder<TInput, TResolved, {}, ITaskMeta, TagType[], TaskMiddlewareAttachmentType[]>;
|
|
1355
|
-
interface TaskBuilderWithPhantom {
|
|
1356
|
-
(id: string): TaskFluentBuilder<undefined, Promise<any>, {}, ITaskMeta, TagType[], TaskMiddlewareAttachmentType[]>;
|
|
1357
|
-
phantom: typeof phantomTaskBuilder;
|
|
1358
|
-
}
|
|
1359
|
-
|
|
1360
|
-
/**
|
|
1361
|
-
* Helper type to determine if config should be replaced.
|
|
1362
|
-
*/
|
|
1363
|
-
type ShouldReplaceConfig<T> = [T] extends [void] ? true : [T] extends [undefined] ? true : false;
|
|
1364
|
-
/**
|
|
1365
|
-
* Resolves the config type - uses proposed if existing is void/undefined.
|
|
1366
|
-
*/
|
|
1367
|
-
type ResolveConfig<TExisting, TProposed> = ShouldReplaceConfig<TExisting> extends true ? TProposed : TExisting;
|
|
1368
|
-
|
|
1369
|
-
/**
|
|
1370
|
-
* Fluent builder interface for constructing resources.
|
|
1371
|
-
* Each method returns a new builder with updated type parameters.
|
|
1372
|
-
*/
|
|
1373
|
-
interface ResourceFluentBuilder<TConfig = void, TValue extends Promise<any> = Promise<any>, TDeps extends DependencyMapType = {}, TContext = any, TMeta extends IResourceMeta = IResourceMeta, TTags extends TagType[] = TagType[], TMiddleware extends ResourceMiddlewareAttachmentType[] = ResourceMiddlewareAttachmentType[]> {
|
|
1374
|
-
id: string;
|
|
1375
|
-
dependencies<TNewDeps extends DependencyMapType>(deps: TNewDeps | ((config: TConfig) => TNewDeps), options?: {
|
|
1376
|
-
override?: false;
|
|
1377
|
-
}): ResourceFluentBuilder<TConfig, TValue, TDeps & TNewDeps, TContext, TMeta, TTags, TMiddleware>;
|
|
1378
|
-
dependencies<TNewDeps extends DependencyMapType>(deps: TNewDeps | ((config: TConfig) => TNewDeps), options: {
|
|
1379
|
-
override: true;
|
|
1380
|
-
}): ResourceFluentBuilder<TConfig, TValue, TNewDeps, TContext, TMeta, TTags, TMiddleware>;
|
|
1381
|
-
register(items: RegisterableItems | Array<RegisterableItems> | ((config: TConfig) => RegisterableItems | Array<RegisterableItems>), options?: {
|
|
1382
|
-
override?: boolean;
|
|
1383
|
-
}): ResourceFluentBuilder<TConfig, TValue, TDeps, TContext, TMeta, TTags, TMiddleware>;
|
|
1384
|
-
middleware<TNewMw extends ResourceMiddlewareAttachmentType[]>(mw: TNewMw, options?: {
|
|
1385
|
-
override?: boolean;
|
|
1386
|
-
}): ResourceFluentBuilder<TConfig, TValue, TDeps, TContext, TMeta, TTags, TNewMw>;
|
|
1387
|
-
tags<TNewTags extends TagType[]>(tags: TNewTags, options?: {
|
|
1388
|
-
override?: false;
|
|
1389
|
-
}): ResourceFluentBuilder<TConfig, TValue, TDeps, TContext, TMeta, [
|
|
1390
|
-
...TTags,
|
|
1391
|
-
...TNewTags
|
|
1392
|
-
], TMiddleware>;
|
|
1393
|
-
tags<TNewTags extends TagType[]>(tags: TNewTags, options: {
|
|
1394
|
-
override: true;
|
|
1395
|
-
}): ResourceFluentBuilder<TConfig, TValue, TDeps, TContext, TMeta, TNewTags, TMiddleware>;
|
|
1396
|
-
context<TNewCtx>(factory: () => TNewCtx): ResourceFluentBuilder<TConfig, TValue, TDeps, TNewCtx, TMeta, TTags, TMiddleware>;
|
|
1397
|
-
configSchema<TNewConfig>(schema: IValidationSchema<TNewConfig>): ResourceFluentBuilder<TNewConfig, TValue, TDeps, TContext, TMeta, TTags, TMiddleware>;
|
|
1398
|
-
resultSchema<TResolved>(schema: IValidationSchema<TResolved>): ResourceFluentBuilder<TConfig, Promise<TResolved>, TDeps, TContext, TMeta, TTags, TMiddleware>;
|
|
1399
|
-
init<TNewConfig = TConfig, TNewValue extends Promise<any> = TValue>(fn: ResourceInitFn<ResolveConfig<TConfig, TNewConfig>, TNewValue, TDeps, TContext, TMeta, TTags, TMiddleware>): ResourceFluentBuilder<ResolveConfig<TConfig, TNewConfig>, TNewValue, TDeps, TContext, TMeta, TTags, TMiddleware>;
|
|
1400
|
-
dispose(fn: NonNullable<IResourceDefinition<TConfig, TValue, TDeps, TContext, any, any, TMeta, TTags, TMiddleware>["dispose"]>): ResourceFluentBuilder<TConfig, TValue, TDeps, TContext, TMeta, TTags, TMiddleware>;
|
|
1401
|
-
meta<TNewMeta extends IResourceMeta>(m: TNewMeta): ResourceFluentBuilder<TConfig, TValue, TDeps, TContext, TNewMeta, TTags, TMiddleware>;
|
|
1402
|
-
throws(list: ThrowsList): ResourceFluentBuilder<TConfig, TValue, TDeps, TContext, TMeta, TTags, TMiddleware>;
|
|
1403
|
-
overrides(o: Array<OverridableElements>, options?: {
|
|
1404
|
-
override?: boolean;
|
|
1405
|
-
}): ResourceFluentBuilder<TConfig, TValue, TDeps, TContext, TMeta, TTags, TMiddleware>;
|
|
1406
|
-
build(): IResource<TConfig, TValue, TDeps, TContext, TMeta, TTags, TMiddleware>;
|
|
1407
|
-
}
|
|
1408
|
-
|
|
1409
|
-
/**
|
|
1410
|
-
* Creates a new resource builder with the given id.
|
|
1411
|
-
* Overload allows callers to seed the config type at the entry point for convenience.
|
|
1412
|
-
*/
|
|
1413
|
-
declare function resourceBuilder<TConfig = void>(id: string): ResourceFluentBuilder<TConfig, Promise<any>, {}, any, IResourceMeta, TagType[], ResourceMiddlewareAttachmentType[]>;
|
|
1414
|
-
|
|
1415
|
-
/**
|
|
1416
|
-
* Type definitions for the Serializer class
|
|
1417
|
-
*/
|
|
1418
|
-
/**
|
|
1419
|
-
* Definition for a custom type that can be serialized/deserialized
|
|
1420
|
-
*/
|
|
1421
|
-
interface TypeDefinition<TInstance = unknown, TSerialized = unknown> {
|
|
1422
|
-
/** Unique identifier for the type */
|
|
1423
|
-
id: string;
|
|
1424
|
-
/** Predicate function to check if an object matches this type */
|
|
1425
|
-
is: (obj: unknown) => obj is TInstance;
|
|
1426
|
-
/** Function to serialize the object */
|
|
1427
|
-
serialize: (obj: TInstance) => TSerialized;
|
|
1428
|
-
/** Function to deserialize the data back to the original object */
|
|
1429
|
-
deserialize: (data: TSerialized) => TInstance;
|
|
1430
|
-
/** Optional factory used to create a placeholder during deserialization */
|
|
1431
|
-
create?: () => TInstance;
|
|
1432
|
-
/** Serialization strategy: 'value' (inline, no identity) or 'ref' (graph node, identity preserved). Default: 'ref' */
|
|
1433
|
-
strategy?: "value" | "ref";
|
|
1434
|
-
}
|
|
1435
|
-
/** Reference to another object in the serialization */
|
|
1436
|
-
interface ObjectReference {
|
|
1437
|
-
/** Reference to object ID */
|
|
1438
|
-
__ref: string;
|
|
1439
|
-
}
|
|
1440
|
-
/**
|
|
1441
|
-
* Discriminated union describing the serialized graph payload.
|
|
1442
|
-
* Each node captures either an array, plain object, or typed payload.
|
|
1443
|
-
*/
|
|
1444
|
-
type SerializedNode = {
|
|
1445
|
-
kind: "array";
|
|
1446
|
-
value: SerializedValue[];
|
|
1447
|
-
} | {
|
|
1448
|
-
kind: "object";
|
|
1449
|
-
value: Record<string, SerializedValue>;
|
|
1450
|
-
} | {
|
|
1451
|
-
kind: "type";
|
|
1452
|
-
type: string;
|
|
1453
|
-
value: SerializedValue;
|
|
1454
|
-
};
|
|
1455
|
-
/**
|
|
1456
|
-
* Serialization context for tracking object references
|
|
1457
|
-
*/
|
|
1458
|
-
interface SerializationContext {
|
|
1459
|
-
/** Map of objects to their IDs */
|
|
1460
|
-
objectIds: WeakMap<object, string>;
|
|
1461
|
-
/** Counter for generating unique IDs */
|
|
1462
|
-
idCounter: number;
|
|
1463
|
-
/** Number of graph nodes recorded */
|
|
1464
|
-
nodeCount: number;
|
|
1465
|
-
/** Nodes collected during serialization (id -> serialized node) */
|
|
1466
|
-
nodes: Record<string, SerializedNode>;
|
|
1467
|
-
}
|
|
1468
|
-
/**
|
|
1469
|
-
* Deserialization context used when materialising a graph payload.
|
|
1470
|
-
*/
|
|
1471
|
-
interface DeserializationContext {
|
|
1472
|
-
nodes: Record<string, SerializedNode>;
|
|
1473
|
-
resolved: Map<string, unknown>;
|
|
1474
|
-
resolving: Set<string>;
|
|
1475
|
-
/**
|
|
1476
|
-
* Tracks reference ids that were requested while still being resolved.
|
|
1477
|
-
* Used to detect circular references that rely on placeholders.
|
|
1478
|
-
*/
|
|
1479
|
-
resolvingRefs: Set<string>;
|
|
1480
|
-
}
|
|
1481
|
-
/**
|
|
1482
|
-
* Union type for serialized values
|
|
1483
|
-
*/
|
|
1484
|
-
type JsonPrimitive = string | number | boolean | null;
|
|
1485
|
-
interface SerializedTypeRecord {
|
|
1486
|
-
__type: string;
|
|
1487
|
-
value: SerializedValue;
|
|
1488
|
-
}
|
|
1489
|
-
type SerializedValue = JsonPrimitive | ObjectReference | SerializedTypeRecord | SerializedValue[] | {
|
|
1490
|
-
[key: string]: SerializedValue;
|
|
1491
|
-
};
|
|
1492
|
-
declare enum SymbolPolicy {
|
|
1493
|
-
AllowAll = "AllowAll",
|
|
1494
|
-
WellKnownOnly = "WellKnownOnly",
|
|
1495
|
-
Disabled = "Disabled"
|
|
1496
|
-
}
|
|
1497
|
-
/**
|
|
1498
|
-
* Main serializer options
|
|
1499
|
-
*/
|
|
1500
|
-
interface SerializerOptions {
|
|
1501
|
-
/** Whether to pretty-print JSON (for debugging) */
|
|
1502
|
-
pretty?: boolean;
|
|
1503
|
-
/** Maximum recursion depth allowed during serialize/deserialize */
|
|
1504
|
-
maxDepth?: number;
|
|
1505
|
-
/** Restrict deserialization to this list of type IDs */
|
|
1506
|
-
allowedTypes?: readonly string[];
|
|
1507
|
-
/** Controls which Symbol payloads may be deserialized */
|
|
1508
|
-
symbolPolicy?: SymbolPolicy;
|
|
1509
|
-
/** Maximum accepted RegExp pattern length during deserialization */
|
|
1510
|
-
maxRegExpPatternLength?: number;
|
|
1511
|
-
/** Allow RegExp patterns that fail the safety heuristic */
|
|
1512
|
-
allowUnsafeRegExp?: boolean;
|
|
1513
|
-
}
|
|
1514
|
-
/**
|
|
1515
|
-
* Minimal serializer contract used across transports and persistence.
|
|
1516
|
-
* Implementations must be able to round-trip JSON-compatible payloads and
|
|
1517
|
-
* should support custom value types via `addType`.
|
|
1518
|
-
*/
|
|
1519
|
-
interface SerializerLike {
|
|
1520
|
-
stringify(value: unknown): string;
|
|
1521
|
-
parse<T = unknown>(text: string): T;
|
|
1522
|
-
addType?<TJson = unknown, TInstance = unknown>(name: string, factory: (json: TJson) => TInstance): void;
|
|
1523
|
-
}
|
|
1524
|
-
|
|
1525
|
-
/**
|
|
1526
|
-
* Graph-aware serializer/deserializer with circular reference
|
|
1527
|
-
* handling and pluggable type support.
|
|
1528
|
-
*
|
|
1529
|
-
* Internal protocol reference: `readmes/SERIALIZER_PROTOCOL.md`.
|
|
1530
|
-
*/
|
|
1531
|
-
|
|
1532
|
-
declare class Serializer {
|
|
1533
|
-
/** Type registry for managing custom types */
|
|
1534
|
-
private readonly typeRegistry;
|
|
1535
|
-
private readonly runtimeOptions;
|
|
1536
|
-
/** JSON indentation width when pretty printing is enabled */
|
|
1537
|
-
private readonly indent;
|
|
1538
|
-
/** Maximum recursion depth allowed */
|
|
1539
|
-
private readonly maxDepth;
|
|
1540
|
-
/** Maximum allowed RegExp pattern length during deserialization */
|
|
1541
|
-
private readonly maxRegExpPatternLength;
|
|
1542
|
-
/** Allow RegExp patterns that fail the safety heuristic */
|
|
1543
|
-
private readonly allowUnsafeRegExp;
|
|
1544
|
-
/** Disallowed keys that can lead to prototype pollution */
|
|
1545
|
-
private readonly unsafeKeys;
|
|
1546
|
-
constructor(options?: SerializerOptions);
|
|
1547
|
-
/**
|
|
1548
|
-
* Alias of `serialize()` to match the historical tunnel serializer surface.
|
|
1549
|
-
*/
|
|
1550
|
-
stringify<T>(value: T): string;
|
|
1551
|
-
/**
|
|
1552
|
-
* Alias of `deserialize()` to match the historical tunnel serializer surface.
|
|
1553
|
-
*/
|
|
1554
|
-
parse<T = unknown>(payload: string): T;
|
|
1555
|
-
/**
|
|
1556
|
-
* Serialize an arbitrary value into a JSON string.
|
|
1557
|
-
*/
|
|
1558
|
-
serialize<T>(value: T, context?: SerializationContext): string;
|
|
1559
|
-
/**
|
|
1560
|
-
* Deserialize a JSON string back to its original value.
|
|
1561
|
-
*/
|
|
1562
|
-
deserialize<T = unknown>(payload: string): T;
|
|
1563
|
-
/**
|
|
1564
|
-
* Register a custom type for serialization/deserialization.
|
|
1565
|
-
*/
|
|
1566
|
-
addType<TInstance, TSerialized>(typeDef: TypeDefinition<TInstance, TSerialized>): void;
|
|
1567
|
-
addType<TJson = unknown, TInstance = unknown>(name: string, factory: (json: TJson) => TInstance): void;
|
|
1568
|
-
/**
|
|
1569
|
-
* @internal - Exposed for testing RegExp safety validation
|
|
1570
|
-
*/
|
|
1571
|
-
readonly isRegExpPatternSafe: (pattern: string) => boolean;
|
|
1572
|
-
/**
|
|
1573
|
-
* @internal - Exposed for testing quantifier detection
|
|
1574
|
-
*/
|
|
1575
|
-
readonly isQuantifierAt: (pattern: string, index: number) => boolean;
|
|
1576
|
-
/**
|
|
1577
|
-
* @internal - Exposed for testing quantifier character detection
|
|
1578
|
-
*/
|
|
1579
|
-
readonly isQuantifierChar: (char: string, pattern: string, index: number) => boolean;
|
|
1580
|
-
/**
|
|
1581
|
-
* @internal - Exposed for testing bounded quantifier detection
|
|
1582
|
-
*/
|
|
1583
|
-
readonly isBoundedQuantifier: (pattern: string, index: number) => boolean;
|
|
1584
|
-
/**
|
|
1585
|
-
* @internal - Exposed for test compatibility
|
|
1586
|
-
*/
|
|
1587
|
-
toNodeRecord(nodes: Record<string, SerializedNode>): Record<string, SerializedNode>;
|
|
1588
|
-
/**
|
|
1589
|
-
* @internal - Exposed for test compatibility
|
|
1590
|
-
*/
|
|
1591
|
-
deserializeValue(value: SerializedValue, context: DeserializationContext, depth?: number): unknown;
|
|
1592
|
-
/**
|
|
1593
|
-
* @internal - Exposed for test compatibility
|
|
1594
|
-
*/
|
|
1595
|
-
resolveReference(id: string, context: DeserializationContext, depth?: number): unknown;
|
|
1596
|
-
/**
|
|
1597
|
-
* @internal - Exposed for test compatibility
|
|
1598
|
-
*/
|
|
1599
|
-
mergePlaceholder(placeholder: unknown, result: unknown): unknown;
|
|
1600
|
-
/**
|
|
1601
|
-
* @internal - Exposed for test compatibility
|
|
1602
|
-
*/
|
|
1603
|
-
isSerializedTypeRecord(value: unknown): value is {
|
|
1604
|
-
__type: string;
|
|
1605
|
-
value: unknown;
|
|
1606
|
-
};
|
|
1607
|
-
private jsonStringify;
|
|
1608
|
-
}
|
|
1609
|
-
|
|
1610
|
-
/**
|
|
1611
|
-
* Main export module for the Serializer
|
|
1612
|
-
*/
|
|
1613
|
-
|
|
1614
|
-
declare function getDefaultSerializer(): Serializer;
|
|
1615
|
-
|
|
1616
|
-
type TunnelMode = "client" | "server" | "both" | "none";
|
|
1617
|
-
type TunnelTaskSelector = Array<string | ITask<any, any, any, any, any, any>> | ((task: ITask<any, any, any, any, any, any>) => boolean);
|
|
1618
|
-
type TunnelEventSelector = Array<string | IEvent<any>> | ((event: IEvent<any>) => boolean);
|
|
1619
|
-
type EventDeliveryMode = "mirror" | "remote-only" | "local-only" | "remote-first";
|
|
1620
|
-
interface TunnelTagConfig {
|
|
1621
|
-
}
|
|
1622
|
-
type TunnelTaskRunner = (task: ITask<any, any, any, any, any, any>, input?: any) => Promise<any>;
|
|
1623
|
-
interface TunnelRunner {
|
|
1624
|
-
transport?: "http" | string;
|
|
1625
|
-
mode?: TunnelMode;
|
|
1626
|
-
tasks?: TunnelTaskSelector;
|
|
1627
|
-
events?: TunnelEventSelector;
|
|
1628
|
-
eventDeliveryMode?: EventDeliveryMode;
|
|
1629
|
-
run?: TunnelTaskRunner;
|
|
1630
|
-
emit?: (event: IEventEmission<any>) => Promise<any>;
|
|
1631
|
-
}
|
|
1632
|
-
interface ExposureFetchAuthConfig {
|
|
1633
|
-
header?: string;
|
|
1634
|
-
token: string;
|
|
1635
|
-
}
|
|
1636
|
-
interface ExposureFetchConfig {
|
|
1637
|
-
baseUrl: string;
|
|
1638
|
-
auth?: ExposureFetchAuthConfig;
|
|
1639
|
-
timeoutMs?: number;
|
|
1640
|
-
fetchImpl?: typeof fetch;
|
|
1641
|
-
serializer: SerializerLike;
|
|
1642
|
-
onRequest?: (ctx: {
|
|
1643
|
-
url: string;
|
|
1644
|
-
headers: Record<string, string>;
|
|
1645
|
-
}) => void | Promise<void>;
|
|
1646
|
-
contexts?: Array<IAsyncContext<unknown>>;
|
|
1647
|
-
errorRegistry?: Map<string, IErrorHelper<any>>;
|
|
1648
|
-
}
|
|
1649
|
-
interface ExposureFetchClient {
|
|
1650
|
-
task<I = unknown, O = unknown>(id: string, input?: I): Promise<O>;
|
|
1651
|
-
event<P = unknown>(id: string, payload?: P): Promise<void>;
|
|
1652
|
-
/**
|
|
1653
|
-
* Emits an event and returns the final payload as seen by the remote Runner.
|
|
1654
|
-
* Requires server support; older servers will respond with `{ ok: true }`
|
|
1655
|
-
* without `result`, in which case clients should throw.
|
|
1656
|
-
*/
|
|
1657
|
-
eventWithResult?<P = unknown>(id: string, payload?: P): Promise<P>;
|
|
1658
|
-
}
|
|
1659
|
-
|
|
1660
|
-
declare function normalizeError(input: unknown): Error;
|
|
1661
|
-
|
|
1662
|
-
/**
|
|
1663
|
-
* This functions communicates with the exposure server over HTTP.
|
|
1664
|
-
* It uses the @readmes/TUNNEL_HTTP_POLICY.md strategy.
|
|
1665
|
-
*
|
|
1666
|
-
* @param cfg
|
|
1667
|
-
* @returns
|
|
1668
|
-
*/
|
|
1669
|
-
declare function createExposureFetch(cfg: ExposureFetchConfig): ExposureFetchClient;
|
|
1670
|
-
|
|
1671
|
-
interface HttpClientAuthConfig {
|
|
1672
|
-
header?: string;
|
|
1673
|
-
token: string;
|
|
1674
|
-
}
|
|
1675
|
-
interface HttpCreateClientConfig {
|
|
1676
|
-
url: string;
|
|
1677
|
-
auth?: HttpClientAuthConfig;
|
|
1678
|
-
timeoutMs?: number;
|
|
1679
|
-
fetchImpl?: typeof fetch;
|
|
1680
|
-
serializer: SerializerLike;
|
|
1681
|
-
onRequest?: (ctx: {
|
|
1682
|
-
url: string;
|
|
1683
|
-
headers: Record<string, string>;
|
|
1684
|
-
}) => void | Promise<void>;
|
|
1685
|
-
}
|
|
1686
|
-
|
|
1687
|
-
type TunnelMiddlewareId = string | ITaskMiddleware<any, any, any, any>;
|
|
1688
|
-
interface TunnelTaskMiddlewareSidePolicy {
|
|
1689
|
-
/**
|
|
1690
|
-
* Middleware ids/definitions allowed to run on this side when the task is tunneled.
|
|
1691
|
-
* If omitted, defaults to allowing none (caller-side middleware is skipped by default).
|
|
1692
|
-
*/
|
|
1693
|
-
middlewareAllowList?: TunnelMiddlewareId[];
|
|
1694
|
-
}
|
|
1695
|
-
type TunnelTaskMiddlewarePolicySideConfig = TunnelTaskMiddlewareSidePolicy | TunnelMiddlewareId[];
|
|
1696
|
-
interface TunnelTaskMiddlewarePolicyConfig {
|
|
1697
|
-
/**
|
|
1698
|
-
* Preferred configuration shape: explicit per-side allowlist.
|
|
1699
|
-
*/
|
|
1700
|
-
client?: TunnelTaskMiddlewarePolicySideConfig;
|
|
1701
|
-
server?: TunnelTaskMiddlewarePolicySideConfig;
|
|
1702
|
-
/**
|
|
1703
|
-
* Backwards-compatible configuration shape (previous): grouped allowlists.
|
|
1704
|
-
*/
|
|
1705
|
-
middlewareAllowList?: {
|
|
1706
|
-
client?: TunnelMiddlewareId[];
|
|
1707
|
-
server?: TunnelMiddlewareId[];
|
|
1708
|
-
};
|
|
1709
|
-
}
|
|
1710
|
-
|
|
1711
|
-
interface TimeoutMiddlewareConfig {
|
|
1712
|
-
/**
|
|
1713
|
-
* Maximum time in milliseconds before the wrapped operation is aborted
|
|
1714
|
-
* and a timeout error is thrown. Defaults to 5000ms.
|
|
1715
|
-
*/
|
|
1716
|
-
ttl: number;
|
|
1717
|
-
}
|
|
1718
|
-
|
|
1719
|
-
/**
|
|
1720
|
-
* Configuration options for the retry middleware
|
|
1721
|
-
*/
|
|
1722
|
-
interface RetryMiddlewareConfig {
|
|
1723
|
-
/**
|
|
1724
|
-
* Maximum number of retry attempts (default: 3)
|
|
1725
|
-
*/
|
|
1726
|
-
retries?: number;
|
|
1727
|
-
/**
|
|
1728
|
-
* Callback to determine if retry should stop based on error
|
|
1729
|
-
* @default () => false (retry all errors)
|
|
1730
|
-
*/
|
|
1731
|
-
stopRetryIf?: (error: Error) => boolean;
|
|
1732
|
-
/**
|
|
1733
|
-
* Custom delay strategy function
|
|
1734
|
-
* @default Exponential backoff starting at 100ms
|
|
1735
|
-
*/
|
|
1736
|
-
delayStrategy?: (attempt: number, error: Error) => number;
|
|
1737
|
-
}
|
|
1738
|
-
|
|
1739
|
-
interface FallbackMiddlewareConfig {
|
|
1740
|
-
/**
|
|
1741
|
-
* The fallback to use if the task fails.
|
|
1742
|
-
* Can be a value, a function that returns a value (or promise), or another task.
|
|
1743
|
-
*/
|
|
1744
|
-
fallback: any;
|
|
1745
|
-
}
|
|
1746
|
-
|
|
1747
|
-
declare const SemaphoreEvents: {
|
|
1748
|
-
readonly queued: IEvent<SemaphoreEvent>;
|
|
1749
|
-
readonly acquired: IEvent<SemaphoreEvent>;
|
|
1750
|
-
readonly released: IEvent<SemaphoreEvent>;
|
|
1751
|
-
readonly timeout: IEvent<SemaphoreEvent>;
|
|
1752
|
-
readonly aborted: IEvent<SemaphoreEvent>;
|
|
1753
|
-
readonly disposed: IEvent<SemaphoreEvent>;
|
|
1754
|
-
};
|
|
1755
|
-
type SemaphoreEventType = keyof typeof SemaphoreEvents;
|
|
1756
|
-
type SemaphoreEvent = {
|
|
1757
|
-
type: SemaphoreEventType;
|
|
1758
|
-
permits: number;
|
|
1759
|
-
waiting: number;
|
|
1760
|
-
maxPermits: number;
|
|
1761
|
-
disposed: boolean;
|
|
1762
|
-
};
|
|
1763
|
-
/**
|
|
1764
|
-
* A semaphore that limits the number of concurrent operations.
|
|
1765
|
-
* Used to prevent connection pool exhaustion by limiting concurrent
|
|
1766
|
-
* database operations to the pool size.
|
|
1767
|
-
*/
|
|
1768
|
-
declare class Semaphore {
|
|
1769
|
-
private permits;
|
|
1770
|
-
private waitingHead;
|
|
1771
|
-
private waitingTail;
|
|
1772
|
-
private waitingCount;
|
|
1773
|
-
private disposed;
|
|
1774
|
-
private readonly maxPermits;
|
|
1775
|
-
private readonly eventManager;
|
|
1776
|
-
private listenerId;
|
|
1777
|
-
private activeListeners;
|
|
1778
|
-
constructor(maxPermits: number);
|
|
1779
|
-
/**
|
|
1780
|
-
* Acquire a permit. If no permits are available, waits until one becomes available.
|
|
1781
|
-
*/
|
|
1782
|
-
acquire(options?: {
|
|
1783
|
-
timeout?: number;
|
|
1784
|
-
signal?: AbortSignal;
|
|
1785
|
-
}): Promise<void>;
|
|
1786
|
-
/**
|
|
1787
|
-
* Release a permit, allowing waiting operations to proceed.
|
|
1788
|
-
*/
|
|
1789
|
-
release(): void;
|
|
1790
|
-
private removeFromQueue;
|
|
1791
|
-
/**
|
|
1792
|
-
* Execute a function with a permit, automatically releasing it afterwards.
|
|
1793
|
-
*/
|
|
1794
|
-
withPermit<T>(fn: () => Promise<T>, options?: {
|
|
1795
|
-
timeout?: number;
|
|
1796
|
-
signal?: AbortSignal;
|
|
1797
|
-
}): Promise<T>;
|
|
1798
|
-
/**
|
|
1799
|
-
* Dispose the semaphore, rejecting all waiting operations and preventing new ones.
|
|
1800
|
-
*/
|
|
1801
|
-
dispose(): void;
|
|
1802
|
-
/**
|
|
1803
|
-
* Get current number of available permits (for debugging)
|
|
1804
|
-
*/
|
|
1805
|
-
getAvailablePermits(): number;
|
|
1806
|
-
/**
|
|
1807
|
-
* Get current number of waiting operations (for debugging)
|
|
1808
|
-
*/
|
|
1809
|
-
getWaitingCount(): number;
|
|
1810
|
-
/**
|
|
1811
|
-
* Get maximum number of permits
|
|
1812
|
-
*/
|
|
1813
|
-
getMaxPermits(): number;
|
|
1814
|
-
/**
|
|
1815
|
-
* Check if the semaphore has been disposed
|
|
1816
|
-
*/
|
|
1817
|
-
isDisposed(): boolean;
|
|
1818
|
-
/**
|
|
1819
|
-
* Get metrics about the current state of the semaphore
|
|
1820
|
-
*/
|
|
1821
|
-
getMetrics(): {
|
|
1822
|
-
availablePermits: number;
|
|
1823
|
-
waitingCount: number;
|
|
1824
|
-
maxPermits: number;
|
|
1825
|
-
utilization: number;
|
|
1826
|
-
disposed: boolean;
|
|
1827
|
-
};
|
|
1828
|
-
on(type: SemaphoreEventType, handler: (event: SemaphoreEvent) => any): () => void;
|
|
1829
|
-
once(type: SemaphoreEventType, handler: (event: SemaphoreEvent) => any): () => void;
|
|
1830
|
-
private enqueue;
|
|
1831
|
-
private dequeue;
|
|
1832
|
-
private emit;
|
|
1833
|
-
private buildEvent;
|
|
1834
|
-
}
|
|
1835
|
-
|
|
1836
|
-
interface ConcurrencyMiddlewareConfig {
|
|
1837
|
-
/**
|
|
1838
|
-
* Maximum number of concurrent executions.
|
|
1839
|
-
* If provided, a Semaphore will be created and shared for this config object.
|
|
1840
|
-
*/
|
|
1841
|
-
limit?: number;
|
|
1842
|
-
/**
|
|
1843
|
-
* Optional key to identify a shared semaphore.
|
|
1844
|
-
* If provided, the semaphore will be shared across all tasks using the same key.
|
|
1845
|
-
*/
|
|
1846
|
-
key?: string;
|
|
1847
|
-
/**
|
|
1848
|
-
* An existing Semaphore instance to use.
|
|
1849
|
-
*/
|
|
1850
|
-
semaphore?: Semaphore;
|
|
1851
|
-
}
|
|
1852
|
-
|
|
1853
|
-
interface TemporalMiddlewareConfig {
|
|
1854
|
-
ms: number;
|
|
1855
|
-
}
|
|
1856
|
-
interface DebounceState {
|
|
1857
|
-
timeoutId?: NodeJS.Timeout;
|
|
1858
|
-
latestInput?: any;
|
|
1859
|
-
resolveList: ((value: any) => void)[];
|
|
1860
|
-
rejectList: ((error: any) => void)[];
|
|
1861
|
-
}
|
|
1862
|
-
interface ThrottleState {
|
|
1863
|
-
lastExecution: number;
|
|
1864
|
-
timeoutId?: NodeJS.Timeout;
|
|
1865
|
-
latestInput?: any;
|
|
1866
|
-
resolveList: ((value: any) => void)[];
|
|
1867
|
-
rejectList: ((error: any) => void)[];
|
|
1868
|
-
currentPromise?: Promise<any>;
|
|
1869
|
-
}
|
|
1870
|
-
|
|
1871
|
-
/**
|
|
1872
|
-
* States of the Circuit Breaker
|
|
1873
|
-
*/
|
|
1874
|
-
declare enum CircuitBreakerState {
|
|
1875
|
-
CLOSED = "CLOSED",
|
|
1876
|
-
OPEN = "OPEN",
|
|
1877
|
-
HALF_OPEN = "HALF_OPEN"
|
|
1878
|
-
}
|
|
1879
|
-
/**
|
|
1880
|
-
* Configuration for the Circuit Breaker middleware
|
|
1881
|
-
*/
|
|
1882
|
-
interface CircuitBreakerMiddlewareConfig {
|
|
1883
|
-
/**
|
|
1884
|
-
* Number of failures before tripping the circuit
|
|
1885
|
-
* @default 5
|
|
1886
|
-
*/
|
|
1887
|
-
failureThreshold?: number;
|
|
1888
|
-
/**
|
|
1889
|
-
* Time in milliseconds before transitioning from OPEN to HALF_OPEN
|
|
1890
|
-
* @default 30000 (30 seconds)
|
|
1891
|
-
*/
|
|
1892
|
-
resetTimeout?: number;
|
|
1893
|
-
}
|
|
1894
|
-
interface CircuitBreakerStatus {
|
|
1895
|
-
state: CircuitBreakerState;
|
|
1896
|
-
failures: number;
|
|
1897
|
-
lastFailureTime: number;
|
|
1898
|
-
}
|
|
1899
|
-
|
|
1900
|
-
interface RateLimitMiddlewareConfig {
|
|
1901
|
-
/**
|
|
1902
|
-
* Time window in milliseconds
|
|
1903
|
-
*/
|
|
1904
|
-
windowMs: number;
|
|
1905
|
-
/**
|
|
1906
|
-
* Maximum number of requests within the window
|
|
1907
|
-
*/
|
|
1908
|
-
max: number;
|
|
1909
|
-
}
|
|
1910
|
-
interface RateLimitState {
|
|
1911
|
-
count: number;
|
|
1912
|
-
resetTime: number;
|
|
1913
|
-
}
|
|
1914
|
-
|
|
1915
|
-
/**
|
|
1916
|
-
* Options for configuring event listeners.
|
|
1917
|
-
*/
|
|
1918
|
-
interface IEventHandlerOptions<T = any> {
|
|
1919
|
-
order?: number;
|
|
1920
|
-
filter?: (event: IEventEmission<T>) => boolean;
|
|
1921
|
-
/**
|
|
1922
|
-
* Represents the listener ID. Use this to avoid a listener calling itself.
|
|
1923
|
-
*/
|
|
1924
|
-
id?: string;
|
|
1925
|
-
}
|
|
1926
|
-
/**
|
|
1927
|
-
* Interceptor for event emissions.
|
|
1928
|
-
*/
|
|
1929
|
-
type EventEmissionInterceptor = (next: (event: IEventEmission<any>) => Promise<void>, event: IEventEmission<any>) => Promise<void>;
|
|
1930
|
-
/**
|
|
1931
|
-
* Interceptor for hook execution.
|
|
1932
|
-
*/
|
|
1933
|
-
type HookExecutionInterceptor = (next: (hook: IHook<any, any>, event: IEventEmission<any>) => Promise<any>, hook: IHook<any, any>, event: IEventEmission<any>) => Promise<any>;
|
|
1934
|
-
|
|
1935
|
-
/**
|
|
1936
|
-
* EventManager handles event emission, listener registration, and event processing.
|
|
1937
|
-
* It supports both specific event listeners and global listeners that handle all events.
|
|
1938
|
-
* Listeners are processed in order based on their priority.
|
|
1939
|
-
*/
|
|
1940
|
-
declare class EventManager {
|
|
1941
|
-
#private;
|
|
1942
|
-
private listeners;
|
|
1943
|
-
private globalListeners;
|
|
1944
|
-
private cachedMergedListeners;
|
|
1945
|
-
private emissionInterceptors;
|
|
1946
|
-
private hookInterceptors;
|
|
1947
|
-
private readonly registry;
|
|
1948
|
-
private readonly cycleContext;
|
|
1949
|
-
private readonly runtimeEventCycleDetection;
|
|
1950
|
-
constructor(options?: {
|
|
1951
|
-
runtimeEventCycleDetection?: boolean;
|
|
1952
|
-
});
|
|
1953
|
-
/**
|
|
1954
|
-
* Gets the current lock status of the EventManager
|
|
1955
|
-
*/
|
|
1956
|
-
get isLocked(): boolean;
|
|
1957
|
-
/**
|
|
1958
|
-
* Locks the EventManager, preventing any further modifications to listeners
|
|
1959
|
-
*/
|
|
1960
|
-
lock(): void;
|
|
1961
|
-
/**
|
|
1962
|
-
* Emits an event to all registered listeners for that event type.
|
|
1963
|
-
* Listeners are processed in order of priority and can stop event propagation.
|
|
1964
|
-
*
|
|
1965
|
-
* @param eventDefinition - The event definition to emit
|
|
1966
|
-
* @param data - The event payload data
|
|
1967
|
-
* @param source - The source identifier of the event emitter
|
|
1968
|
-
*/
|
|
1969
|
-
emit<TInput>(eventDefinition: IEvent<TInput>, data: TInput, source: string): Promise<void>;
|
|
1970
|
-
/**
|
|
1971
|
-
* Emits an event and returns the final payload.
|
|
1972
|
-
* The payload is taken from the deepest emission object that reached either:
|
|
1973
|
-
* - the base listener executor, or
|
|
1974
|
-
* - an interceptor that short-circuited the emission.
|
|
1975
|
-
*
|
|
1976
|
-
* This enables tunnel transports to return the final payload after local and/or remote delivery.
|
|
1977
|
-
*/
|
|
1978
|
-
emitWithResult<TInput>(eventDefinition: IEvent<TInput>, data: TInput, source: string): Promise<TInput>;
|
|
1979
|
-
private emitAndReturnEmission;
|
|
1980
|
-
/**
|
|
1981
|
-
* Registers an event listener for specific event(s).
|
|
1982
|
-
* Listeners are ordered by priority and executed in ascending order.
|
|
1983
|
-
*
|
|
1984
|
-
* @param event - The event definition(s) to listen for
|
|
1985
|
-
* @param handler - The callback function to handle the event
|
|
1986
|
-
* @param options - Configuration options for the listener
|
|
1987
|
-
*/
|
|
1988
|
-
addListener<T>(event: IEvent<T> | Array<IEvent<T>>, handler: EventHandlerType<T>, options?: IEventHandlerOptions<T>): void;
|
|
1989
|
-
/**
|
|
1990
|
-
* Registers a global event listener that handles all events.
|
|
1991
|
-
* Global listeners are mixed with specific listeners and ordered by priority.
|
|
1992
|
-
*
|
|
1993
|
-
* @param handler - The callback function to handle events
|
|
1994
|
-
* @param options - Configuration options for the listener
|
|
1995
|
-
*/
|
|
1996
|
-
addGlobalListener(handler: EventHandlerType, options?: IEventHandlerOptions): void;
|
|
1997
|
-
/**
|
|
1998
|
-
* Checks if there are any listeners registered for the given event
|
|
1999
|
-
*
|
|
2000
|
-
* @param eventDefinition - The event definition to check
|
|
2001
|
-
* @returns true if listeners exist, false otherwise
|
|
2002
|
-
*/
|
|
2003
|
-
hasListeners<T>(eventDefinition: IEvent<T>): boolean;
|
|
2004
|
-
/**
|
|
2005
|
-
* Adds an interceptor for all event emissions
|
|
2006
|
-
* Interceptors are executed in the order they are added, with the ability to
|
|
2007
|
-
* modify, log, or prevent event emissions
|
|
2008
|
-
*
|
|
2009
|
-
* @param interceptor - The interceptor function to add
|
|
2010
|
-
*/
|
|
2011
|
-
intercept(interceptor: EventEmissionInterceptor): void;
|
|
2012
|
-
/**
|
|
2013
|
-
* Adds an interceptor for hook execution
|
|
2014
|
-
* Interceptors are executed in the order they are added, with the ability to
|
|
2015
|
-
* modify, log, or prevent hook execution
|
|
2016
|
-
*
|
|
2017
|
-
* @param interceptor - The interceptor function to add
|
|
2018
|
-
*/
|
|
2019
|
-
interceptHook(interceptor: HookExecutionInterceptor): void;
|
|
2020
|
-
/**
|
|
2021
|
-
* Executes a hook with all registered hook interceptors applied
|
|
2022
|
-
* This method should be used by TaskRunner when executing hooks
|
|
2023
|
-
*
|
|
2024
|
-
* @param hook - The hook to execute
|
|
2025
|
-
* @param event - The event that triggered the hook
|
|
2026
|
-
* @param computedDependencies - The computed dependencies for the hook
|
|
2027
|
-
* @returns Promise resolving to the hook execution result
|
|
2028
|
-
*/
|
|
2029
|
-
executeHookWithInterceptors(hook: IHook<any, any>, event: IEventEmission<any>, computedDependencies: DependencyValuesType<any>): Promise<any>;
|
|
2030
|
-
/**
|
|
2031
|
-
* Throws an error if the EventManager is locked
|
|
2032
|
-
*/
|
|
2033
|
-
private checkLock;
|
|
2034
|
-
/**
|
|
2035
|
-
* Clears all listeners and interceptors.
|
|
2036
|
-
* Call this to release references and free memory.
|
|
2037
|
-
*/
|
|
2038
|
-
clear(): void;
|
|
2039
|
-
/**
|
|
2040
|
-
* Disposes the EventManager, releasing all listeners and interceptors.
|
|
2041
|
-
* Alias for clear() following the IResource disposal pattern.
|
|
2042
|
-
*/
|
|
2043
|
-
dispose(): void;
|
|
2044
|
-
/**
|
|
2045
|
-
* Retrieves cached merged listeners for an event, or creates them if not cached.
|
|
2046
|
-
* Kept for backward compatibility (tests spy on this).
|
|
2047
|
-
*/
|
|
2048
|
-
private getCachedMergedListeners;
|
|
2049
|
-
}
|
|
2050
|
-
|
|
2051
|
-
declare class TaskRunner {
|
|
2052
|
-
protected readonly store: Store;
|
|
2053
|
-
protected readonly eventManager: EventManager;
|
|
2054
|
-
protected readonly logger: Logger;
|
|
2055
|
-
protected readonly runnerStore: Map<string | symbol, (input: any, journal?: ExecutionJournal) => Promise<any>>;
|
|
2056
|
-
constructor(store: Store, eventManager: EventManager, logger: Logger);
|
|
2057
|
-
private readonly middlewareManager;
|
|
2058
|
-
/**
|
|
2059
|
-
* Begins the execution of an task. These are registered tasks and all sanity checks have been performed at this stage to ensure consistency of the object.
|
|
2060
|
-
* This function can throw only if any of the event listeners or run function throws
|
|
2061
|
-
* @param task the task to be run
|
|
2062
|
-
* @param input the input to be passed to the task
|
|
2063
|
-
* @param options optional call options including journal for forwarding
|
|
2064
|
-
*/
|
|
2065
|
-
run<TInput, TOutput extends Promise<any>, TDeps extends DependencyMapType>(task: ITask<TInput, TOutput, TDeps>, input?: TInput, options?: TaskCallOptions): Promise<TOutput | undefined>;
|
|
2066
|
-
/**
|
|
2067
|
-
* Creates the function with the chain of middleware.
|
|
2068
|
-
* @param task
|
|
2069
|
-
* @param input
|
|
2070
|
-
* @param taskDependencies
|
|
2071
|
-
* @returns
|
|
2072
|
-
*/
|
|
2073
|
-
protected createRunnerWithMiddleware<TInput, TOutput extends Promise<any>, TDeps extends DependencyMapType>(task: ITask<TInput, TOutput, TDeps>): (input: TInput, parentJournal?: ExecutionJournal) => Promise<Awaited<TOutput>>;
|
|
2074
|
-
}
|
|
2075
|
-
|
|
2076
|
-
/**
|
|
2077
|
-
* Interceptor for task middleware execution
|
|
2078
|
-
*/
|
|
2079
|
-
type TaskMiddlewareInterceptor = (next: (input: ITaskMiddlewareExecutionInput<any>) => Promise<any>, input: ITaskMiddlewareExecutionInput<any>) => Promise<any>;
|
|
2080
|
-
/**
|
|
2081
|
-
* Interceptor for resource middleware execution
|
|
2082
|
-
*/
|
|
2083
|
-
type ResourceMiddlewareInterceptor = (next: (input: IResourceMiddlewareExecutionInput<any>) => Promise<any>, input: IResourceMiddlewareExecutionInput<any>) => Promise<any>;
|
|
2084
|
-
|
|
2085
|
-
/**
|
|
2086
|
-
* Centralizes middleware composition and execution for both tasks and resources.
|
|
2087
|
-
* Keeps observability emissions and unhandled error routing consistent.
|
|
2088
|
-
*
|
|
2089
|
-
* This is a facade that delegates to specialized composer classes for maintainability.
|
|
2090
|
-
*/
|
|
2091
|
-
declare class MiddlewareManager {
|
|
2092
|
-
protected readonly store: Store;
|
|
2093
|
-
protected readonly eventManager: EventManager;
|
|
2094
|
-
protected readonly logger: Logger;
|
|
2095
|
-
private readonly interceptorRegistry;
|
|
2096
|
-
private readonly middlewareResolver;
|
|
2097
|
-
private readonly taskComposer;
|
|
2098
|
-
private readonly resourceComposer;
|
|
2099
|
-
constructor(store: Store, eventManager: EventManager, logger: Logger);
|
|
2100
|
-
/**
|
|
2101
|
-
* @internal
|
|
2102
|
-
*/
|
|
2103
|
-
get taskMiddlewareInterceptors(): TaskMiddlewareInterceptor[];
|
|
2104
|
-
/**
|
|
2105
|
-
* @internal
|
|
2106
|
-
*/
|
|
2107
|
-
get resourceMiddlewareInterceptors(): ResourceMiddlewareInterceptor[];
|
|
2108
|
-
/**
|
|
2109
|
-
* Gets the current lock status of the MiddlewareManager
|
|
2110
|
-
*/
|
|
2111
|
-
get isLocked(): boolean;
|
|
2112
|
-
/**
|
|
2113
|
-
* Locks the MiddlewareManager, preventing any further modifications to interceptors
|
|
2114
|
-
*/
|
|
2115
|
-
lock(): void;
|
|
2116
|
-
/**
|
|
2117
|
-
* Adds an interceptor for task or resource middleware execution
|
|
2118
|
-
* Interceptors are executed in the order they are added, with the ability to
|
|
2119
|
-
* modify, log, or prevent middleware execution
|
|
2120
|
-
*
|
|
2121
|
-
* @param kind - The type of middleware to intercept ("task" or "resource")
|
|
2122
|
-
* @param interceptor - The interceptor function to add
|
|
2123
|
-
*/
|
|
2124
|
-
intercept(kind: "task" | "resource", interceptor: TaskMiddlewareInterceptor | ResourceMiddlewareInterceptor): void;
|
|
2125
|
-
/**
|
|
2126
|
-
* Adds an interceptor for a specific middleware instance with better type safety
|
|
2127
|
-
* This method automatically determines the type and provides type-safe access
|
|
2128
|
-
*
|
|
2129
|
-
* @param middleware - The middleware instance to intercept
|
|
2130
|
-
* @param interceptor - The interceptor function with proper typing
|
|
2131
|
-
*/
|
|
2132
|
-
interceptMiddleware(middleware: ITaskMiddleware<any, any, any, any> | IResourceMiddleware<any, any, any, any>, interceptor: TaskMiddlewareInterceptor | ResourceMiddlewareInterceptor): void;
|
|
2133
|
-
/**
|
|
2134
|
-
* Compose a runner for a task with its local interceptors and applicable middlewares.
|
|
2135
|
-
* Returns a function that accepts the task input and resolves to the task output.
|
|
2136
|
-
*/
|
|
2137
|
-
composeTaskRunner<TInput, TOutput extends Promise<any>, TDeps extends DependencyMapType>(task: ITask<TInput, TOutput, TDeps>): (input: TInput, parentJournal?: ExecutionJournal) => Promise<Awaited<TOutput>>;
|
|
2138
|
-
/**
|
|
2139
|
-
* Run a resource init wrapped with its applicable middlewares.
|
|
2140
|
-
*/
|
|
2141
|
-
runResourceInit<C, V extends Promise<any>, D extends DependencyMapType, TContext>(resource: IResource<C, V, D, TContext>, config: C, dependencies: any, context: TContext): Promise<V | undefined>;
|
|
2142
|
-
/**
|
|
2143
|
-
* Gets all "everywhere" middlewares that apply to the given task
|
|
2144
|
-
* @deprecated Internal method exposed for testing - may be removed in future versions
|
|
2145
|
-
*/
|
|
2146
|
-
getEverywhereMiddlewareForTasks(task: ITask<any, any, any>): ITaskMiddleware[];
|
|
2147
|
-
/**
|
|
2148
|
-
* Gets all "everywhere" middlewares that apply to the given resource
|
|
2149
|
-
* @deprecated Internal method exposed for testing - may be removed in future versions
|
|
2150
|
-
*/
|
|
2151
|
-
getEverywhereMiddlewareForResources(resource: IResource<any, any, any, any>): IResourceMiddleware[];
|
|
2152
|
-
}
|
|
2153
|
-
|
|
2154
|
-
/**
|
|
2155
|
-
* Store class which is used to store all the resources, tasks, middleware and events.
|
|
2156
|
-
*/
|
|
2157
|
-
declare class Store {
|
|
2158
|
-
#private;
|
|
2159
|
-
protected readonly eventManager: EventManager;
|
|
2160
|
-
protected readonly logger: Logger;
|
|
2161
|
-
readonly onUnhandledError: OnUnhandledError;
|
|
2162
|
-
root: ResourceStoreElementType;
|
|
2163
|
-
private registry;
|
|
2164
|
-
private overrideManager;
|
|
2165
|
-
private validator;
|
|
2166
|
-
private taskRunner?;
|
|
2167
|
-
private middlewareManager;
|
|
2168
|
-
private readonly initializedResourceIds;
|
|
2169
|
-
mode: RunnerMode;
|
|
2170
|
-
constructor(eventManager: EventManager, logger: Logger, onUnhandledError: OnUnhandledError, mode?: RunnerMode);
|
|
2171
|
-
get tasks(): Map<string, TaskStoreElementType>;
|
|
2172
|
-
get hooks(): Map<string, HookStoreElementType>;
|
|
2173
|
-
get resources(): Map<string, ResourceStoreElementType>;
|
|
2174
|
-
get events(): Map<string, EventStoreElementType>;
|
|
2175
|
-
get errors(): Map<string, IErrorHelper<any>>;
|
|
2176
|
-
get asyncContexts(): Map<string, IAsyncContext<any>>;
|
|
2177
|
-
get taskMiddlewares(): Map<string, TaskMiddlewareStoreElementType>;
|
|
2178
|
-
get resourceMiddlewares(): Map<string, ResourceMiddlewareStoreElementType>;
|
|
2179
|
-
get tags(): Map<string, ITag<void, void, void>>;
|
|
2180
|
-
get overrides(): Map<string, ITask<any, any, {}, any, TagType[], TaskMiddlewareAttachmentType[]> | IResourceMiddleware<any, void, void, any> | IHook<{}, any, any> | IResource<void, Promise<any>, any, any, any, TagType[], ResourceMiddlewareAttachmentType[]> | ITaskMiddleware<any, void, void, any> | IResourceWithConfig<any, Promise<any>, any, any, any, TagType[], IResourceMiddleware<any, void, void, any>[]>>;
|
|
2181
|
-
get overrideRequests(): Set<{
|
|
2182
|
-
source: string;
|
|
2183
|
-
override: RegisterableItems;
|
|
2184
|
-
}>;
|
|
2185
|
-
getMiddlewareManager(): MiddlewareManager;
|
|
2186
|
-
get isLocked(): boolean;
|
|
2187
|
-
lock(): void;
|
|
2188
|
-
checkLock(): void;
|
|
2189
|
-
private registerGlobalComponents;
|
|
2190
|
-
setTaskRunner(taskRunner: TaskRunner): void;
|
|
2191
|
-
private setupRootResource;
|
|
2192
|
-
validateDependencyGraph(): void;
|
|
2193
|
-
validateEventEmissionGraph(): void;
|
|
2194
|
-
initializeStore(root: IResource<any, any, any, any, any>, config: any): void;
|
|
2195
|
-
dispose(): Promise<void>;
|
|
2196
|
-
recordResourceInitialized(resourceId: string): void;
|
|
2197
|
-
private getResourcesInDisposeOrder;
|
|
2198
|
-
/**
|
|
2199
|
-
* Internal, avoid using this method directly.
|
|
2200
|
-
*/
|
|
2201
|
-
processOverrides(): void;
|
|
2202
|
-
/**
|
|
2203
|
-
* Internal, avoid using this method directly.
|
|
2204
|
-
* @param item
|
|
2205
|
-
* @returns
|
|
2206
|
-
*/
|
|
2207
|
-
storeGenericItem<C>(item: RegisterableItems): void;
|
|
2208
|
-
/**
|
|
2209
|
-
* Returns all tasks with the given tag.
|
|
2210
|
-
* @param tag - The tag to filter by.
|
|
2211
|
-
* @returns The tasks with the given tag.
|
|
2212
|
-
*/
|
|
2213
|
-
getTasksWithTag(tag: string | ITag<any, any, any>): ITask<any, any, any, any, TagType[], TaskMiddlewareAttachmentType[]>[];
|
|
2214
|
-
/**
|
|
2215
|
-
* Returns all resources with the given tag.
|
|
2216
|
-
* @param tag - The tag to filter by.
|
|
2217
|
-
* @returns The resources with the given tag.
|
|
2218
|
-
*/
|
|
2219
|
-
getResourcesWithTag(tag: string | ITag<any, any, any>): IResource<any, any, {}, any, any, TagType[], ResourceMiddlewareAttachmentType[]>[];
|
|
2220
|
-
}
|
|
2221
|
-
|
|
2222
|
-
declare class ResourceInitializer {
|
|
2223
|
-
protected readonly store: Store;
|
|
2224
|
-
protected readonly eventManager: EventManager;
|
|
2225
|
-
protected readonly logger: Logger;
|
|
2226
|
-
constructor(store: Store, eventManager: EventManager, logger: Logger);
|
|
2227
|
-
private readonly middlewareManager;
|
|
2228
|
-
/**
|
|
2229
|
-
* Begins the execution of an task. These are registered tasks and all sanity checks have been performed at this stage to ensure consistency of the object.
|
|
2230
|
-
* This function can throw only if any of the event listeners or run function throws
|
|
2231
|
-
*/
|
|
2232
|
-
initializeResource<TConfig = null, TValue extends Promise<any> = Promise<any>, TDeps extends DependencyMapType = {}, TContext = any>(resource: IResource<TConfig, TValue, TDeps>, config: TConfig, dependencies: ResourceDependencyValuesType<TDeps>): Promise<{
|
|
2233
|
-
value: TValue | undefined;
|
|
2234
|
-
context: TContext;
|
|
2235
|
-
}>;
|
|
2236
|
-
initWithMiddleware<C, V extends Promise<any>, D extends DependencyMapType, TContext>(resource: IResource<C, V, D, TContext>, config: C, dependencies: ResourceDependencyValuesType<D>, context: TContext): Promise<V | undefined>;
|
|
2237
|
-
}
|
|
2238
|
-
|
|
2239
|
-
/**
|
|
2240
|
-
* Resolves and caches computed dependencies for store items (resources, tasks, middleware, hooks).
|
|
2241
|
-
*/
|
|
2242
|
-
declare class DependencyProcessor {
|
|
2243
|
-
protected readonly store: Store;
|
|
2244
|
-
protected readonly eventManager: EventManager;
|
|
2245
|
-
protected readonly taskRunner: TaskRunner;
|
|
2246
|
-
protected readonly resourceInitializer: ResourceInitializer;
|
|
2247
|
-
protected readonly logger: Logger;
|
|
2248
|
-
constructor(store: Store, eventManager: EventManager, taskRunner: TaskRunner, logger: Logger);
|
|
2249
|
-
/**
|
|
2250
|
-
* Computes and caches dependencies for all registered store items.
|
|
2251
|
-
*/
|
|
2252
|
-
computeAllDependencies(): Promise<void>;
|
|
2253
|
-
private computeTaskDependencies;
|
|
2254
|
-
initializeUninitializedResources(): Promise<void>;
|
|
2255
|
-
private rethrowResourceInitError;
|
|
2256
|
-
/**
|
|
2257
|
-
* Computes and caches dependencies for a resource (if not already computed).
|
|
2258
|
-
*/
|
|
2259
|
-
protected processResourceDependencies<TD extends DependencyMapType>(resource: ResourceStoreElementType<any, any, TD>): Promise<void>;
|
|
2260
|
-
private wrapResourceDependencies;
|
|
2261
|
-
private makeTaskWithIntercept;
|
|
2262
|
-
initializeRoot(): Promise<void>;
|
|
2263
|
-
/**
|
|
2264
|
-
* Attaches listeners for all hooks. Must run before emitting events.
|
|
2265
|
-
*/
|
|
2266
|
-
attachListeners(): void;
|
|
2267
|
-
extractDependencies<T extends DependencyMapType>(map: T, source: string): Promise<DependencyValuesType<T>>;
|
|
2268
|
-
extractDependency(object: any, source: string): Promise<any>;
|
|
2269
|
-
/**
|
|
2270
|
-
* Converts the event into a running functions with real inputs
|
|
2271
|
-
* @param object
|
|
2272
|
-
* @returns
|
|
2273
|
-
*/
|
|
2274
|
-
extractEventDependency(object: IEvent<any>, source: string): (input: any) => Promise<void>;
|
|
2275
|
-
extractTaskDependency(object: ITask<any, any, {}>): Promise<(input: unknown, options?: TaskCallOptions) => Promise<any>>;
|
|
2276
|
-
extractResourceDependency(object: IResource<any, any, any>): Promise<any>;
|
|
2277
|
-
}
|
|
2278
|
-
|
|
2279
|
-
declare const QueueEvents: {
|
|
2280
|
-
readonly enqueue: IEvent<QueueEvent>;
|
|
2281
|
-
readonly start: IEvent<QueueEvent>;
|
|
2282
|
-
readonly finish: IEvent<QueueEvent>;
|
|
2283
|
-
readonly error: IEvent<QueueEvent>;
|
|
2284
|
-
readonly cancel: IEvent<QueueEvent>;
|
|
2285
|
-
readonly disposed: IEvent<QueueEvent>;
|
|
2286
|
-
};
|
|
2287
|
-
type QueueEventType = keyof typeof QueueEvents;
|
|
2288
|
-
type QueueEvent = {
|
|
2289
|
-
type: QueueEventType;
|
|
2290
|
-
taskId: number;
|
|
2291
|
-
disposed: boolean;
|
|
2292
|
-
error?: Error;
|
|
2293
|
-
};
|
|
2294
|
-
/**
|
|
2295
|
-
* Cooperative task queue.
|
|
2296
|
-
* • Tasks run one‑after‑another (FIFO ordering).
|
|
2297
|
-
* • Dead‑lock detection prevents nesting.
|
|
2298
|
-
* • dispose() drains or cancels outstanding tasks, then rejects new ones.
|
|
2299
|
-
*/
|
|
2300
|
-
declare class Queue {
|
|
2301
|
-
private tail;
|
|
2302
|
-
private disposed;
|
|
2303
|
-
private abortController;
|
|
2304
|
-
private readonly eventManager;
|
|
2305
|
-
private nextTaskId;
|
|
2306
|
-
private listenerId;
|
|
2307
|
-
private activeListeners;
|
|
2308
|
-
private readonly executionContext;
|
|
2309
|
-
private readonly hasAsyncLocalStorage;
|
|
2310
|
-
/**
|
|
2311
|
-
* Schedule an asynchronous task.
|
|
2312
|
-
* @param task – receives an AbortSignal so it can cancel early if desired.
|
|
2313
|
-
*/
|
|
2314
|
-
run<T>(task: (signal: AbortSignal) => Promise<T>): Promise<T>;
|
|
2315
|
-
/**
|
|
2316
|
-
* Disposes the queue.
|
|
2317
|
-
* @param options.cancel – if true, broadcasts AbortSignal to running task.
|
|
2318
|
-
* default: false (waits for tasks to finish).
|
|
2319
|
-
*/
|
|
2320
|
-
dispose(options?: {
|
|
2321
|
-
cancel?: boolean;
|
|
2322
|
-
}): Promise<void>;
|
|
2323
|
-
on(type: QueueEventType, handler: (event: QueueEvent) => any): () => void;
|
|
2324
|
-
once(type: QueueEventType, handler: (event: QueueEvent) => any): () => void;
|
|
2325
|
-
private emit;
|
|
2326
|
-
}
|
|
2327
|
-
|
|
2328
|
-
declare class RunResult<V> {
|
|
2329
|
-
readonly value: V;
|
|
2330
|
-
readonly logger: Logger;
|
|
2331
|
-
readonly store: Store;
|
|
2332
|
-
private readonly eventManager;
|
|
2333
|
-
private readonly taskRunner;
|
|
2334
|
-
private readonly disposeFn;
|
|
2335
|
-
constructor(value: V, logger: Logger, store: Store, eventManager: EventManager, taskRunner: TaskRunner, disposeFn: () => Promise<void>);
|
|
2336
|
-
/**
|
|
2337
|
-
* Run a task within the context of the run result.
|
|
2338
|
-
* @param task - The task to run.
|
|
2339
|
-
* @param args - The arguments to pass to the task.
|
|
2340
|
-
* @returns The result of the task.
|
|
2341
|
-
*/
|
|
2342
|
-
runTask: <I = undefined, O extends Promise<any> = any, D extends DependencyMapType = any>(task: ITask<I, O, D> | string, ...args: I extends undefined | void ? [] : [I]) => Promise<O | undefined>;
|
|
2343
|
-
/**
|
|
2344
|
-
* Emit an event within the context of the run result.
|
|
2345
|
-
* @param event - The event to emit.
|
|
2346
|
-
* @param payload - The payload to emit.
|
|
2347
|
-
*/
|
|
2348
|
-
emitEvent: <P>(event: IEvent<P> | string, payload?: P extends undefined | void ? undefined : P) => Promise<void>;
|
|
2349
|
-
/**
|
|
2350
|
-
* Get the value of a resource from the run result.
|
|
2351
|
-
* @param resource - The resource to get the value of.
|
|
2352
|
-
* @returns The value of the resource.
|
|
2353
|
-
*/
|
|
2354
|
-
getResourceValue: <Output extends Promise<any>>(resource: string | IResource<any, Output, any, any, any>) => Output extends Promise<infer U> ? U : Output;
|
|
2355
|
-
dispose: () => Promise<void>;
|
|
2356
|
-
}
|
|
2357
|
-
|
|
2358
|
-
/**
|
|
2359
|
-
* Define a task.
|
|
2360
|
-
* Generates a strongly-typed task object with id, dependencies,
|
|
2361
|
-
* middleware, and metadata.
|
|
2362
|
-
*
|
|
2363
|
-
* @typeParam Input - Input type accepted by the task's `run` function.
|
|
2364
|
-
* @typeParam Output - Promise type returned by the `run` function.
|
|
2365
|
-
* @typeParam Deps - Dependency map type this task requires.
|
|
2366
|
-
* @typeParam TOn - Event type or "*" this task listens to.
|
|
2367
|
-
* @typeParam TMeta - Arbitrary metadata type carried by the task.
|
|
2368
|
-
* @param taskConfig - The task definition config.
|
|
2369
|
-
* @returns A branded task definition usable by the runner.
|
|
2370
|
-
*/
|
|
2371
|
-
declare function defineTask<Input = undefined, Output extends Promise<any> = any, Deps extends DependencyMapType = any, TMeta extends ITaskMeta = any, TTags extends TagType[] = TagType[], TMiddleware extends TaskMiddlewareAttachmentType[] = TaskMiddlewareAttachmentType[]>(taskConfig: ITaskDefinition<Input, Output, Deps, TMeta, TTags, TMiddleware>): ITask<Input, Output, Deps, TMeta, TTags, TMiddleware>;
|
|
2372
|
-
declare namespace defineTask {
|
|
2373
|
-
var phantom: <Input = undefined, Output extends Promise<any> = any>(taskConfig: Omit<ITaskDefinition<Input, Output, any, any, any, any>, "run">) => IPhantomTask<Input, Output, any, any, any, any>;
|
|
2374
|
-
}
|
|
2375
|
-
|
|
2376
|
-
/**
|
|
2377
|
-
* Define a hook (event listeners).
|
|
2378
|
-
* Same shape as task with mandatory `on` and without `middleware`.
|
|
2379
|
-
*/
|
|
2380
|
-
declare function defineHook<D extends DependencyMapType = any, TOn extends "*" | IEventDefinition<any> | readonly IEventDefinition<any>[] = any, TMeta extends ITaskMeta = any>(hookDef: IHookDefinition<D, TOn, TMeta>): IHook<D, TOn, TMeta>;
|
|
2381
|
-
|
|
2382
|
-
declare function defineResource<TConfig = void, TValue extends Promise<any> = Promise<any>, TDeps extends DependencyMapType = {}, TPrivate = any, TMeta extends IResourceMeta = any, TTags extends TagType[] = TagType[], TMiddleware extends ResourceMiddlewareAttachmentType[] = ResourceMiddlewareAttachmentType[]>(constConfig: IResourceDefinition<TConfig, TValue, TDeps, TPrivate, any, any, TMeta, TTags, TMiddleware>): IResource<TConfig, TValue, TDeps, TPrivate, TMeta, TTags, TMiddleware>;
|
|
2383
|
-
|
|
2384
|
-
declare function defineEvent<TPayload = void>(config: IEventDefinition<TPayload>): IEvent<TPayload>;
|
|
2385
|
-
|
|
2386
|
-
declare function defineTaskMiddleware<TConfig = any, TEnforceInputContract = void, TEnforceOutputContract = void, TDependencies extends DependencyMapType = any>(middlewareDef: ITaskMiddlewareDefinition<TConfig, TEnforceInputContract, TEnforceOutputContract, TDependencies>): ITaskMiddleware<TConfig, TEnforceInputContract, TEnforceOutputContract, TDependencies>;
|
|
2387
|
-
|
|
2388
|
-
declare function defineResourceMiddleware<TConfig = any, TEnforceInputContract = void, TEnforceOutputContract = void, TDependencies extends DependencyMapType = any>(middlewareDef: IResourceMiddlewareDefinition<TConfig, TEnforceInputContract, TEnforceOutputContract, TDependencies>): IResourceMiddleware<TConfig, TEnforceInputContract, TEnforceOutputContract, TDependencies>;
|
|
2389
|
-
|
|
2390
|
-
/**
|
|
2391
|
-
* Override helper that preserves the original `id` and returns the same type.
|
|
2392
|
-
* You can override any property except `id`. The override is shallow-merged over the base.
|
|
2393
|
-
*
|
|
2394
|
-
* @param base - The base definition to override.
|
|
2395
|
-
* @param patch - Properties to override (except `id`).
|
|
2396
|
-
* @returns A definition of the same kind with overrides applied.
|
|
2397
|
-
*/
|
|
2398
|
-
type AnyTask = ITask<any, any, any, any, any, any>;
|
|
2399
|
-
type AnyResource = IResource<any, any, any, any, any, any, any>;
|
|
2400
|
-
type AnyTaskMiddleware = ITaskMiddleware<any, any, any, any>;
|
|
2401
|
-
type AnyResourceMiddleware = IResourceMiddleware<any, any, any, any>;
|
|
2402
|
-
type AnyHook = IHook<any, any, any>;
|
|
2403
|
-
type AnyOverrideable = AnyTask | AnyResource | AnyTaskMiddleware | AnyResourceMiddleware | AnyHook;
|
|
2404
|
-
type OverridePatch<TBase extends AnyOverrideable> = Readonly<TBase extends AnyHook ? Omit<Partial<TBase>, "id" | "on"> : Omit<Partial<TBase>, "id">>;
|
|
2405
|
-
declare function defineOverride<TBase extends AnyOverrideable>(base: TBase, patch: OverridePatch<TBase>): TBase;
|
|
2406
|
-
|
|
2407
|
-
/**
|
|
2408
|
-
* Create a tag definition.
|
|
2409
|
-
* - `.with(config)` to create configured instances
|
|
2410
|
-
* - `.extract(tags)` to extract this tag from a list of tags or a taggable's meta
|
|
2411
|
-
*
|
|
2412
|
-
* @typeParam TConfig - Configuration type carried by configured tags.
|
|
2413
|
-
* @typeParam TEnforceContract - Optional helper type to enforce a contract when tags are used.
|
|
2414
|
-
* @param definition - The tag definition (id).
|
|
2415
|
-
* @returns A tag object with helpers to configure and extract.
|
|
2416
|
-
*/
|
|
2417
|
-
declare function defineTag<TConfig = void, TEnforceInputContract = void, TEnforceOutputContract = void>(definition: ITagDefinition<TConfig, TEnforceInputContract, TEnforceOutputContract>): ITag<TConfig, TEnforceInputContract, TEnforceOutputContract>;
|
|
2418
|
-
|
|
2419
|
-
/**
|
|
2420
|
-
* Platform abstraction interface for universal compatibility
|
|
2421
|
-
* Inspired by Remix's approach to Web APIs and runtime-agnostic design
|
|
2422
|
-
*/
|
|
2423
|
-
type PlatformId = "node" | "browser" | "edge" | "universal";
|
|
2424
|
-
interface IPlatformAdapter {
|
|
2425
|
-
readonly id: PlatformId;
|
|
2426
|
-
onUncaughtException(handler: (error: Error) => void): () => void;
|
|
2427
|
-
onUnhandledRejection(handler: (reason: unknown) => void): () => void;
|
|
2428
|
-
onShutdownSignal(handler: () => void): () => void;
|
|
2429
|
-
exit(code: number): void;
|
|
2430
|
-
getEnv(key: string): string | undefined;
|
|
2431
|
-
hasAsyncLocalStorage(): boolean;
|
|
2432
|
-
createAsyncLocalStorage<T>(): IAsyncLocalStorage<T>;
|
|
2433
|
-
setTimeout: typeof globalThis.setTimeout;
|
|
2434
|
-
clearTimeout: typeof globalThis.clearTimeout;
|
|
2435
|
-
init: () => Promise<void>;
|
|
2436
|
-
}
|
|
2437
|
-
interface IAsyncLocalStorage<T> {
|
|
2438
|
-
getStore(): T | undefined;
|
|
2439
|
-
run<R>(store: T, callback: () => R): R;
|
|
2440
|
-
}
|
|
2441
|
-
|
|
2442
|
-
declare function setPlatform(adapter: IPlatformAdapter): void;
|
|
2443
|
-
declare class PlatformAdapter implements IPlatformAdapter {
|
|
2444
|
-
private inner;
|
|
2445
|
-
readonly env: PlatformId;
|
|
2446
|
-
readonly id: PlatformId;
|
|
2447
|
-
constructor(env?: PlatformId);
|
|
2448
|
-
init(): Promise<void>;
|
|
2449
|
-
onUncaughtException(handler: (error: any) => void): () => void;
|
|
2450
|
-
onUnhandledRejection(handler: (reason: any) => void): () => void;
|
|
2451
|
-
onShutdownSignal(handler: () => void): () => void;
|
|
2452
|
-
exit(code: number): void;
|
|
2453
|
-
getEnv(key: string): string | undefined;
|
|
2454
|
-
hasAsyncLocalStorage(): boolean;
|
|
2455
|
-
createAsyncLocalStorage<T>(): IAsyncLocalStorage<T>;
|
|
2456
|
-
setTimeout: typeof setTimeout;
|
|
2457
|
-
clearTimeout: typeof clearTimeout;
|
|
2458
|
-
}
|
|
2459
|
-
|
|
2460
|
-
declare const duplicateRegistrationError: IErrorHelper<{
|
|
2461
|
-
type: string;
|
|
2462
|
-
id: string;
|
|
2463
|
-
} & DefaultErrorType>;
|
|
2464
|
-
declare const dependencyNotFoundError: IErrorHelper<{
|
|
2465
|
-
key: string;
|
|
2466
|
-
} & DefaultErrorType>;
|
|
2467
|
-
declare const unknownItemTypeError: IErrorHelper<{
|
|
2468
|
-
item: unknown;
|
|
2469
|
-
} & DefaultErrorType>;
|
|
2470
|
-
declare const contextError: IErrorHelper<{
|
|
2471
|
-
details?: string;
|
|
2472
|
-
} & DefaultErrorType>;
|
|
2473
|
-
declare const circularDependenciesError: IErrorHelper<{
|
|
2474
|
-
cycles: string[];
|
|
2475
|
-
} & DefaultErrorType>;
|
|
2476
|
-
declare const eventNotFoundError: IErrorHelper<{
|
|
2477
|
-
id: string;
|
|
2478
|
-
} & DefaultErrorType>;
|
|
2479
|
-
declare const resourceNotFoundError: IErrorHelper<{
|
|
2480
|
-
id: string;
|
|
2481
|
-
} & DefaultErrorType>;
|
|
2482
|
-
declare const middlewareNotRegisteredError: IErrorHelper<{
|
|
2483
|
-
type: "task" | "resource";
|
|
2484
|
-
source: string;
|
|
2485
|
-
middlewareId: string;
|
|
2486
|
-
} & DefaultErrorType>;
|
|
2487
|
-
declare const tagNotFoundError: IErrorHelper<{
|
|
2488
|
-
id: string;
|
|
2489
|
-
} & DefaultErrorType>;
|
|
2490
|
-
declare const lockedError: IErrorHelper<{
|
|
2491
|
-
what: string;
|
|
2492
|
-
} & DefaultErrorType>;
|
|
2493
|
-
declare const storeAlreadyInitializedError: IErrorHelper<DefaultErrorType>;
|
|
2494
|
-
declare const validationError: IErrorHelper<{
|
|
2495
|
-
subject: string;
|
|
2496
|
-
id: string;
|
|
2497
|
-
originalError: string | Error;
|
|
2498
|
-
} & DefaultErrorType>;
|
|
2499
|
-
declare const eventCycleError: IErrorHelper<{
|
|
2500
|
-
path: Array<{
|
|
2501
|
-
id: string;
|
|
2502
|
-
source: string;
|
|
2503
|
-
}>;
|
|
2504
|
-
} & DefaultErrorType>;
|
|
2505
|
-
declare const eventEmissionCycleError: IErrorHelper<{
|
|
2506
|
-
cycles: string[];
|
|
2507
|
-
} & DefaultErrorType>;
|
|
2508
|
-
declare const platformUnsupportedFunctionError: IErrorHelper<{
|
|
2509
|
-
functionName: string;
|
|
2510
|
-
} & DefaultErrorType>;
|
|
2511
|
-
declare const cancellationError: IErrorHelper<{
|
|
2512
|
-
reason?: string;
|
|
2513
|
-
} & DefaultErrorType>;
|
|
2514
|
-
declare const tunnelOwnershipConflictError: IErrorHelper<{
|
|
2515
|
-
taskId: string;
|
|
2516
|
-
currentOwnerId: string;
|
|
2517
|
-
attemptedOwnerId: string;
|
|
2518
|
-
} & DefaultErrorType>;
|
|
2519
|
-
declare const phantomTaskNotRoutedError: IErrorHelper<{
|
|
2520
|
-
taskId: string;
|
|
2521
|
-
} & DefaultErrorType>;
|
|
2522
|
-
declare const taskNotRegisteredError: IErrorHelper<{
|
|
2523
|
-
taskId: string;
|
|
2524
|
-
} & DefaultErrorType>;
|
|
2525
|
-
/** Builder types that require validation before build() */
|
|
2526
|
-
type BuilderType = "hook" | "task-middleware" | "resource-middleware";
|
|
2527
|
-
declare const builderIncompleteError: IErrorHelper<{
|
|
2528
|
-
type: BuilderType;
|
|
2529
|
-
builderId: string;
|
|
2530
|
-
missingFields: string[];
|
|
2531
|
-
} & DefaultErrorType>;
|
|
2532
|
-
declare function isCancellationError(err: unknown): boolean;
|
|
2533
|
-
|
|
2534
|
-
type errors_BuilderType = BuilderType;
|
|
2535
|
-
type errors_IErrorHelper<TData extends DefaultErrorType = DefaultErrorType> = IErrorHelper<TData>;
|
|
2536
|
-
declare const errors_builderIncompleteError: typeof builderIncompleteError;
|
|
2537
|
-
declare const errors_cancellationError: typeof cancellationError;
|
|
2538
|
-
declare const errors_circularDependenciesError: typeof circularDependenciesError;
|
|
2539
|
-
declare const errors_contextError: typeof contextError;
|
|
2540
|
-
declare const errors_dependencyNotFoundError: typeof dependencyNotFoundError;
|
|
2541
|
-
declare const errors_duplicateRegistrationError: typeof duplicateRegistrationError;
|
|
2542
|
-
declare const errors_eventCycleError: typeof eventCycleError;
|
|
2543
|
-
declare const errors_eventEmissionCycleError: typeof eventEmissionCycleError;
|
|
2544
|
-
declare const errors_eventNotFoundError: typeof eventNotFoundError;
|
|
2545
|
-
declare const errors_isCancellationError: typeof isCancellationError;
|
|
2546
|
-
declare const errors_lockedError: typeof lockedError;
|
|
2547
|
-
declare const errors_middlewareNotRegisteredError: typeof middlewareNotRegisteredError;
|
|
2548
|
-
declare const errors_phantomTaskNotRoutedError: typeof phantomTaskNotRoutedError;
|
|
2549
|
-
declare const errors_platformUnsupportedFunctionError: typeof platformUnsupportedFunctionError;
|
|
2550
|
-
declare const errors_resourceNotFoundError: typeof resourceNotFoundError;
|
|
2551
|
-
declare const errors_storeAlreadyInitializedError: typeof storeAlreadyInitializedError;
|
|
2552
|
-
declare const errors_tagNotFoundError: typeof tagNotFoundError;
|
|
2553
|
-
declare const errors_taskNotRegisteredError: typeof taskNotRegisteredError;
|
|
2554
|
-
declare const errors_tunnelOwnershipConflictError: typeof tunnelOwnershipConflictError;
|
|
2555
|
-
declare const errors_unknownItemTypeError: typeof unknownItemTypeError;
|
|
2556
|
-
declare const errors_validationError: typeof validationError;
|
|
2557
|
-
declare namespace errors {
|
|
2558
|
-
export { type errors_BuilderType as BuilderType, type errors_IErrorHelper as IErrorHelper, errors_builderIncompleteError as builderIncompleteError, errors_cancellationError as cancellationError, errors_circularDependenciesError as circularDependenciesError, errors_contextError as contextError, errors_dependencyNotFoundError as dependencyNotFoundError, errors_duplicateRegistrationError as duplicateRegistrationError, errors_eventCycleError as eventCycleError, errors_eventEmissionCycleError as eventEmissionCycleError, errors_eventNotFoundError as eventNotFoundError, errors_isCancellationError as isCancellationError, errors_lockedError as lockedError, errors_middlewareNotRegisteredError as middlewareNotRegisteredError, errors_phantomTaskNotRoutedError as phantomTaskNotRoutedError, errors_platformUnsupportedFunctionError as platformUnsupportedFunctionError, errors_resourceNotFoundError as resourceNotFoundError, errors_storeAlreadyInitializedError as storeAlreadyInitializedError, errors_tagNotFoundError as tagNotFoundError, errors_taskNotRegisteredError as taskNotRegisteredError, errors_tunnelOwnershipConflictError as tunnelOwnershipConflictError, errors_unknownItemTypeError as unknownItemTypeError, errors_validationError as validationError };
|
|
2559
|
-
}
|
|
2560
|
-
|
|
2561
|
-
/**
|
|
2562
|
-
* Create a new typed Context. The result contains helpers similar to React’s
|
|
2563
|
-
* Context API but adapted for async usage in Runner.
|
|
2564
|
-
*/
|
|
2565
|
-
declare function defineAsyncContext<T>(def: IAsyncContextDefinition<T>): IAsyncContext<T>;
|
|
2566
|
-
|
|
2567
|
-
/** Convenience creator allowing optional name. Used by tests and legacy API. */
|
|
2568
|
-
/** @deprecated Use defineAsyncContext instead */
|
|
2569
|
-
declare function createContext$1<T>(name?: string): IAsyncContext<T>;
|
|
2570
|
-
|
|
2571
|
-
/**
|
|
2572
|
-
* This is the central function that kicks off you runner. You can run as many resources as you want in a single process, they will run in complete isolation.
|
|
2573
|
-
*
|
|
2574
|
-
* @param resourceOrResourceWithConfig - The resource or resource with config to run.
|
|
2575
|
-
* @param options - The options for the run.
|
|
2576
|
-
* @returns A promise that resolves to the result of the run.
|
|
2577
|
-
*/
|
|
2578
|
-
declare function run<C, V extends Promise<any>>(resourceOrResourceWithConfig: IResourceWithConfig<C, V> | IResource<void, V, any, any> | IResource<{
|
|
2579
|
-
[K in any]?: any;
|
|
2580
|
-
}, V, any, any>, // For optional config
|
|
2581
|
-
options?: RunOptions): Promise<RunResult<V extends Promise<infer U> ? U : V>>;
|
|
2582
|
-
|
|
2583
|
-
/**
|
|
2584
|
-
* Helper to create a minimal test harness resource that wraps a root app (or any registerable)
|
|
2585
|
-
* and exposes convenient testing utilities while running the full ecosystem
|
|
2586
|
-
* (registration, overrides, middleware, events) without modifying the core API.
|
|
2587
|
-
* @deprecated Use `run` instead with your testResource, as it provides the necessary toolkit.
|
|
2588
|
-
*/
|
|
2589
|
-
declare function createTestResource(root: RegisterableItems, options?: {
|
|
2590
|
-
overrides?: Array<IResource | ITask | ITaskMiddleware | IResourceMiddleware | IResourceWithConfig>;
|
|
2591
|
-
}): IResource<void, Promise<ReturnType<typeof buildTestFacade>>>;
|
|
2592
|
-
declare function buildTestFacade(deps: {
|
|
2593
|
-
taskRunner: TaskRunner;
|
|
2594
|
-
store: Store;
|
|
2595
|
-
logger: Logger;
|
|
2596
|
-
eventManager: EventManager;
|
|
2597
|
-
}): {
|
|
2598
|
-
runTask: <I, O extends Promise<any>, D extends DependencyMapType>(task: ITask<I, O, D>, ...args: I extends undefined ? [] : [I]) => Promise<Awaited<O> | undefined>;
|
|
2599
|
-
getResource: (id: string) => any;
|
|
2600
|
-
taskRunner: TaskRunner;
|
|
2601
|
-
store: Store;
|
|
2602
|
-
logger: Logger;
|
|
2603
|
-
eventManager: EventManager;
|
|
2604
|
-
};
|
|
2605
|
-
|
|
2606
|
-
type HookOn = "*" | IEventDefinition<any> | readonly IEventDefinition<any>[];
|
|
2607
|
-
interface HookOverrideBuilder<TDeps extends DependencyMapType, TOn extends HookOn, TMeta extends ITaskMeta> {
|
|
2608
|
-
id: string;
|
|
2609
|
-
order(order: number): HookOverrideBuilder<TDeps, TOn, TMeta>;
|
|
2610
|
-
dependencies<TNewDeps extends DependencyMapType, TIsOverride extends boolean = false>(deps: TNewDeps | (() => TNewDeps), options?: {
|
|
2611
|
-
override?: TIsOverride;
|
|
2612
|
-
}): HookOverrideBuilder<TIsOverride extends true ? TNewDeps : TDeps & TNewDeps, TOn, TMeta>;
|
|
2613
|
-
tags<TNewTags extends TagType[]>(t: TNewTags, options?: {
|
|
2614
|
-
override?: boolean;
|
|
2615
|
-
}): HookOverrideBuilder<TDeps, TOn, TMeta>;
|
|
2616
|
-
meta<TNewMeta extends ITaskMeta>(m: TNewMeta): HookOverrideBuilder<TDeps, TOn, TNewMeta>;
|
|
2617
|
-
run(fn: IHookDefinition<TDeps, TOn, TMeta>["run"]): HookOverrideBuilder<TDeps, TOn, TMeta>;
|
|
2618
|
-
build(): IHook<TDeps, TOn, TMeta>;
|
|
2619
|
-
}
|
|
2620
|
-
|
|
2621
|
-
declare function override<TInput, TOutput extends Promise<any>, TDeps extends DependencyMapType, TMeta extends ITaskMeta, TTags extends TagType[], TMiddleware extends TaskMiddlewareAttachmentType[]>(base: ITask<TInput, TOutput, TDeps, TMeta, TTags, TMiddleware>): TaskFluentBuilder<TInput, TOutput, TDeps, TMeta, TTags, TMiddleware>;
|
|
2622
|
-
declare function override<TConfig, TValue extends Promise<any>, TDeps extends DependencyMapType, TContext, TMeta extends IResourceMeta, TTags extends TagType[], TMiddleware extends ResourceMiddlewareAttachmentType[]>(base: IResource<TConfig, TValue, TDeps, TContext, TMeta, TTags, TMiddleware>): ResourceFluentBuilder<TConfig, TValue, TDeps, TContext, TMeta, TTags, TMiddleware>;
|
|
2623
|
-
declare function override<TDeps extends DependencyMapType, TOn extends HookOn, TMeta extends ITaskMeta>(base: IHook<TDeps, TOn, TMeta>): HookOverrideBuilder<TDeps, TOn, TMeta>;
|
|
2624
|
-
declare function override<C, In, Out, D extends DependencyMapType>(base: ITaskMiddleware<C, In, Out, D>): TaskMiddlewareFluentBuilder<C, In, Out, D>;
|
|
2625
|
-
declare function override<C, In, Out, D extends DependencyMapType>(base: IResourceMiddleware<C, In, Out, D>): ResourceMiddlewareFluentBuilder<C, In, Out, D>;
|
|
2626
|
-
|
|
2627
|
-
declare const debugLevels: {
|
|
2628
|
-
normal: DebugConfig;
|
|
2629
|
-
verbose: DebugConfig;
|
|
2630
|
-
};
|
|
2631
|
-
declare const debug: {
|
|
2632
|
-
levels: {
|
|
2633
|
-
normal: DebugConfig;
|
|
2634
|
-
verbose: DebugConfig;
|
|
2635
|
-
};
|
|
2636
|
-
};
|
|
2637
|
-
|
|
2638
|
-
interface HttpClientAuth {
|
|
2639
|
-
header?: string;
|
|
2640
|
-
token: string;
|
|
2641
|
-
}
|
|
2642
|
-
interface HttpClientConfig {
|
|
2643
|
-
baseUrl: string;
|
|
2644
|
-
auth?: HttpClientAuth;
|
|
2645
|
-
timeoutMs?: number;
|
|
2646
|
-
fetchImpl?: typeof fetch;
|
|
2647
|
-
serializer: SerializerLike;
|
|
2648
|
-
onRequest?: (ctx: {
|
|
2649
|
-
url: string;
|
|
2650
|
-
headers: Record<string, string>;
|
|
2651
|
-
}) => void | Promise<void>;
|
|
2652
|
-
contexts?: Array<IAsyncContext<unknown>>;
|
|
2653
|
-
errorRegistry?: Map<string, IErrorHelper<any>>;
|
|
2654
|
-
}
|
|
2655
|
-
interface HttpClient {
|
|
2656
|
-
task<I = unknown, O = unknown>(id: string, input?: I): Promise<O>;
|
|
2657
|
-
event<P = unknown>(id: string, payload?: P): Promise<void>;
|
|
2658
|
-
eventWithResult?<P = unknown>(id: string, payload?: P): Promise<P>;
|
|
2659
|
-
}
|
|
2660
|
-
declare function createHttpClient(cfg: HttpClientConfig): HttpClient;
|
|
2661
|
-
|
|
2662
|
-
/**
|
|
2663
|
-
* Factory for creating HTTP clients with automatic injection of:
|
|
2664
|
-
* - serializer
|
|
2665
|
-
* - error registry (from Store)
|
|
2666
|
-
* - async contexts (from Store)
|
|
2667
|
-
*
|
|
2668
|
-
* Note: Node streaming clients are exposed via the Node entry only
|
|
2669
|
-
* (see createHttpSmartClient/createHttpMixedClient in `@bluelibs/runner/node`).
|
|
2670
|
-
* Keeping this universal factory browser-safe avoids dynamic imports.
|
|
2671
|
-
*/
|
|
2672
|
-
interface HttpClientFactoryConfig {
|
|
2673
|
-
baseUrl: string;
|
|
2674
|
-
auth?: HttpClientConfig["auth"];
|
|
2675
|
-
timeoutMs?: number;
|
|
2676
|
-
fetchImpl?: typeof fetch;
|
|
2677
|
-
onRequest?: HttpClientConfig["onRequest"];
|
|
2678
|
-
}
|
|
2679
|
-
type HttpClientFactory = (config: HttpClientFactoryConfig) => HttpClient;
|
|
2680
|
-
|
|
2681
|
-
/**
|
|
2682
|
-
* Implementation of ExecutionJournal.
|
|
2683
|
-
* Created per task execution and passed through the middleware chain.
|
|
2684
|
-
*/
|
|
2685
|
-
declare class ExecutionJournalImpl implements ExecutionJournal {
|
|
2686
|
-
private readonly store;
|
|
2687
|
-
/**
|
|
2688
|
-
* Store a value in the journal.
|
|
2689
|
-
* Throws an error if the key already exists unless { override: true } is passed.
|
|
2690
|
-
*/
|
|
2691
|
-
set<T>(key: JournalKey<T>, value: T, options?: JournalSetOptions): void;
|
|
2692
|
-
get<T>(key: JournalKey<T>): T | undefined;
|
|
2693
|
-
has<T>(key: JournalKey<T>): boolean;
|
|
2694
|
-
}
|
|
2695
|
-
/**
|
|
2696
|
-
* Creates a typed journal key for use with ExecutionJournal.
|
|
2697
|
-
*
|
|
2698
|
-
* @example
|
|
2699
|
-
* ```typescript
|
|
2700
|
-
* const abortController = journal.createKey<AbortController>("timeout.abortController");
|
|
2701
|
-
* journal.set(abortController, new AbortController());
|
|
2702
|
-
* const ctrl = journal.get(abortController); // AbortController | undefined
|
|
2703
|
-
* ```
|
|
2704
|
-
*/
|
|
2705
|
-
declare function createKey<T>(id: string): JournalKey<T>;
|
|
2706
|
-
declare const journal: {
|
|
2707
|
-
createKey: typeof createKey;
|
|
2708
|
-
/**
|
|
2709
|
-
* Creates a new empty ExecutionJournal.
|
|
2710
|
-
* Useful when you need to pass a specific journal instance to `runTask` or nested calls.
|
|
2711
|
-
*/
|
|
2712
|
-
create: () => ExecutionJournalImpl;
|
|
2713
|
-
};
|
|
2714
|
-
|
|
2715
|
-
declare const globals: {
|
|
2716
|
-
events: {
|
|
2717
|
-
readonly ready: IEvent<void>;
|
|
2718
|
-
};
|
|
2719
|
-
resources: {
|
|
2720
|
-
readonly store: IResource<void, Promise<Store>, {}, any, any, TagType[], ResourceMiddlewareAttachmentType[]>;
|
|
2721
|
-
readonly middlewareManager: IResource<void, Promise<MiddlewareManager>, {}, any, any, TagType[], ResourceMiddlewareAttachmentType[]>;
|
|
2722
|
-
readonly eventManager: IResource<void, Promise<EventManager>, {}, any, any, TagType[], ResourceMiddlewareAttachmentType[]>;
|
|
2723
|
-
readonly taskRunner: IResource<void, Promise<TaskRunner>, {}, any, any, TagType[], ResourceMiddlewareAttachmentType[]>;
|
|
2724
|
-
readonly logger: IResource<void, Promise<Logger>, {}, any, any, TagType[], ResourceMiddlewareAttachmentType[]>;
|
|
2725
|
-
readonly serializer: IResource<void, Promise<SerializerLike>, {}, any, any, TagType[], ResourceMiddlewareAttachmentType[]>;
|
|
2726
|
-
readonly cache: IResource<{
|
|
2727
|
-
defaultOptions?: any;
|
|
2728
|
-
}, Promise<{
|
|
2729
|
-
map: Map<string, ICacheInstance>;
|
|
2730
|
-
cacheFactoryTask: TaskDependencyWithIntercept<lru_cache.LRUCache.Options<any, any, any>, Promise<ICacheInstance>>;
|
|
2731
|
-
defaultOptions: any;
|
|
2732
|
-
}>, {
|
|
2733
|
-
cacheFactoryTask: ITask<lru_cache.LRUCache.Options<any, any, any>, Promise<ICacheInstance>, any, any, TagType[], TaskMiddlewareAttachmentType[]>;
|
|
2734
|
-
}, any, any, TagType[], ResourceMiddlewareAttachmentType[]>;
|
|
2735
|
-
readonly queue: IResource<void, Promise<{
|
|
2736
|
-
map: Map<string, Queue>;
|
|
2737
|
-
run: <T>(id: string, task: (signal: AbortSignal) => Promise<T>) => Promise<T>;
|
|
2738
|
-
}>, {}, {
|
|
2739
|
-
map: Map<string, Queue>;
|
|
2740
|
-
}, {
|
|
2741
|
-
title: string;
|
|
2742
|
-
description: string;
|
|
2743
|
-
}, TagType[], ResourceMiddlewareAttachmentType[]>;
|
|
2744
|
-
readonly httpClientFactory: IResource<void, Promise<HttpClientFactory>, {
|
|
2745
|
-
serializer: IResource<void, Promise<SerializerLike>, {}, any, any, TagType[], ResourceMiddlewareAttachmentType[]>;
|
|
2746
|
-
store: IResource<void, Promise<Store>, {}, any, any, TagType[], ResourceMiddlewareAttachmentType[]>;
|
|
2747
|
-
}, any, {
|
|
2748
|
-
title: string;
|
|
2749
|
-
description: string;
|
|
2750
|
-
}, TagType[], ResourceMiddlewareAttachmentType[]>;
|
|
2751
|
-
readonly rateLimit: IResource<void, Promise<{
|
|
2752
|
-
states: WeakMap<RateLimitMiddlewareConfig, RateLimitState>;
|
|
2753
|
-
}>, {}, any, any, ITag<{
|
|
2754
|
-
metadata?: Record<string, any>;
|
|
2755
|
-
}, void, void>[], ResourceMiddlewareAttachmentType[]>;
|
|
2756
|
-
readonly circuitBreaker: IResource<void, Promise<{
|
|
2757
|
-
statusMap: Map<string, CircuitBreakerStatus>;
|
|
2758
|
-
}>, {}, any, any, ITag<{
|
|
2759
|
-
metadata?: Record<string, any>;
|
|
2760
|
-
}, void, void>[], ResourceMiddlewareAttachmentType[]>;
|
|
2761
|
-
readonly temporal: IResource<void, Promise<{
|
|
2762
|
-
debounceStates: WeakMap<TemporalMiddlewareConfig, DebounceState>;
|
|
2763
|
-
throttleStates: WeakMap<TemporalMiddlewareConfig, ThrottleState>;
|
|
2764
|
-
}>, {}, any, any, ITag<{
|
|
2765
|
-
metadata?: Record<string, any>;
|
|
2766
|
-
}, void, void>[], ResourceMiddlewareAttachmentType[]>;
|
|
2767
|
-
readonly concurrency: IResource<void, Promise<{
|
|
2768
|
-
semaphoresByConfig: WeakMap<ConcurrencyMiddlewareConfig, Semaphore>;
|
|
2769
|
-
semaphoresByKey: Map<string, {
|
|
2770
|
-
semaphore: Semaphore;
|
|
2771
|
-
limit: number;
|
|
2772
|
-
}>;
|
|
2773
|
-
}>, {}, any, any, ITag<{
|
|
2774
|
-
metadata?: Record<string, any>;
|
|
2775
|
-
}, void, void>[], ResourceMiddlewareAttachmentType[]>;
|
|
2776
|
-
};
|
|
2777
|
-
middleware: {
|
|
2778
|
-
requireContext: ITaskMiddleware<{
|
|
2779
|
-
context: IAsyncContext<any>;
|
|
2780
|
-
}, void, void, any>;
|
|
2781
|
-
task: {
|
|
2782
|
-
requireContext: ITaskMiddleware<{
|
|
2783
|
-
context: IAsyncContext<any>;
|
|
2784
|
-
}, void, void, any>;
|
|
2785
|
-
cache: ITaskMiddleware<any, void, void, {
|
|
2786
|
-
cache: IResource<{
|
|
2787
|
-
defaultOptions?: any;
|
|
2788
|
-
}, Promise<{
|
|
2789
|
-
map: Map<string, ICacheInstance>;
|
|
2790
|
-
cacheFactoryTask: TaskDependencyWithIntercept<lru_cache.LRUCache.Options<any, any, any>, Promise<ICacheInstance>>;
|
|
2791
|
-
defaultOptions: any;
|
|
2792
|
-
}>, {
|
|
2793
|
-
cacheFactoryTask: ITask<lru_cache.LRUCache.Options<any, any, any>, Promise<ICacheInstance>, any, any, TagType[], TaskMiddlewareAttachmentType[]>;
|
|
2794
|
-
}, any, any, TagType[], ResourceMiddlewareAttachmentType[]>;
|
|
2795
|
-
}> & {
|
|
2796
|
-
journalKeys: {
|
|
2797
|
-
readonly hit: JournalKey<boolean>;
|
|
2798
|
-
};
|
|
2799
|
-
};
|
|
2800
|
-
concurrency: ITaskMiddleware<ConcurrencyMiddlewareConfig, void, void, {
|
|
2801
|
-
state: IResource<void, Promise<{
|
|
2802
|
-
semaphoresByConfig: WeakMap<ConcurrencyMiddlewareConfig, Semaphore>;
|
|
2803
|
-
semaphoresByKey: Map<string, {
|
|
2804
|
-
semaphore: Semaphore;
|
|
2805
|
-
limit: number;
|
|
2806
|
-
}>;
|
|
2807
|
-
}>, {}, any, any, ITag<{
|
|
2808
|
-
metadata?: Record<string, any>;
|
|
2809
|
-
}, void, void>[], ResourceMiddlewareAttachmentType[]>;
|
|
2810
|
-
}>;
|
|
2811
|
-
debounce: ITaskMiddleware<TemporalMiddlewareConfig, void, void, {
|
|
2812
|
-
state: IResource<void, Promise<{
|
|
2813
|
-
debounceStates: WeakMap<TemporalMiddlewareConfig, DebounceState>;
|
|
2814
|
-
throttleStates: WeakMap<TemporalMiddlewareConfig, ThrottleState>;
|
|
2815
|
-
}>, {}, any, any, ITag<{
|
|
2816
|
-
metadata?: Record<string, any>;
|
|
2817
|
-
}, void, void>[], ResourceMiddlewareAttachmentType[]>;
|
|
2818
|
-
}>;
|
|
2819
|
-
throttle: ITaskMiddleware<TemporalMiddlewareConfig, void, void, {
|
|
2820
|
-
state: IResource<void, Promise<{
|
|
2821
|
-
debounceStates: WeakMap<TemporalMiddlewareConfig, DebounceState>;
|
|
2822
|
-
throttleStates: WeakMap<TemporalMiddlewareConfig, ThrottleState>;
|
|
2823
|
-
}>, {}, any, any, ITag<{
|
|
2824
|
-
metadata?: Record<string, any>;
|
|
2825
|
-
}, void, void>[], ResourceMiddlewareAttachmentType[]>;
|
|
2826
|
-
}>;
|
|
2827
|
-
fallback: ITaskMiddleware<FallbackMiddlewareConfig, void, void, {
|
|
2828
|
-
taskRunner: IResource<void, Promise<TaskRunner>, {}, any, any, TagType[], ResourceMiddlewareAttachmentType[]>;
|
|
2829
|
-
}> & {
|
|
2830
|
-
journalKeys: {
|
|
2831
|
-
readonly active: JournalKey<boolean>;
|
|
2832
|
-
readonly error: JournalKey<Error>;
|
|
2833
|
-
};
|
|
2834
|
-
};
|
|
2835
|
-
rateLimit: ITaskMiddleware<RateLimitMiddlewareConfig, void, void, {
|
|
2836
|
-
state: IResource<void, Promise<{
|
|
2837
|
-
states: WeakMap<RateLimitMiddlewareConfig, RateLimitState>;
|
|
2838
|
-
}>, {}, any, any, ITag<{
|
|
2839
|
-
metadata?: Record<string, any>;
|
|
2840
|
-
}, void, void>[], ResourceMiddlewareAttachmentType[]>;
|
|
2841
|
-
}> & {
|
|
2842
|
-
journalKeys: {
|
|
2843
|
-
readonly remaining: JournalKey<number>;
|
|
2844
|
-
readonly resetTime: JournalKey<number>;
|
|
2845
|
-
readonly limit: JournalKey<number>;
|
|
2846
|
-
};
|
|
2847
|
-
};
|
|
2848
|
-
retry: ITaskMiddleware<RetryMiddlewareConfig, void, void, any> & {
|
|
2849
|
-
journalKeys: {
|
|
2850
|
-
readonly attempt: JournalKey<number>;
|
|
2851
|
-
readonly lastError: JournalKey<Error>;
|
|
2852
|
-
};
|
|
2853
|
-
};
|
|
2854
|
-
timeout: ITaskMiddleware<TimeoutMiddlewareConfig, void, void, any> & {
|
|
2855
|
-
journalKeys: {
|
|
2856
|
-
readonly abortController: JournalKey<AbortController>;
|
|
2857
|
-
};
|
|
2858
|
-
};
|
|
2859
|
-
circuitBreaker: ITaskMiddleware<CircuitBreakerMiddlewareConfig, void, void, {
|
|
2860
|
-
state: IResource<void, Promise<{
|
|
2861
|
-
statusMap: Map<string, CircuitBreakerStatus>;
|
|
2862
|
-
}>, {}, any, any, ITag<{
|
|
2863
|
-
metadata?: Record<string, any>;
|
|
2864
|
-
}, void, void>[], ResourceMiddlewareAttachmentType[]>;
|
|
2865
|
-
}> & {
|
|
2866
|
-
journalKeys: {
|
|
2867
|
-
readonly state: JournalKey<CircuitBreakerState>;
|
|
2868
|
-
readonly failures: JournalKey<number>;
|
|
2869
|
-
};
|
|
2870
|
-
};
|
|
2871
|
-
};
|
|
2872
|
-
resource: {
|
|
2873
|
-
retry: IResourceMiddleware<RetryMiddlewareConfig, void, void, any>;
|
|
2874
|
-
timeout: IResourceMiddleware<TimeoutMiddlewareConfig, void, void, any>;
|
|
2875
|
-
};
|
|
2876
|
-
};
|
|
2877
|
-
tags: {
|
|
2878
|
-
system: ITag<{
|
|
2879
|
-
metadata?: Record<string, any>;
|
|
2880
|
-
}, void, void>;
|
|
2881
|
-
excludeFromGlobalHooks: ITag<{
|
|
2882
|
-
metadata?: Record<string, any>;
|
|
2883
|
-
}, void, void>;
|
|
2884
|
-
debug: ITag<DebugFriendlyConfig, void, void>;
|
|
2885
|
-
tunnel: ITag<void, void, TunnelRunner>;
|
|
2886
|
-
tunnelPolicy: ITag<TunnelTaskMiddlewarePolicyConfig, void, void>;
|
|
2887
|
-
authValidator: ITag<void, void, void>;
|
|
2888
|
-
};
|
|
2889
|
-
tunnels: Readonly<{
|
|
2890
|
-
http: Readonly<{
|
|
2891
|
-
createClient(cfg: HttpCreateClientConfig): ExposureFetchClient;
|
|
2892
|
-
}>;
|
|
2893
|
-
}>;
|
|
2894
|
-
debug: {
|
|
2895
|
-
levels: {
|
|
2896
|
-
normal: DebugConfig;
|
|
2897
|
-
verbose: DebugConfig;
|
|
2898
|
-
};
|
|
2899
|
-
};
|
|
2900
|
-
};
|
|
2901
|
-
|
|
2902
|
-
declare const createContext: typeof createContext$1;
|
|
2903
|
-
|
|
2904
|
-
declare const r: Readonly<{
|
|
2905
|
-
resource: typeof resourceBuilder;
|
|
2906
|
-
task: TaskBuilderWithPhantom;
|
|
2907
|
-
event: typeof eventBuilder;
|
|
2908
|
-
hook: typeof hookBuilder;
|
|
2909
|
-
tag: typeof tagBuilder;
|
|
2910
|
-
override: typeof override;
|
|
2911
|
-
asyncContext: typeof asyncContextBuilder;
|
|
2912
|
-
error: typeof errorBuilder;
|
|
2913
|
-
middleware: Readonly<{
|
|
2914
|
-
task: typeof taskMiddlewareBuilder;
|
|
2915
|
-
resource: typeof resourceMiddlewareBuilder;
|
|
2916
|
-
}>;
|
|
2917
|
-
}>;
|
|
2918
|
-
|
|
2919
|
-
export { type CommonPayload, type DebugConfig, type DebugFriendlyConfig, type DefaultErrorType, type DependencyMapType, DependencyProcessor, type DependencyValueType, type DependencyValuesType, type ErrorReference, errors as Errors, type EventDeliveryMode, type EventEmissionInterceptor, type EventHandlerType, EventManager, type EventStoreElementType, type ExecutionJournal, type ExposureFetchAuthConfig, type ExposureFetchClient, type ExposureFetchConfig, type ExtractEventPayload, type ExtractResourceConfig, type ExtractResourceValue, type ExtractTaskInput, type ExtractTaskOutput, type HookExecutionInterceptor, type HookStoreElementType, type HttpClient, type HttpClientAuth, type HttpClientConfig, type HttpClientFactory, type HttpClientFactoryConfig, type IAsyncContext, type IAsyncContextDefinition, type IAsyncContextMeta, type ICacheInstance, type IErrorDefinition, type IErrorDefinitionFinal, type IErrorHelper, type IErrorMeta, type IEvent, type IEventDefinition, type IEventEmission, type IEventHandlerOptions, type IEventMeta, type IHook, type IHookDefinition, type ILog, type ILogInfo, type IMeta, type IMiddlewareMeta, type IOptionalDependency, type IPhantomTask, type IResource, type IResourceDefinition, type IResourceMeta, type IResourceMiddleware, type IResourceMiddlewareConfigured, type IResourceMiddlewareDefinition, type IResourceMiddlewareExecutionInput, type IResourceWithConfig, type ITag, type ITagConfigured, type ITagDefinition, type ITagMeta, type ITaggable, type ITask, type ITaskDefinition, type ITaskMeta, type ITaskMiddleware, type ITaskMiddlewareConfigured, type ITaskMiddlewareDefinition, type ITaskMiddlewareExecutionInput, type IValidationSchema, type JournalKey, type LogLevels, Logger, MiddlewareManager, type OnUnhandledError, type OnUnhandledErrorInfo, type OverridableElements, PlatformAdapter, type PrintStrategy, Queue, type RegisterableItems, type RequiredKeys, type ResourceDependencyValueType, type ResourceDependencyValuesType, type ResourceForkInfo, type ResourceForkOptions, type ResourceForkRegisterMode, type ResourceInitFn, ResourceInitializer, type ResourceMiddlewareAttachmentType, type ResourceMiddlewareInterceptor, type ResourceMiddlewareStoreElementType, type ResourceStoreElementType, type RunOptions, RunResult, RunnerMode, Semaphore, Serializer, type SerializerOptions, Store, type TagType, type TaskCallOptions, type TaskDependencyWithIntercept, type TaskLocalInterceptor, type TaskMiddlewareAttachmentType, type TaskMiddlewareInterceptor, type TaskMiddlewareStoreElementType, TaskRunner, type TaskStoreElementType, type ThrowsList, type TunnelEventSelector, type TunnelMode, type TunnelRunner, type TunnelTagConfig, type TunnelTaskRunner, type TunnelTaskSelector, type TypeDefinition, type UnhandledErrorKind, type UnionToIntersection, allFalse, defineAsyncContext as asyncContext, bindProcessErrorHandler, createContext, createDefaultUnhandledError, createExposureFetch, createHttpClient, createTestResource, debug, debugLevels, defs as definitions, defineEvent as event, getConfig, getDefaultSerializer, globals, defineHook as hook, isOneOf, journal, levelNormal, levelVerbose, normalizeError, onAnyOf, defineOverride as override, r, defineResource as resource, defineResourceMiddleware as resourceMiddleware, run, safeReportUnhandledError, setPlatform, symbolAsyncContext, symbolError, symbolEvent, symbolFilePath, symbolHook, symbolMiddleware, symbolMiddlewareConfigured, symbolOptionalDependency, symbolPhantomTask, symbolResource, symbolResourceForkedFrom, symbolResourceMiddleware, symbolResourceWithConfig, symbolTag, symbolTagConfigured, symbolTask, symbolTaskMiddleware, symbolTunneledBy, defineTag as tag, defineTask as task, defineTaskMiddleware as taskMiddleware };
|