@hahnpro/flow-sdk 4.24.0 → 4.24.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.
@@ -1,9 +1,9 @@
1
1
  import 'reflect-metadata';
2
2
  import { API } from '@hahnpro/hpc-api';
3
+ import { ConsumeMessage } from 'amqplib';
3
4
  import { AmqpConnectionManager } from 'amqp-connection-manager';
4
- import { CloudEvent } from 'cloudevents';
5
5
  import { PartialObserver } from 'rxjs';
6
- import { AmqpConnection, AmqpConnectionConfig, Nack } from './amqp';
6
+ import { AmqpConnection, AmqpConnectionConfig } from './amqp';
7
7
  import { ClassType, Flow, FlowElementContext } from './flow.interface';
8
8
  import { FlowEvent } from './FlowEvent';
9
9
  import { Logger } from './FlowLogger';
@@ -45,7 +45,7 @@ export declare class FlowApplication {
45
45
  emit: (event: FlowEvent) => void;
46
46
  emitPartial: (completeEvent: FlowEvent, partialEvent: FlowEvent) => void;
47
47
  getProperties(): Record<string, any>;
48
- onMessage: (event: CloudEvent<any>) => Promise<Nack | undefined>;
48
+ onMessage: (msg: ConsumeMessage) => Promise<void>;
49
49
  /**
50
50
  * Publish a flow event to the amqp flowlogs exchange.
51
51
  * If the event size exceeds the limit it will be truncated
@@ -99,13 +99,22 @@ class FlowApplication {
99
99
  this.logger.error(err);
100
100
  }
101
101
  };
102
- this.onMessage = async (event) => {
102
+ this.onMessage = async (msg) => {
103
103
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
104
+ let event;
105
+ try {
106
+ event = JSON.parse(msg.content.toString());
107
+ }
108
+ catch (err) {
109
+ this.logger.error(err);
110
+ return;
111
+ }
104
112
  if (event.type === 'com.flowstudio.deployment.update') {
105
113
  try {
106
114
  const flow = event.data;
107
115
  if (!flow) {
108
- return new amqp_1.Nack(false);
116
+ this.amqpChannel.nack(msg, false, false);
117
+ return;
109
118
  }
110
119
  let context = {};
111
120
  if (flow.context) {
@@ -174,9 +183,8 @@ class FlowApplication {
174
183
  this.destroy();
175
184
  }
176
185
  else {
177
- return new amqp_1.Nack(false);
186
+ this.amqpChannel.nack(msg, false, false);
178
187
  }
179
- return undefined;
180
188
  };
181
189
  this.publishEvent = (event) => {
182
190
  if (!this.amqpChannel) {
package/dist/amqp.d.ts CHANGED
@@ -12,8 +12,3 @@ export interface AmqpConnectionConfig {
12
12
  port?: number;
13
13
  }
14
14
  export declare function createAmqpConnection(config: AmqpConnectionConfig): AmqpConnectionManager;
15
- export declare class Nack {
16
- private readonly _requeue;
17
- constructor(_requeue?: boolean);
18
- get requeue(): boolean;
19
- }
package/dist/amqp.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Nack = exports.createAmqpConnection = void 0;
3
+ exports.createAmqpConnection = void 0;
4
4
  const amqp_connection_manager_1 = require("amqp-connection-manager");
5
5
  function createAmqpConnection(config) {
6
6
  if (!config) {
@@ -11,12 +11,3 @@ function createAmqpConnection(config) {
11
11
  return (0, amqp_connection_manager_1.connect)(uri);
12
12
  }
13
13
  exports.createAmqpConnection = createAmqpConnection;
14
- class Nack {
15
- constructor(_requeue = false) {
16
- this._requeue = _requeue;
17
- }
18
- get requeue() {
19
- return this._requeue;
20
- }
21
- }
22
- exports.Nack = Nack;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hahnpro/flow-sdk",
3
- "version": "4.24.0",
3
+ "version": "4.24.1",
4
4
  "description": "SDK for building Flow Modules",
5
5
  "license": "MIT",
6
6
  "author": {