import { InferSchemaType } from "@shared/utils/validator.ts";
import { createErrorFactory, defineError } from "@shared/utils/errors.ts";

export const queryExecutionErrorSchema = defineError(
    "QueryExecutionError",
);
export const queryExecutionError = createErrorFactory(
    queryExecutionErrorSchema,
);
export type QueryExecutionError = InferSchemaType<
    typeof queryExecutionErrorSchema
>;

export const noAdminEntryErrorSchema = defineError("NoAdminEntryError");
export const noAdminEntryError = createErrorFactory(noAdminEntryErrorSchema);
export type NoAdminEntryError = InferSchemaType<typeof noAdminEntryErrorSchema>;

export const failedToReadFileErrorSchema = defineError("FailedToReadFileError");
export const failedToReadFileError = createErrorFactory(
    failedToReadFileErrorSchema,
);
export type FailedToReadFileError = InferSchemaType<
    typeof failedToReadFileErrorSchema
>;

export const invalidSyntaxErrorSchema = defineError("InvalidSyntaxError");
export const invalidSyntaxError = createErrorFactory(invalidSyntaxErrorSchema);
export type InvalidSyntaxError = InferSchemaType<
    typeof invalidSyntaxErrorSchema
>;

export const invalidPathErrorSchema = defineError("InvalidPathError");
export const invalidPathError = createErrorFactory(invalidPathErrorSchema);
export type InvalidPathError = InferSchemaType<typeof invalidPathErrorSchema>;

export const adminPasswordNotSetErrorSchema = defineError(
    "AdminPasswordNotSetError",
);
export const adminPasswordNotSetError = createErrorFactory(
    adminPasswordNotSetErrorSchema,
);
export type AdminPasswordNotSetError = InferSchemaType<
    typeof adminPasswordNotSetErrorSchema
>;

export const requestValidationErrorSchema = defineError(
    "RequestValidationError",
);
export const requestValidationError = createErrorFactory(
    requestValidationErrorSchema,
);
export type RequestValidationError = InferSchemaType<
    typeof requestValidationErrorSchema
>;

export const responseValidationErrorSchema = defineError(
    "ResponseValidationError",
);
export const responseValidationError = createErrorFactory(
    responseValidationErrorSchema,
);
export type ResponseValidationError = InferSchemaType<
    typeof responseValidationErrorSchema
>;

export const failedToParseRequestAsJSONErrorSchema = defineError(
    "FailedToParseRequestAsJSONError",
);
export const failedToParseRequestAsJSONError = createErrorFactory(
    failedToParseRequestAsJSONErrorSchema,
);
export type FailedToParseRequestAsJSONError = InferSchemaType<
    typeof failedToParseRequestAsJSONErrorSchema
>;
