Compare commits
35 Commits
WEBINT-335
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 3f7c052572 | |||
| 3d9e2a6e9b | |||
| f94ee799d0 | |||
| d1e5892a0d | |||
| b14464da39 | |||
| cf6204e231 | |||
| 9d8788db39 | |||
| 79ceb74604 | |||
| d02b1d48bf | |||
| 1fb50323b0 | |||
| 985c85da59 | |||
| 23c61097a8 | |||
| 5372045bd7 | |||
| 72d61b8376 | |||
| 526c094494 | |||
| 474f7b7c68 | |||
| f8692e3e2e | |||
| 62715fae34 | |||
| f8678a68bb | |||
| 8f8ae22f23 | |||
| 2611147eb3 | |||
| b0b3badd5c | |||
| 2b812098fb | |||
| 3146efec64 | |||
| 44e4b98e35 | |||
| 6adb4d5c95 | |||
| bcb1a28164 | |||
| d5798602e2 | |||
| 1f94a89520 | |||
| 44bbc8f17c | |||
| 9e6877c329 | |||
| d5883ba75e | |||
| 421d0aa705 | |||
| 69b5958296 | |||
| b9e3e1784f |
@@ -2,10 +2,12 @@ compressionLevel: mixed
|
||||
|
||||
enableGlobalCache: false
|
||||
|
||||
enableScripts: true
|
||||
|
||||
nodeLinker: node-modules
|
||||
|
||||
npmRegistryServer: "https://registry.npmjs.org/"
|
||||
|
||||
npmScopes:
|
||||
sf-alvar:
|
||||
npmRegistryServer: "https://git.savefamilygps.net/api/packages/SaveFamily/npm/"
|
||||
|
||||
npmRegistryServer: "https://registry.npmjs.org/"
|
||||
|
||||
@@ -6,6 +6,8 @@ networks:
|
||||
external: true
|
||||
internal:
|
||||
driver: bridge
|
||||
volumes:
|
||||
rabbitmq_data:
|
||||
|
||||
services:
|
||||
rabbitmq-sim-broker:
|
||||
@@ -28,6 +30,7 @@ services:
|
||||
entrypoint: ["bash", "/usr/local/bin/docker-entrypoint-wrapper.sh"]
|
||||
command: ["rabbitmq-server"]
|
||||
volumes:
|
||||
- rabbitmq_data:/var/lib/rabbitmq
|
||||
- ./rabbit/docker-entrypoint-wrapper.sh:/usr/local/bin/docker-entrypoint-wrapper.sh:ro
|
||||
- ./rabbitmq_plugins/enabled_plugins:/etc/rabbitmq/enabled_plugins:ro
|
||||
- ./rabbit/rabbitmq.conf:/etc/rabbitmq/rabbitmq.conf:ro
|
||||
@@ -73,7 +76,9 @@ services:
|
||||
volumes:
|
||||
- ./.env:/home/node/app/.env:ro
|
||||
- ./sim-consumidor-nos.env:/home/node/app/packages/sim-consumidor-nos/.env:ro
|
||||
- ./sim-consumidor-alai.env:/home/node/app/packages/sim-consumidor-alai/.env:ro
|
||||
- ./sim-consumidor-objenious.env:/home/node/app/packages/sim-consumidor-objenious/.env:ro
|
||||
- ./wsaccess_alaisecure_com_cert_client_new.p12:/home/node/app/packages/sim-consumidor-alai/certificates/wsaccess_alaisecure_com_cert_client_new.p12:ro
|
||||
- ./sim-objenious-cron.env:/home/node/app/packages/sim-objenious-cron/.env:ro
|
||||
- ./obj.pem:/home/node/app/packages/sim-consumidor-objenious/obj.pem:ro
|
||||
- ./obj.pem:/home/node/app/packages/sim-objenious-cron/obj.pem:ro
|
||||
|
||||
@@ -23,7 +23,7 @@ pipeline {
|
||||
stage("🧱 Building") {
|
||||
steps {
|
||||
sh 'rm -rf dist/'
|
||||
sh 'yarn run build'
|
||||
sh 'yarn run build:prod'
|
||||
}
|
||||
}
|
||||
stage("🏗 Deploying") {
|
||||
@@ -40,31 +40,11 @@ pipeline {
|
||||
),
|
||||
sshTransfer(
|
||||
cleanRemote: false,
|
||||
execCommand: "ln -sf $BASE_REMOTE_PATH/vault/savefamily/sf-sims/.env $APP_REMOTE_PATH/.env"
|
||||
execCommand: "rm -rf $APP_REMOTE_PATH/dist"
|
||||
),
|
||||
sshTransfer(
|
||||
cleanRemote: false,
|
||||
execCommand: "ln -sf $BASE_REMOTE_PATH/vault/savefamily/sf-sims/sim-consumidor-objenious.env $APP_REMOTE_PATH/packages/sim-consumidor-objenious/.env"
|
||||
),
|
||||
sshTransfer(
|
||||
cleanRemote: false,
|
||||
execCommand: "ln -sf $BASE_REMOTE_PATH/vault/savefamily/sf-sims/sim-consumidor-nos.env $APP_REMOTE_PATH/packages/sim-consumidor-nos/.env"
|
||||
),
|
||||
sshTransfer(
|
||||
cleanRemote: false,
|
||||
execCommand: "ln -sf $BASE_REMOTE_PATH/vault/savefamily/sf-sims/sim-consumidor-alai.env $APP_REMOTE_PATH/packages/sim-consumidor-alai/.env"
|
||||
),
|
||||
sshTransfer(
|
||||
cleanRemote: false,
|
||||
execCommand: "ln -sf $BASE_REMOTE_PATH/vault/savefamily/sf-sims/wsaccess_alaisecure_com_cert_client_new.p12 $APP_REMOTE_PATH/packages/wsaccess_alaisecure_com_cert_client_new.p12"
|
||||
),
|
||||
sshTransfer(
|
||||
cleanRemote: false,
|
||||
execCommand: "ln -sf $BASE_REMOTE_PATH/vault/savefamily/sf-sims/sim-objenious-cron.env $APP_REMOTE_PATH/packages/sim-objenious-cron/.env"
|
||||
),
|
||||
sshTransfer(
|
||||
cleanRemote: false,
|
||||
execCommand: "ln -sf $BASE_REMOTE_PATH/vault/savefamily/sf-sims/obj.pem $APP_REMOTE_PATH/packages/sim-consumidor-objenious/obj.pem"
|
||||
execCommand: "ls -la $BASE_REMOTE_PATH/vault/savefamily/sf-sims/"
|
||||
),
|
||||
sshTransfer(
|
||||
cleanRemote: false,
|
||||
@@ -72,6 +52,34 @@ pipeline {
|
||||
sourceFiles: "dist/**/*",
|
||||
excludes: "dist/**/node_modules/**"
|
||||
),
|
||||
sshTransfer(
|
||||
cleanRemote: false,
|
||||
execCommand: "ln -sf $BASE_REMOTE_PATH/vault/savefamily/sf-sims/.env $APP_REMOTE_PATH/.env"
|
||||
),
|
||||
sshTransfer(
|
||||
cleanRemote: false,
|
||||
execCommand: "ln -sf $BASE_REMOTE_PATH/vault/savefamily/sf-sims/wsaccess_alaisecure_com_cert_client_new.p12 $APP_REMOTE_PATH/wsaccess_alaisecure_com_cert_client_new.p12"
|
||||
),
|
||||
sshTransfer(
|
||||
cleanRemote: false,
|
||||
execCommand: "ln -sf $BASE_REMOTE_PATH/vault/savefamily/sf-sims/sim-consumidor-objenious.env $APP_REMOTE_PATH/sim-consumidor-objenious.env"
|
||||
),
|
||||
sshTransfer(
|
||||
cleanRemote: false,
|
||||
execCommand: "ln -sf $BASE_REMOTE_PATH/vault/savefamily/sf-sims/sim-consumidor-nos.env $APP_REMOTE_PATH/sim-consumidor-nos.env"
|
||||
),
|
||||
sshTransfer(
|
||||
cleanRemote: false,
|
||||
execCommand: "ln -sf $BASE_REMOTE_PATH/vault/savefamily/sf-sims/sim-consumidor-alai.env $APP_REMOTE_PATH/sim-consumidor-alai.env"
|
||||
),
|
||||
sshTransfer(
|
||||
cleanRemote: false,
|
||||
execCommand: "ln -sf $BASE_REMOTE_PATH/vault/savefamily/sf-sims/sim-objenious-cron.env $APP_REMOTE_PATH/sim-objenious-cron.env"
|
||||
),
|
||||
sshTransfer(
|
||||
cleanRemote: false,
|
||||
execCommand: "ln -sf $BASE_REMOTE_PATH/vault/savefamily/sf-sims/obj.pem $APP_REMOTE_PATH/obj.pem"
|
||||
),
|
||||
sshTransfer(
|
||||
cleanRemote: false,
|
||||
remoteDirectory: "$APP_REMOTE_PATH",
|
||||
|
||||
@@ -1,90 +1,92 @@
|
||||
{
|
||||
"rabbit_version": "4.2.2",
|
||||
"rabbitmq_version": "4.2.2",
|
||||
"product_name": "RabbitMQ",
|
||||
"product_version": "4.2.2",
|
||||
"users": [
|
||||
{
|
||||
"name": "RABBITMQ_USER_PLACEHOLDER",
|
||||
"password": "RABBITMQ_PASSWORD_PLACEHOLDER",
|
||||
"tags": ["administrator"]
|
||||
}
|
||||
],
|
||||
"vhosts": [
|
||||
{
|
||||
"name": "sim-vhost"
|
||||
}
|
||||
],
|
||||
"permissions": [
|
||||
{
|
||||
"user": "RABBITMQ_USER_PLACEHOLDER",
|
||||
"vhost": "sim-vhost",
|
||||
"configure": ".*",
|
||||
"write": ".*",
|
||||
"read": ".*"
|
||||
}
|
||||
],
|
||||
"topic_permissions": [],
|
||||
"parameters": [],
|
||||
"global_parameters": [
|
||||
{
|
||||
"name": "cluster_name",
|
||||
"value": "rabbit@a8d5c6e08439"
|
||||
},
|
||||
{
|
||||
"name": "internal_cluster_id",
|
||||
"value": "rabbitmq-cluster-id-gXeBLbsUC2W2tU0Bx_QY_w"
|
||||
}
|
||||
],
|
||||
"policies": [
|
||||
{
|
||||
"vhost": "sim-vhost",
|
||||
"name": "pol.sim.dlx",
|
||||
"pattern": "sim.*",
|
||||
"apply-to": "queues",
|
||||
"definition": {
|
||||
"dead-letter-exchange": "sim.dlx"
|
||||
},
|
||||
"priority": 7
|
||||
}
|
||||
],
|
||||
"exchanges": [
|
||||
{
|
||||
"name": "sim.exchange",
|
||||
"vhost": "sim-vhost",
|
||||
"type": "topic",
|
||||
"durable": true,
|
||||
"auto_delete": false,
|
||||
"internal": false,
|
||||
"argurments": {}
|
||||
},
|
||||
{
|
||||
"name": "sim.dlx",
|
||||
"vhost": "sim-vhost",
|
||||
"type": "topic",
|
||||
"durable": true,
|
||||
"auto_delete": false,
|
||||
"internal": false,
|
||||
"argurments": {}
|
||||
}
|
||||
],
|
||||
"queues": [
|
||||
{
|
||||
"name": "sim.logs",
|
||||
"vhost": "sim-vhost",
|
||||
"durable": true,
|
||||
"auto_delete": false,
|
||||
"arguments": {}
|
||||
}
|
||||
],
|
||||
"bindings": [
|
||||
{
|
||||
"source": "sim.exchange",
|
||||
"vhost": "sim-vhost",
|
||||
"destination": "sim.logs",
|
||||
"destination_type": "queue",
|
||||
"routing_key": "sim.#",
|
||||
"arguments": {}
|
||||
}
|
||||
]
|
||||
}
|
||||
"rabbit_version": "4.2.2",
|
||||
"rabbitmq_version": "4.2.2",
|
||||
"product_name": "RabbitMQ",
|
||||
"product_version": "4.2.2",
|
||||
"users": [
|
||||
{
|
||||
"name": "RABBITMQ_USER_PLACEHOLDER",
|
||||
"password": "RABBITMQ_PASSWORD_PLACEHOLDER",
|
||||
"tags": [
|
||||
"administrator"
|
||||
]
|
||||
}
|
||||
],
|
||||
"vhosts": [
|
||||
{
|
||||
"name": "sim-vhost"
|
||||
}
|
||||
],
|
||||
"permissions": [
|
||||
{
|
||||
"user": "RABBITMQ_USER_PLACEHOLDER",
|
||||
"vhost": "sim-vhost",
|
||||
"configure": ".*",
|
||||
"write": ".*",
|
||||
"read": ".*"
|
||||
}
|
||||
],
|
||||
"topic_permissions": [],
|
||||
"parameters": [],
|
||||
"global_parameters": [
|
||||
{
|
||||
"name": "cluster_name",
|
||||
"value": "rabbit@a8d5c6e08439"
|
||||
},
|
||||
{
|
||||
"name": "internal_cluster_id",
|
||||
"value": "rabbitmq-cluster-id-gXeBLbsUC2W2tU0Bx_QY_w"
|
||||
}
|
||||
],
|
||||
"policies": [
|
||||
{
|
||||
"vhost": "sim-vhost",
|
||||
"name": "pol.sim.dlx",
|
||||
"pattern": "sim.*",
|
||||
"apply-to": "queues",
|
||||
"definition": {
|
||||
"dead-letter-exchange": "sim.dlx"
|
||||
},
|
||||
"priority": 7
|
||||
}
|
||||
],
|
||||
"exchanges": [
|
||||
{
|
||||
"name": "sim.exchange",
|
||||
"vhost": "sim-vhost",
|
||||
"type": "topic",
|
||||
"durable": true,
|
||||
"auto_delete": false,
|
||||
"internal": false,
|
||||
"argurments": {}
|
||||
},
|
||||
{
|
||||
"name": "sim.dlx",
|
||||
"vhost": "sim-vhost",
|
||||
"type": "topic",
|
||||
"durable": true,
|
||||
"auto_delete": false,
|
||||
"internal": false,
|
||||
"argurments": {}
|
||||
}
|
||||
],
|
||||
"queues": [
|
||||
{
|
||||
"name": "sim.logs",
|
||||
"vhost": "sim-vhost",
|
||||
"durable": true,
|
||||
"auto_delete": false,
|
||||
"arguments": {}
|
||||
}
|
||||
],
|
||||
"bindings": [
|
||||
{
|
||||
"source": "sim.exchange",
|
||||
"vhost": "sim-vhost",
|
||||
"destination": "sim.logs",
|
||||
"destination_type": "queue",
|
||||
"routing_key": "sim.#",
|
||||
"arguments": {}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ post {
|
||||
|
||||
body:json {
|
||||
{
|
||||
"iccid": "1234"
|
||||
"iccid": "8934909001500561503"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,9 @@ params:query {
|
||||
}
|
||||
|
||||
body:form-urlencoded {
|
||||
iccid: 8933201125065160380
|
||||
iccid: 8934909001500954922
|
||||
offer: mensual
|
||||
orderId: test
|
||||
}
|
||||
|
||||
settings {
|
||||
|
||||
@@ -11,7 +11,7 @@ post {
|
||||
}
|
||||
|
||||
body:form-urlencoded {
|
||||
iccid: 8935103196306448300
|
||||
iccid: 8934909001500561503
|
||||
~offer: SAVEFAMILY1
|
||||
}
|
||||
|
||||
|
||||
38
docs/sim-objenious/Alerts.bru
Normal file
38
docs/sim-objenious/Alerts.bru
Normal file
@@ -0,0 +1,38 @@
|
||||
meta {
|
||||
name: Alerts
|
||||
type: http
|
||||
seq: 23
|
||||
}
|
||||
|
||||
get {
|
||||
url: https://api-getway.objenious.com/ws/alarms
|
||||
body: formUrlEncoded
|
||||
auth: bearer
|
||||
}
|
||||
|
||||
auth:bearer {
|
||||
token: {{ws-access-token-partenaire}}
|
||||
}
|
||||
|
||||
body:json {
|
||||
{
|
||||
"identifier": {
|
||||
"identifiers": ["8933201124059175967"],
|
||||
"identifierType": "ICCID"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
body:form-urlencoded {
|
||||
~identifier.identifierType: "ICCID"
|
||||
~identifier.identifiers: ["8933201124059175967"]
|
||||
}
|
||||
|
||||
vars:pre-request {
|
||||
~id: 5187320
|
||||
}
|
||||
|
||||
settings {
|
||||
encodeUrl: true
|
||||
timeout: 0
|
||||
}
|
||||
@@ -1,13 +1,14 @@
|
||||
{
|
||||
"name": "sim-eventos",
|
||||
"version": "1.0.0",
|
||||
"packageManager": "yarn@4.12.0",
|
||||
"packageManager": "yarn@4.14.1",
|
||||
"workspaces": [
|
||||
"packages/*"
|
||||
],
|
||||
"scripts": {
|
||||
"test": "vitest watch",
|
||||
"build": "rm -rf ./dist && yarn workspaces foreach -Api run build && yarn setup:runtime",
|
||||
"build:prod": "rm -rf ./dist && yarn workspaces foreach -Api run build:prod && yarn setup:runtime",
|
||||
"setup:runtime": "mkdir -p dist/packages/node_modules && ln -sf ../sim-shared dist/packages/node_modules/sim-shared && ln -sf ../sf-consumidor-objenious dist/packages/node_modules/sim-consumidor-objenious",
|
||||
"start": "yarn workspaces foreach -Apiv run start",
|
||||
"typecheck": "npx tsc --noEmit",
|
||||
|
||||
@@ -7,6 +7,11 @@ import { SimEvents } from "sim-shared/domain/SimEvents.js";
|
||||
import { iccidValidator } from "./httpValidators.js";
|
||||
import { alaiSimToCommonSim } from "#domain/transformers.js";
|
||||
|
||||
type ErrorUsecase = {
|
||||
msg: string,
|
||||
stackTrace?: string
|
||||
}
|
||||
|
||||
export class SimAlaiController {
|
||||
|
||||
constructor(
|
||||
@@ -41,12 +46,13 @@ export class SimAlaiController {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Metodo duplicado se puede generalizar la a una clase sharedController con las funciones basicas
|
||||
* TODO: meter un check de 429
|
||||
*/
|
||||
private async tryUseCase<T extends any>
|
||||
(msg: ConsumeMessage, usecase: () => Promise<Result<string, T>>): Promise<Result<string, T>> {
|
||||
(msg: ConsumeMessage, usecase: () => Promise<Result<ErrorUsecase, T>>): Promise<Result<ErrorUsecase, T>> {
|
||||
try {
|
||||
const result = await usecase()
|
||||
if (result.error == undefined) {
|
||||
@@ -61,7 +67,10 @@ export class SimAlaiController {
|
||||
console.error("Error general procesando el caso de uso (Alai)")
|
||||
this.eventBus.nack(msg)
|
||||
return {
|
||||
error: String(e)
|
||||
error: {
|
||||
msg: String(e),
|
||||
stackTrace: String(e)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -72,9 +81,30 @@ export class SimAlaiController {
|
||||
const data = this.validateMsg(msg) as SimEvents.activation
|
||||
const iccid = data.payload.iccid
|
||||
const correlation_id = data.headers?.message_id
|
||||
const externalId = data.payload.orderId
|
||||
|
||||
const res = await this.tryUseCase(msg, this.uscases.activate({
|
||||
iccid: iccid,
|
||||
correlation_id: correlation_id
|
||||
correlation_id: correlation_id,
|
||||
}))
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
public preactivate() {
|
||||
return async (msg: ConsumeMessage) => {
|
||||
console.log("[i] Evento preactivate ", msg)
|
||||
const data = this.validateMsg(msg) as SimEvents.preActivation
|
||||
const iccid = data.payload.iccid
|
||||
const correlation_id = data.headers?.message_id
|
||||
const externalId = data.payload.orderId
|
||||
|
||||
console.log("MSG:", data, data.headers)
|
||||
|
||||
const res = await this.tryUseCase(msg, this.uscases.preactivate({
|
||||
iccid: iccid,
|
||||
correlation_id: correlation_id,
|
||||
externalId: externalId
|
||||
}))
|
||||
return res;
|
||||
}
|
||||
@@ -114,7 +144,7 @@ export class SimAlaiController {
|
||||
|
||||
public terminate() {
|
||||
return async (msg: ConsumeMessage) => {
|
||||
console.log("Evento reActivate ", msg.fields)
|
||||
console.log("Evento reActivate ", msg.fields, msg)
|
||||
const data = this.validateMsg(msg) as SimEvents.reActivation
|
||||
const iccid = data.payload.iccid
|
||||
const correlation_id = data.headers?.message_id
|
||||
|
||||
@@ -9,7 +9,7 @@ import { EventBus } from "sim-shared/domain/EventBus.port.js";
|
||||
import { Result } from "sim-shared/domain/Result.js";
|
||||
import { SimAlaiController } from "./SimAlai.controller.js";
|
||||
|
||||
type FuncType = ((m: ConsumeMessage) => Promise<Result<string, any>>)
|
||||
type FuncType = ((m: ConsumeMessage) => Promise<Result<{ msg: string, stackTrace?: string }, any>>)
|
||||
|
||||
export class SimAlaiRouter {
|
||||
private readonly routes: Map<string, FuncType>;
|
||||
@@ -24,7 +24,7 @@ export class SimAlaiRouter {
|
||||
["pause", this.simController.suspend()],
|
||||
["reactivate", this.simController.reActivate()],
|
||||
["cancel", this.simController.terminate()],
|
||||
["preActivate", this.simController.activate()]
|
||||
["preactivate", this.simController.preactivate()]
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
@@ -10,12 +10,10 @@
|
||||
*/
|
||||
import { AlaiAPI } from "#domain/AlaiAPI.js";
|
||||
import { AlaiRepository } from "#infrastructure/AlaiRepository.js";
|
||||
import { ConsumeMessage } from "amqplib";
|
||||
import { ErrorOrderDTO, FinishOrderDTO, UpdateOrderDTO } from "sim-shared/domain/Order.js";
|
||||
import { Result } from "sim-shared/domain/Result.js";
|
||||
import { HttpClient } from "sim-shared/infrastructure/HTTPClient.js";
|
||||
import { OrderRepository } from "sim-shared/infrastructure/OrderRepository.js";
|
||||
import { isOmittedExpression } from "typescript";
|
||||
|
||||
export class SimAlaiUsecases {
|
||||
constructor(
|
||||
@@ -44,7 +42,7 @@ export class SimAlaiUsecases {
|
||||
return order
|
||||
}
|
||||
|
||||
private async setFailed(correlation_id: string, reason: string, detail?: string) {
|
||||
private async setFailed(correlation_id: string, reason: string, stackTrace?: string) {
|
||||
// En NOS el updateOrder se hace con el correlation_id que viene en la cabecera del
|
||||
// mensaje consumido
|
||||
const updateData: ErrorOrderDTO = {
|
||||
@@ -52,7 +50,7 @@ export class SimAlaiUsecases {
|
||||
correlation_id: correlation_id,
|
||||
reason: reason,
|
||||
error: reason,
|
||||
stackTrace: detail
|
||||
stackTrace: stackTrace
|
||||
}
|
||||
|
||||
console.log("SET FAILED DATA:", updateData)
|
||||
@@ -66,11 +64,11 @@ export class SimAlaiUsecases {
|
||||
* a peticiones de lectura (no pasan por la cola y no generan un order)
|
||||
*/
|
||||
public usecaseTemplate<T, R>(
|
||||
func: (_: T) => Promise<Result<string, R>>,
|
||||
func: (_: T) => Promise<Result<{ msg: string, stackTrace?: string }, R>>,
|
||||
args: T,
|
||||
correlation_id?: string | undefined
|
||||
) {
|
||||
return async (): Promise<Result<string, R>> => {
|
||||
return async (): Promise<Result<{ msg: string, stackTrace?: string }, R>> => {
|
||||
// Operacion pending -> running
|
||||
if (correlation_id != undefined)
|
||||
this.setRunning(correlation_id)
|
||||
@@ -85,7 +83,7 @@ export class SimAlaiUsecases {
|
||||
if (res.error != undefined) {
|
||||
console.log("Error peticion: ", res, correlation_id)
|
||||
if (correlation_id != undefined)
|
||||
this.setFailed(correlation_id, res.error)
|
||||
this.setFailed(correlation_id, res.error.msg, res.error.stackTrace)
|
||||
.then(e => console.log("failed", e))
|
||||
.catch(e => console.error(e))
|
||||
return res;
|
||||
@@ -99,7 +97,9 @@ export class SimAlaiUsecases {
|
||||
if (correlation_id != undefined)
|
||||
this.setFailed(correlation_id, "Error general de operacion de SIM (NOS) ", String(e)).then()
|
||||
return {
|
||||
error: "Error general de operacion de SIM (NOS) " + String(e)
|
||||
error: {
|
||||
msg: "Error general de operacion de SIM (NOS) " + String(e)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -108,17 +108,35 @@ export class SimAlaiUsecases {
|
||||
|
||||
public activate(args: {
|
||||
iccid: string,
|
||||
correlation_id: string | undefined
|
||||
correlation_id: string | undefined,
|
||||
}) {
|
||||
return this.usecaseTemplate(async (iccid /*iccid*/) => {
|
||||
const order = await this.alaiRepository.createOrder()
|
||||
if (order.error != undefined) {
|
||||
// Falla el crearse un order (problema de servidor, token, etc)
|
||||
console.error(order.error)
|
||||
return order
|
||||
const sim = await this.alaiRepository.getSimByICCID(iccid)
|
||||
if (sim.error != undefined) {
|
||||
return sim
|
||||
}
|
||||
const reserved = await this.alaiRepository.createReserve(order.data.id, iccid)
|
||||
return reserved
|
||||
|
||||
if (sim.data == undefined) {
|
||||
return {
|
||||
error: {
|
||||
msg: `La sim ${iccid} no se ha encontrado`
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const subscriptionId = sim.data.subscription!.id
|
||||
|
||||
if (subscriptionId == undefined) {
|
||||
return {
|
||||
error: {
|
||||
msg: `La sim ${iccid} no tiene un id de subscripción`
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const activationRes = await this.alaiRepository.activateSubscription(subscriptionId)
|
||||
return activationRes
|
||||
|
||||
}, args.iccid, args.correlation_id)
|
||||
}
|
||||
|
||||
@@ -144,6 +162,8 @@ export class SimAlaiUsecases {
|
||||
|
||||
const applyOrder = await this.alaiRepository.applyOrder(orderId)
|
||||
if (applyOrder.error != undefined) {
|
||||
// TODO: gestion del error
|
||||
// reusar el orderId
|
||||
return applyOrder
|
||||
}
|
||||
|
||||
@@ -153,7 +173,7 @@ export class SimAlaiUsecases {
|
||||
}
|
||||
|
||||
// TODO: Controlar sim no encotrada (No deberia pasar)
|
||||
const subscriptionId = preactivatedSim.data!.subscription.id
|
||||
const subscriptionId = preactivatedSim.data!.subscription!.id
|
||||
if (args.externalId) {
|
||||
const externalIdAdded = await this.alaiRepository.changeExternalId(subscriptionId, args.externalId)
|
||||
if (externalIdAdded.error != undefined) {
|
||||
@@ -178,7 +198,8 @@ export class SimAlaiUsecases {
|
||||
}
|
||||
|
||||
// TODO: Controlar que no se encuentre la subscription
|
||||
const suspension = this.alaiRepository.pauseSubscription(subscription.data!.id)
|
||||
const subscriptionid = subscription.data?.subscription?.id
|
||||
const suspension = this.alaiRepository.pauseSubscription(subscriptionid!)
|
||||
return suspension
|
||||
}, args, args.correlation_id)
|
||||
}
|
||||
@@ -193,9 +214,9 @@ export class SimAlaiUsecases {
|
||||
if (subscription.error != undefined) {
|
||||
return subscription
|
||||
}
|
||||
|
||||
const subscriptionid = subscription.data?.subscription?.id
|
||||
// TODO: Controlar que no se encuentre la subscription
|
||||
const suspension = this.alaiRepository.unPauseSubscription(subscription.data!.id)
|
||||
const suspension = this.alaiRepository.unPauseSubscription(subscriptionid!)
|
||||
return suspension
|
||||
}, args, args.correlation_id)
|
||||
}
|
||||
@@ -226,10 +247,10 @@ export class SimAlaiUsecases {
|
||||
* Para sacar los datos de una liena hay que sacar sim -> subscripcion -> imei
|
||||
* son 3 llamadas distintas.
|
||||
*/
|
||||
public async selectCompleteSim(iccid: string): Promise<Result<string, {
|
||||
public async selectCompleteSim(iccid: string): Promise<Result<{ msg: string, stackTrace?: string }, {
|
||||
sim: AlaiAPI.Sim,
|
||||
subscription: AlaiAPI.Subscription,
|
||||
imei: AlaiAPI.GetImeiSubscriptionDTO
|
||||
subscription?: AlaiAPI.Subscription,
|
||||
imei?: AlaiAPI.GetImeiSubscriptionDTO
|
||||
}>> {
|
||||
const sim = await this.alaiRepository.getSimByICCID(iccid)
|
||||
|
||||
@@ -237,7 +258,26 @@ export class SimAlaiUsecases {
|
||||
return sim
|
||||
}
|
||||
|
||||
const subscriptionId = sim.data!.subscription.id
|
||||
if (sim.data == undefined) {
|
||||
return {
|
||||
error: {
|
||||
msg: `La sim ${iccid} no se ha encontrado`
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// En este caso la tarjeta no se ha preactivado, por lo que no tiene subscripcion
|
||||
if (sim.data.subscription == undefined) {
|
||||
return {
|
||||
data: {
|
||||
sim: sim.data,
|
||||
subscription: undefined,
|
||||
imei: undefined
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const subscriptionId = sim.data.subscription.id
|
||||
const subscription = await this.alaiRepository.getSubscriptionById(subscriptionId)
|
||||
|
||||
if (subscription.error != undefined) {
|
||||
|
||||
@@ -1 +1 @@
|
||||
eyJhbGciOiJIUzM4NCJ9.eyJiciI6InNhdmVmYW1pbHkiLCJpcCI6Ijg4LjE1LjE1Ny4xNjciLCJzdWIiOiJwYWxvbWFpYmFuZXoiLCJzIjoiRVdTMTY0NmFmNjNlZGUyMjgzIiwicG9zIjoic2F2ZWZhbWlseUNhYyIsImlkV3NVc2VyIjoiODYiLCJpc012bmEiOmZhbHNlLCJkb21haW4iOiJBbGFpfHNhdmVmYW1pbHkiLCJpYXQiOjE3Nzc4OTk3MzcsImV4cCI6MTc3NzkxMDUzN30.PvTTRhUpKlslGOerQsLY4RLBXdQ5FIVvUKb_1ZK4b2Zggt04KZhwX0d-XoLAcP93
|
||||
eyJhbGciOiJIUzM4NCJ9.eyJiciI6InNhdmVmYW1pbHkiLCJpcCI6Ijg4LjE1LjE1Ny4xNjciLCJzdWIiOiJwYWxvbWFpYmFuZXoiLCJzIjoiRVdTMTY3MzRhYTM2MDY1M2EwIiwicG9zIjoic2F2ZWZhbWlseUNhYyIsImlkV3NVc2VyIjoiODYiLCJpc012bmEiOmZhbHNlLCJkb21haW4iOiJBbGFpfHNhdmVmYW1pbHkiLCJpYXQiOjE3Nzg2ODQ0NjIsImV4cCI6MTc3ODY5NTI2Mn0.wMWgjaOErm5clang7ErYzREU56okgpXWzq1zihT4lOfUDRQ005r-nCHJu7rpilj1
|
||||
|
||||
@@ -5,13 +5,16 @@ import { httpsAgent } from "./httpsAgent.js"
|
||||
import { DebugTokenManager } from "#aplication/DebugTokenManager.js";
|
||||
|
||||
const tokenManager = new AlaiTokenManager()
|
||||
//const debugTokenManagr = new DebugTokenManager()
|
||||
const debugTokenManagr = new DebugTokenManager()
|
||||
//console.error("USANDO DebugTokenManager! Eliminar en prod")
|
||||
|
||||
|
||||
export const alaiHttp = new HttpClient({
|
||||
baseURL: env.ALAI_API_URL as string,
|
||||
headers: {},
|
||||
headers: {
|
||||
"content-type": "application/json"
|
||||
},
|
||||
jwtManager: tokenManager,
|
||||
//jwtManager: debugTokenManagr,
|
||||
httpsAgent: httpsAgent
|
||||
})
|
||||
|
||||
@@ -237,7 +237,7 @@ export namespace AlaiAPI {
|
||||
name: string,
|
||||
links: Link[]
|
||||
},
|
||||
subscription: {
|
||||
subscription?: {
|
||||
id: string,
|
||||
name: string,
|
||||
links: Link[]
|
||||
|
||||
@@ -11,7 +11,8 @@ const alaiStates = new Map<AlaiAPI.Status, CommonSim<any>["billing_status"]>([
|
||||
["CONFIGURING", "SUSPENDED"],
|
||||
["DELETED", "TERMINATED"],
|
||||
["PRE_ACTIVE", "PREACTIVATED"],
|
||||
["TERMINATED", "TERMINATED"]
|
||||
["TERMINATED", "TERMINATED"],
|
||||
|
||||
])
|
||||
|
||||
const alaiNetworkStates = new Map<AlaiAPI.NetworkStatus, CommonSim<any>["network_status"]>([
|
||||
@@ -22,23 +23,37 @@ const alaiNetworkStates = new Map<AlaiAPI.NetworkStatus, CommonSim<any>["network
|
||||
["FRAUD", "TERMINATED"]
|
||||
])
|
||||
|
||||
export function alaiSimToCommonSim(alaiSim: AlaiAPI.Sim, alaiSubscription: AlaiAPI.Subscription, imeiSubscription: AlaiAPI.GetImeiSubscriptionDTO):
|
||||
Result<string, CommonSim<AlaiAPI.Subscription>> {
|
||||
export function alaiSimToCommonSim(alaiSim: AlaiAPI.Sim, alaiSubscription?: AlaiAPI.Subscription, imeiSubscription?: AlaiAPI.GetImeiSubscriptionDTO):
|
||||
Result<string, CommonSim<
|
||||
{
|
||||
sim: AlaiAPI.Sim,
|
||||
subscription?: AlaiAPI.Subscription,
|
||||
imeiSubscription?: AlaiAPI.GetImeiSubscriptionDTO
|
||||
}
|
||||
>> {
|
||||
|
||||
const status = alaiStates.get(alaiSubscription.status) ?? "UNKNOWN"
|
||||
const networkStatus = alaiNetworkStates.get(alaiSubscription.networkStatus) ?? "UNKNOWN"
|
||||
const billingStatus = (alaiSubscription == undefined) ? "AVAILABLE" : alaiStates.get(alaiSubscription?.status ?? "") ?? "UNKNOWN"
|
||||
const networkStatus = (alaiSubscription == undefined) ? "AVAILABLE" : alaiNetworkStates.get(alaiSubscription.networkStatus) ?? "UNKNOWN"
|
||||
|
||||
const commonSim: CommonSim<AlaiAPI.Subscription> = {
|
||||
const commonSim: CommonSim<{
|
||||
sim: AlaiAPI.Sim,
|
||||
subscription?: AlaiAPI.Subscription,
|
||||
imeiSubscription?: AlaiAPI.GetImeiSubscriptionDTO
|
||||
}> = {
|
||||
company: "ALAI",
|
||||
tariff: alaiSubscription.name,
|
||||
tariff: alaiSubscription?.name,
|
||||
iccid: alaiSim.id,
|
||||
msisdn: alaiSubscription.lastMsisdnID,
|
||||
billing_status: status,
|
||||
msisdn: alaiSubscription?.lastMsisdnID,
|
||||
billing_status: billingStatus,
|
||||
network_status: networkStatus,
|
||||
raw: alaiSubscription,
|
||||
imei: imeiSubscription.content[0].id ?? "0",
|
||||
preactivation_date: new Date(alaiSubscription.creationDate),
|
||||
activation_date: new Date(alaiSubscription.firstActivationDate)
|
||||
raw: {
|
||||
subscription: alaiSubscription,
|
||||
sim: alaiSim,
|
||||
imeiSubscription: imeiSubscription
|
||||
},
|
||||
imei: imeiSubscription?.content[0]?.id ?? "0",
|
||||
preactivation_date: (alaiSubscription != undefined) ? new Date(alaiSubscription.creationDate) : undefined,
|
||||
activation_date: (alaiSubscription != undefined) ? new Date(alaiSubscription.firstActivationDate) : undefined
|
||||
}
|
||||
|
||||
return {
|
||||
|
||||
@@ -5,13 +5,18 @@ import { env } from "#config/env/env.js";
|
||||
import { HttpClient } from "sim-shared/infrastructure/HTTPClient.js";
|
||||
import https from "https"
|
||||
|
||||
type ErrorRepo = {
|
||||
msg: string,
|
||||
stackTrace?: string
|
||||
}
|
||||
|
||||
export class AlaiRepository {
|
||||
constructor(
|
||||
private httpClient: HttpClient
|
||||
) {
|
||||
}
|
||||
|
||||
private async manageRequest<E, T>(promiseReq: Promise<AxiosResponse<T>>): Promise<Result<string, T>> {
|
||||
private async manageRequest<E, T>(promiseReq: Promise<AxiosResponse<T>>): Promise<Result<ErrorRepo, T>> {
|
||||
try {
|
||||
const res = await promiseReq
|
||||
return {
|
||||
@@ -19,19 +24,26 @@ export class AlaiRepository {
|
||||
}
|
||||
} catch (e) {
|
||||
if (axios.isAxiosError(e)) {
|
||||
console.log("ERROR REQUEST ", e.response)
|
||||
const error = e as AxiosError
|
||||
return {
|
||||
error: error.code + " : " + String(error.response?.statusText)
|
||||
error: {
|
||||
msg: error.code + " : " + String(error.response?.statusText),
|
||||
stackTrace: JSON.stringify(error.response?.data)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return {
|
||||
error: String(e)
|
||||
error: {
|
||||
msg: String(e),
|
||||
stackTrace: String(e)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static async login(httpsAgent: https.Agent): Promise<Result<string, AlaiAPI.LoginResponseDTO>> {
|
||||
public static async login(httpsAgent: https.Agent): Promise<Result<ErrorRepo, AlaiAPI.LoginResponseDTO>> {
|
||||
const alaiUrl = env.ALAI_API_URL
|
||||
const endpoint = "/v1/auth/login"
|
||||
const fullUrl = alaiUrl + endpoint
|
||||
@@ -50,11 +62,16 @@ export class AlaiRepository {
|
||||
if (axios.isAxiosError(e)) {
|
||||
const error = e as AxiosError
|
||||
return {
|
||||
error: error.code + " : " + String(error.response?.statusText)
|
||||
error: {
|
||||
msg: error.code + " : " + String(error.response?.statusText),
|
||||
stackTrace: String(error)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return {
|
||||
error: String(e)
|
||||
error: {
|
||||
msg: String(e)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -101,7 +118,7 @@ export class AlaiRepository {
|
||||
/**
|
||||
* Antes se usaba PATCH /v1/sim/{iccid}/{orderId} pero en la docu ha pasado a POST
|
||||
*/
|
||||
public async createReserve(orderId: string, iccid: string): Promise<Result<string, AlaiAPI.CreateOrderResponseDTO>> {
|
||||
public async createReserve(orderId: string, iccid: string): Promise<Result<ErrorRepo, AlaiAPI.CreateOrderResponseDTO>> {
|
||||
const endpoint = `/v1/sim/${iccid}/order/${orderId}`
|
||||
// Crear la reserva no usa datos en el body
|
||||
const promReq = this.httpClient.post<AlaiAPI.CreateOrderResponseDTO>(endpoint, undefined)
|
||||
@@ -135,16 +152,37 @@ export class AlaiRepository {
|
||||
return res
|
||||
}
|
||||
|
||||
public async unPauseSubscription(subscriptionId: string) {
|
||||
public async activateSubscription(subscriptionId: string) {
|
||||
const endpoint = `/v1/subscription/${subscriptionId}`
|
||||
// En teoria ahora se usa ["action", "UNBLOCK"] pero no he probado
|
||||
const params = new URLSearchParams([
|
||||
["action", "CHANGE_STATUS"]
|
||||
])
|
||||
|
||||
const data = {
|
||||
"status": "ACTIVE"
|
||||
}
|
||||
|
||||
const promReq = this.httpClient.patch<AlaiAPI.UpdateSubscriptionDTO | undefined>(endpoint, data, { params: params })
|
||||
const res = await this.manageRequest(promReq)
|
||||
return res
|
||||
}
|
||||
|
||||
public async unPauseSubscription(subscriptionId: string) {
|
||||
const endpoint = `/v1/subscription/${subscriptionId}`
|
||||
// En teoria ahora se usa ["action", "UNBLOCK"] pero no he probado
|
||||
const params = new URLSearchParams([
|
||||
["action", "UNBLOCK"]
|
||||
])
|
||||
|
||||
const rawParams = {
|
||||
"action": "UNBLOCK"
|
||||
}
|
||||
|
||||
const data = {
|
||||
status: "ACTIVE"
|
||||
}
|
||||
const promReq = this.httpClient.patch<AlaiAPI.UpdateSubscriptionDTO | undefined>(endpoint, data, { params: params })
|
||||
const promReq = this.httpClient.patch<AlaiAPI.UpdateSubscriptionDTO | undefined>(endpoint, undefined, { params: rawParams })
|
||||
const res = await this.manageRequest(promReq)
|
||||
return res
|
||||
}
|
||||
|
||||
@@ -39,9 +39,10 @@
|
||||
},
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1",
|
||||
"build": "yarn tsc --project tsconfig.json && yarn tsc-alias && cp package.json ../../dist/packages/sim-consumidor-nos/ && cp -r certificates/ ../../dist/packages/sim-consumidor-alai/",
|
||||
"build": "yarn tsc --project tsconfig.json && yarn tsc-alias && cp -P .env package.json ../../dist/packages/sim-consumidor-alai/ && cp -r certificates/ ../../dist/packages/sim-consumidor-alai/",
|
||||
"build:prod": "yarn tsc --project tsconfig.json && yarn tsc-alias && cp -P package.json ../../dist/packages/sim-consumidor-alai/ && mkdir ../../dist/packages/sim-consumidor-alai/certificates",
|
||||
"esbuild": "esbuild index.ts --platform=node",
|
||||
"start": "node ../../dist/packages/sim-consumidor-nos/index.js",
|
||||
"start": "node ../../dist/packages/sim-consumidor-alai/index.js",
|
||||
"dev": "tsx watch index.ts"
|
||||
},
|
||||
"author": "",
|
||||
|
||||
@@ -29,8 +29,8 @@ export const env = {
|
||||
RABBITMQ_RETRY_INTERVAL: process.env.RABBITMQ_INTERVAL,
|
||||
RABBITMQ_VHOST: String(process.env.RABBITMQ_VHOST),
|
||||
|
||||
APP_PORT: Number(process.env.NOS_PORT),
|
||||
APP_HOST: String(process.env.NOS_HOST),
|
||||
APP_PORT: Number(process.env.NOS_PORT ?? 3001),
|
||||
APP_HOST: String(process.env.NOS_HOST ?? "0.0.0.0"),
|
||||
|
||||
// ESPECIFICO NOS
|
||||
NOS_BASE_URL: String(process.env.NOS_BASE_URL),
|
||||
|
||||
@@ -39,7 +39,8 @@
|
||||
},
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1",
|
||||
"build": "yarn tsc --project tsconfig.json && yarn tsc-alias && cp package.json ../../dist/packages/sim-consumidor-nos/",
|
||||
"build": "yarn tsc --project tsconfig.json && yarn tsc-alias && cp -P .env package.json ../../dist/packages/sim-consumidor-nos/",
|
||||
"build:prod": "yarn tsc --project tsconfig.json && yarn tsc-alias && cp -P package.json ../../dist/packages/sim-consumidor-nos/",
|
||||
"esbuild": "esbuild index.ts --platform=node",
|
||||
"start": "node ../../dist/packages/sim-consumidor-nos/index.js",
|
||||
"dev": "tsx watch index.ts"
|
||||
|
||||
@@ -20,7 +20,7 @@ export class SimRouter {
|
||||
["pause", this.simController.suspend()],
|
||||
["cancel", this.simController.terminate()],
|
||||
["reactivate", this.simController.reActivate()],
|
||||
["preActivate", this.simController.preActivate()]
|
||||
["preactivate", this.simController.preActivate()]
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
@@ -185,7 +185,7 @@ export class SimUseCases {
|
||||
console.log("Sim preactivada con exito", resp.data)
|
||||
const operation: ObjeniousOperation = {
|
||||
correlation_id: preActivateData.correlation_id,
|
||||
operation: "preActivate",
|
||||
operation: "preactivate",
|
||||
iccids: String(preActivateData.identifier.identifiers),
|
||||
status: "noMassID",
|
||||
request_id: resp.data.requestId
|
||||
|
||||
@@ -46,8 +46,8 @@ async function buildQueues(channel: Channel) {
|
||||
await channel.assertExchange(EXCHANGES.DLX, "topic")
|
||||
await channel.assertExchange(EXCHANGES.MAIN, "topic")
|
||||
|
||||
await channel.assertQueue(QUEUES.OBJ)
|
||||
await channel.assertQueue(QUEUES.OBJDLX)
|
||||
await channel.assertQueue(QUEUES.OBJ, { durable: true })
|
||||
await channel.assertQueue(QUEUES.OBJDLX, { durable: true })
|
||||
await channel.assertQueue(QUEUES.OBJDEL, {
|
||||
durable: true,
|
||||
arguments: {
|
||||
|
||||
@@ -55,7 +55,8 @@
|
||||
"scripts": {
|
||||
"test": "node --import tsx --test ./**/*.test.ts",
|
||||
"dev": "tsx watch index.ts",
|
||||
"build": "tsc --build && yarn tsc-alias -p tsconfig.json && cp .env package.json ../../dist/packages/sim-consumidor-objenious/",
|
||||
"build": "tsc --build && yarn tsc-alias -p tsconfig.json && cp -P ./.env ./package.json ../../dist/packages/sim-consumidor-objenious/",
|
||||
"build:prod": "tsc --build && yarn tsc-alias -p tsconfig.json && cp -P ./package.json ../../dist/packages/sim-consumidor-objenious/",
|
||||
"start": "node ../../dist/packages/sim-consumidor-objenious/index.js",
|
||||
"type:test": "tsc --noEmit"
|
||||
},
|
||||
|
||||
@@ -164,15 +164,16 @@ export class SimUsecases {
|
||||
Promise<Result<string, { iccid: string, message_id: string, operation: "preactivation" }>> {
|
||||
|
||||
const preActivationEvent = <SimEvents.preActivation>{
|
||||
key: `sim.${args.compañia}.preActivate`,
|
||||
key: `sim.${args.compañia}.preactivate`,
|
||||
payload: {
|
||||
iccid: args.iccid
|
||||
}
|
||||
}
|
||||
console.log("[d] Pre - activation ", preActivationEvent)
|
||||
await this.eventBus.publish([preActivationEvent])
|
||||
const preactivationWithId = this.addMessage_id(preActivationEvent)
|
||||
const createdOrder = await this.saveOrder<SimEvents.preActivation>(preactivationWithId)
|
||||
|
||||
const preActivationWithId = this.addMessage_id(preActivationEvent)
|
||||
console.log("[d] Pre - activation ", preActivationWithId)
|
||||
await this.eventBus.publish([preActivationWithId])
|
||||
const createdOrder = await this.saveOrder<SimEvents.preActivation>(preActivationWithId)
|
||||
if (createdOrder.error != undefined) {
|
||||
console.error(createdOrder.error)
|
||||
return {
|
||||
|
||||
@@ -41,6 +41,7 @@
|
||||
"scripts": {
|
||||
"test": "node --import tsx --test ./**/*.test.ts",
|
||||
"build": "tsc --build && tsc-alias -p tsconfig.json && cp package.json ../../dist/packages/sim-entrada-eventos/",
|
||||
"build:prod": "yarn build",
|
||||
"dev": "tsx watch index.ts",
|
||||
"start": "node ../../dist/packages/sim-entrada-eventos/index.js"
|
||||
},
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
"scripts": {
|
||||
"test": "node --import tsx --test ./**/*.test.ts",
|
||||
"build": "tsc --build && tsc-alias -p tsconfig.json && cp .env package.json ../../dist/packages/sim-objenious-cron/",
|
||||
"build:prod": "yarn build",
|
||||
"dev": "tsx watch index.ts",
|
||||
"start": "node ../../dist/packages/sim-objenious-cron/index.js"
|
||||
},
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
export type CommonSim<T> = {
|
||||
company: "NOS" | "OBJ" | "ALAI",
|
||||
iccid: string,
|
||||
msisdn: string,
|
||||
tariff: string, // Depende de la compañia
|
||||
billing_status: "PREACTIVATED" | "ACTIVE" | "SUSPENDED" | "TERMINATED" | "UNKNOWN",
|
||||
msisdn?: string,
|
||||
tariff?: string, // Depende de la compañia
|
||||
billing_status: "AVAILABLE" | "PREACTIVATED" | "ACTIVE" | "SUSPENDED" | "TERMINATED" | "UNKNOWN",
|
||||
network_status: "AVAILABLE" | "PREACTIVATED" | "ACTIVE" | "SUSPENDED" | "TERMINATED" | "UNKNOWN",
|
||||
preactivation_date?: Date | null,
|
||||
activation_date?: Date | null,
|
||||
|
||||
@@ -18,9 +18,10 @@ export namespace SimEvents {
|
||||
}
|
||||
|
||||
export type preActivation = DomainEvent & {
|
||||
key: `sim.${string}.preActivate`,
|
||||
key: `sim.${string}.preactivate`,
|
||||
payload: {
|
||||
iccid: string
|
||||
iccid: string,
|
||||
orderId?: string // Solo Alai
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
@@ -40,7 +40,8 @@
|
||||
"scripts": {
|
||||
"test": "node --import tsx --test ./**/*.test.ts",
|
||||
"dev": "echo \" Shared no es un modulo ejecutable \" ",
|
||||
"build": "tsc --build && tsc-alias -p tsconfig.json && cp package.json ../../dist/packages/sim-shared/"
|
||||
"build": "tsc --build && tsc-alias -p tsconfig.json && cp package.json ../../dist/packages/sim-shared/",
|
||||
"build:prod": "yarn build"
|
||||
},
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
|
||||
13
test_api.ts
13
test_api.ts
@@ -1,35 +1,34 @@
|
||||
import { NosHttpClient } from "./packages/sim-consumidor-nos/infrastructure/NosHttpClient.js";
|
||||
import { NosRepository } from "./packages/sim-consumidor-nos/infrastructure/NosRepository.js";
|
||||
import { env } from "./packages/sim-consumidor-nos/config/env/env.js";
|
||||
|
||||
async function main() {
|
||||
console.log("NOS_BASE_URL", env.NOS_BASE_URL);
|
||||
const client = new NosHttpClient(env.NOS_BASE_URL);
|
||||
|
||||
|
||||
// Try to get a subscriber
|
||||
const res = await client.get("/subscribers", { params: { limit: 1 } });
|
||||
console.log("SUBSCRIBER:", res.data.content[0].physicalId);
|
||||
|
||||
|
||||
const iccid = res.data.content[0].physicalId;
|
||||
|
||||
|
||||
try {
|
||||
const history = await client.get(`/subscribers/${iccid}/history`);
|
||||
console.log("HISTORY:", history.data);
|
||||
} catch(e) {
|
||||
} catch (e) {
|
||||
console.error("HISTORY ERROR");
|
||||
}
|
||||
|
||||
try {
|
||||
const audit = await client.get(`/subscribers/${iccid}/audit`);
|
||||
console.log("AUDIT:", audit.data);
|
||||
} catch(e) {
|
||||
} catch (e) {
|
||||
console.error("AUDIT ERROR");
|
||||
}
|
||||
|
||||
try {
|
||||
const actions = await client.get(`/subscribers/${iccid}/actions`);
|
||||
console.log("ACTIONS:", actions.data);
|
||||
} catch(e) {
|
||||
} catch (e) {
|
||||
console.error("ACTIONS ERROR");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user