@cobre-npm/library-portal-core 0.67.0 → 0.68.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 +21 -2
- package/dist/cjs/accounts/status/utils/account-status.utils.d.ts +4 -1
- package/dist/cjs/accounts/status/utils/account-status.utils.js +6 -7
- package/dist/cjs/accounts/types/utils/account-type.utils.d.ts +4 -1
- package/dist/cjs/accounts/types/utils/account-type.utils.js +6 -11
- package/dist/cjs/blockchains/utils/blockchain.utils.d.ts +4 -1
- package/dist/cjs/blockchains/utils/blockchain.utils.js +6 -7
- package/dist/cjs/canonicalTransactions/nature/utils/nature.utils.d.ts +4 -1
- package/dist/cjs/canonicalTransactions/nature/utils/nature.utils.js +4 -6
- package/dist/cjs/canonicalTransactions/productType/utils/product-type.utils.d.ts +4 -1
- package/dist/cjs/canonicalTransactions/productType/utils/product-type.utils.js +4 -6
- package/dist/cjs/counterparties/types/utils/counterparty-type.utils.d.ts +4 -1
- package/dist/cjs/counterparties/types/utils/counterparty-type.utils.js +6 -7
- package/dist/cjs/countries/base/utils/country.utils.d.ts +4 -1
- package/dist/cjs/countries/base/utils/country.utils.js +6 -7
- package/dist/cjs/countries/iso/utils/country-iso.utils.d.ts +4 -1
- package/dist/cjs/countries/iso/utils/country-iso.utils.js +6 -7
- package/dist/cjs/documentTypes/utils/document-type.utils.d.ts +4 -1
- package/dist/cjs/documentTypes/utils/document-type.utils.js +7 -11
- package/dist/cjs/filterClassification/categoryFamilies/utils/filter-classification-category-family.utils.d.ts +4 -1
- package/dist/cjs/filterClassification/categoryFamilies/utils/filter-classification-category-family.utils.js +4 -6
- package/dist/cjs/filterClassification/sections/utils/filter-classification-section.utils.d.ts +4 -1
- package/dist/cjs/filterClassification/sections/utils/filter-classification-section.utils.js +4 -7
- package/dist/cjs/financialInstitutions/utils/financial-institution.utils.d.ts +6 -3
- package/dist/cjs/financialInstitutions/utils/financial-institution.utils.js +11 -7
- package/dist/cjs/lang/index.d.ts +8 -0
- package/dist/cjs/lang/index.js +11 -1
- package/dist/cjs/movements/status/utils/movement-status.utils.d.ts +4 -1
- package/dist/cjs/movements/status/utils/movement-status.utils.js +5 -6
- package/dist/cjs/movements/types/utils/movement-type.utils.d.ts +4 -1
- package/dist/cjs/movements/types/utils/movement-type.utils.js +5 -6
- package/dist/cjs/subclients/status/utils/subclient-status.utils.d.ts +4 -1
- package/dist/cjs/subclients/status/utils/subclient-status.utils.js +4 -6
- package/dist/cjs/transactions/types/utils/transaction-type.utils.d.ts +4 -1
- package/dist/cjs/transactions/types/utils/transaction-type.utils.js +5 -10
- package/dist/cjs/utils/catalog-label.utils.d.ts +8 -0
- package/dist/cjs/utils/catalog-label.utils.js +2 -0
- package/dist/esm/accounts/status/utils/account-status.utils.js +3 -4
- package/dist/esm/accounts/types/utils/account-type.utils.js +3 -8
- package/dist/esm/blockchains/utils/blockchain.utils.js +3 -4
- package/dist/esm/canonicalTransactions/nature/utils/nature.utils.js +3 -4
- package/dist/esm/canonicalTransactions/productType/utils/product-type.utils.js +3 -4
- package/dist/esm/counterparties/types/utils/counterparty-type.utils.js +3 -4
- package/dist/esm/countries/base/utils/country.utils.js +3 -4
- package/dist/esm/countries/iso/utils/country-iso.utils.js +3 -4
- package/dist/esm/documentTypes/utils/document-type.utils.js +4 -8
- package/dist/esm/filterClassification/categoryFamilies/utils/filter-classification-category-family.utils.js +3 -4
- package/dist/esm/filterClassification/sections/utils/filter-classification-section.utils.js +3 -5
- package/dist/esm/financialInstitutions/utils/financial-institution.utils.js +9 -5
- package/dist/esm/lang/index.js +9 -0
- package/dist/esm/movements/status/utils/movement-status.utils.js +3 -4
- package/dist/esm/movements/types/utils/movement-type.utils.js +3 -4
- package/dist/esm/subclients/status/utils/subclient-status.utils.js +3 -4
- package/dist/esm/transactions/types/utils/transaction-type.utils.js +3 -8
- package/dist/esm/utils/catalog-label.utils.js +1 -0
- package/package.json +1 -1
|
@@ -3,7 +3,8 @@ 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.queryFinancialInstitutions =
|
|
6
|
+
exports.queryFinancialInstitutions = void 0;
|
|
7
|
+
exports.getFinancialInstitutions = getFinancialInstitutions;
|
|
7
8
|
const catalog_1 = require("../catalog");
|
|
8
9
|
const en_json_1 = __importDefault(require("../locales/en.json"));
|
|
9
10
|
const es_mex_json_1 = __importDefault(require("../locales/es-mex.json"));
|
|
@@ -18,12 +19,15 @@ const buildFinancialInstitutions = (lang) => {
|
|
|
18
19
|
}
|
|
19
20
|
return result;
|
|
20
21
|
};
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
const
|
|
26
|
-
|
|
22
|
+
function getFinancialInstitutions(...args) {
|
|
23
|
+
if (args.length !== 0)
|
|
24
|
+
return buildFinancialInstitutions(args[0]);
|
|
25
|
+
const result = {};
|
|
26
|
+
for (const record of Object.values(catalog_1.FINANCIAL_INSTITUTIONS)) {
|
|
27
|
+
result[record.code] = { ...record };
|
|
28
|
+
}
|
|
29
|
+
return result;
|
|
30
|
+
}
|
|
27
31
|
/** The catalog as a list, narrowed by the query — see `matchesQuery` for the matching rules. */
|
|
28
32
|
const queryFinancialInstitutions = (query) => {
|
|
29
33
|
const { lang, ...criteria } = query;
|
package/dist/cjs/lang/index.d.ts
CHANGED
|
@@ -2,3 +2,11 @@ export declare const DEFAULT_EN_LOCALE = "en";
|
|
|
2
2
|
export declare const DEFAULT_ES_LOCALE = "es-mex";
|
|
3
3
|
export declare const LOCALES: readonly ["en", "es-mex"];
|
|
4
4
|
export type Locale = (typeof LOCALES)[number];
|
|
5
|
+
/**
|
|
6
|
+
* Narrows any string to a supported `Locale`: an exact member of `LOCALES` passes through, anything else
|
|
7
|
+
* falls back to `DEFAULT_ES_LOCALE`. The active language is not always a library literal (a user preference
|
|
8
|
+
* saved without validation, `en-US` from the browser), and every translated `getX(lang)` / `queryX({ lang })`
|
|
9
|
+
* indexes its messages by the exact string and throws on anything else. Call it once where a pipeline reads
|
|
10
|
+
* the active language, not at every call site.
|
|
11
|
+
*/
|
|
12
|
+
export declare const toSupportedLocale: (lang: string) => Locale;
|
package/dist/cjs/lang/index.js
CHANGED
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.LOCALES = exports.DEFAULT_ES_LOCALE = exports.DEFAULT_EN_LOCALE = void 0;
|
|
3
|
+
exports.toSupportedLocale = exports.LOCALES = exports.DEFAULT_ES_LOCALE = exports.DEFAULT_EN_LOCALE = void 0;
|
|
4
4
|
exports.DEFAULT_EN_LOCALE = "en";
|
|
5
5
|
exports.DEFAULT_ES_LOCALE = "es-mex";
|
|
6
6
|
exports.LOCALES = [exports.DEFAULT_EN_LOCALE, exports.DEFAULT_ES_LOCALE];
|
|
7
|
+
const SUPPORTED_LOCALES = exports.LOCALES;
|
|
8
|
+
/**
|
|
9
|
+
* Narrows any string to a supported `Locale`: an exact member of `LOCALES` passes through, anything else
|
|
10
|
+
* falls back to `DEFAULT_ES_LOCALE`. The active language is not always a library literal (a user preference
|
|
11
|
+
* saved without validation, `en-US` from the browser), and every translated `getX(lang)` / `queryX({ lang })`
|
|
12
|
+
* indexes its messages by the exact string and throws on anything else. Call it once where a pipeline reads
|
|
13
|
+
* the active language, not at every call site.
|
|
14
|
+
*/
|
|
15
|
+
const toSupportedLocale = (lang) => SUPPORTED_LOCALES.includes(lang) ? lang : exports.DEFAULT_ES_LOCALE;
|
|
16
|
+
exports.toSupportedLocale = toSupportedLocale;
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import type { MovementStatus, MovementStatusRecord } from "../catalog";
|
|
2
2
|
import type { Locale } from "../../../lang";
|
|
3
3
|
import type { CatalogQuery } from "../../../utils/catalog-query.utils";
|
|
4
|
+
import type { WithoutLabel } from "../../../utils/catalog-label.utils";
|
|
4
5
|
export type MovementStatusOption = MovementStatusRecord & {
|
|
5
6
|
label: string;
|
|
6
7
|
};
|
|
7
|
-
|
|
8
|
+
/** Without `lang`: the records with no `label`, to read codes and metadata where no language applies. */
|
|
9
|
+
export declare function getMovementStatuses(): Record<MovementStatus, WithoutLabel<MovementStatusOption>>;
|
|
10
|
+
export declare function getMovementStatuses(lang: Locale): Record<MovementStatus, MovementStatusOption>;
|
|
8
11
|
/** i18n domain: `lang` is required, inside the query object — see matchesQuery for the matching rules. */
|
|
9
12
|
export type MovementStatusQuery = CatalogQuery<MovementStatusRecord> & {
|
|
10
13
|
lang: Locale;
|
|
@@ -3,21 +3,20 @@ 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.queryMovementStatuses =
|
|
6
|
+
exports.queryMovementStatuses = void 0;
|
|
7
|
+
exports.getMovementStatuses = getMovementStatuses;
|
|
7
8
|
const catalog_1 = require("../catalog");
|
|
8
9
|
const en_json_1 = __importDefault(require("../locales/en.json"));
|
|
9
10
|
const es_mex_json_1 = __importDefault(require("../locales/es-mex.json"));
|
|
10
11
|
const catalog_query_utils_1 = require("../../../utils/catalog-query.utils");
|
|
11
12
|
const locales = { en: en_json_1.default, "es-mex": es_mex_json_1.default };
|
|
12
|
-
|
|
13
|
-
const locale = locales[lang];
|
|
13
|
+
function getMovementStatuses(...args) {
|
|
14
14
|
const result = {};
|
|
15
15
|
for (const record of Object.values(catalog_1.MOVEMENT_STATUSES)) {
|
|
16
|
-
result[record.code] = { ...record, label:
|
|
16
|
+
result[record.code] = args.length === 0 ? { ...record } : { ...record, label: locales[args[0]].movementStatuses[record.code] };
|
|
17
17
|
}
|
|
18
18
|
return result;
|
|
19
|
-
}
|
|
20
|
-
exports.getMovementStatuses = getMovementStatuses;
|
|
19
|
+
}
|
|
21
20
|
/**
|
|
22
21
|
* The catalog as a list narrowed by the query, each record enriched with its label for `query.lang`.
|
|
23
22
|
* `code` is the only filterable field — `label` is display text, added after filtering, never a query key.
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import type { MovementType, MovementTypeRecord, MovementTypeScope } from "../catalog";
|
|
2
2
|
import type { Locale } from "../../../lang";
|
|
3
3
|
import type { CatalogQuery } from "../../../utils/catalog-query.utils";
|
|
4
|
+
import type { WithoutLabel } from "../../../utils/catalog-label.utils";
|
|
4
5
|
export type MovementTypeOption = MovementTypeRecord & {
|
|
5
6
|
label: string;
|
|
6
7
|
};
|
|
7
|
-
|
|
8
|
+
/** Without `lang`: the records with no `label`, to read codes and metadata where no language applies. */
|
|
9
|
+
export declare function getMovementTypes(): Record<MovementType, WithoutLabel<MovementTypeOption>>;
|
|
10
|
+
export declare function getMovementTypes(lang: Locale): Record<MovementType, MovementTypeOption>;
|
|
8
11
|
/** i18n domain: `lang` is required, inside the query object — see matchesQuery for the matching rules. */
|
|
9
12
|
export type MovementTypeQuery = CatalogQuery<Omit<MovementTypeRecord, "scope">> & {
|
|
10
13
|
lang: Locale;
|
|
@@ -3,21 +3,20 @@ 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.queryMovementTypes =
|
|
6
|
+
exports.queryMovementTypes = void 0;
|
|
7
|
+
exports.getMovementTypes = getMovementTypes;
|
|
7
8
|
const catalog_1 = require("../catalog");
|
|
8
9
|
const en_json_1 = __importDefault(require("../locales/en.json"));
|
|
9
10
|
const es_mex_json_1 = __importDefault(require("../locales/es-mex.json"));
|
|
10
11
|
const catalog_query_utils_1 = require("../../../utils/catalog-query.utils");
|
|
11
12
|
const locales = { en: en_json_1.default, "es-mex": es_mex_json_1.default };
|
|
12
|
-
|
|
13
|
-
const locale = locales[lang];
|
|
13
|
+
function getMovementTypes(...args) {
|
|
14
14
|
const result = {};
|
|
15
15
|
for (const record of Object.values(catalog_1.MOVEMENT_TYPES)) {
|
|
16
|
-
result[record.code] = { ...record, label:
|
|
16
|
+
result[record.code] = args.length === 0 ? { ...record } : { ...record, label: locales[args[0]].movementTypes[record.code] };
|
|
17
17
|
}
|
|
18
18
|
return result;
|
|
19
|
-
}
|
|
20
|
-
exports.getMovementTypes = getMovementTypes;
|
|
19
|
+
}
|
|
21
20
|
/**
|
|
22
21
|
* The catalog as a list narrowed by the query, each record enriched with its label for `query.lang`.
|
|
23
22
|
*
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import type { SubclientStatus, SubclientStatusRecord } from "../catalog";
|
|
2
2
|
import type { Locale } from "../../../lang";
|
|
3
|
+
import type { WithoutLabel } from "../../../utils/catalog-label.utils";
|
|
3
4
|
export type SubclientStatusOption = SubclientStatusRecord & {
|
|
4
5
|
label: string;
|
|
5
6
|
};
|
|
6
|
-
|
|
7
|
+
/** Without `lang`: the records with no `label`, to read codes and metadata where no language applies. */
|
|
8
|
+
export declare function getSubclientStatuses(): Record<SubclientStatus, WithoutLabel<SubclientStatusOption>>;
|
|
9
|
+
export declare function getSubclientStatuses(lang: Locale): Record<SubclientStatus, SubclientStatusOption>;
|
|
@@ -3,17 +3,15 @@ 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.getSubclientStatuses =
|
|
6
|
+
exports.getSubclientStatuses = getSubclientStatuses;
|
|
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
10
|
const locales = { en: en_json_1.default, "es-mex": es_mex_json_1.default };
|
|
11
|
-
|
|
12
|
-
const locale = locales[lang];
|
|
11
|
+
function getSubclientStatuses(...args) {
|
|
13
12
|
const result = {};
|
|
14
13
|
for (const record of Object.values(catalog_1.SUBCLIENT_STATUSES)) {
|
|
15
|
-
result[record.code] = { ...record, label:
|
|
14
|
+
result[record.code] = args.length === 0 ? { ...record } : { ...record, label: locales[args[0]].subclientStatuses[record.code] };
|
|
16
15
|
}
|
|
17
16
|
return result;
|
|
18
|
-
}
|
|
19
|
-
exports.getSubclientStatuses = getSubclientStatuses;
|
|
17
|
+
}
|
|
@@ -2,14 +2,17 @@ import type { TransactionType, TransactionTypeGroup, TransactionTypeRecord } fro
|
|
|
2
2
|
import type { FilterClassificationRecord } from "../../../filterClassification/interfaces/filter-classification.interface";
|
|
3
3
|
import type { Locale } from "../../../lang";
|
|
4
4
|
import type { CatalogQuery } from "../../../utils/catalog-query.utils";
|
|
5
|
+
import type { WithoutLabel } from "../../../utils/catalog-label.utils";
|
|
5
6
|
export type TransactionTypeOption = TransactionTypeRecord & {
|
|
6
7
|
label: string;
|
|
7
8
|
};
|
|
9
|
+
/** Without `lang`: the records with no `label`, to read codes and metadata where no language applies. */
|
|
10
|
+
export declare function getTransactionTypes(): Record<TransactionType, WithoutLabel<TransactionTypeOption>>;
|
|
8
11
|
/**
|
|
9
12
|
* The catalog indexed by code (same shape as TRANSACTION_TYPES), each record enriched
|
|
10
13
|
* with its label for the given language. Access by code directly, or Object.values for a list.
|
|
11
14
|
*/
|
|
12
|
-
export declare
|
|
15
|
+
export declare function getTransactionTypes(lang: Locale): Record<TransactionType, TransactionTypeOption>;
|
|
13
16
|
/** i18n domain: `lang` is required, inside the query object — see matchesQuery for the matching rules. */
|
|
14
17
|
export type TransactionTypeQuery = CatalogQuery<TransactionTypeRecord> & {
|
|
15
18
|
lang: Locale;
|
|
@@ -3,25 +3,20 @@ 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.collapseTransactionTypes = exports.queryTransactionTypes =
|
|
6
|
+
exports.collapseTransactionTypes = exports.queryTransactionTypes = void 0;
|
|
7
|
+
exports.getTransactionTypes = getTransactionTypes;
|
|
7
8
|
const catalog_1 = require("../catalog");
|
|
8
9
|
const en_json_1 = __importDefault(require("../locales/en.json"));
|
|
9
10
|
const es_mex_json_1 = __importDefault(require("../locales/es-mex.json"));
|
|
10
11
|
const catalog_query_utils_1 = require("../../../utils/catalog-query.utils");
|
|
11
12
|
const locales = { en: en_json_1.default, "es-mex": es_mex_json_1.default };
|
|
12
|
-
|
|
13
|
-
* The catalog indexed by code (same shape as TRANSACTION_TYPES), each record enriched
|
|
14
|
-
* with its label for the given language. Access by code directly, or Object.values for a list.
|
|
15
|
-
*/
|
|
16
|
-
const getTransactionTypes = (lang) => {
|
|
17
|
-
const locale = locales[lang];
|
|
13
|
+
function getTransactionTypes(...args) {
|
|
18
14
|
const result = {};
|
|
19
15
|
for (const record of Object.values(catalog_1.TRANSACTION_TYPES)) {
|
|
20
|
-
result[record.code] = { ...record, label:
|
|
16
|
+
result[record.code] = args.length === 0 ? { ...record } : { ...record, label: locales[args[0]].transactionTypes[record.code] };
|
|
21
17
|
}
|
|
22
18
|
return result;
|
|
23
|
-
}
|
|
24
|
-
exports.getTransactionTypes = getTransactionTypes;
|
|
19
|
+
}
|
|
25
20
|
/** The catalog as a list narrowed by the query, each record enriched with its label for `query.lang`. */
|
|
26
21
|
const queryTransactionTypes = (query) => {
|
|
27
22
|
const { lang, ...filters } = query;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A catalog record without its `label`: what an i18n `getX()` returns when called with no language.
|
|
3
|
+
*
|
|
4
|
+
* Distributive on purpose. A catalog's record type is a union of its `as const` rows, and a field present on only
|
|
5
|
+
* some rows (`filterDisplay` in `transactions/types`) would vanish under a plain `Omit`, which computes `keyof` over
|
|
6
|
+
* the whole union and keeps only the keys every row shares.
|
|
7
|
+
*/
|
|
8
|
+
export type WithoutLabel<T> = T extends unknown ? Omit<T, "label"> : never;
|
|
@@ -3,14 +3,13 @@ import enLocale from "../locales/en.json";
|
|
|
3
3
|
import esMexLocale from "../locales/es-mex.json";
|
|
4
4
|
import { matchesQuery } from "../../../utils/catalog-query.utils";
|
|
5
5
|
const locales = { en: enLocale, "es-mex": esMexLocale };
|
|
6
|
-
export
|
|
7
|
-
const locale = locales[lang];
|
|
6
|
+
export function getAccountStatuses(...args) {
|
|
8
7
|
const result = {};
|
|
9
8
|
for (const record of Object.values(ACCOUNT_STATUSES)) {
|
|
10
|
-
result[record.code] = { ...record, label:
|
|
9
|
+
result[record.code] = args.length === 0 ? { ...record } : { ...record, label: locales[args[0]].accountStatuses[record.code] };
|
|
11
10
|
}
|
|
12
11
|
return result;
|
|
13
|
-
}
|
|
12
|
+
}
|
|
14
13
|
/** The catalog as a list, narrowed by the query — see `matchesQuery` for the matching rules. */
|
|
15
14
|
export const queryAccountStatuses = (query) => {
|
|
16
15
|
const { lang, ...criteria } = query;
|
|
@@ -3,18 +3,13 @@ import enLocale from "../locales/en.json";
|
|
|
3
3
|
import esMexLocale from "../locales/es-mex.json";
|
|
4
4
|
import { matchesQuery } from "../../../utils/catalog-query.utils";
|
|
5
5
|
const locales = { en: enLocale, "es-mex": esMexLocale };
|
|
6
|
-
|
|
7
|
-
* The catalog indexed by code (same shape as ACCOUNT_TYPES), each record enriched
|
|
8
|
-
* with its label for the given language. Access by code directly, or Object.values for a list.
|
|
9
|
-
*/
|
|
10
|
-
export const getAccountTypes = (lang) => {
|
|
11
|
-
const locale = locales[lang];
|
|
6
|
+
export function getAccountTypes(...args) {
|
|
12
7
|
const result = {};
|
|
13
8
|
for (const record of Object.values(ACCOUNT_TYPES)) {
|
|
14
|
-
result[record.code] = { ...record, label:
|
|
9
|
+
result[record.code] = args.length === 0 ? { ...record } : { ...record, label: locales[args[0]].accountTypes[record.code] };
|
|
15
10
|
}
|
|
16
11
|
return result;
|
|
17
|
-
}
|
|
12
|
+
}
|
|
18
13
|
/** The catalog as a list, narrowed by the query — see `matchesQuery` for the matching rules. */
|
|
19
14
|
export const queryAccountTypes = (query) => {
|
|
20
15
|
const { lang, ...criteria } = query;
|
|
@@ -3,14 +3,13 @@ import enLocale from "../locales/en.json";
|
|
|
3
3
|
import esMexLocale from "../locales/es-mex.json";
|
|
4
4
|
import { matchesQuery } from "../../utils/catalog-query.utils";
|
|
5
5
|
const locales = { en: enLocale, "es-mex": esMexLocale };
|
|
6
|
-
export
|
|
7
|
-
const locale = locales[lang];
|
|
6
|
+
export function getBlockchains(...args) {
|
|
8
7
|
const result = {};
|
|
9
8
|
for (const record of Object.values(BLOCKCHAINS)) {
|
|
10
|
-
result[record.code] = { ...record, label:
|
|
9
|
+
result[record.code] = args.length === 0 ? { ...record } : { ...record, label: locales[args[0]].blockchains[record.code] };
|
|
11
10
|
}
|
|
12
11
|
return result;
|
|
13
|
-
}
|
|
12
|
+
}
|
|
14
13
|
/** The catalog as a list, narrowed by the query — see `matchesQuery` for the matching rules. */
|
|
15
14
|
export const queryBlockchains = (query) => {
|
|
16
15
|
const { lang, ...criteria } = query;
|
|
@@ -2,11 +2,10 @@ import { NATURES } from "../catalog";
|
|
|
2
2
|
import enLocale from "../locales/en.json";
|
|
3
3
|
import esMexLocale from "../locales/es-mex.json";
|
|
4
4
|
const locales = { en: enLocale, "es-mex": esMexLocale };
|
|
5
|
-
export
|
|
6
|
-
const locale = locales[lang];
|
|
5
|
+
export function getNatures(...args) {
|
|
7
6
|
const result = {};
|
|
8
7
|
for (const record of Object.values(NATURES)) {
|
|
9
|
-
result[record.code] = { ...record, label:
|
|
8
|
+
result[record.code] = args.length === 0 ? { ...record } : { ...record, label: locales[args[0]].natures[record.code] };
|
|
10
9
|
}
|
|
11
10
|
return result;
|
|
12
|
-
}
|
|
11
|
+
}
|
|
@@ -2,11 +2,10 @@ import { PRODUCT_TYPES } from "../catalog";
|
|
|
2
2
|
import enLocale from "../locales/en.json";
|
|
3
3
|
import esMexLocale from "../locales/es-mex.json";
|
|
4
4
|
const locales = { en: enLocale, "es-mex": esMexLocale };
|
|
5
|
-
export
|
|
6
|
-
const locale = locales[lang];
|
|
5
|
+
export function getProductTypes(...args) {
|
|
7
6
|
const result = {};
|
|
8
7
|
for (const record of Object.values(PRODUCT_TYPES)) {
|
|
9
|
-
result[record.code] = { ...record, label:
|
|
8
|
+
result[record.code] = args.length === 0 ? { ...record } : { ...record, label: locales[args[0]].productTypes[record.code] };
|
|
10
9
|
}
|
|
11
10
|
return result;
|
|
12
|
-
}
|
|
11
|
+
}
|
|
@@ -3,14 +3,13 @@ import enLocale from "../locales/en.json";
|
|
|
3
3
|
import esMexLocale from "../locales/es-mex.json";
|
|
4
4
|
import { matchesQuery } from "../../../utils/catalog-query.utils";
|
|
5
5
|
const locales = { en: enLocale, "es-mex": esMexLocale };
|
|
6
|
-
export
|
|
7
|
-
const locale = locales[lang];
|
|
6
|
+
export function getCounterpartyTypes(...args) {
|
|
8
7
|
const result = {};
|
|
9
8
|
for (const record of Object.values(COUNTERPARTY_TYPES)) {
|
|
10
|
-
result[record.code] = { ...record, label:
|
|
9
|
+
result[record.code] = args.length === 0 ? { ...record } : { ...record, label: locales[args[0]].counterpartyTypes[record.code] };
|
|
11
10
|
}
|
|
12
11
|
return result;
|
|
13
|
-
}
|
|
12
|
+
}
|
|
14
13
|
/** The catalog as a list, narrowed by the query — see `matchesQuery` for the matching rules. */
|
|
15
14
|
export const queryCounterpartyTypes = (query) => {
|
|
16
15
|
const { lang, ...criteria } = query;
|
|
@@ -3,14 +3,13 @@ import enLocale from "../locales/en.json";
|
|
|
3
3
|
import esMexLocale from "../locales/es-mex.json";
|
|
4
4
|
import { matchesQuery } from "../../../utils/catalog-query.utils";
|
|
5
5
|
const locales = { en: enLocale, "es-mex": esMexLocale };
|
|
6
|
-
export
|
|
7
|
-
const locale = locales[lang];
|
|
6
|
+
export function getCountries(...args) {
|
|
8
7
|
const result = {};
|
|
9
8
|
for (const record of Object.values(COUNTRIES)) {
|
|
10
|
-
result[record.code] = { ...record, label:
|
|
9
|
+
result[record.code] = args.length === 0 ? { ...record } : { ...record, label: locales[args[0]].countries[record.code] };
|
|
11
10
|
}
|
|
12
11
|
return result;
|
|
13
|
-
}
|
|
12
|
+
}
|
|
14
13
|
/** The catalog as a list, narrowed by the query — see `matchesQuery` for the matching rules. */
|
|
15
14
|
export const queryCountries = (query) => {
|
|
16
15
|
const { lang, ...criteria } = query;
|
|
@@ -5,14 +5,13 @@ import { matchesQuery } from "../../../utils/catalog-query.utils";
|
|
|
5
5
|
const locales = { en: enLocale, "es-mex": esMexLocale };
|
|
6
6
|
const AVAILABLE_FLAG_CODES = new Set(["col", "mex", "usa"]);
|
|
7
7
|
export const hasCountryISOFlag = (code) => AVAILABLE_FLAG_CODES.has(code);
|
|
8
|
-
export
|
|
9
|
-
const locale = locales[lang];
|
|
8
|
+
export function getCountriesISO(...args) {
|
|
10
9
|
const result = {};
|
|
11
10
|
for (const record of Object.values(COUNTRIES_ISO)) {
|
|
12
|
-
result[record.code] = { ...record, label:
|
|
11
|
+
result[record.code] = args.length === 0 ? { ...record } : { ...record, label: locales[args[0]].countriesISO[record.code] };
|
|
13
12
|
}
|
|
14
13
|
return result;
|
|
15
|
-
}
|
|
14
|
+
}
|
|
16
15
|
/** The catalog as a list, narrowed by the query — see `matchesQuery` for the matching rules. */
|
|
17
16
|
export const queryCountriesISO = (query) => {
|
|
18
17
|
const { lang, ...criteria } = query;
|
|
@@ -3,18 +3,14 @@ import enLocale from "../locales/en.json";
|
|
|
3
3
|
import esMexLocale from "../locales/es-mex.json";
|
|
4
4
|
import { matchesQuery } from "../../utils/catalog-query.utils";
|
|
5
5
|
const locales = { en: enLocale, "es-mex": esMexLocale };
|
|
6
|
-
|
|
7
|
-
* Documents indexed by code (definition + label). For the unique list (Object.values),
|
|
8
|
-
* validation ([code].minLength / maxLength / type) and label ([code].label).
|
|
9
|
-
*/
|
|
10
|
-
export const getDocumentTypes = (lang) => {
|
|
11
|
-
const locale = locales[lang];
|
|
6
|
+
export function getDocumentTypes(...args) {
|
|
12
7
|
const result = {};
|
|
13
8
|
for (const { code, minLength, maxLength, type } of Object.values(DOCUMENT_TYPES)) {
|
|
14
|
-
|
|
9
|
+
const validation = { code, minLength, maxLength, type };
|
|
10
|
+
result[code] = args.length === 0 ? validation : { ...validation, label: locales[args[0]].documentTypes[code] };
|
|
15
11
|
}
|
|
16
12
|
return result;
|
|
17
|
-
}
|
|
13
|
+
}
|
|
18
14
|
/** DOCUMENT_TYPES flattened by geo, one row per (code, geo) pair — no label, so it is what gets filtered. */
|
|
19
15
|
const flattenByGeo = () => Object.values(DOCUMENT_TYPES).flatMap(({ geo, ...record }) => {
|
|
20
16
|
const entries = Object.entries(geo);
|
|
@@ -2,11 +2,10 @@ import { FILTER_CLASSIFICATION_CATEGORY_FAMILIES } from "../catalog";
|
|
|
2
2
|
import enLocale from "../locales/en.json";
|
|
3
3
|
import esMexLocale from "../locales/es-mex.json";
|
|
4
4
|
const locales = { en: enLocale, "es-mex": esMexLocale };
|
|
5
|
-
export
|
|
6
|
-
const locale = locales[lang];
|
|
5
|
+
export function getFilterClassificationCategoryFamilies(...args) {
|
|
7
6
|
const result = {};
|
|
8
7
|
for (const record of Object.values(FILTER_CLASSIFICATION_CATEGORY_FAMILIES)) {
|
|
9
|
-
result[record.code] = { ...record, label:
|
|
8
|
+
result[record.code] = args.length === 0 ? { ...record } : { ...record, label: locales[args[0]].categoryFamilies[record.code] };
|
|
10
9
|
}
|
|
11
10
|
return result;
|
|
12
|
-
}
|
|
11
|
+
}
|
|
@@ -2,12 +2,10 @@ import { FILTER_CLASSIFICATION_SECTIONS } from "../catalog";
|
|
|
2
2
|
import enLocale from "../locales/en.json";
|
|
3
3
|
import esMexLocale from "../locales/es-mex.json";
|
|
4
4
|
const locales = { en: enLocale, "es-mex": esMexLocale };
|
|
5
|
-
|
|
6
|
-
export const getFilterClassificationSections = (lang) => {
|
|
7
|
-
const locale = locales[lang];
|
|
5
|
+
export function getFilterClassificationSections(...args) {
|
|
8
6
|
const result = {};
|
|
9
7
|
for (const record of Object.values(FILTER_CLASSIFICATION_SECTIONS)) {
|
|
10
|
-
result[record.code] = { ...record, label:
|
|
8
|
+
result[record.code] = args.length === 0 ? { ...record } : { ...record, label: locales[args[0]].sections[record.code] };
|
|
11
9
|
}
|
|
12
10
|
return result;
|
|
13
|
-
}
|
|
11
|
+
}
|
|
@@ -12,11 +12,15 @@ const buildFinancialInstitutions = (lang) => {
|
|
|
12
12
|
}
|
|
13
13
|
return result;
|
|
14
14
|
};
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
15
|
+
export function getFinancialInstitutions(...args) {
|
|
16
|
+
if (args.length !== 0)
|
|
17
|
+
return buildFinancialInstitutions(args[0]);
|
|
18
|
+
const result = {};
|
|
19
|
+
for (const record of Object.values(FINANCIAL_INSTITUTIONS)) {
|
|
20
|
+
result[record.code] = { ...record };
|
|
21
|
+
}
|
|
22
|
+
return result;
|
|
23
|
+
}
|
|
20
24
|
/** The catalog as a list, narrowed by the query — see `matchesQuery` for the matching rules. */
|
|
21
25
|
export const queryFinancialInstitutions = (query) => {
|
|
22
26
|
const { lang, ...criteria } = query;
|
package/dist/esm/lang/index.js
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
1
|
export const DEFAULT_EN_LOCALE = "en";
|
|
2
2
|
export const DEFAULT_ES_LOCALE = "es-mex";
|
|
3
3
|
export const LOCALES = [DEFAULT_EN_LOCALE, DEFAULT_ES_LOCALE];
|
|
4
|
+
const SUPPORTED_LOCALES = LOCALES;
|
|
5
|
+
/**
|
|
6
|
+
* Narrows any string to a supported `Locale`: an exact member of `LOCALES` passes through, anything else
|
|
7
|
+
* falls back to `DEFAULT_ES_LOCALE`. The active language is not always a library literal (a user preference
|
|
8
|
+
* saved without validation, `en-US` from the browser), and every translated `getX(lang)` / `queryX({ lang })`
|
|
9
|
+
* indexes its messages by the exact string and throws on anything else. Call it once where a pipeline reads
|
|
10
|
+
* the active language, not at every call site.
|
|
11
|
+
*/
|
|
12
|
+
export const toSupportedLocale = (lang) => SUPPORTED_LOCALES.includes(lang) ? lang : DEFAULT_ES_LOCALE;
|
|
@@ -3,14 +3,13 @@ import enLocale from "../locales/en.json";
|
|
|
3
3
|
import esMexLocale from "../locales/es-mex.json";
|
|
4
4
|
import { matchesQuery } from "../../../utils/catalog-query.utils";
|
|
5
5
|
const locales = { en: enLocale, "es-mex": esMexLocale };
|
|
6
|
-
export
|
|
7
|
-
const locale = locales[lang];
|
|
6
|
+
export function getMovementStatuses(...args) {
|
|
8
7
|
const result = {};
|
|
9
8
|
for (const record of Object.values(MOVEMENT_STATUSES)) {
|
|
10
|
-
result[record.code] = { ...record, label:
|
|
9
|
+
result[record.code] = args.length === 0 ? { ...record } : { ...record, label: locales[args[0]].movementStatuses[record.code] };
|
|
11
10
|
}
|
|
12
11
|
return result;
|
|
13
|
-
}
|
|
12
|
+
}
|
|
14
13
|
/**
|
|
15
14
|
* The catalog as a list narrowed by the query, each record enriched with its label for `query.lang`.
|
|
16
15
|
* `code` is the only filterable field — `label` is display text, added after filtering, never a query key.
|
|
@@ -3,14 +3,13 @@ import enLocale from "../locales/en.json";
|
|
|
3
3
|
import esMexLocale from "../locales/es-mex.json";
|
|
4
4
|
import { matchesQuery } from "../../../utils/catalog-query.utils";
|
|
5
5
|
const locales = { en: enLocale, "es-mex": esMexLocale };
|
|
6
|
-
export
|
|
7
|
-
const locale = locales[lang];
|
|
6
|
+
export function getMovementTypes(...args) {
|
|
8
7
|
const result = {};
|
|
9
8
|
for (const record of Object.values(MOVEMENT_TYPES)) {
|
|
10
|
-
result[record.code] = { ...record, label:
|
|
9
|
+
result[record.code] = args.length === 0 ? { ...record } : { ...record, label: locales[args[0]].movementTypes[record.code] };
|
|
11
10
|
}
|
|
12
11
|
return result;
|
|
13
|
-
}
|
|
12
|
+
}
|
|
14
13
|
/**
|
|
15
14
|
* The catalog as a list narrowed by the query, each record enriched with its label for `query.lang`.
|
|
16
15
|
*
|
|
@@ -2,11 +2,10 @@ import { SUBCLIENT_STATUSES } from "../catalog";
|
|
|
2
2
|
import enLocale from "../locales/en.json";
|
|
3
3
|
import esMexLocale from "../locales/es-mex.json";
|
|
4
4
|
const locales = { en: enLocale, "es-mex": esMexLocale };
|
|
5
|
-
export
|
|
6
|
-
const locale = locales[lang];
|
|
5
|
+
export function getSubclientStatuses(...args) {
|
|
7
6
|
const result = {};
|
|
8
7
|
for (const record of Object.values(SUBCLIENT_STATUSES)) {
|
|
9
|
-
result[record.code] = { ...record, label:
|
|
8
|
+
result[record.code] = args.length === 0 ? { ...record } : { ...record, label: locales[args[0]].subclientStatuses[record.code] };
|
|
10
9
|
}
|
|
11
10
|
return result;
|
|
12
|
-
}
|
|
11
|
+
}
|
|
@@ -3,18 +3,13 @@ import enLocale from "../locales/en.json";
|
|
|
3
3
|
import esMexLocale from "../locales/es-mex.json";
|
|
4
4
|
import { matchesQuery } from "../../../utils/catalog-query.utils";
|
|
5
5
|
const locales = { en: enLocale, "es-mex": esMexLocale };
|
|
6
|
-
|
|
7
|
-
* The catalog indexed by code (same shape as TRANSACTION_TYPES), each record enriched
|
|
8
|
-
* with its label for the given language. Access by code directly, or Object.values for a list.
|
|
9
|
-
*/
|
|
10
|
-
export const getTransactionTypes = (lang) => {
|
|
11
|
-
const locale = locales[lang];
|
|
6
|
+
export function getTransactionTypes(...args) {
|
|
12
7
|
const result = {};
|
|
13
8
|
for (const record of Object.values(TRANSACTION_TYPES)) {
|
|
14
|
-
result[record.code] = { ...record, label:
|
|
9
|
+
result[record.code] = args.length === 0 ? { ...record } : { ...record, label: locales[args[0]].transactionTypes[record.code] };
|
|
15
10
|
}
|
|
16
11
|
return result;
|
|
17
|
-
}
|
|
12
|
+
}
|
|
18
13
|
/** The catalog as a list narrowed by the query, each record enriched with its label for `query.lang`. */
|
|
19
14
|
export const queryTransactionTypes = (query) => {
|
|
20
15
|
const { lang, ...filters } = query;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|