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

Document patch() #97

Open
jeff-zucker opened this issue Dec 4, 2019 · 6 comments
Open

Document patch() #97

jeff-zucker opened this issue Dec 4, 2019 · 6 comments
Labels
enhancement New feature or request

Comments

@jeff-zucker
Copy link
Owner

jeff-zucker commented Dec 4, 2019

Currently in 1.0.0 the default (high-level) behavior of both createFile() and updateFile() is to call putFile making them both equivalent to createOrReplaceFile(). I suggest we have a real updateFile(), in other words, we support PATCH so that users can make atomic changes to the content of a file without completely replacing it. I would guess we'd want a SolidApi.patch() method and call it from SolidFileClient.updateFile(). @bourgeoa. @Otto-AA Thoughts?

@bourgeoa
Copy link
Collaborator

bourgeoa commented Dec 4, 2019

The name updateFile is very confusing, It was widely used in solid-file-client as a replacement to putFile.
I prefer something like patchFile.

@Otto-AA
Copy link
Contributor

Otto-AA commented Dec 4, 2019

Regarding putFile: I think it depends on how much custom logic you want. If updateFile would only forward to putFile, then why not directly use putFile and remove the alias?

Regarding patch: Do you think that PATCH would be a high or low level method? I'd guess that those persons who know how to use it will know it as "PATCH" and hence I'd use patch(File) as a name. If you want to add additional behavior (more than just making a PATCH request) we should find a different name though.

@jeff-zucker
Copy link
Owner Author

jeff-zucker commented Dec 4, 2019 via email

@jeff-zucker jeff-zucker changed the title How to handle update Document patch() Jan 2, 2020
@jeff-zucker jeff-zucker added the enhancement New feature or request label Jan 2, 2020
@bourgeoa
Copy link
Collaborator

bourgeoa commented Sep 10, 2020

@Otto-AA @jeff-zucker
I am going to make a patchFile()

Going in NSS through :

Only 3 SPARQL verbs are allowed : INSERT/DELETE/WHERE

There appears to be 2 ways to make a patch. Both allow using prefixes.

  • a turtle content and a contentType = application/sparql-update
        @prefix solid: <http://www.w3.org/ns/solid/terms#>.
        @prefix : <#>.
        @prefix ex: <http://example.com#>.
        <> solid:patches <urlToPatch>;
             solid:inserts { <> ex:temp 245 . };
             solid.deletes { <> ex:temp 200 .}.
  • or a N3 text content with a contentType=text/n3
        @prefix ex: <http://example.com#>.
        INSERT { :test1 ex:temp :321; ex:temp1 :322, :300 .}
        DELETE { <#test> :temp :245. }
        DELETE { <> a :test. }

the function could be : patchFile(urlToPatch, patchContent, patchContentType, options)

What check do we introduce knowing that NSS does a lot of tests:

  • if urlToPatch do not exist it is created. It is like a PUT
  • contentType can only be application/sparql-update or text/n3
  • insert or delete is needed
    .....

I think we could check that urlToPatch has a text/turtle extension .acl, .meta, .ttl and nothing else

@jeff-zucker
Copy link
Owner Author

This will be a great addition. Thank you.

Yes, I think your syntax for the method is good.
All of the checks you mention make sense to me.
Do you need anything else on my end? I plan to be more available, so ping me at any time.

@bourgeoa
Copy link
Collaborator

see PR #170

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants