@postgresx/noredis 0.10.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.
Files changed (44) hide show
  1. package/README.md +5 -0
  2. package/dist/adapters/bun.d.ts +5 -8
  3. package/dist/adapters/ioredis.d.ts +12 -15
  4. package/dist/adapters/ioredis.js +8 -1
  5. package/dist/adapters/node.d.ts +11 -13
  6. package/dist/adapters/redis.d.ts +12 -15
  7. package/dist/adapters/redis.js +8 -1
  8. package/dist/adapters/web.d.ts +11 -16
  9. package/dist/advisory-lock.d.ts +24 -0
  10. package/dist/{chunk-WRMEEA6T.js → chunk-6PU53SX7.js} +16 -2
  11. package/dist/{chunk-HW3WONAC.js → chunk-JRMUZTI4.js} +128 -15
  12. package/dist/{chunk-YSWHEFPX.js → chunk-LN56Y4FI.js} +68 -0
  13. package/dist/{chunk-7T5O55TM.js → chunk-QIWUTOLC.js} +50 -15
  14. package/dist/client.d.ts +70 -0
  15. package/dist/counter.d.ts +27 -0
  16. package/dist/errors.d.ts +5 -0
  17. package/dist/hash-index.d.ts +1 -43
  18. package/dist/hash.d.ts +40 -0
  19. package/dist/index.d.ts +17 -16
  20. package/dist/index.js +4 -4
  21. package/dist/kv-cache.d.ts +36 -20
  22. package/dist/kv-cache.js +1 -1
  23. package/dist/kv.d.ts +1 -3
  24. package/dist/kv.js +1 -1
  25. package/dist/list-index.d.ts +1 -53
  26. package/dist/list-index.js +1 -1
  27. package/dist/list.d.ts +74 -0
  28. package/dist/metrics.d.ts +48 -0
  29. package/dist/pipeline.d.ts +14 -0
  30. package/dist/pubsub-index.d.ts +1 -60
  31. package/dist/pubsub.d.ts +57 -0
  32. package/dist/queue.d.ts +50 -0
  33. package/dist/rate-limit.d.ts +108 -0
  34. package/dist/redis-aliases.d.ts +129 -0
  35. package/dist/set-index.d.ts +1 -42
  36. package/dist/set.d.ts +39 -0
  37. package/dist/sorted-set-index.d.ts +1 -58
  38. package/dist/sorted-set-index.js +1 -1
  39. package/dist/sorted-set.d.ts +73 -0
  40. package/dist/sql.d.ts +8 -0
  41. package/dist/stream.d.ts +59 -0
  42. package/package.json +4 -4
  43. package/dist/client-ChVkyyno.d.ts +0 -513
  44. package/dist/sql-DKf2TDlu.d.ts +0 -10
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
+ }
@@ -1,60 +1 @@
1
- import { P as PgSqlLike } from './sql-DKf2TDlu.js';
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";
@@ -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;
@@ -0,0 +1,50 @@
1
+ export interface PgBossQueueDefinition {
2
+ name?: string;
3
+ [key: string]: unknown;
4
+ }
5
+ export type PgBossQueueMap = Record<string, Omit<PgBossQueueDefinition, "name">>;
6
+ export interface PgBossQueueOptions {
7
+ connectionString?: string;
8
+ schema?: string;
9
+ queues?: PgBossQueueMap;
10
+ [key: string]: unknown;
11
+ }
12
+ export type PgBossOptions = PgBossQueueOptions;
13
+ export interface PgBossJob<T extends object = object> {
14
+ id: string;
15
+ name?: string;
16
+ data: T;
17
+ [key: string]: unknown;
18
+ }
19
+ export interface PgBossQueueResult {
20
+ name: string;
21
+ [key: string]: unknown;
22
+ }
23
+ export interface PgBossSendOptions {
24
+ [key: string]: unknown;
25
+ }
26
+ export interface PgBossWorkOptions {
27
+ [key: string]: unknown;
28
+ }
29
+ export type PgBossWorkHandler<T extends object = object> = (jobs: PgBossJob<T>[]) => Promise<void> | void;
30
+ export interface PgBossLike {
31
+ start(): Promise<void>;
32
+ stop(): Promise<void>;
33
+ createQueue(name: string, options?: Omit<PgBossQueueDefinition, "name">): Promise<void>;
34
+ send<T extends object>(name: string, data?: T | null, options?: PgBossSendOptions): Promise<string | null>;
35
+ work<T extends object>(name: string, options: PgBossWorkOptions, handler: PgBossWorkHandler<T>): Promise<string>;
36
+ getQueues(): Promise<PgBossQueueResult[]>;
37
+ }
38
+ export declare class PgBossJobQueue {
39
+ private readonly options;
40
+ private boss;
41
+ constructor(options: PgBossQueueOptions | string);
42
+ start(): Promise<PgBossLike>;
43
+ stop(): Promise<void>;
44
+ ensureQueue(name: string, options?: Omit<PgBossQueueDefinition, "name">): Promise<void>;
45
+ send<T extends object>(name: string, data?: T | null, options?: PgBossSendOptions): Promise<string | null>;
46
+ work<T extends object>(name: string, options: PgBossWorkOptions, handler: PgBossWorkHandler<T>): Promise<string>;
47
+ getBoss(): Promise<PgBossLike>;
48
+ }
49
+ export declare function createPgBossJobQueue(options: PgBossQueueOptions | string): PgBossJobQueue;
50
+ export type { PgBossJob as Job, PgBossLike as PgBoss, PgBossQueueDefinition as Queue, PgBossQueueResult as QueueResult, PgBossSendOptions as SendOptions, PgBossWorkHandler as WorkHandler, PgBossWorkOptions as WorkOptions };
@@ -0,0 +1,108 @@
1
+ import { type PgSqlLike } from "./sql.js";
2
+ export interface PgRateLimiterOptions {
3
+ sql: PgSqlLike;
4
+ namespace?: string;
5
+ tableName?: string;
6
+ limit: number;
7
+ windowMs: number;
8
+ now?: () => number;
9
+ }
10
+ export interface PgRateLimitHitOptions {
11
+ limit?: number;
12
+ windowMs?: number;
13
+ cost?: number;
14
+ }
15
+ export interface PgRateLimitStateOptions {
16
+ limit?: number;
17
+ windowMs?: number;
18
+ }
19
+ export interface PgRateLimitBlockOptions extends PgRateLimitStateOptions {
20
+ blockMs: number;
21
+ count?: number;
22
+ }
23
+ export interface PgRateLimitSchemaOptions {
24
+ unlogged?: boolean;
25
+ }
26
+ export interface PgRateLimitResult {
27
+ allowed: boolean;
28
+ limit: number;
29
+ count: number;
30
+ remaining: number;
31
+ resetAt: Date;
32
+ retryAfterMs: number;
33
+ }
34
+ export interface PgSlidingWindowRateLimiterOptions {
35
+ sql: PgSqlLike;
36
+ namespace?: string;
37
+ tableName?: string;
38
+ limit: number;
39
+ windowMs: number;
40
+ precisionMs?: number;
41
+ now?: () => number;
42
+ }
43
+ export interface PgTokenBucketRateLimiterOptions {
44
+ sql: PgSqlLike;
45
+ namespace?: string;
46
+ tableName?: string;
47
+ capacity: number;
48
+ refillTokens: number;
49
+ refillIntervalMs: number;
50
+ now?: () => number;
51
+ }
52
+ export interface PgTokenBucketResult {
53
+ allowed: boolean;
54
+ capacity: number;
55
+ tokens: number;
56
+ remaining: number;
57
+ retryAfterMs: number;
58
+ }
59
+ export declare class PgFixedWindowRateLimiter {
60
+ readonly namespace: string;
61
+ readonly tableName: string;
62
+ readonly quotedTableName: string;
63
+ private readonly sql;
64
+ private readonly now;
65
+ private readonly limit;
66
+ private readonly windowMs;
67
+ constructor(options: PgRateLimiterOptions);
68
+ ensureSchema(options?: PgRateLimitSchemaOptions): Promise<void>;
69
+ hit(key: string, options?: PgRateLimitHitOptions): Promise<PgRateLimitResult>;
70
+ get(key: string, options?: PgRateLimitStateOptions): Promise<PgRateLimitResult | null>;
71
+ reward(key: string, cost?: number, options?: PgRateLimitStateOptions): Promise<PgRateLimitResult | null>;
72
+ private decrementWindow;
73
+ block(key: string, options: PgRateLimitBlockOptions): Promise<PgRateLimitResult>;
74
+ delete(key: string): Promise<boolean>;
75
+ cleanupExpired(limit?: number): Promise<number>;
76
+ private resultFromRow;
77
+ private getActiveBlock;
78
+ }
79
+ export declare function createPgFixedWindowRateLimiter(options: PgRateLimiterOptions): PgFixedWindowRateLimiter;
80
+ export declare class PgSlidingWindowRateLimiter {
81
+ readonly namespace: string;
82
+ readonly tableName: string;
83
+ readonly quotedTableName: string;
84
+ private readonly sql;
85
+ private readonly now;
86
+ private readonly limit;
87
+ private readonly windowMs;
88
+ private readonly precisionMs;
89
+ constructor(options: PgSlidingWindowRateLimiterOptions);
90
+ ensureSchema(options?: PgRateLimitSchemaOptions): Promise<void>;
91
+ hit(key: string, options?: PgRateLimitHitOptions): Promise<PgRateLimitResult>;
92
+ cleanupExpired(limit?: number): Promise<number>;
93
+ }
94
+ export declare class PgTokenBucketRateLimiter {
95
+ readonly namespace: string;
96
+ readonly tableName: string;
97
+ readonly quotedTableName: string;
98
+ private readonly sql;
99
+ private readonly now;
100
+ private readonly capacity;
101
+ private readonly refillTokens;
102
+ private readonly refillIntervalMs;
103
+ constructor(options: PgTokenBucketRateLimiterOptions);
104
+ ensureSchema(options?: PgRateLimitSchemaOptions): Promise<void>;
105
+ consume(key: string, cost?: number): Promise<PgTokenBucketResult>;
106
+ }
107
+ export declare function createPgSlidingWindowRateLimiter(options: PgSlidingWindowRateLimiterOptions): PgSlidingWindowRateLimiter;
108
+ export declare function createPgTokenBucketRateLimiter(options: PgTokenBucketRateLimiterOptions): PgTokenBucketRateLimiter;
@@ -0,0 +1,129 @@
1
+ import type { PgredisClient } from "./client.js";
2
+ import type { PgNotifyPayload } from "./pubsub.js";
3
+ export interface RedisSetAliasOptions {
4
+ EX?: number;
5
+ PX?: number;
6
+ NX?: boolean;
7
+ XX?: boolean;
8
+ }
9
+ export interface PgredisMigrationAliases {
10
+ get<T = unknown>(key: string): Promise<T | null>;
11
+ set<T = unknown>(key: string, value: T, options?: RedisSetAliasOptions): Promise<"OK" | null>;
12
+ del(...keys: string[]): Promise<number>;
13
+ unlink(...keys: string[]): Promise<number>;
14
+ exists(...keys: string[]): Promise<number>;
15
+ type(key: string): Promise<"string" | "none">;
16
+ expire(key: string, seconds: number): Promise<number>;
17
+ pexpire(key: string, milliseconds: number): Promise<number>;
18
+ ttl(key: string): Promise<number>;
19
+ pttl(key: string): Promise<number>;
20
+ persist(key: string): Promise<number>;
21
+ setex<T = unknown>(key: string, seconds: number, value: T): Promise<"OK">;
22
+ psetex<T = unknown>(key: string, milliseconds: number, value: T): Promise<"OK">;
23
+ setnx<T = unknown>(key: string, value: T): Promise<number>;
24
+ getset<T = unknown>(key: string, value: T): Promise<T | null>;
25
+ getdel<T = unknown>(key: string): Promise<T | null>;
26
+ mget<T = unknown>(...keys: string[]): Promise<Array<T | null>>;
27
+ mset<T = unknown>(entries: Record<string, T> | Iterable<readonly [string, T]>): Promise<"OK">;
28
+ keys(pattern?: string): Promise<string[]>;
29
+ scan(cursor?: string | null, count?: number, pattern?: string): Promise<{
30
+ cursor: string | null;
31
+ keys: string[];
32
+ }>;
33
+ rename(key: string, newKey: string): Promise<boolean>;
34
+ incr(key: string): Promise<number>;
35
+ incrby(key: string, amount: number): Promise<number>;
36
+ decr(key: string): Promise<number>;
37
+ decrby(key: string, amount: number): Promise<number>;
38
+ hget<T = unknown>(key: string, field: string): Promise<T | null>;
39
+ hset<T = unknown>(key: string, field: string, value: T): Promise<number>;
40
+ hmset<T = unknown>(key: string, entries: Record<string, T> | Iterable<readonly [string, T]>): Promise<"OK">;
41
+ hmget<T = unknown>(key: string, ...fields: string[]): Promise<Array<T | null>>;
42
+ hgetall<T = unknown>(key: string): Promise<Record<string, T>>;
43
+ hdel(key: string, ...fields: string[]): Promise<number>;
44
+ hexists(key: string, field: string): Promise<number>;
45
+ hlen(key: string): Promise<number>;
46
+ hincrby(key: string, field: string, amount?: number): Promise<number>;
47
+ hkeys(key: string): Promise<string[]>;
48
+ hvals<T = unknown>(key: string): Promise<T[]>;
49
+ hstrlen(key: string, field: string): Promise<number>;
50
+ hscan<T = unknown>(key: string, cursor?: string | null, count?: number): Promise<{
51
+ cursor: string | null;
52
+ entries: Array<readonly [string, T]>;
53
+ }>;
54
+ lpush<T = unknown>(key: string, ...values: T[]): Promise<number>;
55
+ rpush<T = unknown>(key: string, ...values: T[]): Promise<number>;
56
+ lpop<T = unknown>(key: string): Promise<T | null>;
57
+ rpop<T = unknown>(key: string): Promise<T | null>;
58
+ blpop<T = unknown>(key: string | readonly string[], timeoutSeconds?: number): Promise<[string, T] | null>;
59
+ brpop<T = unknown>(key: string | readonly string[], timeoutSeconds?: number): Promise<[string, T] | null>;
60
+ llen(key: string): Promise<number>;
61
+ lrange<T = unknown>(key: string, start?: number, stop?: number): Promise<T[]>;
62
+ lrem(key: string, count: number, value: unknown): Promise<number>;
63
+ ltrim(key: string, start?: number, stop?: number): Promise<"OK">;
64
+ lindex<T = unknown>(key: string, index: number): Promise<T | null>;
65
+ lset<T = unknown>(key: string, index: number, value: T): Promise<"OK">;
66
+ sadd(key: string, ...members: string[]): Promise<number>;
67
+ srem(key: string, ...members: string[]): Promise<number>;
68
+ smembers(key: string): Promise<string[]>;
69
+ sismember(key: string, member: string): Promise<number>;
70
+ scard(key: string): Promise<number>;
71
+ sinter(...keys: string[]): Promise<string[]>;
72
+ sunion(...keys: string[]): Promise<string[]>;
73
+ sdiff(...keys: string[]): Promise<string[]>;
74
+ spop(key: string, count?: number): Promise<string[]>;
75
+ srandmember(key: string, count?: number): Promise<string[]>;
76
+ smove(source: string, destination: string, member: string): Promise<number>;
77
+ sscan(key: string, cursor?: string | null, count?: number): Promise<{
78
+ cursor: string | null;
79
+ members: string[];
80
+ }>;
81
+ zadd(key: string, ...args: Array<number | string>): Promise<number>;
82
+ zscore(key: string, member: string): Promise<number | null>;
83
+ zrange(key: string, start: number, stop: number): Promise<string[]>;
84
+ zrevrange(key: string, start: number, stop: number): Promise<string[]>;
85
+ zrangeByScore(key: string, min: number, max: number): Promise<string[]>;
86
+ zrank(key: string, member: string): Promise<number | null>;
87
+ zcount(key: string, min: number, max: number): Promise<number>;
88
+ zrem(key: string, ...members: string[]): Promise<number>;
89
+ zremrangebyscore(key: string, min?: number, max?: number): Promise<number>;
90
+ zremrangebyrank(key: string, start?: number, stop?: number): Promise<number>;
91
+ zmscore(key: string, ...members: string[]): Promise<Array<number | null>>;
92
+ zrevrank(key: string, member: string): Promise<number | null>;
93
+ zcard(key: string): Promise<number>;
94
+ zincrby(key: string, amount: number, member: string): Promise<number>;
95
+ zpopmin(key: string, count?: number): Promise<Array<{
96
+ member: string;
97
+ score: number;
98
+ }>>;
99
+ zpopmax(key: string, count?: number): Promise<Array<{
100
+ member: string;
101
+ score: number;
102
+ }>>;
103
+ zscan(key: string, cursor?: string | null, count?: number): Promise<{
104
+ cursor: string | null;
105
+ entries: Array<{
106
+ member: string;
107
+ score: number;
108
+ }>;
109
+ }>;
110
+ publish(channel: string, payload: PgNotifyPayload): Promise<number>;
111
+ connect(): Promise<void>;
112
+ quit(): Promise<void>;
113
+ disconnect(): void;
114
+ duplicate(): PgredisMigrationAliases;
115
+ on(event: string, handler: (...args: unknown[]) => void): PgredisMigrationAliases;
116
+ pipeline(): PipelineFacade;
117
+ multi(): PipelineFacade;
118
+ unsupported(command: string): never;
119
+ }
120
+ export interface PipelineCommand {
121
+ command: string;
122
+ args: unknown[];
123
+ }
124
+ export interface PipelineFacade {
125
+ queue: PipelineCommand[];
126
+ exec(): Promise<Array<[Error | null, unknown]>>;
127
+ add(command: string, ...args: unknown[]): PipelineFacade;
128
+ }
129
+ export declare function createPgredisMigrationAliases(client: PgredisClient): PgredisMigrationAliases;
@@ -1,42 +1 @@
1
- import { P as PgSqlLike } from './sql-DKf2TDlu.js';
2
-
3
- interface PgSetOptions {
4
- sql: PgSqlLike;
5
- namespace?: string;
6
- tableName?: string;
7
- }
8
- interface PgSetSchemaOptions {
9
- unlogged?: boolean;
10
- }
11
- interface PgSetScanResult {
12
- cursor: string | null;
13
- members: string[];
14
- }
15
- declare class PgSet {
16
- readonly namespace: string;
17
- readonly tableName: string;
18
- readonly quotedTableName: string;
19
- private readonly sql;
20
- constructor(options: PgSetOptions);
21
- ensureSchema(options?: PgSetSchemaOptions): Promise<void>;
22
- sadd(key: string, ...members: string[]): Promise<number>;
23
- srem(key: string, ...members: string[]): Promise<number>;
24
- sismember(key: string, member: string): Promise<boolean>;
25
- smembers(key: string): Promise<string[]>;
26
- sinter(...keys: string[]): Promise<string[]>;
27
- sunion(...keys: string[]): Promise<string[]>;
28
- sdiff(key: string, ...otherKeys: string[]): Promise<string[]>;
29
- scard(key: string): Promise<number>;
30
- sclear(key: string): Promise<number>;
31
- sscan(key: string, cursor?: string | null, count?: number): Promise<PgSetScanResult>;
32
- expire(key: string, ttlMs: number): Promise<number>;
33
- persist(key: string): Promise<number>;
34
- ttl(key: string): Promise<number | null>;
35
- spop(key: string, count?: number): Promise<string[]>;
36
- srandmember(key: string, count?: number): Promise<string[]>;
37
- smove(source: string, destination: string, member: string): Promise<boolean>;
38
- cleanupExpired(limit?: number): Promise<number>;
39
- }
40
- declare function createPgSet(options: PgSetOptions): PgSet;
41
-
42
- export { PgSet, type PgSetOptions, type PgSetScanResult, type PgSetSchemaOptions, createPgSet };
1
+ export { createPgSet, PgSet, type PgSetOptions, type PgSetSchemaOptions, type PgSetScanResult } from "./set.js";
package/dist/set.d.ts ADDED
@@ -0,0 +1,39 @@
1
+ import { type PgSqlLike } from "./sql.js";
2
+ export interface PgSetOptions {
3
+ sql: PgSqlLike;
4
+ namespace?: string;
5
+ tableName?: string;
6
+ }
7
+ export interface PgSetSchemaOptions {
8
+ unlogged?: boolean;
9
+ }
10
+ export interface PgSetScanResult {
11
+ cursor: string | null;
12
+ members: string[];
13
+ }
14
+ export declare class PgSet {
15
+ readonly namespace: string;
16
+ readonly tableName: string;
17
+ readonly quotedTableName: string;
18
+ private readonly sql;
19
+ constructor(options: PgSetOptions);
20
+ ensureSchema(options?: PgSetSchemaOptions): Promise<void>;
21
+ sadd(key: string, ...members: string[]): Promise<number>;
22
+ srem(key: string, ...members: string[]): Promise<number>;
23
+ sismember(key: string, member: string): Promise<boolean>;
24
+ smembers(key: string): Promise<string[]>;
25
+ sinter(...keys: string[]): Promise<string[]>;
26
+ sunion(...keys: string[]): Promise<string[]>;
27
+ sdiff(key: string, ...otherKeys: string[]): Promise<string[]>;
28
+ scard(key: string): Promise<number>;
29
+ sclear(key: string): Promise<number>;
30
+ sscan(key: string, cursor?: string | null, count?: number): Promise<PgSetScanResult>;
31
+ expire(key: string, ttlMs: number): Promise<number>;
32
+ persist(key: string): Promise<number>;
33
+ ttl(key: string): Promise<number | null>;
34
+ spop(key: string, count?: number): Promise<string[]>;
35
+ srandmember(key: string, count?: number): Promise<string[]>;
36
+ smove(source: string, destination: string, member: string): Promise<boolean>;
37
+ cleanupExpired(limit?: number): Promise<number>;
38
+ }
39
+ export declare function createPgSet(options: PgSetOptions): PgSet;