@merkaly/nest 0.2.0 → 0.2.2

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.
Files changed (54) hide show
  1. package/README.md +44 -24
  2. package/dist/events/aliexpress.d.ts +10 -0
  3. package/dist/events/aliexpress.d.ts.map +1 -0
  4. package/dist/events/aliexpress.js +12 -0
  5. package/dist/events/aliexpress.js.map +1 -0
  6. package/dist/events/index.d.ts +2 -2
  7. package/dist/events/index.d.ts.map +1 -1
  8. package/dist/events/index.js +2 -2
  9. package/dist/events/index.js.map +1 -1
  10. package/dist/events/merkaly-event.d.ts +96 -0
  11. package/dist/events/merkaly-event.d.ts.map +1 -0
  12. package/dist/events/merkaly-event.js +49 -0
  13. package/dist/events/merkaly-event.js.map +1 -0
  14. package/dist/http/request-logger.d.ts +1 -0
  15. package/dist/http/request-logger.d.ts.map +1 -1
  16. package/dist/http/request-logger.js +16 -5
  17. package/dist/http/request-logger.js.map +1 -1
  18. package/dist/logger/request-context.d.ts +7 -0
  19. package/dist/logger/request-context.d.ts.map +1 -1
  20. package/dist/logger/request-context.js +8 -0
  21. package/dist/logger/request-context.js.map +1 -1
  22. package/dist/rabbit/events.consumer.d.ts +19 -0
  23. package/dist/rabbit/events.consumer.d.ts.map +1 -0
  24. package/dist/rabbit/events.consumer.js +96 -0
  25. package/dist/rabbit/events.consumer.js.map +1 -0
  26. package/dist/rabbit/events.publisher.d.ts +8 -8
  27. package/dist/rabbit/events.publisher.d.ts.map +1 -1
  28. package/dist/rabbit/events.publisher.js +36 -41
  29. package/dist/rabbit/events.publisher.js.map +1 -1
  30. package/dist/rabbit/index.d.ts +1 -0
  31. package/dist/rabbit/index.d.ts.map +1 -1
  32. package/dist/rabbit/index.js +1 -0
  33. package/dist/rabbit/index.js.map +1 -1
  34. package/dist/rabbit/rabbit.consumer.d.ts +7 -10
  35. package/dist/rabbit/rabbit.consumer.d.ts.map +1 -1
  36. package/dist/rabbit/rabbit.consumer.js +38 -13
  37. package/dist/rabbit/rabbit.consumer.js.map +1 -1
  38. package/dist/rabbit/rabbit.module.d.ts +4 -2
  39. package/dist/rabbit/rabbit.module.d.ts.map +1 -1
  40. package/dist/rabbit/rabbit.module.js +35 -15
  41. package/dist/rabbit/rabbit.module.js.map +1 -1
  42. package/dist/rabbit/rabbit.options.d.ts +25 -5
  43. package/dist/rabbit/rabbit.options.d.ts.map +1 -1
  44. package/dist/rabbit/rabbit.options.js +6 -2
  45. package/dist/rabbit/rabbit.options.js.map +1 -1
  46. package/package.json +1 -1
  47. package/dist/events/webhook-event.d.ts +0 -12
  48. package/dist/events/webhook-event.d.ts.map +0 -1
  49. package/dist/events/webhook-event.js +0 -11
  50. package/dist/events/webhook-event.js.map +0 -1
  51. package/dist/events/webhook-patterns.d.ts +0 -52
  52. package/dist/events/webhook-patterns.d.ts.map +0 -1
  53. package/dist/events/webhook-patterns.js +0 -49
  54. package/dist/events/webhook-patterns.js.map +0 -1
@@ -1,18 +1,18 @@
1
1
  import { OnApplicationBootstrap, OnApplicationShutdown } from '@nestjs/common';
2
- import { WebhookEvent, WebhookPattern } from '../events';
2
+ import { EventDataMap, MerkalyEvent, MerkalyEventMeta, MerkalyEventType } from '../events';
3
3
  import { LoggerService } from '../logger';
4
- import { BrokerStatus, RabbitClientFactory, RabbitModuleOptions } from './rabbit.options';
4
+ import { BrokerStatus, RabbitClient, RabbitModuleOptions } from './rabbit.options';
5
+ export declare const describeError: (error: any) => string;
5
6
  export declare class EventsPublisher implements OnApplicationBootstrap, OnApplicationShutdown {
6
7
  private readonly options;
7
- private readonly factory;
8
- private readonly clients;
8
+ private readonly client;
9
9
  private readonly logger;
10
10
  private brokerStatus;
11
- constructor(options: RabbitModuleOptions, factory: RabbitClientFactory | null, logger?: LoggerService);
11
+ constructor(options: RabbitModuleOptions, client: RabbitClient | null, logger?: LoggerService);
12
12
  get status(): BrokerStatus;
13
+ private get exchange();
13
14
  onApplicationBootstrap(): void | Promise<any>;
14
- onApplicationShutdown(): Promise<any[]>;
15
- publish<T>(pattern: WebhookPattern | (string & {}), event: WebhookEvent<T>): Promise<void>;
16
- private client;
15
+ onApplicationShutdown(): any;
16
+ emit<K extends MerkalyEventType>(type: K, data: EventDataMap[K], meta?: MerkalyEventMeta): Promise<MerkalyEvent<K>>;
17
17
  }
