@open-mercato/core 0.4.2-canary-15e78de280 → 0.4.2-canary-f075c3eb92

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.
Files changed (87) hide show
  1. package/dist/modules/api_keys/setup.js +11 -0
  2. package/dist/modules/api_keys/setup.js.map +7 -0
  3. package/dist/modules/attachments/components/AttachmentLibrary.js +1 -1
  4. package/dist/modules/attachments/components/AttachmentLibrary.js.map +2 -2
  5. package/dist/modules/attachments/lib/assignmentDetails.js +31 -17
  6. package/dist/modules/attachments/lib/assignmentDetails.js.map +2 -2
  7. package/dist/modules/attachments/lib/partitions.js +3 -3
  8. package/dist/modules/attachments/lib/partitions.js.map +2 -2
  9. package/dist/modules/attachments/setup.js +11 -0
  10. package/dist/modules/attachments/setup.js.map +7 -0
  11. package/dist/modules/audit_logs/setup.js +12 -0
  12. package/dist/modules/audit_logs/setup.js.map +7 -0
  13. package/dist/modules/auth/lib/setup-app.js +29 -159
  14. package/dist/modules/auth/lib/setup-app.js.map +2 -2
  15. package/dist/modules/auth/setup.js +11 -0
  16. package/dist/modules/auth/setup.js.map +7 -0
  17. package/dist/modules/business_rules/setup.js +11 -0
  18. package/dist/modules/business_rules/setup.js.map +7 -0
  19. package/dist/modules/catalog/setup.js +22 -0
  20. package/dist/modules/catalog/setup.js.map +7 -0
  21. package/dist/modules/configs/lib/upgrade-actions.js +65 -15
  22. package/dist/modules/configs/lib/upgrade-actions.js.map +2 -2
  23. package/dist/modules/configs/setup.js +16 -0
  24. package/dist/modules/configs/setup.js.map +7 -0
  25. package/dist/modules/currencies/setup.js +16 -0
  26. package/dist/modules/currencies/setup.js.map +7 -0
  27. package/dist/modules/customers/setup.js +36 -0
  28. package/dist/modules/customers/setup.js.map +7 -0
  29. package/dist/modules/dashboards/setup.js +12 -0
  30. package/dist/modules/dashboards/setup.js.map +7 -0
  31. package/dist/modules/dictionaries/setup.js +12 -0
  32. package/dist/modules/dictionaries/setup.js.map +7 -0
  33. package/dist/modules/directory/setup.js +12 -0
  34. package/dist/modules/directory/setup.js.map +7 -0
  35. package/dist/modules/entities/setup.js +11 -0
  36. package/dist/modules/entities/setup.js.map +7 -0
  37. package/dist/modules/feature_toggles/setup.js +11 -0
  38. package/dist/modules/feature_toggles/setup.js.map +7 -0
  39. package/dist/modules/perspectives/setup.js +12 -0
  40. package/dist/modules/perspectives/setup.js.map +7 -0
  41. package/dist/modules/planner/setup.js +21 -0
  42. package/dist/modules/planner/setup.js.map +7 -0
  43. package/dist/modules/query_index/setup.js +11 -0
  44. package/dist/modules/query_index/setup.js.map +7 -0
  45. package/dist/modules/resources/setup.js +21 -0
  46. package/dist/modules/resources/setup.js.map +7 -0
  47. package/dist/modules/sales/setup.js +99 -0
  48. package/dist/modules/sales/setup.js.map +7 -0
  49. package/dist/modules/staff/setup.js +27 -0
  50. package/dist/modules/staff/setup.js.map +7 -0
  51. package/dist/modules/workflows/lib/seeds.js +3 -15
  52. package/dist/modules/workflows/lib/seeds.js.map +2 -2
  53. package/dist/modules/workflows/migrations/Migration20251207131955.js +76 -72
  54. package/dist/modules/workflows/migrations/Migration20251207131955.js.map +2 -2
  55. package/dist/modules/workflows/setup.js +16 -0
  56. package/dist/modules/workflows/setup.js.map +7 -0
  57. package/package.json +2 -2
  58. package/src/__tests__/module-decoupling.test.ts +356 -0
  59. package/src/modules/api_keys/setup.ts +9 -0
  60. package/src/modules/attachments/components/AttachmentLibrary.tsx +2 -2
  61. package/src/modules/attachments/lib/assignmentDetails.ts +32 -16
  62. package/src/modules/attachments/lib/partitions.ts +3 -3
  63. package/src/modules/attachments/setup.ts +9 -0
  64. package/src/modules/audit_logs/setup.ts +10 -0
  65. package/src/modules/auth/__tests__/cli-setup-acl.test.ts +30 -0
  66. package/src/modules/auth/lib/setup-app.ts +40 -177
  67. package/src/modules/auth/setup.ts +9 -0
  68. package/src/modules/business_rules/setup.ts +9 -0
  69. package/src/modules/catalog/setup.ts +22 -0
  70. package/src/modules/configs/lib/upgrade-actions.ts +78 -17
  71. package/src/modules/configs/setup.ts +14 -0
  72. package/src/modules/currencies/setup.ts +15 -0
  73. package/src/modules/customers/setup.ts +36 -0
  74. package/src/modules/dashboards/setup.ts +10 -0
  75. package/src/modules/dictionaries/setup.ts +10 -0
  76. package/src/modules/directory/setup.ts +10 -0
  77. package/src/modules/entities/setup.ts +9 -0
  78. package/src/modules/feature_toggles/setup.ts +9 -0
  79. package/src/modules/perspectives/setup.ts +10 -0
  80. package/src/modules/planner/setup.ts +21 -0
  81. package/src/modules/query_index/setup.ts +9 -0
  82. package/src/modules/resources/setup.ts +21 -0
  83. package/src/modules/sales/setup.ts +108 -0
  84. package/src/modules/staff/setup.ts +27 -0
  85. package/src/modules/workflows/lib/seeds.ts +4 -16
  86. package/src/modules/workflows/migrations/Migration20251207131955.ts +77 -143
  87. package/src/modules/workflows/setup.ts +15 -0
