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, Unique } from "@mikro-orm/decorators/legacy";
let ApiKey = class {
  constructor() {
    this.createdAt = /* @__PURE__ */ new Date();
  }
};
__decorateClass([
  PrimaryKey({ type: "uuid", defaultRaw: "gen_random_uuid()" })
], ApiKey.prototype, "id", 2);
__decorateClass([
  Property({ type: "text" })
], ApiKey.prototype, "name", 2);
__decorateClass([
  Property({ name: "description", type: "text", nullable: true })
], ApiKey.prototype, "description", 2);
__decorateClass([
  Property({ name: "tenant_id", type: "uuid", nullable: true })
], ApiKey.prototype, "tenantId", 2);
__decorateClass([
  Property({ name: "organization_id", type: "uuid", nullable: true })
], ApiKey.prototype, "organizationId", 2);
__decorateClass([
  Property({ name: "key_hash", type: "text" })
], ApiKey.prototype, "keyHash", 2);
__decorateClass([
  Property({ name: "key_prefix", type: "text" })
], ApiKey.prototype, "keyPrefix", 2);
__decorateClass([
  Property({ name: "roles_json", type: "json", nullable: true })
], ApiKey.prototype, "rolesJson", 2);
__decorateClass([
  Property({ name: "created_by", type: "uuid", nullable: true })
], ApiKey.prototype, "createdBy", 2);
__decorateClass([
  Property({ name: "session_token", type: "text", nullable: true })
], ApiKey.prototype, "sessionToken", 2);
__decorateClass([
  Property({ name: "session_user_id", type: "uuid", nullable: true })
], ApiKey.prototype, "sessionUserId", 2);
__decorateClass([
  Property({ name: "session_secret_encrypted", type: "text", nullable: true })
], ApiKey.prototype, "sessionSecretEncrypted", 2);
__decorateClass([
  Property({ name: "opencode_session_id", type: "text", nullable: true })
], ApiKey.prototype, "opencodeSessionId", 2);
__decorateClass([
  Property({ name: "last_used_at", type: Date, nullable: true })
], ApiKey.prototype, "lastUsedAt", 2);
__decorateClass([
  Property({ name: "expires_at", type: Date, nullable: true })
], ApiKey.prototype, "expiresAt", 2);
__decorateClass([
  Property({ name: "created_at", type: Date, onCreate: () => /* @__PURE__ */ new Date() })
], ApiKey.prototype, "createdAt", 2);
__decorateClass([
  Property({ name: "updated_at", type: Date, onUpdate: () => /* @__PURE__ */ new Date(), nullable: true })
], ApiKey.prototype, "updatedAt", 2);
__decorateClass([
  Property({ name: "deleted_at", type: Date, nullable: true })
], ApiKey.prototype, "deletedAt", 2);
ApiKey = __decorateClass([
  Entity({ tableName: "api_keys" }),
  Unique({ properties: ["keyPrefix"] }),
  Index({
    name: "api_keys_opencode_session_id_uq",
    expression: 'create unique index "api_keys_opencode_session_id_uq" on "api_keys" ("opencode_session_id") where "opencode_session_id" is not null and "deleted_at" is null'
  })
], ApiKey);
export {
  ApiKey
};
//# sourceMappingURL=entities.js.map
