feat(post-audit): Phase 3 EOI overrides + 3c spawn + 3d promote + Phase 4 worker
Phase 3b — EOI dialog field overrides:
- New EoiOverridesInput shape (clientEmail / clientPhone / yachtName)
threaded through generate-and-sign validator + both pathways
(in-app pdf-lib fill, Documenso template generate).
- src/lib/services/eoi-overrides.service.ts applies side-effects in one
transaction: useOnlyForThisEoi writes documents.override_* and stops;
setAsDefault demotes the prior primary + promotes (existing contactId)
or inserts + promotes (fresh value); neither flag inserts a non-primary
client_contacts row for future dropdown reuse.
- Document override columns persisted post-insert, with a 1-minute
source_document_id backfill on freshly inserted contact rows.
- eoi-context route returns available.{emails, phones} so the dialog
can render combobox options.
- <OverridableContactField> in eoi-generate-dialog.tsx renders the
combobox + manual input + 2 checkboxes per field with mutually
exclusive intent semantics.
Phase 3c — yacht spawn from EOI dialog:
- YachtForm gains createExtras + onCreated callbacks; the EOI dialog
opens it as a nested Sheet pre-filled with the linked client as owner.
On save the new yacht is stamped source='eoi-generated' and the
interest is PATCHed with the new yachtId so the EOI context reflows.
Phase 3d — promote-to-primary + audit + [EOI] badge:
- POST /api/v1/clients/:id/contacts/:contactId/promote-to-primary
(transactional demote+promote via promoteContactToPrimary).
- src/lib/audit.ts AuditAction type adds eoi_field_override,
promote_to_primary, eoi_spawn_yacht (DB column is free-text).
- ContactsEditor surfaces an [EOI] badge on non-primary rows where
source='eoi-custom-input'.
Phase 4 — worker + TOD picker:
- processOverdueReminders refactored to UPDATE...RETURNING with a
fired_at IS NULL gate so parallel workers can't double-fire. Uses
the idx_reminders_due_unfired partial index from migration 0072.
- /settings gets a "Default reminder time" time-of-day picker; the
value lands in user_profiles.preferences.digestTimeOfDay (validated
HH:MM at the route). <ReminderForm> seeds its dueAt from this
preference via a React-Query me-prefs fetch.
Phase 6 hardening:
- IMAP bounce poller strips whitespace from IMAP_PASS so a copy-paste
of Google Workspace's 16-char App Password formatted as
"abcd efgh ijkl mnop" still authenticates. Workspace activation
procedure documented in MASTER-PLAN §Phase 6 (was previously written
to CLAUDE.md, which was bloat — moved to the plan).
Quality gates: 1374/1374 vitest, tsc clean, lint 0 errors.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -63,6 +63,29 @@ export const generateSchema = z.object({
|
||||
berthId: z.string().optional(),
|
||||
});
|
||||
|
||||
/**
|
||||
* Phase 3b — per-field override descriptor used by the EOI dialog.
|
||||
*
|
||||
* Three modes:
|
||||
* - `useOnlyForThisEoi=true` → write the value to documents.override_*
|
||||
* and stop; client_contacts is untouched.
|
||||
* - `setAsDefault=true` + new value → insert a client_contacts row
|
||||
* (source='eoi-custom-input', source_document_id=this EOI), promote
|
||||
* to primary inside a transaction (demote the prior primary first).
|
||||
* - `setAsDefault=true` + existing `contactId` → promote that row.
|
||||
* - both flags false + new value → insert a non-primary client_contacts
|
||||
* row only (rep typed a fresh value but doesn't want it as default).
|
||||
*/
|
||||
const fieldOverrideSchema = z.object({
|
||||
value: z.string().min(1).max(500),
|
||||
useOnlyForThisEoi: z.boolean().default(false),
|
||||
setAsDefault: z.boolean().default(false),
|
||||
/** When the value comes from an existing client_contacts row, the rep
|
||||
* picked it from the combobox — pass the id so the service can skip
|
||||
* re-inserting and just promote it (when setAsDefault is set). */
|
||||
contactId: z.string().uuid().optional(),
|
||||
});
|
||||
|
||||
export const generateAndSignSchema = generateSchema.extend({
|
||||
pathway: z.enum(['inapp', 'documenso-template']).default('inapp'),
|
||||
signers: z
|
||||
@@ -80,6 +103,14 @@ export const generateAndSignSchema = generateSchema.extend({
|
||||
* EOI's Length/Width/Draft formValues. The drawer's toggle drives this;
|
||||
* server defaults to the yacht's `lengthUnit` column when omitted. */
|
||||
dimensionUnit: z.enum(['ft', 'm']).optional(),
|
||||
/** Phase 3b — optional per-field overrides applied at generation. */
|
||||
overrides: z
|
||||
.object({
|
||||
clientEmail: fieldOverrideSchema.optional(),
|
||||
clientPhone: fieldOverrideSchema.optional(),
|
||||
yachtName: fieldOverrideSchema.optional(),
|
||||
})
|
||||
.optional(),
|
||||
});
|
||||
|
||||
export type CreateTemplateInput = z.infer<typeof createTemplateSchema>;
|
||||
|
||||
@@ -34,6 +34,11 @@ export const createYachtSchema = z.object({
|
||||
status: z.enum(['active', 'retired', 'sold_away']).optional().default('active'),
|
||||
notes: z.string().optional(),
|
||||
tagIds: z.array(z.string()).optional().default([]),
|
||||
// Phase 3c — origin tracking. Defaults to 'manual'; the EOI spawn flow
|
||||
// sends 'eoi-generated' and the migration-0073 CHECK enforces the
|
||||
// values at the DB level.
|
||||
source: z.enum(['manual', 'imported', 'eoi-generated']).optional(),
|
||||
sourceDocumentId: z.string().uuid().optional(),
|
||||
});
|
||||
|
||||
export const updateYachtSchema = createYachtSchema.partial().omit({ owner: true });
|
||||
|
||||
Reference in New Issue
Block a user