Conversation
…DB models, and customer->project wiring
- prisma/schema.prisma
- Tighten zod-prisma-types generator config (disable many auto-created input types, keep model types, enable some options)
- Add PrebuiltWorkflowRun model for persisting execution runs
- Add relation Project.customerId -> Customer (nullable) and Customer.projects relation
- Wire Organization.prebuiltWorkflowRuns
- Add indexes for customerId on Project
- prisma/migrations
- Add SQL migrations for PrebuiltWorkflowConfig and PrebuiltWorkflowRun tables (migration files created)
- src/workflows/prebuilt/executor.ts
- New large PrebuiltWorkflowExecutor implementation
- Loads configured prebuilt workflows, evaluates handlers, creates run records, updates status/results
- Handlers provided for common scenarios: lead->client conversion, client onboarding, project lifecycle, invoice tracking, contract renewal, internal health
- Utilities for template rendering, email sending, invoice/project/customer helpers, safe coercion and formatting
- Exposes prebuiltWorkflowExecutor singleton and PrebuiltWorkflowExecutionSummary type
- Uses prisma client and EmailService, records run metadata and execution details
- src/lib/workflow-dispatcher.ts
- Integrate prebuiltWorkflowExecutor.execute(event) into dispatch flow
- Capture summary results and return them on DispatchResult.prebuiltExecutions
- Error-tolerant call (logs and continues if prebuilt execution fails)
- src/server/api/routers/crm/contacts.ts
- src/server/api/routers/crm/interactions.ts
- Adjust to z.custom<Prisma.*> fallbacks for input schemas (generator no longer produces input zod types)
- src/server/api/routers/projects/project.ts
- Add support to filter projects by customerId and validate access
- Include customer preview info in project queries (select customer fields)
- Support customerId in create/update payloads, resolve and validate customer, and include customer metadata in WorkflowEvents payloads
- Add deriveCustomerName helper to compute a display name from customer first/last/company
- Stronger typing for project payloads and included relations
- src/types/{expenses,finance,hr}.ts
- Rework type exports: continue to re-export model schemas/types from generated zod
- Provide local zod.custom<Prisma.*CreateInput|UpdateInput> fallbacks for input schemas that are no longer generated by the zod generator
- Reorganize and export additional model/enums where appropriate
Why:
- Introduce a pluggable "prebuilt workflows" system to run canned automation (email notifications, provisioning, invoice drafts, etc.) without requiring user-created workflows
- Persist workflow run records for visibility and troubleshooting
- Adjust zod generation strategy to avoid generating input types; provide local fallbacks to keep compile-time validation and typing consistent
- Wire customers to projects and enhance projects API so workflows and UI can show customer metadata
Notes:
- Large new executor file implements many domain-specific heuristics — review handlers and templates for org-specific needs and edge cases.
- Migration SQL files added; run prisma migrate to apply DB changes.
- Some runtime behavior depends on EmailService and PREBUILT_WORKFLOWS definitions (not modified here).
…project->customer wiring, executor improvements and UI polish - prisma: add messageTemplateId to PrebuiltWorkflowConfig (nullable) and customerId to Project; add indexes and FK; add migration SQL - generated/zod: update PrebuiltWorkflowConfig schema to include messageTemplateId - server/workflows/prebuilt: enhance prebuilt router to resolve and link message templates (system & action templates), return preview/linkedTemplate metadata, accept templateId in updateTemplate - workflows/executor & dispatcher & logger: - add detailed prebuilt execution logging (logPrebuiltExecutionSummary) and emit summary from dispatcher - refactor and harden PrebuiltWorkflowExecutor: improved matching, richer logging, new invoice creation for project-based invoice tracking, better recipient/customer resolution, more robust handlers and error handling - add helper utilities (createProjectInvoice, buildInvoiceTrackingVariablesFromProject, etc.) - UI: - add Switch UI component (Radix wrapper) and use it in workflows list for toggle control - add "Beta" badge to Workflows nav item and badge support in NavMain - message-template-picker: add showCreateButton toggle - project create/edit dialogs: wire customerId field to contacts API and add customer select to forms - next.config: remove bundle-analyzer wrapper and export config directly - package/bun.lock: add @radix-ui/react-switch dependency - cosmetic & UX: numerous UI improvements to workflows list/detail (cards, badges, skeletons, alerts, separators) and clearer error / loading states
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.