@ferricstore/ferricstore 0.1.5 → 0.1.7

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 (209) hide show
  1. package/README.md +239 -9
  2. package/dist/index.cjs +14658 -4692
  3. package/dist/index.cjs.map +1 -1
  4. package/dist/index.d.cts +1671 -868
  5. package/dist/index.d.ts +1671 -868
  6. package/dist/index.js +14590 -4632
  7. package/dist/index.js.map +1 -1
  8. package/docs/api/assets/hierarchy.js +1 -1
  9. package/docs/api/assets/navigation.js +1 -1
  10. package/docs/api/assets/search.js +1 -1
  11. package/docs/api/classes/BitmapStore.html +2 -2
  12. package/docs/api/classes/BloomFilterStore.html +4 -2
  13. package/docs/api/classes/ClaimHydrationError.html +38 -0
  14. package/docs/api/classes/ConnectionClosedError.html +37 -0
  15. package/docs/api/classes/CountMinSketchStore.html +3 -2
  16. package/docs/api/classes/CuckooFilterStore.html +3 -2
  17. package/docs/api/classes/FerricStoreClient.html +204 -140
  18. package/docs/api/classes/FerricStoreError.html +1 -1
  19. package/docs/api/classes/FlowAlreadyExistsError.html +2 -2
  20. package/docs/api/classes/FlowBatchError.html +39 -0
  21. package/docs/api/classes/FlowNotFoundError.html +2 -2
  22. package/docs/api/classes/FlowWrongStateError.html +2 -2
  23. package/docs/api/classes/GeoStore.html +4 -2
  24. package/docs/api/classes/HashStore.html +2 -2
  25. package/docs/api/classes/HyperLogLogStore.html +3 -2
  26. package/docs/api/classes/InvalidCommandError.html +2 -2
  27. package/docs/api/classes/KeyValueStore.html +2 -2
  28. package/docs/api/classes/LeaseRenewalError.html +34 -0
  29. package/docs/api/classes/ListStore.html +6 -2
  30. package/docs/api/classes/LockHeldError.html +2 -2
  31. package/docs/api/classes/LockNotOwnedError.html +2 -2
  32. package/docs/api/classes/NativeAdapter.html +4 -2
  33. package/docs/api/classes/OverloadedError.html +2 -2
  34. package/docs/api/classes/Queue.html +2 -2
  35. package/docs/api/classes/QueueClient.html +2 -2
  36. package/docs/api/classes/QueueCompletionError.html +35 -0
  37. package/docs/api/classes/QueueWorker.html +2 -2
  38. package/docs/api/classes/ReconnectingExecutor.html +8 -2
  39. package/docs/api/classes/RequestTimeoutError.html +38 -0
  40. package/docs/api/classes/RerouteError.html +36 -0
  41. package/docs/api/classes/RoutingTopology.html +2 -2
  42. package/docs/api/classes/SetStore.html +4 -2
  43. package/docs/api/classes/SortedSetStore.html +3 -2
  44. package/docs/api/classes/StaleLeaseError.html +2 -2
  45. package/docs/api/classes/StreamStore.html +2 -2
  46. package/docs/api/classes/TDigestStore.html +2 -2
  47. package/docs/api/classes/TopKStore.html +6 -2
  48. package/docs/api/classes/TopologyNativeAdapterPool.html +7 -2
  49. package/docs/api/classes/Workflow.html +5 -2
  50. package/docs/api/classes/WorkflowClient.html +2 -2
  51. package/docs/api/classes/WorkflowContext.html +2 -2
  52. package/docs/api/classes/WorkflowFlowCommands.html +3 -2
  53. package/docs/api/classes/WorkflowWorker.html +2 -2
  54. package/docs/api/functions/classifyServerError.html +1 -1
  55. package/docs/api/functions/complete.html +1 -1
  56. package/docs/api/functions/fail.html +1 -1
  57. package/docs/api/functions/isOutcome.html +1 -0
  58. package/docs/api/functions/isReconnectableClosedConnectionError.html +1 -1
  59. package/docs/api/functions/mapException.html +1 -1
  60. package/docs/api/functions/retry.html +1 -1
  61. package/docs/api/functions/transition.html +1 -1
  62. package/docs/api/hierarchy.html +1 -1
  63. package/docs/api/index.html +157 -12
  64. package/docs/api/interfaces/AdminListOptions.html +4 -0
  65. package/docs/api/interfaces/ApprovalListOptions.html +6 -0
  66. package/docs/api/interfaces/ApprovalRequestOptions.html +11 -0
  67. package/docs/api/interfaces/AttributeQueryOptions.html +5 -0
  68. package/docs/api/interfaces/AutoBatchOptions.html +3 -2
  69. package/docs/api/interfaces/BackpressurePolicy.html +2 -2
  70. package/docs/api/interfaces/BudgetCommitOptions.html +3 -0
  71. package/docs/api/interfaces/BudgetReserveOptions.html +5 -0
  72. package/docs/api/interfaces/CancelOptions.html +12 -6
  73. package/docs/api/interfaces/ChildSpec.html +2 -2
  74. package/docs/api/interfaces/CircuitOpenOptions.html +4 -0
  75. package/docs/api/interfaces/ClaimDueOptions.html +4 -2
  76. package/docs/api/interfaces/ClaimHydrationItem.html +3 -0
  77. package/docs/api/interfaces/ClaimedItem.html +4 -3
  78. package/docs/api/interfaces/CommandExecutor.html +7 -2
  79. package/docs/api/interfaces/CompleteJobsAndClaimJobsResult.html +11 -0
  80. package/docs/api/interfaces/CompleteManyOptions.html +14 -0
  81. package/docs/api/interfaces/CompleteOptions.html +4 -2
  82. package/docs/api/interfaces/CompleteOutcome.html +4 -2
  83. package/docs/api/interfaces/CountMinMergeOptions.html +2 -2
  84. package/docs/api/interfaces/CreateItem.html +3 -2
  85. package/docs/api/interfaces/CreateManyOptions.html +10 -2
  86. package/docs/api/interfaces/CreateOptions.html +6 -2
  87. package/docs/api/interfaces/EffectCompensateOptions.html +7 -0
  88. package/docs/api/interfaces/EffectConfirmOptions.html +7 -0
  89. package/docs/api/interfaces/EffectFailOptions.html +8 -0
  90. package/docs/api/interfaces/EffectReserveOptions.html +8 -0
  91. package/docs/api/interfaces/EffectStatusOptions.html +5 -0
  92. package/docs/api/interfaces/ExecutePipelineOptions.html +6 -2
  93. package/docs/api/interfaces/ExtendLeaseOptions.html +7 -0
  94. package/docs/api/interfaces/FailOptions.html +4 -2
  95. package/docs/api/interfaces/FailOutcome.html +4 -2
  96. package/docs/api/interfaces/FencedItem.html +2 -2
  97. package/docs/api/interfaces/FerricStoreClientFromUrlOptions.html +6 -2
  98. package/docs/api/interfaces/FerricStoreClientOptions.html +6 -2
  99. package/docs/api/interfaces/FetchOrComputeFencedResult.html +9 -0
  100. package/docs/api/interfaces/FetchOrComputeHitResult.html +6 -0
  101. package/docs/api/interfaces/FetchOrComputeLegacyResult.html +9 -0
  102. package/docs/api/interfaces/FlowBatchCompletedItem.html +3 -0
  103. package/docs/api/interfaces/FlowPolicyOptions.html +11 -0
  104. package/docs/api/interfaces/FlowRecord.html +3 -2
  105. package/docs/api/interfaces/FlowStatePolicy.html +3 -0
  106. package/docs/api/interfaces/FlowStatsOptions.html +6 -0
  107. package/docs/api/interfaces/GeoMember.html +2 -2
  108. package/docs/api/interfaces/GovernanceLedgerOptions.html +6 -0
  109. package/docs/api/interfaces/HistoryOptions.html +16 -0
  110. package/docs/api/interfaces/InvocationCreateOptions.html +4 -0
  111. package/docs/api/interfaces/KeyInfo.html +2 -2
  112. package/docs/api/interfaces/LeaseMutationOptions.html +14 -0
  113. package/docs/api/interfaces/LimitAmountOptions.html +4 -0
  114. package/docs/api/interfaces/LimitLeaseOptions.html +6 -0
  115. package/docs/api/interfaces/LimitListOptions.html +5 -0
  116. package/docs/api/interfaces/LimitReleaseOptions.html +4 -0
  117. package/docs/api/interfaces/MutateOptions.html +4 -2
  118. package/docs/api/interfaces/NamedValueMutation.html +4 -2
  119. package/docs/api/interfaces/NativeAdapterOptions.html +21 -9
  120. package/docs/api/interfaces/NativeClientOptions.html +43 -0
  121. package/docs/api/interfaces/NativeProtocolEvent.html +5 -0
  122. package/docs/api/interfaces/ProtocolCommand.html +2 -2
  123. package/docs/api/interfaces/QueueOptions.html +2 -2
  124. package/docs/api/interfaces/QueueWorkerResult.html +2 -2
  125. package/docs/api/interfaces/RangeLimit.html +2 -2
  126. package/docs/api/interfaces/RateLimitResult.html +2 -2
  127. package/docs/api/interfaces/ReadOptions.html +2 -2
  128. package/docs/api/interfaces/ReclaimOptions.html +4 -2
  129. package/docs/api/interfaces/ReconnectOptions.html +8 -2
  130. package/docs/api/interfaces/RequestContext.html +4 -0
  131. package/docs/api/interfaces/RequestContextOptions.html +2 -0
  132. package/docs/api/interfaces/RetryOptions.html +4 -2
  133. package/docs/api/interfaces/RetryOutcome.html +4 -2
  134. package/docs/api/interfaces/RetryPolicy.html +2 -2
  135. package/docs/api/interfaces/RoutingEndpoint.html +2 -2
  136. package/docs/api/interfaces/RoutingRoute.html +2 -2
  137. package/docs/api/interfaces/RunStepsItem.html +3 -0
  138. package/docs/api/interfaces/RunStepsManyOptions.html +11 -0
  139. package/docs/api/interfaces/ScanOptions.html +4 -2
  140. package/docs/api/interfaces/ScheduleFireDueOptions.html +5 -0
  141. package/docs/api/interfaces/ScheduleListOptions.html +9 -0
  142. package/docs/api/interfaces/ScheduleOptions.html +16 -0
  143. package/docs/api/interfaces/SearchOptions.html +2 -2
  144. package/docs/api/interfaces/StartAndClaimOptions.html +17 -0
  145. package/docs/api/interfaces/StateOptions.html +3 -2
  146. package/docs/api/interfaces/StateRegistration.html +3 -2
  147. package/docs/api/interfaces/StepContinueOptions.html +20 -0
  148. package/docs/api/interfaces/StoreCommandClient.html +3 -2
  149. package/docs/api/interfaces/TDigestCreateOptions.html +2 -2
  150. package/docs/api/interfaces/TDigestMergeOptions.html +2 -2
  151. package/docs/api/interfaces/TopologyNativeAdapterOptions.html +39 -0
  152. package/docs/api/interfaces/TransitionOptions.html +4 -2
  153. package/docs/api/interfaces/TransitionOutcome.html +4 -2
  154. package/docs/api/interfaces/ValueConfig.html +2 -2
  155. package/docs/api/interfaces/WorkerConfig.html +23 -2
  156. package/docs/api/interfaces/WorkflowOptions.html +2 -2
  157. package/docs/api/interfaces/WorkflowWorkerResult.html +2 -2
  158. package/docs/api/interfaces/XReadStream.html +2 -2
  159. package/docs/api/interfaces/ZAddMember.html +2 -2
  160. package/docs/api/media/kv-store.ts +2 -2
  161. package/docs/api/modules.html +1 -1
  162. package/docs/api/types/BackoffKind.html +1 -1
  163. package/docs/api/types/CollectionScanOptions.html +2 -0
  164. package/docs/api/types/Command.html +1 -1
  165. package/docs/api/types/CommandArgument.html +1 -1
  166. package/docs/api/types/ConnectionRequestDisposition.html +2 -0
  167. package/docs/api/types/EndpointPolicy.html +2 -1
  168. package/docs/api/types/ExceptionPolicy.html +1 -1
  169. package/docs/api/types/ExpiryCondition.html +1 -0
  170. package/docs/api/types/FencingToken.html +2 -0
  171. package/docs/api/types/FetchOrComputeComputeResult.html +1 -0
  172. package/docs/api/types/FetchOrComputeResult.html +1 -0
  173. package/docs/api/types/FlowAdminRecord.html +1 -0
  174. package/docs/api/types/FlowStateMode.html +1 -0
  175. package/docs/api/types/FlowStatePolicyLike.html +1 -0
  176. package/docs/api/types/GeoAddOptions.html +2 -0
  177. package/docs/api/types/GetExOptions.html +2 -0
  178. package/docs/api/types/HashScanResult.html +2 -0
  179. package/docs/api/types/IntegerReply.html +2 -0
  180. package/docs/api/types/ManagementPairs.html +1 -1
  181. package/docs/api/types/MaxActiveMs.html +1 -0
  182. package/docs/api/types/Outcome.html +1 -1
  183. package/docs/api/types/QueueBatchHandler.html +1 -1
  184. package/docs/api/types/QueueHandler.html +1 -1
  185. package/docs/api/types/QueueJob.html +1 -1
  186. package/docs/api/types/RequestDisposition.html +1 -0
  187. package/docs/api/types/SearchStateMeta.html +1 -1
  188. package/docs/api/types/SetOptions.html +2 -0
  189. package/docs/api/types/SetScanResult.html +2 -0
  190. package/docs/api/types/SortedSetScanResult.html +2 -0
  191. package/docs/api/types/StateMeta.html +1 -1
  192. package/docs/api/types/StateMetaValue.html +1 -1
  193. package/docs/api/types/TopKReserveOptions.html +1 -0
  194. package/docs/api/types/WorkerProfile.html +1 -1
  195. package/docs/api/types/WorkerRefillStrategy.html +1 -0
  196. package/docs/api/types/WorkflowHandler.html +1 -1
  197. package/docs/api/types/ZAddOptions.html +2 -0
  198. package/docs/api/variables/COMMAND_OPCODES.html +1 -1
  199. package/docs/api/variables/COMPACT_RESPONSE_OPCODES.html +2 -0
  200. package/docs/python-parity.md +12 -6
  201. package/package.json +5 -1
  202. package/docs/api/classes/JsonStore.html +0 -15
  203. package/docs/api/interfaces/FetchOrComputeResult.html +0 -6
  204. package/docs/api/interfaces/GeoAddOptions.html +0 -4
  205. package/docs/api/interfaces/GetExOptions.html +0 -6
  206. package/docs/api/interfaces/JsonSetOptions.html +0 -3
  207. package/docs/api/interfaces/SetOptions.html +0 -9
  208. package/docs/api/interfaces/TopKReserveOptions.html +0 -4
  209. package/docs/api/interfaces/ZAddOptions.html +0 -6
package/dist/index.d.cts CHANGED
@@ -1,6 +1,74 @@
1
- import tls from 'node:tls';
1
+ import { ConnectionOptions } from 'node:tls';
2
2
  import { Buffer as Buffer$1 } from 'node:buffer';
3
3
 
