api.md

September 25, 2020 · View on GitHub

Classes

SolidAPI
SolidFileClientSolidApi

Class for working with files on Solid Pods

Typedefs

WriteOptions : object
ReadFolderOptions : object
SolidApiOptions : object
Links : object
Item : object
FolderData : object
fetchPromise.<Response>

(optionally authenticated) fetch method similar to window.fetch

zipOptions : object
  • .acl write parameters
unzipOptions : object
  • .acl write parameters
SolidFileClientOptions : object

SolidAPI

Kind: global class

new SolidAPI(fetch, [options])

Provide API methods which use the passed fetch method constructor adds :

  • this.rdf methods from RdfQuery
  • this.acl methods from AclParser
ParamType
fetchfetch
[options]SolidApiOptions

solidAPI.fetch(url, [options]) ⇒ Promise.<Response>

Fetch a resource with the passed fetch method

Kind: instance method of SolidAPI
Returns: Promise.<Response> - resolves if response.ok is true, else rejects the response

ParamType
urlstring
[options]RequestInit

solidAPI.get(url, [options]) ⇒ Promise.<Response>

Send get request

Kind: instance method of SolidAPI

ParamType
urlstring
[options]RequestInit

solidAPI.delete(url, [options]) ⇒ Promise.<Response>

Send delete request

Kind: instance method of SolidAPI

ParamType
urlstring
[options]RequestInit

solidAPI.post(url, [options]) ⇒ Promise.<Response>

Send post request

Kind: instance method of SolidAPI

ParamType
urlstring
[options]RequestInit

solidAPI.put(url, [options]) ⇒ Promise.<Response>

Send put request

Kind: instance method of SolidAPI

ParamType
urlstring
[options]RequestInit

solidAPI.patch(url, [options]) ⇒ Promise.<Response>

Send patch request

Kind: instance method of SolidAPI

ParamType
urlstring
[options]RequestInit

solidAPI.head(url, [options]) ⇒ Promise.<Response>

Send head request

Kind: instance method of SolidAPI

ParamType
urlstring
[options]RequestInit

solidAPI.options(url, [options]) ⇒ Promise.<Response>

Send options request

Kind: instance method of SolidAPI

ParamType
urlstring
[options]RequestInit

solidAPI.itemExists(url) ⇒ Promise.<boolean>

Check if item exists. Return false if status is 404. If status is 403 (or any other "bad" status) reject.

Kind: instance method of SolidAPI

ParamType
urlstring

Create an item at target url. Per default it will create the parent folder if it doesn't exist.

Kind: instance method of SolidAPI

ParamTypeDescription
urlstring
contentBlob | string
contentTypestring
linkstringheader for Container/Resource, see LINK in apiUtils
[options]WriteOptionsonly uses createPath option

solidAPI.createFolder(url, [options]) ⇒ Promise.<Response>

Create a folder if it doesn't exist. Per default it will resolve when the folder already existed

Kind: instance method of SolidAPI
Returns: Promise.<Response> - Response of HEAD request if it already existed, else of creation request

ParamType
urlstring
[options]WriteOptions

solidAPI.postFile(url, content, [options]) ⇒ Promise.<Response>

Create a new file.

Kind: instance method of SolidAPI

ParamType
urlstring
contentBlob | String
[options]WriteOptions

solidAPI.createFile(url, content, [options]) ⇒ Promise.<Response>

Create a new file. Per default it will overwrite existing files

Kind: instance method of SolidAPI

ParamType
urlstring
contentBlob | String
[options]WriteOptions

solidAPI.putFile(url, content, [options]) ⇒ Promise.<Response>

Create a file using PUT Per default it will overwrite existing files

Kind: instance method of SolidAPI

ParamType
urlstring
contentBlob | String
[options]WriteOptions

solidAPI.patchFile(url, patchContent, patchContentType) ⇒ Promise.<Response>

Update a file using PATCH

Kind: instance method of SolidAPI

ParamTypeDescription
urlstringparsable by N3.js
patchContentString
patchContentTypestring

Properties

NameTypeDescription
'text/n3'patchContentTypeor 'application/sparql-update'

solidAPI.readFolder(url, [options]) ⇒ Promise.<FolderData>

Fetch and parse a folder

Kind: instance method of SolidAPI

ParamType
urlstring
[options]ReadFolderOptions

Get acl and meta links of an item

Kind: instance method of SolidAPI

ParamTypeDescription
urlstring
[options]object- specify if links should be checked for existence or not - may select acl or meta only

solidAPI.copyFile(from, to, [options]) ⇒ Promise.<Response>

Copy a file. Per default overwrite existing files and copy links too.

Kind: instance method of SolidAPI
Returns: Promise.<Response> - - Response from the new file created

