🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

@reddb-io/client

Package Overview
Dependencies
Maintainers
1
Versions
258
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@reddb-io/client - npm Package Compare versions

Comparing version
1.22.0-rc.246
to
1.22.0-rc.251
+1
-1
index.browser.d.ts

@@ -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[]>

@@ -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[]>

{
"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",

@@ -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 @@ ```

@@ -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) : []
}