@royalinvest/dto 0.69.11 → 0.69.12

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/dist/config.d.ts CHANGED
@@ -1,9 +1,11 @@
1
- import { CountryEnum, CurrencyEnum } from "./enum";
1
+ import { CountryEnum, CurrencyEnum, UILanguage } from "./enum";
2
2
  export type CountryConfig = {
3
3
  defaultCurrency: CurrencyEnum;
4
4
  defaultLocale: string;
5
5
  supportedLocales: string[];
6
- uiLanguages?: Array<"en" | "fr" | "de" | "es" | "nl">;
6
+ uiLanguages?: Array<UILanguage>;
7
7
  };
8
8
  export declare const COUNTRY_CONFIG: Record<CountryEnum, CountryConfig>;
9
9
  export declare const CurrencyMinorUnits: Record<CurrencyEnum, number>;
10
+ export declare const DEFAULT_LOCALE_BY_LANGUAGE: Record<UILanguage, string>;
11
+ export declare const DEFAULT_LOCALE_BY_COUNTRY_AND_LANGUAGE: Record<CountryEnum, Record<string, string>>;
package/dist/config.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CurrencyMinorUnits = exports.COUNTRY_CONFIG = void 0;
3
+ exports.DEFAULT_LOCALE_BY_COUNTRY_AND_LANGUAGE = exports.DEFAULT_LOCALE_BY_LANGUAGE = exports.CurrencyMinorUnits = exports.COUNTRY_CONFIG = void 0;
4
4
  const enum_1 = require("./enum");
5
5
  exports.COUNTRY_CONFIG = {
6
6
  [enum_1.CountryEnum.CA]: {
@@ -59,3 +59,20 @@ exports.CurrencyMinorUnits = {
59
59
  [enum_1.CurrencyEnum.GBP]: 2,
60
60
  [enum_1.CurrencyEnum.AUD]: 2,
61
61
  };
62
+ exports.DEFAULT_LOCALE_BY_LANGUAGE = {
63
+ en: "en-US",
64
+ fr: "fr-FR",
65
+ de: "de-DE",
66
+ es: "es-ES",
67
+ nl: "nl-NL",
68
+ };
69
+ exports.DEFAULT_LOCALE_BY_COUNTRY_AND_LANGUAGE = {
70
+ CA: { en: "en-CA", fr: "fr-CA" },
71
+ US: { en: "en-US" },
72
+ FR: { fr: "fr-FR", en: "en-FR" },
73
+ DE: { de: "de-DE", en: "en-DE" },
74
+ NL: { nl: "nl-NL", en: "en-NL" },
75
+ ES: { es: "es-ES", en: "en-ES" },
76
+ GB: { en: "en-GB" },
77
+ AU: { en: "en-AU" },
78
+ };
@@ -1,5 +1,6 @@
1
1
  export * from "./country";
2
2
  export * from "./currency";
3
+ export * from "./uiLanguage";
3
4
  export declare enum PartyTypeEnum {
4
5
  default = "",
5
6
  lessor = "lessor",
@@ -17,6 +17,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
17
17
  exports.UnitMeasurementEnum = exports.BulkPurchaseSourceTypeEnum = exports.TextAlignmentEnum = exports.LeaseDurationEnum = exports.LeaseTermTypeEnum = exports.LeaseCategoryEnum = exports.LeaseTypeEnum = exports.LeaseNoticeTypeEnum = exports.SignatureDateTypeEnum = exports.SignActionEnum = exports.NotificationTypeEnum = exports.SignStatusEnum = exports.SignatureType = exports.LeaseStatusEnum = exports.RentTypeEnum = exports.PartyTypeEnum = void 0;
18
18
  __exportStar(require("./country"), exports);
19
19
  __exportStar(require("./currency"), exports);
20
+ __exportStar(require("./uiLanguage"), exports);
20
21
  var PartyTypeEnum;
21
22
  (function (PartyTypeEnum) {
22
23
  PartyTypeEnum["default"] = "";
@@ -0,0 +1 @@
1
+ export type UILanguage = "en" | "fr" | "de" | "es" | "nl";
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/dist/utils.d.ts CHANGED
@@ -1,4 +1,5 @@
1
- import { CurrencyEnum } from "./enum";
1
+ import { CountryEnum, CurrencyEnum, UILanguage } from "./enum";
2
2
  export declare function fromMinorUnits(amountMinor: string, currency: CurrencyEnum): number;
3
3
  export declare function fromMinorUnitsExact(amountMinor: string, currency: CurrencyEnum): string;
4
4
  export declare function parseMajorToMinor(value: string, currency: CurrencyEnum): string;
5
+ export declare function resolveLocale(uiLanguage: UILanguage, country?: CountryEnum | null): string;
package/dist/utils.js CHANGED
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.fromMinorUnits = fromMinorUnits;
4
4
  exports.fromMinorUnitsExact = fromMinorUnitsExact;
5
5
  exports.parseMajorToMinor = parseMajorToMinor;
6
+ exports.resolveLocale = resolveLocale;
6
7
  const config_1 = require("./config");
7
8
  // This is going to be used for web app to show amount in minor taking into account units configured for the currency
8
9
  function fromMinorUnits(amountMinor, currency) {
@@ -23,3 +24,13 @@ function parseMajorToMinor(value, currency) {
23
24
  const padded = (d + "0".repeat(decimals)).slice(0, decimals);
24
25
  return `${i}${padded}`;
25
26
  }
27
+ function resolveLocale(uiLanguage, country) {
28
+ if (country) {
29
+ const byCountry = config_1.DEFAULT_LOCALE_BY_COUNTRY_AND_LANGUAGE[country];
30
+ if (byCountry) {
31
+ return byCountry[uiLanguage] ?? Object.values(byCountry)[0];
32
+ }
33
+ }
34
+ // Fallback: language-only default
35
+ return config_1.DEFAULT_LOCALE_BY_LANGUAGE[uiLanguage] ?? "en-US";
36
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@royalinvest/dto",
3
- "version": "0.69.11",
3
+ "version": "0.69.12",
4
4
  "description": "Data Transfer Objects (DTOs) to carry data between frontend and backend processes.",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",