sim-node-lib 0.0.108 → 0.0.110

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.
@@ -0,0 +1,7 @@
1
+ import { PubSubActionEnum } from '../../Enums/PubSubActionEnum';
2
+ import { PubSubTableEnum } from '../../Enums/PubSubTableEnum';
3
+ export declare class GooglePubSubPublish {
4
+ constructor(topicName: string);
5
+ private _topicName;
6
+ createMessages<T>(message: T, action: PubSubActionEnum, table: PubSubTableEnum): Promise<void>;
7
+ }
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.GooglePubSubPublish = void 0;
13
+ const pubsub_1 = require("@google-cloud/pubsub");
14
+ const PubSubModel_1 = require("../../Models/v2/PubSubModel");
15
+ class GooglePubSubPublish {
16
+ constructor(topicName) {
17
+ this._topicName = topicName;
18
+ }
19
+ createMessages(message, action, table) {
20
+ return __awaiter(this, void 0, void 0, function* () {
21
+ const pubSubClient = new pubsub_1.PubSub();
22
+ const send = new PubSubModel_1.PubSubModel(message, action, table);
23
+ const topic = pubSubClient.topic(this._topicName);
24
+ const dataSend = JSON.stringify(send);
25
+ const data = Buffer.from(dataSend);
26
+ yield topic.publishMessage({ data });
27
+ });
28
+ }
29
+ }
30
+ exports.GooglePubSubPublish = GooglePubSubPublish;
@@ -52,6 +52,7 @@ export declare enum PubSubTableEnum {
52
52
  tipoPremiacao = "tipo_premiacao",
53
53
  voucherDesconto = "voucher_desconto",
54
54
  voucherDescontoLote = "voucher_desconto_lote",
55
+ voucherIndividual = "voucher_individual",
55
56
  voucherMigracao = "voucher_migracao",
56
57
  voucherMigracaoLote = "voucher_migracao_lote"
57
58
  }
@@ -56,6 +56,7 @@ var PubSubTableEnum;
56
56
  PubSubTableEnum["tipoPremiacao"] = "tipo_premiacao";
57
57
  PubSubTableEnum["voucherDesconto"] = "voucher_desconto";
58
58
  PubSubTableEnum["voucherDescontoLote"] = "voucher_desconto_lote";
59
+ PubSubTableEnum["voucherIndividual"] = "voucher_individual";
59
60
  PubSubTableEnum["voucherMigracao"] = "voucher_migracao";
60
61
  PubSubTableEnum["voucherMigracaoLote"] = "voucher_migracao_lote";
61
62
  })(PubSubTableEnum = exports.PubSubTableEnum || (exports.PubSubTableEnum = {}));
@@ -0,0 +1,13 @@
1
+ import { PubSubModel } from '../../Models/v2/PubSubModel';
2
+ export declare abstract class PubSubHandlerAction<T> {
3
+ constructor(pubsubModel: PubSubModel<T>);
4
+ protected _pubsubValueModel: PubSubModel<T>;
5
+ handlerAction(): Promise<boolean>;
6
+ protected insert(): Promise<boolean>;
7
+ protected insertMany(): Promise<boolean>;
8
+ protected update(): Promise<boolean>;
9
+ protected updateMany(): Promise<boolean>;
10
+ protected delete(): Promise<boolean>;
11
+ protected deleteMany(): Promise<boolean>;
12
+ protected buildData(): Object;
13
+ }
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.PubSubHandlerAction = void 0;
13
+ class PubSubHandlerAction {
14
+ constructor(pubsubModel) {
15
+ this._pubsubValueModel = pubsubModel;
16
+ }
17
+ handlerAction() {
18
+ return __awaiter(this, void 0, void 0, function* () {
19
+ switch (this._pubsubValueModel.action) {
20
+ case 'insert':
21
+ return yield this.insert();
22
+ case 'insert_many':
23
+ return yield this.insertMany();
24
+ case 'update':
25
+ return yield this.update();
26
+ case 'update_many':
27
+ return yield this.updateMany();
28
+ case 'delete':
29
+ return yield this.delete();
30
+ case 'delete_many':
31
+ return yield this.deleteMany();
32
+ default:
33
+ return true;
34
+ }
35
+ });
36
+ }
37
+ insert() {
38
+ throw new Error('Method insert PubSub handler action not implemented.');
39
+ }
40
+ insertMany() {
41
+ throw new Error('Method insertMany PubSub handler action not implemented.');
42
+ }
43
+ update() {
44
+ throw new Error('Method update PubSub handler action not implemented.');
45
+ }
46
+ updateMany() {
47
+ throw new Error('Method updateMany PubSub handler action not implemented.');
48
+ }
49
+ delete() {
50
+ throw new Error('Method delete PubSub handler action not implemented.');
51
+ }
52
+ deleteMany() {
53
+ throw new Error('Method deleteMany PubSub handler action not implemented.');
54
+ }
55
+ buildData() {
56
+ throw new Error('Method buildData PubSub handler action not implemented.');
57
+ }
58
+ }
59
+ exports.PubSubHandlerAction = PubSubHandlerAction;
@@ -56,19 +56,19 @@ class HtmlBadgerHelper {
56
56
  return this.getHTMLPill('badge-info', `Forma Pagamento ${operacao} ${descriptionList.join(', ')}`);
57
57
  }
58
58
  static getTextoOperacao(operacao) {
59
- let resultado = operacao;
59
+ let resultado;
60
60
  switch (operacao) {
61
61
  case '=':
62
- operacao = 'igual a';
62
+ resultado = 'igual a';
63
63
  break;
64
64
  case '<>':
65
- operacao = 'diferente de';
65
+ resultado = 'diferente de';
66
66
  break;
67
67
  case 'contem':
68
- operacao = 'for uma das opções:';
68
+ resultado = 'for uma das opções:';
69
69
  break;
70
70
  default:
71
- operacao = 'ERROR';
71
+ resultado = 'ERROR';
72
72
  }
73
73
  return resultado;
74
74
  }
@@ -0,0 +1,8 @@
1
+ import { PubSubActionEnum } from '../../Enums/PubSubActionEnum';
2
+ import { PubSubTableEnum } from '../../Enums/PubSubTableEnum';
3
+ export declare class PubSubModel<T> {
4
+ readonly value: T;
5
+ readonly action: PubSubActionEnum;
6
+ readonly table: PubSubTableEnum;
7
+ constructor(value: T, action: PubSubActionEnum, table: PubSubTableEnum);
8
+ }
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PubSubModel = void 0;
4
+ class PubSubModel {
5
+ constructor(value, action, table) {
6
+ this.value = value;
7
+ this.action = action;
8
+ this.table = table;
9
+ }
10
+ }
11
+ exports.PubSubModel = PubSubModel;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sim-node-lib",
3
- "version": "0.0.108",
3
+ "version": "0.0.110",
4
4
  "description": "Library from SIMLabs",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",