@open-mercato/core 0.10.1-develop.7736.1.88e07906bf → 0.10.1-develop.7748.1.d745ba61aa
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +1 -1
- package/dist/generated/entities/api_key/index.js +2 -0
- package/dist/generated/entities/api_key/index.js.map +2 -2
- package/dist/generated/entities/attachment_partition/index.js +2 -0
- package/dist/generated/entities/attachment_partition/index.js.map +2 -2
- package/dist/generated/entity-fields-registry.js +2 -0
- package/dist/generated/entity-fields-registry.js.map +2 -2
- package/dist/helpers/integration/attachmentAccessFixtures.js +144 -0
- package/dist/helpers/integration/attachmentAccessFixtures.js.map +7 -0
- package/dist/modules/api_keys/data/entities.js +7 -0
- package/dist/modules/api_keys/data/entities.js.map +2 -2
- package/dist/modules/api_keys/migrations/Migration20261012202110_api_keys.js +30 -0
- package/dist/modules/api_keys/migrations/Migration20261012202110_api_keys.js.map +7 -0
- package/dist/modules/api_keys/services/apiKeyService.js +31 -9
- package/dist/modules/api_keys/services/apiKeyService.js.map +2 -2
- package/dist/modules/attachments/api/file/[id]/route.js +16 -10
- package/dist/modules/attachments/api/file/[id]/route.js.map +2 -2
- package/dist/modules/attachments/api/image/[id]/[[...slug]]/route.js +15 -9
- package/dist/modules/attachments/api/image/[id]/[[...slug]]/route.js.map +2 -2
- package/dist/modules/attachments/api/library/[id]/route.js +100 -56
- package/dist/modules/attachments/api/library/[id]/route.js.map +3 -3
- package/dist/modules/attachments/api/library/route.js +56 -17
- package/dist/modules/attachments/api/library/route.js.map +2 -2
- package/dist/modules/attachments/api/partitions/route.js +2 -0
- package/dist/modules/attachments/api/partitions/route.js.map +2 -2
- package/dist/modules/attachments/api/route.js +74 -34
- package/dist/modules/attachments/api/route.js.map +3 -3
- package/dist/modules/attachments/api/transfer/route.js +63 -37
- package/dist/modules/attachments/api/transfer/route.js.map +2 -2
- package/dist/modules/attachments/data/entities.js +3 -0
- package/dist/modules/attachments/data/entities.js.map +2 -2
- package/dist/modules/attachments/data/validators.js +41 -0
- package/dist/modules/attachments/data/validators.js.map +7 -0
- package/dist/modules/attachments/di.js +5 -2
- package/dist/modules/attachments/di.js.map +2 -2
- package/dist/modules/attachments/generators.js +29 -0
- package/dist/modules/attachments/generators.js.map +7 -0
- package/dist/modules/attachments/index.js +8 -1
- package/dist/modules/attachments/index.js.map +2 -2
- package/dist/modules/attachments/lib/access-errors.js +35 -0
- package/dist/modules/attachments/lib/access-errors.js.map +7 -0
- package/dist/modules/attachments/lib/access-mutation.js +23 -0
- package/dist/modules/attachments/lib/access-mutation.js.map +7 -0
- package/dist/modules/attachments/lib/access-protection.js +73 -0
- package/dist/modules/attachments/lib/access-protection.js.map +7 -0
- package/dist/modules/attachments/lib/access-query.js +74 -0
- package/dist/modules/attachments/lib/access-query.js.map +7 -0
- package/dist/modules/attachments/lib/access-registry.js +87 -0
- package/dist/modules/attachments/lib/access-registry.js.map +7 -0
- package/dist/modules/attachments/lib/access-runner.js +161 -0
- package/dist/modules/attachments/lib/access-runner.js.map +7 -0
- package/dist/modules/attachments/lib/access-types.js +1 -0
- package/dist/modules/attachments/lib/access-types.js.map +7 -0
- package/dist/modules/attachments/lib/attachment-service.js +14 -6
- package/dist/modules/attachments/lib/attachment-service.js.map +2 -2
- package/dist/modules/attachments/lib/createFromBuffer.js +2 -0
- package/dist/modules/attachments/lib/createFromBuffer.js.map +2 -2
- package/dist/modules/attachments/lib/partitions.js +3 -2
- package/dist/modules/attachments/lib/partitions.js.map +2 -2
- package/dist/modules/attachments/lib/scoped-upload-service.js +2 -0
- package/dist/modules/attachments/lib/scoped-upload-service.js.map +2 -2
- package/dist/modules/attachments/lib/target-access-service.js +12 -3
- package/dist/modules/attachments/lib/target-access-service.js.map +2 -2
- package/dist/modules/attachments/migrations/Migration20261001120000_attachments.js +38 -0
- package/dist/modules/attachments/migrations/Migration20261001120000_attachments.js.map +7 -0
- package/dist/modules/attachments/setup.js +10 -0
- package/dist/modules/attachments/setup.js.map +2 -2
- package/dist/modules/notifications/api/[id]/action/route.js +8 -0
- package/dist/modules/notifications/api/[id]/action/route.js.map +2 -2
- package/dist/modules/notifications/api/route.js +17 -0
- package/dist/modules/notifications/api/route.js.map +2 -2
- package/dist/modules/notifications/data/validators.js +1 -1
- package/dist/modules/notifications/data/validators.js.map +2 -2
- package/dist/modules/notifications/lib/notificationService.js +45 -3
- package/dist/modules/notifications/lib/notificationService.js.map +2 -2
- package/dist/modules/notifications/lib/routeHelpers.js +27 -0
- package/dist/modules/notifications/lib/routeHelpers.js.map +2 -2
- package/dist/modules/payment_gateways/lib/gateway-service.js +50 -34
- package/dist/modules/payment_gateways/lib/gateway-service.js.map +2 -2
- package/dist/modules/payment_gateways/lib/status-machine.js +10 -1
- package/dist/modules/payment_gateways/lib/status-machine.js.map +2 -2
- package/dist/modules/payment_gateways/lib/webhook-processor.js +1 -1
- package/dist/modules/payment_gateways/lib/webhook-processor.js.map +2 -2
- package/dist/modules/staff/notifications.js +4 -2
- package/dist/modules/staff/notifications.js.map +2 -2
- package/dist/modules/workflows/api/portal/tasks/[id]/complete/route.js +1 -1
- package/dist/modules/workflows/api/portal/tasks/[id]/complete/route.js.map +2 -2
- package/dist/modules/workflows/api/tasks/[id]/complete/route.js +7 -1
- package/dist/modules/workflows/api/tasks/[id]/complete/route.js.map +2 -2
- package/dist/modules/workflows/backend/tasks/[id]/page.js +2 -1
- package/dist/modules/workflows/backend/tasks/[id]/page.js.map +2 -2
- package/dist/modules/workflows/data/entities.js.map +2 -2
- package/dist/modules/workflows/lib/activity-executor.js +18 -4
- package/dist/modules/workflows/lib/activity-executor.js.map +2 -2
- package/dist/modules/workflows/lib/activity-types.js +2 -2
- package/dist/modules/workflows/lib/activity-types.js.map +2 -2
- package/dist/modules/workflows/lib/condition-handler.js +7 -1
- package/dist/modules/workflows/lib/condition-handler.js.map +2 -2
- package/dist/modules/workflows/lib/duration.js +13 -0
- package/dist/modules/workflows/lib/duration.js.map +2 -2
- package/dist/modules/workflows/lib/instance-status.js +16 -0
- package/dist/modules/workflows/lib/instance-status.js.map +7 -0
- package/dist/modules/workflows/lib/step-handler.js +9 -2
- package/dist/modules/workflows/lib/step-handler.js.map +2 -2
- package/dist/modules/workflows/lib/task-handler.js +16 -8
- package/dist/modules/workflows/lib/task-handler.js.map +2 -2
- package/dist/modules/workflows/lib/task-quick-action.js +13 -10
- package/dist/modules/workflows/lib/task-quick-action.js.map +2 -2
- package/dist/modules/workflows/lib/task-sla.js +10 -0
- package/dist/modules/workflows/lib/task-sla.js.map +2 -2
- package/dist/modules/workflows/lib/transition-handler.js +2 -1
- package/dist/modules/workflows/lib/transition-handler.js.map +2 -2
- package/dist/modules/workflows/lib/workflow-executor.js +29 -1
- package/dist/modules/workflows/lib/workflow-executor.js.map +2 -2
- package/dist/modules/workflows/notifications.js +4 -0
- package/dist/modules/workflows/notifications.js.map +2 -2
- package/generated/entities/api_key/index.ts +1 -0
- package/generated/entities/attachment_partition/index.ts +1 -0
- package/generated/entity-fields-registry.ts +2 -0
- package/package.json +7 -7
- package/src/helpers/integration/attachmentAccessFixtures.ts +141 -0
- package/src/modules/api_keys/data/entities.ts +25 -1
- package/src/modules/api_keys/migrations/.snapshot-open-mercato.json +234 -68
- package/src/modules/api_keys/migrations/Migration20261012202110_api_keys.ts +47 -0
- package/src/modules/api_keys/services/apiKeyService.ts +55 -9
- package/src/modules/attachments/api/file/[id]/route.ts +12 -9
- package/src/modules/attachments/api/image/[id]/[[...slug]]/route.ts +10 -8
- package/src/modules/attachments/api/library/[id]/route.ts +87 -58
- package/src/modules/attachments/api/library/route.ts +40 -11
- package/src/modules/attachments/api/partitions/route.ts +2 -0
- package/src/modules/attachments/api/route.ts +68 -35
- package/src/modules/attachments/api/transfer/route.ts +65 -42
- package/src/modules/attachments/data/entities.ts +4 -0
- package/src/modules/attachments/data/validators.ts +36 -0
- package/src/modules/attachments/di.ts +4 -1
- package/src/modules/attachments/generators.ts +27 -0
- package/src/modules/attachments/i18n/de.json +4 -0
- package/src/modules/attachments/i18n/en.json +4 -0
- package/src/modules/attachments/i18n/es.json +4 -0
- package/src/modules/attachments/i18n/ko.json +4 -0
- package/src/modules/attachments/i18n/pl.json +4 -0
- package/src/modules/attachments/index.ts +18 -0
- package/src/modules/attachments/lib/access-errors.ts +32 -0
- package/src/modules/attachments/lib/access-mutation.ts +26 -0
- package/src/modules/attachments/lib/access-protection.ts +83 -0
- package/src/modules/attachments/lib/access-query.ts +86 -0
- package/src/modules/attachments/lib/access-registry.ts +117 -0
- package/src/modules/attachments/lib/access-runner.ts +183 -0
- package/src/modules/attachments/lib/access-types.ts +78 -0
- package/src/modules/attachments/lib/attachment-service.ts +8 -4
- package/src/modules/attachments/lib/createFromBuffer.ts +3 -0
- package/src/modules/attachments/lib/partitions.ts +3 -2
- package/src/modules/attachments/lib/scoped-upload-service.ts +2 -0
- package/src/modules/attachments/lib/target-access-service.ts +10 -3
- package/src/modules/attachments/migrations/.snapshot-open-mercato.json +17 -0
- package/src/modules/attachments/migrations/Migration20261001120000_attachments.ts +35 -0
- package/src/modules/attachments/setup.ts +10 -0
- package/src/modules/auth/i18n/de.json +3 -0
- package/src/modules/auth/i18n/en.json +3 -0
- package/src/modules/auth/i18n/es.json +3 -0
- package/src/modules/auth/i18n/ko.json +3 -0
- package/src/modules/auth/i18n/pl.json +3 -0
- package/src/modules/notifications/api/[id]/action/route.ts +8 -0
- package/src/modules/notifications/api/route.ts +17 -0
- package/src/modules/notifications/data/validators.ts +1 -1
- package/src/modules/notifications/i18n/de.json +2 -0
- package/src/modules/notifications/i18n/en.json +2 -0
- package/src/modules/notifications/i18n/es.json +2 -0
- package/src/modules/notifications/i18n/ko.json +2 -0
- package/src/modules/notifications/i18n/pl.json +2 -0
- package/src/modules/notifications/lib/notificationService.ts +67 -1
- package/src/modules/notifications/lib/routeHelpers.ts +38 -0
- package/src/modules/payment_gateways/lib/gateway-service.ts +50 -33
- package/src/modules/payment_gateways/lib/status-machine.ts +19 -0
- package/src/modules/payment_gateways/lib/webhook-processor.ts +1 -1
- package/src/modules/staff/notifications.ts +2 -0
- package/src/modules/workflows/AGENTS.md +2 -2
- package/src/modules/workflows/api/portal/tasks/[id]/complete/route.ts +5 -1
- package/src/modules/workflows/api/tasks/[id]/complete/route.ts +7 -1
- package/src/modules/workflows/backend/tasks/[id]/page.tsx +6 -2
- package/src/modules/workflows/data/entities.ts +6 -0
- package/src/modules/workflows/i18n/de.json +2 -0
- package/src/modules/workflows/i18n/en.json +2 -0
- package/src/modules/workflows/i18n/es.json +2 -0
- package/src/modules/workflows/i18n/ko.json +2 -0
- package/src/modules/workflows/i18n/pl.json +2 -0
- package/src/modules/workflows/lib/activity-executor.ts +36 -4
- package/src/modules/workflows/lib/activity-types.ts +2 -2
- package/src/modules/workflows/lib/condition-handler.ts +16 -1
- package/src/modules/workflows/lib/duration.ts +25 -0
- package/src/modules/workflows/lib/instance-status.ts +29 -0
- package/src/modules/workflows/lib/step-handler.ts +16 -1
- package/src/modules/workflows/lib/task-handler.ts +18 -10
- package/src/modules/workflows/lib/task-quick-action.ts +19 -10
- package/src/modules/workflows/lib/task-sla.ts +13 -0
- package/src/modules/workflows/lib/transition-handler.ts +2 -1
- package/src/modules/workflows/lib/workflow-executor.ts +44 -1
- package/src/modules/workflows/notifications.ts +4 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/modules/workflows/data/entities.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * Workflows Module - Database Entities\n *\n * MikroORM entities for workflow engine.\n */\n\nimport { OptionalProps } from '@mikro-orm/core'\nimport { Entity, Index, PrimaryKey, Property, Unique } from '@mikro-orm/decorators/legacy'\nimport type { WorkflowRunOutcome } from '../lib/run-outcome'\n\nexport type { WorkflowRunOutcome }\n\n// ============================================================================\n// Type Definitions\n// ============================================================================\n\nexport type WorkflowStepType =\n | 'START'\n | 'END'\n | 'USER_TASK'\n | 'AUTOMATED'\n | 'PARALLEL_FORK'\n | 'PARALLEL_JOIN'\n | 'SUB_WORKFLOW'\n | 'WAIT_FOR_SIGNAL'\n | 'WAIT_FOR_TIMER'\n | 'WAIT_FOR_CONDITION'\n | 'IF_ELSE'\n | 'SWITCH'\n\nexport type WorkflowInstanceStatus =\n | 'RUNNING'\n | 'PAUSED'\n | 'COMPLETED'\n | 'FAILED'\n | 'CANCELLED'\n | 'COMPENSATING'\n | 'COMPENSATED'\n | 'WAITING_FOR_ACTIVITIES'\n | 'FORKED'\n\nexport type WorkflowBranchInstanceStatus =\n | 'ACTIVE'\n | 'PAUSED'\n | 'WAITING_FOR_ACTIVITIES'\n | 'COMPLETED'\n | 'FAILED'\n | 'CANCELLED'\n\nexport type StepInstanceStatus =\n | 'PENDING'\n | 'ACTIVE'\n | 'COMPLETED'\n | 'FAILED'\n | 'SKIPPED'\n | 'CANCELLED'\n\nexport type UserTaskStatus =\n | 'PENDING'\n | 'IN_PROGRESS'\n | 'COMPLETED'\n | 'CANCELLED'\n | 'ESCALATED'\n\n/**\n * Which principal namespace `user_tasks.assigned_to` names.\n *\n * `'user'` = a backoffice user id. `'customer'` = a portal principal\n * (`CustomerAuthContext.sub`). A discriminator column rather than a\n * `customer:<id>` string prefix (maintainer decision): a prefix is unindexable,\n * collides with any id containing a colon, and would force a parsing rule into\n * every existing comparison \u2014 the claim filter, the `myWork` `$or`, the\n * reassign write.\n */\nexport type UserTaskAssigneeKind = 'user' | 'customer'\n\n// ============================================================================\n// Event Trigger Types\n// ============================================================================\n\nexport type TriggerFilterOperator =\n | 'eq'\n | 'neq'\n | 'gt'\n | 'gte'\n | 'lt'\n | 'lte'\n | 'contains'\n | 'startsWith'\n | 'endsWith'\n | 'in'\n | 'notIn'\n | 'exists'\n | 'notExists'\n | 'regex'\n\nexport interface TriggerFilterCondition {\n field: string // JSON path (e.g., \"status\", \"metadata.type\")\n operator: TriggerFilterOperator\n value: unknown\n}\n\nexport interface TriggerContextMapping {\n targetKey: string // Key in workflow initial context\n sourceExpression: string // Path from event payload (supports dot notation)\n defaultValue?: unknown\n}\n\nexport interface WorkflowEventTriggerConfig {\n filterConditions?: TriggerFilterCondition[]\n contextMapping?: TriggerContextMapping[]\n debounceMs?: number // Debounce rapid events\n maxConcurrentInstances?: number // Limit concurrent instances\n entityType?: string // Entity type for workflow instance metadata (e.g., \"SalesOrder\")\n}\n\n/**\n * WorkflowDefinitionTrigger - Embedded trigger configuration\n *\n * Triggers are now embedded directly in the workflow definition,\n * allowing users to configure event-based workflow starts during\n * workflow creation in the visual editor.\n */\nexport interface WorkflowDefinitionTrigger {\n triggerId: string\n name: string\n description?: string | null\n eventPattern: string // e.g., \"sales.orders.created\", \"customers.*\"\n config?: WorkflowEventTriggerConfig | null\n enabled: boolean\n priority: number\n}\n\n// ============================================================================\n// JSONB Structure Interfaces\n// ============================================================================\n\nexport interface WorkflowContextSchemaField {\n name: string\n type: 'text' | 'number' | 'boolean' | 'select' | 'date'\n label?: string\n required?: boolean\n options?: string[]\n}\n\nexport interface WorkflowContextSchema {\n input?: {\n fields: WorkflowContextSchemaField[]\n }\n}\n\nexport interface WorkflowIoPortField {\n name: string\n type: 'text' | 'number' | 'boolean' | 'select' | 'date'\n label: string\n required?: boolean\n options?: string[]\n}\n\nexport interface WorkflowIoContract {\n inputs?: WorkflowIoPortField[]\n outputs?: WorkflowIoPortField[]\n}\n\nexport interface WorkflowErrorHandlerData {\n workflowId?: string\n version?: number\n stepId?: string\n}\n\nexport interface WorkflowDefinitionData {\n steps: any[] // WorkflowStep[] - will define schema in validators.ts\n transitions: any[] // WorkflowTransition[] - will define schema in validators.ts\n triggers?: WorkflowDefinitionTrigger[] // Event triggers for automatic workflow start\n contextSchema?: WorkflowContextSchema // Declared typed-input contract (spec \u00A73.1) \u2014 canonical input contract\n io?: WorkflowIoContract // Sub-workflow port contract; io.inputs is a read-through alias of contextSchema.input\n interpolation?: 'strict' | 'lenient' // Interpolation mode (spec \u00A73.6): absent = lenient; create path defaults new definitions to 'strict'\n errorHandler?: WorkflowErrorHandlerData // Catch-all error handler (spec \u00A75.9): a handler workflow OR a handler step, never both\n activities?: any[] // ActivityDefinition[] - will define schema in validators.ts\n queries?: any[]\n signals?: any[]\n timers?: any[]\n}\n\nexport interface WorkflowSampleEnvelope {\n pinnedAt: string\n source: 'manual' | 'test'\n data: unknown\n}\n\nexport interface WorkflowEditorMetadata {\n samples?: Record<string, WorkflowSampleEnvelope>\n [key: string]: unknown\n}\n\n/**\n * Marks a definition another module AUTHORED and keeps in sync, rather than a\n * human writing it in the Studio.\n *\n * It changes nothing about how the definition executes \u2014 a generated workflow is\n * an ordinary workflow, visible and editable like any other. What it records is\n * WHO regenerates it, so the owning module knows which row is its own and the\n * editor can warn that a hand edit may be overwritten on the owner's next save.\n */\nexport interface WorkflowGeneratedBy {\n /** Owning module id, e.g. `agent_orchestrator`. */\n module: string\n /** The owner's own record id (a process definition id, say). */\n ownerId: string\n}\n\nexport interface WorkflowMetadata {\n tags?: string[]\n category?: string\n icon?: string\n generatedBy?: WorkflowGeneratedBy\n // Forward-compatibility guard (spec section 5.8): the lowest engine version\n // able to execute this definition. Engines older than the declared version\n // refuse to instantiate it instead of misexecuting unknown capabilities.\n minEngineVersion?: number\n editor?: WorkflowEditorMetadata\n}\n\n/**\n * Failure-queue park marker (spec 5.9 \"Send to failure queue\"). Written when a\n * step's `failureQueue` error directive parks the instance instead of failing\n * it; the instances list filters on it (`?attention=true`) and the Phase 5\n * triage UI consumes it. Additive and engine-owned \u2014 never user-writable.\n */\nexport interface WorkflowInstanceAttention {\n reason: string\n stepId?: string\n error?: string\n at: string\n}\n\n/**\n * Recursion marker for the workflow-level error handler (spec 5.9). Engine-owned\n * and durable \u2014 deliberately NOT in `context`, which the context PATCH API lets\n * callers write, so the guard cannot be spoofed away.\n */\nexport interface WorkflowInstanceErrorHandlerMetadata {\n depth: number\n forInstanceId?: string\n forStepId?: string\n}\n\nimport type { WorkflowInstanceStepThrough } from '../lib/step-through'\n\nexport interface WorkflowInstanceMetadata {\n entityType?: string\n entityId?: string\n initiatedBy?: string\n labels?: Record<string, string>\n attention?: WorkflowInstanceAttention | null\n errorHandler?: WorkflowInstanceErrorHandlerMetadata | null\n /**\n * Step-through release token (spec section 8.2). Engine-owned and never\n * user-writable: the start route sets it from a feature-gated flag and the\n * step-through route advances it, so a client cannot release a step by\n * writing metadata directly. See `lib/step-through.ts`.\n */\n stepThrough?: WorkflowInstanceStepThrough | null\n}\n\n// ============================================================================\n// Entity: WorkflowDefinition\n// ============================================================================\n\n/**\n * WorkflowDefinition entity\n *\n * Stores workflow definitions (templates) that can be instantiated\n * to create workflow instances.\n */\n@Entity({ tableName: 'workflow_definitions' })\n// Versions of the same workflow coexist as separate rows; uniqueness is per\n// (workflowId, version, tenantId) so draft/published versions can live together.\n@Unique({ properties: ['workflowId', 'version', 'tenantId'] })\n@Index({ name: 'workflow_definitions_enabled_idx', properties: ['enabled'] })\n@Index({ name: 'workflow_definitions_tenant_org_idx', properties: ['tenantId', 'organizationId'] })\n@Index({ name: 'workflow_definitions_workflow_id_idx', properties: ['workflowId'] })\n@Index({ name: 'workflow_definitions_kind_idx', properties: ['kind'] })\n@Index({ name: 'workflow_definitions_definition_gin_idx', properties: ['definition'], type: 'gin' })\nexport class WorkflowDefinition {\n [OptionalProps]?: 'enabled' | 'version' | 'kind' | 'lifecycle' | 'createdAt' | 'updatedAt' | 'deletedAt' | 'codeWorkflowId'\n\n @PrimaryKey({ type: 'uuid', defaultRaw: 'gen_random_uuid()' })\n id!: string\n\n @Property({ name: 'workflow_id', type: 'varchar', length: 100 })\n workflowId!: string\n\n @Property({ name: 'code_workflow_id', type: 'varchar', length: 100, nullable: true })\n codeWorkflowId?: string | null\n\n @Property({ name: 'workflow_name', type: 'varchar', length: 255 })\n workflowName!: string\n\n @Property({ name: 'description', type: 'text', nullable: true })\n description?: string | null\n\n @Property({ name: 'version', type: 'integer', default: 1 })\n version: number = 1\n\n @Property({ name: 'definition', type: 'jsonb' })\n definition!: WorkflowDefinitionData\n\n @Property({ name: 'metadata', type: 'jsonb', nullable: true })\n metadata?: WorkflowMetadata | null\n\n @Property({ name: 'enabled', type: 'boolean', default: true })\n enabled: boolean = true\n\n // Distinguishes a reusable library component (no trigger, not standalone-\n // startable, callable only as a SUB_WORKFLOW) from a normal workflow.\n @Property({ name: 'kind', type: 'varchar', length: 20, default: 'workflow' })\n kind: 'workflow' | 'component' = 'workflow'\n\n // Draft/published version lifecycle. Existing rows backfill to 'published';\n // the publish flow + version coexistence land with the versioning phase.\n @Property({ name: 'lifecycle', type: 'varchar', length: 20, default: 'published' })\n lifecycle: 'draft' | 'published' | 'archived' = 'published'\n\n @Property({ name: 'effective_from', type: Date, nullable: true })\n effectiveFrom?: Date | null\n\n @Property({ name: 'effective_to', type: Date, nullable: true })\n effectiveTo?: Date | null\n\n @Property({ name: 'tenant_id', type: 'uuid' })\n tenantId!: string\n\n @Property({ name: 'organization_id', type: 'uuid' })\n organizationId!: string\n\n /**\n * The least-privilege ACL features every run of THIS version executes with.\n *\n * Null/empty (the default, and every pre-existing row) keeps the historic\n * behaviour: the run borrows the identity of whoever started it. A non-empty\n * grant makes the run act as its own `auth` execution principal instead \u2014\n * always, regardless of who started it \u2014 so it can neither inherit an admin's\n * powers nor be left without an actor when an event trigger starts it.\n *\n * A real column rather than a `metadata` key because it is a security\n * boundary: it is read on every advance, written only through the\n * `workflows.definitions.grant_features` gate, and must be diffable in an\n * audit. Per version by construction \u2014 a published version is a new row.\n */\n @Property({ name: 'granted_features', type: 'jsonb', nullable: true })\n grantedFeatures?: string[] | null\n\n @Property({ name: 'created_by', type: 'varchar', length: 255, nullable: true })\n createdBy?: string | null\n\n @Property({ name: 'updated_by', type: 'varchar', length: 255, nullable: true })\n updatedBy?: string | null\n\n @Property({ name: 'created_at', type: Date, onCreate: () => new Date() })\n createdAt: Date = new Date()\n\n @Property({ name: 'updated_at', type: Date, onUpdate: () => new Date() })\n updatedAt: Date = new Date()\n\n @Property({ name: 'deleted_at', type: Date, nullable: true })\n deletedAt?: Date | null\n}\n\n// ============================================================================\n// Entity: WorkflowDefinitionDraft\n// ============================================================================\n\n/**\n * WorkflowDefinitionDraft entity\n *\n * Per-user autosaved editor drafts for workflow definitions. A draft may\n * reference an existing definition (definitionId set) or a not-yet-saved one\n * (definitionId null). baseUpdatedAt captures the definition's updatedAt the\n * draft forked from, enabling conflict-aware restore messaging.\n */\n@Entity({ tableName: 'workflow_definition_drafts' })\n@Unique({ properties: ['definitionId', 'userId', 'tenantId'] })\n@Index({ name: 'workflow_definition_drafts_tenant_org_idx', properties: ['tenantId', 'organizationId'] })\nexport class WorkflowDefinitionDraft {\n [OptionalProps]?: 'createdAt' | 'updatedAt' | 'deletedAt'\n\n @PrimaryKey({ type: 'uuid', defaultRaw: 'gen_random_uuid()' })\n id!: string\n\n @Property({ name: 'definition_id', type: 'uuid', nullable: true })\n definitionId?: string | null\n\n @Property({ name: 'user_id', type: 'uuid' })\n userId!: string\n\n @Property({ name: 'definition', type: 'jsonb' })\n definition!: WorkflowDefinitionData\n\n @Property({ name: 'metadata', type: 'jsonb', nullable: true })\n metadata?: WorkflowMetadata | null\n\n @Property({ name: 'base_updated_at', type: Date, nullable: true })\n baseUpdatedAt?: Date | null\n\n @Property({ name: 'tenant_id', type: 'uuid' })\n tenantId!: string\n\n @Property({ name: 'organization_id', type: 'uuid' })\n organizationId!: string\n\n @Property({ name: 'created_at', type: Date, onCreate: () => new Date() })\n createdAt: Date = new Date()\n\n @Property({ name: 'updated_at', type: Date, onUpdate: () => new Date() })\n updatedAt: Date = new Date()\n\n @Property({ name: 'deleted_at', type: Date, nullable: true })\n deletedAt?: Date | null\n}\n\n// ============================================================================\n// Entity: WorkflowInstance\n// ============================================================================\n\n/**\n * WorkflowInstance entity\n *\n * Represents a running instance of a workflow definition.\n * Tracks the current state, context data, and execution status.\n */\n@Entity({ tableName: 'workflow_instances' })\n@Index({ name: 'workflow_instances_definition_status_idx', properties: ['definitionId', 'status'] })\n@Index({ name: 'workflow_instances_correlation_key_idx', properties: ['correlationKey'] })\n@Index({ name: 'workflow_instances_status_tenant_idx', properties: ['status', 'tenantId'] })\n@Index({ name: 'workflow_instances_current_step_idx', properties: ['currentStepId', 'status'] })\n@Index({ name: 'workflow_instances_tenant_org_idx', properties: ['tenantId', 'organizationId'] })\nexport class WorkflowInstance {\n [OptionalProps]?: 'retryCount' | 'isDryRun' | 'createdAt' | 'updatedAt' | 'deletedAt'\n\n @PrimaryKey({ type: 'uuid', defaultRaw: 'gen_random_uuid()' })\n id!: string\n\n @Property({ name: 'definition_id', type: 'uuid' })\n definitionId!: string\n\n @Property({ name: 'workflow_id', type: 'varchar', length: 100 })\n workflowId!: string\n\n @Property({ name: 'version', type: 'integer' })\n version!: number\n\n @Property({ name: 'status', type: 'varchar', length: 30 })\n status!: WorkflowInstanceStatus\n\n /**\n * Terminal VERDICT, written once when the run terminates and null while it is\n * still going (`lib/run-outcome.ts` owns the vocabulary and the decision).\n *\n * Additive and nullable ON PURPOSE: `status` keeps meaning exactly what every\n * existing consumer, filter and subscriber already believes it means, and a\n * null on a pre-existing row means \"ran before outcomes existed\" \u2014 never\n * \"success\". Nothing is backfilled: a fabricated verdict would be the same\n * dishonesty this column exists to remove, pointed the other way.\n */\n @Property({ name: 'outcome', type: 'varchar', length: 30, nullable: true })\n outcome?: WorkflowRunOutcome | null\n\n @Property({ name: 'current_step_id', type: 'varchar', length: 100 })\n currentStepId!: string\n\n @Property({ name: 'context', type: 'jsonb' })\n context!: Record<string, any>\n\n @Property({ name: 'correlation_key', type: 'varchar', length: 255, nullable: true })\n correlationKey?: string | null\n\n @Property({ name: 'metadata', type: 'jsonb', nullable: true })\n metadata?: WorkflowInstanceMetadata | null\n\n @Property({ name: 'started_at', type: Date })\n startedAt!: Date\n\n @Property({ name: 'completed_at', type: Date, nullable: true })\n completedAt?: Date | null\n\n @Property({ name: 'paused_at', type: Date, nullable: true })\n pausedAt?: Date | null\n\n @Property({ name: 'cancelled_at', type: Date, nullable: true })\n cancelledAt?: Date | null\n\n @Property({ name: 'error_message', type: 'text', nullable: true })\n errorMessage?: string | null\n\n @Property({ name: 'error_details', type: 'jsonb', nullable: true })\n errorDetails?: any | null\n\n @Property({ name: 'pending_transition', type: 'jsonb', nullable: true })\n pendingTransition?: {\n toStepId: string\n activityResults: any[]\n timestamp: Date\n } | null\n\n // When the instance is FORKED, points at the open PARALLEL_FORK step whose\n // branches are currently executing. Null for single-token instances.\n @Property({ name: 'active_fork_step_id', type: 'varchar', length: 100, nullable: true })\n activeForkStepId?: string | null\n\n @Property({ name: 'retry_count', type: 'integer', default: 0 })\n retryCount: number = 0\n\n /**\n * Marks the run as a side-effect-free simulation (spec section 8.2).\n *\n * It is a COLUMN rather than a metadata key because every isolation decision\n * reads it \u2014 the activity dispatcher, the USER_TASK handler, the business-rule\n * bridge and the list/KPI `where` builders \u2014 and a jsonb path predicate in a\n * hot filter is both slower and easy to forget. It is written once at start\n * and never mutated, so a run cannot change what it is halfway through.\n */\n @Property({ name: 'is_dry_run', type: 'boolean', default: false })\n isDryRun: boolean = false\n\n @Property({ name: 'tenant_id', type: 'uuid' })\n tenantId!: string\n\n @Property({ name: 'organization_id', type: 'uuid' })\n organizationId!: string\n\n @Property({ name: 'created_at', type: Date, onCreate: () => new Date() })\n createdAt: Date = new Date()\n\n @Property({ name: 'updated_at', type: Date, onUpdate: () => new Date() })\n updatedAt: Date = new Date()\n\n @Property({ name: 'deleted_at', type: Date, nullable: true })\n deletedAt?: Date | null\n}\n\n// ============================================================================\n// Entity: WorkflowBranchInstance\n// ============================================================================\n\n/**\n * WorkflowBranchInstance entity\n *\n * A single parallel branch token created by a PARALLEL_FORK step. Each branch\n * advances independently (interleaved under the instance lock) with its own\n * private context namespace, and converges to the paired PARALLEL_JOIN step.\n * Branches are tenant/org scoped and never cross-tenant.\n */\n@Entity({ tableName: 'workflow_branch_instances' })\n@Index({ name: 'workflow_branch_instances_instance_status_idx', properties: ['workflowInstanceId', 'status'] })\n@Index({ name: 'workflow_branch_instances_instance_fork_idx', properties: ['workflowInstanceId', 'forkStepId'] })\n@Index({ name: 'workflow_branch_instances_tenant_org_idx', properties: ['tenantId', 'organizationId'] })\nexport class WorkflowBranchInstance {\n [OptionalProps]?: 'createdAt' | 'updatedAt'\n\n @PrimaryKey({ type: 'uuid', defaultRaw: 'gen_random_uuid()' })\n id!: string\n\n @Property({ name: 'workflow_instance_id', type: 'uuid' })\n workflowInstanceId!: string\n\n @Property({ name: 'fork_step_id', type: 'varchar', length: 100 })\n forkStepId!: string\n\n @Property({ name: 'join_step_id', type: 'varchar', length: 100 })\n joinStepId!: string\n\n // The transitionId of the FORK's outgoing transition that created this branch.\n @Property({ name: 'branch_key', type: 'varchar', length: 100 })\n branchKey!: string\n\n // Reserved for nested-fork support (always null this iteration; validator blocks nesting).\n @Property({ name: 'parent_branch_id', type: 'uuid', nullable: true })\n parentBranchId?: string | null\n\n @Property({ name: 'current_step_id', type: 'varchar', length: 100 })\n currentStepId!: string\n\n @Property({ name: 'status', type: 'varchar', length: 30 })\n status!: WorkflowBranchInstanceStatus\n\n // The branch's private write scope; merged back into instance.context at JOIN.\n @Property({ name: 'context_namespace', type: 'jsonb' })\n contextNamespace!: Record<string, any>\n\n // Per-branch equivalent of WorkflowInstance.pendingTransition (async activities).\n @Property({ name: 'pending_transition', type: 'jsonb', nullable: true })\n pendingTransition?: {\n toStepId: string\n activityResults: any[]\n timestamp: Date\n } | null\n\n @Property({ name: 'error_message', type: 'text', nullable: true })\n errorMessage?: string | null\n\n @Property({ name: 'error_details', type: 'jsonb', nullable: true })\n errorDetails?: any | null\n\n @Property({ name: 'started_at', type: Date, nullable: true })\n startedAt?: Date | null\n\n @Property({ name: 'completed_at', type: Date, nullable: true })\n completedAt?: Date | null\n\n @Property({ name: 'tenant_id', type: 'uuid' })\n tenantId!: string\n\n @Property({ name: 'organization_id', type: 'uuid' })\n organizationId!: string\n\n @Property({ name: 'created_at', type: Date, onCreate: () => new Date() })\n createdAt: Date = new Date()\n\n @Property({ name: 'updated_at', type: Date, onUpdate: () => new Date() })\n updatedAt: Date = new Date()\n}\n\n// ============================================================================\n// Entity: StepInstance\n// ============================================================================\n\n/**\n * StepInstance entity\n *\n * Tracks individual step executions within a workflow instance.\n * Records input/output data, timing, and execution status for each step.\n */\n@Entity({ tableName: 'step_instances' })\n@Index({ name: 'step_instances_workflow_instance_idx', properties: ['workflowInstanceId', 'status'] })\n@Index({ name: 'step_instances_step_id_idx', properties: ['stepId', 'status'] })\n@Index({ name: 'step_instances_tenant_org_idx', properties: ['tenantId', 'organizationId'] })\nexport class StepInstance {\n [OptionalProps]?: 'retryCount' | 'createdAt' | 'updatedAt'\n\n @PrimaryKey({ type: 'uuid', defaultRaw: 'gen_random_uuid()' })\n id!: string\n\n @Property({ name: 'workflow_instance_id', type: 'uuid' })\n workflowInstanceId!: string\n\n // Set when this step executes inside a parallel branch; null for single-token.\n @Property({ name: 'branch_instance_id', type: 'uuid', nullable: true })\n branchInstanceId?: string | null\n\n @Property({ name: 'step_id', type: 'varchar', length: 100 })\n stepId!: string\n\n @Property({ name: 'step_name', type: 'varchar', length: 255 })\n stepName!: string\n\n @Property({ name: 'step_type', type: 'varchar', length: 50 })\n stepType!: string\n\n @Property({ name: 'status', type: 'varchar', length: 20 })\n status!: StepInstanceStatus\n\n @Property({ name: 'input_data', type: 'jsonb', nullable: true })\n inputData?: any | null\n\n @Property({ name: 'output_data', type: 'jsonb', nullable: true })\n outputData?: any | null\n\n @Property({ name: 'error_data', type: 'jsonb', nullable: true })\n errorData?: any | null\n\n @Property({ name: 'entered_at', type: Date, nullable: true })\n enteredAt?: Date | null\n\n @Property({ name: 'exited_at', type: Date, nullable: true })\n exitedAt?: Date | null\n\n @Property({ name: 'execution_time_ms', type: 'integer', nullable: true })\n executionTimeMs?: number | null\n\n @Property({ name: 'retry_count', type: 'integer', default: 0 })\n retryCount: number = 0\n\n @Property({ name: 'tenant_id', type: 'uuid' })\n tenantId!: string\n\n @Property({ name: 'organization_id', type: 'uuid' })\n organizationId!: string\n\n @Property({ name: 'created_at', type: Date, onCreate: () => new Date() })\n createdAt: Date = new Date()\n\n @Property({ name: 'updated_at', type: Date, onUpdate: () => new Date() })\n updatedAt: Date = new Date()\n}\n\n// ============================================================================\n// Entity: UserTask\n// ============================================================================\n\n/**\n * UserTask entity\n *\n * Represents user tasks that require human interaction within a workflow.\n * Tracks assignment, SLA, escalation, and completion status.\n */\n@Entity({ tableName: 'user_tasks' })\n@Index({ name: 'user_tasks_workflow_instance_idx', properties: ['workflowInstanceId'] })\n@Index({ name: 'user_tasks_status_assigned_idx', properties: ['status', 'assignedTo'] })\n@Index({ name: 'user_tasks_status_due_date_idx', properties: ['status', 'dueDate'] })\n@Index({ name: 'user_tasks_tenant_org_idx', properties: ['tenantId', 'organizationId'] })\n// The \u00A76.4 entity gate is \"no binding whose type is outside my allowed set\",\n// which is a containment test over `entity_types` \u2014 so it must be a SQL WHERE,\n// not a JS post-filter. Post-filtering a page makes `pagination.total` a lie and\n// returns short pages. GIN is what makes `<@` indexable.\n@Index({ name: 'user_tasks_entity_types_gin_idx', properties: ['entityTypes'], type: 'gin' })\nexport class UserTask {\n [OptionalProps]?: 'createdAt' | 'updatedAt' | 'assigneeKind'\n\n @PrimaryKey({ type: 'uuid', defaultRaw: 'gen_random_uuid()' })\n id!: string\n\n @Property({ name: 'workflow_instance_id', type: 'uuid' })\n workflowInstanceId!: string\n\n @Property({ name: 'step_instance_id', type: 'uuid' })\n stepInstanceId!: string\n\n // Set when this task belongs to a parallel branch; null for single-token instances.\n @Property({ name: 'branch_instance_id', type: 'uuid', nullable: true })\n branchInstanceId?: string | null\n\n @Property({ name: 'task_name', type: 'varchar', length: 255 })\n taskName!: string\n\n @Property({ name: 'description', type: 'text', nullable: true })\n description?: string | null\n\n @Property({ name: 'status', type: 'varchar', length: 20 })\n status!: UserTaskStatus\n\n @Property({ name: 'form_schema', type: 'jsonb', nullable: true })\n formSchema?: any | null\n\n @Property({ name: 'form_data', type: 'jsonb', nullable: true })\n formData?: any | null\n\n @Property({ name: 'assigned_to', type: 'varchar', length: 255, nullable: true })\n assignedTo?: string | null\n\n /**\n * Which principal namespace `assignedTo` names.\n *\n * NOT NULL with a default rather than nullable: the column exists precisely to\n * remove ambiguity, and reintroducing a null case defeats it. Existing rows\n * backfill to `'user'`, which is correct \u2014 every `assigned_to` written before\n * this column existed is a backoffice user id. Rows with `assigned_to IS NULL`\n * also get `'user'`; harmless, because every branch that reads it first checks\n * that `assignedTo` is set.\n *\n * `assignedToRoles` is never combined with `'customer'`: portal roles are a\n * different namespace (`CustomerRole`) and portal principals cannot claim from\n * a queue.\n */\n @Property({ name: 'assignee_kind', type: 'varchar', length: 20, default: 'user' })\n assigneeKind: UserTaskAssigneeKind = 'user'\n\n @Property({ name: 'assigned_to_roles', type: 'text[]', nullable: true })\n assignedToRoles?: string[] | null\n\n @Property({ name: 'claimed_by', type: 'varchar', length: 255, nullable: true })\n claimedBy?: string | null\n\n @Property({ name: 'claimed_at', type: Date, nullable: true })\n claimedAt?: Date | null\n\n @Property({ name: 'due_date', type: Date, nullable: true })\n dueDate?: Date | null\n\n @Property({ name: 'escalated_at', type: Date, nullable: true })\n escalatedAt?: Date | null\n\n @Property({ name: 'escalated_to', type: 'varchar', length: 255, nullable: true })\n escalatedTo?: string | null\n\n @Property({ name: 'completed_by', type: 'varchar', length: 255, nullable: true })\n completedBy?: string | null\n\n @Property({ name: 'completed_at', type: Date, nullable: true })\n completedAt?: Date | null\n\n @Property({ name: 'comments', type: 'text', nullable: true })\n comments?: string | null\n\n /**\n * Records this task is about, resolved from the authored\n * `userTaskConfig.entityBindings` when the task was created.\n *\n * A real column rather than a read of the authored `formSchema` blob: the\n * work inbox, the record-page widget and the \u00A76.4 visibility predicate all\n * need to filter on it, and the authored form schema is the wrong shape and\n * the wrong lifetime for that (it describes the FORM, and re-editing the\n * definition must not retro-change what a running task is about).\n */\n @Property({ name: 'entity_bindings', type: 'jsonb', nullable: true })\n entityBindings?: unknown[] | null\n\n /**\n * The distinct AUTHORED `entityType` values from `entityBindings`, denormalized\n * so the \u00A76.4 entity gate is expressible as `entity_types <@ ARRAY[allowed]`\n * against a GIN index.\n *\n * Authored verbatim, not normalized to generated entity ids, because the\n * visibility predicate keys its per-request access map on exactly the string\n * the binding carries. Storing a second, normalized spelling here would give\n * the SQL filter and the JS predicate two different notions of \"the same type\"\n * \u2014 and the one place they could disagree is the one place a task goes\n * invisible without a trace.\n *\n * NULL means \"no bindings\", which is \u00A72.4's vacuous pass for a backoffice\n * principal. Every row written before this column existed is therefore correct\n * by construction \u2014 no backfill needed.\n */\n @Property({ name: 'entity_types', type: 'text[]', nullable: true })\n entityTypes?: string[] | null\n\n /** Authored `low|medium|high|extreme`, mirroring the platform's labels. */\n @Property({ name: 'priority', type: 'varchar', length: 20, nullable: true })\n priority?: string | null\n\n /**\n * Reassignment audit \u2014 who moved this task, when, and why.\n *\n * Deliberately audit columns and not a new `UserTaskStatus` value: a status\n * addition is an Ask-First state-machine change, and the reassigned task is\n * still exactly as pending or in-progress as it was. Mirrors how Phase 3a's\n * failure queue reused `PAUSED` plus a marker.\n */\n @Property({ name: 'reassigned_by', type: 'varchar', length: 255, nullable: true })\n reassignedBy?: string | null\n\n @Property({ name: 'reassigned_at', type: Date, nullable: true })\n reassignedAt?: Date | null\n\n @Property({ name: 'reassign_reason', type: 'text', nullable: true })\n reassignReason?: string | null\n\n @Property({ name: 'tenant_id', type: 'uuid' })\n tenantId!: string\n\n @Property({ name: 'organization_id', type: 'uuid' })\n organizationId!: string\n\n @Property({ name: 'created_at', type: Date, onCreate: () => new Date() })\n createdAt: Date = new Date()\n\n @Property({ name: 'updated_at', type: Date, onUpdate: () => new Date() })\n updatedAt: Date = new Date()\n}\n\n// ============================================================================\n// Entity: WorkflowEvent\n// ============================================================================\n\n/**\n * WorkflowEvent entity\n *\n * Event sourcing log for workflow execution history.\n * Records all events that occur during workflow execution for audit and replay.\n */\n@Entity({ tableName: 'workflow_events' })\n@Index({ name: 'workflow_events_instance_occurred_idx', properties: ['workflowInstanceId', 'occurredAt'] })\n@Index({ name: 'workflow_events_event_type_idx', properties: ['eventType', 'occurredAt'] })\n@Index({ name: 'workflow_events_tenant_org_idx', properties: ['tenantId', 'organizationId'] })\nexport class WorkflowEvent {\n @PrimaryKey({ type: 'bigint', autoincrement: true })\n id!: string\n\n @Property({ name: 'workflow_instance_id', type: 'uuid' })\n workflowInstanceId!: string\n\n @Property({ name: 'step_instance_id', type: 'uuid', nullable: true })\n stepInstanceId?: string | null\n\n // Set when the event was logged within a parallel branch; null otherwise.\n @Property({ name: 'branch_instance_id', type: 'uuid', nullable: true })\n branchInstanceId?: string | null\n\n @Property({ name: 'event_type', type: 'varchar', length: 50 })\n eventType!: string\n\n @Property({ name: 'event_data', type: 'jsonb' })\n eventData!: any\n\n @Property({ name: 'occurred_at', type: Date, onCreate: () => new Date() })\n occurredAt: Date = new Date()\n\n @Property({ name: 'user_id', type: 'varchar', length: 255, nullable: true })\n userId?: string | null\n\n @Property({ name: 'tenant_id', type: 'uuid' })\n tenantId!: string\n\n @Property({ name: 'organization_id', type: 'uuid' })\n organizationId!: string\n}\n\n// ============================================================================\n// Entity: WorkflowEventTrigger\n// ============================================================================\n\n/**\n * WorkflowEventTrigger entity\n *\n * Maps event patterns to workflow definitions for automatic triggering.\n * When a matching event is emitted, the corresponding workflow is started\n * with context mapped from the event payload.\n */\n@Entity({ tableName: 'workflow_event_triggers' })\n@Index({ name: 'workflow_event_triggers_event_pattern_idx', properties: ['eventPattern', 'enabled'] })\n@Index({ name: 'workflow_event_triggers_definition_idx', properties: ['workflowDefinitionId'] })\n@Index({ name: 'workflow_event_triggers_tenant_org_idx', properties: ['tenantId', 'organizationId'] })\n@Index({ name: 'workflow_event_triggers_enabled_priority_idx', properties: ['enabled', 'priority'] })\nexport class WorkflowEventTrigger {\n [OptionalProps]?: 'enabled' | 'priority' | 'createdAt' | 'updatedAt' | 'deletedAt'\n\n @PrimaryKey({ type: 'uuid', defaultRaw: 'gen_random_uuid()' })\n id!: string\n\n @Property({ name: 'name', type: 'varchar', length: 255 })\n name!: string\n\n @Property({ name: 'description', type: 'text', nullable: true })\n description?: string | null\n\n @Property({ name: 'workflow_definition_id', type: 'uuid' })\n workflowDefinitionId!: string\n\n @Property({ name: 'event_pattern', type: 'varchar', length: 255 })\n eventPattern!: string\n\n @Property({ name: 'config', type: 'jsonb', nullable: true })\n config?: WorkflowEventTriggerConfig | null\n\n @Property({ name: 'enabled', type: 'boolean', default: true })\n enabled: boolean = true\n\n @Property({ name: 'priority', type: 'integer', default: 0 })\n priority: number = 0\n\n @Property({ name: 'tenant_id', type: 'uuid' })\n tenantId!: string\n\n @Property({ name: 'organization_id', type: 'uuid' })\n organizationId!: string\n\n @Property({ name: 'created_by', type: 'varchar', length: 255, nullable: true })\n createdBy?: string | null\n\n @Property({ name: 'updated_by', type: 'varchar', length: 255, nullable: true })\n updatedBy?: string | null\n\n @Property({ name: 'created_at', type: Date, onCreate: () => new Date() })\n createdAt: Date = new Date()\n\n @Property({ name: 'updated_at', type: Date, onUpdate: () => new Date() })\n updatedAt: Date = new Date()\n\n @Property({ name: 'deleted_at', type: Date, nullable: true })\n deletedAt?: Date | null\n}\n\n// ============================================================================\n// Entity: WorkflowDefinitionMetricRollup\n// ============================================================================\n\n/**\n * WorkflowDefinitionMetricRollup entity (spec \u00A78.5)\n *\n * Precomputed per-definition operational KPIs \u2014 runs, success rate, run-duration\n * percentiles and task SLA hit-rate \u2014 over the sliding windows an operator reads.\n * Deliberately shaped after `agent_orchestrator`'s `AgentMetricRollup`\n * (tenant/org + logical id + window bounds + `computed_at` + a zod-validated\n * `metrics` jsonb) so the two ops surfaces stay legible side by side. The shape\n * is MIRRORED, never imported: `enterprise` is an optional peer and core must\n * not hard-require it.\n *\n * Two deliberate divergences from that model, both fixing a latent flaw in it:\n *\n * - **`window_key` is its own column and part of the unique key.** The mirrored\n * table identifies a row by `(org, agent, window_start)` alone, so a 7d window\n * computed in one pass and a 30d window computed 23 days later can land on the\n * same `window_start` and silently overwrite each other with metrics for a\n * different span. Naming the span makes that impossible.\n * - **The unique key is enforced by the DATABASE**, and includes `tenant_id`.\n * The mirrored writer does a read-then-insert with no constraint behind it, so\n * two concurrent passes both miss and both insert. Here the recompute-and-\n * upsert is idempotent because the index says so, not because only one worker\n * happens to run.\n *\n * Not user-editable: rows are written only by the rollup worker and read only by\n * `api/metrics/definitions`. It therefore carries no `updated_at` and takes the\n * background-job / machine-aggregate exemption from the optimistic-lock rule \u2014\n * there is no edit form, no delete endpoint and no concurrent human writer for a\n * version token to protect. `computed_at` is the freshness stamp readers use.\n *\n * Keyed on `workflow_id` (the logical id, like `AgentMetricRollup.agentId`)\n * rather than on a `workflow_definitions` row id: `WorkflowInstance.workflowId`\n * is already denormalized so no join is needed, and an operator asks how a\n * PROCESS is doing, not how version 3 of it is doing.\n */\n@Entity({ tableName: 'workflow_definition_metric_rollups' })\n@Unique({\n name: 'workflow_definition_metric_rollups_bucket_uq',\n properties: ['tenantId', 'organizationId', 'workflowId', 'windowKey', 'windowStart'],\n})\n@Index({\n name: 'workflow_definition_metric_rollups_lookup_idx',\n properties: ['tenantId', 'organizationId', 'workflowId', 'windowKey'],\n})\nexport class WorkflowDefinitionMetricRollup {\n [OptionalProps]?: 'computedAt' | 'createdAt'\n\n @PrimaryKey({ type: 'uuid', defaultRaw: 'gen_random_uuid()' })\n id!: string\n\n @Property({ name: 'tenant_id', type: 'uuid' })\n tenantId!: string\n\n @Property({ name: 'organization_id', type: 'uuid' })\n organizationId!: string\n\n /** Logical workflow id, mirroring `WorkflowInstance.workflowId`. */\n @Property({ name: 'workflow_id', type: 'varchar', length: 100 })\n workflowId!: string\n\n /** Window length this row measures: `24h`, `7d` or `30d`. */\n @Property({ name: 'window_key', type: 'varchar', length: 10 })\n windowKey!: string\n\n @Property({ name: 'window_start', type: Date })\n windowStart!: Date\n\n @Property({ name: 'window_end', type: Date })\n windowEnd!: Date\n\n @Property({ name: 'computed_at', type: Date, onCreate: () => new Date() })\n computedAt: Date = new Date()\n\n /** Validated by `workflowDefinitionMetricsSchema` on every read. */\n @Property({ name: 'metrics', type: 'jsonb' })\n metrics!: Record<string, unknown>\n\n @Property({ name: 'created_at', type: Date, onCreate: () => new Date() })\n createdAt: Date = new Date()\n}\n\n// Export all entities as default for MikroORM discovery\nexport default [\n WorkflowDefinition,\n WorkflowDefinitionDraft,\n WorkflowInstance,\n WorkflowBranchInstance,\n StepInstance,\n UserTask,\n WorkflowEvent,\n WorkflowEventTrigger,\n WorkflowDefinitionMetricRollup,\n]\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;AAMA,SAAS,qBAAqB;AAC9B,SAAS,QAAQ,OAAO,YAAY,UAAU,cAAc;AAsRzD;AADI,IAAM,qBAAN,MAAyB;AAAA,EAAzB;AAmBL,mBAAkB;AASlB,mBAAmB;AAKnB,gBAAiC;AAKjC,qBAAgD;AAsChD,qBAAkB,oBAAI,KAAK;AAG3B,qBAAkB,oBAAI,KAAK;AAAA;AAI7B;AA/EE;AAAA,EADC,WAAW,EAAE,MAAM,QAAQ,YAAY,oBAAoB,CAAC;AAAA,GAHlD,mBAIX;AAGA;AAAA,EADC,SAAS,EAAE,MAAM,eAAe,MAAM,WAAW,QAAQ,IAAI,CAAC;AAAA,GANpD,mBAOX;AAGA;AAAA,EADC,SAAS,EAAE,MAAM,oBAAoB,MAAM,WAAW,QAAQ,KAAK,UAAU,KAAK,CAAC;AAAA,GATzE,mBAUX;AAGA;AAAA,EADC,SAAS,EAAE,MAAM,iBAAiB,MAAM,WAAW,QAAQ,IAAI,CAAC;AAAA,GAZtD,mBAaX;AAGA;AAAA,EADC,SAAS,EAAE,MAAM,eAAe,MAAM,QAAQ,UAAU,KAAK,CAAC;AAAA,GAfpD,mBAgBX;AAGA;AAAA,EADC,SAAS,EAAE,MAAM,WAAW,MAAM,WAAW,SAAS,EAAE,CAAC;AAAA,GAlB/C,mBAmBX;AAGA;AAA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AO,mBAAQ;AAAA,EACb;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;",
|
|
4
|
+
"sourcesContent": ["/**\n * Workflows Module - Database Entities\n *\n * MikroORM entities for workflow engine.\n */\n\nimport { OptionalProps } from '@mikro-orm/core'\nimport { Entity, Index, PrimaryKey, Property, Unique } from '@mikro-orm/decorators/legacy'\nimport type { WorkflowRunOutcome } from '../lib/run-outcome'\n\nexport type { WorkflowRunOutcome }\n\n// ============================================================================\n// Type Definitions\n// ============================================================================\n\nexport type WorkflowStepType =\n | 'START'\n | 'END'\n | 'USER_TASK'\n | 'AUTOMATED'\n | 'PARALLEL_FORK'\n | 'PARALLEL_JOIN'\n | 'SUB_WORKFLOW'\n | 'WAIT_FOR_SIGNAL'\n | 'WAIT_FOR_TIMER'\n | 'WAIT_FOR_CONDITION'\n | 'IF_ELSE'\n | 'SWITCH'\n\nexport type WorkflowInstanceStatus =\n | 'RUNNING'\n | 'PAUSED'\n | 'COMPLETED'\n | 'FAILED'\n | 'CANCELLED'\n | 'COMPENSATING'\n | 'COMPENSATED'\n | 'WAITING_FOR_ACTIVITIES'\n | 'FORKED'\n\nexport type WorkflowBranchInstanceStatus =\n | 'ACTIVE'\n | 'PAUSED'\n | 'WAITING_FOR_ACTIVITIES'\n | 'COMPLETED'\n | 'FAILED'\n | 'CANCELLED'\n\nexport type StepInstanceStatus =\n | 'PENDING'\n | 'ACTIVE'\n | 'COMPLETED'\n | 'FAILED'\n | 'SKIPPED'\n | 'CANCELLED'\n\nexport type UserTaskStatus =\n | 'PENDING'\n | 'IN_PROGRESS'\n | 'COMPLETED'\n | 'CANCELLED'\n | 'ESCALATED'\n\n/**\n * Which principal namespace `user_tasks.assigned_to` names.\n *\n * `'user'` = a backoffice user id. `'customer'` = a portal principal\n * (`CustomerAuthContext.sub`). A discriminator column rather than a\n * `customer:<id>` string prefix (maintainer decision): a prefix is unindexable,\n * collides with any id containing a colon, and would force a parsing rule into\n * every existing comparison \u2014 the claim filter, the `myWork` `$or`, the\n * reassign write.\n */\nexport type UserTaskAssigneeKind = 'user' | 'customer'\n\n// ============================================================================\n// Event Trigger Types\n// ============================================================================\n\nexport type TriggerFilterOperator =\n | 'eq'\n | 'neq'\n | 'gt'\n | 'gte'\n | 'lt'\n | 'lte'\n | 'contains'\n | 'startsWith'\n | 'endsWith'\n | 'in'\n | 'notIn'\n | 'exists'\n | 'notExists'\n | 'regex'\n\nexport interface TriggerFilterCondition {\n field: string // JSON path (e.g., \"status\", \"metadata.type\")\n operator: TriggerFilterOperator\n value: unknown\n}\n\nexport interface TriggerContextMapping {\n targetKey: string // Key in workflow initial context\n sourceExpression: string // Path from event payload (supports dot notation)\n defaultValue?: unknown\n}\n\nexport interface WorkflowEventTriggerConfig {\n filterConditions?: TriggerFilterCondition[]\n contextMapping?: TriggerContextMapping[]\n debounceMs?: number // Debounce rapid events\n maxConcurrentInstances?: number // Limit concurrent instances\n entityType?: string // Entity type for workflow instance metadata (e.g., \"SalesOrder\")\n}\n\n/**\n * WorkflowDefinitionTrigger - Embedded trigger configuration\n *\n * Triggers are now embedded directly in the workflow definition,\n * allowing users to configure event-based workflow starts during\n * workflow creation in the visual editor.\n */\nexport interface WorkflowDefinitionTrigger {\n triggerId: string\n name: string\n description?: string | null\n eventPattern: string // e.g., \"sales.orders.created\", \"customers.*\"\n config?: WorkflowEventTriggerConfig | null\n enabled: boolean\n priority: number\n}\n\n// ============================================================================\n// JSONB Structure Interfaces\n// ============================================================================\n\nexport interface WorkflowContextSchemaField {\n name: string\n type: 'text' | 'number' | 'boolean' | 'select' | 'date'\n label?: string\n required?: boolean\n options?: string[]\n}\n\nexport interface WorkflowContextSchema {\n input?: {\n fields: WorkflowContextSchemaField[]\n }\n}\n\nexport interface WorkflowIoPortField {\n name: string\n type: 'text' | 'number' | 'boolean' | 'select' | 'date'\n label: string\n required?: boolean\n options?: string[]\n}\n\nexport interface WorkflowIoContract {\n inputs?: WorkflowIoPortField[]\n outputs?: WorkflowIoPortField[]\n}\n\nexport interface WorkflowErrorHandlerData {\n workflowId?: string\n version?: number\n stepId?: string\n}\n\nexport interface WorkflowDefinitionData {\n steps: any[] // WorkflowStep[] - will define schema in validators.ts\n transitions: any[] // WorkflowTransition[] - will define schema in validators.ts\n triggers?: WorkflowDefinitionTrigger[] // Event triggers for automatic workflow start\n contextSchema?: WorkflowContextSchema // Declared typed-input contract (spec \u00A73.1) \u2014 canonical input contract\n io?: WorkflowIoContract // Sub-workflow port contract; io.inputs is a read-through alias of contextSchema.input\n interpolation?: 'strict' | 'lenient' // Interpolation mode (spec \u00A73.6): absent = lenient; create path defaults new definitions to 'strict'\n errorHandler?: WorkflowErrorHandlerData // Catch-all error handler (spec \u00A75.9): a handler workflow OR a handler step, never both\n activities?: any[] // ActivityDefinition[] - will define schema in validators.ts\n queries?: any[]\n signals?: any[]\n timers?: any[]\n}\n\nexport interface WorkflowSampleEnvelope {\n pinnedAt: string\n source: 'manual' | 'test'\n data: unknown\n}\n\nexport interface WorkflowEditorMetadata {\n samples?: Record<string, WorkflowSampleEnvelope>\n [key: string]: unknown\n}\n\n/**\n * Marks a definition another module AUTHORED and keeps in sync, rather than a\n * human writing it in the Studio.\n *\n * It changes nothing about how the definition executes \u2014 a generated workflow is\n * an ordinary workflow, visible and editable like any other. What it records is\n * WHO regenerates it, so the owning module knows which row is its own and the\n * editor can warn that a hand edit may be overwritten on the owner's next save.\n */\nexport interface WorkflowGeneratedBy {\n /** Owning module id, e.g. `agent_orchestrator`. */\n module: string\n /** The owner's own record id (a process definition id, say). */\n ownerId: string\n}\n\nexport interface WorkflowMetadata {\n tags?: string[]\n category?: string\n icon?: string\n generatedBy?: WorkflowGeneratedBy\n // Forward-compatibility guard (spec section 5.8): the lowest engine version\n // able to execute this definition. Engines older than the declared version\n // refuse to instantiate it instead of misexecuting unknown capabilities.\n minEngineVersion?: number\n editor?: WorkflowEditorMetadata\n}\n\n/**\n * Failure-queue park marker (spec 5.9 \"Send to failure queue\"). Written when a\n * step's `failureQueue` error directive parks the instance instead of failing\n * it; the instances list filters on it (`?attention=true`) and the Phase 5\n * triage UI consumes it. Additive and engine-owned \u2014 never user-writable.\n */\nexport interface WorkflowInstanceAttention {\n reason: string\n stepId?: string\n error?: string\n at: string\n}\n\n/**\n * Recursion marker for the workflow-level error handler (spec 5.9). Engine-owned\n * and durable \u2014 deliberately NOT in `context`, which the context PATCH API lets\n * callers write, so the guard cannot be spoofed away.\n */\nexport interface WorkflowInstanceErrorHandlerMetadata {\n depth: number\n forInstanceId?: string\n forStepId?: string\n}\n\nimport type { WorkflowInstanceStepThrough } from '../lib/step-through'\n\nexport interface WorkflowInstanceMetadata {\n entityType?: string\n entityId?: string\n initiatedBy?: string\n labels?: Record<string, string>\n attention?: WorkflowInstanceAttention | null\n errorHandler?: WorkflowInstanceErrorHandlerMetadata | null\n /**\n * Step-through release token (spec section 8.2). Engine-owned and never\n * user-writable: the start route sets it from a feature-gated flag and the\n * step-through route advances it, so a client cannot release a step by\n * writing metadata directly. See `lib/step-through.ts`.\n */\n stepThrough?: WorkflowInstanceStepThrough | null\n}\n\n// ============================================================================\n// Entity: WorkflowDefinition\n// ============================================================================\n\n/**\n * WorkflowDefinition entity\n *\n * Stores workflow definitions (templates) that can be instantiated\n * to create workflow instances.\n */\n@Entity({ tableName: 'workflow_definitions' })\n// Versions of the same workflow coexist as separate rows; uniqueness is per\n// (workflowId, version, tenantId) so draft/published versions can live together.\n@Unique({ properties: ['workflowId', 'version', 'tenantId'] })\n@Index({ name: 'workflow_definitions_enabled_idx', properties: ['enabled'] })\n@Index({ name: 'workflow_definitions_tenant_org_idx', properties: ['tenantId', 'organizationId'] })\n@Index({ name: 'workflow_definitions_workflow_id_idx', properties: ['workflowId'] })\n@Index({ name: 'workflow_definitions_kind_idx', properties: ['kind'] })\n@Index({ name: 'workflow_definitions_definition_gin_idx', properties: ['definition'], type: 'gin' })\nexport class WorkflowDefinition {\n [OptionalProps]?: 'enabled' | 'version' | 'kind' | 'lifecycle' | 'createdAt' | 'updatedAt' | 'deletedAt' | 'codeWorkflowId'\n\n @PrimaryKey({ type: 'uuid', defaultRaw: 'gen_random_uuid()' })\n id!: string\n\n @Property({ name: 'workflow_id', type: 'varchar', length: 100 })\n workflowId!: string\n\n @Property({ name: 'code_workflow_id', type: 'varchar', length: 100, nullable: true })\n codeWorkflowId?: string | null\n\n @Property({ name: 'workflow_name', type: 'varchar', length: 255 })\n workflowName!: string\n\n @Property({ name: 'description', type: 'text', nullable: true })\n description?: string | null\n\n @Property({ name: 'version', type: 'integer', default: 1 })\n version: number = 1\n\n @Property({ name: 'definition', type: 'jsonb' })\n definition!: WorkflowDefinitionData\n\n @Property({ name: 'metadata', type: 'jsonb', nullable: true })\n metadata?: WorkflowMetadata | null\n\n @Property({ name: 'enabled', type: 'boolean', default: true })\n enabled: boolean = true\n\n // Distinguishes a reusable library component (no trigger, not standalone-\n // startable, callable only as a SUB_WORKFLOW) from a normal workflow.\n @Property({ name: 'kind', type: 'varchar', length: 20, default: 'workflow' })\n kind: 'workflow' | 'component' = 'workflow'\n\n // Draft/published version lifecycle. Existing rows backfill to 'published';\n // the publish flow + version coexistence land with the versioning phase.\n @Property({ name: 'lifecycle', type: 'varchar', length: 20, default: 'published' })\n lifecycle: 'draft' | 'published' | 'archived' = 'published'\n\n @Property({ name: 'effective_from', type: Date, nullable: true })\n effectiveFrom?: Date | null\n\n @Property({ name: 'effective_to', type: Date, nullable: true })\n effectiveTo?: Date | null\n\n @Property({ name: 'tenant_id', type: 'uuid' })\n tenantId!: string\n\n @Property({ name: 'organization_id', type: 'uuid' })\n organizationId!: string\n\n /**\n * The least-privilege ACL features every run of THIS version executes with.\n *\n * Null/empty (the default, and every pre-existing row) keeps the historic\n * behaviour: the run borrows the identity of whoever started it. A non-empty\n * grant makes the run act as its own `auth` execution principal instead \u2014\n * always, regardless of who started it \u2014 so it can neither inherit an admin's\n * powers nor be left without an actor when an event trigger starts it.\n *\n * A real column rather than a `metadata` key because it is a security\n * boundary: it is read on every advance, written only through the\n * `workflows.definitions.grant_features` gate, and must be diffable in an\n * audit. Per version by construction \u2014 a published version is a new row.\n */\n @Property({ name: 'granted_features', type: 'jsonb', nullable: true })\n grantedFeatures?: string[] | null\n\n @Property({ name: 'created_by', type: 'varchar', length: 255, nullable: true })\n createdBy?: string | null\n\n @Property({ name: 'updated_by', type: 'varchar', length: 255, nullable: true })\n updatedBy?: string | null\n\n @Property({ name: 'created_at', type: Date, onCreate: () => new Date() })\n createdAt: Date = new Date()\n\n @Property({ name: 'updated_at', type: Date, onUpdate: () => new Date() })\n updatedAt: Date = new Date()\n\n @Property({ name: 'deleted_at', type: Date, nullable: true })\n deletedAt?: Date | null\n}\n\n// ============================================================================\n// Entity: WorkflowDefinitionDraft\n// ============================================================================\n\n/**\n * WorkflowDefinitionDraft entity\n *\n * Per-user autosaved editor drafts for workflow definitions. A draft may\n * reference an existing definition (definitionId set) or a not-yet-saved one\n * (definitionId null). baseUpdatedAt captures the definition's updatedAt the\n * draft forked from, enabling conflict-aware restore messaging.\n */\n@Entity({ tableName: 'workflow_definition_drafts' })\n@Unique({ properties: ['definitionId', 'userId', 'tenantId'] })\n@Index({ name: 'workflow_definition_drafts_tenant_org_idx', properties: ['tenantId', 'organizationId'] })\nexport class WorkflowDefinitionDraft {\n [OptionalProps]?: 'createdAt' | 'updatedAt' | 'deletedAt'\n\n @PrimaryKey({ type: 'uuid', defaultRaw: 'gen_random_uuid()' })\n id!: string\n\n @Property({ name: 'definition_id', type: 'uuid', nullable: true })\n definitionId?: string | null\n\n @Property({ name: 'user_id', type: 'uuid' })\n userId!: string\n\n @Property({ name: 'definition', type: 'jsonb' })\n definition!: WorkflowDefinitionData\n\n @Property({ name: 'metadata', type: 'jsonb', nullable: true })\n metadata?: WorkflowMetadata | null\n\n @Property({ name: 'base_updated_at', type: Date, nullable: true })\n baseUpdatedAt?: Date | null\n\n @Property({ name: 'tenant_id', type: 'uuid' })\n tenantId!: string\n\n @Property({ name: 'organization_id', type: 'uuid' })\n organizationId!: string\n\n @Property({ name: 'created_at', type: Date, onCreate: () => new Date() })\n createdAt: Date = new Date()\n\n @Property({ name: 'updated_at', type: Date, onUpdate: () => new Date() })\n updatedAt: Date = new Date()\n\n @Property({ name: 'deleted_at', type: Date, nullable: true })\n deletedAt?: Date | null\n}\n\n// ============================================================================\n// Entity: WorkflowInstance\n// ============================================================================\n\n/**\n * WorkflowInstance entity\n *\n * Represents a running instance of a workflow definition.\n * Tracks the current state, context data, and execution status.\n */\n@Entity({ tableName: 'workflow_instances' })\n@Index({ name: 'workflow_instances_definition_status_idx', properties: ['definitionId', 'status'] })\n@Index({ name: 'workflow_instances_correlation_key_idx', properties: ['correlationKey'] })\n@Index({ name: 'workflow_instances_status_tenant_idx', properties: ['status', 'tenantId'] })\n@Index({ name: 'workflow_instances_current_step_idx', properties: ['currentStepId', 'status'] })\n@Index({ name: 'workflow_instances_tenant_org_idx', properties: ['tenantId', 'organizationId'] })\nexport class WorkflowInstance {\n [OptionalProps]?: 'retryCount' | 'isDryRun' | 'createdAt' | 'updatedAt' | 'deletedAt'\n\n @PrimaryKey({ type: 'uuid', defaultRaw: 'gen_random_uuid()' })\n id!: string\n\n @Property({ name: 'definition_id', type: 'uuid' })\n definitionId!: string\n\n @Property({ name: 'workflow_id', type: 'varchar', length: 100 })\n workflowId!: string\n\n @Property({ name: 'version', type: 'integer' })\n version!: number\n\n @Property({ name: 'status', type: 'varchar', length: 30 })\n status!: WorkflowInstanceStatus\n\n /**\n * Terminal VERDICT, written once when the run terminates and null while it is\n * still going (`lib/run-outcome.ts` owns the vocabulary and the decision).\n *\n * Additive and nullable ON PURPOSE: `status` keeps meaning exactly what every\n * existing consumer, filter and subscriber already believes it means, and a\n * null on a pre-existing row means \"ran before outcomes existed\" \u2014 never\n * \"success\". Nothing is backfilled: a fabricated verdict would be the same\n * dishonesty this column exists to remove, pointed the other way.\n */\n @Property({ name: 'outcome', type: 'varchar', length: 30, nullable: true })\n outcome?: WorkflowRunOutcome | null\n\n @Property({ name: 'current_step_id', type: 'varchar', length: 100 })\n currentStepId!: string\n\n @Property({ name: 'context', type: 'jsonb' })\n context!: Record<string, any>\n\n @Property({ name: 'correlation_key', type: 'varchar', length: 255, nullable: true })\n correlationKey?: string | null\n\n @Property({ name: 'metadata', type: 'jsonb', nullable: true })\n metadata?: WorkflowInstanceMetadata | null\n\n @Property({ name: 'started_at', type: Date })\n startedAt!: Date\n\n @Property({ name: 'completed_at', type: Date, nullable: true })\n completedAt?: Date | null\n\n @Property({ name: 'paused_at', type: Date, nullable: true })\n pausedAt?: Date | null\n\n @Property({ name: 'cancelled_at', type: Date, nullable: true })\n cancelledAt?: Date | null\n\n @Property({ name: 'error_message', type: 'text', nullable: true })\n errorMessage?: string | null\n\n @Property({ name: 'error_details', type: 'jsonb', nullable: true })\n errorDetails?: any | null\n\n @Property({ name: 'pending_transition', type: 'jsonb', nullable: true })\n pendingTransition?: {\n toStepId: string\n activityResults: any[]\n timestamp: Date\n } | null\n\n // When the instance is FORKED, points at the open PARALLEL_FORK step whose\n // branches are currently executing. Null for single-token instances.\n @Property({ name: 'active_fork_step_id', type: 'varchar', length: 100, nullable: true })\n activeForkStepId?: string | null\n\n @Property({ name: 'retry_count', type: 'integer', default: 0 })\n retryCount: number = 0\n\n /**\n * Marks the run as a side-effect-free simulation (spec section 8.2).\n *\n * It is a COLUMN rather than a metadata key because every isolation decision\n * reads it \u2014 the activity dispatcher, the USER_TASK handler, the business-rule\n * bridge and the list/KPI `where` builders \u2014 and a jsonb path predicate in a\n * hot filter is both slower and easy to forget. It is written once at start\n * and never mutated, so a run cannot change what it is halfway through.\n */\n @Property({ name: 'is_dry_run', type: 'boolean', default: false })\n isDryRun: boolean = false\n\n @Property({ name: 'tenant_id', type: 'uuid' })\n tenantId!: string\n\n @Property({ name: 'organization_id', type: 'uuid' })\n organizationId!: string\n\n @Property({ name: 'created_at', type: Date, onCreate: () => new Date() })\n createdAt: Date = new Date()\n\n @Property({ name: 'updated_at', type: Date, onUpdate: () => new Date() })\n updatedAt: Date = new Date()\n\n @Property({ name: 'deleted_at', type: Date, nullable: true })\n deletedAt?: Date | null\n}\n\n// ============================================================================\n// Entity: WorkflowBranchInstance\n// ============================================================================\n\n/**\n * WorkflowBranchInstance entity\n *\n * A single parallel branch token created by a PARALLEL_FORK step. Each branch\n * advances independently (interleaved under the instance lock) with its own\n * private context namespace, and converges to the paired PARALLEL_JOIN step.\n * Branches are tenant/org scoped and never cross-tenant.\n */\n@Entity({ tableName: 'workflow_branch_instances' })\n@Index({ name: 'workflow_branch_instances_instance_status_idx', properties: ['workflowInstanceId', 'status'] })\n@Index({ name: 'workflow_branch_instances_instance_fork_idx', properties: ['workflowInstanceId', 'forkStepId'] })\n@Index({ name: 'workflow_branch_instances_tenant_org_idx', properties: ['tenantId', 'organizationId'] })\nexport class WorkflowBranchInstance {\n [OptionalProps]?: 'createdAt' | 'updatedAt'\n\n @PrimaryKey({ type: 'uuid', defaultRaw: 'gen_random_uuid()' })\n id!: string\n\n @Property({ name: 'workflow_instance_id', type: 'uuid' })\n workflowInstanceId!: string\n\n @Property({ name: 'fork_step_id', type: 'varchar', length: 100 })\n forkStepId!: string\n\n @Property({ name: 'join_step_id', type: 'varchar', length: 100 })\n joinStepId!: string\n\n // The transitionId of the FORK's outgoing transition that created this branch.\n @Property({ name: 'branch_key', type: 'varchar', length: 100 })\n branchKey!: string\n\n // Reserved for nested-fork support (always null this iteration; validator blocks nesting).\n @Property({ name: 'parent_branch_id', type: 'uuid', nullable: true })\n parentBranchId?: string | null\n\n @Property({ name: 'current_step_id', type: 'varchar', length: 100 })\n currentStepId!: string\n\n @Property({ name: 'status', type: 'varchar', length: 30 })\n status!: WorkflowBranchInstanceStatus\n\n // The branch's private write scope; merged back into instance.context at JOIN.\n @Property({ name: 'context_namespace', type: 'jsonb' })\n contextNamespace!: Record<string, any>\n\n // Per-branch equivalent of WorkflowInstance.pendingTransition (async activities).\n @Property({ name: 'pending_transition', type: 'jsonb', nullable: true })\n pendingTransition?: {\n toStepId: string\n activityResults: any[]\n timestamp: Date\n } | null\n\n @Property({ name: 'error_message', type: 'text', nullable: true })\n errorMessage?: string | null\n\n @Property({ name: 'error_details', type: 'jsonb', nullable: true })\n errorDetails?: any | null\n\n @Property({ name: 'started_at', type: Date, nullable: true })\n startedAt?: Date | null\n\n @Property({ name: 'completed_at', type: Date, nullable: true })\n completedAt?: Date | null\n\n @Property({ name: 'tenant_id', type: 'uuid' })\n tenantId!: string\n\n @Property({ name: 'organization_id', type: 'uuid' })\n organizationId!: string\n\n @Property({ name: 'created_at', type: Date, onCreate: () => new Date() })\n createdAt: Date = new Date()\n\n @Property({ name: 'updated_at', type: Date, onUpdate: () => new Date() })\n updatedAt: Date = new Date()\n}\n\n// ============================================================================\n// Entity: StepInstance\n// ============================================================================\n\n/**\n * StepInstance entity\n *\n * Tracks individual step executions within a workflow instance.\n * Records input/output data, timing, and execution status for each step.\n */\n@Entity({ tableName: 'step_instances' })\n@Index({ name: 'step_instances_workflow_instance_idx', properties: ['workflowInstanceId', 'status'] })\n@Index({ name: 'step_instances_step_id_idx', properties: ['stepId', 'status'] })\n@Index({ name: 'step_instances_tenant_org_idx', properties: ['tenantId', 'organizationId'] })\nexport class StepInstance {\n [OptionalProps]?: 'retryCount' | 'createdAt' | 'updatedAt'\n\n @PrimaryKey({ type: 'uuid', defaultRaw: 'gen_random_uuid()' })\n id!: string\n\n @Property({ name: 'workflow_instance_id', type: 'uuid' })\n workflowInstanceId!: string\n\n // Set when this step executes inside a parallel branch; null for single-token.\n @Property({ name: 'branch_instance_id', type: 'uuid', nullable: true })\n branchInstanceId?: string | null\n\n @Property({ name: 'step_id', type: 'varchar', length: 100 })\n stepId!: string\n\n @Property({ name: 'step_name', type: 'varchar', length: 255 })\n stepName!: string\n\n @Property({ name: 'step_type', type: 'varchar', length: 50 })\n stepType!: string\n\n @Property({ name: 'status', type: 'varchar', length: 20 })\n status!: StepInstanceStatus\n\n @Property({ name: 'input_data', type: 'jsonb', nullable: true })\n inputData?: any | null\n\n @Property({ name: 'output_data', type: 'jsonb', nullable: true })\n outputData?: any | null\n\n @Property({ name: 'error_data', type: 'jsonb', nullable: true })\n errorData?: any | null\n\n @Property({ name: 'entered_at', type: Date, nullable: true })\n enteredAt?: Date | null\n\n @Property({ name: 'exited_at', type: Date, nullable: true })\n exitedAt?: Date | null\n\n /**\n * @deprecated Written on the COMPLETED path only and `null` for any step that\n * lasted 2^31 ms (~24.86 days) or longer, which a Postgres `integer` cannot\n * hold. Derive the duration from `exitedAt - enteredAt` instead; the column\n * is scheduled for removal no earlier than 0.11.0 (see UPGRADE_NOTES.md).\n */\n @Property({ name: 'execution_time_ms', type: 'integer', nullable: true })\n executionTimeMs?: number | null\n\n @Property({ name: 'retry_count', type: 'integer', default: 0 })\n retryCount: number = 0\n\n @Property({ name: 'tenant_id', type: 'uuid' })\n tenantId!: string\n\n @Property({ name: 'organization_id', type: 'uuid' })\n organizationId!: string\n\n @Property({ name: 'created_at', type: Date, onCreate: () => new Date() })\n createdAt: Date = new Date()\n\n @Property({ name: 'updated_at', type: Date, onUpdate: () => new Date() })\n updatedAt: Date = new Date()\n}\n\n// ============================================================================\n// Entity: UserTask\n// ============================================================================\n\n/**\n * UserTask entity\n *\n * Represents user tasks that require human interaction within a workflow.\n * Tracks assignment, SLA, escalation, and completion status.\n */\n@Entity({ tableName: 'user_tasks' })\n@Index({ name: 'user_tasks_workflow_instance_idx', properties: ['workflowInstanceId'] })\n@Index({ name: 'user_tasks_status_assigned_idx', properties: ['status', 'assignedTo'] })\n@Index({ name: 'user_tasks_status_due_date_idx', properties: ['status', 'dueDate'] })\n@Index({ name: 'user_tasks_tenant_org_idx', properties: ['tenantId', 'organizationId'] })\n// The \u00A76.4 entity gate is \"no binding whose type is outside my allowed set\",\n// which is a containment test over `entity_types` \u2014 so it must be a SQL WHERE,\n// not a JS post-filter. Post-filtering a page makes `pagination.total` a lie and\n// returns short pages. GIN is what makes `<@` indexable.\n@Index({ name: 'user_tasks_entity_types_gin_idx', properties: ['entityTypes'], type: 'gin' })\nexport class UserTask {\n [OptionalProps]?: 'createdAt' | 'updatedAt' | 'assigneeKind'\n\n @PrimaryKey({ type: 'uuid', defaultRaw: 'gen_random_uuid()' })\n id!: string\n\n @Property({ name: 'workflow_instance_id', type: 'uuid' })\n workflowInstanceId!: string\n\n @Property({ name: 'step_instance_id', type: 'uuid' })\n stepInstanceId!: string\n\n // Set when this task belongs to a parallel branch; null for single-token instances.\n @Property({ name: 'branch_instance_id', type: 'uuid', nullable: true })\n branchInstanceId?: string | null\n\n @Property({ name: 'task_name', type: 'varchar', length: 255 })\n taskName!: string\n\n @Property({ name: 'description', type: 'text', nullable: true })\n description?: string | null\n\n @Property({ name: 'status', type: 'varchar', length: 20 })\n status!: UserTaskStatus\n\n @Property({ name: 'form_schema', type: 'jsonb', nullable: true })\n formSchema?: any | null\n\n @Property({ name: 'form_data', type: 'jsonb', nullable: true })\n formData?: any | null\n\n @Property({ name: 'assigned_to', type: 'varchar', length: 255, nullable: true })\n assignedTo?: string | null\n\n /**\n * Which principal namespace `assignedTo` names.\n *\n * NOT NULL with a default rather than nullable: the column exists precisely to\n * remove ambiguity, and reintroducing a null case defeats it. Existing rows\n * backfill to `'user'`, which is correct \u2014 every `assigned_to` written before\n * this column existed is a backoffice user id. Rows with `assigned_to IS NULL`\n * also get `'user'`; harmless, because every branch that reads it first checks\n * that `assignedTo` is set.\n *\n * `assignedToRoles` is never combined with `'customer'`: portal roles are a\n * different namespace (`CustomerRole`) and portal principals cannot claim from\n * a queue.\n */\n @Property({ name: 'assignee_kind', type: 'varchar', length: 20, default: 'user' })\n assigneeKind: UserTaskAssigneeKind = 'user'\n\n @Property({ name: 'assigned_to_roles', type: 'text[]', nullable: true })\n assignedToRoles?: string[] | null\n\n @Property({ name: 'claimed_by', type: 'varchar', length: 255, nullable: true })\n claimedBy?: string | null\n\n @Property({ name: 'claimed_at', type: Date, nullable: true })\n claimedAt?: Date | null\n\n @Property({ name: 'due_date', type: Date, nullable: true })\n dueDate?: Date | null\n\n @Property({ name: 'escalated_at', type: Date, nullable: true })\n escalatedAt?: Date | null\n\n @Property({ name: 'escalated_to', type: 'varchar', length: 255, nullable: true })\n escalatedTo?: string | null\n\n @Property({ name: 'completed_by', type: 'varchar', length: 255, nullable: true })\n completedBy?: string | null\n\n @Property({ name: 'completed_at', type: Date, nullable: true })\n completedAt?: Date | null\n\n @Property({ name: 'comments', type: 'text', nullable: true })\n comments?: string | null\n\n /**\n * Records this task is about, resolved from the authored\n * `userTaskConfig.entityBindings` when the task was created.\n *\n * A real column rather than a read of the authored `formSchema` blob: the\n * work inbox, the record-page widget and the \u00A76.4 visibility predicate all\n * need to filter on it, and the authored form schema is the wrong shape and\n * the wrong lifetime for that (it describes the FORM, and re-editing the\n * definition must not retro-change what a running task is about).\n */\n @Property({ name: 'entity_bindings', type: 'jsonb', nullable: true })\n entityBindings?: unknown[] | null\n\n /**\n * The distinct AUTHORED `entityType` values from `entityBindings`, denormalized\n * so the \u00A76.4 entity gate is expressible as `entity_types <@ ARRAY[allowed]`\n * against a GIN index.\n *\n * Authored verbatim, not normalized to generated entity ids, because the\n * visibility predicate keys its per-request access map on exactly the string\n * the binding carries. Storing a second, normalized spelling here would give\n * the SQL filter and the JS predicate two different notions of \"the same type\"\n * \u2014 and the one place they could disagree is the one place a task goes\n * invisible without a trace.\n *\n * NULL means \"no bindings\", which is \u00A72.4's vacuous pass for a backoffice\n * principal. Every row written before this column existed is therefore correct\n * by construction \u2014 no backfill needed.\n */\n @Property({ name: 'entity_types', type: 'text[]', nullable: true })\n entityTypes?: string[] | null\n\n /** Authored `low|medium|high|extreme`, mirroring the platform's labels. */\n @Property({ name: 'priority', type: 'varchar', length: 20, nullable: true })\n priority?: string | null\n\n /**\n * Reassignment audit \u2014 who moved this task, when, and why.\n *\n * Deliberately audit columns and not a new `UserTaskStatus` value: a status\n * addition is an Ask-First state-machine change, and the reassigned task is\n * still exactly as pending or in-progress as it was. Mirrors how Phase 3a's\n * failure queue reused `PAUSED` plus a marker.\n */\n @Property({ name: 'reassigned_by', type: 'varchar', length: 255, nullable: true })\n reassignedBy?: string | null\n\n @Property({ name: 'reassigned_at', type: Date, nullable: true })\n reassignedAt?: Date | null\n\n @Property({ name: 'reassign_reason', type: 'text', nullable: true })\n reassignReason?: string | null\n\n @Property({ name: 'tenant_id', type: 'uuid' })\n tenantId!: string\n\n @Property({ name: 'organization_id', type: 'uuid' })\n organizationId!: string\n\n @Property({ name: 'created_at', type: Date, onCreate: () => new Date() })\n createdAt: Date = new Date()\n\n @Property({ name: 'updated_at', type: Date, onUpdate: () => new Date() })\n updatedAt: Date = new Date()\n}\n\n// ============================================================================\n// Entity: WorkflowEvent\n// ============================================================================\n\n/**\n * WorkflowEvent entity\n *\n * Event sourcing log for workflow execution history.\n * Records all events that occur during workflow execution for audit and replay.\n */\n@Entity({ tableName: 'workflow_events' })\n@Index({ name: 'workflow_events_instance_occurred_idx', properties: ['workflowInstanceId', 'occurredAt'] })\n@Index({ name: 'workflow_events_event_type_idx', properties: ['eventType', 'occurredAt'] })\n@Index({ name: 'workflow_events_tenant_org_idx', properties: ['tenantId', 'organizationId'] })\nexport class WorkflowEvent {\n @PrimaryKey({ type: 'bigint', autoincrement: true })\n id!: string\n\n @Property({ name: 'workflow_instance_id', type: 'uuid' })\n workflowInstanceId!: string\n\n @Property({ name: 'step_instance_id', type: 'uuid', nullable: true })\n stepInstanceId?: string | null\n\n // Set when the event was logged within a parallel branch; null otherwise.\n @Property({ name: 'branch_instance_id', type: 'uuid', nullable: true })\n branchInstanceId?: string | null\n\n @Property({ name: 'event_type', type: 'varchar', length: 50 })\n eventType!: string\n\n @Property({ name: 'event_data', type: 'jsonb' })\n eventData!: any\n\n @Property({ name: 'occurred_at', type: Date, onCreate: () => new Date() })\n occurredAt: Date = new Date()\n\n @Property({ name: 'user_id', type: 'varchar', length: 255, nullable: true })\n userId?: string | null\n\n @Property({ name: 'tenant_id', type: 'uuid' })\n tenantId!: string\n\n @Property({ name: 'organization_id', type: 'uuid' })\n organizationId!: string\n}\n\n// ============================================================================\n// Entity: WorkflowEventTrigger\n// ============================================================================\n\n/**\n * WorkflowEventTrigger entity\n *\n * Maps event patterns to workflow definitions for automatic triggering.\n * When a matching event is emitted, the corresponding workflow is started\n * with context mapped from the event payload.\n */\n@Entity({ tableName: 'workflow_event_triggers' })\n@Index({ name: 'workflow_event_triggers_event_pattern_idx', properties: ['eventPattern', 'enabled'] })\n@Index({ name: 'workflow_event_triggers_definition_idx', properties: ['workflowDefinitionId'] })\n@Index({ name: 'workflow_event_triggers_tenant_org_idx', properties: ['tenantId', 'organizationId'] })\n@Index({ name: 'workflow_event_triggers_enabled_priority_idx', properties: ['enabled', 'priority'] })\nexport class WorkflowEventTrigger {\n [OptionalProps]?: 'enabled' | 'priority' | 'createdAt' | 'updatedAt' | 'deletedAt'\n\n @PrimaryKey({ type: 'uuid', defaultRaw: 'gen_random_uuid()' })\n id!: string\n\n @Property({ name: 'name', type: 'varchar', length: 255 })\n name!: string\n\n @Property({ name: 'description', type: 'text', nullable: true })\n description?: string | null\n\n @Property({ name: 'workflow_definition_id', type: 'uuid' })\n workflowDefinitionId!: string\n\n @Property({ name: 'event_pattern', type: 'varchar', length: 255 })\n eventPattern!: string\n\n @Property({ name: 'config', type: 'jsonb', nullable: true })\n config?: WorkflowEventTriggerConfig | null\n\n @Property({ name: 'enabled', type: 'boolean', default: true })\n enabled: boolean = true\n\n @Property({ name: 'priority', type: 'integer', default: 0 })\n priority: number = 0\n\n @Property({ name: 'tenant_id', type: 'uuid' })\n tenantId!: string\n\n @Property({ name: 'organization_id', type: 'uuid' })\n organizationId!: string\n\n @Property({ name: 'created_by', type: 'varchar', length: 255, nullable: true })\n createdBy?: string | null\n\n @Property({ name: 'updated_by', type: 'varchar', length: 255, nullable: true })\n updatedBy?: string | null\n\n @Property({ name: 'created_at', type: Date, onCreate: () => new Date() })\n createdAt: Date = new Date()\n\n @Property({ name: 'updated_at', type: Date, onUpdate: () => new Date() })\n updatedAt: Date = new Date()\n\n @Property({ name: 'deleted_at', type: Date, nullable: true })\n deletedAt?: Date | null\n}\n\n// ============================================================================\n// Entity: WorkflowDefinitionMetricRollup\n// ============================================================================\n\n/**\n * WorkflowDefinitionMetricRollup entity (spec \u00A78.5)\n *\n * Precomputed per-definition operational KPIs \u2014 runs, success rate, run-duration\n * percentiles and task SLA hit-rate \u2014 over the sliding windows an operator reads.\n * Deliberately shaped after `agent_orchestrator`'s `AgentMetricRollup`\n * (tenant/org + logical id + window bounds + `computed_at` + a zod-validated\n * `metrics` jsonb) so the two ops surfaces stay legible side by side. The shape\n * is MIRRORED, never imported: `enterprise` is an optional peer and core must\n * not hard-require it.\n *\n * Two deliberate divergences from that model, both fixing a latent flaw in it:\n *\n * - **`window_key` is its own column and part of the unique key.** The mirrored\n * table identifies a row by `(org, agent, window_start)` alone, so a 7d window\n * computed in one pass and a 30d window computed 23 days later can land on the\n * same `window_start` and silently overwrite each other with metrics for a\n * different span. Naming the span makes that impossible.\n * - **The unique key is enforced by the DATABASE**, and includes `tenant_id`.\n * The mirrored writer does a read-then-insert with no constraint behind it, so\n * two concurrent passes both miss and both insert. Here the recompute-and-\n * upsert is idempotent because the index says so, not because only one worker\n * happens to run.\n *\n * Not user-editable: rows are written only by the rollup worker and read only by\n * `api/metrics/definitions`. It therefore carries no `updated_at` and takes the\n * background-job / machine-aggregate exemption from the optimistic-lock rule \u2014\n * there is no edit form, no delete endpoint and no concurrent human writer for a\n * version token to protect. `computed_at` is the freshness stamp readers use.\n *\n * Keyed on `workflow_id` (the logical id, like `AgentMetricRollup.agentId`)\n * rather than on a `workflow_definitions` row id: `WorkflowInstance.workflowId`\n * is already denormalized so no join is needed, and an operator asks how a\n * PROCESS is doing, not how version 3 of it is doing.\n */\n@Entity({ tableName: 'workflow_definition_metric_rollups' })\n@Unique({\n name: 'workflow_definition_metric_rollups_bucket_uq',\n properties: ['tenantId', 'organizationId', 'workflowId', 'windowKey', 'windowStart'],\n})\n@Index({\n name: 'workflow_definition_metric_rollups_lookup_idx',\n properties: ['tenantId', 'organizationId', 'workflowId', 'windowKey'],\n})\nexport class WorkflowDefinitionMetricRollup {\n [OptionalProps]?: 'computedAt' | 'createdAt'\n\n @PrimaryKey({ type: 'uuid', defaultRaw: 'gen_random_uuid()' })\n id!: string\n\n @Property({ name: 'tenant_id', type: 'uuid' })\n tenantId!: string\n\n @Property({ name: 'organization_id', type: 'uuid' })\n organizationId!: string\n\n /** Logical workflow id, mirroring `WorkflowInstance.workflowId`. */\n @Property({ name: 'workflow_id', type: 'varchar', length: 100 })\n workflowId!: string\n\n /** Window length this row measures: `24h`, `7d` or `30d`. */\n @Property({ name: 'window_key', type: 'varchar', length: 10 })\n windowKey!: string\n\n @Property({ name: 'window_start', type: Date })\n windowStart!: Date\n\n @Property({ name: 'window_end', type: Date })\n windowEnd!: Date\n\n @Property({ name: 'computed_at', type: Date, onCreate: () => new Date() })\n computedAt: Date = new Date()\n\n /** Validated by `workflowDefinitionMetricsSchema` on every read. */\n @Property({ name: 'metrics', type: 'jsonb' })\n metrics!: Record<string, unknown>\n\n @Property({ name: 'created_at', type: Date, onCreate: () => new Date() })\n createdAt: Date = new Date()\n}\n\n// Export all entities as default for MikroORM discovery\nexport default [\n WorkflowDefinition,\n WorkflowDefinitionDraft,\n WorkflowInstance,\n WorkflowBranchInstance,\n StepInstance,\n UserTask,\n WorkflowEvent,\n WorkflowEventTrigger,\n WorkflowDefinitionMetricRollup,\n]\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;AAMA,SAAS,qBAAqB;AAC9B,SAAS,QAAQ,OAAO,YAAY,UAAU,cAAc;AAsRzD;AADI,IAAM,qBAAN,MAAyB;AAAA,EAAzB;AAmBL,mBAAkB;AASlB,mBAAmB;AAKnB,gBAAiC;AAKjC,qBAAgD;AAsChD,qBAAkB,oBAAI,KAAK;AAG3B,qBAAkB,oB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AAGA;AAAA,EADC,SAAS,EAAE,MAAM,eAAe,MAAM,MAAM,UAAU,MAAM,oBAAI,KAAK,EAAE,CAAC;AAAA,GA1B9D,+BA2BX;AAIA;AAAA,EADC,SAAS,EAAE,MAAM,WAAW,MAAM,QAAQ,CAAC;AAAA,GA9BjC,+BA+BX;AAGA;AAAA,EADC,SAAS,EAAE,MAAM,cAAc,MAAM,MAAM,UAAU,MAAM,oBAAI,KAAK,EAAE,CAAC;AAAA,GAjC7D,+BAkCX;AAlCW,iCAAN;AAAA,EATN,OAAO,EAAE,WAAW,qCAAqC,CAAC;AAAA,EAC1D,OAAO;AAAA,IACN,MAAM;AAAA,IACN,YAAY,CAAC,YAAY,kBAAkB,cAAc,aAAa,aAAa;AAAA,EACrF,CAAC;AAAA,EACA,MAAM;AAAA,IACL,MAAM;AAAA,IACN,YAAY,CAAC,YAAY,kBAAkB,cAAc,WAAW;AAAA,EACtE,CAAC;AAAA,GACY;AAsCb,IAAO,mBAAQ;AAAA,EACb;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -38,7 +38,7 @@ import "./activity-registry-bootstrap.js";
|
|
|
38
38
|
import { bindActivityExecutor } from "./activity-types.js";
|
|
39
39
|
import { getActivityType } from "./activity-registry.js";
|
|
40
40
|
import { logWorkflowEvent } from "./event-logger.js";
|
|
41
|
-
import { calculateWaitDelayMs } from "./duration.js";
|
|
41
|
+
import { MAX_INLINE_WAIT_MS, assertInProcessWaitDelay, calculateWaitDelayMs } from "./duration.js";
|
|
42
42
|
import { calculateWaitDelayMs as calculateWaitDelayMs2 } from "./duration.js";
|
|
43
43
|
import { resolveActivityTimeoutMs } from "./activityTimeoutFields.js";
|
|
44
44
|
import { getWorkflowSafeCommand } from "./workflow-safe-commands.js";
|
|
@@ -359,12 +359,26 @@ async function executeActivity(em, container, activity, context) {
|
|
|
359
359
|
async: activity.async || false
|
|
360
360
|
};
|
|
361
361
|
}
|
|
362
|
-
|
|
362
|
+
function isLongInlineWait(activity, context) {
|
|
363
|
+
const entry = getActivityType(activity.activityType);
|
|
364
|
+
if (!entry?.enqueueDelayMs || entry.async.capable === false) return false;
|
|
365
|
+
try {
|
|
366
|
+
const delayMs = entry.enqueueDelayMs(
|
|
367
|
+
interpolateActivityConfig(activity.config, context, activity.activityType, activity.activityName)
|
|
368
|
+
);
|
|
369
|
+
return delayMs !== null && delayMs > MAX_INLINE_WAIT_MS;
|
|
370
|
+
} catch {
|
|
371
|
+
return false;
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
async function executeActivities(em, container, activities, context, options = {}) {
|
|
363
375
|
const results = [];
|
|
364
376
|
const forceSynchronous = isDryRunInstance(context.workflowInstance);
|
|
365
377
|
for (let i = 0; i < activities.length; i++) {
|
|
366
378
|
const activity = activities[i];
|
|
367
|
-
|
|
379
|
+
const isLastActivity = i === activities.length - 1;
|
|
380
|
+
const queueAsLongWait = !activity.async && options.queueLongInlineWaits === true && isLastActivity && isLongInlineWait(activity, context);
|
|
381
|
+
if ((activity.async || queueAsLongWait) && !forceSynchronous) {
|
|
368
382
|
const jobId = await enqueueActivity(em, activity, context);
|
|
369
383
|
results.push({
|
|
370
384
|
activityId: activity.activityId,
|
|
@@ -786,7 +800,7 @@ async function executeFunction(config, context, container, signal) {
|
|
|
786
800
|
}
|
|
787
801
|
}
|
|
788
802
|
async function executeWait(config) {
|
|
789
|
-
const durationMs = calculateWaitDelayMs(config);
|
|
803
|
+
const durationMs = assertInProcessWaitDelay(calculateWaitDelayMs(config));
|
|
790
804
|
await sleep(durationMs);
|
|
791
805
|
return { waited: true, durationMs };
|
|
792
806
|
}
|