@marmot-systems/common 2.0.29 → 2.0.31

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/index.cjs CHANGED
@@ -31,6 +31,8 @@ __export(index_exports, {
31
31
  RegisterFormSchema: () => RegisterFormSchema,
32
32
  SalesInvoiceSchema: () => SalesInvoiceSchema,
33
33
  addDaysLocalYmd: () => addDaysLocalYmd,
34
+ countryToCurrency: () => countryToCurrency,
35
+ currencyToLocale: () => currencyToLocale,
34
36
  exceedsTwoDecimals: () => exceedsTwoDecimals,
35
37
  formatMoneyCurrency: () => formatMoneyCurrency,
36
38
  formatYmdLong: () => formatYmdLong,
@@ -55,11 +57,15 @@ var import_zod2 = require("zod");
55
57
  var ISO_COUNTRY_CODES = ["US", "HN"];
56
58
  var USER_ROLES = ["admin", "driver"];
57
59
 
58
- // src/utils/types.ts
60
+ // src/types/money_types.ts
59
61
  var countryToCurrency = {
60
62
  US: "USD",
61
63
  HN: "HNL"
62
64
  };
65
+ var currencyToLocale = {
66
+ USD: "en-US",
67
+ HNL: "es-HN"
68
+ };
63
69
 
64
70
  // src/utils/utils.ts
65
71
  var import_zod = require("zod");
@@ -109,10 +115,11 @@ function roundWithPrecision(num, precision, opts) {
109
115
  function getCurrencyFromCountry(country) {
110
116
  return countryToCurrency[country];
111
117
  }
112
- function formatMoneyCurrency(value, cur) {
113
- return new Intl.NumberFormat("en-US", {
118
+ function formatMoneyCurrency(value, currency) {
119
+ const locale = currency in currencyToLocale ? currencyToLocale[currency] : "en-US";
120
+ return new Intl.NumberFormat(locale, {
114
121
  style: "currency",
115
- currency: cur
122
+ currency
116
123
  }).format(value);
117
124
  }
118
125
 
@@ -358,6 +365,8 @@ var exceedsTwoDecimals = (raw) => {
358
365
  RegisterFormSchema,
359
366
  SalesInvoiceSchema,
360
367
  addDaysLocalYmd,
368
+ countryToCurrency,
369
+ currencyToLocale,
361
370
  exceedsTwoDecimals,
362
371
  formatMoneyCurrency,
363
372
  formatYmdLong,
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/schemas/companies_schemas.ts","../src/types/company_types.ts","../src/utils/types.ts","../src/utils/utils.ts","../src/schemas/customer_schemas.ts","../src/schemas/product_schemas.ts","../src/types/shared_types.ts","../src/domains/invoices/invoices_schemas.ts","../src/domains/invoices/invoices_types.ts","../src/utils/date_utils.ts","../src/utils/errors_utils.ts","../src/utils/money_utils.ts"],"sourcesContent":["export * from \"./schemas/companies_schemas\";\nexport * from \"./schemas/customer_schemas\";\nexport * from \"./schemas/product_schemas\";\nexport * from \"./utils/utils\";\nexport {\n UserRole,\n IsoCountryCode,\n InventorySystem,\n} from \"./types/company_types\";\nexport { CreatedLocation, UUID } from \"./types/shared_types\";\nexport { SyncInvoice } from \"./types/sync_types\";\nexport * from \"./types/customers_types\";\nexport * from \"./types/vendors_types\";\nexport * from \"./domains/invoices/invoices_schemas\";\nexport * from \"./domains/invoices/invoices_types\";\nexport * from \"./domains/products/products_types\";\nexport * from \"./utils/date_utils\";\nexport * from \"./utils/errors_utils\";\nexport * from \"./utils/money_utils\";\n","import { z } from \"zod\";\nimport { ISO_COUNTRY_CODES, USER_ROLES } from \"../types/company_types\";\nimport * as GlobalUtils from \"../utils/utils\";\n\nconst iso_country_code = z.enum(ISO_COUNTRY_CODES, {\n error: \"Country code not supported.\",\n});\n\nconst user_role = z.enum(USER_ROLES, {\n error: \"User role not supported.\",\n});\n\nexport const RegisterFormSchema = z.strictObject({\n companyData: z.strictObject({\n company_name: z\n .string()\n .transform(GlobalUtils.normalizeSpaces)\n .pipe(\n z\n .string()\n .min(1, \"Company name is required\")\n .max(50, \"Company name must be at most 50 characters.\")\n ),\n company_address: z\n .string()\n .transform(GlobalUtils.normalizeSpaces)\n .pipe(\n z\n .string()\n .min(1, \"Company address is required\")\n .max(100, \"Company address must be at most 100 characters.\")\n ),\n company_phone_number: z\n .string()\n .transform(GlobalUtils.removeAllWhitespace)\n .transform(GlobalUtils.removeDashesAndPlusSign)\n .refine((s) => /^\\d{4,15}$/.test(s), {\n error: \"Phone number required and must be from 4 to 15 digits.\",\n }),\n iso_country_code: z\n .string()\n .transform(GlobalUtils.removeAllWhitespace)\n .transform((s) => s.toUpperCase())\n .pipe(iso_country_code),\n }),\n adminUserData: z.strictObject({\n user_first_name: z\n .string()\n .transform(GlobalUtils.normalizeSpaces)\n .pipe(\n z\n .string()\n .min(1, \"First name is required\")\n .max(50, \"First name must be at most 50 characters.\")\n ),\n user_last_name: z\n .string()\n .transform(GlobalUtils.normalizeSpaces)\n .pipe(\n z\n .string()\n .min(1, \"Last name is required\")\n .max(50, \"Last name must be at most 50 characters.\")\n ),\n user_email: z\n .string()\n .transform(GlobalUtils.removeAllWhitespace)\n .pipe(\n z\n .email()\n .max(254, \"Customer email must be at most 254 characters.\")\n .transform((email) => email.toLowerCase())\n ),\n password: z\n .string()\n .min(8, \"Password must be at least 8 characters\")\n .max(25, \"Password must be at most 25 characters\")\n .regex(/[A-Z]/, \"Password must contain at least one uppercase letter\")\n .regex(/[a-z]/, \"Password must contain at least one lowercase letter\")\n .regex(/\\d/, \"Password must contain at least one number\")\n .regex(\n /[@$!%*?&#^_+=-]/,\n \"Password must contain at least one special character\"\n )\n .regex(/^\\S*$/, \"Password cannot contain spaces or other whitespace.\"),\n }),\n});\n","export const ISO_COUNTRY_CODES = [\"US\", \"HN\"] as const;\n\nexport type IsoCountryCode = (typeof ISO_COUNTRY_CODES)[number];\n\nexport const USER_ROLES = [\"admin\", \"driver\"] as const;\n\nexport type UserRole = (typeof USER_ROLES)[number];\n\nexport type InventorySystem = \"warehouse_only\" | \"dsd\";\n","import { IsoCountryCode } from \"../types/company_types\";\n\ntype RoundType = \"half_up\";\n\nexport interface ToFixedOptions {\n roundType?: RoundType;\n}\n\nexport type WhitespaceMode = \"normalize\" | \"remove\";\n\nexport type IsoCurrencyCode = \"USD\" | \"HNL\";\n\nexport const countryToCurrency: Record<IsoCountryCode, IsoCurrencyCode> = {\n US: \"USD\",\n HN: \"HNL\",\n};\n","import * as GlobalTypes from \"./types\";\nimport { IsoCountryCode } from \"../types/company_types\";\n\nimport { z } from \"zod\";\n\n/**\n * Validates zod currency with precision.\n *\n *\n * @param minAmount\n * @param maxAmount\n * @returns\n */\nexport function handleZodCurrency(minAmount: number, maxAmount: number) {\n const fromString = z\n .string({\n error: \"Enter a valid number\",\n })\n .refine((s) => s.trim().length > 0, { error: \"Enter a valid number\" })\n .transform((s) => s.replace(/[,\\s]/g, \"\"))\n .refine((s) => s !== \"\" && !Number.isNaN(Number(s)), {\n error: \"Enter a valid number\",\n })\n .refine((s) => Number.isFinite(Number(s)), {\n error: \"Enter a valid number\",\n })\n .refine((s) => Number(s) >= 0, { error: \"Enter a positive number\" })\n .transform((s) => Number(s));\n\n const fromNumber = z\n .number()\n .refine((n) => Number.isFinite(n), { error: \"Enter a valid number\" })\n .refine((n) => n >= 0, { error: \"Enter a positive number\" });\n\n return z\n .union([fromString, fromNumber])\n .transform((n) => roundWithPrecision(n, 2))\n .refine((n) => n >= minAmount, {\n error: `Must be greater than ${minAmount}`,\n })\n .refine((n) => n <= maxAmount, {\n error: `Exceeds allowed limit ${maxAmount}`,\n });\n}\n\n/**\n * Trims any leading or trailing spaces\n * Transforms empty strings into undefined.\n *\n * @param s\n * @returns\n */\nexport const transformEmptyStringToUndefined = (s: string) =>\n s.trim() === \"\" ? undefined : s;\n\n/**\n * - Collapses any run of whitespace in a string (spaces, tabs, newlines, nbspb, and other weird unicode spaces etc.)\n * into a single ASCII space.\n * - Trims leading and trailing whitespace.\n * \" Jared \\n Gomez \\t Driver\\t \" -> \"Jared Gomez Driver\"\n *\n * @param s\n * @returns\n */\nexport const normalizeSpaces = (s: string) => whitespace(s, \"normalize\");\n\n/**\n * Removes all whitespace from a string\n * @param s\n * @returns\n */\nexport const removeAllWhitespace = (s: string) => whitespace(s, \"remove\");\n\nconst whitespace = (s: string, mode: GlobalTypes.WhitespaceMode) => {\n if (mode === \"remove\") {\n return s.replace(/\\s+/g, \"\");\n }\n\n return s.replace(/\\s+/g, \" \").trim();\n};\n\n/**\n * Removes all dashes and + signs from a string\n * +1-305-555-0123 -> \"13055550123\"\n * 305-555-0123 -> \"3055550123\"\n *\n * @param s\n * @returns\n */\nexport const removeDashesAndPlusSign = (s: string): string =>\n s.replace(/[+-]/g, \"\");\n\n/**\n * Rounds a number to a certain precision.\n * Contract:\n * 1. Number must be finite and non negative.\n * 2. Precision must be finite nonnegative and an integer.\n * 3. Precision must be <= Max precision\n * 4. Returns a number >= 0\n * Default is round half up.\n *\n * @param num\n * @param precision\n * @param opts\n * @returns\n */\nexport function roundWithPrecision(\n num: number,\n precision: number,\n opts?: GlobalTypes.ToFixedOptions\n): number {\n const MAX_PRECISION = 2;\n const { roundType = \"half_up\" } = opts ?? {};\n\n if (!Number.isFinite(num) || num < 0) {\n throw new RangeError(\"Number must be finite and greater than 0.\");\n }\n\n if (\n !Number.isFinite(precision) ||\n !Number.isInteger(precision) ||\n precision < 1\n ) {\n throw new RangeError(\"Precision must be a finite integer greater than 0.\");\n }\n\n if (precision > MAX_PRECISION) {\n throw new RangeError(\"Max precision allowed is 2.\");\n }\n\n return Number(\n (+(Math.round(+(num + \"e\" + precision)) + \"e\" + -precision)).toFixed(\n precision\n )\n );\n}\n\nexport function getCurrencyFromCountry(\n country: IsoCountryCode\n): GlobalTypes.IsoCurrencyCode {\n return GlobalTypes.countryToCurrency[country];\n}\n\nexport function formatMoneyCurrency(\n value: number,\n cur: GlobalTypes.IsoCurrencyCode\n) {\n return new Intl.NumberFormat(\"en-US\", {\n style: \"currency\",\n currency: cur,\n }).format(value);\n}\n","import { z } from \"zod\";\nimport * as GlobalUtils from \"../utils/utils\";\n\nexport const CustomerFormSchema = z.strictObject({\n customer_name: z\n .string()\n .transform(GlobalUtils.normalizeSpaces)\n .pipe(\n z\n .string()\n .min(1, \"Customer name is required\")\n .max(50, \"Customer name must be at most 50 characters.\")\n ),\n\n customer_address: z\n .string()\n .transform(GlobalUtils.normalizeSpaces)\n .pipe(\n z.string().max(100, \"Customer address must be at most 100 characters.\")\n )\n .transform(GlobalUtils.transformEmptyStringToUndefined)\n .optional(),\n\n customer_phone_number: z\n .string()\n .transform(GlobalUtils.removeAllWhitespace)\n .transform(GlobalUtils.removeDashesAndPlusSign)\n .refine((s) => s === \"\" || /^\\d{4,15}$/.test(s), {\n error: \"Phone number must be from 4 to 15 digits.\",\n })\n .transform(GlobalUtils.transformEmptyStringToUndefined)\n .optional(),\n\n customer_email_address: z\n .string()\n .transform(GlobalUtils.removeAllWhitespace)\n .transform(GlobalUtils.transformEmptyStringToUndefined)\n .pipe(\n z\n .email()\n .max(254, \"Customer email must be at most 254 characters.\")\n .transform((email) => email.toLowerCase())\n .optional()\n )\n .optional(),\n\n tax_rate: GlobalUtils.handleZodCurrency(0, 100),\n});\n","import { z } from \"zod\";\nimport * as GlobalUtils from \"../utils/utils\";\n\nexport const ProductFormSchema = z\n .strictObject({\n product_name: z\n .string()\n .transform(GlobalUtils.normalizeSpaces)\n .pipe(\n z\n .string()\n .min(1, \"Product name is required\")\n .max(50, \"Product name must be at most 50 characters.\")\n ),\n\n product_description: z\n .string()\n .transform(GlobalUtils.normalizeSpaces)\n .pipe(\n z\n .string()\n .max(100, \"Product desription must be at most 100 characters.\")\n )\n .transform(GlobalUtils.transformEmptyStringToUndefined)\n .optional(),\n\n product_sku: z\n .string()\n .transform(GlobalUtils.normalizeSpaces)\n .pipe(z.string().max(30, \"Product SKU must be at most 30 characters.\"))\n .transform(GlobalUtils.transformEmptyStringToUndefined)\n .optional(),\n\n product_upc: z\n .string()\n .transform((s) => s.replace(/\\s+/g, \"\"))\n .refine((s) => s === \"\" || /^\\d{12}$/.test(s), {\n error: \"UPC must be exactly 12 digits\",\n })\n .transform(GlobalUtils.transformEmptyStringToUndefined)\n .optional(),\n\n product_gtin_14: z\n .string()\n .transform((s) => s.replace(/\\s+/g, \"\"))\n .refine((s) => s === \"\" || /^\\d{14}$/.test(s), {\n error: \"GTIN14 must be exactly 14 digits\",\n })\n .transform(GlobalUtils.transformEmptyStringToUndefined)\n .optional(),\n\n product_type: z.enum([\"unit\", \"weight\", \"case\"], {\n error: \"Product type must be unit, weight, or case.\",\n }),\n\n weight_unit: z.preprocess((v) => {\n if (v === \"\") return undefined;\n if (typeof v === \"string\") return v.trim().toLowerCase();\n return v;\n }, z.enum([\"kg\", \"lb\", \"g\", \"oz\"]).optional()),\n\n price: GlobalUtils.handleZodCurrency(0, 99_999.99),\n cost: GlobalUtils.handleZodCurrency(0, 99_999.99),\n })\n\n .superRefine((data, ctx) => {\n if (data.product_type === \"weight\" && !data.weight_unit) {\n ctx.addIssue({\n code: \"custom\",\n error: \"Weight unit is required.\",\n path: [\"weight_unit\"],\n });\n }\n\n if (\n data.product_type !== \"weight\" &&\n typeof data.weight_unit !== \"undefined\"\n ) {\n ctx.addIssue({\n code: \"custom\",\n error: \"Weight unit must be empty\",\n path: [\"weight_unit\"],\n });\n }\n });\n","import { z } from \"zod\";\n\nexport const CREATED_LOCATION = [\"web\", \"mobile\"] as const;\n\nexport type CreatedLocation = (typeof CREATED_LOCATION)[number];\n\nexport type IntBool = 0 | 1;\n\nexport const uuidSchema = z.uuid();\nexport type UUID = z.infer<typeof uuidSchema>;\n","import { z } from \"zod\";\nimport { CREDIT_TYPE, INVOICE_STATUS, INVOICE_TYPE } from \"./invoices_types\";\nimport { handleZodCurrency } from \"../../utils/utils\";\n\nconst YmdDateSchema = z.string().regex(/^\\d{4}-\\d{2}-\\d{2}$/, \"Use YYYY-MM-DD\");\n\nconst BaseInvoice = z\n .object({\n invoice_type: z.enum(INVOICE_TYPE, { error: \"Invoice type not found.\" }),\n invoice_date: YmdDateSchema,\n due_date: YmdDateSchema,\n tax_rate: z.number().default(0),\n tax_amount: z.number().default(0),\n warehouse_id: z.uuid().optional(),\n invoice_status: z.enum(INVOICE_STATUS).default(\"finalized\"),\n })\n .superRefine(({ invoice_date, due_date }, ctx) => {\n if (due_date < invoice_date) {\n ctx.addIssue({\n code: \"custom\",\n message: \"Due date can't be earlier than the invoice date.\",\n path: [\"due_date\"],\n });\n }\n });\n\nconst LineItemBase = z.object({\n invoice_id: z.uuid().optional(),\n product_id: z.uuid({ error: \"Select a product\" }),\n product_name: z.string().optional(),\n product_description: z.string().optional(),\n product_type: z.enum([\"unit\", \"weight\", \"case\"]).optional(),\n product_upc: z.string().optional(),\n weight_unit: z.enum([\"kg\", \"lb\", \"g\", \"oz\"]).optional(),\n quantity: handleZodCurrency(0.01, 99_999.99),\n});\n\nconst SalesItem = LineItemBase.safeExtend({\n price: handleZodCurrency(0, 99_999.99),\n credit_type: z.undefined(),\n});\n\nconst CreditItem = LineItemBase.safeExtend({\n price: handleZodCurrency(0, 99_999.99),\n credit_type: z.enum(CREDIT_TYPE, {\n error: \"Select a credit type\",\n }),\n});\n\nconst PurchaseItem = LineItemBase.safeExtend({\n price: handleZodCurrency(0, 99_999.99),\n credit_type: z.undefined(),\n});\n\nexport const SalesInvoiceSchema = BaseInvoice.safeExtend({\n invoice_type: z.literal(\"sales\"),\n party_id: z.uuid({ message: \"Select a customer\" }),\n invoice_items: z.array(SalesItem).min(1, \"Add at least one invoice item\"),\n});\n\nexport const CreditInvoiceSchema = BaseInvoice.safeExtend({\n invoice_type: z.literal(\"credit\"),\n party_id: z.uuid({ message: \"Select a customer\" }),\n invoice_items: z.array(CreditItem).min(1, \"Add at least one invoice item\"),\n});\n\nexport const PurchaseInvoiceSchema = BaseInvoice.safeExtend({\n invoice_type: z.literal(\"purchase\"),\n party_id: z.uuid({ message: \"Select a vendor\" }),\n invoice_items: z.array(PurchaseItem).min(1, \"Add at least one invoice item\"),\n});\n\nexport const AnyInvoiceSchema = z.discriminatedUnion(\"invoice_type\", [\n SalesInvoiceSchema,\n PurchaseInvoiceSchema,\n CreditInvoiceSchema,\n]);\n","import { z } from \"zod\";\nimport * as InvoiceSchemas from \"./invoices_schemas\";\n\nexport type SalesInvoice = z.infer<typeof InvoiceSchemas.SalesInvoiceSchema>;\nexport type CreditInvoice = z.infer<typeof InvoiceSchemas.CreditInvoiceSchema>;\nexport type PurchaseInvoice = z.infer<\n typeof InvoiceSchemas.PurchaseInvoiceSchema\n>;\nexport type AnyInvoiceOut = z.output<typeof InvoiceSchemas.AnyInvoiceSchema>;\n\nexport const INVOICE_TYPE = [\"sales\", \"credit\", \"purchase\"] as const;\n\nexport type InvoiceType = (typeof INVOICE_TYPE)[number];\n\nexport const INVOICE_STATUS = [\"finalized\", \"voided\"] as const;\n\nexport type InvoiceStatus = (typeof INVOICE_STATUS)[number];\n\nexport const CREDIT_TYPE = [\"dump\", \"return\"] as const;\n\nexport type CreditType = (typeof CREDIT_TYPE)[number];\n","// \"Today\" in the user's LOCAL timezone as YMD\nexport function todayLocalYmd(): string {\n const now = new Date();\n const y = now.getFullYear();\n const m = String(now.getMonth() + 1).padStart(2, \"0\");\n const d = String(now.getDate()).padStart(2, \"0\");\n return `${y}-${m}-${d}`;\n}\n\n// Add days in LOCAL time (no drift)\nexport function addDaysLocalYmd(ymd: string, days: number): string {\n const dt = localDateFromYmd(ymd);\n dt.setDate(dt.getDate() + days);\n return ymdFromLocalDate(dt);\n}\n\nexport function formatYmdLong(ymd: string, locale = \"en-US\"): string {\n const { y, m, d } = parseYmd(ymd);\n const utcDate = new Date(Date.UTC(y, m - 1, d)); // 00:00Z\n return new Intl.DateTimeFormat(locale, {\n dateStyle: \"long\",\n timeZone: \"UTC\",\n }).format(utcDate);\n}\n\nexport function localDateFromYmd(ymd: string): Date {\n const { y, m, d } = parseYmd(ymd);\n return new Date(y, m - 1, d); // LOCAL midnight\n}\n\nexport function ymdFromLocalDate(dt: Date): string {\n const y = dt.getFullYear();\n const m = String(dt.getMonth() + 1).padStart(2, \"0\");\n const d = String(dt.getDate()).padStart(2, \"0\");\n return `${y}-${m}-${d}`;\n}\n\nfunction parseYmd(ymd: string): { y: number; m: number; d: number } {\n const m = /^(\\d{4})-(\\d{2})-(\\d{2})$/.exec(ymd);\n if (!m) throw new Error(\"Bad YMD\");\n return { y: Number(m[1]), m: Number(m[2]), d: Number(m[3]) };\n}\n","import type { FieldError, FieldErrorsImpl, Merge } from \"react-hook-form\";\n\ntype RHFError =\n | string\n | FieldError\n | Merge<FieldError, FieldErrorsImpl<any>>\n | undefined;\n\nexport const getErrorMessage = (err: RHFError): string | undefined => {\n if (!err) return undefined;\n if (typeof err === \"string\") return err;\n // FieldError has .message (string | undefined)\n const msg = (err as FieldError).message as string | undefined;\n return typeof msg === \"string\" ? msg : undefined;\n};\n","export const exceedsTwoDecimals = (raw: string) => {\n const s = String(raw ?? \"\").replace(/[,\\s]/g, \"\");\n const dot = s.indexOf(\".\");\n if (dot === -1) return false;\n const after = s.slice(dot + 1);\n const digitsAfter = (after.match(/\\d/g) ?? []).length;\n return digitsAfter > 2;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,IAAAA,cAAkB;;;ACAX,IAAM,oBAAoB,CAAC,MAAM,IAAI;AAIrC,IAAM,aAAa,CAAC,SAAS,QAAQ;;;ACQrC,IAAM,oBAA6D;AAAA,EACxE,IAAI;AAAA,EACJ,IAAI;AACN;;;ACZA,iBAAkB;AAUX,SAAS,kBAAkB,WAAmB,WAAmB;AACtE,QAAM,aAAa,aAChB,OAAO;AAAA,IACN,OAAO;AAAA,EACT,CAAC,EACA,OAAO,CAAC,MAAM,EAAE,KAAK,EAAE,SAAS,GAAG,EAAE,OAAO,uBAAuB,CAAC,EACpE,UAAU,CAAC,MAAM,EAAE,QAAQ,UAAU,EAAE,CAAC,EACxC,OAAO,CAAC,MAAM,MAAM,MAAM,CAAC,OAAO,MAAM,OAAO,CAAC,CAAC,GAAG;AAAA,IACnD,OAAO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QAAQ,EAAE,MAAM,MAAM,CAAC;AAC7B,QAAM,gBAAe,WAAM,MAAM,KAAK,MAAjB,YAAsB,CAAC,GAAG;AAC/C,SAAO,cAAc;AACvB;","names":["import_zod","import_zod","import_zod","import_zod","import_zod"]}
1
+ {"version":3,"sources":["../src/index.ts","../src/schemas/companies_schemas.ts","../src/types/company_types.ts","../src/types/money_types.ts","../src/utils/utils.ts","../src/schemas/customer_schemas.ts","../src/schemas/product_schemas.ts","../src/types/shared_types.ts","../src/domains/invoices/invoices_schemas.ts","../src/domains/invoices/invoices_types.ts","../src/utils/date_utils.ts","../src/utils/errors_utils.ts","../src/utils/money_utils.ts"],"sourcesContent":["export * from \"./schemas/companies_schemas\";\nexport * from \"./schemas/customer_schemas\";\nexport * from \"./schemas/product_schemas\";\nexport * from \"./utils/utils\";\nexport {\n UserRole,\n IsoCountryCode,\n InventorySystem,\n} from \"./types/company_types\";\nexport { CreatedLocation, UUID } from \"./types/shared_types\";\nexport { SyncInvoice } from \"./types/sync_types\";\nexport * from \"./types/customers_types\";\nexport * from \"./types/vendors_types\";\nexport * from \"./domains/invoices/invoices_schemas\";\nexport * from \"./domains/invoices/invoices_types\";\nexport * from \"./domains/products/products_types\";\nexport * from \"./utils/date_utils\";\nexport * from \"./utils/errors_utils\";\n\n// Money\nexport * from \"./utils/money_utils\";\nexport * from \"./types/money_types\";\n","import { z } from \"zod\";\nimport { ISO_COUNTRY_CODES, USER_ROLES } from \"../types/company_types\";\nimport * as GlobalUtils from \"../utils/utils\";\n\nconst iso_country_code = z.enum(ISO_COUNTRY_CODES, {\n error: \"Country code not supported.\",\n});\n\nconst user_role = z.enum(USER_ROLES, {\n error: \"User role not supported.\",\n});\n\nexport const RegisterFormSchema = z.strictObject({\n companyData: z.strictObject({\n company_name: z\n .string()\n .transform(GlobalUtils.normalizeSpaces)\n .pipe(\n z\n .string()\n .min(1, \"Company name is required\")\n .max(50, \"Company name must be at most 50 characters.\")\n ),\n company_address: z\n .string()\n .transform(GlobalUtils.normalizeSpaces)\n .pipe(\n z\n .string()\n .min(1, \"Company address is required\")\n .max(100, \"Company address must be at most 100 characters.\")\n ),\n company_phone_number: z\n .string()\n .transform(GlobalUtils.removeAllWhitespace)\n .transform(GlobalUtils.removeDashesAndPlusSign)\n .refine((s) => /^\\d{4,15}$/.test(s), {\n error: \"Phone number required and must be from 4 to 15 digits.\",\n }),\n iso_country_code: z\n .string()\n .transform(GlobalUtils.removeAllWhitespace)\n .transform((s) => s.toUpperCase())\n .pipe(iso_country_code),\n }),\n adminUserData: z.strictObject({\n user_first_name: z\n .string()\n .transform(GlobalUtils.normalizeSpaces)\n .pipe(\n z\n .string()\n .min(1, \"First name is required\")\n .max(50, \"First name must be at most 50 characters.\")\n ),\n user_last_name: z\n .string()\n .transform(GlobalUtils.normalizeSpaces)\n .pipe(\n z\n .string()\n .min(1, \"Last name is required\")\n .max(50, \"Last name must be at most 50 characters.\")\n ),\n user_email: z\n .string()\n .transform(GlobalUtils.removeAllWhitespace)\n .pipe(\n z\n .email()\n .max(254, \"Customer email must be at most 254 characters.\")\n .transform((email) => email.toLowerCase())\n ),\n password: z\n .string()\n .min(8, \"Password must be at least 8 characters\")\n .max(25, \"Password must be at most 25 characters\")\n .regex(/[A-Z]/, \"Password must contain at least one uppercase letter\")\n .regex(/[a-z]/, \"Password must contain at least one lowercase letter\")\n .regex(/\\d/, \"Password must contain at least one number\")\n .regex(\n /[@$!%*?&#^_+=-]/,\n \"Password must contain at least one special character\"\n )\n .regex(/^\\S*$/, \"Password cannot contain spaces or other whitespace.\"),\n }),\n});\n","export const ISO_COUNTRY_CODES = [\"US\", \"HN\"] as const;\n\nexport type IsoCountryCode = (typeof ISO_COUNTRY_CODES)[number];\n\nexport const USER_ROLES = [\"admin\", \"driver\"] as const;\n\nexport type UserRole = (typeof USER_ROLES)[number];\n\nexport type InventorySystem = \"warehouse_only\" | \"dsd\";\n","import { IsoCountryCode } from \"../types/company_types\";\n\nexport type IsoCurrencyCode = \"USD\" | \"HNL\";\ntype Locale = \"en-US\" | \"es-HN\";\n\nexport const countryToCurrency: Record<IsoCountryCode, IsoCurrencyCode> = {\n US: \"USD\",\n HN: \"HNL\",\n};\n\nexport const currencyToLocale: Record<IsoCurrencyCode, Locale> = {\n USD: \"en-US\",\n HNL: \"es-HN\",\n};\n","import * as GlobalTypes from \"./types\";\nimport { IsoCountryCode } from \"../types/company_types\";\nimport {\n IsoCurrencyCode,\n countryToCurrency,\n currencyToLocale,\n} from \"../types/money_types\";\n\nimport { z } from \"zod\";\n\n/**\n * Validates zod currency with precision.\n *\n *\n * @param minAmount\n * @param maxAmount\n * @returns\n */\nexport function handleZodCurrency(minAmount: number, maxAmount: number) {\n const fromString = z\n .string({\n error: \"Enter a valid number\",\n })\n .refine((s) => s.trim().length > 0, { error: \"Enter a valid number\" })\n .transform((s) => s.replace(/[,\\s]/g, \"\"))\n .refine((s) => s !== \"\" && !Number.isNaN(Number(s)), {\n error: \"Enter a valid number\",\n })\n .refine((s) => Number.isFinite(Number(s)), {\n error: \"Enter a valid number\",\n })\n .refine((s) => Number(s) >= 0, { error: \"Enter a positive number\" })\n .transform((s) => Number(s));\n\n const fromNumber = z\n .number()\n .refine((n) => Number.isFinite(n), { error: \"Enter a valid number\" })\n .refine((n) => n >= 0, { error: \"Enter a positive number\" });\n\n return z\n .union([fromString, fromNumber])\n .transform((n) => roundWithPrecision(n, 2))\n .refine((n) => n >= minAmount, {\n error: `Must be greater than ${minAmount}`,\n })\n .refine((n) => n <= maxAmount, {\n error: `Exceeds allowed limit ${maxAmount}`,\n });\n}\n\n/**\n * Trims any leading or trailing spaces\n * Transforms empty strings into undefined.\n *\n * @param s\n * @returns\n */\nexport const transformEmptyStringToUndefined = (s: string) =>\n s.trim() === \"\" ? undefined : s;\n\n/**\n * - Collapses any run of whitespace in a string (spaces, tabs, newlines, nbspb, and other weird unicode spaces etc.)\n * into a single ASCII space.\n * - Trims leading and trailing whitespace.\n * \" Jared \\n Gomez \\t Driver\\t \" -> \"Jared Gomez Driver\"\n *\n * @param s\n * @returns\n */\nexport const normalizeSpaces = (s: string) => whitespace(s, \"normalize\");\n\n/**\n * Removes all whitespace from a string\n * @param s\n * @returns\n */\nexport const removeAllWhitespace = (s: string) => whitespace(s, \"remove\");\n\nconst whitespace = (s: string, mode: GlobalTypes.WhitespaceMode) => {\n if (mode === \"remove\") {\n return s.replace(/\\s+/g, \"\");\n }\n\n return s.replace(/\\s+/g, \" \").trim();\n};\n\n/**\n * Removes all dashes and + signs from a string\n * +1-305-555-0123 -> \"13055550123\"\n * 305-555-0123 -> \"3055550123\"\n *\n * @param s\n * @returns\n */\nexport const removeDashesAndPlusSign = (s: string): string =>\n s.replace(/[+-]/g, \"\");\n\n/**\n * Rounds a number to a certain precision.\n * Contract:\n * 1. Number must be finite and non negative.\n * 2. Precision must be finite nonnegative and an integer.\n * 3. Precision must be <= Max precision\n * 4. Returns a number >= 0\n * Default is round half up.\n *\n * @param num\n * @param precision\n * @param opts\n * @returns\n */\nexport function roundWithPrecision(\n num: number,\n precision: number,\n opts?: GlobalTypes.ToFixedOptions\n): number {\n const MAX_PRECISION = 2;\n const { roundType = \"half_up\" } = opts ?? {};\n\n if (!Number.isFinite(num) || num < 0) {\n throw new RangeError(\"Number must be finite and greater than 0.\");\n }\n\n if (\n !Number.isFinite(precision) ||\n !Number.isInteger(precision) ||\n precision < 1\n ) {\n throw new RangeError(\"Precision must be a finite integer greater than 0.\");\n }\n\n if (precision > MAX_PRECISION) {\n throw new RangeError(\"Max precision allowed is 2.\");\n }\n\n return Number(\n (+(Math.round(+(num + \"e\" + precision)) + \"e\" + -precision)).toFixed(\n precision\n )\n );\n}\n\nexport function getCurrencyFromCountry(\n country: IsoCountryCode\n): IsoCurrencyCode {\n return countryToCurrency[country];\n}\n\nexport function formatMoneyCurrency(value: number, currency: IsoCurrencyCode) {\n const locale =\n currency in currencyToLocale ? currencyToLocale[currency] : \"en-US\";\n\n return new Intl.NumberFormat(locale, {\n style: \"currency\",\n currency: currency,\n }).format(value);\n}\n","import { z } from \"zod\";\nimport * as GlobalUtils from \"../utils/utils\";\n\nexport const CustomerFormSchema = z.strictObject({\n customer_name: z\n .string()\n .transform(GlobalUtils.normalizeSpaces)\n .pipe(\n z\n .string()\n .min(1, \"Customer name is required\")\n .max(50, \"Customer name must be at most 50 characters.\")\n ),\n\n customer_address: z\n .string()\n .transform(GlobalUtils.normalizeSpaces)\n .pipe(\n z.string().max(100, \"Customer address must be at most 100 characters.\")\n )\n .transform(GlobalUtils.transformEmptyStringToUndefined)\n .optional(),\n\n customer_phone_number: z\n .string()\n .transform(GlobalUtils.removeAllWhitespace)\n .transform(GlobalUtils.removeDashesAndPlusSign)\n .refine((s) => s === \"\" || /^\\d{4,15}$/.test(s), {\n error: \"Phone number must be from 4 to 15 digits.\",\n })\n .transform(GlobalUtils.transformEmptyStringToUndefined)\n .optional(),\n\n customer_email_address: z\n .string()\n .transform(GlobalUtils.removeAllWhitespace)\n .transform(GlobalUtils.transformEmptyStringToUndefined)\n .pipe(\n z\n .email()\n .max(254, \"Customer email must be at most 254 characters.\")\n .transform((email) => email.toLowerCase())\n .optional()\n )\n .optional(),\n\n tax_rate: GlobalUtils.handleZodCurrency(0, 100),\n});\n","import { z } from \"zod\";\nimport * as GlobalUtils from \"../utils/utils\";\n\nexport const ProductFormSchema = z\n .strictObject({\n product_name: z\n .string()\n .transform(GlobalUtils.normalizeSpaces)\n .pipe(\n z\n .string()\n .min(1, \"Product name is required\")\n .max(50, \"Product name must be at most 50 characters.\")\n ),\n\n product_description: z\n .string()\n .transform(GlobalUtils.normalizeSpaces)\n .pipe(\n z\n .string()\n .max(100, \"Product desription must be at most 100 characters.\")\n )\n .transform(GlobalUtils.transformEmptyStringToUndefined)\n .optional(),\n\n product_sku: z\n .string()\n .transform(GlobalUtils.normalizeSpaces)\n .pipe(z.string().max(30, \"Product SKU must be at most 30 characters.\"))\n .transform(GlobalUtils.transformEmptyStringToUndefined)\n .optional(),\n\n product_upc: z\n .string()\n .transform((s) => s.replace(/\\s+/g, \"\"))\n .refine((s) => s === \"\" || /^\\d{12}$/.test(s), {\n error: \"UPC must be exactly 12 digits\",\n })\n .transform(GlobalUtils.transformEmptyStringToUndefined)\n .optional(),\n\n product_gtin_14: z\n .string()\n .transform((s) => s.replace(/\\s+/g, \"\"))\n .refine((s) => s === \"\" || /^\\d{14}$/.test(s), {\n error: \"GTIN14 must be exactly 14 digits\",\n })\n .transform(GlobalUtils.transformEmptyStringToUndefined)\n .optional(),\n\n product_type: z.enum([\"unit\", \"weight\", \"case\"], {\n error: \"Product type must be unit, weight, or case.\",\n }),\n\n weight_unit: z.preprocess((v) => {\n if (v === \"\") return undefined;\n if (typeof v === \"string\") return v.trim().toLowerCase();\n return v;\n }, z.enum([\"kg\", \"lb\", \"g\", \"oz\"]).optional()),\n\n price: GlobalUtils.handleZodCurrency(0, 99_999.99),\n cost: GlobalUtils.handleZodCurrency(0, 99_999.99),\n })\n\n .superRefine((data, ctx) => {\n if (data.product_type === \"weight\" && !data.weight_unit) {\n ctx.addIssue({\n code: \"custom\",\n error: \"Weight unit is required.\",\n path: [\"weight_unit\"],\n });\n }\n\n if (\n data.product_type !== \"weight\" &&\n typeof data.weight_unit !== \"undefined\"\n ) {\n ctx.addIssue({\n code: \"custom\",\n error: \"Weight unit must be empty\",\n path: [\"weight_unit\"],\n });\n }\n });\n","import { z } from \"zod\";\n\nexport const CREATED_LOCATION = [\"web\", \"mobile\"] as const;\n\nexport type CreatedLocation = (typeof CREATED_LOCATION)[number];\n\nexport type IntBool = 0 | 1;\n\nexport const uuidSchema = z.uuid();\nexport type UUID = z.infer<typeof uuidSchema>;\n","import { z } from \"zod\";\nimport { CREDIT_TYPE, INVOICE_STATUS, INVOICE_TYPE } from \"./invoices_types\";\nimport { handleZodCurrency } from \"../../utils/utils\";\n\nconst YmdDateSchema = z.string().regex(/^\\d{4}-\\d{2}-\\d{2}$/, \"Use YYYY-MM-DD\");\n\nconst BaseInvoice = z\n .object({\n invoice_type: z.enum(INVOICE_TYPE, { error: \"Invoice type not found.\" }),\n invoice_date: YmdDateSchema,\n due_date: YmdDateSchema,\n tax_rate: z.number().default(0),\n tax_amount: z.number().default(0),\n warehouse_id: z.uuid().optional(),\n invoice_status: z.enum(INVOICE_STATUS).default(\"finalized\"),\n })\n .superRefine(({ invoice_date, due_date }, ctx) => {\n if (due_date < invoice_date) {\n ctx.addIssue({\n code: \"custom\",\n message: \"Due date can't be earlier than the invoice date.\",\n path: [\"due_date\"],\n });\n }\n });\n\nconst LineItemBase = z.object({\n invoice_id: z.uuid().optional(),\n product_id: z.uuid({ error: \"Select a product\" }),\n product_name: z.string().optional(),\n product_description: z.string().optional(),\n product_type: z.enum([\"unit\", \"weight\", \"case\"]).optional(),\n product_upc: z.string().optional(),\n weight_unit: z.enum([\"kg\", \"lb\", \"g\", \"oz\"]).optional(),\n quantity: handleZodCurrency(0.01, 99_999.99),\n});\n\nconst SalesItem = LineItemBase.safeExtend({\n price: handleZodCurrency(0, 99_999.99),\n credit_type: z.undefined(),\n});\n\nconst CreditItem = LineItemBase.safeExtend({\n price: handleZodCurrency(0, 99_999.99),\n credit_type: z.enum(CREDIT_TYPE, {\n error: \"Select a credit type\",\n }),\n});\n\nconst PurchaseItem = LineItemBase.safeExtend({\n price: handleZodCurrency(0, 99_999.99),\n credit_type: z.undefined(),\n});\n\nexport const SalesInvoiceSchema = BaseInvoice.safeExtend({\n invoice_type: z.literal(\"sales\"),\n party_id: z.uuid({ message: \"Select a customer\" }),\n invoice_items: z.array(SalesItem).min(1, \"Add at least one invoice item\"),\n});\n\nexport const CreditInvoiceSchema = BaseInvoice.safeExtend({\n invoice_type: z.literal(\"credit\"),\n party_id: z.uuid({ message: \"Select a customer\" }),\n invoice_items: z.array(CreditItem).min(1, \"Add at least one invoice item\"),\n});\n\nexport const PurchaseInvoiceSchema = BaseInvoice.safeExtend({\n invoice_type: z.literal(\"purchase\"),\n party_id: z.uuid({ message: \"Select a vendor\" }),\n invoice_items: z.array(PurchaseItem).min(1, \"Add at least one invoice item\"),\n});\n\nexport const AnyInvoiceSchema = z.discriminatedUnion(\"invoice_type\", [\n SalesInvoiceSchema,\n PurchaseInvoiceSchema,\n CreditInvoiceSchema,\n]);\n","import { z } from \"zod\";\nimport * as InvoiceSchemas from \"./invoices_schemas\";\n\nexport type SalesInvoice = z.infer<typeof InvoiceSchemas.SalesInvoiceSchema>;\nexport type CreditInvoice = z.infer<typeof InvoiceSchemas.CreditInvoiceSchema>;\nexport type PurchaseInvoice = z.infer<\n typeof InvoiceSchemas.PurchaseInvoiceSchema\n>;\nexport type AnyInvoiceOut = z.output<typeof InvoiceSchemas.AnyInvoiceSchema>;\n\nexport const INVOICE_TYPE = [\"sales\", \"credit\", \"purchase\"] as const;\n\nexport type InvoiceType = (typeof INVOICE_TYPE)[number];\n\nexport const INVOICE_STATUS = [\"finalized\", \"voided\"] as const;\n\nexport type InvoiceStatus = (typeof INVOICE_STATUS)[number];\n\nexport const CREDIT_TYPE = [\"dump\", \"return\"] as const;\n\nexport type CreditType = (typeof CREDIT_TYPE)[number];\n","// \"Today\" in the user's LOCAL timezone as YMD\nexport function todayLocalYmd(): string {\n const now = new Date();\n const y = now.getFullYear();\n const m = String(now.getMonth() + 1).padStart(2, \"0\");\n const d = String(now.getDate()).padStart(2, \"0\");\n return `${y}-${m}-${d}`;\n}\n\n// Add days in LOCAL time (no drift)\nexport function addDaysLocalYmd(ymd: string, days: number): string {\n const dt = localDateFromYmd(ymd);\n dt.setDate(dt.getDate() + days);\n return ymdFromLocalDate(dt);\n}\n\nexport function formatYmdLong(ymd: string, locale = \"en-US\"): string {\n const { y, m, d } = parseYmd(ymd);\n const utcDate = new Date(Date.UTC(y, m - 1, d)); // 00:00Z\n return new Intl.DateTimeFormat(locale, {\n dateStyle: \"long\",\n timeZone: \"UTC\",\n }).format(utcDate);\n}\n\nexport function localDateFromYmd(ymd: string): Date {\n const { y, m, d } = parseYmd(ymd);\n return new Date(y, m - 1, d); // LOCAL midnight\n}\n\nexport function ymdFromLocalDate(dt: Date): string {\n const y = dt.getFullYear();\n const m = String(dt.getMonth() + 1).padStart(2, \"0\");\n const d = String(dt.getDate()).padStart(2, \"0\");\n return `${y}-${m}-${d}`;\n}\n\nfunction parseYmd(ymd: string): { y: number; m: number; d: number } {\n const m = /^(\\d{4})-(\\d{2})-(\\d{2})$/.exec(ymd);\n if (!m) throw new Error(\"Bad YMD\");\n return { y: Number(m[1]), m: Number(m[2]), d: Number(m[3]) };\n}\n","import type { FieldError, FieldErrorsImpl, Merge } from \"react-hook-form\";\n\ntype RHFError =\n | string\n | FieldError\n | Merge<FieldError, FieldErrorsImpl<any>>\n | undefined;\n\nexport const getErrorMessage = (err: RHFError): string | undefined => {\n if (!err) return undefined;\n if (typeof err === \"string\") return err;\n // FieldError has .message (string | undefined)\n const msg = (err as FieldError).message as string | undefined;\n return typeof msg === \"string\" ? msg : undefined;\n};\n","export const exceedsTwoDecimals = (raw: string) => {\n const s = String(raw ?? \"\").replace(/[,\\s]/g, \"\");\n const dot = s.indexOf(\".\");\n if (dot === -1) return false;\n const after = s.slice(dot + 1);\n const digitsAfter = (after.match(/\\d/g) ?? []).length;\n return digitsAfter > 2;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,IAAAA,cAAkB;;;ACAX,IAAM,oBAAoB,CAAC,MAAM,IAAI;AAIrC,IAAM,aAAa,CAAC,SAAS,QAAQ;;;ACCrC,IAAM,oBAA6D;AAAA,EACxE,IAAI;AAAA,EACJ,IAAI;AACN;AAEO,IAAM,mBAAoD;AAAA,EAC/D,KAAK;AAAA,EACL,KAAK;AACP;;;ACLA,iBAAkB;AAUX,SAAS,kBAAkB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D;;;ACjCO,IAAM,kBAAkB,CAAC,QAAsC;AACpE,MAAI,CAAC,IAAK,QAAO;AACjB,MAAI,OAAO,QAAQ,SAAU,QAAO;AAEpC,QAAM,MAAO,IAAmB;AAChC,SAAO,OAAO,QAAQ,WAAW,MAAM;AACzC;;;ACdO,IAAM,qBAAqB,CAAC,QAAgB;AAAnD;AACE,QAAM,IAAI,OAAO,oBAAO,EAAE,EAAE,QAAQ,UAAU,EAAE;AAChD,QAAM,MAAM,EAAE,QAAQ,GAAG;AACzB,MAAI,QAAQ,GAAI,QAAO;AACvB,QAAM,QAAQ,EAAE,MAAM,MAAM,CAAC;AAC7B,QAAM,gBAAe,WAAM,MAAM,KAAK,MAAjB,YAAsB,CAAC,GAAG;AAC/C,SAAO,cAAc;AACvB;","names":["import_zod","import_zod","import_zod","import_zod","import_zod"]}
package/dist/index.d.cts CHANGED
@@ -48,17 +48,21 @@ declare const ProductFormSchema: z.ZodObject<{
48
48
  cost: z.ZodPipe<z.ZodUnion<readonly [z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodTransform<number, string>>, z.ZodNumber]>, z.ZodTransform<number, number>>;
49
49
  }, z.core.$strict>;
50
50
 
51
+ type RoundType = "half_up";
52
+ interface ToFixedOptions {
53
+ roundType?: RoundType;
54
+ }
55
+
51
56
  declare const ISO_COUNTRY_CODES: readonly ["US", "HN"];
52
57
  type IsoCountryCode = (typeof ISO_COUNTRY_CODES)[number];
53
58
  declare const USER_ROLES: readonly ["admin", "driver"];
54
59
  type UserRole = (typeof USER_ROLES)[number];
55
60
  type InventorySystem = "warehouse_only" | "dsd";
56
61
 
57
- type RoundType = "half_up";
58
- interface ToFixedOptions {
59
- roundType?: RoundType;
60
- }
61
62
  type IsoCurrencyCode = "USD" | "HNL";
63
+ type Locale = "en-US" | "es-HN";
64
+ declare const countryToCurrency: Record<IsoCountryCode, IsoCurrencyCode>;
65
+ declare const currencyToLocale: Record<IsoCurrencyCode, Locale>;
62
66
 
63
67
  /**
64
68
  * Validates zod currency with precision.
@@ -118,7 +122,7 @@ declare const removeDashesAndPlusSign: (s: string) => string;
118
122
  */
119
123
  declare function roundWithPrecision(num: number, precision: number, opts?: ToFixedOptions): number;
120
124
  declare function getCurrencyFromCountry(country: IsoCountryCode): IsoCurrencyCode;
121
- declare function formatMoneyCurrency(value: number, cur: IsoCurrencyCode): string;
125
+ declare function formatMoneyCurrency(value: number, currency: IsoCurrencyCode): string;
122
126
 
123
127
  declare const CREATED_LOCATION: readonly ["web", "mobile"];
124
128
  type CreatedLocation = (typeof CREATED_LOCATION)[number];
@@ -396,4 +400,4 @@ declare const getErrorMessage: (err: RHFError) => string | undefined;
396
400
 
397
401
  declare const exceedsTwoDecimals: (raw: string) => boolean;
398
402
 
399
- export { type AnyInvoiceOut, AnyInvoiceSchema, CREDIT_TYPE, type CreatedLocation, type CreditInvoice, CreditInvoiceSchema, type CreditType, CustomerFormSchema, INVOICE_STATUS, INVOICE_TYPE, type InventorySystem, type InvoiceStatus, type InvoiceType, type IsoCountryCode, type MappedCustomers, type MappedVendors, ProductFormSchema, type ProductType, type PurchaseInvoice, PurchaseInvoiceSchema, RegisterFormSchema, type SalesInvoice, SalesInvoiceSchema, type SyncInvoice, type UUID, type UserRole, type WeightUnit, addDaysLocalYmd, exceedsTwoDecimals, formatMoneyCurrency, formatYmdLong, getCurrencyFromCountry, getErrorMessage, handleZodCurrency, localDateFromYmd, normalizeSpaces, removeAllWhitespace, removeDashesAndPlusSign, roundWithPrecision, todayLocalYmd, transformEmptyStringToUndefined, ymdFromLocalDate };
403
+ export { type AnyInvoiceOut, AnyInvoiceSchema, CREDIT_TYPE, type CreatedLocation, type CreditInvoice, CreditInvoiceSchema, type CreditType, CustomerFormSchema, INVOICE_STATUS, INVOICE_TYPE, type InventorySystem, type InvoiceStatus, type InvoiceType, type IsoCountryCode, type IsoCurrencyCode, type MappedCustomers, type MappedVendors, ProductFormSchema, type ProductType, type PurchaseInvoice, PurchaseInvoiceSchema, RegisterFormSchema, type SalesInvoice, SalesInvoiceSchema, type SyncInvoice, type UUID, type UserRole, type WeightUnit, addDaysLocalYmd, countryToCurrency, currencyToLocale, exceedsTwoDecimals, formatMoneyCurrency, formatYmdLong, getCurrencyFromCountry, getErrorMessage, handleZodCurrency, localDateFromYmd, normalizeSpaces, removeAllWhitespace, removeDashesAndPlusSign, roundWithPrecision, todayLocalYmd, transformEmptyStringToUndefined, ymdFromLocalDate };
package/dist/index.d.ts CHANGED
@@ -48,17 +48,21 @@ declare const ProductFormSchema: z.ZodObject<{
48
48
  cost: z.ZodPipe<z.ZodUnion<readonly [z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodTransform<number, string>>, z.ZodNumber]>, z.ZodTransform<number, number>>;
49
49
  }, z.core.$strict>;
50
50
 
51
+ type RoundType = "half_up";
52
+ interface ToFixedOptions {
53
+ roundType?: RoundType;
54
+ }
55
+
51
56
  declare const ISO_COUNTRY_CODES: readonly ["US", "HN"];
52
57
  type IsoCountryCode = (typeof ISO_COUNTRY_CODES)[number];
53
58
  declare const USER_ROLES: readonly ["admin", "driver"];
54
59
  type UserRole = (typeof USER_ROLES)[number];
55
60
  type InventorySystem = "warehouse_only" | "dsd";
56
61
 
57
- type RoundType = "half_up";
58
- interface ToFixedOptions {
59
- roundType?: RoundType;
60
- }
61
62
  type IsoCurrencyCode = "USD" | "HNL";
63
+ type Locale = "en-US" | "es-HN";
64
+ declare const countryToCurrency: Record<IsoCountryCode, IsoCurrencyCode>;
65
+ declare const currencyToLocale: Record<IsoCurrencyCode, Locale>;
62
66
 
63
67
  /**
64
68
  * Validates zod currency with precision.
@@ -118,7 +122,7 @@ declare const removeDashesAndPlusSign: (s: string) => string;
118
122
  */
119
123
  declare function roundWithPrecision(num: number, precision: number, opts?: ToFixedOptions): number;
120
124
  declare function getCurrencyFromCountry(country: IsoCountryCode): IsoCurrencyCode;
121
- declare function formatMoneyCurrency(value: number, cur: IsoCurrencyCode): string;
125
+ declare function formatMoneyCurrency(value: number, currency: IsoCurrencyCode): string;
122
126
 
123
127
  declare const CREATED_LOCATION: readonly ["web", "mobile"];
124
128
  type CreatedLocation = (typeof CREATED_LOCATION)[number];
@@ -396,4 +400,4 @@ declare const getErrorMessage: (err: RHFError) => string | undefined;
396
400
 
397
401
  declare const exceedsTwoDecimals: (raw: string) => boolean;
398
402
 
399
- export { type AnyInvoiceOut, AnyInvoiceSchema, CREDIT_TYPE, type CreatedLocation, type CreditInvoice, CreditInvoiceSchema, type CreditType, CustomerFormSchema, INVOICE_STATUS, INVOICE_TYPE, type InventorySystem, type InvoiceStatus, type InvoiceType, type IsoCountryCode, type MappedCustomers, type MappedVendors, ProductFormSchema, type ProductType, type PurchaseInvoice, PurchaseInvoiceSchema, RegisterFormSchema, type SalesInvoice, SalesInvoiceSchema, type SyncInvoice, type UUID, type UserRole, type WeightUnit, addDaysLocalYmd, exceedsTwoDecimals, formatMoneyCurrency, formatYmdLong, getCurrencyFromCountry, getErrorMessage, handleZodCurrency, localDateFromYmd, normalizeSpaces, removeAllWhitespace, removeDashesAndPlusSign, roundWithPrecision, todayLocalYmd, transformEmptyStringToUndefined, ymdFromLocalDate };
403
+ export { type AnyInvoiceOut, AnyInvoiceSchema, CREDIT_TYPE, type CreatedLocation, type CreditInvoice, CreditInvoiceSchema, type CreditType, CustomerFormSchema, INVOICE_STATUS, INVOICE_TYPE, type InventorySystem, type InvoiceStatus, type InvoiceType, type IsoCountryCode, type IsoCurrencyCode, type MappedCustomers, type MappedVendors, ProductFormSchema, type ProductType, type PurchaseInvoice, PurchaseInvoiceSchema, RegisterFormSchema, type SalesInvoice, SalesInvoiceSchema, type SyncInvoice, type UUID, type UserRole, type WeightUnit, addDaysLocalYmd, countryToCurrency, currencyToLocale, exceedsTwoDecimals, formatMoneyCurrency, formatYmdLong, getCurrencyFromCountry, getErrorMessage, handleZodCurrency, localDateFromYmd, normalizeSpaces, removeAllWhitespace, removeDashesAndPlusSign, roundWithPrecision, todayLocalYmd, transformEmptyStringToUndefined, ymdFromLocalDate };
package/dist/index.js CHANGED
@@ -5,11 +5,15 @@ import { z as z2 } from "zod";
5
5
  var ISO_COUNTRY_CODES = ["US", "HN"];
6
6
  var USER_ROLES = ["admin", "driver"];
7
7
 
8
- // src/utils/types.ts
8
+ // src/types/money_types.ts
9
9
  var countryToCurrency = {
10
10
  US: "USD",
11
11
  HN: "HNL"
12
12
  };
13
+ var currencyToLocale = {
14
+ USD: "en-US",
15
+ HNL: "es-HN"
16
+ };
13
17
 
14
18
  // src/utils/utils.ts
15
19
  import { z } from "zod";
@@ -59,10 +63,11 @@ function roundWithPrecision(num, precision, opts) {
59
63
  function getCurrencyFromCountry(country) {
60
64
  return countryToCurrency[country];
61
65
  }
62
- function formatMoneyCurrency(value, cur) {
63
- return new Intl.NumberFormat("en-US", {
66
+ function formatMoneyCurrency(value, currency) {
67
+ const locale = currency in currencyToLocale ? currencyToLocale[currency] : "en-US";
68
+ return new Intl.NumberFormat(locale, {
64
69
  style: "currency",
65
- currency: cur
70
+ currency
66
71
  }).format(value);
67
72
  }
68
73
 
@@ -307,6 +312,8 @@ export {
307
312
  RegisterFormSchema,
308
313
  SalesInvoiceSchema,
309
314
  addDaysLocalYmd,
315
+ countryToCurrency,
316
+ currencyToLocale,
310
317
  exceedsTwoDecimals,
311
318
  formatMoneyCurrency,
312
319
  formatYmdLong,
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/schemas/companies_schemas.ts","../src/types/company_types.ts","../src/utils/types.ts","../src/utils/utils.ts","../src/schemas/customer_schemas.ts","../src/schemas/product_schemas.ts","../src/types/shared_types.ts","../src/domains/invoices/invoices_schemas.ts","../src/domains/invoices/invoices_types.ts","../src/utils/date_utils.ts","../src/utils/errors_utils.ts","../src/utils/money_utils.ts"],"sourcesContent":["import { z } from \"zod\";\nimport { ISO_COUNTRY_CODES, USER_ROLES } from \"../types/company_types\";\nimport * as GlobalUtils from \"../utils/utils\";\n\nconst iso_country_code = z.enum(ISO_COUNTRY_CODES, {\n error: \"Country code not supported.\",\n});\n\nconst user_role = z.enum(USER_ROLES, {\n error: \"User role not supported.\",\n});\n\nexport const RegisterFormSchema = z.strictObject({\n companyData: z.strictObject({\n company_name: z\n .string()\n .transform(GlobalUtils.normalizeSpaces)\n .pipe(\n z\n .string()\n .min(1, \"Company name is required\")\n .max(50, \"Company name must be at most 50 characters.\")\n ),\n company_address: z\n .string()\n .transform(GlobalUtils.normalizeSpaces)\n .pipe(\n z\n .string()\n .min(1, \"Company address is required\")\n .max(100, \"Company address must be at most 100 characters.\")\n ),\n company_phone_number: z\n .string()\n .transform(GlobalUtils.removeAllWhitespace)\n .transform(GlobalUtils.removeDashesAndPlusSign)\n .refine((s) => /^\\d{4,15}$/.test(s), {\n error: \"Phone number required and must be from 4 to 15 digits.\",\n }),\n iso_country_code: z\n .string()\n .transform(GlobalUtils.removeAllWhitespace)\n .transform((s) => s.toUpperCase())\n .pipe(iso_country_code),\n }),\n adminUserData: z.strictObject({\n user_first_name: z\n .string()\n .transform(GlobalUtils.normalizeSpaces)\n .pipe(\n z\n .string()\n .min(1, \"First name is required\")\n .max(50, \"First name must be at most 50 characters.\")\n ),\n user_last_name: z\n .string()\n .transform(GlobalUtils.normalizeSpaces)\n .pipe(\n z\n .string()\n .min(1, \"Last name is required\")\n .max(50, \"Last name must be at most 50 characters.\")\n ),\n user_email: z\n .string()\n .transform(GlobalUtils.removeAllWhitespace)\n .pipe(\n z\n .email()\n .max(254, \"Customer email must be at most 254 characters.\")\n .transform((email) => email.toLowerCase())\n ),\n password: z\n .string()\n .min(8, \"Password must be at least 8 characters\")\n .max(25, \"Password must be at most 25 characters\")\n .regex(/[A-Z]/, \"Password must contain at least one uppercase letter\")\n .regex(/[a-z]/, \"Password must contain at least one lowercase letter\")\n .regex(/\\d/, \"Password must contain at least one number\")\n .regex(\n /[@$!%*?&#^_+=-]/,\n \"Password must contain at least one special character\"\n )\n .regex(/^\\S*$/, \"Password cannot contain spaces or other whitespace.\"),\n }),\n});\n","export const ISO_COUNTRY_CODES = [\"US\", \"HN\"] as const;\n\nexport type IsoCountryCode = (typeof ISO_COUNTRY_CODES)[number];\n\nexport const USER_ROLES = [\"admin\", \"driver\"] as const;\n\nexport type UserRole = (typeof USER_ROLES)[number];\n\nexport type InventorySystem = \"warehouse_only\" | \"dsd\";\n","import { IsoCountryCode } from \"../types/company_types\";\n\ntype RoundType = \"half_up\";\n\nexport interface ToFixedOptions {\n roundType?: RoundType;\n}\n\nexport type WhitespaceMode = \"normalize\" | \"remove\";\n\nexport type IsoCurrencyCode = \"USD\" | \"HNL\";\n\nexport const countryToCurrency: Record<IsoCountryCode, IsoCurrencyCode> = {\n US: \"USD\",\n HN: \"HNL\",\n};\n","import * as GlobalTypes from \"./types\";\nimport { IsoCountryCode } from \"../types/company_types\";\n\nimport { z } from \"zod\";\n\n/**\n * Validates zod currency with precision.\n *\n *\n * @param minAmount\n * @param maxAmount\n * @returns\n */\nexport function handleZodCurrency(minAmount: number, maxAmount: number) {\n const fromString = z\n .string({\n error: \"Enter a valid number\",\n })\n .refine((s) => s.trim().length > 0, { error: \"Enter a valid number\" })\n .transform((s) => s.replace(/[,\\s]/g, \"\"))\n .refine((s) => s !== \"\" && !Number.isNaN(Number(s)), {\n error: \"Enter a valid number\",\n })\n .refine((s) => Number.isFinite(Number(s)), {\n error: \"Enter a valid number\",\n })\n .refine((s) => Number(s) >= 0, { error: \"Enter a positive number\" })\n .transform((s) => Number(s));\n\n const fromNumber = z\n .number()\n .refine((n) => Number.isFinite(n), { error: \"Enter a valid number\" })\n .refine((n) => n >= 0, { error: \"Enter a positive number\" });\n\n return z\n .union([fromString, fromNumber])\n .transform((n) => roundWithPrecision(n, 2))\n .refine((n) => n >= minAmount, {\n error: `Must be greater than ${minAmount}`,\n })\n .refine((n) => n <= maxAmount, {\n error: `Exceeds allowed limit ${maxAmount}`,\n });\n}\n\n/**\n * Trims any leading or trailing spaces\n * Transforms empty strings into undefined.\n *\n * @param s\n * @returns\n */\nexport const transformEmptyStringToUndefined = (s: string) =>\n s.trim() === \"\" ? undefined : s;\n\n/**\n * - Collapses any run of whitespace in a string (spaces, tabs, newlines, nbspb, and other weird unicode spaces etc.)\n * into a single ASCII space.\n * - Trims leading and trailing whitespace.\n * \" Jared \\n Gomez \\t Driver\\t \" -> \"Jared Gomez Driver\"\n *\n * @param s\n * @returns\n */\nexport const normalizeSpaces = (s: string) => whitespace(s, \"normalize\");\n\n/**\n * Removes all whitespace from a string\n * @param s\n * @returns\n */\nexport const removeAllWhitespace = (s: string) => whitespace(s, \"remove\");\n\nconst whitespace = (s: string, mode: GlobalTypes.WhitespaceMode) => {\n if (mode === \"remove\") {\n return s.replace(/\\s+/g, \"\");\n }\n\n return s.replace(/\\s+/g, \" \").trim();\n};\n\n/**\n * Removes all dashes and + signs from a string\n * +1-305-555-0123 -> \"13055550123\"\n * 305-555-0123 -> \"3055550123\"\n *\n * @param s\n * @returns\n */\nexport const removeDashesAndPlusSign = (s: string): string =>\n s.replace(/[+-]/g, \"\");\n\n/**\n * Rounds a number to a certain precision.\n * Contract:\n * 1. Number must be finite and non negative.\n * 2. Precision must be finite nonnegative and an integer.\n * 3. Precision must be <= Max precision\n * 4. Returns a number >= 0\n * Default is round half up.\n *\n * @param num\n * @param precision\n * @param opts\n * @returns\n */\nexport function roundWithPrecision(\n num: number,\n precision: number,\n opts?: GlobalTypes.ToFixedOptions\n): number {\n const MAX_PRECISION = 2;\n const { roundType = \"half_up\" } = opts ?? {};\n\n if (!Number.isFinite(num) || num < 0) {\n throw new RangeError(\"Number must be finite and greater than 0.\");\n }\n\n if (\n !Number.isFinite(precision) ||\n !Number.isInteger(precision) ||\n precision < 1\n ) {\n throw new RangeError(\"Precision must be a finite integer greater than 0.\");\n }\n\n if (precision > MAX_PRECISION) {\n throw new RangeError(\"Max precision allowed is 2.\");\n }\n\n return Number(\n (+(Math.round(+(num + \"e\" + precision)) + \"e\" + -precision)).toFixed(\n precision\n )\n );\n}\n\nexport function getCurrencyFromCountry(\n country: IsoCountryCode\n): GlobalTypes.IsoCurrencyCode {\n return GlobalTypes.countryToCurrency[country];\n}\n\nexport function formatMoneyCurrency(\n value: number,\n cur: GlobalTypes.IsoCurrencyCode\n) {\n return new Intl.NumberFormat(\"en-US\", {\n style: \"currency\",\n currency: cur,\n }).format(value);\n}\n","import { z } from \"zod\";\nimport * as GlobalUtils from \"../utils/utils\";\n\nexport const CustomerFormSchema = z.strictObject({\n customer_name: z\n .string()\n .transform(GlobalUtils.normalizeSpaces)\n .pipe(\n z\n .string()\n .min(1, \"Customer name is required\")\n .max(50, \"Customer name must be at most 50 characters.\")\n ),\n\n customer_address: z\n .string()\n .transform(GlobalUtils.normalizeSpaces)\n .pipe(\n z.string().max(100, \"Customer address must be at most 100 characters.\")\n )\n .transform(GlobalUtils.transformEmptyStringToUndefined)\n .optional(),\n\n customer_phone_number: z\n .string()\n .transform(GlobalUtils.removeAllWhitespace)\n .transform(GlobalUtils.removeDashesAndPlusSign)\n .refine((s) => s === \"\" || /^\\d{4,15}$/.test(s), {\n error: \"Phone number must be from 4 to 15 digits.\",\n })\n .transform(GlobalUtils.transformEmptyStringToUndefined)\n .optional(),\n\n customer_email_address: z\n .string()\n .transform(GlobalUtils.removeAllWhitespace)\n .transform(GlobalUtils.transformEmptyStringToUndefined)\n .pipe(\n z\n .email()\n .max(254, \"Customer email must be at most 254 characters.\")\n .transform((email) => email.toLowerCase())\n .optional()\n )\n .optional(),\n\n tax_rate: GlobalUtils.handleZodCurrency(0, 100),\n});\n","import { z } from \"zod\";\nimport * as GlobalUtils from \"../utils/utils\";\n\nexport const ProductFormSchema = z\n .strictObject({\n product_name: z\n .string()\n .transform(GlobalUtils.normalizeSpaces)\n .pipe(\n z\n .string()\n .min(1, \"Product name is required\")\n .max(50, \"Product name must be at most 50 characters.\")\n ),\n\n product_description: z\n .string()\n .transform(GlobalUtils.normalizeSpaces)\n .pipe(\n z\n .string()\n .max(100, \"Product desription must be at most 100 characters.\")\n )\n .transform(GlobalUtils.transformEmptyStringToUndefined)\n .optional(),\n\n product_sku: z\n .string()\n .transform(GlobalUtils.normalizeSpaces)\n .pipe(z.string().max(30, \"Product SKU must be at most 30 characters.\"))\n .transform(GlobalUtils.transformEmptyStringToUndefined)\n .optional(),\n\n product_upc: z\n .string()\n .transform((s) => s.replace(/\\s+/g, \"\"))\n .refine((s) => s === \"\" || /^\\d{12}$/.test(s), {\n error: \"UPC must be exactly 12 digits\",\n })\n .transform(GlobalUtils.transformEmptyStringToUndefined)\n .optional(),\n\n product_gtin_14: z\n .string()\n .transform((s) => s.replace(/\\s+/g, \"\"))\n .refine((s) => s === \"\" || /^\\d{14}$/.test(s), {\n error: \"GTIN14 must be exactly 14 digits\",\n })\n .transform(GlobalUtils.transformEmptyStringToUndefined)\n .optional(),\n\n product_type: z.enum([\"unit\", \"weight\", \"case\"], {\n error: \"Product type must be unit, weight, or case.\",\n }),\n\n weight_unit: z.preprocess((v) => {\n if (v === \"\") return undefined;\n if (typeof v === \"string\") return v.trim().toLowerCase();\n return v;\n }, z.enum([\"kg\", \"lb\", \"g\", \"oz\"]).optional()),\n\n price: GlobalUtils.handleZodCurrency(0, 99_999.99),\n cost: GlobalUtils.handleZodCurrency(0, 99_999.99),\n })\n\n .superRefine((data, ctx) => {\n if (data.product_type === \"weight\" && !data.weight_unit) {\n ctx.addIssue({\n code: \"custom\",\n error: \"Weight unit is required.\",\n path: [\"weight_unit\"],\n });\n }\n\n if (\n data.product_type !== \"weight\" &&\n typeof data.weight_unit !== \"undefined\"\n ) {\n ctx.addIssue({\n code: \"custom\",\n error: \"Weight unit must be empty\",\n path: [\"weight_unit\"],\n });\n }\n });\n","import { z } from \"zod\";\n\nexport const CREATED_LOCATION = [\"web\", \"mobile\"] as const;\n\nexport type CreatedLocation = (typeof CREATED_LOCATION)[number];\n\nexport type IntBool = 0 | 1;\n\nexport const uuidSchema = z.uuid();\nexport type UUID = z.infer<typeof uuidSchema>;\n","import { z } from \"zod\";\nimport { CREDIT_TYPE, INVOICE_STATUS, INVOICE_TYPE } from \"./invoices_types\";\nimport { handleZodCurrency } from \"../../utils/utils\";\n\nconst YmdDateSchema = z.string().regex(/^\\d{4}-\\d{2}-\\d{2}$/, \"Use YYYY-MM-DD\");\n\nconst BaseInvoice = z\n .object({\n invoice_type: z.enum(INVOICE_TYPE, { error: \"Invoice type not found.\" }),\n invoice_date: YmdDateSchema,\n due_date: YmdDateSchema,\n tax_rate: z.number().default(0),\n tax_amount: z.number().default(0),\n warehouse_id: z.uuid().optional(),\n invoice_status: z.enum(INVOICE_STATUS).default(\"finalized\"),\n })\n .superRefine(({ invoice_date, due_date }, ctx) => {\n if (due_date < invoice_date) {\n ctx.addIssue({\n code: \"custom\",\n message: \"Due date can't be earlier than the invoice date.\",\n path: [\"due_date\"],\n });\n }\n });\n\nconst LineItemBase = z.object({\n invoice_id: z.uuid().optional(),\n product_id: z.uuid({ error: \"Select a product\" }),\n product_name: z.string().optional(),\n product_description: z.string().optional(),\n product_type: z.enum([\"unit\", \"weight\", \"case\"]).optional(),\n product_upc: z.string().optional(),\n weight_unit: z.enum([\"kg\", \"lb\", \"g\", \"oz\"]).optional(),\n quantity: handleZodCurrency(0.01, 99_999.99),\n});\n\nconst SalesItem = LineItemBase.safeExtend({\n price: handleZodCurrency(0, 99_999.99),\n credit_type: z.undefined(),\n});\n\nconst CreditItem = LineItemBase.safeExtend({\n price: handleZodCurrency(0, 99_999.99),\n credit_type: z.enum(CREDIT_TYPE, {\n error: \"Select a credit type\",\n }),\n});\n\nconst PurchaseItem = LineItemBase.safeExtend({\n price: handleZodCurrency(0, 99_999.99),\n credit_type: z.undefined(),\n});\n\nexport const SalesInvoiceSchema = BaseInvoice.safeExtend({\n invoice_type: z.literal(\"sales\"),\n party_id: z.uuid({ message: \"Select a customer\" }),\n invoice_items: z.array(SalesItem).min(1, \"Add at least one invoice item\"),\n});\n\nexport const CreditInvoiceSchema = BaseInvoice.safeExtend({\n invoice_type: z.literal(\"credit\"),\n party_id: z.uuid({ message: \"Select a customer\" }),\n invoice_items: z.array(CreditItem).min(1, \"Add at least one invoice item\"),\n});\n\nexport const PurchaseInvoiceSchema = BaseInvoice.safeExtend({\n invoice_type: z.literal(\"purchase\"),\n party_id: z.uuid({ message: \"Select a vendor\" }),\n invoice_items: z.array(PurchaseItem).min(1, \"Add at least one invoice item\"),\n});\n\nexport const AnyInvoiceSchema = z.discriminatedUnion(\"invoice_type\", [\n SalesInvoiceSchema,\n PurchaseInvoiceSchema,\n CreditInvoiceSchema,\n]);\n","import { z } from \"zod\";\nimport * as InvoiceSchemas from \"./invoices_schemas\";\n\nexport type SalesInvoice = z.infer<typeof InvoiceSchemas.SalesInvoiceSchema>;\nexport type CreditInvoice = z.infer<typeof InvoiceSchemas.CreditInvoiceSchema>;\nexport type PurchaseInvoice = z.infer<\n typeof InvoiceSchemas.PurchaseInvoiceSchema\n>;\nexport type AnyInvoiceOut = z.output<typeof InvoiceSchemas.AnyInvoiceSchema>;\n\nexport const INVOICE_TYPE = [\"sales\", \"credit\", \"purchase\"] as const;\n\nexport type InvoiceType = (typeof INVOICE_TYPE)[number];\n\nexport const INVOICE_STATUS = [\"finalized\", \"voided\"] as const;\n\nexport type InvoiceStatus = (typeof INVOICE_STATUS)[number];\n\nexport const CREDIT_TYPE = [\"dump\", \"return\"] as const;\n\nexport type CreditType = (typeof CREDIT_TYPE)[number];\n","// \"Today\" in the user's LOCAL timezone as YMD\nexport function todayLocalYmd(): string {\n const now = new Date();\n const y = now.getFullYear();\n const m = String(now.getMonth() + 1).padStart(2, \"0\");\n const d = String(now.getDate()).padStart(2, \"0\");\n return `${y}-${m}-${d}`;\n}\n\n// Add days in LOCAL time (no drift)\nexport function addDaysLocalYmd(ymd: string, days: number): string {\n const dt = localDateFromYmd(ymd);\n dt.setDate(dt.getDate() + days);\n return ymdFromLocalDate(dt);\n}\n\nexport function formatYmdLong(ymd: string, locale = \"en-US\"): string {\n const { y, m, d } = parseYmd(ymd);\n const utcDate = new Date(Date.UTC(y, m - 1, d)); // 00:00Z\n return new Intl.DateTimeFormat(locale, {\n dateStyle: \"long\",\n timeZone: \"UTC\",\n }).format(utcDate);\n}\n\nexport function localDateFromYmd(ymd: string): Date {\n const { y, m, d } = parseYmd(ymd);\n return new Date(y, m - 1, d); // LOCAL midnight\n}\n\nexport function ymdFromLocalDate(dt: Date): string {\n const y = dt.getFullYear();\n const m = String(dt.getMonth() + 1).padStart(2, \"0\");\n const d = String(dt.getDate()).padStart(2, \"0\");\n return `${y}-${m}-${d}`;\n}\n\nfunction parseYmd(ymd: string): { y: number; m: number; d: number } {\n const m = /^(\\d{4})-(\\d{2})-(\\d{2})$/.exec(ymd);\n if (!m) throw new Error(\"Bad YMD\");\n return { y: Number(m[1]), m: Number(m[2]), d: Number(m[3]) };\n}\n","import type { FieldError, FieldErrorsImpl, Merge } from \"react-hook-form\";\n\ntype RHFError =\n | string\n | FieldError\n | Merge<FieldError, FieldErrorsImpl<any>>\n | undefined;\n\nexport const getErrorMessage = (err: RHFError): string | undefined => {\n if (!err) return undefined;\n if (typeof err === \"string\") return err;\n // FieldError has .message (string | undefined)\n const msg = (err as FieldError).message as string | undefined;\n return typeof msg === \"string\" ? msg : undefined;\n};\n","export const exceedsTwoDecimals = (raw: string) => {\n const s = String(raw ?? \"\").replace(/[,\\s]/g, \"\");\n const dot = s.indexOf(\".\");\n if (dot === -1) return false;\n const after = s.slice(dot + 1);\n const digitsAfter = (after.match(/\\d/g) ?? []).length;\n return digitsAfter > 2;\n};\n"],"mappings":";AAAA,SAAS,KAAAA,UAAS;;;ACAX,IAAM,oBAAoB,CAAC,MAAM,IAAI;AAIrC,IAAM,aAAa,CAAC,SAAS,QAAQ;;;ACQrC,IAAM,oBAA6D;AAAA,EACxE,IAAI;AAAA,EACJ,IAAI;AACN;;;ACZA,SAAS,SAAS;AAUX,SAAS,kBAAkB,WAAmB,WAAmB;AACtE,QAAM,aAAa,EAChB,OAAO;AAAA,IACN,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O,IAAM,kBAAkB,CAAC,QAAsC;AACpE,MAAI,CAAC,IAAK,QAAO;AACjB,MAAI,OAAO,QAAQ,SAAU,QAAO;AAEpC,QAAM,MAAO,IAAmB;AAChC,SAAO,OAAO,QAAQ,WAAW,MAAM;AACzC;;;ACdO,IAAM,qBAAqB,CAAC,QAAgB;AAAnD;AACE,QAAM,IAAI,OAAO,oBAAO,EAAE,EAAE,QAAQ,UAAU,EAAE;AAChD,QAAM,MAAM,EAAE,QAAQ,GAAG;AACzB,MAAI,QAAQ,GAAI,QAAO;AACvB,QAAM,QAAQ,EAAE,MAAM,MAAM,CAAC;AAC7B,QAAM,gBAAe,WAAM,MAAM,KAAK,MAAjB,YAAsB,CAAC,GAAG;AAC/C,SAAO,cAAc;AACvB;","names":["z","z","z","z","z","z","z","z","z","z"]}
1
+ {"version":3,"sources":["../src/schemas/companies_schemas.ts","../src/types/company_types.ts","../src/types/money_types.ts","../src/utils/utils.ts","../src/schemas/customer_schemas.ts","../src/schemas/product_schemas.ts","../src/types/shared_types.ts","../src/domains/invoices/invoices_schemas.ts","../src/domains/invoices/invoices_types.ts","../src/utils/date_utils.ts","../src/utils/errors_utils.ts","../src/utils/money_utils.ts"],"sourcesContent":["import { z } from \"zod\";\nimport { ISO_COUNTRY_CODES, USER_ROLES } from \"../types/company_types\";\nimport * as GlobalUtils from \"../utils/utils\";\n\nconst iso_country_code = z.enum(ISO_COUNTRY_CODES, {\n error: \"Country code not supported.\",\n});\n\nconst user_role = z.enum(USER_ROLES, {\n error: \"User role not supported.\",\n});\n\nexport const RegisterFormSchema = z.strictObject({\n companyData: z.strictObject({\n company_name: z\n .string()\n .transform(GlobalUtils.normalizeSpaces)\n .pipe(\n z\n .string()\n .min(1, \"Company name is required\")\n .max(50, \"Company name must be at most 50 characters.\")\n ),\n company_address: z\n .string()\n .transform(GlobalUtils.normalizeSpaces)\n .pipe(\n z\n .string()\n .min(1, \"Company address is required\")\n .max(100, \"Company address must be at most 100 characters.\")\n ),\n company_phone_number: z\n .string()\n .transform(GlobalUtils.removeAllWhitespace)\n .transform(GlobalUtils.removeDashesAndPlusSign)\n .refine((s) => /^\\d{4,15}$/.test(s), {\n error: \"Phone number required and must be from 4 to 15 digits.\",\n }),\n iso_country_code: z\n .string()\n .transform(GlobalUtils.removeAllWhitespace)\n .transform((s) => s.toUpperCase())\n .pipe(iso_country_code),\n }),\n adminUserData: z.strictObject({\n user_first_name: z\n .string()\n .transform(GlobalUtils.normalizeSpaces)\n .pipe(\n z\n .string()\n .min(1, \"First name is required\")\n .max(50, \"First name must be at most 50 characters.\")\n ),\n user_last_name: z\n .string()\n .transform(GlobalUtils.normalizeSpaces)\n .pipe(\n z\n .string()\n .min(1, \"Last name is required\")\n .max(50, \"Last name must be at most 50 characters.\")\n ),\n user_email: z\n .string()\n .transform(GlobalUtils.removeAllWhitespace)\n .pipe(\n z\n .email()\n .max(254, \"Customer email must be at most 254 characters.\")\n .transform((email) => email.toLowerCase())\n ),\n password: z\n .string()\n .min(8, \"Password must be at least 8 characters\")\n .max(25, \"Password must be at most 25 characters\")\n .regex(/[A-Z]/, \"Password must contain at least one uppercase letter\")\n .regex(/[a-z]/, \"Password must contain at least one lowercase letter\")\n .regex(/\\d/, \"Password must contain at least one number\")\n .regex(\n /[@$!%*?&#^_+=-]/,\n \"Password must contain at least one special character\"\n )\n .regex(/^\\S*$/, \"Password cannot contain spaces or other whitespace.\"),\n }),\n});\n","export const ISO_COUNTRY_CODES = [\"US\", \"HN\"] as const;\n\nexport type IsoCountryCode = (typeof ISO_COUNTRY_CODES)[number];\n\nexport const USER_ROLES = [\"admin\", \"driver\"] as const;\n\nexport type UserRole = (typeof USER_ROLES)[number];\n\nexport type InventorySystem = \"warehouse_only\" | \"dsd\";\n","import { IsoCountryCode } from \"../types/company_types\";\n\nexport type IsoCurrencyCode = \"USD\" | \"HNL\";\ntype Locale = \"en-US\" | \"es-HN\";\n\nexport const countryToCurrency: Record<IsoCountryCode, IsoCurrencyCode> = {\n US: \"USD\",\n HN: \"HNL\",\n};\n\nexport const currencyToLocale: Record<IsoCurrencyCode, Locale> = {\n USD: \"en-US\",\n HNL: \"es-HN\",\n};\n","import * as GlobalTypes from \"./types\";\nimport { IsoCountryCode } from \"../types/company_types\";\nimport {\n IsoCurrencyCode,\n countryToCurrency,\n currencyToLocale,\n} from \"../types/money_types\";\n\nimport { z } from \"zod\";\n\n/**\n * Validates zod currency with precision.\n *\n *\n * @param minAmount\n * @param maxAmount\n * @returns\n */\nexport function handleZodCurrency(minAmount: number, maxAmount: number) {\n const fromString = z\n .string({\n error: \"Enter a valid number\",\n })\n .refine((s) => s.trim().length > 0, { error: \"Enter a valid number\" })\n .transform((s) => s.replace(/[,\\s]/g, \"\"))\n .refine((s) => s !== \"\" && !Number.isNaN(Number(s)), {\n error: \"Enter a valid number\",\n })\n .refine((s) => Number.isFinite(Number(s)), {\n error: \"Enter a valid number\",\n })\n .refine((s) => Number(s) >= 0, { error: \"Enter a positive number\" })\n .transform((s) => Number(s));\n\n const fromNumber = z\n .number()\n .refine((n) => Number.isFinite(n), { error: \"Enter a valid number\" })\n .refine((n) => n >= 0, { error: \"Enter a positive number\" });\n\n return z\n .union([fromString, fromNumber])\n .transform((n) => roundWithPrecision(n, 2))\n .refine((n) => n >= minAmount, {\n error: `Must be greater than ${minAmount}`,\n })\n .refine((n) => n <= maxAmount, {\n error: `Exceeds allowed limit ${maxAmount}`,\n });\n}\n\n/**\n * Trims any leading or trailing spaces\n * Transforms empty strings into undefined.\n *\n * @param s\n * @returns\n */\nexport const transformEmptyStringToUndefined = (s: string) =>\n s.trim() === \"\" ? undefined : s;\n\n/**\n * - Collapses any run of whitespace in a string (spaces, tabs, newlines, nbspb, and other weird unicode spaces etc.)\n * into a single ASCII space.\n * - Trims leading and trailing whitespace.\n * \" Jared \\n Gomez \\t Driver\\t \" -> \"Jared Gomez Driver\"\n *\n * @param s\n * @returns\n */\nexport const normalizeSpaces = (s: string) => whitespace(s, \"normalize\");\n\n/**\n * Removes all whitespace from a string\n * @param s\n * @returns\n */\nexport const removeAllWhitespace = (s: string) => whitespace(s, \"remove\");\n\nconst whitespace = (s: string, mode: GlobalTypes.WhitespaceMode) => {\n if (mode === \"remove\") {\n return s.replace(/\\s+/g, \"\");\n }\n\n return s.replace(/\\s+/g, \" \").trim();\n};\n\n/**\n * Removes all dashes and + signs from a string\n * +1-305-555-0123 -> \"13055550123\"\n * 305-555-0123 -> \"3055550123\"\n *\n * @param s\n * @returns\n */\nexport const removeDashesAndPlusSign = (s: string): string =>\n s.replace(/[+-]/g, \"\");\n\n/**\n * Rounds a number to a certain precision.\n * Contract:\n * 1. Number must be finite and non negative.\n * 2. Precision must be finite nonnegative and an integer.\n * 3. Precision must be <= Max precision\n * 4. Returns a number >= 0\n * Default is round half up.\n *\n * @param num\n * @param precision\n * @param opts\n * @returns\n */\nexport function roundWithPrecision(\n num: number,\n precision: number,\n opts?: GlobalTypes.ToFixedOptions\n): number {\n const MAX_PRECISION = 2;\n const { roundType = \"half_up\" } = opts ?? {};\n\n if (!Number.isFinite(num) || num < 0) {\n throw new RangeError(\"Number must be finite and greater than 0.\");\n }\n\n if (\n !Number.isFinite(precision) ||\n !Number.isInteger(precision) ||\n precision < 1\n ) {\n throw new RangeError(\"Precision must be a finite integer greater than 0.\");\n }\n\n if (precision > MAX_PRECISION) {\n throw new RangeError(\"Max precision allowed is 2.\");\n }\n\n return Number(\n (+(Math.round(+(num + \"e\" + precision)) + \"e\" + -precision)).toFixed(\n precision\n )\n );\n}\n\nexport function getCurrencyFromCountry(\n country: IsoCountryCode\n): IsoCurrencyCode {\n return countryToCurrency[country];\n}\n\nexport function formatMoneyCurrency(value: number, currency: IsoCurrencyCode) {\n const locale =\n currency in currencyToLocale ? currencyToLocale[currency] : \"en-US\";\n\n return new Intl.NumberFormat(locale, {\n style: \"currency\",\n currency: currency,\n }).format(value);\n}\n","import { z } from \"zod\";\nimport * as GlobalUtils from \"../utils/utils\";\n\nexport const CustomerFormSchema = z.strictObject({\n customer_name: z\n .string()\n .transform(GlobalUtils.normalizeSpaces)\n .pipe(\n z\n .string()\n .min(1, \"Customer name is required\")\n .max(50, \"Customer name must be at most 50 characters.\")\n ),\n\n customer_address: z\n .string()\n .transform(GlobalUtils.normalizeSpaces)\n .pipe(\n z.string().max(100, \"Customer address must be at most 100 characters.\")\n )\n .transform(GlobalUtils.transformEmptyStringToUndefined)\n .optional(),\n\n customer_phone_number: z\n .string()\n .transform(GlobalUtils.removeAllWhitespace)\n .transform(GlobalUtils.removeDashesAndPlusSign)\n .refine((s) => s === \"\" || /^\\d{4,15}$/.test(s), {\n error: \"Phone number must be from 4 to 15 digits.\",\n })\n .transform(GlobalUtils.transformEmptyStringToUndefined)\n .optional(),\n\n customer_email_address: z\n .string()\n .transform(GlobalUtils.removeAllWhitespace)\n .transform(GlobalUtils.transformEmptyStringToUndefined)\n .pipe(\n z\n .email()\n .max(254, \"Customer email must be at most 254 characters.\")\n .transform((email) => email.toLowerCase())\n .optional()\n )\n .optional(),\n\n tax_rate: GlobalUtils.handleZodCurrency(0, 100),\n});\n","import { z } from \"zod\";\nimport * as GlobalUtils from \"../utils/utils\";\n\nexport const ProductFormSchema = z\n .strictObject({\n product_name: z\n .string()\n .transform(GlobalUtils.normalizeSpaces)\n .pipe(\n z\n .string()\n .min(1, \"Product name is required\")\n .max(50, \"Product name must be at most 50 characters.\")\n ),\n\n product_description: z\n .string()\n .transform(GlobalUtils.normalizeSpaces)\n .pipe(\n z\n .string()\n .max(100, \"Product desription must be at most 100 characters.\")\n )\n .transform(GlobalUtils.transformEmptyStringToUndefined)\n .optional(),\n\n product_sku: z\n .string()\n .transform(GlobalUtils.normalizeSpaces)\n .pipe(z.string().max(30, \"Product SKU must be at most 30 characters.\"))\n .transform(GlobalUtils.transformEmptyStringToUndefined)\n .optional(),\n\n product_upc: z\n .string()\n .transform((s) => s.replace(/\\s+/g, \"\"))\n .refine((s) => s === \"\" || /^\\d{12}$/.test(s), {\n error: \"UPC must be exactly 12 digits\",\n })\n .transform(GlobalUtils.transformEmptyStringToUndefined)\n .optional(),\n\n product_gtin_14: z\n .string()\n .transform((s) => s.replace(/\\s+/g, \"\"))\n .refine((s) => s === \"\" || /^\\d{14}$/.test(s), {\n error: \"GTIN14 must be exactly 14 digits\",\n })\n .transform(GlobalUtils.transformEmptyStringToUndefined)\n .optional(),\n\n product_type: z.enum([\"unit\", \"weight\", \"case\"], {\n error: \"Product type must be unit, weight, or case.\",\n }),\n\n weight_unit: z.preprocess((v) => {\n if (v === \"\") return undefined;\n if (typeof v === \"string\") return v.trim().toLowerCase();\n return v;\n }, z.enum([\"kg\", \"lb\", \"g\", \"oz\"]).optional()),\n\n price: GlobalUtils.handleZodCurrency(0, 99_999.99),\n cost: GlobalUtils.handleZodCurrency(0, 99_999.99),\n })\n\n .superRefine((data, ctx) => {\n if (data.product_type === \"weight\" && !data.weight_unit) {\n ctx.addIssue({\n code: \"custom\",\n error: \"Weight unit is required.\",\n path: [\"weight_unit\"],\n });\n }\n\n if (\n data.product_type !== \"weight\" &&\n typeof data.weight_unit !== \"undefined\"\n ) {\n ctx.addIssue({\n code: \"custom\",\n error: \"Weight unit must be empty\",\n path: [\"weight_unit\"],\n });\n }\n });\n","import { z } from \"zod\";\n\nexport const CREATED_LOCATION = [\"web\", \"mobile\"] as const;\n\nexport type CreatedLocation = (typeof CREATED_LOCATION)[number];\n\nexport type IntBool = 0 | 1;\n\nexport const uuidSchema = z.uuid();\nexport type UUID = z.infer<typeof uuidSchema>;\n","import { z } from \"zod\";\nimport { CREDIT_TYPE, INVOICE_STATUS, INVOICE_TYPE } from \"./invoices_types\";\nimport { handleZodCurrency } from \"../../utils/utils\";\n\nconst YmdDateSchema = z.string().regex(/^\\d{4}-\\d{2}-\\d{2}$/, \"Use YYYY-MM-DD\");\n\nconst BaseInvoice = z\n .object({\n invoice_type: z.enum(INVOICE_TYPE, { error: \"Invoice type not found.\" }),\n invoice_date: YmdDateSchema,\n due_date: YmdDateSchema,\n tax_rate: z.number().default(0),\n tax_amount: z.number().default(0),\n warehouse_id: z.uuid().optional(),\n invoice_status: z.enum(INVOICE_STATUS).default(\"finalized\"),\n })\n .superRefine(({ invoice_date, due_date }, ctx) => {\n if (due_date < invoice_date) {\n ctx.addIssue({\n code: \"custom\",\n message: \"Due date can't be earlier than the invoice date.\",\n path: [\"due_date\"],\n });\n }\n });\n\nconst LineItemBase = z.object({\n invoice_id: z.uuid().optional(),\n product_id: z.uuid({ error: \"Select a product\" }),\n product_name: z.string().optional(),\n product_description: z.string().optional(),\n product_type: z.enum([\"unit\", \"weight\", \"case\"]).optional(),\n product_upc: z.string().optional(),\n weight_unit: z.enum([\"kg\", \"lb\", \"g\", \"oz\"]).optional(),\n quantity: handleZodCurrency(0.01, 99_999.99),\n});\n\nconst SalesItem = LineItemBase.safeExtend({\n price: handleZodCurrency(0, 99_999.99),\n credit_type: z.undefined(),\n});\n\nconst CreditItem = LineItemBase.safeExtend({\n price: handleZodCurrency(0, 99_999.99),\n credit_type: z.enum(CREDIT_TYPE, {\n error: \"Select a credit type\",\n }),\n});\n\nconst PurchaseItem = LineItemBase.safeExtend({\n price: handleZodCurrency(0, 99_999.99),\n credit_type: z.undefined(),\n});\n\nexport const SalesInvoiceSchema = BaseInvoice.safeExtend({\n invoice_type: z.literal(\"sales\"),\n party_id: z.uuid({ message: \"Select a customer\" }),\n invoice_items: z.array(SalesItem).min(1, \"Add at least one invoice item\"),\n});\n\nexport const CreditInvoiceSchema = BaseInvoice.safeExtend({\n invoice_type: z.literal(\"credit\"),\n party_id: z.uuid({ message: \"Select a customer\" }),\n invoice_items: z.array(CreditItem).min(1, \"Add at least one invoice item\"),\n});\n\nexport const PurchaseInvoiceSchema = BaseInvoice.safeExtend({\n invoice_type: z.literal(\"purchase\"),\n party_id: z.uuid({ message: \"Select a vendor\" }),\n invoice_items: z.array(PurchaseItem).min(1, \"Add at least one invoice item\"),\n});\n\nexport const AnyInvoiceSchema = z.discriminatedUnion(\"invoice_type\", [\n SalesInvoiceSchema,\n PurchaseInvoiceSchema,\n CreditInvoiceSchema,\n]);\n","import { z } from \"zod\";\nimport * as InvoiceSchemas from \"./invoices_schemas\";\n\nexport type SalesInvoice = z.infer<typeof InvoiceSchemas.SalesInvoiceSchema>;\nexport type CreditInvoice = z.infer<typeof InvoiceSchemas.CreditInvoiceSchema>;\nexport type PurchaseInvoice = z.infer<\n typeof InvoiceSchemas.PurchaseInvoiceSchema\n>;\nexport type AnyInvoiceOut = z.output<typeof InvoiceSchemas.AnyInvoiceSchema>;\n\nexport const INVOICE_TYPE = [\"sales\", \"credit\", \"purchase\"] as const;\n\nexport type InvoiceType = (typeof INVOICE_TYPE)[number];\n\nexport const INVOICE_STATUS = [\"finalized\", \"voided\"] as const;\n\nexport type InvoiceStatus = (typeof INVOICE_STATUS)[number];\n\nexport const CREDIT_TYPE = [\"dump\", \"return\"] as const;\n\nexport type CreditType = (typeof CREDIT_TYPE)[number];\n","// \"Today\" in the user's LOCAL timezone as YMD\nexport function todayLocalYmd(): string {\n const now = new Date();\n const y = now.getFullYear();\n const m = String(now.getMonth() + 1).padStart(2, \"0\");\n const d = String(now.getDate()).padStart(2, \"0\");\n return `${y}-${m}-${d}`;\n}\n\n// Add days in LOCAL time (no drift)\nexport function addDaysLocalYmd(ymd: string, days: number): string {\n const dt = localDateFromYmd(ymd);\n dt.setDate(dt.getDate() + days);\n return ymdFromLocalDate(dt);\n}\n\nexport function formatYmdLong(ymd: string, locale = \"en-US\"): string {\n const { y, m, d } = parseYmd(ymd);\n const utcDate = new Date(Date.UTC(y, m - 1, d)); // 00:00Z\n return new Intl.DateTimeFormat(locale, {\n dateStyle: \"long\",\n timeZone: \"UTC\",\n }).format(utcDate);\n}\n\nexport function localDateFromYmd(ymd: string): Date {\n const { y, m, d } = parseYmd(ymd);\n return new Date(y, m - 1, d); // LOCAL midnight\n}\n\nexport function ymdFromLocalDate(dt: Date): string {\n const y = dt.getFullYear();\n const m = String(dt.getMonth() + 1).padStart(2, \"0\");\n const d = String(dt.getDate()).padStart(2, \"0\");\n return `${y}-${m}-${d}`;\n}\n\nfunction parseYmd(ymd: string): { y: number; m: number; d: number } {\n const m = /^(\\d{4})-(\\d{2})-(\\d{2})$/.exec(ymd);\n if (!m) throw new Error(\"Bad YMD\");\n return { y: Number(m[1]), m: Number(m[2]), d: Number(m[3]) };\n}\n","import type { FieldError, FieldErrorsImpl, Merge } from \"react-hook-form\";\n\ntype RHFError =\n | string\n | FieldError\n | Merge<FieldError, FieldErrorsImpl<any>>\n | undefined;\n\nexport const getErrorMessage = (err: RHFError): string | undefined => {\n if (!err) return undefined;\n if (typeof err === \"string\") return err;\n // FieldError has .message (string | undefined)\n const msg = (err as FieldError).message as string | undefined;\n return typeof msg === \"string\" ? msg : undefined;\n};\n","export const exceedsTwoDecimals = (raw: string) => {\n const s = String(raw ?? \"\").replace(/[,\\s]/g, \"\");\n const dot = s.indexOf(\".\");\n if (dot === -1) return false;\n const after = s.slice(dot + 1);\n const digitsAfter = (after.match(/\\d/g) ?? []).length;\n return digitsAfter > 2;\n};\n"],"mappings":";AAAA,SAAS,KAAAA,UAAS;;;ACAX,IAAM,oBAAoB,CAAC,MAAM,IAAI;AAIrC,IAAM,aAAa,CAAC,SAAS,QAAQ;;;ACCrC,IAAM,oBAA6D;AAAA,EACxE,IAAI;AAAA,EACJ,IAAI;AACN;AAEO,IAAM,mBAAoD;AAAA,EAC/D,KAAK;AAAA,EACL,KAAK;AACP;;;ACLA,SAAS,SAAS;AAUX,SAAS,kBAAkB,WAAmB,WAAmB;AACtE,QAAM,aAAa,EAChB,OAAO;AAAA,IACN,OAAO;AAAA,EACT,CAAC,EACA,OAAO,CAAC,MAAM,EAAE,KAAK,EAAE,SAAS,GAAG,EAAE,OAAO,uBAAuB,CAAC,EACpE,UAAU,CAAC,MAAM,EAAE,QAAQ,UAAU,EAAE,CAAC,EACxC,OAAO,CAAC,MAAM,MAAM,MAAM,CAAC,OAAO,MAAM,OAAO,CAAC,CAAC,GAAG;AAAA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B,CAAC,QAAgB;AAAnD;AACE,QAAM,IAAI,OAAO,oBAAO,EAAE,EAAE,QAAQ,UAAU,EAAE;AAChD,QAAM,MAAM,EAAE,QAAQ,GAAG;AACzB,MAAI,QAAQ,GAAI,QAAO;AACvB,QAAM,QAAQ,EAAE,MAAM,MAAM,CAAC;AAC7B,QAAM,gBAAe,WAAM,MAAM,KAAK,MAAjB,YAAsB,CAAC,GAAG;AAC/C,SAAO,cAAc;AACvB;","names":["z","z","z","z","z","z","z","z","z","z"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@marmot-systems/common",
3
- "version": "2.0.29",
3
+ "version": "2.0.31",
4
4
  "description": "Schemas and utils shared across Marmot apps",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",