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 { Entity, Index, PrimaryKey, Property } from "@mikro-orm/decorators/legacy";
let ActionLog = class {
  constructor() {
    this.tenantId = null;
    this.organizationId = null;
    this.actorUserId = null;
    this.actionLabel = null;
    this.actionType = null;
    this.resourceKind = null;
    this.resourceId = null;
    this.parentResourceKind = null;
    this.parentResourceId = null;
    this.executionState = "done";
    this.undoToken = null;
    this.commandPayload = null;
    this.snapshotBefore = null;
    this.snapshotAfter = null;
    this.changesJson = null;
    this.changedFields = null;
    this.primaryChangedField = null;
    this.contextJson = null;
    this.sourceKey = null;
    this.relatedResourceKind = null;
    this.relatedResourceId = null;
    this.createdAt = /* @__PURE__ */ new Date();
    this.updatedAt = /* @__PURE__ */ new Date();
    this.deletedAt = null;
  }
};
__decorateClass([
  PrimaryKey({ type: "uuid", defaultRaw: "gen_random_uuid()" })
], ActionLog.prototype, "id", 2);
__decorateClass([
  Property({ name: "tenant_id", type: "uuid", nullable: true })
], ActionLog.prototype, "tenantId", 2);
__decorateClass([
  Property({ name: "organization_id", type: "uuid", nullable: true })
], ActionLog.prototype, "organizationId", 2);
__decorateClass([
  Property({ name: "actor_user_id", type: "uuid", nullable: true })
], ActionLog.prototype, "actorUserId", 2);
__decorateClass([
  Property({ name: "command_id", type: "text" })
], ActionLog.prototype, "commandId", 2);
__decorateClass([
  Property({ name: "action_label", type: "text", nullable: true })
], ActionLog.prototype, "actionLabel", 2);
__decorateClass([
  Property({ name: "action_type", type: "text", nullable: true })
], ActionLog.prototype, "actionType", 2);
__decorateClass([
  Property({ name: "resource_kind", type: "text", nullable: true })
], ActionLog.prototype, "resourceKind", 2);
__decorateClass([
  Property({ name: "resource_id", type: "text", nullable: true })
], ActionLog.prototype, "resourceId", 2);
__decorateClass([
  Property({ name: "parent_resource_kind", type: "text", nullable: true })
], ActionLog.prototype, "parentResourceKind", 2);
__decorateClass([
  Property({ name: "parent_resource_id", type: "text", nullable: true })
], ActionLog.prototype, "parentResourceId", 2);
__decorateClass([
  Property({ name: "execution_state", type: "text", default: "done" })
], ActionLog.prototype, "executionState", 2);
__decorateClass([
  Property({ name: "undo_token", type: "text", nullable: true })
], ActionLog.prototype, "undoToken", 2);
__decorateClass([
  Property({ name: "command_payload", type: "jsonb", nullable: true })
], ActionLog.prototype, "commandPayload", 2);
__decorateClass([
  Property({ name: "snapshot_before", type: "jsonb", nullable: true })
], ActionLog.prototype, "snapshotBefore", 2);
__decorateClass([
  Property({ name: "snapshot_after", type: "jsonb", nullable: true })
], ActionLog.prototype, "snapshotAfter", 2);
__decorateClass([
  Property({ name: "changes_json", type: "jsonb", nullable: true })
], ActionLog.prototype, "changesJson", 2);
__decorateClass([
  Property({ name: "changed_fields", type: "text[]", nullable: true })
], ActionLog.prototype, "changedFields", 2);
__decorateClass([
  Property({ name: "primary_changed_field", type: "text", nullable: true })
], ActionLog.prototype, "primaryChangedField", 2);
__decorateClass([
  Property({ name: "context_json", type: "jsonb", nullable: true })
], ActionLog.prototype, "contextJson", 2);
__decorateClass([
  Property({ name: "source_key", type: "text", nullable: true })
], ActionLog.prototype, "sourceKey", 2);
__decorateClass([
  Property({ name: "related_resource_kind", type: "text", nullable: true })
], ActionLog.prototype, "relatedResourceKind", 2);
__decorateClass([
  Property({ name: "related_resource_id", type: "text", nullable: true })
], ActionLog.prototype, "relatedResourceId", 2);
__decorateClass([
  Property({ name: "created_at", type: Date, onCreate: () => /* @__PURE__ */ new Date() })
], ActionLog.prototype, "createdAt", 2);
__decorateClass([
  Property({ name: "updated_at", type: Date, onUpdate: () => /* @__PURE__ */ new Date() })
], ActionLog.prototype, "updatedAt", 2);
__decorateClass([
  Property({ name: "deleted_at", type: Date, nullable: true })
], ActionLog.prototype, "deletedAt", 2);
ActionLog = __decorateClass([
  Entity({ tableName: "action_logs" }),
  Index({ name: "action_logs_tenant_idx", properties: ["tenantId", "createdAt"] }),
  Index({ name: "action_logs_actor_idx", properties: ["actorUserId", "createdAt"] }),
  Index({ name: "action_logs_resource_idx", properties: ["tenantId", "resourceKind", "resourceId", "createdAt"] }),
  Index({ name: "action_logs_parent_resource_idx", properties: ["tenantId", "parentResourceKind", "parentResourceId", "createdAt"] }),
  Index({ name: "action_logs_action_type_idx", properties: ["tenantId", "organizationId", "actionType", "createdAt"] }),
  Index({ name: "action_logs_source_key_idx", properties: ["tenantId", "organizationId", "sourceKey", "createdAt"] }),
  Index({ name: "action_logs_primary_changed_field_idx", properties: ["tenantId", "organizationId", "primaryChangedField", "createdAt"] }),
  Index({ name: "action_logs_changed_fields_idx", properties: ["changedFields"], type: "gin" }),
  Index({ name: "action_logs_related_resource_idx", properties: ["tenantId", "relatedResourceKind", "relatedResourceId", "createdAt"] })
], ActionLog);
let AccessLog = class {
  constructor() {
    this.tenantId = null;
    this.organizationId = null;
    this.actorUserId = null;
    this.fieldsJson = null;
    this.contextJson = null;
    this.createdAt = /* @__PURE__ */ new Date();
    this.deletedAt = null;
  }
};
__decorateClass([
  PrimaryKey({ type: "uuid", defaultRaw: "gen_random_uuid()" })
], AccessLog.prototype, "id", 2);
__decorateClass([
  Property({ name: "tenant_id", type: "uuid", nullable: true })
], AccessLog.prototype, "tenantId", 2);
__decorateClass([
  Property({ name: "organization_id", type: "uuid", nullable: true })
], AccessLog.prototype, "organizationId", 2);
__decorateClass([
  Property({ name: "actor_user_id", type: "uuid", nullable: true })
], AccessLog.prototype, "actorUserId", 2);
__decorateClass([
  Property({ name: "resource_kind", type: "text" })
], AccessLog.prototype, "resourceKind", 2);
__decorateClass([
  Property({ name: "resource_id", type: "text" })
], AccessLog.prototype, "resourceId", 2);
__decorateClass([
  Property({ name: "access_type", type: "text" })
], AccessLog.prototype, "accessType", 2);
__decorateClass([
  Property({ name: "fields_json", type: "jsonb", nullable: true })
], AccessLog.prototype, "fieldsJson", 2);
__decorateClass([
  Property({ name: "context_json", type: "jsonb", nullable: true })
], AccessLog.prototype, "contextJson", 2);
__decorateClass([
  Property({ name: "created_at", type: Date, onCreate: () => /* @__PURE__ */ new Date() })
], AccessLog.prototype, "createdAt", 2);
__decorateClass([
  Property({ name: "deleted_at", type: Date, nullable: true })
], AccessLog.prototype, "deletedAt", 2);
AccessLog = __decorateClass([
  Entity({ tableName: "access_logs" }),
  Index({ name: "access_logs_tenant_idx", properties: ["tenantId", "createdAt"] }),
  Index({ name: "access_logs_actor_idx", properties: ["actorUserId", "createdAt"] }),
  Index({ name: "access_logs_created_at_idx", properties: ["createdAt"] })
], AccessLog);
export {
  AccessLog,
  ActionLog
};
//# sourceMappingURL=entities.js.map
