@g9tm/syncdata 1.5.20 → 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/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.20";
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.20';
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
@@ -1 +1 @@
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,cA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AAE,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.20';\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"]}
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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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.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"]}
@@ -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"]}
@@ -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,6DA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9B,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\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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,GAAG,CAAC,WAAW,CAAC;KACnD,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,KAAc;IAC1C,MAAM,CAAC,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC;IACrB,OAAO;QACL,QAAQ,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.
@@ -23,6 +23,8 @@ export class G9SignalRSyncTransport {
23
23
  this._handlers = [];
24
24
  this._connecting = null;
25
25
  this._lastHello = null;
26
+ /** The model this connection already sent in full, and the server's id for it (1.5.21, twin of .NET `_modelOnConnection`). */
27
+ this._modelOnConnection = null;
26
28
  if (!options || typeof options.url !== 'string' || options.url.trim() === '')
27
29
  throw new TypeError('A hub URL is required.');
28
30
  this._options = options;
@@ -102,12 +104,35 @@ export class G9SignalRSyncTransport {
102
104
  throw new G9SyncException(G9SyncErrorCodes.NetworkFailure, `The sync connection is ${String(this.client.connection.state)}.`, { retryable: true });
103
105
  }
104
106
  }
107
+ /**
108
+ * 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
109
+ * 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
110
+ * answers `modelRequired` and the full Hello goes at once. A new connection — a reconnect included — always starts with the full model.
111
+ */
105
112
  async hello(request, signal) {
106
- const result = await this._invoke(G9SyncProtocol.Methods.Hello, [this._wire(request)], readHelloResult, this._callTimeoutMs(), signal);
107
- if (!result.error)
113
+ const known = this._modelOnConnection;
114
+ const sent = known && known.connectionId === this._connectionId() && known.tables === request.tables && request.tables.length > 0
115
+ ? { ...request, tables: [], modelHash: known.modelHash }
116
+ : request;
117
+ let result = await this._invoke(G9SyncProtocol.Methods.Hello, [this._wire(sent)], readHelloResult, this._callTimeoutMs(), signal);
118
+ if (result.modelRequired && sent !== request) {
119
+ this._modelOnConnection = null;
120
+ result = await this._invoke(G9SyncProtocol.Methods.Hello, [this._wire(request)], readHelloResult, this._callTimeoutMs(), signal);
121
+ }
122
+ if (!result.error) {
108
123
  this._lastHello = request;
124
+ this._rememberModel(request, result);
125
+ }
109
126
  return result;
110
127
  }
