@open-mercato/core 0.4.2-canary-f728a6d66a → 0.4.2-canary-ec4978dbb3
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/dist/modules/business_rules/api/execute/[ruleId]/route.js +3 -8
- package/dist/modules/business_rules/api/execute/[ruleId]/route.js.map +2 -2
- package/dist/modules/workflows/cli.js.map +2 -2
- package/dist/modules/workflows/data/entities.js.map +2 -2
- package/package.json +2 -2
- package/src/modules/business_rules/api/execute/[ruleId]/route.ts +3 -8
- package/src/modules/workflows/cli.ts +8 -2
- package/src/modules/workflows/data/entities.ts +1 -0
|
@@ -110,14 +110,9 @@ const openApi = {
|
|
|
110
110
|
POST: {
|
|
111
111
|
summary: "Execute a specific rule by its database UUID",
|
|
112
112
|
description: "Directly executes a specific business rule identified by its UUID, bypassing the normal entityType/eventType discovery mechanism. Useful for workflows and targeted rule execution.",
|
|
113
|
-
pathParams:
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
description: "The database UUID of the business rule to execute",
|
|
117
|
-
required: true,
|
|
118
|
-
schema: z.uuid()
|
|
119
|
-
}
|
|
120
|
-
],
|
|
113
|
+
pathParams: z.object({
|
|
114
|
+
ruleId: z.string().uuid().describe("The database UUID of the business rule to execute")
|
|
115
|
+
}),
|
|
121
116
|
requestBody: {
|
|
122
117
|
contentType: "application/json",
|
|
123
118
|
schema: executeByIdRequestSchema
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../src/modules/business_rules/api/execute/%5BruleId%5D/route.ts"],
|
|
4
|
-
"sourcesContent": ["import { NextResponse } from 'next/server'\nimport { z } from 'zod'\nimport type { OpenApiRouteDoc } from '@open-mercato/shared/lib/openapi'\nimport { getAuthFromRequest } from '@open-mercato/shared/lib/auth/server'\nimport { createRequestContainer } from '@open-mercato/shared/lib/di/container'\nimport type { EntityManager } from '@mikro-orm/postgresql'\nimport * as ruleEngine from '../../../lib/rule-engine'\n\nconst executeByIdRequestSchema = z.object({\n data: z.any(),\n dryRun: z.boolean().optional().default(false),\n entityType: z.string().optional(),\n entityId: z.string().optional(),\n eventType: z.string().optional(),\n})\n\nconst executeByIdResponseSchema = z.object({\n success: z.boolean(),\n ruleId: z.string(),\n ruleName: z.string(),\n conditionResult: z.boolean(),\n actionsExecuted: z.object({\n success: z.boolean(),\n results: z.array(z.object({\n type: z.string(),\n success: z.boolean(),\n error: z.string().optional(),\n })),\n }).nullable(),\n executionTime: z.number(),\n error: z.string().optional(),\n logId: z.string().optional(),\n})\n\nconst errorResponseSchema = z.object({\n error: z.string(),\n})\n\nconst routeMetadata = {\n POST: { requireAuth: true, requireFeatures: ['business_rules.execute'] },\n}\n\nexport const metadata = routeMetadata\n\ninterface RouteContext {\n params: Promise<{ ruleId: string }>\n}\n\nexport async function POST(req: Request, context: RouteContext) {\n const auth = await getAuthFromRequest(req)\n if (!auth) {\n return NextResponse.json({ error: 'Unauthorized' }, { status: 401 })\n }\n\n const params = await context.params\n const ruleId = params.ruleId\n\n if (!ruleId || !z.uuid().safeParse(ruleId).success) {\n return NextResponse.json({ error: 'Invalid rule ID' }, { status: 400 })\n }\n\n const container = await createRequestContainer()\n const em = container.resolve('em') as EntityManager\n\n let body: any\n try {\n body = await req.json()\n } catch {\n return NextResponse.json({ error: 'Invalid JSON body' }, { status: 400 })\n }\n\n const parsed = executeByIdRequestSchema.safeParse(body)\n if (!parsed.success) {\n const errors = parsed.error.issues.map(e => `${e.path.join('.')}: ${e.message}`)\n return NextResponse.json({ error: `Validation failed: ${errors.join(', ')}` }, { status: 400 })\n }\n\n const { data, dryRun, entityType, entityId, eventType } = parsed.data\n\n const execContext: ruleEngine.DirectRuleExecutionContext = {\n ruleId,\n data,\n user: {\n id: auth.sub,\n email: auth.email,\n role: (auth.role as string) ?? undefined,\n },\n tenantId: auth.tenantId ?? '',\n organizationId: auth.orgId ?? '',\n executedBy: auth.sub ?? auth.email ?? undefined,\n dryRun,\n entityType,\n entityId,\n eventType,\n }\n\n try {\n const result = await ruleEngine.executeRuleById(em, execContext)\n\n const response = {\n success: result.success,\n ruleId: result.ruleId,\n ruleName: result.ruleName,\n conditionResult: result.conditionResult,\n actionsExecuted: result.actionsExecuted ? {\n success: result.actionsExecuted.success,\n results: result.actionsExecuted.results.map(ar => ({\n type: ar.action.type,\n success: ar.success,\n error: ar.error,\n })),\n } : null,\n executionTime: result.executionTime,\n error: result.error,\n logId: result.logId,\n }\n\n // Return appropriate status based on result\n const status = result.success ? 200 : (result.error === 'Rule not found' ? 404 : 200)\n return NextResponse.json(response, { status })\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : String(error)\n return NextResponse.json(\n { error: `Rule execution failed: ${errorMessage}` },\n { status: 500 }\n )\n }\n}\n\nexport const openApi: OpenApiRouteDoc = {\n tag: 'Business Rules',\n summary: 'Execute a specific business rule by ID',\n methods: {\n POST: {\n summary: 'Execute a specific rule by its database UUID',\n description: 'Directly executes a specific business rule identified by its UUID, bypassing the normal entityType/eventType discovery mechanism. Useful for workflows and targeted rule execution.',\n pathParams:
|
|
5
|
-
"mappings": "AAAA,SAAS,oBAAoB;AAC7B,SAAS,SAAS;AAElB,SAAS,0BAA0B;AACnC,SAAS,8BAA8B;AAEvC,YAAY,gBAAgB;AAE5B,MAAM,2BAA2B,EAAE,OAAO;AAAA,EACxC,MAAM,EAAE,IAAI;AAAA,EACZ,QAAQ,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,KAAK;AAAA,EAC5C,YAAY,EAAE,OAAO,EAAE,SAAS;AAAA,EAChC,UAAU,EAAE,OAAO,EAAE,SAAS;AAAA,EAC9B,WAAW,EAAE,OAAO,EAAE,SAAS;AACjC,CAAC;AAED,MAAM,4BAA4B,EAAE,OAAO;AAAA,EACzC,SAAS,EAAE,QAAQ;AAAA,EACnB,QAAQ,EAAE,OAAO;AAAA,EACjB,UAAU,EAAE,OAAO;AAAA,EACnB,iBAAiB,E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AAK,UAAU,EAAE,OAAO,CAAC;AAAA,EAC/C,SAAS,OAAO;AACd,UAAM,eAAe,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;AAC1E,WAAO,aAAa;AAAA,MAClB,EAAE,OAAO,0BAA0B,YAAY,GAAG;AAAA,MAClD,EAAE,QAAQ,IAAI;AAAA,IAChB;AAAA,EACF;AACF;AAEO,MAAM,UAA2B;AAAA,EACtC,KAAK;AAAA,EACL,SAAS;AAAA,EACT,SAAS;AAAA,IACP,MAAM;AAAA,MACJ,SAAS;AAAA,MACT,aAAa;AAAA,MACb,YAAY
|
|
4
|
+
"sourcesContent": ["import { NextResponse } from 'next/server'\nimport { z } from 'zod'\nimport type { OpenApiRouteDoc } from '@open-mercato/shared/lib/openapi'\nimport { getAuthFromRequest } from '@open-mercato/shared/lib/auth/server'\nimport { createRequestContainer } from '@open-mercato/shared/lib/di/container'\nimport type { EntityManager } from '@mikro-orm/postgresql'\nimport * as ruleEngine from '../../../lib/rule-engine'\n\nconst executeByIdRequestSchema = z.object({\n data: z.any(),\n dryRun: z.boolean().optional().default(false),\n entityType: z.string().optional(),\n entityId: z.string().optional(),\n eventType: z.string().optional(),\n})\n\nconst executeByIdResponseSchema = z.object({\n success: z.boolean(),\n ruleId: z.string(),\n ruleName: z.string(),\n conditionResult: z.boolean(),\n actionsExecuted: z.object({\n success: z.boolean(),\n results: z.array(z.object({\n type: z.string(),\n success: z.boolean(),\n error: z.string().optional(),\n })),\n }).nullable(),\n executionTime: z.number(),\n error: z.string().optional(),\n logId: z.string().optional(),\n})\n\nconst errorResponseSchema = z.object({\n error: z.string(),\n})\n\nconst routeMetadata = {\n POST: { requireAuth: true, requireFeatures: ['business_rules.execute'] },\n}\n\nexport const metadata = routeMetadata\n\ninterface RouteContext {\n params: Promise<{ ruleId: string }>\n}\n\nexport async function POST(req: Request, context: RouteContext) {\n const auth = await getAuthFromRequest(req)\n if (!auth) {\n return NextResponse.json({ error: 'Unauthorized' }, { status: 401 })\n }\n\n const params = await context.params\n const ruleId = params.ruleId\n\n if (!ruleId || !z.uuid().safeParse(ruleId).success) {\n return NextResponse.json({ error: 'Invalid rule ID' }, { status: 400 })\n }\n\n const container = await createRequestContainer()\n const em = container.resolve('em') as EntityManager\n\n let body: any\n try {\n body = await req.json()\n } catch {\n return NextResponse.json({ error: 'Invalid JSON body' }, { status: 400 })\n }\n\n const parsed = executeByIdRequestSchema.safeParse(body)\n if (!parsed.success) {\n const errors = parsed.error.issues.map(e => `${e.path.join('.')}: ${e.message}`)\n return NextResponse.json({ error: `Validation failed: ${errors.join(', ')}` }, { status: 400 })\n }\n\n const { data, dryRun, entityType, entityId, eventType } = parsed.data\n\n const execContext: ruleEngine.DirectRuleExecutionContext = {\n ruleId,\n data,\n user: {\n id: auth.sub,\n email: auth.email,\n role: (auth.role as string) ?? undefined,\n },\n tenantId: auth.tenantId ?? '',\n organizationId: auth.orgId ?? '',\n executedBy: auth.sub ?? auth.email ?? undefined,\n dryRun,\n entityType,\n entityId,\n eventType,\n }\n\n try {\n const result = await ruleEngine.executeRuleById(em, execContext)\n\n const response = {\n success: result.success,\n ruleId: result.ruleId,\n ruleName: result.ruleName,\n conditionResult: result.conditionResult,\n actionsExecuted: result.actionsExecuted ? {\n success: result.actionsExecuted.success,\n results: result.actionsExecuted.results.map(ar => ({\n type: ar.action.type,\n success: ar.success,\n error: ar.error,\n })),\n } : null,\n executionTime: result.executionTime,\n error: result.error,\n logId: result.logId,\n }\n\n // Return appropriate status based on result\n const status = result.success ? 200 : (result.error === 'Rule not found' ? 404 : 200)\n return NextResponse.json(response, { status })\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : String(error)\n return NextResponse.json(\n { error: `Rule execution failed: ${errorMessage}` },\n { status: 500 }\n )\n }\n}\n\nexport const openApi: OpenApiRouteDoc = {\n tag: 'Business Rules',\n summary: 'Execute a specific business rule by ID',\n methods: {\n POST: {\n summary: 'Execute a specific rule by its database UUID',\n description: 'Directly executes a specific business rule identified by its UUID, bypassing the normal entityType/eventType discovery mechanism. Useful for workflows and targeted rule execution.',\n pathParams: z.object({\n ruleId: z.string().uuid().describe('The database UUID of the business rule to execute'),\n }),\n requestBody: {\n contentType: 'application/json',\n schema: executeByIdRequestSchema,\n },\n responses: [\n {\n status: 200,\n description: 'Rule executed successfully',\n schema: executeByIdResponseSchema,\n },\n {\n status: 404,\n description: 'Rule not found',\n schema: errorResponseSchema,\n },\n ],\n errors: [\n { status: 400, description: 'Invalid request payload or rule ID', schema: errorResponseSchema },\n { status: 401, description: 'Unauthorized', schema: errorResponseSchema },\n { status: 500, description: 'Execution error', schema: errorResponseSchema },\n ],\n },\n },\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,oBAAoB;AAC7B,SAAS,SAAS;AAElB,SAAS,0BAA0B;AACnC,SAAS,8BAA8B;AAEvC,YAAY,gBAAgB;AAE5B,MAAM,2BAA2B,EAAE,OAAO;AAAA,EACxC,MAAM,EAAE,IAAI;AAAA,EACZ,QAAQ,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,KAAK;AAAA,EAC5C,YAAY,EAAE,OAAO,EAAE,SAAS;AAAA,EAChC,UAAU,EAAE,OAAO,EAAE,SAAS;AAAA,EAC9B,WAAW,EAAE,OAAO,EAAE,SAAS;AACjC,CAAC;AAED,MAAM,4BAA4B,EAAE,OAAO;AAAA,EACzC,SAAS,EAAE,QAAQ;AAAA,EACnB,QAAQ,EAAE,OAAO;AAAA,EACjB,UAAU,EAAE,OAAO;AAAA,EACnB,iBAAiB,EAAE,QAAQ;AAAA,EAC3B,iBAAiB,EAAE,OAAO;AAAA,IACxB,SAAS,EAAE,QAAQ;AAAA,IACnB,SAAS,EAAE,MAAM,EAAE,OAAO;AAAA,MACxB,MAAM,EAAE,OAAO;AAAA,MACf,SAAS,EAAE,QAAQ;AAAA,MACnB,OAAO,EAAE,OAAO,EAAE,SAAS;AAAA,IAC7B,CAAC,CAAC;AAAA,EACJ,CAAC,EAAE,SAAS;AAAA,E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AS;AAAA,EACT,SAAS;AAAA,IACP,MAAM;AAAA,MACJ,SAAS;AAAA,MACT,aAAa;AAAA,MACb,YAAY,EAAE,OAAO;AAAA,QACnB,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS,mDAAmD;AAAA,MACxF,CAAC;AAAA,MACD,aAAa;AAAA,QACX,aAAa;AAAA,QACb,QAAQ;AAAA,MACV;AAAA,MACA,WAAW;AAAA,QACT;AAAA,UACE,QAAQ;AAAA,UACR,aAAa;AAAA,UACb,QAAQ;AAAA,QACV;AAAA,QACA;AAAA,UACE,QAAQ;AAAA,UACR,aAAa;AAAA,UACb,QAAQ;AAAA,QACV;AAAA,MACF;AAAA,MACA,QAAQ;AAAA,QACN,EAAE,QAAQ,KAAK,aAAa,sCAAsC,QAAQ,oBAAoB;AAAA,QAC9F,EAAE,QAAQ,KAAK,aAAa,gBAAgB,QAAQ,oBAAoB;AAAA,QACxE,EAAE,QAAQ,KAAK,aAAa,mBAAmB,QAAQ,oBAAoB;AAAA,MAC7E;AAAA,IACF;AAAA,EACF;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/modules/workflows/cli.ts"],
|
|
4
|
-
"sourcesContent": ["import type { ModuleCli } from '@open-mercato/shared/modules/registry'\nimport { createRequestContainer } from '@open-mercato/shared/lib/di/container'\nimport type { EntityManager } from '@mikro-orm/postgresql'\nimport { WorkflowDefinition } from './data/entities'\nimport { BusinessRule } from '@open-mercato/core/modules/business_rules/data/entities'\nimport * as fs from 'fs'\nimport * as path from 'path'\nimport { fileURLToPath } from 'url'\n\nconst __filename = fileURLToPath(import.meta.url)\nconst __dirname = path.dirname(__filename)\n\n/**\n * Parse CLI arguments\n */\nfunction parseArgs(args: string[]) {\n const result: Record<string, string> = {}\n for (let i = 0; i < args.length; i += 2) {\n const key = args[i]?.replace(/^-+/, '') // Remove one or more dashes\n const value = args[i + 1]\n if (key && value) {\n result[key] = value\n }\n }\n return result\n}\n\n/**\n * Seed demo checkout workflow\n */\nconst seedDemo: ModuleCli = {\n command: 'seed-demo',\n async run(rest: string[]) {\n const args = parseArgs(rest)\n const tenantId = String(args.tenantId ?? args.tenant ?? args.t ?? '')\n const organizationId = String(args.organizationId ?? args.orgId ?? args.org ?? args.o ?? '')\n\n if (!tenantId || !organizationId) {\n console.error('Usage: mercato workflows seed-demo --tenant <tenantId> --org <organizationId>')\n console.error(' or: mercato workflows seed-demo -t <tenantId> -o <organizationId>')\n return\n }\n\n try {\n const { resolve } = await createRequestContainer()\n const em = resolve<EntityManager>('em')\n\n // Read the demo workflow definition\n const demoPath = path.join(__dirname, 'examples', 'checkout-demo-definition.json')\n const demoData = JSON.parse(fs.readFileSync(demoPath, 'utf8'))\n\n // Check if it already exists\n const existing = await em.findOne(WorkflowDefinition, {\n workflowId: demoData.workflowId,\n tenantId,\n organizationId,\n })\n\n if (existing) {\n console.log(`\u2713 Demo workflow '${demoData.workflowId}' already exists (ID: ${existing.id})`)\n return\n }\n\n // Create the workflow definition\n const workflow = em.create(WorkflowDefinition, {\n ...demoData,\n tenantId,\n organizationId,\n })\n\n await em.persistAndFlush(workflow)\n\n console.log(`\u2713 Seeded demo workflow: ${workflow.workflowName}`)\n console.log(` - ID: ${workflow.id}`)\n console.log(` - Workflow ID: ${workflow.workflowId}`)\n console.log(` - Version: ${workflow.version}`)\n console.log(` - Steps: ${workflow.definition.steps.length}`)\n console.log(` - Transitions: ${workflow.definition.transitions.length}`)\n console.log('')\n console.log('Demo workflow is ready! You can now:')\n console.log(' 1. View it in admin: /backend/definitions')\n console.log(' 2. Try the demo page: /checkout-demo')\n console.log(' 3. Start an instance via API: POST /api/workflows/instances')\n console.log('')\n console.log('Note: This workflow includes a USER_TASK step for customer information.')\n console.log('When the workflow reaches this step, it will pause and require user input.')\n console.log('Complete pending tasks at: /backend/tasks')\n } catch (error) {\n console.error('Error seeding demo workflow:', error)\n throw error\n }\n },\n}\n\n/**\n * Seed demo checkout workflow with guard rules\n */\nconst seedDemoWithRules: ModuleCli = {\n command: 'seed-demo-with-rules',\n async run(rest: string[]) {\n const args = parseArgs(rest)\n const tenantId = String(args.tenantId ?? args.tenant ?? args.t ?? '')\n const organizationId = String(args.organizationId ?? args.orgId ?? args.org ?? args.o ?? '')\n\n if (!tenantId || !organizationId) {\n console.error('Usage: mercato workflows seed-demo-with-rules --tenant <tenantId> --org <organizationId>')\n console.error(' or: mercato workflows seed-demo-with-rules -t <tenantId> -o <organizationId>')\n return\n }\n\n console.log('Seeding demo workflow with guard rules...\\n')\n\n try {\n // Seed the workflow definition\n console.log('1. Seeding demo workflow...')\n await seedDemo.run(rest)\n\n // Seed the guard rules\n console.log('\\n2. Seeding guard rules...')\n const { resolve } = await createRequestContainer()\n const em = resolve<EntityManager>('em')\n\n // Import BusinessRule entity\n const { BusinessRule } = await import('../business_rules/data/entities')\n\n // Read guard rules\n const rulesPath = path.join(__dirname, 'examples', 'guard-rules-example.json')\n const rulesData = JSON.parse(fs.readFileSync(rulesPath, 'utf8'))\n\n let seededCount = 0\n let skippedCount = 0\n\n for (const ruleData of rulesData) {\n const existing = await em.findOne(BusinessRule, {\n ruleId: ruleData.ruleId,\n tenantId,\n organizationId,\n })\n\n if (existing) {\n console.log(` \u2298 Guard rule '${ruleData.ruleId}' already exists`)\n skippedCount++\n continue\n }\n\n const rule = em.create(BusinessRule, {\n ...ruleData,\n tenantId,\n organizationId,\n })\n\n await em.persistAndFlush(rule)\n console.log(` \u2713 Seeded guard rule: ${rule.ruleName}`)\n seededCount++\n }\n\n console.log(`\\n\u2713 Demo workflow with guard rules seeded successfully!`)\n console.log(` - Workflow: checkout_simple_v1`)\n console.log(` - Guard rules seeded: ${seededCount}`)\n console.log(` - Guard rules skipped: ${skippedCount}`)\n } catch (error) {\n console.error('Error seeding demo with rules:', error)\n throw error\n }\n },\n}\n\n/**\n * Seed sales pipeline example\n */\nconst seedSalesPipeline: ModuleCli = {\n command: 'seed-sales-pipeline',\n async run(rest: string[]) {\n const args = parseArgs(rest)\n const tenantId = String(args.tenantId ?? args.tenant ?? args.t ?? '')\n const organizationId = String(args.organizationId ?? args.orgId ?? args.org ?? args.o ?? '')\n\n if (!tenantId || !organizationId) {\n console.error('Usage: mercato workflows seed-sales-pipeline --tenant <tenantId> --org <organizationId>')\n return\n }\n\n try {\n const { resolve } = await createRequestContainer()\n const em = resolve<EntityManager>('em')\n\n // Read the sales pipeline workflow definition\n const pipelinePath = path.join(__dirname, 'examples', 'sales-pipeline-definition.json')\n const pipelineData = JSON.parse(fs.readFileSync(pipelinePath, 'utf8'))\n\n // Check if it already exists\n const existing = await em.findOne(WorkflowDefinition, {\n workflowId: pipelineData.workflowId,\n tenantId,\n organizationId,\n })\n\n if (existing) {\n console.log(`\u2713 Sales pipeline workflow '${pipelineData.workflowId}' already exists (ID: ${existing.id})`)\n return\n }\n\n // Create the workflow definition\n const workflow = em.create(WorkflowDefinition, {\n ...pipelineData,\n tenantId,\n organizationId,\n })\n\n await em.persistAndFlush(workflow)\n\n console.log(`\u2713 Seeded sales pipeline workflow: ${workflow.workflowName}`)\n console.log(` - ID: ${workflow.id}`)\n console.log(` - Workflow ID: ${workflow.workflowId}`)\n console.log(` - Version: ${workflow.version}`)\n console.log(` - Steps: ${workflow.definition.steps.length}`)\n console.log(` - Transitions: ${workflow.definition.transitions.length}`)\n console.log(` - Activities: ${workflow.definition.transitions.reduce((sum, t) => sum + (t.activities?.length || 0), 0)}`)\n console.log('')\n console.log('Sales pipeline workflow is ready!')\n } catch (error) {\n console.error('Error seeding sales pipeline workflow:', error)\n throw error\n }\n },\n}\n\n/**\n * Seed simple approval example\n */\nconst seedSimpleApproval: ModuleCli = {\n command: 'seed-simple-approval',\n async run(rest: string[]) {\n const args = parseArgs(rest)\n const tenantId = String(args.tenantId ?? args.tenant ?? args.t ?? '')\n const organizationId = String(args.organizationId ?? args.orgId ?? args.org ?? args.o ?? '')\n\n if (!tenantId || !organizationId) {\n console.error('Usage: mercato workflows seed-simple-approval --tenant <tenantId> --org <organizationId>')\n return\n }\n\n try {\n const { resolve } = await createRequestContainer()\n const em = resolve<EntityManager>('em')\n\n // Read the simple approval workflow definition\n const approvalPath = path.join(__dirname, 'examples', 'simple-approval-definition.json')\n const approvalData = JSON.parse(fs.readFileSync(approvalPath, 'utf8'))\n\n // Check if it already exists\n const existing = await em.findOne(WorkflowDefinition, {\n workflowId: approvalData.workflowId,\n tenantId,\n organizationId,\n })\n\n if (existing) {\n console.log(`\u2713 Simple approval workflow '${approvalData.workflowId}' already exists (ID: ${existing.id})`)\n return\n }\n\n // Create the workflow definition\n const workflow = em.create(WorkflowDefinition, {\n ...approvalData,\n tenantId,\n organizationId,\n })\n\n await em.persistAndFlush(workflow)\n\n console.log(`\u2713 Seeded simple approval workflow: ${workflow.workflowName}`)\n console.log(` - ID: ${workflow.id}`)\n console.log(` - Workflow ID: ${workflow.workflowId}`)\n console.log(` - Version: ${workflow.version}`)\n console.log(` - Steps: ${workflow.definition.steps.length}`)\n console.log(` - Transitions: ${workflow.definition.transitions.length}`)\n console.log('')\n console.log('Simple approval workflow is ready!')\n } catch (error) {\n console.error('Error seeding simple approval workflow:', error)\n throw error\n }\n },\n}\n\n/**\n * Seed order approval example\n */\nconst seedOrderApproval: ModuleCli = {\n command: 'seed-order-approval',\n async run(rest: string[]) {\n const args = parseArgs(rest)\n const tenantId = String(args.tenantId ?? args.tenant ?? args.t ?? '')\n const organizationId = String(args.organizationId ?? args.orgId ?? args.org ?? args.o ?? '')\n\n if (!tenantId || !organizationId) {\n console.error('Usage: mercato workflows seed-order-approval --tenant <tenantId> --org <organizationId>')\n return\n }\n\n try {\n const { resolve } = await createRequestContainer()\n const em = resolve<EntityManager>('em')\n\n // 1. Seed order approval guard rules first\n const guardRulesPath = path.join(__dirname, 'examples', 'order-approval-guard-rules.json')\n const guardRulesData = JSON.parse(fs.readFileSync(guardRulesPath, 'utf8')) as Array<{\n ruleId: string\n ruleName: string\n [key: string]: unknown\n }>\n\n let rulesSeeded = 0\n let rulesSkipped = 0\n for (const rule of guardRulesData) {\n const existingRule = await em.findOne(BusinessRule, {\n ruleId: rule.ruleId,\n tenantId,\n organizationId,\n })\n\n if (existingRule) {\n rulesSkipped++\n continue\n }\n\n const newRule = em.create(BusinessRule, {\n ...rule,\n tenantId,\n organizationId,\n })\n em.persist(newRule)\n console.log(` \u2713 Seeded guard rule: ${rule.ruleName}`)\n rulesSeeded++\n }\n\n if (rulesSeeded > 0) {\n await em.flush()\n }\n\n // 2. Read the order approval workflow definition\n const approvalPath = path.join(__dirname, 'examples', 'order-approval-definition.json')\n const approvalData = JSON.parse(fs.readFileSync(approvalPath, 'utf8'))\n\n // Check if it already exists\n const existing = await em.findOne(WorkflowDefinition, {\n workflowId: approvalData.workflowId,\n tenantId,\n organizationId,\n })\n\n if (existing) {\n console.log(`\u2713 Order approval workflow '${approvalData.workflowId}' already exists (ID: ${existing.id})`)\n console.log(` - Guard rules seeded: ${rulesSeeded}`)\n console.log(` - Guard rules skipped: ${rulesSkipped}`)\n return\n }\n\n // Create the workflow definition\n const workflow = em.create(WorkflowDefinition, {\n ...approvalData,\n tenantId,\n organizationId,\n })\n\n await em.persistAndFlush(workflow)\n\n console.log(`\u2713 Seeded order approval workflow: ${workflow.workflowName}`)\n console.log(` - ID: ${workflow.id}`)\n console.log(` - Workflow ID: ${workflow.workflowId}`)\n console.log(` - Version: ${workflow.version}`)\n console.log(` - Steps: ${workflow.definition.steps.length}`)\n console.log(` - Transitions: ${workflow.definition.transitions.length}`)\n console.log(` - Guard rules seeded: ${rulesSeeded}`)\n console.log(` - Guard rules skipped: ${rulesSkipped}`)\n console.log('')\n console.log('Order approval workflow is ready!')\n } catch (error) {\n console.error('Error seeding order approval workflow:', error)\n throw error\n }\n },\n}\n\n/**\n * Start workflow activity worker\n */\nconst startWorker: ModuleCli = {\n command: 'start-worker',\n async run(rest: string[]) {\n const args = parseArgs(rest)\n const concurrency = parseInt(args.concurrency ?? args.c ?? '5')\n\n const strategy = process.env.QUEUE_STRATEGY === 'async' ? 'async' : 'local'\n\n console.log('[Workflow Worker] Starting activity worker...')\n console.log(`[Workflow Worker] Strategy: ${strategy}`)\n\n if (strategy === 'local') {\n const pollMs = process.env.LOCAL_QUEUE_POLL_MS || '5000'\n console.log(`[Workflow Worker] Polling interval: ${pollMs}ms`)\n console.log('[Workflow Worker] NOTE: Local strategy is for development only.')\n console.log('[Workflow Worker] Use QUEUE_STRATEGY=async with Redis for production.')\n } else {\n console.log(`[Workflow Worker] Concurrency: ${concurrency}`)\n console.log(`[Workflow Worker] Redis: ${process.env.REDIS_URL || process.env.QUEUE_REDIS_URL}`)\n }\n\n try {\n const container = await createRequestContainer()\n const em = container.resolve<EntityManager>('em')\n\n // Import queue and handler\n const { runWorker } = await import('@open-mercato/queue/worker')\n const { createActivityWorkerHandler } = await import('./lib/activity-worker-handler')\n const { WORKFLOW_ACTIVITIES_QUEUE_NAME } = await import('./lib/activity-queue-types')\n\n // Create handler\n const handler = createActivityWorkerHandler(em, container)\n\n // Run worker\n await runWorker({\n queueName: WORKFLOW_ACTIVITIES_QUEUE_NAME,\n handler,\n connection: strategy === 'async' ? {\n url: process.env.REDIS_URL || process.env.QUEUE_REDIS_URL,\n } : undefined,\n concurrency,\n gracefulShutdown: true,\n })\n } catch (error) {\n console.error('[Workflow Worker] Failed to start worker:', error)\n throw error\n }\n },\n}\n\n/**\n * Seed all example workflows\n */\nconst seedAll: ModuleCli = {\n command: 'seed-all',\n async run(rest: string[]) {\n const args = parseArgs(rest)\n const tenantId = String(args.tenantId ?? args.tenant ?? args.t ?? '')\n const organizationId = String(args.organizationId ?? args.orgId ?? args.org ?? args.o ?? '')\n\n if (!tenantId || !organizationId) {\n console.error('Usage: mercato workflows seed-all --tenant <tenantId> --org <organizationId>')\n return\n }\n\n console.log('Seeding all example workflows...\\n')\n\n try {\n // Seed demo checkout with rules\n await seedDemoWithRules.run(rest)\n console.log('')\n\n // Seed sales pipeline\n await seedSalesPipeline.run(rest)\n console.log('')\n\n // Seed simple approval\n await seedSimpleApproval.run(rest)\n console.log('')\n\n // Seed order approval\n await seedOrderApproval.run(rest)\n console.log('')\n\n console.log('\u2713 All example workflows seeded successfully!')\n } catch (error) {\n console.error('Error seeding workflows:', error)\n throw error\n }\n },\n}\n\n/**\n * Manually process pending workflow activities\n */\nconst processActivities: ModuleCli = {\n command: 'process-activities',\n async run(rest: string[]) {\n const args = parseArgs(rest)\n const limit = parseInt(args.limit ?? args.l ?? '0')\n\n console.log('[Workflow Activities] Processing pending activities...')\n if (limit > 0) {\n console.log(`[Workflow Activities] Limit: ${limit} jobs`)\n }\n\n try {\n const container = await createRequestContainer()\n const em = container.resolve<EntityManager>('em')\n\n // Import queue and handler\n const { createQueue } = await import('@open-mercato/queue')\n const { createActivityWorkerHandler } = await import('./lib/activity-worker-handler')\n const { WORKFLOW_ACTIVITIES_QUEUE_NAME } = await import('./lib/activity-queue-types')\n\n // Create queue instance\n const queue = createQueue(WORKFLOW_ACTIVITIES_QUEUE_NAME, 'local', {\n baseDir: process.env.QUEUE_BASE_DIR || '.queue',\n })\n\n // Create handler\n const handler = createActivityWorkerHandler(em, container)\n\n // Get initial counts\n const initialCounts = await queue.getJobCounts()\n console.log(`[Workflow Activities] Pending jobs: ${initialCounts.waiting}`)\n\n if (initialCounts.waiting === 0) {\n console.log('[Workflow Activities] No jobs to process')\n await queue.close()\n return\n }\n\n // Process jobs\n const result = await queue.process(handler as any, limit > 0 ? { limit } : undefined)\n\n console.log(`\\n[Workflow Activities] \u2713 Processed ${result.processed} activities`)\n if (result.failed > 0) {\n console.log(`[Workflow Activities] \u2717 Failed: ${result.failed} activities`)\n }\n\n // Show remaining\n const finalCounts = await queue.getJobCounts()\n if (finalCounts.waiting > 0) {\n console.log(`[Workflow Activities] Remaining: ${finalCounts.waiting} jobs`)\n }\n\n await queue.close()\n } catch (error) {\n console.error('[Workflow Activities] Error processing activities:', error)\n throw error\n }\n },\n}\n\nconst workflowsCliCommands = [\n startWorker,\n processActivities,\n seedDemo,\n seedDemoWithRules,\n seedSalesPipeline,\n seedSimpleApproval,\n seedOrderApproval,\n seedAll,\n]\n\nexport default workflowsCliCommands\n"],
|
|
5
|
-
"mappings": "AACA,SAAS,8BAA8B;AAEvC,SAAS,0BAA0B;AACnC,SAAS,
|
|
4
|
+
"sourcesContent": ["import type { ModuleCli } from '@open-mercato/shared/modules/registry'\nimport { createRequestContainer } from '@open-mercato/shared/lib/di/container'\nimport type { EntityManager } from '@mikro-orm/postgresql'\nimport { WorkflowDefinition } from './data/entities'\nimport { BusinessRule, type RuleType } from '@open-mercato/core/modules/business_rules/data/entities'\nimport * as fs from 'fs'\nimport * as path from 'path'\nimport { fileURLToPath } from 'url'\n\nconst __filename = fileURLToPath(import.meta.url)\nconst __dirname = path.dirname(__filename)\n\n/**\n * Parse CLI arguments\n */\nfunction parseArgs(args: string[]) {\n const result: Record<string, string> = {}\n for (let i = 0; i < args.length; i += 2) {\n const key = args[i]?.replace(/^-+/, '') // Remove one or more dashes\n const value = args[i + 1]\n if (key && value) {\n result[key] = value\n }\n }\n return result\n}\n\n/**\n * Seed demo checkout workflow\n */\nconst seedDemo: ModuleCli = {\n command: 'seed-demo',\n async run(rest: string[]) {\n const args = parseArgs(rest)\n const tenantId = String(args.tenantId ?? args.tenant ?? args.t ?? '')\n const organizationId = String(args.organizationId ?? args.orgId ?? args.org ?? args.o ?? '')\n\n if (!tenantId || !organizationId) {\n console.error('Usage: mercato workflows seed-demo --tenant <tenantId> --org <organizationId>')\n console.error(' or: mercato workflows seed-demo -t <tenantId> -o <organizationId>')\n return\n }\n\n try {\n const { resolve } = await createRequestContainer()\n const em = resolve<EntityManager>('em')\n\n // Read the demo workflow definition\n const demoPath = path.join(__dirname, 'examples', 'checkout-demo-definition.json')\n const demoData = JSON.parse(fs.readFileSync(demoPath, 'utf8'))\n\n // Check if it already exists\n const existing = await em.findOne(WorkflowDefinition, {\n workflowId: demoData.workflowId,\n tenantId,\n organizationId,\n })\n\n if (existing) {\n console.log(`\u2713 Demo workflow '${demoData.workflowId}' already exists (ID: ${existing.id})`)\n return\n }\n\n // Create the workflow definition\n const workflow = em.create(WorkflowDefinition, {\n ...demoData,\n tenantId,\n organizationId,\n })\n\n await em.persistAndFlush(workflow)\n\n console.log(`\u2713 Seeded demo workflow: ${workflow.workflowName}`)\n console.log(` - ID: ${workflow.id}`)\n console.log(` - Workflow ID: ${workflow.workflowId}`)\n console.log(` - Version: ${workflow.version}`)\n console.log(` - Steps: ${workflow.definition.steps.length}`)\n console.log(` - Transitions: ${workflow.definition.transitions.length}`)\n console.log('')\n console.log('Demo workflow is ready! You can now:')\n console.log(' 1. View it in admin: /backend/definitions')\n console.log(' 2. Try the demo page: /checkout-demo')\n console.log(' 3. Start an instance via API: POST /api/workflows/instances')\n console.log('')\n console.log('Note: This workflow includes a USER_TASK step for customer information.')\n console.log('When the workflow reaches this step, it will pause and require user input.')\n console.log('Complete pending tasks at: /backend/tasks')\n } catch (error) {\n console.error('Error seeding demo workflow:', error)\n throw error\n }\n },\n}\n\n/**\n * Seed demo checkout workflow with guard rules\n */\nconst seedDemoWithRules: ModuleCli = {\n command: 'seed-demo-with-rules',\n async run(rest: string[]) {\n const args = parseArgs(rest)\n const tenantId = String(args.tenantId ?? args.tenant ?? args.t ?? '')\n const organizationId = String(args.organizationId ?? args.orgId ?? args.org ?? args.o ?? '')\n\n if (!tenantId || !organizationId) {\n console.error('Usage: mercato workflows seed-demo-with-rules --tenant <tenantId> --org <organizationId>')\n console.error(' or: mercato workflows seed-demo-with-rules -t <tenantId> -o <organizationId>')\n return\n }\n\n console.log('Seeding demo workflow with guard rules...\\n')\n\n try {\n // Seed the workflow definition\n console.log('1. Seeding demo workflow...')\n await seedDemo.run(rest)\n\n // Seed the guard rules\n console.log('\\n2. Seeding guard rules...')\n const { resolve } = await createRequestContainer()\n const em = resolve<EntityManager>('em')\n\n // Import BusinessRule entity\n const { BusinessRule } = await import('../business_rules/data/entities')\n\n // Read guard rules\n const rulesPath = path.join(__dirname, 'examples', 'guard-rules-example.json')\n const rulesData = JSON.parse(fs.readFileSync(rulesPath, 'utf8'))\n\n let seededCount = 0\n let skippedCount = 0\n\n for (const ruleData of rulesData) {\n const existing = await em.findOne(BusinessRule, {\n ruleId: ruleData.ruleId,\n tenantId,\n organizationId,\n })\n\n if (existing) {\n console.log(` \u2298 Guard rule '${ruleData.ruleId}' already exists`)\n skippedCount++\n continue\n }\n\n const rule = em.create(BusinessRule, {\n ...ruleData,\n tenantId,\n organizationId,\n })\n\n await em.persistAndFlush(rule)\n console.log(` \u2713 Seeded guard rule: ${rule.ruleName}`)\n seededCount++\n }\n\n console.log(`\\n\u2713 Demo workflow with guard rules seeded successfully!`)\n console.log(` - Workflow: checkout_simple_v1`)\n console.log(` - Guard rules seeded: ${seededCount}`)\n console.log(` - Guard rules skipped: ${skippedCount}`)\n } catch (error) {\n console.error('Error seeding demo with rules:', error)\n throw error\n }\n },\n}\n\n/**\n * Seed sales pipeline example\n */\nconst seedSalesPipeline: ModuleCli = {\n command: 'seed-sales-pipeline',\n async run(rest: string[]) {\n const args = parseArgs(rest)\n const tenantId = String(args.tenantId ?? args.tenant ?? args.t ?? '')\n const organizationId = String(args.organizationId ?? args.orgId ?? args.org ?? args.o ?? '')\n\n if (!tenantId || !organizationId) {\n console.error('Usage: mercato workflows seed-sales-pipeline --tenant <tenantId> --org <organizationId>')\n return\n }\n\n try {\n const { resolve } = await createRequestContainer()\n const em = resolve<EntityManager>('em')\n\n // Read the sales pipeline workflow definition\n const pipelinePath = path.join(__dirname, 'examples', 'sales-pipeline-definition.json')\n const pipelineData = JSON.parse(fs.readFileSync(pipelinePath, 'utf8'))\n\n // Check if it already exists\n const existing = await em.findOne(WorkflowDefinition, {\n workflowId: pipelineData.workflowId,\n tenantId,\n organizationId,\n })\n\n if (existing) {\n console.log(`\u2713 Sales pipeline workflow '${pipelineData.workflowId}' already exists (ID: ${existing.id})`)\n return\n }\n\n // Create the workflow definition\n const workflow = em.create(WorkflowDefinition, {\n ...pipelineData,\n tenantId,\n organizationId,\n })\n\n await em.persistAndFlush(workflow)\n\n console.log(`\u2713 Seeded sales pipeline workflow: ${workflow.workflowName}`)\n console.log(` - ID: ${workflow.id}`)\n console.log(` - Workflow ID: ${workflow.workflowId}`)\n console.log(` - Version: ${workflow.version}`)\n console.log(` - Steps: ${workflow.definition.steps.length}`)\n console.log(` - Transitions: ${workflow.definition.transitions.length}`)\n console.log(` - Activities: ${workflow.definition.transitions.reduce((sum, t) => sum + (t.activities?.length || 0), 0)}`)\n console.log('')\n console.log('Sales pipeline workflow is ready!')\n } catch (error) {\n console.error('Error seeding sales pipeline workflow:', error)\n throw error\n }\n },\n}\n\n/**\n * Seed simple approval example\n */\nconst seedSimpleApproval: ModuleCli = {\n command: 'seed-simple-approval',\n async run(rest: string[]) {\n const args = parseArgs(rest)\n const tenantId = String(args.tenantId ?? args.tenant ?? args.t ?? '')\n const organizationId = String(args.organizationId ?? args.orgId ?? args.org ?? args.o ?? '')\n\n if (!tenantId || !organizationId) {\n console.error('Usage: mercato workflows seed-simple-approval --tenant <tenantId> --org <organizationId>')\n return\n }\n\n try {\n const { resolve } = await createRequestContainer()\n const em = resolve<EntityManager>('em')\n\n // Read the simple approval workflow definition\n const approvalPath = path.join(__dirname, 'examples', 'simple-approval-definition.json')\n const approvalData = JSON.parse(fs.readFileSync(approvalPath, 'utf8'))\n\n // Check if it already exists\n const existing = await em.findOne(WorkflowDefinition, {\n workflowId: approvalData.workflowId,\n tenantId,\n organizationId,\n })\n\n if (existing) {\n console.log(`\u2713 Simple approval workflow '${approvalData.workflowId}' already exists (ID: ${existing.id})`)\n return\n }\n\n // Create the workflow definition\n const workflow = em.create(WorkflowDefinition, {\n ...approvalData,\n tenantId,\n organizationId,\n })\n\n await em.persistAndFlush(workflow)\n\n console.log(`\u2713 Seeded simple approval workflow: ${workflow.workflowName}`)\n console.log(` - ID: ${workflow.id}`)\n console.log(` - Workflow ID: ${workflow.workflowId}`)\n console.log(` - Version: ${workflow.version}`)\n console.log(` - Steps: ${workflow.definition.steps.length}`)\n console.log(` - Transitions: ${workflow.definition.transitions.length}`)\n console.log('')\n console.log('Simple approval workflow is ready!')\n } catch (error) {\n console.error('Error seeding simple approval workflow:', error)\n throw error\n }\n },\n}\n\n/**\n * Seed order approval example\n */\nconst seedOrderApproval: ModuleCli = {\n command: 'seed-order-approval',\n async run(rest: string[]) {\n const args = parseArgs(rest)\n const tenantId = String(args.tenantId ?? args.tenant ?? args.t ?? '')\n const organizationId = String(args.organizationId ?? args.orgId ?? args.org ?? args.o ?? '')\n\n if (!tenantId || !organizationId) {\n console.error('Usage: mercato workflows seed-order-approval --tenant <tenantId> --org <organizationId>')\n return\n }\n\n try {\n const { resolve } = await createRequestContainer()\n const em = resolve<EntityManager>('em')\n\n // 1. Seed order approval guard rules first\n const guardRulesPath = path.join(__dirname, 'examples', 'order-approval-guard-rules.json')\n const guardRulesData = JSON.parse(fs.readFileSync(guardRulesPath, 'utf8')) as Array<{\n ruleId: string\n ruleName: string\n ruleType: RuleType\n entityType: string\n description?: string\n eventType?: string\n conditionExpression?: Record<string, unknown>\n enabled?: boolean\n priority?: number\n }>\n\n let rulesSeeded = 0\n let rulesSkipped = 0\n for (const rule of guardRulesData) {\n const existingRule = await em.findOne(BusinessRule, {\n ruleId: rule.ruleId,\n tenantId,\n organizationId,\n })\n\n if (existingRule) {\n rulesSkipped++\n continue\n }\n\n const newRule = em.create(BusinessRule, {\n ...rule,\n tenantId,\n organizationId,\n })\n em.persist(newRule)\n console.log(` \u2713 Seeded guard rule: ${rule.ruleName}`)\n rulesSeeded++\n }\n\n if (rulesSeeded > 0) {\n await em.flush()\n }\n\n // 2. Read the order approval workflow definition\n const approvalPath = path.join(__dirname, 'examples', 'order-approval-definition.json')\n const approvalData = JSON.parse(fs.readFileSync(approvalPath, 'utf8'))\n\n // Check if it already exists\n const existing = await em.findOne(WorkflowDefinition, {\n workflowId: approvalData.workflowId,\n tenantId,\n organizationId,\n })\n\n if (existing) {\n console.log(`\u2713 Order approval workflow '${approvalData.workflowId}' already exists (ID: ${existing.id})`)\n console.log(` - Guard rules seeded: ${rulesSeeded}`)\n console.log(` - Guard rules skipped: ${rulesSkipped}`)\n return\n }\n\n // Create the workflow definition\n const workflow = em.create(WorkflowDefinition, {\n ...approvalData,\n tenantId,\n organizationId,\n })\n\n await em.persistAndFlush(workflow)\n\n console.log(`\u2713 Seeded order approval workflow: ${workflow.workflowName}`)\n console.log(` - ID: ${workflow.id}`)\n console.log(` - Workflow ID: ${workflow.workflowId}`)\n console.log(` - Version: ${workflow.version}`)\n console.log(` - Steps: ${workflow.definition.steps.length}`)\n console.log(` - Transitions: ${workflow.definition.transitions.length}`)\n console.log(` - Guard rules seeded: ${rulesSeeded}`)\n console.log(` - Guard rules skipped: ${rulesSkipped}`)\n console.log('')\n console.log('Order approval workflow is ready!')\n } catch (error) {\n console.error('Error seeding order approval workflow:', error)\n throw error\n }\n },\n}\n\n/**\n * Start workflow activity worker\n */\nconst startWorker: ModuleCli = {\n command: 'start-worker',\n async run(rest: string[]) {\n const args = parseArgs(rest)\n const concurrency = parseInt(args.concurrency ?? args.c ?? '5')\n\n const strategy = process.env.QUEUE_STRATEGY === 'async' ? 'async' : 'local'\n\n console.log('[Workflow Worker] Starting activity worker...')\n console.log(`[Workflow Worker] Strategy: ${strategy}`)\n\n if (strategy === 'local') {\n const pollMs = process.env.LOCAL_QUEUE_POLL_MS || '5000'\n console.log(`[Workflow Worker] Polling interval: ${pollMs}ms`)\n console.log('[Workflow Worker] NOTE: Local strategy is for development only.')\n console.log('[Workflow Worker] Use QUEUE_STRATEGY=async with Redis for production.')\n } else {\n console.log(`[Workflow Worker] Concurrency: ${concurrency}`)\n console.log(`[Workflow Worker] Redis: ${process.env.REDIS_URL || process.env.QUEUE_REDIS_URL}`)\n }\n\n try {\n const container = await createRequestContainer()\n const em = container.resolve<EntityManager>('em')\n\n // Import queue and handler\n const { runWorker } = await import('@open-mercato/queue/worker')\n const { createActivityWorkerHandler } = await import('./lib/activity-worker-handler')\n const { WORKFLOW_ACTIVITIES_QUEUE_NAME } = await import('./lib/activity-queue-types')\n\n // Create handler\n const handler = createActivityWorkerHandler(em, container)\n\n // Run worker\n await runWorker({\n queueName: WORKFLOW_ACTIVITIES_QUEUE_NAME,\n handler,\n connection: strategy === 'async' ? {\n url: process.env.REDIS_URL || process.env.QUEUE_REDIS_URL,\n } : undefined,\n concurrency,\n gracefulShutdown: true,\n })\n } catch (error) {\n console.error('[Workflow Worker] Failed to start worker:', error)\n throw error\n }\n },\n}\n\n/**\n * Seed all example workflows\n */\nconst seedAll: ModuleCli = {\n command: 'seed-all',\n async run(rest: string[]) {\n const args = parseArgs(rest)\n const tenantId = String(args.tenantId ?? args.tenant ?? args.t ?? '')\n const organizationId = String(args.organizationId ?? args.orgId ?? args.org ?? args.o ?? '')\n\n if (!tenantId || !organizationId) {\n console.error('Usage: mercato workflows seed-all --tenant <tenantId> --org <organizationId>')\n return\n }\n\n console.log('Seeding all example workflows...\\n')\n\n try {\n // Seed demo checkout with rules\n await seedDemoWithRules.run(rest)\n console.log('')\n\n // Seed sales pipeline\n await seedSalesPipeline.run(rest)\n console.log('')\n\n // Seed simple approval\n await seedSimpleApproval.run(rest)\n console.log('')\n\n // Seed order approval\n await seedOrderApproval.run(rest)\n console.log('')\n\n console.log('\u2713 All example workflows seeded successfully!')\n } catch (error) {\n console.error('Error seeding workflows:', error)\n throw error\n }\n },\n}\n\n/**\n * Manually process pending workflow activities\n */\nconst processActivities: ModuleCli = {\n command: 'process-activities',\n async run(rest: string[]) {\n const args = parseArgs(rest)\n const limit = parseInt(args.limit ?? args.l ?? '0')\n\n console.log('[Workflow Activities] Processing pending activities...')\n if (limit > 0) {\n console.log(`[Workflow Activities] Limit: ${limit} jobs`)\n }\n\n try {\n const container = await createRequestContainer()\n const em = container.resolve<EntityManager>('em')\n\n // Import queue and handler\n const { createQueue } = await import('@open-mercato/queue')\n const { createActivityWorkerHandler } = await import('./lib/activity-worker-handler')\n const { WORKFLOW_ACTIVITIES_QUEUE_NAME } = await import('./lib/activity-queue-types')\n\n // Create queue instance\n const queue = createQueue(WORKFLOW_ACTIVITIES_QUEUE_NAME, 'local', {\n baseDir: process.env.QUEUE_BASE_DIR || '.queue',\n })\n\n // Create handler\n const handler = createActivityWorkerHandler(em, container)\n\n // Get initial counts\n const initialCounts = await queue.getJobCounts()\n console.log(`[Workflow Activities] Pending jobs: ${initialCounts.waiting}`)\n\n if (initialCounts.waiting === 0) {\n console.log('[Workflow Activities] No jobs to process')\n await queue.close()\n return\n }\n\n // Process jobs\n const result = await queue.process(handler as any, limit > 0 ? { limit } : undefined)\n\n console.log(`\\n[Workflow Activities] \u2713 Processed ${result.processed} activities`)\n if (result.failed > 0) {\n console.log(`[Workflow Activities] \u2717 Failed: ${result.failed} activities`)\n }\n\n // Show remaining\n const finalCounts = await queue.getJobCounts()\n if (finalCounts.waiting > 0) {\n console.log(`[Workflow Activities] Remaining: ${finalCounts.waiting} jobs`)\n }\n\n await queue.close()\n } catch (error) {\n console.error('[Workflow Activities] Error processing activities:', error)\n throw error\n }\n },\n}\n\nconst workflowsCliCommands = [\n startWorker,\n processActivities,\n seedDemo,\n seedDemoWithRules,\n seedSalesPipeline,\n seedSimpleApproval,\n seedOrderApproval,\n seedAll,\n]\n\nexport default workflowsCliCommands\n"],
|
|
5
|
+
"mappings": "AACA,SAAS,8BAA8B;AAEvC,SAAS,0BAA0B;AACnC,SAAS,oBAAmC;AAC5C,YAAY,QAAQ;AACpB,YAAY,UAAU;AACtB,SAAS,qBAAqB;AAE9B,MAAM,aAAa,cAAc,YAAY,GAAG;AAChD,MAAM,YAAY,KAAK,QAAQ,UAAU;AAKzC,SAAS,UAAU,MAAgB;AACjC,QAAM,SAAiC,CAAC;AACxC,WAAS,IAAI,GAAG,IAAI,KAAK,QAAQ,KAAK,GAAG;AACvC,UAAM,MAAM,KAAK,C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IACR;AAAA,EACF;AACF;AAEA,MAAM,uBAAuB;AAAA,EAC3B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAEA,IAAO,cAAQ;",
|
|
6
6
|
"names": ["BusinessRule"]
|
|
7
7
|
}
|
|
@@ -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 { Entity, PrimaryKey, Property, Index, Unique, OptionalProps } from '@mikro-orm/core'\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\nexport type WorkflowInstanceStatus =\n | 'RUNNING'\n | 'PAUSED'\n | 'COMPLETED'\n | 'FAILED'\n | 'CANCELLED'\n | 'COMPENSATING'\n | 'COMPENSATED'\n | 'WAITING_FOR_ACTIVITIES'\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// 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}\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 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 activities?: any[] // ActivityDefinition[] - will define schema in validators.ts\n queries?: any[]\n signals?: any[]\n timers?: any[]\n}\n\nexport interface WorkflowMetadata {\n tags?: string[]\n category?: string\n icon?: string\n}\n\nexport interface WorkflowInstanceMetadata {\n entityType?: string\n entityId?: string\n initiatedBy?: string\n labels?: Record<string, string>\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@Unique({ properties: ['workflowId', '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'] })\nexport class WorkflowDefinition {\n [OptionalProps]?: 'enabled' | 'version' | 'createdAt' | 'updatedAt' | 'deletedAt'\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: '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 @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 @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: 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' | '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 @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 @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 @Property({ name: 'deleted_at', type: Date, nullable: true })\n deletedAt?: Date | null\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 @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'] })\nexport class UserTask {\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: 'step_instance_id', type: 'uuid' })\n stepInstanceId!: string\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 @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 @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 @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// Export all entities as default for MikroORM discovery\nexport default [\n WorkflowDefinition,\n WorkflowInstance,\n StepInstance,\n UserTask,\n WorkflowEvent,\n WorkflowEventTrigger,\n]\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;AAMA,SAAS,QAAQ,YAAY,UAAU,OAAO,QAAQ,qBAAqB;AA6IxE;AADI,IAAM,qBAAN,MAAyB;AAAA,EAAzB;AAgBL,mBAAkB;AASlB,mBAAmB;AAqBnB,qBAAkB,oBAAI,KAAK;AAG3B,qBAAkB,oBAAI,KAAK;AAAA;AAI7B;AAjDE;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,iBAAiB,MAAM,WAAW,QAAQ,IAAI,CAAC;AAAA,GATtD,mBAUX;AAGA;AAAA,EADC,SAAS,EAAE,MAAM,eAAe,MAAM,QAAQ,UAAU,KAAK,CAAC;AAAA,GAZpD,mBAaX;AAGA;AAAA,EADC,SAAS,EAAE,MAAM,WAAW,MAAM,WAAW,SAAS,EAAE,CAAC;AAAA,GAf/C,mBAgBX;AAGA;AAAA,EADC,SAAS,EAAE,MAAM,cAAc,MAAM,QAAQ,CAAC;AAAA,GAlBpC,mBAmBX;AAGA;AAAA,EADC,SAAS,EAAE,MAAM,YAAY,MAAM,SAAS,UAAU,KAAK,CAAC;AAAA,GArBlD,mBAsBX;AAGA;AAAA,EADC,SAAS,EAAE,MAAM,WAAW,MAAM,WAAW,SAAS,KAAK,CAAC;AAAA,GAxBlD,mBAyBX;AAGA;AAAA,EADC,SAAS,EAAE,MAAM,kBAAkB,MAAM,MAAM,UAAU,KAAK,CAAC;AAAA,GA3BrD,mBA4BX;AAGA;AAAA,EADC,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AAAA,EALN,OAAO,EAAE,WAAW,0BAA0B,CAAC;AAAA,EAC/C,MAAM,EAAE,MAAM,6CAA6C,YAAY,CAAC,gBAAgB,SAAS,EAAE,CAAC;AAAA,EACpG,MAAM,EAAE,MAAM,0CAA0C,YAAY,CAAC,sBAAsB,EAAE,CAAC;AAAA,EAC9F,MAAM,EAAE,MAAM,0CAA0C,YAAY,CAAC,YAAY,gBAAgB,EAAE,CAAC;AAAA,EACpG,MAAM,EAAE,MAAM,gDAAgD,YAAY,CAAC,WAAW,UAAU,EAAE,CAAC;AAAA,GACvF;AAkDb,IAAO,mBAAQ;AAAA,EACb;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 { Entity, PrimaryKey, Property, Index, Unique, OptionalProps } from '@mikro-orm/core'\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\nexport type WorkflowInstanceStatus =\n | 'RUNNING'\n | 'PAUSED'\n | 'COMPLETED'\n | 'FAILED'\n | 'CANCELLED'\n | 'COMPENSATING'\n | 'COMPENSATED'\n | 'WAITING_FOR_ACTIVITIES'\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// 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 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 activities?: any[] // ActivityDefinition[] - will define schema in validators.ts\n queries?: any[]\n signals?: any[]\n timers?: any[]\n}\n\nexport interface WorkflowMetadata {\n tags?: string[]\n category?: string\n icon?: string\n}\n\nexport interface WorkflowInstanceMetadata {\n entityType?: string\n entityId?: string\n initiatedBy?: string\n labels?: Record<string, string>\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@Unique({ properties: ['workflowId', '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'] })\nexport class WorkflowDefinition {\n [OptionalProps]?: 'enabled' | 'version' | 'createdAt' | 'updatedAt' | 'deletedAt'\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: '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 @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 @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: 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' | '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 @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 @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 @Property({ name: 'deleted_at', type: Date, nullable: true })\n deletedAt?: Date | null\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 @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'] })\nexport class UserTask {\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: 'step_instance_id', type: 'uuid' })\n stepInstanceId!: string\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 @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 @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 @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// Export all entities as default for MikroORM discovery\nexport default [\n WorkflowDefinition,\n WorkflowInstance,\n StepInstance,\n UserTask,\n WorkflowEvent,\n WorkflowEventTrigger,\n]\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;AAMA,SAAS,QAAQ,YAAY,UAAU,OAAO,QAAQ,qBAAqB;AA8IxE;AADI,IAAM,qBAAN,MAAyB;AAAA,EAAzB;AAgBL,mBAAkB;AASlB,mBAAmB;AAqBnB,qBAAkB,oBAAI,KAAK;AAG3B,qBAAkB,oBAAI,KAAK;AAAA;AAI7B;AAjDE;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,iBAAiB,MAAM,WAAW,QAAQ,IAAI,CAAC;AAAA,GATtD,mBAUX;AAGA;AAAA,EADC,SAAS,EAAE,MAAM,eAAe,MAAM,QAAQ,UAAU,KAAK,CAAC;AAAA,GAZpD,mBAaX;AAGA;AAAA,EADC,SAAS,EAAE,MAAM,WAAW,MAAM,WAAW,SAAS,EAAE,CAAC;AAAA,GAf/C,mBAgBX;AAGA;AAAA,EADC,SAAS,EAAE,MAAM,cAAc,MAAM,QAAQ,CAAC;AAAA,GAlBpC,mBAmBX;AAGA;AAAA,EADC,SAAS,EAAE,MAAM,YAAY,MAAM,SAAS,UAAU,KAAK,CAAC;AAAA,GArBlD,mBAsBX;AAGA;AAAA,EADC,SA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,cAAc,MAAM,MAAM,UAAU,MAAM,oBAAI,KAAK,EAAE,CAAC;AAAA,GA1C7D,qBA2CX;AAGA;AAAA,EADC,SAAS,EAAE,MAAM,cAAc,MAAM,MAAM,UAAU,KAAK,CAAC;AAAA,GA7CjD,qBA8CX;AA9CW,uBAAN;AAAA,EALN,OAAO,EAAE,WAAW,0BAA0B,CAAC;AAAA,EAC/C,MAAM,EAAE,MAAM,6CAA6C,YAAY,CAAC,gBAAgB,SAAS,EAAE,CAAC;AAAA,EACpG,MAAM,EAAE,MAAM,0CAA0C,YAAY,CAAC,sBAAsB,EAAE,CAAC;AAAA,EAC9F,MAAM,EAAE,MAAM,0CAA0C,YAAY,CAAC,YAAY,gBAAgB,EAAE,CAAC;AAAA,EACpG,MAAM,EAAE,MAAM,gDAAgD,YAAY,CAAC,WAAW,UAAU,EAAE,CAAC;AAAA,GACvF;AAkDb,IAAO,mBAAQ;AAAA,EACb;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@open-mercato/core",
|
|
3
|
-
"version": "0.4.2-canary-
|
|
3
|
+
"version": "0.4.2-canary-ec4978dbb3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -207,7 +207,7 @@
|
|
|
207
207
|
}
|
|
208
208
|
},
|
|
209
209
|
"dependencies": {
|
|
210
|
-
"@open-mercato/shared": "0.4.2-canary-
|
|
210
|
+
"@open-mercato/shared": "0.4.2-canary-ec4978dbb3",
|
|
211
211
|
"@xyflow/react": "^12.6.0",
|
|
212
212
|
"date-fns": "^4.1.0",
|
|
213
213
|
"date-fns-tz": "^3.2.0"
|
|
@@ -134,14 +134,9 @@ export const openApi: OpenApiRouteDoc = {
|
|
|
134
134
|
POST: {
|
|
135
135
|
summary: 'Execute a specific rule by its database UUID',
|
|
136
136
|
description: 'Directly executes a specific business rule identified by its UUID, bypassing the normal entityType/eventType discovery mechanism. Useful for workflows and targeted rule execution.',
|
|
137
|
-
pathParams:
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
description: 'The database UUID of the business rule to execute',
|
|
141
|
-
required: true,
|
|
142
|
-
schema: z.uuid(),
|
|
143
|
-
},
|
|
144
|
-
],
|
|
137
|
+
pathParams: z.object({
|
|
138
|
+
ruleId: z.string().uuid().describe('The database UUID of the business rule to execute'),
|
|
139
|
+
}),
|
|
145
140
|
requestBody: {
|
|
146
141
|
contentType: 'application/json',
|
|
147
142
|
schema: executeByIdRequestSchema,
|
|
@@ -2,7 +2,7 @@ import type { ModuleCli } from '@open-mercato/shared/modules/registry'
|
|
|
2
2
|
import { createRequestContainer } from '@open-mercato/shared/lib/di/container'
|
|
3
3
|
import type { EntityManager } from '@mikro-orm/postgresql'
|
|
4
4
|
import { WorkflowDefinition } from './data/entities'
|
|
5
|
-
import { BusinessRule } from '@open-mercato/core/modules/business_rules/data/entities'
|
|
5
|
+
import { BusinessRule, type RuleType } from '@open-mercato/core/modules/business_rules/data/entities'
|
|
6
6
|
import * as fs from 'fs'
|
|
7
7
|
import * as path from 'path'
|
|
8
8
|
import { fileURLToPath } from 'url'
|
|
@@ -308,7 +308,13 @@ const seedOrderApproval: ModuleCli = {
|
|
|
308
308
|
const guardRulesData = JSON.parse(fs.readFileSync(guardRulesPath, 'utf8')) as Array<{
|
|
309
309
|
ruleId: string
|
|
310
310
|
ruleName: string
|
|
311
|
-
|
|
311
|
+
ruleType: RuleType
|
|
312
|
+
entityType: string
|
|
313
|
+
description?: string
|
|
314
|
+
eventType?: string
|
|
315
|
+
conditionExpression?: Record<string, unknown>
|
|
316
|
+
enabled?: boolean
|
|
317
|
+
priority?: number
|
|
312
318
|
}>
|
|
313
319
|
|
|
314
320
|
let rulesSeeded = 0
|
|
@@ -83,6 +83,7 @@ export interface WorkflowEventTriggerConfig {
|
|
|
83
83
|
contextMapping?: TriggerContextMapping[]
|
|
84
84
|
debounceMs?: number // Debounce rapid events
|
|
85
85
|
maxConcurrentInstances?: number // Limit concurrent instances
|
|
86
|
+
entityType?: string // Entity type for workflow instance metadata (e.g., "SalesOrder")
|
|
86
87
|
}
|
|
87
88
|
|
|
88
89
|
/**
|