@ferricstore/ferricstore 0.1.6 → 0.2.0

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