@cobre-npm/library-portal-core 0.46.0 → 0.47.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 CHANGED
@@ -164,20 +164,25 @@ one-off predicates even where `queryX()` exists.
164
164
 
165
165
  ```ts
166
166
  import {
167
- getAccountTypes, getAccountProviders, getAccountStatuses, queryAccountStatuses,
168
- type AccountType, type AccountTypeOption,
167
+ getAccountTypes, queryAccountTypes, getAccountProviders, getAccountStatuses, queryAccountStatuses,
168
+ type AccountType, type AccountTypeOption, type AccountTypeQuery,
169
169
  type AccountProvider, type AccountProviderRecord,
170
170
  type AccountStatus, type AccountStatusOption, type AccountStatusQuery,
171
171
  type Account, type AccountResponsePaginated, /* ... interfaces */
172
172
  } from "@cobre-npm/library-portal-core/accounts"
173
173
 
174
174
  getAccountTypes("en") // Record<AccountType, AccountTypeOption> → { ch: { code, geo, label }, ... }
175
+ queryAccountTypes({ lang: "en", geo: "mex" }) // [ clabe, cobre_balance, spei_card ] → MEX-eligible account types
175
176
  getAccountProviders() // Record<AccountProvider, AccountProviderRecord> (no i18n)
176
177
  getAccountStatuses("en").closed // { code: "closed", type: "neutral", label: "Inactive" }
177
178
  queryAccountStatuses({ lang: "en", type: "error" }) // [ disconnected, failed ] → the list a picker needs
178
179
  ```
179
180
 
180
181
  - **types** (i18n): `getAccountTypes(lang)`; each record carries `code`, `geo` (`Country[]`) and `label`.
182
+ `queryAccountTypes({ lang, ... })` returns the same catalog as a **list**, narrowed by `code`/`geo` —
183
+ same matching rules as [`queryAccountStatuses`](#accounts) below: `lang` is required (i18n domain, no
184
+ default) inside the query object, and since `geo` is itself an array field, `{ geo: "mex" }` matches
185
+ "contains any" (so `cobre_balance`, whose `geo` is `["col", "mex"]`, qualifies for either country).
181
186
  - **providers** (no i18n): `getAccountProviders()`.
182
187
  - **status** (i18n): `getAccountStatuses(lang)`; account statuses (`creating`, `connected`, `connecting`,
183
188
  `disconnected`, `failed`, `closed`). `queryAccountStatuses({ lang, ... })` returns the same catalog as a
@@ -1,5 +1,6 @@
1
1
  import type { AccountType, AccountTypeRecord } from "../catalog";
2
2
  import type { Locale } from "../../../lang";
3
+ import type { CatalogQuery } from "../../../utils/catalog-query.utils";
3
4
  export type AccountTypeOption = AccountTypeRecord & {
4
5
  label: string;
5
6
  };
@@ -8,3 +9,9 @@ export type AccountTypeOption = AccountTypeRecord & {
8
9
  * with its label for the given language. Access by code directly, or Object.values for a list.
9
10
  */
10
11
  export declare const getAccountTypes: (lang: Locale) => Record<AccountType, AccountTypeOption>;
12
+ /** `lang` is required (i18n domain, no default) and travels inside the query object, never positional. */
13
+ export type AccountTypeQuery = CatalogQuery<AccountTypeRecord> & {
14
+ lang: Locale;
15
+ };
16
+ /** The catalog as a list, narrowed by the query — see `matchesQuery` for the matching rules. */
17
+ export declare const queryAccountTypes: (query: AccountTypeQuery) => AccountTypeOption[];
@@ -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.getAccountTypes = void 0;
6
+ exports.queryAccountTypes = exports.getAccountTypes = 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
  /**
12
13
  * The catalog indexed by code (same shape as ACCOUNT_TYPES), each record enriched
@@ -21,3 +22,10 @@ const getAccountTypes = (lang) => {
21
22
  return result;
22
23
  };
23
24
  exports.getAccountTypes = getAccountTypes;
25
+ /** The catalog as a list, narrowed by the query — see `matchesQuery` for the matching rules. */
26
+ const queryAccountTypes = (query) => {
27
+ const { lang, ...criteria } = query;
28
+ const types = (0, exports.getAccountTypes)(lang);
29
+ return Object.values(types).filter(type => (0, catalog_query_utils_1.matchesQuery)(type, criteria));
30
+ };
31
+ exports.queryAccountTypes = queryAccountTypes;
@@ -1,6 +1,7 @@
1
1
  import { ACCOUNT_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
  /**
6
7
  * The catalog indexed by code (same shape as ACCOUNT_TYPES), each record enriched
@@ -14,3 +15,9 @@ export const getAccountTypes = (lang) => {
14
15
  }
15
16
  return result;
16
17
  };
18
+ /** The catalog as a list, narrowed by the query — see `matchesQuery` for the matching rules. */
19
+ export const queryAccountTypes = (query) => {
20
+ const { lang, ...criteria } = query;
21
+ const types = getAccountTypes(lang);
22
+ return Object.values(types).filter(type => matchesQuery(type, criteria));
23
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cobre-npm/library-portal-core",
3
- "version": "0.46.0",
3
+ "version": "0.47.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",