@blokjs/runner 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (307) hide show
  1. package/dist/Blok.d.ts +19 -0
  2. package/dist/Blok.js +184 -0
  3. package/dist/Blok.js.map +1 -0
  4. package/dist/BlokResponse.d.ts +16 -0
  5. package/dist/BlokResponse.js +28 -0
  6. package/dist/BlokResponse.js.map +1 -0
  7. package/dist/Configuration.d.ts +37 -0
  8. package/dist/Configuration.js +248 -0
  9. package/dist/Configuration.js.map +1 -0
  10. package/dist/ConfigurationResolver.d.ts +7 -0
  11. package/dist/ConfigurationResolver.js +15 -0
  12. package/dist/ConfigurationResolver.js.map +1 -0
  13. package/dist/DefaultLogger.d.ts +65 -0
  14. package/dist/DefaultLogger.js +101 -0
  15. package/dist/DefaultLogger.js.map +1 -0
  16. package/dist/LocalStorage.d.ts +7 -0
  17. package/dist/LocalStorage.js +56 -0
  18. package/dist/LocalStorage.js.map +1 -0
  19. package/dist/MemoryUsage.d.ts +22 -0
  20. package/dist/MemoryUsage.js +83 -0
  21. package/dist/MemoryUsage.js.map +1 -0
  22. package/dist/NodeMap.d.ts +7 -0
  23. package/dist/NodeMap.js +13 -0
  24. package/dist/NodeMap.js.map +1 -0
  25. package/dist/ResolverBase.d.ts +8 -0
  26. package/dist/ResolverBase.js +18 -0
  27. package/dist/ResolverBase.js.map +1 -0
  28. package/dist/Runner.d.ts +25 -0
  29. package/dist/Runner.js +32 -0
  30. package/dist/Runner.js.map +1 -0
  31. package/dist/RunnerNode.d.ts +9 -0
  32. package/dist/RunnerNode.js +8 -0
  33. package/dist/RunnerNode.js.map +1 -0
  34. package/dist/RunnerNodeBase.d.ts +4 -0
  35. package/dist/RunnerNodeBase.js +3 -0
  36. package/dist/RunnerNodeBase.js.map +1 -0
  37. package/dist/RunnerSteps.d.ts +14 -0
  38. package/dist/RunnerSteps.js +110 -0
  39. package/dist/RunnerSteps.js.map +1 -0
  40. package/dist/RuntimeAdapterNode.d.ts +19 -0
  41. package/dist/RuntimeAdapterNode.js +87 -0
  42. package/dist/RuntimeAdapterNode.js.map +1 -0
  43. package/dist/RuntimeRegistry.d.ts +61 -0
  44. package/dist/RuntimeRegistry.js +87 -0
  45. package/dist/RuntimeRegistry.js.map +1 -0
  46. package/dist/TriggerBase.d.ts +119 -0
  47. package/dist/TriggerBase.js +413 -0
  48. package/dist/TriggerBase.js.map +1 -0
  49. package/dist/adapters/BunRuntimeAdapter.d.ts +38 -0
  50. package/dist/adapters/BunRuntimeAdapter.js +169 -0
  51. package/dist/adapters/BunRuntimeAdapter.js.map +1 -0
  52. package/dist/adapters/DockerRuntimeAdapter.d.ts +85 -0
  53. package/dist/adapters/DockerRuntimeAdapter.js +298 -0
  54. package/dist/adapters/DockerRuntimeAdapter.js.map +1 -0
  55. package/dist/adapters/HttpRuntimeAdapter.d.ts +58 -0
  56. package/dist/adapters/HttpRuntimeAdapter.js +152 -0
  57. package/dist/adapters/HttpRuntimeAdapter.js.map +1 -0
  58. package/dist/adapters/NodeJsRuntimeAdapter.d.ts +23 -0
  59. package/dist/adapters/NodeJsRuntimeAdapter.js +67 -0
  60. package/dist/adapters/NodeJsRuntimeAdapter.js.map +1 -0
  61. package/dist/adapters/RuntimeAdapter.d.ts +42 -0
  62. package/dist/adapters/RuntimeAdapter.js +2 -0
  63. package/dist/adapters/RuntimeAdapter.js.map +1 -0
  64. package/dist/adapters/WasmRuntimeAdapter.d.ts +69 -0
  65. package/dist/adapters/WasmRuntimeAdapter.js +279 -0
  66. package/dist/adapters/WasmRuntimeAdapter.js.map +1 -0
  67. package/dist/cache/NodeResultCache.d.ts +286 -0
  68. package/dist/cache/NodeResultCache.js +499 -0
  69. package/dist/cache/NodeResultCache.js.map +1 -0
  70. package/dist/cache/index.d.ts +1 -0
  71. package/dist/cache/index.js +2 -0
  72. package/dist/cache/index.js.map +1 -0
  73. package/dist/cost/CostEstimator.d.ts +57 -0
  74. package/dist/cost/CostEstimator.js +171 -0
  75. package/dist/cost/CostEstimator.js.map +1 -0
  76. package/dist/cost/index.d.ts +4 -0
  77. package/dist/cost/index.js +3 -0
  78. package/dist/cost/index.js.map +1 -0
  79. package/dist/cost/pricing.d.ts +24 -0
  80. package/dist/cost/pricing.js +169 -0
  81. package/dist/cost/pricing.js.map +1 -0
  82. package/dist/defineNode.d.ts +155 -0
  83. package/dist/defineNode.js +191 -0
  84. package/dist/defineNode.js.map +1 -0
  85. package/dist/graphql/GraphQLSchemaGenerator.d.ts +129 -0
  86. package/dist/graphql/GraphQLSchemaGenerator.js +425 -0
  87. package/dist/graphql/GraphQLSchemaGenerator.js.map +1 -0
  88. package/dist/hmr/FileWatcher.d.ts +62 -0
  89. package/dist/hmr/FileWatcher.js +185 -0
  90. package/dist/hmr/FileWatcher.js.map +1 -0
  91. package/dist/hmr/HmrDevConsole.d.ts +13 -0
  92. package/dist/hmr/HmrDevConsole.js +46 -0
  93. package/dist/hmr/HmrDevConsole.js.map +1 -0
  94. package/dist/hmr/HotReloadManager.d.ts +84 -0
  95. package/dist/hmr/HotReloadManager.js +195 -0
  96. package/dist/hmr/HotReloadManager.js.map +1 -0
  97. package/dist/hmr/index.d.ts +39 -0
  98. package/dist/hmr/index.js +38 -0
  99. package/dist/hmr/index.js.map +1 -0
  100. package/dist/index.d.ts +107 -0
  101. package/dist/index.js +107 -0
  102. package/dist/index.js.map +1 -0
  103. package/dist/integrations/APMIntegration.d.ts +141 -0
  104. package/dist/integrations/APMIntegration.js +212 -0
  105. package/dist/integrations/APMIntegration.js.map +1 -0
  106. package/dist/integrations/AzureMonitorIntegration.d.ts +118 -0
  107. package/dist/integrations/AzureMonitorIntegration.js +254 -0
  108. package/dist/integrations/AzureMonitorIntegration.js.map +1 -0
  109. package/dist/integrations/CloudWatchIntegration.d.ts +135 -0
  110. package/dist/integrations/CloudWatchIntegration.js +293 -0
  111. package/dist/integrations/CloudWatchIntegration.js.map +1 -0
  112. package/dist/integrations/SentryIntegration.d.ts +153 -0
  113. package/dist/integrations/SentryIntegration.js +200 -0
  114. package/dist/integrations/SentryIntegration.js.map +1 -0
  115. package/dist/integrations/index.d.ts +19 -0
  116. package/dist/integrations/index.js +16 -0
  117. package/dist/integrations/index.js.map +1 -0
  118. package/dist/marketplace/RuntimeAutoScaler.d.ts +148 -0
  119. package/dist/marketplace/RuntimeAutoScaler.js +366 -0
  120. package/dist/marketplace/RuntimeAutoScaler.js.map +1 -0
  121. package/dist/marketplace/RuntimeCatalog.d.ts +174 -0
  122. package/dist/marketplace/RuntimeCatalog.js +339 -0
  123. package/dist/marketplace/RuntimeCatalog.js.map +1 -0
  124. package/dist/marketplace/RuntimeDiscovery.d.ts +86 -0
  125. package/dist/marketplace/RuntimeDiscovery.js +219 -0
  126. package/dist/marketplace/RuntimeDiscovery.js.map +1 -0
  127. package/dist/marketplace/RuntimeHealthMonitor.d.ts +100 -0
  128. package/dist/marketplace/RuntimeHealthMonitor.js +241 -0
  129. package/dist/marketplace/RuntimeHealthMonitor.js.map +1 -0
  130. package/dist/marketplace/RuntimeMetricsDashboard.d.ts +113 -0
  131. package/dist/marketplace/RuntimeMetricsDashboard.js +293 -0
  132. package/dist/marketplace/RuntimeMetricsDashboard.js.map +1 -0
  133. package/dist/monitoring/CircuitBreaker.d.ts +107 -0
  134. package/dist/monitoring/CircuitBreaker.js +238 -0
  135. package/dist/monitoring/CircuitBreaker.js.map +1 -0
  136. package/dist/monitoring/DistributedTracer.d.ts +125 -0
  137. package/dist/monitoring/DistributedTracer.js +230 -0
  138. package/dist/monitoring/DistributedTracer.js.map +1 -0
  139. package/dist/monitoring/HealthCheck.d.ts +54 -0
  140. package/dist/monitoring/HealthCheck.js +102 -0
  141. package/dist/monitoring/HealthCheck.js.map +1 -0
  142. package/dist/monitoring/PerformanceProfiler.d.ts +63 -0
  143. package/dist/monitoring/PerformanceProfiler.js +229 -0
  144. package/dist/monitoring/PerformanceProfiler.js.map +1 -0
  145. package/dist/monitoring/PrometheusBootstrap.d.ts +30 -0
  146. package/dist/monitoring/PrometheusBootstrap.js +71 -0
  147. package/dist/monitoring/PrometheusBootstrap.js.map +1 -0
  148. package/dist/monitoring/PrometheusMetricsBridge.d.ts +60 -0
  149. package/dist/monitoring/PrometheusMetricsBridge.js +216 -0
  150. package/dist/monitoring/PrometheusMetricsBridge.js.map +1 -0
  151. package/dist/monitoring/RateLimiter.d.ts +58 -0
  152. package/dist/monitoring/RateLimiter.js +128 -0
  153. package/dist/monitoring/RateLimiter.js.map +1 -0
  154. package/dist/monitoring/StructuredLogger.d.ts +131 -0
  155. package/dist/monitoring/StructuredLogger.js +207 -0
  156. package/dist/monitoring/StructuredLogger.js.map +1 -0
  157. package/dist/monitoring/TracingBootstrap.d.ts +69 -0
  158. package/dist/monitoring/TracingBootstrap.js +129 -0
  159. package/dist/monitoring/TracingBootstrap.js.map +1 -0
  160. package/dist/monitoring/TriggerMetricsCollector.d.ts +94 -0
  161. package/dist/monitoring/TriggerMetricsCollector.js +174 -0
  162. package/dist/monitoring/TriggerMetricsCollector.js.map +1 -0
  163. package/dist/monitoring/index.d.ts +9 -0
  164. package/dist/monitoring/index.js +10 -0
  165. package/dist/monitoring/index.js.map +1 -0
  166. package/dist/openapi/OpenAPIGenerator.d.ts +192 -0
  167. package/dist/openapi/OpenAPIGenerator.js +373 -0
  168. package/dist/openapi/OpenAPIGenerator.js.map +1 -0
  169. package/dist/openapi/index.d.ts +20 -0
  170. package/dist/openapi/index.js +20 -0
  171. package/dist/openapi/index.js.map +1 -0
  172. package/dist/security/ABAC.d.ts +224 -0
  173. package/dist/security/ABAC.js +380 -0
  174. package/dist/security/ABAC.js.map +1 -0
  175. package/dist/security/AuditLogger.d.ts +242 -0
  176. package/dist/security/AuditLogger.js +317 -0
  177. package/dist/security/AuditLogger.js.map +1 -0
  178. package/dist/security/AuthMiddleware.d.ts +163 -0
  179. package/dist/security/AuthMiddleware.js +274 -0
  180. package/dist/security/AuthMiddleware.js.map +1 -0
  181. package/dist/security/EncryptionAtRest.d.ts +206 -0
  182. package/dist/security/EncryptionAtRest.js +236 -0
  183. package/dist/security/EncryptionAtRest.js.map +1 -0
  184. package/dist/security/OAuthProvider.d.ts +334 -0
  185. package/dist/security/OAuthProvider.js +719 -0
  186. package/dist/security/OAuthProvider.js.map +1 -0
  187. package/dist/security/PIIDetector.d.ts +233 -0
  188. package/dist/security/PIIDetector.js +354 -0
  189. package/dist/security/PIIDetector.js.map +1 -0
  190. package/dist/security/RBAC.d.ts +143 -0
  191. package/dist/security/RBAC.js +285 -0
  192. package/dist/security/RBAC.js.map +1 -0
  193. package/dist/security/SecretManager.d.ts +652 -0
  194. package/dist/security/SecretManager.js +1146 -0
  195. package/dist/security/SecretManager.js.map +1 -0
  196. package/dist/security/TLSConfig.d.ts +305 -0
  197. package/dist/security/TLSConfig.js +550 -0
  198. package/dist/security/TLSConfig.js.map +1 -0
  199. package/dist/security/index.d.ts +79 -0
  200. package/dist/security/index.js +80 -0
  201. package/dist/security/index.js.map +1 -0
  202. package/dist/testing/TestHarness.d.ts +189 -0
  203. package/dist/testing/TestHarness.js +272 -0
  204. package/dist/testing/TestHarness.js.map +1 -0
  205. package/dist/testing/TestLogger.d.ts +103 -0
  206. package/dist/testing/TestLogger.js +153 -0
  207. package/dist/testing/TestLogger.js.map +1 -0
  208. package/dist/testing/WorkflowTestRunner.d.ts +172 -0
  209. package/dist/testing/WorkflowTestRunner.js +355 -0
  210. package/dist/testing/WorkflowTestRunner.js.map +1 -0
  211. package/dist/testing/index.d.ts +21 -0
  212. package/dist/testing/index.js +22 -0
  213. package/dist/testing/index.js.map +1 -0
  214. package/dist/tracing/InMemoryRunStore.d.ts +44 -0
  215. package/dist/tracing/InMemoryRunStore.js +341 -0
  216. package/dist/tracing/InMemoryRunStore.js.map +1 -0
  217. package/dist/tracing/PostgresRunStore.d.ts +82 -0
  218. package/dist/tracing/PostgresRunStore.js +640 -0
  219. package/dist/tracing/PostgresRunStore.js.map +1 -0
  220. package/dist/tracing/RunStore.d.ts +38 -0
  221. package/dist/tracing/RunStore.js +2 -0
  222. package/dist/tracing/RunStore.js.map +1 -0
  223. package/dist/tracing/RunTracker.d.ts +75 -0
  224. package/dist/tracing/RunTracker.js +374 -0
  225. package/dist/tracing/RunTracker.js.map +1 -0
  226. package/dist/tracing/SqliteRunStore.d.ts +53 -0
  227. package/dist/tracing/SqliteRunStore.js +703 -0
  228. package/dist/tracing/SqliteRunStore.js.map +1 -0
  229. package/dist/tracing/TraceRouter.d.ts +47 -0
  230. package/dist/tracing/TraceRouter.js +904 -0
  231. package/dist/tracing/TraceRouter.js.map +1 -0
  232. package/dist/tracing/TracingLogger.d.ts +21 -0
  233. package/dist/tracing/TracingLogger.js +62 -0
  234. package/dist/tracing/TracingLogger.js.map +1 -0
  235. package/dist/tracing/createStore.d.ts +30 -0
  236. package/dist/tracing/createStore.js +75 -0
  237. package/dist/tracing/createStore.js.map +1 -0
  238. package/dist/tracing/index.d.ts +13 -0
  239. package/dist/tracing/index.js +9 -0
  240. package/dist/tracing/index.js.map +1 -0
  241. package/dist/tracing/sanitize.d.ts +7 -0
  242. package/dist/tracing/sanitize.js +95 -0
  243. package/dist/tracing/sanitize.js.map +1 -0
  244. package/dist/tracing/types.d.ts +178 -0
  245. package/dist/tracing/types.js +3 -0
  246. package/dist/tracing/types.js.map +1 -0
  247. package/dist/types/Average.d.ts +11 -0
  248. package/dist/types/Average.js +2 -0
  249. package/dist/types/Average.js.map +1 -0
  250. package/dist/types/Condition.d.ts +8 -0
  251. package/dist/types/Condition.js +2 -0
  252. package/dist/types/Condition.js.map +1 -0
  253. package/dist/types/Conditions.d.ts +5 -0
  254. package/dist/types/Conditions.js +2 -0
  255. package/dist/types/Conditions.js.map +1 -0
  256. package/dist/types/Config.d.ts +12 -0
  257. package/dist/types/Config.js +2 -0
  258. package/dist/types/Config.js.map +1 -0
  259. package/dist/types/Flow.d.ts +5 -0
  260. package/dist/types/Flow.js +2 -0
  261. package/dist/types/Flow.js.map +1 -0
  262. package/dist/types/GlobalOptions.d.ts +11 -0
  263. package/dist/types/GlobalOptions.js +2 -0
  264. package/dist/types/GlobalOptions.js.map +1 -0
  265. package/dist/types/Inputs.d.ts +5 -0
  266. package/dist/types/Inputs.js +2 -0
  267. package/dist/types/Inputs.js.map +1 -0
  268. package/dist/types/JsonLikeObject.d.ts +3 -0
  269. package/dist/types/JsonLikeObject.js +2 -0
  270. package/dist/types/JsonLikeObject.js.map +1 -0
  271. package/dist/types/Mapper.d.ts +5 -0
  272. package/dist/types/Mapper.js +2 -0
  273. package/dist/types/Mapper.js.map +1 -0
  274. package/dist/types/Node.d.ts +10 -0
  275. package/dist/types/Node.js +2 -0
  276. package/dist/types/Node.js.map +1 -0
  277. package/dist/types/ParamsDictionary.d.ts +3 -0
  278. package/dist/types/ParamsDictionary.js +2 -0
  279. package/dist/types/ParamsDictionary.js.map +1 -0
  280. package/dist/types/Properties.d.ts +5 -0
  281. package/dist/types/Properties.js +2 -0
  282. package/dist/types/Properties.js.map +1 -0
  283. package/dist/types/Targets.d.ts +5 -0
  284. package/dist/types/Targets.js +2 -0
  285. package/dist/types/Targets.js.map +1 -0
  286. package/dist/types/Trigger.d.ts +5 -0
  287. package/dist/types/Trigger.js +2 -0
  288. package/dist/types/Trigger.js.map +1 -0
  289. package/dist/types/TriggerHttp.d.ts +7 -0
  290. package/dist/types/TriggerHttp.js +2 -0
  291. package/dist/types/TriggerHttp.js.map +1 -0
  292. package/dist/types/TriggerResponse.d.ts +6 -0
  293. package/dist/types/TriggerResponse.js +2 -0
  294. package/dist/types/TriggerResponse.js.map +1 -0
  295. package/dist/types/Triggers.d.ts +5 -0
  296. package/dist/types/Triggers.js +2 -0
  297. package/dist/types/Triggers.js.map +1 -0
  298. package/dist/types/TryCatch.d.ts +6 -0
  299. package/dist/types/TryCatch.js +2 -0
  300. package/dist/types/TryCatch.js.map +1 -0
  301. package/dist/visualization/NodeDependencyGraph.d.ts +76 -0
  302. package/dist/visualization/NodeDependencyGraph.js +418 -0
  303. package/dist/visualization/NodeDependencyGraph.js.map +1 -0
  304. package/dist/visualization/WorkflowVisualizer.d.ts +144 -0
  305. package/dist/visualization/WorkflowVisualizer.js +446 -0
  306. package/dist/visualization/WorkflowVisualizer.js.map +1 -0
  307. package/package.json +95 -0
