@restatedev/sessions 0.11.1 → 0.12.0
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/README.md +330 -178
- package/dist/addon.d.ts +1 -0
- package/dist/addon.d.ts.map +1 -1
- package/dist/addon.js.map +1 -1
- package/dist/calls.d.ts +28 -28
- package/dist/calls.d.ts.map +1 -1
- package/dist/calls.js +25 -25
- package/dist/calls.js.map +1 -1
- package/dist/database.d.ts +90 -166
- package/dist/database.d.ts.map +1 -1
- package/dist/database.js +137 -249
- package/dist/database.js.map +1 -1
- package/dist/driver.d.ts +129 -126
- package/dist/driver.d.ts.map +1 -1
- package/dist/driver.js +337 -276
- package/dist/driver.js.map +1 -1
- package/dist/endpoint.d.ts +47 -5
- package/dist/endpoint.d.ts.map +1 -1
- package/dist/endpoint.js +175 -60
- package/dist/endpoint.js.map +1 -1
- package/dist/handler.d.ts +20 -17
- package/dist/handler.d.ts.map +1 -1
- package/dist/handler.js +161 -127
- package/dist/handler.js.map +1 -1
- package/dist/host.d.ts +29 -0
- package/dist/host.d.ts.map +1 -0
- package/dist/host.js +2 -0
- package/dist/host.js.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -26
- package/dist/index.js.map +1 -1
- package/dist/internal.d.ts +11 -11
- package/dist/internal.d.ts.map +1 -1
- package/dist/internal.js +20 -16
- package/dist/internal.js.map +1 -1
- package/dist/link.d.ts +1 -2
- package/dist/link.d.ts.map +1 -1
- package/dist/link.js +4 -5
- package/dist/link.js.map +1 -1
- package/dist/log.d.ts +14 -0
- package/dist/log.d.ts.map +1 -0
- package/dist/log.js +21 -0
- package/dist/log.js.map +1 -0
- package/dist/object.d.ts +217 -142
- package/dist/object.d.ts.map +1 -1
- package/dist/object.js +195 -241
- package/dist/object.js.map +1 -1
- package/dist/platform.d.ts +0 -1
- package/dist/platform.d.ts.map +1 -1
- package/dist/platform.js +4 -6
- package/dist/platform.js.map +1 -1
- package/dist/schema.d.ts +14 -22
- package/dist/schema.d.ts.map +1 -1
- package/dist/schema.js +31 -69
- package/dist/schema.js.map +1 -1
- package/dist/serve.d.ts +11 -17
- package/dist/serve.d.ts.map +1 -1
- package/dist/serve.js +21 -39
- package/dist/serve.js.map +1 -1
- package/dist/session.d.ts +58 -236
- package/dist/session.d.ts.map +1 -1
- package/dist/session.js +206 -513
- package/dist/session.js.map +1 -1
- package/dist/stop.d.ts +59 -0
- package/dist/stop.d.ts.map +1 -0
- package/dist/stop.js +220 -0
- package/dist/stop.js.map +1 -0
- package/dist/vm.d.ts +108 -29
- package/dist/vm.d.ts.map +1 -1
- package/dist/vm.js +43 -10
- package/dist/vm.js.map +1 -1
- package/package.json +4 -4
- package/src/addon.ts +1 -0
- package/src/calls.ts +51 -47
- package/src/database.ts +195 -339
- package/src/driver.ts +379 -315
- package/src/endpoint.ts +217 -62
- package/src/handler.ts +183 -164
- package/src/host.ts +28 -0
- package/src/index.ts +6 -26
- package/src/internal.ts +28 -39
- package/src/link.ts +4 -5
- package/src/log.ts +42 -0
- package/src/object.ts +379 -335
- package/src/platform.ts +4 -6
- package/src/schema.ts +37 -103
- package/src/serve.ts +20 -41
- package/src/session.ts +236 -613
- package/src/stop.ts +225 -0
- package/src/vm.ts +151 -55
- package/dist/scope.d.ts +0 -38
- package/dist/scope.d.ts.map +0 -1
- package/dist/scope.js +0 -55
- package/dist/scope.js.map +0 -1
- package/src/scope.ts +0 -78
package/dist/database.d.ts
CHANGED
|
@@ -1,284 +1,208 @@
|
|
|
1
1
|
import { Buffer } from 'node:buffer';
|
|
2
|
-
import { type Vm } from './vm.ts';
|
|
2
|
+
import { type Vm, type VmCommit } from './vm.ts';
|
|
3
3
|
/** An SQL value. Integers come back as numbers, or as bigints beyond 2^53. */
|
|
4
4
|
export type SqlValue = null | number | bigint | string | Uint8Array;
|
|
5
5
|
/** An SQL parameter: an `SqlValue`, or a boolean, stored as 0 or 1. */
|
|
6
6
|
export type SqlParam = SqlValue | boolean;
|
|
7
|
-
|
|
8
|
-
export interface SqlQueryResult {
|
|
7
|
+
interface SqlQueryResult {
|
|
9
8
|
columns: string[];
|
|
10
9
|
rows: SqlValue[][];
|
|
11
10
|
}
|
|
12
11
|
/**
|
|
13
|
-
* A failure a retry would repeat: SQL
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
* refused, which may have ended it (a `COMMIT` in a transaction's body, a
|
|
17
|
-
* transaction left open). A storage error, which ends the session, rejects
|
|
18
|
-
* as it is.
|
|
12
|
+
* A failure a retry would repeat: rejected SQL (undoes only that statement),
|
|
13
|
+
* a parameter that cannot bind, or a refused call, which may end the session
|
|
14
|
+
* (a `COMMIT` in a transaction body). A storage error rejects unchanged.
|
|
19
15
|
*/
|
|
20
16
|
export declare class SqlError extends Error {
|
|
21
17
|
name: string;
|
|
22
18
|
}
|
|
23
|
-
/** A row as an object, by column name. */
|
|
24
19
|
export type Row = Record<string, SqlValue>;
|
|
25
|
-
/** Reads of a database, or of one
|
|
20
|
+
/** Reads of a database, or of one of its transactions. */
|
|
26
21
|
export interface DatabaseReader {
|
|
27
22
|
/**
|
|
28
|
-
* The rows of one statement, each an object by column name
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
23
|
+
* The rows of one statement, each an object by column name. `T` declares
|
|
24
|
+
* the row shape, unchecked: integers past 2^53 come back as bigints, and
|
|
25
|
+
* booleans as 0 or 1. Columns are named as SQL names them (an expression
|
|
26
|
+
* needs `AS`). Two columns with the same name are an SQL error (from
|
|
27
|
+
* `ctx.db`, a `TerminalError`): alias them, or use {@link values}.
|
|
33
28
|
*/
|
|
34
29
|
query<T = Row>(sql: string, params?: SqlParam[]): Promise<T[]>;
|
|
35
30
|
/** The first row of {@link query}, or `undefined` when there is none. */
|
|
36
31
|
get<T = Row>(sql: string, params?: SqlParam[]): Promise<T | undefined>;
|
|
37
|
-
/** The rows
|
|
32
|
+
/** The rows as arrays, in column order: for adapters, and for columns that share a name. */
|
|
38
33
|
values(sql: string, params?: SqlParam[]): Promise<SqlValue[][]>;
|
|
39
34
|
}
|
|
40
|
-
/** SQL
|
|
35
|
+
/** SQL on a database, or on one of its transactions. */
|
|
41
36
|
export interface DatabaseWriter extends DatabaseReader {
|
|
42
37
|
/** Run SQL (one or more statements), discarding rows; parameters only with a single statement. */
|
|
43
38
|
execute(sql: string, params?: SqlParam[]): Promise<void>;
|
|
44
39
|
}
|
|
45
|
-
/**
|
|
46
|
-
* {@link DatabaseWriter} over `run`, which runs one call's SQL and returns
|
|
47
|
-
* its rows with their columns, failing as `failure` makes its errors (as
|
|
48
|
-
* `run` makes the engine's). `run` answers with the value itself when the
|
|
49
|
-
* call was ready at once, which only this package sees: each call returns a
|
|
50
|
-
* promise.
|
|
51
|
-
*/
|
|
40
|
+
/** A {@link DatabaseWriter} over `run`, which may answer synchronously; each method returns a promise. */
|
|
52
41
|
export declare function sqlOver(run: (sql: string, params?: SqlParam[]) => Answer<SqlQueryResult>, failure?: (error: unknown) => unknown): DatabaseWriter;
|
|
53
42
|
/**
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
* since the last sync and loses the rest. `get` returns the stored value, or
|
|
58
|
-
* this request's own latest write; `undefined` or `null` when absent.
|
|
43
|
+
* The object state as a key/value store. `sync` resolves once every earlier
|
|
44
|
+
* write is stored. Writes are stored in order, so a crash keeps a prefix of
|
|
45
|
+
* them. `get` sees this request's own writes; absent is `undefined` or `null`.
|
|
59
46
|
*/
|
|
60
47
|
export interface Store {
|
|
61
48
|
get(key: string): Promise<Uint8Array | null | undefined>;
|
|
62
49
|
set(key: string, value: Uint8Array): void;
|
|
63
50
|
clear(key: string): void;
|
|
64
51
|
sync(): Promise<void>;
|
|
65
|
-
/**
|
|
66
|
-
* Every key, as `ctx.stateKeys()`: then a commit that checkpoints deletes
|
|
67
|
-
* the packs no checkpoint needs any more. A store without it keeps them.
|
|
68
|
-
*/
|
|
52
|
+
/** Every key. With it, a checkpoint deletes packs no checkpoint needs; without it they stay. */
|
|
69
53
|
keys?(): Promise<string[]>;
|
|
70
54
|
}
|
|
71
|
-
/**
|
|
72
|
-
|
|
73
|
-
* runs between `begin` and `commit` (or `rollback`). A call answers at once
|
|
74
|
-
* with its value (or throws) when it needs nothing from the store, such as
|
|
75
|
-
* SQL on cached pages, and with a promise when it waits for the store.
|
|
76
|
-
*/
|
|
77
|
-
interface NativeSession {
|
|
55
|
+
/** An addon session. A call that needs nothing from the store returns its value or throws. */
|
|
56
|
+
export interface NativeSession {
|
|
78
57
|
queryColumns(sql: string, params?: SqlParam[]): Answer<SqlQueryResult>;
|
|
79
|
-
/** `queryColumns`, after `before`'s statements in the same call; absent in an addon without it. */
|
|
80
|
-
queryColumnsAfter?(before: string[], sql: string, params?: SqlParam[]): Answer<SqlQueryResult>;
|
|
81
58
|
begin(): Answer<void>;
|
|
82
|
-
/**
|
|
83
|
-
|
|
59
|
+
/**
|
|
60
|
+
* On the VM, `withCommit` is what commits with the transaction: its sends,
|
|
61
|
+
* inside the commit's atomic group (see {@link ConnectionTransaction.commitWith}).
|
|
62
|
+
*/
|
|
63
|
+
commit(records: Record<string, Buffer>, withCommit?: VmCommit): Answer<void>;
|
|
84
64
|
rollback(): Answer<void>;
|
|
85
65
|
record(name: string): Answer<Buffer>;
|
|
86
66
|
isUsable(): boolean;
|
|
87
67
|
save(): Answer<void>;
|
|
88
68
|
close(): Promise<void>;
|
|
89
69
|
}
|
|
90
|
-
/** A value, or a promise of it: `await` takes either. */
|
|
91
70
|
type Answer<T> = T | Promise<T>;
|
|
92
|
-
/**
|
|
93
|
-
* Run `fn`, keeping the attempt alive meanwhile: the attempt's `working`
|
|
94
|
-
* (see `driver.ts`). The database's calls run in it, being local work that
|
|
95
|
-
* never waits on Restate for long.
|
|
96
|
-
*/
|
|
71
|
+
/** `ctx.working` (see stop.ts). */
|
|
97
72
|
export type Working = <T>(fn: () => T | Promise<T>) => Promise<T>;
|
|
98
|
-
/**
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
*/
|
|
73
|
+
/** `ctx.stoppable` (see stop.ts). */
|
|
74
|
+
export type Stoppable = <T>(fn: (signal: AbortSignal) => T | Promise<T>) => Promise<T>;
|
|
75
|
+
/** `ctx.suspendable` (see stop.ts). */
|
|
76
|
+
export type Suspendable = <T>(fn: () => T | Promise<T>) => Promise<T>;
|
|
77
|
+
/** Open the database of `namespace` over `store`. A `reader` (a view) reads the state as of the open. */
|
|
103
78
|
export declare function open(namespace: string, store: Store, { reader }?: {
|
|
104
79
|
reader?: boolean | undefined;
|
|
105
80
|
}): Promise<Connection>;
|
|
106
81
|
/**
|
|
107
|
-
* Open the database of `namespace` over the attempt
|
|
108
|
-
*
|
|
109
|
-
*
|
|
110
|
-
*
|
|
111
|
-
*
|
|
112
|
-
* are never reached. `name` names a database beside the object's own.
|
|
82
|
+
* Open the database of `namespace` over the attempt VM. The addon reads and
|
|
83
|
+
* writes the state as the VM's own actions and never calls a store; a commit
|
|
84
|
+
* is one atomic group, with what the transaction gave
|
|
85
|
+
* {@link ConnectionTransaction.commitWith}. `name` names a database beside the
|
|
86
|
+
* object database.
|
|
113
87
|
*/
|
|
114
|
-
export declare function openOnVm(namespace: string,
|
|
88
|
+
export declare function openOnVm(namespace: string, vm: Vm, { name, reader, keepAlive }?: {
|
|
115
89
|
name?: string;
|
|
116
90
|
reader?: boolean;
|
|
117
|
-
|
|
91
|
+
keepAlive?: Working;
|
|
118
92
|
}): Promise<Connection>;
|
|
119
93
|
/**
|
|
120
|
-
* The store as the addon calls it.
|
|
121
|
-
*
|
|
122
|
-
*
|
|
123
|
-
* CancelledError, say). And a commit's sync first runs what its transaction
|
|
124
|
-
* gave {@link ConnectionTransaction.withCommit}: after the commit's writes,
|
|
125
|
-
* before anything is awaited.
|
|
94
|
+
* The store as the addon calls it. A store error crosses the addon as text and
|
|
95
|
+
* ends the session, so the first one is kept for later calls to fail with. A
|
|
96
|
+
* commit sync first runs `withCommit`. On the VM the addon calls none of it.
|
|
126
97
|
*/
|
|
127
98
|
declare class Boundary implements Store {
|
|
128
|
-
/** The first error of the store's. */
|
|
129
99
|
failed: {
|
|
130
100
|
error: unknown;
|
|
131
101
|
} | undefined;
|
|
132
|
-
/** What the next sync runs first: the committing transaction
|
|
102
|
+
/** What the next sync runs first: the `withCommit` work of the committing transaction. */
|
|
133
103
|
withSync: (() => void) | undefined;
|
|
134
104
|
readonly keys?: () => Promise<string[]>;
|
|
135
105
|
private readonly store;
|
|
136
106
|
private readonly working;
|
|
137
|
-
constructor(store: Store, working?: Working);
|
|
107
|
+
constructor(store: Store | undefined, working?: Working);
|
|
138
108
|
get(key: string): Promise<Uint8Array<ArrayBufferLike> | null | undefined>;
|
|
139
109
|
set(key: string, value: Uint8Array): void;
|
|
140
110
|
clear(key: string): void;
|
|
141
111
|
sync(): Promise<void>;
|
|
142
|
-
/**
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
* scope, which opens as the call returns it.
|
|
146
|
-
*/
|
|
112
|
+
/** On the VM, reaching here is a bug in the addon. */
|
|
113
|
+
private stored;
|
|
114
|
+
/** A synchronous answer needs no keep-alive; a promise runs in `Stop.keepAlive`. */
|
|
147
115
|
aliveNow<T>(call: () => Answer<T>): Answer<T>;
|
|
148
|
-
/** `call`, in the attempt
|
|
116
|
+
/** `call`, in the attempt keep-alive if there is one (on the VM). */
|
|
149
117
|
alive<T>(call: () => T | Promise<T>): Promise<T>;
|
|
150
|
-
/** `request
|
|
118
|
+
/** Run `request`, keeping the first error, whether thrown or rejected. */
|
|
151
119
|
private kept;
|
|
152
120
|
}
|
|
153
|
-
/**
|
|
154
|
-
* SQL on a session of the addon: {@link DatabaseWriter}'s `query` and `execute`
|
|
155
|
-
* by way of its `queryColumnsNow`.
|
|
156
|
-
*/
|
|
121
|
+
/** {@link DatabaseWriter} on an addon session, built on `queryColumnsNow`. */
|
|
157
122
|
declare abstract class Sql implements DatabaseWriter {
|
|
158
123
|
protected readonly native: NativeSession;
|
|
159
124
|
protected readonly boundary: Boundary;
|
|
160
125
|
private readonly over;
|
|
161
126
|
constructor(native: NativeSession, boundary: Boundary);
|
|
162
|
-
/**
|
|
163
|
-
* The rows of one statement with their column names: the value itself if
|
|
164
|
-
* the addon answered at once (only the package's own code takes it so), else
|
|
165
|
-
* a promise of it. A failure is a rejection.
|
|
166
|
-
*/
|
|
127
|
+
/** The rows of one statement with their columns; synchronous if the addon answered so. A failure rejects. */
|
|
167
128
|
abstract queryColumnsNow(sql: string, params?: SqlParam[]): Answer<SqlQueryResult>;
|
|
168
|
-
queryColumns(sql: string, params?: SqlParam[]): Promise<SqlQueryResult>;
|
|
169
129
|
query<T = Row>(sql: string, params?: SqlParam[]): Promise<T[]>;
|
|
170
130
|
get<T = Row>(sql: string, params?: SqlParam[]): Promise<T | undefined>;
|
|
171
131
|
values(sql: string, params?: SqlParam[]): Promise<SqlValue[][]>;
|
|
172
132
|
execute(sql: string, params?: SqlParam[]): Promise<void>;
|
|
173
|
-
/** {@link request}
|
|
133
|
+
/** {@link request} that returns a ready value synchronously, with no keep-alive. */
|
|
174
134
|
protected requestNow<T>(call: () => Answer<T>): Answer<T>;
|
|
175
|
-
/**
|
|
176
|
-
* `call`'s result, or its {@link failure}: `call` makes the request, as the
|
|
177
|
-
* addon throws as it is called (arguments it cannot convert, and the error
|
|
178
|
-
* of a call that answers at once).
|
|
179
|
-
*/
|
|
135
|
+
/** The result of `call`, or its {@link failure}, whether the addon throws or rejects. */
|
|
180
136
|
protected request<T>(call: () => Answer<T>): Promise<T>;
|
|
181
137
|
/**
|
|
182
|
-
*
|
|
183
|
-
*
|
|
138
|
+
* An {@link SqlError} if a retry would repeat `error`; the store error if
|
|
139
|
+
* that ended the session. `sends`: `error` failed the commit of a
|
|
140
|
+
* transaction that sends on the VM, the one call whose failure can be the
|
|
141
|
+
* VM's refusal of a send, or the attempt's end with the session usable.
|
|
184
142
|
*/
|
|
185
|
-
protected failure(error: unknown
|
|
143
|
+
protected failure(error: unknown, { sends }?: {
|
|
144
|
+
sends?: boolean;
|
|
145
|
+
}): unknown;
|
|
186
146
|
}
|
|
187
|
-
/**
|
|
188
|
-
* A session of a database: calls run one at a time, in call order, and a
|
|
189
|
-
* transaction holds the session until it commits or rolls back. Calls made
|
|
190
|
-
* meanwhile wait, but a call from inside the transaction's body is refused,
|
|
191
|
-
* as it would wait for that body: the body uses its `tx`.
|
|
192
|
-
*/
|
|
147
|
+
/** A session of a database. Call ordering and the transaction guard: see the header. */
|
|
193
148
|
export declare class Connection extends Sql {
|
|
194
|
-
/**
|
|
149
|
+
/**
|
|
150
|
+
* The transaction guard: the open transaction, in the async context of its
|
|
151
|
+
* body. A call from a continuation created before the transaction, which
|
|
152
|
+
* the body then awaits, is not refused and deadlocks.
|
|
153
|
+
*/
|
|
195
154
|
private readonly running;
|
|
196
|
-
/** Settles once the last call queued so far has: the next call runs after it. */
|
|
197
155
|
private queue;
|
|
198
|
-
/**
|
|
199
|
-
private tail;
|
|
200
|
-
/** Calls queued and not settled: with none, a call that is ready runs at once, in order. */
|
|
156
|
+
/** Calls queued and not settled. With none, a call can take the fast path. */
|
|
201
157
|
private inflight;
|
|
202
158
|
private readonly release;
|
|
203
159
|
queryColumnsNow(sql: string, params?: SqlParam[]): Answer<SqlQueryResult>;
|
|
204
160
|
/**
|
|
205
|
-
* Run `body` as one SQL transaction:
|
|
206
|
-
*
|
|
207
|
-
*
|
|
208
|
-
* the transaction (`COMMIT`, `ROLLBACK`) ends the session. A failing
|
|
209
|
-
* COMMIT rolls back.
|
|
161
|
+
* Run `body` as one SQL transaction: once its calls settle, commit with its
|
|
162
|
+
* records, or roll back if it rejects. A `COMMIT` or `ROLLBACK` statement
|
|
163
|
+
* in it ends the session.
|
|
210
164
|
*/
|
|
211
165
|
transaction<T>(body: (tx: ConnectionTransaction) => Promise<T>): Promise<T>;
|
|
212
166
|
private run;
|
|
213
|
-
/**
|
|
214
|
-
* The record `name`, as the last commit that set it left it (see
|
|
215
|
-
* {@link ConnectionTransaction.setRecord}); empty if none did.
|
|
216
|
-
*/
|
|
167
|
+
/** The record `name` as last committed (see {@link ConnectionTransaction.setRecord}); empty if never set. */
|
|
217
168
|
record(name: string): Promise<Uint8Array>;
|
|
218
|
-
/**
|
|
169
|
+
/** An SQL error leaves the session usable; a storage error ends it. */
|
|
219
170
|
isUsable(): boolean;
|
|
220
|
-
/**
|
|
221
|
-
* End the session after the calls before it, leaving its engine to the
|
|
222
|
-
* next one. It rejects if they left a transaction open, or a failure ended
|
|
223
|
-
* the session.
|
|
224
|
-
*/
|
|
171
|
+
/** End the session after earlier calls. Rejects if a transaction is left open or a failure ended it. */
|
|
225
172
|
save(): Promise<void>;
|
|
226
|
-
/** End the session now, whatever its state
|
|
173
|
+
/** End the session now, whatever its state. Queued calls reject. */
|
|
227
174
|
close(): Promise<void>;
|
|
228
|
-
/**
|
|
175
|
+
/** Queue `call` after earlier calls. Refused from the body of an open transaction (the guard). */
|
|
229
176
|
private serial;
|
|
230
|
-
/** Roll back,
|
|
177
|
+
/** Roll back, ignoring errors: the caller rethrows its own error, which explains the failure. */
|
|
231
178
|
private rollback;
|
|
232
179
|
}
|
|
233
|
-
/** SQL in one transaction
|
|
180
|
+
/** SQL in one transaction while its body runs, and the records it commits with. */
|
|
234
181
|
export interface ConnectionTransaction extends DatabaseWriter {
|
|
235
|
-
/** The rows of one statement
|
|
236
|
-
queryColumns(sql: string, params?: SqlParam[]): Promise<SqlQueryResult>;
|
|
237
|
-
/** {@link queryColumns} for the package's own code: the value itself if the addon answered at once. */
|
|
182
|
+
/** The rows of one statement with their columns, synchronous if the addon answered so (package code only). */
|
|
238
183
|
queryColumnsNow(sql: string, params?: SqlParam[]): Answer<SqlQueryResult>;
|
|
239
184
|
/**
|
|
240
|
-
* Set the record `name` to `value`
|
|
241
|
-
*
|
|
242
|
-
*
|
|
243
|
-
*
|
|
244
|
-
* name is at most 255 bytes, and not `db`; a value at most 16 MiB.
|
|
185
|
+
* Set the record `name` to `value` in this commit: a value kept outside the
|
|
186
|
+
* tables, stored exactly when the transaction is, even if no row changes.
|
|
187
|
+
* It stays until a later transaction sets it. An empty value reads as never
|
|
188
|
+
* set. A name is at most 255 bytes and not `db`; a value at most 16 MiB.
|
|
245
189
|
*/
|
|
246
190
|
setRecord(name: string, value: Uint8Array): void;
|
|
247
|
-
/** The record `name` as this transaction would commit it
|
|
191
|
+
/** The record `name` as this transaction would commit it. */
|
|
248
192
|
record(name: string): Promise<Uint8Array>;
|
|
249
193
|
/**
|
|
250
|
-
* Run `run`
|
|
251
|
-
*
|
|
252
|
-
*
|
|
253
|
-
* sends, which it stores in order with the writes). Never if the
|
|
254
|
-
* transaction rolls back.
|
|
194
|
+
* Run `run` right after the commit writes, before waiting for them: for a
|
|
195
|
+
* store in JavaScript (the sends of a test's transaction, session.ts).
|
|
196
|
+
* Never if the transaction rolls back. On the VM, {@link commitWith}.
|
|
255
197
|
*/
|
|
256
198
|
withCommit(run: () => void): void;
|
|
257
199
|
/**
|
|
258
|
-
*
|
|
259
|
-
*
|
|
260
|
-
*
|
|
261
|
-
*
|
|
262
|
-
* the crossing of a call. Returns false, and queues nothing, where the
|
|
263
|
-
* addon cannot (an addon without `queryColumnsAfter`): run the statement
|
|
264
|
-
* with {@link queryColumns}. One still queued as the body settles runs
|
|
265
|
-
* then, before the commit, and its failure fails the transaction.
|
|
266
|
-
*/
|
|
267
|
-
defer(sql: string): boolean;
|
|
268
|
-
/**
|
|
269
|
-
* Take back the last `sql` that {@link defer} queued if no call has taken
|
|
270
|
-
* it yet: it never runs. Whether it did.
|
|
271
|
-
*/
|
|
272
|
-
undefer(sql: string): boolean;
|
|
273
|
-
/**
|
|
274
|
-
* Settles, and never rejects, once another call to the connection has
|
|
275
|
-
* queued behind this transaction: it is waiting for the body to settle.
|
|
276
|
-
* A body that holds the transaction open for more work can return on it,
|
|
277
|
-
* so that the call costs one commit rather than a stall. A call made
|
|
278
|
-
* before the transaction began does not settle it, and neither does one
|
|
279
|
-
* made from the body, which is refused.
|
|
200
|
+
* On the VM: commit `commit`'s sends with the transaction, inside its
|
|
201
|
+
* commit's atomic group, which is inside `commit.parentSpan`. A transaction
|
|
202
|
+
* that writes nothing makes them in a group of its own. A later call
|
|
203
|
+
* replaces it.
|
|
280
204
|
*/
|
|
281
|
-
|
|
205
|
+
commitWith(commit: VmCommit): void;
|
|
282
206
|
}
|
|
283
207
|
export {};
|
|
284
208
|
//# sourceMappingURL=database.d.ts.map
|
package/dist/database.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"database.d.ts","sourceRoot":"","sources":["../src/database.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"database.d.ts","sourceRoot":"","sources":["../src/database.ts"],"names":[],"mappings":"AAqBA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,OAAO,EAAiC,KAAK,EAAE,EAAE,KAAK,QAAQ,EAAE,MAAM,SAAS,CAAC;AAGhF,8EAA8E;AAC9E,MAAM,MAAM,QAAQ,GAAG,IAAI,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,UAAU,CAAC;AAEpE,uEAAuE;AACvE,MAAM,MAAM,QAAQ,GAAG,QAAQ,GAAG,OAAO,CAAC;AAE1C,UAAU,cAAc;IACtB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,IAAI,EAAE,QAAQ,EAAE,EAAE,CAAC;CACpB;AAED;;;;GAIG;AACH,qBAAa,QAAS,SAAQ,KAAK;IACxB,IAAI,SAAc;CAC5B;AAED,MAAM,MAAM,GAAG,GAAG,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;AAE3C,0DAA0D;AAC1D,MAAM,WAAW,cAAc;IAC7B;;;;;;OAMG;IACH,KAAK,CAAC,CAAC,GAAG,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC,CAAC,EAAE,C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