cloudinary-community / cloudinary-util

https://cloudinary-util.vercel.app
MIT License
12 stars 19 forks source link

[Feature] Add enum for format parameter #142

Closed colbyfayock closed 1 month ago

colbyfayock commented 9 months ago

Feature Request

Is your feature request related to a problem? Please describe.

Add a list of allowable strings as an enum type for the format parameter.

Related: https://github.com/colbyfayock/cloudinary-util/pull/139#discussion_r1484069703

Location: https://github.com/cloudinary-community/cloudinary-util/blob/main/packages/url-loader/src/types/asset.ts#L47

Node format list: https://github.com/cloudinary/cloudinary_npm/blob/master/types/index.d.ts#L223

Documentation: https://cloudinary.com/documentation/transformation_reference#f_format

saai-syvendra commented 1 month ago

Hi @colbyfayock! Shall I work on this?

colbyfayock commented 1 month ago

all yours!

saai-syvendra commented 1 month ago

@colbyfayock the below two instances use values other than the expected enum values... Can you guide me as to wether include these in the enum, or change the below lines..

The enum values for format:

format: z
    .enum([
      "auto",
      "gif",
      "png",
      "jpg",
      "bmp",
      "ico",
      "pdf",
      "tiff",
      "eps",
      "jpc",
      "jp2",
      "psd",
      "webp",
      "zip",
      "svg",
      "webm",
      "wdp",
      "hpx",
      "djvu",
      "ai",
      "flif",
      "bpg",
      "miff",
      "tga",
      "heic",
    ])
    .default("auto")
    .describe(
      JSON.stringify({
        text: "Converts (if necessary) and delivers an asset in the specified format.",
        url: "https://cloudinary.com/documentation/transformation_reference#f_format",
      }),
    )
    .optional(),

Different format value instances: https://github.com/cloudinary-community/cloudinary-util/blob/main/packages/url-loader/src/lib/cloudinary.ts#L287 https://github.com/cloudinary-community/cloudinary-util/blob/main/packages/url-loader/src/lib/video-player.ts#L190

colbyfayock commented 1 month ago

default is an irregular value that i added to this library to allow someone to essentially turn formatting off. there are some cases where someone may not want a format of auto applied, and there needs to be a mechanism to turn it off, which is what default does, but its not a standard option for the API, only for this library

auto:image on the other hand is a standard value, i just believe it's just not well documented. there's also auto:animated

saai-syvendra commented 1 month ago

Alright.. So I will include the auto:image and auto:animated to the enum.

So, the default one I can leave it out, is it?

colbyfayock commented 1 month ago

default is a valid property for the library so it needs to be included. you can add a comment afterwards explaining that "// library specific feature to turn off automatic optimization"

github-actions[bot] commented 1 month ago

:tada: This issue has been resolved in version @cloudinary-util/url-loader-v5.10.6 :tada:

The release is available on:

Your semantic-release bot :package::rocket:

github-actions[bot] commented 1 month ago

:tada: This issue has been resolved in version @cloudinary-util/url-loader-v6.0.0-beta.2 :tada:

The release is available on:

Your semantic-release bot :package::rocket: