@ferricstore/ferricstore 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +20 -3
- package/dist/index.cjs +515 -124
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +58 -7
- package/dist/index.d.ts +58 -7
- package/dist/index.js +502 -113
- package/dist/index.js.map +1 -1
- package/docs/api/assets/hierarchy.js +1 -1
- package/docs/api/assets/navigation.js +1 -1
- package/docs/api/assets/search.js +1 -1
- package/docs/api/classes/ClaimHydrationError.html +1 -1
- package/docs/api/classes/ConnectionClosedError.html +1 -1
- package/docs/api/classes/FerricStoreClient.html +3 -3
- package/docs/api/classes/FerricStoreError.html +1 -1
- package/docs/api/classes/FlowAlreadyExistsError.html +2 -2
- package/docs/api/classes/FlowBatchError.html +1 -1
- package/docs/api/classes/FlowNotFoundError.html +1 -1
- package/docs/api/classes/FlowWrongStateError.html +1 -1
- package/docs/api/classes/InvalidCommandError.html +2 -2
- package/docs/api/classes/LeaseRenewalError.html +1 -1
- package/docs/api/classes/LockHeldError.html +2 -2
- package/docs/api/classes/LockNotOwnedError.html +2 -2
- package/docs/api/classes/OverloadedError.html +2 -2
- package/docs/api/classes/QueueCompletionError.html +1 -1
- package/docs/api/classes/ReconnectingExecutor.html +4 -4
- package/docs/api/classes/RequestTimeoutError.html +1 -1
- package/docs/api/classes/RerouteError.html +2 -2
- package/docs/api/classes/StaleLeaseError.html +1 -1
- package/docs/api/classes/StalePolicyGenerationError.html +39 -0
- package/docs/api/classes/TopologyNativeAdapterPool.html +3 -3
- package/docs/api/classes/Workflow.html +1 -1
- package/docs/api/classes/WorkflowWorker.html +2 -2
- package/docs/api/functions/classifyServerError.html +1 -1
- package/docs/api/functions/isReconnectableClosedConnectionError.html +1 -1
- package/docs/api/functions/mapException.html +1 -1
- package/docs/api/hierarchy.html +1 -1
- package/docs/api/index.html +8 -4
- package/docs/api/interfaces/AdminListOptions.html +1 -1
- package/docs/api/interfaces/CancelOptions.html +2 -2
- package/docs/api/interfaces/CompleteOptions.html +2 -2
- package/docs/api/interfaces/CompleteOutcome.html +1 -1
- package/docs/api/interfaces/CreateManyOptions.html +1 -1
- package/docs/api/interfaces/EffectCompensateOptions.html +1 -1
- package/docs/api/interfaces/EffectConfirmOptions.html +1 -1
- package/docs/api/interfaces/EffectFailOptions.html +1 -1
- package/docs/api/interfaces/EffectStatusOptions.html +1 -1
- package/docs/api/interfaces/ExtendLeaseOptions.html +2 -2
- package/docs/api/interfaces/FailOptions.html +2 -2
- package/docs/api/interfaces/FailOutcome.html +1 -1
- package/docs/api/interfaces/FerricStoreClientFromUrlOptions.html +1 -1
- package/docs/api/interfaces/FerricStoreClientOptions.html +1 -1
- package/docs/api/interfaces/FlowPolicyBackoffSnapshot.html +5 -0
- package/docs/api/interfaces/FlowPolicyOptions.html +8 -4
- package/docs/api/interfaces/FlowPolicyRetentionSnapshot.html +3 -0
- package/docs/api/interfaces/FlowPolicyRetrySnapshot.html +4 -0
- package/docs/api/interfaces/FlowPolicySnapshot.html +17 -0
- package/docs/api/interfaces/FlowPolicyStateSnapshot.html +6 -0
- package/docs/api/interfaces/HistoryOptions.html +2 -2
- package/docs/api/interfaces/InvocationCreateOptions.html +2 -2
- package/docs/api/interfaces/LeaseMutationOptions.html +2 -2
- package/docs/api/interfaces/LimitListOptions.html +1 -1
- package/docs/api/interfaces/MutateOptions.html +2 -2
- package/docs/api/interfaces/NamedValueMutation.html +1 -1
- package/docs/api/interfaces/ProtocolCommand.html +2 -2
- package/docs/api/interfaces/ReadOptions.html +2 -2
- package/docs/api/interfaces/ReclaimOptions.html +1 -1
- package/docs/api/interfaces/RequestContext.html +2 -2
- package/docs/api/interfaces/RequestContextOptions.html +2 -2
- package/docs/api/interfaces/RetryOptions.html +2 -2
- package/docs/api/interfaces/RetryOutcome.html +1 -1
- package/docs/api/interfaces/RunStepsItem.html +2 -2
- package/docs/api/interfaces/RunStepsManyOptions.html +2 -2
- package/docs/api/interfaces/SearchOptions.html +2 -2
- package/docs/api/interfaces/StepContinueOptions.html +3 -3
- package/docs/api/interfaces/TDigestCreateOptions.html +1 -1
- package/docs/api/interfaces/TDigestMergeOptions.html +1 -1
- package/docs/api/interfaces/TransitionOptions.html +2 -2
- package/docs/api/interfaces/TransitionOutcome.html +1 -1
- package/docs/api/modules.html +1 -1
- package/docs/api/types/ConnectionRequestDisposition.html +1 -1
- package/docs/api/types/FlowPolicyBackoffKind.html +1 -0
- package/docs/api/types/ManagementPairs.html +1 -1
- package/docs/api/types/SearchStateMeta.html +1 -1
- package/docs/api/variables/FERRICSTORE_MINIMUM_SERVER_VERSION.html +1 -1
- package/docs/api/variables/FERRICSTORE_NATIVE_PROTOCOL_VERSION.html +1 -1
- package/docs/api/variables/FERRICSTORE_SDK_VERSION.html +1 -1
- package/docs/api/variables/MAX_FLOW_POLICY_GENERATION.html +1 -0
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -56,6 +56,7 @@ __export(index_exports, {
|
|
|
56
56
|
ListStore: () => ListStore,
|
|
57
57
|
LockHeldError: () => LockHeldError,
|
|
58
58
|
LockNotOwnedError: () => LockNotOwnedError,
|
|
59
|
+
MAX_FLOW_POLICY_GENERATION: () => MAX_FLOW_POLICY_GENERATION,
|
|
59
60
|
NativeAdapter: () => NativeAdapter,
|
|
60
61
|
OverloadedError: () => OverloadedError,
|
|
61
62
|
Queue: () => Queue,
|
|
@@ -70,6 +71,7 @@ __export(index_exports, {
|
|
|
70
71
|
SetStore: () => SetStore,
|
|
71
72
|
SortedSetStore: () => SortedSetStore,
|
|
72
73
|
StaleLeaseError: () => StaleLeaseError,
|
|
74
|
+
StalePolicyGenerationError: () => StalePolicyGenerationError,
|
|
73
75
|
StreamStore: () => StreamStore,
|
|
74
76
|
TDigestStore: () => TDigestStore,
|
|
75
77
|
TopKStore: () => TopKStore,
|
|
@@ -102,7 +104,7 @@ function assertSafeVariadicDispatch(argumentCount, arrayCapability) {
|
|
|
102
104
|
// src/native-adapter.ts
|
|
103
105
|
var import_node_net3 = require("net");
|
|
104
106
|
var import_node_tls3 = require("tls");
|
|
105
|
-
var
|
|
107
|
+
var import_node_buffer26 = require("buffer");
|
|
106
108
|
|
|
107
109
|
// src/errors.ts
|
|
108
110
|
var FerricStoreError = class extends Error {
|
|
@@ -150,6 +152,9 @@ var FlowWrongStateError = class extends FerricStoreError {
|
|
|
150
152
|
var StaleLeaseError = class extends FerricStoreError {
|
|
151
153
|
code = "stale_lease";
|
|
152
154
|
};
|
|
155
|
+
var StalePolicyGenerationError = class extends FerricStoreError {
|
|
156
|
+
code = "stale_policy_generation";
|
|
157
|
+
};
|
|
153
158
|
var FlowAlreadyExistsError = class extends FerricStoreError {
|
|
154
159
|
code = "flow_already_exists";
|
|
155
160
|
};
|
|
@@ -215,6 +220,9 @@ function classifyServerError(message, raw, cause, status) {
|
|
|
215
220
|
if (code === "stale_lease" || code === "stale_flow_lease" || lower.includes("stale flow lease") || lower.includes("stale lease") || lower.includes("stale token")) {
|
|
216
221
|
return new StaleLeaseError(message, { cause, raw });
|
|
217
222
|
}
|
|
223
|
+
if (code === "stale_generation" || code === "stale_policy_generation" || code === "stale_flow_policy_generation" || lower.includes("stale flow policy generation") || lower.includes("stale policy generation")) {
|
|
224
|
+
return new StalePolicyGenerationError(message, { cause, raw });
|
|
225
|
+
}
|
|
218
226
|
if (code === "flow_not_found" || lower.includes("flow") && (lower.includes("not found") || lower.includes("does not exist"))) {
|
|
219
227
|
return new FlowNotFoundError(message, { cause, raw });
|
|
220
228
|
}
|
|
@@ -1268,7 +1276,7 @@ var NativeHeartbeat = class {
|
|
|
1268
1276
|
};
|
|
1269
1277
|
|
|
1270
1278
|
// src/protocol.ts
|
|
1271
|
-
var
|
|
1279
|
+
var import_node_buffer22 = require("buffer");
|
|
1272
1280
|
|
|
1273
1281
|
// src/command-grammar.ts
|
|
1274
1282
|
var import_node_buffer3 = require("buffer");
|
|
@@ -2090,6 +2098,8 @@ var OPCODES = {
|
|
|
2090
2098
|
flowRetryMany: COMMAND_OPCODES["FLOW.RETRY_MANY"],
|
|
2091
2099
|
flowFailMany: COMMAND_OPCODES["FLOW.FAIL_MANY"],
|
|
2092
2100
|
flowReclaim: COMMAND_OPCODES["FLOW.RECLAIM"],
|
|
2101
|
+
flowPolicySet: COMMAND_OPCODES["FLOW.POLICY.SET"],
|
|
2102
|
+
flowPolicyGet: COMMAND_OPCODES["FLOW.POLICY.GET"],
|
|
2093
2103
|
flowSpawnChildren: COMMAND_OPCODES["FLOW.SPAWN_CHILDREN"],
|
|
2094
2104
|
flowStepContinue: COMMAND_OPCODES["FLOW.STEP_CONTINUE"],
|
|
2095
2105
|
flowStartAndClaim: COMMAND_OPCODES["FLOW.START_AND_CLAIM"],
|
|
@@ -4254,6 +4264,162 @@ function flowSignalPayload(args) {
|
|
|
4254
4264
|
return { opcode: OPCODES.flowSignal, payload: { id: args[0], ...options } };
|
|
4255
4265
|
}
|
|
4256
4266
|
|
|
4267
|
+
// src/protocol-flow-policy.ts
|
|
4268
|
+
var import_node_buffer12 = require("buffer");
|
|
4269
|
+
var BACKOFF_FIELDS = {
|
|
4270
|
+
BASE_MS: "base_ms",
|
|
4271
|
+
MAX_MS: "max_ms",
|
|
4272
|
+
JITTER_PCT: "jitter_pct"
|
|
4273
|
+
};
|
|
4274
|
+
var RETENTION_FIELDS = {
|
|
4275
|
+
RETENTION_TTL: "ttl_ms",
|
|
4276
|
+
RETENTION_TTL_MS: "ttl_ms",
|
|
4277
|
+
HISTORY_MAX_EVENTS: "history_max_events"
|
|
4278
|
+
};
|
|
4279
|
+
function flowPolicySetPayload(args) {
|
|
4280
|
+
if (!hasOwnCommandArgument(args, 0, args.length, "Flow policy arguments")) return void 0;
|
|
4281
|
+
if (!isBinaryArgument(args[0])) return void 0;
|
|
4282
|
+
const payload = { type: args[0] };
|
|
4283
|
+
const states = {};
|
|
4284
|
+
let target = payload;
|
|
4285
|
+
for (let index = 1; index < args.length; index += 2) {
|
|
4286
|
+
if (!hasOwnCommandArgument(args, index, args.length, "Flow policy arguments") || !hasOwnCommandArgument(args, index + 1, args.length, "Flow policy arguments")) return void 0;
|
|
4287
|
+
const token = optionalText(args[index])?.toUpperCase();
|
|
4288
|
+
const value = args[index + 1];
|
|
4289
|
+
if (token == null || value == null) return void 0;
|
|
4290
|
+
if (token === "STATE") {
|
|
4291
|
+
if (!isBinaryArgument(value)) return void 0;
|
|
4292
|
+
const state = asText(value);
|
|
4293
|
+
target = {};
|
|
4294
|
+
setOwnValue2(states, state, target);
|
|
4295
|
+
setOwnValue2(payload, "states", states);
|
|
4296
|
+
continue;
|
|
4297
|
+
}
|
|
4298
|
+
if (token === "MODE") {
|
|
4299
|
+
if (!isBinaryArgument(value)) return void 0;
|
|
4300
|
+
const mode = optionalText(value)?.toLowerCase();
|
|
4301
|
+
if (target === payload || mode !== "fifo" && mode !== "parallel") return void 0;
|
|
4302
|
+
setOwnValue2(target, "mode", mode);
|
|
4303
|
+
continue;
|
|
4304
|
+
}
|
|
4305
|
+
if (token === "EXPECTED_GENERATION") {
|
|
4306
|
+
if (target !== payload) return void 0;
|
|
4307
|
+
const generation = integerOption(value);
|
|
4308
|
+
if (generation == null || generation < 0) return void 0;
|
|
4309
|
+
setOwnValue2(payload, "expected_generation", generation);
|
|
4310
|
+
continue;
|
|
4311
|
+
}
|
|
4312
|
+
if (token === "REPLACE") {
|
|
4313
|
+
if (target !== payload || !isBoolToken(value)) return void 0;
|
|
4314
|
+
setOwnValue2(payload, "replace", boolArg(value));
|
|
4315
|
+
continue;
|
|
4316
|
+
}
|
|
4317
|
+
if (token === "MAX_ACTIVE_MS") {
|
|
4318
|
+
if (target !== payload) return void 0;
|
|
4319
|
+
const maxActiveMs = maxActiveOption(value);
|
|
4320
|
+
if (maxActiveMs == null) return void 0;
|
|
4321
|
+
setOwnValue2(payload, "max_active_ms", maxActiveMs);
|
|
4322
|
+
continue;
|
|
4323
|
+
}
|
|
4324
|
+
if (token === "INDEXED_STATE_META") {
|
|
4325
|
+
if (target !== payload || !isBinaryArgument(value)) return void 0;
|
|
4326
|
+
setOwnValue2(payload, "indexed_state_meta", value);
|
|
4327
|
+
continue;
|
|
4328
|
+
}
|
|
4329
|
+
if (token === "INDEXED_ATTRIBUTES") {
|
|
4330
|
+
if (target !== payload) return void 0;
|
|
4331
|
+
const names = indexedAttributes(value);
|
|
4332
|
+
if (names == null) return void 0;
|
|
4333
|
+
setOwnValue2(payload, "indexed_attributes", names);
|
|
4334
|
+
continue;
|
|
4335
|
+
}
|
|
4336
|
+
if (token === "MAX_RETRIES") {
|
|
4337
|
+
const parsed = integerOption(value);
|
|
4338
|
+
if (parsed == null) return void 0;
|
|
4339
|
+
setOwnValue2(objectField(target, "retry"), "max_retries", parsed);
|
|
4340
|
+
continue;
|
|
4341
|
+
}
|
|
4342
|
+
if (token === "EXHAUSTED_TO") {
|
|
4343
|
+
if (!isBinaryArgument(value)) return void 0;
|
|
4344
|
+
setOwnValue2(objectField(target, "retry"), "exhausted_to", value);
|
|
4345
|
+
continue;
|
|
4346
|
+
}
|
|
4347
|
+
const backoffField = BACKOFF_FIELDS[token];
|
|
4348
|
+
if (backoffField != null) {
|
|
4349
|
+
const parsed = integerOption(value);
|
|
4350
|
+
if (parsed == null) return void 0;
|
|
4351
|
+
setOwnValue2(objectField(objectField(target, "retry"), "backoff"), backoffField, parsed);
|
|
4352
|
+
continue;
|
|
4353
|
+
}
|
|
4354
|
+
if (token === "BACKOFF") {
|
|
4355
|
+
if (!isBinaryArgument(value)) return void 0;
|
|
4356
|
+
const kind = optionalText(value)?.toLowerCase();
|
|
4357
|
+
if (kind == null) return void 0;
|
|
4358
|
+
setOwnValue2(objectField(objectField(target, "retry"), "backoff"), "kind", kind);
|
|
4359
|
+
continue;
|
|
4360
|
+
}
|
|
4361
|
+
const retentionField = RETENTION_FIELDS[token];
|
|
4362
|
+
if (retentionField != null) {
|
|
4363
|
+
if (target === payload) return void 0;
|
|
4364
|
+
const parsed = integerOption(value);
|
|
4365
|
+
if (parsed == null) return void 0;
|
|
4366
|
+
setOwnValue2(objectField(target, "retention"), retentionField, parsed);
|
|
4367
|
+
continue;
|
|
4368
|
+
}
|
|
4369
|
+
return void 0;
|
|
4370
|
+
}
|
|
4371
|
+
return { opcode: OPCODES.flowPolicySet, payload };
|
|
4372
|
+
}
|
|
4373
|
+
function flowPolicyGetPayload(args) {
|
|
4374
|
+
if (!hasOwnCommandArgument(args, 0, args.length, "Flow policy arguments")) return void 0;
|
|
4375
|
+
if (!isBinaryArgument(args[0])) return void 0;
|
|
4376
|
+
if (args.length !== 1 && args.length !== 3) return void 0;
|
|
4377
|
+
const payload = { type: args[0] };
|
|
4378
|
+
if (args.length === 3) {
|
|
4379
|
+
if (!hasOwnCommandArgument(args, 1, args.length, "Flow policy arguments") || !hasOwnCommandArgument(args, 2, args.length, "Flow policy arguments") || optionalText(args[1])?.toUpperCase() !== "STATE" || !isBinaryArgument(args[2])) return void 0;
|
|
4380
|
+
setOwnValue2(payload, "state", args[2]);
|
|
4381
|
+
}
|
|
4382
|
+
return { opcode: OPCODES.flowPolicyGet, payload };
|
|
4383
|
+
}
|
|
4384
|
+
function integerOption(value) {
|
|
4385
|
+
try {
|
|
4386
|
+
return safeIntegerNumberArg(value);
|
|
4387
|
+
} catch {
|
|
4388
|
+
return void 0;
|
|
4389
|
+
}
|
|
4390
|
+
}
|
|
4391
|
+
function maxActiveOption(value) {
|
|
4392
|
+
if (isBinaryArgument(value) && asText(value).toLowerCase() === "infinity") {
|
|
4393
|
+
return "infinity";
|
|
4394
|
+
}
|
|
4395
|
+
return integerOption(value);
|
|
4396
|
+
}
|
|
4397
|
+
function isBinaryArgument(value) {
|
|
4398
|
+
return typeof value === "string" || import_node_buffer12.Buffer.isBuffer(value) || value instanceof Uint8Array;
|
|
4399
|
+
}
|
|
4400
|
+
function objectField(target, name) {
|
|
4401
|
+
const existing = Object.hasOwn(target, name) ? target[name] : void 0;
|
|
4402
|
+
if (typeof existing === "object" && existing != null && !Array.isArray(existing)) {
|
|
4403
|
+
return existing;
|
|
4404
|
+
}
|
|
4405
|
+
const value = {};
|
|
4406
|
+
setOwnValue2(target, name, value);
|
|
4407
|
+
return value;
|
|
4408
|
+
}
|
|
4409
|
+
function indexedAttributes(value) {
|
|
4410
|
+
if (Array.isArray(value)) {
|
|
4411
|
+
return value.every((item) => typeof item === "string") ? value : void 0;
|
|
4412
|
+
}
|
|
4413
|
+
const source = optionalText(value);
|
|
4414
|
+
if (source == null) return void 0;
|
|
4415
|
+
try {
|
|
4416
|
+
const parsed = JSON.parse(source);
|
|
4417
|
+
return Array.isArray(parsed) && parsed.every((item) => typeof item === "string") ? parsed : void 0;
|
|
4418
|
+
} catch {
|
|
4419
|
+
return void 0;
|
|
4420
|
+
}
|
|
4421
|
+
}
|
|
4422
|
+
|
|
4257
4423
|
// src/protocol-connection-policy.ts
|
|
4258
4424
|
function assertCommandDoesNotRequirePinnedConnection(args) {
|
|
4259
4425
|
const outer = commandName(args[0]);
|
|
@@ -4301,7 +4467,7 @@ function commandRequiresOrderedPipelineExecution(args) {
|
|
|
4301
4467
|
}
|
|
4302
4468
|
|
|
4303
4469
|
// src/protocol-compact-request.ts
|
|
4304
|
-
var
|
|
4470
|
+
var import_node_buffer13 = require("buffer");
|
|
4305
4471
|
function compactMsetPayload(args, maxBodyBytes) {
|
|
4306
4472
|
if (args.length % 2 !== 0) throw new FerricStoreError("MSET requires key/value pairs");
|
|
4307
4473
|
const minimum = 6 + args.length * 4;
|
|
@@ -4320,7 +4486,7 @@ function compactMsetPayload(args, maxBodyBytes) {
|
|
|
4320
4486
|
total += 4 + byteLength;
|
|
4321
4487
|
}
|
|
4322
4488
|
assertCompactPayloadFits(total, maxBodyBytes);
|
|
4323
|
-
const out =
|
|
4489
|
+
const out = import_node_buffer13.Buffer.allocUnsafe(total);
|
|
4324
4490
|
let offset = writeCompactPipelineHeader(out, 1, args.length / 2);
|
|
4325
4491
|
for (let index = 0; index < args.length; index += 1) {
|
|
4326
4492
|
offset = writeBinaryValue(out, offset, args[index], byteLengths[index] ?? 0);
|
|
@@ -4344,7 +4510,7 @@ function compactKeyPipelinePayload(opcode, args, mode, maxBodyBytes) {
|
|
|
4344
4510
|
total += 4 + byteLength;
|
|
4345
4511
|
}
|
|
4346
4512
|
assertCompactPayloadFits(total, maxBodyBytes);
|
|
4347
|
-
const out =
|
|
4513
|
+
const out = import_node_buffer13.Buffer.allocUnsafe(total);
|
|
4348
4514
|
let offset = writeCompactPipelineHeader(out, mode, args.length);
|
|
4349
4515
|
for (let index = 0; index < args.length; index += 1) {
|
|
4350
4516
|
offset = writeBinaryValue(out, offset, args[index], byteLengths[index] ?? 0);
|
|
@@ -4354,7 +4520,7 @@ function compactKeyPipelinePayload(opcode, args, mode, maxBodyBytes) {
|
|
|
4354
4520
|
function compactPipelinePayload(commands, maxBodyBytes) {
|
|
4355
4521
|
if (commands.length === 0) {
|
|
4356
4522
|
assertCompactPayloadFits(6, maxBodyBytes);
|
|
4357
|
-
const out =
|
|
4523
|
+
const out = import_node_buffer13.Buffer.allocUnsafe(6);
|
|
4358
4524
|
writeCompactPipelineHeader(out, 128 | 2, 0);
|
|
4359
4525
|
return out;
|
|
4360
4526
|
}
|
|
@@ -4396,7 +4562,7 @@ function compactSetPipelinePayload(commands, maxBodyBytes) {
|
|
|
4396
4562
|
total += 8 + keyByteLength + valueByteLength;
|
|
4397
4563
|
}
|
|
4398
4564
|
assertCompactPayloadFits(total, maxBodyBytes);
|
|
4399
|
-
const out =
|
|
4565
|
+
const out = import_node_buffer13.Buffer.allocUnsafe(total);
|
|
4400
4566
|
let offset = writeCompactPipelineHeader(out, 128 | 1, commands.length);
|
|
4401
4567
|
for (let index = 0; index < commands.length; index += 1) {
|
|
4402
4568
|
offset = writeBinaryValue(out, offset, argumentValues[index * 2], argumentByteLengths[index * 2] ?? 0);
|
|
@@ -4431,7 +4597,7 @@ function compactGetPipelinePayload(commands, maxBodyBytes) {
|
|
|
4431
4597
|
total += 4 + keyByteLength;
|
|
4432
4598
|
}
|
|
4433
4599
|
assertCompactPayloadFits(total, maxBodyBytes);
|
|
4434
|
-
const out =
|
|
4600
|
+
const out = import_node_buffer13.Buffer.allocUnsafe(total);
|
|
4435
4601
|
let offset = writeCompactPipelineHeader(out, 128 | 2, commands.length);
|
|
4436
4602
|
for (let index = 0; index < commands.length; index += 1) {
|
|
4437
4603
|
offset = writeBinaryValue(out, offset, keys[index], keyByteLengths[index] ?? 0);
|
|
@@ -4445,7 +4611,7 @@ function compactArgumentsEligible(args, sparseMessage) {
|
|
|
4445
4611
|
}
|
|
4446
4612
|
return true;
|
|
4447
4613
|
}
|
|
4448
|
-
function compactPipelineEligible(commands,
|
|
4614
|
+
function compactPipelineEligible(commands, commandName5, argumentCount) {
|
|
4449
4615
|
for (let index = 0; index < commands.length; index += 1) {
|
|
4450
4616
|
const command = commands[index];
|
|
4451
4617
|
if (!Object.hasOwn(commands, index) || !Array.isArray(command)) {
|
|
@@ -4457,7 +4623,7 @@ function compactPipelineEligible(commands, commandName4, argumentCount) {
|
|
|
4457
4623
|
throw new TypeError("pipeline command arguments must be dense");
|
|
4458
4624
|
}
|
|
4459
4625
|
}
|
|
4460
|
-
if (!commandNameIs(command[0],
|
|
4626
|
+
if (!commandNameIs(command[0], commandName5)) return false;
|
|
4461
4627
|
for (let argumentIndex = 1; argumentIndex < argumentCount; argumentIndex += 1) {
|
|
4462
4628
|
if (!isCompactBinaryScalar(command[argumentIndex])) return false;
|
|
4463
4629
|
}
|
|
@@ -4472,7 +4638,7 @@ function writeCompactPipelineHeader(out, mode, count) {
|
|
|
4472
4638
|
}
|
|
4473
4639
|
|
|
4474
4640
|
// src/protocol-kv.ts
|
|
4475
|
-
var
|
|
4641
|
+
var import_node_buffer14 = require("buffer");
|
|
4476
4642
|
function collectionProtocolCommand(command, args) {
|
|
4477
4643
|
switch (command) {
|
|
4478
4644
|
case "CAS":
|
|
@@ -4719,17 +4885,17 @@ function parsedNumber(value) {
|
|
|
4719
4885
|
}
|
|
4720
4886
|
}
|
|
4721
4887
|
function isBinaryCommandArgument(value) {
|
|
4722
|
-
return typeof value === "string" ||
|
|
4888
|
+
return typeof value === "string" || import_node_buffer14.Buffer.isBuffer(value);
|
|
4723
4889
|
}
|
|
4724
4890
|
function isDirectKvValueArgument(value) {
|
|
4725
4891
|
return isBinaryCommandArgument(value) || typeof value === "object" && value != null;
|
|
4726
4892
|
}
|
|
4727
4893
|
function binaryToken(value) {
|
|
4728
|
-
return typeof value === "string" ? value.toUpperCase() :
|
|
4894
|
+
return typeof value === "string" ? value.toUpperCase() : import_node_buffer14.Buffer.isBuffer(value) ? value.toString("utf8").toUpperCase() : void 0;
|
|
4729
4895
|
}
|
|
4730
4896
|
|
|
4731
4897
|
// src/protocol-value.ts
|
|
4732
|
-
var
|
|
4898
|
+
var import_node_buffer15 = require("buffer");
|
|
4733
4899
|
function planValueWithLimit(value, maxBytes) {
|
|
4734
4900
|
const budget = {
|
|
4735
4901
|
maxBytes,
|
|
@@ -4784,7 +4950,7 @@ function planContainerValue(value, budget, ancestors, depth) {
|
|
|
4784
4950
|
let byteLength = 5;
|
|
4785
4951
|
let index = 0;
|
|
4786
4952
|
for (const [key, item] of entries) {
|
|
4787
|
-
const keyByteLength =
|
|
4953
|
+
const keyByteLength = import_node_buffer15.Buffer.byteLength(key);
|
|
4788
4954
|
consumeEncodeBytes(budget, 4 + keyByteLength);
|
|
4789
4955
|
const valuePlan = planValueAt(item, budget, ancestors, depth + 1);
|
|
4790
4956
|
entryPlans[index] = { key, keyByteLength, value: valuePlan };
|
|
@@ -4833,7 +4999,7 @@ function planScalarValue(value, budget) {
|
|
|
4833
4999
|
consumeEncodeBytes(budget, 9);
|
|
4834
5000
|
return { byteLength: 9, tag: 7, value };
|
|
4835
5001
|
}
|
|
4836
|
-
if (typeof value === "string" ||
|
|
5002
|
+
if (typeof value === "string" || import_node_buffer15.Buffer.isBuffer(value) || value instanceof Uint8Array) {
|
|
4837
5003
|
const valueByteLength = binaryValueByteLength(value);
|
|
4838
5004
|
const byteLength = 5 + valueByteLength;
|
|
4839
5005
|
consumeEncodeBytes(budget, byteLength);
|
|
@@ -4857,7 +5023,7 @@ function writeValuePlan(output, start, plan) {
|
|
|
4857
5023
|
offset += 4;
|
|
4858
5024
|
if (typeof plan.value === "string") {
|
|
4859
5025
|
output.write(plan.value, offset, plan.valueByteLength, "utf8");
|
|
4860
|
-
} else if (
|
|
5026
|
+
} else if (import_node_buffer15.Buffer.isBuffer(plan.value)) {
|
|
4861
5027
|
plan.value.copy(output, offset);
|
|
4862
5028
|
} else {
|
|
4863
5029
|
output.set(plan.value, offset);
|
|
@@ -4991,20 +5157,20 @@ function requireAvailable(data, offset, size) {
|
|
|
4991
5157
|
}
|
|
4992
5158
|
|
|
4993
5159
|
// src/key-slot-validation.ts
|
|
4994
|
-
var
|
|
5160
|
+
var import_node_buffer17 = require("buffer");
|
|
4995
5161
|
|
|
4996
5162
|
// src/topology-utilities.ts
|
|
4997
|
-
var
|
|
5163
|
+
var import_node_buffer16 = require("buffer");
|
|
4998
5164
|
function isPlainObject3(value) {
|
|
4999
|
-
return typeof value === "object" && value != null && !Array.isArray(value) && !
|
|
5165
|
+
return typeof value === "object" && value != null && !Array.isArray(value) && !import_node_buffer16.Buffer.isBuffer(value);
|
|
5000
5166
|
}
|
|
5001
5167
|
function getField(source, ...keys) {
|
|
5002
5168
|
if (source instanceof Map) {
|
|
5003
5169
|
for (const key of keys) {
|
|
5004
5170
|
if (source.has(key)) return source.get(key);
|
|
5005
|
-
const bufferKey =
|
|
5171
|
+
const bufferKey = import_node_buffer16.Buffer.from(key);
|
|
5006
5172
|
for (const [itemKey, value] of source.entries()) {
|
|
5007
|
-
if (
|
|
5173
|
+
if (import_node_buffer16.Buffer.isBuffer(itemKey) && itemKey.equals(bufferKey)) return value;
|
|
5008
5174
|
}
|
|
5009
5175
|
}
|
|
5010
5176
|
return void 0;
|
|
@@ -5018,7 +5184,7 @@ function getField(source, ...keys) {
|
|
|
5018
5184
|
}
|
|
5019
5185
|
function textOrUndefined(value) {
|
|
5020
5186
|
if (typeof value === "string") return value;
|
|
5021
|
-
if (
|
|
5187
|
+
if (import_node_buffer16.Buffer.isBuffer(value)) return value.toString("utf8");
|
|
5022
5188
|
return void 0;
|
|
5023
5189
|
}
|
|
5024
5190
|
function numberOrUndefined(value) {
|
|
@@ -5193,7 +5359,7 @@ function stringHashRange(key) {
|
|
|
5193
5359
|
var validatedCommands = /* @__PURE__ */ new WeakSet();
|
|
5194
5360
|
function assertAtomicKeyValueCommandSharesSlot(args) {
|
|
5195
5361
|
const value = args[0];
|
|
5196
|
-
const command = (typeof value === "string" ? value :
|
|
5362
|
+
const command = (typeof value === "string" ? value : import_node_buffer17.Buffer.isBuffer(value) ? value.toString("utf8") : "").toUpperCase();
|
|
5197
5363
|
if (command === "MSET" || command === "MSETNX") {
|
|
5198
5364
|
assertKeyValueCommandSharesSlot(args, command);
|
|
5199
5365
|
}
|
|
@@ -5203,7 +5369,7 @@ function assertKeyValueCommandSharesSlot(args, command) {
|
|
|
5203
5369
|
let expectedSlot;
|
|
5204
5370
|
for (let index = 1; index < args.length; index += 2) {
|
|
5205
5371
|
const key = args[index];
|
|
5206
|
-
if (typeof key !== "string" && !
|
|
5372
|
+
if (typeof key !== "string" && !import_node_buffer17.Buffer.isBuffer(key)) return;
|
|
5207
5373
|
const slot = routingSlotForKey(key);
|
|
5208
5374
|
expectedSlot ??= slot;
|
|
5209
5375
|
if (slot !== expectedSlot) {
|
|
@@ -5214,13 +5380,13 @@ function assertKeyValueCommandSharesSlot(args, command) {
|
|
|
5214
5380
|
}
|
|
5215
5381
|
|
|
5216
5382
|
// src/protocol-response.ts
|
|
5217
|
-
var
|
|
5383
|
+
var import_node_buffer21 = require("buffer");
|
|
5218
5384
|
|
|
5219
5385
|
// src/protocol-compact-response.ts
|
|
5220
|
-
var
|
|
5386
|
+
var import_node_buffer20 = require("buffer");
|
|
5221
5387
|
|
|
5222
5388
|
// src/native-negotiation.ts
|
|
5223
|
-
var
|
|
5389
|
+
var import_node_buffer18 = require("buffer");
|
|
5224
5390
|
var EMPTY_COMPACT_RESPONSE_OPCODES = /* @__PURE__ */ new Map();
|
|
5225
5391
|
function nativeNegotiation(value) {
|
|
5226
5392
|
const capabilities = field(value, "capabilities") ?? value;
|
|
@@ -5288,14 +5454,14 @@ function nonNegativeSafeInteger2(value) {
|
|
|
5288
5454
|
}
|
|
5289
5455
|
function text2(value) {
|
|
5290
5456
|
if (typeof value === "string") return value;
|
|
5291
|
-
if (
|
|
5292
|
-
return
|
|
5457
|
+
if (import_node_buffer18.Buffer.isBuffer(value) || value instanceof Uint8Array) {
|
|
5458
|
+
return import_node_buffer18.Buffer.from(value).toString("utf8");
|
|
5293
5459
|
}
|
|
5294
5460
|
return void 0;
|
|
5295
5461
|
}
|
|
5296
5462
|
|
|
5297
5463
|
// src/protocol-compact-collections.ts
|
|
5298
|
-
var
|
|
5464
|
+
var import_node_buffer19 = require("buffer");
|
|
5299
5465
|
function decodeCompactIntegerList(data, budget) {
|
|
5300
5466
|
requireAvailable(data, 0, 5);
|
|
5301
5467
|
const count = data.readUInt32BE(1);
|
|
@@ -5441,7 +5607,7 @@ function decodeCompactOkList(data, budget) {
|
|
|
5441
5607
|
const count = data.readUInt32BE(1);
|
|
5442
5608
|
requireCompactContainer2(count, budget);
|
|
5443
5609
|
if (data.byteLength !== 5) throw new FerricStoreError("invalid compact OK list response");
|
|
5444
|
-
return Array.from({ length: count }, () =>
|
|
5610
|
+
return Array.from({ length: count }, () => import_node_buffer20.Buffer.from("OK"));
|
|
5445
5611
|
}
|
|
5446
5612
|
function decodeCompactKvGet(data) {
|
|
5447
5613
|
requireAvailable(data, 0, 2);
|
|
@@ -5487,7 +5653,7 @@ function decodeCompactMgetFixed(data, budget) {
|
|
|
5487
5653
|
if (size === NULL_U32 || data.byteLength !== expected) {
|
|
5488
5654
|
throw new FerricStoreError("invalid compact fixed MGET response");
|
|
5489
5655
|
}
|
|
5490
|
-
if (size === 0) return new Array(count).fill(
|
|
5656
|
+
if (size === 0) return new Array(count).fill(import_node_buffer20.Buffer.alloc(0));
|
|
5491
5657
|
const values = new Array(count);
|
|
5492
5658
|
for (let index = 0, offset = 9; index < count; index += 1, offset += size) {
|
|
5493
5659
|
values[index] = data.subarray(offset, offset + size);
|
|
@@ -5702,7 +5868,7 @@ function requireCompactContainer2(count, budget) {
|
|
|
5702
5868
|
}
|
|
5703
5869
|
function errorMessage(status, value) {
|
|
5704
5870
|
if (typeof value === "string") return value;
|
|
5705
|
-
if (
|
|
5871
|
+
if (import_node_buffer20.Buffer.isBuffer(value)) return value.toString("utf8");
|
|
5706
5872
|
if (typeof value === "object" && value != null && Object.hasOwn(value, "message")) {
|
|
5707
5873
|
const message = value.message;
|
|
5708
5874
|
return typeof message === "string" ? message : String(message);
|
|
@@ -5782,7 +5948,7 @@ function unwrapPipelineResponse(value, options = {}, expectedItems) {
|
|
|
5782
5948
|
return out;
|
|
5783
5949
|
}
|
|
5784
5950
|
function pipelineStatus(value) {
|
|
5785
|
-
if (typeof value !== "string" && !
|
|
5951
|
+
if (typeof value !== "string" && !import_node_buffer21.Buffer.isBuffer(value) && !(value instanceof Uint8Array)) return null;
|
|
5786
5952
|
const status = asText(value).toLowerCase();
|
|
5787
5953
|
return status === "ok" || status === "busy" || status === "error" ? status : null;
|
|
5788
5954
|
}
|
|
@@ -5797,7 +5963,7 @@ function decodeResponseValue(opcode, body, hints) {
|
|
|
5797
5963
|
}
|
|
5798
5964
|
function errorMessage2(status, value) {
|
|
5799
5965
|
if (typeof value === "string") return value;
|
|
5800
|
-
if (
|
|
5966
|
+
if (import_node_buffer21.Buffer.isBuffer(value)) return value.toString("utf8");
|
|
5801
5967
|
if (typeof value === "object" && value != null && Object.hasOwn(value, "message")) {
|
|
5802
5968
|
const message = value.message;
|
|
5803
5969
|
return typeof message === "string" ? message : String(message);
|
|
@@ -5813,7 +5979,7 @@ function encodeRequest(command, requestId, maxBodyBytes = Number.MAX_SAFE_INTEGE
|
|
|
5813
5979
|
const bodyLength = customPayload ? binaryValueByteLength(command.payload) : plan?.byteLength ?? 0;
|
|
5814
5980
|
if (bodyLength > bodyLimit) throw requestFrameTooLarge(bodyLimit);
|
|
5815
5981
|
const flags = command.flags ?? 0;
|
|
5816
|
-
const frame =
|
|
5982
|
+
const frame = import_node_buffer22.Buffer.allocUnsafe(HEADER_SIZE + bodyLength);
|
|
5817
5983
|
frame.write(MAGIC, 0, "ascii");
|
|
5818
5984
|
frame.writeUInt8(REQUEST_VERSION, 4);
|
|
5819
5985
|
frame.writeUInt8(flags, 5);
|
|
@@ -5938,6 +6104,12 @@ function buildProtocolCommand(args, maxBodyBytes = Number.MAX_SAFE_INTEGER, allo
|
|
|
5938
6104
|
if (command === "FLOW.LIST") {
|
|
5939
6105
|
return (allowCustomPayload ? compactFlowListPayload(commandArgs2, maxBodyBytes) : void 0) ?? commandExec(args);
|
|
5940
6106
|
}
|
|
6107
|
+
if (command === "FLOW.POLICY.SET") {
|
|
6108
|
+
return flowPolicySetPayload(commandArgs2) ?? commandExec(args);
|
|
6109
|
+
}
|
|
6110
|
+
if (command === "FLOW.POLICY.GET") {
|
|
6111
|
+
return flowPolicyGetPayload(commandArgs2) ?? commandExec(args);
|
|
6112
|
+
}
|
|
5941
6113
|
const flowAdmin = FLOW_ADMIN_COMMANDS[command];
|
|
5942
6114
|
if (flowAdmin != null) {
|
|
5943
6115
|
return flowAdminPayload(flowAdmin.opcode, commandArgs2, flowAdmin.leadingFields) ?? commandExec(args);
|
|
@@ -6193,7 +6365,7 @@ var import_node_net2 = require("net");
|
|
|
6193
6365
|
var import_node_tls2 = require("tls");
|
|
6194
6366
|
|
|
6195
6367
|
// src/client-native-options.ts
|
|
6196
|
-
var
|
|
6368
|
+
var import_node_buffer23 = require("buffer");
|
|
6197
6369
|
|
|
6198
6370
|
// src/string-array-snapshot.ts
|
|
6199
6371
|
function snapshotOwnStringArray(values, name) {
|
|
@@ -6276,7 +6448,7 @@ function snapshotTlsOptions(options) {
|
|
|
6276
6448
|
return Object.freeze(snapshot);
|
|
6277
6449
|
}
|
|
6278
6450
|
function snapshotTlsValue(value, name) {
|
|
6279
|
-
if (
|
|
6451
|
+
if (import_node_buffer23.Buffer.isBuffer(value)) return import_node_buffer23.Buffer.from(value);
|
|
6280
6452
|
if (value instanceof Uint8Array) return value.slice();
|
|
6281
6453
|
if (Array.isArray(value)) {
|
|
6282
6454
|
const snapshot = new Array(value.length);
|
|
@@ -6831,7 +7003,7 @@ var NativeChunkAssembler = class {
|
|
|
6831
7003
|
};
|
|
6832
7004
|
|
|
6833
7005
|
// src/native-response-handler.ts
|
|
6834
|
-
var
|
|
7006
|
+
var import_node_buffer24 = require("buffer");
|
|
6835
7007
|
|
|
6836
7008
|
// src/native-receive-buffer.ts
|
|
6837
7009
|
var FRAME_ASSEMBLY_PAGE_BYTES = 64 * 1024;
|
|
@@ -7166,7 +7338,7 @@ var NativeRequestScheduler = class {
|
|
|
7166
7338
|
};
|
|
7167
7339
|
|
|
7168
7340
|
// src/native-write-queue.ts
|
|
7169
|
-
var
|
|
7341
|
+
var import_node_buffer25 = require("buffer");
|
|
7170
7342
|
var NativeWriteQueue = class {
|
|
7171
7343
|
constructor(socket, maxQueuedWriteBytes, isClosed, hasPending, rejectPending) {
|
|
7172
7344
|
this.socket = socket;
|
|
@@ -7683,7 +7855,30 @@ function executeCommandArgs(executor, args) {
|
|
|
7683
7855
|
}
|
|
7684
7856
|
|
|
7685
7857
|
// src/reconnecting-executor.ts
|
|
7686
|
-
var
|
|
7858
|
+
var import_node_buffer28 = require("buffer");
|
|
7859
|
+
|
|
7860
|
+
// src/command-retry-policy.ts
|
|
7861
|
+
var import_node_buffer27 = require("buffer");
|
|
7862
|
+
function isCasMutation(args) {
|
|
7863
|
+
const offset = commandName2(args[0]) === "COMMAND_EXEC" ? 1 : 0;
|
|
7864
|
+
const name = commandName2(args[offset]);
|
|
7865
|
+
if (name === "CAS") return true;
|
|
7866
|
+
if (name !== "FLOW.POLICY.SET") return false;
|
|
7867
|
+
for (let index = offset + 2; index < args.length; index += 2) {
|
|
7868
|
+
if (!Object.hasOwn(args, index)) return false;
|
|
7869
|
+
if (commandName2(args[index]) === "EXPECTED_GENERATION") return true;
|
|
7870
|
+
}
|
|
7871
|
+
return false;
|
|
7872
|
+
}
|
|
7873
|
+
function commandName2(value) {
|
|
7874
|
+
if (typeof value === "string") return value.toUpperCase();
|
|
7875
|
+
if (import_node_buffer27.Buffer.isBuffer(value) || value instanceof Uint8Array) {
|
|
7876
|
+
return import_node_buffer27.Buffer.from(value).toString("utf8").toUpperCase();
|
|
7877
|
+
}
|
|
7878
|
+
return void 0;
|
|
7879
|
+
}
|
|
7880
|
+
|
|
7881
|
+
// src/reconnecting-executor.ts
|
|
7687
7882
|
var ReconnectingExecutor = class {
|
|
7688
7883
|
constructor(createExecutor, options = {}) {
|
|
7689
7884
|
this.createExecutor = createExecutor;
|
|
@@ -7714,7 +7909,12 @@ var ReconnectingExecutor = class {
|
|
|
7714
7909
|
async executeCommandArgs(args) {
|
|
7715
7910
|
const snapshot = snapshotCommandArguments(args);
|
|
7716
7911
|
assertCommandHasStableConnectionState(snapshot);
|
|
7717
|
-
|
|
7912
|
+
const casMutation = isCasMutation(snapshot);
|
|
7913
|
+
return await this.withReconnect(
|
|
7914
|
+
(executor) => executeCommandArgs(executor, snapshot),
|
|
7915
|
+
casMutation ? isClosedConnectionError : isReconnectableClosedConnectionError,
|
|
7916
|
+
!casMutation
|
|
7917
|
+
);
|
|
7718
7918
|
}
|
|
7719
7919
|
async ready() {
|
|
7720
7920
|
await this.executorPromise;
|
|
@@ -7799,7 +7999,7 @@ var ReconnectingExecutor = class {
|
|
|
7799
7999
|
})();
|
|
7800
8000
|
await this.closePromise;
|
|
7801
8001
|
}
|
|
7802
|
-
async withReconnect(operation, reconnectable = isReconnectableClosedConnectionError) {
|
|
8002
|
+
async withReconnect(operation, reconnectable = isReconnectableClosedConnectionError, replayAllowed = true) {
|
|
7803
8003
|
let executor = await this.executorPromise;
|
|
7804
8004
|
let retries = 0;
|
|
7805
8005
|
for (; ; ) {
|
|
@@ -7808,6 +8008,10 @@ var ReconnectingExecutor = class {
|
|
|
7808
8008
|
return await operation(executor);
|
|
7809
8009
|
} catch (error) {
|
|
7810
8010
|
if (this.closed || retries >= this.maxRetries || !reconnectable(error)) throw error;
|
|
8011
|
+
if (!replayAllowed) {
|
|
8012
|
+
await this.reconnect(executor).catch(() => void 0);
|
|
8013
|
+
throw error;
|
|
8014
|
+
}
|
|
7811
8015
|
for (; ; ) {
|
|
7812
8016
|
retries += 1;
|
|
7813
8017
|
try {
|
|
@@ -7860,6 +8064,9 @@ var ReconnectingExecutor = class {
|
|
|
7860
8064
|
function isReconnectableClosedConnectionError(error) {
|
|
7861
8065
|
return error instanceof ConnectionClosedError && error.requestDisposition === "unsent";
|
|
7862
8066
|
}
|
|
8067
|
+
function isClosedConnectionError(error) {
|
|
8068
|
+
return error instanceof ConnectionClosedError;
|
|
8069
|
+
}
|
|
7863
8070
|
function isReadOnlyReconnectableClosedConnectionError(error) {
|
|
7864
8071
|
const pending = [error];
|
|
7865
8072
|
const seen = /* @__PURE__ */ new Set();
|
|
@@ -7878,10 +8085,10 @@ function normalizeNonNegativeInteger2(value, fallback) {
|
|
|
7878
8085
|
}
|
|
7879
8086
|
|
|
7880
8087
|
// src/topology.ts
|
|
7881
|
-
var
|
|
8088
|
+
var import_node_buffer30 = require("buffer");
|
|
7882
8089
|
|
|
7883
8090
|
// src/topology-routing.ts
|
|
7884
|
-
var
|
|
8091
|
+
var import_node_buffer29 = require("buffer");
|
|
7885
8092
|
var import_node_crypto = require("crypto");
|
|
7886
8093
|
var FLOW_PARTITION_ROUTE_CACHE_MAX = 1024;
|
|
7887
8094
|
var flowPartitionRouteCache = /* @__PURE__ */ new Map();
|
|
@@ -7901,7 +8108,7 @@ function routingKeyFromProtocolPayload(name, command) {
|
|
|
7901
8108
|
"scope"
|
|
7902
8109
|
]) {
|
|
7903
8110
|
const value = getField(command.payload, field2);
|
|
7904
|
-
if (typeof value === "string" ||
|
|
8111
|
+
if (typeof value === "string" || import_node_buffer29.Buffer.isBuffer(value)) {
|
|
7905
8112
|
return value;
|
|
7906
8113
|
}
|
|
7907
8114
|
}
|
|
@@ -7948,7 +8155,7 @@ function flowRoutingData(name, args) {
|
|
|
7948
8155
|
if (typeof partition === "string" && partition.toUpperCase() !== "AUTO" && partition.toUpperCase() !== "MIXED") {
|
|
7949
8156
|
return flowRoutingResult(flowLogicalPartitionRoutingKey(partition));
|
|
7950
8157
|
}
|
|
7951
|
-
if (
|
|
8158
|
+
if (import_node_buffer29.Buffer.isBuffer(partition)) {
|
|
7952
8159
|
const text3 = partition.toString("utf8").toUpperCase();
|
|
7953
8160
|
if (text3 !== "AUTO" && text3 !== "MIXED") {
|
|
7954
8161
|
return flowRoutingResult(flowLogicalPartitionRoutingKey(partition));
|
|
@@ -8039,13 +8246,13 @@ function flowPartitionRoutingKeyFromCommand(command, claim) {
|
|
|
8039
8246
|
return { handled: false };
|
|
8040
8247
|
}
|
|
8041
8248
|
function isRoutingKey(value) {
|
|
8042
|
-
return typeof value === "string" ||
|
|
8249
|
+
return typeof value === "string" || import_node_buffer29.Buffer.isBuffer(value);
|
|
8043
8250
|
}
|
|
8044
8251
|
function flowLogicalPartitionRoutingKey(value) {
|
|
8045
|
-
if (typeof value !== "string" && !
|
|
8252
|
+
if (typeof value !== "string" && !import_node_buffer29.Buffer.isBuffer(value)) {
|
|
8046
8253
|
return void 0;
|
|
8047
8254
|
}
|
|
8048
|
-
const bytes2 =
|
|
8255
|
+
const bytes2 = import_node_buffer29.Buffer.isBuffer(value) ? value : import_node_buffer29.Buffer.from(value);
|
|
8049
8256
|
const text3 = bytes2.toString("utf8");
|
|
8050
8257
|
const autoMatch = /^__flow_auto__:(0|[1-9]\d{0,2})$/u.exec(text3);
|
|
8051
8258
|
if (autoMatch != null) {
|
|
@@ -8054,7 +8261,7 @@ function flowLogicalPartitionRoutingKey(value) {
|
|
|
8054
8261
|
return `{fa:${bucket}}`;
|
|
8055
8262
|
}
|
|
8056
8263
|
}
|
|
8057
|
-
const cacheKey = `${
|
|
8264
|
+
const cacheKey = `${import_node_buffer29.Buffer.isBuffer(value) ? "b" : "s"}:${bytes2.toString("base64")}`;
|
|
8058
8265
|
const cached = flowPartitionRouteCache.get(cacheKey);
|
|
8059
8266
|
if (cached != null) {
|
|
8060
8267
|
flowPartitionRouteCache.delete(cacheKey);
|
|
@@ -8071,14 +8278,14 @@ function flowLogicalPartitionRoutingKey(value) {
|
|
|
8071
8278
|
return routeKey;
|
|
8072
8279
|
}
|
|
8073
8280
|
function flowAutoIdRoutingKey(value) {
|
|
8074
|
-
if (typeof value !== "string" && !
|
|
8281
|
+
if (typeof value !== "string" && !import_node_buffer29.Buffer.isBuffer(value)) {
|
|
8075
8282
|
return void 0;
|
|
8076
8283
|
}
|
|
8077
|
-
const bucket = (
|
|
8284
|
+
const bucket = (import_node_buffer29.Buffer.isBuffer(value) ? crc32(value) : crc32Utf8(value)) & 255;
|
|
8078
8285
|
return `{fa:${bucket}}`;
|
|
8079
8286
|
}
|
|
8080
8287
|
function flowClaimLogicalPartitionRoutingKey(value) {
|
|
8081
|
-
if (typeof value !== "string" && !
|
|
8288
|
+
if (typeof value !== "string" && !import_node_buffer29.Buffer.isBuffer(value)) return void 0;
|
|
8082
8289
|
const selector = commandPart(value);
|
|
8083
8290
|
if (selector === "AUTO" || selector === "ANY") return void 0;
|
|
8084
8291
|
if (selector === "GLOBAL") return "{f}";
|
|
@@ -8093,7 +8300,7 @@ function singleShardFlowClaimPartitionKey(values) {
|
|
|
8093
8300
|
return keys.some((key) => key == null) ? void 0 : singleShardKey(keys);
|
|
8094
8301
|
}
|
|
8095
8302
|
function singleShardKey(keys) {
|
|
8096
|
-
if (keys.length === 0 || keys.some((key) => typeof key !== "string" && !
|
|
8303
|
+
if (keys.length === 0 || keys.some((key) => typeof key !== "string" && !import_node_buffer29.Buffer.isBuffer(key))) {
|
|
8097
8304
|
return void 0;
|
|
8098
8305
|
}
|
|
8099
8306
|
const usable = keys;
|
|
@@ -8104,7 +8311,7 @@ function singleShardKey(keys) {
|
|
|
8104
8311
|
const firstSlot = routingSlotForKey(first);
|
|
8105
8312
|
return usable.every((key) => routingSlotForKey(key) === firstSlot) ? first : void 0;
|
|
8106
8313
|
}
|
|
8107
|
-
function
|
|
8314
|
+
function commandName3(args) {
|
|
8108
8315
|
return commandView(args).name;
|
|
8109
8316
|
}
|
|
8110
8317
|
var commandPart = commandToken;
|
|
@@ -8126,7 +8333,7 @@ function routedKeyGroups(keys, routeKey) {
|
|
|
8126
8333
|
const groups = /* @__PURE__ */ new Map();
|
|
8127
8334
|
for (let index = 0; index < keys.length; index += 1) {
|
|
8128
8335
|
const key = keys[index];
|
|
8129
|
-
if (typeof key !== "string" && !
|
|
8336
|
+
if (typeof key !== "string" && !import_node_buffer29.Buffer.isBuffer(key)) return void 0;
|
|
8130
8337
|
const route = routeKey(key);
|
|
8131
8338
|
const groupKey = `${route.endpointKey}\0${route.laneId}`;
|
|
8132
8339
|
const group = groups.get(groupKey);
|
|
@@ -8518,7 +8725,7 @@ var TopologyPipelineExecutor = class {
|
|
|
8518
8725
|
commands.forEach((command, index) => {
|
|
8519
8726
|
const routed = this.context.routeData(command);
|
|
8520
8727
|
if (routed == null) {
|
|
8521
|
-
if (decomposableCommandNames.has(
|
|
8728
|
+
if (decomposableCommandNames.has(commandName3(command) ?? "")) standalone.push({ command, index });
|
|
8522
8729
|
else {
|
|
8523
8730
|
controlCommands.push(command);
|
|
8524
8731
|
controlIndices.push(index);
|
|
@@ -8734,7 +8941,7 @@ function topologyRouteIsCurrent(topology, route) {
|
|
|
8734
8941
|
// src/topology-route-planner.ts
|
|
8735
8942
|
function topologyRouteData(args, route) {
|
|
8736
8943
|
if (args.length === 0) return void 0;
|
|
8737
|
-
const name =
|
|
8944
|
+
const name = commandName3(args);
|
|
8738
8945
|
if (name?.startsWith("FLOW.") === true) {
|
|
8739
8946
|
const routed = flowRoutingData(name, args);
|
|
8740
8947
|
return routed == null ? void 0 : {
|
|
@@ -8763,7 +8970,7 @@ var TopologyScatterExecutor = class {
|
|
|
8763
8970
|
}
|
|
8764
8971
|
dependencies;
|
|
8765
8972
|
async execute(args) {
|
|
8766
|
-
const name =
|
|
8973
|
+
const name = commandName3(args);
|
|
8767
8974
|
if (name === "MGET") {
|
|
8768
8975
|
const value = await this.scatterArray(name, args.slice(1));
|
|
8769
8976
|
return value == null ? { handled: false } : { handled: true, value };
|
|
@@ -8845,6 +9052,18 @@ var TopologyScatterExecutor = class {
|
|
|
8845
9052
|
}
|
|
8846
9053
|
};
|
|
8847
9054
|
|
|
9055
|
+
// src/topology-reroute-retry.ts
|
|
9056
|
+
async function canRetrySafeReroute(error, attempt, retryAllowed, refresh, assertOpen) {
|
|
9057
|
+
if (attempt !== 0 || !isRetryableRouteError(error)) return false;
|
|
9058
|
+
const refreshed = await refresh().then(
|
|
9059
|
+
() => true,
|
|
9060
|
+
() => false
|
|
9061
|
+
);
|
|
9062
|
+
if (!refreshed || !retryAllowed || !await waitForExplicitlySafeReroute(error)) return false;
|
|
9063
|
+
assertOpen();
|
|
9064
|
+
return true;
|
|
9065
|
+
}
|
|
9066
|
+
|
|
8848
9067
|
// src/topology.ts
|
|
8849
9068
|
var TopologyNativeAdapterPool = class _TopologyNativeAdapterPool {
|
|
8850
9069
|
adapterOptions;
|
|
@@ -9030,6 +9249,7 @@ var TopologyNativeAdapterPool = class _TopologyNativeAdapterPool {
|
|
|
9030
9249
|
this.assertOpen();
|
|
9031
9250
|
const snapshot = snapshotCommandArguments(args);
|
|
9032
9251
|
assertCommandHasStableConnectionState(snapshot);
|
|
9252
|
+
const casMutation = isCasMutation(snapshot);
|
|
9033
9253
|
let rerouteAttempt = 0;
|
|
9034
9254
|
for (let planningAttempt = 0; planningAttempt < MAX_TOPOLOGY_PLANNING_ATTEMPTS; planningAttempt += 1) {
|
|
9035
9255
|
const routed = this.routeData(snapshot);
|
|
@@ -9045,7 +9265,7 @@ var TopologyNativeAdapterPool = class _TopologyNativeAdapterPool {
|
|
|
9045
9265
|
try {
|
|
9046
9266
|
return routed.command == null ? await adapter.executeCommandOnLane(snapshot, routed.route.laneId) : await adapter.executeProtocolCommand(routed.command, routed.route.laneId);
|
|
9047
9267
|
} catch (error) {
|
|
9048
|
-
if (await this.refreshAndCanRetrySafeReroute(error, rerouteAttempt)) {
|
|
9268
|
+
if (await this.refreshAndCanRetrySafeReroute(error, rerouteAttempt, !casMutation)) {
|
|
9049
9269
|
rerouteAttempt += 1;
|
|
9050
9270
|
continue;
|
|
9051
9271
|
}
|
|
@@ -9087,6 +9307,7 @@ var TopologyNativeAdapterPool = class _TopologyNativeAdapterPool {
|
|
|
9087
9307
|
assertCommandHasStableConnectionState(command);
|
|
9088
9308
|
}
|
|
9089
9309
|
let rerouteAttempt = 0;
|
|
9310
|
+
const containsCasMutation = snapshot.some(isCasMutation);
|
|
9090
9311
|
for (let planningAttempt = 0; planningAttempt < MAX_TOPOLOGY_PLANNING_ATTEMPTS; planningAttempt += 1) {
|
|
9091
9312
|
const route = singleRouteForCommands(snapshot, (command) => this.routeData(command));
|
|
9092
9313
|
if (route == null) return void 0;
|
|
@@ -9095,7 +9316,7 @@ var TopologyNativeAdapterPool = class _TopologyNativeAdapterPool {
|
|
|
9095
9316
|
try {
|
|
9096
9317
|
return await adapter.executeFusedPipelineOnLane(snapshot, route.laneId, snapshotOptions);
|
|
9097
9318
|
} catch (error) {
|
|
9098
|
-
if (await this.refreshAndCanRetrySafeReroute(error, rerouteAttempt)) {
|
|
9319
|
+
if (await this.refreshAndCanRetrySafeReroute(error, rerouteAttempt, !containsCasMutation)) {
|
|
9099
9320
|
rerouteAttempt += 1;
|
|
9100
9321
|
continue;
|
|
9101
9322
|
}
|
|
@@ -9104,15 +9325,14 @@ var TopologyNativeAdapterPool = class _TopologyNativeAdapterPool {
|
|
|
9104
9325
|
}
|
|
9105
9326
|
throw new StaleTopologyRouteError();
|
|
9106
9327
|
}
|
|
9107
|
-
async refreshAndCanRetrySafeReroute(error, attempt) {
|
|
9108
|
-
|
|
9109
|
-
|
|
9110
|
-
|
|
9111
|
-
|
|
9328
|
+
async refreshAndCanRetrySafeReroute(error, attempt, retryAllowed = true) {
|
|
9329
|
+
return await canRetrySafeReroute(
|
|
9330
|
+
error,
|
|
9331
|
+
attempt,
|
|
9332
|
+
retryAllowed,
|
|
9333
|
+
async () => await this.refreshTopology(),
|
|
9334
|
+
() => this.assertOpen()
|
|
9112
9335
|
);
|
|
9113
|
-
if (!refreshed || !await waitForExplicitlySafeReroute(error)) return false;
|
|
9114
|
-
this.assertOpen();
|
|
9115
|
-
return true;
|
|
9116
9336
|
}
|
|
9117
9337
|
async executePipelineOnRoute(commands, route, options) {
|
|
9118
9338
|
const adapter = await this.adapterForCurrentRoute(route);
|
|
@@ -9202,7 +9422,7 @@ var TopologyNativeAdapterPool = class _TopologyNativeAdapterPool {
|
|
|
9202
9422
|
};
|
|
9203
9423
|
|
|
9204
9424
|
// src/response-map-preservation.ts
|
|
9205
|
-
var
|
|
9425
|
+
var import_node_buffer31 = require("buffer");
|
|
9206
9426
|
function toStringKeyMapPreservingValues(value) {
|
|
9207
9427
|
if (value == null) return void 0;
|
|
9208
9428
|
const result = {};
|
|
@@ -9212,7 +9432,7 @@ function toStringKeyMapPreservingValues(value) {
|
|
|
9212
9432
|
}
|
|
9213
9433
|
return result;
|
|
9214
9434
|
}
|
|
9215
|
-
if (typeof value === "object" && !Array.isArray(value) && !
|
|
9435
|
+
if (typeof value === "object" && !Array.isArray(value) && !import_node_buffer31.Buffer.isBuffer(value) && !(value instanceof Uint8Array)) {
|
|
9216
9436
|
for (const [key, item] of Object.entries(value)) {
|
|
9217
9437
|
setOwnValue(result, text(key), normalizeMapStructurePreservingBytes(item));
|
|
9218
9438
|
}
|
|
@@ -9221,7 +9441,7 @@ function toStringKeyMapPreservingValues(value) {
|
|
|
9221
9441
|
return void 0;
|
|
9222
9442
|
}
|
|
9223
9443
|
function normalizeMapStructurePreservingBytes(value) {
|
|
9224
|
-
if (
|
|
9444
|
+
if (import_node_buffer31.Buffer.isBuffer(value) || value instanceof Uint8Array) return value;
|
|
9225
9445
|
if (value instanceof Map) {
|
|
9226
9446
|
const result = {};
|
|
9227
9447
|
for (const [key, item] of value.entries()) {
|
|
@@ -9243,7 +9463,7 @@ function normalizeMapStructurePreservingBytes(value) {
|
|
|
9243
9463
|
}
|
|
9244
9464
|
|
|
9245
9465
|
// src/native-kv-responses.ts
|
|
9246
|
-
var
|
|
9466
|
+
var import_node_buffer32 = require("buffer");
|
|
9247
9467
|
function rateLimitResultFromResp(value) {
|
|
9248
9468
|
if (!Array.isArray(value) || value.length !== 4) {
|
|
9249
9469
|
throw new TypeError("RATELIMIT.ADD returned an unexpected response");
|
|
@@ -9300,13 +9520,13 @@ function fetchOrComputeResultFromResp(value, codec) {
|
|
|
9300
9520
|
}
|
|
9301
9521
|
function decodePayload(codec, value) {
|
|
9302
9522
|
if (value == null) return null;
|
|
9303
|
-
if (
|
|
9304
|
-
if (value instanceof Uint8Array) return codec.decode(
|
|
9305
|
-
if (typeof value === "string") return codec.decode(
|
|
9523
|
+
if (import_node_buffer32.Buffer.isBuffer(value)) return codec.decode(value);
|
|
9524
|
+
if (value instanceof Uint8Array) return codec.decode(import_node_buffer32.Buffer.from(value));
|
|
9525
|
+
if (typeof value === "string") return codec.decode(import_node_buffer32.Buffer.from(value));
|
|
9306
9526
|
return normalizeRefMeta(value);
|
|
9307
9527
|
}
|
|
9308
9528
|
function requiredResponseString(value, context) {
|
|
9309
|
-
if (typeof value !== "string" && !
|
|
9529
|
+
if (typeof value !== "string" && !import_node_buffer32.Buffer.isBuffer(value) && !(value instanceof Uint8Array)) {
|
|
9310
9530
|
throw new TypeError(`${context} returned an unexpected response`);
|
|
9311
9531
|
}
|
|
9312
9532
|
const result = text(value);
|
|
@@ -9323,7 +9543,7 @@ function requiredNonNegativeInteger(value, context) {
|
|
|
9323
9543
|
return result;
|
|
9324
9544
|
}
|
|
9325
9545
|
function responseBytes(value, context) {
|
|
9326
|
-
if (typeof value !== "string" && !
|
|
9546
|
+
if (typeof value !== "string" && !import_node_buffer32.Buffer.isBuffer(value) && !(value instanceof Uint8Array)) {
|
|
9327
9547
|
throw new TypeError(`${context} returned an unexpected response`);
|
|
9328
9548
|
}
|
|
9329
9549
|
return bytes(value);
|
|
@@ -10033,7 +10253,7 @@ function groupAutoPartitionItems(items) {
|
|
|
10033
10253
|
}
|
|
10034
10254
|
|
|
10035
10255
|
// src/client-values.ts
|
|
10036
|
-
var
|
|
10256
|
+
var import_node_buffer33 = require("buffer");
|
|
10037
10257
|
async function valueMGetEntries(client, refs, options = {}) {
|
|
10038
10258
|
const refCount = refs.length;
|
|
10039
10259
|
if (refCount === 0) {
|
|
@@ -10068,12 +10288,12 @@ async function valueMGetEntries(client, refs, options = {}) {
|
|
|
10068
10288
|
const item = response[index];
|
|
10069
10289
|
if (item == null) {
|
|
10070
10290
|
entries[index] = { found: false };
|
|
10071
|
-
} else if (
|
|
10291
|
+
} else if (import_node_buffer33.Buffer.isBuffer(item)) {
|
|
10072
10292
|
entries[index] = { found: true, value: client.codec.decode(item) };
|
|
10073
10293
|
} else if (item instanceof Uint8Array) {
|
|
10074
|
-
entries[index] = { found: true, value: client.codec.decode(
|
|
10294
|
+
entries[index] = { found: true, value: client.codec.decode(import_node_buffer33.Buffer.from(item)) };
|
|
10075
10295
|
} else if (typeof item === "string") {
|
|
10076
|
-
entries[index] = { found: true, value: client.codec.decode(
|
|
10296
|
+
entries[index] = { found: true, value: client.codec.decode(import_node_buffer33.Buffer.from(item)) };
|
|
10077
10297
|
} else {
|
|
10078
10298
|
entries[index] = { found: true, value: item };
|
|
10079
10299
|
}
|
|
@@ -10082,10 +10302,10 @@ async function valueMGetEntries(client, refs, options = {}) {
|
|
|
10082
10302
|
}
|
|
10083
10303
|
|
|
10084
10304
|
// src/auto-batch.ts
|
|
10085
|
-
var
|
|
10305
|
+
var import_node_buffer35 = require("buffer");
|
|
10086
10306
|
|
|
10087
10307
|
// src/auto-batch-ordering.ts
|
|
10088
|
-
var
|
|
10308
|
+
var import_node_buffer34 = require("buffer");
|
|
10089
10309
|
function autoBatchOrderingPlan(batch) {
|
|
10090
10310
|
const accesses = /* @__PURE__ */ new Map();
|
|
10091
10311
|
const fallbackDependencies = [];
|
|
@@ -10200,13 +10420,13 @@ function flowManyAutoBatchIds(command, name) {
|
|
|
10200
10420
|
return fixedFlowItemIds(
|
|
10201
10421
|
command,
|
|
10202
10422
|
mixed ? 4 : 3,
|
|
10203
|
-
(itemIndex) => isAutoBatchResourceValue(command[itemIndex]) && (!mixed || isAutoBatchResourceValue(command[itemIndex + 1])) && isFencingToken(command[itemIndex + (mixed ? 2 : 1)]) &&
|
|
10423
|
+
(itemIndex) => isAutoBatchResourceValue(command[itemIndex]) && (!mixed || isAutoBatchResourceValue(command[itemIndex + 1])) && isFencingToken(command[itemIndex + (mixed ? 2 : 1)]) && import_node_buffer34.Buffer.isBuffer(command[itemIndex + (mixed ? 3 : 2)])
|
|
10204
10424
|
);
|
|
10205
10425
|
}
|
|
10206
10426
|
return fixedFlowItemIds(
|
|
10207
10427
|
command,
|
|
10208
10428
|
mixed ? 4 : 3,
|
|
10209
|
-
(itemIndex) => isAutoBatchResourceValue(command[itemIndex]) && (!mixed || isAutoBatchResourceValue(command[itemIndex + 1])) &&
|
|
10429
|
+
(itemIndex) => isAutoBatchResourceValue(command[itemIndex]) && (!mixed || isAutoBatchResourceValue(command[itemIndex + 1])) && import_node_buffer34.Buffer.isBuffer(command[itemIndex + (mixed ? 2 : 1)]) && isFencingToken(command[itemIndex + (mixed ? 3 : 2)])
|
|
10210
10430
|
);
|
|
10211
10431
|
}
|
|
10212
10432
|
function createManyAutoBatchIds(command) {
|
|
@@ -10219,7 +10439,7 @@ function createManyAutoBatchIds(command) {
|
|
|
10219
10439
|
const ids = fixedFlowItemIds(
|
|
10220
10440
|
command,
|
|
10221
10441
|
width,
|
|
10222
|
-
(itemIndex) => isAutoBatchResourceValue(command[itemIndex]) && (!mixed || isAutoBatchResourceValue(command[itemIndex + 1])) &&
|
|
10442
|
+
(itemIndex) => isAutoBatchResourceValue(command[itemIndex]) && (!mixed || isAutoBatchResourceValue(command[itemIndex + 1])) && import_node_buffer34.Buffer.isBuffer(command[itemIndex + width - 1]),
|
|
10223
10443
|
markerIndex
|
|
10224
10444
|
);
|
|
10225
10445
|
if (ids != null) return ids;
|
|
@@ -10237,7 +10457,7 @@ function extendedCreateManyAutoBatchIds(command, markerIndex) {
|
|
|
10237
10457
|
let cursor = markerIndex + 2;
|
|
10238
10458
|
for (let itemIndex = 0; itemIndex < itemCount; itemIndex += 1) {
|
|
10239
10459
|
const id = command[cursor];
|
|
10240
|
-
if (!isAutoBatchResourceValue(id) || !isAutoBatchResourceValue(command[cursor + 1]) || !
|
|
10460
|
+
if (!isAutoBatchResourceValue(id) || !isAutoBatchResourceValue(command[cursor + 1]) || !import_node_buffer34.Buffer.isBuffer(command[cursor + 2])) return void 0;
|
|
10241
10461
|
ids.push(id);
|
|
10242
10462
|
cursor += 3;
|
|
10243
10463
|
const afterValues = skipExtendedNamedItems(command, cursor, true);
|
|
@@ -10256,7 +10476,7 @@ function skipExtendedNamedItems(command, countIndex, encodedValues) {
|
|
|
10256
10476
|
for (let index = 0; index < count; index += 1) {
|
|
10257
10477
|
const name = command[firstItem + index * 2];
|
|
10258
10478
|
const value = command[firstItem + index * 2 + 1];
|
|
10259
|
-
if (!isAutoBatchResourceValue(name) || (encodedValues ? !
|
|
10479
|
+
if (!isAutoBatchResourceValue(name) || (encodedValues ? !import_node_buffer34.Buffer.isBuffer(value) : !isAutoBatchResourceValue(value))) return void 0;
|
|
10260
10480
|
}
|
|
10261
10481
|
return firstItem + count * 2;
|
|
10262
10482
|
}
|
|
@@ -10271,7 +10491,7 @@ function runStepsManyAutoBatchIds(command) {
|
|
|
10271
10491
|
ids.push(item);
|
|
10272
10492
|
continue;
|
|
10273
10493
|
}
|
|
10274
|
-
if (typeof item !== "object" || item == null || Array.isArray(item) ||
|
|
10494
|
+
if (typeof item !== "object" || item == null || Array.isArray(item) || import_node_buffer34.Buffer.isBuffer(item)) return void 0;
|
|
10275
10495
|
const id = item.id;
|
|
10276
10496
|
if (!isAutoBatchResourceValue(id)) return void 0;
|
|
10277
10497
|
ids.push(id);
|
|
@@ -10312,7 +10532,7 @@ function flowValuePutOwner(command, start) {
|
|
|
10312
10532
|
}
|
|
10313
10533
|
var flowValuePutOptionTokens = /* @__PURE__ */ new Set(["NAME", "NOW", "OVERRIDE", "OWNER_FLOW_ID", "PARTITION", "TTL", "TTL_MS"]);
|
|
10314
10534
|
function isAutoBatchResourceValue(value) {
|
|
10315
|
-
return typeof value === "string" ||
|
|
10535
|
+
return typeof value === "string" || import_node_buffer34.Buffer.isBuffer(value);
|
|
10316
10536
|
}
|
|
10317
10537
|
function isFencingToken(value) {
|
|
10318
10538
|
return typeof value === "number" && Number.isSafeInteger(value) || typeof value === "bigint";
|
|
@@ -10321,7 +10541,7 @@ function nonNegativeItemCount(value) {
|
|
|
10321
10541
|
return typeof value === "number" && Number.isSafeInteger(value) && value >= 0 ? value : void 0;
|
|
10322
10542
|
}
|
|
10323
10543
|
function autoBatchResourceKey(namespace, value) {
|
|
10324
|
-
return `${namespace}:${
|
|
10544
|
+
return `${namespace}:${import_node_buffer34.Buffer.from(value).toString("base64")}`;
|
|
10325
10545
|
}
|
|
10326
10546
|
function autoBatchCommandName(command) {
|
|
10327
10547
|
return commandView(command).name ?? null;
|
|
@@ -10730,15 +10950,15 @@ function claimFailure(error) {
|
|
|
10730
10950
|
}
|
|
10731
10951
|
|
|
10732
10952
|
// src/client-flow-support.ts
|
|
10733
|
-
var
|
|
10953
|
+
var import_node_buffer42 = require("buffer");
|
|
10734
10954
|
|
|
10735
10955
|
// src/client-core.ts
|
|
10736
|
-
var
|
|
10956
|
+
var import_node_buffer40 = require("buffer");
|
|
10737
10957
|
|
|
10738
10958
|
// src/client-core-helpers.ts
|
|
10739
|
-
var
|
|
10959
|
+
var import_node_buffer36 = require("buffer");
|
|
10740
10960
|
function bgsaveResponse(response) {
|
|
10741
|
-
if ((typeof response === "string" ||
|
|
10961
|
+
if ((typeof response === "string" || import_node_buffer36.Buffer.isBuffer(response) || response instanceof Uint8Array) && text(response) === "Background saving started") {
|
|
10742
10962
|
return true;
|
|
10743
10963
|
}
|
|
10744
10964
|
return okResponse(response);
|
|
@@ -10752,7 +10972,7 @@ function fetchOrComputeCompletionToken(options) {
|
|
|
10752
10972
|
"fetch-or-compute completion requires computeToken"
|
|
10753
10973
|
);
|
|
10754
10974
|
}
|
|
10755
|
-
if (!
|
|
10975
|
+
if (!import_node_buffer36.Buffer.isBuffer(options.computeToken)) {
|
|
10756
10976
|
throw new TypeError("fetch-or-compute computeToken must be a Buffer");
|
|
10757
10977
|
}
|
|
10758
10978
|
return options.computeToken;
|
|
@@ -10775,10 +10995,10 @@ function unsupportedClientCaching() {
|
|
|
10775
10995
|
}
|
|
10776
10996
|
|
|
10777
10997
|
// src/client-base.ts
|
|
10778
|
-
var
|
|
10998
|
+
var import_node_buffer38 = require("buffer");
|
|
10779
10999
|
|
|
10780
11000
|
// src/client-executor.ts
|
|
10781
|
-
var
|
|
11001
|
+
var import_node_buffer37 = require("buffer");
|
|
10782
11002
|
var ErrorMappingExecutor = class {
|
|
10783
11003
|
constructor(executor) {
|
|
10784
11004
|
this.executor = executor;
|
|
@@ -11112,14 +11332,14 @@ var FerricStoreAdministrationClient = class extends FerricStoreClientBase {
|
|
|
11112
11332
|
};
|
|
11113
11333
|
|
|
11114
11334
|
// src/store-utilities.ts
|
|
11115
|
-
var
|
|
11335
|
+
var import_node_buffer39 = require("buffer");
|
|
11116
11336
|
function encode(codec, value) {
|
|
11117
11337
|
return codec.encode(value);
|
|
11118
11338
|
}
|
|
11119
11339
|
function decode(codec, value) {
|
|
11120
11340
|
if (value == null) return null;
|
|
11121
|
-
if (
|
|
11122
|
-
if (value instanceof Uint8Array) return codec.decode(
|
|
11341
|
+
if (import_node_buffer39.Buffer.isBuffer(value)) return codec.decode(value);
|
|
11342
|
+
if (value instanceof Uint8Array) return codec.decode(import_node_buffer39.Buffer.from(value));
|
|
11123
11343
|
return value;
|
|
11124
11344
|
}
|
|
11125
11345
|
function number(value) {
|
|
@@ -11180,7 +11400,7 @@ function requireNonEmpty(values, command, noun = "argument") {
|
|
|
11180
11400
|
if (values.length === 0) throw new TypeError(`${command} requires at least one ${noun}`);
|
|
11181
11401
|
return values;
|
|
11182
11402
|
}
|
|
11183
|
-
function
|
|
11403
|
+
function commandName4(args) {
|
|
11184
11404
|
return typeof args[0] === "string" ? args[0] : "command";
|
|
11185
11405
|
}
|
|
11186
11406
|
function commandArgs(client, args) {
|
|
@@ -11195,7 +11415,7 @@ function arrayOrRest(values) {
|
|
|
11195
11415
|
function appendXReadStreams(args, streams) {
|
|
11196
11416
|
const offset = args.length;
|
|
11197
11417
|
const streamCount = streams.length;
|
|
11198
|
-
requireNonEmpty(streams,
|
|
11418
|
+
requireNonEmpty(streams, commandName4(args), "stream");
|
|
11199
11419
|
args.length = offset + 1 + streamCount * 2;
|
|
11200
11420
|
args[offset] = "STREAMS";
|
|
11201
11421
|
for (let index = 0; index < streamCount; index += 1) {
|
|
@@ -11205,7 +11425,7 @@ function appendXReadStreams(args, streams) {
|
|
|
11205
11425
|
const stream = streams[index];
|
|
11206
11426
|
if (stream == null) throw new TypeError("XREAD streams must contain only stream descriptors");
|
|
11207
11427
|
if (!Object.hasOwn(stream, "key") || !Object.hasOwn(stream, "id")) {
|
|
11208
|
-
throw new TypeError(`${
|
|
11428
|
+
throw new TypeError(`${commandName4(args)} streams require own key and id fields`);
|
|
11209
11429
|
}
|
|
11210
11430
|
args[offset + 1 + index] = stream.key;
|
|
11211
11431
|
args[offset + 1 + streamCount + index] = stream.id;
|
|
@@ -11227,7 +11447,7 @@ function concatArgs(...parts) {
|
|
|
11227
11447
|
return args;
|
|
11228
11448
|
}
|
|
11229
11449
|
function encodedArgs(prefix, codec, values, allowEmpty = false) {
|
|
11230
|
-
if (!allowEmpty) requireNonEmpty(values,
|
|
11450
|
+
if (!allowEmpty) requireNonEmpty(values, commandName4(prefix));
|
|
11231
11451
|
const args = new Array(prefix.length + values.length);
|
|
11232
11452
|
for (let index = 0; index < prefix.length; index += 1) args[index] = prefix[index];
|
|
11233
11453
|
for (let index = 0; index < values.length; index += 1) {
|
|
@@ -11241,7 +11461,7 @@ function encodedArgs(prefix, codec, values, allowEmpty = false) {
|
|
|
11241
11461
|
function keyValueArgs(prefix, codec, entries) {
|
|
11242
11462
|
const validateTuples = Array.isArray(entries);
|
|
11243
11463
|
const pairs = validateTuples ? entries : Object.entries(entries);
|
|
11244
|
-
requireNonEmpty(pairs,
|
|
11464
|
+
requireNonEmpty(pairs, commandName4(prefix), "entry");
|
|
11245
11465
|
const args = new Array(prefix.length + pairs.length * 2);
|
|
11246
11466
|
for (let index = 0; index < prefix.length; index += 1) args[index] = prefix[index];
|
|
11247
11467
|
for (let index = 0; index < pairs.length; index += 1) {
|
|
@@ -11255,7 +11475,7 @@ function keyValueArgs(prefix, codec, entries) {
|
|
|
11255
11475
|
return args;
|
|
11256
11476
|
}
|
|
11257
11477
|
function encodedEntryArgs(prefix, codec, entries) {
|
|
11258
|
-
requireNonEmpty(entries,
|
|
11478
|
+
requireNonEmpty(entries, commandName4(prefix), "entry");
|
|
11259
11479
|
const args = new Array(prefix.length + entries.length * 2);
|
|
11260
11480
|
for (let index = 0; index < prefix.length; index += 1) args[index] = prefix[index];
|
|
11261
11481
|
for (let index = 0; index < entries.length; index += 1) {
|
|
@@ -13354,6 +13574,165 @@ function throwIfClosed(signal) {
|
|
|
13354
13574
|
throw new FerricStoreError("FerricStore client is closed", { raw: signal.reason });
|
|
13355
13575
|
}
|
|
13356
13576
|
|
|
13577
|
+
// src/flow-policy.ts
|
|
13578
|
+
var import_node_buffer41 = require("buffer");
|
|
13579
|
+
var MAX_FLOW_POLICY_GENERATION = Number.MAX_SAFE_INTEGER;
|
|
13580
|
+
function assertFlowPolicyGeneration(value) {
|
|
13581
|
+
if (typeof value !== "number" || !Number.isSafeInteger(value) || value < 0) {
|
|
13582
|
+
throw new TypeError("expectedGeneration must be a nonnegative safe integer");
|
|
13583
|
+
}
|
|
13584
|
+
}
|
|
13585
|
+
function flowPolicySnapshotFromResp(value) {
|
|
13586
|
+
const policy = requiredRecord(value, "FLOW policy snapshot");
|
|
13587
|
+
const maxActiveMs = optionalPositiveInteger(field(policy, "max_active_ms"), "max_active_ms");
|
|
13588
|
+
const state = optionalText2(field(policy, "state"), "state");
|
|
13589
|
+
const mode = optionalMode(field(policy, "mode"), "mode");
|
|
13590
|
+
const version = optionalVersion(field(policy, "version"));
|
|
13591
|
+
const indexedStateMeta = optionalText2(field(policy, "indexed_state_meta"), "indexed_state_meta");
|
|
13592
|
+
const governance = optionalRecord(field(policy, "governance"), "governance");
|
|
13593
|
+
const states = optionalStates(field(policy, "states"));
|
|
13594
|
+
return {
|
|
13595
|
+
type: requiredText(field(policy, "type"), "type"),
|
|
13596
|
+
generation: nonNegativeInteger(field(policy, "generation"), "generation"),
|
|
13597
|
+
...state == null ? {} : { state },
|
|
13598
|
+
...version == null ? {} : { version },
|
|
13599
|
+
...mode == null ? {} : { mode },
|
|
13600
|
+
...maxActiveMs == null ? {} : { maxActiveMs },
|
|
13601
|
+
retry: retrySnapshot(field(policy, "retry"), "retry"),
|
|
13602
|
+
retention: retentionSnapshot(field(policy, "retention"), "retention"),
|
|
13603
|
+
indexedAttributes: stringArray(field(policy, "indexed_attributes"), "indexed_attributes"),
|
|
13604
|
+
...indexedStateMeta == null ? {} : { indexedStateMeta },
|
|
13605
|
+
...governance == null ? {} : { governance },
|
|
13606
|
+
...states == null ? {} : { states },
|
|
13607
|
+
raw: value
|
|
13608
|
+
};
|
|
13609
|
+
}
|
|
13610
|
+
function retrySnapshot(value, context) {
|
|
13611
|
+
const retry2 = requiredRecord(value, `FLOW policy ${context}`);
|
|
13612
|
+
const backoff = requiredRecord(field(retry2, "backoff"), `FLOW policy ${context}.backoff`);
|
|
13613
|
+
return {
|
|
13614
|
+
maxRetries: nonNegativeInteger(field(retry2, "max_retries"), `${context}.max_retries`),
|
|
13615
|
+
backoff: {
|
|
13616
|
+
kind: backoffKind(field(backoff, "kind"), `${context}.backoff.kind`),
|
|
13617
|
+
baseMs: nonNegativeInteger(field(backoff, "base_ms"), `${context}.backoff.base_ms`),
|
|
13618
|
+
maxMs: nonNegativeInteger(field(backoff, "max_ms"), `${context}.backoff.max_ms`),
|
|
13619
|
+
jitterPct: nonNegativeInteger(field(backoff, "jitter_pct"), `${context}.backoff.jitter_pct`)
|
|
13620
|
+
},
|
|
13621
|
+
exhaustedTo: requiredText(field(retry2, "exhausted_to"), `${context}.exhausted_to`)
|
|
13622
|
+
};
|
|
13623
|
+
}
|
|
13624
|
+
function retentionSnapshot(value, context) {
|
|
13625
|
+
const retention = requiredRecord(value, `FLOW policy ${context}`);
|
|
13626
|
+
return {
|
|
13627
|
+
ttlMs: nonNegativeInteger(field(retention, "ttl_ms"), `${context}.ttl_ms`),
|
|
13628
|
+
historyMaxEvents: nonNegativeInteger(
|
|
13629
|
+
field(retention, "history_max_events"),
|
|
13630
|
+
`${context}.history_max_events`
|
|
13631
|
+
)
|
|
13632
|
+
};
|
|
13633
|
+
}
|
|
13634
|
+
function optionalStates(value) {
|
|
13635
|
+
if (value == null) return void 0;
|
|
13636
|
+
const source = requiredRecord(value, "FLOW policy states");
|
|
13637
|
+
const result = {};
|
|
13638
|
+
for (const [state, raw] of Object.entries(source)) {
|
|
13639
|
+
const policy = requiredRecord(raw, `FLOW policy state ${state}`);
|
|
13640
|
+
const maxActiveMs = optionalPositiveInteger(
|
|
13641
|
+
field(policy, "max_active_ms"),
|
|
13642
|
+
`states.${state}.max_active_ms`
|
|
13643
|
+
);
|
|
13644
|
+
const governance = optionalRecord(field(policy, "governance"), `states.${state}.governance`);
|
|
13645
|
+
Object.defineProperty(result, state, {
|
|
13646
|
+
configurable: true,
|
|
13647
|
+
enumerable: true,
|
|
13648
|
+
value: {
|
|
13649
|
+
mode: requiredMode(field(policy, "mode"), `states.${state}.mode`),
|
|
13650
|
+
...maxActiveMs == null ? {} : { maxActiveMs },
|
|
13651
|
+
retry: retrySnapshot(field(policy, "retry"), `states.${state}.retry`),
|
|
13652
|
+
retention: retentionSnapshot(field(policy, "retention"), `states.${state}.retention`),
|
|
13653
|
+
...governance == null ? {} : { governance }
|
|
13654
|
+
},
|
|
13655
|
+
writable: true
|
|
13656
|
+
});
|
|
13657
|
+
}
|
|
13658
|
+
return result;
|
|
13659
|
+
}
|
|
13660
|
+
function requiredRecord(value, context) {
|
|
13661
|
+
if (value instanceof Map) {
|
|
13662
|
+
const result = {};
|
|
13663
|
+
for (const [key, item] of value.entries()) {
|
|
13664
|
+
setOwnValue(result, requiredText(key, `${context} key`), item);
|
|
13665
|
+
}
|
|
13666
|
+
return result;
|
|
13667
|
+
}
|
|
13668
|
+
if (typeof value === "object" && value != null && !Array.isArray(value) && !import_node_buffer41.Buffer.isBuffer(value) && !(value instanceof Uint8Array)) return value;
|
|
13669
|
+
throw new TypeError(`${context} returned an unexpected response`);
|
|
13670
|
+
}
|
|
13671
|
+
function optionalRecord(value, context) {
|
|
13672
|
+
return value == null ? void 0 : requiredRecord(value, `FLOW policy ${context}`);
|
|
13673
|
+
}
|
|
13674
|
+
function stringArray(value, context) {
|
|
13675
|
+
if (!Array.isArray(value)) {
|
|
13676
|
+
throw new TypeError(`FLOW policy ${context} returned an unexpected response`);
|
|
13677
|
+
}
|
|
13678
|
+
const result = new Array(value.length);
|
|
13679
|
+
for (let index = 0; index < value.length; index += 1) {
|
|
13680
|
+
if (!Object.hasOwn(value, index)) {
|
|
13681
|
+
throw new TypeError(`FLOW policy ${context} returned an unexpected response`);
|
|
13682
|
+
}
|
|
13683
|
+
result[index] = requiredText(value[index], `${context}[${index}]`);
|
|
13684
|
+
}
|
|
13685
|
+
return result;
|
|
13686
|
+
}
|
|
13687
|
+
function requiredText(value, context) {
|
|
13688
|
+
if (typeof value === "string") return value;
|
|
13689
|
+
if (import_node_buffer41.Buffer.isBuffer(value) || value instanceof Uint8Array) {
|
|
13690
|
+
return import_node_buffer41.Buffer.from(value).toString("utf8");
|
|
13691
|
+
}
|
|
13692
|
+
throw new TypeError(`FLOW policy ${context} returned an unexpected response`);
|
|
13693
|
+
}
|
|
13694
|
+
function optionalText2(value, context) {
|
|
13695
|
+
return value == null ? void 0 : requiredText(value, context);
|
|
13696
|
+
}
|
|
13697
|
+
function nonNegativeInteger(value, context) {
|
|
13698
|
+
let parsed;
|
|
13699
|
+
try {
|
|
13700
|
+
parsed = integer(value);
|
|
13701
|
+
} catch {
|
|
13702
|
+
throw new TypeError(`FLOW policy ${context} returned an unexpected response`);
|
|
13703
|
+
}
|
|
13704
|
+
if (parsed < 0) throw new TypeError(`FLOW policy ${context} returned an unexpected response`);
|
|
13705
|
+
return parsed;
|
|
13706
|
+
}
|
|
13707
|
+
function optionalPositiveInteger(value, context) {
|
|
13708
|
+
if (value == null) return void 0;
|
|
13709
|
+
const parsed = nonNegativeInteger(value, context);
|
|
13710
|
+
if (parsed === 0) throw new TypeError(`FLOW policy ${context} returned an unexpected response`);
|
|
13711
|
+
return parsed;
|
|
13712
|
+
}
|
|
13713
|
+
function optionalVersion(value) {
|
|
13714
|
+
if (value == null) return void 0;
|
|
13715
|
+
if (typeof value === "number" || typeof value === "bigint") {
|
|
13716
|
+
return nonNegativeInteger(value, "version");
|
|
13717
|
+
}
|
|
13718
|
+
return requiredText(value, "version");
|
|
13719
|
+
}
|
|
13720
|
+
function backoffKind(value, context) {
|
|
13721
|
+
const kind = requiredText(value, context).toLowerCase();
|
|
13722
|
+
if (kind === "none" || kind === "fixed" || kind === "linear" || kind === "exponential") {
|
|
13723
|
+
return kind;
|
|
13724
|
+
}
|
|
13725
|
+
throw new TypeError(`FLOW policy ${context} returned an unexpected response`);
|
|
13726
|
+
}
|
|
13727
|
+
function requiredMode(value, context) {
|
|
13728
|
+
const mode = requiredText(value, context).toLowerCase();
|
|
13729
|
+
if (mode === "fifo" || mode === "parallel") return mode;
|
|
13730
|
+
throw new TypeError(`FLOW policy ${context} returned an unexpected response`);
|
|
13731
|
+
}
|
|
13732
|
+
function optionalMode(value, context) {
|
|
13733
|
+
return value == null ? void 0 : requiredMode(value, context);
|
|
13734
|
+
}
|
|
13735
|
+
|
|
13357
13736
|
// src/client-flow-support.ts
|
|
13358
13737
|
var FerricStoreFlowSupportClient = class extends FerricStoreManagementClient {
|
|
13359
13738
|
async rewind(id, options = {}) {
|
|
@@ -13496,27 +13875,36 @@ var FerricStoreFlowSupportClient = class extends FerricStoreManagementClient {
|
|
|
13496
13875
|
}
|
|
13497
13876
|
async installPolicy(type, options = {}) {
|
|
13498
13877
|
const args = ["FLOW.POLICY.SET", type];
|
|
13878
|
+
const expectedGeneration = Object.hasOwn(options, "expectedGeneration") ? options.expectedGeneration : void 0;
|
|
13879
|
+
const replace = Object.hasOwn(options, "replace") ? options.replace : void 0;
|
|
13880
|
+
if (expectedGeneration != null) assertFlowPolicyGeneration(expectedGeneration);
|
|
13881
|
+
if (replace != null && typeof replace !== "boolean") {
|
|
13882
|
+
throw new TypeError("replace must be a boolean");
|
|
13883
|
+
}
|
|
13884
|
+
append(args, "EXPECTED_GENERATION", expectedGeneration);
|
|
13885
|
+
appendBool(args, "REPLACE", replace);
|
|
13499
13886
|
if (options.indexedAttributes != null) {
|
|
13500
13887
|
args.push("INDEXED_ATTRIBUTES", JSON.stringify(options.indexedAttributes));
|
|
13501
13888
|
}
|
|
13502
13889
|
append(args, "INDEXED_STATE_META", options.indexedStateMeta);
|
|
13503
13890
|
append(args, "MAX_ACTIVE_MS", options.maxActiveMs);
|
|
13891
|
+
if (options.state == null) append(args, "RETENTION_TTL_MS", options.retentionTtlMs);
|
|
13504
13892
|
append(args, "STATE", options.state);
|
|
13505
13893
|
appendPolicyMode(args, options.state, options.mode);
|
|
13506
13894
|
if (options.retry != null) {
|
|
13507
13895
|
appendRetryPolicy(args, options.retry);
|
|
13508
13896
|
}
|
|
13897
|
+
if (options.state != null) append(args, "RETENTION_TTL_MS", options.retentionTtlMs);
|
|
13509
13898
|
for (const [state, policy] of Object.entries(options.states ?? {})) {
|
|
13510
13899
|
args.push("STATE", state);
|
|
13511
13900
|
appendFlowStatePolicy(args, policy);
|
|
13512
13901
|
}
|
|
13513
|
-
|
|
13514
|
-
return await this.commandArgs(args);
|
|
13902
|
+
return flowPolicySnapshotFromResp(await this.commandArgs(args));
|
|
13515
13903
|
}
|
|
13516
13904
|
async policyGet(type, options = {}) {
|
|
13517
13905
|
const args = ["FLOW.POLICY.GET", type];
|
|
13518
13906
|
append(args, "STATE", options.state);
|
|
13519
|
-
return
|
|
13907
|
+
return flowPolicySnapshotFromResp(await this.commandArgs(args));
|
|
13520
13908
|
}
|
|
13521
13909
|
async retentionCleanup() {
|
|
13522
13910
|
return parseKvResponse(await this.command("FLOW.RETENTION_CLEANUP"));
|
|
@@ -13605,7 +13993,7 @@ var FerricStoreFlowSupportClient = class extends FerricStoreManagementClient {
|
|
|
13605
13993
|
};
|
|
13606
13994
|
|
|
13607
13995
|
// src/flow-many-snapshot.ts
|
|
13608
|
-
var
|
|
13996
|
+
var import_node_buffer43 = require("buffer");
|
|
13609
13997
|
var encodedOptionFields = ["error", "payload", "reason", "result"];
|
|
13610
13998
|
function snapshotCreateItem(item, codec) {
|
|
13611
13999
|
const snapshot = {
|
|
@@ -13645,7 +14033,7 @@ function snapshotFlowManyOptions(options, codec) {
|
|
|
13645
14033
|
}
|
|
13646
14034
|
function snapshotClaimedItem(item) {
|
|
13647
14035
|
const wire = item[CLAIMED_ITEM_WIRE];
|
|
13648
|
-
const leaseToken =
|
|
14036
|
+
const leaseToken = import_node_buffer43.Buffer.from(wire?.leaseToken ?? item.leaseToken);
|
|
13649
14037
|
const snapshot = {
|
|
13650
14038
|
...item,
|
|
13651
14039
|
fencingToken: wire?.fencingToken ?? item.fencingToken,
|
|
@@ -13662,15 +14050,15 @@ function snapshotClaimedItem(item) {
|
|
|
13662
14050
|
function snapshotFencedItem(item) {
|
|
13663
14051
|
return Object.freeze({
|
|
13664
14052
|
...item,
|
|
13665
|
-
...item.leaseToken == null ? {} : { leaseToken:
|
|
14053
|
+
...item.leaseToken == null ? {} : { leaseToken: import_node_buffer43.Buffer.from(item.leaseToken) }
|
|
13666
14054
|
});
|
|
13667
14055
|
}
|
|
13668
14056
|
function snapshotClaimedItemWire(wire, leaseToken) {
|
|
13669
14057
|
return Object.freeze({
|
|
13670
14058
|
fencingToken: wire.fencingToken,
|
|
13671
|
-
id:
|
|
14059
|
+
id: import_node_buffer43.Buffer.from(wire.id),
|
|
13672
14060
|
leaseToken,
|
|
13673
|
-
partitionKey: wire.partitionKey == null ? wire.partitionKey :
|
|
14061
|
+
partitionKey: wire.partitionKey == null ? wire.partitionKey : import_node_buffer43.Buffer.from(wire.partitionKey)
|
|
13674
14062
|
});
|
|
13675
14063
|
}
|
|
13676
14064
|
function snapshotArray(values) {
|
|
@@ -13681,7 +14069,7 @@ function snapshotArray(values) {
|
|
|
13681
14069
|
return Object.freeze(snapshot);
|
|
13682
14070
|
}
|
|
13683
14071
|
function snapshotStateMeta(stateMeta) {
|
|
13684
|
-
return snapshotRecord(stateMeta, (value) =>
|
|
14072
|
+
return snapshotRecord(stateMeta, (value) => import_node_buffer43.Buffer.isBuffer(value) ? import_node_buffer43.Buffer.from(value) : value);
|
|
13685
14073
|
}
|
|
13686
14074
|
function snapshotCommandRecord(values) {
|
|
13687
14075
|
const seen = /* @__PURE__ */ new WeakMap();
|
|
@@ -13699,7 +14087,7 @@ function snapshotRecord(values, capture) {
|
|
|
13699
14087
|
}
|
|
13700
14088
|
function snapshotCommandArgument(value, seen) {
|
|
13701
14089
|
if (typeof value !== "object" || value == null) return value;
|
|
13702
|
-
if (
|
|
14090
|
+
if (import_node_buffer43.Buffer.isBuffer(value) || value instanceof Uint8Array) return import_node_buffer43.Buffer.from(value);
|
|
13703
14091
|
const objectValue = value;
|
|
13704
14092
|
const existing = seen.get(objectValue);
|
|
13705
14093
|
if (existing != null) return existing;
|
|
@@ -14921,7 +15309,7 @@ async function runContinuousWorkerPool(options) {
|
|
|
14921
15309
|
initialIdleSleepMs,
|
|
14922
15310
|
nonNegativeDuration(options.maxIdleSleepMs, 5e3)
|
|
14923
15311
|
);
|
|
14924
|
-
const refillDelayMs =
|
|
15312
|
+
const refillDelayMs = nonNegativeInteger2(options.refillDelayMs, 0);
|
|
14925
15313
|
const active = /* @__PURE__ */ new Set();
|
|
14926
15314
|
const pending = [];
|
|
14927
15315
|
let pendingIndex = 0;
|
|
@@ -15040,7 +15428,7 @@ function normalizeWorkflowWorkerConfig(options) {
|
|
|
15040
15428
|
function positiveInteger(value, fallback) {
|
|
15041
15429
|
return value == null || !Number.isFinite(value) ? fallback : Math.max(1, Math.trunc(value));
|
|
15042
15430
|
}
|
|
15043
|
-
function
|
|
15431
|
+
function nonNegativeInteger2(value, fallback) {
|
|
15044
15432
|
return value == null || !Number.isFinite(value) ? fallback : Math.max(0, Math.trunc(value));
|
|
15045
15433
|
}
|
|
15046
15434
|
function nonNegativeDuration(value, fallback) {
|
|
@@ -16456,6 +16844,7 @@ var Workflow = class {
|
|
|
16456
16844
|
}
|
|
16457
16845
|
return await this.client.installPolicy(this.type, {
|
|
16458
16846
|
...options,
|
|
16847
|
+
replace: Object.hasOwn(options, "replace") ? options.replace ?? true : true,
|
|
16459
16848
|
states
|
|
16460
16849
|
});
|
|
16461
16850
|
}
|
|
@@ -16668,8 +17057,8 @@ var WorkflowWorker = class {
|
|
|
16668
17057
|
};
|
|
16669
17058
|
|
|
16670
17059
|
// src/version.ts
|
|
16671
|
-
var FERRICSTORE_SDK_VERSION = "0.
|
|
16672
|
-
var FERRICSTORE_MINIMUM_SERVER_VERSION = "0.
|
|
17060
|
+
var FERRICSTORE_SDK_VERSION = "0.3.0";
|
|
17061
|
+
var FERRICSTORE_MINIMUM_SERVER_VERSION = "0.9.1";
|
|
16673
17062
|
var FERRICSTORE_NATIVE_PROTOCOL_VERSION = 1;
|
|
16674
17063
|
// Annotate the CommonJS export names for ESM import in node:
|
|
16675
17064
|
0 && (module.exports = {
|
|
@@ -16699,6 +17088,7 @@ var FERRICSTORE_NATIVE_PROTOCOL_VERSION = 1;
|
|
|
16699
17088
|
ListStore,
|
|
16700
17089
|
LockHeldError,
|
|
16701
17090
|
LockNotOwnedError,
|
|
17091
|
+
MAX_FLOW_POLICY_GENERATION,
|
|
16702
17092
|
NativeAdapter,
|
|
16703
17093
|
OverloadedError,
|
|
16704
17094
|
Queue,
|
|
@@ -16713,6 +17103,7 @@ var FERRICSTORE_NATIVE_PROTOCOL_VERSION = 1;
|
|
|
16713
17103
|
SetStore,
|
|
16714
17104
|
SortedSetStore,
|
|
16715
17105
|
StaleLeaseError,
|
|
17106
|
+
StalePolicyGenerationError,
|
|
16716
17107
|
StreamStore,
|
|
16717
17108
|
TDigestStore,
|
|
16718
17109
|
TopKStore,
|