import { f as Result, i as CleanSubmission, l as FormDef, o as FieldError, p as StoredSubmission } from "./types-D1S3rFK7.js";
import { Querier } from "@platform-modules/db";
//#region src/schema.d.ts
declare const formSubmissions: import("drizzle-orm/pg-core").PgTableWithColumns<{
  name: "form_submissions";
  schema: undefined;
  columns: {
    id: import("drizzle-orm/pg-core").PgColumn<{
      name: "id";
      tableName: "form_submissions";
      dataType: "string";
      columnType: "PgUUID";
      data: string;
      driverParam: string;
      notNull: true;
      hasDefault: true;
      isPrimaryKey: true;
      isAutoincrement: false;
      hasRuntimeDefault: true;
      enumValues: undefined;
      baseColumn: never;
      identity: undefined;
      generated: undefined;
    }, {}, {}>;
    formId: import("drizzle-orm/pg-core").PgColumn<{
      name: "form_id";
      tableName: "form_submissions";
      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;
    }, {}, {}>;
    data: import("drizzle-orm/pg-core").PgColumn<{
      name: "data";
      tableName: "form_submissions";
      dataType: "json";
      columnType: "PgJsonb";
      data: CleanSubmission;
      driverParam: unknown;
      notNull: true;
      hasDefault: false;
      isPrimaryKey: false;
      isAutoincrement: false;
      hasRuntimeDefault: false;
      enumValues: undefined;
      baseColumn: never;
      identity: undefined;
      generated: undefined;
    }, {}, {
      $type: CleanSubmission;
    }>;
    meta: import("drizzle-orm/pg-core").PgColumn<{
      name: "meta";
      tableName: "form_submissions";
      dataType: "json";
      columnType: "PgJsonb";
      data: {
        ip?: string;
        userAgent?: string;
        ref?: string;
      };
      driverParam: unknown;
      notNull: false;
      hasDefault: false;
      isPrimaryKey: false;
      isAutoincrement: false;
      hasRuntimeDefault: false;
      enumValues: undefined;
      baseColumn: never;
      identity: undefined;
      generated: undefined;
    }, {}, {
      $type: {
        ip?: string;
        userAgent?: string;
        ref?: string;
      };
    }>;
    spam: import("drizzle-orm/pg-core").PgColumn<{
      name: "spam";
      tableName: "form_submissions";
      dataType: "boolean";
      columnType: "PgBoolean";
      data: boolean;
      driverParam: boolean;
      notNull: true;
      hasDefault: true;
      isPrimaryKey: false;
      isAutoincrement: false;
      hasRuntimeDefault: false;
      enumValues: undefined;
      baseColumn: never;
      identity: undefined;
      generated: undefined;
    }, {}, {}>;
    createdAt: import("drizzle-orm/pg-core").PgColumn<{
      name: "created_at";
      tableName: "form_submissions";
      dataType: "date";
      columnType: "PgTimestamp";
      data: Date;
      driverParam: string;
      notNull: true;
      hasDefault: true;
      isPrimaryKey: false;
      isAutoincrement: false;
      hasRuntimeDefault: true;
      enumValues: undefined;
      baseColumn: never;
      identity: undefined;
      generated: undefined;
    }, {}, {}>;
  };
  dialect: "pg";
}>;
declare const formsSchema: {
  formSubmissions: import("drizzle-orm/pg-core").PgTableWithColumns<{
    name: "form_submissions";
    schema: undefined;
    columns: {
      id: import("drizzle-orm/pg-core").PgColumn<{
        name: "id";
        tableName: "form_submissions";
        dataType: "string";
        columnType: "PgUUID";
        data: string;
        driverParam: string;
        notNull: true;
        hasDefault: true;
        isPrimaryKey: true;
        isAutoincrement: false;
        hasRuntimeDefault: true;
        enumValues: undefined;
        baseColumn: never;
        identity: undefined;
        generated: undefined;
      }, {}, {}>;
      formId: import("drizzle-orm/pg-core").PgColumn<{
        name: "form_id";
        tableName: "form_submissions";
        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;
      }, {}, {}>;
      data: import("drizzle-orm/pg-core").PgColumn<{
        name: "data";
        tableName: "form_submissions";
        dataType: "json";
        columnType: "PgJsonb";
        data: CleanSubmission;
        driverParam: unknown;
        notNull: true;
        hasDefault: false;
        isPrimaryKey: false;
        isAutoincrement: false;
        hasRuntimeDefault: false;
        enumValues: undefined;
        baseColumn: never;
        identity: undefined;
        generated: undefined;
      }, {}, {
        $type: CleanSubmission;
      }>;
      meta: import("drizzle-orm/pg-core").PgColumn<{
        name: "meta";
        tableName: "form_submissions";
        dataType: "json";
        columnType: "PgJsonb";
        data: {
          ip?: string;
          userAgent?: string;
          ref?: string;
        };
        driverParam: unknown;
        notNull: false;
        hasDefault: false;
        isPrimaryKey: false;
        isAutoincrement: false;
        hasRuntimeDefault: false;
        enumValues: undefined;
        baseColumn: never;
        identity: undefined;
        generated: undefined;
      }, {}, {
        $type: {
          ip?: string;
          userAgent?: string;
          ref?: string;
        };
      }>;
      spam: import("drizzle-orm/pg-core").PgColumn<{
        name: "spam";
        tableName: "form_submissions";
        dataType: "boolean";
        columnType: "PgBoolean";
        data: boolean;
        driverParam: boolean;
        notNull: true;
        hasDefault: true;
        isPrimaryKey: false;
        isAutoincrement: false;
        hasRuntimeDefault: false;
        enumValues: undefined;
        baseColumn: never;
        identity: undefined;
        generated: undefined;
      }, {}, {}>;
      createdAt: import("drizzle-orm/pg-core").PgColumn<{
        name: "created_at";
        tableName: "form_submissions";
        dataType: "date";
        columnType: "PgTimestamp";
        data: Date;
        driverParam: string;
        notNull: true;
        hasDefault: true;
        isPrimaryKey: false;
        isAutoincrement: false;
        hasRuntimeDefault: true;
        enumValues: undefined;
        baseColumn: never;
        identity: undefined;
        generated: undefined;
      }, {}, {}>;
    };
    dialect: "pg";
  }>;
};
type FormsSchema = typeof formsSchema;
/**
 * Pure DDL helper — returns CREATE TABLE + index SQL the host applies once (per-statement-split
 * on neon-http). Column names + types match the drizzle table above exactly.
 */
