@merkaly/nuxt 0.7.2 → 0.7.4

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/module.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "compatibility": {
5
5
  "nuxt": ">=3.14.0"
6
6
  },
7
- "version": "0.7.2",
7
+ "version": "0.7.4",
8
8
  "builder": {
9
9
  "@nuxt/module-builder": "1.0.2",
10
10
  "unbuild": "3.6.1"
@@ -21,14 +21,17 @@ function extractConstraints(constructor) {
21
21
  return constraints;
22
22
  }
23
23
  function applyErrors(result, errors, state) {
24
- for (const key of Object.keys(errors)) {
25
- errors[key] = "";
26
- state[key] = true;
27
- }
24
+ const failures = /* @__PURE__ */ new Map();
28
25
  for (const error of result) {
29
26
  const messages = error.constraints ? Object.values(error.constraints) : [];
30
- errors[error.property] = messages[0] || "Invalid";
31
- state[error.property] = false;
27
+ failures.set(error.property, messages[0] || "Invalid");
28
+ }
29
+ const keys = /* @__PURE__ */ new Set([...Object.keys(errors), ...failures.keys()]);
30
+ for (const key of keys) {
31
+ const message = failures.get(key) ?? "";
32
+ const isValid = !failures.has(key);
33
+ if (errors[key] !== message) errors[key] = message;
34
+ if (state[key] !== isValid) state[key] = isValid;
32
35
  }
33
36
  }
34
37
  function mergeAttrs(constraints, state) {
@@ -1,6 +1,7 @@
1
1
  import { defineEventHandler, getRequestURL, proxyRequest } from "h3";
2
2
  import { useRuntimeConfig } from "#imports";
3
3
  const GLOBAL_API_HEADER = "x-merkaly-global";
4
+ const TENANT_HOST_HEADER = "x-merkaly-host";
4
5
  const API_PREFIX_PATTERN = /^\/api\/?/;
5
6
  const API_ROUTE_PATTERN = /^\/api(?:\/|$)/;
6
7
  const EDGE_SLASH_PATTERN = /^\/|\/$/g;
@@ -27,6 +28,7 @@ export default defineEventHandler((event) => {
27
28
  const prefix = isGlobalRequest(event.node.req.headers[GLOBAL_API_HEADER]) ? "" : $config.merkaly.api.prefix;
28
29
  const path = resolveProxyPath(prefix, url.pathname, url.search);
29
30
  event.node.req.headers["x-forwarded-host"] = url.host;
31
+ event.node.req.headers[TENANT_HOST_HEADER] = url.host;
30
32
  if (import.meta.dev && targetOrigin.hostname.endsWith(".test")) {
31
33
  process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";
32
34
  }
@@ -3,5 +3,17 @@ export interface FormatMoneyOptions {
3
3
  currency?: string;
4
4
  locale?: string;
5
5
  mode?: Intl.NumberFormatOptionsStyle;
6
+ notation?: Intl.NumberFormatOptions['notation'];
7
+ maximumFractionDigits?: number;
6
8
  }
9
+ /**
10
+ * Formats a monetary value held as an **integer in the minor unit (cents)**.
11
+ *
12
+ * Across Merkaly money is stored and transported as integer cents ($1.00 -> 100),
13
+ * so this helper divides by `base` (default 100) before formatting. Pass cents in,
14
+ * get a currency string out: `formatMoney(100)` -> `"$1.00"`.
15
+ *
16
+ * For non-currency numbers (counts, units, percentages) use `formatNumber` /
17
+ * `MKFormatNumber` instead — those do NOT divide and would show the raw cents.
18
+ */
7
19
  export declare function formatMoney(value: number, options?: FormatMoneyOptions): string;
@@ -1,6 +1,8 @@
1
1
  export function formatMoney(value, options = {}) {
2
2
  return (value / (options.base ?? 100)).toLocaleString(options.locale ?? "en-US", {
3
3
  style: options.mode ?? "currency",
4
- currency: options.currency ?? "USD"
4
+ currency: options.currency ?? "USD",
5
+ notation: options.notation,
6
+ maximumFractionDigits: options.maximumFractionDigits
5
7
  });
6
8
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@merkaly/nuxt",
3
- "version": "0.7.2",
3
+ "version": "0.7.4",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/merkaly-io/nuxt.git"
@@ -56,7 +56,7 @@
56
56
  "notivue": "^2.4.5",
57
57
  "nuxt": "^4.4.8",
58
58
  "reflect-metadata": "^0.2.2",
59
- "sass": "^1.100.0",
59
+ "sass": "^1.101.0",
60
60
  "typescript": "~5.9.3",
61
61
  "v-money3": "^3.26.1",
62
62
  "vite-svg-loader": "^5.1.1",