@superhero/eventflow-db 4.3.5 → 4.3.7
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/index.js +35 -35
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
|
|
2
2
|
import Gateway from '@superhero/db'
|
|
3
|
-
import AdapterFactory from '@superhero/db/adapter/
|
|
3
|
+
import AdapterFactory from '@superhero/db/adapter/mysql2/factory.js'
|
|
4
4
|
import mysql2 from 'mysql2'
|
|
5
5
|
import path from 'node:path'
|
|
6
6
|
import { fileURLToPath } from 'node:url'
|
|
@@ -185,7 +185,7 @@ export default class DB
|
|
|
185
185
|
id = event.id ?? this.#generateEventId(),
|
|
186
186
|
data = JSON.stringify(event.data ?? {})
|
|
187
187
|
|
|
188
|
-
await this.gateway.query('event/persist',
|
|
188
|
+
await this.gateway.query('event/persist', { ...event, id, data })
|
|
189
189
|
|
|
190
190
|
return id
|
|
191
191
|
}
|
|
@@ -203,7 +203,7 @@ export default class DB
|
|
|
203
203
|
{
|
|
204
204
|
try
|
|
205
205
|
{
|
|
206
|
-
const result = await this.gateway.query('event/delete-by-id',
|
|
206
|
+
const result = await this.gateway.query('event/delete-by-id', id)
|
|
207
207
|
return result.affectedRows > 0
|
|
208
208
|
}
|
|
209
209
|
catch(reason)
|
|
@@ -219,7 +219,7 @@ export default class DB
|
|
|
219
219
|
{
|
|
220
220
|
try
|
|
221
221
|
{
|
|
222
|
-
const result = await this.gateway.query('event/delete-by-pid-domain',
|
|
222
|
+
const result = await this.gateway.query('event/delete-by-pid-domain', pid, domain)
|
|
223
223
|
return result.affectedRows > 0
|
|
224
224
|
}
|
|
225
225
|
catch(reason)
|
|
@@ -237,7 +237,7 @@ export default class DB
|
|
|
237
237
|
|
|
238
238
|
try
|
|
239
239
|
{
|
|
240
|
-
result = await this.gateway.query('event/read-by-id',
|
|
240
|
+
result = await this.gateway.query('event/read-by-id', id)
|
|
241
241
|
}
|
|
242
242
|
catch(reason)
|
|
243
243
|
{
|
|
@@ -264,7 +264,7 @@ export default class DB
|
|
|
264
264
|
|
|
265
265
|
try
|
|
266
266
|
{
|
|
267
|
-
result = await this.gateway.query('event/read-by-pid-domain',
|
|
267
|
+
result = await this.gateway.query('event/read-by-pid-domain', pid, domain)
|
|
268
268
|
}
|
|
269
269
|
catch(reason)
|
|
270
270
|
{
|
|
@@ -283,7 +283,7 @@ export default class DB
|
|
|
283
283
|
|
|
284
284
|
try
|
|
285
285
|
{
|
|
286
|
-
result = await this.gateway.query('event/read-by-pid-domain-betweeen-timestamps',
|
|
286
|
+
result = await this.gateway.query('event/read-by-pid-domain-betweeen-timestamps', pid, domain, timestampMin, timestampMax)
|
|
287
287
|
}
|
|
288
288
|
catch(reason)
|
|
289
289
|
{
|
|
@@ -303,7 +303,7 @@ export default class DB
|
|
|
303
303
|
try
|
|
304
304
|
{
|
|
305
305
|
const castings = names.map(() => `CAST(? AS CHAR CHARACTER SET ascii) COLLATE ascii_bin`).join(',')
|
|
306
|
-
result = await this.gateway.query('event/read-by-pid-domain-names',
|
|
306
|
+
result = await this.gateway.query('event/read-by-pid-domain-names', castings, pid, domain, ...names)
|
|
307
307
|
}
|
|
308
308
|
catch(reason)
|
|
309
309
|
{
|
|
@@ -320,7 +320,7 @@ export default class DB
|
|
|
320
320
|
{
|
|
321
321
|
try
|
|
322
322
|
{
|
|
323
|
-
const result = await this.gateway.query('event_cpid/persist',
|
|
323
|
+
const result = await this.gateway.query('event_cpid/persist', event_id, domain, cpid)
|
|
324
324
|
return result.affectedRows > 0
|
|
325
325
|
}
|
|
326
326
|
catch(reason)
|
|
@@ -336,7 +336,7 @@ export default class DB
|
|
|
336
336
|
{
|
|
337
337
|
try
|
|
338
338
|
{
|
|
339
|
-
const result = await this.gateway.query('event_cpid/delete',
|
|
339
|
+
const result = await this.gateway.query('event_cpid/delete', event_id, domain, cpid)
|
|
340
340
|
return result.affectedRows > 0
|
|
341
341
|
}
|
|
342
342
|
catch(reason)
|
|
@@ -354,7 +354,7 @@ export default class DB
|
|
|
354
354
|
|
|
355
355
|
try
|
|
356
356
|
{
|
|
357
|
-
result = await this.gateway.query('event_cpid/read-by-event_id',
|
|
357
|
+
result = await this.gateway.query('event_cpid/read-by-event_id', id)
|
|
358
358
|
}
|
|
359
359
|
catch(reason)
|
|
360
360
|
{
|
|
@@ -371,7 +371,7 @@ export default class DB
|
|
|
371
371
|
{
|
|
372
372
|
try
|
|
373
373
|
{
|
|
374
|
-
return await this.gateway.query('event_cpid/read-by-cpid-domain',
|
|
374
|
+
return await this.gateway.query('event_cpid/read-by-cpid-domain', cpid, domain)
|
|
375
375
|
}
|
|
376
376
|
catch(reason)
|
|
377
377
|
{
|
|
@@ -386,7 +386,7 @@ export default class DB
|
|
|
386
386
|
{
|
|
387
387
|
try
|
|
388
388
|
{
|
|
389
|
-
const result = await this.gateway.query('event_eid/persist',
|
|
389
|
+
const result = await this.gateway.query('event_eid/persist', event_id, eid)
|
|
390
390
|
return result.affectedRows > 0
|
|
391
391
|
}
|
|
392
392
|
catch(reason)
|
|
@@ -402,7 +402,7 @@ export default class DB
|
|
|
402
402
|
{
|
|
403
403
|
try
|
|
404
404
|
{
|
|
405
|
-
const result = await this.gateway.query('event_eid/delete',
|
|
405
|
+
const result = await this.gateway.query('event_eid/delete', event_id, eid)
|
|
406
406
|
return result.affectedRows > 0
|
|
407
407
|
}
|
|
408
408
|
catch(reason)
|
|
@@ -420,7 +420,7 @@ export default class DB
|
|
|
420
420
|
|
|
421
421
|
try
|
|
422
422
|
{
|
|
423
|
-
result = await this.gateway.query('event_eid/read-by-event_id',
|
|
423
|
+
result = await this.gateway.query('event_eid/read-by-event_id', id)
|
|
424
424
|
}
|
|
425
425
|
catch(reason)
|
|
426
426
|
{
|
|
@@ -437,7 +437,7 @@ export default class DB
|
|
|
437
437
|
{
|
|
438
438
|
try
|
|
439
439
|
{
|
|
440
|
-
return await this.gateway.query('event_eid/read-by-eid',
|
|
440
|
+
return await this.gateway.query('event_eid/read-by-eid', eid)
|
|
441
441
|
}
|
|
442
442
|
catch(reason)
|
|
443
443
|
{
|
|
@@ -452,7 +452,7 @@ export default class DB
|
|
|
452
452
|
{
|
|
453
453
|
try
|
|
454
454
|
{
|
|
455
|
-
return await this.gateway.query('event_eid/read-by-eid-domain',
|
|
455
|
+
return await this.gateway.query('event_eid/read-by-eid-domain', eid, domain)
|
|
456
456
|
}
|
|
457
457
|
catch(reason)
|
|
458
458
|
{
|
|
@@ -467,7 +467,7 @@ export default class DB
|
|
|
467
467
|
{
|
|
468
468
|
try
|
|
469
469
|
{
|
|
470
|
-
const result = await this.gateway.query('event_published/persist',
|
|
470
|
+
const result = await this.gateway.query('event_published/persist', publishedEvent)
|
|
471
471
|
return result.affectedRows > 0
|
|
472
472
|
}
|
|
473
473
|
catch(reason)
|
|
@@ -484,7 +484,7 @@ export default class DB
|
|
|
484
484
|
{
|
|
485
485
|
try
|
|
486
486
|
{
|
|
487
|
-
const result = await this.gateway.query('event_published/update-to-consumed-by-hub',
|
|
487
|
+
const result = await this.gateway.query('event_published/update-to-consumed-by-hub', hub, id)
|
|
488
488
|
return result.affectedRows > 0
|
|
489
489
|
}
|
|
490
490
|
catch(reason)
|
|
@@ -500,7 +500,7 @@ export default class DB
|
|
|
500
500
|
{
|
|
501
501
|
try
|
|
502
502
|
{
|
|
503
|
-
const result = await this.gateway.query('event_published/update-to-consumed-by-spoke',
|
|
503
|
+
const result = await this.gateway.query('event_published/update-to-consumed-by-spoke', spoke, id)
|
|
504
504
|
return result.affectedRows > 0
|
|
505
505
|
}
|
|
506
506
|
catch(reason)
|
|
@@ -516,7 +516,7 @@ export default class DB
|
|
|
516
516
|
{
|
|
517
517
|
try
|
|
518
518
|
{
|
|
519
|
-
const result = await this.gateway.query('event_published/update-to-orphan',
|
|
519
|
+
const result = await this.gateway.query('event_published/update-to-orphan', id)
|
|
520
520
|
return result.affectedRows > 0
|
|
521
521
|
}
|
|
522
522
|
catch(reason)
|
|
@@ -532,7 +532,7 @@ export default class DB
|
|
|
532
532
|
{
|
|
533
533
|
try
|
|
534
534
|
{
|
|
535
|
-
const result = await this.gateway.query('event_published/update-to-success',
|
|
535
|
+
const result = await this.gateway.query('event_published/update-to-success', id)
|
|
536
536
|
return result.affectedRows > 0
|
|
537
537
|
}
|
|
538
538
|
catch(reason)
|
|
@@ -548,7 +548,7 @@ export default class DB
|
|
|
548
548
|
{
|
|
549
549
|
try
|
|
550
550
|
{
|
|
551
|
-
const result = await this.gateway.query('event_published/update-to-failed',
|
|
551
|
+
const result = await this.gateway.query('event_published/update-to-failed', id)
|
|
552
552
|
return result.affectedRows > 0
|
|
553
553
|
}
|
|
554
554
|
catch(reason)
|
|
@@ -564,7 +564,7 @@ export default class DB
|
|
|
564
564
|
{
|
|
565
565
|
try
|
|
566
566
|
{
|
|
567
|
-
const result = await this.gateway.query('event_scheduled/persist',
|
|
567
|
+
const result = await this.gateway.query('event_scheduled/persist', scheduledEvent)
|
|
568
568
|
return result.affectedRows > 0
|
|
569
569
|
}
|
|
570
570
|
catch(reason)
|
|
@@ -596,7 +596,7 @@ export default class DB
|
|
|
596
596
|
{
|
|
597
597
|
try
|
|
598
598
|
{
|
|
599
|
-
const result = await this.gateway.query('event_scheduled/update-executed',
|
|
599
|
+
const result = await this.gateway.query('event_scheduled/update-executed', id)
|
|
600
600
|
return result.affectedRows > 0
|
|
601
601
|
}
|
|
602
602
|
catch(reason)
|
|
@@ -612,7 +612,7 @@ export default class DB
|
|
|
612
612
|
{
|
|
613
613
|
try
|
|
614
614
|
{
|
|
615
|
-
const result = await this.gateway.query('event_scheduled/update-success',
|
|
615
|
+
const result = await this.gateway.query('event_scheduled/update-success', id)
|
|
616
616
|
return result.affectedRows > 0
|
|
617
617
|
}
|
|
618
618
|
catch(reason)
|
|
@@ -628,7 +628,7 @@ export default class DB
|
|
|
628
628
|
{
|
|
629
629
|
try
|
|
630
630
|
{
|
|
631
|
-
const result = await this.gateway.query('event_scheduled/update-failed',
|
|
631
|
+
const result = await this.gateway.query('event_scheduled/update-failed', id)
|
|
632
632
|
return result.affectedRows > 0
|
|
633
633
|
}
|
|
634
634
|
catch(reason)
|
|
@@ -644,7 +644,7 @@ export default class DB
|
|
|
644
644
|
{
|
|
645
645
|
try
|
|
646
646
|
{
|
|
647
|
-
const result = await this.gateway.query('hub/persist',
|
|
647
|
+
const result = await this.gateway.query('hub/persist', hub)
|
|
648
648
|
return result.affectedRows > 0
|
|
649
649
|
}
|
|
650
650
|
catch(reason)
|
|
@@ -676,7 +676,7 @@ export default class DB
|
|
|
676
676
|
{
|
|
677
677
|
try
|
|
678
678
|
{
|
|
679
|
-
const result = await this.gateway.query('hub/update-to-quit',
|
|
679
|
+
const result = await this.gateway.query('hub/update-to-quit', hub)
|
|
680
680
|
return result.affectedRows > 0
|
|
681
681
|
}
|
|
682
682
|
catch(reason)
|
|
@@ -692,7 +692,7 @@ export default class DB
|
|
|
692
692
|
{
|
|
693
693
|
try
|
|
694
694
|
{
|
|
695
|
-
const result = await this.gateway.query('hub/read-quit-hub',
|
|
695
|
+
const result = await this.gateway.query('hub/read-quit-hub', hub)
|
|
696
696
|
return result.length > 0
|
|
697
697
|
}
|
|
698
698
|
catch(reason)
|
|
@@ -709,7 +709,7 @@ export default class DB
|
|
|
709
709
|
try
|
|
710
710
|
{
|
|
711
711
|
log.error = JSON.stringify(log.error ?? {})
|
|
712
|
-
await this.gateway.query('log/persist',
|
|
712
|
+
await this.gateway.query('log/persist', log)
|
|
713
713
|
}
|
|
714
714
|
catch(reason)
|
|
715
715
|
{
|
|
@@ -727,7 +727,7 @@ export default class DB
|
|
|
727
727
|
try
|
|
728
728
|
{
|
|
729
729
|
const partition = date.replace(/-/g, '')
|
|
730
|
-
await this.gateway.query('log/archive',
|
|
730
|
+
await this.gateway.query('log/archive', partition, date)
|
|
731
731
|
}
|
|
732
732
|
catch(reason)
|
|
733
733
|
{
|
|
@@ -744,7 +744,7 @@ export default class DB
|
|
|
744
744
|
|
|
745
745
|
try
|
|
746
746
|
{
|
|
747
|
-
result = await this.gateway.query('certificate/read',
|
|
747
|
+
result = await this.gateway.query('certificate/read', id)
|
|
748
748
|
}
|
|
749
749
|
catch(reason)
|
|
750
750
|
{
|
|
@@ -768,7 +768,7 @@ export default class DB
|
|
|
768
768
|
{
|
|
769
769
|
try
|
|
770
770
|
{
|
|
771
|
-
const result = await this.gateway.query('certificate/persist',
|
|
771
|
+
const result = await this.gateway.query('certificate/persist', certificate)
|
|
772
772
|
return result.affectedRows > 0
|
|
773
773
|
}
|
|
774
774
|
catch(reason)
|
|
@@ -790,7 +790,7 @@ export default class DB
|
|
|
790
790
|
{
|
|
791
791
|
try
|
|
792
792
|
{
|
|
793
|
-
const result = await this.gateway.query('certificate/revoke',
|
|
793
|
+
const result = await this.gateway.query('certificate/revoke', id, id)
|
|
794
794
|
return result.affectedRows > 0
|
|
795
795
|
}
|
|
796
796
|
catch(reason)
|