fix(documents): gate selected_custom_fields behind editable guard; bound index cap to column width

Addresses review: add selected_custom_fields to offers/issued-orders
NON_STATUS_UPDATE_FIELDS so a non-editable document rejects selection
edits (status-only transitions still pass); tighten Zod cap 200->50 to
stay within VARCHAR(255).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
BOHA
2026-06-16 20:31:58 +02:00
parent 59f555059b
commit fb480d886d
5 changed files with 6 additions and 4 deletions

View File

@@ -53,7 +53,7 @@ export const CreateInvoiceSchema = z.object({
// Positional indices of company custom fields to print on this document's PDF.
selected_custom_fields: z
.array(z.number().int().nonnegative())
.max(200)
.max(50)
.optional(),
});
@@ -81,7 +81,7 @@ export const UpdateInvoiceSchema = z.object({
sections: z.array(DocumentSectionSchema).optional(),
selected_custom_fields: z
.array(z.number().int().nonnegative())
.max(200)
.max(50)
.optional(),
});

View File

@@ -45,7 +45,7 @@ export const CreateIssuedOrderSchema = z.object({
// PDF. Omitted/empty ⇒ none. Update schema derives via .partial().
selected_custom_fields: z
.array(z.number().int().nonnegative())
.max(200)
.max(50)
.optional(),
});

View File

@@ -52,7 +52,7 @@ export const CreateQuotationSchema = z.object({
// PDF. Omitted/empty ⇒ none. Update schema derives via .partial().
selected_custom_fields: z
.array(z.number().int().nonnegative())
.max(200)
.max(50)
.optional(),
});

View File

@@ -129,6 +129,7 @@ const NON_STATUS_UPDATE_FIELDS = [
"language",
"order_text",
"internal_notes",
"selected_custom_fields",
"items",
"sections",
] as const;

View File

@@ -68,6 +68,7 @@ const NON_STATUS_UPDATE_FIELDS = [
"language",
"scope_title",
"scope_description",
"selected_custom_fields",
"items",
"sections",
] as const;