@reddb-io/cli 1.22.0-rc.250 → 1.22.0-rc.252
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/drivers/js/package.json +1 -1
- package/drivers/js/src/queue.js +23 -3
- package/package.json +1 -1
package/drivers/js/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reddb-io/sdk",
|
|
3
|
-
"version": "1.22.0-rc.
|
|
3
|
+
"version": "1.22.0-rc.252",
|
|
4
4
|
"description": "Official embedded RedDB SDK — launches a local red binary over stdio JSON-RPC. Use @reddb-io/client for remote HTTP, gRPC, and RedWire.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.js",
|
package/drivers/js/src/queue.js
CHANGED
|
@@ -14,9 +14,9 @@ export class QueueClient {
|
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
push(queue, value, options = {}) {
|
|
17
|
-
const
|
|
17
|
+
const suffix = queuePushOptions(options)
|
|
18
18
|
return this.client.call('query', {
|
|
19
|
-
sql: `QUEUE PUSH ${queueIdentifier(queue)} ${queueValueLiteral(value)}${
|
|
19
|
+
sql: `QUEUE PUSH ${queueIdentifier(queue)} ${queueValueLiteral(value)}${suffix}`,
|
|
20
20
|
})
|
|
21
21
|
}
|
|
22
22
|
|
|
@@ -103,13 +103,33 @@ function queuePriority(priority) {
|
|
|
103
103
|
return String(priority)
|
|
104
104
|
}
|
|
105
105
|
|
|
106
|
+
function queuePushOptions(options) {
|
|
107
|
+
if (options.key != null && (options.delay != null || options.at != null)) {
|
|
108
|
+
throw new RedDBError(
|
|
109
|
+
'INVALID_ARGUMENT',
|
|
110
|
+
'QUEUE PUSH KEY cannot be combined with DELAY / AVAILABLE AT',
|
|
111
|
+
)
|
|
112
|
+
}
|
|
113
|
+
let suffix = ''
|
|
114
|
+
if (options.priority != null) suffix += ` PRIORITY ${queuePriority(options.priority)}`
|
|
115
|
+
if (options.key != null) suffix += ` KEY ${queueStringLiteral(options.key)}`
|
|
116
|
+
if (options.dedup != null) suffix += ` DEDUP ${queueStringLiteral(options.dedup)}`
|
|
117
|
+
if (options.delay != null) suffix += ` DELAY ${options.delay}`
|
|
118
|
+
if (options.at != null) suffix += ` AVAILABLE AT ${options.at}`
|
|
119
|
+
return suffix
|
|
120
|
+
}
|
|
121
|
+
|
|
106
122
|
function queueValueLiteral(value) {
|
|
107
123
|
if (typeof value === 'number' || typeof value === 'boolean') return String(value)
|
|
108
124
|
if (value == null) return 'NULL'
|
|
109
|
-
if (typeof value === 'string') return
|
|
125
|
+
if (typeof value === 'string') return queueStringLiteral(value)
|
|
110
126
|
return JSON.stringify(value)
|
|
111
127
|
}
|
|
112
128
|
|
|
129
|
+
function queueStringLiteral(value) {
|
|
130
|
+
return `'${String(value).replace(/'/g, "''")}'`
|
|
131
|
+
}
|
|
132
|
+
|
|
113
133
|
function queuePayloads(result) {
|
|
114
134
|
return Array.isArray(result?.rows) ? result.rows.map((row) => row.payload) : []
|
|
115
135
|
}
|