sim-node-lib 0.0.52 → 0.0.55

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,5 +1,6 @@
1
1
  export declare enum PubSubTableEnum {
2
2
  agrupador = "agrupador",
3
+ autosystem_plate = "autosystem-pessoa_frota",
3
4
  bandeira = "bandeira",
4
5
  cargo = "cargo",
5
6
  cliente = "cliente",
@@ -4,6 +4,7 @@ exports.PubSubTableEnum = void 0;
4
4
  var PubSubTableEnum;
5
5
  (function (PubSubTableEnum) {
6
6
  PubSubTableEnum["agrupador"] = "agrupador";
7
+ PubSubTableEnum["autosystem_plate"] = "autosystem-pessoa_frota";
7
8
  PubSubTableEnum["bandeira"] = "bandeira";
8
9
  PubSubTableEnum["cargo"] = "cargo";
9
10
  PubSubTableEnum["cliente"] = "cliente";
@@ -7,4 +7,6 @@ export declare class AxiosService {
7
7
  post(params?: object, data?: object): Promise<AxiosResponse<any, any>>;
8
8
  put(params?: object, data?: object): Promise<AxiosResponse<any, any>>;
9
9
  delete(params?: object, data?: object): Promise<AxiosResponse<any, any>>;
10
+ byPass(method: Method, params?: object, data?: object): Promise<AxiosResponse<any, any>>;
10
11
  }
12
+ export declare type Method = 'get' | 'GET' | 'delete' | 'DELETE' | 'head' | 'HEAD' | 'options' | 'OPTIONS' | 'post' | 'POST' | 'put' | 'PUT' | 'patch' | 'PATCH' | 'purge' | 'PURGE' | 'link' | 'LINK' | 'unlink' | 'UNLINK';
@@ -95,5 +95,16 @@ class AxiosService {
95
95
  });
96
96
  });
97
97
  }
98
+ byPass(method, params, data) {
99
+ return __awaiter(this, void 0, void 0, function* () {
100
+ let content = {
101
+ method: method,
102
+ headers: headers,
103
+ params: params ? params : undefined,
104
+ data: data ? data : undefined,
105
+ };
106
+ return yield (0, axios_1.default)(this.url, content);
107
+ });
108
+ }
98
109
  }
99
110
  exports.AxiosService = AxiosService;
