@delali/sirannon-db 0.3.4-next.62 → 0.3.4

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.
Files changed (108) hide show
  1. package/README.md +79 -56
  2. package/dist/backup/index.d.ts +44 -45
  3. package/dist/backup/index.mjs +7 -7
  4. package/dist/backup-scheduler/index.d.ts +42 -41
  5. package/dist/backup-scheduler/index.mjs +4 -4
  6. package/dist/baseline-Co3iIsN_.d.ts +19 -0
  7. package/dist/change-tracker-DqCdeEyx.d.ts +128 -0
  8. package/dist/{chunk-VOSJBZ6Q.mjs → chunk-2ES3DT4A.mjs} +71 -33
  9. package/dist/{chunk-6CMCO7S4.mjs → chunk-2O3PP4CF.mjs} +1 -1
  10. package/dist/{chunk-E7Q7HE46.mjs → chunk-3BZLZ47R.mjs} +26 -26
  11. package/dist/chunk-4KASJKKK.mjs +2501 -0
  12. package/dist/{chunk-MYNI2WFS.mjs → chunk-52XW3Z76.mjs} +40 -8
  13. package/dist/chunk-55YRLSM2.mjs +57 -0
  14. package/dist/{chunk-KDAHYFW7.mjs → chunk-6AOJCNRU.mjs} +5 -5
  15. package/dist/{chunk-KXTYR2OQ.mjs → chunk-A3PHCO6W.mjs} +39 -111
  16. package/dist/chunk-ADNWEHGZ.mjs +299 -0
  17. package/dist/{chunk-2QLXDHAP.mjs → chunk-BLMRNSUG.mjs} +11 -2
  18. package/dist/chunk-BVMZJOVM.mjs +5 -0
  19. package/dist/{chunk-IWGIYDMZ.mjs → chunk-BZWDPF4G.mjs} +1 -1
  20. package/dist/{chunk-YVF2ZJTE.mjs → chunk-CZL4D3BM.mjs} +1 -1
  21. package/dist/{chunk-7SC2TZAS.mjs → chunk-DX4WGJL7.mjs} +2 -2
  22. package/dist/{chunk-45MKELYA.mjs → chunk-ESTZZPT5.mjs} +132 -13
  23. package/dist/{chunk-QP5L5DFJ.mjs → chunk-FJPR2CJX.mjs} +3 -3
  24. package/dist/chunk-HR7K3GZW.mjs +36 -0
  25. package/dist/{chunk-LXCGPZPA.mjs → chunk-IEKIYO4V.mjs} +1 -1
  26. package/dist/{chunk-TUD5CJ76.mjs → chunk-KB4OLJAD.mjs} +26 -19
  27. package/dist/{chunk-PBRXXISQ.mjs → chunk-KINDFBQP.mjs} +3 -2
  28. package/dist/{chunk-E6IMX7RS.mjs → chunk-KJLNYOOL.mjs} +2 -2
  29. package/dist/{chunk-BTTFW4Z4.mjs → chunk-KU32OT4H.mjs} +2 -10
  30. package/dist/{chunk-JQWGHSEH.mjs → chunk-NVSQ2T5Q.mjs} +71 -70
  31. package/dist/{chunk-W4EUTJNT.mjs → chunk-NZGSDALX.mjs} +94 -96
  32. package/dist/{chunk-U445A3C4.mjs → chunk-QGVRRKB2.mjs} +1 -1
  33. package/dist/{chunk-GYCEJNU4.mjs → chunk-R7GBXNTO.mjs} +1 -1
  34. package/dist/{chunk-7C36BCSN.mjs → chunk-VDN6FHU4.mjs} +1 -1
  35. package/dist/{chunk-6IYS4WLH.mjs → chunk-VO3ZWA2G.mjs} +142 -115
  36. package/dist/chunk-WOMADPM4.mjs +12 -0
  37. package/dist/{chunk-OUSWVNWT.mjs → chunk-YCMB6GR4.mjs} +1 -1
  38. package/dist/{chunk-YNTDOFTN.mjs → chunk-YW7IKQ7T.mjs} +1 -1
  39. package/dist/{chunk-M2BEAH5I.mjs → chunk-ZN4HI5FK.mjs} +126 -72
  40. package/dist/{chunk-SBL6GN43.mjs → chunk-ZYWI45EN.mjs} +1 -1
  41. package/dist/client/index.d.ts +135 -137
  42. package/dist/client/index.mjs +177 -82
  43. package/dist/client/topology.d.ts +31 -31
  44. package/dist/client/topology.mjs +42 -23
  45. package/dist/client-base-BxTocU1x.d.ts +398 -0
  46. package/dist/client-streams-YKANXMWO.mjs +112 -0
  47. package/dist/codegen/cli.mjs +4 -4
  48. package/dist/codegen/index.d.ts +36 -29
  49. package/dist/codegen/index.mjs +4 -4
  50. package/dist/core/index.d.ts +130 -115
  51. package/dist/core/index.mjs +387 -297
  52. package/dist/core/writer-worker.mjs +3 -3
  53. package/dist/database-CGDsXW1K.d.ts +959 -0
  54. package/dist/database-backup-DcLhxoa1.d.ts +143 -0
  55. package/dist/driver/better-sqlite3.d.ts +11 -10
  56. package/dist/driver/better-sqlite3.mjs +11 -11
  57. package/dist/driver/bun.d.ts +9 -8
  58. package/dist/driver/expo.d.ts +6 -7
  59. package/dist/driver/node.d.ts +11 -10
  60. package/dist/driver/node.mjs +13 -11
  61. package/dist/driver/wa-sqlite.d.ts +6 -6
  62. package/dist/errors-CJUkQ-KL.d.ts +199 -0
  63. package/dist/file-migrations/index.d.ts +20 -18
  64. package/dist/file-migrations/index.mjs +3 -3
  65. package/dist/forward-rpc-VRWFZXHN.mjs +44 -0
  66. package/dist/operation-registry-CGhNT-Sn.d.ts +96 -0
  67. package/dist/primary-wins-CHNOYuN7.d.ts +81 -0
  68. package/dist/protocol-DFpNNsIT.d.ts +153 -0
  69. package/dist/query-types-5B02ixH0.d.ts +129 -0
  70. package/dist/react/index.d.ts +22 -22
  71. package/dist/replication/coordinator/etcd.d.ts +37 -31
  72. package/dist/replication/coordinator/etcd.mjs +296 -131
  73. package/dist/replication/index.d.ts +201 -161
  74. package/dist/replication/index.mjs +630 -529
  75. package/dist/restore-options-CH8mE-Tb.d.ts +84 -0
  76. package/dist/server/index.d.ts +201 -191
  77. package/dist/server/index.mjs +736 -619
  78. package/dist/server-options-aYtCkefX.d.ts +317 -0
  79. package/dist/server-streams-24XL4T43.mjs +254 -0
  80. package/dist/sirannon-J3EgPVD7.d.ts +179 -0
  81. package/dist/transport/grpc.d.ts +37 -24
  82. package/dist/transport/grpc.mjs +83 -3199
  83. package/dist/transport/memory.d.ts +25 -26
  84. package/dist/transport/memory.mjs +18 -9
  85. package/dist/types-BrAiDGOb.d.ts +505 -0
  86. package/dist/types-CEJG0eFS.d.ts +88 -0
  87. package/dist/types-Dc8oWlxj.d.ts +1580 -0
  88. package/dist/types-DqODKeOq.d.ts +123 -0
  89. package/dist/types-guEKSzMr.d.ts +367 -0
  90. package/package.json +7 -7
  91. package/dist/baseline-D93hcIEE.d.ts +0 -17
  92. package/dist/change-tracker-CjRFuZdB.d.ts +0 -144
  93. package/dist/client-base-Cmd9EVme.d.ts +0 -397
  94. package/dist/database-BLQvqjsw.d.ts +0 -917
  95. package/dist/database-backup-B7oszQ2n.d.ts +0 -141
  96. package/dist/errors-Dei4GdBb.d.ts +0 -196
  97. package/dist/operation-registry-oiPuSYI6.d.ts +0 -94
  98. package/dist/primary-wins-B0np8JS3.d.ts +0 -85
  99. package/dist/protocol-HI-nY8DD.d.ts +0 -152
  100. package/dist/query-types-p1liOP-b.d.ts +0 -127
  101. package/dist/restore-options-CksYsH1l.d.ts +0 -83
  102. package/dist/server-options-Bj5iJnjx.d.ts +0 -292
  103. package/dist/sirannon-BPxC5tC2.d.ts +0 -178
  104. package/dist/types-B0EhgDbr.d.ts +0 -340
  105. package/dist/types-CbjfRwrK.d.ts +0 -499
  106. package/dist/types-CjhxcjhA.d.ts +0 -123
  107. package/dist/types-DPSmjU54.d.ts +0 -1518
  108. package/dist/types-DTO4CYhW.d.ts +0 -88
