@lyxa.ai/core 1.1.31-alpha.1 → 1.1.31-alpha.2

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.
@@ -22,7 +22,7 @@ Perfect for sharing types between frontend and backend applications.
22
22
 
23
23
  ## Version
24
24
 
25
- Version: 1.1.31-alpha.1
25
+ Version: 1.1.31-alpha.2
26
26
 
27
27
  ## Dependencies
28
28
 
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lyxa.ai/types",
3
- "version": "1.1.31-alpha.1",
3
+ "version": "1.1.31-alpha.2",
4
4
  "description": "Lyxa type definitions and validation schemas for both frontend and backend",
5
5
  "author": "elie <42282499+Internalizable@users.noreply.github.com>",
6
6
  "license": "MIT",
@@ -7,11 +7,10 @@ const roundCurrencySync = (amount, roundingFactor) => {
7
7
  if (typeof amount !== 'number' ||
8
8
  isNaN(amount) ||
9
9
  typeof roundingFactor !== 'number' ||
10
- roundingFactor <= 0) {
10
+ roundingFactor <= 0 ||
11
+ amount === 0) {
11
12
  return 0;
12
13
  }
13
- if (amount === 0)
14
- return 0;
15
14
  const decimals = (roundingFactor.toString().split('.')[1] || '').length;
16
15
  const rounded = Math.round(amount / roundingFactor) * roundingFactor;
17
16
  return Number(rounded.toFixed(decimals));
@@ -1 +1 @@
1
- {"version":3,"file":"currency.js","sourceRoot":"/","sources":["utilities/shared/currency.ts"],"names":[],"mappings":";;;AACa,QAAA,mBAAmB,GAAG,IAAI,CAAC;AAC3B,QAAA,wBAAwB,GAAG,IAAI,CAAC;AAGtC,MAAM,iBAAiB,GAAG,CAAC,MAAc,EAAE,cAAsB,EAAU,EAAE;IACnF,IACC,OAAO,MAAM,KAAK,QAAQ;QAC1B,KAAK,CAAC,MAAM,CAAC;QACb,OAAO,cAAc,KAAK,QAAQ;QAClC,cAAc,IAAI,CAAC,EAClB,CAAC;QACF,OAAO,CAAC,CAAC;IACV,CAAC;IAED,IAAI,MAAM,KAAK,CAAC;QAAE,OAAO,CAAC,CAAC;IAE3B,MAAM,QAAQ,GAAG,CAAC,cAAc,CAAC,QAAQ,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC;IACxE,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,cAAc,CAAC,GAAG,cAAc,CAAC;IAErE,OAAO,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC;AAC1C,CAAC,CAAC;AAhBW,QAAA,iBAAiB,qBAgB5B;AAGK,MAAM,iBAAiB,GAAG,CAAC,MAAc,EAAU,EAAE;IAC3D,OAAO,IAAA,yBAAiB,EAAC,MAAM,EAAE,2BAAmB,CAAC,CAAC;AACvD,CAAC,CAAC;AAFW,QAAA,iBAAiB,qBAE5B;AAEK,MAAM,sBAAsB,GAAG,CAAC,MAAc,EAAU,EAAE;IAChE,OAAO,IAAA,yBAAiB,EAAC,MAAM,EAAE,gCAAwB,CAAC,CAAC;AAC5D,CAAC,CAAC;AAFW,QAAA,sBAAsB,0BAEjC;AAGK,MAAM,sBAAsB,GAAG,CAAC,MAAc,EAAE,YAAoB,EAAU,EAAE;IACtF,IACC,OAAO,MAAM,KAAK,QAAQ;QAC1B,KAAK,CAAC,MAAM,CAAC;QACb,OAAO,YAAY,KAAK,QAAQ;QAChC,KAAK,CAAC,YAAY,CAAC,EAClB,CAAC;QACF,OAAO,CAAC,CAAC;IACV,CAAC;IAED,OAAO,IAAA,8BAAsB,EAAC,MAAM,GAAG,YAAY,CAAC,CAAC;AACtD,CAAC,CAAC;AAXW,QAAA,sBAAsB,0BAWjC","sourcesContent":["// === Currency Rounding Constants ===\nexport const BaseCurrencyRoundTo = 0.01;\nexport const SecondaryCurrencyRoundTo = 1000;\n\n// === Safely rounds a number to the nearest rounding unit ===\nexport const roundCurrencySync = (amount: number, roundingFactor: number): number => {\n\tif (\n\t\ttypeof amount !== 'number' ||\n\t\tisNaN(amount) ||\n\t\ttypeof roundingFactor !== 'number' ||\n\t\troundingFactor <= 0\n\t) {\n\t\treturn 0;\n\t}\n\n\tif (amount === 0) return 0;\n\n\tconst decimals = (roundingFactor.toString().split('.')[1] || '').length;\n\tconst rounded = Math.round(amount / roundingFactor) * roundingFactor;\n\n\treturn Number(rounded.toFixed(decimals));\n};\n\n// === Specific rounding functions for base and secondary currencies ===\nexport const roundBaseCurrency = (amount: number): number => {\n\treturn roundCurrencySync(amount, BaseCurrencyRoundTo);\n};\n\nexport const roundSecondaryCurrency = (amount: number): number => {\n\treturn roundCurrencySync(amount, SecondaryCurrencyRoundTo);\n};\n\n// === Converts a price from base currency to secondary currency using the provided exchange rate and rounds it ===\nexport const convertToSecondarySync = (amount: number, exchangeRate: number): number => {\n\tif (\n\t\ttypeof amount !== 'number' ||\n\t\tisNaN(amount) ||\n\t\ttypeof exchangeRate !== 'number' ||\n\t\tisNaN(exchangeRate)\n\t) {\n\t\treturn 0;\n\t}\n\n\treturn roundSecondaryCurrency(amount * exchangeRate);\n};\n"]}
1
+ {"version":3,"file":"currency.js","sourceRoot":"/","sources":["utilities/shared/currency.ts"],"names":[],"mappings":";;;AACa,QAAA,mBAAmB,GAAG,IAAI,CAAC;AAC3B,QAAA,wBAAwB,GAAG,IAAI,CAAC;AAGtC,MAAM,iBAAiB,GAAG,CAAC,MAAc,EAAE,cAAsB,EAAU,EAAE;IACnF,IACC,OAAO,MAAM,KAAK,QAAQ;QAC1B,KAAK,CAAC,MAAM,CAAC;QACb,OAAO,cAAc,KAAK,QAAQ;QAClC,cAAc,IAAI,CAAC;QACnB,MAAM,KAAK,CAAC,EACX,CAAC;QACF,OAAO,CAAC,CAAC;IACV,CAAC;IAED,MAAM,QAAQ,GAAG,CAAC,cAAc,CAAC,QAAQ,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC;IACxE,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,cAAc,CAAC,GAAG,cAAc,CAAC;IAErE,OAAO,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC;AAC1C,CAAC,CAAC;AAfW,QAAA,iBAAiB,qBAe5B;AAGK,MAAM,iBAAiB,GAAG,CAAC,MAAc,EAAU,EAAE;IAC3D,OAAO,IAAA,yBAAiB,EAAC,MAAM,EAAE,2BAAmB,CAAC,CAAC;AACvD,CAAC,CAAC;AAFW,QAAA,iBAAiB,qBAE5B;AAEK,MAAM,sBAAsB,GAAG,CAAC,MAAc,EAAU,EAAE;IAChE,OAAO,IAAA,yBAAiB,EAAC,MAAM,EAAE,gCAAwB,CAAC,CAAC;AAC5D,CAAC,CAAC;AAFW,QAAA,sBAAsB,0BAEjC;AAGK,MAAM,sBAAsB,GAAG,CAAC,MAAc,EAAE,YAAoB,EAAU,EAAE;IACtF,IACC,OAAO,MAAM,KAAK,QAAQ;QAC1B,KAAK,CAAC,MAAM,CAAC;QACb,OAAO,YAAY,KAAK,QAAQ;QAChC,KAAK,CAAC,YAAY,CAAC,EAClB,CAAC;QACF,OAAO,CAAC,CAAC;IACV,CAAC;IAED,OAAO,IAAA,8BAAsB,EAAC,MAAM,GAAG,YAAY,CAAC,CAAC;AACtD,CAAC,CAAC;AAXW,QAAA,sBAAsB,0BAWjC","sourcesContent":["// === Currency Rounding Constants ===\nexport const BaseCurrencyRoundTo = 0.01;\nexport const SecondaryCurrencyRoundTo = 1000;\n\n// === Safely rounds a number to the nearest rounding unit ===\nexport const roundCurrencySync = (amount: number, roundingFactor: number): number => {\n\tif (\n\t\ttypeof amount !== 'number' ||\n\t\tisNaN(amount) ||\n\t\ttypeof roundingFactor !== 'number' ||\n\t\troundingFactor <= 0 ||\n\t\tamount === 0\n\t) {\n\t\treturn 0;\n\t}\n\n\tconst decimals = (roundingFactor.toString().split('.')[1] || '').length;\n\tconst rounded = Math.round(amount / roundingFactor) * roundingFactor;\n\n\treturn Number(rounded.toFixed(decimals));\n};\n\n// === Specific rounding functions for base and secondary currencies ===\nexport const roundBaseCurrency = (amount: number): number => {\n\treturn roundCurrencySync(amount, BaseCurrencyRoundTo);\n};\n\nexport const roundSecondaryCurrency = (amount: number): number => {\n\treturn roundCurrencySync(amount, SecondaryCurrencyRoundTo);\n};\n\n// === Converts a price from base currency to secondary currency using the provided exchange rate and rounds it ===\nexport const convertToSecondarySync = (amount: number, exchangeRate: number): number => {\n\tif (\n\t\ttypeof amount !== 'number' ||\n\t\tisNaN(amount) ||\n\t\ttypeof exchangeRate !== 'number' ||\n\t\tisNaN(exchangeRate)\n\t) {\n\t\treturn 0;\n\t}\n\n\treturn roundSecondaryCurrency(amount * exchangeRate);\n};\n"]}
@@ -8,10 +8,21 @@ const getSecondaryCurrencyStage = ({ valuePath, exchangeRate, }) => {
8
8
  { $ifNull: [valuePath, false] },
9
9
  {
10
10
  $function: {
11
- body: function (price, exchangeRate) {
12
- (0, shared_1.convertToSecondarySync)(price, exchangeRate);
11
+ body: function (amount, exchangeRate, roundingFactor) {
12
+ if (typeof amount !== 'number' ||
13
+ isNaN(amount) ||
14
+ typeof exchangeRate !== 'number' ||
15
+ isNaN(exchangeRate) ||
16
+ typeof roundingFactor !== 'number' ||
17
+ roundingFactor <= 0 ||
18
+ amount === 0) {
19
+ return 0;
20
+ }
21
+ const decimals = (roundingFactor.toString().split('.')[1] || '').length;
22
+ const rounded = Math.round(amount / roundingFactor) * roundingFactor;
23
+ return Number(rounded.toFixed(decimals));
13
24
  }.toString(),
14
- args: [valuePath, exchangeRate],
25
+ args: [valuePath, exchangeRate, shared_1.SecondaryCurrencyRoundTo],
15
26
  lang: 'js',
16
27
  },
17
28
  },
@@ -1 +1 @@
1
- {"version":3,"file":"common-pipeline-functions.js","sourceRoot":"/","sources":["utilities/pipelines/common-pipeline-functions.ts"],"names":[],"mappings":";;;AAAA,sCAAmD;AAE5C,MAAM,yBAAyB,GAAG,CAAC,EACzC,SAAS,EACT,YAAY,GAIZ,EAAO,EAAE;IACT,OAAO;QACN,KAAK,EAAE;YACN,EAAE,OAAO,EAAE,CAAC,SAAS,EAAE,KAAK,CAAC,EAAE;YAC/B;gBACC,SAAS,EAAE;oBACV,IAAI,EAAE,UAAU,KAAa,EAAE,YAAoB;wBAClD,IAAA,+BAAsB,EAAC,KAAK,EAAE,YAAY,CAAC,CAAC;oBAC7C,CAAC,CAAC,QAAQ,EAAE;oBACZ,IAAI,EAAE,CAAC,SAAS,EAAE,YAAY,CAAC;oBAC/B,IAAI,EAAE,IAAI;iBACV;aACD;YACD,IAAI;SACJ;KACD,CAAC;AACH,CAAC,CAAC;AAtBW,QAAA,yBAAyB,6BAsBpC","sourcesContent":["import { convertToSecondarySync } from '../shared';\n\nexport const getSecondaryCurrencyStage = ({\n\tvaluePath,\n\texchangeRate,\n}: {\n\tvaluePath: string;\n\texchangeRate: number;\n}): any => {\n\treturn {\n\t\t$cond: [\n\t\t\t{ $ifNull: [valuePath, false] },\n\t\t\t{\n\t\t\t\t$function: {\n\t\t\t\t\tbody: function (price: number, exchangeRate: number) {\n\t\t\t\t\t\tconvertToSecondarySync(price, exchangeRate);\n\t\t\t\t\t}.toString(),\n\t\t\t\t\targs: [valuePath, exchangeRate],\n\t\t\t\t\tlang: 'js',\n\t\t\t\t},\n\t\t\t},\n\t\t\tnull,\n\t\t],\n\t};\n};\n"]}
1
+ {"version":3,"file":"common-pipeline-functions.js","sourceRoot":"/","sources":["utilities/pipelines/common-pipeline-functions.ts"],"names":[],"mappings":";;;AAAA,sCAAqD;AAE9C,MAAM,yBAAyB,GAAG,CAAC,EACzC,SAAS,EACT,YAAY,GAIZ,EAAO,EAAE;IACT,OAAO;QACN,KAAK,EAAE;YACN,EAAE,OAAO,EAAE,CAAC,SAAS,EAAE,KAAK,CAAC,EAAE;YAC/B;gBACC,SAAS,EAAE;oBACV,IAAI,EAAE,UAAU,MAAc,EAAE,YAAoB,EAAE,cAAsB;wBAC3E,IACC,OAAO,MAAM,KAAK,QAAQ;4BAC1B,KAAK,CAAC,MAAM,CAAC;4BACb,OAAO,YAAY,KAAK,QAAQ;4BAChC,KAAK,CAAC,YAAY,CAAC;4BACnB,OAAO,cAAc,KAAK,QAAQ;4BAClC,cAAc,IAAI,CAAC;4BACnB,MAAM,KAAK,CAAC,EACX,CAAC;4BACF,OAAO,CAAC,CAAC;wBACV,CAAC;wBAED,MAAM,QAAQ,GAAG,CAAC,cAAc,CAAC,QAAQ,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC;wBACxE,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,cAAc,CAAC,GAAG,cAAc,CAAC;wBAErE,OAAO,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC;oBAC1C,CAAC,CAAC,QAAQ,EAAE;oBACZ,IAAI,EAAE,CAAC,SAAS,EAAE,YAAY,EAAE,iCAAwB,CAAC;oBACzD,IAAI,EAAE,IAAI;iBACV;aACD;YACD,IAAI;SACJ;KACD,CAAC;AACH,CAAC,CAAC;AArCW,QAAA,yBAAyB,6BAqCpC","sourcesContent":["import { SecondaryCurrencyRoundTo } from '../shared';\n\nexport const getSecondaryCurrencyStage = ({\n\tvaluePath,\n\texchangeRate,\n}: {\n\tvaluePath: string;\n\texchangeRate: number;\n}): any => {\n\treturn {\n\t\t$cond: [\n\t\t\t{ $ifNull: [valuePath, false] },\n\t\t\t{\n\t\t\t\t$function: {\n\t\t\t\t\tbody: function (amount: number, exchangeRate: number, roundingFactor: number) {\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\ttypeof amount !== 'number' ||\n\t\t\t\t\t\t\tisNaN(amount) ||\n\t\t\t\t\t\t\ttypeof exchangeRate !== 'number' ||\n\t\t\t\t\t\t\tisNaN(exchangeRate) ||\n\t\t\t\t\t\t\ttypeof roundingFactor !== 'number' ||\n\t\t\t\t\t\t\troundingFactor <= 0 ||\n\t\t\t\t\t\t\tamount === 0\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\treturn 0;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst decimals = (roundingFactor.toString().split('.')[1] || '').length;\n\t\t\t\t\t\tconst rounded = Math.round(amount / roundingFactor) * roundingFactor;\n\n\t\t\t\t\t\treturn Number(rounded.toFixed(decimals));\n\t\t\t\t\t}.toString(),\n\t\t\t\t\targs: [valuePath, exchangeRate, SecondaryCurrencyRoundTo],\n\t\t\t\t\tlang: 'js',\n\t\t\t\t},\n\t\t\t},\n\t\t\tnull,\n\t\t],\n\t};\n};\n"]}
@@ -7,11 +7,10 @@ const roundCurrencySync = (amount, roundingFactor) => {
7
7
  if (typeof amount !== 'number' ||
8
8
  isNaN(amount) ||
9
9
  typeof roundingFactor !== 'number' ||
10
- roundingFactor <= 0) {
10
+ roundingFactor <= 0 ||
11
+ amount === 0) {
11
12
  return 0;
12
13
  }
13
- if (amount === 0)
14
- return 0;
15
14
  const decimals = (roundingFactor.toString().split('.')[1] || '').length;
16
15
  const rounded = Math.round(amount / roundingFactor) * roundingFactor;
17
16
  return Number(rounded.toFixed(decimals));
@@ -1 +1 @@
1
- {"version":3,"file":"currency.js","sourceRoot":"/","sources":["utilities/shared/currency.ts"],"names":[],"mappings":";;;AACa,QAAA,mBAAmB,GAAG,IAAI,CAAC;AAC3B,QAAA,wBAAwB,GAAG,IAAI,CAAC;AAGtC,MAAM,iBAAiB,GAAG,CAAC,MAAc,EAAE,cAAsB,EAAU,EAAE;IACnF,IACC,OAAO,MAAM,KAAK,QAAQ;QAC1B,KAAK,CAAC,MAAM,CAAC;QACb,OAAO,cAAc,KAAK,QAAQ;QAClC,cAAc,IAAI,CAAC,EAClB,CAAC;QACF,OAAO,CAAC,CAAC;IACV,CAAC;IAED,IAAI,MAAM,KAAK,CAAC;QAAE,OAAO,CAAC,CAAC;IAE3B,MAAM,QAAQ,GAAG,CAAC,cAAc,CAAC,QAAQ,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC;IACxE,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,cAAc,CAAC,GAAG,cAAc,CAAC;IAErE,OAAO,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC;AAC1C,CAAC,CAAC;AAhBW,QAAA,iBAAiB,qBAgB5B;AAGK,MAAM,iBAAiB,GAAG,CAAC,MAAc,EAAU,EAAE;IAC3D,OAAO,IAAA,yBAAiB,EAAC,MAAM,EAAE,2BAAmB,CAAC,CAAC;AACvD,CAAC,CAAC;AAFW,QAAA,iBAAiB,qBAE5B;AAEK,MAAM,sBAAsB,GAAG,CAAC,MAAc,EAAU,EAAE;IAChE,OAAO,IAAA,yBAAiB,EAAC,MAAM,EAAE,gCAAwB,CAAC,CAAC;AAC5D,CAAC,CAAC;AAFW,QAAA,sBAAsB,0BAEjC;AAGK,MAAM,sBAAsB,GAAG,CAAC,MAAc,EAAE,YAAoB,EAAU,EAAE;IACtF,IACC,OAAO,MAAM,KAAK,QAAQ;QAC1B,KAAK,CAAC,MAAM,CAAC;QACb,OAAO,YAAY,KAAK,QAAQ;QAChC,KAAK,CAAC,YAAY,CAAC,EAClB,CAAC;QACF,OAAO,CAAC,CAAC;IACV,CAAC;IAED,OAAO,IAAA,8BAAsB,EAAC,MAAM,GAAG,YAAY,CAAC,CAAC;AACtD,CAAC,CAAC;AAXW,QAAA,sBAAsB,0BAWjC","sourcesContent":["// === Currency Rounding Constants ===\nexport const BaseCurrencyRoundTo = 0.01;\nexport const SecondaryCurrencyRoundTo = 1000;\n\n// === Safely rounds a number to the nearest rounding unit ===\nexport const roundCurrencySync = (amount: number, roundingFactor: number): number => {\n\tif (\n\t\ttypeof amount !== 'number' ||\n\t\tisNaN(amount) ||\n\t\ttypeof roundingFactor !== 'number' ||\n\t\troundingFactor <= 0\n\t) {\n\t\treturn 0;\n\t}\n\n\tif (amount === 0) return 0;\n\n\tconst decimals = (roundingFactor.toString().split('.')[1] || '').length;\n\tconst rounded = Math.round(amount / roundingFactor) * roundingFactor;\n\n\treturn Number(rounded.toFixed(decimals));\n};\n\n// === Specific rounding functions for base and secondary currencies ===\nexport const roundBaseCurrency = (amount: number): number => {\n\treturn roundCurrencySync(amount, BaseCurrencyRoundTo);\n};\n\nexport const roundSecondaryCurrency = (amount: number): number => {\n\treturn roundCurrencySync(amount, SecondaryCurrencyRoundTo);\n};\n\n// === Converts a price from base currency to secondary currency using the provided exchange rate and rounds it ===\nexport const convertToSecondarySync = (amount: number, exchangeRate: number): number => {\n\tif (\n\t\ttypeof amount !== 'number' ||\n\t\tisNaN(amount) ||\n\t\ttypeof exchangeRate !== 'number' ||\n\t\tisNaN(exchangeRate)\n\t) {\n\t\treturn 0;\n\t}\n\n\treturn roundSecondaryCurrency(amount * exchangeRate);\n};\n"]}
1
+ {"version":3,"file":"currency.js","sourceRoot":"/","sources":["utilities/shared/currency.ts"],"names":[],"mappings":";;;AACa,QAAA,mBAAmB,GAAG,IAAI,CAAC;AAC3B,QAAA,wBAAwB,GAAG,IAAI,CAAC;AAGtC,MAAM,iBAAiB,GAAG,CAAC,MAAc,EAAE,cAAsB,EAAU,EAAE;IACnF,IACC,OAAO,MAAM,KAAK,QAAQ;QAC1B,KAAK,CAAC,MAAM,CAAC;QACb,OAAO,cAAc,KAAK,QAAQ;QAClC,cAAc,IAAI,CAAC;QACnB,MAAM,KAAK,CAAC,EACX,CAAC;QACF,OAAO,CAAC,CAAC;IACV,CAAC;IAED,MAAM,QAAQ,GAAG,CAAC,cAAc,CAAC,QAAQ,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC;IACxE,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,cAAc,CAAC,GAAG,cAAc,CAAC;IAErE,OAAO,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC;AAC1C,CAAC,CAAC;AAfW,QAAA,iBAAiB,qBAe5B;AAGK,MAAM,iBAAiB,GAAG,CAAC,MAAc,EAAU,EAAE;IAC3D,OAAO,IAAA,yBAAiB,EAAC,MAAM,EAAE,2BAAmB,CAAC,CAAC;AACvD,CAAC,CAAC;AAFW,QAAA,iBAAiB,qBAE5B;AAEK,MAAM,sBAAsB,GAAG,CAAC,MAAc,EAAU,EAAE;IAChE,OAAO,IAAA,yBAAiB,EAAC,MAAM,EAAE,gCAAwB,CAAC,CAAC;AAC5D,CAAC,CAAC;AAFW,QAAA,sBAAsB,0BAEjC;AAGK,MAAM,sBAAsB,GAAG,CAAC,MAAc,EAAE,YAAoB,EAAU,EAAE;IACtF,IACC,OAAO,MAAM,KAAK,QAAQ;QAC1B,KAAK,CAAC,MAAM,CAAC;QACb,OAAO,YAAY,KAAK,QAAQ;QAChC,KAAK,CAAC,YAAY,CAAC,EAClB,CAAC;QACF,OAAO,CAAC,CAAC;IACV,CAAC;IAED,OAAO,IAAA,8BAAsB,EAAC,MAAM,GAAG,YAAY,CAAC,CAAC;AACtD,CAAC,CAAC;AAXW,QAAA,sBAAsB,0BAWjC","sourcesContent":["// === Currency Rounding Constants ===\nexport const BaseCurrencyRoundTo = 0.01;\nexport const SecondaryCurrencyRoundTo = 1000;\n\n// === Safely rounds a number to the nearest rounding unit ===\nexport const roundCurrencySync = (amount: number, roundingFactor: number): number => {\n\tif (\n\t\ttypeof amount !== 'number' ||\n\t\tisNaN(amount) ||\n\t\ttypeof roundingFactor !== 'number' ||\n\t\troundingFactor <= 0 ||\n\t\tamount === 0\n\t) {\n\t\treturn 0;\n\t}\n\n\tconst decimals = (roundingFactor.toString().split('.')[1] || '').length;\n\tconst rounded = Math.round(amount / roundingFactor) * roundingFactor;\n\n\treturn Number(rounded.toFixed(decimals));\n};\n\n// === Specific rounding functions for base and secondary currencies ===\nexport const roundBaseCurrency = (amount: number): number => {\n\treturn roundCurrencySync(amount, BaseCurrencyRoundTo);\n};\n\nexport const roundSecondaryCurrency = (amount: number): number => {\n\treturn roundCurrencySync(amount, SecondaryCurrencyRoundTo);\n};\n\n// === Converts a price from base currency to secondary currency using the provided exchange rate and rounds it ===\nexport const convertToSecondarySync = (amount: number, exchangeRate: number): number => {\n\tif (\n\t\ttypeof amount !== 'number' ||\n\t\tisNaN(amount) ||\n\t\ttypeof exchangeRate !== 'number' ||\n\t\tisNaN(exchangeRate)\n\t) {\n\t\treturn 0;\n\t}\n\n\treturn roundSecondaryCurrency(amount * exchangeRate);\n};\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lyxa.ai/core",
3
- "version": "1.1.31-alpha.1",
3
+ "version": "1.1.31-alpha.2",
4
4
  "description": "The Core system of the Lyxa services.",
5
5
  "author": "elie <42282499+Internalizable@users.noreply.github.com>",
6
6
  "license": "MIT",