Comparing version 2.9.1 to 2.10.0
31
API.md
@@ -165,2 +165,3 @@ ## Modules | ||
* [.createWriteStream(remoteFilename, [options])](#ClientInterface.createWriteStream) ⇒ <code>Writeable</code> | ||
* [.customRequest(remotePath, [requestOptions], [options])](#ClientInterface.customRequest) ⇒ <code>Promise.<Any></code> | ||
* [.deleteFile(remotePath, [options])](#ClientInterface.deleteFile) ⇒ <code>Promise</code> | ||
@@ -247,2 +248,27 @@ * [.getDirectoryContents(remotePath, [options])](#ClientInterface.getDirectoryContents) ⇒ <code>Promise.<Array.<Stat>></code> | ||
``` | ||
<a name="ClientInterface.customRequest"></a> | ||
### ClientInterface.customRequest(remotePath, [requestOptions], [options]) ⇒ <code>Promise.<Any></code> | ||
Send a custom request | ||
**Kind**: static method of [<code>ClientInterface</code>](#ClientInterface) | ||
**Returns**: <code>Promise.<Any></code> - A promise that resolves with response of the request | ||
| Param | Type | Description | | ||
| --- | --- | --- | | ||
| remotePath | <code>String</code> | The remote path | | ||
| [requestOptions] | [<code>RequestOptions</code>](#RequestOptions) | the request options | | ||
| [options] | <code>Options</code> | Options for the request | | ||
**Example** | ||
```js | ||
const contents = await client.customRequest("/alrighty.jpg", { | ||
method: "PROPFIND", | ||
headers: { | ||
Accept: "text/plain", | ||
Depth: 0 | ||
}, | ||
responseType: "text" | ||
}); | ||
``` | ||
<a name="ClientInterface.deleteFile"></a> | ||
@@ -496,3 +522,4 @@ | ||
| [headers] | <code>Object</code> | Set additional request headers | | ||
| [withCredentials] | <code>Boolean</code> | Set whether or not credentials should be included with the request. Defaults to value used by axios. | | ||
| [withCredentials] | <code>Boolean</code> | Set whether or not credentials should | | ||
| data | <code>Object</code> \| <code>String</code> \| <code>\*</code> | Set additional body be included with the request. Defaults to value used by axios. | | ||
@@ -512,3 +539,3 @@ <a name="RequestOptions"></a> | ||
| [httpsAgent] | <code>Object</code> | A HTTPS agent interface | | ||
| body | <code>Object</code> \| <code>String</code> \| <code>\*</code> | Body data for the request | | ||
| data | <code>Object</code> \| <code>String</code> \| <code>\*</code> | Body data for the request | | ||
# WebDAV-Client changelog | ||
## v2.10.0 | ||
_2019-10-12_ | ||
* [#174](https://github.com/perry-mitchell/webdav-client/pull/174) `customRequest` method for making custom requests | ||
## v2.9.1 | ||
@@ -4,0 +9,0 @@ _2019-07-07_ |
@@ -14,2 +14,3 @@ "use strict"; | ||
const createStream = require("./interface/createStream.js"); | ||
const custom = require("./interface/custom.js"); | ||
const deletion = require("./interface/delete.js"); | ||
@@ -198,2 +199,24 @@ const getFile = require("./interface/getFile.js"); | ||
/** | ||
* Send a custom request | ||
* @param {String} remotePath The remote path | ||
* @param {RequestOptions=} requestOptions the request options | ||
* @param {Options=} options Options for the request | ||
* @memberof ClientInterface | ||
* @returns {Promise<Any>} A promise that resolves with response of the request | ||
* @example | ||
* const contents = await client.customRequest("/alrighty.jpg", { | ||
* method: "PROPFIND", | ||
* headers: { | ||
* Accept: "text/plain", | ||
* Depth: 0 | ||
* }, | ||
* responseType: "text" | ||
* }); | ||
*/ | ||
customRequest: function customRequest(remotePath, requestOptions, options) { | ||
const customOptions = merge(runtimeOptions, options || {}); | ||
return custom.customRequest(remotePath, requestOptions, customOptions); | ||
}, | ||
/** | ||
* Delete a remote file | ||
@@ -200,0 +223,0 @@ * @param {String} remotePath The remote path to delete |
@@ -67,3 +67,4 @@ "use strict"; | ||
module.exports = { | ||
getStat | ||
getStat, | ||
parseStat | ||
}; |
@@ -31,2 +31,3 @@ "use strict"; | ||
* @property {Boolean=} withCredentials - Set whether or not credentials should | ||
* @property {Object|String|*=} data - Set additional body | ||
* be included with the request. Defaults to value used by axios. | ||
@@ -47,2 +48,5 @@ */ | ||
} | ||
if (methodOptions.data) { | ||
requestOptions.data = methodOptions.data; | ||
} | ||
if (methodOptions.headers && typeof methodOptions.headers === "object") { | ||
@@ -73,3 +77,3 @@ requestOptions.headers = merge(requestOptions.headers || {}, methodOptions.headers); | ||
* @property {Object=} httpsAgent - A HTTPS agent interface | ||
* @property {Object|String|*=} body - Body data for the request | ||
* @property {Object|String|*=} data - Body data for the request | ||
*/ | ||
@@ -76,0 +80,0 @@ |
{ | ||
"name": "webdav", | ||
"version": "2.9.1", | ||
"version": "2.10.0", | ||
"description": "WebDAV client for NodeJS", | ||
@@ -72,3 +72,3 @@ "main": "dist/index.js", | ||
"jsdoc-to-markdown": "^5.0.0", | ||
"karma": "^4.1.0", | ||
"karma": "^3.1.4", | ||
"karma-chai": "^0.1.0", | ||
@@ -87,3 +87,3 @@ "karma-chrome-launcher": "^2.2.0", | ||
"sinon": "^7.3.2", | ||
"wait-on": "^3.2.0", | ||
"wait-on": "~3.2.0", | ||
"webdav-server": "^2.4.6", | ||
@@ -90,0 +90,0 @@ "webpack": "^4.35.2", |
@@ -5,3 +5,3 @@  | ||
[](https://travis-ci.org/perry-mitchell/webdav-client) [](https://www.npmjs.com/package/webdav) [](https://www.npmjs.com/package/webdav) | ||
[](https://travis-ci.org/perry-mitchell/webdav-client) [](https://www.npmjs.com/package/webdav) [](https://www.npmjs.com/package/webdav) [](https://www.npmjs.com/package/webdav) | ||
@@ -254,2 +254,17 @@ ## About | ||
### Custom requests | ||
Custom requests can be made to the attached host: | ||
```javascript | ||
const contents = await client.customRequest("/alrighty.jpg", { | ||
method: "PROPFIND", | ||
headers: { | ||
Accept: "text/plain", | ||
Depth: 0 | ||
}, | ||
responseType: "text" | ||
}); | ||
``` | ||
### Returned data structures | ||
@@ -256,0 +271,0 @@ |
Sorry, the diff of this file is too big to display
1202109
33
6797
342