@@ -1,141 +0,0 @@
1
- import { h as BackupChainBase, i as BackupChainChange, g as BackupChain, k as BackupChainRecord, B as BackupDestination, I as SQLiteConnection, P as DriverCapabilities, Q as BackupEngine, p as BackupFileReport, y as BackupToDestinationOptions, f as BackupRunReport, O as BackupScheduleOptions, n as BackupCycleOptions, o as BackupCycleStatus, z as BackupVerifyResult } from './types-DPSmjU54.js';
2
-
3
- /**
4
- * What one runtime supports of the backup operations, so a caller learns
5
- * before a run rather than at failure time. A runtime that hands over whole
6
- * databases only reports no full copy at all.
7
- *
8
- * @public
9
- */
10
- interface BackupCapabilities {
11
- /** Whether this runtime copies an open database while writes continue. */
12
- fullCopy: boolean;
13
- /** Whether a full copy reaches the destination without a local file. */
14
- streamedCopy: boolean;
15
- /** Whether a full copy writes a local file and sends that file on. */
16
- stagedCopy: boolean;
17
- /** Local disk a full copy needs, which the staged route sets to the size of the backup. */
18
- localDiskRequired: 'none' | 'equal-to-backup';
19
- /** Whether this runtime repeats a full copy on a schedule. */
20
- schedule: boolean;
21
- }
22
-
23
- /** What one restore has to read, and what it will produce.
24
- * @public
25
- */
26
- interface BackupRestorePlan {
27
- /** The chain to read. */
28
- chainId: string;
29
- /** The full copy to start from. */
30
- base: BackupChainBase;
31
- /** The change pieces to apply on top of it, oldest first. */
32
- changes: BackupChainChange[];
33
- /**
34
- * Epoch milliseconds the restored database will reflect. This is when the
35
- * last piece in the plan was captured, which is at or before the moment you
36
- * asked for.
37
- */
38
- restoresTo: number;
39
- }
40
- /** How far back you still want to be able to restore.
41
- * @public
42
- */
43
- interface BackupSafeToDeleteOptions {
44
- /**
45
- * Epoch milliseconds of the earliest moment a restore must still reach.
46
- * Leave it out and the answer covers only the backups no restore could ever
47
- * use.
48
- */
49
- restorableFrom?: number;
50
- }
51
- /**
52
- * Works out what a restore to a given moment has to read: the newest full copy
53
- * finished at or before it, then every change piece captured from that copy up
54
- * to it.
55
- *
56
- * You get back the moment the result will actually reflect, which is when the
57
- * last piece was captured. One piece covers every write in the interval it was
58
- * taken over, so a restore arrives at a piece boundary, not at the exact
59
- * millisecond you named.
60
- *
61
- * A gap in the chain fails the plan with `BACKUP_CHAIN_BROKEN` and names the
62
- * missing piece, because a plan that stopped part-way through would leave a
63
- * database nobody could trust.
64
- *
65
- * @param chains - The chains a destination holds, as {@link readBackupChains} returns them.
66
- * @param moment - Epoch milliseconds you want back.
67
- * @returns The full copy, the change pieces to apply, and the moment the result reflects.
68
- *
69
- * @public
70
- */
71
- declare function planBackupRestore(chains: readonly BackupChain[], moment: number): BackupRestorePlan;
72
- /**
73
- * Tells you which backups no restore still needs, so you can delete them
74
- * knowing exactly what you give up.
75
- *
76
- * Two kinds are dead whatever you ask for: a chain whose full copy has gone,
77
- * and every change piece after a gap, since nothing can be replayed past the
78
- * gap. Name the earliest moment you still want to reach and the answer also
79
- * covers the older chains a newer full copy already spans.
80
- *
81
- * Sirannon lists them and deletes nothing. The destination is yours.
82
- *
83
- * @param chains - The chains a destination holds, as {@link readBackupChains} returns them.
84
- * @param options - How far back you still want to be able to restore.
85
- * @returns The records you may delete, oldest first.
86
- *
87
- * @public
88
- */
89
- declare function backupPiecesSafeToDelete(chains: readonly BackupChain[], options?: BackupSafeToDeleteOptions): BackupChainRecord[];
90
-
91
- type RunExclusive = (op: () => Promise<void>) => Promise<void>;
92
- /** Where one database's backups are stored, and what a restore of that database reads.
93
- * @public
94
- */
95
- interface BackupChainLocation {
96
- /** The destination its pieces and its chain records go to. */
97
- destination: BackupDestination;
98
- /** Name that destination lists its chains under. */
99
- chainName: string;
100
- /** Directory the cycle stages each capture in before that capture goes out. */
101
- stagingDir: string;
102
- /** Deadline the operator set on every call to that destination, where they set one. */
103
- destinationTimeoutMs?: number;
104
- }
105
- declare class DatabaseBackupController {
106
- private readonly runExclusive;
107
- private readonly acquireWriter;
108
- private readonly driverCapabilities;
109
- private readonly databaseId;
110
- private readonly sourcePath;
111
- private readonly engine?;
112
- private readonly cancellers;
113
- private cycle;
114
- private cycleOptions;
115
- private cycleStarted;
116
- constructor(runExclusive: RunExclusive, acquireWriter: () => SQLiteConnection, driverCapabilities: DriverCapabilities, databaseId: string, sourcePath: string, engine?: BackupEngine | undefined);
117
- private require;
118
- private requireCycle;
119
- capabilities(): BackupCapabilities;
120
- backup(destPath: string): Promise<BackupFileReport>;
121
- backupTo(options: BackupToDestinationOptions): Promise<BackupRunReport>;
122
- schedule(options: BackupScheduleOptions): void;
123
- /**
124
- * Builds the cycle and starts it in the background. Its first turn copies the
125
- * whole database, and an open cannot wait on that. A failure reaches the
126
- * caller through the cycle's own error callback.
127
- */
128
- startCycle(options: BackupCycleOptions): void;
129
- captureChanges(): Promise<BackupRunReport | undefined>;
130
- chains(): Promise<BackupChain[]>;
131
- status(): BackupCycleStatus;
132
- location(): BackupChainLocation;
133
- verify(name: string): Promise<BackupVerifyResult>;
134
- restorePlan(moment: number): Promise<BackupRestorePlan>;
135
- piecesSafeToDelete(options?: BackupSafeToDeleteOptions): Promise<BackupChainRecord[]>;
136
- /** Stops the cycle, capturing the log one final time so nothing written since the previous turn is lost. */
137
- stopCycle(): Promise<void>;
138
- cancelAll(): void;
139
- }
140
-
141
- export { type BackupCapabilities as B, DatabaseBackupController as D, type BackupChainLocation as a, type BackupRestorePlan as b, type BackupSafeToDeleteOptions as c, backupPiecesSafeToDelete as d, planBackupRestore as p };
@@ -1,196 +0,0 @@
1
- /**
2
- * Base class for all sirannon-db errors. Extend this class to create
3
- * domain-specific errors that carry a machine-readable {@link SirannonError.code}.
4
- *
5
- * @public
6
- */
7
- declare class SirannonError extends Error {
8
- /**
9
- * Machine-readable code the server maps to an HTTP status.
10
- */
11
- readonly code: string;
12
- constructor(message: string,
13
- /**
14
- * Machine-readable code the server maps to an HTTP status.
15
- */
16
- code: string);
17
- }
18
- /**
19
- * Thrown when a database ID cannot be resolved in the registry.
20
- * This typically means the database was never opened or has already been closed.
21
- *
22
- * @public
23
- */
24
- declare class DatabaseNotFoundError extends SirannonError {
25
- constructor(id: string);
26
- }
27
- /**
28
- * Thrown when attempting to register a database with an ID that is already
29
- * in use. Each database ID must be unique within the registry.
30
- *
31
- * @public
32
- */
33
- declare class DatabaseAlreadyExistsError extends SirannonError {
34
- constructor(id: string);
35
- }
36
- /**
37
- * Thrown when a write operation is attempted on a database that was opened
38
- * in read-only mode.
39
- *
40
- * @public
41
- */
42
- declare class ReadOnlyError extends SirannonError {
43
- constructor(id: string);
44
- }
45
- /**
46
- * Thrown when SQLite fails to execute a statement. The {@link QueryError.sql} property
47
- * holds the original SQL string that caused the failure, which is useful for
48
- * debugging and logging.
49
- *
50
- * @public
51
- */
52
- declare class QueryError extends SirannonError {
53
- /**
54
- * The statement that failed.
55
- */
56
- readonly sql: string;
57
- constructor(message: string,
58
- /**
59
- * The statement that failed.
60
- */
61
- sql: string);
62
- }
63
- /**
64
- * Thrown when a transaction cannot be committed or is forcibly rolled back.
65
- * Check the message for the underlying cause.
66
- *
67
- * @public
68
- */
69
- declare class TransactionError extends SirannonError {
70
- constructor(message: string);
71
- }
72
- /**
73
- * Thrown when a migration step fails. The {@link MigrationError.version} property identifies
74
- * which schema version triggered the error so the failure can be pinpointed
75
- * in the migration history.
76
- *
77
- * @public
78
- */
79
- declare class MigrationError extends SirannonError {
80
- /**
81
- * Version of the migration that failed.
82
- */
83
- readonly version: number;
84
- constructor(message: string,
85
- /**
86
- * Version of the migration that failed.
87
- */
88
- version: number, code?: string);
89
- }
90
- /**
91
- * Thrown when a before-hook explicitly rejects an operation. The optional
92
- * `reason` string is surfaced in the message so callers can distinguish
93
- * between different hook policies.
94
- *
95
- * @public
96
- */
97
- declare class HookDeniedError extends SirannonError {
98
- constructor(hookName: string, reason?: string);
99
- }
100
- /**
101
- * Refuses one request with a status of your own. Throw it from an authenticate hook or a registered operation.
102
- *
103
- * @public
104
- */
105
- declare class RequestDeniedError extends SirannonError {
106
- /**
107
- * HTTP status the server answers the refused request with.
108
- */
109
- readonly status: number;
110
- constructor(status: number, code: string, message: string);
111
- }
112
- /**
113
- * Thrown when the change-data-capture pipeline encounters an unrecoverable
114
- * error, such as a failed event dispatch or a corrupt change record.
115
- *
116
- * @public
117
- */
118
- declare class CDCError extends SirannonError {
119
- constructor(message: string);
120
- }
121
- /**
122
- * Thrown when a caller reaches for a table Sirannon reserves for itself. The
123
- * internal bookkeeping tables and SQLite's own catalogue are off limits to the
124
- * query API so a caller cannot read or corrupt the change log, replication
125
- * ledger, or schema catalogue.
126
- *
127
- * @public
128
- */
129
- declare class ForbiddenSqlError extends SirannonError {
130
- constructor(message: string);
131
- }
132
- /**
133
- * Thrown when a backup operation fails, whether that is an online backup via
134
- * the SQLite backup API or a file-level copy.
135
- *
136
- * @public
137
- */
138
- declare class BackupError extends SirannonError {
139
- constructor(message: string);
140
- }
141
- /**
142
- * Thrown when the connection pool reaches its limit or is configured with
143
- * invalid parameters such as a minimum size greater than the maximum.
144
- *
145
- * @public
146
- */
147
- declare class ConnectionPoolError extends SirannonError {
148
- constructor(message: string);
149
- }
150
- /**
151
- * Thrown when opening a new database would exceed the configured cap on
152
- * concurrently open databases. Close an existing database before opening
153
- * another one.
154
- *
155
- * @public
156
- */
157
- declare class MaxDatabasesError extends SirannonError {
158
- constructor(max: number);
159
- }
160
- /**
161
- * Thrown when more writes are pending than the writer-worker limit allows. It
162
- * signals load shedding, so the server maps it to a 503 with a Retry-After hint.
163
- *
164
- * @public
165
- */
166
- declare class WriteOverloadError extends SirannonError {
167
- /**
168
- * Number of pending writes the database accepts before it refuses more.
169
- */
170
- readonly limit: number;
171
- /**
172
- * Milliseconds the caller should wait before retrying.
173
- */
174
- readonly retryAfterMs: number;
175
- constructor(
176
- /**
177
- * Number of pending writes the database accepts before it refuses more.
178
- */
179
- limit: number,
180
- /**
181
- * Milliseconds the caller should wait before retrying.
182
- */
183
- retryAfterMs: number);
184
- }
185
- /**
186
- * Thrown when a native SQLite extension cannot be loaded. The `path` argument
187
- * is the filesystem path passed to `load_extension`, and the optional `cause`
188
- * string carries the error detail reported by SQLite.
189
- *
190
- * @public
191
- */
192
- declare class ExtensionError extends SirannonError {
193
- constructor(path: string, cause?: string);
194
- }
195
-
196
- export { BackupError as B, CDCError as C, DatabaseAlreadyExistsError as D, ExtensionError as E, ForbiddenSqlError as F, HookDeniedError as H, MaxDatabasesError as M, QueryError as Q, ReadOnlyError as R, SirannonError as S, TransactionError as T, WriteOverloadError as W, ConnectionPoolError as a, DatabaseNotFoundError as b, MigrationError as c, RequestDeniedError as d };
@@ -1,94 +0,0 @@
1
- import { P as Params } from './query-types-p1liOP-b.js';
2
-
3
- /** One statement a registered operation runs, with its parameters bound.
4
- * @public
5
- */
6
- interface OperationStatement {
7
- /** The statement to run. */
8
- sql: string;
9
- /** Parameters bound to that statement. */
10
- params?: Params;
11
- }
12
- /** Values a caller passes when it invokes a registered operation by name.
13
- * @public
14
- */
15
- type OperationArguments = Record<string, unknown>;
16
- /** A read a caller invokes by name, so the server accepts no SQL from the network.
17
- * @public
18
- */
19
- interface ReadOperation<Identity = unknown> {
20
- /** Argument names this operation accepts from the caller. */
21
- args?: readonly string[];
22
- /** Arguments the server fills from the authenticated identity, so a caller cannot supply them. */
23
- fromIdentity?: Readonly<Record<string, keyof Identity & string>>;
24
- /**
25
- * The columns every row of this read carries. Code generation emits a typed
26
- * row from it, and reads the columns from the statement only when the
27
- * operation takes no arguments, because arguments choose the statement.
28
- */
29
- columns?: readonly string[];
30
- /** Builds the statement this read runs for a given set of arguments. */
31
- statement(args: OperationArguments): OperationStatement;
32
- }
33
- /** A write a caller invokes by name. The server runs every statement it returns in one transaction.
34
- * @public
35
- */
36
- interface WriteOperation<Identity = unknown> {
37
- /** Argument names this operation accepts from the caller. */
38
- args?: readonly string[];
39
- /** Arguments the server fills from the authenticated identity, so a caller cannot supply them. */
40
- fromIdentity?: Readonly<Record<string, keyof Identity & string>>;
41
- /** Builds the statements this write runs for a given set of arguments. */
42
- statements(args: OperationArguments): OperationStatement | readonly OperationStatement[];
43
- }
44
- /** The reads and writes one database exposes by name.
45
- * @public
46
- */
47
- interface DatabaseOperations<Identity = unknown> {
48
- /** Reads callers may invoke, keyed by operation name. */
49
- reads?: Readonly<Record<string, ReadOperation<Identity>>>;
50
- /** Writes callers may invoke, keyed by operation name. */
51
- writes?: Readonly<Record<string, WriteOperation<Identity>>>;
52
- }
53
- /** Every database's registered operations, keyed by database identifier.
54
- * @public
55
- */
56
- type OperationRegistry<Identity = unknown> = Readonly<Record<string, DatabaseOperations<Identity>>>;
57
- /**
58
- * A named operation a remote caller invokes, carrying the argument and row
59
- * types of the registered operation. Only `name` exists at runtime; `types`
60
- * is never assigned and is present so both type parameters are inferable at
61
- * the call site. Code generation emits one reference per registered operation.
62
- *
63
- * @public
64
- */
65
- interface OperationRef<Args = OperationArguments, Row = Record<string, unknown>> {
66
- /** Name the server registered this operation under. */
67
- readonly name: string;
68
- /** Present for type inference only, and never assigned at runtime. */
69
- readonly types?: {
70
- args: Args;
71
- row: Row;
72
- };
73
- }
74
- /**
75
- * Builds a typed reference to a registered operation so that a call site infers its
76
- * argument and row types from the name alone.
77
- *
78
- * @param name - Name the server registered the operation under.
79
- * @returns A reference carrying that name and the two inferred types.
80
- *
81
- * @public
82
- */
83
- declare function operationRef<Args = OperationArguments, Row = Record<string, unknown>>(name: string): OperationRef<Args, Row>;
84
- /**
85
- * Reads the operation name out of either a plain string or a typed reference.
86
- *
87
- * @param operation - The name itself, or a reference built by {@link operationRef}.
88
- * @returns The registered operation name.
89
- *
90
- * @public
91
- */
92
- declare function operationName(operation: string | OperationRef<never, never>): string;
93
-
94
- export { type DatabaseOperations as D, type OperationRef as O, type ReadOperation as R, type WriteOperation as W, type OperationRegistry as a, type OperationArguments as b, type OperationStatement as c, operationRef as d, operationName as o };
@@ -1,85 +0,0 @@
1
- import { C as ConflictResolver, a as ConflictContext, b as ConflictResolution } from './types-CjhxcjhA.js';
2
-
3
- type ColumnVersionGetter = (table: string, rowId: string) => Promise<Map<string, {
4
- hlc: string;
5
- nodeId: string;
6
- }>>;
7
- /**
8
- * Per-column conflict resolver that merges non-overlapping field changes.
9
- *
10
- * Given a conflict between a local and remote write on the same row, this
11
- * resolver computes the set of columns each side changed relative to the
12
- * common ancestor (oldData). If the changed column sets don't overlap, both
13
- * sides' changes are merged into a single row, avoiding unnecessary data
14
- * loss. When columns do overlap, per-column HLC versions (retrieved via the
15
- * injected `getColumnVersions` callback) determine which side's value wins
16
- * for each contested column. If no column version metadata exists, the
17
- * resolver falls back to whole-row LWW.
18
- *
19
- * @public
20
- */
21
- declare class FieldMergeResolver implements ConflictResolver {
22
- private readonly getColumnVersions;
23
- private readonly lww;
24
- constructor(getColumnVersions: ColumnVersionGetter);
25
- /**
26
- * Merges columns only one side changed, and settles overlapping columns by their per-column stamps.
27
- *
28
- * @param ctx - The local and incoming versions of one row.
29
- * @returns Which version to write, or the merged row.
30
- */
31
- resolve(ctx: ConflictContext): Promise<ConflictResolution>;
32
- }
33
-
34
- /**
35
- * Last-Writer-Wins conflict resolver.
36
- *
37
- * A remote delete is accepted whatever the timestamps say, so a delete wins over
38
- * a concurrent update and a deleted row is never resurrected.
39
- *
40
- * Otherwise compares the remote HLC against the local HLC. The higher timestamp wins.
41
- * When both timestamps are equal (concurrent writes within the same
42
- * millisecond and logical tick), the tie is broken deterministically by
43
- * comparing node IDs lexicographically, so that every node reaches the same
44
- * resolution without coordination. This is the default resolver and the
45
- * fallback used by PrimaryWinsResolver and FieldMergeResolver when they
46
- * cannot make a more specific decision.
47
- *
48
- * @public
49
- */
50
- declare class LWWResolver implements ConflictResolver {
51
- /**
52
- * Takes the incoming row when its stamp is higher, and keeps the local row otherwise.
53
- *
54
- * @param ctx - The local and incoming versions of one row.
55
- * @returns Which version to write.
56
- */
57
- resolve(ctx: ConflictContext): ConflictResolution;
58
- }
59
-
60
- /**
61
- * Conflict resolver that unconditionally favors the designated primary node.
62
- *
63
- * If the remote change originated from the primary, it is accepted. If the
64
- * local change originated from the primary, the remote is rejected. When
65
- * neither side is the primary (e.g., two replicas syncing through a relay),
66
- * the decision falls back to LWW ordering. This resolver is designed for
67
- * primary-replica topologies where the primary is the authoritative source of
68
- * truth and replica-side writes should never override it.
69
- *
70
- * @public
71
- */
72
- declare class PrimaryWinsResolver implements ConflictResolver {
73
- private readonly primaryNodeId;
74
- private readonly lww;
75
- constructor(primaryNodeId: string);
76
- /**
77
- * Takes the version authored by the configured primary node, and falls back to last-writer-wins otherwise.
78
- *
79
- * @param ctx - The local and incoming versions of one row.
80
- * @returns Which version to write.
81
- */
82
- resolve(ctx: ConflictContext): ConflictResolution;
83
- }
84
-
85
- export { FieldMergeResolver as F, LWWResolver as L, PrimaryWinsResolver as P };
@@ -1,152 +0,0 @@
1
- import { W as WriteConcern, R as ReadConcern, E as ExecuteResult } from './query-types-p1liOP-b.js';
2
- import { B as BulkLoadDurability, a as BulkLoadResult } from './server-options-Bj5iJnjx.js';
3
-
4
- /**
5
- * Body of `POST /db/{id}/query`.
6
- *
7
- * @public
8
- */
9
- interface QueryRequest {
10
- /** The statement to run. */
11
- sql: string;
12
- /** Values bound to the statement, named or positional. */
13
- params?: Record<string, unknown> | unknown[];
14
- /** Currency this read requires. */
15
- readConcern?: ReadConcern;
16
- }
17
- /**
18
- * Body of `POST /db/{id}/execute`.
19
- *
20
- * @public
21
- */
22
- interface ExecuteRequest {
23
- /** The statement to run. */
24
- sql: string;
25
- /** Values bound to the statement, named or positional. */
26
- params?: Record<string, unknown> | unknown[];
27
- /** Acknowledgements this write waits for. */
28
- writeConcern?: WriteConcern;
29
- }
30
- /**
31
- * One statement inside a transaction or a registered write.
32
- *
33
- * @public
34
- */
35
- interface TransactionStatement {
36
- /** The statement to run. */
37
- sql: string;
38
- /** Values bound to the statement, named or positional. */
39
- params?: Record<string, unknown> | unknown[];
40
- }
41
- /**
42
- * Body of `POST /db/{id}/transaction`, whose statements all succeed or all fail.
43
- *
44
- * @public
45
- */
46
- interface TransactionRequest {
47
- /** The statements to run, in order. */
48
- statements: TransactionStatement[];
49
- /** Acknowledgements the transaction waits for. */
50
- writeConcern?: WriteConcern;
51
- }
52
- /** The whole batch commits atomically in one server-side transaction with one fsync.
53
- * @public
54
- */
55
- interface BatchRequest {
56
- /** The statement to run for each parameter set. */
57
- sql: string;
58
- /** One parameter set per run. */
59
- paramsBatch: (Record<string, unknown> | unknown[])[];
60
- /** Acknowledgements the batch waits for. */
61
- writeConcern?: WriteConcern;
62
- }
63
- /**
64
- * What a read route answers with.
65
- *
66
- * @public
67
- */
68
- interface QueryResponse {
69
- /** The rows the statement produced, with blobs and large integers in their tagged wire form. */
70
- rows: Record<string, unknown>[];
71
- }
72
- /**
73
- * What a write route answers with.
74
- *
75
- * @public
76
- */
77
- interface ExecuteResponse {
78
- /** Number of rows the statement inserted, updated, or deleted. */
79
- changes: number;
80
- /** Row id SQLite assigned to the last inserted row, as a decimal string when it exceeds the safe range. */
81
- lastInsertRowId: number | string;
82
- }
83
- /**
84
- * What a transaction route answers with.
85
- *
86
- * @public
87
- */
88
- interface TransactionResponse {
89
- /** One result per statement, in the order the transaction ran them. */
90
- results: ExecuteResponse[];
91
- }
92
- /**
93
- * What a batch route answers with.
94
- *
95
- * @public
96
- */
97
- interface BatchResponse {
98
- /** One result per parameter set, in order. */
99
- results: ExecuteResponse[];
100
- }
101
- /**
102
- * Loads rows with relaxed writer durability; the configured durability is
103
- * restored before the response is sent, and a load interrupted by a crash is
104
- * recovered by re-running it.
105
- *
106
- * @public
107
- */
108
- interface LoadRequest {
109
- /** The statement to run for each parameter set. */
110
- sql: string;
111
- /** One parameter set per row. */
112
- paramsBatch: (Record<string, unknown> | unknown[])[];
113
- /** Durability in force while the load runs. Default: 'off'. */
114
- durability?: BulkLoadDurability;
115
- /** Whether this load ends with a checkpoint. Set it false on every batch but the last of a multi-batch import. */
116
- checkpoint?: boolean;
117
- }
118
- /**
119
- * How many rows a bulk load applied and how many rows changed.
120
- *
121
- * @public
122
- */
123
- type LoadResponse = BulkLoadResult;
124
- interface AckResponse {
125
- acked: boolean;
126
- seq: string;
127
- }
128
- /**
129
- * The body every failed route answers with.
130
- *
131
- * @public
132
- */
133
- interface ErrorResponse {
134
- /** Machine-readable code, human-readable message, and anything else the route attached. */
135
- error: {
136
- code: string;
137
- message: string;
138
- details?: Record<string, unknown>;
139
- };
140
- }
141
- /**
142
- * Turns a write result into its wire form, encoding a row id beyond the safe
143
- * integer range as a decimal string.
144
- *
145
- * @param result - What the write reported locally.
146
- * @returns The result as it crosses the wire.
147
- *
148
- * @public
149
- */
150
- declare function toExecuteResponse(result: ExecuteResult): ExecuteResponse;
151
-
152
- export { type AckResponse as A, type BatchResponse as B, type ExecuteResponse as E, type LoadResponse as L, type QueryResponse as Q, type TransactionResponse as T, type TransactionStatement as a, type BatchRequest as b, type ErrorResponse as c, type ExecuteRequest as d, type LoadRequest as e, type QueryRequest as f, type TransactionRequest as g, toExecuteResponse as t };