@marmot-systems/common 2.0.19 → 2.0.21

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
@@ -21,6 +21,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
21
21
  var index_exports = {};
22
22
  __export(index_exports, {
23
23
  CustomerFormSchema: () => CustomerFormSchema,
24
+ INVOICE_STATUS: () => INVOICE_STATUS,
24
25
  INVOICE_TYPE: () => INVOICE_TYPE,
25
26
  ProductFormSchema: () => ProductFormSchema,
26
27
  RegisterFormSchema: () => RegisterFormSchema,
@@ -203,6 +204,7 @@ var ProductFormSchema = import_zod4.z.strictObject({
203
204
 
204
205
  // src/types/invoices_types.ts
205
206
  var INVOICE_TYPE = ["sales", "credit", "purchase"];
207
+ var INVOICE_STATUS = ["finalized", "voided"];
206
208
 
207
209
  // src/types/shared_types.ts
208
210
  var import_zod5 = require("zod");
@@ -210,6 +212,7 @@ var uuidSchema = import_zod5.z.uuid();
210
212
  // Annotate the CommonJS export names for ESM import in node:
211
213
  0 && (module.exports = {
212
214
  CustomerFormSchema,
215
+ INVOICE_STATUS,
213
216
  INVOICE_TYPE,
214
217
  ProductFormSchema,
215
218
  RegisterFormSchema,
@@ -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/invoices_types.ts","../src/types/shared_types.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 {\n InvoiceType,\n InvoiceStatus,\n INVOICE_TYPE,\n} from \"./types/invoices_types\";\nexport { CreatedLocation, UUID } from \"./types/shared_types\";\nexport { SyncInvoice } from \"./types/sync_types\";\nexport * from \"./types/customers_types\";\nexport * from \"./types/vendors_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\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","export 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","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"],"mappings":";;;;;;;;;;;;;;;;;;;;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;AAAA,EACT,CAAC,EACA,OAAO,CAAC,MAAM,OAAO,SAAS,OAAO,CAAC,CAAC,GAAG;AAAA,IACzC,OAAO;AAAA,EACT,CAAC,EACA,OAAO,CAAC,MAAM,OAAO,CAAC,KAAK,GAAG,EAAE,OAAO,0BAA0B,CAAC,EAClE,UAAU,CAAC,MAAM,OAAO,CAAC,CAAC;AAE7B,QAAM,aAAa,aAChB,O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AM,GAAI,QAAO;AACrB,QAAI,OAAO,MAAM,SAAU,QAAO,EAAE,KAAK,EAAE,YAAY;AACvD,WAAO;AAAA,EACT,GAAG,cAAE,KAAK,CAAC,MAAM,MAAM,KAAK,IAAI,CAAC,EAAE,SAAS,CAAC;AAAA,EAE7C,OAAmB,kBAAkB,GAAG,QAAS;AAAA,EACjD,MAAkB,kBAAkB,GAAG,QAAS;AAClD,CAAC,EAEA,YAAY,CAAC,MAAM,QAAQ;AAC1B,MAAI,KAAK,iBAAiB,YAAY,CAAC,KAAK,aAAa;AACvD,QAAI,SAAS;AAAA,MACX,MAAM;AAAA,MACN,OAAO;AAAA,MACP,MAAM,CAAC,aAAa;AAAA,IACtB,CAAC;AAAA,EACH;AAEA,MACE,KAAK,iBAAiB,YACtB,OAAO,KAAK,gBAAgB,aAC5B;AACA,QAAI,SAAS;AAAA,MACX,MAAM;AAAA,MACN,OAAO;AAAA,MACP,MAAM,CAAC,aAAa;AAAA,IACtB,CAAC;AAAA,EACH;AACF,CAAC;;;ACpFI,IAAM,eAAe,CAAC,SAAS,UAAU,UAAU;;;ACA1D,IAAAC,cAAkB;AAQX,IAAM,aAAa,cAAE,KAAK;","names":["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/utils/types.ts","../src/utils/utils.ts","../src/schemas/customer_schemas.ts","../src/schemas/product_schemas.ts","../src/types/invoices_types.ts","../src/types/shared_types.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 * from \"./types/invoices_types\";\nexport { CreatedLocation, UUID } from \"./types/shared_types\";\nexport { SyncInvoice } from \"./types/sync_types\";\nexport * from \"./types/customers_types\";\nexport * from \"./types/vendors_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\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","export 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","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"],"mappings":";;;;;;;;;;;;;;;;;;;;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;AAAA,EACT,CAAC,EACA,OAAO,CAAC,MAAM,OAAO,SAAS,OAAO,CAAC,CAAC,GAAG;AAAA,IACzC,OAAO;AAAA,EACT,CAAC,EACA,OAAO,CAAC,MAAM,OAAO,CAAC,KAAK,GAAG,EAAE,OAAO,0BAA0B,CAAC,EAClE,UAAU,CAAC,MAAM,OAAO,CAAC,CAAC;AAE7B,QAAM,aAAa,aAChB,OAAO,EACP,OAAO,CAAC,MAAM,OAAO,SAAS,CAAC,GAAG,EAAE,OAAO,uBAAuB,CAAC,EACn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WAAO;AAAA,EACT,GAAG,cAAE,KAAK,CAAC,MAAM,MAAM,KAAK,IAAI,CAAC,EAAE,SAAS,CAAC;AAAA,EAE7C,OAAmB,kBAAkB,GAAG,QAAS;AAAA,EACjD,MAAkB,kBAAkB,GAAG,QAAS;AAClD,CAAC,EAEA,YAAY,CAAC,MAAM,QAAQ;AAC1B,MAAI,KAAK,iBAAiB,YAAY,CAAC,KAAK,aAAa;AACvD,QAAI,SAAS;AAAA,MACX,MAAM;AAAA,MACN,OAAO;AAAA,MACP,MAAM,CAAC,aAAa;AAAA,IACtB,CAAC;AAAA,EACH;AAEA,MACE,KAAK,iBAAiB,YACtB,OAAO,KAAK,gBAAgB,aAC5B;AACA,QAAI,SAAS;AAAA,MACX,MAAM;AAAA,MACN,OAAO;AAAA,MACP,MAAM,CAAC,aAAa;AAAA,IACtB,CAAC;AAAA,EACH;AACF,CAAC;;;ACpFI,IAAM,eAAe,CAAC,SAAS,UAAU,UAAU;AAInD,IAAM,iBAAiB,CAAC,aAAa,QAAQ;;;ACJpD,IAAAC,cAAkB;AAQX,IAAM,aAAa,cAAE,KAAK;","names":["import_zod","import_zod","import_zod","import_zod"]}
package/dist/index.d.cts CHANGED
@@ -166,4 +166,4 @@ type MappedVendors = {
166
166
  tax_rate: number;
167
167
  };
168
168
 
169
- export { type CreatedLocation, CustomerFormSchema, INVOICE_TYPE, type InventorySystem, type InvoiceStatus, type InvoiceType, type IsoCountryCode, type MappedCustomers, type MappedVendors, ProductFormSchema, RegisterFormSchema, type SyncInvoice, type UUID, type UserRole, formatMoneyCurrency, getCurrencyFromCountry, handleZodCurrency, normalizeSpaces, removeAllWhitespace, removeDashesAndPlusSign, roundWithPrecision, transformEmptyStringToUndefined };
169
+ export { type CreatedLocation, CustomerFormSchema, INVOICE_STATUS, INVOICE_TYPE, type InventorySystem, type InvoiceStatus, type InvoiceType, type IsoCountryCode, type MappedCustomers, type MappedVendors, ProductFormSchema, RegisterFormSchema, type SyncInvoice, type UUID, type UserRole, formatMoneyCurrency, getCurrencyFromCountry, handleZodCurrency, normalizeSpaces, removeAllWhitespace, removeDashesAndPlusSign, roundWithPrecision, transformEmptyStringToUndefined };
package/dist/index.d.ts CHANGED
@@ -166,4 +166,4 @@ type MappedVendors = {
166
166
  tax_rate: number;
167
167
  };
168
168
 
169
- export { type CreatedLocation, CustomerFormSchema, INVOICE_TYPE, type InventorySystem, type InvoiceStatus, type InvoiceType, type IsoCountryCode, type MappedCustomers, type MappedVendors, ProductFormSchema, RegisterFormSchema, type SyncInvoice, type UUID, type UserRole, formatMoneyCurrency, getCurrencyFromCountry, handleZodCurrency, normalizeSpaces, removeAllWhitespace, removeDashesAndPlusSign, roundWithPrecision, transformEmptyStringToUndefined };
169
+ export { type CreatedLocation, CustomerFormSchema, INVOICE_STATUS, INVOICE_TYPE, type InventorySystem, type InvoiceStatus, type InvoiceType, type IsoCountryCode, type MappedCustomers, type MappedVendors, ProductFormSchema, RegisterFormSchema, type SyncInvoice, type UUID, type UserRole, formatMoneyCurrency, getCurrencyFromCountry, handleZodCurrency, normalizeSpaces, removeAllWhitespace, removeDashesAndPlusSign, roundWithPrecision, transformEmptyStringToUndefined };
package/dist/index.js CHANGED
@@ -166,12 +166,14 @@ var ProductFormSchema = z4.strictObject({
166
166
 
167
167
  // src/types/invoices_types.ts
168
168
  var INVOICE_TYPE = ["sales", "credit", "purchase"];
169
+ var INVOICE_STATUS = ["finalized", "voided"];
169
170
 
170
171
  // src/types/shared_types.ts
171
172
  import { z as z5 } from "zod";
172
173
  var uuidSchema = z5.uuid();
173
174
  export {
174
175
  CustomerFormSchema,
176
+ INVOICE_STATUS,
175
177
  INVOICE_TYPE,
176
178
  ProductFormSchema,
177
179
  RegisterFormSchema,
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/invoices_types.ts","../src/types/shared_types.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","export 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","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"],"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,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;AAAA,EACT,CAAC,EACA,OAAO,CAAC,MAAM,OAAO,SAAS,OAAO,CAAC,CAAC,GAAG;AAAA,IACzC,OAAO;AAAA,EACT,CAAC,EACA,OAAO,CAAC,MAAM,OAAO,CAAC,KAAK,GAAG,EAAE,OAAO,0BAA0B,CAAC,EAClE,UAAU,CAAC,MAAM,OAAO,CAAC,CAAC;AAE7B,QAAM,aAAa,EAChB,OAAO,EACP,OAAO,CAAC,MAAM,OAAO,SAAS,CAAC,GAAG,EAAE,OAAO,uBAAuB,CAAC,EACnE,OAAO,CAAC,MAAM,KAAK,GAAG,EAAE,OAAO,0BAA0B,CAAC;AAE7D,SAAO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GAAGA,GAAE,KAAK,CAAC,MAAM,MAAM,KAAK,IAAI,CAAC,EAAE,SAAS,CAAC;AAAA,EAE7C,OAAmB,kBAAkB,GAAG,QAAS;AAAA,EACjD,MAAkB,kBAAkB,GAAG,QAAS;AAClD,CAAC,EAEA,YAAY,CAAC,MAAM,QAAQ;AAC1B,MAAI,KAAK,iBAAiB,YAAY,CAAC,KAAK,aAAa;AACvD,QAAI,SAAS;AAAA,MACX,MAAM;AAAA,MACN,OAAO;AAAA,MACP,MAAM,CAAC,aAAa;AAAA,IACtB,CAAC;AAAA,EACH;AAEA,MACE,KAAK,iBAAiB,YACtB,OAAO,KAAK,gBAAgB,aAC5B;AACA,QAAI,SAAS;AAAA,MACX,MAAM;AAAA,MACN,OAAO;AAAA,MACP,MAAM,CAAC,aAAa;AAAA,IACtB,CAAC;AAAA,EACH;AACF,CAAC;;;ACpFI,IAAM,eAAe,CAAC,SAAS,UAAU,UAAU;;;ACA1D,SAAS,KAAAC,UAAS;AAQX,IAAM,aAAaC,GAAE,KAAK;","names":["z","z","z","z","z","z","z","z"]}
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/invoices_types.ts","../src/types/shared_types.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","export 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","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"],"mappings":";AAAA,SAAS,KAAAA,UAAS;;;ACAX,IAAM,oBAAoB,CAAC,MAAM,IAAI;AAIrC,IAAM,aAAa,CAAC,SAAS,QAAQ;;;ACQrC,IAAM,oBAA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S;AAAA,MACX,MAAM;AAAA,MACN,OAAO;AAAA,MACP,MAAM,CAAC,aAAa;AAAA,IACtB,CAAC;AAAA,EACH;AACF,CAAC;;;ACpFI,IAAM,eAAe,CAAC,SAAS,UAAU,UAAU;AAInD,IAAM,iBAAiB,CAAC,aAAa,QAAQ;;;ACJpD,SAAS,KAAAC,UAAS;AAQX,IAAM,aAAaC,GAAE,KAAK;","names":["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.19",
3
+ "version": "2.0.21",
4
4
  "description": "Schemas and utils shared across Marmot apps",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",