@@ -0,0 +1,59 @@
1
+ /// <reference types="node" />
2
+ import { EventEmitter } from 'events';
3
+ export declare class PubSubModel {
4
+ readonly value: any;
5
+ readonly action: PubSubActionEnum;
6
+ readonly table: PubSubTableEnum;
7
+ constructor(value: object, action: PubSubActionEnum, table: PubSubTableEnum);
8
+ }
9
+ export declare class GooglePubSubSubscription {
10
+ constructor(subscriptionName: string);
11
+ private _subscription;
12
+ listenMessages(eventEmitter: EventEmitter): Promise<void>;
13
+ }
14
+ export declare class GooglePubSubPublish {
15
+ constructor(topicName: string);
16
+ private _topicName;
17
+ createMessages(message: object, action: PubSubActionEnum, table: PubSubTableEnum): Promise<void>;
18
+ }
19
+ export declare abstract class PubSubHandelerAction {
20
+ constructor(pubsubModel: PubSubModel);
21
+ protected _pubsubValueModel: PubSubModel;
22
+ handlerAction(): Promise<boolean>;
23
+ protected insert(): Promise<boolean>;
24
+ protected update(): Promise<boolean>;
25
+ protected remove(): Promise<boolean>;
26
+ protected buildData(): Object;
27
+ }
28
+ export declare enum PubSubActionEnum {
29
+ insert = "insert",
30
+ update = "update",
31
+ remove = "remove"
32
+ }
33
+ export declare enum PubSubTableEnum {
34
+ bandeira = 0,
35
+ cliente = 1,
36
+ clienteEndereco = 2,
37
+ clientePendente = 3,
38
+ configuracao = 4,
39
+ empresa = 5,
40
+ empresaHorario = 6,
41
+ empresaServico = 7,
42
+ grupoDesconto = 8,
43
+ grupoDescontoLimite = 9,
44
+ grupoEmpresa = 10,
45
+ item = 11,
46
+ itemTag = 12,
47
+ promocao = 13,
48
+ promocaoEmpresa = 14,
49
+ promocaoGrupoDesconto = 15,
50
+ promocaoItem = 16,
51
+ promocaoRecorrencia = 17,
52
+ promocaoTag = 18,
53
+ servico = 19,
54
+ tag = 20,
55
+ voucherDesconto = 21,
56
+ voucherDescontoLote = 22,
57
+ voucherMigracao = 23,
58
+ voucherMigracaoLote = 24
59
+ }
@@ -0,0 +1,121 @@
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
+ const pubsub_1 = require("@google-cloud/pubsub");
13
+ class PubSubModel {
14
+ constructor(value, action, table) {
15
+ this.value = value;
16
+ this.action = action;
17
+ this.table = table;
18
+ }
19
+ }
20
+ exports.PubSubModel = PubSubModel;
21
+ class GooglePubSubSubscription {
22
+ constructor(subscriptionName) {
23
+ this._subscription = new pubsub_1.PubSub().subscription(subscriptionName);
24
+ }
25
+ listenMessages(eventEmitter) {
26
+ return __awaiter(this, void 0, void 0, function* () {
27
+ this._subscription.on('message', (message) => {
28
+ const data = JSON.parse(message.data.toString());
29
+ const pubSubModel = new PubSubModel(data.value, data.action, data.table);
30
+ eventEmitter.emit('event', [pubSubModel, message]);
31
+ });
32
+ this._subscription.on('error', (error) => {
33
+ console.error('Received error:', error);
34
+ eventEmitter.emit('error', error);
35
+ });
36
+ });
37
+ }
38
+ }
39
+ exports.GooglePubSubSubscription = GooglePubSubSubscription;
40
+ class GooglePubSubPublish {
41
+ constructor(topicName) {
42
+ this._topicName = topicName;
43
+ }
44
+ createMessages(message, action, table) {
45
+ return __awaiter(this, void 0, void 0, function* () {
46
+ const pubSubClient = new pubsub_1.PubSub();
47
+ const send = new PubSubModel(message, action, table);
48
+ const topic = pubSubClient.topic(this._topicName);
49
+ const dataSend = JSON.stringify(send);
50
+ const data = Buffer.from(dataSend);
51
+ yield topic.publishMessage({ data });
52
+ });
53
+ }
54
+ }
55
+ exports.GooglePubSubPublish = GooglePubSubPublish;
56
+ class PubSubHandelerAction {
57
+ constructor(pubsubModel) {
58
+ this._pubsubValueModel = pubsubModel;
59
+ }
60
+ handlerAction() {
61
+ return __awaiter(this, void 0, void 0, function* () {
62
+ switch (this._pubsubValueModel.action) {
63
+ case 'insert':
64
+ return yield this.insert();
65
+ case 'update':
66
+ return yield this.update();
67
+ case 'remove':
68
+ return yield this.remove();
69
+ default:
70
+ throw new Error('PubSub handler action not implemented.');
71
+ }
72
+ });
73
+ }
74
+ insert() {
75
+ throw new Error('Method insert PubSub handler action not implemented.');
76
+ }
77
+ update() {
78
+ throw new Error('Method update PubSub handler action not implemented.');
79
+ }
80
+ remove() {
81
+ throw new Error('Method remove PubSub handler action not implemented.');
82
+ }
83
+ buildData() {
84
+ throw new Error('Method buildData PubSub handler action not implemented.');
85
+ }
86
+ }
87
+ exports.PubSubHandelerAction = PubSubHandelerAction;
88
+ var PubSubActionEnum;
89
+ (function (PubSubActionEnum) {
90
+ PubSubActionEnum["insert"] = "insert";
91
+ PubSubActionEnum["update"] = "update";
92
+ PubSubActionEnum["remove"] = "remove";
93
+ })(PubSubActionEnum = exports.PubSubActionEnum || (exports.PubSubActionEnum = {}));
94
+ var PubSubTableEnum;
95
+ (function (PubSubTableEnum) {
96
+ PubSubTableEnum[PubSubTableEnum["bandeira"] = 0] = "bandeira";
97
+ PubSubTableEnum[PubSubTableEnum["cliente"] = 1] = "cliente";
98
+ PubSubTableEnum[PubSubTableEnum["clienteEndereco"] = 2] = "clienteEndereco";
99
+ PubSubTableEnum[PubSubTableEnum["clientePendente"] = 3] = "clientePendente";
100
+ PubSubTableEnum[PubSubTableEnum["configuracao"] = 4] = "configuracao";
101
+ PubSubTableEnum[PubSubTableEnum["empresa"] = 5] = "empresa";
102
+ PubSubTableEnum[PubSubTableEnum["empresaHorario"] = 6] = "empresaHorario";
103
+ PubSubTableEnum[PubSubTableEnum["empresaServico"] = 7] = "empresaServico";
104
+ PubSubTableEnum[PubSubTableEnum["grupoDesconto"] = 8] = "grupoDesconto";
105
+ PubSubTableEnum[PubSubTableEnum["grupoDescontoLimite"] = 9] = "grupoDescontoLimite";
106
+ PubSubTableEnum[PubSubTableEnum["grupoEmpresa"] = 10] = "grupoEmpresa";
107
+ PubSubTableEnum[PubSubTableEnum["item"] = 11] = "item";
108
+ PubSubTableEnum[PubSubTableEnum["itemTag"] = 12] = "itemTag";
109
+ PubSubTableEnum[PubSubTableEnum["promocao"] = 13] = "promocao";
110
+ PubSubTableEnum[PubSubTableEnum["promocaoEmpresa"] = 14] = "promocaoEmpresa";
111
+ PubSubTableEnum[PubSubTableEnum["promocaoGrupoDesconto"] = 15] = "promocaoGrupoDesconto";
112
+ PubSubTableEnum[PubSubTableEnum["promocaoItem"] = 16] = "promocaoItem";
113
+ PubSubTableEnum[PubSubTableEnum["promocaoRecorrencia"] = 17] = "promocaoRecorrencia";
114
+ PubSubTableEnum[PubSubTableEnum["promocaoTag"] = 18] = "promocaoTag";
115
+ PubSubTableEnum[PubSubTableEnum["servico"] = 19] = "servico";
116
+ PubSubTableEnum[PubSubTableEnum["tag"] = 20] = "tag";
117
+ PubSubTableEnum[PubSubTableEnum["voucherDesconto"] = 21] = "voucherDesconto";
118
+ PubSubTableEnum[PubSubTableEnum["voucherDescontoLote"] = 22] = "voucherDescontoLote";
119
+ PubSubTableEnum[PubSubTableEnum["voucherMigracao"] = 23] = "voucherMigracao";
120
+ PubSubTableEnum[PubSubTableEnum["voucherMigracaoLote"] = 24] = "voucherMigracaoLote";
121
+ })(PubSubTableEnum = exports.PubSubTableEnum || (exports.PubSubTableEnum = {}));
@@ -0,0 +1,2 @@
1
+ export declare function sayHello(): void;
2
+ export declare function sayGoodbye(): void;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ require("dotenv").config();
4
+ function sayHello() {
5
+ console.log("hi my friend, the NODE PORT is: ", process.env.PORT);
6
+ }
7
+ exports.sayHello = sayHello;
8
+ function sayGoodbye() {
9
+ console.log("goodbye");
10
+ }
11
+ exports.sayGoodbye = sayGoodbye;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sim-node-lib",
3
- "version": "0.0.52",
3
+ "version": "0.0.55",
4
4
  "description": "Library from SIMLabs",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",