18
18
  //# sourceMappingURL=events.publisher.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"events.publisher.d.ts","sourceRoot":"","sources":["../../src/rabbit/events.publisher.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,sBAAsB,EACtB,qBAAqB,EAGtB,MAAM,gBAAgB,CAAC;AAGxB,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EACL,YAAY,EAIZ,mBAAmB,EACnB,mBAAmB,EACpB,MAAM,kBAAkB,CAAC;AAO1B,qBACa,eAAgB,YAAW,sBAAsB,EAAE,qBAAqB;IAMzD,OAAO,CAAC,QAAQ,CAAC,OAAO;IACjB,OAAO,CAAC,QAAQ,CAAC,OAAO;IANzD,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAkC;IAC1D,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAgB;IACvC,OAAO,CAAC,YAAY,CAAe;gBAGQ,OAAO,EAAE,mBAAmB,EACrB,OAAO,EAAE,mBAAmB,GAAG,IAAI,EACvE,MAAM,CAAC,EAAE,aAAa;IAMpC,IAAW,MAAM,iBAEhB;IAEM,sBAAsB;IAyBtB,qBAAqB;IAIrB,OAAO,CAAC,CAAC,EACd,OAAO,EAAE,cAAc,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,EACvC,KAAK,EAAE,YAAY,CAAC,CAAC,CAAC,GACrB,OAAO,CAAC,IAAI,CAAC;IAsBhB,OAAO,CAAC,MAAM;CAKf"}
