import { a as RatingAggregate, c as ReviewStatus, i as REVIEW_LIST_MAX_LIMIT, l as VerifiedPurchasePort, n as Page, o as Review, r as REVIEW_LIST_DEFAULT_LIMIT, s as ReviewRating, t as ModerationAdapter } from "./types-pHp_wPM8.js";
import { Querier } from "@platform-modules/db";
//#region src/schema.d.ts
declare const review: import("drizzle-orm/pg-core").PgTableWithColumns<{
  name: "review";
  schema: undefined;
  columns: {
    id: import("drizzle-orm/pg-core").PgColumn<{
      name: "id";
      tableName: "review";
      dataType: "string";
      columnType: "PgUUID";
      data: string;
      driverParam: string;
      notNull: true;
      hasDefault: true;
      isPrimaryKey: true;
      isAutoincrement: false;
      hasRuntimeDefault: false;
      enumValues: undefined;
      baseColumn: never;
      identity: undefined;
      generated: undefined;
    }, {}, {}>;
    productId: import("drizzle-orm/pg-core").PgColumn<{
      name: "product_id";
      tableName: "review";
      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;
    }, {}, {}>;
    userId: import("drizzle-orm/pg-core").PgColumn<{
      name: "user_id";
      tableName: "review";
      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;
    }, {}, {}>;
    purchaseId: import("drizzle-orm/pg-core").PgColumn<{
      name: "purchase_id";
      tableName: "review";
      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;
    }, {}, {}>;
    vendorId: import("drizzle-orm/pg-core").PgColumn<{
      name: "vendor_id";
      tableName: "review";
      dataType: "string";
      columnType: "PgText";
      data: string;
      driverParam: string;
      notNull: false;
      hasDefault: false;
      isPrimaryKey: false;
      isAutoincrement: false;
      hasRuntimeDefault: false;
      enumValues: [string, ...string[]];
      baseColumn: never;
      identity: undefined;
      generated: undefined;
    }, {}, {}>;
    rating: import("drizzle-orm/pg-core").PgColumn<{
      name: "rating";
      tableName: "review";
      dataType: "number";
      columnType: "PgInteger";
      data: number;
      driverParam: string | number;
      notNull: true;
      hasDefault: false;
      isPrimaryKey: false;
      isAutoincrement: false;
      hasRuntimeDefault: false;
      enumValues: undefined;
      baseColumn: never;
      identity: undefined;
      generated: undefined;
    }, {}, {}>;
    body: import("drizzle-orm/pg-core").PgColumn<{
      name: "body";
      tableName: "review";
      dataType: "string";
      columnType: "PgText";
      data: string;
      driverParam: string;
      notNull: false;
      hasDefault: false;
      isPrimaryKey: false;
      isAutoincrement: false;
      hasRuntimeDefault: false;
      enumValues: [string, ...string[]];
      baseColumn: never;
      identity: undefined;
      generated: undefined;
    }, {}, {}>;
    status: import("drizzle-orm/pg-core").PgColumn<{
      name: "status";
      tableName: "review";
      dataType: "string";
      columnType: "PgText";
      data: ReviewStatus;
      driverParam: string;
      notNull: true;
      hasDefault: true;
      isPrimaryKey: false;
      isAutoincrement: false;
      hasRuntimeDefault: false;
      enumValues: [string, ...string[]];
      baseColumn: never;
      identity: undefined;
      generated: undefined;
    }, {}, {
      $type: ReviewStatus;
    }>;
    vendorReply: import("drizzle-orm/pg-core").PgColumn<{
      name: "vendor_reply";
      tableName: "review";
      dataType: "string";
      columnType: "PgText";
      data: string;
      driverParam: string;
      notNull: false;
      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: "review";
      dataType: "date";
      columnType: "PgTimestamp";
      data: Date;
      driverParam: string;
      notNull: true;
      hasDefault: true;
      isPrimaryKey: false;
      isAutoincrement: false;
      hasRuntimeDefault: false;
      enumValues: undefined;
      baseColumn: never;
      identity: undefined;
      generated: undefined;
    }, {}, {}>;
    updatedAt: import("drizzle-orm/pg-core").PgColumn<{
      name: "updated_at";
      tableName: "review";
      dataType: "date";
      columnType: "PgTimestamp";
      data: Date;
      driverParam: string;
      notNull: true;
      hasDefault: true;
      isPrimaryKey: false;
      isAutoincrement: false;
      hasRuntimeDefault: false;
      enumValues: undefined;
      baseColumn: never;
      identity: undefined;
      generated: undefined;
    }, {}, {}>;
  };
  dialect: "pg";
}>;
declare const reviewsSchema: {
  review: import("drizzle-orm/pg-core").PgTableWithColumns<{
    name: "review";
    schema: undefined;
    columns: {
      id: import("drizzle-orm/pg-core").PgColumn<{
        name: "id";
        tableName: "review";
        dataType: "string";
        columnType: "PgUUID";
        data: string;
        driverParam: string;
        notNull: true;
        hasDefault: true;
        isPrimaryKey: true;
        isAutoincrement: false;
        hasRuntimeDefault: false;
        enumValues: undefined;
        baseColumn: never;
        identity: undefined;
        generated: undefined;
      }, {}, {}>;
      productId: import("drizzle-orm/pg-core").PgColumn<{
        name: "product_id";
        tableName: "review";
        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;
      }, {}, {}>;
      userId: import("drizzle-orm/pg-core").PgColumn<{
        name: "user_id";
        tableName: "review";
        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;
      }, {}, {}>;
      purchaseId: import("drizzle-orm/pg-core").PgColumn<{
        name: "purchase_id";
        tableName: "review";
        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;
      }, {}, {}>;
      vendorId: import("drizzle-orm/pg-core").PgColumn<{
        name: "vendor_id";
        tableName: "review";
        dataType: "string";
        columnType: "PgText";
        data: string;
        driverParam: string;
        notNull: false;
        hasDefault: false;
        isPrimaryKey: false;
        isAutoincrement: false;
        hasRuntimeDefault: false;
        enumValues: [string, ...string[]];
        baseColumn: never;
        identity: undefined;
        generated: undefined;
      }, {}, {}>;
      rating: import("drizzle-orm/pg-core").PgColumn<{
        name: "rating";
        tableName: "review";
        dataType: "number";
        columnType: "PgInteger";
        data: number;
        driverParam: string | number;
        notNull: true;
        hasDefault: false;
        isPrimaryKey: false;
        isAutoincrement: false;
        hasRuntimeDefault: false;
        enumValues: undefined;
        baseColumn: never;
        identity: undefined;
        generated: undefined;
      }, {}, {}>;
      body: import("drizzle-orm/pg-core").PgColumn<{
        name: "body";
        tableName: "review";
        dataType: "string";
        columnType: "PgText";
        data: string;
        driverParam: string;
        notNull: false;
        hasDefault: false;
        isPrimaryKey: false;
        isAutoincrement: false;
        hasRuntimeDefault: false;
        enumValues: [string, ...string[]];
        baseColumn: never;
        identity: undefined;
        generated: undefined;
      }, {}, {}>;
      status: import("drizzle-orm/pg-core").PgColumn<{
        name: "status";
        tableName: "review";
        dataType: "string";
        columnType: "PgText";
        data: ReviewStatus;
        driverParam: string;
        notNull: true;
        hasDefault: true;
        isPrimaryKey: false;
        isAutoincrement: false;
        hasRuntimeDefault: false;
        enumValues: [string, ...string[]];
        baseColumn: never;
        identity: undefined;
        generated: undefined;
      }, {}, {
        $type: ReviewStatus;
      }>;
      vendorReply: import("drizzle-orm/pg-core").PgColumn<{
        name: "vendor_reply";
        tableName: "review";
        dataType: "string";
        columnType: "PgText";
        data: string;
        driverParam: string;
        notNull: false;
        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: "review";
        dataType: "date";
        columnType: "PgTimestamp";
        data: Date;
        driverParam: string;
        notNull: true;
        hasDefault: true;
        isPrimaryKey: false;
        isAutoincrement: false;
        hasRuntimeDefault: false;
        enumValues: undefined;
        baseColumn: never;
        identity: undefined;
        generated: undefined;
      }, {}, {}>;
      updatedAt: import("drizzle-orm/pg-core").PgColumn<{
        name: "updated_at";
        tableName: "review";
        dataType: "date";
        columnType: "PgTimestamp";
        data: Date;
        driverParam: string;
        notNull: true;
        hasDefault: true;
        isPrimaryKey: false;
        isAutoincrement: false;
        hasRuntimeDefault: false;
        enumValues: undefined;
        baseColumn: never;
        identity: undefined;
        generated: undefined;
      }, {}, {}>;
    };
    dialect: "pg";
  }>;
};
type ReviewsSchema = typeof reviewsSchema;
//#endregion
//#region src/aggregate.d.ts
declare function getRatingAggregate(q: Querier<ReviewsSchema>, productId: string): Promise<RatingAggregate>;
//#endregion
//#region src/list.d.ts
interface ListReviewsOptions {
  audience: 'public' | 'admin';
  vendorId?: string;
  cursor?: string;
  limit?: number;
}
declare function listReviews(q: Querier<ReviewsSchema>, productId: string, opts: ListReviewsOptions): Promise<Page<Review>>;
interface ListReviewsByVendorOptions {
  audience: 'public' | 'admin';
  productId?: string;
  cursor?: string;
  limit?: number;
}
declare function listReviewsByVendor(q: Querier<ReviewsSchema>, vendorId: string, opts: ListReviewsByVendorOptions): Promise<Page<Review>>;
//#endregion
//#region src/moderate.d.ts
declare function moderateReview(q: Querier<ReviewsSchema>, reviewId: string, action: 'approve' | 'reject'): Promise<void>;
//#endregion
//#region src/reply.d.ts
declare function replyToReview(q: Querier<ReviewsSchema>, reviewId: string, vendorId: string, reply: string): Promise<void>;
//#endregion
//#region src/errors.d.ts
declare class NotPurchasedError extends Error {
  readonly userId: string;
  readonly productId: string;
  readonly name = "NotPurchasedError";
  readonly code: "NOT_PURCHASED";
  readonly httpStatus: 403;
  constructor(userId: string, productId: string);
}
declare class ReviewNotFoundError extends Error {
  readonly reviewId: string;
  readonly name = "ReviewNotFoundError";
  readonly code: "REVIEW_NOT_FOUND";
  readonly httpStatus: 404;
  constructor(reviewId: string);
}
declare class ReviewValidationError extends Error {
  readonly field: string;
  readonly name = "ReviewValidationError";
  readonly code: "REVIEW_VALIDATION";
  readonly httpStatus: 400;
  constructor(field: string);
}
type ImmutableField = 'userId' | 'productId' | 'purchaseId' | 'vendorId';
declare class ImmutableFieldError extends Error {
  readonly field: ImmutableField;
  readonly name = "ImmutableFieldError";
  readonly code: "IMMUTABLE_FIELD";
  constructor(field: ImmutableField);
}
declare class ReviewsConfigError extends Error {
  readonly detail: string;
  readonly name = "ReviewsConfigError";
  readonly code: "REVIEWS_CONFIG";
  constructor(detail: string);
}
declare class ReviewsMigrateError extends Error {
  readonly detail: string;
  readonly name = "ReviewsMigrateError";
  readonly code: "REVIEWS_MIGRATE";
  constructor(detail: string);
}
declare function isNotPurchasedError(e: unknown): e is NotPurchasedError;
declare function isReviewNotFoundError(e: unknown): e is ReviewNotFoundError;
declare function isReviewValidationError(e: unknown): e is ReviewValidationError;
declare function isImmutableFieldError(e: unknown): e is ImmutableFieldError;
declare function isReviewsConfigError(e: unknown): e is ReviewsConfigError;
declare function isReviewsMigrateError(e: unknown): e is ReviewsMigrateError;
//#endregion
//#region src/migrate.d.ts
declare function pushReviewsSchema(db: Querier<ReviewsSchema>): Promise<void>;
//#endregion
//#region src/submit.d.ts
interface SubmitReviewInput {
  productId: string;
  userId: string;
  vendorId: string | null;
  rating: number;
  body?: string | null;
  purchaseId: string;
}
interface SubmitReviewOptions {
  verifiedPurchase: VerifiedPurchasePort;
  moderation?: ModerationAdapter;
}
declare function submitReview(q: Querier<ReviewsSchema>, input: SubmitReviewInput, opts: SubmitReviewOptions): Promise<Review>;
//#endregion
export { type ImmutableField, ImmutableFieldError, type ListReviewsByVendorOptions, type ListReviewsOptions, type ModerationAdapter, NotPurchasedError, type Page, REVIEW_LIST_DEFAULT_LIMIT, REVIEW_LIST_MAX_LIMIT, type RatingAggregate, type Review, ReviewNotFoundError, type ReviewRating, type ReviewStatus, ReviewValidationError, ReviewsConfigError, ReviewsMigrateError, type ReviewsSchema, type SubmitReviewInput, type SubmitReviewOptions, type VerifiedPurchasePort, getRatingAggregate, isImmutableFieldError, isNotPurchasedError, isReviewNotFoundError, isReviewValidationError, isReviewsConfigError, isReviewsMigrateError, listReviews, listReviewsByVendor, moderateReview, pushReviewsSchema, replyToReview, review, reviewsSchema, submitReview };