ParamTypeDescription
fromstringUrl where the file currently is
tostringUrl where it should be copied to
[options]WriteOptions

solidAPI.copyMetaFileForItem(oldTargetFile, newTargetFile, [options]) ⇒ Promise.<(Response|undefined)>

Copy a meta file

Kind: instance method of SolidAPI
Returns: Promise.<(Response|undefined)> - creation response

ParamType
oldTargetFilestring
newTargetFilestring
[options]WriteOptions

solidAPI.copyAclFileForItem(oldTargetFile, newTargetFile, [options]) ⇒ Promise.<Response>

Copy an ACL file

Kind: instance method of SolidAPI
Returns: Promise.<Response> - creation response

ParamTypeDescription
oldTargetFilestringUrl of the file the acl file targets (e.g. file.ttl for file.ttl.acl)
newTargetFilestringUrl of the new file targeted (e.g. new-file.ttl for new-file.ttl.acl)
[options]WriteOptions

solidAPI.copyLinksForItem(oldTargetFile, newTargetFile, [options]) ⇒ Promise.<Array.<Response>>

Copy links for an item. Use withAcl and withMeta options to specify which links to copy Does not throw if the links don't exist.

Kind: instance method of SolidAPI
Returns: Promise.<Array.<Response>> - creation responses

ParamTypeDescription
oldTargetFilestringUrl of the file the acl file targets (e.g. file.ttl for file.ttl.acl)
newTargetFilestringUrl of the new file targeted (e.g. new-file.ttl for new-file.ttl.acl)
[options]WriteOptions

solidAPI.copyFolder(from, to, [options]) ⇒ Promise.<Array.<Response>>

Copy a folder and all contents. Per default existing folders will be deleted before copying and links will be copied.

Kind: instance method of SolidAPI
Returns: Promise.<Array.<Response>> - Resolves with an array of creation responses. The first one will be the folder specified by "to". The others will be creation responses from the contents in arbitrary order.

ParamType
fromstring
tostring
[options]WriteOptions

solidAPI.copy(from, to, [options]) ⇒ Promise.<Array.<Response>>

Copy a file (url ending with file name) or folder (url ending with "/"). Per default existing folders will be deleted before copying and links will be copied.

Kind: instance method of SolidAPI
Returns: Promise.<Array.<Response>> - Resolves with an array of creation responses. The first one will be the folder specified by "to". If it is a folder, the others will be creation responses from the contents in arbitrary order.

ParamType
fromstring
tostring
[options]WriteOptions

solidAPI.deleteFolderContents(url) ⇒ Promise.<Array.<Response>>

Delete all folders and files inside a folder

Kind: instance method of SolidAPI
Returns: Promise.<Array.<Response>> - Resolves with a response for each deletion request

ParamType
urlstring

solidAPI.deleteFolderRecursively(url) ⇒ Promise.<Array.<Response>>

Delete a folder, its contents and links recursively

Kind: instance method of SolidAPI
Returns: Promise.<Array.<Response>> - Resolves with an array of deletion responses. The first one will be the folder specified by "url". The others will be the deletion responses from the contents in arbitrary order

ParamType
urlstring

solidAPI.move(from, to, [copyOptions]) ⇒ Promise.<Array.<Response>>

Move a file (url ending with file name) or folder (url ending with "/"). Shortcut for copying and deleting items

Kind: instance method of SolidAPI
Returns: Promise.<Array.<Response>> - Responses of the copying

ParamType
fromstring
tostring
[copyOptions]WriteOptions

solidAPI.rename(url, newName, [moveOptions]) ⇒ Promise.<Array.<Response>>

Rename a file (url ending with file name) or folder (url ending with "/"). Shortcut for moving items within the same directory

Kind: instance method of SolidAPI
Returns: Promise.<Array.<Response>> - Response of the newly created items

ParamType
urlstring
newNamestring
[moveOptions]RequestOptions

SolidFileClient ⇐ SolidApi

Class for working with files on Solid Pods

Kind: global class
Extends: SolidApi

new SolidFileClient(auth, [options])

ParamTypeDescription
authSolidAuthClientAn auth client, for instance solid-auth-client or solid-auth-cli
[options]SolidFileClientOptions

solidFileClient.readFile(url, [request]) ⇒ Promise.<(string|Blob|Response)>

Fetch an item and return content as text,json,or blob as needed

Kind: instance method of SolidFileClient

ParamType
urlstring
[request]RequestInit

solidFileClient.readHead(url, options) ⇒ string

read Head as string

Kind: instance method of SolidFileClient
Returns: string - headStr

ParamType
urlstring
optionsobject

solidFileClient.deleteFile(url) ⇒ Promise.<Response>

delete file

Kind: instance method of SolidFileClient
Returns: Promise.<Response> - response of the file deletion

ParamType
urlstring