1
+ {"version":3,"file":"events.publisher.d.ts","sourceRoot":"","sources":["../../src/rabbit/events.publisher.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,sBAAsB,EACtB,qBAAqB,EAGtB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EACL,YAAY,EACZ,YAAY,EACZ,gBAAgB,EAChB,gBAAgB,EAEjB,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,aAAa,EAAe,MAAM,WAAW,CAAC;AACvD,OAAO,EACL,YAAY,EAKZ,YAAY,EACZ,mBAAmB,EACpB,MAAM,kBAAkB,CAAC;AAE1B,eAAO,MAAM,aAAa,GAAI,OAAO,GAAG,KAAG,MAGkB,CAAC;AAI9D,qBACa,eAAgB,YAAW,sBAAsB,EAAE,qBAAqB;IAKzD,OAAO,CAAC,QAAQ,CAAC,OAAO;IACzB,OAAO,CAAC,QAAQ,CAAC,MAAM;IALhD,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAgB;IACvC,OAAO,CAAC,YAAY,CAAe;gBAGQ,OAAO,EAAE,mBAAmB,EAC7B,MAAM,EAAE,YAAY,GAAG,IAAI,EACvD,MAAM,CAAC,EAAE,aAAa;IAMpC,IAAW,MAAM,iBAEhB;IAED,OAAO,KAAK,QAAQ,GAEnB;IAEM,sBAAsB;IAkBtB,qBAAqB;IAKrB,IAAI,CAAC,CAAC,SAAS,gBAAgB,EACpC,IAAI,EAAE,CAAC,EACP,IAAI,EAAE,YAAY,CAAC,CAAC,CAAC,EACrB,IAAI,CAAC,EAAE,gBAAgB,GACtB,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;CAuB5B"}
@@ -11,84 +11,79 @@ var __metadata = (this && this.__metadata) || function (k, v) {
11
11
  var __param = (this && this.__param) || function (paramIndex, decorator) {
12
12
  return function (target, key) { decorator(target, key, paramIndex); }
13
13
  };
14
- var EventsPublisher_1;
15
14
  Object.defineProperty(exports, "__esModule", { value: true });
16
- exports.EventsPublisher = void 0;
15
+ exports.EventsPublisher = exports.describeError = void 0;
17
16
  const common_1 = require("@nestjs/common");
18
17
  const rxjs_1 = require("rxjs");
18
+ const events_1 = require("../events");
19
19
  const logger_1 = require("../logger");
20
20
  const rabbit_options_1 = require("./rabbit.options");
21
- const describe = (error) => error?.message ??
21
+ const describeError = (error) => error?.message ??
22
22
  error?.err?.message ??
23
23
  (typeof error === 'string' ? error : JSON.stringify(error));
24
- let EventsPublisher = EventsPublisher_1 = class EventsPublisher {
24
+ exports.describeError = describeError;
25
+ const GROUP = 'EventsPublisher';
26
+ let EventsPublisher = class EventsPublisher {
25
27
  options;
26
- factory;
27
- clients = new Map();
28
+ client;
28
29
  logger;
29
30
  brokerStatus;
30
- constructor(options, factory, logger) {
31
+ constructor(options, client, logger) {
31
32
  this.options = options;
32
- this.factory = factory;
33
+ this.client = client;
33
34
  this.logger = logger ?? new logger_1.LoggerService();
34
- this.brokerStatus = factory ? 'connecting' : 'disabled';
35
+ this.brokerStatus = client ? 'connecting' : 'disabled';
35
36
  }
36
37
  get status() {
37
38
  return this.brokerStatus;
38
39
  }
40
+ get exchange() {
41
+ return this.options.exchange ?? rabbit_options_1.MERKALY_EXCHANGE;
42
+ }
39
43
  onApplicationBootstrap() {
40
- if (!this.factory) {
44
+ if (!this.client) {
41
45
  return this.logger.warn({
42
- group: EventsPublisher_1.name,
43
- message: 'RabbitMQ url is not set: publishing disabled, every publish will fail',
44
- type: 'event',
46
+ group: GROUP,
47
+ message: 'RabbitMQ url is not set: publishing disabled, every emit will fail',
45
48
  });
46
49
  }
47
- const client = this.client(this.options.queue);
48
- client.status?.subscribe((status) => {
50
+ this.client.status?.subscribe((status) => {
49
51
  this.brokerStatus = status === 'connected' ? 'connected' : 'disconnected';
50
52
  });
51
- return client.connect().catch((error) => {
53
+ return this.client.connect().catch((error) => {
52
54
  this.brokerStatus = 'disconnected';
53
- this.logger.error({
54
- group: EventsPublisher_1.name,
55
- message: `Broker unreachable: ${describe(error)}`,
56
- type: 'event',
57
- });
55
+ this.logger.error({ group: GROUP, message: `Broker unreachable: ${(0, exports.describeError)(error)}` });
58
56
  });
59
57
  }
60
58
  onApplicationShutdown() {
61
- return Promise.all([...this.clients.values()].map((client) => client.close()));
59
+ return this.client?.close();
62
60
  }
63
- publish(pattern, event) {
64
- if (!this.factory) {
61
+ emit(type, data, meta) {
62
+ if (!this.client) {
65
63
  return Promise.reject(new common_1.ServiceUnavailableException('Event broker is not configured'));
66
64
  }
67
- const queue = this.options.routes?.[pattern] ?? this.options.queue;
65
+ const event = (0, events_1.createMerkalyEvent)(this.options.producer, type, data, meta);
68
66
  const ms = this.options.timeout ?? rabbit_options_1.DEFAULT_PUBLISH_TIMEOUT;
69
- const emitted$ = this.client(queue).emit(pattern, event).pipe((0, rxjs_1.timeout)(ms));
70
- const log = { group: EventsPublisher_1.name, type: 'event' };
71
- return (0, rxjs_1.lastValueFrom)(emitted$, { defaultValue: undefined })
72
- .then(() => this.logger.log({ ...log, message: `${pattern} (${event.id}) -> ${queue}` }))
67
+ const line = `${type} (${event.id}) -> ${this.exchange}`;
68
+ return (0, rxjs_1.lastValueFrom)(this.client.emit(type, event).pipe((0, rxjs_1.timeout)(ms)), {
69
+ defaultValue: undefined,
70
+ })
71
+ .then(() => {
72
+ if (!(0, logger_1.noteRequest)(`-> ${type}`))
73
+ this.logger.log({ group: GROUP, message: line });
74
+ return event;
75
+ })
73
76
  .catch((error) => {
74
- this.logger.error({
75
- ...log,
76
- message: `${pattern} (${event.id}) -> ${queue} failed: ${describe(error)}`,
77
- });
78
- throw new common_1.ServiceUnavailableException(`Could not publish ${pattern}`);
77
+ this.logger.error({ group: GROUP, message: `${line} failed: ${(0, exports.describeError)(error)}` });
78
+ throw new common_1.ServiceUnavailableException(`Could not publish ${type}`);
79
79
  });
80
80
  }
81
- client(queue) {
82
- if (!this.clients.has(queue))
83
- this.clients.set(queue, this.factory(queue));
84
- return this.clients.get(queue);
85
- }
86
81
  };
87
82
  exports.EventsPublisher = EventsPublisher;
88
- exports.EventsPublisher = EventsPublisher = EventsPublisher_1 = __decorate([
83
+ exports.EventsPublisher = EventsPublisher = __decorate([
89
84
  (0, common_1.Injectable)(),
90
85
  __param(0, (0, common_1.Inject)(rabbit_options_1.RABBIT_OPTIONS)),
91
- __param(1, (0, common_1.Inject)(rabbit_options_1.RABBIT_CLIENT_FACTORY)),
86
+ __param(1, (0, common_1.Inject)(rabbit_options_1.RABBIT_CLIENT)),
92
87
  __param(2, (0, common_1.Optional)()),
93
88
  __metadata("design:paramtypes", [Object, Object, logger_1.LoggerService])
94
89
  ], EventsPublisher);
@@ -1 +1 @@
1
- {"version":3,"file":"events.publisher.js","sourceRoot":"","sources":["../../src/rabbit/events.publisher.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAOwB;AAExB,+BAA8C;AAE9C,sCAA0C;AAC1C,qDAO0B;AAE1B,MAAM,QAAQ,GAAG,CAAC,KAAU,EAAU,EAAE,CACtC,KAAK,EAAE,OAAO;IACd,KAAK,EAAE,GAAG,EAAE,OAAO;IACnB,CAAC,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC;AAGvD,IAAM,eAAe,uBAArB,MAAM,eAAe;IAMiB;IACO;IANjC,OAAO,GAAG,IAAI,GAAG,EAAuB,CAAC;IACzC,MAAM,CAAgB;IAC/B,YAAY,CAAe;IAEnC,YAC2C,OAA4B,EACrB,OAAmC,EACvE,MAAsB;QAFO,YAAO,GAAP,OAAO,CAAqB;QACrB,YAAO,GAAP,OAAO,CAA4B;QAGnF,IAAI,CAAC,MAAM,GAAG,MAAM,IAAI,IAAI,sBAAa,EAAE,CAAC;QAC5C,IAAI,CAAC,YAAY,GAAG,OAAO,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,UAAU,CAAC;IAC1D,CAAC;IAED,IAAW,MAAM;QACf,OAAO,IAAI,CAAC,YAAY,CAAC;IAC3B,CAAC;IAEM,sBAAsB;QAC3B,IAAI,CAAC,IAAI,CAAC,OA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C,OAAO,IAAI,wCAAuB,CAAC;QAC3D,MAAM,IAAI,GAAG,GAAG,IAAI,KAAK,KAAK,CAAC,EAAE,QAAQ,IAAI,CAAC,QAAQ,EAAE,CAAC;QAEzD,OAAO,IAAA,oBAAa,EAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,IAAI,CAAC,IAAA,cAAO,EAAC,EAAE,CAAC,CAAC,EAAE;YACpE,YAAY,EAAE,SAAS;SACxB,CAAC;aACC,IAAI,CAAC,GAAG,EAAE;YACT,IAAI,CAAC,IAAA,oBAAW,EAAC,MAAM,IAAI,EAAE,CAAC;gBAAE,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;YAEjF,OAAO,KAAK,CAAC;QACf,CAAC,CAAC;aACD,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;YACf,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,IAAI,YAAY,IAAA,qBAAa,EAAC,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC;YAExF,MAAM,IAAI,oCAA2B,CAAC,qBAAqB,IAAI,EAAE,CAAC,CAAC;QACrE,CAAC,CAAC,CAAC;IACP,CAAC;CACF,CAAA;AAvEY,0CAAe;0BAAf,eAAe;IAD3B,IAAA,mBAAU,GAAE;IAMR,WAAA,IAAA,eAAM,EAAC,+BAAc,CAAC,CAAA;IACtB,WAAA,IAAA,eAAM,EAAC,8BAAa,CAAC,CAAA;IACrB,WAAA,IAAA,iBAAQ,GAAE,CAAA;qDAAU,sBAAa;GAPzB,eAAe,CAuE3B"}
@@ -1,3 +1,4 @@
1
+ export * from './events.consumer';
1
2
  export * from './events.publisher';
2
3
  export * from './rabbit.consumer';
3
4
  export * from './rabbit.module';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/rabbit/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/rabbit/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC"}
@@ -14,6 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./events.consumer"), exports);
17
18
  __exportStar(require("./events.publisher"), exports);
18
19
  __exportStar(require("./rabbit.consumer"), exports);
19
20
  __exportStar(require("./rabbit.module"), exports);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/rabbit/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,qDAAmC;AACnC,oDAAkC;AAClC,kDAAgC;AAChC,mDAAiC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/rabbit/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,oDAAkC;AAClC,qDAAmC;AACnC,oDAAkC;AAClC,kDAAgC;AAChC,mDAAiC"}
@@ -1,12 +1,9 @@
1
- import { RmqContext, RmqOptions } from '@nestjs/microservices';
2
- import { WebhookPattern } from '../events';
3
- export interface RabbitConsumerOptions {
4
- url: string;
5
- queue: string;
6
- prefetchCount?: number;
7
- }
1
+ import { RmqOptions } from '@nestjs/microservices';
2
+ import { MerkalyEventType } from '../events';
3
+ import { RabbitConsumerOptions } from './rabbit.options';
4
+ export declare const retryQueue: (queue: string) => string;
5
+ export declare const deadLetterQueue: (queue: string) => string;
8
6
  export declare function rabbitConsumerOptions(options: RabbitConsumerOptions): RmqOptions;
9
- export declare const OnRabbitEvent: (pattern: WebhookPattern | (string & {})) => MethodDecorator;
10
- export declare function ackMessage(context: RmqContext): void;
11
- export declare function nackMessage(context: RmqContext, requeue?: boolean): void;
7
+ export declare function assertConsumerTopology(options: RabbitConsumerOptions): Promise<void>;
8
+ export declare const OnMerkalyEvent: (...types: MerkalyEventType[]) => MethodDecorator;
12
9
  //# sourceMappingURL=rabbit.consumer.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"rabbit.consumer.d.ts","sourceRoot":"","sources":["../../src/rabbit/rabbit.consumer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,UAAU,EAAE,UAAU,EAAa,MAAM,uBAAuB,CAAC;AACxF,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAE3C,MAAM,WAAW,qBAAqB;IACpC,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,qBAAqB,GAAG,UAAU,CAWhF;AAED,eAAO,MAAM,aAAa,GAAI,SAAS,cAAc,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,oBAC/B,CAAC;AAEvC,wBAAgB,UAAU,CAAC,OAAO,EAAE,UAAU,QAI7C;AAED,wBAAgB,WAAW,CAAC,OAAO,EAAE,UAAU,EAAE,OAAO,UAAQ,QAI/D"}
1
+ {"version":3,"file":"rabbit.consumer.d.ts","sourceRoot":"","sources":["../../src/rabbit/rabbit.consumer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,UAAU,EAAa,MAAM,uBAAuB,CAAC;AAE5E,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAyC,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AAIhG,eAAO,MAAM,UAAU,GAAI,OAAO,MAAM,WAAqB,CAAC;AAE9D,eAAO,MAAM,eAAe,GAAI,OAAO,MAAM,WAAmB,CAAC;AAGjE,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,qBAAqB,GAAG,UAAU,CAuBhF;AAGD,wBAAsB,sBAAsB,CAAC,OAAO,EAAE,qBAAqB,iBAgB1E;AAGD,eAAO,MAAM,cAAc,GAAI,GAAG,OAAO,gBAAgB,EAAE,oBAAuC,CAAC"}
@@ -1,30 +1,55 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.OnRabbitEvent = void 0;
3
+ exports.OnMerkalyEvent = exports.deadLetterQueue = exports.retryQueue = void 0;
4
4
  exports.rabbitConsumerOptions = rabbitConsumerOptions;
5
- exports.ackMessage = ackMessage;
6
- exports.nackMessage = nackMessage;
5
+ exports.assertConsumerTopology = assertConsumerTopology;
7
6
  const microservices_1 = require("@nestjs/microservices");
7
+ const amqplib_1 = require("amqplib");
8
+ const rabbit_options_1 = require("./rabbit.options");
9
+ const WEEK = 7 * 24 * 60 * 60 * 1000;
10
+ const retryQueue = (queue) => `${queue}.retry`;
11
+ exports.retryQueue = retryQueue;
12
+ const deadLetterQueue = (queue) => `${queue}.dlq`;
13
+ exports.deadLetterQueue = deadLetterQueue;
8
14
  function rabbitConsumerOptions(options) {
9
15
  return {
10
16
  transport: microservices_1.Transport.RMQ,
11
17
  options: {
12
18
  urls: [options.url],
13
19
  queue: options.queue,
14
- queueOptions: { durable: true },
20
+ exchange: options.exchange ?? rabbit_options_1.MERKALY_EXCHANGE,
21
+ exchangeType: 'topic',
22
+ wildcards: true,
15
23
  noAck: false,
16
24
  prefetchCount: options.prefetchCount ?? 10,
25
+ queueOptions: {
26
+ durable: true,
27
+ arguments: {
28
+ 'x-message-ttl': WEEK,
29
+ 'x-max-length': 10_000,
30
+ 'x-overflow': 'drop-head',
31
+ 'x-dead-letter-exchange': '',
32
+ 'x-dead-letter-routing-key': (0, exports.deadLetterQueue)(options.queue),
33
+ },
34
+ },
17
35
  },
18
36
  };
19
37
  }
20
- const OnRabbitEvent = (pattern) => (0, microservices_1.EventPattern)(pattern, microservices_1.Transport.RMQ);
21
- exports.OnRabbitEvent = OnRabbitEvent;
22
- function ackMessage(context) {
23
- const channel = context.getChannelRef();
24
- channel.ack(context.getMessage());
25
- }
26
- function nackMessage(context, requeue = false) {
27
- const channel = context.getChannelRef();
28
- channel.nack(context.getMessage(), false, requeue);
38
+ async function assertConsumerTopology(options) {
39
+ const connection = await (0, amqplib_1.connect)(options.url);
40
+ const channel = await connection.createChannel();
41
+ await channel.assertQueue((0, exports.deadLetterQueue)(options.queue), { durable: true });
42
+ await channel.assertQueue((0, exports.retryQueue)(options.queue), {
43
+ durable: true,
44
+ arguments: {
45
+ 'x-message-ttl': options.retryDelay ?? rabbit_options_1.DEFAULT_RETRY_DELAY,
46
+ 'x-dead-letter-exchange': '',
47
+ 'x-dead-letter-routing-key': options.queue,
48
+ },
49
+ });
50
+ await channel.close();
51
+ await connection.close();
29
52
  }
53
+ const OnMerkalyEvent = (...types) => (0, microservices_1.EventPattern)(types, microservices_1.Transport.RMQ);
54
+ exports.OnMerkalyEvent = OnMerkalyEvent;
30
55
  //# sourceMappingURL=rabbit.consumer.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"rabbit.consumer.js","sourceRoot":"","sources":["../../src/rabbit/rabbit.consumer.ts"],"names":[],"mappings":";;;AASA,sDAWC;AAKD,gCAIC;AAED,kCAIC;AAnCD,yDAAwF;AASxF,SAAgB,qBAAqB,CAAC,OAA8B;IAClE,OAAO;QACL,SAAS,EAAE,yBAAS,CAAC,GAAG;QACxB,OAAO,EAAE;YACP,IAAI,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC;YACnB,KAAK,EAAE,OAAO,CAAC,KAAK;YACpB,YAAY,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE;YAC/B,KAAK,EAAE,KAAK;YACZ,a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AAC,GAAG,CAAC,CAAC;AAAtF,QAAA,cAAc,kBAAwE"}
@@ -1,8 +1,10 @@
1
1
  import { DynamicModule } from '@nestjs/common';
2
- import { RabbitClientFactory, RabbitModuleAsyncOptions, RabbitModuleOptions } from './rabbit.options';
3
- export declare function createRabbitClientFactory(options: RabbitModuleOptions): RabbitClientFactory | null;
2
+ import { EventsConsumerAsyncOptions, EventsConsumerOptions, RabbitClient, RabbitModuleAsyncOptions, RabbitModuleOptions } from './rabbit.options';
3
+ export declare function createRabbitClient(options: RabbitModuleOptions): RabbitClient | null;
4
4
  export declare class RabbitModule {
5
5
  static forRoot(options: RabbitModuleOptions): DynamicModule;
6
6
  static forRootAsync(options: RabbitModuleAsyncOptions): DynamicModule;
7
+ static forConsumer(options: EventsConsumerOptions): DynamicModule;
8
+ static forConsumerAsync(options: EventsConsumerAsyncOptions): DynamicModule;
7
9
  }
8
10
  //# sourceMappingURL=rabbit.module.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"rabbit.module.d.ts","sourceRoot":"","sources":["../../src/rabbit/rabbit.module.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAA4B,MAAM,gBAAgB,CAAC;AAGzE,OAAO,EAGL,mBAAmB,EACnB,wBAAwB,EACxB,mBAAmB,EACpB,MAAM,kBAAkB,CAAC;AAE1B,wBAAgB,yBAAyB,CACvC,OAAO,EAAE,mBAAmB,GAC3B,mBAAmB,GAAG,IAAI,CAc5B;AAQD,qBAEa,YAAY;IACvB,MAAM,CAAC,OAAO,CAAC,OAAO,EAAE,mBAAmB,GAAG,aAAa;IAY3D,MAAM,CAAC,YAAY,CAAC,OAAO,EAAE,wBAAwB,GAAG,aAAa;CAYtE"}
1
+ {"version":3,"file":"rabbit.module.d.ts","sourceRoot":"","sources":["../../src/rabbit/rabbit.module.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAA4B,MAAM,gBAAgB,CAAC;AAIzE,OAAO,EAEL,0BAA0B,EAC1B,qBAAqB,EAIrB,YAAY,EACZ,wBAAwB,EACxB,mBAAmB,EACpB,MAAM,kBAAkB,CAAC;AAG1B,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,mBAAmB,GAAG,YAAY,GAAG,IAAI,CAiBpF;AAQD,qBAEa,YAAY;IACvB,MAAM,CAAC,OAAO,CAAC,OAAO,EAAE,mBAAmB,GAAG,aAAa;IAQ3D,MAAM,CAAC,YAAY,CAAC,OAAO,EAAE,wBAAwB,GAAG,aAAa;IAarE,MAAM,CAAC,WAAW,CAAC,OAAO,EAAE,qBAAqB,GAAG,aAAa;IAQjE,MAAM,CAAC,gBAAgB,CAAC,OAAO,EAAE,0BAA0B,GAAG,aAAa;CAW5E"}
@@ -8,37 +8,39 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
8
8
  var RabbitModule_1;
9
9
  Object.defineProperty(exports, "__esModule", { value: true });
10
10
  exports.RabbitModule = void 0;
11
- exports.createRabbitClientFactory = createRabbitClientFactory;
11
+ exports.createRabbitClient = createRabbitClient;
12
12
  const common_1 = require("@nestjs/common");
13
13
  const microservices_1 = require("@nestjs/microservices");
14
+ const events_consumer_1 = require("./events.consumer");
14
15
  const events_publisher_1 = require("./events.publisher");
15
16
  const rabbit_options_1 = require("./rabbit.options");
16
- function createRabbitClientFactory(options) {
17
- const { url } = options;
18
- if (!url) {
17
+ function createRabbitClient(options) {
18
+ if (!options.url) {
19
19
  if (options.required)
20
20
  throw new Error('RabbitMQ url is required');
21
21
  return null;
22
22
  }
23
- return (queue) => microservices_1.ClientProxyFactory.create({
23
+ return microservices_1.ClientProxyFactory.create({
24
24
  transport: microservices_1.Transport.RMQ,
25
- options: { urls: [url], queue, queueOptions: { durable: true }, persistent: true },
25
+ options: {
26
+ urls: [options.url],
27
+ exchange: options.exchange ?? rabbit_options_1.MERKALY_EXCHANGE,
28
+ exchangeType: 'topic',
29
+ wildcards: true,
30
+ persistent: true,
31
+ },
26
32
  });
27
33
  }
28
- const clientFactoryProvider = {
29
- provide: rabbit_options_1.RABBIT_CLIENT_FACTORY,
30
- useFactory: createRabbitClientFactory,
34
+ const clientProvider = {
35
+ provide: rabbit_options_1.RABBIT_CLIENT,
36
+ useFactory: createRabbitClient,
31
37
  inject: [rabbit_options_1.RABBIT_OPTIONS],
32
38
  };
33
39
  let RabbitModule = RabbitModule_1 = class RabbitModule {
34
40
  static forRoot(options) {
35
41
  return {
36
42
  module: RabbitModule_1,
37
- providers: [
38
- { provide: rabbit_options_1.RABBIT_OPTIONS, useValue: options },
39
- clientFactoryProvider,
40
- events_publisher_1.EventsPublisher,
41
- ],
43
+ providers: [{ provide: rabbit_options_1.RABBIT_OPTIONS, useValue: options }, clientProvider, events_publisher_1.EventsPublisher],
42
44
  exports: [events_publisher_1.EventsPublisher],
43
45
  };
44
46
  }
@@ -48,12 +50,30 @@ let RabbitModule = RabbitModule_1 = class RabbitModule {
48
50
  imports: options.imports ?? [],
49
51
  providers: [
50
52
  { provide: rabbit_options_1.RABBIT_OPTIONS, useFactory: options.useFactory, inject: options.inject ?? [] },
51
- clientFactoryProvider,
53
+ clientProvider,
52
54
  events_publisher_1.EventsPublisher,
53
55
  ],
54
56
  exports: [events_publisher_1.EventsPublisher],
55
57
  };
56
58
  }
59
+ static forConsumer(options) {
60
+ return {
61
+ module: RabbitModule_1,
62
+ providers: [{ provide: rabbit_options_1.CONSUMER_OPTIONS, useValue: options }, events_consumer_1.EventsConsumer],
63
+ exports: [events_consumer_1.EventsConsumer],
64
+ };
65
+ }
66
+ static forConsumerAsync(options) {
67
+ return {
68
+ module: RabbitModule_1,
69
+ imports: options.imports ?? [],
70
+ providers: [
71
+ { provide: rabbit_options_1.CONSUMER_OPTIONS, useFactory: options.useFactory, inject: options.inject ?? [] },
72
+ events_consumer_1.EventsConsumer,
73
+ ],
74
+ exports: [events_consumer_1.EventsConsumer],
75
+ };
76
+ }
57
77
  };
58
78
  exports.RabbitModule = RabbitModule;
59
79
  exports.RabbitModule = RabbitModule = RabbitModule_1 = __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IAAA,eAAM,EAAC,EAAE,CAAC;GACE,YAAY,CAyCxB"}
@@ -1,11 +1,17 @@
1
1
  import { ModuleMetadata } from '@nestjs/common';
2
2
  import { ClientProxy } from '@nestjs/microservices';
3
+ import { MerkalyEvent, MerkalyProducer } from '../events';
3
4
  export declare const RABBIT_OPTIONS: unique symbol;
4
- export declare const RABBIT_CLIENT_FACTORY: unique symbol;
5
+ export declare const RABBIT_CLIENT: unique symbol;
6
+ export declare const CONSUMER_OPTIONS: unique symbol;
7
+ export declare const MERKALY_EXCHANGE = "merkaly.events";
8
+ export declare const DEFAULT_PUBLISH_TIMEOUT = 5000;
9
+ export declare const DEFAULT_RETRIES = 5;
10
+ export declare const DEFAULT_RETRY_DELAY = 30000;
5
11
  export interface RabbitModuleOptions {
6
12
  url?: string;
7
- queue: string;
8
- routes?: Record<string, string>;
13
+ producer: MerkalyProducer;
14
+ exchange?: string;
9
15
  timeout?: number;
10
16
  required?: boolean;
11
17
  }
@@ -13,7 +19,21 @@ export interface RabbitModuleAsyncOptions extends Pick<ModuleMetadata, 'imports'
13
19
  useFactory: (...args: any[]) => RabbitModuleOptions | Promise<RabbitModuleOptions>;
14
20
  inject?: any[];
15
21
  }
16
- export type RabbitClientFactory = (queue: string) => ClientProxy;
22
+ export interface RabbitConsumerOptions {
23
+ url: string;
24
+ queue: string;
25
+ exchange?: string;
26
+ prefetchCount?: number;
27
+ retries?: number;
28
+ retryDelay?: number;
29
+ }
30
+ export interface EventsConsumerOptions extends Pick<RabbitConsumerOptions, 'queue' | 'retries'> {
31
+ around?: (event: MerkalyEvent, next: () => Promise<unknown>) => Promise<unknown>;
32
+ }
33
+ export interface EventsConsumerAsyncOptions extends Pick<ModuleMetadata, 'imports'> {
34
+ useFactory: (...args: any[]) => EventsConsumerOptions | Promise<EventsConsumerOptions>;
35
+ inject?: any[];
36
+ }
37
+ export type RabbitClient = ClientProxy;
17
38
  export type BrokerStatus = 'disabled' | 'connecting' | 'connected' | 'disconnected';
18
- export declare const DEFAULT_PUBLISH_TIMEOUT = 5000;
19
39
  //# sourceMappingURL=rabbit.options.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"rabbit.options.d.ts","sourceRoot":"","sources":["../../src/rabbit/rabbit.options.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAEpD,eAAO,MAAM,cAAc,eAA2B,CAAC;AACvD,eAAO,MAAM,qBAAqB,eAAkC,CAAC;AAErE,MAAM,WAAW,mBAAmB;IAClC,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,WAAW,wBAAyB,SAAQ,IAAI,CAAC,cAAc,EAAE,SAAS,CAAC;IAC/E,UAAU,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,mBAAmB,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC;IACnF,MAAM,CAAC,EAAE,GAAG,EAAE,CAAC;CAChB;AAED,MAAM,MAAM,mBAAmB,GAAG,CAAC,KAAK,EAAE,MAAM,KAAK,WAAW,CAAC;AAEjE,MAAM,MAAM,YAAY,GAAG,UAAU,GAAG,YAAY,GAAG,WAAW,GAAG,cAAc,CAAC;AAEpF,eAAO,MAAM,uBAAuB,OAAO,CAAC"}
1
+ {"version":3,"file":"rabbit.options.d.ts","sourceRoot":"","sources":["../../src/rabbit/rabbit.options.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAA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EAAE,SAAS,CAAC;IACjF,UAAU,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,qBAAqB,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAAC;IACvF,MAAM,CAAC,EAAE,GAAG,EAAE,CAAC;CAChB;AAED,MAAM,MAAM,YAAY,GAAG,WAAW,CAAC;AAEvC,MAAM,MAAM,YAAY,GAAG,UAAU,GAAG,YAAY,GAAG,WAAW,GAAG,cAAc,CAAC"}
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DEFAULT_PUBLISH_TIMEOUT = exports.RABBIT_CLIENT_FACTORY = exports.RABBIT_OPTIONS = void 0;
3
+ exports.DEFAULT_RETRY_DELAY = exports.DEFAULT_RETRIES = exports.DEFAULT_PUBLISH_TIMEOUT = exports.MERKALY_EXCHANGE = exports.CONSUMER_OPTIONS = exports.RABBIT_CLIENT = exports.RABBIT_OPTIONS = void 0;
4
4
  exports.RABBIT_OPTIONS = Symbol('RABBIT_OPTIONS');
5
- exports.RABBIT_CLIENT_FACTORY = Symbol('RABBIT_CLIENT_FACTORY');
5
+ exports.RABBIT_CLIENT = Symbol('RABBIT_CLIENT');
6
+ exports.CONSUMER_OPTIONS = Symbol('CONSUMER_OPTIONS');
7
+ exports.MERKALY_EXCHANGE = 'merkaly.events';
6
8
  exports.DEFAULT_PUBLISH_TIMEOUT = 5000;
9
+ exports.DEFAULT_RETRIES = 5;
10
+ exports.DEFAULT_RETRY_DELAY = 30_000;
7
11
  //# sourceMappingURL=rabbit.options.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"rabbit.options.js","sourceRoot":"","sources":["../../src/rabbit/rabbit.options.ts"],"names":[],"mappings":";;;AAGa,QAAA,cAAc,GAAG,MAAM,CAAC,gBAAgB,CAAC,CAAC;AAC1C,QAAA,qBAAqB,GAAG,MAAM,CAAC,uBAAuB,CAAC,CAAC;AAmBxD,QAAA,uBAAuB,GAAG,IAAI,CAAC"}
1
+ {"version":3,"file":"rabbit.options.js","sourceRoot":"","sources":["../../src/rabbit/rabbit.options.ts"],"names":[],"mappings":";;;AAIa,QAAA,cAAc,GAAG,MAAM,CAAC,gBAAgB,CAAC,CAAC;AAC1C,QAAA,aAAa,GAAG,MAAM,CAAC,eAAe,CAAC,CAAC;AACxC,QAAA,gBAAgB,GAAG,MAAM,CAAC,kBAAkB,CAAC,CAAC;AAE9C,QAAA,gBAAgB,GAAG,gBAAgB,CAAC;AACpC,QAAA,uBAAuB,GAAG,IAAI,CAAC;AAC/B,QAAA,eAAe,GAAG,CAAC,CAAC;AACpB,QAAA,mBAAmB,GAAG,MAAM,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@merkaly/nest",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "description": "Shared NestJS runtime and tooling for Merkaly backend apps: pinned versions plus RabbitMQ events, logger, filters, config and signatures",
5
5
  "repository": {
6
6
  "type": "git",
@@ -1,12 +0,0 @@
1
- export type WebhookSource = 'asaas' | 'stripe' | 'auth0' | 'aliexpress';
2
- export interface WebhookEvent<T = unknown> {
3
- id: string;
4
- source: WebhookSource;
5
- type: string;
6
- receivedAt: string;
7
- organization?: string;
8
- data: T;
9
- }
10
- export declare function toPattern(source: WebhookSource, event: string): string;
11
- export declare function createWebhookEvent<T>(event: Omit<WebhookEvent<T>, 'receivedAt'>): WebhookEvent<T>;
12
- //# sourceMappingURL=webhook-event.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"webhook-event.d.ts","sourceRoot":"","sources":["../../src/events/webhook-event.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,aAAa,GAAG,OAAO,GAAG,QAAQ,GAAG,OAAO,GAAG,YAAY,CAAC;AAExE,MAAM,WAAW,YAAY,CAAC,CAAC,GAAG,OAAO;IACvC,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,aAAa,CAAC;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,IAAI,EAAE,CAAC,CAAC;CACT;AAED,wBAAgB,SAAS,CAAC,MAAM,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,UAE7D;AAED,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,YAAY,CAAC,GAAG,YAAY,CAAC,CAAC,CAAC,CAEjG"}
@@ -1,11 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.toPattern = toPattern;
4
- exports.createWebhookEvent = createWebhookEvent;
5
- function toPattern(source, event) {
6
- return `${source}.${event.toLowerCase()}`;
7
- }
8
- function createWebhookEvent(event) {
9
- return { ...event, receivedAt: new Date().toISOString() };
10
- }
11
- //# sourceMappingURL=webhook-event.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"webhook-event.js","sourceRoot":"","sources":["../../src/events/webhook-event.ts"],"names":[],"mappings":";;AAWA,8BAEC;AAED,gDAEC;AAND,SAAgB,SAAS,CAAC,MAAqB,EAAE,KAAa;IAC5D,OAAO,GAAG,MAAM,IAAI,KAAK,CAAC,WAAW,EAAE,EAAE,CAAC;AAC5C,CAAC;AAED,SAAgB,kBAAkB,CAAI,KAA0C;IAC9E,OAAO,EAAE,GAAG,KAAK,EAAE,UAAU,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,EAAE,CAAC;AAC5D,CAAC"}
@@ -1,52 +0,0 @@
1
- export declare const WebhookPatterns: {
2
- readonly asaas: {
3
- readonly PAYMENT_CREATED: "asaas.payment_created";
4
- readonly PAYMENT_AUTHORIZED: "asaas.payment_authorized";
5
- readonly PAYMENT_UPDATED: "asaas.payment_updated";
6
- readonly PAYMENT_CONFIRMED: "asaas.payment_confirmed";
7
- readonly PAYMENT_RECEIVED: "asaas.payment_received";
8
- readonly PAYMENT_OVERDUE: "asaas.payment_overdue";
9
- readonly PAYMENT_DELETED: "asaas.payment_deleted";
10
- readonly PAYMENT_REFUNDED: "asaas.payment_refunded";
11
- readonly PAYMENT_PARTIALLY_REFUNDED: "asaas.payment_partially_refunded";
12
- readonly PAYMENT_CHARGEBACK_REQUESTED: "asaas.payment_chargeback_requested";
13
- readonly PAYMENT_CHARGEBACK_DISPUTE: "asaas.payment_chargeback_dispute";
14
- readonly ACCOUNT_APPROVED: "asaas.account_status_general_approval_approved";
15
- readonly ACCOUNT_REJECTED: "asaas.account_status_general_approval_rejected";
16
- };
17
- readonly stripe: {
18
- readonly SUBSCRIPTION_CREATED: "stripe.customer.subscription.created";
19
- readonly SUBSCRIPTION_UPDATED: "stripe.customer.subscription.updated";
20
- readonly SUBSCRIPTION_DELETED: "stripe.customer.subscription.deleted";
21
- readonly INVOICE_PAID: "stripe.invoice.paid";
22
- readonly INVOICE_PAYMENT_FAILED: "stripe.invoice.payment_failed";
23
- };
24
- readonly auth0: {
25
- readonly SUCCESS_SIGNUP: "auth0.success_signup";
26
- readonly SUCCESS_LOGIN: "auth0.success_login";
27
- readonly FAILED_LOGIN: "auth0.failed_login";
28
- readonly USER_DELETED: "auth0.user_deleted";
29
- readonly BLOCKED_ACCOUNT: "auth0.blocked_account";
30
- readonly USER_LOGIN: "auth0.user_login";
31
- };
32
- readonly aliexpress: {
33
- readonly DS_ORDER_STATUS_UPDATE: "aliexpress.dropshipper_order_status_update";
34
- readonly WAYBILL_CHANGED: "aliexpress.waybill_changed";
35
- readonly PRODUCT_DELETED: "aliexpress.product_deleted";
36
- };
37
- };
38
- export declare const AliexpressOrderStatus: {
39
- readonly CREATED: "OrderCreated";
40
- readonly PAYMENT_AUTHORIZED: "PaymentAuthorized";
41
- readonly PAYMENT_FAILED: "paymentFailedEvent";
42
- readonly SHIPPED: "OrderShipped";
43
- readonly CONFIRMED: "OrderConfirmed";
44
- readonly CLOSED: "OrderClosed";
45
- };
46
- type Values<T> = T[keyof T];
47
- export type WebhookPattern = Values<{
48
- [S in keyof typeof WebhookPatterns]: Values<(typeof WebhookPatterns)[S]>;
49
- }>;
50
- export type AliexpressOrderStatus = Values<typeof AliexpressOrderStatus>;
51
- export {};
52
- //# sourceMappingURL=webhook-patterns.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"webhook-patterns.d.ts","sourceRoot":"","sources":["../../src/events/webhook-patterns.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoClB,CAAC;AAEX,eAAO,MAAM,qBAAqB;;;;;;;CAOxB,CAAC;AAEX,KAAK,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;AAE5B,MAAM,MAAM,cAAc,GAAG,MAAM,CAAC;KACjC,CAAC,IAAI,MAAM,OAAO,eAAe,GAAG,MAAM,CAAC,CAAC,OAAO,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC;CACzE,CAAC,CAAC;AAEH,MAAM,MAAM,qBAAqB,GAAG,MAAM,CAAC,OAAO,qBAAqB,CAAC,CAAC"}