@ferricstore/ferricstore 0.2.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (113) hide show
  1. package/README.md +72 -3
  2. package/dist/index.cjs +2618 -554
  3. package/dist/index.cjs.map +1 -1
  4. package/dist/index.d.cts +247 -33
  5. package/dist/index.d.ts +247 -33
  6. package/dist/index.js +2621 -562
  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/ClaimHydrationError.html +5 -5
  12. package/docs/api/classes/ConnectionClosedError.html +5 -5
  13. package/docs/api/classes/FerricStoreClient.html +7 -3
  14. package/docs/api/classes/FerricStoreError.html +5 -5
  15. package/docs/api/classes/FlowAlreadyExistsError.html +5 -5
  16. package/docs/api/classes/FlowBatchError.html +5 -5
  17. package/docs/api/classes/FlowNotFoundError.html +5 -5
  18. package/docs/api/classes/FlowQueryError.html +42 -0
  19. package/docs/api/classes/FlowWrongStateError.html +5 -5
  20. package/docs/api/classes/InvalidCommandError.html +5 -5
  21. package/docs/api/classes/LeaseRenewalError.html +5 -5
  22. package/docs/api/classes/LockHeldError.html +5 -5
  23. package/docs/api/classes/LockNotOwnedError.html +5 -5
  24. package/docs/api/classes/NativeAdapter.html +3 -3
  25. package/docs/api/classes/OverloadedError.html +5 -5
  26. package/docs/api/classes/QueueCompletionError.html +5 -5
  27. package/docs/api/classes/ReconnectingExecutor.html +4 -4
  28. package/docs/api/classes/RequestTimeoutError.html +5 -5
  29. package/docs/api/classes/RerouteError.html +5 -5
  30. package/docs/api/classes/StaleLeaseError.html +5 -5
  31. package/docs/api/classes/StalePolicyGenerationError.html +39 -0
  32. package/docs/api/classes/TopologyNativeAdapterPool.html +3 -3
  33. package/docs/api/classes/Workflow.html +1 -1
  34. package/docs/api/classes/WorkflowWorker.html +2 -2
  35. package/docs/api/functions/classifyServerError.html +1 -1
  36. package/docs/api/functions/isReconnectableClosedConnectionError.html +1 -1
  37. package/docs/api/functions/mapException.html +1 -1
  38. package/docs/api/functions/projectFlowQuery.html +1 -0
  39. package/docs/api/hierarchy.html +1 -1
  40. package/docs/api/index.html +36 -5
  41. package/docs/api/interfaces/AdminListOptions.html +1 -1
  42. package/docs/api/interfaces/CancelOptions.html +2 -2
  43. package/docs/api/interfaces/CompleteOptions.html +2 -2
  44. package/docs/api/interfaces/CompleteOutcome.html +1 -1
  45. package/docs/api/interfaces/CreateManyOptions.html +1 -1
  46. package/docs/api/interfaces/EffectCompensateOptions.html +1 -1
  47. package/docs/api/interfaces/EffectConfirmOptions.html +1 -1
  48. package/docs/api/interfaces/EffectFailOptions.html +1 -1
  49. package/docs/api/interfaces/EffectStatusOptions.html +1 -1
  50. package/docs/api/interfaces/ExtendLeaseOptions.html +2 -2
  51. package/docs/api/interfaces/FailOptions.html +2 -2
  52. package/docs/api/interfaces/FailOutcome.html +1 -1
  53. package/docs/api/interfaces/FerricStoreClientFromUrlOptions.html +1 -1
  54. package/docs/api/interfaces/FerricStoreClientOptions.html +1 -1
  55. package/docs/api/interfaces/FlowEventProjectionField.html +4 -0
  56. package/docs/api/interfaces/FlowExplainResult.html +10 -0
  57. package/docs/api/interfaces/FlowPolicyBackoffSnapshot.html +5 -0
  58. package/docs/api/interfaces/FlowPolicyOptions.html +8 -4
  59. package/docs/api/interfaces/FlowPolicyRetentionSnapshot.html +3 -0
  60. package/docs/api/interfaces/FlowPolicyRetrySnapshot.html +4 -0
  61. package/docs/api/interfaces/FlowPolicySnapshot.html +17 -0
  62. package/docs/api/interfaces/FlowPolicyStateSnapshot.html +6 -0
  63. package/docs/api/interfaces/FlowQueryCountResult.html +7 -0
  64. package/docs/api/interfaces/FlowQueryErrorPosition.html +4 -0
  65. package/docs/api/interfaces/FlowQueryIndex.html +9 -0
  66. package/docs/api/interfaces/FlowQueryIndexFormat.html +7 -0
  67. package/docs/api/interfaces/FlowQueryIndexRegistry.html +3 -0
  68. package/docs/api/interfaces/FlowQueryIndexStatus.html +8 -0
  69. package/docs/api/interfaces/FlowQueryPage.html +3 -0
  70. package/docs/api/interfaces/FlowQueryQuality.html +5 -0
  71. package/docs/api/interfaces/FlowQueryRecordsResult.html +8 -0
  72. package/docs/api/interfaces/FlowQueryUsage.html +12 -0
  73. package/docs/api/interfaces/FlowRunProjectionField.html +4 -0
  74. package/docs/api/interfaces/HistoryOptions.html +2 -2
  75. package/docs/api/interfaces/InvocationCreateOptions.html +2 -2
  76. package/docs/api/interfaces/LeaseMutationOptions.html +2 -2
  77. package/docs/api/interfaces/LimitListOptions.html +1 -1
  78. package/docs/api/interfaces/MutateOptions.html +2 -2
  79. package/docs/api/interfaces/NamedValueMutation.html +1 -1
  80. package/docs/api/interfaces/ProtocolCommand.html +2 -2
  81. package/docs/api/interfaces/ReadOptions.html +5 -3
  82. package/docs/api/interfaces/ReclaimOptions.html +1 -1
  83. package/docs/api/interfaces/RequestContext.html +2 -2
  84. package/docs/api/interfaces/RequestContextOptions.html +2 -2
  85. package/docs/api/interfaces/RetryOptions.html +2 -2
  86. package/docs/api/interfaces/RetryOutcome.html +1 -1
  87. package/docs/api/interfaces/RunStepsItem.html +2 -2
  88. package/docs/api/interfaces/RunStepsManyOptions.html +2 -2
  89. package/docs/api/interfaces/SearchOptions.html +4 -3
  90. package/docs/api/interfaces/StepContinueOptions.html +3 -3
  91. package/docs/api/interfaces/TDigestCreateOptions.html +1 -1
  92. package/docs/api/interfaces/TDigestMergeOptions.html +1 -1
  93. package/docs/api/interfaces/TransitionOptions.html +2 -2
  94. package/docs/api/interfaces/TransitionOutcome.html +1 -1
  95. package/docs/api/modules.html +1 -1
  96. package/docs/api/types/ConnectionRequestDisposition.html +1 -1
  97. package/docs/api/types/FlowPolicyBackoffKind.html +1 -0
  98. package/docs/api/types/FlowProjectionField.html +1 -0
  99. package/docs/api/types/FlowProjectionShape.html +1 -0
  100. package/docs/api/types/FlowQueryInteger.html +1 -0
  101. package/docs/api/types/FlowQueryParameter.html +1 -0
  102. package/docs/api/types/FlowQueryParameters.html +1 -0
  103. package/docs/api/types/FlowQueryRecord.html +1 -0
  104. package/docs/api/types/FlowQueryResult.html +1 -0
  105. package/docs/api/types/ManagementPairs.html +1 -1
  106. package/docs/api/types/SearchStateMeta.html +1 -1
  107. package/docs/api/variables/COMMAND_OPCODES.html +1 -1
  108. package/docs/api/variables/FERRICSTORE_MINIMUM_SERVER_VERSION.html +1 -1
  109. package/docs/api/variables/FERRICSTORE_NATIVE_PROTOCOL_VERSION.html +1 -1
  110. package/docs/api/variables/FERRICSTORE_SDK_VERSION.html +1 -1
  111. package/docs/api/variables/FlowProjection.html +1 -0
  112. package/docs/api/variables/MAX_FLOW_POLICY_GENERATION.html +1 -0
  113. package/package.json +4 -3