@@ -1,24 +1,12 @@
1
1
  import * as fs from "fs";
2
2
  import * as path from "path";
3
+ import { fileURLToPath } from "node:url";
3
4
  import { WorkflowDefinition } from "../data/entities.js";
4
5
  import { BusinessRule } from "@open-mercato/core/modules/business_rules/data/entities";
5
- import checkoutDemoDefinition from "../examples/checkout-demo-definition.json";
6
- import guardRulesExample from "../examples/guard-rules-example.json";
7
- import salesPipelineDefinition from "../examples/sales-pipeline-definition.json";
8
- import simpleApprovalDefinition from "../examples/simple-approval-definition.json";
9
- const embeddedSeeds = {
10
- "checkout-demo-definition.json": checkoutDemoDefinition,
11
- "guard-rules-example.json": guardRulesExample,
12
- "sales-pipeline-definition.json": salesPipelineDefinition,
13
- "simple-approval-definition.json": simpleApprovalDefinition
14
- };
6
+ const __esmDirname = path.dirname(fileURLToPath(import.meta.url));
15
7
  function readExampleJson(fileName) {
16
- const embedded = embeddedSeeds[fileName];
17
- if (embedded) {
18
- return embedded;
19
- }
20
8
  const candidates = [
21
- path.join(__dirname, "..", "examples", fileName),
9
+ path.join(__esmDirname, "..", "examples", fileName),
22
10
  path.join(process.cwd(), "packages", "core", "src", "modules", "workflows", "examples", fileName),
23
11
  path.join(process.cwd(), "src", "modules", "workflows", "examples", fileName)
24
12
  ];
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/modules/workflows/lib/seeds.ts"],
4
- "sourcesContent": ["import type { EntityManager } from '@mikro-orm/postgresql'\nimport * as fs from 'fs'\nimport * as path from 'path'\nimport { WorkflowDefinition, type WorkflowDefinitionData } from '../data/entities'\nimport { BusinessRule, type RuleType } from '@open-mercato/core/modules/business_rules/data/entities'\nimport checkoutDemoDefinition from '../examples/checkout-demo-definition.json'\nimport guardRulesExample from '../examples/guard-rules-example.json'\nimport salesPipelineDefinition from '../examples/sales-pipeline-definition.json'\nimport simpleApprovalDefinition from '../examples/simple-approval-definition.json'\n\nexport type WorkflowSeedScope = { tenantId: string; organizationId: string }\n\ntype WorkflowSeedDefinition = {\n workflowId: string\n workflowName: string\n description?: string | null\n version?: number\n definition: WorkflowDefinitionData\n metadata?: Record<string, unknown> | null\n enabled?: boolean\n effectiveFrom?: string | null\n effectiveTo?: string | null\n createdBy?: string | null\n updatedBy?: string | null\n}\n\ntype GuardRuleSeed = {\n ruleId: string\n ruleName: string\n ruleType: RuleType\n entityType: string\n conditionExpression: unknown\n eventType?: string | null\n ruleCategory?: string | null\n description?: string | null\n successActions?: unknown\n failureActions?: unknown\n enabled?: boolean\n priority?: number\n version?: number\n effectiveFrom?: string | null\n effectiveTo?: string | null\n createdBy?: string | null\n updatedBy?: string | null\n tagsJson?: string[]\n labelsJson?: Record<string, string>\n}\n\nconst embeddedSeeds: Record<string, unknown> = {\n 'checkout-demo-definition.json': checkoutDemoDefinition,\n 'guard-rules-example.json': guardRulesExample,\n 'sales-pipeline-definition.json': salesPipelineDefinition,\n 'simple-approval-definition.json': simpleApprovalDefinition,\n}\n\nfunction readExampleJson<T>(fileName: string): T {\n const embedded = embeddedSeeds[fileName]\n if (embedded) {\n return embedded as T\n }\n const candidates = [\n path.join(__dirname, '..', 'examples', fileName),\n path.join(process.cwd(), 'packages', 'core', 'src', 'modules', 'workflows', 'examples', fileName),\n path.join(process.cwd(), 'src', 'modules', 'workflows', 'examples', fileName),\n ]\n const filePath = candidates.find((candidate) => fs.existsSync(candidate))\n if (!filePath) {\n throw new Error(`Missing workflow seed file: ${fileName}`)\n }\n return JSON.parse(fs.readFileSync(filePath, 'utf8')) as T\n}\n\nfunction requireString(value: unknown, label: string): string {\n if (typeof value === 'string' && value.trim().length > 0) return value\n throw new Error(`Invalid ${label} in workflow seed data.`)\n}\n\nasync function seedWorkflowDefinition(\n em: EntityManager,\n scope: WorkflowSeedScope,\n fileName: string,\n): Promise<boolean> {\n const seed = readExampleJson<WorkflowSeedDefinition>(fileName)\n const workflowId = requireString(seed.workflowId, 'workflowId')\n\n const existing = await em.findOne(WorkflowDefinition, {\n workflowId,\n tenantId: scope.tenantId,\n organizationId: scope.organizationId,\n })\n\n if (existing) {\n // Check if the definition needs to be updated (e.g., missing preConditions on START step)\n const seedStartStep = seed.definition.steps.find((s: any) => s.stepType === 'START')\n const existingStartStep = existing.definition.steps.find((s: any) => s.stepType === 'START')\n\n const seedHasPreConditions = seedStartStep?.preConditions && seedStartStep.preConditions.length > 0\n const existingHasPreConditions = existingStartStep?.preConditions && existingStartStep.preConditions.length > 0\n\n // Update if seed has preConditions but existing doesn't\n if (seedHasPreConditions && !existingHasPreConditions) {\n console.log(`[seed] Updating workflow ${workflowId} with preConditions`)\n existing.definition = seed.definition\n await em.flush()\n return true\n }\n\n return false\n }\n\n const workflow = em.create(WorkflowDefinition, {\n ...seed,\n workflowId,\n tenantId: scope.tenantId,\n organizationId: scope.organizationId,\n })\n em.persist(workflow)\n await em.flush()\n return true\n}\n\nasync function seedGuardRules(\n em: EntityManager,\n scope: WorkflowSeedScope,\n fileName: string,\n): Promise<{ seeded: number; skipped: number; updated: number }> {\n const seeds = readExampleJson<GuardRuleSeed[]>(fileName)\n if (!Array.isArray(seeds)) {\n throw new Error('Invalid guard rules seed data.')\n }\n\n let seeded = 0\n let skipped = 0\n let updated = 0\n for (const rule of seeds) {\n const ruleId = requireString(rule.ruleId, 'ruleId')\n const existing = await em.findOne(BusinessRule, {\n ruleId,\n tenantId: scope.tenantId,\n organizationId: scope.organizationId,\n })\n if (existing) {\n // Check if entityType or eventType needs updating\n const needsUpdate = existing.entityType !== rule.entityType || existing.eventType !== rule.eventType\n if (needsUpdate) {\n console.log(`[seed] Updating business rule ${ruleId}: entityType=${rule.entityType}, eventType=${rule.eventType}`)\n existing.entityType = rule.entityType\n existing.eventType = rule.eventType ?? null\n updated += 1\n } else {\n skipped += 1\n }\n continue\n }\n const entry = em.create(BusinessRule, {\n ...rule,\n ruleId,\n tenantId: scope.tenantId,\n organizationId: scope.organizationId,\n })\n em.persist(entry)\n seeded += 1\n }\n if (seeded > 0 || updated > 0) {\n await em.flush()\n }\n return { seeded, skipped, updated }\n}\n\nexport async function seedExampleWorkflows(em: EntityManager, scope: WorkflowSeedScope): Promise<void> {\n await seedWorkflowDefinition(em, scope, 'checkout-demo-definition.json')\n await seedGuardRules(em, scope, 'guard-rules-example.json')\n await seedWorkflowDefinition(em, scope, 'sales-pipeline-definition.json')\n await seedWorkflowDefinition(em, scope, 'simple-approval-definition.json')\n}\n"],
5
- "mappings": "AACA,YAAY,QAAQ;AACpB,YAAY,UAAU;AACtB,SAAS,0BAAuD;AAChE,SAAS,oBAAmC;AAC5C,OAAO,4BAA4B;AACnC,OAAO,uBAAuB;AAC9B,OAAO,6BAA6B;AACpC,OAAO,8BAA8B;AAwCrC,MAAM,gBAAyC;AAAA,EAC7C,iCAAiC;AAAA,EACjC,4BAA4B;AAAA,EAC5B,kCAAkC;AAAA,EAClC,mCAAmC;AACrC;AAEA,SAAS,gBAAmB,UAAqB;AAC/C,QAAM,WAAW,cAAc,QAAQ;AACvC,MAAI,UAAU;AACZ,WAAO;AAAA,EACT;AACA,QAAM,aAAa;AAAA,IACjB,KAAK,KAAK,WAAW,MAAM,YAAY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yC;AACrG,QAAM,uBAAuB,IAAI,OAAO,+BAA+B;AACvE,QAAM,eAAe,IAAI,OAAO,0BAA0B;AAC1D,QAAM,uBAAuB,IAAI,OAAO,gCAAgC;AACxE,QAAM,uBAAuB,IAAI,OAAO,iCAAiC;AAC3E;",
4
+ "sourcesContent": ["import type { EntityManager } from '@mikro-orm/postgresql'\nimport * as fs from 'fs'\nimport * as path from 'path'\nimport { fileURLToPath } from 'node:url'\nimport { WorkflowDefinition, type WorkflowDefinitionData } from '../data/entities'\nimport { BusinessRule, type RuleType } from '@open-mercato/core/modules/business_rules/data/entities'\n\nconst __esmDirname = path.dirname(fileURLToPath(import.meta.url))\n\nexport type WorkflowSeedScope = { tenantId: string; organizationId: string }\n\ntype WorkflowSeedDefinition = {\n workflowId: string\n workflowName: string\n description?: string | null\n version?: number\n definition: WorkflowDefinitionData\n metadata?: Record<string, unknown> | null\n enabled?: boolean\n effectiveFrom?: string | null\n effectiveTo?: string | null\n createdBy?: string | null\n updatedBy?: string | null\n}\n\ntype GuardRuleSeed = {\n ruleId: string\n ruleName: string\n ruleType: RuleType\n entityType: string\n conditionExpression: unknown\n eventType?: string | null\n ruleCategory?: string | null\n description?: string | null\n successActions?: unknown\n failureActions?: unknown\n enabled?: boolean\n priority?: number\n version?: number\n effectiveFrom?: string | null\n effectiveTo?: string | null\n createdBy?: string | null\n updatedBy?: string | null\n tagsJson?: string[]\n labelsJson?: Record<string, string>\n}\n\nfunction readExampleJson<T>(fileName: string): T {\n const candidates = [\n path.join(__esmDirname, '..', 'examples', fileName),\n path.join(process.cwd(), 'packages', 'core', 'src', 'modules', 'workflows', 'examples', fileName),\n path.join(process.cwd(), 'src', 'modules', 'workflows', 'examples', fileName),\n ]\n const filePath = candidates.find((candidate) => fs.existsSync(candidate))\n if (!filePath) {\n throw new Error(`Missing workflow seed file: ${fileName}`)\n }\n return JSON.parse(fs.readFileSync(filePath, 'utf8')) as T\n}\n\nfunction requireString(value: unknown, label: string): string {\n if (typeof value === 'string' && value.trim().length > 0) return value\n throw new Error(`Invalid ${label} in workflow seed data.`)\n}\n\nasync function seedWorkflowDefinition(\n em: EntityManager,\n scope: WorkflowSeedScope,\n fileName: string,\n): Promise<boolean> {\n const seed = readExampleJson<WorkflowSeedDefinition>(fileName)\n const workflowId = requireString(seed.workflowId, 'workflowId')\n\n const existing = await em.findOne(WorkflowDefinition, {\n workflowId,\n tenantId: scope.tenantId,\n organizationId: scope.organizationId,\n })\n\n if (existing) {\n // Check if the definition needs to be updated (e.g., missing preConditions on START step)\n const seedStartStep = seed.definition.steps.find((s: any) => s.stepType === 'START')\n const existingStartStep = existing.definition.steps.find((s: any) => s.stepType === 'START')\n\n const seedHasPreConditions = seedStartStep?.preConditions && seedStartStep.preConditions.length > 0\n const existingHasPreConditions = existingStartStep?.preConditions && existingStartStep.preConditions.length > 0\n\n // Update if seed has preConditions but existing doesn't\n if (seedHasPreConditions && !existingHasPreConditions) {\n console.log(`[seed] Updating workflow ${workflowId} with preConditions`)\n existing.definition = seed.definition\n await em.flush()\n return true\n }\n\n return false\n }\n\n const workflow = em.create(WorkflowDefinition, {\n ...seed,\n workflowId,\n tenantId: scope.tenantId,\n organizationId: scope.organizationId,\n })\n em.persist(workflow)\n await em.flush()\n return true\n}\n\nasync function seedGuardRules(\n em: EntityManager,\n scope: WorkflowSeedScope,\n fileName: string,\n): Promise<{ seeded: number; skipped: number; updated: number }> {\n const seeds = readExampleJson<GuardRuleSeed[]>(fileName)\n if (!Array.isArray(seeds)) {\n throw new Error('Invalid guard rules seed data.')\n }\n\n let seeded = 0\n let skipped = 0\n let updated = 0\n for (const rule of seeds) {\n const ruleId = requireString(rule.ruleId, 'ruleId')\n const existing = await em.findOne(BusinessRule, {\n ruleId,\n tenantId: scope.tenantId,\n organizationId: scope.organizationId,\n })\n if (existing) {\n // Check if entityType or eventType needs updating\n const needsUpdate = existing.entityType !== rule.entityType || existing.eventType !== rule.eventType\n if (needsUpdate) {\n console.log(`[seed] Updating business rule ${ruleId}: entityType=${rule.entityType}, eventType=${rule.eventType}`)\n existing.entityType = rule.entityType\n existing.eventType = rule.eventType ?? null\n updated += 1\n } else {\n skipped += 1\n }\n continue\n }\n const entry = em.create(BusinessRule, {\n ...rule,\n ruleId,\n tenantId: scope.tenantId,\n organizationId: scope.organizationId,\n })\n em.persist(entry)\n seeded += 1\n }\n if (seeded > 0 || updated > 0) {\n await em.flush()\n }\n return { seeded, skipped, updated }\n}\n\nexport async function seedExampleWorkflows(em: EntityManager, scope: WorkflowSeedScope): Promise<void> {\n await seedWorkflowDefinition(em, scope, 'checkout-demo-definition.json')\n await seedGuardRules(em, scope, 'guard-rules-example.json')\n await seedWorkflowDefinition(em, scope, 'sales-pipeline-definition.json')\n await seedWorkflowDefinition(em, scope, 'simple-approval-definition.json')\n}\n"],
5
+ "mappings": "AACA,YAAY,QAAQ;AACpB,YAAY,UAAU;AACtB,SAAS,qBAAqB;AAC9B,SAAS,0BAAuD;AAChE,SAAS,oBAAmC;AAE5C,MAAM,eAAe,KAAK,QAAQ,cAAc,YAAY,GAAG,CAAC;AAwChE,SAAS,gBAAmB,UAAqB;AAC/C,QAAM,aAAa;AAAA,IACjB,KAAK,KAAK,cAAc,MAAM,YAAY,QAAQ;AAAA,IAClD,KAAK,KAAK,QAAQ,IAAI,GAAG,YAAY,QAAQ,OAAO,WAAW,aAAa,YAAY,QAAQ;AAAA,IAChG,KAAK,KAAK,QAAQ,IAAI,GAAG,OAAO,WAAW,aAAa,YAAY,QAAQ;AAAA,EAC9E;AACA,QAAM,WAAW,WAAW,KAAK,CAAC,cAAc,GAAG,WAAW,SAAS,CAAC;AACxE,MAAI,CAAC,UAAU;AACb,UAAM,IAAI,MAAM,+BAA+B,QAAQ,EAAE;AAAA,EAC3D;AACA,SAAO,KAAK,MAAM,GAAG,aAAa,UAAU,MAAM,CAAC;AACrD;AAEA,SAAS,cAAc,OAAgB,OAAuB;AAC5D,MAAI,OAAO,UAAU,YAAY,MAAM,KAAK,EAAE,SAAS,E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ClD,UAAM,WAAW,MAAM,GAAG,QAAQ,cAAc;AAAA,MAC9C;AAAA,MACA,UAAU,MAAM;AAAA,MAChB,gBAAgB,MAAM;AAAA,IACxB,CAAC;AACD,QAAI,UAAU;AAEZ,YAAM,cAAc,SAAS,eAAe,KAAK,cAAc,SAAS,cAAc,KAAK;AAC3F,UAAI,aAAa;AACf,gBAAQ,IAAI,iCAAiC,MAAM,gBAAgB,KAAK,UAAU,eAAe,KAAK,SAAS,EAAE;AACjH,iBAAS,aAAa,KAAK;AAC3B,iBAAS,YAAY,KAAK,aAAa;AACvC,mBAAW;AAAA,MACb,OAAO;AACL,mBAAW;AAAA,MACb;AACA;AAAA,IACF;AACA,UAAM,QAAQ,GAAG,OAAO,cAAc;AAAA,MACpC,GAAG;AAAA,MACH;AAAA,MACA,UAAU,MAAM;AAAA,MAChB,gBAAgB,MAAM;AAAA,IACxB,CAAC;AACD,OAAG,QAAQ,KAAK;AAChB,cAAU;AAAA,EACZ;AACA,MAAI,SAAS,KAAK,UAAU,GAAG;AAC7B,UAAM,GAAG,MAAM;AAAA,EACjB;AACA,SAAO,EAAE,QAAQ,SAAS,QAAQ;AACpC;AAEA,eAAsB,qBAAqB,IAAmB,OAAyC;AACrG,QAAM,uBAAuB,IAAI,OAAO,+BAA+B;AACvE,QAAM,eAAe,IAAI,OAAO,0BAA0B;AAC1D,QAAM,uBAAuB,IAAI,OAAO,gCAAgC;AACxE,QAAM,uBAAuB,IAAI,OAAO,iCAAiC;AAC3E;",
6
6
  "names": []
7
7
  }
@@ -1,78 +1,82 @@
1
1
  import { Migration } from "@mikro-orm/migrations";
2
2
  class Migration20251207131955 extends Migration {
3
+ /** Drop a foreign key constraint only when the owning table exists (safe for disabled modules). */
4
+ dropConstraintIfTableExists(table, constraint) {
5
+ this.addSql(`DO $$ BEGIN IF EXISTS (SELECT 1 FROM information_schema.tables WHERE table_name = '${table}') THEN ALTER TABLE "${table}" DROP CONSTRAINT IF EXISTS "${constraint}"; END IF; END $$;`);
6
+ }
3
7
  async up() {
4
- this.addSql(`alter table "rule_execution_logs" drop constraint "rule_execution_logs_rule_id_foreign";`);
5
- this.addSql(`alter table "rule_set_members" drop constraint "rule_set_members_rule_id_foreign";`);
6
- this.addSql(`alter table "catalog_product_variant_prices" drop constraint "catalog_product_variant_prices_price_kind_id_foreign";`);
7
- this.addSql(`alter table "catalog_product_category_assignments" drop constraint "catalog_product_category_assignments_category_id_foreign";`);
8
- this.addSql(`alter table "catalog_product_variant_prices" drop constraint "catalog_product_variant_prices_offer_id_foreign";`);
9
- this.addSql(`alter table "catalog_products" drop constraint "catalog_products_option_schema_id_foreign";`);
10
- this.addSql(`alter table "catalog_product_tag_assignments" drop constraint "catalog_product_tag_assignments_tag_id_foreign";`);
11
- this.addSql(`alter table "catalog_product_variant_option_values" drop constraint "catalog_product_variant_option_values_variant_id_foreign";`);
12
- this.addSql(`alter table "catalog_product_variant_prices" drop constraint "catalog_product_variant_prices_variant_id_foreign";`);
13
- this.addSql(`alter table "catalog_product_variant_relations" drop constraint "catalog_product_variant_relations_child_variant_id_foreign";`);
14
- this.addSql(`alter table "catalog_product_variant_relations" drop constraint "catalog_product_variant_relations_parent_variant_id_foreign";`);
15
- this.addSql(`alter table "catalog_product_category_assignments" drop constraint "catalog_product_category_assignments_product_id_foreign";`);
16
- this.addSql(`alter table "catalog_product_offers" drop constraint "catalog_product_offers_product_id_foreign";`);
17
- this.addSql(`alter table "catalog_product_options" drop constraint "catalog_product_options_product_id_foreign";`);
18
- this.addSql(`alter table "catalog_product_relations" drop constraint "catalog_product_relations_child_product_id_foreign";`);
19
- this.addSql(`alter table "catalog_product_relations" drop constraint "catalog_product_relations_parent_product_id_foreign";`);
20
- this.addSql(`alter table "catalog_product_tag_assignments" drop constraint "catalog_product_tag_assignments_product_id_foreign";`);
21
- this.addSql(`alter table "catalog_product_variant_prices" drop constraint "catalog_product_variant_prices_product_id_foreign";`);
22
- this.addSql(`alter table "catalog_product_variants" drop constraint "catalog_product_variants_product_id_foreign";`);
23
- this.addSql(`alter table "customer_activities" drop constraint "customer_activities_deal_id_foreign";`);
24
- this.addSql(`alter table "customer_comments" drop constraint "customer_comments_deal_id_foreign";`);
25
- this.addSql(`alter table "customer_deal_companies" drop constraint "customer_deal_companies_deal_id_foreign";`);
26
- this.addSql(`alter table "customer_deal_people" drop constraint "customer_deal_people_deal_id_foreign";`);
27
- this.addSql(`alter table "customer_activities" drop constraint "customer_activities_entity_id_foreign";`);
28
- this.addSql(`alter table "customer_addresses" drop constraint "customer_addresses_entity_id_foreign";`);
29
- this.addSql(`alter table "customer_comments" drop constraint "customer_comments_entity_id_foreign";`);
30
- this.addSql(`alter table "customer_companies" drop constraint "customer_companies_entity_id_foreign";`);
31
- this.addSql(`alter table "customer_deal_companies" drop constraint "customer_deal_companies_company_entity_id_foreign";`);
32
- this.addSql(`alter table "customer_deal_people" drop constraint "customer_deal_people_person_entity_id_foreign";`);
33
- this.addSql(`alter table "customer_people" drop constraint "customer_people_company_entity_id_foreign";`);
34
- this.addSql(`alter table "customer_people" drop constraint "customer_people_entity_id_foreign";`);
35
- this.addSql(`alter table "customer_tag_assignments" drop constraint "customer_tag_assignments_entity_id_foreign";`);
36
- this.addSql(`alter table "customer_todo_links" drop constraint "customer_todo_links_entity_id_foreign";`);
37
- this.addSql(`alter table "customer_tag_assignments" drop constraint "customer_tag_assignments_tag_id_foreign";`);
38
- this.addSql(`alter table "dictionary_entries" drop constraint "dictionary_entries_dictionary_id_foreign";`);
39
- this.addSql(`alter table "role_acls" drop constraint "role_acls_role_id_foreign";`);
40
- this.addSql(`alter table "role_sidebar_preferences" drop constraint "role_sidebar_preferences_role_id_foreign";`);
41
- this.addSql(`alter table "user_roles" drop constraint "user_roles_role_id_foreign";`);
42
- this.addSql(`alter table "rule_set_members" drop constraint "rule_set_members_rule_set_id_foreign";`);
43
- this.addSql(`alter table "sales_orders" drop constraint "sales_orders_channel_ref_id_foreign";`);
44
- this.addSql(`alter table "sales_credit_memo_lines" drop constraint "sales_credit_memo_lines_credit_memo_id_foreign";`);
45
- this.addSql(`alter table "sales_orders" drop constraint "sales_orders_delivery_window_ref_id_foreign";`);
46
- this.addSql(`alter table "sales_credit_memos" drop constraint "sales_credit_memos_invoice_id_foreign";`);
47
- this.addSql(`alter table "sales_invoice_lines" drop constraint "sales_invoice_lines_invoice_id_foreign";`);
48
- this.addSql(`alter table "sales_payment_allocations" drop constraint "sales_payment_allocations_invoice_id_foreign";`);
49
- this.addSql(`alter table "sales_credit_memo_lines" drop constraint "sales_credit_memo_lines_order_line_id_foreign";`);
50
- this.addSql(`alter table "sales_invoice_lines" drop constraint "sales_invoice_lines_order_line_id_foreign";`);
51
- this.addSql(`alter table "sales_order_adjustments" drop constraint "sales_order_adjustments_order_line_id_foreign";`);
52
- this.addSql(`alter table "sales_shipment_items" drop constraint "sales_shipment_items_order_line_id_foreign";`);
53
- this.addSql(`alter table "sales_credit_memos" drop constraint "sales_credit_memos_order_id_foreign";`);
54
- this.addSql(`alter table "sales_invoices" drop constraint "sales_invoices_order_id_foreign";`);
55
- this.addSql(`alter table "sales_notes" drop constraint "sales_notes_order_id_foreign";`);
56
- this.addSql(`alter table "sales_order_adjustments" drop constraint "sales_order_adjustments_order_id_foreign";`);
57
- this.addSql(`alter table "sales_order_lines" drop constraint "sales_order_lines_order_id_foreign";`);
58
- this.addSql(`alter table "sales_payment_allocations" drop constraint "sales_payment_allocations_order_id_foreign";`);
59
- this.addSql(`alter table "sales_payments" drop constraint "sales_payments_order_id_foreign";`);
60
- this.addSql(`alter table "sales_shipments" drop constraint "sales_shipments_order_id_foreign";`);
61
- this.addSql(`alter table "sales_orders" drop constraint "sales_orders_payment_method_ref_id_foreign";`);
62
- this.addSql(`alter table "sales_payments" drop constraint "sales_payments_payment_method_id_foreign";`);
63
- this.addSql(`alter table "sales_payment_allocations" drop constraint "sales_payment_allocations_payment_id_foreign";`);
64
- this.addSql(`alter table "sales_quote_adjustments" drop constraint "sales_quote_adjustments_quote_line_id_foreign";`);
65
- this.addSql(`alter table "sales_notes" drop constraint "sales_notes_quote_id_foreign";`);
66
- this.addSql(`alter table "sales_quote_adjustments" drop constraint "sales_quote_adjustments_quote_id_foreign";`);
67
- this.addSql(`alter table "sales_quote_lines" drop constraint "sales_quote_lines_quote_id_foreign";`);
68
- this.addSql(`alter table "sales_shipment_items" drop constraint "sales_shipment_items_shipment_id_foreign";`);
69
- this.addSql(`alter table "sales_orders" drop constraint "sales_orders_shipping_method_ref_id_foreign";`);
70
- this.addSql(`alter table "organizations" drop constraint "organizations_tenant_id_foreign";`);
71
- this.addSql(`alter table "password_resets" drop constraint "password_resets_user_id_foreign";`);
72
- this.addSql(`alter table "sessions" drop constraint "sessions_user_id_foreign";`);
73
- this.addSql(`alter table "user_acls" drop constraint "user_acls_user_id_foreign";`);
74
- this.addSql(`alter table "user_roles" drop constraint "user_roles_user_id_foreign";`);
75
- this.addSql(`alter table "user_sidebar_preferences" drop constraint "user_sidebar_preferences_user_id_foreign";`);
8
+ this.dropConstraintIfTableExists("rule_execution_logs", "rule_execution_logs_rule_id_foreign");
9
+ this.dropConstraintIfTableExists("rule_set_members", "rule_set_members_rule_id_foreign");
10
+ this.dropConstraintIfTableExists("catalog_product_variant_prices", "catalog_product_variant_prices_price_kind_id_foreign");
11
+ this.dropConstraintIfTableExists("catalog_product_category_assignments", "catalog_product_category_assignments_category_id_foreign");
12
+ this.dropConstraintIfTableExists("catalog_product_variant_prices", "catalog_product_variant_prices_offer_id_foreign");
13
+ this.dropConstraintIfTableExists("catalog_products", "catalog_products_option_schema_id_foreign");
14
+ this.dropConstraintIfTableExists("catalog_product_tag_assignments", "catalog_product_tag_assignments_tag_id_foreign");
15
+ this.dropConstraintIfTableExists("catalog_product_variant_option_values", "catalog_product_variant_option_values_variant_id_foreign");
16
+ this.dropConstraintIfTableExists("catalog_product_variant_prices", "catalog_product_variant_prices_variant_id_foreign");
17
+ this.dropConstraintIfTableExists("catalog_product_variant_relations", "catalog_product_variant_relations_child_variant_id_foreign");
18
+ this.dropConstraintIfTableExists("catalog_product_variant_relations", "catalog_product_variant_relations_parent_variant_id_foreign");
19
+ this.dropConstraintIfTableExists("catalog_product_category_assignments", "catalog_product_category_assignments_product_id_foreign");
20
+ this.dropConstraintIfTableExists("catalog_product_offers", "catalog_product_offers_product_id_foreign");
21
+ this.dropConstraintIfTableExists("catalog_product_options", "catalog_product_options_product_id_foreign");
22
+ this.dropConstraintIfTableExists("catalog_product_relations", "catalog_product_relations_child_product_id_foreign");
23
+ this.dropConstraintIfTableExists("catalog_product_relations", "catalog_product_relations_parent_product_id_foreign");
24
+ this.dropConstraintIfTableExists("catalog_product_tag_assignments", "catalog_product_tag_assignments_product_id_foreign");
25
+ this.dropConstraintIfTableExists("catalog_product_variant_prices", "catalog_product_variant_prices_product_id_foreign");
26
+ this.dropConstraintIfTableExists("catalog_product_variants", "catalog_product_variants_product_id_foreign");
27
+ this.dropConstraintIfTableExists("customer_activities", "customer_activities_deal_id_foreign");
28
+ this.dropConstraintIfTableExists("customer_comments", "customer_comments_deal_id_foreign");
29
+ this.dropConstraintIfTableExists("customer_deal_companies", "customer_deal_companies_deal_id_foreign");
30
+ this.dropConstraintIfTableExists("customer_deal_people", "customer_deal_people_deal_id_foreign");
31
+ this.dropConstraintIfTableExists("customer_activities", "customer_activities_entity_id_foreign");
32
+ this.dropConstraintIfTableExists("customer_addresses", "customer_addresses_entity_id_foreign");
33
+ this.dropConstraintIfTableExists("customer_comments", "customer_comments_entity_id_foreign");
34
+ this.dropConstraintIfTableExists("customer_companies", "customer_companies_entity_id_foreign");
35
+ this.dropConstraintIfTableExists("customer_deal_companies", "customer_deal_companies_company_entity_id_foreign");
36
+ this.dropConstraintIfTableExists("customer_deal_people", "customer_deal_people_person_entity_id_foreign");
37
+ this.dropConstraintIfTableExists("customer_people", "customer_people_company_entity_id_foreign");
38
+ this.dropConstraintIfTableExists("customer_people", "customer_people_entity_id_foreign");
39
+ this.dropConstraintIfTableExists("customer_tag_assignments", "customer_tag_assignments_entity_id_foreign");
40
+ this.dropConstraintIfTableExists("customer_todo_links", "customer_todo_links_entity_id_foreign");
41
+ this.dropConstraintIfTableExists("customer_tag_assignments", "customer_tag_assignments_tag_id_foreign");
42
+ this.dropConstraintIfTableExists("dictionary_entries", "dictionary_entries_dictionary_id_foreign");
43
+ this.dropConstraintIfTableExists("role_acls", "role_acls_role_id_foreign");
44
+ this.dropConstraintIfTableExists("role_sidebar_preferences", "role_sidebar_preferences_role_id_foreign");
45
+ this.dropConstraintIfTableExists("user_roles", "user_roles_role_id_foreign");
46
+ this.dropConstraintIfTableExists("rule_set_members", "rule_set_members_rule_set_id_foreign");
47
+ this.dropConstraintIfTableExists("sales_orders", "sales_orders_channel_ref_id_foreign");
48
+ this.dropConstraintIfTableExists("sales_credit_memo_lines", "sales_credit_memo_lines_credit_memo_id_foreign");
49
+ this.dropConstraintIfTableExists("sales_orders", "sales_orders_delivery_window_ref_id_foreign");
50
+ this.dropConstraintIfTableExists("sales_credit_memos", "sales_credit_memos_invoice_id_foreign");
51
+ this.dropConstraintIfTableExists("sales_invoice_lines", "sales_invoice_lines_invoice_id_foreign");
52
+ this.dropConstraintIfTableExists("sales_payment_allocations", "sales_payment_allocations_invoice_id_foreign");
53
+ this.dropConstraintIfTableExists("sales_credit_memo_lines", "sales_credit_memo_lines_order_line_id_foreign");
54
+ this.dropConstraintIfTableExists("sales_invoice_lines", "sales_invoice_lines_order_line_id_foreign");
55
+ this.dropConstraintIfTableExists("sales_order_adjustments", "sales_order_adjustments_order_line_id_foreign");
56
+ this.dropConstraintIfTableExists("sales_shipment_items", "sales_shipment_items_order_line_id_foreign");
57
+ this.dropConstraintIfTableExists("sales_credit_memos", "sales_credit_memos_order_id_foreign");
58
+ this.dropConstraintIfTableExists("sales_invoices", "sales_invoices_order_id_foreign");
59
+ this.dropConstraintIfTableExists("sales_notes", "sales_notes_order_id_foreign");
60
+ this.dropConstraintIfTableExists("sales_order_adjustments", "sales_order_adjustments_order_id_foreign");
61
+ this.dropConstraintIfTableExists("sales_order_lines", "sales_order_lines_order_id_foreign");
62
+ this.dropConstraintIfTableExists("sales_payment_allocations", "sales_payment_allocations_order_id_foreign");
63
+ this.dropConstraintIfTableExists("sales_payments", "sales_payments_order_id_foreign");
64
+ this.dropConstraintIfTableExists("sales_shipments", "sales_shipments_order_id_foreign");
65
+ this.dropConstraintIfTableExists("sales_orders", "sales_orders_payment_method_ref_id_foreign");
66
+ this.dropConstraintIfTableExists("sales_payments", "sales_payments_payment_method_id_foreign");
67
+ this.dropConstraintIfTableExists("sales_payment_allocations", "sales_payment_allocations_payment_id_foreign");
68
+ this.dropConstraintIfTableExists("sales_quote_adjustments", "sales_quote_adjustments_quote_line_id_foreign");
69
+ this.dropConstraintIfTableExists("sales_notes", "sales_notes_quote_id_foreign");
70
+ this.dropConstraintIfTableExists("sales_quote_adjustments", "sales_quote_adjustments_quote_id_foreign");
71
+ this.dropConstraintIfTableExists("sales_quote_lines", "sales_quote_lines_quote_id_foreign");
72
+ this.dropConstraintIfTableExists("sales_shipment_items", "sales_shipment_items_shipment_id_foreign");
73
+ this.dropConstraintIfTableExists("sales_orders", "sales_orders_shipping_method_ref_id_foreign");
74
+ this.dropConstraintIfTableExists("organizations", "organizations_tenant_id_foreign");
75
+ this.dropConstraintIfTableExists("password_resets", "password_resets_user_id_foreign");
76
+ this.dropConstraintIfTableExists("sessions", "sessions_user_id_foreign");
77
+ this.dropConstraintIfTableExists("user_acls", "user_acls_user_id_foreign");
78
+ this.dropConstraintIfTableExists("user_roles", "user_roles_user_id_foreign");
79
+ this.dropConstraintIfTableExists("user_sidebar_preferences", "user_sidebar_preferences_user_id_foreign");
76
80
  this.addSql(`create table "step_instances" ("id" uuid not null default gen_random_uuid(), "workflow_instance_id" uuid not null, "step_id" varchar(100) not null, "step_name" varchar(255) not null, "step_type" varchar(50) not null, "status" varchar(20) not null, "input_data" jsonb null, "output_data" jsonb null, "error_data" jsonb null, "entered_at" timestamptz null, "exited_at" timestamptz null, "execution_time_ms" int null, "retry_count" int not null default 0, "tenant_id" uuid not null, "organization_id" uuid not null, "created_at" timestamptz not null, "updated_at" timestamptz not null, constraint "step_instances_pkey" primary key ("id"));`);
77
81
  this.addSql(`create index "step_instances_tenant_org_idx" on "step_instances" ("tenant_id", "organization_id");`);
78
82
  this.addSql(`create index "step_instances_step_id_idx" on "step_instances" ("step_id", "status");`);