4
+ declare class FerricStoreError extends Error {
5
+ readonly code: string;
6
+ readonly raw: unknown;
7
+ constructor(message: string, options?: {
8
+ raw?: unknown;
9
+ cause?: unknown;
10
+ });
11
+ }
12
+ type RequestDisposition = "unsent" | "possibly_sent";
13
+ /** Connection closure annotated with whether the current request may have reached the server. */
14
+ declare class ConnectionClosedError extends FerricStoreError {
15
+ readonly code = "connection_closed";
16
+ readonly requestDisposition: RequestDisposition;
17
+ constructor(requestDisposition: RequestDisposition, options?: {
18
+ raw?: unknown;
19
+ cause?: unknown;
20
+ message?: string;
21
+ });
22
+ }
23
+ /** Request timeout annotated with whether the request may have reached the server. */
24
+ declare class RequestTimeoutError extends FerricStoreError {
25
+ readonly code = "request_timeout";
26
+ readonly requestDisposition: RequestDisposition;
27
+ readonly timeoutMs: number;
28
+ constructor(timeoutMs: number, requestDisposition: RequestDisposition, options?: {
29
+ raw?: unknown;
30
+ cause?: unknown;
31
+ });
32
+ }
33
+ declare class FlowNotFoundError extends FerricStoreError {
34
+ readonly code = "flow_not_found";
35
+ }
36
+ declare class FlowWrongStateError extends FerricStoreError {
37
+ readonly code = "flow_wrong_state";
38
+ }
39
+ declare class StaleLeaseError extends FerricStoreError {
40
+ readonly code = "stale_lease";
41
+ }
42
+ declare class FlowAlreadyExistsError extends FerricStoreError {
43
+ readonly code = "flow_already_exists";
44
+ }
45
+ declare class LockHeldError extends FerricStoreError {
46
+ readonly code = "lock_held";
47
+ }
48
+ declare class LockNotOwnedError extends FerricStoreError {
49
+ readonly code = "lock_not_owned";
50
+ }
51
+ declare class InvalidCommandError extends FerricStoreError {
52
+ readonly code = "invalid_command";
53
+ }
54
+ declare class OverloadedError extends FerricStoreError {
55
+ readonly code = "overloaded";
56
+ readonly retryAfterMs: number | undefined;
57
+ readonly reason: string | undefined;
58
+ constructor(message: string, options?: {
59
+ raw?: unknown;
60
+ cause?: unknown;
61
+ retryAfterMs?: number;
62
+ reason?: string;
63
+ });
64
+ }
65
+ /** The contacted endpoint cannot serve this route and topology should be refreshed. */
66
+ declare class RerouteError extends FerricStoreError {
67
+ readonly code = "reroute";
68
+ }
69
+ declare function classifyServerError(message: string, raw?: unknown, cause?: unknown, status?: number | string): FerricStoreError;
70
+ declare function mapException(error: unknown): unknown;
71
+
4
72
  interface Codec<T = unknown> {
5
73
  encode(value: T | null | undefined): Buffer;
6
74
  decode(value: Buffer | null | undefined): T | null;
@@ -14,18 +82,26 @@ declare class JsonCodec<T = unknown> implements Codec<T> {
14
82
  decode(value: Buffer | null | undefined): T | null;
15
83
  }
16
84
 
17
- type CommandArgument = string | Buffer | number | boolean | Record<string, unknown> | null | undefined;
85
+ type CommandArgument = string | Buffer | number | bigint | boolean | readonly CommandArgument[] | Record<string, unknown> | null | undefined;
18
86
  type Command = readonly CommandArgument[];
19
87
 
20
- type EndpointPolicy = "seed_hosts" | "any" | "none" | {
21
- readonly allowHosts: readonly string[];
22
- };
88
+ interface ExecutePipelineOptions {
89
+ /** @internal Earlier command indexes that must settle before each individual fallback command starts. */
90
+ fallbackDependencies?: readonly (readonly number[])[];
91
+ /** Maximum concurrent requests when a native pipeline is unavailable. Defaults to 64. */
92
+ fallbackConcurrency?: number;
93
+ /** Preserve command execution order when a native pipeline is unavailable. */
94
+ ordered?: boolean;
95
+ throwOnItemError?: boolean;
96
+ }
97
+
23
98
  interface RoutingEndpoint {
24
99
  readonly node: string;
25
100
  readonly host: string;
26
101
  readonly nativePort: number;
27
102
  readonly nativeTlsPort?: number;
28
103
  }
104
+
29
105
  interface RoutingRoute {
30
106
  readonly shard: number;
31
107
  readonly laneId: number;
@@ -42,35 +118,137 @@ declare class RoutingTopology {
42
118
  private constructor();
43
119
  static empty(): RoutingTopology;
44
120
  static build(payload: unknown): RoutingTopology;
45
- static slotForKey(key: string | Buffer$1): number;
46
- routeKey(key: string | Buffer$1): RoutingRoute;
121
+ static slotForKey(key: string | Buffer): number;
122
+ routeKey(key: string | Buffer): RoutingRoute;
47
123
  }
124
+
125
+ /** Trust policy for endpoints learned from SHARDS topology responses. */
126
+ type EndpointPolicy = "seed_hosts" | "any" | "none" | {
127
+ readonly allowHosts: readonly string[];
128
+ };
129
+
48
130
  declare class TopologyNativeAdapterPool implements CommandExecutor {
49
131
  private readonly adapterOptions;
50
- private readonly adapters;
51
- private readonly endpointPolicy;
52
- private readonly endpointValidator?;
53
- private readonly seedEndpointKeys;
132
+ private readonly seedAdapterOptions;
133
+ private closed;
134
+ private readonly adapterRegistry;
135
+ private closePromise?;
136
+ private readonly endpointTrust;
137
+ private readonly seedUrlByEndpointKey;
54
138
  private readonly seedUrls;
55
139
  private readonly tls;
56
- private readonly trustedHosts;
140
+ private readonly topologyConcurrency;
141
+ private readonly pipelineExecutor;
142
+ private readonly scatterExecutor;
57
143
  private readonly warmConnections;
144
+ private eventRefreshPromise?;
145
+ private lastSuccessfulRefreshKey?;
146
+ private refreshPromise?;
147
+ private refreshRequested;
58
148
  private topologyValue;
59
149
  private constructor();
60
- static fromUrls(urls: readonly string[], options?: NativeAdapterOptions): Promise<TopologyNativeAdapterPool>;
150
+ static fromUrls(urls: readonly string[], options?: TopologyNativeAdapterOptions): Promise<TopologyNativeAdapterPool>;
61
151
  get topology(): RoutingTopology;
152
+ private requestTopologyRefresh;
153
+ private drainTopologyRefreshRequests;
62
154
  refreshTopology(): Promise<RoutingTopology>;
155
+ private loadTopology;
63
156
  route(key: string | Buffer$1): RoutingRoute;
64
157
  executeCommand(...args: CommandArgument[]): Promise<unknown>;
158
+ executeCommandArgs(args: readonly CommandArgument[]): Promise<unknown>;
65
159
  executePipeline(commands: readonly Command[], options?: ExecutePipelineOptions): Promise<unknown[]>;
160
+ executeFusedPipeline(commands: readonly Command[], options?: ExecutePipelineOptions): Promise<unknown[] | undefined>;
161
+ private refreshAndCanRetrySafeReroute;
162
+ private executePipelineOnRoute;
163
+ private executeSplitPipeline;
66
164
  close(): Promise<void>;
67
165
  private routeData;
68
- private singleRouteForCommands;
166
+ private executeOnRoute;
69
167
  private controlAdapter;
70
- private adapterForUrl;
168
+ private adapterForSeedUrl;
71
169
  private adapterForEndpoint;
72
- private validateEndpoint;
73
- private refreshCandidateUrls;
170
+ private adapterForCurrentRoute;
171
+ private retireRemovedAdapters;
172
+ private refreshCandidates;
173
+ private assertOpen;
174
+ }
175
+
176
+ interface CommandExecutor {
177
+ executeCommand(...args: CommandArgument[]): Promise<unknown>;
178
+ /** Execute an already-built command without a JavaScript variadic-call limit. */
179
+ executeCommandArgs?(args: readonly CommandArgument[]): Promise<unknown>;
180
+ executePipeline?(commands: readonly Command[], options?: ExecutePipelineOptions): Promise<unknown[]>;
181
+ /**
182
+ * Execute all commands in one native transport request. Returning undefined
183
+ * guarantees that no command was submitted, so the caller may fall back.
184
+ */
185
+ executeFusedPipeline?(commands: readonly Command[], options?: ExecutePipelineOptions): Promise<unknown[] | undefined>;
186
+ refreshTopology?(): Promise<RoutingTopology>;
187
+ route?(key: string | Buffer): Promise<RoutingRoute> | RoutingRoute;
188
+ close?(): Promise<void> | void;
189
+ }
190
+ interface NativeProtocolEvent {
191
+ readonly flags: number;
192
+ readonly laneId: number;
193
+ readonly opcode: number;
194
+ readonly value: unknown;
195
+ }
196
+ interface NativeAdapterOptions {
197
+ clientName?: string;
198
+ connectTimeoutMs?: number;
199
+ /** Cancels connection, STARTUP, or AUTH while the native adapter is being created. */
200
+ signal?: AbortSignal;
201
+ heartbeatIntervalMs?: number;
202
+ keepAlive?: boolean;
203
+ keepAliveInitialDelayMs?: number;
204
+ /** Maximum source bytes buffered across chunked responses, including final assembly. */
205
+ maxChunkBytes?: number;
206
+ /** Maximum source frames buffered across chunked responses, including final assembly. */
207
+ maxChunkFrames?: number;
208
+ /** Maximum body bytes declared by any single native frame. */
209
+ maxFrameBytes?: number;
210
+ /** Maximum decoded response body bytes, including all chunks. */
211
+ maxResponseBytes?: number;
212
+ /** Maximum correlated control requests awaiting responses on one native connection. */
213
+ maxPendingControlRequests?: number;
214
+ /** Maximum requests waiting locally for native flow-control credit. */
215
+ maxQueuedRequests?: number;
216
+ /** Maximum encoded request bytes waiting locally for socket backpressure. */
217
+ maxQueuedWriteBytes?: number;
218
+ /** Native management events requested during STARTUP. */
219
+ events?: readonly string[];
220
+ /** Non-blocking callback for unsolicited native management frames. */
221
+ onEvent?: (event: NativeProtocolEvent) => unknown;
222
+ protocolLanes?: number;
223
+ timeoutMs?: number;
224
+ username?: string;
225
+ password?: string;
226
+ tlsOptions?: ConnectionOptions;
227
+ }
228
+ interface TopologyNativeAdapterOptions extends NativeAdapterOptions {
229
+ /** Learned endpoint trust policy; defaults to exact seeds plus `trustedHosts`. */
230
+ endpointPolicy?: EndpointPolicy;
231
+ endpointValidator?: (endpoint: RoutingEndpoint) => boolean | void;
232
+ /** Additional learned hosts allowed by the default `seed_hosts` policy. */
233
+ trustedHosts?: readonly string[];
234
+ /** Maximum concurrent per-route fan-out operations; defaults to 16. */
235
+ topologyConcurrency?: number;
236
+ warmConnections?: boolean;
237
+ }
238
+ /** Options accepted by FerricStoreClient.fromUrl(s), including client-side HA and reconnect policy. */
239
+ interface NativeClientOptions extends TopologyNativeAdapterOptions {
240
+ autoReconnect?: boolean | ReconnectOptions;
241
+ haRouting?: boolean;
242
+ seeds?: readonly string[];
243
+ }
244
+ interface ReconnectOptions {
245
+ /** Base delay after a failed reconnect attempt. Defaults to 25ms. */
246
+ baseDelayMs?: number;
247
+ /** Percentage of positive random jitter added to reconnect delays. Defaults to 20. */
248
+ jitterPct?: number;
249
+ /** Maximum reconnect delay. Defaults to 1,000ms. */
250
+ maxDelayMs?: number;
251
+ maxRetries?: number;
74
252
  }
75
253
 
76
254
  declare const COMMAND_OPCODES: {
@@ -213,604 +391,454 @@ declare const COMMAND_OPCODES: {
213
391
  readonly "FERRICSTORE.METRICS": 783;
214
392
  readonly "FERRICSTORE.BLOBGC": 784;
215
393
  };
394
+ /** Direct compact response kinds advertised by the FerricStore native protocol. */
395
+ declare const COMPACT_RESPONSE_OPCODES: {
396
+ readonly flow_claim_jobs_v1: readonly [515];
397
+ readonly flow_record_list_v1: readonly [526, 535, 536, 537, 538, 539, 541];
398
+ readonly flow_record_v1: readonly [514];
399
+ readonly kv_get_v1: readonly [257];
400
+ readonly kv_mget_v1: readonly [260, 524];
401
+ readonly ok_list_v1: readonly [258, 261, 527, 528, 530, 531, 532];
402
+ readonly pipeline_v1: readonly [14];
403
+ };
216
404
  interface ProtocolCommand {
217
405
  readonly opcode: number;
218
406
  readonly payload: unknown;
219
407
  readonly flags?: number;
220
408
  readonly laneId?: number;
409
+ /** @internal Correlated compact claim shape used to decode a direct response without guessing. */
410
+ readonly compactClaimMode?: CompactClaimMode;
411
+ /** @internal Correlated compact claim shapes for native pipeline response items. */
412
+ readonly pipelineClaimModes?: readonly (CompactClaimMode | undefined)[];
413
+ /** @internal Parsed routing metadata retained when a command uses COMMAND_EXEC. */
414
+ readonly routing?: ProtocolRoutingHints;
415
+ /** @internal Server-side blocking duration used to derive a safe response timeout. */
416
+ readonly serverBlockMs?: number;
417
+ }
418
+ type CompactClaimMode = "base" | "attrs" | "state" | "stateAttrs";
419
+ interface ProtocolRoutingHints {
420
+ readonly flowPartitionKey?: unknown;
421
+ readonly flowPartitionKeys?: readonly unknown[];
221
422
  }
222
423
 
223
- interface CommandExecutor {
224
- executeCommand(...args: CommandArgument[]): Promise<unknown>;
225
- executePipeline?(commands: readonly Command[], options?: ExecutePipelineOptions): Promise<unknown[]>;
226
- refreshTopology?(): Promise<RoutingTopology>;
227
- route?(key: string | Buffer$1): Promise<RoutingRoute> | RoutingRoute;
228
- close?(): Promise<void> | void;
229
- }
230
- interface ExecutePipelineOptions {
231
- throwOnItemError?: boolean;
232
- }
233
- interface NativeAdapterOptions {
234
- autoReconnect?: boolean | ReconnectOptions;
235
- clientName?: string;
236
- connectTimeoutMs?: number;
237
- endpointPolicy?: EndpointPolicy;
238
- endpointValidator?: (endpoint: RoutingEndpoint) => boolean | void;
239
- haRouting?: boolean;
240
- heartbeatIntervalMs?: number;
241
- keepAlive?: boolean;
242
- keepAliveInitialDelayMs?: number;
243
- maxChunkBytes?: number;
244
- protocolLanes?: number;
245
- seeds?: readonly string[];
246
- timeoutMs?: number;
247
- trustedHosts?: readonly string[];
248
- username?: string;
249
- password?: string;
250
- tlsOptions?: tls.ConnectionOptions;
251
- warmConnections?: boolean;
252
- }
253
- interface ReconnectOptions {
254
- maxRetries?: number;
255
- }
256
424
  declare class NativeAdapter implements CommandExecutor {
257
425
  private readonly socket;
258
426
  private readonly pending;
259
- private readonly chunks;
260
- private readonly chunkBytes;
261
- private buffer;
427
+ private readonly flowControl;
428
+ private readonly closedWaiters;
429
+ private readonly chunkAssembler;
262
430
  private closed;
263
- private dataLane;
264
- private readonly maxChunkBytes;
265
- private requestId;
266
- private readonly protocolLanes;
267
- private readonly heartbeatIntervalMs?;
268
- private heartbeatInFlight;
269
- private heartbeatTimer?;
270
- private lastActivityMs;
431
+ private protocolLanes;
432
+ private maxPipelineCommands;
433
+ private maxRequestFrameBytes;
434
+ private pendingControlRequests;
435
+ private readonly maxPendingControlRequests;
436
+ private readonly heartbeat;
437
+ private readonly heartbeatIntervalMs;
438
+ private readonly responseHandler;
439
+ private readonly requestScheduler;
271
440
  private readonly timeoutMs;
441
+ private draining;
442
+ private readonly writeQueue;
272
443
  private constructor();
273
444
  static fromUrl(url: string, options?: NativeAdapterOptions): Promise<NativeAdapter>;
445
+ /** @internal Closed and GOAWAY-draining adapters must not receive new work. */
446
+ get isUnavailable(): boolean;
274
447
  executeCommand(...args: CommandArgument[]): Promise<unknown>;
448
+ executeCommandArgs(args: readonly CommandArgument[]): Promise<unknown>;
449
+ /** @internal Execute raw command arguments on a topology-selected lane. */
450
+ executeCommandOnLane(args: readonly CommandArgument[], laneId: number): Promise<unknown>;
275
451
  executeProtocolCommand(command: ProtocolCommand, laneId?: number): Promise<unknown>;
276
452
  executePipeline(commands: readonly Command[], options?: ExecutePipelineOptions): Promise<unknown[]>;
453
+ /** @internal Attempt one physical pipeline request without splitting or fallback. */
454
+ executeFusedPipeline(commands: readonly Command[], options?: ExecutePipelineOptions): Promise<unknown[] | undefined>;
455
+ /** @internal Attempt one physical pipeline request on a topology-selected lane. */
456
+ executeFusedPipelineOnLane(commands: readonly Command[], laneId: number | undefined, options?: ExecutePipelineOptions): Promise<unknown[] | undefined>;
457
+ /** @internal Execute an ordered pipeline on a topology-selected lane. */
458
+ executePipelineOnLane(commands: readonly Command[], laneId: number | undefined, options?: ExecutePipelineOptions): Promise<unknown[]>;
277
459
  close(): Promise<void>;
278
460
  private startup;
279
- private auth;
280
461
  private request;
281
- private startHeartbeat;
282
- private stopHeartbeat;
283
- private sendHeartbeat;
284
- private onData;
285
- private handleFrame;
462
+ private waitForCreditAndSend;
463
+ private sendAcquiredRequest;
464
+ private timeoutPending;
465
+ private finishDrainIfIdle;
286
466
  private failAll;
287
- private cleanupChunksForRequest;
288
- private nextRequestId;
289
- private assignLane;
467
+ /** @internal Gracefully stop new requests and close after correlated requests settle. */
468
+ retire(): Promise<void>;
469
+ private beginDraining;
470
+ private resolveClosedWaiters;
471
+ private takePending;
472
+ private applyFlowControlLimits;
473
+ private applyStartupLimits;
290
474
  }
475
+
291
476
  declare class ReconnectingExecutor implements CommandExecutor {
292
477
  private readonly createExecutor;
478
+ private readonly baseDelayMs;
293
479
  private closed;
480
+ private closePromise?;
481
+ private readonly jitterPct;
482
+ private readonly maxDelayMs;
294
483
  private readonly maxRetries;
484
+ private readonly retryAbortController;
295
485
  private executorPromise;
296
486
  private reconnectPromise?;
297
- constructor(createExecutor: () => Promise<CommandExecutor>, options?: ReconnectOptions);
487
+ constructor(createExecutor: (signal?: AbortSignal) => Promise<CommandExecutor>, options?: ReconnectOptions);
298
488
  executeCommand(...args: CommandArgument[]): Promise<unknown>;
489
+ executeCommandArgs(args: readonly CommandArgument[]): Promise<unknown>;
490
+ ready(): Promise<void>;
299
491
  executePipeline(commands: readonly Command[], options?: ExecutePipelineOptions): Promise<unknown[]>;
492
+ executeFusedPipeline(commands: readonly Command[], options?: ExecutePipelineOptions): Promise<unknown[] | undefined>;
300
493
  refreshTopology(): Promise<RoutingTopology>;
301
494
  route(key: string | Buffer$1): Promise<RoutingRoute>;
302
495
  close(): Promise<void>;
303
496
  private withReconnect;
497
+ private waitBeforeReconnect;
304
498
  private reconnect;
305
499
  }
306
500
  declare function isReconnectableClosedConnectionError(error: unknown): boolean;
307
501
 
308
- interface StoreCommandClient {
309
- readonly codec: Codec;
310
- command(...args: CommandArgument[]): Promise<unknown>;
502
+ type ExceptionPolicy = "retry" | "fail" | "raise";
503
+ type BackoffKind = "fixed" | "linear" | "exponential";
504
+ type WorkerProfile = "latency" | "throughput";
505
+ type WorkerRefillStrategy = "continuous" | "wave";
506
+ interface RetryPolicy {
507
+ maxRetries?: number;
508
+ backoff?: BackoffKind | string;
509
+ baseMs?: number;
510
+ maxMs?: number;
511
+ jitterPct?: number;
512
+ exhaustedTo?: string;
311
513
  }
312
- interface SetOptions {
313
- ex?: number;
314
- px?: number;
315
- exat?: number;
316
- pxat?: number;
317
- nx?: boolean;
318
- xx?: boolean;
319
- get?: boolean;
320
- keepTtl?: boolean;
514
+ interface BackpressurePolicy {
515
+ maxRetries?: number;
516
+ baseDelayMs?: number;
517
+ maxDelayMs?: number;
518
+ jitterPct?: number;
321
519
  }
322
- interface GetExOptions {
323
- ex?: number;
324
- px?: number;
325
- exat?: number;
326
- pxat?: number;
327
- persist?: boolean;
520
+ interface ValueConfig {
521
+ valueMaxBytes?: number;
522
+ localCache?: boolean;
328
523
  }
329
- interface ScanOptions {
330
- match?: string;
331
- count?: number;
524
+ interface WorkerConfig {
525
+ profile?: WorkerProfile;
526
+ /** Alias for concurrency when concurrency is omitted. */
527
+ workers?: number;
528
+ /** Maximum simultaneously running per-job handlers and claim credit. */
529
+ concurrency?: number;
530
+ /** Refill free per-job slots continuously or wait for the current wave. Defaults to continuous in run(). */
531
+ refillStrategy?: WorkerRefillStrategy;
532
+ /** Additional slot-refill coalescing delay in milliseconds. Zero still coalesces one event-loop turn. */
533
+ refillDelayMs?: number;
534
+ /** Pipeline batchable completions with replacement claims when routes match. Defaults to true. */
535
+ fuseCompleteClaim?: boolean;
536
+ /** Claim and terminal mutation batch size, capped at the server Flow limit of 1,000. */
537
+ batchSize?: number;
538
+ leaseMs?: number;
539
+ /** Automatically extend leases while handlers run. Defaults to true. */
540
+ leaseRenewal?: boolean;
541
+ /** Lease-renewal interval in milliseconds. Defaults to half of leaseMs. */
542
+ leaseRenewIntervalMs?: number;
543
+ priority?: number;
544
+ nowMs?: number;
545
+ partitionKey?: string;
546
+ partitionKeys?: string[];
547
+ reclaimExpired?: boolean;
548
+ reclaimRatio?: number;
549
+ claimPayload?: boolean;
550
+ claimValues?: string[];
551
+ /** Include Flow attributes in compact worker claims. Defaults to false. */
552
+ claimAttributes?: boolean;
553
+ valueMaxBytes?: number;
554
+ blockMs?: number;
555
+ /** Maximum server block interval while signal is present, bounding safe shutdown latency. */
556
+ abortPollMs?: number;
557
+ idleSleepMs?: number;
558
+ maxIdleSleepMs?: number;
559
+ exceptionPolicy?: ExceptionPolicy;
560
+ /** Persist handler Error.stack for diagnostics. Defaults to false because stacks can expose paths or secrets. */
561
+ includeErrorStack?: boolean;
562
+ /** Maximum asynchronous terminal batches; non-finite values use the worker-mode default. */
563
+ completeAsyncDepth?: number;
564
+ completeIndependent?: boolean;
565
+ /** Maximum sequential non-blocking claims performed by one runOnce call. */
566
+ claimDrainBatches?: number;
567
+ signal?: AbortSignal;
568
+ worker?: string;
332
569
  }
333
- interface ZAddMember {
334
- score: number;
335
- member: unknown;
570
+
571
+ type MaxActiveMs = number | "infinity";
572
+ /** An exact Flow fencing token; bigint is used beyond JavaScript's safe integer range. */
573
+ type FencingToken = number | bigint;
574
+ interface ChildSpec {
575
+ id: string;
576
+ type: string;
577
+ payload?: unknown;
578
+ partitionKey?: string;
579
+ values?: Record<string, unknown>;
580
+ valueRefs?: Record<string, string>;
336
581
  }
337
- interface ZAddOptions {
338
- nx?: boolean;
339
- xx?: boolean;
340
- gt?: boolean;
341
- lt?: boolean;
342
- ch?: boolean;
582
+ type StateMetaValue = string | number | boolean | Buffer;
583
+ type StateMeta = Record<string, StateMetaValue>;
584
+ interface CreateItem {
585
+ id: string;
586
+ payload?: unknown;
587
+ partitionKey?: string;
588
+ attributes?: Record<string, CommandArgument>;
589
+ values?: Record<string, unknown>;
590
+ valueRefs?: Record<string, string>;
591
+ stateMeta?: StateMeta;
343
592
  }
344
- interface RangeLimit {
345
- offset: number;
346
- count: number;
593
+ /** @internal */
594
+ declare const CLAIMED_ITEM_WIRE: unique symbol;
595
+ /** @internal */
596
+ interface ClaimedItemWire {
597
+ id: Buffer;
598
+ partitionKey?: Buffer | null;
599
+ leaseToken: Buffer;
600
+ fencingToken: FencingToken;
347
601
  }
348
- interface XReadStream {
349
- key: string;
602
+ interface ClaimedItem<TPayload = unknown> {
350
603
  id: string;
604
+ leaseToken: Buffer;
605
+ fencingToken: FencingToken;
606
+ partitionKey?: string;
607
+ /** Present when supplied by a full response or known compact-claim context. */
608
+ type?: string;
609
+ state: string;
610
+ runState?: string;
611
+ payload?: TPayload | null;
612
+ attributes?: Record<string, unknown>;
613
+ /** @internal */
614
+ [CLAIMED_ITEM_WIRE]?: ClaimedItemWire;
351
615
  }
352
- interface GeoMember {
353
- longitude: number;
354
- latitude: number;
355
- member: unknown;
356
- }
357
- interface GeoAddOptions {
358
- nx?: boolean;
359
- xx?: boolean;
360
- ch?: boolean;
616
+ interface FencedItem {
617
+ id: string;
618
+ fencingToken: FencingToken;
619
+ leaseToken?: Buffer;
620
+ partitionKey?: string;
361
621
  }
362
- declare class KeyValueStore {
363
- private readonly client;
364
- constructor(client: StoreCommandClient);
365
- get<T = unknown>(key: string): Promise<T | null>;
366
- set(key: string, value: unknown, options?: SetOptions): Promise<unknown>;
367
- del(...keys: string[]): Promise<number>;
368
- exists(...keys: string[]): Promise<number>;
369
- mget<T = unknown>(keys: string[]): Promise<(T | null)[]>;
370
- mset(entries: Record<string, unknown> | [string, unknown][]): Promise<boolean>;
371
- msetnx(entries: Record<string, unknown> | [string, unknown][]): Promise<boolean>;
372
- incr(key: string): Promise<number>;
373
- decr(key: string): Promise<number>;
374
- incrby(key: string, increment: number): Promise<number>;
375
- decrby(key: string, decrement: number): Promise<number>;
376
- incrbyfloat(key: string, increment: number): Promise<string>;
377
- append(key: string, value: unknown): Promise<number>;
378
- strlen(key: string): Promise<number>;
379
- getset<T = unknown>(key: string, value: unknown): Promise<T | null>;
380
- getdel<T = unknown>(key: string): Promise<T | null>;
381
- getex<T = unknown>(key: string, options?: GetExOptions): Promise<T | null>;
382
- setnx(key: string, value: unknown): Promise<boolean>;
383
- setex(key: string, seconds: number, value: unknown): Promise<boolean>;
384
- psetex(key: string, milliseconds: number, value: unknown): Promise<boolean>;
385
- getrange(key: string, start: number, end: number): Promise<Buffer | string | unknown>;
386
- setrange(key: string, offset: number, value: unknown): Promise<number>;
387
- expire(key: string, seconds: number): Promise<boolean>;
388
- pexpire(key: string, milliseconds: number): Promise<boolean>;
389
- expireat(key: string, unixSeconds: number): Promise<boolean>;
390
- pexpireat(key: string, unixMilliseconds: number): Promise<boolean>;
391
- ttl(key: string): Promise<number>;
392
- pttl(key: string): Promise<number>;
393
- persist(key: string): Promise<boolean>;
394
- expiretime(key: string): Promise<number>;
395
- pexpiretime(key: string): Promise<number>;
396
- type(key: string): Promise<string>;
397
- unlink(...keys: string[]): Promise<number>;
398
- rename(key: string, newKey: string): Promise<boolean>;
399
- renamenx(key: string, newKey: string): Promise<boolean>;
400
- copy(source: string, destination: string, options?: {
401
- replace?: boolean;
402
- }): Promise<boolean>;
403
- randomkey(): Promise<string | null>;
404
- keys(pattern: string): Promise<unknown[]>;
405
- scan(cursor: string | number, options?: ScanOptions): Promise<unknown>;
406
- dbsize(): Promise<number>;
407
- flushdb(mode?: "ASYNC" | "SYNC"): Promise<boolean>;
408
- flushall(mode?: "ASYNC" | "SYNC"): Promise<boolean>;
409
- objectEncoding(key: string): Promise<string | null>;
410
- objectHelp(): Promise<unknown[]>;
411
- objectFreq(key: string): Promise<number>;
412
- objectIdleTime(key: string): Promise<number>;
413
- objectRefcount(key: string): Promise<number>;
414
- wait(numReplicas: number, timeoutMs: number): Promise<number>;
415
- waitAof(numLocal: number, numReplicas: number, timeoutMs: number): Promise<unknown[]>;
416
- memoryUsage(key: string): Promise<number>;
622
+ interface RateLimitResult {
623
+ status: string;
624
+ count: number;
625
+ remaining: number;
626
+ resetMs: number;
627
+ allowed: boolean;
417
628
  }
418
- declare class HashStore {
419
- private readonly client;
420
- constructor(client: StoreCommandClient);
421
- hset(key: string, entries: Record<string, unknown> | [string, unknown][]): Promise<number>;
422
- hget<T = unknown>(key: string, field: string): Promise<T | null>;
423
- hdel(key: string, ...fields: string[]): Promise<number>;
424
- hmget<T = unknown>(key: string, fields: string[]): Promise<(T | null)[]>;
425
- hgetall(key: string): Promise<unknown>;
426
- hexists(key: string, field: string): Promise<boolean>;
427
- hkeys(key: string): Promise<unknown[]>;
428
- hvals<T = unknown>(key: string): Promise<(T | null)[]>;
429
- hlen(key: string): Promise<number>;
430
- hincrby(key: string, field: string, increment: number): Promise<number>;
431
- hincrbyfloat(key: string, field: string, increment: number): Promise<string>;
432
- hsetnx(key: string, field: string, value: unknown): Promise<boolean>;
433
- hstrlen(key: string, field: string): Promise<number>;
434
- hrandfield(key: string, count?: number, withValues?: boolean): Promise<unknown>;
435
- hscan(key: string, cursor: string | number, options?: ScanOptions): Promise<unknown>;
436
- hexpire(key: string, seconds: number, fields: string[]): Promise<unknown[]>;
437
- httl(key: string, fields: string[]): Promise<unknown[]>;
438
- hpersist(key: string, fields: string[]): Promise<unknown[]>;
439
- hpexpire(key: string, milliseconds: number, fields: string[]): Promise<unknown[]>;
440
- hpttl(key: string, fields: string[]): Promise<unknown[]>;
441
- hexpiretime(key: string, fields: string[]): Promise<unknown[]>;
442
- hgetdel<T = unknown>(key: string, fields: string[]): Promise<(T | null)[]>;
443
- hgetex<T = unknown>(key: string, fields: string[], options?: GetExOptions): Promise<(T | null)[]>;
444
- hsetex(key: string, seconds: number, entries: Record<string, unknown> | [string, unknown][]): Promise<number>;
629
+ interface KeyInfo {
630
+ type: string;
631
+ valueSize: number;
632
+ ttlMs: number;
633
+ hotCacheStatus: string;
634
+ lastWriteShard: number;
635
+ raw: Record<string, unknown>;
445
636
  }
446
- declare class ListStore {
447
- private readonly client;
448
- constructor(client: StoreCommandClient);
449
- lpush(key: string, ...elements: unknown[]): Promise<number>;
450
- rpush(key: string, ...elements: unknown[]): Promise<number>;
451
- lpop<T = unknown>(key: string, count?: number): Promise<T | (T | null)[] | null>;
452
- rpop<T = unknown>(key: string, count?: number): Promise<T | (T | null)[] | null>;
453
- lrange<T = unknown>(key: string, start: number, stop: number): Promise<(T | null)[]>;
454
- llen(key: string): Promise<number>;
455
- lindex<T = unknown>(key: string, index: number): Promise<T | null>;
456
- lset(key: string, index: number, element: unknown): Promise<boolean>;
457
- lrem(key: string, count: number, element: unknown): Promise<number>;
458
- ltrim(key: string, start: number, stop: number): Promise<boolean>;
459
- lpos(key: string, element: unknown, options?: {
460
- rank?: number;
461
- count?: number;
462
- maxlen?: number;
463
- }): Promise<unknown>;
464
- linsert(key: string, where: "BEFORE" | "AFTER", pivot: unknown, element: unknown): Promise<number>;
465
- lmove(source: string, destination: string, from: "LEFT" | "RIGHT", to: "LEFT" | "RIGHT"): Promise<unknown>;
466
- rpoplpush(source: string, destination: string): Promise<unknown>;
467
- lpushx(key: string, ...elements: unknown[]): Promise<number>;
468
- rpushx(key: string, ...elements: unknown[]): Promise<number>;
469
- blpop(keys: string[], timeoutSeconds: number): Promise<unknown>;
470
- brpop(keys: string[], timeoutSeconds: number): Promise<unknown>;
471
- blmove(source: string, destination: string, from: "LEFT" | "RIGHT", to: "LEFT" | "RIGHT", timeoutSeconds: number): Promise<unknown>;
472
- blmpop(timeoutSeconds: number, keys: string[], from: "LEFT" | "RIGHT", options?: {
473
- count?: number;
474
- }): Promise<unknown>;
637
+ interface FetchOrComputeHitResult<T = unknown> {
638
+ readonly computeMode: "hit";
639
+ readonly hit: true;
640
+ readonly shouldCompute: false;
641
+ readonly status: "hit";
642
+ readonly value: T | null;
643
+ }
644
+ interface FetchOrComputeLegacyResult {
645
+ /** Opaque application hint echoed for the process elected to compute. */
646
+ readonly computeHint: Buffer;
647
+ readonly computeMode: "legacy";
648
+ /** Explicit null distinguishes a legacy tokenless lease from an omitted token. */
649
+ readonly computeToken: null;
650
+ readonly hit: false;
651
+ readonly shouldCompute: true;
652
+ readonly status: "compute";
653
+ }
654
+ interface FetchOrComputeFencedResult {
655
+ /** Opaque application hint echoed for the process elected to compute. */
656
+ readonly computeHint: Buffer;
657
+ readonly computeMode: "fenced";
658
+ /** Fencing token required when publishing the computed result or error. */
659
+ readonly computeToken: Buffer;
660
+ readonly hit: false;
661
+ readonly shouldCompute: true;
662
+ readonly status: "compute";
663
+ }
664
+ type FetchOrComputeComputeResult = FetchOrComputeLegacyResult | FetchOrComputeFencedResult;
665
+ type FetchOrComputeResult<T = unknown> = FetchOrComputeHitResult<T> | FetchOrComputeComputeResult;
666
+ interface FlowRecord<TPayload = unknown> {
667
+ id: string;
668
+ type: string;
669
+ state: string;
670
+ partitionKey: string;
671
+ runState?: string;
672
+ payload?: TPayload | null;
673
+ leaseToken: Buffer;
674
+ fencingToken: FencingToken;
675
+ version: number;
676
+ parentFlowId?: string;
677
+ rootFlowId?: string;
678
+ correlationId?: string;
679
+ maxActiveMs?: number;
680
+ valueRefs?: Record<string, unknown>;
681
+ values?: Record<string, unknown>;
682
+ valueSizes?: Record<string, unknown>;
683
+ valueOmitted?: Record<string, unknown>;
684
+ valueMissing?: Record<string, unknown>;
685
+ attributes?: Record<string, unknown>;
686
+ stateMeta?: Record<string, unknown>;
687
+ indexedStateMeta?: string;
688
+ raw?: unknown;
475
689
  }
476
- declare class SetStore {
477
- private readonly client;
478
- constructor(client: StoreCommandClient);
479
- sadd(key: string, ...members: unknown[]): Promise<number>;
480
- srem(key: string, ...members: unknown[]): Promise<number>;
481
- smembers<T = unknown>(key: string): Promise<(T | null)[]>;
482
- sismember(key: string, member: unknown): Promise<boolean>;
483
- smismember(key: string, members: unknown[]): Promise<unknown[]>;
484
- scard(key: string): Promise<number>;
485
- srandmember<T = unknown>(key: string, count?: number): Promise<T | (T | null)[] | null>;
486
- spop<T = unknown>(key: string, count?: number): Promise<T | (T | null)[] | null>;
487
- sdiff<T = unknown>(keys: string[]): Promise<(T | null)[]>;
488
- sinter<T = unknown>(keys: string[]): Promise<(T | null)[]>;
489
- sunion<T = unknown>(keys: string[]): Promise<(T | null)[]>;
490
- sdiffstore(destination: string, keys: string[]): Promise<number>;
491
- sinterstore(destination: string, keys: string[]): Promise<number>;
492
- sunionstore(destination: string, keys: string[]): Promise<number>;
493
- sintercard(keys: string[], limit?: number): Promise<number>;
494
- smove(source: string, destination: string, member: unknown): Promise<boolean>;
495
- sscan(key: string, cursor: string | number, options?: ScanOptions): Promise<unknown>;
690
+
691
+ type FlowAdminRecord = Record<string, unknown>;
692
+ interface FlowStatsOptions {
693
+ state?: string;
694
+ partitionKey?: string;
695
+ count?: number;
696
+ attributes?: Record<string, CommandArgument>;
697
+ consistentProjection?: boolean;
496
698
  }
497
- declare class SortedSetStore {
498
- private readonly client;
499
- constructor(client: StoreCommandClient);
500
- zadd(key: string, members: ZAddMember[], options?: ZAddOptions): Promise<number>;
501
- zscore(key: string, member: unknown): Promise<string | null>;
502
- zrank(key: string, member: unknown): Promise<number | null>;
503
- zrevrank(key: string, member: unknown): Promise<number | null>;
504
- zrange(key: string, start: number, stop: number, options?: {
505
- withScores?: boolean;
506
- }): Promise<unknown[]>;
507
- zrevrange(key: string, start: number, stop: number, options?: {
508
- withScores?: boolean;
509
- }): Promise<unknown[]>;
510
- zcard(key: string): Promise<number>;
511
- zrem(key: string, ...members: unknown[]): Promise<number>;
512
- zincrby(key: string, increment: number, member: unknown): Promise<string>;
513
- zcount(key: string, min: string | number, max: string | number): Promise<number>;
514
- zpopmin(key: string, count?: number): Promise<unknown[]>;
515
- zpopmax(key: string, count?: number): Promise<unknown[]>;
516
- zrandmember(key: string, count?: number, withScores?: boolean): Promise<unknown>;
517
- zmscore(key: string, members: unknown[]): Promise<unknown[]>;
518
- zrangebyscore(key: string, min: string | number, max: string | number, options?: {
519
- withScores?: boolean;
520
- limit?: RangeLimit;
521
- }): Promise<unknown[]>;
522
- zrevrangebyscore(key: string, max: string | number, min: string | number, options?: {
523
- withScores?: boolean;
524
- limit?: RangeLimit;
525
- }): Promise<unknown[]>;
526
- zscan(key: string, cursor: string | number, options?: ScanOptions): Promise<unknown>;
699
+ interface AttributeQueryOptions {
700
+ state?: string;
701
+ partitionKey?: string;
702
+ count?: number;
703
+ consistentProjection?: boolean;
527
704
  }
528
- declare class StreamStore {
529
- private readonly client;
530
- constructor(client: StoreCommandClient);
531
- xadd(key: string, id: string, fields: Record<string, unknown> | [string, unknown][]): Promise<unknown>;
532
- xlen(key: string): Promise<number>;
533
- xrange(key: string, start?: string, end?: string, count?: number): Promise<unknown[]>;
534
- xrevrange(key: string, end?: string, start?: string, count?: number): Promise<unknown[]>;
535
- xread(streams: XReadStream[], options?: {
536
- count?: number;
537
- blockMs?: number;
538
- }): Promise<unknown>;
539
- xtrim(key: string, strategy: "MAXLEN" | "MINID", threshold: string | number, approximate?: boolean): Promise<number>;
540
- xdel(key: string, ...ids: string[]): Promise<number>;
541
- xinfoStream(key: string): Promise<unknown>;
542
- xgroupCreate(key: string, group: string, id: string, mkstream?: boolean): Promise<boolean>;
543
- xreadgroup(group: string, consumer: string, streams: XReadStream[], options?: {
544
- count?: number;
545
- blockMs?: number;
546
- noack?: boolean;
547
- }): Promise<unknown>;
548
- xack(key: string, group: string, ...ids: string[]): Promise<number>;
705
+ interface ScheduleOptions {
706
+ target: Record<string, unknown>;
707
+ kind?: string;
708
+ atMs?: number;
709
+ delayMs?: number;
710
+ startAtMs?: number;
711
+ everyMs?: number;
712
+ cron?: string;
713
+ timezone?: string;
714
+ overlapPolicy?: string;
715
+ overlapRetryMs?: number;
716
+ maxFires?: number;
717
+ endAtMs?: number;
718
+ overwrite?: boolean;
719
+ nowMs?: number;
720
+ extraOptions?: Record<string, CommandArgument>;
549
721
  }
550
- declare class BitmapStore {
551
- private readonly client;
552
- constructor(client: StoreCommandClient);
553
- setbit(key: string, offset: number, value: 0 | 1): Promise<number>;
554
- getbit(key: string, offset: number): Promise<number>;
555
- bitcount(key: string, start?: number, end?: number, unit?: "BYTE" | "BIT"): Promise<number>;
556
- bitpos(key: string, bit: 0 | 1, start?: number, end?: number, unit?: "BYTE" | "BIT"): Promise<number>;
557
- bitop(operation: "AND" | "OR" | "XOR" | "NOT", destination: string, ...keys: string[]): Promise<number>;
722
+ interface ScheduleListOptions {
723
+ kind?: string;
724
+ state?: string;
725
+ timezone?: string;
726
+ targetType?: string;
727
+ fromMs?: number;
728
+ toMs?: number;
729
+ count?: number;
730
+ rev?: boolean;
558
731
  }
559
- declare class HyperLogLogStore {
560
- private readonly client;
561
- constructor(client: StoreCommandClient);
562
- pfadd(key: string, ...elements: unknown[]): Promise<number>;
563
- pfcount(...keys: string[]): Promise<number>;
564
- pfmerge(destination: string, ...sources: string[]): Promise<boolean>;
732
+ interface ScheduleFireDueOptions {
733
+ nowMs?: number;
734
+ worker?: string;
735
+ blockMs?: number;
736
+ limit?: number;
565
737
  }
566
- declare class GeoStore {
567
- private readonly client;
568
- constructor(client: StoreCommandClient);
569
- geoadd(key: string, members: GeoMember[], options?: GeoAddOptions): Promise<number>;
570
- geopos(key: string, ...members: unknown[]): Promise<unknown[]>;
571
- geodist(key: string, member1: unknown, member2: unknown, unit?: "m" | "km" | "mi" | "ft"): Promise<string | null>;
572
- geohash(key: string, ...members: unknown[]): Promise<unknown[]>;
573
- geosearch(key: string, args: CommandArgument[]): Promise<unknown[]>;
574
- geosearchstore(destination: string, source: string, args: CommandArgument[]): Promise<number>;
738
+ interface EffectReserveOptions {
739
+ partitionKey?: string;
740
+ leaseToken?: Buffer;
741
+ fencingToken?: FencingToken;
742
+ operationDigest: string;
743
+ idempotencyKey?: string;
744
+ governanceScope?: string;
745
+ nowMs?: number;
575
746
  }
576
-
577
- interface TopKReserveOptions {
578
- width?: number;
579
- depth?: number;
580
- decay?: number;
747
+ interface EffectStatusOptions {
748
+ partitionKey?: string;
749
+ leaseToken?: Buffer;
750
+ fencingToken?: FencingToken;
751
+ nowMs?: number;
581
752
  }
582
- interface CountMinMergeOptions {
583
- weights?: number[];
753
+ interface EffectConfirmOptions extends EffectStatusOptions {
754
+ externalId?: string;
755
+ latencyMs?: number;
756
+ }
757
+ interface EffectFailOptions extends EffectStatusOptions {
758
+ error?: string;
759
+ reason?: string;
760
+ latencyMs?: number;
761
+ }
762
+ interface EffectCompensateOptions extends EffectStatusOptions {
763
+ externalId?: string;
764
+ reason?: string;
765
+ }
766
+ interface ApprovalRequestOptions {
767
+ flowId: string;
768
+ scope: string;
769
+ reason?: string;
770
+ requestedBy?: string;
771
+ assignees?: readonly string[];
772
+ policyHash?: string;
773
+ policyVersion?: string | number;
774
+ timeoutMs?: number;
775
+ expiresAtMs?: number;
776
+ nowMs?: number;
584
777
  }
585
- interface TDigestCreateOptions {
586
- compression?: number;
778
+ interface ApprovalListOptions {
779
+ status?: string;
780
+ scope?: string;
781
+ partitionKey?: string;
782
+ flowId?: string;
783
+ limit?: number;
587
784
  }
588
- interface TDigestMergeOptions extends TDigestCreateOptions {
589
- override?: boolean;
785
+ interface CircuitOpenOptions {
786
+ openMs?: number;
787
+ failureThreshold?: number;
788
+ nowMs?: number;
590
789
  }
591
- interface JsonSetOptions {
592
- nx?: boolean;
593
- xx?: boolean;
790
+ interface BudgetReserveOptions {
791
+ limit?: number;
792
+ windowMs?: number;
793
+ reservationId?: string;
794
+ nowMs?: number;
594
795
  }
595
- declare class BloomFilterStore {
596
- private readonly client;
597
- constructor(client: StoreCommandClient);
598
- reserve(key: string, errorRate: number, capacity: number): Promise<boolean>;
599
- add(key: string, element: unknown): Promise<boolean>;
600
- madd(key: string, ...elements: unknown[]): Promise<number[]>;
601
- exists(key: string, element: unknown): Promise<boolean>;
602
- mexists(key: string, ...elements: unknown[]): Promise<number[]>;
603
- card(key: string): Promise<number>;
604
- info(key: string): Promise<unknown[]>;
796
+ interface BudgetCommitOptions {
797
+ usage?: Record<string, unknown>;
798
+ nowMs?: number;
605
799
  }
606
- declare class CuckooFilterStore {
607
- private readonly client;
608
- constructor(client: StoreCommandClient);
609
- reserve(key: string, capacity: number): Promise<boolean>;
610
- add(key: string, element: unknown): Promise<boolean>;
611
- addnx(key: string, element: unknown): Promise<boolean>;
612
- del(key: string, element: unknown): Promise<boolean>;
613
- exists(key: string, element: unknown): Promise<boolean>;
614
- mexists(key: string, ...elements: unknown[]): Promise<number[]>;
615
- count(key: string, element: unknown): Promise<number>;
616
- info(key: string): Promise<unknown[]>;
800
+ interface AdminListOptions {
801
+ scope?: string;
802
+ partitionKey?: string;
803
+ limit?: number;
617
804
  }
618
- declare class CountMinSketchStore {
619
- private readonly client;
620
- constructor(client: StoreCommandClient);
621
- initByDim(key: string, width: number, depth: number): Promise<boolean>;
622
- initByProb(key: string, error: number, probability: number): Promise<boolean>;
623
- incrBy(key: string, entries: [unknown, number][]): Promise<number[]>;
624
- query(key: string, ...items: unknown[]): Promise<number[]>;
625
- merge(destination: string, sources: string[], options?: CountMinMergeOptions): Promise<boolean>;
626
- info(key: string): Promise<unknown[]>;
805
+ interface LimitListOptions extends AdminListOptions {
806
+ nowMs?: number;
627
807
  }
628
- declare class TopKStore {
629
- private readonly client;
630
- constructor(client: StoreCommandClient);
631
- reserve(key: string, k: number, options?: TopKReserveOptions): Promise<boolean>;
632
- add<T = unknown>(key: string, ...elements: unknown[]): Promise<(T | null)[]>;
633
- incrBy<T = unknown>(key: string, entries: [unknown, number][]): Promise<(T | null)[]>;
634
- query(key: string, ...elements: unknown[]): Promise<number[]>;
635
- list<T = unknown>(key: string, options?: {
636
- withCount?: boolean;
637
- }): Promise<(T | number | null)[]>;
638
- info(key: string): Promise<unknown[]>;
639
- }
640
- declare class TDigestStore {
641
- private readonly client;
642
- constructor(client: StoreCommandClient);
643
- create(key: string, options?: TDigestCreateOptions): Promise<boolean>;
644
- add(key: string, ...values: number[]): Promise<boolean>;
645
- reset(key: string): Promise<boolean>;
646
- quantile(key: string, ...quantiles: number[]): Promise<string[]>;
647
- cdf(key: string, ...values: number[]): Promise<string[]>;
648
- rank(key: string, ...values: number[]): Promise<number[]>;
649
- revrank(key: string, ...values: number[]): Promise<number[]>;
650
- byrank(key: string, ...ranks: number[]): Promise<string[]>;
651
- byrevrank(key: string, ...ranks: number[]): Promise<string[]>;
652
- trimmedMean(key: string, low: number, high: number): Promise<string>;
653
- min(key: string): Promise<string>;
654
- max(key: string): Promise<string>;
655
- info(key: string): Promise<unknown[]>;
656
- merge(destination: string, sources: string[], options?: TDigestMergeOptions): Promise<boolean>;
657
- }
658
- declare class JsonStore {
659
- private readonly client;
660
- constructor(client: StoreCommandClient);
661
- set(key: string, path: string, value: unknown, options?: JsonSetOptions): Promise<boolean>;
662
- get<T = unknown>(key: string, paths?: string | string[]): Promise<T | null>;
663
- del(key: string, path?: string): Promise<number>;
664
- numIncrBy(key: string, path: string, value: number): Promise<string>;
665
- type(key: string, path?: string): Promise<string | null>;
666
- strlen(key: string, path?: string): Promise<number | null>;
667
- objKeys(key: string, path?: string): Promise<unknown[]>;
668
- objLen(key: string, path?: string): Promise<number>;
669
- arrAppend(key: string, path: string, ...values: unknown[]): Promise<number>;
670
- arrLen(key: string, path?: string): Promise<number>;
671
- toggle(key: string, path: string): Promise<number>;
672
- clear(key: string, path?: string): Promise<number>;
673
- mget<T = unknown>(keys: string[], path: string): Promise<(T | null)[]>;
674
- }
675
-
676
- type ExceptionPolicy = "retry" | "fail" | "raise";
677
- type BackoffKind = "fixed" | "linear" | "exponential";
678
- type WorkerProfile = "latency" | "throughput";
679
- interface RetryPolicy {
680
- maxRetries?: number;
681
- backoff?: BackoffKind | string;
682
- baseMs?: number;
683
- maxMs?: number;
684
- jitterPct?: number;
685
- exhaustedTo?: string;
686
- }
687
- interface BackpressurePolicy {
688
- maxRetries?: number;
689
- baseDelayMs?: number;
690
- maxDelayMs?: number;
691
- jitterPct?: number;
692
- }
693
- interface ValueConfig {
694
- valueMaxBytes?: number;
695
- localCache?: boolean;
696
- }
697
- interface WorkerConfig {
698
- profile?: WorkerProfile;
699
- workers?: number;
700
- concurrency?: number;
701
- batchSize?: number;
702
- leaseMs?: number;
703
- priority?: number;
808
+ interface LimitLeaseOptions {
809
+ shardId: number;
810
+ amount: number;
811
+ ttlMs: number;
812
+ limit?: number;
704
813
  nowMs?: number;
705
- partitionKey?: string;
706
- partitionKeys?: string[];
707
- reclaimExpired?: boolean;
708
- reclaimRatio?: number;
709
- claimPayload?: boolean;
710
- claimValues?: string[];
711
- valueMaxBytes?: number;
712
- blockMs?: number;
713
- idleSleepMs?: number;
714
- maxIdleSleepMs?: number;
715
- exceptionPolicy?: ExceptionPolicy;
716
- completeAsyncDepth?: number;
717
- completeIndependent?: boolean;
718
- claimDrainBatches?: number;
719
- signal?: AbortSignal;
720
- worker?: string;
721
- }
722
- interface ChildSpec {
723
- id: string;
724
- type: string;
725
- payload?: unknown;
726
- partitionKey?: string;
727
- values?: Record<string, unknown>;
728
- valueRefs?: Record<string, string>;
729
814
  }
730
- type StateMetaValue = string | number | boolean | Buffer;
731
- type StateMeta = Record<string, StateMetaValue>;
732
- interface CreateItem {
733
- id: string;
734
- payload?: unknown;
735
- partitionKey?: string;
736
- values?: Record<string, unknown>;
737
- valueRefs?: Record<string, string>;
738
- stateMeta?: StateMeta;
815
+ interface LimitAmountOptions {
816
+ shardId: number;
817
+ amount: number;
818
+ nowMs?: number;
739
819
  }
740
- /** @internal */
741
- declare const CLAIMED_ITEM_WIRE: unique symbol;
742
- /** @internal */
743
- interface ClaimedItemWire {
744
- id: Buffer;
745
- partitionKey?: Buffer | null;
746
- leaseToken: Buffer;
747
- fencingToken: number;
820
+ interface LimitReleaseOptions {
821
+ shardId: number;
822
+ reservationIds: readonly string[];
823
+ amount?: number;
748
824
  }
749
- interface ClaimedItem<TPayload = unknown> {
750
- id: string;
751
- leaseToken: Buffer;
752
- fencingToken: number;
825
+ interface GovernanceLedgerOptions {
753
826
  partitionKey?: string;
754
- type: string;
755
- state: string;
756
- runState?: string;
757
- payload?: TPayload | null;
758
- attributes?: Record<string, unknown>;
759
- /** @internal */
760
- [CLAIMED_ITEM_WIRE]?: ClaimedItemWire;
761
- }
762
- interface FencedItem {
763
- id: string;
764
- fencingToken: number;
765
- leaseToken?: Buffer;
766
- partitionKey?: string;
767
- }
768
- interface RateLimitResult {
769
- status: string;
770
- count: number;
771
- remaining: number;
772
- resetMs: number;
773
- allowed: boolean;
774
- }
775
- interface KeyInfo {
776
- type: string;
777
- valueSize: number;
778
- ttlMs: number;
779
- hotCacheStatus: string;
780
- lastWriteShard: number;
781
- raw: Record<string, unknown>;
827
+ limit?: number;
828
+ fromMs?: number;
829
+ toMs?: number;
830
+ rev?: boolean;
782
831
  }
783
- interface FetchOrComputeResult<T = unknown> {
784
- status: "hit" | "compute" | string;
785
- value?: T | null;
786
- computeToken?: Buffer;
787
- hit: boolean;
788
- shouldCompute: boolean;
832
+
833
+ interface FlowBatchCompletedItem {
834
+ readonly index: number;
835
+ readonly value: unknown;
789
836
  }
790
- interface FlowRecord<TPayload = unknown> {
791
- id: string;
792
- type: string;
793
- state: string;
794
- partitionKey: string;
795
- runState?: string;
796
- payload?: TPayload | null;
797
- leaseToken: Buffer;
798
- fencingToken: number;
799
- version: number;
800
- parentFlowId?: string;
801
- rootFlowId?: string;
802
- correlationId?: string;
803
- valueRefs?: Record<string, unknown>;
804
- values?: Record<string, unknown>;
805
- valueSizes?: Record<string, unknown>;
806
- valueOmitted?: Record<string, unknown>;
807
- valueMissing?: Record<string, unknown>;
808
- attributes?: Record<string, unknown>;
809
- stateMeta?: Record<string, unknown>;
810
- indexedStateMeta?: string;
811
- raw?: unknown;
837
+ interface ClaimHydrationItem {
838
+ readonly index: number;
839
+ readonly record: FlowRecord;
812
840
  }
813
-
841
+ /** A legacy compact claim leased jobs successfully, but one or more fallback reads failed. */
814
842
  interface AutoBatchOptions {
815
843
  enabled?: boolean;
816
844
  maxCommands?: number;
@@ -821,9 +849,13 @@ interface FerricStoreClientOptions {
821
849
  autoBatch?: boolean | AutoBatchOptions;
822
850
  codec?: Codec;
823
851
  backpressure?: BackpressurePolicy;
852
+ /** Maximum items per Flow `*_MANY` server request. Must match `flow_max_batch_items`; defaults to 1,000. */
853
+ flowManyBatchLimit?: number;
854
+ /** Maximum concurrent FLOW.GET fallbacks for legacy compact full-claim responses. Defaults to 16. */
855
+ legacyClaimHydrationConcurrency?: number;
824
856
  }
825
857
  interface FerricStoreClientFromUrlOptions extends FerricStoreClientOptions {
826
- nativeOptions?: NativeAdapterOptions;
858
+ nativeOptions?: NativeClientOptions;
827
859
  reconnect?: boolean | ReconnectOptions;
828
860
  }
829
861
  interface CreateOptions {
@@ -839,6 +871,10 @@ interface CreateOptions {
839
871
  priority?: number;
840
872
  idempotent?: boolean;
841
873
  retentionTtlMs?: number;
874
+ /** Maximum active lifetime from creation, or "infinity" to disable a type policy timeout. */
875
+ maxActiveMs?: MaxActiveMs;
876
+ /** Attribute values stored on the Flow and available to configured attribute indexes. */
877
+ attributes?: Record<string, CommandArgument>;
842
878
  values?: Record<string, unknown>;
843
879
  valueRefs?: Record<string, string>;
844
880
  stateMeta?: StateMeta;
@@ -847,6 +883,28 @@ interface CreateOptions {
847
883
  interface CreateManyOptions extends Omit<CreateOptions, "payload" | "partitionKey" | "returnRecord"> {
848
884
  partitionKey?: string;
849
885
  independent?: boolean;
886
+ /** Maximum auto-partition batches sent concurrently. Defaults to 8. */
887
+ autoPartitionConcurrency?: number;
888
+ /** Maximum items per auto-partition request, capped by the client's `flowManyBatchLimit`. */
889
+ autoPartitionBatchSize?: number;
890
+ }
891
+ interface StartAndClaimOptions {
892
+ type: string;
893
+ initialState: string;
894
+ worker: string;
895
+ leaseMs?: number;
896
+ payload?: unknown;
897
+ partitionKey?: string;
898
+ parentFlowId?: string;
899
+ rootFlowId?: string;
900
+ correlationId?: string;
901
+ nowMs?: number;
902
+ priority?: number;
903
+ retentionTtlMs?: number;
904
+ attributes?: Record<string, CommandArgument>;
905
+ stateMeta?: StateMeta;
906
+ values?: Record<string, unknown>;
907
+ valueRefs?: Record<string, string>;
850
908
  }
851
909
  interface ClaimDueOptions {
852
910
  state?: string;
@@ -864,13 +922,72 @@ interface ClaimDueOptions {
864
922
  jobOnly?: boolean;
865
923
  payload?: boolean;
866
924
  payloadMaxBytes?: number;
867
- values?: string[];
925
+ values?: readonly string[];
868
926
  valueMaxBytes?: number;
869
927
  includeState?: boolean;
928
+ /** Include Flow attributes in compact job-only claims. Defaults to false to minimize wire size. */
929
+ includeAttributes?: boolean;
930
+ }
931
+ interface CompleteManyOptions {
932
+ result?: unknown;
933
+ payload?: unknown;
934
+ values?: Record<string, unknown>;
935
+ valueRefs?: Record<string, string>;
936
+ dropValues?: string[];
937
+ overrideValues?: string[];
938
+ attributesMerge?: Record<string, CommandArgument>;
939
+ attributesDelete?: string[];
940
+ stateMeta?: StateMeta;
941
+ ttlMs?: number;
942
+ nowMs?: number;
943
+ independent?: boolean;
944
+ returnOkOnSuccess?: boolean;
945
+ }
946
+ interface CompleteJobsAndClaimJobsResult {
947
+ /** Raw FLOW.COMPLETE_MANY result, retained even when an item failed. */
948
+ readonly completion: unknown;
949
+ /** Any replacement leases returned by the claim half of the operation. */
950
+ readonly claimed: (FlowRecord | ClaimedItem)[];
951
+ /** Completion validation failure; replacement leases must still be handled. */
952
+ readonly completionError?: Error;
953
+ /** Claim command failure after the completion command was submitted. */
954
+ readonly claimError?: Error;
955
+ /** True when both commands shared one ordered transport pipeline. */
956
+ readonly fused: boolean;
870
957
  }
871
958
  interface ReclaimOptions extends Omit<ClaimDueOptions, "state" | "states" | "blockMs" | "reclaimExpired" | "reclaimRatio" | "includeState"> {
872
959
  state?: "running";
873
960
  }
961
+ type FlowStateMode = "fifo" | "parallel";
962
+ interface FlowStatePolicy {
963
+ mode?: FlowStateMode;
964
+ retry?: RetryPolicy;
965
+ }
966
+ type FlowStatePolicyLike = FlowStatePolicy | RetryPolicy;
967
+ interface FlowPolicyOptions {
968
+ state?: string;
969
+ mode?: FlowStateMode;
970
+ retry?: RetryPolicy;
971
+ states?: Record<string, FlowStatePolicyLike>;
972
+ retentionTtlMs?: number;
973
+ /** Type-level maximum active lifetime for newly created Flows. */
974
+ maxActiveMs?: MaxActiveMs;
975
+ /** Type-level attribute names projected for FLOW.SEARCH. An empty array clears the index list. */
976
+ indexedAttributes?: readonly string[];
977
+ indexedStateMeta?: string;
978
+ }
979
+ interface RequestContext {
980
+ subject?: string;
981
+ tenant?: string;
982
+ scopes?: string | readonly string[];
983
+ }
984
+ interface RequestContextOptions {
985
+ requestContext?: RequestContext;
986
+ }
987
+ interface InvocationCreateOptions extends RequestContextOptions {
988
+ context?: Record<string, unknown>;
989
+ idempotencyKey?: string;
990
+ }
874
991
  interface MutateOptions {
875
992
  partitionKey?: string;
876
993
  payload?: unknown;
@@ -878,13 +995,23 @@ interface MutateOptions {
878
995
  valueRefs?: Record<string, string>;
879
996
  dropValues?: string[];
880
997
  overrideValues?: string[];
998
+ attributesMerge?: Record<string, CommandArgument>;
999
+ attributesDelete?: string[];
881
1000
  stateMeta?: StateMeta;
882
1001
  nowMs?: number;
883
1002
  returnRecord?: boolean;
884
1003
  }
885
1004
  interface LeaseMutationOptions extends MutateOptions {
886
1005
  leaseToken: Buffer;
887
- fencingToken: number;
1006
+ fencingToken: FencingToken;
1007
+ }
1008
+ interface ExtendLeaseOptions {
1009
+ leaseToken: Buffer;
1010
+ fencingToken: FencingToken;
1011
+ leaseMs: number;
1012
+ partitionKey?: string;
1013
+ nowMs?: number;
1014
+ returnOkOnSuccess?: boolean;
888
1015
  }
889
1016
  interface TransitionOptions extends LeaseMutationOptions {
890
1017
  fromState: string;
@@ -892,6 +1019,31 @@ interface TransitionOptions extends LeaseMutationOptions {
892
1019
  runAtMs?: number;
893
1020
  priority?: number;
894
1021
  }
1022
+ interface StepContinueOptions extends Omit<LeaseMutationOptions, "returnRecord"> {
1023
+ fromState: string;
1024
+ toState: string;
1025
+ leaseMs?: number;
1026
+ worker?: string;
1027
+ returnJob?: boolean;
1028
+ /** Flow type to retain when returnJob requests a compact response. */
1029
+ type?: string;
1030
+ }
1031
+ interface RunStepsItem {
1032
+ id: string;
1033
+ partitionKey?: string;
1034
+ }
1035
+ interface RunStepsManyOptions {
1036
+ type: string;
1037
+ states?: readonly string[];
1038
+ steps?: number;
1039
+ worker: string;
1040
+ leaseMs?: number;
1041
+ nowMs?: number;
1042
+ payload?: unknown;
1043
+ result?: unknown;
1044
+ partitionKey?: string;
1045
+ retentionTtlMs?: number;
1046
+ }
895
1047
  interface CompleteOptions extends LeaseMutationOptions {
896
1048
  result?: unknown;
897
1049
  ttlMs?: number;
@@ -900,41 +1052,619 @@ interface RetryOptions extends LeaseMutationOptions {
900
1052
  error?: unknown;
901
1053
  runAtMs?: number;
902
1054
  }
903
- interface FailOptions extends LeaseMutationOptions {
904
- error?: unknown;
905
- ttlMs?: number;
1055
+ interface FailOptions extends LeaseMutationOptions {
1056
+ error?: unknown;
1057
+ ttlMs?: number;
1058
+ }
1059
+ interface CancelOptions extends Omit<MutateOptions, "payload"> {
1060
+ fencingToken: FencingToken;
1061
+ leaseToken?: Buffer;
1062
+ reason?: unknown;
1063
+ ttlMs?: number;
1064
+ }
1065
+ interface ReadOptions {
1066
+ partitionKey?: string;
1067
+ count?: number;
1068
+ fromMs?: number;
1069
+ toMs?: number;
1070
+ rev?: boolean;
1071
+ state?: string;
1072
+ terminalOnly?: boolean;
1073
+ includeCold?: boolean;
1074
+ consistentProjection?: boolean;
1075
+ }
1076
+ interface HistoryOptions {
1077
+ partitionKey?: string;
1078
+ count?: number;
1079
+ fromEvent?: string;
1080
+ toEvent?: string;
1081
+ fromMs?: number;
1082
+ toMs?: number;
1083
+ fromVersion?: number;
1084
+ toVersion?: number;
1085
+ rev?: boolean;
1086
+ event?: string;
1087
+ worker?: string;
1088
+ includeCold?: boolean;
1089
+ consistentProjection?: boolean;
1090
+ values?: boolean;
1091
+ payloadMaxBytes?: number;
1092
+ }
1093
+ type SearchStateMeta = StateMeta | Record<string, StateMeta>;
1094
+ interface SearchOptions extends ReadOptions {
1095
+ attributes?: Record<string, CommandArgument>;
1096
+ stateMeta?: SearchStateMeta;
1097
+ }
1098
+ type ManagementPairs = Record<string, CommandArgument>;
1099
+
1100
+ declare class ClaimHydrationError extends FerricStoreError {
1101
+ readonly code = "flow_claim_hydration_partial";
1102
+ readonly claimed: readonly ClaimedItem[];
1103
+ readonly failedIndex: number;
1104
+ readonly hydratedItems: readonly ClaimHydrationItem[];
1105
+ constructor(cause: unknown, claimed: readonly ClaimedItem[], hydratedItems: readonly ClaimHydrationItem[], failedIndex: number);
1106
+ }
1107
+ /** A chunked independent Flow operation failed after zero or more item results were confirmed. */
1108
+ declare class FlowBatchError extends FerricStoreError {
1109
+ readonly code = "flow_batch_partial";
1110
+ readonly completed: number;
1111
+ readonly completedItems: readonly FlowBatchCompletedItem[];
1112
+ readonly operation: string;
1113
+ constructor(operation: string, cause: unknown, completedItems: readonly FlowBatchCompletedItem[]);
1114
+ }
1115
+
1116
+ declare class FerricStoreClientBase {
1117
+ readonly executor: CommandExecutor;
1118
+ readonly codec: Codec;
1119
+ readonly backpressure: Required<BackpressurePolicy>;
1120
+ readonly flowManyBatchLimit: number;
1121
+ readonly legacyClaimHydrationConcurrency: number;
1122
+ private readonly closeAbortController;
1123
+ private closePromise?;
1124
+ constructor(executor: CommandExecutor, options?: FerricStoreClientOptions);
1125
+ command(...args: CommandArgument[]): Promise<unknown>;
1126
+ /** Execute an already-built command without a JavaScript variadic-call limit. */
1127
+ commandArgs(args: readonly CommandArgument[]): Promise<unknown>;
1128
+ pipeline(commands: readonly Command[], options?: ExecutePipelineOptions): Promise<unknown[]>;
1129
+ close(): Promise<void>;
1130
+ protected get closeSignal(): AbortSignal;
1131
+ refreshTopology(): Promise<RoutingTopology>;
1132
+ route(key: string | Buffer$1): Promise<RoutingRoute>;
1133
+ }
1134
+
1135
+ /** Cluster, FerricStore administration, telemetry, and invocation commands. */
1136
+ declare class FerricStoreAdministrationClient extends FerricStoreClientBase {
1137
+ clusterHealth(): Promise<Record<string, unknown>>;
1138
+ clusterStats(): Promise<Record<string, unknown>>;
1139
+ clusterKeyslot(key: string): Promise<number>;
1140
+ clusterSlots(): Promise<unknown>;
1141
+ clusterStatus(): Promise<Record<string, unknown>>;
1142
+ clusterRole(): Promise<unknown>;
1143
+ clusterJoin(node: string, options?: {
1144
+ replace?: boolean;
1145
+ }): Promise<boolean>;
1146
+ clusterLeave(): Promise<boolean>;
1147
+ clusterFailover(shardIndex: number, targetNode: string): Promise<boolean>;
1148
+ clusterPromote(node: string): Promise<boolean>;
1149
+ clusterDemote(node: string): Promise<boolean>;
1150
+ ferricstoreConfig(...args: CommandArgument[]): Promise<unknown>;
1151
+ ferricstoreHotness(...args: CommandArgument[]): Promise<Record<string, unknown>>;
1152
+ ferricstoreMetrics(...args: CommandArgument[]): Promise<string>;
1153
+ ferricstoreBlobgc(...args: CommandArgument[]): Promise<unknown>;
1154
+ ferricstoreDoctor(...args: CommandArgument[]): Promise<unknown>;
1155
+ capabilities(): Promise<Record<string, unknown>>;
1156
+ ensureNamespace(prefix: string, attrs?: ManagementPairs): Promise<unknown>;
1157
+ getNamespace(prefix: string): Promise<unknown>;
1158
+ listNamespaces(): Promise<unknown>;
1159
+ deleteNamespace(prefix: string): Promise<unknown>;
1160
+ setQuota(namespace: string, quotaSpec?: ManagementPairs): Promise<unknown>;
1161
+ getQuota(namespace: string): Promise<unknown>;
1162
+ quotaUsage(namespace: string): Promise<unknown>;
1163
+ clusterInfo(): Promise<Record<string, unknown>>;
1164
+ namespaceUsage(prefix: string): Promise<Record<string, unknown>>;
1165
+ flowQuery(attrs?: ManagementPairs): Promise<unknown[]>;
1166
+ flowHistory(id: string, attrs?: ManagementPairs): Promise<unknown[]>;
1167
+ invocationDefinitionPut(definition: Record<string, unknown> | string, options?: RequestContextOptions): Promise<unknown>;
1168
+ invocationDefinitionGet(name: string, options?: RequestContextOptions): Promise<unknown>;
1169
+ invocationDefinitionList(options?: RequestContextOptions): Promise<unknown[]>;
1170
+ invocationCreate(name: string, attrs: Record<string, unknown>, options?: InvocationCreateOptions): Promise<unknown>;
1171
+ invocationGet(id: string, options?: RequestContextOptions): Promise<unknown>;
1172
+ invocationPartitionList(name: string, options?: RequestContextOptions & {
1173
+ scope?: string;
1174
+ }): Promise<unknown[]>;
1175
+ }
1176
+
1177
+ declare class KeyValueStore {
1178
+ private readonly client;
1179
+ constructor(client: StoreCommandClient);
1180
+ get<T = unknown>(key: string): Promise<T | null>;
1181
+ set(key: string, value: unknown, options?: SetOptions): Promise<unknown>;
1182
+ del(keys: readonly string[]): Promise<number>;
1183
+ del(key: string, ...keys: string[]): Promise<number>;
1184
+ exists(keys: readonly string[]): Promise<number>;
1185
+ exists(key: string, ...keys: string[]): Promise<number>;
1186
+ mget<T = unknown>(keys: string[]): Promise<(T | null)[]>;
1187
+ mset(entries: Record<string, unknown> | [string, unknown][]): Promise<boolean>;
1188
+ msetnx(entries: Record<string, unknown> | [string, unknown][]): Promise<boolean>;
1189
+ incr(key: string): Promise<IntegerReply>;
1190
+ decr(key: string): Promise<IntegerReply>;
1191
+ incrby(key: string, increment: number | bigint): Promise<IntegerReply>;
1192
+ decrby(key: string, decrement: number | bigint): Promise<IntegerReply>;
1193
+ incrbyfloat(key: string, increment: number): Promise<string>;
1194
+ append(key: string, value: unknown): Promise<number>;
1195
+ strlen(key: string): Promise<number>;
1196
+ getset<T = unknown>(key: string, value: unknown): Promise<T | null>;
1197
+ getdel<T = unknown>(key: string): Promise<T | null>;
1198
+ getex<T = unknown>(key: string, options?: GetExOptions): Promise<T | null>;
1199
+ setnx(key: string, value: unknown): Promise<boolean>;
1200
+ setex(key: string, seconds: number, value: unknown): Promise<boolean>;
1201
+ psetex(key: string, milliseconds: number, value: unknown): Promise<boolean>;
1202
+ getrange(key: string, start: number, end: number): Promise<Buffer | string | unknown>;
1203
+ setrange(key: string, offset: number, value: unknown): Promise<number>;
1204
+ expire(key: string, seconds: number, condition?: ExpiryCondition): Promise<boolean>;
1205
+ pexpire(key: string, milliseconds: number, condition?: ExpiryCondition): Promise<boolean>;
1206
+ expireat(key: string, unixSeconds: number, condition?: ExpiryCondition): Promise<boolean>;
1207
+ pexpireat(key: string, unixMilliseconds: number, condition?: ExpiryCondition): Promise<boolean>;
1208
+ ttl(key: string): Promise<IntegerReply>;
1209
+ pttl(key: string): Promise<IntegerReply>;
1210
+ persist(key: string): Promise<boolean>;
1211
+ expiretime(key: string): Promise<IntegerReply>;
1212
+ pexpiretime(key: string): Promise<IntegerReply>;
1213
+ type(key: string): Promise<string>;
1214
+ unlink(keys: readonly string[]): Promise<number>;
1215
+ unlink(key: string, ...keys: string[]): Promise<number>;
1216
+ rename(key: string, newKey: string): Promise<boolean>;
1217
+ renamenx(key: string, newKey: string): Promise<boolean>;
1218
+ copy(source: string, destination: string, options?: {
1219
+ replace?: boolean;
1220
+ }): Promise<boolean>;
1221
+ randomkey(): Promise<string | null>;
1222
+ keys(pattern: string): Promise<string[]>;
1223
+ scan(cursor: string | number, options?: ScanOptions): Promise<[string, string[]]>;
1224
+ dbsize(): Promise<number>;
1225
+ flushdb(mode?: "ASYNC" | "SYNC"): Promise<boolean>;
1226
+ flushall(mode?: "ASYNC" | "SYNC"): Promise<boolean>;
1227
+ objectEncoding(key: string): Promise<string | null>;
1228
+ objectHelp(): Promise<unknown[]>;
1229
+ objectFreq(key: string): Promise<number>;
1230
+ objectIdleTime(key: string): Promise<number>;
1231
+ objectRefcount(key: string): Promise<number>;
1232
+ wait(numReplicas: number, timeoutMs: number): Promise<number>;
1233
+ waitAof(numLocal: number, numReplicas: number, timeoutMs: number): Promise<[IntegerReply, IntegerReply]>;
1234
+ memoryUsage(key: string): Promise<number | null>;
1235
+ }
1236
+
1237
+ declare class GeoStore {
1238
+ private readonly client;
1239
+ constructor(client: StoreCommandClient);
1240
+ geoadd(key: string, members: GeoMember[], options?: GeoAddOptions): Promise<number>;
1241
+ geopos(key: string, member: unknown, ...members: unknown[]): Promise<([string, string] | null)[]>;
1242
+ geoposMany(key: string, members: readonly unknown[]): Promise<([string, string] | null)[]>;
1243
+ geodist(key: string, member1: unknown, member2: unknown, unit?: "m" | "km" | "mi" | "ft"): Promise<string | null>;
1244
+ geohash(key: string, member: unknown, ...members: unknown[]): Promise<(string | null)[]>;
1245
+ geohashMany(key: string, members: readonly unknown[]): Promise<(string | null)[]>;
1246
+ geosearch(key: string, args: CommandArgument[]): Promise<unknown[]>;
1247
+ geosearchstore(destination: string, source: string, args: CommandArgument[]): Promise<number>;
1248
+ }
1249
+
1250
+ declare class ListStore {
1251
+ private readonly client;
1252
+ constructor(client: StoreCommandClient);
1253
+ lpush(key: string, element: unknown, ...elements: unknown[]): Promise<number>;
1254
+ lpushMany(key: string, elements: readonly unknown[]): Promise<number>;
1255
+ rpush(key: string, element: unknown, ...elements: unknown[]): Promise<number>;
1256
+ rpushMany(key: string, elements: readonly unknown[]): Promise<number>;
1257
+ lpop<T = unknown>(key: string, count?: number): Promise<T | (T | null)[] | null>;
1258
+ rpop<T = unknown>(key: string, count?: number): Promise<T | (T | null)[] | null>;
1259
+ lrange<T = unknown>(key: string, start: number, stop: number): Promise<(T | null)[]>;
1260
+ llen(key: string): Promise<number>;
1261
+ lindex<T = unknown>(key: string, index: number): Promise<T | null>;
1262
+ lset(key: string, index: number, element: unknown): Promise<boolean>;
1263
+ lrem(key: string, count: number, element: unknown): Promise<number>;
1264
+ ltrim(key: string, start: number, stop: number): Promise<boolean>;
1265
+ lpos(key: string, element: unknown, options?: {
1266
+ rank?: number;
1267
+ count?: number;
1268
+ maxlen?: number;
1269
+ }): Promise<number | number[] | null>;
1270
+ linsert(key: string, where: "BEFORE" | "AFTER", pivot: unknown, element: unknown): Promise<number>;
1271
+ lmove<T = unknown>(source: string, destination: string, from: "LEFT" | "RIGHT", to: "LEFT" | "RIGHT"): Promise<T | null>;
1272
+ rpoplpush<T = unknown>(source: string, destination: string): Promise<T | null>;
1273
+ lpushx(key: string, element: unknown, ...elements: unknown[]): Promise<number>;
1274
+ lpushxMany(key: string, elements: readonly unknown[]): Promise<number>;
1275
+ rpushx(key: string, element: unknown, ...elements: unknown[]): Promise<number>;
1276
+ rpushxMany(key: string, elements: readonly unknown[]): Promise<number>;
1277
+ blpop(keys: string[], timeoutSeconds: number): Promise<unknown>;
1278
+ brpop(keys: string[], timeoutSeconds: number): Promise<unknown>;
1279
+ blmove<T = unknown>(source: string, destination: string, from: "LEFT" | "RIGHT", to: "LEFT" | "RIGHT", timeoutSeconds: number): Promise<T | null>;
1280
+ blmpop(timeoutSeconds: number, keys: string[], from: "LEFT" | "RIGHT", options?: {
1281
+ count?: number;
1282
+ }): Promise<unknown>;
1283
+ }
1284
+
1285
+ declare class SortedSetStore {
1286
+ private readonly client;
1287
+ constructor(client: StoreCommandClient);
1288
+ zadd(key: string, members: ZAddMember[], options?: ZAddOptions): Promise<number>;
1289
+ zscore(key: string, member: unknown): Promise<string | null>;
1290
+ zrank(key: string, member: unknown): Promise<number | null>;
1291
+ zrevrank(key: string, member: unknown): Promise<number | null>;
1292
+ zrange(key: string, start: number, stop: number, options?: {
1293
+ withScores?: boolean;
1294
+ }): Promise<unknown[]>;
1295
+ zrevrange(key: string, start: number, stop: number, options?: {
1296
+ withScores?: boolean;
1297
+ }): Promise<unknown[]>;
1298
+ zcard(key: string): Promise<number>;
1299
+ zrem(key: string, member: unknown, ...members: unknown[]): Promise<number>;
1300
+ zremMany(key: string, members: readonly unknown[]): Promise<number>;
1301
+ zincrby(key: string, increment: number, member: unknown): Promise<string>;
1302
+ zcount(key: string, min: string | number, max: string | number): Promise<number>;
1303
+ zpopmin(key: string, count?: number): Promise<unknown[]>;
1304
+ zpopmax(key: string, count?: number): Promise<unknown[]>;
1305
+ zrandmember<T = unknown>(key: string): Promise<T | null>;
1306
+ zrandmember<T = unknown>(key: string, count: number, withScores?: false): Promise<(T | null)[]>;
1307
+ zrandmember(key: string, count: number, withScores: boolean): Promise<unknown[]>;
1308
+ zmscore(key: string, members: unknown[]): Promise<(string | null)[]>;
1309
+ zrangebyscore(key: string, min: string | number, max: string | number, options?: {
1310
+ withScores?: boolean;
1311
+ limit?: RangeLimit;
1312
+ }): Promise<unknown[]>;
1313
+ zrevrangebyscore(key: string, max: string | number, min: string | number, options?: {
1314
+ withScores?: boolean;
1315
+ limit?: RangeLimit;
1316
+ }): Promise<unknown[]>;
1317
+ zscan<T = unknown>(key: string, cursor: string | number, options?: CollectionScanOptions): Promise<SortedSetScanResult<T>>;
1318
+ }
1319
+ declare class StreamStore {
1320
+ private readonly client;
1321
+ constructor(client: StoreCommandClient);
1322
+ xadd(key: string, id: string, fields: Record<string, unknown> | [string, unknown][]): Promise<unknown>;
1323
+ xlen(key: string): Promise<number>;
1324
+ xrange(key: string, start?: string, end?: string, count?: number): Promise<unknown[]>;
1325
+ xrevrange(key: string, end?: string, start?: string, count?: number): Promise<unknown[]>;
1326
+ xread(streams: XReadStream[], options?: {
1327
+ count?: number;
1328
+ blockMs?: number;
1329
+ }): Promise<unknown>;
1330
+ xtrim(key: string, strategy: "MAXLEN" | "MINID", threshold: string | number, approximate?: boolean): Promise<number>;
1331
+ xdel(key: string, ids: readonly string[]): Promise<number>;
1332
+ xdel(key: string, id: string, ...ids: string[]): Promise<number>;
1333
+ xinfoStream(key: string): Promise<unknown>;
1334
+ xgroupCreate(key: string, group: string, id: string, mkstream?: boolean): Promise<boolean>;
1335
+ xreadgroup(group: string, consumer: string, streams: XReadStream[], options?: {
1336
+ count?: number;
1337
+ blockMs?: number;
1338
+ noack?: boolean;
1339
+ }): Promise<unknown>;
1340
+ xack(key: string, group: string, ids: readonly string[]): Promise<number>;
1341
+ xack(key: string, group: string, id: string, ...ids: string[]): Promise<number>;
1342
+ }
1343
+ declare class BitmapStore {
1344
+ private readonly client;
1345
+ constructor(client: StoreCommandClient);
1346
+ setbit(key: string, offset: number, value: 0 | 1): Promise<number>;
1347
+ getbit(key: string, offset: number): Promise<number>;
1348
+ bitcount(key: string): Promise<number>;
1349
+ bitcount(key: string, start: number, end: number, unit?: "BYTE" | "BIT"): Promise<number>;
1350
+ bitpos(key: string, bit: 0 | 1): Promise<number>;
1351
+ bitpos(key: string, bit: 0 | 1, start: number): Promise<number>;
1352
+ bitpos(key: string, bit: 0 | 1, start: number, end: number, unit?: "BYTE" | "BIT"): Promise<number>;
1353
+ bitop(operation: "AND" | "OR" | "XOR" | "NOT", destination: string, keys: readonly string[]): Promise<number>;
1354
+ bitop(operation: "AND" | "OR" | "XOR" | "NOT", destination: string, ...keys: string[]): Promise<number>;
1355
+ }
1356
+ declare class HyperLogLogStore {
1357
+ private readonly client;
1358
+ constructor(client: StoreCommandClient);
1359
+ pfadd(key: string, ...elements: unknown[]): Promise<number>;
1360
+ pfaddMany(key: string, elements: readonly unknown[]): Promise<number>;
1361
+ pfcount(keys: readonly string[]): Promise<IntegerReply>;
1362
+ pfcount(key: string, ...keys: string[]): Promise<IntegerReply>;
1363
+ pfmerge(destination: string, sources: readonly string[]): Promise<boolean>;
1364
+ pfmerge(destination: string, source: string, ...sources: string[]): Promise<boolean>;
1365
+ }
1366
+
1367
+ declare class SetStore {
1368
+ private readonly client;
1369
+ constructor(client: StoreCommandClient);
1370
+ sadd(key: string, member: unknown, ...members: unknown[]): Promise<number>;
1371
+ saddMany(key: string, members: readonly unknown[]): Promise<number>;
1372
+ srem(key: string, member: unknown, ...members: unknown[]): Promise<number>;
1373
+ sremMany(key: string, members: readonly unknown[]): Promise<number>;
1374
+ smembers<T = unknown>(key: string): Promise<(T | null)[]>;
1375
+ sismember(key: string, member: unknown): Promise<boolean>;
1376
+ smismember(key: string, members: unknown[]): Promise<number[]>;
1377
+ scard(key: string): Promise<number>;
1378
+ srandmember<T = unknown>(key: string, count?: number): Promise<T | (T | null)[] | null>;
1379
+ spop<T = unknown>(key: string, count?: number): Promise<T | (T | null)[] | null>;
1380
+ sdiff<T = unknown>(keys: string[]): Promise<(T | null)[]>;
1381
+ sinter<T = unknown>(keys: string[]): Promise<(T | null)[]>;
1382
+ sunion<T = unknown>(keys: string[]): Promise<(T | null)[]>;
1383
+ sdiffstore(destination: string, keys: string[]): Promise<number>;
1384
+ sinterstore(destination: string, keys: string[]): Promise<number>;
1385
+ sunionstore(destination: string, keys: string[]): Promise<number>;
1386
+ sintercard(keys: string[], limit?: number): Promise<number>;
1387
+ smove(source: string, destination: string, member: unknown): Promise<boolean>;
1388
+ sscan<T = unknown>(key: string, cursor: string | number, options?: CollectionScanOptions): Promise<SetScanResult<T>>;
1389
+ }
1390
+
1391
+ interface StoreCommandClient {
1392
+ readonly codec: Codec;
1393
+ command(...args: CommandArgument[]): Promise<unknown>;
1394
+ commandArgs?(args: readonly CommandArgument[]): Promise<unknown>;
1395
+ }
1396
+ /** An exact integer reply: safe values are numbers and larger int64 values are bigints. */
1397
+ type IntegerReply = number | bigint;
1398
+ /** Flat field/value pairs returned with a scan cursor. */
1399
+ type HashScanResult<T = unknown> = [cursor: string, entries: (string | T | null)[]];
1400
+ /** Decoded set members returned with a scan cursor. */
1401
+ type SetScanResult<T = unknown> = [cursor: string, members: (T | null)[]];
1402
+ /** Flat member/score pairs returned with a scan cursor. */
1403
+ type SortedSetScanResult<T = unknown> = [cursor: string, entries: (T | null | string)[]];
1404
+ /** SET accepts one condition and at most one expiry mode. */
1405
+ type SetOptions = {
1406
+ get?: boolean;
1407
+ } & ({
1408
+ nx?: boolean;
1409
+ xx?: false;
1410
+ } | {
1411
+ nx?: false;
1412
+ xx?: boolean;
1413
+ }) & ({
1414
+ ex?: never;
1415
+ px?: never;
1416
+ exat?: never;
1417
+ pxat?: never;
1418
+ keepTtl?: boolean;
1419
+ } | {
1420
+ ex?: number;
1421
+ px?: never;
1422
+ exat?: never;
1423
+ pxat?: never;
1424
+ keepTtl?: false;
1425
+ } | {
1426
+ ex?: never;
1427
+ px?: number;
1428
+ exat?: never;
1429
+ pxat?: never;
1430
+ keepTtl?: false;
1431
+ } | {
1432
+ ex?: never;
1433
+ px?: never;
1434
+ exat?: number;
1435
+ pxat?: never;
1436
+ keepTtl?: false;
1437
+ } | {
1438
+ ex?: never;
1439
+ px?: never;
1440
+ exat?: never;
1441
+ pxat?: number;
1442
+ keepTtl?: false;
1443
+ });
1444
+ /** GETEX/HGETEX accept at most one expiry mutation. */
1445
+ type GetExOptions = {
1446
+ ex?: never;
1447
+ px?: never;
1448
+ exat?: never;
1449
+ pxat?: never;
1450
+ persist?: false;
1451
+ } | {
1452
+ ex: number;
1453
+ px?: never;
1454
+ exat?: never;
1455
+ pxat?: never;
1456
+ persist?: false;
1457
+ } | {
1458
+ ex?: never;
1459
+ px: number;
1460
+ exat?: never;
1461
+ pxat?: never;
1462
+ persist?: false;
1463
+ } | {
1464
+ ex?: never;
1465
+ px?: never;
1466
+ exat: number;
1467
+ pxat?: never;
1468
+ persist?: false;
1469
+ } | {
1470
+ ex?: never;
1471
+ px?: never;
1472
+ exat?: never;
1473
+ pxat: number;
1474
+ persist?: false;
1475
+ } | {
1476
+ ex?: never;
1477
+ px?: never;
1478
+ exat?: never;
1479
+ pxat?: never;
1480
+ persist: true;
1481
+ };
1482
+ interface ScanOptions {
1483
+ match?: string;
1484
+ count?: number;
1485
+ /** Filter keys by the server-reported data type. */
1486
+ type?: string;
1487
+ }
1488
+ /** MATCH/COUNT options supported by collection-specific scan commands. */
1489
+ type CollectionScanOptions = Omit<ScanOptions, "type">;
1490
+ type ExpiryCondition = "NX" | "XX" | "GT" | "LT";
1491
+ interface ZAddMember {
1492
+ score: number;
1493
+ member: unknown;
1494
+ }
1495
+ /** ZADD condition and comparison flags must form a valid server grammar. */
1496
+ type ZAddOptions = {
1497
+ ch?: boolean;
1498
+ } & ({
1499
+ nx?: boolean;
1500
+ xx?: false;
1501
+ gt?: false;
1502
+ lt?: false;
1503
+ } | ({
1504
+ nx?: false;
1505
+ xx?: boolean;
1506
+ } & ({
1507
+ gt?: boolean;
1508
+ lt?: false;
1509
+ } | {
1510
+ gt?: false;
1511
+ lt?: boolean;
1512
+ })));
1513
+ interface RangeLimit {
1514
+ offset: number;
1515
+ count: number;
1516
+ }
1517
+ interface XReadStream {
1518
+ key: string;
1519
+ id: string;
1520
+ }
1521
+ interface GeoMember {
1522
+ longitude: number;
1523
+ latitude: number;
1524
+ member: unknown;
1525
+ }
1526
+ /** GEOADD NX and XX are mutually exclusive. */
1527
+ type GeoAddOptions = {
1528
+ ch?: boolean;
1529
+ } & ({
1530
+ nx?: boolean;
1531
+ xx?: false;
1532
+ } | {
1533
+ nx?: false;
1534
+ xx?: boolean;
1535
+ });
1536
+ declare class HashStore {
1537
+ private readonly client;
1538
+ constructor(client: StoreCommandClient);
1539
+ hset(key: string, entries: Record<string, unknown> | [string, unknown][]): Promise<number>;
1540
+ hget<T = unknown>(key: string, field: string): Promise<T | null>;
1541
+ hdel(key: string, fields: readonly string[]): Promise<number>;
1542
+ hdel(key: string, field: string, ...fields: string[]): Promise<number>;
1543
+ hmget<T = unknown>(key: string, fields: string[]): Promise<(T | null)[]>;
1544
+ hgetall<T = unknown>(key: string): Promise<Record<string, T | null>>;
1545
+ hexists(key: string, field: string): Promise<boolean>;
1546
+ hkeys(key: string): Promise<string[]>;
1547
+ hvals<T = unknown>(key: string): Promise<(T | null)[]>;
1548
+ hlen(key: string): Promise<number>;
1549
+ hincrby(key: string, field: string, increment: number | bigint): Promise<IntegerReply>;
1550
+ hincrbyfloat(key: string, field: string, increment: number): Promise<string>;
1551
+ hsetnx(key: string, field: string, value: unknown): Promise<boolean>;
1552
+ hstrlen(key: string, field: string): Promise<number>;
1553
+ hrandfield(key: string): Promise<string | null>;
1554
+ hrandfield(key: string, count: number, withValues?: false): Promise<string[]>;
1555
+ hrandfield<T = unknown>(key: string, count: number, withValues: true): Promise<(string | T | null)[]>;
1556
+ hrandfield<T = unknown>(key: string, count: number, withValues: boolean): Promise<string[] | (string | T | null)[]>;
1557
+ hscan<T = unknown>(key: string, cursor: string | number, options?: CollectionScanOptions): Promise<HashScanResult<T>>;
1558
+ hexpire(key: string, seconds: number, fields: string[]): Promise<number[]>;
1559
+ httl(key: string, fields: string[]): Promise<IntegerReply[]>;
1560
+ hpersist(key: string, fields: string[]): Promise<number[]>;
1561
+ hpexpire(key: string, milliseconds: number, fields: string[]): Promise<number[]>;
1562
+ hpttl(key: string, fields: string[]): Promise<IntegerReply[]>;
1563
+ hexpiretime(key: string, fields: string[]): Promise<IntegerReply[]>;
1564
+ hgetdel<T = unknown>(key: string, fields: string[]): Promise<(T | null)[]>;
1565
+ hgetex<T = unknown>(key: string, fields: string[], options?: GetExOptions): Promise<(T | null)[]>;
1566
+ hsetex(key: string, seconds: number, entries: Record<string, unknown> | [string, unknown][]): Promise<number>;
1567
+ }
1568
+
1569
+ type TopKReserveOptions = {
1570
+ width?: never;
1571
+ depth?: never;
1572
+ decay?: never;
1573
+ } | {
1574
+ width: number;
1575
+ depth: number;
1576
+ decay: number;
1577
+ };
1578
+ interface CountMinMergeOptions {
1579
+ weights?: readonly (number | bigint)[];
1580
+ }
1581
+ interface TDigestCreateOptions {
1582
+ compression?: number;
1583
+ }
1584
+ interface TDigestMergeOptions extends TDigestCreateOptions {
1585
+ override?: boolean;
1586
+ }
1587
+ declare class BloomFilterStore {
1588
+ private readonly client;
1589
+ constructor(client: StoreCommandClient);
1590
+ reserve(key: string, errorRate: number, capacity: number): Promise<boolean>;
1591
+ add(key: string, element: unknown): Promise<boolean>;
1592
+ madd(key: string, element: unknown, ...elements: unknown[]): Promise<number[]>;
1593
+ maddMany(key: string, elements: readonly unknown[]): Promise<number[]>;
1594
+ exists(key: string, element: unknown): Promise<boolean>;
1595
+ mexists(key: string, element: unknown, ...elements: unknown[]): Promise<number[]>;
1596
+ mexistsMany(key: string, elements: readonly unknown[]): Promise<number[]>;
1597
+ card(key: string): Promise<IntegerReply>;
1598
+ info(key: string): Promise<unknown[]>;
1599
+ }
1600
+ declare class CuckooFilterStore {
1601
+ private readonly client;
1602
+ constructor(client: StoreCommandClient);
1603
+ reserve(key: string, capacity: number): Promise<boolean>;
1604
+ add(key: string, element: unknown): Promise<boolean>;
1605
+ addnx(key: string, element: unknown): Promise<boolean>;
1606
+ del(key: string, element: unknown): Promise<boolean>;
1607
+ exists(key: string, element: unknown): Promise<boolean>;
1608
+ mexists(key: string, element: unknown, ...elements: unknown[]): Promise<number[]>;
1609
+ mexistsMany(key: string, elements: readonly unknown[]): Promise<number[]>;
1610
+ count(key: string, element: unknown): Promise<IntegerReply>;
1611
+ info(key: string): Promise<unknown[]>;
906
1612
  }
907
- interface CancelOptions {
908
- fencingToken: number;
909
- leaseToken?: Buffer;
910
- partitionKey?: string;
911
- reason?: unknown;
912
- ttlMs?: number;
913
- nowMs?: number;
914
- stateMeta?: StateMeta;
915
- returnRecord?: boolean;
1613
+ declare class CountMinSketchStore {
1614
+ private readonly client;
1615
+ constructor(client: StoreCommandClient);
1616
+ initByDim(key: string, width: number, depth: number): Promise<boolean>;
1617
+ initByProb(key: string, error: number, probability: number): Promise<boolean>;
1618
+ incrBy(key: string, entries: [unknown, number | bigint][]): Promise<IntegerReply[]>;
1619
+ query(key: string, item: unknown, ...items: unknown[]): Promise<IntegerReply[]>;
1620
+ queryMany(key: string, items: readonly unknown[]): Promise<IntegerReply[]>;
1621
+ merge(destination: string, sources: readonly string[], options?: CountMinMergeOptions): Promise<boolean>;
1622
+ info(key: string): Promise<unknown[]>;
916
1623
  }
917
- interface ReadOptions {
918
- partitionKey?: string;
919
- count?: number;
920
- fromMs?: number;
921
- toMs?: number;
922
- rev?: boolean;
923
- state?: string;
924
- terminalOnly?: boolean;
925
- includeCold?: boolean;
926
- consistentProjection?: boolean;
1624
+ declare class TopKStore {
1625
+ private readonly client;
1626
+ constructor(client: StoreCommandClient);
1627
+ reserve(key: string, k: number, options?: TopKReserveOptions): Promise<boolean>;
1628
+ add<T = unknown>(key: string, element: unknown, ...elements: unknown[]): Promise<(T | null)[]>;
1629
+ addMany<T = unknown>(key: string, elements: readonly unknown[]): Promise<(T | null)[]>;
1630
+ incrBy<T = unknown>(key: string, entries: [unknown, number | bigint][]): Promise<(T | null)[]>;
1631
+ query(key: string, element: unknown, ...elements: unknown[]): Promise<number[]>;
1632
+ queryMany(key: string, elements: readonly unknown[]): Promise<number[]>;
1633
+ count(key: string, element: unknown, ...elements: unknown[]): Promise<IntegerReply[]>;
1634
+ countMany(key: string, elements: readonly unknown[]): Promise<IntegerReply[]>;
1635
+ list<T = unknown>(key: string, options?: {
1636
+ withCount?: boolean;
1637
+ }): Promise<(T | IntegerReply | null)[]>;
1638
+ info(key: string): Promise<unknown[]>;
927
1639
  }
928
- type SearchStateMeta = StateMeta | Record<string, StateMeta>;
929
- interface SearchOptions extends ReadOptions {
930
- attributes?: Record<string, CommandArgument>;
931
- stateMeta?: SearchStateMeta;
1640
+ declare class TDigestStore {
1641
+ private readonly client;
1642
+ constructor(client: StoreCommandClient);
1643
+ create(key: string, options?: TDigestCreateOptions): Promise<boolean>;
1644
+ add(key: string, values: readonly number[]): Promise<boolean>;
1645
+ add(key: string, value: number, ...values: number[]): Promise<boolean>;
1646
+ reset(key: string): Promise<boolean>;
1647
+ quantile(key: string, quantiles: readonly number[]): Promise<string[]>;
1648
+ quantile(key: string, quantile: number, ...quantiles: number[]): Promise<string[]>;
1649
+ cdf(key: string, values: readonly number[]): Promise<string[]>;
1650
+ cdf(key: string, value: number, ...values: number[]): Promise<string[]>;
1651
+ rank(key: string, values: readonly number[]): Promise<IntegerReply[]>;
1652
+ rank(key: string, value: number, ...values: number[]): Promise<IntegerReply[]>;
1653
+ revrank(key: string, values: readonly number[]): Promise<IntegerReply[]>;
1654
+ revrank(key: string, value: number, ...values: number[]): Promise<IntegerReply[]>;
1655
+ byrank(key: string, ranks: readonly number[]): Promise<string[]>;
1656
+ byrank(key: string, rank: number, ...ranks: number[]): Promise<string[]>;
1657
+ byrevrank(key: string, ranks: readonly number[]): Promise<string[]>;
1658
+ byrevrank(key: string, rank: number, ...ranks: number[]): Promise<string[]>;
1659
+ trimmedMean(key: string, low: number, high: number): Promise<string>;
1660
+ min(key: string): Promise<string>;
1661
+ max(key: string): Promise<string>;
1662
+ info(key: string): Promise<unknown[]>;
1663
+ merge(destination: string, sources: string[], options?: TDigestMergeOptions): Promise<boolean>;
932
1664
  }
933
- type ManagementPairs = Record<string, CommandArgument>;
934
- declare class FerricStoreClient {
935
- readonly executor: CommandExecutor;
936
- readonly codec: Codec;
937
- readonly backpressure: Required<BackpressurePolicy>;
1665
+
1666
+ declare class FerricStoreClientCore extends FerricStoreAdministrationClient {
1667
+ protected extendLeaseOkResponseSupport?: boolean | "probing";
938
1668
  readonly bitmap: BitmapStore;
939
1669
  readonly bloom: BloomFilterStore;
940
1670
  readonly cms: CountMinSketchStore;
@@ -942,7 +1672,6 @@ declare class FerricStoreClient {
942
1672
  readonly geo: GeoStore;
943
1673
  readonly hash: HashStore;
944
1674
  readonly hyperloglog: HyperLogLogStore;
945
- readonly json: JsonStore;
946
1675
  readonly kv: KeyValueStore;
947
1676
  readonly lists: ListStore;
948
1677
  readonly sets: SetStore;
@@ -951,13 +1680,6 @@ declare class FerricStoreClient {
951
1680
  readonly topk: TopKStore;
952
1681
  readonly zset: SortedSetStore;
953
1682
  constructor(executor: CommandExecutor, options?: FerricStoreClientOptions);
954
- static fromUrl(url: string, options?: FerricStoreClientFromUrlOptions): Promise<FerricStoreClient>;
955
- static fromUrls(urls: readonly string[], options?: FerricStoreClientFromUrlOptions): Promise<FerricStoreClient>;
956
- command(...args: CommandArgument[]): Promise<unknown>;
957
- pipeline(commands: readonly Command[]): Promise<unknown[]>;
958
- close(): Promise<void>;
959
- refreshTopology(): Promise<RoutingTopology>;
960
- route(key: string | Buffer): Promise<RoutingRoute>;
961
1683
  ping(message?: CommandArgument): Promise<unknown>;
962
1684
  echo(message: CommandArgument): Promise<unknown>;
963
1685
  serverInfo(section?: string): Promise<string>;
@@ -984,7 +1706,7 @@ declare class FerricStoreClient {
984
1706
  clientList(options?: {
985
1707
  type?: string;
986
1708
  }): Promise<string>;
987
- clientTracking(mode: "ON" | "OFF", options?: {
1709
+ clientTracking(_mode: "ON" | "OFF", _options?: {
988
1710
  redirect?: number;
989
1711
  prefixes?: string[];
990
1712
  bcast?: boolean;
@@ -992,7 +1714,7 @@ declare class FerricStoreClient {
992
1714
  optout?: boolean;
993
1715
  noloop?: boolean;
994
1716
  }): Promise<boolean>;
995
- clientCaching(mode: "YES" | "NO"): Promise<boolean>;
1717
+ clientCaching(_mode: "YES" | "NO"): Promise<boolean>;
996
1718
  clientTrackingInfo(): Promise<unknown>;
997
1719
  clientGetRedir(): Promise<number>;
998
1720
  save(): Promise<boolean>;
@@ -1031,111 +1753,156 @@ declare class FerricStoreClient {
1031
1753
  }): Promise<FetchOrComputeResult<T>>;
1032
1754
  fetchOrComputeResult(key: string, value: unknown, options: {
1033
1755
  ttlMs: number;
1756
+ computeToken: Buffer$1 | null;
1034
1757
  }): Promise<boolean>;
1035
- fetchOrComputeError(key: string, message: string): Promise<boolean>;
1036
- clusterHealth(): Promise<Record<string, unknown>>;
1037
- clusterStats(): Promise<Record<string, unknown>>;
1038
- clusterKeyslot(key: string): Promise<number>;
1039
- clusterSlots(): Promise<unknown>;
1040
- clusterStatus(): Promise<Record<string, unknown>>;
1041
- clusterRole(): Promise<unknown>;
1042
- clusterJoin(node: string, options?: {
1043
- replace?: boolean;
1758
+ fetchOrComputeError(key: string, message: string, options: {
1759
+ computeToken: Buffer$1 | null;
1044
1760
  }): Promise<boolean>;
1045
- clusterLeave(): Promise<boolean>;
1046
- clusterFailover(shardIndex: number, targetNode: string): Promise<boolean>;
1047
- clusterPromote(node: string): Promise<boolean>;
1048
- clusterDemote(node: string): Promise<boolean>;
1049
- ferricstoreConfig(...args: CommandArgument[]): Promise<unknown>;
1050
- ferricstoreHotness(...args: CommandArgument[]): Promise<Record<string, unknown>>;
1051
- ferricstoreMetrics(...args: CommandArgument[]): Promise<Record<string, unknown>>;
1052
- ferricstoreBlobgc(...args: CommandArgument[]): Promise<unknown>;
1053
- ferricstoreDoctor(...args: CommandArgument[]): Promise<unknown>;
1054
- capabilities(): Promise<Record<string, unknown>>;
1055
- ensureNamespace(prefix: string, attrs?: ManagementPairs): Promise<unknown>;
1056
- getNamespace(prefix: string): Promise<unknown>;
1057
- listNamespaces(): Promise<unknown>;
1058
- deleteNamespace(prefix: string): Promise<unknown>;
1059
- setQuota(namespace: string, quotaSpec?: ManagementPairs): Promise<unknown>;
1060
- getQuota(namespace: string): Promise<unknown>;
1061
- quotaUsage(namespace: string): Promise<unknown>;
1062
- clusterInfo(): Promise<Record<string, unknown>>;
1063
- namespaceUsage(prefix: string): Promise<Record<string, unknown>>;
1064
- flowQuery(attrs?: ManagementPairs): Promise<unknown[]>;
1065
- flowHistory(id: string, attrs?: ManagementPairs): Promise<unknown[]>;
1066
- create(id: string, options: CreateOptions): Promise<FlowRecord | Buffer | unknown>;
1067
- enqueue(id: string, options: Omit<CreateOptions, "state"> & {
1068
- state?: string;
1069
- }): Promise<FlowRecord | Buffer | unknown>;
1070
- enqueueMany(items: CreateItem[], options: CreateManyOptions): Promise<unknown[] | unknown>;
1071
- createMany(partitionKey: string | undefined, items: CreateItem[], options: CreateManyOptions): Promise<unknown[] | unknown>;
1072
- valuePut(value: unknown, options?: {
1761
+ }
1762
+
1763
+ /** @internal Administrative and governance commands kept off the primary Flow client surface. */
1764
+ declare class FerricStoreManagementClient extends FerricStoreClientCore {
1765
+ stats(type: string, options?: FlowStatsOptions): Promise<FlowAdminRecord>;
1766
+ countByState(type: string, state: string, options?: Omit<FlowStatsOptions, "state" | "count">): Promise<number>;
1767
+ attributes(type: string, options?: AttributeQueryOptions): Promise<FlowAdminRecord[]>;
1768
+ attributeValues(type: string, attribute: string, options?: AttributeQueryOptions): Promise<FlowAdminRecord[]>;
1769
+ scheduleCreate(id: string, options: ScheduleOptions): Promise<FlowAdminRecord>;
1770
+ scheduleGet(id: string, options?: {
1771
+ nowMs?: number;
1772
+ }): Promise<FlowAdminRecord | null>;
1773
+ scheduleFire(id: string, options?: {
1774
+ nowMs?: number;
1775
+ }): Promise<FlowAdminRecord>;
1776
+ schedulePause(id: string, options?: {
1777
+ nowMs?: number;
1778
+ }): Promise<FlowAdminRecord>;
1779
+ scheduleResume(id: string, options?: {
1780
+ nowMs?: number;
1781
+ }): Promise<FlowAdminRecord>;
1782
+ scheduleDelete(id: string, options?: {
1783
+ nowMs?: number;
1784
+ }): Promise<FlowAdminRecord>;
1785
+ scheduleFireDue(options?: ScheduleFireDueOptions): Promise<FlowAdminRecord>;
1786
+ scheduleList(options?: ScheduleListOptions): Promise<FlowAdminRecord[]>;
1787
+ private scheduleStatus;
1788
+ effectReserve(id: string, effectKey: string, effectType: string, options: EffectReserveOptions): Promise<FlowAdminRecord>;
1789
+ effectConfirm(id: string, effectKey: string, options?: EffectConfirmOptions): Promise<FlowAdminRecord>;
1790
+ effectFail(id: string, effectKey: string, options?: EffectFailOptions): Promise<FlowAdminRecord>;
1791
+ effectCompensate(id: string, effectKey: string, options?: EffectCompensateOptions): Promise<FlowAdminRecord>;
1792
+ effectGet(id: string, effectKey: string, options?: {
1073
1793
  partitionKey?: string;
1074
- ownerFlowId?: string;
1075
- name?: string;
1076
- override?: boolean;
1077
- ttlMs?: number;
1794
+ }): Promise<FlowAdminRecord | null>;
1795
+ private effectStatus;
1796
+ approvalRequest(id: string, options: ApprovalRequestOptions): Promise<FlowAdminRecord>;
1797
+ approvalApprove(id: string, options: {
1798
+ approver: string;
1799
+ reason?: string;
1078
1800
  nowMs?: number;
1079
- }): Promise<unknown>;
1080
- valueMGet(refs: string[], options?: {
1081
- maxBytes?: number;
1082
- }): Promise<unknown[]>;
1083
- signal(id: string, options: {
1084
- signal: string;
1801
+ }): Promise<FlowAdminRecord>;
1802
+ approvalReject(id: string, options: {
1803
+ approver: string;
1804
+ reason?: string;
1805
+ nowMs?: number;
1806
+ }): Promise<FlowAdminRecord>;
1807
+ private approvalStatus;
1808
+ approvalGet(id: string): Promise<FlowAdminRecord | null>;
1809
+ approvalList(options?: ApprovalListOptions): Promise<FlowAdminRecord[]>;
1810
+ governanceOverview(options?: ApprovalListOptions): Promise<FlowAdminRecord>;
1811
+ circuitOpen(scope: string, options?: CircuitOpenOptions): Promise<FlowAdminRecord>;
1812
+ circuitClose(scope: string, options?: {
1813
+ nowMs?: number;
1814
+ }): Promise<FlowAdminRecord>;
1815
+ circuitGet(scope: string): Promise<FlowAdminRecord | null>;
1816
+ budgetReserve(scope: string, amount: number, options?: BudgetReserveOptions): Promise<FlowAdminRecord>;
1817
+ budgetCommit(scope: string, reservationId: string, actualAmount: number, options?: BudgetCommitOptions): Promise<FlowAdminRecord>;
1818
+ budgetRelease(scope: string, reservationId: string, options?: {
1819
+ nowMs?: number;
1820
+ }): Promise<FlowAdminRecord>;
1821
+ budgetGet(scope: string): Promise<FlowAdminRecord | null>;
1822
+ budgetList(options?: AdminListOptions): Promise<FlowAdminRecord[]>;
1823
+ limitLease(scope: string, options: LimitLeaseOptions): Promise<FlowAdminRecord>;
1824
+ limitSpend(scope: string, options: LimitAmountOptions): Promise<FlowAdminRecord>;
1825
+ limitRelease(scope: string, options: LimitReleaseOptions): Promise<FlowAdminRecord>;
1826
+ limitGet(scope: string, options?: {
1827
+ nowMs?: number;
1828
+ }): Promise<FlowAdminRecord | null>;
1829
+ limitList(options?: LimitListOptions): Promise<FlowAdminRecord[]>;
1830
+ governanceLedger(id: string, options?: GovernanceLedgerOptions): Promise<FlowAdminRecord[]>;
1831
+ }
1832
+
1833
+ /** @internal Read, policy, and shared Flow helpers kept off the primary implementation module. */
1834
+ declare class FerricStoreFlowSupportClient extends FerricStoreManagementClient {
1835
+ rewind(id: string, options?: {
1085
1836
  partitionKey?: string;
1086
- idempotencyKey?: string;
1087
- ifState?: string | string[];
1088
- transitionTo?: string;
1089
- runAtMs?: number;
1837
+ toEvent?: string;
1838
+ expectState?: string;
1090
1839
  nowMs?: number;
1091
- priority?: number;
1840
+ returnRecord?: boolean;
1841
+ }): Promise<FlowRecord | Buffer$1 | unknown>;
1842
+ get<TPayload = unknown>(id: string, options?: {
1843
+ partitionKey?: string;
1844
+ full?: boolean;
1845
+ payload?: boolean;
1846
+ payloadMaxBytes?: number;
1847
+ values?: readonly string[];
1848
+ valueMaxBytes?: number;
1849
+ }): Promise<FlowRecord<TPayload> | undefined>;
1850
+ list(type: string, options?: ReadOptions): Promise<FlowRecord[]>;
1851
+ search(type: string, options?: SearchOptions): Promise<FlowRecord[]>;
1852
+ terminals(type: string, options?: ReadOptions): Promise<FlowRecord[]>;
1853
+ failures(type: string, options?: ReadOptions): Promise<FlowRecord[]>;
1854
+ byParent(parentFlowId: string, options?: ReadOptions): Promise<FlowRecord[]>;
1855
+ byRoot(rootFlowId: string, options?: ReadOptions): Promise<FlowRecord[]>;
1856
+ byCorrelation(correlationId: string, options?: ReadOptions): Promise<FlowRecord[]>;
1857
+ info(type: string): Promise<Record<string, unknown>>;
1858
+ stuck(type: string, options?: {
1859
+ partitionKey?: string;
1860
+ count?: number;
1861
+ olderThanMs?: number;
1862
+ nowMs?: number;
1863
+ }): Promise<FlowRecord[]>;
1864
+ history(id: string, options?: HistoryOptions): Promise<unknown[]>;
1865
+ spawnChildren(parentId: string, children: ChildSpec[], options?: {
1866
+ groupId?: string;
1867
+ partitionKey?: string;
1868
+ leaseToken?: Buffer$1;
1869
+ fencingToken?: FencingToken;
1870
+ wait?: string;
1871
+ waitState?: string;
1872
+ success?: string;
1873
+ failure?: string;
1874
+ fromState?: string;
1875
+ nowMs?: number;
1876
+ onChildFailed?: string;
1877
+ onParentClosed?: string;
1878
+ maxActiveMs?: MaxActiveMs;
1092
1879
  values?: Record<string, unknown>;
1093
1880
  valueRefs?: Record<string, string>;
1094
- dropValues?: string[];
1095
- overrideValues?: string[];
1096
1881
  }): Promise<unknown>;
1097
- flowSignal(id: string, options: Parameters<FerricStoreClient["signal"]>[1]): Promise<unknown>;
1098
- claimDue(type: string, options: ClaimDueOptions): Promise<(FlowRecord | ClaimedItem)[]>;
1099
- claimJobs(type: string, options: Omit<ClaimDueOptions, "jobOnly">): Promise<ClaimedItem[]>;
1100
- reclaim(type: string, options: ReclaimOptions): Promise<(FlowRecord | ClaimedItem)[]>;
1101
- extendLease(id: string, options: {
1102
- leaseToken: Buffer;
1103
- fencingToken: number;
1104
- leaseMs: number;
1882
+ installPolicy(type: string, options?: FlowPolicyOptions): Promise<unknown>;
1883
+ policyGet(type: string, options?: {
1884
+ state?: string;
1885
+ }): Promise<Record<string, unknown>>;
1886
+ retentionCleanup(): Promise<Record<string, unknown>>;
1887
+ protected executeProducerWrite(args: CommandArgument[]): Promise<unknown>;
1888
+ protected recordOrGet(response: unknown, id: string, partitionKey: string | undefined): Promise<FlowRecord>;
1889
+ protected records(values: unknown[]): FlowRecord[];
1890
+ protected recordsOrResponse(value: unknown): unknown[] | unknown;
1891
+ protected flowManyLimitError(operation: string): Error;
1892
+ protected executeIndependentManyChunks<T>(operation: string, items: readonly T[], capture: (item: T) => T, execute: (batchItems: T[]) => Promise<unknown[] | unknown>): Promise<unknown[]>;
1893
+ private indexQuery;
1894
+ protected appendPartitionOptions(args: CommandArgument[], options: {
1105
1895
  partitionKey?: string;
1106
- nowMs?: number;
1107
- }): Promise<FlowRecord>;
1896
+ partitionKeys?: string[];
1897
+ }): void;
1898
+ }
1899
+
1900
+ declare class FerricStoreMutationClient extends FerricStoreFlowSupportClient {
1108
1901
  transition(id: string, options: TransitionOptions): Promise<FlowRecord | Buffer | unknown>;
1109
1902
  complete(id: string, options: CompleteOptions): Promise<FlowRecord | Buffer | unknown>;
1110
- completeMany(partitionKey: string | undefined, items: ClaimedItem[], options?: {
1111
- result?: unknown;
1112
- payload?: unknown;
1113
- values?: Record<string, unknown>;
1114
- valueRefs?: Record<string, string>;
1115
- dropValues?: string[];
1116
- overrideValues?: string[];
1117
- stateMeta?: StateMeta;
1118
- ttlMs?: number;
1119
- nowMs?: number;
1120
- independent?: boolean;
1121
- returnOkOnSuccess?: boolean;
1122
- }): Promise<unknown[] | unknown>;
1123
- completeJobs(jobs: ClaimedItem[], options?: Parameters<FerricStoreClient["completeMany"]>[2]): Promise<unknown[] | unknown>;
1124
- transitionMany(partitionKey: string | undefined, options: {
1125
- fromState: string;
1126
- toState: string;
1127
- items: FencedItem[];
1128
- payload?: unknown;
1129
- values?: Record<string, unknown>;
1130
- valueRefs?: Record<string, string>;
1131
- dropValues?: string[];
1132
- overrideValues?: string[];
1133
- stateMeta?: StateMeta;
1134
- runAtMs?: number;
1135
- nowMs?: number;
1136
- priority?: number;
1137
- independent?: boolean;
1138
- }): Promise<unknown[] | unknown>;
1903
+ completeMany(partitionKey: string | undefined, items: ClaimedItem[], options?: CompleteManyOptions): Promise<unknown[] | unknown>;
1904
+ protected completeManyRequest(partitionKey: string | undefined, items: ClaimedItem[], options: CompleteManyOptions): CommandArgument[];
1905
+ completeJobs(jobs: ClaimedItem[], options?: CompleteManyOptions): Promise<unknown[] | unknown>;
1139
1906
  retry(id: string, options: RetryOptions): Promise<FlowRecord | Buffer | unknown>;
1140
1907
  retryMany(partitionKey: string | undefined, items: ClaimedItem[], options?: {
1141
1908
  error?: unknown;
@@ -1144,10 +1911,13 @@ declare class FerricStoreClient {
1144
1911
  valueRefs?: Record<string, string>;
1145
1912
  dropValues?: string[];
1146
1913
  overrideValues?: string[];
1914
+ attributesMerge?: Record<string, CommandArgument>;
1915
+ attributesDelete?: string[];
1147
1916
  stateMeta?: StateMeta;
1148
1917
  runAtMs?: number;
1149
1918
  nowMs?: number;
1150
1919
  independent?: boolean;
1920
+ returnOkOnSuccess?: boolean;
1151
1921
  }): Promise<unknown[] | unknown>;
1152
1922
  fail(id: string, options: FailOptions): Promise<FlowRecord | Buffer | unknown>;
1153
1923
  failMany(partitionKey: string | undefined, items: ClaimedItem[], options?: {
@@ -1157,126 +1927,113 @@ declare class FerricStoreClient {
1157
1927
  valueRefs?: Record<string, string>;
1158
1928
  dropValues?: string[];
1159
1929
  overrideValues?: string[];
1930
+ attributesMerge?: Record<string, CommandArgument>;
1931
+ attributesDelete?: string[];
1160
1932
  stateMeta?: StateMeta;
1161
1933
  ttlMs?: number;
1162
1934
  nowMs?: number;
1163
1935
  independent?: boolean;
1936
+ returnOkOnSuccess?: boolean;
1164
1937
  }): Promise<unknown[] | unknown>;
1165
1938
  cancel(id: string, options: CancelOptions): Promise<FlowRecord | Buffer | unknown>;
1166
1939
  cancelMany(partitionKey: string | undefined, items: FencedItem[], options?: {
1167
1940
  reason?: unknown;
1941
+ values?: Record<string, unknown>;
1942
+ valueRefs?: Record<string, string>;
1943
+ dropValues?: string[];
1944
+ overrideValues?: string[];
1945
+ attributesMerge?: Record<string, CommandArgument>;
1946
+ attributesDelete?: string[];
1168
1947
  stateMeta?: StateMeta;
1169
1948
  ttlMs?: number;
1170
1949
  nowMs?: number;
1171
1950
  independent?: boolean;
1172
1951
  }): Promise<unknown[] | unknown>;
1173
- rewind(id: string, options?: {
1174
- partitionKey?: string;
1175
- toEvent?: string;
1176
- expectState?: string;
1177
- nowMs?: number;
1178
- returnRecord?: boolean;
1952
+ }
1953
+
1954
+ declare class FerricStoreClaimClient extends FerricStoreMutationClient {
1955
+ claimDue(type: string, options: ClaimDueOptions): Promise<(FlowRecord | ClaimedItem)[]>;
1956
+ private claimDueRequest;
1957
+ private claimDueResponse;
1958
+ claimJobs(type: string, options: Omit<ClaimDueOptions, "jobOnly">): Promise<ClaimedItem[]>;
1959
+ reclaim(type: string, options: ReclaimOptions): Promise<(FlowRecord | ClaimedItem)[]>;
1960
+ private claimedItems;
1961
+ extendLease(id: string, options: ExtendLeaseOptions & {
1962
+ readonly returnOkOnSuccess: true;
1963
+ }): Promise<boolean>;
1964
+ extendLease(id: string, options: ExtendLeaseOptions & {
1965
+ readonly returnOkOnSuccess?: false;
1966
+ }): Promise<FlowRecord>;
1967
+ extendLease(id: string, options: ExtendLeaseOptions): Promise<FlowRecord | boolean>;
1968
+ /**
1969
+ * Complete leased jobs and claim replacements through one ordered pipeline
1970
+ * when both commands can use the same route. Item errors are returned beside
1971
+ * any newly leased jobs so callers cannot accidentally discard those leases.
1972
+ */
1973
+ completeJobsAndClaimJobs(jobs: ClaimedItem[], type: string, claimOptions: ClaimDueOptions, completeOptions?: Omit<CompleteManyOptions, "returnOkOnSuccess">): Promise<CompleteJobsAndClaimJobsResult>;
1974
+ completeFlowsAndClaimFlows(jobs: ClaimedItem[], type: string, claimOptions: ClaimDueOptions, completeOptions?: Omit<CompleteManyOptions, "returnOkOnSuccess">): Promise<CompleteJobsAndClaimJobsResult>;
1975
+ }
1976
+
1977
+ /** Producer-oriented Flow commands, separated from mutation and claim APIs. */
1978
+ declare class FerricStoreProducerClient extends FerricStoreClaimClient {
1979
+ create(id: string, options: CreateOptions): Promise<FlowRecord | Buffer | unknown>;
1980
+ enqueue(id: string, options: Omit<CreateOptions, "state"> & {
1981
+ state?: string;
1179
1982
  }): Promise<FlowRecord | Buffer | unknown>;
1180
- get<TPayload = unknown>(id: string, options?: {
1181
- partitionKey?: string;
1182
- full?: boolean;
1183
- }): Promise<FlowRecord<TPayload> | undefined>;
1184
- list(type: string, options?: ReadOptions): Promise<FlowRecord[]>;
1185
- search(type: string, options?: SearchOptions): Promise<FlowRecord[]>;
1186
- terminals(type: string, options?: ReadOptions): Promise<FlowRecord[]>;
1187
- failures(type: string, options?: ReadOptions): Promise<FlowRecord[]>;
1188
- byParent(parentFlowId: string, options?: ReadOptions): Promise<FlowRecord[]>;
1189
- byRoot(rootFlowId: string, options?: ReadOptions): Promise<FlowRecord[]>;
1190
- byCorrelation(correlationId: string, options?: ReadOptions): Promise<FlowRecord[]>;
1191
- info(type: string): Promise<Record<string, unknown>>;
1192
- stuck(type: string, options?: {
1193
- partitionKey?: string;
1194
- count?: number;
1195
- olderThanMs?: number;
1196
- nowMs?: number;
1197
- }): Promise<FlowRecord[]>;
1198
- history(id: string, options?: {
1983
+ enqueueMany(items: CreateItem[], options: CreateManyOptions): Promise<unknown[] | unknown>;
1984
+ createMany(partitionKey: string | undefined, items: CreateItem[], options: CreateManyOptions): Promise<unknown[] | unknown>;
1985
+ }
1986
+
1987
+ declare class FerricStoreClient extends FerricStoreProducerClient {
1988
+ static fromUrl(url: string, options?: FerricStoreClientFromUrlOptions): Promise<FerricStoreClient>;
1989
+ static fromUrls(urls: readonly string[], options?: FerricStoreClientFromUrlOptions): Promise<FerricStoreClient>;
1990
+ valuePut(value: unknown, options?: {
1199
1991
  partitionKey?: string;
1200
- count?: number;
1201
- fromEvent?: string;
1202
- rev?: boolean;
1992
+ ownerFlowId?: string;
1993
+ name?: string;
1994
+ override?: boolean;
1995
+ ttlMs?: number;
1996
+ nowMs?: number;
1997
+ }): Promise<unknown>;
1998
+ valueMGet(refs: string[], options?: {
1999
+ maxBytes?: number;
1203
2000
  }): Promise<unknown[]>;
1204
- spawnChildren(parentId: string, children: ChildSpec[], options?: {
1205
- groupId?: string;
2001
+ signal(id: string, options: {
2002
+ signal: string;
1206
2003
  partitionKey?: string;
1207
- leaseToken?: Buffer;
1208
- fencingToken?: number;
1209
- wait?: string;
1210
- waitState?: string;
1211
- success?: string;
1212
- failure?: string;
1213
- fromState?: string;
2004
+ idempotencyKey?: string;
2005
+ ifState?: string | string[];
2006
+ transitionTo?: string;
2007
+ runAtMs?: number;
1214
2008
  nowMs?: number;
1215
- onChildFailed?: string;
1216
- onParentClosed?: string;
2009
+ priority?: number;
1217
2010
  values?: Record<string, unknown>;
1218
2011
  valueRefs?: Record<string, string>;
2012
+ dropValues?: string[];
2013
+ overrideValues?: string[];
1219
2014
  }): Promise<unknown>;
1220
- installPolicy(type: string, options?: {
1221
- state?: string;
1222
- retry?: RetryPolicy;
1223
- retentionTtlMs?: number;
1224
- indexedStateMeta?: string;
1225
- }): Promise<unknown>;
1226
- policyGet(type: string, options?: {
1227
- state?: string;
1228
- }): Promise<Record<string, unknown>>;
1229
- retentionCleanup(): Promise<Record<string, unknown>>;
1230
- private executeProducerWrite;
1231
- private recordOrGet;
1232
- private records;
1233
- private recordsOrResponse;
1234
- private indexQuery;
1235
- private appendPartitionOptions;
1236
- }
1237
-
1238
- declare class FerricStoreError extends Error {
1239
- readonly code: string;
1240
- readonly raw: unknown;
1241
- constructor(message: string, options?: {
1242
- raw?: unknown;
1243
- cause?: unknown;
1244
- });
1245
- }
1246
- declare class FlowNotFoundError extends FerricStoreError {
1247
- readonly code = "flow_not_found";
1248
- }
1249
- declare class FlowWrongStateError extends FerricStoreError {
1250
- readonly code = "flow_wrong_state";
1251
- }
1252
- declare class StaleLeaseError extends FerricStoreError {
1253
- readonly code = "stale_lease";
1254
- }
1255
- declare class FlowAlreadyExistsError extends FerricStoreError {
1256
- readonly code = "flow_already_exists";
1257
- }
1258
- declare class LockHeldError extends FerricStoreError {
1259
- readonly code = "lock_held";
1260
- }
1261
- declare class LockNotOwnedError extends FerricStoreError {
1262
- readonly code = "lock_not_owned";
1263
- }
1264
- declare class InvalidCommandError extends FerricStoreError {
1265
- readonly code = "invalid_command";
1266
- }
1267
- declare class OverloadedError extends FerricStoreError {
1268
- readonly code = "overloaded";
1269
- readonly retryAfterMs: number | undefined;
1270
- readonly reason: string | undefined;
1271
- constructor(message: string, options?: {
1272
- raw?: unknown;
1273
- cause?: unknown;
1274
- retryAfterMs?: number;
1275
- reason?: string;
1276
- });
2015
+ flowSignal(id: string, options: Parameters<FerricStoreClient["signal"]>[1]): Promise<unknown>;
2016
+ startAndClaim(id: string, options: StartAndClaimOptions): Promise<FlowRecord>;
2017
+ stepContinue(id: string, options: StepContinueOptions): Promise<FlowRecord | ClaimedItem>;
2018
+ runStepsMany(items: readonly (string | RunStepsItem)[], options: RunStepsManyOptions): Promise<unknown>;
2019
+ transitionMany(partitionKey: string | undefined, options: {
2020
+ fromState: string;
2021
+ toState: string;
2022
+ items: FencedItem[];
2023
+ payload?: unknown;
2024
+ values?: Record<string, unknown>;
2025
+ valueRefs?: Record<string, string>;
2026
+ dropValues?: string[];
2027
+ overrideValues?: string[];
2028
+ attributesMerge?: Record<string, CommandArgument>;
2029
+ attributesDelete?: string[];
2030
+ stateMeta?: StateMeta;
2031
+ runAtMs?: number;
2032
+ nowMs?: number;
2033
+ priority?: number;
2034
+ independent?: boolean;
2035
+ }): Promise<unknown[] | unknown>;
1277
2036
  }
1278
- declare function classifyServerError(message: string, raw?: unknown, cause?: unknown): FerricStoreError;
1279
- declare function mapException(error: unknown): unknown;
1280
2037
 
1281
2038
  type Outcome = TransitionOutcome | CompleteOutcome | RetryOutcome | FailOutcome;
1282
2039
  interface NamedValueMutation {
@@ -1284,6 +2041,8 @@ interface NamedValueMutation {
1284
2041
  valueRefs?: Record<string, string>;
1285
2042
  dropValues?: string[];
1286
2043
  overrideValues?: string[];
2044
+ attributesMerge?: Record<string, CommandArgument>;
2045
+ attributesDelete?: string[];
1287
2046
  stateMeta?: StateMeta;
1288
2047
  }
1289
2048
  interface TransitionOutcome extends NamedValueMutation {
@@ -1315,6 +2074,40 @@ declare function transition(toState: string, options?: Omit<TransitionOutcome, "
1315
2074
  declare function complete(options?: Omit<CompleteOutcome, "kind">): CompleteOutcome;
1316
2075
  declare function retry(options?: Omit<RetryOutcome, "kind">): RetryOutcome;
1317
2076
  declare function fail(options?: Omit<FailOutcome, "kind">): FailOutcome;
2077
+ declare function isOutcome(value: unknown): value is Outcome;
2078
+
2079
+ /** Raised when a worker loses the ability to renew a claimed job's lease. */
2080
+ declare class LeaseRenewalError extends Error {
2081
+ constructor(cause: unknown);
2082
+ }
2083
+
2084
+ declare class QueueWorker {
2085
+ readonly queue: Queue;
2086
+ readonly options: WorkerConfig;
2087
+ private readonly pendingCompletions;
2088
+ constructor(queue: Queue, options: WorkerConfig);
2089
+ runOnce(handler: QueueHandler): Promise<QueueWorkerResult>;
2090
+ private runHandlerClaimOnce;
2091
+ runBatchOnce(handler: QueueBatchHandler): Promise<QueueWorkerResult>;
2092
+ runBatchOnceForPartitionKeys(handler: QueueBatchHandler, partitionKeys: readonly string[], options?: {
2093
+ readonly claimCredit?: number;
2094
+ }): Promise<QueueWorkerResult>;
2095
+ flush(): Promise<number>;
2096
+ private runBatchOnceWithClaim;
2097
+ run(handler: QueueHandler): Promise<void>;
2098
+ private runContinuously;
2099
+ private claimJobs;
2100
+ private applyJob;
2101
+ private applyContinuousJob;
2102
+ private guardContinuousJob;
2103
+ private flushCompletions;
2104
+ }
2105
+
2106
+ /** Async terminal-write failure with the number of durable successes drained first. */
2107
+ declare class QueueCompletionError extends Error {
2108
+ readonly completed: number;
2109
+ constructor(cause: unknown, completed: number);
2110
+ }
1318
2111
 
1319
2112
  type QueueJob = FlowRecord | ClaimedItem;
1320
2113
  type QueueHandler = (job: QueueJob) => Promise<unknown> | unknown;
@@ -1342,6 +2135,7 @@ declare class Queue {
1342
2135
  readonly defaultWorker: string;
1343
2136
  constructor(client: FerricStoreClient, options: QueueOptions);
1344
2137
  enqueue(id: string, options?: {
2138
+ attributes?: Record<string, CommandArgument>;
1345
2139
  payload?: unknown;
1346
2140
  partitionKey?: string;
1347
2141
  runAtMs?: number;
@@ -1349,53 +2143,102 @@ declare class Queue {
1349
2143
  priority?: number;
1350
2144
  idempotent?: boolean;
1351
2145
  retentionTtlMs?: number;
2146
+ maxActiveMs?: MaxActiveMs;
1352
2147
  values?: Record<string, unknown>;
1353
2148
  valueRefs?: Record<string, string>;
1354
2149
  stateMeta?: StateMeta;
1355
2150
  returnRecord?: boolean;
1356
2151
  }): Promise<FlowRecord | Buffer | unknown>;
1357
2152
  enqueueMany(items: CreateItem[], options?: {
2153
+ attributes?: Record<string, CommandArgument>;
1358
2154
  partitionKey?: string;
2155
+ autoPartitionBatchSize?: number;
2156
+ autoPartitionConcurrency?: number;
1359
2157
  runAtMs?: number;
1360
2158
  nowMs?: number;
1361
2159
  priority?: number;
1362
2160
  idempotent?: boolean;
1363
2161
  independent?: boolean;
1364
2162
  retentionTtlMs?: number;
2163
+ maxActiveMs?: MaxActiveMs;
1365
2164
  values?: Record<string, unknown>;
1366
2165
  valueRefs?: Record<string, string>;
1367
2166
  stateMeta?: StateMeta;
1368
2167
  }): Promise<unknown[] | unknown>;
1369
2168
  worker(options?: WorkerConfig): QueueWorker;
1370
2169
  }
1371
- declare class QueueWorker {
1372
- readonly queue: Queue;
1373
- readonly options: WorkerConfig;
1374
- private readonly pendingCompletions;
1375
- constructor(queue: Queue, options: WorkerConfig);
1376
- runOnce(handler: QueueHandler): Promise<QueueWorkerResult>;
1377
- runBatchOnce(handler: QueueBatchHandler): Promise<QueueWorkerResult>;
1378
- runBatchOnceForPartitionKeys(handler: QueueBatchHandler, partitionKeys: readonly string[], options?: {
1379
- readonly claimCredit?: number;
1380
- }): Promise<QueueWorkerResult>;
1381
- flush(): Promise<number>;
1382
- private runBatchOnceWithClaim;
1383
- run(handler: QueueHandler): Promise<void>;
1384
- private claimJobs;
1385
- private applyJob;
1386
- private flushCompletions;
1387
- private enqueueCompletion;
1388
- private drainPendingCompletions;
1389
- private applyOutcome;
1390
- private applyException;
2170
+
2171
+ declare class WorkflowContext {
2172
+ readonly workflow: Workflow;
2173
+ readonly job: FlowRecord | ClaimedItem;
2174
+ readonly stateName: string;
2175
+ readonly flow: WorkflowFlowCommands;
2176
+ private readonly leaseJob;
2177
+ private readonly valueCache;
2178
+ constructor(workflow: Workflow, job: FlowRecord | ClaimedItem, stateName: string, leaseJob?: ClaimedItem);
2179
+ get client(): FerricStoreClient;
2180
+ get id(): string;
2181
+ get type(): string;
2182
+ get state(): string;
2183
+ get logicalState(): string;
2184
+ get partitionKey(): string | undefined;
2185
+ get payload(): unknown;
2186
+ get values(): Record<string, unknown>;
2187
+ get stateMeta(): Record<string, unknown>;
2188
+ get indexedStateMeta(): string | undefined;
2189
+ get valueRefs(): Record<string, unknown>;
2190
+ get leaseToken(): Buffer;
2191
+ get fencingToken(): FencingToken;
2192
+ get version(): number;
2193
+ get parentFlowId(): string | undefined;
2194
+ get rootFlowId(): string | undefined;
2195
+ get correlationId(): string | undefined;
2196
+ value(name: string, defaultValue?: unknown, options?: {
2197
+ localCache?: boolean;
2198
+ }): Promise<unknown>;
2199
+ valueMany(names: string[], options?: {
2200
+ localCache?: boolean;
2201
+ }): Promise<Record<string, unknown>>;
2202
+ private valueMaxBytes;
2203
+ }
2204
+ declare class WorkflowFlowCommands {
2205
+ private readonly ctx;
2206
+ constructor(ctx: WorkflowContext);
2207
+ get(id?: string, options?: {
2208
+ partitionKey?: string;
2209
+ full?: boolean;
2210
+ }): Promise<FlowRecord | undefined>;
2211
+ history(id?: string, options?: Parameters<FerricStoreClient["history"]>[1]): Promise<unknown[]>;
2212
+ create(id: string, options?: Omit<Parameters<FerricStoreClient["create"]>[1], "type"> & {
2213
+ type?: string;
2214
+ }): Promise<FlowRecord | Buffer | unknown>;
2215
+ transition(toState: string, options?: Partial<Omit<Parameters<FerricStoreClient["transition"]>[1], "toState" | "fromState" | "leaseToken" | "fencingToken">> & {
2216
+ fromState?: string;
2217
+ }): Promise<FlowRecord | Buffer | unknown>;
2218
+ stepContinue(toState: string, options?: Partial<Omit<StepContinueOptions, "toState" | "fromState" | "leaseToken" | "fencingToken">> & {
2219
+ fromState?: string;
2220
+ }): Promise<FlowRecord | ClaimedItem>;
2221
+ complete(options?: Partial<Omit<Parameters<FerricStoreClient["complete"]>[1], "leaseToken" | "fencingToken">>): Promise<FlowRecord | Buffer | unknown>;
2222
+ retry(options?: Partial<Omit<Parameters<FerricStoreClient["retry"]>[1], "leaseToken" | "fencingToken">>): Promise<FlowRecord | Buffer | unknown>;
2223
+ fail(options?: Partial<Omit<Parameters<FerricStoreClient["fail"]>[1], "leaseToken" | "fencingToken">>): Promise<FlowRecord | Buffer | unknown>;
2224
+ signal(signal: string, options?: Omit<Parameters<FerricStoreClient["signal"]>[1], "signal">): Promise<unknown>;
2225
+ putValue(name: string, value: unknown, options?: Parameters<FerricStoreClient["valuePut"]>[1]): Promise<unknown>;
2226
+ value(name: string, defaultValue?: unknown, options?: {
2227
+ localCache?: boolean;
2228
+ }): Promise<unknown>;
2229
+ values(names: string[], options?: {
2230
+ localCache?: boolean;
2231
+ }): Promise<Record<string, unknown>>;
2232
+ spawnChildren(children: ChildSpec[], options?: Parameters<FerricStoreClient["spawnChildren"]>[2]): Promise<unknown>;
1391
2233
  }
1392
2234
 
1393
2235
  type WorkflowHandler = (ctx: WorkflowContext) => Promise<Outcome | void | unknown> | Outcome | void | unknown;
1394
2236
  interface StateOptions {
2237
+ mode?: FlowStateMode;
1395
2238
  leaseMs?: number;
1396
2239
  claimPayload?: boolean;
1397
2240
  claimRecord?: boolean;
1398
- claimValues?: string[];
2241
+ claimValues?: readonly string[];
1399
2242
  valueMaxBytes?: number;
1400
2243
  exceptionPolicy?: ExceptionPolicy;
1401
2244
  retryPolicy?: RetryPolicy;
@@ -1414,17 +2257,19 @@ interface WorkflowWorkerResult {
1414
2257
  emptyClaims: number;
1415
2258
  }
1416
2259
  interface StateRegistration {
1417
- claimValues?: string[];
1418
- claimPayload: boolean;
1419
- claimRecord: boolean;
1420
- exceptionPolicy: ExceptionPolicy;
1421
- handler: WorkflowHandler;
1422
- leaseMs: number;
1423
- name: string;
1424
- returnRecord: boolean;
1425
- retryPolicy?: RetryPolicy;
1426
- valueMaxBytes?: number;
2260
+ readonly claimValues?: readonly string[];
2261
+ readonly claimPayload: boolean;
2262
+ readonly claimRecord: boolean;
2263
+ readonly exceptionPolicy: ExceptionPolicy;
2264
+ readonly handler: WorkflowHandler;
2265
+ readonly leaseMs: number;
2266
+ readonly mode?: FlowStateMode;
2267
+ readonly name: string;
2268
+ readonly returnRecord: boolean;
2269
+ readonly retryPolicy?: Readonly<RetryPolicy>;
2270
+ readonly valueMaxBytes?: number;
1427
2271
  }
2272
+
1428
2273
  declare class WorkflowClient {
1429
2274
  readonly flow: FerricStoreClient;
1430
2275
  constructor(flow: FerricStoreClient);
@@ -1442,6 +2287,7 @@ declare class Workflow {
1442
2287
  constructor(client: FerricStoreClient, options: WorkflowOptions);
1443
2288
  state(name: string, handler: WorkflowHandler, options?: StateOptions): this;
1444
2289
  start(id: string, options?: {
2290
+ attributes?: Record<string, CommandArgument>;
1445
2291
  payload?: unknown;
1446
2292
  state?: string;
1447
2293
  partitionKey?: string;
@@ -1453,19 +2299,26 @@ declare class Workflow {
1453
2299
  priority?: number;
1454
2300
  idempotent?: boolean;
1455
2301
  retentionTtlMs?: number;
2302
+ maxActiveMs?: MaxActiveMs;
1456
2303
  values?: Record<string, unknown>;
1457
2304
  valueRefs?: Record<string, string>;
1458
2305
  stateMeta?: StateMeta;
1459
2306
  returnRecord?: boolean;
1460
2307
  }): Promise<FlowRecord | Buffer | unknown>;
2308
+ startAndClaim(id: string, options: Omit<StartAndClaimOptions, "type" | "initialState"> & {
2309
+ initialState?: string;
2310
+ }): Promise<FlowRecord>;
2311
+ runStepsMany(items: readonly (string | RunStepsItem)[], options: Omit<RunStepsManyOptions, "type">): Promise<unknown>;
1461
2312
  startMany(items: {
1462
2313
  id: string;
1463
2314
  payload?: unknown;
1464
2315
  partitionKey?: string;
2316
+ attributes?: Record<string, CommandArgument>;
1465
2317
  values?: Record<string, unknown>;
1466
2318
  valueRefs?: Record<string, string>;
1467
2319
  stateMeta?: StateMeta;
1468
2320
  }[], options?: {
2321
+ attributes?: Record<string, CommandArgument>;
1469
2322
  state?: string;
1470
2323
  partitionKey?: string;
1471
2324
  runAtMs?: number;
@@ -1474,6 +2327,7 @@ declare class Workflow {
1474
2327
  idempotent?: boolean;
1475
2328
  independent?: boolean;
1476
2329
  retentionTtlMs?: number;
2330
+ maxActiveMs?: MaxActiveMs;
1477
2331
  values?: Record<string, unknown>;
1478
2332
  valueRefs?: Record<string, string>;
1479
2333
  stateMeta?: StateMeta;
@@ -1484,68 +2338,10 @@ declare class Workflow {
1484
2338
  worker(options?: WorkerConfig & {
1485
2339
  states?: string[];
1486
2340
  }): WorkflowWorker;
2341
+ installPolicy(options?: Omit<FlowPolicyOptions, "mode" | "state" | "states">): Promise<unknown>;
1487
2342
  stateNames(): string[];
1488
2343
  stateRegistration(name: string): StateRegistration | undefined;
1489
2344
  }
1490
- declare class WorkflowContext {
1491
- readonly workflow: Workflow;
1492
- readonly job: FlowRecord | ClaimedItem;
1493
- readonly stateName: string;
1494
- readonly flow: WorkflowFlowCommands;
1495
- private readonly valueCache;
1496
- constructor(workflow: Workflow, job: FlowRecord | ClaimedItem, stateName: string);
1497
- get client(): FerricStoreClient;
1498
- get id(): string;
1499
- get type(): string;
1500
- get state(): string;
1501
- get logicalState(): string;
1502
- get partitionKey(): string | undefined;
1503
- get payload(): unknown;
1504
- get values(): Record<string, unknown>;
1505
- get stateMeta(): Record<string, unknown>;
1506
- get indexedStateMeta(): string | undefined;
1507
- get valueRefs(): Record<string, unknown>;
1508
- get leaseToken(): Buffer;
1509
- get fencingToken(): number;
1510
- get version(): number;
1511
- get parentFlowId(): string | undefined;
1512
- get rootFlowId(): string | undefined;
1513
- get correlationId(): string | undefined;
1514
- value(name: string, defaultValue?: unknown, options?: {
1515
- localCache?: boolean;
1516
- }): Promise<unknown>;
1517
- valueMany(names: string[], options?: {
1518
- localCache?: boolean;
1519
- }): Promise<Record<string, unknown>>;
1520
- private valueMaxBytes;
1521
- }
1522
- declare class WorkflowFlowCommands {
1523
- private readonly ctx;
1524
- constructor(ctx: WorkflowContext);
1525
- get(id?: string, options?: {
1526
- partitionKey?: string;
1527
- full?: boolean;
1528
- }): Promise<FlowRecord | undefined>;
1529
- history(id?: string, options?: Parameters<FerricStoreClient["history"]>[1]): Promise<unknown[]>;
1530
- create(id: string, options?: Omit<Parameters<FerricStoreClient["create"]>[1], "type"> & {
1531
- type?: string;
1532
- }): Promise<FlowRecord | Buffer | unknown>;
1533
- transition(toState: string, options?: Partial<Omit<Parameters<FerricStoreClient["transition"]>[1], "toState" | "fromState" | "leaseToken" | "fencingToken">> & {
1534
- fromState?: string;
1535
- }): Promise<FlowRecord | Buffer | unknown>;
1536
- complete(options?: Partial<Omit<Parameters<FerricStoreClient["complete"]>[1], "leaseToken" | "fencingToken">>): Promise<FlowRecord | Buffer | unknown>;
1537
- retry(options?: Partial<Omit<Parameters<FerricStoreClient["retry"]>[1], "leaseToken" | "fencingToken">>): Promise<FlowRecord | Buffer | unknown>;
1538
- fail(options?: Partial<Omit<Parameters<FerricStoreClient["fail"]>[1], "leaseToken" | "fencingToken">>): Promise<FlowRecord | Buffer | unknown>;
1539
- signal(signal: string, options?: Omit<Parameters<FerricStoreClient["signal"]>[1], "signal">): Promise<unknown>;
1540
- putValue(name: string, value: unknown, options?: Parameters<FerricStoreClient["valuePut"]>[1]): Promise<unknown>;
1541
- value(name: string, defaultValue?: unknown, options?: {
1542
- localCache?: boolean;
1543
- }): Promise<unknown>;
1544
- values(names: string[], options?: {
1545
- localCache?: boolean;
1546
- }): Promise<Record<string, unknown>>;
1547
- spawnChildren(children: ChildSpec[], options?: Parameters<FerricStoreClient["spawnChildren"]>[2]): Promise<unknown>;
1548
- }
1549
2345
  declare class WorkflowWorker {
1550
2346
  readonly workflow: Workflow;
1551
2347
  readonly options: WorkerConfig & {
@@ -1556,8 +2352,15 @@ declare class WorkflowWorker {
1556
2352
  });
1557
2353
  runOnce(): Promise<WorkflowWorkerResult>;
1558
2354
  run(): Promise<void>;
2355
+ private runInWaves;
2356
+ private runContinuously;
2357
+ private resolveStates;
2358
+ private claimState;
1559
2359
  private applyJob;
1560
2360
  private applyHandlerError;
1561
2361
  }
1562
2362
 
1563
- export { type AutoBatchOptions, type BackoffKind, type BackpressurePolicy, BitmapStore, BloomFilterStore, COMMAND_OPCODES, type CancelOptions, type ChildSpec, type ClaimDueOptions, type ClaimedItem, type Codec, type Command, type CommandArgument, type CommandExecutor, type CompleteOptions, type CompleteOutcome, type CountMinMergeOptions, CountMinSketchStore, type CreateItem, type CreateManyOptions, type CreateOptions, CuckooFilterStore, type EndpointPolicy, type ExceptionPolicy, type ExecutePipelineOptions, type FailOptions, type FailOutcome, type FencedItem, FerricStoreClient, type FerricStoreClientFromUrlOptions, type FerricStoreClientOptions, FerricStoreError, type FetchOrComputeResult, FlowAlreadyExistsError, FlowNotFoundError, type FlowRecord, FlowWrongStateError, type GeoAddOptions, type GeoMember, GeoStore, type GetExOptions, HashStore, HyperLogLogStore, InvalidCommandError, JsonCodec, type JsonSetOptions, JsonStore, type KeyInfo, KeyValueStore, ListStore, LockHeldError, LockNotOwnedError, type ManagementPairs, type MutateOptions, type NamedValueMutation, NativeAdapter, type NativeAdapterOptions, type Outcome, OverloadedError, type ProtocolCommand, Queue, type QueueBatchHandler, QueueClient, type QueueHandler, type QueueJob, type QueueOptions, QueueWorker, type QueueWorkerResult, type RangeLimit, type RateLimitResult, RawCodec, type ReadOptions, type ReclaimOptions, type ReconnectOptions, ReconnectingExecutor, type RetryOptions, type RetryOutcome, type RetryPolicy, type RoutingEndpoint, type RoutingRoute, RoutingTopology, type ScanOptions, type SearchOptions, type SearchStateMeta, type SetOptions, SetStore, SortedSetStore, StaleLeaseError, type StateMeta, type StateMetaValue, type StateOptions, type StateRegistration, type StoreCommandClient, StreamStore, type TDigestCreateOptions, type TDigestMergeOptions, TDigestStore, type TopKReserveOptions, TopKStore, TopologyNativeAdapterPool, type TransitionOptions, type TransitionOutcome, type ValueConfig, type WorkerConfig, type WorkerProfile, Workflow, WorkflowClient, WorkflowContext, WorkflowFlowCommands, type WorkflowHandler, type WorkflowOptions, WorkflowWorker, type WorkflowWorkerResult, type XReadStream, type ZAddMember, type ZAddOptions, classifyServerError, complete, fail, isReconnectableClosedConnectionError, mapException, retry, transition };
2363
+ /** @deprecated Use RequestDisposition; retained for source compatibility. */
2364
+ type ConnectionRequestDisposition = RequestDisposition;
2365
+
2366
+ export { type AdminListOptions, type ApprovalListOptions, type ApprovalRequestOptions, type AttributeQueryOptions, type AutoBatchOptions, type BackoffKind, type BackpressurePolicy, BitmapStore, BloomFilterStore, type BudgetCommitOptions, type BudgetReserveOptions, COMMAND_OPCODES, COMPACT_RESPONSE_OPCODES, type CancelOptions, type ChildSpec, type CircuitOpenOptions, type ClaimDueOptions, ClaimHydrationError, type ClaimHydrationItem, type ClaimedItem, type Codec, type CollectionScanOptions, type Command, type CommandArgument, type CommandExecutor, type CompleteJobsAndClaimJobsResult, type CompleteManyOptions, type CompleteOptions, type CompleteOutcome, ConnectionClosedError, type ConnectionRequestDisposition, type CountMinMergeOptions, CountMinSketchStore, type CreateItem, type CreateManyOptions, type CreateOptions, CuckooFilterStore, type EffectCompensateOptions, type EffectConfirmOptions, type EffectFailOptions, type EffectReserveOptions, type EffectStatusOptions, type EndpointPolicy, type ExceptionPolicy, type ExecutePipelineOptions, type ExpiryCondition, type ExtendLeaseOptions, type FailOptions, type FailOutcome, type FencedItem, type FencingToken, FerricStoreClient, type FerricStoreClientFromUrlOptions, type FerricStoreClientOptions, FerricStoreError, type FetchOrComputeComputeResult, type FetchOrComputeFencedResult, type FetchOrComputeHitResult, type FetchOrComputeLegacyResult, type FetchOrComputeResult, type FlowAdminRecord, FlowAlreadyExistsError, type FlowBatchCompletedItem, FlowBatchError, FlowNotFoundError, type FlowPolicyOptions, type FlowRecord, type FlowStateMode, type FlowStatePolicy, type FlowStatePolicyLike, type FlowStatsOptions, FlowWrongStateError, type GeoAddOptions, type GeoMember, GeoStore, type GetExOptions, type GovernanceLedgerOptions, type HashScanResult, HashStore, type HistoryOptions, HyperLogLogStore, type IntegerReply, InvalidCommandError, type InvocationCreateOptions, JsonCodec, type KeyInfo, KeyValueStore, type LeaseMutationOptions, LeaseRenewalError, type LimitAmountOptions, type LimitLeaseOptions, type LimitListOptions, type LimitReleaseOptions, ListStore, LockHeldError, LockNotOwnedError, type ManagementPairs, type MaxActiveMs, type MutateOptions, type NamedValueMutation, NativeAdapter, type NativeAdapterOptions, type NativeClientOptions, type NativeProtocolEvent, type Outcome, OverloadedError, type ProtocolCommand, Queue, type QueueBatchHandler, QueueClient, QueueCompletionError, type QueueHandler, type QueueJob, type QueueOptions, QueueWorker, type QueueWorkerResult, type RangeLimit, type RateLimitResult, RawCodec, type ReadOptions, type ReclaimOptions, type ReconnectOptions, ReconnectingExecutor, type RequestContext, type RequestContextOptions, type RequestDisposition, RequestTimeoutError, RerouteError, type RetryOptions, type RetryOutcome, type RetryPolicy, type RoutingEndpoint, type RoutingRoute, RoutingTopology, type RunStepsItem, type RunStepsManyOptions, type ScanOptions, type ScheduleFireDueOptions, type ScheduleListOptions, type ScheduleOptions, type SearchOptions, type SearchStateMeta, type SetOptions, type SetScanResult, SetStore, type SortedSetScanResult, SortedSetStore, StaleLeaseError, type StartAndClaimOptions, type StateMeta, type StateMetaValue, type StateOptions, type StateRegistration, type StepContinueOptions, type StoreCommandClient, StreamStore, type TDigestCreateOptions, type TDigestMergeOptions, TDigestStore, type TopKReserveOptions, TopKStore, type TopologyNativeAdapterOptions, TopologyNativeAdapterPool, type TransitionOptions, type TransitionOutcome, type ValueConfig, type WorkerConfig, type WorkerProfile, type WorkerRefillStrategy, Workflow, WorkflowClient, WorkflowContext, WorkflowFlowCommands, type WorkflowHandler, type WorkflowOptions, WorkflowWorker, type WorkflowWorkerResult, type XReadStream, type ZAddMember, type ZAddOptions, classifyServerError, complete, fail, isOutcome, isReconnectableClosedConnectionError, mapException, retry, transition };