@omegasolutions/vallora-log-sdk 1.0.0

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.
package/README.md ADDED
@@ -0,0 +1,29 @@
1
+ # README #
2
+
3
+ This README would normally document whatever steps are necessary to get your application up and running.
4
+
5
+ ### What is this repository for? ###
6
+
7
+ * Quick summary
8
+ * Version
9
+ * [Learn Markdown](https://bitbucket.org/tutorials/markdowndemo)
10
+
11
+ ### How do I get set up? ###
12
+
13
+ * Summary of set up
14
+ * Configuration
15
+ * Dependencies
16
+ * Database configuration
17
+ * How to run tests
18
+ * Deployment instructions
19
+
20
+ ### Contribution guidelines ###
21
+
22
+ * Writing tests
23
+ * Code review
24
+ * Other guidelines
25
+
26
+ ### Who do I talk to? ###
27
+
28
+ * Repo owner or admin
29
+ * Other community or team contact
@@ -0,0 +1,2 @@
1
+ export * from './log-client';
2
+ export * from './types';
package/dist/index.js ADDED
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./log-client"), exports);
18
+ __exportStar(require("./types"), exports);
@@ -0,0 +1,10 @@
1
+ import { TransactionLogPayload } from './types';
2
+ export declare class LogClient {
3
+ private pubsub;
4
+ private topicName;
5
+ constructor(projectId?: string, topicName?: string);
6
+ /**
7
+ * Publishes a log message to the transaction-log-topic
8
+ */
9
+ publishLog(payload: Omit<TransactionLogPayload, 'idMessage' | 'createdAt' | 'updatedAt'>): Promise<string>;
10
+ }
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LogClient = void 0;
4
+ const pubsub_1 = require("@google-cloud/pubsub");
5
+ const uuid_1 = require("uuid");
6
+ class LogClient {
7
+ constructor(projectId, topicName = 'transaction-log-topic') {
8
+ this.pubsub = new pubsub_1.PubSub({ projectId });
9
+ this.topicName = topicName;
10
+ }
11
+ /**
12
+ * Publishes a log message to the transaction-log-topic
13
+ */
14
+ async publishLog(payload) {
15
+ const message = {
16
+ ...payload,
17
+ idMessage: (0, uuid_1.v4)(),
18
+ createdAt: new Date().toISOString(),
19
+ updatedAt: new Date().toISOString(),
20
+ };
21
+ const buffer = Buffer.from(JSON.stringify(message));
22
+ const messageId = await this.pubsub.topic(this.topicName).publish(buffer);
23
+ console.log(`Published message ${messageId} to ${this.topicName}`);
24
+ return messageId;
25
+ }
26
+ }
27
+ exports.LogClient = LogClient;
@@ -0,0 +1,20 @@
1
+ export declare enum ServiceType {
2
+ SEND_TO_PAYMENT = "SEND_TO_PAYMENT",
3
+ EDI_SIRIUS = "EDI_SIRIUS",
4
+ FTP_OSGT = "FTP_OSGT",
5
+ CALC_SERVICE = "CALC_SERVICE",
6
+ CCT = "CCT",
7
+ FINANCIAL_V2 = "FINANCIAL_V2",
8
+ UPLOAD_INVOICE = "UPLOAD_INVOICE",
9
+ UPDLOAD_PO = "UPDLOAD_PO",
10
+ PO_MNGMT = "PO_MNGMT"
11
+ }
12
+ export interface TransactionLogPayload {
13
+ idMessage: string;
14
+ idService: ServiceType;
15
+ idUser: string;
16
+ inputPayload: object;
17
+ outputPayload?: object;
18
+ updatedAt?: string;
19
+ createdAt?: string;
20
+ }
package/dist/types.js ADDED
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ServiceType = void 0;
4
+ var ServiceType;
5
+ (function (ServiceType) {
6
+ ServiceType["SEND_TO_PAYMENT"] = "SEND_TO_PAYMENT";
7
+ ServiceType["EDI_SIRIUS"] = "EDI_SIRIUS";
8
+ ServiceType["FTP_OSGT"] = "FTP_OSGT";
9
+ ServiceType["CALC_SERVICE"] = "CALC_SERVICE";
10
+ ServiceType["CCT"] = "CCT";
11
+ ServiceType["FINANCIAL_V2"] = "FINANCIAL_V2";
12
+ ServiceType["UPLOAD_INVOICE"] = "UPLOAD_INVOICE";
13
+ ServiceType["UPDLOAD_PO"] = "UPDLOAD_PO";
14
+ ServiceType["PO_MNGMT"] = "PO_MNGMT";
15
+ })(ServiceType || (exports.ServiceType = ServiceType = {}));
package/package.json ADDED
@@ -0,0 +1,26 @@
1
+ {
2
+ "name": "@omegasolutions/vallora-log-sdk",
3
+ "version": "1.0.0",
4
+ "description": "A lightweight SDK for publishing transaction log events to Google Pub/Sub",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "files": ["dist"],
8
+ "scripts": {
9
+ "build": "tsc",
10
+ "prepublishOnly": "npm run build"
11
+ },
12
+ "keywords": ["nestjs", "pubsub", "sdk", "google-cloud", "logging"],
13
+ "author": "Your Name <rogerio.benetti@omegasolutions.com.br>",
14
+ "license": "MIT",
15
+ "repository": {
16
+ "type": "git",
17
+ "url": "git clone https://rogeriobenetti@bitbucket.org/omegasolutionssp/vallora-back-log-registry-sdk.git"
18
+ },
19
+ "dependencies": {
20
+ "@google-cloud/pubsub": "^4.0.0",
21
+ "uuid": "^9.0.0"
22
+ },
23
+ "devDependencies": {
24
+ "typescript": "^5.0.0"
25
+ }
26
+ }