Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added delivery tojson #462

Merged
merged 8 commits into from
Nov 1, 2021
Merged

added delivery tojson #462

merged 8 commits into from
Nov 1, 2021

Conversation

strausr
Copy link
Contributor

@strausr strausr commented Oct 25, 2021

Pull request for @cloudinary/url-gen

  1. Added Delivery.ToJSON
  2. updated some types in qualifier flag to fix type errors

@strausr strausr requested a review from a user October 25, 2021 11:12
src/actions/delivery/DeliveryColorSpaceFromICC.ts Outdated Show resolved Hide resolved
src/actions/delivery/DeliveryFormat.ts Outdated Show resolved Hide resolved
src/actions/delivery/DeliveryFormat.ts Outdated Show resolved Hide resolved
* @see Visit {@link Actions.Delivery|Delivery} for an example
*/
constructor(deliveryKey?: string, deliveryType?: FormatQualifier | string|number) {
constructor(deliveryKey?: string, deliveryType?: FormatQualifier | string|number, modelProperty?: string) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should avoid changing the signature of constructors for the model, since the model is internal and users don't care about it

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the api that is changed is not part of the end user's api so its okay to add the model properties here

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that having to pass a property name to the parent constructor is a bit hacky and not the simplest path to take. Someone seeing it for the first time (me included) will not immediately understand why it's needed.
How about we do like you've done for DeliveryFormat - update the model in the action's constructor, this means adding action classes if they are missing. this is something you should consider because when we'll want to implement the fromJson, we might need those classes anyway. see here: https://github.com/cloudinary/js-url-gen/blob/master/src/internal/fromJson.ts#L19

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've went ahead and actually streamlined everything into re-using the DeliveryAction.

We can choose to create a new class for each piece of code, but I'll just remind that this is a temporary solution to this problem, and we must revisit everything in the near future (So we should design with care).

I'm okay with both solutions (Many classes, or reusing deliveryAction), but we should be aligned and avoid half-half solutions.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like this direction, in addition to what I've already wrote, it also violates the O in SOLID as far as I can tell. But since it's temporary we can end this discussion here.

src/actions/delivery/DeliveryFormat.ts Show resolved Hide resolved
src/qualifiers/progressive.ts Outdated Show resolved Hide resolved
@strausr strausr requested a review from a user October 25, 2021 13:18
src/qualifiers/flag/FlagQualifier.ts Show resolved Hide resolved
* @see Visit {@link Actions.Delivery|Delivery} for an example
*/
constructor(deliveryKey?: string, deliveryType?: FormatQualifier | string|number) {
constructor(deliveryKey?: string, deliveryType?: FormatQualifier | string|number, modelProperty?: string) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that having to pass a property name to the parent constructor is a bit hacky and not the simplest path to take. Someone seeing it for the first time (me included) will not immediately understand why it's needed.
How about we do like you've done for DeliveryFormat - update the model in the action's constructor, this means adding action classes if they are missing. this is something you should consider because when we'll want to implement the fromJson, we might need those classes anyway. see here: https://github.com/cloudinary/js-url-gen/blob/master/src/internal/fromJson.ts#L19

@patrick-tolosa
Copy link
Contributor

I've pushed a commit to streamline the use of DeliveryAction - I've moved the logic from Quality and Format internally into Delivery Action, which hopefully adds more clarity to the actionModel.

I've also added types for the actionModel:

modelProperty?: 'level' | 'density' | 'defaultImage' | 'colorSpaceType' | 'formatType' | 'type'

@strausr strausr requested a review from a user November 1, 2021 07:17
@strausr strausr merged commit a45f648 into master Nov 1, 2021
@mckomo-cl mckomo-cl deleted the add/toJson-delivery-schema branch December 2, 2022 11:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants