@g9tm/syncdata 1.5.19 → 1.5.21
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/PARITY.md +9 -0
- package/dist/client/engine.d.ts +23 -1
- package/dist/client/engine.js +82 -1
- package/dist/client/engine.js.map +1 -1
- package/dist/client/storeTypes.d.ts +9 -0
- package/dist/client/storeTypes.js +5 -0
- package/dist/client/storeTypes.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/protocol/dtos.d.ts +16 -0
- package/dist/protocol/dtos.js.map +1 -1
- package/dist/protocol/wire.js +6 -0
- package/dist/protocol/wire.js.map +1 -1
- package/dist/signalr/transport.d.ts +9 -0
- package/dist/signalr/transport.js +34 -3
- package/dist/signalr/transport.js.map +1 -1
- package/dist/sqlite/revocation.d.ts +14 -0
- package/dist/sqlite/revocation.js +76 -0
- package/dist/sqlite/revocation.js.map +1 -1
- package/dist/sqlite/snapshotFiles.js.map +1 -1
- package/dist/sqlite/store.d.ts +2 -0
- package/dist/sqlite/store.js +12 -3
- package/dist/sqlite/store.js.map +1 -1
- package/package.json +1 -1
|
@@ -306,6 +306,11 @@ export declare const G9ERevocationReason: {
|
|
|
306
306
|
readonly Unsubscribed: 1;
|
|
307
307
|
readonly Expired: 2;
|
|
308
308
|
readonly AccessRevoked: 3;
|
|
309
|
+
/**
|
|
310
|
+
* A row the device adopted from its own table that no subscription holds and the server never confirmed, released by the
|
|
311
|
+
* application (`G9SyncEngine.releaseUnclaimedRows`, 1.5.19).
|
|
312
|
+
*/
|
|
313
|
+
readonly Unclaimed: 4;
|
|
309
314
|
};
|
|
310
315
|
export type G9ERevocationReason = (typeof G9ERevocationReason)[keyof typeof G9ERevocationReason];
|
|
311
316
|
/** `G9ERevocationDisposition`. */
|
|
@@ -463,6 +468,10 @@ export interface G9SyncClientStore {
|
|
|
463
468
|
/** Gives up the local change of rejected rows and takes the server's copy (LES-0070); run a forced reconcile after it. */
|
|
464
469
|
revertRejected(localTable: string | null, key: string | null, signal?: AbortSignal): Promise<number>;
|
|
465
470
|
markDirty(localTable: string, keys: readonly string[], signal?: AbortSignal): Promise<number>;
|
|
471
|
+
/** `RefetchRowsAsync` (1.5.19): clean held rows get `server_ver = -1` and their subscriptions NeedsReconcile. Returns the rows marked. */
|
|
472
|
+
refetchRows(localTable: string, keys: readonly string[] | null, signal?: AbortSignal): Promise<number>;
|
|
473
|
+
/** `ReleaseUnclaimedRowsAsync` (1.5.19): disposes adopted rows nothing holds and the server never claimed, capture off. */
|
|
474
|
+
releaseUnclaimedRows(localTable: string, keys: readonly string[] | null, includePending: boolean, signal?: AbortSignal): Promise<G9ApplyReport>;
|
|
466
475
|
adoptExistingRows(signal?: AbortSignal): Promise<number>;
|
|
467
476
|
saveRunReport(report: G9SyncRunReport, keep: number, signal?: AbortSignal): Promise<void>;
|
|
468
477
|
getRecentRunReports(count: number, signal?: AbortSignal): Promise<G9SyncRunReport[]>;
|
|
@@ -215,6 +215,11 @@ export const G9ERevocationReason = {
|
|
|
215
215
|
Unsubscribed: 1,
|
|
216
216
|
Expired: 2,
|
|
217
217
|
AccessRevoked: 3,
|
|
218
|
+
/**
|
|
219
|
+
* A row the device adopted from its own table that no subscription holds and the server never confirmed, released by the
|
|
220
|
+
* application (`G9SyncEngine.releaseUnclaimedRows`, 1.5.19).
|
|
221
|
+
*/
|
|
222
|
+
Unclaimed: 4,
|
|
218
223
|
};
|
|
219
224
|
/** `G9ERevocationDisposition`. */
|
|
220
225
|
export const G9ERevocationDisposition = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storeTypes.js","sourceRoot":"","sources":["../../src/client/storeTypes.ts"],"names":[],"mappings":"AAkCA,8BAA8B;AAC9B,MAAM,CAAC,MAAM,oBAAoB,GAAG;IAClC,MAAM,EAAE,CAAC;IACT,cAAc,EAAE,CAAC;IACjB,MAAM,EAAE,CAAC;CACD,CAAC;AAy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AAoB,GAAG;IAClC,KAAK,EAAE,CAAC;IACR,OAAO,EAAE,CAAC;IACV,QAAQ,EAAE,CAAC;IACX,IAAI,EAAE,CAAC;CACC,CAAC;AAQX,MAAM,UAAU,mBAAmB,CAAC,KAAc;IAChD,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,OAAQ,KAAyC,CAAC,iBAAiB,KAAK,QAAQ,CAAC;AACzI,CAAC","sourcesContent":["// Twins of G9SyncData.Client/Storage/*.cs: the client store contract, its records, local commands, revocation rules\r\n// and apply diagnostics. The engine is store-agnostic; `@g9tm/syncdata/sqlite` is the implementation.\r\nimport type { G9EMoveOutPolicy } from '../abstractions/enums.js';\r\nimport type { G9Long } from '../abstractions/long.js';\r\nimport type { G9SyncParameters } from '../abstractions/parameters.js';\r\nimport type {\r\n G9DtBackfillRequest,\r\n G9DtCommand,\r\n G9DtHelloResult,\r\n G9DtNegotiatedTable,\r\n G9DtPullContinuation,\r\n G9DtPullPlan,\r\n G9DtPushResult,\r\n G9DtSnapshotFileRequest,\r\n G9DtSubscriptionDefinition,\r\n G9DtSubscriptionRef,\r\n G9DtSyncChunk,\r\n G9DtTableColumns,\r\n G9DtTableDigest,\r\n} from '../protocol/dtos.js';\r\nimport type { G9SyncClientModel } from './model.js';\r\n\r\n// ---------------------------------------------------------------- server state and subscriptions\r\n\r\n/** What the client last learned from the server (`G9CClientServerState`). */\r\nexport interface G9ClientServerState {\r\n epoch: string | null;\r\n lastHelloUtcMs: number | null;\r\n /** Server clock minus device clock, ms. */\r\n serverClockOffsetMs: number;\r\n tables: G9DtNegotiatedTable[];\r\n definitions: G9DtSubscriptionDefinition[];\r\n}\r\n\r\n/** `G9ESubscriptionState`. */\r\nexport const G9ESubscriptionState = {\r\n Active: 0,\r\n NeedsReconcile: 1,\r\n Failed: 2,\r\n} as const;\r\nexport type G9ESubscriptionState = (typeof G9ESubscriptionState)[keyof typeof G9ESubscriptionState];\r\n\r\n/** A local subscription (`G9CSyncSubscriptionRecord`). Times are epoch milliseconds UTC. */\r\nexport interface G9SyncSubscriptionRecord {\r\n key: string;\r\n name: string;\r\n parameters: G9SyncParameters;\r\n /** Membership slot (bit) for persistent subscriptions; the shared ephemeral slot otherwise. */\r\n slot: number;\r\n ephemeral: boolean;\r\n ttlMs: number | null;\r\n cursor: string | null;\r\n /** The move-out policy the server last announced; kept so it still applies once access is gone. */\r\n moveOutPolicy: G9EMoveOutPolicy | null;\r\n definitionHash: string | null;\r\n authHash: string | null;\r\n state: G9ESubscriptionState;\r\n lastErrorCode: string | null;\r\n createdUtcMs: number;\r\n lastSuccessUtcMs: number | null;\r\n lastReconcileUtcMs: number | null;\r\n lastAccessUtcMs: number | null;\r\n}\r\n\r\n/** `G9CSyncSubscriptionRecord.ToReference()`. */\r\nexport function toSubscriptionRef(record: G9SyncSubscriptionRecord): G9DtSubscriptionRef {\r\n return {\r\n name: record.name,\r\n parameters: record.parameters.values,\r\n cursor: record.cursor,\r\n definitionHash: record.definitionHash,\r\n authHash: record.authHash,\r\n };\r\n}\r\n\r\n/** A partial update of a subscription record; absent members are left unchanged (`G9CSubscriptionUpdate`). */\r\nexport interface G9SubscriptionUpdate {\r\n cursor?: string | null;\r\n definitionHash?: string | null;\r\n authHash?: string | null;\r\n state?: G9ESubscriptionState | null;\r\n errorCode?: string | null;\r\n clearError?: boolean;\r\n succeeded?: boolean;\r\n reconciled?: boolean;\r\n accessed?: boolean;\r\n clearCursor?: boolean;\r\n}\r\n\r\n// ---------------------------------------------------------------- push and pull\r\n\r\n/** A push batch built from dirty rows (`G9CPushBatch`). */\r\nexport interface G9PushBatch {\r\n batchId: number;\r\n /** Highest local change sequence included; rows changed after it stay dirty after the acknowledgement. */\r\n maxSequence: number;\r\n frames: Uint8Array[];\r\n tables: G9DtTableColumns[];\r\n rowCount: number;\r\n /** True when the byte budget ended the batch early: more pending rows follow. */\r\n truncated: boolean;\r\n /** Rows rejected on the device while building the batch (G9S-REJ-TOO-LARGE). */\r\n rejectedLocally: number;\r\n /** Commands carried by this batch, in device order. */\r\n commands: G9DtCommand[];\r\n}\r\n\r\n/** A pull being staged, persisted across restarts (`G9CStagedPull`). */\r\nexport interface G9StagedPull {\r\n runId: string;\r\n plan: G9DtPullPlan;\r\n createdUtcMs: number;\r\n backfills: G9DtBackfillRequest[];\r\n /** What the world looked like when the plan was made (ADR-0046); a run only resumes a stage whose generation matches. */\r\n generation: string | null;\r\n /** The cursor each planned subscription had when the plan was made, by subscription key (ADR-0060). */\r\n plannedFromCursors: { [subscriptionKey: string]: string | null };\r\n /** The device clock when the stage began, assigned by the store. */\r\n stageSequence: number;\r\n}\r\n\r\n/** One committed slice of a staged pull (`G9CApplySlice`). */\r\nexport interface G9ApplySlice {\r\n report: G9ApplyReport;\r\n rowsApplied: number;\r\n rowsAppliedTotal: number;\r\n rowsPlanned: number;\r\n isFinal: boolean;\r\n}\r\n\r\n/** `G9CResumePoint`. */\r\nexport interface G9ResumePoint {\r\n continuation: G9DtPullContinuation | null;\r\n stagedRows: number;\r\n stagedBytes: number;\r\n complete: boolean;\r\n}\r\n\r\n// ---------------------------------------------------------------- reports\r\n\r\n/** Why a table large enough for index deferral kept its indexes live. */\r\nexport const REASON_TABLE_NOT_EMPTY = 'table-not-empty';\r\nconst MAX_FOREIGN_TRIGGER_NAMES = 10;\r\n\r\n/** How an apply ran, as opposed to what it changed (`G9CApplyDiagnostics`, ADR-0058). */\r\n/** A file table copied record for record into an empty table with identical columns (the transfer optimisation). */\r\nexport const FILE_MODE_COPY = 'copy';\r\n/** A file table copied into an empty table by column name. */\r\nexport const FILE_MODE_COLUMNS = 'columns';\r\n/** A file table merged into a table that held rows or protected rows: changed rows only. */\r\nexport const FILE_MODE_MERGE = 'merge';\r\n/** A file table inserted into a table holding only OTHER rows (a second site's first load): every row is new, no per-row diff. */\r\nexport const FILE_MODE_APPEND = 'append';\r\n\r\nexport class G9ApplyDiagnostics {\r\n transactions = 0;\r\n transactionsWithTriggersSkipped = 0;\r\n readonly foreignTriggers: string[] = [];\r\n readonly deferredIndexes: { [table: string]: number } = {};\r\n readonly liveIndexReasons: { [table: string]: string } = {};\r\n readonly rowsByTable: { [table: string]: number } = {};\r\n readonly msByTable: { [table: string]: number } = {};\r\n indexRebuildMs = 0;\r\n elapsedMs = 0;\r\n /** Snapshot files copied in (ADR-0072). */\r\n snapshotFiles = 0;\r\n /** Rows that arrived through snapshot files. */\r\n fileRows = 0;\r\n /** Milliseconds spent copying snapshot files, metadata included. */\r\n fileCopyMs = 0;\r\n /** How each table came out of a snapshot file: `copy`, `columns` or `merge` (see FILE_MODE_*). */\r\n readonly fileTables: { [table: string]: string } = {};\r\n\r\n /** True when every transaction ran with trigger execution off, false when any ran with it on, null when nothing was applied. */\r\n get triggersSkipped(): boolean | null {\r\n return this.transactions === 0 ? null : this.transactionsWithTriggersSkipped === this.transactions;\r\n }\r\n\r\n get deferredIndexCount(): number {\r\n let total = 0;\r\n for (const key of Object.keys(this.deferredIndexes)) total += this.deferredIndexes[key] as number;\r\n return total;\r\n }\r\n\r\n merge(other: G9ApplyDiagnostics): void {\r\n this.transactions += other.transactions;\r\n this.transactionsWithTriggersSkipped += other.transactionsWithTriggersSkipped;\r\n this.indexRebuildMs += other.indexRebuildMs;\r\n this.elapsedMs += other.elapsedMs;\r\n this.snapshotFiles += other.snapshotFiles;\r\n this.fileRows += other.fileRows;\r\n this.fileCopyMs += other.fileCopyMs;\r\n for (const key of Object.keys(other.fileTables)) this.fileTables[key] = other.fileTables[key] as string;\r\n for (const name of other.foreignTriggers) {\r\n if (this.foreignTriggers.length >= MAX_FOREIGN_TRIGGER_NAMES) break;\r\n if (!this.foreignTriggers.some((n) => n.toLowerCase() === name.toLowerCase())) this.foreignTriggers.push(name);\r\n }\r\n addAll(this.deferredIndexes, other.deferredIndexes);\r\n for (const key of Object.keys(other.liveIndexReasons)) this.liveIndexReasons[key] = other.liveIndexReasons[key] as string;\r\n addAll(this.rowsByTable, other.rowsByTable);\r\n addAll(this.msByTable, other.msByTable);\r\n }\r\n\r\n /** One line for a log: what engaged, what did not and why, and the tables that took the time. */\r\n toString(): string {\r\n if (this.transactions === 0) return 'nothing applied';\r\n let text = `${this.transactions} transaction(s) in ${this.elapsedMs} ms; triggers `;\r\n text +=\r\n this.triggersSkipped === true\r\n ? 'skipped'\r\n : this.transactionsWithTriggersSkipped === 0\r\n ? 'LIVE'\r\n : `skipped in ${this.transactionsWithTriggersSkipped} of ${this.transactions}`;\r\n if (this.foreignTriggers.length > 0) text += ' (foreign: ' + this.foreignTriggers.join(', ') + ')';\r\n const deferred = Object.keys(this.deferredIndexes);\r\n if (deferred.length > 0) {\r\n text += `; ${this.deferredIndexCount} index(es) rebuilt after the load in ${this.indexRebuildMs} ms (` + deferred.map((t) => t + ':' + this.deferredIndexes[t]).join(', ') + ')';\r\n }\r\n const live = Object.keys(this.liveIndexReasons);\r\n if (live.length > 0) text += '; live indexes on ' + live.map((t) => t + ' (' + this.liveIndexReasons[t] + ')').join(', ');\r\n if (this.snapshotFiles > 0) {\r\n text +=\r\n `; ${this.snapshotFiles} snapshot file(s), ${this.fileRows} rows copied in ${this.fileCopyMs} ms (` +\r\n Object.keys(this.fileTables)\r\n .map((t) => t + ':' + this.fileTables[t])\r\n .join(', ') +\r\n ')';\r\n }\r\n const slowest = Object.keys(this.msByTable)\r\n .sort((a, b) => (this.msByTable[b] as number) - (this.msByTable[a] as number))\r\n .slice(0, 4);\r\n if (slowest.length > 0) {\r\n text +=\r\n '; ' +\r\n slowest\r\n .map((t) => {\r\n const ms = this.msByTable[t] as number;\r\n const rows = this.rowsByTable[t] ?? 0;\r\n const rate = ms > 0 ? Math.floor((rows * 1000) / ms) : rows;\r\n return `${t} ${rows} rows in ${ms} ms (${rate}/s)`;\r\n })\r\n .join(', ');\r\n }\r\n return text;\r\n }\r\n}\r\n\r\nfunction addAll(target: { [key: string]: number }, source: { [key: string]: number }): void {\r\n for (const key of Object.keys(source)) target[key] = (target[key] ?? 0) + (source[key] as number);\r\n}\r\n\r\n/** What an apply changed (`G9CApplyReport`). */\r\nexport class G9ApplyReport {\r\n upserts = 0;\r\n deletes = 0;\r\n moveOuts = 0;\r\n membershipAdded = 0;\r\n /** Rows skipped because they carry a pending local change. */\r\n skippedDirty = 0;\r\n accepted = 0;\r\n rejected = 0;\r\n conflicts = 0;\r\n /** Conflicts the device lost that were kept on it as rejections (LES-0072). */\r\n conflictsKept = 0;\r\n /** Conflicts the device lost on paper only: the server already held its values for every lost column (LES-0085). */\r\n conflictsSameValue = 0;\r\n commandsCompleted = 0;\r\n revokedDeleted = 0;\r\n revokedQuarantined = 0;\r\n revokedRetained = 0;\r\n /** Changed keys per local table (capped per table). */\r\n readonly changedKeys: { [localTable: string]: string[] } = {};\r\n /** Upserts whose row already held exactly the incoming values (ADR-0058). */\r\n unchangedRows = 0;\r\n readonly diagnostics = new G9ApplyDiagnostics();\r\n\r\n get total(): number {\r\n return this.upserts + this.deletes + this.moveOuts;\r\n }\r\n\r\n merge(other: G9ApplyReport): void {\r\n this.unchangedRows += other.unchangedRows;\r\n this.diagnostics.merge(other.diagnostics);\r\n this.upserts += other.upserts;\r\n this.deletes += other.deletes;\r\n this.moveOuts += other.moveOuts;\r\n this.membershipAdded += other.membershipAdded;\r\n this.skippedDirty += other.skippedDirty;\r\n this.accepted += other.accepted;\r\n this.rejected += other.rejected;\r\n this.conflicts += other.conflicts;\r\n this.conflictsKept += other.conflictsKept;\r\n this.conflictsSameValue += other.conflictsSameValue;\r\n this.commandsCompleted += other.commandsCompleted;\r\n this.revokedDeleted += other.revokedDeleted;\r\n this.revokedQuarantined += other.revokedQuarantined;\r\n this.revokedRetained += other.revokedRetained;\r\n for (const table of Object.keys(other.changedKeys)) {\r\n const list = this.changedKeys[table] ?? (this.changedKeys[table] = []);\r\n for (const key of other.changedKeys[table] as string[]) list.push(key);\r\n }\r\n }\r\n}\r\n\r\n/** A local row as seen by reconciliation (`G9CLocalRowEntry`). */\r\nexport interface G9LocalRowEntry {\r\n key: string;\r\n bucket: number;\r\n version: number;\r\n hash: G9Long;\r\n member: boolean;\r\n dirty: boolean;\r\n}\r\n\r\nexport interface G9PendingTable {\r\n localTable: string;\r\n upserts: number;\r\n deletes: number;\r\n rejected: number;\r\n}\r\n\r\nexport interface G9PendingSummary {\r\n totalRows: number;\r\n rejectedRows: number;\r\n /** Commands recorded on the device and not yet executed by the server. */\r\n pendingCommands: number;\r\n tables: G9PendingTable[];\r\n}\r\n\r\n/** One entry of the local change feed (`G9CChangeFeedEntry`). */\r\nexport interface G9ChangeFeedEntry {\r\n sequence: number;\r\n key: string;\r\n deleted: boolean;\r\n localPending: boolean;\r\n}\r\n\r\n/**\r\n * Narrows a change-feed read to the keys a query of the app's own tables selects (`G9CChangeFeedKeyFilter`): a projection of one\r\n * site no longer walks the entries of every other site. Deletions are always returned - their rows are gone, so no query can place\r\n * them. `keySql` is one SELECT of one column, embedded as `pk IN (...)`; parameters are bound by name (`$name`, `@name`, `:name`)\r\n * and `$g9t`, `$g9a`, `$g9l` belong to the read.\r\n */\r\nexport interface G9ChangeFeedKeyFilter {\r\n keySql: string;\r\n parameters?: { [name: string]: string | number | null };\r\n}\r\n\r\nconst RESERVED_FEED_PARAMETERS = ['$g9t', '$g9a', '$g9l'];\r\n\r\n/** Throws when the filter cannot be embedded safely (`G9CChangeFeedKeyFilter.Validate`). */\r\nexport function validateChangeFeedKeyFilter(filter: G9ChangeFeedKeyFilter): void {\r\n const sql = (filter.keySql ?? '').trim();\r\n if (sql.slice(0, 6).toUpperCase() !== 'SELECT' || sql.indexOf(';') >= 0) {\r\n throw new Error('A change-feed key filter is a single SELECT statement of one column.');\r\n }\r\n for (const name of Object.keys(filter.parameters ?? {})) {\r\n if (name.length < 2 || '$@:'.indexOf(name[0] as string) < 0) throw new Error(`Change-feed key filter parameter '${name}' must be named ($name, @name or :name).`);\r\n if (RESERVED_FEED_PARAMETERS.indexOf(name.toLowerCase()) >= 0) throw new Error(`Change-feed key filter parameter '${name}' is reserved by the read.`);\r\n }\r\n}\r\n\r\nexport interface G9SyncRejection {\r\n localTable: string;\r\n key: string;\r\n code: string;\r\n message: string | null;\r\n sqlState: string | null;\r\n constraint: string | null;\r\n column: string | null;\r\n details: string | null;\r\n atUtcMs: number;\r\n}\r\n\r\n/** A persisted summary of one run (`G9CSyncRunReport`); serialized with the .NET JSON names into g9_runs. */\r\nexport interface G9SyncRunReport {\r\n runId: string;\r\n startedUtcMs: number;\r\n durationMs: number;\r\n outcome: string;\r\n priority: string;\r\n errorCode: string | null;\r\n errorMessage: string | null;\r\n pushed: number;\r\n rejected: number;\r\n conflicts: number;\r\n downloaded: number;\r\n applied: number;\r\n downloadedBytes: number;\r\n subscriptions: string[];\r\n phaseMs: { [phase: string]: number };\r\n triggersSkipped: boolean | null;\r\n foreignTriggers: string[];\r\n applyTransactions: number;\r\n indexesDeferred: number;\r\n indexRebuildMs: number;\r\n liveIndexReasons: { [table: string]: string };\r\n unchangedRows: number;\r\n}\r\n\r\n// ---------------------------------------------------------------- local commands (ADR-0025)\r\n\r\n/** `G9ELocalCommandState`. */\r\nexport const G9ELocalCommandState = {\r\n Pending: 0,\r\n Ok: 1,\r\n Rejected: 2,\r\n Superseded: 3,\r\n} as const;\r\nexport type G9ELocalCommandState = (typeof G9ELocalCommandState)[keyof typeof G9ELocalCommandState];\r\n\r\n/** A command recorded on this device (`G9CLocalCommand`). */\r\nexport interface G9LocalCommand {\r\n commandId: string;\r\n sequence: number;\r\n name: string;\r\n version: number;\r\n payload: string;\r\n createdUtcMs: number;\r\n state: G9ELocalCommandState;\r\n code: string | null;\r\n message: string | null;\r\n result: string | null;\r\n completedUtcMs: number | null;\r\n}\r\n\r\n/** What to record (`G9CCommandRequest`). */\r\nexport interface G9CommandRequest {\r\n name: string;\r\n version?: number;\r\n /** JSON payload for the server's handler. */\r\n payload: string;\r\n}\r\n\r\n/** A value an app binds through {@link G9LocalCommandWriter}: the SQLite driver's value forms, plus booleans. */\r\nexport type G9LocalSqlArgument = null | number | string | boolean | ArrayBuffer | Uint8Array | { int64: string } | G9Long;\r\n\r\n/**\r\n * Writes a command's local effects in the transaction that records it (`IG9LocalCommandWriter`). Rows written here are\r\n * not uploaded as row changes; they are protected from pulls until the server's result arrives.\r\n */\r\nexport interface G9LocalCommandWriter {\r\n /** Executes SQL; parameters bind positionally as `$p0`, `$p1`, … */\r\n execute(sql: string, ...args: G9LocalSqlArgument[]): Promise<number>;\r\n scalar(sql: string, ...args: G9LocalSqlArgument[]): Promise<unknown>;\r\n}\r\n\r\n// ---------------------------------------------------------------- revocation (ADR-0026)\r\n\r\n/** `G9ERevocationReason`. */\r\nexport const G9ERevocationReason = {\r\n LeftScope: 0,\r\n Unsubscribed: 1,\r\n Expired: 2,\r\n AccessRevoked: 3,\r\n} as const;\r\nexport type G9ERevocationReason = (typeof G9ERevocationReason)[keyof typeof G9ERevocationReason];\r\n\r\n/** `G9ERevocationDisposition`. */\r\nexport const G9ERevocationDisposition = {\r\n Delete: 0,\r\n MarkRevoked: 1,\r\n Quarantine: 2,\r\n Retain: 3,\r\n} as const;\r\nexport type G9ERevocationDisposition = (typeof G9ERevocationDisposition)[keyof typeof G9ERevocationDisposition];\r\n\r\n/** A row no subscription holds any more, as a revocation rule sees it (`G9CRevokedRow`). */\r\nexport interface G9RevokedRow {\r\n localTable: string;\r\n key: string;\r\n reason: G9ERevocationReason;\r\n subscriptionKey: string | null;\r\n hasPendingChanges: boolean;\r\n isRejected: boolean;\r\n /** Column values (key included) as stored locally; empty when the row no longer exists locally. */\r\n values: { [column: string]: unknown };\r\n}\r\n\r\n/** Lets a custom rule change the row before its disposition applies. */\r\nexport interface G9RevokedRowEditor {\r\n set(column: string, value: unknown): void;\r\n}\r\n\r\nexport interface G9RevocationRule {\r\n readonly name: string;\r\n readonly condition: (row: G9RevokedRow) => boolean;\r\n readonly decide: (row: G9RevokedRow, editor: G9RevokedRowEditor) => G9ERevocationDisposition;\r\n readonly retainWhile: ((row: G9RevokedRow) => boolean) | null;\r\n}\r\n\r\n/** Ordered revocation rules (`G9CRevocationPolicy`): the first matching rule decides. */\r\nexport class G9RevocationPolicy {\r\n readonly rules: readonly G9RevocationRule[];\r\n\r\n private constructor(rules: readonly G9RevocationRule[]) {\r\n this.rules = rules;\r\n }\r\n\r\n /** No rules: delete clean rows, quarantine rows with pending changes. */\r\n static readonly default = new G9RevocationPolicy([]);\r\n\r\n static create(configure: (builder: G9RevocationPolicyBuilder) => void): G9RevocationPolicy {\r\n const builder = new G9RevocationPolicyBuilder();\r\n configure(builder);\r\n return new G9RevocationPolicy(builder.rules.slice());\r\n }\r\n\r\n decide(row: G9RevokedRow, editor: G9RevokedRowEditor): { rule: G9RevocationRule | null; disposition: G9ERevocationDisposition } {\r\n for (const rule of this.rules) {\r\n if (rule.condition(row)) return { rule, disposition: rule.decide(row, editor) };\r\n }\r\n return { rule: null, disposition: row.hasPendingChanges ? G9ERevocationDisposition.Quarantine : G9ERevocationDisposition.Delete };\r\n }\r\n\r\n find(name: string): G9RevocationRule | null {\r\n for (const rule of this.rules) if (rule.name === name) return rule;\r\n return null;\r\n }\r\n}\r\n\r\nexport class G9RevocationPolicyBuilder {\r\n readonly rules: G9RevocationRule[] = [];\r\n\r\n when(name: string, condition: (row: G9RevokedRow) => boolean): G9RevocationActionBuilder {\r\n if (typeof name !== 'string' || name.trim() === '') throw new TypeError('A rule needs a name.');\r\n if (this.rules.some((r) => r.name === name)) throw new RangeError(`Revocation rule '${name}' is declared twice.`);\r\n return new G9RevocationActionBuilder(this, name, condition);\r\n }\r\n\r\n /** Rows of one local table. */\r\n forTable(name: string, localTable: string, condition?: (row: G9RevokedRow) => boolean): G9RevocationActionBuilder {\r\n const table = localTable.toLowerCase();\r\n return this.when(name, (row) => row.localTable.toLowerCase() === table && (condition ? condition(row) : true));\r\n }\r\n}\r\n\r\nexport class G9RevocationActionBuilder {\r\n private readonly _owner: G9RevocationPolicyBuilder;\r\n private readonly _name: string;\r\n private readonly _condition: (row: G9RevokedRow) => boolean;\r\n\r\n constructor(owner: G9RevocationPolicyBuilder, name: string, condition: (row: G9RevokedRow) => boolean) {\r\n this._owner = owner;\r\n this._name = name;\r\n this._condition = condition;\r\n }\r\n\r\n delete(): G9RevocationPolicyBuilder {\r\n return this._add(() => G9ERevocationDisposition.Delete, null);\r\n }\r\n\r\n markRevoked(): G9RevocationPolicyBuilder {\r\n return this._add(() => G9ERevocationDisposition.MarkRevoked, null);\r\n }\r\n\r\n quarantine(): G9RevocationPolicyBuilder {\r\n return this._add(() => G9ERevocationDisposition.Quarantine, null);\r\n }\r\n\r\n retainWhile(retainWhile: (row: G9RevokedRow) => boolean): G9RevocationPolicyBuilder {\r\n return this._add(() => G9ERevocationDisposition.Retain, retainWhile);\r\n }\r\n\r\n custom(decide: (row: G9RevokedRow, editor: G9RevokedRowEditor) => G9ERevocationDisposition): G9RevocationPolicyBuilder {\r\n return this._add(decide, null);\r\n }\r\n\r\n private _add(\r\n decide: (row: G9RevokedRow, editor: G9RevokedRowEditor) => G9ERevocationDisposition,\r\n retainWhile: ((row: G9RevokedRow) => boolean) | null,\r\n ): G9RevocationPolicyBuilder {\r\n this._owner.rules.push({ name: this._name, condition: this._condition, decide, retainWhile });\r\n return this._owner;\r\n }\r\n}\r\n\r\n/** A row in the holding area (`G9CQuarantinedRow`). */\r\nexport interface G9QuarantinedRow {\r\n localTable: string;\r\n key: string;\r\n reason: G9ERevocationReason;\r\n rule: string | null;\r\n hadPendingChanges: boolean;\r\n values: { [column: string]: unknown };\r\n atUtcMs: number;\r\n}\r\n\r\n/** A row kept in the app's table after revocation (`G9CRetainedRow`). */\r\nexport interface G9RetainedRow {\r\n localTable: string;\r\n key: string;\r\n disposition: G9ERevocationDisposition;\r\n reason: G9ERevocationReason;\r\n rule: string | null;\r\n atUtcMs: number;\r\n}\r\n\r\n// ---------------------------------------------------------------- failures\r\n\r\n/** What went wrong inside a client store, in terms an application can act on (`G9ELocalStoreFailure`). */\r\nexport const G9ELocalStoreFailure = {\r\n Other: 0,\r\n Corrupt: 1,\r\n DiskFull: 2,\r\n Busy: 3,\r\n} as const;\r\nexport type G9ELocalStoreFailure = (typeof G9ELocalStoreFailure)[keyof typeof G9ELocalStoreFailure];\r\n\r\n/** Implemented by a store's errors so the engine can give a run's failure a stable code (`IG9SyncLocalStoreFailure`). */\r\nexport interface G9SyncLocalStoreFailure {\r\n readonly localStoreFailure: G9ELocalStoreFailure;\r\n}\r\n\r\nexport function isLocalStoreFailure(error: unknown): error is G9SyncLocalStoreFailure {\r\n return typeof error === 'object' && error !== null && typeof (error as { localStoreFailure?: unknown }).localStoreFailure === 'number';\r\n}\r\n\r\n// ---------------------------------------------------------------- the store contract\r\n\r\n/**\r\n * The client storage provider (`IG9SyncClientStore`): local tables, change capture, subscription membership,\r\n * staging, apply and metadata. Every method takes an optional AbortSignal (the CancellationToken twin).\r\n */\r\nexport interface G9SyncClientStore {\r\n initialize(model: G9SyncClientModel, signal?: AbortSignal): Promise<void>;\r\n getClientId(signal?: AbortSignal): Promise<string>;\r\n getServerState(signal?: AbortSignal): Promise<G9ClientServerState>;\r\n /**\r\n * Stores the Hello answer. `localMidpointMs`: the local time the server's clock reading corresponds to - the midpoint of the round\r\n * trip (LES-0075); the offset is then exact up to the asymmetry of the two legs. Omitted: the time of this call.\r\n */\r\n saveHello(hello: G9DtHelloResult, signal?: AbortSignal, localMidpointMs?: number): Promise<void>;\r\n getPendingBackfills(signal?: AbortSignal): Promise<G9DtBackfillRequest[]>;\r\n\r\n getSubscriptions(signal?: AbortSignal): Promise<G9SyncSubscriptionRecord[]>;\r\n ensureSubscription(\r\n name: string,\r\n parameters: G9SyncParameters,\r\n ephemeral: boolean,\r\n ttlMs: number | null,\r\n adoptExistingRows: boolean,\r\n signal?: AbortSignal,\r\n ): Promise<G9SyncSubscriptionRecord>;\r\n removeSubscription(key: string, policy: G9EMoveOutPolicy, signal?: AbortSignal): Promise<void>;\r\n releaseSubscriptionRows(key: string, signal?: AbortSignal): Promise<G9ApplyReport>;\r\n updateSubscription(key: string, update: G9SubscriptionUpdate, signal?: AbortSignal): Promise<void>;\r\n collectExpiredEphemeral(utcNowMs: number, signal?: AbortSignal): Promise<number>;\r\n\r\n buildPushBatch(tables: readonly G9DtNegotiatedTable[], maxRows: number, maxBytes: number, signal?: AbortSignal): Promise<G9PushBatch | null>;\r\n forgetUploadedRows(localTable: string, keys: readonly string[] | null, signal?: AbortSignal): Promise<number>;\r\n applyPushResult(batch: G9PushBatch, result: G9DtPushResult, signal?: AbortSignal): Promise<G9ApplyReport>;\r\n\r\n getStagedPull(signal?: AbortSignal): Promise<G9StagedPull | null>;\r\n /** The newest staged pull planned under exactly this generation, or null (ADR-0060). */\r\n getStagedPullForGeneration(generation: string, signal?: AbortSignal): Promise<G9StagedPull | null>;\r\n beginStagedPull(pull: G9StagedPull, signal?: AbortSignal): Promise<void>;\r\n pruneStagedPulls(olderThanUtcMs: number, maxBytes: number, keepGeneration: string | null, signal?: AbortSignal): Promise<number>;\r\n discardAllStagedPulls(signal?: AbortSignal): Promise<number>;\r\n stageChunk(runId: string, chunk: G9DtSyncChunk, signal?: AbortSignal): Promise<void>;\r\n /**\r\n * The store's offer to receive large first downloads as SQLite snapshot files (ADR-0072), or null for rows only. A store that\r\n * makes an offer stages file segments (`chunk.file`) in `stageChunk` and copies the files in `applyStagedPull`.\r\n */\r\n describeSnapshotFiles?(negotiated: readonly G9DtNegotiatedTable[]): G9DtSnapshotFileRequest | null;\r\n getResumePoint(runId: string, signal?: AbortSignal): Promise<G9ResumePoint>;\r\n applyStagedPull(\r\n runId: string,\r\n rowsApplied: ((rows: number) => void) | null,\r\n slices: ((slice: G9ApplySlice) => void) | null,\r\n signal?: AbortSignal,\r\n ): Promise<G9ApplyReport>;\r\n discardStagedPull(runId: string, signal?: AbortSignal): Promise<void>;\r\n\r\n computeDigest(subscriptionKey: string, table: G9DtNegotiatedTable, signal?: AbortSignal): Promise<G9DtTableDigest>;\r\n readLocalEntries(\r\n subscriptionKey: string,\r\n table: G9DtNegotiatedTable,\r\n buckets: ReadonlySet<number>,\r\n serverKeys: ReadonlySet<string>,\r\n signal?: AbortSignal,\r\n ): Promise<G9LocalRowEntry[]>;\r\n applyReconcile(\r\n subscriptionKey: string,\r\n table: G9DtNegotiatedTable,\r\n fetchedFrames: readonly Uint8Array[],\r\n addMembership: readonly string[],\r\n moveOut: readonly string[],\r\n policy: G9EMoveOutPolicy,\r\n signal?: AbortSignal,\r\n ): Promise<G9ApplyReport>;\r\n\r\n getPendingSummary(signal?: AbortSignal): Promise<G9PendingSummary>;\r\n enqueueCommand(\r\n request: G9CommandRequest,\r\n applyLocally: ((writer: G9LocalCommandWriter, signal?: AbortSignal) => Promise<void>) | null,\r\n signal?: AbortSignal,\r\n ): Promise<G9LocalCommand>;\r\n getQuarantined(signal?: AbortSignal): Promise<G9QuarantinedRow[]>;\r\n restoreQuarantined(localTable: string, key: string, signal?: AbortSignal): Promise<number>;\r\n discardQuarantined(localTable: string | null, key: string | null, signal?: AbortSignal): Promise<number>;\r\n getRetained(signal?: AbortSignal): Promise<G9RetainedRow[]>;\r\n reevaluateRetained(signal?: AbortSignal): Promise<number>;\r\n getCommands(state: G9ELocalCommandState | null, limit: number, signal?: AbortSignal): Promise<G9LocalCommand[]>;\r\n readChangeFeed(localTable: string, afterSequence: number, limit: number, signal?: AbortSignal): Promise<G9ChangeFeedEntry[]>;\r\n /** The feed narrowed to the keys `keyFilter` selects, plus every deletion; fewer than `limit` entries means the read is complete. */\r\n readChangeFeedFiltered(localTable: string, afterSequence: number, limit: number, keyFilter: G9ChangeFeedKeyFilter, signal?: AbortSignal): Promise<G9ChangeFeedEntry[]>;\r\n getChangeSequence(signal?: AbortSignal): Promise<number>;\r\n getChangeFeedFloor(signal?: AbortSignal): Promise<number>;\r\n getRejections(signal?: AbortSignal): Promise<G9SyncRejection[]>;\r\n retryRejected(localTable: string | null, key: string | null, signal?: AbortSignal): Promise<number>;\r\n /** Gives up the local change of rejected rows and takes the server's copy (LES-0070); run a forced reconcile after it. */\r\n revertRejected(localTable: string | null, key: string | null, signal?: AbortSignal): Promise<number>;\r\n markDirty(localTable: string, keys: readonly string[], signal?: AbortSignal): Promise<number>;\r\n adoptExistingRows(signal?: AbortSignal): Promise<number>;\r\n saveRunReport(report: G9SyncRunReport, keep: number, signal?: AbortSignal): Promise<void>;\r\n getRecentRunReports(count: number, signal?: AbortSignal): Promise<G9SyncRunReport[]>;\r\n getPhaseStatistics(signal?: AbortSignal): Promise<{ [key: string]: number }>;\r\n recordPhaseStatistics(samples: { [key: string]: number }, signal?: AbortSignal): Promise<void>;\r\n purgeDeletedFeed(keep: number, signal?: AbortSignal): Promise<number>;\r\n dispose(): Promise<void>;\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"storeTypes.js","sourceRoot":"","sources":["../../src/client/storeTypes.ts"],"names":[],"mappings":"AAkCA,8BAA8B;AAC9B,MAAM,CAAC,MAAM,oBAAoB,GAAG;IAClC,MAAM,EAAE,CAAC;IACT,cAAc,EAAE,CAAC;IACjB,MAAM,EAAE,CAAC;CACD,CAAC;AAyBX,iDAAiD;AACjD,MAAM,UAAU,iBAAiB,CAAC,MAAgC;IAChE,OAAO;QACL,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,UAAU,EAAE,MAAM,CAAC,UAAU,CAAC,MAAM;QACpC,MAAM,EAAE,MAAM,CAAC,MAAM;QACrB,cAAc,EAAE,MAAM,CAAC,cAAc;QACrC,QAAQ,EAAE,MAAM,CAAC,QAAQ;KAC1B,CAAC;AACJ,CAAC;AAiED,2EAA2E;AAE3E,yEAAyE;AACzE,MAAM,CAAC,MAAM,sBAAsB,GAAG,iBAAiB,CAAC;AACxD,MAAM,yBAAyB,GAAG,EAAE,CAAC;AAErC,yFAAyF;AACzF,oHAAoH;AACpH,MAAM,CAAC,MAAM,cAAc,GAAG,MAAM,CAAC;AACrC,8DAA8D;AAC9D,MAAM,CAAC,MAAM,iBAAiB,GAAG,SAAS,CAAC;AAC3C,4FAA4F;AAC5F,MAAM,CAA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;IACrE,CAAC;IAED,UAAU;QACR,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,wBAAwB,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;IACpE,CAAC;IAED,WAAW,CAAC,WAA2C;QACrD,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,wBAAwB,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;IACvE,CAAC;IAED,MAAM,CAAC,MAAmF;QACxF,OAAO,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IACjC,CAAC;IAEO,IAAI,CACV,MAAmF,EACnF,WAAoD;QAEpD,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,KAAK,EAAE,SAAS,EAAE,IAAI,CAAC,UAAU,EAAE,MAAM,EAAE,WAAW,EAAE,CAAC,CAAC;QAC9F,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;CACF;AAuBD,4EAA4E;AAE5E,0GAA0G;AAC1G,MAAM,CAAC,MAAM,oBAAoB,GAAG;IAClC,KAAK,EAAE,CAAC;IACR,OAAO,EAAE,CAAC;IACV,QAAQ,EAAE,CAAC;IACX,IAAI,EAAE,CAAC;CACC,CAAC;AAQX,MAAM,UAAU,mBAAmB,CAAC,KAAc;IAChD,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,OAAQ,KAAyC,CAAC,iBAAiB,KAAK,QAAQ,CAAC;AACzI,CAAC","sourcesContent":["// Twins of G9SyncData.Client/Storage/*.cs: the client store contract, its records, local commands, revocation rules\r\n// and apply diagnostics. The engine is store-agnostic; `@g9tm/syncdata/sqlite` is the implementation.\r\nimport type { G9EMoveOutPolicy } from '../abstractions/enums.js';\r\nimport type { G9Long } from '../abstractions/long.js';\r\nimport type { G9SyncParameters } from '../abstractions/parameters.js';\r\nimport type {\r\n G9DtBackfillRequest,\r\n G9DtCommand,\r\n G9DtHelloResult,\r\n G9DtNegotiatedTable,\r\n G9DtPullContinuation,\r\n G9DtPullPlan,\r\n G9DtPushResult,\r\n G9DtSnapshotFileRequest,\r\n G9DtSubscriptionDefinition,\r\n G9DtSubscriptionRef,\r\n G9DtSyncChunk,\r\n G9DtTableColumns,\r\n G9DtTableDigest,\r\n} from '../protocol/dtos.js';\r\nimport type { G9SyncClientModel } from './model.js';\r\n\r\n// ---------------------------------------------------------------- server state and subscriptions\r\n\r\n/** What the client last learned from the server (`G9CClientServerState`). */\r\nexport interface G9ClientServerState {\r\n epoch: string | null;\r\n lastHelloUtcMs: number | null;\r\n /** Server clock minus device clock, ms. */\r\n serverClockOffsetMs: number;\r\n tables: G9DtNegotiatedTable[];\r\n definitions: G9DtSubscriptionDefinition[];\r\n}\r\n\r\n/** `G9ESubscriptionState`. */\r\nexport const G9ESubscriptionState = {\r\n Active: 0,\r\n NeedsReconcile: 1,\r\n Failed: 2,\r\n} as const;\r\nexport type G9ESubscriptionState = (typeof G9ESubscriptionState)[keyof typeof G9ESubscriptionState];\r\n\r\n/** A local subscription (`G9CSyncSubscriptionRecord`). Times are epoch milliseconds UTC. */\r\nexport interface G9SyncSubscriptionRecord {\r\n key: string;\r\n name: string;\r\n parameters: G9SyncParameters;\r\n /** Membership slot (bit) for persistent subscriptions; the shared ephemeral slot otherwise. */\r\n slot: number;\r\n ephemeral: boolean;\r\n ttlMs: number | null;\r\n cursor: string | null;\r\n /** The move-out policy the server last announced; kept so it still applies once access is gone. */\r\n moveOutPolicy: G9EMoveOutPolicy | null;\r\n definitionHash: string | null;\r\n authHash: string | null;\r\n state: G9ESubscriptionState;\r\n lastErrorCode: string | null;\r\n createdUtcMs: number;\r\n lastSuccessUtcMs: number | null;\r\n lastReconcileUtcMs: number | null;\r\n lastAccessUtcMs: number | null;\r\n}\r\n\r\n/** `G9CSyncSubscriptionRecord.ToReference()`. */\r\nexport function toSubscriptionRef(record: G9SyncSubscriptionRecord): G9DtSubscriptionRef {\r\n return {\r\n name: record.name,\r\n parameters: record.parameters.values,\r\n cursor: record.cursor,\r\n definitionHash: record.definitionHash,\r\n authHash: record.authHash,\r\n };\r\n}\r\n\r\n/** A partial update of a subscription record; absent members are left unchanged (`G9CSubscriptionUpdate`). */\r\nexport interface G9SubscriptionUpdate {\r\n cursor?: string | null;\r\n definitionHash?: string | null;\r\n authHash?: string | null;\r\n state?: G9ESubscriptionState | null;\r\n errorCode?: string | null;\r\n clearError?: boolean;\r\n succeeded?: boolean;\r\n reconciled?: boolean;\r\n accessed?: boolean;\r\n clearCursor?: boolean;\r\n}\r\n\r\n// ---------------------------------------------------------------- push and pull\r\n\r\n/** A push batch built from dirty rows (`G9CPushBatch`). */\r\nexport interface G9PushBatch {\r\n batchId: number;\r\n /** Highest local change sequence included; rows changed after it stay dirty after the acknowledgement. */\r\n maxSequence: number;\r\n frames: Uint8Array[];\r\n tables: G9DtTableColumns[];\r\n rowCount: number;\r\n /** True when the byte budget ended the batch early: more pending rows follow. */\r\n truncated: boolean;\r\n /** Rows rejected on the device while building the batch (G9S-REJ-TOO-LARGE). */\r\n rejectedLocally: number;\r\n /** Commands carried by this batch, in device order. */\r\n commands: G9DtCommand[];\r\n}\r\n\r\n/** A pull being staged, persisted across restarts (`G9CStagedPull`). */\r\nexport interface G9StagedPull {\r\n runId: string;\r\n plan: G9DtPullPlan;\r\n createdUtcMs: number;\r\n backfills: G9DtBackfillRequest[];\r\n /** What the world looked like when the plan was made (ADR-0046); a run only resumes a stage whose generation matches. */\r\n generation: string | null;\r\n /** The cursor each planned subscription had when the plan was made, by subscription key (ADR-0060). */\r\n plannedFromCursors: { [subscriptionKey: string]: string | null };\r\n /** The device clock when the stage began, assigned by the store. */\r\n stageSequence: number;\r\n}\r\n\r\n/** One committed slice of a staged pull (`G9CApplySlice`). */\r\nexport interface G9ApplySlice {\r\n report: G9ApplyReport;\r\n rowsApplied: number;\r\n rowsAppliedTotal: number;\r\n rowsPlanned: number;\r\n isFinal: boolean;\r\n}\r\n\r\n/** `G9CResumePoint`. */\r\nexport interface G9ResumePoint {\r\n continuation: G9DtPullContinuation | null;\r\n stagedRows: number;\r\n stagedBytes: number;\r\n complete: boolean;\r\n}\r\n\r\n// ---------------------------------------------------------------- reports\r\n\r\n/** Why a table large enough for index deferral kept its indexes live. */\r\nexport const REASON_TABLE_NOT_EMPTY = 'table-not-empty';\r\nconst MAX_FOREIGN_TRIGGER_NAMES = 10;\r\n\r\n/** How an apply ran, as opposed to what it changed (`G9CApplyDiagnostics`, ADR-0058). */\r\n/** A file table copied record for record into an empty table with identical columns (the transfer optimisation). */\r\nexport const FILE_MODE_COPY = 'copy';\r\n/** A file table copied into an empty table by column name. */\r\nexport const FILE_MODE_COLUMNS = 'columns';\r\n/** A file table merged into a table that held rows or protected rows: changed rows only. */\r\nexport const FILE_MODE_MERGE = 'merge';\r\n/** A file table inserted into a table holding only OTHER rows (a second site's first load): every row is new, no per-row diff. */\r\nexport const FILE_MODE_APPEND = 'append';\r\n\r\nexport class G9ApplyDiagnostics {\r\n transactions = 0;\r\n transactionsWithTriggersSkipped = 0;\r\n readonly foreignTriggers: string[] = [];\r\n readonly deferredIndexes: { [table: string]: number } = {};\r\n readonly liveIndexReasons: { [table: string]: string } = {};\r\n readonly rowsByTable: { [table: string]: number } = {};\r\n readonly msByTable: { [table: string]: number } = {};\r\n indexRebuildMs = 0;\r\n elapsedMs = 0;\r\n /** Snapshot files copied in (ADR-0072). */\r\n snapshotFiles = 0;\r\n /** Rows that arrived through snapshot files. */\r\n fileRows = 0;\r\n /** Milliseconds spent copying snapshot files, metadata included. */\r\n fileCopyMs = 0;\r\n /** How each table came out of a snapshot file: `copy`, `columns` or `merge` (see FILE_MODE_*). */\r\n readonly fileTables: { [table: string]: string } = {};\r\n\r\n /** True when every transaction ran with trigger execution off, false when any ran with it on, null when nothing was applied. */\r\n get triggersSkipped(): boolean | null {\r\n return this.transactions === 0 ? null : this.transactionsWithTriggersSkipped === this.transactions;\r\n }\r\n\r\n get deferredIndexCount(): number {\r\n let total = 0;\r\n for (const key of Object.keys(this.deferredIndexes)) total += this.deferredIndexes[key] as number;\r\n return total;\r\n }\r\n\r\n merge(other: G9ApplyDiagnostics): void {\r\n this.transactions += other.transactions;\r\n this.transactionsWithTriggersSkipped += other.transactionsWithTriggersSkipped;\r\n this.indexRebuildMs += other.indexRebuildMs;\r\n this.elapsedMs += other.elapsedMs;\r\n this.snapshotFiles += other.snapshotFiles;\r\n this.fileRows += other.fileRows;\r\n this.fileCopyMs += other.fileCopyMs;\r\n for (const key of Object.keys(other.fileTables)) this.fileTables[key] = other.fileTables[key] as string;\r\n for (const name of other.foreignTriggers) {\r\n if (this.foreignTriggers.length >= MAX_FOREIGN_TRIGGER_NAMES) break;\r\n if (!this.foreignTriggers.some((n) => n.toLowerCase() === name.toLowerCase())) this.foreignTriggers.push(name);\r\n }\r\n addAll(this.deferredIndexes, other.deferredIndexes);\r\n for (const key of Object.keys(other.liveIndexReasons)) this.liveIndexReasons[key] = other.liveIndexReasons[key] as string;\r\n addAll(this.rowsByTable, other.rowsByTable);\r\n addAll(this.msByTable, other.msByTable);\r\n }\r\n\r\n /** One line for a log: what engaged, what did not and why, and the tables that took the time. */\r\n toString(): string {\r\n if (this.transactions === 0) return 'nothing applied';\r\n let text = `${this.transactions} transaction(s) in ${this.elapsedMs} ms; triggers `;\r\n text +=\r\n this.triggersSkipped === true\r\n ? 'skipped'\r\n : this.transactionsWithTriggersSkipped === 0\r\n ? 'LIVE'\r\n : `skipped in ${this.transactionsWithTriggersSkipped} of ${this.transactions}`;\r\n if (this.foreignTriggers.length > 0) text += ' (foreign: ' + this.foreignTriggers.join(', ') + ')';\r\n const deferred = Object.keys(this.deferredIndexes);\r\n if (deferred.length > 0) {\r\n text += `; ${this.deferredIndexCount} index(es) rebuilt after the load in ${this.indexRebuildMs} ms (` + deferred.map((t) => t + ':' + this.deferredIndexes[t]).join(', ') + ')';\r\n }\r\n const live = Object.keys(this.liveIndexReasons);\r\n if (live.length > 0) text += '; live indexes on ' + live.map((t) => t + ' (' + this.liveIndexReasons[t] + ')').join(', ');\r\n if (this.snapshotFiles > 0) {\r\n text +=\r\n `; ${this.snapshotFiles} snapshot file(s), ${this.fileRows} rows copied in ${this.fileCopyMs} ms (` +\r\n Object.keys(this.fileTables)\r\n .map((t) => t + ':' + this.fileTables[t])\r\n .join(', ') +\r\n ')';\r\n }\r\n const slowest = Object.keys(this.msByTable)\r\n .sort((a, b) => (this.msByTable[b] as number) - (this.msByTable[a] as number))\r\n .slice(0, 4);\r\n if (slowest.length > 0) {\r\n text +=\r\n '; ' +\r\n slowest\r\n .map((t) => {\r\n const ms = this.msByTable[t] as number;\r\n const rows = this.rowsByTable[t] ?? 0;\r\n const rate = ms > 0 ? Math.floor((rows * 1000) / ms) : rows;\r\n return `${t} ${rows} rows in ${ms} ms (${rate}/s)`;\r\n })\r\n .join(', ');\r\n }\r\n return text;\r\n }\r\n}\r\n\r\nfunction addAll(target: { [key: string]: number }, source: { [key: string]: number }): void {\r\n for (const key of Object.keys(source)) target[key] = (target[key] ?? 0) + (source[key] as number);\r\n}\r\n\r\n/** What an apply changed (`G9CApplyReport`). */\r\nexport class G9ApplyReport {\r\n upserts = 0;\r\n deletes = 0;\r\n moveOuts = 0;\r\n membershipAdded = 0;\r\n /** Rows skipped because they carry a pending local change. */\r\n skippedDirty = 0;\r\n accepted = 0;\r\n rejected = 0;\r\n conflicts = 0;\r\n /** Conflicts the device lost that were kept on it as rejections (LES-0072). */\r\n conflictsKept = 0;\r\n /** Conflicts the device lost on paper only: the server already held its values for every lost column (LES-0085). */\r\n conflictsSameValue = 0;\r\n commandsCompleted = 0;\r\n revokedDeleted = 0;\r\n revokedQuarantined = 0;\r\n revokedRetained = 0;\r\n /** Changed keys per local table (capped per table). */\r\n readonly changedKeys: { [localTable: string]: string[] } = {};\r\n /** Upserts whose row already held exactly the incoming values (ADR-0058). */\r\n unchangedRows = 0;\r\n readonly diagnostics = new G9ApplyDiagnostics();\r\n\r\n get total(): number {\r\n return this.upserts + this.deletes + this.moveOuts;\r\n }\r\n\r\n merge(other: G9ApplyReport): void {\r\n this.unchangedRows += other.unchangedRows;\r\n this.diagnostics.merge(other.diagnostics);\r\n this.upserts += other.upserts;\r\n this.deletes += other.deletes;\r\n this.moveOuts += other.moveOuts;\r\n this.membershipAdded += other.membershipAdded;\r\n this.skippedDirty += other.skippedDirty;\r\n this.accepted += other.accepted;\r\n this.rejected += other.rejected;\r\n this.conflicts += other.conflicts;\r\n this.conflictsKept += other.conflictsKept;\r\n this.conflictsSameValue += other.conflictsSameValue;\r\n this.commandsCompleted += other.commandsCompleted;\r\n this.revokedDeleted += other.revokedDeleted;\r\n this.revokedQuarantined += other.revokedQuarantined;\r\n this.revokedRetained += other.revokedRetained;\r\n for (const table of Object.keys(other.changedKeys)) {\r\n const list = this.changedKeys[table] ?? (this.changedKeys[table] = []);\r\n for (const key of other.changedKeys[table] as string[]) list.push(key);\r\n }\r\n }\r\n}\r\n\r\n/** A local row as seen by reconciliation (`G9CLocalRowEntry`). */\r\nexport interface G9LocalRowEntry {\r\n key: string;\r\n bucket: number;\r\n version: number;\r\n hash: G9Long;\r\n member: boolean;\r\n dirty: boolean;\r\n}\r\n\r\nexport interface G9PendingTable {\r\n localTable: string;\r\n upserts: number;\r\n deletes: number;\r\n rejected: number;\r\n}\r\n\r\nexport interface G9PendingSummary {\r\n totalRows: number;\r\n rejectedRows: number;\r\n /** Commands recorded on the device and not yet executed by the server. */\r\n pendingCommands: number;\r\n tables: G9PendingTable[];\r\n}\r\n\r\n/** One entry of the local change feed (`G9CChangeFeedEntry`). */\r\nexport interface G9ChangeFeedEntry {\r\n sequence: number;\r\n key: string;\r\n deleted: boolean;\r\n localPending: boolean;\r\n}\r\n\r\n/**\r\n * Narrows a change-feed read to the keys a query of the app's own tables selects (`G9CChangeFeedKeyFilter`): a projection of one\r\n * site no longer walks the entries of every other site. Deletions are always returned - their rows are gone, so no query can place\r\n * them. `keySql` is one SELECT of one column, embedded as `pk IN (...)`; parameters are bound by name (`$name`, `@name`, `:name`)\r\n * and `$g9t`, `$g9a`, `$g9l` belong to the read.\r\n */\r\nexport interface G9ChangeFeedKeyFilter {\r\n keySql: string;\r\n parameters?: { [name: string]: string | number | null };\r\n}\r\n\r\nconst RESERVED_FEED_PARAMETERS = ['$g9t', '$g9a', '$g9l'];\r\n\r\n/** Throws when the filter cannot be embedded safely (`G9CChangeFeedKeyFilter.Validate`). */\r\nexport function validateChangeFeedKeyFilter(filter: G9ChangeFeedKeyFilter): void {\r\n const sql = (filter.keySql ?? '').trim();\r\n if (sql.slice(0, 6).toUpperCase() !== 'SELECT' || sql.indexOf(';') >= 0) {\r\n throw new Error('A change-feed key filter is a single SELECT statement of one column.');\r\n }\r\n for (const name of Object.keys(filter.parameters ?? {})) {\r\n if (name.length < 2 || '$@:'.indexOf(name[0] as string) < 0) throw new Error(`Change-feed key filter parameter '${name}' must be named ($name, @name or :name).`);\r\n if (RESERVED_FEED_PARAMETERS.indexOf(name.toLowerCase()) >= 0) throw new Error(`Change-feed key filter parameter '${name}' is reserved by the read.`);\r\n }\r\n}\r\n\r\nexport interface G9SyncRejection {\r\n localTable: string;\r\n key: string;\r\n code: string;\r\n message: string | null;\r\n sqlState: string | null;\r\n constraint: string | null;\r\n column: string | null;\r\n details: string | null;\r\n atUtcMs: number;\r\n}\r\n\r\n/** A persisted summary of one run (`G9CSyncRunReport`); serialized with the .NET JSON names into g9_runs. */\r\nexport interface G9SyncRunReport {\r\n runId: string;\r\n startedUtcMs: number;\r\n durationMs: number;\r\n outcome: string;\r\n priority: string;\r\n errorCode: string | null;\r\n errorMessage: string | null;\r\n pushed: number;\r\n rejected: number;\r\n conflicts: number;\r\n downloaded: number;\r\n applied: number;\r\n downloadedBytes: number;\r\n subscriptions: string[];\r\n phaseMs: { [phase: string]: number };\r\n triggersSkipped: boolean | null;\r\n foreignTriggers: string[];\r\n applyTransactions: number;\r\n indexesDeferred: number;\r\n indexRebuildMs: number;\r\n liveIndexReasons: { [table: string]: string };\r\n unchangedRows: number;\r\n}\r\n\r\n// ---------------------------------------------------------------- local commands (ADR-0025)\r\n\r\n/** `G9ELocalCommandState`. */\r\nexport const G9ELocalCommandState = {\r\n Pending: 0,\r\n Ok: 1,\r\n Rejected: 2,\r\n Superseded: 3,\r\n} as const;\r\nexport type G9ELocalCommandState = (typeof G9ELocalCommandState)[keyof typeof G9ELocalCommandState];\r\n\r\n/** A command recorded on this device (`G9CLocalCommand`). */\r\nexport interface G9LocalCommand {\r\n commandId: string;\r\n sequence: number;\r\n name: string;\r\n version: number;\r\n payload: string;\r\n createdUtcMs: number;\r\n state: G9ELocalCommandState;\r\n code: string | null;\r\n message: string | null;\r\n result: string | null;\r\n completedUtcMs: number | null;\r\n}\r\n\r\n/** What to record (`G9CCommandRequest`). */\r\nexport interface G9CommandRequest {\r\n name: string;\r\n version?: number;\r\n /** JSON payload for the server's handler. */\r\n payload: string;\r\n}\r\n\r\n/** A value an app binds through {@link G9LocalCommandWriter}: the SQLite driver's value forms, plus booleans. */\r\nexport type G9LocalSqlArgument = null | number | string | boolean | ArrayBuffer | Uint8Array | { int64: string } | G9Long;\r\n\r\n/**\r\n * Writes a command's local effects in the transaction that records it (`IG9LocalCommandWriter`). Rows written here are\r\n * not uploaded as row changes; they are protected from pulls until the server's result arrives.\r\n */\r\nexport interface G9LocalCommandWriter {\r\n /** Executes SQL; parameters bind positionally as `$p0`, `$p1`, … */\r\n execute(sql: string, ...args: G9LocalSqlArgument[]): Promise<number>;\r\n scalar(sql: string, ...args: G9LocalSqlArgument[]): Promise<unknown>;\r\n}\r\n\r\n// ---------------------------------------------------------------- revocation (ADR-0026)\r\n\r\n/** `G9ERevocationReason`. */\r\nexport const G9ERevocationReason = {\r\n LeftScope: 0,\r\n Unsubscribed: 1,\r\n Expired: 2,\r\n AccessRevoked: 3,\r\n /**\r\n * A row the device adopted from its own table that no subscription holds and the server never confirmed, released by the\r\n * application (`G9SyncEngine.releaseUnclaimedRows`, 1.5.19).\r\n */\r\n Unclaimed: 4,\r\n} as const;\r\nexport type G9ERevocationReason = (typeof G9ERevocationReason)[keyof typeof G9ERevocationReason];\r\n\r\n/** `G9ERevocationDisposition`. */\r\nexport const G9ERevocationDisposition = {\r\n Delete: 0,\r\n MarkRevoked: 1,\r\n Quarantine: 2,\r\n Retain: 3,\r\n} as const;\r\nexport type G9ERevocationDisposition = (typeof G9ERevocationDisposition)[keyof typeof G9ERevocationDisposition];\r\n\r\n/** A row no subscription holds any more, as a revocation rule sees it (`G9CRevokedRow`). */\r\nexport interface G9RevokedRow {\r\n localTable: string;\r\n key: string;\r\n reason: G9ERevocationReason;\r\n subscriptionKey: string | null;\r\n hasPendingChanges: boolean;\r\n isRejected: boolean;\r\n /** Column values (key included) as stored locally; empty when the row no longer exists locally. */\r\n values: { [column: string]: unknown };\r\n}\r\n\r\n/** Lets a custom rule change the row before its disposition applies. */\r\nexport interface G9RevokedRowEditor {\r\n set(column: string, value: unknown): void;\r\n}\r\n\r\nexport interface G9RevocationRule {\r\n readonly name: string;\r\n readonly condition: (row: G9RevokedRow) => boolean;\r\n readonly decide: (row: G9RevokedRow, editor: G9RevokedRowEditor) => G9ERevocationDisposition;\r\n readonly retainWhile: ((row: G9RevokedRow) => boolean) | null;\r\n}\r\n\r\n/** Ordered revocation rules (`G9CRevocationPolicy`): the first matching rule decides. */\r\nexport class G9RevocationPolicy {\r\n readonly rules: readonly G9RevocationRule[];\r\n\r\n private constructor(rules: readonly G9RevocationRule[]) {\r\n this.rules = rules;\r\n }\r\n\r\n /** No rules: delete clean rows, quarantine rows with pending changes. */\r\n static readonly default = new G9RevocationPolicy([]);\r\n\r\n static create(configure: (builder: G9RevocationPolicyBuilder) => void): G9RevocationPolicy {\r\n const builder = new G9RevocationPolicyBuilder();\r\n configure(builder);\r\n return new G9RevocationPolicy(builder.rules.slice());\r\n }\r\n\r\n decide(row: G9RevokedRow, editor: G9RevokedRowEditor): { rule: G9RevocationRule | null; disposition: G9ERevocationDisposition } {\r\n for (const rule of this.rules) {\r\n if (rule.condition(row)) return { rule, disposition: rule.decide(row, editor) };\r\n }\r\n return { rule: null, disposition: row.hasPendingChanges ? G9ERevocationDisposition.Quarantine : G9ERevocationDisposition.Delete };\r\n }\r\n\r\n find(name: string): G9RevocationRule | null {\r\n for (const rule of this.rules) if (rule.name === name) return rule;\r\n return null;\r\n }\r\n}\r\n\r\nexport class G9RevocationPolicyBuilder {\r\n readonly rules: G9RevocationRule[] = [];\r\n\r\n when(name: string, condition: (row: G9RevokedRow) => boolean): G9RevocationActionBuilder {\r\n if (typeof name !== 'string' || name.trim() === '') throw new TypeError('A rule needs a name.');\r\n if (this.rules.some((r) => r.name === name)) throw new RangeError(`Revocation rule '${name}' is declared twice.`);\r\n return new G9RevocationActionBuilder(this, name, condition);\r\n }\r\n\r\n /** Rows of one local table. */\r\n forTable(name: string, localTable: string, condition?: (row: G9RevokedRow) => boolean): G9RevocationActionBuilder {\r\n const table = localTable.toLowerCase();\r\n return this.when(name, (row) => row.localTable.toLowerCase() === table && (condition ? condition(row) : true));\r\n }\r\n}\r\n\r\nexport class G9RevocationActionBuilder {\r\n private readonly _owner: G9RevocationPolicyBuilder;\r\n private readonly _name: string;\r\n private readonly _condition: (row: G9RevokedRow) => boolean;\r\n\r\n constructor(owner: G9RevocationPolicyBuilder, name: string, condition: (row: G9RevokedRow) => boolean) {\r\n this._owner = owner;\r\n this._name = name;\r\n this._condition = condition;\r\n }\r\n\r\n delete(): G9RevocationPolicyBuilder {\r\n return this._add(() => G9ERevocationDisposition.Delete, null);\r\n }\r\n\r\n markRevoked(): G9RevocationPolicyBuilder {\r\n return this._add(() => G9ERevocationDisposition.MarkRevoked, null);\r\n }\r\n\r\n quarantine(): G9RevocationPolicyBuilder {\r\n return this._add(() => G9ERevocationDisposition.Quarantine, null);\r\n }\r\n\r\n retainWhile(retainWhile: (row: G9RevokedRow) => boolean): G9RevocationPolicyBuilder {\r\n return this._add(() => G9ERevocationDisposition.Retain, retainWhile);\r\n }\r\n\r\n custom(decide: (row: G9RevokedRow, editor: G9RevokedRowEditor) => G9ERevocationDisposition): G9RevocationPolicyBuilder {\r\n return this._add(decide, null);\r\n }\r\n\r\n private _add(\r\n decide: (row: G9RevokedRow, editor: G9RevokedRowEditor) => G9ERevocationDisposition,\r\n retainWhile: ((row: G9RevokedRow) => boolean) | null,\r\n ): G9RevocationPolicyBuilder {\r\n this._owner.rules.push({ name: this._name, condition: this._condition, decide, retainWhile });\r\n return this._owner;\r\n }\r\n}\r\n\r\n/** A row in the holding area (`G9CQuarantinedRow`). */\r\nexport interface G9QuarantinedRow {\r\n localTable: string;\r\n key: string;\r\n reason: G9ERevocationReason;\r\n rule: string | null;\r\n hadPendingChanges: boolean;\r\n values: { [column: string]: unknown };\r\n atUtcMs: number;\r\n}\r\n\r\n/** A row kept in the app's table after revocation (`G9CRetainedRow`). */\r\nexport interface G9RetainedRow {\r\n localTable: string;\r\n key: string;\r\n disposition: G9ERevocationDisposition;\r\n reason: G9ERevocationReason;\r\n rule: string | null;\r\n atUtcMs: number;\r\n}\r\n\r\n// ---------------------------------------------------------------- failures\r\n\r\n/** What went wrong inside a client store, in terms an application can act on (`G9ELocalStoreFailure`). */\r\nexport const G9ELocalStoreFailure = {\r\n Other: 0,\r\n Corrupt: 1,\r\n DiskFull: 2,\r\n Busy: 3,\r\n} as const;\r\nexport type G9ELocalStoreFailure = (typeof G9ELocalStoreFailure)[keyof typeof G9ELocalStoreFailure];\r\n\r\n/** Implemented by a store's errors so the engine can give a run's failure a stable code (`IG9SyncLocalStoreFailure`). */\r\nexport interface G9SyncLocalStoreFailure {\r\n readonly localStoreFailure: G9ELocalStoreFailure;\r\n}\r\n\r\nexport function isLocalStoreFailure(error: unknown): error is G9SyncLocalStoreFailure {\r\n return typeof error === 'object' && error !== null && typeof (error as { localStoreFailure?: unknown }).localStoreFailure === 'number';\r\n}\r\n\r\n// ---------------------------------------------------------------- the store contract\r\n\r\n/**\r\n * The client storage provider (`IG9SyncClientStore`): local tables, change capture, subscription membership,\r\n * staging, apply and metadata. Every method takes an optional AbortSignal (the CancellationToken twin).\r\n */\r\nexport interface G9SyncClientStore {\r\n initialize(model: G9SyncClientModel, signal?: AbortSignal): Promise<void>;\r\n getClientId(signal?: AbortSignal): Promise<string>;\r\n getServerState(signal?: AbortSignal): Promise<G9ClientServerState>;\r\n /**\r\n * Stores the Hello answer. `localMidpointMs`: the local time the server's clock reading corresponds to - the midpoint of the round\r\n * trip (LES-0075); the offset is then exact up to the asymmetry of the two legs. Omitted: the time of this call.\r\n */\r\n saveHello(hello: G9DtHelloResult, signal?: AbortSignal, localMidpointMs?: number): Promise<void>;\r\n getPendingBackfills(signal?: AbortSignal): Promise<G9DtBackfillRequest[]>;\r\n\r\n getSubscriptions(signal?: AbortSignal): Promise<G9SyncSubscriptionRecord[]>;\r\n ensureSubscription(\r\n name: string,\r\n parameters: G9SyncParameters,\r\n ephemeral: boolean,\r\n ttlMs: number | null,\r\n adoptExistingRows: boolean,\r\n signal?: AbortSignal,\r\n ): Promise<G9SyncSubscriptionRecord>;\r\n removeSubscription(key: string, policy: G9EMoveOutPolicy, signal?: AbortSignal): Promise<void>;\r\n releaseSubscriptionRows(key: string, signal?: AbortSignal): Promise<G9ApplyReport>;\r\n updateSubscription(key: string, update: G9SubscriptionUpdate, signal?: AbortSignal): Promise<void>;\r\n collectExpiredEphemeral(utcNowMs: number, signal?: AbortSignal): Promise<number>;\r\n\r\n buildPushBatch(tables: readonly G9DtNegotiatedTable[], maxRows: number, maxBytes: number, signal?: AbortSignal): Promise<G9PushBatch | null>;\r\n forgetUploadedRows(localTable: string, keys: readonly string[] | null, signal?: AbortSignal): Promise<number>;\r\n applyPushResult(batch: G9PushBatch, result: G9DtPushResult, signal?: AbortSignal): Promise<G9ApplyReport>;\r\n\r\n getStagedPull(signal?: AbortSignal): Promise<G9StagedPull | null>;\r\n /** The newest staged pull planned under exactly this generation, or null (ADR-0060). */\r\n getStagedPullForGeneration(generation: string, signal?: AbortSignal): Promise<G9StagedPull | null>;\r\n beginStagedPull(pull: G9StagedPull, signal?: AbortSignal): Promise<void>;\r\n pruneStagedPulls(olderThanUtcMs: number, maxBytes: number, keepGeneration: string | null, signal?: AbortSignal): Promise<number>;\r\n discardAllStagedPulls(signal?: AbortSignal): Promise<number>;\r\n stageChunk(runId: string, chunk: G9DtSyncChunk, signal?: AbortSignal): Promise<void>;\r\n /**\r\n * The store's offer to receive large first downloads as SQLite snapshot files (ADR-0072), or null for rows only. A store that\r\n * makes an offer stages file segments (`chunk.file`) in `stageChunk` and copies the files in `applyStagedPull`.\r\n */\r\n describeSnapshotFiles?(negotiated: readonly G9DtNegotiatedTable[]): G9DtSnapshotFileRequest | null;\r\n getResumePoint(runId: string, signal?: AbortSignal): Promise<G9ResumePoint>;\r\n applyStagedPull(\r\n runId: string,\r\n rowsApplied: ((rows: number) => void) | null,\r\n slices: ((slice: G9ApplySlice) => void) | null,\r\n signal?: AbortSignal,\r\n ): Promise<G9ApplyReport>;\r\n discardStagedPull(runId: string, signal?: AbortSignal): Promise<void>;\r\n\r\n computeDigest(subscriptionKey: string, table: G9DtNegotiatedTable, signal?: AbortSignal): Promise<G9DtTableDigest>;\r\n readLocalEntries(\r\n subscriptionKey: string,\r\n table: G9DtNegotiatedTable,\r\n buckets: ReadonlySet<number>,\r\n serverKeys: ReadonlySet<string>,\r\n signal?: AbortSignal,\r\n ): Promise<G9LocalRowEntry[]>;\r\n applyReconcile(\r\n subscriptionKey: string,\r\n table: G9DtNegotiatedTable,\r\n fetchedFrames: readonly Uint8Array[],\r\n addMembership: readonly string[],\r\n moveOut: readonly string[],\r\n policy: G9EMoveOutPolicy,\r\n signal?: AbortSignal,\r\n ): Promise<G9ApplyReport>;\r\n\r\n getPendingSummary(signal?: AbortSignal): Promise<G9PendingSummary>;\r\n enqueueCommand(\r\n request: G9CommandRequest,\r\n applyLocally: ((writer: G9LocalCommandWriter, signal?: AbortSignal) => Promise<void>) | null,\r\n signal?: AbortSignal,\r\n ): Promise<G9LocalCommand>;\r\n getQuarantined(signal?: AbortSignal): Promise<G9QuarantinedRow[]>;\r\n restoreQuarantined(localTable: string, key: string, signal?: AbortSignal): Promise<number>;\r\n discardQuarantined(localTable: string | null, key: string | null, signal?: AbortSignal): Promise<number>;\r\n getRetained(signal?: AbortSignal): Promise<G9RetainedRow[]>;\r\n reevaluateRetained(signal?: AbortSignal): Promise<number>;\r\n getCommands(state: G9ELocalCommandState | null, limit: number, signal?: AbortSignal): Promise<G9LocalCommand[]>;\r\n readChangeFeed(localTable: string, afterSequence: number, limit: number, signal?: AbortSignal): Promise<G9ChangeFeedEntry[]>;\r\n /** The feed narrowed to the keys `keyFilter` selects, plus every deletion; fewer than `limit` entries means the read is complete. */\r\n readChangeFeedFiltered(localTable: string, afterSequence: number, limit: number, keyFilter: G9ChangeFeedKeyFilter, signal?: AbortSignal): Promise<G9ChangeFeedEntry[]>;\r\n getChangeSequence(signal?: AbortSignal): Promise<number>;\r\n getChangeFeedFloor(signal?: AbortSignal): Promise<number>;\r\n getRejections(signal?: AbortSignal): Promise<G9SyncRejection[]>;\r\n retryRejected(localTable: string | null, key: string | null, signal?: AbortSignal): Promise<number>;\r\n /** Gives up the local change of rejected rows and takes the server's copy (LES-0070); run a forced reconcile after it. */\r\n revertRejected(localTable: string | null, key: string | null, signal?: AbortSignal): Promise<number>;\r\n markDirty(localTable: string, keys: readonly string[], signal?: AbortSignal): Promise<number>;\r\n /** `RefetchRowsAsync` (1.5.19): clean held rows get `server_ver = -1` and their subscriptions NeedsReconcile. Returns the rows marked. */\r\n refetchRows(localTable: string, keys: readonly string[] | null, signal?: AbortSignal): Promise<number>;\r\n /** `ReleaseUnclaimedRowsAsync` (1.5.19): disposes adopted rows nothing holds and the server never claimed, capture off. */\r\n releaseUnclaimedRows(localTable: string, keys: readonly string[] | null, includePending: boolean, signal?: AbortSignal): Promise<G9ApplyReport>;\r\n adoptExistingRows(signal?: AbortSignal): Promise<number>;\r\n saveRunReport(report: G9SyncRunReport, keep: number, signal?: AbortSignal): Promise<void>;\r\n getRecentRunReports(count: number, signal?: AbortSignal): Promise<G9SyncRunReport[]>;\r\n getPhaseStatistics(signal?: AbortSignal): Promise<{ [key: string]: number }>;\r\n recordPhaseStatistics(samples: { [key: string]: number }, signal?: AbortSignal): Promise<void>;\r\n purgeDeletedFeed(keep: number, signal?: AbortSignal): Promise<number>;\r\n dispose(): Promise<void>;\r\n}\r\n"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** The package version; equal to the .NET packages' (G9SyncDataVersion) — one release, both sides. */
|
|
2
|
-
export declare const VERSION = "1.5.
|
|
2
|
+
export declare const VERSION = "1.5.21";
|
|
3
3
|
export { G9EConflictPolicy, G9EMoveOutPolicy, G9ESyncColumnType, G9ESyncDirection, columnTypeName, isColumnType } from './abstractions/enums.js';
|
|
4
4
|
export { G9SyncErrorCodes, G9SyncException, isRetryableCode, isSyncException, type G9SyncExceptionOptions } from './abstractions/errors.js';
|
|
5
5
|
export { G9Long, parseJson, stringifyJson } from './abstractions/long.js';
|
package/dist/index.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// doubles `@g9tm/syncdata/testing`, the pure-JavaScript Brotli decoder `@g9tm/syncdata/brotli-js`; Lynx wiring is the
|
|
4
4
|
// separate package `@g9tm/syncdata-lynx`. Every public type keeps its .NET name without the G9C prefix (PARITY.md).
|
|
5
5
|
/** The package version; equal to the .NET packages' (G9SyncDataVersion) — one release, both sides. */
|
|
6
|
-
export const VERSION = '1.5.
|
|
6
|
+
export const VERSION = '1.5.21';
|
|
7
7
|
// abstractions
|
|
8
8
|
export { G9EConflictPolicy, G9EMoveOutPolicy, G9ESyncColumnType, G9ESyncDirection, columnTypeName, isColumnType } from './abstractions/enums.js';
|
|
9
9
|
export { G9SyncErrorCodes, G9SyncException, isRetryableCode, isSyncException } from './abstractions/errors.js';
|
package/dist/index.js.map
CHANGED
|
@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AAgB,EAA4E,MAAM,+BAA+B,CAAC;AAC3I,OAAO,EACL,gBAAgB,EAChB,2BAA2B,EAC3B,YAAY,EACZ,gBAAgB,EAChB,eAAe,EACf,2BAA2B,GAI5B,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,YAAY,EAAE,YAAY,EAAqB,MAAM,4BAA4B,CAAC;AAE3H,SAAS;AACT,OAAO,EAAE,iBAAiB,EAAE,wBAAwB,EAAE,iBAAiB,EAAE,wBAAwB,EAAmD,MAAM,mBAAmB,CAAC;AAC9K,cAAc,wBAAwB,CAAC;AAEvC,OAAO,EAAE,YAAY,EAAE,qBAAqB,EAAE,SAAS,EAAyB,MAAM,sBAAsB,CAAC;AAC7G,OAAO,EACL,cAAc,EACd,eAAe,EACf,cAAc,EACd,SAAS,EACT,oBAAoB,EACpB,gBAAgB,EAChB,cAAc,EACd,WAAW,EACX,YAAY,EACZ,oBAAoB,GAYrB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAEnE,2CAA2C;AAC3C,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACpE,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAC5D,OAAO,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AACxC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC","sourcesContent":["// @g9tm/syncdata — the TypeScript twin of the G9SyncData .NET client (abstractions, protocol, engine). The SQLite store\r\n// is `@g9tm/syncdata/sqlite`, the SignalR transport `@g9tm/syncdata/signalr`, Node helpers `@g9tm/syncdata/node`, test\r\n// doubles `@g9tm/syncdata/testing`, the pure-JavaScript Brotli decoder `@g9tm/syncdata/brotli-js`; Lynx wiring is the\r\n// separate package `@g9tm/syncdata-lynx`. Every public type keeps its .NET name without the G9C prefix (PARITY.md).\r\n\r\n/** The package version; equal to the .NET packages' (G9SyncDataVersion) — one release, both sides. */\r\nexport const VERSION = '1.5.
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,wHAAwH;AACxH,uHAAuH;AACvH,sHAAsH;AACtH,oHAAoH;AAEpH,sGAAsG;AACtG,MAAM,CAAC,MAAM,OAAO,GAAG,QAAQ,CAAC;AAEhC,eAAe;AACf,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACjJ,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,eAAe,EAAE,eAAe,EAA+B,MAAM,0BAA0B,CAAC;AAC5I,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAC1E,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AACvG,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAElF,WAAW;AACX,cAAc,oBAAoB,CAAC;AACnC,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,qBAAqB,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAC5G,OAAO,EACL,UAAU,EACV,UAAU,EACV,oBAAoB,EACpB,UAAU,EACV,mBAAmB,EACnB,oBAAoB,EACpB,gBAAgB,EAChB,eAAe,EACf,YAAY,EACZ,cAAc,EACd,o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AqB,CAAC","sourcesContent":["// @g9tm/syncdata — the TypeScript twin of the G9SyncData .NET client (abstractions, protocol, engine). The SQLite store\r\n// is `@g9tm/syncdata/sqlite`, the SignalR transport `@g9tm/syncdata/signalr`, Node helpers `@g9tm/syncdata/node`, test\r\n// doubles `@g9tm/syncdata/testing`, the pure-JavaScript Brotli decoder `@g9tm/syncdata/brotli-js`; Lynx wiring is the\r\n// separate package `@g9tm/syncdata-lynx`. Every public type keeps its .NET name without the G9C prefix (PARITY.md).\r\n\r\n/** The package version; equal to the .NET packages' (G9SyncDataVersion) — one release, both sides. */\r\nexport const VERSION = '1.5.21';\r\n\r\n// abstractions\r\nexport { G9EConflictPolicy, G9EMoveOutPolicy, G9ESyncColumnType, G9ESyncDirection, columnTypeName, isColumnType } from './abstractions/enums.js';\r\nexport { G9SyncErrorCodes, G9SyncException, isRetryableCode, isSyncException, type G9SyncExceptionOptions } from './abstractions/errors.js';\r\nexport { G9Long, parseJson, stringifyJson } from './abstractions/long.js';\r\nexport { EMPTY_GUID, guidToN, newGuid, normalizeGuid, tryNormalizeGuid } from './abstractions/guid.js';\r\nexport { G9SyncKey } from './abstractions/key.js';\r\nexport { G9SyncDigest } from './abstractions/digest.js';\r\nexport { G9SyncParameters, escapeDataString } from './abstractions/parameters.js';\r\n\r\n// protocol\r\nexport * from './protocol/dtos.js';\r\nexport { G9SyncHubErrors, G9SyncProtocol, negotiateFrameVersion, tableGroup } from './protocol/protocol.js';\r\nexport {\r\n bytesField,\r\n dateTimeMs,\r\n fromMessagePackNames,\r\n G9WireGuid,\r\n GUID_EXTENSION_TYPE,\r\n readChangesAvailable,\r\n readContinuation,\r\n readHelloResult,\r\n readPullPlan,\r\n readPushResult,\r\n readReconcileSummary,\r\n readSyncChunk,\r\n toMessagePackNames,\r\n type G9WireFormat,\r\n} from './protocol/wire.js';\r\nexport { G9ECompression, G9EPushRowOp, G9ERowBatchOp, G9RowBatchFormat, G9RowBatchFormatError } from './protocol/rowBatch/format.js';\r\nexport { G9RowBatchWriter, type G9DateTimeOffsetValue, type G9DateTimeValue, type G9FrameCompressor } from './protocol/rowBatch/writer.js';\r\nexport {\r\n G9RowBatchReader,\r\n getDefaultFrameDecompressor,\r\n openRowBatch,\r\n openRowBatchSync,\r\n readFrameHeader,\r\n setDefaultFrameDecompressor,\r\n type G9FrameDecompressor,\r\n type G9FrameHeader,\r\n type G9OpenRowBatchOptions,\r\n} from './protocol/rowBatch/reader.js';\r\nexport { decimalToDouble, formatDecimal, formatDouble, parseDecimal, type DecimalParts } from './internal/dotnetFormat.js';\r\n\r\n// client\r\nexport { G9SyncClientModel, G9SyncClientModelBuilder, G9SyncClientTable, G9SyncClientTableBuilder, type G9SyncClientColumn, type G9SyncClientIndex } from './client/model.js';\r\nexport * from './client/storeTypes.js';\r\nexport type { G9SyncTransport } from './client/transport.js';\r\nexport { G9ESyncPhase, G9SyncProgressTracker, phaseName, type G9DtSyncProgress } from './client/progress.js';\r\nexport {\r\n G9ESyncOutcome,\r\n G9ESyncPriority,\r\n G9SyncPostStep,\r\n G9SyncRun,\r\n describeModelProblem,\r\n isTransientError,\r\n normalizeError,\r\n outcomeName,\r\n priorityName,\r\n resolveEngineOptions,\r\n type G9RowsAppliedEvent,\r\n type G9SubscriptionOptions,\r\n type G9SyncEngineOptions,\r\n type G9SyncHealth,\r\n type G9SyncHostHooks,\r\n type G9SyncLogger,\r\n type G9SyncLogLevel,\r\n type G9SyncModelProblem,\r\n type G9SyncPostStepContext,\r\n type G9SyncRequest,\r\n type G9SyncRunResult,\r\n} from './client/runs.js';\r\nexport { G9SyncEngine, stageGeneration } from './client/engine.js';\r\n\r\n// helpers the Lynx package and tests share\r\nexport { base64ToBytes, bytesToBase64 } from './internal/base64.js';\r\nexport { utf8Decode, utf8Encode } from './internal/utf8.js';\r\nexport { md5 } from './internal/md5.js';\r\nexport { sha256, toHex } from './internal/sha256.js';\r\nexport { cancellationError, createAbortController, delay, linkSignals, onAbort, yieldToEventLoop } from './internal/abort.js';\r\n"]}
|
package/dist/protocol/dtos.d.ts
CHANGED
|
@@ -88,6 +88,12 @@ export interface G9DtHelloRequest {
|
|
|
88
88
|
protocolVersion: number;
|
|
89
89
|
tables: G9DtClientTableModel[];
|
|
90
90
|
subscriptions: G9DtSubscriptionRef[];
|
|
91
|
+
/** Instead of `tables` (sent empty): the server's id of the same model, given earlier on THIS connection (1.5.21). */
|
|
92
|
+
modelHash?: string | null;
|
|
93
|
+
/** The `tablesHash` of the negotiated tables the client holds: the same on the server → `tablesUnchanged` (1.5.21). */
|
|
94
|
+
knownTablesHash?: string | null;
|
|
95
|
+
/** The `definitionsHash` of the definitions the client holds: the same on the server → `definitionsUnchanged` (1.5.21). */
|
|
96
|
+
knownDefinitionsHash?: string | null;
|
|
91
97
|
}
|
|
92
98
|
export interface G9DtColumnTypeMismatch {
|
|
93
99
|
name: string;
|
|
@@ -149,6 +155,16 @@ export interface G9DtHelloResult {
|
|
|
149
155
|
maxPushRows: number;
|
|
150
156
|
maxPushBytes: number;
|
|
151
157
|
error?: G9DtSyncError | null;
|
|
158
|
+
/** The server's id of the client model this Hello was negotiated from (1.5.21); null from an older server. */
|
|
159
|
+
modelHash?: string | null;
|
|
160
|
+
/** The request named a model the server no longer holds: send the Hello again WITH the tables (1.5.21). */
|
|
161
|
+
modelRequired?: boolean;
|
|
162
|
+
tablesHash?: string | null;
|
|
163
|
+
/** `tables` and `unknownTables` were left out: the client holds them (1.5.21). */
|
|
164
|
+
tablesUnchanged?: boolean;
|
|
165
|
+
definitionsHash?: string | null;
|
|
166
|
+
/** `definitions` was left out: the client holds it (1.5.21). */
|
|
167
|
+
definitionsUnchanged?: boolean;
|
|
152
168
|
}
|
|
153
169
|
export interface G9DtTableColumns {
|
|
154
170
|
tableId: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dtos.js","sourceRoot":"","sources":["../../src/protocol/dtos.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAG5D,4FAA4F;AAC5F,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,EAAE,EAAE,CAAC;IACL,OAAO,EAAE,CAAC;IACV,SAAS,EAAE,CAAC;IACZ,cAAc,EAAE,CAAC;IACjB,OAAO,EAAE,CAAC;IACV,iBAAiB,EAAE,CAAC;IACpB,SAAS,EAAE,CAAC;CACJ,CAAC;AAGX,uDAAuD;AACvD,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,QAAQ,EAAE,CAAC;IACX,KAAK,EAAE,CAAC;IACR,QAAQ,EAAE,CAAC;IACX,+GAA+G;IAC/G,YAAY,EAAE,CAAC;CACP,CAAC;AAGX,wEAAwE;AACxE,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,EAAE,EAAE,CAAC;IACL,QAAQ,EAAE,CAAC;IACX,UAAU,EAAE,CAAC;CACL,CAAC;AAYX,qCAAqC;AACrC,MAAM,UAAU,oBAAoB,CAAC,KAAoB;;IACvD,OAAO,IAAI,eAAe,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,KAAK,CAAC,SAAS,EAAE,OAAO,EAAE,MAAA,KAAK,CAAC,OAAO,mCAAI,IAAI,EAAE,CAAC,CAAC;AACxH,CAAC;AAED,uCAAuC;AACvC,MAAM,UAAU,aAAa,CAAC,SAA0B;IACtD,OAAO,EAAE,IAAI,EAAE,SAAS,CAAC,IAAI,EAAE,OAAO,EAAE,SAAS,CAAC,OAAO,EAAE,SAAS,EAAE,SAAS,CAAC,SAAS,EAAE,OAAO,EAAE,SAAS,CAAC,OAAO,EAAE,CAAC;AAC1H,CAAC","sourcesContent":["// Twins of G9SyncData.Protocol/Dtos/*.cs. Property names are the camelCase of the .NET names (the JSON wire names);\r\n// the MessagePack codec maps them to the PascalCase keys Nerdbank.MessagePack writes. .NET `long` values are numbers\r\n// except where they must stay exact: reconciliation digests and conflict masks are G9Long.\r\nimport type { G9EConflictPolicy, G9EMoveOutPolicy, G9ESyncColumnType, G9ESyncDirection } from '../abstractions/enums.js';\r\nimport { G9SyncException } from '../abstractions/errors.js';\r\nimport type { G9Long } from '../abstractions/long.js';\r\n\r\n/** What a subscription must do next, as decided by the server (`G9ESubscriptionAction`). */\r\nexport const G9ESubscriptionAction = {\r\n Ok: 0,\r\n Initial: 1,\r\n Reconcile: 2,\r\n ResyncRequired: 3,\r\n Unknown: 4,\r\n InvalidParameters: 5,\r\n Forbidden: 6,\r\n} as const;\r\nexport type G9ESubscriptionAction = (typeof G9ESubscriptionAction)[keyof typeof G9ESubscriptionAction];\r\n\r\n/** Kind of a planned pull part (`G9EPullPartKind`). */\r\nexport const G9EPullPartKind = {\r\n Snapshot: 0,\r\n Delta: 1,\r\n Backfill: 2,\r\n /** A subscription's snapshot as a SQLite file (ADR-0072), streamed as file segments (`G9DtSyncChunk.file`). */\r\n SnapshotFile: 3,\r\n} as const;\r\nexport type G9EPullPartKind = (typeof G9EPullPartKind)[keyof typeof G9EPullPartKind];\r\n\r\n/** Outcome of a command executed by the server (`G9ECommandStatus`). */\r\nexport const G9ECommandStatus = {\r\n Ok: 0,\r\n Rejected: 1,\r\n Superseded: 2,\r\n} as const;\r\nexport type G9ECommandStatus = (typeof G9ECommandStatus)[keyof typeof G9ECommandStatus];\r\n\r\n// ---------------------------------------------------------------- common\r\n\r\nexport interface G9DtSyncError {\r\n code: string;\r\n message: string;\r\n retryable: boolean;\r\n details?: string | null;\r\n}\r\n\r\n/** `G9DtSyncError.ToException()`. */\r\nexport function syncErrorToException(error: G9DtSyncError): G9SyncException {\r\n return new G9SyncException(error.code, error.message, { retryable: error.retryable, details: error.details ?? null });\r\n}\r\n\r\n/** `G9DtSyncError.From(exception)`. */\r\nexport function syncErrorFrom(exception: G9SyncException): G9DtSyncError {\r\n return { code: exception.code, message: exception.message, retryable: exception.retryable, details: exception.details };\r\n}\r\n\r\nexport interface G9DtColumnModel {\r\n name: string;\r\n type: G9ESyncColumnType;\r\n nullable: boolean;\r\n}\r\n\r\n/** A subscription as the client holds it: name, canonical parameters and its sync state. */\r\nexport interface G9DtSubscriptionRef {\r\n name: string;\r\n parameters: { [name: string]: string };\r\n /** Opaque server cursor of the last completed pull. Null before the first pull. */\r\n cursor?: string | null;\r\n definitionHash?: string | null;\r\n authHash?: string | null;\r\n}\r\n\r\n/** Resume point after a chunk. Only chunks that carry one are safe restart points. */\r\nexport interface G9DtPullContinuation {\r\n partIndex: number;\r\n afterKey?: string | null;\r\n nextSequence: number;\r\n}\r\n\r\n/** One unit of a data stream; `payload` is a G9RowBatch frame. */\r\nexport interface G9DtSyncChunk {\r\n sequence: number;\r\n payload?: Uint8Array | null;\r\n rowCount: number;\r\n subscriptionKey?: string | null;\r\n isFinal: boolean;\r\n continuation?: G9DtPullContinuation | null;\r\n reconcileSummary?: G9DtReconcileSummary | null;\r\n /** Set when the chunk carries a snapshot-file segment (ADR-0072): `payload` is then the segment, Brotli-compressed on its own. */\r\n file?: G9DtFileSegment | null;\r\n}\r\n\r\n/** Server → client hint that tables changed. */\r\nexport interface G9DtChangesAvailable {\r\n tables: string[];\r\n}\r\n\r\n// ---------------------------------------------------------------- hello\r\n\r\nexport interface G9DtClientTableModel {\r\n name: string;\r\n keyColumn: string;\r\n keyType: G9ESyncColumnType;\r\n columns: G9DtColumnModel[];\r\n}\r\n\r\nexport interface G9DtHelloRequest {\r\n clientId: string;\r\n appVersion?: string | null;\r\n protocolVersion: number;\r\n tables: G9DtClientTableModel[];\r\n subscriptions: G9DtSubscriptionRef[];\r\n}\r\n\r\nexport interface G9DtColumnTypeMismatch {\r\n name: string;\r\n clientType: G9ESyncColumnType;\r\n serverType: G9ESyncColumnType;\r\n}\r\n\r\n/** The column set both sides agreed on for one table. */\r\nexport interface G9DtNegotiatedTable {\r\n tableId: number;\r\n name: string;\r\n keyColumn: string;\r\n keyType: G9ESyncColumnType;\r\n columns: G9DtColumnModel[];\r\n computedColumns: string[];\r\n readOnlyColumns: string[];\r\n missingColumns: string[];\r\n typeMismatchColumns: G9DtColumnTypeMismatch[];\r\n direction: G9ESyncDirection;\r\n conflictPolicy: G9EConflictPolicy;\r\n}\r\n\r\nexport interface G9DtParameterDefinition {\r\n name: string;\r\n type: G9ESyncColumnType;\r\n required: boolean;\r\n isList: boolean;\r\n}\r\n\r\nexport interface G9DtSubscriptionDependency {\r\n name: string;\r\n required: boolean;\r\n}\r\n\r\nexport interface G9DtSubscriptionDefinition {\r\n name: string;\r\n parameters: G9DtParameterDefinition[];\r\n dependsOn: G9DtSubscriptionDependency[];\r\n tables: string[];\r\n ephemeral: boolean;\r\n ttlSeconds: number;\r\n heavy: boolean;\r\n moveOutPolicy: G9EMoveOutPolicy;\r\n reconcileIntervalMinutes: number;\r\n definitionHash: string;\r\n}\r\n\r\nexport interface G9DtSubscriptionState {\r\n key: string;\r\n action: G9ESubscriptionAction;\r\n definitionHash?: string | null;\r\n authHash?: string | null;\r\n message?: string | null;\r\n}\r\n\r\nexport interface G9DtHelloResult {\r\n epoch: string;\r\n /** Server clock at the answer, epoch milliseconds UTC (.NET `DateTime ServerTimeUtc`). */\r\n serverTimeUtcMs: number;\r\n protocolVersion: number;\r\n tables: G9DtNegotiatedTable[];\r\n unknownTables: string[];\r\n definitions: G9DtSubscriptionDefinition[];\r\n subscriptions: G9DtSubscriptionState[];\r\n maxPushRows: number;\r\n maxPushBytes: number;\r\n error?: G9DtSyncError | null;\r\n}\r\n\r\n// ---------------------------------------------------------------- push / pull\r\n\r\nexport interface G9DtTableColumns {\r\n tableId: number;\r\n columns: string[];\r\n}\r\n\r\nexport interface G9DtRowRef {\r\n tableId: number;\r\n key: string;\r\n}\r\n\r\nexport interface G9DtCommand {\r\n commandId: string;\r\n sequence: number;\r\n name: string;\r\n version: number;\r\n payload: string;\r\n createdUtcMs: number;\r\n touched: G9DtRowRef[];\r\n}\r\n\r\nexport interface G9DtCommandResult {\r\n commandId: string;\r\n status: G9ECommandStatus;\r\n code?: string | null;\r\n message?: string | null;\r\n result?: string | null;\r\n}\r\n\r\nexport interface G9DtPushRequest {\r\n clientId: string;\r\n batchId: number;\r\n subscriptions: G9DtSubscriptionRef[];\r\n tables: G9DtTableColumns[];\r\n commands: G9DtCommand[];\r\n heldTables: G9DtTableColumns[];\r\n frameVersion: number;\r\n}\r\n\r\nexport interface G9DtAcceptedRows {\r\n tableId: number;\r\n keys: string[];\r\n versions: number[];\r\n deleted: boolean[];\r\n}\r\n\r\nexport interface G9DtRowRejection {\r\n tableId: number;\r\n key: string;\r\n code: string;\r\n message?: string | null;\r\n sqlState?: string | null;\r\n constraint?: string | null;\r\n column?: string | null;\r\n details?: string | null;\r\n}\r\n\r\nexport interface G9DtRowConflict {\r\n tableId: number;\r\n key: string;\r\n code: string;\r\n /** Bits (push column order) the server changed after the client's base version; -1 when unknown. */\r\n serverChangedMask: G9Long;\r\n partiallyApplied: boolean;\r\n}\r\n\r\nexport interface G9DtPushResult {\r\n batchId: number;\r\n alreadyApplied: boolean;\r\n accepted: G9DtAcceptedRows[];\r\n rejections: G9DtRowRejection[];\r\n conflicts: G9DtRowConflict[];\r\n canonicalFrames: Uint8Array[];\r\n commandResults: G9DtCommandResult[];\r\n error?: G9DtSyncError | null;\r\n}\r\n\r\nexport interface G9DtBackfillRequest {\r\n tableId: number;\r\n columns: string[];\r\n}\r\n\r\nexport interface G9DtPullRequest {\r\n clientId: string;\r\n subscriptions: G9DtSubscriptionRef[];\r\n tables: G9DtTableColumns[];\r\n backfills: G9DtBackfillRequest[];\r\n frameVersion: number;\r\n /** Set when the client accepts large first downloads as SQLite snapshot files (ADR-0072); absent = rows only. */\r\n snapshotFiles?: G9DtSnapshotFileRequest | null;\r\n}\r\n\r\nexport interface G9DtPlannedPart {\r\n subscriptionKey: string;\r\n /** 0 for a snapshot-file part, whose tables are in `file`. */\r\n tableId: number;\r\n kind: G9EPullPartKind;\r\n rows: number;\r\n estimatedBytes: number;\r\n /** The file a snapshot-file part delivers; null for every other kind. */\r\n file?: G9DtPlannedFile | null;\r\n}\r\n\r\n// ---------------------------------------------------------------- snapshot files (ADR-0072)\r\n\r\n/** The client's offer to receive snapshot files: its storage forms and the shape of every table it receives. */\r\nexport interface G9DtSnapshotFileRequest {\r\n formatVersion: number;\r\n storage: G9DtSnapshotFileStorage;\r\n tables: G9DtSnapshotFileTable[];\r\n minRows: number;\r\n maxBytes: number;\r\n maxFiles: number;\r\n}\r\n\r\nexport interface G9DtSnapshotFileStorage {\r\n dateTimeAsTicks: boolean;\r\n dateTimeFormat: string;\r\n decimalAsText: boolean;\r\n}\r\n\r\n/** One device table: local name, key and synced columns in LOCAL order, declared indexes. */\r\nexport interface G9DtSnapshotFileTable {\r\n tableId: number;\r\n localName: string;\r\n keyColumn: string;\r\n keyType: G9ESyncColumnType;\r\n columns: G9DtColumnModel[];\r\n indexes: G9DtSnapshotFileIndex[];\r\n}\r\n\r\nexport interface G9DtSnapshotFileIndex {\r\n name: string;\r\n columns: string[];\r\n unique: boolean;\r\n}\r\n\r\nexport interface G9DtPlannedFile {\r\n fileId: string;\r\n /** When the server's state the file holds was taken (epoch ms UTC; .NET `DateTime SnapshotUtc`). */\r\n snapshotUtcMs: number;\r\n tables: G9DtPlannedFileTable[];\r\n}\r\n\r\nexport interface G9DtPlannedFileTable {\r\n tableId: number;\r\n rows: number;\r\n}\r\n\r\n/** One segment of a snapshot file: `length` raw bytes at `offset`, compressed on its own. */\r\nexport interface G9DtFileSegment {\r\n fileId: string;\r\n index: number;\r\n offset: number;\r\n length: number;\r\n /** SHA-256 of the raw segment, lower-case hex. */\r\n sha256: string;\r\n /** Set on the first segment a stream sends for the file (also after a resume). */\r\n manifest?: G9DtSnapshotFileManifest | null;\r\n}\r\n\r\nexport interface G9DtSnapshotFileManifest {\r\n fileId: string;\r\n formatVersion: number;\r\n bytes: number;\r\n segmentBytes: number;\r\n segments: number;\r\n sha256: string;\r\n compression: string;\r\n /** Epoch ms UTC (.NET `DateTime BuiltUtc`). */\r\n builtUtcMs: number;\r\n tables: G9DtSnapshotFileTableInfo[];\r\n}\r\n\r\nexport interface G9DtSnapshotFileTableInfo {\r\n tableId: number;\r\n name: string;\r\n versionTable: string;\r\n rows: number;\r\n}\r\n\r\nexport interface G9DtSubscriptionCursor {\r\n key: string;\r\n cursor: string;\r\n definitionHash: string;\r\n authHash: string;\r\n}\r\n\r\nexport interface G9DtPullPlan {\r\n token: string;\r\n parts: G9DtPlannedPart[];\r\n totalRows: number;\r\n estimatedBytes: number;\r\n cursors: G9DtSubscriptionCursor[];\r\n skipped: G9DtSubscriptionState[];\r\n error?: G9DtSyncError | null;\r\n}\r\n\r\nexport interface G9DtTableDigest {\r\n tableId: number;\r\n computedColumns: string[];\r\n /** 256 bucket digests (XOR of row hashes). */\r\n digests: G9Long[];\r\n /** 256 bucket row counts. */\r\n counts: number[];\r\n}\r\n\r\nexport interface G9DtReconcileRequest {\r\n clientId: string;\r\n subscription: G9DtSubscriptionRef;\r\n tables: G9DtTableDigest[];\r\n frameVersion: number;\r\n}\r\n\r\nexport interface G9DtTableBuckets {\r\n tableId: number;\r\n buckets: number[];\r\n}\r\n\r\nexport interface G9DtReconcileSummary {\r\n cursor: string;\r\n definitionHash: string;\r\n authHash: string;\r\n mismatched: G9DtTableBuckets[];\r\n}\r\n\r\nexport interface G9DtFetchRowsRequest {\r\n clientId: string;\r\n subscription: G9DtSubscriptionRef;\r\n tableId: number;\r\n keys: string[];\r\n columns: string[];\r\n frameVersion: number;\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"dtos.js","sourceRoot":"","sources":["../../src/protocol/dtos.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAG5D,4FAA4F;AAC5F,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,EAAE,EAAE,CAAC;IACL,OAAO,EAAE,CAAC;IACV,SAAS,EAAE,CAAC;IACZ,cAAc,EAAE,CAAC;IACjB,OAAO,EAAE,CAAC;IACV,iBAAiB,EAAE,CAAC;IACpB,SAAS,EAAE,CAAC;CACJ,CAAC;AAGX,uDAAuD;AACvD,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,QAAQ,EAAE,CAAC;IACX,KAAK,EAAE,CAAC;IACR,QAAQ,EAAE,CAAC;IACX,+GAA+G;IAC/G,YAAY,EAAE,CAAC;CACP,CAAC;AAGX,wEAAwE;AACxE,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,EAAE,EAAE,CAAC;IACL,QAAQ,EAAE,CAAC;IACX,UAAU,EAAE,CAAC;CACL,CAAC;AAYX,qCAAqC;AACrC,MAAM,UAAU,oBAAoB,CAAC,KAAoB;;IACvD,OAAO,IAAI,eAAe,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,KAAK,CAAC,SAAS,EAAE,OAAO,EAAE,MAAA,KAAK,CAAC,OAAO,mCAAI,IAAI,EAAE,CAAC,CAAC;AACxH,CAAC;AAED,uCAAuC;AACvC,MAAM,UAAU,aAAa,CAAC,SAA0B;IACtD,OAAO,EAAE,IAAI,EAAE,SAAS,CAAC,IAAI,EAAE,OAAO,EAAE,SAAS,CAAC,OAAO,EAAE,SAAS,EAAE,SAAS,CAAC,SAAS,EAAE,OAAO,EAAE,SAAS,CAAC,OAAO,EAAE,CAAC;AAC1H,CAAC","sourcesContent":["// Twins of G9SyncData.Protocol/Dtos/*.cs. Property names are the camelCase of the .NET names (the JSON wire names);\n// the MessagePack codec maps them to the PascalCase keys Nerdbank.MessagePack writes. .NET `long` values are numbers\n// except where they must stay exact: reconciliation digests and conflict masks are G9Long.\nimport type { G9EConflictPolicy, G9EMoveOutPolicy, G9ESyncColumnType, G9ESyncDirection } from '../abstractions/enums.js';\nimport { G9SyncException } from '../abstractions/errors.js';\nimport type { G9Long } from '../abstractions/long.js';\n\n/** What a subscription must do next, as decided by the server (`G9ESubscriptionAction`). */\nexport const G9ESubscriptionAction = {\n Ok: 0,\n Initial: 1,\n Reconcile: 2,\n ResyncRequired: 3,\n Unknown: 4,\n InvalidParameters: 5,\n Forbidden: 6,\n} as const;\nexport type G9ESubscriptionAction = (typeof G9ESubscriptionAction)[keyof typeof G9ESubscriptionAction];\n\n/** Kind of a planned pull part (`G9EPullPartKind`). */\nexport const G9EPullPartKind = {\n Snapshot: 0,\n Delta: 1,\n Backfill: 2,\n /** A subscription's snapshot as a SQLite file (ADR-0072), streamed as file segments (`G9DtSyncChunk.file`). */\n SnapshotFile: 3,\n} as const;\nexport type G9EPullPartKind = (typeof G9EPullPartKind)[keyof typeof G9EPullPartKind];\n\n/** Outcome of a command executed by the server (`G9ECommandStatus`). */\nexport const G9ECommandStatus = {\n Ok: 0,\n Rejected: 1,\n Superseded: 2,\n} as const;\nexport type G9ECommandStatus = (typeof G9ECommandStatus)[keyof typeof G9ECommandStatus];\n\n// ---------------------------------------------------------------- common\n\nexport interface G9DtSyncError {\n code: string;\n message: string;\n retryable: boolean;\n details?: string | null;\n}\n\n/** `G9DtSyncError.ToException()`. */\nexport function syncErrorToException(error: G9DtSyncError): G9SyncException {\n return new G9SyncException(error.code, error.message, { retryable: error.retryable, details: error.details ?? null });\n}\n\n/** `G9DtSyncError.From(exception)`. */\nexport function syncErrorFrom(exception: G9SyncException): G9DtSyncError {\n return { code: exception.code, message: exception.message, retryable: exception.retryable, details: exception.details };\n}\n\nexport interface G9DtColumnModel {\n name: string;\n type: G9ESyncColumnType;\n nullable: boolean;\n}\n\n/** A subscription as the client holds it: name, canonical parameters and its sync state. */\nexport interface G9DtSubscriptionRef {\n name: string;\n parameters: { [name: string]: string };\n /** Opaque server cursor of the last completed pull. Null before the first pull. */\n cursor?: string | null;\n definitionHash?: string | null;\n authHash?: string | null;\n}\n\n/** Resume point after a chunk. Only chunks that carry one are safe restart points. */\nexport interface G9DtPullContinuation {\n partIndex: number;\n afterKey?: string | null;\n nextSequence: number;\n}\n\n/** One unit of a data stream; `payload` is a G9RowBatch frame. */\nexport interface G9DtSyncChunk {\n sequence: number;\n payload?: Uint8Array | null;\n rowCount: number;\n subscriptionKey?: string | null;\n isFinal: boolean;\n continuation?: G9DtPullContinuation | null;\n reconcileSummary?: G9DtReconcileSummary | null;\n /** Set when the chunk carries a snapshot-file segment (ADR-0072): `payload` is then the segment, Brotli-compressed on its own. */\n file?: G9DtFileSegment | null;\n}\n\n/** Server → client hint that tables changed. */\nexport interface G9DtChangesAvailable {\n tables: string[];\n}\n\n// ---------------------------------------------------------------- hello\n\nexport interface G9DtClientTableModel {\n name: string;\n keyColumn: string;\n keyType: G9ESyncColumnType;\n columns: G9DtColumnModel[];\n}\n\nexport interface G9DtHelloRequest {\n clientId: string;\n appVersion?: string | null;\n protocolVersion: number;\n tables: G9DtClientTableModel[];\n subscriptions: G9DtSubscriptionRef[];\n /** Instead of `tables` (sent empty): the server's id of the same model, given earlier on THIS connection (1.5.21). */\n modelHash?: string | null;\n /** The `tablesHash` of the negotiated tables the client holds: the same on the server → `tablesUnchanged` (1.5.21). */\n knownTablesHash?: string | null;\n /** The `definitionsHash` of the definitions the client holds: the same on the server → `definitionsUnchanged` (1.5.21). */\n knownDefinitionsHash?: string | null;\n}\n\nexport interface G9DtColumnTypeMismatch {\n name: string;\n clientType: G9ESyncColumnType;\n serverType: G9ESyncColumnType;\n}\n\n/** The column set both sides agreed on for one table. */\nexport interface G9DtNegotiatedTable {\n tableId: number;\n name: string;\n keyColumn: string;\n keyType: G9ESyncColumnType;\n columns: G9DtColumnModel[];\n computedColumns: string[];\n readOnlyColumns: string[];\n missingColumns: string[];\n typeMismatchColumns: G9DtColumnTypeMismatch[];\n direction: G9ESyncDirection;\n conflictPolicy: G9EConflictPolicy;\n}\n\nexport interface G9DtParameterDefinition {\n name: string;\n type: G9ESyncColumnType;\n required: boolean;\n isList: boolean;\n}\n\nexport interface G9DtSubscriptionDependency {\n name: string;\n required: boolean;\n}\n\nexport interface G9DtSubscriptionDefinition {\n name: string;\n parameters: G9DtParameterDefinition[];\n dependsOn: G9DtSubscriptionDependency[];\n tables: string[];\n ephemeral: boolean;\n ttlSeconds: number;\n heavy: boolean;\n moveOutPolicy: G9EMoveOutPolicy;\n reconcileIntervalMinutes: number;\n definitionHash: string;\n}\n\nexport interface G9DtSubscriptionState {\n key: string;\n action: G9ESubscriptionAction;\n definitionHash?: string | null;\n authHash?: string | null;\n message?: string | null;\n}\n\nexport interface G9DtHelloResult {\n epoch: string;\n /** Server clock at the answer, epoch milliseconds UTC (.NET `DateTime ServerTimeUtc`). */\n serverTimeUtcMs: number;\n protocolVersion: number;\n tables: G9DtNegotiatedTable[];\n unknownTables: string[];\n definitions: G9DtSubscriptionDefinition[];\n subscriptions: G9DtSubscriptionState[];\n maxPushRows: number;\n maxPushBytes: number;\n error?: G9DtSyncError | null;\n /** The server's id of the client model this Hello was negotiated from (1.5.21); null from an older server. */\n modelHash?: string | null;\n /** The request named a model the server no longer holds: send the Hello again WITH the tables (1.5.21). */\n modelRequired?: boolean;\n tablesHash?: string | null;\n /** `tables` and `unknownTables` were left out: the client holds them (1.5.21). */\n tablesUnchanged?: boolean;\n definitionsHash?: string | null;\n /** `definitions` was left out: the client holds it (1.5.21). */\n definitionsUnchanged?: boolean;\n}\n\n// ---------------------------------------------------------------- push / pull\n\nexport interface G9DtTableColumns {\n tableId: number;\n columns: string[];\n}\n\nexport interface G9DtRowRef {\n tableId: number;\n key: string;\n}\n\nexport interface G9DtCommand {\n commandId: string;\n sequence: number;\n name: string;\n version: number;\n payload: string;\n createdUtcMs: number;\n touched: G9DtRowRef[];\n}\n\nexport interface G9DtCommandResult {\n commandId: string;\n status: G9ECommandStatus;\n code?: string | null;\n message?: string | null;\n result?: string | null;\n}\n\nexport interface G9DtPushRequest {\n clientId: string;\n batchId: number;\n subscriptions: G9DtSubscriptionRef[];\n tables: G9DtTableColumns[];\n commands: G9DtCommand[];\n heldTables: G9DtTableColumns[];\n frameVersion: number;\n}\n\nexport interface G9DtAcceptedRows {\n tableId: number;\n keys: string[];\n versions: number[];\n deleted: boolean[];\n}\n\nexport interface G9DtRowRejection {\n tableId: number;\n key: string;\n code: string;\n message?: string | null;\n sqlState?: string | null;\n constraint?: string | null;\n column?: string | null;\n details?: string | null;\n}\n\nexport interface G9DtRowConflict {\n tableId: number;\n key: string;\n code: string;\n /** Bits (push column order) the server changed after the client's base version; -1 when unknown. */\n serverChangedMask: G9Long;\n partiallyApplied: boolean;\n}\n\nexport interface G9DtPushResult {\n batchId: number;\n alreadyApplied: boolean;\n accepted: G9DtAcceptedRows[];\n rejections: G9DtRowRejection[];\n conflicts: G9DtRowConflict[];\n canonicalFrames: Uint8Array[];\n commandResults: G9DtCommandResult[];\n error?: G9DtSyncError | null;\n}\n\nexport interface G9DtBackfillRequest {\n tableId: number;\n columns: string[];\n}\n\nexport interface G9DtPullRequest {\n clientId: string;\n subscriptions: G9DtSubscriptionRef[];\n tables: G9DtTableColumns[];\n backfills: G9DtBackfillRequest[];\n frameVersion: number;\n /** Set when the client accepts large first downloads as SQLite snapshot files (ADR-0072); absent = rows only. */\n snapshotFiles?: G9DtSnapshotFileRequest | null;\n}\n\nexport interface G9DtPlannedPart {\n subscriptionKey: string;\n /** 0 for a snapshot-file part, whose tables are in `file`. */\n tableId: number;\n kind: G9EPullPartKind;\n rows: number;\n estimatedBytes: number;\n /** The file a snapshot-file part delivers; null for every other kind. */\n file?: G9DtPlannedFile | null;\n}\n\n// ---------------------------------------------------------------- snapshot files (ADR-0072)\n\n/** The client's offer to receive snapshot files: its storage forms and the shape of every table it receives. */\nexport interface G9DtSnapshotFileRequest {\n formatVersion: number;\n storage: G9DtSnapshotFileStorage;\n tables: G9DtSnapshotFileTable[];\n minRows: number;\n maxBytes: number;\n maxFiles: number;\n}\n\nexport interface G9DtSnapshotFileStorage {\n dateTimeAsTicks: boolean;\n dateTimeFormat: string;\n decimalAsText: boolean;\n}\n\n/** One device table: local name, key and synced columns in LOCAL order, declared indexes. */\nexport interface G9DtSnapshotFileTable {\n tableId: number;\n localName: string;\n keyColumn: string;\n keyType: G9ESyncColumnType;\n columns: G9DtColumnModel[];\n indexes: G9DtSnapshotFileIndex[];\n}\n\nexport interface G9DtSnapshotFileIndex {\n name: string;\n columns: string[];\n unique: boolean;\n}\n\nexport interface G9DtPlannedFile {\n fileId: string;\n /** When the server's state the file holds was taken (epoch ms UTC; .NET `DateTime SnapshotUtc`). */\n snapshotUtcMs: number;\n tables: G9DtPlannedFileTable[];\n}\n\nexport interface G9DtPlannedFileTable {\n tableId: number;\n rows: number;\n}\n\n/** One segment of a snapshot file: `length` raw bytes at `offset`, compressed on its own. */\nexport interface G9DtFileSegment {\n fileId: string;\n index: number;\n offset: number;\n length: number;\n /** SHA-256 of the raw segment, lower-case hex. */\n sha256: string;\n /** Set on the first segment a stream sends for the file (also after a resume). */\n manifest?: G9DtSnapshotFileManifest | null;\n}\n\nexport interface G9DtSnapshotFileManifest {\n fileId: string;\n formatVersion: number;\n bytes: number;\n segmentBytes: number;\n segments: number;\n sha256: string;\n compression: string;\n /** Epoch ms UTC (.NET `DateTime BuiltUtc`). */\n builtUtcMs: number;\n tables: G9DtSnapshotFileTableInfo[];\n}\n\nexport interface G9DtSnapshotFileTableInfo {\n tableId: number;\n name: string;\n versionTable: string;\n rows: number;\n}\n\nexport interface G9DtSubscriptionCursor {\n key: string;\n cursor: string;\n definitionHash: string;\n authHash: string;\n}\n\nexport interface G9DtPullPlan {\n token: string;\n parts: G9DtPlannedPart[];\n totalRows: number;\n estimatedBytes: number;\n cursors: G9DtSubscriptionCursor[];\n skipped: G9DtSubscriptionState[];\n error?: G9DtSyncError | null;\n}\n\nexport interface G9DtTableDigest {\n tableId: number;\n computedColumns: string[];\n /** 256 bucket digests (XOR of row hashes). */\n digests: G9Long[];\n /** 256 bucket row counts. */\n counts: number[];\n}\n\nexport interface G9DtReconcileRequest {\n clientId: string;\n subscription: G9DtSubscriptionRef;\n tables: G9DtTableDigest[];\n frameVersion: number;\n}\n\nexport interface G9DtTableBuckets {\n tableId: number;\n buckets: number[];\n}\n\nexport interface G9DtReconcileSummary {\n cursor: string;\n definitionHash: string;\n authHash: string;\n mismatched: G9DtTableBuckets[];\n}\n\nexport interface G9DtFetchRowsRequest {\n clientId: string;\n subscription: G9DtSubscriptionRef;\n tableId: number;\n keys: string[];\n columns: string[];\n frameVersion: number;\n}\n"]}
|
package/dist/protocol/wire.js
CHANGED
|
@@ -218,6 +218,12 @@ export function readHelloResult(value) {
|
|
|
218
218
|
maxPushRows: num(v.maxPushRows),
|
|
219
219
|
maxPushBytes: num(v.maxPushBytes),
|
|
220
220
|
error: readSyncError(v.error),
|
|
221
|
+
modelHash: optStr(v.modelHash),
|
|
222
|
+
modelRequired: bool(v.modelRequired),
|
|
223
|
+
tablesHash: optStr(v.tablesHash),
|
|
224
|
+
tablesUnchanged: bool(v.tablesUnchanged),
|
|
225
|
+
definitionsHash: optStr(v.definitionsHash),
|
|
226
|
+
definitionsUnchanged: bool(v.definitionsUnchanged),
|
|
221
227
|
};
|
|
222
228
|
}
|
|
223
229
|
function readAccepted(value) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wire.js","sourceRoot":"","sources":["../../src/protocol/wire.ts"],"names":[],"mappings":"AAAA,oHAAoH;AACpH,qHAAqH;AACrH,qHAAqH;AACrH,yFAAyF;AACzF,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AA8BtD,6HAA6H;AAC7H,MAAM,OAAO,UAAU;IAGrB,YAAY,KAAa;QACvB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;CACF;AAED,6DAA6D;AAC7D,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,CAAC;AAIrC,SAAS,aAAa,CAAC,KAAc;IACnC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,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sourcesContent":["// The wire forms of the DTOs. Both SignalR protocols are decoded to plain objects first — JSON with camelCase names\r\n// (System.Text.Json, G9SyncJsonContext), MessagePack with the PascalCase names Nerdbank.MessagePack writes, GUIDs as\r\n// extension type 2 (16 big-endian bytes) and DateTime as the timestamp extension — then normalised here into the DTO\r\n// interfaces, with every missing field defaulted the way .NET's initialisers default it.\r\nimport { G9Long, longToNumber } from '../abstractions/long.js';\r\nimport { tryNormalizeGuid } from '../abstractions/guid.js';\r\nimport { base64ToBytes } from '../internal/base64.js';\r\nimport type {\r\n G9DtAcceptedRows,\r\n G9DtChangesAvailable,\r\n G9DtColumnModel,\r\n G9DtColumnTypeMismatch,\r\n G9DtCommandResult,\r\n G9DtHelloResult,\r\n G9DtNegotiatedTable,\r\n G9DtFileSegment,\r\n G9DtPlannedFile,\r\n G9DtPlannedPart,\r\n G9DtPullContinuation,\r\n G9DtSnapshotFileManifest,\r\n G9DtPullPlan,\r\n G9DtPushResult,\r\n G9DtReconcileSummary,\r\n G9DtRowConflict,\r\n G9DtRowRejection,\r\n G9DtSubscriptionCursor,\r\n G9DtSubscriptionDefinition,\r\n G9DtSubscriptionState,\r\n G9DtSyncChunk,\r\n G9DtSyncError,\r\n G9DtTableBuckets,\r\n} from './dtos.js';\r\n\r\n/** Which SignalR hub protocol a value came from or goes to. */\r\nexport type G9WireFormat = 'json' | 'messagepack';\r\n\r\n/** A GUID on its way into MessagePack (written as extension type 2, 16 big-endian bytes, like Nerdbank's Guid converter). */\r\nexport class G9WireGuid {\r\n readonly value: string;\r\n\r\n constructor(value: string) {\r\n this.value = value;\r\n }\r\n}\r\n\r\n/** Nerdbank.MessagePack's extension type for System.Guid. */\r\nexport const GUID_EXTENSION_TYPE = 2;\r\n\r\ntype Plain = { [key: string]: unknown };\r\n\r\nfunction isPlainObject(value: unknown): value is Plain {\r\n return typeof value === 'object' && value !== null && !Array.isArray(value) && !(value instanceof Uint8Array) && !(value instanceof G9Long) && !(value instanceof Date) && !(value instanceof G9WireGuid);\r\n}\r\n\r\nfunction lowerFirst(name: string): string {\r\n return name.length === 0 ? name : name.charAt(0).toLowerCase() + name.slice(1);\r\n}\r\n\r\nfunction upperFirst(name: string): string {\r\n return name.length === 0 ? name : name.charAt(0).toUpperCase() + name.slice(1);\r\n}\r\n\r\n/** The camelCase twin of a decoded MessagePack value (a `Parameters` dictionary keeps its own keys). */\r\nexport function fromMessagePackNames(value: unknown): unknown {\r\n if (Array.isArray(value)) return value.map(fromMessagePackNames);\r\n if (!isPlainObject(value)) return value;\r\n const out: Plain = {};\r\n for (const key of Object.keys(value)) {\r\n const item = value[key];\r\n out[lowerFirst(key)] = key === 'Parameters' && isPlainObject(item) ? copyDictionary(item) : fromMessagePackNames(item);\r\n }\r\n return out;\r\n}\r\n\r\n/**\r\n * The MessagePack form of an outgoing DTO: PascalCase names (a `parameters` dictionary keeps its keys), GUID fields as\r\n * {@link G9WireGuid}. G9Long values stay as they are (the protocol writes them as int64).\r\n */\r\nexport function toMessagePackNames(value: unknown): unknown {\r\n if (Array.isArray(value)) return value.map(toMessagePackNames);\r\n if (!isPlainObject(value)) return value;\r\n const out: Plain = {};\r\n for (const key of Object.keys(value)) {\r\n const item = value[key];\r\n if (item === undefined) continue;\r\n let mapped: unknown;\r\n if (key === 'parameters' && isPlainObject(item)) mapped = copyDictionary(item);\r\n else if (GUID_FIELDS[key] === true && typeof item === 'string') mapped = new G9WireGuid(item);\r\n else mapped = toMessagePackNames(item);\r\n out[upperFirst(key)] = mapped;\r\n }\r\n return out;\r\n}\r\n\r\n/** DTO fields typed System.Guid on the .NET side. */\r\nconst GUID_FIELDS: { [key: string]: true } = { clientId: true, commandId: true, epoch: true };\r\n\r\nfunction copyDictionary(value: Plain): { [key: string]: string } {\r\n const out: { [key: string]: string } = {};\r\n for (const key of Object.keys(value)) out[key] = String(value[key]);\r\n return out;\r\n}\r\n\r\n// ---------------------------------------------------------------- field readers\r\n\r\nfunction obj(value: unknown): Plain {\r\n return isPlainObject(value) ? value : {};\r\n}\r\n\r\nfunction str(value: unknown, fallback = ''): string {\r\n return typeof value === 'string' ? value : fallback;\r\n}\r\n\r\nfunction optStr(value: unknown): string | null {\r\n return typeof value === 'string' ? value : null;\r\n}\r\n\r\nfunction num(value: unknown): number {\r\n return value === null || value === undefined ? 0 : longToNumber(value);\r\n}\r\n\r\nfunction bool(value: unknown): boolean {\r\n return value === true;\r\n}\r\n\r\nfunction long(value: unknown): G9Long {\r\n if (value instanceof G9Long) return value;\r\n if (typeof value === 'number') return G9Long.fromNumber(value);\r\n if (typeof value === 'string' && value !== '') return G9Long.parse(value);\r\n return G9Long.ZERO;\r\n}\r\n\r\nfunction arr(value: unknown): unknown[] {\r\n return Array.isArray(value) ? value : [];\r\n}\r\n\r\nfunction strings(value: unknown): string[] {\r\n return arr(value).map((v) => str(v));\r\n}\r\n\r\nfunction guid(value: unknown): string {\r\n if (value instanceof G9WireGuid) return value.value;\r\n if (typeof value === 'string') return tryNormalizeGuid(value) ?? value;\r\n return '00000000-0000-0000-0000-000000000000';\r\n}\r\n\r\n/** A byte[] field: base64 text (JSON) or bytes (MessagePack). */\r\nexport function bytesField(value: unknown): Uint8Array | null {\r\n if (value instanceof Uint8Array) return value;\r\n if (typeof value === 'string') return base64ToBytes(value);\r\n if (value instanceof ArrayBuffer) return new Uint8Array(value);\r\n return null;\r\n}\r\n\r\n/** Epoch milliseconds of a wire DateTime: ISO text (JSON) or a Date (MessagePack timestamp). */\r\nexport function dateTimeMs(value: unknown): number {\r\n if (value instanceof Date) return value.getTime();\r\n if (typeof value === 'number') return value;\r\n if (typeof value !== 'string') return 0;\r\n const m = /^(\\d{4})-(\\d{2})-(\\d{2})[T ](\\d{2}):(\\d{2})(?::(\\d{2})(?:\\.(\\d+))?)?(Z|[+-]\\d{2}:?\\d{2})?$/.exec(value.trim());\r\n if (!m) return 0;\r\n const fraction = m[7] ? (m[7] + '00').slice(0, 3) : '0';\r\n let ms = Date.UTC(+(m[1] as string), +(m[2] as string) - 1, +(m[3] as string), +(m[4] as string), +(m[5] as string), m[6] ? +m[6] : 0, +fraction);\r\n // Date.UTC maps years 0..99 to 1900..1999.\r\n if (+(m[1] as string) < 100) {\r\n const date = new Date(ms);\r\n date.setUTCFullYear(+(m[1] as string));\r\n ms = date.getTime();\r\n }\r\n const zone = m[8];\r\n if (zone && zone !== 'Z') {\r\n const sign = zone.charAt(0) === '-' ? -1 : 1;\r\n const digits = zone.slice(1).replace(':', '');\r\n ms -= sign * (+digits.slice(0, 2) * 60 + +digits.slice(2, 4)) * 60000;\r\n }\r\n return ms;\r\n}\r\n\r\n// ---------------------------------------------------------------- DTO readers (camelCase input)\r\n\r\nexport function readSyncError(value: unknown): G9DtSyncError | null {\r\n if (!isPlainObject(value)) return null;\r\n return { code: str(value.code, 'G9S-SRV-ERROR'), message: str(value.message), retryable: bool(value.retryable), details: optStr(value.details) };\r\n}\r\n\r\nfunction readColumn(value: unknown): G9DtColumnModel {\r\n const v = obj(value);\r\n return { name: str(v.name), type: num(v.type) as G9DtColumnModel['type'], nullable: bool(v.nullable) };\r\n}\r\n\r\nfunction readMismatch(value: unknown): G9DtColumnTypeMismatch {\r\n const v = obj(value);\r\n return { name: str(v.name), clientType: num(v.clientType) as G9DtColumnTypeMismatch['clientType'], serverType: num(v.serverType) as G9DtColumnTypeMismatch['serverType'] };\r\n}\r\n\r\nexport function readNegotiatedTable(value: unknown): G9DtNegotiatedTable {\r\n const v = obj(value);\r\n return {\r\n tableId: num(v.tableId),\r\n name: str(v.name),\r\n keyColumn: str(v.keyColumn),\r\n keyType: num(v.keyType) as G9DtNegotiatedTable['keyType'],\r\n columns: arr(v.columns).map(readColumn),\r\n computedColumns: strings(v.computedColumns),\r\n readOnlyColumns: strings(v.readOnlyColumns),\r\n missingColumns: strings(v.missingColumns),\r\n typeMismatchColumns: arr(v.typeMismatchColumns).map(readMismatch),\r\n direction: num(v.direction) as G9DtNegotiatedTable['direction'],\r\n conflictPolicy: num(v.conflictPolicy) as G9DtNegotiatedTable['conflictPolicy'],\r\n };\r\n}\r\n\r\nexport function readSubscriptionDefinition(value: unknown): G9DtSubscriptionDefinition {\r\n const v = obj(value);\r\n return {\r\n name: str(v.name),\r\n parameters: arr(v.parameters).map((p) => {\r\n const d = obj(p);\r\n return { name: str(d.name), type: num(d.type) as G9DtColumnModel['type'], required: bool(d.required), isList: bool(d.isList) };\r\n }),\r\n dependsOn: arr(v.dependsOn).map((p) => {\r\n const d = obj(p);\r\n return { name: str(d.name), required: d.required === undefined ? true : bool(d.required) };\r\n }),\r\n tables: strings(v.tables),\r\n ephemeral: bool(v.ephemeral),\r\n ttlSeconds: num(v.ttlSeconds),\r\n heavy: bool(v.heavy),\r\n moveOutPolicy: num(v.moveOutPolicy) as G9DtSubscriptionDefinition['moveOutPolicy'],\r\n reconcileIntervalMinutes: num(v.reconcileIntervalMinutes),\r\n definitionHash: str(v.definitionHash),\r\n };\r\n}\r\n\r\nexport function readSubscriptionState(value: unknown): G9DtSubscriptionState {\r\n const v = obj(value);\r\n return {\r\n key: str(v.key),\r\n action: num(v.action) as G9DtSubscriptionState['action'],\r\n definitionHash: optStr(v.definitionHash),\r\n authHash: optStr(v.authHash),\r\n message: optStr(v.message),\r\n };\r\n}\r\n\r\nexport function readHelloResult(value: unknown): G9DtHelloResult {\r\n const v = obj(value);\r\n return {\r\n epoch: guid(v.epoch),\r\n serverTimeUtcMs: dateTimeMs(v.serverTimeUtc),\r\n protocolVersion: v.protocolVersion === undefined ? 1 : num(v.protocolVersion),\r\n tables: arr(v.tables).map(readNegotiatedTable),\r\n unknownTables: strings(v.unknownTables),\r\n definitions: arr(v.definitions).map(readSubscriptionDefinition),\r\n subscriptions: arr(v.subscriptions).map(readSubscriptionState),\r\n maxPushRows: num(v.maxPushRows),\r\n maxPushBytes: num(v.maxPushBytes),\r\n error: readSyncError(v.error),\r\n };\r\n}\r\n\r\nfunction readAccepted(value: unknown): G9DtAcceptedRows {\r\n const v = obj(value);\r\n return { tableId: num(v.tableId), keys: strings(v.keys), versions: arr(v.versions).map(num), deleted: arr(v.deleted).map(bool) };\r\n}\r\n\r\nfunction readRejection(value: unknown): G9DtRowRejection {\r\n const v = obj(value);\r\n return {\r\n tableId: num(v.tableId),\r\n key: str(v.key),\r\n code: str(v.code, 'G9S-REJ-CONSTRAINT'),\r\n message: optStr(v.message),\r\n sqlState: optStr(v.sqlState),\r\n constraint: optStr(v.constraint),\r\n column: optStr(v.column),\r\n details: optStr(v.details),\r\n };\r\n}\r\n\r\nfunction readConflict(value: unknown): G9DtRowConflict {\r\n const v = obj(value);\r\n return {\r\n tableId: num(v.tableId),\r\n key: str(v.key),\r\n code: str(v.code, 'G9S-CON-SERVER-WINS'),\r\n serverChangedMask: long(v.serverChangedMask),\r\n partiallyApplied: bool(v.partiallyApplied),\r\n };\r\n}\r\n\r\nfunction readCommandResult(value: unknown): G9DtCommandResult {\r\n const v = obj(value);\r\n return { commandId: guid(v.commandId), status: num(v.status) as G9DtCommandResult['status'], code: optStr(v.code), message: optStr(v.message), result: optStr(v.result) };\r\n}\r\n\r\nexport function readPushResult(value: unknown): G9DtPushResult {\r\n const v = obj(value);\r\n return {\r\n batchId: num(v.batchId),\r\n alreadyApplied: bool(v.alreadyApplied),\r\n accepted: arr(v.accepted).map(readAccepted),\r\n rejections: arr(v.rejections).map(readRejection),\r\n conflicts: arr(v.conflicts).map(readConflict),\r\n canonicalFrames: arr(v.canonicalFrames)\r\n .map(bytesField)\r\n .filter((b): b is Uint8Array => b !== null),\r\n commandResults: arr(v.commandResults).map(readCommandResult),\r\n error: readSyncError(v.error),\r\n };\r\n}\r\n\r\n/** A wire DateTime (`snapshotUtc`) or the persisted epoch milliseconds (`snapshotUtcMs`) of the same field. */\r\nfunction msOf(v: Plain, name: string): number {\r\n return v[name + 'Ms'] !== undefined ? num(v[name + 'Ms']) : dateTimeMs(v[name]);\r\n}\r\n\r\nfunction readPlannedFile(value: unknown): G9DtPlannedFile | null {\r\n if (!isPlainObject(value)) return null;\r\n return {\r\n fileId: str(value.fileId),\r\n snapshotUtcMs: msOf(value, 'snapshotUtc'),\r\n tables: arr(value.tables).map((t) => {\r\n const d = obj(t);\r\n return { tableId: num(d.tableId), rows: num(d.rows) };\r\n }),\r\n };\r\n}\r\n\r\nfunction readPlannedPart(value: unknown): G9DtPlannedPart {\r\n const v = obj(value);\r\n return {\r\n subscriptionKey: str(v.subscriptionKey),\r\n tableId: num(v.tableId),\r\n kind: num(v.kind) as G9DtPlannedPart['kind'],\r\n rows: num(v.rows),\r\n estimatedBytes: num(v.estimatedBytes),\r\n file: readPlannedFile(v.file),\r\n };\r\n}\r\n\r\n/** A snapshot-file manifest (wire or persisted). */\r\nexport function readFileManifest(value: unknown): G9DtSnapshotFileManifest | null {\r\n if (!isPlainObject(value)) return null;\r\n return {\r\n fileId: str(value.fileId),\r\n formatVersion: num(value.formatVersion),\r\n bytes: num(value.bytes),\r\n segmentBytes: num(value.segmentBytes),\r\n segments: num(value.segments),\r\n sha256: str(value.sha256),\r\n compression: str(value.compression, 'br'),\r\n builtUtcMs: msOf(value, 'builtUtc'),\r\n tables: arr(value.tables).map((t) => {\r\n const d = obj(t);\r\n return { tableId: num(d.tableId), name: str(d.name), versionTable: str(d.versionTable), rows: num(d.rows) };\r\n }),\r\n };\r\n}\r\n\r\nfunction readFileSegment(value: unknown): G9DtFileSegment | null {\r\n if (!isPlainObject(value)) return null;\r\n return {\r\n fileId: str(value.fileId),\r\n index: num(value.index),\r\n offset: num(value.offset),\r\n length: num(value.length),\r\n sha256: str(value.sha256),\r\n manifest: readFileManifest(value.manifest),\r\n };\r\n}\r\n\r\nfunction readCursor(value: unknown): G9DtSubscriptionCursor {\r\n const v = obj(value);\r\n return { key: str(v.key), cursor: str(v.cursor), definitionHash: str(v.definitionHash), authHash: str(v.authHash) };\r\n}\r\n\r\nexport function readPullPlan(value: unknown): G9DtPullPlan {\r\n const v = obj(value);\r\n return {\r\n token: str(v.token),\r\n parts: arr(v.parts).map(readPlannedPart),\r\n totalRows: num(v.totalRows),\r\n estimatedBytes: num(v.estimatedBytes),\r\n cursors: arr(v.cursors).map(readCursor),\r\n skipped: arr(v.skipped).map(readSubscriptionState),\r\n error: readSyncError(v.error),\r\n };\r\n}\r\n\r\nexport function readContinuation(value: unknown): G9DtPullContinuation | null {\r\n if (!isPlainObject(value)) return null;\r\n return { partIndex: num(value.partIndex), afterKey: optStr(value.afterKey), nextSequence: num(value.nextSequence) };\r\n}\r\n\r\nfunction readBuckets(value: unknown): G9DtTableBuckets {\r\n const v = obj(value);\r\n return { tableId: num(v.tableId), buckets: arr(v.buckets).map(num) };\r\n}\r\n\r\nexport function readReconcileSummary(value: unknown): G9DtReconcileSummary | null {\r\n if (!isPlainObject(value)) return null;\r\n return {\r\n cursor: str(value.cursor),\r\n definitionHash: str(value.definitionHash),\r\n authHash: str(value.authHash),\r\n mismatched: arr(value.mismatched).map(readBuckets),\r\n };\r\n}\r\n\r\nexport function readSyncChunk(value: unknown): G9DtSyncChunk {\r\n const v = obj(value);\r\n return {\r\n sequence: num(v.sequence),\r\n payload: bytesField(v.payload),\r\n rowCount: num(v.rowCount),\r\n subscriptionKey: optStr(v.subscriptionKey),\r\n isFinal: bool(v.isFinal),\r\n continuation: readContinuation(v.continuation),\r\n reconcileSummary: readReconcileSummary(v.reconcileSummary),\r\n file: readFileSegment(v.file),\r\n };\r\n}\r\n\r\nexport function readChangesAvailable(value: unknown): G9DtChangesAvailable {\r\n return { tables: strings(obj(value).tables) };\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"wire.js","sourceRoot":"","sources":["../../src/protocol/wire.ts"],"names":[],"mappings":"AAAA,oHAAoH;AACpH,qHAAqH;AACrH,qHAAqH;AACrH,yFAAyF;AACzF,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AA8BtD,6HAA6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Q,EAAE,GAAG,CAAC,CAAC,CAAC,QAAQ,CAAC;QACzB,OAAO,EAAE,UAAU,CAAC,CAAC,CAAC,OAAO,CAAC;QAC9B,QAAQ,EAAE,GAAG,CAAC,CAAC,CAAC,QAAQ,CAAC;QACzB,eAAe,EAAE,MAAM,CAAC,CAAC,CAAC,eAAe,CAAC;QAC1C,OAAO,EAAE,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC;QACxB,YAAY,EAAE,gBAAgB,CAAC,CAAC,CAAC,YAAY,CAAC;QAC9C,gBAAgB,EAAE,oBAAoB,CAAC,CAAC,CAAC,gBAAgB,CAAC;QAC1D,IAAI,EAAE,eAAe,CAAC,CAAC,CAAC,IAAI,CAAC;KAC9B,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,oBAAoB,CAAC,KAAc;IACjD,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC;AAChD,CAAC","sourcesContent":["// The wire forms of the DTOs. Both SignalR protocols are decoded to plain objects first — JSON with camelCase names\n// (System.Text.Json, G9SyncJsonContext), MessagePack with the PascalCase names Nerdbank.MessagePack writes, GUIDs as\n// extension type 2 (16 big-endian bytes) and DateTime as the timestamp extension — then normalised here into the DTO\n// interfaces, with every missing field defaulted the way .NET's initialisers default it.\nimport { G9Long, longToNumber } from '../abstractions/long.js';\nimport { tryNormalizeGuid } from '../abstractions/guid.js';\nimport { base64ToBytes } from '../internal/base64.js';\nimport type {\n G9DtAcceptedRows,\n G9DtChangesAvailable,\n G9DtColumnModel,\n G9DtColumnTypeMismatch,\n G9DtCommandResult,\n G9DtHelloResult,\n G9DtNegotiatedTable,\n G9DtFileSegment,\n G9DtPlannedFile,\n G9DtPlannedPart,\n G9DtPullContinuation,\n G9DtSnapshotFileManifest,\n G9DtPullPlan,\n G9DtPushResult,\n G9DtReconcileSummary,\n G9DtRowConflict,\n G9DtRowRejection,\n G9DtSubscriptionCursor,\n G9DtSubscriptionDefinition,\n G9DtSubscriptionState,\n G9DtSyncChunk,\n G9DtSyncError,\n G9DtTableBuckets,\n} from './dtos.js';\n\n/** Which SignalR hub protocol a value came from or goes to. */\nexport type G9WireFormat = 'json' | 'messagepack';\n\n/** A GUID on its way into MessagePack (written as extension type 2, 16 big-endian bytes, like Nerdbank's Guid converter). */\nexport class G9WireGuid {\n readonly value: string;\n\n constructor(value: string) {\n this.value = value;\n }\n}\n\n/** Nerdbank.MessagePack's extension type for System.Guid. */\nexport const GUID_EXTENSION_TYPE = 2;\n\ntype Plain = { [key: string]: unknown };\n\nfunction isPlainObject(value: unknown): value is Plain {\n return typeof value === 'object' && value !== null && !Array.isArray(value) && !(value instanceof Uint8Array) && !(value instanceof G9Long) && !(value instanceof Date) && !(value instanceof G9WireGuid);\n}\n\nfunction lowerFirst(name: string): string {\n return name.length === 0 ? name : name.charAt(0).toLowerCase() + name.slice(1);\n}\n\nfunction upperFirst(name: string): string {\n return name.length === 0 ? name : name.charAt(0).toUpperCase() + name.slice(1);\n}\n\n/** The camelCase twin of a decoded MessagePack value (a `Parameters` dictionary keeps its own keys). */\nexport function fromMessagePackNames(value: unknown): unknown {\n if (Array.isArray(value)) return value.map(fromMessagePackNames);\n if (!isPlainObject(value)) return value;\n const out: Plain = {};\n for (const key of Object.keys(value)) {\n const item = value[key];\n out[lowerFirst(key)] = key === 'Parameters' && isPlainObject(item) ? copyDictionary(item) : fromMessagePackNames(item);\n }\n return out;\n}\n\n/**\n * The MessagePack form of an outgoing DTO: PascalCase names (a `parameters` dictionary keeps its keys), GUID fields as\n * {@link G9WireGuid}. G9Long values stay as they are (the protocol writes them as int64).\n */\nexport function toMessagePackNames(value: unknown): unknown {\n if (Array.isArray(value)) return value.map(toMessagePackNames);\n if (!isPlainObject(value)) return value;\n const out: Plain = {};\n for (const key of Object.keys(value)) {\n const item = value[key];\n if (item === undefined) continue;\n let mapped: unknown;\n if (key === 'parameters' && isPlainObject(item)) mapped = copyDictionary(item);\n else if (GUID_FIELDS[key] === true && typeof item === 'string') mapped = new G9WireGuid(item);\n else mapped = toMessagePackNames(item);\n out[upperFirst(key)] = mapped;\n }\n return out;\n}\n\n/** DTO fields typed System.Guid on the .NET side. */\nconst GUID_FIELDS: { [key: string]: true } = { clientId: true, commandId: true, epoch: true };\n\nfunction copyDictionary(value: Plain): { [key: string]: string } {\n const out: { [key: string]: string } = {};\n for (const key of Object.keys(value)) out[key] = String(value[key]);\n return out;\n}\n\n// ---------------------------------------------------------------- field readers\n\nfunction obj(value: unknown): Plain {\n return isPlainObject(value) ? value : {};\n}\n\nfunction str(value: unknown, fallback = ''): string {\n return typeof value === 'string' ? value : fallback;\n}\n\nfunction optStr(value: unknown): string | null {\n return typeof value === 'string' ? value : null;\n}\n\nfunction num(value: unknown): number {\n return value === null || value === undefined ? 0 : longToNumber(value);\n}\n\nfunction bool(value: unknown): boolean {\n return value === true;\n}\n\nfunction long(value: unknown): G9Long {\n if (value instanceof G9Long) return value;\n if (typeof value === 'number') return G9Long.fromNumber(value);\n if (typeof value === 'string' && value !== '') return G9Long.parse(value);\n return G9Long.ZERO;\n}\n\nfunction arr(value: unknown): unknown[] {\n return Array.isArray(value) ? value : [];\n}\n\nfunction strings(value: unknown): string[] {\n return arr(value).map((v) => str(v));\n}\n\nfunction guid(value: unknown): string {\n if (value instanceof G9WireGuid) return value.value;\n if (typeof value === 'string') return tryNormalizeGuid(value) ?? value;\n return '00000000-0000-0000-0000-000000000000';\n}\n\n/** A byte[] field: base64 text (JSON) or bytes (MessagePack). */\nexport function bytesField(value: unknown): Uint8Array | null {\n if (value instanceof Uint8Array) return value;\n if (typeof value === 'string') return base64ToBytes(value);\n if (value instanceof ArrayBuffer) return new Uint8Array(value);\n return null;\n}\n\n/** Epoch milliseconds of a wire DateTime: ISO text (JSON) or a Date (MessagePack timestamp). */\nexport function dateTimeMs(value: unknown): number {\n if (value instanceof Date) return value.getTime();\n if (typeof value === 'number') return value;\n if (typeof value !== 'string') return 0;\n const m = /^(\\d{4})-(\\d{2})-(\\d{2})[T ](\\d{2}):(\\d{2})(?::(\\d{2})(?:\\.(\\d+))?)?(Z|[+-]\\d{2}:?\\d{2})?$/.exec(value.trim());\n if (!m) return 0;\n const fraction = m[7] ? (m[7] + '00').slice(0, 3) : '0';\n let ms = Date.UTC(+(m[1] as string), +(m[2] as string) - 1, +(m[3] as string), +(m[4] as string), +(m[5] as string), m[6] ? +m[6] : 0, +fraction);\n // Date.UTC maps years 0..99 to 1900..1999.\n if (+(m[1] as string) < 100) {\n const date = new Date(ms);\n date.setUTCFullYear(+(m[1] as string));\n ms = date.getTime();\n }\n const zone = m[8];\n if (zone && zone !== 'Z') {\n const sign = zone.charAt(0) === '-' ? -1 : 1;\n const digits = zone.slice(1).replace(':', '');\n ms -= sign * (+digits.slice(0, 2) * 60 + +digits.slice(2, 4)) * 60000;\n }\n return ms;\n}\n\n// ---------------------------------------------------------------- DTO readers (camelCase input)\n\nexport function readSyncError(value: unknown): G9DtSyncError | null {\n if (!isPlainObject(value)) return null;\n return { code: str(value.code, 'G9S-SRV-ERROR'), message: str(value.message), retryable: bool(value.retryable), details: optStr(value.details) };\n}\n\nfunction readColumn(value: unknown): G9DtColumnModel {\n const v = obj(value);\n return { name: str(v.name), type: num(v.type) as G9DtColumnModel['type'], nullable: bool(v.nullable) };\n}\n\nfunction readMismatch(value: unknown): G9DtColumnTypeMismatch {\n const v = obj(value);\n return { name: str(v.name), clientType: num(v.clientType) as G9DtColumnTypeMismatch['clientType'], serverType: num(v.serverType) as G9DtColumnTypeMismatch['serverType'] };\n}\n\nexport function readNegotiatedTable(value: unknown): G9DtNegotiatedTable {\n const v = obj(value);\n return {\n tableId: num(v.tableId),\n name: str(v.name),\n keyColumn: str(v.keyColumn),\n keyType: num(v.keyType) as G9DtNegotiatedTable['keyType'],\n columns: arr(v.columns).map(readColumn),\n computedColumns: strings(v.computedColumns),\n readOnlyColumns: strings(v.readOnlyColumns),\n missingColumns: strings(v.missingColumns),\n typeMismatchColumns: arr(v.typeMismatchColumns).map(readMismatch),\n direction: num(v.direction) as G9DtNegotiatedTable['direction'],\n conflictPolicy: num(v.conflictPolicy) as G9DtNegotiatedTable['conflictPolicy'],\n };\n}\n\nexport function readSubscriptionDefinition(value: unknown): G9DtSubscriptionDefinition {\n const v = obj(value);\n return {\n name: str(v.name),\n parameters: arr(v.parameters).map((p) => {\n const d = obj(p);\n return { name: str(d.name), type: num(d.type) as G9DtColumnModel['type'], required: bool(d.required), isList: bool(d.isList) };\n }),\n dependsOn: arr(v.dependsOn).map((p) => {\n const d = obj(p);\n return { name: str(d.name), required: d.required === undefined ? true : bool(d.required) };\n }),\n tables: strings(v.tables),\n ephemeral: bool(v.ephemeral),\n ttlSeconds: num(v.ttlSeconds),\n heavy: bool(v.heavy),\n moveOutPolicy: num(v.moveOutPolicy) as G9DtSubscriptionDefinition['moveOutPolicy'],\n reconcileIntervalMinutes: num(v.reconcileIntervalMinutes),\n definitionHash: str(v.definitionHash),\n };\n}\n\nexport function readSubscriptionState(value: unknown): G9DtSubscriptionState {\n const v = obj(value);\n return {\n key: str(v.key),\n action: num(v.action) as G9DtSubscriptionState['action'],\n definitionHash: optStr(v.definitionHash),\n authHash: optStr(v.authHash),\n message: optStr(v.message),\n };\n}\n\nexport function readHelloResult(value: unknown): G9DtHelloResult {\n const v = obj(value);\n return {\n epoch: guid(v.epoch),\n serverTimeUtcMs: dateTimeMs(v.serverTimeUtc),\n protocolVersion: v.protocolVersion === undefined ? 1 : num(v.protocolVersion),\n tables: arr(v.tables).map(readNegotiatedTable),\n unknownTables: strings(v.unknownTables),\n definitions: arr(v.definitions).map(readSubscriptionDefinition),\n subscriptions: arr(v.subscriptions).map(readSubscriptionState),\n maxPushRows: num(v.maxPushRows),\n maxPushBytes: num(v.maxPushBytes),\n error: readSyncError(v.error),\n modelHash: optStr(v.modelHash),\n modelRequired: bool(v.modelRequired),\n tablesHash: optStr(v.tablesHash),\n tablesUnchanged: bool(v.tablesUnchanged),\n definitionsHash: optStr(v.definitionsHash),\n definitionsUnchanged: bool(v.definitionsUnchanged),\n };\n}\n\nfunction readAccepted(value: unknown): G9DtAcceptedRows {\n const v = obj(value);\n return { tableId: num(v.tableId), keys: strings(v.keys), versions: arr(v.versions).map(num), deleted: arr(v.deleted).map(bool) };\n}\n\nfunction readRejection(value: unknown): G9DtRowRejection {\n const v = obj(value);\n return {\n tableId: num(v.tableId),\n key: str(v.key),\n code: str(v.code, 'G9S-REJ-CONSTRAINT'),\n message: optStr(v.message),\n sqlState: optStr(v.sqlState),\n constraint: optStr(v.constraint),\n column: optStr(v.column),\n details: optStr(v.details),\n };\n}\n\nfunction readConflict(value: unknown): G9DtRowConflict {\n const v = obj(value);\n return {\n tableId: num(v.tableId),\n key: str(v.key),\n code: str(v.code, 'G9S-CON-SERVER-WINS'),\n serverChangedMask: long(v.serverChangedMask),\n partiallyApplied: bool(v.partiallyApplied),\n };\n}\n\nfunction readCommandResult(value: unknown): G9DtCommandResult {\n const v = obj(value);\n return { commandId: guid(v.commandId), status: num(v.status) as G9DtCommandResult['status'], code: optStr(v.code), message: optStr(v.message), result: optStr(v.result) };\n}\n\nexport function readPushResult(value: unknown): G9DtPushResult {\n const v = obj(value);\n return {\n batchId: num(v.batchId),\n alreadyApplied: bool(v.alreadyApplied),\n accepted: arr(v.accepted).map(readAccepted),\n rejections: arr(v.rejections).map(readRejection),\n conflicts: arr(v.conflicts).map(readConflict),\n canonicalFrames: arr(v.canonicalFrames)\n .map(bytesField)\n .filter((b): b is Uint8Array => b !== null),\n commandResults: arr(v.commandResults).map(readCommandResult),\n error: readSyncError(v.error),\n };\n}\n\n/** A wire DateTime (`snapshotUtc`) or the persisted epoch milliseconds (`snapshotUtcMs`) of the same field. */\nfunction msOf(v: Plain, name: string): number {\n return v[name + 'Ms'] !== undefined ? num(v[name + 'Ms']) : dateTimeMs(v[name]);\n}\n\nfunction readPlannedFile(value: unknown): G9DtPlannedFile | null {\n if (!isPlainObject(value)) return null;\n return {\n fileId: str(value.fileId),\n snapshotUtcMs: msOf(value, 'snapshotUtc'),\n tables: arr(value.tables).map((t) => {\n const d = obj(t);\n return { tableId: num(d.tableId), rows: num(d.rows) };\n }),\n };\n}\n\nfunction readPlannedPart(value: unknown): G9DtPlannedPart {\n const v = obj(value);\n return {\n subscriptionKey: str(v.subscriptionKey),\n tableId: num(v.tableId),\n kind: num(v.kind) as G9DtPlannedPart['kind'],\n rows: num(v.rows),\n estimatedBytes: num(v.estimatedBytes),\n file: readPlannedFile(v.file),\n };\n}\n\n/** A snapshot-file manifest (wire or persisted). */\nexport function readFileManifest(value: unknown): G9DtSnapshotFileManifest | null {\n if (!isPlainObject(value)) return null;\n return {\n fileId: str(value.fileId),\n formatVersion: num(value.formatVersion),\n bytes: num(value.bytes),\n segmentBytes: num(value.segmentBytes),\n segments: num(value.segments),\n sha256: str(value.sha256),\n compression: str(value.compression, 'br'),\n builtUtcMs: msOf(value, 'builtUtc'),\n tables: arr(value.tables).map((t) => {\n const d = obj(t);\n return { tableId: num(d.tableId), name: str(d.name), versionTable: str(d.versionTable), rows: num(d.rows) };\n }),\n };\n}\n\nfunction readFileSegment(value: unknown): G9DtFileSegment | null {\n if (!isPlainObject(value)) return null;\n return {\n fileId: str(value.fileId),\n index: num(value.index),\n offset: num(value.offset),\n length: num(value.length),\n sha256: str(value.sha256),\n manifest: readFileManifest(value.manifest),\n };\n}\n\nfunction readCursor(value: unknown): G9DtSubscriptionCursor {\n const v = obj(value);\n return { key: str(v.key), cursor: str(v.cursor), definitionHash: str(v.definitionHash), authHash: str(v.authHash) };\n}\n\nexport function readPullPlan(value: unknown): G9DtPullPlan {\n const v = obj(value);\n return {\n token: str(v.token),\n parts: arr(v.parts).map(readPlannedPart),\n totalRows: num(v.totalRows),\n estimatedBytes: num(v.estimatedBytes),\n cursors: arr(v.cursors).map(readCursor),\n skipped: arr(v.skipped).map(readSubscriptionState),\n error: readSyncError(v.error),\n };\n}\n\nexport function readContinuation(value: unknown): G9DtPullContinuation | null {\n if (!isPlainObject(value)) return null;\n return { partIndex: num(value.partIndex), afterKey: optStr(value.afterKey), nextSequence: num(value.nextSequence) };\n}\n\nfunction readBuckets(value: unknown): G9DtTableBuckets {\n const v = obj(value);\n return { tableId: num(v.tableId), buckets: arr(v.buckets).map(num) };\n}\n\nexport function readReconcileSummary(value: unknown): G9DtReconcileSummary | null {\n if (!isPlainObject(value)) return null;\n return {\n cursor: str(value.cursor),\n definitionHash: str(value.definitionHash),\n authHash: str(value.authHash),\n mismatched: arr(value.mismatched).map(readBuckets),\n };\n}\n\nexport function readSyncChunk(value: unknown): G9DtSyncChunk {\n const v = obj(value);\n return {\n sequence: num(v.sequence),\n payload: bytesField(v.payload),\n rowCount: num(v.rowCount),\n subscriptionKey: optStr(v.subscriptionKey),\n isFinal: bool(v.isFinal),\n continuation: readContinuation(v.continuation),\n reconcileSummary: readReconcileSummary(v.reconcileSummary),\n file: readFileSegment(v.file),\n };\n}\n\nexport function readChangesAvailable(value: unknown): G9DtChangesAvailable {\n return { tables: strings(obj(value).tables) };\n}\n"]}
|
|
@@ -58,13 +58,22 @@ export declare class G9SignalRSyncTransport implements G9SyncTransport {
|
|
|
58
58
|
private readonly _handlers;
|
|
59
59
|
private _connecting;
|
|
60
60
|
private _lastHello;
|
|
61
|
+
/** The model this connection already sent in full, and the server's id for it (1.5.21, twin of .NET `_modelOnConnection`). */
|
|
62
|
+
private _modelOnConnection;
|
|
61
63
|
constructor(options: G9SignalRSyncTransportOptions);
|
|
62
64
|
get isConnected(): boolean;
|
|
63
65
|
onChangesAvailable(handler: (changes: G9DtChangesAvailable) => void): () => void;
|
|
64
66
|
/** Connects (joins a connect in progress); a connect that takes longer than connectTimeoutMs is a network failure. */
|
|
65
67
|
connect(signal?: AbortSignal): Promise<void>;
|
|
66
68
|
private _connectCore;
|
|
69
|
+
/**
|
|
70
|
+
* The model once per connection (1.5.21, TR-0069; twin of .NET `HelloAsync`): the first Hello of a connection sends the whole model, a
|
|
71
|
+
* later one on the same connection with the same tables (the engine keeps one array) only the server's id for it. A server that lost it
|
|
72
|
+
* answers `modelRequired` and the full Hello goes at once. A new connection — a reconnect included — always starts with the full model.
|
|
73
|
+
*/
|
|
67
74
|
hello(request: G9DtHelloRequest, signal?: AbortSignal): Promise<G9DtHelloResult>;
|
|
75
|
+
private _rememberModel;
|
|
76
|
+
private _connectionId;
|
|
68
77
|
/**
|
|
69
78
|
* After an automatic reconnect the last accepted Hello is sent again, so the new connection joins the table groups pokes go to
|
|
70
79
|
* (S-2, LES-0087). Fire and forget, bounded by the call timeout; the answer is not used and a failure only delays a hint.
|