Skip to content

Open-source manufacturing ERP, MES and QMS. Quoting, MRP, inventory, shop floor, quality and lot/serial traceability on one Postgres schema, with a REST API and MCP server. Self-host or use Carbon Cloud.

Revert "chore(deps): upgrade Zod 3.25 → 4.5 (#1576)" (#1579)

Sida7fdf9dcb52b
diff --git a/.claude/rules/workflow-edge-function.md b/.claude/rules/workflow-edge-function.md
index 6b6c3e3af0..ef23265f12 100644
--- a/.claude/rules/workflow-edge-function.md
+++ b/.claude/rules/workflow-edge-function.md
@@ -59,7 +59,7 @@ relative to the function dir):
```typescript
import { serve } from "https://deno.land/[email protected]/http/server.ts";
-import z from "npm:zod@^4.5.4";
+import z from "npm:zod@^3.24.1";
import { corsHeaders } from "../lib/headers.ts";
import { requirePermissions } from "../lib/supabase.ts";
import { Database } from "../lib/types.ts";
diff --git a/apps/erp/app/components/Configurator/ConfiguratorForm/ConfiguratorForm.ee.tsx b/apps/erp/app/components/Configurator/ConfiguratorForm/ConfiguratorForm.ee.tsx
index 86f49c6638..5ef81c9965 100644
--- a/apps/erp/app/components/Configurator/ConfiguratorForm/ConfiguratorForm.ee.tsx
+++ b/apps/erp/app/components/Configurator/ConfiguratorForm/ConfiguratorForm.ee.tsx
@@ -53,22 +53,22 @@ function getParameterSchema(parameter: ConfigurationParameter) {
case "numeric":
return zfd.numeric(
z.number({
- error: `${parameter.label} is required`
+ required_error: `${parameter.label} is required`
})
);
case "text":
return z.string({
- error: `${parameter.label} is required`
+ required_error: `${parameter.label} is required`
});
case "list":
return z.enum(parameter.listOptions as [string, ...string[]], {
- error: `${parameter.label} is required`
+ required_error: `${parameter.label} is required`
});
case "boolean":
return z.boolean();
case "material":
return z.string({
- error: `${parameter.label} is required`
+ required_error: `${parameter.label} is required`
});
default:
return z.any();
diff --git a/apps/erp/app/modules/account/ui/UserAttributes/UserAttributesForm.tsx b/apps/erp/app/modules/account/ui/UserAttributes/UserAttributesForm.tsx
index f001675d8d..ced2117fd6 100644
--- a/apps/erp/app/modules/account/ui/UserAttributes/UserAttributesForm.tsx
+++ b/apps/erp/app/modules/account/ui/UserAttributes/UserAttributesForm.tsx
@@ -14,6 +14,7 @@ import { useLocale } from "@react-aria/i18n";
import { useState } from "react";
import { LuFile, LuPaperclip } from "react-icons/lu";
import { useFetcher, useParams } from "react-router";
+import type { ZodSchema } from "zod";
import CustomerAvatar from "~/components/CustomerAvatar";
import { DateTime } from "~/components/DateTime";
import FileDropzone from "~/components/FileDropzone";
@@ -166,7 +167,7 @@ function TypedForm(
<ValidatedForm
method="post"
action={path.to.userAttribute(userId)}
- validator={attributeBooleanValidator}
+ validator={attributeBooleanValidator as ZodSchema}
defaultValues={{
userAttributeId,
userAttributeValueId,
diff --git a/apps/erp/app/modules/accounting/accounting.models.ts b/apps/erp/app/modules/accounting/accounting.models.ts
index 08baae32a9..c37163dc46 100644
--- a/apps/erp/app/modules/accounting/accounting.models.ts
+++ b/apps/erp/app/modules/accounting/accounting.models.ts
@@ -269,7 +269,7 @@ export const reportViewValidator = z.object({
.min(1, { message: "Name is required" })
.max(100, { message: "Name must be 100 characters or fewer" }),
visibility: z.enum(reportViewVisibilities, {
- error: "Visibility is required"
+ errorMap: () => ({ message: "Visibility is required" })
}),
config: z.string().min(2, { message: "Config is required" })
});
@@ -281,14 +281,20 @@ export const groupAccountValidator = z
parentId: zfd.text(z.string().optional()),
accountType: z
.enum(accountTypes, {
- error: "Account type is required"
+ errorMap: () => ({
+ message: "Account type is required"
+ })
})
.optional(),
incomeBalance: z.enum(incomeBalanceTypes, {
- error: "Income balance is required"
+ errorMap: () => ({
+ message: "Income balance is required"
+ })
}),
class: z.enum(accountClassTypes, {
- error: "Class is required"
+ errorMap: () => ({
+ message: "Class is required"
+ })
})
})
.refine(
@@ -330,14 +336,20 @@ export const accountValidator = z
isGroup: zfd.checkbox(),
accountType: z
.enum(accountTypes, {
- error: "Account type is required"
+ errorMap: () => ({
+ message: "Account type is required"
+ })
})
.optional(),
incomeBalance: z.enum(incomeBalanceTypes, {
- error: "Income balance is required"
+ errorMap: () => ({
+ message: "Income balance is required"
+ })
}),
class: z.enum(accountClassTypes, {
- error: "Class is required"
+ errorMap: () => ({
+ message: "Class is required"
+ })
}),
consolidatedRate: z.enum(consolidatedRateTypes)
})
@@ -380,10 +392,14 @@ export const accountValidator = z
export const fiscalYearSettingsValidator = z.object({
startMonth: z.enum(months, {
- error: "Start month is required"
+ errorMap: (issue, ctx) => ({
+ message: "Start month is required"
+ })
}),
taxStartMonth: z.enum(months, {
- error: "Tax start month is required"
+ errorMap: (issue, ctx) => ({
+ message: "Tax start month is required"
+ })
})
});
@@ -591,7 +607,9 @@ export const paymentTermValidator = z.object({
})
),
calculationMethod: z.enum(["Net", "End of Month", "Day of Month"], {
- error: "Calculation method is required"
+ errorMap: (issue, ctx) => ({
+ message: "Calculation method is required"
+ })
})
});
@@ -786,7 +804,7 @@ export const addCloseTaskValidator = z.object({
periodId: z.string().min(1, { message: "Period is required" }),
name: z.string().trim().min(1, { message: "Name is required" }),
taskType: z.enum(periodCloseTaskTypes, {
- error: "Task type is required"
+ errorMap: () => ({ message: "Task type is required" })
}),
required: zfd.checkbox(),
assigneeId: zfd.text(z.string().optional())
@@ -797,7 +815,7 @@ export const periodCloseTaskDefinitionValidator = z.object({
id: zfd.text(z.string().optional()),
name: z.string().trim().min(1, { message: "Name is required" }),
taskType: z.enum(periodCloseTaskTypes, {
- error: "Task type is required"
+ errorMap: () => ({ message: "Task type is required" })
}),
autoCheckKey: zfd.text(z.string().optional()),
sortOrder: zfd.numeric(z.number().int().min(0)),
@@ -853,7 +871,7 @@ export const dimensionValidator = z.object({
id: zfd.text(z.string().optional()),
name: z.string().trim().min(1, { message: "Name is required" }),
entityType: z.enum(dimensionEntityTypes, {
- error: "Entity type is required"
+ errorMap: () => ({ message: "Entity type is required" })
}),
active: zfd.checkbox(),
required: zfd.checkbox(),
@@ -888,7 +906,7 @@ export const fixedAssetClassValidator = z.object({
name: z.string().trim().min(1, { message: "Name is required" }),
description: z.string().optional(),
depreciationMethod: z.enum(depreciationMethods, {
- error: "Depreciation method is required"
+ errorMap: () => ({ message: "Depreciation method is required" })
}),
usefulLifeMonths: zfd.numeric(
z.number().int().positive({ message: "Useful life must be positive" })
@@ -942,7 +960,7 @@ export const fixedAssetValidator = z.object({
description: z.string().optional(),
serialNumber: z.string().optional(),
depreciationMethod: z.enum(depreciationMethods, {
- error: "Depreciation method is required"
+ errorMap: () => ({ message: "Depreciation method is required" })
}),
usefulLifeMonths: zfd.numeric(
z.number().int().positive({ message: "Useful life must be positive" })
diff --git a/apps/erp/app/modules/inventory/inventory.models.ts b/apps/erp/app/modules/inventory/inventory.models.ts
index dece2426d3..aafe651179 100644
--- a/apps/erp/app/modules/inventory/inventory.models.ts
+++ b/apps/erp/app/modules/inventory/inventory.models.ts
@@ -327,7 +327,9 @@ export const shippingMethodValidator = z.object({
id: zfd.text(z.string().optional()),
name: z.string().trim().min(1, { message: "Name is required" }),
carrier: z.enum(["UPS", "FedEx", "USPS", "DHL", "Other"], {
- error: "Carrier is required"
+ errorMap: () => ({
+ message: "Carrier is required"
+ })
}),
carrierAccountId: zfd.text(z.string().optional()),
trackingUrl: zfd.text(z.string().optional())
diff --git a/apps/erp/app/modules/invoicing/invoicing.models.ts b/apps/erp/app/modules/invoicing/invoicing.models.ts
index 338daab5e2..b8dac4fc73 100644
--- a/apps/erp/app/modules/invoicing/invoicing.models.ts
+++ b/apps/erp/app/modules/invoicing/invoicing.models.ts
@@ -109,7 +109,9 @@ export const purchaseInvoiceLineValidator = z
[...itemType, "Fixture", "G/L Account", "Fixed Asset", "Comment"],
{
- error: "Type is required"
+ errorMap: (issue, ctx) => ({
+ message: "Type is required"
+ })
}
),
purchaseOrderId: zfd.text(z.string().optional()),
@@ -269,7 +271,9 @@ export const salesInvoiceLineValidator = z
id: zfd.text(z.string().optional()),
invoiceId: z.string().min(1, { message: "Invoice is required" }),
invoiceLineType: z.enum([...itemType, "Fixture", "Fixed Asset"], {
- error: "Type is required"
+ errorMap: (issue, ctx) => ({
+ message: "Type is required"
+ })
}),
// Wrapped in zfd.text so an empty-string submission (the form always posts a
// hidden methodType) coerces to undefined instead of failing the enum check.
@@ -278,7 +282,9 @@ export const salesInvoiceLineValidator = z
methodType: zfd.text(
z
.enum(methodType, {
- error: "Method is required"
+ errorMap: (issue, ctx) => ({
+ message: "Method is required"
+ })
})
.optional()
),
@@ -368,7 +374,7 @@ export const memoValidator = z
id: zfd.text(z.string().optional()),
memoId: zfd.text(z.string().optional()),
direction: z.enum(memoDirection, {
- error: "Direction is required"
+ errorMap: () => ({ message: "Direction is required" })
}),
customerId: zfd.text(z.string().optional()),
supplierId: zfd.text(z.string().optional()),
@@ -403,7 +409,7 @@ export const paymentValidator = z
id: zfd.text(z.string().optional()),
paymentId: zfd.text(z.string().optional()),
paymentType: z.enum(paymentType, {
- error: "Payment type is required"
+ errorMap: () => ({ message: "Payment type is required" })
}),
customerId: zfd.text(z.string().optional()),
supplierId: zfd.text(z.string().optional()),
diff --git a/apps/erp/app/modules/items/items.models.ts b/apps/erp/app/modules/items/items.models.ts
index 37c7e9bda7..2b2c12504c 100644
--- a/apps/erp/app/modules/items/items.models.ts
+++ b/apps/erp/app/modules/items/items.models.ts
@@ -181,13 +181,19 @@ export const itemValidator = z.object({
// purchased item. Only surfaced/edited for Buy items in the Properties panel.
mpn: zfd.text(z.string().optional()),
replenishmentSystem: z.enum(itemReplenishmentSystems, {
- error: "Replenishment system is required"
+ errorMap: (issue, ctx) => ({
+ message: "Replenishment system is required"
+ })
}),
defaultMethodType: z.enum(methodType, {
- error: "Default method is required"
+ errorMap: (issue, ctx) => ({
+ message: "Default method is required"
+ })
}),
itemTrackingType: z.enum(itemTrackingTypes, {
- error: "Part type is required"
+ errorMap: (issue, ctx) => ({
+ message: "Part type is required"
+ })
}),
postingGroupId: zfd.text(z.string().optional()),
unitOfMeasureCode: z
@@ -227,8 +233,10 @@ export const itemValidator = z.object({
// Common storage / shelf-life refines. Shared across all item-type
// validators. Default Storage Unit is optional for every type - users can
// set it later via the pickMethod UI once they know where the item lives.
-const applyStorageAndShelfLifeRefines = <T extends z.ZodObject>(schema: T) => {
- const refined: z.ZodType<z.infer<T>, z.input<T>> = schema
+const applyStorageAndShelfLifeRefines = <T extends z.AnyZodObject>(
+ schema: T
+) => {
+ const refined: z.ZodEffects<z.ZodTypeAny, z.infer<T>, z.input<T>> = schema
.refine(
(data: z.infer<T>) =>
data.shelfLifeDays === undefined ||
@@ -308,7 +316,7 @@ const applyStorageAndShelfLifeRefines = <T extends z.ZodObject>(schema: T) => {
"Calculate from BOM requires a BoM - only Make or Buy and Make items qualify",
path: ["shelfLifeCalculateFromBom"]
}
- ) as unknown as z.ZodType<z.infer<T>, z.input<T>>;
+ ) as z.ZodEffects<z.ZodTypeAny, z.infer<T>, z.input<T>>;
return refined;
};
@@ -429,14 +437,20 @@ export const methodMaterialValidator = z.object({
makeMethodId: z.string().min(1, { message: "Make method is required" }),
order: zfd.numeric(z.number().min(0)),
itemType: z.enum(methodItemType, {
- error: "Item type is required"
+ errorMap: (issue, ctx) => ({
+ message: "Item type is required"
+ })
}),
kit: zfd.text(z.string().optional()).transform((value) => value === "true"),
methodType: z.enum(methodType, {
- error: "Method type is required"
+ errorMap: (issue, ctx) => ({
+ message: "Method type is required"
+ })
}),
sourcingType: z.enum(sourcingType, {
- error: "Sourcing type is required"
+ errorMap: (issue, ctx) => ({
+ message: "Sourcing type is required"
+ })
}),
itemId: z.string().optional(),
methodOperationId: zfd.text(z.string().optional()),
@@ -460,10 +474,14 @@ export const methodOperationValidator = z
makeMethodId: z.string().min(0, { message: "Make method is required" }),
order: zfd.numeric(z.number().min(0)),
operationOrder: z.enum(methodOperationOrders, {
- error: "Operation order is required"
+ errorMap: (issue, ctx) => ({
+ message: "Operation order is required"
+ })
}),
operationType: z.enum(operationTypes, {
- error: "Operation type is required"
+ errorMap: (issue, ctx) => ({
+ message: "Operation type is required"
+ })
}),
processId: z.string().min(1, { message: "Process is required" }),
workCenterId: zfd.text(z.string().optional()),
@@ -475,19 +493,19 @@ export const methodOperationValidator = z
),
setupUnit: z
.enum(standardFactorType, {
- error: "Setup unit is required"
+ errorMap: () => ({ message: "Setup unit is required" })
})
.optional(),
setupTime: zfd.numeric(z.number().min(0).optional()),
laborUnit: z
.enum(standardFactorType, {
- error: "Labor unit is required"
+ errorMap: () => ({ message: "Labor unit is required" })
})
.optional(),
laborTime: zfd.numeric(z.number().min(0).optional()),
machineUnit: z
.enum(standardFactorType, {
- error: "Machine unit is required"
+ errorMap: () => ({ message: "Machine unit is required" })
})
.optional(),
machineTime: zfd.numeric(z.number().min(0).optional()),
@@ -587,7 +605,9 @@ export const itemCostValidator = z.object({
itemId: z.string().min(1, { message: "Item ID is required" }),
itemPostingGroupId: zfd.text(z.string().optional()),
costingMethod: z.enum(itemCostingMethods, {
- error: "Costing method is required"
+ errorMap: () => ({
+ message: "Costing method is required"
+ })
}),
// standardCost: zfd.numeric(z.number().min(0)),
unitCost: zfd.numeric(z.number().min(0))
@@ -614,7 +634,9 @@ export const itemPlanningValidator = z
itemId: z.string().min(1, { message: "Item ID is required" }),
locationId: z.string().min(1, { message: "Location is required" }),
reorderingPolicy: z.enum(itemReorderingPolicies, {
- error: "Reordering policy is required"
+ errorMap: (issue, ctx) => ({
+ message: "Reordering policy is required"
+ })
}),
demandAccumulationPeriod: zfd.numeric(z.number().min(1).optional()),
demandAccumulationSafetyStock: zfd.numeric(z.number().min(0).optional()),
@@ -914,7 +936,9 @@ export const serviceValidator = applyStorageAndShelfLifeRefines(
.string()
.min(1, { message: "Unit of Measure is required" }),
replenishmentSystem: z.enum(serviceReplenishmentSystems, {
- error: "Replenishment system is required"
+ errorMap: (issue, ctx) => ({
+ message: "Replenishment system is required"
+ })
}),
// Services can never be shipped, received, or stocked
itemTrackingType: z.literal("Non-Inventory")
diff --git a/apps/erp/app/modules/items/items.service.ts b/apps/erp/app/modules/items/items.service.ts
index 479fc7f88f..7020cdf42e 100644
--- a/apps/erp/app/modules/items/items.service.ts
+++ b/apps/erp/app/modules/items/items.service.ts
@@ -4260,23 +4260,11 @@ export async function duplicateMethodOperationStep(
export async function upsertMethodOperationStepSlide(
client: SupabaseClient<Database>,
slide:
- | (Omit<
- z.infer<typeof operationStepSlideValidator>,
- "id" | "annotations"
- > & {
- annotations?: z.infer<
- typeof operationStepSlideValidator
- >["annotations"];
+ | (Omit<z.infer<typeof operationStepSlideValidator>, "id"> & {
companyId: string;
createdBy: string;
})
- | (Omit<
- z.infer<typeof operationStepSlideValidator>,
- "id" | "annotations"
- > & {
- annotations?: z.infer<
- typeof operationStepSlideValidator
- >["annotations"];
+ | (Omit<z.infer<typeof operationStepSlideValidator>, "id"> & {
id: string;
updatedBy: string;
updatedAt: string;
diff --git a/apps/erp/app/modules/production/production.models.ts b/apps/erp/app/modules/production/production.models.ts
index 30b101e790..9045e58ef3 100644
--- a/apps/erp/app/modules/production/production.models.ts
+++ b/apps/erp/app/modules/production/production.models.ts
@@ -216,7 +216,7 @@ const baseJobValidator = z.object({
customerId: zfd.text(z.string().optional()),
dueDate: zfd.text(z.string().optional()),
deadlineType: z.enum(deadlineTypes, {
- error: "Deadline type is required"
+ errorMap: () => ({ message: "Deadline type is required" })
}),
locationId: z.string().min(1, { message: "Location is required" }),
quantity: zfd.numeric(
@@ -249,7 +249,7 @@ export const bulkJobValidator = z
.string()
.min(1, { message: "Unit of measure is required" }),
deadlineType: z.enum(deadlineTypes, {
- error: "Deadline type is required"
+ errorMap: () => ({ message: "Deadline type is required" })
}),
dueDateOfFirstJob: zfd.text(z.string().optional()),
dueDateOfLastJob: zfd.text(z.string().optional()),
@@ -350,10 +350,14 @@ export const baseJobOperationValidator = z.object({
.min(1, { message: "Quote Make Method is required" }),
order: zfd.numeric(z.number().min(0)),
operationOrder: z.enum(methodOperationOrders, {
- error: "Operation order is required"
+ errorMap: (issue, ctx) => ({
+ message: "Operation order is required"
+ })
}),
operationType: z.enum(operationTypes, {
- error: "Operation type is required"
+ errorMap: (issue, ctx) => ({
+ message: "Operation type is required"
+ })
}),
processId: z.string().min(1, { message: "Process is required" }),
procedureId: zfd.text(z.string().optional()),
@@ -364,19 +368,19 @@ export const baseJobOperationValidator = z.object({
),
setupUnit: z
.enum(standardFactorType, {
- error: "Setup unit is required"
+ errorMap: () => ({ message: "Setup unit is required" })
})
.optional(),
setupTime: zfd.numeric(z.number().min(0).optional()),
laborUnit: z
.enum(standardFactorType, {
- error: "Labor unit is required"
+ errorMap: () => ({ message: "Labor unit is required" })
})
.optional(),
laborTime: zfd.numeric(z.number().min(0).optional()),
machineUnit: z
.enum(standardFactorType, {
- error: "Machine unit is required"
+ errorMap: () => ({ message: "Machine unit is required" })
})
.optional(),
machineTime: zfd.numeric(z.number().min(0).optional()),
@@ -748,10 +752,14 @@ const baseMaterialValidator = z.object({
description: z.string().min(1, { message: "Description is required" }),
jobMakeMethodId: z.string().min(1, { message: "Make method is required" }),
itemType: z.enum(methodItemType, {
- error: "Item type is required"
+ errorMap: (issue, ctx) => ({
+ message: "Item type is required"
+ })
}),
methodType: z.enum(methodType, {
- error: "Method type is required"
+ errorMap: (issue, ctx) => ({
+ message: "Method type is required"
+ })
}),
itemId: z.string().min(1, { message: "Item is required" }),
kit: zfd.text(z.string().optional()).transform((value) => value === "true"),
@@ -889,7 +897,7 @@ export const procedureStepValidator = z
name: z.string().trim().min(1, { message: "Name is required" }),
description: zfd.text(z.string().optional()),
type: z.enum(procedureStepType, {
- error: "Type is required"
+ errorMap: () => ({ message: "Type is required" })
}),
unitOfMeasureCode: zfd.text(z.string().optional()),
minValue: zfd.numeric(z.number().min(0).optional()),
@@ -955,7 +963,7 @@ export const productionEventValidator = z
id: zfd.text(z.string().optional()),
jobOperationId: z.string().min(1, { message: "Operation is required" }),
type: z.enum(["Labor", "Machine", "Setup"], {
- error: "Event type is required"
+ errorMap: () => ({ message: "Event type is required" })
}),
employeeId: zfd.text(z.string().optional()),
workCenterId: zfd.text(z.string().optional()),
@@ -997,7 +1005,7 @@ export const productionQuantityValidator = z
id: zfd.text(z.string().optional()),
jobOperationId: z.string().min(1, { message: "Operation is required" }),
type: z.enum(["Rework", "Scrap", "Production"], {
- error: "Quantity type is required"
+ errorMap: () => ({ message: "Quantity type is required" })
}),
scrapReasonId: zfd.text(z.string().optional()),
notes: zfd.text(z.string().optional()),
@@ -1786,7 +1794,7 @@ export const balloonCreateItemWithOverlayValidator = z
unit: z.string().nullable().optional(),
description: z.string().nullable().optional(),
type: z.enum(procedureStepType).optional(),
- data: z.record(z.string(), z.unknown()).optional()
+ data: z.record(z.unknown()).optional()
})
.strict();
@@ -1806,7 +1814,7 @@ export const balloonUpdateItemsValidator = z.array(
regionHeight: normalizedSizeValidator.optional(),
xCoordinate: normalizedCoordinateValidator.optional(),
yCoordinate: normalizedCoordinateValidator.optional(),
- data: z.record(z.string(), z.unknown()).optional()
+ data: z.record(z.unknown()).optional()
})
);
diff --git a/apps/erp/app/modules/production/production.service.ts b/apps/erp/app/modules/production/production.service.ts
index 95f69b0523..36c468fba5 100644
--- a/apps/erp/app/modules/production/production.service.ts
+++ b/apps/erp/app/modules/production/production.service.ts
@@ -3658,23 +3658,11 @@ export async function duplicateJobOperationStep(
export async function upsertJobOperationStepSlide(
client: SupabaseClient<Database>,
slide:
- | (Omit<
- z.infer<typeof operationStepSlideValidator>,
- "id" | "annotations"
- > & {
- annotations?: z.infer<
- typeof operationStepSlideValidator
- >["annotations"];
+ | (Omit<z.infer<typeof operationStepSlideValidator>, "id"> & {
companyId: string;
createdBy: string;
})
- | (Omit<
- z.infer<typeof operationStepSlideValidator>,
- "id" | "annotations"
- > & {
- annotations?: z.infer<
- typeof operationStepSlideValidator
- >["annotations"];
+ | (Omit<z.infer<typeof operationStepSlideValidator>, "id"> & {
id: string;
updatedBy: string;
updatedAt: string;
@@ -6826,23 +6814,11 @@ export async function getAssemblyInstructionStepSlides(
export async function upsertAssemblyInstructionStepSlide(
client: SupabaseClient<Database>,
slide:
- | (Omit<
- z.infer<typeof operationStepSlideValidator>,
- "id" | "annotations"
- > & {
- annotations?: z.infer<
- typeof operationStepSlideValidator
- >["annotations"];
+ | (Omit<z.infer<typeof operationStepSlideValidator>, "id"> & {
companyId: string;
createdBy: string;
})
- | (Omit<
- z.infer<typeof operationStepSlideValidator>,
- "id" | "annotations"
- > & {
- annotations?: z.infer<
- typeof operationStepSlideValidator
- >["annotations"];
+ | (Omit<z.infer<typeof operationStepSlideValidator>, "id"> & {
id: string;
updatedBy: string;
updatedAt: string;
diff --git a/apps/erp/app/modules/purchasing/purchasing.models.ts b/apps/erp/app/modules/purchasing/purchasing.models.ts
index 4325dd472d..8cf27dc327 100644
--- a/apps/erp/app/modules/purchasing/purchasing.models.ts
+++ b/apps/erp/app/modules/purchasing/purchasing.models.ts
@@ -128,7 +128,9 @@ export const purchaseOrderValidator = z.object({
id: zfd.text(z.string().optional()),
purchaseOrderId: zfd.text(z.string().optional()),
purchaseOrderType: z.enum(purchaseOrderTypeType, {
- error: "Type is required"
+ errorMap: (issue, ctx) => ({
+ message: "Type is required"
+ })
}),
status: z.enum(purchaseOrderStatusType).optional(),
supplierId: z.string().min(1, { message: "Supplier is required" }),
@@ -207,7 +209,9 @@ export const purchaseOrderLineValidator = z
purchaseOrderLineType: z.enum(
[...itemType, "Fixture", "G/L Account", "Fixed Asset"],
{
- error: "Type is required"
+ errorMap: (issue, ctx) => ({
+ message: "Type is required"
+ })
}
),
itemId: zfd.text(z.string().optional()),
@@ -352,7 +356,9 @@ export const supplierApprovalValidator = z.object({
readableId: zfd.text(z.string().optional()),
name: z.string().trim().min(1, { message: "Name is required" }),
supplierStatus: z.enum(supplierStatusType, {
- error: "Supplier status is required"
+ errorMap: (issue, ctx) => ({
+ message: "Supplier status is required"
+ })
}),
supplierTypeId: zfd.text(z.string().optional()),
accountManagerId: zfd.text(z.string().optional()),
@@ -445,7 +451,9 @@ export const supplierQuoteValidator = z
id: zfd.text(z.string().optional()),
supplierQuoteId: zfd.text(z.string().optional()),
supplierQuoteType: z.enum(purchaseOrderTypeType, {
- error: "Type is required"
+ errorMap: (issue, ctx) => ({
+ message: "Type is required"
+ })
}),
supplierId: z.string().min(1, { message: "Supplier is required" }),
supplierLocationId: zfd.text(z.string().optional()),
@@ -477,7 +485,7 @@ export const supplierQuoteLineValidator = z
id: zfd.text(z.string().optional()),
supplierQuoteId: z.string(),
supplierQuoteLineType: z.enum([...itemType, "G/L Account"], {
- error: "Type is required"
+ errorMap: () => ({ message: "Type is required" })
}),
itemId: zfd.text(z.string().optional()),
accountId: zfd.text(z.string().optional()),
diff --git a/apps/erp/app/modules/quality/quality.models.ts b/apps/erp/app/modules/quality/quality.models.ts
index 7c3267f6ee..27b9c02e59 100644
--- a/apps/erp/app/modules/quality/quality.models.ts
+++ b/apps/erp/app/modules/quality/quality.models.ts
@@ -262,7 +262,7 @@ export const issueWorkflowValidator = z.object({
const entityAssignmentItem = z.object({
trackedEntityId: z.string().min(1, { message: "Tracked entity is required" }),
quantity: z
- .number({ error: "Quantity is required" })
+ .number({ invalid_type_error: "Quantity is required" })
.positive({ message: "Quantity must be greater than zero" })
});
@@ -287,7 +287,7 @@ export const splitIssueItemValidator = z
itemId: z.string().min(1, { message: "Item is required" }),
splitQuantity: zfd.numeric(
z
- .number({ error: "Split quantity is required" })
+ .number({ invalid_type_error: "Split quantity is required" })
.positive({ message: "Split quantity must be greater than zero" })
.optional()
),
@@ -330,7 +330,7 @@ export const qualityDocumentStepValidator = z
name: z.string().trim().min(1, { message: "Name is required" }),
description: zfd.text(z.string().optional()),
type: z.enum(procedureStepType, {
- error: "Type is required"
+ errorMap: () => ({ message: "Type is required" })
}),
unitOfMeasureCode: zfd.text(z.string().optional()),
minValue: zfd.numeric(z.number().min(0).optional()),
@@ -445,7 +445,7 @@ export const inspectionSampleStatusType = [
export const inspectionValidator = z.object({
id: z.string().min(1, { message: "Id is required" }),
status: z.enum(["Passed", "Failed"], {
- error: "Status is required"
+ errorMap: () => ({ message: "Status is required" })
}),
notes: zfd.text(z.string().optional())
});
@@ -462,7 +462,7 @@ export const inspectionSampleValidator = z.object({
// "Pending" registers a sample without a verdict (identify-only scan when an
// inspection document drives per-feature measurements).
status: z.enum(["Pending", "Passed", "Failed"], {
- error: "Status is required"
+ errorMap: () => ({ message: "Status is required" })
}),
notes: zfd.text(z.string().optional())
});
@@ -470,7 +470,7 @@ export const inspectionSampleValidator = z.object({
export const inspectionDispositionValidator = z.object({
id: z.string().min(1, { message: "Id is required" }),
decision: z.enum(["Accept", "Reject", "Partial"], {
- error: "Decision is required"
+ errorMap: () => ({ message: "Decision is required" })
}),
notes: zfd.text(z.string().optional())
});
@@ -482,7 +482,7 @@ export const inspectionDocumentUsages = ["Receipt"] as const;
export const itemInspectionDocumentAssignmentValidator = z.object({
itemId: z.string().min(1, { message: "Item is required" }),
usage: z.enum(inspectionDocumentUsages, {
- error: "Usage is required"
+ errorMap: () => ({ message: "Usage is required" })
}),
// Empty clears the slot.
inspectionDocumentId: zfd.text(z.string().optional())
diff --git a/apps/erp/app/modules/resources/resources.models.ts b/apps/erp/app/modules/resources/resources.models.ts
index 69a52e8909..1c754f3421 100644
--- a/apps/erp/app/modules/resources/resources.models.ts
+++ b/apps/erp/app/modules/resources/resources.models.ts
@@ -303,11 +303,11 @@ export const processValidator = z
id: zfd.text(z.string().optional()),
name: z.string().trim().min(1, { message: "Process name is required" }),
processType: z.enum(operationTypes, {
- error: "Process type is required"
+ errorMap: () => ({ message: "Process type is required" })
}),
defaultStandardFactor: z
.enum(standardFactorType, {
- error: "Standard factor is required"
+ errorMap: () => ({ message: "Standard factor is required" })
})
.optional(),
workCenters: z
@@ -371,7 +371,7 @@ export const trainingQuestionValidator = z
trainingId: z.string().min(1, { message: "Training is required" }),
question: z.string().min(1, { message: "Question is required" }),
type: z.enum(trainingQuestionType, {
- error: "Type is required"
+ errorMap: () => ({ message: "Type is required" })
}),
sortOrder: zfd.numeric(z.number().min(0).optional()),
required: zfd.checkbox().optional(),
@@ -499,7 +499,7 @@ export const workCenterValidator = z.object({
name: z.string().trim().min(1, { message: "Name is required" }),
description: z.string(),
defaultStandardFactor: z.enum(standardFactorType, {
- error: "Standard factor is required"
+ errorMap: () => ({ message: "Standard factor is required" })
}),
departmentId: zfd.text(z.string().optional()),
laborRate: zfd.numeric(z.number().min(0)),
diff --git a/apps/erp/app/modules/sales/sales.models.ts b/apps/erp/app/modules/sales/sales.models.ts
index ec1b82fb78..e8cd00b86b 100644
--- a/apps/erp/app/modules/sales/sales.models.ts
+++ b/apps/erp/app/modules/sales/sales.models.ts
@@ -299,10 +299,9 @@ export const quoteValidator = z.object({
});
export const quoteLineAdditionalChargesValidator = z.record(
- z.string(),
z.object({
description: z.string(),
- amounts: z.record(z.string(), z.number()),
+ amounts: z.record(z.number()),
taxable: z.boolean().default(true)
})
);
@@ -322,7 +321,7 @@ export const costCategoryKeys = [
export type CostCategoryKey = (typeof costCategoryKeys)[number];
export const quoteLineCategoryMarkupsValidator = z
- .record(z.string(), z.number().min(0))
+ .record(z.number().min(0))
.default({});
export const quoteLineValidator = z.object({
@@ -331,12 +330,12 @@ export const quoteLineValidator = z.object({
itemType: z.enum(itemType).optional(),
itemId: z.string().min(1, { message: "Part is required" }),
status: z.enum(quoteLineStatusType, {
- error: "Status is required"
+ errorMap: () => ({ message: "Status is required" })
}),
estimatorId: zfd.text(z.string().optional()),
description: z.string().min(1, { message: "Description is required" }),
methodType: z.enum(methodType, {
- error: "Method is required"
+ errorMap: () => ({ message: "Method is required" })
}),
customerPartId: zfd.text(z.string().optional()),
customerPartRevision: zfd.text(z.string().optional()),
@@ -362,10 +361,14 @@ export const quoteMaterialValidator = z
.min(1, { message: "Make method is required" }),
order: zfd.numeric(z.number().min(0)),
itemType: z.enum(methodItemType, {
- error: "Item type is required"
+ errorMap: (issue, ctx) => ({
+ message: "Item type is required"
+ })
}),
methodType: z.enum(methodType, {
- error: "Method type is required"
+ errorMap: (issue, ctx) => ({
+ message: "Method type is required"
+ })
}),
itemId: z.string().min(1, { message: "Item is required" }),
kit: zfd.text(z.string().optional()).transform((value) => value === "true"),
@@ -426,10 +429,14 @@ export const quoteOperationValidator = z
.min(1, { message: "Quote Make Method is required" }),
order: zfd.numeric(z.number().min(0)),
operationOrder: z.enum(methodOperationOrders, {
- error: "Operation order is required"
+ errorMap: (issue, ctx) => ({
+ message: "Operation order is required"
+ })
}),
operationType: z.enum(operationTypes, {
- error: "Operation type is required"
+ errorMap: (issue, ctx) => ({
+ message: "Operation type is required"
+ })
}),
processId: z.string().min(1, { message: "Process is required" }),
procedureId: zfd.text(z.string().optional()),
@@ -441,19 +448,19 @@ export const quoteOperationValidator = z
),
setupUnit: z
.enum(standardFactorType, {
- error: "Setup unit is required"
+ errorMap: () => ({ message: "Setup unit is required" })
})
.optional(),
setupTime: zfd.numeric(z.number().min(0).optional()),
laborUnit: z
.enum(standardFactorType, {
- error: "Labor unit is required"
+ errorMap: () => ({ message: "Labor unit is required" })
})
.optional(),
laborTime: zfd.numeric(z.number().min(0).optional()),
machineUnit: z
.enum(standardFactorType, {
- error: "Machine unit is required"
+ errorMap: () => ({ message: "Machine unit is required" })
})
.optional(),
machineTime: zfd.numeric(z.number().min(0).optional()),
@@ -778,7 +785,9 @@ export const salesOrderLineValidator = z
id: zfd.text(z.string().optional()),
salesOrderId: z.string().min(1, { message: "Order is required" }),
salesOrderLineType: z.enum(salesOrderLineType, {
- error: "Type is required"
+ errorMap: (issue, ctx) => ({
+ message: "Type is required"
+ })
}),
accountId: zfd.text(z.string().optional()),
shippingCost: zfd.numeric(z.number().optional()),
@@ -795,7 +804,7 @@ export const salesOrderLineValidator = z
methodType: zfd.text(
z
.enum(methodType, {
- error: "Method is required"
+ errorMap: () => ({ message: "Method is required" })
})
.optional()
),
diff --git a/apps/erp/app/modules/settings/settings.models.ts b/apps/erp/app/modules/settings/settings.models.ts
index 56133a1a99..5441763d9e 100644
--- a/apps/erp/app/modules/settings/settings.models.ts
+++ b/apps/erp/app/modules/settings/settings.models.ts
@@ -429,7 +429,7 @@ export type Theme = (typeof themes)[number];
export const themeValidator = z.object({
next: zfd.text(z.string().optional()),
theme: z.enum(themes, {
- error: "Theme is required"
+ errorMap: (issue, ctx) => ({ message: "Theme is required" })
})
});
diff --git a/apps/erp/app/modules/shared/shared.models.ts b/apps/erp/app/modules/shared/shared.models.ts
index 0d07b4095c..5e09ddf81e 100644
--- a/apps/erp/app/modules/shared/shared.models.ts
+++ b/apps/erp/app/modules/shared/shared.models.ts
@@ -6,7 +6,7 @@ import { zfd } from "zod-form-data";
export const approvalDecisionValidator = z.object({
id: zfd.text(z.string().optional()),
decision: z.enum(["Approved", "Rejected"], {
- error: "Decision is required"
+ errorMap: () => ({ message: "Decision is required" })
}),
decisionNotes: zfd.text(z.string().optional())
});
@@ -32,7 +32,7 @@ export const approvalDocumentTypesWithAmounts: ApprovalDocumentType[] = [
export const approvalFiltersValidator = z.object({
documentType: z.enum(approvalDocumentType, {
- error: "Document type is required"
+ errorMap: () => ({ message: "Document type is required" })
}),
status: zfd.text(z.string().optional()),
dateFrom: zfd.text(z.string().optional()),
@@ -42,7 +42,7 @@ export const approvalFiltersValidator = z.object({
export const approvalRequestValidator = z.object({
id: zfd.text(z.string().optional()),
documentType: z.enum(approvalDocumentType, {
- error: "Document type is required"
+ errorMap: () => ({ message: "Document type is required" })
}),
documentId: zfd.text(
z.string().min(1, { message: "Document ID is required" })
@@ -53,7 +53,7 @@ export const approvalRequestValidator = z.object({
export const approvalRuleValidator = z.object({
id: zfd.text(z.string().optional()),
documentType: z.enum(approvalDocumentType, {
- error: "Document type is required"
+ errorMap: () => ({ message: "Document type is required" })
}),
approverGroupIds: z.array(
z.string().min(1, { message: "Invalid selection" })
@@ -313,7 +313,7 @@ export const operationStepValidator = z
return textToTiptap(String(val));
}),
type: z.enum(procedureStepType, {
- error: "Type is required"
+ errorMap: () => ({ message: "Type is required" })
}),
unitOfMeasureCode: zfd.text(z.string().optional()),
minValue: zfd.numeric(z.number().min(0).optional()),
@@ -457,7 +457,7 @@ export const savedViewValidator = z.object({
export const savedViewStateValidator = z.object({
columnOrder: z.array(z.string()),
columnPinning: z.any(),
- columnVisibility: z.record(z.string(), z.boolean()),
+ columnVisibility: z.record(z.boolean()),
filters: z.array(z.string()).optional(),
sorts: z.array(z.string()).optional()
});
diff --git a/apps/erp/app/modules/users/users.models.ts b/apps/erp/app/modules/users/users.models.ts
index 4a04dfc9ef..c532a2a857 100644
--- a/apps/erp/app/modules/users/users.models.ts
+++ b/apps/erp/app/modules/users/users.models.ts
@@ -38,10 +38,10 @@ export const createEmployeeValidator = z.object({
// even though the browser also enforces `required`.
export const itarEntityCertificationValidator = z.object({
authorityToBind: z.literal(true, {
- error: "You must confirm your authority to bind"
+ errorMap: () => ({ message: "You must confirm your authority to bind" })
}),
acceptRider: z.literal(true, {
- error: "You must accept the Rider"
+ errorMap: () => ({ message: "You must accept the Rider" })
}),
fullLegalName: z
.string()
@@ -57,13 +57,15 @@ export const itarEntityCertificationValidator = z.object({
// ITAR certification — Screen 2 (user U.S.-Person attestation).
export const itarUserCertificationValidator = z.object({
certifyUsPerson: z.literal(true, {
- error: "You must certify that you are a U.S. Person"
+ errorMap: () => ({ message: "You must certify that you are a U.S. Person" })
}),
agreeNotify: z.literal(true, {
- error: "You must agree to the notification requirement"
+ errorMap: () => ({
+ message: "You must agree to the notification requirement"
+ })
}),
understandPenalty: z.literal(true, {
- error: "You must acknowledge the penalties"
+ errorMap: () => ({ message: "You must acknowledge the penalties" })
}),
fullLegalName: z
.string()
diff --git a/apps/erp/app/modules/workflows/workflows.models.ts b/apps/erp/app/modules/workflows/workflows.models.ts
index 07f7aed68f..036a0c5d05 100644
--- a/apps/erp/app/modules/workflows/workflows.models.ts
+++ b/apps/erp/app/modules/workflows/workflows.models.ts
@@ -40,7 +40,7 @@ export const workflowTestRunValidator = z.object({
/** Parsed out of `triggerInput` after the form validator passes. */
export const workflowTestRunInputSchema = z.union([
z.object({ recordId: z.string().min(1) }),
- z.object({ outputs: z.record(z.string(), z.string().min(1)) }),
+ z.object({ outputs: z.record(z.string().min(1)) }),
z.object({})
]);
diff --git a/apps/erp/app/routes/api+/ai+/csv+/$table.columns.tsx b/apps/erp/app/routes/api+/ai+/csv+/$table.columns.tsx
index 61c9a916f9..c64ef559b8 100644
--- a/apps/erp/app/routes/api+/ai+/csv+/$table.columns.tsx
+++ b/apps/erp/app/routes/api+/ai+/csv+/$table.columns.tsx
@@ -12,7 +12,7 @@ const logger = getLogger("erp", "table-columns");
const inputSchema = z.object({
fileColumns: z.array(z.string())
- // firstRows: z.array(z.record(z.string(), z.string())),
+ // firstRows: z.array(z.record(z.string())),
});
export async function action({ request, params }: ActionFunctionArgs) {
diff --git a/apps/erp/app/routes/api+/mcp+/lib/tool-metadata.json b/apps/erp/app/routes/api+/mcp+/lib/tool-metadata.json
index dd52079a4b..b0db755c74 100644
--- a/apps/erp/app/routes/api+/mcp+/lib/tool-metadata.json
+++ b/apps/erp/app/routes/api+/mcp+/lib/tool-metadata.json
@@ -1,5 +1,5 @@
{
- "generated": "2026-09-05T04:01:08.809Z",
+ "generated": "2026-09-03T20:26:47.954Z",
"totalTools": 1495,
"modules": 15,
"tools": [
diff --git a/apps/erp/app/routes/x+/account+/$userId.attribute.tsx b/apps/erp/app/routes/x+/account+/$userId.attribute.tsx
index 6d21852ede..77573d3f8e 100644
--- a/apps/erp/app/routes/x+/account+/$userId.attribute.tsx
+++ b/apps/erp/app/routes/x+/account+/$userId.attribute.tsx
@@ -78,10 +78,7 @@ export async function action({ request, params }: ActionFunctionArgs) {
}
const upsertAttributeValue = await upsertUserAttributeValue(client, {
- // validator(v as ZodSchema) intentionally erases the union of attribute-value
- // schemas; v4's ZodSchema output is `unknown` (was `any` in v3), so restore the
- // permissive spread the runtime already relies on.
- ...(validation.data as any),
+ ...validation.data,
userId: targetUserId,
updatedBy: userId
});
diff --git a/apps/erp/app/routes/x+/production+/planning.update.tsx b/apps/erp/app/routes/x+/production+/planning.update.tsx
index d3dd374cf2..07133b8c0f 100644
--- a/apps/erp/app/routes/x+/production+/planning.update.tsx
+++ b/apps/erp/app/routes/x+/production+/planning.update.tsx
@@ -54,7 +54,7 @@ export async function action({ request }: ActionFunctionArgs) {
const parsedItems = itemsValidator.safeParse(items);
if (!parsedItems.success) {
- const errorMessages = parsedItems.error.issues.map((error) => {
+ const errorMessages = parsedItems.error.errors.map((error) => {
const path = error.path;
const field = path[path.length - 1];
@@ -79,7 +79,7 @@ export async function action({ request }: ActionFunctionArgs) {
return error.message;
});
- logger.error("Validation errors", { errors: parsedItems.error.issues });
+ logger.error("Validation errors", { errors: parsedItems.error.errors });
return data(
{
success: false,
diff --git a/apps/erp/app/routes/x+/purchasing+/planning.update.tsx b/apps/erp/app/routes/x+/purchasing+/planning.update.tsx
index 11e049d1be..fa1556c38e 100644
--- a/apps/erp/app/routes/x+/purchasing+/planning.update.tsx
+++ b/apps/erp/app/routes/x+/purchasing+/planning.update.tsx
@@ -54,7 +54,7 @@ export async function action({ request }: ActionFunctionArgs) {
const parsedItems = itemsValidator.safeParse(items);
if (!parsedItems.success) {
- const errorMessages = parsedItems.error.issues.map((error) => {
+ const errorMessages = parsedItems.error.errors.map((error) => {
const path = error.path;
const field = path[path.length - 1];
diff --git a/apps/erp/app/routes/x+/quality+/risks.new.tsx b/apps/erp/app/routes/x+/quality+/risks.new.tsx
index 6942f63239..1a2341b454 100644
--- a/apps/erp/app/routes/x+/quality+/risks.new.tsx
+++ b/apps/erp/app/routes/x+/quality+/risks.new.tsx
@@ -90,8 +90,7 @@ export default function NewRiskRoute() {
status: "Open",
severity: "1",
likelihood: "1",
- type: "Risk",
- notes: ""
+ type: "Risk"
}}
onClose={onClose}
/>
diff --git a/apps/erp/app/routes/x+/quote+/$quoteId.$lineId.cost.delete.tsx b/apps/erp/app/routes/x+/quote+/$quoteId.$lineId.cost.delete.tsx
index f6620c1e56..75a5aca815 100644
--- a/apps/erp/app/routes/x+/quote+/$quoteId.$lineId.cost.delete.tsx
+++ b/apps/erp/app/routes/x+/quote+/$quoteId.$lineId.cost.delete.tsx
@@ -35,7 +35,7 @@ export async function action({ request, params }: ActionFunctionArgs) {
quoteLineAdditionalChargesValidator.safeParse(additionalCharges);
if (parsedCharges.success === false) {
return data(
- { data: null, errors: parsedCharges.error.issues?.[0].message },
+ { data: null, errors: parsedCharges.error.errors?.[0].message },
{ status: 400 }
);
}
diff --git a/apps/erp/app/routes/x+/quote+/$quoteId.$lineId.cost.new.tsx b/apps/erp/app/routes/x+/quote+/$quoteId.$lineId.cost.new.tsx
index c750092e79..4f173b9e7f 100644
--- a/apps/erp/app/routes/x+/quote+/$quoteId.$lineId.cost.new.tsx
+++ b/apps/erp/app/routes/x+/quote+/$quoteId.$lineId.cost.new.tsx
@@ -35,7 +35,7 @@ export async function action({ request, params }: ActionFunctionArgs) {
quoteLineAdditionalChargesValidator.safeParse(additionalCharges);
if (parsedCharges.success === false) {
return data(
- { data: null, errors: parsedCharges.error.issues?.[0].message },
+ { data: null, errors: parsedCharges.error.errors?.[0].message },
{ status: 400 }
);
}
diff --git a/apps/erp/app/routes/x+/quote+/$quoteId.$lineId.recalculate-price.tsx b/apps/erp/app/routes/x+/quote+/$quoteId.$lineId.recalculate-price.tsx
index 3c14c24240..31f2db224d 100644
--- a/apps/erp/app/routes/x+/quote+/$quoteId.$lineId.recalculate-price.tsx
+++ b/apps/erp/app/routes/x+/quote+/$quoteId.$lineId.recalculate-price.tsx
@@ -33,8 +33,7 @@ export async function action({ request, params }: ActionFunctionArgs) {
);
const categoryMarkupsByQuantityValidator = z.record(
- z.string(),
- z.record(z.string(), z.number().min(0))
+ z.record(z.number().min(0))
);
const categoryMarkupsByQuantity =
categoryMarkupsByQuantityValidator.safeParse(
@@ -43,14 +42,14 @@ export async function action({ request, params }: ActionFunctionArgs) {
if (unitPricesByQuantity.success === false) {
return data(
- { data: null, errors: unitPricesByQuantity.error.issues?.[0].message },
+ { data: null, errors: unitPricesByQuantity.error.errors?.[0].message },
{ status: 400 }
);
}
if (quantities.success === false) {
return data(
- { data: null, errors: quantities.error.issues?.[0].message },
+ { data: null, errors: quantities.error.errors?.[0].message },
{ status: 400 }
);
}
diff --git a/apps/erp/app/routes/x+/shared+/import.$tableId.tsx b/apps/erp/app/routes/x+/shared+/import.$tableId.tsx
index fc2b6fb7eb..38483856db 100644
--- a/apps/erp/app/routes/x+/shared+/import.$tableId.tsx
+++ b/apps/erp/app/routes/x+/shared+/import.$tableId.tsx
@@ -41,7 +41,7 @@ export async function action({ request, params }: ActionFunctionArgs) {
const importResult = await importCsv(serviceRole, {
table,
filePath: filePath as string,
- columnMappings: columnMappings as Record<string, string>,
+ columnMappings,
enumMappings: enumMappings ? JSON.parse(enumMappings as string) : undefined,
companyId,
userId
diff --git a/apps/mes/app/services/itar.service.ts b/apps/mes/app/services/itar.service.ts
index 17e54c0d43..7ff3b3f626 100644
--- a/apps/mes/app/services/itar.service.ts
+++ b/apps/mes/app/services/itar.service.ts
@@ -15,10 +15,10 @@ const logger = getLogger("mes", "itar");
export const itarEntityCertificationValidator = z.object({
authorityToBind: z.literal(true, {
- error: "You must confirm your authority to bind"
+ errorMap: () => ({ message: "You must confirm your authority to bind" })
}),
acceptRider: z.literal(true, {
- error: "You must accept the Rider"
+ errorMap: () => ({ message: "You must accept the Rider" })
}),
fullLegalName: z
.string()
@@ -33,13 +33,15 @@ export const itarEntityCertificationValidator = z.object({
export const itarUserCertificationValidator = z.object({
certifyUsPerson: z.literal(true, {
- error: "You must certify that you are a U.S. Person"
+ errorMap: () => ({ message: "You must certify that you are a U.S. Person" })
}),
agreeNotify: z.literal(true, {
- error: "You must agree to the notification requirement"
+ errorMap: () => ({
+ message: "You must agree to the notification requirement"
+ })
}),
understandPenalty: z.literal(true, {
- error: "You must acknowledge the penalties"
+ errorMap: () => ({ message: "You must acknowledge the penalties" })
}),
fullLegalName: z
.string()
diff --git a/apps/mes/app/services/models.ts b/apps/mes/app/services/models.ts
index 77b66580e0..9eb07e44b6 100644
--- a/apps/mes/app/services/models.ts
+++ b/apps/mes/app/services/models.ts
@@ -144,10 +144,14 @@ export const productionEventValidator = z.object({
.string()
.min(1, { message: "Job Operation ID is required" }),
action: z.enum(productionEventAction, {
- error: "Action is required"
+ errorMap: (issue, ctx) => ({
+ message: "Action is required"
+ })
}),
type: z.enum(productionEventType, {
- error: "Type is required"
+ errorMap: (issue, ctx) => ({
+ message: "Type is required"
+ })
}),
workCenterId: zfd.text(z.string().optional()),
trackedEntityId: zfd.text(z.string().optional()),
@@ -234,13 +238,13 @@ export const triggerReworkValidator = z.object({
export const maintenanceDispatchValidator = z.object({
workCenterId: z.string().min(1, { message: "Work Center is required" }),
priority: z.enum(maintenanceDispatchPriority, {
- error: "Priority is required"
+ errorMap: () => ({ message: "Priority is required" })
}),
severity: z.enum(maintenanceSeverity, {
- error: "Severity is required"
+ errorMap: () => ({ message: "Severity is required" })
}),
oeeImpact: z.enum(oeeImpact, {
- error: "OEE Impact is required"
+ errorMap: () => ({ message: "OEE Impact is required" })
}),
suspectedFailureModeId: zfd.text(z.string().optional()),
actualFailureModeId: zfd.text(z.string().optional()),
@@ -263,7 +267,7 @@ export const qualityIssueValidator = z.object({
.string()
.min(1, { message: "Issue type is required" }),
priority: z.enum(qualityIssuePriority, {
- error: "Priority is required"
+ errorMap: () => ({ message: "Priority is required" })
}),
trackedEntityId: zfd.text(z.string().optional())
});
@@ -300,7 +304,7 @@ export const inspectionSampleValidator = z.object({
// "Pending" registers a sample without a verdict (identify-only scan when an
// inspection document drives per-feature measurements).
status: z.enum(["Pending", "Passed", "Failed"], {
- error: "Status is required"
+ errorMap: () => ({ message: "Status is required" })
}),
notes: zfd.text(z.string().optional())
});
@@ -315,7 +319,7 @@ export const inspectionSampleValidator = z.object({
export const inspectionDispositionValidator = z
.object({
decision: z.enum(["Accept", "Reject", "Partial"], {
- error: "Decision is required"
+ errorMap: () => ({ message: "Decision is required" })
}),
// The job operation, for postings + redirect back to the inspection view.
operationId: z.string().min(1, { message: "Operation is required" }),
diff --git a/packages/checks/src/conformance/no-default-on-effects.test.ts b/packages/checks/src/conformance/no-default-on-effects.test.ts
deleted file mode 100644
index 4d755001e8..0000000000
--- a/packages/checks/src/conformance/no-default-on-effects.test.ts
+++ /dev/null
@@ -1,79 +0,0 @@
-import { describe, expect, it } from "vitest";
-import { noDefaultOnEffects } from "./no-default-on-effects";
-
-describe("no-default-on-effects", () => {
- it("flags .default() after a transform", () => {
- const src = `const v = z.string().transform(Number).default(5);`;
- const violations = noDefaultOnEffects.scan("a.ts", src);
- expect(violations).toHaveLength(1);
- expect(violations[0]?.line).toBe(1);
- });
-
- it("flags .default() on a z.preprocess pipe", () => {
- const src = `const v = z.preprocess((s) => String(s).trim(), z.string()).default(" padded ");`;
- expect(noDefaultOnEffects.scan("a.ts", src)).toHaveLength(1);
- });
-
- it("flags .default() after refine and pipe across a multi-line chain", () => {
- const src = [
- "const v = z",
- " .object({ a: z.string() })",
- " .refine((d) => d.a.length > 0)",
- " .default({ a: 'x' });",
- "const w = z.string().pipe(z.coerce.number()).default(1);"
- ].join("\n");
- const violations = noDefaultOnEffects.scan("a.ts", src);
- expect(violations).toHaveLength(2);
- expect(violations.map((v) => v.line)).toEqual([4, 5]);
- });
-
- it("allows .default() on plain schemas, records, and coercions", () => {
- const src = [
- `const a = z.string().default("x");`,
- `const b = z.record(z.string(), z.number().min(0)).default({});`,
- `const c = z.coerce.boolean().default(false);`,
- `const d = z.enum(values).default("Draft");`
- ].join("\n");
- expect(noDefaultOnEffects.scan("a.ts", src)).toHaveLength(0);
- });
-
- it("allows .prefault() on effect-bearing schemas (that is the fix)", () => {
- const src = `const v = z.object({ a: z.string().default("x") }).prefault({});`;
- expect(noDefaultOnEffects.scan("a.ts", src)).toHaveLength(0);
- });
-
- it("does not cross into a previous statement's effects", () => {
- // The receiver walk stops at the statement boundary, so a transform in an
- // earlier statement never taints an innocent .default().
- const src = [
- `const other = z.string().transform(Number);`,
- `const v = z.string().default("x");`
- ].join("\n");
- expect(noDefaultOnEffects.scan("a.ts", src)).toHaveLength(0);
- });
-
- it("stops at a block boundary instead of leaking a previous block", () => {
- const src = [
- "if (x) { register(z.string().transform(Number)); }",
- `return z.string().default("x");`
- ].join("\n");
- expect(noDefaultOnEffects.scan("a.ts", src)).toHaveLength(0);
- });
-
- it("flags an inner-shape transform too — the default bypasses it as well", () => {
- // `.default({a: 1})` on this object returns the literal as-is; the shape's
- // transform never runs on it. That is the same v4 bypass, so it counts.
- const src = `const v = z.object({ a: z.string().transform(Number) }).default({ a: 1 });`;
- expect(noDefaultOnEffects.scan("a.ts", src)).toHaveLength(1);
- });
-
- it("uses the trimmed .default line as the snippet", () => {
- const src = [
- "const v = z.string().transform(Number)",
- " .default(5);"
- ].join("\n");
- const [violation] = noDefaultOnEffects.scan("a.ts", src);
- expect(violation?.snippet).toBe(".default(5);");
- expect(violation?.line).toBe(2);
- });
-});
diff --git a/packages/checks/src/conformance/no-default-on-effects.ts b/packages/checks/src/conformance/no-default-on-effects.ts
deleted file mode 100644
index b26b486dd3..0000000000
--- a/packages/checks/src/conformance/no-default-on-effects.ts
+++ /dev/null
@@ -1,77 +0,0 @@
-import type { ConformanceCheck, Violation } from "../check";
-
-// zod v4 changed `.default()` semantics: on `undefined` input the default value
-// is returned AS-IS — it is no longer parsed through the schema. On a chain that
-// carries a transform/refinement/pipe, the default therefore bypasses the effect
-// entirely: `z.string().min(3).transform(fn).default("ab")` silently emits "ab"
-// untransformed and unvalidated (v3 would have re-parsed it). Typecheck cannot
-// catch this — the literal satisfies the OUTPUT type either way. Use
-// `.prefault()` when the default must be parsed, or verify the literal is a
-// valid output and baseline the site.
-const EFFECTS =
- /\.(transform|refine|superRefine|check|overwrite|pipe)\s*\(|\bz\.preprocess\s*\(/;
-
-const DEFAULT_CALL = /\.default\s*\(/g;
-
-// Walk backwards from the `.` of `.default(` over the receiver expression:
-// balanced (...)/[...]/{...} groups plus identifier chars, dots, and
-// whitespace. Stops at anything else (an operator, `=`, the enclosing call's
-// open paren), which bounds the receiver to the chain `.default` is called on.
-function receiverBefore(text: string, dotIndex: number): string {
- let i = dotIndex - 1;
- while (i >= 0) {
- const c = text[i];
- if (c === undefined) break;
- // A bare `}` here is a block/statement boundary, not part of a schema
- // chain (an object literal in a chain sits inside an already-skipped call
- // group) — skipping it would leak a previous block into the receiver.
- if (c === "}") break;
- if (c === ")" || c === "]") {
- let depth = 1;
- i--;
- while (i >= 0 && depth > 0) {
- const ch = text[i];
- if (ch === ")" || ch === "]" || ch === "}") depth++;
- else if (ch === "(" || ch === "[" || ch === "{") depth--;
- i--;
- }
- continue;
- }
- if (/[\w$.\s]/.test(c)) {
- i--;
- continue;
- }
- break;
- }
- return text.slice(i + 1, dotIndex);
-}
-
-export const noDefaultOnEffects: ConformanceCheck = {
- id: "no-default-on-effects",
- description:
- "`.default()` on a schema with transforms/refinements/pipes is not re-parsed in zod v4 — use `.prefault()` when the default must run through the schema",
- provenance: {
- deprecates:
- "zod v3 `.default()` on effect-bearing schemas (the default was re-parsed through the schema)",
- replacedBy:
- "`.prefault()` when the default must be parsed; a verified output-typed literal otherwise",
- since: "2026-09-05"
- },
- scan(file: string, contents: string): Violation[] {
- const violations: Violation[] = [];
- for (const match of contents.matchAll(DEFAULT_CALL)) {
- const receiver = receiverBefore(contents, match.index);
- if (!EFFECTS.test(receiver)) continue;
- const line = contents.slice(0, match.index).split("\n").length;
- const lineText = contents.split("\n")[line - 1] ?? "";
- violations.push({
- file,
- line,
- snippet: lineText.trim(),
- message:
- "`.default()` after a transform/refine/pipe is NOT re-parsed in zod v4 — the value bypasses the effect. Use `.prefault()` to parse it, or verify the literal is a valid OUTPUT and baseline this site."
- });
- }
- return violations;
- }
-};
diff --git a/packages/checks/src/index.ts b/packages/checks/src/index.ts
index cd39f56931..04a50b7e8a 100644
--- a/packages/checks/src/index.ts
+++ b/packages/checks/src/index.ts
@@ -8,7 +8,6 @@ export type {
export { findClobbers, objectRefs } from "./clobber";
export { moduleShape } from "./conformance/module-shape";
export { noDbClientInService } from "./conformance/no-db-client-in-service";
-export { noDefaultOnEffects } from "./conformance/no-default-on-effects";
export { noDerivedPercentColumn } from "./conformance/no-derived-percent-column";
export { noInlineFractionDigits } from "./conformance/no-inline-fraction-digits";
export { noLegacyRls } from "./conformance/no-legacy-rls";
diff --git a/packages/checks/src/run.ts b/packages/checks/src/run.ts
index 06f0d23c87..471da2e464 100644
--- a/packages/checks/src/run.ts
+++ b/packages/checks/src/run.ts
@@ -8,7 +8,6 @@ import type {
} from "./check";
import { moduleShape } from "./conformance/module-shape";
import { noDbClientInService } from "./conformance/no-db-client-in-service";
-import { noDefaultOnEffects } from "./conformance/no-default-on-effects";
import { noDerivedPercentColumn } from "./conformance/no-derived-percent-column";
import { noInlineFractionDigits } from "./conformance/no-inline-fraction-digits";
import { noLegacyRls } from "./conformance/no-legacy-rls";
@@ -39,8 +38,7 @@ export const SERVER_CHECKS: ConformanceCheck[] = [
export const TS_CHECKS: ConformanceCheck[] = [
noRawRounding,
noInlineFractionDigits,
- noDbClientInService,
- noDefaultOnEffects
+ noDbClientInService
];
export const STRUCTURE_CHECKS: StructureCheck[] = [moduleShape];
diff --git a/packages/database/src/event.ts b/packages/database/src/event.ts
index 5a0f401aea..41bfa5821a 100644
--- a/packages/database/src/event.ts
+++ b/packages/database/src/event.ts
@@ -22,15 +22,15 @@ export const EventSchema = z.discriminatedUnion("operation", [
table: z.string(),
operation: z.enum(["UPDATE"]),
recordId: z.string(),
- new: z.record(z.string(), z.any()),
- old: z.record(z.string(), z.any()),
+ new: z.record(z.any()),
+ old: z.record(z.any()),
timestamp: z.string()
}),
z.object({
table: z.string(),
operation: z.enum(["INSERT"]),
recordId: z.string(),
- new: z.record(z.string(), z.any()),
+ new: z.record(z.any()),
old: z.null(),
timestamp: z.string()
}),
@@ -39,7 +39,7 @@ export const EventSchema = z.discriminatedUnion("operation", [
operation: z.enum(["DELETE", "TRUNCATE"]),
recordId: z.string(),
new: z.null(),
- old: z.record(z.string(), z.any()),
+ old: z.record(z.any()),
timestamp: z.string()
})
]);
@@ -48,7 +48,7 @@ export const QueueMessageSchema = z.object({
subscriptionId: z.string(),
triggerType: z.enum(["ROW", "STATEMENT"]),
handlerType: HandlerTypeSchema,
- handlerConfig: z.record(z.string(), z.any()),
+ handlerConfig: z.record(z.any()),
companyId: z.string(),
actorId: z.string().nullish(), // Captured from auth.uid() at trigger time
workflowRunId: z.string().nullish(), // Set when the write was made by a running workflow (workflow_run_id JWT claim)
@@ -75,9 +75,9 @@ export const CreateSubscriptionSchema = z.object({
type: HandlerTypeSchema,
// Configuration specific to the handler (URL for webhooks, WorkflowID for workflows)
// We allow any object here since it's stored as JSONB
- config: z.record(z.string(), z.any()).default({}),
+ config: z.record(z.any()).default({}),
// Database-level filtering (e.g. { status: "paid" })
- filter: z.record(z.string(), z.any()).default({}),
+ filter: z.record(z.any()).default({}),
// Defaults to true
active: z.boolean().default(true)
});
diff --git a/packages/database/supabase/functions/assign-serial-numbers/index.ts b/packages/database/supabase/functions/assign-serial-numbers/index.ts
index 9575f44734..cbef7a0a8d 100644
--- a/packages/database/supabase/functions/assign-serial-numbers/index.ts
+++ b/packages/database/supabase/functions/assign-serial-numbers/index.ts
@@ -1,6 +1,6 @@
import { serve } from "https://deno.land/[email protected]/http/server.ts";
import { sql } from "kysely";
-import { z } from "npm:zod@^4.5.4";
+import { z } from "npm:zod@^3.24.1";
import { DB, getConnectionPool, getDatabaseClient } from "../lib/database.ts";
import { corsPreflight, errorResponse, jsonResponse } from "../lib/response.ts";
diff --git a/packages/database/supabase/functions/close-job/index.ts b/packages/database/supabase/functions/close-job/index.ts
index 4691b32f46..9dc4a8bfc4 100644
--- a/packages/database/supabase/functions/close-job/index.ts
+++ b/packages/database/supabase/functions/close-job/index.ts
@@ -1,6 +1,6 @@
import { serve } from "https://deno.land/[email protected]/http/server.ts";
import { nanoid } from "https://deno.land/x/[email protected]/mod.ts";
-import z from "npm:zod@^4.5.4";
+import z from "npm:zod@^3.24.1";
import { DB, getConnectionPool, getDatabaseClient } from "../lib/database.ts";
import { datetime, getCompanyTimeZone } from "../lib/datetime.ts";
import { corsPreflight, errorResponse, jsonResponse } from "../lib/response.ts";
diff --git a/packages/database/supabase/functions/convert/index.ts b/packages/database/supabase/functions/convert/index.ts
index 9d9a90f2cd..ea8d6da953 100644
--- a/packages/database/supabase/functions/convert/index.ts
+++ b/packages/database/supabase/functions/convert/index.ts
@@ -1,11 +1,10 @@
import { serve } from "https://deno.land/[email protected]/http/server.ts";
-import { z } from "npm:zod@^4.5.4";
+import { z } from "npm:zod@^3.24.1";
import { DB, getConnectionPool, getDatabaseClient } from "../lib/database.ts";
import { datetime, getCompanyTimeZone } from "../lib/datetime.ts";
import { format } from "https://deno.land/[email protected]/datetime/format.ts";
-import { getFunctionLogger } from "../lib/logging.ts";
import { corsPreflight, errorResponse, jsonResponse } from "../lib/response.ts";
import { requirePermissions } from "../lib/supabase.ts";
import { Database } from "../lib/types.ts";
@@ -15,7 +14,6 @@ import { getRemainingQuantityToInvoice } from "../shared/short-close.ts";
const pool = getConnectionPool(2);
const db = getDatabaseClient<DB>(pool);
-const logger = getFunctionLogger("convert");
// Supabase/PostgREST caps a single response at 1000 rows. Page through with
// .range() so large reads (e.g. a quote's lines × quantity-break prices) are
@@ -163,7 +161,13 @@ serve(async (req: Request) => {
try {
const { type, id, companyId, userId } = payloadValidator.parse(payload);
- logger.info({ type, id, companyId, userId });
+ console.log({
+ function: "convert",
+ type,
+ id,
+ companyId,
+ userId,
+ });
const permissionsByType: Record<string, { view?: string | string[]; create?: string | string[]; update?: string | string[]; delete?: string | string[] }> = {
methodVersionToActive: { update: "resources" },
diff --git a/packages/database/supabase/functions/create/index.ts b/packages/database/supabase/functions/create/index.ts
index 71d2058863..1ca03a1e5a 100644
--- a/packages/database/supabase/functions/create/index.ts
+++ b/packages/database/supabase/functions/create/index.ts
@@ -3,8 +3,7 @@ import { nanoid } from "https://deno.land/x/[email protected]/mod.ts";
import { DB, getConnectionPool, getDatabaseClient } from "../lib/database.ts";
import { datetime, getCompanyTimeZone } from "../lib/datetime.ts";
-import z from "npm:zod@^4.5.4";
-import { getFunctionLogger } from "../lib/logging.ts";
+import z from "npm:zod@^3.24.1";
import { corsPreflight, errorResponse, jsonResponse } from "../lib/response.ts";
import { requirePermissions } from "../lib/supabase.ts";
import { Database } from "../lib/types.ts";
@@ -12,7 +11,6 @@ import { getNextSequence } from "../shared/get-next-sequence.ts";
const pool = getConnectionPool(1);
const db = getDatabaseClient<DB>(pool);
-const logger = getFunctionLogger("create");
// Resolves a fallback location when a caller omits locationId, so creating a
// blank shipment degrades gracefully instead of failing payload validation.
@@ -180,7 +178,11 @@ serve(async (req: Request) => {
case "nonConformanceTasks": {
const { id } = payload;
- logger.info({ type, id });
+ console.log({
+ function: "create",
+ type,
+ id,
+ });
try {
@@ -349,7 +351,7 @@ serve(async (req: Request) => {
});
}
- logger.debug({
+ console.log({
description: nonConformance.data?.description,
insertedContent,
});
@@ -414,7 +416,13 @@ serve(async (req: Request) => {
case "purchaseOrderFromJob": {
const { jobId, purchaseOrdersBySupplierId } = payload;
- logger.info({ type, jobId, companyId, userId });
+ console.log({
+ function: "create",
+ type,
+ jobId,
+ companyId,
+ userId,
+ });
try {
const [job, jobOperations] = await Promise.all([
@@ -729,7 +737,13 @@ serve(async (req: Request) => {
case "receiptDefault": {
const { locationId } = payload;
let createdDocumentId;
- logger.info({ type, locationId, companyId, userId });
+ console.log({
+ function: "create",
+ type,
+ locationId,
+ companyId,
+ userId,
+ });
try {
await db.transaction().execute(async (trx) => {
createdDocumentId = await getNextSequence(trx, "receipt", companyId);
@@ -760,7 +774,8 @@ serve(async (req: Request) => {
locationId: userLocationId,
} = payload;
- logger.info({
+ console.log({
+ function: "create",
type,
companyId,
purchaseOrderId,
@@ -1021,7 +1036,14 @@ serve(async (req: Request) => {
case "receiptFromInboundTransfer": {
const { warehouseTransferId, receiptId: existingReceiptId } = payload;
- logger.info({ type, companyId, warehouseTransferId, existingReceiptId, userId });
+ console.log({
+ function: "create",
+ type,
+ companyId,
+ warehouseTransferId,
+ existingReceiptId,
+ userId,
+ });
try {
@@ -1181,7 +1203,14 @@ serve(async (req: Request) => {
case "receiptFromWarehouseTransfer": {
const { warehouseTransferId, receiptId: existingReceiptId } = payload;
- logger.info({ type, companyId, warehouseTransferId, existingReceiptId, userId });
+ console.log({
+ function: "create",
+ type,
+ companyId,
+ warehouseTransferId,
+ existingReceiptId,
+ userId,
+ });
try {
@@ -1348,7 +1377,15 @@ serve(async (req: Request) => {
case "receiptLineSplit": {
const { receiptId, receiptLineId, quantity, locationId } = payload;
- logger.info({ type, locationId, receiptId, receiptLineId, quantity, userId });
+ console.log({
+ function: "create",
+ type,
+ locationId,
+ receiptId,
+ receiptLineId,
+ quantity,
+ userId,
+ });
try {
@@ -1364,7 +1401,9 @@ serve(async (req: Request) => {
.eq("attributes->> Receipt Line", receiptLineId),
]);
- logger.debug({ trackedEntities });
+ console.log({
+ trackedEntities,
+ });
if (!receiptLine.data) throw new Error("Receipt line not found");
@@ -1461,7 +1500,13 @@ serve(async (req: Request) => {
case "shipmentDefault": {
let createdDocumentId;
const { locationId } = payload;
- logger.info({ type, companyId, locationId, userId });
+ console.log({
+ function: "create",
+ type,
+ companyId,
+ locationId,
+ userId,
+ });
try {
const effectiveLocationId =
locationId ?? (await getFallbackLocationId(client, companyId, userId));
@@ -1492,7 +1537,8 @@ serve(async (req: Request) => {
case "shipmentFromWarehouseTransfer": {
const { warehouseTransferId, shipmentId: existingShipmentId } = payload;
- logger.info({
+ console.log({
+ function: "create",
type,
companyId,
warehouseTransferId,
@@ -1660,7 +1706,8 @@ serve(async (req: Request) => {
locationId,
} = payload;
- logger.info({
+ console.log({
+ function: "create",
type,
companyId,
locationId,
@@ -1853,7 +1900,8 @@ serve(async (req: Request) => {
locationId,
} = payload;
- logger.info({
+ console.log({
+ function: "create",
type,
companyId,
locationId,
@@ -2200,7 +2248,8 @@ serve(async (req: Request) => {
locationId,
} = payload;
- logger.info({
+ console.log({
+ function: "create",
type,
companyId,
locationId,
@@ -2456,7 +2505,15 @@ serve(async (req: Request) => {
case "shipmentLineSplit": {
const { shipmentId, shipmentLineId, quantity, locationId } = payload;
- logger.info({ type, locationId, shipmentId, shipmentLineId, quantity, userId });
+ console.log({
+ function: "create",
+ type,
+ locationId,
+ shipmentId,
+ shipmentLineId,
+ quantity,
+ userId,
+ });
try {
diff --git a/packages/database/supabase/functions/download/index.ts b/packages/database/supabase/functions/download/index.ts
index 0f834b5e62..eb9ba518fc 100644
--- a/packages/database/supabase/functions/download/index.ts
+++ b/packages/database/supabase/functions/download/index.ts
@@ -1,12 +1,9 @@
import { serve } from "https://deno.land/[email protected]/http/server.ts";
-import { z } from "npm:zod@^4.5.4";
+import { z } from "npm:zod@^3.24.1";
-import { getFunctionLogger } from "../lib/logging.ts";
import { corsPreflight, errorResponse, jsonResponse } from "../lib/response.ts";
import { requirePermissions } from "../lib/supabase.ts";
-const logger = getFunctionLogger("download");
-
const downloadValidator = z.object({
bucket: z.string(),
path: z.string(),
@@ -23,7 +20,13 @@ serve(async (req: Request) => {
const validatedPayload = downloadValidator.parse(payload);
const { bucket, path, companyId, userId } = validatedPayload;
- logger.info({ bucket, path, companyId, userId });
+ console.log({
+ function: "download",
+ bucket,
+ path,
+ companyId,
+ userId,
+ });
// verify that the request is authorized by an API key or service role
const serviceRole = await requirePermissions(req, companyId, userId, { view: "documents" });
diff --git a/packages/database/supabase/functions/embed/index.ts b/packages/database/supabase/functions/embed/index.ts
index 33de0ed8a3..13037f0284 100644
--- a/packages/database/supabase/functions/embed/index.ts
+++ b/packages/database/supabase/functions/embed/index.ts
@@ -1,14 +1,12 @@
import { serve } from "https://deno.land/[email protected]/http/server.ts";
import "jsr:@supabase/functions-js/edge-runtime.d.ts";
import { Kysely, sql } from "kysely";
-import z from "npm:zod@^4.5.4";
+import z from "npm:zod@^3.24.1";
import { generateEmbedding } from "../lib/ai/embedding.ts";
import { DB, getConnectionPool, getDatabaseClient } from "../lib/database.ts";
-import { getFunctionLogger } from "../lib/logging.ts";
const pool = getConnectionPool(1);
const db = getDatabaseClient<DB>(pool);
-const logger = getFunctionLogger("embed");
const jobSchema = z.object({
jobId: z.number(),
@@ -42,7 +40,10 @@ serve(async (req: Request) => {
// Use Zod to parse and validate the request body
const parseResult = z.array(jobSchema).safeParse(await req.json());
- logger.info(parseResult);
+ console.log({
+ function: "embed",
+ ...parseResult,
+ });
if (parseResult.error) {
return new Response(`invalid request body: ${parseResult.error.message}`, {
@@ -66,12 +67,7 @@ serve(async (req: Request) => {
await processJob(db, currentJob);
completedJobs.push(currentJob);
} catch (error) {
- logger.error("processJob failed", {
- error:
- error instanceof Error
- ? (error.stack ?? error.message)
- : JSON.stringify(error),
- });
+ console.error(error);
failedJobs.push({
...currentJob,
error: error instanceof Error ? error.message : JSON.stringify(error),
@@ -86,12 +82,7 @@ serve(async (req: Request) => {
} catch (error) {
// If the worker is terminating (e.g. wall clock limit reached),
// add pending jobs to fail list with termination reason
- logger.error("embed worker terminating", {
- error:
- error instanceof Error
- ? (error.stack ?? error.message)
- : JSON.stringify(error),
- });
+ console.error(error);
failedJobs.push(
...pendingJobs.map((job) => ({
...job,
@@ -101,7 +92,7 @@ serve(async (req: Request) => {
}
// Log completed and failed jobs for traceability
- logger.info("finished processing jobs", {
+ console.log("finished processing jobs:", {
completedJobs: completedJobs.length,
failedJobs: failedJobs.length,
});
@@ -133,17 +124,17 @@ serve(async (req: Request) => {
async function processJob(db: Kysely<DB>, job: Job) {
const { jobId, id, table } = job;
- logger.debug(`Processing job ${jobId} for ${table} with id ${id}`);
+ console.log(`Processing job ${jobId} for ${table} with id ${id}`);
if (table === "item") {
- logger.debug("Fetching item from database...");
+ console.log("Fetching item from database...");
const item = await db
.selectFrom("item")
.selectAll()
.where("id", "=", id)
.executeTakeFirst();
- logger.debug("Item fetched", {
+ console.log("Item fetched:", {
id: item?.id,
name: item?.name,
description: item?.description,
@@ -154,12 +145,12 @@ async function processJob(db: Kysely<DB>, job: Job) {
);
const textToEmbed = textParts.join(" ");
- logger.debug("Text to embed", { textToEmbed });
+ console.log("Text to embed:", textToEmbed);
const embedding = await generateEmbedding(textToEmbed);
const embeddingString = JSON.stringify(embedding);
- logger.debug("Updating item with embedding...", {
+ console.log("Updating item with embedding...", {
embeddingLength: embedding.length,
embeddingStringLength: embeddingString.length,
});
@@ -172,18 +163,18 @@ async function processJob(db: Kysely<DB>, job: Job) {
.where("id", "=", id)
.execute();
- logger.debug("Item update result", { result });
+ console.log("Item update result:", result);
}
if (table === "supplier") {
- logger.debug("Fetching supplier from database...");
+ console.log("Fetching supplier from database...");
const supplier = await db
.selectFrom("supplier")
.selectAll()
.where("id", "=", id)
.executeTakeFirst();
- logger.debug("Supplier fetched", {
+ console.log("Supplier fetched:", {
id: supplier?.id,
name: supplier?.name,
});
@@ -194,12 +185,12 @@ async function processJob(db: Kysely<DB>, job: Job) {
throw new Error(`Supplier ${id} has no name to embed`);
}
- logger.debug("Text to embed", { textToEmbed });
+ console.log("Text to embed:", textToEmbed);
const embedding = await generateEmbedding(textToEmbed);
const embeddingString = JSON.stringify(embedding);
- logger.debug("Updating supplier with embedding...", {
+ console.log("Updating supplier with embedding...", {
embeddingLength: embedding.length,
embeddingStringLength: embeddingString.length,
});
@@ -213,18 +204,18 @@ async function processJob(db: Kysely<DB>, job: Job) {
.where("id", "=", id)
.execute();
- logger.debug("Supplier update result", { result });
+ console.log("Supplier update result:", result);
}
if (table === "customer") {
- logger.debug("Fetching customer from database...");
+ console.log("Fetching customer from database...");
const customer = await db
.selectFrom("customer")
.selectAll()
.where("id", "=", id)
.executeTakeFirst();
- logger.debug("Customer fetched", {
+ console.log("Customer fetched:", {
id: customer?.id,
name: customer?.name,
});
@@ -235,12 +226,12 @@ async function processJob(db: Kysely<DB>, job: Job) {
throw new Error(`Customer ${id} has no name to embed`);
}
- logger.debug("Text to embed", { textToEmbed });
+ console.log("Text to embed:", textToEmbed);
const embedding = await generateEmbedding(textToEmbed);
const embeddingString = JSON.stringify(embedding);
- logger.debug("Updating customer with embedding...", {
+ console.log("Updating customer with embedding...", {
embeddingLength: embedding.length,
embeddingStringLength: embeddingString.length,
});
@@ -254,15 +245,15 @@ async function processJob(db: Kysely<DB>, job: Job) {
.where("id", "=", id)
.execute();
- logger.debug("Customer update result", { result });
+ console.log("Customer update result:", result);
}
- logger.debug(`Deleting job ${jobId} from queue...`);
+ console.log(`Deleting job ${jobId} from queue...`);
const deleteResult =
await sql`select pgmq.delete(${QUEUE_NAME}, ${jobId}::bigint)`.execute(db);
- logger.debug("Queue delete result", { deleteResult });
+ console.log("Queue delete result:", deleteResult);
- logger.debug(`Job ${jobId} processing completed successfully`);
+ console.log(`Job ${jobId} processing completed successfully`);
}
/**
diff --git a/packages/database/supabase/functions/get-method/index.ts b/packages/database/supabase/functions/get-method/index.ts
index e1d22efb56..07914f2baa 100644
--- a/packages/database/supabase/functions/get-method/index.ts
+++ b/packages/database/supabase/functions/get-method/index.ts
@@ -1,6 +1,6 @@
import { serve } from "https://deno.land/[email protected]/http/server.ts";
import { nanoid } from "https://deno.land/x/[email protected]/mod.ts";
-import { z } from "npm:zod@^4.5.4";
+import { z } from "npm:zod@^3.24.1";
import type {
PostgrestError,
@@ -27,7 +27,6 @@ import {
traverseJobMethodAsync,
traverseQuoteMethod,
} from "../lib/methods.ts";
-import { getFunctionLogger } from "../lib/logging.ts";
import { KyselyDatabase } from "../lib/postgres/index.ts";
import { importTypeScript } from "../lib/sandbox.ee.ts";
import { getStorageUnitId } from "../lib/storage-units.ts";
@@ -44,7 +43,6 @@ import { scrapAllowance } from "../shared/precision.ts";
const pool = getConnectionPool(1);
const db = getDatabaseClient<DB>(pool);
-const logger = getFunctionLogger("get-method");
// Stored configurator rules are user-authored JS that may still return legacy "Inside"/"Outside" operationType values.
const normalizeOperationType = (value: unknown) =>
@@ -161,9 +159,7 @@ const partsValidator = z.object({
tools: z.boolean().default(true),
steps: z.boolean().default(true),
workInstructions: z.boolean().default(true),
- // prefault, not default: v4's .default() returns {} AS-IS on undefined input,
- // which would skip every inner default and disable all six part flags.
-}).prefault({});
+}).default({});
const payloadValidator = z.object({
type: z.enum([
@@ -187,7 +183,7 @@ const payloadValidator = z.object({
targetId: z.string(),
companyId: z.string(),
userId: z.string(),
- configuration: z.record(z.string(), z.unknown()).optional(),
+ configuration: z.record(z.unknown()).optional(),
parts: partsValidator,
// A specific source makeMethod version (itemToJob / itemToJobMakeMethod
// only). Absent = the item's active method, as before.
@@ -211,7 +207,8 @@ serve(async (req: Request) => {
versionId,
} = payloadValidator.parse(payload);
- logger.info({
+ console.log({
+ function: "get-method",
type,
sourceId,
targetId,
@@ -868,9 +865,7 @@ serve(async (req: Request) => {
const result = await mod.configure(hydratedConfiguration);
return (result ?? defaultValue) as T;
} catch (err) {
- logger.error("configuration field resolver failed", {
- error: String((err as Error)?.stack ?? err),
- });
+ console.error(err);
return defaultValue;
}
}
@@ -2607,9 +2602,7 @@ serve(async (req: Request) => {
return (result ?? defaultValue) as T;
} catch (err) {
- logger.error("configuration field resolver failed", {
- error: String((err as Error)?.stack ?? err),
- });
+ console.error(err);
return defaultValue;
}
}
@@ -2625,7 +2618,7 @@ serve(async (req: Request) => {
node: MethodTreeItem,
parentQuoteMakeMethodId: string | null
) {
- logger.debug("[traverseMethod]", {
+ console.log("[traverseMethod]", {
isRoot: node.data.isRoot,
itemId: node.data.itemId,
methodType: node.data.methodType,
@@ -2738,7 +2731,7 @@ serve(async (req: Request) => {
processId,
op.workCenterId
);
- logger.debug({
+ console.log({
processId,
...operationRates,
});
@@ -3082,7 +3075,7 @@ serve(async (req: Request) => {
(child) => child.data.methodType === "Make to Order"
);
- logger.debug("[traverseMethod] materials", {
+ console.log("[traverseMethod] materials", {
totalChildren: materialsWithConfiguredFields.length,
madeMaterialsCount: madeMaterials.length,
madeChildrenCount: madeChildren.length,
@@ -3110,7 +3103,7 @@ serve(async (req: Request) => {
.where("parentMaterialId", "=", materialId)
.execute();
- logger.debug("[traverseMethod] processing made child", {
+ console.log("[traverseMethod] processing made child", {
index,
materialId,
newMakeMethodId,
@@ -3137,7 +3130,7 @@ serve(async (req: Request) => {
}
function logTree(node: MethodTreeItem, depth = 0) {
- logger.debug(" ".repeat(depth) + `[tree] ${node.data.itemId} (${node.data.methodType}, isRoot=${node.data.isRoot}, children=${node.children.length})`);
+ console.log(" ".repeat(depth) + `[tree] ${node.data.itemId} (${node.data.methodType}, isRoot=${node.data.isRoot}, children=${node.children.length})`);
for (const child of node.children) {
logTree(child, depth + 1);
}
@@ -3282,9 +3275,7 @@ serve(async (req: Request) => {
const result = await mod.configure(hydratedConfiguration);
return (result ?? defaultValue) as T;
} catch (err) {
- logger.error("configuration field resolver failed", {
- error: String((err as Error)?.stack ?? err),
- });
+ console.error(err);
return defaultValue;
}
}
@@ -6006,13 +5997,14 @@ serve(async (req: Request) => {
quoteOperations.error
) {
if (quoteMakeMethod.error) {
- logger.error("quoteMakeMethodError", { error: quoteMakeMethod.error });
+ console.log("quoteMakeMethodError");
+ console.log(quoteMakeMethod.error);
}
if (quoteMaterials.error) {
- logger.error("quoteMaterialsError", { error: quoteMaterials.error });
+ console.log(quoteMaterials.error);
}
if (quoteOperations.error) {
- logger.error("quoteOperationsError", { error: quoteOperations.error });
+ console.log(quoteOperations.error);
}
throw new Error("Failed to fetch quote data");
}
@@ -6536,9 +6528,7 @@ serve(async (req: Request) => {
]);
if (targetQuoteMakeMethod.error || !targetQuoteMakeMethod.data) {
- logger.error("Failed to get target quote make method", {
- error: targetQuoteMakeMethod.error,
- });
+ console.error(targetQuoteMakeMethod.error);
throw new Error("Failed to get target quote make method");
}
@@ -7108,9 +7098,7 @@ serve(async (req: Request) => {
]);
if (targetQuoteMakeMethod.error) {
- logger.error("Failed to get target quote make method", {
- error: targetQuoteMakeMethod.error,
- });
+ console.error(targetQuoteMakeMethod.error);
throw new Error("Failed to get target quote make method");
}
@@ -8167,9 +8155,7 @@ async function hydrateConfiguration(
return transformed;
} catch (err) {
- logger.error("configuration transform failed", {
- error: String((err as Error)?.stack ?? err),
- });
+ console.error(err);
return configuration;
}
}
diff --git a/packages/database/supabase/functions/import-csv/index.ts b/packages/database/supabase/functions/import-csv/index.ts
index 1512e6d1ac..22fa490be9 100644
--- a/packages/database/supabase/functions/import-csv/index.ts
+++ b/packages/database/supabase/functions/import-csv/index.ts
@@ -2,9 +2,8 @@ import { parse } from "https://deno.land/[email protected]/encoding/csv.ts";
import { serve } from "https://deno.land/[email protected]/http/server.ts";
import { nanoid } from "https://deno.land/x/[email protected]/mod.ts";
import { sql } from "npm:[email protected]";
-import z from "npm:zod@^4.5.4";
+import z from "npm:zod@^3.24.1";
import { DB, getConnectionPool, getDatabaseClient } from "../lib/database.ts";
-import { getFunctionLogger } from "../lib/logging.ts";
import { corsPreflight, errorResponse, jsonResponse } from "../lib/response.ts";
import { requirePermissions } from "../lib/supabase.ts";
import { Database } from "../lib/types.ts";
@@ -15,7 +14,6 @@ import { importMethods } from "./method-import.ts";
const pool = getConnectionPool(1);
const db = getDatabaseClient<DB>(pool);
-const logger = getFunctionLogger("import-csv");
const importCsvValidator = z.object({
table: z.enum([
@@ -42,10 +40,8 @@ const importCsvValidator = z.object({
"materialDimension",
]),
filePath: z.string(),
- columnMappings: z.record(z.string(), z.string()),
- enumMappings: z
- .record(z.string(), z.record(z.string(), z.string()))
- .optional(),
+ columnMappings: z.record(z.string()),
+ enumMappings: z.record(z.record(z.string())).optional(),
companyId: z.string(),
userId: z.string(),
});
@@ -957,7 +953,15 @@ serve(async (req: Request) => {
userId,
} = importCsvValidator.parse(payload);
- logger.info({ table, filePath, columnMappings, enumMappings, companyId, userId });
+ console.log({
+ function: "import-csv",
+ table,
+ filePath,
+ columnMappings,
+ enumMappings,
+ companyId,
+ userId,
+ });
const client = await requirePermissions(req, companyId, userId, { create: "resources" });
@@ -1139,7 +1143,7 @@ serve(async (req: Request) => {
}
}
- logger.info({
+ console.log({
totalRecords: mappedRecords.length,
customerInserts: customerInserts.length,
customerUpdates: customerUpdates.length,
@@ -1340,7 +1344,7 @@ serve(async (req: Request) => {
}
}
- logger.info({
+ console.log({
totalRecords: mappedRecords.length,
supplierInserts: supplierInserts.length,
supplierUpdates: supplierUpdates.length,
@@ -1967,7 +1971,7 @@ serve(async (req: Request) => {
}
}
- logger.info({
+ console.log({
totalRecords: mappedRecords.length,
itemInserts: itemInserts.length,
itemUpdates: itemUpdates.length,
@@ -2134,7 +2138,7 @@ serve(async (req: Request) => {
summary.inserted += contactInserts.length;
summary.updated += contactUpdates.length;
- logger.info({
+ console.log({
totalRecords: mappedRecords.length,
contactInserts: contactInserts.length,
contactUpdates: contactUpdates.length,
@@ -2254,7 +2258,7 @@ serve(async (req: Request) => {
summary.inserted += contactInserts.length;
summary.updated += contactUpdates.length;
- logger.info({
+ console.log({
totalRecords: mappedRecords.length,
contactInserts: contactInserts.length,
contactUpdates: contactUpdates.length,
@@ -2367,7 +2371,7 @@ serve(async (req: Request) => {
}
}
- logger.info({
+ console.log({
totalRecords: mappedRecords.length,
workCenterInserts: workCenterInserts.length,
workCenterUpdates: workCenterUpdates.length,
@@ -2476,7 +2480,7 @@ serve(async (req: Request) => {
}
}
- logger.info({
+ console.log({
totalRecords: mappedRecords.length,
processInserts: processInserts.length,
processUpdates: processUpdates.length,
@@ -2783,7 +2787,7 @@ serve(async (req: Request) => {
}
}
- logger.info({
+ console.log({
totalRecords: mappedRecords.length,
storageUnitInserts: inserts.length,
storageUnitUpdates: updates.length,
diff --git a/packages/database/supabase/functions/issue/index.ts b/packages/database/supabase/functions/issue/index.ts
index 2453c296cd..f60eefbbdd 100644
--- a/packages/database/supabase/functions/issue/index.ts
+++ b/packages/database/supabase/functions/issue/index.ts
@@ -1,13 +1,12 @@
import { serve } from "https://deno.land/[email protected]/http/server.ts";
import { type CalendarDate, parseDate } from "@internationalized/date";
import { Transaction } from "kysely";
-import { z } from "npm:zod@^4.5.4";
+import { z } from "npm:zod@^3.24.1";
import { DB, getConnectionPool, getDatabaseClient } from "../lib/database.ts";
import { datetime, getCompanyTimeZone } from "../lib/datetime.ts";
import { nanoid } from "https://deno.land/x/[email protected]/nanoid.ts";
-import { getFunctionLogger } from "../lib/logging.ts";
import { corsPreflight, errorResponse, jsonResponse } from "../lib/response.ts";
import {
getStorageUnitWithHighestQuantity,
@@ -810,7 +809,6 @@ async function createMaterialWipEntries(
const pool = getConnectionPool(1);
const db = getDatabaseClient<DB>(pool);
-const logger = getFunctionLogger("issue");
const payloadValidator = z.discriminatedUnion("type", [
z.object({
@@ -990,12 +988,15 @@ serve(async (req: Request) => {
const preflight = corsPreflight(req);
if (preflight) return preflight;
const payload = await req.json();
- logger.info({ payload });
+ console.log({ payload });
try {
const validatedPayload = payloadValidator.parse(payload);
- logger.info(validatedPayload);
+ console.log({
+ function: "issue",
+ ...validatedPayload,
+ });
const itemLedgerInserts: Database["public"]["Tables"]["itemLedger"]["Insert"][] =
[];
@@ -1874,9 +1875,10 @@ serve(async (req: Request) => {
signal: AbortSignal.timeout(10_000),
});
} catch (rescheduleError) {
- logger.error("Failed to trigger reschedule after scrap", {
- error: String((rescheduleError as Error)?.stack ?? rescheduleError),
- });
+ console.error(
+ "Failed to trigger reschedule after scrap:",
+ rescheduleError
+ );
}
return jsonResponse({
@@ -2674,9 +2676,10 @@ serve(async (req: Request) => {
signal: AbortSignal.timeout(10_000),
});
} catch (rescheduleError) {
- logger.error("Failed to trigger reschedule after scrap", {
- error: String((rescheduleError as Error)?.stack ?? rescheduleError),
- });
+ console.error(
+ "Failed to trigger reschedule after scrap:",
+ rescheduleError
+ );
}
}
@@ -3241,7 +3244,7 @@ serve(async (req: Request) => {
.where("id", "=", actualMaterialId)
.execute();
- logger.info("Job material quantity updated", {
+ console.log("Job material quantity updated:", {
materialId: actualMaterialId,
newQuantityIssued,
});
@@ -3740,7 +3743,7 @@ serve(async (req: Request) => {
await trx.insertInto("itemLedger").values(ledgerEntries).execute();
}
- logger.info("Entity converted", {
+ console.log("Entity converted:", {
trackedEntityId,
oldRevision: oldItem.revision,
newRevision,
diff --git a/packages/database/supabase/functions/pick/index.ts b/packages/database/supabase/functions/pick/index.ts
index 45da94b6ac..bbb71e1037 100644
--- a/packages/database/supabase/functions/pick/index.ts
+++ b/packages/database/supabase/functions/pick/index.ts
@@ -1,15 +1,13 @@
import { serve } from "https://deno.land/[email protected]/http/server.ts";
-import { z } from "npm:zod@^4.5.4";
+import { z } from "npm:zod@^3.24.1";
import { DB, getConnectionPool, getDatabaseClient } from "../lib/database.ts";
-import { getFunctionLogger } from "../lib/logging.ts";
import { requirePermissions } from "../lib/supabase.ts";
import { corsPreflight, errorResponse } from "../lib/response.ts";
const pool = getConnectionPool(1);
const db = getDatabaseClient<DB>(pool);
-const logger = getFunctionLogger("pick");
const payloadValidator = z.discriminatedUnion("type", [
z.object({
@@ -48,7 +46,12 @@ serve(async (req: Request) => {
try {
const { type, companyId, userId } = payloadValidator.parse(payload);
- logger.info({ type, companyId, userId });
+ console.log({
+ function: "pick",
+ type,
+ companyId,
+ userId,
+ });
const client = await requirePermissions(req, companyId, userId, { update: "inventory" });
@@ -61,9 +64,7 @@ serve(async (req: Request) => {
return errorResponse("Invalid operation type", 400);
}
} catch (error) {
- logger.error("pick failed", {
- error: String((error as Error)?.stack ?? error),
- });
+ console.error("Error in pick:", error);
return errorResponse(error, 500);
}
});
diff --git a/packages/database/supabase/functions/post-memo/index.ts b/packages/database/supabase/functions/post-memo/index.ts
index bc058c2092..6f1c519b36 100644
--- a/packages/database/supabase/functions/post-memo/index.ts
+++ b/packages/database/supabase/functions/post-memo/index.ts
@@ -1,9 +1,8 @@
import { serve } from "https://deno.land/[email protected]/http/server.ts";
import { nanoid } from "https://deno.land/x/[email protected]/mod.ts";
-import z from "npm:zod@^4.5.4";
+import z from "npm:zod@^3.24.1";
import { DB, getConnectionPool, getDatabaseClient } from "../lib/database.ts";
import { datetime, getCompanyTimeZone } from "../lib/datetime.ts";
-import { getFunctionLogger } from "../lib/logging.ts";
import { corsPreflight, errorResponse, jsonResponse } from "../lib/response.ts";
import { getSupabaseServiceRole } from "../lib/supabase.ts";
@@ -14,7 +13,6 @@ import { buildMemoJournal, type MemoJournalLine } from "./build-memo-journal.ts"
const pool = getConnectionPool(1);
const db = getDatabaseClient<DB>(pool);
-const logger = getFunctionLogger("post-memo");
const payloadValidator = z.object({
type: z.enum(["post", "void"]).default("post"),
@@ -32,7 +30,7 @@ serve(async (req: Request) => {
try {
const { type, memoId, userId, companyId } = payloadValidator.parse(payload);
- logger.info({ type, memoId, userId, companyId });
+ console.log({ function: "post-memo", type, memoId, userId, companyId });
const client = await getSupabaseServiceRole(
req.headers.get("Authorization"),
diff --git a/packages/database/supabase/functions/post-payment/index.ts b/packages/database/supabase/functions/post-payment/index.ts
index bc94c688a1..8c49036dd7 100644
--- a/packages/database/supabase/functions/post-payment/index.ts
+++ b/packages/database/supabase/functions/post-payment/index.ts
@@ -1,9 +1,8 @@
import { serve } from "https://deno.land/[email protected]/http/server.ts";
import { nanoid } from "https://deno.land/x/[email protected]/mod.ts";
-import z from "npm:zod@^4.5.4";
+import z from "npm:zod@^3.24.1";
import { DB, getConnectionPool, getDatabaseClient } from "../lib/database.ts";
import { datetime, getCompanyTimeZone } from "../lib/datetime.ts";
-import { getFunctionLogger } from "../lib/logging.ts";
import { corsPreflight, errorResponse, jsonResponse } from "../lib/response.ts";
import { getSupabaseServiceRole } from "../lib/supabase.ts";
@@ -18,7 +17,6 @@ import { round } from "../shared/precision.ts";
const pool = getConnectionPool(1);
const db = getDatabaseClient<DB>(pool);
-const logger = getFunctionLogger("post-payment");
const payloadValidator = z.object({
type: z.enum(["post", "void"]).default("post"),
@@ -48,7 +46,7 @@ serve(async (req: Request) => {
const { type, paymentId, userId, companyId, fee } =
payloadValidator.parse(payload);
- logger.info({ type, paymentId, userId, companyId });
+ console.log({ function: "post-payment", type, paymentId, userId, companyId });
const client = await getSupabaseServiceRole(
req.headers.get("Authorization"),
diff --git a/packages/database/supabase/functions/post-production-event/index.ts b/packages/database/supabase/functions/post-production-event/index.ts
index 1b7263ca54..4a1b1af5f2 100644
--- a/packages/database/supabase/functions/post-production-event/index.ts
+++ b/packages/database/supabase/functions/post-production-event/index.ts
@@ -1,6 +1,6 @@
import { serve } from "https://deno.land/[email protected]/http/server.ts";
import { nanoid } from "https://deno.land/x/[email protected]/mod.ts";
-import z from "npm:zod@^4.5.4";
+import z from "npm:zod@^3.24.1";
import { DB, getConnectionPool, getDatabaseClient } from "../lib/database.ts";
import { datetime, getCompanyTimeZone } from "../lib/datetime.ts";
import { corsPreflight, errorResponse, jsonResponse } from "../lib/response.ts";
diff --git a/packages/database/supabase/functions/post-purchase-invoice/index.ts b/packages/database/supabase/functions/post-purchase-invoice/index.ts
index 312e17fab2..bcc45b3b4e 100644
--- a/packages/database/supabase/functions/post-purchase-invoice/index.ts
+++ b/packages/database/supabase/functions/post-purchase-invoice/index.ts
@@ -1,9 +1,8 @@
import { serve } from "https://deno.land/[email protected]/http/server.ts";
import { nanoid } from "https://deno.land/x/[email protected]/mod.ts";
-import z from "npm:zod@^4.5.4";
+import z from "npm:zod@^3.24.1";
import { DB, getConnectionPool, getDatabaseClient } from "../lib/database.ts";
import { datetime, getCompanyTimeZone } from "../lib/datetime.ts";
-import { getFunctionLogger } from "../lib/logging.ts";
import { corsPreflight, errorResponse, jsonResponse } from "../lib/response.ts";
import { requirePermissions } from "../lib/supabase.ts";
import type { Database } from "../lib/types.ts";
@@ -27,7 +26,6 @@ import { round } from "../shared/precision.ts";
const pool = getConnectionPool(1);
const db = getDatabaseClient<DB>(pool);
-const logger = getFunctionLogger("post-purchase-invoice");
const payloadValidator = z.object({
type: z.enum(["post", "void"]).default("post"),
@@ -47,7 +45,13 @@ serve(async (req: Request) => {
const { type, invoiceId, userId, companyId, skipReceiptPost } =
payloadValidator.parse(payload);
- logger.info({ type, invoiceId, userId, skipReceiptPost });
+ console.log({
+ function: "post-purchase-invoice",
+ type,
+ invoiceId,
+ userId,
+ skipReceiptPost,
+ });
const client = await requirePermissions(req, companyId, userId, { update: "invoicing" });
const today = datetime.today(await getCompanyTimeZone(client, companyId)).toString();
@@ -544,7 +548,7 @@ serve(async (req: Request) => {
if (purchaseInvoiceDelivery.error)
throw new Error("Failed to fetch purchase invoice delivery");
if (dimensions.error) {
- logger.error("Failed to fetch dimensions", { error: dimensions.error });
+ console.error("Failed to fetch dimensions", dimensions.error);
}
const dimensionMap = new Map<string, string>();
@@ -882,7 +886,7 @@ serve(async (req: Request) => {
);
const itemTrackingType = item?.itemTrackingType ?? "Inventory";
- logger.debug({
+ console.log({
invoiceLineItemId: invoiceLine.itemId,
foundItem: item,
itemTrackingType,
@@ -2270,9 +2274,7 @@ serve(async (req: Request) => {
receiptIds: createdReceiptIds,
});
} catch (err) {
- logger.error("post-purchase-invoice failed", {
- error: String((err as Error)?.stack ?? err),
- });
+ console.error(err);
if (payload.type !== "void" && "invoiceId" in payload) {
const client = await requirePermissions(req, payload.companyId, payload.userId, { update: "invoicing" });
await client
diff --git a/packages/database/supabase/functions/post-sales-invoice/index.ts b/packages/database/supabase/functions/post-sales-invoice/index.ts
index a89f2b1efd..7dd18423b7 100644
--- a/packages/database/supabase/functions/post-sales-invoice/index.ts
+++ b/packages/database/supabase/functions/post-sales-invoice/index.ts
@@ -1,9 +1,8 @@
import { serve } from "https://deno.land/[email protected]/http/server.ts";
import { nanoid } from "https://deno.land/x/[email protected]/mod.ts";
-import z from "npm:zod@^4.5.4";
+import z from "npm:zod@^3.24.1";
import { DB, getConnectionPool, getDatabaseClient } from "../lib/database.ts";
import { datetime, getCompanyTimeZone } from "../lib/datetime.ts";
-import { getFunctionLogger } from "../lib/logging.ts";
import { corsPreflight, errorResponse, jsonResponse } from "../lib/response.ts";
import { requirePermissions } from "../lib/supabase.ts";
import type { Database } from "../lib/types.ts";
@@ -21,7 +20,6 @@ import { calculateCOGS } from "../shared/calculate-cogs.ts";
const pool = getConnectionPool(1);
const db = getDatabaseClient<DB>(pool);
-const logger = getFunctionLogger("post-sales-invoice");
const payloadValidator = z.object({
type: z.enum(["post", "void"]).default("post"),
@@ -40,7 +38,13 @@ serve(async (req: Request) => {
const { type, invoiceId, userId, companyId } =
payloadValidator.parse(payload);
- logger.info({ type, invoiceId, userId, companyId });
+ console.log({
+ function: "post-sales-invoice",
+ type,
+ invoiceId,
+ userId,
+ companyId,
+ });
const client = await requirePermissions(req, companyId, userId, { update: "invoicing" });
const today = datetime.today(await getCompanyTimeZone(client, companyId)).toString();
@@ -1692,9 +1696,7 @@ serve(async (req: Request) => {
return jsonResponse({ success: true });
} catch (err) {
- logger.error("post-sales-invoice failed", {
- error: String((err as Error)?.stack ?? err),
- });
+ console.error(err);
if ("invoiceId" in payload) {
const client = await requirePermissions(req, payload.companyId, payload.userId, { update: "invoicing" });
await client
diff --git a/packages/database/supabase/functions/recalculate/index.ts b/packages/database/supabase/functions/recalculate/index.ts
index b662e4dc01..ddd0fa56b7 100644
--- a/packages/database/supabase/functions/recalculate/index.ts
+++ b/packages/database/supabase/functions/recalculate/index.ts
@@ -1,10 +1,9 @@
import { serve } from "https://deno.land/[email protected]/http/server.ts";
-import { z } from "npm:zod@^4.5.4";
+import { z } from "npm:zod@^3.24.1";
import { DB, getConnectionPool, getDatabaseClient } from "../lib/database.ts";
import { sql, Transaction } from "kysely";
-import { getFunctionLogger } from "../lib/logging.ts";
import { corsPreflight, errorResponse, jsonResponse } from "../lib/response.ts";
import {
computeJobQuantities,
@@ -16,7 +15,6 @@ import { requirePermissions } from "../lib/supabase.ts";
const pool = getConnectionPool(1);
const db = getDatabaseClient<DB>(pool);
-const logger = getFunctionLogger("recalculate");
const payloadValidator = z.object({
type: z.enum(["jobMakeMethodRequirements", "jobRequirements"]),
@@ -33,7 +31,13 @@ serve(async (req: Request) => {
try {
const { type, id, companyId, userId } = payloadValidator.parse(payload);
- logger.info({ type, id, companyId, userId });
+ console.log({
+ function: "recalculate",
+ type,
+ id,
+ companyId,
+ userId,
+ });
const client = await requirePermissions(req, companyId, userId, { update: "production" });
@@ -79,7 +83,7 @@ serve(async (req: Request) => {
}
if (jobMaterial.data.methodType !== "Make to Order") {
- logger.info(
+ console.log(
`Job material ${jobMakeMethod.data.parentMaterialId} is not a 'Make' type. Skipping recalculation.`
);
return jsonResponse({ success: true });
@@ -238,9 +242,10 @@ const updateJobQuantities = async (
const allCycleNodeIds = new Set([...flattenCycles, ...cycleNodeIds]);
if (allCycleNodeIds.size > 0) {
// Corrupt tree data — the nodes were skipped rather than looped on.
- logger.error("recalculate: cyclic job method tree; skipped nodes", {
- skippedNodeIds: [...allCycleNodeIds],
- });
+ console.error(
+ "recalculate: cyclic job method tree; skipped node ids:",
+ [...allCycleNodeIds]
+ );
}
// jobMaterial scrap/estimated — one VALUES-join update for the whole tree
diff --git a/packages/database/supabase/functions/sync/index.ts b/packages/database/supabase/functions/sync/index.ts
index 449d93ad7c..2c849dfcaf 100644
--- a/packages/database/supabase/functions/sync/index.ts
+++ b/packages/database/supabase/functions/sync/index.ts
@@ -2,15 +2,13 @@ import { serve } from "https://deno.land/[email protected]/http/server.ts";
import { Transaction } from "npm:kysely";
import { DB, getConnectionPool, getDatabaseClient } from "../lib/database.ts";
-import z from "npm:zod@^4.5.4";
-import { getFunctionLogger } from "../lib/logging.ts";
+import z from "npm:zod@^3.24.1";
import { corsPreflight, errorResponse, jsonResponse } from "../lib/response.ts";
import { requirePermissions } from "../lib/supabase.ts";
import { getReadableIdWithRevision } from "../lib/utils.ts";
const pool = getConnectionPool(1);
const db = getDatabaseClient<DB>(pool);
-const logger = getFunctionLogger("sync");
const onShapeDataValidator = z.object({
index: z.string(),
@@ -177,7 +175,14 @@ serve(async (req: Request) => {
case "onshape": {
const { makeMethodId, data } = payload;
- logger.info({ type, makeMethodId, data, companyId, userId });
+ console.log({
+ function: "sync",
+ type,
+ makeMethodId,
+ data,
+ companyId,
+ userId,
+ });
const client = await requirePermissions(req, companyId, userId, { update: "resources" });
@@ -220,7 +225,8 @@ serve(async (req: Request) => {
const maxVersion = Number(allVersions.data?.version ?? 0);
const newVersion = maxVersion + 1;
- logger.info({
+ console.log({
+ function: "sync",
action: "creating_top_level_draft",
itemId: topLevelMakeMethod.data.itemId,
maxVersion,
@@ -265,7 +271,8 @@ serve(async (req: Request) => {
.in("id", Array.from(existingItemIds)),
]);
- logger.info({
+ console.log({
+ function: "sync",
action: "fetched_active_make_methods",
count: existingMakeMethods.data?.length ?? 0,
data: existingMakeMethods.data,
@@ -539,7 +546,8 @@ serve(async (req: Request) => {
existingMakeMethodsByItemId.get(itemId) ||
newlyCreatedMakeMethodsByItemId.get(itemId);
- logger.info({
+ console.log({
+ function: "sync",
action: "processing_item",
itemId,
partId,
@@ -564,7 +572,8 @@ serve(async (req: Request) => {
.orderBy("version", "desc")
.executeTakeFirst();
- logger.info({
+ console.log({
+ function: "sync",
action: "check_existing_draft",
itemId,
companyId,
@@ -595,7 +604,8 @@ serve(async (req: Request) => {
const maxVersion = Number(maxVersionRow?.version ?? 0);
const newVersion = maxVersion + 1;
- logger.info({
+ console.log({
+ function: "sync",
action: "creating_child_draft",
itemId,
companyId,
diff --git a/packages/database/supabase/functions/textract/index.ts b/packages/database/supabase/functions/textract/index.ts
index e16ad74d42..f6c3c7a465 100644
--- a/packages/database/supabase/functions/textract/index.ts
+++ b/packages/database/supabase/functions/textract/index.ts
@@ -9,13 +9,10 @@ import {
TextractClient,
} from "https://deno.land/x/[email protected]/client-textract/mod.ts";
-import z from "npm:zod@^4.5.4";
-import { getFunctionLogger } from "../lib/logging.ts";
+import z from "npm:zod@^3.24.1";
import { corsPreflight, errorResponse, jsonResponse } from "../lib/response.ts";
import { getSupabaseServiceRole } from "../lib/supabase.ts";
-const logger = getFunctionLogger("textract");
-
const AWS_REGION = Deno.env.get("AWS_REGION");
const AWS_ACCESS_KEY_ID = Deno.env.get("AWS_ACCESS_KEY_ID");
const AWS_SECRET_ACCESS_KEY = Deno.env.get("AWS_SECRET_ACCESS_KEY");
@@ -59,7 +56,10 @@ serve(async (req: Request) => {
try {
const { path } = payloadValidator.parse(payload);
- logger.info({ path });
+ console.log({
+ function: "textract",
+ path,
+ });
const supabase = await getSupabaseServiceRole(
req.headers.get("Authorization")
@@ -74,7 +74,7 @@ serve(async (req: Request) => {
Key: s3Key,
})
);
- logger.info("File already exists in S3, skipping upload");
+ console.log("File already exists in S3, skipping upload");
} catch (error) {
if (error.name === "NotFound") {
// File doesn't exist, proceed with download and upload
@@ -93,7 +93,7 @@ serve(async (req: Request) => {
Body: data,
})
);
- logger.info("File uploaded to S3");
+ console.log("File uploaded to S3");
} else {
// Unexpected error
throw error;
diff --git a/packages/database/supabase/functions/thumbnail/index.ts b/packages/database/supabase/functions/thumbnail/index.ts
index e400402b11..804634e2c5 100644
--- a/packages/database/supabase/functions/thumbnail/index.ts
+++ b/packages/database/supabase/functions/thumbnail/index.ts
@@ -1,9 +1,8 @@
import { serve } from "https://deno.land/[email protected]/http/server.ts";
import puppeteer from "npm:[email protected]";
-import { z } from "npm:zod@^4.5.4";
+import { z } from "npm:zod@^3.24.1";
import { Buffer } from "node:buffer";
import { corsHeaders } from "../lib/headers.ts";
-import { getFunctionLogger } from "../lib/logging.ts";
import { corsPreflight, errorResponse } from "../lib/response.ts";
import {
@@ -13,8 +12,6 @@ import {
initializeImageMagick,
} from "npm:@imagemagick/[email protected]";
-const logger = getFunctionLogger("thumbnail");
-
const wasmBytes = await Deno.readFile(
new URL(
"magick.wasm",
@@ -42,7 +39,10 @@ serve(async (req: Request) => {
const payload = await req.json();
const { url } = payloadSchema.parse(payload);
- logger.info({ url });
+ console.log({
+ function: "thumbnail",
+ url,
+ });
browser = await puppeteer.connect({
browserWSEndpoint,
@@ -50,18 +50,18 @@ serve(async (req: Request) => {
// valid cert so this is a no-op there.
ignoreHTTPSErrors: true,
});
- logger.debug("browser connected");
+ console.log("browser connected");
const page = await browser.newPage();
- logger.debug("page created");
+ console.log("page created");
await page.setViewport({ width: 1000, height: 1000 });
- logger.debug("viewport set");
+ console.log("viewport set");
await page.goto(url);
- logger.debug(`navigated to ${url}`);
+ console.log(`navigated to ${url}`);
// Wait for the canvas with id=viewer to be visible, but no longer than 5 seconds
await page.waitForSelector("#model-viewer-canvas", {
timeout: 10000,
});
- logger.debug("model-viewer-canvas visible");
+ console.log("model-viewer-canvas visible");
// Capture just the center portion of the viewport to avoid the ring
const screenshot = await page.screenshot({
encoding: "binary",
@@ -95,7 +95,7 @@ serve(async (req: Request) => {
} finally {
if (browser) {
await browser.close();
- logger.debug("browser closed");
+ console.log("browser closed");
}
}
});
diff --git a/packages/database/supabase/functions/transcription/index.ts b/packages/database/supabase/functions/transcription/index.ts
index 92b811ed88..d8dc07a3cf 100644
--- a/packages/database/supabase/functions/transcription/index.ts
+++ b/packages/database/supabase/functions/transcription/index.ts
@@ -1,16 +1,13 @@
import { SupabaseClient } from "@supabase/supabase-js";
import { serve } from "https://deno.land/[email protected]/http/server.ts";
import { experimental_transcribe as transcribe } from "npm:[email protected]";
-import { z } from "npm:zod@^4.5.4";
+import { z } from "npm:zod@^3.24.1";
import { openai } from "../lib/ai/openai.ts";
import { corsHeaders } from "../lib/headers.ts";
-import { getFunctionLogger } from "../lib/logging.ts";
import { corsPreflight, errorResponse, jsonResponse } from "../lib/response.ts";
import { getSupabase } from "../lib/supabase.ts";
import { Database } from "../lib/types.ts";
-const logger = getFunctionLogger("transcription");
-
const transcriptionRequestSchema = z.object({
audio: z.string().describe("Base64 encoded audio data"),
mimeType: z.string().describe("MIME type of the audio file"),
@@ -20,7 +17,9 @@ serve(async (req: Request) => {
const preflight = corsPreflight(req);
if (preflight) return preflight;
- logger.info("invoked");
+ console.log({
+ function: "transcription",
+ });
let client: SupabaseClient<Database> | null = null;
let userId: string | null = null;
@@ -68,7 +67,11 @@ serve(async (req: Request) => {
const { audio, mimeType } = validationResult.data;
- logger.info({ mimeType, audioLength: audio.length });
+ console.log({
+ function: "transcription",
+ mimeType,
+ audioLength: audio.length,
+ });
// Convert base64 to Uint8Array
const audioBuffer = Uint8Array.from(atob(audio), (c) => c.charCodeAt(0));
@@ -84,7 +87,8 @@ serve(async (req: Request) => {
audio: audioBuffer,
});
- logger.info("Audio transcription completed", {
+ console.log({
+ function: "Audio transcription completed",
userId,
companyId,
transcriptLength: result.text.length,
@@ -96,9 +100,7 @@ serve(async (req: Request) => {
language: result.language,
});
} catch (error) {
- logger.error("Transcription failed", {
- error: String((error as Error)?.stack ?? error),
- });
+ console.error("Transcription failed:", error);
return errorResponse(error, 500);
}
diff --git a/packages/database/supabase/functions/trigger-rework/index.ts b/packages/database/supabase/functions/trigger-rework/index.ts
index 54e3804d9e..a87867bc4c 100644
--- a/packages/database/supabase/functions/trigger-rework/index.ts
+++ b/packages/database/supabase/functions/trigger-rework/index.ts
@@ -1,16 +1,14 @@
import { serve } from "https://deno.land/[email protected]/http/server.ts";
import type { Transaction } from "kysely";
import { nanoid } from "https://deno.land/x/[email protected]/nanoid.ts";
-import z from "npm:zod@^4.5.4";
+import z from "npm:zod@^3.24.1";
import { getConnectionPool, getDatabaseClient } from "../lib/database.ts";
-import { getFunctionLogger } from "../lib/logging.ts";
import { corsPreflight, errorResponse, jsonResponse } from "../lib/response.ts";
import { requirePermissions } from "../lib/supabase.ts";
import type { DB } from "../lib/types.ts";
const pool = getConnectionPool(1);
const db = getDatabaseClient<DB>(pool);
-const logger = getFunctionLogger("trigger-rework");
interface TriggerReworkRequest {
jobId: string;
@@ -112,7 +110,7 @@ async function triggerRework(
triggeredAtJobOperationId
);
- logger.info(
+ console.info(
`📋 Rework path: ${operationPath.length} operations to clone`
);
@@ -265,7 +263,7 @@ async function triggerRework(
sourceToCloneMap.set(sourceOp.id, clonedOps[i].id);
});
- logger.info(`🔧 Cloned ${clonedOperationIds.length} operations`);
+ console.info(`🔧 Cloned ${clonedOperationIds.length} operations`);
// 6. Clone steps, tools, and parameters (batch fetch + batch insert)
const [allSteps, allTools, allParams] = await Promise.all([
@@ -382,7 +380,7 @@ async function triggerRework(
.execute();
}
- logger.info(`🔗 DAG wired with ${downstreamDeps.length} downstream deps rewired`);
+ console.info(`🔗 DAG wired with ${downstreamDeps.length} downstream deps rewired`);
// 8. Record a productionQuantity entry for the rework
await trx
@@ -460,7 +458,7 @@ serve(async (req) => {
return errorResponse("Job not found in this company", 404);
}
- logger.info(
+ console.info(
`🔰 Starting rework for job ${body.jobId}: go back to ${body.targetJobOperationId} from ${body.triggeredAtJobOperationId}`
);
@@ -485,14 +483,12 @@ serve(async (req) => {
}),
});
} catch (err) {
- logger.error("Failed to trigger reschedule after rework", {
- error: String((err as Error)?.stack ?? err),
- });
+ console.error("Failed to trigger reschedule after rework:", err);
}
return jsonResponse({ success: true, ...result });
} catch (error) {
- logger.error(
+ console.error(
`❌ Rework failed: ${
error instanceof Error ? error.message : String(error)
}`
diff --git a/packages/database/supabase/functions/trigger/index.ts b/packages/database/supabase/functions/trigger/index.ts
index ec6ea02f0e..406c8429d3 100644
--- a/packages/database/supabase/functions/trigger/index.ts
+++ b/packages/database/supabase/functions/trigger/index.ts
@@ -1,12 +1,9 @@
import { serve } from "https://deno.land/[email protected]/http/server.ts";
-import { z } from "npm:zod@^4.5.4";
+import { z } from "npm:zod@^3.24.1";
-import { getFunctionLogger } from "../lib/logging.ts";
import { corsPreflight, errorResponse, jsonResponse } from "../lib/response.ts";
import { sendInngestEvent } from "../lib/inngest.ts";
-const logger = getFunctionLogger("trigger");
-
const recipientValidator = z.discriminatedUnion("type", [
z.object({
type: z.literal("user"),
@@ -47,7 +44,11 @@ serve(async (req: Request) => {
const validatedPayload = payloadValidator.parse(payload);
const { type, ...data } = validatedPayload;
- logger.info({ type, ...data });
+ console.log({
+ function: "trigger",
+ type,
+ ...data,
+ });
switch (type) {
case "notify": {
diff --git a/packages/database/supabase/functions/update-purchased-prices/index.ts b/packages/database/supabase/functions/update-purchased-prices/index.ts
index e5d74bc945..b04780a98c 100644
--- a/packages/database/supabase/functions/update-purchased-prices/index.ts
+++ b/packages/database/supabase/functions/update-purchased-prices/index.ts
@@ -1,17 +1,15 @@
import { serve } from "https://deno.land/[email protected]/http/server.ts";
import { sql } from "kysely";
-import z from "npm:zod@^4.5.4";
+import z from "npm:zod@^3.24.1";
import { DB, getConnectionPool, getDatabaseClient } from "../lib/database.ts";
import { datetime, getCompanyTimeZone } from "../lib/datetime.ts";
-import { getFunctionLogger } from "../lib/logging.ts";
import { corsPreflight, errorResponse, jsonResponse } from "../lib/response.ts";
import { requirePermissions } from "../lib/supabase.ts";
import { Database } from "../lib/types.ts";
const pool = getConnectionPool(1);
const db = getDatabaseClient<DB>(pool);
-const logger = getFunctionLogger("update-purchased-prices");
const payloadValidator = z.discriminatedUnion("source", [
z.object({
@@ -65,7 +63,13 @@ serve(async (req: Request) => {
const shouldUpdatePrices = parsedPayload.updatePrices ?? true;
const shouldUpdateLeadTimes = parsedPayload.updateLeadTimes ?? false;
- logger.info({ source, companyId, shouldUpdatePrices, shouldUpdateLeadTimes });
+ console.log({
+ function: "update-purchased-prices",
+ source,
+ companyId,
+ shouldUpdatePrices,
+ shouldUpdateLeadTimes,
+ });
try {
const client = await requirePermissions(req, companyId, userId, { update: "purchasing" });
@@ -77,7 +81,12 @@ serve(async (req: Request) => {
case "purchaseOrder": {
const { purchaseOrderId } = parsedPayload;
- logger.info({ source, purchaseOrderId, companyId });
+ console.log({
+ function: "update-purchased-prices",
+ source,
+ purchaseOrderId,
+ companyId,
+ });
const [purchaseOrder, purchaseOrderLines] = await Promise.all([
client
@@ -156,7 +165,12 @@ serve(async (req: Request) => {
case "purchaseInvoice": {
const { invoiceId } = parsedPayload;
- logger.info({ source, invoiceId, companyId });
+ console.log({
+ function: "update-purchased-prices",
+ source,
+ invoiceId,
+ companyId,
+ });
const [purchaseInvoice, purchaseInvoiceLines] = await Promise.all([
client
diff --git a/packages/ee/src/accounting/core/models.ts b/packages/ee/src/accounting/core/models.ts
index eb7fafcfb5..4474080b92 100644
--- a/packages/ee/src/accounting/core/models.ts
+++ b/packages/ee/src/accounting/core/models.ts
@@ -115,7 +115,7 @@ export const AccountingSyncSchema = z.object({
syncType: z.enum(["webhook", "scheduled", "trigger"]),
syncDirection: SyncDirectionSchema,
entities: z.array(z.custom<AccountingEntity>()),
- metadata: z.record(z.string(), z.any()).optional()
+ metadata: z.record(z.any()).optional()
});
export const ENTITY_DEFINITIONS: Record<
@@ -777,7 +777,7 @@ export const SyncOperationSchema = z.object({
errorCode: z.string().nullable(),
errorMessage: z.string().nullable(),
externalId: z.string().nullable(),
- metadata: z.record(z.string(), z.any()).nullable(),
+ metadata: z.record(z.any()).nullable(),
createdBy: z.string(),
createdAt: z.string(),
updatedBy: z.string().nullable(),
@@ -879,7 +879,7 @@ export const ContactSchema = z.object({
postalCode: z.string().nullish()
})
),
- raw: z.record(z.string(), z.any())
+ raw: z.record(z.any())
});
export const EmployeeSchema = z.object({
@@ -904,7 +904,7 @@ export const EmployeeSchema = z.object({
})
.optional(),
updatedAt: z.string().datetime(),
- raw: z.record(z.string(), z.any()).optional()
+ raw: z.record(z.any()).optional()
});
// ============================================================================
@@ -949,7 +949,7 @@ export const SalesOrderSchema = z.object({
customerReference: withNullable(z.string()),
lines: z.array(SalesOrderLineSchema),
updatedAt: z.string().datetime(),
- raw: z.record(z.string(), z.any()).optional()
+ raw: z.record(z.any()).optional()
});
// Sales Invoice schemas
@@ -1000,7 +1000,7 @@ export const SalesInvoiceSchema = z.object({
balance: z.number(),
lines: z.array(SalesInvoiceLineSchema),
updatedAt: z.string().datetime(),
- raw: z.record(z.string(), z.any()).optional()
+ raw: z.record(z.any()).optional()
});
// Bill (Purchase Invoice) schemas
@@ -1050,7 +1050,7 @@ export const BillSchema = z.object({
supplierReference: withNullable(z.string()),
lines: z.array(BillLineSchema),
updatedAt: z.string().datetime(),
- raw: z.record(z.string(), z.any()).optional()
+ raw: z.record(z.any()).optional()
});
// Purchase Order schemas
@@ -1101,7 +1101,7 @@ export const PurchaseOrderSchema = z.object({
supplierReference: withNullable(z.string()),
lines: z.array(PurchaseOrderLineSchema),
updatedAt: z.string().datetime(),
- raw: z.record(z.string(), z.any()).optional()
+ raw: z.record(z.any()).optional()
});
// ============================================================================
@@ -1132,7 +1132,7 @@ export const ItemSchema = z.object({
isSold: z.boolean(),
isTrackedAsInventory: z.boolean(),
updatedAt: z.string(),
- raw: z.record(z.string(), z.any()).optional()
+ raw: z.record(z.any()).optional()
});
// ============================================================================
@@ -1152,7 +1152,7 @@ export const InventoryAdjustmentSchema = z.object({
inventoryAccount: z.string(), // resolved GL account from accountDefault (rawMaterialsAccount for Buy items, finishedGoodsAccount for Make / Buy and Make)
adjustmentVarianceAccount: z.string(), // GL account code from accountDefault
updatedAt: z.string().datetime(),
- raw: z.record(z.string(), z.any()).optional()
+ raw: z.record(z.any()).optional()
});
// ============================================================================
@@ -1202,5 +1202,5 @@ export const JournalEntrySchema = z.object({
reversal: z.boolean(),
lines: z.array(JournalEntryLineSchema),
updatedAt: z.string(),
- raw: z.record(z.string(), z.any()).optional()
+ raw: z.record(z.any()).optional()
});
diff --git a/packages/ee/src/accounting/models.ts b/packages/ee/src/accounting/models.ts
index 819558ce99..b1488481a9 100644
--- a/packages/ee/src/accounting/models.ts
+++ b/packages/ee/src/accounting/models.ts
@@ -59,7 +59,7 @@ export const AttachmentSchema = BaseEntitySchema.extend({
isPublic: z.boolean().default(false),
uploadedBy: z.string().optional(),
checksum: z.string().optional(), // For file integrity
- metadata: z.record(z.string(), z.any()).optional() // Provider-specific metadata
+ metadata: z.record(z.any()).optional() // Provider-specific metadata
});
// Account schema for chart of accounts
@@ -117,7 +117,7 @@ export const CustomerSchema = BaseEntitySchema.extend({
balance: z.number().optional(),
notes: z.string().optional(),
tags: z.array(z.string()).optional(),
- customFields: z.record(z.string(), z.any()).optional(),
+ customFields: z.record(z.any()).optional(),
attachments: z.array(AttachmentSchema).optional()
});
@@ -140,7 +140,7 @@ export const VendorSchema = BaseEntitySchema.extend({
balance: z.number().optional(),
notes: z.string().optional(),
tags: z.array(z.string()).optional(),
- customFields: z.record(z.string(), z.any()).optional(),
+ customFields: z.record(z.any()).optional(),
attachments: z.array(AttachmentSchema).optional()
});
@@ -162,7 +162,7 @@ export const ItemSchema = BaseEntitySchema.extend({
isSold: z.boolean().default(true),
isPurchased: z.boolean().default(false),
taxCode: z.string().optional(),
- customFields: z.record(z.string(), z.any()).optional()
+ customFields: z.record(z.any()).optional()
});
// Enhanced invoice schema with attachments
@@ -212,7 +212,7 @@ export const InvoiceSchema = BaseEntitySchema.extend({
})
),
attachments: z.array(AttachmentSchema).optional(),
- customFields: z.record(z.string(), z.any()).optional()
+ customFields: z.record(z.any()).optional()
});
// Bill schema (for vendor bills)
@@ -259,7 +259,7 @@ export const BillSchema = BaseEntitySchema.extend({
})
),
attachments: z.array(AttachmentSchema).optional(),
- customFields: z.record(z.string(), z.any()).optional()
+ customFields: z.record(z.any()).optional()
});
// Enhanced transaction schema with attachments and reconciliation
@@ -309,7 +309,7 @@ export const TransactionSchema = BaseEntitySchema.extend({
)
.optional(),
attachments: z.array(AttachmentSchema).optional(),
- customFields: z.record(z.string(), z.any()).optional()
+ customFields: z.record(z.any()).optional()
});
// Expense schema
@@ -350,7 +350,7 @@ export const ExpenseSchema = BaseEntitySchema.extend({
)
.optional(),
attachments: z.array(AttachmentSchema).optional(),
- customFields: z.record(z.string(), z.any()).optional()
+ customFields: z.record(z.any()).optional()
});
// Journal Entry schema
@@ -385,7 +385,7 @@ export const JournalEntrySchema = BaseEntitySchema.extend({
totalCredit: z.number(),
notes: z.string().optional(),
attachments: z.array(AttachmentSchema).optional(),
- customFields: z.record(z.string(), z.any()).optional()
+ customFields: z.record(z.any()).optional()
});
// Payment schema
@@ -416,7 +416,7 @@ export const PaymentSchema = BaseEntitySchema.extend({
fees: z.number().optional(),
notes: z.string().optional(),
attachments: z.array(AttachmentSchema).optional(),
- customFields: z.record(z.string(), z.any()).optional()
+ customFields: z.record(z.any()).optional()
});
// Company info schema
@@ -435,7 +435,7 @@ export const CompanyInfoSchema = BaseEntitySchema.extend({
logo: z.string().url().optional(),
industry: z.string().optional(),
employees: z.number().optional(),
- customFields: z.record(z.string(), z.any()).optional()
+ customFields: z.record(z.any()).optional()
});
// Enhanced provider-specific metadata
@@ -445,8 +445,8 @@ export const ProviderMetadataSchema = z.object({
lastSyncAt: z.string().datetime().optional(),
syncHash: z.string().optional(),
version: z.string().optional(),
- rawData: z.record(z.string(), z.any()).optional(), // Store original provider data
- customFields: z.record(z.string(), z.any()).optional()
+ rawData: z.record(z.any()).optional(), // Store original provider data
+ customFields: z.record(z.any()).optional()
});
// Enhanced API Request/Response schemas
diff --git a/packages/ee/src/accounting/providers/rillet/models.ts b/packages/ee/src/accounting/providers/rillet/models.ts
index 08fed6813c..b28d9d4bbd 100644
--- a/packages/ee/src/accounting/providers/rillet/models.ts
+++ b/packages/ee/src/accounting/providers/rillet/models.ts
@@ -86,7 +86,7 @@ export namespace Rillet {
id: z.string(),
name: z.string(),
values: z.array(FieldValueSchema).default([]),
- settings: z.record(z.string(), z.unknown()).nullish(),
+ settings: z.record(z.unknown()).nullish(),
updated_at: z.string().nullish()
});
diff --git a/packages/form/package.json b/packages/form/package.json
index ab44e03aa8..3517db249b 100644
--- a/packages/form/package.json
+++ b/packages/form/package.json
@@ -22,8 +22,7 @@
"ts-toolbelt": "9.6.0",
"tsconfig": "*",
"typescript": "catalog:",
- "vitest": "catalog:",
- "zod-form-data": "catalog:"
+ "vitest": "catalog:"
},
"dependencies": {
"@carbon/glossary": "workspace:*",
diff --git a/packages/form/src/ValidatedForm.tsx b/packages/form/src/ValidatedForm.tsx
index efa4a2ab0d..cc8c94a3f5 100644
--- a/packages/form/src/ValidatedForm.tsx
+++ b/packages/form/src/ValidatedForm.tsx
@@ -63,7 +63,7 @@ export type FormProps<DataType, Subaction extends string | undefined> = {
/**
* A `Validator` object that describes how to validate the form.
*/
- validator: z.Schema<DataType> | z.ZodObject<any> | z.ZodPipe<any, any>;
+ validator: z.Schema<DataType> | z.ZodEffects<any> | z.ZodObject<any>;
/**
* A submit callback that gets called when the form is submitted
* after all validations have been run.
diff --git a/packages/form/src/internal/isFieldOptional.test.ts b/packages/form/src/internal/isFieldOptional.test.ts
index 7f8d600dc8..7de78b8f6c 100644
--- a/packages/form/src/internal/isFieldOptional.test.ts
+++ b/packages/form/src/internal/isFieldOptional.test.ts
@@ -1,91 +1,43 @@
import { describe, expect, it } from "vitest";
import { z } from "zod";
-import { zfd } from "zod-form-data";
import { isFieldOptional } from "./isFieldOptional";
-// Pins the schema walk that drives each field's required/optional marker.
-// The zfd cases matter most: a zfd wrapper is pipe(in: transform, out: schema),
-// and walking into the bare transform used to report every optional zfd field
-// as required.
-
describe("isFieldOptional", () => {
- it("reports plain optional / required / default fields", () => {
- const schema = z.object({
- required: z.string().min(1),
- optional: z.string().optional(),
- defaulted: z.string().default("draft"),
- prefaulted: z.string().prefault("draft")
- });
- expect(isFieldOptional(schema, "required")).toBe(false);
- expect(isFieldOptional(schema, "optional")).toBe(true);
- expect(isFieldOptional(schema, "defaulted")).toBe(true);
- expect(isFieldOptional(schema, "prefaulted")).toBe(true);
- });
-
- it("nullable is not optional", () => {
- const schema = z.object({ n: z.string().nullable() });
- expect(isFieldOptional(schema, "n")).toBe(false);
- });
-
- it("sees through zfd preprocess pipes to the real schema", () => {
- const schema = z.object({
- id: zfd.text(z.string().optional()),
- name: zfd.text(z.string().min(1)),
- qty: zfd.numeric(z.number().min(0)),
- active: zfd.checkbox()
- });
- expect(isFieldOptional(schema, "id")).toBe(true);
- expect(isFieldOptional(schema, "name")).toBe(false);
- expect(isFieldOptional(schema, "qty")).toBe(false);
- expect(isFieldOptional(schema, "active")).toBe(true);
- });
-
- it("sees through z.preprocess the same way", () => {
- const schema = z.object({
- reason: z.preprocess(
- (val) => (val === "" ? undefined : val),
- z.enum(["a", "b"]).optional()
- )
- });
- expect(isFieldOptional(schema, "reason")).toBe(true);
- });
-
- it("resolves nested object and array-element paths", () => {
- const schema = z.object({
- user: z.object({ email: z.string().optional(), name: z.string() }),
- items: z.array(z.object({ label: z.string().optional() }))
- });
- expect(isFieldOptional(schema, "user.email")).toBe(true);
- expect(isFieldOptional(schema, "user.name")).toBe(false);
- expect(isFieldOptional(schema, "items[0].label")).toBe(true);
+ const schema = z.object({
+ requiredName: z.string(),
+ optionalName: z.string().optional(),
+ defaultedName: z.string().default(""),
+ nested: z.object({
+ requiredChild: z.string(),
+ optionalChild: z.string().optional()
+ }),
+ optionalNested: z
+ .object({
+ requiredChild: z.string()
+ })
+ .optional(),
+ items: z.array(
+ z.object({
+ code: z.string().optional()
+ })
+ )
});
- it("an optional parent makes every child optional", () => {
- const schema = z.object({
- address: z.object({ city: z.string() }).optional()
- });
- expect(isFieldOptional(schema, "address.city")).toBe(true);
+ it("returns false for required fields", () => {
+ expect(isFieldOptional(schema, "requiredName")).toBe(false);
+ expect(isFieldOptional(schema, "nested.requiredChild")).toBe(false);
});
- it("resolves record values and returns undefined for unknown fields", () => {
- const schema = z.object({
- amounts: z.record(z.string(), z.number().optional())
- });
- expect(isFieldOptional(schema, "amounts.anything")).toBe(true);
- expect(isFieldOptional(schema, "nope")).toBeUndefined();
- expect(isFieldOptional(undefined, "x")).toBeUndefined();
+ it("returns true for optional fields", () => {
+ expect(isFieldOptional(schema, "optionalName")).toBe(true);
+ expect(isFieldOptional(schema, "defaultedName")).toBe(true);
+ expect(isFieldOptional(schema, "nested.optionalChild")).toBe(true);
+ expect(isFieldOptional(schema, "optionalNested.requiredChild")).toBe(true);
+ expect(isFieldOptional(schema, "items[0].code")).toBe(true);
});
- it("resolves lazy schemas without looping", () => {
- type Node = { name?: string; child?: Node };
- const node: z.ZodType<Node> = z.lazy(() =>
- z.object({
- name: z.string().optional(),
- child: node.optional()
- })
- );
- const schema = z.object({ root: node });
- expect(isFieldOptional(schema, "root.name")).toBe(true);
- expect(isFieldOptional(schema, "root.child.name")).toBe(true);
+ it("returns undefined when field path is not in schema", () => {
+ expect(isFieldOptional(schema, "missingField")).toBeUndefined();
+ expect(isFieldOptional(schema, "optionalNested.missing")).toBeUndefined();
});
});
diff --git a/packages/form/src/internal/isFieldOptional.ts b/packages/form/src/internal/isFieldOptional.ts
index 872e4a0e35..bad06d5ffd 100644
--- a/packages/form/src/internal/isFieldOptional.ts
+++ b/packages/form/src/internal/isFieldOptional.ts
@@ -1,84 +1,119 @@
-import { z } from "zod";
+import { type ZodSchema, z } from "zod";
import { stringToPathArray } from "../utils";
-// v4's wrapper generics default to the core `$ZodType` interface; every schema
-// an app hands the form library is built with the classic API, so re-viewing an
-// unwrapped child as a classic `ZodType` is sound.
-const classic = (schema: z.core.$ZodType): z.ZodType => schema as z.ZodType;
-
type UnwrapResult = {
- schema: z.ZodType;
+ schema: ZodSchema;
isOptional: boolean;
hasDefault: boolean;
};
function unwrapSchema(
- schema: z.ZodType,
+ schema: ZodSchema,
io: "input" | "output" = "output"
): UnwrapResult {
let current = schema;
let isOptional = false;
let hasDefault = false;
- const seen = new Set<z.ZodType>();
+ const seen = new Set<ZodSchema>();
- while (!seen.has(current)) {
+ while (true) {
+ if (seen.has(current)) return { schema: current, isOptional, hasDefault };
seen.add(current);
- if (current instanceof z.ZodOptional) {
- isOptional = true;
- current = classic(current.unwrap());
- } else if (
- current instanceof z.ZodDefault ||
- current instanceof z.ZodPrefault
- ) {
- isOptional = true;
- hasDefault = true;
- current = classic(current.unwrap());
- } else if (current instanceof z.ZodCatch) {
- isOptional = true;
- current = classic(current.unwrap());
- } else if (current instanceof z.ZodNonOptional) {
- isOptional = false;
- current = classic(current.unwrap());
- } else if (
- // nullable is semantically distinct from optional; the rest are transparent
- current instanceof z.ZodNullable ||
- current instanceof z.ZodReadonly ||
- current instanceof z.ZodPromise ||
- current instanceof z.ZodLazy
- ) {
- current = classic(current.unwrap());
- } else if (current instanceof z.ZodPipe) {
- // Direction matters — except that a preprocess pipe (zfd.text, zfd.numeric,
- // z.preprocess) carries a bare transform on its input side, which accepts
- // anything: whether the FIELD is required is decided by what the output
- // side demands. Walking into the transform reported every optional zfd
- // field as required.
- const side =
- io === "input" && !(current.in instanceof z.ZodTransform)
- ? current.in
- : current.out;
- current = classic(side);
- } else {
- break;
+ const def: any = (current as any)._zod?.def ?? (current as any)._def;
+ const type: string | undefined = def?.type ?? def?.typeName;
+
+ switch (type) {
+ // optionality wrappers
+ case "optional":
+ case "ZodOptional":
+ isOptional = true;
+ current = def.innerType;
+ continue;
+
+ case "default":
+ case "ZodDefault":
+ isOptional = true;
+ hasDefault = true;
+ current = def.innerType;
+ continue;
+
+ case "prefault":
+ isOptional = true;
+ hasDefault = true;
+ current = def.innerType;
+ continue;
+
+ case "catch":
+ case "ZodCatch":
+ isOptional = true;
+ current = def.innerType;
+ continue;
+
+ // nullable — semantically distinct from optional
+ case "nullable":
+ case "ZodNullable":
+ current = def.innerType;
+ continue;
+
+ // transparent wrappers
+ case "readonly":
+ case "ZodReadonly":
+ current = def.innerType;
+ continue;
+
+ case "nonoptional":
+ isOptional = false;
+ current = def.innerType;
+ continue;
+
+ case "promise":
+ case "ZodPromise":
+ current = def.innerType;
+ continue;
+
+ case "ZodBranded":
+ current = def.type;
+ continue;
+
+ // lazy — resolve the thunk
+ case "lazy":
+ case "ZodLazy": {
+ const inner = (current as any)._zod?.innerType ?? def.getter?.();
+ if (!inner) return { schema: current, isOptional, hasDefault };
+ current = inner;
+ continue;
+ }
+
+ // pipe — direction matters
+ case "pipe":
+ case "ZodPipeline":
+ current = io === "input" ? def.in : def.out;
+ continue;
+
+ // effects (v3 refine/transform/preprocess)
+ case "ZodEffects":
+ current = def.schema;
+ continue;
+
+ default:
+ return { schema: current, isOptional, hasDefault };
}
}
-
- return { schema: current, isOptional, hasDefault };
}
function getChildSchema(
- schema: z.ZodType,
+ schema: ZodSchema,
segment: string | number
-): z.ZodType | null {
+): ZodSchema | null {
if (schema instanceof z.ZodObject) {
+ const shape = schema.shape;
if (typeof segment !== "string") return null;
- const child = (schema.shape as Record<string, z.core.$ZodType>)[segment];
- return child ? classic(child) : null;
+ return shape[segment] ?? null;
}
if (schema instanceof z.ZodArray) {
- return classic(schema.element);
+ return schema.element;
}
if (schema instanceof z.ZodTuple) {
@@ -89,28 +124,26 @@ function getChildSchema(
? null
: Number(segment);
if (index === null) return null;
- const item = schema.def.items[index];
- return item ? classic(item) : null;
+ return schema.items[index] ?? null;
}
if (schema instanceof z.ZodRecord) {
- return classic(schema.valueType);
+ return schema._def.valueType;
}
return null;
}
export function isFieldOptional(
- schema: z.ZodType | undefined,
+ schema: ZodSchema | undefined,
fieldName: string
): boolean | undefined {
- // Fields receive caller input, so requiredness is judged on the input side.
- const dir = "input";
+ const dir = "input"; // Can be a param
if (!schema || !fieldName) return undefined;
const path = stringToPathArray(fieldName);
- let current: z.ZodType | null = schema;
+ let current: ZodSchema | null = schema;
let optionalFromParent = false;
for (const segment of path) {
diff --git a/packages/form/src/zod.test.ts b/packages/form/src/zod.test.ts
deleted file mode 100644
index edf179898a..0000000000
--- a/packages/form/src/zod.test.ts
+++ /dev/null
@@ -1,153 +0,0 @@
-import { assert, describe, expect, it } from "vitest";
-import { z } from "zod";
-import { zfd } from "zod-form-data";
-import { validator } from "./zod";
-
-// Runtime coverage for the zod adapter — the paths typecheck can't prove:
-// `.default()` output semantics, ZodError -> FieldErrors mapping, dotted and
-// array-indexed paths, the union-issue shape (`issue.errors`) that
-// getIssuesForError recurses into, and the FormData -> object preprocessing a
-// route action's `validator(schema).validate(formData)` relies on.
-
-describe("validator (zod adapter)", () => {
- it("parses a valid value and applies a default", async () => {
- const schema = z.object({
- name: z.string().min(1),
- active: z.boolean().default(true)
- });
- const result = await validator(schema).validate({ name: "hi" });
- expect(result.error).toBeUndefined();
- expect(result.data).toEqual({ name: "hi", active: true });
- });
-
- it("maps an invalid field to a FieldErrors entry keyed by path", async () => {
- const schema = z.object({
- name: z.string().min(1, { message: "Name is required" })
- });
- const result = await validator(schema).validate({ name: "" });
- expect(result.data).toBeUndefined();
- expect(result.error?.fieldErrors?.name).toBe("Name is required");
- });
-
- it("surfaces a nested field error at a dotted path", async () => {
- const schema = z.object({
- user: z.object({ email: z.email({ message: "Bad email" }) })
- });
- const result = await validator(schema).validate({
- user: { email: "nope" }
- });
- expect(result.error?.fieldErrors?.["user.email"]).toBe("Bad email");
- });
-
- it("keys an array element error with an index path", async () => {
- const schema = z.object({
- items: z.array(
- z.object({ name: z.string().min(1, { message: "Required" }) })
- )
- });
- const result = await validator(schema).validate({
- items: [{ name: "ok" }, { name: "" }]
- });
- expect(result.error?.fieldErrors?.["items[1].name"]).toBe("Required");
- });
-
- it("recurses into a union issue's sub-errors without crashing", async () => {
- const schema = z.object({
- val: z.union([z.string().min(3), z.number()])
- });
- // "ab" fails both members -> an invalid_union issue carrying `errors`.
- const result = await validator(schema).validate({ val: "ab" });
- expect(result.data).toBeUndefined();
- expect(Object.keys(result.error?.fieldErrors ?? {}).length).toBeGreaterThan(
- 0
- );
- });
-
- it("surfaces a discriminated-union branch error at its own path", async () => {
- const schema = z.object({
- op: z.discriminatedUnion("kind", [
- z.object({ kind: z.literal("email"), address: z.email() }),
- z.object({ kind: z.literal("phone"), number: z.string().min(7) })
- ])
- });
- const result = await validator(schema).validate({
- op: { kind: "email", address: "nope" }
- });
- expect(result.data).toBeUndefined();
- expect(result.error?.fieldErrors?.["op.address"]).toBeDefined();
- });
-
- it("validateField returns the message for one field only", async () => {
- const schema = z.object({
- name: z.string().min(1, { message: "Name is required" }),
- age: z.number()
- });
- const v = validator(schema);
- assert(v.validateField);
- const nameErr = await v.validateField({ name: "", age: 1 }, "name");
- expect(nameErr.error).toBe("Name is required");
- });
-
- it("validateField resolves a nested dotted path", async () => {
- const schema = z.object({
- user: z.object({ email: z.email({ message: "Bad email" }) }),
- name: z.string()
- });
- const v = validator(schema);
- assert(v.validateField);
- const err = await v.validateField(
- { user: { email: "nope" }, name: "ok" },
- "user.email"
- );
- expect(err.error).toBe("Bad email");
- const clean = await v.validateField(
- { user: { email: "nope" }, name: "ok" },
- "name"
- );
- expect(clean.error).toBeUndefined();
- });
-});
-
-describe("validator with FormData (the route-action path)", () => {
- const schema = z.object({
- id: zfd.text(z.string().optional()),
- name: z.string().min(1, { message: "Name is required" }),
- quantity: zfd.numeric(z.number().min(0)),
- isActive: zfd.checkbox(),
- tags: zfd.repeatableOfType(z.string()).optional()
- });
-
- it("coerces zfd fields from a real FormData submission", async () => {
- const fd = new FormData();
- fd.append("name", "Widget");
- fd.append("quantity", "42");
- fd.append("tags", "a");
- fd.append("tags", "b");
- // id omitted, isActive unchecked (absent)
- const result = await validator(schema).validate(fd);
- expect(result.error).toBeUndefined();
- expect(result.data).toEqual({
- name: "Widget",
- quantity: 42,
- isActive: false,
- tags: ["a", "b"]
- });
- });
-
- it("treats a checked checkbox's 'on' as true", async () => {
- const fd = new FormData();
- fd.append("name", "Widget");
- fd.append("quantity", "1");
- fd.append("isActive", "on");
- const result = await validator(schema).validate(fd);
- expect(result.data?.isActive).toBe(true);
- });
-
- it("maps an empty required text field to its error", async () => {
- const fd = new FormData();
- fd.append("name", "");
- fd.append("quantity", "1");
- const result = await validator(schema).validate(fd);
- expect(result.error?.fieldErrors?.name).toBe("Name is required");
- });
-});
diff --git a/packages/form/src/zod.ts b/packages/form/src/zod.ts
index b2bdeaa92b..4690075621 100644
--- a/packages/form/src/zod.ts
+++ b/packages/form/src/zod.ts
@@ -4,22 +4,18 @@ import { stringToPathArray } from "./utils";
import { createValidator } from "./validation/createValidator";
import type { FieldErrors, Validator } from "./validation/types";
-// Flatten a ZodError's issues, recursing into union issues (`invalid_union`
-// carries `errors: $ZodIssue[][]`) so a nested field error surfaces at its own
-// path. A union issue with no sub-errors is kept as-is so a message survives.
-const getIssuesForError = (err: z.ZodError): z.core.$ZodIssue[] => {
- const collect = (issues: readonly z.core.$ZodIssue[]): z.core.$ZodIssue[] =>
- issues.flatMap((issue) =>
- issue.code === "invalid_union" && issue.errors.length > 0
- ? collect(issue.errors.flat())
- : [issue]
- );
- return collect(err.issues);
+const getIssuesForError = (err: z.ZodError<any>): z.ZodIssue[] => {
+ return err.issues.flatMap((issue) => {
+ if ("unionErrors" in issue) {
+ return issue.unionErrors.flatMap((err) => getIssuesForError(err));
+ } else {
+ return [issue];
+ }
+ });
};
-function pathToString(array: PropertyKey[]): string {
- return array.reduce<string>(function (string: string, itemRaw: PropertyKey) {
- const item = String(itemRaw);
+function pathToString(array: (string | number)[]): string {
+ return array.reduce<string>(function (string: string, item: string | number) {
const prefix = string === "" ? "" : ".";
return string + (isNaN(Number(item)) ? prefix + item : "[" + item + "]");
}, "");
@@ -28,10 +24,10 @@ function pathToString(array: PropertyKey[]): string {
/**
* Create a validator using a `zod` schema.
*/
-export function validator<Schema extends z.ZodType>(
- zodSchema: Schema,
- parseParams?: Parameters<Schema["safeParseAsync"]>[1]
-): Validator<z.output<Schema>> {
+export function validator<T, U extends z.ZodTypeDef>(
+ zodSchema: z.Schema<T, U, unknown>,
+ parseParams?: Partial<z.ParseParams>
+): Validator<T> {
return createValidator({
validate: async (value) => {
const result = await zodSchema.safeParseAsync(value, parseParams);
diff --git a/packages/jobs/src/inngest/functions/events/audit.ts b/packages/jobs/src/inngest/functions/events/audit.ts
index 5cf048c130..9ef9fc6c3f 100644
--- a/packages/jobs/src/inngest/functions/events/audit.ts
+++ b/packages/jobs/src/inngest/functions/events/audit.ts
@@ -33,13 +33,13 @@ const AuditRecordSchema = z.object({
table: z.string(),
operation: z.enum(["INSERT", "UPDATE", "DELETE", "TRUNCATE"]),
recordId: z.string(),
- new: z.record(z.string(), z.any()).nullable(),
- old: z.record(z.string(), z.any()).nullable(),
+ new: z.record(z.any()).nullable(),
+ old: z.record(z.any()).nullable(),
timestamp: z.string()
}),
companyId: z.string(),
actorId: z.string().nullish(),
- handlerConfig: z.record(z.string(), z.any())
+ handlerConfig: z.record(z.any())
});
const AuditPayloadSchema = z.object({
diff --git a/packages/jobs/src/inngest/functions/events/embedding.ts b/packages/jobs/src/inngest/functions/events/embedding.ts
index f4d817faf6..8c4a829d3d 100644
--- a/packages/jobs/src/inngest/functions/events/embedding.ts
+++ b/packages/jobs/src/inngest/functions/events/embedding.ts
@@ -14,8 +14,8 @@ const EmbeddingRecordSchema = z.object({
table: z.string(),
operation: z.enum(["INSERT", "UPDATE", "DELETE", "TRUNCATE"]),
recordId: z.string(),
- new: z.record(z.string(), z.any()).nullable(),
- old: z.record(z.string(), z.any()).nullable(),
+ new: z.record(z.any()).nullable(),
+ old: z.record(z.any()).nullable(),
timestamp: z.string()
}),
companyId: z.string()
diff --git a/packages/jobs/src/inngest/functions/events/search.ts b/packages/jobs/src/inngest/functions/events/search.ts
index 45497c52b1..4dfc9427bb 100644
--- a/packages/jobs/src/inngest/functions/events/search.ts
+++ b/packages/jobs/src/inngest/functions/events/search.ts
@@ -337,8 +337,8 @@ const SearchRecordSchema = z.object({
table: z.string(),
operation: z.enum(["INSERT", "UPDATE", "DELETE", "TRUNCATE"]),
recordId: z.string(),
- new: z.record(z.string(), z.any()).nullable(),
- old: z.record(z.string(), z.any()).nullable(),
+ new: z.record(z.any()).nullable(),
+ old: z.record(z.any()).nullable(),
timestamp: z.string()
}),
companyId: z.string()
diff --git a/packages/jobs/src/inngest/functions/events/webhook-body.ts b/packages/jobs/src/inngest/functions/events/webhook-body.ts
index ce71c5e2d6..73e7ef44d6 100644
--- a/packages/jobs/src/inngest/functions/events/webhook-body.ts
+++ b/packages/jobs/src/inngest/functions/events/webhook-body.ts
@@ -7,8 +7,8 @@ const eventSchema = z.object({
table: z.string(),
operation: z.enum(["INSERT", "UPDATE", "DELETE", "TRUNCATE"]),
recordId: z.string().optional(),
- new: z.record(z.string(), z.any()).nullable().optional(),
- old: z.record(z.string(), z.any()).nullable().optional(),
+ new: z.record(z.any()).nullable().optional(),
+ old: z.record(z.any()).nullable().optional(),
timestamp: z.string().optional()
});
@@ -19,7 +19,7 @@ export const webhookPayloadSchema = z.object({
data: eventSchema,
config: z
.object({
- headers: z.record(z.string(), z.string()).optional(),
+ headers: z.record(z.string()).optional(),
webhookId: z.string().optional()
})
.passthrough()
diff --git a/packages/jobs/src/inngest/functions/integrations/accounting-backfill.ts b/packages/jobs/src/inngest/functions/integrations/accounting-backfill.ts
index f2a929cf65..9a27cb31c1 100644
--- a/packages/jobs/src/inngest/functions/integrations/accounting-backfill.ts
+++ b/packages/jobs/src/inngest/functions/integrations/accounting-backfill.ts
@@ -98,7 +98,7 @@ const BackfillPayloadSchema = z.object({
vendors: z.boolean().default(true),
items: z.boolean().default(true)
})
- .prefault({})
+ .default({})
});
/**
diff --git a/packages/jobs/src/inngest/functions/workflows/moment.ts b/packages/jobs/src/inngest/functions/workflows/moment.ts
index 7b635b0604..bf3cd6464a 100644
--- a/packages/jobs/src/inngest/functions/workflows/moment.ts
+++ b/packages/jobs/src/inngest/functions/workflows/moment.ts
@@ -8,7 +8,7 @@ const momentPayloadSchema = z.object({
momentId: z.string(),
moment: z.string(),
companyId: z.string(),
- outputs: z.record(z.string(), z.object({ id: z.string() }).passthrough())
+ outputs: z.record(z.object({ id: z.string() }).passthrough())
});
/** Moment entry point of the workflow matcher. A moment already IS a catalog event
diff --git a/packages/workflows/src/definition/schema.ts b/packages/workflows/src/definition/schema.ts
index 0884153a29..fcddd44cfd 100644
--- a/packages/workflows/src/definition/schema.ts
+++ b/packages/workflows/src/definition/schema.ts
@@ -69,7 +69,7 @@ const computeNode = z.object({
type: z.literal("compute"),
data: z.object({
operation: z.string(),
- inputs: z.record(z.string(), valueOrRefSchema).default({})
+ inputs: z.record(valueOrRefSchema).default({})
})
});
@@ -99,7 +99,7 @@ const actionNode = z.object({
// No `batch` flag: whether the step repeats is read off the wiring. See `batch.ts`.
data: z.object({
action: z.string(),
- inputs: z.record(z.string(), valueOrRefSchema).default({})
+ inputs: z.record(valueOrRefSchema).default({})
})
});
diff --git a/packages/workflows/src/run-trigger.ts b/packages/workflows/src/run-trigger.ts
index 5a6644d1cc..88de3f0195 100644
--- a/packages/workflows/src/run-trigger.ts
+++ b/packages/workflows/src/run-trigger.ts
@@ -7,14 +7,14 @@ export const runTriggerSchema = z.discriminatedUnion("kind", [
table: z.string(),
recordId: z.string(),
operation: z.enum(["INSERT", "UPDATE", "DELETE"]),
- record: z.record(z.string(), z.unknown()).nullable(),
- before: z.record(z.string(), z.unknown()).nullable(),
- after: z.record(z.string(), z.unknown()).nullable()
+ record: z.record(z.unknown()).nullable(),
+ before: z.record(z.unknown()).nullable(),
+ after: z.record(z.unknown()).nullable()
}),
z.object({
kind: z.literal("moment"),
moment: z.string(),
- outputs: z.record(z.string(), z.object({ id: z.string() }).passthrough())
+ outputs: z.record(z.object({ id: z.string() }).passthrough())
}),
z.object({
kind: z.literal("schedule"),
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index b63c2f090a..9c85227b68 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -271,11 +271,11 @@ catalogs:
specifier: 7.2.0
version: 7.2.0
zod:
- specifier: 4.5.4
- version: 4.5.4
+ specifier: 3.25.76
+ version: 3.25.76
zod-form-data:
- specifier: 3.0.3
- version: 3.0.3
+ specifier: 2.0.8
+ version: 2.0.8
zustand:
specifier: 5.0.12
version: 5.0.12
@@ -535,10 +535,10 @@ importers:
version: 1.0.7([email protected])
zod:
specifier: 'catalog:'
- version: 4.5.4
+ version: 3.25.76
zod-form-data:
specifier: 'catalog:'
- version: 3.0.3([email protected])
+ version: 2.0.8([email protected])
devDependencies:
'@carbon/config':
specifier: workspace:*
@@ -593,31 +593,31 @@ importers:
dependencies:
'@ai-sdk-tools/agents':
specifier: 1.2.0
'@ai-sdk-tools/artifacts':
specifier: 1.2.0
'@ai-sdk-tools/cache':
specifier: 1.2.0
'@ai-sdk-tools/devtools':
specifier: 1.2.0
'@ai-sdk-tools/memory':
specifier: 1.2.0
'@ai-sdk-tools/store':
specifier: 1.2.0
'@ai-sdk/anthropic':
specifier: 2.0.74
- version: 2.0.74([email protected])
+ version: 2.0.74([email protected])
'@ai-sdk/openai':
specifier: 'catalog:'
- version: 2.0.102([email protected])
+ version: 2.0.102([email protected])
'@ai-sdk/react':
specifier: 2.0.174
'@base-ui-components/react':
specifier: 1.0.0-rc.0
@@ -716,7 +716,7 @@ importers:
'@modelcontextprotocol/sdk':
specifier: 1.29.0
- version: 1.29.0([email protected])
+ version: 1.29.0([email protected])
'@monaco-editor/react':
specifier: 4.7.0
@@ -737,7 +737,7 @@ importers:
'@react-router/remix-routes-option-adapter':
specifier: 'catalog:'
'@react-router/serve':
specifier: 'catalog:'
@@ -782,7 +782,7 @@ importers:
'@vercel/react-router':
specifier: 'catalog:'
'@visx/responsive':
specifier: 2.17.0
version: 2.17.0([email protected])
@@ -791,7 +791,7 @@ importers:
ai:
specifier: 5.0.172
- version: 5.0.172([email protected])
+ version: 5.0.172([email protected])
assert-never:
specifier: 1.4.0
version: 1.4.0
@@ -827,7 +827,7 @@ importers:
inngest:
specifier: ^3.52.7
intl-parse-accept-language:
specifier: 'catalog:'
version: 1.0.0
@@ -992,13 +992,13 @@ importers:
version: 1.1.3([email protected])
zod:
specifier: 'catalog:'
- version: 4.5.4
+ version: 3.25.76
zod-form-data:
specifier: 'catalog:'
- version: 3.0.3([email protected])
+ version: 2.0.8([email protected])
zod-to-json-schema:
specifier: 3.25.2
- version: 3.25.2([email protected])
+ version: 3.25.2([email protected])
zustand:
specifier: 'catalog:'
@@ -1014,16 +1014,16 @@ importers:
'@lingui/vite-plugin':
specifier: 'catalog:'
'@react-router/dev':
specifier: 'catalog:'
'@tailwindcss/typography':
specifier: 'catalog:'
version: 0.5.19([email protected])
'@tailwindcss/vite':
specifier: 'catalog:'
'@types/d3':
specifier: 7.4.3
version: 7.4.3
@@ -1083,13 +1083,13 @@ importers:
version: 5.8.3
vite:
specifier: 'catalog:'
vite-plugin-babel-macros:
specifier: 'catalog:'
vitest:
specifier: 'catalog:'
apps/mes:
dependencies:
@@ -1344,10 +1344,10 @@ importers:
zod:
specifier: 'catalog:'
- version: 4.5.4
+ version: 3.25.76
zod-form-data:
specifier: 'catalog:'
- version: 3.0.3([email protected])
+ version: 2.0.8([email protected])
devDependencies:
'@carbon/config':
specifier: workspace:*
@@ -1498,10 +1498,10 @@ importers:
version: 1.0.7([email protected])
zod:
specifier: 'catalog:'
- version: 4.5.4
+ version: 3.25.76
zod-form-data:
specifier: 'catalog:'
- version: 3.0.3([email protected])
+ version: 2.0.8([email protected])
devDependencies:
'@carbon/config':
specifier: workspace:*
@@ -1617,10 +1617,10 @@ importers:
version: 4.6.9
zod:
specifier: 'catalog:'
- version: 4.5.4
+ version: 3.25.76
zod-form-data:
specifier: 'catalog:'
- version: 3.0.3([email protected])
+ version: 2.0.8([email protected])
devDependencies:
'@tailwindcss/vite':
specifier: 'catalog:'
@@ -1881,10 +1881,10 @@ importers:
zod:
specifier: 'catalog:'
- version: 4.5.4
+ version: 3.25.76
zod-form-data:
specifier: 'catalog:'
- version: 3.0.3([email protected])
+ version: 2.0.8([email protected])
zustand:
specifier: 'catalog:'
@@ -2021,7 +2021,7 @@ importers:
version: 4.6.9
zod:
specifier: 'catalog:'
- version: 4.5.4
+ version: 3.25.76
devDependencies:
'@carbon/config':
specifier: workspace:*
@@ -2164,7 +2164,7 @@ importers:
version: 4.6.9
zod:
specifier: 'catalog:'
- version: 4.5.4
+ version: 3.25.76
devDependencies:
'@carbon/config':
specifier: workspace:*
@@ -2234,7 +2234,7 @@ importers:
dependencies:
'@ai-sdk/openai':
specifier: 'catalog:'
- version: 2.0.102([email protected])
+ version: 2.0.102([email protected])
'@carbon/auth':
specifier: workspace:*
version: link:../auth
@@ -2282,7 +2282,7 @@ importers:
version: 2.80.0
ai:
specifier: 5.0.172
- version: 5.0.172([email protected])
+ version: 5.0.172([email protected])
axios:
specifier: 1.16.0
version: 1.16.0
@@ -2327,10 +2327,10 @@ importers:
zod:
specifier: 'catalog:'
- version: 4.5.4
+ version: 3.25.76
zod-form-data:
specifier: 'catalog:'
- version: 3.0.3([email protected])
+ version: 2.0.8([email protected])
devDependencies:
'@carbon/config':
specifier: workspace:*
@@ -2425,7 +2425,7 @@ importers:
version: 1.3.3
zod:
specifier: 'catalog:'
- version: 4.5.4
+ version: 3.25.76
zustand:
specifier: 'catalog:'
@@ -2466,9 +2466,6 @@ importers:
vitest:
specifier: 'catalog:'
- zod-form-data:
- specifier: 'catalog:'
- version: 3.0.3([email protected])
packages/glossary:
dependencies:
@@ -2523,7 +2520,7 @@ importers:
dependencies:
'@ai-sdk/openai':
specifier: 'catalog:'
- version: 2.0.102([email protected])
+ version: 2.0.102([email protected])
'@carbon/auth':
specifier: workspace:*
version: link:../auth
@@ -2586,13 +2583,13 @@ importers:
version: 2.80.0
ai:
specifier: 5.0.172
- version: 5.0.172([email protected])
+ version: 5.0.172([email protected])
axios:
specifier: 1.16.0
version: 1.16.0
inngest:
specifier: ^3.52.7
kysely:
specifier: 'catalog:'
version: 0.28.17
@@ -2631,7 +2628,7 @@ importers:
version: 8.10.0
zod:
specifier: 'catalog:'
- version: 4.5.4
+ version: 3.25.76
devDependencies:
'@carbon/config':
specifier: workspace:*
@@ -2741,7 +2738,7 @@ importers:
version: 2.80.0
inngest:
specifier: 3.54.0
nanoid:
specifier: 'catalog:'
version: 5.1.16
@@ -2756,7 +2753,7 @@ importers:
version: 2.89.0(patch_hash=f278052dbb83b89896a8f742e486a879c8f00b1b22e188717aeb199b1f1a4b4c)
zod:
specifier: 'catalog:'
- version: 4.5.4
+ version: 3.25.76
devDependencies:
'@carbon/config':
specifier: workspace:*
@@ -2903,7 +2900,7 @@ importers:
version: 5.6.0([email protected])
zod:
specifier: 'catalog:'
- version: 4.5.4
+ version: 3.25.76
zustand:
specifier: 'catalog:'
@@ -2952,10 +2949,10 @@ importers:
zod:
specifier: 'catalog:'
- version: 4.5.4
+ version: 3.25.76
zod-form-data:
specifier: 'catalog:'
- version: 3.0.3([email protected])
+ version: 2.0.8([email protected])
devDependencies:
'@carbon/config':
specifier: workspace:*
@@ -3360,7 +3357,7 @@ importers:
version: 5.8.3
zod:
specifier: 'catalog:'
- version: 4.5.4
+ version: 3.25.76
packages/tiptap:
dependencies:
@@ -3544,7 +3541,7 @@ importers:
version: 5.1.16
zod:
specifier: 'catalog:'
- version: 4.5.4
+ version: 3.25.76
devDependencies:
'@carbon/config':
specifier: workspace:*
@@ -3654,7 +3651,7 @@ importers:
zod:
specifier: 'catalog:'
- version: 4.5.4
+ version: 3.25.76
devDependencies:
'@carbon/config':
specifier: workspace:*
@@ -16509,10 +16506,10 @@ packages:
resolution: {integrity: sha512-0LPOt3AxKqMdFBZA3HBAt/t/8vIKq7VaQYbuA8WxCgung+p9TVyKRYdpvCb80HcdTN2NkbIKbhNwKUfm3tQywQ==}
- resolution: {integrity: sha512-1qXJ6hayyUr3TqxfXqmm5qwCa8f/mnG/o8Itcny03iFyrwX/dZkCwfCcYoJDyQP8RxEkycw0c/ldCJXBeaCstg==}
+ resolution: {integrity: sha512-X31GkEc8uk5/L387L4TVI1z7obBbN/0MRHBHfHW3uMOWkVJeSsa+grvkTvY9qyFbNshKEnqK+jLJNlY+d7jpLw==}
peerDependencies:
- zod: '>= 3.25.0'
+ zod: '>= 3.11.0'
resolution: {integrity: sha512-O/PgfnpT1xKSDeQYSCfRI5Gy3hPf91mKVDuYLUHZJMiDFptvP41MSnWofm8dnCm0256ZNfZIM7DSzuSMAFnjHA==}
@@ -16528,9 +16525,6 @@ packages:
resolution: {integrity: sha512-ytENFjIJFl2UwYglde2jchW2Hwm4GJFLDiSXWdTrJQBIN9Fcyp7n4DhxJEiWNAJMV1/BqWfW/kkg71UDcHJyTQ==}
- resolution: {integrity: sha512-sC95tT5iHHH9gtpj6A81kh+NEaRAUFN+qlUPDUbRfOMvNf5QCBqsb3WgvnpVtK5Y+4UfA6KqufotuTvMGiTlsA==}
-
resolution: {integrity: sha512-PIJDIZKtokhof+9+60cpockVOq05sJzHCriyvaLBmEJixseQ1a5Kdov6fWZfWOu5SK9c+FhH1jU0tntLxRJYMA==}
engines: {node: '>=12.7.0'}
@@ -16578,42 +16572,42 @@ packages:
snapshots:
dependencies:
- ai: 5.0.172([email protected])
- zod: 4.5.4
+ ai: 5.0.172([email protected])
+ zod: 3.25.76
optionalDependencies:
- '@ai-sdk-tools/artifacts': 1.2.0([email protected]([email protected]))([email protected])
+ '@ai-sdk-tools/artifacts': 1.2.0([email protected]([email protected]))([email protected])
dependencies:
- ai: 5.0.172([email protected])
+ ai: 5.0.172([email protected])
react: 18.3.1
- zod: 4.5.4
+ zod: 4.4.3
dependencies:
- ai: 5.0.172([email protected])
+ ai: 5.0.172([email protected])
optionalDependencies:
- '@ai-sdk-tools/artifacts': 1.2.0([email protected]([email protected]))([email protected])
+ '@ai-sdk-tools/artifacts': 1.2.0([email protected]([email protected]))([email protected])
dependencies:
- '@ai-sdk/react': 2.0.174([email protected])([email protected])
+ '@ai-sdk/react': 2.0.174([email protected])([email protected])
'@emotion/react': 11.14.0(@types/[email protected])([email protected])
'@emotion/styled': 11.14.1(@emotion/[email protected](@types/[email protected])([email protected]))(@types/[email protected])([email protected])
'@types/dagre': 0.7.54
- ai: 5.0.172([email protected])
+ ai: 5.0.172([email protected])
dagre: 0.8.5
react: 18.3.1
react-dom: 18.3.1([email protected])
react-json-view-lite: 2.5.0([email protected])
optionalDependencies:
- '@ai-sdk-tools/store': 1.2.0(patch_hash=b16f28188d77cbc082143745663e4379eae4fae4380a3d6d1102b960cb829870)(@ai-sdk/[email protected]([email protected])([email protected]))([email protected])([email protected])([email protected](@types/[email protected])([email protected])([email protected])([email protected]([email protected])))
+ '@ai-sdk-tools/store': 1.2.0(patch_hash=b16f28188d77cbc082143745663e4379eae4fae4380a3d6d1102b960cb829870)(@ai-sdk/[email protected]([email protected])([email protected]))([email protected])([email protected])([email protected](@types/[email protected])([email protected])([email protected])([email protected]([email protected])))
transitivePeerDependencies:
- '@mui/material-pigment-css'
- '@types/react'
@@ -16621,19 +16615,19 @@ snapshots:
- supports-color
- zod
dependencies:
- zod: 4.5.4
+ zod: 4.4.3
optionalDependencies:
'@upstash/redis': 1.37.0
- ai: 5.0.172([email protected])
+ ai: 5.0.172([email protected])
ioredis: 5.10.1
dependencies:
- '@ai-sdk/react': 2.0.174([email protected])([email protected])
+ '@ai-sdk/react': 2.0.174([email protected])([email protected])
'@types/node': 24.12.2
- ai: 5.0.172([email protected])
+ ai: 5.0.172([email protected])
react: 18.3.1
transitivePeerDependencies:
@@ -16645,18 +16639,18 @@ snapshots:
'@ai-sdk/provider-utils': 2.2.8([email protected])
zod: 3.25.76
dependencies:
'@ai-sdk/provider': 2.0.1
- '@ai-sdk/provider-utils': 3.0.23([email protected])
- zod: 4.5.4
+ '@ai-sdk/provider-utils': 3.0.23([email protected])
+ zod: 3.25.76
dependencies:
'@ai-sdk/provider': 2.0.1
- '@ai-sdk/provider-utils': 3.0.23([email protected])
+ '@ai-sdk/provider-utils': 3.0.23([email protected])
'@vercel/oidc': 3.1.0
- zod: 4.5.4
+ zod: 3.25.76
dependencies:
@@ -16670,11 +16664,11 @@ snapshots:
'@ai-sdk/provider-utils': 2.2.8([email protected])
zod: 3.25.76
dependencies:
'@ai-sdk/provider': 2.0.1
- '@ai-sdk/provider-utils': 3.0.23([email protected])
- zod: 4.5.4
+ '@ai-sdk/provider-utils': 3.0.23([email protected])
+ zod: 3.25.76
dependencies:
@@ -16683,12 +16677,12 @@ snapshots:
secure-json-parse: 2.7.0
zod: 3.25.76
dependencies:
'@ai-sdk/provider': 2.0.1
'@standard-schema/spec': 1.1.0
eventsource-parser: 3.0.6
- zod: 4.5.4
+ zod: 3.25.76
'@ai-sdk/[email protected]':
dependencies:
@@ -16708,15 +16702,15 @@ snapshots:
optionalDependencies:
zod: 3.25.76
dependencies:
- '@ai-sdk/provider-utils': 3.0.23([email protected])
- ai: 5.0.172([email protected])
+ '@ai-sdk/provider-utils': 3.0.23([email protected])
+ ai: 5.0.172([email protected])
react: 18.3.1
swr: 2.4.1([email protected])
throttleit: 2.1.0
optionalDependencies:
- zod: 4.5.4
+ zod: 3.25.76
dependencies:
@@ -17118,7 +17112,7 @@ snapshots:
'@babel/traverse': 7.29.0
'@babel/types': 7.29.0
convert-source-map: 2.0.0
- debug: 4.4.3([email protected])
+ debug: 4.4.3([email protected])
gensync: 1.0.0-beta.2
json5: 2.2.3
semver: 7.7.4
@@ -17138,7 +17132,7 @@ snapshots:
'@babel/types': 7.29.0
'@jridgewell/remapping': 2.3.5
convert-source-map: 2.0.0
- debug: 4.4.3([email protected])
+ debug: 4.4.3([email protected])
gensync: 1.0.0-beta.2
json5: 2.2.3
semver: 7.7.4
@@ -17308,7 +17302,7 @@ snapshots:
'@babel/parser': 7.29.2
'@babel/template': 7.28.6
'@babel/types': 7.29.0
- debug: 4.4.3([email protected])
+ debug: 4.4.3([email protected])
globals: 11.12.0
transitivePeerDependencies:
- supports-color
@@ -17321,7 +17315,7 @@ snapshots:
'@babel/parser': 7.29.2
'@babel/template': 7.28.6
'@babel/types': 7.29.0
- debug: 4.4.3([email protected])
+ debug: 4.4.3([email protected])
transitivePeerDependencies:
- supports-color
@@ -18340,6 +18334,16 @@ snapshots:
- supports-color
- typescript
+ dependencies:
+ '@lingui/cli': 5.9.4([email protected])([email protected])
+ '@lingui/conf': 5.9.4([email protected])
+ transitivePeerDependencies:
+ - babel-plugin-macros
+ - supports-color
+ - typescript
+
dependencies:
'@lingui/cli': 5.9.4([email protected])([email protected])
@@ -18417,7 +18421,7 @@ snapshots:
'@mjackson/[email protected]': {}
- '@modelcontextprotocol/[email protected]([email protected])':
+ '@modelcontextprotocol/[email protected]([email protected])':
dependencies:
'@hono/node-server': 1.19.13([email protected])
ajv: 8.18.0
@@ -18434,8 +18438,8 @@ snapshots:
json-schema-typed: 8.0.2
pkce-challenge: 5.0.1
raw-body: 3.0.2
- zod: 4.5.4
- zod-to-json-schema: 3.25.2([email protected])
+ zod: 3.25.76
+ zod-to-json-schema: 3.25.2([email protected])
transitivePeerDependencies:
- supports-color
@@ -18701,7 +18705,7 @@ snapshots:
dependencies:
'@oclif/core': 4.11.7
ansis: 3.17.0
- debug: 4.4.3([email protected])
+ debug: 4.4.3([email protected])
npm: 11.17.0
npm-package-arg: 11.0.3
npm-run-path: 5.3.0
@@ -22197,6 +22201,56 @@ snapshots:
- tsx
- yaml
+ dependencies:
+ '@babel/core': 7.29.0
+ '@babel/generator': 7.29.1
+ '@babel/parser': 7.29.2
+ '@babel/plugin-syntax-jsx': 7.28.6(@babel/[email protected])
+ '@babel/preset-typescript': 7.28.5(@babel/[email protected])
+ '@babel/traverse': 7.29.0
+ '@babel/types': 7.29.0
+ '@remix-run/node-fetch-server': 0.13.1
+ arg: 5.0.2
+ babel-dead-code-elimination: 1.0.12
+ chokidar: 4.0.3
+ dedent: 1.7.2([email protected])
+ es-module-lexer: 1.7.0
+ exit-hook: 2.2.1
+ isbot: 5.1.37
+ jsesc: 3.0.2
+ lodash: 4.18.1
+ p-map: 7.0.4
+ pathe: 1.1.2
+ picocolors: 1.1.1
+ pkg-types: 2.3.0
+ prettier: 3.8.1
+ react-refresh: 0.14.2
+ semver: 7.7.4
+ tinyglobby: 0.2.17
+ valibot: 1.3.1([email protected])
+ optionalDependencies:
+ typescript: 5.8.3
+ transitivePeerDependencies:
+ - '@types/node'
+ - babel-plugin-macros
+ - jiti
+ - less
+ - lightningcss
+ - sass
+ - sass-embedded
+ - stylus
+ - sugarss
+ - supports-color
+ - terser
+ - tsx
+ - yaml
+
dependencies:
'@babel/core': 7.29.0
@@ -22275,6 +22329,12 @@ snapshots:
optionalDependencies:
typescript: 5.8.3
+ dependencies:
+ optionalDependencies:
+ typescript: 5.8.3
+
dependencies:
@@ -23560,6 +23620,13 @@ snapshots:
postcss-selector-parser: 6.0.10
tailwindcss: 4.3.0
+ dependencies:
+ '@tailwindcss/node': 4.3.0
+ '@tailwindcss/oxide': 4.3.0
+ tailwindcss: 4.3.0
+
dependencies:
'@tailwindcss/node': 4.3.0
@@ -24339,7 +24406,7 @@ snapshots:
dependencies:
'@types/node': 22.19.7
tapable: 2.3.3
transitivePeerDependencies:
- '@minify-html/node'
- '@swc/core'
@@ -24437,6 +24504,16 @@ snapshots:
react-dom: 18.3.1([email protected])
ts-morph: 12.0.0
+ dependencies:
+ '@vercel/static-config': 3.2.0
+ isbot: 5.1.37
+ react: 18.3.1
+ react-dom: 18.3.1([email protected])
+ ts-morph: 12.0.0
+
dependencies:
@@ -24583,6 +24660,14 @@ snapshots:
optionalDependencies:
+ dependencies:
+ '@vitest/spy': 4.1.6
+ estree-walker: 3.0.3
+ magic-string: 0.30.21
+ optionalDependencies:
+
dependencies:
'@vitest/spy': 4.1.6
@@ -24768,13 +24853,13 @@ snapshots:
optionalDependencies:
react: 18.3.1
dependencies:
- '@ai-sdk/gateway': 2.0.76([email protected])
+ '@ai-sdk/gateway': 2.0.76([email protected])
'@ai-sdk/provider': 2.0.1
- '@ai-sdk/provider-utils': 3.0.23([email protected])
+ '@ai-sdk/provider-utils': 3.0.23([email protected])
'@opentelemetry/api': 1.9.0
- zod: 4.5.4
+ zod: 3.25.76
optionalDependencies:
@@ -25042,7 +25127,7 @@ snapshots:
dependencies:
bytes: 3.1.2
content-type: 1.0.5
- debug: 4.4.3([email protected])
+ debug: 4.4.3([email protected])
http-errors: 2.0.1
iconv-lite: 0.7.2
on-finished: 2.4.1
@@ -25909,7 +25994,7 @@ snapshots:
dependencies:
'@socket.io/component-emitter': 3.1.2
- debug: 4.4.3([email protected])
+ debug: 4.4.3([email protected])
engine.io-parser: 5.2.3
ws: 8.21.0
xmlhttprequest-ssl: 2.1.2
@@ -25929,7 +26014,7 @@ snapshots:
base64id: 2.0.0
cookie: 0.7.2
cors: 2.8.6
- debug: 4.4.3([email protected])
+ debug: 4.4.3([email protected])
engine.io-parser: 5.2.3
ws: 8.21.0
transitivePeerDependencies:
@@ -26346,7 +26431,7 @@ snapshots:
content-type: 1.0.5
cookie: 0.7.2
cookie-signature: 1.2.2
- debug: 4.4.3([email protected])
+ debug: 4.4.3([email protected])
depd: 2.0.0
encodeurl: 2.0.0
escape-html: 1.0.3
@@ -26475,7 +26560,7 @@ snapshots:
dependencies:
- debug: 4.4.3([email protected])
+ debug: 4.4.3([email protected])
encodeurl: 2.0.0
escape-html: 1.0.3
on-finished: 2.4.1
@@ -27040,14 +27125,14 @@ snapshots:
dependencies:
agent-base: 7.1.4
- debug: 4.4.3([email protected])
+ debug: 4.4.3([email protected])
transitivePeerDependencies:
- supports-color
dependencies:
agent-base: 9.0.0
- debug: 4.4.3([email protected])
+ debug: 4.4.3([email protected])
transitivePeerDependencies:
- supports-color
@@ -27141,7 +27226,7 @@ snapshots:
dependencies:
'@bufbuild/protobuf': 2.11.0
'@inngest/ai': 0.1.7
@@ -27160,7 +27245,7 @@ snapshots:
canonicalize: 1.0.8
chalk: 4.1.2
cross-fetch: 4.1.0([email protected])
- debug: 4.4.3([email protected])
+ debug: 4.4.3([email protected])
hash.js: 1.1.7
json-stringify-safe: 5.0.1
ms: 2.1.3
@@ -27168,7 +27253,7 @@ snapshots:
strip-ansi: 5.2.0
temporal-polyfill: 0.2.5
ulid: 2.4.0
- zod: 4.5.4
+ zod: 3.25.76
optionalDependencies:
express: 4.22.1
hono: 4.12.25
@@ -27179,7 +27264,7 @@ snapshots:
- encoding
- supports-color
dependencies:
'@bufbuild/protobuf': 2.11.0
'@inngest/ai': 0.1.7
@@ -27198,7 +27283,7 @@ snapshots:
canonicalize: 1.0.8
chalk: 4.1.2
cross-fetch: 4.1.0([email protected])
- debug: 4.4.3([email protected])
+ debug: 4.4.3([email protected])
hash.js: 1.1.7
json-stringify-safe: 5.0.1
ms: 2.1.3
@@ -27206,7 +27291,7 @@ snapshots:
strip-ansi: 5.2.0
temporal-polyfill: 0.2.5
ulid: 2.4.0
- zod: 4.5.4
+ zod: 3.25.76
optionalDependencies:
express: 5.2.1
hono: 4.12.25
@@ -27260,7 +27345,7 @@ snapshots:
dependencies:
'@ioredis/commands': 1.5.1
cluster-key-slot: 1.1.2
- debug: 4.4.3([email protected])
+ debug: 4.4.3([email protected])
denque: 2.1.0
lodash.defaults: 4.2.0
lodash.isarguments: 3.1.0
@@ -28389,7 +28474,7 @@ snapshots:
dependencies:
'@types/debug': 4.1.13
- debug: 4.4.3([email protected])
+ debug: 4.4.3([email protected])
decode-named-character-reference: 1.3.0
devlop: 1.1.0
micromark-core-commonmark: 2.0.3
@@ -28459,7 +28544,7 @@ snapshots:
jest-worker: 27.5.1
schema-utils: 4.3.3
terser: 5.48.0
optionalDependencies:
esbuild: 0.25.0
lightningcss: 1.32.0
@@ -29988,7 +30073,7 @@ snapshots:
dependencies:
- debug: 4.4.3([email protected])
+ debug: 4.4.3([email protected])
module-details-from-path: 1.0.4
resolve: 1.22.11
transitivePeerDependencies:
@@ -29996,7 +30081,7 @@ snapshots:
dependencies:
- debug: 4.4.3([email protected])
+ debug: 4.4.3([email protected])
module-details-from-path: 1.0.4
transitivePeerDependencies:
- supports-color
@@ -30113,7 +30198,7 @@ snapshots:
dependencies:
- debug: 4.4.3([email protected])
+ debug: 4.4.3([email protected])
depd: 2.0.0
is-promise: 4.0.0
parseurl: 1.3.3
@@ -30221,7 +30306,7 @@ snapshots:
dependencies:
- debug: 4.4.3([email protected])
+ debug: 4.4.3([email protected])
encodeurl: 2.0.0
escape-html: 1.0.3
etag: 1.8.1
@@ -30401,7 +30486,7 @@ snapshots:
dependencies:
- debug: 4.4.3([email protected])
+ debug: 4.4.3([email protected])
ws: 8.21.0
transitivePeerDependencies:
- bufferutil
@@ -30422,7 +30507,7 @@ snapshots:
dependencies:
'@socket.io/component-emitter': 3.1.2
- debug: 4.4.3([email protected])
+ debug: 4.4.3([email protected])
transitivePeerDependencies:
- supports-color
@@ -30431,7 +30516,7 @@ snapshots:
accepts: 1.3.8
base64id: 2.0.0
cors: 2.8.6
- debug: 4.4.3([email protected])
+ debug: 4.4.3([email protected])
engine.io: 6.6.9
socket.io-adapter: 2.5.8
socket.io-parser: 4.2.7
@@ -30888,7 +30973,7 @@ snapshots:
dependencies:
callsites: 3.1.0
- debug: 4.4.3([email protected])
+ debug: 4.4.3([email protected])
is-observable: 2.1.0
observable-fns: 0.6.1
optionalDependencies:
@@ -31029,7 +31114,7 @@ snapshots:
cac: 6.7.14
chokidar: 4.0.3
consola: 3.4.2
- debug: 4.4.3([email protected])
+ debug: 4.4.3([email protected])
esbuild: 0.27.7
fix-dts-default-cjs-exports: 1.0.1
joycon: 3.1.1
@@ -31057,7 +31142,7 @@ snapshots:
cac: 6.7.14
chokidar: 4.0.3
consola: 3.4.2
- debug: 4.4.3([email protected])
+ debug: 4.4.3([email protected])
esbuild: 0.27.7
fix-dts-default-cjs-exports: 1.0.1
joycon: 3.1.1
@@ -31359,7 +31444,7 @@ snapshots:
dependencies:
cac: 6.7.14
- debug: 4.4.3([email protected])
+ debug: 4.4.3([email protected])
es-module-lexer: 1.7.0
pathe: 2.0.3
@@ -31380,7 +31465,7 @@ snapshots:
dependencies:
cac: 6.7.14
- debug: 4.4.3([email protected])
+ debug: 4.4.3([email protected])
es-module-lexer: 1.7.0
pathe: 2.0.3
@@ -31420,6 +31505,17 @@ snapshots:
transitivePeerDependencies:
- supports-color
+ dependencies:
+ '@babel/core': 7.29.0
+ '@babel/plugin-syntax-jsx': 7.28.6(@babel/[email protected])
+ '@babel/plugin-syntax-typescript': 7.28.6(@babel/[email protected])
+ '@types/babel__core': 7.20.5
+ babel-plugin-macros: 3.1.0
+ transitivePeerDependencies:
+ - supports-color
+
dependencies:
'@babel/core': 7.29.0
@@ -31516,6 +31612,22 @@ snapshots:
tsx: 4.21.0
yaml: 2.8.3
+ dependencies:
+ lightningcss: 1.32.0
+ picomatch: 4.0.4
+ postcss: 8.5.18
+ rolldown: 1.0.3
+ tinyglobby: 0.2.17
+ optionalDependencies:
+ '@types/node': 26.1.0
+ esbuild: 0.27.7
+ fsevents: 2.3.3
+ jiti: 2.7.0
+ terser: 5.48.0
+ tsx: 4.21.0
+ yaml: 2.8.3
+
dependencies:
lightningcss: 1.32.0
@@ -31672,6 +31784,34 @@ snapshots:
transitivePeerDependencies:
- msw
+ dependencies:
+ '@vitest/expect': 4.1.6
+ '@vitest/pretty-format': 4.1.6
+ '@vitest/runner': 4.1.6
+ '@vitest/snapshot': 4.1.6
+ '@vitest/spy': 4.1.6
+ '@vitest/utils': 4.1.6
+ es-module-lexer: 2.3.0
+ expect-type: 1.3.0
+ magic-string: 0.30.21
+ obug: 2.1.1
+ pathe: 2.0.3
+ picomatch: 4.0.4
+ std-env: 4.0.0
+ tinybench: 2.9.0
+ tinyexec: 1.2.4
+ tinyglobby: 0.2.17
+ tinyrainbow: 3.1.0
+ why-is-node-running: 2.3.0
+ optionalDependencies:
+ '@opentelemetry/api': 1.9.0
+ '@types/node': 26.1.0
+ transitivePeerDependencies:
+ - msw
+
dependencies:
'@vitest/expect': 4.1.6
@@ -31738,7 +31878,7 @@ snapshots:
dependencies:
'@types/estree': 1.0.8
'@types/json-schema': 7.0.15
@@ -31915,27 +32055,21 @@ snapshots:
dependencies:
'@rvf/set-get': 7.0.2
- zod: 4.5.4
+ zod: 3.25.76
dependencies:
zod: 3.25.76
- dependencies:
- zod: 4.5.4
-
-
optionalDependencies:
react: 18.3.1
diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml
index 9e115bd770..8fda1a04e7 100644
--- a/pnpm-workspace.yaml
+++ b/pnpm-workspace.yaml
@@ -148,6 +148,6 @@ catalog:
vite-plugin-babel-macros: 1.0.6
vitest: 4.1.6
wait-on: 7.2.0
- zod: 4.5.4
- zod-form-data: 3.0.3
+ zod: 3.25.76
+ zod-form-data: 2.0.8
zustand: 5.0.12