128
+ _rememberModel(full, result) {
129
+ if (result.modelHash && full.tables.length > 0)
130
+ this._modelOnConnection = { connectionId: this._connectionId(), tables: full.tables, modelHash: result.modelHash };
131
+ }
132
+ _connectionId() {
133
+ const id = this.client.connection.connectionId;
134
+ return typeof id === 'string' ? id : null;
135
+ }
111
136
  /**
112
137
  * After an automatic reconnect the last accepted Hello is sent again, so the new connection joins the table groups pokes go to
113
138
  * (S-2, LES-0087). Fire and forget, bounded by the call timeout; the answer is not used and a failure only delays a hint.
@@ -116,7 +141,13 @@ export class G9SignalRSyncTransport {
116
141
  const hello = this._lastHello;
117
142
  if (!hello)
118
143
  return;
119
- this._invoke(G9SyncProtocol.Methods.Hello, [this._wire(hello)], readHelloResult, this._callTimeoutMs()).catch(() => undefined);
144
+ // The full Hello (a new connection never holds the model): its answer names the model for the next Hello on it.
145
+ this._invoke(G9SyncProtocol.Methods.Hello, [this._wire(hello)], readHelloResult, this._callTimeoutMs())
146
+ .then((result) => {
147
+ if (!result.error)
148
+ this._rememberModel(hello, result);
149
+ })
150
+ .catch(() => undefined);
120
151
  }
121
152
  push(request, chunks, signal) {
122
153
  var _a;
@@ -1 +1 @@
1
- {"version":3,"file":"transport.js","sourceRoot":"","sources":["../../src/signalr/transport.ts"],"names":[],"mappings":"AAAA,yHAAyH;AACzH,wHAAwH;AACxH,wGAAwG;AACxG,2DAA2D;AAC3D,OAAO,EAAE,QAAQ,EAAwB,MAAM,mCAAmC,CAAC;AACnF,OAAO,EAAE,kBAAkB,EAAE,OAAO,EAA6D,MAAM,oBAAoB,CAAC;AAC5H,OAAO,EAAE,gBA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,CAAC,CAAC;IAC5I,+GAA+G;IAC/G,IAAI,6BAA6B,CAAC,IAAI,CAAC,OAAO,CAAC;QAAE,OAAO,IAAI,eAAe,CAAC,gBAAgB,CAAC,WAAW,EAAE,OAAO,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;IACtJ,OAAO,IAAI,eAAe,CAAC,gBAAgB,CAAC,cAAc,EAAE,OAAO,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;AAC1G,CAAC","sourcesContent":["// Twin of G9SyncData.Client.SignalR/G9CSignalRSyncTransport.cs: the sync transport over the G9SignalRSuperNetCore client\r\n// (its jittered reconnect policy and connection states), every failure surfacing as a G9SyncException with the server's\r\n// stable code. Lynx hosts build the client with the native WebSocket of @g9tm/signalr-supernetcore-lynx\r\n// (`createLynxSyncTransport` in @g9tm/syncdata-lynx does).\r\nimport { G9Client, type G9ClientOptions } from '@g9tm/signalr-supernetcore-client';\r\nimport { HubConnectionState, Subject, type IHubProtocol, type IStreamResult, type ISubscription } from '@microsoft/signalr';\r\nimport { G9SyncErrorCodes, G9SyncException, isSyncException } from '../abstractions/errors.js';\r\nimport { createAbortController, onAbort } from '../internal/abort.js';\r\nimport type { G9SyncTransport } from '../client/transport.js';\r\nimport type {\r\n G9DtChangesAvailable,\r\n G9DtFetchRowsRequest,\r\n G9DtHelloRequest,\r\n G9DtHelloResult,\r\n G9DtPullContinuation,\r\n G9DtPullPlan,\r\n G9DtPullRequest,\r\n G9DtPushRequest,\r\n G9DtPushResult,\r\n G9DtReconcileRequest,\r\n G9DtSyncChunk,\r\n} from '../protocol/dtos.js';\r\nimport { G9SyncHubErrors, G9SyncProtocol } from '../protocol/protocol.js';\r\nimport {\r\n fromMessagePackNames,\r\n readChangesAvailable,\r\n readHelloResult,\r\n readPullPlan,\r\n readPushResult,\r\n readSyncChunk,\r\n toMessagePackNames,\r\n type G9WireFormat,\r\n} from '../protocol/wire.js';\r\nimport { createSyncMessagePackProtocol, G9SyncJsonHubProtocol } from './protocols.js';\r\n\r\n/** The SignalR hub protocol a client speaks (`G9ESyncHubProtocol`). The server accepts both. */\r\nexport const G9ESyncHubProtocol = {\r\n /** Text frames; payloads base64-encoded (+33%). Readable in traces. */\r\n Json: 0,\r\n /** Binary frames: payloads as raw bytes. The default. */\r\n MessagePack: 1,\r\n} as const;\r\nexport type G9ESyncHubProtocol = (typeof G9ESyncHubProtocol)[keyof typeof G9ESyncHubProtocol];\r\n\r\n/** Options of {@link G9SignalRSyncTransport} (`G9CSignalRSyncTransportOptions`). Durations are milliseconds. */\r\nexport interface G9SignalRSyncTransportOptions {\r\n /** Absolute hub URL, e.g. `https://sync.example.com/g9sync`. */\r\n url: string;\r\n /** Hub protocol; MessagePack by default. */\r\n protocol?: G9ESyncHubProtocol;\r\n /** Supplies the bearer token for every (re)connect. */\r\n accessTokenFactory?: () => string | Promise<string>;\r\n /** SignalR stateful reconnect (ADR-0069); off by default, the server must allow it too. */\r\n statefulReconnect?: boolean;\r\n /** How long one connect may take before it counts as a network failure. */\r\n connectTimeoutMs?: number;\r\n serverTimeoutMs?: number;\r\n keepAliveIntervalMs?: number;\r\n /**\r\n * How long a Hello waits for its answer before it is a retryable G9S-NET-FAILURE (ADR-0074). Default 60000; 0 = no limit.\r\n * A live connection does not guarantee an answer: pings keep it up while the call's message was lost on the way.\r\n */\r\n callTimeoutMs?: number;\r\n /**\r\n * How long a PlanPull waits for its plan. Default 300000 (5 minutes); 0 = no limit (ADR-0074, amended in 1.5.1): a site's first\r\n * plan builds key sets and plans a snapshot file - 16 s for a 450,000-row farm on a desktop, several times that on a busy server.\r\n */\r\n planTimeoutMs?: number;\r\n /** How long a push may take from its first chunk to its result; a safety net, not a pace. Default 600000; 0 = no limit. */\r\n pushTimeoutMs?: number;\r\n /**\r\n * How long a server stream (Pull, Reconcile, FetchRows) may go without a chunk before it is a retryable G9S-NET-FAILURE; the\r\n * engine resumes from its last continuation. Default 120000 (a snapshot file may still be building); 0 = no limit (ADR-0074).\r\n */\r\n streamIdleTimeoutMs?: number;\r\n /**\r\n * Everything else the G9 client takes (transport, headers, WebSocket constructor, skipNegotiation, reconnect policy, log\r\n * level…) — the twin of ConfigureHttpConnection/ConfigureBuilder. `url`, `protocol` and the timeouts above win.\r\n */\r\n client?: Partial<G9ClientOptions>;\r\n /** Builds the client (tests, hosts with their own wiring); `new G9Client(options)` by default. */\r\n createClient?: (options: G9ClientOptions) => G9Client;\r\n}\r\n\r\n/** The SignalR implementation of {@link G9SyncTransport}. */\r\nexport class G9SignalRSyncTransport implements G9SyncTransport {\r\n readonly client: G9Client;\r\n readonly format: G9WireFormat;\r\n private readonly _options: G9SignalRSyncTransportOptions;\r\n private readonly _handlers: ((changes: G9DtChangesAvailable) => void)[] = [];\r\n private _connecting: Promise<void> | null = null;\r\n private _lastHello: G9DtHelloRequest | null = null;\r\n\r\n constructor(options: G9SignalRSyncTransportOptions) {\r\n if (!options || typeof options.url !== 'string' || options.url.trim() === '') throw new TypeError('A hub URL is required.');\r\n this._options = options;\r\n const json = options.protocol === G9ESyncHubProtocol.Json;\r\n this.format = json ? 'json' : 'messagepack';\r\n const protocol: IHubProtocol = json ? new G9SyncJsonHubProtocol() : createSyncMessagePackProtocol();\r\n const clientOptions: G9ClientOptions = {\r\n ...(options.client ?? {}),\r\n url: options.url,\r\n protocol,\r\n statefulReconnect: options.statefulReconnect ?? false,\r\n serverTimeoutMs: options.serverTimeoutMs ?? 30000,\r\n keepAliveIntervalMs: options.keepAliveIntervalMs ?? 10000,\r\n };\r\n if (options.accessTokenFactory) clientOptions.accessTokenFactory = options.accessTokenFactory;\r\n this.client = options.createClient ? options.createClient(clientOptions) : new G9Client(clientOptions);\r\n this.client.on(G9SyncProtocol.Listeners.OnChangesAvailable, (payload: unknown) => this._onChanges(payload));\r\n // Twin of .NET OnReconnectedAsync (S-2, LES-0087): a connection that reconnected by itself is a new connection id in no table group.\r\n const connection = this.client.connection as { onreconnected?: (callback: (connectionId?: string) => void) => void };\r\n if (typeof connection.onreconnected === 'function') connection.onreconnected(() => this._rejoin());\r\n }\r\n\r\n get isConnected(): boolean {\r\n return this.client.connection.state === HubConnectionState.Connected;\r\n }\r\n\r\n onChangesAvailable(handler: (changes: G9DtChangesAvailable) => void): () => void {\r\n this._handlers.push(handler);\r\n return () => {\r\n const index = this._handlers.indexOf(handler);\r\n if (index >= 0) this._handlers.splice(index, 1);\r\n };\r\n }\r\n\r\n /** Connects (joins a connect in progress); a connect that takes longer than connectTimeoutMs is a network failure. */\r\n connect(signal?: AbortSignal): Promise<void> {\r\n if (this.isConnected) return Promise.resolve();\r\n if (!this._connecting) {\r\n const connecting = this._connectCore().finally(() => {\r\n if (this._connecting === connecting) this._connecting = null;\r\n });\r\n this._connecting = connecting;\r\n }\r\n const connecting = this._connecting;\r\n if (!signal) return connecting;\r\n return new Promise<void>((resolve, reject) => {\r\n const unsubscribe = onAbort(signal, () => reject(new G9SyncException(G9SyncErrorCodes.Canceled, 'The connect was canceled.')));\r\n connecting.then(\r\n () => {\r\n unsubscribe();\r\n resolve();\r\n },\r\n (error) => {\r\n unsubscribe();\r\n reject(error);\r\n },\r\n );\r\n });\r\n }\r\n\r\n private async _connectCore(): Promise<void> {\r\n const timeout = createAbortController();\r\n const timer = setTimeout(() => timeout.abort(), this._options.connectTimeoutMs ?? 20000);\r\n try {\r\n await this.client.start(timeout.signal);\r\n } catch (error) {\r\n const mapped = mapError(error, false) ?? new G9SyncException(G9SyncErrorCodes.NetworkFailure, messageOf(error), { retryable: true, cause: error });\r\n throw mapped.code === G9SyncErrorCodes.Canceled\r\n ? new G9SyncException(G9SyncErrorCodes.NetworkFailure, `The sync connection to ${this._options.url} did not open in time.`, { retryable: true, cause: error })\r\n : mapped;\r\n } finally {\r\n clearTimeout(timer);\r\n }\r\n if (!this.isConnected) {\r\n throw new G9SyncException(G9SyncErrorCodes.NetworkFailure, `The sync connection is ${String(this.client.connection.state)}.`, { retryable: true });\r\n }\r\n }\r\n\r\n async hello(request: G9DtHelloRequest, signal?: AbortSignal): Promise<G9DtHelloResult> {\r\n const result = await this._invoke(G9SyncProtocol.Methods.Hello, [this._wire(request)], readHelloResult, this._callTimeoutMs(), signal);\r\n if (!result.error) this._lastHello = request;\r\n return result;\r\n }\r\n\r\n /**\r\n * After an automatic reconnect the last accepted Hello is sent again, so the new connection joins the table groups pokes go to\r\n * (S-2, LES-0087). Fire and forget, bounded by the call timeout; the answer is not used and a failure only delays a hint.\r\n */\r\n private _rejoin(): void {\r\n const hello = this._lastHello;\r\n if (!hello) return;\r\n this._invoke(G9SyncProtocol.Methods.Hello, [this._wire(hello)], readHelloResult, this._callTimeoutMs()).catch(() => undefined);\r\n }\r\n\r\n push(request: G9DtPushRequest, chunks: AsyncIterable<G9DtSyncChunk>, signal?: AbortSignal): Promise<G9DtPushResult> {\r\n const subject = new Subject<unknown>();\r\n const result = this._invoke(G9SyncProtocol.Methods.Push, [this._wire(request), subject], readPushResult, this._options.pushTimeoutMs ?? 600000, signal);\r\n void (async () => {\r\n try {\r\n for await (const chunk of chunks) subject.next(this._wire(chunk));\r\n subject.complete();\r\n } catch (error) {\r\n subject.error(error);\r\n }\r\n })();\r\n return result;\r\n }\r\n\r\n planPull(request: G9DtPullRequest, signal?: AbortSignal): Promise<G9DtPullPlan> {\r\n return this._invoke(G9SyncProtocol.Methods.PlanPull, [this._wire(request)], readPullPlan, this._options.planTimeoutMs ?? 300000, signal);\r\n }\r\n\r\n pull(token: string, continuation: G9DtPullContinuation | null, signal?: AbortSignal): AsyncIterable<G9DtSyncChunk> {\r\n return this._stream(G9SyncProtocol.Methods.Pull, [token, continuation === null ? null : this._wire(continuation)], signal);\r\n }\r\n\r\n reconcile(request: G9DtReconcileRequest, signal?: AbortSignal): AsyncIterable<G9DtSyncChunk> {\r\n return this._stream(G9SyncProtocol.Methods.Reconcile, [this._wire(request)], signal);\r\n }\r\n\r\n fetchRows(request: G9DtFetchRowsRequest, signal?: AbortSignal): AsyncIterable<G9DtSyncChunk> {\r\n return this._stream(G9SyncProtocol.Methods.FetchRows, [this._wire(request)], signal);\r\n }\r\n\r\n async dispose(): Promise<void> {\r\n this._handlers.length = 0;\r\n await this.client.stop();\r\n }\r\n\r\n // ================================================================ plumbing\r\n\r\n private _wire(value: unknown): unknown {\r\n return this.format === 'messagepack' ? toMessagePackNames(value) : value;\r\n }\r\n\r\n private _read(value: unknown): unknown {\r\n return this.format === 'messagepack' ? fromMessagePackNames(value) : value;\r\n }\r\n\r\n private _callTimeoutMs(): number {\r\n return this._options.callTimeoutMs ?? 60000;\r\n }\r\n\r\n private async _invoke<T>(method: string, args: unknown[], read: (value: unknown) => T, timeoutMs: number, signal?: AbortSignal): Promise<T> {\r\n if (signal && signal.aborted) throw new G9SyncException(G9SyncErrorCodes.Canceled, 'The call was canceled.');\r\n let unsubscribe: () => void = () => undefined;\r\n let timer: ReturnType<typeof setTimeout> | null = null;\r\n let timedOut = false;\r\n try {\r\n const call = this.client.connection.invoke(method, ...args);\r\n const raw =\r\n signal || timeoutMs > 0\r\n ? await new Promise<unknown>((resolve, reject) => {\r\n if (signal) unsubscribe = onAbort(signal, () => reject(new G9SyncException(G9SyncErrorCodes.Canceled, 'The call was canceled.')));\r\n if (timeoutMs > 0) {\r\n timer = setTimeout(() => {\r\n timedOut = true;\r\n reject(\r\n new G9SyncException(G9SyncErrorCodes.NetworkFailure, `The sync server did not answer ${method} within ${Math.round(timeoutMs / 1000)} s.`, {\r\n retryable: true,\r\n }),\r\n );\r\n }, timeoutMs);\r\n }\r\n call.then(resolve, reject);\r\n })\r\n : await call;\r\n return read(this._read(raw));\r\n } catch (error) {\r\n // ADR-0074: the answer did not come in time. The connection is not trusted any more (the server runs one invocation per\r\n // connection at a time, and whatever lost this answer may lose the next): drop it, so the retry runs on a fresh one.\r\n if (timedOut) await this._dropConnection();\r\n throw mapError(error, signal ? signal.aborted : false) ?? error;\r\n } finally {\r\n if (timer !== null) clearTimeout(timer);\r\n unsubscribe();\r\n }\r\n }\r\n\r\n /** Ends the connection after a call or stream ran out of time (ADR-0074); the next call connects afresh. Never throws. */\r\n private async _dropConnection(): Promise<void> {\r\n try {\r\n await this.client.connection.stop();\r\n } catch {\r\n // Stopping a connection that is already gone may throw; the next call connects afresh either way.\r\n }\r\n }\r\n\r\n private _stream(method: string, args: unknown[], signal?: AbortSignal): AsyncIterable<G9DtSyncChunk> {\r\n // eslint-disable-next-line @typescript-eslint/no-this-alias\r\n const self = this;\r\n return {\r\n [Symbol.asyncIterator](): AsyncIterator<G9DtSyncChunk> {\r\n const queue: G9DtSyncChunk[] = [];\r\n let done = false;\r\n let failure: unknown = null;\r\n let wake: (() => void) | null = null;\r\n let subscription: ISubscription<unknown> | null = null;\r\n const notify = (): void => {\r\n const w = wake;\r\n wake = null;\r\n if (w) w();\r\n };\r\n let unsubscribeAbort: () => void = () => undefined;\r\n // ADR-0074: the idle limit runs only while the iterator waits for the next chunk, never while the caller processes one.\r\n const idleMs = self._options.streamIdleTimeoutMs ?? 120000;\r\n let idleTimer: ReturnType<typeof setTimeout> | null = null;\r\n let idleExpired = false;\r\n const stopIdle = (): void => {\r\n if (idleTimer !== null) clearTimeout(idleTimer);\r\n idleTimer = null;\r\n };\r\n const armIdle = (): void => {\r\n stopIdle();\r\n if (idleMs <= 0 || done) return;\r\n idleTimer = setTimeout(() => {\r\n idleTimer = null;\r\n if (done) return;\r\n idleExpired = true;\r\n failure = new G9SyncException(G9SyncErrorCodes.NetworkFailure, `The sync server sent nothing on ${method} for ${Math.round(idleMs / 1000)} s.`, {\r\n retryable: true,\r\n });\r\n done = true;\r\n subscription?.dispose();\r\n notify();\r\n }, idleMs);\r\n };\r\n const start = (): void => {\r\n if (subscription || done) return;\r\n let stream: IStreamResult<unknown>;\r\n try {\r\n stream = self.client.connection.stream(method, ...args);\r\n } catch (error) {\r\n failure = error;\r\n done = true;\r\n return;\r\n }\r\n subscription = stream.subscribe({\r\n next: (item) => {\r\n queue.push(readSyncChunk(self._read(item)));\r\n notify();\r\n },\r\n error: (error) => {\r\n failure = error;\r\n done = true;\r\n notify();\r\n },\r\n complete: () => {\r\n done = true;\r\n notify();\r\n },\r\n });\r\n unsubscribeAbort = onAbort(signal, () => {\r\n failure = new G9SyncException(G9SyncErrorCodes.Canceled, 'The stream was canceled.');\r\n done = true;\r\n subscription?.dispose();\r\n notify();\r\n });\r\n };\r\n const finish = (): void => {\r\n stopIdle();\r\n unsubscribeAbort();\r\n if (subscription && !done) subscription.dispose();\r\n done = true;\r\n };\r\n return {\r\n async next(): Promise<IteratorResult<G9DtSyncChunk>> {\r\n start();\r\n for (;;) {\r\n const item = queue.shift();\r\n if (item) {\r\n stopIdle();\r\n return { value: item, done: false };\r\n }\r\n if (done) {\r\n stopIdle();\r\n unsubscribeAbort();\r\n if (idleExpired) await self._dropConnection();\r\n if (failure !== null) throw mapError(failure, signal ? signal.aborted : false) ?? failure;\r\n return { value: undefined as unknown as G9DtSyncChunk, done: true };\r\n }\r\n if (idleTimer === null) armIdle();\r\n await new Promise<void>((resolve) => {\r\n wake = resolve;\r\n });\r\n }\r\n },\r\n async return(): Promise<IteratorResult<G9DtSyncChunk>> {\r\n finish();\r\n return { value: undefined as unknown as G9DtSyncChunk, done: true };\r\n },\r\n };\r\n },\r\n };\r\n }\r\n\r\n private _onChanges(payload: unknown): void {\r\n const changes = readChangesAvailable(this._read(payload));\r\n for (const handler of this._handlers.slice()) {\r\n try {\r\n handler(changes);\r\n } catch {\r\n // A ChangesAvailable handler threw (logged by the .NET transport); it must not break the connection.\r\n }\r\n }\r\n }\r\n}\r\n\r\nfunction messageOf(error: unknown): string {\r\n return error instanceof Error ? error.message : String(error);\r\n}\r\n\r\n/**\r\n * The sync exception for a transport failure (`Map`): the server's `[G9S|code|retryable]` marker wins; any other hub\r\n * error is a retryable server error; 401/403 is Unauthorized; the rest is a retryable network failure. Null leaves the\r\n * error as it is (an already mapped one).\r\n */\r\nexport function mapError(error: unknown, canceled: boolean): G9SyncException | null {\r\n if (isSyncException(error)) return null;\r\n if (canceled) return new G9SyncException(G9SyncErrorCodes.Canceled, 'The call was canceled.', { cause: error });\r\n const message = messageOf(error);\r\n const marked = G9SyncHubErrors.tryParse(message);\r\n if (marked) return marked;\r\n const status = (error as { statusCode?: unknown }).statusCode;\r\n if (status === 401 || status === 403) return new G9SyncException(G9SyncErrorCodes.Unauthorized, 'The sync server refused the credentials.', { cause: error });\r\n if (error instanceof Error && error.name === 'AbortError') return new G9SyncException(G9SyncErrorCodes.Canceled, message, { cause: error });\r\n // A completion error from the hub: SignalR words it \"An unexpected error occurred invoking '…' on the server.\"\r\n if (/on the server|HubException/i.test(message)) return new G9SyncException(G9SyncErrorCodes.ServerError, message, { retryable: true, cause: error });\r\n return new G9SyncException(G9SyncErrorCodes.NetworkFailure, message, { retryable: true, cause: error });\r\n}\r\n"]}
1
+ {"version":3,"file":"transport.js","sourceRoot":"","sources":["../../src/signalr/transport.ts"],"names":[],"mappings":"AAAA,yHAAyH;AACzH,wHAAwH;AACxH,wGAAwG;AACxG,2DAA2D;AAC3D,OAAO,EAAE,QAAQ,EAAwB,MAAM,mCAAmC,CAAC;AACnF,OAAO,EAAE,kBAAkB,EAAE,OAAO,EAA6D,MAAM,oBAAoB,CAAC;AAC5H,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC/F,OAAO,EAAE,qBAAqB,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAetE,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAC1E,OAAO,EACL,oBAAoB,EACpB,oBAAoB,EACpB,eAAe,EACf,YAAY,EACZ,cAAc,EACd,aAAa,EACb,kBAAkB,GAEnB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,6BAA6B,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AAEtF,gGAAgG;AAChG,MAAM,CAAC,MAAM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AAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;IACtJ,OAAO,IAAI,eAAe,CAAC,gBAAgB,CAAC,cAAc,EAAE,OAAO,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;AAC1G,CAAC","sourcesContent":["// Twin of G9SyncData.Client.SignalR/G9CSignalRSyncTransport.cs: the sync transport over the G9SignalRSuperNetCore client\n// (its jittered reconnect policy and connection states), every failure surfacing as a G9SyncException with the server's\n// stable code. Lynx hosts build the client with the native WebSocket of @g9tm/signalr-supernetcore-lynx\n// (`createLynxSyncTransport` in @g9tm/syncdata-lynx does).\nimport { G9Client, type G9ClientOptions } from '@g9tm/signalr-supernetcore-client';\nimport { HubConnectionState, Subject, type IHubProtocol, type IStreamResult, type ISubscription } from '@microsoft/signalr';\nimport { G9SyncErrorCodes, G9SyncException, isSyncException } from '../abstractions/errors.js';\nimport { createAbortController, onAbort } from '../internal/abort.js';\nimport type { G9SyncTransport } from '../client/transport.js';\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';\nimport { G9SyncHubErrors, G9SyncProtocol } from '../protocol/protocol.js';\nimport {\n fromMessagePackNames,\n readChangesAvailable,\n readHelloResult,\n readPullPlan,\n readPushResult,\n readSyncChunk,\n toMessagePackNames,\n type G9WireFormat,\n} from '../protocol/wire.js';\nimport { createSyncMessagePackProtocol, G9SyncJsonHubProtocol } from './protocols.js';\n\n/** The SignalR hub protocol a client speaks (`G9ESyncHubProtocol`). The server accepts both. */\nexport const G9ESyncHubProtocol = {\n /** Text frames; payloads base64-encoded (+33%). Readable in traces. */\n Json: 0,\n /** Binary frames: payloads as raw bytes. The default. */\n MessagePack: 1,\n} as const;\nexport type G9ESyncHubProtocol = (typeof G9ESyncHubProtocol)[keyof typeof G9ESyncHubProtocol];\n\n/** Options of {@link G9SignalRSyncTransport} (`G9CSignalRSyncTransportOptions`). Durations are milliseconds. */\nexport interface G9SignalRSyncTransportOptions {\n /** Absolute hub URL, e.g. `https://sync.example.com/g9sync`. */\n url: string;\n /** Hub protocol; MessagePack by default. */\n protocol?: G9ESyncHubProtocol;\n /** Supplies the bearer token for every (re)connect. */\n accessTokenFactory?: () => string | Promise<string>;\n /** SignalR stateful reconnect (ADR-0069); off by default, the server must allow it too. */\n statefulReconnect?: boolean;\n /** How long one connect may take before it counts as a network failure. */\n connectTimeoutMs?: number;\n serverTimeoutMs?: number;\n keepAliveIntervalMs?: number;\n /**\n * How long a Hello waits for its answer before it is a retryable G9S-NET-FAILURE (ADR-0074). Default 60000; 0 = no limit.\n * A live connection does not guarantee an answer: pings keep it up while the call's message was lost on the way.\n */\n callTimeoutMs?: number;\n /**\n * How long a PlanPull waits for its plan. Default 300000 (5 minutes); 0 = no limit (ADR-0074, amended in 1.5.1): a site's first\n * plan builds key sets and plans a snapshot file - 16 s for a 450,000-row farm on a desktop, several times that on a busy server.\n */\n planTimeoutMs?: number;\n /** How long a push may take from its first chunk to its result; a safety net, not a pace. Default 600000; 0 = no limit. */\n pushTimeoutMs?: number;\n /**\n * How long a server stream (Pull, Reconcile, FetchRows) may go without a chunk before it is a retryable G9S-NET-FAILURE; the\n * engine resumes from its last continuation. Default 120000 (a snapshot file may still be building); 0 = no limit (ADR-0074).\n */\n streamIdleTimeoutMs?: number;\n /**\n * Everything else the G9 client takes (transport, headers, WebSocket constructor, skipNegotiation, reconnect policy, log\n * level…) — the twin of ConfigureHttpConnection/ConfigureBuilder. `url`, `protocol` and the timeouts above win.\n */\n client?: Partial<G9ClientOptions>;\n /** Builds the client (tests, hosts with their own wiring); `new G9Client(options)` by default. */\n createClient?: (options: G9ClientOptions) => G9Client;\n}\n\n/** The SignalR implementation of {@link G9SyncTransport}. */\nexport class G9SignalRSyncTransport implements G9SyncTransport {\n readonly client: G9Client;\n readonly format: G9WireFormat;\n private readonly _options: G9SignalRSyncTransportOptions;\n private readonly _handlers: ((changes: G9DtChangesAvailable) => void)[] = [];\n private _connecting: Promise<void> | null = null;\n private _lastHello: G9DtHelloRequest | null = null;\n /** The model this connection already sent in full, and the server's id for it (1.5.21, twin of .NET `_modelOnConnection`). */\n private _modelOnConnection: { connectionId: string | null; tables: G9DtHelloRequest['tables']; modelHash: string } | null = null;\n\n constructor(options: G9SignalRSyncTransportOptions) {\n if (!options || typeof options.url !== 'string' || options.url.trim() === '') throw new TypeError('A hub URL is required.');\n this._options = options;\n const json = options.protocol === G9ESyncHubProtocol.Json;\n this.format = json ? 'json' : 'messagepack';\n const protocol: IHubProtocol = json ? new G9SyncJsonHubProtocol() : createSyncMessagePackProtocol();\n const clientOptions: G9ClientOptions = {\n ...(options.client ?? {}),\n url: options.url,\n protocol,\n statefulReconnect: options.statefulReconnect ?? false,\n serverTimeoutMs: options.serverTimeoutMs ?? 30000,\n keepAliveIntervalMs: options.keepAliveIntervalMs ?? 10000,\n };\n if (options.accessTokenFactory) clientOptions.accessTokenFactory = options.accessTokenFactory;\n this.client = options.createClient ? options.createClient(clientOptions) : new G9Client(clientOptions);\n this.client.on(G9SyncProtocol.Listeners.OnChangesAvailable, (payload: unknown) => this._onChanges(payload));\n // Twin of .NET OnReconnectedAsync (S-2, LES-0087): a connection that reconnected by itself is a new connection id in no table group.\n const connection = this.client.connection as { onreconnected?: (callback: (connectionId?: string) => void) => void };\n if (typeof connection.onreconnected === 'function') connection.onreconnected(() => this._rejoin());\n }\n\n get isConnected(): boolean {\n return this.client.connection.state === HubConnectionState.Connected;\n }\n\n onChangesAvailable(handler: (changes: G9DtChangesAvailable) => void): () => void {\n this._handlers.push(handler);\n return () => {\n const index = this._handlers.indexOf(handler);\n if (index >= 0) this._handlers.splice(index, 1);\n };\n }\n\n /** Connects (joins a connect in progress); a connect that takes longer than connectTimeoutMs is a network failure. */\n connect(signal?: AbortSignal): Promise<void> {\n if (this.isConnected) return Promise.resolve();\n if (!this._connecting) {\n const connecting = this._connectCore().finally(() => {\n if (this._connecting === connecting) this._connecting = null;\n });\n this._connecting = connecting;\n }\n const connecting = this._connecting;\n if (!signal) return connecting;\n return new Promise<void>((resolve, reject) => {\n const unsubscribe = onAbort(signal, () => reject(new G9SyncException(G9SyncErrorCodes.Canceled, 'The connect was canceled.')));\n connecting.then(\n () => {\n unsubscribe();\n resolve();\n },\n (error) => {\n unsubscribe();\n reject(error);\n },\n );\n });\n }\n\n private async _connectCore(): Promise<void> {\n const timeout = createAbortController();\n const timer = setTimeout(() => timeout.abort(), this._options.connectTimeoutMs ?? 20000);\n try {\n await this.client.start(timeout.signal);\n } catch (error) {\n const mapped = mapError(error, false) ?? new G9SyncException(G9SyncErrorCodes.NetworkFailure, messageOf(error), { retryable: true, cause: error });\n throw mapped.code === G9SyncErrorCodes.Canceled\n ? new G9SyncException(G9SyncErrorCodes.NetworkFailure, `The sync connection to ${this._options.url} did not open in time.`, { retryable: true, cause: error })\n : mapped;\n } finally {\n clearTimeout(timer);\n }\n if (!this.isConnected) {\n throw new G9SyncException(G9SyncErrorCodes.NetworkFailure, `The sync connection is ${String(this.client.connection.state)}.`, { retryable: true });\n }\n }\n\n /**\n * 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\n * 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\n * answers `modelRequired` and the full Hello goes at once. A new connection — a reconnect included — always starts with the full model.\n */\n async hello(request: G9DtHelloRequest, signal?: AbortSignal): Promise<G9DtHelloResult> {\n const known = this._modelOnConnection;\n const sent: G9DtHelloRequest =\n known && known.connectionId === this._connectionId() && known.tables === request.tables && request.tables.length > 0\n ? { ...request, tables: [], modelHash: known.modelHash }\n : request;\n let result = await this._invoke(G9SyncProtocol.Methods.Hello, [this._wire(sent)], readHelloResult, this._callTimeoutMs(), signal);\n if (result.modelRequired && sent !== request) {\n this._modelOnConnection = null;\n result = await this._invoke(G9SyncProtocol.Methods.Hello, [this._wire(request)], readHelloResult, this._callTimeoutMs(), signal);\n }\n if (!result.error) {\n this._lastHello = request;\n this._rememberModel(request, result);\n }\n return result;\n }\n\n private _rememberModel(full: G9DtHelloRequest, result: G9DtHelloResult): void {\n if (result.modelHash && full.tables.length > 0) this._modelOnConnection = { connectionId: this._connectionId(), tables: full.tables, modelHash: result.modelHash };\n }\n\n private _connectionId(): string | null {\n const id = (this.client.connection as { connectionId?: string | null }).connectionId;\n return typeof id === 'string' ? id : null;\n }\n\n /**\n * After an automatic reconnect the last accepted Hello is sent again, so the new connection joins the table groups pokes go to\n * (S-2, LES-0087). Fire and forget, bounded by the call timeout; the answer is not used and a failure only delays a hint.\n */\n private _rejoin(): void {\n const hello = this._lastHello;\n if (!hello) return;\n // The full Hello (a new connection never holds the model): its answer names the model for the next Hello on it.\n this._invoke(G9SyncProtocol.Methods.Hello, [this._wire(hello)], readHelloResult, this._callTimeoutMs())\n .then((result) => {\n if (!result.error) this._rememberModel(hello, result);\n })\n .catch(() => undefined);\n }\n\n push(request: G9DtPushRequest, chunks: AsyncIterable<G9DtSyncChunk>, signal?: AbortSignal): Promise<G9DtPushResult> {\n const subject = new Subject<unknown>();\n const result = this._invoke(G9SyncProtocol.Methods.Push, [this._wire(request), subject], readPushResult, this._options.pushTimeoutMs ?? 600000, signal);\n void (async () => {\n try {\n for await (const chunk of chunks) subject.next(this._wire(chunk));\n subject.complete();\n } catch (error) {\n subject.error(error);\n }\n })();\n return result;\n }\n\n planPull(request: G9DtPullRequest, signal?: AbortSignal): Promise<G9DtPullPlan> {\n return this._invoke(G9SyncProtocol.Methods.PlanPull, [this._wire(request)], readPullPlan, this._options.planTimeoutMs ?? 300000, signal);\n }\n\n pull(token: string, continuation: G9DtPullContinuation | null, signal?: AbortSignal): AsyncIterable<G9DtSyncChunk> {\n return this._stream(G9SyncProtocol.Methods.Pull, [token, continuation === null ? null : this._wire(continuation)], signal);\n }\n\n reconcile(request: G9DtReconcileRequest, signal?: AbortSignal): AsyncIterable<G9DtSyncChunk> {\n return this._stream(G9SyncProtocol.Methods.Reconcile, [this._wire(request)], signal);\n }\n\n fetchRows(request: G9DtFetchRowsRequest, signal?: AbortSignal): AsyncIterable<G9DtSyncChunk> {\n return this._stream(G9SyncProtocol.Methods.FetchRows, [this._wire(request)], signal);\n }\n\n async dispose(): Promise<void> {\n this._handlers.length = 0;\n await this.client.stop();\n }\n\n // ================================================================ plumbing\n\n private _wire(value: unknown): unknown {\n return this.format === 'messagepack' ? toMessagePackNames(value) : value;\n }\n\n private _read(value: unknown): unknown {\n return this.format === 'messagepack' ? fromMessagePackNames(value) : value;\n }\n\n private _callTimeoutMs(): number {\n return this._options.callTimeoutMs ?? 60000;\n }\n\n private async _invoke<T>(method: string, args: unknown[], read: (value: unknown) => T, timeoutMs: number, signal?: AbortSignal): Promise<T> {\n if (signal && signal.aborted) throw new G9SyncException(G9SyncErrorCodes.Canceled, 'The call was canceled.');\n let unsubscribe: () => void = () => undefined;\n let timer: ReturnType<typeof setTimeout> | null = null;\n let timedOut = false;\n try {\n const call = this.client.connection.invoke(method, ...args);\n const raw =\n signal || timeoutMs > 0\n ? await new Promise<unknown>((resolve, reject) => {\n if (signal) unsubscribe = onAbort(signal, () => reject(new G9SyncException(G9SyncErrorCodes.Canceled, 'The call was canceled.')));\n if (timeoutMs > 0) {\n timer = setTimeout(() => {\n timedOut = true;\n reject(\n new G9SyncException(G9SyncErrorCodes.NetworkFailure, `The sync server did not answer ${method} within ${Math.round(timeoutMs / 1000)} s.`, {\n retryable: true,\n }),\n );\n }, timeoutMs);\n }\n call.then(resolve, reject);\n })\n : await call;\n return read(this._read(raw));\n } catch (error) {\n // ADR-0074: the answer did not come in time. The connection is not trusted any more (the server runs one invocation per\n // connection at a time, and whatever lost this answer may lose the next): drop it, so the retry runs on a fresh one.\n if (timedOut) await this._dropConnection();\n throw mapError(error, signal ? signal.aborted : false) ?? error;\n } finally {\n if (timer !== null) clearTimeout(timer);\n unsubscribe();\n }\n }\n\n /** Ends the connection after a call or stream ran out of time (ADR-0074); the next call connects afresh. Never throws. */\n private async _dropConnection(): Promise<void> {\n try {\n await this.client.connection.stop();\n } catch {\n // Stopping a connection that is already gone may throw; the next call connects afresh either way.\n }\n }\n\n private _stream(method: string, args: unknown[], signal?: AbortSignal): AsyncIterable<G9DtSyncChunk> {\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n const self = this;\n return {\n [Symbol.asyncIterator](): AsyncIterator<G9DtSyncChunk> {\n const queue: G9DtSyncChunk[] = [];\n let done = false;\n let failure: unknown = null;\n let wake: (() => void) | null = null;\n let subscription: ISubscription<unknown> | null = null;\n const notify = (): void => {\n const w = wake;\n wake = null;\n if (w) w();\n };\n let unsubscribeAbort: () => void = () => undefined;\n // ADR-0074: the idle limit runs only while the iterator waits for the next chunk, never while the caller processes one.\n const idleMs = self._options.streamIdleTimeoutMs ?? 120000;\n let idleTimer: ReturnType<typeof setTimeout> | null = null;\n let idleExpired = false;\n const stopIdle = (): void => {\n if (idleTimer !== null) clearTimeout(idleTimer);\n idleTimer = null;\n };\n const armIdle = (): void => {\n stopIdle();\n if (idleMs <= 0 || done) return;\n idleTimer = setTimeout(() => {\n idleTimer = null;\n if (done) return;\n idleExpired = true;\n failure = new G9SyncException(G9SyncErrorCodes.NetworkFailure, `The sync server sent nothing on ${method} for ${Math.round(idleMs / 1000)} s.`, {\n retryable: true,\n });\n done = true;\n subscription?.dispose();\n notify();\n }, idleMs);\n };\n const start = (): void => {\n if (subscription || done) return;\n let stream: IStreamResult<unknown>;\n try {\n stream = self.client.connection.stream(method, ...args);\n } catch (error) {\n failure = error;\n done = true;\n return;\n }\n subscription = stream.subscribe({\n next: (item) => {\n queue.push(readSyncChunk(self._read(item)));\n notify();\n },\n error: (error) => {\n failure = error;\n done = true;\n notify();\n },\n complete: () => {\n done = true;\n notify();\n },\n });\n unsubscribeAbort = onAbort(signal, () => {\n failure = new G9SyncException(G9SyncErrorCodes.Canceled, 'The stream was canceled.');\n done = true;\n subscription?.dispose();\n notify();\n });\n };\n const finish = (): void => {\n stopIdle();\n unsubscribeAbort();\n if (subscription && !done) subscription.dispose();\n done = true;\n };\n return {\n async next(): Promise<IteratorResult<G9DtSyncChunk>> {\n start();\n for (;;) {\n const item = queue.shift();\n if (item) {\n stopIdle();\n return { value: item, done: false };\n }\n if (done) {\n stopIdle();\n unsubscribeAbort();\n if (idleExpired) await self._dropConnection();\n if (failure !== null) throw mapError(failure, signal ? signal.aborted : false) ?? failure;\n return { value: undefined as unknown as G9DtSyncChunk, done: true };\n }\n if (idleTimer === null) armIdle();\n await new Promise<void>((resolve) => {\n wake = resolve;\n });\n }\n },\n async return(): Promise<IteratorResult<G9DtSyncChunk>> {\n finish();\n return { value: undefined as unknown as G9DtSyncChunk, done: true };\n },\n };\n },\n };\n }\n\n private _onChanges(payload: unknown): void {\n const changes = readChangesAvailable(this._read(payload));\n for (const handler of this._handlers.slice()) {\n try {\n handler(changes);\n } catch {\n // A ChangesAvailable handler threw (logged by the .NET transport); it must not break the connection.\n }\n }\n }\n}\n\nfunction messageOf(error: unknown): string {\n return error instanceof Error ? error.message : String(error);\n}\n\n/**\n * The sync exception for a transport failure (`Map`): the server's `[G9S|code|retryable]` marker wins; any other hub\n * error is a retryable server error; 401/403 is Unauthorized; the rest is a retryable network failure. Null leaves the\n * error as it is (an already mapped one).\n */\nexport function mapError(error: unknown, canceled: boolean): G9SyncException | null {\n if (isSyncException(error)) return null;\n if (canceled) return new G9SyncException(G9SyncErrorCodes.Canceled, 'The call was canceled.', { cause: error });\n const message = messageOf(error);\n const marked = G9SyncHubErrors.tryParse(message);\n if (marked) return marked;\n const status = (error as { statusCode?: unknown }).statusCode;\n if (status === 401 || status === 403) return new G9SyncException(G9SyncErrorCodes.Unauthorized, 'The sync server refused the credentials.', { cause: error });\n if (error instanceof Error && error.name === 'AbortError') return new G9SyncException(G9SyncErrorCodes.Canceled, message, { cause: error });\n // A completion error from the hub: SignalR words it \"An unexpected error occurred invoking '…' on the server.\"\n if (/on the server|HubException/i.test(message)) return new G9SyncException(G9SyncErrorCodes.ServerError, message, { retryable: true, cause: error });\n return new G9SyncException(G9SyncErrorCodes.NetworkFailure, message, { retryable: true, cause: error });\n}\n"]}