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 CustomFieldDef = class {
  constructor() {
    this.isActive = true;
    this.createdAt = /* @__PURE__ */ new Date();
    this.updatedAt = /* @__PURE__ */ new Date();
  }
};
__decorateClass([
  PrimaryKey({ type: "uuid", defaultRaw: "gen_random_uuid()" })
], CustomFieldDef.prototype, "id", 2);
__decorateClass([
  Property({ name: "entity_id", type: "text" })
], CustomFieldDef.prototype, "entityId", 2);
__decorateClass([
  Property({ name: "organization_id", type: "uuid", nullable: true })
], CustomFieldDef.prototype, "organizationId", 2);
__decorateClass([
  Property({ name: "tenant_id", type: "uuid", nullable: true })
], CustomFieldDef.prototype, "tenantId", 2);
__decorateClass([
  Property({ type: "text" }),
  Index({ name: "cf_defs_entity_key_idx" })
], CustomFieldDef.prototype, "key", 2);
__decorateClass([
  Property({ type: "text" })
], CustomFieldDef.prototype, "kind", 2);
__decorateClass([
  Property({ name: "config_json", type: "json", nullable: true })
], CustomFieldDef.prototype, "configJson", 2);
__decorateClass([
  Property({ name: "is_active", type: "boolean", default: true })
], CustomFieldDef.prototype, "isActive", 2);
__decorateClass([
  Property({ name: "created_at", type: Date, onCreate: () => /* @__PURE__ */ new Date() })
], CustomFieldDef.prototype, "createdAt", 2);
__decorateClass([
  Property({ name: "updated_at", type: Date, onUpdate: () => /* @__PURE__ */ new Date() })
], CustomFieldDef.prototype, "updatedAt", 2);
__decorateClass([
  Property({ name: "deleted_at", type: Date, nullable: true })
], CustomFieldDef.prototype, "deletedAt", 2);
CustomFieldDef = __decorateClass([
  Entity({ tableName: "custom_field_defs" }),
  Index({
    name: "cf_defs_entity_tenant_org_idx",
    properties: ["entityId", "tenantId", "organizationId"]
  }),
  Index({
    name: "cf_defs_entity_tenant_idx",
    properties: ["entityId", "tenantId"]
  }),
  Index({
    name: "cf_defs_entity_org_idx",
    properties: ["entityId", "organizationId"]
  }),
  Index({
    name: "cf_defs_entity_global_idx",
    properties: ["entityId"]
  }),
  Index({
    name: "cf_defs_entity_key_scope_idx",
    properties: ["entityId", "key", "tenantId", "organizationId"]
  })
], CustomFieldDef);
let CustomFieldEntityConfig = class {
  constructor() {
    this.isActive = true;
    this.createdAt = /* @__PURE__ */ new Date();
    this.updatedAt = /* @__PURE__ */ new Date();
  }
};
__decorateClass([
  PrimaryKey({ type: "uuid", defaultRaw: "gen_random_uuid()" })
], CustomFieldEntityConfig.prototype, "id", 2);
__decorateClass([
  Property({ name: "entity_id", type: "text" })
], CustomFieldEntityConfig.prototype, "entityId", 2);
__decorateClass([
  Property({ name: "organization_id", type: "uuid", nullable: true })
], CustomFieldEntityConfig.prototype, "organizationId", 2);
__decorateClass([
  Property({ name: "tenant_id", type: "uuid", nullable: true })
], CustomFieldEntityConfig.prototype, "tenantId", 2);
__decorateClass([
  Property({ name: "config_json", type: "jsonb", nullable: true })
], CustomFieldEntityConfig.prototype, "configJson", 2);
__decorateClass([
  Property({ name: "is_active", type: "boolean", default: true })
], CustomFieldEntityConfig.prototype, "isActive", 2);
__decorateClass([
  Property({ name: "created_at", type: Date, onCreate: () => /* @__PURE__ */ new Date() })
], CustomFieldEntityConfig.prototype, "createdAt", 2);
__decorateClass([
  Property({ name: "updated_at", type: Date, onUpdate: () => /* @__PURE__ */ new Date() })
], CustomFieldEntityConfig.prototype, "updatedAt", 2);
__decorateClass([
  Property({ name: "deleted_at", type: Date, nullable: true })
], CustomFieldEntityConfig.prototype, "deletedAt", 2);
CustomFieldEntityConfig = __decorateClass([
  Entity({ tableName: "custom_field_entity_configs" }),
  Index({
    name: "cf_entity_cfgs_entity_scope_idx",
    properties: ["entityId", "tenantId", "organizationId"]
  }),
  Index({
    name: "cf_entity_cfgs_entity_tenant_idx",
    properties: ["entityId", "tenantId"]
  }),
  Index({
    name: "cf_entity_cfgs_entity_org_idx",
    properties: ["entityId", "organizationId"]
  })
], CustomFieldEntityConfig);
let CustomEntity = class {
  constructor() {
    this.showInSidebar = false;
    this.isActive = true;
    this.createdAt = /* @__PURE__ */ new Date();
    this.updatedAt = /* @__PURE__ */ new Date();
  }
};
__decorateClass([
  PrimaryKey({ type: "uuid", defaultRaw: "gen_random_uuid()" })
], CustomEntity.prototype, "id", 2);
__decorateClass([
  Property({ name: "entity_id", type: "text" })
], CustomEntity.prototype, "entityId", 2);
__decorateClass([
  Property({ type: "text" })
], CustomEntity.prototype, "label", 2);
__decorateClass([
  Property({ type: "text", nullable: true })
], CustomEntity.prototype, "description", 2);
__decorateClass([
  Property({ name: "label_field", type: "text", nullable: true })
], CustomEntity.prototype, "labelField", 2);
__decorateClass([
  Property({ name: "default_editor", type: "text", nullable: true })
], CustomEntity.prototype, "defaultEditor", 2);
__decorateClass([
  Property({ name: "show_in_sidebar", type: "boolean", default: false })
], CustomEntity.prototype, "showInSidebar", 2);
__decorateClass([
  Property({ name: "organization_id", type: "uuid", nullable: true })
], CustomEntity.prototype, "organizationId", 2);
__decorateClass([
  Property({ name: "tenant_id", type: "uuid", nullable: true })
], CustomEntity.prototype, "tenantId", 2);
__decorateClass([
  Property({ name: "is_active", type: "boolean", default: true })
], CustomEntity.prototype, "isActive", 2);
__decorateClass([
  Property({ name: "created_at", type: Date, onCreate: () => /* @__PURE__ */ new Date() })
], CustomEntity.prototype, "createdAt", 2);
__decorateClass([
  Property({ name: "updated_at", type: Date, onUpdate: () => /* @__PURE__ */ new Date() })
], CustomEntity.prototype, "updatedAt", 2);
__decorateClass([
  Property({ name: "deleted_at", type: Date, nullable: true })
], CustomEntity.prototype, "deletedAt", 2);
CustomEntity = __decorateClass([
  Entity({ tableName: "custom_entities" }),
  Index({ name: "custom_entities_unique_idx", properties: ["entityId", "organizationId", "tenantId"], options: { unique: true } })
], CustomEntity);
let CustomEntityStorage = class {
  constructor() {
    this.createdAt = /* @__PURE__ */ new Date();
    this.updatedAt = /* @__PURE__ */ new Date();
  }
};
__decorateClass([
  PrimaryKey({ type: "uuid", defaultRaw: "gen_random_uuid()" })
], CustomEntityStorage.prototype, "id", 2);
__decorateClass([
  Property({ name: "entity_type", type: "text" })
], CustomEntityStorage.prototype, "entityType", 2);
__decorateClass([
  Property({ name: "entity_id", type: "text" })
], CustomEntityStorage.prototype, "entityId", 2);
__decorateClass([
  Property({ name: "organization_id", type: "uuid", nullable: true })
], CustomEntityStorage.prototype, "organizationId", 2);
__decorateClass([
  Property({ name: "tenant_id", type: "uuid", nullable: true })
], CustomEntityStorage.prototype, "tenantId", 2);
__decorateClass([
  Property({ name: "doc", type: "json" })
], CustomEntityStorage.prototype, "doc", 2);
__decorateClass([
  Property({ name: "created_at", type: Date, onCreate: () => /* @__PURE__ */ new Date() })
], CustomEntityStorage.prototype, "createdAt", 2);
__decorateClass([
  Property({ name: "updated_at", type: Date, onUpdate: () => /* @__PURE__ */ new Date() })
], CustomEntityStorage.prototype, "updatedAt", 2);
__decorateClass([
  Property({ name: "deleted_at", type: Date, nullable: true })
], CustomEntityStorage.prototype, "deletedAt", 2);
CustomEntityStorage = __decorateClass([
  Entity({ tableName: "custom_entities_storage" }),
  Index({ name: "custom_entities_storage_unique_idx", properties: ["entityType", "entityId", "organizationId"], options: { unique: true } })
], CustomEntityStorage);
let CustomFieldValue = class {
  constructor() {
    this.createdAt = /* @__PURE__ */ new Date();
  }
};
__decorateClass([
  PrimaryKey({ type: "uuid", defaultRaw: "gen_random_uuid()" })
], CustomFieldValue.prototype, "id", 2);
__decorateClass([
  Property({ name: "entity_id", type: "text" })
], CustomFieldValue.prototype, "entityId", 2);
__decorateClass([
  Property({ name: "record_id", type: "text" })
], CustomFieldValue.prototype, "recordId", 2);
__decorateClass([
  Property({ name: "organization_id", type: "uuid", nullable: true })
], CustomFieldValue.prototype, "organizationId", 2);
__decorateClass([
  Property({ name: "tenant_id", type: "uuid", nullable: true })
], CustomFieldValue.prototype, "tenantId", 2);
__decorateClass([
  Property({ name: "field_key", type: "text" }),
  Index({ name: "cf_values_entity_record_field_idx" })
], CustomFieldValue.prototype, "fieldKey", 2);
__decorateClass([
  Property({ name: "value_text", type: "text", nullable: true })
], CustomFieldValue.prototype, "valueText", 2);
__decorateClass([
  Property({ name: "value_multiline", type: "text", nullable: true })
], CustomFieldValue.prototype, "valueMultiline", 2);
__decorateClass([
  Property({ name: "value_int", type: "int", nullable: true })
], CustomFieldValue.prototype, "valueInt", 2);
__decorateClass([
  Property({ name: "value_float", type: "float", nullable: true })
], CustomFieldValue.prototype, "valueFloat", 2);
__decorateClass([
  Property({ name: "value_bool", type: "boolean", nullable: true })
], CustomFieldValue.prototype, "valueBool", 2);
__decorateClass([
  Property({ name: "created_at", type: Date, onCreate: () => /* @__PURE__ */ new Date() })
], CustomFieldValue.prototype, "createdAt", 2);
__decorateClass([
  Property({ name: "deleted_at", type: Date, nullable: true })
], CustomFieldValue.prototype, "deletedAt", 2);
CustomFieldValue = __decorateClass([
  Entity({ tableName: "custom_field_values" }),
  Index({
    name: "cf_values_entity_record_tenant_idx",
    properties: ["entityId", "recordId", "tenantId"]
  })
], CustomFieldValue);
let EncryptionMap = class {
  constructor() {
    this.isActive = true;
    this.createdAt = /* @__PURE__ */ new Date();
    this.updatedAt = /* @__PURE__ */ new Date();
  }
};
__decorateClass([
  PrimaryKey({ type: "uuid", defaultRaw: "gen_random_uuid()" })
], EncryptionMap.prototype, "id", 2);
__decorateClass([
  Property({ name: "entity_id", type: "text" })
], EncryptionMap.prototype, "entityId", 2);
__decorateClass([
  Property({ name: "tenant_id", type: "uuid", nullable: true })
], EncryptionMap.prototype, "tenantId", 2);
__decorateClass([
  Property({ name: "organization_id", type: "uuid", nullable: true })
], EncryptionMap.prototype, "organizationId", 2);
__decorateClass([
  Property({ name: "fields_json", type: "jsonb", nullable: true })
], EncryptionMap.prototype, "fieldsJson", 2);
__decorateClass([
  Property({ name: "is_active", type: "boolean", default: true })
], EncryptionMap.prototype, "isActive", 2);
__decorateClass([
  Property({ name: "created_at", type: Date, onCreate: () => /* @__PURE__ */ new Date() })
], EncryptionMap.prototype, "createdAt", 2);
__decorateClass([
  Property({ name: "updated_at", type: Date, onUpdate: () => /* @__PURE__ */ new Date() })
], EncryptionMap.prototype, "updatedAt", 2);
__decorateClass([
  Property({ name: "deleted_at", type: Date, nullable: true })
], EncryptionMap.prototype, "deletedAt", 2);
EncryptionMap = __decorateClass([
  Entity({ tableName: "encryption_maps" }),
  Index({
    name: "encryption_maps_entity_scope_idx",
    properties: ["entityId", "tenantId", "organizationId"]
  })
], EncryptionMap);
export {
  CustomEntity,
  CustomEntityStorage,
  CustomFieldDef,
  CustomFieldEntityConfig,
  CustomFieldValue,
  EncryptionMap
};
//# sourceMappingURL=entities.js.map
