@ferricstore/ferricstore 0.5.2 → 0.11.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (111) hide show
  1. package/README.md +44 -5
  2. package/dist/index.cjs +825 -298
  3. package/dist/index.cjs.map +1 -1
  4. package/dist/index.d.cts +90 -26
  5. package/dist/index.d.ts +90 -26
  6. package/dist/index.js +825 -298
  7. package/dist/index.js.map +1 -1
  8. package/docs/api/assets/hierarchy.js +1 -1
  9. package/docs/api/assets/navigation.js +1 -1
  10. package/docs/api/assets/search.js +1 -1
  11. package/docs/api/classes/ConnectionClosedError.html +1 -1
  12. package/docs/api/classes/FerricStoreClient.html +3 -3
  13. package/docs/api/classes/FerricStoreError.html +1 -1
  14. package/docs/api/classes/FlowAlreadyExistsError.html +1 -1
  15. package/docs/api/classes/FlowBatchError.html +1 -1
  16. package/docs/api/classes/FlowNotFoundError.html +1 -1
  17. package/docs/api/classes/FlowQueryError.html +1 -1
  18. package/docs/api/classes/FlowWrongStateError.html +1 -1
  19. package/docs/api/classes/InvalidCommandError.html +1 -1
  20. package/docs/api/classes/LeaseRenewalError.html +1 -1
  21. package/docs/api/classes/LockHeldError.html +1 -1
  22. package/docs/api/classes/LockNotOwnedError.html +1 -1
  23. package/docs/api/classes/OverloadedError.html +1 -1
  24. package/docs/api/classes/QueueCompletionError.html +1 -1
  25. package/docs/api/classes/RequestTimeoutError.html +1 -1
  26. package/docs/api/classes/RerouteError.html +1 -1
  27. package/docs/api/classes/StaleLeaseError.html +1 -1
  28. package/docs/api/classes/StalePolicyGenerationError.html +1 -1
  29. package/docs/api/hierarchy.html +1 -1
  30. package/docs/api/index.html +34 -5
  31. package/docs/api/interfaces/AdminListOptions.html +2 -2
  32. package/docs/api/interfaces/ApprovalListOptions.html +2 -2
  33. package/docs/api/interfaces/ApprovalRequestOptions.html +2 -2
  34. package/docs/api/interfaces/AttributeQueryOptions.html +2 -2
  35. package/docs/api/interfaces/AutoBatchOptions.html +2 -2
  36. package/docs/api/interfaces/BudgetCommitOptions.html +2 -2
  37. package/docs/api/interfaces/BudgetReserveOptions.html +2 -2
  38. package/docs/api/interfaces/CancelOptions.html +2 -2
  39. package/docs/api/interfaces/CircuitOpenOptions.html +2 -2
  40. package/docs/api/interfaces/ClaimDueOptions.html +3 -3
  41. package/docs/api/interfaces/ClaimHydrationItem.html +2 -2
  42. package/docs/api/interfaces/CompleteJobsAndClaimJobsResult.html +6 -6
  43. package/docs/api/interfaces/CompleteManyOptions.html +2 -2
  44. package/docs/api/interfaces/CompleteOptions.html +2 -2
  45. package/docs/api/interfaces/CompleteOutcome.html +1 -1
  46. package/docs/api/interfaces/CreateManyOptions.html +5 -5
  47. package/docs/api/interfaces/CreateOptions.html +3 -3
  48. package/docs/api/interfaces/EffectCompensateOptions.html +2 -2
  49. package/docs/api/interfaces/EffectConfirmOptions.html +2 -2
  50. package/docs/api/interfaces/EffectFailOptions.html +2 -2
  51. package/docs/api/interfaces/EffectReserveOptions.html +2 -2
  52. package/docs/api/interfaces/EffectStatusOptions.html +2 -2
  53. package/docs/api/interfaces/ExtendLeaseOptions.html +2 -2
  54. package/docs/api/interfaces/FailOptions.html +2 -2
  55. package/docs/api/interfaces/FailOutcome.html +1 -1
  56. package/docs/api/interfaces/FerricStoreClientFromUrlOptions.html +4 -4
  57. package/docs/api/interfaces/FerricStoreClientOptions.html +4 -4
  58. package/docs/api/interfaces/FlowBatchCompletedItem.html +2 -2
  59. package/docs/api/interfaces/FlowPolicyOptions.html +5 -5
  60. package/docs/api/interfaces/FlowQueryCountResult.html +1 -1
  61. package/docs/api/interfaces/FlowQueryIndexBuild.html +1 -1
  62. package/docs/api/interfaces/FlowQueryIndexProgress.html +1 -1
  63. package/docs/api/interfaces/FlowQueryIndexValidation.html +1 -1
  64. package/docs/api/interfaces/FlowQueryRecordsResult.html +1 -1
  65. package/docs/api/interfaces/FlowStatePolicy.html +2 -2
  66. package/docs/api/interfaces/FlowStatsOptions.html +2 -2
  67. package/docs/api/interfaces/GovernanceLedgerOptions.html +2 -2
  68. package/docs/api/interfaces/HistoryOptions.html +2 -2
  69. package/docs/api/interfaces/InvocationCreateOptions.html +2 -2
  70. package/docs/api/interfaces/LeaseMutationOptions.html +2 -2
  71. package/docs/api/interfaces/LimitAmountOptions.html +2 -2
  72. package/docs/api/interfaces/LimitLeaseOptions.html +2 -2
  73. package/docs/api/interfaces/LimitListOptions.html +2 -2
  74. package/docs/api/interfaces/LimitReleaseOptions.html +2 -2
  75. package/docs/api/interfaces/MutateOptions.html +2 -2
  76. package/docs/api/interfaces/NamedValueMutation.html +1 -1
  77. package/docs/api/interfaces/ReadOptions.html +3 -3
  78. package/docs/api/interfaces/ReclaimOptions.html +2 -2
  79. package/docs/api/interfaces/RequestContext.html +2 -2
  80. package/docs/api/interfaces/RequestContextOptions.html +2 -2
  81. package/docs/api/interfaces/RetryOptions.html +2 -2
  82. package/docs/api/interfaces/RetryOutcome.html +1 -1
  83. package/docs/api/interfaces/RunStepsItem.html +2 -2
  84. package/docs/api/interfaces/RunStepsManyOptions.html +2 -2
  85. package/docs/api/interfaces/ScheduleFireDueOptions.html +3 -2
  86. package/docs/api/interfaces/ScheduleFireOptions.html +3 -0
  87. package/docs/api/interfaces/ScheduleListOptions.html +2 -2
  88. package/docs/api/interfaces/ScheduleOptions.html +4 -2
  89. package/docs/api/interfaces/SearchOptions.html +3 -3
  90. package/docs/api/interfaces/StartAndClaimOptions.html +3 -3
  91. package/docs/api/interfaces/StepContinueOptions.html +3 -3
  92. package/docs/api/interfaces/TDigestCreateOptions.html +1 -1
  93. package/docs/api/interfaces/TDigestMergeOptions.html +1 -1
  94. package/docs/api/interfaces/TransitionOptions.html +2 -2
  95. package/docs/api/interfaces/TransitionOutcome.html +1 -1
  96. package/docs/api/modules.html +1 -1
  97. package/docs/api/types/ConnectionRequestDisposition.html +1 -1
  98. package/docs/api/types/FlowStateMode.html +1 -1
  99. package/docs/api/types/FlowStatePolicyLike.html +1 -1
  100. package/docs/api/types/ManagementPairs.html +1 -1
  101. package/docs/api/types/ScheduleCatchupPolicy.html +2 -0
  102. package/docs/api/types/ScheduleFireDueResult.html +3 -0
  103. package/docs/api/types/ScheduleFireResult.html +2 -0
  104. package/docs/api/types/ScheduleKind.html +1 -0
  105. package/docs/api/types/ScheduleOverlapPolicy.html +1 -0
  106. package/docs/api/types/ScheduleRecord.html +12 -0
  107. package/docs/api/types/ScheduleState.html +1 -0
  108. package/docs/api/types/SearchStateMeta.html +1 -1
  109. package/docs/api/variables/FERRICSTORE_MINIMUM_SERVER_VERSION.html +1 -1
  110. package/docs/api/variables/FERRICSTORE_SDK_VERSION.html +1 -1
  111. package/package.json +2 -2
package/dist/index.cjs CHANGED
@@ -3187,6 +3187,7 @@ var FLOW_ADMIN_FIELDS = {
3187
3187
  AT_MS: "at_ms",
3188
3188
  BLOCK: "block_ms",
3189
3189
  BLOCK_MS: "block_ms",
3190
+ CATCHUP_POLICY: "catchup_policy",
3190
3191
  CONSISTENT_PROJECTION: "consistent_projection",
3191
3192
  CORRELATION_ID: "correlation_id",
3192
3193
  COUNT: "count",
@@ -5620,15 +5621,15 @@ function requiredMap(value, context) {
5620
5621
  }
5621
5622
  throw incompatibleServer(`${context} is missing or invalid`);
5622
5623
  }
