@ferricstore/ferricstore 0.11.8 → 0.11.9

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 (261) hide show
  1. package/README.md +35 -1
  2. package/dist/index.cjs +672 -152
  3. package/dist/index.cjs.map +1 -1
  4. package/dist/index.d.cts +40 -2
  5. package/dist/index.d.ts +40 -2
  6. package/dist/index.js +662 -145
  7. package/dist/index.js.map +1 -1
  8. package/docs/api/assets/hierarchy.js +1 -1
  9. package/docs/api/assets/highlight.css +1 -1
  10. package/docs/api/assets/main.js +1 -1
  11. package/docs/api/assets/navigation.js +1 -1
  12. package/docs/api/assets/search.js +1 -1
  13. package/docs/api/assets/style.css +18 -3
  14. package/docs/api/classes/BitmapStore.html +192 -3
  15. package/docs/api/classes/BloomFilterStore.html +197 -3
  16. package/docs/api/classes/ClaimHydrationError.html +202 -7
  17. package/docs/api/classes/ConnectionClosedError.html +193 -8
  18. package/docs/api/classes/CountMinSketchStore.html +171 -3
  19. package/docs/api/classes/CuckooFilterStore.html +196 -3
  20. package/docs/api/classes/FerricStoreClient.html +2888 -7
  21. package/docs/api/classes/FerricStoreError.html +197 -7
  22. package/docs/api/classes/FlowAlreadyExistsError.html +185 -7
  23. package/docs/api/classes/FlowBatchError.html +204 -8
  24. package/docs/api/classes/FlowNotFoundError.html +185 -7
  25. package/docs/api/classes/FlowQueryError.html +204 -7
  26. package/docs/api/classes/FlowWrongStateError.html +185 -7
  27. package/docs/api/classes/GeoStore.html +188 -3
  28. package/docs/api/classes/HTTPAdapter.html +144 -0
  29. package/docs/api/classes/HTTPTransportError.html +222 -0
  30. package/docs/api/classes/HashStore.html +493 -3
  31. package/docs/api/classes/HyperLogLogStore.html +148 -3
  32. package/docs/api/classes/InvalidCommandError.html +185 -7
  33. package/docs/api/classes/JsonCodec.html +104 -3
  34. package/docs/api/classes/KeyValueStore.html +794 -3
  35. package/docs/api/classes/LeaseRenewalError.html +157 -8
  36. package/docs/api/classes/ListStore.html +451 -3
  37. package/docs/api/classes/LockHeldError.html +185 -7
  38. package/docs/api/classes/LockNotOwnedError.html +185 -7
  39. package/docs/api/classes/NativeAdapter.html +135 -3
  40. package/docs/api/classes/OverloadedError.html +190 -7
  41. package/docs/api/classes/Queue.html +141 -4
  42. package/docs/api/classes/QueueClient.html +97 -4
  43. package/docs/api/classes/QueueCompletionError.html +163 -8
  44. package/docs/api/classes/QueueWorker.html +153 -4
  45. package/docs/api/classes/RawCodec.html +96 -3
  46. package/docs/api/classes/ReconnectingExecutor.html +180 -5
  47. package/docs/api/classes/RequestTimeoutError.html +199 -8
  48. package/docs/api/classes/RerouteError.html +188 -8
  49. package/docs/api/classes/RoutingTopology.html +125 -3
  50. package/docs/api/classes/SetStore.html +363 -3
  51. package/docs/api/classes/SortedSetStore.html +369 -3
  52. package/docs/api/classes/StaleLeaseError.html +185 -7
  53. package/docs/api/classes/StalePolicyGenerationError.html +188 -8
  54. package/docs/api/classes/StreamStore.html +259 -3
  55. package/docs/api/classes/TDigestStore.html +348 -3
  56. package/docs/api/classes/TopKStore.html +229 -3
  57. package/docs/api/classes/TopologyNativeAdapterPool.html +180 -5
  58. package/docs/api/classes/Workflow.html +266 -4
  59. package/docs/api/classes/WorkflowClient.html +97 -4
  60. package/docs/api/classes/WorkflowContext.html +293 -5
  61. package/docs/api/classes/WorkflowFlowCommands.html +251 -3
  62. package/docs/api/classes/WorkflowWorker.html +108 -4
  63. package/docs/api/functions/classifyServerError.html +44 -1
  64. package/docs/api/functions/complete.html +41 -1
  65. package/docs/api/functions/fail.html +41 -1
  66. package/docs/api/functions/httpCommandDisposition.html +41 -0
  67. package/docs/api/functions/isOutcome.html +41 -1
  68. package/docs/api/functions/isReconnectableClosedConnectionError.html +41 -1
  69. package/docs/api/functions/mapException.html +41 -1
  70. package/docs/api/functions/projectFlowQuery.html +43 -1
  71. package/docs/api/functions/retry.html +41 -1
  72. package/docs/api/functions/transition.html +42 -1
  73. package/docs/api/hierarchy.html +112 -1
  74. package/docs/api/index.html +70 -3
  75. package/docs/api/interfaces/AdminListOptions.html +70 -2
  76. package/docs/api/interfaces/ApprovalListOptions.html +74 -2
  77. package/docs/api/interfaces/ApprovalRequestOptions.html +99 -2
  78. package/docs/api/interfaces/AttributeQueryOptions.html +69 -2
  79. package/docs/api/interfaces/AutoBatchOptions.html +72 -3
  80. package/docs/api/interfaces/BackpressurePolicy.html +69 -2
  81. package/docs/api/interfaces/BudgetCommitOptions.html +59 -2
  82. package/docs/api/interfaces/BudgetReserveOptions.html +69 -2
  83. package/docs/api/interfaces/CancelOptions.html +135 -2
  84. package/docs/api/interfaces/ChildSpec.html +79 -2
  85. package/docs/api/interfaces/CircuitOpenOptions.html +64 -2
  86. package/docs/api/interfaces/ClaimDueOptions.html +146 -3
  87. package/docs/api/interfaces/ClaimHydrationItem.html +59 -2
  88. package/docs/api/interfaces/ClaimedItem.html +100 -3
  89. package/docs/api/interfaces/Codec.html +84 -2
  90. package/docs/api/interfaces/CommandExecutor.html +145 -4
  91. package/docs/api/interfaces/CompleteJobsAndClaimJobsResult.html +84 -7
  92. package/docs/api/interfaces/CompleteManyOptions.html +114 -2
  93. package/docs/api/interfaces/CompleteOptions.html +143 -2
  94. package/docs/api/interfaces/CompleteOutcome.html +117 -2
  95. package/docs/api/interfaces/CountMinMergeOptions.html +54 -2
  96. package/docs/api/interfaces/CreateItem.html +84 -2
  97. package/docs/api/interfaces/CreateManyOptions.html +173 -6
  98. package/docs/api/interfaces/CreateOptions.html +143 -4
  99. package/docs/api/interfaces/EffectCompensateOptions.html +89 -2
  100. package/docs/api/interfaces/EffectConfirmOptions.html +89 -2
  101. package/docs/api/interfaces/EffectFailOptions.html +94 -2
  102. package/docs/api/interfaces/EffectReserveOptions.html +84 -2
  103. package/docs/api/interfaces/EffectStatusOptions.html +77 -2
  104. package/docs/api/interfaces/ExecutePipelineOptions.html +68 -4
  105. package/docs/api/interfaces/ExtendLeaseOptions.html +79 -2
  106. package/docs/api/interfaces/FailOptions.html +143 -2
  107. package/docs/api/interfaces/FailOutcome.html +117 -2
  108. package/docs/api/interfaces/FencedItem.html +69 -2
  109. package/docs/api/interfaces/FerricStoreClientFromUrlOptions.html +105 -4
  110. package/docs/api/interfaces/FerricStoreClientOptions.html +84 -4
  111. package/docs/api/interfaces/FetchOrComputeComputeResult.html +83 -4
  112. package/docs/api/interfaces/FetchOrComputeHitResult.html +78 -2
  113. package/docs/api/interfaces/FlowBatchCompletedItem.html +59 -2
  114. package/docs/api/interfaces/FlowEventProjectionField.html +64 -2
  115. package/docs/api/interfaces/FlowExplainCapabilities.html +69 -2
  116. package/docs/api/interfaces/FlowExplainResult.html +124 -2
  117. package/docs/api/interfaces/FlowMaxActiveFailure.html +59 -2
  118. package/docs/api/interfaces/FlowPolicyBackoffSnapshot.html +69 -2
  119. package/docs/api/interfaces/FlowPolicyOptions.html +107 -6
  120. package/docs/api/interfaces/FlowPolicyRetentionSnapshot.html +59 -2
  121. package/docs/api/interfaces/FlowPolicyRetrySnapshot.html +64 -2
  122. package/docs/api/interfaces/FlowPolicySnapshot.html +121 -5
  123. package/docs/api/interfaces/FlowPolicyStateSnapshot.html +74 -2
  124. package/docs/api/interfaces/FlowQueryCountResult.html +89 -2
  125. package/docs/api/interfaces/FlowQueryErrorPosition.html +64 -2
  126. package/docs/api/interfaces/FlowQueryIndex.html +134 -2
  127. package/docs/api/interfaces/FlowQueryIndexBuild.html +106 -2
  128. package/docs/api/interfaces/FlowQueryIndexCoverage.html +69 -2
  129. package/docs/api/interfaces/FlowQueryIndexField.html +69 -2
  130. package/docs/api/interfaces/FlowQueryIndexFormat.html +79 -2
  131. package/docs/api/interfaces/FlowQueryIndexProgress.html +86 -2
  132. package/docs/api/interfaces/FlowQueryIndexRegistry.html +59 -2
  133. package/docs/api/interfaces/FlowQueryIndexRetirement.html +94 -2
  134. package/docs/api/interfaces/FlowQueryIndexServices.html +74 -2
  135. package/docs/api/interfaces/FlowQueryIndexStatistics.html +99 -2
  136. package/docs/api/interfaces/FlowQueryIndexStatus.html +84 -2
  137. package/docs/api/interfaces/FlowQueryIndexValidation.html +121 -2
  138. package/docs/api/interfaces/FlowQueryPage.html +59 -2
  139. package/docs/api/interfaces/FlowQueryQuality.html +69 -2
  140. package/docs/api/interfaces/FlowQueryRecordsResult.html +94 -2
  141. package/docs/api/interfaces/FlowQueryUsage.html +104 -2
  142. package/docs/api/interfaces/FlowRecord.html +173 -2
  143. package/docs/api/interfaces/FlowRunProjectionField.html +64 -2
  144. package/docs/api/interfaces/FlowStatePolicy.html +59 -2
  145. package/docs/api/interfaces/FlowStatsOptions.html +74 -2
  146. package/docs/api/interfaces/GeoMember.html +64 -2
  147. package/docs/api/interfaces/GovernanceLedgerOptions.html +74 -2
  148. package/docs/api/interfaces/HTTPAdapterOptions.html +120 -0
  149. package/docs/api/interfaces/HistoryOptions.html +124 -2
  150. package/docs/api/interfaces/InvocationCreateOptions.html +71 -2
  151. package/docs/api/interfaces/KeyInfo.html +79 -2
  152. package/docs/api/interfaces/LeaseMutationOptions.html +136 -2
  153. package/docs/api/interfaces/LimitAmountOptions.html +64 -2
  154. package/docs/api/interfaces/LimitLeaseOptions.html +74 -2
  155. package/docs/api/interfaces/LimitListOptions.html +78 -2
  156. package/docs/api/interfaces/LimitReleaseOptions.html +64 -2
  157. package/docs/api/interfaces/MutateOptions.html +110 -2
  158. package/docs/api/interfaces/NamedValueMutation.html +93 -2
  159. package/docs/api/interfaces/NativeAdapterOptions.html +175 -12
  160. package/docs/api/interfaces/NativeClientOptions.html +249 -16
  161. package/docs/api/interfaces/NativeProtocolEvent.html +69 -2
  162. package/docs/api/interfaces/ProtocolCommand.html +69 -2
  163. package/docs/api/interfaces/QueueOptions.html +64 -2
  164. package/docs/api/interfaces/QueueWorkerResult.html +69 -2
  165. package/docs/api/interfaces/RangeLimit.html +59 -2
  166. package/docs/api/interfaces/RateLimitResult.html +74 -2
  167. package/docs/api/interfaces/ReadOptions.html +107 -3
  168. package/docs/api/interfaces/ReclaimOptions.html +140 -3
  169. package/docs/api/interfaces/ReconnectOptions.html +75 -5
  170. package/docs/api/interfaces/RequestContext.html +64 -2
  171. package/docs/api/interfaces/RequestContextOptions.html +60 -2
  172. package/docs/api/interfaces/RetryOptions.html +143 -2
  173. package/docs/api/interfaces/RetryOutcome.html +117 -2
  174. package/docs/api/interfaces/RetryPolicy.html +79 -2
  175. package/docs/api/interfaces/RoutingEndpoint.html +69 -2
  176. package/docs/api/interfaces/RoutingRoute.html +79 -2
  177. package/docs/api/interfaces/RunStepsItem.html +59 -2
  178. package/docs/api/interfaces/RunStepsManyOptions.html +99 -2
  179. package/docs/api/interfaces/ScanOptions.html +66 -3
  180. package/docs/api/interfaces/ScheduleFireDueOptions.html +74 -2
  181. package/docs/api/interfaces/ScheduleFireOptions.html +59 -2
  182. package/docs/api/interfaces/ScheduleListOptions.html +89 -2
  183. package/docs/api/interfaces/ScheduleOptions.html +131 -3
  184. package/docs/api/interfaces/SearchOptions.html +122 -3
  185. package/docs/api/interfaces/StartAndClaimOptions.html +136 -3
  186. package/docs/api/interfaces/StateOptions.html +94 -2
  187. package/docs/api/interfaces/StateRegistration.html +104 -2
  188. package/docs/api/interfaces/StepContinueOptions.html +159 -3
  189. package/docs/api/interfaces/StoreCommandClient.html +89 -3
  190. package/docs/api/interfaces/TDigestCreateOptions.html +60 -2
  191. package/docs/api/interfaces/TDigestMergeOptions.html +66 -2
  192. package/docs/api/interfaces/TopologyNativeAdapterOptions.html +228 -15
  193. package/docs/api/interfaces/TransitionOptions.html +153 -2
  194. package/docs/api/interfaces/TransitionOutcome.html +122 -2
  195. package/docs/api/interfaces/ValueConfig.html +59 -2
  196. package/docs/api/interfaces/WorkerConfig.html +230 -15
  197. package/docs/api/interfaces/WorkflowOptions.html +69 -2
  198. package/docs/api/interfaces/WorkflowWorkerResult.html +69 -2
  199. package/docs/api/interfaces/XReadStream.html +59 -2
  200. package/docs/api/interfaces/ZAddMember.html +59 -2
  201. package/docs/api/modules.html +51 -1
  202. package/docs/api/types/BackoffKind.html +32 -1
  203. package/docs/api/types/CollectionScanOptions.html +34 -2
  204. package/docs/api/types/Command.html +32 -1
  205. package/docs/api/types/CommandArgument.html +32 -1
  206. package/docs/api/types/ConnectionRequestDisposition.html +36 -2
  207. package/docs/api/types/EndpointPolicy.html +34 -2
  208. package/docs/api/types/ExceptionPolicy.html +32 -1
  209. package/docs/api/types/ExpiryCondition.html +32 -1
  210. package/docs/api/types/FencingToken.html +34 -2
  211. package/docs/api/types/FetchOrComputeFencedResult.html +32 -1
  212. package/docs/api/types/FetchOrComputeResult.html +36 -1
  213. package/docs/api/types/FlowAdminRecord.html +32 -1
  214. package/docs/api/types/FlowPolicyBackoffKind.html +32 -1
  215. package/docs/api/types/FlowProjectionField.html +32 -1
  216. package/docs/api/types/FlowProjectionShape.html +32 -1
  217. package/docs/api/types/FlowQueryIndexServiceState.html +32 -1
  218. package/docs/api/types/FlowQueryInteger.html +32 -1
  219. package/docs/api/types/FlowQueryParameter.html +32 -1
  220. package/docs/api/types/FlowQueryParameters.html +32 -1
  221. package/docs/api/types/FlowQueryRecord.html +32 -1
  222. package/docs/api/types/FlowQueryResult.html +32 -1
  223. package/docs/api/types/FlowStateMode.html +32 -1
  224. package/docs/api/types/FlowStatePolicyLike.html +32 -1
  225. package/docs/api/types/GeoAddOptions.html +34 -2
  226. package/docs/api/types/GetExOptions.html +34 -2
  227. package/docs/api/types/HTTPCommandDisposition.html +32 -0
  228. package/docs/api/types/HashScanResult.html +38 -2
  229. package/docs/api/types/IntegerReply.html +34 -2
  230. package/docs/api/types/ManagementPairs.html +32 -1
  231. package/docs/api/types/MaxActiveMs.html +32 -1
  232. package/docs/api/types/Outcome.html +32 -1
  233. package/docs/api/types/QueueBatchHandler.html +44 -1
  234. package/docs/api/types/QueueHandler.html +44 -1
  235. package/docs/api/types/QueueJob.html +32 -1
  236. package/docs/api/types/RequestDisposition.html +32 -1
  237. package/docs/api/types/ScheduleCatchupPolicy.html +34 -2
  238. package/docs/api/types/ScheduleFireDueResult.html +55 -3
  239. package/docs/api/types/ScheduleFireResult.html +34 -2
  240. package/docs/api/types/ScheduleKind.html +32 -1
  241. package/docs/api/types/ScheduleOverlapPolicy.html +32 -1
  242. package/docs/api/types/ScheduleRecord.html +95 -12
  243. package/docs/api/types/ScheduleState.html +32 -1
  244. package/docs/api/types/SearchStateMeta.html +32 -1
  245. package/docs/api/types/SetOptions.html +34 -2
  246. package/docs/api/types/SetScanResult.html +38 -2
  247. package/docs/api/types/SortedSetScanResult.html +38 -2
  248. package/docs/api/types/StateMeta.html +32 -1
  249. package/docs/api/types/StateMetaValue.html +32 -1
  250. package/docs/api/types/TopKReserveOptions.html +32 -1
  251. package/docs/api/types/WorkerProfile.html +32 -1
  252. package/docs/api/types/WorkerRefillStrategy.html +32 -1
  253. package/docs/api/types/WorkflowHandler.html +44 -1
  254. package/docs/api/types/ZAddOptions.html +34 -2
  255. package/docs/api/variables/COMMAND_OPCODES.html +297 -1
  256. package/docs/api/variables/FERRICSTORE_MINIMUM_SERVER_VERSION.html +34 -2
  257. package/docs/api/variables/FERRICSTORE_NATIVE_PROTOCOL_VERSION.html +34 -2
  258. package/docs/api/variables/FERRICSTORE_SDK_VERSION.html +34 -2
  259. package/docs/api/variables/FlowProjection.html +32 -1
  260. package/docs/api/variables/MAX_FLOW_POLICY_GENERATION.html +32 -1
  261. package/package.json +8 -8
