var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __decorateClass = (decorators, target, key, kind) => {
  var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
    if (decorator = decorators[i])
      result = (kind ? decorator(target, key, result) : decorator(result)) || result;
  if (kind && result) __defProp(target, key, result);
  return result;
};
import { OptionalProps } from "@mikro-orm/core";
import { Entity, Index, PrimaryKey, Property, Unique } from "@mikro-orm/decorators/legacy";
OptionalProps;
let WorkflowDefinition = class {
  constructor() {
    this.version = 1;
    this.enabled = true;
    this.createdAt = /* @__PURE__ */ new Date();
    this.updatedAt = /* @__PURE__ */ new Date();
  }
};
__decorateClass([
  PrimaryKey({ type: "uuid", defaultRaw: "gen_random_uuid()" })
], WorkflowDefinition.prototype, "id", 2);
__decorateClass([
  Property({ name: "workflow_id", type: "varchar", length: 100 })
], WorkflowDefinition.prototype, "workflowId", 2);
__decorateClass([
  Property({ name: "code_workflow_id", type: "varchar", length: 100, nullable: true })
], WorkflowDefinition.prototype, "codeWorkflowId", 2);
__decorateClass([
  Property({ name: "workflow_name", type: "varchar", length: 255 })
], WorkflowDefinition.prototype, "workflowName", 2);
__decorateClass([
  Property({ name: "description", type: "text", nullable: true })
], WorkflowDefinition.prototype, "description", 2);
__decorateClass([
  Property({ name: "version", type: "integer", default: 1 })
], WorkflowDefinition.prototype, "version", 2);
__decorateClass([
  Property({ name: "definition", type: "jsonb" })
], WorkflowDefinition.prototype, "definition", 2);
__decorateClass([
  Property({ name: "metadata", type: "jsonb", nullable: true })
], WorkflowDefinition.prototype, "metadata", 2);
__decorateClass([
  Property({ name: "enabled", type: "boolean", default: true })
], WorkflowDefinition.prototype, "enabled", 2);
__decorateClass([
  Property({ name: "effective_from", type: Date, nullable: true })
], WorkflowDefinition.prototype, "effectiveFrom", 2);
__decorateClass([
  Property({ name: "effective_to", type: Date, nullable: true })
], WorkflowDefinition.prototype, "effectiveTo", 2);
__decorateClass([
  Property({ name: "tenant_id", type: "uuid" })
], WorkflowDefinition.prototype, "tenantId", 2);
__decorateClass([
  Property({ name: "organization_id", type: "uuid" })
], WorkflowDefinition.prototype, "organizationId", 2);
__decorateClass([
  Property({ name: "created_by", type: "varchar", length: 255, nullable: true })
], WorkflowDefinition.prototype, "createdBy", 2);
__decorateClass([
  Property({ name: "updated_by", type: "varchar", length: 255, nullable: true })
], WorkflowDefinition.prototype, "updatedBy", 2);
__decorateClass([
  Property({ name: "created_at", type: Date, onCreate: () => /* @__PURE__ */ new Date() })
], WorkflowDefinition.prototype, "createdAt", 2);
__decorateClass([
  Property({ name: "updated_at", type: Date, onUpdate: () => /* @__PURE__ */ new Date() })
], WorkflowDefinition.prototype, "updatedAt", 2);
__decorateClass([
  Property({ name: "deleted_at", type: Date, nullable: true })
], WorkflowDefinition.prototype, "deletedAt", 2);
WorkflowDefinition = __decorateClass([
  Entity({ tableName: "workflow_definitions" }),
  Unique({ properties: ["workflowId", "tenantId"] }),
  Index({ name: "workflow_definitions_enabled_idx", properties: ["enabled"] }),
  Index({ name: "workflow_definitions_tenant_org_idx", properties: ["tenantId", "organizationId"] }),
  Index({ name: "workflow_definitions_workflow_id_idx", properties: ["workflowId"] })
], WorkflowDefinition);
OptionalProps;
let WorkflowInstance = class {
  constructor() {
    this.retryCount = 0;
    this.createdAt = /* @__PURE__ */ new Date();
    this.updatedAt = /* @__PURE__ */ new Date();
  }
};
__decorateClass([
  PrimaryKey({ type: "uuid", defaultRaw: "gen_random_uuid()" })
], WorkflowInstance.prototype, "id", 2);
__decorateClass([
  Property({ name: "definition_id", type: "uuid" })
], WorkflowInstance.prototype, "definitionId", 2);
__decorateClass([
  Property({ name: "workflow_id", type: "varchar", length: 100 })
], WorkflowInstance.prototype, "workflowId", 2);
__decorateClass([
  Property({ name: "version", type: "integer" })
], WorkflowInstance.prototype, "version", 2);
__decorateClass([
  Property({ name: "status", type: "varchar", length: 30 })
], WorkflowInstance.prototype, "status", 2);
__decorateClass([
  Property({ name: "current_step_id", type: "varchar", length: 100 })
], WorkflowInstance.prototype, "currentStepId", 2);
__decorateClass([
  Property({ name: "context", type: "jsonb" })
], WorkflowInstance.prototype, "context", 2);
__decorateClass([
  Property({ name: "correlation_key", type: "varchar", length: 255, nullable: true })
], WorkflowInstance.prototype, "correlationKey", 2);
__decorateClass([
  Property({ name: "metadata", type: "jsonb", nullable: true })
], WorkflowInstance.prototype, "metadata", 2);
__decorateClass([
  Property({ name: "started_at", type: Date })
], WorkflowInstance.prototype, "startedAt", 2);
__decorateClass([
  Property({ name: "completed_at", type: Date, nullable: true })
], WorkflowInstance.prototype, "completedAt", 2);
__decorateClass([
  Property({ name: "paused_at", type: Date, nullable: true })
], WorkflowInstance.prototype, "pausedAt", 2);
__decorateClass([
  Property({ name: "cancelled_at", type: Date, nullable: true })
], WorkflowInstance.prototype, "cancelledAt", 2);
__decorateClass([
  Property({ name: "error_message", type: "text", nullable: true })
], WorkflowInstance.prototype, "errorMessage", 2);
__decorateClass([
  Property({ name: "error_details", type: "jsonb", nullable: true })
], WorkflowInstance.prototype, "errorDetails", 2);
__decorateClass([
  Property({ name: "pending_transition", type: "jsonb", nullable: true })
], WorkflowInstance.prototype, "pendingTransition", 2);
__decorateClass([
  Property({ name: "active_fork_step_id", type: "varchar", length: 100, nullable: true })
], WorkflowInstance.prototype, "activeForkStepId", 2);
__decorateClass([
  Property({ name: "retry_count", type: "integer", default: 0 })
], WorkflowInstance.prototype, "retryCount", 2);
__decorateClass([
  Property({ name: "tenant_id", type: "uuid" })
], WorkflowInstance.prototype, "tenantId", 2);
__decorateClass([
  Property({ name: "organization_id", type: "uuid" })
], WorkflowInstance.prototype, "organizationId", 2);
__decorateClass([
  Property({ name: "created_at", type: Date, onCreate: () => /* @__PURE__ */ new Date() })
], WorkflowInstance.prototype, "createdAt", 2);
__decorateClass([
  Property({ name: "updated_at", type: Date, onUpdate: () => /* @__PURE__ */ new Date() })
], WorkflowInstance.prototype, "updatedAt", 2);
__decorateClass([
  Property({ name: "deleted_at", type: Date, nullable: true })
], WorkflowInstance.prototype, "deletedAt", 2);
WorkflowInstance = __decorateClass([
  Entity({ tableName: "workflow_instances" }),
  Index({ name: "workflow_instances_definition_status_idx", properties: ["definitionId", "status"] }),
  Index({ name: "workflow_instances_correlation_key_idx", properties: ["correlationKey"] }),
  Index({ name: "workflow_instances_status_tenant_idx", properties: ["status", "tenantId"] }),
  Index({ name: "workflow_instances_current_step_idx", properties: ["currentStepId", "status"] }),
  Index({ name: "workflow_instances_tenant_org_idx", properties: ["tenantId", "organizationId"] })
], WorkflowInstance);
OptionalProps;
let WorkflowBranchInstance = class {
  constructor() {
    this.createdAt = /* @__PURE__ */ new Date();
    this.updatedAt = /* @__PURE__ */ new Date();
  }
};
__decorateClass([
  PrimaryKey({ type: "uuid", defaultRaw: "gen_random_uuid()" })
], WorkflowBranchInstance.prototype, "id", 2);
__decorateClass([
  Property({ name: "workflow_instance_id", type: "uuid" })
], WorkflowBranchInstance.prototype, "workflowInstanceId", 2);
__decorateClass([
  Property({ name: "fork_step_id", type: "varchar", length: 100 })
], WorkflowBranchInstance.prototype, "forkStepId", 2);
__decorateClass([
  Property({ name: "join_step_id", type: "varchar", length: 100 })
], WorkflowBranchInstance.prototype, "joinStepId", 2);
__decorateClass([
  Property({ name: "branch_key", type: "varchar", length: 100 })
], WorkflowBranchInstance.prototype, "branchKey", 2);
__decorateClass([
  Property({ name: "parent_branch_id", type: "uuid", nullable: true })
], WorkflowBranchInstance.prototype, "parentBranchId", 2);
__decorateClass([
  Property({ name: "current_step_id", type: "varchar", length: 100 })
], WorkflowBranchInstance.prototype, "currentStepId", 2);
__decorateClass([
  Property({ name: "status", type: "varchar", length: 30 })
], WorkflowBranchInstance.prototype, "status", 2);
__decorateClass([
  Property({ name: "context_namespace", type: "jsonb" })
], WorkflowBranchInstance.prototype, "contextNamespace", 2);
__decorateClass([
  Property({ name: "pending_transition", type: "jsonb", nullable: true })
], WorkflowBranchInstance.prototype, "pendingTransition", 2);
__decorateClass([
  Property({ name: "error_message", type: "text", nullable: true })
], WorkflowBranchInstance.prototype, "errorMessage", 2);
__decorateClass([
  Property({ name: "error_details", type: "jsonb", nullable: true })
], WorkflowBranchInstance.prototype, "errorDetails", 2);
__decorateClass([
  Property({ name: "started_at", type: Date, nullable: true })
], WorkflowBranchInstance.prototype, "startedAt", 2);
__decorateClass([
  Property({ name: "completed_at", type: Date, nullable: true })
], WorkflowBranchInstance.prototype, "completedAt", 2);
__decorateClass([
  Property({ name: "tenant_id", type: "uuid" })
], WorkflowBranchInstance.prototype, "tenantId", 2);
__decorateClass([
  Property({ name: "organization_id", type: "uuid" })
], WorkflowBranchInstance.prototype, "organizationId", 2);
__decorateClass([
  Property({ name: "created_at", type: Date, onCreate: () => /* @__PURE__ */ new Date() })
], WorkflowBranchInstance.prototype, "createdAt", 2);
__decorateClass([
  Property({ name: "updated_at", type: Date, onUpdate: () => /* @__PURE__ */ new Date() })
], WorkflowBranchInstance.prototype, "updatedAt", 2);
WorkflowBranchInstance = __decorateClass([
  Entity({ tableName: "workflow_branch_instances" }),
  Index({ name: "workflow_branch_instances_instance_status_idx", properties: ["workflowInstanceId", "status"] }),
  Index({ name: "workflow_branch_instances_instance_fork_idx", properties: ["workflowInstanceId", "forkStepId"] }),
  Index({ name: "workflow_branch_instances_tenant_org_idx", properties: ["tenantId", "organizationId"] })
], WorkflowBranchInstance);
OptionalProps;
let StepInstance = class {
  constructor() {
    this.retryCount = 0;
    this.createdAt = /* @__PURE__ */ new Date();
    this.updatedAt = /* @__PURE__ */ new Date();
  }
};
__decorateClass([
  PrimaryKey({ type: "uuid", defaultRaw: "gen_random_uuid()" })
], StepInstance.prototype, "id", 2);
__decorateClass([
  Property({ name: "workflow_instance_id", type: "uuid" })
], StepInstance.prototype, "workflowInstanceId", 2);
__decorateClass([
  Property({ name: "branch_instance_id", type: "uuid", nullable: true })
], StepInstance.prototype, "branchInstanceId", 2);
__decorateClass([
  Property({ name: "step_id", type: "varchar", length: 100 })
], StepInstance.prototype, "stepId", 2);
__decorateClass([
  Property({ name: "step_name", type: "varchar", length: 255 })
], StepInstance.prototype, "stepName", 2);
__decorateClass([
  Property({ name: "step_type", type: "varchar", length: 50 })
], StepInstance.prototype, "stepType", 2);
__decorateClass([
  Property({ name: "status", type: "varchar", length: 20 })
], StepInstance.prototype, "status", 2);
__decorateClass([
  Property({ name: "input_data", type: "jsonb", nullable: true })
], StepInstance.prototype, "inputData", 2);
__decorateClass([
  Property({ name: "output_data", type: "jsonb", nullable: true })
], StepInstance.prototype, "outputData", 2);
__decorateClass([
  Property({ name: "error_data", type: "jsonb", nullable: true })
], StepInstance.prototype, "errorData", 2);
__decorateClass([
  Property({ name: "entered_at", type: Date, nullable: true })
], StepInstance.prototype, "enteredAt", 2);
__decorateClass([
  Property({ name: "exited_at", type: Date, nullable: true })
], StepInstance.prototype, "exitedAt", 2);
__decorateClass([
  Property({ name: "execution_time_ms", type: "integer", nullable: true })
], StepInstance.prototype, "executionTimeMs", 2);
__decorateClass([
  Property({ name: "retry_count", type: "integer", default: 0 })
], StepInstance.prototype, "retryCount", 2);
__decorateClass([
  Property({ name: "tenant_id", type: "uuid" })
], StepInstance.prototype, "tenantId", 2);
__decorateClass([
  Property({ name: "organization_id", type: "uuid" })
], StepInstance.prototype, "organizationId", 2);
__decorateClass([
  Property({ name: "created_at", type: Date, onCreate: () => /* @__PURE__ */ new Date() })
], StepInstance.prototype, "createdAt", 2);
__decorateClass([
  Property({ name: "updated_at", type: Date, onUpdate: () => /* @__PURE__ */ new Date() })
], StepInstance.prototype, "updatedAt", 2);
StepInstance = __decorateClass([
  Entity({ tableName: "step_instances" }),
  Index({ name: "step_instances_workflow_instance_idx", properties: ["workflowInstanceId", "status"] }),
  Index({ name: "step_instances_step_id_idx", properties: ["stepId", "status"] }),
  Index({ name: "step_instances_tenant_org_idx", properties: ["tenantId", "organizationId"] })
], StepInstance);
OptionalProps;
let UserTask = class {
  constructor() {
    this.createdAt = /* @__PURE__ */ new Date();
    this.updatedAt = /* @__PURE__ */ new Date();
  }
};
__decorateClass([
  PrimaryKey({ type: "uuid", defaultRaw: "gen_random_uuid()" })
], UserTask.prototype, "id", 2);
__decorateClass([
  Property({ name: "workflow_instance_id", type: "uuid" })
], UserTask.prototype, "workflowInstanceId", 2);
__decorateClass([
  Property({ name: "step_instance_id", type: "uuid" })
], UserTask.prototype, "stepInstanceId", 2);
__decorateClass([
  Property({ name: "branch_instance_id", type: "uuid", nullable: true })
], UserTask.prototype, "branchInstanceId", 2);
__decorateClass([
  Property({ name: "task_name", type: "varchar", length: 255 })
], UserTask.prototype, "taskName", 2);
__decorateClass([
  Property({ name: "description", type: "text", nullable: true })
], UserTask.prototype, "description", 2);
__decorateClass([
  Property({ name: "status", type: "varchar", length: 20 })
], UserTask.prototype, "status", 2);
__decorateClass([
  Property({ name: "form_schema", type: "jsonb", nullable: true })
], UserTask.prototype, "formSchema", 2);
__decorateClass([
  Property({ name: "form_data", type: "jsonb", nullable: true })
], UserTask.prototype, "formData", 2);
__decorateClass([
  Property({ name: "assigned_to", type: "varchar", length: 255, nullable: true })
], UserTask.prototype, "assignedTo", 2);
__decorateClass([
  Property({ name: "assigned_to_roles", type: "text[]", nullable: true })
], UserTask.prototype, "assignedToRoles", 2);
__decorateClass([
  Property({ name: "claimed_by", type: "varchar", length: 255, nullable: true })
], UserTask.prototype, "claimedBy", 2);
__decorateClass([
  Property({ name: "claimed_at", type: Date, nullable: true })
], UserTask.prototype, "claimedAt", 2);
__decorateClass([
  Property({ name: "due_date", type: Date, nullable: true })
], UserTask.prototype, "dueDate", 2);
__decorateClass([
  Property({ name: "escalated_at", type: Date, nullable: true })
], UserTask.prototype, "escalatedAt", 2);
__decorateClass([
  Property({ name: "escalated_to", type: "varchar", length: 255, nullable: true })
], UserTask.prototype, "escalatedTo", 2);
__decorateClass([
  Property({ name: "completed_by", type: "varchar", length: 255, nullable: true })
], UserTask.prototype, "completedBy", 2);
__decorateClass([
  Property({ name: "completed_at", type: Date, nullable: true })
], UserTask.prototype, "completedAt", 2);
__decorateClass([
  Property({ name: "comments", type: "text", nullable: true })
], UserTask.prototype, "comments", 2);
__decorateClass([
  Property({ name: "tenant_id", type: "uuid" })
], UserTask.prototype, "tenantId", 2);
__decorateClass([
  Property({ name: "organization_id", type: "uuid" })
], UserTask.prototype, "organizationId", 2);
__decorateClass([
  Property({ name: "created_at", type: Date, onCreate: () => /* @__PURE__ */ new Date() })
], UserTask.prototype, "createdAt", 2);
__decorateClass([
  Property({ name: "updated_at", type: Date, onUpdate: () => /* @__PURE__ */ new Date() })
], UserTask.prototype, "updatedAt", 2);
UserTask = __decorateClass([
  Entity({ tableName: "user_tasks" }),
  Index({ name: "user_tasks_workflow_instance_idx", properties: ["workflowInstanceId"] }),
  Index({ name: "user_tasks_status_assigned_idx", properties: ["status", "assignedTo"] }),
  Index({ name: "user_tasks_status_due_date_idx", properties: ["status", "dueDate"] }),
  Index({ name: "user_tasks_tenant_org_idx", properties: ["tenantId", "organizationId"] })
], UserTask);
let WorkflowEvent = class {
  constructor() {
    this.occurredAt = /* @__PURE__ */ new Date();
  }
};
__decorateClass([
  PrimaryKey({ type: "bigint", autoincrement: true })
], WorkflowEvent.prototype, "id", 2);
__decorateClass([
  Property({ name: "workflow_instance_id", type: "uuid" })
], WorkflowEvent.prototype, "workflowInstanceId", 2);
__decorateClass([
  Property({ name: "step_instance_id", type: "uuid", nullable: true })
], WorkflowEvent.prototype, "stepInstanceId", 2);
__decorateClass([
  Property({ name: "branch_instance_id", type: "uuid", nullable: true })
], WorkflowEvent.prototype, "branchInstanceId", 2);
__decorateClass([
  Property({ name: "event_type", type: "varchar", length: 50 })
], WorkflowEvent.prototype, "eventType", 2);
__decorateClass([
  Property({ name: "event_data", type: "jsonb" })
], WorkflowEvent.prototype, "eventData", 2);
__decorateClass([
  Property({ name: "occurred_at", type: Date, onCreate: () => /* @__PURE__ */ new Date() })
], WorkflowEvent.prototype, "occurredAt", 2);
__decorateClass([
  Property({ name: "user_id", type: "varchar", length: 255, nullable: true })
], WorkflowEvent.prototype, "userId", 2);
__decorateClass([
  Property({ name: "tenant_id", type: "uuid" })
], WorkflowEvent.prototype, "tenantId", 2);
__decorateClass([
  Property({ name: "organization_id", type: "uuid" })
], WorkflowEvent.prototype, "organizationId", 2);
WorkflowEvent = __decorateClass([
  Entity({ tableName: "workflow_events" }),
  Index({ name: "workflow_events_instance_occurred_idx", properties: ["workflowInstanceId", "occurredAt"] }),
  Index({ name: "workflow_events_event_type_idx", properties: ["eventType", "occurredAt"] }),
  Index({ name: "workflow_events_tenant_org_idx", properties: ["tenantId", "organizationId"] })
], WorkflowEvent);
OptionalProps;
let WorkflowEventTrigger = class {
  constructor() {
    this.enabled = true;
    this.priority = 0;
    this.createdAt = /* @__PURE__ */ new Date();
    this.updatedAt = /* @__PURE__ */ new Date();
  }
};
__decorateClass([
  PrimaryKey({ type: "uuid", defaultRaw: "gen_random_uuid()" })
], WorkflowEventTrigger.prototype, "id", 2);
__decorateClass([
  Property({ name: "name", type: "varchar", length: 255 })
], WorkflowEventTrigger.prototype, "name", 2);
__decorateClass([
  Property({ name: "description", type: "text", nullable: true })
], WorkflowEventTrigger.prototype, "description", 2);
__decorateClass([
  Property({ name: "workflow_definition_id", type: "uuid" })
], WorkflowEventTrigger.prototype, "workflowDefinitionId", 2);
__decorateClass([
  Property({ name: "event_pattern", type: "varchar", length: 255 })
], WorkflowEventTrigger.prototype, "eventPattern", 2);
__decorateClass([
  Property({ name: "config", type: "jsonb", nullable: true })
], WorkflowEventTrigger.prototype, "config", 2);
__decorateClass([
  Property({ name: "enabled", type: "boolean", default: true })
], WorkflowEventTrigger.prototype, "enabled", 2);
__decorateClass([
  Property({ name: "priority", type: "integer", default: 0 })
], WorkflowEventTrigger.prototype, "priority", 2);
__decorateClass([
  Property({ name: "tenant_id", type: "uuid" })
], WorkflowEventTrigger.prototype, "tenantId", 2);
__decorateClass([
  Property({ name: "organization_id", type: "uuid" })
], WorkflowEventTrigger.prototype, "organizationId", 2);
__decorateClass([
  Property({ name: "created_by", type: "varchar", length: 255, nullable: true })
], WorkflowEventTrigger.prototype, "createdBy", 2);
__decorateClass([
  Property({ name: "updated_by", type: "varchar", length: 255, nullable: true })
], WorkflowEventTrigger.prototype, "updatedBy", 2);
__decorateClass([
  Property({ name: "created_at", type: Date, onCreate: () => /* @__PURE__ */ new Date() })
], WorkflowEventTrigger.prototype, "createdAt", 2);
__decorateClass([
  Property({ name: "updated_at", type: Date, onUpdate: () => /* @__PURE__ */ new Date() })
], WorkflowEventTrigger.prototype, "updatedAt", 2);
__decorateClass([
  Property({ name: "deleted_at", type: Date, nullable: true })
], WorkflowEventTrigger.prototype, "deletedAt", 2);
WorkflowEventTrigger = __decorateClass([
  Entity({ tableName: "workflow_event_triggers" }),
  Index({ name: "workflow_event_triggers_event_pattern_idx", properties: ["eventPattern", "enabled"] }),
  Index({ name: "workflow_event_triggers_definition_idx", properties: ["workflowDefinitionId"] }),
  Index({ name: "workflow_event_triggers_tenant_org_idx", properties: ["tenantId", "organizationId"] }),
  Index({ name: "workflow_event_triggers_enabled_priority_idx", properties: ["enabled", "priority"] })
], WorkflowEventTrigger);
var entities_default = [
  WorkflowDefinition,
  WorkflowInstance,
  WorkflowBranchInstance,
  StepInstance,
  UserTask,
  WorkflowEvent,
  WorkflowEventTrigger
];
export {
  StepInstance,
  UserTask,
  WorkflowBranchInstance,
  WorkflowDefinition,
  WorkflowEvent,
  WorkflowEventTrigger,
  WorkflowInstance,
  entities_default as default
};
//# sourceMappingURL=entities.js.map
