@lunora/do 1.0.0-alpha.12 → 1.0.0-alpha.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -5045,10 +5045,22 @@ declare abstract class ShardDO {
5045
5045
  */
5046
5046
  protected respondFromIdempotencyCache(functionPath: string, dispatchStartedAt: number, mutatorClass: ClientMutationClass | undefined, cachedValue: unknown): Response;
5047
5047
  /**
5048
+ * The CDC cursor a just-committed plain mutation landed at — the post-write
5049
+ * high-watermark, on the same scale as the `cursor` on `data`/`delta` frames.
5050
+ * The client drops a pending per-call optimistic overlay once it sees a frame
5051
+ * with `cursor >= commitCursor` (gapless reconciliation that keeps mutations
5052
+ * concurrent, without the serialized custom-mutator watermark). Scoped to a
5053
+ * mutation (carries an `x-lunora-mutation-id`) on a CDC-enabled shard;
5054
+ * `undefined` otherwise, leaving the wire byte-identical for queries/actions
5055
+ * and CDC-off shards.
5056
+ */
5057
+ protected mutationCommitCursor(): number | undefined;
5058
+ /**
5048
5059
  * Build the success response for a dispatched RPC. A `"next"` custom-mutator
5049
5060
  * push echoes the applied `lastMutationId` so the client drops the pending
5050
- * optimistic overlay as soon as the ack lands; ordinary calls return the bare
5051
- * `{ result }` envelope unchanged.
5061
+ * optimistic overlay as soon as the ack lands; a plain mutation echoes
5062
+ * `commitCursor` (see {@link mutationCommitCursor}); other calls return the
5063
+ * bare `{ result }` envelope unchanged.
5052
5064
  */
5053
5065
  protected buildDispatchResponse(mutatorClass: ClientMutationClass | undefined, result: unknown): Response;
5054
5066
  /**
package/dist/index.d.ts CHANGED
@@ -5045,10 +5045,22 @@ declare abstract class ShardDO {
5045
5045
  */
5046
5046
  protected respondFromIdempotencyCache(functionPath: string, dispatchStartedAt: number, mutatorClass: ClientMutationClass | undefined, cachedValue: unknown): Response;
5047
5047
  /**
5048
+ * The CDC cursor a just-committed plain mutation landed at — the post-write
5049
+ * high-watermark, on the same scale as the `cursor` on `data`/`delta` frames.
5050
+ * The client drops a pending per-call optimistic overlay once it sees a frame
5051
+ * with `cursor >= commitCursor` (gapless reconciliation that keeps mutations
5052
+ * concurrent, without the serialized custom-mutator watermark). Scoped to a
5053
+ * mutation (carries an `x-lunora-mutation-id`) on a CDC-enabled shard;
5054
+ * `undefined` otherwise, leaving the wire byte-identical for queries/actions
5055
+ * and CDC-off shards.
5056
+ */
5057
+ protected mutationCommitCursor(): number | undefined;
5058
+ /**
5048
5059
  * Build the success response for a dispatched RPC. A `"next"` custom-mutator
5049
5060
  * push echoes the applied `lastMutationId` so the client drops the pending
5050
- * optimistic overlay as soon as the ack lands; ordinary calls return the bare
5051
- * `{ result }` envelope unchanged.
5061
+ * optimistic overlay as soon as the ack lands; a plain mutation echoes
5062
+ * `commitCursor` (see {@link mutationCommitCursor}); other calls return the
5063
+ * bare `{ result }` envelope unchanged.
5052
5064
  */
5053
5065
  protected buildDispatchResponse(mutatorClass: ClientMutationClass | undefined, result: unknown): Response;
5054
5066
  /**
package/dist/index.mjs CHANGED
@@ -23,7 +23,7 @@ export { RLS_UNWRAP_SYMBOL, RlsRequiredError, guardWriter } from './packem_share
23
23
  export { buildFtsMatch, ftsTableName, scoreDocument, stringifySearchText, tokenizeSearch } from './packem_shared/buildFtsMatch-BLEMawrp.mjs';
24
24
  export { M as MIN_ADMIN_TOKEN_LENGTH, a as MIN_AUTH_SECRET_LENGTH, b as buildSecurityAudit } from './packem_shared/security-audit-CucgBice.mjs';
25
25
  export { SESSION_DO_TTL_DEFAULT, SessionDO } from './packem_shared/SESSION_DO_TTL_DEFAULT-ilPZsVwu.mjs';
26
- export { ROOT_DO_SIZE_WARN_BYTES, ROOT_SHARD_NAME, ShardDO } from './packem_shared/ROOT_DO_SIZE_WARN_BYTES-CM5_hVnA.mjs';
26
+ export { ROOT_DO_SIZE_WARN_BYTES, ROOT_SHARD_NAME, ShardDO } from './packem_shared/ROOT_DO_SIZE_WARN_BYTES-XEs4csIH.mjs';
27
27
  export { SHARD_REGISTRY_DO_NAME, ShardRegistryDO } from './packem_shared/SHARD_REGISTRY_DO_NAME-BsAbi5Mn.mjs';
28
28
  export { MAX_SQL_ROWS, assertReadonly, runReadonlySql } from './packem_shared/MAX_SQL_ROWS-dDcFE1YZ.mjs';
29
29
  export { createSystemReader } from './packem_shared/createSystemReader-8CzSZP9V.mjs';
@@ -2426,19 +2426,35 @@ class ShardDO {
2426
2426
  this.advanceClientMutationWatermark();
2427
2427
  return this.buildDispatchResponse(mutatorClass, cachedValue);
2428
2428
  }
2429
- return jsonResponse({ result: cachedValue }, 200, this.currentResponseBookmark);
2429
+ const commitCursor = this.mutationCommitCursor();
2430
+ return jsonResponse(commitCursor === void 0 ? { result: cachedValue } : { commitCursor, result: cachedValue }, 200, this.currentResponseBookmark);
2431
+ }
2432
+ /**
2433
+ * The CDC cursor a just-committed plain mutation landed at — the post-write
2434
+ * high-watermark, on the same scale as the `cursor` on `data`/`delta` frames.
2435
+ * The client drops a pending per-call optimistic overlay once it sees a frame
2436
+ * with `cursor >= commitCursor` (gapless reconciliation that keeps mutations
2437
+ * concurrent, without the serialized custom-mutator watermark). Scoped to a
2438
+ * mutation (carries an `x-lunora-mutation-id`) on a CDC-enabled shard;
2439
+ * `undefined` otherwise, leaving the wire byte-identical for queries/actions
2440
+ * and CDC-off shards.
2441
+ */
2442
+ mutationCommitCursor() {
2443
+ return this.currentRequestMutationId === void 0 ? void 0 : this.currentCdcCursor();
2430
2444
  }
2431
2445
  /**
2432
2446
  * Build the success response for a dispatched RPC. A `"next"` custom-mutator
2433
2447
  * push echoes the applied `lastMutationId` so the client drops the pending
2434
- * optimistic overlay as soon as the ack lands; ordinary calls return the bare
2435
- * `{ result }` envelope unchanged.
2448
+ * optimistic overlay as soon as the ack lands; a plain mutation echoes
2449
+ * `commitCursor` (see {@link mutationCommitCursor}); other calls return the
2450
+ * bare `{ result }` envelope unchanged.
2436
2451
  */
2437
2452
  buildDispatchResponse(mutatorClass, result) {
2438
2453
  if (mutatorClass?.kind === "next") {
2439
2454
  return jsonResponse({ lastMutationId: this.currentRequestClientSeq, result }, 200, this.currentResponseBookmark);
2440
2455
  }
2441
- return jsonResponse({ result }, 200, this.currentResponseBookmark);
2456
+ const commitCursor = this.mutationCommitCursor();
2457
+ return jsonResponse(commitCursor === void 0 ? { result } : { commitCursor, result }, 200, this.currentResponseBookmark);
2442
2458
  }
2443
2459
  /**
2444
2460
  * Commit a mutation's replay bookkeeping — the `(identity, mutationId)`
@@ -4844,9 +4860,8 @@ class ShardDO {
4844
4860
  if (existing?.lastJson === json) {
4845
4861
  existing.tables = outcome.tables;
4846
4862
  const settledWatermark = this.socketClientWatermark(ws);
4847
- if (settledWatermark !== void 0) {
4848
- trySendFrame(ws, `{"type":"settled","id":${JSON.stringify(subId)},"lastMutationId":${String(settledWatermark)}${cursorSuffix}}`);
4849
- }
4863
+ const watermarkField = settledWatermark === void 0 ? "" : `,"lastMutationId":${String(settledWatermark)}`;
4864
+ trySendFrame(ws, `{"type":"settled","id":${JSON.stringify(subId)}${watermarkField}${cursorSuffix}}`);
4850
4865
  return;
4851
4866
  }
4852
4867
  const deltaFrames = [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lunora/do",
3
- "version": "1.0.0-alpha.12",
3
+ "version": "1.0.0-alpha.13",
4
4
  "description": "Lunora Durable Objects: ShardDO (SQLite, OCC, hibernated WebSocket subscriptions) and SessionDO",
5
5
  "keywords": [
6
6
  "cloudflare",