solidFileClient.deleteFolder(url) ⇒ Promise.<Array.<Response>>

Delete a folder, its contents and links recursively

Kind: instance method of SolidFileClient
Returns: Promise.<Array.<Response>> - Resolves with an array of deletion responses. The first one will be the folder specified by "url". The others will be the deletion responses from the contents in arbitrary order

ParamType
urlstring

solidFileClient.aclUrlParser(url) ⇒ object

ACL content url parser

Kind: instance method of SolidFileClient
Returns: object - an acl object from url.acl

ParamType
urlstring

solidFileClient.getFolderItemList(path) ⇒ Promise.<Array.<Item>>

Wrap API response for retrieving folder item list

Kind: instance method of SolidFileClient

ParamType
pathString

solidFileClient.createZipArchive(resource, archiveUrl, options) ⇒ promise.<response>

Request API to upload the items as zip archive zip file contains a blob (or a string if async blob is not supported like in jest tests)

Kind: instance method of SolidFileClient
Returns: promise.<response> - res => { const success = await res.text() })>}

ParamTypeDescription
resourcestringpath (file or folder)
archiveUrlstring.zip file url
optionsobject

solidFileClient.getAsZip()

Wrap API response for zipping multiple items

Kind: instance method of SolidFileClient

solidFileClient.addItemsToZip()

Add items with links to a zip object recursively

Kind: instance method of SolidFileClient

Add item links to a zip object

Kind: instance method of SolidFileClient

ParamType
zipobject
itemLinksArray
itemNamestring

solidFileClient.extractZipArchive(zip, destination, options) ⇒

Wrap API response for extracting a zip archive unzip file is expecting a blob content (except if async blob is not supported like in jest tests)

Kind: instance method of SolidFileClient
Returns: {promise<{ err: [], info: []}>)

ParamTypeDescription
zipstringfile
destinationstringfolder
optionsobject

Properties

NameType
...unzipOptionsoptions

solidFileClient.uploadExtractedZipArchive(zip, destination, curFolder, responses, options) ⇒ promise

Recursively upload all files and folders with links from an extracted zip archive

Kind: instance method of SolidFileClient

ParamTypeDescription
zipobject
destinationstringurl
curFolderstring
responsesArray
optionsobject

solidFileClient._uploadLinkFile()

Check that link content is valid and create link

Kind: instance method of SolidFileClient

WriteOptions : object

Kind: global typedef
Properties

NameTypeDefaultDescription
[createPath]booleantruecreate parent containers if they don't exist
[withAcl]booleantruealso copy acl files
[agent]AGENT"no_modify"specify how to handle existing .acl
[withMeta]booleantruealso copy meta files
[merge]MERGE"replace"specify how to handle existing files/folders

ReadFolderOptions : object

Kind: global typedef
Properties

NameTypeDefault
[links]LINKS"exclude"

SolidApiOptions : object

Kind: global typedef
Properties

NameTypeDefaultDescription
[enableLogging]boolean | stringfalseset to true to output all logging to the console or e.g. solid-file-client:fetch for partial logs

Kind: global typedef
Properties

NameType
[acl]string
[meta]string

Item : object

Kind: global typedef
Properties

NameType
urlstring
namestring
parentstring
itemType"Container" | "Resource"
[links]Links

FolderData : object

Kind: global typedef
Properties

NameType
urlstring
namestring
parentstring
linksLinks
type"folder"
foldersArray.<Item>
filesArray.<Item>

fetch ⇒ Promise.<Response>

(optionally authenticated) fetch method similar to window.fetch

Kind: global typedef

ParamType
urlstring
[options]RequestInit

zipOptions : object

  • .acl write parameters

Kind: global typedef
Properties

NameTypeDefaultDescription
[createPath]booleantruecreate parent containers if they don't exist
[links]LINKS"include"
[withAcl]booleantruealso copy acl files
[withMeta]booleantruealso copy meta files

unzipOptions : object

  • .acl write parameters

Kind: global typedef
Properties

NameTypeDefaultDescription
[createPath]booleantruecreate parent containers if they don't exist
[links]LINKS"include"
[withAcl]booleantruealso copy acl files
[withMeta]booleantruealso copy meta files
[merge]MERGE"replace"specify how to handle existing files/folders - .acl content validation parameters
[aclMode]aclMode"Control"specify the minimal existing mode to validate ACL document
[aclAuth]aclAuth"must"should be "must" (actually NSS accepts "may" = absence of acl:Authorization)
[aclDefault]aclDefault"must"specify if acl:default is needed to validate ACL document

SolidFileClientOptions : object

Kind: global typedef
Properties

NameTypeDefaultDescription
[enableLogging]boolean | stringfalsetrue for all logging or e.g. solid-file-client:fetch for partial logs