import { Querier } from "@platform-modules/db";
//#region src/api-keys/errors.d.ts
declare class InvalidApiKeyOwnerError extends Error {
  readonly owner: string;
  readonly name = "InvalidApiKeyOwnerError";
  readonly code: "INVALID_API_KEY_OWNER";
  constructor(owner: string);
}
declare class InvalidApiKeyScopesError extends Error {
  readonly name = "InvalidApiKeyScopesError";
  readonly code: "INVALID_API_KEY_SCOPES";
  constructor();
}
declare class ApiKeyOwnerMismatchError extends Error {
  readonly owner: string;
  readonly issuedByOwner: string;
  readonly name = "ApiKeyOwnerMismatchError";
  readonly code: "API_KEY_OWNER_MISMATCH";
  constructor(owner: string, issuedByOwner: string);
}
declare class ApiKeyRevokedError extends Error {
  readonly id: string;
  readonly name = "ApiKeyRevokedError";
  readonly code: "API_KEY_REVOKED";
  constructor(id: string);
}
declare class ApiKeyExpiredError extends Error {
  readonly id: string;
  readonly name = "ApiKeyExpiredError";
  readonly code: "API_KEY_EXPIRED";
  constructor(id: string);
}
declare class ApiKeyLastUsedAtUpdateError extends Error {
  readonly id: string;
  readonly cause: unknown;
  readonly name = "ApiKeyLastUsedAtUpdateError";
  readonly code: "API_KEY_LAST_USED_AT_UPDATE_FAILED";
  constructor(id: string, cause: unknown);
}
type ApiKeyError = InvalidApiKeyOwnerError | InvalidApiKeyScopesError | ApiKeyOwnerMismatchError | ApiKeyRevokedError | ApiKeyExpiredError | ApiKeyLastUsedAtUpdateError;
declare function isInvalidApiKeyOwnerError(error: unknown): error is InvalidApiKeyOwnerError;
declare function isInvalidApiKeyScopesError(error: unknown): error is InvalidApiKeyScopesError;
declare function isApiKeyOwnerMismatchError(error: unknown): error is ApiKeyOwnerMismatchError;
declare function isApiKeyRevokedError(error: unknown): error is ApiKeyRevokedError;
declare function isApiKeyExpiredError(error: unknown): error is ApiKeyExpiredError;
declare function isApiKeyLastUsedAtUpdateError(error: unknown): error is ApiKeyLastUsedAtUpdateError;
declare function isApiKeyError(error: unknown): error is ApiKeyError;
//#endregion
//#region src/api-keys/schema.d.ts
declare const apiKeys: import("drizzle-orm/pg-core").PgTableWithColumns<{
  name: "api_keys";
  schema: undefined;
  columns: {
    id: import("drizzle-orm/pg-core").PgColumn<{
      name: "id";
      tableName: "api_keys";
      dataType: "string";
      columnType: "PgText";
      data: string;
      driverParam: string;
      notNull: true;
      hasDefault: false;
      isPrimaryKey: true;
      isAutoincrement: false;
      hasRuntimeDefault: false;
      enumValues: [string, ...string[]];
      baseColumn: never;
      identity: undefined;
      generated: undefined;
    }, {}, {}>;
    prefix: import("drizzle-orm/pg-core").PgColumn<{
      name: "prefix";
      tableName: "api_keys";
      dataType: "string";
      columnType: "PgText";
      data: string;
      driverParam: string;
      notNull: true;
      hasDefault: false;
      isPrimaryKey: false;
      isAutoincrement: false;
      hasRuntimeDefault: false;
      enumValues: [string, ...string[]];
      baseColumn: never;
      identity: undefined;
      generated: undefined;
    }, {}, {}>;
    secretHash: import("drizzle-orm/pg-core").PgColumn<{
      name: "secret_hash";
      tableName: "api_keys";
      dataType: "string";
      columnType: "PgText";
      data: string;
      driverParam: string;
      notNull: true;
      hasDefault: false;
      isPrimaryKey: false;
      isAutoincrement: false;
      hasRuntimeDefault: false;
      enumValues: [string, ...string[]];
      baseColumn: never;
      identity: undefined;
      generated: undefined;
    }, {}, {}>;
    owner: import("drizzle-orm/pg-core").PgColumn<{
      name: "owner";
      tableName: "api_keys";
      dataType: "string";
      columnType: "PgText";
      data: string;
      driverParam: string;
      notNull: true;
      hasDefault: false;
      isPrimaryKey: false;
      isAutoincrement: false;
      hasRuntimeDefault: false;
      enumValues: [string, ...string[]];
      baseColumn: never;
      identity: undefined;
      generated: undefined;
    }, {}, {}>;
    scopes: import("drizzle-orm/pg-core").PgColumn<{
      name: "scopes";
      tableName: "api_keys";
      dataType: "string";
      columnType: "PgText";
      data: string;
      driverParam: string;
      notNull: true;
      hasDefault: false;
      isPrimaryKey: false;
      isAutoincrement: false;
      hasRuntimeDefault: false;
      enumValues: [string, ...string[]];
      baseColumn: never;
      identity: undefined;
      generated: undefined;
    }, {}, {}>;
    createdAt: import("drizzle-orm/pg-core").PgColumn<{
      name: "created_at";
      tableName: "api_keys";
      dataType: "date";
      columnType: "PgTimestamp";
      data: Date;
      driverParam: string;
      notNull: true;
      hasDefault: false;
      isPrimaryKey: false;
      isAutoincrement: false;
      hasRuntimeDefault: false;
      enumValues: undefined;
      baseColumn: never;
      identity: undefined;
      generated: undefined;
    }, {}, {}>;
    lastUsedAt: import("drizzle-orm/pg-core").PgColumn<{
      name: "last_used_at";
      tableName: "api_keys";
      dataType: "date";
      columnType: "PgTimestamp";
      data: Date;
      driverParam: string;
      notNull: false;
      hasDefault: false;
      isPrimaryKey: false;
      isAutoincrement: false;
      hasRuntimeDefault: false;
      enumValues: undefined;
      baseColumn: never;
      identity: undefined;
      generated: undefined;
    }, {}, {}>;
    revokedAt: import("drizzle-orm/pg-core").PgColumn<{
      name: "revoked_at";
      tableName: "api_keys";
      dataType: "date";
      columnType: "PgTimestamp";
      data: Date;
      driverParam: string;
      notNull: false;
      hasDefault: false;
      isPrimaryKey: false;
      isAutoincrement: false;
      hasRuntimeDefault: false;
      enumValues: undefined;
      baseColumn: never;
      identity: undefined;
      generated: undefined;
    }, {}, {}>;
    expiresAt: import("drizzle-orm/pg-core").PgColumn<{
      name: "expires_at";
      tableName: "api_keys";
      dataType: "date";
      columnType: "PgTimestamp";
      data: Date;
      driverParam: string;
      notNull: false;
      hasDefault: false;
      isPrimaryKey: false;
      isAutoincrement: false;
      hasRuntimeDefault: false;
      enumValues: undefined;
      baseColumn: never;
      identity: undefined;
      generated: undefined;
    }, {}, {}>;
  };
  dialect: "pg";
}>;
declare const apiKeysCreationSql: () => string;
declare const apiKeysSchema: {
  apiKeys: import("drizzle-orm/pg-core").PgTableWithColumns<{
    name: "api_keys";
    schema: undefined;
    columns: {
      id: import("drizzle-orm/pg-core").PgColumn<{
        name: "id";
        tableName: "api_keys";
        dataType: "string";
        columnType: "PgText";
        data: string;
        driverParam: string;
        notNull: true;
        hasDefault: false;
        isPrimaryKey: true;
        isAutoincrement: false;
        hasRuntimeDefault: false;
        enumValues: [string, ...string[]];
        baseColumn: never;
        identity: undefined;
        generated: undefined;
      }, {}, {}>;
      prefix: import("drizzle-orm/pg-core").PgColumn<{
        name: "prefix";
        tableName: "api_keys";
        dataType: "string";
        columnType: "PgText";
        data: string;
        driverParam: string;
        notNull: true;
        hasDefault: false;
        isPrimaryKey: false;
        isAutoincrement: false;
        hasRuntimeDefault: false;
        enumValues: [string, ...string[]];
        baseColumn: never;
        identity: undefined;
        generated: undefined;
      }, {}, {}>;
      secretHash: import("drizzle-orm/pg-core").PgColumn<{
        name: "secret_hash";
        tableName: "api_keys";
        dataType: "string";
        columnType: "PgText";
        data: string;
        driverParam: string;
        notNull: true;
        hasDefault: false;
        isPrimaryKey: false;
        isAutoincrement: false;
        hasRuntimeDefault: false;
        enumValues: [string, ...string[]];
        baseColumn: never;
        identity: undefined;
        generated: undefined;
      }, {}, {}>;
      owner: import("drizzle-orm/pg-core").PgColumn<{
        name: "owner";
        tableName: "api_keys";
        dataType: "string";
        columnType: "PgText";
        data: string;
        driverParam: string;
        notNull: true;
        hasDefault: false;
        isPrimaryKey: false;
        isAutoincrement: false;
        hasRuntimeDefault: false;
        enumValues: [string, ...string[]];
        baseColumn: never;
        identity: undefined;
        generated: undefined;
      }, {}, {}>;
      scopes: import("drizzle-orm/pg-core").PgColumn<{
        name: "scopes";
        tableName: "api_keys";
        dataType: "string";
        columnType: "PgText";
        data: string;
        driverParam: string;
        notNull: true;
        hasDefault: false;
        isPrimaryKey: false;
        isAutoincrement: false;
        hasRuntimeDefault: false;
        enumValues: [string, ...string[]];
        baseColumn: never;
        identity: undefined;
        generated: undefined;
      }, {}, {}>;
      createdAt: import("drizzle-orm/pg-core").PgColumn<{
        name: "created_at";
        tableName: "api_keys";
        dataType: "date";
        columnType: "PgTimestamp";
        data: Date;
        driverParam: string;
        notNull: true;
        hasDefault: false;
        isPrimaryKey: false;
        isAutoincrement: false;
        hasRuntimeDefault: false;
        enumValues: undefined;
        baseColumn: never;
        identity: undefined;
        generated: undefined;
      }, {}, {}>;
      lastUsedAt: import("drizzle-orm/pg-core").PgColumn<{
        name: "last_used_at";
        tableName: "api_keys";
        dataType: "date";
        columnType: "PgTimestamp";
        data: Date;
        driverParam: string;
        notNull: false;
        hasDefault: false;
        isPrimaryKey: false;
        isAutoincrement: false;
        hasRuntimeDefault: false;
        enumValues: undefined;
        baseColumn: never;
        identity: undefined;
        generated: undefined;
      }, {}, {}>;
      revokedAt: import("drizzle-orm/pg-core").PgColumn<{
        name: "revoked_at";
        tableName: "api_keys";
        dataType: "date";
        columnType: "PgTimestamp";
        data: Date;
        driverParam: string;
        notNull: false;
        hasDefault: false;
        isPrimaryKey: false;
        isAutoincrement: false;
        hasRuntimeDefault: false;
        enumValues: undefined;
        baseColumn: never;
        identity: undefined;
        generated: undefined;
      }, {}, {}>;
      expiresAt: import("drizzle-orm/pg-core").PgColumn<{
        name: "expires_at";
        tableName: "api_keys";
        dataType: "date";
        columnType: "PgTimestamp";
        data: Date;
        driverParam: string;
        notNull: false;
        hasDefault: false;
        isPrimaryKey: false;
        isAutoincrement: false;
        hasRuntimeDefault: false;
        enumValues: undefined;
        baseColumn: never;
        identity: undefined;
        generated: undefined;
      }, {}, {}>;
    };
    dialect: "pg";
  }>;
};
type ApiKeysSchema = typeof apiKeysSchema;
//#endregion
//#region src/api-keys/types.d.ts
type IssueApiKeyInput = {
  owner: string;
  issuedBy: {
    owner: string;
  };
  scopes: string[];
  expiresAt?: Date | null;
};
type IssuedApiKey = {
  id: string;
  key: string;
};
type VerifiedApiKey = {
  id: string;
  owner: string;
  scopes: string[];
};
type VerifyApiKeyOptions = {
  now?: Date;
  onLastUsedAtUpdateError?: (error: ApiKeyLastUsedAtUpdateError) => void;
};
//#endregion
//#region src/api-keys/index.d.ts
declare function issueApiKey<S extends Record<string, unknown>>(db: Querier<S>, input: IssueApiKeyInput): Promise<IssuedApiKey>;
declare function verifyApiKey<S extends Record<string, unknown>>(db: Querier<S>, presented: string, options?: VerifyApiKeyOptions): Promise<VerifiedApiKey | null>;
//#endregion
export { type ApiKeyError, ApiKeyExpiredError, ApiKeyLastUsedAtUpdateError, ApiKeyOwnerMismatchError, ApiKeyRevokedError, type ApiKeysSchema, InvalidApiKeyOwnerError, InvalidApiKeyScopesError, type IssueApiKeyInput, type IssuedApiKey, type VerifiedApiKey, type VerifyApiKeyOptions, apiKeys, apiKeysCreationSql, apiKeysSchema, isApiKeyError, isApiKeyExpiredError, isApiKeyLastUsedAtUpdateError, isApiKeyOwnerMismatchError, isApiKeyRevokedError, isInvalidApiKeyOwnerError, isInvalidApiKeyScopesError, issueApiKey, verifyApiKey };