@haathie/pgmb 0.2.9 → 0.2.10

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/src/queries.ts DELETED
@@ -1,630 +0,0 @@
1
- /** Types generated for queries found in "sql/queries.sql" */
2
- import { PreparedQuery } from '@pgtyped/runtime';
3
-
4
- export type config_type = 'future_intervals_to_create' | 'partition_interval' | 'partition_retention_period' | 'pg_cron_partition_maintenance_cron' | 'pg_cron_poll_for_events_cron' | 'plugin_version' | 'poll_chunk_size' | 'use_pg_cron';
5
-
6
- export type DateOrString = Date | string;
7
-
8
- export type DateOrStringArray = (DateOrString)[];
9
-
10
- export type stringArray = (string)[];
11
-
12
- export type unknownArray = (unknown)[];
13
-
14
- /** 'AssertGroup' parameters type */
15
- export interface IAssertGroupParams {
16
- id: string;
17
- }
18
-
19
- /** 'AssertGroup' return type */
20
- export type IAssertGroupResult = void;
21
-
22
- /** 'AssertGroup' query type */
23
- export interface IAssertGroupQuery {
24
- params: IAssertGroupParams;
25
- result: IAssertGroupResult;
26
- }
27
-
28
- const assertGroupIR: any = {"usedParamSet":{"id":true},"params":[{"name":"id","required":true,"transform":{"type":"scalar"},"locs":[{"a":50,"b":53}]}],"statement":"INSERT INTO pgmb.subscription_groups (id)\nVALUES (:id!)\nON CONFLICT DO NOTHING"};
29
-
30
- /**
31
- * Query generated from SQL:
32
- * ```
33
- * INSERT INTO pgmb.subscription_groups (id)
34
- * VALUES (:id!)
35
- * ON CONFLICT DO NOTHING
36
- * ```
37
- */
38
- export const assertGroup = new PreparedQuery<IAssertGroupParams,IAssertGroupResult>(assertGroupIR);
39
-
40
-
41
- /** 'AssertSubscription' parameters type */
42
- export interface IAssertSubscriptionParams {
43
- conditionsSql?: string | null | void;
44
- expiryInterval?: DateOrString | null | void;
45
- groupId: string;
46
- params?: unknown | null | void;
47
- }
48
-
49
- /** 'AssertSubscription' return type */
50
- export interface IAssertSubscriptionResult {
51
- id: string;
52
- }
53
-
54
- /** 'AssertSubscription' query type */
55
- export interface IAssertSubscriptionQuery {
56
- params: IAssertSubscriptionParams;
57
- result: IAssertSubscriptionResult;
58
- }
59
-
60
- const assertSubscriptionIR: any = {"usedParamSet":{"groupId":true,"conditionsSql":true,"params":true,"expiryInterval":true},"params":[{"name":"groupId","required":true,"transform":{"type":"scalar"},"locs":[{"a":98,"b":106}]},{"name":"conditionsSql","required":false,"transform":{"type":"scalar"},"locs":[{"a":119,"b":132}]},{"name":"params","required":false,"transform":{"type":"scalar"},"locs":[{"a":154,"b":160}]},{"name":"expiryInterval","required":false,"transform":{"type":"scalar"},"locs":[{"a":178,"b":192}]}],"statement":"INSERT INTO pgmb.subscriptions\n\tAS s(group_id, conditions_sql, params, expiry_interval)\nVALUES (\n\t:groupId!,\n\tCOALESCE(:conditionsSql, 'TRUE'),\n\tCOALESCE(:params::jsonb, '{}'),\n\t:expiryInterval::interval\n)\nON CONFLICT (identity) DO UPDATE\nSET\n\t-- set expiry_interval to the new value only if it's greater than the existing one\n\t-- or if the new value is NULL (indicating no expiration)\n\texpiry_interval = CASE\n\t\tWHEN EXCLUDED.expiry_interval IS NULL OR s.expiry_interval IS NULL\n\t\t\tTHEN NULL\n\t\tELSE\n\t\t\tGREATEST(s.expiry_interval, EXCLUDED.expiry_interval)\n\tEND,\n\tlast_active_at = NOW()\nRETURNING id AS \"id!\""};
61
-
62
- /**
63
- * Query generated from SQL:
64
- * ```
65
- * INSERT INTO pgmb.subscriptions
66
- * AS s(group_id, conditions_sql, params, expiry_interval)
67
- * VALUES (
68
- * :groupId!,
69
- * COALESCE(:conditionsSql, 'TRUE'),
70
- * COALESCE(:params::jsonb, '{}'),
71
- * :expiryInterval::interval
72
- * )
73
- * ON CONFLICT (identity) DO UPDATE
74
- * SET
75
- * -- set expiry_interval to the new value only if it's greater than the existing one
76
- * -- or if the new value is NULL (indicating no expiration)
77
- * expiry_interval = CASE
78
- * WHEN EXCLUDED.expiry_interval IS NULL OR s.expiry_interval IS NULL
79
- * THEN NULL
80
- * ELSE
81
- * GREATEST(s.expiry_interval, EXCLUDED.expiry_interval)
82
- * END,
83
- * last_active_at = NOW()
84
- * RETURNING id AS "id!"
85
- * ```
86
- */
87
- export const assertSubscription = new PreparedQuery<IAssertSubscriptionParams,IAssertSubscriptionResult>(assertSubscriptionIR);
88
-
89
-
90
- /** 'DeleteSubscriptions' parameters type */
91
- export interface IDeleteSubscriptionsParams {
92
- ids: readonly (string)[];
93
- }
94
-
95
- /** 'DeleteSubscriptions' return type */
96
- export type IDeleteSubscriptionsResult = void;
97
-
98
- /** 'DeleteSubscriptions' query type */
99
- export interface IDeleteSubscriptionsQuery {
100
- params: IDeleteSubscriptionsParams;
101
- result: IDeleteSubscriptionsResult;
102
- }
103
-
104
- const deleteSubscriptionsIR: any = {"usedParamSet":{"ids":true},"params":[{"name":"ids","required":true,"transform":{"type":"array_spread"},"locs":[{"a":43,"b":47}]}],"statement":"DELETE FROM pgmb.subscriptions\nWHERE id IN :ids!"};
105
-
106
- /**
107
- * Query generated from SQL:
108
- * ```
109
- * DELETE FROM pgmb.subscriptions
110
- * WHERE id IN :ids!
111
- * ```
112
- */
113
- export const deleteSubscriptions = new PreparedQuery<IDeleteSubscriptionsParams,IDeleteSubscriptionsResult>(deleteSubscriptionsIR);
114
-
115
-
116
- /** 'MarkSubscriptionsActive' parameters type */
117
- export interface IMarkSubscriptionsActiveParams {
118
- ids: stringArray;
119
- }
120
-
121
- /** 'MarkSubscriptionsActive' return type */
122
- export type IMarkSubscriptionsActiveResult = void;
123
-
124
- /** 'MarkSubscriptionsActive' query type */
125
- export interface IMarkSubscriptionsActiveQuery {
126
- params: IMarkSubscriptionsActiveParams;
127
- result: IMarkSubscriptionsActiveResult;
128
- }
129
-
130
- const markSubscriptionsActiveIR: any = {"usedParamSet":{"ids":true},"params":[{"name":"ids","required":true,"transform":{"type":"scalar"},"locs":[{"a":88,"b":92}]}],"statement":"UPDATE pgmb.subscriptions\nSET\n\tlast_active_at = NOW()\nWHERE id IN (SELECT * FROM unnest(:ids!::pgmb.subscription_id[]))"};
131
-
132
- /**
133
- * Query generated from SQL:
134
- * ```
135
- * UPDATE pgmb.subscriptions
136
- * SET
137
- * last_active_at = NOW()
138
- * WHERE id IN (SELECT * FROM unnest(:ids!::pgmb.subscription_id[]))
139
- * ```
140
- */
141
- export const markSubscriptionsActive = new PreparedQuery<IMarkSubscriptionsActiveParams,IMarkSubscriptionsActiveResult>(markSubscriptionsActiveIR);
142
-
143
-
144
- /** 'PollForEvents' parameters type */
145
- export type IPollForEventsParams = void;
146
-
147
- /** 'PollForEvents' return type */
148
- export interface IPollForEventsResult {
149
- count: number;
150
- }
151
-
152
- /** 'PollForEvents' query type */
153
- export interface IPollForEventsQuery {
154
- params: IPollForEventsParams;
155
- result: IPollForEventsResult;
156
- }
157
-
158
- const pollForEventsIR: any = {"usedParamSet":{},"params":[],"statement":"SELECT count AS \"count!\" FROM pgmb.poll_for_events() AS count"};
159
-
160
- /**
161
- * Query generated from SQL:
162
- * ```
163
- * SELECT count AS "count!" FROM pgmb.poll_for_events() AS count
164
- * ```
165
- */
166
- export const pollForEvents = new PreparedQuery<IPollForEventsParams,IPollForEventsResult>(pollForEventsIR);
167
-
168
-
169
- /** 'ReadNextEvents' parameters type */
170
- export interface IReadNextEventsParams {
171
- chunkSize: number;
172
- cursor?: string | null | void;
173
- groupId: string;
174
- }
175
-
176
- /** 'ReadNextEvents' return type */
177
- export interface IReadNextEventsResult {
178
- id: string;
179
- metadata: unknown;
180
- nextCursor: string;
181
- payload: unknown;
182
- subscriptionIds: stringArray;
183
- topic: string;
184
- }
185
-
186
- /** 'ReadNextEvents' query type */
187
- export interface IReadNextEventsQuery {
188
- params: IReadNextEventsParams;
189
- result: IReadNextEventsResult;
190
- }
191
-
192
- const readNextEventsIR: any = {"usedParamSet":{"groupId":true,"cursor":true,"chunkSize":true},"params":[{"name":"groupId","required":true,"transform":{"type":"scalar"},"locs":[{"a":197,"b":205}]},{"name":"cursor","required":false,"transform":{"type":"scalar"},"locs":[{"a":208,"b":214}]},{"name":"chunkSize","required":true,"transform":{"type":"scalar"},"locs":[{"a":217,"b":227}]}],"statement":"SELECT\n\tid AS \"id!\",\n\ttopic AS \"topic!\",\n\tpayload AS \"payload!\",\n\tmetadata AS \"metadata!\",\n\tsubscription_ids::text[] AS \"subscriptionIds!\",\n\tnext_cursor AS \"nextCursor!\"\nFROM pgmb.read_next_events(:groupId!, :cursor, :chunkSize!)"};
193
-
194
- /**
195
- * Query generated from SQL:
196
- * ```
197
- * SELECT
198
- * id AS "id!",
199
- * topic AS "topic!",
200
- * payload AS "payload!",
201
- * metadata AS "metadata!",
202
- * subscription_ids::text[] AS "subscriptionIds!",
203
- * next_cursor AS "nextCursor!"
204
- * FROM pgmb.read_next_events(:groupId!, :cursor, :chunkSize!)
205
- * ```
206
- */
207
- export const readNextEvents = new PreparedQuery<IReadNextEventsParams,IReadNextEventsResult>(readNextEventsIR);
208
-
209
-
210
- /** 'ReadNextEventsText' parameters type */
211
- export interface IReadNextEventsTextParams {
212
- chunkSize: number;
213
- cursor?: string | null | void;
214
- groupId: string;
215
- }
216
-
217
- /** 'ReadNextEventsText' return type */
218
- export interface IReadNextEventsTextResult {
219
- id: string;
220
- payload: string;
221
- topic: string;
222
- }
223
-
224
- /** 'ReadNextEventsText' query type */
225
- export interface IReadNextEventsTextQuery {
226
- params: IReadNextEventsTextParams;
227
- result: IReadNextEventsTextResult;
228
- }
229
-
230
- const readNextEventsTextIR: any = {"usedParamSet":{"groupId":true,"cursor":true,"chunkSize":true},"params":[{"name":"groupId","required":true,"transform":{"type":"scalar"},"locs":[{"a":97,"b":105}]},{"name":"cursor","required":false,"transform":{"type":"scalar"},"locs":[{"a":108,"b":114}]},{"name":"chunkSize","required":true,"transform":{"type":"scalar"},"locs":[{"a":117,"b":127}]}],"statement":"SELECT\n\tid AS \"id!\",\n\ttopic AS \"topic!\",\n\tpayload::text AS \"payload!\"\nFROM pgmb.read_next_events(:groupId!, :cursor, :chunkSize!)"};
231
-
232
- /**
233
- * Query generated from SQL:
234
- * ```
235
- * SELECT
236
- * id AS "id!",
237
- * topic AS "topic!",
238
- * payload::text AS "payload!"
239
- * FROM pgmb.read_next_events(:groupId!, :cursor, :chunkSize!)
240
- * ```
241
- */
242
- export const readNextEventsText = new PreparedQuery<IReadNextEventsTextParams,IReadNextEventsTextResult>(readNextEventsTextIR);
243
-
244
-
245
- /** 'ReplayEvents' parameters type */
246
- export interface IReplayEventsParams {
247
- fromEventId: string;
248
- groupId: string;
249
- maxEvents: number;
250
- subscriptionId: string;
251
- }
252
-
253
- /** 'ReplayEvents' return type */
254
- export interface IReplayEventsResult {
255
- id: string;
256
- metadata: unknown;
257
- payload: unknown;
258
- topic: string;
259
- }
260
-
261
- /** 'ReplayEvents' query type */
262
- export interface IReplayEventsQuery {
263
- params: IReplayEventsParams;
264
- result: IReplayEventsResult;
265
- }
266
-
267
- const replayEventsIR: any = {"usedParamSet":{"groupId":true,"subscriptionId":true,"fromEventId":true,"maxEvents":true},"params":[{"name":"groupId","required":true,"transform":{"type":"scalar"},"locs":[{"a":116,"b":124}]},{"name":"subscriptionId","required":true,"transform":{"type":"scalar"},"locs":[{"a":128,"b":143}]},{"name":"fromEventId","required":true,"transform":{"type":"scalar"},"locs":[{"a":147,"b":159}]},{"name":"maxEvents","required":true,"transform":{"type":"scalar"},"locs":[{"a":178,"b":188}]}],"statement":"SELECT\n\tid AS \"id!\",\n\ttopic AS \"topic!\",\n\tpayload AS \"payload!\",\n\tmetadata AS \"metadata!\"\nFROM pgmb.replay_events(\n\t:groupId!,\n\t:subscriptionId!,\n\t:fromEventId!::pgmb.event_id,\n\t:maxEvents!\n)"};
268
-
269
- /**
270
- * Query generated from SQL:
271
- * ```
272
- * SELECT
273
- * id AS "id!",
274
- * topic AS "topic!",
275
- * payload AS "payload!",
276
- * metadata AS "metadata!"
277
- * FROM pgmb.replay_events(
278
- * :groupId!,
279
- * :subscriptionId!,
280
- * :fromEventId!::pgmb.event_id,
281
- * :maxEvents!
282
- * )
283
- * ```
284
- */
285
- export const replayEvents = new PreparedQuery<IReplayEventsParams,IReplayEventsResult>(replayEventsIR);
286
-
287
-
288
- /** 'SetGroupCursor' parameters type */
289
- export interface ISetGroupCursorParams {
290
- cursor: string;
291
- groupId: string;
292
- releaseLock?: boolean | null | void;
293
- }
294
-
295
- /** 'SetGroupCursor' return type */
296
- export interface ISetGroupCursorResult {
297
- success: undefined;
298
- }
299
-
300
- /** 'SetGroupCursor' query type */
301
- export interface ISetGroupCursorQuery {
302
- params: ISetGroupCursorParams;
303
- result: ISetGroupCursorResult;
304
- }
305
-
306
- const setGroupCursorIR: any = {"usedParamSet":{"groupId":true,"cursor":true,"releaseLock":true},"params":[{"name":"groupId","required":true,"transform":{"type":"scalar"},"locs":[{"a":31,"b":39}]},{"name":"cursor","required":true,"transform":{"type":"scalar"},"locs":[{"a":43,"b":50}]},{"name":"releaseLock","required":false,"transform":{"type":"scalar"},"locs":[{"a":69,"b":80}]}],"statement":"SELECT pgmb.set_group_cursor(\n\t:groupId!,\n\t:cursor!::pgmb.event_id,\n\t:releaseLock::boolean\n) AS \"success!\""};
307
-
308
- /**
309
- * Query generated from SQL:
310
- * ```
311
- * SELECT pgmb.set_group_cursor(
312
- * :groupId!,
313
- * :cursor!::pgmb.event_id,
314
- * :releaseLock::boolean
315
- * ) AS "success!"
316
- * ```
317
- */
318
- export const setGroupCursor = new PreparedQuery<ISetGroupCursorParams,ISetGroupCursorResult>(setGroupCursorIR);
319
-
320
-
321
- /** 'ReleaseGroupLock' parameters type */
322
- export interface IReleaseGroupLockParams {
323
- groupId: string;
324
- }
325
-
326
- /** 'ReleaseGroupLock' return type */
327
- export interface IReleaseGroupLockResult {
328
- success: undefined;
329
- }
330
-
331
- /** 'ReleaseGroupLock' query type */
332
- export interface IReleaseGroupLockQuery {
333
- params: IReleaseGroupLockParams;
334
- result: IReleaseGroupLockResult;
335
- }
336
-
337
- const releaseGroupLockIR: any = {"usedParamSet":{"groupId":true},"params":[{"name":"groupId","required":true,"transform":{"type":"scalar"},"locs":[{"a":31,"b":39}]}],"statement":"SELECT pgmb.release_group_lock(:groupId!) AS \"success!\""};
338
-
339
- /**
340
- * Query generated from SQL:
341
- * ```
342
- * SELECT pgmb.release_group_lock(:groupId!) AS "success!"
343
- * ```
344
- */
345
- export const releaseGroupLock = new PreparedQuery<IReleaseGroupLockParams,IReleaseGroupLockResult>(releaseGroupLockIR);
346
-
347
-
348
- /** 'WriteEvents' parameters type */
349
- export interface IWriteEventsParams {
350
- metadatas: unknownArray;
351
- payloads: unknownArray;
352
- topics: stringArray;
353
- }
354
-
355
- /** 'WriteEvents' return type */
356
- export interface IWriteEventsResult {
357
- id: string;
358
- }
359
-
360
- /** 'WriteEvents' query type */
361
- export interface IWriteEventsQuery {
362
- params: IWriteEventsParams;
363
- result: IWriteEventsResult;
364
- }
365
-
366
- const writeEventsIR: any = {"usedParamSet":{"topics":true,"payloads":true,"metadatas":true},"params":[{"name":"topics","required":true,"transform":{"type":"scalar"},"locs":[{"a":100,"b":107}]},{"name":"payloads","required":true,"transform":{"type":"scalar"},"locs":[{"a":119,"b":128}]},{"name":"metadatas","required":true,"transform":{"type":"scalar"},"locs":[{"a":141,"b":151}]}],"statement":"INSERT INTO pgmb.events (topic, payload, metadata)\nSELECT\n\ttopic,\n\tpayload,\n\tmetadata\nFROM unnest(\n\t:topics!::TEXT[],\n\t:payloads!::JSONB[],\n\t:metadatas!::JSONB[]\n) AS t(topic, payload, metadata)\nRETURNING id AS \"id!\""};
367
-
368
- /**
369
- * Query generated from SQL:
370
- * ```
371
- * INSERT INTO pgmb.events (topic, payload, metadata)
372
- * SELECT
373
- * topic,
374
- * payload,
375
- * metadata
376
- * FROM unnest(
377
- * :topics!::TEXT[],
378
- * :payloads!::JSONB[],
379
- * :metadatas!::JSONB[]
380
- * ) AS t(topic, payload, metadata)
381
- * RETURNING id AS "id!"
382
- * ```
383
- */
384
- export const writeEvents = new PreparedQuery<IWriteEventsParams,IWriteEventsResult>(writeEventsIR);
385
-
386
-
387
- /** 'WriteScheduledEvents' parameters type */
388
- export interface IWriteScheduledEventsParams {
389
- metadatas: unknownArray;
390
- payloads: unknownArray;
391
- topics: stringArray;
392
- ts: DateOrStringArray;
393
- }
394
-
395
- /** 'WriteScheduledEvents' return type */
396
- export interface IWriteScheduledEventsResult {
397
- id: string;
398
- }
399
-
400
- /** 'WriteScheduledEvents' query type */
401
- export interface IWriteScheduledEventsQuery {
402
- params: IWriteScheduledEventsParams;
403
- result: IWriteScheduledEventsResult;
404
- }
405
-
406
- const writeScheduledEventsIR: any = {"usedParamSet":{"ts":true,"topics":true,"payloads":true,"metadatas":true},"params":[{"name":"ts","required":true,"transform":{"type":"scalar"},"locs":[{"a":189,"b":192}]},{"name":"topics","required":true,"transform":{"type":"scalar"},"locs":[{"a":211,"b":218}]},{"name":"payloads","required":true,"transform":{"type":"scalar"},"locs":[{"a":230,"b":239}]},{"name":"metadatas","required":true,"transform":{"type":"scalar"},"locs":[{"a":252,"b":262}]}],"statement":"INSERT INTO pgmb.events (id, topic, payload, metadata)\nSELECT\n\tpgmb.create_event_id(COALESCE(ts, clock_timestamp()), pgmb.create_random_bigint()),\n\ttopic,\n\tpayload,\n\tmetadata\nFROM unnest(\n\t:ts!::TIMESTAMPTZ[],\n\t:topics!::TEXT[],\n\t:payloads!::JSONB[],\n\t:metadatas!::JSONB[]\n) AS t(ts, topic, payload, metadata)\nRETURNING id AS \"id!\""};
407
-
408
- /**
409
- * Query generated from SQL:
410
- * ```
411
- * INSERT INTO pgmb.events (id, topic, payload, metadata)
412
- * SELECT
413
- * pgmb.create_event_id(COALESCE(ts, clock_timestamp()), pgmb.create_random_bigint()),
414
- * topic,
415
- * payload,
416
- * metadata
417
- * FROM unnest(
418
- * :ts!::TIMESTAMPTZ[],
419
- * :topics!::TEXT[],
420
- * :payloads!::JSONB[],
421
- * :metadatas!::JSONB[]
422
- * ) AS t(ts, topic, payload, metadata)
423
- * RETURNING id AS "id!"
424
- * ```
425
- */
426
- export const writeScheduledEvents = new PreparedQuery<IWriteScheduledEventsParams,IWriteScheduledEventsResult>(writeScheduledEventsIR);
427
-
428
-
429
- /** 'ScheduleEventRetry' parameters type */
430
- export interface IScheduleEventRetryParams {
431
- delayInterval: DateOrString;
432
- handlerName: string;
433
- ids: stringArray;
434
- retryNumber: number;
435
- subscriptionId: string;
436
- }
437
-
438
- /** 'ScheduleEventRetry' return type */
439
- export interface IScheduleEventRetryResult {
440
- id: string;
441
- }
442
-
443
- /** 'ScheduleEventRetry' query type */
444
- export interface IScheduleEventRetryQuery {
445
- params: IScheduleEventRetryParams;
446
- result: IScheduleEventRetryResult;
447
- }
448
-
449
- const scheduleEventRetryIR: any = {"usedParamSet":{"delayInterval":true,"ids":true,"retryNumber":true,"handlerName":true,"subscriptionId":true},"params":[{"name":"delayInterval","required":true,"transform":{"type":"scalar"},"locs":[{"a":103,"b":117}]},{"name":"ids","required":true,"transform":{"type":"scalar"},"locs":[{"a":212,"b":216}]},{"name":"retryNumber","required":true,"transform":{"type":"scalar"},"locs":[{"a":255,"b":267}]},{"name":"handlerName","required":true,"transform":{"type":"scalar"},"locs":[{"a":294,"b":306}]},{"name":"subscriptionId","required":true,"transform":{"type":"scalar"},"locs":[{"a":319,"b":334}]}],"statement":"INSERT INTO pgmb.events (id, topic, payload, subscription_id)\nSELECT\n\tpgmb.create_event_id(\n\t\tNOW() + (:delayInterval!::INTERVAL),\n\t\tpgmb.create_random_bigint()\n\t),\n\t'pgmb-retry',\n\tjsonb_build_object(\n\t\t'ids',\n\t\t:ids!::pgmb.event_id[],\n\t\t'retryNumber',\n\t\t:retryNumber!::int,\n\t\t'handlerName',\n\t\t:handlerName!::text\n\t),\n\t:subscriptionId!::pgmb.subscription_id\nRETURNING id AS \"id!\""};
450
-
451
- /**
452
- * Query generated from SQL:
453
- * ```
454
- * INSERT INTO pgmb.events (id, topic, payload, subscription_id)
455
- * SELECT
456
- * pgmb.create_event_id(
457
- * NOW() + (:delayInterval!::INTERVAL),
458
- * pgmb.create_random_bigint()
459
- * ),
460
- * 'pgmb-retry',
461
- * jsonb_build_object(
462
- * 'ids',
463
- * :ids!::pgmb.event_id[],
464
- * 'retryNumber',
465
- * :retryNumber!::int,
466
- * 'handlerName',
467
- * :handlerName!::text
468
- * ),
469
- * :subscriptionId!::pgmb.subscription_id
470
- * RETURNING id AS "id!"
471
- * ```
472
- */
473
- export const scheduleEventRetry = new PreparedQuery<IScheduleEventRetryParams,IScheduleEventRetryResult>(scheduleEventRetryIR);
474
-
475
-
476
- /** 'FindEvents' parameters type */
477
- export interface IFindEventsParams {
478
- ids: stringArray;
479
- }
480
-
481
- /** 'FindEvents' return type */
482
- export interface IFindEventsResult {
483
- id: string;
484
- metadata: unknown;
485
- payload: unknown;
486
- topic: string;
487
- }
488
-
489
- /** 'FindEvents' query type */
490
- export interface IFindEventsQuery {
491
- params: IFindEventsParams;
492
- result: IFindEventsResult;
493
- }
494
-
495
- const findEventsIR: any = {"usedParamSet":{"ids":true},"params":[{"name":"ids","required":true,"transform":{"type":"scalar"},"locs":[{"a":122,"b":126}]}],"statement":"SELECT\n\tid AS \"id!\",\n\ttopic AS \"topic!\",\n\tpayload AS \"payload!\",\n\tmetadata AS \"metadata!\"\nFROM pgmb.events\nWHERE id = ANY(:ids!::pgmb.event_id[])"};
496
-
497
- /**
498
- * Query generated from SQL:
499
- * ```
500
- * SELECT
501
- * id AS "id!",
502
- * topic AS "topic!",
503
- * payload AS "payload!",
504
- * metadata AS "metadata!"
505
- * FROM pgmb.events
506
- * WHERE id = ANY(:ids!::pgmb.event_id[])
507
- * ```
508
- */
509
- export const findEvents = new PreparedQuery<IFindEventsParams,IFindEventsResult>(findEventsIR);
510
-
511
-
512
- /** 'RemoveExpiredSubscriptions' parameters type */
513
- export interface IRemoveExpiredSubscriptionsParams {
514
- activeIds: stringArray;
515
- groupId: string;
516
- }
517
-
518
- /** 'RemoveExpiredSubscriptions' return type */
519
- export interface IRemoveExpiredSubscriptionsResult {
520
- deleted: string;
521
- }
522
-
523
- /** 'RemoveExpiredSubscriptions' query type */
524
- export interface IRemoveExpiredSubscriptionsQuery {
525
- params: IRemoveExpiredSubscriptionsParams;
526
- result: IRemoveExpiredSubscriptionsResult;
527
- }
528
-
529
- const removeExpiredSubscriptionsIR: any = {"usedParamSet":{"groupId":true,"activeIds":true},"params":[{"name":"groupId","required":true,"transform":{"type":"scalar"},"locs":[{"a":68,"b":76}]},{"name":"activeIds","required":true,"transform":{"type":"scalar"},"locs":[{"a":219,"b":229}]}],"statement":"WITH deleted AS (\n\tDELETE FROM pgmb.subscriptions\n\tWHERE group_id = :groupId!\n\t\tAND expiry_interval IS NOT NULL\n\t\tAND pgmb.add_interval_imm(last_active_at, expiry_interval) < NOW()\n\t\tAND id NOT IN (select * from unnest(:activeIds!::pgmb.subscription_id[]))\n\tRETURNING id\n)\nSELECT COUNT(*) AS \"deleted!\" FROM deleted"};
530
-
531
- /**
532
- * Query generated from SQL:
533
- * ```
534
- * WITH deleted AS (
535
- * DELETE FROM pgmb.subscriptions
536
- * WHERE group_id = :groupId!
537
- * AND expiry_interval IS NOT NULL
538
- * AND pgmb.add_interval_imm(last_active_at, expiry_interval) < NOW()
539
- * AND id NOT IN (select * from unnest(:activeIds!::pgmb.subscription_id[]))
540
- * RETURNING id
541
- * )
542
- * SELECT COUNT(*) AS "deleted!" FROM deleted
543
- * ```
544
- */
545
- export const removeExpiredSubscriptions = new PreparedQuery<IRemoveExpiredSubscriptionsParams,IRemoveExpiredSubscriptionsResult>(removeExpiredSubscriptionsIR);
546
-
547
-
548
- /** 'GetConfigValue' parameters type */
549
- export interface IGetConfigValueParams {
550
- key: config_type;
551
- }
552
-
553
- /** 'GetConfigValue' return type */
554
- export interface IGetConfigValueResult {
555
- value: string | null;
556
- }
557
-
558
- /** 'GetConfigValue' query type */
559
- export interface IGetConfigValueQuery {
560
- params: IGetConfigValueParams;
561
- result: IGetConfigValueResult;
562
- }
563
-
564
- const getConfigValueIR: any = {"usedParamSet":{"key":true},"params":[{"name":"key","required":true,"transform":{"type":"scalar"},"locs":[{"a":29,"b":33}]}],"statement":"SELECT pgmb.get_config_value(:key!::pgmb.config_type) AS \"value\""};
565
-
566
- /**
567
- * Query generated from SQL:
568
- * ```
569
- * SELECT pgmb.get_config_value(:key!::pgmb.config_type) AS "value"
570
- * ```
571
- */
572
- export const getConfigValue = new PreparedQuery<IGetConfigValueParams,IGetConfigValueResult>(getConfigValueIR);
573
-
574
-
575
- /** 'UpdateConfigValue' parameters type */
576
- export interface IUpdateConfigValueParams {
577
- key: config_type;
578
- value: string;
579
- }
580
-
581
- /** 'UpdateConfigValue' return type */
582
- export interface IUpdateConfigValueResult {
583
- updated: number;
584
- }
585
-
586
- /** 'UpdateConfigValue' query type */
587
- export interface IUpdateConfigValueQuery {
588
- params: IUpdateConfigValueParams;
589
- result: IUpdateConfigValueResult;
590
- }
591
-
592
- const updateConfigValueIR: any = {"usedParamSet":{"value":true,"key":true},"params":[{"name":"value","required":true,"transform":{"type":"scalar"},"locs":[{"a":31,"b":37}]},{"name":"key","required":true,"transform":{"type":"scalar"},"locs":[{"a":56,"b":60}]}],"statement":"UPDATE pgmb.config\nSET value = :value!::TEXT\nWHERE id = :key!::pgmb.config_type\nRETURNING 1 AS \"updated!\""};
593
-
594
- /**
595
- * Query generated from SQL:
596
- * ```
597
- * UPDATE pgmb.config
598
- * SET value = :value!::TEXT
599
- * WHERE id = :key!::pgmb.config_type
600
- * RETURNING 1 AS "updated!"
601
- * ```
602
- */
603
- export const updateConfigValue = new PreparedQuery<IUpdateConfigValueParams,IUpdateConfigValueResult>(updateConfigValueIR);
604
-
605
-
606
- /** 'MaintainEventsTable' parameters type */
607
- export type IMaintainEventsTableParams = void;
608
-
609
- /** 'MaintainEventsTable' return type */
610
- export interface IMaintainEventsTableResult {
611
- maintainEventsTable: undefined | null;
612
- }
613
-
614
- /** 'MaintainEventsTable' query type */
615
- export interface IMaintainEventsTableQuery {
616
- params: IMaintainEventsTableParams;
617
- result: IMaintainEventsTableResult;
618
- }
619
-
620
- const maintainEventsTableIR: any = {"usedParamSet":{},"params":[],"statement":"SELECT pgmb.maintain_events_table()"};
621
-
622
- /**
623
- * Query generated from SQL:
624
- * ```
625
- * SELECT pgmb.maintain_events_table()
626
- * ```
627
- */
628
- export const maintainEventsTable = new PreparedQuery<IMaintainEventsTableParams,IMaintainEventsTableResult>(maintainEventsTableIR);
629
-
630
-
@@ -1,21 +0,0 @@
1
- export type QueryResult<T> = {
2
- rowCount: number
3
- rows: T[]
4
- }
5
-
6
- export interface PgClient {
7
- query<T = any>(query: string, params?: unknown[]): Promise<QueryResult<T>>
8
- exec?(query: string): Promise<unknown>
9
- }
10
-
11
- export interface PgReleasableClient extends PgClient {
12
- release: () => void
13
- }
14
-
15
- export interface PgPoolLike extends PgClient {
16
- connect: () => Promise<PgReleasableClient>
17
- on(ev: 'remove', handler: (cl: PgReleasableClient) => void): this
18
- off(ev: 'remove', handler: (cl: PgReleasableClient) => void): this
19
- }
20
-
21
- export type PgClientLike = PgClient | PgPoolLike