Bug de logueo de operacion

This commit is contained in:
2026-04-14 16:07:17 +02:00
parent 70bf73b0a4
commit 4d34308a13
8 changed files with 111 additions and 10 deletions

View File

@@ -11,7 +11,7 @@ post {
}
body:form-urlencoded {
iccid: 8933201125068886692
iccid: 8933201125068887864
}
settings {

View File

@@ -15,7 +15,7 @@ params:query {
}
body:form-urlencoded {
iccid: 8933201125068886692
iccid: 8933201125068886700
}
settings {

View File

@@ -75,13 +75,14 @@ export class SimUseCases {
operation: args.operation,
iccids: String(args.iccid),
status: "noMassID",
request_id: response.data.requestId
request_id: response.data.requestId,
correlation_id: args.correlation_id
}
// TODO: Esto tiene poco sentido si la operacion ya se
// tenia que haber creado en el generador
this.logOperation(operation)
.then().catch(e => console.error(e))
.then().catch(e => console.error("Error login operation", e))
if (args.correlation_id != undefined) {
this.orderRepository.updateOrder({
@@ -276,6 +277,17 @@ export class SimUseCases {
const correlation_id = suspendData.correlation_id
const iccid = suspendData.identifier.identifiers
const operation: ObjeniousOperation = {
operation: "suspend",
iccids: iccid[0],
status: "running",
correlation_id: correlation_id
}
this.logOperation(operation)
.then().catch(e => console.error("Error login operation", e))
const fail = (error: string) => {
console.error("[Sim.usecases]", error)
if (correlation_id != undefined) {
@@ -286,6 +298,14 @@ export class SimUseCases {
}
}
// TODO REGISTRAR EL ORDER
if (correlation_id != undefined) {
await this.orderRepository.createOrder({
correlation_id: correlation_id,
order_type: "pause"
})
}
let activationDate;
try {
activationDate = await this.findActivationDate(suspendData)
@@ -332,10 +352,11 @@ export class SimUseCases {
public stage_terminate(terminateData: ActionData): () => Promise<Result<string, boolean>> {
return async (): Promise<Result<string, boolean>> => {
const correlation_id = terminateData.correlation_id
const iccid = terminateData.identifier.identifiers[0]
const activationDate = await this.findActivationDate(terminateData)
const newTask: CreatePauseCancelTaskDTO = {
iccid: terminateData.identifier.identifiers[0],
iccid: iccid,
activation_date: activationDate,
next_check: undefined, // Que se haga instantaneamente al ser la primera
operation_type: "terminate",
@@ -344,6 +365,16 @@ export class SimUseCases {
const taskCreated = await this.pauseRepository.addTask(newTask)
const operation: ObjeniousOperation = {
operation: "terminate",
iccids: iccid,
status: "running",
correlation_id: correlation_id
}
this.logOperation(operation)
.then().catch(e => console.error("Error login operation", e))
// Caso que la task no se pueda crear en la BDD
if (taskCreated.error != undefined) {
console.error("[Sim.usecases]", taskCreated.error)

View File

@@ -176,6 +176,7 @@ export class SimUsecases {
console.log("[d] Cancelation ", cancelationWithId)
await this.eventBus.publish([cancelationWithId])
const savedOrder = await this.saveOrder(cancelationWithId)
if (savedOrder.error != undefined) {
console.error(savedOrder.error)
return {
@@ -205,11 +206,12 @@ export class SimUsecases {
iccid: args.iccid
}
}
const pauseWithId = this.addMessage_id(pauseEvent)
console.log("[d] Pause", pauseWithId)
await this.eventBus.publish([pauseWithId])
await this.saveOrder(pauseWithId)
const savedOrder = await this.saveOrder(pauseWithId)
//await this.saveOrder(pauseWithId)
const savedOrder = await this.saveOrder<SimEvents.pause>(pauseWithId)
if (savedOrder.error != undefined) {
console.error(savedOrder.error)

View File

@@ -35,4 +35,12 @@ simRoutes.post("/test", simController.test())
// Proceso especifico de ALAI para liberar sims canceladas
simRoutes.post("/free", simController.free())
// Proxy
const proxySimConnections =
simRoutes.post("/simconnections/sim/activate",)
simRoutes.post("/simconnections/sim/pause")
export { simRoutes }

View File

@@ -53,6 +53,7 @@
"cors": "*",
"dotenv": "*",
"express": "*",
"http-proxy-middleware": "^3.0.5",
"sim-shared": "sim-shared:*",
"typescript": "*"
},

View File

@@ -12,7 +12,7 @@ export type ObjeniousOperation = {
id?: number;
/** Uuid del mensaje asociado a la operacion */
correlation_id?: string;
operation: "activate" | string; // TODO: completar y actualizar
operation: "activate" | "suspend" | "terminate" | string; // TODO: completar y actualizar
retry_count?: number;
max_retry?: number;
max_date_retry?: string | null;

View File

@@ -576,6 +576,15 @@ __metadata:
languageName: node
linkType: hard
"@types/http-proxy@npm:^1.17.15":
version: 1.17.17
resolution: "@types/http-proxy@npm:1.17.17"
dependencies:
"@types/node": "npm:*"
checksum: 10/893e46e12be576baa471cf2fc13a4f0e413eaf30a5850de8fdbea3040e138ad4171234c59b986cf7137ff20a1582b254bf0c44cfd715d5ed772e1ab94dd75cd1
languageName: node
linkType: hard
"@types/methods@npm:^1.1.4":
version: 1.1.4
resolution: "@types/methods@npm:1.1.4"
@@ -1154,7 +1163,7 @@ __metadata:
languageName: node
linkType: hard
"debug@npm:4, debug@npm:^4.1.1, debug@npm:^4.3.4, debug@npm:^4.3.7, debug@npm:^4.4.0, debug@npm:^4.4.3":
"debug@npm:4, debug@npm:^4.1.1, debug@npm:^4.3.4, debug@npm:^4.3.6, debug@npm:^4.3.7, debug@npm:^4.4.0, debug@npm:^4.4.3":
version: 4.4.3
resolution: "debug@npm:4.4.3"
dependencies:
@@ -1413,6 +1422,13 @@ __metadata:
languageName: node
linkType: hard
"eventemitter3@npm:^4.0.0":
version: 4.0.7
resolution: "eventemitter3@npm:4.0.7"
checksum: 10/8030029382404942c01d0037079f1b1bc8fed524b5849c237b80549b01e2fc49709e1d0c557fa65ca4498fc9e24cff1475ef7b855121fcc15f9d61f93e282346
languageName: node
linkType: hard
"expect-type@npm:^1.2.2":
version: 1.3.0
resolution: "expect-type@npm:1.3.0"
@@ -1527,6 +1543,16 @@ __metadata:
languageName: node
linkType: hard
"follow-redirects@npm:^1.0.0":
version: 1.16.0
resolution: "follow-redirects@npm:1.16.0"
peerDependenciesMeta:
debug:
optional: true
checksum: 10/3fbe3d80b3b544c22705d837aa5d4a0d07a740d913534a2620b0a004c610af4148e3b58723536dd099aaa1c9d3a155964bde9665d6e5cb331460809a1fc572fd
languageName: node
linkType: hard
"follow-redirects@npm:^1.15.11":
version: 1.15.11
resolution: "follow-redirects@npm:1.15.11"
@@ -1788,6 +1814,31 @@ __metadata:
languageName: node
linkType: hard
"http-proxy-middleware@npm:^3.0.5":
version: 3.0.5
resolution: "http-proxy-middleware@npm:3.0.5"
dependencies:
"@types/http-proxy": "npm:^1.17.15"
debug: "npm:^4.3.6"
http-proxy: "npm:^1.18.1"
is-glob: "npm:^4.0.3"
is-plain-object: "npm:^5.0.0"
micromatch: "npm:^4.0.8"
checksum: 10/83c1956be6451a5f4a2f3c7b3d84085dbd47e1efb5bb684c1ed668a6606c18c7c07be823b0dbba1326955b64cf88de2672492940b0b48d140215fbdb06105c9a
languageName: node
linkType: hard
"http-proxy@npm:^1.18.1":
version: 1.18.1
resolution: "http-proxy@npm:1.18.1"
dependencies:
eventemitter3: "npm:^4.0.0"
follow-redirects: "npm:^1.0.0"
requires-port: "npm:^1.0.0"
checksum: 10/2489e98aba70adbfd8b9d41ed1ff43528be4598c88616c558b109a09eaffe4bb35e551b6c75ac42ed7d948bb7530a22a2be6ef4f0cecacb5927be139f4274594
languageName: node
linkType: hard
"https-proxy-agent@npm:^7.0.1":
version: 7.0.6
resolution: "https-proxy-agent@npm:7.0.6"
@@ -1865,7 +1916,7 @@ __metadata:
languageName: node
linkType: hard
"is-glob@npm:^4.0.1, is-glob@npm:~4.0.1":
"is-glob@npm:^4.0.1, is-glob@npm:^4.0.3, is-glob@npm:~4.0.1":
version: 4.0.3
resolution: "is-glob@npm:4.0.3"
dependencies:
@@ -1881,6 +1932,13 @@ __metadata:
languageName: node
linkType: hard
"is-plain-object@npm:^5.0.0":
version: 5.0.0
resolution: "is-plain-object@npm:5.0.0"
checksum: 10/e32d27061eef62c0847d303125440a38660517e586f2f3db7c9d179ae5b6674ab0f469d519b2e25c147a1a3bc87156d0d5f4d8821e0ce4a9ee7fe1fcf11ce45c
languageName: node
linkType: hard
"is-promise@npm:^4.0.0":
version: 4.0.0
resolution: "is-promise@npm:4.0.0"
@@ -2842,6 +2900,7 @@ __metadata:
cors: "npm:*"
dotenv: "npm:*"
express: "npm:*"
http-proxy-middleware: "npm:^3.0.5"
prettier: "npm:*"
sim-shared: "sim-shared:*"
supertest: "npm:*"