declare function formsTableSql(table?: string): string;
//#endregion
//#region src/store.d.ts
interface SubmissionStore {
  record(s: Omit<StoredSubmission, 'id' | 'createdAt'>): Promise<StoredSubmission>;
  get(formId: string, id: string): Promise<StoredSubmission | null>;
  list(formId: string, opts?: {
    limit?: number;
    cursor?: string;
    includeSpam?: boolean;
  }): Promise<{
    items: StoredSubmission[];
    nextCursor?: string;
  }>;
  delete(formId: string, id: string): Promise<void>;
}
/**
 * Reference adapter over the `db` type-contract. All reads/writes are SCOPED by formId (IDOR floor):
 * a submission read MUST be authorized by the host before calling list/get; the store never
 * exposes a cross-form global read. Cursor = the last row's createdAt ISO (keyset by created_at desc).
 */
declare function createDbSubmissionStore(db: Querier<FormsSchema>): SubmissionStore;
/**
 * The one call a host endpoint wires: validate → anti-spam (sets the spam flag) → store.record.
 * Validation failure => Result error and NOTHING is stored. A spam verdict is stored with
 * spam=true (quarantine for review) — FLAG not drop (data-loss floor).
 */
declare function recordSubmission(args: {
  form: FormDef;
  raw: Record<string, unknown> | FormData;
  store: SubmissionStore;
  antispam: {
    renderToken?: string;
    secret?: string;
    now: number;
    challengeToken?: string;
    ip?: string;
    userAgent?: string;
    ref?: string;
  };
}): Promise<Result<StoredSubmission, FieldError[]>>;
//#endregion
export { type FormsSchema, SubmissionStore, createDbSubmissionStore, formSubmissions, formsSchema, formsTableSql, recordSubmission };