@vtex/api
Advanced tools
Comparing version
@@ -57,5 +57,5 @@ 'use strict'; | ||
key: 'uninstallApp', | ||
value: function uninstallApp(account, workspace, vendor, name) { | ||
(0, _required2.default)({ account: account, workspace: workspace, vendor: vendor, name: name }); | ||
var url = '' + this.endpointUrl + this.routes.App(account, workspace, vendor, name); | ||
value: function uninstallApp(account, workspace, app) { | ||
(0, _required2.default)({ account: account, workspace: workspace, app: app }); | ||
var url = '' + this.endpointUrl + this.routes.App(account, workspace, app); | ||
@@ -66,5 +66,5 @@ return this.http.delete(url).thenJson(); | ||
key: 'updateAppSettings', | ||
value: function updateAppSettings(account, workspace, vendor, name, version, settings) { | ||
(0, _required2.default)({ account: account, workspace: workspace, vendor: vendor, name: name, version: version, settings: settings }); | ||
var url = '' + this.endpointUrl + this.routes.App(account, workspace, vendor, name, version); | ||
value: function updateAppSettings(account, workspace, app, settings) { | ||
(0, _required2.default)({ account: account, workspace: workspace, app: app, settings: settings }); | ||
var url = '' + this.endpointUrl + this.routes.App(account, workspace, app); | ||
@@ -77,5 +77,5 @@ return this.http.put(url).send({ | ||
key: 'updateAppTtl', | ||
value: function updateAppTtl(account, workspace, vendor, name, version) { | ||
(0, _required2.default)({ account: account, workspace: workspace, vendor: vendor, name: name, version: version }); | ||
var url = '' + this.endpointUrl + this.routes.App(account, workspace, vendor, name, version); | ||
value: function updateAppTtl(account, workspace, app) { | ||
(0, _required2.default)({ account: account, workspace: workspace, app: app }); | ||
var url = '' + this.endpointUrl + this.routes.App(account, workspace, app); | ||
@@ -87,3 +87,3 @@ return this.http.patch(url).thenJson(); | ||
value: function listApps(account, workspace) { | ||
var options = arguments.length <= 2 || arguments[2] === undefined ? { oldVersion: '', context: '', since: '', service: '' } : arguments[2]; | ||
var options = arguments.length <= 2 || arguments[2] === undefined ? { oldVersion: '', context: [], since: '', service: '' } : arguments[2]; | ||
@@ -100,3 +100,3 @@ (0, _required2.default)({ account: account, workspace: workspace }); | ||
oldVersion: oldVersion, | ||
context: context, | ||
context: contextQuery(context), | ||
since: since, | ||
@@ -108,16 +108,16 @@ service: service | ||
key: 'listAppFiles', | ||
value: function listAppFiles(account, workspace, vendor, name, version, _ref2) { | ||
value: function listAppFiles(account, workspace, app, _ref2) { | ||
var _ref2$prefix = _ref2.prefix; | ||
var prefix = _ref2$prefix === undefined ? '' : _ref2$prefix; | ||
var _ref2$context = _ref2.context; | ||
var context = _ref2$context === undefined ? '' : _ref2$context; | ||
var context = _ref2$context === undefined ? [] : _ref2$context; | ||
var _ref2$nextMarker = _ref2.nextMarker; | ||
var nextMarker = _ref2$nextMarker === undefined ? '' : _ref2$nextMarker; | ||
(0, _required2.default)({ account: account, workspace: workspace, vendor: vendor, name: name, version: version }); | ||
var url = '' + this.endpointUrl + this.routes.Files(account, workspace, vendor, name, version); | ||
(0, _required2.default)({ account: account, workspace: workspace, app: app }); | ||
var url = '' + this.endpointUrl + this.routes.Files(account, workspace, app); | ||
return this.http.get(url).query({ | ||
prefix: prefix, | ||
context: context, | ||
context: contextQuery(context), | ||
nextMarker: nextMarker | ||
@@ -128,22 +128,22 @@ }).thenJson(); | ||
key: 'getAppFile', | ||
value: function getAppFile(account, workspace, vendor, name, version, path) { | ||
var context = arguments.length <= 6 || arguments[6] === undefined ? '' : arguments[6]; | ||
value: function getAppFile(account, workspace, app, path) { | ||
var context = arguments.length <= 4 || arguments[4] === undefined ? [] : arguments[4]; | ||
(0, _required2.default)({ account: account, workspace: workspace, vendor: vendor, name: name, version: version, path: path }); | ||
var url = '' + this.endpointUrl + this.routes.File(account, workspace, vendor, name, version, path); | ||
(0, _required2.default)({ account: account, workspace: workspace, app: app, path: path }); | ||
var url = '' + this.endpointUrl + this.routes.File(account, workspace, app, path); | ||
return this.http.get(url).query({ | ||
context: context | ||
}).thenJson(); | ||
context: contextQuery(context) | ||
}).thenText(); | ||
} | ||
}, { | ||
key: 'getApp', | ||
value: function getApp(account, workspace, vendor, name, version) { | ||
var context = arguments.length <= 5 || arguments[5] === undefined ? '' : arguments[5]; | ||
value: function getApp(account, workspace, app) { | ||
var context = arguments.length <= 3 || arguments[3] === undefined ? [] : arguments[3]; | ||
(0, _required2.default)({ account: account, workspace: workspace, vendor: vendor, name: name, version: version }); | ||
var url = '' + this.endpointUrl + this.routes.App(account, workspace, vendor, name, version); | ||
(0, _required2.default)({ account: account, workspace: workspace, app: app }); | ||
var url = '' + this.endpointUrl + this.routes.App(account, workspace, app); | ||
return this.http.get(url).query({ | ||
context: context | ||
context: contextQuery(context) | ||
}).thenJson(); | ||
@@ -172,10 +172,10 @@ } | ||
}, | ||
App: function App(account, workspace, vendor, name, version) { | ||
return version ? this.Apps(account, workspace) + '/' + vendor + '.' + name + '@' + version : this.Apps(account, workspace) + '/' + vendor + '.' + name; | ||
App: function App(account, workspace, app) { | ||
return this.Apps(account, workspace) + '/' + app; | ||
}, | ||
Files: function Files(account, workspace, vendor, name, version) { | ||
return this.App(account, workspace, vendor, name, version) + '/files'; | ||
Files: function Files(account, workspace, app) { | ||
return this.App(account, workspace, app) + '/files'; | ||
}, | ||
File: function File(account, workspace, vendor, name, version, path) { | ||
return this.Files(account, workspace, vendor, name, version) + '/' + path; | ||
File: function File(account, workspace, app, path) { | ||
return this.Files(account, workspace, app) + '/' + path; | ||
}, | ||
@@ -187,2 +187,6 @@ DependencyMap: function DependencyMap(account, workspace) { | ||
var contextQuery = function contextQuery(context) { | ||
return context ? context.join('/') : context; | ||
}; | ||
exports.default = AppsClient; |
@@ -50,2 +50,7 @@ 'use strict'; | ||
}); | ||
} else if (res.is('text')) { | ||
return res.text().then(function (body) { | ||
error.error = body; | ||
throw error; | ||
}); | ||
} | ||
@@ -63,2 +68,8 @@ throw error; | ||
}); | ||
}; | ||
_request2.default.prototype.thenText = function () { | ||
return this.then(function (res) { | ||
return res.text(); | ||
}); | ||
}; |
@@ -87,2 +87,38 @@ 'use strict'; | ||
} | ||
}, { | ||
key: 'listFiles', | ||
value: function listFiles(account, workspace, bucket) { | ||
var prefix = arguments.length <= 3 || arguments[3] === undefined ? '' : arguments[3]; | ||
(0, _required2.default)({ account: account, workspace: workspace, bucket: bucket }); | ||
var url = '' + this.endpointUrl + this.routes.Files(account, workspace, bucket); | ||
return this.http.get(url).query({ prefix: prefix }).thenJson(); | ||
} | ||
}, { | ||
key: 'getFile', | ||
value: function getFile(account, workspace, bucket, path) { | ||
(0, _required2.default)({ account: account, workspace: workspace, bucket: bucket, path: path }); | ||
var url = '' + this.endpointUrl + this.routes.Files(account, workspace, bucket, path); | ||
return this.http.get(url).thenText(); | ||
} | ||
}, { | ||
key: 'saveFile', | ||
value: function saveFile(account, workspace, bucket, path, filePath) { | ||
var unzip = arguments.length <= 5 || arguments[5] === undefined ? false : arguments[5]; | ||
(0, _required2.default)({ account: account, workspace: workspace, bucket: bucket, path: path, filePath: filePath }); | ||
var url = '' + this.endpointUrl + this.routes.Files(account, workspace, bucket, path); | ||
return this.http.put(url).query({ unzip: unzip }).sendFile(filePath).thenJson(); | ||
} | ||
}, { | ||
key: 'deleteFile', | ||
value: function deleteFile(account, workspace, bucket, path) { | ||
(0, _required2.default)({ account: account, workspace: workspace, bucket: bucket, path: path }); | ||
var url = '' + this.endpointUrl + this.routes.Files(account, workspace, bucket, path); | ||
return this.http.delete(url).thenJson(); | ||
} | ||
}]); | ||
@@ -100,4 +136,7 @@ | ||
}, | ||
WorkspaceMaster: function WorkspaceMaster(account, workspace) { | ||
return this.Workspace(account, workspace) + '/master'; | ||
WorkspaceMaster: function WorkspaceMaster(account) { | ||
return this.Account(account) + '/master'; | ||
}, | ||
Files: function Files(account, workspace, bucket, path) { | ||
return this.Workspace(account, workspace) + '/buckets/' + bucket + '/files' + (path ? '/' + path : ''); | ||
} | ||
@@ -104,0 +143,0 @@ }; |
{ | ||
"name": "@vtex/api", | ||
"version": "0.8.2", | ||
"version": "0.8.3", | ||
"description": "VTEX I/O API client", | ||
@@ -5,0 +5,0 @@ "main": "./lib/index.js", |
29723
5.73%607
8.2%