@privateaim/server-db-kit 0.8.16 → 0.8.18
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 +30 -0
- package/dist/subscriber/base.d.ts +3 -4
- package/dist/subscriber/base.d.ts.map +1 -1
- package/dist/subscriber/base.js +5 -4
- package/dist/subscriber/base.js.map +1 -1
- package/dist/subscriber/types.d.ts +4 -4
- package/dist/subscriber/types.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/subscriber/base.ts +11 -9
- package/src/subscriber/types.ts +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,35 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.8.18](https://github.com/PrivateAIM/hub/compare/v0.8.17...v0.8.18) (2025-09-16)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Dependencies
|
|
7
|
+
|
|
8
|
+
* The following workspace dependencies were updated
|
|
9
|
+
* dependencies
|
|
10
|
+
* @privateaim/kit bumped from ^0.8.17 to ^0.8.18
|
|
11
|
+
* @privateaim/server-kit bumped from ^0.8.17 to ^0.8.18
|
|
12
|
+
|
|
13
|
+
## [0.8.17](https://github.com/PrivateAIM/hub/compare/v0.8.16...v0.8.17) (2025-09-01)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
### Features
|
|
17
|
+
|
|
18
|
+
* refactor domain event publisher & register amqp ([0f98ecf](https://github.com/PrivateAIM/hub/commit/0f98ecf3c24239d9050fd4a7c2e0bd6843cb3dc8))
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
### Bug Fixes
|
|
22
|
+
|
|
23
|
+
* database base subscriber types ([f30c44e](https://github.com/PrivateAIM/hub/commit/f30c44eb7f891400de96104c2ea95b6d8fc5a438))
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
### Dependencies
|
|
27
|
+
|
|
28
|
+
* The following workspace dependencies were updated
|
|
29
|
+
* dependencies
|
|
30
|
+
* @privateaim/kit bumped from ^0.8.16 to ^0.8.17
|
|
31
|
+
* @privateaim/server-kit bumped from ^0.8.16 to ^0.8.17
|
|
32
|
+
|
|
3
33
|
## [0.8.16](https://github.com/PrivateAIM/hub/compare/v0.8.15...v0.8.16) (2025-08-26)
|
|
4
34
|
|
|
5
35
|
|
|
@@ -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
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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;
|
|
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"}
|
package/dist/subscriber/base.js
CHANGED
|
@@ -12,10 +12,10 @@ const server_kit_1 = require("@privateaim/server-kit");
|
|
|
12
12
|
class BaseSubscriber {
|
|
13
13
|
publisher;
|
|
14
14
|
destinations;
|
|
15
|
-
|
|
15
|
+
refType;
|
|
16
16
|
constructor(ctx) {
|
|
17
|
-
this.
|
|
18
|
-
this.publisher = (0, server_kit_1.
|
|
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
|
-
|
|
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/subscriber/base.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAGH,yCAAkD;AAKlD,uDAAiE;AAMjE,MAAa,cAAc;
|
|
1
|
+
{"version":3,"file":"base.js","sourceRoot":"","sources":["../../src/subscriber/base.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAGH,yCAAkD;AAKlD,uDAAiE;AAMjE,MAAa,cAAc;IAGN,SAAS,CAAuB;IAEhC,YAAY,CAA+D;IAE3E,OAAO,CAAS;IAEjC,YAAY,GAAkC;QAC1C,IAAI,CAAC,OAAO,GAAG,GAAG,CAAC,OAAO,CAAC;QAC3B,IAAI,CAAC,SAAS,GAAG,IAAA,oCAAuB,GAAE,CAAC;QAC3C,IAAI,CAAC,YAAY,GAAG,GAAG,CAAC,YAAY,CAAC;IACzC,CAAC;IAED,KAAK,CAAC,WAAW,CAAC,KAA0B;QACxC,MAAM,IAAI,CAAC,OAAO,CAAC;YACf,IAAI,EAAE,KAAK,CAAC,MAAM;YAClB,IAAI,EAAE,qBAAe,CAAC,OAAO;YAC7B,QAAQ,EAAE,KAAK,CAAC,WAAW,CAAC,IAAI;SACnC,CAAC,CAAC;IACP,CAAC;IAED,KAAK,CAAC,WAAW,CAAC,KAA0B;QACxC,MAAM,IAAI,CAAC,OAAO,CAAC;YACf,IAAI,EAAE,qBAAe,CAAC,OAAO;YAC7B,IAAI,EAAE,KAAK,CAAC,MAAgB;YAC5B,YAAY,EAAE,KAAK,CAAC,cAAc;YAClC,QAAQ,EAAE,KAAK,CAAC,WAAW,CAAC,IAAI;SACnC,CAAC,CAAC;IACP,CAAC;IAED,KAAK,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 {
|
|
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<
|
|
6
|
+
metadata?: Partial<EntityEventMetadata>;
|
|
7
7
|
};
|
|
8
8
|
export type BaseSubscriberContext<RECORD extends ObjectLiteral = ObjectLiteral> = {
|
|
9
|
-
|
|
10
|
-
destinations:
|
|
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,
|
|
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.
|
|
3
|
+
"version": "0.8.18",
|
|
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.
|
|
15
|
-
"@privateaim/server-kit": "^0.8.
|
|
14
|
+
"@privateaim/kit": "^0.8.18",
|
|
15
|
+
"@privateaim/server-kit": "^0.8.18"
|
|
16
16
|
},
|
|
17
17
|
"devDependencies": {
|
|
18
18
|
"typeorm": "^0.3.26",
|
package/src/subscriber/base.ts
CHANGED
|
@@ -8,10 +8,10 @@
|
|
|
8
8
|
import type { ObjectLiteral } from '@privateaim/kit';
|
|
9
9
|
import { DomainEventName } from '@privateaim/kit';
|
|
10
10
|
import type {
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
EntityEventDestinations, EntityEventDestinationsFn,
|
|
12
|
+
EntityEventPublisher,
|
|
13
13
|
} from '@privateaim/server-kit';
|
|
14
|
-
import {
|
|
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
|
-
|
|
23
|
+
private readonly publisher: EntityEventPublisher;
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
private readonly destinations : EntityEventDestinations | EntityEventDestinationsFn<RECORD>;
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
private readonly refType: string;
|
|
28
28
|
|
|
29
29
|
constructor(ctx: BaseSubscriberContext<RECORD>) {
|
|
30
|
-
this.
|
|
31
|
-
this.publisher =
|
|
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
|
-
|
|
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
|
},
|
package/src/subscriber/types.ts
CHANGED
|
@@ -6,9 +6,9 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import type {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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<
|
|
19
|
+
metadata?: Partial<EntityEventMetadata>,
|
|
20
20
|
};
|
|
21
21
|
|
|
22
22
|
export type BaseSubscriberContext<
|
|
23
23
|
RECORD extends ObjectLiteral = ObjectLiteral,
|
|
24
24
|
> = {
|
|
25
|
-
|
|
26
|
-
destinations:
|
|
25
|
+
refType: string,
|
|
26
|
+
destinations: EntityEventDestinations | EntityEventDestinationsFn<RECORD>,
|
|
27
27
|
};
|