@lunora/shard-engine 1.0.0-alpha.34 → 1.0.0-alpha.36
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
|
@@ -851,6 +851,7 @@ interface SubscriptionEnvelope {
|
|
|
851
851
|
clientId?: string;
|
|
852
852
|
context?: Record<string, unknown>;
|
|
853
853
|
data?: unknown;
|
|
854
|
+
generation?: number;
|
|
854
855
|
id: string;
|
|
855
856
|
query?: SubscriptionQuery;
|
|
856
857
|
shape?: {
|
|
@@ -1066,6 +1067,7 @@ declare const MAX_DURABLE_STREAM_BYTES: number;
|
|
|
1066
1067
|
interface DurableStreamSink {
|
|
1067
1068
|
readonly chunk: (chunk: {
|
|
1068
1069
|
data: unknown;
|
|
1070
|
+
generation?: number;
|
|
1069
1071
|
seq: number;
|
|
1070
1072
|
}) => boolean;
|
|
1071
1073
|
readonly complete: () => void;
|
|
@@ -1076,10 +1078,14 @@ interface DurableStreamSink {
|
|
|
1076
1078
|
}
|
|
1077
1079
|
type DurableAttachDecision = "attach" | "interrupted" | "reclaim" | "replay-terminal";
|
|
1078
1080
|
declare const decideDurableAttach: (run: DurableStreamRun | undefined, context: {
|
|
1079
|
-
|
|
1081
|
+
generation?: number;
|
|
1082
|
+
live?: {
|
|
1083
|
+
generation: number;
|
|
1084
|
+
};
|
|
1080
1085
|
resuming: boolean;
|
|
1081
1086
|
}) => DurableAttachDecision;
|
|
1082
1087
|
interface DurableStreamAttach {
|
|
1088
|
+
readonly generation?: number;
|
|
1083
1089
|
readonly iterator: (signal: AbortSignal) => AsyncIterable<unknown>;
|
|
1084
1090
|
readonly runKey: string;
|
|
1085
1091
|
readonly sinceChunk: number;
|
package/dist/index.d.ts
CHANGED
|
@@ -851,6 +851,7 @@ interface SubscriptionEnvelope {
|
|
|
851
851
|
clientId?: string;
|
|
852
852
|
context?: Record<string, unknown>;
|
|
853
853
|
data?: unknown;
|
|
854
|
+
generation?: number;
|
|
854
855
|
id: string;
|
|
855
856
|
query?: SubscriptionQuery;
|
|
856
857
|
shape?: {
|
|
@@ -1066,6 +1067,7 @@ declare const MAX_DURABLE_STREAM_BYTES: number;
|
|
|
1066
1067
|
interface DurableStreamSink {
|
|
1067
1068
|
readonly chunk: (chunk: {
|
|
1068
1069
|
data: unknown;
|
|
1070
|
+
generation?: number;
|
|
1069
1071
|
seq: number;
|
|
1070
1072
|
}) => boolean;
|
|
1071
1073
|
readonly complete: () => void;
|
|
@@ -1076,10 +1078,14 @@ interface DurableStreamSink {
|
|
|
1076
1078
|
}
|
|
1077
1079
|
type DurableAttachDecision = "attach" | "interrupted" | "reclaim" | "replay-terminal";
|
|
1078
1080
|
declare const decideDurableAttach: (run: DurableStreamRun | undefined, context: {
|
|
1079
|
-
|
|
1081
|
+
generation?: number;
|
|
1082
|
+
live?: {
|
|
1083
|
+
generation: number;
|
|
1084
|
+
};
|
|
1080
1085
|
resuming: boolean;
|
|
1081
1086
|
}) => DurableAttachDecision;
|
|
1082
1087
|
interface DurableStreamAttach {
|
|
1088
|
+
readonly generation?: number;
|
|
1083
1089
|
readonly iterator: (signal: AbortSignal) => AsyncIterable<unknown>;
|
|
1084
1090
|
readonly runKey: string;
|
|
1085
1091
|
readonly sinceChunk: number;
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{exportShardRows as o,exportShardTable as a,importShardRows as t,parseExportShardArgs as n,parseImportShardArgs as s,selectExportTables as i,validateImportRow as l}from"./packem_shared/exportShardRows-Cgt3ITwH.mjs";import{AGGREGATE_SQL_FUNCTION as p,aggregateSqlFunction as c,matchesStaticWhere as d,normalizeCountArgument as S,throwingScheduler as u}from"./packem_shared/AGGREGATE_SQL_FUNCTION-m1iUU1rv.mjs";import{aggregateTableName as f,coerceAggregateNumber as T,encodeAggregateKey as E,foldAggregateTally as A,readAggregateValue as R}from"./packem_shared/aggregateTableName-Cy5e03oz.mjs";import{CountRlsUnsupportedError as h,mergeWhere as C,planAggregateLookup as _,selectIndexForAggregate as I,selectIndexForCount as L,selectIndexForGroupBy as b}from"./packem_shared/CountRlsUnsupportedError-Bdfupt3g.mjs";import{AUDIT_LOG_TABLE as y,appendAuditEntry as N,ensureAuditTable as O,readAuditLog as D}from"./packem_shared/AUDIT_LOG_TABLE-uNVU9O1W.mjs";import{NotUniqueError as P,assertValidClientId as k,createShardCtxDb as B,normalizeIdStructurally as G}from"./packem_shared/NotUniqueError-THUZXy3C.mjs";import{backfillAggregateIndexes as q,backfillRankIndexes as w,backfillSearchIndexes as K,backfillSearchIndexesForTable as W}from"./packem_shared/backfillAggregateIndexes-DVQ2sVuV.mjs";import{CDC_LOG_TABLE as z,CDC_META_TABLE as H,appendCdcChange as X,applyCdcChanges as V,bumpCdcEpoch as Q,migrateCdcLog as j,migrateCdcMeta as Y,minCdcSeq as J,readCdcChanges as Z,readCdcCursor as $,readCdcEpoch as ee,trimCdcChanges as re}from"./packem_shared/CDC_LOG_TABLE-B58N8NQO.mjs";import{CLIENT_WATERMARK_TABLE as ae,advanceClientWatermark as te,migrateClientWatermark as ne,readClientWatermark as se}from"./packem_shared/CLIENT_WATERMARK_TABLE-BoS1HEqz.mjs";import{COMMIT_SEQ_FIELD as le,COMMIT_SEQ_TABLE as me,allocateCommitSeq as pe,migrateCommitSeq as ce,readCommitSeq as de}from"./packem_shared/COMMIT_SEQ_FIELD-CSe_oNZu.mjs";import{c as ue}from"./packem_shared/ctx-db-companions-lTt-rvKG.mjs";import{GLOBAL_SHAPE_SNAPSHOT_TABLE as fe,deleteGlobalShapeSnapshot as Te,deleteGlobalShapeSnapshotsForConnection as Ee,migrateGlobalShapeSnapshot as Ae,readGlobalShapeSnapshot as Re,writeGlobalShapeSnapshot as ge}from"./packem_shared/GLOBAL_SHAPE_SNAPSHOT_TABLE-NWaL77m5.mjs";import{IDEMPOTENCY_TABLE as Ce,migrateIdempotency as _e,readIdempotent as Ie,trimIdempotent as Le,writeIdempotent as be}from"./packem_shared/IDEMPOTENCY_TABLE-DKVe2Ohf.mjs";import{clearMemoryTables as ye,isMemoryTable as Ne,memoryTableNames as Oe}from"./packem_shared/clearMemoryTables-CXULwypv.mjs";import{computeRankPage as Fe,hydrateDocsById as Pe}from"./packem_shared/computeRankPage-Bby1Npkd.mjs";import{SEARCH_STATE_TABLE as Be,migrateSearchState as Ge,readSearchBackfillState as Ue,writeSearchBackfillState as qe}from"./packem_shared/SEARCH_STATE_TABLE-Dju8ebbU.mjs";import{SHAPE_POKE_CURSOR_TABLE as Ke,deleteShapePokeCursor as We,deleteShapePokeCursorsForConnection as ve,migrateShapePokeCursor as ze,readShapePokeCursor as He,writeShapePokeCursor as Xe}from"./packem_shared/SHAPE_POKE_CURSOR_TABLE-Dh4HfSdC.mjs";import{selectShapeMemberIds as Qe,selectShapeRows as je}from"./packem_shared/selectShapeMemberIds-B-pQJHAu.mjs";import{DATA_MIGRATION_STATE_TABLE as Je,readMigrationStatus as Ze,runDataMigration as $e}from"./packem_shared/DATA_MIGRATION_STATE_TABLE-4l6aU1Vc.mjs";import{SCAN_DEP as rr,createDependencyTracker as or,depKey as ar,tableFromDepKey as tr}from"./packem_shared/SCAN_DEP-D7qE3iUe.mjs";import{runDrizzle as sr,runSql as ir}from"./packem_shared/runDrizzle-it6rL9bR.mjs";import{A as mr,a as pr,b as cr,D as dr,c as Sr,d as ur,g as xr,i as fr,j as Tr,e as Er,q as Ar,f as Rr,r as gr,t as hr,h as Cr}from"./packem_shared/do-sql-Dk_DJxn4.mjs";import{param as Ir,renderSql as Lr,sqliteInList as br,unionAll as Mr}from"./packem_shared/param-Ib8WHnrF.mjs";import{appendStreamChunk as Nr,claimStreamRun as Or,deleteStreamRun as Dr,finishStreamRun as Fr,migrateDurableStreams as Pr,readStreamChunks as kr,readStreamRun as Br,trimStreamRuns as Gr}from"./packem_shared/appendStreamChunk-CH4e4nJn.mjs";import{DurableStreamRunner as qr,MAX_DURABLE_STREAM_BYTES as wr,MAX_DURABLE_STREAM_CHUNKS as Kr,decideDurableAttach as Wr}from"./packem_shared/DurableStreamRunner-Bm6KDMBU.mjs";import{diffExternalSource as zr}from"./packem_shared/diffExternalSource-DbHrcoZK.mjs";import{liftSourceId as Xr,normalizeSourceDocument as Vr,normalizeSourceValue as Qr}from"./packem_shared/liftSourceId-CA3ENhXj.mjs";import{materializeExternalRows as Yr,materializeExternalRowsIncremental as Jr,readExternalSourceBaseline as Zr,runExternalSourceTick as $r}from"./packem_shared/materializeExternalRows-D5tgL1mR.mjs";import{isSoftDeleted as ro,isSourceDue as oo,pullExternalSourceIncrementalTick as ao,pullExternalSourceTick as to}from"./packem_shared/isSoftDeleted-DR79pnU-.mjs";import{GEO_DEFAULT_PRECISION as so,boundingBoxCenter as io,boundingBoxGeohashes as lo,coveringGeohashes as mo,encodeGeohash as po,haversineMeters as co,pointInBoundingBox as So}from"./packem_shared/GEO_DEFAULT_PRECISION-CqpQZ-J_.mjs";import{ADMIN_FUNCTIONS as xo,ADMIN_FUNCTION_PREFIX as fo,DEFAULT_FANOUT_TOPIC_LIMIT as To,FLAGS_FUNCTION_PREFIX as Eo,MAX_PAGE_SIZE as Ao,RELATION_FUNCTION_PREFIX as Ro,createFanoutCounters as go,facetColumn as ho,findStorageReferences as Co,listTables as _o,readTablePage as Io,recordFanoutPass as Lo,selectMatchingIds as bo,summarizeFanoutTopics as Mo,summarizeSubscriptions as yo}from"./packem_shared/ADMIN_FUNCTIONS-2mZJ-FQW.mjs";import{MAIL_RETENTION as Oo,MAIL_TABLE as Do,clearCapturedMail as Fo,ensureMailTable as Po,readCapturedMail as ko,recordCapturedMail as Bo}from"./packem_shared/MAIL_RETENTION-Cig9Dmc8.mjs";import{NotFoundError as Uo}from"./packem_shared/NotFoundError-BhF7FeFr.mjs";import{armRestore as wo,readBookmark as Ko}from"./packem_shared/armRestore-Bu1_8SUa.mjs";import{applySelect as vo,buildSeekBeforeWhere as zo,buildSeekWhere as Ho,decodeCursor as Xo,encodeCursor as Vo,normalizeOrderKeys as Qo,softDeleteScope as jo}from"./packem_shared/applySelect-BQbHyo-W.mjs";import{QUEUE_TABLE as Jo,clearQueueMessages as Zo,isLossyBody as $o,readQueueMessageById as ea,readQueueMessages as ra,recordQueueMessages as oa}from"./packem_shared/QUEUE_TABLE-zj9Tt6tk.mjs";import{RANK_TIEBREAK as ta,encodePartitionKey as na,matchesRankStaticWhere as sa,rankKeyFromDoc as ia,rankTableName as la,resolveRankPartition as ma,sortColumnName as pa}from"./packem_shared/RANK_TIEBREAK-ci3MaM65.mjs";import{ReactiveCache as da,reactiveCacheKey as Sa}from"./packem_shared/ReactiveCache-DlJ38txF.mjs";import{REACTOR_STATE_TABLE as xa,listReactorStates as fa,migrateReactorState as Ta,reactorNeedsRun as Ea,readReactorState as Aa,writeReactorState as Ra}from"./packem_shared/REACTOR_STATE_TABLE-Cr9Orfp8.mjs";import{createReadFootprint as ha}from"./packem_shared/createReadFootprint-MRH1If3F.mjs";import{buildIndexRange as _a,indexKeysForRow as Ia,keysTouchRanges as La}from"./packem_shared/buildIndexRange-CBKQmHSS.mjs";import{DEFAULT_MAX_RELATION_KEYS as Ma,assertFlatPredicate as ya,assertShapeShardable as Na,containsRelationPredicate as Oa,isRelationPredicate as Da,resolveRelationPredicates as Fa}from"./packem_shared/DEFAULT_MAX_RELATION_KEYS-BAWGIEvC.mjs";import{applyOnDelete as ka,distinctValues as Ba,fanOutScalarCounts as Ga,relationHooks as Ua,resolveWith as qa,runRowValidators as wa}from"./packem_shared/applyOnDelete-BlcwKjuO.mjs";import{DEFAULT_PROMOTION_THRESHOLDS as Wa,clampPromotionThresholds as va,nextPromotionState as za,relayCountFor as Ha,shapeRoutingKey as Xa}from"./packem_shared/DEFAULT_PROMOTION_THRESHOLDS-H2sHFvlw.mjs";import{DEFAULT_MAX_RELAYS as Qa,OwnerRelay as ja,RelayMember as Ya,createRelayLink as Ja}from"./packem_shared/DEFAULT_MAX_RELAYS-tuHNDUZr.mjs";import{createReplicaLink as $a,gateReplicaDispatch as et,handleReplicaControl as rt}from"./packem_shared/createReplicaLink-C1JuP_DN.mjs";import{buildReprojectionMigration as at,countLegacyRows as tt,reprojectableFields as nt,reprojectionTables as st}from"./packem_shared/buildReprojectionMigration-8nVn8Qwb.mjs";import{RLS_UNWRAP_SYMBOL as lt,RlsRequiredError as mt,guardWriter as pt}from"./packem_shared/RLS_UNWRAP_SYMBOL-BWloGsd3.mjs";import{SCHEMA_HISTORY_MAX_VERSIONS as dt,readSchemaHistory as St,readSchemaVersion as ut,recordSchemaVersion as xt}from"./packem_shared/SCHEMA_HISTORY_MAX_VERSIONS-DsycDXWm.mjs";import{serializeSqlValue as Tt}from"./packem_shared/serializeSqlValue-DbI1VQYM.mjs";import{buildSettings as At,isDevEnvironment as Rt}from"./packem_shared/buildSettings-B4igo4rJ.mjs";import{buildPokeFrames as ht,diffGlobalMembership as Ct,encodeRowsPatch as _t,projectColumns as It}from"./packem_shared/buildPokeFrames-BXejpiII.mjs";import{ShardRunner as bt}from"./packem_shared/ShardRunner-C9p5DVOx.mjs";import{runSocketPool as yt}from"./packem_shared/runSocketPool-CZJ2X9cF.mjs";import{MAX_SQL_ROWS as Ot,assertReadonly as Dt,lintReadonlySql as Ft,runReadonlySql as Pt}from"./packem_shared/MAX_SQL_ROWS-gsiUV0Eo.mjs";import{awaitWsDrain as Bt,subscriptionFrames as Gt,subscriptionListDeltas as Ut,trySendFrame as qt}from"./packem_shared/awaitWsDrain-Cs-1HHP6.mjs";import{mergeChangedKeys as Kt,recordChangedKeys as Wt,writeTouchesMemo as vt}from"./packem_shared/mergeChangedKeys-D1T-TPUb.mjs";import{createSystemReader as Ht}from"./packem_shared/createSystemReader-BtYeSMDb.mjs";import{ConflictError as Vt}from"./packem_shared/ConflictError-C8GtJmjS.mjs";import{DEFAULT_TRANSACTION_LIMITS as jt,TransactionHeadroomTracker as Yt}from"./packem_shared/DEFAULT_TRANSACTION_LIMITS-Bcoi7Bvf.mjs";import{hasTrigger as Zt,runTriggers as $t}from"./packem_shared/hasTrigger-CjlwI4le.mjs";import{selectExpiredIds as rn}from"./packem_shared/selectExpiredIds-_5514W_v.mjs";import{compileWhereSql as an,literalInList as tn}from"./packem_shared/compileWhereSql-JBpSfQm9.mjs";import{RELATION_EXISTS_KEY as sn}from"./packem_shared/RELATION_EXISTS_KEY-CFUhnZSZ.mjs";import{REPROJECTION_MIGRATION_PREFIX as mn,reprojectionMigrationId as pn}from"./packem_shared/REPROJECTION_MIGRATION_PREFIX-Czcb6_mO.mjs";import{quoteIdentifier as dn}from"./packem_shared/quoteIdentifier-CObIFRhb.mjs";import{runShardMigrations as un}from"./packem_shared/runShardMigrations-DtIbA812.mjs";import{stableStringify as fn}from"./packem_shared/stableStringify-G9OF5wcs.mjs";import{stableWireKey as En}from"./packem_shared/stableWireKey-DSCJB6E7.mjs";export{xo as ADMIN_FUNCTIONS,fo as ADMIN_FUNCTION_PREFIX,p as AGGREGATE_SQL_FUNCTION,mr as AGG_COUNT,pr as AGG_KEY,cr as AGG_VALUE,y as AUDIT_LOG_TABLE,z as CDC_LOG_TABLE,H as CDC_META_TABLE,ae as CLIENT_WATERMARK_TABLE,le as COMMIT_SEQ_FIELD,me as COMMIT_SEQ_TABLE,Vt as ConflictError,h as CountRlsUnsupportedError,Je as DATA_MIGRATION_STATE_TABLE,To as DEFAULT_FANOUT_TOPIC_LIMIT,Ma as DEFAULT_MAX_RELATION_KEYS,Qa as DEFAULT_MAX_RELAYS,Wa as DEFAULT_PROMOTION_THRESHOLDS,jt as DEFAULT_TRANSACTION_LIMITS,dr as DOC_COLUMN,qr as DurableStreamRunner,Eo as FLAGS_FUNCTION_PREFIX,so as GEO_DEFAULT_PRECISION,fe as GLOBAL_SHAPE_SNAPSHOT_TABLE,Ce as IDEMPOTENCY_TABLE,Oo as MAIL_RETENTION,Do as MAIL_TABLE,wr as MAX_DURABLE_STREAM_BYTES,Kr as MAX_DURABLE_STREAM_CHUNKS,Ao as MAX_PAGE_SIZE,Ot as MAX_SQL_ROWS,Uo as NotFoundError,P as NotUniqueError,ja as OwnerRelay,Jo as QUEUE_TABLE,ta as RANK_TIEBREAK,xa as REACTOR_STATE_TABLE,sn as RELATION_EXISTS_KEY,Ro as RELATION_FUNCTION_PREFIX,mn as REPROJECTION_MIGRATION_PREFIX,lt as RLS_UNWRAP_SYMBOL,da as ReactiveCache,Ya as RelayMember,mt as RlsRequiredError,rr as SCAN_DEP,dt as SCHEMA_HISTORY_MAX_VERSIONS,Be as SEARCH_STATE_TABLE,Ke as SHAPE_POKE_CURSOR_TABLE,bt as ShardRunner,Yt as TransactionHeadroomTracker,te as advanceClientWatermark,Sr as aggUpsertSql,c as aggregateSqlFunction,f as aggregateTableName,pe as allocateCommitSeq,N as appendAuditEntry,X as appendCdcChange,Nr as appendStreamChunk,V as applyCdcChanges,ka as applyOnDelete,vo as applySelect,wo as armRestore,ya as assertFlatPredicate,Dt as assertReadonly,Na as assertShapeShardable,k as assertValidClientId,Bt as awaitWsDrain,q as backfillAggregateIndexes,w as backfillRankIndexes,K as backfillSearchIndexes,W as backfillSearchIndexesForTable,io as boundingBoxCenter,lo as boundingBoxGeohashes,_a as buildIndexRange,ht as buildPokeFrames,at as buildReprojectionMigration,zo as buildSeekBeforeWhere,Ho as buildSeekWhere,At as buildSettings,Q as bumpCdcEpoch,Or as claimStreamRun,va as clampPromotionThresholds,Fo as clearCapturedMail,ye as clearMemoryTables,Zo as clearQueueMessages,T as coerceAggregateNumber,an as compileWhereSql,Fe as computeRankPage,Oa as containsRelationPredicate,tt as countLegacyRows,mo as coveringGeohashes,ue as createCompanionSync,or as createDependencyTracker,go as createFanoutCounters,ur as createIndexSql,ha as createReadFootprint,Ja as createRelayLink,$a as createReplicaLink,B as createShardCtxDb,Ht as createSystemReader,Wr as decideDurableAttach,Xo as decodeCursor,Te as deleteGlobalShapeSnapshot,Ee as deleteGlobalShapeSnapshotsForConnection,We as deleteShapePokeCursor,ve as deleteShapePokeCursorsForConnection,Dr as deleteStreamRun,ar as depKey,zr as diffExternalSource,Ct as diffGlobalMembership,Ba as distinctValues,E as encodeAggregateKey,Vo as encodeCursor,po as encodeGeohash,na as encodePartitionKey,_t as encodeRowsPatch,O as ensureAuditTable,Po as ensureMailTable,o as exportShardRows,a as exportShardTable,ho as facetColumn,Ga as fanOutScalarCounts,Co as findStorageReferences,Fr as finishStreamRun,A as foldAggregateTally,et as gateReplicaDispatch,xr as geoTableName,pt as guardWriter,rt as handleReplicaControl,Zt as hasTrigger,co as haversineMeters,Pe as hydrateDocsById,t as importShardRows,Ia as indexKeysForRow,Rt as isDevEnvironment,fr as isFtsAvailable,$o as isLossyBody,Ne as isMemoryTable,Da as isRelationPredicate,ro as isSoftDeleted,oo as isSourceDue,Tr as jsonPath,Er as jsonPathSql,La as keysTouchRanges,Xr as liftSourceId,Ft as lintReadonlySql,fa as listReactorStates,_o as listTables,tn as literalInList,sa as matchesRankStaticWhere,d as matchesStaticWhere,Yr as materializeExternalRows,Jr as materializeExternalRowsIncremental,Oe as memoryTableNames,Kt as mergeChangedKeys,C as mergeWhere,j as migrateCdcLog,Y as migrateCdcMeta,ne as migrateClientWatermark,ce as migrateCommitSeq,Pr as migrateDurableStreams,Ae as migrateGlobalShapeSnapshot,_e as migrateIdempotency,Ta as migrateReactorState,Ge as migrateSearchState,ze as migrateShapePokeCursor,J as minCdcSeq,za as nextPromotionState,S as normalizeCountArgument,G as normalizeIdStructurally,Qo as normalizeOrderKeys,Vr as normalizeSourceDocument,Qr as normalizeSourceValue,Ir as param,n as parseExportShardArgs,s as parseImportShardArgs,_ as planAggregateLookup,So as pointInBoundingBox,It as projectColumns,ao as pullExternalSourceIncrementalTick,to as pullExternalSourceTick,Ar as qualifiedJsonPath,Rr as qualifiedJsonPathSql,dn as quoteIdentifier,ia as rankKeyFromDoc,la as rankTableName,Sa as reactiveCacheKey,Ea as reactorNeedsRun,R as readAggregateValue,D as readAuditLog,Ko as readBookmark,ko as readCapturedMail,Z as readCdcChanges,$ as readCdcCursor,ee as readCdcEpoch,se as readClientWatermark,de as readCommitSeq,Zr as readExternalSourceBaseline,Re as readGlobalShapeSnapshot,Ie as readIdempotent,Ze as readMigrationStatus,ea as readQueueMessageById,ra as readQueueMessages,Aa as readReactorState,St as readSchemaHistory,ut as readSchemaVersion,Ue as readSearchBackfillState,He as readShapePokeCursor,kr as readStreamChunks,Br as readStreamRun,Io as readTablePage,Bo as recordCapturedMail,Wt as recordChangedKeys,Lo as recordFanoutPass,oa as recordQueueMessages,xt as recordSchemaVersion,Ua as relationHooks,Ha as relayCountFor,Lr as renderSql,nt as reprojectableFields,pn as reprojectionMigrationId,st as reprojectionTables,ma as resolveRankPartition,Fa as resolveRelationPredicates,qa as resolveWith,gr as rowToDocument,$e as runDataMigration,sr as runDrizzle,$r as runExternalSourceTick,Pt as runReadonlySql,wa as runRowValidators,un as runShardMigrations,yt as runSocketPool,ir as runSql,$t as runTriggers,rn as selectExpiredIds,i as selectExportTables,I as selectIndexForAggregate,L as selectIndexForCount,b as selectIndexForGroupBy,bo as selectMatchingIds,Qe as selectShapeMemberIds,je as selectShapeRows,Tt as serializeSqlValue,Xa as shapeRoutingKey,jo as softDeleteScope,pa as sortColumnName,br as sqliteInList,fn as stableStringify,En as stableWireKey,Gt as subscriptionFrames,Ut as subscriptionListDeltas,Mo as summarizeFanoutTopics,yo as summarizeSubscriptions,hr as tableColumns,tr as tableFromDepKey,u as throwingScheduler,re as trimCdcChanges,Le as trimIdempotent,Gr as trimStreamRuns,Cr as tryRowToDocument,qt as trySendFrame,Mr as unionAll,l as validateImportRow,ge as writeGlobalShapeSnapshot,be as writeIdempotent,Ra as writeReactorState,qe as writeSearchBackfillState,Xe as writeShapePokeCursor,vt as writeTouchesMemo};
|
|
1
|
+
import{exportShardRows as o,exportShardTable as a,importShardRows as t,parseExportShardArgs as n,parseImportShardArgs as s,selectExportTables as i,validateImportRow as l}from"./packem_shared/exportShardRows-Cgt3ITwH.mjs";import{AGGREGATE_SQL_FUNCTION as p,aggregateSqlFunction as c,matchesStaticWhere as d,normalizeCountArgument as S,throwingScheduler as u}from"./packem_shared/AGGREGATE_SQL_FUNCTION-m1iUU1rv.mjs";import{aggregateTableName as f,coerceAggregateNumber as T,encodeAggregateKey as E,foldAggregateTally as A,readAggregateValue as R}from"./packem_shared/aggregateTableName-Cy5e03oz.mjs";import{CountRlsUnsupportedError as h,mergeWhere as C,planAggregateLookup as _,selectIndexForAggregate as I,selectIndexForCount as L,selectIndexForGroupBy as b}from"./packem_shared/CountRlsUnsupportedError-Bdfupt3g.mjs";import{AUDIT_LOG_TABLE as y,appendAuditEntry as N,ensureAuditTable as O,readAuditLog as D}from"./packem_shared/AUDIT_LOG_TABLE-uNVU9O1W.mjs";import{NotUniqueError as P,assertValidClientId as k,createShardCtxDb as B,normalizeIdStructurally as G}from"./packem_shared/NotUniqueError-THUZXy3C.mjs";import{backfillAggregateIndexes as q,backfillRankIndexes as w,backfillSearchIndexes as K,backfillSearchIndexesForTable as W}from"./packem_shared/backfillAggregateIndexes-DVQ2sVuV.mjs";import{CDC_LOG_TABLE as z,CDC_META_TABLE as H,appendCdcChange as X,applyCdcChanges as V,bumpCdcEpoch as Q,migrateCdcLog as j,migrateCdcMeta as Y,minCdcSeq as J,readCdcChanges as Z,readCdcCursor as $,readCdcEpoch as ee,trimCdcChanges as re}from"./packem_shared/CDC_LOG_TABLE-B58N8NQO.mjs";import{CLIENT_WATERMARK_TABLE as ae,advanceClientWatermark as te,migrateClientWatermark as ne,readClientWatermark as se}from"./packem_shared/CLIENT_WATERMARK_TABLE-BoS1HEqz.mjs";import{COMMIT_SEQ_FIELD as le,COMMIT_SEQ_TABLE as me,allocateCommitSeq as pe,migrateCommitSeq as ce,readCommitSeq as de}from"./packem_shared/COMMIT_SEQ_FIELD-CSe_oNZu.mjs";import{c as ue}from"./packem_shared/ctx-db-companions-lTt-rvKG.mjs";import{GLOBAL_SHAPE_SNAPSHOT_TABLE as fe,deleteGlobalShapeSnapshot as Te,deleteGlobalShapeSnapshotsForConnection as Ee,migrateGlobalShapeSnapshot as Ae,readGlobalShapeSnapshot as Re,writeGlobalShapeSnapshot as ge}from"./packem_shared/GLOBAL_SHAPE_SNAPSHOT_TABLE-NWaL77m5.mjs";import{IDEMPOTENCY_TABLE as Ce,migrateIdempotency as _e,readIdempotent as Ie,trimIdempotent as Le,writeIdempotent as be}from"./packem_shared/IDEMPOTENCY_TABLE-DKVe2Ohf.mjs";import{clearMemoryTables as ye,isMemoryTable as Ne,memoryTableNames as Oe}from"./packem_shared/clearMemoryTables-CXULwypv.mjs";import{computeRankPage as Fe,hydrateDocsById as Pe}from"./packem_shared/computeRankPage-Bby1Npkd.mjs";import{SEARCH_STATE_TABLE as Be,migrateSearchState as Ge,readSearchBackfillState as Ue,writeSearchBackfillState as qe}from"./packem_shared/SEARCH_STATE_TABLE-Dju8ebbU.mjs";import{SHAPE_POKE_CURSOR_TABLE as Ke,deleteShapePokeCursor as We,deleteShapePokeCursorsForConnection as ve,migrateShapePokeCursor as ze,readShapePokeCursor as He,writeShapePokeCursor as Xe}from"./packem_shared/SHAPE_POKE_CURSOR_TABLE-Dh4HfSdC.mjs";import{selectShapeMemberIds as Qe,selectShapeRows as je}from"./packem_shared/selectShapeMemberIds-B-pQJHAu.mjs";import{DATA_MIGRATION_STATE_TABLE as Je,readMigrationStatus as Ze,runDataMigration as $e}from"./packem_shared/DATA_MIGRATION_STATE_TABLE-4l6aU1Vc.mjs";import{SCAN_DEP as rr,createDependencyTracker as or,depKey as ar,tableFromDepKey as tr}from"./packem_shared/SCAN_DEP-D7qE3iUe.mjs";import{runDrizzle as sr,runSql as ir}from"./packem_shared/runDrizzle-it6rL9bR.mjs";import{A as mr,a as pr,b as cr,D as dr,c as Sr,d as ur,g as xr,i as fr,j as Tr,e as Er,q as Ar,f as Rr,r as gr,t as hr,h as Cr}from"./packem_shared/do-sql-Dk_DJxn4.mjs";import{param as Ir,renderSql as Lr,sqliteInList as br,unionAll as Mr}from"./packem_shared/param-Ib8WHnrF.mjs";import{appendStreamChunk as Nr,claimStreamRun as Or,deleteStreamRun as Dr,finishStreamRun as Fr,migrateDurableStreams as Pr,readStreamChunks as kr,readStreamRun as Br,trimStreamRuns as Gr}from"./packem_shared/appendStreamChunk-CH4e4nJn.mjs";import{DurableStreamRunner as qr,MAX_DURABLE_STREAM_BYTES as wr,MAX_DURABLE_STREAM_CHUNKS as Kr,decideDurableAttach as Wr}from"./packem_shared/DurableStreamRunner-DDBi1UXj.mjs";import{diffExternalSource as zr}from"./packem_shared/diffExternalSource-DbHrcoZK.mjs";import{liftSourceId as Xr,normalizeSourceDocument as Vr,normalizeSourceValue as Qr}from"./packem_shared/liftSourceId-CA3ENhXj.mjs";import{materializeExternalRows as Yr,materializeExternalRowsIncremental as Jr,readExternalSourceBaseline as Zr,runExternalSourceTick as $r}from"./packem_shared/materializeExternalRows-D5tgL1mR.mjs";import{isSoftDeleted as ro,isSourceDue as oo,pullExternalSourceIncrementalTick as ao,pullExternalSourceTick as to}from"./packem_shared/isSoftDeleted-DR79pnU-.mjs";import{GEO_DEFAULT_PRECISION as so,boundingBoxCenter as io,boundingBoxGeohashes as lo,coveringGeohashes as mo,encodeGeohash as po,haversineMeters as co,pointInBoundingBox as So}from"./packem_shared/GEO_DEFAULT_PRECISION-CqpQZ-J_.mjs";import{ADMIN_FUNCTIONS as xo,ADMIN_FUNCTION_PREFIX as fo,DEFAULT_FANOUT_TOPIC_LIMIT as To,FLAGS_FUNCTION_PREFIX as Eo,MAX_PAGE_SIZE as Ao,RELATION_FUNCTION_PREFIX as Ro,createFanoutCounters as go,facetColumn as ho,findStorageReferences as Co,listTables as _o,readTablePage as Io,recordFanoutPass as Lo,selectMatchingIds as bo,summarizeFanoutTopics as Mo,summarizeSubscriptions as yo}from"./packem_shared/ADMIN_FUNCTIONS-2mZJ-FQW.mjs";import{MAIL_RETENTION as Oo,MAIL_TABLE as Do,clearCapturedMail as Fo,ensureMailTable as Po,readCapturedMail as ko,recordCapturedMail as Bo}from"./packem_shared/MAIL_RETENTION-Cig9Dmc8.mjs";import{NotFoundError as Uo}from"./packem_shared/NotFoundError-BhF7FeFr.mjs";import{armRestore as wo,readBookmark as Ko}from"./packem_shared/armRestore-Bu1_8SUa.mjs";import{applySelect as vo,buildSeekBeforeWhere as zo,buildSeekWhere as Ho,decodeCursor as Xo,encodeCursor as Vo,normalizeOrderKeys as Qo,softDeleteScope as jo}from"./packem_shared/applySelect-BQbHyo-W.mjs";import{QUEUE_TABLE as Jo,clearQueueMessages as Zo,isLossyBody as $o,readQueueMessageById as ea,readQueueMessages as ra,recordQueueMessages as oa}from"./packem_shared/QUEUE_TABLE-zj9Tt6tk.mjs";import{RANK_TIEBREAK as ta,encodePartitionKey as na,matchesRankStaticWhere as sa,rankKeyFromDoc as ia,rankTableName as la,resolveRankPartition as ma,sortColumnName as pa}from"./packem_shared/RANK_TIEBREAK-ci3MaM65.mjs";import{ReactiveCache as da,reactiveCacheKey as Sa}from"./packem_shared/ReactiveCache-DlJ38txF.mjs";import{REACTOR_STATE_TABLE as xa,listReactorStates as fa,migrateReactorState as Ta,reactorNeedsRun as Ea,readReactorState as Aa,writeReactorState as Ra}from"./packem_shared/REACTOR_STATE_TABLE-Cr9Orfp8.mjs";import{createReadFootprint as ha}from"./packem_shared/createReadFootprint-MRH1If3F.mjs";import{buildIndexRange as _a,indexKeysForRow as Ia,keysTouchRanges as La}from"./packem_shared/buildIndexRange-CBKQmHSS.mjs";import{DEFAULT_MAX_RELATION_KEYS as Ma,assertFlatPredicate as ya,assertShapeShardable as Na,containsRelationPredicate as Oa,isRelationPredicate as Da,resolveRelationPredicates as Fa}from"./packem_shared/DEFAULT_MAX_RELATION_KEYS-BAWGIEvC.mjs";import{applyOnDelete as ka,distinctValues as Ba,fanOutScalarCounts as Ga,relationHooks as Ua,resolveWith as qa,runRowValidators as wa}from"./packem_shared/applyOnDelete-BlcwKjuO.mjs";import{DEFAULT_PROMOTION_THRESHOLDS as Wa,clampPromotionThresholds as va,nextPromotionState as za,relayCountFor as Ha,shapeRoutingKey as Xa}from"./packem_shared/DEFAULT_PROMOTION_THRESHOLDS-H2sHFvlw.mjs";import{DEFAULT_MAX_RELAYS as Qa,OwnerRelay as ja,RelayMember as Ya,createRelayLink as Ja}from"./packem_shared/DEFAULT_MAX_RELAYS-tuHNDUZr.mjs";import{createReplicaLink as $a,gateReplicaDispatch as et,handleReplicaControl as rt}from"./packem_shared/createReplicaLink-C1JuP_DN.mjs";import{buildReprojectionMigration as at,countLegacyRows as tt,reprojectableFields as nt,reprojectionTables as st}from"./packem_shared/buildReprojectionMigration-8nVn8Qwb.mjs";import{RLS_UNWRAP_SYMBOL as lt,RlsRequiredError as mt,guardWriter as pt}from"./packem_shared/RLS_UNWRAP_SYMBOL-BWloGsd3.mjs";import{SCHEMA_HISTORY_MAX_VERSIONS as dt,readSchemaHistory as St,readSchemaVersion as ut,recordSchemaVersion as xt}from"./packem_shared/SCHEMA_HISTORY_MAX_VERSIONS-DsycDXWm.mjs";import{serializeSqlValue as Tt}from"./packem_shared/serializeSqlValue-DbI1VQYM.mjs";import{buildSettings as At,isDevEnvironment as Rt}from"./packem_shared/buildSettings-B4igo4rJ.mjs";import{buildPokeFrames as ht,diffGlobalMembership as Ct,encodeRowsPatch as _t,projectColumns as It}from"./packem_shared/buildPokeFrames-BXejpiII.mjs";import{ShardRunner as bt}from"./packem_shared/ShardRunner-C9p5DVOx.mjs";import{runSocketPool as yt}from"./packem_shared/runSocketPool-CZJ2X9cF.mjs";import{MAX_SQL_ROWS as Ot,assertReadonly as Dt,lintReadonlySql as Ft,runReadonlySql as Pt}from"./packem_shared/MAX_SQL_ROWS-gsiUV0Eo.mjs";import{awaitWsDrain as Bt,subscriptionFrames as Gt,subscriptionListDeltas as Ut,trySendFrame as qt}from"./packem_shared/awaitWsDrain-Cs-1HHP6.mjs";import{mergeChangedKeys as Kt,recordChangedKeys as Wt,writeTouchesMemo as vt}from"./packem_shared/mergeChangedKeys-D1T-TPUb.mjs";import{createSystemReader as Ht}from"./packem_shared/createSystemReader-BtYeSMDb.mjs";import{ConflictError as Vt}from"./packem_shared/ConflictError-C8GtJmjS.mjs";import{DEFAULT_TRANSACTION_LIMITS as jt,TransactionHeadroomTracker as Yt}from"./packem_shared/DEFAULT_TRANSACTION_LIMITS-Bcoi7Bvf.mjs";import{hasTrigger as Zt,runTriggers as $t}from"./packem_shared/hasTrigger-CjlwI4le.mjs";import{selectExpiredIds as rn}from"./packem_shared/selectExpiredIds-_5514W_v.mjs";import{compileWhereSql as an,literalInList as tn}from"./packem_shared/compileWhereSql-JBpSfQm9.mjs";import{RELATION_EXISTS_KEY as sn}from"./packem_shared/RELATION_EXISTS_KEY-CFUhnZSZ.mjs";import{REPROJECTION_MIGRATION_PREFIX as mn,reprojectionMigrationId as pn}from"./packem_shared/REPROJECTION_MIGRATION_PREFIX-Czcb6_mO.mjs";import{quoteIdentifier as dn}from"./packem_shared/quoteIdentifier-CObIFRhb.mjs";import{runShardMigrations as un}from"./packem_shared/runShardMigrations-DtIbA812.mjs";import{stableStringify as fn}from"./packem_shared/stableStringify-G9OF5wcs.mjs";import{stableWireKey as En}from"./packem_shared/stableWireKey-DSCJB6E7.mjs";export{xo as ADMIN_FUNCTIONS,fo as ADMIN_FUNCTION_PREFIX,p as AGGREGATE_SQL_FUNCTION,mr as AGG_COUNT,pr as AGG_KEY,cr as AGG_VALUE,y as AUDIT_LOG_TABLE,z as CDC_LOG_TABLE,H as CDC_META_TABLE,ae as CLIENT_WATERMARK_TABLE,le as COMMIT_SEQ_FIELD,me as COMMIT_SEQ_TABLE,Vt as ConflictError,h as CountRlsUnsupportedError,Je as DATA_MIGRATION_STATE_TABLE,To as DEFAULT_FANOUT_TOPIC_LIMIT,Ma as DEFAULT_MAX_RELATION_KEYS,Qa as DEFAULT_MAX_RELAYS,Wa as DEFAULT_PROMOTION_THRESHOLDS,jt as DEFAULT_TRANSACTION_LIMITS,dr as DOC_COLUMN,qr as DurableStreamRunner,Eo as FLAGS_FUNCTION_PREFIX,so as GEO_DEFAULT_PRECISION,fe as GLOBAL_SHAPE_SNAPSHOT_TABLE,Ce as IDEMPOTENCY_TABLE,Oo as MAIL_RETENTION,Do as MAIL_TABLE,wr as MAX_DURABLE_STREAM_BYTES,Kr as MAX_DURABLE_STREAM_CHUNKS,Ao as MAX_PAGE_SIZE,Ot as MAX_SQL_ROWS,Uo as NotFoundError,P as NotUniqueError,ja as OwnerRelay,Jo as QUEUE_TABLE,ta as RANK_TIEBREAK,xa as REACTOR_STATE_TABLE,sn as RELATION_EXISTS_KEY,Ro as RELATION_FUNCTION_PREFIX,mn as REPROJECTION_MIGRATION_PREFIX,lt as RLS_UNWRAP_SYMBOL,da as ReactiveCache,Ya as RelayMember,mt as RlsRequiredError,rr as SCAN_DEP,dt as SCHEMA_HISTORY_MAX_VERSIONS,Be as SEARCH_STATE_TABLE,Ke as SHAPE_POKE_CURSOR_TABLE,bt as ShardRunner,Yt as TransactionHeadroomTracker,te as advanceClientWatermark,Sr as aggUpsertSql,c as aggregateSqlFunction,f as aggregateTableName,pe as allocateCommitSeq,N as appendAuditEntry,X as appendCdcChange,Nr as appendStreamChunk,V as applyCdcChanges,ka as applyOnDelete,vo as applySelect,wo as armRestore,ya as assertFlatPredicate,Dt as assertReadonly,Na as assertShapeShardable,k as assertValidClientId,Bt as awaitWsDrain,q as backfillAggregateIndexes,w as backfillRankIndexes,K as backfillSearchIndexes,W as backfillSearchIndexesForTable,io as boundingBoxCenter,lo as boundingBoxGeohashes,_a as buildIndexRange,ht as buildPokeFrames,at as buildReprojectionMigration,zo as buildSeekBeforeWhere,Ho as buildSeekWhere,At as buildSettings,Q as bumpCdcEpoch,Or as claimStreamRun,va as clampPromotionThresholds,Fo as clearCapturedMail,ye as clearMemoryTables,Zo as clearQueueMessages,T as coerceAggregateNumber,an as compileWhereSql,Fe as computeRankPage,Oa as containsRelationPredicate,tt as countLegacyRows,mo as coveringGeohashes,ue as createCompanionSync,or as createDependencyTracker,go as createFanoutCounters,ur as createIndexSql,ha as createReadFootprint,Ja as createRelayLink,$a as createReplicaLink,B as createShardCtxDb,Ht as createSystemReader,Wr as decideDurableAttach,Xo as decodeCursor,Te as deleteGlobalShapeSnapshot,Ee as deleteGlobalShapeSnapshotsForConnection,We as deleteShapePokeCursor,ve as deleteShapePokeCursorsForConnection,Dr as deleteStreamRun,ar as depKey,zr as diffExternalSource,Ct as diffGlobalMembership,Ba as distinctValues,E as encodeAggregateKey,Vo as encodeCursor,po as encodeGeohash,na as encodePartitionKey,_t as encodeRowsPatch,O as ensureAuditTable,Po as ensureMailTable,o as exportShardRows,a as exportShardTable,ho as facetColumn,Ga as fanOutScalarCounts,Co as findStorageReferences,Fr as finishStreamRun,A as foldAggregateTally,et as gateReplicaDispatch,xr as geoTableName,pt as guardWriter,rt as handleReplicaControl,Zt as hasTrigger,co as haversineMeters,Pe as hydrateDocsById,t as importShardRows,Ia as indexKeysForRow,Rt as isDevEnvironment,fr as isFtsAvailable,$o as isLossyBody,Ne as isMemoryTable,Da as isRelationPredicate,ro as isSoftDeleted,oo as isSourceDue,Tr as jsonPath,Er as jsonPathSql,La as keysTouchRanges,Xr as liftSourceId,Ft as lintReadonlySql,fa as listReactorStates,_o as listTables,tn as literalInList,sa as matchesRankStaticWhere,d as matchesStaticWhere,Yr as materializeExternalRows,Jr as materializeExternalRowsIncremental,Oe as memoryTableNames,Kt as mergeChangedKeys,C as mergeWhere,j as migrateCdcLog,Y as migrateCdcMeta,ne as migrateClientWatermark,ce as migrateCommitSeq,Pr as migrateDurableStreams,Ae as migrateGlobalShapeSnapshot,_e as migrateIdempotency,Ta as migrateReactorState,Ge as migrateSearchState,ze as migrateShapePokeCursor,J as minCdcSeq,za as nextPromotionState,S as normalizeCountArgument,G as normalizeIdStructurally,Qo as normalizeOrderKeys,Vr as normalizeSourceDocument,Qr as normalizeSourceValue,Ir as param,n as parseExportShardArgs,s as parseImportShardArgs,_ as planAggregateLookup,So as pointInBoundingBox,It as projectColumns,ao as pullExternalSourceIncrementalTick,to as pullExternalSourceTick,Ar as qualifiedJsonPath,Rr as qualifiedJsonPathSql,dn as quoteIdentifier,ia as rankKeyFromDoc,la as rankTableName,Sa as reactiveCacheKey,Ea as reactorNeedsRun,R as readAggregateValue,D as readAuditLog,Ko as readBookmark,ko as readCapturedMail,Z as readCdcChanges,$ as readCdcCursor,ee as readCdcEpoch,se as readClientWatermark,de as readCommitSeq,Zr as readExternalSourceBaseline,Re as readGlobalShapeSnapshot,Ie as readIdempotent,Ze as readMigrationStatus,ea as readQueueMessageById,ra as readQueueMessages,Aa as readReactorState,St as readSchemaHistory,ut as readSchemaVersion,Ue as readSearchBackfillState,He as readShapePokeCursor,kr as readStreamChunks,Br as readStreamRun,Io as readTablePage,Bo as recordCapturedMail,Wt as recordChangedKeys,Lo as recordFanoutPass,oa as recordQueueMessages,xt as recordSchemaVersion,Ua as relationHooks,Ha as relayCountFor,Lr as renderSql,nt as reprojectableFields,pn as reprojectionMigrationId,st as reprojectionTables,ma as resolveRankPartition,Fa as resolveRelationPredicates,qa as resolveWith,gr as rowToDocument,$e as runDataMigration,sr as runDrizzle,$r as runExternalSourceTick,Pt as runReadonlySql,wa as runRowValidators,un as runShardMigrations,yt as runSocketPool,ir as runSql,$t as runTriggers,rn as selectExpiredIds,i as selectExportTables,I as selectIndexForAggregate,L as selectIndexForCount,b as selectIndexForGroupBy,bo as selectMatchingIds,Qe as selectShapeMemberIds,je as selectShapeRows,Tt as serializeSqlValue,Xa as shapeRoutingKey,jo as softDeleteScope,pa as sortColumnName,br as sqliteInList,fn as stableStringify,En as stableWireKey,Gt as subscriptionFrames,Ut as subscriptionListDeltas,Mo as summarizeFanoutTopics,yo as summarizeSubscriptions,hr as tableColumns,tr as tableFromDepKey,u as throwingScheduler,re as trimCdcChanges,Le as trimIdempotent,Gr as trimStreamRuns,Cr as tryRowToDocument,qt as trySendFrame,Mr as unionAll,l as validateImportRow,ge as writeGlobalShapeSnapshot,be as writeIdempotent,Ra as writeReactorState,qe as writeSearchBackfillState,Xe as writeShapePokeCursor,vt as writeTouchesMemo};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{toErrorBody as R,LunoraError as k}from"@lunora/errors";import{e as A}from"./wire-codec-BU9T2xJ7.mjs";import{readStreamRun as T,deleteStreamRun as w,claimStreamRun as _,appendStreamChunk as b,finishStreamRun as E,trimStreamRuns as y,readStreamChunks as v}from"./appendStreamChunk-CH4e4nJn.mjs";const p=5e4,S=64*1024*1024,M=864e5,N=36e5,L=(i,e)=>{const r=i?.startedAt??e.live?.generation;return e.resuming&&e.generation!==void 0&&r!==void 0&&e.generation!==r?"interrupted":e.live!==void 0?"attach":i===void 0?e.resuming?"interrupted":"attach":i.status==="complete"||i.status==="error"?e.resuming?"replay-terminal":"reclaim":e.resuming?"interrupted":"reclaim"},O=(i,e,r)=>{(i||r())&&e.fail({code:"STREAM_INTERRUPTED",message:i?"the run this durable stream resumed from no longer exists; start a new run":"the producer for this durable stream did not survive; start a new run"})};class I{lastTrimAt=0;runs=new Map;sql;waitUntil;constructor(e){this.sql=e.sql,this.waitUntil=e.waitUntil}async attach(e){try{await this.attachOrThrow(e)}catch(r){const{body:t,redacted:o}=R(r,{fallbackCode:"INTERNAL_SERVER_ERROR",redactedMessage:"internal error"});o&&console.error("[@lunora/shard-engine] durable stream attach failed:",r),e.sink.fail({code:t.code,message:t.message})}}detach(e,r){this.runs.get(e)?.sinks.delete(r)}isLive(e){return this.runs.has(e)}async attachOrThrow(e){const r=this.sql(),{runKey:t,sinceChunk:o,sink:c}=e,n=T(r,t),u=o>0,s=this.runs.get(t),a=n?.startedAt??s?.generation,l=L(n,{generation:e.generation,live:s,resuming:u}),d=()=>{for(const g of v(r,t,o))if(!c.chunk({data:JSON.parse(g.dataJson),generation:a,seq:g.seq}))return!1;return!0};if(l==="replay-terminal"){d()&&(n?.status==="error"?c.fail({code:n.errorCode??"INTERNAL_SERVER_ERROR",message:n.error??"stream failed"}):c.complete());return}if(l==="interrupted"){O(e.generation!==void 0&&a!==void 0&&e.generation!==a,c,d);return}if(s){d()&&s.sinks.add(c);return}l==="reclaim"&&w(r,t),this.trim(r);const m=Math.max(Date.now(),n===void 0?0:n.startedAt+1);_(r,t,m,e.ttlMs??M);const h={generation:m,sinks:new Set([c])};this.runs.set(t,h);const f=this.produce(t,e.iterator,h);this.waitUntil?.(f),await f}async produce(e,r,t){const o=this.sql(),c=new AbortController;let n=0,u=0;try{for await(const s of r(c.signal)){const a=A(s),l=JSON.stringify(a);if(n+=1,u+=l.length,n>p||u>S)throw new k("STREAM_TOO_LONG",`durable stream exceeded its ceiling (${String(p)} chunks / ${String(S)} bytes); yield less, or drop \`durable\``,{status:507});b(o,e,n,l);for(const d of t.sinks)d.chunk({data:a,generation:t.generation,seq:n})||t.sinks.delete(d)}E(o,e,"complete",n);for(const s of t.sinks)s.complete()}catch(s){const{body:a,redacted:l}=R(s,{fallbackCode:"INTERNAL_SERVER_ERROR",redactedMessage:"internal error"});l&&console.error("[@lunora/shard-engine] unhandled durable stream error:",s),E(o,e,"error",n,{code:a.code,message:a.message});for(const d of t.sinks)d.fail({code:a.code,message:a.message})}finally{this.runs.delete(e)}}trim(e){const r=Date.now();if(!(r-this.lastTrimAt<=N)){this.lastTrimAt=r;try{y(e,r)}catch{}}}}export{I as DurableStreamRunner,S as MAX_DURABLE_STREAM_BYTES,p as MAX_DURABLE_STREAM_CHUNKS,L as decideDurableAttach};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lunora/shard-engine",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.36",
|
|
4
4
|
"description": "Host-neutral reactive engine for Lunora: per-shard state, OCC, CDC, reactive subscriptions, and the poke protocol. Consumes @lunora/platform host contracts and can be mounted on any platform host.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cloudflare",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
51
|
"@lunora/errors": "1.0.0-alpha.22",
|
|
52
|
-
"@lunora/platform": "1.0.0-alpha.
|
|
52
|
+
"@lunora/platform": "1.0.0-alpha.17",
|
|
53
53
|
"drizzle-orm": "^0.45.2"
|
|
54
54
|
},
|
|
55
55
|
"engines": {
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{toErrorBody as f,LunoraError as S}from"@lunora/errors";import{e as k}from"./wire-codec-BU9T2xJ7.mjs";import{readStreamRun as p,deleteStreamRun as T,claimStreamRun as _,appendStreamChunk as w,finishStreamRun as R,trimStreamRuns as A,readStreamChunks as y}from"./appendStreamChunk-CH4e4nJn.mjs";const E=5e4,g=64*1024*1024,b=864e5,M=36e5,N=(d,e)=>d===void 0||e.live?"attach":d.status==="complete"||d.status==="error"?e.resuming?"replay-terminal":"reclaim":e.resuming?"interrupted":"reclaim";class U{lastTrimAt=0;runs=new Map;sql;waitUntil;constructor(e){this.sql=e.sql,this.waitUntil=e.waitUntil}async attach(e){try{await this.attachOrThrow(e)}catch(r){const{body:t,redacted:i}=f(r,{fallbackCode:"INTERNAL_SERVER_ERROR",redactedMessage:"internal error"});i&&console.error("[@lunora/shard-engine] durable stream attach failed:",r),e.sink.fail({code:t.code,message:t.message})}}detach(e,r){this.runs.get(e)?.sinks.delete(r)}isLive(e){return this.runs.has(e)}async attachOrThrow(e){const r=this.sql(),{runKey:t,sinceChunk:i,sink:o}=e,s=p(r,t),u=i>0,a=this.runs.get(t),n=N(s,{live:a!==void 0,resuming:u}),c=()=>{for(const h of y(r,t,i))if(!o.chunk({data:JSON.parse(h.dataJson),seq:h.seq}))return!1;return!0};if(n==="replay-terminal"){c()&&(s?.status==="error"?o.fail({code:s.errorCode??"INTERNAL_SERVER_ERROR",message:s.error??"stream failed"}):o.complete());return}if(n==="interrupted"){c()&&o.fail({code:"STREAM_INTERRUPTED",message:"the producer for this durable stream did not survive; start a new run"});return}if(a){c()&&a.sinks.add(o);return}n==="reclaim"&&T(r,t),this.trim(r),_(r,t,Date.now(),e.ttlMs??b);const l={sinks:new Set([o])};this.runs.set(t,l);const m=this.produce(t,e.iterator,l);this.waitUntil?.(m),await m}async produce(e,r,t){const i=this.sql(),o=new AbortController;let s=0,u=0;try{for await(const a of r(o.signal)){const n=k(a),c=JSON.stringify(n);if(s+=1,u+=c.length,s>E||u>g)throw new S("STREAM_TOO_LONG",`durable stream exceeded its ceiling (${String(E)} chunks / ${String(g)} bytes); yield less, or drop \`durable\``,{status:507});w(i,e,s,c);for(const l of t.sinks)l.chunk({data:n,seq:s})||t.sinks.delete(l)}R(i,e,"complete",s);for(const a of t.sinks)a.complete()}catch(a){const{body:n,redacted:c}=f(a,{fallbackCode:"INTERNAL_SERVER_ERROR",redactedMessage:"internal error"});c&&console.error("[@lunora/shard-engine] unhandled durable stream error:",a),R(i,e,"error",s,{code:n.code,message:n.message});for(const l of t.sinks)l.fail({code:n.code,message:n.message})}finally{this.runs.delete(e)}}trim(e){const r=Date.now();if(!(r-this.lastTrimAt<=M)){this.lastTrimAt=r;try{A(e,r)}catch{}}}}export{U as DurableStreamRunner,g as MAX_DURABLE_STREAM_BYTES,E as MAX_DURABLE_STREAM_CHUNKS,N as decideDurableAttach};
|