/**
 * Cloudflare IMAGES API
 *
 * Generated from Cloudflare TypeScript SDK.
 * DO NOT EDIT - regenerate with: bun scripts/generate.ts --service images
 */
import * as Schema from "effect/Schema";
import * as API from "../client/api.js";
import * as T from "../traits.js";
import {} from "../errors.js";
import { UploadableSchema } from "../schemas.js";
// =============================================================================
// Errors
// =============================================================================
export class ImageAlreadyExists extends Schema.TaggedErrorClass()("ImageAlreadyExists", { code: Schema.Number, message: Schema.String }) {
}
T.applyErrorMatchers(ImageAlreadyExists, [{ code: 5409 }]);
export class ImageNotFound extends Schema.TaggedErrorClass()("ImageNotFound", { code: Schema.Number, message: Schema.String }) {
}
T.applyErrorMatchers(ImageNotFound, [{ code: 5404 }]);
export class ImagesAccessNotEnabled extends Schema.TaggedErrorClass()("ImagesAccessNotEnabled", { code: Schema.Number, message: Schema.String }) {
}
T.applyErrorMatchers(ImagesAccessNotEnabled, [{ code: 5403 }]);
export class InvalidUploadFormat extends Schema.TaggedErrorClass()("InvalidUploadFormat", { code: Schema.Number, message: Schema.String }) {
}
T.applyErrorMatchers(InvalidUploadFormat, [{ code: 5415 }]);
export class KeyNotFound extends Schema.TaggedErrorClass()("KeyNotFound", { code: Schema.Number, message: Schema.String }) {
}
T.applyErrorMatchers(KeyNotFound, [{ code: 5404 }]);
export class VariantNameNotAllowed extends Schema.TaggedErrorClass()("VariantNameNotAllowed", { code: Schema.Number, message: Schema.String }) {
}
T.applyErrorMatchers(VariantNameNotAllowed, [{ code: 5400 }]);
export class VariantNotFound extends Schema.TaggedErrorClass()("VariantNotFound", { code: Schema.Number, message: Schema.String }) {
}
T.applyErrorMatchers(VariantNotFound, [{ code: 5401 }]);
export const GetV1Request = /*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    imageId: Schema.String.pipe(T.HttpPath("imageId")),
    accountId: Schema.String.pipe(T.HttpPath("account_id")),
}).pipe(T.Http({ method: "GET", path: "/accounts/{account_id}/images/v1/{imageId}" }));
export const GetV1Response = /*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    id: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
    creator: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
    filename: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
    meta: Schema.optional(Schema.Union([Schema.Unknown, Schema.Null])),
    requireSignedURLs: Schema.optional(Schema.Union([Schema.Boolean, Schema.Null])),
    uploaded: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
    variants: Schema.optional(Schema.Union([Schema.Array(Schema.String), Schema.Null])),
}).pipe(T.ResponsePath("result"));
export const getV1 = /*@__PURE__*/ /*#__PURE__*/ API.make(() => ({
    input: GetV1Request,
    output: GetV1Response,
    errors: [ImagesAccessNotEnabled, ImageNotFound],
}));
export const ListV1sRequest = /*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    accountId: Schema.String.pipe(T.HttpPath("account_id")),
    page: Schema.optional(Schema.Number).pipe(T.HttpQuery("page")),
    perPage: Schema.optional(Schema.Number).pipe(T.HttpQuery("per_page")),
    creator: Schema.optional(Schema.Union([Schema.String, Schema.Null])).pipe(T.HttpQuery("creator")),
}).pipe(T.Http({ method: "GET", path: "/accounts/{account_id}/images/v1" }));
export const ListV1sResponse = /*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    result: Schema.Struct({
        items: Schema.optional(Schema.Union([
            Schema.Array(Schema.Struct({
                images: Schema.optional(Schema.Union([
                    Schema.Array(Schema.Struct({
                        id: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
                        creator: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
                        filename: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
                        meta: Schema.optional(Schema.Union([Schema.Unknown, Schema.Null])),
                        requireSignedURLs: Schema.optional(Schema.Union([Schema.Boolean, Schema.Null])),
                        uploaded: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
                        variants: Schema.optional(Schema.Union([Schema.Array(Schema.String), Schema.Null])),
                    })),
                    Schema.Null,
                ])),
            })),
            Schema.Null,
        ])),
    }),
    resultInfo: Schema.optional(Schema.Union([
        Schema.Struct({
            count: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
            page: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
            perPage: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
            totalCount: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
        }).pipe(Schema.encodeKeys({
            count: "count",
            page: "page",
            perPage: "per_page",
            totalCount: "total_count",
        })),
        Schema.Null,
    ])),
}).pipe(Schema.encodeKeys({ result: "result", resultInfo: "result_info" }));
export const listV1s = /*@__PURE__*/ /*#__PURE__*/ API.makePaginated(() => ({
    input: ListV1sRequest,
    output: ListV1sResponse,
    errors: [ImagesAccessNotEnabled],
    pagination: {
        mode: "page",
        inputToken: "page",
        outputToken: "resultInfo.page",
        items: "result.items",
        pageSize: "perPage",
    },
}));
export const CreateV1Request = /*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    accountId: Schema.String.pipe(T.HttpPath("account_id")),
    id: Schema.optional(Schema.String),
    creator: Schema.optional(Schema.String),
    file: Schema.optional(UploadableSchema.pipe(T.HttpFormDataFile())),
    metadata: Schema.optional(Schema.Unknown),
    requireSignedURLs: Schema.optional(Schema.Boolean),
    url: Schema.optional(Schema.String),
}).pipe(T.Http({
    method: "POST",
    path: "/accounts/{account_id}/images/v1",
    contentType: "multipart",
}));
export const CreateV1Response = /*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    id: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
    creator: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
    filename: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
    meta: Schema.optional(Schema.Union([Schema.Unknown, Schema.Null])),
    requireSignedURLs: Schema.optional(Schema.Union([Schema.Boolean, Schema.Null])),
    uploaded: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
    variants: Schema.optional(Schema.Union([Schema.Array(Schema.String), Schema.Null])),
}).pipe(T.ResponsePath("result"));
export const createV1 = /*@__PURE__*/ /*#__PURE__*/ API.make(() => ({
    input: CreateV1Request,
    output: CreateV1Response,
    errors: [ImagesAccessNotEnabled],
}));
export const PatchV1Request = /*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    imageId: Schema.String.pipe(T.HttpPath("imageId")),
    accountId: Schema.String.pipe(T.HttpPath("account_id")),
    creator: Schema.optional(Schema.String),
    metadata: Schema.optional(Schema.Unknown),
    requireSignedURLs: Schema.optional(Schema.Boolean),
}).pipe(T.Http({
    method: "PATCH",
    path: "/accounts/{account_id}/images/v1/{imageId}",
}));
export const PatchV1Response = /*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    id: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
    creator: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
    filename: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
    meta: Schema.optional(Schema.Union([Schema.Unknown, Schema.Null])),
    requireSignedURLs: Schema.optional(Schema.Union([Schema.Boolean, Schema.Null])),
    uploaded: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
    variants: Schema.optional(Schema.Union([Schema.Array(Schema.String), Schema.Null])),
}).pipe(T.ResponsePath("result"));
export const patchV1 = /*@__PURE__*/ /*#__PURE__*/ API.make(() => ({
    input: PatchV1Request,
    output: PatchV1Response,
    errors: [ImagesAccessNotEnabled, ImageNotFound],
}));
export const DeleteV1Request = /*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    imageId: Schema.String.pipe(T.HttpPath("imageId")),
    accountId: Schema.String.pipe(T.HttpPath("account_id")),
}).pipe(T.Http({
    method: "DELETE",
    path: "/accounts/{account_id}/images/v1/{imageId}",
}));
export const DeleteV1Response = /*@__PURE__*/ /*#__PURE__*/ Schema.String.pipe(T.ResponsePath("result"));
export const deleteV1 = /*@__PURE__*/ /*#__PURE__*/ API.make(() => ({
    input: DeleteV1Request,
    output: DeleteV1Response,
    errors: [ImagesAccessNotEnabled, ImageNotFound],
}));
export const GetV1BlobRequest = /*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    imageId: Schema.String.pipe(T.HttpPath("imageId")),
    accountId: Schema.String.pipe(T.HttpPath("account_id")),
}).pipe(T.Http({
    method: "GET",
    path: "/accounts/{account_id}/images/v1/{imageId}/blob",
}));
export const GetV1BlobResponse = 
/*@__PURE__*/ /*#__PURE__*/ Schema.Unknown;
export const getV1Blob = /*@__PURE__*/ /*#__PURE__*/ API.make(() => ({
    input: GetV1BlobRequest,
    output: GetV1BlobResponse,
    errors: [ImagesAccessNotEnabled, ImageNotFound],
}));
export const ListV1KeysRequest = /*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    accountId: Schema.String.pipe(T.HttpPath("account_id")),
}).pipe(T.Http({ method: "GET", path: "/accounts/{account_id}/images/v1/keys" }));
export const ListV1KeysResponse = /*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    keys: Schema.optional(Schema.Union([
        Schema.Array(Schema.Struct({
            name: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
            value: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
        })),
        Schema.Null,
    ])),
}).pipe(T.ResponsePath("result"));
export const listV1Keys = /*@__PURE__*/ /*#__PURE__*/ API.make(() => ({
    input: ListV1KeysRequest,
    output: ListV1KeysResponse,
    errors: [ImagesAccessNotEnabled],
}));
export const PutV1KeyRequest = /*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    signingKeyName: Schema.String.pipe(T.HttpPath("signingKeyName")),
    accountId: Schema.String.pipe(T.HttpPath("account_id")),
}).pipe(T.Http({
    method: "PUT",
    path: "/accounts/{account_id}/images/v1/keys/{signingKeyName}",
}));
export const PutV1KeyResponse = /*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    keys: Schema.optional(Schema.Union([
        Schema.Array(Schema.Struct({
            name: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
            value: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
        })),
        Schema.Null,
    ])),
}).pipe(T.ResponsePath("result"));
export const putV1Key = /*@__PURE__*/ /*#__PURE__*/ API.make(() => ({
    input: PutV1KeyRequest,
    output: PutV1KeyResponse,
    errors: [ImagesAccessNotEnabled],
}));
export const DeleteV1KeyRequest = /*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    signingKeyName: Schema.String.pipe(T.HttpPath("signingKeyName")),
    accountId: Schema.String.pipe(T.HttpPath("account_id")),
}).pipe(T.Http({
    method: "DELETE",
    path: "/accounts/{account_id}/images/v1/keys/{signingKeyName}",
}));
export const DeleteV1KeyResponse = /*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    keys: Schema.optional(Schema.Union([
        Schema.Array(Schema.Struct({
            name: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
            value: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
        })),
        Schema.Null,
    ])),
}).pipe(T.ResponsePath("result"));
export const deleteV1Key = /*@__PURE__*/ /*#__PURE__*/ API.make(() => ({
    input: DeleteV1KeyRequest,
    output: DeleteV1KeyResponse,
    errors: [ImagesAccessNotEnabled, KeyNotFound],
}));
export const GetV1StatRequest = /*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    accountId: Schema.String.pipe(T.HttpPath("account_id")),
}).pipe(T.Http({ method: "GET", path: "/accounts/{account_id}/images/v1/stats" }));
export const GetV1StatResponse = /*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    count: Schema.optional(Schema.Union([
        Schema.Struct({
            allowed: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
            current: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
        }),
        Schema.Null,
    ])),
}).pipe(T.ResponsePath("result"));
export const getV1Stat = /*@__PURE__*/ /*#__PURE__*/ API.make(() => ({
    input: GetV1StatRequest,
    output: GetV1StatResponse,
    errors: [ImagesAccessNotEnabled],
}));
export const GetV1VariantRequest = /*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    variantId: Schema.String.pipe(T.HttpPath("variantId")),
    accountId: Schema.String.pipe(T.HttpPath("account_id")),
}).pipe(T.Http({
    method: "GET",
    path: "/accounts/{account_id}/images/v1/variants/{variantId}",
}));
export const GetV1VariantResponse = /*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    variant: Schema.optional(Schema.Union([
        Schema.Struct({
            id: Schema.String,
            options: Schema.Struct({
                fit: Schema.Literals([
                    "scale-down",
                    "contain",
                    "cover",
                    "crop",
                    "pad",
                ]),
                height: Schema.Number,
                metadata: Schema.Literals(["keep", "copyright", "none"]),
                width: Schema.Number,
            }),
            neverRequireSignedURLs: Schema.optional(Schema.Union([Schema.Boolean, Schema.Null])),
        }),
        Schema.Null,
    ])),
}).pipe(T.ResponsePath("result"));
export const getV1Variant = /*@__PURE__*/ /*#__PURE__*/ API.make(() => ({
    input: GetV1VariantRequest,
    output: GetV1VariantResponse,
    errors: [ImagesAccessNotEnabled, VariantNameNotAllowed, VariantNotFound],
}));
export const ListV1VariantsRequest = /*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    accountId: Schema.String.pipe(T.HttpPath("account_id")),
}).pipe(T.Http({ method: "GET", path: "/accounts/{account_id}/images/v1/variants" }));
export const ListV1VariantsResponse = /*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    id: Schema.String,
    options: Schema.Struct({
        fit: Schema.Literals(["scale-down", "contain", "cover", "crop", "pad"]),
        height: Schema.Number,
        metadata: Schema.Literals(["keep", "copyright", "none"]),
        width: Schema.Number,
    }),
    neverRequireSignedURLs: Schema.optional(Schema.Union([Schema.Boolean, Schema.Null])),
}).pipe(T.ResponsePath("result"));
export const listV1Variants = /*@__PURE__*/ /*#__PURE__*/ API.make(() => ({
    input: ListV1VariantsRequest,
    output: ListV1VariantsResponse,
    errors: [ImagesAccessNotEnabled],
}));
export const CreateV1VariantRequest = /*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    accountId: Schema.String.pipe(T.HttpPath("account_id")),
    id: Schema.String,
    options: Schema.Struct({
        fit: Schema.Literals(["scale-down", "contain", "cover", "crop", "pad"]),
        height: Schema.Number,
        metadata: Schema.Literals(["keep", "copyright", "none"]),
        width: Schema.Number,
    }),
    neverRequireSignedURLs: Schema.optional(Schema.Boolean),
}).pipe(T.Http({ method: "POST", path: "/accounts/{account_id}/images/v1/variants" }));
export const CreateV1VariantResponse = 
/*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    variant: Schema.optional(Schema.Union([
        Schema.Struct({
            id: Schema.String,
            options: Schema.Struct({
                fit: Schema.Literals([
                    "scale-down",
                    "contain",
                    "cover",
                    "crop",
                    "pad",
                ]),
                height: Schema.Number,
                metadata: Schema.Literals(["keep", "copyright", "none"]),
                width: Schema.Number,
            }),
            neverRequireSignedURLs: Schema.optional(Schema.Union([Schema.Boolean, Schema.Null])),
        }),
        Schema.Null,
    ])),
}).pipe(T.ResponsePath("result"));
export const createV1Variant = /*@__PURE__*/ /*#__PURE__*/ API.make(() => ({
    input: CreateV1VariantRequest,
    output: CreateV1VariantResponse,
    errors: [ImagesAccessNotEnabled, VariantNameNotAllowed],
}));
export const PatchV1VariantRequest = /*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    variantId: Schema.String.pipe(T.HttpPath("variantId")),
    accountId: Schema.String.pipe(T.HttpPath("account_id")),
    options: Schema.Struct({
        fit: Schema.Literals(["scale-down", "contain", "cover", "crop", "pad"]),
        height: Schema.Number,
        metadata: Schema.Literals(["keep", "copyright", "none"]),
        width: Schema.Number,
    }),
    neverRequireSignedURLs: Schema.optional(Schema.Boolean),
}).pipe(T.Http({
    method: "PATCH",
    path: "/accounts/{account_id}/images/v1/variants/{variantId}",
}));
export const PatchV1VariantResponse = /*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    variant: Schema.optional(Schema.Union([
        Schema.Struct({
            id: Schema.String,
            options: Schema.Struct({
                fit: Schema.Literals([
                    "scale-down",
                    "contain",
                    "cover",
                    "crop",
                    "pad",
                ]),
                height: Schema.Number,
                metadata: Schema.Literals(["keep", "copyright", "none"]),
                width: Schema.Number,
            }),
            neverRequireSignedURLs: Schema.optional(Schema.Union([Schema.Boolean, Schema.Null])),
        }),
        Schema.Null,
    ])),
}).pipe(T.ResponsePath("result"));
export const patchV1Variant = /*@__PURE__*/ /*#__PURE__*/ API.make(() => ({
    input: PatchV1VariantRequest,
    output: PatchV1VariantResponse,
    errors: [ImagesAccessNotEnabled, VariantNameNotAllowed, VariantNotFound],
}));
export const DeleteV1VariantRequest = /*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    variantId: Schema.String.pipe(T.HttpPath("variantId")),
    accountId: Schema.String.pipe(T.HttpPath("account_id")),
}).pipe(T.Http({
    method: "DELETE",
    path: "/accounts/{account_id}/images/v1/variants/{variantId}",
}));
export const DeleteV1VariantResponse = 
/*@__PURE__*/ /*#__PURE__*/ Schema.String.pipe(T.ResponsePath("result"));
export const deleteV1Variant = /*@__PURE__*/ /*#__PURE__*/ API.make(() => ({
    input: DeleteV1VariantRequest,
    output: DeleteV1VariantResponse,
    errors: [ImagesAccessNotEnabled, VariantNameNotAllowed, VariantNotFound],
}));
export const ListV2sRequest = /*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    accountId: Schema.String.pipe(T.HttpPath("account_id")),
    continuationToken: Schema.optional(Schema.Union([Schema.String, Schema.Null])).pipe(T.HttpQuery("continuation_token")),
    creator: Schema.optional(Schema.Union([Schema.String, Schema.Null])).pipe(T.HttpQuery("creator")),
    perPage: Schema.optional(Schema.Number).pipe(T.HttpQuery("per_page")),
    sortOrder: Schema.optional(Schema.Literals(["asc", "desc"])).pipe(T.HttpQuery("sort_order")),
}).pipe(T.Http({ method: "GET", path: "/accounts/{account_id}/images/v2" }));
export const ListV2sResponse = /*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    continuationToken: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
    images: Schema.optional(Schema.Union([
        Schema.Array(Schema.Struct({
            id: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
            creator: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
            filename: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
            meta: Schema.optional(Schema.Union([Schema.Unknown, Schema.Null])),
            requireSignedURLs: Schema.optional(Schema.Union([Schema.Boolean, Schema.Null])),
            uploaded: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
            variants: Schema.optional(Schema.Union([Schema.Array(Schema.String), Schema.Null])),
        })),
        Schema.Null,
    ])),
})
    .pipe(Schema.encodeKeys({
    continuationToken: "continuation_token",
    images: "images",
}))
    .pipe(T.ResponsePath("result"));
export const listV2s = /*@__PURE__*/ /*#__PURE__*/ API.make(() => ({
    input: ListV2sRequest,
    output: ListV2sResponse,
    errors: [ImagesAccessNotEnabled],
}));
export const CreateV2DirectUploadRequest = 
/*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    accountId: Schema.String.pipe(T.HttpPath("account_id")),
    id: Schema.optional(Schema.String),
    creator: Schema.optional(Schema.String),
    expiry: Schema.optional(Schema.String),
    metadata: Schema.optional(Schema.Unknown),
    requireSignedURLs: Schema.optional(Schema.Boolean),
}).pipe(T.Http({
    method: "POST",
    path: "/accounts/{account_id}/images/v2/direct_upload",
    contentType: "multipart",
}));
export const CreateV2DirectUploadResponse = 
/*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    id: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
    uploadURL: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
}).pipe(T.ResponsePath("result"));
export const createV2DirectUpload = /*@__PURE__*/ /*#__PURE__*/ API.make(() => ({
    input: CreateV2DirectUploadRequest,
    output: CreateV2DirectUploadResponse,
    errors: [ImagesAccessNotEnabled, ImageAlreadyExists, InvalidUploadFormat],
}));
//# sourceMappingURL=images.js.map