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 merge functionality to javascript client sdk #217

Merged
merged 1 commit into from
Mar 6, 2023

Conversation

PJGitLan
Copy link
Contributor

No description provided.

@thjaeckle
Copy link
Member

Hello @PJGitLan and thanks for this contribution.
Will take a look once the "Checks" for this PR are all green.

For the "eclipsefdn/eca" check you will have to create an Eclipse account and sign the ECA (Eclipse Contributor Agreement), as also noted in the CONTRIBUTING.md - and sign your commit with the email address registered in your Eclipse account.

@PJGitLan PJGitLan force-pushed the add-merge branch 2 times, most recently from c3b76d9 to 7f735bc Compare February 22, 2023 16:16
Copy link
Member

@thjaeckle thjaeckle left a comment

Choose a reason for hiding this comment

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

Thanks @PJGitLan for the contribution.

I added some remarks / wishes for changing inline.
Good that you added "some" merge functionality to the JS SDK. 👍

However, it would be nice if we go into that direction in the JS SDK to support PATCH / merge, that all levels are supported.
Do you think you can also address all other levels (where currently only "PUT" is available in the client)?
From the top of my head:

  • merge Thing
  • merge Thing attributes
  • merge Thing attribute
  • merge Features (all)
  • merge Feature (single)
  • merge Feature desired properties

That way the complete "merge" would be available in the JS client and not only a small selected subpart.

@@ -51,6 +51,19 @@ export abstract class RequestSender {
});
}

public fetchMergeRequest<T>(options: ParseRequest<T>): Promise<MergeResponse<T>> {
return this.fetchRequest(options).then(response => {
if (response.status === 204) {
Copy link
Member

Choose a reason for hiding this comment

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

As far as I remember a PATCH / merge could also create a new feature or property ..
So IMO checking for the status code 201 is missing here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this should be resolved by using fetchPutRequest()

javascript/lib/api/src/model/response.ts Outdated Show resolved Hide resolved
@PJGitLan PJGitLan force-pushed the add-merge branch 2 times, most recently from 17cd4db to 91165cb Compare February 27, 2023 12:36
@PJGitLan PJGitLan changed the title added merge property to javascript client sdk added merge functionality to javascript client sdk Feb 27, 2023
@PJGitLan
Copy link
Contributor Author

Thanks @PJGitLan for the contribution.

I added some remarks / wishes for changing inline. Good that you added "some" merge functionality to the JS SDK. +1

However, it would be nice if we go into that direction in the JS SDK to support PATCH / merge, that all levels are supported. Do you think you can also address all other levels (where currently only "PUT" is available in the client)? From the top of my head:

  • merge Thing
  • merge Thing attributes
  • merge Thing attribute
  • merge Features (all)
  • merge Feature (single)
  • merge Feature desired properties

That way the complete "merge" would be available in the JS client and not only a small selected subpart.

I added further merge functionality and solved previous remarks

@@ -142,6 +172,17 @@ export interface HttpThingsHandle extends ThingsHandle {
*/
putPolicyId(thingId: string, policyId: string, options?: MatchOptions): Promise<PutResponse<string>>;
Copy link
Contributor Author

@PJGitLan PJGitLan Feb 27, 2023

Choose a reason for hiding this comment

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

Any reason why policyId and definition are only used for http-requests and not for websocket-requests?

@PJGitLan PJGitLan force-pushed the add-merge branch 2 times, most recently from d732853 to 84de897 Compare February 27, 2023 14:40
Copy link
Member

@thjaeckle thjaeckle left a comment

Choose a reason for hiding this comment

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

Thanks, that looks very promising 👍
I added some remarks, mainly about the js-doc, which were copy&pasted without adjustment at some places.

I like the added enums, but we then already should use them everywhere to get the JS client in a better shape slowly :)

javascript/lib/api/src/client/constants/content-type.ts Outdated Show resolved Hide resolved
javascript/lib/api/src/client/constants/header.ts Outdated Show resolved Hide resolved
javascript/lib/api/src/client/constants/http-verb.ts Outdated Show resolved Hide resolved
javascript/lib/api/src/client/handles/things.interfaces.ts Outdated Show resolved Hide resolved
javascript/lib/api/src/client/handles/things.interfaces.ts Outdated Show resolved Hide resolved
Copy link
Member

@thjaeckle thjaeckle left a comment

Choose a reason for hiding this comment

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

@PJGitLan the changes look good to me, very nice 👍
Great that you did the extra changes to completely support "merge". Thank you for the contribution.

@thjaeckle thjaeckle merged commit d5af2b3 into eclipse-ditto:master Mar 6, 2023
@thjaeckle thjaeckle added this to the 3.2.0 milestone Mar 6, 2023
@PJGitLan
Copy link
Contributor Author

PJGitLan commented Mar 8, 2023

@PJGitLan the changes look good to me, very nice +1 Great that you did the extra changes to completely support "merge". Thank you for the contribution.

Hi @thjaeckle, no problem. Any idea when version 3.2.0 will be published?

@thjaeckle
Copy link
Member

Today 😉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants