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 Perspective = class {
  constructor() {
    this.isDefault = false;
    this.createdAt = /* @__PURE__ */ new Date();
  }
};
__decorateClass([
  PrimaryKey({ type: "uuid", defaultRaw: "gen_random_uuid()" })
], Perspective.prototype, "id", 2);
__decorateClass([
  Property({ name: "user_id", type: "uuid" })
], Perspective.prototype, "userId", 2);
__decorateClass([
  Property({ name: "tenant_id", type: "uuid", nullable: true })
], Perspective.prototype, "tenantId", 2);
__decorateClass([
  Property({ name: "organization_id", type: "uuid", nullable: true })
], Perspective.prototype, "organizationId", 2);
__decorateClass([
  Property({ name: "table_id", type: "text" })
], Perspective.prototype, "tableId", 2);
__decorateClass([
  Property({ type: "text" })
], Perspective.prototype, "name", 2);
__decorateClass([
  Property({ name: "settings_json", type: "json" })
], Perspective.prototype, "settingsJson", 2);
__decorateClass([
  Property({ name: "is_default", type: "boolean", default: false })
], Perspective.prototype, "isDefault", 2);
__decorateClass([
  Property({ name: "created_at", type: Date, onCreate: () => /* @__PURE__ */ new Date() })
], Perspective.prototype, "createdAt", 2);
__decorateClass([
  Property({ name: "updated_at", type: Date, onUpdate: () => /* @__PURE__ */ new Date(), nullable: true })
], Perspective.prototype, "updatedAt", 2);
__decorateClass([
  Property({ name: "deleted_at", type: Date, nullable: true })
], Perspective.prototype, "deletedAt", 2);
Perspective = __decorateClass([
  Entity({ tableName: "perspectives" }),
  Index({ name: "perspectives_user_scope_idx", properties: ["userId", "tenantId", "organizationId", "tableId"] }),
  Index({
    name: "perspectives_live_user_org_uq",
    expression: 'create unique index "perspectives_live_user_org_uq" on "perspectives" ("user_id", "tenant_id", "organization_id", "table_id", "name") where "deleted_at" is null and "tenant_id" is not null and "organization_id" is not null'
  }),
  Index({
    name: "perspectives_live_user_tenant_uq",
    expression: 'create unique index "perspectives_live_user_tenant_uq" on "perspectives" ("user_id", "tenant_id", "table_id", "name") where "deleted_at" is null and "tenant_id" is not null and "organization_id" is null'
  }),
  Index({
    name: "perspectives_live_user_org_only_uq",
    expression: 'create unique index "perspectives_live_user_org_only_uq" on "perspectives" ("user_id", "organization_id", "table_id", "name") where "deleted_at" is null and "tenant_id" is null and "organization_id" is not null'
  }),
  Index({
    name: "perspectives_live_user_global_uq",
    expression: 'create unique index "perspectives_live_user_global_uq" on "perspectives" ("user_id", "table_id", "name") where "deleted_at" is null and "tenant_id" is null and "organization_id" is null'
  })
], Perspective);
let RolePerspective = class {
  constructor() {
    this.isDefault = false;
    this.createdAt = /* @__PURE__ */ new Date();
  }
};
__decorateClass([
  PrimaryKey({ type: "uuid", defaultRaw: "gen_random_uuid()" })
], RolePerspective.prototype, "id", 2);
__decorateClass([
  Property({ name: "role_id", type: "uuid" })
], RolePerspective.prototype, "roleId", 2);
__decorateClass([
  Property({ name: "tenant_id", type: "uuid", nullable: true })
], RolePerspective.prototype, "tenantId", 2);
__decorateClass([
  Property({ name: "organization_id", type: "uuid", nullable: true })
], RolePerspective.prototype, "organizationId", 2);
__decorateClass([
  Property({ name: "table_id", type: "text" })
], RolePerspective.prototype, "tableId", 2);
__decorateClass([
  Property({ type: "text" })
], RolePerspective.prototype, "name", 2);
__decorateClass([
  Property({ name: "settings_json", type: "json" })
], RolePerspective.prototype, "settingsJson", 2);
__decorateClass([
  Property({ name: "is_default", type: "boolean", default: false })
], RolePerspective.prototype, "isDefault", 2);
__decorateClass([
  Property({ name: "created_at", type: Date, onCreate: () => /* @__PURE__ */ new Date() })
], RolePerspective.prototype, "createdAt", 2);
__decorateClass([
  Property({ name: "updated_at", type: Date, onUpdate: () => /* @__PURE__ */ new Date(), nullable: true })
], RolePerspective.prototype, "updatedAt", 2);
__decorateClass([
  Property({ name: "deleted_at", type: Date, nullable: true })
], RolePerspective.prototype, "deletedAt", 2);
RolePerspective = __decorateClass([
  Entity({ tableName: "role_perspectives" }),
  Index({ name: "role_perspectives_role_scope_idx", properties: ["roleId", "tenantId", "organizationId", "tableId"] }),
  Index({
    name: "role_perspectives_live_role_org_uq",
    expression: 'create unique index "role_perspectives_live_role_org_uq" on "role_perspectives" ("role_id", "tenant_id", "organization_id", "table_id", "name") where "deleted_at" is null and "tenant_id" is not null and "organization_id" is not null'
  }),
  Index({
    name: "role_perspectives_live_role_tenant_uq",
    expression: 'create unique index "role_perspectives_live_role_tenant_uq" on "role_perspectives" ("role_id", "tenant_id", "table_id", "name") where "deleted_at" is null and "tenant_id" is not null and "organization_id" is null'
  }),
  Index({
    name: "role_perspectives_live_role_org_only_uq",
    expression: 'create unique index "role_perspectives_live_role_org_only_uq" on "role_perspectives" ("role_id", "organization_id", "table_id", "name") where "deleted_at" is null and "tenant_id" is null and "organization_id" is not null'
  }),
  Index({
    name: "role_perspectives_live_role_global_uq",
    expression: 'create unique index "role_perspectives_live_role_global_uq" on "role_perspectives" ("role_id", "table_id", "name") where "deleted_at" is null and "tenant_id" is null and "organization_id" is null'
  })
], RolePerspective);
export {
  Perspective,
  RolePerspective
};
//# sourceMappingURL=entities.js.map
