@g9tm/syncdata 1.2.1
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/LICENSE.md +21 -0
- package/PARITY.md +71 -0
- package/README.md +71 -0
- package/THIRD-PARTY-NOTICES.md +31 -0
- package/dist/abstractions/digest.d.ts +27 -0
- package/dist/abstractions/digest.js +78 -0
- package/dist/abstractions/digest.js.map +1 -0
- package/dist/abstractions/enums.d.ts +42 -0
- package/dist/abstractions/enums.js +60 -0
- package/dist/abstractions/enums.js.map +1 -0
- package/dist/abstractions/errors.d.ts +72 -0
- package/dist/abstractions/errors.js +90 -0
- package/dist/abstractions/errors.js.map +1 -0
- package/dist/abstractions/guid.d.ts +24 -0
- package/dist/abstractions/guid.js +93 -0
- package/dist/abstractions/guid.js.map +1 -0
- package/dist/abstractions/key.d.ts +16 -0
- package/dist/abstractions/key.js +47 -0
- package/dist/abstractions/key.js.map +1 -0
- package/dist/abstractions/long.d.ts +103 -0
- package/dist/abstractions/long.js +351 -0
- package/dist/abstractions/long.js.map +1 -0
- package/dist/abstractions/parameters.d.ts +49 -0
- package/dist/abstractions/parameters.js +153 -0
- package/dist/abstractions/parameters.js.map +1 -0
- package/dist/brotli-js/decode.d.ts +8 -0
- package/dist/brotli-js/decode.js +2004 -0
- package/dist/brotli-js/decode.js.map +1 -0
- package/dist/brotli-js/index.d.ts +5 -0
- package/dist/brotli-js/index.js +19 -0
- package/dist/brotli-js/index.js.map +1 -0
- package/dist/client/engine.d.ts +110 -0
- package/dist/client/engine.js +1158 -0
- package/dist/client/engine.js.map +1 -0
- package/dist/client/model.d.ts +61 -0
- package/dist/client/model.js +154 -0
- package/dist/client/model.js.map +1 -0
- package/dist/client/progress.d.ts +101 -0
- package/dist/client/progress.js +251 -0
- package/dist/client/progress.js.map +1 -0
- package/dist/client/runs.d.ts +219 -0
- package/dist/client/runs.js +239 -0
- package/dist/client/runs.js.map +1 -0
- package/dist/client/storeTypes.d.ts +428 -0
- package/dist/client/storeTypes.js +256 -0
- package/dist/client/storeTypes.js.map +1 -0
- package/dist/client/transport.d.ts +19 -0
- package/dist/client/transport.js +2 -0
- package/dist/client/transport.js.map +1 -0
- package/dist/index.d.ts +27 -0
- package/dist/index.js +35 -0
- package/dist/index.js.map +1 -0
- package/dist/internal/abort.d.ts +21 -0
- package/dist/internal/abort.js +125 -0
- package/dist/internal/abort.js.map +1 -0
- package/dist/internal/base64.d.ts +8 -0
- package/dist/internal/base64.js +85 -0
- package/dist/internal/base64.js.map +1 -0
- package/dist/internal/dotnetFormat.d.ts +32 -0
- package/dist/internal/dotnetFormat.js +207 -0
- package/dist/internal/dotnetFormat.js.map +1 -0
- package/dist/internal/md5.d.ts +2 -0
- package/dist/internal/md5.js +97 -0
- package/dist/internal/md5.js.map +1 -0
- package/dist/internal/sha256.d.ts +20 -0
- package/dist/internal/sha256.js +153 -0
- package/dist/internal/sha256.js.map +1 -0
- package/dist/internal/utf8.d.ts +8 -0
- package/dist/internal/utf8.js +143 -0
- package/dist/internal/utf8.js.map +1 -0
- package/dist/node/index.d.ts +9 -0
- package/dist/node/index.js +35 -0
- package/dist/node/index.js.map +1 -0
- package/dist/node/sqliteDriver.d.ts +11 -0
- package/dist/node/sqliteDriver.js +252 -0
- package/dist/node/sqliteDriver.js.map +1 -0
- package/dist/protocol/dtos.d.ts +280 -0
- package/dist/protocol/dtos.js +33 -0
- package/dist/protocol/dtos.js.map +1 -0
- package/dist/protocol/protocol.d.ts +36 -0
- package/dist/protocol/protocol.js +63 -0
- package/dist/protocol/protocol.js.map +1 -0
- package/dist/protocol/rowBatch/columnLayout.d.ts +4 -0
- package/dist/protocol/rowBatch/columnLayout.js +309 -0
- package/dist/protocol/rowBatch/columnLayout.js.map +1 -0
- package/dist/protocol/rowBatch/format.d.ts +74 -0
- package/dist/protocol/rowBatch/format.js +163 -0
- package/dist/protocol/rowBatch/format.js.map +1 -0
- package/dist/protocol/rowBatch/reader.d.ts +119 -0
- package/dist/protocol/rowBatch/reader.js +459 -0
- package/dist/protocol/rowBatch/reader.js.map +1 -0
- package/dist/protocol/rowBatch/writer.d.ts +101 -0
- package/dist/protocol/rowBatch/writer.js +412 -0
- package/dist/protocol/rowBatch/writer.js.map +1 -0
- package/dist/protocol/wire.d.ts +32 -0
- package/dist/protocol/wire.js +329 -0
- package/dist/protocol/wire.js.map +1 -0
- package/dist/signalr/index.d.ts +2 -0
- package/dist/signalr/index.js +5 -0
- package/dist/signalr/index.js.map +1 -0
- package/dist/signalr/protocols.d.ts +17 -0
- package/dist/signalr/protocols.js +109 -0
- package/dist/signalr/protocols.js.map +1 -0
- package/dist/signalr/transport.d.ts +67 -0
- package/dist/signalr/transport.js +286 -0
- package/dist/signalr/transport.js.map +1 -0
- package/dist/sqlite/apply.d.ts +91 -0
- package/dist/sqlite/apply.js +657 -0
- package/dist/sqlite/apply.js.map +1 -0
- package/dist/sqlite/commands.d.ts +24 -0
- package/dist/sqlite/commands.js +167 -0
- package/dist/sqlite/commands.js.map +1 -0
- package/dist/sqlite/connection.d.ts +81 -0
- package/dist/sqlite/connection.js +322 -0
- package/dist/sqlite/connection.js.map +1 -0
- package/dist/sqlite/driver.d.ts +63 -0
- package/dist/sqlite/driver.js +9 -0
- package/dist/sqlite/driver.js.map +1 -0
- package/dist/sqlite/index.d.ts +6 -0
- package/dist/sqlite/index.js +7 -0
- package/dist/sqlite/index.js.map +1 -0
- package/dist/sqlite/internals.d.ts +63 -0
- package/dist/sqlite/internals.js +194 -0
- package/dist/sqlite/internals.js.map +1 -0
- package/dist/sqlite/options.d.ts +78 -0
- package/dist/sqlite/options.js +78 -0
- package/dist/sqlite/options.js.map +1 -0
- package/dist/sqlite/push.d.ts +9 -0
- package/dist/sqlite/push.js +272 -0
- package/dist/sqlite/push.js.map +1 -0
- package/dist/sqlite/query.d.ts +38 -0
- package/dist/sqlite/query.js +476 -0
- package/dist/sqlite/query.js.map +1 -0
- package/dist/sqlite/revocation.d.ts +28 -0
- package/dist/sqlite/revocation.js +337 -0
- package/dist/sqlite/revocation.js.map +1 -0
- package/dist/sqlite/sql.d.ts +60 -0
- package/dist/sqlite/sql.js +324 -0
- package/dist/sqlite/sql.js.map +1 -0
- package/dist/sqlite/store.d.ts +116 -0
- package/dist/sqlite/store.js +664 -0
- package/dist/sqlite/store.js.map +1 -0
- package/dist/sqlite/values.d.ts +29 -0
- package/dist/sqlite/values.js +288 -0
- package/dist/sqlite/values.js.map +1 -0
- package/dist/testing/index.d.ts +61 -0
- package/dist/testing/index.js +175 -0
- package/dist/testing/index.js.map +1 -0
- package/package.json +104 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storeTypes.js","sourceRoot":"","sources":["../../src/client/storeTypes.ts"],"names":[],"mappings":"AAiCA,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,MAAM,OAAO,kBAAkB;IAA/B;QACE,iBAAY,GAAG,CAAC,CAAC;QACjB,oCAA+B,GAAG,CAAC,CAAC;QAC3B,oBAAe,GAAa,EAAE,CAAC;QAC/B,oBAAe,GAAgC,EAAE,CAAC;QAClD,qBAAgB,GAAgC,EAAE,CAAC;QACnD,g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WAAW;QACT,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,wBAAwB,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC;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\n// and apply diagnostics. The engine is store-agnostic; `@g9tm/syncdata/sqlite` is the implementation.\nimport type { G9EMoveOutPolicy } from '../abstractions/enums.js';\nimport type { G9Long } from '../abstractions/long.js';\nimport type { G9SyncParameters } from '../abstractions/parameters.js';\nimport type {\n G9DtBackfillRequest,\n G9DtCommand,\n G9DtHelloResult,\n G9DtNegotiatedTable,\n G9DtPullContinuation,\n G9DtPullPlan,\n G9DtPushResult,\n G9DtSubscriptionDefinition,\n G9DtSubscriptionRef,\n G9DtSyncChunk,\n G9DtTableColumns,\n G9DtTableDigest,\n} from '../protocol/dtos.js';\nimport type { G9SyncClientModel } from './model.js';\n\n// ---------------------------------------------------------------- server state and subscriptions\n\n/** What the client last learned from the server (`G9CClientServerState`). */\nexport interface G9ClientServerState {\n epoch: string | null;\n lastHelloUtcMs: number | null;\n /** Server clock minus device clock, ms. */\n serverClockOffsetMs: number;\n tables: G9DtNegotiatedTable[];\n definitions: G9DtSubscriptionDefinition[];\n}\n\n/** `G9ESubscriptionState`. */\nexport const G9ESubscriptionState = {\n Active: 0,\n NeedsReconcile: 1,\n Failed: 2,\n} as const;\nexport type G9ESubscriptionState = (typeof G9ESubscriptionState)[keyof typeof G9ESubscriptionState];\n\n/** A local subscription (`G9CSyncSubscriptionRecord`). Times are epoch milliseconds UTC. */\nexport interface G9SyncSubscriptionRecord {\n key: string;\n name: string;\n parameters: G9SyncParameters;\n /** Membership slot (bit) for persistent subscriptions; the shared ephemeral slot otherwise. */\n slot: number;\n ephemeral: boolean;\n ttlMs: number | null;\n cursor: string | null;\n /** The move-out policy the server last announced; kept so it still applies once access is gone. */\n moveOutPolicy: G9EMoveOutPolicy | null;\n definitionHash: string | null;\n authHash: string | null;\n state: G9ESubscriptionState;\n lastErrorCode: string | null;\n createdUtcMs: number;\n lastSuccessUtcMs: number | null;\n lastReconcileUtcMs: number | null;\n lastAccessUtcMs: number | null;\n}\n\n/** `G9CSyncSubscriptionRecord.ToReference()`. */\nexport function toSubscriptionRef(record: G9SyncSubscriptionRecord): G9DtSubscriptionRef {\n return {\n name: record.name,\n parameters: record.parameters.values,\n cursor: record.cursor,\n definitionHash: record.definitionHash,\n authHash: record.authHash,\n };\n}\n\n/** A partial update of a subscription record; absent members are left unchanged (`G9CSubscriptionUpdate`). */\nexport interface G9SubscriptionUpdate {\n cursor?: string | null;\n definitionHash?: string | null;\n authHash?: string | null;\n state?: G9ESubscriptionState | null;\n errorCode?: string | null;\n clearError?: boolean;\n succeeded?: boolean;\n reconciled?: boolean;\n accessed?: boolean;\n clearCursor?: boolean;\n}\n\n// ---------------------------------------------------------------- push and pull\n\n/** A push batch built from dirty rows (`G9CPushBatch`). */\nexport interface G9PushBatch {\n batchId: number;\n /** Highest local change sequence included; rows changed after it stay dirty after the acknowledgement. */\n maxSequence: number;\n frames: Uint8Array[];\n tables: G9DtTableColumns[];\n rowCount: number;\n /** True when the byte budget ended the batch early: more pending rows follow. */\n truncated: boolean;\n /** Rows rejected on the device while building the batch (G9S-REJ-TOO-LARGE). */\n rejectedLocally: number;\n /** Commands carried by this batch, in device order. */\n commands: G9DtCommand[];\n}\n\n/** A pull being staged, persisted across restarts (`G9CStagedPull`). */\nexport interface G9StagedPull {\n runId: string;\n plan: G9DtPullPlan;\n createdUtcMs: number;\n backfills: G9DtBackfillRequest[];\n /** What the world looked like when the plan was made (ADR-0046); a run only resumes a stage whose generation matches. */\n generation: string | null;\n /** The cursor each planned subscription had when the plan was made, by subscription key (ADR-0060). */\n plannedFromCursors: { [subscriptionKey: string]: string | null };\n /** The device clock when the stage began, assigned by the store. */\n stageSequence: number;\n}\n\n/** One committed slice of a staged pull (`G9CApplySlice`). */\nexport interface G9ApplySlice {\n report: G9ApplyReport;\n rowsApplied: number;\n rowsAppliedTotal: number;\n rowsPlanned: number;\n isFinal: boolean;\n}\n\n/** `G9CResumePoint`. */\nexport interface G9ResumePoint {\n continuation: G9DtPullContinuation | null;\n stagedRows: number;\n stagedBytes: number;\n complete: boolean;\n}\n\n// ---------------------------------------------------------------- reports\n\n/** Why a table large enough for index deferral kept its indexes live. */\nexport const REASON_TABLE_NOT_EMPTY = 'table-not-empty';\nconst MAX_FOREIGN_TRIGGER_NAMES = 10;\n\n/** How an apply ran, as opposed to what it changed (`G9CApplyDiagnostics`, ADR-0058). */\nexport class G9ApplyDiagnostics {\n transactions = 0;\n transactionsWithTriggersSkipped = 0;\n readonly foreignTriggers: string[] = [];\n readonly deferredIndexes: { [table: string]: number } = {};\n readonly liveIndexReasons: { [table: string]: string } = {};\n readonly rowsByTable: { [table: string]: number } = {};\n readonly msByTable: { [table: string]: number } = {};\n indexRebuildMs = 0;\n elapsedMs = 0;\n\n /** True when every transaction ran with trigger execution off, false when any ran with it on, null when nothing was applied. */\n get triggersSkipped(): boolean | null {\n return this.transactions === 0 ? null : this.transactionsWithTriggersSkipped === this.transactions;\n }\n\n get deferredIndexCount(): number {\n let total = 0;\n for (const key of Object.keys(this.deferredIndexes)) total += this.deferredIndexes[key] as number;\n return total;\n }\n\n merge(other: G9ApplyDiagnostics): void {\n this.transactions += other.transactions;\n this.transactionsWithTriggersSkipped += other.transactionsWithTriggersSkipped;\n this.indexRebuildMs += other.indexRebuildMs;\n this.elapsedMs += other.elapsedMs;\n for (const name of other.foreignTriggers) {\n if (this.foreignTriggers.length >= MAX_FOREIGN_TRIGGER_NAMES) break;\n if (!this.foreignTriggers.some((n) => n.toLowerCase() === name.toLowerCase())) this.foreignTriggers.push(name);\n }\n addAll(this.deferredIndexes, other.deferredIndexes);\n for (const key of Object.keys(other.liveIndexReasons)) this.liveIndexReasons[key] = other.liveIndexReasons[key] as string;\n addAll(this.rowsByTable, other.rowsByTable);\n addAll(this.msByTable, other.msByTable);\n }\n\n /** One line for a log: what engaged, what did not and why, and the tables that took the time. */\n toString(): string {\n if (this.transactions === 0) return 'nothing applied';\n let text = `${this.transactions} transaction(s) in ${this.elapsedMs} ms; triggers `;\n text +=\n this.triggersSkipped === true\n ? 'skipped'\n : this.transactionsWithTriggersSkipped === 0\n ? 'LIVE'\n : `skipped in ${this.transactionsWithTriggersSkipped} of ${this.transactions}`;\n if (this.foreignTriggers.length > 0) text += ' (foreign: ' + this.foreignTriggers.join(', ') + ')';\n const deferred = Object.keys(this.deferredIndexes);\n if (deferred.length > 0) {\n text += `; ${this.deferredIndexCount} index(es) rebuilt after the load in ${this.indexRebuildMs} ms (` + deferred.map((t) => t + ':' + this.deferredIndexes[t]).join(', ') + ')';\n }\n const live = Object.keys(this.liveIndexReasons);\n if (live.length > 0) text += '; live indexes on ' + live.map((t) => t + ' (' + this.liveIndexReasons[t] + ')').join(', ');\n const slowest = Object.keys(this.msByTable)\n .sort((a, b) => (this.msByTable[b] as number) - (this.msByTable[a] as number))\n .slice(0, 4);\n if (slowest.length > 0) {\n text +=\n '; ' +\n slowest\n .map((t) => {\n const ms = this.msByTable[t] as number;\n const rows = this.rowsByTable[t] ?? 0;\n const rate = ms > 0 ? Math.floor((rows * 1000) / ms) : rows;\n return `${t} ${rows} rows in ${ms} ms (${rate}/s)`;\n })\n .join(', ');\n }\n return text;\n }\n}\n\nfunction addAll(target: { [key: string]: number }, source: { [key: string]: number }): void {\n for (const key of Object.keys(source)) target[key] = (target[key] ?? 0) + (source[key] as number);\n}\n\n/** What an apply changed (`G9CApplyReport`). */\nexport class G9ApplyReport {\n upserts = 0;\n deletes = 0;\n moveOuts = 0;\n membershipAdded = 0;\n /** Rows skipped because they carry a pending local change. */\n skippedDirty = 0;\n accepted = 0;\n rejected = 0;\n conflicts = 0;\n commandsCompleted = 0;\n revokedDeleted = 0;\n revokedQuarantined = 0;\n revokedRetained = 0;\n /** Changed keys per local table (capped per table). */\n readonly changedKeys: { [localTable: string]: string[] } = {};\n /** Upserts whose row already held exactly the incoming values (ADR-0058). */\n unchangedRows = 0;\n readonly diagnostics = new G9ApplyDiagnostics();\n\n get total(): number {\n return this.upserts + this.deletes + this.moveOuts;\n }\n\n merge(other: G9ApplyReport): void {\n this.unchangedRows += other.unchangedRows;\n this.diagnostics.merge(other.diagnostics);\n this.upserts += other.upserts;\n this.deletes += other.deletes;\n this.moveOuts += other.moveOuts;\n this.membershipAdded += other.membershipAdded;\n this.skippedDirty += other.skippedDirty;\n this.accepted += other.accepted;\n this.rejected += other.rejected;\n this.conflicts += other.conflicts;\n this.commandsCompleted += other.commandsCompleted;\n this.revokedDeleted += other.revokedDeleted;\n this.revokedQuarantined += other.revokedQuarantined;\n this.revokedRetained += other.revokedRetained;\n for (const table of Object.keys(other.changedKeys)) {\n const list = this.changedKeys[table] ?? (this.changedKeys[table] = []);\n for (const key of other.changedKeys[table] as string[]) list.push(key);\n }\n }\n}\n\n/** A local row as seen by reconciliation (`G9CLocalRowEntry`). */\nexport interface G9LocalRowEntry {\n key: string;\n bucket: number;\n version: number;\n hash: G9Long;\n member: boolean;\n dirty: boolean;\n}\n\nexport interface G9PendingTable {\n localTable: string;\n upserts: number;\n deletes: number;\n rejected: number;\n}\n\nexport interface G9PendingSummary {\n totalRows: number;\n rejectedRows: number;\n /** Commands recorded on the device and not yet executed by the server. */\n pendingCommands: number;\n tables: G9PendingTable[];\n}\n\n/** One entry of the local change feed (`G9CChangeFeedEntry`). */\nexport interface G9ChangeFeedEntry {\n sequence: number;\n key: string;\n deleted: boolean;\n localPending: boolean;\n}\n\nexport interface G9SyncRejection {\n localTable: string;\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 atUtcMs: number;\n}\n\n/** A persisted summary of one run (`G9CSyncRunReport`); serialized with the .NET JSON names into g9_runs. */\nexport interface G9SyncRunReport {\n runId: string;\n startedUtcMs: number;\n durationMs: number;\n outcome: string;\n priority: string;\n errorCode: string | null;\n errorMessage: string | null;\n pushed: number;\n rejected: number;\n conflicts: number;\n downloaded: number;\n applied: number;\n downloadedBytes: number;\n subscriptions: string[];\n phaseMs: { [phase: string]: number };\n triggersSkipped: boolean | null;\n foreignTriggers: string[];\n applyTransactions: number;\n indexesDeferred: number;\n indexRebuildMs: number;\n liveIndexReasons: { [table: string]: string };\n unchangedRows: number;\n}\n\n// ---------------------------------------------------------------- local commands (ADR-0025)\n\n/** `G9ELocalCommandState`. */\nexport const G9ELocalCommandState = {\n Pending: 0,\n Ok: 1,\n Rejected: 2,\n Superseded: 3,\n} as const;\nexport type G9ELocalCommandState = (typeof G9ELocalCommandState)[keyof typeof G9ELocalCommandState];\n\n/** A command recorded on this device (`G9CLocalCommand`). */\nexport interface G9LocalCommand {\n commandId: string;\n sequence: number;\n name: string;\n version: number;\n payload: string;\n createdUtcMs: number;\n state: G9ELocalCommandState;\n code: string | null;\n message: string | null;\n result: string | null;\n completedUtcMs: number | null;\n}\n\n/** What to record (`G9CCommandRequest`). */\nexport interface G9CommandRequest {\n name: string;\n version?: number;\n /** JSON payload for the server's handler. */\n payload: string;\n}\n\n/** A value an app binds through {@link G9LocalCommandWriter}: the SQLite driver's value forms, plus booleans. */\nexport type G9LocalSqlArgument = null | number | string | boolean | ArrayBuffer | Uint8Array | { int64: string } | G9Long;\n\n/**\n * Writes a command's local effects in the transaction that records it (`IG9LocalCommandWriter`). Rows written here are\n * not uploaded as row changes; they are protected from pulls until the server's result arrives.\n */\nexport interface G9LocalCommandWriter {\n /** Executes SQL; parameters bind positionally as `$p0`, `$p1`, … */\n execute(sql: string, ...args: G9LocalSqlArgument[]): Promise<number>;\n scalar(sql: string, ...args: G9LocalSqlArgument[]): Promise<unknown>;\n}\n\n// ---------------------------------------------------------------- revocation (ADR-0026)\n\n/** `G9ERevocationReason`. */\nexport const G9ERevocationReason = {\n LeftScope: 0,\n Unsubscribed: 1,\n Expired: 2,\n AccessRevoked: 3,\n} as const;\nexport type G9ERevocationReason = (typeof G9ERevocationReason)[keyof typeof G9ERevocationReason];\n\n/** `G9ERevocationDisposition`. */\nexport const G9ERevocationDisposition = {\n Delete: 0,\n MarkRevoked: 1,\n Quarantine: 2,\n Retain: 3,\n} as const;\nexport type G9ERevocationDisposition = (typeof G9ERevocationDisposition)[keyof typeof G9ERevocationDisposition];\n\n/** A row no subscription holds any more, as a revocation rule sees it (`G9CRevokedRow`). */\nexport interface G9RevokedRow {\n localTable: string;\n key: string;\n reason: G9ERevocationReason;\n subscriptionKey: string | null;\n hasPendingChanges: boolean;\n isRejected: boolean;\n /** Column values (key included) as stored locally; empty when the row no longer exists locally. */\n values: { [column: string]: unknown };\n}\n\n/** Lets a custom rule change the row before its disposition applies. */\nexport interface G9RevokedRowEditor {\n set(column: string, value: unknown): void;\n}\n\nexport interface G9RevocationRule {\n readonly name: string;\n readonly condition: (row: G9RevokedRow) => boolean;\n readonly decide: (row: G9RevokedRow, editor: G9RevokedRowEditor) => G9ERevocationDisposition;\n readonly retainWhile: ((row: G9RevokedRow) => boolean) | null;\n}\n\n/** Ordered revocation rules (`G9CRevocationPolicy`): the first matching rule decides. */\nexport class G9RevocationPolicy {\n readonly rules: readonly G9RevocationRule[];\n\n private constructor(rules: readonly G9RevocationRule[]) {\n this.rules = rules;\n }\n\n /** No rules: delete clean rows, quarantine rows with pending changes. */\n static readonly default = new G9RevocationPolicy([]);\n\n static create(configure: (builder: G9RevocationPolicyBuilder) => void): G9RevocationPolicy {\n const builder = new G9RevocationPolicyBuilder();\n configure(builder);\n return new G9RevocationPolicy(builder.rules.slice());\n }\n\n decide(row: G9RevokedRow, editor: G9RevokedRowEditor): { rule: G9RevocationRule | null; disposition: G9ERevocationDisposition } {\n for (const rule of this.rules) {\n if (rule.condition(row)) return { rule, disposition: rule.decide(row, editor) };\n }\n return { rule: null, disposition: row.hasPendingChanges ? G9ERevocationDisposition.Quarantine : G9ERevocationDisposition.Delete };\n }\n\n find(name: string): G9RevocationRule | null {\n for (const rule of this.rules) if (rule.name === name) return rule;\n return null;\n }\n}\n\nexport class G9RevocationPolicyBuilder {\n readonly rules: G9RevocationRule[] = [];\n\n when(name: string, condition: (row: G9RevokedRow) => boolean): G9RevocationActionBuilder {\n if (typeof name !== 'string' || name.trim() === '') throw new TypeError('A rule needs a name.');\n if (this.rules.some((r) => r.name === name)) throw new RangeError(`Revocation rule '${name}' is declared twice.`);\n return new G9RevocationActionBuilder(this, name, condition);\n }\n\n /** Rows of one local table. */\n forTable(name: string, localTable: string, condition?: (row: G9RevokedRow) => boolean): G9RevocationActionBuilder {\n const table = localTable.toLowerCase();\n return this.when(name, (row) => row.localTable.toLowerCase() === table && (condition ? condition(row) : true));\n }\n}\n\nexport class G9RevocationActionBuilder {\n private readonly _owner: G9RevocationPolicyBuilder;\n private readonly _name: string;\n private readonly _condition: (row: G9RevokedRow) => boolean;\n\n constructor(owner: G9RevocationPolicyBuilder, name: string, condition: (row: G9RevokedRow) => boolean) {\n this._owner = owner;\n this._name = name;\n this._condition = condition;\n }\n\n delete(): G9RevocationPolicyBuilder {\n return this._add(() => G9ERevocationDisposition.Delete, null);\n }\n\n markRevoked(): G9RevocationPolicyBuilder {\n return this._add(() => G9ERevocationDisposition.MarkRevoked, null);\n }\n\n quarantine(): G9RevocationPolicyBuilder {\n return this._add(() => G9ERevocationDisposition.Quarantine, null);\n }\n\n retainWhile(retainWhile: (row: G9RevokedRow) => boolean): G9RevocationPolicyBuilder {\n return this._add(() => G9ERevocationDisposition.Retain, retainWhile);\n }\n\n custom(decide: (row: G9RevokedRow, editor: G9RevokedRowEditor) => G9ERevocationDisposition): G9RevocationPolicyBuilder {\n return this._add(decide, null);\n }\n\n private _add(\n decide: (row: G9RevokedRow, editor: G9RevokedRowEditor) => G9ERevocationDisposition,\n retainWhile: ((row: G9RevokedRow) => boolean) | null,\n ): G9RevocationPolicyBuilder {\n this._owner.rules.push({ name: this._name, condition: this._condition, decide, retainWhile });\n return this._owner;\n }\n}\n\n/** A row in the holding area (`G9CQuarantinedRow`). */\nexport interface G9QuarantinedRow {\n localTable: string;\n key: string;\n reason: G9ERevocationReason;\n rule: string | null;\n hadPendingChanges: boolean;\n values: { [column: string]: unknown };\n atUtcMs: number;\n}\n\n/** A row kept in the app's table after revocation (`G9CRetainedRow`). */\nexport interface G9RetainedRow {\n localTable: string;\n key: string;\n disposition: G9ERevocationDisposition;\n reason: G9ERevocationReason;\n rule: string | null;\n atUtcMs: number;\n}\n\n// ---------------------------------------------------------------- failures\n\n/** What went wrong inside a client store, in terms an application can act on (`G9ELocalStoreFailure`). */\nexport const G9ELocalStoreFailure = {\n Other: 0,\n Corrupt: 1,\n DiskFull: 2,\n Busy: 3,\n} as const;\nexport type G9ELocalStoreFailure = (typeof G9ELocalStoreFailure)[keyof typeof G9ELocalStoreFailure];\n\n/** Implemented by a store's errors so the engine can give a run's failure a stable code (`IG9SyncLocalStoreFailure`). */\nexport interface G9SyncLocalStoreFailure {\n readonly localStoreFailure: G9ELocalStoreFailure;\n}\n\nexport function isLocalStoreFailure(error: unknown): error is G9SyncLocalStoreFailure {\n return typeof error === 'object' && error !== null && typeof (error as { localStoreFailure?: unknown }).localStoreFailure === 'number';\n}\n\n// ---------------------------------------------------------------- the store contract\n\n/**\n * The client storage provider (`IG9SyncClientStore`): local tables, change capture, subscription membership,\n * staging, apply and metadata. Every method takes an optional AbortSignal (the CancellationToken twin).\n */\nexport interface G9SyncClientStore {\n initialize(model: G9SyncClientModel, signal?: AbortSignal): Promise<void>;\n getClientId(signal?: AbortSignal): Promise<string>;\n getServerState(signal?: AbortSignal): Promise<G9ClientServerState>;\n saveHello(hello: G9DtHelloResult, signal?: AbortSignal): Promise<void>;\n getPendingBackfills(signal?: AbortSignal): Promise<G9DtBackfillRequest[]>;\n\n getSubscriptions(signal?: AbortSignal): Promise<G9SyncSubscriptionRecord[]>;\n ensureSubscription(\n name: string,\n parameters: G9SyncParameters,\n ephemeral: boolean,\n ttlMs: number | null,\n adoptExistingRows: boolean,\n signal?: AbortSignal,\n ): Promise<G9SyncSubscriptionRecord>;\n removeSubscription(key: string, policy: G9EMoveOutPolicy, signal?: AbortSignal): Promise<void>;\n releaseSubscriptionRows(key: string, signal?: AbortSignal): Promise<G9ApplyReport>;\n updateSubscription(key: string, update: G9SubscriptionUpdate, signal?: AbortSignal): Promise<void>;\n collectExpiredEphemeral(utcNowMs: number, signal?: AbortSignal): Promise<number>;\n\n buildPushBatch(tables: readonly G9DtNegotiatedTable[], maxRows: number, maxBytes: number, signal?: AbortSignal): Promise<G9PushBatch | null>;\n forgetUploadedRows(localTable: string, keys: readonly string[] | null, signal?: AbortSignal): Promise<number>;\n applyPushResult(batch: G9PushBatch, result: G9DtPushResult, signal?: AbortSignal): Promise<G9ApplyReport>;\n\n getStagedPull(signal?: AbortSignal): Promise<G9StagedPull | null>;\n /** The newest staged pull planned under exactly this generation, or null (ADR-0060). */\n getStagedPullForGeneration(generation: string, signal?: AbortSignal): Promise<G9StagedPull | null>;\n beginStagedPull(pull: G9StagedPull, signal?: AbortSignal): Promise<void>;\n pruneStagedPulls(olderThanUtcMs: number, maxBytes: number, keepGeneration: string | null, signal?: AbortSignal): Promise<number>;\n discardAllStagedPulls(signal?: AbortSignal): Promise<number>;\n stageChunk(runId: string, chunk: G9DtSyncChunk, signal?: AbortSignal): Promise<void>;\n getResumePoint(runId: string, signal?: AbortSignal): Promise<G9ResumePoint>;\n applyStagedPull(\n runId: string,\n rowsApplied: ((rows: number) => void) | null,\n slices: ((slice: G9ApplySlice) => void) | null,\n signal?: AbortSignal,\n ): Promise<G9ApplyReport>;\n discardStagedPull(runId: string, signal?: AbortSignal): Promise<void>;\n\n computeDigest(subscriptionKey: string, table: G9DtNegotiatedTable, signal?: AbortSignal): Promise<G9DtTableDigest>;\n readLocalEntries(\n subscriptionKey: string,\n table: G9DtNegotiatedTable,\n buckets: ReadonlySet<number>,\n serverKeys: ReadonlySet<string>,\n signal?: AbortSignal,\n ): Promise<G9LocalRowEntry[]>;\n applyReconcile(\n subscriptionKey: string,\n table: G9DtNegotiatedTable,\n fetchedFrames: readonly Uint8Array[],\n addMembership: readonly string[],\n moveOut: readonly string[],\n policy: G9EMoveOutPolicy,\n signal?: AbortSignal,\n ): Promise<G9ApplyReport>;\n\n getPendingSummary(signal?: AbortSignal): Promise<G9PendingSummary>;\n enqueueCommand(\n request: G9CommandRequest,\n applyLocally: ((writer: G9LocalCommandWriter, signal?: AbortSignal) => Promise<void>) | null,\n signal?: AbortSignal,\n ): Promise<G9LocalCommand>;\n getQuarantined(signal?: AbortSignal): Promise<G9QuarantinedRow[]>;\n restoreQuarantined(localTable: string, key: string, signal?: AbortSignal): Promise<number>;\n discardQuarantined(localTable: string | null, key: string | null, signal?: AbortSignal): Promise<number>;\n getRetained(signal?: AbortSignal): Promise<G9RetainedRow[]>;\n reevaluateRetained(signal?: AbortSignal): Promise<number>;\n getCommands(state: G9ELocalCommandState | null, limit: number, signal?: AbortSignal): Promise<G9LocalCommand[]>;\n readChangeFeed(localTable: string, afterSequence: number, limit: number, signal?: AbortSignal): Promise<G9ChangeFeedEntry[]>;\n getChangeSequence(signal?: AbortSignal): Promise<number>;\n getChangeFeedFloor(signal?: AbortSignal): Promise<number>;\n getRejections(signal?: AbortSignal): Promise<G9SyncRejection[]>;\n retryRejected(localTable: string | null, key: string | null, signal?: AbortSignal): Promise<number>;\n markDirty(localTable: string, keys: readonly string[], signal?: AbortSignal): Promise<number>;\n adoptExistingRows(signal?: AbortSignal): Promise<number>;\n saveRunReport(report: G9SyncRunReport, keep: number, signal?: AbortSignal): Promise<void>;\n getRecentRunReports(count: number, signal?: AbortSignal): Promise<G9SyncRunReport[]>;\n getPhaseStatistics(signal?: AbortSignal): Promise<{ [key: string]: number }>;\n recordPhaseStatistics(samples: { [key: string]: number }, signal?: AbortSignal): Promise<void>;\n purgeDeletedFeed(keep: number, signal?: AbortSignal): Promise<number>;\n dispose(): Promise<void>;\n}\n"]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { G9DtChangesAvailable, G9DtFetchRowsRequest, G9DtHelloRequest, G9DtHelloResult, G9DtPullContinuation, G9DtPullPlan, G9DtPullRequest, G9DtPushRequest, G9DtPushResult, G9DtReconcileRequest, G9DtSyncChunk } from '../protocol/dtos.js';
|
|
2
|
+
/**
|
|
3
|
+
* Carries protocol calls to a G9SyncData server. Implementations: SignalR (`@g9tm/syncdata/signalr`, and its Lynx
|
|
4
|
+
* wiring in `@g9tm/syncdata-lynx`) and the in-memory test transport (`@g9tm/syncdata/testing`). Failures surface as
|
|
5
|
+
* G9SyncException; transport faults use G9S-NET-FAILURE.
|
|
6
|
+
*/
|
|
7
|
+
export interface G9SyncTransport {
|
|
8
|
+
readonly isConnected: boolean;
|
|
9
|
+
/** Subscribes to server "pokes" (tables changed); returns the unsubscribe function. */
|
|
10
|
+
onChangesAvailable(handler: (changes: G9DtChangesAvailable) => void): () => void;
|
|
11
|
+
connect(signal?: AbortSignal): Promise<void>;
|
|
12
|
+
hello(request: G9DtHelloRequest, signal?: AbortSignal): Promise<G9DtHelloResult>;
|
|
13
|
+
push(request: G9DtPushRequest, chunks: AsyncIterable<G9DtSyncChunk>, signal?: AbortSignal): Promise<G9DtPushResult>;
|
|
14
|
+
planPull(request: G9DtPullRequest, signal?: AbortSignal): Promise<G9DtPullPlan>;
|
|
15
|
+
pull(token: string, continuation: G9DtPullContinuation | null, signal?: AbortSignal): AsyncIterable<G9DtSyncChunk>;
|
|
16
|
+
reconcile(request: G9DtReconcileRequest, signal?: AbortSignal): AsyncIterable<G9DtSyncChunk>;
|
|
17
|
+
fetchRows(request: G9DtFetchRowsRequest, signal?: AbortSignal): AsyncIterable<G9DtSyncChunk>;
|
|
18
|
+
dispose(): Promise<void>;
|
|
19
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transport.js","sourceRoot":"","sources":["../../src/client/transport.ts"],"names":[],"mappings":"","sourcesContent":["// Twin of G9SyncData.Client/Transport/IG9SyncTransport.cs.\nimport type {\n G9DtChangesAvailable,\n G9DtFetchRowsRequest,\n G9DtHelloRequest,\n G9DtHelloResult,\n G9DtPullContinuation,\n G9DtPullPlan,\n G9DtPullRequest,\n G9DtPushRequest,\n G9DtPushResult,\n G9DtReconcileRequest,\n G9DtSyncChunk,\n} from '../protocol/dtos.js';\n\n/**\n * Carries protocol calls to a G9SyncData server. Implementations: SignalR (`@g9tm/syncdata/signalr`, and its Lynx\n * wiring in `@g9tm/syncdata-lynx`) and the in-memory test transport (`@g9tm/syncdata/testing`). Failures surface as\n * G9SyncException; transport faults use G9S-NET-FAILURE.\n */\nexport interface G9SyncTransport {\n readonly isConnected: boolean;\n /** Subscribes to server \"pokes\" (tables changed); returns the unsubscribe function. */\n onChangesAvailable(handler: (changes: G9DtChangesAvailable) => void): () => void;\n connect(signal?: AbortSignal): Promise<void>;\n hello(request: G9DtHelloRequest, signal?: AbortSignal): Promise<G9DtHelloResult>;\n push(request: G9DtPushRequest, chunks: AsyncIterable<G9DtSyncChunk>, signal?: AbortSignal): Promise<G9DtPushResult>;\n planPull(request: G9DtPullRequest, signal?: AbortSignal): Promise<G9DtPullPlan>;\n pull(token: string, continuation: G9DtPullContinuation | null, signal?: AbortSignal): AsyncIterable<G9DtSyncChunk>;\n reconcile(request: G9DtReconcileRequest, signal?: AbortSignal): AsyncIterable<G9DtSyncChunk>;\n fetchRows(request: G9DtFetchRowsRequest, signal?: AbortSignal): AsyncIterable<G9DtSyncChunk>;\n dispose(): Promise<void>;\n}\n"]}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/** The package version; equal to the .NET packages' (G9SyncDataVersion) — one release, both sides. */
|
|
2
|
+
export declare const VERSION = "1.2.1";
|
|
3
|
+
export { G9EConflictPolicy, G9EMoveOutPolicy, G9ESyncColumnType, G9ESyncDirection, columnTypeName, isColumnType } from './abstractions/enums.js';
|
|
4
|
+
export { G9SyncErrorCodes, G9SyncException, isRetryableCode, isSyncException, type G9SyncExceptionOptions } from './abstractions/errors.js';
|
|
5
|
+
export { G9Long, parseJson, stringifyJson } from './abstractions/long.js';
|
|
6
|
+
export { EMPTY_GUID, guidToN, newGuid, normalizeGuid, tryNormalizeGuid } from './abstractions/guid.js';
|
|
7
|
+
export { G9SyncKey } from './abstractions/key.js';
|
|
8
|
+
export { G9SyncDigest } from './abstractions/digest.js';
|
|
9
|
+
export { G9SyncParameters, escapeDataString } from './abstractions/parameters.js';
|
|
10
|
+
export * from './protocol/dtos.js';
|
|
11
|
+
export { G9SyncHubErrors, G9SyncProtocol, negotiateFrameVersion, tableGroup } from './protocol/protocol.js';
|
|
12
|
+
export { bytesField, dateTimeMs, fromMessagePackNames, G9WireGuid, GUID_EXTENSION_TYPE, readChangesAvailable, readContinuation, readHelloResult, readPullPlan, readPushResult, readReconcileSummary, readSyncChunk, toMessagePackNames, type G9WireFormat, } from './protocol/wire.js';
|
|
13
|
+
export { G9ECompression, G9EPushRowOp, G9ERowBatchOp, G9RowBatchFormat, G9RowBatchFormatError } from './protocol/rowBatch/format.js';
|
|
14
|
+
export { G9RowBatchWriter, type G9DateTimeOffsetValue, type G9DateTimeValue, type G9FrameCompressor } from './protocol/rowBatch/writer.js';
|
|
15
|
+
export { G9RowBatchReader, getDefaultFrameDecompressor, openRowBatch, openRowBatchSync, readFrameHeader, setDefaultFrameDecompressor, type G9FrameDecompressor, type G9FrameHeader, type G9OpenRowBatchOptions, } from './protocol/rowBatch/reader.js';
|
|
16
|
+
export { decimalToDouble, formatDecimal, formatDouble, parseDecimal, type DecimalParts } from './internal/dotnetFormat.js';
|
|
17
|
+
export { G9SyncClientModel, G9SyncClientModelBuilder, G9SyncClientTable, G9SyncClientTableBuilder, type G9SyncClientColumn, type G9SyncClientIndex } from './client/model.js';
|
|
18
|
+
export * from './client/storeTypes.js';
|
|
19
|
+
export type { G9SyncTransport } from './client/transport.js';
|
|
20
|
+
export { G9ESyncPhase, G9SyncProgressTracker, phaseName, type G9DtSyncProgress } from './client/progress.js';
|
|
21
|
+
export { G9ESyncOutcome, G9ESyncPriority, G9SyncPostStep, G9SyncRun, describeModelProblem, isTransientError, normalizeError, outcomeName, priorityName, resolveEngineOptions, type G9RowsAppliedEvent, type G9SubscriptionOptions, type G9SyncEngineOptions, type G9SyncHealth, type G9SyncHostHooks, type G9SyncLogger, type G9SyncLogLevel, type G9SyncModelProblem, type G9SyncPostStepContext, type G9SyncRequest, type G9SyncRunResult, } from './client/runs.js';
|
|
22
|
+
export { G9SyncEngine, stageGeneration } from './client/engine.js';
|
|
23
|
+
export { base64ToBytes, bytesToBase64 } from './internal/base64.js';
|
|
24
|
+
export { utf8Decode, utf8Encode } from './internal/utf8.js';
|
|
25
|
+
export { md5 } from './internal/md5.js';
|
|
26
|
+
export { sha256, toHex } from './internal/sha256.js';
|
|
27
|
+
export { cancellationError, createAbortController, delay, linkSignals, onAbort, yieldToEventLoop } from './internal/abort.js';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
// @g9tm/syncdata — the TypeScript twin of the G9SyncData .NET client (abstractions, protocol, engine). The SQLite store
|
|
2
|
+
// is `@g9tm/syncdata/sqlite`, the SignalR transport `@g9tm/syncdata/signalr`, Node helpers `@g9tm/syncdata/node`, test
|
|
3
|
+
// doubles `@g9tm/syncdata/testing`, the pure-JavaScript Brotli decoder `@g9tm/syncdata/brotli-js`; Lynx wiring is the
|
|
4
|
+
// separate package `@g9tm/syncdata-lynx`. Every public type keeps its .NET name without the G9C prefix (PARITY.md).
|
|
5
|
+
/** The package version; equal to the .NET packages' (G9SyncDataVersion) — one release, both sides. */
|
|
6
|
+
export const VERSION = '1.2.1';
|
|
7
|
+
// abstractions
|
|
8
|
+
export { G9EConflictPolicy, G9EMoveOutPolicy, G9ESyncColumnType, G9ESyncDirection, columnTypeName, isColumnType } from './abstractions/enums.js';
|
|
9
|
+
export { G9SyncErrorCodes, G9SyncException, isRetryableCode, isSyncException } from './abstractions/errors.js';
|
|
10
|
+
export { G9Long, parseJson, stringifyJson } from './abstractions/long.js';
|
|
11
|
+
export { EMPTY_GUID, guidToN, newGuid, normalizeGuid, tryNormalizeGuid } from './abstractions/guid.js';
|
|
12
|
+
export { G9SyncKey } from './abstractions/key.js';
|
|
13
|
+
export { G9SyncDigest } from './abstractions/digest.js';
|
|
14
|
+
export { G9SyncParameters, escapeDataString } from './abstractions/parameters.js';
|
|
15
|
+
// protocol
|
|
16
|
+
export * from './protocol/dtos.js';
|
|
17
|
+
export { G9SyncHubErrors, G9SyncProtocol, negotiateFrameVersion, tableGroup } from './protocol/protocol.js';
|
|
18
|
+
export { bytesField, dateTimeMs, fromMessagePackNames, G9WireGuid, GUID_EXTENSION_TYPE, readChangesAvailable, readContinuation, readHelloResult, readPullPlan, readPushResult, readReconcileSummary, readSyncChunk, toMessagePackNames, } from './protocol/wire.js';
|
|
19
|
+
export { G9ECompression, G9EPushRowOp, G9ERowBatchOp, G9RowBatchFormat, G9RowBatchFormatError } from './protocol/rowBatch/format.js';
|
|
20
|
+
export { G9RowBatchWriter } from './protocol/rowBatch/writer.js';
|
|
21
|
+
export { G9RowBatchReader, getDefaultFrameDecompressor, openRowBatch, openRowBatchSync, readFrameHeader, setDefaultFrameDecompressor, } from './protocol/rowBatch/reader.js';
|
|
22
|
+
export { decimalToDouble, formatDecimal, formatDouble, parseDecimal } from './internal/dotnetFormat.js';
|
|
23
|
+
// client
|
|
24
|
+
export { G9SyncClientModel, G9SyncClientModelBuilder, G9SyncClientTable, G9SyncClientTableBuilder } from './client/model.js';
|
|
25
|
+
export * from './client/storeTypes.js';
|
|
26
|
+
export { G9ESyncPhase, G9SyncProgressTracker, phaseName } from './client/progress.js';
|
|
27
|
+
export { G9ESyncOutcome, G9ESyncPriority, G9SyncPostStep, G9SyncRun, describeModelProblem, isTransientError, normalizeError, outcomeName, priorityName, resolveEngineOptions, } from './client/runs.js';
|
|
28
|
+
export { G9SyncEngine, stageGeneration } from './client/engine.js';
|
|
29
|
+
// helpers the Lynx package and tests share
|
|
30
|
+
export { base64ToBytes, bytesToBase64 } from './internal/base64.js';
|
|
31
|
+
export { utf8Decode, utf8Encode } from './internal/utf8.js';
|
|
32
|
+
export { md5 } from './internal/md5.js';
|
|
33
|
+
export { sha256, toHex } from './internal/sha256.js';
|
|
34
|
+
export { cancellationError, createAbortController, delay, linkSignals, onAbort, yieldToEventLoop } from './internal/abort.js';
|
|
35
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version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;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\n// is `@g9tm/syncdata/sqlite`, the SignalR transport `@g9tm/syncdata/signalr`, Node helpers `@g9tm/syncdata/node`, test\n// doubles `@g9tm/syncdata/testing`, the pure-JavaScript Brotli decoder `@g9tm/syncdata/brotli-js`; Lynx wiring is the\n// separate package `@g9tm/syncdata-lynx`. Every public type keeps its .NET name without the G9C prefix (PARITY.md).\n\n/** The package version; equal to the .NET packages' (G9SyncDataVersion) — one release, both sides. */\nexport const VERSION = '1.2.1';\n\n// abstractions\nexport { G9EConflictPolicy, G9EMoveOutPolicy, G9ESyncColumnType, G9ESyncDirection, columnTypeName, isColumnType } from './abstractions/enums.js';\nexport { G9SyncErrorCodes, G9SyncException, isRetryableCode, isSyncException, type G9SyncExceptionOptions } from './abstractions/errors.js';\nexport { G9Long, parseJson, stringifyJson } from './abstractions/long.js';\nexport { EMPTY_GUID, guidToN, newGuid, normalizeGuid, tryNormalizeGuid } from './abstractions/guid.js';\nexport { G9SyncKey } from './abstractions/key.js';\nexport { G9SyncDigest } from './abstractions/digest.js';\nexport { G9SyncParameters, escapeDataString } from './abstractions/parameters.js';\n\n// protocol\nexport * from './protocol/dtos.js';\nexport { G9SyncHubErrors, G9SyncProtocol, negotiateFrameVersion, tableGroup } from './protocol/protocol.js';\nexport {\n bytesField,\n dateTimeMs,\n fromMessagePackNames,\n G9WireGuid,\n GUID_EXTENSION_TYPE,\n readChangesAvailable,\n readContinuation,\n readHelloResult,\n readPullPlan,\n readPushResult,\n readReconcileSummary,\n readSyncChunk,\n toMessagePackNames,\n type G9WireFormat,\n} from './protocol/wire.js';\nexport { G9ECompression, G9EPushRowOp, G9ERowBatchOp, G9RowBatchFormat, G9RowBatchFormatError } from './protocol/rowBatch/format.js';\nexport { G9RowBatchWriter, type G9DateTimeOffsetValue, type G9DateTimeValue, type G9FrameCompressor } from './protocol/rowBatch/writer.js';\nexport {\n G9RowBatchReader,\n getDefaultFrameDecompressor,\n openRowBatch,\n openRowBatchSync,\n readFrameHeader,\n setDefaultFrameDecompressor,\n type G9FrameDecompressor,\n type G9FrameHeader,\n type G9OpenRowBatchOptions,\n} from './protocol/rowBatch/reader.js';\nexport { decimalToDouble, formatDecimal, formatDouble, parseDecimal, type DecimalParts } from './internal/dotnetFormat.js';\n\n// client\nexport { G9SyncClientModel, G9SyncClientModelBuilder, G9SyncClientTable, G9SyncClientTableBuilder, type G9SyncClientColumn, type G9SyncClientIndex } from './client/model.js';\nexport * from './client/storeTypes.js';\nexport type { G9SyncTransport } from './client/transport.js';\nexport { G9ESyncPhase, G9SyncProgressTracker, phaseName, type G9DtSyncProgress } from './client/progress.js';\nexport {\n G9ESyncOutcome,\n G9ESyncPriority,\n G9SyncPostStep,\n G9SyncRun,\n describeModelProblem,\n isTransientError,\n normalizeError,\n outcomeName,\n priorityName,\n resolveEngineOptions,\n type G9RowsAppliedEvent,\n type G9SubscriptionOptions,\n type G9SyncEngineOptions,\n type G9SyncHealth,\n type G9SyncHostHooks,\n type G9SyncLogger,\n type G9SyncLogLevel,\n type G9SyncModelProblem,\n type G9SyncPostStepContext,\n type G9SyncRequest,\n type G9SyncRunResult,\n} from './client/runs.js';\nexport { G9SyncEngine, stageGeneration } from './client/engine.js';\n\n// helpers the Lynx package and tests share\nexport { base64ToBytes, bytesToBase64 } from './internal/base64.js';\nexport { utf8Decode, utf8Encode } from './internal/utf8.js';\nexport { md5 } from './internal/md5.js';\nexport { sha256, toHex } from './internal/sha256.js';\nexport { cancellationError, createAbortController, delay, linkSignals, onAbort, yieldToEventLoop } from './internal/abort.js';\n"]}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
type Listener = () => void;
|
|
2
|
+
/** An AbortController (native when the runtime has one). */
|
|
3
|
+
export interface G9AbortController {
|
|
4
|
+
readonly signal: AbortSignal;
|
|
5
|
+
abort(reason?: unknown): void;
|
|
6
|
+
}
|
|
7
|
+
export declare function createAbortController(): G9AbortController;
|
|
8
|
+
/** Calls `callback` once when `signal` aborts (at once when it already has); returns the unsubscribe function. */
|
|
9
|
+
export declare function onAbort(signal: AbortSignal | null | undefined, callback: Listener): () => void;
|
|
10
|
+
/** A controller that aborts when any of `signals` does (`CancellationTokenSource.CreateLinkedTokenSource`). */
|
|
11
|
+
export declare function linkSignals(...signals: (AbortSignal | null | undefined)[]): G9AbortController & {
|
|
12
|
+
dispose(): void;
|
|
13
|
+
};
|
|
14
|
+
/** The error a cancelled operation rejects with (name `AbortError`, like DOM's). */
|
|
15
|
+
export declare function cancellationError(message?: string): Error;
|
|
16
|
+
export declare function throwIfAborted(signal: AbortSignal | null | undefined): void;
|
|
17
|
+
/** `Task.Delay(ms, token)`. */
|
|
18
|
+
export declare function delay(ms: number, signal?: AbortSignal | null): Promise<void>;
|
|
19
|
+
/** Lets the event loop run (Lynx: keeps the background thread responsive during long applies). */
|
|
20
|
+
export declare function yieldToEventLoop(): Promise<void>;
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
// Cancellation (the CancellationToken twin) over AbortSignal. Lynx has AbortController on globalThis; a runtime without
|
|
2
|
+
// one gets a minimal stand-in with the same surface, so the library never depends on it existing.
|
|
3
|
+
class FallbackSignal {
|
|
4
|
+
constructor() {
|
|
5
|
+
this.aborted = false;
|
|
6
|
+
this.reason = undefined;
|
|
7
|
+
this.onabort = null;
|
|
8
|
+
this._listeners = [];
|
|
9
|
+
}
|
|
10
|
+
addEventListener(_type, listener) {
|
|
11
|
+
this._listeners.push(listener);
|
|
12
|
+
}
|
|
13
|
+
removeEventListener(_type, listener) {
|
|
14
|
+
const index = this._listeners.indexOf(listener);
|
|
15
|
+
if (index >= 0)
|
|
16
|
+
this._listeners.splice(index, 1);
|
|
17
|
+
}
|
|
18
|
+
/** @internal */
|
|
19
|
+
fire(reason) {
|
|
20
|
+
if (this.aborted)
|
|
21
|
+
return;
|
|
22
|
+
this.aborted = true;
|
|
23
|
+
this.reason = reason;
|
|
24
|
+
const listeners = this._listeners.splice(0, this._listeners.length);
|
|
25
|
+
for (const listener of listeners) {
|
|
26
|
+
try {
|
|
27
|
+
listener();
|
|
28
|
+
}
|
|
29
|
+
catch {
|
|
30
|
+
// a listener must not stop the others
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
if (this.onabort) {
|
|
34
|
+
try {
|
|
35
|
+
this.onabort.call(this);
|
|
36
|
+
}
|
|
37
|
+
catch {
|
|
38
|
+
// ignore
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
export function createAbortController() {
|
|
44
|
+
const Native = globalThis.AbortController;
|
|
45
|
+
if (typeof Native === 'function')
|
|
46
|
+
return new Native();
|
|
47
|
+
const signal = new FallbackSignal();
|
|
48
|
+
return {
|
|
49
|
+
signal: signal,
|
|
50
|
+
abort: (reason) => signal.fire(reason === undefined ? cancellationError() : reason),
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
/** Calls `callback` once when `signal` aborts (at once when it already has); returns the unsubscribe function. */
|
|
54
|
+
export function onAbort(signal, callback) {
|
|
55
|
+
if (!signal)
|
|
56
|
+
return noop;
|
|
57
|
+
if (signal.aborted) {
|
|
58
|
+
callback();
|
|
59
|
+
return noop;
|
|
60
|
+
}
|
|
61
|
+
let done = false;
|
|
62
|
+
const listener = () => {
|
|
63
|
+
if (done)
|
|
64
|
+
return;
|
|
65
|
+
done = true;
|
|
66
|
+
callback();
|
|
67
|
+
};
|
|
68
|
+
signal.addEventListener('abort', listener);
|
|
69
|
+
return () => {
|
|
70
|
+
done = true;
|
|
71
|
+
signal.removeEventListener('abort', listener);
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
function noop() {
|
|
75
|
+
// nothing to undo
|
|
76
|
+
}
|
|
77
|
+
/** A controller that aborts when any of `signals` does (`CancellationTokenSource.CreateLinkedTokenSource`). */
|
|
78
|
+
export function linkSignals(...signals) {
|
|
79
|
+
const controller = createAbortController();
|
|
80
|
+
const unsubscribes = [];
|
|
81
|
+
for (const signal of signals) {
|
|
82
|
+
unsubscribes.push(onAbort(signal, () => controller.abort(signal ? signal.reason : undefined)));
|
|
83
|
+
}
|
|
84
|
+
return {
|
|
85
|
+
signal: controller.signal,
|
|
86
|
+
abort: (reason) => controller.abort(reason),
|
|
87
|
+
dispose: () => {
|
|
88
|
+
for (const unsubscribe of unsubscribes)
|
|
89
|
+
unsubscribe();
|
|
90
|
+
},
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
/** The error a cancelled operation rejects with (name `AbortError`, like DOM's). */
|
|
94
|
+
export function cancellationError(message = 'The operation was canceled.') {
|
|
95
|
+
const error = new Error(message);
|
|
96
|
+
error.name = 'AbortError';
|
|
97
|
+
return error;
|
|
98
|
+
}
|
|
99
|
+
export function throwIfAborted(signal) {
|
|
100
|
+
if (signal && signal.aborted)
|
|
101
|
+
throw cancellationError();
|
|
102
|
+
}
|
|
103
|
+
/** `Task.Delay(ms, token)`. */
|
|
104
|
+
export function delay(ms, signal) {
|
|
105
|
+
return new Promise((resolve, reject) => {
|
|
106
|
+
if (signal && signal.aborted) {
|
|
107
|
+
reject(cancellationError());
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
let unsubscribe = noop;
|
|
111
|
+
const timer = setTimeout(() => {
|
|
112
|
+
unsubscribe();
|
|
113
|
+
resolve();
|
|
114
|
+
}, Math.max(0, ms));
|
|
115
|
+
unsubscribe = onAbort(signal, () => {
|
|
116
|
+
clearTimeout(timer);
|
|
117
|
+
reject(cancellationError());
|
|
118
|
+
});
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
/** Lets the event loop run (Lynx: keeps the background thread responsive during long applies). */
|
|
122
|
+
export function yieldToEventLoop() {
|
|
123
|
+
return new Promise((resolve) => setTimeout(resolve, 0));
|
|
124
|
+
}
|
|
125
|
+
//# sourceMappingURL=abort.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"abort.js","sourceRoot":"","sources":["../../src/internal/abort.ts"],"names":[],"mappings":"AAAA,wHAAwH;AACxH,kGAAkG;AAWlG,MAAM,cAAc;IAApB;QACE,YAAO,GAAG,KAAK,CAAC;QAChB,WAAM,GAAY,SAAS,CAAC;QAC5B,YAAO,GAAqC,IAAI,CAAC;QAChC,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C;AACL,CAAC;AAED,kGAAkG;AAClG,MAAM,UAAU,gBAAgB;IAC9B,OAAO,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC;AAChE,CAAC","sourcesContent":["// Cancellation (the CancellationToken twin) over AbortSignal. Lynx has AbortController on globalThis; a runtime without\n// one gets a minimal stand-in with the same surface, so the library never depends on it existing.\n\ntype Listener = () => void;\n\ninterface MinimalSignal {\n readonly aborted: boolean;\n readonly reason: unknown;\n addEventListener(type: 'abort', listener: Listener, options?: { once?: boolean }): void;\n removeEventListener(type: 'abort', listener: Listener): void;\n}\n\nclass FallbackSignal implements MinimalSignal {\n aborted = false;\n reason: unknown = undefined;\n onabort: ((this: unknown) => void) | null = null;\n private readonly _listeners: Listener[] = [];\n\n addEventListener(_type: 'abort', listener: Listener): void {\n this._listeners.push(listener);\n }\n\n removeEventListener(_type: 'abort', listener: Listener): void {\n const index = this._listeners.indexOf(listener);\n if (index >= 0) this._listeners.splice(index, 1);\n }\n\n /** @internal */\n fire(reason: unknown): void {\n if (this.aborted) return;\n this.aborted = true;\n this.reason = reason;\n const listeners = this._listeners.splice(0, this._listeners.length);\n for (const listener of listeners) {\n try {\n listener();\n } catch {\n // a listener must not stop the others\n }\n }\n if (this.onabort) {\n try {\n this.onabort.call(this);\n } catch {\n // ignore\n }\n }\n }\n}\n\n/** An AbortController (native when the runtime has one). */\nexport interface G9AbortController {\n readonly signal: AbortSignal;\n abort(reason?: unknown): void;\n}\n\nexport function createAbortController(): G9AbortController {\n const Native = (globalThis as { AbortController?: new () => G9AbortController }).AbortController;\n if (typeof Native === 'function') return new Native();\n const signal = new FallbackSignal();\n return {\n signal: signal as unknown as AbortSignal,\n abort: (reason?: unknown) => signal.fire(reason === undefined ? cancellationError() : reason),\n };\n}\n\n/** Calls `callback` once when `signal` aborts (at once when it already has); returns the unsubscribe function. */\nexport function onAbort(signal: AbortSignal | null | undefined, callback: Listener): () => void {\n if (!signal) return noop;\n if (signal.aborted) {\n callback();\n return noop;\n }\n let done = false;\n const listener = (): void => {\n if (done) return;\n done = true;\n callback();\n };\n (signal as unknown as MinimalSignal).addEventListener('abort', listener);\n return () => {\n done = true;\n (signal as unknown as MinimalSignal).removeEventListener('abort', listener);\n };\n}\n\nfunction noop(): void {\n // nothing to undo\n}\n\n/** A controller that aborts when any of `signals` does (`CancellationTokenSource.CreateLinkedTokenSource`). */\nexport function linkSignals(...signals: (AbortSignal | null | undefined)[]): G9AbortController & { dispose(): void } {\n const controller = createAbortController();\n const unsubscribes: (() => void)[] = [];\n for (const signal of signals) {\n unsubscribes.push(onAbort(signal, () => controller.abort(signal ? signal.reason : undefined)));\n }\n return {\n signal: controller.signal,\n abort: (reason?: unknown) => controller.abort(reason),\n dispose: () => {\n for (const unsubscribe of unsubscribes) unsubscribe();\n },\n };\n}\n\n/** The error a cancelled operation rejects with (name `AbortError`, like DOM's). */\nexport function cancellationError(message = 'The operation was canceled.'): Error {\n const error = new Error(message);\n error.name = 'AbortError';\n return error;\n}\n\nexport function throwIfAborted(signal: AbortSignal | null | undefined): void {\n if (signal && signal.aborted) throw cancellationError();\n}\n\n/** `Task.Delay(ms, token)`. */\nexport function delay(ms: number, signal?: AbortSignal | null): Promise<void> {\n return new Promise<void>((resolve, reject) => {\n if (signal && signal.aborted) {\n reject(cancellationError());\n return;\n }\n let unsubscribe: () => void = noop;\n const timer = setTimeout(() => {\n unsubscribe();\n resolve();\n }, Math.max(0, ms));\n unsubscribe = onAbort(signal, () => {\n clearTimeout(timer);\n reject(cancellationError());\n });\n });\n}\n\n/** Lets the event loop run (Lynx: keeps the background thread responsive during long applies). */\nexport function yieldToEventLoop(): Promise<void> {\n return new Promise<void>((resolve) => setTimeout(resolve, 0));\n}\n"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/** Standard (RFC 4648, padded) base64 of `bytes` — what System.Text.Json writes and reads for `byte[]`. */
|
|
2
|
+
export declare function bytesToBase64(bytes: Uint8Array): string;
|
|
3
|
+
/** The table-driven encoder (exported for tests; use {@link bytesToBase64}). */
|
|
4
|
+
export declare function bytesToBase64Js(bytes: Uint8Array): string;
|
|
5
|
+
/** Decodes standard or url-safe base64 (padding optional, whitespace ignored). Throws on any other character. */
|
|
6
|
+
export declare function base64ToBytes(text: string): Uint8Array;
|
|
7
|
+
/** The table-driven decoder (exported for tests; use {@link base64ToBytes}). */
|
|
8
|
+
export declare function base64ToBytesJs(text: string): Uint8Array;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
// Base64 helpers that work in browsers, WebViews, Node and Lynx without Buffer, btoa or atob (Lynx's background
|
|
2
|
+
// thread has none of them). They use the native Uint8Array.prototype.toBase64 / Uint8Array.fromBase64 (ES2026) when
|
|
3
|
+
// the runtime has them, and a table-driven codec otherwise.
|
|
4
|
+
const ALPHABET = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
|
|
5
|
+
const ENCODE = [];
|
|
6
|
+
const DECODE = new Int16Array(256).fill(-1);
|
|
7
|
+
for (let i = 0; i < ALPHABET.length; i++) {
|
|
8
|
+
ENCODE[i] = ALPHABET.charAt(i);
|
|
9
|
+
DECODE[ALPHABET.charCodeAt(i)] = i;
|
|
10
|
+
}
|
|
11
|
+
// base64url digits decode too (they never collide with the standard ones).
|
|
12
|
+
DECODE['-'.charCodeAt(0)] = 62;
|
|
13
|
+
DECODE['_'.charCodeAt(0)] = 63;
|
|
14
|
+
/** Standard (RFC 4648, padded) base64 of `bytes` — what System.Text.Json writes and reads for `byte[]`. */
|
|
15
|
+
export function bytesToBase64(bytes) {
|
|
16
|
+
const native = bytes.toBase64;
|
|
17
|
+
if (typeof native === 'function')
|
|
18
|
+
return native.call(bytes);
|
|
19
|
+
return bytesToBase64Js(bytes);
|
|
20
|
+
}
|
|
21
|
+
/** The table-driven encoder (exported for tests; use {@link bytesToBase64}). */
|
|
22
|
+
export function bytesToBase64Js(bytes) {
|
|
23
|
+
const parts = [];
|
|
24
|
+
const length = bytes.length;
|
|
25
|
+
const whole = length - (length % 3);
|
|
26
|
+
let line = '';
|
|
27
|
+
for (let i = 0; i < whole; i += 3) {
|
|
28
|
+
const n = (bytes[i] << 16) | (bytes[i + 1] << 8) | bytes[i + 2];
|
|
29
|
+
line += ENCODE[n >>> 18] + ENCODE[(n >>> 12) & 63] + ENCODE[(n >>> 6) & 63] + ENCODE[n & 63];
|
|
30
|
+
// Joining bounded pieces keeps string building linear on engines without rope strings.
|
|
31
|
+
if (line.length >= 8192) {
|
|
32
|
+
parts.push(line);
|
|
33
|
+
line = '';
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
const rest = length - whole;
|
|
37
|
+
if (rest === 1) {
|
|
38
|
+
const n = bytes[whole] << 16;
|
|
39
|
+
line += ENCODE[n >>> 18] + ENCODE[(n >>> 12) & 63] + '==';
|
|
40
|
+
}
|
|
41
|
+
else if (rest === 2) {
|
|
42
|
+
const n = (bytes[whole] << 16) | (bytes[whole + 1] << 8);
|
|
43
|
+
line += ENCODE[n >>> 18] + ENCODE[(n >>> 12) & 63] + ENCODE[(n >>> 6) & 63] + '=';
|
|
44
|
+
}
|
|
45
|
+
parts.push(line);
|
|
46
|
+
return parts.join('');
|
|
47
|
+
}
|
|
48
|
+
/** Decodes standard or url-safe base64 (padding optional, whitespace ignored). Throws on any other character. */
|
|
49
|
+
export function base64ToBytes(text) {
|
|
50
|
+
const native = Uint8Array.fromBase64;
|
|
51
|
+
if (typeof native === 'function') {
|
|
52
|
+
try {
|
|
53
|
+
return native(text);
|
|
54
|
+
}
|
|
55
|
+
catch {
|
|
56
|
+
// Fall through to the table codec, which also accepts url-safe digits and missing padding.
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return base64ToBytesJs(text);
|
|
60
|
+
}
|
|
61
|
+
/** The table-driven decoder (exported for tests; use {@link base64ToBytes}). */
|
|
62
|
+
export function base64ToBytesJs(text) {
|
|
63
|
+
const out = new Uint8Array(Math.floor((text.length * 3) / 4) + 3);
|
|
64
|
+
let size = 0;
|
|
65
|
+
let buffer = 0;
|
|
66
|
+
let bits = 0;
|
|
67
|
+
for (let i = 0; i < text.length; i++) {
|
|
68
|
+
const code = text.charCodeAt(i);
|
|
69
|
+
if (code === 61 /* = */)
|
|
70
|
+
break;
|
|
71
|
+
if (code === 32 || code === 9 || code === 10 || code === 13)
|
|
72
|
+
continue;
|
|
73
|
+
const value = code < 256 ? DECODE[code] : -1;
|
|
74
|
+
if (value < 0)
|
|
75
|
+
throw new SyntaxError(`Invalid base64 character at position ${i}.`);
|
|
76
|
+
buffer = ((buffer << 6) | value) & 0xffffff;
|
|
77
|
+
bits += 6;
|
|
78
|
+
if (bits >= 8) {
|
|
79
|
+
bits -= 8;
|
|
80
|
+
out[size++] = (buffer >>> bits) & 0xff;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return out.subarray(0, size);
|
|
84
|
+
}
|
|
85
|
+
//# sourceMappingURL=base64.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base64.js","sourceRoot":"","sources":["../../src/internal/base64.ts"],"names":[],"mappings":"AAAA,gHAAgH;AAChH,oHAAoH;AACpH,4DAA4D;AAK5D,MAAM,QAAQ,GAAG,kEAAkE,CAAC;AACpF,MAAM,MAAM,GAAa,EAAE,CAAC;AAC5B,MAAM,MAAM,GAAG,IAAI,UAAU,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;AAC5C,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,QAAQ,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;IACzC,MAAM,CAAC,CAAC,CAAC,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IAC/B,MAAM,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;AACrC,CAA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,QAAQ,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;AAC/B,CAAC","sourcesContent":["// Base64 helpers that work in browsers, WebViews, Node and Lynx without Buffer, btoa or atob (Lynx's background\n// thread has none of them). They use the native Uint8Array.prototype.toBase64 / Uint8Array.fromBase64 (ES2026) when\n// the runtime has them, and a table-driven codec otherwise.\n\ntype NativeToBase64 = { toBase64?: () => string };\ntype NativeFromBase64 = { fromBase64?: (text: string) => Uint8Array };\n\nconst ALPHABET = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';\nconst ENCODE: string[] = [];\nconst DECODE = new Int16Array(256).fill(-1);\nfor (let i = 0; i < ALPHABET.length; i++) {\n ENCODE[i] = ALPHABET.charAt(i);\n DECODE[ALPHABET.charCodeAt(i)] = i;\n}\n// base64url digits decode too (they never collide with the standard ones).\nDECODE['-'.charCodeAt(0)] = 62;\nDECODE['_'.charCodeAt(0)] = 63;\n\n/** Standard (RFC 4648, padded) base64 of `bytes` — what System.Text.Json writes and reads for `byte[]`. */\nexport function bytesToBase64(bytes: Uint8Array): string {\n const native = (bytes as unknown as NativeToBase64).toBase64;\n if (typeof native === 'function') return native.call(bytes);\n return bytesToBase64Js(bytes);\n}\n\n/** The table-driven encoder (exported for tests; use {@link bytesToBase64}). */\nexport function bytesToBase64Js(bytes: Uint8Array): string {\n const parts: string[] = [];\n const length = bytes.length;\n const whole = length - (length % 3);\n let line = '';\n for (let i = 0; i < whole; i += 3) {\n const n = (bytes[i]! << 16) | (bytes[i + 1]! << 8) | bytes[i + 2]!;\n line += ENCODE[n >>> 18]! + ENCODE[(n >>> 12) & 63]! + ENCODE[(n >>> 6) & 63]! + ENCODE[n & 63]!;\n // Joining bounded pieces keeps string building linear on engines without rope strings.\n if (line.length >= 8192) {\n parts.push(line);\n line = '';\n }\n }\n const rest = length - whole;\n if (rest === 1) {\n const n = bytes[whole]! << 16;\n line += ENCODE[n >>> 18]! + ENCODE[(n >>> 12) & 63]! + '==';\n } else if (rest === 2) {\n const n = (bytes[whole]! << 16) | (bytes[whole + 1]! << 8);\n line += ENCODE[n >>> 18]! + ENCODE[(n >>> 12) & 63]! + ENCODE[(n >>> 6) & 63]! + '=';\n }\n parts.push(line);\n return parts.join('');\n}\n\n/** Decodes standard or url-safe base64 (padding optional, whitespace ignored). Throws on any other character. */\nexport function base64ToBytes(text: string): Uint8Array {\n const native = (Uint8Array as unknown as NativeFromBase64).fromBase64;\n if (typeof native === 'function') {\n try {\n return native(text);\n } catch {\n // Fall through to the table codec, which also accepts url-safe digits and missing padding.\n }\n }\n return base64ToBytesJs(text);\n}\n\n/** The table-driven decoder (exported for tests; use {@link base64ToBytes}). */\nexport function base64ToBytesJs(text: string): Uint8Array {\n const out = new Uint8Array(Math.floor((text.length * 3) / 4) + 3);\n let size = 0;\n let buffer = 0;\n let bits = 0;\n for (let i = 0; i < text.length; i++) {\n const code = text.charCodeAt(i);\n if (code === 61 /* = */) break;\n if (code === 32 || code === 9 || code === 10 || code === 13) continue;\n const value = code < 256 ? DECODE[code]! : -1;\n if (value < 0) throw new SyntaxError(`Invalid base64 character at position ${i}.`);\n buffer = ((buffer << 6) | value) & 0xffffff;\n bits += 6;\n if (bits >= 8) {\n bits -= 8;\n out[size++] = (buffer >>> bits) & 0xff;\n }\n }\n return out.subarray(0, size);\n}\n"]}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `double.ToString(CultureInfo.InvariantCulture)` (.NET Core 3.0+): the shortest round-trip digits, in fixed notation
|
|
3
|
+
* unless the decimal exponent is 17 or more, or below -4, then `d.dddE+XX` (the golden vectors pin both edges).
|
|
4
|
+
*/
|
|
5
|
+
export declare function formatDouble(value: number): string;
|
|
6
|
+
/** The parts of a .NET `decimal`: 96-bit magnitude as three 32-bit words, a scale 0..28 and a sign. */
|
|
7
|
+
export interface DecimalParts {
|
|
8
|
+
lo: number;
|
|
9
|
+
mid: number;
|
|
10
|
+
hi: number;
|
|
11
|
+
scale: number;
|
|
12
|
+
negative: boolean;
|
|
13
|
+
}
|
|
14
|
+
/** `decimal.ToString(CultureInfo.InvariantCulture)`: every digit of the magnitude, the scale kept (`1.50`, `0.000`). */
|
|
15
|
+
export declare function formatDecimal(parts: DecimalParts): string;
|
|
16
|
+
/**
|
|
17
|
+
* `(double)decimal` exactly as .NET computes it (`DecCalc.VarR8FromDec`): `((double)low64 + (double)high · 2^64) /
|
|
18
|
+
* 10^scale`, each step an IEEE double operation, so the result matches .NET to the bit (it is not always the correctly
|
|
19
|
+
* rounded value, and must not be: the server compares what .NET stored).
|
|
20
|
+
*/
|
|
21
|
+
export declare function decimalToDouble(parts: DecimalParts): number;
|
|
22
|
+
/**
|
|
23
|
+
* Parses invariant decimal text (`decimal.Parse(text, NumberStyles.Number | NumberStyles.AllowExponent, Invariant)`
|
|
24
|
+
* for the forms SQLite and .NET produce: sign, digits, one '.', an optional exponent). Digits past 28 significant are
|
|
25
|
+
* rounded half to even… as .NET does (to the 96-bit limit). Returns null for text that is not a number.
|
|
26
|
+
*/
|
|
27
|
+
export declare function parseDecimal(text: string): DecimalParts | null;
|
|
28
|
+
/**
|
|
29
|
+
* `(decimal)double` exactly as .NET converts it (`new decimal(double)`, VarDecFromR8): the value rounded to 15
|
|
30
|
+
* significant digits, then trailing zeros dropped. Throws `RangeError` for NaN, infinities and |value| ≥ 7.9e28.
|
|
31
|
+
*/
|
|
32
|
+
export declare function doubleToDecimal(value: number): DecimalParts;
|