@superhero/eventflow-db 4.1.1 → 4.1.3

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/README.md CHANGED
@@ -423,87 +423,87 @@ npm test
423
423
  ▶ @superhero/eventflow-db
424
424
  ▶ Setup table schemas
425
425
  ▶ Persist a hub
426
- ✔ Read online hubs (8.808208ms)
426
+ ✔ Read online hubs (6.657231ms)
427
427
 
428
428
  ▶ Persisting an event should generate an ID if not provided
429
- ✔ Read an event by id should return the same data as when persisted the event (9.057985ms)
429
+ ✔ Read an event by id should return the same data as when persisted the event (6.927063ms)
430
430
 
431
431
  ▶ Schedule a persisted event
432
- ✔ Read all scheduled events (5.28951ms)
433
- ✔ Update scheduled event as executed (11.686935ms)
434
- ✔ Update scheduled event as success (10.393756ms)
435
- ✔ Update scheduled event as failed (9.877872ms)
436
- ✔ Schedule a persisted event (50.493271ms)
432
+ ✔ Read all scheduled events (3.495457ms)
433
+ ✔ Update scheduled event as executed (8.137136ms)
434
+ ✔ Update scheduled event as success (4.61686ms)
435
+ ✔ Update scheduled event as failed (6.822805ms)
436
+ ✔ Schedule a persisted event (32.658117ms)
437
437
 
438
438
  ▶ Publish a persisted event
439
- ✔ Update published event to consumed by hub (8.985592ms)
440
- ✔ Update published event to consumed by spoke (10.847144ms)
441
- ✔ Update published event to success (8.945934ms)
442
- ✔ Update published event to failed (12.743366ms)
443
- ✔ Update published event to orphan (12.484305ms)
444
- ✔ Publish a persisted event (69.042999ms)
439
+ ✔ Update published event to consumed by hub (5.682705ms)
440
+ ✔ Update published event to consumed by spoke (6.462036ms)
441
+ ✔ Update published event to success (6.573691ms)
442
+ ✔ Update published event to failed (8.581383ms)
443
+ ✔ Update published event to orphan (6.094177ms)
444
+ ✔ Publish a persisted event (43.017241ms)
445
445
 
446
446
  ▶ Persist event cpid association
447
- ✔ Read events by domain and cpid (6.375096ms)
448
- ✔ Read associated cpid by event id (6.539711ms)
449
- ✔ Delete associated cpid by event id (35.785772ms)
450
- ✔ Read deleted associated cpid by event id returns empty (3.44164ms)
451
- ✔ Persist event cpid association (63.474382ms)
447
+ ✔ Read events by domain and cpid (3.71914ms)
448
+ ✔ Read associated cpid by event id (7.035953ms)
449
+ ✔ Delete associated cpid by event id (6.621011ms)
450
+ ✔ Read deleted associated cpid by event id returns empty (4.727825ms)
451
+ ✔ Persist event cpid association (34.125991ms)
452
452
 
453
453
  ▶ Persist event eid association
454
- ✔ Read events by eid (3.186193ms)
455
- ✔ Read events by domain and eid (3.211094ms)
456
- ✔ Read associated eid by event id (5.22712ms)
457
- ✔ Delete associated eid by event id (4.791241ms)
458
- ✔ Read deleted associated eid by event id returns empty (2.82022ms)
459
- ✔ Persist event eid association (25.839658ms)
454
+ ✔ Read events by eid (3.884999ms)
455
+ ✔ Read events by domain and eid (5.055002ms)
456
+ ✔ Read associated eid by event id (5.857354ms)
457
+ ✔ Delete associated eid by event id (6.000871ms)
458
+ ✔ Read deleted associated eid by event id returns empty (3.435941ms)
459
+ ✔ Persist event eid association (35.837834ms)
460
460
 
461
461
  ▶ Delete event
462
- ✔ Reading a deleted event rejects (2.870914ms)
463
- ✔ Delete event (12.001935ms)
462
+ ✔ Reading a deleted event rejects (3.54941ms)
463
+ ✔ Delete event (12.321329ms)
464
464
 
465
465
  ▶ By domain and pid
466
- ✔ Read event by domain and pid (4.653075ms)
467
- ✔ Delete event by domain and pid (6.649683ms)
468
- ✔ Read empty eventlog by domain and pid (2.870288ms)
469
- ✔ By domain and pid (19.564013ms)
470
- ✔ Persisting an event should generate an ID if not provided (257.977724ms)
471
-
472
- ✔ Persist log (8.236839ms)
473
- ✔ Update hub to quit (11.86896ms)
466
+ ✔ Read event by domain and pid (4.147919ms)
467
+ ✔ Delete event by domain and pid (6.651147ms)
468
+ ✔ Read empty eventlog by domain and pid (5.039975ms)
469
+ ✔ By domain and pid (24.294124ms)
470
+ ✔ Persisting an event should generate an ID if not provided (196.618539ms)
471
+
472
+ ✔ Persist log (9.773113ms)
473
+ ✔ Update hub to quit (6.745869ms)
474
474
 
475
475
  ▶ Certificate management
476
- ✔ Persist a certificate (9.410534ms)
477
- ✔ Persisting a duplicate certificate should return false (3.669139ms)
478
- ✔ Read a persisted certificate by id (9.817305ms)
479
- ✔ Reading a non-existing certificate should reject with an error (3.705119ms)
476
+ ✔ Persist a certificate (11.285064ms)
477
+ ✔ Persisting a duplicate certificate should return false (3.597549ms)
478
+ ✔ Read a persisted certificate by id (9.74682ms)
479
+ ✔ Reading a non-existing certificate should reject with an error (3.670532ms)
480
480
 
