@encore.dev/sdk 2.0.0-beta.15 → 2.0.0-beta.16
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 +111 -101
- package/app_meta.ts +56 -54
- package/config/config.ts +60 -57
- package/config/secrets.ts +45 -52
- package/config/value.ts +23 -26
- package/cron/mod.ts +28 -29
- package/dist/app_meta.d.ts +52 -50
- package/dist/app_meta.d.ts.map +1 -1
- package/dist/app_meta.js +2 -2
- package/dist/app_meta.js.map +1 -1
- package/dist/config/config.d.ts +58 -55
- package/dist/config/config.d.ts.map +1 -1
- package/dist/config/config.js +8 -9
- package/dist/config/config.js.map +1 -1
- package/dist/config/secrets.d.ts +45 -52
- package/dist/config/secrets.d.ts.map +1 -1
- package/dist/config/secrets.js +8 -9
- package/dist/config/secrets.js.map +1 -1
- package/dist/config/value.d.ts +20 -23
- package/dist/config/value.d.ts.map +1 -1
- package/dist/config/value.js +20 -23
- package/dist/config/value.js.map +1 -1
- package/dist/cron/mod.d.ts +26 -27
- package/dist/cron/mod.d.ts.map +1 -1
- package/dist/cron/mod.js +13 -14
- package/dist/cron/mod.js.map +1 -1
- package/dist/frontends/mod.d.ts +20 -19
- package/dist/frontends/mod.d.ts.map +1 -1
- package/dist/frontends/mod.js +20 -19
- package/dist/frontends/mod.js.map +1 -1
- package/dist/gateway/errors.d.ts +28 -30
- package/dist/gateway/errors.d.ts.map +1 -1
- package/dist/gateway/errors.js +29 -31
- package/dist/gateway/errors.js.map +1 -1
- package/dist/gateway/match.d.ts +54 -54
- package/dist/gateway/match.d.ts.map +1 -1
- package/dist/gateway/match.js +56 -56
- package/dist/gateway/match.js.map +1 -1
- package/dist/gateway/middleware.d.ts +62 -64
- package/dist/gateway/middleware.d.ts.map +1 -1
- package/dist/gateway/middleware.js +1 -1
- package/dist/gateway/middleware.js.map +1 -1
- package/dist/gateway/mod.d.ts +64 -67
- package/dist/gateway/mod.d.ts.map +1 -1
- package/dist/gateway/mod.js +72 -76
- package/dist/gateway/mod.js.map +1 -1
- package/dist/gateway/request.d.ts +138 -134
- package/dist/gateway/request.d.ts.map +1 -1
- package/dist/gateway/request.js +117 -108
- package/dist/gateway/request.js.map +1 -1
- package/dist/gateway/serve.d.ts +29 -34
- package/dist/gateway/serve.d.ts.map +1 -1
- package/dist/gateway/serve.js +51 -56
- package/dist/gateway/serve.js.map +1 -1
- package/dist/gateways/mod.d.ts +23 -21
- package/dist/gateways/mod.d.ts.map +1 -1
- package/dist/gateways/mod.js +25 -23
- package/dist/gateways/mod.js.map +1 -1
- package/dist/internal/runtime/napi/napi.cjs +1 -1
- package/dist/internal/runtime/napi/napi.d.cts +10 -3
- package/dist/internal/runtime/shutdown.d.ts +75 -57
- package/dist/internal/runtime/shutdown.d.ts.map +1 -1
- package/dist/internal/runtime/shutdown.js +88 -84
- package/dist/internal/runtime/shutdown.js.map +1 -1
- package/dist/log/logger.d.ts +43 -37
- package/dist/log/logger.d.ts.map +1 -1
- package/dist/log/logger.js +26 -25
- package/dist/log/logger.js.map +1 -1
- package/dist/metrics/mod.d.ts +133 -114
- package/dist/metrics/mod.d.ts.map +1 -1
- package/dist/metrics/mod.js +109 -101
- package/dist/metrics/mod.js.map +1 -1
- package/dist/otel.d.ts +6 -3
- package/dist/otel.d.ts.map +1 -1
- package/dist/otel.js +6 -3
- package/dist/otel.js.map +1 -1
- package/dist/pubsub/subscription.d.ts +88 -116
- package/dist/pubsub/subscription.d.ts.map +1 -1
- package/dist/pubsub/subscription.js +14 -17
- package/dist/pubsub/subscription.js.map +1 -1
- package/dist/pubsub/topic.d.ts +86 -113
- package/dist/pubsub/topic.d.ts.map +1 -1
- package/dist/pubsub/topic.js +68 -82
- package/dist/pubsub/topic.js.map +1 -1
- package/dist/reqctx/mod.d.ts +83 -86
- package/dist/reqctx/mod.d.ts.map +1 -1
- package/dist/reqctx/mod.js +39 -41
- package/dist/reqctx/mod.js.map +1 -1
- package/dist/services/index.d.ts +76 -75
- package/dist/services/index.d.ts.map +1 -1
- package/dist/services/index.js +73 -71
- package/dist/services/index.js.map +1 -1
- package/dist/shutdown/mod.d.ts +26 -25
- package/dist/shutdown/mod.d.ts.map +1 -1
- package/dist/shutdown/mod.js +26 -25
- package/dist/shutdown/mod.js.map +1 -1
- package/dist/storage/clickhouse/database.d.ts +113 -115
- package/dist/storage/clickhouse/database.d.ts.map +1 -1
- package/dist/storage/clickhouse/database.js +65 -79
- package/dist/storage/clickhouse/database.js.map +1 -1
- package/dist/storage/clickhouse/errors.d.ts +25 -26
- package/dist/storage/clickhouse/errors.d.ts.map +1 -1
- package/dist/storage/clickhouse/errors.js +15 -17
- package/dist/storage/clickhouse/errors.js.map +1 -1
- package/dist/storage/clickhouse/mod.d.ts +10 -10
- package/dist/storage/clickhouse/mod.js +10 -10
- package/dist/storage/objects/bucket.d.ts +196 -225
- package/dist/storage/objects/bucket.d.ts.map +1 -1
- package/dist/storage/objects/bucket.js +71 -84
- package/dist/storage/objects/bucket.js.map +1 -1
- package/dist/storage/objects/error.d.ts +4 -4
- package/dist/storage/objects/error.js +4 -4
- package/dist/storage/postgres/database.d.ts +124 -149
- package/dist/storage/postgres/database.d.ts.map +1 -1
- package/dist/storage/postgres/database.js +98 -135
- package/dist/storage/postgres/database.js.map +1 -1
- package/dist/storage/postgres/errors.d.ts +42 -48
- package/dist/storage/postgres/errors.d.ts.map +1 -1
- package/dist/storage/postgres/errors.js +44 -51
- package/dist/storage/postgres/errors.js.map +1 -1
- package/dist/storage/postgres/interval.d.ts +19 -19
- package/dist/storage/postgres/interval.d.ts.map +1 -1
- package/dist/storage/postgres/interval.js +21 -21
- package/dist/storage/postgres/interval.js.map +1 -1
- package/dist/storage/redis/bitfield.d.ts +48 -23
- package/dist/storage/redis/bitfield.d.ts.map +1 -1
- package/dist/storage/redis/bitfield.js +38 -19
- package/dist/storage/redis/bitfield.js.map +1 -1
- package/dist/storage/redis/command.d.ts +16 -12
- package/dist/storage/redis/command.d.ts.map +1 -1
- package/dist/storage/redis/command.js +16 -12
- package/dist/storage/redis/command.js.map +1 -1
- package/dist/storage/redis/commands.d.ts +99 -100
- package/dist/storage/redis/commands.d.ts.map +1 -1
- package/dist/storage/redis/commands.js +84 -85
- package/dist/storage/redis/commands.js.map +1 -1
- package/dist/storage/redis/database.d.ts +138 -122
- package/dist/storage/redis/database.d.ts.map +1 -1
- package/dist/storage/redis/database.js +120 -101
- package/dist/storage/redis/database.js.map +1 -1
- package/dist/storage/redis/mod.d.ts +52 -48
- package/dist/storage/redis/mod.d.ts.map +1 -1
- package/dist/storage/redis/mod.js +52 -48
- package/dist/storage/redis/mod.js.map +1 -1
- package/dist/storage/redis/options.d.ts +26 -24
- package/dist/storage/redis/options.d.ts.map +1 -1
- package/dist/storage/redis/options.js.map +1 -1
- package/dist/storage/redis/pubsub.d.ts +16 -16
- package/dist/storage/redis/pubsub.d.ts.map +1 -1
- package/dist/storage/redis/pubsub.js +14 -14
- package/dist/storage/redis/pubsub.js.map +1 -1
- package/dist/storage/redis/reply.d.ts +80 -72
- package/dist/storage/redis/reply.d.ts.map +1 -1
- package/dist/storage/redis/reply.js +53 -46
- package/dist/storage/redis/reply.js.map +1 -1
- package/dist/storage/redis/scan.d.ts +4 -4
- package/dist/storage/redis/scan.d.ts.map +1 -1
- package/dist/storage/redis/scan.js +6 -6
- package/dist/storage/redis/scan.js.map +1 -1
- package/dist/storage/redis/script.d.ts +28 -21
- package/dist/storage/redis/script.d.ts.map +1 -1
- package/dist/storage/redis/script.js +29 -22
- package/dist/storage/redis/script.js.map +1 -1
- package/dist/storage/redis/target.d.ts +17 -1
- package/dist/storage/redis/target.d.ts.map +1 -1
- package/dist/storage/redis/target.js +30 -1
- package/dist/storage/redis/target.js.map +1 -1
- package/dist/storage/redis/wire.d.ts +6 -6
- package/dist/storage/redis/wire.d.ts.map +1 -1
- package/dist/storage/redis/wire.js +6 -6
- package/dist/storage/redis/wire.js.map +1 -1
- package/dist/testing/mod.d.ts +83 -88
- package/dist/testing/mod.d.ts.map +1 -1
- package/dist/testing/mod.js +75 -81
- package/dist/testing/mod.js.map +1 -1
- package/dist/testing/playwright.d.ts +28 -32
- package/dist/testing/playwright.d.ts.map +1 -1
- package/dist/testing/playwright.js +22 -27
- package/dist/testing/playwright.js.map +1 -1
- package/dist/testing/puppeteer.d.ts +11 -12
- package/dist/testing/puppeteer.d.ts.map +1 -1
- package/dist/testing/puppeteer.js +17 -18
- package/dist/testing/puppeteer.js.map +1 -1
- package/dist/testing/system.d.ts +72 -90
- package/dist/testing/system.d.ts.map +1 -1
- package/dist/testing/system.js +90 -107
- package/dist/testing/system.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/frontends/mod.test.ts +6 -2
- package/frontends/mod.ts +20 -19
- package/gateway/errors.ts +30 -32
- package/gateway/match.ts +61 -57
- package/gateway/middleware.ts +62 -64
- package/gateway/mod.ts +73 -76
- package/gateway/request.ts +143 -140
- package/gateway/serve.ts +58 -63
- package/gateways/mod.ts +25 -23
- package/internal/runtime/napi/napi.cjs +1 -1
- package/internal/runtime/napi/napi.d.cts +10 -3
- package/internal/runtime/shutdown.ts +113 -101
- package/log/logger.test.ts +8 -0
- package/log/logger.ts +48 -45
- package/metrics/mod.ts +138 -122
- package/otel.ts +6 -3
- package/package.json +1 -1
- package/pubsub/subscription.ts +93 -123
- package/pubsub/topic.ts +96 -130
- package/reqctx/mod.ts +83 -86
- package/services/index.ts +78 -78
- package/shutdown/mod.ts +26 -25
- package/storage/clickhouse/database.ts +115 -129
- package/storage/clickhouse/errors.ts +27 -29
- package/storage/clickhouse/mod.ts +10 -10
- package/storage/objects/bucket.ts +209 -239
- package/storage/objects/error.ts +4 -4
- package/storage/postgres/database.ts +131 -164
- package/storage/postgres/errors.ts +45 -52
- package/storage/postgres/interval.ts +21 -21
- package/storage/redis/bitfield.ts +51 -26
- package/storage/redis/command.ts +16 -12
- package/storage/redis/commands.ts +99 -100
- package/storage/redis/database.ts +145 -123
- package/storage/redis/mod.ts +52 -48
- package/storage/redis/options.ts +26 -24
- package/storage/redis/pubsub.ts +14 -14
- package/storage/redis/redis.test.ts +17 -2
- package/storage/redis/reply.ts +85 -77
- package/storage/redis/scan.ts +6 -6
- package/storage/redis/script.ts +29 -22
- package/storage/redis/target.ts +34 -1
- package/storage/redis/wire.ts +8 -8
- package/testing/mod.ts +99 -105
- package/testing/playwright.ts +32 -37
- package/testing/puppeteer.ts +22 -23
- package/testing/system.ts +117 -133
|
@@ -7,58 +7,51 @@ import { Reply } from './reply.js';
|
|
|
7
7
|
import { Invocation, QueuedInvocation, Script } from './script.js';
|
|
8
8
|
import { ConnTarget, PoolTarget, type Target } from './target.js';
|
|
9
9
|
/**
|
|
10
|
-
*
|
|
11
|
-
* fields must be literals.
|
|
10
|
+
* Configuration options for a Redis database. Encore reads this statically
|
|
11
|
+
* from the declaration, so all fields must be literals.
|
|
12
12
|
*/
|
|
13
13
|
export interface DatabaseConfig {
|
|
14
14
|
/**
|
|
15
|
-
*
|
|
16
|
-
* database
|
|
15
|
+
* Whether data must survive restarts and never be evicted. When omitted or
|
|
16
|
+
* `false`, the database acts as a cache and its data may be lost or evicted.
|
|
17
17
|
*/
|
|
18
18
|
persistent?: boolean;
|
|
19
19
|
/**
|
|
20
|
-
* Tags that classify the database
|
|
21
|
-
*
|
|
22
|
-
* letters, digits, `_
|
|
23
|
-
* letter
|
|
20
|
+
* Tags that classify the database for policy evaluation, written as string
|
|
21
|
+
* literals (for example, `{data: "pci"}`). Keys and values may contain
|
|
22
|
+
* lowercase letters, digits, `_`, and `-`, up to 63 characters. Keys must
|
|
23
|
+
* start with a letter and cannot start with the reserved prefix `encore`.
|
|
24
|
+
* At most 32 tags are allowed.
|
|
24
25
|
*/
|
|
25
26
|
tags?: Record<string, string>;
|
|
26
27
|
}
|
|
27
28
|
/**
|
|
28
|
-
* A handle to a {@link Database}
|
|
29
|
-
*
|
|
30
|
-
* code.
|
|
29
|
+
* A read-only handle to a {@link Database}, created by {@link Database.read}
|
|
30
|
+
* or {@link Database.readPrimary}. Safe to pass to other code.
|
|
31
31
|
*
|
|
32
|
-
* Its command groups
|
|
32
|
+
* Its command groups expose only read-only commands.
|
|
33
33
|
*/
|
|
34
34
|
export interface ReadOnlyDatabaseRef extends ReadCommandGroups {
|
|
35
35
|
}
|
|
36
36
|
export declare class ReadOnlyDatabaseRef {
|
|
37
37
|
private readonly t;
|
|
38
|
-
/**
|
|
39
|
-
* The runtime gives a database one pool for now, on the primary, which
|
|
40
|
-
* every handle shares.
|
|
41
|
-
*/
|
|
42
|
-
readonly primary: boolean;
|
|
43
38
|
/** @internal */
|
|
44
|
-
constructor(t: PoolTarget, groups: ReadCommandGroups
|
|
39
|
+
constructor(t: PoolTarget, groups: ReadCommandGroups);
|
|
45
40
|
/**
|
|
46
|
-
*
|
|
47
|
-
*
|
|
41
|
+
* Prepares an invocation of `script`, which must have been created with
|
|
42
|
+
* {@link Script.readOnly}.
|
|
48
43
|
*/
|
|
49
|
-
primary: boolean);
|
|
50
|
-
/** A call to `script`, which must be one made by {@link Script.readOnly}. */
|
|
51
44
|
script(script: Script): Invocation;
|
|
52
45
|
/**
|
|
53
|
-
*
|
|
54
|
-
* {@link DatabaseRef.command}
|
|
55
|
-
*
|
|
46
|
+
* Prepares an arbitrary Redis command that is not covered by the typed
|
|
47
|
+
* command groups, as described in {@link DatabaseRef.command}. Only commands
|
|
48
|
+
* that Redis marks as read-only are allowed.
|
|
56
49
|
*/
|
|
57
50
|
command<N extends string>(name: StringLiteral<N>): CommandInvocation;
|
|
58
51
|
}
|
|
59
52
|
/**
|
|
60
|
-
* A handle to a {@link Database}
|
|
61
|
-
* {@link Database.write}.
|
|
53
|
+
* A read-write handle to a {@link Database}, created by
|
|
54
|
+
* {@link Database.write}. Safe to pass to other code.
|
|
62
55
|
*/
|
|
63
56
|
export interface DatabaseRef extends CommandGroups {
|
|
64
57
|
}
|
|
@@ -74,9 +67,9 @@ export declare class DatabaseRef {
|
|
|
74
67
|
/** @internal */
|
|
75
68
|
groups: CommandGroups);
|
|
76
69
|
/**
|
|
77
|
-
*
|
|
78
|
-
*
|
|
79
|
-
* the rest.
|
|
70
|
+
* Creates a pipeline that sends a batch of commands in a single round trip.
|
|
71
|
+
* A pipeline is not a transaction: commands from other clients may run
|
|
72
|
+
* between queued commands, and one failing command does not stop the rest.
|
|
80
73
|
*
|
|
81
74
|
* ```ts
|
|
82
75
|
* const pipe = SESSIONS.pipeline();
|
|
@@ -87,11 +80,11 @@ export declare class DatabaseRef {
|
|
|
87
80
|
*/
|
|
88
81
|
pipeline(): Pipeline;
|
|
89
82
|
/**
|
|
90
|
-
*
|
|
91
|
-
*
|
|
83
|
+
* Creates a transaction (`MULTI`/`EXEC`) whose queued commands run together
|
|
84
|
+
* without commands from other clients interleaving between them.
|
|
92
85
|
*
|
|
93
|
-
* Nothing is sent until {@link Transaction.exec}, so a transaction
|
|
94
|
-
*
|
|
86
|
+
* Nothing is sent until {@link Transaction.exec} is called, so a transaction
|
|
87
|
+
* is never held open while your code awaits other work.
|
|
95
88
|
*
|
|
96
89
|
* ```ts
|
|
97
90
|
* const tx = LEDGER.transaction();
|
|
@@ -102,16 +95,16 @@ export declare class DatabaseRef {
|
|
|
102
95
|
*/
|
|
103
96
|
transaction(): Transaction;
|
|
104
97
|
/**
|
|
105
|
-
*
|
|
106
|
-
*
|
|
107
|
-
* {@link Connection.close}, or
|
|
98
|
+
* Acquires a dedicated connection from the pool for operations that must run
|
|
99
|
+
* on the same connection, such as watching keys before a transaction. Return
|
|
100
|
+
* it with {@link Connection.close}, or manage it with `await using`.
|
|
108
101
|
*/
|
|
109
102
|
acquire(): Promise<Connection>;
|
|
110
103
|
/**
|
|
111
|
-
* Runs `body` as an optimistic transaction
|
|
112
|
-
*
|
|
113
|
-
*
|
|
114
|
-
*
|
|
104
|
+
* Runs `body` as an optimistic transaction watching `keys`. `body` reads
|
|
105
|
+
* values through the connection and queues writes on the transaction; the
|
|
106
|
+
* transaction commits only if none of `keys` changed in the meantime. If a
|
|
107
|
+
* watched key changes, `body` is retried.
|
|
115
108
|
*
|
|
116
109
|
* ```ts
|
|
117
110
|
* const left = await LEDGER.watch(["balance"], async (conn, tx) => {
|
|
@@ -122,38 +115,45 @@ export declare class DatabaseRef {
|
|
|
122
115
|
* ```
|
|
123
116
|
*/
|
|
124
117
|
watch<T>(keys: string[], body: (conn: Connection, tx: WatchedTransaction) => Promise<T>): Promise<T>;
|
|
125
|
-
/**
|
|
118
|
+
/**
|
|
119
|
+
* Prepares an invocation of `script` so you can attach its keys and
|
|
120
|
+
* arguments and then invoke it.
|
|
121
|
+
*/
|
|
126
122
|
script(script: Script): Invocation;
|
|
127
123
|
/**
|
|
128
|
-
*
|
|
129
|
-
*
|
|
124
|
+
* Prepares an arbitrary Redis command that is not covered by the typed
|
|
125
|
+
* command groups. Pass the command name as a string literal, add its
|
|
126
|
+
* arguments in order (marking keys with `key()`), and then call `invoke()`.
|
|
130
127
|
*
|
|
131
128
|
* ```ts
|
|
132
129
|
* const freq = await SESSIONS.command("OBJECT").arg("FREQ").key("hot").invoke().number();
|
|
133
130
|
* ```
|
|
134
131
|
*
|
|
135
|
-
* Encore reads the name to grant the access
|
|
136
|
-
*
|
|
137
|
-
*
|
|
138
|
-
*
|
|
139
|
-
* database,
|
|
140
|
-
*
|
|
141
|
-
*
|
|
132
|
+
* Encore reads the command name statically to grant the required access.
|
|
133
|
+
* Before sending the command, the runtime checks it against Redis's command
|
|
134
|
+
* table and throws a `TypeError` if a required key argument was not passed
|
|
135
|
+
* with `key()` (which applies the database's key prefix), or if the command
|
|
136
|
+
* reaches outside the database, modifies a shared connection, or already has
|
|
137
|
+
* a dedicated API (`MULTI`, `SUBSCRIBE`, `EVAL`, `SCAN`, `FLUSHALL`, …).
|
|
138
|
+
* Unknown commands, such as module commands, are sent with their keys as
|
|
139
|
+
* marked.
|
|
142
140
|
*/
|
|
143
141
|
command<N extends string>(name: StringLiteral<N>): CommandInvocation;
|
|
144
142
|
/**
|
|
145
|
-
* The connection string
|
|
146
|
-
*
|
|
143
|
+
* The connection string for connecting to this database from an external
|
|
144
|
+
* client.
|
|
147
145
|
*
|
|
148
|
-
*
|
|
149
|
-
*
|
|
146
|
+
* Note that external clients connect without the database's key prefix, so
|
|
147
|
+
* keys stored by an external client will not match keys read by this SDK
|
|
148
|
+
* under the same names.
|
|
150
149
|
*/
|
|
151
150
|
get connectionString(): string;
|
|
152
151
|
}
|
|
153
152
|
/**
|
|
154
|
-
* A Redis database
|
|
153
|
+
* A Redis database backed by a connection pool created on first use.
|
|
155
154
|
*
|
|
156
|
-
* Declare
|
|
155
|
+
* Declare databases at module scope and run commands through their command
|
|
156
|
+
* groups:
|
|
157
157
|
*
|
|
158
158
|
* ```ts
|
|
159
159
|
* import { Database } from "@encore.dev/sdk/storage/redis";
|
|
@@ -165,15 +165,16 @@ export declare class DatabaseRef {
|
|
|
165
165
|
* ```
|
|
166
166
|
*/
|
|
167
167
|
export declare class Database extends DatabaseRef {
|
|
168
|
-
private
|
|
168
|
+
private reader?;
|
|
169
|
+
private primaryReader?;
|
|
169
170
|
/**
|
|
170
171
|
* Declares a Redis database.
|
|
171
172
|
*
|
|
172
|
-
* Encore reads the name and
|
|
173
|
-
* must be literals
|
|
173
|
+
* Encore reads the name and configuration statically from the declaration, so
|
|
174
|
+
* both must be literals and the database must be declared at module scope.
|
|
174
175
|
*
|
|
175
|
-
* The name must be unique within the Encore application
|
|
176
|
-
* Once deployed, never
|
|
176
|
+
* The name must be unique within the Encore application and use kebab-case.
|
|
177
|
+
* Once deployed, never rename it — doing so creates a new database under the
|
|
177
178
|
* new name.
|
|
178
179
|
*/
|
|
179
180
|
constructor(name: string, cfg?: DatabaseConfig);
|
|
@@ -181,30 +182,31 @@ export declare class Database extends DatabaseRef {
|
|
|
181
182
|
* References an existing database by name. To declare a new database, use
|
|
182
183
|
* `new Database(...)` instead.
|
|
183
184
|
*
|
|
184
|
-
* The name must be a string literal
|
|
185
|
-
*
|
|
185
|
+
* The name must be a string literal so Encore can resolve it statically. A
|
|
186
|
+
* referenced database takes no configuration; it is configured where it is
|
|
186
187
|
* declared.
|
|
187
188
|
*/
|
|
188
189
|
static named<Name extends string>(name: StringLiteral<Name>): Database;
|
|
189
|
-
/**
|
|
190
|
+
/** Returns a read-write handle to the database. */
|
|
190
191
|
write(): DatabaseRef;
|
|
191
192
|
/**
|
|
192
|
-
*
|
|
193
|
-
*
|
|
194
|
-
*
|
|
193
|
+
* Returns a read-only handle to the database. Reads from a read replica when
|
|
194
|
+
* a read-only connection pool is configured, and from the primary server
|
|
195
|
+
* otherwise. Write commands are rejected before being sent. To always read
|
|
196
|
+
* from the primary server, use {@link Database.readPrimary}.
|
|
195
197
|
*/
|
|
196
198
|
read(): ReadOnlyDatabaseRef;
|
|
197
199
|
/**
|
|
198
|
-
*
|
|
199
|
-
* server even
|
|
200
|
+
* Returns a read-only handle to the database that always reads from the
|
|
201
|
+
* primary server, even when read replicas are available. Write commands are
|
|
202
|
+
* rejected before being sent.
|
|
200
203
|
*/
|
|
201
204
|
readPrimary(): ReadOnlyDatabaseRef;
|
|
202
|
-
private readOnlyGroups;
|
|
203
205
|
}
|
|
204
206
|
/**
|
|
205
|
-
* A batch of commands sent in
|
|
206
|
-
* {@link DatabaseRef.pipeline}. Not a transaction.
|
|
207
|
-
*
|
|
207
|
+
* A batch of commands sent in a single round trip, created by
|
|
208
|
+
* {@link DatabaseRef.pipeline}. Not a transaction. Queue commands through its
|
|
209
|
+
* command groups (for example, `pipe.string.get(...)`).
|
|
208
210
|
*/
|
|
209
211
|
export interface Pipeline extends QueueGroups {
|
|
210
212
|
}
|
|
@@ -213,28 +215,30 @@ export declare class Pipeline {
|
|
|
213
215
|
private readonly queued;
|
|
214
216
|
/** @internal */
|
|
215
217
|
constructor(t: Target);
|
|
216
|
-
/**
|
|
218
|
+
/** The number of commands currently queued. */
|
|
217
219
|
get length(): number;
|
|
218
|
-
/**
|
|
220
|
+
/**
|
|
221
|
+
* Prepares a call to `script` to be queued on this pipeline. Call
|
|
222
|
+
* {@link QueuedInvocation.queue} to append it.
|
|
223
|
+
*/
|
|
219
224
|
script(script: Script): QueuedInvocation;
|
|
220
225
|
/**
|
|
221
|
-
*
|
|
222
|
-
* {@link
|
|
223
|
-
*
|
|
224
|
-
* queued: the batch fails.
|
|
226
|
+
* Prepares an arbitrary Redis command (see {@link DatabaseRef.command}) to
|
|
227
|
+
* be queued on this pipeline. Call {@link QueuedCommandInvocation.queue} to
|
|
228
|
+
* append it. Blocking commands cannot be queued and will fail the batch.
|
|
225
229
|
*/
|
|
226
230
|
command<N extends string>(name: StringLiteral<N>): QueuedCommandInvocation;
|
|
227
231
|
/**
|
|
228
|
-
* Sends
|
|
229
|
-
*
|
|
230
|
-
*
|
|
232
|
+
* Sends all queued commands and returns their replies in order. If the server
|
|
233
|
+
* rejects any command, throws a {@link BatchError} containing all replies.
|
|
234
|
+
* Clears the pipeline afterwards.
|
|
231
235
|
*/
|
|
232
236
|
exec(): Promise<Reply[]>;
|
|
233
237
|
}
|
|
234
238
|
/**
|
|
235
|
-
* A transaction
|
|
236
|
-
*
|
|
237
|
-
* between.
|
|
239
|
+
* A transaction created by {@link DatabaseRef.transaction}. Commands queued
|
|
240
|
+
* through its command groups execute together without commands from other
|
|
241
|
+
* clients interleaving between them.
|
|
238
242
|
*/
|
|
239
243
|
export interface Transaction extends QueueGroups {
|
|
240
244
|
}
|
|
@@ -243,32 +247,36 @@ export declare class Transaction {
|
|
|
243
247
|
private readonly queued;
|
|
244
248
|
/** @internal */
|
|
245
249
|
constructor(t: Target);
|
|
246
|
-
/**
|
|
250
|
+
/** The number of commands currently queued. */
|
|
247
251
|
get length(): number;
|
|
248
|
-
/**
|
|
252
|
+
/**
|
|
253
|
+
* Prepares a call to `script` to be queued on this transaction. Call
|
|
254
|
+
* {@link QueuedInvocation.queue} to append it.
|
|
255
|
+
*/
|
|
249
256
|
script(script: Script): QueuedInvocation;
|
|
250
257
|
/**
|
|
251
|
-
*
|
|
252
|
-
* {@link
|
|
253
|
-
*
|
|
254
|
-
* queued: the batch fails.
|
|
258
|
+
* Prepares an arbitrary Redis command (see {@link DatabaseRef.command}) to
|
|
259
|
+
* be queued on this transaction. Call {@link QueuedCommandInvocation.queue}
|
|
260
|
+
* to append it. Blocking commands cannot be queued and will fail the batch.
|
|
255
261
|
*/
|
|
256
262
|
command<N extends string>(name: StringLiteral<N>): QueuedCommandInvocation;
|
|
257
263
|
/**
|
|
258
|
-
* Runs
|
|
259
|
-
* {@link Pipeline.exec}
|
|
260
|
-
*
|
|
264
|
+
* Runs all queued commands as a single transaction and returns their replies,
|
|
265
|
+
* matching {@link Pipeline.exec}. If the server rejects a command during
|
|
266
|
+
* execution, the remaining commands still run — Redis does not support
|
|
267
|
+
* rollbacks.
|
|
261
268
|
*/
|
|
262
269
|
exec(): Promise<Reply[]>;
|
|
263
270
|
/**
|
|
264
|
-
*
|
|
265
|
-
*
|
|
271
|
+
* Discards the transaction by clearing its queue. Because nothing has been
|
|
272
|
+
* sent yet, there is nothing to undo on the server.
|
|
266
273
|
*/
|
|
267
274
|
discard(): void;
|
|
268
275
|
}
|
|
269
276
|
/**
|
|
270
|
-
* A transaction on a {@link Connection},
|
|
271
|
-
*
|
|
277
|
+
* A transaction on a {@link Connection}, created by
|
|
278
|
+
* {@link Connection.transaction}. It aborts without running if any key watched
|
|
279
|
+
* by the connection has changed.
|
|
272
280
|
*/
|
|
273
281
|
export interface WatchedTransaction extends QueueGroups {
|
|
274
282
|
}
|
|
@@ -277,29 +285,31 @@ export declare class WatchedTransaction {
|
|
|
277
285
|
private readonly queued;
|
|
278
286
|
/** @internal */
|
|
279
287
|
constructor(t: ConnTarget);
|
|
280
|
-
/**
|
|
288
|
+
/** The number of commands currently queued. */
|
|
281
289
|
get length(): number;
|
|
282
|
-
/**
|
|
290
|
+
/**
|
|
291
|
+
* Prepares a call to `script` to be queued on this transaction. Call
|
|
292
|
+
* {@link QueuedInvocation.queue} to append it.
|
|
293
|
+
*/
|
|
283
294
|
script(script: Script): QueuedInvocation;
|
|
284
295
|
/**
|
|
285
|
-
*
|
|
286
|
-
* {@link
|
|
287
|
-
*
|
|
288
|
-
* queued: the batch fails.
|
|
296
|
+
* Prepares an arbitrary Redis command (see {@link DatabaseRef.command}) to
|
|
297
|
+
* be queued on this transaction. Call {@link QueuedCommandInvocation.queue}
|
|
298
|
+
* to append it. Blocking commands cannot be queued and will fail the batch.
|
|
289
299
|
*/
|
|
290
300
|
command<N extends string>(name: StringLiteral<N>): QueuedCommandInvocation;
|
|
291
301
|
/**
|
|
292
|
-
* Runs
|
|
293
|
-
* {@link Transaction.exec}
|
|
294
|
-
* which case none of
|
|
295
|
-
* afterwards.
|
|
302
|
+
* Runs all queued commands as a single transaction and returns their replies
|
|
303
|
+
* (as in {@link Transaction.exec}), or `null` if a watched key changed (in
|
|
304
|
+
* which case none of the commands ran). Either way, all watches on the
|
|
305
|
+
* connection are cleared afterwards.
|
|
296
306
|
*/
|
|
297
307
|
exec(): Promise<Reply[] | null>;
|
|
298
308
|
}
|
|
299
309
|
/**
|
|
300
|
-
* A connection
|
|
301
|
-
* {@link DatabaseRef.acquire}.
|
|
302
|
-
*
|
|
310
|
+
* A dedicated connection acquired from a database's pool via
|
|
311
|
+
* {@link DatabaseRef.acquire}. Commands run sequentially through its command
|
|
312
|
+
* groups. Return it to the pool with {@link Connection.close}.
|
|
303
313
|
*/
|
|
304
314
|
export interface Connection extends CommandGroups {
|
|
305
315
|
}
|
|
@@ -309,26 +319,32 @@ export declare class Connection implements AsyncDisposable {
|
|
|
309
319
|
/** @internal */
|
|
310
320
|
constructor(impl: runtime.RedisConnection, pool: PoolTarget);
|
|
311
321
|
/**
|
|
312
|
-
* Watches `keys
|
|
313
|
-
*
|
|
322
|
+
* Watches `keys` for changes. A subsequent {@link Connection.transaction}
|
|
323
|
+
* will abort without running if any watched key changes before `exec()`.
|
|
314
324
|
*/
|
|
315
325
|
watch(...keys: string[]): Promise<void>;
|
|
316
|
-
/** Stops watching
|
|
326
|
+
/** Stops watching all keys on this connection. */
|
|
317
327
|
unwatch(): Promise<void>;
|
|
318
|
-
/**
|
|
328
|
+
/**
|
|
329
|
+
* Creates a transaction on this connection that depends on its watched keys.
|
|
330
|
+
*/
|
|
319
331
|
transaction(): WatchedTransaction;
|
|
320
|
-
/**
|
|
332
|
+
/**
|
|
333
|
+
* Creates a pipeline that sends a batch of commands in a single round trip
|
|
334
|
+
* on this connection.
|
|
335
|
+
*/
|
|
321
336
|
pipeline(): Pipeline;
|
|
322
|
-
/**
|
|
337
|
+
/** Prepares an invocation of `script` on this connection. */
|
|
323
338
|
script(script: Script): Invocation;
|
|
324
339
|
/**
|
|
325
|
-
*
|
|
326
|
-
* {@link DatabaseRef.command}.
|
|
340
|
+
* Prepares an arbitrary Redis command on this connection (see
|
|
341
|
+
* {@link DatabaseRef.command}). Blocking commands are not allowed on an
|
|
342
|
+
* acquired connection.
|
|
327
343
|
*/
|
|
328
344
|
command<N extends string>(name: StringLiteral<N>): CommandInvocation;
|
|
329
345
|
/**
|
|
330
|
-
* Returns the connection to its pool
|
|
331
|
-
*
|
|
346
|
+
* Returns the connection to its pool, automatically unwatching any keys that
|
|
347
|
+
* are still watched.
|
|
332
348
|
*/
|
|
333
349
|
close(): Promise<void>;
|
|
334
350
|
[Symbol.asyncDispose](): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"database.d.ts","sourceRoot":"","sources":["../../../storage/redis/database.ts"],"names":[],"mappings":";AACA,OAAO,KAAK,KAAK,OAAO,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAC,aAAa,EAAC,MAAM,kCAAkC,CAAC;AAC/D,OAAO,EAIL,KAAK,aAAa,EAClB,KAAK,WAAW,EAChB,KAAK,iBAAiB,EACvB,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,iBAAiB,EACjB,uBAAuB,EAExB,MAAM,WAAW,CAAC;AACnB,OAAO,EAAa,KAAK,EAAC,MAAM,SAAS,CAAC;AAC1C,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