@postgresx/noredis 0.1.0 → 0.5.2

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.
@@ -0,0 +1,494 @@
1
+ import { PgKvCache, PgKvCacheOptions } from './kv-cache.js';
2
+ import { P as PgSqlLike } from './sql-DKf2TDlu.js';
3
+ import { PgHash } from './hash-index.js';
4
+ import { PgList } from './list-index.js';
5
+ import { PgListenerHealth, PgNotifyPayload, PgPublisher } from './pubsub-index.js';
6
+ import { PgSet } from './set-index.js';
7
+ import { PgSortedSet } from './sorted-set-index.js';
8
+
9
+ type PgAdvisoryLockKey = string | number | bigint | readonly [number, number];
10
+ interface PgAdvisoryLockOptions {
11
+ wait?: boolean;
12
+ lockTimeoutMs?: number;
13
+ transaction?: <T>(callback: (tx: PgSqlLike) => Promise<T>) => Promise<T>;
14
+ }
15
+ declare class PgAdvisoryLockBusyError extends Error {
16
+ readonly key: PgAdvisoryLockKey;
17
+ constructor(key: PgAdvisoryLockKey);
18
+ }
19
+ interface LockSqlArgs {
20
+ expression: string;
21
+ params: readonly unknown[];
22
+ }
23
+ declare function advisoryLockKeyToSqlArgs(key: PgAdvisoryLockKey): LockSqlArgs;
24
+ declare function withPgAdvisoryLock<T>(sql: PgSqlLike, key: PgAdvisoryLockKey, callback: (tx: PgSqlLike) => Promise<T>, options?: PgAdvisoryLockOptions): Promise<T>;
25
+ declare class PgAdvisoryLocker {
26
+ private readonly sql;
27
+ constructor(sql: PgSqlLike);
28
+ withLock<T>(key: PgAdvisoryLockKey, callback: (tx: PgSqlLike) => Promise<T>, options?: PgAdvisoryLockOptions): Promise<T>;
29
+ }
30
+ declare function createPgAdvisoryLocker(sql: PgSqlLike): PgAdvisoryLocker;
31
+
32
+ interface PgCounterOptions {
33
+ sql: PgSqlLike;
34
+ namespace?: string;
35
+ tableName?: string;
36
+ }
37
+ interface PgCounterSetOptions {
38
+ ttlMs?: number | null;
39
+ }
40
+ interface PgCounterSchemaOptions {
41
+ unlogged?: boolean;
42
+ }
43
+ declare class PgCounter {
44
+ readonly namespace: string;
45
+ readonly tableName: string;
46
+ readonly quotedTableName: string;
47
+ private readonly sql;
48
+ constructor(options: PgCounterOptions);
49
+ ensureSchema(options?: PgCounterSchemaOptions): Promise<void>;
50
+ get(key: string): Promise<number | null>;
51
+ set(key: string, value: number, options?: PgCounterSetOptions): Promise<number>;
52
+ incr(key: string, amount?: number, options?: PgCounterSetOptions): Promise<number>;
53
+ decr(key: string, amount?: number, options?: PgCounterSetOptions): Promise<number>;
54
+ delete(key: string): Promise<boolean>;
55
+ cleanupExpired(limit?: number): Promise<number>;
56
+ }
57
+ declare function createPgCounter(options: PgCounterOptions): PgCounter;
58
+
59
+ interface PgBossQueueDefinition {
60
+ name?: string;
61
+ [key: string]: unknown;
62
+ }
63
+ type PgBossQueueMap = Record<string, Omit<PgBossQueueDefinition, "name">>;
64
+ interface PgBossQueueOptions {
65
+ connectionString?: string;
66
+ schema?: string;
67
+ queues?: PgBossQueueMap;
68
+ [key: string]: unknown;
69
+ }
70
+ type PgBossOptions = PgBossQueueOptions;
71
+ interface PgBossJob<T extends object = object> {
72
+ id: string;
73
+ name?: string;
74
+ data: T;
75
+ [key: string]: unknown;
76
+ }
77
+ interface PgBossQueueResult {
78
+ name: string;
79
+ [key: string]: unknown;
80
+ }
81
+ interface PgBossSendOptions {
82
+ [key: string]: unknown;
83
+ }
84
+ interface PgBossWorkOptions {
85
+ [key: string]: unknown;
86
+ }
87
+ type PgBossWorkHandler<T extends object = object> = (jobs: PgBossJob<T>[]) => Promise<void> | void;
88
+ interface PgBossLike {
89
+ start(): Promise<void>;
90
+ stop(): Promise<void>;
91
+ createQueue(name: string, options?: Omit<PgBossQueueDefinition, "name">): Promise<void>;
92
+ send<T extends object>(name: string, data?: T | null, options?: PgBossSendOptions): Promise<string | null>;
93
+ work<T extends object>(name: string, options: PgBossWorkOptions, handler: PgBossWorkHandler<T>): Promise<string>;
94
+ getQueues(): Promise<PgBossQueueResult[]>;
95
+ }
96
+ declare class PgBossJobQueue {
97
+ private readonly options;
98
+ private boss;
99
+ constructor(options: PgBossQueueOptions | string);
100
+ start(): Promise<PgBossLike>;
101
+ stop(): Promise<void>;
102
+ ensureQueue(name: string, options?: Omit<PgBossQueueDefinition, "name">): Promise<void>;
103
+ send<T extends object>(name: string, data?: T | null, options?: PgBossSendOptions): Promise<string | null>;
104
+ work<T extends object>(name: string, options: PgBossWorkOptions, handler: PgBossWorkHandler<T>): Promise<string>;
105
+ getBoss(): Promise<PgBossLike>;
106
+ }
107
+ declare function createPgBossJobQueue(options: PgBossQueueOptions | string): PgBossJobQueue;
108
+
109
+ interface PgredisTableMetrics {
110
+ tableName: string;
111
+ totalBytes: number;
112
+ liveRows: number;
113
+ deadRows: number;
114
+ lastVacuum: Date | null;
115
+ lastAutovacuum: Date | null;
116
+ ttlBacklog: number | null;
117
+ }
118
+ interface PgredisCleanupMetrics {
119
+ totalDeleted: number;
120
+ lastDeleted: number;
121
+ lastRunAt: Date | null;
122
+ }
123
+ interface PgredisListenerMetrics {
124
+ status: PgListenerHealth["status"];
125
+ connected: boolean;
126
+ reconnectAttempts: number;
127
+ listeningChannels: string[];
128
+ lastConnectedAt: number | null;
129
+ lastNotificationAt: number | null;
130
+ lastError: string | null;
131
+ }
132
+ interface PgredisQueueMetrics {
133
+ queues: unknown[];
134
+ }
135
+ interface PgredisMetrics {
136
+ namespace?: string;
137
+ tables: PgredisTableMetrics[];
138
+ cleanup?: PgredisCleanupMetrics;
139
+ listener?: PgredisListenerMetrics;
140
+ queue?: PgredisQueueMetrics;
141
+ }
142
+ interface PgredisMetricsOptions {
143
+ sql: PgSqlLike;
144
+ namespace?: string;
145
+ tablePrefix?: string;
146
+ tableNames?: readonly string[];
147
+ cleanup?: PgredisCleanupMetrics;
148
+ listener?: {
149
+ getHealth(): PgListenerHealth;
150
+ };
151
+ queue?: PgBossJobQueue;
152
+ }
153
+ declare function collectPgredisMetrics(options: PgredisMetricsOptions): Promise<PgredisMetrics>;
154
+
155
+ type PgredisBatchOperation<T = unknown> = (client: PgredisClient) => Promise<T> | T;
156
+ declare class PgredisPipeline {
157
+ private readonly runBatch;
158
+ private readonly operations;
159
+ constructor(runBatch: <T>(operation: PgredisBatchOperation<T>) => Promise<T>);
160
+ add<T>(operation: PgredisBatchOperation<T>): this;
161
+ get<T = unknown>(key: string): this;
162
+ set<T = unknown>(key: string, value: T, options?: Parameters<PgredisClient["cache"]["set"]>[2]): this;
163
+ del(key: string): this;
164
+ incr(key: string, amount?: number): this;
165
+ publish(channel: string, payload: Parameters<PgredisClient["pubsub"]["publish"]>[1]): this;
166
+ exec(): Promise<unknown[]>;
167
+ }
168
+
169
+ interface PgRateLimiterOptions {
170
+ sql: PgSqlLike;
171
+ namespace?: string;
172
+ tableName?: string;
173
+ limit: number;
174
+ windowMs: number;
175
+ now?: () => number;
176
+ }
177
+ interface PgRateLimitHitOptions {
178
+ limit?: number;
179
+ windowMs?: number;
180
+ cost?: number;
181
+ }
182
+ interface PgRateLimitSchemaOptions {
183
+ unlogged?: boolean;
184
+ }
185
+ interface PgRateLimitResult {
186
+ allowed: boolean;
187
+ limit: number;
188
+ count: number;
189
+ remaining: number;
190
+ resetAt: Date;
191
+ retryAfterMs: number;
192
+ }
193
+ interface PgSlidingWindowRateLimiterOptions {
194
+ sql: PgSqlLike;
195
+ namespace?: string;
196
+ tableName?: string;
197
+ limit: number;
198
+ windowMs: number;
199
+ precisionMs?: number;
200
+ now?: () => number;
201
+ }
202
+ interface PgTokenBucketRateLimiterOptions {
203
+ sql: PgSqlLike;
204
+ namespace?: string;
205
+ tableName?: string;
206
+ capacity: number;
207
+ refillTokens: number;
208
+ refillIntervalMs: number;
209
+ now?: () => number;
210
+ }
211
+ interface PgTokenBucketResult {
212
+ allowed: boolean;
213
+ capacity: number;
214
+ tokens: number;
215
+ remaining: number;
216
+ retryAfterMs: number;
217
+ }
218
+ declare class PgFixedWindowRateLimiter {
219
+ readonly namespace: string;
220
+ readonly tableName: string;
221
+ readonly quotedTableName: string;
222
+ private readonly sql;
223
+ private readonly now;
224
+ private readonly limit;
225
+ private readonly windowMs;
226
+ constructor(options: PgRateLimiterOptions);
227
+ ensureSchema(options?: PgRateLimitSchemaOptions): Promise<void>;
228
+ hit(key: string, options?: PgRateLimitHitOptions): Promise<PgRateLimitResult>;
229
+ cleanupExpired(limit?: number): Promise<number>;
230
+ }
231
+ declare function createPgFixedWindowRateLimiter(options: PgRateLimiterOptions): PgFixedWindowRateLimiter;
232
+ declare class PgSlidingWindowRateLimiter {
233
+ readonly namespace: string;
234
+ readonly tableName: string;
235
+ readonly quotedTableName: string;
236
+ private readonly sql;
237
+ private readonly now;
238
+ private readonly limit;
239
+ private readonly windowMs;
240
+ private readonly precisionMs;
241
+ constructor(options: PgSlidingWindowRateLimiterOptions);
242
+ ensureSchema(options?: PgRateLimitSchemaOptions): Promise<void>;
243
+ hit(key: string, options?: PgRateLimitHitOptions): Promise<PgRateLimitResult>;
244
+ cleanupExpired(limit?: number): Promise<number>;
245
+ }
246
+ declare class PgTokenBucketRateLimiter {
247
+ readonly namespace: string;
248
+ readonly tableName: string;
249
+ readonly quotedTableName: string;
250
+ private readonly sql;
251
+ private readonly now;
252
+ private readonly capacity;
253
+ private readonly refillTokens;
254
+ private readonly refillIntervalMs;
255
+ constructor(options: PgTokenBucketRateLimiterOptions);
256
+ ensureSchema(options?: PgRateLimitSchemaOptions): Promise<void>;
257
+ consume(key: string, cost?: number): Promise<PgTokenBucketResult>;
258
+ }
259
+ declare function createPgSlidingWindowRateLimiter(options: PgSlidingWindowRateLimiterOptions): PgSlidingWindowRateLimiter;
260
+ declare function createPgTokenBucketRateLimiter(options: PgTokenBucketRateLimiterOptions): PgTokenBucketRateLimiter;
261
+
262
+ interface RedisSetAliasOptions {
263
+ EX?: number;
264
+ PX?: number;
265
+ NX?: boolean;
266
+ XX?: boolean;
267
+ }
268
+ interface PgredisMigrationAliases {
269
+ get<T = unknown>(key: string): Promise<T | null>;
270
+ set<T = unknown>(key: string, value: T, options?: RedisSetAliasOptions): Promise<"OK" | null>;
271
+ del(...keys: string[]): Promise<number>;
272
+ unlink(...keys: string[]): Promise<number>;
273
+ exists(...keys: string[]): Promise<number>;
274
+ type(key: string): Promise<"string" | "none">;
275
+ expire(key: string, seconds: number): Promise<number>;
276
+ pexpire(key: string, milliseconds: number): Promise<number>;
277
+ ttl(key: string): Promise<number>;
278
+ pttl(key: string): Promise<number>;
279
+ persist(key: string): Promise<number>;
280
+ setex<T = unknown>(key: string, seconds: number, value: T): Promise<"OK">;
281
+ psetex<T = unknown>(key: string, milliseconds: number, value: T): Promise<"OK">;
282
+ setnx<T = unknown>(key: string, value: T): Promise<number>;
283
+ getset<T = unknown>(key: string, value: T): Promise<T | null>;
284
+ getdel<T = unknown>(key: string): Promise<T | null>;
285
+ mget<T = unknown>(...keys: string[]): Promise<Array<T | null>>;
286
+ mset<T = unknown>(entries: Record<string, T> | Iterable<readonly [string, T]>): Promise<"OK">;
287
+ keys(pattern?: string): Promise<string[]>;
288
+ scan(cursor?: string | null, count?: number, pattern?: string): Promise<{
289
+ cursor: string | null;
290
+ keys: string[];
291
+ }>;
292
+ rename(key: string, newKey: string): Promise<boolean>;
293
+ incr(key: string): Promise<number>;
294
+ incrby(key: string, amount: number): Promise<number>;
295
+ decr(key: string): Promise<number>;
296
+ decrby(key: string, amount: number): Promise<number>;
297
+ hget<T = unknown>(key: string, field: string): Promise<T | null>;
298
+ hset<T = unknown>(key: string, field: string, value: T): Promise<number>;
299
+ hmset<T = unknown>(key: string, entries: Record<string, T> | Iterable<readonly [string, T]>): Promise<"OK">;
300
+ hmget<T = unknown>(key: string, ...fields: string[]): Promise<Array<T | null>>;
301
+ hgetall<T = unknown>(key: string): Promise<Record<string, T>>;
302
+ hdel(key: string, ...fields: string[]): Promise<number>;
303
+ hexists(key: string, field: string): Promise<number>;
304
+ hlen(key: string): Promise<number>;
305
+ hincrby(key: string, field: string, amount?: number): Promise<number>;
306
+ hkeys(key: string): Promise<string[]>;
307
+ hvals<T = unknown>(key: string): Promise<T[]>;
308
+ hstrlen(key: string, field: string): Promise<number>;
309
+ hscan<T = unknown>(key: string, cursor?: string | null, count?: number): Promise<{
310
+ cursor: string | null;
311
+ entries: Array<readonly [string, T]>;
312
+ }>;
313
+ lpush<T = unknown>(key: string, ...values: T[]): Promise<number>;
314
+ rpush<T = unknown>(key: string, ...values: T[]): Promise<number>;
315
+ lpop<T = unknown>(key: string): Promise<T | null>;
316
+ rpop<T = unknown>(key: string): Promise<T | null>;
317
+ blpop<T = unknown>(key: string | readonly string[], timeoutSeconds?: number): Promise<[string, T] | null>;
318
+ brpop<T = unknown>(key: string | readonly string[], timeoutSeconds?: number): Promise<[string, T] | null>;
319
+ llen(key: string): Promise<number>;
320
+ lrange<T = unknown>(key: string, start?: number, stop?: number): Promise<T[]>;
321
+ lrem(key: string, count: number, value: unknown): Promise<number>;
322
+ sadd(key: string, ...members: string[]): Promise<number>;
323
+ srem(key: string, ...members: string[]): Promise<number>;
324
+ smembers(key: string): Promise<string[]>;
325
+ sismember(key: string, member: string): Promise<number>;
326
+ scard(key: string): Promise<number>;
327
+ sinter(...keys: string[]): Promise<string[]>;
328
+ sunion(...keys: string[]): Promise<string[]>;
329
+ sdiff(...keys: string[]): Promise<string[]>;
330
+ spop(key: string, count?: number): Promise<string[]>;
331
+ srandmember(key: string, count?: number): Promise<string[]>;
332
+ smove(source: string, destination: string, member: string): Promise<number>;
333
+ sscan(key: string, cursor?: string | null, count?: number): Promise<{
334
+ cursor: string | null;
335
+ members: string[];
336
+ }>;
337
+ zadd(key: string, ...args: Array<number | string>): Promise<number>;
338
+ zscore(key: string, member: string): Promise<number | null>;
339
+ zrange(key: string, start: number, stop: number): Promise<string[]>;
340
+ zrevrange(key: string, start: number, stop: number): Promise<string[]>;
341
+ zrangeByScore(key: string, min: number, max: number): Promise<string[]>;
342
+ zrank(key: string, member: string): Promise<number | null>;
343
+ zcount(key: string, min: number, max: number): Promise<number>;
344
+ zrem(key: string, ...members: string[]): Promise<number>;
345
+ zcard(key: string): Promise<number>;
346
+ zincrby(key: string, amount: number, member: string): Promise<number>;
347
+ zpopmin(key: string, count?: number): Promise<Array<{
348
+ member: string;
349
+ score: number;
350
+ }>>;
351
+ zpopmax(key: string, count?: number): Promise<Array<{
352
+ member: string;
353
+ score: number;
354
+ }>>;
355
+ zscan(key: string, cursor?: string | null, count?: number): Promise<{
356
+ cursor: string | null;
357
+ entries: Array<{
358
+ member: string;
359
+ score: number;
360
+ }>;
361
+ }>;
362
+ publish(channel: string, payload: PgNotifyPayload): Promise<number>;
363
+ connect(): Promise<void>;
364
+ quit(): Promise<void>;
365
+ disconnect(): void;
366
+ duplicate(): PgredisMigrationAliases;
367
+ on(event: string, handler: (...args: unknown[]) => void): PgredisMigrationAliases;
368
+ pipeline(): PipelineFacade;
369
+ multi(): PipelineFacade;
370
+ unsupported(command: string): never;
371
+ }
372
+ interface PipelineCommand {
373
+ command: string;
374
+ args: unknown[];
375
+ }
376
+ interface PipelineFacade {
377
+ queue: PipelineCommand[];
378
+ exec(): Promise<Array<[Error | null, unknown]>>;
379
+ add(command: string, ...args: unknown[]): PipelineFacade;
380
+ }
381
+ declare function createPgredisMigrationAliases(client: PgredisClient): PgredisMigrationAliases;
382
+
383
+ interface PgOutboxStreamOptions {
384
+ sql: PgSqlLike;
385
+ namespace?: string;
386
+ tableName?: string;
387
+ }
388
+ interface PgOutboxStreamSchemaOptions {
389
+ unlogged?: boolean;
390
+ }
391
+ interface PgOutboxAppendOptions {
392
+ availableAt?: Date;
393
+ }
394
+ interface PgOutboxReadOptions {
395
+ afterId?: string | number;
396
+ limit?: number;
397
+ includeProcessed?: boolean;
398
+ }
399
+ interface PgOutboxClaimOptions {
400
+ limit?: number;
401
+ visibilityTimeoutMs?: number;
402
+ }
403
+ interface PgOutboxTrimOptions {
404
+ stream?: string;
405
+ beforeId?: string | number;
406
+ maxAgeMs?: number;
407
+ limit?: number;
408
+ }
409
+ interface PgOutboxMessage<T = unknown> {
410
+ id: string;
411
+ stream: string;
412
+ payload: T;
413
+ consumer: string | null;
414
+ deliveryCount: number;
415
+ availableAt: Date;
416
+ lockedUntil: Date | null;
417
+ processedAt: Date | null;
418
+ createdAt: Date;
419
+ }
420
+ interface PgOutboxPendingSummary {
421
+ pending: number;
422
+ locked: number;
423
+ }
424
+ declare class PgOutboxStream {
425
+ readonly namespace: string;
426
+ readonly tableName: string;
427
+ readonly quotedTableName: string;
428
+ private readonly sql;
429
+ constructor(options: PgOutboxStreamOptions);
430
+ ensureSchema(options?: PgOutboxStreamSchemaOptions): Promise<void>;
431
+ append<T = unknown>(stream: string, payload: T, options?: PgOutboxAppendOptions): Promise<string>;
432
+ xadd<T = unknown>(stream: string, payload: T, options?: PgOutboxAppendOptions): Promise<string>;
433
+ read<T = unknown>(stream: string, options?: PgOutboxReadOptions): Promise<PgOutboxMessage<T>[]>;
434
+ claim<T = unknown>(stream: string, consumer: string, options?: PgOutboxClaimOptions): Promise<PgOutboxMessage<T>[]>;
435
+ ack(ids: readonly (string | number)[]): Promise<number>;
436
+ pending(stream?: string): Promise<PgOutboxPendingSummary>;
437
+ trim(options?: PgOutboxTrimOptions): Promise<number>;
438
+ private mapMessage;
439
+ }
440
+ declare function createPgOutboxStream(options: PgOutboxStreamOptions): PgOutboxStream;
441
+
442
+ interface PgredisOptions {
443
+ sql: PgSqlLike;
444
+ namespace?: string;
445
+ tablePrefix?: string;
446
+ cache?: Omit<PgKvCacheOptions, "sql" | "namespace" | "tableName"> & {
447
+ tableName?: string;
448
+ };
449
+ rateLimit?: {
450
+ limit: number;
451
+ windowMs: number;
452
+ tableName?: string;
453
+ };
454
+ queue?: PgBossQueueOptions | string;
455
+ outbox?: {
456
+ tableName?: string;
457
+ };
458
+ }
459
+ interface PgredisClient {
460
+ cache: PgKvCache;
461
+ counter: PgCounter;
462
+ hash: PgHash;
463
+ set: PgSet;
464
+ list: PgList;
465
+ sortedSet: PgSortedSet;
466
+ locks: PgAdvisoryLocker;
467
+ pubsub: PgPublisher;
468
+ rateLimit?: PgFixedWindowRateLimiter;
469
+ queue?: PgBossJobQueue;
470
+ outbox: PgOutboxStream;
471
+ stream: PgOutboxStream;
472
+ redis: PgredisMigrationAliases;
473
+ batch<T>(operation: PgredisBatchOperation<T>): Promise<T>;
474
+ pipeline(): PgredisPipeline;
475
+ health(): Promise<{
476
+ ok: true;
477
+ }>;
478
+ stats(): Promise<{
479
+ cache: ReturnType<PgKvCache["stats"]>;
480
+ queue?: PgBossQueueResult[];
481
+ cleanup: PgredisCleanupMetrics;
482
+ }>;
483
+ metrics(): Promise<PgredisMetrics>;
484
+ cleanupExpired(limit?: number): Promise<Record<string, number>>;
485
+ startCleanupWorker(options?: {
486
+ intervalMs?: number;
487
+ limit?: number;
488
+ onError?: (error: unknown) => void;
489
+ }): () => void;
490
+ ensureSchema(): Promise<void>;
491
+ }
492
+ declare function createPgredis(options: PgredisOptions): PgredisClient;
493
+
494
+ export { collectPgredisMetrics as $, type PgOutboxStreamSchemaOptions as A, type PgOutboxTrimOptions as B, type PgRateLimitHitOptions as C, type PgRateLimitResult as D, type PgRateLimitSchemaOptions as E, type PgRateLimiterOptions as F, PgSlidingWindowRateLimiter as G, type PgSlidingWindowRateLimiterOptions as H, PgTokenBucketRateLimiter as I, type PgTokenBucketRateLimiterOptions as J, type PgTokenBucketResult as K, type PgredisBatchOperation as L, type PgredisCleanupMetrics as M, type PgredisClient as N, type PgredisListenerMetrics as O, PgAdvisoryLockBusyError as P, type PgredisMetrics as Q, type PgredisMetricsOptions as R, type PgredisMigrationAliases as S, type PgredisOptions as T, PgredisPipeline as U, type PgredisQueueMetrics as V, type PgredisTableMetrics as W, type PipelineCommand as X, type PipelineFacade as Y, type RedisSetAliasOptions as Z, advisoryLockKeyToSqlArgs as _, type PgAdvisoryLockKey as a, createPgAdvisoryLocker as a0, createPgBossJobQueue as a1, createPgCounter as a2, createPgFixedWindowRateLimiter as a3, createPgOutboxStream as a4, createPgSlidingWindowRateLimiter as a5, createPgTokenBucketRateLimiter as a6, createPgredis as a7, createPgredisMigrationAliases as a8, withPgAdvisoryLock as a9, type PgAdvisoryLockOptions as b, PgAdvisoryLocker as c, type PgBossJob as d, PgBossJobQueue as e, type PgBossLike as f, type PgBossOptions as g, type PgBossQueueDefinition as h, type PgBossQueueMap as i, type PgBossQueueOptions as j, type PgBossQueueResult as k, type PgBossSendOptions as l, type PgBossWorkHandler as m, type PgBossWorkOptions as n, PgCounter as o, type PgCounterOptions as p, type PgCounterSchemaOptions as q, type PgCounterSetOptions as r, PgFixedWindowRateLimiter as s, type PgOutboxAppendOptions as t, type PgOutboxClaimOptions as u, type PgOutboxMessage as v, type PgOutboxPendingSummary as w, type PgOutboxReadOptions as x, PgOutboxStream as y, type PgOutboxStreamOptions as z };
@@ -0,0 +1,43 @@
1
+ import { P as PgSqlLike } from './sql-DKf2TDlu.js';
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 };
@@ -0,0 +1,9 @@
1
+ import {
2
+ PgHash,
3
+ createPgHash
4
+ } from "./chunk-5ZGPCW5N.js";
5
+ import "./chunk-RWRM5RVO.js";
6
+ export {
7
+ PgHash,
8
+ createPgHash
9
+ };