package/README.md CHANGED
@@ -18,7 +18,7 @@ Requires Node.js 22.22 or newer. The SDK ships ESM and CommonJS builds and is te
18
18
 
19
19
  ## Compatibility
20
20
 
21
- SDK `0.2.x` requires FerricStore server `0.8.0` or newer. FerricStore 0.8 is a
21
+ SDK `0.5.x` requires FerricStore server `0.11.0` or newer. FerricStore 0.11 is a
22
22
  breaking beta API contract update, while the native wire protocol remains v1
23
23
  (`FSNP` framing and existing opcode numbers are unchanged). Capabilities and
24
24
  response-size limits are negotiated per connection from the HELLO-shaped
@@ -42,7 +42,50 @@ const { FerricStoreClient, JsonCodec } = require("@ferricstore/ferricstore");
42
42
  docker run -p 6388:6388 \
43
43
  -e FERRICSTORE_PROTECTED_MODE=false \
44
44
  -v ferricstore_data:/data \
45
- ghcr.io/ferricstore/ferricstore:0.8.0
45
+ ghcr.io/ferricstore/ferricstore:0.11.0
46
+ ```
47
+
48
+ ## Query durable runs
49
+
50
+ Use parameterized FQL for bounded, partition-scoped reads. Cursors are opaque
51
+ and must be reused with the same query and parameters.
52
+
53
+ ```ts
54
+ const client = await FerricStoreClient.fromUrl("ferric://127.0.0.1:6388");
55
+ const query = `FROM runs
56
+ WHERE partition_key = @partition AND type = @type AND state = @state
57
+ ORDER BY updated_at_ms ASC LIMIT 25 RETURN RECORDS`;
58
+ const params = { partition: "partition-a", type: "invoice", state: "queued" };
59
+
60
+ const result = await client.query(query, params);
61
+ const plan = await client.explain(query, params);
62
+ const indexes = await client.queryIndexes();
63
+ ```
64
+
65
+ Each index reports `coveringFields`, which identifies the built-in and dynamic
66
+ `attribute.*` or `state_meta.*` fields that it can return without record
67
+ hydration. Its `format` values are opaque storage-generation identifiers; use
68
+ them to detect a rebuild requirement, not to decode server storage. The
69
+ `counter` format is absent for indexes without counters.
70
+
71
+ Select a sparse result map by adding up to 32 source-specific fields after
72
+ `RETURN RECORD` or `RETURN RECORDS`, for example
73
+ `RETURN RECORDS (run_id, state, attribute['customer'])`. A bare return keeps the
74
+ complete public record. Projection runs after authorization, authoritative
75
+ recheck, ordering, and cursor calculation: it reduces retained result data,
76
+ encoding, network, and client decoding work, but not index scans or hydration.
77
+
78
+ Use the source-aware builder to avoid hand-quoting result selectors:
79
+
80
+ ```ts
81
+ const projected = projectFlowQuery(
82
+ "FROM runs WHERE partition_key = @partition AND run_id = @run",
83
+ "record",
84
+ FlowProjection.run.id,
85
+ FlowProjection.run.state,
86
+ FlowProjection.run.attribute("customer")
87
+ );
88
+ const result = await client.query(projected, { partition: "partition-a", run: "run-1" });
46
89
  ```
47
90
 
48
91
  ## Cluster-aware client
@@ -387,12 +430,25 @@ await flow.scheduleCreate("orders-every-five-minutes", {
387
430
  FIFO Flow state policy is opt-in per state:
388
431
 
389
432
  ```ts
