sim-node-lib 0.0.13 → 0.0.16

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.
@@ -18,11 +18,11 @@ export declare class GooglePubSubPublish {
18
18
  }
19
19
  export declare abstract class PubSubHandelerAction {
20
20
  constructor(pubsubModel: PubSubModel);
21
- protected _pubsubValueModel: any;
22
- protected handlerAction(action: string): void;
23
- protected insert(): void;
24
- protected update(): void;
25
- protected remove(): void;
21
+ protected _pubsubValueModel: PubSubModel;
22
+ handlerAction(): boolean;
23
+ protected insert(): boolean;
24
+ protected update(): boolean;
25
+ protected remove(): boolean;
26
26
  protected buildData(): Object;
27
27
  }
28
28
  export declare enum PubSubActionEnum {
@@ -28,7 +28,7 @@ class GooglePubSubSubscription {
28
28
  try {
29
29
  const data = JSON.parse(message.data.toString());
30
30
  const pubSubModel = new PubSubModel(data.value, data.action, data.table);
31
- eventEmitter.emit('event', [pubSubModel, message]);
31
+ eventEmitter.emit('event', pubSubModel);
32
32
  }
33
33
  catch (error) {
34
34
  console.error(error);
@@ -55,7 +55,6 @@ class GooglePubSubPublish {
55
55
  const send = new PubSubModel(message, action, table);
56
56
  // Creates a new topic
57
57
  const topic = pubSubClient.topic(this._topicName);
58
- console.log(`Topic ${topic.name} created.`);
59
58
  const dataSend = JSON.stringify(send);
60
59
  //Create message
61
60
  const data = Buffer.from(dataSend);
@@ -67,23 +66,18 @@ class GooglePubSubPublish {
67
66
  exports.GooglePubSubPublish = GooglePubSubPublish;
68
67
  class PubSubHandelerAction {
69
68
  constructor(pubsubModel) {
70
- this._pubsubValueModel = pubsubModel.value;
71
- this.handlerAction(pubsubModel.action);
69
+ this._pubsubValueModel = pubsubModel;
72
70
  }
73
- handlerAction(action) {
74
- switch (action) {
71
+ handlerAction() {
72
+ switch (this._pubsubValueModel.action) {
75
73
  case 'insert':
76
- this.insert();
77
- break;
74
+ return this.insert();
78
75
  case 'update':
79
- this.update();
80
- break;
76
+ return this.update();
81
77
  case 'delete':
82
- this.remove();
83
- break;
78
+ return this.remove();
84
79
  default:
85
- this.insert();
86
- //throw new Error('PubSub handler action not implemented.')
80
+ throw new Error('PubSub handler action not implemented.');
87
81
  }
88
82
  }
89
83
  insert() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sim-node-lib",
3
- "version": "0.0.13",
3
+ "version": "0.0.16",
4
4
  "description": "Library from SIMLabs",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",