@upstash/redis
Advanced tools
Comparing version 1.0.0-alpha.1 to 1.0.0-alpha.2
@@ -1,3 +0,4 @@ | ||
import { au as Command, N as NonEmptyArray } from './zunionstore-462de5d3'; | ||
export { A as AppendCommand, B as BitCountCommand, a as BitPosCommand, b as DecrByCommand, D as DecrCommand, c as DelCommand, E as EchoCommand, d as ExistsCommand, f as ExpireAtCommand, e as ExpireCommand, F as FlushAllCommand, g as FlushDBCommand, h as GetBitCommand, G as GetCommand, i as GetRangeCommand, j as HDelCommand, k as HExistsCommand, m as HGetAllCommand, l as HGetCommand, n as HIncrByCommand, o as HIncrByFloatCommand, p as HKeysCommand, q as HLenCommand, r as HMGetCommand, s as HScanCommand, t as HStrLenCommand, u as HValsCommand, v as IncrByCommand, w as IncrByFloatCommand, I as IncrCommand, K as KeysCommand, L as LIndexCommand, x as LLenCommand, y as LPopCommand, z as LRangeCommand, J as LTrimCommand, M as MGetCommand, Q as PExpireAtCommand, O as PExpireCommand, S as PTtlCommand, P as PersistCommand, R as PingCommand, V as RPopCommand, T as RenameCommand, U as RenameNXCommand, X as SCardCommand, Y as SDiffCommand, Z as SDiffStoreCommand, a1 as SInterCommand, a2 as SInterStoreCommand, a3 as SMembersCommand, a4 as SPopCommand, a5 as SRandMemberCommand, a6 as SScanCommand, a8 as SUnionCommand, a9 as SUnionStoreCommand, W as ScanCommand, av as ScanCommandOptions, ae as ScoreMember, $ as SetBitCommand, aw as SetCommand, _ as SetCommandOptions, a0 as SetRangeCommand, a7 as StrLenCommand, aa as TouchCommand, ab as TtlCommand, at as Type, ac as TypeCommand, ad as UnlinkCommand, ax as ZAddCommand, af as ZAddCommandOptions, ag as ZAddCommandOptionsWithIncr, ah as ZCardCommand, ai as ZCountCommand, aj as ZInterStoreCommand, ay as ZInterStoreCommandOptions, ak as ZLexCountCommand, al as ZPopMaxCommand, am as ZPopMinCommand, an as ZRangeCommand, az as ZRangeCommandOptions, ao as ZRemRangeByLexCommand, ap as ZRemRangeByRankCommand, aq as ZRemRangeByScoreCommand, ar as ZScanCommand, as as ZUnionStoreCommand, aA as ZUnionStoreCommandOptions } from './zunionstore-462de5d3'; | ||
import { at as Command, N as NonEmptyArray } from './zunionstore-dffa797d'; | ||
export { A as AppendCommand, B as BitCountCommand, a as BitPosCommand, b as DecrByCommand, D as DecrCommand, c as DelCommand, E as EchoCommand, d as ExistsCommand, f as ExpireAtCommand, e as ExpireCommand, F as FlushAllCommand, g as FlushDBCommand, h as GetBitCommand, G as GetCommand, i as GetRangeCommand, H as HDelCommand, j as HExistsCommand, l as HGetAllCommand, k as HGetCommand, m as HIncrByCommand, n as HIncrByFloatCommand, o as HKeysCommand, p as HLenCommand, q as HMGetCommand, r as HScanCommand, s as HStrLenCommand, t as HValsCommand, u as IncrByCommand, v as IncrByFloatCommand, I as IncrCommand, K as KeysCommand, L as LIndexCommand, w as LLenCommand, x as LPopCommand, y as LRangeCommand, z as LTrimCommand, M as MGetCommand, O as PExpireAtCommand, J as PExpireCommand, R as PTtlCommand, P as PersistCommand, Q as PingCommand, U as RPopCommand, S as RenameCommand, T as RenameNXCommand, W as SCardCommand, X as SDiffCommand, Y as SDiffStoreCommand, a0 as SInterCommand, a1 as SInterStoreCommand, a2 as SMembersCommand, a3 as SPopCommand, a4 as SRandMemberCommand, a5 as SScanCommand, a7 as SUnionCommand, a8 as SUnionStoreCommand, V as ScanCommand, au as ScanCommandOptions, ad as ScoreMember, _ as SetBitCommand, av as SetCommand, Z as SetCommandOptions, $ as SetRangeCommand, a6 as StrLenCommand, a9 as TouchCommand, aa as TtlCommand, as as Type, ab as TypeCommand, ac as UnlinkCommand, aw as ZAddCommand, ae as ZAddCommandOptions, af as ZAddCommandOptionsWithIncr, ag as ZCardCommand, ah as ZCountCommand, ai as ZInterStoreCommand, ax as ZInterStoreCommandOptions, aj as ZLexCountCommand, ak as ZPopMaxCommand, al as ZPopMinCommand, am as ZRangeCommand, ay as ZRangeCommandOptions, an as ZRemRangeByLexCommand, ao as ZRemRangeByRankCommand, ap as ZRemRangeByScoreCommand, aq as ZScanCommand, ar as ZUnionStoreCommand, az as ZUnionStoreCommandOptions } from './zunionstore-dffa797d'; | ||
import './http'; | ||
@@ -4,0 +5,0 @@ /** |
@@ -170,3 +170,3 @@ var __defProp = Object.defineProperty; | ||
async exec(client) { | ||
const { result, error } = await client.post({ | ||
const { result, error } = await client.request({ | ||
body: this.command | ||
@@ -173,0 +173,0 @@ }); |
1008
dist/index.d.ts
@@ -1,1005 +0,7 @@ | ||
import { H as HttpClient, C as CommandArgs, A as AppendCommand, B as BitCountCommand, a as BitPosCommand, D as DecrCommand, b as DecrByCommand, c as DelCommand, E as EchoCommand, d as ExistsCommand, e as ExpireCommand, f as ExpireAtCommand, F as FlushAllCommand, g as FlushDBCommand, G as GetCommand, h as GetBitCommand, i as GetRangeCommand, j as HDelCommand, k as HExistsCommand, l as HGetCommand, m as HGetAllCommand, n as HIncrByCommand, o as HIncrByFloatCommand, p as HKeysCommand, q as HLenCommand, r as HMGetCommand, s as HScanCommand, t as HStrLenCommand, u as HValsCommand, I as IncrCommand, v as IncrByCommand, w as IncrByFloatCommand, K as KeysCommand, L as LIndexCommand, x as LLenCommand, y as LPopCommand, N as NonEmptyArray, z as LRangeCommand, J as LTrimCommand, M as MGetCommand, P as PersistCommand, O as PExpireCommand, Q as PExpireAtCommand, R as PingCommand, S as PTtlCommand, T as RenameCommand, U as RenameNXCommand, V as RPopCommand, W as ScanCommand, X as SCardCommand, Y as SDiffCommand, Z as SDiffStoreCommand, _ as SetCommandOptions, $ as SetBitCommand, a0 as SetRangeCommand, a1 as SInterCommand, a2 as SInterStoreCommand, a3 as SMembersCommand, a4 as SPopCommand, a5 as SRandMemberCommand, a6 as SScanCommand, a7 as StrLenCommand, a8 as SUnionCommand, a9 as SUnionStoreCommand, aa as TouchCommand, ab as TtlCommand, ac as TypeCommand, ad as UnlinkCommand, ae as ScoreMember, af as ZAddCommandOptions, ag as ZAddCommandOptionsWithIncr, ah as ZCardCommand, ai as ZCountCommand, aj as ZInterStoreCommand, ak as ZLexCountCommand, al as ZPopMaxCommand, am as ZPopMinCommand, an as ZRangeCommand, ao as ZRemRangeByLexCommand, ap as ZRemRangeByRankCommand, aq as ZRemRangeByScoreCommand, ar as ZScanCommand, as as ZUnionStoreCommand, at as Type } from './zunionstore-462de5d3'; | ||
export { Redis, RedisConfigNodejs } from './nodejs'; | ||
import './redis-dd052782'; | ||
import './zunionstore-dffa797d'; | ||
import './http'; | ||
/** | ||
* Upstash REST API supports command pipelining to send multiple commands in | ||
* batch, instead of sending each command one by one and waiting for a response. | ||
* When using pipelines, several commands are sent using a single HTTP request, | ||
* and a single JSON array response is returned. Each item in the response array | ||
* corresponds to the command in the same order within the pipeline. | ||
* | ||
* **NOTE:** | ||
* | ||
* Execution of the pipeline is not atomic. Even though each command in | ||
* the pipeline will be executed in order, commands sent by other clients can | ||
* interleave with the pipeline. | ||
* | ||
* | ||
* **Examples:** | ||
* | ||
* ```ts | ||
* const p = redis.pipeline() | ||
* p.set("key","value") | ||
* p.get("key") | ||
* const res = await p.exec() | ||
* ``` | ||
* | ||
* You can also chain commands together | ||
* ```ts | ||
* const p = redis.pipeline() | ||
* const res = await p.set("key","value").get("key").exec() | ||
* ``` | ||
* | ||
* It's not possible to infer correct types with a dynamic pipeline, so you can | ||
* override the response type manually: | ||
* ```ts | ||
* redis.pipeline() | ||
* .set("key", { greeting: "hello"}) | ||
* .get("key") | ||
* .exec<["OK", { greeting: string } ]>() | ||
* | ||
* ``` | ||
*/ | ||
declare class Pipeline { | ||
private client; | ||
private commands; | ||
constructor(client: HttpClient); | ||
/** | ||
* Send the pipeline request to upstash. | ||
* | ||
* Returns an array with the results of all pipelined commands. | ||
* | ||
* You can define a return type manually to make working in typescript easier | ||
* ```ts | ||
* redis.pipeline().get("key").exec<[{ greeting: string }]>() | ||
* ``` | ||
*/ | ||
exec<TCommandResults extends unknown[] = unknown[]>(): Promise<TCommandResults>; | ||
/** | ||
* Pushes a command into the pipelien and returns a chainable instance of the | ||
* pipeline | ||
*/ | ||
private chain; | ||
/** | ||
* @see https://redis.io/commands/append | ||
*/ | ||
append(...args: CommandArgs<typeof AppendCommand>): this; | ||
/** | ||
* @see https://redis.io/commands/bitcount | ||
*/ | ||
bitcount(...args: CommandArgs<typeof BitCountCommand>): this; | ||
/** | ||
* @see https://redis.io/commands/bitop | ||
*/ | ||
bitop(op: "and" | "or" | "xor", destinationKey: string, sourceKey: string, ...sourceKeys: string[]): this; | ||
bitop(op: "not", destinationKey: string, sourceKey: string): this; | ||
/** | ||
* @see https://redis.io/commands/bitpos | ||
*/ | ||
bitpos(...args: CommandArgs<typeof BitPosCommand>): this; | ||
/** | ||
* @see https://redis.io/commands/dbsize | ||
*/ | ||
dbsize(): this; | ||
/** | ||
* @see https://redis.io/commands/decr | ||
*/ | ||
decr(...args: CommandArgs<typeof DecrCommand>): this; | ||
/** | ||
* @see https://redis.io/commands/decrby | ||
*/ | ||
decrby(...args: CommandArgs<typeof DecrByCommand>): this; | ||
/** | ||
* @see https://redis.io/commands/del | ||
*/ | ||
del(...args: CommandArgs<typeof DelCommand>): this; | ||
/** | ||
* @see https://redis.io/commands/echo | ||
*/ | ||
echo(...args: CommandArgs<typeof EchoCommand>): this; | ||
/** | ||
* @see https://redis.io/commands/exists | ||
*/ | ||
exists(...args: CommandArgs<typeof ExistsCommand>): this; | ||
/** | ||
* @see https://redis.io/commands/expire | ||
*/ | ||
expire(...args: CommandArgs<typeof ExpireCommand>): this; | ||
/** | ||
* @see https://redis.io/commands/expireat | ||
*/ | ||
expireat(...args: CommandArgs<typeof ExpireAtCommand>): this; | ||
/** | ||
* @see https://redis.io/commands/flushall | ||
*/ | ||
flushall(...args: CommandArgs<typeof FlushAllCommand>): this; | ||
/** | ||
* @see https://redis.io/commands/flushdb | ||
*/ | ||
flushdb(...args: CommandArgs<typeof FlushDBCommand>): this; | ||
/** | ||
* @see https://redis.io/commands/get | ||
*/ | ||
get<TData>(...args: CommandArgs<typeof GetCommand>): this; | ||
/** | ||
* @see https://redis.io/commands/getbit | ||
*/ | ||
getbit(...args: CommandArgs<typeof GetBitCommand>): this; | ||
/** | ||
* @see https://redis.io/commands/getrange | ||
*/ | ||
getrange(...args: CommandArgs<typeof GetRangeCommand>): this; | ||
/** | ||
* @see https://redis.io/commands/getset | ||
*/ | ||
getset<TData>(key: string, value: TData): this; | ||
/** | ||
* @see https://redis.io/commands/hdel | ||
*/ | ||
hdel(...args: CommandArgs<typeof HDelCommand>): this; | ||
/** | ||
* @see https://redis.io/commands/hexists | ||
*/ | ||
hexists(...args: CommandArgs<typeof HExistsCommand>): this; | ||
/** | ||
* @see https://redis.io/commands/hget | ||
*/ | ||
hget<TData>(...args: CommandArgs<typeof HGetCommand>): this; | ||
/** | ||
* @see https://redis.io/commands/hgetall | ||
*/ | ||
hgetall<TData extends Record<string, unknown>>(...args: CommandArgs<typeof HGetAllCommand>): this; | ||
/** | ||
* @see https://redis.io/commands/hincrby | ||
*/ | ||
hincrby(...args: CommandArgs<typeof HIncrByCommand>): this; | ||
/** | ||
* @see https://redis.io/commands/hincrbyfloat | ||
*/ | ||
hincrbyfloat(...args: CommandArgs<typeof HIncrByFloatCommand>): this; | ||
/** | ||
* @see https://redis.io/commands/hkeys | ||
*/ | ||
hkeys(...args: CommandArgs<typeof HKeysCommand>): this; | ||
/** | ||
* @see https://redis.io/commands/hlen | ||
*/ | ||
hlen(...args: CommandArgs<typeof HLenCommand>): this; | ||
/** | ||
* @see https://redis.io/commands/hmget | ||
*/ | ||
hmget<TData extends Record<string, unknown>>(...args: CommandArgs<typeof HMGetCommand>): this; | ||
/** | ||
* @see https://redis.io/commands/hmset | ||
*/ | ||
hmset<TData>(key: string, kv: { | ||
[field: string]: TData; | ||
}): this; | ||
/** | ||
* @see https://redis.io/commands/hscan | ||
*/ | ||
hscan(...args: CommandArgs<typeof HScanCommand>): this; | ||
/** | ||
* @see https://redis.io/commands/hset | ||
*/ | ||
hset<TData>(key: string, field: string, value: TData): this; | ||
/** | ||
* @see https://redis.io/commands/hsetnx | ||
*/ | ||
hsetnx<TData>(key: string, field: string, value: TData): this; | ||
/** | ||
* @see https://redis.io/commands/hstrlen | ||
*/ | ||
hstrlen(...args: CommandArgs<typeof HStrLenCommand>): this; | ||
/** | ||
* @see https://redis.io/commands/hvals | ||
*/ | ||
hvals(...args: CommandArgs<typeof HValsCommand>): this; | ||
/** | ||
* @see https://redis.io/commands/incr | ||
*/ | ||
incr(...args: CommandArgs<typeof IncrCommand>): this; | ||
/** | ||
* @see https://redis.io/commands/incrby | ||
*/ | ||
incrby(...args: CommandArgs<typeof IncrByCommand>): this; | ||
/** | ||
* @see https://redis.io/commands/incrbyfloat | ||
*/ | ||
incrbyfloat(...args: CommandArgs<typeof IncrByFloatCommand>): this; | ||
/** | ||
* @see https://redis.io/commands/keys | ||
*/ | ||
keys(...args: CommandArgs<typeof KeysCommand>): this; | ||
/** | ||
* @see https://redis.io/commands/lindex | ||
*/ | ||
lindex(...args: CommandArgs<typeof LIndexCommand>): this; | ||
/** | ||
* @see https://redis.io/commands/linsert | ||
*/ | ||
linsert<TData>(key: string, direction: "before" | "after", pivot: TData, value: TData): this; | ||
/** | ||
* @see https://redis.io/commands/llen | ||
*/ | ||
llen(...args: CommandArgs<typeof LLenCommand>): this; | ||
/** | ||
* @see https://redis.io/commands/lpop | ||
*/ | ||
lpop<TData>(...args: CommandArgs<typeof LPopCommand>): this; | ||
/** | ||
* @see https://redis.io/commands/lpush | ||
*/ | ||
lpush<TData>(key: string, ...elements: NonEmptyArray<TData>): this; | ||
/** | ||
* @see https://redis.io/commands/lpushx | ||
*/ | ||
lpushx<TData>(key: string, ...elements: NonEmptyArray<TData>): this; | ||
/** | ||
* @see https://redis.io/commands/lrange | ||
*/ | ||
lrange<TResult = string>(...args: CommandArgs<typeof LRangeCommand>): this; | ||
/** | ||
* @see https://redis.io/commands/lrem | ||
*/ | ||
lrem<TData>(key: string, count: number, value: TData): this; | ||
/** | ||
* @see https://redis.io/commands/lset | ||
*/ | ||
lset<TData>(key: string, value: TData, index: number): this; | ||
/** | ||
* @see https://redis.io/commands/ltrim | ||
*/ | ||
ltrim(...args: CommandArgs<typeof LTrimCommand>): this; | ||
/** | ||
* @see https://redis.io/commands/mget | ||
*/ | ||
mget<TData extends [unknown, ...unknown[]]>(...args: CommandArgs<typeof MGetCommand>): this; | ||
/** | ||
* @see https://redis.io/commands/mset | ||
*/ | ||
mset<TData>(kv: { | ||
[key: string]: TData; | ||
}): this; | ||
/** | ||
* @see https://redis.io/commands/msetnx | ||
*/ | ||
msetnx<TData>(kv: { | ||
[key: string]: TData; | ||
}): this; | ||
/** | ||
* @see https://redis.io/commands/persist | ||
*/ | ||
persist(...args: CommandArgs<typeof PersistCommand>): this; | ||
/** | ||
* @see https://redis.io/commands/pexpire | ||
*/ | ||
pexpire(...args: CommandArgs<typeof PExpireCommand>): this; | ||
/** | ||
* @see https://redis.io/commands/pexpireat | ||
*/ | ||
pexpireat(...args: CommandArgs<typeof PExpireAtCommand>): this; | ||
/** | ||
* @see https://redis.io/commands/ping | ||
*/ | ||
ping(...args: CommandArgs<typeof PingCommand>): this; | ||
/** | ||
* @see https://redis.io/commands/psetex | ||
*/ | ||
psetex<TData>(key: string, ttl: number, value: TData): this; | ||
/** | ||
* @see https://redis.io/commands/pttl | ||
*/ | ||
pttl(...args: CommandArgs<typeof PTtlCommand>): this; | ||
/** | ||
* @see https://redis.io/commands/randomkey | ||
*/ | ||
randomkey(): this; | ||
/** | ||
* @see https://redis.io/commands/rename | ||
*/ | ||
rename(...args: CommandArgs<typeof RenameCommand>): this; | ||
/** | ||
* @see https://redis.io/commands/renamenx | ||
*/ | ||
renamenx(...args: CommandArgs<typeof RenameNXCommand>): this; | ||
/** | ||
* @see https://redis.io/commands/rpop | ||
*/ | ||
rpop<TData = string>(...args: CommandArgs<typeof RPopCommand>): this; | ||
/** | ||
* @see https://redis.io/commands/rpush | ||
*/ | ||
rpush<TData>(key: string, ...elements: NonEmptyArray<TData>): this; | ||
/** | ||
* @see https://redis.io/commands/rpushx | ||
*/ | ||
rpushx<TData>(key: string, ...elements: NonEmptyArray<TData>): this; | ||
/** | ||
* @see https://redis.io/commands/sadd | ||
*/ | ||
sadd<TData>(key: string, ...members: NonEmptyArray<TData>): this; | ||
/** | ||
* @see https://redis.io/commands/scan | ||
*/ | ||
scan(...args: CommandArgs<typeof ScanCommand>): this; | ||
/** | ||
* @see https://redis.io/commands/scard | ||
*/ | ||
scard(...args: CommandArgs<typeof SCardCommand>): this; | ||
/** | ||
* @see https://redis.io/commands/sdiff | ||
*/ | ||
sdiff(...args: CommandArgs<typeof SDiffCommand>): this; | ||
/** | ||
* @see https://redis.io/commands/sdiffstore | ||
*/ | ||
sdiffstore(...args: CommandArgs<typeof SDiffStoreCommand>): this; | ||
/** | ||
* @see https://redis.io/commands/set | ||
*/ | ||
set<TData>(key: string, value: TData, opts?: SetCommandOptions): this; | ||
/** | ||
* @see https://redis.io/commands/setbit | ||
*/ | ||
setbit(...args: CommandArgs<typeof SetBitCommand>): this; | ||
/** | ||
* @see https://redis.io/commands/setex | ||
*/ | ||
setex<TData>(key: string, ttl: number, value: TData): this; | ||
/** | ||
* @see https://redis.io/commands/setnx | ||
*/ | ||
setnx<TData>(key: string, value: TData): this; | ||
/** | ||
* @see https://redis.io/commands/setrange | ||
*/ | ||
setrange(...args: CommandArgs<typeof SetRangeCommand>): this; | ||
/** | ||
* @see https://redis.io/commands/sinter | ||
*/ | ||
sinter(...args: CommandArgs<typeof SInterCommand>): this; | ||
/** | ||
* @see https://redis.io/commands/sinterstore | ||
*/ | ||
sinterstore(...args: CommandArgs<typeof SInterStoreCommand>): this; | ||
/** | ||
* @see https://redis.io/commands/sismember | ||
*/ | ||
sismember<TData>(key: string, member: TData): this; | ||
/** | ||
* @see https://redis.io/commands/smembers | ||
*/ | ||
smembers(...args: CommandArgs<typeof SMembersCommand>): this; | ||
/** | ||
* @see https://redis.io/commands/smove | ||
*/ | ||
smove<TData>(source: string, destination: string, member: TData): this; | ||
/** | ||
* @see https://redis.io/commands/spop | ||
*/ | ||
spop<TData>(...args: CommandArgs<typeof SPopCommand>): this; | ||
/** | ||
* @see https://redis.io/commands/srandmember | ||
*/ | ||
srandmember<TData>(...args: CommandArgs<typeof SRandMemberCommand>): this; | ||
/** | ||
* @see https://redis.io/commands/srem | ||
*/ | ||
srem<TData>(key: string, ...members: NonEmptyArray<TData>): this; | ||
/** | ||
* @see https://redis.io/commands/sscan | ||
*/ | ||
sscan(...args: CommandArgs<typeof SScanCommand>): this; | ||
/** | ||
* @see https://redis.io/commands/strlen | ||
*/ | ||
strlen(...args: CommandArgs<typeof StrLenCommand>): this; | ||
/** | ||
* @see https://redis.io/commands/sunion | ||
*/ | ||
sunion(...args: CommandArgs<typeof SUnionCommand>): this; | ||
/** | ||
* @see https://redis.io/commands/sunionstore | ||
*/ | ||
sunionstore(...args: CommandArgs<typeof SUnionStoreCommand>): this; | ||
/** | ||
* @see https://redis.io/commands/time | ||
*/ | ||
time(): this; | ||
/** | ||
* @see https://redis.io/commands/touch | ||
*/ | ||
touch(...args: CommandArgs<typeof TouchCommand>): this; | ||
/** | ||
* @see https://redis.io/commands/ttl | ||
*/ | ||
ttl(...args: CommandArgs<typeof TtlCommand>): this; | ||
/** | ||
* @see https://redis.io/commands/type | ||
*/ | ||
type(...args: CommandArgs<typeof TypeCommand>): this; | ||
/** | ||
* @see https://redis.io/commands/unlink | ||
*/ | ||
unlink(...args: CommandArgs<typeof UnlinkCommand>): this; | ||
/** | ||
* @see https://redis.io/commands/zadd | ||
*/ | ||
zadd<TData>(key: string, scoreMember: ScoreMember<TData>, ...scoreMemberPairs: ScoreMember<TData>[]): this; | ||
zadd<TData>(key: string, opts: ZAddCommandOptions | ZAddCommandOptionsWithIncr, ...scoreMemberPairs: [ScoreMember<TData>, ...ScoreMember<TData>[]]): this; | ||
/** | ||
* @see https://redis.io/commands/zcard | ||
*/ | ||
zcard(...args: CommandArgs<typeof ZCardCommand>): this; | ||
/** | ||
* @see https://redis.io/commands/zcount | ||
*/ | ||
zcount(...args: CommandArgs<typeof ZCountCommand>): this; | ||
/** | ||
* @see https://redis.io/commands/zincrby | ||
*/ | ||
zincrby<TData>(key: string, increment: number, member: TData): this; | ||
/** | ||
* @see https://redis.io/commands/zinterstore | ||
*/ | ||
zinterstore(...args: CommandArgs<typeof ZInterStoreCommand>): this; | ||
/** | ||
* @see https://redis.io/commands/zlexcount | ||
*/ | ||
zlexcount(...args: CommandArgs<typeof ZLexCountCommand>): this; | ||
/** | ||
* @see https://redis.io/commands/zpopmax | ||
*/ | ||
zpopmax<TData>(...args: CommandArgs<typeof ZPopMaxCommand>): this; | ||
/** | ||
* @see https://redis.io/commands/zpopmin | ||
*/ | ||
zpopmin<TData>(...args: CommandArgs<typeof ZPopMinCommand>): this; | ||
/** | ||
* @see https://redis.io/commands/zrange | ||
*/ | ||
zrange<TData extends unknown[]>(...args: CommandArgs<typeof ZRangeCommand>): this; | ||
/** | ||
* @see https://redis.io/commands/zrank | ||
*/ | ||
zrank<TData>(key: string, member: TData): this; | ||
/** | ||
* @see https://redis.io/commands/zrem | ||
*/ | ||
zrem<TData>(key: string, ...members: NonEmptyArray<TData>): this; | ||
/** | ||
* @see https://redis.io/commands/zremrangebylex | ||
*/ | ||
zremrangebylex(...args: CommandArgs<typeof ZRemRangeByLexCommand>): this; | ||
/** | ||
* @see https://redis.io/commands/zremrangebyrank | ||
*/ | ||
zremrangebyrank(...args: CommandArgs<typeof ZRemRangeByRankCommand>): this; | ||
/** | ||
* @see https://redis.io/commands/zremrangebyscore | ||
*/ | ||
zremrangebyscore(...args: CommandArgs<typeof ZRemRangeByScoreCommand>): this; | ||
/** | ||
* @see https://redis.io/commands/zrevrank | ||
*/ | ||
zrevrank<TData>(key: string, member: TData): this; | ||
/** | ||
* @see https://redis.io/commands/zscan | ||
*/ | ||
zscan(...args: CommandArgs<typeof ZScanCommand>): this; | ||
/** | ||
* @see https://redis.io/commands/zscore | ||
*/ | ||
zscore<TData>(key: string, member: TData): this; | ||
/** | ||
* @see https://redis.io/commands/zunionstore | ||
*/ | ||
zunionstore(...args: CommandArgs<typeof ZUnionStoreCommand>): this; | ||
} | ||
/** | ||
* Connection credentials for upstash redis. | ||
* Get them from https://console.upstash.com/redis/<uuid> | ||
*/ | ||
declare type RedisConfig = { | ||
/** | ||
* UPSTASH_REDIS_REST_URL | ||
*/ | ||
url: string; | ||
/** | ||
* UPSTASH_REDIS_REST_TOKEN | ||
*/ | ||
token: string; | ||
requestOptions?: { | ||
/** | ||
* **fastly only** | ||
* | ||
* A Request can be forwarded to any backend defined on your service. Backends | ||
* can be created via the Fastly CLI, API, or web interface, and are | ||
* referenced by name. | ||
*/ | ||
backend?: string; | ||
}; | ||
}; | ||
/** | ||
* Serverless redis client for upstash. | ||
*/ | ||
declare class Redis { | ||
private readonly client; | ||
/** | ||
* Create a new redis client | ||
* | ||
* @example | ||
* ```typescript | ||
* const redis = new Redis({ | ||
* url: "<UPSTASH_REDIS_REST_URL>", | ||
* token: "<UPSTASH_REDIS_REST_TOKEN>", | ||
* }); | ||
* ``` | ||
*/ | ||
constructor(config: RedisConfig); | ||
/** | ||
* Create a new Upstash Redis instance from environment variables. | ||
* | ||
* Use this to automatically load connection secrets from your environment | ||
* variables. For instance when using the Vercel integration. | ||
* | ||
* This tries to load `UPSTASH_REDIS_REST_URL` and `UPSTASH_REDIS_REST_TOKEN` from | ||
* your environment. | ||
* | ||
* If you are using Cloudflare, please use `fromCloudflareEnv()` instead. | ||
*/ | ||
static fromEnv(): Redis; | ||
/** | ||
* Create a new Upstash Redis instance from environment variables on cloudflare. | ||
* | ||
* This tries to load `UPSTASH_REDIS_REST_URL` and `UPSTASH_REDIS_REST_TOKEN` from | ||
* the global namespace | ||
*/ | ||
static fromCloudflareEnv(): Redis; | ||
/** | ||
* Create a new pipeline that allows you to send requests in bulk. | ||
* | ||
* @see {@link Pipeline} | ||
*/ | ||
pipeline(): Pipeline; | ||
/** | ||
* @see https://redis.io/commands/append | ||
*/ | ||
append(...args: CommandArgs<typeof AppendCommand>): Promise<number>; | ||
/** | ||
* @see https://redis.io/commands/bitcount | ||
*/ | ||
bitcount(...args: CommandArgs<typeof BitCountCommand>): Promise<number>; | ||
/** | ||
* @see https://redis.io/commands/bitop | ||
*/ | ||
bitop(op: "and" | "or" | "xor", destinationKey: string, sourceKey: string, ...sourceKeys: string[]): Promise<number>; | ||
bitop(op: "not", destinationKey: string, sourceKey: string): Promise<number>; | ||
/** | ||
* @see https://redis.io/commands/bitpos | ||
*/ | ||
bitpos(...args: CommandArgs<typeof BitPosCommand>): Promise<number>; | ||
/** | ||
* @see https://redis.io/commands/dbsize | ||
*/ | ||
dbsize(): Promise<number>; | ||
/** | ||
* @see https://redis.io/commands/decr | ||
*/ | ||
decr(...args: CommandArgs<typeof DecrCommand>): Promise<number>; | ||
/** | ||
* @see https://redis.io/commands/decrby | ||
*/ | ||
decrby(...args: CommandArgs<typeof DecrByCommand>): Promise<number>; | ||
/** | ||
* @see https://redis.io/commands/del | ||
*/ | ||
del(...args: CommandArgs<typeof DelCommand>): Promise<number>; | ||
/** | ||
* @see https://redis.io/commands/echo | ||
*/ | ||
echo(...args: CommandArgs<typeof EchoCommand>): Promise<string>; | ||
/** | ||
* @see https://redis.io/commands/exists | ||
*/ | ||
exists(...args: CommandArgs<typeof ExistsCommand>): Promise<0 | 1>; | ||
/** | ||
* @see https://redis.io/commands/expire | ||
*/ | ||
expire(...args: CommandArgs<typeof ExpireCommand>): Promise<0 | 1>; | ||
/** | ||
* @see https://redis.io/commands/expireat | ||
*/ | ||
expireat(...args: CommandArgs<typeof ExpireAtCommand>): Promise<0 | 1>; | ||
/** | ||
* @see https://redis.io/commands/flushall | ||
*/ | ||
flushall(...args: CommandArgs<typeof FlushAllCommand>): Promise<"OK">; | ||
/** | ||
* @see https://redis.io/commands/flushdb | ||
*/ | ||
flushdb(...args: CommandArgs<typeof FlushDBCommand>): Promise<"OK">; | ||
/** | ||
* @see https://redis.io/commands/get | ||
*/ | ||
get<TData>(...args: CommandArgs<typeof GetCommand>): Promise<TData | null>; | ||
/** | ||
* @see https://redis.io/commands/getbit | ||
*/ | ||
getbit(...args: CommandArgs<typeof GetBitCommand>): Promise<0 | 1>; | ||
/** | ||
* @see https://redis.io/commands/getrange | ||
*/ | ||
getrange(...args: CommandArgs<typeof GetRangeCommand>): Promise<string>; | ||
/** | ||
* @see https://redis.io/commands/getset | ||
*/ | ||
getset<TData>(key: string, value: TData): Promise<TData | null>; | ||
/** | ||
* @see https://redis.io/commands/hdel | ||
*/ | ||
hdel(...args: CommandArgs<typeof HDelCommand>): Promise<0 | 1>; | ||
/** | ||
* @see https://redis.io/commands/hexists | ||
*/ | ||
hexists(...args: CommandArgs<typeof HExistsCommand>): Promise<number>; | ||
/** | ||
* @see https://redis.io/commands/hget | ||
*/ | ||
hget<TData>(...args: CommandArgs<typeof HGetCommand>): Promise<TData | null>; | ||
/** | ||
* @see https://redis.io/commands/hgetall | ||
*/ | ||
hgetall<TData extends Record<string, unknown>>(...args: CommandArgs<typeof HGetAllCommand>): Promise<TData | null>; | ||
/** | ||
* @see https://redis.io/commands/hincrby | ||
*/ | ||
hincrby(...args: CommandArgs<typeof HIncrByCommand>): Promise<number>; | ||
/** | ||
* @see https://redis.io/commands/hincrbyfloat | ||
*/ | ||
hincrbyfloat(...args: CommandArgs<typeof HIncrByFloatCommand>): Promise<number>; | ||
/** | ||
* @see https://redis.io/commands/hkeys | ||
*/ | ||
hkeys(...args: CommandArgs<typeof HKeysCommand>): Promise<string[]>; | ||
/** | ||
* @see https://redis.io/commands/hlen | ||
*/ | ||
hlen(...args: CommandArgs<typeof HLenCommand>): Promise<number>; | ||
/** | ||
* @see https://redis.io/commands/hmget | ||
*/ | ||
hmget<TData extends Record<string, unknown>>(...args: CommandArgs<typeof HMGetCommand>): Promise<TData | null>; | ||
/** | ||
* @see https://redis.io/commands/hmset | ||
*/ | ||
hmset<TData>(key: string, kv: { | ||
[field: string]: TData; | ||
}): Promise<number>; | ||
/** | ||
* @see https://redis.io/commands/hscan | ||
*/ | ||
hscan(...args: CommandArgs<typeof HScanCommand>): Promise<[number, (string | number)[]]>; | ||
/** | ||
* @see https://redis.io/commands/hset | ||
*/ | ||
hset<TData>(key: string, field: string, value: TData): Promise<number>; | ||
/** | ||
* @see https://redis.io/commands/hsetnx | ||
*/ | ||
hsetnx<TData>(key: string, field: string, value: TData): Promise<0 | 1>; | ||
/** | ||
* @see https://redis.io/commands/hstrlen | ||
*/ | ||
hstrlen(...args: CommandArgs<typeof HStrLenCommand>): Promise<number>; | ||
/** | ||
* @see https://redis.io/commands/hvals | ||
*/ | ||
hvals(...args: CommandArgs<typeof HValsCommand>): Promise<unknown[]>; | ||
/** | ||
* @see https://redis.io/commands/incr | ||
*/ | ||
incr(...args: CommandArgs<typeof IncrCommand>): Promise<number>; | ||
/** | ||
* @see https://redis.io/commands/incrby | ||
*/ | ||
incrby(...args: CommandArgs<typeof IncrByCommand>): Promise<number>; | ||
/** | ||
* @see https://redis.io/commands/incrbyfloat | ||
*/ | ||
incrbyfloat(...args: CommandArgs<typeof IncrByFloatCommand>): Promise<number>; | ||
/** | ||
* @see https://redis.io/commands/keys | ||
*/ | ||
keys(...args: CommandArgs<typeof KeysCommand>): Promise<string[]>; | ||
/** | ||
* @see https://redis.io/commands/lindex | ||
*/ | ||
lindex(...args: CommandArgs<typeof LIndexCommand>): Promise<string | null>; | ||
/** | ||
* @see https://redis.io/commands/linsert | ||
*/ | ||
linsert<TData>(key: string, direction: "before" | "after", pivot: TData, value: TData): Promise<number>; | ||
/** | ||
* @see https://redis.io/commands/llen | ||
*/ | ||
llen(...args: CommandArgs<typeof LLenCommand>): Promise<number>; | ||
/** | ||
* @see https://redis.io/commands/lpop | ||
*/ | ||
lpop<TData>(...args: CommandArgs<typeof LPopCommand>): Promise<TData | null>; | ||
/** | ||
* @see https://redis.io/commands/lpush | ||
*/ | ||
lpush<TData>(key: string, ...elements: NonEmptyArray<TData>): Promise<number>; | ||
/** | ||
* @see https://redis.io/commands/lpushx | ||
*/ | ||
lpushx<TData>(key: string, ...elements: NonEmptyArray<TData>): Promise<number>; | ||
/** | ||
* @see https://redis.io/commands/lrange | ||
*/ | ||
lrange<TResult = string>(...args: CommandArgs<typeof LRangeCommand>): Promise<TResult[]>; | ||
/** | ||
* @see https://redis.io/commands/lrem | ||
*/ | ||
lrem<TData>(key: string, count: number, value: TData): Promise<number>; | ||
/** | ||
* @see https://redis.io/commands/lset | ||
*/ | ||
lset<TData>(key: string, value: TData, index: number): Promise<"OK">; | ||
/** | ||
* @see https://redis.io/commands/ltrim | ||
*/ | ||
ltrim(...args: CommandArgs<typeof LTrimCommand>): Promise<"OK">; | ||
/** | ||
* @see https://redis.io/commands/mget | ||
*/ | ||
mget<TData extends unknown[]>(...args: CommandArgs<typeof MGetCommand>): Promise<TData>; | ||
/** | ||
* @see https://redis.io/commands/mset | ||
*/ | ||
mset<TData>(kv: { | ||
[key: string]: TData; | ||
}): Promise<"OK">; | ||
/** | ||
* @see https://redis.io/commands/msetnx | ||
*/ | ||
msetnx<TData>(kv: { | ||
[key: string]: TData; | ||
}): Promise<number>; | ||
/** | ||
* @see https://redis.io/commands/persist | ||
*/ | ||
persist(...args: CommandArgs<typeof PersistCommand>): Promise<0 | 1>; | ||
/** | ||
* @see https://redis.io/commands/pexpire | ||
*/ | ||
pexpire(...args: CommandArgs<typeof PExpireCommand>): Promise<0 | 1>; | ||
/** | ||
* @see https://redis.io/commands/pexpireat | ||
*/ | ||
pexpireat(...args: CommandArgs<typeof PExpireAtCommand>): Promise<0 | 1>; | ||
/** | ||
* @see https://redis.io/commands/ping | ||
*/ | ||
ping(...args: CommandArgs<typeof PingCommand>): Promise<string>; | ||
/** | ||
* @see https://redis.io/commands/psetex | ||
*/ | ||
psetex<TData>(key: string, ttl: number, value: TData): Promise<string>; | ||
/** | ||
* @see https://redis.io/commands/pttl | ||
*/ | ||
pttl(...args: CommandArgs<typeof PTtlCommand>): Promise<number>; | ||
/** | ||
* @see https://redis.io/commands/randomkey | ||
*/ | ||
randomkey(): Promise<string | null>; | ||
/** | ||
* @see https://redis.io/commands/rename | ||
*/ | ||
rename(...args: CommandArgs<typeof RenameCommand>): Promise<"OK">; | ||
/** | ||
* @see https://redis.io/commands/renamenx | ||
*/ | ||
renamenx(...args: CommandArgs<typeof RenameNXCommand>): Promise<0 | 1>; | ||
/** | ||
* @see https://redis.io/commands/rpop | ||
*/ | ||
rpop<TData = string>(...args: CommandArgs<typeof RPopCommand>): Promise<TData | null>; | ||
/** | ||
* @see https://redis.io/commands/rpush | ||
*/ | ||
rpush<TData>(key: string, ...elements: NonEmptyArray<TData>): Promise<number>; | ||
/** | ||
* @see https://redis.io/commands/rpushx | ||
*/ | ||
rpushx<TData>(key: string, ...elements: NonEmptyArray<TData>): Promise<number>; | ||
/** | ||
* @see https://redis.io/commands/sadd | ||
*/ | ||
sadd<TData>(key: string, ...members: NonEmptyArray<TData>): Promise<number>; | ||
/** | ||
* @see https://redis.io/commands/scan | ||
*/ | ||
scan(...args: CommandArgs<typeof ScanCommand>): Promise<[number, string[]]>; | ||
/** | ||
* @see https://redis.io/commands/scard | ||
*/ | ||
scard(...args: CommandArgs<typeof SCardCommand>): Promise<number>; | ||
/** | ||
* @see https://redis.io/commands/sdiff | ||
*/ | ||
sdiff(...args: CommandArgs<typeof SDiffCommand>): Promise<unknown[]>; | ||
/** | ||
* @see https://redis.io/commands/sdiffstore | ||
*/ | ||
sdiffstore(...args: CommandArgs<typeof SDiffStoreCommand>): Promise<number>; | ||
/** | ||
* @see https://redis.io/commands/set | ||
*/ | ||
set<TData>(key: string, value: TData, opts?: SetCommandOptions): Promise<TData>; | ||
/** | ||
* @see https://redis.io/commands/setbit | ||
*/ | ||
setbit(...args: CommandArgs<typeof SetBitCommand>): Promise<0 | 1>; | ||
/** | ||
* @see https://redis.io/commands/setex | ||
*/ | ||
setex<TData>(key: string, ttl: number, value: TData): Promise<"OK">; | ||
/** | ||
* @see https://redis.io/commands/setnx | ||
*/ | ||
setnx<TData>(key: string, value: TData): Promise<number>; | ||
/** | ||
* @see https://redis.io/commands/setrange | ||
*/ | ||
setrange(...args: CommandArgs<typeof SetRangeCommand>): Promise<number>; | ||
/** | ||
* @see https://redis.io/commands/sinter | ||
*/ | ||
sinter(...args: CommandArgs<typeof SInterCommand>): Promise<string[]>; | ||
/** | ||
* @see https://redis.io/commands/sinterstore | ||
*/ | ||
sinterstore(...args: CommandArgs<typeof SInterStoreCommand>): Promise<string[]>; | ||
/** | ||
* @see https://redis.io/commands/sismember | ||
*/ | ||
sismember<TData>(key: string, member: TData): Promise<0 | 1>; | ||
/** | ||
* @see https://redis.io/commands/smembers | ||
*/ | ||
smembers(...args: CommandArgs<typeof SMembersCommand>): Promise<string[]>; | ||
/** | ||
* @see https://redis.io/commands/smove | ||
*/ | ||
smove<TData>(source: string, destination: string, member: TData): Promise<0 | 1>; | ||
/** | ||
* @see https://redis.io/commands/spop | ||
*/ | ||
spop<TData>(...args: CommandArgs<typeof SPopCommand>): Promise<TData | null>; | ||
/** | ||
* @see https://redis.io/commands/srandmember | ||
*/ | ||
srandmember<TData>(...args: CommandArgs<typeof SRandMemberCommand>): Promise<TData | null>; | ||
/** | ||
* @see https://redis.io/commands/srem | ||
*/ | ||
srem<TData>(key: string, ...members: NonEmptyArray<TData>): Promise<number>; | ||
/** | ||
* @see https://redis.io/commands/sscan | ||
*/ | ||
sscan(...args: CommandArgs<typeof SScanCommand>): Promise<[number, (string | number)[]]>; | ||
/** | ||
* @see https://redis.io/commands/strlen | ||
*/ | ||
strlen(...args: CommandArgs<typeof StrLenCommand>): Promise<number>; | ||
/** | ||
* @see https://redis.io/commands/sunion | ||
*/ | ||
sunion(...args: CommandArgs<typeof SUnionCommand>): Promise<unknown[]>; | ||
/** | ||
* @see https://redis.io/commands/sunionstore | ||
*/ | ||
sunionstore(...args: CommandArgs<typeof SUnionStoreCommand>): Promise<number>; | ||
/** | ||
* @see https://redis.io/commands/time | ||
*/ | ||
time(): Promise<[number, number]>; | ||
/** | ||
* @see https://redis.io/commands/touch | ||
*/ | ||
touch(...args: CommandArgs<typeof TouchCommand>): Promise<number>; | ||
/** | ||
* @see https://redis.io/commands/ttl | ||
*/ | ||
ttl(...args: CommandArgs<typeof TtlCommand>): Promise<number>; | ||
/** | ||
* @see https://redis.io/commands/type | ||
*/ | ||
type(...args: CommandArgs<typeof TypeCommand>): Promise<Type>; | ||
/** | ||
* @see https://redis.io/commands/unlink | ||
*/ | ||
unlink(...args: CommandArgs<typeof UnlinkCommand>): Promise<number>; | ||
/** | ||
* @see https://redis.io/commands/zadd | ||
*/ | ||
zadd<TData>(key: string, scoreMember: ScoreMember<TData>, ...scoreMemberPairs: ScoreMember<TData>[]): Promise<number | null>; | ||
zadd<TData>(key: string, opts: ZAddCommandOptions | ZAddCommandOptionsWithIncr, ...scoreMemberPairs: [ScoreMember<TData>, ...ScoreMember<TData>[]]): Promise<number | null>; | ||
/** | ||
* @see https://redis.io/commands/zcard | ||
*/ | ||
zcard(...args: CommandArgs<typeof ZCardCommand>): Promise<number>; | ||
/** | ||
* @see https://redis.io/commands/zcount | ||
*/ | ||
zcount(...args: CommandArgs<typeof ZCountCommand>): Promise<number>; | ||
/** | ||
* @see https://redis.io/commands/zincrby | ||
*/ | ||
zincrby<TData>(key: string, increment: number, member: TData): Promise<number>; | ||
/** | ||
* @see https://redis.io/commands/zinterstore | ||
*/ | ||
zinterstore(...args: CommandArgs<typeof ZInterStoreCommand>): Promise<number>; | ||
/** | ||
* @see https://redis.io/commands/zlexcount | ||
*/ | ||
zlexcount(...args: CommandArgs<typeof ZLexCountCommand>): Promise<number>; | ||
/** | ||
* @see https://redis.io/commands/zpopmax | ||
*/ | ||
zpopmax<TData>(...args: CommandArgs<typeof ZPopMaxCommand>): Promise<TData[]>; | ||
/** | ||
* @see https://redis.io/commands/zpopmin | ||
*/ | ||
zpopmin<TData>(...args: CommandArgs<typeof ZPopMinCommand>): Promise<TData[]>; | ||
/** | ||
* @see https://redis.io/commands/zrange | ||
*/ | ||
zrange<TData extends unknown[]>(...args: CommandArgs<typeof ZRangeCommand>): Promise<TData>; | ||
/** | ||
* @see https://redis.io/commands/zrank | ||
*/ | ||
zrank<TData>(key: string, member: TData): Promise<number | null>; | ||
/** | ||
* @see https://redis.io/commands/zrem | ||
*/ | ||
zrem<TData>(key: string, ...members: NonEmptyArray<TData>): Promise<number>; | ||
/** | ||
* @see https://redis.io/commands/zremrangebylex | ||
*/ | ||
zremrangebylex(...args: CommandArgs<typeof ZRemRangeByLexCommand>): Promise<number>; | ||
/** | ||
* @see https://redis.io/commands/zremrangebyrank | ||
*/ | ||
zremrangebyrank(...args: CommandArgs<typeof ZRemRangeByRankCommand>): Promise<number>; | ||
/** | ||
* @see https://redis.io/commands/zremrangebyscore | ||
*/ | ||
zremrangebyscore(...args: CommandArgs<typeof ZRemRangeByScoreCommand>): Promise<number>; | ||
/** | ||
* @see https://redis.io/commands/zrevrank | ||
*/ | ||
zrevrank<TData>(key: string, member: TData): Promise<number | null>; | ||
/** | ||
* @see https://redis.io/commands/zscan | ||
*/ | ||
zscan(...args: CommandArgs<typeof ZScanCommand>): Promise<[number, (string | number)[]]>; | ||
/** | ||
* @see https://redis.io/commands/zscore | ||
*/ | ||
zscore<TData>(key: string, member: TData): Promise<number | null>; | ||
/** | ||
* @see https://redis.io/commands/zunionstore | ||
*/ | ||
zunionstore(...args: CommandArgs<typeof ZUnionStoreCommand>): Promise<number>; | ||
} | ||
/** | ||
* Result of a bad request to upstash | ||
@@ -1011,2 +13,2 @@ */ | ||
export { Redis, RedisConfig, UpstashError }; | ||
export { UpstashError }; |
@@ -41,9 +41,6 @@ var __defProp = Object.defineProperty; | ||
__export(pkg_exports, { | ||
Redis: () => Redis, | ||
Redis: () => Redis2, | ||
UpstashError: () => UpstashError | ||
}); | ||
// pkg/http.ts | ||
var import_isomorphic_fetch = require("isomorphic-fetch"); | ||
// pkg/error.ts | ||
@@ -57,35 +54,2 @@ var UpstashError = class extends Error { | ||
// pkg/http.ts | ||
var HttpClient = class { | ||
constructor(config) { | ||
var _a; | ||
this.baseUrl = config.baseUrl.replace(/\/$/, ""); | ||
this.headers = (_a = config.headers) != null ? _a : {}; | ||
this.options = config.options; | ||
} | ||
async request(method, req) { | ||
var _a; | ||
if (!req.path) { | ||
req.path = []; | ||
} | ||
const headers = __spreadValues(__spreadValues({ | ||
"Content-Type": "application/json" | ||
}, this.headers), req.headers); | ||
const res = await fetch([this.baseUrl, ...req.path].join("/"), { | ||
method, | ||
headers, | ||
body: JSON.stringify(req.body), | ||
backend: (_a = this.options) == null ? void 0 : _a.backend | ||
}); | ||
const body = await res.json(); | ||
if (!res.ok) { | ||
throw new UpstashError(body.error); | ||
} | ||
return body; | ||
} | ||
async post(req) { | ||
return await this.request("POST", req); | ||
} | ||
}; | ||
// pkg/util.ts | ||
@@ -117,3 +81,3 @@ function parseRecursive(obj) { | ||
async exec(client) { | ||
const { result, error } = await client.post({ | ||
const { result, error } = await client.request({ | ||
body: this.command | ||
@@ -1050,3 +1014,3 @@ }); | ||
} | ||
const res = await this.client.post({ | ||
const res = await this.client.request({ | ||
path: ["pipeline"], | ||
@@ -1391,36 +1355,5 @@ body: Object.values(this.commands).map((c) => c.command) | ||
var Redis = class { | ||
constructor(config) { | ||
this.client = new HttpClient({ | ||
baseUrl: config.url, | ||
headers: { | ||
authorization: `Bearer ${config.token}` | ||
}, | ||
options: config.requestOptions | ||
}); | ||
constructor(client) { | ||
this.client = client; | ||
} | ||
static fromEnv() { | ||
if (typeof (process == null ? void 0 : process.env) === "undefined") { | ||
throw new Error("Unable to get environment variables, `process.env` is undefined. If you are deploying to cloudflare, please use `fromCloudflareEnv()` instead"); | ||
} | ||
const url = process.env["UPSTASH_REDIS_REST_URL"]; | ||
if (!url) { | ||
throw new Error("Unable to find environment variable: `UPSTASH_REDIS_REST_URL`"); | ||
} | ||
const token = process.env["UPSTASH_REDIS_REST_TOKEN"]; | ||
if (!token) { | ||
throw new Error("Unable to find environment variable: `UPSTASH_REDIS_REST_TOKEN`"); | ||
} | ||
return new Redis({ url, token }); | ||
} | ||
static fromCloudflareEnv() { | ||
const url = UPSTASH_REDIS_REST_URL; | ||
const token = UPSTASH_REDIS_REST_TOKEN; | ||
if (!url) { | ||
throw new Error("Unable to find environment variable: `UPSTASH_REDIS_REST_URL`"); | ||
} | ||
if (!token) { | ||
throw new Error("Unable to find environment variable: `UPSTASH_REDIS_REST_TOKEN`"); | ||
} | ||
return new Redis({ url, token }); | ||
} | ||
pipeline() { | ||
@@ -1754,2 +1687,59 @@ return new Pipeline(this.client); | ||
}; | ||
// pkg/http.ts | ||
var import_isomorphic_fetch = require("isomorphic-fetch"); | ||
var HttpClient = class { | ||
constructor(config) { | ||
this.baseUrl = config.baseUrl.replace(/\/$/, ""); | ||
this.headers = __spreadValues({ | ||
"Content-Type": "application/json" | ||
}, config.headers); | ||
this.options = config.options; | ||
} | ||
async request(req) { | ||
var _a; | ||
if (!req.path) { | ||
req.path = []; | ||
} | ||
const res = await fetch([this.baseUrl, ...req.path].join("/"), { | ||
method: "POST", | ||
headers: this.headers, | ||
body: JSON.stringify(req.body), | ||
backend: (_a = this.options) == null ? void 0 : _a.backend | ||
}); | ||
const body = await res.json(); | ||
if (!res.ok) { | ||
throw new UpstashError(body.error); | ||
} | ||
return body; | ||
} | ||
}; | ||
// pkg/nodejs.ts | ||
var import_isomorphic_fetch2 = require("isomorphic-fetch"); | ||
var Redis2 = class extends Redis { | ||
constructor(config) { | ||
const client = new HttpClient({ | ||
baseUrl: config.url, | ||
headers: { | ||
authorization: `Bearer ${config.token}` | ||
} | ||
}); | ||
super(client); | ||
} | ||
static fromEnv() { | ||
if (typeof (process == null ? void 0 : process.env) === "undefined") { | ||
throw new Error("Unable to get environment variables, `process.env` is undefined. If you are deploying to cloudflare, please use `Redis.onCloudflare()` instead"); | ||
} | ||
const url = process.env["UPSTASH_REDIS_REST_URL"]; | ||
if (!url) { | ||
throw new Error("Unable to find environment variable: `UPSTASH_REDIS_REST_URL`"); | ||
} | ||
const token = process.env["UPSTASH_REDIS_REST_TOKEN"]; | ||
if (!token) { | ||
throw new Error("Unable to find environment variable: `UPSTASH_REDIS_REST_TOKEN`"); | ||
} | ||
return new Redis2({ url, token }); | ||
} | ||
}; | ||
module.exports = __toCommonJS(pkg_exports); | ||
@@ -1756,0 +1746,0 @@ // Annotate the CommonJS export names for ESM import in node: |
@@ -1,1 +0,1 @@ | ||
{ "name": "@upstash/redis", "version": "v1.0.0-alpha.1", "engines": { "node": ">=10" }, "description": "An HTTP/REST based Redis client built on top of Upstash REST API.", "main": "./dist/index.js", "module": "./dist/index.mjs", "types": "./dist/index.d.ts", "exports": { ".": { "require": "./dist/index.js", "import": "./dist/index.mjs", "types": "./dist/index.d.ts" } }, "files": [ "package.json", "dist" ], "scripts": { "test": "jest -i", "fmt": "pnpm lint && pnpm prettier --write .", "lint": "eslint --ext .ts --fix --ignore-path .gitignore .", "build": "tsup && pnpm size-limit" }, "repository": { "type": "git", "url": "git+https://github.com/upstash/upstash-redis.git" }, "keywords": [ "redis", "database", "serverless", "edge", "upstash" ], "author": "Andreas Thomas <andreas.thomas@chronark.com>", "license": "MIT", "bugs": { "url": "https://github.com/upstash/upstash-redis/issues" }, "homepage": "https://github.com/upstash/upstash-redis#readme", "directories": { "examples": "examples" }, "devDependencies": { "@jest/globals": "^27.4.6", "@size-limit/preset-small-lib": "^7.0.8", "@trivago/prettier-plugin-sort-imports": "^3.2.0", "@types/jest": "^27.4.0", "@types/node": "^17.0.8", "@typescript-eslint/eslint-plugin": "^5.9.1", "@typescript-eslint/parser": "^5.9.1", "dotenv": "^12.0.3", "eslint": "^8.6.0", "eslint-config-prettier": "^8.3.0", "eslint-plugin-prettier": "^4.0.0", "jest": "^27.4.7", "prettier": "^2.5.1", "size-limit": "^7.0.8", "ts-jest": "^27.1.3", "tsup": "^5.11.11", "typescript": "^4.5.5" }, "dependencies": { "isomorphic-fetch": "^3.0.0" }, "browser": { "isomorphic-fetch": false }, "size-limit": [ { "path": "dist/index.js", "limit": "5 KB" }, { "path": "dist/index.mjs", "limit": "5 KB" } ] } | ||
{ "name": "@upstash/redis", "version": "v1.0.0-alpha.2", "engines": { "node": ">=10" }, "description": "An HTTP/REST based Redis client built on top of Upstash REST API.", "main": "./index.js", "module": "./index.mjs", "types": "./index.d.ts", "scripts": { "test": "jest -i", "fmt": "pnpm lint && pnpm prettier --write .", "lint": "eslint --ext .ts --fix --ignore-path .gitignore .", "build": "tsup && cp package.json ./dist/ && pnpm size-limit" }, "repository": { "type": "git", "url": "git+https://github.com/upstash/upstash-redis.git" }, "keywords": [ "redis", "database", "serverless", "edge", "upstash" ], "author": "Andreas Thomas <andreas.thomas@chronark.com>", "license": "MIT", "bugs": { "url": "https://github.com/upstash/upstash-redis/issues" }, "homepage": "https://github.com/upstash/upstash-redis#readme", "directories": { "examples": "examples" }, "devDependencies": { "@jest/globals": "^27.4.6", "@size-limit/preset-small-lib": "^7.0.8", "@trivago/prettier-plugin-sort-imports": "^3.2.0", "@types/jest": "^27.4.0", "@types/node": "^17.0.8", "@typescript-eslint/eslint-plugin": "^5.9.1", "@typescript-eslint/parser": "^5.9.1", "dotenv": "^12.0.3", "eslint": "^8.6.0", "eslint-config-prettier": "^8.3.0", "eslint-plugin-prettier": "^4.0.0", "jest": "^27.4.7", "prettier": "^2.5.1", "size-limit": "^7.0.8", "ts-jest": "^27.1.3", "tsup": "^5.11.11", "typescript": "^4.5.5" }, "dependencies": { "isomorphic-fetch": "^3.0.0" }, "browser": { "isomorphic-fetch": false }, "size-limit": [ { "path": "dist/index.js", "limit": "5 KB" }, { "path": "dist/index.mjs", "limit": "5 KB" } ] } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
685989
265
18754
9
8