390
- await flow.installPolicy("email", {
433
+ const policy = await flow.installPolicy("email", {
391
434
  states: {
392
435
  queued: { mode: "fifo" }
393
436
  }
394
437
  });
395
438
 
439
+ // Direct writes deep-patch by default. Fence concurrent editors with generation CAS.
440
+ const updated = await flow.installPolicy("email", {
441
+ expectedGeneration: policy.generation,
442
+ maxActiveMs: 300_000
443
+ });
444
+
445
+ // Full replacement is explicit on the client API.
446
+ await flow.installPolicy("email", {
447
+ expectedGeneration: updated.generation,
448
+ replace: true,
449
+ states: { queued: { mode: "fifo" } }
450
+ });
451
+
396
452
  await flow.create("email-3", {
397
453
  partitionKey: "tenant-a:email",
398
454
  payload: Buffer.from("welcome"),
@@ -402,6 +458,10 @@ await flow.create("email-3", {
402
458
  ```
403
459
 
404
460
  FIFO states require a `partitionKey`; priority is for parallel states.
461
+ `Workflow.installPolicy()` defaults to full replacement because workflow declarations
462
+ describe a complete policy. Pass `replace: false` when a workflow install should patch.
463
+ FIFO ordering is enforced by the server per `(type, state, partitionKey)`; worker
464
+ concurrency remains available across different partitions.
405
465
 
406
466
  ## FerricStore KV And Data Structures
407
467
 
@@ -533,6 +593,15 @@ FERRICSTORE_INTEGRATION=1 npm run test:integration
533
593
  npm run integration:down
534
594
  ```
535
595
 
596
+ Benchmark raw FQL and the record convenience layer against a live server. The default
597
+ comparison interleaves both paths and fails if either performs more than one `FLOW.QUERY`
598
+ or any `FLOW.GET` hydration per operation:
599
+
600
+ ```bash
601
+ npm run build
602
+ npm run bench:flow-query -- --requests 500 --concurrency 2 --rows 100 --pretty
603
+ ```
604
+
536
605
  Generate API docs with:
537
606
 
538
607
  ```bash