@cobre-npm/library-portal-core 0.57.0 → 0.58.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 +40 -3
- package/dist/cjs/blockchains/catalog.d.ts +25 -0
- package/dist/cjs/blockchains/catalog.js +12 -0
- package/dist/cjs/blockchains/index.d.ts +2 -0
- package/dist/cjs/blockchains/index.js +17 -0
- package/dist/cjs/blockchains/locales/en.json +11 -0
- package/dist/cjs/blockchains/locales/es-mex.json +11 -0
- package/dist/cjs/blockchains/utils/blockchain.utils.d.ts +13 -0
- package/dist/cjs/blockchains/utils/blockchain.utils.js +27 -0
- package/dist/cjs/canonicalTransactions/index.d.ts +4 -0
- package/dist/cjs/canonicalTransactions/index.js +2 -0
- package/dist/cjs/canonicalTransactions/interfaces/response.interface.d.ts +4 -2
- package/dist/cjs/canonicalTransactions/nature/catalog.d.ts +22 -0
- package/dist/cjs/canonicalTransactions/nature/catalog.js +11 -0
- package/dist/cjs/canonicalTransactions/nature/locales/en.json +10 -0
- package/dist/cjs/canonicalTransactions/nature/locales/es-mex.json +10 -0
- package/dist/cjs/canonicalTransactions/nature/utils/nature.utils.d.ts +6 -0
- package/dist/cjs/canonicalTransactions/nature/utils/nature.utils.js +19 -0
- package/dist/cjs/canonicalTransactions/productType/catalog.d.ts +19 -0
- package/dist/cjs/canonicalTransactions/productType/catalog.js +18 -0
- package/dist/cjs/canonicalTransactions/productType/locales/en.json +9 -0
- package/dist/cjs/canonicalTransactions/productType/locales/es-mex.json +9 -0
- package/dist/cjs/canonicalTransactions/productType/utils/product-type.utils.d.ts +6 -0
- package/dist/cjs/canonicalTransactions/productType/utils/product-type.utils.js +19 -0
- package/dist/esm/blockchains/catalog.js +9 -0
- package/dist/esm/blockchains/index.js +1 -0
- package/dist/esm/blockchains/locales/en.json +11 -0
- package/dist/esm/blockchains/locales/es-mex.json +11 -0
- package/dist/esm/blockchains/utils/blockchain.utils.js +19 -0
- package/dist/esm/canonicalTransactions/index.js +2 -0
- package/dist/esm/canonicalTransactions/nature/catalog.js +8 -0
- package/dist/esm/canonicalTransactions/nature/locales/en.json +10 -0
- package/dist/esm/canonicalTransactions/nature/locales/es-mex.json +10 -0
- package/dist/esm/canonicalTransactions/nature/utils/nature.utils.js +12 -0
- package/dist/esm/canonicalTransactions/productType/catalog.js +15 -0
- package/dist/esm/canonicalTransactions/productType/locales/en.json +9 -0
- package/dist/esm/canonicalTransactions/productType/locales/es-mex.json +9 -0
- package/dist/esm/canonicalTransactions/productType/utils/product-type.utils.js +12 -0
- package/package.json +6 -1
package/README.md
CHANGED
|
@@ -4,6 +4,10 @@ Shared catalogs, configuration and interfaces for Cobre's Portal MFEs (Vue 3 + T
|
|
|
4
4
|
It is a **static data** library (no app runtime): account types, counterparties, countries, currencies,
|
|
5
5
|
movement types, document types, etc., together with their translated labels.
|
|
6
6
|
|
|
7
|
+
The vocabulary these catalogs share with the Portal and the BFF (rail, movement type, line, business category,
|
|
8
|
+
product type, nature, …) is defined in [`GLOSSARY.md`](./GLOSSARY.md); [`GLOSSARY-MAP.md`](./GLOSSARY-MAP.md)
|
|
9
|
+
lists it together with the glossary local to `canonicalTransactions`.
|
|
10
|
+
|
|
7
11
|
- No runtime dependencies (only `devDependencies`).
|
|
8
12
|
- Published compiled to `dist/` (CommonJS + `.d.ts`).
|
|
9
13
|
- Managed with **pnpm**; built with plain `tsc`.
|
|
@@ -43,8 +47,9 @@ import { getCountries } from "@cobre-npm/library-portal-core/countries"
|
|
|
43
47
|
| `@cobre-npm/library-portal-core/subclients` | Subclient statuses + `Subclient`/`SubclientPerson` interfaces |
|
|
44
48
|
| `@cobre-npm/library-portal-core/documentTypes` | Document types (definition + per-country applicability) |
|
|
45
49
|
| `@cobre-npm/library-portal-core/currencies` | Currencies |
|
|
50
|
+
| `@cobre-npm/library-portal-core/blockchains` | Blockchains (chains of the counterparty dropdown) |
|
|
46
51
|
| `@cobre-npm/library-portal-core/transactions` | Transaction types + interfaces |
|
|
47
|
-
| `@cobre-npm/library-portal-core/canonicalTransactions` | Canonical transaction/money-movement detail interfaces |
|
|
52
|
+
| `@cobre-npm/library-portal-core/canonicalTransactions` | Canonical transaction/money-movement detail interfaces + product type and nature catalogs |
|
|
48
53
|
| `@cobre-npm/library-portal-core/search` | Search / aggregation interfaces |
|
|
49
54
|
| `@cobre-npm/library-portal-core/filterClassification` | Grouped type-filter vocabulary (families, sections, categories), `splitTypeLabel`, group-selection helpers |
|
|
50
55
|
| `@cobre-npm/library-portal-core/trustedSessions` | Trusted session (OTP elevation window) interfaces + constants |
|
|
@@ -145,7 +150,7 @@ one-off predicates even where `queryX()` exists.
|
|
|
145
150
|
|
|
146
151
|
| Class | When | Signature | Examples |
|
|
147
152
|
|---|---|---|---|
|
|
148
|
-
| **With i18n** | the label depends on the language | `getX(lang)` | accountTypes, counterpartyTypes, movementTypes, transactionTypes, countries, countriesISO, documentTypes |
|
|
153
|
+
| **With i18n** | the label depends on the language | `getX(lang)` | accountTypes, counterpartyTypes, movementTypes, transactionTypes, countries, countriesISO, documentTypes, blockchains, productTypes, natures |
|
|
149
154
|
| **Without i18n** | the label is fixed (or there is none) | `getX()` | currencies (inline label), accountProviders |
|
|
150
155
|
|
|
151
156
|
`currencies`/`providers` **don't take `lang`** because there's no translation — the signature is honest.
|
|
@@ -567,9 +572,30 @@ caller stop attaching an `otp_token` per request while the window is active.
|
|
|
567
572
|
`constants/trustedSessions.constants.ts` — the pattern for a domain that needs standalone constants
|
|
568
573
|
(no catalog, no i18n): a `constants/<domain>.constants.ts` file, re-exported from the barrel.
|
|
569
574
|
|
|
575
|
+
### `blockchains`
|
|
576
|
+
|
|
577
|
+
```ts
|
|
578
|
+
import {
|
|
579
|
+
getBlockchains, queryBlockchains,
|
|
580
|
+
type Blockchain, type BlockchainOption, type BlockchainQuery,
|
|
581
|
+
} from "@cobre-npm/library-portal-core/blockchains"
|
|
582
|
+
|
|
583
|
+
getBlockchains("en").stellar.label // "Stellar" → point lookup of a chain code
|
|
584
|
+
queryBlockchains({ lang: "en" }) // the 7 chains as a list → dropdowns
|
|
585
|
+
queryBlockchains({ lang: "en", code: ["tron", "base"] }) // [ tron, base ]
|
|
586
|
+
```
|
|
587
|
+
|
|
588
|
+
- Single i18n catalog (`code` + `label`), 7 chains: `ethereum`, `tron`, `solana`, `polygon`, `base`, `xrpl`, `stellar`.
|
|
589
|
+
Labels are proper names, so `en` and `es-mex` match today.
|
|
590
|
+
- No logo field: the logo is a presentation concern of the consumer (Portal derives it from `code`).
|
|
591
|
+
- `counterparty_chain` / `chain` stay `string` in the counterparties and accounts interfaces — a `string` from
|
|
592
|
+
the backend may not be a `Blockchain`, so consumers narrow it themselves before indexing `getBlockchains()`.
|
|
593
|
+
- No visibility field, so `queryBlockchains({ lang })` returns all 7 (same rule as every `queryX()`: a key that is
|
|
594
|
+
present always filters, so `{ code: undefined }` returns `[]`).
|
|
595
|
+
|
|
570
596
|
### `canonicalTransactions`
|
|
571
597
|
|
|
572
|
-
Interfaces
|
|
598
|
+
Interfaces plus two small i18n catalogs (`productType`, `nature`). The interfaces are the single source of truth for the canonical money-movement /
|
|
573
599
|
transaction detail — built by `core-portal-bff`'s transaction-canonical BFF, consumed as-is by the
|
|
574
600
|
`portal` MFE (`CanonicalMoneyMovement`), and narrowed with `Pick` by the receipts-generation service:
|
|
575
601
|
|
|
@@ -591,6 +617,17 @@ import type {
|
|
|
591
617
|
consumers (`portal`, `core-portal-bff`, `util-portal-receipts`) — see `ICanonicalApprovalEvent`'s
|
|
592
618
|
doc comment for one case that's a superset of two non-overlapping shapes rather than a clean merge,
|
|
593
619
|
and revisit it once the real payload is confirmed.
|
|
620
|
+
- **productType / nature** (i18n): `getProductTypes(lang)` / `getNatures(lang)` cover the 5 `product_type` and 6
|
|
621
|
+
`nature` values of the BFF's `rail-mapper.interface.ts` (the source of truth), and `CanonicalProductType` /
|
|
622
|
+
`CanonicalNature` are derived from them — `conversion`, `on_ramp` and `off_ramp` used to be missing. `en` labels
|
|
623
|
+
are the humanized code in Title Case (`on_ramp` → "On Ramp"); `es-mex` labels are Design's copy (`payout` →
|
|
624
|
+
"Transferencia", `payin` → "Depósito", `cross_border` → "Internacional", `payment` → "Pago", `collection` →
|
|
625
|
+
"Recaudo", `return` → "Reversión", `on_ramp` → "Conversión a stablecoin", `off_ramp` → "Conversión a moneda
|
|
626
|
+
local"). Only `getX()` for now (no `queryX()`).
|
|
627
|
+
They are not duplicates of `businessLines` or `movements/types`: `product_type` is the BFF's per-transaction class
|
|
628
|
+
and flips with the ledger direction (`payin` ↔ `payout`), whereas a `BusinessLine` is fixed per movement type;
|
|
629
|
+
the value sets differ (`internal_transfer`, `conversion` vs `cbmm`, `stable`, `unclassified`) and
|
|
630
|
+
`movements/types` has 26 rail codes, not 5 classes. The only shared label is `cross_border`.
|
|
594
631
|
|
|
595
632
|
### `exports`
|
|
596
633
|
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export declare const BLOCKCHAINS: {
|
|
2
|
+
readonly ethereum: {
|
|
3
|
+
readonly code: "ethereum";
|
|
4
|
+
};
|
|
5
|
+
readonly tron: {
|
|
6
|
+
readonly code: "tron";
|
|
7
|
+
};
|
|
8
|
+
readonly solana: {
|
|
9
|
+
readonly code: "solana";
|
|
10
|
+
};
|
|
11
|
+
readonly polygon: {
|
|
12
|
+
readonly code: "polygon";
|
|
13
|
+
};
|
|
14
|
+
readonly base: {
|
|
15
|
+
readonly code: "base";
|
|
16
|
+
};
|
|
17
|
+
readonly xrpl: {
|
|
18
|
+
readonly code: "xrpl";
|
|
19
|
+
};
|
|
20
|
+
readonly stellar: {
|
|
21
|
+
readonly code: "stellar";
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
export type Blockchain = keyof typeof BLOCKCHAINS;
|
|
25
|
+
export type BlockchainRecord = (typeof BLOCKCHAINS)[Blockchain];
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BLOCKCHAINS = void 0;
|
|
4
|
+
exports.BLOCKCHAINS = {
|
|
5
|
+
ethereum: { code: "ethereum" },
|
|
6
|
+
tron: { code: "tron" },
|
|
7
|
+
solana: { code: "solana" },
|
|
8
|
+
polygon: { code: "polygon" },
|
|
9
|
+
base: { code: "base" },
|
|
10
|
+
xrpl: { code: "xrpl" },
|
|
11
|
+
stellar: { code: "stellar" },
|
|
12
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./utils/blockchain.utils"), exports);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Blockchain, BlockchainRecord } from "../catalog";
|
|
2
|
+
import type { Locale } from "../../lang";
|
|
3
|
+
import type { CatalogQuery } from "../../utils/catalog-query.utils";
|
|
4
|
+
export type BlockchainOption = BlockchainRecord & {
|
|
5
|
+
label: string;
|
|
6
|
+
};
|
|
7
|
+
export declare const getBlockchains: (lang: Locale) => Record<Blockchain, BlockchainOption>;
|
|
8
|
+
/** `lang` is required (i18n domain, no default) and travels inside the query object, never positional. */
|
|
9
|
+
export type BlockchainQuery = CatalogQuery<BlockchainRecord> & {
|
|
10
|
+
lang: Locale;
|
|
11
|
+
};
|
|
12
|
+
/** The catalog as a list, narrowed by the query — see `matchesQuery` for the matching rules. */
|
|
13
|
+
export declare const queryBlockchains: (query: BlockchainQuery) => BlockchainOption[];
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.queryBlockchains = exports.getBlockchains = void 0;
|
|
7
|
+
const catalog_1 = require("../catalog");
|
|
8
|
+
const en_json_1 = __importDefault(require("../locales/en.json"));
|
|
9
|
+
const es_mex_json_1 = __importDefault(require("../locales/es-mex.json"));
|
|
10
|
+
const catalog_query_utils_1 = require("../../utils/catalog-query.utils");
|
|
11
|
+
const locales = { en: en_json_1.default, "es-mex": es_mex_json_1.default };
|
|
12
|
+
const getBlockchains = (lang) => {
|
|
13
|
+
const locale = locales[lang];
|
|
14
|
+
const result = {};
|
|
15
|
+
for (const record of Object.values(catalog_1.BLOCKCHAINS)) {
|
|
16
|
+
result[record.code] = { ...record, label: locale.blockchains[record.code] };
|
|
17
|
+
}
|
|
18
|
+
return result;
|
|
19
|
+
};
|
|
20
|
+
exports.getBlockchains = getBlockchains;
|
|
21
|
+
/** The catalog as a list, narrowed by the query — see `matchesQuery` for the matching rules. */
|
|
22
|
+
const queryBlockchains = (query) => {
|
|
23
|
+
const { lang, ...criteria } = query;
|
|
24
|
+
const blockchains = (0, exports.getBlockchains)(lang);
|
|
25
|
+
return Object.values(blockchains).filter(blockchain => (0, catalog_query_utils_1.matchesQuery)(blockchain, criteria));
|
|
26
|
+
};
|
|
27
|
+
exports.queryBlockchains = queryBlockchains;
|
|
@@ -1,2 +1,6 @@
|
|
|
1
1
|
export * from "./interfaces/response.interface";
|
|
2
2
|
export * from "./interfaces/request.interface";
|
|
3
|
+
export type { ProductType } from "./productType/catalog";
|
|
4
|
+
export * from "./productType/utils/product-type.utils";
|
|
5
|
+
export type { Nature } from "./nature/catalog";
|
|
6
|
+
export * from "./nature/utils/nature.utils";
|
|
@@ -16,3 +16,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./interfaces/response.interface"), exports);
|
|
18
18
|
__exportStar(require("./interfaces/request.interface"), exports);
|
|
19
|
+
__exportStar(require("./productType/utils/product-type.utils"), exports);
|
|
20
|
+
__exportStar(require("./nature/utils/nature.utils"), exports);
|
|
@@ -3,9 +3,11 @@ import type { CounterpartyType } from "../../counterparties/types/catalog";
|
|
|
3
3
|
import type { Currency } from "../../currencies/catalog";
|
|
4
4
|
import type { DocumentType } from "../../documentTypes/catalog";
|
|
5
5
|
import type { MovementStatus } from "../../movements/status/catalog";
|
|
6
|
+
import type { Nature } from "../nature/catalog";
|
|
7
|
+
import type { ProductType } from "../productType/catalog";
|
|
6
8
|
export type CanonicalDirection = "credit" | "debit";
|
|
7
|
-
export type CanonicalProductType =
|
|
8
|
-
export type CanonicalNature =
|
|
9
|
+
export type CanonicalProductType = ProductType;
|
|
10
|
+
export type CanonicalNature = Nature;
|
|
9
11
|
export type CanonicalStatusPresentationType = "status-pending" | "info" | "success" | "error" | "neutral" | "warning";
|
|
10
12
|
export type CanonicalAlertType = "danger" | "success" | "warning" | "info";
|
|
11
13
|
export type CanonicalAlertActionType = "open_drawer" | "copy_to_clipboard";
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export declare const NATURES: {
|
|
2
|
+
readonly payment: {
|
|
3
|
+
readonly code: "payment";
|
|
4
|
+
};
|
|
5
|
+
readonly collection: {
|
|
6
|
+
readonly code: "collection";
|
|
7
|
+
};
|
|
8
|
+
readonly return: {
|
|
9
|
+
readonly code: "return";
|
|
10
|
+
};
|
|
11
|
+
readonly fx_conversion: {
|
|
12
|
+
readonly code: "fx_conversion";
|
|
13
|
+
};
|
|
14
|
+
readonly on_ramp: {
|
|
15
|
+
readonly code: "on_ramp";
|
|
16
|
+
};
|
|
17
|
+
readonly off_ramp: {
|
|
18
|
+
readonly code: "off_ramp";
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
export type Nature = keyof typeof NATURES;
|
|
22
|
+
export type NatureRecord = (typeof NATURES)[Nature];
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NATURES = void 0;
|
|
4
|
+
exports.NATURES = {
|
|
5
|
+
payment: { code: "payment" },
|
|
6
|
+
collection: { code: "collection" },
|
|
7
|
+
return: { code: "return" },
|
|
8
|
+
fx_conversion: { code: "fx_conversion" },
|
|
9
|
+
on_ramp: { code: "on_ramp" },
|
|
10
|
+
off_ramp: { code: "off_ramp" },
|
|
11
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.getNatures = void 0;
|
|
7
|
+
const catalog_1 = require("../catalog");
|
|
8
|
+
const en_json_1 = __importDefault(require("../locales/en.json"));
|
|
9
|
+
const es_mex_json_1 = __importDefault(require("../locales/es-mex.json"));
|
|
10
|
+
const locales = { en: en_json_1.default, "es-mex": es_mex_json_1.default };
|
|
11
|
+
const getNatures = (lang) => {
|
|
12
|
+
const locale = locales[lang];
|
|
13
|
+
const result = {};
|
|
14
|
+
for (const record of Object.values(catalog_1.NATURES)) {
|
|
15
|
+
result[record.code] = { ...record, label: locale.natures[record.code] };
|
|
16
|
+
}
|
|
17
|
+
return result;
|
|
18
|
+
};
|
|
19
|
+
exports.getNatures = getNatures;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export declare const PRODUCT_TYPES: {
|
|
2
|
+
readonly payout: {
|
|
3
|
+
readonly code: "payout";
|
|
4
|
+
};
|
|
5
|
+
readonly payin: {
|
|
6
|
+
readonly code: "payin";
|
|
7
|
+
};
|
|
8
|
+
readonly internal_transfer: {
|
|
9
|
+
readonly code: "internal_transfer";
|
|
10
|
+
};
|
|
11
|
+
readonly cross_border: {
|
|
12
|
+
readonly code: "cross_border";
|
|
13
|
+
};
|
|
14
|
+
readonly conversion: {
|
|
15
|
+
readonly code: "conversion";
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
export type ProductType = keyof typeof PRODUCT_TYPES;
|
|
19
|
+
export type ProductTypeRecord = (typeof PRODUCT_TYPES)[ProductType];
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PRODUCT_TYPES = void 0;
|
|
4
|
+
/*
|
|
5
|
+
The BFF's `classification.product_type` (core-portal-bff `rail-mapper.interface.ts`). Not a BusinessLine and not
|
|
6
|
+
a MovementType, even though `payin`/`payout` share a name with the former:
|
|
7
|
+
- It is assigned per rail and flips with the ledger direction (a debit `payin` becomes `payout` and a credit
|
|
8
|
+
`payout` becomes `payin`), while a BusinessLine is a fixed property of each movement type.
|
|
9
|
+
- It has values a BusinessLine lacks (`internal_transfer`, `conversion`, `cross_border`) and vice versa
|
|
10
|
+
(`cbmm`, `stable`, `unclassified`), and it needs labels, which `businessLines` does not have.
|
|
11
|
+
*/
|
|
12
|
+
exports.PRODUCT_TYPES = {
|
|
13
|
+
payout: { code: "payout" },
|
|
14
|
+
payin: { code: "payin" },
|
|
15
|
+
internal_transfer: { code: "internal_transfer" },
|
|
16
|
+
cross_border: { code: "cross_border" },
|
|
17
|
+
conversion: { code: "conversion" },
|
|
18
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { ProductType, ProductTypeRecord } from "../catalog";
|
|
2
|
+
import type { Locale } from "../../../lang";
|
|
3
|
+
export type ProductTypeOption = ProductTypeRecord & {
|
|
4
|
+
label: string;
|
|
5
|
+
};
|
|
6
|
+
export declare const getProductTypes: (lang: Locale) => Record<ProductType, ProductTypeOption>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.getProductTypes = void 0;
|
|
7
|
+
const catalog_1 = require("../catalog");
|
|
8
|
+
const en_json_1 = __importDefault(require("../locales/en.json"));
|
|
9
|
+
const es_mex_json_1 = __importDefault(require("../locales/es-mex.json"));
|
|
10
|
+
const locales = { en: en_json_1.default, "es-mex": es_mex_json_1.default };
|
|
11
|
+
const getProductTypes = (lang) => {
|
|
12
|
+
const locale = locales[lang];
|
|
13
|
+
const result = {};
|
|
14
|
+
for (const record of Object.values(catalog_1.PRODUCT_TYPES)) {
|
|
15
|
+
result[record.code] = { ...record, label: locale.productTypes[record.code] };
|
|
16
|
+
}
|
|
17
|
+
return result;
|
|
18
|
+
};
|
|
19
|
+
exports.getProductTypes = getProductTypes;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./utils/blockchain.utils";
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { BLOCKCHAINS } from "../catalog";
|
|
2
|
+
import enLocale from "../locales/en.json";
|
|
3
|
+
import esMexLocale from "../locales/es-mex.json";
|
|
4
|
+
import { matchesQuery } from "../../utils/catalog-query.utils";
|
|
5
|
+
const locales = { en: enLocale, "es-mex": esMexLocale };
|
|
6
|
+
export const getBlockchains = (lang) => {
|
|
7
|
+
const locale = locales[lang];
|
|
8
|
+
const result = {};
|
|
9
|
+
for (const record of Object.values(BLOCKCHAINS)) {
|
|
10
|
+
result[record.code] = { ...record, label: locale.blockchains[record.code] };
|
|
11
|
+
}
|
|
12
|
+
return result;
|
|
13
|
+
};
|
|
14
|
+
/** The catalog as a list, narrowed by the query — see `matchesQuery` for the matching rules. */
|
|
15
|
+
export const queryBlockchains = (query) => {
|
|
16
|
+
const { lang, ...criteria } = query;
|
|
17
|
+
const blockchains = getBlockchains(lang);
|
|
18
|
+
return Object.values(blockchains).filter(blockchain => matchesQuery(blockchain, criteria));
|
|
19
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { NATURES } from "../catalog";
|
|
2
|
+
import enLocale from "../locales/en.json";
|
|
3
|
+
import esMexLocale from "../locales/es-mex.json";
|
|
4
|
+
const locales = { en: enLocale, "es-mex": esMexLocale };
|
|
5
|
+
export const getNatures = (lang) => {
|
|
6
|
+
const locale = locales[lang];
|
|
7
|
+
const result = {};
|
|
8
|
+
for (const record of Object.values(NATURES)) {
|
|
9
|
+
result[record.code] = { ...record, label: locale.natures[record.code] };
|
|
10
|
+
}
|
|
11
|
+
return result;
|
|
12
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/*
|
|
2
|
+
The BFF's `classification.product_type` (core-portal-bff `rail-mapper.interface.ts`). Not a BusinessLine and not
|
|
3
|
+
a MovementType, even though `payin`/`payout` share a name with the former:
|
|
4
|
+
- It is assigned per rail and flips with the ledger direction (a debit `payin` becomes `payout` and a credit
|
|
5
|
+
`payout` becomes `payin`), while a BusinessLine is a fixed property of each movement type.
|
|
6
|
+
- It has values a BusinessLine lacks (`internal_transfer`, `conversion`, `cross_border`) and vice versa
|
|
7
|
+
(`cbmm`, `stable`, `unclassified`), and it needs labels, which `businessLines` does not have.
|
|
8
|
+
*/
|
|
9
|
+
export const PRODUCT_TYPES = {
|
|
10
|
+
payout: { code: "payout" },
|
|
11
|
+
payin: { code: "payin" },
|
|
12
|
+
internal_transfer: { code: "internal_transfer" },
|
|
13
|
+
cross_border: { code: "cross_border" },
|
|
14
|
+
conversion: { code: "conversion" },
|
|
15
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { PRODUCT_TYPES } from "../catalog";
|
|
2
|
+
import enLocale from "../locales/en.json";
|
|
3
|
+
import esMexLocale from "../locales/es-mex.json";
|
|
4
|
+
const locales = { en: enLocale, "es-mex": esMexLocale };
|
|
5
|
+
export const getProductTypes = (lang) => {
|
|
6
|
+
const locale = locales[lang];
|
|
7
|
+
const result = {};
|
|
8
|
+
for (const record of Object.values(PRODUCT_TYPES)) {
|
|
9
|
+
result[record.code] = { ...record, label: locale.productTypes[record.code] };
|
|
10
|
+
}
|
|
11
|
+
return result;
|
|
12
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cobre-npm/library-portal-core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.58.0",
|
|
4
4
|
"description": "Shared configurations and resources for Portal MFEs",
|
|
5
5
|
"main": "./dist/cjs/index.js",
|
|
6
6
|
"module": "./dist/esm/index.js",
|
|
@@ -56,6 +56,11 @@
|
|
|
56
56
|
"import": "./dist/esm/transactions/index.js",
|
|
57
57
|
"require": "./dist/cjs/transactions/index.js"
|
|
58
58
|
},
|
|
59
|
+
"./blockchains": {
|
|
60
|
+
"types": "./dist/cjs/blockchains/index.d.ts",
|
|
61
|
+
"import": "./dist/esm/blockchains/index.js",
|
|
62
|
+
"require": "./dist/cjs/blockchains/index.js"
|
|
63
|
+
},
|
|
59
64
|
"./canonicalTransactions": {
|
|
60
65
|
"types": "./dist/cjs/canonicalTransactions/index.d.ts",
|
|
61
66
|
"import": "./dist/esm/canonicalTransactions/index.js",
|