@fiado/api-invoker 5.9.0 → 5.11.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.
@@ -1,10 +1,14 @@
1
1
  import { IAccountBeneficiaryApi } from "./interfaces/IAccountBeneficiaryApi.js";
2
2
  import { IHttpRequest } from "@fiado/http-client";
3
- import { AccountBeneficiaryCreateRequest } from "@fiado/type-kit/bin/beneficiary/index.js";
3
+ import { AccountBeneficiaryCreateRequest, AccountBeneficiaryResponse } from "@fiado/type-kit/bin/beneficiary/index.js";
4
4
  import { CountryId } from "@fiado/type-kit/bin/country/index.js";
5
+ type FiadoApiResponse<T> = import("@fiado/type-kit/bin/apiResponse/dtos/FiadoApiResponse.js").default<T>;
5
6
  export declare class AccountBeneficiaryApi implements IAccountBeneficiaryApi {
6
7
  private httpRequest;
7
8
  private readonly baseUrl;
8
9
  constructor(httpRequest: IHttpRequest);
9
10
  create(directoryId: string, countryId: CountryId, input: AccountBeneficiaryCreateRequest[]): Promise<void>;
11
+ getByDirectoryId(directoryId: string, countryId: CountryId): Promise<FiadoApiResponse<AccountBeneficiaryResponse[]>>;
12
+ update(directoryId: string, countryId: CountryId, input: AccountBeneficiaryCreateRequest[]): Promise<FiadoApiResponse<unknown>>;
10
13
  }
14
+ export {};
@@ -21,6 +21,14 @@ let AccountBeneficiaryApi = class AccountBeneficiaryApi {
21
21
  const url = `${this.baseUrl}${countryId}/users/${directoryId}`;
22
22
  return await this.httpRequest.post(url, input);
23
23
  }
24
+ async getByDirectoryId(directoryId, countryId) {
25
+ const url = `${this.baseUrl}${countryId}/users/${directoryId}`;
26
+ return await this.httpRequest.get(url);
27
+ }
28
+ async update(directoryId, countryId, input) {
29
+ const url = `${this.baseUrl}${countryId}/users/${directoryId}`;
30
+ return await this.httpRequest.put(url, input);
31
+ }
24
32
  };