481
481
  ▶ Revoke a persisted certificate
482
- ✔ Reading a revoked certificate should reject with an error (3.894204ms)
483
- ✔ Revoke a persisted certificate (14.21005ms)
482
+ ✔ Reading a revoked certificate should reject with an error (2.507398ms)
483
+ ✔ Revoke a persisted certificate (10.427673ms)
484
484
 
485
485
  ▶ Revoke certificates that past there validity period
486
- ✔ Reading a revoked certificate should reject with an error (2.925027ms)
487
- ✔ Revoke certificates that past there validity period (13.092224ms)
488
- ✔ Certificate management (44.130336ms)
489
- ✔ Persist a hub (339.721847ms)
486
+ ✔ Reading a revoked certificate should reject with an error (2.622701ms)
487
+ ✔ Revoke certificates that past there validity period (15.182145ms)
488
+ ✔ Certificate management (58.006904ms)
489
+ ✔ Persist a hub (302.207468ms)
490
490
 
491
- ✔ Reading a non existing event should reject with an error (6.280731ms)
492
- ✔ Setup table schemas (431.031157ms)
493
- ✔ @superhero/eventflow-db (436.106715ms)
491
+ ✔ Reading a non existing event should reject with an error (3.189934ms)
492
+ ✔ Setup table schemas (516.946853ms)
493
+ ✔ @superhero/eventflow-db (519.11646ms)
494
494
 
495
- tests 43
495
+ tests 45
496
496
  suites 1
497
- pass 43
497
+ pass 45
498
498
 
499
499
  -------------------------------------------------------------------------------------------------------------------------
500
500
  file | line % | branch % | funcs % | uncovered lines
501
501
  -------------------------------------------------------------------------------------------------------------------------
502
502
  config.js | 100.00 | 100.00 | 100.00 |
503
- index.js | 69.41 | 56.25 | 97.92 | 43-48 58-62 73-77 88-92 103-107 118-122 133-137 148-153 186-191 203-207…
503
+ index.js | 69.26 | 56.57 | 97.96 | 43-48 58-62 73-77 88-92 103-107 118-122 133-137 148-153 186-191 203-207…
504
504
  index.test.js | 100.00 | 100.00 | 100.00 |
505
505
  -------------------------------------------------------------------------------------------------------------------------
506
- all files | 79.42 | 70.83 | 98.92 |
506
+ all files | 79.36 | 71.14 | 98.96 |
507
507
  -------------------------------------------------------------------------------------------------------------------------
508
508
  ```
509
509
 
package/config.js CHANGED
@@ -5,7 +5,7 @@ export default
5
5
  {
6
6
  locator:
7
7
  {
8
- '@superhero/eventflow-db' : './index.js'
8
+ '@superhero/eventflow-db' : true
9
9
  },
10
10
  eventflow:
11
11
  {
package/index.js CHANGED
@@ -1,14 +1,14 @@
1
1
 
2
2
  import Gateway from '@superhero/db'
3
- import mysql2 from 'mysql2'
4
3
  import AdapterFactory from '@superhero/db/adapter/mysql/factory.js'
4
+ import mysql2 from 'mysql2'
5
5
  import path from 'node:path'
6
6
  import { fileURLToPath } from 'node:url'
7
7
 
8
8
  export function locate(locator)
9
9
  {
10
10
  const
11
- config = locator('@superhero/config').find('eventflow/db', {}),
11
+ config = locator.config.find('eventflow/db', {}),
12
12
  adapterFactory = new AdapterFactory(),
13
13
  adapter = adapterFactory.create(mysql2, config),
14
14
  filePath = fileURLToPath(path.join(path.dirname(import.meta.url), 'sql')),
package/index.test.js CHANGED
@@ -1,4 +1,3 @@
1
- import Config from '@superhero/config'
2
1
  import Locator from '@superhero/locator'
3
2
  import { locate } from '@superhero/eventflow-db'
4
3
  import assert from 'node:assert/strict'
@@ -7,10 +6,9 @@ import { after, suite, test } from 'node:test'
7
6
  suite('@superhero/eventflow-db', async () =>
8
7
  {
9
8
  const
10
- config = new Config(),
11
- locator = new Locator()
9
+ locator = new Locator(),
10
+ config = locator.config
12
11
 
13
- locator.set('@superhero/config', config)
14
12
  await config.add('./config.js')
15
13
  const db = locate(locator)
16
14
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@superhero/eventflow-db",
3
- "version": "4.1.1",
3
+ "version": "4.1.3",
4
4
  "description": "Eventflow db is a set of common database logic in the eventflow ecosystem.",
5
5
  "keywords": [
6
6
  "eventflow"
@@ -15,8 +15,7 @@
15
15
  "@superhero/db": "^0.5.0"
16
16
  },
17
17
  "devDependencies": {
18
- "@superhero/config": "4.1.2",
19
- "@superhero/locator": "4.2.0"
18
+ "@superhero/locator": "4.2.2"
20
19
  },
21
20
  "scripts": {
22
21
  "test-build": "docker ps -q -f name=eventflow-mysql | grep -q . && docker stop eventflow-mysql; docker run --rm --name eventflow-mysql -e MYSQL_ROOT_PASSWORD=root -e MYSQL_DATABASE=eventflow -p 3306:3306 --health-cmd=\"mysqladmin ping -h 127.0.0.1 -uroot -proot --silent || exit 1\" --health-interval=10s --health-timeout=5s --health-retries=5 -d mysql:latest; until [ \"$(docker inspect --format='{{.State.Health.Status}}' eventflow-mysql)\" == \"healthy\" ]; do sleep 1; done",