@cobre-npm/library-response-catalog-node 0.2.0 → 0.3.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/README.md +14 -14
- package/dist/adapter/http/axios-client.d.ts +20 -0
- package/dist/adapter/http/axios-client.d.ts.map +1 -0
- package/dist/adapter/http/base-url.d.ts +13 -0
- package/dist/adapter/http/base-url.d.ts.map +1 -0
- package/dist/adapter/http/catalog-auth-headers-source.d.ts +5 -0
- package/dist/adapter/http/catalog-auth-headers-source.d.ts.map +1 -0
- package/dist/adapter/http/catalog-unavailable-error.d.ts +7 -0
- package/dist/adapter/http/catalog-unavailable-error.d.ts.map +1 -0
- package/dist/adapter/http/catalog-unavailable-reason.d.ts +8 -0
- package/dist/adapter/http/catalog-unavailable-reason.d.ts.map +1 -0
- package/dist/adapter/http/connection-mode.d.ts +6 -0
- package/dist/adapter/http/connection-mode.d.ts.map +1 -0
- package/dist/adapter/http/error-chain.d.ts +19 -0
- package/dist/adapter/http/error-chain.d.ts.map +1 -0
- package/dist/adapter/http/fallback-key.d.ts +2 -0
- package/dist/adapter/http/fallback-key.d.ts.map +1 -0
- package/dist/adapter/http/fallback-match.d.ts +6 -0
- package/dist/adapter/http/fallback-match.d.ts.map +1 -0
- package/dist/adapter/http/fallback-token-map-loader.d.ts +5 -0
- package/dist/adapter/http/fallback-token-map-loader.d.ts.map +1 -0
- package/dist/adapter/http/fallback-token-map.d.ts +12 -0
- package/dist/adapter/http/fallback-token-map.d.ts.map +1 -0
- package/dist/adapter/http/fallback-token-resolver.d.ts +16 -0
- package/dist/adapter/http/fallback-token-resolver.d.ts.map +1 -0
- package/dist/adapter/http/internal-gateway-auth-headers-source.d.ts +31 -0
- package/dist/adapter/http/internal-gateway-auth-headers-source.d.ts.map +1 -0
- package/dist/adapter/http/locale-utils.d.ts +14 -0
- package/dist/adapter/http/locale-utils.d.ts.map +1 -0
- package/dist/adapter/http/no-auth-headers-source.d.ts +3 -0
- package/dist/adapter/http/no-auth-headers-source.d.ts.map +1 -0
- package/dist/adapter/http/resilience.d.ts +21 -0
- package/dist/adapter/http/resilience.d.ts.map +1 -0
- package/dist/adapter/http/resolved-fallback.d.ts +11 -0
- package/dist/adapter/http/resolved-fallback.d.ts.map +1 -0
- package/dist/domain/core/models/{catalog-client-exception.d.ts → catalog-client-error.d.ts} +3 -3
- package/dist/domain/core/models/catalog-client-error.d.ts.map +1 -0
- package/dist/domain/core/models/response.d.ts +22 -0
- package/dist/domain/core/models/response.d.ts.map +1 -1
- package/dist/domain/core/models/supplier-error-context.d.ts +12 -0
- package/dist/domain/core/models/supplier-error-context.d.ts.map +1 -1
- package/dist/domain/ports/out/catalog-port.d.ts +36 -0
- package/dist/domain/ports/out/catalog-port.d.ts.map +1 -0
- package/dist/index.d.ts +16 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +18 -7
- package/dist/index.js.map +1 -1
- package/dist/shared/text.d.ts +34 -0
- package/dist/shared/text.d.ts.map +1 -0
- package/package.json +4 -5
- package/dist/domain/core/models/catalog-client-exception.d.ts.map +0 -1
- package/dist/domain/ports/out/catalog.port.d.ts +0 -16
- package/dist/domain/ports/out/catalog.port.d.ts.map +0 -1
package/README.md
CHANGED
|
@@ -4,14 +4,14 @@ Node.js SDK that will resolve a supplier-reported error against Cobre's Response
|
|
|
4
4
|
Read API (`GET /v1/resolve`). Callers send a supplier, domain, and error code; the catalog
|
|
5
5
|
returns a localized frontend message plus internal metadata.
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
`SupplierErrorContext` builder, the `CatalogPort` outbound port,
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
7
|
+
As of `0.3.0` this package has the **domain contract** — the `Response` shape, the
|
|
8
|
+
`SupplierErrorContext` builder, the `CatalogPort` outbound port, `CatalogClientError` —
|
|
9
|
+
plus the **local fallback token map** that resolves a technical error to a locally
|
|
10
|
+
known token instead of failing outright, unlike
|
|
11
|
+
[`library-response-catalog-java`](https://github.com/Cobre-Colombia/library-response-catalog-java).
|
|
12
|
+
There is still no HTTP implementation — that lands in a later stacked PR on
|
|
13
|
+
`Feature/BLCK-28319-*`, which will wire the fallback map to `CatalogPort` and add
|
|
14
|
+
retries and a circuit breaker.
|
|
15
15
|
|
|
16
16
|
## Install
|
|
17
17
|
|
|
@@ -23,23 +23,23 @@ Requires [pnpm](https://pnpm.io) `10.27.0` (see `packageManager` in `package.jso
|
|
|
23
23
|
Same-cluster calls will need nothing else. Cross-cluster (`INTERNAL_GATEWAY`) will also
|
|
24
24
|
need `@cobre-npm/library-nodejs-common`.
|
|
25
25
|
|
|
26
|
-
## Public API (0.
|
|
26
|
+
## Public API (0.3.0)
|
|
27
27
|
|
|
28
28
|
| Export | Role |
|
|
29
29
|
|---|---|
|
|
30
|
-
| `LIBRARY_VERSION` | Package version string (`0.
|
|
30
|
+
| `LIBRARY_VERSION` | Package version string (`0.3.0`). Matches `package.json`. |
|
|
31
31
|
| `buildSupplierErrorContext` | Validates and builds a `SupplierErrorContext` (`supplier`/`domain`/`code` required, `locale` optional). |
|
|
32
32
|
| `SupplierErrorContext`, `SupplierErrorContextInput` | Validated context type and its raw input. |
|
|
33
33
|
| `CatalogPort` | Outbound port: `fetchResponse(context): Promise<Response>`. |
|
|
34
34
|
| `Response`, `SupplierInfo`, `InternalInfo`, `ApiInfo` | Resolved catalog entry: supplier/internal/api views plus the localized message. |
|
|
35
|
-
| `
|
|
35
|
+
| `CatalogClientError` | Thrown by a `CatalogPort` implementation. `isTransient()` / `isCredentialError()` classify the failure. |
|
|
36
36
|
|
|
37
37
|
## Usage
|
|
38
38
|
|
|
39
39
|
```typescript
|
|
40
40
|
import {
|
|
41
41
|
buildSupplierErrorContext,
|
|
42
|
-
|
|
42
|
+
CatalogClientError,
|
|
43
43
|
CatalogPort,
|
|
44
44
|
} from '@cobre-npm/library-response-catalog-node'
|
|
45
45
|
|
|
@@ -54,8 +54,8 @@ try {
|
|
|
54
54
|
const response = await catalogPort.fetchResponse(context)
|
|
55
55
|
console.log(response.resolvedMessage)
|
|
56
56
|
} catch (error) {
|
|
57
|
-
if (error instanceof
|
|
58
|
-
// safe to retry, or fall back
|
|
57
|
+
if (error instanceof CatalogClientError && error.isTransient()) {
|
|
58
|
+
// safe to retry, or fall back to a local token once the HTTP layer ships
|
|
59
59
|
}
|
|
60
60
|
throw error
|
|
61
61
|
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type AxiosInstance } from 'axios';
|
|
2
|
+
export declare const DEFAULT_CONNECT_TIMEOUT_MS = 2000;
|
|
3
|
+
export declare const DEFAULT_READ_TIMEOUT_MS = 5000;
|
|
4
|
+
/**
|
|
5
|
+
* Builds the axios instance used for every resolve call.
|
|
6
|
+
*
|
|
7
|
+
* `validateStatus` accepts every status so the adapter, not axios, decides what
|
|
8
|
+
* an error status means. Keep-alive agents let retries and repeated calls reuse
|
|
9
|
+
* connections instead of paying a fresh handshake each time.
|
|
10
|
+
*
|
|
11
|
+
* @param options.connectTimeoutMs - Socket inactivity timeout applied to the agents
|
|
12
|
+
* @param options.readTimeoutMs - Overall request timeout
|
|
13
|
+
* @returns A configured axios instance
|
|
14
|
+
*/
|
|
15
|
+
export interface AxiosClientOptions {
|
|
16
|
+
readonly connectTimeoutMs: number;
|
|
17
|
+
readonly readTimeoutMs: number;
|
|
18
|
+
}
|
|
19
|
+
export declare const createAxiosClient: ({ connectTimeoutMs, readTimeoutMs }: AxiosClientOptions) => AxiosInstance;
|
|
20
|
+
//# sourceMappingURL=axios-client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"axios-client.d.ts","sourceRoot":"","sources":["../../../src/adapter/http/axios-client.ts"],"names":[],"mappings":"AAAA,OAAc,EAAE,KAAK,aAAa,EAAE,MAAM,OAAO,CAAA;AAIjD,eAAO,MAAM,0BAA0B,OAAQ,CAAA;AAC/C,eAAO,MAAM,uBAAuB,OAAQ,CAAA;AAE5C;;;;;;;;;;GAUG;AACH,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAA;IACjC,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAA;CAC/B;AAED,eAAO,MAAM,iBAAiB,GAC5B,qCAAqC,kBAAkB,KACtD,aASC,CAAA"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rejects a `baseUrl` that is not an absolute HTTP(S) URL, so a typo or a
|
|
3
|
+
* missing scheme fails when the client is created rather than surfacing later
|
|
4
|
+
* disguised as a network failure.
|
|
5
|
+
*
|
|
6
|
+
* Stricter than the Java library, which accepts any absolute URI: only `http:`
|
|
7
|
+
* and `https:` can reach the catalog over this adapter.
|
|
8
|
+
*
|
|
9
|
+
* @param baseUrl - The configured base URL
|
|
10
|
+
* @throws Error when the value is unparseable or uses another scheme
|
|
11
|
+
*/
|
|
12
|
+
export declare const requireAbsoluteBaseUrl: (baseUrl: string) => void;
|
|
13
|
+
//# sourceMappingURL=base-url.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base-url.d.ts","sourceRoot":"","sources":["../../../src/adapter/http/base-url.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,eAAO,MAAM,sBAAsB,GAAI,SAAS,MAAM,KAAG,IAexD,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"catalog-auth-headers-source.d.ts","sourceRoot":"","sources":["../../../src/adapter/http/catalog-auth-headers-source.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,wBAAwB;IACvC,OAAO,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAA;IAC1C,OAAO,CAAC,cAAc,EAAE,MAAM,GAAG,IAAI,CAAA;CACtC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { CatalogClientError } from '../../domain/core/models/catalog-client-error';
|
|
2
|
+
import type { CatalogUnavailableReason } from './catalog-unavailable-reason';
|
|
3
|
+
export declare class CatalogUnavailableError extends CatalogClientError {
|
|
4
|
+
readonly reason: CatalogUnavailableReason;
|
|
5
|
+
constructor(message: string, reason: CatalogUnavailableReason, httpStatusCodeOrCause?: number | Error);
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=catalog-unavailable-error.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"catalog-unavailable-error.d.ts","sourceRoot":"","sources":["../../../src/adapter/http/catalog-unavailable-error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,+CAA+C,CAAA;AAClF,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,8BAA8B,CAAA;AAE5E,qBAAa,uBAAwB,SAAQ,kBAAkB;IAC7D,QAAQ,CAAC,MAAM,EAAE,wBAAwB,CAAA;gBAGvC,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,wBAAwB,EAChC,qBAAqB,CAAC,EAAE,MAAM,GAAG,KAAK;CAMzC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare const CATALOG_UNAVAILABLE_REASONS: {
|
|
2
|
+
readonly NETWORK: "network";
|
|
3
|
+
readonly SERVER_ERROR: "server_error";
|
|
4
|
+
readonly CIRCUIT_OPEN: "circuit_open";
|
|
5
|
+
readonly INVALID_RESPONSE: "invalid_response";
|
|
6
|
+
};
|
|
7
|
+
export type CatalogUnavailableReason = typeof CATALOG_UNAVAILABLE_REASONS[keyof typeof CATALOG_UNAVAILABLE_REASONS];
|
|
8
|
+
//# sourceMappingURL=catalog-unavailable-reason.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"catalog-unavailable-reason.d.ts","sourceRoot":"","sources":["../../../src/adapter/http/catalog-unavailable-reason.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,2BAA2B;;;;;CAK9B,CAAA;AAEV,MAAM,MAAM,wBAAwB,GAClC,OAAO,2BAA2B,CAAC,MAAM,OAAO,2BAA2B,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connection-mode.d.ts","sourceRoot":"","sources":["../../../src/adapter/http/connection-mode.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,gBAAgB;;;CAGnB,CAAA;AAEV,MAAM,MAAM,cAAc,GAAG,OAAO,gBAAgB,CAAC,MAAM,OAAO,gBAAgB,CAAC,CAAA"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Walks an error and its `cause` chain looking for the first value the
|
|
3
|
+
* predicate accepts. Resilience policies wrap the original failure, so the
|
|
4
|
+
* catalog exception is usually nested rather than thrown directly.
|
|
5
|
+
*
|
|
6
|
+
* @param error - The error to inspect, along with its causes
|
|
7
|
+
* @param predicate - Type guard identifying the error being looked for
|
|
8
|
+
* @returns The first matching error, or `undefined` when none matches
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```typescript
|
|
12
|
+
* const catalogError = findErrorInChain(
|
|
13
|
+
* wrapped,
|
|
14
|
+
* (candidate): candidate is CatalogClientError => candidate instanceof CatalogClientError,
|
|
15
|
+
* )
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export declare const findErrorInChain: <T>(error: unknown, predicate: (candidate: unknown) => candidate is T) => T | undefined;
|
|
19
|
+
//# sourceMappingURL=error-chain.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error-chain.d.ts","sourceRoot":"","sources":["../../../src/adapter/http/error-chain.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,gBAAgB,GAAI,CAAC,EAChC,OAAO,OAAO,EACd,WAAW,CAAC,SAAS,EAAE,OAAO,KAAK,SAAS,IAAI,CAAC,KAChD,CAAC,GAAG,SAoBN,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fallback-key.d.ts","sourceRoot":"","sources":["../../../src/adapter/http/fallback-key.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,aAAa,GAAI,MAAM,MAAM,EAAE,QAAQ,MAAM,KAAG,MAA8B,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fallback-match.d.ts","sourceRoot":"","sources":["../../../src/adapter/http/fallback-match.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,gBAAgB;;;CAGnB,CAAA;AAEV,MAAM,MAAM,aAAa,GAAG,OAAO,gBAAgB,CAAC,MAAM,OAAO,gBAAgB,CAAC,CAAA"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { FallbackTokenMap } from './fallback-token-map';
|
|
2
|
+
export declare const DEFAULT_FALLBACK_TOKENS_LOCATION = "bundle:response-catalog-fallbacks.json";
|
|
3
|
+
export declare const loadFallbackTokenMap: (location: string) => FallbackTokenMap;
|
|
4
|
+
export declare const loadFallbackTokenMapFromFilePath: (filePath: string) => FallbackTokenMap;
|
|
5
|
+
//# sourceMappingURL=fallback-token-map-loader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fallback-token-map-loader.d.ts","sourceRoot":"","sources":["../../../src/adapter/http/fallback-token-map-loader.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AAU5D,eAAO,MAAM,gCAAgC,2CAA6C,CAAA;AAqI1F,eAAO,MAAM,oBAAoB,GAAI,UAAU,MAAM,KAAG,gBAUvD,CAAA;AAED,eAAO,MAAM,gCAAgC,GAAI,UAAU,MAAM,KAAG,gBAInE,CAAA"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Validated fallback token map, built once when the client is created. Keys are
|
|
3
|
+
* `code::locale` pairs produced by {@link toFallbackKey}; the on-disk JSON
|
|
4
|
+
* schema it is parsed from is documented in `docs/fallback.md` and enforced by
|
|
5
|
+
* `fallback-token-map-loader.ts`.
|
|
6
|
+
*/
|
|
7
|
+
export type FallbackTokenMap = {
|
|
8
|
+
readonly defaultLocale: string;
|
|
9
|
+
readonly defaultToken: string;
|
|
10
|
+
readonly tokens: ReadonlyMap<string, string>;
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=fallback-token-map.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fallback-token-map.d.ts","sourceRoot":"","sources":["../../../src/adapter/http/fallback-token-map.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC7B,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAA;IAC9B,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAA;IAC7B,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAC7C,CAAA"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { SupplierErrorContext } from '../../domain/core/models/supplier-error-context';
|
|
2
|
+
import type { FallbackTokenMap } from './fallback-token-map';
|
|
3
|
+
import type { ResolvedFallback } from './resolved-fallback';
|
|
4
|
+
/** Resolves a supplier error to a local token. See `docs/fallback.md`. */
|
|
5
|
+
export interface FallbackTokenResolver {
|
|
6
|
+
resolve(context: SupplierErrorContext): ResolvedFallback;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Binds a validated token map to a resolver. The map is loaded once when the
|
|
10
|
+
* client is created, so resolution is a pure in-memory lookup.
|
|
11
|
+
*
|
|
12
|
+
* @param tokenMap - The validated map to look up in
|
|
13
|
+
* @returns A resolver over that map
|
|
14
|
+
*/
|
|
15
|
+
export declare const createFallbackTokenResolver: (tokenMap: FallbackTokenMap) => FallbackTokenResolver;
|
|
16
|
+
//# sourceMappingURL=fallback-token-resolver.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fallback-token-resolver.d.ts","sourceRoot":"","sources":["../../../src/adapter/http/fallback-token-resolver.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,iDAAiD,CAAA;AAG3F,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AAE5D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAA;AAG3D,0EAA0E;AAC1E,MAAM,WAAW,qBAAqB;IACpC,OAAO,CAAC,OAAO,EAAE,oBAAoB,GAAG,gBAAgB,CAAA;CACzD;AAkBD;;;;;;GAMG;AACH,eAAO,MAAM,2BAA2B,GACtC,UAAU,gBAAgB,KACzB,qBASD,CAAA"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { CatalogAuthHeadersSource } from './catalog-auth-headers-source';
|
|
2
|
+
export interface InternalGatewayHeadersFetcher {
|
|
3
|
+
(params: {
|
|
4
|
+
secretAdapterRegion: string;
|
|
5
|
+
apigwSecretName: string;
|
|
6
|
+
authManagerBaseURL: string;
|
|
7
|
+
}): Promise<Record<string, string>>;
|
|
8
|
+
}
|
|
9
|
+
export interface InternalGatewayAuthHeadersSourceOptions {
|
|
10
|
+
readonly secretName: string;
|
|
11
|
+
readonly authManagerBaseURL: string;
|
|
12
|
+
readonly secretAdapterRegion: string;
|
|
13
|
+
readonly fetchHeaders: InternalGatewayHeadersFetcher;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Auth source for INTERNAL_GATEWAY. Caches headers from library-nodejs-common and
|
|
17
|
+
* invalidates the cache when `confirm` reports a credential rejection so the next
|
|
18
|
+
* retry (after confirm) fetches fresh credentials — same semantic as Java's
|
|
19
|
+
* APIGWKeysUseCase.confirmStatusCode.
|
|
20
|
+
*/
|
|
21
|
+
export declare class InternalGatewayAuthHeadersSource implements CatalogAuthHeadersSource {
|
|
22
|
+
private readonly options;
|
|
23
|
+
private cachedHeaders;
|
|
24
|
+
private inFlight;
|
|
25
|
+
private invalidateOnNextHeaders;
|
|
26
|
+
constructor(options: InternalGatewayAuthHeadersSourceOptions);
|
|
27
|
+
headers(): Promise<Record<string, string>>;
|
|
28
|
+
private fetchAndCache;
|
|
29
|
+
confirm(httpStatusCode: number): void;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=internal-gateway-auth-headers-source.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"internal-gateway-auth-headers-source.d.ts","sourceRoot":"","sources":["../../../src/adapter/http/internal-gateway-auth-headers-source.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAA;AAI7E,MAAM,WAAW,6BAA6B;IAC5C,CAAC,MAAM,EAAE;QACP,mBAAmB,EAAE,MAAM,CAAA;QAC3B,eAAe,EAAE,MAAM,CAAA;QACvB,kBAAkB,EAAE,MAAM,CAAA;KAC3B,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAA;CACpC;AAED,MAAM,WAAW,uCAAuC;IACtD,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;IAC3B,QAAQ,CAAC,kBAAkB,EAAE,MAAM,CAAA;IACnC,QAAQ,CAAC,mBAAmB,EAAE,MAAM,CAAA;IACpC,QAAQ,CAAC,YAAY,EAAE,6BAA6B,CAAA;CACrD;AAED;;;;;GAKG;AACH,qBAAa,gCAAiC,YAAW,wBAAwB;IAKnE,OAAO,CAAC,QAAQ,CAAC,OAAO;IAJpC,OAAO,CAAC,aAAa,CAAsC;IAC3D,OAAO,CAAC,QAAQ,CAA+C;IAC/D,OAAO,CAAC,uBAAuB,CAAQ;gBAEV,OAAO,EAAE,uCAAuC;IAEvE,OAAO,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;YAkBlC,aAAa;IAmB3B,OAAO,CAAC,cAAc,EAAE,MAAM,GAAG,IAAI;CAKtC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Canonicalizes a locale tag, accepting both underscore and hyphen separators.
|
|
3
|
+
*
|
|
4
|
+
* @param locale - Locale tag such as `es_CO` or `es-co`
|
|
5
|
+
* @returns The canonical BCP 47 tag (`es-CO`)
|
|
6
|
+
* @throws Error when the tag is not a structurally valid locale
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* normalizeLocale('es_CO') // 'es-CO'
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
13
|
+
export declare const normalizeLocale: (locale: string) => string;
|
|
14
|
+
//# sourceMappingURL=locale-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"locale-utils.d.ts","sourceRoot":"","sources":["../../../src/adapter/http/locale-utils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,eAAe,GAAI,QAAQ,MAAM,KAAG,MAUhD,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"no-auth-headers-source.d.ts","sourceRoot":"","sources":["../../../src/adapter/http/no-auth-headers-source.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAA;AAW7E,eAAO,MAAM,mBAAmB,QAAO,wBAAkD,CAAA"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { BrokenCircuitError, type IPolicy } from 'cockatiel';
|
|
2
|
+
export declare const DEFAULT_MAX_ATTEMPTS = 3;
|
|
3
|
+
export declare const DEFAULT_CIRCUIT_BREAKER_WAIT_DURATION_MS = 30000;
|
|
4
|
+
export type ResiliencePolicies = {
|
|
5
|
+
readonly policy: IPolicy;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* Builds the retry and circuit breaker guarding calls to the catalog. Retry
|
|
9
|
+
* wraps the breaker, so retries stop once the breaker opens.
|
|
10
|
+
*
|
|
11
|
+
* @param options.maxAttempts - Total attempts including the first
|
|
12
|
+
* @param options.circuitBreakerOpenDurationMs - How long the breaker stays open before a trial call
|
|
13
|
+
* @returns The composed policy the adapter executes calls through
|
|
14
|
+
*/
|
|
15
|
+
export interface ResilienceOptions {
|
|
16
|
+
readonly maxAttempts?: number;
|
|
17
|
+
readonly circuitBreakerOpenDurationMs?: number;
|
|
18
|
+
}
|
|
19
|
+
export declare const createResiliencePolicies: ({ maxAttempts, circuitBreakerOpenDurationMs, }?: ResilienceOptions) => ResiliencePolicies;
|
|
20
|
+
export declare const isBrokenCircuitError: (error: unknown) => error is BrokenCircuitError;
|
|
21
|
+
//# sourceMappingURL=resilience.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resilience.d.ts","sourceRoot":"","sources":["../../../src/adapter/http/resilience.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAOlB,KAAK,OAAO,EACb,MAAM,WAAW,CAAA;AAKlB,eAAO,MAAM,oBAAoB,IAAI,CAAA;AACrC,eAAO,MAAM,wCAAwC,QAAS,CAAA;AAgD9D,MAAM,MAAM,kBAAkB,GAAG;IAC/B,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAA;CACzB,CAAA;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAA;IAC7B,QAAQ,CAAC,4BAA4B,CAAC,EAAE,MAAM,CAAA;CAC/C;AAED,eAAO,MAAM,wBAAwB,GAAI,iDAGtC,iBAAsB,KAAG,kBA4B3B,CAAA;AAED,eAAO,MAAM,oBAAoB,GAAI,OAAO,OAAO,KAAG,KAAK,IAAI,kBAC1B,CAAA"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { FallbackMatch } from './fallback-match';
|
|
2
|
+
/** Outcome of resolving a supplier error against the local token map. */
|
|
3
|
+
export type ResolvedFallback = {
|
|
4
|
+
/** The frontend token exposed as `resolvedMessage`. */
|
|
5
|
+
readonly token: string;
|
|
6
|
+
/** The locale the lookup ran under, which may be the map's default. */
|
|
7
|
+
readonly resolvedLocale: string;
|
|
8
|
+
/** Whether the token came from an exact entry or the file default. */
|
|
9
|
+
readonly match: FallbackMatch;
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=resolved-fallback.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolved-fallback.d.ts","sourceRoot":"","sources":["../../../src/adapter/http/resolved-fallback.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AAErD,yEAAyE;AACzE,MAAM,MAAM,gBAAgB,GAAG;IAC7B,uDAAuD;IACvD,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,uEAAuE;IACvE,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAA;IAC/B,sEAAsE;IACtE,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAA;CAC9B,CAAA"}
|
|
@@ -8,13 +8,13 @@
|
|
|
8
8
|
* try {
|
|
9
9
|
* await catalogPort.fetchResponse(context)
|
|
10
10
|
* } catch (error) {
|
|
11
|
-
* if (error instanceof
|
|
11
|
+
* if (error instanceof CatalogClientError && error.isTransient()) {
|
|
12
12
|
* // safe to retry or fall back locally
|
|
13
13
|
* }
|
|
14
14
|
* }
|
|
15
15
|
* ```
|
|
16
16
|
*/
|
|
17
|
-
export declare class
|
|
17
|
+
export declare class CatalogClientError extends Error {
|
|
18
18
|
/**
|
|
19
19
|
* HTTP status code returned by the catalog, or `null` when the failure
|
|
20
20
|
* was a network-level error (no HTTP response was received).
|
|
@@ -39,4 +39,4 @@ export declare class CatalogClientException extends Error {
|
|
|
39
39
|
*/
|
|
40
40
|
isCredentialError(): boolean;
|
|
41
41
|
}
|
|
42
|
-
//# sourceMappingURL=catalog-client-
|
|
42
|
+
//# sourceMappingURL=catalog-client-error.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"catalog-client-error.d.ts","sourceRoot":"","sources":["../../../../src/domain/core/models/catalog-client-error.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;GAeG;AACH,qBAAa,kBAAmB,SAAQ,KAAK;IAC3C;;;OAGG;IACH,QAAQ,CAAC,cAAc,EAAE,MAAM,GAAG,IAAI,CAAA;IAEtC;;;;;OAKG;gBACS,OAAO,EAAE,MAAM,EAAE,qBAAqB,CAAC,EAAE,MAAM,GAAG,KAAK;IAYnE;;;;OAIG;IACH,WAAW,IAAI,OAAO;IAItB;;;OAGG;IACH,iBAAiB,IAAI,OAAO;CAG7B"}
|
|
@@ -5,11 +5,17 @@
|
|
|
5
5
|
* @see {@link Response}
|
|
6
6
|
*/
|
|
7
7
|
export interface SupplierInfo {
|
|
8
|
+
/** The supplier identifier, e.g. `"nequi"`. */
|
|
8
9
|
readonly supplierId: string;
|
|
10
|
+
/** The business domain the supplier belongs to, e.g. `"wallets"`. */
|
|
9
11
|
readonly domain: string;
|
|
12
|
+
/** The supplier's raw response status code. */
|
|
10
13
|
readonly supplierResponseStatusCode: string;
|
|
14
|
+
/** The supplier's raw response status description. */
|
|
11
15
|
readonly supplierResponseStatusDescription?: string;
|
|
16
|
+
/** The catalog entry lifecycle status, e.g. `"ACTIVE"`. */
|
|
12
17
|
readonly status?: string;
|
|
18
|
+
/** The Cobre internal status code this supplier code maps to. */
|
|
13
19
|
readonly internalStatusCode?: string;
|
|
14
20
|
}
|
|
15
21
|
/**
|
|
@@ -19,10 +25,13 @@ export interface SupplierInfo {
|
|
|
19
25
|
* @see {@link Response}
|
|
20
26
|
*/
|
|
21
27
|
export interface InternalInfo {
|
|
28
|
+
/** The Cobre internal status code, e.g. `"cobre.rail.nequi.not_registered"`. */
|
|
22
29
|
readonly internalStatusCode: string;
|
|
30
|
+
/** The human-readable description of the internal status. */
|
|
23
31
|
readonly internalStatusDescription?: string;
|
|
24
32
|
/** Whether Cobre-internal tooling should retry the originating operation. */
|
|
25
33
|
readonly retryable: boolean;
|
|
34
|
+
/** The catalog entry lifecycle status, e.g. `"ACTIVE"`. */
|
|
26
35
|
readonly status?: string;
|
|
27
36
|
}
|
|
28
37
|
/**
|
|
@@ -32,8 +41,11 @@ export interface InternalInfo {
|
|
|
32
41
|
* @see {@link Response}
|
|
33
42
|
*/
|
|
34
43
|
export interface ApiInfo {
|
|
44
|
+
/** The public Cobre API error code, e.g. `"RE0042"`. */
|
|
35
45
|
readonly code: string;
|
|
46
|
+
/** The public, locale-resolved error message. */
|
|
36
47
|
readonly message: string;
|
|
48
|
+
/** The HTTP status code Cobre APIs should return for this response. */
|
|
37
49
|
readonly httpResponseCode: number;
|
|
38
50
|
/** Error category (for example `validation`, `technical`). */
|
|
39
51
|
readonly type?: string;
|
|
@@ -43,7 +55,9 @@ export interface ApiInfo {
|
|
|
43
55
|
readonly retryable: boolean;
|
|
44
56
|
/** Link to public documentation describing this error code. */
|
|
45
57
|
readonly docUrl?: string;
|
|
58
|
+
/** The catalog entry lifecycle status, e.g. `"ACTIVE"`. */
|
|
46
59
|
readonly status?: string;
|
|
60
|
+
/** The Cobre internal status code this API entry maps to. */
|
|
47
61
|
readonly internalStatusCode?: string;
|
|
48
62
|
}
|
|
49
63
|
/**
|
|
@@ -56,10 +70,18 @@ export interface ApiInfo {
|
|
|
56
70
|
* public API mapping yet).
|
|
57
71
|
*/
|
|
58
72
|
export interface Response {
|
|
73
|
+
/** The raw supplier-side view of the response. */
|
|
59
74
|
readonly supplier: SupplierInfo | null;
|
|
75
|
+
/** The Cobre-internal, rail-agnostic view of the response. */
|
|
60
76
|
readonly internal: InternalInfo | null;
|
|
77
|
+
/** The public API-facing view of the response. */
|
|
61
78
|
readonly api: ApiInfo | null;
|
|
79
|
+
/**
|
|
80
|
+
* The locale the message was actually resolved in, which may differ from
|
|
81
|
+
* the requested locale when `fallbackApplied` is `true`.
|
|
82
|
+
*/
|
|
62
83
|
readonly resolvedLocale: string;
|
|
84
|
+
/** The human-readable message resolved for `resolvedLocale`. */
|
|
63
85
|
readonly resolvedMessage: string;
|
|
64
86
|
/** `true` when this response was produced by the local fallback resolver instead of the remote catalog. */
|
|
65
87
|
readonly fallbackApplied: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"response.d.ts","sourceRoot":"","sources":["../../../../src/domain/core/models/response.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;IAC3B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,0BAA0B,EAAE,MAAM,CAAA;IAC3C,QAAQ,CAAC,iCAAiC,CAAC,EAAE,MAAM,CAAA;IACnD,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,kBAAkB,CAAC,EAAE,MAAM,CAAA;CACrC;AAED;;;;;GAKG;AACH,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,kBAAkB,EAAE,MAAM,CAAA;IACnC,QAAQ,CAAC,yBAAyB,CAAC,EAAE,MAAM,CAAA;IAC3C,6EAA6E;IAC7E,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAA;IAC3B,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CACzB;AAED;;;;;GAKG;AACH,MAAM,WAAW,OAAO;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAA;IACjC,8DAA8D;IAC9D,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAA;IACtB,2EAA2E;IAC3E,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAA;IACxB,+DAA+D;IAC/D,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAA;IAC3B,+DAA+D;IAC/D,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,kBAAkB,CAAC,EAAE,MAAM,CAAA;CACrC;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,QAAQ;IACvB,QAAQ,CAAC,QAAQ,EAAE,YAAY,GAAG,IAAI,CAAA;IACtC,QAAQ,CAAC,QAAQ,EAAE,YAAY,GAAG,IAAI,CAAA;IACtC,QAAQ,CAAC,GAAG,EAAE,OAAO,GAAG,IAAI,CAAA;IAC5B,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAA;IAC/B,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAA;IAChC,2GAA2G;IAC3G,QAAQ,CAAC,eAAe,EAAE,OAAO,CAAA;CAClC"}
|
|
1
|
+
{"version":3,"file":"response.d.ts","sourceRoot":"","sources":["../../../../src/domain/core/models/response.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,WAAW,YAAY;IAC3B,+CAA+C;IAC/C,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;IAC3B,qEAAqE;IACrE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,+CAA+C;IAC/C,QAAQ,CAAC,0BAA0B,EAAE,MAAM,CAAA;IAC3C,sDAAsD;IACtD,QAAQ,CAAC,iCAAiC,CAAC,EAAE,MAAM,CAAA;IACnD,2DAA2D;IAC3D,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAA;IACxB,iEAAiE;IACjE,QAAQ,CAAC,kBAAkB,CAAC,EAAE,MAAM,CAAA;CACrC;AAED;;;;;GAKG;AACH,MAAM,WAAW,YAAY;IAC3B,gFAAgF;IAChF,QAAQ,CAAC,kBAAkB,EAAE,MAAM,CAAA;IACnC,6DAA6D;IAC7D,QAAQ,CAAC,yBAAyB,CAAC,EAAE,MAAM,CAAA;IAC3C,6EAA6E;IAC7E,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAA;IAC3B,2DAA2D;IAC3D,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CACzB;AAED;;;;;GAKG;AACH,MAAM,WAAW,OAAO;IACtB,wDAAwD;IACxD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,iDAAiD;IACjD,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB,uEAAuE;IACvE,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAA;IACjC,8DAA8D;IAC9D,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAA;IACtB,2EAA2E;IAC3E,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAA;IACxB,+DAA+D;IAC/D,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAA;IAC3B,+DAA+D;IAC/D,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAA;IACxB,2DAA2D;IAC3D,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAA;IACxB,6DAA6D;IAC7D,QAAQ,CAAC,kBAAkB,CAAC,EAAE,MAAM,CAAA;CACrC;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,QAAQ;IACvB,kDAAkD;IAClD,QAAQ,CAAC,QAAQ,EAAE,YAAY,GAAG,IAAI,CAAA;IACtC,8DAA8D;IAC9D,QAAQ,CAAC,QAAQ,EAAE,YAAY,GAAG,IAAI,CAAA;IACtC,kDAAkD;IAClD,QAAQ,CAAC,GAAG,EAAE,OAAO,GAAG,IAAI,CAAA;IAC5B;;;OAGG;IACH,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAA;IAC/B,gEAAgE;IAChE,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAA;IAChC,2GAA2G;IAC3G,QAAQ,CAAC,eAAe,EAAE,OAAO,CAAA;CAClC"}
|
|
@@ -4,9 +4,17 @@
|
|
|
4
4
|
* when omitted.
|
|
5
5
|
*/
|
|
6
6
|
export interface SupplierErrorContextInput {
|
|
7
|
+
/** The supplier identifier, e.g. `"nequi"`. Must not be blank. */
|
|
7
8
|
readonly supplier: string;
|
|
9
|
+
/** The business domain the supplier belongs to, e.g. `"wallets"`. Must not be blank. */
|
|
8
10
|
readonly domain: string;
|
|
11
|
+
/** The supplier's raw response status code, e.g. `"58"`. Must not be blank. */
|
|
9
12
|
readonly code: string;
|
|
13
|
+
/**
|
|
14
|
+
* The locale to resolve the message in, e.g. `"es-CO"`. Optional; a blank
|
|
15
|
+
* or omitted value normalizes to `null` and the catalog resolves against
|
|
16
|
+
* its own default locale.
|
|
17
|
+
*/
|
|
10
18
|
readonly locale?: string | null;
|
|
11
19
|
}
|
|
12
20
|
/**
|
|
@@ -14,9 +22,13 @@ export interface SupplierErrorContextInput {
|
|
|
14
22
|
* to {@link CatalogPort.fetchResponse}.
|
|
15
23
|
*/
|
|
16
24
|
export interface SupplierErrorContext {
|
|
25
|
+
/** The supplier identifier, trimmed and non-blank. */
|
|
17
26
|
readonly supplier: string;
|
|
27
|
+
/** The business domain the supplier belongs to, trimmed and non-blank. */
|
|
18
28
|
readonly domain: string;
|
|
29
|
+
/** The supplier's raw response status code, trimmed and non-blank. */
|
|
19
30
|
readonly code: string;
|
|
31
|
+
/** The locale to resolve the message in, or `null` when not provided. */
|
|
20
32
|
readonly locale: string | null;
|
|
21
33
|
}
|
|
22
34
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"supplier-error-context.d.ts","sourceRoot":"","sources":["../../../../src/domain/core/models/supplier-error-context.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"supplier-error-context.d.ts","sourceRoot":"","sources":["../../../../src/domain/core/models/supplier-error-context.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,MAAM,WAAW,yBAAyB;IACxC,kEAAkE;IAClE,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;IACzB,wFAAwF;IACxF,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,+EAA+E;IAC/E,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB;;;;OAIG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAChC;AAED;;;GAGG;AACH,MAAM,WAAW,oBAAoB;IACnC,sDAAsD;IACtD,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;IACzB,0EAA0E;IAC1E,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,sEAAsE;IACtE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,yEAAyE;IACzE,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAA;CAC/B;AAED;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,yBAAyB,GACpC,OAAO,yBAAyB,KAC/B,oBAKD,CAAA"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { Response } from '../../core/models/response';
|
|
2
|
+
import type { SupplierErrorContext } from '../../core/models/supplier-error-context';
|
|
3
|
+
/**
|
|
4
|
+
* Outbound port: resolve a supplier error against the response catalog.
|
|
5
|
+
* Consumers depend on this abstract class, never on a concrete adapter — the
|
|
6
|
+
* HTTP implementation ships in `createCatalogClient` / `createCatalogClientSync`.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* class FakeCatalogPort extends CatalogPort {
|
|
11
|
+
* async fetchResponse(context: SupplierErrorContext): Promise<Response> {
|
|
12
|
+
* return {
|
|
13
|
+
* supplier: null,
|
|
14
|
+
* internal: null,
|
|
15
|
+
* api: null,
|
|
16
|
+
* resolvedLocale: 'en-US',
|
|
17
|
+
* resolvedMessage: 'stubbed for a test',
|
|
18
|
+
* fallbackApplied: false,
|
|
19
|
+
* }
|
|
20
|
+
* }
|
|
21
|
+
* }
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export declare abstract class CatalogPort {
|
|
25
|
+
/**
|
|
26
|
+
* Resolves a supplier-reported error against the Response Catalog.
|
|
27
|
+
*
|
|
28
|
+
* @param context - Validated supplier, domain, error code, and optional locale
|
|
29
|
+
* @returns The resolved {@link Response}
|
|
30
|
+
* @throws {CatalogClientError} When the catalog request fails (network
|
|
31
|
+
* failure or non-2xx response). Use `isTransient()` to decide whether to
|
|
32
|
+
* retry or fall back locally.
|
|
33
|
+
*/
|
|
34
|
+
abstract fetchResponse(context: SupplierErrorContext): Promise<Response>;
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=catalog-port.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"catalog-port.d.ts","sourceRoot":"","sources":["../../../../src/domain/ports/out/catalog-port.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAA;AAC1D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,0CAA0C,CAAA;AAEpF;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,8BAAsB,WAAW;IAC/B;;;;;;;;OAQG;IACH,QAAQ,CAAC,aAAa,CAAC,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC,QAAQ,CAAC;CACzE"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module @cobre-npm/library-response-catalog-node
|
|
3
|
+
*
|
|
4
|
+
* Node.js client for resolving supplier-reported errors against Cobre's
|
|
5
|
+
* Response Catalog Read API. Build a `CatalogPort` with `createCatalogClient`
|
|
6
|
+
* or `createCatalogClientSync`, then call `fetchResponse` with a
|
|
7
|
+
* `SupplierErrorContext` from `buildSupplierErrorContext`.
|
|
8
|
+
*/
|
|
1
9
|
/**
|
|
2
10
|
* Published package version. Matches `package.json`.
|
|
3
11
|
*
|
|
@@ -5,16 +13,19 @@
|
|
|
5
13
|
* ```typescript
|
|
6
14
|
* import { LIBRARY_VERSION } from '@cobre-npm/library-response-catalog-node'
|
|
7
15
|
*
|
|
8
|
-
* console.log(LIBRARY_VERSION) // '0.
|
|
16
|
+
* console.log(LIBRARY_VERSION) // '0.3.0'
|
|
9
17
|
* ```
|
|
10
18
|
*
|
|
11
19
|
* @see {@link https://github.com/Cobre-Colombia/library-response-catalog-node/blob/trunk/CHANGELOG.md | CHANGELOG}
|
|
12
|
-
* @see {@link https://github.com/Cobre-Colombia/library-response-catalog-node/blob/trunk/docs/releases/01-scaffold.md | Scaffold notes}
|
|
13
20
|
*/
|
|
14
|
-
export declare const LIBRARY_VERSION = "0.
|
|
15
|
-
export { CatalogPort } from './domain/ports/out/catalog
|
|
21
|
+
export declare const LIBRARY_VERSION = "0.3.0";
|
|
22
|
+
export { CatalogPort } from './domain/ports/out/catalog-port';
|
|
16
23
|
export type { Response, SupplierInfo, InternalInfo, ApiInfo, } from './domain/core/models/response';
|
|
17
24
|
export { buildSupplierErrorContext } from './domain/core/models/supplier-error-context';
|
|
18
25
|
export type { SupplierErrorContext, SupplierErrorContextInput, } from './domain/core/models/supplier-error-context';
|
|
19
|
-
export {
|
|
26
|
+
export { CatalogClientError } from './domain/core/models/catalog-client-error';
|
|
27
|
+
export { CONNECTION_MODES } from './adapter/http/connection-mode';
|
|
28
|
+
export type { ConnectionMode } from './adapter/http/connection-mode';
|
|
29
|
+
export type { CatalogAuthHeadersSource } from './adapter/http/catalog-auth-headers-source';
|
|
30
|
+
export { noAuthHeadersSource } from './adapter/http/no-auth-headers-source';
|
|
20
31
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,eAAe,UAAU,CAAA;AAEtC,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAA;AAE7D,YAAY,EACV,QAAQ,EACR,YAAY,EACZ,YAAY,EACZ,OAAO,GACR,MAAM,+BAA+B,CAAA;AAEtC,OAAO,EAAE,yBAAyB,EAAE,MAAM,6CAA6C,CAAA;AAEvF,YAAY,EACV,oBAAoB,EACpB,yBAAyB,GAC1B,MAAM,6CAA6C,CAAA;AAEpD,OAAO,EAAE,kBAAkB,EAAE,MAAM,2CAA2C,CAAA;AAE9E,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAA;AAEjE,YAAY,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAA;AAEpE,YAAY,EAAE,wBAAwB,EAAE,MAAM,4CAA4C,CAAA;AAE1F,OAAO,EAAE,mBAAmB,EAAE,MAAM,uCAAuC,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,15 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* @module @cobre-npm/library-response-catalog-node
|
|
5
|
+
*
|
|
6
|
+
* Node.js client for resolving supplier-reported errors against Cobre's
|
|
7
|
+
* Response Catalog Read API. Build a `CatalogPort` with `createCatalogClient`
|
|
8
|
+
* or `createCatalogClientSync`, then call `fetchResponse` with a
|
|
9
|
+
* `SupplierErrorContext` from `buildSupplierErrorContext`.
|
|
10
|
+
*/
|
|
3
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.
|
|
12
|
+
exports.noAuthHeadersSource = exports.CONNECTION_MODES = exports.CatalogClientError = exports.buildSupplierErrorContext = exports.CatalogPort = exports.LIBRARY_VERSION = void 0;
|
|
5
13
|
/**
|
|
6
14
|
* Published package version. Matches `package.json`.
|
|
7
15
|
*
|
|
@@ -9,17 +17,20 @@ exports.CatalogClientException = exports.buildSupplierErrorContext = exports.Cat
|
|
|
9
17
|
* ```typescript
|
|
10
18
|
* import { LIBRARY_VERSION } from '@cobre-npm/library-response-catalog-node'
|
|
11
19
|
*
|
|
12
|
-
* console.log(LIBRARY_VERSION) // '0.
|
|
20
|
+
* console.log(LIBRARY_VERSION) // '0.3.0'
|
|
13
21
|
* ```
|
|
14
22
|
*
|
|
15
23
|
* @see {@link https://github.com/Cobre-Colombia/library-response-catalog-node/blob/trunk/CHANGELOG.md | CHANGELOG}
|
|
16
|
-
* @see {@link https://github.com/Cobre-Colombia/library-response-catalog-node/blob/trunk/docs/releases/01-scaffold.md | Scaffold notes}
|
|
17
24
|
*/
|
|
18
|
-
exports.LIBRARY_VERSION = '0.
|
|
19
|
-
var catalog_port_1 = require("./domain/ports/out/catalog
|
|
25
|
+
exports.LIBRARY_VERSION = '0.3.0';
|
|
26
|
+
var catalog_port_1 = require("./domain/ports/out/catalog-port");
|
|
20
27
|
Object.defineProperty(exports, "CatalogPort", { enumerable: true, get: function () { return catalog_port_1.CatalogPort; } });
|
|
21
28
|
var supplier_error_context_1 = require("./domain/core/models/supplier-error-context");
|
|
22
29
|
Object.defineProperty(exports, "buildSupplierErrorContext", { enumerable: true, get: function () { return supplier_error_context_1.buildSupplierErrorContext; } });
|
|
23
|
-
var
|
|
24
|
-
Object.defineProperty(exports, "
|
|
30
|
+
var catalog_client_error_1 = require("./domain/core/models/catalog-client-error");
|
|
31
|
+
Object.defineProperty(exports, "CatalogClientError", { enumerable: true, get: function () { return catalog_client_error_1.CatalogClientError; } });
|
|
32
|
+
var connection_mode_1 = require("./adapter/http/connection-mode");
|
|
33
|
+
Object.defineProperty(exports, "CONNECTION_MODES", { enumerable: true, get: function () { return connection_mode_1.CONNECTION_MODES; } });
|
|
34
|
+
var no_auth_headers_source_1 = require("./adapter/http/no-auth-headers-source");
|
|
35
|
+
Object.defineProperty(exports, "noAuthHeadersSource", { enumerable: true, get: function () { return no_auth_headers_source_1.noAuthHeadersSource; } });
|
|
25
36
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":[null],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAAA;;;;;;;AAOG;;;AAEH;;;;;;;;;;;AAWG;AACU,OAAA,CAAA,eAAe,GAAG,OAAO;AAEtC,IAAA,cAAA,GAAA,OAAA,CAAA,iCAAA,CAAA;AAAS,MAAA,CAAA,cAAA,CAAA,OAAA,EAAA,aAAA,EAAA,EAAA,UAAA,EAAA,IAAA,EAAA,GAAA,EAAA,YAAA,EAAA,OAAA,cAAA,CAAA,WAAW,CAAA,CAAA,CAAA,EAAA,CAAA;AASpB,IAAA,wBAAA,GAAA,OAAA,CAAA,6CAAA,CAAA;AAAS,MAAA,CAAA,cAAA,CAAA,OAAA,EAAA,2BAAA,EAAA,EAAA,UAAA,EAAA,IAAA,EAAA,GAAA,EAAA,YAAA,EAAA,OAAA,wBAAA,CAAA,yBAAyB,CAAA,CAAA,CAAA,EAAA,CAAA;AAOlC,IAAA,sBAAA,GAAA,OAAA,CAAA,2CAAA,CAAA;AAAS,MAAA,CAAA,cAAA,CAAA,OAAA,EAAA,oBAAA,EAAA,EAAA,UAAA,EAAA,IAAA,EAAA,GAAA,EAAA,YAAA,EAAA,OAAA,sBAAA,CAAA,kBAAkB,CAAA,CAAA,CAAA,EAAA,CAAA;AAE3B,IAAA,iBAAA,GAAA,OAAA,CAAA,gCAAA,CAAA;AAAS,MAAA,CAAA,cAAA,CAAA,OAAA,EAAA,kBAAA,EAAA,EAAA,UAAA,EAAA,IAAA,EAAA,GAAA,EAAA,YAAA,EAAA,OAAA,iBAAA,CAAA,gBAAgB,CAAA,CAAA,CAAA,EAAA,CAAA;AAMzB,IAAA,wBAAA,GAAA,OAAA,CAAA,uCAAA,CAAA;AAAS,MAAA,CAAA,cAAA,CAAA,OAAA,EAAA,qBAAA,EAAA,EAAA,UAAA,EAAA,IAAA,EAAA,GAAA,EAAA,YAAA,EAAA,OAAA,wBAAA,CAAA,mBAAmB,CAAA,CAAA,CAAA,EAAA,CAAA"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Blank-string predicates shared by the domain and the adapters. A value counts
|
|
3
|
+
* as text only when it is present and holds at least one non-whitespace
|
|
4
|
+
* character, so `''`, `' '`, `null` and `undefined` are all treated alike.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Narrows a possibly-absent string to one that holds non-whitespace text.
|
|
8
|
+
*
|
|
9
|
+
* @param value - The value to check
|
|
10
|
+
* @returns `true` when the value is a string with non-whitespace content
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* hasText(' es-CO ') // true
|
|
15
|
+
* hasText(' ') // false
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export declare const hasText: (value: string | null | undefined) => value is string;
|
|
19
|
+
/**
|
|
20
|
+
* Returns the trimmed value, or throws when it holds no text.
|
|
21
|
+
*
|
|
22
|
+
* @param value - The value to validate
|
|
23
|
+
* @param fieldName - Name used in the error message
|
|
24
|
+
* @returns The value with surrounding whitespace removed
|
|
25
|
+
* @throws Error when the value holds no non-whitespace character
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```typescript
|
|
29
|
+
* requireText(' #UNKNOWN# ', 'token') // '#UNKNOWN#'
|
|
30
|
+
* requireText(' ', 'token') // throws: token must not be blank
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
export declare const requireText: (value: string | null | undefined, fieldName: string) => string;
|
|
34
|
+
//# sourceMappingURL=text.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text.d.ts","sourceRoot":"","sources":["../../src/shared/text.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,OAAO,GAAI,OAAO,MAAM,GAAG,IAAI,GAAG,SAAS,KAAG,KAAK,IAAI,MACF,CAAA;AAElE;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,WAAW,GAAI,OAAO,MAAM,GAAG,IAAI,GAAG,SAAS,EAAE,WAAW,MAAM,KAAG,MAMjF,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cobre-npm/library-response-catalog-node",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"packageManager": "pnpm@10.27.0",
|
|
5
5
|
"description": "Node.js Cobre library for resolving supplier errors against the Response Catalog Read API",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -17,9 +17,10 @@
|
|
|
17
17
|
"build:qa-arm": "npm run build",
|
|
18
18
|
"build:prod-arm": "npm run build",
|
|
19
19
|
"lint": "eslint src --ext .ts",
|
|
20
|
-
"test": "jest",
|
|
20
|
+
"test": "jest --coverage",
|
|
21
21
|
"test:coverage": "jest --coverage",
|
|
22
|
-
"docs": "typedoc"
|
|
22
|
+
"docs": "typedoc",
|
|
23
|
+
"test:watch": "jest --watch"
|
|
23
24
|
},
|
|
24
25
|
"license": "ISC",
|
|
25
26
|
"dependencies": {
|
|
@@ -47,9 +48,7 @@
|
|
|
47
48
|
"eslint": "^8.57.0",
|
|
48
49
|
"jest": "^29.7.0",
|
|
49
50
|
"nock": "^13.5.4",
|
|
50
|
-
"rimraf": "^5.0.7",
|
|
51
51
|
"rollup": "^4.18.0",
|
|
52
|
-
"rollup-plugin-typescript2": "^0.36.0",
|
|
53
52
|
"ts-jest": "^29.2.3",
|
|
54
53
|
"tslib": "^2.8.1",
|
|
55
54
|
"typedoc": "^0.28.20",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"catalog-client-exception.d.ts","sourceRoot":"","sources":["../../../../src/domain/core/models/catalog-client-exception.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;GAeG;AACH,qBAAa,sBAAuB,SAAQ,KAAK;IAC/C;;;OAGG;IACH,QAAQ,CAAC,cAAc,EAAE,MAAM,GAAG,IAAI,CAAA;IAEtC;;;;;OAKG;gBACS,OAAO,EAAE,MAAM,EAAE,qBAAqB,CAAC,EAAE,MAAM,GAAG,KAAK;IAYnE;;;;OAIG;IACH,WAAW,IAAI,OAAO;IAItB;;;OAGG;IACH,iBAAiB,IAAI,OAAO;CAG7B"}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import type { Response } from '../../core/models/response';
|
|
2
|
-
import type { SupplierErrorContext } from '../../core/models/supplier-error-context';
|
|
3
|
-
/** Outbound port: resolve a supplier error against the response catalog. */
|
|
4
|
-
export declare abstract class CatalogPort {
|
|
5
|
-
/**
|
|
6
|
-
* Resolves a supplier-reported error against the Response Catalog.
|
|
7
|
-
*
|
|
8
|
-
* @param context - Validated supplier, domain, error code, and optional locale
|
|
9
|
-
* @returns The resolved {@link Response}
|
|
10
|
-
* @throws {CatalogClientException} When the catalog request fails (network
|
|
11
|
-
* failure or non-2xx response). Use `isTransient()` to decide whether to
|
|
12
|
-
* retry or fall back locally.
|
|
13
|
-
*/
|
|
14
|
-
abstract fetchResponse(context: SupplierErrorContext): Promise<Response>;
|
|
15
|
-
}
|
|
16
|
-
//# sourceMappingURL=catalog.port.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"catalog.port.d.ts","sourceRoot":"","sources":["../../../../src/domain/ports/out/catalog.port.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAA;AAC1D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,0CAA0C,CAAA;AAEpF,4EAA4E;AAC5E,8BAAsB,WAAW;IAC/B;;;;;;;;OAQG;IACH,QAAQ,CAAC,aAAa,CAAC,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC,QAAQ,CAAC;CACzE"}
|