25
33
  AccountBeneficiaryApi = __decorate([
26
34
  injectable(),
@@ -1,5 +1,20 @@
1
- import { AccountBeneficiaryCreateRequest } from "@fiado/type-kit/bin/beneficiary/index.js";
1
+ import { AccountBeneficiaryCreateRequest, AccountBeneficiaryResponse } from "@fiado/type-kit/bin/beneficiary/index.js";
2
2
  import { CountryId } from "@fiado/type-kit/bin/country/index.js";
3
+ type FiadoApiResponse<T> = import("@fiado/type-kit/bin/apiResponse/dtos/FiadoApiResponse.js").default<T>;
4
+ /**
5
+ * API PRIVADA de `beneficiary-business` (M2M, VPC-only). Las tres operaciones viven en la MISMA ruta
6
+ * (`/{countryId}/users/{directoryId}`) y se distinguen por método HTTP.
7
+ */
3
8
  export interface IAccountBeneficiaryApi {
4
9
  create(directoryId: string, countryId: CountryId, input: AccountBeneficiaryCreateRequest[]): Promise<void>;
10
+ /** Beneficiarios vigentes del directorio. Lista vacía si no tiene ninguno. */
11
+ getByDirectoryId(directoryId: string, countryId: CountryId): Promise<FiadoApiResponse<AccountBeneficiaryResponse[]>>;
12
+ /**
13
+ * Reemplaza el conjunto de beneficiarios del directorio.
14
+ *
15
+ * ⚠️ Es un REEMPLAZO, no un alta incremental: se manda SIEMPRE la lista completa que debe quedar.
16
+ * Mandar uno solo deja uno solo.
17
+ */
18
+ update(directoryId: string, countryId: CountryId, input: AccountBeneficiaryCreateRequest[]): Promise<FiadoApiResponse<unknown>>;
5
19
  }
20
+ export {};
@@ -1,5 +1,5 @@
1
1
  import type { IHttpRequest } from "@fiado/http-client";
2
- import type { IAuthBusinessApi } from "./interfaces/IAuthBusinessApi.js";
2
+ import type { IAuthBusinessApi, ResolveOnboardingProfileInput, ResolveOnboardingProfileResponse } from "./interfaces/IAuthBusinessApi.js";
3
3
  import type { SignUpProspectRequest, SignUpProspectResponse } from "@fiado/type-kit/bin/auth/index.js";
4
4
  type FiadoApiResponse<T> = import("@fiado/type-kit/bin/apiResponse/dtos/FiadoApiResponse.js").default<T>;
5
5
  export declare class AuthBusinessApi implements IAuthBusinessApi {
@@ -10,5 +10,6 @@ export declare class AuthBusinessApi implements IAuthBusinessApi {
10
10
  deletedCount: number;
11
11
  }>>;
12
12
  signUpProspect(request: SignUpProspectRequest): Promise<FiadoApiResponse<SignUpProspectResponse>>;
13
+ resolveOnboardingProfile(input: ResolveOnboardingProfileInput): Promise<FiadoApiResponse<ResolveOnboardingProfileResponse>>;
13
14
  }
14
15
  export {};
@@ -12,6 +12,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
12
12
  };
13
13
  import { inject, injectable } from "inversify";
14
14
  import dotenv from 'dotenv';
15
+ import { NotSupportedGeographyError } from "./interfaces/IAuthBusinessApi.js";
15
16
  dotenv.config();
16
17
  let AuthBusinessApi = class AuthBusinessApi {
17
18
  httpRequest;
@@ -33,6 +34,24 @@ let AuthBusinessApi = class AuthBusinessApi {
33
34
  const url = `${this.baseUrl}/private/signup-prospect`;
34
35
  return await this.httpRequest.post(url, request);
35
36
  }
37
+ async resolveOnboardingProfile(input) {
38
+ // Path exacto del openapi/private.yaml de auth-business (operationId: privateResolveOnboardingProfile).
39
+ const url = `${this.baseUrl}/private/onboarding-profile/resolve`;
40
+ try {
41
+ return await this.httpRequest.post(url, input);
42
+ }
43
+ catch (error) {
44
+ // @fiado/http-client es un wrapper fino de axios: ante 4xx/5xx el error trae
45
+ // `response.{status,data}`. Fila 8 de la matriz (400 NOT_SUPPORTED_GEOGRAPHY)
46
+ // se re-lanza TIPADA para que el consumidor la distinga por instanceof de un
47
+ // error de red/5xx (fail-closed, spec §9). Todo lo demás se propaga tal cual.
48
+ const response = error.response;
49
+ if (response?.status === 400 && response.data?.code === "NOT_SUPPORTED_GEOGRAPHY") {
50
+ throw new NotSupportedGeographyError();
51
+ }
52
+ throw error;
53
+ }
54
+ }
36
55
  };
37
56
  AuthBusinessApi = __decorate([
38
57
  injectable(),
@@ -1,5 +1,23 @@
1
1
  import type { SignUpProspectRequest, SignUpProspectResponse } from "@fiado/type-kit/bin/auth/index.js";
2
+ import type { Scope } from "@fiado/type-kit/bin/directory/enums/Scope.js";
2
3
  type FiadoApiResponse<T> = import("@fiado/type-kit/bin/apiResponse/dtos/FiadoApiResponse.js").default<T>;
4
+ export interface ResolveOnboardingProfileInput {
5
+ countryOfBirth: string;
6
+ countryOfDomicile: string;
7
+ USA_DebitAccountWish?: boolean;
8
+ MEX_DebitAccountWish?: boolean;
9
+ }
10
+ export interface ResolveOnboardingProfileResponse {
11
+ scope: Scope[];
12
+ userProfile: "HOST";
13
+ USA_DebitAccountWish: boolean;
14
+ MEX_DebitAccountWish: boolean;
15
+ SSN_ITINRequired: boolean | null;
16
+ }
17
+ export declare class NotSupportedGeographyError extends Error {
18
+ readonly code = "NOT_SUPPORTED_GEOGRAPHY";
19
+ constructor();
20
+ }
3
21
  /**
4
22
  * Interfaz para el servicio Auth Business (auth-business).
5
23
  */
@@ -26,5 +44,17 @@ export interface IAuthBusinessApi {
26
44
  * @throws propaga el error del destino; nunca devuelve fallback.
27
45
  */
28
46
  signUpProspect(request: SignUpProspectRequest): Promise<FiadoApiResponse<SignUpProspectResponse>>;
47
+ /**
48
+ * Fuente única de la decisión de onboarding por geografía (matriz nació × vive,
49
+ * spec 2026-07-27 §2/§2.1). El feature flag GEO_SCOPE_MATRIX_ENABLED vive en
50
+ * auth-business: con flag OFF devuelve la regla legacy de wish flags (paridad).
51
+ *
52
+ * ⚠️ PII: nunca loguees el payload (lleva países crudos) — logueá solo la salida
53
+ * (scope/SSN_ITINRequired) del lado del consumidor.
54
+ *
55
+ * @throws {NotSupportedGeographyError} fila 8 de la matriz (400 NOT_SUPPORTED_GEOGRAPHY del destino).
56
+ * @throws propaga cualquier otro error (red / 5xx / 400 INVALID_REQUEST) tal cual; nunca devuelve fallback.
57
+ */
58
+ resolveOnboardingProfile(input: ResolveOnboardingProfileInput): Promise<FiadoApiResponse<ResolveOnboardingProfileResponse>>;
29
59
  }
30
60
  export {};
@@ -1 +1,11 @@
1
- export {};
1
+ // Fila 8 de la matriz (nació fuera / vive MX, pospuesta a fase 2): el destino responde
2
+ // 400 con code NOT_SUPPORTED_GEOGRAPHY y el cliente lo re-lanza TIPADO para que el
3
+ // consumidor lo distinga por instanceof de un error de red/5xx (fail-closed, spec §9).
4
+ // El mensaje NO incluye países (regla cero-PII).
5
+ export class NotSupportedGeographyError extends Error {
6
+ code = "NOT_SUPPORTED_GEOGRAPHY";
7
+ constructor() {
8
+ super("Geografía de onboarding no soportada");
9
+ this.name = "NotSupportedGeographyError";
10
+ }
11
+ }
package/jest.config.cjs CHANGED
@@ -8,5 +8,7 @@ module.exports = {
8
8
  transform: {
9
9
  '^.+\\.[tj]sx?$': ['ts-jest', { useESM: true, isolatedModules: true, tsconfig: 'tsconfig.test.json' }],
10
10
  },
11
- transformIgnorePatterns: ['/node_modules/(?!(inversify|@inversifyjs)/)'],
11
+ // @fiado/gateway-adapter se publica como ESM puro ("type": "module") — hay que
12
+ // transformarlo para que jest (CJS runtime de los tests) pueda importarlo.
13
+ transformIgnorePatterns: ['/node_modules/(?!(inversify|@inversifyjs|@fiado/gateway-adapter)/)'],
12
14
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fiado/api-invoker",
3
- "version": "5.9.0",
3
+ "version": "5.11.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,9 +1,10 @@
1
1
  import { inject, injectable } from "inversify";
2
2
  import { IAccountBeneficiaryApi } from "./interfaces/IAccountBeneficiaryApi.js";
3
3
  import { IHttpRequest } from "@fiado/http-client";
4
- import { AccountBeneficiaryCreateRequest } from "@fiado/type-kit/bin/beneficiary/index.js";
4
+ import { AccountBeneficiaryCreateRequest, AccountBeneficiaryResponse } from "@fiado/type-kit/bin/beneficiary/index.js";
5
5
  import { CountryId } from "@fiado/type-kit/bin/country/index.js";
6
6
 
7
+ type FiadoApiResponse<T> = import("@fiado/type-kit/bin/apiResponse/dtos/FiadoApiResponse.js").default<T>;
7
8
 
8
9
  @injectable()
9
10
  export class AccountBeneficiaryApi implements IAccountBeneficiaryApi {
@@ -16,4 +17,14 @@ export class AccountBeneficiaryApi implements IAccountBeneficiaryApi {
16
17
  const url = `${this.baseUrl}${countryId}/users/${directoryId}`;
17
18
  return await this.httpRequest.post(url, input);
18
19
  }
19
- }
20
+
21
+ async getByDirectoryId(directoryId: string, countryId: CountryId): Promise<FiadoApiResponse<AccountBeneficiaryResponse[]>> {
22
+ const url = `${this.baseUrl}${countryId}/users/${directoryId}`;
23
+ return await this.httpRequest.get<FiadoApiResponse<AccountBeneficiaryResponse[]>>(url);
24
+ }
25
+
26
+ async update(directoryId: string, countryId: CountryId, input: AccountBeneficiaryCreateRequest[]): Promise<FiadoApiResponse<unknown>> {
27
+ const url = `${this.baseUrl}${countryId}/users/${directoryId}`;
28
+ return await this.httpRequest.put<FiadoApiResponse<unknown>>(url, input);
29
+ }
30
+ }
@@ -1,8 +1,25 @@
1
- import { AccountBeneficiaryCreateRequest } from "@fiado/type-kit/bin/beneficiary/index.js";
1
+ import { AccountBeneficiaryCreateRequest, AccountBeneficiaryResponse } from "@fiado/type-kit/bin/beneficiary/index.js";
2
2
  import { CountryId } from "@fiado/type-kit/bin/country/index.js";
3
3
 
4
+ type FiadoApiResponse<T> = import("@fiado/type-kit/bin/apiResponse/dtos/FiadoApiResponse.js").default<T>;
5
+
6
+ /**
7
+ * API PRIVADA de `beneficiary-business` (M2M, VPC-only). Las tres operaciones viven en la MISMA ruta
8
+ * (`/{countryId}/users/{directoryId}`) y se distinguen por método HTTP.
9
+ */
4
10
  export interface IAccountBeneficiaryApi {
5
11
 
6
12
  create(directoryId: string, countryId: CountryId, input: AccountBeneficiaryCreateRequest[]): Promise<void>;
7
13
 
8
- }
14
+ /** Beneficiarios vigentes del directorio. Lista vacía si no tiene ninguno. */
15
+ getByDirectoryId(directoryId: string, countryId: CountryId): Promise<FiadoApiResponse<AccountBeneficiaryResponse[]>>;
16
+
17
+ /**
18
+ * Reemplaza el conjunto de beneficiarios del directorio.
19
+ *
20
+ * ⚠️ Es un REEMPLAZO, no un alta incremental: se manda SIEMPRE la lista completa que debe quedar.
21
+ * Mandar uno solo deja uno solo.
22
+ */
23
+ update(directoryId: string, countryId: CountryId, input: AccountBeneficiaryCreateRequest[]): Promise<FiadoApiResponse<unknown>>;
24
+
25
+ }
@@ -1,7 +1,12 @@
1
1
  import { inject, injectable } from "inversify";
2
2
  import type { IHttpRequest } from "@fiado/http-client";
3
3
  import dotenv from 'dotenv';
4
- import type { IAuthBusinessApi } from "./interfaces/IAuthBusinessApi.js";
4
+ import type {
5
+ IAuthBusinessApi,
6
+ ResolveOnboardingProfileInput,
7
+ ResolveOnboardingProfileResponse,
8
+ } from "./interfaces/IAuthBusinessApi.js";
9
+ import { NotSupportedGeographyError } from "./interfaces/IAuthBusinessApi.js";
5
10
  import type { SignUpProspectRequest, SignUpProspectResponse } from "@fiado/type-kit/bin/auth/index.js";
6
11
  type FiadoApiResponse<T> = import("@fiado/type-kit/bin/apiResponse/dtos/FiadoApiResponse.js").default<T>;
7
12
 
@@ -29,4 +34,22 @@ export class AuthBusinessApi implements IAuthBusinessApi {
29
34
  const url = `${this.baseUrl}/private/signup-prospect`;
30
35
  return await this.httpRequest.post<FiadoApiResponse<SignUpProspectResponse>>(url, request);
31
36
  }
37
+
38
+ async resolveOnboardingProfile(input: ResolveOnboardingProfileInput): Promise<FiadoApiResponse<ResolveOnboardingProfileResponse>> {
39
+ // Path exacto del openapi/private.yaml de auth-business (operationId: privateResolveOnboardingProfile).
40
+ const url = `${this.baseUrl}/private/onboarding-profile/resolve`;
41
+ try {
42
+ return await this.httpRequest.post<FiadoApiResponse<ResolveOnboardingProfileResponse>>(url, input);
43
+ } catch (error) {
44
+ // @fiado/http-client es un wrapper fino de axios: ante 4xx/5xx el error trae
45
+ // `response.{status,data}`. Fila 8 de la matriz (400 NOT_SUPPORTED_GEOGRAPHY)
46
+ // se re-lanza TIPADA para que el consumidor la distinga por instanceof de un
47
+ // error de red/5xx (fail-closed, spec §9). Todo lo demás se propaga tal cual.
48
+ const response = (error as { response?: { status?: number; data?: { code?: string } } }).response;
49
+ if (response?.status === 400 && response.data?.code === "NOT_SUPPORTED_GEOGRAPHY") {
50
+ throw new NotSupportedGeographyError();
51
+ }
52
+ throw error;
53
+ }
54
+ }
32
55
  }
@@ -1,7 +1,44 @@
1
1
  import type { SignUpProspectRequest, SignUpProspectResponse } from "@fiado/type-kit/bin/auth/index.js";
2
+ import type { Scope } from "@fiado/type-kit/bin/directory/enums/Scope.js";
2
3
 
3
4
  type FiadoApiResponse<T> = import("@fiado/type-kit/bin/apiResponse/dtos/FiadoApiResponse.js").default<T>;
4
5
 
6
+ // Input de la matriz geográfica de onboarding (spec 2026-07-27 §2).
7
+ // Interfaz LOCAL transitoria: el DTO canónico con validators vive en auth-business y su
8
+ // TD-004 pendiente lo cataloga en @fiado/type-kit — cuando eso pase, este tipo se
9
+ // reemplaza por el del type-kit (como ya hace signUpProspect en este mismo archivo).
10
+ // Los wish flags viajan por compatibilidad de contrato: con GEO_SCOPE_MATRIX_ENABLED
11
+ // prendido en auth-business se ignoran; apagado, deciden la regla legacy (paridad).
12
+ export interface ResolveOnboardingProfileInput {
13
+ countryOfBirth: string;
14
+ countryOfDomicile: string;
15
+ USA_DebitAccountWish?: boolean;
16
+ MEX_DebitAccountWish?: boolean;
17
+ }
18
+
19
+ // Salida de la matriz (spec §2/§2.1): scope + userProfile + wish flags DERIVADOS
20
+ // (son los que el consumidor persiste, no los del request) + SSN_ITINRequired
21
+ // (null cuando el flag de la matriz está apagado en auth-business).
22
+ export interface ResolveOnboardingProfileResponse {
23
+ scope: Scope[];
24
+ userProfile: "HOST";
25
+ USA_DebitAccountWish: boolean;
26
+ MEX_DebitAccountWish: boolean;
27
+ SSN_ITINRequired: boolean | null;
28
+ }
29
+
30
+ // Fila 8 de la matriz (nació fuera / vive MX, pospuesta a fase 2): el destino responde
31
+ // 400 con code NOT_SUPPORTED_GEOGRAPHY y el cliente lo re-lanza TIPADO para que el
32
+ // consumidor lo distinga por instanceof de un error de red/5xx (fail-closed, spec §9).
33
+ // El mensaje NO incluye países (regla cero-PII).
34
+ export class NotSupportedGeographyError extends Error {
35
+ readonly code = "NOT_SUPPORTED_GEOGRAPHY";
36
+ constructor() {
37
+ super("Geografía de onboarding no soportada");
38
+ this.name = "NotSupportedGeographyError";
39
+ }
40
+ }
41
+
5
42
  /**
6
43
  * Interfaz para el servicio Auth Business (auth-business).
7
44
  */
@@ -29,4 +66,17 @@ export interface IAuthBusinessApi {
29
66
  * @throws propaga el error del destino; nunca devuelve fallback.
30
67
  */
31
68
  signUpProspect(request: SignUpProspectRequest): Promise<FiadoApiResponse<SignUpProspectResponse>>;
69
+
70
+ /**
71
+ * Fuente única de la decisión de onboarding por geografía (matriz nació × vive,
72
+ * spec 2026-07-27 §2/§2.1). El feature flag GEO_SCOPE_MATRIX_ENABLED vive en
73
+ * auth-business: con flag OFF devuelve la regla legacy de wish flags (paridad).
74
+ *
75
+ * ⚠️ PII: nunca loguees el payload (lleva países crudos) — logueá solo la salida
76
+ * (scope/SSN_ITINRequired) del lado del consumidor.
77
+ *
78
+ * @throws {NotSupportedGeographyError} fila 8 de la matriz (400 NOT_SUPPORTED_GEOGRAPHY del destino).
79
+ * @throws propaga cualquier otro error (red / 5xx / 400 INVALID_REQUEST) tal cual; nunca devuelve fallback.
80
+ */
81
+ resolveOnboardingProfile(input: ResolveOnboardingProfileInput): Promise<FiadoApiResponse<ResolveOnboardingProfileResponse>>;
32
82
  }