@cobre-npm/library-portal-core 0.47.0 → 0.49.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 +10 -4
- package/dist/cjs/counterparties/types/utils/counterparty-type.utils.d.ts +7 -0
- package/dist/cjs/counterparties/types/utils/counterparty-type.utils.js +9 -1
- package/dist/cjs/financialInstitutions/locales/en.json +1 -1
- package/dist/cjs/financialInstitutions/locales/es-mex.json +1 -1
- package/dist/esm/counterparties/types/utils/counterparty-type.utils.js +7 -0
- package/dist/esm/financialInstitutions/locales/en.json +1 -1
- package/dist/esm/financialInstitutions/locales/es-mex.json +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -196,15 +196,21 @@ queryAccountStatuses({ lang: "en", type: "error" }) // [ disconnected, failed
|
|
|
196
196
|
|
|
197
197
|
```ts
|
|
198
198
|
import {
|
|
199
|
-
getCounterpartyTypes,
|
|
200
|
-
type CounterpartyType, type CounterpartyTypeOption,
|
|
199
|
+
getCounterpartyTypes, queryCounterpartyTypes,
|
|
200
|
+
type CounterpartyType, type CounterpartyTypeOption, type CounterpartyTypeQuery,
|
|
201
201
|
type Counterparty, CounterpartyVerificationStatus, /* ... */
|
|
202
202
|
} from "@cobre-npm/library-portal-core/counterparties"
|
|
203
203
|
|
|
204
|
-
getCounterpartyTypes("es-mex")
|
|
204
|
+
getCounterpartyTypes("es-mex") // Record<CounterpartyType, CounterpartyTypeOption> ({ code, geo, label })
|
|
205
|
+
queryCounterpartyTypes({ lang: "es-mex", geo: "mex" }) // [ clabe, r2p_spei, spei_card ] → MEX-eligible counterparty types
|
|
205
206
|
```
|
|
206
207
|
|
|
207
|
-
- **types** (i18n): `getCounterpartyTypes(lang)
|
|
208
|
+
- **types** (i18n): `getCounterpartyTypes(lang)`; each record carries `code`, `geo` (`Country[]`) and
|
|
209
|
+
`label`. `queryCounterpartyTypes({ lang, ... })` returns the same catalog as a **list**, narrowed by
|
|
210
|
+
`code`/`geo` — same matching rules as [`queryAccountTypes`](#accounts): `lang` is required (i18n
|
|
211
|
+
domain, no default) inside the query object, and `geo` being an array field means `{ geo: "mex" }`
|
|
212
|
+
matches "contains any". A few codes (`np`, `le`, `mm_return`) carry an empty `geo: []` — they never
|
|
213
|
+
match any `geo` filter, only a `code` filter, since `[].some(...)` is always `false`.
|
|
208
214
|
- **interfaces**: `Counterparty`, `CounterpartyMetadata`, `CounterpartyBankDetails`,
|
|
209
215
|
`CounterpartyPaymentInformation`, `CounterpartyVerificationStatus` (enum), `ParamsGetCounterparties`,
|
|
210
216
|
`CreateCounterpartyRequest`, …
|
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
import type { CounterpartyType, CounterpartyTypeRecord } from "../catalog";
|
|
2
2
|
import type { Locale } from "../../../lang";
|
|
3
|
+
import type { CatalogQuery } from "../../../utils/catalog-query.utils";
|
|
3
4
|
export type CounterpartyTypeOption = CounterpartyTypeRecord & {
|
|
4
5
|
label: string;
|
|
5
6
|
};
|
|
6
7
|
export declare const getCounterpartyTypes: (lang: Locale) => Record<CounterpartyType, CounterpartyTypeOption>;
|
|
8
|
+
/** `lang` is required (i18n domain, no default) and travels inside the query object, never positional. */
|
|
9
|
+
export type CounterpartyTypeQuery = CatalogQuery<CounterpartyTypeRecord> & {
|
|
10
|
+
lang: Locale;
|
|
11
|
+
};
|
|
12
|
+
/** The catalog as a list, narrowed by the query — see `matchesQuery` for the matching rules. */
|
|
13
|
+
export declare const queryCounterpartyTypes: (query: CounterpartyTypeQuery) => CounterpartyTypeOption[];
|
|
@@ -3,10 +3,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.getCounterpartyTypes = void 0;
|
|
6
|
+
exports.queryCounterpartyTypes = exports.getCounterpartyTypes = void 0;
|
|
7
7
|
const catalog_1 = require("../catalog");
|
|
8
8
|
const en_json_1 = __importDefault(require("../locales/en.json"));
|
|
9
9
|
const es_mex_json_1 = __importDefault(require("../locales/es-mex.json"));
|
|
10
|
+
const catalog_query_utils_1 = require("../../../utils/catalog-query.utils");
|
|
10
11
|
const locales = { en: en_json_1.default, "es-mex": es_mex_json_1.default };
|
|
11
12
|
const getCounterpartyTypes = (lang) => {
|
|
12
13
|
const locale = locales[lang];
|
|
@@ -17,3 +18,10 @@ const getCounterpartyTypes = (lang) => {
|
|
|
17
18
|
return result;
|
|
18
19
|
};
|
|
19
20
|
exports.getCounterpartyTypes = getCounterpartyTypes;
|
|
21
|
+
/** The catalog as a list, narrowed by the query — see `matchesQuery` for the matching rules. */
|
|
22
|
+
const queryCounterpartyTypes = (query) => {
|
|
23
|
+
const { lang, ...criteria } = query;
|
|
24
|
+
const types = (0, exports.getCounterpartyTypes)(lang);
|
|
25
|
+
return Object.values(types).filter(type => (0, catalog_query_utils_1.matchesQuery)(type, criteria));
|
|
26
|
+
};
|
|
27
|
+
exports.queryCounterpartyTypes = queryCounterpartyTypes;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { COUNTERPARTY_TYPES } from "../catalog";
|
|
2
2
|
import enLocale from "../locales/en.json";
|
|
3
3
|
import esMexLocale from "../locales/es-mex.json";
|
|
4
|
+
import { matchesQuery } from "../../../utils/catalog-query.utils";
|
|
4
5
|
const locales = { en: enLocale, "es-mex": esMexLocale };
|
|
5
6
|
export const getCounterpartyTypes = (lang) => {
|
|
6
7
|
const locale = locales[lang];
|
|
@@ -10,3 +11,9 @@ export const getCounterpartyTypes = (lang) => {
|
|
|
10
11
|
}
|
|
11
12
|
return result;
|
|
12
13
|
};
|
|
14
|
+
/** The catalog as a list, narrowed by the query — see `matchesQuery` for the matching rules. */
|
|
15
|
+
export const queryCounterpartyTypes = (query) => {
|
|
16
|
+
const { lang, ...criteria } = query;
|
|
17
|
+
const types = getCounterpartyTypes(lang);
|
|
18
|
+
return Object.values(types).filter(type => matchesQuery(type, criteria));
|
|
19
|
+
};
|