@encore.dev/sdk 0.0.0 → 2.0.0-beta.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.
- package/LICENSE +362 -0
- package/README.md +122 -2
- package/app_meta.test.ts +134 -0
- package/app_meta.ts +186 -0
- package/config/config.test.ts +381 -0
- package/config/config.ts +178 -0
- package/config/mod.ts +14 -0
- package/config/secrets.ts +147 -0
- package/config/value.ts +243 -0
- package/cron/mod.ts +23 -0
- package/dist/app_meta.d.ts +93 -0
- package/dist/app_meta.js +65 -0
- package/dist/app_meta.js.map +1 -0
- package/dist/config/config.d.ts +105 -0
- package/dist/config/config.js +87 -0
- package/dist/config/config.js.map +1 -0
- package/dist/config/mod.d.ts +4 -0
- package/dist/config/mod.js +3 -0
- package/dist/config/mod.js.map +1 -0
- package/dist/config/secrets.d.ts +92 -0
- package/dist/config/secrets.js +80 -0
- package/dist/config/secrets.js.map +1 -0
- package/dist/config/value.d.ts +51 -0
- package/dist/config/value.js +178 -0
- package/dist/config/value.js.map +1 -0
- package/dist/cron/mod.d.ts +22 -0
- package/dist/cron/mod.js +9 -0
- package/dist/cron/mod.js.map +1 -0
- package/dist/internal/otel/backend.d.ts +50 -0
- package/dist/internal/otel/backend.js +2 -0
- package/dist/internal/otel/backend.js.map +1 -0
- package/dist/internal/otel/context.d.ts +10 -0
- package/dist/internal/otel/context.js +34 -0
- package/dist/internal/otel/context.js.map +1 -0
- package/dist/internal/otel/context_manager.d.ts +22 -0
- package/dist/internal/otel/context_manager.js +120 -0
- package/dist/internal/otel/context_manager.js.map +1 -0
- package/dist/internal/otel/encode.d.ts +112 -0
- package/dist/internal/otel/encode.js +290 -0
- package/dist/internal/otel/encode.js.map +1 -0
- package/dist/internal/otel/index.d.ts +9 -0
- package/dist/internal/otel/index.js +9 -0
- package/dist/internal/otel/index.js.map +1 -0
- package/dist/internal/otel/meter.d.ts +73 -0
- package/dist/internal/otel/meter.js +265 -0
- package/dist/internal/otel/meter.js.map +1 -0
- package/dist/internal/otel/propagator.d.ts +14 -0
- package/dist/internal/otel/propagator.js +61 -0
- package/dist/internal/otel/propagator.js.map +1 -0
- package/dist/internal/otel/provider.d.ts +9 -0
- package/dist/internal/otel/provider.js +19 -0
- package/dist/internal/otel/provider.js.map +1 -0
- package/dist/internal/otel/request_context.d.ts +11 -0
- package/dist/internal/otel/request_context.js +20 -0
- package/dist/internal/otel/request_context.js.map +1 -0
- package/dist/internal/otel/span.d.ts +61 -0
- package/dist/internal/otel/span.js +206 -0
- package/dist/internal/otel/span.js.map +1 -0
- package/dist/internal/otel/tracer.d.ts +15 -0
- package/dist/internal/otel/tracer.js +65 -0
- package/dist/internal/otel/tracer.js.map +1 -0
- package/dist/internal/reqtrack/mod.d.ts +6 -0
- package/dist/internal/reqtrack/mod.js +28 -0
- package/dist/internal/reqtrack/mod.js.map +1 -0
- package/dist/internal/runtime/meter.d.ts +11 -0
- package/dist/internal/runtime/meter.js +22 -0
- package/dist/internal/runtime/meter.js.map +1 -0
- package/dist/internal/runtime/mod.d.ts +12 -0
- package/dist/internal/runtime/mod.js +28 -0
- package/dist/internal/runtime/mod.js.map +1 -0
- package/dist/internal/runtime/napi/napi.cjs +122 -0
- package/dist/internal/runtime/napi/napi.d.cts +601 -0
- package/dist/internal/runtime/shutdown.d.ts +13 -0
- package/dist/internal/runtime/shutdown.js +56 -0
- package/dist/internal/runtime/shutdown.js.map +1 -0
- package/dist/internal/utils/constraints.d.ts +9 -0
- package/dist/internal/utils/constraints.js +2 -0
- package/dist/internal/utils/constraints.js.map +1 -0
- package/dist/log/index.d.ts +39 -0
- package/dist/log/index.js +44 -0
- package/dist/log/index.js.map +1 -0
- package/dist/log/logger.d.ts +123 -0
- package/dist/log/logger.js +203 -0
- package/dist/log/logger.js.map +1 -0
- package/dist/log/runtime.d.ts +19 -0
- package/dist/log/runtime.js +22 -0
- package/dist/log/runtime.js.map +1 -0
- package/dist/log/stderr.d.ts +9 -0
- package/dist/log/stderr.js +25 -0
- package/dist/log/stderr.js.map +1 -0
- package/dist/metrics/mod.d.ts +315 -0
- package/dist/metrics/mod.js +488 -0
- package/dist/metrics/mod.js.map +1 -0
- package/dist/mod.d.ts +6 -0
- package/dist/mod.js +4 -0
- package/dist/mod.js.map +1 -0
- package/dist/otel.d.ts +9 -0
- package/dist/otel.js +13 -0
- package/dist/otel.js.map +1 -0
- package/dist/pubsub/encoding.d.ts +3 -0
- package/dist/pubsub/encoding.js +10 -0
- package/dist/pubsub/encoding.js.map +1 -0
- package/dist/pubsub/mod.d.ts +6 -0
- package/dist/pubsub/mod.js +3 -0
- package/dist/pubsub/mod.js.map +1 -0
- package/dist/pubsub/refs.d.ts +12 -0
- package/dist/pubsub/refs.js +11 -0
- package/dist/pubsub/refs.js.map +1 -0
- package/dist/pubsub/subscription.d.ts +128 -0
- package/dist/pubsub/subscription.js +39 -0
- package/dist/pubsub/subscription.js.map +1 -0
- package/dist/pubsub/topic.d.ts +148 -0
- package/dist/pubsub/topic.js +164 -0
- package/dist/pubsub/topic.js.map +1 -0
- package/dist/req_meta.d.ts +47 -0
- package/dist/req_meta.js +26 -0
- package/dist/req_meta.js.map +1 -0
- package/dist/services/index.d.ts +7 -0
- package/dist/services/index.js +17 -0
- package/dist/services/index.js.map +1 -0
- package/dist/shutdown/mod.d.ts +23 -0
- package/dist/shutdown/mod.js +24 -0
- package/dist/shutdown/mod.js.map +1 -0
- package/dist/storage/objects/bucket.d.ts +216 -0
- package/dist/storage/objects/bucket.js +123 -0
- package/dist/storage/objects/bucket.js.map +1 -0
- package/dist/storage/objects/error.d.ts +14 -0
- package/dist/storage/objects/error.js +81 -0
- package/dist/storage/objects/error.js.map +1 -0
- package/dist/storage/objects/mod.d.ts +4 -0
- package/dist/storage/objects/mod.js +3 -0
- package/dist/storage/objects/mod.js.map +1 -0
- package/dist/storage/objects/refs.d.ts +31 -0
- package/dist/storage/objects/refs.js +20 -0
- package/dist/storage/objects/refs.js.map +1 -0
- package/dist/storage/postgres/database.d.ts +295 -0
- package/dist/storage/postgres/database.js +378 -0
- package/dist/storage/postgres/database.js.map +1 -0
- package/dist/storage/postgres/mod.d.ts +2 -0
- package/dist/storage/postgres/mod.js +2 -0
- package/dist/storage/postgres/mod.js.map +1 -0
- package/dist/storage/redis/commands.d.ts +573 -0
- package/dist/storage/redis/commands.js +637 -0
- package/dist/storage/redis/commands.js.map +1 -0
- package/dist/storage/redis/database.d.ts +302 -0
- package/dist/storage/redis/database.js +336 -0
- package/dist/storage/redis/database.js.map +1 -0
- package/dist/storage/redis/mod.d.ts +88 -0
- package/dist/storage/redis/mod.js +84 -0
- package/dist/storage/redis/mod.js.map +1 -0
- package/dist/storage/redis/native.d.ts +8 -0
- package/dist/storage/redis/native.js +11 -0
- package/dist/storage/redis/native.js.map +1 -0
- package/dist/storage/redis/options.d.ts +89 -0
- package/dist/storage/redis/options.js +53 -0
- package/dist/storage/redis/options.js.map +1 -0
- package/dist/storage/redis/pubsub.d.ts +53 -0
- package/dist/storage/redis/pubsub.js +88 -0
- package/dist/storage/redis/pubsub.js.map +1 -0
- package/dist/storage/redis/reply.d.ts +256 -0
- package/dist/storage/redis/reply.js +572 -0
- package/dist/storage/redis/reply.js.map +1 -0
- package/dist/storage/redis/scan.d.ts +11 -0
- package/dist/storage/redis/scan.js +76 -0
- package/dist/storage/redis/scan.js.map +1 -0
- package/dist/storage/redis/script.d.ts +91 -0
- package/dist/storage/redis/script.js +143 -0
- package/dist/storage/redis/script.js.map +1 -0
- package/dist/storage/redis/target.d.ts +47 -0
- package/dist/storage/redis/target.js +82 -0
- package/dist/storage/redis/target.js.map +1 -0
- package/dist/storage/redis/wire.d.ts +105 -0
- package/dist/storage/redis/wire.js +333 -0
- package/dist/storage/redis/wire.js.map +1 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -0
- package/dist/types/mod.d.ts +42 -0
- package/dist/types/mod.js +65 -0
- package/dist/types/mod.js.map +1 -0
- package/internal/otel/backend.ts +60 -0
- package/internal/otel/context.test.ts +70 -0
- package/internal/otel/context.ts +48 -0
- package/internal/otel/context_manager.test.ts +154 -0
- package/internal/otel/context_manager.ts +141 -0
- package/internal/otel/encode.test.ts +266 -0
- package/internal/otel/encode.ts +408 -0
- package/internal/otel/index.ts +20 -0
- package/internal/otel/meter.test.ts +231 -0
- package/internal/otel/meter.ts +332 -0
- package/internal/otel/propagator.test.ts +105 -0
- package/internal/otel/propagator.ts +68 -0
- package/internal/otel/provider.ts +23 -0
- package/internal/otel/request_context.ts +32 -0
- package/internal/otel/span.ts +252 -0
- package/internal/otel/tracer.test.ts +352 -0
- package/internal/otel/tracer.ts +104 -0
- package/internal/reqtrack/mod.ts +39 -0
- package/internal/runtime/meter.ts +26 -0
- package/internal/runtime/mod.ts +41 -0
- package/internal/runtime/napi/napi.cjs +122 -0
- package/internal/runtime/napi/napi.d.cts +601 -0
- package/internal/runtime/shutdown.test.ts +248 -0
- package/internal/runtime/shutdown.ts +64 -0
- package/internal/utils/constraints.ts +12 -0
- package/log/index.ts +107 -0
- package/log/logger.test.ts +194 -0
- package/log/logger.ts +308 -0
- package/log/runtime.test.ts +65 -0
- package/log/runtime.ts +40 -0
- package/log/stderr.test.ts +23 -0
- package/log/stderr.ts +24 -0
- package/metrics/export.test.ts +337 -0
- package/metrics/mod.test.ts +180 -0
- package/metrics/mod.ts +619 -0
- package/mod.ts +22 -0
- package/otel.test.ts +84 -0
- package/otel.ts +17 -0
- package/package.json +121 -5
- package/pubsub/encoding.ts +8 -0
- package/pubsub/mod.ts +14 -0
- package/pubsub/pubsub.test.ts +186 -0
- package/pubsub/refs.ts +22 -0
- package/pubsub/subscription.ts +180 -0
- package/pubsub/topic.test.ts +121 -0
- package/pubsub/topic.ts +212 -0
- package/req_meta.ts +75 -0
- package/services/index.test.ts +30 -0
- package/services/index.ts +16 -0
- package/shutdown/mod.ts +24 -0
- package/storage/objects/bucket.ts +338 -0
- package/storage/objects/error.ts +94 -0
- package/storage/objects/mod.ts +35 -0
- package/storage/objects/refs.ts +69 -0
- package/storage/postgres/database.integration.test.ts +175 -0
- package/storage/postgres/database.test.ts +241 -0
- package/storage/postgres/database.ts +497 -0
- package/storage/postgres/mod.ts +15 -0
- package/storage/redis/commands.ts +1221 -0
- package/storage/redis/database.ts +466 -0
- package/storage/redis/mod.ts +135 -0
- package/storage/redis/native.ts +11 -0
- package/storage/redis/options.ts +119 -0
- package/storage/redis/pubsub.ts +92 -0
- package/storage/redis/redis.test.ts +706 -0
- package/storage/redis/reply.ts +705 -0
- package/storage/redis/runtime.test.ts +233 -0
- package/storage/redis/scan.ts +125 -0
- package/storage/redis/script.ts +162 -0
- package/storage/redis/target.ts +131 -0
- package/storage/redis/wire.ts +369 -0
- package/types/mod.ts +92 -0
|
@@ -0,0 +1,573 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The command groups: one per Redis data type, each holding the commands on
|
|
3
|
+
* it in three forms: the ones that run now, the ones of those that only read,
|
|
4
|
+
* and the ones that queue on a pipeline or a transaction.
|
|
5
|
+
*
|
|
6
|
+
* All three come from one list per group, below, after the Rust SDK's
|
|
7
|
+
* (`sdk/rs/encore/src/storage/redis/commands.rs`): the same commands, named in
|
|
8
|
+
* TypeScript's casing. A command is written once: whether it reads or writes,
|
|
9
|
+
* its parameters, the Redis command it builds, with the arguments that are
|
|
10
|
+
* keys marked, and what its reply is read as. Encore's parser holds the same
|
|
11
|
+
* list (`TS_TABLES.families` in `encore_parser`), which is how it knows what
|
|
12
|
+
* each call needs to be granted; a test there reads this file and fails when
|
|
13
|
+
* the two differ.
|
|
14
|
+
*
|
|
15
|
+
* Two are TypeScript's own, as they are Go's: `incrFloat` and `hincrFloat`,
|
|
16
|
+
* where Rust picks `INCRBY` or `INCRBYFLOAT` by the type of the amount.
|
|
17
|
+
*
|
|
18
|
+
* @module
|
|
19
|
+
*/
|
|
20
|
+
import { type Direction, type Expiry, type RadiusOptions, type ScanOptions, type SetOptions, type StreamMaxlen, type Unit } from './options.js';
|
|
21
|
+
import { Reply, ReplyPromise } from './reply.js';
|
|
22
|
+
import { type Subscription } from './pubsub.js';
|
|
23
|
+
import type { Target } from './target.js';
|
|
24
|
+
import { Cmd, type Pairs, type RedisArg, type Value } from './wire.js';
|
|
25
|
+
/** A score bound: a number, `"-inf"` or `"+inf"`, or exclusive as `"(1.5"`. */
|
|
26
|
+
export type ScoreBound = number | string;
|
|
27
|
+
/** A command: whether it writes, how it is built, and what its reply is read as. */
|
|
28
|
+
interface CommandDef<A extends unknown[], R, W extends boolean> {
|
|
29
|
+
readonly write: W;
|
|
30
|
+
readonly build: (...args: A) => Cmd;
|
|
31
|
+
readonly reply: (v: Value) => R;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* What runs now and is no command of its own to queue: a scan, which returns
|
|
35
|
+
* an iteration, and a subscription.
|
|
36
|
+
*/
|
|
37
|
+
interface RunDef<A extends unknown[], R, W extends boolean> {
|
|
38
|
+
readonly write: W;
|
|
39
|
+
readonly run: (t: Target, ...args: A) => R;
|
|
40
|
+
}
|
|
41
|
+
/** Every group, by the name it has on a database. */
|
|
42
|
+
declare const groups: {
|
|
43
|
+
generic: {
|
|
44
|
+
/** Whether the key exists. */
|
|
45
|
+
exists: CommandDef<[key: string], boolean, false>;
|
|
46
|
+
/**
|
|
47
|
+
* The seconds until the key expires: -1 if it never does, -2 if it does not
|
|
48
|
+
* exist.
|
|
49
|
+
*/
|
|
50
|
+
ttl: CommandDef<[key: string], number, false>;
|
|
51
|
+
/**
|
|
52
|
+
* The milliseconds until the key expires: -1 if it never does, -2 if it does
|
|
53
|
+
* not exist.
|
|
54
|
+
*/
|
|
55
|
+
pttl: CommandDef<[key: string], number, false>;
|
|
56
|
+
/**
|
|
57
|
+
* The type of the value at the key: `string`, `list`, `set`, `zset`, `hash`,
|
|
58
|
+
* `stream`, or `none` if it does not exist.
|
|
59
|
+
*/
|
|
60
|
+
keyType: CommandDef<[key: string], string, false>;
|
|
61
|
+
/**
|
|
62
|
+
* The Unix time, in seconds, the key expires at: -1 if it never does, -2 if
|
|
63
|
+
* it does not exist.
|
|
64
|
+
*/
|
|
65
|
+
expireTime: CommandDef<[key: string], number, false>;
|
|
66
|
+
/** Iterates over the database's keys. */
|
|
67
|
+
scan: RunDef<[options?: ScanOptions | undefined], AsyncGenerator<string, any, unknown>, false>;
|
|
68
|
+
/** Deletes the keys, returning how many existed. */
|
|
69
|
+
del: CommandDef<string[], number, true>;
|
|
70
|
+
/**
|
|
71
|
+
* Deletes the keys, reclaiming their memory in the background. Returns how
|
|
72
|
+
* many existed.
|
|
73
|
+
*/
|
|
74
|
+
unlink: CommandDef<string[], number, true>;
|
|
75
|
+
/** Has the key expire in `seconds`. `false` if it does not exist. */
|
|
76
|
+
expire: CommandDef<[key: string, seconds: number], boolean, true>;
|
|
77
|
+
/** Has the key expire in `milliseconds`. `false` if it does not exist. */
|
|
78
|
+
pexpire: CommandDef<[key: string, milliseconds: number], boolean, true>;
|
|
79
|
+
/**
|
|
80
|
+
* Has the key expire at a Unix time, in seconds. `false` if it does not
|
|
81
|
+
* exist.
|
|
82
|
+
*/
|
|
83
|
+
expireAt: CommandDef<[key: string, timestamp: number], boolean, true>;
|
|
84
|
+
/** Removes the key's expiry. `false` if it had none, or does not exist. */
|
|
85
|
+
persist: CommandDef<[key: string], boolean, true>;
|
|
86
|
+
/** Renames the key, replacing `newKey` if it exists. */
|
|
87
|
+
rename: CommandDef<[key: string, newKey: string], void, true>;
|
|
88
|
+
/** Renames the key unless `newKey` exists. `false` if it does. */
|
|
89
|
+
renameNx: CommandDef<[key: string, newKey: string], boolean, true>;
|
|
90
|
+
/**
|
|
91
|
+
* Copies the value at `source` to `destination`. `false` if `destination`
|
|
92
|
+
* exists.
|
|
93
|
+
*/
|
|
94
|
+
copy: CommandDef<[source: string, destination: string], boolean, true>;
|
|
95
|
+
/** Marks the keys as used just now, returning how many exist. */
|
|
96
|
+
touch: CommandDef<string[], number, true>;
|
|
97
|
+
};
|
|
98
|
+
string: {
|
|
99
|
+
/** The value at the key: nil if it does not exist. */
|
|
100
|
+
get: CommandDef<[key: string], Reply, false>;
|
|
101
|
+
/**
|
|
102
|
+
* The values at the keys, in order, each missing one as nil: read it with
|
|
103
|
+
* {@link Reply.optionalTexts}.
|
|
104
|
+
*/
|
|
105
|
+
mget: CommandDef<string[], Reply, false>;
|
|
106
|
+
/** The length of the value at the key, in bytes. */
|
|
107
|
+
strlen: CommandDef<[key: string], number, false>;
|
|
108
|
+
/**
|
|
109
|
+
* The part of the value from byte `from` to byte `to`, inclusive. Negative
|
|
110
|
+
* offsets count from the end.
|
|
111
|
+
*/
|
|
112
|
+
getrange: CommandDef<[key: string, from: number, to: number], Reply, false>;
|
|
113
|
+
/** Sets the key to the value. */
|
|
114
|
+
set: CommandDef<[key: string, value: RedisArg], void, true>;
|
|
115
|
+
/** Sets the key to the value, expiring in `seconds`. */
|
|
116
|
+
setEx: CommandDef<[key: string, value: RedisArg, seconds: number], void, true>;
|
|
117
|
+
/** Sets the key to the value unless the key exists. `false` if it does. */
|
|
118
|
+
setNx: CommandDef<[key: string, value: RedisArg], boolean, true>;
|
|
119
|
+
/**
|
|
120
|
+
* Sets the key to the value as `options` say: only if it exists or does
|
|
121
|
+
* not, with an expiry, replying the old value.
|
|
122
|
+
*/
|
|
123
|
+
setOptions: CommandDef<[key: string, value: RedisArg, options: SetOptions], Reply, true>;
|
|
124
|
+
/** Sets each key to its value, all at once. */
|
|
125
|
+
mset: CommandDef<[items: Pairs<RedisArg>], void, true>;
|
|
126
|
+
/**
|
|
127
|
+
* Sets each key to its value unless any of the keys exists. `false` if one
|
|
128
|
+
* does, in which case none is set.
|
|
129
|
+
*/
|
|
130
|
+
msetNx: CommandDef<[items: Pairs<RedisArg>], boolean, true>;
|
|
131
|
+
/** The value at the key, which is deleted. */
|
|
132
|
+
getDel: CommandDef<[key: string], Reply, true>;
|
|
133
|
+
/** The value at the key, whose expiry is set as `expiry` says. */
|
|
134
|
+
getEx: CommandDef<[key: string, expiry: Expiry], Reply, true>;
|
|
135
|
+
/** Appends to the value at the key, returning its new length. */
|
|
136
|
+
append: CommandDef<[key: string, value: RedisArg], number, true>;
|
|
137
|
+
/** Overwrites the value from byte `offset`, returning its new length. */
|
|
138
|
+
setrange: CommandDef<[key: string, offset: number, value: RedisArg], number, true>;
|
|
139
|
+
/**
|
|
140
|
+
* Adds `delta` to the integer at the key, returning the result. A missing
|
|
141
|
+
* key counts as 0.
|
|
142
|
+
*/
|
|
143
|
+
incr: CommandDef<[key: string, delta: number | bigint], number, true>;
|
|
144
|
+
/**
|
|
145
|
+
* Adds `delta` to the number at the key, returning the result. A missing key
|
|
146
|
+
* counts as 0.
|
|
147
|
+
*/
|
|
148
|
+
incrFloat: CommandDef<[key: string, delta: number], number, true>;
|
|
149
|
+
/** Subtracts `delta` from the integer at the key, returning the result. */
|
|
150
|
+
decr: CommandDef<[key: string, delta: number | bigint], number, true>;
|
|
151
|
+
};
|
|
152
|
+
bitmap: {
|
|
153
|
+
/** The bit at `offset`. */
|
|
154
|
+
getbit: CommandDef<[key: string, offset: number], boolean, false>;
|
|
155
|
+
/** How many bits are set. */
|
|
156
|
+
bitcount: CommandDef<[key: string], number, false>;
|
|
157
|
+
/** How many bits are set from byte `start` to byte `end`, inclusive. */
|
|
158
|
+
bitcountRange: CommandDef<[key: string, start: number, end: number], number, false>;
|
|
159
|
+
/** The position of the first bit that is `bit`, or -1 if there is none. */
|
|
160
|
+
bitpos: CommandDef<[key: string, bit: boolean], number, false>;
|
|
161
|
+
/** Sets the bit at `offset`, returning what it was. */
|
|
162
|
+
setbit: CommandDef<[key: string, offset: number, value: boolean], boolean, true>;
|
|
163
|
+
/**
|
|
164
|
+
* Stores the AND of the sources at `destination`, returning its length in
|
|
165
|
+
* bytes.
|
|
166
|
+
*/
|
|
167
|
+
bitAnd: CommandDef<[destination: string, ...sources: string[]], number, true>;
|
|
168
|
+
/**
|
|
169
|
+
* Stores the OR of the sources at `destination`, returning its length in
|
|
170
|
+
* bytes.
|
|
171
|
+
*/
|
|
172
|
+
bitOr: CommandDef<[destination: string, ...sources: string[]], number, true>;
|
|
173
|
+
/**
|
|
174
|
+
* Stores the XOR of the sources at `destination`, returning its length in
|
|
175
|
+
* bytes.
|
|
176
|
+
*/
|
|
177
|
+
bitXor: CommandDef<[destination: string, ...sources: string[]], number, true>;
|
|
178
|
+
/**
|
|
179
|
+
* Stores the inverse of the source at `destination`, returning its length in
|
|
180
|
+
* bytes.
|
|
181
|
+
*/
|
|
182
|
+
bitNot: CommandDef<[destination: string, source: string], number, true>;
|
|
183
|
+
};
|
|
184
|
+
hash: {
|
|
185
|
+
/** The value of a field: nil if it does not exist. */
|
|
186
|
+
hget: CommandDef<[key: string, field: RedisArg], Reply, false>;
|
|
187
|
+
/**
|
|
188
|
+
* The values of the fields, in order, each missing one as nil: read it with
|
|
189
|
+
* {@link Reply.optionalTexts}.
|
|
190
|
+
*/
|
|
191
|
+
hmget: CommandDef<[key: string, ...fields: RedisArg[]], Reply, false>;
|
|
192
|
+
/** Every field and its value: read it with {@link Reply.textMap}. */
|
|
193
|
+
hgetall: CommandDef<[key: string], Reply, false>;
|
|
194
|
+
/** Whether the field exists. */
|
|
195
|
+
hexists: CommandDef<[key: string, field: RedisArg], boolean, false>;
|
|
196
|
+
/** How many fields the hash has. */
|
|
197
|
+
hlen: CommandDef<[key: string], number, false>;
|
|
198
|
+
/** The names of the fields. */
|
|
199
|
+
hkeys: CommandDef<[key: string], Reply, false>;
|
|
200
|
+
/** The values of the fields. */
|
|
201
|
+
hvals: CommandDef<[key: string], Reply, false>;
|
|
202
|
+
/** The name of a field chosen at random. */
|
|
203
|
+
hrandfield: CommandDef<[key: string], Reply, false>;
|
|
204
|
+
/** Iterates over the hash's fields, each with its value. */
|
|
205
|
+
hscan: RunDef<[key: string, options?: ScanOptions | undefined], AsyncGenerator<import("./reply.js").FieldValue, any, unknown>, false>;
|
|
206
|
+
/** Sets a field, returning 1 if it is new and 0 if it was replaced. */
|
|
207
|
+
hset: CommandDef<[key: string, field: RedisArg, value: RedisArg], number, true>;
|
|
208
|
+
/** Sets several fields, returning how many are new. */
|
|
209
|
+
hsetMultiple: CommandDef<[key: string, items: Pairs<RedisArg>], number, true>;
|
|
210
|
+
/** Sets a field unless it exists. `false` if it does. */
|
|
211
|
+
hsetNx: CommandDef<[key: string, field: RedisArg, value: RedisArg], boolean, true>;
|
|
212
|
+
/** Deletes the fields, returning how many existed. */
|
|
213
|
+
hdel: CommandDef<[key: string, ...fields: RedisArg[]], number, true>;
|
|
214
|
+
/** Adds `delta` to the integer in a field, returning the result. */
|
|
215
|
+
hincr: CommandDef<[key: string, field: RedisArg, delta: number | bigint], number, true>;
|
|
216
|
+
/** Adds `delta` to the number in a field, returning the result. */
|
|
217
|
+
hincrFloat: CommandDef<[key: string, field: RedisArg, delta: number], number, true>;
|
|
218
|
+
};
|
|
219
|
+
list: {
|
|
220
|
+
/**
|
|
221
|
+
* The elements from index `start` to index `stop`, inclusive. Negative
|
|
222
|
+
* indexes count from the end: `0, -1` is the whole list.
|
|
223
|
+
*/
|
|
224
|
+
lrange: CommandDef<[key: string, start: number, stop: number], Reply, false>;
|
|
225
|
+
/** The element at an index. */
|
|
226
|
+
lindex: CommandDef<[key: string, index: number], Reply, false>;
|
|
227
|
+
/** How many elements the list has. */
|
|
228
|
+
llen: CommandDef<[key: string], number, false>;
|
|
229
|
+
/** The index of the first element equal to `value`: `null` if there is none. */
|
|
230
|
+
lpos: CommandDef<[key: string, value: RedisArg], number | null, false>;
|
|
231
|
+
/** Prepends the values, returning the list's new length. */
|
|
232
|
+
lpush: CommandDef<[key: string, ...values: RedisArg[]], number, true>;
|
|
233
|
+
/** Appends the values, returning the list's new length. */
|
|
234
|
+
rpush: CommandDef<[key: string, ...values: RedisArg[]], number, true>;
|
|
235
|
+
/** Prepends the values if the list exists, returning its length. */
|
|
236
|
+
lpushExists: CommandDef<[key: string, ...values: RedisArg[]], number, true>;
|
|
237
|
+
/** Appends the values if the list exists, returning its length. */
|
|
238
|
+
rpushExists: CommandDef<[key: string, ...values: RedisArg[]], number, true>;
|
|
239
|
+
/**
|
|
240
|
+
* Removes and returns the first element, or with a `count`, that many, as a
|
|
241
|
+
* list.
|
|
242
|
+
*/
|
|
243
|
+
lpop: CommandDef<[key: string, count?: number | undefined], Reply, true>;
|
|
244
|
+
/**
|
|
245
|
+
* Removes and returns the last element, or with a `count`, that many, as a
|
|
246
|
+
* list.
|
|
247
|
+
*/
|
|
248
|
+
rpop: CommandDef<[key: string, count?: number | undefined], Reply, true>;
|
|
249
|
+
/** Replaces the element at an index. */
|
|
250
|
+
lset: CommandDef<[key: string, index: number, value: RedisArg], void, true>;
|
|
251
|
+
/** Keeps only the elements from index `start` to index `stop`, inclusive. */
|
|
252
|
+
ltrim: CommandDef<[key: string, start: number, stop: number], void, true>;
|
|
253
|
+
/**
|
|
254
|
+
* Inserts the value before the first element equal to `pivot`, returning
|
|
255
|
+
* the list's new length, or -1 if there is no such element.
|
|
256
|
+
*/
|
|
257
|
+
linsertBefore: CommandDef<[key: string, pivot: RedisArg, value: RedisArg], number, true>;
|
|
258
|
+
/**
|
|
259
|
+
* Inserts the value after the first element equal to `pivot`, returning the
|
|
260
|
+
* list's new length, or -1 if there is no such element.
|
|
261
|
+
*/
|
|
262
|
+
linsertAfter: CommandDef<[key: string, pivot: RedisArg, value: RedisArg], number, true>;
|
|
263
|
+
/**
|
|
264
|
+
* Removes elements equal to `value`: the first `count` of them, the last
|
|
265
|
+
* `-count` if it is negative, or all if it is 0. Returns how many.
|
|
266
|
+
*/
|
|
267
|
+
lrem: CommandDef<[key: string, count: number, value: RedisArg], number, true>;
|
|
268
|
+
/**
|
|
269
|
+
* Moves an element from one end of `source` to one end of `destination`,
|
|
270
|
+
* returning it.
|
|
271
|
+
*/
|
|
272
|
+
lmove: CommandDef<[source: string, destination: string, from: Direction, to: Direction], Reply, true>;
|
|
273
|
+
};
|
|
274
|
+
set: {
|
|
275
|
+
/** Every member. */
|
|
276
|
+
smembers: CommandDef<[key: string], Reply, false>;
|
|
277
|
+
/** Whether the value is a member. */
|
|
278
|
+
sismember: CommandDef<[key: string, member: RedisArg], boolean, false>;
|
|
279
|
+
/** Whether each of the values is a member, in order. */
|
|
280
|
+
smismember: CommandDef<[key: string, ...members: RedisArg[]], boolean[], false>;
|
|
281
|
+
/** How many members the set has. */
|
|
282
|
+
scard: CommandDef<[key: string], number, false>;
|
|
283
|
+
/** A member chosen at random. */
|
|
284
|
+
srandmember: CommandDef<[key: string], Reply, false>;
|
|
285
|
+
/**
|
|
286
|
+
* `count` distinct members chosen at random, or with a negative `count` that
|
|
287
|
+
* many, possibly repeated.
|
|
288
|
+
*/
|
|
289
|
+
srandmemberMultiple: CommandDef<[key: string, count: number], Reply, false>;
|
|
290
|
+
/** The members of the first set that are in none of the others. */
|
|
291
|
+
sdiff: CommandDef<string[], Reply, false>;
|
|
292
|
+
/** The members that are in every one of the sets. */
|
|
293
|
+
sinter: CommandDef<string[], Reply, false>;
|
|
294
|
+
/** The members that are in any of the sets. */
|
|
295
|
+
sunion: CommandDef<string[], Reply, false>;
|
|
296
|
+
/** Iterates over the set's members. */
|
|
297
|
+
sscan: RunDef<[key: string, options?: ScanOptions | undefined], AsyncGenerator<string, any, unknown>, false>;
|
|
298
|
+
/** Adds the members, returning how many are new. */
|
|
299
|
+
sadd: CommandDef<[key: string, ...members: RedisArg[]], number, true>;
|
|
300
|
+
/** Removes the members, returning how many there were. */
|
|
301
|
+
srem: CommandDef<[key: string, ...members: RedisArg[]], number, true>;
|
|
302
|
+
/** Removes and returns a member chosen at random. */
|
|
303
|
+
spop: CommandDef<[key: string], Reply, true>;
|
|
304
|
+
/**
|
|
305
|
+
* Moves a member from one set to another. `false` if it is not in `source`.
|
|
306
|
+
*/
|
|
307
|
+
smove: CommandDef<[source: string, destination: string, member: RedisArg], boolean, true>;
|
|
308
|
+
/** Stores `sdiff` of the sets at `destination`, returning its size. */
|
|
309
|
+
sdiffstore: CommandDef<[destination: string, ...keys: string[]], number, true>;
|
|
310
|
+
/** Stores `sinter` of the sets at `destination`, returning its size. */
|
|
311
|
+
sinterstore: CommandDef<[destination: string, ...keys: string[]], number, true>;
|
|
312
|
+
/** Stores `sunion` of the sets at `destination`, returning its size. */
|
|
313
|
+
sunionstore: CommandDef<[destination: string, ...keys: string[]], number, true>;
|
|
314
|
+
};
|
|
315
|
+
sortedSet: {
|
|
316
|
+
/**
|
|
317
|
+
* The members ranked `start` to `stop`, inclusive, lowest score first.
|
|
318
|
+
* Negative ranks count from the highest: `0, -1` is every member.
|
|
319
|
+
*/
|
|
320
|
+
zrange: CommandDef<[key: string, start: number, stop: number], Reply, false>;
|
|
321
|
+
/**
|
|
322
|
+
* `zrange`, each member with its score: read it with
|
|
323
|
+
* {@link Reply.scoredMembers}.
|
|
324
|
+
*/
|
|
325
|
+
zrangeWithscores: CommandDef<[key: string, start: number, stop: number], Reply, false>;
|
|
326
|
+
/** The members ranked `start` to `stop`, inclusive, highest score first. */
|
|
327
|
+
zrevrange: CommandDef<[key: string, start: number, stop: number], Reply, false>;
|
|
328
|
+
/**
|
|
329
|
+
* `zrevrange`, each member with its score: read it with
|
|
330
|
+
* {@link Reply.scoredMembers}.
|
|
331
|
+
*/
|
|
332
|
+
zrevrangeWithscores: CommandDef<[key: string, start: number, stop: number], Reply, false>;
|
|
333
|
+
/** The members with a score from `min` to `max`, lowest first. */
|
|
334
|
+
zrangebyscore: CommandDef<[key: string, min: ScoreBound, max: ScoreBound], Reply, false>;
|
|
335
|
+
/**
|
|
336
|
+
* `zrangebyscore`, each member with its score: read it with
|
|
337
|
+
* {@link Reply.scoredMembers}.
|
|
338
|
+
*/
|
|
339
|
+
zrangebyscoreWithscores: CommandDef<[key: string, min: ScoreBound, max: ScoreBound], Reply, false>;
|
|
340
|
+
/** A member's score: `null` if it is not a member. */
|
|
341
|
+
zscore: CommandDef<[key: string, member: RedisArg], number | null, false>;
|
|
342
|
+
/**
|
|
343
|
+
* A member's rank, lowest score first, from 0: `null` if it is not a
|
|
344
|
+
* member.
|
|
345
|
+
*/
|
|
346
|
+
zrank: CommandDef<[key: string, member: RedisArg], number | null, false>;
|
|
347
|
+
/**
|
|
348
|
+
* A member's rank, highest score first, from 0: `null` if it is not a
|
|
349
|
+
* member.
|
|
350
|
+
*/
|
|
351
|
+
zrevrank: CommandDef<[key: string, member: RedisArg], number | null, false>;
|
|
352
|
+
/** How many members the set has. */
|
|
353
|
+
zcard: CommandDef<[key: string], number, false>;
|
|
354
|
+
/** How many members have a score from `min` to `max`. */
|
|
355
|
+
zcount: CommandDef<[key: string, min: ScoreBound, max: ScoreBound], number, false>;
|
|
356
|
+
/** A member chosen at random. */
|
|
357
|
+
zrandmember: CommandDef<[key: string], Reply, false>;
|
|
358
|
+
/** Iterates over the sorted set's members, each with its score. */
|
|
359
|
+
zscan: RunDef<[key: string, options?: ScanOptions | undefined], AsyncGenerator<import("./reply.js").ScoredMember, any, unknown>, false>;
|
|
360
|
+
/**
|
|
361
|
+
* Adds a member with a score, or updates its score. Returns 1 if it is new.
|
|
362
|
+
*/
|
|
363
|
+
zadd: CommandDef<[key: string, member: RedisArg, score: number], number, true>;
|
|
364
|
+
/**
|
|
365
|
+
* Adds several members, each with its score, returning how many are new.
|
|
366
|
+
*/
|
|
367
|
+
zaddMultiple: CommandDef<[key: string, items: Pairs<number>], number, true>;
|
|
368
|
+
/** Removes the members, returning how many there were. */
|
|
369
|
+
zrem: CommandDef<[key: string, ...members: RedisArg[]], number, true>;
|
|
370
|
+
/** Adds `delta` to a member's score, returning the result. */
|
|
371
|
+
zincr: CommandDef<[key: string, member: RedisArg, delta: number], number, true>;
|
|
372
|
+
/**
|
|
373
|
+
* Removes and returns the `count` members with the lowest scores, each with
|
|
374
|
+
* its score: read it with {@link Reply.scoredMembers}.
|
|
375
|
+
*/
|
|
376
|
+
zpopmin: CommandDef<[key: string, count: number], Reply, true>;
|
|
377
|
+
/**
|
|
378
|
+
* Removes and returns the `count` members with the highest scores, each
|
|
379
|
+
* with its score: read it with {@link Reply.scoredMembers}.
|
|
380
|
+
*/
|
|
381
|
+
zpopmax: CommandDef<[key: string, count: number], Reply, true>;
|
|
382
|
+
/**
|
|
383
|
+
* Removes the members with a score from `min` to `max`, returning how many.
|
|
384
|
+
*/
|
|
385
|
+
zrembyscore: CommandDef<[key: string, min: ScoreBound, max: ScoreBound], number, true>;
|
|
386
|
+
/** Removes the members ranked `start` to `stop`, returning how many. */
|
|
387
|
+
zremrangebyrank: CommandDef<[key: string, start: number, stop: number], number, true>;
|
|
388
|
+
/**
|
|
389
|
+
* Stores at `destination` the members in every one of the sets, their
|
|
390
|
+
* scores summed. Returns its size.
|
|
391
|
+
*/
|
|
392
|
+
zinterstore: CommandDef<[destination: string, ...keys: string[]], number, true>;
|
|
393
|
+
/**
|
|
394
|
+
* Stores at `destination` the members in any of the sets, their scores
|
|
395
|
+
* summed. Returns its size.
|
|
396
|
+
*/
|
|
397
|
+
zunionstore: CommandDef<[destination: string, ...keys: string[]], number, true>;
|
|
398
|
+
};
|
|
399
|
+
geo: {
|
|
400
|
+
/**
|
|
401
|
+
* The positions of the members, each missing one as nil: read it with
|
|
402
|
+
* {@link Reply.geoPositions}.
|
|
403
|
+
*/
|
|
404
|
+
geoPos: CommandDef<[key: string, ...members: RedisArg[]], Reply, false>;
|
|
405
|
+
/** The distance between two members: `null` if either is not a member. */
|
|
406
|
+
geoDist: CommandDef<[key: string, from: RedisArg, to: RedisArg, unit: Unit], number | null, false>;
|
|
407
|
+
/** The geohash of each member. */
|
|
408
|
+
geoHash: CommandDef<[key: string, ...members: RedisArg[]], Reply, false>;
|
|
409
|
+
/**
|
|
410
|
+
* The members within `radius` of a position: read it with
|
|
411
|
+
* {@link Reply.geoRadius}.
|
|
412
|
+
*/
|
|
413
|
+
geoRadius: CommandDef<[key: string, longitude: number, latitude: number, radius: number, unit: Unit, options?: RadiusOptions | undefined], Reply, false>;
|
|
414
|
+
/**
|
|
415
|
+
* The members within `radius` of another member: read it with
|
|
416
|
+
* {@link Reply.geoRadius}.
|
|
417
|
+
*/
|
|
418
|
+
geoRadiusByMember: CommandDef<[key: string, member: RedisArg, radius: number, unit: Unit, options?: RadiusOptions | undefined], Reply, false>;
|
|
419
|
+
/** Adds a member at a position, or moves it there. Returns 1 if it is new. */
|
|
420
|
+
geoAdd: CommandDef<[key: string, longitude: number, latitude: number, member: RedisArg], number, true>;
|
|
421
|
+
};
|
|
422
|
+
stream: {
|
|
423
|
+
/**
|
|
424
|
+
* The entries with an id from `start` to `end`, oldest first. `"-"` and
|
|
425
|
+
* `"+"` are the lowest and highest ids. Read it with
|
|
426
|
+
* {@link Reply.streamEntries}.
|
|
427
|
+
*/
|
|
428
|
+
xrange: CommandDef<[key: string, start: string, end: string], Reply, false>;
|
|
429
|
+
/** `xrange`, at most `count` entries. */
|
|
430
|
+
xrangeCount: CommandDef<[key: string, start: string, end: string, count: number], Reply, false>;
|
|
431
|
+
/** The entries with an id from `end` down to `start`, newest first. */
|
|
432
|
+
xrevrange: CommandDef<[key: string, end: string, start: string], Reply, false>;
|
|
433
|
+
/** `xrevrange`, at most `count` entries. */
|
|
434
|
+
xrevrangeCount: CommandDef<[key: string, end: string, start: string, count: number], Reply, false>;
|
|
435
|
+
/** How many entries the stream has. */
|
|
436
|
+
xlen: CommandDef<[key: string], number, false>;
|
|
437
|
+
/**
|
|
438
|
+
* The entries after an id in each of the streams, `ids` giving the id for
|
|
439
|
+
* each of `keys` in order. Returns at once with what is there. Read it with
|
|
440
|
+
* {@link Reply.streams}.
|
|
441
|
+
*/
|
|
442
|
+
xread: CommandDef<[keys: string[], ids: string[]], Reply, false>;
|
|
443
|
+
/**
|
|
444
|
+
* A summary of the entries a consumer group has been given and not
|
|
445
|
+
* acknowledged: read it with {@link Reply.streamPending}.
|
|
446
|
+
*/
|
|
447
|
+
xpending: CommandDef<[key: string, group: string], Reply, false>;
|
|
448
|
+
/**
|
|
449
|
+
* What the server knows about the stream: read it with
|
|
450
|
+
* {@link Reply.streamInfo}.
|
|
451
|
+
*/
|
|
452
|
+
xinfoStream: CommandDef<[key: string], Reply, false>;
|
|
453
|
+
/**
|
|
454
|
+
* Appends an entry with the given fields, replying its id. Pass `"*"` as
|
|
455
|
+
* the id to have the server choose it.
|
|
456
|
+
*/
|
|
457
|
+
xadd: CommandDef<[key: string, id: string, fields: Pairs<RedisArg>], Reply, true>;
|
|
458
|
+
/** `xadd`, trimming the stream to a maximum length. */
|
|
459
|
+
xaddMaxlen: CommandDef<[key: string, maxlen: StreamMaxlen, id: string, fields: Pairs<RedisArg>], Reply, true>;
|
|
460
|
+
/** Deletes the entries with the given ids, returning how many existed. */
|
|
461
|
+
xdel: CommandDef<[key: string, ...ids: string[]], number, true>;
|
|
462
|
+
/**
|
|
463
|
+
* Trims the stream to a maximum length, returning how many entries were
|
|
464
|
+
* removed.
|
|
465
|
+
*/
|
|
466
|
+
xtrim: CommandDef<[key: string, maxlen: StreamMaxlen], number, true>;
|
|
467
|
+
/**
|
|
468
|
+
* Creates a consumer group that starts reading after `id`: `"$"` for only
|
|
469
|
+
* new entries, `"0"` for all. The stream must exist.
|
|
470
|
+
*/
|
|
471
|
+
xgroupCreate: CommandDef<[key: string, group: string, id: string], void, true>;
|
|
472
|
+
/** `xgroupCreate`, creating the stream if it does not exist. */
|
|
473
|
+
xgroupCreateMkstream: CommandDef<[key: string, group: string, id: string], void, true>;
|
|
474
|
+
/** Deletes a consumer group. `false` if there was none. */
|
|
475
|
+
xgroupDestroy: CommandDef<[key: string, group: string], boolean, true>;
|
|
476
|
+
/**
|
|
477
|
+
* Reads entries as `consumer` of a group: `">"` as the id for the ones no
|
|
478
|
+
* consumer has been given yet. With a `count`, at most that many per
|
|
479
|
+
* stream. A write: it records them as given to the consumer. Read it with
|
|
480
|
+
* {@link Reply.streams}.
|
|
481
|
+
*/
|
|
482
|
+
xreadGroup: CommandDef<[group: string, consumer: string, keys: string[], ids: string[], count?: number | undefined], Reply, true>;
|
|
483
|
+
/**
|
|
484
|
+
* Acknowledges entries a consumer group was given, returning how many were
|
|
485
|
+
* pending.
|
|
486
|
+
*/
|
|
487
|
+
xack: CommandDef<[key: string, group: string, ...ids: string[]], number, true>;
|
|
488
|
+
/**
|
|
489
|
+
* Takes over pending entries that have been idle for `minIdleMs`, for
|
|
490
|
+
* `consumer`: read it with {@link Reply.streamEntries}.
|
|
491
|
+
*/
|
|
492
|
+
xclaim: CommandDef<[key: string, group: string, consumer: string, minIdleMs: number, ...ids: string[]], Reply, true>;
|
|
493
|
+
/**
|
|
494
|
+
* Takes over the pending entries from id `start` that have been idle for
|
|
495
|
+
* `minIdleMs`, for `consumer`: read it with {@link Reply.streamAutoClaim}.
|
|
496
|
+
*/
|
|
497
|
+
xautoclaim: CommandDef<[key: string, group: string, consumer: string, minIdleMs: number, start: string], Reply, true>;
|
|
498
|
+
};
|
|
499
|
+
pubsub: {
|
|
500
|
+
/** Subscribes to one or more channels, on a connection of its own. */
|
|
501
|
+
subscribe: RunDef<string[], Promise<Subscription>, false>;
|
|
502
|
+
/**
|
|
503
|
+
* Subscribes to the channels matching one or more glob-style patterns, on a
|
|
504
|
+
* connection of its own.
|
|
505
|
+
*/
|
|
506
|
+
psubscribe: RunDef<string[], Promise<Subscription>, false>;
|
|
507
|
+
/**
|
|
508
|
+
* Publishes a message to a channel, returning how many subscribers received
|
|
509
|
+
* it. A channel is prefixed like a key, so only this database's subscribers
|
|
510
|
+
* hear it.
|
|
511
|
+
*/
|
|
512
|
+
publish: CommandDef<[channel: string, message: RedisArg], number, true>;
|
|
513
|
+
};
|
|
514
|
+
};
|
|
515
|
+
type Groups = typeof groups;
|
|
516
|
+
/** A command run now: a reply for the caller to read, or one of one shape. */
|
|
517
|
+
type RunForm<D> = D extends CommandDef<infer A, infer R, boolean> ? (...args: A) => R extends Reply ? ReplyPromise : Promise<R> : D extends RunDef<infer A, infer R, boolean> ? (...args: A) => R : never;
|
|
518
|
+
/** A command group's commands, run as they are called. */
|
|
519
|
+
export type Commands<G> = {
|
|
520
|
+
readonly [K in keyof G]: RunForm<G[K]>;
|
|
521
|
+
};
|
|
522
|
+
/** A command group's commands that only read. */
|
|
523
|
+
export type ReadCommands<G> = {
|
|
524
|
+
readonly [K in keyof G as G[K] extends {
|
|
525
|
+
write: false;
|
|
526
|
+
} ? K : never]: RunForm<G[K]>;
|
|
527
|
+
};
|
|
528
|
+
/**
|
|
529
|
+
* A command group's commands, queued on a pipeline or a transaction. What
|
|
530
|
+
* each replies is read from `exec`, in the order queued.
|
|
531
|
+
*/
|
|
532
|
+
export type Queue<G> = {
|
|
533
|
+
readonly [K in keyof G as G[K] extends CommandDef<any, any, boolean> ? K : never]: G[K] extends CommandDef<infer A, any, boolean> ? (...args: A) => Queue<G> : never;
|
|
534
|
+
};
|
|
535
|
+
/** Commands that work on a key of any type: expiry, deletion, renaming. */
|
|
536
|
+
export type GenericCommands = Commands<Groups['generic']>;
|
|
537
|
+
/** Commands on strings, which is what a plain value is. */
|
|
538
|
+
export type StringCommands = Commands<Groups['string']>;
|
|
539
|
+
/** Commands on the bits of a string. */
|
|
540
|
+
export type BitmapCommands = Commands<Groups['bitmap']>;
|
|
541
|
+
/** Commands on hashes: a key holding fields, each with a value. */
|
|
542
|
+
export type HashCommands = Commands<Groups['hash']>;
|
|
543
|
+
/** Commands on lists. */
|
|
544
|
+
export type ListCommands = Commands<Groups['list']>;
|
|
545
|
+
/** Commands on sets. */
|
|
546
|
+
export type SetCommands = Commands<Groups['set']>;
|
|
547
|
+
/** Commands on sorted sets: members ordered by a score. */
|
|
548
|
+
export type SortedSetCommands = Commands<Groups['sortedSet']>;
|
|
549
|
+
/** Commands on geospatial indexes. */
|
|
550
|
+
export type GeoCommands = Commands<Groups['geo']>;
|
|
551
|
+
/** Commands on streams. */
|
|
552
|
+
export type StreamCommands = Commands<Groups['stream']>;
|
|
553
|
+
/** Publishing to channels, and subscribing to them. */
|
|
554
|
+
export type PubsubCommands = Commands<Groups['pubsub']>;
|
|
555
|
+
/** The command groups of a database, a writing handle and a connection. */
|
|
556
|
+
export type CommandGroups = {
|
|
557
|
+
readonly [G in keyof Groups]: Commands<Groups[G]>;
|
|
558
|
+
};
|
|
559
|
+
/** The command groups of a handle that can only read. */
|
|
560
|
+
export type ReadCommandGroups = {
|
|
561
|
+
readonly [G in keyof Groups]: ReadCommands<Groups[G]>;
|
|
562
|
+
};
|
|
563
|
+
/** The command groups of a pipeline or a transaction. */
|
|
564
|
+
export type QueueGroups = {
|
|
565
|
+
readonly [G in keyof Groups]: Queue<Groups[G]>;
|
|
566
|
+
};
|
|
567
|
+
/** The command groups of `t`, each running its commands as they are called. */
|
|
568
|
+
export declare function commandGroups(t: Target): CommandGroups;
|
|
569
|
+
/** The command groups of `t` that only read. */
|
|
570
|
+
export declare function readCommandGroups(t: Target): ReadCommandGroups;
|
|
571
|
+
/** The command groups of a pipeline or a transaction, queueing on `queue`. */
|
|
572
|
+
export declare function queueGroups(queue: Cmd[]): QueueGroups;
|
|
573
|
+
export {};
|