package/dist/index.js CHANGED
@@ -28,6 +28,14 @@ var FerricStoreError = class extends Error {
28
28
  this.retryAfterMs = options.retryAfterMs ?? structuredIntegerField(options.raw, "retry_after_ms");
29
29
  }
30
30
  };
31
+ var HTTPTransportError = class extends FerricStoreError {
32
+ code = "http_transport";
33
+ statusCode;
34
+ constructor(message, options = {}) {
35
+ super(message, options);
36
+ this.statusCode = options.statusCode;
37
+ }
38
+ };
31
39
  var ConnectionClosedError = class extends FerricStoreError {
32
40
  code = "connection_closed";
33
41
  requestDisposition;
@@ -8546,6 +8554,497 @@ var NativeAdapter = class _NativeAdapter {
8546
8554
  }
8547
8555
  };
8548
8556
 
8557
+ // src/http-command-policy.ts
8558
+ var nativeOnlyCommands = /* @__PURE__ */ new Set([
8559
+ "AUTH",
8560
+ "BACKPRESSURE",
8561
+ "CLIENT",
8562
+ "CLIENT.INFO",
8563
+ "CLIENT.SETNAME",
8564
+ "EVENT",
8565
+ "GOAWAY",
8566
+ "HELLO",
8567
+ "OPTIONS",
8568
+ "PIPELINE",
8569
+ "QUIT",
8570
+ "ROUTE",
8571
+ "ROUTE_BATCH",
8572
+ "SHARDS",
8573
+ "STARTUP",
8574
+ "SUBSCRIBE_EVENTS",
8575
+ "UNSUBSCRIBE_EVENTS",
8576
+ "WINDOW_UPDATE"
8577
+ ]);
8578
+ var sessionOnlyCommands = /* @__PURE__ */ new Set([
8579
+ "AUTH",
8580
+ "BLMOVE",
8581
+ "BLMPOP",
8582
+ "BLPOP",
8583
+ "BRPOP",
8584
+ "CLIENT",
8585
+ "DISCARD",
8586
+ "EXEC",
8587
+ "HELLO",
8588
+ "MULTI",
8589
+ "PSUBSCRIBE",
8590
+ "PUNSUBSCRIBE",
8591
+ "QUIT",
8592
+ "SELECT",
8593
+ "SUBSCRIBE",
8594
+ "UNSUBSCRIBE",
8595
+ "UNWATCH",
8596
+ "WATCH",
8597
+ "XREAD",
8598
+ "XREADGROUP"
8599
+ ]);
8600
+ function httpCommandDisposition(name) {
8601
+ const normalized = name.toUpperCase();
8602
+ return nativeOnlyCommands.has(normalized) || sessionOnlyCommands.has(normalized) ? "native_only" : "supported";
8603
+ }
8604
+ function assertHTTPCommandSupported(name) {
8605
+ if (typeof name !== "string" || name === "") throw new TypeError("HTTP command must have a name");
8606
+ if (sessionOnlyCommands.has(name.toUpperCase())) {
8607
+ throw new Error(`${name.toUpperCase()} requires a persistent native TCP session`);
8608
+ }
8609
+ }
8610
+
8611
+ // src/http-envelope.ts
8612
+ import { Buffer as Buffer33 } from "buffer";
8613
+ var encoding = "ferricstore-json-v1";
8614
+ var bytesMarker = "$ferricstore_bytes";
8615
+ var mapMarker = "$ferricstore_map";
8616
+ var maxDepth = 64;
8617
+ function encodeHTTPCommands(commands) {
8618
+ return Buffer33.from(JSON.stringify({
8619
+ encoding,
8620
+ commands: commands.map((command) => encodeValue(command, 0))
8621
+ }));
8622
+ }
8623
+ function decodeHTTPEnvelope(source) {
8624
+ let parsed;
8625
+ try {
8626
+ parsed = JSON.parse(source.toString("utf8"));
8627
+ } catch (error) {
8628
+ throw new TypeError("invalid HTTP command response JSON", { cause: error });
8629
+ }
8630
+ if (!isRecord(parsed)) throw new TypeError("HTTP command response must be an object");
8631
+ return decodePlainRecord(parsed, 0);
8632
+ }
8633
+ function encodeValue(value, depth) {
8634
+ if (depth > maxDepth) throw new TypeError("HTTP command value exceeds maximum depth");
8635
+ if (value == null || typeof value === "string" || typeof value === "boolean") return value;
8636
+ if (Buffer33.isBuffer(value) || value instanceof Uint8Array) {
8637
+ return { [bytesMarker]: Buffer33.from(value).toString("base64") };
8638
+ }
8639
+ if (typeof value === "number") {
8640
+ if (!Number.isFinite(value)) throw new TypeError("HTTP command numbers must be finite");
8641
+ return value;
8642
+ }
8643
+ if (typeof value === "bigint") {
8644
+ return value >= BigInt(Number.MIN_SAFE_INTEGER) && value <= BigInt(Number.MAX_SAFE_INTEGER) ? Number(value) : value.toString();
8645
+ }
8646
+ if (Array.isArray(value)) return denseArray(value, depth + 1, encodeValue);
8647
+ if (value instanceof Map) {
8648
+ return { [mapMarker]: [...value.entries()].map(([key, item]) => [
8649
+ encodeValue(key, depth + 1),
8650
+ encodeValue(item, depth + 1)
8651
+ ]) };
8652
+ }
8653
+ if (isRecord(value)) {
8654
+ return { [mapMarker]: Object.entries(value).map(([key, item]) => [
8655
+ encodeValue(key, depth + 1),
8656
+ encodeValue(item, depth + 1)
8657
+ ]) };
8658
+ }
8659
+ throw new TypeError(`unsupported HTTP command value: ${typeof value}`);
8660
+ }
8661
+ function decodeValue2(value, depth) {
8662
+ if (depth > maxDepth) throw new TypeError("HTTP response value exceeds maximum depth");
8663
+ if (Array.isArray(value)) return denseArray(value, depth + 1, decodeValue2);
8664
+ if (!isRecord(value)) return value;
8665
+ if (Object.keys(value).length === 1 && typeof value[bytesMarker] === "string") {
8666
+ return decodeBase64(value[bytesMarker]);
8667
+ }
8668
+ if (Object.keys(value).length === 1 && Array.isArray(value[mapMarker])) {
8669
+ const result = /* @__PURE__ */ new Map();
8670
+ for (const pair of value[mapMarker]) {
8671
+ if (!Array.isArray(pair) || pair.length !== 2) throw new TypeError("invalid HTTP map marker");
8672
+ result.set(decodeValue2(pair[0], depth + 1), decodeValue2(pair[1], depth + 1));
8673
+ }
8674
+ return result;
8675
+ }
8676
+ return decodePlainRecord(value, depth + 1);
8677
+ }
8678
+ function decodeBase64(value) {
8679
+ if (value.length % 4 !== 0 || !/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(value)) {
8680
+ throw new TypeError("invalid HTTP bytes marker");
8681
+ }
8682
+ const decoded = Buffer33.from(value, "base64");
8683
+ if (decoded.toString("base64") !== value) throw new TypeError("invalid HTTP bytes marker");
8684
+ return decoded;
8685
+ }
8686
+ function decodePlainRecord(value, depth) {
8687
+ const result = {};
8688
+ for (const [key, item] of Object.entries(value)) result[key] = decodeValue2(item, depth);
8689
+ return result;
8690
+ }
8691
+ function denseArray(values, depth, transform) {
8692
+ const result = new Array(values.length);
8693
+ for (let index = 0; index < values.length; index += 1) {
8694
+ if (!Object.hasOwn(values, index)) throw new TypeError("HTTP command arrays must be dense");
8695
+ result[index] = transform(values[index], depth);
8696
+ }
8697
+ return result;
8698
+ }
8699
+ function isRecord(value) {
8700
+ return typeof value === "object" && value != null && !Array.isArray(value) && !Buffer33.isBuffer(value);
8701
+ }
8702
+
8703
+ // src/http-options.ts
8704
+ function normalizeHTTPOptions(value, options) {
8705
+ const url = new URL(value);
8706
+ if (url.protocol !== "http:" && url.protocol !== "https:") {
8707
+ throw new TypeError(`unsupported HTTP URL scheme: ${url.protocol}`);
8708
+ }
8709
+ if (url.username !== "" || url.password !== "") throw new TypeError("HTTP URL userinfo is not allowed");
8710
+ if (url.search !== "" || url.hash !== "") throw new TypeError("HTTP base URL cannot contain query or fragment");
8711
+ const headers = normalizedHeaders(options.headers ?? {});
8712
+ const authorization = authorizationHeader(url, options, headers.authorization);
8713
+ if (authorization != null) headers.authorization = authorization;
8714
+ url.pathname = `${url.pathname.replace(/\/$/u, "")}/v1/commands`;
8715
+ return Object.freeze({
8716
+ commandUrl: url,
8717
+ headers: Object.freeze(headers),
8718
+ http2: booleanOption(options.http2, false, "http2"),
8719
+ maxBatchItems: positiveInteger(options.maxBatchItems, 1e3, "maxBatchItems"),
8720
+ maxConnections: positiveInteger(options.maxConnections, 100, "maxConnections"),
8721
+ maxRedirects: nonNegativeInteger(options.maxRedirects, 20, "maxRedirects"),
8722
+ maxRequestBytes: positiveInteger(options.maxRequestBytes, 1024 * 1024, "maxRequestBytes"),
8723
+ maxResponseBytes: positiveInteger(options.maxResponseBytes, 16 * 1024 * 1024, "maxResponseBytes"),
8724
+ timeoutMs: positiveInteger(options.timeoutMs, 3e4, "timeoutMs"),
8725
+ tlsOptions: Object.freeze({ ...options.tlsOptions ?? {} })
8726
+ });
8727
+ }
8728
+ function normalizedHeaders(source) {
8729
+ const headers = {};
8730
+ for (const [rawName, value] of Object.entries(source)) {
8731
+ const name = rawName.toLowerCase();
8732
+ if (name === "" || !safeHeader(name) || !safeHeader(value)) {
8733
+ throw new TypeError(`invalid HTTP header: ${rawName}`);
8734
+ }
8735
+ headers[name] = value;
8736
+ }
8737
+ return headers;
8738
+ }
8739
+ function authorizationHeader(url, options, custom) {
8740
+ const basic = options.username != null || options.password != null;
8741
+ const count = Number(custom != null) + Number(options.bearerToken != null) + Number(basic);
8742
+ if (count > 1) throw new TypeError("HTTP credentials are mutually exclusive");
8743
+ if (options.bearerToken != null) {
8744
+ if (!safeHeader(options.bearerToken)) throw new TypeError("invalid bearer token");
8745
+ return `Bearer ${options.bearerToken}`;
8746
+ }
8747
+ if (!basic) return custom;
8748
+ if (url.protocol !== "https:") throw new TypeError("Basic authentication requires HTTPS");
8749
+ if (typeof options.password !== "string") throw new TypeError("Basic authentication requires a password");
8750
+ const username = options.username ?? "default";
8751
+ if (username === "" || username.includes(":") || !safeHeader(username) || !safeHeader(options.password)) {
8752
+ throw new TypeError("invalid Basic authentication credentials");
8753
+ }
8754
+ return `Basic ${Buffer.from(`${username}:${options.password}`).toString("base64")}`;
8755
+ }
8756
+ function positiveInteger(value, fallback, name) {
8757
+ const result = value ?? fallback;
8758
+ if (!Number.isSafeInteger(result) || result <= 0) throw new TypeError(`${name} must be a positive integer`);
8759
+ return result;
8760
+ }
8761
+ function nonNegativeInteger(value, fallback, name) {
8762
+ const result = value ?? fallback;
8763
+ if (!Number.isSafeInteger(result) || result < 0) throw new TypeError(`${name} must be a non-negative integer`);
8764
+ return result;
8765
+ }
8766
+ function booleanOption(value, fallback, name) {
8767
+ const result = value ?? fallback;
8768
+ if (typeof result !== "boolean") throw new TypeError(`${name} must be a boolean`);
8769
+ return result;
8770
+ }
8771
+ function safeHeader(value) {
8772
+ return !value.includes("\r") && !value.includes("\n");
8773
+ }
8774
+
8775
+ // src/http-transport.ts
8776
+ import http from "http";
8777
+ import http2 from "http2";
8778
+ import https from "https";
8779
+ import { Buffer as Buffer34 } from "buffer";
8780
+ var HTTPTransport = class {
8781
+ constructor(config) {
8782
+ this.config = config;
8783
+ this.#httpAgent = new http.Agent({ keepAlive: true, maxSockets: config.maxConnections });
8784
+ this.#httpsAgent = new https.Agent({
8785
+ ...config.tlsOptions,
8786
+ keepAlive: true,
8787
+ maxSockets: config.maxConnections
8788
+ });
8789
+ }
8790
+ config;
8791
+ #httpAgent;
8792
+ #httpsAgent;
8793
+ #sessions = /* @__PURE__ */ new Map();
8794
+ #closed = false;
8795
+ async post(body) {
8796
+ if (this.#closed) throw new HTTPTransportError("HTTP transport is closed");
8797
+ const controller = new AbortController();
8798
+ const timer = setTimeout(() => controller.abort(), this.config.timeoutMs);
8799
+ try {
8800
+ return await this.request(this.config.commandUrl, "POST", body, 0, controller.signal);
8801
+ } catch (error) {
8802
+ if (controller.signal.aborted) {
8803
+ throw new RequestTimeoutError(this.config.timeoutMs, "possibly_sent", {
8804
+ cause: error,
8805
+ raw: { retryable: true, safe_to_retry: false }
8806
+ });
8807
+ }
8808
+ if (error instanceof HTTPTransportError || error instanceof RequestTimeoutError) throw error;
8809
+ throw new HTTPTransportError("HTTP command request failed", {
8810
+ cause: error,
8811
+ retryable: true,
8812
+ safeToRetry: false
8813
+ });
8814
+ } finally {
8815
+ clearTimeout(timer);
8816
+ }
8817
+ }
8818
+ async close() {
8819
+ if (this.#closed) return;
8820
+ this.#closed = true;
8821
+ this.#httpAgent.destroy();
8822
+ this.#httpsAgent.destroy();
8823
+ for (const session of this.#sessions.values()) session.destroy();
8824
+ this.#sessions.clear();
8825
+ }
8826
+ async request(url, method, body, redirects, signal) {
8827
+ const response = this.config.http2 ? await this.http2Request(url, method, body, signal) : await this.http1Request(url, method, body, signal);
8828
+ if (![301, 302, 303, 307, 308].includes(response.status)) return response;
8829
+ if (redirects >= this.config.maxRedirects) throw new HTTPTransportError("too many HTTP redirects");
8830
+ const location = response.headers.location;
8831
+ if (location == null || location === "") throw new HTTPTransportError("HTTP redirect has no location");
8832
+ const target = new URL(location, url);
8833
+ if (target.protocol !== "http:" && target.protocol !== "https:") {
8834
+ throw new HTTPTransportError("HTTP redirect has an unsupported scheme");
8835
+ }
8836
+ const switchToGet = [301, 302, 303].includes(response.status);
8837
+ return await this.request(
8838
+ target,
8839
+ switchToGet ? "GET" : method,
8840
+ switchToGet ? void 0 : body,
8841
+ redirects + 1,
8842
+ signal
8843
+ );
8844
+ }
8845
+ async http1Request(url, method, body, signal) {
8846
+ const request = url.protocol === "https:" ? https.request : http.request;
8847
+ const agent = url.protocol === "https:" ? this.#httpsAgent : this.#httpAgent;
8848
+ const headers = this.requestHeaders(body);
8849
+ return await new Promise((resolve, reject) => {
8850
+ const outgoing = request(url, { agent, headers, method, signal }, (response) => {
8851
+ void this.collectHttp1(response).then(resolve, reject);
8852
+ });
8853
+ outgoing.once("error", reject);
8854
+ outgoing.end(body);
8855
+ });
8856
+ }
8857
+ async collectHttp1(response) {
8858
+ const declared = headerValue(response.headers["content-length"]);
8859
+ if (declared != null && Number(declared) > this.config.maxResponseBytes) {
8860
+ response.destroy();
8861
+ throw new HTTPTransportError("HTTP response exceeds maxResponseBytes");
8862
+ }
8863
+ return await collectBody(
8864
+ response,
8865
+ response.statusCode ?? 0,
8866
+ normalizeHeaders(response.headers),
8867
+ this.config.maxResponseBytes
8868
+ );
8869
+ }
8870
+ async http2Request(url, method, body, signal) {
8871
+ const session = this.session(url);
8872
+ const headers = {
8873
+ ...this.requestHeaders(body),
8874
+ ":authority": url.host,
8875
+ ":method": method,
8876
+ ":path": `${url.pathname}${url.search}`,
8877
+ ":scheme": url.protocol.slice(0, -1)
8878
+ };
8879
+ return await new Promise((resolve, reject) => {
8880
+ const stream = session.request(headers);
8881
+ let responseHeaders = {};
8882
+ const abort = () => stream.close(http2.constants.NGHTTP2_CANCEL);
8883
+ signal.addEventListener("abort", abort, { once: true });
8884
+ stream.once("response", (value) => responseHeaders = value);
8885
+ stream.once("error", reject);
8886
+ void collectBody(stream, 0, {}, this.config.maxResponseBytes).then((response) => {
8887
+ const status = Number(responseHeaders[":status"] ?? 0);
8888
+ resolve({ body: response.body, headers: normalizeHeaders(responseHeaders), status });
8889
+ }, reject).finally(() => signal.removeEventListener("abort", abort));
8890
+ stream.end(body);
8891
+ });
8892
+ }
8893
+ session(url) {
8894
+ const origin = url.origin;
8895
+ const current = this.#sessions.get(origin);
8896
+ if (current != null && !current.closed && !current.destroyed) return current;
8897
+ const session = http2.connect(origin, this.config.tlsOptions);
8898
+ session.on("error", () => void 0);
8899
+ session.once("close", () => this.#sessions.delete(origin));
8900
+ this.#sessions.set(origin, session);
8901
+ return session;
8902
+ }
8903
+ requestHeaders(body) {
8904
+ const headers = { ...this.config.headers };
8905
+ delete headers["content-length"];
8906
+ delete headers["content-type"];
8907
+ return {
8908
+ ...headers,
8909
+ accept: "application/json",
8910
+ ...body == null ? {} : { "content-length": body.byteLength, "content-type": "application/json" }
8911
+ };
8912
+ }
8913
+ };
8914
+ async function collectBody(source, status, headers, maximum) {
8915
+ const chunks = [];
8916
+ let size = 0;
8917
+ for await (const chunk of source) {
8918
+ const bytes2 = Buffer34.from(chunk);
8919
+ size += bytes2.byteLength;
8920
+ if (size > maximum) {
8921
+ const destroy = source.destroy;
8922
+ if (destroy != null) destroy.call(source);
8923
+ throw new HTTPTransportError("HTTP response exceeds maxResponseBytes");
8924
+ }
8925
+ chunks.push(bytes2);
8926
+ }
8927
+ return { body: Buffer34.concat(chunks, size), headers, status };
8928
+ }
8929
+ function normalizeHeaders(headers) {
8930
+ const result = {};
8931
+ for (const [name, raw] of Object.entries(headers)) {
8932
+ const value = headerValue(raw);
8933
+ if (value != null) result[name.toLowerCase()] = value;
8934
+ }
8935
+ return result;
8936
+ }
8937
+ function headerValue(value) {
8938
+ if (Array.isArray(value)) return value.join(", ");
8939
+ return value == null ? void 0 : String(value);
8940
+ }
8941
+
8942
+ // src/http-adapter.ts
8943
+ var HTTPAdapter = class _HTTPAdapter {
8944
+ #config;
8945
+ #transport;
8946
+ static async fromUrl(url, options = {}) {
8947
+ return new _HTTPAdapter(normalizeHTTPOptions(url, options));
8948
+ }
8949
+ constructor(config) {
8950
+ this.#config = config;
8951
+ this.#transport = new HTTPTransport(config);
8952
+ }
8953
+ async executeCommand(...args) {
8954
+ return await this.executeCommandArgs(args);
8955
+ }
8956
+ async executeCommandArgs(args) {
8957
+ const [result] = await this.executeBatch([args]);
8958
+ if (result == null) throw new HTTPTransportError("HTTP response omitted a command result");
8959
+ if (result.status === "error") throw commandError(result.error);
8960
+ return result.value;
8961
+ }
8962
+ async executePipeline(commands, options = {}) {
8963
+ const results = await this.executeBatch(commands);
8964
+ const values = results.map((result) => result.status === "ok" ? result.value : commandError(result.error));
8965
+ if (options.throwOnItemError !== false) {
8966
+ const failure = values.find((value) => value instanceof Error);
8967
+ if (failure instanceof Error) throw failure;
8968
+ }
8969
+ return values;
8970
+ }
8971
+ async executeFusedPipeline(commands, options = {}) {
8972
+ return await this.executePipeline(commands, options);
8973
+ }
8974
+ async close() {
8975
+ await this.#transport.close();
8976
+ }
8977
+ async executeBatch(commands) {
8978
+ if (commands.length > this.#config.maxBatchItems) {
8979
+ throw new HTTPTransportError("HTTP command batch exceeds maxBatchItems");
8980
+ }
8981
+ for (const command of commands) assertHTTPCommandSupported(command[0]);
8982
+ const body = encodeHTTPCommands(commands.map((command) => httpCommand(command, this.#config.maxRequestBytes)));
8983
+ if (body.byteLength > this.#config.maxRequestBytes) {
8984
+ throw new HTTPTransportError("HTTP command request exceeds maxRequestBytes");
8985
+ }
8986
+ const response = await this.#transport.post(body);
8987
+ let envelope = {};
8988
+ try {
8989
+ if (response.body.byteLength > 0) envelope = decodeHTTPEnvelope(response.body);
8990
+ } catch (error) {
8991
+ if (response.status >= 200 && response.status < 300) throw error;
8992
+ }
8993
+ if (response.status < 200 || response.status >= 300) throw topLevelError(
8994
+ response.status,
8995
+ envelope,
8996
+ response.headers["retry-after"]
8997
+ );
8998
+ if (envelope.encoding !== "ferricstore-json-v1") {
8999
+ throw new HTTPTransportError("HTTP response has an unsupported encoding");
9000
+ }
9001
+ if (!Array.isArray(envelope.results) || envelope.results.length !== commands.length) {
9002
+ throw new HTTPTransportError("HTTP response result count does not match the command batch");
9003
+ }
9004
+ return envelope.results.map((result) => validatedResult(result));
9005
+ }
9006
+ };
9007
+ var commandNamesByOpcode = new Map(
9008
+ Object.entries(COMMAND_OPCODES).map(([name, opcode]) => [opcode, name])
9009
+ );
9010
+ function httpCommand(command, maxRequestBytes) {
9011
+ const protocol = buildProtocolCommand(command, maxRequestBytes, false);
9012
+ if (protocol.opcode === OPCODES.commandExec) return command;
9013
+ const name = commandNamesByOpcode.get(protocol.opcode);
9014
+ if (name == null) throw new HTTPTransportError(`HTTP command has unknown opcode ${protocol.opcode}`);
9015
+ return { command: name, opcode: protocol.opcode, payload: protocol.payload ?? {} };
9016
+ }
9017
+ function validatedResult(value) {
9018
+ if (!isRecord2(value)) throw new HTTPTransportError("HTTP response has an invalid result item");
9019
+ if (value.status === "ok" && Object.hasOwn(value, "value")) {
9020
+ return { status: "ok", value: value.value };
9021
+ }
9022
+ if (value.status === "error" && isRecord2(value.error)) {
9023
+ return { error: value.error, status: "error" };
9024
+ }
9025
+ throw new HTTPTransportError("HTTP response has an invalid result item");
9026
+ }
9027
+ function commandError(value) {
9028
+ const message = isRecord2(value) && typeof value.message === "string" ? value.message : "FerricStore command failed";
9029
+ const code = isRecord2(value) && typeof value.code === "string" ? value.code : void 0;
9030
+ return classifyServerError(message, value, void 0, code);
9031
+ }
9032
+ function topLevelError(status, envelope, retryAfter) {
9033
+ const details = isRecord2(envelope.error) ? envelope.error : {};
9034
+ const message = typeof details.message === "string" ? details.message : `HTTP command request failed with status ${status}`;
9035
+ const retryAfterMs2 = retryAfter == null || !/^\d+$/u.test(retryAfter) ? void 0 : Number(retryAfter) * 1e3;
9036
+ return new HTTPTransportError(message, {
9037
+ raw: details,
9038
+ retryable: status === 408 || status === 425 || status === 429 || status >= 500,
9039
+ retryAfterMs: retryAfterMs2,
9040
+ safeToRetry: false,
9041
+ statusCode: status
9042
+ });
9043
+ }
9044
+ function isRecord2(value) {
9045
+ return typeof value === "object" && value != null && !Array.isArray(value);
9046
+ }
9047
+
8549
9048
  // src/adapters.ts
8550
9049
  function executeCommandArgs(executor, args) {
8551
9050
  if (executor.executeCommandArgs != null) return executor.executeCommandArgs(args);
@@ -8557,7 +9056,7 @@ function executeCommandArgs(executor, args) {
8557
9056
  import "buffer";
8558
9057
 
8559
9058
  // src/command-retry-policy.ts
8560
- import { Buffer as Buffer33 } from "buffer";
9059
+ import { Buffer as Buffer35 } from "buffer";
8561
9060
  function isCasMutation(args) {
8562
9061
  const offset = commandName2(args[0]) === "COMMAND_EXEC" ? 1 : 0;
8563
9062
  const name = commandName2(args[offset]);
@@ -8571,8 +9070,8 @@ function isCasMutation(args) {
8571
9070
  }
8572
9071
  function commandName2(value) {
8573
9072
  if (typeof value === "string") return value.toUpperCase();
8574
- if (Buffer33.isBuffer(value) || value instanceof Uint8Array) {
8575
- return Buffer33.from(value).toString("utf8").toUpperCase();
9073
+ if (Buffer35.isBuffer(value) || value instanceof Uint8Array) {
9074
+ return Buffer35.from(value).toString("utf8").toUpperCase();
8576
9075
  }
8577
9076
  return void 0;
8578
9077
  }
@@ -8787,12 +9286,12 @@ function normalizeNonNegativeInteger2(value, fallback) {
8787
9286
  import "buffer";
8788
9287
 
8789
9288
  // src/topology-routing.ts
8790
- import { Buffer as Buffer36 } from "buffer";
9289
+ import { Buffer as Buffer38 } from "buffer";
8791
9290
 
8792
9291
  // src/flow-partition-route-cache.ts
8793
- import { Buffer as Buffer35 } from "buffer";
9292
+ import { Buffer as Buffer37 } from "buffer";
8794
9293
  import { createHash } from "crypto";
8795
- var AUTO_PREFIX = Buffer35.from("__flow_auto__:", "ascii");
9294
+ var AUTO_PREFIX = Buffer37.from("__flow_auto__:", "ascii");
8796
9295
  var MAX_CACHEABLE_PARTITION_BYTES = 4 * 1024;
8797
9296
  var MAX_CACHE_BYTES = 1 * 1024 * 1024;
8798
9297
  var MAX_CACHE_ENTRIES = 1024;
@@ -8802,10 +9301,10 @@ var cacheBytes = 0;
8802
9301
  var cacheHits = 0;
8803
9302
  var cacheMisses = 0;
8804
9303
  function flowLogicalPartitionRoutingKey(value) {
8805
- if (typeof value !== "string" && !Buffer35.isBuffer(value)) return void 0;
9304
+ if (typeof value !== "string" && !Buffer37.isBuffer(value)) return void 0;
8806
9305
  const autoBucket = flowAutoBucket(value);
8807
9306
  if (autoBucket != null) return `{fa:${autoBucket}}`;
8808
- const bytes2 = Buffer35.isBuffer(value) ? value : Buffer35.from(value);
9307
+ const bytes2 = Buffer37.isBuffer(value) ? value : Buffer37.from(value);
8809
9308
  if (bytes2.byteLength > MAX_CACHEABLE_PARTITION_BYTES) return hashRoute(bytes2);
8810
9309
  const cacheKey = bytes2.toString("base64");
8811
9310
  const cached = routeCache.get(cacheKey);
@@ -8879,7 +9378,7 @@ function routingKeyFromProtocolPayload(name, command) {
8879
9378
  "scope"
8880
9379
  ]) {
8881
9380
  const value = getField(command.payload, field3);
8882
- if (typeof value === "string" || Buffer36.isBuffer(value)) {
9381
+ if (typeof value === "string" || Buffer38.isBuffer(value)) {
8883
9382
  return value;
8884
9383
  }
8885
9384
  }
@@ -8927,7 +9426,7 @@ function flowRoutingData(name, args) {
8927
9426
  if (typeof partition === "string" && partition.toUpperCase() !== "AUTO" && partition.toUpperCase() !== "MIXED") {
8928
9427
  return flowRoutingResult(flowLogicalPartitionRoutingKey(partition));
8929
9428
  }
8930
- if (Buffer36.isBuffer(partition)) {
9429
+ if (Buffer38.isBuffer(partition)) {
8931
9430
  const text3 = partition.toString("utf8").toUpperCase();
8932
9431
  if (text3 !== "AUTO" && text3 !== "MIXED") {
8933
9432
  return flowRoutingResult(flowLogicalPartitionRoutingKey(partition));
@@ -9018,17 +9517,17 @@ function flowPartitionRoutingKeyFromCommand(command, claim) {
9018
9517
  return { handled: false };
9019
9518
  }
9020
9519
  function isRoutingKey(value) {
9021
- return typeof value === "string" || Buffer36.isBuffer(value);
9520
+ return typeof value === "string" || Buffer38.isBuffer(value);
9022
9521
  }
9023
9522
  function flowAutoIdRoutingKey(value) {
9024
- if (typeof value !== "string" && !Buffer36.isBuffer(value)) {
9523
+ if (typeof value !== "string" && !Buffer38.isBuffer(value)) {
9025
9524
  return void 0;
9026
9525
  }
9027
- const bucket = (Buffer36.isBuffer(value) ? crc32(value) : crc32Utf8(value)) & 255;
9526
+ const bucket = (Buffer38.isBuffer(value) ? crc32(value) : crc32Utf8(value)) & 255;
9028
9527
  return `{fa:${bucket}}`;
9029
9528
  }
9030
9529
  function flowClaimLogicalPartitionRoutingKey(value) {
9031
- if (typeof value !== "string" && !Buffer36.isBuffer(value)) return void 0;
9530
+ if (typeof value !== "string" && !Buffer38.isBuffer(value)) return void 0;
9032
9531
  const selector = commandPart(value);
9033
9532
  if (selector === "AUTO" || selector === "ANY") return void 0;
9034
9533
  if (selector === "GLOBAL") return "{f}";
@@ -9043,7 +9542,7 @@ function singleShardFlowClaimPartitionKey(values) {
9043
9542
  return keys.some((key) => key == null) ? void 0 : singleShardKey(keys);
9044
9543
  }
9045
9544
  function singleShardKey(keys) {
9046
- if (keys.length === 0 || keys.some((key) => typeof key !== "string" && !Buffer36.isBuffer(key))) {
9545
+ if (keys.length === 0 || keys.some((key) => typeof key !== "string" && !Buffer38.isBuffer(key))) {
9047
9546
  return void 0;
9048
9547
  }
9049
9548
  const usable = keys;
@@ -9076,7 +9575,7 @@ function routedKeyGroups(keys, routeKey) {
9076
9575
  const groups = /* @__PURE__ */ new Map();
9077
9576
  for (let index = 0; index < keys.length; index += 1) {
9078
9577
  const key = keys[index];
9079
- if (typeof key !== "string" && !Buffer36.isBuffer(key)) return void 0;
9578
+ if (typeof key !== "string" && !Buffer38.isBuffer(key)) return void 0;
9080
9579
  const route = routeKey(key);
9081
9580
  const groupKey = `${route.endpointKey}\0${route.laneId}`;
9082
9581
  const group = groups.get(groupKey);
@@ -10165,7 +10664,7 @@ var TopologyNativeAdapterPool = class _TopologyNativeAdapterPool {
10165
10664
  };
10166
10665
 
10167
10666
  // src/response-map-preservation.ts
10168
- import { Buffer as Buffer38 } from "buffer";
10667
+ import { Buffer as Buffer40 } from "buffer";
10169
10668
  function toStringKeyMapPreservingValues(value) {
10170
10669
  if (value == null) return void 0;
10171
10670
  const result = {};
@@ -10175,7 +10674,7 @@ function toStringKeyMapPreservingValues(value) {
10175
10674
  }
10176
10675
  return result;
10177
10676
  }
10178
- if (typeof value === "object" && !Array.isArray(value) && !Buffer38.isBuffer(value) && !(value instanceof Uint8Array)) {
10677
+ if (typeof value === "object" && !Array.isArray(value) && !Buffer40.isBuffer(value) && !(value instanceof Uint8Array)) {
10179
10678
  for (const [key, item] of Object.entries(value)) {
10180
10679
  setOwnValue(result, text(key), normalizeMapStructurePreservingBytes(item));
10181
10680
  }
@@ -10184,7 +10683,7 @@ function toStringKeyMapPreservingValues(value) {
10184
10683
  return void 0;
10185
10684
  }
10186
10685
  function normalizeMapStructurePreservingBytes(value) {
10187
- if (Buffer38.isBuffer(value) || value instanceof Uint8Array) return value;
10686
+ if (Buffer40.isBuffer(value) || value instanceof Uint8Array) return value;
10188
10687
  if (value instanceof Map) {
10189
10688
  const result = {};
10190
10689
  for (const [key, item] of value.entries()) {
@@ -10206,7 +10705,7 @@ function normalizeMapStructurePreservingBytes(value) {
10206
10705
  }
10207
10706
 
10208
10707
  // src/native-kv-responses.ts
10209
- import { Buffer as Buffer39 } from "buffer";
10708
+ import { Buffer as Buffer41 } from "buffer";
10210
10709
  function rateLimitResultFromResp(value) {
10211
10710
  if (!Array.isArray(value) || value.length !== 4) {
10212
10711
  throw new TypeError("RATELIMIT.ADD returned an unexpected response");
@@ -10263,13 +10762,13 @@ function fetchOrComputeResultFromResp(value, codec) {
10263
10762
  }
10264
10763
  function decodePayload(codec, value) {
10265
10764
  if (value == null) return null;
10266
- if (Buffer39.isBuffer(value)) return codec.decode(value);
10267
- if (value instanceof Uint8Array) return codec.decode(Buffer39.from(value));
10268
- if (typeof value === "string") return codec.decode(Buffer39.from(value));
10765
+ if (Buffer41.isBuffer(value)) return codec.decode(value);
10766
+ if (value instanceof Uint8Array) return codec.decode(Buffer41.from(value));
10767
+ if (typeof value === "string") return codec.decode(Buffer41.from(value));
10269
10768
  return normalizeRefMeta(value);
10270
10769
  }
10271
10770
  function requiredResponseString(value, context) {
10272
- if (typeof value !== "string" && !Buffer39.isBuffer(value) && !(value instanceof Uint8Array)) {
10771
+ if (typeof value !== "string" && !Buffer41.isBuffer(value) && !(value instanceof Uint8Array)) {
10273
10772
  throw new TypeError(`${context} returned an unexpected response`);
10274
10773
  }
10275
10774
  const result = text(value);
@@ -10286,7 +10785,7 @@ function requiredNonNegativeInteger(value, context) {
10286
10785
  return result;
10287
10786
  }
10288
10787
  function responseBytes(value, context) {
10289
- if (typeof value !== "string" && !Buffer39.isBuffer(value) && !(value instanceof Uint8Array)) {
10788
+ if (typeof value !== "string" && !Buffer41.isBuffer(value) && !(value instanceof Uint8Array)) {
10290
10789
  throw new TypeError(`${context} returned an unexpected response`);
10291
10790
  }
10292
10791
  return bytes(value);
@@ -10969,7 +11468,7 @@ function groupAutoPartitionItems(items) {
10969
11468
  }
10970
11469
 
10971
11470
  // src/client-values.ts
10972
- import { Buffer as Buffer40 } from "buffer";
11471
+ import { Buffer as Buffer42 } from "buffer";
10973
11472
  async function valueMGetEntries(client, refs, options = {}) {
10974
11473
  const refCount = refs.length;
10975
11474
  if (refCount === 0) {
@@ -11004,12 +11503,12 @@ async function valueMGetEntries(client, refs, options = {}) {
11004
11503
  const item = response[index];
11005
11504
  if (item == null) {
11006
11505
  entries[index] = { found: false };
11007
- } else if (Buffer40.isBuffer(item)) {
11506
+ } else if (Buffer42.isBuffer(item)) {
11008
11507
  entries[index] = { found: true, value: client.codec.decode(item) };
11009
11508
  } else if (item instanceof Uint8Array) {
11010
- entries[index] = { found: true, value: client.codec.decode(Buffer40.from(item)) };
11509
+ entries[index] = { found: true, value: client.codec.decode(Buffer42.from(item)) };
11011
11510
  } else if (typeof item === "string") {
11012
- entries[index] = { found: true, value: client.codec.decode(Buffer40.from(item)) };
11511
+ entries[index] = { found: true, value: client.codec.decode(Buffer42.from(item)) };
11013
11512
  } else {
11014
11513
  entries[index] = { found: true, value: item };
11015
11514
  }
@@ -11021,7 +11520,7 @@ async function valueMGetEntries(client, refs, options = {}) {
11021
11520
  import "buffer";
11022
11521
 
11023
11522
  // src/auto-batch-ordering.ts
11024
- import { Buffer as Buffer41 } from "buffer";
11523
+ import { Buffer as Buffer43 } from "buffer";
11025
11524
  function autoBatchOrderingPlan(batch) {
11026
11525
  const accesses = /* @__PURE__ */ new Map();
11027
11526
  const fallbackDependencies = [];
@@ -11136,13 +11635,13 @@ function flowManyAutoBatchIds(command, name) {
11136
11635
  return fixedFlowItemIds(
11137
11636
  command,
11138
11637
  mixed ? 4 : 3,
11139
- (itemIndex) => isAutoBatchResourceValue(command[itemIndex]) && (!mixed || isAutoBatchResourceValue(command[itemIndex + 1])) && isFencingToken(command[itemIndex + (mixed ? 2 : 1)]) && Buffer41.isBuffer(command[itemIndex + (mixed ? 3 : 2)])
11638
+ (itemIndex) => isAutoBatchResourceValue(command[itemIndex]) && (!mixed || isAutoBatchResourceValue(command[itemIndex + 1])) && isFencingToken(command[itemIndex + (mixed ? 2 : 1)]) && Buffer43.isBuffer(command[itemIndex + (mixed ? 3 : 2)])
11140
11639
  );
11141
11640
  }
11142
11641
  return fixedFlowItemIds(
11143
11642
  command,
11144
11643
  mixed ? 4 : 3,
11145
- (itemIndex) => isAutoBatchResourceValue(command[itemIndex]) && (!mixed || isAutoBatchResourceValue(command[itemIndex + 1])) && Buffer41.isBuffer(command[itemIndex + (mixed ? 2 : 1)]) && isFencingToken(command[itemIndex + (mixed ? 3 : 2)])
11644
+ (itemIndex) => isAutoBatchResourceValue(command[itemIndex]) && (!mixed || isAutoBatchResourceValue(command[itemIndex + 1])) && Buffer43.isBuffer(command[itemIndex + (mixed ? 2 : 1)]) && isFencingToken(command[itemIndex + (mixed ? 3 : 2)])
11146
11645
  );
11147
11646
  }
11148
11647
  function createManyAutoBatchIds(command) {
@@ -11155,7 +11654,7 @@ function createManyAutoBatchIds(command) {
11155
11654
  const ids = fixedFlowItemIds(
11156
11655
  command,
11157
11656
  width,
11158
- (itemIndex) => isAutoBatchResourceValue(command[itemIndex]) && (!mixed || isAutoBatchResourceValue(command[itemIndex + 1])) && Buffer41.isBuffer(command[itemIndex + width - 1]),
11657
+ (itemIndex) => isAutoBatchResourceValue(command[itemIndex]) && (!mixed || isAutoBatchResourceValue(command[itemIndex + 1])) && Buffer43.isBuffer(command[itemIndex + width - 1]),
11159
11658
  markerIndex
11160
11659
  );
11161
11660
  if (ids != null) return ids;
@@ -11173,7 +11672,7 @@ function extendedCreateManyAutoBatchIds(command, markerIndex) {
11173
11672
  let cursor = markerIndex + 2;
11174
11673
  for (let itemIndex = 0; itemIndex < itemCount; itemIndex += 1) {
11175
11674
  const id = command[cursor];
11176
- if (!isAutoBatchResourceValue(id) || !isAutoBatchResourceValue(command[cursor + 1]) || !Buffer41.isBuffer(command[cursor + 2])) return void 0;
11675
+ if (!isAutoBatchResourceValue(id) || !isAutoBatchResourceValue(command[cursor + 1]) || !Buffer43.isBuffer(command[cursor + 2])) return void 0;
11177
11676
  ids.push(id);
11178
11677
  cursor += 3;
11179
11678
  const afterValues = skipExtendedNamedItems(command, cursor, true);
@@ -11192,7 +11691,7 @@ function skipExtendedNamedItems(command, countIndex, encodedValues) {
11192
11691
  for (let index = 0; index < count; index += 1) {
11193
11692
  const name = command[firstItem + index * 2];
11194
11693
  const value = command[firstItem + index * 2 + 1];
11195
- if (!isAutoBatchResourceValue(name) || (encodedValues ? !Buffer41.isBuffer(value) : !isAutoBatchResourceValue(value))) return void 0;
11694
+ if (!isAutoBatchResourceValue(name) || (encodedValues ? !Buffer43.isBuffer(value) : !isAutoBatchResourceValue(value))) return void 0;
11196
11695
  }
11197
11696
  return firstItem + count * 2;
11198
11697
  }
@@ -11207,7 +11706,7 @@ function runStepsManyAutoBatchIds(command) {
11207
11706
  ids.push(item);
11208
11707
  continue;
11209
11708
  }
11210
- if (typeof item !== "object" || item == null || Array.isArray(item) || Buffer41.isBuffer(item)) return void 0;
11709
+ if (typeof item !== "object" || item == null || Array.isArray(item) || Buffer43.isBuffer(item)) return void 0;
11211
11710
  const id = item.id;
11212
11711
  if (!isAutoBatchResourceValue(id)) return void 0;
11213
11712
  ids.push(id);
@@ -11248,7 +11747,7 @@ function flowValuePutOwner(command, start) {
11248
11747
  }
11249
11748
  var flowValuePutOptionTokens = /* @__PURE__ */ new Set(["NAME", "NOW", "OVERRIDE", "OWNER_FLOW_ID", "PARTITION", "TTL", "TTL_MS"]);
11250
11749
  function isAutoBatchResourceValue(value) {
11251
- return typeof value === "string" || Buffer41.isBuffer(value);
11750
+ return typeof value === "string" || Buffer43.isBuffer(value);
11252
11751
  }
11253
11752
  function isFencingToken(value) {
11254
11753
  return typeof value === "number" && Number.isSafeInteger(value) || typeof value === "bigint";
@@ -11257,7 +11756,7 @@ function nonNegativeItemCount(value) {
11257
11756
  return typeof value === "number" && Number.isSafeInteger(value) && value >= 0 ? value : void 0;
11258
11757
  }
11259
11758
  function autoBatchResourceKey(namespace, value) {
11260
- return `${namespace}:${Buffer41.from(value).toString("base64")}`;
11759
+ return `${namespace}:${Buffer43.from(value).toString("base64")}`;
11261
11760
  }
11262
11761
  function autoBatchCommandName(command) {
11263
11762
  return commandView(command).name ?? null;
@@ -11669,10 +12168,10 @@ function claimFailure(error) {
11669
12168
  import "buffer";
11670
12169
 
11671
12170
  // src/flow-query-builder.ts
11672
- import { Buffer as Buffer44 } from "buffer";
12171
+ import { Buffer as Buffer46 } from "buffer";
11673
12172
 
11674
12173
  // src/flow-query-metadata.ts
11675
- import { Buffer as Buffer43 } from "buffer";
12174
+ import { Buffer as Buffer45 } from "buffer";
11676
12175
  var MAX_FLOW_QUERY_METADATA_KEY_BYTES = 64;
11677
12176
  function normalizeStateMeta(value, state) {
11678
12177
  if (value == null) return {};
@@ -11697,7 +12196,7 @@ function normalizeStateMeta(value, state) {
11697
12196
  function metadataEntries(value, context) {
11698
12197
  const entries = objectEntries(value ?? {}, context).map(([rawName, item]) => {
11699
12198
  const name = rawName.trim();
11700
- const size = Buffer43.byteLength(name, "utf8");
12199
+ const size = Buffer45.byteLength(name, "utf8");
11701
12200
  if (size === 0 || size > MAX_FLOW_QUERY_METADATA_KEY_BYTES || name.startsWith("__")) {
11702
12201
  throw new TypeError(`${context} key is invalid or reserved`);
11703
12202
  }
@@ -11721,7 +12220,7 @@ function objectEntries(value, context) {
11721
12220
  return keys.map((key) => [key, value[key]]);
11722
12221
  }
11723
12222
  function isPlainRecord(value) {
11724
- if (typeof value !== "object" || value == null || Array.isArray(value) || Buffer43.isBuffer(value)) {
12223
+ if (typeof value !== "object" || value == null || Array.isArray(value) || Buffer45.isBuffer(value)) {
11725
12224
  return false;
11726
12225
  }
11727
12226
  const prototype = Object.getPrototypeOf(value);
@@ -11791,7 +12290,7 @@ var FlowCollectionQuery = class {
11791
12290
  const states = /* @__PURE__ */ new Set();
11792
12291
  for (const [rawState, metadata] of objectEntries(values, "stateMeta")) {
11793
12292
  const state = requiredText(rawState, "stateMeta state").trim();
11794
- const stateBytes = Buffer44.byteLength(state, "utf8");
12293
+ const stateBytes = Buffer46.byteLength(state, "utf8");
11795
12294
  if (stateBytes === 0 || stateBytes > MAX_FLOW_QUERY_STATE_BYTES) {
11796
12295
  throw new TypeError(
11797
12296
  `stateMeta state names must be 1..${MAX_FLOW_QUERY_STATE_BYTES} bytes`
@@ -11970,7 +12469,7 @@ function requiredPartition(value) {
11970
12469
  "FLOW.QUERY convenience methods require a partition key"
11971
12470
  );
11972
12471
  }
11973
- const size = Buffer44.byteLength(value, "utf8");
12472
+ const size = Buffer46.byteLength(value, "utf8");
11974
12473
  if (size === 0 || size > MAX_FLOW_QUERY_PARTITION_BYTES) {
11975
12474
  throw new TypeError(
11976
12475
  `FLOW.QUERY partition key must be 1..${MAX_FLOW_QUERY_PARTITION_BYTES} bytes`
@@ -12018,23 +12517,23 @@ function requiredText(value, context) {
12018
12517
  return value;
12019
12518
  }
12020
12519
  function queryParameter(value, context) {
12021
- if (typeof value === "string" || typeof value === "boolean" || typeof value === "bigint" || typeof value === "number" || Buffer44.isBuffer(value)) {
12520
+ if (typeof value === "string" || typeof value === "boolean" || typeof value === "bigint" || typeof value === "number" || Buffer46.isBuffer(value)) {
12022
12521
  return value;
12023
12522
  }
12024
12523
  throw new TypeError(`${context} must be a scalar FLOW.QUERY parameter`);
12025
12524
  }
12026
12525
 
12027
12526
  // src/flow-query-response.ts
12028
- import { Buffer as Buffer48 } from "buffer";
12527
+ import { Buffer as Buffer50 } from "buffer";
12029
12528
 
12030
12529
  // src/flow-query-diagnostic-response.ts
12031
- import { Buffer as Buffer46 } from "buffer";
12530
+ import { Buffer as Buffer48 } from "buffer";
12032
12531
 
12033
12532
  // src/flow-query-response-validation.ts
12034
- import { Buffer as Buffer45 } from "buffer";
12533
+ import { Buffer as Buffer47 } from "buffer";
12035
12534
  function requiredMap2(value, context) {
12036
12535
  if (value instanceof Map) return value;
12037
- if (typeof value !== "object" || value == null || Array.isArray(value) || Buffer45.isBuffer(value) || value instanceof Uint8Array) {
12536
+ if (typeof value !== "object" || value == null || Array.isArray(value) || Buffer47.isBuffer(value) || value instanceof Uint8Array) {
12038
12537
  throw decodeError(`${context} must be a map`, value);
12039
12538
  }
12040
12539
  return value;
@@ -12091,7 +12590,7 @@ function normalizeMetadataValue(value, context, budget, ancestors, depth) {
12091
12590
  if (!value.isWellFormed()) throw decodeError(`${context} contains invalid text`, value);
12092
12591
  return value;
12093
12592
  }
12094
- if (Buffer45.isBuffer(value) || value instanceof Uint8Array) {
12593
+ if (Buffer47.isBuffer(value) || value instanceof Uint8Array) {
12095
12594
  const decoded = strictText2(value);
12096
12595
  if (decoded == null) throw decodeError(`${context} contains invalid UTF-8`, value);
12097
12596
  return decoded;
@@ -12170,7 +12669,7 @@ function optionalText2(mapping2, name, context) {
12170
12669
  }
12171
12670
  function requiredBoundedText2(mapping2, name, context, maximumBytes) {
12172
12671
  const value = requiredText2(mapping2, name, context);
12173
- if (Buffer45.byteLength(value, "utf8") > maximumBytes) {
12672
+ if (Buffer47.byteLength(value, "utf8") > maximumBytes) {
12174
12673
  throw decodeError(
12175
12674
  `${context} ${name} exceeds ${maximumBytes} bytes`,
12176
12675
  mapping2
@@ -12183,7 +12682,7 @@ function boundedText(value, context, maximumBytes) {
12183
12682
  if (decoded == null || decoded.length === 0) {
12184
12683
  throw decodeError(`${context} must be non-empty text`, value);
12185
12684
  }
12186
- if (Buffer45.byteLength(decoded, "utf8") > maximumBytes) {
12685
+ if (Buffer47.byteLength(decoded, "utf8") > maximumBytes) {
12187
12686
  throw decodeError(`${context} exceeds ${maximumBytes} bytes`, value);
12188
12687
  }
12189
12688
  return decoded;
@@ -12195,7 +12694,7 @@ function requiredBoolean(mapping2, name, context) {
12195
12694
  }
12196
12695
  return value;
12197
12696
  }
12198
- function nonNegativeInteger(value, context) {
12697
+ function nonNegativeInteger2(value, context) {
12199
12698
  if (typeof value === "bigint") {
12200
12699
  if (value >= 0n && value <= BigInt(Number.MAX_SAFE_INTEGER))
12201
12700
  return Number(value);
@@ -12204,8 +12703,8 @@ function nonNegativeInteger(value, context) {
12204
12703
  }
12205
12704
  throw decodeError(`${context} must be a non-negative safe integer`, value);
12206
12705
  }
12207
- function positiveInteger(value, context) {
12208
- const parsed = nonNegativeInteger(value, context);
12706
+ function positiveInteger2(value, context) {
12707
+ const parsed = nonNegativeInteger2(value, context);
12209
12708
  if (parsed === 0) throw decodeError(`${context} must be positive`, value);
12210
12709
  return parsed;
12211
12710
  }
@@ -12237,10 +12736,10 @@ function positiveBoundedInteger(value, maximum, context) {
12237
12736
  function hasKey(mapping2, name) {
12238
12737
  if (!(mapping2 instanceof Map)) return Object.hasOwn(mapping2, name);
12239
12738
  if (mapping2.has(name)) return true;
12240
- const binaryName = Buffer45.from(name);
12739
+ const binaryName = Buffer47.from(name);
12241
12740
  for (const key of mapping2.keys()) {
12242
- if (Buffer45.isBuffer(key) && key.equals(binaryName)) return true;
12243
- if (key instanceof Uint8Array && Buffer45.from(key).equals(binaryName))
12741
+ if (Buffer47.isBuffer(key) && key.equals(binaryName)) return true;
12742
+ if (key instanceof Uint8Array && Buffer47.from(key).equals(binaryName))
12244
12743
  return true;
12245
12744
  }
12246
12745
  return false;
@@ -12251,7 +12750,7 @@ function decodeError(message, raw) {
12251
12750
  function strictText2(value) {
12252
12751
  if (typeof value === "string")
12253
12752
  return value.isWellFormed() ? value : void 0;
12254
- if (Buffer45.isBuffer(value) || value instanceof Uint8Array) {
12753
+ if (Buffer47.isBuffer(value) || value instanceof Uint8Array) {
12255
12754
  try {
12256
12755
  return new TextDecoder("utf-8", { fatal: true }).decode(value);
12257
12756
  } catch {
@@ -12315,7 +12814,7 @@ function tryDecodeFlowQueryError(value, cause) {
12315
12814
  hint: optionalDiagnosticText(mapping2, "hint"),
12316
12815
  retryable: requiredBoolean(mapping2, "retryable", "FLOW.QUERY diagnostic"),
12317
12816
  safeToRetry: requiredBoolean(mapping2, "safe_to_retry", "FLOW.QUERY diagnostic"),
12318
- retryAfterMs: nonNegativeInteger(
12817
+ retryAfterMs: nonNegativeInteger2(
12319
12818
  field(mapping2, "retry_after_ms"),
12320
12819
  "FLOW.QUERY diagnostic retry_after_ms"
12321
12820
  ),
@@ -12331,7 +12830,7 @@ function tryDecodeFlowQueryError(value, cause) {
12331
12830
  }
12332
12831
  function optionalDiagnosticText(mapping2, name) {
12333
12832
  const value = optionalText2(mapping2, name, "FLOW.QUERY diagnostic");
12334
- if (value != null && Buffer46.byteLength(value, "utf8") > DIAGNOSTIC_TEXT_BYTES) {
12833
+ if (value != null && Buffer48.byteLength(value, "utf8") > DIAGNOSTIC_TEXT_BYTES) {
12335
12834
  throw decodeError(
12336
12835
  `FLOW.QUERY diagnostic ${name} exceeds ${DIAGNOSTIC_TEXT_BYTES} bytes`,
12337
12836
  mapping2
@@ -12366,7 +12865,7 @@ function validateDiagnosticContextValue(value, depth, budget) {
12366
12865
  }
12367
12866
  const text3 = diagnosticContextText(value);
12368
12867
  if (text3 != null) {
12369
- if (Buffer46.byteLength(text3, "utf8") <= DIAGNOSTIC_TEXT_BYTES) return;
12868
+ if (Buffer48.byteLength(text3, "utf8") <= DIAGNOSTIC_TEXT_BYTES) return;
12370
12869
  throw decodeError("FLOW.QUERY diagnostic context contains oversized text", value);
12371
12870
  }
12372
12871
  if (depth <= 0) {
@@ -12392,7 +12891,7 @@ function validateDiagnosticContextValue(value, depth, budget) {
12392
12891
  }
12393
12892
  for (const [rawKey, item] of entries) {
12394
12893
  const key = diagnosticContextText(rawKey);
12395
- if (key == null || key.length === 0 || Buffer46.byteLength(key, "utf8") > DIAGNOSTIC_CONTEXT_KEY_BYTES) {
12894
+ if (key == null || key.length === 0 || Buffer48.byteLength(key, "utf8") > DIAGNOSTIC_CONTEXT_KEY_BYTES) {
12396
12895
  throw decodeError("FLOW.QUERY diagnostic context contains an invalid key", value);
12397
12896
  }
12398
12897
  validateDiagnosticContextValue(item, depth - 1, budget);
@@ -12409,7 +12908,7 @@ function consumeDiagnosticContextNode(value, budget) {
12409
12908
  }
12410
12909
  function diagnosticContextText(value) {
12411
12910
  if (typeof value === "string") return value.isWellFormed() ? value : void 0;
12412
- if (!Buffer46.isBuffer(value) && !(value instanceof Uint8Array)) return void 0;
12911
+ if (!Buffer48.isBuffer(value) && !(value instanceof Uint8Array)) return void 0;
12413
12912
  try {
12414
12913
  return new TextDecoder("utf-8", { fatal: true }).decode(value);
12415
12914
  } catch {
@@ -12425,9 +12924,9 @@ function decodePosition(value) {
12425
12924
  if (value == null) return void 0;
12426
12925
  const mapping2 = requiredMap2(value, "FLOW.QUERY diagnostic position");
12427
12926
  return Object.freeze({
12428
- byte: positiveInteger(field(mapping2, "byte"), "FLOW.QUERY diagnostic position byte"),
12429
- line: positiveInteger(field(mapping2, "line"), "FLOW.QUERY diagnostic position line"),
12430
- column: positiveInteger(
12927
+ byte: positiveInteger2(field(mapping2, "byte"), "FLOW.QUERY diagnostic position byte"),
12928
+ line: positiveInteger2(field(mapping2, "line"), "FLOW.QUERY diagnostic position line"),
12929
+ column: positiveInteger2(
12431
12930
  field(mapping2, "column"),
12432
12931
  "FLOW.QUERY diagnostic position column"
12433
12932
  )
@@ -12435,7 +12934,7 @@ function decodePosition(value) {
12435
12934
  }
12436
12935
 
12437
12936
  // src/flow-query-index-contract.ts
12438
- import { Buffer as Buffer47 } from "buffer";
12937
+ import { Buffer as Buffer49 } from "buffer";
12439
12938
  var FLOW_QUERY_BUILD_PHASES = ["pending", "snapshot", "backfill", "done"];
12440
12939
  var FLOW_QUERY_VALIDATION_PHASES = [
12441
12940
  "pending",
@@ -12681,10 +13180,10 @@ function fieldKind(name) {
12681
13180
  return void 0;
12682
13181
  }
12683
13182
  function validUnquoted(value) {
12684
- return !value.startsWith("__") && UNQUOTED_METADATA.test(value) && Buffer47.byteLength(value, "ascii") <= 64;
13183
+ return !value.startsWith("__") && UNQUOTED_METADATA.test(value) && Buffer49.byteLength(value, "ascii") <= 64;
12685
13184
  }
12686
13185
  function validMetadata(value, rejectReserved) {
12687
- return value.length > 0 && Buffer47.byteLength(value, "utf8") <= 64 && (!rejectReserved || !value.startsWith("__"));
13186
+ return value.length > 0 && Buffer49.byteLength(value, "utf8") <= 64 && (!rejectReserved || !value.startsWith("__"));
12688
13187
  }
12689
13188
  function externalSelector(root, ...segments) {
12690
13189
  return segments.every(validUnquoted) ? [root, ...segments].join(".") : root + segments.map((segment) => `['${segment.replaceAll("'", "''")}']`).join("");
@@ -13194,7 +13693,7 @@ function decodeCountPrefixes(value, fieldCount) {
13194
13693
  if (!Object.hasOwn(value, index)) {
13195
13694
  throw decodeError(`${context} must be dense`, value);
13196
13695
  }
13197
- const prefix = positiveInteger(value[index], `${context} entry`);
13696
+ const prefix = positiveInteger2(value[index], `${context} entry`);
13198
13697
  if (prefix > fieldCount || prefix <= previous) {
13199
13698
  throw decodeError(`${context} are invalid`, value);
13200
13699
  }
@@ -13576,7 +14075,7 @@ function decodeUsage(value) {
13576
14075
  const mapping2 = requiredMap2(value, "FLOW.QUERY usage");
13577
14076
  const usage = /* @__PURE__ */ Object.create(null);
13578
14077
  for (const [wireName, property] of USAGE_FIELDS2) {
13579
- usage[property] = nonNegativeInteger(
14078
+ usage[property] = nonNegativeInteger2(
13580
14079
  field(mapping2, wireName),
13581
14080
  `FLOW.QUERY usage ${wireName}`
13582
14081
  );
@@ -13591,7 +14090,7 @@ function decodePage(value) {
13591
14090
  const mapping2 = requiredMap2(value, "FLOW.QUERY page");
13592
14091
  const hasMore = requiredBoolean(mapping2, "has_more", "FLOW.QUERY page");
13593
14092
  const cursor = optionalText2(mapping2, "cursor", "FLOW.QUERY page");
13594
- if (cursor != null && (!cursor.startsWith("fqc1_") || Buffer48.byteLength(cursor) < 16 || Buffer48.byteLength(cursor) > 4096)) {
14093
+ if (cursor != null && (!cursor.startsWith("fqc1_") || Buffer50.byteLength(cursor) < 16 || Buffer50.byteLength(cursor) > 4096)) {
13595
14094
  throw decodeError("FLOW.QUERY page cursor is invalid", value);
13596
14095
  }
13597
14096
  if (hasMore !== (cursor != null)) {
@@ -13604,9 +14103,9 @@ function decodePage(value) {
13604
14103
  import "buffer";
13605
14104
 
13606
14105
  // src/client-core-helpers.ts
13607
- import { Buffer as Buffer49 } from "buffer";
14106
+ import { Buffer as Buffer51 } from "buffer";
13608
14107
  function bgsaveResponse(response) {
13609
- if ((typeof response === "string" || Buffer49.isBuffer(response) || response instanceof Uint8Array) && text(response) === "Background saving started") {
14108
+ if ((typeof response === "string" || Buffer51.isBuffer(response) || response instanceof Uint8Array) && text(response) === "Background saving started") {
13610
14109
  return true;
13611
14110
  }
13612
14111
  return okResponse(response);
@@ -13620,7 +14119,7 @@ function fetchOrComputeCompletionToken(options) {
13620
14119
  "fetch-or-compute completion requires computeToken"
13621
14120
  );
13622
14121
  }
13623
- if (!Buffer49.isBuffer(options.computeToken)) {
14122
+ if (!Buffer51.isBuffer(options.computeToken)) {
13624
14123
  throw new TypeError("fetch-or-compute computeToken must be a Buffer");
13625
14124
  }
13626
14125
  return options.computeToken;
@@ -13711,7 +14210,14 @@ function snapshotClientOptions(options) {
13711
14210
  ...own2,
13712
14211
  ...typeof own2.autoBatch === "object" && own2.autoBatch != null ? { autoBatch: Object.freeze({ ...own2.autoBatch }) } : {},
13713
14212
  ...own2.backpressure == null ? {} : { backpressure: Object.freeze({ ...own2.backpressure }) },
13714
- ...typeof own2.reconnect === "object" && own2.reconnect != null ? { reconnect: Object.freeze({ ...own2.reconnect }) } : {}
14213
+ ...typeof own2.reconnect === "object" && own2.reconnect != null ? { reconnect: Object.freeze({ ...own2.reconnect }) } : {},
14214
+ ...own2.httpOptions == null ? {} : {
14215
+ httpOptions: Object.freeze({
14216
+ ...own2.httpOptions,
14217
+ ...own2.httpOptions.headers == null ? {} : { headers: Object.freeze({ ...own2.httpOptions.headers }) },
14218
+ ...own2.httpOptions.tlsOptions == null ? {} : { tlsOptions: Object.freeze({ ...own2.httpOptions.tlsOptions }) }
14219
+ })
14220
+ }
13715
14221
  };
13716
14222
  return Object.freeze(snapshot);
13717
14223
  }
@@ -13980,14 +14486,14 @@ var FerricStoreAdministrationClient = class extends FerricStoreClientBase {
13980
14486
  };
13981
14487
 
13982
14488
  // src/store-utilities.ts
13983
- import { Buffer as Buffer52 } from "buffer";
14489
+ import { Buffer as Buffer54 } from "buffer";
13984
14490
  function encode(codec, value) {
13985
14491
  return codec.encode(value);
13986
14492
  }
13987
14493
  function decode(codec, value) {
13988
14494
  if (value == null) return null;
13989
- if (Buffer52.isBuffer(value)) return codec.decode(value);
13990
- if (value instanceof Uint8Array) return codec.decode(Buffer52.from(value));
14495
+ if (Buffer54.isBuffer(value)) return codec.decode(value);
14496
+ if (value instanceof Uint8Array) return codec.decode(Buffer54.from(value));
13991
14497
  return value;
13992
14498
  }
13993
14499
  function number(value) {
@@ -14008,7 +14514,7 @@ function array(value, expectedItems, command) {
14008
14514
  }
14009
14515
  return value;
14010
14516
  }
14011
- function denseArray(value, command) {
14517
+ function denseArray2(value, command) {
14012
14518
  return assertDenseArray(array(value), command);
14013
14519
  }
14014
14520
  function denseArrayResponse(value, expectedItems, command) {
@@ -14296,7 +14802,7 @@ var BloomFilterStore = class {
14296
14802
  return integerReply(await this.client.command("BF.CARD", key));
14297
14803
  }
14298
14804
  async info(key) {
14299
- return denseArray(await this.client.command("BF.INFO", key), "BF.INFO");
14805
+ return denseArray2(await this.client.command("BF.INFO", key), "BF.INFO");
14300
14806
  }
14301
14807
  };
14302
14808
  var CuckooFilterStore = class {
@@ -14335,7 +14841,7 @@ var CuckooFilterStore = class {
14335
14841
  return integerReply(await this.client.command("CF.COUNT", key, encode(this.client.codec, element)));
14336
14842
  }
14337
14843
  async info(key) {
14338
- return denseArray(await this.client.command("CF.INFO", key), "CF.INFO");
14844
+ return denseArray2(await this.client.command("CF.INFO", key), "CF.INFO");
14339
14845
  }
14340
14846
  };
14341
14847
  var CountMinSketchStore = class {
@@ -14380,7 +14886,7 @@ var CountMinSketchStore = class {
14380
14886
  return okResponse(await commandArgs(this.client, args));
14381
14887
  }
14382
14888
  async info(key) {
14383
- return denseArray(await this.client.command("CMS.INFO", key), "CMS.INFO");
14889
+ return denseArray2(await this.client.command("CMS.INFO", key), "CMS.INFO");
14384
14890
  }
14385
14891
  };
14386
14892
  var TopKStore = class {
@@ -14463,7 +14969,7 @@ var TopKStore = class {
14463
14969
  );
14464
14970
  }
14465
14971
  async info(key) {
14466
- return denseArray(await this.client.command("TOPK.INFO", key), "TOPK.INFO");
14972
+ return denseArray2(await this.client.command("TOPK.INFO", key), "TOPK.INFO");
14467
14973
  }
14468
14974
  };
14469
14975
  var TDigestStore = class {
@@ -14554,7 +15060,7 @@ var TDigestStore = class {
14554
15060
  return string(await this.client.command("TDIGEST.MAX", key));
14555
15061
  }
14556
15062
  async info(key) {
14557
- return denseArray(await this.client.command("TDIGEST.INFO", key), "TDIGEST.INFO");
15063
+ return denseArray2(await this.client.command("TDIGEST.INFO", key), "TDIGEST.INFO");
14558
15064
  }
14559
15065
  async merge(destination, sources, options = {}) {
14560
15066
  requireNonEmpty(sources, "TDIGEST.MERGE", "source");
@@ -14946,7 +15452,7 @@ var KeyValueStore = class {
14946
15452
  return response == null ? null : string(response);
14947
15453
  }
14948
15454
  async objectHelp() {
14949
- return denseArray(await this.client.command("OBJECT", "HELP"), "OBJECT HELP");
15455
+ return denseArray2(await this.client.command("OBJECT", "HELP"), "OBJECT HELP");
14950
15456
  }
14951
15457
  async objectFreq(key) {
14952
15458
  return number(await this.client.command("OBJECT", "FREQ", key));
@@ -15954,14 +16460,14 @@ function validateScheduleCreate(id, options) {
15954
16460
  validateTiming(kind, options);
15955
16461
  const recurring = RECURRING_KINDS.has(kind);
15956
16462
  validateTarget(options.target, recurring);
15957
- nonNegativeInteger2(options.atMs, "at_ms");
15958
- nonNegativeInteger2(options.delayMs, "delay_ms");
15959
- nonNegativeInteger2(options.startAtMs, "start_at_ms");
15960
- positiveInteger2(options.everyMs, "every_ms");
15961
- positiveInteger2(options.overlapRetryMs, "overlap_retry_ms");
15962
- positiveInteger2(options.maxFires, "max_fires");
15963
- nonNegativeInteger2(options.endAtMs, "end_at_ms");
15964
- nonNegativeInteger2(options.nowMs, "now_ms");
16463
+ nonNegativeInteger3(options.atMs, "at_ms");
16464
+ nonNegativeInteger3(options.delayMs, "delay_ms");
16465
+ nonNegativeInteger3(options.startAtMs, "start_at_ms");
16466
+ positiveInteger3(options.everyMs, "every_ms");
16467
+ positiveInteger3(options.overlapRetryMs, "overlap_retry_ms");
16468
+ positiveInteger3(options.maxFires, "max_fires");
16469
+ nonNegativeInteger3(options.endAtMs, "end_at_ms");
16470
+ nonNegativeInteger3(options.nowMs, "now_ms");
15965
16471
  optionalBoolean(options.overwrite, "overwrite");
15966
16472
  if (kind === "delay") {
15967
16473
  if (options.delayMs == null) throw new TypeError("delay_ms is required for delay schedules");
@@ -16018,20 +16524,20 @@ function validateScheduleID(id) {
16018
16524
  }
16019
16525
  function validateScheduleFire(id, options) {
16020
16526
  validateScheduleID(id);
16021
- nonNegativeInteger2(options.fireAtMs, "fire_at_ms");
16022
- nonNegativeInteger2(options.nowMs, "now_ms");
16527
+ nonNegativeInteger3(options.fireAtMs, "fire_at_ms");
16528
+ nonNegativeInteger3(options.nowMs, "now_ms");
16023
16529
  }
16024
16530
  function validateScheduleStatus(id, nowMs2) {
16025
16531
  validateScheduleID(id);
16026
- nonNegativeInteger2(nowMs2, "now_ms");
16532
+ nonNegativeInteger3(nowMs2, "now_ms");
16027
16533
  }
16028
16534
  function validateScheduleFireDue(options) {
16029
16535
  if (!mapping(options)) throw new TypeError("schedule fire-due options must be a mapping");
16030
- nonNegativeInteger2(options.nowMs, "now_ms");
16536
+ nonNegativeInteger3(options.nowMs, "now_ms");
16031
16537
  optionalText3(options.worker, "worker");
16032
- positiveInteger2(options.leaseMs, "lease_ms");
16033
- nonNegativeInteger2(options.blockMs, "block_ms");
16034
- positiveInteger2(options.limit, "limit");
16538
+ positiveInteger3(options.leaseMs, "lease_ms");
16539
+ nonNegativeInteger3(options.blockMs, "block_ms");
16540
+ positiveInteger3(options.limit, "limit");
16035
16541
  const leaseMs = options.leaseMs ?? 3e4;
16036
16542
  if (options.nowMs != null && options.nowMs > MAX_EXACT_INTEGER - leaseMs) {
16037
16543
  throw new TypeError("now_ms plus lease_ms exceeds the exact integer range");
@@ -16047,12 +16553,12 @@ function validateScheduleList(options) {
16047
16553
  }
16048
16554
  optionalText3(options.timezone, "timezone");
16049
16555
  optionalText3(options.targetType, "target_type");
16050
- nonNegativeInteger2(options.fromMs, "from_ms");
16051
- nonNegativeInteger2(options.toMs, "to_ms");
16556
+ nonNegativeInteger3(options.fromMs, "from_ms");
16557
+ nonNegativeInteger3(options.toMs, "to_ms");
16052
16558
  if (options.fromMs != null && options.toMs != null && options.fromMs > options.toMs) {
16053
16559
  throw new TypeError("from_ms must not exceed to_ms");
16054
16560
  }
16055
- positiveInteger2(options.count, "count");
16561
+ positiveInteger3(options.count, "count");
16056
16562
  optionalBoolean(options.rev, "rev");
16057
16563
  }
16058
16564
  function effectiveKind(options) {
@@ -16110,7 +16616,7 @@ function validateTarget(value, recurring) {
16110
16616
  if (typeof idPrefix === "string" && idPrefix.startsWith(INTERNAL_SCHEDULE_ID_PREFIX)) {
16111
16617
  throw new TypeError("target id_prefix is reserved for internal use");
16112
16618
  }
16113
- nonNegativeInteger2(own(target, "run_at_ms"), "target run_at_ms");
16619
+ nonNegativeInteger3(own(target, "run_at_ms"), "target run_at_ms");
16114
16620
  const priority = own(target, "priority");
16115
16621
  if (priority != null && (typeof priority !== "number" || !Number.isSafeInteger(priority) || priority < 0 || priority > 2)) {
16116
16622
  throw new TypeError("target priority must be an integer between 0 and 2");
@@ -16132,12 +16638,12 @@ function requiredText3(value, name) {
16132
16638
  function optionalText3(value, name) {
16133
16639
  if (value != null) requiredText3(value, name);
16134
16640
  }
16135
- function nonNegativeInteger2(value, name) {
16641
+ function nonNegativeInteger3(value, name) {
16136
16642
  if (value != null && (typeof value !== "number" || !Number.isSafeInteger(value) || value < 0)) {
16137
16643
  throw new TypeError(`${name} must be a non-negative exact integer`);
16138
16644
  }
16139
16645
  }
16140
- function positiveInteger2(value, name) {
16646
+ function positiveInteger3(value, name) {
16141
16647
  if (value != null && (typeof value !== "number" || !Number.isSafeInteger(value) || value <= 0)) {
16142
16648
  throw new TypeError(`${name} must be a positive exact integer`);
16143
16649
  }
@@ -16843,7 +17349,7 @@ function throwIfClosed(signal) {
16843
17349
  }
16844
17350
 
16845
17351
  // src/flow-policy.ts
16846
- import { Buffer as Buffer54 } from "buffer";
17352
+ import { Buffer as Buffer56 } from "buffer";
16847
17353
  var MAX_FLOW_POLICY_GENERATION = Number.MAX_SAFE_INTEGER;
16848
17354
  function assertFlowPolicyGeneration(value) {
16849
17355
  if (typeof value !== "number" || !Number.isSafeInteger(value) || value < 0) {
@@ -16861,7 +17367,7 @@ function flowPolicySnapshotFromResp(value) {
16861
17367
  const states = optionalStates(field(policy, "states"));
16862
17368
  return {
16863
17369
  type: requiredText4(field(policy, "type"), "type"),
16864
- generation: nonNegativeInteger3(field(policy, "generation"), "generation"),
17370
+ generation: nonNegativeInteger4(field(policy, "generation"), "generation"),
16865
17371
  ...state == null ? {} : { state },
16866
17372
  ...version == null ? {} : { version },
16867
17373
  ...mode == null ? {} : { mode },
@@ -16879,12 +17385,12 @@ function retrySnapshot(value, context) {
16879
17385
  const retry2 = requiredRecord(value, `FLOW policy ${context}`);
16880
17386
  const backoff = requiredRecord(field(retry2, "backoff"), `FLOW policy ${context}.backoff`);
16881
17387
  return {
16882
- maxRetries: nonNegativeInteger3(field(retry2, "max_retries"), `${context}.max_retries`),
17388
+ maxRetries: nonNegativeInteger4(field(retry2, "max_retries"), `${context}.max_retries`),
16883
17389
  backoff: {
16884
17390
  kind: backoffKind(field(backoff, "kind"), `${context}.backoff.kind`),
16885
- baseMs: nonNegativeInteger3(field(backoff, "base_ms"), `${context}.backoff.base_ms`),
16886
- maxMs: nonNegativeInteger3(field(backoff, "max_ms"), `${context}.backoff.max_ms`),
16887
- jitterPct: nonNegativeInteger3(field(backoff, "jitter_pct"), `${context}.backoff.jitter_pct`)
17391
+ baseMs: nonNegativeInteger4(field(backoff, "base_ms"), `${context}.backoff.base_ms`),
17392
+ maxMs: nonNegativeInteger4(field(backoff, "max_ms"), `${context}.backoff.max_ms`),
17393
+ jitterPct: nonNegativeInteger4(field(backoff, "jitter_pct"), `${context}.backoff.jitter_pct`)
16888
17394
  },
16889
17395
  exhaustedTo: requiredText4(field(retry2, "exhausted_to"), `${context}.exhausted_to`)
16890
17396
  };
@@ -16892,8 +17398,8 @@ function retrySnapshot(value, context) {
16892
17398
  function retentionSnapshot(value, context) {
16893
17399
  const retention = requiredRecord(value, `FLOW policy ${context}`);
16894
17400
  return {
16895
- ttlMs: nonNegativeInteger3(field(retention, "ttl_ms"), `${context}.ttl_ms`),
16896
- historyMaxEvents: nonNegativeInteger3(
17401
+ ttlMs: nonNegativeInteger4(field(retention, "ttl_ms"), `${context}.ttl_ms`),
17402
+ historyMaxEvents: nonNegativeInteger4(
16897
17403
  field(retention, "history_max_events"),
16898
17404
  `${context}.history_max_events`
16899
17405
  )
@@ -16933,7 +17439,7 @@ function requiredRecord(value, context) {
16933
17439
  }
16934
17440
  return result;
16935
17441
  }
16936
- if (typeof value === "object" && value != null && !Array.isArray(value) && !Buffer54.isBuffer(value) && !(value instanceof Uint8Array)) return value;
17442
+ if (typeof value === "object" && value != null && !Array.isArray(value) && !Buffer56.isBuffer(value) && !(value instanceof Uint8Array)) return value;
16937
17443
  throw new TypeError(`${context} returned an unexpected response`);
16938
17444
  }
16939
17445
  function optionalRecord(value, context) {
@@ -16954,15 +17460,15 @@ function stringArray(value, context) {
16954
17460
  }
16955
17461
  function requiredText4(value, context) {
16956
17462
  if (typeof value === "string") return value;
16957
- if (Buffer54.isBuffer(value) || value instanceof Uint8Array) {
16958
- return Buffer54.from(value).toString("utf8");
17463
+ if (Buffer56.isBuffer(value) || value instanceof Uint8Array) {
17464
+ return Buffer56.from(value).toString("utf8");
16959
17465
  }
16960
17466
  throw new TypeError(`FLOW policy ${context} returned an unexpected response`);
16961
17467
  }
16962
17468
  function optionalText4(value, context) {
16963
17469
  return value == null ? void 0 : requiredText4(value, context);
16964
17470
  }
16965
- function nonNegativeInteger3(value, context) {
17471
+ function nonNegativeInteger4(value, context) {
16966
17472
  let parsed;
16967
17473
  try {
16968
17474
  parsed = integer(value);
@@ -16974,14 +17480,14 @@ function nonNegativeInteger3(value, context) {
16974
17480
  }
16975
17481
  function optionalPositiveInteger(value, context) {
16976
17482
  if (value == null) return void 0;
16977
- const parsed = nonNegativeInteger3(value, context);
17483
+ const parsed = nonNegativeInteger4(value, context);
16978
17484
  if (parsed === 0) throw new TypeError(`FLOW policy ${context} returned an unexpected response`);
16979
17485
  return parsed;
16980
17486
  }
16981
17487
  function optionalVersion(value) {
16982
17488
  if (value == null) return void 0;
16983
17489
  if (typeof value === "number" || typeof value === "bigint") {
16984
- return nonNegativeInteger3(value, "version");
17490
+ return nonNegativeInteger4(value, "version");
16985
17491
  }
16986
17492
  return requiredText4(value, "version");
16987
17493
  }
@@ -17211,7 +17717,7 @@ var FerricStoreFlowSupportClient = class extends FerricStoreFlowQueryClient {
17211
17717
  };
17212
17718
 
17213
17719
  // src/flow-many-snapshot.ts
17214
- import { Buffer as Buffer56 } from "buffer";
17720
+ import { Buffer as Buffer58 } from "buffer";
17215
17721
  var encodedOptionFields = ["error", "payload", "reason", "result"];
17216
17722
  function snapshotCreateItem(item, codec) {
17217
17723
  const snapshot = {
@@ -17251,7 +17757,7 @@ function snapshotFlowManyOptions(options, codec) {
17251
17757
  }
17252
17758
  function snapshotClaimedItem(item) {
17253
17759
  const wire = item[CLAIMED_ITEM_WIRE];
17254
- const leaseToken = Buffer56.from(wire?.leaseToken ?? item.leaseToken);
17760
+ const leaseToken = Buffer58.from(wire?.leaseToken ?? item.leaseToken);
17255
17761
  const snapshot = {
17256
17762
  ...item,
17257
17763
  fencingToken: wire?.fencingToken ?? item.fencingToken,
@@ -17268,15 +17774,15 @@ function snapshotClaimedItem(item) {
17268
17774
  function snapshotFencedItem(item) {
17269
17775
  return Object.freeze({
17270
17776
  ...item,
17271
- ...item.leaseToken == null ? {} : { leaseToken: Buffer56.from(item.leaseToken) }
17777
+ ...item.leaseToken == null ? {} : { leaseToken: Buffer58.from(item.leaseToken) }
17272
17778
  });
17273
17779
  }
17274
17780
  function snapshotClaimedItemWire(wire, leaseToken) {
17275
17781
  return Object.freeze({
17276
17782
  fencingToken: wire.fencingToken,
17277
- id: Buffer56.from(wire.id),
17783
+ id: Buffer58.from(wire.id),
17278
17784
  leaseToken,
17279
- partitionKey: wire.partitionKey == null ? wire.partitionKey : Buffer56.from(wire.partitionKey)
17785
+ partitionKey: wire.partitionKey == null ? wire.partitionKey : Buffer58.from(wire.partitionKey)
17280
17786
  });
17281
17787
  }
17282
17788
  function snapshotArray(values) {
@@ -17287,7 +17793,7 @@ function snapshotArray(values) {
17287
17793
  return Object.freeze(snapshot);
17288
17794
  }
17289
17795
  function snapshotStateMeta(stateMeta) {
17290
- return snapshotRecord(stateMeta, (value) => Buffer56.isBuffer(value) ? Buffer56.from(value) : value);
17796
+ return snapshotRecord(stateMeta, (value) => Buffer58.isBuffer(value) ? Buffer58.from(value) : value);
17291
17797
  }
17292
17798
  function snapshotCommandRecord(values) {
17293
17799
  const seen = /* @__PURE__ */ new WeakMap();
@@ -17305,7 +17811,7 @@ function snapshotRecord(values, capture) {
17305
17811
  }
17306
17812
  function snapshotCommandArgument(value, seen) {
17307
17813
  if (typeof value !== "object" || value == null) return value;
17308
- if (Buffer56.isBuffer(value) || value instanceof Uint8Array) return Buffer56.from(value);
17814
+ if (Buffer58.isBuffer(value) || value instanceof Uint8Array) return Buffer58.from(value);
17309
17815
  const objectValue = value;
17310
17816
  const existing = seen.get(objectValue);
17311
17817
  if (existing != null) return existing;
@@ -18070,6 +18576,14 @@ var FerricStoreProducerClient = class extends FerricStoreClaimClient {
18070
18576
  var FerricStoreClient = class _FerricStoreClient extends FerricStoreProducerClient {
18071
18577
  static async fromUrl(url, options = {}) {
18072
18578
  const clientOptions = snapshotClientOptions(options);
18579
+ const scheme = new URL(url).protocol;
18580
+ if (scheme === "http:" || scheme === "https:") {
18581
+ if (clientOptions.nativeOptions != null) {
18582
+ throw new TypeError("nativeOptions are not valid for an HTTP FerricStore URL");
18583
+ }
18584
+ const executor2 = await HTTPAdapter.fromUrl(url, clientOptions.httpOptions);
18585
+ return new _FerricStoreClient(executor2, clientOptions);
18586
+ }
18073
18587
  const nativeOptions = snapshotNativeClientOptions(clientOptions.nativeOptions ?? {});
18074
18588
  const reconnectOptions = clientOptions.reconnect ?? nativeOptions.autoReconnect ?? true;
18075
18589
  const seeds = nativeOptions.seeds ?? [];
@@ -18293,7 +18807,7 @@ function nativeOptionsForBootstrap(options, signal) {
18293
18807
  }
18294
18808
 
18295
18809
  // src/flow-query-projection.ts
18296
- import { Buffer as Buffer57 } from "buffer";
18810
+ import { Buffer as Buffer59 } from "buffer";
18297
18811
  var MAX_PROJECTION_FIELDS = 32;
18298
18812
  var MAX_DYNAMIC_NAME_BYTES = 64;
18299
18813
  var FIELD_BRAND = /* @__PURE__ */ Symbol("FerricStoreFlowProjectionField");
@@ -18363,7 +18877,7 @@ function projectFlowQuery(query, shape, ...fields) {
18363
18877
  }
18364
18878
  const base = stripOptionalTerminator(query);
18365
18879
  const result = `${base} RETURN ${shape.toUpperCase()} (${selectors.join(", ")})`;
18366
- if (Buffer57.byteLength(result, "utf8") > FLOW_QUERY_MAX_BYTES) {
18880
+ if (Buffer59.byteLength(result, "utf8") > FLOW_QUERY_MAX_BYTES) {
18367
18881
  throw new TypeError(`FLOW.QUERY query exceeds ${FLOW_QUERY_MAX_BYTES} bytes`);
18368
18882
  }
18369
18883
  return result;
@@ -18423,7 +18937,7 @@ function quoteName(value, allowPrivate) {
18423
18937
  throw new TypeError("Flow query projection metadata name must be text");
18424
18938
  }
18425
18939
  validateUnicodeScalarText2(value);
18426
- const size = Buffer57.byteLength(value, "utf8");
18940
+ const size = Buffer59.byteLength(value, "utf8");
18427
18941
  if (size === 0 || size > MAX_DYNAMIC_NAME_BYTES || !allowPrivate && value.startsWith("__")) {
18428
18942
  throw new TypeError(
18429
18943
  `Flow query projection metadata names must be 1..${MAX_DYNAMIC_NAME_BYTES} UTF-8 bytes`
@@ -18525,7 +19039,7 @@ var LeaseRenewalGuard = class {
18525
19039
  if (options.leaseRenewal === false) {
18526
19040
  return;
18527
19041
  }
18528
- const intervalMs = positiveInteger3(options.leaseRenewIntervalMs, Math.max(1, Math.trunc(leaseMs / 2)));
19042
+ const intervalMs = positiveInteger4(options.leaseRenewIntervalMs, Math.max(1, Math.trunc(leaseMs / 2)));
18529
19043
  this.timer = setLongInterval(() => this.renew(), intervalMs);
18530
19044
  this.timer.unref();
18531
19045
  }
@@ -18597,7 +19111,7 @@ function snapshotLeasedJob(job) {
18597
19111
  return snapshot;
18598
19112
  }
18599
19113
  function workerConcurrency(options) {
18600
- return positiveInteger3(options.concurrency ?? options.workers, 1);
19114
+ return positiveInteger4(options.concurrency ?? options.workers, 1);
18601
19115
  }
18602
19116
  function workerRefillStrategy(options) {
18603
19117
  return options.refillStrategy === "wave" ? "wave" : "continuous";
@@ -18640,18 +19154,18 @@ function workerErrorPayload(error, options, codec) {
18640
19154
  }
18641
19155
  function workerBatchSize(options, flowManyBatchLimit = DEFAULT_FLOW_MANY_BATCH_LIMIT2) {
18642
19156
  return Math.min(
18643
- positiveInteger3(options.batchSize, 10),
18644
- positiveInteger3(flowManyBatchLimit, DEFAULT_FLOW_MANY_BATCH_LIMIT2)
19157
+ positiveInteger4(options.batchSize, 10),
19158
+ positiveInteger4(flowManyBatchLimit, DEFAULT_FLOW_MANY_BATCH_LIMIT2)
18645
19159
  );
18646
19160
  }
18647
19161
  function workerClaimLimit(options, flowManyBatchLimit = DEFAULT_FLOW_MANY_BATCH_LIMIT2) {
18648
19162
  return Math.min(workerBatchSize(options, flowManyBatchLimit), workerConcurrency(options));
18649
19163
  }
18650
19164
  function workerDrainBatches(options) {
18651
- return positiveInteger3(options.claimDrainBatches, 1);
19165
+ return positiveInteger4(options.claimDrainBatches, 1);
18652
19166
  }
18653
19167
  function workerLeaseMs(options, fallback = 3e4) {
18654
- return positiveInteger3(options.leaseMs, positiveInteger3(fallback, 3e4));
19168
+ return positiveInteger4(options.leaseMs, positiveInteger4(fallback, 3e4));
18655
19169
  }
18656
19170
  function workerIdleSleepMs(options) {
18657
19171
  return nonNegativeDuration(options.idleSleepMs, 250);
@@ -18663,7 +19177,7 @@ function workerClaimBlockMs(options, useBlocking) {
18663
19177
  if (options.signal == null || !Number.isFinite(options.blockMs) || options.blockMs < 0) {
18664
19178
  return options.blockMs;
18665
19179
  }
18666
- const abortPollMs = positiveInteger3(options.abortPollMs, 1e3);
19180
+ const abortPollMs = positiveInteger4(options.abortPollMs, 1e3);
18667
19181
  return options.blockMs === 0 ? abortPollMs : Math.min(Math.trunc(options.blockMs), abortPollMs);
18668
19182
  }
18669
19183
  function workerMaxIdleSleepMs(options, idleSleepMs = workerIdleSleepMs(options)) {
@@ -18674,14 +19188,14 @@ function nextWorkerIdleSleepMs(currentIdleSleepMs, maxIdleSleepMs) {
18674
19188
  return Math.min(maxIdleSleepMs, Math.max(1, currentIdleSleepMs * 2));
18675
19189
  }
18676
19190
  async function runContinuousWorkerPool(options) {
18677
- const concurrency = positiveInteger3(options.concurrency, 1);
18678
- const maxClaimSize = positiveInteger3(options.maxClaimSize, concurrency);
19191
+ const concurrency = positiveInteger4(options.concurrency, 1);
19192
+ const maxClaimSize = positiveInteger4(options.maxClaimSize, concurrency);
18679
19193
  const initialIdleSleepMs = nonNegativeDuration(options.idleSleepMs, 250);
18680
19194
  const maxIdleSleepMs = Math.max(
18681
19195
  initialIdleSleepMs,
18682
19196
  nonNegativeDuration(options.maxIdleSleepMs, 5e3)
18683
19197
  );
18684
- const refillDelayMs = nonNegativeInteger4(options.refillDelayMs, 0);
19198
+ const refillDelayMs = nonNegativeInteger5(options.refillDelayMs, 0);
18685
19199
  const active = /* @__PURE__ */ new Set();
18686
19200
  const pending = [];
18687
19201
  let pendingIndex = 0;
@@ -18797,10 +19311,10 @@ function normalizeWorkflowWorkerConfig(options) {
18797
19311
  ...captured
18798
19312
  });
18799
19313
  }
18800
- function positiveInteger3(value, fallback) {
19314
+ function positiveInteger4(value, fallback) {
18801
19315
  return value == null || !Number.isFinite(value) ? fallback : Math.max(1, Math.trunc(value));
18802
19316
  }
18803
- function nonNegativeInteger4(value, fallback) {
19317
+ function nonNegativeInteger5(value, fallback) {
18804
19318
  return value == null || !Number.isFinite(value) ? fallback : Math.max(0, Math.trunc(value));
18805
19319
  }
18806
19320
  function nonNegativeDuration(value, fallback) {
@@ -20429,7 +20943,7 @@ var WorkflowWorker = class {
20429
20943
  };
20430
20944
 
20431
20945
  // src/version.ts
20432
- var FERRICSTORE_SDK_VERSION = "0.11.8";
20946
+ var FERRICSTORE_SDK_VERSION = "0.11.9";
20433
20947
  var FERRICSTORE_MINIMUM_SERVER_VERSION = "0.11.4";
20434
20948
  var FERRICSTORE_NATIVE_PROTOCOL_VERSION = 1;
20435
20949
  export {
@@ -20452,6 +20966,8 @@ export {
20452
20966
  FlowQueryError,
20453
20967
  FlowWrongStateError,
20454
20968
  GeoStore,
20969
+ HTTPAdapter,
20970
+ HTTPTransportError,
20455
20971
  HashStore,
20456
20972
  HyperLogLogStore,
20457
20973
  InvalidCommandError,
@@ -20489,6 +21005,7 @@ export {
20489
21005
  classifyServerError,
20490
21006
  complete,
20491
21007
  fail2 as fail,
21008
+ httpCommandDisposition,
20492
21009
  isOutcome,
20493
21010
  isReconnectableClosedConnectionError,
20494
21011
  mapException,