@fiado/api-invoker 5.43.0 → 5.44.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/bin/document-generator/DocumentGeneratorApi.d.ts +1 -1
- package/bin/document-generator/DocumentGeneratorApi.js +3 -3
- package/bin/legalDocument/api/LegalDocumentApi.d.ts +2 -1
- package/bin/legalDocument/api/LegalDocumentApi.js +7 -0
- package/bin/legalDocument/api/interfaces/ILegalDocumentApi.d.ts +5 -0
- package/bin/retailCatalog/api/RetailCatalogBusinessApi.d.ts +2 -1
- package/bin/retailCatalog/api/RetailCatalogBusinessApi.js +11 -0
- package/bin/retailCatalog/api/interfaces/IRetailCatalogBusinessApi.d.ts +56 -5
- package/bin/retailCatalog/api/interfaces/IRetailCatalogBusinessApi.js +2 -1
- package/package.json +1 -1
- package/src/document-generator/DocumentGeneratorApi.ts +4 -4
- package/src/legalDocument/api/LegalDocumentApi.ts +12 -1
- package/src/legalDocument/api/interfaces/ILegalDocumentApi.ts +6 -0
- package/src/retailCatalog/api/RetailCatalogBusinessApi.ts +16 -0
- package/src/retailCatalog/api/interfaces/IRetailCatalogBusinessApi.ts +61 -5
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IHttpRequest } from "@fiado/http-client";
|
|
1
|
+
import type { IHttpRequest } from "@fiado/http-client";
|
|
2
2
|
import { IDocumentGeneratorApi } from "./interfaces/IDocumentGeneratorApi.js";
|
|
3
3
|
import { DocumentGenerateRequest } from "@fiado/type-kit/bin/credit/dtos/internal/DocumentGenerateRequest.js";
|
|
4
4
|
import { DocumentGenerateResponse } from "@fiado/type-kit/bin/credit/dtos/internal/DocumentGenerateResponse.js";
|
|
@@ -37,17 +37,17 @@ let DocumentGeneratorApi = class DocumentGeneratorApi {
|
|
|
37
37
|
async getDocument(documentId) {
|
|
38
38
|
const url = `${this.baseUrl}document/${documentId}`;
|
|
39
39
|
const operationName = "documentGetDocument";
|
|
40
|
-
return await this.httpRequest.
|
|
40
|
+
return await this.httpRequest.get(url, undefined, { 'operationName': operationName });
|
|
41
41
|
}
|
|
42
42
|
async getDocumentUrl(documentId) {
|
|
43
43
|
const url = `${this.baseUrl}document/${documentId}/url`;
|
|
44
44
|
const operationName = "documentGetDocumentUrl";
|
|
45
|
-
return await this.httpRequest.
|
|
45
|
+
return await this.httpRequest.get(url, undefined, { 'operationName': operationName });
|
|
46
46
|
}
|
|
47
47
|
async getDocumentByReference(type, referenceId) {
|
|
48
48
|
const url = `${this.baseUrl}document/by-reference/${type}/${referenceId}`;
|
|
49
49
|
const operationName = "documentGetDocumentByReference";
|
|
50
|
-
return await this.httpRequest.
|
|
50
|
+
return await this.httpRequest.get(url, undefined, { 'operationName': operationName });
|
|
51
51
|
}
|
|
52
52
|
};
|
|
53
53
|
DocumentGeneratorApi = __decorate([
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { ILegalDocumentApi } from "./interfaces/ILegalDocumentApi.js";
|
|
2
|
-
import { IHttpRequest } from "@fiado/http-client";
|
|
2
|
+
import type { IHttpRequest } from "@fiado/http-client";
|
|
3
3
|
export declare class LegalDocumentApi implements ILegalDocumentApi {
|
|
4
4
|
private httpRequest;
|
|
5
5
|
private readonly baseUrl;
|
|
6
6
|
constructor(httpRequest: IHttpRequest);
|
|
7
7
|
getPendingSign(directoryId: string): Promise<any>;
|
|
8
8
|
getDirectoryAcceptanceByDirectoryId(directoryId: string): Promise<any>;
|
|
9
|
+
getDocumentByType(type: string): Promise<any>;
|
|
9
10
|
}
|
|
@@ -31,6 +31,13 @@ let LegalDocumentApi = class LegalDocumentApi {
|
|
|
31
31
|
const url = `${this.baseUrl}directories/${directoryId}`;
|
|
32
32
|
return await this.httpRequest.get(url);
|
|
33
33
|
}
|
|
34
|
+
async getDocumentByType(type) {
|
|
35
|
+
if (!type) {
|
|
36
|
+
throw new Error("Document type is required.");
|
|
37
|
+
}
|
|
38
|
+
const url = `${this.baseUrl}documents/types/${encodeURIComponent(type)}`;
|
|
39
|
+
return await this.httpRequest.get(url);
|
|
40
|
+
}
|
|
34
41
|
};
|
|
35
42
|
LegalDocumentApi = __decorate([
|
|
36
43
|
injectable(),
|
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
export interface ILegalDocumentApi {
|
|
2
2
|
getPendingSign(directoryId: string): Promise<any>;
|
|
3
3
|
getDirectoryAcceptanceByDirectoryId(directoryId: string): Promise<any>;
|
|
4
|
+
/**
|
|
5
|
+
* Documento legal vigente de un tipo (PRIVACY_PAY, etc.).
|
|
6
|
+
* Devuelve el documento con su URL firmada y el vencimiento de esa URL.
|
|
7
|
+
*/
|
|
8
|
+
getDocumentByType(type: string): Promise<any>;
|
|
4
9
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { IHttpRequest } from "@fiado/http-client";
|
|
2
2
|
import { StandardResponse } from "@fiado/gateway-adapter";
|
|
3
|
-
import { IRetailCatalogBusinessApi, ReleaseReservationBody, ReserveInventoryBody, ReserveInventoryResult, SellInventoryBody, StoreCatalogItem } from "./interfaces/IRetailCatalogBusinessApi.js";
|
|
3
|
+
import { ImeiProductLookupResponse, IRetailCatalogBusinessApi, ReleaseReservationBody, ReserveInventoryBody, ReserveInventoryResult, SellInventoryBody, StoreCatalogItem } from "./interfaces/IRetailCatalogBusinessApi.js";
|
|
4
4
|
/**
|
|
5
5
|
* Publisher HTTP del lambda `retail-catalog-business` (SureKeep Fase 1, pista Retail) para sus
|
|
6
6
|
* endpoints privados del ciclo de venta del IMEI. Contrato y semántica completos →
|
|
@@ -20,6 +20,7 @@ export default class RetailCatalogBusinessApi implements IRetailCatalogBusinessA
|
|
|
20
20
|
constructor(httpRequest: IHttpRequest);
|
|
21
21
|
private tenantHeader;
|
|
22
22
|
getStoreCatalog(storeId: string, issuer: string): Promise<StandardResponse<StoreCatalogItem[]>>;
|
|
23
|
+
getProductsByImei(imeis: string[], tenantId: string): Promise<StandardResponse<ImeiProductLookupResponse>>;
|
|
23
24
|
reserveInventory(imei: string, body: ReserveInventoryBody, issuer: string): Promise<StandardResponse<ReserveInventoryResult>>;
|
|
24
25
|
sellInventory(imei: string, body: SellInventoryBody, issuer: string): Promise<StandardResponse<void>>;
|
|
25
26
|
releaseInventory(imei: string, body: ReleaseReservationBody, issuer: string): Promise<StandardResponse<void>>;
|
|
@@ -11,6 +11,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
|
11
11
|
return function (target, key) { decorator(target, key, paramIndex); }
|
|
12
12
|
};
|
|
13
13
|
import { inject, injectable } from "inversify";
|
|
14
|
+
import { IMEI_PRODUCT_BATCH_MAX, } from "./interfaces/IRetailCatalogBusinessApi.js";
|
|
14
15
|
/** Header por el que el destino resuelve el silo (issuer Cognito forwardeado por el caller). */
|
|
15
16
|
const TENANT_ISSUER_HEADER = "x-tenant-issuer";
|
|
16
17
|
/**
|
|
@@ -40,6 +41,16 @@ let RetailCatalogBusinessApi = class RetailCatalogBusinessApi {
|
|
|
40
41
|
const url = `${this.baseUrl}/private/stores/${encodeURIComponent(storeId)}/catalog`;
|
|
41
42
|
return await this.httpRequest.get(url, undefined, this.tenantHeader(issuer));
|
|
42
43
|
}
|
|
44
|
+
async getProductsByImei(imeis, tenantId) {
|
|
45
|
+
// Se corta acá: mandar un lote que el destino va a rechazar solo gasta un round-trip.
|
|
46
|
+
if (imeis.length > IMEI_PRODUCT_BATCH_MAX) {
|
|
47
|
+
throw new Error(`El lote admite hasta ${IMEI_PRODUCT_BATCH_MAX} IMEIs y llegaron ${imeis.length}`);
|
|
48
|
+
}
|
|
49
|
+
// `URLSearchParams` codifica la coma del separador; el destino hace `split(',')` sobre el
|
|
50
|
+
// valor ya decodificado por API Gateway.
|
|
51
|
+
const query = new URLSearchParams({ imeis: imeis.join(","), tenantId });
|
|
52
|
+
return await this.httpRequest.get(`${this.baseUrl}/private/products/by-imei?${query.toString()}`);
|
|
53
|
+
}
|
|
43
54
|
async reserveInventory(imei, body, issuer) {
|
|
44
55
|
const url = `${this.baseUrl}/private/inventory/${encodeURIComponent(imei)}/reserve`;
|
|
45
56
|
return await this.httpRequest.put(url, body, this.tenantHeader(issuer));
|
|
@@ -5,12 +5,17 @@ import type { MdmLockModeEnum, MdmProviderEnum } from "@fiado/type-kit/bin/retai
|
|
|
5
5
|
* para sus endpoints privados del ciclo de venta del IMEI, consumidos por el wizard F2.
|
|
6
6
|
*
|
|
7
7
|
* ─────────────────────────────────────────────────────────────────────────────
|
|
8
|
-
* TENANT —
|
|
8
|
+
* TENANT — DOS convenciones conviven acá. Mirá la firma de cada método.
|
|
9
9
|
* ─────────────────────────────────────────────────────────────────────────────
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
* `
|
|
10
|
+
* Los cinco métodos del ciclo de venta del IMEI toman `issuer` y lo mandan en el header
|
|
11
|
+
* `x-tenant-issuer` (`PrivateController.issuerFromHeader` → `TenantContextService.withContext`).
|
|
12
|
+
* `getProductsByImei` toma `tenantId` y lo manda por `?tenantId=`
|
|
13
|
+
* (→ `TenantContextService.withContextByTenantId`), porque su consumidor es un backoffice que no
|
|
14
|
+
* tiene el issuer Cognito. Los privados son `Feature.ANONIMUS` (sin RBAC; la protección es la red
|
|
15
|
+
* VPC), así que el caller DEBE declarar uno de los dos — no hay default.
|
|
16
|
+
*
|
|
17
|
+
* TD: converger los cinco del ciclo de venta a `?tenantId=`, el camino canónico para
|
|
18
|
+
* service-to-service. No se migran acá para no romper al wizard, que ya consume el header.
|
|
14
19
|
*
|
|
15
20
|
* ⚠️ Retorno `StandardResponse<T>` — el consumer lee `result.data`, NO `result.body`.
|
|
16
21
|
* Errores: el destino lanza `DomainError` tipado → el publisher RECHAZA (no devuelve null); cada
|
|
@@ -53,6 +58,28 @@ export interface StoreCatalogItem {
|
|
|
53
58
|
/** Modo de bloqueo pactado; `null` si el producto no lleva MDM. */
|
|
54
59
|
mdmLockMode: MdmLockModeEnum | null;
|
|
55
60
|
}
|
|
61
|
+
/** Techo de IMEIs por request del lote IMEI->producto. Lo declara y lo honra el destino. */
|
|
62
|
+
export declare const IMEI_PRODUCT_BATCH_MAX = 100;
|
|
63
|
+
/** Por que se pudo (o no) resolver el producto de un IMEI del lote. */
|
|
64
|
+
export type ImeiProductLookupStatus = "OK" | "NOT_FOUND" | "UNAVAILABLE" | "INVALID_ID";
|
|
65
|
+
/** Una entrada del lote IMEI->producto (espeja `ImeiProductLookupEntry` del destino). */
|
|
66
|
+
export interface ImeiProductLookupEntry {
|
|
67
|
+
imei: string;
|
|
68
|
+
/**
|
|
69
|
+
* `OK` trae sku/brand/model · `NOT_FOUND` el catalogo no llega al producto (dato POSITIVO) ·
|
|
70
|
+
* `UNAVAILABLE` no se pudo leer ese IMEI, reintentalo · `INVALID_ID` no tiene forma de IMEI.
|
|
71
|
+
*/
|
|
72
|
+
status: ImeiProductLookupStatus;
|
|
73
|
+
sku?: string;
|
|
74
|
+
/** Marca comercial (p. ej. "Apple"). Solo viene con `status: OK`. */
|
|
75
|
+
brand?: string;
|
|
76
|
+
/** Modelo (p. ej. "iPhone 15 Pro"). Solo viene con `status: OK`. */
|
|
77
|
+
model?: string;
|
|
78
|
+
}
|
|
79
|
+
/** Respuesta del lote: UNA entrada por IMEI pedido, en el MISMO orden. */
|
|
80
|
+
export interface ImeiProductLookupResponse {
|
|
81
|
+
items: ImeiProductLookupEntry[];
|
|
82
|
+
}
|
|
56
83
|
/** Resultado de la reserva (espeja `ReserveInventoryResponse` del destino). */
|
|
57
84
|
export interface ReserveInventoryResult {
|
|
58
85
|
reservationExpiresAt: string;
|
|
@@ -74,6 +101,30 @@ export interface ReleaseReservationBody {
|
|
|
74
101
|
export interface IRetailCatalogBusinessApi {
|
|
75
102
|
/** GET `/private/stores/{storeId}/catalog` — catálogo vendible (sku, imei, precio de contado, disponibilidad). */
|
|
76
103
|
getStoreCatalog(storeId: string, issuer: string): Promise<StandardResponse<StoreCatalogItem[]>>;
|
|
104
|
+
/**
|
|
105
|
+
* GET `/private/products/by-imei?imeis=&tenantId=` — resuelve un lote de IMEIs a su producto
|
|
106
|
+
* (sku + marca + modelo). Para los lambdas que del equipo solo guardan el IMEI.
|
|
107
|
+
*
|
|
108
|
+
* ─────────────────────────────────────────────────────────────────────────────
|
|
109
|
+
* ⚠️ El tenant va por `?tenantId=`, NO por el header `x-tenant-issuer` del resto de este publisher.
|
|
110
|
+
* ─────────────────────────────────────────────────────────────────────────────
|
|
111
|
+
* El consumidor es un backoffice que solo tiene el `tenantId` de su contexto; el issuer Cognito
|
|
112
|
+
* no existe de su lado. El destino entra por `TenantContextService.withContextByTenantId`, con las
|
|
113
|
+
* mismas garantías (mismo diccionario, AssumeRole del silo, fail-closed sin tenant).
|
|
114
|
+
*
|
|
115
|
+
* ── El contrato del lote ────────────────────────────────────────────────────────────────────
|
|
116
|
+
* Devuelve UNA entrada por cada IMEI pedido, en el MISMO orden — el caller nunca reconcilia. Los
|
|
117
|
+
* repetidos se consultan una sola vez pero salen repetidos. Techo de `IMEI_PRODUCT_BATCH_MAX`
|
|
118
|
+
* IMEIs por request; el caller parte los lotes mayores.
|
|
119
|
+
*
|
|
120
|
+
* Ningún IMEI tumba el lote: el mal formado sale `INVALID_ID`, el que el catálogo no alcanza a
|
|
121
|
+
* resolver sale `NOT_FOUND` y el que DynamoDB no llegó a leer sale `UNAVAILABLE` (reintentable).
|
|
122
|
+
* Solo un fallo total del destino rechaza la promesa.
|
|
123
|
+
*
|
|
124
|
+
* @throws Error si el lote supera el techo (se corta acá, sin salir a la red) ·
|
|
125
|
+
* `400 IMEI_BATCH_REQUIRED` si `imeis` viene vacío · `400 UNKNOWN_TENANT` sin `tenantId`.
|
|
126
|
+
*/
|
|
127
|
+
getProductsByImei(imeis: string[], tenantId: string): Promise<StandardResponse<ImeiProductLookupResponse>>;
|
|
77
128
|
/** PUT `/private/inventory/{imei}/reserve` — reserva atómica del IMEI para una sesión (AVAILABLE → RESERVED). */
|
|
78
129
|
reserveInventory(imei: string, body: ReserveInventoryBody, issuer: string): Promise<StandardResponse<ReserveInventoryResult>>;
|
|
79
130
|
/** PUT `/private/inventory/{imei}/sell` — vende el IMEI (RESERVED → SOLD). */
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
/** Techo de IMEIs por request del lote IMEI->producto. Lo declara y lo honra el destino. */
|
|
2
|
+
export const IMEI_PRODUCT_BATCH_MAX = 100;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fiado/api-invoker",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.44.0",
|
|
4
4
|
"description": "Sirve como un puente entre diferentes funciones lambda, facilitando la comunicación entre ellas a través de invocaciones http",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "bin/index.js",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import dotenv from 'dotenv';
|
|
2
2
|
import { inject, injectable } from "inversify";
|
|
3
|
-
import { IHttpRequest } from "@fiado/http-client";
|
|
3
|
+
import type { IHttpRequest } from "@fiado/http-client";
|
|
4
4
|
import { IDocumentGeneratorApi } from "./interfaces/IDocumentGeneratorApi.js";
|
|
5
5
|
import { DocumentGenerateRequest } from "@fiado/type-kit/bin/credit/dtos/internal/DocumentGenerateRequest.js";
|
|
6
6
|
import { DocumentGenerateResponse } from "@fiado/type-kit/bin/credit/dtos/internal/DocumentGenerateResponse.js";
|
|
@@ -34,18 +34,18 @@ export class DocumentGeneratorApi implements IDocumentGeneratorApi {
|
|
|
34
34
|
public async getDocument(documentId: string): Promise<DocumentGenerateResponse> {
|
|
35
35
|
const url = `${this.baseUrl}document/${documentId}`;
|
|
36
36
|
const operationName = "documentGetDocument";
|
|
37
|
-
return await this.httpRequest.
|
|
37
|
+
return await this.httpRequest.get(url, undefined, { 'operationName': operationName });
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
public async getDocumentUrl(documentId: string): Promise<{ url: string; expiresAt: string }> {
|
|
41
41
|
const url = `${this.baseUrl}document/${documentId}/url`;
|
|
42
42
|
const operationName = "documentGetDocumentUrl";
|
|
43
|
-
return await this.httpRequest.
|
|
43
|
+
return await this.httpRequest.get(url, undefined, { 'operationName': operationName });
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
public async getDocumentByReference(type: string, referenceId: string): Promise<DocumentGenerateResponse[]> {
|
|
47
47
|
const url = `${this.baseUrl}document/by-reference/${type}/${referenceId}`;
|
|
48
48
|
const operationName = "documentGetDocumentByReference";
|
|
49
|
-
return await this.httpRequest.
|
|
49
|
+
return await this.httpRequest.get(url, undefined, { 'operationName': operationName });
|
|
50
50
|
}
|
|
51
51
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { inject, injectable } from "inversify";
|
|
2
2
|
import { ILegalDocumentApi } from "./interfaces/ILegalDocumentApi.js";
|
|
3
|
-
import { IHttpRequest } from "@fiado/http-client";
|
|
3
|
+
import type { IHttpRequest } from "@fiado/http-client";
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
@@ -34,5 +34,16 @@ export class LegalDocumentApi implements ILegalDocumentApi {
|
|
|
34
34
|
|
|
35
35
|
return await this.httpRequest.get<any>(url);
|
|
36
36
|
}
|
|
37
|
+
|
|
38
|
+
async getDocumentByType(type: string): Promise<any> {
|
|
39
|
+
|
|
40
|
+
if (!type) {
|
|
41
|
+
throw new Error("Document type is required.")
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const url = `${this.baseUrl}documents/types/${encodeURIComponent(type)}`;
|
|
45
|
+
|
|
46
|
+
return await this.httpRequest.get<any>(url);
|
|
47
|
+
}
|
|
37
48
|
}
|
|
38
49
|
|
|
@@ -5,4 +5,10 @@ export interface ILegalDocumentApi {
|
|
|
5
5
|
getPendingSign(directoryId: string): Promise<any>;
|
|
6
6
|
getDirectoryAcceptanceByDirectoryId(directoryId: string): Promise<any>;
|
|
7
7
|
|
|
8
|
+
/**
|
|
9
|
+
* Documento legal vigente de un tipo (PRIVACY_PAY, etc.).
|
|
10
|
+
* Devuelve el documento con su URL firmada y el vencimiento de esa URL.
|
|
11
|
+
*/
|
|
12
|
+
getDocumentByType(type: string): Promise<any>;
|
|
13
|
+
|
|
8
14
|
}
|
|
@@ -2,6 +2,8 @@ import { inject, injectable } from "inversify";
|
|
|
2
2
|
import type { IHttpRequest } from "@fiado/http-client";
|
|
3
3
|
import { StandardResponse } from "@fiado/gateway-adapter";
|
|
4
4
|
import {
|
|
5
|
+
IMEI_PRODUCT_BATCH_MAX,
|
|
6
|
+
ImeiProductLookupResponse,
|
|
5
7
|
IRetailCatalogBusinessApi,
|
|
6
8
|
ReleaseReservationBody,
|
|
7
9
|
ReserveInventoryBody,
|
|
@@ -42,6 +44,20 @@ export default class RetailCatalogBusinessApi implements IRetailCatalogBusinessA
|
|
|
42
44
|
return await this.httpRequest.get(url, undefined, this.tenantHeader(issuer));
|
|
43
45
|
}
|
|
44
46
|
|
|
47
|
+
async getProductsByImei(
|
|
48
|
+
imeis: string[],
|
|
49
|
+
tenantId: string,
|
|
50
|
+
): Promise<StandardResponse<ImeiProductLookupResponse>> {
|
|
51
|
+
// Se corta acá: mandar un lote que el destino va a rechazar solo gasta un round-trip.
|
|
52
|
+
if (imeis.length > IMEI_PRODUCT_BATCH_MAX) {
|
|
53
|
+
throw new Error(`El lote admite hasta ${IMEI_PRODUCT_BATCH_MAX} IMEIs y llegaron ${imeis.length}`);
|
|
54
|
+
}
|
|
55
|
+
// `URLSearchParams` codifica la coma del separador; el destino hace `split(',')` sobre el
|
|
56
|
+
// valor ya decodificado por API Gateway.
|
|
57
|
+
const query = new URLSearchParams({ imeis: imeis.join(","), tenantId });
|
|
58
|
+
return await this.httpRequest.get(`${this.baseUrl}/private/products/by-imei?${query.toString()}`);
|
|
59
|
+
}
|
|
60
|
+
|
|
45
61
|
async reserveInventory(
|
|
46
62
|
imei: string,
|
|
47
63
|
body: ReserveInventoryBody,
|
|
@@ -6,12 +6,17 @@ import type { MdmLockModeEnum, MdmProviderEnum } from "@fiado/type-kit/bin/retai
|
|
|
6
6
|
* para sus endpoints privados del ciclo de venta del IMEI, consumidos por el wizard F2.
|
|
7
7
|
*
|
|
8
8
|
* ─────────────────────────────────────────────────────────────────────────────
|
|
9
|
-
* TENANT —
|
|
9
|
+
* TENANT — DOS convenciones conviven acá. Mirá la firma de cada método.
|
|
10
10
|
* ─────────────────────────────────────────────────────────────────────────────
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
* `
|
|
11
|
+
* Los cinco métodos del ciclo de venta del IMEI toman `issuer` y lo mandan en el header
|
|
12
|
+
* `x-tenant-issuer` (`PrivateController.issuerFromHeader` → `TenantContextService.withContext`).
|
|
13
|
+
* `getProductsByImei` toma `tenantId` y lo manda por `?tenantId=`
|
|
14
|
+
* (→ `TenantContextService.withContextByTenantId`), porque su consumidor es un backoffice que no
|
|
15
|
+
* tiene el issuer Cognito. Los privados son `Feature.ANONIMUS` (sin RBAC; la protección es la red
|
|
16
|
+
* VPC), así que el caller DEBE declarar uno de los dos — no hay default.
|
|
17
|
+
*
|
|
18
|
+
* TD: converger los cinco del ciclo de venta a `?tenantId=`, el camino canónico para
|
|
19
|
+
* service-to-service. No se migran acá para no romper al wizard, que ya consume el header.
|
|
15
20
|
*
|
|
16
21
|
* ⚠️ Retorno `StandardResponse<T>` — el consumer lee `result.data`, NO `result.body`.
|
|
17
22
|
* Errores: el destino lanza `DomainError` tipado → el publisher RECHAZA (no devuelve null); cada
|
|
@@ -62,6 +67,32 @@ export interface StoreCatalogItem {
|
|
|
62
67
|
mdmLockMode: MdmLockModeEnum | null;
|
|
63
68
|
}
|
|
64
69
|
|
|
70
|
+
/** Techo de IMEIs por request del lote IMEI->producto. Lo declara y lo honra el destino. */
|
|
71
|
+
export const IMEI_PRODUCT_BATCH_MAX = 100;
|
|
72
|
+
|
|
73
|
+
/** Por que se pudo (o no) resolver el producto de un IMEI del lote. */
|
|
74
|
+
export type ImeiProductLookupStatus = "OK" | "NOT_FOUND" | "UNAVAILABLE" | "INVALID_ID";
|
|
75
|
+
|
|
76
|
+
/** Una entrada del lote IMEI->producto (espeja `ImeiProductLookupEntry` del destino). */
|
|
77
|
+
export interface ImeiProductLookupEntry {
|
|
78
|
+
imei: string;
|
|
79
|
+
/**
|
|
80
|
+
* `OK` trae sku/brand/model · `NOT_FOUND` el catalogo no llega al producto (dato POSITIVO) ·
|
|
81
|
+
* `UNAVAILABLE` no se pudo leer ese IMEI, reintentalo · `INVALID_ID` no tiene forma de IMEI.
|
|
82
|
+
*/
|
|
83
|
+
status: ImeiProductLookupStatus;
|
|
84
|
+
sku?: string;
|
|
85
|
+
/** Marca comercial (p. ej. "Apple"). Solo viene con `status: OK`. */
|
|
86
|
+
brand?: string;
|
|
87
|
+
/** Modelo (p. ej. "iPhone 15 Pro"). Solo viene con `status: OK`. */
|
|
88
|
+
model?: string;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/** Respuesta del lote: UNA entrada por IMEI pedido, en el MISMO orden. */
|
|
92
|
+
export interface ImeiProductLookupResponse {
|
|
93
|
+
items: ImeiProductLookupEntry[];
|
|
94
|
+
}
|
|
95
|
+
|
|
65
96
|
/** Resultado de la reserva (espeja `ReserveInventoryResponse` del destino). */
|
|
66
97
|
export interface ReserveInventoryResult {
|
|
67
98
|
reservationExpiresAt: string;
|
|
@@ -88,6 +119,31 @@ export interface IRetailCatalogBusinessApi {
|
|
|
88
119
|
/** GET `/private/stores/{storeId}/catalog` — catálogo vendible (sku, imei, precio de contado, disponibilidad). */
|
|
89
120
|
getStoreCatalog(storeId: string, issuer: string): Promise<StandardResponse<StoreCatalogItem[]>>;
|
|
90
121
|
|
|
122
|
+
/**
|
|
123
|
+
* GET `/private/products/by-imei?imeis=&tenantId=` — resuelve un lote de IMEIs a su producto
|
|
124
|
+
* (sku + marca + modelo). Para los lambdas que del equipo solo guardan el IMEI.
|
|
125
|
+
*
|
|
126
|
+
* ─────────────────────────────────────────────────────────────────────────────
|
|
127
|
+
* ⚠️ El tenant va por `?tenantId=`, NO por el header `x-tenant-issuer` del resto de este publisher.
|
|
128
|
+
* ─────────────────────────────────────────────────────────────────────────────
|
|
129
|
+
* El consumidor es un backoffice que solo tiene el `tenantId` de su contexto; el issuer Cognito
|
|
130
|
+
* no existe de su lado. El destino entra por `TenantContextService.withContextByTenantId`, con las
|
|
131
|
+
* mismas garantías (mismo diccionario, AssumeRole del silo, fail-closed sin tenant).
|
|
132
|
+
*
|
|
133
|
+
* ── El contrato del lote ────────────────────────────────────────────────────────────────────
|
|
134
|
+
* Devuelve UNA entrada por cada IMEI pedido, en el MISMO orden — el caller nunca reconcilia. Los
|
|
135
|
+
* repetidos se consultan una sola vez pero salen repetidos. Techo de `IMEI_PRODUCT_BATCH_MAX`
|
|
136
|
+
* IMEIs por request; el caller parte los lotes mayores.
|
|
137
|
+
*
|
|
138
|
+
* Ningún IMEI tumba el lote: el mal formado sale `INVALID_ID`, el que el catálogo no alcanza a
|
|
139
|
+
* resolver sale `NOT_FOUND` y el que DynamoDB no llegó a leer sale `UNAVAILABLE` (reintentable).
|
|
140
|
+
* Solo un fallo total del destino rechaza la promesa.
|
|
141
|
+
*
|
|
142
|
+
* @throws Error si el lote supera el techo (se corta acá, sin salir a la red) ·
|
|
143
|
+
* `400 IMEI_BATCH_REQUIRED` si `imeis` viene vacío · `400 UNKNOWN_TENANT` sin `tenantId`.
|
|
144
|
+
*/
|
|
145
|
+
getProductsByImei(imeis: string[], tenantId: string): Promise<StandardResponse<ImeiProductLookupResponse>>;
|
|
146
|
+
|
|
91
147
|
/** PUT `/private/inventory/{imei}/reserve` — reserva atómica del IMEI para una sesión (AVAILABLE → RESERVED). */
|
|
92
148
|
reserveInventory(imei: string, body: ReserveInventoryBody, issuer: string): Promise<StandardResponse<ReserveInventoryResult>>;
|
|
93
149
|
|