@postgresx/noredis 0.11.0 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/adapters/bun.d.ts +5 -8
- package/dist/adapters/ioredis.d.ts +12 -15
- package/dist/adapters/ioredis.js +8 -1
- package/dist/adapters/node.d.ts +11 -13
- package/dist/adapters/redis.d.ts +12 -15
- package/dist/adapters/redis.js +8 -1
- package/dist/adapters/web.d.ts +11 -16
- package/dist/advisory-lock.d.ts +24 -0
- package/dist/{chunk-WRMEEA6T.js → chunk-6PU53SX7.js} +16 -2
- package/dist/{chunk-HW3WONAC.js → chunk-JRMUZTI4.js} +128 -15
- package/dist/{chunk-YSWHEFPX.js → chunk-LN56Y4FI.js} +68 -0
- package/dist/client.d.ts +70 -0
- package/dist/counter.d.ts +27 -0
- package/dist/errors.d.ts +5 -0
- package/dist/hash-index.d.ts +1 -43
- package/dist/hash.d.ts +40 -0
- package/dist/index.d.ts +17 -16
- package/dist/index.js +3 -3
- package/dist/kv-cache.d.ts +16 -20
- package/dist/kv.d.ts +1 -3
- package/dist/list-index.d.ts +1 -53
- package/dist/list-index.js +1 -1
- package/dist/list.d.ts +74 -0
- package/dist/metrics.d.ts +48 -0
- package/dist/pipeline.d.ts +14 -0
- package/dist/pubsub-index.d.ts +1 -60
- package/dist/pubsub.d.ts +57 -0
- package/dist/queue.d.ts +50 -0
- package/dist/rate-limit.d.ts +108 -0
- package/dist/redis-aliases.d.ts +129 -0
- package/dist/set-index.d.ts +1 -42
- package/dist/set.d.ts +39 -0
- package/dist/sorted-set-index.d.ts +1 -58
- package/dist/sorted-set-index.js +1 -1
- package/dist/sorted-set.d.ts +73 -0
- package/dist/sql.d.ts +8 -0
- package/dist/stream.d.ts +59 -0
- package/package.json +4 -4
- package/dist/client-ChVkyyno.d.ts +0 -513
- package/dist/sql-DKf2TDlu.d.ts +0 -10
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { type PgSqlLike } from "./sql.js";
|
|
2
|
+
export interface PgCounterOptions {
|
|
3
|
+
sql: PgSqlLike;
|
|
4
|
+
namespace?: string;
|
|
5
|
+
tableName?: string;
|
|
6
|
+
}
|
|
7
|
+
export interface PgCounterSetOptions {
|
|
8
|
+
ttlMs?: number | null;
|
|
9
|
+
}
|
|
10
|
+
export interface PgCounterSchemaOptions {
|
|
11
|
+
unlogged?: boolean;
|
|
12
|
+
}
|
|
13
|
+
export declare class PgCounter {
|
|
14
|
+
readonly namespace: string;
|
|
15
|
+
readonly tableName: string;
|
|
16
|
+
readonly quotedTableName: string;
|
|
17
|
+
private readonly sql;
|
|
18
|
+
constructor(options: PgCounterOptions);
|
|
19
|
+
ensureSchema(options?: PgCounterSchemaOptions): Promise<void>;
|
|
20
|
+
get(key: string): Promise<number | null>;
|
|
21
|
+
set(key: string, value: number, options?: PgCounterSetOptions): Promise<number>;
|
|
22
|
+
incr(key: string, amount?: number, options?: PgCounterSetOptions): Promise<number>;
|
|
23
|
+
decr(key: string, amount?: number, options?: PgCounterSetOptions): Promise<number>;
|
|
24
|
+
delete(key: string): Promise<boolean>;
|
|
25
|
+
cleanupExpired(limit?: number): Promise<number>;
|
|
26
|
+
}
|
|
27
|
+
export declare function createPgCounter(options: PgCounterOptions): PgCounter;
|
package/dist/errors.d.ts
ADDED
package/dist/hash-index.d.ts
CHANGED
|
@@ -1,43 +1 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
interface PgHashOptions {
|
|
4
|
-
sql: PgSqlLike;
|
|
5
|
-
namespace?: string;
|
|
6
|
-
tableName?: string;
|
|
7
|
-
}
|
|
8
|
-
interface PgHashSchemaOptions {
|
|
9
|
-
unlogged?: boolean;
|
|
10
|
-
}
|
|
11
|
-
interface PgHashScanResult<T = unknown> {
|
|
12
|
-
cursor: string | null;
|
|
13
|
-
entries: Array<readonly [string, T]>;
|
|
14
|
-
}
|
|
15
|
-
declare class PgHash {
|
|
16
|
-
readonly namespace: string;
|
|
17
|
-
readonly tableName: string;
|
|
18
|
-
readonly quotedTableName: string;
|
|
19
|
-
private readonly sql;
|
|
20
|
-
constructor(options: PgHashOptions);
|
|
21
|
-
ensureSchema(options?: PgHashSchemaOptions): Promise<void>;
|
|
22
|
-
hget<T = unknown>(key: string, field: string): Promise<T | null>;
|
|
23
|
-
hset<T = unknown>(key: string, field: string, value: T): Promise<void>;
|
|
24
|
-
hmset<T = unknown>(key: string, entries: Iterable<readonly [string, T]>): Promise<void>;
|
|
25
|
-
hgetall<T = unknown>(key: string): Promise<Record<string, T>>;
|
|
26
|
-
hdel(key: string, field: string): Promise<boolean>;
|
|
27
|
-
hclear(key: string): Promise<number>;
|
|
28
|
-
hexists(key: string, field: string): Promise<boolean>;
|
|
29
|
-
hlen(key: string): Promise<number>;
|
|
30
|
-
hincrby(key: string, field: string, amount?: number): Promise<number>;
|
|
31
|
-
hscan<T = unknown>(key: string, cursor?: string | null, count?: number): Promise<PgHashScanResult<T>>;
|
|
32
|
-
expire(key: string, ttlMs: number): Promise<number>;
|
|
33
|
-
persist(key: string): Promise<number>;
|
|
34
|
-
ttl(key: string): Promise<number | null>;
|
|
35
|
-
hmget<T = unknown>(key: string, ...fields: string[]): Promise<Array<T | null>>;
|
|
36
|
-
hkeys(key: string): Promise<string[]>;
|
|
37
|
-
hvals<T = unknown>(key: string): Promise<T[]>;
|
|
38
|
-
hstrlen(key: string, field: string): Promise<number>;
|
|
39
|
-
cleanupExpired(limit?: number): Promise<number>;
|
|
40
|
-
}
|
|
41
|
-
declare function createPgHash(options: PgHashOptions): PgHash;
|
|
42
|
-
|
|
43
|
-
export { PgHash, type PgHashOptions, type PgHashScanResult, type PgHashSchemaOptions, createPgHash };
|
|
1
|
+
export { createPgHash, PgHash, type PgHashOptions, type PgHashSchemaOptions, type PgHashScanResult } from "./hash.js";
|
package/dist/hash.d.ts
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { type PgSqlLike } from "./sql.js";
|
|
2
|
+
export interface PgHashOptions {
|
|
3
|
+
sql: PgSqlLike;
|
|
4
|
+
namespace?: string;
|
|
5
|
+
tableName?: string;
|
|
6
|
+
}
|
|
7
|
+
export interface PgHashSchemaOptions {
|
|
8
|
+
unlogged?: boolean;
|
|
9
|
+
}
|
|
10
|
+
export interface PgHashScanResult<T = unknown> {
|
|
11
|
+
cursor: string | null;
|
|
12
|
+
entries: Array<readonly [string, T]>;
|
|
13
|
+
}
|
|
14
|
+
export declare class PgHash {
|
|
15
|
+
readonly namespace: string;
|
|
16
|
+
readonly tableName: string;
|
|
17
|
+
readonly quotedTableName: string;
|
|
18
|
+
private readonly sql;
|
|
19
|
+
constructor(options: PgHashOptions);
|
|
20
|
+
ensureSchema(options?: PgHashSchemaOptions): Promise<void>;
|
|
21
|
+
hget<T = unknown>(key: string, field: string): Promise<T | null>;
|
|
22
|
+
hset<T = unknown>(key: string, field: string, value: T): Promise<void>;
|
|
23
|
+
hmset<T = unknown>(key: string, entries: Iterable<readonly [string, T]>): Promise<void>;
|
|
24
|
+
hgetall<T = unknown>(key: string): Promise<Record<string, T>>;
|
|
25
|
+
hdel(key: string, field: string): Promise<boolean>;
|
|
26
|
+
hclear(key: string): Promise<number>;
|
|
27
|
+
hexists(key: string, field: string): Promise<boolean>;
|
|
28
|
+
hlen(key: string): Promise<number>;
|
|
29
|
+
hincrby(key: string, field: string, amount?: number): Promise<number>;
|
|
30
|
+
hscan<T = unknown>(key: string, cursor?: string | null, count?: number): Promise<PgHashScanResult<T>>;
|
|
31
|
+
expire(key: string, ttlMs: number): Promise<number>;
|
|
32
|
+
persist(key: string): Promise<number>;
|
|
33
|
+
ttl(key: string): Promise<number | null>;
|
|
34
|
+
hmget<T = unknown>(key: string, ...fields: string[]): Promise<Array<T | null>>;
|
|
35
|
+
hkeys(key: string): Promise<string[]>;
|
|
36
|
+
hvals<T = unknown>(key: string): Promise<T[]>;
|
|
37
|
+
hstrlen(key: string, field: string): Promise<number>;
|
|
38
|
+
cleanupExpired(limit?: number): Promise<number>;
|
|
39
|
+
}
|
|
40
|
+
export declare function createPgHash(options: PgHashOptions): PgHash;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
export
|
|
5
|
-
export
|
|
6
|
-
export
|
|
7
|
-
export
|
|
8
|
-
export
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
export
|
|
1
|
+
export { createPgKvCache, PgKvCache, type BunSqlLike, type PgKvCacheInvalidationOptions, type PgKvCacheL1Options, type PgKvCacheListenerFactory, type PgKvCacheListenerFactoryOptions, type PgKvCacheNotifyOptions, type PgKvCacheOptions, type PgKvCacheStats, type PgKvNotification, type PgKvSchemaOptions, type PgKvSetOptions } from "./kv-cache.js";
|
|
2
|
+
export * from "./advisory-lock.js";
|
|
3
|
+
export * from "./client.js";
|
|
4
|
+
export * from "./counter.js";
|
|
5
|
+
export * from "./hash.js";
|
|
6
|
+
export * from "./list.js";
|
|
7
|
+
export * from "./metrics.js";
|
|
8
|
+
export * from "./pipeline.js";
|
|
9
|
+
export * from "./pubsub.js";
|
|
10
|
+
export * from "./queue.js";
|
|
11
|
+
export * from "./rate-limit.js";
|
|
12
|
+
export * from "./redis-aliases.js";
|
|
13
|
+
export * from "./set.js";
|
|
14
|
+
export * from "./sql.js";
|
|
15
|
+
export * from "./sorted-set.js";
|
|
16
|
+
export * from "./stream.js";
|
|
17
|
+
export * from "./errors.js";
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
UnsupportedCommandError,
|
|
3
3
|
createPgredisMigrationAliases
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-6PU53SX7.js";
|
|
5
5
|
import {
|
|
6
6
|
PgHash,
|
|
7
7
|
createPgHash
|
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
import {
|
|
14
14
|
PgList,
|
|
15
15
|
createPgList
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-JRMUZTI4.js";
|
|
17
17
|
import {
|
|
18
18
|
createBunPgListener,
|
|
19
19
|
createPgListener,
|
|
@@ -27,7 +27,7 @@ import {
|
|
|
27
27
|
import {
|
|
28
28
|
PgSortedSet,
|
|
29
29
|
createPgSortedSet
|
|
30
|
-
} from "./chunk-
|
|
30
|
+
} from "./chunk-LN56Y4FI.js";
|
|
31
31
|
import {
|
|
32
32
|
indexName,
|
|
33
33
|
normalizePositiveInteger,
|
package/dist/kv-cache.d.ts
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
import { NotifyHandler, PgListenerHandle } from
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
interface BunSqlLike {
|
|
1
|
+
import type { NotifyHandler, PgListenerHandle } from "./pubsub.js";
|
|
2
|
+
export interface BunSqlLike {
|
|
5
3
|
unsafe<T = Record<string, unknown>>(query: string, params?: readonly unknown[]): Promise<T[]>;
|
|
6
4
|
begin?<T>(callback: (tx: BunSqlLike) => Promise<T>): Promise<T>;
|
|
7
5
|
}
|
|
8
|
-
interface PgKvCacheL1Options {
|
|
6
|
+
export interface PgKvCacheL1Options {
|
|
9
7
|
max?: number;
|
|
10
8
|
ttlMs?: number;
|
|
11
9
|
/**
|
|
@@ -26,7 +24,7 @@ interface PgKvCacheL1Options {
|
|
|
26
24
|
*/
|
|
27
25
|
maxEntryBytes?: number;
|
|
28
26
|
}
|
|
29
|
-
interface PgKvCacheNotifyOptions {
|
|
27
|
+
export interface PgKvCacheNotifyOptions {
|
|
30
28
|
channel?: string;
|
|
31
29
|
enabled?: boolean;
|
|
32
30
|
listener?: PgKvCacheListenerFactory;
|
|
@@ -34,17 +32,17 @@ interface PgKvCacheNotifyOptions {
|
|
|
34
32
|
/** Pause L1 reads and fills while the invalidation listener is unhealthy. Defaults to true. */
|
|
35
33
|
pauseOnDisconnect?: boolean;
|
|
36
34
|
}
|
|
37
|
-
interface PgKvCacheListenerFactoryOptions {
|
|
35
|
+
export interface PgKvCacheListenerFactoryOptions {
|
|
38
36
|
channels: string[];
|
|
39
37
|
onNotify: NotifyHandler;
|
|
40
38
|
}
|
|
41
|
-
type PgKvCacheListenerFactory = (options: PgKvCacheListenerFactoryOptions) => PgListenerHandle;
|
|
42
|
-
interface PgKvCacheInvalidationOptions {
|
|
39
|
+
export type PgKvCacheListenerFactory = (options: PgKvCacheListenerFactoryOptions) => PgListenerHandle;
|
|
40
|
+
export interface PgKvCacheInvalidationOptions {
|
|
43
41
|
clearL1OnReconnect?: boolean;
|
|
44
42
|
/** Pause L1 reads and fills while the invalidation listener is unhealthy. Defaults to true. */
|
|
45
43
|
pauseOnDisconnect?: boolean;
|
|
46
44
|
}
|
|
47
|
-
interface PgKvCacheOptions {
|
|
45
|
+
export interface PgKvCacheOptions {
|
|
48
46
|
sql: BunSqlLike;
|
|
49
47
|
namespace?: string;
|
|
50
48
|
tableName?: string;
|
|
@@ -59,31 +57,31 @@ interface PgKvCacheOptions {
|
|
|
59
57
|
*/
|
|
60
58
|
singleflight?: boolean;
|
|
61
59
|
}
|
|
62
|
-
interface PgKvSetOptions {
|
|
60
|
+
export interface PgKvSetOptions {
|
|
63
61
|
ttlMs?: number | null;
|
|
64
62
|
notify?: boolean;
|
|
65
63
|
mode?: "always" | "nx" | "xx";
|
|
66
64
|
nx?: boolean;
|
|
67
65
|
xx?: boolean;
|
|
68
66
|
}
|
|
69
|
-
interface PgKvCompareAndSwapOptions extends PgKvSetOptions {
|
|
67
|
+
export interface PgKvCompareAndSwapOptions extends PgKvSetOptions {
|
|
70
68
|
expectedMissing?: boolean;
|
|
71
69
|
}
|
|
72
|
-
interface PgKvSchemaOptions {
|
|
70
|
+
export interface PgKvSchemaOptions {
|
|
73
71
|
unlogged?: boolean;
|
|
74
72
|
}
|
|
75
|
-
interface PgKvSerializer {
|
|
73
|
+
export interface PgKvSerializer {
|
|
76
74
|
serialize(value: unknown): unknown;
|
|
77
75
|
deserialize(value: unknown): unknown;
|
|
78
76
|
}
|
|
79
|
-
interface PgKvNotification {
|
|
77
|
+
export interface PgKvNotification {
|
|
80
78
|
namespace: string;
|
|
81
79
|
key?: string;
|
|
82
80
|
prefix?: string;
|
|
83
81
|
op: "set" | "delete" | "clearPrefix" | "clearNamespace";
|
|
84
82
|
senderId?: string;
|
|
85
83
|
}
|
|
86
|
-
interface PgKvCacheStats {
|
|
84
|
+
export interface PgKvCacheStats {
|
|
87
85
|
namespace: string;
|
|
88
86
|
tableName: string;
|
|
89
87
|
l1Size: number;
|
|
@@ -105,7 +103,7 @@ interface PgKvCacheStats {
|
|
|
105
103
|
/** Configured byte cap, or 0 when unlimited. */
|
|
106
104
|
l1MaxBytes: number;
|
|
107
105
|
}
|
|
108
|
-
declare class PgKvCache {
|
|
106
|
+
export declare class PgKvCache {
|
|
109
107
|
readonly namespace: string;
|
|
110
108
|
readonly tableName: string;
|
|
111
109
|
readonly quotedTableName: string;
|
|
@@ -198,6 +196,4 @@ declare class PgKvCache {
|
|
|
198
196
|
private cleanupL1;
|
|
199
197
|
private enforceL1Max;
|
|
200
198
|
}
|
|
201
|
-
declare function createPgKvCache(options: PgKvCacheOptions): PgKvCache;
|
|
202
|
-
|
|
203
|
-
export { type BunSqlLike, PgKvCache, type PgKvCacheInvalidationOptions, type PgKvCacheL1Options, type PgKvCacheListenerFactory, type PgKvCacheListenerFactoryOptions, type PgKvCacheNotifyOptions, type PgKvCacheOptions, type PgKvCacheStats, type PgKvCompareAndSwapOptions, type PgKvNotification, type PgKvSchemaOptions, type PgKvSerializer, type PgKvSetOptions, createPgKvCache };
|
|
199
|
+
export declare function createPgKvCache(options: PgKvCacheOptions): PgKvCache;
|
package/dist/kv.d.ts
CHANGED
|
@@ -1,3 +1 @@
|
|
|
1
|
-
export {
|
|
2
|
-
import './pubsub-index.js';
|
|
3
|
-
import './sql-DKf2TDlu.js';
|
|
1
|
+
export { createPgKvCache, PgKvCache, type PgKvCacheOptions, type PgKvSetOptions, type PgKvSchemaOptions, type PgKvCacheStats, type BunSqlLike, type PgKvCacheInvalidationOptions, type PgKvCacheL1Options, type PgKvCacheListenerFactory, type PgKvCacheListenerFactoryOptions, type PgKvCacheNotifyOptions, type PgKvSerializer, type PgKvNotification } from "./kv-cache.js";
|
package/dist/list-index.d.ts
CHANGED
|
@@ -1,53 +1 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
interface PgListOptions {
|
|
4
|
-
sql: PgSqlLike;
|
|
5
|
-
namespace?: string;
|
|
6
|
-
tableName?: string;
|
|
7
|
-
}
|
|
8
|
-
interface PgListSchemaOptions {
|
|
9
|
-
unlogged?: boolean;
|
|
10
|
-
}
|
|
11
|
-
interface PgListScanResult<T = unknown> {
|
|
12
|
-
cursor: number | null;
|
|
13
|
-
values: T[];
|
|
14
|
-
}
|
|
15
|
-
interface PgListBlockingPopOptions {
|
|
16
|
-
timeoutMs?: number;
|
|
17
|
-
pollIntervalMs?: number;
|
|
18
|
-
}
|
|
19
|
-
interface PgListBlockingPopResult<T = unknown> {
|
|
20
|
-
key: string;
|
|
21
|
-
value: T;
|
|
22
|
-
}
|
|
23
|
-
declare class PgList {
|
|
24
|
-
readonly namespace: string;
|
|
25
|
-
readonly tableName: string;
|
|
26
|
-
readonly quotedTableName: string;
|
|
27
|
-
private readonly sql;
|
|
28
|
-
private readonly now;
|
|
29
|
-
constructor(options: PgListOptions & {
|
|
30
|
-
now?: () => number;
|
|
31
|
-
});
|
|
32
|
-
ensureSchema(options?: PgListSchemaOptions): Promise<void>;
|
|
33
|
-
lpush<T = unknown>(key: string, ...values: T[]): Promise<number>;
|
|
34
|
-
rpush<T = unknown>(key: string, ...values: T[]): Promise<number>;
|
|
35
|
-
lpop<T = unknown>(key: string, count?: number): Promise<T[]>;
|
|
36
|
-
rpop<T = unknown>(key: string, count?: number): Promise<T[]>;
|
|
37
|
-
blpop<T = unknown>(keys: string | readonly string[], options?: PgListBlockingPopOptions): Promise<PgListBlockingPopResult<T> | null>;
|
|
38
|
-
brpop<T = unknown>(keys: string | readonly string[], options?: PgListBlockingPopOptions): Promise<PgListBlockingPopResult<T> | null>;
|
|
39
|
-
lrange<T = unknown>(key: string, start?: number, stop?: number): Promise<T[]>;
|
|
40
|
-
llen(key: string): Promise<number>;
|
|
41
|
-
lclear(key: string): Promise<number>;
|
|
42
|
-
private push;
|
|
43
|
-
private pop;
|
|
44
|
-
private blockingPop;
|
|
45
|
-
lscan<T = unknown>(key: string, cursor?: number | null, count?: number): Promise<PgListScanResult<T>>;
|
|
46
|
-
expire(key: string, ttlMs: number): Promise<number>;
|
|
47
|
-
persist(key: string): Promise<number>;
|
|
48
|
-
ttl(key: string): Promise<number | null>;
|
|
49
|
-
cleanupExpired(limit?: number): Promise<number>;
|
|
50
|
-
}
|
|
51
|
-
declare function createPgList(options: PgListOptions): PgList;
|
|
52
|
-
|
|
53
|
-
export { PgList, type PgListBlockingPopOptions, type PgListBlockingPopResult, type PgListOptions, type PgListScanResult, type PgListSchemaOptions, createPgList };
|
|
1
|
+
export { createPgList, PgList, type PgListOptions, type PgListSchemaOptions, type PgListScanResult, type PgListBlockingPopOptions, type PgListBlockingPopResult } from "./list.js";
|
package/dist/list-index.js
CHANGED
package/dist/list.d.ts
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { type PgSqlLike } from "./sql.js";
|
|
2
|
+
export interface PgListOptions {
|
|
3
|
+
sql: PgSqlLike;
|
|
4
|
+
namespace?: string;
|
|
5
|
+
tableName?: string;
|
|
6
|
+
}
|
|
7
|
+
export interface PgListSchemaOptions {
|
|
8
|
+
unlogged?: boolean;
|
|
9
|
+
}
|
|
10
|
+
export interface PgListScanResult<T = unknown> {
|
|
11
|
+
cursor: number | null;
|
|
12
|
+
values: T[];
|
|
13
|
+
}
|
|
14
|
+
export interface PgListBlockingPopOptions {
|
|
15
|
+
timeoutMs?: number;
|
|
16
|
+
pollIntervalMs?: number;
|
|
17
|
+
}
|
|
18
|
+
export interface PgListBlockingPopResult<T = unknown> {
|
|
19
|
+
key: string;
|
|
20
|
+
value: T;
|
|
21
|
+
}
|
|
22
|
+
export declare class PgList {
|
|
23
|
+
readonly namespace: string;
|
|
24
|
+
readonly tableName: string;
|
|
25
|
+
readonly quotedTableName: string;
|
|
26
|
+
private readonly sql;
|
|
27
|
+
private readonly now;
|
|
28
|
+
constructor(options: PgListOptions & {
|
|
29
|
+
now?: () => number;
|
|
30
|
+
});
|
|
31
|
+
ensureSchema(options?: PgListSchemaOptions): Promise<void>;
|
|
32
|
+
lpush<T = unknown>(key: string, ...values: T[]): Promise<number>;
|
|
33
|
+
rpush<T = unknown>(key: string, ...values: T[]): Promise<number>;
|
|
34
|
+
lpop<T = unknown>(key: string, count?: number): Promise<T[]>;
|
|
35
|
+
rpop<T = unknown>(key: string, count?: number): Promise<T[]>;
|
|
36
|
+
blpop<T = unknown>(keys: string | readonly string[], options?: PgListBlockingPopOptions): Promise<PgListBlockingPopResult<T> | null>;
|
|
37
|
+
brpop<T = unknown>(keys: string | readonly string[], options?: PgListBlockingPopOptions): Promise<PgListBlockingPopResult<T> | null>;
|
|
38
|
+
lrange<T = unknown>(key: string, start?: number, stop?: number): Promise<T[]>;
|
|
39
|
+
/**
|
|
40
|
+
* LINDEX: the element at a zero-based index, negative counting from the
|
|
41
|
+
* tail. Returns null when the index is out of range.
|
|
42
|
+
*/
|
|
43
|
+
lindex<T = unknown>(key: string, index?: number): Promise<T | null>;
|
|
44
|
+
/**
|
|
45
|
+
* LSET: overwrite the element at a zero-based index, negative counting from
|
|
46
|
+
* the tail. Returns false when the index is out of range, which is the error
|
|
47
|
+
* Redis reports for the same input.
|
|
48
|
+
*/
|
|
49
|
+
lset<T = unknown>(key: string, index: number, value: T): Promise<boolean>;
|
|
50
|
+
/**
|
|
51
|
+
* LTRIM: keep the inclusive [start, stop] range, negative counting from the
|
|
52
|
+
* tail, and delete everything outside it. Returns the number of removed
|
|
53
|
+
* elements. Redis itself answers OK.
|
|
54
|
+
*/
|
|
55
|
+
ltrim(key: string, start?: number, stop?: number): Promise<number>;
|
|
56
|
+
/**
|
|
57
|
+
* LREM: remove occurrences of value. count > 0 removes from the head, count
|
|
58
|
+
* < 0 from the tail, count = 0 removes every occurrence. Returns the number
|
|
59
|
+
* of removed elements.
|
|
60
|
+
*/
|
|
61
|
+
lrem(key: string, count: number | undefined, value: unknown): Promise<number>;
|
|
62
|
+
private selectSlice;
|
|
63
|
+
llen(key: string): Promise<number>;
|
|
64
|
+
lclear(key: string): Promise<number>;
|
|
65
|
+
private push;
|
|
66
|
+
private pop;
|
|
67
|
+
private blockingPop;
|
|
68
|
+
lscan<T = unknown>(key: string, cursor?: number | null, count?: number): Promise<PgListScanResult<T>>;
|
|
69
|
+
expire(key: string, ttlMs: number): Promise<number>;
|
|
70
|
+
persist(key: string): Promise<number>;
|
|
71
|
+
ttl(key: string): Promise<number | null>;
|
|
72
|
+
cleanupExpired(limit?: number): Promise<number>;
|
|
73
|
+
}
|
|
74
|
+
export declare function createPgList(options: PgListOptions): PgList;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { PgListenerHealth } from "./pubsub.js";
|
|
2
|
+
import type { PgBossJobQueue } from "./queue.js";
|
|
3
|
+
import { type PgSqlLike } from "./sql.js";
|
|
4
|
+
export interface PgredisTableMetrics {
|
|
5
|
+
tableName: string;
|
|
6
|
+
totalBytes: number;
|
|
7
|
+
liveRows: number;
|
|
8
|
+
deadRows: number;
|
|
9
|
+
lastVacuum: Date | null;
|
|
10
|
+
lastAutovacuum: Date | null;
|
|
11
|
+
ttlBacklog: number | null;
|
|
12
|
+
}
|
|
13
|
+
export interface PgredisCleanupMetrics {
|
|
14
|
+
totalDeleted: number;
|
|
15
|
+
lastDeleted: number;
|
|
16
|
+
lastRunAt: Date | null;
|
|
17
|
+
}
|
|
18
|
+
export interface PgredisListenerMetrics {
|
|
19
|
+
status: PgListenerHealth["status"];
|
|
20
|
+
connected: boolean;
|
|
21
|
+
reconnectAttempts: number;
|
|
22
|
+
listeningChannels: string[];
|
|
23
|
+
lastConnectedAt: number | null;
|
|
24
|
+
lastNotificationAt: number | null;
|
|
25
|
+
lastError: string | null;
|
|
26
|
+
}
|
|
27
|
+
export interface PgredisQueueMetrics {
|
|
28
|
+
queues: unknown[];
|
|
29
|
+
}
|
|
30
|
+
export interface PgredisMetrics {
|
|
31
|
+
namespace?: string;
|
|
32
|
+
tables: PgredisTableMetrics[];
|
|
33
|
+
cleanup?: PgredisCleanupMetrics;
|
|
34
|
+
listener?: PgredisListenerMetrics;
|
|
35
|
+
queue?: PgredisQueueMetrics;
|
|
36
|
+
}
|
|
37
|
+
export interface PgredisMetricsOptions {
|
|
38
|
+
sql: PgSqlLike;
|
|
39
|
+
namespace?: string;
|
|
40
|
+
tablePrefix?: string;
|
|
41
|
+
tableNames?: readonly string[];
|
|
42
|
+
cleanup?: PgredisCleanupMetrics;
|
|
43
|
+
listener?: {
|
|
44
|
+
getHealth(): PgListenerHealth;
|
|
45
|
+
};
|
|
46
|
+
queue?: PgBossJobQueue;
|
|
47
|
+
}
|
|
48
|
+
export declare function collectPgredisMetrics(options: PgredisMetricsOptions): Promise<PgredisMetrics>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { PgredisClient } from "./client.js";
|
|
2
|
+
export type PgredisBatchOperation<T = unknown> = (client: PgredisClient) => Promise<T> | T;
|
|
3
|
+
export declare class PgredisPipeline {
|
|
4
|
+
private readonly runBatch;
|
|
5
|
+
private readonly operations;
|
|
6
|
+
constructor(runBatch: <T>(operation: PgredisBatchOperation<T>) => Promise<T>);
|
|
7
|
+
add<T>(operation: PgredisBatchOperation<T>): this;
|
|
8
|
+
get<T = unknown>(key: string): this;
|
|
9
|
+
set<T = unknown>(key: string, value: T, options?: Parameters<PgredisClient["cache"]["set"]>[2]): this;
|
|
10
|
+
del(key: string): this;
|
|
11
|
+
incr(key: string, amount?: number): this;
|
|
12
|
+
publish(channel: string, payload: Parameters<PgredisClient["pubsub"]["publish"]>[1]): this;
|
|
13
|
+
exec(): Promise<unknown[]>;
|
|
14
|
+
}
|
package/dist/pubsub-index.d.ts
CHANGED
|
@@ -1,60 +1 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
type PgNotifyPayload = string | number | boolean | null | Record<string, unknown> | unknown[];
|
|
4
|
-
interface PgPublisher {
|
|
5
|
-
publish(channel: string, payload: PgNotifyPayload): Promise<void>;
|
|
6
|
-
}
|
|
7
|
-
type NotifyHandler = (channel: string, payload: string) => void;
|
|
8
|
-
interface PgListenerHealth {
|
|
9
|
-
status: "connecting" | "connected" | "reconnecting" | "closed" | "error";
|
|
10
|
-
connected: boolean;
|
|
11
|
-
listeningChannels: string[];
|
|
12
|
-
queuedQueries: number;
|
|
13
|
-
activeQuery: boolean;
|
|
14
|
-
reconnectAttempts: number;
|
|
15
|
-
lastConnectedAt: number | null;
|
|
16
|
-
lastMessageAt: number | null;
|
|
17
|
-
lastNotificationAt: number | null;
|
|
18
|
-
lastError: string | null;
|
|
19
|
-
}
|
|
20
|
-
interface PgListenerEvents {
|
|
21
|
-
connected: PgListenerHealth;
|
|
22
|
-
close: {
|
|
23
|
-
willReconnect: boolean;
|
|
24
|
-
error?: Error;
|
|
25
|
-
};
|
|
26
|
-
error: Error;
|
|
27
|
-
health: PgListenerHealth;
|
|
28
|
-
notification: {
|
|
29
|
-
channel: string;
|
|
30
|
-
payload: string;
|
|
31
|
-
};
|
|
32
|
-
reconnect: {
|
|
33
|
-
attempt: number;
|
|
34
|
-
delayMs: number;
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
interface PgListenerOptions {
|
|
38
|
-
channels?: string[];
|
|
39
|
-
onNotify?: NotifyHandler;
|
|
40
|
-
tls?: boolean | Record<string, unknown>;
|
|
41
|
-
ssl?: boolean | Record<string, unknown>;
|
|
42
|
-
sslMode?: "disable" | "allow" | "prefer" | "require" | "verify-ca" | "verify-full" | "no-verify";
|
|
43
|
-
reconnectDelayMs?: number | ((attempt: number) => number);
|
|
44
|
-
healthCheckIntervalMs?: number;
|
|
45
|
-
logger?: Partial<Pick<typeof console, "debug" | "info" | "warn" | "error">> | false;
|
|
46
|
-
}
|
|
47
|
-
interface PgListenerHandle {
|
|
48
|
-
close(): void;
|
|
49
|
-
notify(channel: string, payload?: string): Promise<void>;
|
|
50
|
-
getHealth(): PgListenerHealth;
|
|
51
|
-
on<K extends keyof PgListenerEvents>(event: K, handler: (payload: PgListenerEvents[K]) => void): () => void;
|
|
52
|
-
off<K extends keyof PgListenerEvents>(event: K, handler: (payload: PgListenerEvents[K]) => void): void;
|
|
53
|
-
}
|
|
54
|
-
declare function createBunPgListener(databaseUrl: string, channels: string[], onNotify: NotifyHandler, options?: PgListenerOptions): PgListenerHandle;
|
|
55
|
-
declare function createBunPgListener(databaseUrl: string, options?: PgListenerOptions): PgListenerHandle;
|
|
56
|
-
declare const createPgListener: typeof createBunPgListener;
|
|
57
|
-
declare function publishPgNotify(sql: PgSqlLike, channel: string, payload: PgNotifyPayload): Promise<void>;
|
|
58
|
-
declare function createPgPublisher(sql: PgSqlLike): PgPublisher;
|
|
59
|
-
|
|
60
|
-
export { type NotifyHandler, type PgListenerEvents, type PgListenerHandle, type PgListenerHealth, type PgListenerOptions, type PgNotifyPayload, type PgPublisher, createBunPgListener, createPgListener, createPgPublisher, publishPgNotify };
|
|
1
|
+
export { createBunPgListener, createPgListener, createPgPublisher, publishPgNotify, type PgNotifyPayload, type NotifyHandler, type PgListenerOptions, type PgListenerHandle, type PgListenerHealth, type PgListenerEvents, type PgPublisher } from "./pubsub.js";
|
package/dist/pubsub.d.ts
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import type { PgSqlLike } from "./sql.js";
|
|
2
|
+
export type PgNotifyPayload = string | number | boolean | null | Record<string, unknown> | unknown[];
|
|
3
|
+
export interface PgPublisher {
|
|
4
|
+
publish(channel: string, payload: PgNotifyPayload): Promise<void>;
|
|
5
|
+
}
|
|
6
|
+
export type NotifyHandler = (channel: string, payload: string) => void;
|
|
7
|
+
export interface PgListenerHealth {
|
|
8
|
+
status: "connecting" | "connected" | "reconnecting" | "closed" | "error";
|
|
9
|
+
connected: boolean;
|
|
10
|
+
listeningChannels: string[];
|
|
11
|
+
queuedQueries: number;
|
|
12
|
+
activeQuery: boolean;
|
|
13
|
+
reconnectAttempts: number;
|
|
14
|
+
lastConnectedAt: number | null;
|
|
15
|
+
lastMessageAt: number | null;
|
|
16
|
+
lastNotificationAt: number | null;
|
|
17
|
+
lastError: string | null;
|
|
18
|
+
}
|
|
19
|
+
export interface PgListenerEvents {
|
|
20
|
+
connected: PgListenerHealth;
|
|
21
|
+
close: {
|
|
22
|
+
willReconnect: boolean;
|
|
23
|
+
error?: Error;
|
|
24
|
+
};
|
|
25
|
+
error: Error;
|
|
26
|
+
health: PgListenerHealth;
|
|
27
|
+
notification: {
|
|
28
|
+
channel: string;
|
|
29
|
+
payload: string;
|
|
30
|
+
};
|
|
31
|
+
reconnect: {
|
|
32
|
+
attempt: number;
|
|
33
|
+
delayMs: number;
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
export interface PgListenerOptions {
|
|
37
|
+
channels?: string[];
|
|
38
|
+
onNotify?: NotifyHandler;
|
|
39
|
+
tls?: boolean | Record<string, unknown>;
|
|
40
|
+
ssl?: boolean | Record<string, unknown>;
|
|
41
|
+
sslMode?: "disable" | "allow" | "prefer" | "require" | "verify-ca" | "verify-full" | "no-verify";
|
|
42
|
+
reconnectDelayMs?: number | ((attempt: number) => number);
|
|
43
|
+
healthCheckIntervalMs?: number;
|
|
44
|
+
logger?: Partial<Pick<typeof console, "debug" | "info" | "warn" | "error">> | false;
|
|
45
|
+
}
|
|
46
|
+
export interface PgListenerHandle {
|
|
47
|
+
close(): void;
|
|
48
|
+
notify(channel: string, payload?: string): Promise<void>;
|
|
49
|
+
getHealth(): PgListenerHealth;
|
|
50
|
+
on<K extends keyof PgListenerEvents>(event: K, handler: (payload: PgListenerEvents[K]) => void): () => void;
|
|
51
|
+
off<K extends keyof PgListenerEvents>(event: K, handler: (payload: PgListenerEvents[K]) => void): void;
|
|
52
|
+
}
|
|
53
|
+
export declare function createBunPgListener(databaseUrl: string, channels: string[], onNotify: NotifyHandler, options?: PgListenerOptions): PgListenerHandle;
|
|
54
|
+
export declare function createBunPgListener(databaseUrl: string, options?: PgListenerOptions): PgListenerHandle;
|
|
55
|
+
export declare const createPgListener: typeof createBunPgListener;
|
|
56
|
+
export declare function publishPgNotify(sql: PgSqlLike, channel: string, payload: PgNotifyPayload): Promise<void>;
|
|
57
|
+
export declare function createPgPublisher(sql: PgSqlLike): PgPublisher;
|