@cobre-npm/library-portal-core 0.34.0 → 0.35.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
@@ -212,13 +212,15 @@ hasCountryISOFlag("col") // true — whether a flag asset is avai
212
212
 
213
213
  ```ts
214
214
  import {
215
- getMovementTypes, type MovementType, type MovementTypeOption,
215
+ getMovementTypes, queryMovementTypes, type MovementType, type MovementTypeGroupLabel,
216
+ type MovementTypeOption, type MovementTypeQuery,
216
217
  getMovementStatuses, type MovementStatus, type MovementStatusRecord,
217
218
  } from "@cobre-npm/library-portal-core/movements"
218
219
 
219
220
  getMovementTypes("en").ach.label // "ACH"
220
221
  getMovementTypes("en").on_ramp.groupLabel // "Stablecoin"
221
222
  getMovementTypes("en").on_ramp.label // "On Ramp" (individual label, unchanged)
223
+ queryMovementTypes({ lang: "en", groupLabel: "Stablecoin" }) // global, off_ramp, on_ramp, stable_payout
222
224
  getMovementStatuses().completed // { code: "completed" } (no i18n)
223
225
  ```
224
226
 
@@ -228,6 +230,15 @@ getMovementStatuses().completed // { code: "completed" }
228
230
  consumer that wants the grouped label picks `groupLabel ?? label`. There's no separate `getXLabel`
229
231
  for this — the value already comes back inside `getMovementTypes()`, same as everything else in this
230
232
  catalog.
233
+ - **types query** (i18n `queryX()`): `queryMovementTypes({ lang, ...filters })` — same rules as
234
+ `queryTransactionTypes`/`queryDocumentTypes`, no default field. `groupLabel` is the only filterable
235
+ field besides `code`, and it's optional on the record: **a key that is present always filters**, so
236
+ `groupLabel: undefined` matches the 19 rails that don't carry a group, not "no filter". An optional UI
237
+ filter has to be spread in conditionally:
238
+
239
+ ```ts
240
+ queryMovementTypes({ lang, ...(group.value ? { groupLabel: group.value } : {}) })
241
+ ```
231
242
  - **status** (no i18n): movement statuses (`initiated`, `processing`, `completed`, …).
232
243
 
233
244
  ### `subclients`
@@ -1,4 +1,4 @@
1
- export type { MovementType } from "./types/catalog";
1
+ export type { MovementType, MovementTypeGroupLabel } from "./types/catalog";
2
2
  export * from "./types/utils/movement-type.utils";
3
3
  export type { MovementStatus, MovementStatusRecord } from "./status/catalog";
4
4
  export * from "./status/utils/movement-status.utils";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/movements/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AACnD,cAAc,mCAAmC,CAAA;AAEjD,YAAY,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAA;AAC5E,cAAc,sCAAsC,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/movements/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,YAAY,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAA;AAC3E,cAAc,mCAAmC,CAAA;AAEjD,YAAY,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAA;AAC5E,cAAc,sCAAsC,CAAA"}
@@ -75,5 +75,7 @@ export declare const MOVEMENT_TYPES: {
75
75
  };
76
76
  };
77
77
  export type MovementType = keyof typeof MOVEMENT_TYPES;
78
- export type MovementTypeRecord = (typeof MOVEMENT_TYPES)[MovementType];
78
+ export type MovementTypeRecord = (typeof MOVEMENT_TYPES)[MovementType] & {
79
+ readonly groupLabel?: MovementTypeGroupLabel;
80
+ };
79
81
  //# sourceMappingURL=catalog.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"catalog.d.ts","sourceRoot":"","sources":["../../../src/movements/types/catalog.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,sBAAsB,GAAG,YAAY,CAAA;AAEjD,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAwB+D,CAAA;AAE1F,MAAM,MAAM,YAAY,GAAG,MAAM,OAAO,cAAc,CAAA;AACtD,MAAM,MAAM,kBAAkB,GAAG,CAAC,OAAO,cAAc,CAAC,CAAC,YAAY,CAAC,CAAA"}
