@rsdk/kafka.producer.outbox.typeorm 3.0.2 → 3.1.0-next.1

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
@@ -3,6 +3,16 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [3.1.0-next.1](https://github.com/R-Vision/rsdk/compare/v3.1.0-next.0...v3.1.0-next.1) (2023-08-08)
7
+
8
+ **Note:** Version bump only for package @rsdk/kafka.producer.outbox.typeorm
9
+
10
+ ## [3.1.0-next.0](https://github.com/R-Vision/rsdk/compare/v3.0.2...v3.1.0-next.0) (2023-08-08)
11
+
12
+ ### Features
13
+
14
+ * **kafka:** added option to consume by topic name ([#93](https://github.com/R-Vision/rsdk/issues/93)) ([09b4c1b](https://github.com/R-Vision/rsdk/commit/09b4c1bd515c1c2c3ccda17851fbe79e64ea8ac5))
15
+
6
16
  ## [3.0.2](https://github.com/R-Vision/rsdk/compare/v3.0.1...v3.0.2) (2023-08-07)
7
17
 
8
18
  **Note:** Version bump only for package @rsdk/kafka.producer.outbox.typeorm
@@ -3,9 +3,9 @@ import type { PublishOptions } from '@rsdk/kafka.producer';
3
3
  import { BaseProducer } from '@rsdk/kafka.producer';
4
4
  import type { Repository } from 'typeorm';
5
5
  import type { Outbox } from './outbox.entity';
6
- export declare class TypeOrmProducer<T extends EventType> extends BaseProducer<T> {
6
+ export declare class TypeOrmProducer<T extends EventType, P = T extends EventType<infer X> ? X : never> extends BaseProducer<T, P> {
7
7
  readonly protoType: T;
8
8
  private readonly outbox;
9
9
  constructor(protoType: T, outbox: Repository<Outbox>);
10
- publish(payload: T, options?: PublishOptions): Promise<void>;
10
+ publish(payload: P, options?: PublishOptions): Promise<void>;
11
11
  }
@@ -1 +1 @@
1
- {"version":3,"file":"typeorm.producer.js","sourceRoot":"","sources":["../src/typeorm.producer.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,yDAAoD;AACpD,oDAAsC;AAKtC,MAAa,eAAqC,SAAQ,6BAAe;IAE5D;IACQ;IAFnB,YACW,SAAY,EACJ,MAA0B;QAE3C,KAAK,CAAC,SAAS,CAAC,CAAC;QAHR,cAAS,GAAT,SAAS,CAAG;QACJ,WAAM,GAAN,MAAM,CAAoB;IAG7C,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,OAAU,EAAE,OAAwB;QAChD,MAAM,KAAK,GAAG,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QAElD,MAAM,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,GAAG,KAAK,EAAE,EAAE,EAAE,MAAM,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;IAClE,CAAC;CACF;AAbD,0CAaC"}
1
+ {"version":3,"file":"typeorm.producer.js","sourceRoot":"","sources":["../src/typeorm.producer.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,yDAAoD;AACpD,oDAAsC;AAKtC,MAAa,eAGX,SAAQ,6BAAkB;IAEf;IACQ;IAFnB,YACW,SAAY,EACJ,MAA0B;QAE3C,KAAK,CAAC,SAAS,CAAC,CAAC;QAHR,cAAS,GAAT,SAAS,CAAG;QACJ,WAAM,GAAN,MAAM,CAAoB;IAG7C,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,OAAU,EAAE,OAAwB;QAChD,MAAM,KAAK,GAAG,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QAElD,MAAM,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,GAAG,KAAK,EAAE,EAAE,EAAE,MAAM,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;IAClE,CAAC;CACF;AAhBD,0CAgBC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rsdk/kafka.producer.outbox.typeorm",
3
- "version": "3.0.2",
3
+ "version": "3.1.0-next.1",
4
4
  "description": "Producing messages to outbox table (on top of typeorm 0.3.*)",
5
5
  "license": "Apache License 2.0",
6
6
  "publishConfig": {
@@ -14,17 +14,17 @@
14
14
  "@nestjs/common": "^10.1.3",
15
15
  "@nestjs/microservices": "^10.1.3",
16
16
  "@nestjs/typeorm": "^10.0.0",
17
- "@rsdk/autodoc.protocol": "^3.0.2",
18
- "@rsdk/common": "^3.0.2",
19
- "@rsdk/core": "^3.0.2",
20
- "@rsdk/kafka.common": "^3.0.2",
21
- "@rsdk/kafka.producer": "^3.0.2",
22
- "@rsdk/logging": "^3.0.2",
23
- "@rsdk/metadata": "^3.0.2",
17
+ "@rsdk/autodoc.protocol": "^3.1.0-next.0",
18
+ "@rsdk/common": "^3.1.0-next.0",
19
+ "@rsdk/core": "^3.1.0-next.1",
20
+ "@rsdk/kafka.common": "^3.1.0-next.1",
21
+ "@rsdk/kafka.producer": "^3.1.0-next.1",
22
+ "@rsdk/logging": "^3.1.0-next.0",
23
+ "@rsdk/metadata": "^3.1.0-next.0",
24
24
  "typeorm": "^0.3.12"
25
25
  },
26
26
  "dependencies": {
27
27
  "lodash": "^4.17.21"
28
28
  },
29
- "gitHead": "3ee33710bf18bfadf87a6da92b060e6a17481110"
29
+ "gitHead": "e9002b175fb3d24b9bae5169df59bd250091672c"
30
30
  }
@@ -6,7 +6,10 @@ import type { Repository } from 'typeorm';
6
6
 
7
7
  import type { Outbox } from './outbox.entity';
8
8
 
9
- export class TypeOrmProducer<T extends EventType> extends BaseProducer<T> {
9
+ export class TypeOrmProducer<
10
+ T extends EventType,
11
+ P = T extends EventType<infer X> ? X : never,
12
+ > extends BaseProducer<T, P> {
10
13
  constructor(
11
14
  readonly protoType: T,
12
15
  private readonly outbox: Repository<Outbox>,
@@ -14,7 +17,7 @@ export class TypeOrmProducer<T extends EventType> extends BaseProducer<T> {
14
17
  super(protoType);
15
18
  }
16
19
 
17
- async publish(payload: T, options?: PublishOptions): Promise<void> {
20
+ async publish(payload: P, options?: PublishOptions): Promise<void> {
18
21
  const value = this.parsePayload(payload, options);
19
22
 
20
23
  await this.outbox.insert({ ...value, id: crypto.randomUUID() });
@@ -1,5 +0,0 @@
1
- import type { DynamicModule } from '@nestjs/common';
2
- import type { EventType } from '@rsdk/kafka.common';
3
- export declare class TypeOrmOutbox {
4
- static forEvent(eventType: EventType | EventType[]): DynamicModule;
5
- }
@@ -1,42 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.TypeOrmOutbox = void 0;
7
- const typeorm_1 = require("@nestjs/typeorm");
8
- const autodoc_protocol_1 = require("@rsdk/autodoc.protocol");
9
- const metadata_1 = require("@rsdk/metadata");
10
- const omit_1 = __importDefault(require("lodash/omit"));
11
- const autodoc_resolver_1 = require("./metadata/autodoc.resolver");
12
- const outbox_entity_1 = require("./outbox.entity");
13
- const typeorm_producer_1 = require("./typeorm.producer");
14
- class TypeOrmOutbox {
15
- static forEvent(eventType) {
16
- const eventTypes = Array.isArray(eventType) ? eventType : [eventType];
17
- const providers = eventTypes.map((eventType) => ({
18
- inject: [(0, typeorm_1.getRepositoryToken)(outbox_entity_1.Outbox)],
19
- provide: eventType.$type,
20
- useFactory: (repository) => new typeorm_producer_1.TypeOrmProducer(eventType, repository),
21
- }));
22
- const moduleDef = {
23
- imports: [typeorm_1.TypeOrmModule.forFeature([outbox_entity_1.Outbox])],
24
- module: TypeOrmOutbox,
25
- providers,
26
- exports: providers,
27
- };
28
- const rsdkMetadata = new metadata_1.RsdkMetadata(moduleDef, 'kafka-producer-direct');
29
- for (const eventType of eventTypes) {
30
- rsdkMetadata.add({
31
- eventType,
32
- // Потому что https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify#:~:text=If%20the%20value%20has%20a%20toJSON()%20method%2C%20it%27s%20responsible%20to%20define%20what%20data%20will%20be%20serialized.
33
- eventData: (0, omit_1.default)(eventType, 'toJSON'),
34
- });
35
- }
36
- const autodocMetadata = new autodoc_protocol_1.AutodocMetadata(rsdkMetadata);
37
- autodocMetadata.defineResolver(new autodoc_resolver_1.TypeormOutboxAutodocResolver(rsdkMetadata));
38
- return moduleDef;
39
- }
40
- }
41
- exports.TypeOrmOutbox = TypeOrmOutbox;
42
- //# sourceMappingURL=type-orm.outbox.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"type-orm.outbox.js","sourceRoot":"","sources":["../src/type-orm.outbox.ts"],"names":[],"mappings":";;;;;;AACA,6CAAoE;AACpE,6DAAyD;AAEzD,6CAA8C;AAC9C,uDAA+B;AAG/B,kEAA2E;AAC3E,mDAAyC;AACzC,yDAAqD;AAErD,MAAa,aAAa;IACxB,MAAM,CAAC,QAAQ,CAAC,SAAkC;QAChD,MAAM,UAAU,GAAG,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;QAEtE,MAAM,SAAS,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;YAC/C,MAAM,EAAE,CAAC,IAAA,4BAAkB,EAAC,sBAAM,CAAC,CAAC;YACpC,OAAO,EAAE,SAAS,CAAC,KAAK;YACxB,UAAU,EAAE,CACV,UAA8B,EACF,EAAE,CAC9B,IAAI,kCAAe,CAAC,SAAS,EAAE,UAAU,CAAC;SAC7C,CAAC,CAAC,CAAC;QAEJ,MAAM,SAAS,GAAG;YAChB,OAAO,EAAE,CAAC,uBAAa,CAAC,UAAU,CAAC,CAAC,sBAAM,CAAC,CAAC,CAAC;YAC7C,MAAM,EAAE,aAAa;YACrB,SAAS;YACT,OAAO,EAAE,SAAS;SACnB,CAAC;QACF,MAAM,YAAY,GAAG,IAAI,uBAAY,CAGlC,SAAS,EAAE,uBAAuB,CAAC,CAAC;QAEvC,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE;YAClC,YAAY,CAAC,GAAG,CAAC;gBACf,SAAS;gBACT,oPAAoP;gBACpP,SAAS,EAAE,IAAA,cAAI,EAAC,SAAS,EAAE,QAAQ,CAAC;aACrC,CAAC,CAAC;SACJ;QAED,MAAM,eAAe,GAAG,IAAI,kCAAe,CAAC,YAAY,CAAC,CAAC;QAE1D,eAAe,CAAC,cAAc,CAC5B,IAAI,+CAA4B,CAAC,YAAY,CAAC,CAC/C,CAAC;QAEF,OAAO,SAAS,CAAC;IACnB,CAAC;CACF;AAxCD,sCAwCC"}
@@ -1,5 +0,0 @@
1
- import type { DynamicModule } from '@nestjs/common';
2
- import type { EventType } from '@rsdk/kafka.common';
3
- export declare class TypeOrmOutboxStrategy {
4
- static forEvent(eventType: EventType): DynamicModule;
5
- }
@@ -1,23 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TypeOrmOutboxStrategy = void 0;
4
- const typeorm_1 = require("@nestjs/typeorm");
5
- const outbox_entity_1 = require("./outbox.entity");
6
- const typeorm_producer_1 = require("./typeorm.producer");
7
- class TypeOrmOutboxStrategy {
8
- static forEvent(eventType) {
9
- const provider = {
10
- inject: [(0, typeorm_1.getRepositoryToken)(outbox_entity_1.Outbox)],
11
- provide: eventType.$type,
12
- useFactory: (repository) => new typeorm_producer_1.TypeOrmProducer(eventType, repository),
13
- };
14
- return {
15
- imports: [typeorm_1.TypeOrmModule.forFeature([outbox_entity_1.Outbox])],
16
- module: TypeOrmOutboxStrategy,
17
- providers: [provider],
18
- exports: [provider.provide],
19
- };
20
- }
21
- }
22
- exports.TypeOrmOutboxStrategy = TypeOrmOutboxStrategy;
23
- //# sourceMappingURL=typeorm-outbox.strategy.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"typeorm-outbox.strategy.js","sourceRoot":"","sources":["../src/typeorm-outbox.strategy.ts"],"names":[],"mappings":";;;AACA,6CAAoE;AAIpE,mDAAyC;AACzC,yDAAqD;AAErD,MAAa,qBAAqB;IAChC,MAAM,CAAC,QAAQ,CAAC,SAAoB;QAClC,MAAM,QAAQ,GAAG;YACf,MAAM,EAAE,CAAC,IAAA,4BAAkB,EAAC,sBAAM,CAAC,CAAC;YACpC,OAAO,EAAE,SAAS,CAAC,KAAK;YACxB,UAAU,EAAE,CACV,UAA8B,EACF,EAAE,CAC9B,IAAI,kCAAe,CAAC,SAAS,EAAE,UAAU,CAAC;SAC7C,CAAC;QAEF,OAAO;YACL,OAAO,EAAE,CAAC,uBAAa,CAAC,UAAU,CAAC,CAAC,sBAAM,CAAC,CAAC,CAAC;YAC7C,MAAM,EAAE,qBAAqB;YAC7B,SAAS,EAAE,CAAC,QAAQ,CAAC;YACrB,OAAO,EAAE,CAAC,QAAQ,CAAC,OAAO,CAAC;SAC5B,CAAC;IACJ,CAAC;CACF;AAlBD,sDAkBC"}