lonnymq 0.0.16 → 0.0.17
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/dist/index.cjs +56 -56
- package/dist/index.d.ts +50 -36
- package/dist/index.js +22 -22
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
var{defineProperty:h,getOwnPropertyNames:
|
|
1
|
+
var{defineProperty:h,getOwnPropertyNames:V,getOwnPropertyDescriptor:z}=Object,W=Object.prototype.hasOwnProperty;var L=new WeakMap,Y=(e)=>{var t=L.get(e),a;if(t)return t;if(t=h({},"__esModule",{value:!0}),e&&typeof e==="object"||typeof e==="function")V(e).map((r)=>!W.call(t,r)&&h(t,r,{get:()=>e[r],enumerable:!(a=z(e,r))||a.enumerable}));return L.set(e,t),t};var X=(e,t)=>{for(var a in t)h(e,a,{get:t[a],enumerable:!0,configurable:!0,set:(r)=>t[a]=()=>r})};var ie={};X(ie,{queueEventDecode:()=>O,Queue:()=>v,MessageHeartbeatCommand:()=>R,MessageDequeueCommand:()=>i,MessageDeleteCommand:()=>u,MessageDeferCommand:()=>c,MessageCreateCommand:()=>o,ChannelPolicySetCommand:()=>m,ChannelPolicyClearCommand:()=>l});module.exports=Y(ie);var E=(e)=>({nodeType:"VALUE",value:e}),s=(e)=>({nodeType:"REF",value:e}),J=(e)=>({nodeType:"RAW",value:e}),K=(e)=>{return`'${e.replace(/'/g,"''")}'`},j=(e)=>{if(e===null)return"NULL";else if(typeof e==="string")return K(e);else if(typeof e==="number")return e.toString();else if(typeof e==="boolean")return e?"TRUE":"FALSE";else if(e instanceof Date)return`'${e.toISOString()}'`;else if(typeof e==="bigint")return e.toString();else throw new Error(`Unsupported value type: ${typeof e}`)},Z=(e)=>{return`"${e.replace(/"/g,'""')}"`},ee=(e)=>{if(e.nodeType==="VALUE")return j(e.value);else if(e.nodeType==="REF")return Z(e.value);else if(e.nodeType==="RAW")return e.value;else throw new Error("Unsupported SQL node type")};var n=(e,...t)=>{let a=[];for(let r=0;r<e.length;r+=1)if(a.push(e[r]),r<t.length)a.push(ee(t[r]));return J(a.join(""))};class l{schema;channelName;createdAt;constructor(e){this.schema=e.schema,this.channelName=e.channelName,this.createdAt=new Date}async execute(e){await e.query(n`
|
|
2
2
|
SELECT 1 FROM ${s(this.schema)}."channel_policy_clear"(
|
|
3
3
|
$1
|
|
4
4
|
)
|
|
5
|
-
`.value,[this.channelName])}}class
|
|
5
|
+
`.value,[this.channelName])}}class m{schema;channelName;maxSize;maxConcurrency;releaseIntervalMs;createdAt;constructor(e){this.schema=e.schema,this.channelName=e.channelName;let t=e.maxConcurrency??null;this.maxConcurrency=t!==null?Math.max(0,t):null;let a=e.maxSize??null;this.maxSize=a!==null?Math.max(0,a):null;let r=e.releaseIntervalMs??null;this.releaseIntervalMs=r!==null?Math.max(0,r):null,this.createdAt=new Date}async execute(e){await e.query(n`
|
|
6
6
|
SELECT 1 FROM ${s(this.schema)}."channel_policy_set"(
|
|
7
7
|
$1,
|
|
8
8
|
$2::INTEGER,
|
|
9
9
|
$3::INTEGER,
|
|
10
10
|
$4::INTEGER
|
|
11
11
|
)
|
|
12
|
-
`.value,[this.channelName,this.maxSize,this.maxConcurrency,this.releaseIntervalMs])}}var
|
|
12
|
+
`.value,[this.channelName,this.maxSize,this.maxConcurrency,this.releaseIntervalMs])}}var U=(e)=>{return e*1000};var d=U(0);var O=(e)=>{let t=JSON.parse(e);if(t.type===0)return{eventType:"MESSAGE_CREATED",id:t.id,delayMs:t.delay_ms};else if(t.type===1)return{eventType:"MESSAGE_DELETED",id:t.id};else if(t.type===2)return{eventType:"MESSAGE_DEFERRED",id:t.id,delayMs:t.delay_ms};else throw new Error("Unknown event type")};var f=require("node:crypto");class o{schema;channelName;name;content;lockMs;id;delayMs;createdAt;constructor(e){let t=e.name??null,a=Math.max(0,e.lockMs),r=e.delayMs===void 0?d:e.delayMs;this.id=f.randomUUID(),this.schema=e.schema,this.channelName=e.channelName,this.content=e.content,this.name=t,this.lockMs=a,this.delayMs=r,this.createdAt=new Date}async execute(e){let t=await e.query(n`
|
|
13
13
|
SELECT * FROM ${s(this.schema)}."message_create"(
|
|
14
14
|
$1,
|
|
15
15
|
$2,
|
|
@@ -18,33 +18,33 @@ var{defineProperty:h,getOwnPropertyNames:W,getOwnPropertyDescriptor:Y}=Object,X=
|
|
|
18
18
|
$5::BIGINT,
|
|
19
19
|
$6::BIGINT
|
|
20
20
|
)
|
|
21
|
-
`.value,[this.id,this.channelName,this.name,this.content,this.lockMs,this.delayMs]).then((
|
|
21
|
+
`.value,[this.id,this.channelName,this.name,this.content,this.lockMs,this.delayMs]).then((a)=>a.rows[0]);if(t.result_code===1)return{resultType:"MESSAGE_DROPPED"};else if(t.result_code===2)return{resultType:"MESSAGE_DEDUPLICATED"};else if(t.result_code===0)return{resultType:"MESSAGE_CREATED"};else throw new Error("Unexpected result")}}class i{schema;constructor(e){this.schema=e.schema}async execute(e){let t=await e.query(n`
|
|
22
22
|
SELECT
|
|
23
23
|
result_code,
|
|
24
24
|
metadata,
|
|
25
25
|
content,
|
|
26
26
|
state
|
|
27
27
|
FROM ${s(this.schema)}."message_dequeue"()
|
|
28
|
-
`.value,[]).then((
|
|
28
|
+
`.value,[]).then((a)=>a.rows[0]);if(t.result_code===0)return{resultType:"MESSAGE_NOT_AVAILABLE",retryMs:t.metadata.retry_ms};else if(t.result_code===1)return{resultType:"MESSAGE_DEQUEUED",message:{id:t.metadata.id,channelName:t.metadata.channel_name,isUnlocked:t.metadata.is_unlocked,name:t.metadata.name,content:t.content,state:t.state,numAttempts:t.metadata.num_attempts}};else throw new Error("Unexpected dequeue result")}}class u{schema;id;numAttempts;constructor(e){this.schema=e.schema,this.id=e.id,this.numAttempts=e.numAttempts}async execute(e){let t=await e.query(n`
|
|
29
29
|
SELECT * FROM ${s(this.schema)}."message_delete"(
|
|
30
30
|
$1,
|
|
31
31
|
$2::BIGINT
|
|
32
32
|
)
|
|
33
|
-
`.value,[this.id,this.numAttempts]).then((
|
|
33
|
+
`.value,[this.id,this.numAttempts]).then((a)=>a.rows[0]);if(t.result_code===0)return{resultType:"MESSAGE_NOT_FOUND"};else if(t.result_code===1)return{resultType:"STATE_INVALID"};else if(t.result_code===2)return{resultType:"MESSAGE_DELETED"};else throw new Error("Unexpected result")}}class c{schema;id;numAttempts;delayMs;state;constructor(e){let t=e.delayMs===void 0?d:e.delayMs;this.schema=e.schema,this.numAttempts=e.numAttempts,this.id=e.id,this.delayMs=t,this.state=e.state??null}async execute(e){let t=await e.query(n`
|
|
34
34
|
SELECT * FROM ${s(this.schema)}."message_defer"(
|
|
35
35
|
$1,
|
|
36
36
|
$2::BIGINT,
|
|
37
37
|
$3::BIGINT,
|
|
38
38
|
$4
|
|
39
39
|
)
|
|
40
|
-
`.value,[this.id,this.numAttempts,this.delayMs,this.state]).then((
|
|
40
|
+
`.value,[this.id,this.numAttempts,this.delayMs,this.state]).then((a)=>a.rows[0]);if(t.result_code===0)return{resultType:"MESSAGE_NOT_FOUND"};else if(t.result_code===1)return{resultType:"STATE_INVALID"};else if(t.result_code===2)return{resultType:"MESSAGE_DEFERRED"};else throw new Error("Unexpected result")}}class R{schema;id;numAttempts;constructor(e){this.schema=e.schema,this.numAttempts=e.numAttempts,this.id=e.id}async execute(e){let t=await e.query(n`
|
|
41
41
|
SELECT * FROM ${s(this.schema)}."message_heartbeat"(
|
|
42
42
|
$1,
|
|
43
43
|
$2::BIGINT
|
|
44
44
|
)
|
|
45
|
-
`.value,[this.id,this.numAttempts]).then((
|
|
46
|
-
`),
|
|
47
|
-
`).trim()};var
|
|
45
|
+
`.value,[this.id,this.numAttempts]).then((a)=>a.rows[0]);if(t.result_code===0)return{resultType:"MESSAGE_NOT_FOUND"};else if(t.result_code===1)return{resultType:"MESSAGE_STATE_INVALID"};else if(t.result_code===2)return{resultType:"MESSAGE_HEARTBEATED"};else throw new Error("Unexpected result")}}var x=(e)=>{let t=e.split(`
|
|
46
|
+
`),a=Number.MAX_SAFE_INTEGER;for(let r of t){if(r.trim().length===0)continue;let T=r.search(/\S/);a=Math.min(a,T)}return t.map((r)=>r.slice(a)).join(`
|
|
47
|
+
`).trim()};var S=require("path"),__filename="/home/runner/work/lonnymq/lonnymq/src/core/path.ts",Ee=S.dirname(S.dirname(__filename)),_e=new RegExp(`^${Ee}/`),_=(e)=>{return e.replace(_e,"")};var __filename="/home/runner/work/lonnymq/lonnymq/src/migration/00-table-channel-policy.ts",G={name:_(__filename),sql:(e)=>{return[n`
|
|
48
48
|
CREATE TABLE ${s(e.schema)}."channel_policy" (
|
|
49
49
|
"id" UUID NOT NULL DEFAULT GEN_RANDOM_UUID(),
|
|
50
50
|
"name" TEXT NOT NULL,
|
|
@@ -54,10 +54,10 @@ var{defineProperty:h,getOwnPropertyNames:W,getOwnPropertyDescriptor:Y}=Object,X=
|
|
|
54
54
|
"created_at" TIMESTAMP NOT NULL,
|
|
55
55
|
PRIMARY KEY ("id")
|
|
56
56
|
);
|
|
57
|
-
`,
|
|
57
|
+
`,n`
|
|
58
58
|
CREATE UNIQUE INDEX "channel_policy_name_ux"
|
|
59
59
|
ON ${s(e.schema)}."channel_policy" ("name");
|
|
60
|
-
`]}};var __filename="/home/runner/work/lonnymq/lonnymq/src/migration/01-table-channel-state.ts"
|
|
60
|
+
`]}};var __filename="/home/runner/work/lonnymq/lonnymq/src/migration/01-table-channel-state.ts",F={name:_(__filename),sql:(e)=>{return[n`
|
|
61
61
|
CREATE TABLE ${s(e.schema)}."channel_state" (
|
|
62
62
|
"id" UUID NOT NULL DEFAULT GEN_RANDOM_UUID(),
|
|
63
63
|
"name" TEXT NOT NULL,
|
|
@@ -74,16 +74,16 @@ var{defineProperty:h,getOwnPropertyNames:W,getOwnPropertyDescriptor:Y}=Object,X=
|
|
|
74
74
|
"created_at" TIMESTAMP NOT NULL,
|
|
75
75
|
PRIMARY KEY ("id")
|
|
76
76
|
);
|
|
77
|
-
`,
|
|
77
|
+
`,n`
|
|
78
78
|
CREATE UNIQUE INDEX "channel_state_name_ux"
|
|
79
79
|
ON ${s(e.schema)}."channel_state" ("name");
|
|
80
|
-
`,
|
|
80
|
+
`,n`
|
|
81
81
|
CREATE INDEX "channel_state_dequeue_ix"
|
|
82
82
|
ON ${s(e.schema)}."channel_state" (
|
|
83
83
|
"active_next_at" ASC
|
|
84
84
|
) WHERE "message_id" IS NOT NULL
|
|
85
85
|
AND ("max_concurrency" IS NULL OR "current_concurrency" < "max_concurrency");
|
|
86
|
-
`]}};var __filename="/home/runner/work/lonnymq/lonnymq/src/migration/02-table-message.ts",
|
|
86
|
+
`]}};var __filename="/home/runner/work/lonnymq/lonnymq/src/migration/02-table-message.ts",q={name:_(__filename),sql:(e)=>{return[n`
|
|
87
87
|
CREATE TABLE ${s(e.schema)}."message" (
|
|
88
88
|
"id" UUID NOT NULL,
|
|
89
89
|
"channel_name" TEXT NOT NULL,
|
|
@@ -99,25 +99,25 @@ var{defineProperty:h,getOwnPropertyNames:W,getOwnPropertyDescriptor:Y}=Object,X=
|
|
|
99
99
|
"created_at" TIMESTAMP NOT NULL,
|
|
100
100
|
PRIMARY KEY ("id")
|
|
101
101
|
);
|
|
102
|
-
`,
|
|
102
|
+
`,n`
|
|
103
103
|
CREATE UNIQUE INDEX "message_name_ux"
|
|
104
104
|
ON ${s(e.schema)}."message" (
|
|
105
105
|
"channel_name",
|
|
106
106
|
"name"
|
|
107
107
|
) WHERE "num_attempts" = 0
|
|
108
|
-
`,
|
|
108
|
+
`,n`
|
|
109
109
|
CREATE INDEX "message_dequeue_ix"
|
|
110
110
|
ON ${s(e.schema)}."message" (
|
|
111
111
|
"channel_name",
|
|
112
112
|
"dequeue_at" ASC,
|
|
113
113
|
"seq_no" ASC
|
|
114
114
|
) WHERE NOT "is_locked";
|
|
115
|
-
`,
|
|
115
|
+
`,n`
|
|
116
116
|
CREATE INDEX "message_locked_dequeue_ix"
|
|
117
117
|
ON ${s(e.schema)}."message" (
|
|
118
118
|
"unlock_at" ASC
|
|
119
119
|
) WHERE "is_locked";
|
|
120
|
-
`]}};var __filename="/home/runner/work/lonnymq/lonnymq/src/migration/03-function-message-create.ts"
|
|
120
|
+
`]}};var __filename="/home/runner/work/lonnymq/lonnymq/src/migration/03-function-message-create.ts",$={name:_(__filename),sql:(e)=>{return[n`
|
|
121
121
|
CREATE FUNCTION ${s(e.schema)}."message_create" (
|
|
122
122
|
p_id UUID,
|
|
123
123
|
p_channel_name TEXT,
|
|
@@ -180,7 +180,7 @@ var{defineProperty:h,getOwnPropertyNames:W,getOwnPropertyDescriptor:Y}=Object,X=
|
|
|
180
180
|
|
|
181
181
|
IF v_channel_state."current_size" >= v_channel_policy."max_size" THEN
|
|
182
182
|
RETURN QUERY SELECT
|
|
183
|
-
${
|
|
183
|
+
${E(1)};
|
|
184
184
|
RETURN;
|
|
185
185
|
END IF;
|
|
186
186
|
|
|
@@ -217,7 +217,7 @@ var{defineProperty:h,getOwnPropertyNames:W,getOwnPropertyDescriptor:Y}=Object,X=
|
|
|
217
217
|
|
|
218
218
|
IF v_message."id" != p_id THEN
|
|
219
219
|
RETURN QUERY SELECT
|
|
220
|
-
${
|
|
220
|
+
${E(2)};
|
|
221
221
|
RETURN;
|
|
222
222
|
END IF;
|
|
223
223
|
|
|
@@ -242,11 +242,11 @@ var{defineProperty:h,getOwnPropertyNames:W,getOwnPropertyDescriptor:Y}=Object,X=
|
|
|
242
242
|
WHERE "id" = v_channel_state."id";
|
|
243
243
|
END IF;
|
|
244
244
|
|
|
245
|
-
IF ${
|
|
245
|
+
IF ${E(e.eventChannel!==null)} THEN
|
|
246
246
|
PERFORM PG_NOTIFY(
|
|
247
|
-
${
|
|
247
|
+
${E(e.eventChannel)},
|
|
248
248
|
JSON_BUILD_OBJECT(
|
|
249
|
-
'type', ${
|
|
249
|
+
'type', ${E(0)},
|
|
250
250
|
'id', p_id,
|
|
251
251
|
'delay_ms', p_delay_ms
|
|
252
252
|
)::TEXT
|
|
@@ -254,11 +254,11 @@ var{defineProperty:h,getOwnPropertyNames:W,getOwnPropertyDescriptor:Y}=Object,X=
|
|
|
254
254
|
END IF;
|
|
255
255
|
|
|
256
256
|
RETURN QUERY SELECT
|
|
257
|
-
${
|
|
257
|
+
${E(0)};
|
|
258
258
|
RETURN;
|
|
259
259
|
END;
|
|
260
260
|
$$ LANGUAGE plpgsql;
|
|
261
|
-
`]}};var __filename="/home/runner/work/lonnymq/lonnymq/src/migration/04-function-message-dequeue.ts",
|
|
261
|
+
`]}};var __filename="/home/runner/work/lonnymq/lonnymq/src/migration/04-function-message-dequeue.ts",le=(e)=>n`
|
|
262
262
|
SELECT
|
|
263
263
|
"message"."id",
|
|
264
264
|
"message"."name",
|
|
@@ -272,7 +272,7 @@ var{defineProperty:h,getOwnPropertyNames:W,getOwnPropertyDescriptor:Y}=Object,X=
|
|
|
272
272
|
WHERE "is_locked"
|
|
273
273
|
AND "unlock_at" <= ${e.now}
|
|
274
274
|
ORDER BY "unlock_at" ASC
|
|
275
|
-
`,
|
|
275
|
+
`,me=(e)=>n`
|
|
276
276
|
SELECT
|
|
277
277
|
"channel_state"."id",
|
|
278
278
|
"channel_state"."name",
|
|
@@ -285,7 +285,7 @@ var{defineProperty:h,getOwnPropertyNames:W,getOwnPropertyDescriptor:Y}=Object,X=
|
|
|
285
285
|
WHERE "message_id" IS NOT NULL
|
|
286
286
|
AND ("max_concurrency" IS NULL OR "current_concurrency" < "max_concurrency")
|
|
287
287
|
ORDER BY "active_next_at" ASC
|
|
288
|
-
`,
|
|
288
|
+
`,oe=(e)=>n`
|
|
289
289
|
SELECT
|
|
290
290
|
"message"."id",
|
|
291
291
|
"message"."dequeue_at",
|
|
@@ -294,7 +294,7 @@ var{defineProperty:h,getOwnPropertyNames:W,getOwnPropertyDescriptor:Y}=Object,X=
|
|
|
294
294
|
WHERE NOT "is_locked"
|
|
295
295
|
AND "channel_name" = ${e.channelName}
|
|
296
296
|
ORDER BY "dequeue_at" ASC, "seq_no" ASC
|
|
297
|
-
`,
|
|
297
|
+
`,b={name:_(__filename),sql:(e)=>{let t=le({now:n`v_now`,schema:e.schema}),a=oe({channelName:n`v_channel_state."name"`,schema:e.schema}),r=me({schema:e.schema});return[n`
|
|
298
298
|
CREATE FUNCTION ${s(e.schema)}."message_dequeue" ()
|
|
299
299
|
RETURNS TABLE (
|
|
300
300
|
result_code INTEGER,
|
|
@@ -324,7 +324,7 @@ var{defineProperty:h,getOwnPropertyNames:W,getOwnPropertyDescriptor:Y}=Object,X=
|
|
|
324
324
|
WHERE "id" = v_message_locked."id";
|
|
325
325
|
|
|
326
326
|
RETURN QUERY SELECT
|
|
327
|
-
${
|
|
327
|
+
${E(1)},
|
|
328
328
|
v_message_locked.content,
|
|
329
329
|
v_message_locked.state,
|
|
330
330
|
JSON_BUILD_OBJECT(
|
|
@@ -337,7 +337,7 @@ var{defineProperty:h,getOwnPropertyNames:W,getOwnPropertyDescriptor:Y}=Object,X=
|
|
|
337
337
|
RETURN;
|
|
338
338
|
END IF;
|
|
339
339
|
|
|
340
|
-
${
|
|
340
|
+
${r}
|
|
341
341
|
FOR UPDATE
|
|
342
342
|
SKIP LOCKED
|
|
343
343
|
LIMIT 1
|
|
@@ -345,7 +345,7 @@ var{defineProperty:h,getOwnPropertyNames:W,getOwnPropertyDescriptor:Y}=Object,X=
|
|
|
345
345
|
|
|
346
346
|
IF v_channel_state."id" IS NULL THEN
|
|
347
347
|
RETURN QUERY SELECT
|
|
348
|
-
${
|
|
348
|
+
${E(0)},
|
|
349
349
|
NULL::BYTEA,
|
|
350
350
|
NULL::BYTEA,
|
|
351
351
|
JSON_BUILD_OBJECT('retry_ms', NULL);
|
|
@@ -354,7 +354,7 @@ var{defineProperty:h,getOwnPropertyNames:W,getOwnPropertyDescriptor:Y}=Object,X=
|
|
|
354
354
|
|
|
355
355
|
IF v_channel_state."active_next_at" > v_now THEN
|
|
356
356
|
RETURN QUERY SELECT
|
|
357
|
-
${
|
|
357
|
+
${E(0)},
|
|
358
358
|
NULL::BYTEA,
|
|
359
359
|
NULL::BYTEA,
|
|
360
360
|
JSON_BUILD_OBJECT(
|
|
@@ -381,7 +381,7 @@ var{defineProperty:h,getOwnPropertyNames:W,getOwnPropertyDescriptor:Y}=Object,X=
|
|
|
381
381
|
"unlock_at" = v_now + (v_message_dequeue."lock_ms" * INTERVAL '1 millisecond')
|
|
382
382
|
WHERE "id" = v_message_dequeue."id";
|
|
383
383
|
|
|
384
|
-
${
|
|
384
|
+
${a}
|
|
385
385
|
LIMIT 1
|
|
386
386
|
INTO v_message_next;
|
|
387
387
|
|
|
@@ -406,7 +406,7 @@ var{defineProperty:h,getOwnPropertyNames:W,getOwnPropertyDescriptor:Y}=Object,X=
|
|
|
406
406
|
END IF;
|
|
407
407
|
|
|
408
408
|
RETURN QUERY SELECT
|
|
409
|
-
${
|
|
409
|
+
${E(1)},
|
|
410
410
|
v_message_dequeue.content,
|
|
411
411
|
v_message_dequeue.state,
|
|
412
412
|
JSON_BUILD_OBJECT(
|
|
@@ -419,7 +419,7 @@ var{defineProperty:h,getOwnPropertyNames:W,getOwnPropertyDescriptor:Y}=Object,X=
|
|
|
419
419
|
RETURN;
|
|
420
420
|
END;
|
|
421
421
|
$$ LANGUAGE plpgsql;
|
|
422
|
-
`]}};var __filename="/home/runner/work/lonnymq/lonnymq/src/migration/05-function-message-delete.ts",
|
|
422
|
+
`]}};var __filename="/home/runner/work/lonnymq/lonnymq/src/migration/05-function-message-delete.ts",B={name:_(__filename),sql:(e)=>{return[n`
|
|
423
423
|
CREATE FUNCTION ${s(e.schema)}."message_delete" (
|
|
424
424
|
p_id UUID,
|
|
425
425
|
p_num_attempts BIGINT
|
|
@@ -444,11 +444,11 @@ var{defineProperty:h,getOwnPropertyNames:W,getOwnPropertyDescriptor:Y}=Object,X=
|
|
|
444
444
|
|
|
445
445
|
IF v_message."id" IS NULL THEN
|
|
446
446
|
RETURN QUERY SELECT
|
|
447
|
-
${
|
|
447
|
+
${E(0)};
|
|
448
448
|
RETURN;
|
|
449
449
|
ELSIF NOT v_message."is_locked" OR v_message."num_attempts" <> p_num_attempts THEN
|
|
450
450
|
RETURN QUERY SELECT
|
|
451
|
-
${
|
|
451
|
+
${E(1)};
|
|
452
452
|
RETURN;
|
|
453
453
|
END IF;
|
|
454
454
|
|
|
@@ -478,11 +478,11 @@ var{defineProperty:h,getOwnPropertyNames:W,getOwnPropertyDescriptor:Y}=Object,X=
|
|
|
478
478
|
WHERE "id" = v_channel_state."id";
|
|
479
479
|
END IF;
|
|
480
480
|
|
|
481
|
-
IF ${
|
|
481
|
+
IF ${E(e.eventChannel!==null)} THEN
|
|
482
482
|
PERFORM PG_NOTIFY(
|
|
483
|
-
${
|
|
483
|
+
${E(e.eventChannel)},
|
|
484
484
|
JSON_BUILD_OBJECT(
|
|
485
|
-
'type', ${
|
|
485
|
+
'type', ${E(1)},
|
|
486
486
|
'id', p_id
|
|
487
487
|
)::TEXT
|
|
488
488
|
);
|
|
@@ -492,11 +492,11 @@ var{defineProperty:h,getOwnPropertyNames:W,getOwnPropertyDescriptor:Y}=Object,X=
|
|
|
492
492
|
WHERE "id" = p_id;
|
|
493
493
|
|
|
494
494
|
RETURN QUERY SELECT
|
|
495
|
-
${
|
|
495
|
+
${E(2)};
|
|
496
496
|
RETURN;
|
|
497
497
|
END;
|
|
498
498
|
$$ LANGUAGE plpgsql;
|
|
499
|
-
`]}};var __filename="/home/runner/work/lonnymq/lonnymq/src/migration/06-function-message-defer.ts",
|
|
499
|
+
`]}};var __filename="/home/runner/work/lonnymq/lonnymq/src/migration/06-function-message-defer.ts",P={name:_(__filename),sql:(e)=>{return[n`
|
|
500
500
|
CREATE FUNCTION ${s(e.schema)}."message_defer" (
|
|
501
501
|
p_id UUID,
|
|
502
502
|
p_num_attempts BIGINT,
|
|
@@ -527,11 +527,11 @@ var{defineProperty:h,getOwnPropertyNames:W,getOwnPropertyDescriptor:Y}=Object,X=
|
|
|
527
527
|
|
|
528
528
|
IF v_message."id" IS NULL THEN
|
|
529
529
|
RETURN QUERY SELECT
|
|
530
|
-
${
|
|
530
|
+
${E(0)};
|
|
531
531
|
RETURN;
|
|
532
532
|
ELSIF NOT v_message."is_locked" OR v_message."num_attempts" <> p_num_attempts THEN
|
|
533
533
|
RETURN QUERY SELECT
|
|
534
|
-
${
|
|
534
|
+
${E(1)};
|
|
535
535
|
RETURN;
|
|
536
536
|
END IF;
|
|
537
537
|
|
|
@@ -576,11 +576,11 @@ var{defineProperty:h,getOwnPropertyNames:W,getOwnPropertyDescriptor:Y}=Object,X=
|
|
|
576
576
|
"dequeue_at" = v_dequeue_at
|
|
577
577
|
WHERE "id" = p_id;
|
|
578
578
|
|
|
579
|
-
IF ${
|
|
579
|
+
IF ${E(e.eventChannel!==null)} THEN
|
|
580
580
|
PERFORM PG_NOTIFY(
|
|
581
|
-
${
|
|
581
|
+
${E(e.eventChannel)},
|
|
582
582
|
JSON_BUILD_OBJECT(
|
|
583
|
-
'type', ${
|
|
583
|
+
'type', ${E(2)},
|
|
584
584
|
'delay_ms', p_delay_ms,
|
|
585
585
|
'id', p_id
|
|
586
586
|
)::TEXT
|
|
@@ -588,11 +588,11 @@ var{defineProperty:h,getOwnPropertyNames:W,getOwnPropertyDescriptor:Y}=Object,X=
|
|
|
588
588
|
END IF;
|
|
589
589
|
|
|
590
590
|
RETURN QUERY SELECT
|
|
591
|
-
${
|
|
591
|
+
${E(2)};
|
|
592
592
|
RETURN;
|
|
593
593
|
END;
|
|
594
594
|
$$ LANGUAGE plpgsql;
|
|
595
|
-
`]}};var __filename="/home/runner/work/lonnymq/lonnymq/src/migration/07-function-message-heartbeat.ts",
|
|
595
|
+
`]}};var __filename="/home/runner/work/lonnymq/lonnymq/src/migration/07-function-message-heartbeat.ts",Q={name:_(__filename),sql:(e)=>{return[n`
|
|
596
596
|
CREATE FUNCTION ${s(e.schema)}."message_heartbeat" (
|
|
597
597
|
p_id UUID,
|
|
598
598
|
p_num_attempts BIGINT
|
|
@@ -618,11 +618,11 @@ var{defineProperty:h,getOwnPropertyNames:W,getOwnPropertyDescriptor:Y}=Object,X=
|
|
|
618
618
|
|
|
619
619
|
IF v_message."id" IS NULL THEN
|
|
620
620
|
RETURN QUERY SELECT
|
|
621
|
-
${
|
|
621
|
+
${E(0)};
|
|
622
622
|
RETURN;
|
|
623
623
|
ELSIF NOT v_message."is_locked" OR v_message."num_attempts" <> p_num_attempts THEN
|
|
624
624
|
RETURN QUERY SELECT
|
|
625
|
-
${
|
|
625
|
+
${E(1)};
|
|
626
626
|
RETURN;
|
|
627
627
|
END IF;
|
|
628
628
|
|
|
@@ -631,11 +631,11 @@ var{defineProperty:h,getOwnPropertyNames:W,getOwnPropertyDescriptor:Y}=Object,X=
|
|
|
631
631
|
WHERE "id" = p_id;
|
|
632
632
|
|
|
633
633
|
RETURN QUERY SELECT
|
|
634
|
-
${
|
|
634
|
+
${E(2)};
|
|
635
635
|
RETURN;
|
|
636
636
|
END;
|
|
637
637
|
$$ LANGUAGE plpgsql;
|
|
638
|
-
`]}};var __filename="/home/runner/work/lonnymq/lonnymq/src/migration/08-function-channel-policy-clear.ts",
|
|
638
|
+
`]}};var __filename="/home/runner/work/lonnymq/lonnymq/src/migration/08-function-channel-policy-clear.ts",w={name:_(__filename),sql:(e)=>{return[n`
|
|
639
639
|
CREATE FUNCTION ${s(e.schema)}."channel_policy_clear" (
|
|
640
640
|
p_name TEXT
|
|
641
641
|
) RETURNS VOID AS $$
|
|
@@ -665,7 +665,7 @@ var{defineProperty:h,getOwnPropertyNames:W,getOwnPropertyDescriptor:Y}=Object,X=
|
|
|
665
665
|
END IF;
|
|
666
666
|
END;
|
|
667
667
|
$$ LANGUAGE plpgsql;
|
|
668
|
-
`]}};var __filename="/home/runner/work/lonnymq/lonnymq/src/migration/09-function-channel-policy-set.ts",
|
|
668
|
+
`]}};var __filename="/home/runner/work/lonnymq/lonnymq/src/migration/09-function-channel-policy-set.ts",H={name:_(__filename),sql:(e)=>{return[n`
|
|
669
669
|
CREATE FUNCTION ${s(e.schema)}."channel_policy_set" (
|
|
670
670
|
p_name TEXT,
|
|
671
671
|
p_max_size INTEGER,
|
|
@@ -701,4 +701,4 @@ var{defineProperty:h,getOwnPropertyNames:W,getOwnPropertyDescriptor:Y}=Object,X=
|
|
|
701
701
|
WHERE "name" = p_name;
|
|
702
702
|
END;
|
|
703
703
|
$$ LANGUAGE plpgsql;
|
|
704
|
-
`]}};class
|
|
704
|
+
`]}};class g{schema;channelName;registerFn;constructor(e){this.schema=e.schema,this.channelName=e.channelName,this.registerFn=e.registerFn}create(e){let t=new o({schema:this.schema,channelName:this.channelName,name:e.name,content:e.content,lockMs:e.lockMs,delayMs:e.delayMs}),a=new Promise((r)=>{this.registerFn({sortKey:JSON.stringify([t.channelName,t.name,t.createdAt.toISOString()]),execute:(T)=>t.execute(T).then((k)=>r(k))})});return{messageId:t.id,promise:a}}}class A{schema;channelName;registerFn;constructor(e){this.schema=e.schema,this.channelName=e.channelName,this.registerFn=e.registerFn}set(e){let t=new m({schema:this.schema,channelName:this.channelName,maxConcurrency:e.maxConcurrency,maxSize:e.maxSize,releaseIntervalMs:e.releaseIntervalMs});this.registerFn({sortKey:JSON.stringify([t.channelName,null,t.createdAt.toISOString()]),execute:async(a)=>{await t.execute(a)}})}clear(){let e=new l({schema:this.schema,channelName:this.channelName});this.registerFn({sortKey:JSON.stringify([e.channelName,null,e.createdAt.toISOString()]),execute:async(t)=>{await e.execute(t)}})}}class p{policy;message;constructor(e){this.message=new g(e),this.policy=new A(e)}}var ce=(e,t)=>{return e.sortKey.localeCompare(t.sortKey)};class D{commands;schema;adaptor;constructor(e){this.schema=e.schema,this.adaptor=e.adaptor,this.commands=[]}channel(e){return new p({schema:this.schema,channelName:e,registerFn:(t)=>{this.commands.push(t)}})}async execute(e){let t=this.adaptor(e.databaseClient);for(let a of this.commands.sort(ce))await a.execute(t)}}class y{schema;channelName;adaptor;constructor(e){this.schema=e.schema,this.adaptor=e.adaptor,this.channelName=e.channelName}async create(e){let t=this.adaptor(e.databaseClient);return new o({schema:this.schema,channelName:this.channelName,name:e.name,content:e.content,lockMs:e.lockMs,delayMs:e.delayMs}).execute(t)}}class M{schema;adaptor;channelName;constructor(e){this.schema=e.schema,this.adaptor=e.adaptor,this.channelName=e.channelName}set(e){let t=this.adaptor(e.databaseClient);return new m({schema:this.schema,channelName:this.channelName,maxConcurrency:e.maxConcurrency,maxSize:e.maxSize,releaseIntervalMs:e.releaseIntervalMs}).execute(t)}clear(e){let t=this.adaptor(e.databaseClient);return new l({schema:this.schema,channelName:this.channelName}).execute(t)}}class C{policy;message;constructor(e){this.message=new y({schema:e.schema,adaptor:e.adaptor,channelName:e.channelName}),this.policy=new M({schema:e.schema,adaptor:e.adaptor,channelName:e.channelName})}}class I{schema;adaptor;id;isUnlocked;channelName;name;content;state;numAttempts;constructor(e){this.schema=e.schema,this.adaptor=e.adaptor,this.id=e.id,this.channelName=e.channelName,this.isUnlocked=e.isUnlocked,this.name=e.name,this.content=e.content,this.state=e.state,this.numAttempts=e.numAttempts}async defer(e){let t=this.adaptor(e.databaseClient);return new c({schema:this.schema,id:this.id,numAttempts:this.numAttempts,delayMs:e.delayMs,state:e.state}).execute(t)}async delete(e){let t=this.adaptor(e.databaseClient);return new u({schema:this.schema,numAttempts:this.numAttempts,id:this.id}).execute(t)}async heartbeat(e){let t=this.adaptor(e.databaseClient);return new c({schema:this.schema,id:this.id,numAttempts:this.numAttempts}).execute(t)}}class v{schema;adaptor;constructor(e){this.schema=e.schema,this.adaptor=e.adaptor?e.adaptor:(t)=>t}async dequeue(e){let t=new i({schema:this.schema}),a=this.adaptor(e.databaseClient),r=await t.execute(a);if(r.resultType==="MESSAGE_DEQUEUED")return{resultType:"MESSAGE_DEQUEUED",message:new I({schema:this.schema,adaptor:this.adaptor,id:r.message.id,channelName:r.message.channelName,name:r.message.name,isUnlocked:r.message.isUnlocked,content:r.message.content,state:r.message.state,numAttempts:r.message.numAttempts})};else return r}channel(e){return new C({adaptor:this.adaptor,schema:this.schema,channelName:e})}batch(){return new D({schema:this.schema,adaptor:this.adaptor})}migrations(e={}){return[G,F,q,$,b,B,P,Q,H,w].sort((t,a)=>t.name.localeCompare(a.name)).flatMap((t)=>t.sql({schema:this.schema,eventChannel:e.eventChannel??null})).map((t)=>x(t.value))}}
|
package/dist/index.d.ts
CHANGED
|
@@ -6,19 +6,19 @@ export type DatabaseClientQueryResult = {
|
|
|
6
6
|
export interface DatabaseClient {
|
|
7
7
|
query(query: string, params: Array<unknown>): Promise<DatabaseClientQueryResult>;
|
|
8
8
|
}
|
|
9
|
+
export type DatabaseClientAdaptor<T> = (client: T) => DatabaseClient;
|
|
9
10
|
export declare class ChannelPolicyClearCommand {
|
|
10
|
-
readonly schema
|
|
11
|
+
private readonly schema;
|
|
11
12
|
readonly channelName: string;
|
|
12
13
|
readonly createdAt: Date;
|
|
13
14
|
constructor(params: {
|
|
14
15
|
schema: string;
|
|
15
16
|
channelName: string;
|
|
16
17
|
});
|
|
17
|
-
sortKeyGet(): string;
|
|
18
18
|
execute(databaseClient: DatabaseClient): Promise<void>;
|
|
19
19
|
}
|
|
20
20
|
export declare class ChannelPolicySetCommand {
|
|
21
|
-
readonly schema
|
|
21
|
+
private readonly schema;
|
|
22
22
|
readonly channelName: string;
|
|
23
23
|
readonly maxSize: number | null;
|
|
24
24
|
readonly maxConcurrency: number | null;
|
|
@@ -31,7 +31,6 @@ export declare class ChannelPolicySetCommand {
|
|
|
31
31
|
maxConcurrency?: number | null;
|
|
32
32
|
releaseIntervalMs?: number | null;
|
|
33
33
|
});
|
|
34
|
-
sortKeyGet(): string;
|
|
35
34
|
execute(databaseClient: DatabaseClient): Promise<void>;
|
|
36
35
|
}
|
|
37
36
|
export type QueueEventMessageCreate = {
|
|
@@ -66,7 +65,7 @@ export type MessageCreateCommandResultMessageDropped = {
|
|
|
66
65
|
};
|
|
67
66
|
export type MessageCreateCommandResult = MessageCreateCommandResultMessageCreated | MessageCreateCommandResultMessageDeduplicated | MessageCreateCommandResultMessageDropped;
|
|
68
67
|
export declare class MessageCreateCommand {
|
|
69
|
-
readonly schema
|
|
68
|
+
private readonly schema;
|
|
70
69
|
readonly channelName: string;
|
|
71
70
|
readonly name: string | null;
|
|
72
71
|
readonly content: Buffer;
|
|
@@ -79,7 +78,7 @@ export declare class MessageCreateCommand {
|
|
|
79
78
|
channelName: string;
|
|
80
79
|
name?: string;
|
|
81
80
|
content: Buffer;
|
|
82
|
-
lockMs
|
|
81
|
+
lockMs: number;
|
|
83
82
|
delayMs?: number;
|
|
84
83
|
});
|
|
85
84
|
execute(databaseClient: DatabaseClient): Promise<MessageCreateCommandResult>;
|
|
@@ -102,7 +101,7 @@ export type MessageDequeueCommandResultMessageNotAvailable = {
|
|
|
102
101
|
};
|
|
103
102
|
export type MessageDequeueCommandResult = MessageDequeueCommandResultMessageDequeued | MessageDequeueCommandResultMessageNotAvailable;
|
|
104
103
|
export declare class MessageDequeueCommand {
|
|
105
|
-
readonly schema
|
|
104
|
+
private readonly schema;
|
|
106
105
|
constructor(params: {
|
|
107
106
|
schema: string;
|
|
108
107
|
});
|
|
@@ -119,7 +118,7 @@ export type MessageDeleteCommandResultMessageDeleted = {
|
|
|
119
118
|
};
|
|
120
119
|
export type MessageDeleteCommandResult = MessageDeleteCommandResultMessageNotFound | MessageDeleteCommandResultStateInvalid | MessageDeleteCommandResultMessageDeleted;
|
|
121
120
|
export declare class MessageDeleteCommand {
|
|
122
|
-
readonly schema
|
|
121
|
+
private readonly schema;
|
|
123
122
|
readonly id: string;
|
|
124
123
|
readonly numAttempts: number;
|
|
125
124
|
constructor(params: {
|
|
@@ -140,7 +139,7 @@ export type MessageDeferCommandResultMessageDeferred = {
|
|
|
140
139
|
};
|
|
141
140
|
export type MessageDeferCommandResult = MessageDeferCommandResultMessageNotFound | MessageDeferCommandResultStateInvalid | MessageDeferCommandResultMessageDeferred;
|
|
142
141
|
export declare class MessageDeferCommand {
|
|
143
|
-
readonly schema
|
|
142
|
+
private readonly schema;
|
|
144
143
|
readonly id: string;
|
|
145
144
|
readonly numAttempts: number;
|
|
146
145
|
readonly delayMs: number;
|
|
@@ -165,7 +164,7 @@ export type MessageHeartbeatCommandResultMessageHeartbeated = {
|
|
|
165
164
|
};
|
|
166
165
|
export type MessageHeartbeatCommandResult = MessageHeartbeatCommandResultMessageNotFound | MessageHeartbeatCommandResultStateInvalid | MessageHeartbeatCommandResultMessageHeartbeated;
|
|
167
166
|
export declare class MessageHeartbeatCommand {
|
|
168
|
-
readonly schema
|
|
167
|
+
private readonly schema;
|
|
169
168
|
readonly id: string;
|
|
170
169
|
readonly numAttempts: number;
|
|
171
170
|
constructor(params: {
|
|
@@ -190,7 +189,7 @@ export declare class QueueBatchChannelMessage {
|
|
|
190
189
|
});
|
|
191
190
|
create(params: {
|
|
192
191
|
name?: string;
|
|
193
|
-
lockMs
|
|
192
|
+
lockMs: number;
|
|
194
193
|
content: Buffer;
|
|
195
194
|
delayMs?: number;
|
|
196
195
|
}): QueueBatchChannelMessageCreateResult;
|
|
@@ -225,59 +224,67 @@ export type BatchedCommand = {
|
|
|
225
224
|
execute: (databaseClient: DatabaseClient) => Promise<void>;
|
|
226
225
|
};
|
|
227
226
|
export type BatchedCommandRegisterFn = (command: BatchedCommand) => void;
|
|
228
|
-
export declare class QueueBatch {
|
|
227
|
+
export declare class QueueBatch<T> {
|
|
229
228
|
private readonly commands;
|
|
230
229
|
private readonly schema;
|
|
230
|
+
private readonly adaptor;
|
|
231
231
|
constructor(params: {
|
|
232
232
|
schema: string;
|
|
233
|
+
adaptor: DatabaseClientAdaptor<T>;
|
|
233
234
|
});
|
|
234
235
|
channel(channelName: string): QueueBatchChannel;
|
|
235
236
|
execute(params: {
|
|
236
|
-
databaseClient:
|
|
237
|
+
databaseClient: T;
|
|
237
238
|
}): Promise<void>;
|
|
238
239
|
}
|
|
239
|
-
export declare class QueueChannelMessage {
|
|
240
|
+
export declare class QueueChannelMessage<T> {
|
|
240
241
|
private readonly schema;
|
|
241
242
|
private readonly channelName;
|
|
243
|
+
private readonly adaptor;
|
|
242
244
|
constructor(params: {
|
|
243
245
|
schema: string;
|
|
246
|
+
adaptor: DatabaseClientAdaptor<T>;
|
|
244
247
|
channelName: string;
|
|
245
248
|
});
|
|
246
249
|
create(params: {
|
|
247
|
-
databaseClient:
|
|
250
|
+
databaseClient: T;
|
|
248
251
|
name?: string;
|
|
249
|
-
lockMs
|
|
252
|
+
lockMs: number;
|
|
250
253
|
content: Buffer;
|
|
251
254
|
delayMs?: number;
|
|
252
255
|
}): Promise<MessageCreateCommandResult>;
|
|
253
256
|
}
|
|
254
|
-
export declare class QueueChannelPolicy {
|
|
257
|
+
export declare class QueueChannelPolicy<T> {
|
|
255
258
|
private readonly schema;
|
|
259
|
+
private readonly adaptor;
|
|
256
260
|
private readonly channelName;
|
|
257
261
|
constructor(params: {
|
|
258
262
|
schema: string;
|
|
263
|
+
adaptor: DatabaseClientAdaptor<T>;
|
|
259
264
|
channelName: string;
|
|
260
265
|
});
|
|
261
266
|
set(params: {
|
|
262
|
-
databaseClient:
|
|
267
|
+
databaseClient: T;
|
|
263
268
|
maxConcurrency?: number | null;
|
|
264
269
|
maxSize?: number | null;
|
|
265
270
|
releaseIntervalMs?: number | null;
|
|
266
271
|
}): Promise<void>;
|
|
267
272
|
clear(params: {
|
|
268
|
-
databaseClient:
|
|
273
|
+
databaseClient: T;
|
|
269
274
|
}): Promise<void>;
|
|
270
275
|
}
|
|
271
|
-
export declare class QueueChannel {
|
|
272
|
-
readonly policy: QueueChannelPolicy
|
|
273
|
-
readonly message: QueueChannelMessage
|
|
276
|
+
export declare class QueueChannel<T> {
|
|
277
|
+
readonly policy: QueueChannelPolicy<T>;
|
|
278
|
+
readonly message: QueueChannelMessage<T>;
|
|
274
279
|
constructor(params: {
|
|
275
280
|
schema: string;
|
|
281
|
+
adaptor: DatabaseClientAdaptor<T>;
|
|
276
282
|
channelName: string;
|
|
277
283
|
});
|
|
278
284
|
}
|
|
279
|
-
export declare class QueueMessage {
|
|
285
|
+
export declare class QueueMessage<T> {
|
|
280
286
|
private readonly schema;
|
|
287
|
+
private readonly adaptor;
|
|
281
288
|
readonly id: string;
|
|
282
289
|
readonly isUnlocked: boolean;
|
|
283
290
|
readonly channelName: string;
|
|
@@ -287,6 +294,7 @@ export declare class QueueMessage {
|
|
|
287
294
|
readonly numAttempts: number;
|
|
288
295
|
constructor(params: {
|
|
289
296
|
schema: string;
|
|
297
|
+
adaptor: DatabaseClientAdaptor<T>;
|
|
290
298
|
id: string;
|
|
291
299
|
channelName: string;
|
|
292
300
|
isUnlocked: boolean;
|
|
@@ -296,34 +304,40 @@ export declare class QueueMessage {
|
|
|
296
304
|
numAttempts: number;
|
|
297
305
|
});
|
|
298
306
|
defer(params: {
|
|
299
|
-
databaseClient:
|
|
307
|
+
databaseClient: T;
|
|
300
308
|
delayMs?: number;
|
|
301
309
|
state?: Buffer;
|
|
302
310
|
}): Promise<MessageDeferCommandResult>;
|
|
303
311
|
delete(params: {
|
|
304
|
-
databaseClient:
|
|
312
|
+
databaseClient: T;
|
|
305
313
|
}): Promise<MessageDeleteCommandResult>;
|
|
306
314
|
heartbeat(params: {
|
|
307
|
-
databaseClient:
|
|
315
|
+
databaseClient: T;
|
|
308
316
|
}): Promise<MessageDeferCommandResult>;
|
|
309
317
|
}
|
|
310
|
-
export type MessageDequeueResult = {
|
|
318
|
+
export type MessageDequeueResult<T> = {
|
|
311
319
|
resultType: "MESSAGE_NOT_AVAILABLE";
|
|
312
320
|
retryMs: number | null;
|
|
313
321
|
} | {
|
|
314
322
|
resultType: "MESSAGE_DEQUEUED";
|
|
315
|
-
message: QueueMessage
|
|
323
|
+
message: QueueMessage<T>;
|
|
324
|
+
};
|
|
325
|
+
export type QueueParams<T> = T extends DatabaseClient ? {
|
|
326
|
+
schema: string;
|
|
327
|
+
adaptor?: DatabaseClientAdaptor<T>;
|
|
328
|
+
} : {
|
|
329
|
+
schema: string;
|
|
330
|
+
adaptor: DatabaseClientAdaptor<T>;
|
|
316
331
|
};
|
|
317
|
-
export declare class Queue {
|
|
332
|
+
export declare class Queue<T = DatabaseClient> {
|
|
318
333
|
private readonly schema;
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
});
|
|
334
|
+
private readonly adaptor;
|
|
335
|
+
constructor(params: QueueParams<T>);
|
|
322
336
|
dequeue(params: {
|
|
323
|
-
databaseClient:
|
|
324
|
-
}): Promise<MessageDequeueResult
|
|
325
|
-
channel(channelName: string): QueueChannel
|
|
326
|
-
batch(): QueueBatch
|
|
337
|
+
databaseClient: T;
|
|
338
|
+
}): Promise<MessageDequeueResult<T>>;
|
|
339
|
+
channel(channelName: string): QueueChannel<T>;
|
|
340
|
+
batch(): QueueBatch<T>;
|
|
327
341
|
migrations(params?: {
|
|
328
342
|
eventChannel?: string;
|
|
329
343
|
}): string[];
|
package/dist/index.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
var r=(e)=>({nodeType:"VALUE",value:e}),s=(e)=>({nodeType:"REF",value:e}),
|
|
1
|
+
var r=(e)=>({nodeType:"VALUE",value:e}),s=(e)=>({nodeType:"REF",value:e}),Q=(e)=>({nodeType:"RAW",value:e}),w=(e)=>{return`'${e.replace(/'/g,"''")}'`},H=(e)=>{if(e===null)return"NULL";else if(typeof e==="string")return w(e);else if(typeof e==="number")return e.toString();else if(typeof e==="boolean")return e?"TRUE":"FALSE";else if(e instanceof Date)return`'${e.toISOString()}'`;else if(typeof e==="bigint")return e.toString();else throw new Error(`Unsupported value type: ${typeof e}`)},k=(e)=>{return`"${e.replace(/"/g,'""')}"`},V=(e)=>{if(e.nodeType==="VALUE")return H(e.value);else if(e.nodeType==="REF")return k(e.value);else if(e.nodeType==="RAW")return e.value;else throw new Error("Unsupported SQL node type")};var n=(e,...t)=>{let a=[];for(let E=0;E<e.length;E+=1)if(a.push(e[E]),E<t.length)a.push(V(t[E]));return Q(a.join(""))};class l{schema;channelName;createdAt;constructor(e){this.schema=e.schema,this.channelName=e.channelName,this.createdAt=new Date}async execute(e){await e.query(n`
|
|
2
2
|
SELECT 1 FROM ${s(this.schema)}."channel_policy_clear"(
|
|
3
3
|
$1
|
|
4
4
|
)
|
|
5
|
-
`.value,[this.channelName])}}class
|
|
5
|
+
`.value,[this.channelName])}}class m{schema;channelName;maxSize;maxConcurrency;releaseIntervalMs;createdAt;constructor(e){this.schema=e.schema,this.channelName=e.channelName;let t=e.maxConcurrency??null;this.maxConcurrency=t!==null?Math.max(0,t):null;let a=e.maxSize??null;this.maxSize=a!==null?Math.max(0,a):null;let E=e.releaseIntervalMs??null;this.releaseIntervalMs=E!==null?Math.max(0,E):null,this.createdAt=new Date}async execute(e){await e.query(n`
|
|
6
6
|
SELECT 1 FROM ${s(this.schema)}."channel_policy_set"(
|
|
7
7
|
$1,
|
|
8
8
|
$2::INTEGER,
|
|
9
9
|
$3::INTEGER,
|
|
10
10
|
$4::INTEGER
|
|
11
11
|
)
|
|
12
|
-
`.value,[this.channelName,this.maxSize,this.maxConcurrency,this.releaseIntervalMs])}}var
|
|
12
|
+
`.value,[this.channelName,this.maxSize,this.maxConcurrency,this.releaseIntervalMs])}}var M=(e)=>{return e*1000};var i=M(0);var z=(e)=>{let t=JSON.parse(e);if(t.type===0)return{eventType:"MESSAGE_CREATED",id:t.id,delayMs:t.delay_ms};else if(t.type===1)return{eventType:"MESSAGE_DELETED",id:t.id};else if(t.type===2)return{eventType:"MESSAGE_DEFERRED",id:t.id,delayMs:t.delay_ms};else throw new Error("Unknown event type")};import{randomUUID as Y}from"node:crypto";class o{schema;channelName;name;content;lockMs;id;delayMs;createdAt;constructor(e){let t=e.name??null,a=Math.max(0,e.lockMs),E=e.delayMs===void 0?i:e.delayMs;this.id=Y(),this.schema=e.schema,this.channelName=e.channelName,this.content=e.content,this.name=t,this.lockMs=a,this.delayMs=E,this.createdAt=new Date}async execute(e){let t=await e.query(n`
|
|
13
13
|
SELECT * FROM ${s(this.schema)}."message_create"(
|
|
14
14
|
$1,
|
|
15
15
|
$2,
|
|
@@ -30,21 +30,21 @@ var r=(e)=>({nodeType:"VALUE",value:e}),s=(e)=>({nodeType:"REF",value:e}),H=(e)=
|
|
|
30
30
|
$1,
|
|
31
31
|
$2::BIGINT
|
|
32
32
|
)
|
|
33
|
-
`.value,[this.id,this.numAttempts]).then((a)=>a.rows[0]);if(t.result_code===0)return{resultType:"MESSAGE_NOT_FOUND"};else if(t.result_code===1)return{resultType:"STATE_INVALID"};else if(t.result_code===2)return{resultType:"MESSAGE_DELETED"};else throw new Error("Unexpected result")}}class
|
|
33
|
+
`.value,[this.id,this.numAttempts]).then((a)=>a.rows[0]);if(t.result_code===0)return{resultType:"MESSAGE_NOT_FOUND"};else if(t.result_code===1)return{resultType:"STATE_INVALID"};else if(t.result_code===2)return{resultType:"MESSAGE_DELETED"};else throw new Error("Unexpected result")}}class c{schema;id;numAttempts;delayMs;state;constructor(e){let t=e.delayMs===void 0?i:e.delayMs;this.schema=e.schema,this.numAttempts=e.numAttempts,this.id=e.id,this.delayMs=t,this.state=e.state??null}async execute(e){let t=await e.query(n`
|
|
34
34
|
SELECT * FROM ${s(this.schema)}."message_defer"(
|
|
35
35
|
$1,
|
|
36
36
|
$2::BIGINT,
|
|
37
37
|
$3::BIGINT,
|
|
38
38
|
$4
|
|
39
39
|
)
|
|
40
|
-
`.value,[this.id,this.numAttempts,this.delayMs,this.state]).then((a)=>a.rows[0]);if(t.result_code===0)return{resultType:"MESSAGE_NOT_FOUND"};else if(t.result_code===1)return{resultType:"STATE_INVALID"};else if(t.result_code===2)return{resultType:"MESSAGE_DEFERRED"};else throw new Error("Unexpected result")}}class
|
|
40
|
+
`.value,[this.id,this.numAttempts,this.delayMs,this.state]).then((a)=>a.rows[0]);if(t.result_code===0)return{resultType:"MESSAGE_NOT_FOUND"};else if(t.result_code===1)return{resultType:"STATE_INVALID"};else if(t.result_code===2)return{resultType:"MESSAGE_DEFERRED"};else throw new Error("Unexpected result")}}class C{schema;id;numAttempts;constructor(e){this.schema=e.schema,this.numAttempts=e.numAttempts,this.id=e.id}async execute(e){let t=await e.query(n`
|
|
41
41
|
SELECT * FROM ${s(this.schema)}."message_heartbeat"(
|
|
42
42
|
$1,
|
|
43
43
|
$2::BIGINT
|
|
44
44
|
)
|
|
45
|
-
`.value,[this.id,this.numAttempts]).then((a)=>a.rows[0]);if(t.result_code===0)return{resultType:"MESSAGE_NOT_FOUND"};else if(t.result_code===1)return{resultType:"MESSAGE_STATE_INVALID"};else if(t.result_code===2)return{resultType:"MESSAGE_HEARTBEATED"};else throw new Error("Unexpected result")}}var
|
|
46
|
-
`),a=Number.MAX_SAFE_INTEGER;for(let
|
|
47
|
-
`).trim()};import{dirname as
|
|
45
|
+
`.value,[this.id,this.numAttempts]).then((a)=>a.rows[0]);if(t.result_code===0)return{resultType:"MESSAGE_NOT_FOUND"};else if(t.result_code===1)return{resultType:"MESSAGE_STATE_INVALID"};else if(t.result_code===2)return{resultType:"MESSAGE_HEARTBEATED"};else throw new Error("Unexpected result")}}var I=(e)=>{let t=e.split(`
|
|
46
|
+
`),a=Number.MAX_SAFE_INTEGER;for(let E of t){if(E.trim().length===0)continue;let T=E.search(/\S/);a=Math.min(a,T)}return t.map((E)=>E.slice(a)).join(`
|
|
47
|
+
`).trim()};import{dirname as v}from"path";var __filename="/home/runner/work/lonnymq/lonnymq/src/core/path.ts",Z=v(v(__filename)),ee=new RegExp(`^${Z}/`),_=(e)=>{return e.replace(ee,"")};var __filename="/home/runner/work/lonnymq/lonnymq/src/migration/00-table-channel-policy.ts",L={name:_(__filename),sql:(e)=>{return[n`
|
|
48
48
|
CREATE TABLE ${s(e.schema)}."channel_policy" (
|
|
49
49
|
"id" UUID NOT NULL DEFAULT GEN_RANDOM_UUID(),
|
|
50
50
|
"name" TEXT NOT NULL,
|
|
@@ -57,7 +57,7 @@ var r=(e)=>({nodeType:"VALUE",value:e}),s=(e)=>({nodeType:"REF",value:e}),H=(e)=
|
|
|
57
57
|
`,n`
|
|
58
58
|
CREATE UNIQUE INDEX "channel_policy_name_ux"
|
|
59
59
|
ON ${s(e.schema)}."channel_policy" ("name");
|
|
60
|
-
`]}};var __filename="/home/runner/work/lonnymq/lonnymq/src/migration/01-table-channel-state.ts",
|
|
60
|
+
`]}};var __filename="/home/runner/work/lonnymq/lonnymq/src/migration/01-table-channel-state.ts",U={name:_(__filename),sql:(e)=>{return[n`
|
|
61
61
|
CREATE TABLE ${s(e.schema)}."channel_state" (
|
|
62
62
|
"id" UUID NOT NULL DEFAULT GEN_RANDOM_UUID(),
|
|
63
63
|
"name" TEXT NOT NULL,
|
|
@@ -83,7 +83,7 @@ var r=(e)=>({nodeType:"VALUE",value:e}),s=(e)=>({nodeType:"REF",value:e}),H=(e)=
|
|
|
83
83
|
"active_next_at" ASC
|
|
84
84
|
) WHERE "message_id" IS NOT NULL
|
|
85
85
|
AND ("max_concurrency" IS NULL OR "current_concurrency" < "max_concurrency");
|
|
86
|
-
`]}};var __filename="/home/runner/work/lonnymq/lonnymq/src/migration/02-table-message.ts",
|
|
86
|
+
`]}};var __filename="/home/runner/work/lonnymq/lonnymq/src/migration/02-table-message.ts",O={name:_(__filename),sql:(e)=>{return[n`
|
|
87
87
|
CREATE TABLE ${s(e.schema)}."message" (
|
|
88
88
|
"id" UUID NOT NULL,
|
|
89
89
|
"channel_name" TEXT NOT NULL,
|
|
@@ -117,7 +117,7 @@ var r=(e)=>({nodeType:"VALUE",value:e}),s=(e)=>({nodeType:"REF",value:e}),H=(e)=
|
|
|
117
117
|
ON ${s(e.schema)}."message" (
|
|
118
118
|
"unlock_at" ASC
|
|
119
119
|
) WHERE "is_locked";
|
|
120
|
-
`]}};var __filename="/home/runner/work/lonnymq/lonnymq/src/migration/03-function-message-create.ts",
|
|
120
|
+
`]}};var __filename="/home/runner/work/lonnymq/lonnymq/src/migration/03-function-message-create.ts",f={name:_(__filename),sql:(e)=>{return[n`
|
|
121
121
|
CREATE FUNCTION ${s(e.schema)}."message_create" (
|
|
122
122
|
p_id UUID,
|
|
123
123
|
p_channel_name TEXT,
|
|
@@ -258,7 +258,7 @@ var r=(e)=>({nodeType:"VALUE",value:e}),s=(e)=>({nodeType:"REF",value:e}),H=(e)=
|
|
|
258
258
|
RETURN;
|
|
259
259
|
END;
|
|
260
260
|
$$ LANGUAGE plpgsql;
|
|
261
|
-
`]}};var __filename="/home/runner/work/lonnymq/lonnymq/src/migration/04-function-message-dequeue.ts",
|
|
261
|
+
`]}};var __filename="/home/runner/work/lonnymq/lonnymq/src/migration/04-function-message-dequeue.ts",te=(e)=>n`
|
|
262
262
|
SELECT
|
|
263
263
|
"message"."id",
|
|
264
264
|
"message"."name",
|
|
@@ -272,7 +272,7 @@ var r=(e)=>({nodeType:"VALUE",value:e}),s=(e)=>({nodeType:"REF",value:e}),H=(e)=
|
|
|
272
272
|
WHERE "is_locked"
|
|
273
273
|
AND "unlock_at" <= ${e.now}
|
|
274
274
|
ORDER BY "unlock_at" ASC
|
|
275
|
-
`,
|
|
275
|
+
`,se=(e)=>n`
|
|
276
276
|
SELECT
|
|
277
277
|
"channel_state"."id",
|
|
278
278
|
"channel_state"."name",
|
|
@@ -285,7 +285,7 @@ var r=(e)=>({nodeType:"VALUE",value:e}),s=(e)=>({nodeType:"REF",value:e}),H=(e)=
|
|
|
285
285
|
WHERE "message_id" IS NOT NULL
|
|
286
286
|
AND ("max_concurrency" IS NULL OR "current_concurrency" < "max_concurrency")
|
|
287
287
|
ORDER BY "active_next_at" ASC
|
|
288
|
-
`,
|
|
288
|
+
`,ne=(e)=>n`
|
|
289
289
|
SELECT
|
|
290
290
|
"message"."id",
|
|
291
291
|
"message"."dequeue_at",
|
|
@@ -294,7 +294,7 @@ var r=(e)=>({nodeType:"VALUE",value:e}),s=(e)=>({nodeType:"REF",value:e}),H=(e)=
|
|
|
294
294
|
WHERE NOT "is_locked"
|
|
295
295
|
AND "channel_name" = ${e.channelName}
|
|
296
296
|
ORDER BY "dequeue_at" ASC, "seq_no" ASC
|
|
297
|
-
`,
|
|
297
|
+
`,x={name:_(__filename),sql:(e)=>{let t=te({now:n`v_now`,schema:e.schema}),a=ne({channelName:n`v_channel_state."name"`,schema:e.schema}),E=se({schema:e.schema});return[n`
|
|
298
298
|
CREATE FUNCTION ${s(e.schema)}."message_dequeue" ()
|
|
299
299
|
RETURNS TABLE (
|
|
300
300
|
result_code INTEGER,
|
|
@@ -337,7 +337,7 @@ var r=(e)=>({nodeType:"VALUE",value:e}),s=(e)=>({nodeType:"REF",value:e}),H=(e)=
|
|
|
337
337
|
RETURN;
|
|
338
338
|
END IF;
|
|
339
339
|
|
|
340
|
-
${
|
|
340
|
+
${E}
|
|
341
341
|
FOR UPDATE
|
|
342
342
|
SKIP LOCKED
|
|
343
343
|
LIMIT 1
|
|
@@ -419,7 +419,7 @@ var r=(e)=>({nodeType:"VALUE",value:e}),s=(e)=>({nodeType:"REF",value:e}),H=(e)=
|
|
|
419
419
|
RETURN;
|
|
420
420
|
END;
|
|
421
421
|
$$ LANGUAGE plpgsql;
|
|
422
|
-
`]}};var __filename="/home/runner/work/lonnymq/lonnymq/src/migration/05-function-message-delete.ts",
|
|
422
|
+
`]}};var __filename="/home/runner/work/lonnymq/lonnymq/src/migration/05-function-message-delete.ts",G={name:_(__filename),sql:(e)=>{return[n`
|
|
423
423
|
CREATE FUNCTION ${s(e.schema)}."message_delete" (
|
|
424
424
|
p_id UUID,
|
|
425
425
|
p_num_attempts BIGINT
|
|
@@ -496,7 +496,7 @@ var r=(e)=>({nodeType:"VALUE",value:e}),s=(e)=>({nodeType:"REF",value:e}),H=(e)=
|
|
|
496
496
|
RETURN;
|
|
497
497
|
END;
|
|
498
498
|
$$ LANGUAGE plpgsql;
|
|
499
|
-
`]}};var __filename="/home/runner/work/lonnymq/lonnymq/src/migration/06-function-message-defer.ts"
|
|
499
|
+
`]}};var __filename="/home/runner/work/lonnymq/lonnymq/src/migration/06-function-message-defer.ts",F={name:_(__filename),sql:(e)=>{return[n`
|
|
500
500
|
CREATE FUNCTION ${s(e.schema)}."message_defer" (
|
|
501
501
|
p_id UUID,
|
|
502
502
|
p_num_attempts BIGINT,
|
|
@@ -592,7 +592,7 @@ var r=(e)=>({nodeType:"VALUE",value:e}),s=(e)=>({nodeType:"REF",value:e}),H=(e)=
|
|
|
592
592
|
RETURN;
|
|
593
593
|
END;
|
|
594
594
|
$$ LANGUAGE plpgsql;
|
|
595
|
-
`]}};var __filename="/home/runner/work/lonnymq/lonnymq/src/migration/07-function-message-heartbeat.ts",
|
|
595
|
+
`]}};var __filename="/home/runner/work/lonnymq/lonnymq/src/migration/07-function-message-heartbeat.ts",q={name:_(__filename),sql:(e)=>{return[n`
|
|
596
596
|
CREATE FUNCTION ${s(e.schema)}."message_heartbeat" (
|
|
597
597
|
p_id UUID,
|
|
598
598
|
p_num_attempts BIGINT
|
|
@@ -635,7 +635,7 @@ var r=(e)=>({nodeType:"VALUE",value:e}),s=(e)=>({nodeType:"REF",value:e}),H=(e)=
|
|
|
635
635
|
RETURN;
|
|
636
636
|
END;
|
|
637
637
|
$$ LANGUAGE plpgsql;
|
|
638
|
-
`]}};var __filename="/home/runner/work/lonnymq/lonnymq/src/migration/08-function-channel-policy-clear.ts"
|
|
638
|
+
`]}};var __filename="/home/runner/work/lonnymq/lonnymq/src/migration/08-function-channel-policy-clear.ts",$={name:_(__filename),sql:(e)=>{return[n`
|
|
639
639
|
CREATE FUNCTION ${s(e.schema)}."channel_policy_clear" (
|
|
640
640
|
p_name TEXT
|
|
641
641
|
) RETURNS VOID AS $$
|
|
@@ -665,7 +665,7 @@ var r=(e)=>({nodeType:"VALUE",value:e}),s=(e)=>({nodeType:"REF",value:e}),H=(e)=
|
|
|
665
665
|
END IF;
|
|
666
666
|
END;
|
|
667
667
|
$$ LANGUAGE plpgsql;
|
|
668
|
-
`]}};var __filename="/home/runner/work/lonnymq/lonnymq/src/migration/09-function-channel-policy-set.ts",
|
|
668
|
+
`]}};var __filename="/home/runner/work/lonnymq/lonnymq/src/migration/09-function-channel-policy-set.ts",b={name:_(__filename),sql:(e)=>{return[n`
|
|
669
669
|
CREATE FUNCTION ${s(e.schema)}."channel_policy_set" (
|
|
670
670
|
p_name TEXT,
|
|
671
671
|
p_max_size INTEGER,
|
|
@@ -701,4 +701,4 @@ var r=(e)=>({nodeType:"VALUE",value:e}),s=(e)=>({nodeType:"REF",value:e}),H=(e)=
|
|
|
701
701
|
WHERE "name" = p_name;
|
|
702
702
|
END;
|
|
703
703
|
$$ LANGUAGE plpgsql;
|
|
704
|
-
`]}};class
|
|
704
|
+
`]}};class N{schema;channelName;registerFn;constructor(e){this.schema=e.schema,this.channelName=e.channelName,this.registerFn=e.registerFn}create(e){let t=new o({schema:this.schema,channelName:this.channelName,name:e.name,content:e.content,lockMs:e.lockMs,delayMs:e.delayMs}),a=new Promise((E)=>{this.registerFn({sortKey:JSON.stringify([t.channelName,t.name,t.createdAt.toISOString()]),execute:(T)=>t.execute(T).then((P)=>E(P))})});return{messageId:t.id,promise:a}}}class R{schema;channelName;registerFn;constructor(e){this.schema=e.schema,this.channelName=e.channelName,this.registerFn=e.registerFn}set(e){let t=new m({schema:this.schema,channelName:this.channelName,maxConcurrency:e.maxConcurrency,maxSize:e.maxSize,releaseIntervalMs:e.releaseIntervalMs});this.registerFn({sortKey:JSON.stringify([t.channelName,null,t.createdAt.toISOString()]),execute:async(a)=>{await t.execute(a)}})}clear(){let e=new l({schema:this.schema,channelName:this.channelName});this.registerFn({sortKey:JSON.stringify([e.channelName,null,e.createdAt.toISOString()]),execute:async(t)=>{await e.execute(t)}})}}class S{policy;message;constructor(e){this.message=new N(e),this.policy=new R(e)}}var ae=(e,t)=>{return e.sortKey.localeCompare(t.sortKey)};class g{commands;schema;adaptor;constructor(e){this.schema=e.schema,this.adaptor=e.adaptor,this.commands=[]}channel(e){return new S({schema:this.schema,channelName:e,registerFn:(t)=>{this.commands.push(t)}})}async execute(e){let t=this.adaptor(e.databaseClient);for(let a of this.commands.sort(ae))await a.execute(t)}}class A{schema;channelName;adaptor;constructor(e){this.schema=e.schema,this.adaptor=e.adaptor,this.channelName=e.channelName}async create(e){let t=this.adaptor(e.databaseClient);return new o({schema:this.schema,channelName:this.channelName,name:e.name,content:e.content,lockMs:e.lockMs,delayMs:e.delayMs}).execute(t)}}class p{schema;adaptor;channelName;constructor(e){this.schema=e.schema,this.adaptor=e.adaptor,this.channelName=e.channelName}set(e){let t=this.adaptor(e.databaseClient);return new m({schema:this.schema,channelName:this.channelName,maxConcurrency:e.maxConcurrency,maxSize:e.maxSize,releaseIntervalMs:e.releaseIntervalMs}).execute(t)}clear(e){let t=this.adaptor(e.databaseClient);return new l({schema:this.schema,channelName:this.channelName}).execute(t)}}class D{policy;message;constructor(e){this.message=new A({schema:e.schema,adaptor:e.adaptor,channelName:e.channelName}),this.policy=new p({schema:e.schema,adaptor:e.adaptor,channelName:e.channelName})}}class y{schema;adaptor;id;isUnlocked;channelName;name;content;state;numAttempts;constructor(e){this.schema=e.schema,this.adaptor=e.adaptor,this.id=e.id,this.channelName=e.channelName,this.isUnlocked=e.isUnlocked,this.name=e.name,this.content=e.content,this.state=e.state,this.numAttempts=e.numAttempts}async defer(e){let t=this.adaptor(e.databaseClient);return new c({schema:this.schema,id:this.id,numAttempts:this.numAttempts,delayMs:e.delayMs,state:e.state}).execute(t)}async delete(e){let t=this.adaptor(e.databaseClient);return new d({schema:this.schema,numAttempts:this.numAttempts,id:this.id}).execute(t)}async heartbeat(e){let t=this.adaptor(e.databaseClient);return new c({schema:this.schema,id:this.id,numAttempts:this.numAttempts}).execute(t)}}class B{schema;adaptor;constructor(e){this.schema=e.schema,this.adaptor=e.adaptor?e.adaptor:(t)=>t}async dequeue(e){let t=new u({schema:this.schema}),a=this.adaptor(e.databaseClient),E=await t.execute(a);if(E.resultType==="MESSAGE_DEQUEUED")return{resultType:"MESSAGE_DEQUEUED",message:new y({schema:this.schema,adaptor:this.adaptor,id:E.message.id,channelName:E.message.channelName,name:E.message.name,isUnlocked:E.message.isUnlocked,content:E.message.content,state:E.message.state,numAttempts:E.message.numAttempts})};else return E}channel(e){return new D({adaptor:this.adaptor,schema:this.schema,channelName:e})}batch(){return new g({schema:this.schema,adaptor:this.adaptor})}migrations(e={}){return[L,U,O,f,x,G,F,q,b,$].sort((t,a)=>t.name.localeCompare(a.name)).flatMap((t)=>t.sql({schema:this.schema,eventChannel:e.eventChannel??null})).map((t)=>I(t.value))}}export{z as queueEventDecode,B as Queue,C as MessageHeartbeatCommand,u as MessageDequeueCommand,d as MessageDeleteCommand,c as MessageDeferCommand,o as MessageCreateCommand,m as ChannelPolicySetCommand,l as ChannelPolicyClearCommand};
|