@fiado/type-kit 3.162.0 → 3.164.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/_test_/unit/remittance/resolveExceptionCode.test.ts +37 -0
- package/bin/remittance/dtos/RemittanceExceptionCatalog.d.ts +13 -0
- package/bin/remittance/dtos/RemittanceExceptionCatalog.js +88 -0
- package/bin/remittance/dtos/index.d.ts +1 -0
- package/bin/remittance/dtos/index.js +1 -0
- package/bin/remittance/enums/RemittanceExceptionCode.d.ts +16 -0
- package/bin/remittance/enums/RemittanceExceptionCode.js +24 -0
- package/bin/remittance/enums/index.d.ts +1 -0
- package/bin/remittance/enums/index.js +1 -0
- package/bin/walletFunding/dtos/ApplyWalletFundingRequest.d.ts +21 -0
- package/bin/walletFunding/dtos/ApplyWalletFundingRequest.js +68 -0
- package/bin/walletFunding/dtos/ApplyWalletFundingResponse.d.ts +10 -0
- package/bin/walletFunding/dtos/ApplyWalletFundingResponse.js +6 -0
- package/bin/walletFunding/dtos/GetExposureStateResponse.d.ts +9 -0
- package/bin/walletFunding/dtos/GetExposureStateResponse.js +7 -0
- package/bin/walletFunding/dtos/ReleaseExposureRequest.d.ts +10 -0
- package/bin/walletFunding/dtos/ReleaseExposureRequest.js +37 -0
- package/bin/walletFunding/dtos/ReleaseExposureResponse.d.ts +6 -0
- package/bin/walletFunding/dtos/ReleaseExposureResponse.js +6 -0
- package/bin/walletFunding/dtos/ReserveExposureRequest.d.ts +13 -0
- package/bin/walletFunding/dtos/ReserveExposureRequest.js +47 -0
- package/bin/walletFunding/dtos/ReserveExposureResponse.d.ts +8 -0
- package/bin/walletFunding/dtos/ReserveExposureResponse.js +6 -0
- package/bin/walletFunding/dtos/index.d.ts +7 -0
- package/bin/walletFunding/dtos/index.js +7 -0
- package/bin/walletFunding/enums/FundingVerificationOutcomeEnum.d.ts +6 -0
- package/bin/walletFunding/enums/FundingVerificationOutcomeEnum.js +10 -0
- package/bin/walletFunding/enums/ServiceStateEnum.d.ts +6 -0
- package/bin/walletFunding/enums/ServiceStateEnum.js +10 -0
- package/bin/walletFunding/enums/WalletFundingPaymentStatusEnum.d.ts +4 -0
- package/bin/walletFunding/enums/WalletFundingPaymentStatusEnum.js +4 -0
- package/bin/walletFunding/enums/index.d.ts +2 -0
- package/bin/walletFunding/enums/index.js +2 -0
- package/bin/walletFunding/schemas/AggregateExposureStateSchema.d.ts +30 -0
- package/bin/walletFunding/schemas/AggregateExposureStateSchema.js +32 -0
- package/bin/walletFunding/schemas/index.d.ts +1 -0
- package/bin/walletFunding/schemas/index.js +1 -0
- package/package.json +1 -1
- package/src/remittance/dtos/RemittanceExceptionCatalog.ts +97 -0
- package/src/remittance/dtos/index.ts +1 -0
- package/src/remittance/enums/RemittanceExceptionCode.ts +20 -0
- package/src/remittance/enums/index.ts +1 -0
- package/src/walletFunding/dtos/ApplyWalletFundingRequest.ts +23 -0
- package/src/walletFunding/dtos/ApplyWalletFundingResponse.ts +11 -0
- package/src/walletFunding/dtos/GetExposureStateResponse.ts +10 -0
- package/src/walletFunding/dtos/ReleaseExposureRequest.ts +12 -0
- package/src/walletFunding/dtos/ReleaseExposureResponse.ts +7 -0
- package/src/walletFunding/dtos/ReserveExposureRequest.ts +15 -0
- package/src/walletFunding/dtos/ReserveExposureResponse.ts +9 -0
- package/src/walletFunding/dtos/index.ts +7 -0
- package/src/walletFunding/enums/FundingVerificationOutcomeEnum.ts +6 -0
- package/src/walletFunding/enums/ServiceStateEnum.ts +6 -0
- package/src/walletFunding/enums/WalletFundingPaymentStatusEnum.ts +4 -0
- package/src/walletFunding/enums/index.ts +2 -0
- package/src/walletFunding/schemas/AggregateExposureStateSchema.ts +32 -0
- package/src/walletFunding/schemas/index.ts +1 -0
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { RemittanceExceptionCode } from "../../../src/remittance/enums/RemittanceExceptionCode";
|
|
2
|
+
import {
|
|
3
|
+
REMITTANCE_EXCEPTION_CATALOG,
|
|
4
|
+
resolveExceptionCode,
|
|
5
|
+
} from "../../../src/remittance/dtos/RemittanceExceptionCatalog";
|
|
6
|
+
|
|
7
|
+
describe("resolveExceptionCode", () => {
|
|
8
|
+
it("HOLD con sub-status de timeout → HOLD_PROVIDER_TIMEOUT", () => {
|
|
9
|
+
expect(resolveExceptionCode("HOLD", "SENDMONEY_TIMEOUT")).toBe(RemittanceExceptionCode.HOLD_PROVIDER_TIMEOUT);
|
|
10
|
+
});
|
|
11
|
+
it("HOLD sin sub-status → HOLD_GENERIC", () => {
|
|
12
|
+
expect(resolveExceptionCode("HOLD")).toBe(RemittanceExceptionCode.HOLD_GENERIC);
|
|
13
|
+
});
|
|
14
|
+
it("CANCELLATION con cancelReason USER_REQUESTED → CANCEL_USER_REQUESTED", () => {
|
|
15
|
+
expect(resolveExceptionCode("CANCELLATION_IN_PROGRESS", undefined, "USER_REQUESTED")).toBe(RemittanceExceptionCode.CANCEL_USER_REQUESTED);
|
|
16
|
+
});
|
|
17
|
+
it("IN_PROCESS → INPROCESS_STALE_24H", () => {
|
|
18
|
+
expect(resolveExceptionCode("IN_PROCESS")).toBe(RemittanceExceptionCode.INPROCESS_STALE_24H);
|
|
19
|
+
});
|
|
20
|
+
it("HOLD con sub-status desconocido → HOLD_GENERIC (no UNKNOWN)", () => {
|
|
21
|
+
const code = resolveExceptionCode("HOLD", "ZZZ_NUEVO_CODIGO_UNIR");
|
|
22
|
+
expect(code).toBe(RemittanceExceptionCode.HOLD_GENERIC);
|
|
23
|
+
expect(REMITTANCE_EXCEPTION_CATALOG[code]).toBeDefined();
|
|
24
|
+
});
|
|
25
|
+
it("status totalmente inesperado → UNKNOWN con catálogo definido", () => {
|
|
26
|
+
const code = resolveExceptionCode("PLASMA");
|
|
27
|
+
expect(code).toBe(RemittanceExceptionCode.UNKNOWN);
|
|
28
|
+
expect(REMITTANCE_EXCEPTION_CATALOG[code].motivo.length).toBeGreaterThan(0);
|
|
29
|
+
});
|
|
30
|
+
it("todo our-code tiene entrada de catálogo (motivo+acción no vacíos)", () => {
|
|
31
|
+
for (const code of Object.values(RemittanceExceptionCode)) {
|
|
32
|
+
const entry = REMITTANCE_EXCEPTION_CATALOG[code];
|
|
33
|
+
expect(entry?.motivo?.length ?? 0).toBeGreaterThan(0);
|
|
34
|
+
expect(entry?.accionSugerida?.length ?? 0).toBeGreaterThan(0);
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { RemittanceExceptionCode } from "../enums/RemittanceExceptionCode";
|
|
2
|
+
export interface ExceptionCatalogEntry {
|
|
3
|
+
motivo: string;
|
|
4
|
+
accionSugerida: string;
|
|
5
|
+
}
|
|
6
|
+
/** our-code → texto ya traducido (español). El front lo muestra tal cual. */
|
|
7
|
+
export declare const REMITTANCE_EXCEPTION_CATALOG: Record<RemittanceExceptionCode, ExceptionCatalogEntry>;
|
|
8
|
+
/**
|
|
9
|
+
* Resuelve el our-code a partir del status + los códigos crudos de UNIR.
|
|
10
|
+
* Fallback por bucket (HOLD_GENERIC / CANCEL_GENERIC / INPROCESS_STALE_24H) y
|
|
11
|
+
* UNKNOWN para status inesperados. Nunca lanza.
|
|
12
|
+
*/
|
|
13
|
+
export declare function resolveExceptionCode(status: string, unirSubStatus?: string | null, cancelReason?: string | null): RemittanceExceptionCode;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.REMITTANCE_EXCEPTION_CATALOG = void 0;
|
|
4
|
+
exports.resolveExceptionCode = resolveExceptionCode;
|
|
5
|
+
const RemittanceExceptionCode_1 = require("../enums/RemittanceExceptionCode");
|
|
6
|
+
/** our-code → texto ya traducido (español). El front lo muestra tal cual. */
|
|
7
|
+
exports.REMITTANCE_EXCEPTION_CATALOG = {
|
|
8
|
+
[RemittanceExceptionCode_1.RemittanceExceptionCode.HOLD_DISPERSAL_UNCONFIRMED]: {
|
|
9
|
+
motivo: "El proveedor no ha confirmado la dispersión de fondos.",
|
|
10
|
+
accionSugerida: "Investigar el estado de la dispersión. Si supera 48h en HOLD, escalar a soporte del proveedor.",
|
|
11
|
+
},
|
|
12
|
+
[RemittanceExceptionCode_1.RemittanceExceptionCode.HOLD_PROVIDER_TIMEOUT]: {
|
|
13
|
+
motivo: "Tiempo de espera agotado con el proveedor · sin confirmar dispersión.",
|
|
14
|
+
accionSugerida: "Investigar el estado de la transacción. Si supera 48h en HOLD, escalar a soporte del proveedor.",
|
|
15
|
+
},
|
|
16
|
+
[RemittanceExceptionCode_1.RemittanceExceptionCode.HOLD_COMPLIANCE_REVIEW]: {
|
|
17
|
+
motivo: "El proveedor puso la transacción en revisión de cumplimiento.",
|
|
18
|
+
accionSugerida: "Monitorear. Si el proveedor no libera en 72h, escalar a soporte.",
|
|
19
|
+
},
|
|
20
|
+
[RemittanceExceptionCode_1.RemittanceExceptionCode.HOLD_GENERIC]: {
|
|
21
|
+
motivo: "El proveedor marcó la transacción con un problema.",
|
|
22
|
+
accionSugerida: "Investigar el estado de la transacción. Si supera 48h en HOLD, escalar a soporte del proveedor.",
|
|
23
|
+
},
|
|
24
|
+
[RemittanceExceptionCode_1.RemittanceExceptionCode.CANCEL_USER_REQUESTED]: {
|
|
25
|
+
motivo: "El cliente canceló la transacción. Esperando que el proveedor confirme la devolución de fondos.",
|
|
26
|
+
accionSugerida: "Monitorear. La devolución al monedero se dispara automáticamente al confirmar el proveedor. Si supera 72h, escalar a tesorería.",
|
|
27
|
+
},
|
|
28
|
+
[RemittanceExceptionCode_1.RemittanceExceptionCode.CANCEL_PROVIDER_INITIATED]: {
|
|
29
|
+
motivo: "El proveedor inició la cancelación de la transacción.",
|
|
30
|
+
accionSugerida: "Monitorear la confirmación de devolución. Si supera 72h, escalar a tesorería.",
|
|
31
|
+
},
|
|
32
|
+
[RemittanceExceptionCode_1.RemittanceExceptionCode.CANCEL_GENERIC]: {
|
|
33
|
+
motivo: "Cancelación en proceso. Esperando confirmación del proveedor.",
|
|
34
|
+
accionSugerida: "Monitorear. Si supera 72h sin confirmación, escalar a tesorería.",
|
|
35
|
+
},
|
|
36
|
+
[RemittanceExceptionCode_1.RemittanceExceptionCode.INPROCESS_STALE_24H]: {
|
|
37
|
+
motivo: "La transacción lleva más de 24h sin avanzar a PAYABLE/PAID.",
|
|
38
|
+
accionSugerida: "Verificar el sync con el proveedor. Si no responde, escalar a soporte con el número de transacción.",
|
|
39
|
+
},
|
|
40
|
+
[RemittanceExceptionCode_1.RemittanceExceptionCode.UNKNOWN]: {
|
|
41
|
+
motivo: "Situación no catalogada.",
|
|
42
|
+
accionSugerida: "Revisar manualmente el detalle de la transacción y escalar si aplica.",
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* Mapa de códigos CRUDOS de UNIR (sub-status) → our-code.
|
|
47
|
+
* Se amplía minando el PDF de UNIR (tarea aparte). Las claves se normalizan a MAYÚSCULAS.
|
|
48
|
+
*/
|
|
49
|
+
const UNIR_HOLD_SUBSTATUS_TO_CODE = {
|
|
50
|
+
SENDMONEY_TIMEOUT: RemittanceExceptionCode_1.RemittanceExceptionCode.HOLD_PROVIDER_TIMEOUT,
|
|
51
|
+
TIMEOUT: RemittanceExceptionCode_1.RemittanceExceptionCode.HOLD_PROVIDER_TIMEOUT,
|
|
52
|
+
DISPERSAL_UNCONFIRMED: RemittanceExceptionCode_1.RemittanceExceptionCode.HOLD_DISPERSAL_UNCONFIRMED,
|
|
53
|
+
COMPLIANCE_REVIEW: RemittanceExceptionCode_1.RemittanceExceptionCode.HOLD_COMPLIANCE_REVIEW,
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* Mapa de cancelReason → our-code.
|
|
57
|
+
* Incluye tanto los valores reales de RemittanceCancelledByEnum (USER / SYSTEM)
|
|
58
|
+
* como los códigos semánticos de UNIR (USER_REQUESTED / PROVIDER_INITIATED).
|
|
59
|
+
*/
|
|
60
|
+
const UNIR_CANCEL_REASON_TO_CODE = {
|
|
61
|
+
// Valores de RemittanceCancelledByEnum
|
|
62
|
+
USER: RemittanceExceptionCode_1.RemittanceExceptionCode.CANCEL_USER_REQUESTED,
|
|
63
|
+
SYSTEM: RemittanceExceptionCode_1.RemittanceExceptionCode.CANCEL_GENERIC,
|
|
64
|
+
// Códigos semánticos de UNIR
|
|
65
|
+
USER_REQUESTED: RemittanceExceptionCode_1.RemittanceExceptionCode.CANCEL_USER_REQUESTED,
|
|
66
|
+
PROVIDER_INITIATED: RemittanceExceptionCode_1.RemittanceExceptionCode.CANCEL_PROVIDER_INITIATED,
|
|
67
|
+
};
|
|
68
|
+
/**
|
|
69
|
+
* Resuelve el our-code a partir del status + los códigos crudos de UNIR.
|
|
70
|
+
* Fallback por bucket (HOLD_GENERIC / CANCEL_GENERIC / INPROCESS_STALE_24H) y
|
|
71
|
+
* UNKNOWN para status inesperados. Nunca lanza.
|
|
72
|
+
*/
|
|
73
|
+
function resolveExceptionCode(status, unirSubStatus, cancelReason) {
|
|
74
|
+
switch (status) {
|
|
75
|
+
case "HOLD": {
|
|
76
|
+
const key = (unirSubStatus ?? "").trim().toUpperCase();
|
|
77
|
+
return UNIR_HOLD_SUBSTATUS_TO_CODE[key] ?? RemittanceExceptionCode_1.RemittanceExceptionCode.HOLD_GENERIC;
|
|
78
|
+
}
|
|
79
|
+
case "CANCELLATION_IN_PROGRESS": {
|
|
80
|
+
const key = (cancelReason ?? "").trim().toUpperCase();
|
|
81
|
+
return UNIR_CANCEL_REASON_TO_CODE[key] ?? RemittanceExceptionCode_1.RemittanceExceptionCode.CANCEL_GENERIC;
|
|
82
|
+
}
|
|
83
|
+
case "IN_PROCESS":
|
|
84
|
+
return RemittanceExceptionCode_1.RemittanceExceptionCode.INPROCESS_STALE_24H;
|
|
85
|
+
default:
|
|
86
|
+
return RemittanceExceptionCode_1.RemittanceExceptionCode.UNKNOWN;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
@@ -60,3 +60,4 @@ __exportStar(require("./RemittancePricing"), exports);
|
|
|
60
60
|
__exportStar(require("./RemittancePromotion"), exports);
|
|
61
61
|
__exportStar(require("./RemittanceRule"), exports);
|
|
62
62
|
__exportStar(require("./RemittancePricingTable"), exports);
|
|
63
|
+
__exportStar(require("./RemittanceExceptionCatalog"), exports);
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Códigos propios ("our-code") de excepciones de remesas. Traducimos los códigos
|
|
3
|
+
* crudos de UNIR a ESTE formato; los crudos NUNCA se exponen. UNKNOWN es el
|
|
4
|
+
* fallback para sub-status/motivos no catalogados (nuevos o desconocidos).
|
|
5
|
+
*/
|
|
6
|
+
export declare enum RemittanceExceptionCode {
|
|
7
|
+
HOLD_DISPERSAL_UNCONFIRMED = "HOLD_DISPERSAL_UNCONFIRMED",
|
|
8
|
+
HOLD_PROVIDER_TIMEOUT = "HOLD_PROVIDER_TIMEOUT",
|
|
9
|
+
HOLD_COMPLIANCE_REVIEW = "HOLD_COMPLIANCE_REVIEW",
|
|
10
|
+
HOLD_GENERIC = "HOLD_GENERIC",
|
|
11
|
+
CANCEL_USER_REQUESTED = "CANCEL_USER_REQUESTED",
|
|
12
|
+
CANCEL_PROVIDER_INITIATED = "CANCEL_PROVIDER_INITIATED",
|
|
13
|
+
CANCEL_GENERIC = "CANCEL_GENERIC",
|
|
14
|
+
INPROCESS_STALE_24H = "INPROCESS_STALE_24H",
|
|
15
|
+
UNKNOWN = "UNKNOWN"
|
|
16
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RemittanceExceptionCode = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Códigos propios ("our-code") de excepciones de remesas. Traducimos los códigos
|
|
6
|
+
* crudos de UNIR a ESTE formato; los crudos NUNCA se exponen. UNKNOWN es el
|
|
7
|
+
* fallback para sub-status/motivos no catalogados (nuevos o desconocidos).
|
|
8
|
+
*/
|
|
9
|
+
var RemittanceExceptionCode;
|
|
10
|
+
(function (RemittanceExceptionCode) {
|
|
11
|
+
// HOLD (el proveedor marcó la tx)
|
|
12
|
+
RemittanceExceptionCode["HOLD_DISPERSAL_UNCONFIRMED"] = "HOLD_DISPERSAL_UNCONFIRMED";
|
|
13
|
+
RemittanceExceptionCode["HOLD_PROVIDER_TIMEOUT"] = "HOLD_PROVIDER_TIMEOUT";
|
|
14
|
+
RemittanceExceptionCode["HOLD_COMPLIANCE_REVIEW"] = "HOLD_COMPLIANCE_REVIEW";
|
|
15
|
+
RemittanceExceptionCode["HOLD_GENERIC"] = "HOLD_GENERIC";
|
|
16
|
+
// Cancelación en proceso
|
|
17
|
+
RemittanceExceptionCode["CANCEL_USER_REQUESTED"] = "CANCEL_USER_REQUESTED";
|
|
18
|
+
RemittanceExceptionCode["CANCEL_PROVIDER_INITIATED"] = "CANCEL_PROVIDER_INITIATED";
|
|
19
|
+
RemittanceExceptionCode["CANCEL_GENERIC"] = "CANCEL_GENERIC";
|
|
20
|
+
// In-process atorada > 24h
|
|
21
|
+
RemittanceExceptionCode["INPROCESS_STALE_24H"] = "INPROCESS_STALE_24H";
|
|
22
|
+
// Fallback
|
|
23
|
+
RemittanceExceptionCode["UNKNOWN"] = "UNKNOWN";
|
|
24
|
+
})(RemittanceExceptionCode || (exports.RemittanceExceptionCode = RemittanceExceptionCode = {}));
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { FundingVerificationOutcomeEnum } from "../enums/FundingVerificationOutcomeEnum";
|
|
2
|
+
/**
|
|
3
|
+
* Request del endpoint privado `POST /funding/apply` del connector.
|
|
4
|
+
*
|
|
5
|
+
* Lo invoca `db-conciliacion` cuando la verificación autoritativa (poll al
|
|
6
|
+
* portal del Proveedor, ~10 min) resuelve. Dispara el acreditamiento diferido:
|
|
7
|
+
* el webhook `payment` NO acredita — solo deja el pago en IN_VERIFICATION;
|
|
8
|
+
* este apply es la segunda ejecución (async) que mueve el dinero.
|
|
9
|
+
*/
|
|
10
|
+
export declare class ApplyWalletFundingRequest {
|
|
11
|
+
providerName: string;
|
|
12
|
+
providerTxId: string;
|
|
13
|
+
providerReference: string;
|
|
14
|
+
directoryId: string;
|
|
15
|
+
walletAccountId: string;
|
|
16
|
+
amount: number;
|
|
17
|
+
currencyCode: string;
|
|
18
|
+
paidAt: string;
|
|
19
|
+
/** Resultado de la verificación. APPROVED → acredita (settle); REJECTED → revierte. */
|
|
20
|
+
outcome: FundingVerificationOutcomeEnum;
|
|
21
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
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
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.ApplyWalletFundingRequest = void 0;
|
|
13
|
+
const class_validator_1 = require("class-validator");
|
|
14
|
+
const FundingVerificationOutcomeEnum_1 = require("../enums/FundingVerificationOutcomeEnum");
|
|
15
|
+
/**
|
|
16
|
+
* Request del endpoint privado `POST /funding/apply` del connector.
|
|
17
|
+
*
|
|
18
|
+
* Lo invoca `db-conciliacion` cuando la verificación autoritativa (poll al
|
|
19
|
+
* portal del Proveedor, ~10 min) resuelve. Dispara el acreditamiento diferido:
|
|
20
|
+
* el webhook `payment` NO acredita — solo deja el pago en IN_VERIFICATION;
|
|
21
|
+
* este apply es la segunda ejecución (async) que mueve el dinero.
|
|
22
|
+
*/
|
|
23
|
+
class ApplyWalletFundingRequest {
|
|
24
|
+
}
|
|
25
|
+
exports.ApplyWalletFundingRequest = ApplyWalletFundingRequest;
|
|
26
|
+
__decorate([
|
|
27
|
+
(0, class_validator_1.IsString)(),
|
|
28
|
+
(0, class_validator_1.MaxLength)(32),
|
|
29
|
+
__metadata("design:type", String)
|
|
30
|
+
], ApplyWalletFundingRequest.prototype, "providerName", void 0);
|
|
31
|
+
__decorate([
|
|
32
|
+
(0, class_validator_1.IsString)(),
|
|
33
|
+
(0, class_validator_1.MaxLength)(64),
|
|
34
|
+
__metadata("design:type", String)
|
|
35
|
+
], ApplyWalletFundingRequest.prototype, "providerTxId", void 0);
|
|
36
|
+
__decorate([
|
|
37
|
+
(0, class_validator_1.IsString)(),
|
|
38
|
+
(0, class_validator_1.MaxLength)(128),
|
|
39
|
+
__metadata("design:type", String)
|
|
40
|
+
], ApplyWalletFundingRequest.prototype, "providerReference", void 0);
|
|
41
|
+
__decorate([
|
|
42
|
+
(0, class_validator_1.IsString)(),
|
|
43
|
+
(0, class_validator_1.MaxLength)(64),
|
|
44
|
+
__metadata("design:type", String)
|
|
45
|
+
], ApplyWalletFundingRequest.prototype, "directoryId", void 0);
|
|
46
|
+
__decorate([
|
|
47
|
+
(0, class_validator_1.IsString)(),
|
|
48
|
+
(0, class_validator_1.MaxLength)(64),
|
|
49
|
+
__metadata("design:type", String)
|
|
50
|
+
], ApplyWalletFundingRequest.prototype, "walletAccountId", void 0);
|
|
51
|
+
__decorate([
|
|
52
|
+
(0, class_validator_1.IsNumber)(),
|
|
53
|
+
(0, class_validator_1.IsPositive)(),
|
|
54
|
+
__metadata("design:type", Number)
|
|
55
|
+
], ApplyWalletFundingRequest.prototype, "amount", void 0);
|
|
56
|
+
__decorate([
|
|
57
|
+
(0, class_validator_1.IsString)(),
|
|
58
|
+
(0, class_validator_1.Length)(3, 3),
|
|
59
|
+
__metadata("design:type", String)
|
|
60
|
+
], ApplyWalletFundingRequest.prototype, "currencyCode", void 0);
|
|
61
|
+
__decorate([
|
|
62
|
+
(0, class_validator_1.IsDateString)(),
|
|
63
|
+
__metadata("design:type", String)
|
|
64
|
+
], ApplyWalletFundingRequest.prototype, "paidAt", void 0);
|
|
65
|
+
__decorate([
|
|
66
|
+
(0, class_validator_1.IsEnum)(FundingVerificationOutcomeEnum_1.FundingVerificationOutcomeEnum),
|
|
67
|
+
__metadata("design:type", String)
|
|
68
|
+
], ApplyWalletFundingRequest.prototype, "outcome", void 0);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { WalletFundingPaymentStatusEnum } from "../enums/WalletFundingPaymentStatusEnum";
|
|
2
|
+
import { WalletFundingErrorCodeEnum } from "../enums/WalletFundingErrorCodeEnum";
|
|
3
|
+
export declare class ApplyWalletFundingResponse {
|
|
4
|
+
/** Estado del pago tras aplicar la verificación: APPLIED (acreditado) o REVERSED. */
|
|
5
|
+
status: WalletFundingPaymentStatusEnum;
|
|
6
|
+
/** Folio del processor si se acreditó (idempotente si ya estaba APPLIED). */
|
|
7
|
+
processorTransactionNumber?: string;
|
|
8
|
+
errorCode?: WalletFundingErrorCodeEnum;
|
|
9
|
+
message?: string;
|
|
10
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ServiceStateEnum } from "../enums/ServiceStateEnum";
|
|
2
|
+
/** Response de `wallet-funding-rules` (GET /state). Estado del cap + breaker. */
|
|
3
|
+
export declare class GetExposureStateResponse {
|
|
4
|
+
currentExposureAmount: number;
|
|
5
|
+
serviceState: ServiceStateEnum;
|
|
6
|
+
capThreshold: number;
|
|
7
|
+
alertThreshold: number;
|
|
8
|
+
reactivationThreshold: number;
|
|
9
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GetExposureStateResponse = void 0;
|
|
4
|
+
/** Response de `wallet-funding-rules` (GET /state). Estado del cap + breaker. */
|
|
5
|
+
class GetExposureStateResponse {
|
|
6
|
+
}
|
|
7
|
+
exports.GetExposureStateResponse = GetExposureStateResponse;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Request de `wallet-funding-rules` (POST /release). Lo llama la conciliación
|
|
3
|
+
* (db-conciliacion) al liquidar el SPEI, o el flujo de rechazo/reverso.
|
|
4
|
+
* Libera monto de la exposición agregada; puede reactivar el servicio.
|
|
5
|
+
*/
|
|
6
|
+
export declare class ReleaseExposureRequest {
|
|
7
|
+
amount: number;
|
|
8
|
+
currencyCode: string;
|
|
9
|
+
providerTxId?: string;
|
|
10
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
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
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.ReleaseExposureRequest = void 0;
|
|
13
|
+
const class_validator_1 = require("class-validator");
|
|
14
|
+
/**
|
|
15
|
+
* Request de `wallet-funding-rules` (POST /release). Lo llama la conciliación
|
|
16
|
+
* (db-conciliacion) al liquidar el SPEI, o el flujo de rechazo/reverso.
|
|
17
|
+
* Libera monto de la exposición agregada; puede reactivar el servicio.
|
|
18
|
+
*/
|
|
19
|
+
class ReleaseExposureRequest {
|
|
20
|
+
}
|
|
21
|
+
exports.ReleaseExposureRequest = ReleaseExposureRequest;
|
|
22
|
+
__decorate([
|
|
23
|
+
(0, class_validator_1.IsNumber)(),
|
|
24
|
+
(0, class_validator_1.IsPositive)(),
|
|
25
|
+
__metadata("design:type", Number)
|
|
26
|
+
], ReleaseExposureRequest.prototype, "amount", void 0);
|
|
27
|
+
__decorate([
|
|
28
|
+
(0, class_validator_1.IsString)(),
|
|
29
|
+
(0, class_validator_1.Length)(3, 3),
|
|
30
|
+
__metadata("design:type", String)
|
|
31
|
+
], ReleaseExposureRequest.prototype, "currencyCode", void 0);
|
|
32
|
+
__decorate([
|
|
33
|
+
(0, class_validator_1.IsOptional)(),
|
|
34
|
+
(0, class_validator_1.IsString)(),
|
|
35
|
+
(0, class_validator_1.MaxLength)(64),
|
|
36
|
+
__metadata("design:type", String)
|
|
37
|
+
], ReleaseExposureRequest.prototype, "providerTxId", void 0);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Request de `wallet-funding-rules` (POST /reserve). Lo llama el processor en
|
|
3
|
+
* `walletFundingValidate` (cap gate). Reserva monto contra la exposición
|
|
4
|
+
* agregada FSA de forma atómica (single-region + ConditionExpression).
|
|
5
|
+
*/
|
|
6
|
+
export declare class ReserveExposureRequest {
|
|
7
|
+
directoryId: string;
|
|
8
|
+
amount: number;
|
|
9
|
+
currencyCode: string;
|
|
10
|
+
providerName: string;
|
|
11
|
+
/** Idempotencia: referencia/tx del Proveedor para no doble-reservar en reintentos. */
|
|
12
|
+
providerTxId?: string;
|
|
13
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
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
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.ReserveExposureRequest = void 0;
|
|
13
|
+
const class_validator_1 = require("class-validator");
|
|
14
|
+
/**
|
|
15
|
+
* Request de `wallet-funding-rules` (POST /reserve). Lo llama el processor en
|
|
16
|
+
* `walletFundingValidate` (cap gate). Reserva monto contra la exposición
|
|
17
|
+
* agregada FSA de forma atómica (single-region + ConditionExpression).
|
|
18
|
+
*/
|
|
19
|
+
class ReserveExposureRequest {
|
|
20
|
+
}
|
|
21
|
+
exports.ReserveExposureRequest = ReserveExposureRequest;
|
|
22
|
+
__decorate([
|
|
23
|
+
(0, class_validator_1.IsString)(),
|
|
24
|
+
(0, class_validator_1.MaxLength)(64),
|
|
25
|
+
__metadata("design:type", String)
|
|
26
|
+
], ReserveExposureRequest.prototype, "directoryId", void 0);
|
|
27
|
+
__decorate([
|
|
28
|
+
(0, class_validator_1.IsNumber)(),
|
|
29
|
+
(0, class_validator_1.IsPositive)(),
|
|
30
|
+
__metadata("design:type", Number)
|
|
31
|
+
], ReserveExposureRequest.prototype, "amount", void 0);
|
|
32
|
+
__decorate([
|
|
33
|
+
(0, class_validator_1.IsString)(),
|
|
34
|
+
(0, class_validator_1.Length)(3, 3),
|
|
35
|
+
__metadata("design:type", String)
|
|
36
|
+
], ReserveExposureRequest.prototype, "currencyCode", void 0);
|
|
37
|
+
__decorate([
|
|
38
|
+
(0, class_validator_1.IsString)(),
|
|
39
|
+
(0, class_validator_1.MaxLength)(32),
|
|
40
|
+
__metadata("design:type", String)
|
|
41
|
+
], ReserveExposureRequest.prototype, "providerName", void 0);
|
|
42
|
+
__decorate([
|
|
43
|
+
(0, class_validator_1.IsOptional)(),
|
|
44
|
+
(0, class_validator_1.IsString)(),
|
|
45
|
+
(0, class_validator_1.MaxLength)(64),
|
|
46
|
+
__metadata("design:type", String)
|
|
47
|
+
], ReserveExposureRequest.prototype, "providerTxId", void 0);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ServiceStateEnum } from "../enums/ServiceStateEnum";
|
|
2
|
+
export declare class ReserveExposureResponse {
|
|
3
|
+
/** true si la reserva pasó el cap; false si excede el cap o el servicio está SUSPENDED. */
|
|
4
|
+
allowed: boolean;
|
|
5
|
+
serviceState: ServiceStateEnum;
|
|
6
|
+
/** Motivo cuando allowed=false (ej. "CAP_REACHED", "SERVICE_SUSPENDED"). */
|
|
7
|
+
reason?: string;
|
|
8
|
+
}
|
|
@@ -21,3 +21,10 @@ export * from "./AuthorizeFundingRequest";
|
|
|
21
21
|
export * from "./AuthorizeFundingResponse";
|
|
22
22
|
export * from "./SettleWalletFundingRequest";
|
|
23
23
|
export * from "./SettleWalletFundingResponse";
|
|
24
|
+
export * from "./ApplyWalletFundingRequest";
|
|
25
|
+
export * from "./ApplyWalletFundingResponse";
|
|
26
|
+
export * from "./ReserveExposureRequest";
|
|
27
|
+
export * from "./ReserveExposureResponse";
|
|
28
|
+
export * from "./ReleaseExposureRequest";
|
|
29
|
+
export * from "./ReleaseExposureResponse";
|
|
30
|
+
export * from "./GetExposureStateResponse";
|
|
@@ -37,3 +37,10 @@ __exportStar(require("./AuthorizeFundingRequest"), exports);
|
|
|
37
37
|
__exportStar(require("./AuthorizeFundingResponse"), exports);
|
|
38
38
|
__exportStar(require("./SettleWalletFundingRequest"), exports);
|
|
39
39
|
__exportStar(require("./SettleWalletFundingResponse"), exports);
|
|
40
|
+
__exportStar(require("./ApplyWalletFundingRequest"), exports);
|
|
41
|
+
__exportStar(require("./ApplyWalletFundingResponse"), exports);
|
|
42
|
+
__exportStar(require("./ReserveExposureRequest"), exports);
|
|
43
|
+
__exportStar(require("./ReserveExposureResponse"), exports);
|
|
44
|
+
__exportStar(require("./ReleaseExposureRequest"), exports);
|
|
45
|
+
__exportStar(require("./ReleaseExposureResponse"), exports);
|
|
46
|
+
__exportStar(require("./GetExposureStateResponse"), exports);
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare enum FundingVerificationOutcomeEnum {
|
|
2
|
+
/** La verificación autoritativa confirmó el pago en el Proveedor → acreditar. */
|
|
3
|
+
APPROVED = "APPROVED",
|
|
4
|
+
/** La verificación determinó que el pago fue rechazado → revertir, no acreditar. */
|
|
5
|
+
REJECTED = "REJECTED"
|
|
6
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FundingVerificationOutcomeEnum = void 0;
|
|
4
|
+
var FundingVerificationOutcomeEnum;
|
|
5
|
+
(function (FundingVerificationOutcomeEnum) {
|
|
6
|
+
/** La verificación autoritativa confirmó el pago en el Proveedor → acreditar. */
|
|
7
|
+
FundingVerificationOutcomeEnum["APPROVED"] = "APPROVED";
|
|
8
|
+
/** La verificación determinó que el pago fue rechazado → revertir, no acreditar. */
|
|
9
|
+
FundingVerificationOutcomeEnum["REJECTED"] = "REJECTED";
|
|
10
|
+
})(FundingVerificationOutcomeEnum || (exports.FundingVerificationOutcomeEnum = FundingVerificationOutcomeEnum = {}));
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ServiceStateEnum = void 0;
|
|
4
|
+
var ServiceStateEnum;
|
|
5
|
+
(function (ServiceStateEnum) {
|
|
6
|
+
/** Servicio operando normal — se autorizan nuevos permisos de Cash In. */
|
|
7
|
+
ServiceStateEnum["NORMAL"] = "NORMAL";
|
|
8
|
+
/** Cap agregado FSA alcanzado — se rechazan nuevos permisos hasta reactivar. */
|
|
9
|
+
ServiceStateEnum["SUSPENDED"] = "SUSPENDED";
|
|
10
|
+
})(ServiceStateEnum || (exports.ServiceStateEnum = ServiceStateEnum = {}));
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
export declare enum WalletFundingPaymentStatusEnum {
|
|
2
2
|
/** Webhook consult procesado — pre-check OK, esperando webhook payment. */
|
|
3
3
|
CONSULTED = "CONSULTED",
|
|
4
|
+
/** Pago recibido (webhook payment), en verificación autoritativa; aún NO acreditado. El webhook lo escribe y termina; el crédito es una invocación async posterior (db-conciliacion → /funding/apply). */
|
|
5
|
+
IN_VERIFICATION = "IN_VERIFICATION",
|
|
4
6
|
/** Pago aplicado al wallet via processor.credit. */
|
|
5
7
|
APPLIED = "APPLIED",
|
|
8
|
+
/** Liquidado por el Proveedor a FSA (SPEI recibido); marcado en la conciliación semanal. */
|
|
9
|
+
SETTLED = "SETTLED",
|
|
6
10
|
/** Pago revertido via processor.reverse. */
|
|
7
11
|
REVERSED = "REVERSED",
|
|
8
12
|
/** Cliente ya gastó el dinero — ops resuelve manualmente. */
|
|
@@ -5,8 +5,12 @@ var WalletFundingPaymentStatusEnum;
|
|
|
5
5
|
(function (WalletFundingPaymentStatusEnum) {
|
|
6
6
|
/** Webhook consult procesado — pre-check OK, esperando webhook payment. */
|
|
7
7
|
WalletFundingPaymentStatusEnum["CONSULTED"] = "CONSULTED";
|
|
8
|
+
/** Pago recibido (webhook payment), en verificación autoritativa; aún NO acreditado. El webhook lo escribe y termina; el crédito es una invocación async posterior (db-conciliacion → /funding/apply). */
|
|
9
|
+
WalletFundingPaymentStatusEnum["IN_VERIFICATION"] = "IN_VERIFICATION";
|
|
8
10
|
/** Pago aplicado al wallet via processor.credit. */
|
|
9
11
|
WalletFundingPaymentStatusEnum["APPLIED"] = "APPLIED";
|
|
12
|
+
/** Liquidado por el Proveedor a FSA (SPEI recibido); marcado en la conciliación semanal. */
|
|
13
|
+
WalletFundingPaymentStatusEnum["SETTLED"] = "SETTLED";
|
|
10
14
|
/** Pago revertido via processor.reverse. */
|
|
11
15
|
WalletFundingPaymentStatusEnum["REVERSED"] = "REVERSED";
|
|
12
16
|
/** Cliente ya gastó el dinero — ops resuelve manualmente. */
|
|
@@ -23,3 +23,5 @@ __exportStar(require("./WalletFundingRefundReasonEnum"), exports);
|
|
|
23
23
|
__exportStar(require("./PaymentCodeTypeEnum"), exports);
|
|
24
24
|
__exportStar(require("./FundingWebhookTypeEnum"), exports);
|
|
25
25
|
__exportStar(require("./SettlementErrorCodeEnum"), exports);
|
|
26
|
+
__exportStar(require("./ServiceStateEnum"), exports);
|
|
27
|
+
__exportStar(require("./FundingVerificationOutcomeEnum"), exports);
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Schema literal de la tabla DDB `AggregateExposureState_GT`.
|
|
3
|
+
*
|
|
4
|
+
* Singleton (pk `AGGREGATE#CASH_IN` / sk `STATE`) que lleva la exposición
|
|
5
|
+
* agregada de FiadoSA frente al Proveedor y el estado del circuit breaker.
|
|
6
|
+
*
|
|
7
|
+
* IMPORTANTE: tabla SINGLE-REGION (una sola réplica). Las escrituras del cap
|
|
8
|
+
* son UpdateItem con ConditionExpression y deben ser atómicas; una Global
|
|
9
|
+
* Table multi-región (last-writer-wins) rompería la garantía del cap.
|
|
10
|
+
*
|
|
11
|
+
* Owner: wallet-funding-rules-business.
|
|
12
|
+
*/
|
|
13
|
+
export declare const AggregateExposureStateTable: {
|
|
14
|
+
readonly name: "AggregateExposureState_GT";
|
|
15
|
+
readonly pk: "pk";
|
|
16
|
+
readonly sk: "sk";
|
|
17
|
+
readonly attributes: {
|
|
18
|
+
readonly pk: "pk";
|
|
19
|
+
readonly sk: "sk";
|
|
20
|
+
readonly currentExposureAmount: "currentExposureAmount";
|
|
21
|
+
readonly serviceState: "serviceState";
|
|
22
|
+
readonly capThreshold: "capThreshold";
|
|
23
|
+
readonly alertThreshold: "alertThreshold";
|
|
24
|
+
readonly reactivationThreshold: "reactivationThreshold";
|
|
25
|
+
readonly lastCapReachedAt: "lastCapReachedAt";
|
|
26
|
+
readonly lastAlertSentAt: "lastAlertSentAt";
|
|
27
|
+
readonly updatedAt: "updatedAt";
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
export type AggregateExposureStateAttribute = typeof AggregateExposureStateTable.attributes[keyof typeof AggregateExposureStateTable.attributes];
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AggregateExposureStateTable = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Schema literal de la tabla DDB `AggregateExposureState_GT`.
|
|
6
|
+
*
|
|
7
|
+
* Singleton (pk `AGGREGATE#CASH_IN` / sk `STATE`) que lleva la exposición
|
|
8
|
+
* agregada de FiadoSA frente al Proveedor y el estado del circuit breaker.
|
|
9
|
+
*
|
|
10
|
+
* IMPORTANTE: tabla SINGLE-REGION (una sola réplica). Las escrituras del cap
|
|
11
|
+
* son UpdateItem con ConditionExpression y deben ser atómicas; una Global
|
|
12
|
+
* Table multi-región (last-writer-wins) rompería la garantía del cap.
|
|
13
|
+
*
|
|
14
|
+
* Owner: wallet-funding-rules-business.
|
|
15
|
+
*/
|
|
16
|
+
exports.AggregateExposureStateTable = {
|
|
17
|
+
name: "AggregateExposureState_GT",
|
|
18
|
+
pk: "pk",
|
|
19
|
+
sk: "sk",
|
|
20
|
+
attributes: {
|
|
21
|
+
pk: "pk",
|
|
22
|
+
sk: "sk",
|
|
23
|
+
currentExposureAmount: "currentExposureAmount",
|
|
24
|
+
serviceState: "serviceState",
|
|
25
|
+
capThreshold: "capThreshold",
|
|
26
|
+
alertThreshold: "alertThreshold",
|
|
27
|
+
reactivationThreshold: "reactivationThreshold",
|
|
28
|
+
lastCapReachedAt: "lastCapReachedAt",
|
|
29
|
+
lastAlertSentAt: "lastAlertSentAt",
|
|
30
|
+
updatedAt: "updatedAt",
|
|
31
|
+
},
|
|
32
|
+
};
|
|
@@ -16,3 +16,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./EqualityFundingPaymentSchema"), exports);
|
|
18
18
|
__exportStar(require("./AccountPagoConfiadoSchema"), exports);
|
|
19
|
+
__exportStar(require("./AggregateExposureStateSchema"), exports);
|
package/package.json
CHANGED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { RemittanceExceptionCode } from "../enums/RemittanceExceptionCode";
|
|
2
|
+
|
|
3
|
+
export interface ExceptionCatalogEntry {
|
|
4
|
+
motivo: string;
|
|
5
|
+
accionSugerida: string;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
/** our-code → texto ya traducido (español). El front lo muestra tal cual. */
|
|
9
|
+
export const REMITTANCE_EXCEPTION_CATALOG: Record<RemittanceExceptionCode, ExceptionCatalogEntry> = {
|
|
10
|
+
[RemittanceExceptionCode.HOLD_DISPERSAL_UNCONFIRMED]: {
|
|
11
|
+
motivo: "El proveedor no ha confirmado la dispersión de fondos.",
|
|
12
|
+
accionSugerida: "Investigar el estado de la dispersión. Si supera 48h en HOLD, escalar a soporte del proveedor.",
|
|
13
|
+
},
|
|
14
|
+
[RemittanceExceptionCode.HOLD_PROVIDER_TIMEOUT]: {
|
|
15
|
+
motivo: "Tiempo de espera agotado con el proveedor · sin confirmar dispersión.",
|
|
16
|
+
accionSugerida: "Investigar el estado de la transacción. Si supera 48h en HOLD, escalar a soporte del proveedor.",
|
|
17
|
+
},
|
|
18
|
+
[RemittanceExceptionCode.HOLD_COMPLIANCE_REVIEW]: {
|
|
19
|
+
motivo: "El proveedor puso la transacción en revisión de cumplimiento.",
|
|
20
|
+
accionSugerida: "Monitorear. Si el proveedor no libera en 72h, escalar a soporte.",
|
|
21
|
+
},
|
|
22
|
+
[RemittanceExceptionCode.HOLD_GENERIC]: {
|
|
23
|
+
motivo: "El proveedor marcó la transacción con un problema.",
|
|
24
|
+
accionSugerida: "Investigar el estado de la transacción. Si supera 48h en HOLD, escalar a soporte del proveedor.",
|
|
25
|
+
},
|
|
26
|
+
[RemittanceExceptionCode.CANCEL_USER_REQUESTED]: {
|
|
27
|
+
motivo: "El cliente canceló la transacción. Esperando que el proveedor confirme la devolución de fondos.",
|
|
28
|
+
accionSugerida: "Monitorear. La devolución al monedero se dispara automáticamente al confirmar el proveedor. Si supera 72h, escalar a tesorería.",
|
|
29
|
+
},
|
|
30
|
+
[RemittanceExceptionCode.CANCEL_PROVIDER_INITIATED]: {
|
|
31
|
+
motivo: "El proveedor inició la cancelación de la transacción.",
|
|
32
|
+
accionSugerida: "Monitorear la confirmación de devolución. Si supera 72h, escalar a tesorería.",
|
|
33
|
+
},
|
|
34
|
+
[RemittanceExceptionCode.CANCEL_GENERIC]: {
|
|
35
|
+
motivo: "Cancelación en proceso. Esperando confirmación del proveedor.",
|
|
36
|
+
accionSugerida: "Monitorear. Si supera 72h sin confirmación, escalar a tesorería.",
|
|
37
|
+
},
|
|
38
|
+
[RemittanceExceptionCode.INPROCESS_STALE_24H]: {
|
|
39
|
+
motivo: "La transacción lleva más de 24h sin avanzar a PAYABLE/PAID.",
|
|
40
|
+
accionSugerida: "Verificar el sync con el proveedor. Si no responde, escalar a soporte con el número de transacción.",
|
|
41
|
+
},
|
|
42
|
+
[RemittanceExceptionCode.UNKNOWN]: {
|
|
43
|
+
motivo: "Situación no catalogada.",
|
|
44
|
+
accionSugerida: "Revisar manualmente el detalle de la transacción y escalar si aplica.",
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Mapa de códigos CRUDOS de UNIR (sub-status) → our-code.
|
|
50
|
+
* Se amplía minando el PDF de UNIR (tarea aparte). Las claves se normalizan a MAYÚSCULAS.
|
|
51
|
+
*/
|
|
52
|
+
const UNIR_HOLD_SUBSTATUS_TO_CODE: Record<string, RemittanceExceptionCode> = {
|
|
53
|
+
SENDMONEY_TIMEOUT: RemittanceExceptionCode.HOLD_PROVIDER_TIMEOUT,
|
|
54
|
+
TIMEOUT: RemittanceExceptionCode.HOLD_PROVIDER_TIMEOUT,
|
|
55
|
+
DISPERSAL_UNCONFIRMED: RemittanceExceptionCode.HOLD_DISPERSAL_UNCONFIRMED,
|
|
56
|
+
COMPLIANCE_REVIEW: RemittanceExceptionCode.HOLD_COMPLIANCE_REVIEW,
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Mapa de cancelReason → our-code.
|
|
61
|
+
* Incluye tanto los valores reales de RemittanceCancelledByEnum (USER / SYSTEM)
|
|
62
|
+
* como los códigos semánticos de UNIR (USER_REQUESTED / PROVIDER_INITIATED).
|
|
63
|
+
*/
|
|
64
|
+
const UNIR_CANCEL_REASON_TO_CODE: Record<string, RemittanceExceptionCode> = {
|
|
65
|
+
// Valores de RemittanceCancelledByEnum
|
|
66
|
+
USER: RemittanceExceptionCode.CANCEL_USER_REQUESTED,
|
|
67
|
+
SYSTEM: RemittanceExceptionCode.CANCEL_GENERIC,
|
|
68
|
+
// Códigos semánticos de UNIR
|
|
69
|
+
USER_REQUESTED: RemittanceExceptionCode.CANCEL_USER_REQUESTED,
|
|
70
|
+
PROVIDER_INITIATED: RemittanceExceptionCode.CANCEL_PROVIDER_INITIATED,
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Resuelve el our-code a partir del status + los códigos crudos de UNIR.
|
|
75
|
+
* Fallback por bucket (HOLD_GENERIC / CANCEL_GENERIC / INPROCESS_STALE_24H) y
|
|
76
|
+
* UNKNOWN para status inesperados. Nunca lanza.
|
|
77
|
+
*/
|
|
78
|
+
export function resolveExceptionCode(
|
|
79
|
+
status: string,
|
|
80
|
+
unirSubStatus?: string | null,
|
|
81
|
+
cancelReason?: string | null,
|
|
82
|
+
): RemittanceExceptionCode {
|
|
83
|
+
switch (status) {
|
|
84
|
+
case "HOLD": {
|
|
85
|
+
const key = (unirSubStatus ?? "").trim().toUpperCase();
|
|
86
|
+
return UNIR_HOLD_SUBSTATUS_TO_CODE[key] ?? RemittanceExceptionCode.HOLD_GENERIC;
|
|
87
|
+
}
|
|
88
|
+
case "CANCELLATION_IN_PROGRESS": {
|
|
89
|
+
const key = (cancelReason ?? "").trim().toUpperCase();
|
|
90
|
+
return UNIR_CANCEL_REASON_TO_CODE[key] ?? RemittanceExceptionCode.CANCEL_GENERIC;
|
|
91
|
+
}
|
|
92
|
+
case "IN_PROCESS":
|
|
93
|
+
return RemittanceExceptionCode.INPROCESS_STALE_24H;
|
|
94
|
+
default:
|
|
95
|
+
return RemittanceExceptionCode.UNKNOWN;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Códigos propios ("our-code") de excepciones de remesas. Traducimos los códigos
|
|
3
|
+
* crudos de UNIR a ESTE formato; los crudos NUNCA se exponen. UNKNOWN es el
|
|
4
|
+
* fallback para sub-status/motivos no catalogados (nuevos o desconocidos).
|
|
5
|
+
*/
|
|
6
|
+
export enum RemittanceExceptionCode {
|
|
7
|
+
// HOLD (el proveedor marcó la tx)
|
|
8
|
+
HOLD_DISPERSAL_UNCONFIRMED = "HOLD_DISPERSAL_UNCONFIRMED",
|
|
9
|
+
HOLD_PROVIDER_TIMEOUT = "HOLD_PROVIDER_TIMEOUT",
|
|
10
|
+
HOLD_COMPLIANCE_REVIEW = "HOLD_COMPLIANCE_REVIEW",
|
|
11
|
+
HOLD_GENERIC = "HOLD_GENERIC",
|
|
12
|
+
// Cancelación en proceso
|
|
13
|
+
CANCEL_USER_REQUESTED = "CANCEL_USER_REQUESTED",
|
|
14
|
+
CANCEL_PROVIDER_INITIATED = "CANCEL_PROVIDER_INITIATED",
|
|
15
|
+
CANCEL_GENERIC = "CANCEL_GENERIC",
|
|
16
|
+
// In-process atorada > 24h
|
|
17
|
+
INPROCESS_STALE_24H = "INPROCESS_STALE_24H",
|
|
18
|
+
// Fallback
|
|
19
|
+
UNKNOWN = "UNKNOWN",
|
|
20
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { IsString, IsNumber, IsPositive, Length, IsDateString, MaxLength, IsEnum } from "class-validator";
|
|
2
|
+
import { FundingVerificationOutcomeEnum } from "../enums/FundingVerificationOutcomeEnum";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Request del endpoint privado `POST /funding/apply` del connector.
|
|
6
|
+
*
|
|
7
|
+
* Lo invoca `db-conciliacion` cuando la verificación autoritativa (poll al
|
|
8
|
+
* portal del Proveedor, ~10 min) resuelve. Dispara el acreditamiento diferido:
|
|
9
|
+
* el webhook `payment` NO acredita — solo deja el pago en IN_VERIFICATION;
|
|
10
|
+
* este apply es la segunda ejecución (async) que mueve el dinero.
|
|
11
|
+
*/
|
|
12
|
+
export class ApplyWalletFundingRequest {
|
|
13
|
+
@IsString() @MaxLength(32) providerName!: string;
|
|
14
|
+
@IsString() @MaxLength(64) providerTxId!: string;
|
|
15
|
+
@IsString() @MaxLength(128) providerReference!: string;
|
|
16
|
+
@IsString() @MaxLength(64) directoryId!: string;
|
|
17
|
+
@IsString() @MaxLength(64) walletAccountId!: string;
|
|
18
|
+
@IsNumber() @IsPositive() amount!: number;
|
|
19
|
+
@IsString() @Length(3, 3) currencyCode!: string;
|
|
20
|
+
@IsDateString() paidAt!: string;
|
|
21
|
+
/** Resultado de la verificación. APPROVED → acredita (settle); REJECTED → revierte. */
|
|
22
|
+
@IsEnum(FundingVerificationOutcomeEnum) outcome!: FundingVerificationOutcomeEnum;
|
|
23
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { WalletFundingPaymentStatusEnum } from "../enums/WalletFundingPaymentStatusEnum";
|
|
2
|
+
import { WalletFundingErrorCodeEnum } from "../enums/WalletFundingErrorCodeEnum";
|
|
3
|
+
|
|
4
|
+
export class ApplyWalletFundingResponse {
|
|
5
|
+
/** Estado del pago tras aplicar la verificación: APPLIED (acreditado) o REVERSED. */
|
|
6
|
+
status!: WalletFundingPaymentStatusEnum;
|
|
7
|
+
/** Folio del processor si se acreditó (idempotente si ya estaba APPLIED). */
|
|
8
|
+
processorTransactionNumber?: string;
|
|
9
|
+
errorCode?: WalletFundingErrorCodeEnum;
|
|
10
|
+
message?: string;
|
|
11
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ServiceStateEnum } from "../enums/ServiceStateEnum";
|
|
2
|
+
|
|
3
|
+
/** Response de `wallet-funding-rules` (GET /state). Estado del cap + breaker. */
|
|
4
|
+
export class GetExposureStateResponse {
|
|
5
|
+
currentExposureAmount!: number;
|
|
6
|
+
serviceState!: ServiceStateEnum;
|
|
7
|
+
capThreshold!: number;
|
|
8
|
+
alertThreshold!: number;
|
|
9
|
+
reactivationThreshold!: number;
|
|
10
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { IsString, IsNumber, IsPositive, Length, MaxLength, IsOptional } from "class-validator";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Request de `wallet-funding-rules` (POST /release). Lo llama la conciliación
|
|
5
|
+
* (db-conciliacion) al liquidar el SPEI, o el flujo de rechazo/reverso.
|
|
6
|
+
* Libera monto de la exposición agregada; puede reactivar el servicio.
|
|
7
|
+
*/
|
|
8
|
+
export class ReleaseExposureRequest {
|
|
9
|
+
@IsNumber() @IsPositive() amount!: number;
|
|
10
|
+
@IsString() @Length(3, 3) currencyCode!: string;
|
|
11
|
+
@IsOptional() @IsString() @MaxLength(64) providerTxId?: string;
|
|
12
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { IsString, IsNumber, IsPositive, Length, MaxLength, IsOptional } from "class-validator";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Request de `wallet-funding-rules` (POST /reserve). Lo llama el processor en
|
|
5
|
+
* `walletFundingValidate` (cap gate). Reserva monto contra la exposición
|
|
6
|
+
* agregada FSA de forma atómica (single-region + ConditionExpression).
|
|
7
|
+
*/
|
|
8
|
+
export class ReserveExposureRequest {
|
|
9
|
+
@IsString() @MaxLength(64) directoryId!: string;
|
|
10
|
+
@IsNumber() @IsPositive() amount!: number;
|
|
11
|
+
@IsString() @Length(3, 3) currencyCode!: string;
|
|
12
|
+
@IsString() @MaxLength(32) providerName!: string;
|
|
13
|
+
/** Idempotencia: referencia/tx del Proveedor para no doble-reservar en reintentos. */
|
|
14
|
+
@IsOptional() @IsString() @MaxLength(64) providerTxId?: string;
|
|
15
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ServiceStateEnum } from "../enums/ServiceStateEnum";
|
|
2
|
+
|
|
3
|
+
export class ReserveExposureResponse {
|
|
4
|
+
/** true si la reserva pasó el cap; false si excede el cap o el servicio está SUSPENDED. */
|
|
5
|
+
allowed!: boolean;
|
|
6
|
+
serviceState!: ServiceStateEnum;
|
|
7
|
+
/** Motivo cuando allowed=false (ej. "CAP_REACHED", "SERVICE_SUSPENDED"). */
|
|
8
|
+
reason?: string;
|
|
9
|
+
}
|
|
@@ -21,3 +21,10 @@ export * from "./AuthorizeFundingRequest";
|
|
|
21
21
|
export * from "./AuthorizeFundingResponse";
|
|
22
22
|
export * from "./SettleWalletFundingRequest";
|
|
23
23
|
export * from "./SettleWalletFundingResponse";
|
|
24
|
+
export * from "./ApplyWalletFundingRequest";
|
|
25
|
+
export * from "./ApplyWalletFundingResponse";
|
|
26
|
+
export * from "./ReserveExposureRequest";
|
|
27
|
+
export * from "./ReserveExposureResponse";
|
|
28
|
+
export * from "./ReleaseExposureRequest";
|
|
29
|
+
export * from "./ReleaseExposureResponse";
|
|
30
|
+
export * from "./GetExposureStateResponse";
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
export enum WalletFundingPaymentStatusEnum {
|
|
2
2
|
/** Webhook consult procesado — pre-check OK, esperando webhook payment. */
|
|
3
3
|
CONSULTED = "CONSULTED",
|
|
4
|
+
/** Pago recibido (webhook payment), en verificación autoritativa; aún NO acreditado. El webhook lo escribe y termina; el crédito es una invocación async posterior (db-conciliacion → /funding/apply). */
|
|
5
|
+
IN_VERIFICATION = "IN_VERIFICATION",
|
|
4
6
|
/** Pago aplicado al wallet via processor.credit. */
|
|
5
7
|
APPLIED = "APPLIED",
|
|
8
|
+
/** Liquidado por el Proveedor a FSA (SPEI recibido); marcado en la conciliación semanal. */
|
|
9
|
+
SETTLED = "SETTLED",
|
|
6
10
|
/** Pago revertido via processor.reverse. */
|
|
7
11
|
REVERSED = "REVERSED",
|
|
8
12
|
/** Cliente ya gastó el dinero — ops resuelve manualmente. */
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Schema literal de la tabla DDB `AggregateExposureState_GT`.
|
|
3
|
+
*
|
|
4
|
+
* Singleton (pk `AGGREGATE#CASH_IN` / sk `STATE`) que lleva la exposición
|
|
5
|
+
* agregada de FiadoSA frente al Proveedor y el estado del circuit breaker.
|
|
6
|
+
*
|
|
7
|
+
* IMPORTANTE: tabla SINGLE-REGION (una sola réplica). Las escrituras del cap
|
|
8
|
+
* son UpdateItem con ConditionExpression y deben ser atómicas; una Global
|
|
9
|
+
* Table multi-región (last-writer-wins) rompería la garantía del cap.
|
|
10
|
+
*
|
|
11
|
+
* Owner: wallet-funding-rules-business.
|
|
12
|
+
*/
|
|
13
|
+
export const AggregateExposureStateTable = {
|
|
14
|
+
name: "AggregateExposureState_GT",
|
|
15
|
+
pk: "pk",
|
|
16
|
+
sk: "sk",
|
|
17
|
+
attributes: {
|
|
18
|
+
pk: "pk",
|
|
19
|
+
sk: "sk",
|
|
20
|
+
currentExposureAmount: "currentExposureAmount",
|
|
21
|
+
serviceState: "serviceState",
|
|
22
|
+
capThreshold: "capThreshold",
|
|
23
|
+
alertThreshold: "alertThreshold",
|
|
24
|
+
reactivationThreshold: "reactivationThreshold",
|
|
25
|
+
lastCapReachedAt: "lastCapReachedAt",
|
|
26
|
+
lastAlertSentAt: "lastAlertSentAt",
|
|
27
|
+
updatedAt: "updatedAt",
|
|
28
|
+
},
|
|
29
|
+
} as const;
|
|
30
|
+
|
|
31
|
+
export type AggregateExposureStateAttribute =
|
|
32
|
+
typeof AggregateExposureStateTable.attributes[keyof typeof AggregateExposureStateTable.attributes];
|