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 } from "@mikro-orm/decorators/legacy";
OptionalProps;
let SyncExternalIdMapping = class {
  constructor() {
    this.syncStatus = "not_synced";
    this.createdAt = /* @__PURE__ */ new Date();
    this.updatedAt = /* @__PURE__ */ new Date();
  }
};
__decorateClass([
  PrimaryKey({ type: "uuid", defaultRaw: "gen_random_uuid()" })
], SyncExternalIdMapping.prototype, "id", 2);
__decorateClass([
  Property({ name: "integration_id", type: "text" })
], SyncExternalIdMapping.prototype, "integrationId", 2);
__decorateClass([
  Property({ name: "internal_entity_type", type: "text" })
], SyncExternalIdMapping.prototype, "internalEntityType", 2);
__decorateClass([
  Property({ name: "internal_entity_id", type: "uuid" })
], SyncExternalIdMapping.prototype, "internalEntityId", 2);
__decorateClass([
  Property({ name: "external_id", type: "text" })
], SyncExternalIdMapping.prototype, "externalId", 2);
__decorateClass([
  Property({ name: "sync_status", type: "text", default: "not_synced" })
], SyncExternalIdMapping.prototype, "syncStatus", 2);
__decorateClass([
  Property({ name: "last_synced_at", type: Date, nullable: true })
], SyncExternalIdMapping.prototype, "lastSyncedAt", 2);
__decorateClass([
  Property({ name: "organization_id", type: "uuid" })
], SyncExternalIdMapping.prototype, "organizationId", 2);
__decorateClass([
  Property({ name: "tenant_id", type: "uuid" })
], SyncExternalIdMapping.prototype, "tenantId", 2);
__decorateClass([
  Property({ name: "created_at", type: Date, onCreate: () => /* @__PURE__ */ new Date() })
], SyncExternalIdMapping.prototype, "createdAt", 2);
__decorateClass([
  Property({ name: "updated_at", type: Date, onUpdate: () => /* @__PURE__ */ new Date() })
], SyncExternalIdMapping.prototype, "updatedAt", 2);
__decorateClass([
  Property({ name: "deleted_at", type: Date, nullable: true })
], SyncExternalIdMapping.prototype, "deletedAt", 2);
SyncExternalIdMapping = __decorateClass([
  Entity({ tableName: "sync_external_id_mappings" }),
  Index({ properties: ["internalEntityType", "internalEntityId", "organizationId"] }),
  Index({ properties: ["integrationId", "externalId", "organizationId"] })
], SyncExternalIdMapping);
OptionalProps;
let IntegrationCredentials = class {
  constructor() {
    this.createdAt = /* @__PURE__ */ new Date();
    this.updatedAt = /* @__PURE__ */ new Date();
  }
};
__decorateClass([
  PrimaryKey({ type: "uuid", defaultRaw: "gen_random_uuid()" })
], IntegrationCredentials.prototype, "id", 2);
__decorateClass([
  Property({ name: "integration_id", type: "text" })
], IntegrationCredentials.prototype, "integrationId", 2);
__decorateClass([
  Property({ name: "credentials", type: "json" })
], IntegrationCredentials.prototype, "credentials", 2);
__decorateClass([
  Property({ name: "organization_id", type: "uuid" })
], IntegrationCredentials.prototype, "organizationId", 2);
__decorateClass([
  Property({ name: "tenant_id", type: "uuid" })
], IntegrationCredentials.prototype, "tenantId", 2);
__decorateClass([
  Property({ name: "user_id", type: "uuid", nullable: true })
], IntegrationCredentials.prototype, "userId", 2);
__decorateClass([
  Property({ name: "created_at", type: Date, onCreate: () => /* @__PURE__ */ new Date() })
], IntegrationCredentials.prototype, "createdAt", 2);
__decorateClass([
  Property({ name: "updated_at", type: Date, onCreate: () => /* @__PURE__ */ new Date(), onUpdate: () => /* @__PURE__ */ new Date() })
], IntegrationCredentials.prototype, "updatedAt", 2);
__decorateClass([
  Property({ name: "deleted_at", type: Date, nullable: true })
], IntegrationCredentials.prototype, "deletedAt", 2);
IntegrationCredentials = __decorateClass([
  Entity({ tableName: "integration_credentials" }),
  Index({ properties: ["integrationId", "organizationId", "tenantId"] }),
  Index({
    name: "integration_credentials_user_lookup_idx",
    expression: `create unique index "integration_credentials_user_lookup_idx" on "integration_credentials" ("integration_id", "organization_id", "tenant_id", "user_id") where "user_id" is not null and "deleted_at" is null`
  })
], IntegrationCredentials);
OptionalProps;
let IntegrationState = class {
  constructor() {
    this.isEnabled = true;
    this.reauthRequired = false;
    this.createdAt = /* @__PURE__ */ new Date();
    this.updatedAt = /* @__PURE__ */ new Date();
  }
};
__decorateClass([
  PrimaryKey({ type: "uuid", defaultRaw: "gen_random_uuid()" })
], IntegrationState.prototype, "id", 2);
__decorateClass([
  Property({ name: "integration_id", type: "text" })
], IntegrationState.prototype, "integrationId", 2);
__decorateClass([
  Property({ name: "is_enabled", type: "boolean", default: true })
], IntegrationState.prototype, "isEnabled", 2);
__decorateClass([
  Property({ name: "api_version", type: "text", nullable: true })
], IntegrationState.prototype, "apiVersion", 2);
__decorateClass([
  Property({ name: "reauth_required", type: "boolean", default: false })
], IntegrationState.prototype, "reauthRequired", 2);
__decorateClass([
  Property({ name: "last_health_status", type: "text", nullable: true })
], IntegrationState.prototype, "lastHealthStatus", 2);
__decorateClass([
  Property({ name: "last_health_checked_at", type: Date, nullable: true })
], IntegrationState.prototype, "lastHealthCheckedAt", 2);
__decorateClass([
  Property({ name: "last_health_latency_ms", type: "int", nullable: true })
], IntegrationState.prototype, "lastHealthLatencyMs", 2);
__decorateClass([
  Property({ name: "enabled_at", type: Date, nullable: true })
], IntegrationState.prototype, "enabledAt", 2);
__decorateClass([
  Property({ name: "organization_id", type: "uuid" })
], IntegrationState.prototype, "organizationId", 2);
__decorateClass([
  Property({ name: "tenant_id", type: "uuid" })
], IntegrationState.prototype, "tenantId", 2);
__decorateClass([
  Property({ name: "created_at", type: Date, onCreate: () => /* @__PURE__ */ new Date() })
], IntegrationState.prototype, "createdAt", 2);
__decorateClass([
  Property({ name: "updated_at", type: Date, onCreate: () => /* @__PURE__ */ new Date(), onUpdate: () => /* @__PURE__ */ new Date() })
], IntegrationState.prototype, "updatedAt", 2);
__decorateClass([
  Property({ name: "deleted_at", type: Date, nullable: true })
], IntegrationState.prototype, "deletedAt", 2);
IntegrationState = __decorateClass([
  Entity({ tableName: "integration_states" }),
  Index({ properties: ["integrationId", "organizationId", "tenantId"] })
], IntegrationState);
OptionalProps;
let IntegrationLog = class {
  constructor() {
    this.createdAt = /* @__PURE__ */ new Date();
  }
};
__decorateClass([
  PrimaryKey({ type: "uuid", defaultRaw: "gen_random_uuid()" })
], IntegrationLog.prototype, "id", 2);
__decorateClass([
  Property({ name: "integration_id", type: "text" })
], IntegrationLog.prototype, "integrationId", 2);
__decorateClass([
  Property({ name: "run_id", type: "uuid", nullable: true })
], IntegrationLog.prototype, "runId", 2);
__decorateClass([
  Property({ name: "scope_entity_type", type: "text", nullable: true })
], IntegrationLog.prototype, "scopeEntityType", 2);
__decorateClass([
  Property({ name: "scope_entity_id", type: "uuid", nullable: true })
], IntegrationLog.prototype, "scopeEntityId", 2);
__decorateClass([
  Property({ name: "level", type: "text" })
], IntegrationLog.prototype, "level", 2);
__decorateClass([
  Property({ name: "message", type: "text" })
], IntegrationLog.prototype, "message", 2);
__decorateClass([
  Property({ name: "code", type: "text", nullable: true })
], IntegrationLog.prototype, "code", 2);
__decorateClass([
  Property({ name: "payload", type: "json", nullable: true })
], IntegrationLog.prototype, "payload", 2);
__decorateClass([
  Property({ name: "organization_id", type: "uuid" })
], IntegrationLog.prototype, "organizationId", 2);
__decorateClass([
  Property({ name: "tenant_id", type: "uuid" })
], IntegrationLog.prototype, "tenantId", 2);
__decorateClass([
  Property({ name: "created_at", type: Date, onCreate: () => /* @__PURE__ */ new Date() })
], IntegrationLog.prototype, "createdAt", 2);
IntegrationLog = __decorateClass([
  Entity({ tableName: "integration_logs" }),
  Index({ properties: ["integrationId", "organizationId", "tenantId", "createdAt"] }),
  Index({ properties: ["level", "organizationId", "tenantId", "createdAt"] })
], IntegrationLog);
export {
  IntegrationCredentials,
  IntegrationLog,
  IntegrationState,
  SyncExternalIdMapping
};
//# sourceMappingURL=entities.js.map
