@fiado/api-invoker 1.0.62 → 1.0.64
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/bin/container.config.js +2 -0
- package/bin/index.d.ts +1 -0
- package/bin/index.js +1 -0
- package/bin/transaction/index.d.ts +2 -0
- package/bin/transaction/index.js +18 -0
- package/bin/transaction/queue/TransactionPublisher.d.ts +6 -0
- package/bin/transaction/queue/TransactionPublisher.js +34 -0
- package/bin/transaction/queue/interfaces/ITransactionPublisher.d.ts +4 -0
- package/bin/transaction/queue/interfaces/ITransactionPublisher.js +2 -0
- package/package.json +2 -2
- package/src/container.config.ts +3 -0
- package/src/index.ts +2 -1
- package/src/transaction/index.ts +2 -0
- package/src/transaction/queue/TransactionPublisher.ts +23 -0
- package/src/transaction/queue/interfaces/ITransactionPublisher.ts +5 -0
package/bin/container.config.js
CHANGED
|
@@ -19,6 +19,7 @@ const sessionActivity_1 = require("./sessionActivity");
|
|
|
19
19
|
const ExchangeRatesApi_1 = __importDefault(require("./exchangeRates/ExchangeRatesApi"));
|
|
20
20
|
const authentication_1 = require("./authentication");
|
|
21
21
|
const card_1 = require("./card");
|
|
22
|
+
const TransactionPublisher_1 = require("./transaction/queue/TransactionPublisher");
|
|
22
23
|
exports.apiInvokerBindings = new inversify_1.ContainerModule((bind) => {
|
|
23
24
|
bind("IDirectoryApi").to(directory_1.DirectoryApi);
|
|
24
25
|
bind("IIdentityApi").to(identity_1.IdentityApi);
|
|
@@ -32,6 +33,7 @@ exports.apiInvokerBindings = new inversify_1.ContainerModule((bind) => {
|
|
|
32
33
|
bind("IAccountFiadoSAApi").to(AccountFiadoSAApi_1.default);
|
|
33
34
|
bind("INotificationMessagesPublisher").to(NotificationMessagePublisher_1.default);
|
|
34
35
|
bind("ISessionActivityPublisher").to(sessionActivity_1.SessionActivityPublisher);
|
|
36
|
+
bind("ITransactionPublisher").to(TransactionPublisher_1.TransactionPublisher);
|
|
35
37
|
bind("IAuthenticationApi").to(authentication_1.AuthenticationApi);
|
|
36
38
|
bind("ICardApi").to(card_1.CardApi);
|
|
37
39
|
});
|
package/bin/index.d.ts
CHANGED
package/bin/index.js
CHANGED
|
@@ -28,3 +28,4 @@ __exportStar(require("./account-fiadosa"), exports);
|
|
|
28
28
|
__exportStar(require("./account-pagoconfiado"), exports);
|
|
29
29
|
__exportStar(require("./exchangeRates"), exports);
|
|
30
30
|
__exportStar(require("./authentication"), exports);
|
|
31
|
+
__exportStar(require("./transaction"), exports);
|
|
@@ -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("./queue/TransactionPublisher"), exports);
|
|
18
|
+
__exportStar(require("./queue/interfaces/ITransactionPublisher"), exports);
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ITransactionPublisher } from "./interfaces/ITransactionPublisher";
|
|
2
|
+
import { TransactionCreateRequest } from "@fiado/type-kit/bin/transaction";
|
|
3
|
+
export declare class TransactionPublisher implements ITransactionPublisher {
|
|
4
|
+
private readonly TRANSACTION_QUEUE;
|
|
5
|
+
publish(message: TransactionCreateRequest): Promise<void>;
|
|
6
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.TransactionPublisher = void 0;
|
|
10
|
+
const client_sqs_1 = require("@aws-sdk/client-sqs");
|
|
11
|
+
const inversify_1 = require("inversify");
|
|
12
|
+
let TransactionPublisher = class TransactionPublisher {
|
|
13
|
+
constructor() {
|
|
14
|
+
this.TRANSACTION_QUEUE = process.env.TRANSACTION_QUEUE;
|
|
15
|
+
}
|
|
16
|
+
async publish(message) {
|
|
17
|
+
try {
|
|
18
|
+
const client = new client_sqs_1.SQSClient();
|
|
19
|
+
const sendMessageRequest = {
|
|
20
|
+
QueueUrl: this.TRANSACTION_QUEUE,
|
|
21
|
+
MessageBody: JSON.stringify(message)
|
|
22
|
+
};
|
|
23
|
+
const command = new client_sqs_1.SendMessageCommand(sendMessageRequest);
|
|
24
|
+
await client.send(command);
|
|
25
|
+
}
|
|
26
|
+
catch (error) {
|
|
27
|
+
throw new Error(`Error publishing message to queue ${': ' + error.message ?? ''}`);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
exports.TransactionPublisher = TransactionPublisher;
|
|
32
|
+
exports.TransactionPublisher = TransactionPublisher = __decorate([
|
|
33
|
+
(0, inversify_1.injectable)()
|
|
34
|
+
], TransactionPublisher);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fiado/api-invoker",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.64",
|
|
4
4
|
"description": "Sirve como un puente entre diferentes funciones lambda, facilitando la comunicación entre ellas a traves de invocaciones http",
|
|
5
5
|
"main": "bin/index.js",
|
|
6
6
|
"types": "bin/index.d.ts",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"@fiado/api-invoker": "^1.0.19",
|
|
17
17
|
"@fiado/gateway-adapter": "^1.0.30",
|
|
18
18
|
"@fiado/http-client": "^1.0.1",
|
|
19
|
-
"@fiado/type-kit": "^1.1.
|
|
19
|
+
"@fiado/type-kit": "^1.1.14",
|
|
20
20
|
"dotenv": "^16.4.5",
|
|
21
21
|
"inversify": "^6.0.2",
|
|
22
22
|
"reflect-metadata": "^0.2.1",
|
package/src/container.config.ts
CHANGED
|
@@ -21,6 +21,8 @@ import {IExchangeRatesApi} from "./exchangeRates";
|
|
|
21
21
|
import ExchangeRatesApi from "./exchangeRates/ExchangeRatesApi";
|
|
22
22
|
import { AuthenticationApi, IAuthenticationApi } from "./authentication";
|
|
23
23
|
import { CardApi, ICardApi } from "./card";
|
|
24
|
+
import { ITransactionPublisher } from "./transaction/queue/interfaces/ITransactionPublisher";
|
|
25
|
+
import { TransactionPublisher } from "./transaction/queue/TransactionPublisher";
|
|
24
26
|
|
|
25
27
|
export const apiInvokerBindings = new ContainerModule((bind: interfaces.Bind) => {
|
|
26
28
|
bind<IDirectoryApi>("IDirectoryApi").to(DirectoryApi);
|
|
@@ -35,6 +37,7 @@ export const apiInvokerBindings = new ContainerModule((bind: interfaces.Bind) =>
|
|
|
35
37
|
bind<IAccountFiadoSAApi>("IAccountFiadoSAApi").to(AccountFiadoSAApi);
|
|
36
38
|
bind<INotificationMessagesPublisher>("INotificationMessagesPublisher").to(NotificationMessagePublisher);
|
|
37
39
|
bind<ISessionActivityPublisher>("ISessionActivityPublisher").to(SessionActivityPublisher);
|
|
40
|
+
bind<ITransactionPublisher>("ITransactionPublisher").to(TransactionPublisher);
|
|
38
41
|
bind<IAuthenticationApi>("IAuthenticationApi").to(AuthenticationApi);
|
|
39
42
|
bind<ICardApi>("ICardApi").to(CardApi)
|
|
40
43
|
});
|
package/src/index.ts
CHANGED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import {SendMessageCommand, SendMessageRequest, SQSClient} from "@aws-sdk/client-sqs";
|
|
2
|
+
import { ITransactionPublisher} from "./interfaces/ITransactionPublisher";
|
|
3
|
+
import {injectable} from "inversify";
|
|
4
|
+
import { TransactionCreateRequest } from "@fiado/type-kit/bin/transaction";
|
|
5
|
+
|
|
6
|
+
@injectable()
|
|
7
|
+
export class TransactionPublisher implements ITransactionPublisher {
|
|
8
|
+
private readonly TRANSACTION_QUEUE = process.env.TRANSACTION_QUEUE
|
|
9
|
+
|
|
10
|
+
async publish(message: TransactionCreateRequest): Promise<void> {
|
|
11
|
+
try {
|
|
12
|
+
const client: SQSClient = new SQSClient();
|
|
13
|
+
const sendMessageRequest: SendMessageRequest = {
|
|
14
|
+
QueueUrl: this.TRANSACTION_QUEUE,
|
|
15
|
+
MessageBody: JSON.stringify(message)
|
|
16
|
+
};
|
|
17
|
+
const command: SendMessageCommand = new SendMessageCommand(sendMessageRequest);
|
|
18
|
+
await client.send(command);
|
|
19
|
+
} catch (error) {
|
|
20
|
+
throw new Error(`Error publishing message to queue ${': ' + error.message ?? ''}`);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|