@privateaim/server-db-kit 0.8.16 → 0.8.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/CHANGELOG.md CHANGED
@@ -1,5 +1,25 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.8.17](https://github.com/PrivateAIM/hub/compare/v0.8.16...v0.8.17) (2025-09-01)
4
+
5
+
6
+ ### Features
7
+
8
+ * refactor domain event publisher & register amqp ([0f98ecf](https://github.com/PrivateAIM/hub/commit/0f98ecf3c24239d9050fd4a7c2e0bd6843cb3dc8))
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * database base subscriber types ([f30c44e](https://github.com/PrivateAIM/hub/commit/f30c44eb7f891400de96104c2ea95b6d8fc5a438))
14
+
15
+
16
+ ### Dependencies
17
+
18
+ * The following workspace dependencies were updated
19
+ * dependencies
20
+ * @privateaim/kit bumped from ^0.8.16 to ^0.8.17
21
+ * @privateaim/server-kit bumped from ^0.8.16 to ^0.8.17
22
+
3
23
  ## [0.8.16](https://github.com/PrivateAIM/hub/compare/v0.8.15...v0.8.16) (2025-08-26)
4
24
 
5
25
 
@@ -1,11 +1,10 @@
1
1
  import type { ObjectLiteral } from '@privateaim/kit';
2
- import type { DomainEventDestinations, DomainEventDestinationsFn, DomainEventPublisher } from '@privateaim/server-kit';
3
2
  import type { EntitySubscriberInterface, InsertEvent, RemoveEvent, UpdateEvent } from 'typeorm';
4
3
  import type { BaseSubscriberContext, SubscriberPublishPayload } from './types';
5
4
  export declare class BaseSubscriber<RECORD extends ObjectLiteral> implements EntitySubscriberInterface<RECORD> {
6
- protected publisher: DomainEventPublisher;
7
- protected destinations: DomainEventDestinations | DomainEventDestinationsFn<RECORD>;
8
- protected domain: string;
5
+ private readonly publisher;
6
+ private readonly destinations;
7
+ private readonly refType;
9
8
  constructor(ctx: BaseSubscriberContext<RECORD>);
10
9
  afterInsert(event: InsertEvent<RECORD>): Promise<any>;
11
10
  afterUpdate(event: UpdateEvent<RECORD>): Promise<any>;
@@ -1 +1 @@
1
- {"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../src/subscriber/base.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAErD,OAAO,KAAK,EACR,uBAAuB,EAAE,yBAAyB,EAClD,oBAAoB,EACvB,MAAM,wBAAwB,CAAC;AAEhC,OAAO,KAAK,EACR,yBAAyB,EAAE,WAAW,EAAE,WAAW,EAAE,WAAW,EACnE,MAAM,SAAS,CAAC;AACjB,OAAO,KAAK,EAAE,qBAAqB,EAAE,wBAAwB,EAAE,MAAM,SAAS,CAAC;AAE/E,qBAAa,cAAc,CACvB,MAAM,SAAS,aAAa,CAC9B,YAAW,yBAAyB,CAAC,MAAM,CAAC;IAC1C,SAAS,CAAC,SAAS,EAAE,oBAAoB,CAAC;IAE1C,SAAS,CAAC,YAAY,EAAG,uBAAuB,GAAG,yBAAyB,CAAC,MAAM,CAAC,CAAC;IAErF,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC;gBAEb,GAAG,EAAE,qBAAqB,CAAC,MAAM,CAAC;IAMxC,WAAW,CAAC,KAAK,EAAE,WAAW,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC;IAQrD,WAAW,CAAC,KAAK,EAAE,WAAW,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC;IASrD,YAAY,CAAC,KAAK,EAAE,WAAW,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC;IAUtD,OAAO,CAAC,OAAO,EAAE,wBAAwB,CAAC,MAAM,CAAC;CAY1D"}
1
+ {"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../src/subscriber/base.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAOrD,OAAO,KAAK,EACR,yBAAyB,EAAE,WAAW,EAAE,WAAW,EAAE,WAAW,EACnE,MAAM,SAAS,CAAC;AACjB,OAAO,KAAK,EAAE,qBAAqB,EAAE,wBAAwB,EAAE,MAAM,SAAS,CAAC;AAE/E,qBAAa,cAAc,CACvB,MAAM,SAAS,aAAa,CAC9B,YAAW,yBAAyB,CAAC,MAAM,CAAC;IAC1C,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAuB;IAEjD,OAAO,CAAC,QAAQ,CAAC,YAAY,CAA+D;IAE5F,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;gBAErB,GAAG,EAAE,qBAAqB,CAAC,MAAM,CAAC;IAMxC,WAAW,CAAC,KAAK,EAAE,WAAW,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC;IAQrD,WAAW,CAAC,KAAK,EAAE,WAAW,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC;IASrD,YAAY,CAAC,KAAK,EAAE,WAAW,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC;IAUtD,OAAO,CAAC,OAAO,EAAE,wBAAwB,CAAC,MAAM,CAAC;CAc1D"}
@@ -12,10 +12,10 @@ const server_kit_1 = require("@privateaim/server-kit");
12
12
  class BaseSubscriber {
13
13
  publisher;
14
14
  destinations;
15
- domain;
15
+ refType;
16
16
  constructor(ctx) {
17
- this.domain = ctx.domain;
18
- this.publisher = (0, server_kit_1.useDomainEventPublisher)();
17
+ this.refType = ctx.refType;
18
+ this.publisher = (0, server_kit_1.useEntityEventPublisher)();
19
19
  this.destinations = ctx.destinations;
20
20
  }
21
21
  async afterInsert(event) {
@@ -47,7 +47,8 @@ class BaseSubscriber {
47
47
  data: payload.data,
48
48
  dataPrevious: payload.dataPrevious,
49
49
  metadata: {
50
- domain: this.domain,
50
+ ref_type: this.refType,
51
+ ref_id: payload.data.id,
51
52
  event: payload.type,
52
53
  ...(payload.metadata ? payload.metadata : {}),
53
54
  },
@@ -1 +1 @@
1
- {"version":3,"file":"base.js","sourceRoot":"","sources":["../../src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K,CAAC,YAAY,CAAC,KAA0B;QACzC,IAAI,KAAK,CAAC,MAAM,EAAE,CAAC;YACf,MAAM,IAAI,CAAC,OAAO,CAAC;gBACf,IAAI,EAAE,qBAAe,CAAC,OAAO;gBAC7B,IAAI,EAAE,KAAK,CAAC,MAAgB;gBAC5B,QAAQ,EAAE,KAAK,CAAC,WAAW,CAAC,IAAI;aACnC,CAAC,CAAC;QACP,CAAC;IACL,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,OAAyC;QACnD,MAAM,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC;YAC7B,IAAI,EAAE,OAAO,CAAC,IAAI;YAClB,YAAY,EAAE,OAAO,CAAC,YAAY;YAClC,QAAQ,EAAE;gBACN,QAAQ,EAAE,IAAI,CAAC,OAAO;gBACtB,MAAM,EAAE,OAAO,CAAC,IAAI,CAAC,EAAE;gBAEvB,KAAK,EAAE,OAAO,CAAC,IAAI;gBACnB,GAAG,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC;aAChD;YACD,YAAY,EAAE,IAAI,CAAC,YAAY;SAClC,CAAC,CAAC;IACP,CAAC;CACJ;AAxDD,wCAwDC"}
@@ -1,12 +1,12 @@
1
- import type { DomainEventDestinations, DomainEventDestinationsFn, DomainEventMetadata, ObjectLiteral } from '@privateaim/server-kit';
1
+ import type { EntityEventDestinations, EntityEventDestinationsFn, EntityEventMetadata, ObjectLiteral } from '@privateaim/server-kit';
2
2
  export type SubscriberPublishPayload<T> = {
3
3
  type: string;
4
4
  data: T;
5
5
  dataPrevious?: T;
6
- metadata?: Partial<DomainEventMetadata>;
6
+ metadata?: Partial<EntityEventMetadata>;
7
7
  };
8
8
  export type BaseSubscriberContext<RECORD extends ObjectLiteral = ObjectLiteral> = {
9
- domain: string;
10
- destinations: DomainEventDestinations | DomainEventDestinationsFn<RECORD>;
9
+ refType: string;
10
+ destinations: EntityEventDestinations | EntityEventDestinationsFn<RECORD>;
11
11
  };
12
12
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/subscriber/types.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EACR,uBAAuB,EACvB,yBAAyB,EACzB,mBAAmB,EACnB,aAAa,EAChB,MAAM,wBAAwB,CAAC;AAEhC,MAAM,MAAM,wBAAwB,CAAC,CAAC,IAAI;IACtC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,CAAC,CAAC;IACR,YAAY,CAAC,EAAE,CAAC,CAAC;IACjB,QAAQ,CAAC,EAAE,OAAO,CAAC,mBAAmB,CAAC,CAAC;CAC3C,CAAC;AAEF,MAAM,MAAM,qBAAqB,CAC7B,MAAM,SAAS,aAAa,GAAG,aAAa,IAC5C;IACA,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,uBAAuB,GAAG,yBAAyB,CAAC,MAAM,CAAC,CAAC;CAC7E,CAAC"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/subscriber/types.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EACR,uBAAuB,EACvB,yBAAyB,EACzB,mBAAmB,EACnB,aAAa,EAChB,MAAM,wBAAwB,CAAC;AAEhC,MAAM,MAAM,wBAAwB,CAAC,CAAC,IAAI;IACtC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,CAAC,CAAC;IACR,YAAY,CAAC,EAAE,CAAC,CAAC;IACjB,QAAQ,CAAC,EAAE,OAAO,CAAC,mBAAmB,CAAC,CAAC;CAC3C,CAAC;AAEF,MAAM,MAAM,qBAAqB,CAC7B,MAAM,SAAS,aAAa,GAAG,aAAa,IAC5C;IACA,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,uBAAuB,GAAG,yBAAyB,CAAC,MAAM,CAAC,CAAC;CAC7E,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@privateaim/server-db-kit",
3
- "version": "0.8.16",
3
+ "version": "0.8.17",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "author": {
@@ -11,8 +11,8 @@
11
11
  "license": "Apache-2.0",
12
12
  "description": "This package contains server side db helpers & utilities.",
13
13
  "dependencies": {
14
- "@privateaim/kit": "^0.8.16",
15
- "@privateaim/server-kit": "^0.8.16"
14
+ "@privateaim/kit": "^0.8.17",
15
+ "@privateaim/server-kit": "^0.8.17"
16
16
  },
17
17
  "devDependencies": {
18
18
  "typeorm": "^0.3.26",
@@ -8,10 +8,10 @@
8
8
  import type { ObjectLiteral } from '@privateaim/kit';
9
9
  import { DomainEventName } from '@privateaim/kit';
10
10
  import type {
11
- DomainEventDestinations, DomainEventDestinationsFn,
12
- DomainEventPublisher,
11
+ EntityEventDestinations, EntityEventDestinationsFn,
12
+ EntityEventPublisher,
13
13
  } from '@privateaim/server-kit';
14
- import { useDomainEventPublisher } from '@privateaim/server-kit';
14
+ import { useEntityEventPublisher } from '@privateaim/server-kit';
15
15
  import type {
16
16
  EntitySubscriberInterface, InsertEvent, RemoveEvent, UpdateEvent,
17
17
  } from 'typeorm';
@@ -20,15 +20,15 @@ import type { BaseSubscriberContext, SubscriberPublishPayload } from './types';
20
20
  export class BaseSubscriber<
21
21
  RECORD extends ObjectLiteral,
22
22
  > implements EntitySubscriberInterface<RECORD> {
23
- protected publisher: DomainEventPublisher;
23
+ private readonly publisher: EntityEventPublisher;
24
24
 
25
- protected destinations : DomainEventDestinations | DomainEventDestinationsFn<RECORD>;
25
+ private readonly destinations : EntityEventDestinations | EntityEventDestinationsFn<RECORD>;
26
26
 
27
- protected domain: string;
27
+ private readonly refType: string;
28
28
 
29
29
  constructor(ctx: BaseSubscriberContext<RECORD>) {
30
- this.domain = ctx.domain;
31
- this.publisher = useDomainEventPublisher();
30
+ this.refType = ctx.refType;
31
+ this.publisher = useEntityEventPublisher();
32
32
  this.destinations = ctx.destinations;
33
33
  }
34
34
 
@@ -64,7 +64,9 @@ export class BaseSubscriber<
64
64
  data: payload.data,
65
65
  dataPrevious: payload.dataPrevious,
66
66
  metadata: {
67
- domain: this.domain,
67
+ ref_type: this.refType,
68
+ ref_id: payload.data.id,
69
+
68
70
  event: payload.type,
69
71
  ...(payload.metadata ? payload.metadata : {}),
70
72
  },
@@ -6,9 +6,9 @@
6
6
  */
7
7
 
8
8
  import type {
9
- DomainEventDestinations,
10
- DomainEventDestinationsFn,
11
- DomainEventMetadata,
9
+ EntityEventDestinations,
10
+ EntityEventDestinationsFn,
11
+ EntityEventMetadata,
12
12
  ObjectLiteral,
13
13
  } from '@privateaim/server-kit';
14
14
 
@@ -16,12 +16,12 @@ export type SubscriberPublishPayload<T> = {
16
16
  type: string,
17
17
  data: T,
18
18
  dataPrevious?: T,
19
- metadata?: Partial<DomainEventMetadata>,
19
+ metadata?: Partial<EntityEventMetadata>,
20
20
  };
21
21
 
22
22
  export type BaseSubscriberContext<
23
23
  RECORD extends ObjectLiteral = ObjectLiteral,
24
24
  > = {
25
- domain: string,
26
- destinations: DomainEventDestinations | DomainEventDestinationsFn<RECORD>,
25
+ refType: string,
26
+ destinations: EntityEventDestinations | EntityEventDestinationsFn<RECORD>,
27
27
  };