@privateaim/server-db-kit 0.8.21 → 0.8.23

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,41 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.8.23](https://github.com/PrivateAIM/hub/compare/v0.8.22...v0.8.23) (2026-02-02)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * **deps:** bump the minorandpatch group across 1 directory with 19 updates ([#1392](https://github.com/PrivateAIM/hub/issues/1392)) ([23060bf](https://github.com/PrivateAIM/hub/commit/23060bfce24100d17d4d83c7ee45ed6d85073c6b))
9
+ * initializing event component + reading event batches ([482e9e6](https://github.com/PrivateAIM/hub/commit/482e9e65f2aba1811bec26c4fcebe4d4bc91234b))
10
+
11
+
12
+ ### Dependencies
13
+
14
+ * The following workspace dependencies were updated
15
+ * dependencies
16
+ * @privateaim/kit bumped from ^0.8.22 to ^0.8.23
17
+ * @privateaim/server-kit bumped from ^0.8.22 to ^0.8.23
18
+
19
+ ## [0.8.22](https://github.com/PrivateAIM/hub/compare/v0.8.21...v0.8.22) (2026-01-27)
20
+
21
+
22
+ ### Features
23
+
24
+ * migrate to esm & replace jest with vitest ([#1368](https://github.com/PrivateAIM/hub/issues/1368)) ([5a4d9d1](https://github.com/PrivateAIM/hub/commit/5a4d9d1ce118f65740aa49caf948208eac299032))
25
+
26
+
27
+ ### Bug Fixes
28
+
29
+ * **deps:** bump the minorandpatch group across 1 directory with 16 updates ([#1329](https://github.com/PrivateAIM/hub/issues/1329)) ([7b394da](https://github.com/PrivateAIM/hub/commit/7b394da159d8e52cc37fe489832307a234f3ddb0))
30
+
31
+
32
+ ### Dependencies
33
+
34
+ * The following workspace dependencies were updated
35
+ * dependencies
36
+ * @privateaim/kit bumped from ^0.8.21 to ^0.8.22
37
+ * @privateaim/server-kit bumped from ^0.8.21 to ^0.8.22
38
+
3
39
  ## [0.8.21](https://github.com/PrivateAIM/hub/compare/v0.8.20...v0.8.21) (2025-11-04)
4
40
 
5
41
 
package/dist/index.mjs ADDED
@@ -0,0 +1,53 @@
1
+ import { DomainEventName } from '@privateaim/kit';
2
+ import { useEntityEventPublisher } from '@privateaim/server-kit';
3
+
4
+ class BaseSubscriber {
5
+ publisher;
6
+ destinations;
7
+ refType;
8
+ constructor(ctx){
9
+ this.refType = ctx.refType;
10
+ this.publisher = useEntityEventPublisher();
11
+ this.destinations = ctx.destinations;
12
+ }
13
+ async afterInsert(event) {
14
+ await this.publish({
15
+ data: event.entity,
16
+ type: DomainEventName.CREATED,
17
+ metadata: event.queryRunner.data
18
+ });
19
+ }
20
+ async afterUpdate(event) {
21
+ await this.publish({
22
+ type: DomainEventName.UPDATED,
23
+ data: event.entity,
24
+ dataPrevious: event.databaseEntity,
25
+ metadata: event.queryRunner.data
26
+ });
27
+ }
28
+ async beforeRemove(event) {
29
+ if (event.entity) {
30
+ await this.publish({
31
+ type: DomainEventName.DELETED,
32
+ data: event.entity,
33
+ metadata: event.queryRunner.data
34
+ });
35
+ }
36
+ }
37
+ async publish(payload) {
38
+ await this.publisher.safePublish({
39
+ data: payload.data,
40
+ dataPrevious: payload.dataPrevious,
41
+ metadata: {
42
+ ref_type: this.refType,
43
+ ref_id: payload.data.id,
44
+ event: payload.type,
45
+ ...payload.metadata ? payload.metadata : {}
46
+ },
47
+ destinations: this.destinations
48
+ });
49
+ }
50
+ }
51
+
52
+ export { BaseSubscriber };
53
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","sources":["../src/subscriber/base.ts"],"sourcesContent":["/*\n * Copyright (c) 2025.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport type { ObjectLiteral } from '@privateaim/kit';\nimport { DomainEventName } from '@privateaim/kit';\nimport type {\n EntityEventDestinations, EntityEventDestinationsFn,\n EntityEventPublisher,\n} from '@privateaim/server-kit';\nimport { useEntityEventPublisher } from '@privateaim/server-kit';\nimport type {\n EntitySubscriberInterface, InsertEvent, RemoveEvent, UpdateEvent,\n} from 'typeorm';\nimport type { BaseSubscriberContext, SubscriberPublishPayload } from './types';\n\nexport class BaseSubscriber<\n RECORD extends ObjectLiteral,\n> implements EntitySubscriberInterface<RECORD> {\n private readonly publisher: EntityEventPublisher;\n\n private readonly destinations : EntityEventDestinations | EntityEventDestinationsFn<RECORD>;\n\n private readonly refType: string;\n\n constructor(ctx: BaseSubscriberContext<RECORD>) {\n this.refType = ctx.refType;\n this.publisher = useEntityEventPublisher();\n this.destinations = ctx.destinations;\n }\n\n async afterInsert(event: InsertEvent<RECORD>): Promise<any> {\n await this.publish({\n data: event.entity,\n type: DomainEventName.CREATED,\n metadata: event.queryRunner.data,\n });\n }\n\n async afterUpdate(event: UpdateEvent<RECORD>): Promise<any> {\n await this.publish({\n type: DomainEventName.UPDATED,\n data: event.entity as RECORD,\n dataPrevious: event.databaseEntity,\n metadata: event.queryRunner.data,\n });\n }\n\n async beforeRemove(event: RemoveEvent<RECORD>): Promise<any> {\n if (event.entity) {\n await this.publish({\n type: DomainEventName.DELETED,\n data: event.entity as RECORD,\n metadata: event.queryRunner.data,\n });\n }\n }\n\n async publish(payload: SubscriberPublishPayload<RECORD>) {\n await this.publisher.safePublish({\n data: payload.data,\n dataPrevious: payload.dataPrevious,\n metadata: {\n ref_type: this.refType,\n ref_id: payload.data.id,\n\n event: payload.type,\n ...(payload.metadata ? payload.metadata : {}),\n },\n destinations: this.destinations,\n });\n }\n}\n"],"names":["BaseSubscriber","publisher","destinations","refType","ctx","useEntityEventPublisher","afterInsert","event","publish","data","entity","type","DomainEventName","CREATED","metadata","queryRunner","afterUpdate","UPDATED","dataPrevious","databaseEntity","beforeRemove","DELETED","payload","safePublish","ref_type","ref_id","id"],"mappings":";;;AAmBO,MAAMA,cAAAA,CAAAA;IAGQC,SAAAA;IAEAC,YAAAA;IAEAC,OAAAA;AAEjB,IAAA,WAAA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U;gBACNU,QAAAA,EAAU,IAAI,CAACrB,OAAO;gBACtBsB,MAAAA,EAAQH,OAAAA,CAAQb,IAAI,CAACiB,EAAE;AAEvBnB,gBAAAA,KAAAA,EAAOe,QAAQX,IAAI;AACnB,gBAAA,GAAIW,QAAQR,QAAQ,GAAGQ,QAAQR,QAAQ,GAAG;AAC9C,aAAA;YACAZ,YAAAA,EAAc,IAAI,CAACA;AACvB,SAAA,CAAA;AACJ,IAAA;AACJ;;;;"}
package/package.json CHANGED
@@ -1,8 +1,16 @@
1
1
  {
2
2
  "name": "@privateaim/server-db-kit",
3
- "version": "0.8.21",
4
- "main": "dist/index.js",
3
+ "type": "module",
4
+ "version": "0.8.23",
5
+ "module": "dist/index.mjs",
5
6
  "types": "dist/index.d.ts",
7
+ "exports": {
8
+ "./package.json": "./package.json",
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.mjs"
12
+ }
13
+ },
6
14
  "author": {
7
15
  "name": "Peter Placzek",
8
16
  "email": "contact@tada5hi.net",
@@ -11,18 +19,20 @@
11
19
  "license": "Apache-2.0",
12
20
  "description": "This package contains server side db helpers & utilities.",
13
21
  "dependencies": {
14
- "@privateaim/kit": "^0.8.21",
15
- "@privateaim/server-kit": "^0.8.21"
22
+ "@privateaim/kit": "^0.8.23",
23
+ "@privateaim/server-kit": "^0.8.23"
16
24
  },
17
25
  "devDependencies": {
18
- "typeorm": "^0.3.27",
19
- "typeorm-extension": "^3.7.1"
26
+ "typeorm": "^0.3.28",
27
+ "typeorm-extension": "^3.8.0"
20
28
  },
21
29
  "peerDependencies": {
22
- "typeorm": "^0.3.27",
23
- "typeorm-extension": "^3.7.1"
30
+ "typeorm": "^0.3.28",
31
+ "typeorm-extension": "^3.8.0"
24
32
  },
25
33
  "scripts": {
26
- "build": "rimraf dist && tsc -p tsconfig.build.json"
34
+ "build:types": "tsc --emitDeclarationOnly -p tsconfig.build.json",
35
+ "build:js": "rollup -c",
36
+ "build": "rimraf ./dist && cross-env NODE_ENV=production npm run build:js && npm run build:types"
27
37
  }
28
38
  }
@@ -0,0 +1,14 @@
1
+ /*
2
+ * Copyright (c) 2022.
3
+ * Author Peter Placzek (tada5hi)
4
+ * For the full copyright and license information,
5
+ * view the LICENSE file that was distributed with this source code.
6
+ */
7
+
8
+ import fs from 'node:fs';
9
+
10
+ import { createConfig } from '../../rollup.config.mjs';
11
+
12
+ export default createConfig({
13
+ pkg: JSON.parse(fs.readFileSync(new URL('./package.json', import.meta.url), { encoding: 'utf-8' })),
14
+ });
package/dist/index.js DELETED
@@ -1,24 +0,0 @@
1
- "use strict";
2
- /*
3
- * Copyright (c) 2024.
4
- * Author Peter Placzek (tada5hi)
5
- * For the full copyright and license information,
6
- * view the LICENSE file that was distributed with this source code.
7
- */
8
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
9
- if (k2 === undefined) k2 = k;
10
- var desc = Object.getOwnPropertyDescriptor(m, k);
11
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
12
- desc = { enumerable: true, get: function() { return m[k]; } };
13
- }
14
- Object.defineProperty(o, k2, desc);
15
- }) : (function(o, m, k, k2) {
16
- if (k2 === undefined) k2 = k;
17
- o[k2] = m[k];
18
- }));
19
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
20
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
21
- };
22
- Object.defineProperty(exports, "__esModule", { value: true });
23
- __exportStar(require("./subscriber"), exports);
24
- //# sourceMappingURL=index.js.map
package/dist/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;;;;;;;;;;;;;AAEH,+CAA6B"}
@@ -1,60 +0,0 @@
1
- "use strict";
2
- /*
3
- * Copyright (c) 2025.
4
- * Author Peter Placzek (tada5hi)
5
- * For the full copyright and license information,
6
- * view the LICENSE file that was distributed with this source code.
7
- */
8
- Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.BaseSubscriber = void 0;
10
- const kit_1 = require("@privateaim/kit");
11
- const server_kit_1 = require("@privateaim/server-kit");
12
- class BaseSubscriber {
13
- publisher;
14
- destinations;
15
- refType;
16
- constructor(ctx) {
17
- this.refType = ctx.refType;
18
- this.publisher = (0, server_kit_1.useEntityEventPublisher)();
19
- this.destinations = ctx.destinations;
20
- }
21
- async afterInsert(event) {
22
- await this.publish({
23
- data: event.entity,
24
- type: kit_1.DomainEventName.CREATED,
25
- metadata: event.queryRunner.data,
26
- });
27
- }
28
- async afterUpdate(event) {
29
- await this.publish({
30
- type: kit_1.DomainEventName.UPDATED,
31
- data: event.entity,
32
- dataPrevious: event.databaseEntity,
33
- metadata: event.queryRunner.data,
34
- });
35
- }
36
- async beforeRemove(event) {
37
- if (event.entity) {
38
- await this.publish({
39
- type: kit_1.DomainEventName.DELETED,
40
- data: event.entity,
41
- metadata: event.queryRunner.data,
42
- });
43
- }
44
- }
45
- async publish(payload) {
46
- await this.publisher.safePublish({
47
- data: payload.data,
48
- dataPrevious: payload.dataPrevious,
49
- metadata: {
50
- ref_type: this.refType,
51
- ref_id: payload.data.id,
52
- event: payload.type,
53
- ...(payload.metadata ? payload.metadata : {}),
54
- },
55
- destinations: this.destinations,
56
- });
57
- }
58
- }
59
- exports.BaseSubscriber = BaseSubscriber;
60
- //# sourceMappingURL=base.js.map
@@ -1 +0,0 @@
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,oCAAu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,CAAC,CAAC,EAAE,CAAC;aAChD;YACD,YAAY,EAAE,IAAI,CAAC,YAAY;SAClC,CAAC,CAAC;IACP,CAAC;CACJ;AAxDD,wCAwDC"}
@@ -1,25 +0,0 @@
1
- "use strict";
2
- /*
3
- * Copyright (c) 2025.
4
- * Author Peter Placzek (tada5hi)
5
- * For the full copyright and license information,
6
- * view the LICENSE file that was distributed with this source code.
7
- */
8
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
9
- if (k2 === undefined) k2 = k;
10
- var desc = Object.getOwnPropertyDescriptor(m, k);
11
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
12
- desc = { enumerable: true, get: function() { return m[k]; } };
13
- }
14
- Object.defineProperty(o, k2, desc);
15
- }) : (function(o, m, k, k2) {
16
- if (k2 === undefined) k2 = k;
17
- o[k2] = m[k];
18
- }));
19
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
20
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
21
- };
22
- Object.defineProperty(exports, "__esModule", { value: true });
23
- __exportStar(require("./base"), exports);
24
- __exportStar(require("./types"), exports);
25
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/subscriber/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;;;;;;;;;;;;;AAEH,yCAAuB;AACvB,0CAAwB"}
@@ -1,9 +0,0 @@
1
- "use strict";
2
- /*
3
- * Copyright (c) 2025.
4
- * Author Peter Placzek (tada5hi)
5
- * For the full copyright and license information,
6
- * view the LICENSE file that was distributed with this source code.
7
- */
8
- Object.defineProperty(exports, "__esModule", { value: true });
9
- //# sourceMappingURL=types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/subscriber/types.ts"],"names":[],"mappings":";AAAA;;;;;GAKG"}