sim-node-lib 0.0.12 → 0.0.15

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.
@@ -4,7 +4,7 @@ export declare class PubSubModel {
4
4
  readonly value: object;
5
5
  readonly action: string;
6
6
  readonly table: string;
7
- constructor(value: object, action: PubSubActionEnum, table: string);
7
+ constructor(value: object, action: PubSubActionEnum, table: PubSubTableEnum);
8
8
  }
9
9
  export declare class GooglePubSubSubscription {
10
10
  constructor(subscriptionName: string);
@@ -14,15 +14,15 @@ export declare class GooglePubSubSubscription {
14
14
  export declare class GooglePubSubPublish {
15
15
  constructor(topicName: string);
16
16
  private _topicName;
17
- createMessages(message: object, action: PubSubActionEnum, table: string): Promise<void>;
17
+ createMessages(message: object, action: PubSubActionEnum, table: PubSubTableEnum): Promise<void>;
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 {
@@ -30,3 +30,6 @@ export declare enum PubSubActionEnum {
30
30
  update = "update",
31
31
  remove = "remove"
32
32
  }
33
+ export declare enum PubSubTableEnum {
34
+ documentoDigital = "documentoDigital"
35
+ }
@@ -14,7 +14,7 @@ class PubSubModel {
14
14
  constructor(value, action, table) {
15
15
  this.value = value;
16
16
  this.action = action.toString();
17
- this.table = table;
17
+ this.table = table.toString();
18
18
  }
19
19
  }
20
20
  exports.PubSubModel = PubSubModel;
@@ -33,7 +33,6 @@ class GooglePubSubSubscription {
33
33
  catch (error) {
34
34
  console.error(error);
35
35
  eventEmitter.emit('error', error);
36
- message.ack();
37
36
  }
38
37
  });
39
38
  // Receive callbacks for errors on the subscription
@@ -55,7 +54,6 @@ class GooglePubSubPublish {
55
54
  const send = new PubSubModel(message, action, table);
56
55
  // Creates a new topic
57
56
  const topic = pubSubClient.topic(this._topicName);
58
- console.log(`Topic ${topic.name} created.`);
59
57
  const dataSend = JSON.stringify(send);
60
58
  //Create message
61
59
  const data = Buffer.from(dataSend);
@@ -67,23 +65,18 @@ class GooglePubSubPublish {
67
65
  exports.GooglePubSubPublish = GooglePubSubPublish;
68
66
  class PubSubHandelerAction {
69
67
  constructor(pubsubModel) {
70
- this._pubsubValueModel = pubsubModel.value;
71
- this.handlerAction(pubsubModel.action);
68
+ this._pubsubValueModel = pubsubModel;
72
69
  }
73
- handlerAction(action) {
74
- switch (action) {
70
+ handlerAction() {
71
+ switch (this._pubsubValueModel.action) {
75
72
  case 'insert':
76
- this.insert();
77
- break;
73
+ return this.insert();
78
74
  case 'update':
79
- this.update();
80
- break;
75
+ return this.update();
81
76
  case 'delete':
82
- this.remove();
83
- break;
77
+ return this.remove();
84
78
  default:
85
- this.insert();
86
- //throw new Error('PubSub handler action not implemented.')
79
+ throw new Error('PubSub handler action not implemented.');
87
80
  }
88
81
  }
89
82
  insert() {
@@ -106,3 +99,7 @@ var PubSubActionEnum;
106
99
  PubSubActionEnum["update"] = "update";
107
100
  PubSubActionEnum["remove"] = "remove";
108
101
  })(PubSubActionEnum = exports.PubSubActionEnum || (exports.PubSubActionEnum = {}));
102
+ var PubSubTableEnum;
103
+ (function (PubSubTableEnum) {
104
+ PubSubTableEnum["documentoDigital"] = "documentoDigital";
105
+ })(PubSubTableEnum = exports.PubSubTableEnum || (exports.PubSubTableEnum = {}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sim-node-lib",
3
- "version": "0.0.12",
3
+ "version": "0.0.15",
4
4
  "description": "Library from SIMLabs",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",