@reddb-io/client
Advanced tools
@@ -186,3 +186,3 @@ /** | ||
| value: unknown, | ||
| options?: { priority?: number }, | ||
| options?: { priority?: number; key?: string; dedup?: string; delay?: string; at?: number }, | ||
| ): Promise<QueryResult> | ||
@@ -189,0 +189,0 @@ pop(queue: string, count?: number): Promise<unknown[]> |
+1
-1
@@ -182,3 +182,3 @@ /** | ||
| value: unknown, | ||
| options?: { priority?: number }, | ||
| options?: { priority?: number; key?: string; dedup?: string; delay?: string; at?: number }, | ||
| ): Promise<QueryResult> | ||
@@ -185,0 +185,0 @@ pop(queue: string, count?: number): Promise<unknown[]> |
+1
-1
| { | ||
| "name": "@reddb-io/client", | ||
| "version": "1.22.0-rc.246", | ||
| "version": "1.22.0-rc.251", | ||
| "description": "Thin remote-only RedDB driver. Downloads the `red_client` binary on install. Speaks RedWire/gRPC/HTTP. Embedded URIs (memory://, file://, red:///path) are rejected — use @reddb-io/sdk for those.", | ||
@@ -5,0 +5,0 @@ "type": "module", |
+8
-0
@@ -61,2 +61,10 @@ # @reddb-io/client | ||
| await db.queues.create('jobs') | ||
| await db.queues.push('jobs', { task: 'email', orderId: 42 }, { dedup: 'outbox:email:42' }) | ||
| await db.queues.push( | ||
| 'jobs', | ||
| { task: 'rebuild_account', accountId: 'acct_123' }, | ||
| { key: 'acct_123' }, | ||
| ) | ||
| await db.close() | ||
@@ -63,0 +71,0 @@ ``` |
+23
-3
@@ -9,5 +9,5 @@ import { RedDBError } from './protocol.js' | ||
| push(queue, value, options = {}) { | ||
| const priority = options.priority != null ? ` PRIORITY ${queuePriority(options.priority)}` : '' | ||
| const suffix = queuePushOptions(options) | ||
| return this.client.call('query', { | ||
| sql: `QUEUE PUSH ${queueIdentifier(queue)} ${queueValueLiteral(value)}${priority}`, | ||
| sql: `QUEUE PUSH ${queueIdentifier(queue)} ${queueValueLiteral(value)}${suffix}`, | ||
| }) | ||
@@ -94,11 +94,31 @@ } | ||
| function queuePushOptions(options) { | ||
| if (options.key != null && (options.delay != null || options.at != null)) { | ||
| throw new RedDBError( | ||
| 'INVALID_ARGUMENT', | ||
| 'QUEUE PUSH KEY cannot be combined with DELAY / AVAILABLE AT', | ||
| ) | ||
| } | ||
| let suffix = '' | ||
| if (options.priority != null) suffix += ` PRIORITY ${queuePriority(options.priority)}` | ||
| if (options.key != null) suffix += ` KEY ${queueStringLiteral(options.key)}` | ||
| if (options.dedup != null) suffix += ` DEDUP ${queueStringLiteral(options.dedup)}` | ||
| if (options.delay != null) suffix += ` DELAY ${options.delay}` | ||
| if (options.at != null) suffix += ` AVAILABLE AT ${options.at}` | ||
| return suffix | ||
| } | ||
| function queueValueLiteral(value) { | ||
| if (typeof value === 'number' || typeof value === 'boolean') return String(value) | ||
| if (value == null) return 'NULL' | ||
| if (typeof value === 'string') return `'${value.replace(/'/g, "''")}'` | ||
| if (typeof value === 'string') return queueStringLiteral(value) | ||
| return JSON.stringify(value) | ||
| } | ||
| function queueStringLiteral(value) { | ||
| return `'${String(value).replace(/'/g, "''")}'` | ||
| } | ||
| function queuePayloads(result) { | ||
| return Array.isArray(result?.rows) ? result.rows.map((row) => row.payload) : [] | ||
| } |
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
245333
0.43%6263
0.29%228
3.64%