@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.
- package/README.md +35 -1
- package/dist/index.cjs +672 -152
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +40 -2
- package/dist/index.d.ts +40 -2
- package/dist/index.js +662 -145
- package/dist/index.js.map +1 -1
- package/docs/api/assets/hierarchy.js +1 -1
- package/docs/api/assets/highlight.css +1 -1
- package/docs/api/assets/main.js +1 -1
- package/docs/api/assets/navigation.js +1 -1
- package/docs/api/assets/search.js +1 -1
- package/docs/api/assets/style.css +18 -3
- package/docs/api/classes/BitmapStore.html +192 -3
- package/docs/api/classes/BloomFilterStore.html +197 -3
- package/docs/api/classes/ClaimHydrationError.html +202 -7
- package/docs/api/classes/ConnectionClosedError.html +193 -8
- package/docs/api/classes/CountMinSketchStore.html +171 -3
- package/docs/api/classes/CuckooFilterStore.html +196 -3
- package/docs/api/classes/FerricStoreClient.html +2888 -7
- package/docs/api/classes/FerricStoreError.html +197 -7
- package/docs/api/classes/FlowAlreadyExistsError.html +185 -7
- package/docs/api/classes/FlowBatchError.html +204 -8
- package/docs/api/classes/FlowNotFoundError.html +185 -7
- package/docs/api/classes/FlowQueryError.html +204 -7
- package/docs/api/classes/FlowWrongStateError.html +185 -7
- package/docs/api/classes/GeoStore.html +188 -3
- package/docs/api/classes/HTTPAdapter.html +144 -0
- package/docs/api/classes/HTTPTransportError.html +222 -0
- package/docs/api/classes/HashStore.html +493 -3
- package/docs/api/classes/HyperLogLogStore.html +148 -3
- package/docs/api/classes/InvalidCommandError.html +185 -7
- package/docs/api/classes/JsonCodec.html +104 -3
- package/docs/api/classes/KeyValueStore.html +794 -3
- package/docs/api/classes/LeaseRenewalError.html +157 -8
- package/docs/api/classes/ListStore.html +451 -3
- package/docs/api/classes/LockHeldError.html +185 -7
- package/docs/api/classes/LockNotOwnedError.html +185 -7
- package/docs/api/classes/NativeAdapter.html +135 -3
- package/docs/api/classes/OverloadedError.html +190 -7
- package/docs/api/classes/Queue.html +141 -4
- package/docs/api/classes/QueueClient.html +97 -4
- package/docs/api/classes/QueueCompletionError.html +163 -8
- package/docs/api/classes/QueueWorker.html +153 -4
- package/docs/api/classes/RawCodec.html +96 -3
- package/docs/api/classes/ReconnectingExecutor.html +180 -5
- package/docs/api/classes/RequestTimeoutError.html +199 -8
- package/docs/api/classes/RerouteError.html +188 -8
- package/docs/api/classes/RoutingTopology.html +125 -3
- package/docs/api/classes/SetStore.html +363 -3
- package/docs/api/classes/SortedSetStore.html +369 -3
- package/docs/api/classes/StaleLeaseError.html +185 -7
- package/docs/api/classes/StalePolicyGenerationError.html +188 -8
- package/docs/api/classes/StreamStore.html +259 -3
- package/docs/api/classes/TDigestStore.html +348 -3
- package/docs/api/classes/TopKStore.html +229 -3
- package/docs/api/classes/TopologyNativeAdapterPool.html +180 -5
- package/docs/api/classes/Workflow.html +266 -4
- package/docs/api/classes/WorkflowClient.html +97 -4
- package/docs/api/classes/WorkflowContext.html +293 -5
- package/docs/api/classes/WorkflowFlowCommands.html +251 -3
- package/docs/api/classes/WorkflowWorker.html +108 -4
- package/docs/api/functions/classifyServerError.html +44 -1
- package/docs/api/functions/complete.html +41 -1
- package/docs/api/functions/fail.html +41 -1
- package/docs/api/functions/httpCommandDisposition.html +41 -0
- package/docs/api/functions/isOutcome.html +41 -1
- package/docs/api/functions/isReconnectableClosedConnectionError.html +41 -1
- package/docs/api/functions/mapException.html +41 -1
- package/docs/api/functions/projectFlowQuery.html +43 -1
- package/docs/api/functions/retry.html +41 -1
- package/docs/api/functions/transition.html +42 -1
- package/docs/api/hierarchy.html +112 -1
- package/docs/api/index.html +70 -3
- package/docs/api/interfaces/AdminListOptions.html +70 -2
- package/docs/api/interfaces/ApprovalListOptions.html +74 -2
- package/docs/api/interfaces/ApprovalRequestOptions.html +99 -2
- package/docs/api/interfaces/AttributeQueryOptions.html +69 -2
- package/docs/api/interfaces/AutoBatchOptions.html +72 -3
- package/docs/api/interfaces/BackpressurePolicy.html +69 -2
- package/docs/api/interfaces/BudgetCommitOptions.html +59 -2
- package/docs/api/interfaces/BudgetReserveOptions.html +69 -2
- package/docs/api/interfaces/CancelOptions.html +135 -2
- package/docs/api/interfaces/ChildSpec.html +79 -2
- package/docs/api/interfaces/CircuitOpenOptions.html +64 -2
- package/docs/api/interfaces/ClaimDueOptions.html +146 -3
- package/docs/api/interfaces/ClaimHydrationItem.html +59 -2
- package/docs/api/interfaces/ClaimedItem.html +100 -3
- package/docs/api/interfaces/Codec.html +84 -2
- package/docs/api/interfaces/CommandExecutor.html +145 -4
- package/docs/api/interfaces/CompleteJobsAndClaimJobsResult.html +84 -7
- package/docs/api/interfaces/CompleteManyOptions.html +114 -2
- package/docs/api/interfaces/CompleteOptions.html +143 -2
- package/docs/api/interfaces/CompleteOutcome.html +117 -2
- package/docs/api/interfaces/CountMinMergeOptions.html +54 -2
- package/docs/api/interfaces/CreateItem.html +84 -2
- package/docs/api/interfaces/CreateManyOptions.html +173 -6
- package/docs/api/interfaces/CreateOptions.html +143 -4
- package/docs/api/interfaces/EffectCompensateOptions.html +89 -2
- package/docs/api/interfaces/EffectConfirmOptions.html +89 -2
- package/docs/api/interfaces/EffectFailOptions.html +94 -2
- package/docs/api/interfaces/EffectReserveOptions.html +84 -2
- package/docs/api/interfaces/EffectStatusOptions.html +77 -2
- package/docs/api/interfaces/ExecutePipelineOptions.html +68 -4
- package/docs/api/interfaces/ExtendLeaseOptions.html +79 -2
- package/docs/api/interfaces/FailOptions.html +143 -2
- package/docs/api/interfaces/FailOutcome.html +117 -2
- package/docs/api/interfaces/FencedItem.html +69 -2
- package/docs/api/interfaces/FerricStoreClientFromUrlOptions.html +105 -4
- package/docs/api/interfaces/FerricStoreClientOptions.html +84 -4
- package/docs/api/interfaces/FetchOrComputeComputeResult.html +83 -4
- package/docs/api/interfaces/FetchOrComputeHitResult.html +78 -2
- package/docs/api/interfaces/FlowBatchCompletedItem.html +59 -2
- package/docs/api/interfaces/FlowEventProjectionField.html +64 -2
- package/docs/api/interfaces/FlowExplainCapabilities.html +69 -2
- package/docs/api/interfaces/FlowExplainResult.html +124 -2
- package/docs/api/interfaces/FlowMaxActiveFailure.html +59 -2
- package/docs/api/interfaces/FlowPolicyBackoffSnapshot.html +69 -2
- package/docs/api/interfaces/FlowPolicyOptions.html +107 -6
- package/docs/api/interfaces/FlowPolicyRetentionSnapshot.html +59 -2
- package/docs/api/interfaces/FlowPolicyRetrySnapshot.html +64 -2
- package/docs/api/interfaces/FlowPolicySnapshot.html +121 -5
- package/docs/api/interfaces/FlowPolicyStateSnapshot.html +74 -2
- package/docs/api/interfaces/FlowQueryCountResult.html +89 -2
- package/docs/api/interfaces/FlowQueryErrorPosition.html +64 -2
- package/docs/api/interfaces/FlowQueryIndex.html +134 -2
- package/docs/api/interfaces/FlowQueryIndexBuild.html +106 -2
- package/docs/api/interfaces/FlowQueryIndexCoverage.html +69 -2
- package/docs/api/interfaces/FlowQueryIndexField.html +69 -2
- package/docs/api/interfaces/FlowQueryIndexFormat.html +79 -2
- package/docs/api/interfaces/FlowQueryIndexProgress.html +86 -2
- package/docs/api/interfaces/FlowQueryIndexRegistry.html +59 -2
- package/docs/api/interfaces/FlowQueryIndexRetirement.html +94 -2
- package/docs/api/interfaces/FlowQueryIndexServices.html +74 -2
- package/docs/api/interfaces/FlowQueryIndexStatistics.html +99 -2
- package/docs/api/interfaces/FlowQueryIndexStatus.html +84 -2
- package/docs/api/interfaces/FlowQueryIndexValidation.html +121 -2
- package/docs/api/interfaces/FlowQueryPage.html +59 -2
- package/docs/api/interfaces/FlowQueryQuality.html +69 -2
- package/docs/api/interfaces/FlowQueryRecordsResult.html +94 -2
- package/docs/api/interfaces/FlowQueryUsage.html +104 -2
- package/docs/api/interfaces/FlowRecord.html +173 -2
- package/docs/api/interfaces/FlowRunProjectionField.html +64 -2
- package/docs/api/interfaces/FlowStatePolicy.html +59 -2
- package/docs/api/interfaces/FlowStatsOptions.html +74 -2
- package/docs/api/interfaces/GeoMember.html +64 -2
- package/docs/api/interfaces/GovernanceLedgerOptions.html +74 -2
- package/docs/api/interfaces/HTTPAdapterOptions.html +120 -0
- package/docs/api/interfaces/HistoryOptions.html +124 -2
- package/docs/api/interfaces/InvocationCreateOptions.html +71 -2
- package/docs/api/interfaces/KeyInfo.html +79 -2
- package/docs/api/interfaces/LeaseMutationOptions.html +136 -2
- package/docs/api/interfaces/LimitAmountOptions.html +64 -2
- package/docs/api/interfaces/LimitLeaseOptions.html +74 -2
- package/docs/api/interfaces/LimitListOptions.html +78 -2
- package/docs/api/interfaces/LimitReleaseOptions.html +64 -2
- package/docs/api/interfaces/MutateOptions.html +110 -2
- package/docs/api/interfaces/NamedValueMutation.html +93 -2
- package/docs/api/interfaces/NativeAdapterOptions.html +175 -12
- package/docs/api/interfaces/NativeClientOptions.html +249 -16
- package/docs/api/interfaces/NativeProtocolEvent.html +69 -2
- package/docs/api/interfaces/ProtocolCommand.html +69 -2
- package/docs/api/interfaces/QueueOptions.html +64 -2
- package/docs/api/interfaces/QueueWorkerResult.html +69 -2
- package/docs/api/interfaces/RangeLimit.html +59 -2
- package/docs/api/interfaces/RateLimitResult.html +74 -2
- package/docs/api/interfaces/ReadOptions.html +107 -3
- package/docs/api/interfaces/ReclaimOptions.html +140 -3
- package/docs/api/interfaces/ReconnectOptions.html +75 -5
- package/docs/api/interfaces/RequestContext.html +64 -2
- package/docs/api/interfaces/RequestContextOptions.html +60 -2
- package/docs/api/interfaces/RetryOptions.html +143 -2
- package/docs/api/interfaces/RetryOutcome.html +117 -2
- package/docs/api/interfaces/RetryPolicy.html +79 -2
- package/docs/api/interfaces/RoutingEndpoint.html +69 -2
- package/docs/api/interfaces/RoutingRoute.html +79 -2
- package/docs/api/interfaces/RunStepsItem.html +59 -2
- package/docs/api/interfaces/RunStepsManyOptions.html +99 -2
- package/docs/api/interfaces/ScanOptions.html +66 -3
- package/docs/api/interfaces/ScheduleFireDueOptions.html +74 -2
- package/docs/api/interfaces/ScheduleFireOptions.html +59 -2
- package/docs/api/interfaces/ScheduleListOptions.html +89 -2
- package/docs/api/interfaces/ScheduleOptions.html +131 -3
- package/docs/api/interfaces/SearchOptions.html +122 -3
- package/docs/api/interfaces/StartAndClaimOptions.html +136 -3
- package/docs/api/interfaces/StateOptions.html +94 -2
- package/docs/api/interfaces/StateRegistration.html +104 -2
- package/docs/api/interfaces/StepContinueOptions.html +159 -3
- package/docs/api/interfaces/StoreCommandClient.html +89 -3
- package/docs/api/interfaces/TDigestCreateOptions.html +60 -2
- package/docs/api/interfaces/TDigestMergeOptions.html +66 -2
- package/docs/api/interfaces/TopologyNativeAdapterOptions.html +228 -15
- package/docs/api/interfaces/TransitionOptions.html +153 -2
- package/docs/api/interfaces/TransitionOutcome.html +122 -2
- package/docs/api/interfaces/ValueConfig.html +59 -2
- package/docs/api/interfaces/WorkerConfig.html +230 -15
- package/docs/api/interfaces/WorkflowOptions.html +69 -2
- package/docs/api/interfaces/WorkflowWorkerResult.html +69 -2
- package/docs/api/interfaces/XReadStream.html +59 -2
- package/docs/api/interfaces/ZAddMember.html +59 -2
- package/docs/api/modules.html +51 -1
- package/docs/api/types/BackoffKind.html +32 -1
- package/docs/api/types/CollectionScanOptions.html +34 -2
- package/docs/api/types/Command.html +32 -1
- package/docs/api/types/CommandArgument.html +32 -1
- package/docs/api/types/ConnectionRequestDisposition.html +36 -2
- package/docs/api/types/EndpointPolicy.html +34 -2
- package/docs/api/types/ExceptionPolicy.html +32 -1
- package/docs/api/types/ExpiryCondition.html +32 -1
- package/docs/api/types/FencingToken.html +34 -2
- package/docs/api/types/FetchOrComputeFencedResult.html +32 -1
- package/docs/api/types/FetchOrComputeResult.html +36 -1
- package/docs/api/types/FlowAdminRecord.html +32 -1
- package/docs/api/types/FlowPolicyBackoffKind.html +32 -1
- package/docs/api/types/FlowProjectionField.html +32 -1
- package/docs/api/types/FlowProjectionShape.html +32 -1
- package/docs/api/types/FlowQueryIndexServiceState.html +32 -1
- package/docs/api/types/FlowQueryInteger.html +32 -1
- package/docs/api/types/FlowQueryParameter.html +32 -1
- package/docs/api/types/FlowQueryParameters.html +32 -1
- package/docs/api/types/FlowQueryRecord.html +32 -1
- package/docs/api/types/FlowQueryResult.html +32 -1
- package/docs/api/types/FlowStateMode.html +32 -1
- package/docs/api/types/FlowStatePolicyLike.html +32 -1
- package/docs/api/types/GeoAddOptions.html +34 -2
- package/docs/api/types/GetExOptions.html +34 -2
- package/docs/api/types/HTTPCommandDisposition.html +32 -0
- package/docs/api/types/HashScanResult.html +38 -2
- package/docs/api/types/IntegerReply.html +34 -2
- package/docs/api/types/ManagementPairs.html +32 -1
- package/docs/api/types/MaxActiveMs.html +32 -1
- package/docs/api/types/Outcome.html +32 -1
- package/docs/api/types/QueueBatchHandler.html +44 -1
- package/docs/api/types/QueueHandler.html +44 -1
- package/docs/api/types/QueueJob.html +32 -1
- package/docs/api/types/RequestDisposition.html +32 -1
- package/docs/api/types/ScheduleCatchupPolicy.html +34 -2
- package/docs/api/types/ScheduleFireDueResult.html +55 -3
- package/docs/api/types/ScheduleFireResult.html +34 -2
- package/docs/api/types/ScheduleKind.html +32 -1
- package/docs/api/types/ScheduleOverlapPolicy.html +32 -1
- package/docs/api/types/ScheduleRecord.html +95 -12
- package/docs/api/types/ScheduleState.html +32 -1
- package/docs/api/types/SearchStateMeta.html +32 -1
- package/docs/api/types/SetOptions.html +34 -2
- package/docs/api/types/SetScanResult.html +38 -2
- package/docs/api/types/SortedSetScanResult.html +38 -2
- package/docs/api/types/StateMeta.html +32 -1
- package/docs/api/types/StateMetaValue.html +32 -1
- package/docs/api/types/TopKReserveOptions.html +32 -1
- package/docs/api/types/WorkerProfile.html +32 -1
- package/docs/api/types/WorkerRefillStrategy.html +32 -1
- package/docs/api/types/WorkflowHandler.html +44 -1
- package/docs/api/types/ZAddOptions.html +34 -2
- package/docs/api/variables/COMMAND_OPCODES.html +297 -1
- package/docs/api/variables/FERRICSTORE_MINIMUM_SERVER_VERSION.html +34 -2
- package/docs/api/variables/FERRICSTORE_NATIVE_PROTOCOL_VERSION.html +34 -2
- package/docs/api/variables/FERRICSTORE_SDK_VERSION.html +34 -2
- package/docs/api/variables/FlowProjection.html +32 -1
- package/docs/api/variables/MAX_FLOW_POLICY_GENERATION.html +32 -1
- package/package.json +8 -8
package/dist/index.cjs
CHANGED
|
@@ -49,6 +49,8 @@ __export(index_exports, {
|
|
|
49
49
|
FlowQueryError: () => FlowQueryError,
|
|
50
50
|
FlowWrongStateError: () => FlowWrongStateError,
|
|
51
51
|
GeoStore: () => GeoStore,
|
|
52
|
+
HTTPAdapter: () => HTTPAdapter,
|
|
53
|
+
HTTPTransportError: () => HTTPTransportError,
|
|
52
54
|
HashStore: () => HashStore,
|
|
53
55
|
HyperLogLogStore: () => HyperLogLogStore,
|
|
54
56
|
InvalidCommandError: () => InvalidCommandError,
|
|
@@ -86,6 +88,7 @@ __export(index_exports, {
|
|
|
86
88
|
classifyServerError: () => classifyServerError,
|
|
87
89
|
complete: () => complete,
|
|
88
90
|
fail: () => fail2,
|
|
91
|
+
httpCommandDisposition: () => httpCommandDisposition,
|
|
89
92
|
isOutcome: () => isOutcome,
|
|
90
93
|
isReconnectableClosedConnectionError: () => isReconnectableClosedConnectionError,
|
|
91
94
|
mapException: () => mapException,
|
|
@@ -125,6 +128,14 @@ var FerricStoreError = class extends Error {
|
|
|
125
128
|
this.retryAfterMs = options.retryAfterMs ?? structuredIntegerField(options.raw, "retry_after_ms");
|
|
126
129
|
}
|
|
127
130
|
};
|
|
131
|
+
var HTTPTransportError = class extends FerricStoreError {
|
|
132
|
+
code = "http_transport";
|
|
133
|
+
statusCode;
|
|
134
|
+
constructor(message, options = {}) {
|
|
135
|
+
super(message, options);
|
|
136
|
+
this.statusCode = options.statusCode;
|
|
137
|
+
}
|
|
138
|
+
};
|
|
128
139
|
var ConnectionClosedError = class extends FerricStoreError {
|
|
129
140
|
code = "connection_closed";
|
|
130
141
|
requestDisposition;
|
|
@@ -8643,6 +8654,497 @@ var NativeAdapter = class _NativeAdapter {
|
|
|
8643
8654
|
}
|
|
8644
8655
|
};
|
|
8645
8656
|
|
|
8657
|
+
// src/http-command-policy.ts
|
|
8658
|
+
var nativeOnlyCommands = /* @__PURE__ */ new Set([
|
|
8659
|
+
"AUTH",
|
|
8660
|
+
"BACKPRESSURE",
|
|
8661
|
+
"CLIENT",
|
|
8662
|
+
"CLIENT.INFO",
|
|
8663
|
+
"CLIENT.SETNAME",
|
|
8664
|
+
"EVENT",
|
|
8665
|
+
"GOAWAY",
|
|
8666
|
+
"HELLO",
|
|
8667
|
+
"OPTIONS",
|
|
8668
|
+
"PIPELINE",
|
|
8669
|
+
"QUIT",
|
|
8670
|
+
"ROUTE",
|
|
8671
|
+
"ROUTE_BATCH",
|
|
8672
|
+
"SHARDS",
|
|
8673
|
+
"STARTUP",
|
|
8674
|
+
"SUBSCRIBE_EVENTS",
|
|
8675
|
+
"UNSUBSCRIBE_EVENTS",
|
|
8676
|
+
"WINDOW_UPDATE"
|
|
8677
|
+
]);
|
|
8678
|
+
var sessionOnlyCommands = /* @__PURE__ */ new Set([
|
|
8679
|
+
"AUTH",
|
|
8680
|
+
"BLMOVE",
|
|
8681
|
+
"BLMPOP",
|
|
8682
|
+
"BLPOP",
|
|
8683
|
+
"BRPOP",
|
|
8684
|
+
"CLIENT",
|
|
8685
|
+
"DISCARD",
|
|
8686
|
+
"EXEC",
|
|
8687
|
+
"HELLO",
|
|
8688
|
+
"MULTI",
|
|
8689
|
+
"PSUBSCRIBE",
|
|
8690
|
+
"PUNSUBSCRIBE",
|
|
8691
|
+
"QUIT",
|
|
8692
|
+
"SELECT",
|
|
8693
|
+
"SUBSCRIBE",
|
|
8694
|
+
"UNSUBSCRIBE",
|
|
8695
|
+
"UNWATCH",
|
|
8696
|
+
"WATCH",
|
|
8697
|
+
"XREAD",
|
|
8698
|
+
"XREADGROUP"
|
|
8699
|
+
]);
|
|
8700
|
+
function httpCommandDisposition(name) {
|
|
8701
|
+
const normalized = name.toUpperCase();
|
|
8702
|
+
return nativeOnlyCommands.has(normalized) || sessionOnlyCommands.has(normalized) ? "native_only" : "supported";
|
|
8703
|
+
}
|
|
8704
|
+
function assertHTTPCommandSupported(name) {
|
|
8705
|
+
if (typeof name !== "string" || name === "") throw new TypeError("HTTP command must have a name");
|
|
8706
|
+
if (sessionOnlyCommands.has(name.toUpperCase())) {
|
|
8707
|
+
throw new Error(`${name.toUpperCase()} requires a persistent native TCP session`);
|
|
8708
|
+
}
|
|
8709
|
+
}
|
|
8710
|
+
|
|
8711
|
+
// src/http-envelope.ts
|
|
8712
|
+
var import_node_buffer33 = require("buffer");
|
|
8713
|
+
var encoding = "ferricstore-json-v1";
|
|
8714
|
+
var bytesMarker = "$ferricstore_bytes";
|
|
8715
|
+
var mapMarker = "$ferricstore_map";
|
|
8716
|
+
var maxDepth = 64;
|
|
8717
|
+
function encodeHTTPCommands(commands) {
|
|
8718
|
+
return import_node_buffer33.Buffer.from(JSON.stringify({
|
|
8719
|
+
encoding,
|
|
8720
|
+
commands: commands.map((command) => encodeValue(command, 0))
|
|
8721
|
+
}));
|
|
8722
|
+
}
|
|
8723
|
+
function decodeHTTPEnvelope(source) {
|
|
8724
|
+
let parsed;
|
|
8725
|
+
try {
|
|
8726
|
+
parsed = JSON.parse(source.toString("utf8"));
|
|
8727
|
+
} catch (error) {
|
|
8728
|
+
throw new TypeError("invalid HTTP command response JSON", { cause: error });
|
|
8729
|
+
}
|
|
8730
|
+
if (!isRecord(parsed)) throw new TypeError("HTTP command response must be an object");
|
|
8731
|
+
return decodePlainRecord(parsed, 0);
|
|
8732
|
+
}
|
|
8733
|
+
function encodeValue(value, depth) {
|
|
8734
|
+
if (depth > maxDepth) throw new TypeError("HTTP command value exceeds maximum depth");
|
|
8735
|
+
if (value == null || typeof value === "string" || typeof value === "boolean") return value;
|
|
8736
|
+
if (import_node_buffer33.Buffer.isBuffer(value) || value instanceof Uint8Array) {
|
|
8737
|
+
return { [bytesMarker]: import_node_buffer33.Buffer.from(value).toString("base64") };
|
|
8738
|
+
}
|
|
8739
|
+
if (typeof value === "number") {
|
|
8740
|
+
if (!Number.isFinite(value)) throw new TypeError("HTTP command numbers must be finite");
|
|
8741
|
+
return value;
|
|
8742
|
+
}
|
|
8743
|
+
if (typeof value === "bigint") {
|
|
8744
|
+
return value >= BigInt(Number.MIN_SAFE_INTEGER) && value <= BigInt(Number.MAX_SAFE_INTEGER) ? Number(value) : value.toString();
|
|
8745
|
+
}
|
|
8746
|
+
if (Array.isArray(value)) return denseArray(value, depth + 1, encodeValue);
|
|
8747
|
+
if (value instanceof Map) {
|
|
8748
|
+
return { [mapMarker]: [...value.entries()].map(([key, item]) => [
|
|
8749
|
+
encodeValue(key, depth + 1),
|
|
8750
|
+
encodeValue(item, depth + 1)
|
|
8751
|
+
]) };
|
|
8752
|
+
}
|
|
8753
|
+
if (isRecord(value)) {
|
|
8754
|
+
return { [mapMarker]: Object.entries(value).map(([key, item]) => [
|
|
8755
|
+
encodeValue(key, depth + 1),
|
|
8756
|
+
encodeValue(item, depth + 1)
|
|
8757
|
+
]) };
|
|
8758
|
+
}
|
|
8759
|
+
throw new TypeError(`unsupported HTTP command value: ${typeof value}`);
|
|
8760
|
+
}
|
|
8761
|
+
function decodeValue2(value, depth) {
|
|
8762
|
+
if (depth > maxDepth) throw new TypeError("HTTP response value exceeds maximum depth");
|
|
8763
|
+
if (Array.isArray(value)) return denseArray(value, depth + 1, decodeValue2);
|
|
8764
|
+
if (!isRecord(value)) return value;
|
|
8765
|
+
if (Object.keys(value).length === 1 && typeof value[bytesMarker] === "string") {
|
|
8766
|
+
return decodeBase64(value[bytesMarker]);
|
|
8767
|
+
}
|
|
8768
|
+
if (Object.keys(value).length === 1 && Array.isArray(value[mapMarker])) {
|
|
8769
|
+
const result = /* @__PURE__ */ new Map();
|
|
8770
|
+
for (const pair of value[mapMarker]) {
|
|
8771
|
+
if (!Array.isArray(pair) || pair.length !== 2) throw new TypeError("invalid HTTP map marker");
|
|
8772
|
+
result.set(decodeValue2(pair[0], depth + 1), decodeValue2(pair[1], depth + 1));
|
|
8773
|
+
}
|
|
8774
|
+
return result;
|
|
8775
|
+
}
|
|
8776
|
+
return decodePlainRecord(value, depth + 1);
|
|
8777
|
+
}
|
|
8778
|
+
function decodeBase64(value) {
|
|
8779
|
+
if (value.length % 4 !== 0 || !/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(value)) {
|
|
8780
|
+
throw new TypeError("invalid HTTP bytes marker");
|
|
8781
|
+
}
|
|
8782
|
+
const decoded = import_node_buffer33.Buffer.from(value, "base64");
|
|
8783
|
+
if (decoded.toString("base64") !== value) throw new TypeError("invalid HTTP bytes marker");
|
|
8784
|
+
return decoded;
|
|
8785
|
+
}
|
|
8786
|
+
function decodePlainRecord(value, depth) {
|
|
8787
|
+
const result = {};
|
|
8788
|
+
for (const [key, item] of Object.entries(value)) result[key] = decodeValue2(item, depth);
|
|
8789
|
+
return result;
|
|
8790
|
+
}
|
|
8791
|
+
function denseArray(values, depth, transform) {
|
|
8792
|
+
const result = new Array(values.length);
|
|
8793
|
+
for (let index = 0; index < values.length; index += 1) {
|
|
8794
|
+
if (!Object.hasOwn(values, index)) throw new TypeError("HTTP command arrays must be dense");
|
|
8795
|
+
result[index] = transform(values[index], depth);
|
|
8796
|
+
}
|
|
8797
|
+
return result;
|
|
8798
|
+
}
|
|
8799
|
+
function isRecord(value) {
|
|
8800
|
+
return typeof value === "object" && value != null && !Array.isArray(value) && !import_node_buffer33.Buffer.isBuffer(value);
|
|
8801
|
+
}
|
|
8802
|
+
|
|
8803
|
+
// src/http-options.ts
|
|
8804
|
+
function normalizeHTTPOptions(value, options) {
|
|
8805
|
+
const url = new URL(value);
|
|
8806
|
+
if (url.protocol !== "http:" && url.protocol !== "https:") {
|
|
8807
|
+
throw new TypeError(`unsupported HTTP URL scheme: ${url.protocol}`);
|
|
8808
|
+
}
|
|
8809
|
+
if (url.username !== "" || url.password !== "") throw new TypeError("HTTP URL userinfo is not allowed");
|
|
8810
|
+
if (url.search !== "" || url.hash !== "") throw new TypeError("HTTP base URL cannot contain query or fragment");
|
|
8811
|
+
const headers = normalizedHeaders(options.headers ?? {});
|
|
8812
|
+
const authorization = authorizationHeader(url, options, headers.authorization);
|
|
8813
|
+
if (authorization != null) headers.authorization = authorization;
|
|
8814
|
+
url.pathname = `${url.pathname.replace(/\/$/u, "")}/v1/commands`;
|
|
8815
|
+
return Object.freeze({
|
|
8816
|
+
commandUrl: url,
|
|
8817
|
+
headers: Object.freeze(headers),
|
|
8818
|
+
http2: booleanOption(options.http2, false, "http2"),
|
|
8819
|
+
maxBatchItems: positiveInteger(options.maxBatchItems, 1e3, "maxBatchItems"),
|
|
8820
|
+
maxConnections: positiveInteger(options.maxConnections, 100, "maxConnections"),
|
|
8821
|
+
maxRedirects: nonNegativeInteger(options.maxRedirects, 20, "maxRedirects"),
|
|
8822
|
+
maxRequestBytes: positiveInteger(options.maxRequestBytes, 1024 * 1024, "maxRequestBytes"),
|
|
8823
|
+
maxResponseBytes: positiveInteger(options.maxResponseBytes, 16 * 1024 * 1024, "maxResponseBytes"),
|
|
8824
|
+
timeoutMs: positiveInteger(options.timeoutMs, 3e4, "timeoutMs"),
|
|
8825
|
+
tlsOptions: Object.freeze({ ...options.tlsOptions ?? {} })
|
|
8826
|
+
});
|
|
8827
|
+
}
|
|
8828
|
+
function normalizedHeaders(source) {
|
|
8829
|
+
const headers = {};
|
|
8830
|
+
for (const [rawName, value] of Object.entries(source)) {
|
|
8831
|
+
const name = rawName.toLowerCase();
|
|
8832
|
+
if (name === "" || !safeHeader(name) || !safeHeader(value)) {
|
|
8833
|
+
throw new TypeError(`invalid HTTP header: ${rawName}`);
|
|
8834
|
+
}
|
|
8835
|
+
headers[name] = value;
|
|
8836
|
+
}
|
|
8837
|
+
return headers;
|
|
8838
|
+
}
|
|
8839
|
+
function authorizationHeader(url, options, custom) {
|
|
8840
|
+
const basic = options.username != null || options.password != null;
|
|
8841
|
+
const count = Number(custom != null) + Number(options.bearerToken != null) + Number(basic);
|
|
8842
|
+
if (count > 1) throw new TypeError("HTTP credentials are mutually exclusive");
|
|
8843
|
+
if (options.bearerToken != null) {
|
|
8844
|
+
if (!safeHeader(options.bearerToken)) throw new TypeError("invalid bearer token");
|
|
8845
|
+
return `Bearer ${options.bearerToken}`;
|
|
8846
|
+
}
|
|
8847
|
+
if (!basic) return custom;
|
|
8848
|
+
if (url.protocol !== "https:") throw new TypeError("Basic authentication requires HTTPS");
|
|
8849
|
+
if (typeof options.password !== "string") throw new TypeError("Basic authentication requires a password");
|
|
8850
|
+
const username = options.username ?? "default";
|
|
8851
|
+
if (username === "" || username.includes(":") || !safeHeader(username) || !safeHeader(options.password)) {
|
|
8852
|
+
throw new TypeError("invalid Basic authentication credentials");
|
|
8853
|
+
}
|
|
8854
|
+
return `Basic ${Buffer.from(`${username}:${options.password}`).toString("base64")}`;
|
|
8855
|
+
}
|
|
8856
|
+
function positiveInteger(value, fallback, name) {
|
|
8857
|
+
const result = value ?? fallback;
|
|
8858
|
+
if (!Number.isSafeInteger(result) || result <= 0) throw new TypeError(`${name} must be a positive integer`);
|
|
8859
|
+
return result;
|
|
8860
|
+
}
|
|
8861
|
+
function nonNegativeInteger(value, fallback, name) {
|
|
8862
|
+
const result = value ?? fallback;
|
|
8863
|
+
if (!Number.isSafeInteger(result) || result < 0) throw new TypeError(`${name} must be a non-negative integer`);
|
|
8864
|
+
return result;
|
|
8865
|
+
}
|
|
8866
|
+
function booleanOption(value, fallback, name) {
|
|
8867
|
+
const result = value ?? fallback;
|
|
8868
|
+
if (typeof result !== "boolean") throw new TypeError(`${name} must be a boolean`);
|
|
8869
|
+
return result;
|
|
8870
|
+
}
|
|
8871
|
+
function safeHeader(value) {
|
|
8872
|
+
return !value.includes("\r") && !value.includes("\n");
|
|
8873
|
+
}
|
|
8874
|
+
|
|
8875
|
+
// src/http-transport.ts
|
|
8876
|
+
var import_node_http = __toESM(require("http"), 1);
|
|
8877
|
+
var import_node_http2 = __toESM(require("http2"), 1);
|
|
8878
|
+
var import_node_https = __toESM(require("https"), 1);
|
|
8879
|
+
var import_node_buffer34 = require("buffer");
|
|
8880
|
+
var HTTPTransport = class {
|
|
8881
|
+
constructor(config) {
|
|
8882
|
+
this.config = config;
|
|
8883
|
+
this.#httpAgent = new import_node_http.default.Agent({ keepAlive: true, maxSockets: config.maxConnections });
|
|
8884
|
+
this.#httpsAgent = new import_node_https.default.Agent({
|
|
8885
|
+
...config.tlsOptions,
|
|
8886
|
+
keepAlive: true,
|
|
8887
|
+
maxSockets: config.maxConnections
|
|
8888
|
+
});
|
|
8889
|
+
}
|
|
8890
|
+
config;
|
|
8891
|
+
#httpAgent;
|
|
8892
|
+
#httpsAgent;
|
|
8893
|
+
#sessions = /* @__PURE__ */ new Map();
|
|
8894
|
+
#closed = false;
|
|
8895
|
+
async post(body) {
|
|
8896
|
+
if (this.#closed) throw new HTTPTransportError("HTTP transport is closed");
|
|
8897
|
+
const controller = new AbortController();
|
|
8898
|
+
const timer = setTimeout(() => controller.abort(), this.config.timeoutMs);
|
|
8899
|
+
try {
|
|
8900
|
+
return await this.request(this.config.commandUrl, "POST", body, 0, controller.signal);
|
|
8901
|
+
} catch (error) {
|
|
8902
|
+
if (controller.signal.aborted) {
|
|
8903
|
+
throw new RequestTimeoutError(this.config.timeoutMs, "possibly_sent", {
|
|
8904
|
+
cause: error,
|
|
8905
|
+
raw: { retryable: true, safe_to_retry: false }
|
|
8906
|
+
});
|
|
8907
|
+
}
|
|
8908
|
+
if (error instanceof HTTPTransportError || error instanceof RequestTimeoutError) throw error;
|
|
8909
|
+
throw new HTTPTransportError("HTTP command request failed", {
|
|
8910
|
+
cause: error,
|
|
8911
|
+
retryable: true,
|
|
8912
|
+
safeToRetry: false
|
|
8913
|
+
});
|
|
8914
|
+
} finally {
|
|
8915
|
+
clearTimeout(timer);
|
|
8916
|
+
}
|
|
8917
|
+
}
|
|
8918
|
+
async close() {
|
|
8919
|
+
if (this.#closed) return;
|
|
8920
|
+
this.#closed = true;
|
|
8921
|
+
this.#httpAgent.destroy();
|
|
8922
|
+
this.#httpsAgent.destroy();
|
|
8923
|
+
for (const session of this.#sessions.values()) session.destroy();
|
|
8924
|
+
this.#sessions.clear();
|
|
8925
|
+
}
|
|
8926
|
+
async request(url, method, body, redirects, signal) {
|
|
8927
|
+
const response = this.config.http2 ? await this.http2Request(url, method, body, signal) : await this.http1Request(url, method, body, signal);
|
|
8928
|
+
if (![301, 302, 303, 307, 308].includes(response.status)) return response;
|
|
8929
|
+
if (redirects >= this.config.maxRedirects) throw new HTTPTransportError("too many HTTP redirects");
|
|
8930
|
+
const location = response.headers.location;
|
|
8931
|
+
if (location == null || location === "") throw new HTTPTransportError("HTTP redirect has no location");
|
|
8932
|
+
const target = new URL(location, url);
|
|
8933
|
+
if (target.protocol !== "http:" && target.protocol !== "https:") {
|
|
8934
|
+
throw new HTTPTransportError("HTTP redirect has an unsupported scheme");
|
|
8935
|
+
}
|
|
8936
|
+
const switchToGet = [301, 302, 303].includes(response.status);
|
|
8937
|
+
return await this.request(
|
|
8938
|
+
target,
|
|
8939
|
+
switchToGet ? "GET" : method,
|
|
8940
|
+
switchToGet ? void 0 : body,
|
|
8941
|
+
redirects + 1,
|
|
8942
|
+
signal
|
|
8943
|
+
);
|
|
8944
|
+
}
|
|
8945
|
+
async http1Request(url, method, body, signal) {
|
|
8946
|
+
const request = url.protocol === "https:" ? import_node_https.default.request : import_node_http.default.request;
|
|
8947
|
+
const agent = url.protocol === "https:" ? this.#httpsAgent : this.#httpAgent;
|
|
8948
|
+
const headers = this.requestHeaders(body);
|
|
8949
|
+
return await new Promise((resolve, reject) => {
|
|
8950
|
+
const outgoing = request(url, { agent, headers, method, signal }, (response) => {
|
|
8951
|
+
void this.collectHttp1(response).then(resolve, reject);
|
|
8952
|
+
});
|
|
8953
|
+
outgoing.once("error", reject);
|
|
8954
|
+
outgoing.end(body);
|
|
8955
|
+
});
|
|
8956
|
+
}
|
|
8957
|
+
async collectHttp1(response) {
|
|
8958
|
+
const declared = headerValue(response.headers["content-length"]);
|
|
8959
|
+
if (declared != null && Number(declared) > this.config.maxResponseBytes) {
|
|
8960
|
+
response.destroy();
|
|
8961
|
+
throw new HTTPTransportError("HTTP response exceeds maxResponseBytes");
|
|
8962
|
+
}
|
|
8963
|
+
return await collectBody(
|
|
8964
|
+
response,
|
|
8965
|
+
response.statusCode ?? 0,
|
|
8966
|
+
normalizeHeaders(response.headers),
|
|
8967
|
+
this.config.maxResponseBytes
|
|
8968
|
+
);
|
|
8969
|
+
}
|
|
8970
|
+
async http2Request(url, method, body, signal) {
|
|
8971
|
+
const session = this.session(url);
|
|
8972
|
+
const headers = {
|
|
8973
|
+
...this.requestHeaders(body),
|
|
8974
|
+
":authority": url.host,
|
|
8975
|
+
":method": method,
|
|
8976
|
+
":path": `${url.pathname}${url.search}`,
|
|
8977
|
+
":scheme": url.protocol.slice(0, -1)
|
|
8978
|
+
};
|
|
8979
|
+
return await new Promise((resolve, reject) => {
|
|
8980
|
+
const stream = session.request(headers);
|
|
8981
|
+
let responseHeaders = {};
|
|
8982
|
+
const abort = () => stream.close(import_node_http2.default.constants.NGHTTP2_CANCEL);
|
|
8983
|
+
signal.addEventListener("abort", abort, { once: true });
|
|
8984
|
+
stream.once("response", (value) => responseHeaders = value);
|
|
8985
|
+
stream.once("error", reject);
|
|
8986
|
+
void collectBody(stream, 0, {}, this.config.maxResponseBytes).then((response) => {
|
|
8987
|
+
const status = Number(responseHeaders[":status"] ?? 0);
|
|
8988
|
+
resolve({ body: response.body, headers: normalizeHeaders(responseHeaders), status });
|
|
8989
|
+
}, reject).finally(() => signal.removeEventListener("abort", abort));
|
|
8990
|
+
stream.end(body);
|
|
8991
|
+
});
|
|
8992
|
+
}
|
|
8993
|
+
session(url) {
|
|
8994
|
+
const origin = url.origin;
|
|
8995
|
+
const current = this.#sessions.get(origin);
|
|
8996
|
+
if (current != null && !current.closed && !current.destroyed) return current;
|
|
8997
|
+
const session = import_node_http2.default.connect(origin, this.config.tlsOptions);
|
|
8998
|
+
session.on("error", () => void 0);
|
|
8999
|
+
session.once("close", () => this.#sessions.delete(origin));
|
|
9000
|
+
this.#sessions.set(origin, session);
|
|
9001
|
+
return session;
|
|
9002
|
+
}
|
|
9003
|
+
requestHeaders(body) {
|
|
9004
|
+
const headers = { ...this.config.headers };
|
|
9005
|
+
delete headers["content-length"];
|
|
9006
|
+
delete headers["content-type"];
|
|
9007
|
+
return {
|
|
9008
|
+
...headers,
|
|
9009
|
+
accept: "application/json",
|
|
9010
|
+
...body == null ? {} : { "content-length": body.byteLength, "content-type": "application/json" }
|
|
9011
|
+
};
|
|
9012
|
+
}
|
|
9013
|
+
};
|
|
9014
|
+
async function collectBody(source, status, headers, maximum) {
|
|
9015
|
+
const chunks = [];
|
|
9016
|
+
let size = 0;
|
|
9017
|
+
for await (const chunk of source) {
|
|
9018
|
+
const bytes2 = import_node_buffer34.Buffer.from(chunk);
|
|
9019
|
+
size += bytes2.byteLength;
|
|
9020
|
+
if (size > maximum) {
|
|
9021
|
+
const destroy = source.destroy;
|
|
9022
|
+
if (destroy != null) destroy.call(source);
|
|
9023
|
+
throw new HTTPTransportError("HTTP response exceeds maxResponseBytes");
|
|
9024
|
+
}
|
|
9025
|
+
chunks.push(bytes2);
|
|
9026
|
+
}
|
|
9027
|
+
return { body: import_node_buffer34.Buffer.concat(chunks, size), headers, status };
|
|
9028
|
+
}
|
|
9029
|
+
function normalizeHeaders(headers) {
|
|
9030
|
+
const result = {};
|
|
9031
|
+
for (const [name, raw] of Object.entries(headers)) {
|
|
9032
|
+
const value = headerValue(raw);
|
|
9033
|
+
if (value != null) result[name.toLowerCase()] = value;
|
|
9034
|
+
}
|
|
9035
|
+
return result;
|
|
9036
|
+
}
|
|
9037
|
+
function headerValue(value) {
|
|
9038
|
+
if (Array.isArray(value)) return value.join(", ");
|
|
9039
|
+
return value == null ? void 0 : String(value);
|
|
9040
|
+
}
|
|
9041
|
+
|
|
9042
|
+
// src/http-adapter.ts
|
|
9043
|
+
var HTTPAdapter = class _HTTPAdapter {
|
|
9044
|
+
#config;
|
|
9045
|
+
#transport;
|
|
9046
|
+
static async fromUrl(url, options = {}) {
|
|
9047
|
+
return new _HTTPAdapter(normalizeHTTPOptions(url, options));
|
|
9048
|
+
}
|
|
9049
|
+
constructor(config) {
|
|
9050
|
+
this.#config = config;
|
|
9051
|
+
this.#transport = new HTTPTransport(config);
|
|
9052
|
+
}
|
|
9053
|
+
async executeCommand(...args) {
|
|
9054
|
+
return await this.executeCommandArgs(args);
|
|
9055
|
+
}
|
|
9056
|
+
async executeCommandArgs(args) {
|
|
9057
|
+
const [result] = await this.executeBatch([args]);
|
|
9058
|
+
if (result == null) throw new HTTPTransportError("HTTP response omitted a command result");
|
|
9059
|
+
if (result.status === "error") throw commandError(result.error);
|
|
9060
|
+
return result.value;
|
|
9061
|
+
}
|
|
9062
|
+
async executePipeline(commands, options = {}) {
|
|
9063
|
+
const results = await this.executeBatch(commands);
|
|
9064
|
+
const values = results.map((result) => result.status === "ok" ? result.value : commandError(result.error));
|
|
9065
|
+
if (options.throwOnItemError !== false) {
|
|
9066
|
+
const failure = values.find((value) => value instanceof Error);
|
|
9067
|
+
if (failure instanceof Error) throw failure;
|
|
9068
|
+
}
|
|
9069
|
+
return values;
|
|
9070
|
+
}
|
|
9071
|
+
async executeFusedPipeline(commands, options = {}) {
|
|
9072
|
+
return await this.executePipeline(commands, options);
|
|
9073
|
+
}
|
|
9074
|
+
async close() {
|
|
9075
|
+
await this.#transport.close();
|
|
9076
|
+
}
|
|
9077
|
+
async executeBatch(commands) {
|
|
9078
|
+
if (commands.length > this.#config.maxBatchItems) {
|
|
9079
|
+
throw new HTTPTransportError("HTTP command batch exceeds maxBatchItems");
|
|
9080
|
+
}
|
|
9081
|
+
for (const command of commands) assertHTTPCommandSupported(command[0]);
|
|
9082
|
+
const body = encodeHTTPCommands(commands.map((command) => httpCommand(command, this.#config.maxRequestBytes)));
|
|
9083
|
+
if (body.byteLength > this.#config.maxRequestBytes) {
|
|
9084
|
+
throw new HTTPTransportError("HTTP command request exceeds maxRequestBytes");
|
|
9085
|
+
}
|
|
9086
|
+
const response = await this.#transport.post(body);
|
|
9087
|
+
let envelope = {};
|
|
9088
|
+
try {
|
|
9089
|
+
if (response.body.byteLength > 0) envelope = decodeHTTPEnvelope(response.body);
|
|
9090
|
+
} catch (error) {
|
|
9091
|
+
if (response.status >= 200 && response.status < 300) throw error;
|
|
9092
|
+
}
|
|
9093
|
+
if (response.status < 200 || response.status >= 300) throw topLevelError(
|
|
9094
|
+
response.status,
|
|
9095
|
+
envelope,
|
|
9096
|
+
response.headers["retry-after"]
|
|
9097
|
+
);
|
|
9098
|
+
if (envelope.encoding !== "ferricstore-json-v1") {
|
|
9099
|
+
throw new HTTPTransportError("HTTP response has an unsupported encoding");
|
|
9100
|
+
}
|
|
9101
|
+
if (!Array.isArray(envelope.results) || envelope.results.length !== commands.length) {
|
|
9102
|
+
throw new HTTPTransportError("HTTP response result count does not match the command batch");
|
|
9103
|
+
}
|
|
9104
|
+
return envelope.results.map((result) => validatedResult(result));
|
|
9105
|
+
}
|
|
9106
|
+
};
|
|
9107
|
+
var commandNamesByOpcode = new Map(
|
|
9108
|
+
Object.entries(COMMAND_OPCODES).map(([name, opcode]) => [opcode, name])
|
|
9109
|
+
);
|
|
9110
|
+
function httpCommand(command, maxRequestBytes) {
|
|
9111
|
+
const protocol = buildProtocolCommand(command, maxRequestBytes, false);
|
|
9112
|
+
if (protocol.opcode === OPCODES.commandExec) return command;
|
|
9113
|
+
const name = commandNamesByOpcode.get(protocol.opcode);
|
|
9114
|
+
if (name == null) throw new HTTPTransportError(`HTTP command has unknown opcode ${protocol.opcode}`);
|
|
9115
|
+
return { command: name, opcode: protocol.opcode, payload: protocol.payload ?? {} };
|
|
9116
|
+
}
|
|
9117
|
+
function validatedResult(value) {
|
|
9118
|
+
if (!isRecord2(value)) throw new HTTPTransportError("HTTP response has an invalid result item");
|
|
9119
|
+
if (value.status === "ok" && Object.hasOwn(value, "value")) {
|
|
9120
|
+
return { status: "ok", value: value.value };
|
|
9121
|
+
}
|
|
9122
|
+
if (value.status === "error" && isRecord2(value.error)) {
|
|
9123
|
+
return { error: value.error, status: "error" };
|
|
9124
|
+
}
|
|
9125
|
+
throw new HTTPTransportError("HTTP response has an invalid result item");
|
|
9126
|
+
}
|
|
9127
|
+
function commandError(value) {
|
|
9128
|
+
const message = isRecord2(value) && typeof value.message === "string" ? value.message : "FerricStore command failed";
|
|
9129
|
+
const code = isRecord2(value) && typeof value.code === "string" ? value.code : void 0;
|
|
9130
|
+
return classifyServerError(message, value, void 0, code);
|
|
9131
|
+
}
|
|
9132
|
+
function topLevelError(status, envelope, retryAfter) {
|
|
9133
|
+
const details = isRecord2(envelope.error) ? envelope.error : {};
|
|
9134
|
+
const message = typeof details.message === "string" ? details.message : `HTTP command request failed with status ${status}`;
|
|
9135
|
+
const retryAfterMs2 = retryAfter == null || !/^\d+$/u.test(retryAfter) ? void 0 : Number(retryAfter) * 1e3;
|
|
9136
|
+
return new HTTPTransportError(message, {
|
|
9137
|
+
raw: details,
|
|
9138
|
+
retryable: status === 408 || status === 425 || status === 429 || status >= 500,
|
|
9139
|
+
retryAfterMs: retryAfterMs2,
|
|
9140
|
+
safeToRetry: false,
|
|
9141
|
+
statusCode: status
|
|
9142
|
+
});
|
|
9143
|
+
}
|
|
9144
|
+
function isRecord2(value) {
|
|
9145
|
+
return typeof value === "object" && value != null && !Array.isArray(value);
|
|
9146
|
+
}
|
|
9147
|
+
|
|
8646
9148
|
// src/adapters.ts
|
|
8647
9149
|
function executeCommandArgs(executor, args) {
|
|
8648
9150
|
if (executor.executeCommandArgs != null) return executor.executeCommandArgs(args);
|
|
@@ -8651,10 +9153,10 @@ function executeCommandArgs(executor, args) {
|
|
|
8651
9153
|
}
|
|
8652
9154
|
|
|
8653
9155
|
// src/reconnecting-executor.ts
|
|
8654
|
-
var
|
|
9156
|
+
var import_node_buffer36 = require("buffer");
|
|
8655
9157
|
|
|
8656
9158
|
// src/command-retry-policy.ts
|
|
8657
|
-
var
|
|
9159
|
+
var import_node_buffer35 = require("buffer");
|
|
8658
9160
|
function isCasMutation(args) {
|
|
8659
9161
|
const offset = commandName2(args[0]) === "COMMAND_EXEC" ? 1 : 0;
|
|
8660
9162
|
const name = commandName2(args[offset]);
|
|
@@ -8668,8 +9170,8 @@ function isCasMutation(args) {
|
|
|
8668
9170
|
}
|
|
8669
9171
|
function commandName2(value) {
|
|
8670
9172
|
if (typeof value === "string") return value.toUpperCase();
|
|
8671
|
-
if (
|
|
8672
|
-
return
|
|
9173
|
+
if (import_node_buffer35.Buffer.isBuffer(value) || value instanceof Uint8Array) {
|
|
9174
|
+
return import_node_buffer35.Buffer.from(value).toString("utf8").toUpperCase();
|
|
8673
9175
|
}
|
|
8674
9176
|
return void 0;
|
|
8675
9177
|
}
|
|
@@ -8881,15 +9383,15 @@ function normalizeNonNegativeInteger2(value, fallback) {
|
|
|
8881
9383
|
}
|
|
8882
9384
|
|
|
8883
9385
|
// src/topology.ts
|
|
8884
|
-
var
|
|
9386
|
+
var import_node_buffer39 = require("buffer");
|
|
8885
9387
|
|
|
8886
9388
|
// src/topology-routing.ts
|
|
8887
|
-
var
|
|
9389
|
+
var import_node_buffer38 = require("buffer");
|
|
8888
9390
|
|
|
8889
9391
|
// src/flow-partition-route-cache.ts
|
|
8890
|
-
var
|
|
9392
|
+
var import_node_buffer37 = require("buffer");
|
|
8891
9393
|
var import_node_crypto = require("crypto");
|
|
8892
|
-
var AUTO_PREFIX =
|
|
9394
|
+
var AUTO_PREFIX = import_node_buffer37.Buffer.from("__flow_auto__:", "ascii");
|
|
8893
9395
|
var MAX_CACHEABLE_PARTITION_BYTES = 4 * 1024;
|
|
8894
9396
|
var MAX_CACHE_BYTES = 1 * 1024 * 1024;
|
|
8895
9397
|
var MAX_CACHE_ENTRIES = 1024;
|
|
@@ -8899,10 +9401,10 @@ var cacheBytes = 0;
|
|
|
8899
9401
|
var cacheHits = 0;
|
|
8900
9402
|
var cacheMisses = 0;
|
|
8901
9403
|
function flowLogicalPartitionRoutingKey(value) {
|
|
8902
|
-
if (typeof value !== "string" && !
|
|
9404
|
+
if (typeof value !== "string" && !import_node_buffer37.Buffer.isBuffer(value)) return void 0;
|
|
8903
9405
|
const autoBucket = flowAutoBucket(value);
|
|
8904
9406
|
if (autoBucket != null) return `{fa:${autoBucket}}`;
|
|
8905
|
-
const bytes2 =
|
|
9407
|
+
const bytes2 = import_node_buffer37.Buffer.isBuffer(value) ? value : import_node_buffer37.Buffer.from(value);
|
|
8906
9408
|
if (bytes2.byteLength > MAX_CACHEABLE_PARTITION_BYTES) return hashRoute(bytes2);
|
|
8907
9409
|
const cacheKey = bytes2.toString("base64");
|
|
8908
9410
|
const cached = routeCache.get(cacheKey);
|
|
@@ -8976,7 +9478,7 @@ function routingKeyFromProtocolPayload(name, command) {
|
|
|
8976
9478
|
"scope"
|
|
8977
9479
|
]) {
|
|
8978
9480
|
const value = getField(command.payload, field3);
|
|
8979
|
-
if (typeof value === "string" ||
|
|
9481
|
+
if (typeof value === "string" || import_node_buffer38.Buffer.isBuffer(value)) {
|
|
8980
9482
|
return value;
|
|
8981
9483
|
}
|
|
8982
9484
|
}
|
|
@@ -9024,7 +9526,7 @@ function flowRoutingData(name, args) {
|
|
|
9024
9526
|
if (typeof partition === "string" && partition.toUpperCase() !== "AUTO" && partition.toUpperCase() !== "MIXED") {
|
|
9025
9527
|
return flowRoutingResult(flowLogicalPartitionRoutingKey(partition));
|
|
9026
9528
|
}
|
|
9027
|
-
if (
|
|
9529
|
+
if (import_node_buffer38.Buffer.isBuffer(partition)) {
|
|
9028
9530
|
const text3 = partition.toString("utf8").toUpperCase();
|
|
9029
9531
|
if (text3 !== "AUTO" && text3 !== "MIXED") {
|
|
9030
9532
|
return flowRoutingResult(flowLogicalPartitionRoutingKey(partition));
|
|
@@ -9115,17 +9617,17 @@ function flowPartitionRoutingKeyFromCommand(command, claim) {
|
|
|
9115
9617
|
return { handled: false };
|
|
9116
9618
|
}
|
|
9117
9619
|
function isRoutingKey(value) {
|
|
9118
|
-
return typeof value === "string" ||
|
|
9620
|
+
return typeof value === "string" || import_node_buffer38.Buffer.isBuffer(value);
|
|
9119
9621
|
}
|
|
9120
9622
|
function flowAutoIdRoutingKey(value) {
|
|
9121
|
-
if (typeof value !== "string" && !
|
|
9623
|
+
if (typeof value !== "string" && !import_node_buffer38.Buffer.isBuffer(value)) {
|
|
9122
9624
|
return void 0;
|
|
9123
9625
|
}
|
|
9124
|
-
const bucket = (
|
|
9626
|
+
const bucket = (import_node_buffer38.Buffer.isBuffer(value) ? crc32(value) : crc32Utf8(value)) & 255;
|
|
9125
9627
|
return `{fa:${bucket}}`;
|
|
9126
9628
|
}
|
|
9127
9629
|
function flowClaimLogicalPartitionRoutingKey(value) {
|
|
9128
|
-
if (typeof value !== "string" && !
|
|
9630
|
+
if (typeof value !== "string" && !import_node_buffer38.Buffer.isBuffer(value)) return void 0;
|
|
9129
9631
|
const selector = commandPart(value);
|
|
9130
9632
|
if (selector === "AUTO" || selector === "ANY") return void 0;
|
|
9131
9633
|
if (selector === "GLOBAL") return "{f}";
|
|
@@ -9140,7 +9642,7 @@ function singleShardFlowClaimPartitionKey(values) {
|
|
|
9140
9642
|
return keys.some((key) => key == null) ? void 0 : singleShardKey(keys);
|
|
9141
9643
|
}
|
|
9142
9644
|
function singleShardKey(keys) {
|
|
9143
|
-
if (keys.length === 0 || keys.some((key) => typeof key !== "string" && !
|
|
9645
|
+
if (keys.length === 0 || keys.some((key) => typeof key !== "string" && !import_node_buffer38.Buffer.isBuffer(key))) {
|
|
9144
9646
|
return void 0;
|
|
9145
9647
|
}
|
|
9146
9648
|
const usable = keys;
|
|
@@ -9173,7 +9675,7 @@ function routedKeyGroups(keys, routeKey) {
|
|
|
9173
9675
|
const groups = /* @__PURE__ */ new Map();
|
|
9174
9676
|
for (let index = 0; index < keys.length; index += 1) {
|
|
9175
9677
|
const key = keys[index];
|
|
9176
|
-
if (typeof key !== "string" && !
|
|
9678
|
+
if (typeof key !== "string" && !import_node_buffer38.Buffer.isBuffer(key)) return void 0;
|
|
9177
9679
|
const route = routeKey(key);
|
|
9178
9680
|
const groupKey = `${route.endpointKey}\0${route.laneId}`;
|
|
9179
9681
|
const group = groups.get(groupKey);
|
|
@@ -10262,7 +10764,7 @@ var TopologyNativeAdapterPool = class _TopologyNativeAdapterPool {
|
|
|
10262
10764
|
};
|
|
10263
10765
|
|
|
10264
10766
|
// src/response-map-preservation.ts
|
|
10265
|
-
var
|
|
10767
|
+
var import_node_buffer40 = require("buffer");
|
|
10266
10768
|
function toStringKeyMapPreservingValues(value) {
|
|
10267
10769
|
if (value == null) return void 0;
|
|
10268
10770
|
const result = {};
|
|
@@ -10272,7 +10774,7 @@ function toStringKeyMapPreservingValues(value) {
|
|
|
10272
10774
|
}
|
|
10273
10775
|
return result;
|
|
10274
10776
|
}
|
|
10275
|
-
if (typeof value === "object" && !Array.isArray(value) && !
|
|
10777
|
+
if (typeof value === "object" && !Array.isArray(value) && !import_node_buffer40.Buffer.isBuffer(value) && !(value instanceof Uint8Array)) {
|
|
10276
10778
|
for (const [key, item] of Object.entries(value)) {
|
|
10277
10779
|
setOwnValue(result, text(key), normalizeMapStructurePreservingBytes(item));
|
|
10278
10780
|
}
|
|
@@ -10281,7 +10783,7 @@ function toStringKeyMapPreservingValues(value) {
|
|
|
10281
10783
|
return void 0;
|
|
10282
10784
|
}
|
|
10283
10785
|
function normalizeMapStructurePreservingBytes(value) {
|
|
10284
|
-
if (
|
|
10786
|
+
if (import_node_buffer40.Buffer.isBuffer(value) || value instanceof Uint8Array) return value;
|
|
10285
10787
|
if (value instanceof Map) {
|
|
10286
10788
|
const result = {};
|
|
10287
10789
|
for (const [key, item] of value.entries()) {
|
|
@@ -10303,7 +10805,7 @@ function normalizeMapStructurePreservingBytes(value) {
|
|
|
10303
10805
|
}
|
|
10304
10806
|
|
|
10305
10807
|
// src/native-kv-responses.ts
|
|
10306
|
-
var
|
|
10808
|
+
var import_node_buffer41 = require("buffer");
|
|
10307
10809
|
function rateLimitResultFromResp(value) {
|
|
10308
10810
|
if (!Array.isArray(value) || value.length !== 4) {
|
|
10309
10811
|
throw new TypeError("RATELIMIT.ADD returned an unexpected response");
|
|
@@ -10360,13 +10862,13 @@ function fetchOrComputeResultFromResp(value, codec) {
|
|
|
10360
10862
|
}
|
|
10361
10863
|
function decodePayload(codec, value) {
|
|
10362
10864
|
if (value == null) return null;
|
|
10363
|
-
if (
|
|
10364
|
-
if (value instanceof Uint8Array) return codec.decode(
|
|
10365
|
-
if (typeof value === "string") return codec.decode(
|
|
10865
|
+
if (import_node_buffer41.Buffer.isBuffer(value)) return codec.decode(value);
|
|
10866
|
+
if (value instanceof Uint8Array) return codec.decode(import_node_buffer41.Buffer.from(value));
|
|
10867
|
+
if (typeof value === "string") return codec.decode(import_node_buffer41.Buffer.from(value));
|
|
10366
10868
|
return normalizeRefMeta(value);
|
|
10367
10869
|
}
|
|
10368
10870
|
function requiredResponseString(value, context) {
|
|
10369
|
-
if (typeof value !== "string" && !
|
|
10871
|
+
if (typeof value !== "string" && !import_node_buffer41.Buffer.isBuffer(value) && !(value instanceof Uint8Array)) {
|
|
10370
10872
|
throw new TypeError(`${context} returned an unexpected response`);
|
|
10371
10873
|
}
|
|
10372
10874
|
const result = text(value);
|
|
@@ -10383,7 +10885,7 @@ function requiredNonNegativeInteger(value, context) {
|
|
|
10383
10885
|
return result;
|
|
10384
10886
|
}
|
|
10385
10887
|
function responseBytes(value, context) {
|
|
10386
|
-
if (typeof value !== "string" && !
|
|
10888
|
+
if (typeof value !== "string" && !import_node_buffer41.Buffer.isBuffer(value) && !(value instanceof Uint8Array)) {
|
|
10387
10889
|
throw new TypeError(`${context} returned an unexpected response`);
|
|
10388
10890
|
}
|
|
10389
10891
|
return bytes(value);
|
|
@@ -11066,7 +11568,7 @@ function groupAutoPartitionItems(items) {
|
|
|
11066
11568
|
}
|
|
11067
11569
|
|
|
11068
11570
|
// src/client-values.ts
|
|
11069
|
-
var
|
|
11571
|
+
var import_node_buffer42 = require("buffer");
|
|
11070
11572
|
async function valueMGetEntries(client, refs, options = {}) {
|
|
11071
11573
|
const refCount = refs.length;
|
|
11072
11574
|
if (refCount === 0) {
|
|
@@ -11101,12 +11603,12 @@ async function valueMGetEntries(client, refs, options = {}) {
|
|
|
11101
11603
|
const item = response[index];
|
|
11102
11604
|
if (item == null) {
|
|
11103
11605
|
entries[index] = { found: false };
|
|
11104
|
-
} else if (
|
|
11606
|
+
} else if (import_node_buffer42.Buffer.isBuffer(item)) {
|
|
11105
11607
|
entries[index] = { found: true, value: client.codec.decode(item) };
|
|
11106
11608
|
} else if (item instanceof Uint8Array) {
|
|
11107
|
-
entries[index] = { found: true, value: client.codec.decode(
|
|
11609
|
+
entries[index] = { found: true, value: client.codec.decode(import_node_buffer42.Buffer.from(item)) };
|
|
11108
11610
|
} else if (typeof item === "string") {
|
|
11109
|
-
entries[index] = { found: true, value: client.codec.decode(
|
|
11611
|
+
entries[index] = { found: true, value: client.codec.decode(import_node_buffer42.Buffer.from(item)) };
|
|
11110
11612
|
} else {
|
|
11111
11613
|
entries[index] = { found: true, value: item };
|
|
11112
11614
|
}
|
|
@@ -11115,10 +11617,10 @@ async function valueMGetEntries(client, refs, options = {}) {
|
|
|
11115
11617
|
}
|
|
11116
11618
|
|
|
11117
11619
|
// src/auto-batch.ts
|
|
11118
|
-
var
|
|
11620
|
+
var import_node_buffer44 = require("buffer");
|
|
11119
11621
|
|
|
11120
11622
|
// src/auto-batch-ordering.ts
|
|
11121
|
-
var
|
|
11623
|
+
var import_node_buffer43 = require("buffer");
|
|
11122
11624
|
function autoBatchOrderingPlan(batch) {
|
|
11123
11625
|
const accesses = /* @__PURE__ */ new Map();
|
|
11124
11626
|
const fallbackDependencies = [];
|
|
@@ -11233,13 +11735,13 @@ function flowManyAutoBatchIds(command, name) {
|
|
|
11233
11735
|
return fixedFlowItemIds(
|
|
11234
11736
|
command,
|
|
11235
11737
|
mixed ? 4 : 3,
|
|
11236
|
-
(itemIndex) => isAutoBatchResourceValue(command[itemIndex]) && (!mixed || isAutoBatchResourceValue(command[itemIndex + 1])) && isFencingToken(command[itemIndex + (mixed ? 2 : 1)]) &&
|
|
11738
|
+
(itemIndex) => isAutoBatchResourceValue(command[itemIndex]) && (!mixed || isAutoBatchResourceValue(command[itemIndex + 1])) && isFencingToken(command[itemIndex + (mixed ? 2 : 1)]) && import_node_buffer43.Buffer.isBuffer(command[itemIndex + (mixed ? 3 : 2)])
|
|
11237
11739
|
);
|
|
11238
11740
|
}
|
|
11239
11741
|
return fixedFlowItemIds(
|
|
11240
11742
|
command,
|
|
11241
11743
|
mixed ? 4 : 3,
|
|
11242
|
-
(itemIndex) => isAutoBatchResourceValue(command[itemIndex]) && (!mixed || isAutoBatchResourceValue(command[itemIndex + 1])) &&
|
|
11744
|
+
(itemIndex) => isAutoBatchResourceValue(command[itemIndex]) && (!mixed || isAutoBatchResourceValue(command[itemIndex + 1])) && import_node_buffer43.Buffer.isBuffer(command[itemIndex + (mixed ? 2 : 1)]) && isFencingToken(command[itemIndex + (mixed ? 3 : 2)])
|
|
11243
11745
|
);
|
|
11244
11746
|
}
|
|
11245
11747
|
function createManyAutoBatchIds(command) {
|
|
@@ -11252,7 +11754,7 @@ function createManyAutoBatchIds(command) {
|
|
|
11252
11754
|
const ids = fixedFlowItemIds(
|
|
11253
11755
|
command,
|
|
11254
11756
|
width,
|
|
11255
|
-
(itemIndex) => isAutoBatchResourceValue(command[itemIndex]) && (!mixed || isAutoBatchResourceValue(command[itemIndex + 1])) &&
|
|
11757
|
+
(itemIndex) => isAutoBatchResourceValue(command[itemIndex]) && (!mixed || isAutoBatchResourceValue(command[itemIndex + 1])) && import_node_buffer43.Buffer.isBuffer(command[itemIndex + width - 1]),
|
|
11256
11758
|
markerIndex
|
|
11257
11759
|
);
|
|
11258
11760
|
if (ids != null) return ids;
|
|
@@ -11270,7 +11772,7 @@ function extendedCreateManyAutoBatchIds(command, markerIndex) {
|
|
|
11270
11772
|
let cursor = markerIndex + 2;
|
|
11271
11773
|
for (let itemIndex = 0; itemIndex < itemCount; itemIndex += 1) {
|
|
11272
11774
|
const id = command[cursor];
|
|
11273
|
-
if (!isAutoBatchResourceValue(id) || !isAutoBatchResourceValue(command[cursor + 1]) || !
|
|
11775
|
+
if (!isAutoBatchResourceValue(id) || !isAutoBatchResourceValue(command[cursor + 1]) || !import_node_buffer43.Buffer.isBuffer(command[cursor + 2])) return void 0;
|
|
11274
11776
|
ids.push(id);
|
|
11275
11777
|
cursor += 3;
|
|
11276
11778
|
const afterValues = skipExtendedNamedItems(command, cursor, true);
|
|
@@ -11289,7 +11791,7 @@ function skipExtendedNamedItems(command, countIndex, encodedValues) {
|
|
|
11289
11791
|
for (let index = 0; index < count; index += 1) {
|
|
11290
11792
|
const name = command[firstItem + index * 2];
|
|
11291
11793
|
const value = command[firstItem + index * 2 + 1];
|
|
11292
|
-
if (!isAutoBatchResourceValue(name) || (encodedValues ? !
|
|
11794
|
+
if (!isAutoBatchResourceValue(name) || (encodedValues ? !import_node_buffer43.Buffer.isBuffer(value) : !isAutoBatchResourceValue(value))) return void 0;
|
|
11293
11795
|
}
|
|
11294
11796
|
return firstItem + count * 2;
|
|
11295
11797
|
}
|
|
@@ -11304,7 +11806,7 @@ function runStepsManyAutoBatchIds(command) {
|
|
|
11304
11806
|
ids.push(item);
|
|
11305
11807
|
continue;
|
|
11306
11808
|
}
|
|
11307
|
-
if (typeof item !== "object" || item == null || Array.isArray(item) ||
|
|
11809
|
+
if (typeof item !== "object" || item == null || Array.isArray(item) || import_node_buffer43.Buffer.isBuffer(item)) return void 0;
|
|
11308
11810
|
const id = item.id;
|
|
11309
11811
|
if (!isAutoBatchResourceValue(id)) return void 0;
|
|
11310
11812
|
ids.push(id);
|
|
@@ -11345,7 +11847,7 @@ function flowValuePutOwner(command, start) {
|
|
|
11345
11847
|
}
|
|
11346
11848
|
var flowValuePutOptionTokens = /* @__PURE__ */ new Set(["NAME", "NOW", "OVERRIDE", "OWNER_FLOW_ID", "PARTITION", "TTL", "TTL_MS"]);
|
|
11347
11849
|
function isAutoBatchResourceValue(value) {
|
|
11348
|
-
return typeof value === "string" ||
|
|
11850
|
+
return typeof value === "string" || import_node_buffer43.Buffer.isBuffer(value);
|
|
11349
11851
|
}
|
|
11350
11852
|
function isFencingToken(value) {
|
|
11351
11853
|
return typeof value === "number" && Number.isSafeInteger(value) || typeof value === "bigint";
|
|
@@ -11354,7 +11856,7 @@ function nonNegativeItemCount(value) {
|
|
|
11354
11856
|
return typeof value === "number" && Number.isSafeInteger(value) && value >= 0 ? value : void 0;
|
|
11355
11857
|
}
|
|
11356
11858
|
function autoBatchResourceKey(namespace, value) {
|
|
11357
|
-
return `${namespace}:${
|
|
11859
|
+
return `${namespace}:${import_node_buffer43.Buffer.from(value).toString("base64")}`;
|
|
11358
11860
|
}
|
|
11359
11861
|
function autoBatchCommandName(command) {
|
|
11360
11862
|
return commandView(command).name ?? null;
|
|
@@ -11763,13 +12265,13 @@ function claimFailure(error) {
|
|
|
11763
12265
|
}
|
|
11764
12266
|
|
|
11765
12267
|
// src/client-flow-support.ts
|
|
11766
|
-
var
|
|
12268
|
+
var import_node_buffer57 = require("buffer");
|
|
11767
12269
|
|
|
11768
12270
|
// src/flow-query-builder.ts
|
|
11769
|
-
var
|
|
12271
|
+
var import_node_buffer46 = require("buffer");
|
|
11770
12272
|
|
|
11771
12273
|
// src/flow-query-metadata.ts
|
|
11772
|
-
var
|
|
12274
|
+
var import_node_buffer45 = require("buffer");
|
|
11773
12275
|
var MAX_FLOW_QUERY_METADATA_KEY_BYTES = 64;
|
|
11774
12276
|
function normalizeStateMeta(value, state) {
|
|
11775
12277
|
if (value == null) return {};
|
|
@@ -11794,7 +12296,7 @@ function normalizeStateMeta(value, state) {
|
|
|
11794
12296
|
function metadataEntries(value, context) {
|
|
11795
12297
|
const entries = objectEntries(value ?? {}, context).map(([rawName, item]) => {
|
|
11796
12298
|
const name = rawName.trim();
|
|
11797
|
-
const size =
|
|
12299
|
+
const size = import_node_buffer45.Buffer.byteLength(name, "utf8");
|
|
11798
12300
|
if (size === 0 || size > MAX_FLOW_QUERY_METADATA_KEY_BYTES || name.startsWith("__")) {
|
|
11799
12301
|
throw new TypeError(`${context} key is invalid or reserved`);
|
|
11800
12302
|
}
|
|
@@ -11818,7 +12320,7 @@ function objectEntries(value, context) {
|
|
|
11818
12320
|
return keys.map((key) => [key, value[key]]);
|
|
11819
12321
|
}
|
|
11820
12322
|
function isPlainRecord(value) {
|
|
11821
|
-
if (typeof value !== "object" || value == null || Array.isArray(value) ||
|
|
12323
|
+
if (typeof value !== "object" || value == null || Array.isArray(value) || import_node_buffer45.Buffer.isBuffer(value)) {
|
|
11822
12324
|
return false;
|
|
11823
12325
|
}
|
|
11824
12326
|
const prototype = Object.getPrototypeOf(value);
|
|
@@ -11888,7 +12390,7 @@ var FlowCollectionQuery = class {
|
|
|
11888
12390
|
const states = /* @__PURE__ */ new Set();
|
|
11889
12391
|
for (const [rawState, metadata] of objectEntries(values, "stateMeta")) {
|
|
11890
12392
|
const state = requiredText(rawState, "stateMeta state").trim();
|
|
11891
|
-
const stateBytes =
|
|
12393
|
+
const stateBytes = import_node_buffer46.Buffer.byteLength(state, "utf8");
|
|
11892
12394
|
if (stateBytes === 0 || stateBytes > MAX_FLOW_QUERY_STATE_BYTES) {
|
|
11893
12395
|
throw new TypeError(
|
|
11894
12396
|
`stateMeta state names must be 1..${MAX_FLOW_QUERY_STATE_BYTES} bytes`
|
|
@@ -12067,7 +12569,7 @@ function requiredPartition(value) {
|
|
|
12067
12569
|
"FLOW.QUERY convenience methods require a partition key"
|
|
12068
12570
|
);
|
|
12069
12571
|
}
|
|
12070
|
-
const size =
|
|
12572
|
+
const size = import_node_buffer46.Buffer.byteLength(value, "utf8");
|
|
12071
12573
|
if (size === 0 || size > MAX_FLOW_QUERY_PARTITION_BYTES) {
|
|
12072
12574
|
throw new TypeError(
|
|
12073
12575
|
`FLOW.QUERY partition key must be 1..${MAX_FLOW_QUERY_PARTITION_BYTES} bytes`
|
|
@@ -12115,23 +12617,23 @@ function requiredText(value, context) {
|
|
|
12115
12617
|
return value;
|
|
12116
12618
|
}
|
|
12117
12619
|
function queryParameter(value, context) {
|
|
12118
|
-
if (typeof value === "string" || typeof value === "boolean" || typeof value === "bigint" || typeof value === "number" ||
|
|
12620
|
+
if (typeof value === "string" || typeof value === "boolean" || typeof value === "bigint" || typeof value === "number" || import_node_buffer46.Buffer.isBuffer(value)) {
|
|
12119
12621
|
return value;
|
|
12120
12622
|
}
|
|
12121
12623
|
throw new TypeError(`${context} must be a scalar FLOW.QUERY parameter`);
|
|
12122
12624
|
}
|
|
12123
12625
|
|
|
12124
12626
|
// src/flow-query-response.ts
|
|
12125
|
-
var
|
|
12627
|
+
var import_node_buffer50 = require("buffer");
|
|
12126
12628
|
|
|
12127
12629
|
// src/flow-query-diagnostic-response.ts
|
|
12128
|
-
var
|
|
12630
|
+
var import_node_buffer48 = require("buffer");
|
|
12129
12631
|
|
|
12130
12632
|
// src/flow-query-response-validation.ts
|
|
12131
|
-
var
|
|
12633
|
+
var import_node_buffer47 = require("buffer");
|
|
12132
12634
|
function requiredMap2(value, context) {
|
|
12133
12635
|
if (value instanceof Map) return value;
|
|
12134
|
-
if (typeof value !== "object" || value == null || Array.isArray(value) ||
|
|
12636
|
+
if (typeof value !== "object" || value == null || Array.isArray(value) || import_node_buffer47.Buffer.isBuffer(value) || value instanceof Uint8Array) {
|
|
12135
12637
|
throw decodeError(`${context} must be a map`, value);
|
|
12136
12638
|
}
|
|
12137
12639
|
return value;
|
|
@@ -12188,7 +12690,7 @@ function normalizeMetadataValue(value, context, budget, ancestors, depth) {
|
|
|
12188
12690
|
if (!value.isWellFormed()) throw decodeError(`${context} contains invalid text`, value);
|
|
12189
12691
|
return value;
|
|
12190
12692
|
}
|
|
12191
|
-
if (
|
|
12693
|
+
if (import_node_buffer47.Buffer.isBuffer(value) || value instanceof Uint8Array) {
|
|
12192
12694
|
const decoded = strictText2(value);
|
|
12193
12695
|
if (decoded == null) throw decodeError(`${context} contains invalid UTF-8`, value);
|
|
12194
12696
|
return decoded;
|
|
@@ -12267,7 +12769,7 @@ function optionalText2(mapping2, name, context) {
|
|
|
12267
12769
|
}
|
|
12268
12770
|
function requiredBoundedText2(mapping2, name, context, maximumBytes) {
|
|
12269
12771
|
const value = requiredText2(mapping2, name, context);
|
|
12270
|
-
if (
|
|
12772
|
+
if (import_node_buffer47.Buffer.byteLength(value, "utf8") > maximumBytes) {
|
|
12271
12773
|
throw decodeError(
|
|
12272
12774
|
`${context} ${name} exceeds ${maximumBytes} bytes`,
|
|
12273
12775
|
mapping2
|
|
@@ -12280,7 +12782,7 @@ function boundedText(value, context, maximumBytes) {
|
|
|
12280
12782
|
if (decoded == null || decoded.length === 0) {
|
|
12281
12783
|
throw decodeError(`${context} must be non-empty text`, value);
|
|
12282
12784
|
}
|
|
12283
|
-
if (
|
|
12785
|
+
if (import_node_buffer47.Buffer.byteLength(decoded, "utf8") > maximumBytes) {
|
|
12284
12786
|
throw decodeError(`${context} exceeds ${maximumBytes} bytes`, value);
|
|
12285
12787
|
}
|
|
12286
12788
|
return decoded;
|
|
@@ -12292,7 +12794,7 @@ function requiredBoolean(mapping2, name, context) {
|
|
|
12292
12794
|
}
|
|
12293
12795
|
return value;
|
|
12294
12796
|
}
|
|
12295
|
-
function
|
|
12797
|
+
function nonNegativeInteger2(value, context) {
|
|
12296
12798
|
if (typeof value === "bigint") {
|
|
12297
12799
|
if (value >= 0n && value <= BigInt(Number.MAX_SAFE_INTEGER))
|
|
12298
12800
|
return Number(value);
|
|
@@ -12301,8 +12803,8 @@ function nonNegativeInteger(value, context) {
|
|
|
12301
12803
|
}
|
|
12302
12804
|
throw decodeError(`${context} must be a non-negative safe integer`, value);
|
|
12303
12805
|
}
|
|
12304
|
-
function
|
|
12305
|
-
const parsed =
|
|
12806
|
+
function positiveInteger2(value, context) {
|
|
12807
|
+
const parsed = nonNegativeInteger2(value, context);
|
|
12306
12808
|
if (parsed === 0) throw decodeError(`${context} must be positive`, value);
|
|
12307
12809
|
return parsed;
|
|
12308
12810
|
}
|
|
@@ -12334,10 +12836,10 @@ function positiveBoundedInteger(value, maximum, context) {
|
|
|
12334
12836
|
function hasKey(mapping2, name) {
|
|
12335
12837
|
if (!(mapping2 instanceof Map)) return Object.hasOwn(mapping2, name);
|
|
12336
12838
|
if (mapping2.has(name)) return true;
|
|
12337
|
-
const binaryName =
|
|
12839
|
+
const binaryName = import_node_buffer47.Buffer.from(name);
|
|
12338
12840
|
for (const key of mapping2.keys()) {
|
|
12339
|
-
if (
|
|
12340
|
-
if (key instanceof Uint8Array &&
|
|
12841
|
+
if (import_node_buffer47.Buffer.isBuffer(key) && key.equals(binaryName)) return true;
|
|
12842
|
+
if (key instanceof Uint8Array && import_node_buffer47.Buffer.from(key).equals(binaryName))
|
|
12341
12843
|
return true;
|
|
12342
12844
|
}
|
|
12343
12845
|
return false;
|
|
@@ -12348,7 +12850,7 @@ function decodeError(message, raw) {
|
|
|
12348
12850
|
function strictText2(value) {
|
|
12349
12851
|
if (typeof value === "string")
|
|
12350
12852
|
return value.isWellFormed() ? value : void 0;
|
|
12351
|
-
if (
|
|
12853
|
+
if (import_node_buffer47.Buffer.isBuffer(value) || value instanceof Uint8Array) {
|
|
12352
12854
|
try {
|
|
12353
12855
|
return new TextDecoder("utf-8", { fatal: true }).decode(value);
|
|
12354
12856
|
} catch {
|
|
@@ -12412,7 +12914,7 @@ function tryDecodeFlowQueryError(value, cause) {
|
|
|
12412
12914
|
hint: optionalDiagnosticText(mapping2, "hint"),
|
|
12413
12915
|
retryable: requiredBoolean(mapping2, "retryable", "FLOW.QUERY diagnostic"),
|
|
12414
12916
|
safeToRetry: requiredBoolean(mapping2, "safe_to_retry", "FLOW.QUERY diagnostic"),
|
|
12415
|
-
retryAfterMs:
|
|
12917
|
+
retryAfterMs: nonNegativeInteger2(
|
|
12416
12918
|
field(mapping2, "retry_after_ms"),
|
|
12417
12919
|
"FLOW.QUERY diagnostic retry_after_ms"
|
|
12418
12920
|
),
|
|
@@ -12428,7 +12930,7 @@ function tryDecodeFlowQueryError(value, cause) {
|
|
|
12428
12930
|
}
|
|
12429
12931
|
function optionalDiagnosticText(mapping2, name) {
|
|
12430
12932
|
const value = optionalText2(mapping2, name, "FLOW.QUERY diagnostic");
|
|
12431
|
-
if (value != null &&
|
|
12933
|
+
if (value != null && import_node_buffer48.Buffer.byteLength(value, "utf8") > DIAGNOSTIC_TEXT_BYTES) {
|
|
12432
12934
|
throw decodeError(
|
|
12433
12935
|
`FLOW.QUERY diagnostic ${name} exceeds ${DIAGNOSTIC_TEXT_BYTES} bytes`,
|
|
12434
12936
|
mapping2
|
|
@@ -12463,7 +12965,7 @@ function validateDiagnosticContextValue(value, depth, budget) {
|
|
|
12463
12965
|
}
|
|
12464
12966
|
const text3 = diagnosticContextText(value);
|
|
12465
12967
|
if (text3 != null) {
|
|
12466
|
-
if (
|
|
12968
|
+
if (import_node_buffer48.Buffer.byteLength(text3, "utf8") <= DIAGNOSTIC_TEXT_BYTES) return;
|
|
12467
12969
|
throw decodeError("FLOW.QUERY diagnostic context contains oversized text", value);
|
|
12468
12970
|
}
|
|
12469
12971
|
if (depth <= 0) {
|
|
@@ -12489,7 +12991,7 @@ function validateDiagnosticContextValue(value, depth, budget) {
|
|
|
12489
12991
|
}
|
|
12490
12992
|
for (const [rawKey, item] of entries) {
|
|
12491
12993
|
const key = diagnosticContextText(rawKey);
|
|
12492
|
-
if (key == null || key.length === 0 ||
|
|
12994
|
+
if (key == null || key.length === 0 || import_node_buffer48.Buffer.byteLength(key, "utf8") > DIAGNOSTIC_CONTEXT_KEY_BYTES) {
|
|
12493
12995
|
throw decodeError("FLOW.QUERY diagnostic context contains an invalid key", value);
|
|
12494
12996
|
}
|
|
12495
12997
|
validateDiagnosticContextValue(item, depth - 1, budget);
|
|
@@ -12506,7 +13008,7 @@ function consumeDiagnosticContextNode(value, budget) {
|
|
|
12506
13008
|
}
|
|
12507
13009
|
function diagnosticContextText(value) {
|
|
12508
13010
|
if (typeof value === "string") return value.isWellFormed() ? value : void 0;
|
|
12509
|
-
if (!
|
|
13011
|
+
if (!import_node_buffer48.Buffer.isBuffer(value) && !(value instanceof Uint8Array)) return void 0;
|
|
12510
13012
|
try {
|
|
12511
13013
|
return new TextDecoder("utf-8", { fatal: true }).decode(value);
|
|
12512
13014
|
} catch {
|
|
@@ -12522,9 +13024,9 @@ function decodePosition(value) {
|
|
|
12522
13024
|
if (value == null) return void 0;
|
|
12523
13025
|
const mapping2 = requiredMap2(value, "FLOW.QUERY diagnostic position");
|
|
12524
13026
|
return Object.freeze({
|
|
12525
|
-
byte:
|
|
12526
|
-
line:
|
|
12527
|
-
column:
|
|
13027
|
+
byte: positiveInteger2(field(mapping2, "byte"), "FLOW.QUERY diagnostic position byte"),
|
|
13028
|
+
line: positiveInteger2(field(mapping2, "line"), "FLOW.QUERY diagnostic position line"),
|
|
13029
|
+
column: positiveInteger2(
|
|
12528
13030
|
field(mapping2, "column"),
|
|
12529
13031
|
"FLOW.QUERY diagnostic position column"
|
|
12530
13032
|
)
|
|
@@ -12532,7 +13034,7 @@ function decodePosition(value) {
|
|
|
12532
13034
|
}
|
|
12533
13035
|
|
|
12534
13036
|
// src/flow-query-index-contract.ts
|
|
12535
|
-
var
|
|
13037
|
+
var import_node_buffer49 = require("buffer");
|
|
12536
13038
|
var FLOW_QUERY_BUILD_PHASES = ["pending", "snapshot", "backfill", "done"];
|
|
12537
13039
|
var FLOW_QUERY_VALIDATION_PHASES = [
|
|
12538
13040
|
"pending",
|
|
@@ -12778,10 +13280,10 @@ function fieldKind(name) {
|
|
|
12778
13280
|
return void 0;
|
|
12779
13281
|
}
|
|
12780
13282
|
function validUnquoted(value) {
|
|
12781
|
-
return !value.startsWith("__") && UNQUOTED_METADATA.test(value) &&
|
|
13283
|
+
return !value.startsWith("__") && UNQUOTED_METADATA.test(value) && import_node_buffer49.Buffer.byteLength(value, "ascii") <= 64;
|
|
12782
13284
|
}
|
|
12783
13285
|
function validMetadata(value, rejectReserved) {
|
|
12784
|
-
return value.length > 0 &&
|
|
13286
|
+
return value.length > 0 && import_node_buffer49.Buffer.byteLength(value, "utf8") <= 64 && (!rejectReserved || !value.startsWith("__"));
|
|
12785
13287
|
}
|
|
12786
13288
|
function externalSelector(root, ...segments) {
|
|
12787
13289
|
return segments.every(validUnquoted) ? [root, ...segments].join(".") : root + segments.map((segment) => `['${segment.replaceAll("'", "''")}']`).join("");
|
|
@@ -13291,7 +13793,7 @@ function decodeCountPrefixes(value, fieldCount) {
|
|
|
13291
13793
|
if (!Object.hasOwn(value, index)) {
|
|
13292
13794
|
throw decodeError(`${context} must be dense`, value);
|
|
13293
13795
|
}
|
|
13294
|
-
const prefix =
|
|
13796
|
+
const prefix = positiveInteger2(value[index], `${context} entry`);
|
|
13295
13797
|
if (prefix > fieldCount || prefix <= previous) {
|
|
13296
13798
|
throw decodeError(`${context} are invalid`, value);
|
|
13297
13799
|
}
|
|
@@ -13673,7 +14175,7 @@ function decodeUsage(value) {
|
|
|
13673
14175
|
const mapping2 = requiredMap2(value, "FLOW.QUERY usage");
|
|
13674
14176
|
const usage = /* @__PURE__ */ Object.create(null);
|
|
13675
14177
|
for (const [wireName, property] of USAGE_FIELDS2) {
|
|
13676
|
-
usage[property] =
|
|
14178
|
+
usage[property] = nonNegativeInteger2(
|
|
13677
14179
|
field(mapping2, wireName),
|
|
13678
14180
|
`FLOW.QUERY usage ${wireName}`
|
|
13679
14181
|
);
|
|
@@ -13688,7 +14190,7 @@ function decodePage(value) {
|
|
|
13688
14190
|
const mapping2 = requiredMap2(value, "FLOW.QUERY page");
|
|
13689
14191
|
const hasMore = requiredBoolean(mapping2, "has_more", "FLOW.QUERY page");
|
|
13690
14192
|
const cursor = optionalText2(mapping2, "cursor", "FLOW.QUERY page");
|
|
13691
|
-
if (cursor != null && (!cursor.startsWith("fqc1_") ||
|
|
14193
|
+
if (cursor != null && (!cursor.startsWith("fqc1_") || import_node_buffer50.Buffer.byteLength(cursor) < 16 || import_node_buffer50.Buffer.byteLength(cursor) > 4096)) {
|
|
13692
14194
|
throw decodeError("FLOW.QUERY page cursor is invalid", value);
|
|
13693
14195
|
}
|
|
13694
14196
|
if (hasMore !== (cursor != null)) {
|
|
@@ -13698,12 +14200,12 @@ function decodePage(value) {
|
|
|
13698
14200
|
}
|
|
13699
14201
|
|
|
13700
14202
|
// src/client-core.ts
|
|
13701
|
-
var
|
|
14203
|
+
var import_node_buffer55 = require("buffer");
|
|
13702
14204
|
|
|
13703
14205
|
// src/client-core-helpers.ts
|
|
13704
|
-
var
|
|
14206
|
+
var import_node_buffer51 = require("buffer");
|
|
13705
14207
|
function bgsaveResponse(response) {
|
|
13706
|
-
if ((typeof response === "string" ||
|
|
14208
|
+
if ((typeof response === "string" || import_node_buffer51.Buffer.isBuffer(response) || response instanceof Uint8Array) && text(response) === "Background saving started") {
|
|
13707
14209
|
return true;
|
|
13708
14210
|
}
|
|
13709
14211
|
return okResponse(response);
|
|
@@ -13717,7 +14219,7 @@ function fetchOrComputeCompletionToken(options) {
|
|
|
13717
14219
|
"fetch-or-compute completion requires computeToken"
|
|
13718
14220
|
);
|
|
13719
14221
|
}
|
|
13720
|
-
if (!
|
|
14222
|
+
if (!import_node_buffer51.Buffer.isBuffer(options.computeToken)) {
|
|
13721
14223
|
throw new TypeError("fetch-or-compute computeToken must be a Buffer");
|
|
13722
14224
|
}
|
|
13723
14225
|
return options.computeToken;
|
|
@@ -13740,10 +14242,10 @@ function unsupportedClientCaching() {
|
|
|
13740
14242
|
}
|
|
13741
14243
|
|
|
13742
14244
|
// src/client-base.ts
|
|
13743
|
-
var
|
|
14245
|
+
var import_node_buffer53 = require("buffer");
|
|
13744
14246
|
|
|
13745
14247
|
// src/client-executor.ts
|
|
13746
|
-
var
|
|
14248
|
+
var import_node_buffer52 = require("buffer");
|
|
13747
14249
|
var ErrorMappingExecutor = class {
|
|
13748
14250
|
constructor(executor) {
|
|
13749
14251
|
this.executor = executor;
|
|
@@ -13808,7 +14310,14 @@ function snapshotClientOptions(options) {
|
|
|
13808
14310
|
...own2,
|
|
13809
14311
|
...typeof own2.autoBatch === "object" && own2.autoBatch != null ? { autoBatch: Object.freeze({ ...own2.autoBatch }) } : {},
|
|
13810
14312
|
...own2.backpressure == null ? {} : { backpressure: Object.freeze({ ...own2.backpressure }) },
|
|
13811
|
-
...typeof own2.reconnect === "object" && own2.reconnect != null ? { reconnect: Object.freeze({ ...own2.reconnect }) } : {}
|
|
14313
|
+
...typeof own2.reconnect === "object" && own2.reconnect != null ? { reconnect: Object.freeze({ ...own2.reconnect }) } : {},
|
|
14314
|
+
...own2.httpOptions == null ? {} : {
|
|
14315
|
+
httpOptions: Object.freeze({
|
|
14316
|
+
...own2.httpOptions,
|
|
14317
|
+
...own2.httpOptions.headers == null ? {} : { headers: Object.freeze({ ...own2.httpOptions.headers }) },
|
|
14318
|
+
...own2.httpOptions.tlsOptions == null ? {} : { tlsOptions: Object.freeze({ ...own2.httpOptions.tlsOptions }) }
|
|
14319
|
+
})
|
|
14320
|
+
}
|
|
13812
14321
|
};
|
|
13813
14322
|
return Object.freeze(snapshot);
|
|
13814
14323
|
}
|
|
@@ -14077,14 +14586,14 @@ var FerricStoreAdministrationClient = class extends FerricStoreClientBase {
|
|
|
14077
14586
|
};
|
|
14078
14587
|
|
|
14079
14588
|
// src/store-utilities.ts
|
|
14080
|
-
var
|
|
14589
|
+
var import_node_buffer54 = require("buffer");
|
|
14081
14590
|
function encode(codec, value) {
|
|
14082
14591
|
return codec.encode(value);
|
|
14083
14592
|
}
|
|
14084
14593
|
function decode(codec, value) {
|
|
14085
14594
|
if (value == null) return null;
|
|
14086
|
-
if (
|
|
14087
|
-
if (value instanceof Uint8Array) return codec.decode(
|
|
14595
|
+
if (import_node_buffer54.Buffer.isBuffer(value)) return codec.decode(value);
|
|
14596
|
+
if (value instanceof Uint8Array) return codec.decode(import_node_buffer54.Buffer.from(value));
|
|
14088
14597
|
return value;
|
|
14089
14598
|
}
|
|
14090
14599
|
function number(value) {
|
|
@@ -14105,7 +14614,7 @@ function array(value, expectedItems, command) {
|
|
|
14105
14614
|
}
|
|
14106
14615
|
return value;
|
|
14107
14616
|
}
|
|
14108
|
-
function
|
|
14617
|
+
function denseArray2(value, command) {
|
|
14109
14618
|
return assertDenseArray(array(value), command);
|
|
14110
14619
|
}
|
|
14111
14620
|
function denseArrayResponse(value, expectedItems, command) {
|
|
@@ -14393,7 +14902,7 @@ var BloomFilterStore = class {
|
|
|
14393
14902
|
return integerReply(await this.client.command("BF.CARD", key));
|
|
14394
14903
|
}
|
|
14395
14904
|
async info(key) {
|
|
14396
|
-
return
|
|
14905
|
+
return denseArray2(await this.client.command("BF.INFO", key), "BF.INFO");
|
|
14397
14906
|
}
|
|
14398
14907
|
};
|
|
14399
14908
|
var CuckooFilterStore = class {
|
|
@@ -14432,7 +14941,7 @@ var CuckooFilterStore = class {
|
|
|
14432
14941
|
return integerReply(await this.client.command("CF.COUNT", key, encode(this.client.codec, element)));
|
|
14433
14942
|
}
|
|
14434
14943
|
async info(key) {
|
|
14435
|
-
return
|
|
14944
|
+
return denseArray2(await this.client.command("CF.INFO", key), "CF.INFO");
|
|
14436
14945
|
}
|
|
14437
14946
|
};
|
|
14438
14947
|
var CountMinSketchStore = class {
|
|
@@ -14477,7 +14986,7 @@ var CountMinSketchStore = class {
|
|
|
14477
14986
|
return okResponse(await commandArgs(this.client, args));
|
|
14478
14987
|
}
|
|
14479
14988
|
async info(key) {
|
|
14480
|
-
return
|
|
14989
|
+
return denseArray2(await this.client.command("CMS.INFO", key), "CMS.INFO");
|
|
14481
14990
|
}
|
|
14482
14991
|
};
|
|
14483
14992
|
var TopKStore = class {
|
|
@@ -14560,7 +15069,7 @@ var TopKStore = class {
|
|
|
14560
15069
|
);
|
|
14561
15070
|
}
|
|
14562
15071
|
async info(key) {
|
|
14563
|
-
return
|
|
15072
|
+
return denseArray2(await this.client.command("TOPK.INFO", key), "TOPK.INFO");
|
|
14564
15073
|
}
|
|
14565
15074
|
};
|
|
14566
15075
|
var TDigestStore = class {
|
|
@@ -14651,7 +15160,7 @@ var TDigestStore = class {
|
|
|
14651
15160
|
return string(await this.client.command("TDIGEST.MAX", key));
|
|
14652
15161
|
}
|
|
14653
15162
|
async info(key) {
|
|
14654
|
-
return
|
|
15163
|
+
return denseArray2(await this.client.command("TDIGEST.INFO", key), "TDIGEST.INFO");
|
|
14655
15164
|
}
|
|
14656
15165
|
async merge(destination, sources, options = {}) {
|
|
14657
15166
|
requireNonEmpty(sources, "TDIGEST.MERGE", "source");
|
|
@@ -15043,7 +15552,7 @@ var KeyValueStore = class {
|
|
|
15043
15552
|
return response == null ? null : string(response);
|
|
15044
15553
|
}
|
|
15045
15554
|
async objectHelp() {
|
|
15046
|
-
return
|
|
15555
|
+
return denseArray2(await this.client.command("OBJECT", "HELP"), "OBJECT HELP");
|
|
15047
15556
|
}
|
|
15048
15557
|
async objectFreq(key) {
|
|
15049
15558
|
return number(await this.client.command("OBJECT", "FREQ", key));
|
|
@@ -16051,14 +16560,14 @@ function validateScheduleCreate(id, options) {
|
|
|
16051
16560
|
validateTiming(kind, options);
|
|
16052
16561
|
const recurring = RECURRING_KINDS.has(kind);
|
|
16053
16562
|
validateTarget(options.target, recurring);
|
|
16054
|
-
|
|
16055
|
-
|
|
16056
|
-
|
|
16057
|
-
|
|
16058
|
-
|
|
16059
|
-
|
|
16060
|
-
|
|
16061
|
-
|
|
16563
|
+
nonNegativeInteger3(options.atMs, "at_ms");
|
|
16564
|
+
nonNegativeInteger3(options.delayMs, "delay_ms");
|
|
16565
|
+
nonNegativeInteger3(options.startAtMs, "start_at_ms");
|
|
16566
|
+
positiveInteger3(options.everyMs, "every_ms");
|
|
16567
|
+
positiveInteger3(options.overlapRetryMs, "overlap_retry_ms");
|
|
16568
|
+
positiveInteger3(options.maxFires, "max_fires");
|
|
16569
|
+
nonNegativeInteger3(options.endAtMs, "end_at_ms");
|
|
16570
|
+
nonNegativeInteger3(options.nowMs, "now_ms");
|
|
16062
16571
|
optionalBoolean(options.overwrite, "overwrite");
|
|
16063
16572
|
if (kind === "delay") {
|
|
16064
16573
|
if (options.delayMs == null) throw new TypeError("delay_ms is required for delay schedules");
|
|
@@ -16115,20 +16624,20 @@ function validateScheduleID(id) {
|
|
|
16115
16624
|
}
|
|
16116
16625
|
function validateScheduleFire(id, options) {
|
|
16117
16626
|
validateScheduleID(id);
|
|
16118
|
-
|
|
16119
|
-
|
|
16627
|
+
nonNegativeInteger3(options.fireAtMs, "fire_at_ms");
|
|
16628
|
+
nonNegativeInteger3(options.nowMs, "now_ms");
|
|
16120
16629
|
}
|
|
16121
16630
|
function validateScheduleStatus(id, nowMs2) {
|
|
16122
16631
|
validateScheduleID(id);
|
|
16123
|
-
|
|
16632
|
+
nonNegativeInteger3(nowMs2, "now_ms");
|
|
16124
16633
|
}
|
|
16125
16634
|
function validateScheduleFireDue(options) {
|
|
16126
16635
|
if (!mapping(options)) throw new TypeError("schedule fire-due options must be a mapping");
|
|
16127
|
-
|
|
16636
|
+
nonNegativeInteger3(options.nowMs, "now_ms");
|
|
16128
16637
|
optionalText3(options.worker, "worker");
|
|
16129
|
-
|
|
16130
|
-
|
|
16131
|
-
|
|
16638
|
+
positiveInteger3(options.leaseMs, "lease_ms");
|
|
16639
|
+
nonNegativeInteger3(options.blockMs, "block_ms");
|
|
16640
|
+
positiveInteger3(options.limit, "limit");
|
|
16132
16641
|
const leaseMs = options.leaseMs ?? 3e4;
|
|
16133
16642
|
if (options.nowMs != null && options.nowMs > MAX_EXACT_INTEGER - leaseMs) {
|
|
16134
16643
|
throw new TypeError("now_ms plus lease_ms exceeds the exact integer range");
|
|
@@ -16144,12 +16653,12 @@ function validateScheduleList(options) {
|
|
|
16144
16653
|
}
|
|
16145
16654
|
optionalText3(options.timezone, "timezone");
|
|
16146
16655
|
optionalText3(options.targetType, "target_type");
|
|
16147
|
-
|
|
16148
|
-
|
|
16656
|
+
nonNegativeInteger3(options.fromMs, "from_ms");
|
|
16657
|
+
nonNegativeInteger3(options.toMs, "to_ms");
|
|
16149
16658
|
if (options.fromMs != null && options.toMs != null && options.fromMs > options.toMs) {
|
|
16150
16659
|
throw new TypeError("from_ms must not exceed to_ms");
|
|
16151
16660
|
}
|
|
16152
|
-
|
|
16661
|
+
positiveInteger3(options.count, "count");
|
|
16153
16662
|
optionalBoolean(options.rev, "rev");
|
|
16154
16663
|
}
|
|
16155
16664
|
function effectiveKind(options) {
|
|
@@ -16207,7 +16716,7 @@ function validateTarget(value, recurring) {
|
|
|
16207
16716
|
if (typeof idPrefix === "string" && idPrefix.startsWith(INTERNAL_SCHEDULE_ID_PREFIX)) {
|
|
16208
16717
|
throw new TypeError("target id_prefix is reserved for internal use");
|
|
16209
16718
|
}
|
|
16210
|
-
|
|
16719
|
+
nonNegativeInteger3(own(target, "run_at_ms"), "target run_at_ms");
|
|
16211
16720
|
const priority = own(target, "priority");
|
|
16212
16721
|
if (priority != null && (typeof priority !== "number" || !Number.isSafeInteger(priority) || priority < 0 || priority > 2)) {
|
|
16213
16722
|
throw new TypeError("target priority must be an integer between 0 and 2");
|
|
@@ -16229,12 +16738,12 @@ function requiredText3(value, name) {
|
|
|
16229
16738
|
function optionalText3(value, name) {
|
|
16230
16739
|
if (value != null) requiredText3(value, name);
|
|
16231
16740
|
}
|
|
16232
|
-
function
|
|
16741
|
+
function nonNegativeInteger3(value, name) {
|
|
16233
16742
|
if (value != null && (typeof value !== "number" || !Number.isSafeInteger(value) || value < 0)) {
|
|
16234
16743
|
throw new TypeError(`${name} must be a non-negative exact integer`);
|
|
16235
16744
|
}
|
|
16236
16745
|
}
|
|
16237
|
-
function
|
|
16746
|
+
function positiveInteger3(value, name) {
|
|
16238
16747
|
if (value != null && (typeof value !== "number" || !Number.isSafeInteger(value) || value <= 0)) {
|
|
16239
16748
|
throw new TypeError(`${name} must be a positive exact integer`);
|
|
16240
16749
|
}
|
|
@@ -16940,7 +17449,7 @@ function throwIfClosed(signal) {
|
|
|
16940
17449
|
}
|
|
16941
17450
|
|
|
16942
17451
|
// src/flow-policy.ts
|
|
16943
|
-
var
|
|
17452
|
+
var import_node_buffer56 = require("buffer");
|
|
16944
17453
|
var MAX_FLOW_POLICY_GENERATION = Number.MAX_SAFE_INTEGER;
|
|
16945
17454
|
function assertFlowPolicyGeneration(value) {
|
|
16946
17455
|
if (typeof value !== "number" || !Number.isSafeInteger(value) || value < 0) {
|
|
@@ -16958,7 +17467,7 @@ function flowPolicySnapshotFromResp(value) {
|
|
|
16958
17467
|
const states = optionalStates(field(policy, "states"));
|
|
16959
17468
|
return {
|
|
16960
17469
|
type: requiredText4(field(policy, "type"), "type"),
|
|
16961
|
-
generation:
|
|
17470
|
+
generation: nonNegativeInteger4(field(policy, "generation"), "generation"),
|
|
16962
17471
|
...state == null ? {} : { state },
|
|
16963
17472
|
...version == null ? {} : { version },
|
|
16964
17473
|
...mode == null ? {} : { mode },
|
|
@@ -16976,12 +17485,12 @@ function retrySnapshot(value, context) {
|
|
|
16976
17485
|
const retry2 = requiredRecord(value, `FLOW policy ${context}`);
|
|
16977
17486
|
const backoff = requiredRecord(field(retry2, "backoff"), `FLOW policy ${context}.backoff`);
|
|
16978
17487
|
return {
|
|
16979
|
-
maxRetries:
|
|
17488
|
+
maxRetries: nonNegativeInteger4(field(retry2, "max_retries"), `${context}.max_retries`),
|
|
16980
17489
|
backoff: {
|
|
16981
17490
|
kind: backoffKind(field(backoff, "kind"), `${context}.backoff.kind`),
|
|
16982
|
-
baseMs:
|
|
16983
|
-
maxMs:
|
|
16984
|
-
jitterPct:
|
|
17491
|
+
baseMs: nonNegativeInteger4(field(backoff, "base_ms"), `${context}.backoff.base_ms`),
|
|
17492
|
+
maxMs: nonNegativeInteger4(field(backoff, "max_ms"), `${context}.backoff.max_ms`),
|
|
17493
|
+
jitterPct: nonNegativeInteger4(field(backoff, "jitter_pct"), `${context}.backoff.jitter_pct`)
|
|
16985
17494
|
},
|
|
16986
17495
|
exhaustedTo: requiredText4(field(retry2, "exhausted_to"), `${context}.exhausted_to`)
|
|
16987
17496
|
};
|
|
@@ -16989,8 +17498,8 @@ function retrySnapshot(value, context) {
|
|
|
16989
17498
|
function retentionSnapshot(value, context) {
|
|
16990
17499
|
const retention = requiredRecord(value, `FLOW policy ${context}`);
|
|
16991
17500
|
return {
|
|
16992
|
-
ttlMs:
|
|
16993
|
-
historyMaxEvents:
|
|
17501
|
+
ttlMs: nonNegativeInteger4(field(retention, "ttl_ms"), `${context}.ttl_ms`),
|
|
17502
|
+
historyMaxEvents: nonNegativeInteger4(
|
|
16994
17503
|
field(retention, "history_max_events"),
|
|
16995
17504
|
`${context}.history_max_events`
|
|
16996
17505
|
)
|
|
@@ -17030,7 +17539,7 @@ function requiredRecord(value, context) {
|
|
|
17030
17539
|
}
|
|
17031
17540
|
return result;
|
|
17032
17541
|
}
|
|
17033
|
-
if (typeof value === "object" && value != null && !Array.isArray(value) && !
|
|
17542
|
+
if (typeof value === "object" && value != null && !Array.isArray(value) && !import_node_buffer56.Buffer.isBuffer(value) && !(value instanceof Uint8Array)) return value;
|
|
17034
17543
|
throw new TypeError(`${context} returned an unexpected response`);
|
|
17035
17544
|
}
|
|
17036
17545
|
function optionalRecord(value, context) {
|
|
@@ -17051,15 +17560,15 @@ function stringArray(value, context) {
|
|
|
17051
17560
|
}
|
|
17052
17561
|
function requiredText4(value, context) {
|
|
17053
17562
|
if (typeof value === "string") return value;
|
|
17054
|
-
if (
|
|
17055
|
-
return
|
|
17563
|
+
if (import_node_buffer56.Buffer.isBuffer(value) || value instanceof Uint8Array) {
|
|
17564
|
+
return import_node_buffer56.Buffer.from(value).toString("utf8");
|
|
17056
17565
|
}
|
|
17057
17566
|
throw new TypeError(`FLOW policy ${context} returned an unexpected response`);
|
|
17058
17567
|
}
|
|
17059
17568
|
function optionalText4(value, context) {
|
|
17060
17569
|
return value == null ? void 0 : requiredText4(value, context);
|
|
17061
17570
|
}
|
|
17062
|
-
function
|
|
17571
|
+
function nonNegativeInteger4(value, context) {
|
|
17063
17572
|
let parsed;
|
|
17064
17573
|
try {
|
|
17065
17574
|
parsed = integer(value);
|
|
@@ -17071,14 +17580,14 @@ function nonNegativeInteger3(value, context) {
|
|
|
17071
17580
|
}
|
|
17072
17581
|
function optionalPositiveInteger(value, context) {
|
|
17073
17582
|
if (value == null) return void 0;
|
|
17074
|
-
const parsed =
|
|
17583
|
+
const parsed = nonNegativeInteger4(value, context);
|
|
17075
17584
|
if (parsed === 0) throw new TypeError(`FLOW policy ${context} returned an unexpected response`);
|
|
17076
17585
|
return parsed;
|
|
17077
17586
|
}
|
|
17078
17587
|
function optionalVersion(value) {
|
|
17079
17588
|
if (value == null) return void 0;
|
|
17080
17589
|
if (typeof value === "number" || typeof value === "bigint") {
|
|
17081
|
-
return
|
|
17590
|
+
return nonNegativeInteger4(value, "version");
|
|
17082
17591
|
}
|
|
17083
17592
|
return requiredText4(value, "version");
|
|
17084
17593
|
}
|
|
@@ -17308,7 +17817,7 @@ var FerricStoreFlowSupportClient = class extends FerricStoreFlowQueryClient {
|
|
|
17308
17817
|
};
|
|
17309
17818
|
|
|
17310
17819
|
// src/flow-many-snapshot.ts
|
|
17311
|
-
var
|
|
17820
|
+
var import_node_buffer58 = require("buffer");
|
|
17312
17821
|
var encodedOptionFields = ["error", "payload", "reason", "result"];
|
|
17313
17822
|
function snapshotCreateItem(item, codec) {
|
|
17314
17823
|
const snapshot = {
|
|
@@ -17348,7 +17857,7 @@ function snapshotFlowManyOptions(options, codec) {
|
|
|
17348
17857
|
}
|
|
17349
17858
|
function snapshotClaimedItem(item) {
|
|
17350
17859
|
const wire = item[CLAIMED_ITEM_WIRE];
|
|
17351
|
-
const leaseToken =
|
|
17860
|
+
const leaseToken = import_node_buffer58.Buffer.from(wire?.leaseToken ?? item.leaseToken);
|
|
17352
17861
|
const snapshot = {
|
|
17353
17862
|
...item,
|
|
17354
17863
|
fencingToken: wire?.fencingToken ?? item.fencingToken,
|
|
@@ -17365,15 +17874,15 @@ function snapshotClaimedItem(item) {
|
|
|
17365
17874
|
function snapshotFencedItem(item) {
|
|
17366
17875
|
return Object.freeze({
|
|
17367
17876
|
...item,
|
|
17368
|
-
...item.leaseToken == null ? {} : { leaseToken:
|
|
17877
|
+
...item.leaseToken == null ? {} : { leaseToken: import_node_buffer58.Buffer.from(item.leaseToken) }
|
|
17369
17878
|
});
|
|
17370
17879
|
}
|
|
17371
17880
|
function snapshotClaimedItemWire(wire, leaseToken) {
|
|
17372
17881
|
return Object.freeze({
|
|
17373
17882
|
fencingToken: wire.fencingToken,
|
|
17374
|
-
id:
|
|
17883
|
+
id: import_node_buffer58.Buffer.from(wire.id),
|
|
17375
17884
|
leaseToken,
|
|
17376
|
-
partitionKey: wire.partitionKey == null ? wire.partitionKey :
|
|
17885
|
+
partitionKey: wire.partitionKey == null ? wire.partitionKey : import_node_buffer58.Buffer.from(wire.partitionKey)
|
|
17377
17886
|
});
|
|
17378
17887
|
}
|
|
17379
17888
|
function snapshotArray(values) {
|
|
@@ -17384,7 +17893,7 @@ function snapshotArray(values) {
|
|
|
17384
17893
|
return Object.freeze(snapshot);
|
|
17385
17894
|
}
|
|
17386
17895
|
function snapshotStateMeta(stateMeta) {
|
|
17387
|
-
return snapshotRecord(stateMeta, (value) =>
|
|
17896
|
+
return snapshotRecord(stateMeta, (value) => import_node_buffer58.Buffer.isBuffer(value) ? import_node_buffer58.Buffer.from(value) : value);
|
|
17388
17897
|
}
|
|
17389
17898
|
function snapshotCommandRecord(values) {
|
|
17390
17899
|
const seen = /* @__PURE__ */ new WeakMap();
|
|
@@ -17402,7 +17911,7 @@ function snapshotRecord(values, capture) {
|
|
|
17402
17911
|
}
|
|
17403
17912
|
function snapshotCommandArgument(value, seen) {
|
|
17404
17913
|
if (typeof value !== "object" || value == null) return value;
|
|
17405
|
-
if (
|
|
17914
|
+
if (import_node_buffer58.Buffer.isBuffer(value) || value instanceof Uint8Array) return import_node_buffer58.Buffer.from(value);
|
|
17406
17915
|
const objectValue = value;
|
|
17407
17916
|
const existing = seen.get(objectValue);
|
|
17408
17917
|
if (existing != null) return existing;
|
|
@@ -18167,6 +18676,14 @@ var FerricStoreProducerClient = class extends FerricStoreClaimClient {
|
|
|
18167
18676
|
var FerricStoreClient = class _FerricStoreClient extends FerricStoreProducerClient {
|
|
18168
18677
|
static async fromUrl(url, options = {}) {
|
|
18169
18678
|
const clientOptions = snapshotClientOptions(options);
|
|
18679
|
+
const scheme = new URL(url).protocol;
|
|
18680
|
+
if (scheme === "http:" || scheme === "https:") {
|
|
18681
|
+
if (clientOptions.nativeOptions != null) {
|
|
18682
|
+
throw new TypeError("nativeOptions are not valid for an HTTP FerricStore URL");
|
|
18683
|
+
}
|
|
18684
|
+
const executor2 = await HTTPAdapter.fromUrl(url, clientOptions.httpOptions);
|
|
18685
|
+
return new _FerricStoreClient(executor2, clientOptions);
|
|
18686
|
+
}
|
|
18170
18687
|
const nativeOptions = snapshotNativeClientOptions(clientOptions.nativeOptions ?? {});
|
|
18171
18688
|
const reconnectOptions = clientOptions.reconnect ?? nativeOptions.autoReconnect ?? true;
|
|
18172
18689
|
const seeds = nativeOptions.seeds ?? [];
|
|
@@ -18390,7 +18907,7 @@ function nativeOptionsForBootstrap(options, signal) {
|
|
|
18390
18907
|
}
|
|
18391
18908
|
|
|
18392
18909
|
// src/flow-query-projection.ts
|
|
18393
|
-
var
|
|
18910
|
+
var import_node_buffer59 = require("buffer");
|
|
18394
18911
|
var MAX_PROJECTION_FIELDS = 32;
|
|
18395
18912
|
var MAX_DYNAMIC_NAME_BYTES = 64;
|
|
18396
18913
|
var FIELD_BRAND = /* @__PURE__ */ Symbol("FerricStoreFlowProjectionField");
|
|
@@ -18460,7 +18977,7 @@ function projectFlowQuery(query, shape, ...fields) {
|
|
|
18460
18977
|
}
|
|
18461
18978
|
const base = stripOptionalTerminator(query);
|
|
18462
18979
|
const result = `${base} RETURN ${shape.toUpperCase()} (${selectors.join(", ")})`;
|
|
18463
|
-
if (
|
|
18980
|
+
if (import_node_buffer59.Buffer.byteLength(result, "utf8") > FLOW_QUERY_MAX_BYTES) {
|
|
18464
18981
|
throw new TypeError(`FLOW.QUERY query exceeds ${FLOW_QUERY_MAX_BYTES} bytes`);
|
|
18465
18982
|
}
|
|
18466
18983
|
return result;
|
|
@@ -18520,7 +19037,7 @@ function quoteName(value, allowPrivate) {
|
|
|
18520
19037
|
throw new TypeError("Flow query projection metadata name must be text");
|
|
18521
19038
|
}
|
|
18522
19039
|
validateUnicodeScalarText2(value);
|
|
18523
|
-
const size =
|
|
19040
|
+
const size = import_node_buffer59.Buffer.byteLength(value, "utf8");
|
|
18524
19041
|
if (size === 0 || size > MAX_DYNAMIC_NAME_BYTES || !allowPrivate && value.startsWith("__")) {
|
|
18525
19042
|
throw new TypeError(
|
|
18526
19043
|
`Flow query projection metadata names must be 1..${MAX_DYNAMIC_NAME_BYTES} UTF-8 bytes`
|
|
@@ -18622,7 +19139,7 @@ var LeaseRenewalGuard = class {
|
|
|
18622
19139
|
if (options.leaseRenewal === false) {
|
|
18623
19140
|
return;
|
|
18624
19141
|
}
|
|
18625
|
-
const intervalMs =
|
|
19142
|
+
const intervalMs = positiveInteger4(options.leaseRenewIntervalMs, Math.max(1, Math.trunc(leaseMs / 2)));
|
|
18626
19143
|
this.timer = setLongInterval(() => this.renew(), intervalMs);
|
|
18627
19144
|
this.timer.unref();
|
|
18628
19145
|
}
|
|
@@ -18694,7 +19211,7 @@ function snapshotLeasedJob(job) {
|
|
|
18694
19211
|
return snapshot;
|
|
18695
19212
|
}
|
|
18696
19213
|
function workerConcurrency(options) {
|
|
18697
|
-
return
|
|
19214
|
+
return positiveInteger4(options.concurrency ?? options.workers, 1);
|
|
18698
19215
|
}
|
|
18699
19216
|
function workerRefillStrategy(options) {
|
|
18700
19217
|
return options.refillStrategy === "wave" ? "wave" : "continuous";
|
|
@@ -18737,18 +19254,18 @@ function workerErrorPayload(error, options, codec) {
|
|
|
18737
19254
|
}
|
|
18738
19255
|
function workerBatchSize(options, flowManyBatchLimit = DEFAULT_FLOW_MANY_BATCH_LIMIT2) {
|
|
18739
19256
|
return Math.min(
|
|
18740
|
-
|
|
18741
|
-
|
|
19257
|
+
positiveInteger4(options.batchSize, 10),
|
|
19258
|
+
positiveInteger4(flowManyBatchLimit, DEFAULT_FLOW_MANY_BATCH_LIMIT2)
|
|
18742
19259
|
);
|
|
18743
19260
|
}
|
|
18744
19261
|
function workerClaimLimit(options, flowManyBatchLimit = DEFAULT_FLOW_MANY_BATCH_LIMIT2) {
|
|
18745
19262
|
return Math.min(workerBatchSize(options, flowManyBatchLimit), workerConcurrency(options));
|
|
18746
19263
|
}
|
|
18747
19264
|
function workerDrainBatches(options) {
|
|
18748
|
-
return
|
|
19265
|
+
return positiveInteger4(options.claimDrainBatches, 1);
|
|
18749
19266
|
}
|
|
18750
19267
|
function workerLeaseMs(options, fallback = 3e4) {
|
|
18751
|
-
return
|
|
19268
|
+
return positiveInteger4(options.leaseMs, positiveInteger4(fallback, 3e4));
|
|
18752
19269
|
}
|
|
18753
19270
|
function workerIdleSleepMs(options) {
|
|
18754
19271
|
return nonNegativeDuration(options.idleSleepMs, 250);
|
|
@@ -18760,7 +19277,7 @@ function workerClaimBlockMs(options, useBlocking) {
|
|
|
18760
19277
|
if (options.signal == null || !Number.isFinite(options.blockMs) || options.blockMs < 0) {
|
|
18761
19278
|
return options.blockMs;
|
|
18762
19279
|
}
|
|
18763
|
-
const abortPollMs =
|
|
19280
|
+
const abortPollMs = positiveInteger4(options.abortPollMs, 1e3);
|
|
18764
19281
|
return options.blockMs === 0 ? abortPollMs : Math.min(Math.trunc(options.blockMs), abortPollMs);
|
|
18765
19282
|
}
|
|
18766
19283
|
function workerMaxIdleSleepMs(options, idleSleepMs = workerIdleSleepMs(options)) {
|
|
@@ -18771,14 +19288,14 @@ function nextWorkerIdleSleepMs(currentIdleSleepMs, maxIdleSleepMs) {
|
|
|
18771
19288
|
return Math.min(maxIdleSleepMs, Math.max(1, currentIdleSleepMs * 2));
|
|
18772
19289
|
}
|
|
18773
19290
|
async function runContinuousWorkerPool(options) {
|
|
18774
|
-
const concurrency =
|
|
18775
|
-
const maxClaimSize =
|
|
19291
|
+
const concurrency = positiveInteger4(options.concurrency, 1);
|
|
19292
|
+
const maxClaimSize = positiveInteger4(options.maxClaimSize, concurrency);
|
|
18776
19293
|
const initialIdleSleepMs = nonNegativeDuration(options.idleSleepMs, 250);
|
|
18777
19294
|
const maxIdleSleepMs = Math.max(
|
|
18778
19295
|
initialIdleSleepMs,
|
|
18779
19296
|
nonNegativeDuration(options.maxIdleSleepMs, 5e3)
|
|
18780
19297
|
);
|
|
18781
|
-
const refillDelayMs =
|
|
19298
|
+
const refillDelayMs = nonNegativeInteger5(options.refillDelayMs, 0);
|
|
18782
19299
|
const active = /* @__PURE__ */ new Set();
|
|
18783
19300
|
const pending = [];
|
|
18784
19301
|
let pendingIndex = 0;
|
|
@@ -18894,10 +19411,10 @@ function normalizeWorkflowWorkerConfig(options) {
|
|
|
18894
19411
|
...captured
|
|
18895
19412
|
});
|
|
18896
19413
|
}
|
|
18897
|
-
function
|
|
19414
|
+
function positiveInteger4(value, fallback) {
|
|
18898
19415
|
return value == null || !Number.isFinite(value) ? fallback : Math.max(1, Math.trunc(value));
|
|
18899
19416
|
}
|
|
18900
|
-
function
|
|
19417
|
+
function nonNegativeInteger5(value, fallback) {
|
|
18901
19418
|
return value == null || !Number.isFinite(value) ? fallback : Math.max(0, Math.trunc(value));
|
|
18902
19419
|
}
|
|
18903
19420
|
function nonNegativeDuration(value, fallback) {
|
|
@@ -20526,7 +21043,7 @@ var WorkflowWorker = class {
|
|
|
20526
21043
|
};
|
|
20527
21044
|
|
|
20528
21045
|
// src/version.ts
|
|
20529
|
-
var FERRICSTORE_SDK_VERSION = "0.11.
|
|
21046
|
+
var FERRICSTORE_SDK_VERSION = "0.11.9";
|
|
20530
21047
|
var FERRICSTORE_MINIMUM_SERVER_VERSION = "0.11.4";
|
|
20531
21048
|
var FERRICSTORE_NATIVE_PROTOCOL_VERSION = 1;
|
|
20532
21049
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -20550,6 +21067,8 @@ var FERRICSTORE_NATIVE_PROTOCOL_VERSION = 1;
|
|
|
20550
21067
|
FlowQueryError,
|
|
20551
21068
|
FlowWrongStateError,
|
|
20552
21069
|
GeoStore,
|
|
21070
|
+
HTTPAdapter,
|
|
21071
|
+
HTTPTransportError,
|
|
20553
21072
|
HashStore,
|
|
20554
21073
|
HyperLogLogStore,
|
|
20555
21074
|
InvalidCommandError,
|
|
@@ -20587,6 +21106,7 @@ var FERRICSTORE_NATIVE_PROTOCOL_VERSION = 1;
|
|
|
20587
21106
|
classifyServerError,
|
|
20588
21107
|
complete,
|
|
20589
21108
|
fail,
|
|
21109
|
+
httpCommandDisposition,
|
|
20590
21110
|
isOutcome,
|
|
20591
21111
|
isReconnectableClosedConnectionError,
|
|
20592
21112
|
mapException,
|