@delali/sirannon-db 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/backup-scheduler/index.d.ts +15 -1
- package/dist/backup-scheduler/index.mjs +2 -2
- package/dist/baseline-D93hcIEE.d.ts +17 -0
- package/dist/{change-tracker-DKRVUC3l.d.ts → change-tracker-DDmXB754.d.ts} +56 -8
- package/dist/{chunk-5NOIGN5Y.mjs → chunk-2QLXDHAP.mjs} +1 -1
- package/dist/{chunk-LNY2VVHE.mjs → chunk-7C36BCSN.mjs} +1 -1
- package/dist/{chunk-NVQS53NT.mjs → chunk-7FQRQH5Z.mjs} +53 -64
- package/dist/{chunk-D7LAYTKN.mjs → chunk-7R4ER4FB.mjs} +1 -1
- package/dist/{chunk-FHWTZFI4.mjs → chunk-BQFQ65OL.mjs} +1 -1
- package/dist/{chunk-O7SLN3GI.mjs → chunk-BTTFW4Z4.mjs} +1 -1
- package/dist/{chunk-H6PIVVDN.mjs → chunk-CCZK6LCB.mjs} +38 -25
- package/dist/{chunk-JZGINXTN.mjs → chunk-HCCGEIZ2.mjs} +2 -2
- package/dist/{chunk-67M7KAH6.mjs → chunk-IWGIYDMZ.mjs} +1 -1
- package/dist/{chunk-LFZ37BSX.mjs → chunk-OUSWVNWT.mjs} +1 -1
- package/dist/{chunk-HR5CWTLC.mjs → chunk-P2VJYRVY.mjs} +60 -7
- package/dist/{chunk-UC3SCMIN.mjs → chunk-PBRXXISQ.mjs} +3 -0
- package/dist/{chunk-JU64Y7HM.mjs → chunk-SBL6GN43.mjs} +1 -1
- package/dist/{chunk-EBJXPQQO.mjs → chunk-UPKKSUPA.mjs} +2 -2
- package/dist/{chunk-TJF5GZSV.mjs → chunk-VOSJBZ6Q.mjs} +1 -1
- package/dist/{chunk-PIKHN33N.mjs → chunk-VOYGMAU7.mjs} +9 -1
- package/dist/{chunk-H237TXZW.mjs → chunk-WJ67DTD6.mjs} +48 -6
- package/dist/{chunk-OQVZBEBY.mjs → chunk-XF2HH5E6.mjs} +4 -61
- package/dist/client/index.d.ts +211 -12
- package/dist/client/index.mjs +155 -67
- package/dist/client/topology.d.ts +55 -7
- package/dist/client/topology.mjs +20 -1
- package/dist/{client-base-CLWmH5Ln.d.ts → client-base-CmZO0v3m.d.ts} +133 -24
- package/dist/codegen/cli.mjs +3 -3
- package/dist/codegen/index.d.ts +92 -2
- package/dist/codegen/index.mjs +3 -3
- package/dist/core/index.d.ts +177 -15
- package/dist/core/index.mjs +2481 -2226
- package/dist/core/writer-worker.mjs +3 -3
- package/dist/database-B5Qv1-cU.d.ts +380 -0
- package/dist/driver/better-sqlite3.d.ts +18 -1
- package/dist/driver/better-sqlite3.mjs +5 -5
- package/dist/driver/bun.d.ts +28 -0
- package/dist/driver/expo.d.ts +17 -0
- package/dist/driver/node.d.ts +18 -1
- package/dist/driver/node.mjs +5 -5
- package/dist/driver/wa-sqlite.d.ts +18 -1
- package/dist/{errors-Bw5MdNCu.d.ts → errors-Dei4GdBb.d.ts} +80 -7
- package/dist/file-migrations/index.d.ts +54 -2
- package/dist/file-migrations/index.mjs +3 -3
- package/dist/{operation-registry-9DcvxcE5.d.ts → operation-registry-hlbhqu7q.d.ts} +50 -1
- package/dist/{primary-wins-DPAm2AKG.d.ts → primary-wins-B0np8JS3.d.ts} +25 -1
- package/dist/protocol-rqANt-9Q.d.ts +152 -0
- package/dist/query-types-DL3LtPvY.d.ts +95 -0
- package/dist/react/index.d.ts +58 -3
- package/dist/replication/coordinator/etcd.d.ts +63 -3
- package/dist/replication/coordinator/etcd.mjs +82 -46
- package/dist/replication/index.d.ts +329 -95
- package/dist/replication/index.mjs +256 -141
- package/dist/server/index.d.ts +230 -12
- package/dist/server/index.mjs +63 -50
- package/dist/{server-options-1JHu8pid.d.ts → server-options-Dab_Jvd_.d.ts} +96 -12
- package/dist/sirannon-CMhiJa5Y.d.ts +111 -0
- package/dist/transport/grpc.d.ts +93 -9
- package/dist/transport/grpc.mjs +63 -20
- package/dist/transport/memory.d.ts +50 -20
- package/dist/transport/memory.mjs +25 -0
- package/dist/{types-CL6piSnD.d.ts → types-BCejqzNA.d.ts} +20 -0
- package/dist/types-CMBcFPhb.d.ts +336 -0
- package/dist/types-CjhxcjhA.d.ts +123 -0
- package/dist/types-DyrCiWuc.d.ts +499 -0
- package/dist/types-rVZKnKN-.d.ts +591 -0
- package/package.json +7 -1
- package/dist/baseline-Br77Fnhb.d.ts +0 -6
- package/dist/database-BY0L5Q2n.d.ts +0 -172
- package/dist/protocol-6KrSq2Hy.d.ts +0 -66
- package/dist/sirannon-DaQSyhbJ.d.ts +0 -36
- package/dist/types-B7gmEsZW.d.ts +0 -221
- package/dist/types-BsVabqSI.d.ts +0 -139
- package/dist/types-C_D8IhpO.d.ts +0 -60
- package/dist/types-zhnRXrsb.d.ts +0 -384
|
@@ -1,27 +1,38 @@
|
|
|
1
|
-
import { B as BulkLoadDurability, a as BulkLoadResult, C as ClientOptions } from './server-options-
|
|
2
|
-
import { R as ResultOp, a as LiveQuery } from './types-
|
|
3
|
-
import { O as OperationRef, b as OperationArguments } from './operation-registry-
|
|
4
|
-
import { P as Params, R as ReadConcern, W as WriteConcern,
|
|
5
|
-
import { Q as QueryResponse, E as ExecuteResponse, a as TransactionResponse, B as BatchResponse, L as LoadResponse } from './protocol-
|
|
6
|
-
|
|
7
|
-
/** What a server announces: the capability tokens and the operation registry it serves. */
|
|
8
|
-
interface CapabilityReport {
|
|
9
|
-
capabilities: string[];
|
|
10
|
-
registryDigest: string | undefined;
|
|
11
|
-
}
|
|
1
|
+
import { B as BulkLoadDurability, a as BulkLoadResult, C as ClientOptions } from './server-options-Dab_Jvd_.js';
|
|
2
|
+
import { R as ResultOp, a as LiveQuery } from './types-BCejqzNA.js';
|
|
3
|
+
import { O as OperationRef, b as OperationArguments } from './operation-registry-hlbhqu7q.js';
|
|
4
|
+
import { P as Params, R as ReadConcern, W as WriteConcern, C as ChangeEvent, Q as QueryOptions } from './query-types-DL3LtPvY.js';
|
|
5
|
+
import { Q as QueryResponse, E as ExecuteResponse, a as TransactionResponse, B as BatchResponse, L as LoadResponse } from './protocol-rqANt-9Q.js';
|
|
12
6
|
|
|
7
|
+
/**
|
|
8
|
+
* Message a client raises when the server accepts no SQL over the network.
|
|
9
|
+
*
|
|
10
|
+
* @internal
|
|
11
|
+
*/
|
|
13
12
|
declare const SQL_REFUSED_MESSAGE = "This server does not accept SQL over the network. Call a registered operation by name, or start the server with acceptSql: true.";
|
|
13
|
+
/**
|
|
14
|
+
* Capability questions a remote database asks before it sends a statement.
|
|
15
|
+
*
|
|
16
|
+
* @public
|
|
17
|
+
*/
|
|
14
18
|
interface ServerCapabilityCheck {
|
|
19
|
+
/** Throws when the server accepts no SQL over the network, so a client refuses to send any. */
|
|
15
20
|
assertSqlAccepted(): Promise<void>;
|
|
21
|
+
/** Reads the digest of the server's operation registry, or undefined when the server announces none. */
|
|
16
22
|
registryDigest(refresh?: boolean): Promise<string | undefined>;
|
|
17
23
|
}
|
|
24
|
+
/**
|
|
25
|
+
* Reads and caches the capability report a server announces.
|
|
26
|
+
*
|
|
27
|
+
* @internal
|
|
28
|
+
*/
|
|
18
29
|
declare class ServerCapabilities implements ServerCapabilityCheck {
|
|
19
30
|
private readonly resolveUrl;
|
|
20
31
|
private readonly headers;
|
|
21
32
|
private readonly requestTimeoutMs;
|
|
22
33
|
private pending;
|
|
23
34
|
constructor(resolveUrl: () => string | Promise<string>, headers: Record<string, string> | undefined, requestTimeoutMs?: number);
|
|
24
|
-
read
|
|
35
|
+
private read;
|
|
25
36
|
registryDigest(refresh?: boolean): Promise<string | undefined>;
|
|
26
37
|
assertSqlAccepted(): Promise<void>;
|
|
27
38
|
private fetch;
|
|
@@ -43,7 +54,7 @@ interface SubscribeOptions {
|
|
|
43
54
|
epoch?: string;
|
|
44
55
|
/**
|
|
45
56
|
* Declares that this device stages pulled changes durably and
|
|
46
|
-
* acknowledges staged sequences
|
|
57
|
+
* acknowledges staged sequences so that the server may pack several events
|
|
47
58
|
* per frame and pace the delivery window continuously. Send only to a
|
|
48
59
|
* server that announces the `sync.staged-stream` capability.
|
|
49
60
|
*/
|
|
@@ -55,16 +66,33 @@ interface SubscribeOptions {
|
|
|
55
66
|
maxUnacknowledgedChanges: number | undefined;
|
|
56
67
|
}) => void;
|
|
57
68
|
}
|
|
69
|
+
/**
|
|
70
|
+
* Callbacks a transport delivers a live query's updates through.
|
|
71
|
+
*
|
|
72
|
+
* @public
|
|
73
|
+
*/
|
|
58
74
|
interface LiveHandlers<T = Record<string, unknown>> {
|
|
75
|
+
/** Receives a complete replacement result set. */
|
|
59
76
|
onRows(rows: T[]): void;
|
|
77
|
+
/** Receives the individual edits that move the result set to its new state. */
|
|
60
78
|
onOps(ops: ResultOp<T>[]): void;
|
|
79
|
+
/** Called when the server starts re-reading the query. */
|
|
61
80
|
onRevalidating(): void;
|
|
81
|
+
/** Called when the query fails. */
|
|
62
82
|
onError(error: RemoteError): void;
|
|
63
83
|
}
|
|
84
|
+
/**
|
|
85
|
+
* Reads the digest of the server's operation registry so that a client notices when
|
|
86
|
+
* the registered operations behind a live query change.
|
|
87
|
+
*
|
|
88
|
+
* @public
|
|
89
|
+
*/
|
|
64
90
|
type RegistryDigestSource = (refresh: boolean) => Promise<string | undefined>;
|
|
65
91
|
/**
|
|
66
92
|
* Transport layer for communicating with a sirannon-db server.
|
|
67
93
|
* Each transport instance is bound to a specific database.
|
|
94
|
+
*
|
|
95
|
+
* @public
|
|
68
96
|
*/
|
|
69
97
|
interface Transport {
|
|
70
98
|
/**
|
|
@@ -75,39 +103,61 @@ interface Transport {
|
|
|
75
103
|
* at another level.
|
|
76
104
|
*/
|
|
77
105
|
readonly carriesReadConcern?: boolean;
|
|
106
|
+
/** Sends a read and returns its rows. */
|
|
78
107
|
query(sql: string, params?: Params, readConcern?: ReadConcern): Promise<QueryResponse>;
|
|
108
|
+
/** Sends one write. */
|
|
79
109
|
execute(sql: string, params?: Params): Promise<ExecuteResponse>;
|
|
110
|
+
/** Sends several statements the server runs in one transaction. */
|
|
80
111
|
transaction(statements: Array<{
|
|
81
112
|
sql: string;
|
|
82
113
|
params?: Params;
|
|
83
114
|
}>): Promise<TransactionResponse>;
|
|
115
|
+
/** Sends one statement over many parameter sets, which the server runs in one transaction. */
|
|
84
116
|
batch(sql: string, paramsBatch: Params[], writeConcern?: WriteConcern): Promise<BatchResponse>;
|
|
117
|
+
/** Sends a bulk load, which the server runs at relaxed durability. */
|
|
85
118
|
load(sql: string, paramsBatch: Params[], durability?: BulkLoadDurability, checkpoint?: boolean): Promise<LoadResponse>;
|
|
119
|
+
/** Runs a registered read by name and returns its rows. */
|
|
86
120
|
queryNamed(name: string, args?: Record<string, unknown>, readConcern?: ReadConcern): Promise<QueryResponse>;
|
|
121
|
+
/** Runs a registered write by name. */
|
|
87
122
|
executeNamed(name: string, args?: Record<string, unknown>, writeConcern?: WriteConcern): Promise<TransactionResponse>;
|
|
123
|
+
/** Opens a live query on a registered read and delivers its updates to the handlers. */
|
|
88
124
|
liveSubscribe(name: string, args: Record<string, unknown> | undefined, handlers: LiveHandlers, registryDigest?: RegistryDigestSource): Promise<RemoteSubscription>;
|
|
125
|
+
/** Opens a change subscription on a watched table. */
|
|
89
126
|
subscribe(table: string, filter: Record<string, unknown> | undefined, callback: (event: ChangeEvent) => void, options?: SubscribeOptions): Promise<RemoteSubscription>;
|
|
127
|
+
/** Closes the transport and every subscription running on it. */
|
|
90
128
|
close(): void;
|
|
91
129
|
}
|
|
92
|
-
/** Handle for an active remote subscription.
|
|
130
|
+
/** Handle for an active remote subscription.
|
|
131
|
+
* @public
|
|
132
|
+
*/
|
|
93
133
|
interface RemoteSubscription {
|
|
134
|
+
/** Ends the subscription, so the callback receives no further events. */
|
|
94
135
|
unsubscribe(): void;
|
|
95
136
|
}
|
|
96
|
-
/** Builder for creating remote CDC subscriptions with optional filters.
|
|
137
|
+
/** Builder for creating remote CDC subscriptions with optional filters.
|
|
138
|
+
* @public
|
|
139
|
+
*/
|
|
97
140
|
interface RemoteSubscriptionBuilder {
|
|
141
|
+
/** Narrows the subscription to rows whose columns equal the given values. */
|
|
98
142
|
filter(conditions: Record<string, unknown>): RemoteSubscriptionBuilder;
|
|
143
|
+
/** Starts the subscription and calls back on each change. */
|
|
99
144
|
subscribe(callback: (event: ChangeEvent) => void, options?: SubscribeOptions): Promise<RemoteSubscription>;
|
|
100
145
|
}
|
|
101
146
|
/**
|
|
102
147
|
* Error originating from a remote sirannon-db server.
|
|
103
148
|
* Carries the machine-readable error code from the server's error response.
|
|
149
|
+
*
|
|
150
|
+
* @public
|
|
104
151
|
*/
|
|
105
152
|
declare class RemoteError extends Error {
|
|
153
|
+
/** Machine-readable code the server sent with the error. */
|
|
106
154
|
readonly code: string;
|
|
107
155
|
constructor(code: string, message: string);
|
|
108
156
|
}
|
|
109
157
|
|
|
110
|
-
/** Options for {@link RemoteDatabase.loadAll}.
|
|
158
|
+
/** Options for {@link RemoteDatabase.loadAll}.
|
|
159
|
+
* @public
|
|
160
|
+
*/
|
|
111
161
|
interface LoadAllOptions {
|
|
112
162
|
/**
|
|
113
163
|
* Rows per batch sent to the server. Each batch is one request, so it must
|
|
@@ -120,27 +170,81 @@ interface LoadAllOptions {
|
|
|
120
170
|
}
|
|
121
171
|
/**
|
|
122
172
|
* Proxy for a remote sirannon-db database. Mirrors the core
|
|
123
|
-
*
|
|
173
|
+
* `Database` query interface with async methods that send
|
|
124
174
|
* requests to the server via the configured transport.
|
|
175
|
+
*
|
|
176
|
+
* @public
|
|
125
177
|
*/
|
|
126
178
|
declare class RemoteDatabase {
|
|
179
|
+
/**
|
|
180
|
+
* Identifier of the database on the server.
|
|
181
|
+
*/
|
|
127
182
|
readonly id: string;
|
|
128
183
|
private readonly transport;
|
|
129
184
|
private readonly capabilities;
|
|
130
185
|
private readonly onDispose?;
|
|
131
|
-
constructor(
|
|
186
|
+
constructor(
|
|
187
|
+
/**
|
|
188
|
+
* Identifier of the database on the server.
|
|
189
|
+
*/
|
|
190
|
+
id: string, transport: Transport, capabilities: ServerCapabilityCheck, onDispose?: (() => void) | undefined);
|
|
191
|
+
/**
|
|
192
|
+
* Sends a read to the server and returns its rows.
|
|
193
|
+
*
|
|
194
|
+
* @param sql - The statement to run. The server refuses it unless it accepts SQL.
|
|
195
|
+
* @param params - Values bound to the statement, named or positional.
|
|
196
|
+
* @param options - Read concern for this statement.
|
|
197
|
+
* @returns The rows the server returned.
|
|
198
|
+
*/
|
|
132
199
|
query<T = Record<string, unknown>>(sql: string, params?: Params, options?: QueryOptions): Promise<T[]>;
|
|
200
|
+
/**
|
|
201
|
+
* Runs a registered read by name and returns its rows.
|
|
202
|
+
*
|
|
203
|
+
* @param operation - Reference to the registered read, which carries its argument and row types.
|
|
204
|
+
* @param args - Arguments the read takes.
|
|
205
|
+
* @param options - Read concern for this statement.
|
|
206
|
+
* @returns The rows the server returned.
|
|
207
|
+
*/
|
|
133
208
|
query<Args, Row>(operation: OperationRef<Args, Row>, args: Args, options?: QueryOptions): Promise<Row[]>;
|
|
134
209
|
private assertReadConcernReaches;
|
|
210
|
+
/**
|
|
211
|
+
* Sends one write to the server.
|
|
212
|
+
*
|
|
213
|
+
* @param sql - The statement to run. The server refuses it unless it accepts SQL.
|
|
214
|
+
* @param params - Values bound to the statement, named or positional.
|
|
215
|
+
* @returns How many rows changed, and the last inserted row id.
|
|
216
|
+
*/
|
|
135
217
|
execute(sql: string, params?: Params): Promise<ExecuteResponse>;
|
|
218
|
+
/**
|
|
219
|
+
* Runs a registered write by name.
|
|
220
|
+
*
|
|
221
|
+
* @param operation - Reference to the registered write, which carries its argument type.
|
|
222
|
+
* @param args - Arguments the write takes.
|
|
223
|
+
* @param writeConcern - Acknowledgements the write waits for.
|
|
224
|
+
* @returns One result per statement the operation ran.
|
|
225
|
+
*/
|
|
136
226
|
execute<Args>(operation: OperationRef<Args, unknown>, args: Args, writeConcern?: WriteConcern): Promise<ExecuteResponse[]>;
|
|
227
|
+
/**
|
|
228
|
+
* Opens a live query on a registered read, which keeps its rows current as the tables behind it change.
|
|
229
|
+
*
|
|
230
|
+
* @param name - Name of the registered read.
|
|
231
|
+
* @param args - Arguments the read takes.
|
|
232
|
+
* @returns The live query, already subscribed.
|
|
233
|
+
*/
|
|
137
234
|
live<T = Record<string, unknown>>(name: string, args?: OperationArguments): Promise<LiveQuery<T>>;
|
|
235
|
+
/**
|
|
236
|
+
* Opens a live query on a registered read, which keeps its rows current as the tables behind it change.
|
|
237
|
+
*
|
|
238
|
+
* @param operation - Reference to the registered read, which carries its argument and row types.
|
|
239
|
+
* @param args - Arguments the read takes.
|
|
240
|
+
* @returns The live query, already subscribed.
|
|
241
|
+
*/
|
|
138
242
|
live<Args, Row>(operation: OperationRef<Args, Row>, args: Args): Promise<LiveQuery<Row>>;
|
|
139
243
|
/**
|
|
140
244
|
* Execute multiple statements as a single atomic transaction.
|
|
141
245
|
* Returns an array of results, one per statement.
|
|
142
246
|
*
|
|
143
|
-
* The whole list
|
|
247
|
+
* The whole list is sent in one request and commits or rolls back as a
|
|
144
248
|
* unit, so the client is never in the loop between statements.
|
|
145
249
|
*/
|
|
146
250
|
transaction(statements: Array<{
|
|
@@ -159,10 +263,10 @@ declare class RemoteDatabase {
|
|
|
159
263
|
* for you and paying the one fsyncing WAL checkpoint once, after the final
|
|
160
264
|
* batch. The configured durability is restored after every batch, so an
|
|
161
265
|
* import that stops partway never leaves the writer at the relaxed level.
|
|
162
|
-
* Prefer this over {@link load} for anything larger than a single request:
|
|
163
|
-
* it
|
|
266
|
+
* Prefer this over {@link RemoteDatabase.load} for anything larger than a single request:
|
|
267
|
+
* it finalises the load itself, so there is no checkpoint flag to forget.
|
|
164
268
|
*
|
|
165
|
-
* Accepts a synchronous or asynchronous iterable of parameter sets
|
|
269
|
+
* Accepts a synchronous or asynchronous iterable of parameter sets so that rows
|
|
166
270
|
* can stream from a file or the network without being held in memory at
|
|
167
271
|
* once. Returns the total rows loaded and changes applied.
|
|
168
272
|
*
|
|
@@ -178,8 +282,8 @@ declare class RemoteDatabase {
|
|
|
178
282
|
/**
|
|
179
283
|
* Load one batch of rows through the same statement with writer durability
|
|
180
284
|
* relaxed for the duration, then restored before this resolves. This is the
|
|
181
|
-
* low-level primitive; prefer {@link loadAll} for a dataset that spans more
|
|
182
|
-
* than one request, since it
|
|
285
|
+
* low-level primitive; prefer {@link RemoteDatabase.loadAll} for a dataset that spans more
|
|
286
|
+
* than one request, since it finalises the load itself rather than relying on
|
|
183
287
|
* a `checkpoint` flag.
|
|
184
288
|
*
|
|
185
289
|
* Returns the total rows loaded and changes applied. When splitting a dataset
|
|
@@ -202,6 +306,11 @@ declare class RemoteDatabase {
|
|
|
202
306
|
* // Later:
|
|
203
307
|
* sub.unsubscribe()
|
|
204
308
|
* ```
|
|
309
|
+
*
|
|
310
|
+
* Begins a change subscription on a watched table.
|
|
311
|
+
*
|
|
312
|
+
* @param table - Name of the watched table.
|
|
313
|
+
* @returns A builder you narrow with a filter and then subscribe to.
|
|
205
314
|
*/
|
|
206
315
|
on(table: string): RemoteSubscriptionBuilder;
|
|
207
316
|
/**
|
package/dist/codegen/cli.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { runCodegen } from '../chunk-
|
|
2
|
-
import '../chunk-
|
|
1
|
+
import { runCodegen } from '../chunk-VOSJBZ6Q.mjs';
|
|
2
|
+
import '../chunk-SBL6GN43.mjs';
|
|
3
3
|
import '../chunk-TUD5CJ76.mjs';
|
|
4
4
|
import '../chunk-GVCNMPOS.mjs';
|
|
5
|
-
import '../chunk-
|
|
5
|
+
import '../chunk-PBRXXISQ.mjs';
|
|
6
6
|
|
|
7
7
|
// src/codegen/cli.ts
|
|
8
8
|
runCodegen(process.argv.slice(2)).catch((err) => {
|
package/dist/codegen/index.d.ts
CHANGED
|
@@ -1,30 +1,120 @@
|
|
|
1
|
-
import { a as OperationRegistry } from '../operation-registry-
|
|
2
|
-
import '../types-
|
|
1
|
+
import { a as OperationRegistry } from '../operation-registry-hlbhqu7q.js';
|
|
2
|
+
import '../query-types-DL3LtPvY.js';
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* @public
|
|
6
|
+
*
|
|
7
|
+
* Version of the manifest format the generator writes.
|
|
8
|
+
*/
|
|
4
9
|
declare const OPERATION_MANIFEST_VERSION = 1;
|
|
10
|
+
/**
|
|
11
|
+
* @public
|
|
12
|
+
*
|
|
13
|
+
* The arguments and columns of one registered operation, as code generation reads them.
|
|
14
|
+
*/
|
|
5
15
|
interface OperationShape {
|
|
16
|
+
/**
|
|
17
|
+
* Argument names the caller supplies.
|
|
18
|
+
*/
|
|
6
19
|
args: string[];
|
|
20
|
+
/**
|
|
21
|
+
* Argument names the server fills from the authenticated identity.
|
|
22
|
+
*/
|
|
7
23
|
identityArgs: string[];
|
|
24
|
+
/**
|
|
25
|
+
* Columns every row of a read carries, or null when the generator cannot tell.
|
|
26
|
+
*/
|
|
8
27
|
columns: string[] | null;
|
|
9
28
|
}
|
|
29
|
+
/**
|
|
30
|
+
* @public
|
|
31
|
+
*
|
|
32
|
+
* The reads and writes one database exposes by name.
|
|
33
|
+
*/
|
|
10
34
|
interface DatabaseManifest {
|
|
35
|
+
/**
|
|
36
|
+
* Registered reads, keyed by operation name.
|
|
37
|
+
*/
|
|
11
38
|
reads: Record<string, OperationShape>;
|
|
39
|
+
/**
|
|
40
|
+
* Registered writes, keyed by operation name.
|
|
41
|
+
*/
|
|
12
42
|
writes: Record<string, OperationShape>;
|
|
13
43
|
}
|
|
44
|
+
/**
|
|
45
|
+
* @public
|
|
46
|
+
*
|
|
47
|
+
* Every database's registered operations, in the form code generation reads.
|
|
48
|
+
*/
|
|
14
49
|
interface OperationManifest {
|
|
50
|
+
/**
|
|
51
|
+
* Version of the manifest format.
|
|
52
|
+
*/
|
|
15
53
|
version: number;
|
|
54
|
+
/**
|
|
55
|
+
* Digest of the registry, which a client compares against the server's.
|
|
56
|
+
*/
|
|
16
57
|
digest: string | undefined;
|
|
58
|
+
/**
|
|
59
|
+
* One manifest per database, keyed by database identifier.
|
|
60
|
+
*/
|
|
17
61
|
databases: Record<string, DatabaseManifest>;
|
|
18
62
|
}
|
|
63
|
+
/**
|
|
64
|
+
* @public
|
|
65
|
+
*
|
|
66
|
+
* Reads a registry and describes each operation's arguments and columns.
|
|
67
|
+
*
|
|
68
|
+
* @param registry - The registered operations to describe.
|
|
69
|
+
* @returns The manifest code generation renders types from.
|
|
70
|
+
*/
|
|
19
71
|
declare function buildOperationManifest<I>(registry: OperationRegistry<I>): OperationManifest;
|
|
72
|
+
/**
|
|
73
|
+
* @public
|
|
74
|
+
*
|
|
75
|
+
* Reads the column names a SELECT statement produces.
|
|
76
|
+
*
|
|
77
|
+
* @param sql - The statement to inspect.
|
|
78
|
+
* @returns The column names, or null when the statement's columns cannot be read from its text.
|
|
79
|
+
*/
|
|
20
80
|
declare function selectColumns(sql: string): string[] | null;
|
|
21
81
|
|
|
82
|
+
/**
|
|
83
|
+
* @public
|
|
84
|
+
*
|
|
85
|
+
* How the generated TypeScript is written.
|
|
86
|
+
*/
|
|
22
87
|
interface RenderOptions {
|
|
88
|
+
/**
|
|
89
|
+
* Package the generated file imports its types from. Default: `@delali/sirannon-db`.
|
|
90
|
+
*/
|
|
23
91
|
packageName?: string;
|
|
24
92
|
}
|
|
93
|
+
/**
|
|
94
|
+
* @public
|
|
95
|
+
*
|
|
96
|
+
* Renders typed references for every operation in a manifest.
|
|
97
|
+
*
|
|
98
|
+
* @param manifest - The operations to render.
|
|
99
|
+
* @param options - The package the generated file imports from.
|
|
100
|
+
* @returns The TypeScript source to write.
|
|
101
|
+
*/
|
|
25
102
|
declare function renderOperationTypes(manifest: OperationManifest, options?: RenderOptions): string;
|
|
26
103
|
|
|
104
|
+
/**
|
|
105
|
+
* @public
|
|
106
|
+
*
|
|
107
|
+
* Usage text the code generator prints when its arguments do not parse.
|
|
108
|
+
*/
|
|
27
109
|
declare const CODEGEN_USAGE = "sirannon-codegen --registry <module> --out <file> [--manifest <file>] [--export <name>] [--package <name>]\n\nReads the operation registry a server is built from and writes the typed\nreferences a client calls it through. The registry module is imported, so run\nit under a loader that reads your source format when it is not JavaScript.";
|
|
110
|
+
/**
|
|
111
|
+
* @public
|
|
112
|
+
*
|
|
113
|
+
* Runs the code generator: it loads a registry module, builds the manifest, and writes the typed references.
|
|
114
|
+
*
|
|
115
|
+
* @param argv - Command-line arguments, without the executable and script names.
|
|
116
|
+
* @throws When an argument is missing or the registry module cannot be loaded.
|
|
117
|
+
*/
|
|
28
118
|
declare function runCodegen(argv: readonly string[]): Promise<void>;
|
|
29
119
|
|
|
30
120
|
export { CODEGEN_USAGE, type DatabaseManifest, OPERATION_MANIFEST_VERSION, type OperationManifest, type OperationShape, type RenderOptions, buildOperationManifest, renderOperationTypes, runCodegen, selectColumns };
|
package/dist/codegen/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { CODEGEN_USAGE, OPERATION_MANIFEST_VERSION, buildOperationManifest, renderOperationTypes, runCodegen, selectColumns } from '../chunk-
|
|
2
|
-
import '../chunk-
|
|
1
|
+
export { CODEGEN_USAGE, OPERATION_MANIFEST_VERSION, buildOperationManifest, renderOperationTypes, runCodegen, selectColumns } from '../chunk-VOSJBZ6Q.mjs';
|
|
2
|
+
import '../chunk-SBL6GN43.mjs';
|
|
3
3
|
import '../chunk-TUD5CJ76.mjs';
|
|
4
4
|
import '../chunk-GVCNMPOS.mjs';
|
|
5
|
-
import '../chunk-
|
|
5
|
+
import '../chunk-PBRXXISQ.mjs';
|