@fiado/api-invoker 5.109.0 → 5.111.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/cognitoBackofficeConnector/api/CognitoBackofficeConnectorApi.d.ts +2 -1
- package/bin/cognitoBackofficeConnector/api/CognitoBackofficeConnectorApi.js +4 -0
- package/bin/cognitoBackofficeConnector/api/interfaces/ICognitoBackofficeConnectorApi.d.ts +9 -1
- package/bin/index.d.ts +1 -0
- package/bin/index.js +1 -0
- package/bin/retailCatalog/api/RetailCatalogBusinessApi.d.ts +4 -0
- package/bin/retailCatalog/api/RetailCatalogBusinessApi.js +11 -0
- package/bin/retailCatalog/api/interfaces/IRetailCatalogBusinessApi.d.ts +5 -0
- package/bin/retailIntegration/api/RetailIntegrationConnectorApi.d.ts +17 -0
- package/bin/retailIntegration/api/RetailIntegrationConnectorApi.js +76 -0
- package/bin/retailIntegration/api/interfaces/IRetailIntegrationConnectorApi.d.ts +18 -0
- package/bin/retailIntegration/api/interfaces/IRetailIntegrationConnectorApi.js +1 -0
- package/bin/retailIntegration/index.d.ts +2 -0
- package/bin/retailIntegration/index.js +2 -0
- package/bin/retailOrg/api/RetailOrgBusinessApi.d.ts +4 -0
- package/bin/retailOrg/api/RetailOrgBusinessApi.js +12 -0
- package/bin/retailOrg/api/interfaces/IRetailOrgBusinessApi.d.ts +5 -0
- package/package.json +3 -3
- package/src/cognitoBackofficeConnector/api/CognitoBackofficeConnectorApi.ts +9 -0
- package/src/cognitoBackofficeConnector/api/interfaces/ICognitoBackofficeConnectorApi.ts +13 -0
- package/src/index.ts +1 -0
- package/src/retailCatalog/api/RetailCatalogBusinessApi.ts +29 -0
- package/src/retailCatalog/api/interfaces/IRetailCatalogBusinessApi.ts +14 -0
- package/src/retailIntegration/api/RetailIntegrationConnectorApi.ts +86 -0
- package/src/retailIntegration/api/interfaces/IRetailIntegrationConnectorApi.ts +38 -0
- package/src/retailIntegration/index.ts +2 -0
- package/src/retailOrg/api/RetailOrgBusinessApi.ts +28 -0
- package/src/retailOrg/api/interfaces/IRetailOrgBusinessApi.ts +14 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { IHttpRequest } from "@fiado/http-client";
|
|
2
2
|
import { ApiGatewayResponse } from "@fiado/gateway-adapter";
|
|
3
|
-
import { CreateUserRequest, CreateUserResponse, UpdateUserAttributesRequest, UserActionRequest, ResendInvitationRequest, SetUserPasswordRequest, UserDetailResponse, AuthEventsRequest, AuthEventResponse, InitiateAuthRequest, InitiateAuthResponse, RespondToChallengeRequest, RespondToChallengeResponse, RefreshTokensRequest, RefreshTokensResponse, ForgotPasswordRequest, ConfirmForgotPasswordRequest, ResendConfirmationRequest, ChangePasswordRequest, TotpBeginRequest, TotpBeginResponse, TotpVerifyRequest, MfaVerifyResponse, SetMfaPreferenceRequest, MfaResetRequest, UpdateEmailRequest, VerifyEmailRequest, UpdateProfileRequest, CreatePoolRequest, CreatePoolResponse, CreatePoolClientRequest, CreatePoolClientResponse, HealthcheckResponse, VerifyPasswordRequest, VerifyPasswordResponse, IntrospectRequest, IntrospectResponse } from "@fiado/type-kit/bin/cognitoBackofficeConnector/index.js";
|
|
3
|
+
import { CreateUserRequest, CreateUserResponse, UpdateUserAttributesRequest, UserActionRequest, ResendInvitationRequest, SetUserPasswordRequest, UserDetailResponse, AuthEventsRequest, AuthEventResponse, InitiateAuthRequest, InitiateAuthResponse, RespondToChallengeRequest, RespondToChallengeResponse, RefreshTokensRequest, RefreshTokensResponse, ForgotPasswordRequest, ConfirmForgotPasswordRequest, ResendConfirmationRequest, ChangePasswordRequest, TotpBeginRequest, TotpBeginResponse, TotpVerifyRequest, MfaVerifyResponse, SetMfaPreferenceRequest, MfaResetRequest, UpdateEmailRequest, VerifyEmailRequest, UpdateProfileRequest, CreatePoolRequest, CreatePoolResponse, CreatePoolClientRequest, CreatePoolClientResponse, HealthcheckResponse, VerifyPasswordRequest, VerifyPasswordResponse, AuthStartLoginRequest, AuthStartLoginResponse, IntrospectRequest, IntrospectResponse } from "@fiado/type-kit/bin/cognitoBackofficeConnector/index.js";
|
|
4
4
|
import { ICognitoBackofficeConnectorApi } from "./interfaces/ICognitoBackofficeConnectorApi.js";
|
|
5
5
|
/**
|
|
6
6
|
* Publisher HTTP del lambda `cognito-backoffice-connector` (componente 05 SureKeep Fase 0).
|
|
@@ -40,6 +40,7 @@ export default class CognitoBackofficeConnectorApi implements ICognitoBackoffice
|
|
|
40
40
|
resetUserMfa(cognitoSub: string, input: MfaResetRequest): Promise<ApiGatewayResponse<void>>;
|
|
41
41
|
authInitiate(input: InitiateAuthRequest): Promise<ApiGatewayResponse<InitiateAuthResponse>>;
|
|
42
42
|
authVerifyPassword(input: VerifyPasswordRequest): Promise<ApiGatewayResponse<VerifyPasswordResponse>>;
|
|
43
|
+
authStartLogin(input: AuthStartLoginRequest): Promise<ApiGatewayResponse<AuthStartLoginResponse>>;
|
|
43
44
|
introspect(input: IntrospectRequest): Promise<ApiGatewayResponse<IntrospectResponse>>;
|
|
44
45
|
authRespondChallenge(input: RespondToChallengeRequest): Promise<ApiGatewayResponse<RespondToChallengeResponse>>;
|
|
45
46
|
authRefreshTokens(input: RefreshTokensRequest): Promise<ApiGatewayResponse<RefreshTokensResponse>>;
|
|
@@ -97,6 +97,10 @@ let CognitoBackofficeConnectorApi = class CognitoBackofficeConnectorApi {
|
|
|
97
97
|
const url = `${this.baseUrl}/auth/verify-password`;
|
|
98
98
|
return await this.httpRequest.post(url, input);
|
|
99
99
|
}
|
|
100
|
+
async authStartLogin(input) {
|
|
101
|
+
const url = `${this.baseUrl}/auth/start-login`;
|
|
102
|
+
return await this.httpRequest.post(url, input);
|
|
103
|
+
}
|
|
100
104
|
async introspect(input) {
|
|
101
105
|
const url = `${this.baseUrl}/auth/introspect`;
|
|
102
106
|
return await this.httpRequest.post(url, input);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ApiGatewayResponse } from "@fiado/gateway-adapter";
|
|
2
|
-
import { CreateUserRequest, CreateUserResponse, UpdateUserAttributesRequest, UserActionRequest, ResendInvitationRequest, SetUserPasswordRequest, UserDetailResponse, AuthEventsRequest, AuthEventResponse, InitiateAuthRequest, InitiateAuthResponse, RespondToChallengeRequest, RespondToChallengeResponse, RefreshTokensRequest, RefreshTokensResponse, ForgotPasswordRequest, ConfirmForgotPasswordRequest, ResendConfirmationRequest, ChangePasswordRequest, TotpBeginRequest, TotpBeginResponse, TotpVerifyRequest, MfaVerifyResponse, SetMfaPreferenceRequest, MfaResetRequest, UpdateEmailRequest, VerifyEmailRequest, UpdateProfileRequest, CreatePoolRequest, CreatePoolResponse, CreatePoolClientRequest, CreatePoolClientResponse, HealthcheckResponse, VerifyPasswordRequest, VerifyPasswordResponse, IntrospectRequest, IntrospectResponse } from "@fiado/type-kit/bin/cognitoBackofficeConnector/index.js";
|
|
2
|
+
import { CreateUserRequest, CreateUserResponse, UpdateUserAttributesRequest, UserActionRequest, ResendInvitationRequest, SetUserPasswordRequest, UserDetailResponse, AuthEventsRequest, AuthEventResponse, InitiateAuthRequest, InitiateAuthResponse, RespondToChallengeRequest, RespondToChallengeResponse, RefreshTokensRequest, RefreshTokensResponse, ForgotPasswordRequest, ConfirmForgotPasswordRequest, ResendConfirmationRequest, ChangePasswordRequest, TotpBeginRequest, TotpBeginResponse, TotpVerifyRequest, MfaVerifyResponse, SetMfaPreferenceRequest, MfaResetRequest, UpdateEmailRequest, VerifyEmailRequest, UpdateProfileRequest, CreatePoolRequest, CreatePoolResponse, CreatePoolClientRequest, CreatePoolClientResponse, HealthcheckResponse, VerifyPasswordRequest, VerifyPasswordResponse, AuthStartLoginRequest, AuthStartLoginResponse, IntrospectRequest, IntrospectResponse } from "@fiado/type-kit/bin/cognitoBackofficeConnector/index.js";
|
|
3
3
|
/**
|
|
4
4
|
* Contrato del publisher HTTP del lambda `cognito-backoffice-connector` (componente 05 SureKeep Fase 0).
|
|
5
5
|
*
|
|
@@ -58,6 +58,14 @@ export interface ICognitoBackofficeConnectorApi {
|
|
|
58
58
|
* solo un veredicto `{ valid }`. El caller (rbac) NO conoce el mecanismo.
|
|
59
59
|
*/
|
|
60
60
|
authVerifyPassword(input: VerifyPasswordRequest): Promise<ApiGatewayResponse<VerifyPasswordResponse>>;
|
|
61
|
+
/**
|
|
62
|
+
* POST /auth/start-login — login de un solo flujo (SRP dentro de CUSTOM_AUTH).
|
|
63
|
+
* El connector hace InitiateAuth(CUSTOM_AUTH, SRP_A) y responde PASSWORD_VERIFIER
|
|
64
|
+
* firmado en una sola operacion; la contraseña nunca viaja en claro. Devuelve
|
|
65
|
+
* tokens (2FA apagado) o el challenge pendiente (NEW_PASSWORD_REQUIRED / el
|
|
66
|
+
* CUSTOM_CHALLENGE del 2do factor). El caller (rbac) decide por que rama sigue.
|
|
67
|
+
*/
|
|
68
|
+
authStartLogin(input: AuthStartLoginRequest): Promise<ApiGatewayResponse<AuthStartLoginResponse>>;
|
|
61
69
|
/**
|
|
62
70
|
* POST /auth/introspect — valida un token (firma + exp + iss + client_id +
|
|
63
71
|
* token_use) y devuelve `{ valid, cognitoSub?, reason? }`. El connector es
|
package/bin/index.d.ts
CHANGED
|
@@ -90,6 +90,7 @@ export * from "./retailCards/index.js";
|
|
|
90
90
|
export * from "./retailNotifications/index.js";
|
|
91
91
|
export * from "./retailWizard/index.js";
|
|
92
92
|
export * from "./retailPromotions/index.js";
|
|
93
|
+
export * from "./retailIntegration/index.js";
|
|
93
94
|
export * from "./shortlink/index.js";
|
|
94
95
|
export * from "./loanConfig/index.js";
|
|
95
96
|
export * from "./loanOfferings/index.js";
|
package/bin/index.js
CHANGED
|
@@ -90,6 +90,7 @@ export * from "./retailCards/index.js";
|
|
|
90
90
|
export * from "./retailNotifications/index.js";
|
|
91
91
|
export * from "./retailWizard/index.js";
|
|
92
92
|
export * from "./retailPromotions/index.js";
|
|
93
|
+
export * from "./retailIntegration/index.js";
|
|
93
94
|
export * from "./shortlink/index.js";
|
|
94
95
|
export * from "./loanConfig/index.js";
|
|
95
96
|
export * from "./loanOfferings/index.js";
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { IHttpRequest } from "@fiado/http-client";
|
|
2
2
|
import { StandardResponse } from "@fiado/gateway-adapter";
|
|
3
3
|
import type { GetStoreStockCatalogResponse, HoldStockRequest, HoldStockResponse, InventoryLensQuery, InventoryLensResponse, ReleaseStockRequest, ReleaseStockResponse, RenewReservationsRequest, RenewReservationsResponse, ReserveStockRequest, ReserveStockResponse, ReturnStockRequest, ReturnStockResponse, SellStockRequest, SellStockResponse, SuggestPiecesQuery, SuggestPiecesResponse, SyncInventoryRequest, SyncInventoryResponse, ValidateProductResponse } from "@fiado/type-kit/bin/retailCatalog/index.js";
|
|
4
|
+
import type { ApplyInventoryEventRequest, ApplyInventoryEventResponse, ApplyProductEventRequest, ApplyProductEventResponse } from "@fiado/type-kit/bin/retailIntegration/index.js";
|
|
4
5
|
import { IRetailCatalogBusinessApi, ProductsByRetailersResponse, ReleaseReservationBody, ReserveInventoryBody, ReserveInventoryResult, SellInventoryBody, StoreCatalogItem } from "./interfaces/IRetailCatalogBusinessApi.js";
|
|
5
6
|
/**
|
|
6
7
|
* Publisher HTTP del lambda `retail-catalog-business` (SureKeep Fase 1, pista Retail) para sus
|
|
@@ -39,4 +40,7 @@ export default class RetailCatalogBusinessApi implements IRetailCatalogBusinessA
|
|
|
39
40
|
syncInventory(retailerId: string, body: SyncInventoryRequest, tenantId: string): Promise<StandardResponse<SyncInventoryResponse>>;
|
|
40
41
|
getStoreStockCatalog(storeId: string, tenantId: string): Promise<StandardResponse<GetStoreStockCatalogResponse>>;
|
|
41
42
|
getInventoryLens(tenantId: string, retailerId: string, query: InventoryLensQuery): Promise<StandardResponse<InventoryLensResponse>>;
|
|
43
|
+
privateApplyProductEvent(request: ApplyProductEventRequest): Promise<StandardResponse<ApplyProductEventResponse>>;
|
|
44
|
+
privateApplyInventoryEvent(request: ApplyInventoryEventRequest): Promise<StandardResponse<ApplyInventoryEventResponse>>;
|
|
45
|
+
private applyRetailEvent;
|
|
42
46
|
}
|
|
@@ -115,6 +115,17 @@ let RetailCatalogBusinessApi = class RetailCatalogBusinessApi {
|
|
|
115
115
|
params.set("storeId", query.storeId);
|
|
116
116
|
return await this.httpRequest.get(`${this.baseUrl}/private/inventory/lens?${params.toString()}`);
|
|
117
117
|
}
|
|
118
|
+
async privateApplyProductEvent(request) {
|
|
119
|
+
return await this.applyRetailEvent("/private/integration/product-events", request);
|
|
120
|
+
}
|
|
121
|
+
async privateApplyInventoryEvent(request) {
|
|
122
|
+
return await this.applyRetailEvent("/private/integration/inventory-events", request);
|
|
123
|
+
}
|
|
124
|
+
// Reenvía un evento del retailer; `enableTimeout` usa HTTP_CLIENT_REQUEST_TIMEOUT_MILISECONDS del consumidor.
|
|
125
|
+
async applyRetailEvent(path, request) {
|
|
126
|
+
const url = `${this.baseUrl}${path}?tenantId=${encodeURIComponent(request.tenantId)}`;
|
|
127
|
+
return await this.httpRequest.post(url, request, {}, undefined, true);
|
|
128
|
+
}
|
|
118
129
|
};
|
|
119
130
|
RetailCatalogBusinessApi = __decorate([
|
|
120
131
|
injectable(),
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { StandardResponse } from "@fiado/gateway-adapter";
|
|
2
2
|
import type { GetStoreStockCatalogResponse, HoldStockRequest, HoldStockResponse, InventoryLensQuery, InventoryLensResponse, MdmLockModeEnum, MdmProviderEnum, ReleaseStockRequest, ReleaseStockResponse, RenewReservationsRequest, RenewReservationsResponse, ReserveStockRequest, ReserveStockResponse, ReturnStockRequest, ReturnStockResponse, SellStockRequest, SellStockResponse, SuggestPiecesQuery, SuggestPiecesResponse, SyncInventoryRequest, SyncInventoryResponse, ValidateProductResponse } from "@fiado/type-kit/bin/retailCatalog/index.js";
|
|
3
|
+
import type { ApplyInventoryEventRequest, ApplyInventoryEventResponse, ApplyProductEventRequest, ApplyProductEventResponse } from "@fiado/type-kit/bin/retailIntegration/index.js";
|
|
3
4
|
/**
|
|
4
5
|
* Contrato del publisher HTTP del lambda `retail-catalog-business` (SureKeep Fase 1, pista Retail)
|
|
5
6
|
* para sus endpoints privados del ciclo de venta del IMEI, consumidos por el wizard F2.
|
|
@@ -175,4 +176,8 @@ export interface IRetailCatalogBusinessApi {
|
|
|
175
176
|
getStoreStockCatalog(storeId: string, tenantId: string): Promise<StandardResponse<GetStoreStockCatalogResponse>>;
|
|
176
177
|
/** GET `/private/inventory/lens` — lente de inventario del retailer; `period` y `storeId` solo aplican a `filter=list`. */
|
|
177
178
|
getInventoryLens(tenantId: string, retailerId: string, query: InventoryLensQuery): Promise<StandardResponse<InventoryLensResponse>>;
|
|
179
|
+
/** `POST /private/integration/product-events?tenantId=` — aplica un evento de producto del retailer. */
|
|
180
|
+
privateApplyProductEvent(request: ApplyProductEventRequest): Promise<StandardResponse<ApplyProductEventResponse>>;
|
|
181
|
+
/** `POST /private/integration/inventory-events?tenantId=` — aplica un movimiento de inventario del retailer. */
|
|
182
|
+
privateApplyInventoryEvent(request: ApplyInventoryEventRequest): Promise<StandardResponse<ApplyInventoryEventResponse>>;
|
|
178
183
|
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { IHttpRequest } from "@fiado/http-client";
|
|
2
|
+
import { StandardResponse } from "@fiado/gateway-adapter";
|
|
3
|
+
import type { GetRetailInventoryRequest, GetRetailInventoryResponse, ListRetailCatalogRequest, ListRetailCatalogResponse, ListRetailStoresRequest, ListRetailStoresResponse, ListRetailUsersRequest, ListRetailUsersResponse, RegisterRetailSaleRequest, RegisterRetailSaleResponse, RetailSystemSale } from "@fiado/type-kit/bin/retailIntegration/index.js";
|
|
4
|
+
import { IRetailIntegrationConnectorApi } from "./interfaces/IRetailIntegrationConnectorApi.js";
|
|
5
|
+
/** Publisher de la salida privada de `retail-integration-connector`. */
|
|
6
|
+
export default class RetailIntegrationConnectorApi implements IRetailIntegrationConnectorApi {
|
|
7
|
+
private httpRequest;
|
|
8
|
+
private readonly baseUrl;
|
|
9
|
+
constructor(httpRequest: IHttpRequest);
|
|
10
|
+
listRetailStores(request: ListRetailStoresRequest): Promise<StandardResponse<ListRetailStoresResponse>>;
|
|
11
|
+
listRetailCatalog(request: ListRetailCatalogRequest): Promise<StandardResponse<ListRetailCatalogResponse>>;
|
|
12
|
+
getRetailInventory(request: GetRetailInventoryRequest): Promise<StandardResponse<GetRetailInventoryResponse>>;
|
|
13
|
+
listRetailUsers(request: ListRetailUsersRequest): Promise<StandardResponse<ListRetailUsersResponse>>;
|
|
14
|
+
registerRetailSale(request: RegisterRetailSaleRequest, sale: RetailSystemSale): Promise<StandardResponse<RegisterRetailSaleResponse>>;
|
|
15
|
+
private getWithTimeout;
|
|
16
|
+
private toQuery;
|
|
17
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
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;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
11
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
12
|
+
};
|
|
13
|
+
import { inject, injectable } from "inversify";
|
|
14
|
+
/** Mayor que el Timeout de 10 s del connector, para no cortar una venta en vuelo. */
|
|
15
|
+
const RETAIL_INTEGRATION_CONNECTOR_TIMEOUT_MS = 12000;
|
|
16
|
+
/** Publisher de la salida privada de `retail-integration-connector`. */
|
|
17
|
+
let RetailIntegrationConnectorApi = class RetailIntegrationConnectorApi {
|
|
18
|
+
httpRequest;
|
|
19
|
+
baseUrl = (process.env.RETAIL_INTEGRATION_CONNECTOR_URL || "").replace(/\/+$/, "");
|
|
20
|
+
constructor(httpRequest) {
|
|
21
|
+
this.httpRequest = httpRequest;
|
|
22
|
+
}
|
|
23
|
+
async listRetailStores(request) {
|
|
24
|
+
return await this.getWithTimeout("/private/retail/stores", {
|
|
25
|
+
tenantId: request.tenantId,
|
|
26
|
+
limit: request.limit,
|
|
27
|
+
nextToken: request.nextToken,
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
async listRetailCatalog(request) {
|
|
31
|
+
return await this.getWithTimeout("/private/retail/catalog", {
|
|
32
|
+
tenantId: request.tenantId,
|
|
33
|
+
limit: request.limit,
|
|
34
|
+
nextToken: request.nextToken,
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
async getRetailInventory(request) {
|
|
38
|
+
return await this.getWithTimeout("/private/retail/inventory", {
|
|
39
|
+
tenantId: request.tenantId,
|
|
40
|
+
storeId: request.storeId,
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
async listRetailUsers(request) {
|
|
44
|
+
return await this.getWithTimeout("/private/retail/users", {
|
|
45
|
+
tenantId: request.tenantId,
|
|
46
|
+
storeId: request.storeId,
|
|
47
|
+
limit: request.limit,
|
|
48
|
+
nextToken: request.nextToken,
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
async registerRetailSale(request, sale) {
|
|
52
|
+
const url = `${this.baseUrl}/private/retail/sales?${this.toQuery({ tenantId: request.tenantId })}`;
|
|
53
|
+
return await this.httpRequest.post(url, sale, {}, undefined, false, {
|
|
54
|
+
timeout: RETAIL_INTEGRATION_CONNECTOR_TIMEOUT_MS,
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
// GET con timeout propio; nunca `enableTimeout`, que tomaría el timeout corto del consumidor.
|
|
58
|
+
async getWithTimeout(path, fields) {
|
|
59
|
+
const url = `${this.baseUrl}${path}?${this.toQuery(fields)}`;
|
|
60
|
+
return await this.httpRequest.get(url, {}, {}, undefined, { timeout: RETAIL_INTEGRATION_CONNECTOR_TIMEOUT_MS }, false);
|
|
61
|
+
}
|
|
62
|
+
toQuery(fields) {
|
|
63
|
+
const params = new URLSearchParams();
|
|
64
|
+
for (const [key, value] of Object.entries(fields)) {
|
|
65
|
+
if (value !== undefined)
|
|
66
|
+
params.set(key, String(value));
|
|
67
|
+
}
|
|
68
|
+
return params.toString();
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
RetailIntegrationConnectorApi = __decorate([
|
|
72
|
+
injectable(),
|
|
73
|
+
__param(0, inject("IHttpRequest")),
|
|
74
|
+
__metadata("design:paramtypes", [Object])
|
|
75
|
+
], RetailIntegrationConnectorApi);
|
|
76
|
+
export default RetailIntegrationConnectorApi;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { StandardResponse } from "@fiado/gateway-adapter";
|
|
2
|
+
import type { GetRetailInventoryRequest, GetRetailInventoryResponse, ListRetailCatalogRequest, ListRetailCatalogResponse, ListRetailStoresRequest, ListRetailStoresResponse, ListRetailUsersRequest, ListRetailUsersResponse, RegisterRetailSaleRequest, RegisterRetailSaleResponse, RetailSystemSale } from "@fiado/type-kit/bin/retailIntegration/index.js";
|
|
3
|
+
/**
|
|
4
|
+
* Salida privada de `retail-integration-connector` hacia el sistema del retailer del tenant.
|
|
5
|
+
* Env var del consumidor: `RETAIL_INTEGRATION_CONNECTOR_URL: '{{resolve:ssm:retail-integration-connector}}'`.
|
|
6
|
+
*/
|
|
7
|
+
export interface IRetailIntegrationConnectorApi {
|
|
8
|
+
/** `GET /private/retail/stores` — una página de tiendas del retailer. */
|
|
9
|
+
listRetailStores(request: ListRetailStoresRequest): Promise<StandardResponse<ListRetailStoresResponse>>;
|
|
10
|
+
/** `GET /private/retail/catalog` — una página del catálogo del retailer. */
|
|
11
|
+
listRetailCatalog(request: ListRetailCatalogRequest): Promise<StandardResponse<ListRetailCatalogResponse>>;
|
|
12
|
+
/** `GET /private/retail/inventory` — piezas y existencias de una tienda. */
|
|
13
|
+
getRetailInventory(request: GetRetailInventoryRequest): Promise<StandardResponse<GetRetailInventoryResponse>>;
|
|
14
|
+
/** `GET /private/retail/users` — una página de usuarios, opcionalmente de una tienda. */
|
|
15
|
+
listRetailUsers(request: ListRetailUsersRequest): Promise<StandardResponse<ListRetailUsersResponse>>;
|
|
16
|
+
/** `POST /private/retail/sales` — registra la venta; ante timeout o 502, reintenta con el mismo `saleId`. */
|
|
17
|
+
registerRetailSale(request: RegisterRetailSaleRequest, sale: RetailSystemSale): Promise<StandardResponse<RegisterRetailSaleResponse>>;
|
|
18
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { IHttpRequest } from "@fiado/http-client";
|
|
2
2
|
import { StandardResponse } from "@fiado/gateway-adapter";
|
|
3
3
|
import { RetailerValidationDto, StoreValidationDto, RetailUserValidationDto, CollectorValidationDto, PrivateSellerListResponse, RetailUserStatusEnum } from "@fiado/type-kit/bin/retailOrg/index.js";
|
|
4
|
+
import type { ApplyRetailUserEventRequest, ApplyRetailUserEventResponse, ApplyStoreEventRequest, ApplyStoreEventResponse } from "@fiado/type-kit/bin/retailIntegration/index.js";
|
|
4
5
|
import { IRetailOrgBusinessApi, RetailerRosterStatusFilter, StoreRosterStatusFilter } from "./interfaces/IRetailOrgBusinessApi.js";
|
|
5
6
|
/**
|
|
6
7
|
* Publisher HTTP del lambda `retail-org-business` (componente 04 SureKeep Fase 1) para sus 9
|
|
@@ -49,4 +50,7 @@ export default class RetailOrgBusinessApi implements IRetailOrgBusinessApi {
|
|
|
49
50
|
* path: el caller no está validando un recurso, está pidiendo una colección entera.
|
|
50
51
|
*/
|
|
51
52
|
listSellers(retailerId: string, tenantId: string, callerService: string, status?: RetailUserStatusEnum): Promise<StandardResponse<PrivateSellerListResponse>>;
|
|
53
|
+
privateApplyStoreEvent(request: ApplyStoreEventRequest): Promise<StandardResponse<ApplyStoreEventResponse>>;
|
|
54
|
+
privateApplyRetailUserEvent(request: ApplyRetailUserEventRequest): Promise<StandardResponse<ApplyRetailUserEventResponse>>;
|
|
55
|
+
private applyRetailEvent;
|
|
52
56
|
}
|
|
@@ -100,6 +100,18 @@ let RetailOrgBusinessApi = class RetailOrgBusinessApi {
|
|
|
100
100
|
query.set("status", status);
|
|
101
101
|
return await this.httpRequest.get(`${this.baseUrl}/private/sellers?${query.toString()}`);
|
|
102
102
|
}
|
|
103
|
+
async privateApplyStoreEvent(request) {
|
|
104
|
+
return await this.applyRetailEvent("/private/integration/store-events", request);
|
|
105
|
+
}
|
|
106
|
+
async privateApplyRetailUserEvent(request) {
|
|
107
|
+
return await this.applyRetailEvent("/private/integration/retail-user-events", request);
|
|
108
|
+
}
|
|
109
|
+
// Reenvía un evento del retailer; quita la "/" final de la base porque el SSM la publica con ella.
|
|
110
|
+
async applyRetailEvent(path, request) {
|
|
111
|
+
const base = this.baseUrl.replace(/\/+$/, "");
|
|
112
|
+
const url = `${base}${path}?tenantId=${encodeURIComponent(request.tenantId)}`;
|
|
113
|
+
return await this.httpRequest.post(url, request, {}, undefined, true);
|
|
114
|
+
}
|
|
103
115
|
};
|
|
104
116
|
RetailOrgBusinessApi = __decorate([
|
|
105
117
|
injectable(),
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { StandardResponse } from "@fiado/gateway-adapter";
|
|
2
2
|
import { RetailerValidationDto, StoreValidationDto, RetailUserValidationDto, CollectorValidationDto, PrivateSellerListResponse, RetailUserStatusEnum, RetailerStatusEnum, StoreStatusEnum } from "@fiado/type-kit/bin/retailOrg/index.js";
|
|
3
|
+
import type { ApplyRetailUserEventRequest, ApplyRetailUserEventResponse, ApplyStoreEventRequest, ApplyStoreEventResponse } from "@fiado/type-kit/bin/retailIntegration/index.js";
|
|
3
4
|
/**
|
|
4
5
|
* Filtro de `listStoresByRetailer`. `"ALL"` no es un estado de tienda: es la ausencia de filtro, y
|
|
5
6
|
* va en el MISMO parámetro que los estados porque los dos hablan del mismo eje — un segundo flag
|
|
@@ -218,4 +219,8 @@ export interface IRetailOrgBusinessApi {
|
|
|
218
219
|
* @throws `400 VALIDATION_ERROR` si `retailerId` no es un ULID · `400 UNKNOWN_TENANT` sin `tenantId`.
|
|
219
220
|
*/
|
|
220
221
|
listSellers(retailerId: string, tenantId: string, callerService: string, status?: RetailUserStatusEnum): Promise<StandardResponse<PrivateSellerListResponse>>;
|
|
222
|
+
/** `POST /private/integration/store-events?tenantId=` — aplica un evento de tienda del retailer. */
|
|
223
|
+
privateApplyStoreEvent(request: ApplyStoreEventRequest): Promise<StandardResponse<ApplyStoreEventResponse>>;
|
|
224
|
+
/** `POST /private/integration/retail-user-events?tenantId=` — aplica un evento de usuario del retailer. */
|
|
225
|
+
privateApplyRetailUserEvent(request: ApplyRetailUserEventRequest): Promise<StandardResponse<ApplyRetailUserEventResponse>>;
|
|
221
226
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fiado/api-invoker",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.111.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",
|
|
@@ -31,10 +31,10 @@
|
|
|
31
31
|
"license": "ISC",
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"@aws-sdk/client-sqs": "^3.919.0",
|
|
34
|
-
"@fiado/gateway-adapter": "^3.
|
|
34
|
+
"@fiado/gateway-adapter": "^3.14.0",
|
|
35
35
|
"@fiado/http-client": "^2.0.1",
|
|
36
36
|
"@fiado/logger": "^1.1.3",
|
|
37
|
-
"@fiado/type-kit": "^3.
|
|
37
|
+
"@fiado/type-kit": "^3.500.0",
|
|
38
38
|
"dotenv": "^16.4.7"
|
|
39
39
|
},
|
|
40
40
|
"peerDependencies": {
|
|
@@ -38,6 +38,8 @@ import {
|
|
|
38
38
|
HealthcheckResponse,
|
|
39
39
|
VerifyPasswordRequest,
|
|
40
40
|
VerifyPasswordResponse,
|
|
41
|
+
AuthStartLoginRequest,
|
|
42
|
+
AuthStartLoginResponse,
|
|
41
43
|
IntrospectRequest,
|
|
42
44
|
IntrospectResponse,
|
|
43
45
|
} from "@fiado/type-kit/bin/cognitoBackofficeConnector/index.js";
|
|
@@ -190,6 +192,13 @@ export default class CognitoBackofficeConnectorApi implements ICognitoBackoffice
|
|
|
190
192
|
return await this.httpRequest.post(url, input);
|
|
191
193
|
}
|
|
192
194
|
|
|
195
|
+
async authStartLogin(
|
|
196
|
+
input: AuthStartLoginRequest,
|
|
197
|
+
): Promise<ApiGatewayResponse<AuthStartLoginResponse>> {
|
|
198
|
+
const url = `${this.baseUrl}/auth/start-login`;
|
|
199
|
+
return await this.httpRequest.post(url, input);
|
|
200
|
+
}
|
|
201
|
+
|
|
193
202
|
async introspect(
|
|
194
203
|
input: IntrospectRequest,
|
|
195
204
|
): Promise<ApiGatewayResponse<IntrospectResponse>> {
|
|
@@ -36,6 +36,8 @@ import {
|
|
|
36
36
|
HealthcheckResponse,
|
|
37
37
|
VerifyPasswordRequest,
|
|
38
38
|
VerifyPasswordResponse,
|
|
39
|
+
AuthStartLoginRequest,
|
|
40
|
+
AuthStartLoginResponse,
|
|
39
41
|
IntrospectRequest,
|
|
40
42
|
IntrospectResponse,
|
|
41
43
|
} from "@fiado/type-kit/bin/cognitoBackofficeConnector/index.js";
|
|
@@ -141,6 +143,17 @@ export interface ICognitoBackofficeConnectorApi {
|
|
|
141
143
|
input: VerifyPasswordRequest,
|
|
142
144
|
): Promise<ApiGatewayResponse<VerifyPasswordResponse>>;
|
|
143
145
|
|
|
146
|
+
/**
|
|
147
|
+
* POST /auth/start-login — login de un solo flujo (SRP dentro de CUSTOM_AUTH).
|
|
148
|
+
* El connector hace InitiateAuth(CUSTOM_AUTH, SRP_A) y responde PASSWORD_VERIFIER
|
|
149
|
+
* firmado en una sola operacion; la contraseña nunca viaja en claro. Devuelve
|
|
150
|
+
* tokens (2FA apagado) o el challenge pendiente (NEW_PASSWORD_REQUIRED / el
|
|
151
|
+
* CUSTOM_CHALLENGE del 2do factor). El caller (rbac) decide por que rama sigue.
|
|
152
|
+
*/
|
|
153
|
+
authStartLogin(
|
|
154
|
+
input: AuthStartLoginRequest,
|
|
155
|
+
): Promise<ApiGatewayResponse<AuthStartLoginResponse>>;
|
|
156
|
+
|
|
144
157
|
/**
|
|
145
158
|
* POST /auth/introspect — valida un token (firma + exp + iss + client_id +
|
|
146
159
|
* token_use) y devuelve `{ valid, cognitoSub?, reason? }`. El connector es
|
package/src/index.ts
CHANGED
|
@@ -90,6 +90,7 @@ export * from "./retailCards/index.js";
|
|
|
90
90
|
export * from "./retailNotifications/index.js";
|
|
91
91
|
export * from "./retailWizard/index.js";
|
|
92
92
|
export * from "./retailPromotions/index.js";
|
|
93
|
+
export * from "./retailIntegration/index.js";
|
|
93
94
|
export * from "./shortlink/index.js";
|
|
94
95
|
export * from "./loanConfig/index.js";
|
|
95
96
|
export * from "./loanOfferings/index.js";
|
|
@@ -23,6 +23,14 @@ import type {
|
|
|
23
23
|
SyncInventoryResponse,
|
|
24
24
|
ValidateProductResponse,
|
|
25
25
|
} from "@fiado/type-kit/bin/retailCatalog/index.js";
|
|
26
|
+
import type {
|
|
27
|
+
ApplyInventoryEventRequest,
|
|
28
|
+
ApplyInventoryEventResponse,
|
|
29
|
+
ApplyProductEventRequest,
|
|
30
|
+
ApplyProductEventResponse,
|
|
31
|
+
ApplyRetailEventRequest,
|
|
32
|
+
ApplyRetailEventResponse,
|
|
33
|
+
} from "@fiado/type-kit/bin/retailIntegration/index.js";
|
|
26
34
|
import {
|
|
27
35
|
IRetailCatalogBusinessApi,
|
|
28
36
|
ProductsByRetailersBody,
|
|
@@ -210,4 +218,25 @@ export default class RetailCatalogBusinessApi implements IRetailCatalogBusinessA
|
|
|
210
218
|
if (query.storeId) params.set("storeId", query.storeId);
|
|
211
219
|
return await this.httpRequest.get(`${this.baseUrl}/private/inventory/lens?${params.toString()}`);
|
|
212
220
|
}
|
|
221
|
+
|
|
222
|
+
async privateApplyProductEvent(
|
|
223
|
+
request: ApplyProductEventRequest,
|
|
224
|
+
): Promise<StandardResponse<ApplyProductEventResponse>> {
|
|
225
|
+
return await this.applyRetailEvent("/private/integration/product-events", request);
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
async privateApplyInventoryEvent(
|
|
229
|
+
request: ApplyInventoryEventRequest,
|
|
230
|
+
): Promise<StandardResponse<ApplyInventoryEventResponse>> {
|
|
231
|
+
return await this.applyRetailEvent("/private/integration/inventory-events", request);
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
// Reenvía un evento del retailer; `enableTimeout` usa HTTP_CLIENT_REQUEST_TIMEOUT_MILISECONDS del consumidor.
|
|
235
|
+
private async applyRetailEvent(
|
|
236
|
+
path: string,
|
|
237
|
+
request: ApplyRetailEventRequest,
|
|
238
|
+
): Promise<StandardResponse<ApplyRetailEventResponse>> {
|
|
239
|
+
const url = `${this.baseUrl}${path}?tenantId=${encodeURIComponent(request.tenantId)}`;
|
|
240
|
+
return await this.httpRequest.post(url, request, {}, undefined, true);
|
|
241
|
+
}
|
|
213
242
|
}
|
|
@@ -23,6 +23,12 @@ import type {
|
|
|
23
23
|
SyncInventoryResponse,
|
|
24
24
|
ValidateProductResponse,
|
|
25
25
|
} from "@fiado/type-kit/bin/retailCatalog/index.js";
|
|
26
|
+
import type {
|
|
27
|
+
ApplyInventoryEventRequest,
|
|
28
|
+
ApplyInventoryEventResponse,
|
|
29
|
+
ApplyProductEventRequest,
|
|
30
|
+
ApplyProductEventResponse,
|
|
31
|
+
} from "@fiado/type-kit/bin/retailIntegration/index.js";
|
|
26
32
|
|
|
27
33
|
/**
|
|
28
34
|
* Contrato del publisher HTTP del lambda `retail-catalog-business` (SureKeep Fase 1, pista Retail)
|
|
@@ -268,4 +274,12 @@ export interface IRetailCatalogBusinessApi {
|
|
|
268
274
|
retailerId: string,
|
|
269
275
|
query: InventoryLensQuery,
|
|
270
276
|
): Promise<StandardResponse<InventoryLensResponse>>;
|
|
277
|
+
|
|
278
|
+
/** `POST /private/integration/product-events?tenantId=` — aplica un evento de producto del retailer. */
|
|
279
|
+
privateApplyProductEvent(request: ApplyProductEventRequest): Promise<StandardResponse<ApplyProductEventResponse>>;
|
|
280
|
+
|
|
281
|
+
/** `POST /private/integration/inventory-events?tenantId=` — aplica un movimiento de inventario del retailer. */
|
|
282
|
+
privateApplyInventoryEvent(
|
|
283
|
+
request: ApplyInventoryEventRequest,
|
|
284
|
+
): Promise<StandardResponse<ApplyInventoryEventResponse>>;
|
|
271
285
|
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { inject, injectable } from "inversify";
|
|
2
|
+
import type { IHttpRequest } from "@fiado/http-client";
|
|
3
|
+
import { StandardResponse } from "@fiado/gateway-adapter";
|
|
4
|
+
import type {
|
|
5
|
+
GetRetailInventoryRequest,
|
|
6
|
+
GetRetailInventoryResponse,
|
|
7
|
+
ListRetailCatalogRequest,
|
|
8
|
+
ListRetailCatalogResponse,
|
|
9
|
+
ListRetailStoresRequest,
|
|
10
|
+
ListRetailStoresResponse,
|
|
11
|
+
ListRetailUsersRequest,
|
|
12
|
+
ListRetailUsersResponse,
|
|
13
|
+
RegisterRetailSaleRequest,
|
|
14
|
+
RegisterRetailSaleResponse,
|
|
15
|
+
RetailSystemSale,
|
|
16
|
+
} from "@fiado/type-kit/bin/retailIntegration/index.js";
|
|
17
|
+
import { IRetailIntegrationConnectorApi } from "./interfaces/IRetailIntegrationConnectorApi.js";
|
|
18
|
+
|
|
19
|
+
/** Mayor que el Timeout de 10 s del connector, para no cortar una venta en vuelo. */
|
|
20
|
+
const RETAIL_INTEGRATION_CONNECTOR_TIMEOUT_MS = 12000;
|
|
21
|
+
|
|
22
|
+
type QueryFields = Record<string, string | number | undefined>;
|
|
23
|
+
|
|
24
|
+
/** Publisher de la salida privada de `retail-integration-connector`. */
|
|
25
|
+
@injectable()
|
|
26
|
+
export default class RetailIntegrationConnectorApi implements IRetailIntegrationConnectorApi {
|
|
27
|
+
private readonly baseUrl = (process.env.RETAIL_INTEGRATION_CONNECTOR_URL || "").replace(/\/+$/, "");
|
|
28
|
+
|
|
29
|
+
constructor(@inject("IHttpRequest") private httpRequest: IHttpRequest) {}
|
|
30
|
+
|
|
31
|
+
async listRetailStores(request: ListRetailStoresRequest): Promise<StandardResponse<ListRetailStoresResponse>> {
|
|
32
|
+
return await this.getWithTimeout("/private/retail/stores", {
|
|
33
|
+
tenantId: request.tenantId,
|
|
34
|
+
limit: request.limit,
|
|
35
|
+
nextToken: request.nextToken,
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
async listRetailCatalog(request: ListRetailCatalogRequest): Promise<StandardResponse<ListRetailCatalogResponse>> {
|
|
40
|
+
return await this.getWithTimeout("/private/retail/catalog", {
|
|
41
|
+
tenantId: request.tenantId,
|
|
42
|
+
limit: request.limit,
|
|
43
|
+
nextToken: request.nextToken,
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
async getRetailInventory(request: GetRetailInventoryRequest): Promise<StandardResponse<GetRetailInventoryResponse>> {
|
|
48
|
+
return await this.getWithTimeout("/private/retail/inventory", {
|
|
49
|
+
tenantId: request.tenantId,
|
|
50
|
+
storeId: request.storeId,
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
async listRetailUsers(request: ListRetailUsersRequest): Promise<StandardResponse<ListRetailUsersResponse>> {
|
|
55
|
+
return await this.getWithTimeout("/private/retail/users", {
|
|
56
|
+
tenantId: request.tenantId,
|
|
57
|
+
storeId: request.storeId,
|
|
58
|
+
limit: request.limit,
|
|
59
|
+
nextToken: request.nextToken,
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
async registerRetailSale(
|
|
64
|
+
request: RegisterRetailSaleRequest,
|
|
65
|
+
sale: RetailSystemSale,
|
|
66
|
+
): Promise<StandardResponse<RegisterRetailSaleResponse>> {
|
|
67
|
+
const url = `${this.baseUrl}/private/retail/sales?${this.toQuery({ tenantId: request.tenantId })}`;
|
|
68
|
+
return await this.httpRequest.post(url, sale, {}, undefined, false, {
|
|
69
|
+
timeout: RETAIL_INTEGRATION_CONNECTOR_TIMEOUT_MS,
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// GET con timeout propio; nunca `enableTimeout`, que tomaría el timeout corto del consumidor.
|
|
74
|
+
private async getWithTimeout<T>(path: string, fields: QueryFields): Promise<StandardResponse<T>> {
|
|
75
|
+
const url = `${this.baseUrl}${path}?${this.toQuery(fields)}`;
|
|
76
|
+
return await this.httpRequest.get(url, {}, {}, undefined, { timeout: RETAIL_INTEGRATION_CONNECTOR_TIMEOUT_MS }, false);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
private toQuery(fields: QueryFields): string {
|
|
80
|
+
const params = new URLSearchParams();
|
|
81
|
+
for (const [key, value] of Object.entries(fields)) {
|
|
82
|
+
if (value !== undefined) params.set(key, String(value));
|
|
83
|
+
}
|
|
84
|
+
return params.toString();
|
|
85
|
+
}
|
|
86
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { StandardResponse } from "@fiado/gateway-adapter";
|
|
2
|
+
import type {
|
|
3
|
+
GetRetailInventoryRequest,
|
|
4
|
+
GetRetailInventoryResponse,
|
|
5
|
+
ListRetailCatalogRequest,
|
|
6
|
+
ListRetailCatalogResponse,
|
|
7
|
+
ListRetailStoresRequest,
|
|
8
|
+
ListRetailStoresResponse,
|
|
9
|
+
ListRetailUsersRequest,
|
|
10
|
+
ListRetailUsersResponse,
|
|
11
|
+
RegisterRetailSaleRequest,
|
|
12
|
+
RegisterRetailSaleResponse,
|
|
13
|
+
RetailSystemSale,
|
|
14
|
+
} from "@fiado/type-kit/bin/retailIntegration/index.js";
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Salida privada de `retail-integration-connector` hacia el sistema del retailer del tenant.
|
|
18
|
+
* Env var del consumidor: `RETAIL_INTEGRATION_CONNECTOR_URL: '{{resolve:ssm:retail-integration-connector}}'`.
|
|
19
|
+
*/
|
|
20
|
+
export interface IRetailIntegrationConnectorApi {
|
|
21
|
+
/** `GET /private/retail/stores` — una página de tiendas del retailer. */
|
|
22
|
+
listRetailStores(request: ListRetailStoresRequest): Promise<StandardResponse<ListRetailStoresResponse>>;
|
|
23
|
+
|
|
24
|
+
/** `GET /private/retail/catalog` — una página del catálogo del retailer. */
|
|
25
|
+
listRetailCatalog(request: ListRetailCatalogRequest): Promise<StandardResponse<ListRetailCatalogResponse>>;
|
|
26
|
+
|
|
27
|
+
/** `GET /private/retail/inventory` — piezas y existencias de una tienda. */
|
|
28
|
+
getRetailInventory(request: GetRetailInventoryRequest): Promise<StandardResponse<GetRetailInventoryResponse>>;
|
|
29
|
+
|
|
30
|
+
/** `GET /private/retail/users` — una página de usuarios, opcionalmente de una tienda. */
|
|
31
|
+
listRetailUsers(request: ListRetailUsersRequest): Promise<StandardResponse<ListRetailUsersResponse>>;
|
|
32
|
+
|
|
33
|
+
/** `POST /private/retail/sales` — registra la venta; ante timeout o 502, reintenta con el mismo `saleId`. */
|
|
34
|
+
registerRetailSale(
|
|
35
|
+
request: RegisterRetailSaleRequest,
|
|
36
|
+
sale: RetailSystemSale,
|
|
37
|
+
): Promise<StandardResponse<RegisterRetailSaleResponse>>;
|
|
38
|
+
}
|
|
@@ -9,6 +9,14 @@ import {
|
|
|
9
9
|
PrivateSellerListResponse,
|
|
10
10
|
RetailUserStatusEnum,
|
|
11
11
|
} from "@fiado/type-kit/bin/retailOrg/index.js";
|
|
12
|
+
import type {
|
|
13
|
+
ApplyRetailEventRequest,
|
|
14
|
+
ApplyRetailEventResponse,
|
|
15
|
+
ApplyRetailUserEventRequest,
|
|
16
|
+
ApplyRetailUserEventResponse,
|
|
17
|
+
ApplyStoreEventRequest,
|
|
18
|
+
ApplyStoreEventResponse,
|
|
19
|
+
} from "@fiado/type-kit/bin/retailIntegration/index.js";
|
|
12
20
|
import {
|
|
13
21
|
IRetailOrgBusinessApi,
|
|
14
22
|
RetailerRosterStatusFilter,
|
|
@@ -141,4 +149,24 @@ export default class RetailOrgBusinessApi implements IRetailOrgBusinessApi {
|
|
|
141
149
|
if (status) query.set("status", status);
|
|
142
150
|
return await this.httpRequest.get(`${this.baseUrl}/private/sellers?${query.toString()}`);
|
|
143
151
|
}
|
|
152
|
+
|
|
153
|
+
async privateApplyStoreEvent(request: ApplyStoreEventRequest): Promise<StandardResponse<ApplyStoreEventResponse>> {
|
|
154
|
+
return await this.applyRetailEvent("/private/integration/store-events", request);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
async privateApplyRetailUserEvent(
|
|
158
|
+
request: ApplyRetailUserEventRequest,
|
|
159
|
+
): Promise<StandardResponse<ApplyRetailUserEventResponse>> {
|
|
160
|
+
return await this.applyRetailEvent("/private/integration/retail-user-events", request);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
// Reenvía un evento del retailer; quita la "/" final de la base porque el SSM la publica con ella.
|
|
164
|
+
private async applyRetailEvent(
|
|
165
|
+
path: string,
|
|
166
|
+
request: ApplyRetailEventRequest,
|
|
167
|
+
): Promise<StandardResponse<ApplyRetailEventResponse>> {
|
|
168
|
+
const base = this.baseUrl.replace(/\/+$/, "");
|
|
169
|
+
const url = `${base}${path}?tenantId=${encodeURIComponent(request.tenantId)}`;
|
|
170
|
+
return await this.httpRequest.post(url, request, {}, undefined, true);
|
|
171
|
+
}
|
|
144
172
|
}
|
|
@@ -9,6 +9,12 @@ import {
|
|
|
9
9
|
RetailerStatusEnum,
|
|
10
10
|
StoreStatusEnum,
|
|
11
11
|
} from "@fiado/type-kit/bin/retailOrg/index.js";
|
|
12
|
+
import type {
|
|
13
|
+
ApplyRetailUserEventRequest,
|
|
14
|
+
ApplyRetailUserEventResponse,
|
|
15
|
+
ApplyStoreEventRequest,
|
|
16
|
+
ApplyStoreEventResponse,
|
|
17
|
+
} from "@fiado/type-kit/bin/retailIntegration/index.js";
|
|
12
18
|
|
|
13
19
|
/**
|
|
14
20
|
* Filtro de `listStoresByRetailer`. `"ALL"` no es un estado de tienda: es la ausencia de filtro, y
|
|
@@ -270,4 +276,12 @@ export interface IRetailOrgBusinessApi {
|
|
|
270
276
|
callerService: string,
|
|
271
277
|
status?: RetailUserStatusEnum,
|
|
272
278
|
): Promise<StandardResponse<PrivateSellerListResponse>>;
|
|
279
|
+
|
|
280
|
+
/** `POST /private/integration/store-events?tenantId=` — aplica un evento de tienda del retailer. */
|
|
281
|
+
privateApplyStoreEvent(request: ApplyStoreEventRequest): Promise<StandardResponse<ApplyStoreEventResponse>>;
|
|
282
|
+
|
|
283
|
+
/** `POST /private/integration/retail-user-events?tenantId=` — aplica un evento de usuario del retailer. */
|
|
284
|
+
privateApplyRetailUserEvent(
|
|
285
|
+
request: ApplyRetailUserEventRequest,
|
|
286
|
+
): Promise<StandardResponse<ApplyRetailUserEventResponse>>;
|
|
273
287
|
}
|