1
+ {"version":3,"file":"catalog.d.ts","sourceRoot":"","sources":["../../../src/movements/types/catalog.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,sBAAsB,GAAG,YAAY,CAAA;AAEjD,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAwB+D,CAAA;AAE1F,MAAM,MAAM,YAAY,GAAG,MAAM,OAAO,cAAc,CAAA;AAMtD,MAAM,MAAM,kBAAkB,GAAG,CAAC,OAAO,cAAc,CAAC,CAAC,YAAY,CAAC,GAAG;IAAE,QAAQ,CAAC,UAAU,CAAC,EAAE,sBAAsB,CAAA;CAAE,CAAA"}
@@ -1,7 +1,20 @@
1
1
  import type { MovementType, MovementTypeRecord } from "../catalog";
2
2
  import type { Locale } from "../../../lang";
3
+ import type { CatalogQuery } from "../../../utils/catalog-query.utils";
3
4
  export type MovementTypeOption = MovementTypeRecord & {
4
5
  label: string;
5
6
  };
6
7
  export declare const getMovementTypes: (lang: Locale) => Record<MovementType, MovementTypeOption>;
8
+ /** i18n domain: `lang` is required, inside the query object — see matchesQuery for the matching rules. */
9
+ export type MovementTypeQuery = CatalogQuery<MovementTypeRecord> & {
10
+ lang: Locale;
11
+ };
12
+ /**
13
+ * The catalog as a list narrowed by the query, each record enriched with its label for `query.lang`.
14
+ *
15
+ * `groupLabel` is optional on the record, so `groupLabel: undefined` is a present key like any other —
16
+ * it matches the 19 records that don't carry a group, not "no filter". A UI filter fed from an optional
17
+ * ref has to be spread in conditionally: `{ lang, ...(group ? { groupLabel: group } : {}) }`.
18
+ */
19
+ export declare const queryMovementTypes: (query: MovementTypeQuery) => MovementTypeOption[];
7
20
  //# sourceMappingURL=movement-type.utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"movement-type.utils.d.ts","sourceRoot":"","sources":["../../../../src/movements/types/utils/movement-type.utils.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AAGlE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AAI3C,MAAM,MAAM,kBAAkB,GAAG,kBAAkB,GAAG;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,CAAA;AAEvE,eAAO,MAAM,gBAAgB,GAAI,MAAM,MAAM,KAAG,MAAM,CAAC,YAAY,EAAE,kBAAkB,CAStF,CAAA"}
1
+ {"version":3,"file":"movement-type.utils.d.ts","sourceRoot":"","sources":["../../../../src/movements/types/utils/movement-type.utils.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AAGlE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AAE3C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAA;AAItE,MAAM,MAAM,kBAAkB,GAAG,kBAAkB,GAAG;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,CAAA;AAEvE,eAAO,MAAM,gBAAgB,GAAI,MAAM,MAAM,KAAG,MAAM,CAAC,YAAY,EAAE,kBAAkB,CAStF,CAAA;AAED,0GAA0G;AAC1G,MAAM,MAAM,iBAAiB,GAAG,YAAY,CAAC,kBAAkB,CAAC,GAAG;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAAA;AAEnF;;;;;;GAMG;AACH,eAAO,MAAM,kBAAkB,GAAI,OAAO,iBAAiB,KAAG,kBAAkB,EAM/E,CAAA"}
@@ -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.getMovementTypes = void 0;
6
+ exports.queryMovementTypes = exports.getMovementTypes = 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 getMovementTypes = (lang) => {
12
13
  const locale = locales[lang];
@@ -17,4 +18,18 @@ const getMovementTypes = (lang) => {
17
18
  return result;
18
19
  };
19
20
  exports.getMovementTypes = getMovementTypes;
21
+ /**
22
+ * The catalog as a list narrowed by the query, each record enriched with its label for `query.lang`.
23
+ *
24
+ * `groupLabel` is optional on the record, so `groupLabel: undefined` is a present key like any other —
25
+ * it matches the 19 records that don't carry a group, not "no filter". A UI filter fed from an optional
26
+ * ref has to be spread in conditionally: `{ lang, ...(group ? { groupLabel: group } : {}) }`.
27
+ */
28
+ const queryMovementTypes = (query) => {
29
+ const { lang, ...filters } = query;
30
+ return Object.values(catalog_1.MOVEMENT_TYPES)
31
+ .filter(record => (0, catalog_query_utils_1.matchesQuery)(record, filters))
32
+ .map(record => ({ ...record, label: locales[lang].movementTypes[record.code] }));
33
+ };
34
+ exports.queryMovementTypes = queryMovementTypes;
20
35
  //# sourceMappingURL=movement-type.utils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"movement-type.utils.js","sourceRoot":"","sources":["../../../../src/movements/types/utils/movement-type.utils.ts"],"names":[],"mappings":";;;;;;AAAA,wCAA2C;AAE3C,iEAAyC;AACzC,yEAAgD;AAGhD,MAAM,OAAO,GAAuC,EAAE,EAAE,EAAE,iBAAQ,EAAE,QAAQ,EAAE,qBAAW,EAAE,CAAA;AAIpF,MAAM,gBAAgB,GAAG,CAAC,IAAY,EAA4C,EAAE;IACzF,MAAM,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAC5B,MAAM,MAAM,GAAG,EAA8C,CAAA;IAE7D,KAAK,MAAM,MAAM,IAAI,MAAM,CAAC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C,CAAC;SAC/C,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,EAAE,GAAG,MAAM,EAAE,KAAK,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAA;AACpF,CAAC,CAAA;AANY,QAAA,kBAAkB,sBAM9B"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cobre-npm/library-portal-core",
3
- "version": "0.34.0",
3
+ "version": "0.35.0",
4
4
  "description": "Shared configurations and resources for Portal MFEs",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",