@@ -0,0 +1,286 @@
1
+ /**
2
+ * Node Result Caching for Blok Runner
3
+ *
4
+ * Provides intelligent caching of node execution results to avoid redundant
5
+ * computation. Supports LRU eviction, TTL-based expiry, tag-based invalidation,
6
+ * and pluggable cache providers.
7
+ *
8
+ * Uses only Node.js built-ins (node:crypto for hashing).
9
+ */
10
+ /**
11
+ * A pluggable cache storage backend. Implementations must be safe for
12
+ * concurrent async access (no overlapping mutations on the same key).
13
+ */
14
+ export interface CacheProvider {
15
+ /** Human-readable name of the provider (e.g. "in-memory", "redis"). */
16
+ readonly name: string;
17
+ /** Retrieve a cached entry, or `null` if the key is absent / expired. */
18
+ get<T>(key: string): Promise<CacheEntry<T> | null>;
19
+ /** Store a value under `key` with optional TTL, tags, and priority. */
20
+ set<T>(key: string, value: T, options?: CacheSetOptions): Promise<void>;
21
+ /** Remove a single key. Returns `true` if the key existed. */
22
+ delete(key: string): Promise<boolean>;
23
+ /** Remove *all* entries from the cache. */
24
+ clear(): Promise<void>;
25
+ /** Check existence without bumping LRU order. */
26
+ has(key: string): Promise<boolean>;
27
+ /** Return a snapshot of hit/miss statistics. */
28
+ getStats(): CacheStats;
29
+ }
30
+ /** A single cached value together with its metadata. */
31
+ export interface CacheEntry<T> {
32
+ /** The cached value. */
33
+ value: T;
34
+ /** The cache key under which this entry is stored. */
35
+ key: string;
36
+ /** Unix-epoch ms when the entry was written. */
37
+ createdAt: number;
38
+ /** Unix-epoch ms when the entry will be considered expired. */
39
+ expiresAt: number;
40
+ /** Number of times this entry has been read from cache. */
41
+ hits: number;
42
+ /** Approximate size in bytes (derived from JSON.stringify length). */
43
+ size: number;
44
+ }
45
+ /** Options accepted by {@link CacheProvider.set}. */
46
+ export interface CacheSetOptions {
47
+ /** Time-to-live in milliseconds. Defaults to 60 000 (60 s). */
48
+ ttlMs?: number;
49
+ /** Arbitrary string tags for bulk invalidation via {@link InMemoryCache.invalidateByTag}. */
50
+ tags?: string[];
51
+ /** Eviction priority. Higher values are evicted later. Default: 0. */
52
+ priority?: number;
53
+ }
54
+ /** Aggregate cache performance statistics. */
55
+ export interface CacheStats {
56
+ /** Total cache hits. */
57
+ hits: number;
58
+ /** Total cache misses. */
59
+ misses: number;
60
+ /** Current number of entries in the cache. */
61
+ size: number;
62
+ /** Maximum number of entries allowed. */
63
+ maxSize: number;
64
+ /** Hit rate as a ratio (0-1). Returns 0 when no requests have been made. */
65
+ hitRate: number;
66
+ /** Number of entries evicted (LRU or TTL). */
67
+ evictions: number;
68
+ /** Total number of `set` calls. */
69
+ totalSets: number;
70
+ /** Approximate memory consumed by cached values, in bytes. */
71
+ memoryUsageBytes: number;
72
+ }
73
+ /** Configuration for {@link InMemoryCache}. */
74
+ export interface InMemoryCacheConfig {
75
+ /** Maximum number of entries before LRU eviction kicks in. Default: 500. */
76
+ maxSize?: number;
77
+ /** Default TTL in milliseconds when none is provided on `set`. Default: 60 000. */
78
+ defaultTTLMs?: number;
79
+ /** Maximum aggregate byte size of cached values. Default: 50 MB. */
80
+ maxMemoryBytes?: number;
81
+ /** Optional callback invoked whenever an entry is evicted. */
82
+ onEvict?: (key: string, reason: "lru" | "ttl" | "memory" | "manual") => void;
83
+ }
84
+ /**
85
+ * LRU cache with TTL-based expiry, tag-based invalidation, and memory limits.
86
+ *
87
+ * Internally backed by a `Map` whose insertion order is used for LRU tracking.
88
+ * Every `get` promotes the accessed key to the most-recently-used position.
89
+ *
90
+ * Expired entries are cleaned up lazily on access and periodically via a
91
+ * background sweep timer (every 60 s). The timer is `unref`-ed so it does
92
+ * not prevent the Node.js process from exiting.
93
+ */
94
+ export declare class InMemoryCache implements CacheProvider {
95
+ readonly name = "in-memory";
96
+ private readonly store;
97
+ private readonly maxSize;
98
+ private readonly defaultTTLMs;
99
+ private readonly maxMemoryBytes;
100
+ private readonly onEvict?;
101
+ private _hits;
102
+ private _misses;
103
+ private _evictions;
104
+ private _totalSets;
105
+ private _memoryUsageBytes;
106
+ private sweepTimer;
107
+ constructor(config?: InMemoryCacheConfig);
108
+ /** @inheritdoc */
109
+ get<T>(key: string): Promise<CacheEntry<T> | null>;
110
+ /** @inheritdoc */
111
+ set<T>(key: string, value: T, options?: CacheSetOptions): Promise<void>;
112
+ /** @inheritdoc */
113
+ delete(key: string): Promise<boolean>;
114
+ /** @inheritdoc */
115
+ clear(): Promise<void>;
116
+ /** @inheritdoc */
117
+ has(key: string): Promise<boolean>;
118
+ /** @inheritdoc */
119
+ getStats(): CacheStats;
120
+ /**
121
+ * Remove all entries that carry the given tag.
122
+ *
123
+ * @param tag - Tag string to match against.
124
+ * @returns Number of entries removed.
125
+ */
126
+ invalidateByTag(tag: string): number;
127
+ /**
128
+ * Stop the periodic sweep timer and release resources.
129
+ * Call this when the cache is no longer needed.
130
+ */
131
+ destroy(): void;
132
+ /**
133
+ * Evict a single key from the cache.
134
+ *
135
+ * @returns `true` if the key existed and was removed.
136
+ */
137
+ private evict;
138
+ /**
139
+ * Evict the least-recently-used entries until `store.size <= maxSize`.
140
+ * Entries with higher priority are skipped in favour of lower-priority ones.
141
+ */
142
+ private enforceSizeLimit;
143
+ /**
144
+ * Evict entries until `_memoryUsageBytes <= maxMemoryBytes`.
145
+ */
146
+ private enforceMemoryLimit;
147
+ /**
148
+ * Sweep all expired entries. Called periodically by the background timer.
149
+ */
150
+ private sweep;
151
+ private startPeriodicSweep;
152
+ private stopPeriodicSweep;
153
+ }
154
+ /** Strategy used by {@link NodeResultCache} to derive cache keys. */
155
+ export type CacheKeyStrategy = "input-hash" | "node-input" | "custom";
156
+ /** Custom key generation function. */
157
+ export type CustomKeyFn = (nodeName: string, input: unknown) => string;
158
+ /** The value returned by {@link NodeResultCache.wrapExecution}. */
159
+ export interface CacheResult<O> {
160
+ /** The execution output (from cache or freshly computed). */
161
+ data: O;
162
+ /** `true` when the result was served from cache. */
163
+ cached: boolean;
164
+ /** The cache key used for this lookup. */
165
+ key: string;
166
+ /** Milliseconds remaining before this entry expires (only when `cached` is true). */
167
+ ttlRemainingMs?: number;
168
+ }
169
+ /** Configuration for {@link NodeResultCache}. */
170
+ export interface NodeResultCacheConfig {
171
+ /** The cache provider to use. Defaults to a new {@link InMemoryCache}. */
172
+ provider?: CacheProvider;
173
+ /** Whether caching is enabled. Default: `true`. */
174
+ enabled?: boolean;
175
+ /** Strategy for generating cache keys. Default: `"node-input"`. */
176
+ keyStrategy?: CacheKeyStrategy;
177
+ /** Required when `keyStrategy` is `"custom"`. */
178
+ customKeyFn?: CustomKeyFn;
179
+ }
180
+ /**
181
+ * Singleton orchestrator that wraps node executions with transparent caching.
182
+ *
183
+ * Typical usage:
184
+ *
185
+ * ```ts
186
+ * const cache = NodeResultCache.getInstance();
187
+ *
188
+ * const result = await cache.wrapExecution("myNode", input, async () => {
189
+ * return expensiveComputation(input);
190
+ * });
191
+ *
192
+ * console.log(result.cached); // true on subsequent identical calls
193
+ * ```
194
+ *
195
+ * The singleton is configured once via {@link NodeResultCache.configure}.
196
+ * Subsequent calls to `getInstance()` return the already-configured instance.
197
+ */
198
+ export declare class NodeResultCache {
199
+ private static instance;
200
+ private readonly provider;
201
+ private readonly enabled;
202
+ private readonly keyStrategy;
203
+ private readonly customKeyFn?;
204
+ /**
205
+ * In-flight promise map for deduplicating concurrent executions of the
206
+ * same cache key. Prevents the "thundering herd" problem where N
207
+ * concurrent callers all compute the same expensive result.
208
+ */
209
+ private readonly inflight;
210
+ private constructor();
211
+ /**
212
+ * Return the singleton instance, creating one with defaults if necessary.
213
+ */
214
+ static getInstance(): NodeResultCache;
215
+ /**
216
+ * Create (or replace) the singleton with the given configuration.
217
+ *
218
+ * @returns The newly configured singleton instance.
219
+ */
220
+ static configure(config: NodeResultCacheConfig): NodeResultCache;
221
+ /**
222
+ * Tear down the singleton, releasing any resources held by the provider.
223
+ */
224
+ static resetInstance(): void;
225
+ /**
226
+ * Wrap an async execution with caching.
227
+ *
228
+ * If a cached result exists for the derived key it is returned immediately.
229
+ * Otherwise `execute` is invoked and its result is stored before being
230
+ * returned.
231
+ *
232
+ * Concurrent calls with the same key will share a single in-flight
233
+ * execution (request coalescing).
234
+ *
235
+ * @param nodeName - Logical name of the node being executed.
236
+ * @param input - The input payload used to derive the cache key.
237
+ * @param execute - Factory that produces the result when no cache hit.
238
+ * @param options - Optional TTL, tags, and priority for the cache entry.
239
+ * @returns A {@link CacheResult} indicating whether the result was cached.
240
+ */
241
+ wrapExecution<I, O>(nodeName: string, input: I, execute: () => Promise<O>, options?: CacheSetOptions): Promise<CacheResult<O>>;
242
+ /**
243
+ * Invalidate all cache entries whose key starts with the node-specific
244
+ * prefix. This is only fully effective with the default `"node-input"`
245
+ * strategy and the built-in {@link InMemoryCache} provider.
246
+ *
247
+ * For external providers, consider using tag-based invalidation instead.
248
+ *
249
+ * @param nodeName - Name of the node whose results should be purged.
250
+ */
251
+ invalidateNode(nodeName: string): Promise<void>;
252
+ /**
253
+ * Invalidate all entries matching *any* of the supplied tags.
254
+ *
255
+ * This is a convenience wrapper around {@link InMemoryCache.invalidateByTag}
256
+ * when the built-in provider is used.
257
+ *
258
+ * @param tags - Array of tag strings.
259
+ */
260
+ invalidateByTags(tags: string[]): Promise<void>;
261
+ /**
262
+ * Pre-populate the cache for a set of known inputs.
263
+ *
264
+ * This is useful during application startup to "warm" the cache and
265
+ * ensure that the first real request for each input is served from cache.
266
+ *
267
+ * @param nodeName - Name of the node.
268
+ * @param inputs - Array of inputs to pre-compute.
269
+ * @param execute - Factory that computes the result for a given input.
270
+ * @param options - Optional cache-set options applied to every entry.
271
+ */
272
+ warmup<I, O>(nodeName: string, inputs: I[], execute: (input: I) => Promise<O>, options?: CacheSetOptions): Promise<void>;
273
+ /**
274
+ * Return the underlying provider's statistics snapshot.
275
+ */
276
+ getStats(): CacheStats;
277
+ /**
278
+ * Return the underlying cache provider instance.
279
+ */
280
+ getProvider(): CacheProvider;
281
+ /**
282
+ * Derive a cache key from the node name and input based on the configured
283
+ * {@link CacheKeyStrategy}.
284
+ */
285
+ private buildKey;
286
+ }