@lunora/do 1.0.0-alpha.285 → 1.0.0-alpha.287
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md
CHANGED
|
@@ -87,7 +87,15 @@ instead, and so does every non-JS SDK — their `subscribe` methods do not expos
|
|
|
87
87
|
the field at all. So no client shipped here reaches a delta stamped with a real
|
|
88
88
|
table name; addressing one means building the subscribe frame by hand. Projects
|
|
89
89
|
generated by `lunora codegen` route this hook to `recordChangedTable` and get
|
|
90
|
-
server-side re-execution instead, which is the path to prefer.
|
|
90
|
+
server-side re-execution instead, which is the path to prefer. A subscription the shard
|
|
91
|
+
serves by re-execution never receives a broadcast (the shard logs a one-time warning if one
|
|
92
|
+
matched). On a shard that overrides `executeSubscription`, that is every function-path
|
|
93
|
+
subscription except one whose seed returned `null`; the choice is made per subscription, kept in
|
|
94
|
+
the socket attachment, and fails closed while the seed is in flight. Refuse a subscriber by
|
|
95
|
+
throwing, never by returning `null`, which opts it into the raw rows described next.
|
|
96
|
+
The broadcast row is the written row: it is not filtered by row-level security, column masks
|
|
97
|
+
or the subscriber's query, so filter in `matchesSubscription` or do not broadcast data an
|
|
98
|
+
anonymous socket may not see.
|
|
91
99
|
|
|
92
100
|
> This README covers the basics. For the full API, options, and guides, see the **[documentation](https://lunora.sh/docs/api/do)**.
|
|
93
101
|
|
package/dist/index.d.mts
CHANGED
|
@@ -1798,6 +1798,8 @@ declare abstract class ShardDO {
|
|
|
1798
1798
|
* stays near a limit warns again after a wake.
|
|
1799
1799
|
*/
|
|
1800
1800
|
private readonly rerunNearLimitWarned;
|
|
1801
|
+
/** One-shot warning for subscriptions `broadcastDelta` skips because re-execution serves them. */
|
|
1802
|
+
private broadcastSkipWarned;
|
|
1801
1803
|
/**
|
|
1802
1804
|
* Client-issued idempotency key for the in-flight mutation, forwarded via the
|
|
1803
1805
|
* `x-lunora-mutation-id` header. When set, the dispatch path dedups the call
|
|
@@ -3727,8 +3729,11 @@ declare abstract class ShardDO {
|
|
|
3727
3729
|
protected matchesSubscription(query: SubscriptionQuery, delta: MutationDelta): boolean;
|
|
3728
3730
|
/**
|
|
3729
3731
|
* Broadcast a mutation delta to every subscriber whose registered query
|
|
3730
|
-
* targets the affected table _and_ matches its args.
|
|
3731
|
-
*
|
|
3732
|
+
* targets the affected table _and_ matches its args. Subscriptions this
|
|
3733
|
+
* shard serves by re-execution (see `servedByReexecution`) are skipped: the
|
|
3734
|
+
* row sent is the written row, not filtered by RLS, masks or the
|
|
3735
|
+
* subscriber's query, and `matchesSubscription` is its only filter. The wire
|
|
3736
|
+
* payload includes the per-socket subscription id, so we serialise once per
|
|
3732
3737
|
* `(socket, sub)` pair — but the structural delta body itself is
|
|
3733
3738
|
* identical, so we build a payload keyed by `subId` lazily.
|
|
3734
3739
|
*/
|
|
@@ -3738,8 +3743,11 @@ declare abstract class ShardDO {
|
|
|
3738
3743
|
* the set of tables it read. The base class can't dispatch user functions,
|
|
3739
3744
|
* so it returns `null` — the codegen-generated subclass overrides this to
|
|
3740
3745
|
* run the handler from the project's function registry. Returning `null`
|
|
3741
|
-
* disables server re-execution
|
|
3742
|
-
* path as
|
|
3746
|
+
* from the seed disables server re-execution for that subscription and
|
|
3747
|
+
* leaves the legacy `broadcastDelta` path as its only live-update
|
|
3748
|
+
* mechanism; a subscription whose seed returned a result never receives a
|
|
3749
|
+
* broadcast. Refuse a subscriber by throwing, never by returning `null`:
|
|
3750
|
+
* `null` opts the subscription into raw, unfiltered broadcast rows.
|
|
3743
3751
|
*
|
|
3744
3752
|
* `identity` is the EXPLICIT subscriber context the query runs under —
|
|
3745
3753
|
* identity claims, userId, and the socket's own `ip`. It is passed by value
|
|
@@ -4502,6 +4510,34 @@ declare abstract class ShardDO {
|
|
|
4502
4510
|
* as this request's. The dispatch path re-pins its own afterwards.
|
|
4503
4511
|
*/
|
|
4504
4512
|
protected restoreRequestScope(scope: RequestScope): void;
|
|
4513
|
+
/**
|
|
4514
|
+
* Whether a subscription gets its updates by re-execution, which diffs the
|
|
4515
|
+
* query's own result. A broadcast row would bypass that diff baseline (no
|
|
4516
|
+
* later delta removes it) and the subscriber's RLS, masks and query filter,
|
|
4517
|
+
* so `broadcastDelta` must not reach such a subscription.
|
|
4518
|
+
*
|
|
4519
|
+
* Decided per subscription. On a shard that overrides `executeSubscription`,
|
|
4520
|
+
* only a subscription whose seed resolved to `null` (recorded in
|
|
4521
|
+
* `broadcastSubs`) and that has no diff baseline is left to broadcast. Fails
|
|
4522
|
+
* closed: a seed still in flight, one that threw (an auth refusal unsubscribes
|
|
4523
|
+
* it), and one that returned a result are all served by re-execution.
|
|
4524
|
+
* @returns `true` when the shard re-runs this subscription's query
|
|
4525
|
+
*/
|
|
4526
|
+
private servedByReexecution;
|
|
4527
|
+
/**
|
|
4528
|
+
* `broadcastDelta`'s skip for a subscription the shard re-runs, logging the
|
|
4529
|
+
* one-time warning the first time it fires.
|
|
4530
|
+
* @returns `true` when `broadcastDelta` must not send this subscription the delta
|
|
4531
|
+
*/
|
|
4532
|
+
private skipsForReexecution;
|
|
4533
|
+
/**
|
|
4534
|
+
* Record that `subId`'s seed resolved to `null` through an overridden
|
|
4535
|
+
* `executeSubscription`, which leaves it to `broadcastDelta`. Skipped while
|
|
4536
|
+
* the subscription is gone or now names another function, so a seed that
|
|
4537
|
+
* outlived its subscription cannot mark the one that replaced it.
|
|
4538
|
+
*/
|
|
4539
|
+
private markBroadcastSubscription;
|
|
4540
|
+
private unmarkBroadcastSubscription;
|
|
4505
4541
|
private deliveryRoleSupported;
|
|
4506
4542
|
private revokeSubscription;
|
|
4507
4543
|
private sendFrame;
|
|
@@ -5859,6 +5895,13 @@ declare abstract class ShardDO {
|
|
|
5859
5895
|
private recordSubscriptionRefreshError;
|
|
5860
5896
|
/** The caller identity a failing subscription is latched under; `""` (matching nothing) when the socket has no failure streak to look up. */
|
|
5861
5897
|
private failureIdentityKey;
|
|
5898
|
+
/** A same-args re-subscribe is the client's retry at the hint and keeps the streak; new args start afresh. */
|
|
5899
|
+
private restartFailureStreakUnlessRetry;
|
|
5900
|
+
/**
|
|
5901
|
+
* A failure no retry can change: an access denial (revoked), a result past the size cap, and on a guarded socket a
|
|
5902
|
+
* persist failure. A subscription hitting one ends rather than latching for backoff.
|
|
5903
|
+
*/
|
|
5904
|
+
private isDeterministicSubscriptionFailure;
|
|
5862
5905
|
/**
|
|
5863
5906
|
* A subscription's refresh threw: count and log it, latch it for backoff, and
|
|
5864
5907
|
* tell the client the first time of a streak. The subscription stays
|
|
@@ -5876,6 +5919,8 @@ declare abstract class ShardDO {
|
|
|
5876
5919
|
* subscriber advances to.
|
|
5877
5920
|
*/
|
|
5878
5921
|
private refreshSubscriptions;
|
|
5922
|
+
/** A retried seed that failed again: the subscription stays registered and is answered with the next hint. */
|
|
5923
|
+
private retryFailedSeed;
|
|
5879
5924
|
/**
|
|
5880
5925
|
* Run {@link ShardDO.seedSubscription} and fail the ONE subscription — never
|
|
5881
5926
|
* the socket — when its handler throws.
|
|
@@ -5891,7 +5936,10 @@ declare abstract class ShardDO {
|
|
|
5891
5936
|
* spins at the initial delay for the life of the page.
|
|
5892
5937
|
*
|
|
5893
5938
|
* So: drop the just-registered subscription from the attachment and answer
|
|
5894
|
-
* with a structured `error` frame carrying the thrown error's code.
|
|
5939
|
+
* with a structured `error` frame carrying the thrown error's code. The one
|
|
5940
|
+
* exception is a retry on an unguarded socket: a same-args re-subscribe of an
|
|
5941
|
+
* already-registered subscription stays registered and is answered with the
|
|
5942
|
+
* next retry hint (see {@link ShardDO.retryFailedSeed}). Mirrors
|
|
5895
5943
|
* `refreshSubscriptions`' per-`(socket, sub)` catch on the write-flush half
|
|
5896
5944
|
* of the same path, and `handleShapeSubscribe`'s rollback-then-error on a
|
|
5897
5945
|
* failed shape seed.
|
package/dist/index.d.ts
CHANGED
|
@@ -1798,6 +1798,8 @@ declare abstract class ShardDO {
|
|
|
1798
1798
|
* stays near a limit warns again after a wake.
|
|
1799
1799
|
*/
|
|
1800
1800
|
private readonly rerunNearLimitWarned;
|
|
1801
|
+
/** One-shot warning for subscriptions `broadcastDelta` skips because re-execution serves them. */
|
|
1802
|
+
private broadcastSkipWarned;
|
|
1801
1803
|
/**
|
|
1802
1804
|
* Client-issued idempotency key for the in-flight mutation, forwarded via the
|
|
1803
1805
|
* `x-lunora-mutation-id` header. When set, the dispatch path dedups the call
|
|
@@ -3727,8 +3729,11 @@ declare abstract class ShardDO {
|
|
|
3727
3729
|
protected matchesSubscription(query: SubscriptionQuery, delta: MutationDelta): boolean;
|
|
3728
3730
|
/**
|
|
3729
3731
|
* Broadcast a mutation delta to every subscriber whose registered query
|
|
3730
|
-
* targets the affected table _and_ matches its args.
|
|
3731
|
-
*
|
|
3732
|
+
* targets the affected table _and_ matches its args. Subscriptions this
|
|
3733
|
+
* shard serves by re-execution (see `servedByReexecution`) are skipped: the
|
|
3734
|
+
* row sent is the written row, not filtered by RLS, masks or the
|
|
3735
|
+
* subscriber's query, and `matchesSubscription` is its only filter. The wire
|
|
3736
|
+
* payload includes the per-socket subscription id, so we serialise once per
|
|
3732
3737
|
* `(socket, sub)` pair — but the structural delta body itself is
|
|
3733
3738
|
* identical, so we build a payload keyed by `subId` lazily.
|
|
3734
3739
|
*/
|
|
@@ -3738,8 +3743,11 @@ declare abstract class ShardDO {
|
|
|
3738
3743
|
* the set of tables it read. The base class can't dispatch user functions,
|
|
3739
3744
|
* so it returns `null` — the codegen-generated subclass overrides this to
|
|
3740
3745
|
* run the handler from the project's function registry. Returning `null`
|
|
3741
|
-
* disables server re-execution
|
|
3742
|
-
* path as
|
|
3746
|
+
* from the seed disables server re-execution for that subscription and
|
|
3747
|
+
* leaves the legacy `broadcastDelta` path as its only live-update
|
|
3748
|
+
* mechanism; a subscription whose seed returned a result never receives a
|
|
3749
|
+
* broadcast. Refuse a subscriber by throwing, never by returning `null`:
|
|
3750
|
+
* `null` opts the subscription into raw, unfiltered broadcast rows.
|
|
3743
3751
|
*
|
|
3744
3752
|
* `identity` is the EXPLICIT subscriber context the query runs under —
|
|
3745
3753
|
* identity claims, userId, and the socket's own `ip`. It is passed by value
|
|
@@ -4502,6 +4510,34 @@ declare abstract class ShardDO {
|
|
|
4502
4510
|
* as this request's. The dispatch path re-pins its own afterwards.
|
|
4503
4511
|
*/
|
|
4504
4512
|
protected restoreRequestScope(scope: RequestScope): void;
|
|
4513
|
+
/**
|
|
4514
|
+
* Whether a subscription gets its updates by re-execution, which diffs the
|
|
4515
|
+
* query's own result. A broadcast row would bypass that diff baseline (no
|
|
4516
|
+
* later delta removes it) and the subscriber's RLS, masks and query filter,
|
|
4517
|
+
* so `broadcastDelta` must not reach such a subscription.
|
|
4518
|
+
*
|
|
4519
|
+
* Decided per subscription. On a shard that overrides `executeSubscription`,
|
|
4520
|
+
* only a subscription whose seed resolved to `null` (recorded in
|
|
4521
|
+
* `broadcastSubs`) and that has no diff baseline is left to broadcast. Fails
|
|
4522
|
+
* closed: a seed still in flight, one that threw (an auth refusal unsubscribes
|
|
4523
|
+
* it), and one that returned a result are all served by re-execution.
|
|
4524
|
+
* @returns `true` when the shard re-runs this subscription's query
|
|
4525
|
+
*/
|
|
4526
|
+
private servedByReexecution;
|
|
4527
|
+
/**
|
|
4528
|
+
* `broadcastDelta`'s skip for a subscription the shard re-runs, logging the
|
|
4529
|
+
* one-time warning the first time it fires.
|
|
4530
|
+
* @returns `true` when `broadcastDelta` must not send this subscription the delta
|
|
4531
|
+
*/
|
|
4532
|
+
private skipsForReexecution;
|
|
4533
|
+
/**
|
|
4534
|
+
* Record that `subId`'s seed resolved to `null` through an overridden
|
|
4535
|
+
* `executeSubscription`, which leaves it to `broadcastDelta`. Skipped while
|
|
4536
|
+
* the subscription is gone or now names another function, so a seed that
|
|
4537
|
+
* outlived its subscription cannot mark the one that replaced it.
|
|
4538
|
+
*/
|
|
4539
|
+
private markBroadcastSubscription;
|
|
4540
|
+
private unmarkBroadcastSubscription;
|
|
4505
4541
|
private deliveryRoleSupported;
|
|
4506
4542
|
private revokeSubscription;
|
|
4507
4543
|
private sendFrame;
|
|
@@ -5859,6 +5895,13 @@ declare abstract class ShardDO {
|
|
|
5859
5895
|
private recordSubscriptionRefreshError;
|
|
5860
5896
|
/** The caller identity a failing subscription is latched under; `""` (matching nothing) when the socket has no failure streak to look up. */
|
|
5861
5897
|
private failureIdentityKey;
|
|
5898
|
+
/** A same-args re-subscribe is the client's retry at the hint and keeps the streak; new args start afresh. */
|
|
5899
|
+
private restartFailureStreakUnlessRetry;
|
|
5900
|
+
/**
|
|
5901
|
+
* A failure no retry can change: an access denial (revoked), a result past the size cap, and on a guarded socket a
|
|
5902
|
+
* persist failure. A subscription hitting one ends rather than latching for backoff.
|
|
5903
|
+
*/
|
|
5904
|
+
private isDeterministicSubscriptionFailure;
|
|
5862
5905
|
/**
|
|
5863
5906
|
* A subscription's refresh threw: count and log it, latch it for backoff, and
|
|
5864
5907
|
* tell the client the first time of a streak. The subscription stays
|
|
@@ -5876,6 +5919,8 @@ declare abstract class ShardDO {
|
|
|
5876
5919
|
* subscriber advances to.
|
|
5877
5920
|
*/
|
|
5878
5921
|
private refreshSubscriptions;
|
|
5922
|
+
/** A retried seed that failed again: the subscription stays registered and is answered with the next hint. */
|
|
5923
|
+
private retryFailedSeed;
|
|
5879
5924
|
/**
|
|
5880
5925
|
* Run {@link ShardDO.seedSubscription} and fail the ONE subscription — never
|
|
5881
5926
|
* the socket — when its handler throws.
|
|
@@ -5891,7 +5936,10 @@ declare abstract class ShardDO {
|
|
|
5891
5936
|
* spins at the initial delay for the life of the page.
|
|
5892
5937
|
*
|
|
5893
5938
|
* So: drop the just-registered subscription from the attachment and answer
|
|
5894
|
-
* with a structured `error` frame carrying the thrown error's code.
|
|
5939
|
+
* with a structured `error` frame carrying the thrown error's code. The one
|
|
5940
|
+
* exception is a retry on an unguarded socket: a same-args re-subscribe of an
|
|
5941
|
+
* already-registered subscription stays registered and is answered with the
|
|
5942
|
+
* next retry hint (see {@link ShardDO.retryFailedSeed}). Mirrors
|
|
5895
5943
|
* `refreshSubscriptions`' per-`(socket, sub)` catch on the write-flush half
|
|
5896
5944
|
* of the same path, and `handleShapeSubscribe`'s rollback-then-error on a
|
|
5897
5945
|
* failed shape seed.
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{AdminRevocationDO as a}from"./packem_shared/AdminRevocationDO-DHjoZWfF.mjs";import{installDeliveryFence as t}from"./packem_shared/installDeliveryFence-B6M9KOnb.mjs";import{MERGED_ROLES as S,mergeDurableObjects as i,roleNamespace as l}from"./packem_shared/MERGED_ROLES-BAMAmIcW.mjs";import{serveRelationFanout as n}from"./packem_shared/serveRelationFanout-DcSjzAZv.mjs";import{SESSION_DO_TTL_DEFAULT as d,SessionDO as p}from"./packem_shared/SESSION_DO_TTL_DEFAULT-DSvTwRjc.mjs";import{ROOT_DO_SIZE_WARN_BYTES as D,ROOT_SHARD_NAME as O,ShardDO as E}from"./packem_shared/ROOT_DO_SIZE_WARN_BYTES-
|
|
1
|
+
import{AdminRevocationDO as a}from"./packem_shared/AdminRevocationDO-DHjoZWfF.mjs";import{installDeliveryFence as t}from"./packem_shared/installDeliveryFence-B6M9KOnb.mjs";import{MERGED_ROLES as S,mergeDurableObjects as i,roleNamespace as l}from"./packem_shared/MERGED_ROLES-BAMAmIcW.mjs";import{serveRelationFanout as n}from"./packem_shared/serveRelationFanout-DcSjzAZv.mjs";import{SESSION_DO_TTL_DEFAULT as d,SessionDO as p}from"./packem_shared/SESSION_DO_TTL_DEFAULT-DSvTwRjc.mjs";import{ROOT_DO_SIZE_WARN_BYTES as D,ROOT_SHARD_NAME as O,ShardDO as E}from"./packem_shared/ROOT_DO_SIZE_WARN_BYTES-w1SvVlQ0.mjs";import{SHARD_REGISTRY_DO_NAME as h,ShardRegistryDO as x,hostedShardRegistry as f}from"./packem_shared/SHARD_REGISTRY_DO_NAME-Dbh8JQJQ.mjs";import{createStableIdFactory as A,createStableRandomFactory as I}from"./packem_shared/createStableIdFactory-DPDT_chw.mjs";import{createShardAlarms as b,createShardDirectory as M,createShardHost as N,createShardKvStore as g,createShardPlatform as y,createSocketHost as k,createWorkerPlatform as F}from"@lunora/platform-cloudflare";import{REPROJECTION_MIGRATION_PREFIX as L,UNVOUCHABLE_DEP as v,applyCdcChanges as H,assertShapeShardable as P,backfillSearchIndexes as j,backfillVectorIndexes as U,buildReprojectionMigration as w,clearMemoryTables as G,countLegacyRows as V,createReadFootprint as B,createShardCtxDb as W,exportShardRows as Y,importShardRows as J,isSourceDue as K,markUnvouchableReads as X,pullExternalSourceIncrementalTick as Z,pullExternalSourceTick as q,reprojectionMigrationId as z,reprojectionTables as Q,runDataMigration as $,runShardMigrations as ee,subscriptionListDeltas as re}from"@lunora/shard-engine";import{A as oe}from"./packem_shared/admin-token-DrufJIZV.mjs";export{oe as ADMIN_REVOCATION_DO_NAME,a as AdminRevocationDO,S as MERGED_ROLES,L as REPROJECTION_MIGRATION_PREFIX,D as ROOT_DO_SIZE_WARN_BYTES,O as ROOT_SHARD_NAME,d as SESSION_DO_TTL_DEFAULT,h as SHARD_REGISTRY_DO_NAME,p as SessionDO,E as ShardDO,x as ShardRegistryDO,v as UNVOUCHABLE_DEP,H as applyCdcChanges,P as assertShapeShardable,j as backfillSearchIndexes,U as backfillVectorIndexes,w as buildReprojectionMigration,G as clearMemoryTables,V as countLegacyRows,B as createReadFootprint,b as createShardAlarms,W as createShardCtxDb,M as createShardDirectory,N as createShardHost,g as createShardKvStore,y as createShardPlatform,k as createSocketHost,A as createStableIdFactory,I as createStableRandomFactory,F as createWorkerPlatform,Y as exportShardRows,f as hostedShardRegistry,J as importShardRows,t as installDeliveryFence,K as isSourceDue,X as markUnvouchableReads,i as mergeDurableObjects,Z as pullExternalSourceIncrementalTick,q as pullExternalSourceTick,z as reprojectionMigrationId,Q as reprojectionTables,l as roleNamespace,$ as runDataMigration,ee as runShardMigrations,n as serveRelationFanout,re as subscriptionListDeltas};
|