5623
- function requiredBoundedText(mapping, name) {
5624
- const value = strictText(field(mapping, name));
5624
+ function requiredBoundedText(mapping2, name) {
5625
+ const value = strictText(field(mapping2, name));
5625
5626
  if (value == null || value.length === 0 || import_node_buffer20.Buffer.byteLength(value) > 256) {
5626
5627
  throw incompatibleServer(`HELLO flow_query ${name} must be bounded non-empty text`);
5627
5628
  }
5628
5629
  return value;
5629
5630
  }
5630
- function boundedTextSet(mapping, name, maximum) {
5631
- const raw = field(mapping, name);
5631
+ function boundedTextSet(mapping2, name, maximum) {
5632
+ const raw = field(mapping2, name);
5632
5633
  if (!Array.isArray(raw) || raw.length < 1 || raw.length > maximum) {
5633
5634
  throw incompatibleServer(`HELLO ${name} must contain 1..${maximum} entries`);
5634
5635
  }
@@ -6951,15 +6952,15 @@ function snapshotOwnStringArray(values, name) {
6951
6952
 
6952
6953
  // src/client-native-options.ts
6953
6954
  function snapshotNativeClientOptions(options) {
6954
- const own = { ...options };
6955
+ const own2 = { ...options };
6955
6956
  const snapshot = {
6956
- ...own,
6957
- ...typeof own.autoReconnect === "object" && own.autoReconnect != null ? { autoReconnect: Object.freeze({ ...own.autoReconnect }) } : {},
6958
- ...own.endpointPolicy == null ? {} : { endpointPolicy: snapshotEndpointPolicy(own.endpointPolicy) },
6959
- ...own.events == null ? {} : { events: snapshotOwnStringArray(own.events, "events") },
6960
- ...own.seeds == null ? {} : { seeds: snapshotOwnStringArray(own.seeds, "seeds") },
6961
- ...own.tlsOptions == null ? {} : { tlsOptions: snapshotTlsOptions(own.tlsOptions) },
6962
- ...own.trustedHosts == null ? {} : { trustedHosts: snapshotOwnStringArray(own.trustedHosts, "trustedHosts") }
6957
+ ...own2,
6958
+ ...typeof own2.autoReconnect === "object" && own2.autoReconnect != null ? { autoReconnect: Object.freeze({ ...own2.autoReconnect }) } : {},
6959
+ ...own2.endpointPolicy == null ? {} : { endpointPolicy: snapshotEndpointPolicy(own2.endpointPolicy) },
6960
+ ...own2.events == null ? {} : { events: snapshotOwnStringArray(own2.events, "events") },
6961
+ ...own2.seeds == null ? {} : { seeds: snapshotOwnStringArray(own2.seeds, "seeds") },
6962
+ ...own2.tlsOptions == null ? {} : { tlsOptions: snapshotTlsOptions(own2.tlsOptions) },
6963
+ ...own2.trustedHosts == null ? {} : { trustedHosts: snapshotOwnStringArray(own2.trustedHosts, "trustedHosts") }
6963
6964
  };
6964
6965
  return Object.freeze(snapshot);
6965
6966
  }
@@ -7000,12 +7001,12 @@ function topologyNativeOptions(options) {
7000
7001
  }
7001
7002
  function snapshotEndpointPolicy(policy) {
7002
7003
  if (typeof policy !== "object") return policy;
7003
- const own = { ...policy };
7004
- if (!Object.hasOwn(own, "allowHosts") || !Array.isArray(own.allowHosts)) {
7004
+ const own2 = { ...policy };
7005
+ if (!Object.hasOwn(own2, "allowHosts") || !Array.isArray(own2.allowHosts)) {
7005
7006
  throw new TypeError("endpointPolicy.allowHosts must be an own array of strings");
7006
7007
  }
7007
7008
  return Object.freeze({
7008
- allowHosts: snapshotOwnStringArray(own.allowHosts, "endpointPolicy.allowHosts")
7009
+ allowHosts: snapshotOwnStringArray(own2.allowHosts, "endpointPolicy.allowHosts")
7009
7010
  });
7010
7011
  }
7011
7012
  function snapshotTlsOptions(options) {
@@ -12085,36 +12086,36 @@ function isPlainObject6(value) {
12085
12086
  const prototype = Object.getPrototypeOf(value);
12086
12087
  return prototype === Object.prototype || prototype === null;
12087
12088
  }
12088
- function requireContract(mapping, name, expected, context) {
12089
- const actual = requiredText2(mapping, name, context);
12089
+ function requireContract(mapping2, name, expected, context) {
12090
+ const actual = requiredText2(mapping2, name, context);
12090
12091
  if (actual !== expected) {
12091
12092
  throw decodeError(
12092
12093
  `${context} has unsupported contract ${JSON.stringify(actual)}`,
12093
- mapping
12094
+ mapping2
12094
12095
  );
12095
12096
  }
12096
12097
  }
12097
- function requiredText2(mapping, name, context) {
12098
- const value = strictText2(field(mapping, name));
12098
+ function requiredText2(mapping2, name, context) {
12099
+ const value = strictText2(field(mapping2, name));
12099
12100
  if (value == null || value.length === 0) {
12100
- throw decodeError(`${context} ${name} must be non-empty text`, mapping);
12101
+ throw decodeError(`${context} ${name} must be non-empty text`, mapping2);
12101
12102
  }
12102
12103
  return value;
12103
12104
  }
12104
- function optionalText2(mapping, name, context) {
12105
- const raw = field(mapping, name);
12105
+ function optionalText2(mapping2, name, context) {
12106
+ const raw = field(mapping2, name);
12106
12107
  if (raw == null) return void 0;
12107
12108
  const value = strictText2(raw);
12108
12109
  if (value == null)
12109
- throw decodeError(`${context} ${name} must be text`, mapping);
12110
+ throw decodeError(`${context} ${name} must be text`, mapping2);
12110
12111
  return value;
12111
12112
  }
12112
- function requiredBoundedText2(mapping, name, context, maximumBytes) {
12113
- const value = requiredText2(mapping, name, context);
12113
+ function requiredBoundedText2(mapping2, name, context, maximumBytes) {
12114
+ const value = requiredText2(mapping2, name, context);
12114
12115
  if (import_node_buffer45.Buffer.byteLength(value, "utf8") > maximumBytes) {
12115
12116
  throw decodeError(
12116
12117
  `${context} ${name} exceeds ${maximumBytes} bytes`,
12117
- mapping
12118
+ mapping2
12118
12119
  );
12119
12120
  }
12120
12121
  return value;
@@ -12129,10 +12130,10 @@ function boundedText(value, context, maximumBytes) {
12129
12130
  }
12130
12131
  return decoded;
12131
12132
  }
12132
- function requiredBoolean(mapping, name, context) {
12133
- const value = field(mapping, name);
12133
+ function requiredBoolean(mapping2, name, context) {
12134
+ const value = field(mapping2, name);
12134
12135
  if (typeof value !== "boolean") {
12135
- throw decodeError(`${context} ${name} must be boolean`, mapping);
12136
+ throw decodeError(`${context} ${name} must be boolean`, mapping2);
12136
12137
  }
12137
12138
  return value;
12138
12139
  }
@@ -12175,11 +12176,11 @@ function positiveBoundedInteger(value, maximum, context) {
12175
12176
  if (parsed === 0) throw decodeError(`${context} must be positive`, value);
12176
12177
  return parsed;
12177
12178
  }
12178
- function hasKey(mapping, name) {
12179
- if (!(mapping instanceof Map)) return Object.hasOwn(mapping, name);
12180
- if (mapping.has(name)) return true;
12179
+ function hasKey(mapping2, name) {
12180
+ if (!(mapping2 instanceof Map)) return Object.hasOwn(mapping2, name);
12181
+ if (mapping2.has(name)) return true;
12181
12182
  const binaryName = import_node_buffer45.Buffer.from(name);
12182
- for (const key of mapping.keys()) {
12183
+ for (const key of mapping2.keys()) {
12183
12184
  if (import_node_buffer45.Buffer.isBuffer(key) && key.equals(binaryName)) return true;
12184
12185
  if (key instanceof Uint8Array && import_node_buffer45.Buffer.from(key).equals(binaryName))
12185
12186
  return true;
@@ -12236,28 +12237,28 @@ var DIAGNOSTIC_CONTEXT_DEPTH = 6;
12236
12237
  var DIAGNOSTIC_CONTEXT_NODES = 512;
12237
12238
  function tryDecodeFlowQueryError(value, cause) {
12238
12239
  try {
12239
- const mapping = requiredMap2(value, "FLOW.QUERY diagnostic");
12240
- const context = decodeDiagnosticContext(field(mapping, "context"));
12241
- const position = decodePosition(field(mapping, "position"));
12240
+ const mapping2 = requiredMap2(value, "FLOW.QUERY diagnostic");
12241
+ const context = decodeDiagnosticContext(field(mapping2, "context"));
12242
+ const position = decodePosition(field(mapping2, "position"));
12242
12243
  return new FlowQueryError({
12243
12244
  code: requiredBoundedText2(
12244
- mapping,
12245
+ mapping2,
12245
12246
  "code",
12246
12247
  "FLOW.QUERY diagnostic",
12247
12248
  DIAGNOSTIC_TEXT_BYTES
12248
12249
  ),
12249
12250
  message: requiredBoundedText2(
12250
- mapping,
12251
+ mapping2,
12251
12252
  "message",
12252
12253
  "FLOW.QUERY diagnostic",
12253
12254
  DIAGNOSTIC_TEXT_BYTES
12254
12255
  ),
12255
- detail: optionalDiagnosticText(mapping, "detail"),
12256
- hint: optionalDiagnosticText(mapping, "hint"),
12257
- retryable: requiredBoolean(mapping, "retryable", "FLOW.QUERY diagnostic"),
12258
- safeToRetry: requiredBoolean(mapping, "safe_to_retry", "FLOW.QUERY diagnostic"),
12256
+ detail: optionalDiagnosticText(mapping2, "detail"),
12257
+ hint: optionalDiagnosticText(mapping2, "hint"),
12258
+ retryable: requiredBoolean(mapping2, "retryable", "FLOW.QUERY diagnostic"),
12259
+ safeToRetry: requiredBoolean(mapping2, "safe_to_retry", "FLOW.QUERY diagnostic"),
12259
12260
  retryAfterMs: nonNegativeInteger(
12260
- field(mapping, "retry_after_ms"),
12261
+ field(mapping2, "retry_after_ms"),
12261
12262
  "FLOW.QUERY diagnostic retry_after_ms"
12262
12263
  ),
12263
12264
  position,
@@ -12270,29 +12271,29 @@ function tryDecodeFlowQueryError(value, cause) {
12270
12271
  throw error;
12271
12272
  }
12272
12273
  }
12273
- function optionalDiagnosticText(mapping, name) {
12274
- const value = optionalText2(mapping, name, "FLOW.QUERY diagnostic");
12274
+ function optionalDiagnosticText(mapping2, name) {
12275
+ const value = optionalText2(mapping2, name, "FLOW.QUERY diagnostic");
12275
12276
  if (value != null && import_node_buffer46.Buffer.byteLength(value, "utf8") > DIAGNOSTIC_TEXT_BYTES) {
12276
12277
  throw decodeError(
12277
12278
  `FLOW.QUERY diagnostic ${name} exceeds ${DIAGNOSTIC_TEXT_BYTES} bytes`,
12278
- mapping
12279
+ mapping2
12279
12280
  );
12280
12281
  }
12281
12282
  return value;
12282
12283
  }
12283
12284
  function decodeDiagnosticContext(value) {
12284
12285
  if (value == null) return void 0;
12285
- const mapping = requiredMap2(value, "FLOW.QUERY diagnostic context");
12286
- const size = mapping instanceof Map ? mapping.size : Object.keys(mapping).length;
12286
+ const mapping2 = requiredMap2(value, "FLOW.QUERY diagnostic context");
12287
+ const size = mapping2 instanceof Map ? mapping2.size : Object.keys(mapping2).length;
12287
12288
  if (size > DIAGNOSTIC_CONTEXT_ENTRIES) {
12288
12289
  throw decodeError("FLOW.QUERY diagnostic context contains too many entries", value);
12289
12290
  }
12290
12291
  validateDiagnosticContextValue(
12291
- mapping,
12292
+ mapping2,
12292
12293
  DIAGNOSTIC_CONTEXT_DEPTH,
12293
12294
  { remaining: DIAGNOSTIC_CONTEXT_NODES }
12294
12295
  );
12295
- return freezeMetadataMap(mapping, "FLOW.QUERY diagnostic context");
12296
+ return freezeMetadataMap(mapping2, "FLOW.QUERY diagnostic context");
12296
12297
  }
12297
12298
  function validateDiagnosticContextValue(value, depth, budget) {
12298
12299
  consumeDiagnosticContextNode(value, budget);
@@ -12364,12 +12365,12 @@ function isDiagnosticContextRecord(value) {
12364
12365
  }
12365
12366
  function decodePosition(value) {
12366
12367
  if (value == null) return void 0;
12367
- const mapping = requiredMap2(value, "FLOW.QUERY diagnostic position");
12368
+ const mapping2 = requiredMap2(value, "FLOW.QUERY diagnostic position");
12368
12369
  return Object.freeze({
12369
- byte: positiveInteger(field(mapping, "byte"), "FLOW.QUERY diagnostic position byte"),
12370
- line: positiveInteger(field(mapping, "line"), "FLOW.QUERY diagnostic position line"),
12370
+ byte: positiveInteger(field(mapping2, "byte"), "FLOW.QUERY diagnostic position byte"),
12371
+ line: positiveInteger(field(mapping2, "line"), "FLOW.QUERY diagnostic position line"),
12371
12372
  column: positiveInteger(
12372
- field(mapping, "column"),
12373
+ field(mapping2, "column"),
12373
12374
  "FLOW.QUERY diagnostic position column"
12374
12375
  )
12375
12376
  });
@@ -12669,25 +12670,25 @@ function decodeUniqueTextArray(value, context, maximum, maximumBytes) {
12669
12670
  }
12670
12671
  return Object.freeze(result);
12671
12672
  }
12672
- function requiredChoice(mapping, name, context, choices) {
12673
- const value = requiredBoundedText2(mapping, name, context, 64);
12673
+ function requiredChoice(mapping2, name, context, choices) {
12674
+ const value = requiredBoundedText2(mapping2, name, context, 64);
12674
12675
  if (!choices.includes(value)) {
12675
- throw decodeError(`${context} ${name} is unsupported`, mapping);
12676
+ throw decodeError(`${context} ${name} is unsupported`, mapping2);
12676
12677
  }
12677
12678
  return value;
12678
12679
  }
12679
- function optionalBoundedText(mapping, name, context, maximumBytes) {
12680
- const value = field(mapping, name);
12680
+ function optionalBoundedText(mapping2, name, context, maximumBytes) {
12681
+ const value = field(mapping2, name);
12681
12682
  if (value == null) return void 0;
12682
12683
  return boundedText(value, `${context} ${name}`, maximumBytes);
12683
12684
  }
12684
- function optionalIndexInteger(mapping, name, context) {
12685
- const value = field(mapping, name);
12685
+ function optionalIndexInteger(mapping2, name, context) {
12686
+ const value = field(mapping2, name);
12686
12687
  return value == null ? void 0 : unsignedIndexInteger(value, `${context} ${name}`);
12687
12688
  }
12688
- function indexCounter(mapping, name, section) {
12689
+ function indexCounter(mapping2, name, section) {
12689
12690
  return unsignedIndexInteger(
12690
- field(mapping, name),
12691
+ field(mapping2, name),
12691
12692
  `FLOW.QUERY.INDEXES index ${section} ${name}`
12692
12693
  );
12693
12694
  }
@@ -12704,13 +12705,13 @@ function indexInteger2(value) {
12704
12705
  // src/flow-query-index-lifecycle-response.ts
12705
12706
  function decodeIndexCoverage(value) {
12706
12707
  const context = "FLOW.QUERY.INDEXES index coverage";
12707
- const mapping = requiredMap2(value, context);
12708
+ const mapping2 = requiredMap2(value, context);
12708
12709
  const completeShards = unsignedIndexInteger(
12709
- field(mapping, "complete_shards"),
12710
+ field(mapping2, "complete_shards"),
12710
12711
  `${context} complete_shards`
12711
12712
  );
12712
12713
  const totalShards = positiveIndexInteger(
12713
- field(mapping, "total_shards"),
12714
+ field(mapping2, "total_shards"),
12714
12715
  `${context} total_shards`
12715
12716
  );
12716
12717
  if (indexInteger2(completeShards) > indexInteger2(totalShards)) {
@@ -12719,60 +12720,60 @@ function decodeIndexCoverage(value) {
12719
12720
  return Object.freeze({
12720
12721
  completeShards,
12721
12722
  totalShards,
12722
- validation: requiredChoice(mapping, "validation", context, [
12723
+ validation: requiredChoice(mapping2, "validation", context, [
12723
12724
  "pending",
12724
12725
  "passed",
12725
12726
  "failed"
12726
12727
  ]),
12727
- raw: freezeMap(mapping)
12728
+ raw: freezeMap(mapping2)
12728
12729
  });
12729
12730
  }
12730
12731
  function decodeIndexBuild(value) {
12731
- const mapping = requiredMap2(value, "FLOW.QUERY.INDEXES index build");
12732
+ const mapping2 = requiredMap2(value, "FLOW.QUERY.INDEXES index build");
12732
12733
  const progress = decodeIndexProgress(
12733
- mapping,
12734
+ mapping2,
12734
12735
  "build",
12735
12736
  FLOW_QUERY_BUILD_PHASES
12736
12737
  );
12737
12738
  return Object.freeze({
12738
12739
  ...progress,
12739
- scannedRecords: indexCounter(mapping, "scanned_records", "build"),
12740
- writtenEntries: indexCounter(mapping, "written_entries", "build"),
12741
- writtenBytes: indexCounter(mapping, "written_bytes", "build")
12740
+ scannedRecords: indexCounter(mapping2, "scanned_records", "build"),
12741
+ writtenEntries: indexCounter(mapping2, "written_entries", "build"),
12742
+ writtenBytes: indexCounter(mapping2, "written_bytes", "build")
12742
12743
  });
12743
12744
  }
12744
12745
  function decodeIndexValidation(value) {
12745
- const mapping = requiredMap2(value, "FLOW.QUERY.INDEXES index validation");
12746
- if (!hasKey(mapping, "failure_reason") || !hasKey(mapping, "validated_at_ms")) {
12746
+ const mapping2 = requiredMap2(value, "FLOW.QUERY.INDEXES index validation");
12747
+ if (!hasKey(mapping2, "failure_reason") || !hasKey(mapping2, "validated_at_ms")) {
12747
12748
  throw decodeError(
12748
12749
  "FLOW.QUERY.INDEXES index validation is missing nullable fields",
12749
12750
  value
12750
12751
  );
12751
12752
  }
12752
12753
  const progress = decodeIndexProgress(
12753
- mapping,
12754
+ mapping2,
12754
12755
  "validation",
12755
12756
  FLOW_QUERY_VALIDATION_PHASES
12756
12757
  );
12757
12758
  return Object.freeze({
12758
12759
  ...progress,
12759
12760
  status: requiredChoice(
12760
- mapping,
12761
+ mapping2,
12761
12762
  "status",
12762
12763
  "FLOW.QUERY.INDEXES index validation",
12763
12764
  ["pending", "passed", "failed"]
12764
12765
  ),
12765
- checkedRecords: indexCounter(mapping, "checked_records", "validation"),
12766
- checkedEntries: indexCounter(mapping, "checked_entries", "validation"),
12767
- mismatches: indexCounter(mapping, "mismatches", "validation"),
12766
+ checkedRecords: indexCounter(mapping2, "checked_records", "validation"),
12767
+ checkedEntries: indexCounter(mapping2, "checked_entries", "validation"),
12768
+ mismatches: indexCounter(mapping2, "mismatches", "validation"),
12768
12769
  failureReason: optionalBoundedText(
12769
- mapping,
12770
+ mapping2,
12770
12771
  "failure_reason",
12771
12772
  "FLOW.QUERY.INDEXES index validation",
12772
12773
  128
12773
12774
  ),
12774
12775
  validatedAtMs: optionalIndexInteger(
12775
- mapping,
12776
+ mapping2,
12776
12777
  "validated_at_ms",
12777
12778
  "FLOW.QUERY.INDEXES index validation"
12778
12779
  )
@@ -12780,77 +12781,77 @@ function decodeIndexValidation(value) {
12780
12781
  }
12781
12782
  function decodeIndexRetirement(value) {
12782
12783
  const context = "FLOW.QUERY.INDEXES index retirement";
12783
- const mapping = requiredMap2(value, context);
12784
- const status = requiredChoice(mapping, "status", context, [
12784
+ const mapping2 = requiredMap2(value, context);
12785
+ const status = requiredChoice(mapping2, "status", context, [
12785
12786
  "not_applicable",
12786
12787
  "pending",
12787
12788
  "complete"
12788
12789
  ]);
12789
12790
  if (status === "not_applicable") {
12790
- return Object.freeze({ status, raw: freezeMap(mapping) });
12791
+ return Object.freeze({ status, raw: freezeMap(mapping2) });
12791
12792
  }
12792
12793
  const completedShards = unsignedIndexInteger(
12793
- field(mapping, "completed_shards"),
12794
+ field(mapping2, "completed_shards"),
12794
12795
  `${context} completed_shards`
12795
12796
  );
12796
12797
  const totalShards = positiveIndexInteger(
12797
- field(mapping, "total_shards"),
12798
+ field(mapping2, "total_shards"),
12798
12799
  `${context} total_shards`
12799
12800
  );
12800
12801
  if (indexInteger2(completedShards) > indexInteger2(totalShards)) {
12801
12802
  throw decodeError(
12802
12803
  `${context} completed_shards exceeds total_shards`,
12803
- mapping
12804
+ mapping2
12804
12805
  );
12805
12806
  }
12806
12807
  return Object.freeze({
12807
12808
  status,
12808
12809
  phaseCounts: decodePhaseCounts(
12809
- field(mapping, "phase_counts"),
12810
+ field(mapping2, "phase_counts"),
12810
12811
  "retirement"
12811
12812
  ),
12812
12813
  currentPhases: decodeAllowedPhases(
12813
- field(mapping, "current_phases"),
12814
+ field(mapping2, "current_phases"),
12814
12815
  "retirement",
12815
12816
  FLOW_QUERY_RETIREMENT_PHASES
12816
12817
  ),
12817
12818
  completedShards,
12818
12819
  totalShards,
12819
- deletedEntries: indexCounter(mapping, "deleted_entries", "retirement"),
12820
- deletedBytes: indexCounter(mapping, "deleted_bytes", "retirement"),
12820
+ deletedEntries: indexCounter(mapping2, "deleted_entries", "retirement"),
12821
+ deletedBytes: indexCounter(mapping2, "deleted_bytes", "retirement"),
12821
12822
  rewrittenReverseRows: indexCounter(
12822
- mapping,
12823
+ mapping2,
12823
12824
  "rewritten_reverse_rows",
12824
12825
  "retirement"
12825
12826
  ),
12826
- raw: freezeMap(mapping)
12827
+ raw: freezeMap(mapping2)
12827
12828
  });
12828
12829
  }
12829
12830
  function decodeIndexStatistics(value) {
12830
12831
  const context = "FLOW.QUERY.INDEXES index statistics";
12831
- const mapping = requiredMap2(value, context);
12832
+ const mapping2 = requiredMap2(value, context);
12832
12833
  for (const name of [
12833
12834
  "oldest_collected_at_ms",
12834
12835
  "newest_collected_at_ms",
12835
12836
  "oldest_age_ms",
12836
12837
  "newest_age_ms"
12837
12838
  ]) {
12838
- if (!hasKey(mapping, name)) {
12839
+ if (!hasKey(mapping2, name)) {
12839
12840
  throw decodeError(
12840
12841
  `${context} is missing required nullable fields`,
12841
12842
  value
12842
12843
  );
12843
12844
  }
12844
12845
  }
12845
- const samples = indexCounter(mapping, "samples", "statistics");
12846
- const freshSamples = indexCounter(mapping, "fresh_samples", "statistics");
12847
- const staleSamples = indexCounter(mapping, "stale_samples", "statistics");
12848
- const futureSamples = indexCounter(mapping, "future_samples", "statistics");
12846
+ const samples = indexCounter(mapping2, "samples", "statistics");
12847
+ const freshSamples = indexCounter(mapping2, "fresh_samples", "statistics");
12848
+ const staleSamples = indexCounter(mapping2, "stale_samples", "statistics");
12849
+ const futureSamples = indexCounter(mapping2, "future_samples", "statistics");
12849
12850
  if (indexInteger2(freshSamples) + indexInteger2(staleSamples) !== indexInteger2(samples) || indexInteger2(futureSamples) > indexInteger2(staleSamples)) {
12850
12851
  throw decodeError(`${context} counters are inconsistent`, value);
12851
12852
  }
12852
12853
  return Object.freeze({
12853
- status: requiredChoice(mapping, "status", context, [
12854
+ status: requiredChoice(mapping2, "status", context, [
12854
12855
  "fresh",
12855
12856
  "stale",
12856
12857
  "future",
@@ -12863,53 +12864,53 @@ function decodeIndexStatistics(value) {
12863
12864
  staleSamples,
12864
12865
  futureSamples,
12865
12866
  oldestCollectedAtMs: optionalIndexInteger(
12866
- mapping,
12867
+ mapping2,
12867
12868
  "oldest_collected_at_ms",
12868
12869
  context
12869
12870
  ),
12870
12871
  newestCollectedAtMs: optionalIndexInteger(
12871
- mapping,
12872
+ mapping2,
12872
12873
  "newest_collected_at_ms",
12873
12874
  context
12874
12875
  ),
12875
- oldestAgeMs: optionalIndexInteger(mapping, "oldest_age_ms", context),
12876
- newestAgeMs: optionalIndexInteger(mapping, "newest_age_ms", context),
12877
- raw: freezeMap(mapping)
12876
+ oldestAgeMs: optionalIndexInteger(mapping2, "oldest_age_ms", context),
12877
+ newestAgeMs: optionalIndexInteger(mapping2, "newest_age_ms", context),
12878
+ raw: freezeMap(mapping2)
12878
12879
  });
12879
12880
  }
12880
- function decodeIndexProgress(mapping, section, allowedPhases) {
12881
+ function decodeIndexProgress(mapping2, section, allowedPhases) {
12881
12882
  const context = `FLOW.QUERY.INDEXES index ${section}`;
12882
12883
  const completedShards = unsignedIndexInteger(
12883
- field(mapping, "completed_shards"),
12884
+ field(mapping2, "completed_shards"),
12884
12885
  `${context} completed_shards`
12885
12886
  );
12886
12887
  const totalShards = positiveIndexInteger(
12887
- field(mapping, "total_shards"),
12888
+ field(mapping2, "total_shards"),
12888
12889
  `${context} total_shards`
12889
12890
  );
12890
12891
  if (indexInteger2(completedShards) > indexInteger2(totalShards)) {
12891
12892
  throw decodeError(
12892
12893
  `${context} completed_shards exceeds total_shards`,
12893
- mapping
12894
+ mapping2
12894
12895
  );
12895
12896
  }
12896
12897
  return Object.freeze({
12897
- scope: requiredChoice(mapping, "scope", context, ["catalog_build"]),
12898
- phaseCounts: decodePhaseCounts(field(mapping, "phase_counts"), section),
12898
+ scope: requiredChoice(mapping2, "scope", context, ["catalog_build"]),
12899
+ phaseCounts: decodePhaseCounts(field(mapping2, "phase_counts"), section),
12899
12900
  currentPhases: decodeAllowedPhases(
12900
- field(mapping, "current_phases"),
12901
+ field(mapping2, "current_phases"),
12901
12902
  section,
12902
12903
  allowedPhases
12903
12904
  ),
12904
12905
  completedShards,
12905
12906
  totalShards,
12906
- raw: freezeMap(mapping)
12907
+ raw: freezeMap(mapping2)
12907
12908
  });
12908
12909
  }
12909
12910
  function decodePhaseCounts(value, section) {
12910
12911
  const context = `FLOW.QUERY.INDEXES index ${section} phase_counts`;
12911
- const mapping = requiredMap2(value, context);
12912
- const entries = mapping instanceof Map ? [...mapping.entries()] : Object.entries(mapping);
12912
+ const mapping2 = requiredMap2(value, context);
12913
+ const entries = mapping2 instanceof Map ? [...mapping2.entries()] : Object.entries(mapping2);
12913
12914
  if (entries.length > 16) {
12914
12915
  throw decodeError(`${context} contains too many entries`, value);
12915
12916
  }
@@ -12942,19 +12943,19 @@ function decodeAllowedPhases(value, section, allowed) {
12942
12943
  // src/flow-query-index-response.ts
12943
12944
  var FLOW_QUERY_INDEXES_CONTRACT = "ferric.flow.query.indexes/v1";
12944
12945
  function decodeFlowQueryIndexStatus(value, expectedId) {
12945
- const mapping = requiredMap2(value, "FLOW.QUERY.INDEXES");
12946
+ const mapping2 = requiredMap2(value, "FLOW.QUERY.INDEXES");
12946
12947
  requireContract(
12947
- mapping,
12948
+ mapping2,
12948
12949
  "contract_version",
12949
12950
  FLOW_QUERY_INDEXES_CONTRACT,
12950
12951
  "FLOW.QUERY.INDEXES"
12951
12952
  );
12952
12953
  const registry = requiredMap2(
12953
- field(mapping, "registry"),
12954
+ field(mapping2, "registry"),
12954
12955
  "FLOW.QUERY.INDEXES registry"
12955
12956
  );
12956
- const services = decodeIndexServices(field(mapping, "services"));
12957
- const rawIndexes = field(mapping, "indexes");
12957
+ const services = decodeIndexServices(field(mapping2, "services"));
12958
+ const rawIndexes = field(mapping2, "indexes");
12958
12959
  if (!Array.isArray(rawIndexes) || rawIndexes.length > 32) {
12959
12960
  throw decodeError(
12960
12961
  "FLOW.QUERY.INDEXES indexes must contain at most 32 entries",
@@ -12974,11 +12975,11 @@ function decodeFlowQueryIndexStatus(value, expectedId) {
12974
12975
  const status = Object.freeze({
12975
12976
  contractVersion: FLOW_QUERY_INDEXES_CONTRACT,
12976
12977
  observedAtMs: unsignedIndexInteger(
12977
- field(mapping, "observed_at_ms"),
12978
+ field(mapping2, "observed_at_ms"),
12978
12979
  "FLOW.QUERY.INDEXES observed_at_ms"
12979
12980
  ),
12980
12981
  statisticsMaxAgeMs: unsignedIndexInteger(
12981
- field(mapping, "statistics_max_age_ms"),
12982
+ field(mapping2, "statistics_max_age_ms"),
12982
12983
  "FLOW.QUERY.INDEXES statistics_max_age_ms"
12983
12984
  ),
12984
12985
  registry: Object.freeze({
@@ -12993,30 +12994,30 @@ function decodeFlowQueryIndexStatus(value, expectedId) {
12993
12994
  }),
12994
12995
  services,
12995
12996
  indexes: Object.freeze(indexes),
12996
- raw: freezeMap(mapping)
12997
+ raw: freezeMap(mapping2)
12997
12998
  });
12998
12999
  validateFlowQueryIndexContract(status, expectedId);
12999
13000
  return status;
13000
13001
  }
13001
13002
  function decodeIndex(value, index) {
13002
- const mapping = requiredMap2(value, `FLOW.QUERY.INDEXES index ${index}`);
13003
- const fields = decodeIndexFields(field(mapping, "fields"));
13003
+ const mapping2 = requiredMap2(value, `FLOW.QUERY.INDEXES index ${index}`);
13004
+ const fields = decodeIndexFields(field(mapping2, "fields"));
13004
13005
  return Object.freeze({
13005
- id: requiredBoundedText2(mapping, "id", "FLOW.QUERY.INDEXES index", 64),
13006
+ id: requiredBoundedText2(mapping2, "id", "FLOW.QUERY.INDEXES index", 64),
13006
13007
  version: positiveIndexInteger(
13007
- field(mapping, "version"),
13008
+ field(mapping2, "version"),
13008
13009
  "FLOW.QUERY.INDEXES index version"
13009
13010
  ),
13010
13011
  buildId: requiredBoundedText2(
13011
- mapping,
13012
+ mapping2,
13012
13013
  "build_id",
13013
13014
  "FLOW.QUERY.INDEXES index",
13014
13015
  128
13015
13016
  ),
13016
- source: requiredChoice(mapping, "source", "FLOW.QUERY.INDEXES index", [
13017
+ source: requiredChoice(mapping2, "source", "FLOW.QUERY.INDEXES index", [
13017
13018
  "runs"
13018
13019
  ]),
13019
- state: requiredChoice(mapping, "state", "FLOW.QUERY.INDEXES index", [
13020
+ state: requiredChoice(mapping2, "state", "FLOW.QUERY.INDEXES index", [
13020
13021
  "building",
13021
13022
  "validating",
13022
13023
  "active",
@@ -13024,60 +13025,60 @@ function decodeIndex(value, index) {
13024
13025
  "failed"
13025
13026
  ]),
13026
13027
  queryable: requiredBoolean(
13027
- mapping,
13028
+ mapping2,
13028
13029
  "queryable",
13029
13030
  "FLOW.QUERY.INDEXES index"
13030
13031
  ),
13031
13032
  fields,
13032
13033
  workloads: decodeUniqueTextArray(
13033
- field(mapping, "workloads"),
13034
+ field(mapping2, "workloads"),
13034
13035
  "FLOW.QUERY.INDEXES index workloads",
13035
13036
  16,
13036
13037
  64
13037
13038
  ),
13038
13039
  countPrefixes: decodeCountPrefixes(
13039
- field(mapping, "count_prefixes"),
13040
+ field(mapping2, "count_prefixes"),
13040
13041
  fields.length
13041
13042
  ),
13042
- coveringFields: decodeCoveringFields(mapping),
13043
- format: decodeIndexFormat(mapping),
13044
- coverage: decodeIndexCoverage(field(mapping, "coverage")),
13045
- build: decodeIndexBuild(field(mapping, "build")),
13046
- validation: decodeIndexValidation(field(mapping, "validation")),
13047
- retirement: decodeIndexRetirement(field(mapping, "retirement")),
13048
- statistics: decodeIndexStatistics(field(mapping, "statistics")),
13049
- raw: freezeMap(mapping)
13043
+ coveringFields: decodeCoveringFields(mapping2),
13044
+ format: decodeIndexFormat(mapping2),
13045
+ coverage: decodeIndexCoverage(field(mapping2, "coverage")),
13046
+ build: decodeIndexBuild(field(mapping2, "build")),
13047
+ validation: decodeIndexValidation(field(mapping2, "validation")),
13048
+ retirement: decodeIndexRetirement(field(mapping2, "retirement")),
13049
+ statistics: decodeIndexStatistics(field(mapping2, "statistics")),
13050
+ raw: freezeMap(mapping2)
13050
13051
  });
13051
13052
  }
13052
13053
  function decodeIndexServices(value) {
13053
- const mapping = requiredMap2(value, "FLOW.QUERY.INDEXES services");
13054
+ const mapping2 = requiredMap2(value, "FLOW.QUERY.INDEXES services");
13054
13055
  const choices = ["ready", "unavailable"];
13055
13056
  return Object.freeze({
13056
13057
  registry: requiredChoice(
13057
- mapping,
13058
+ mapping2,
13058
13059
  "registry",
13059
13060
  "FLOW.QUERY.INDEXES services",
13060
13061
  choices
13061
13062
  ),
13062
13063
  lifecycleWorker: requiredChoice(
13063
- mapping,
13064
+ mapping2,
13064
13065
  "lifecycle_worker",
13065
13066
  "FLOW.QUERY.INDEXES services",
13066
13067
  choices
13067
13068
  ),
13068
13069
  statisticsStore: requiredChoice(
13069
- mapping,
13070
+ mapping2,
13070
13071
  "statistics_store",
13071
13072
  "FLOW.QUERY.INDEXES services",
13072
13073
  choices
13073
13074
  ),
13074
13075
  statisticsWorker: requiredChoice(
13075
- mapping,
13076
+ mapping2,
13076
13077
  "statistics_worker",
13077
13078
  "FLOW.QUERY.INDEXES services",
13078
13079
  choices
13079
13080
  ),
13080
- raw: freezeMap(mapping)
13081
+ raw: freezeMap(mapping2)
13081
13082
  });
13082
13083
  }
13083
13084
  function decodeIndexFields(value) {
@@ -13091,12 +13092,12 @@ function decodeIndexFields(value) {
13091
13092
  if (!Object.hasOwn(value, index)) {
13092
13093
  throw decodeError(`${context} must be dense`, value);
13093
13094
  }
13094
- const mapping = requiredMap2(
13095
+ const mapping2 = requiredMap2(
13095
13096
  value[index],
13096
13097
  `FLOW.QUERY.INDEXES index field ${index}`
13097
13098
  );
13098
13099
  const name = requiredBoundedText2(
13099
- mapping,
13100
+ mapping2,
13100
13101
  "name",
13101
13102
  "FLOW.QUERY.INDEXES index field",
13102
13103
  512
@@ -13108,18 +13109,18 @@ function decodeIndexFields(value) {
13108
13109
  fields[index] = Object.freeze({
13109
13110
  name,
13110
13111
  direction: requiredChoice(
13111
- mapping,
13112
+ mapping2,
13112
13113
  "direction",
13113
13114
  "FLOW.QUERY.INDEXES index field",
13114
13115
  ["asc", "desc"]
13115
13116
  ),
13116
13117
  encoding: requiredChoice(
13117
- mapping,
13118
+ mapping2,
13118
13119
  "encoding",
13119
13120
  "FLOW.QUERY.INDEXES index field",
13120
13121
  ["hashed", "ordered"]
13121
13122
  ),
13122
- raw: freezeMap(mapping)
13123
+ raw: freezeMap(mapping2)
13123
13124
  });
13124
13125
  }
13125
13126
  return Object.freeze(fields);
@@ -13144,8 +13145,8 @@ function decodeCountPrefixes(value, fieldCount) {
13144
13145
  }
13145
13146
  return Object.freeze(prefixes);
13146
13147
  }
13147
- function decodeCoveringFields(mapping) {
13148
- const raw = field(mapping, "covering_fields");
13148
+ function decodeCoveringFields(mapping2) {
13149
+ const raw = field(mapping2, "covering_fields");
13149
13150
  if (!Array.isArray(raw) || raw.length > 32) {
13150
13151
  throw decodeError(
13151
13152
  "FLOW.QUERY.INDEXES index covering_fields must contain at most 32 entries",
@@ -13177,9 +13178,9 @@ function decodeCoveringFields(mapping) {
13177
13178
  }
13178
13179
  return Object.freeze(fields);
13179
13180
  }
13180
- function decodeIndexFormat(mapping) {
13181
+ function decodeIndexFormat(mapping2) {
13181
13182
  const raw = requiredMap2(
13182
- field(mapping, "format"),
13183
+ field(mapping2, "format"),
13183
13184
  "FLOW.QUERY.INDEXES index format"
13184
13185
  );
13185
13186
  if (!hasKey(raw, "counter")) {
@@ -13248,7 +13249,7 @@ var QUALITY_VALUES2 = {
13248
13249
  pagination: ["none", "complete", "authenticated_seek", "live_seek"]
13249
13250
  };
13250
13251
  function decodeFlowQueryResult(value) {
13251
- const result = decodeFlowQueryResponse(value, (mapping) => freezeMap(mapping));
13252
+ const result = decodeFlowQueryResponse(value, (mapping2) => freezeMap(mapping2));
13252
13253
  if (result.kind === "records") {
13253
13254
  return Object.freeze({
13254
13255
  kind: "records",
@@ -13272,7 +13273,7 @@ function decodeFlowQueryResult(value) {
13272
13273
  function decodeFlowQueryRecords(value, decodeRecord) {
13273
13274
  const result = decodeFlowQueryResponse(
13274
13275
  value,
13275
- (mapping, index) => decodeRecord(mapping instanceof Map ? freezeMap(mapping) : mapping, index)
13276
+ (mapping2, index) => decodeRecord(mapping2 instanceof Map ? freezeMap(mapping2) : mapping2, index)
13276
13277
  );
13277
13278
  if (result.kind === "count") {
13278
13279
  throw new FerricStoreError("Flow record convenience query returned a count result", {
@@ -13282,18 +13283,18 @@ function decodeFlowQueryRecords(value, decodeRecord) {
13282
13283
  return result.records;
13283
13284
  }
13284
13285
  function decodeFlowQueryResponse(value, decodeRecord) {
13285
- const mapping = requiredMap2(value, "FLOW.QUERY result");
13286
- requireContract(mapping, "version", FLOW_QUERY_RESULT_CONTRACT, "FLOW.QUERY result");
13287
- const quality = decodeQuality(field(mapping, "quality"));
13288
- const usage = decodeUsage(field(mapping, "usage"));
13289
- const hasRecords = hasKey(mapping, "records");
13290
- const hasCount = hasKey(mapping, "result");
13286
+ const mapping2 = requiredMap2(value, "FLOW.QUERY result");
13287
+ requireContract(mapping2, "version", FLOW_QUERY_RESULT_CONTRACT, "FLOW.QUERY result");
13288
+ const quality = decodeQuality(field(mapping2, "quality"));
13289
+ const usage = decodeUsage(field(mapping2, "usage"));
13290
+ const hasRecords = hasKey(mapping2, "records");
13291
+ const hasCount = hasKey(mapping2, "result");
13291
13292
  if (hasRecords === hasCount) {
13292
13293
  throw decodeError("FLOW.QUERY result must contain exactly one records or count shape", value);
13293
13294
  }
13294
- const raw = freezeMap(mapping);
13295
+ const raw = freezeMap(mapping2);
13295
13296
  if (hasRecords) {
13296
- const rawRecords = field(mapping, "records");
13297
+ const rawRecords = field(mapping2, "records");
13297
13298
  if (!Array.isArray(rawRecords) || rawRecords.length > 100) {
13298
13299
  throw decodeError("FLOW.QUERY records must be an array of at most 100 maps", value);
13299
13300
  }
@@ -13313,16 +13314,16 @@ function decodeFlowQueryResponse(value, decodeRecord) {
13313
13314
  return {
13314
13315
  kind: "records",
13315
13316
  records,
13316
- page: decodePage(field(mapping, "page")),
13317
+ page: decodePage(field(mapping2, "page")),
13317
13318
  quality,
13318
13319
  usage,
13319
13320
  raw
13320
13321
  };
13321
13322
  }
13322
- if (hasKey(mapping, "page")) {
13323
+ if (hasKey(mapping2, "page")) {
13323
13324
  throw decodeError("FLOW.QUERY count result contains an unexpected page", value);
13324
13325
  }
13325
- const countResult = requiredMap2(field(mapping, "result"), "FLOW.QUERY count result");
13326
+ const countResult = requiredMap2(field(mapping2, "result"), "FLOW.QUERY count result");
13326
13327
  if (requiredText2(countResult, "kind", "FLOW.QUERY count result") !== "count") {
13327
13328
  throw decodeError("FLOW.QUERY count result kind must be count", value);
13328
13329
  }
@@ -13343,31 +13344,31 @@ function decodeFlowQueryResponse(value, decodeRecord) {
13343
13344
  };
13344
13345
  }
13345
13346
  function decodeFlowExplainResult(value) {
13346
- const mapping = requiredMap2(value, "FLOW.QUERY explain");
13347
- requireContract(mapping, "version", FLOW_EXPLAIN_CONTRACT, "FLOW.QUERY explain");
13348
- const queryFingerprint = requiredText2(mapping, "query_fingerprint", "FLOW.QUERY explain");
13347
+ const mapping2 = requiredMap2(value, "FLOW.QUERY explain");
13348
+ requireContract(mapping2, "version", FLOW_EXPLAIN_CONTRACT, "FLOW.QUERY explain");
13349
+ const queryFingerprint = requiredText2(mapping2, "query_fingerprint", "FLOW.QUERY explain");
13349
13350
  if (!/^[0-9a-f]{64}$/iu.test(queryFingerprint)) {
13350
13351
  throw decodeError("FLOW.QUERY explain query_fingerprint is invalid", value);
13351
13352
  }
13352
- const status = requiredText2(mapping, "status", "FLOW.QUERY explain");
13353
+ const status = requiredText2(mapping2, "status", "FLOW.QUERY explain");
13353
13354
  if (status !== "planned" && status !== "rejected" && status !== "executed") {
13354
13355
  throw decodeError(`FLOW.QUERY explain status ${JSON.stringify(status)} is unsupported`, value);
13355
13356
  }
13356
13357
  const plan = freezeMetadataMap(
13357
- requiredMap2(field(mapping, "plan"), "FLOW.QUERY explain plan"),
13358
+ requiredMap2(field(mapping2, "plan"), "FLOW.QUERY explain plan"),
13358
13359
  "FLOW.QUERY explain plan"
13359
13360
  );
13360
13361
  const estimate = freezeMetadataMap(
13361
- requiredMap2(field(mapping, "estimate"), "FLOW.QUERY explain estimate"),
13362
+ requiredMap2(field(mapping2, "estimate"), "FLOW.QUERY explain estimate"),
13362
13363
  "FLOW.QUERY explain estimate"
13363
13364
  );
13364
13365
  const bounds = freezeMetadataMap(
13365
- requiredMap2(field(mapping, "bounds"), "FLOW.QUERY explain bounds"),
13366
+ requiredMap2(field(mapping2, "bounds"), "FLOW.QUERY explain bounds"),
13366
13367
  "FLOW.QUERY explain bounds"
13367
13368
  );
13368
- const capabilities = decodeExplainCapabilities(mapping);
13369
+ const capabilities = decodeExplainCapabilities(mapping2);
13369
13370
  const extendedFields = ["stats", "quality", "pressure", "decision", "alternatives"];
13370
- const extendedPresence = extendedFields.map((name) => hasKey(mapping, name));
13371
+ const extendedPresence = extendedFields.map((name) => hasKey(mapping2, name));
13371
13372
  const specialized = capabilities != null && !extendedPresence.some(Boolean);
13372
13373
  let stats;
13373
13374
  let quality;
@@ -13378,30 +13379,30 @@ function decodeFlowExplainResult(value) {
13378
13379
  if (status !== "planned") {
13379
13380
  throw decodeError("FLOW.QUERY specialized explain must be planned", value);
13380
13381
  }
13381
- if (hasKey(mapping, "actual") || hasKey(mapping, "diagnostic")) {
13382
+ if (hasKey(mapping2, "actual") || hasKey(mapping2, "diagnostic")) {
13382
13383
  throw decodeError("FLOW.QUERY specialized explain has extended status fields", value);
13383
13384
  }
13384
13385
  alternatives = Object.freeze([]);
13385
13386
  } else {
13386
- if (!extendedPresence.every(Boolean) || !hasKey(mapping, "actual") || !hasKey(mapping, "diagnostic")) {
13387
+ if (!extendedPresence.every(Boolean) || !hasKey(mapping2, "actual") || !hasKey(mapping2, "diagnostic")) {
13387
13388
  throw decodeError("FLOW.QUERY explain is missing required v1 fields", value);
13388
13389
  }
13389
13390
  stats = freezeMetadataMap(
13390
- requiredMap2(field(mapping, "stats"), "FLOW.QUERY explain stats"),
13391
+ requiredMap2(field(mapping2, "stats"), "FLOW.QUERY explain stats"),
13391
13392
  "FLOW.QUERY explain stats"
13392
13393
  );
13393
- quality = decodeQuality(field(mapping, "quality"));
13394
+ quality = decodeQuality(field(mapping2, "quality"));
13394
13395
  pressure = freezeMetadataMap(
13395
- requiredMap2(field(mapping, "pressure"), "FLOW.QUERY explain pressure"),
13396
+ requiredMap2(field(mapping2, "pressure"), "FLOW.QUERY explain pressure"),
13396
13397
  "FLOW.QUERY explain pressure"
13397
13398
  );
13398
13399
  decision = freezeMetadataMap(
13399
- requiredMap2(field(mapping, "decision"), "FLOW.QUERY explain decision"),
13400
+ requiredMap2(field(mapping2, "decision"), "FLOW.QUERY explain decision"),
13400
13401
  "FLOW.QUERY explain decision"
13401
13402
  );
13402
- alternatives = decodeExplainAlternatives(field(mapping, "alternatives"));
13403
+ alternatives = decodeExplainAlternatives(field(mapping2, "alternatives"));
13403
13404
  }
13404
- const actualValue = field(mapping, "actual");
13405
+ const actualValue = field(mapping2, "actual");
13405
13406
  let actual;
13406
13407
  if (status === "executed") {
13407
13408
  if (actualValue == null) {
@@ -13411,7 +13412,7 @@ function decodeFlowExplainResult(value) {
13411
13412
  } else if (actualValue != null) {
13412
13413
  throw decodeError("FLOW.QUERY non-executed explain contains actual usage", value);
13413
13414
  }
13414
- const diagnosticValue = field(mapping, "diagnostic");
13415
+ const diagnosticValue = field(mapping2, "diagnostic");
13415
13416
  let diagnostic;
13416
13417
  if (status === "rejected") {
13417
13418
  diagnostic = tryDecodeFlowQueryError(diagnosticValue);
@@ -13436,13 +13437,13 @@ function decodeFlowExplainResult(value) {
13436
13437
  capabilities,
13437
13438
  actual,
13438
13439
  diagnostic,
13439
- raw: freezeMap(mapping)
13440
+ raw: freezeMap(mapping2)
13440
13441
  });
13441
13442
  }
13442
- function decodeExplainCapabilities(mapping) {
13443
- if (!hasKey(mapping, "capabilities")) return void 0;
13443
+ function decodeExplainCapabilities(mapping2) {
13444
+ if (!hasKey(mapping2, "capabilities")) return void 0;
13444
13445
  const value = requiredMap2(
13445
- field(mapping, "capabilities"),
13446
+ field(mapping2, "capabilities"),
13446
13447
  "FLOW.QUERY explain capabilities"
13447
13448
  );
13448
13449
  return Object.freeze({
@@ -13498,27 +13499,27 @@ function decodeExplainAlternatives(value) {
13498
13499
  return Object.freeze(alternatives);
13499
13500
  }
13500
13501
  function decodeQuality(value) {
13501
- const mapping = requiredMap2(value, "FLOW.QUERY quality");
13502
+ const mapping2 = requiredMap2(value, "FLOW.QUERY quality");
13502
13503
  return Object.freeze({
13503
- exactness: decodeQualityValue(mapping, "exactness", QUALITY_VALUES2.exactness),
13504
- freshness: decodeQualityValue(mapping, "freshness", QUALITY_VALUES2.freshness),
13505
- coverage: decodeQualityValue(mapping, "coverage", QUALITY_VALUES2.coverage),
13506
- pagination: decodeQualityValue(mapping, "pagination", QUALITY_VALUES2.pagination)
13504
+ exactness: decodeQualityValue(mapping2, "exactness", QUALITY_VALUES2.exactness),
13505
+ freshness: decodeQualityValue(mapping2, "freshness", QUALITY_VALUES2.freshness),
13506
+ coverage: decodeQualityValue(mapping2, "coverage", QUALITY_VALUES2.coverage),
13507
+ pagination: decodeQualityValue(mapping2, "pagination", QUALITY_VALUES2.pagination)
13507
13508
  });
13508
13509
  }
13509
- function decodeQualityValue(mapping, name, allowed) {
13510
- const value = requiredBoundedText2(mapping, name, "FLOW.QUERY quality", 64);
13510
+ function decodeQualityValue(mapping2, name, allowed) {
13511
+ const value = requiredBoundedText2(mapping2, name, "FLOW.QUERY quality", 64);
13511
13512
  if (!allowed.includes(value)) {
13512
- throw decodeError(`FLOW.QUERY quality ${name} is unsupported`, mapping);
13513
+ throw decodeError(`FLOW.QUERY quality ${name} is unsupported`, mapping2);
13513
13514
  }
13514
13515
  return value;
13515
13516
  }
13516
13517
  function decodeUsage(value) {
13517
- const mapping = requiredMap2(value, "FLOW.QUERY usage");
13518
+ const mapping2 = requiredMap2(value, "FLOW.QUERY usage");
13518
13519
  const usage = /* @__PURE__ */ Object.create(null);
13519
13520
  for (const [wireName, property] of USAGE_FIELDS2) {
13520
13521
  usage[property] = nonNegativeInteger(
13521
- field(mapping, wireName),
13522
+ field(mapping2, wireName),
13522
13523
  `FLOW.QUERY usage ${wireName}`
13523
13524
  );
13524
13525
  }
@@ -13529,9 +13530,9 @@ function decodeUsage(value) {
13529
13530
  return Object.freeze(decoded);
13530
13531
  }
13531
13532
  function decodePage(value) {
13532
- const mapping = requiredMap2(value, "FLOW.QUERY page");
13533
- const hasMore = requiredBoolean(mapping, "has_more", "FLOW.QUERY page");
13534
- const cursor = optionalText2(mapping, "cursor", "FLOW.QUERY page");
13533
+ const mapping2 = requiredMap2(value, "FLOW.QUERY page");
13534
+ const hasMore = requiredBoolean(mapping2, "has_more", "FLOW.QUERY page");
13535
+ const cursor = optionalText2(mapping2, "cursor", "FLOW.QUERY page");
13535
13536
  if (cursor != null && (!cursor.startsWith("fqc1_") || import_node_buffer48.Buffer.byteLength(cursor) < 16 || import_node_buffer48.Buffer.byteLength(cursor) > 4096)) {
13536
13537
  throw decodeError("FLOW.QUERY page cursor is invalid", value);
13537
13538
  }
@@ -13647,12 +13648,12 @@ var ErrorMappingExecutor = class {
13647
13648
 
13648
13649
  // src/client-config.ts
13649
13650
  function snapshotClientOptions(options) {
13650
- const own = { ...options };
13651
+ const own2 = { ...options };
13651
13652
  const snapshot = {
13652
- ...own,
13653
- ...typeof own.autoBatch === "object" && own.autoBatch != null ? { autoBatch: Object.freeze({ ...own.autoBatch }) } : {},
13654
- ...own.backpressure == null ? {} : { backpressure: Object.freeze({ ...own.backpressure }) },
13655
- ...typeof own.reconnect === "object" && own.reconnect != null ? { reconnect: Object.freeze({ ...own.reconnect }) } : {}
13653
+ ...own2,
13654
+ ...typeof own2.autoBatch === "object" && own2.autoBatch != null ? { autoBatch: Object.freeze({ ...own2.autoBatch }) } : {},
13655
+ ...own2.backpressure == null ? {} : { backpressure: Object.freeze({ ...own2.backpressure }) },
13656
+ ...typeof own2.reconnect === "object" && own2.reconnect != null ? { reconnect: Object.freeze({ ...own2.reconnect }) } : {}
13656
13657
  };
13657
13658
  return Object.freeze(snapshot);
13658
13659
  }
@@ -15841,33 +15842,511 @@ var FerricStoreClientCore = class extends FerricStoreAdministrationClient {
15841
15842
  }
15842
15843
  };
15843
15844
 
15844
- // src/client-management.ts
15845
- var FerricStoreManagementClient = class extends FerricStoreClientCore {
15846
- async stats(type, options = {}) {
15847
- const args = ["FLOW.STATS", type];
15848
- append(args, "STATE", options.state);
15849
- append(args, "COUNT", options.count);
15850
- append(args, "PARTITION", options.partitionKey);
15851
- appendAttributes(args, options.attributes);
15852
- appendBool(args, "CONSISTENT_PROJECTION", options.consistentProjection);
15853
- return adminRecordResponse(await this.commandArgs(args), "FLOW.STATS");
15845
+ // src/schedule-request.ts
15846
+ var MAX_EXACT_INTEGER = Number.MAX_SAFE_INTEGER;
15847
+ var SCHEDULE_KINDS = /* @__PURE__ */ new Set(["one_shot", "delay", "interval", "cron"]);
15848
+ var RECURRING_KINDS = /* @__PURE__ */ new Set(["interval", "cron"]);
15849
+ var OVERLAP_POLICIES = /* @__PURE__ */ new Set([
15850
+ "allow",
15851
+ "skip",
15852
+ "queue_after_previous",
15853
+ "fail_schedule"
15854
+ ]);
15855
+ var SCHEDULE_STATES = /* @__PURE__ */ new Set([
15856
+ "active",
15857
+ "paused",
15858
+ "running",
15859
+ "completed",
15860
+ "failed",
15861
+ "cancelled",
15862
+ "all"
15863
+ ]);
15864
+ var TARGET_FIELDS = /* @__PURE__ */ new Set([
15865
+ "correlation_id",
15866
+ "id",
15867
+ "id_prefix",
15868
+ "parent_flow_id",
15869
+ "partition_key",
15870
+ "payload",
15871
+ "payload_ref",
15872
+ "priority",
15873
+ "root_flow_id",
15874
+ "run_at_ms",
15875
+ "state",
15876
+ "type",
15877
+ "value_refs",
15878
+ "values"
15879
+ ]);
15880
+ var TARGET_TEXT_FIELDS = [
15881
+ "state",
15882
+ "id",
15883
+ "id_prefix",
15884
+ "partition_key",
15885
+ "correlation_id",
15886
+ "parent_flow_id",
15887
+ "root_flow_id",
15888
+ "payload_ref"
15889
+ ];
15890
+ var INTERNAL_SCHEDULE_TYPE = "__ferricstore_schedule";
15891
+ var INTERNAL_SCHEDULE_ID_PREFIX = "__ferricstore_schedule__:";
15892
+ function validateScheduleCreate(id, options) {
15893
+ requiredText3(id, "id");
15894
+ if (!mapping(options)) throw new TypeError("schedule options must be a mapping");
15895
+ const kind = effectiveKind(options);
15896
+ validateTiming(kind, options);
15897
+ const recurring = RECURRING_KINDS.has(kind);
15898
+ validateTarget(options.target, recurring);
15899
+ nonNegativeInteger2(options.atMs, "at_ms");
15900
+ nonNegativeInteger2(options.delayMs, "delay_ms");
15901
+ nonNegativeInteger2(options.startAtMs, "start_at_ms");
15902
+ positiveInteger2(options.everyMs, "every_ms");
15903
+ positiveInteger2(options.overlapRetryMs, "overlap_retry_ms");
15904
+ positiveInteger2(options.maxFires, "max_fires");
15905
+ nonNegativeInteger2(options.endAtMs, "end_at_ms");
15906
+ nonNegativeInteger2(options.nowMs, "now_ms");
15907
+ optionalBoolean(options.overwrite, "overwrite");
15908
+ if (kind === "delay") {
15909
+ if (options.delayMs == null) throw new TypeError("delay_ms is required for delay schedules");
15910
+ if (options.nowMs != null && options.nowMs > MAX_EXACT_INTEGER - options.delayMs) {
15911
+ throw new TypeError("now_ms plus delay_ms exceeds the exact integer range");
15912
+ }
15913
+ }
15914
+ if (kind === "interval" && options.everyMs == null) {
15915
+ throw new TypeError("every_ms is required for interval schedules");
15916
+ }
15917
+ if (kind === "cron") {
15918
+ requiredText3(options.cron, "cron");
15919
+ optionalText3(options.timezone, "timezone");
15920
+ } else if (options.timezone != null) {
15921
+ throw new TypeError("timezone is only supported for cron schedules");
15922
+ }
15923
+ if (kind === "interval") {
15924
+ if (options.catchupPolicy != null && options.catchupPolicy !== "fire_once") {
15925
+ throw new TypeError("catchup_policy must be fire_once");
15926
+ }
15927
+ } else if (options.catchupPolicy != null) {
15928
+ throw new TypeError("catchup_policy is only supported for interval schedules");
15929
+ }
15930
+ if (recurring) {
15931
+ if (options.overlapPolicy != null && !OVERLAP_POLICIES.has(options.overlapPolicy)) {
15932
+ throw new TypeError(
15933
+ "overlap_policy must be allow, skip, queue_after_previous, or fail_schedule"
15934
+ );
15935
+ }
15936
+ if (options.overlapRetryMs != null && options.overlapPolicy !== "queue_after_previous") {
15937
+ throw new TypeError("overlap_retry_ms requires overlap_policy queue_after_previous");
15938
+ }
15939
+ const firstRun = knownFirstRun(kind, options);
15940
+ if (options.endAtMs != null && firstRun != null && options.endAtMs < firstRun) {
15941
+ throw new TypeError("end_at_ms must be at or after first run");
15942
+ }
15943
+ } else {
15944
+ if (options.overlapPolicy != null) {
15945
+ throw new TypeError("overlap_policy is only supported for recurring schedules");
15946
+ }
15947
+ if (options.overlapRetryMs != null) {
15948
+ throw new TypeError("overlap_retry_ms requires overlap_policy queue_after_previous");
15949
+ }
15950
+ if (options.maxFires != null) {
15951
+ throw new TypeError("max_fires is only supported for recurring schedules");
15952
+ }
15953
+ if (options.endAtMs != null) {
15954
+ throw new TypeError("end_at_ms is only supported for recurring schedules");
15955
+ }
15854
15956
  }
15855
- async countByState(type, state, options = {}) {
15856
- const stats = await this.stats(type, { ...options, state });
15857
- if (!("count" in stats)) throw new TypeError("FLOW.STATS response missing count");
15858
- return integer(stats.count);
15957
+ }
15958
+ function validateScheduleID(id) {
15959
+ requiredText3(id, "id");
15960
+ }
15961
+ function validateScheduleFire(id, options) {
15962
+ validateScheduleID(id);
15963
+ nonNegativeInteger2(options.fireAtMs, "fire_at_ms");
15964
+ nonNegativeInteger2(options.nowMs, "now_ms");
15965
+ }
15966
+ function validateScheduleStatus(id, nowMs2) {
15967
+ validateScheduleID(id);
15968
+ nonNegativeInteger2(nowMs2, "now_ms");
15969
+ }
15970
+ function validateScheduleFireDue(options) {
15971
+ if (!mapping(options)) throw new TypeError("schedule fire-due options must be a mapping");
15972
+ nonNegativeInteger2(options.nowMs, "now_ms");
15973
+ optionalText3(options.worker, "worker");
15974
+ positiveInteger2(options.leaseMs, "lease_ms");
15975
+ nonNegativeInteger2(options.blockMs, "block_ms");
15976
+ positiveInteger2(options.limit, "limit");
15977
+ const leaseMs = options.leaseMs ?? 3e4;
15978
+ if (options.nowMs != null && options.nowMs > MAX_EXACT_INTEGER - leaseMs) {
15979
+ throw new TypeError("now_ms plus lease_ms exceeds the exact integer range");
15859
15980
  }
15860
- async attributes(type, options = {}) {
15861
- const args = ["FLOW.ATTRIBUTES", type];
15862
- appendAttributeQueryOptions(args, options);
15863
- return adminRecordList(await this.commandArgs(args), "FLOW.ATTRIBUTES");
15981
+ }
15982
+ function validateScheduleList(options) {
15983
+ if (!mapping(options)) throw new TypeError("schedule list options must be a mapping");
15984
+ if (options.kind != null && !SCHEDULE_KINDS.has(options.kind)) {
15985
+ throw new TypeError("kind must be one_shot, delay, interval, or cron");
15864
15986
  }
15865
- async attributeValues(type, attribute, options = {}) {
15866
- const args = ["FLOW.ATTRIBUTE_VALUES", type, attribute];
15867
- appendAttributeQueryOptions(args, options);
15868
- return adminRecordList(await this.commandArgs(args), "FLOW.ATTRIBUTE_VALUES");
15987
+ if (options.state != null && !SCHEDULE_STATES.has(options.state)) {
15988
+ throw new TypeError("state is invalid");
15989
+ }
15990
+ optionalText3(options.timezone, "timezone");
15991
+ optionalText3(options.targetType, "target_type");
15992
+ nonNegativeInteger2(options.fromMs, "from_ms");
15993
+ nonNegativeInteger2(options.toMs, "to_ms");
15994
+ if (options.fromMs != null && options.toMs != null && options.fromMs > options.toMs) {
15995
+ throw new TypeError("from_ms must not exceed to_ms");
15996
+ }
15997
+ positiveInteger2(options.count, "count");
15998
+ optionalBoolean(options.rev, "rev");
15999
+ }
16000
+ function effectiveKind(options) {
16001
+ if (options.kind != null) {
16002
+ if (!SCHEDULE_KINDS.has(options.kind)) {
16003
+ throw new TypeError("kind must be one_shot, delay, interval, or cron");
16004
+ }
16005
+ return options.kind;
16006
+ }
16007
+ if (options.cron != null) return "cron";
16008
+ if (options.everyMs != null) return "interval";
16009
+ if (options.delayMs != null) return "delay";
16010
+ return "one_shot";
16011
+ }
16012
+ function validateTiming(kind, options) {
16013
+ if (options.atMs != null && options.startAtMs != null) {
16014
+ throw new TypeError("cannot set both at_ms and start_at_ms");
16015
+ }
16016
+ if (options.delayMs != null && kind !== "delay") {
16017
+ throw new TypeError("delay_ms is only supported for delay schedules");
16018
+ }
16019
+ if (options.everyMs != null && kind !== "interval") {
16020
+ throw new TypeError("every_ms is only supported for interval schedules");
16021
+ }
16022
+ if (options.cron != null && kind !== "cron") {
16023
+ throw new TypeError("cron is only supported for cron schedules");
16024
+ }
16025
+ if (kind === "delay" && (options.atMs != null || options.startAtMs != null)) {
16026
+ throw new TypeError("at_ms and start_at_ms are not supported for delay schedules");
16027
+ }
16028
+ }
16029
+ function validateTarget(value, recurring) {
16030
+ if (!mapping(value)) throw new TypeError("target must be a mapping with a non-empty type");
16031
+ const target = value;
16032
+ for (const key of Object.keys(target)) {
16033
+ if (!TARGET_FIELDS.has(key)) throw new TypeError(`target contains unknown field ${key}`);
16034
+ }
16035
+ const type = own(target, "type");
16036
+ requiredText3(type, "target type");
16037
+ if (type === INTERNAL_SCHEDULE_TYPE) {
16038
+ throw new TypeError("target type is reserved for internal use");
16039
+ }
16040
+ for (const key of TARGET_TEXT_FIELDS) optionalText3(own(target, key), `target ${key}`);
16041
+ const id = own(target, "id");
16042
+ const idPrefix = own(target, "id_prefix");
16043
+ if (id != null && idPrefix != null) {
16044
+ throw new TypeError("target cannot set both id and id_prefix");
16045
+ }
16046
+ if (recurring && id != null) {
16047
+ throw new TypeError("target id is not supported for recurring schedules; use id_prefix");
16048
+ }
16049
+ if (typeof id === "string" && id.startsWith(INTERNAL_SCHEDULE_ID_PREFIX)) {
16050
+ throw new TypeError("target id is reserved for internal use");
16051
+ }
16052
+ if (typeof idPrefix === "string" && idPrefix.startsWith(INTERNAL_SCHEDULE_ID_PREFIX)) {
16053
+ throw new TypeError("target id_prefix is reserved for internal use");
16054
+ }
16055
+ nonNegativeInteger2(own(target, "run_at_ms"), "target run_at_ms");
16056
+ const priority = own(target, "priority");
16057
+ if (priority != null && (typeof priority !== "number" || !Number.isSafeInteger(priority) || priority < 0 || priority > 2)) {
16058
+ throw new TypeError("target priority must be an integer between 0 and 2");
16059
+ }
16060
+ }
16061
+ function knownFirstRun(kind, options) {
16062
+ if (kind === "delay") {
16063
+ if (options.nowMs == null || options.delayMs == null) return void 0;
16064
+ return options.nowMs + options.delayMs;
16065
+ }
16066
+ if (kind === "cron") return options.startAtMs ?? options.atMs ?? options.nowMs;
16067
+ return options.atMs ?? options.startAtMs ?? options.nowMs;
16068
+ }
16069
+ function requiredText3(value, name) {
16070
+ if (typeof value !== "string" || value.length === 0) {
16071
+ throw new TypeError(`${name} must be a non-empty string`);
16072
+ }
16073
+ }
16074
+ function optionalText3(value, name) {
16075
+ if (value != null) requiredText3(value, name);
16076
+ }
16077
+ function nonNegativeInteger2(value, name) {
16078
+ if (value != null && (typeof value !== "number" || !Number.isSafeInteger(value) || value < 0)) {
16079
+ throw new TypeError(`${name} must be a non-negative exact integer`);
16080
+ }
16081
+ }
16082
+ function positiveInteger2(value, name) {
16083
+ if (value != null && (typeof value !== "number" || !Number.isSafeInteger(value) || value <= 0)) {
16084
+ throw new TypeError(`${name} must be a positive exact integer`);
16085
+ }
16086
+ }
16087
+ function optionalBoolean(value, name) {
16088
+ if (value != null && typeof value !== "boolean") {
16089
+ throw new TypeError(`${name} must be a boolean`);
16090
+ }
16091
+ }
16092
+ function mapping(value) {
16093
+ return typeof value === "object" && value !== null && !Array.isArray(value);
16094
+ }
16095
+ function own(mapping2, key) {
16096
+ return Object.prototype.hasOwnProperty.call(mapping2, key) ? mapping2[key] : void 0;
16097
+ }
16098
+
16099
+ // src/schedule-response.ts
16100
+ var SCHEDULE_INTEGER_FIELDS = [
16101
+ "end_at_ms",
16102
+ "last_catchup_at_ms",
16103
+ "last_fire_at_ms",
16104
+ "last_overlap_at_ms",
16105
+ "last_skipped_at_ms",
16106
+ "max_fires",
16107
+ "next_run_at_ms",
16108
+ "overlap_queued_due_at_ms"
16109
+ ];
16110
+ var REQUIRED_SCHEDULE_INTEGER_FIELDS = [
16111
+ "attempts",
16112
+ "coalesced_count",
16113
+ "fire_count",
16114
+ "last_coalesced_count",
16115
+ "skipped_count"
16116
+ ];
16117
+ var OPTIONAL_SCHEDULE_TEXT_FIELDS = [
16118
+ "cron",
16119
+ "end_reason",
16120
+ "flow_id",
16121
+ "last_overlap_reason",
16122
+ "last_overlap_target_id",
16123
+ "last_planning_error",
16124
+ "last_target_id",
16125
+ "timezone"
16126
+ ];
16127
+ var SCHEDULE_KINDS2 = /* @__PURE__ */ new Set(["one_shot", "delay", "interval", "cron"]);
16128
+ var SCHEDULE_STATES2 = /* @__PURE__ */ new Set([
16129
+ "active",
16130
+ "paused",
16131
+ "running",
16132
+ "completed",
16133
+ "failed",
16134
+ "cancelled"
16135
+ ]);
16136
+ var SCHEDULE_OVERLAP_POLICIES = /* @__PURE__ */ new Set([
16137
+ "allow",
16138
+ "skip",
16139
+ "queue_after_previous",
16140
+ "fail_schedule"
16141
+ ]);
16142
+ function scheduleRecordResponse(value, context) {
16143
+ const record = adminRecordResponse(value, context);
16144
+ if (typeof record.id !== "string" || record.id.length === 0) {
16145
+ throw new TypeError(`${context} response missing id`);
16146
+ }
16147
+ if (typeof record.kind !== "string" || !SCHEDULE_KINDS2.has(record.kind)) {
16148
+ throw new TypeError(`${context} response missing or invalid kind`);
16149
+ }
16150
+ if (typeof record.state !== "string" || !SCHEDULE_STATES2.has(record.state)) {
16151
+ throw new TypeError(`${context} response missing or invalid state`);
16152
+ }
16153
+ if (typeof record.target !== "object" || record.target == null || Array.isArray(record.target)) {
16154
+ throw new TypeError(`${context} response missing or invalid target`);
16155
+ }
16156
+ const target = record.target;
16157
+ if (typeof target.type !== "string" || target.type.length === 0) {
16158
+ throw new TypeError(`${context} response missing or invalid target type`);
16159
+ }
16160
+ if (!("catchup_policy" in record) || record.kind === "interval" && record.catchup_policy !== "fire_once" || record.kind !== "interval" && record.catchup_policy != null) {
16161
+ throw new TypeError(`${context} returned an invalid catchup_policy`);
16162
+ }
16163
+ if (typeof record.overlap_policy !== "string" || !SCHEDULE_OVERLAP_POLICIES.has(record.overlap_policy)) {
16164
+ throw new TypeError(`${context} response missing or invalid overlap_policy`);
16165
+ }
16166
+ safeNonNegativeInteger(record, "created_at_ms", context, true);
16167
+ const everyMs = requiredNullableNonNegativeInteger(record, "every_ms", context);
16168
+ const cron = requiredNullableResponseText(record, "cron", context);
16169
+ const timezone = requiredNullableResponseText(record, "timezone", context);
16170
+ const overlapRetryMs = requiredNullableNonNegativeInteger(
16171
+ record,
16172
+ "overlap_retry_ms",
16173
+ context
16174
+ );
16175
+ validateRecurrence(record, context, everyMs, cron, timezone, overlapRetryMs);
16176
+ let coalescedCount = 0;
16177
+ let lastCoalescedCount = 0;
16178
+ for (const field3 of REQUIRED_SCHEDULE_INTEGER_FIELDS) {
16179
+ const value2 = safeNonNegativeInteger(record, field3, context, true);
16180
+ if (field3 === "coalesced_count") coalescedCount = value2;
16181
+ if (field3 === "last_coalesced_count") lastCoalescedCount = value2;
16182
+ }
16183
+ for (const field3 of SCHEDULE_INTEGER_FIELDS) {
16184
+ if (record[field3] != null) safeNonNegativeInteger(record, field3, context);
16185
+ }
16186
+ for (const field3 of OPTIONAL_SCHEDULE_TEXT_FIELDS) {
16187
+ optionalResponseText(record, field3, context);
16188
+ }
16189
+ validateCatchupState(record, context, coalescedCount, lastCoalescedCount);
16190
+ return record;
16191
+ }
16192
+ function validateRecurrence(record, context, everyMs, cron, timezone, overlapRetryMs) {
16193
+ if (record.kind === "interval") {
16194
+ if (everyMs == null || everyMs <= 0) {
16195
+ throw new TypeError(`${context} interval every_ms must be positive`);
16196
+ }
16197
+ } else if (everyMs != null) {
16198
+ throw new TypeError(`${context} every_ms is only valid for interval schedules`);
16199
+ }
16200
+ if (record.kind === "cron") {
16201
+ if (cron == null) throw new TypeError(`${context} cron schedule is missing cron`);
16202
+ if (timezone == null) throw new TypeError(`${context} cron schedule is missing timezone`);
16203
+ } else if (cron != null) {
16204
+ throw new TypeError(`${context} cron is only valid for cron schedules`);
16205
+ } else if (timezone != null) {
16206
+ throw new TypeError(`${context} timezone is only valid for cron schedules`);
16207
+ }
16208
+ if (record.kind !== "interval" && record.kind !== "cron" && record.overlap_policy !== "allow") {
16209
+ throw new TypeError(`${context} overlap_policy is only valid for recurring schedules`);
16210
+ }
16211
+ if (overlapRetryMs != null) {
16212
+ if (overlapRetryMs <= 0) {
16213
+ throw new TypeError(`${context} overlap_retry_ms must be positive`);
16214
+ }
16215
+ if (record.overlap_policy !== "queue_after_previous") {
16216
+ throw new TypeError(`${context} overlap_retry_ms requires queue_after_previous`);
16217
+ }
16218
+ }
16219
+ }
16220
+ function validateCatchupState(record, context, coalescedCount, lastCoalescedCount) {
16221
+ const lastCatchupAt = record.last_catchup_at_ms;
16222
+ if (record.kind !== "interval") {
16223
+ if (coalescedCount !== 0) {
16224
+ throw new TypeError(`${context} non-interval coalesced_count must be zero`);
16225
+ }
16226
+ if (lastCoalescedCount !== 0) {
16227
+ throw new TypeError(`${context} non-interval last_coalesced_count must be zero`);
16228
+ }
16229
+ if (lastCatchupAt != null) {
16230
+ throw new TypeError(`${context} non-interval last_catchup_at_ms must be null`);
16231
+ }
16232
+ return;
16233
+ }
16234
+ if (lastCoalescedCount > coalescedCount) {
16235
+ throw new TypeError(`${context} last_coalesced_count exceeds coalesced_count`);
16236
+ }
16237
+ if (lastCoalescedCount > 0 && lastCatchupAt == null) {
16238
+ throw new TypeError(`${context} response missing last_catchup_at_ms after catch-up`);
16239
+ }
16240
+ if (lastCoalescedCount === 0 && lastCatchupAt != null) {
16241
+ throw new TypeError(`${context} last_catchup_at_ms requires a catch-up`);
16242
+ }
16243
+ }
16244
+ function optionalScheduleRecord(value, context) {
16245
+ return value == null ? null : scheduleRecordResponse(value, context);
16246
+ }
16247
+ function scheduleRecordList(value, context) {
16248
+ return arrayResponse(value).map((item) => scheduleRecordResponse(item, context));
16249
+ }
16250
+ function scheduleFireDueResponse(value) {
16251
+ const context = "FLOW.SCHEDULE.FIRE_DUE";
16252
+ const record = adminRecordResponse(value, context);
16253
+ const claimed = safeNonNegativeInteger(record, "claimed", context, true);
16254
+ const fired = safeNonNegativeInteger(record, "fired", context, true);
16255
+ const skipped = safeNonNegativeInteger(record, "skipped", context, true);
16256
+ const coalesced = safeNonNegativeInteger(record, "coalesced", context, true);
16257
+ if (!Array.isArray(record.errors)) {
16258
+ throw new TypeError(`${context} response missing errors`);
16259
+ }
16260
+ for (const error of record.errors) {
16261
+ if (!Array.isArray(error) || error.length !== 2 || typeof error[0] !== "string" || error[0].length === 0 || typeof error[1] !== "string" || error[1].length === 0) {
16262
+ throw new TypeError(`${context} returned an invalid error entry`);
16263
+ }
16264
+ }
16265
+ if (fired + skipped + record.errors.length !== claimed) {
16266
+ throw new TypeError(`${context} outcomes do not equal claimed`);
16267
+ }
16268
+ optionalResponseText(record, "claim_error", context);
16269
+ const lastTargetId = optionalResponseText(record, "last_target_id", context);
16270
+ const lastSkipReason = optionalResponseText(record, "last_skip_reason", context);
16271
+ if (fired > 0 && lastTargetId == null) {
16272
+ throw new TypeError(`${context} response missing last_target_id`);
16273
+ }
16274
+ if (fired === 0 && lastTargetId != null) {
16275
+ throw new TypeError(`${context} last_target_id requires a fired outcome`);
16276
+ }
16277
+ if (skipped > 0 && lastSkipReason == null) {
16278
+ throw new TypeError(`${context} response missing last_skip_reason`);
16279
+ }
16280
+ if (skipped === 0 && lastSkipReason != null) {
16281
+ throw new TypeError(`${context} last_skip_reason requires a skipped outcome`);
16282
+ }
16283
+ if (coalesced > 0 && fired + skipped === 0) {
16284
+ throw new TypeError(`${context} coalesced count requires a fired or skipped outcome`);
16285
+ }
16286
+ return record;
16287
+ }
16288
+ function scheduleFireResponse(value) {
16289
+ const context = "FLOW.SCHEDULE.FIRE";
16290
+ const record = adminRecordResponse(value, context);
16291
+ const schedule = scheduleRecordResponse(record.schedule, `${context} schedule`);
16292
+ const fired = safeNonNegativeInteger(record, "fired", context, true);
16293
+ const skipped = record.skipped == null ? 0 : safeNonNegativeInteger(record, "skipped", context);
16294
+ if (fired > 1 || skipped > 1 || fired + skipped !== 1) {
16295
+ throw new TypeError(`${context} outcomes must equal one`);
16296
+ }
16297
+ if (fired === 1 && (typeof record.target_id !== "string" || record.target_id.length === 0)) {
16298
+ throw new TypeError(`${context} response missing target_id`);
16299
+ }
16300
+ if (skipped === 1 && (typeof record.reason !== "string" || record.reason.length === 0)) {
16301
+ throw new TypeError(`${context} response missing reason`);
16302
+ }
16303
+ if (fired === 0 && record.target_id != null) {
16304
+ throw new TypeError(`${context} target_id requires a fired outcome`);
16305
+ }
16306
+ if (skipped === 0 && record.reason != null) {
16307
+ throw new TypeError(`${context} reason requires a skipped outcome`);
16308
+ }
16309
+ return { ...record, fired, skipped, schedule };
16310
+ }
16311
+ function optionalResponseText(record, field3, context) {
16312
+ const value = record[field3];
16313
+ if (value == null) return void 0;
16314
+ if (typeof value !== "string" || value.length === 0) {
16315
+ throw new TypeError(`${context} ${field3} must be non-empty text`);
15869
16316
  }
16317
+ return value;
16318
+ }
16319
+ function requiredNullableResponseText(record, field3, context) {
16320
+ if (!(field3 in record)) throw new TypeError(`${context} response missing ${field3}`);
16321
+ if (record[field3] === void 0) {
16322
+ throw new TypeError(`${context} response missing ${field3}`);
16323
+ }
16324
+ return optionalResponseText(record, field3, context) ?? null;
16325
+ }
16326
+ function requiredNullableNonNegativeInteger(record, field3, context) {
16327
+ if (!(field3 in record)) throw new TypeError(`${context} response missing ${field3}`);
16328
+ if (record[field3] === void 0) {
16329
+ throw new TypeError(`${context} response missing ${field3}`);
16330
+ }
16331
+ if (record[field3] === null) return null;
16332
+ return safeNonNegativeInteger(record, field3, context);
16333
+ }
16334
+ function safeNonNegativeInteger(record, field3, context, required = false) {
16335
+ if (!(field3 in record) || record[field3] == null) {
16336
+ if (required) throw new TypeError(`${context} response missing ${field3}`);
16337
+ return 0;
16338
+ }
16339
+ const value = record[field3];
16340
+ if (typeof value !== "number" || !Number.isSafeInteger(value) || value < 0) {
16341
+ throw new TypeError(`${context} ${field3} must be a safe non-negative integer`);
16342
+ }
16343
+ return value;
16344
+ }
16345
+
16346
+ // src/client-schedules.ts
16347
+ var FerricStoreScheduleClient = class extends FerricStoreClientCore {
15870
16348
  async scheduleCreate(id, options) {
16349
+ validateScheduleCreate(id, options);
15871
16350
  const args = ["FLOW.SCHEDULE.CREATE", id];
15872
16351
  append(args, "KIND", options.kind);
15873
16352
  append(args, "AT_MS", options.atMs);
@@ -15877,6 +16356,7 @@ var FerricStoreManagementClient = class extends FerricStoreClientCore {
15877
16356
  append(args, "CRON", options.cron);
15878
16357
  append(args, "TIMEZONE", options.timezone);
15879
16358
  append(args, "TARGET", options.target);
16359
+ append(args, "CATCHUP_POLICY", options.catchupPolicy);
15880
16360
  append(args, "OVERLAP_POLICY", options.overlapPolicy);
15881
16361
  append(args, "OVERLAP_RETRY_MS", options.overlapRetryMs);
15882
16362
  append(args, "MAX_FIRES", options.maxFires);
@@ -15886,34 +16366,55 @@ var FerricStoreManagementClient = class extends FerricStoreClientCore {
15886
16366
  for (const [name, value] of Object.entries(options.extraOptions ?? {})) {
15887
16367
  args.push(name.toUpperCase(), value);
15888
16368
  }
15889
- return adminRecordResponse(await this.commandArgs(args), "FLOW.SCHEDULE.CREATE");
16369
+ return scheduleRecordResponse(await this.commandArgs(args), "FLOW.SCHEDULE.CREATE");
15890
16370
  }
15891
- async scheduleGet(id, options = {}) {
15892
- const args = ["FLOW.SCHEDULE.GET", id];
15893
- append(args, "NOW", options.nowMs);
15894
- return optionalAdminRecord(await this.commandArgs(args), "FLOW.SCHEDULE.GET");
16371
+ async scheduleGet(id) {
16372
+ validateScheduleID(id);
16373
+ return optionalScheduleRecord(
16374
+ await this.commandArgs(["FLOW.SCHEDULE.GET", id]),
16375
+ "FLOW.SCHEDULE.GET"
16376
+ );
15895
16377
  }
15896
16378
  async scheduleFire(id, options = {}) {
15897
- return await this.scheduleStatus("FLOW.SCHEDULE.FIRE", id, options.nowMs);
16379
+ validateScheduleFire(id, options);
16380
+ const args = ["FLOW.SCHEDULE.FIRE", id];
16381
+ append(args, "FIRE_AT_MS", options.fireAtMs);
16382
+ append(args, "NOW", options.nowMs);
16383
+ return scheduleFireResponse(await this.commandArgs(args));
15898
16384
  }
15899
16385
  async schedulePause(id, options = {}) {
15900
- return await this.scheduleStatus("FLOW.SCHEDULE.PAUSE", id, options.nowMs);
16386
+ validateScheduleStatus(id, options.nowMs);
16387
+ return scheduleRecordResponse(
16388
+ await this.scheduleStatusResponse("FLOW.SCHEDULE.PAUSE", id, options.nowMs),
16389
+ "FLOW.SCHEDULE.PAUSE"
16390
+ );
15901
16391
  }
15902
16392
  async scheduleResume(id, options = {}) {
15903
- return await this.scheduleStatus("FLOW.SCHEDULE.RESUME", id, options.nowMs);
16393
+ validateScheduleStatus(id, options.nowMs);
16394
+ return scheduleRecordResponse(
16395
+ await this.scheduleStatusResponse("FLOW.SCHEDULE.RESUME", id, options.nowMs),
16396
+ "FLOW.SCHEDULE.RESUME"
16397
+ );
15904
16398
  }
15905
16399
  async scheduleDelete(id, options = {}) {
15906
- return await this.scheduleStatus("FLOW.SCHEDULE.DELETE", id, options.nowMs);
16400
+ validateScheduleStatus(id, options.nowMs);
16401
+ const response = await this.scheduleStatusResponse("FLOW.SCHEDULE.DELETE", id, options.nowMs);
16402
+ if (!okLike(response)) {
16403
+ throw new TypeError("FLOW.SCHEDULE.DELETE response must be OK");
16404
+ }
15907
16405
  }
15908
16406
  async scheduleFireDue(options = {}) {
16407
+ validateScheduleFireDue(options);
15909
16408
  const args = ["FLOW.SCHEDULE.FIRE_DUE"];
15910
16409
  append(args, "NOW", options.nowMs);
15911
16410
  append(args, "WORKER", options.worker);
16411
+ append(args, "LEASE_MS", options.leaseMs);
15912
16412
  append(args, "BLOCK", options.blockMs);
15913
16413
  append(args, "LIMIT", options.limit);
15914
- return adminRecordResponse(await this.commandArgs(args), "FLOW.SCHEDULE.FIRE_DUE");
16414
+ return scheduleFireDueResponse(await this.commandArgs(args));
15915
16415
  }
15916
16416
  async scheduleList(options = {}) {
16417
+ validateScheduleList(options);
15917
16418
  const args = ["FLOW.SCHEDULE.LIST"];
15918
16419
  append(args, "KIND", options.kind);
15919
16420
  append(args, "STATE", options.state);
@@ -15923,14 +16424,40 @@ var FerricStoreManagementClient = class extends FerricStoreClientCore {
15923
16424
  append(args, "TO_MS", options.toMs);
15924
16425
  append(args, "COUNT", options.count);
15925
16426
  appendBool(args, "REV", options.rev);
15926
- return adminRecordList(await this.commandArgs(args), "FLOW.SCHEDULE.LIST");
16427
+ return scheduleRecordList(await this.commandArgs(args), "FLOW.SCHEDULE.LIST");
15927
16428
  }
15928
- async scheduleStatus(command, id, now) {
16429
+ async scheduleStatusResponse(command, id, now) {
15929
16430
  const args = [command, id];
15930
16431
  append(args, "NOW", now);
15931
- const response = await this.commandArgs(args);
15932
- if (okLike(response)) return { id, status: "deleted" };
15933
- return adminRecordResponse(response, command);
16432
+ return await this.commandArgs(args);
16433
+ }
16434
+ };
16435
+
16436
+ // src/client-management.ts
16437
+ var FerricStoreManagementClient = class extends FerricStoreScheduleClient {
16438
+ async stats(type, options = {}) {
16439
+ const args = ["FLOW.STATS", type];
16440
+ append(args, "STATE", options.state);
16441
+ append(args, "COUNT", options.count);
16442
+ append(args, "PARTITION", options.partitionKey);
16443
+ appendAttributes(args, options.attributes);
16444
+ appendBool(args, "CONSISTENT_PROJECTION", options.consistentProjection);
16445
+ return adminRecordResponse(await this.commandArgs(args), "FLOW.STATS");
16446
+ }
16447
+ async countByState(type, state, options = {}) {
16448
+ const stats = await this.stats(type, { ...options, state });
16449
+ if (!("count" in stats)) throw new TypeError("FLOW.STATS response missing count");
16450
+ return integer(stats.count);
16451
+ }
16452
+ async attributes(type, options = {}) {
16453
+ const args = ["FLOW.ATTRIBUTES", type];
16454
+ appendAttributeQueryOptions(args, options);
16455
+ return adminRecordList(await this.commandArgs(args), "FLOW.ATTRIBUTES");
16456
+ }
16457
+ async attributeValues(type, attribute, options = {}) {
16458
+ const args = ["FLOW.ATTRIBUTE_VALUES", type, attribute];
16459
+ appendAttributeQueryOptions(args, options);
16460
+ return adminRecordList(await this.commandArgs(args), "FLOW.ATTRIBUTE_VALUES");
15934
16461
  }
15935
16462
  async effectReserve(id, effectKey, effectType, options) {
15936
16463
  const args = [
@@ -16268,15 +16795,15 @@ function assertFlowPolicyGeneration(value) {
16268
16795
  function flowPolicySnapshotFromResp(value) {
16269
16796
  const policy = requiredRecord(value, "FLOW policy snapshot");
16270
16797
  const maxActiveMs = optionalPositiveInteger(field(policy, "max_active_ms"), "max_active_ms");
16271
- const state = optionalText3(field(policy, "state"), "state");
16798
+ const state = optionalText4(field(policy, "state"), "state");
16272
16799
  const mode = optionalMode(field(policy, "mode"), "mode");
16273
16800
  const version = optionalVersion(field(policy, "version"));
16274
- const indexedStateMeta = optionalText3(field(policy, "indexed_state_meta"), "indexed_state_meta");
16801
+ const indexedStateMeta = optionalText4(field(policy, "indexed_state_meta"), "indexed_state_meta");
16275
16802
  const governance = optionalRecord(field(policy, "governance"), "governance");
16276
16803
  const states = optionalStates(field(policy, "states"));
16277
16804
  return {
16278
- type: requiredText3(field(policy, "type"), "type"),
16279
- generation: nonNegativeInteger2(field(policy, "generation"), "generation"),
16805
+ type: requiredText4(field(policy, "type"), "type"),
16806
+ generation: nonNegativeInteger3(field(policy, "generation"), "generation"),
16280
16807
  ...state == null ? {} : { state },
16281
16808
  ...version == null ? {} : { version },
16282
16809
  ...mode == null ? {} : { mode },
@@ -16294,21 +16821,21 @@ function retrySnapshot(value, context) {
16294
16821
  const retry2 = requiredRecord(value, `FLOW policy ${context}`);
16295
16822
  const backoff = requiredRecord(field(retry2, "backoff"), `FLOW policy ${context}.backoff`);
16296
16823
  return {
16297
- maxRetries: nonNegativeInteger2(field(retry2, "max_retries"), `${context}.max_retries`),
16824
+ maxRetries: nonNegativeInteger3(field(retry2, "max_retries"), `${context}.max_retries`),
16298
16825
  backoff: {
16299
16826
  kind: backoffKind(field(backoff, "kind"), `${context}.backoff.kind`),
16300
- baseMs: nonNegativeInteger2(field(backoff, "base_ms"), `${context}.backoff.base_ms`),
16301
- maxMs: nonNegativeInteger2(field(backoff, "max_ms"), `${context}.backoff.max_ms`),
16302
- jitterPct: nonNegativeInteger2(field(backoff, "jitter_pct"), `${context}.backoff.jitter_pct`)
16827
+ baseMs: nonNegativeInteger3(field(backoff, "base_ms"), `${context}.backoff.base_ms`),
16828
+ maxMs: nonNegativeInteger3(field(backoff, "max_ms"), `${context}.backoff.max_ms`),
16829
+ jitterPct: nonNegativeInteger3(field(backoff, "jitter_pct"), `${context}.backoff.jitter_pct`)
16303
16830
  },
16304
- exhaustedTo: requiredText3(field(retry2, "exhausted_to"), `${context}.exhausted_to`)
16831
+ exhaustedTo: requiredText4(field(retry2, "exhausted_to"), `${context}.exhausted_to`)
16305
16832
  };
16306
16833
  }
16307
16834
  function retentionSnapshot(value, context) {
16308
16835
  const retention = requiredRecord(value, `FLOW policy ${context}`);
16309
16836
  return {
16310
- ttlMs: nonNegativeInteger2(field(retention, "ttl_ms"), `${context}.ttl_ms`),
16311
- historyMaxEvents: nonNegativeInteger2(
16837
+ ttlMs: nonNegativeInteger3(field(retention, "ttl_ms"), `${context}.ttl_ms`),
16838
+ historyMaxEvents: nonNegativeInteger3(
16312
16839
  field(retention, "history_max_events"),
16313
16840
  `${context}.history_max_events`
16314
16841
  )
@@ -16344,7 +16871,7 @@ function requiredRecord(value, context) {
16344
16871
  if (value instanceof Map) {
16345
16872
  const result = {};
16346
16873
  for (const [key, item] of value.entries()) {
16347
- setOwnValue(result, requiredText3(key, `${context} key`), item);
16874
+ setOwnValue(result, requiredText4(key, `${context} key`), item);
16348
16875
  }
16349
16876
  return result;
16350
16877
  }
@@ -16363,21 +16890,21 @@ function stringArray(value, context) {
16363
16890
  if (!Object.hasOwn(value, index)) {
16364
16891
  throw new TypeError(`FLOW policy ${context} returned an unexpected response`);
16365
16892
  }
16366
- result[index] = requiredText3(value[index], `${context}[${index}]`);
16893
+ result[index] = requiredText4(value[index], `${context}[${index}]`);
16367
16894
  }
16368
16895
  return result;
16369
16896
  }
16370
- function requiredText3(value, context) {
16897
+ function requiredText4(value, context) {
16371
16898
  if (typeof value === "string") return value;
16372
16899
  if (import_node_buffer54.Buffer.isBuffer(value) || value instanceof Uint8Array) {
16373
16900
  return import_node_buffer54.Buffer.from(value).toString("utf8");
16374
16901
  }
16375
16902
  throw new TypeError(`FLOW policy ${context} returned an unexpected response`);
16376
16903
  }
16377
- function optionalText3(value, context) {
16378
- return value == null ? void 0 : requiredText3(value, context);
16904
+ function optionalText4(value, context) {
16905
+ return value == null ? void 0 : requiredText4(value, context);
16379
16906
  }
16380
- function nonNegativeInteger2(value, context) {
16907
+ function nonNegativeInteger3(value, context) {
16381
16908
  let parsed;
16382
16909
  try {
16383
16910
  parsed = integer(value);
@@ -16389,26 +16916,26 @@ function nonNegativeInteger2(value, context) {
16389
16916
  }
16390
16917
  function optionalPositiveInteger(value, context) {
16391
16918
  if (value == null) return void 0;
16392
- const parsed = nonNegativeInteger2(value, context);
16919
+ const parsed = nonNegativeInteger3(value, context);
16393
16920
  if (parsed === 0) throw new TypeError(`FLOW policy ${context} returned an unexpected response`);
16394
16921
  return parsed;
16395
16922
  }
16396
16923
  function optionalVersion(value) {
16397
16924
  if (value == null) return void 0;
16398
16925
  if (typeof value === "number" || typeof value === "bigint") {
16399
- return nonNegativeInteger2(value, "version");
16926
+ return nonNegativeInteger3(value, "version");
16400
16927
  }
16401
- return requiredText3(value, "version");
16928
+ return requiredText4(value, "version");
16402
16929
  }
16403
16930
  function backoffKind(value, context) {
16404
- const kind = requiredText3(value, context).toLowerCase();
16931
+ const kind = requiredText4(value, context).toLowerCase();
16405
16932
  if (kind === "none" || kind === "fixed" || kind === "linear" || kind === "exponential") {
16406
16933
  return kind;
16407
16934
  }
16408
16935
  throw new TypeError(`FLOW policy ${context} returned an unexpected response`);
16409
16936
  }
16410
16937
  function requiredMode(value, context) {
16411
- const mode = requiredText3(value, context).toLowerCase();
16938
+ const mode = requiredText4(value, context).toLowerCase();
16412
16939
  if (mode === "fifo" || mode === "parallel") return mode;
16413
16940
  throw new TypeError(`FLOW policy ${context} returned an unexpected response`);
16414
16941
  }
@@ -17940,7 +18467,7 @@ var LeaseRenewalGuard = class {
17940
18467
  if (options.leaseRenewal === false) {
17941
18468
  return;
17942
18469
  }
17943
- const intervalMs = positiveInteger2(options.leaseRenewIntervalMs, Math.max(1, Math.trunc(leaseMs / 2)));
18470
+ const intervalMs = positiveInteger3(options.leaseRenewIntervalMs, Math.max(1, Math.trunc(leaseMs / 2)));
17944
18471
  this.timer = setLongInterval(() => this.renew(), intervalMs);
17945
18472
  this.timer.unref();
17946
18473
  }
@@ -18012,7 +18539,7 @@ function snapshotLeasedJob(job) {
18012
18539
  return snapshot;
18013
18540
  }
18014
18541
  function workerConcurrency(options) {
18015
- return positiveInteger2(options.concurrency ?? options.workers, 1);
18542
+ return positiveInteger3(options.concurrency ?? options.workers, 1);
18016
18543
  }
18017
18544
  function workerRefillStrategy(options) {
18018
18545
  return options.refillStrategy === "wave" ? "wave" : "continuous";
@@ -18055,18 +18582,18 @@ function workerErrorPayload(error, options, codec) {
18055
18582
  }
18056
18583
  function workerBatchSize(options, flowManyBatchLimit = DEFAULT_FLOW_MANY_BATCH_LIMIT2) {
18057
18584
  return Math.min(
18058
- positiveInteger2(options.batchSize, 10),
18059
- positiveInteger2(flowManyBatchLimit, DEFAULT_FLOW_MANY_BATCH_LIMIT2)
18585
+ positiveInteger3(options.batchSize, 10),
18586
+ positiveInteger3(flowManyBatchLimit, DEFAULT_FLOW_MANY_BATCH_LIMIT2)
18060
18587
  );
18061
18588
  }
18062
18589
  function workerClaimLimit(options, flowManyBatchLimit = DEFAULT_FLOW_MANY_BATCH_LIMIT2) {
18063
18590
  return Math.min(workerBatchSize(options, flowManyBatchLimit), workerConcurrency(options));
18064
18591
  }
18065
18592
  function workerDrainBatches(options) {
18066
- return positiveInteger2(options.claimDrainBatches, 1);
18593
+ return positiveInteger3(options.claimDrainBatches, 1);
18067
18594
  }
18068
18595
  function workerLeaseMs(options, fallback = 3e4) {
18069
- return positiveInteger2(options.leaseMs, positiveInteger2(fallback, 3e4));
18596
+ return positiveInteger3(options.leaseMs, positiveInteger3(fallback, 3e4));
18070
18597
  }
18071
18598
  function workerIdleSleepMs(options) {
18072
18599
  return nonNegativeDuration(options.idleSleepMs, 250);
@@ -18078,7 +18605,7 @@ function workerClaimBlockMs(options, useBlocking) {
18078
18605
  if (options.signal == null || !Number.isFinite(options.blockMs) || options.blockMs < 0) {
18079
18606
  return options.blockMs;
18080
18607
  }
18081
- const abortPollMs = positiveInteger2(options.abortPollMs, 1e3);
18608
+ const abortPollMs = positiveInteger3(options.abortPollMs, 1e3);
18082
18609
  return options.blockMs === 0 ? abortPollMs : Math.min(Math.trunc(options.blockMs), abortPollMs);
18083
18610
  }
18084
18611
  function workerMaxIdleSleepMs(options, idleSleepMs = workerIdleSleepMs(options)) {
@@ -18089,14 +18616,14 @@ function nextWorkerIdleSleepMs(currentIdleSleepMs, maxIdleSleepMs) {
18089
18616
  return Math.min(maxIdleSleepMs, Math.max(1, currentIdleSleepMs * 2));
18090
18617
  }
18091
18618
  async function runContinuousWorkerPool(options) {
18092
- const concurrency = positiveInteger2(options.concurrency, 1);
18093
- const maxClaimSize = positiveInteger2(options.maxClaimSize, concurrency);
18619
+ const concurrency = positiveInteger3(options.concurrency, 1);
18620
+ const maxClaimSize = positiveInteger3(options.maxClaimSize, concurrency);
18094
18621
  const initialIdleSleepMs = nonNegativeDuration(options.idleSleepMs, 250);
18095
18622
  const maxIdleSleepMs = Math.max(
18096
18623
  initialIdleSleepMs,
18097
18624
  nonNegativeDuration(options.maxIdleSleepMs, 5e3)
18098
18625
  );
18099
- const refillDelayMs = nonNegativeInteger3(options.refillDelayMs, 0);
18626
+ const refillDelayMs = nonNegativeInteger4(options.refillDelayMs, 0);
18100
18627
  const active = /* @__PURE__ */ new Set();
18101
18628
  const pending = [];
18102
18629
  let pendingIndex = 0;
@@ -18212,10 +18739,10 @@ function normalizeWorkflowWorkerConfig(options) {
18212
18739
  ...captured
18213
18740
  });
18214
18741
  }
18215
- function positiveInteger2(value, fallback) {
18742
+ function positiveInteger3(value, fallback) {
18216
18743
  return value == null || !Number.isFinite(value) ? fallback : Math.max(1, Math.trunc(value));
18217
18744
  }
18218
- function nonNegativeInteger3(value, fallback) {
18745
+ function nonNegativeInteger4(value, fallback) {
18219
18746
  return value == null || !Number.isFinite(value) ? fallback : Math.max(0, Math.trunc(value));
18220
18747
  }
18221
18748
  function nonNegativeDuration(value, fallback) {
@@ -19099,13 +19626,13 @@ var QueueWorker = class {
19099
19626
 
19100
19627
  // src/flow-client-options.ts
19101
19628
  function snapshotFlowClientOptions(options, context) {
19102
- const own = { ...options };
19103
- if (typeof own.type !== "string" || own.type.length === 0) {
19629
+ const own2 = { ...options };
19630
+ if (typeof own2.type !== "string" || own2.type.length === 0) {
19104
19631
  throw new TypeError(`${context} type must be an own non-empty string`);
19105
19632
  }
19106
- const valueConfig = own.valueConfig;
19633
+ const valueConfig = own2.valueConfig;
19107
19634
  return Object.freeze({
19108
- ...own,
19635
+ ...own2,
19109
19636
  ...valueConfig == null ? {} : { valueConfig: Object.freeze({ ...valueConfig }) }
19110
19637
  });
19111
19638
  }
@@ -19528,19 +20055,19 @@ async function applyFail(client, ctx, outcome, returnRecord) {
19528
20055
 
19529
20056
  // src/workflow-registration.ts
19530
20057
  function createWorkflowStateRegistration(name, handler, options, defaultValueMaxBytes) {
19531
- const own = { ...options };
19532
- const claimValues = own.claimValues == null ? void 0 : snapshotOwnStringArray(own.claimValues, "claimValues");
19533
- const retryPolicy = own.retryPolicy == null ? void 0 : Object.freeze({ ...own.retryPolicy });
20058
+ const own2 = { ...options };
20059
+ const claimValues = own2.claimValues == null ? void 0 : snapshotOwnStringArray(own2.claimValues, "claimValues");
20060
+ const retryPolicy = own2.retryPolicy == null ? void 0 : Object.freeze({ ...own2.retryPolicy });
19534
20061
  return Object.freeze({
19535
- claimPayload: own.claimPayload ?? true,
19536
- claimRecord: own.claimRecord ?? true,
19537
- exceptionPolicy: normalizeExceptionPolicy(own.exceptionPolicy),
20062
+ claimPayload: own2.claimPayload ?? true,
20063
+ claimRecord: own2.claimRecord ?? true,
20064
+ exceptionPolicy: normalizeExceptionPolicy(own2.exceptionPolicy),
19538
20065
  handler,
19539
- leaseMs: own.leaseMs ?? 3e4,
19540
- ...own.mode == null ? {} : { mode: normalizeStateMode(own.mode) },
20066
+ leaseMs: own2.leaseMs ?? 3e4,
20067
+ ...own2.mode == null ? {} : { mode: normalizeStateMode(own2.mode) },
19541
20068
  name,
19542
- returnRecord: own.returnRecord ?? false,
19543
- valueMaxBytes: own.valueMaxBytes ?? defaultValueMaxBytes,
20069
+ returnRecord: own2.returnRecord ?? false,
20070
+ valueMaxBytes: own2.valueMaxBytes ?? defaultValueMaxBytes,
19544
20071
  ...claimValues == null ? {} : { claimValues },
19545
20072
  ...retryPolicy == null ? {} : { retryPolicy }
19546
20073
  });
@@ -19844,8 +20371,8 @@ var WorkflowWorker = class {
19844
20371
  };
19845
20372
 
19846
20373
  // src/version.ts
19847
- var FERRICSTORE_SDK_VERSION = "0.5.2";
19848
- var FERRICSTORE_MINIMUM_SERVER_VERSION = "0.11.0";
20374
+ var FERRICSTORE_SDK_VERSION = "0.11.4";
20375
+ var FERRICSTORE_MINIMUM_SERVER_VERSION = "0.11.4";
19849
20376
  var FERRICSTORE_NATIVE_PROTOCOL_VERSION = 1;
19850
20377
  // Annotate the CommonJS export names for ESM import in node:
19851
20378
  0 && (module.exports = {