Some checks are pending
Bidi Control Character Guard / bidi-control-guard (push) Waiting to run
Circular Dependency Check / Check for new circular dependencies (push) Waiting to run
Citus Migration Smoke / Combined migrations on single-node Citus (push) Waiting to run
E2E Fresh Install Tests / fresh-install-e2e (push) Waiting to run
ext-v2 guardrails / Run ext-v2 guard and ESLint (push) Waiting to run
Integration Tests / Check for relevant changes (push) Waiting to run
Integration Tests / ${{ (github.event_name == 'schedule' || github.event.inputs.suite == 'full') && 'Full integration suite' || 'Tier-1 integration subset' }} (push) Blocked by required conditions
Mobile checks / Mobile lint + typecheck (push) Waiting to run
Mobile checks / Mobile unit tests (push) Waiting to run
Mobile checks / Mobile dependency audit (report) (push) Waiting to run
Mobile checks / Mobile reproducibility checks (push) Waiting to run
Secrets guard (env backups) / Ensure no tracked env backup files (push) Waiting to run
Temporal Readiness / fast-readiness (push) Waiting to run
Temporal Readiness / docker-parity (push) Waiting to run
TypeScript Type Check / Nx affected typecheck (push) Waiting to run
Unit Tests / Skipped-test budget (push) Waiting to run
Unit Tests / Nx affected unit tests (push) Waiting to run
Unit Tests / Server unit coverage (informational) (push) Waiting to run
Validate Tenant Management Schema / Check for relevant changes (push) Waiting to run
Validate Tenant Management Schema / Validate Tenant Management Schema (push) Blocked by required conditions
EE Workflows Build Guard / ee-workflows-build-guard (push) Waiting to run
Excluded: .git, node_modules, secrets/, compose.env, assemblyscript tgz Source: /opt/alga-psa on psa.joliet.tech
10 KiB
10 KiB
Scratchpad — CRM Workflow Follow-up Actions
- Plan slug:
workflow-crm-followup-actions - Created:
2026-04-25
What This Is
Rolling notes for the second CRM workflow action wave after first-pass CRM activity lookup/update/scheduling and quote send actions.
Decisions
- (2026-04-25) This follow-up plan covers the remaining recommended actions:
crm.create_interaction_type,crm.update_activity_status,crm.create_quote,crm.add_quote_item,crm.create_quote_from_template,crm.find_quotes,crm.submit_quote_for_approval,crm.convert_quote, andcrm.tag_activity. - (2026-04-25) Keep actions under
crm.*so existing designer grouping places them in CRM without catalog seed changes. - (2026-04-25) Do not directly import
withAuthserver actions frompackages/*/src/actions/*into shared workflow runtime code. Extract or use shared-safe model/service helpers instead. - (2026-04-25) Resolved: drop
crm.create_client_notefrom CRM follow-up scope. Useclients.add_notefor client notes and add a futurecontacts.add_noteaction if contact note workflow automation is needed. Rationale: module-specific note actions keep ownership clear and avoid duplicating newly merged Client workflow behavior under CRM. - (2026-04-25) Use current Client workflow action conventions for picker metadata, lazy event publication, deterministic event idempotency keys, action idempotency, and DB-backed tests.
- (2026-04-25) Resolved:
crm.create_quotecreates the quote header only; quote item creation is a separate action namedcrm.add_quote_item. Rationale: keeps header creation simple while still supporting full quote-building workflows in this plan. - (2026-04-25) Resolved: include a separate
crm.create_quote_from_templateaction in this plan. Rationale: templates are important for standardized quote automation, but a dedicated action keeps semantics cleaner than overloadingcrm.create_quote. - (2026-04-25) Resolved:
crm.create_interaction_typerequiressettings:update. Rationale: activity types are tenant CRM taxonomy/configuration, so this should be admin-controlled rather than available to all CRM editors. - (2026-04-25) Resolved:
crm.tag_activityis interaction/activity-specific only. Client and contact tagging stay in their own module actions. Rationale: keeps CRM tag action focused and avoids turning it into a generic tag action. - (2026-04-25) Resolved: quote pipeline actions emit quote-specific workflow events only if matching
QUOTE_*schemas/builders already exist. Otherwise they remain audit-only plus existing quote activity records. Rationale: avoids inventing event contracts inside this plan while preserving event parity if contracts already exist.
Discoveries / Constraints
- (2026-04-25)
packages/clients/src/actions/interactionTypeActions.tshascreateInteractionType, but it is awithAuthserver action. Underlying behavior is simple: insertinteraction_typeswithtype_name,icon,display_order, tenant, andcreated_by. - (2026-04-25)
packages/billing/src/schemas/quoteSchemas.tsdefines quote statuses and allowed transitions. Follow-up quote actions must respect these transitions. - (2026-04-25)
packages/billing/src/models/quote.tsexposes shared-looking model methods such asgetById,getByNumber,listByTenant,listByClient,create, andupdate, but import safety from shared workflow runtime must still be confirmed. - (2026-04-25)
packages/billing/src/models/quoteItem.tsand quote item schema rules should be used or mirrored forcrm.add_quote_item; shared runtime import safety must be confirmed. - (2026-04-25)
packages/billing/src/services/quoteConversionService.tsexposes conversion services for draft contracts/invoices/both. These are promising forcrm.convert_quote, but package-boundary safety still needs confirmation. - (2026-04-25)
packages/tags/src/actions/tagActions.tsshows desired tag semantics: entity update permission, tag create permission for new definitions, tag definition creation, tag mapping insertion, and TAG event publication. It is a server action file and should be used as a behavior reference, not directly imported. - (2026-04-25)
packages/clients/src/actions/clientNoteActions.tsandpackages/clients/src/actions/contact-actions/contactNoteActions.tsshow client/contact notes document behavior and NOTE_CREATED publication. They remain useful references for a future Contact-module note action, but CRM follow-up will not implement a note wrapper. - (2026-04-25)
shared/workflow/runtime/actions/businessOperations/clients.tsalready implementsclients.add_notefor client notes. Do not duplicate that implementation in CRM.
Commands / Runbooks
- (2026-04-25) Discovery commands:
rg -n "export const createInteractionType|updateInteractionType" packages/clients/src/actions/interactionTypeActions.tsrg -n "export const createQuote|sendQuote|submitQuoteForApproval|convertQuote" packages/billing/src/actions/quoteActions.tsrg -n "quoteStatusSchema|QUOTE_ALLOWED_STATUS_TRANSITIONS|canTransitionQuoteStatus" packages/billing/src/schemas/quoteSchemas.tsrg -n "list\\(|QuoteListOptions|getByNumber|getById" packages/billing/src/models/quote.tsrg -n "TAG_DEFINITION_CREATED|TAG_APPLIED|buildTagAppliedPayload" packages/tags/src/actions/tagActions.ts shared/workflow/streams/domainEventBuilders/tagEventBuilders.tsrg -n "notes_document_id|saveClientNote|saveContactNote|NOTE_CREATED" packages/clients/src/actions shared/workflow/runtime/actions/businessOperations/clients.ts
Links / References
- First-pass CRM plan:
ee/docs/plans/2026-04-25-workflow-crm-actions/ shared/workflow/runtime/actions/businessOperations/crm.tsshared/workflow/runtime/actions/businessOperations/clients.tsshared/workflow/runtime/actions/businessOperations/shared.tsshared/workflow/runtime/jsonSchemaMetadata.tspackages/clients/src/actions/interactionTypeActions.tspackages/billing/src/actions/quoteActions.tspackages/billing/src/models/quote.tspackages/billing/src/schemas/quoteSchemas.tspackages/billing/src/services/quoteConversionService.tspackages/tags/src/actions/tagActions.tsshared/workflow/streams/domainEventBuilders/tagEventBuilders.tspackages/clients/src/actions/clientNoteActions.tspackages/clients/src/actions/contact-actions/contactNoteActions.tsshared/workflow/streams/domainEventBuilders/crmInteractionNoteEventBuilders.ts
Open Questions
- Resolved: drop
crm.create_client_note; use module-specific note actions instead. - Resolved:
crm.create_quoteis header-only and quote item creation is handled by separatecrm.add_quote_item. - Resolved: template-based quote creation is included as separate
crm.create_quote_from_template. - Resolved: interaction type creation requires
settings:update. - Resolved:
crm.tag_activityis interaction/activity-specific only; clients/contacts use their own module tag actions. - Resolved: quote pipeline actions emit existing quote events only if matching schemas/builders already exist; otherwise audit-only plus quote activities.
Implementation Log — 2026-04-26
- Implemented follow-up CRM workflow actions in
shared/workflow/runtime/actions/businessOperations/crm.ts:crm.create_interaction_typecrm.update_activity_statuscrm.create_quotecrm.add_quote_itemcrm.create_quote_from_templatecrm.find_quotescrm.submit_quote_for_approvalcrm.convert_quotecrm.tag_activity
- Confirmed these actions are all registered at version
1, side-effect metadata is set, and action-provided idempotency is used for retry-sensitive create/tag/item/template mutations. - Added picker metadata for follow-up quote fields:
crm.create_quote.client_id/contact_idcrm.create_quote_from_template.client_id/contact_id
- Kept first-pass actions intact (
crm.create_activity_note,crm.find_activities,crm.update_activity,crm.schedule_activity,crm.send_quote) and did not remove/rename existing IDs. - Quote pipeline event stance preserved: no new quote event schema contracts were added; quote follow-up actions are audit-driven (plus existing quote model/service activity behavior).
crm.tag_activityremains interaction/activity scoped; client/contact tagging remains module-specific.
Test and Runtime Updates — 2026-04-26
- Updated unit/runtime metadata tests:
shared/workflow/runtime/actions/__tests__/registerCrmActionsMetadata.test.tsshared/workflow/runtime/__tests__/workflowDesignerCrmCatalogRuntime.test.tsshared/workflow/runtime/nodes/__tests__/actionCallCrmSaveAsRuntime.test.ts(switched representative runtime smoke to follow-up actioncrm.find_quotes)
- Expanded DB-backed CRM action suite with follow-up tests in:
shared/workflow/runtime/actions/__tests__/businessOperations.crm.db.test.ts- Added helper
createQuoteItemRecordfor conversion/template/add-item test setup.
Vitest Aliasing Discovery — 2026-04-26
- Shared-runtime tests importing billing/authorization modules required additional aliases in
shared/vitest.config.ts:@shared/*@alga-psa/core/*@alga-psa/db/*
- Without these aliases,
crm.tsimports of billing models/services failed test resolution due unresolved package paths.
Commands Run — 2026-04-26
npx vitest run --config shared/vitest.config.ts shared/workflow/runtime/actions/__tests__/registerCrmActionsMetadata.test.ts shared/workflow/runtime/__tests__/workflowDesignerCrmCatalogRuntime.test.tsnpx vitest run --config shared/vitest.config.ts shared/workflow/runtime/actions/__tests__/registerCrmActionsMetadata.test.ts shared/workflow/runtime/__tests__/workflowDesignerCrmCatalogRuntime.test.ts shared/workflow/runtime/nodes/__tests__/actionCallCrmSaveAsRuntime.test.tsnpx vitest run --config shared/vitest.config.ts shared/workflow/runtime/actions/__tests__/businessOperations.crm.db.test.ts
Test Environment Gotcha
- DB-backed CRM suite currently aborts before execution in this shell because
businessOperations.crm.db.test.tsguards against production DB names and detectsDB_NAME_SERVER=serverfrom environment bootstrap. - Command-level overrides (
DB_NAME_SERVER=test_database ...) did not take effect in this run context; follow-up is to run the DB suite in a sanitized env whereDB_NAME_SERVERresolves to a safe test DB before release sign-off.