mongodb-stitch
Version:
[](https://gitter.im/mongodb/stitch?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
1,003 lines (917 loc) • 40.4 kB
JavaScript
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.StitchAdminClient = exports.StitchAdminClientFactory = undefined;
var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); /* global window, fetch */
/* eslint no-labels: ['error', { 'allowLoop': true }] */
var _formData = require('form-data');
var _formData2 = _interopRequireDefault(_formData);
var _client = require('./client');
var _common = require('./common');
var _common2 = _interopRequireDefault(_common);
var _common3 = require('./auth/common');
var _errors = require('./errors');
var _constants = require('./constants');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
/** @private **/
var StitchAdminClientFactory = exports.StitchAdminClientFactory = function () {
function StitchAdminClientFactory() {
_classCallCheck(this, StitchAdminClientFactory);
throw new _errors.StitchError('StitchAdminClient can only be made from the StitchAdminClientFactory.create function');
}
_createClass(StitchAdminClientFactory, null, [{
key: 'create',
value: function create(baseUrl) {
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : { requestOrigin: undefined };
return (0, _client.newStitchClient)(StitchAdminClient.prototype, '', {
requestOrigin: options.requestOrigin,
baseUrl: baseUrl,
authCodec: _common3.ADMIN_CLIENT_CODEC
});
}
}]);
return StitchAdminClientFactory;
}();
/** @private */
var StitchAdminClient = exports.StitchAdminClient = function (_StitchClient) {
_inherits(StitchAdminClient, _StitchClient);
function StitchAdminClient() {
_classCallCheck(this, StitchAdminClient);
return _possibleConstructorReturn(this, (StitchAdminClient.__proto__ || Object.getPrototypeOf(StitchAdminClient)).call(this));
}
_createClass(StitchAdminClient, [{
key: 'verifyRecaptcha',
/**
* Verifies a recaptcha token.
*
* @returns {Promise}
*/
value: function verifyRecaptcha(token) {
return this._v1.private._post('/spa/recaptcha/verify', new URLSearchParams('response=' + token), { credentials: 'include', multipart: true, noAuth: true });
}
/**
* Ends the session for the current user.
*
* @returns {Promise}
*/
}, {
key: 'logout',
value: function logout() {
var _this2 = this;
return _get(StitchAdminClient.prototype.__proto__ || Object.getPrototypeOf(StitchAdminClient.prototype), '_do', this).call(this, '/auth/session', 'DELETE', {
refreshOnFailure: false,
useRefreshToken: true,
apiVersion: _constants.v3
}).then(function () {
return _this2.auth.clear();
});
}
/**
* Returns profile information for the currently logged in user
*
* @returns {Promise}
*/
}, {
key: 'userProfile',
value: function userProfile() {
return this._v3._get('/auth/profile');
}
/**
* Returns available providers for the currently logged in admin
*
* @returns {Promise}
*/
}, {
key: 'getAuthProviders',
value: function getAuthProviders() {
return _get(StitchAdminClient.prototype.__proto__ || Object.getPrototypeOf(StitchAdminClient.prototype), '_do', this).call(this, '/auth/providers', 'GET', { noAuth: true, apiVersion: _constants.v3 }).then(function (response) {
return response.json();
});
}
/**
* Returns an access token for the user
*
* @returns {Promise}
*/
}, {
key: 'doSessionPost',
value: function doSessionPost() {
return _get(StitchAdminClient.prototype.__proto__ || Object.getPrototypeOf(StitchAdminClient.prototype), '_do', this).call(this, '/auth/session', 'POST', {
refreshOnFailure: false,
useRefreshToken: true,
apiVersion: _constants.v3
}).then(function (response) {
return response.json();
});
}
/* Examples of how to access admin API with this client:
*
* List all apps
* a.apps('580e6d055b199c221fcb821c').list()
*
* Fetch app under name 'planner'
* a.apps('580e6d055b199c221fcb821c').app('planner').get()
*
* List services under the app 'planner'
* a.apps('580e6d055b199c221fcb821c').app('planner').services().list()
*
* Delete a rule by ID
* a.apps('580e6d055b199c221fcb821c').app('planner').services().service('mdb1').rules().rule('580e6d055b199c221fcb821d').remove()
*
*/
}, {
key: 'apps',
value: function apps(groupId) {
var api = this._v3;
var groupUrl = '/groups/' + groupId + '/apps';
return {
list: function list(filter) {
return api._get(groupUrl, filter);
},
create: function create(data, options) {
var query = options && options.product ? '?product=' + options.product : '';
return api._post(groupUrl + query, data);
},
measurements: function measurements(filter) {
return api._get('/groups/' + groupId + '/measurements', filter);
},
app: function app(appId) {
var appUrl = groupUrl + '/' + appId;
return {
get: function get() {
return api._get(appUrl);
},
remove: function remove() {
return api._delete(appUrl);
},
export: function _export() {
return api._get(appUrl + '/export', { version: '20200603' }, {
Accept: 'application/zip'
});
},
measurements: function measurements(filter) {
return api._get(appUrl + '/measurements', filter);
},
commands: function commands() {
return {
run: function run(command, data) {
return api._post(appUrl + '/commands/' + command, data);
}
};
},
dependencies: function dependencies() {
return {
list: function list() {
return api._get(appUrl + '/dependencies');
},
upload: function upload(filename, body) {
var form = new _formData2.default();
form.append('file', body, filename);
return api._postRaw(appUrl + '/dependencies', {
body: form,
multipart: true
});
}
};
},
values: function values() {
return {
list: function list() {
return api._get(appUrl + '/values');
},
create: function create(data) {
return api._post(appUrl + '/values', data);
},
value: function value(valueId) {
var valueUrl = appUrl + '/values/' + valueId;
return {
get: function get() {
return api._get(valueUrl);
},
remove: function remove() {
return api._delete(valueUrl);
},
update: function update(data) {
return api._put(valueUrl, { body: JSON.stringify(data) });
}
};
}
};
},
secrets: function secrets() {
return {
list: function list() {
return api._get(appUrl + '/secrets');
},
create: function create(data) {
return api._post(appUrl + '/secrets', data);
},
secret: function secret(secretId) {
var secretUrl = appUrl + '/secrets/' + secretId;
return {
remove: function remove() {
return api._delete(secretUrl);
},
update: function update(data) {
return api._put(secretUrl, { body: JSON.stringify(data) });
}
};
}
};
},
hosting: function hosting() {
return {
config: function config() {
return {
get: function get() {
return api._get(appUrl + '/hosting/config');
},
patch: function patch(config) {
return api._patch(appUrl + '/hosting/config', {
body: JSON.stringify(config)
});
}
};
},
cache: function cache() {
return {
invalidate: function invalidate(path) {
return api._put(appUrl + '/hosting/cache', {
body: JSON.stringify({ invalidate: true, path: path })
});
}
};
},
assets: function assets() {
return {
createDirectory: function createDirectory(folderName) {
return api._put(appUrl + '/hosting/assets/asset', {
body: JSON.stringify({ path: folderName + '/' })
});
},
list: function list(params) {
return api._get(appUrl + '/hosting/assets', params);
},
upload: function upload(metadata, body) {
var form = new _formData2.default();
form.append('meta', metadata);
form.append('file', body);
return api._put(appUrl + '/hosting/assets/asset', {
body: form,
multipart: true
});
},
post: function post(data) {
return api._post(appUrl + '/hosting/assets', data);
},
asset: function asset() {
return {
patch: function patch(options) {
return api._patch(appUrl + '/hosting/assets/asset', {
body: JSON.stringify({ attributes: options.attributes }),
queryParams: { path: options.path }
});
},
get: function get(params) {
return api._get(appUrl + '/hosting/assets/asset', params);
},
delete: function _delete(params) {
return api._delete(appUrl + '/hosting/assets/asset', params);
}
};
}
};
}
};
},
deploy: function deploy() {
return {
auth: function auth() {
return {
github: function github() {
return api._get(appUrl + '/deploy/github/auth', undefined, undefined, {
credentials: 'include'
});
}
};
},
config: function config() {
return api._get(appUrl + '/deploy/config');
},
deployments: function deployments() {
return {
list: function list(filter) {
return api._get(appUrl + '/deployments', filter);
},
get: function get(commit) {
return api._get(appUrl + '/deployments/' + commit);
}
};
},
installation: function installation() {
return api._get(appUrl + '/deploy/installation');
},
repositories: function repositories() {
return {
repository: function repository(repoId) {
return {
github: function github() {
return {
branches: function branches() {
return {
list: function list() {
return api._get(appUrl + '/deploy/github/repositories/' + repoId + '/branches');
}
};
}
};
}
};
}
};
},
updateConfig: function updateConfig(config) {
return api._patch(appUrl + '/deploy/config', {
body: JSON.stringify(config)
});
},
overwriteConfig: function overwriteConfig(config) {
return api._put(appUrl + '/deploy/config', {
body: JSON.stringify(config)
});
}
};
},
drafts: function drafts() {
return {
get: function get(draftId) {
return api._get(appUrl + '/drafts/' + draftId);
},
list: function list() {
return api._get(appUrl + '/drafts');
},
create: function create() {
return api._post(appUrl + '/drafts');
},
delete: function _delete(draftId) {
return api._delete(appUrl + '/drafts/' + draftId);
},
deploy: function deploy(draftId, params) {
return api._post(appUrl + '/drafts/' + draftId + '/deployment', null, params);
},
diff: function diff(draftId) {
return api._get(appUrl + '/drafts/' + draftId + '/diff');
}
};
},
services: function services() {
return {
list: function list() {
return api._get(appUrl + '/services');
},
create: function create(data) {
return api._post(appUrl + '/services', data);
},
service: function service(serviceId) {
return {
get: function get() {
return api._get(appUrl + '/services/' + serviceId);
},
remove: function remove(params) {
return api._delete(appUrl + '/services/' + serviceId, params);
},
update: function update(data) {
return api._patch(appUrl + '/services/' + serviceId, {
body: JSON.stringify(data)
});
},
runCommand: function runCommand(commandName, data) {
return api._post(appUrl + '/services/' + serviceId + '/commands/' + commandName, data);
},
config: function config() {
return {
get: function get(params) {
return api._get(appUrl + '/services/' + serviceId + '/config', params);
},
update: function update(data) {
return api._patch(appUrl + '/services/' + serviceId + '/config', {
body: JSON.stringify(data)
});
}
};
},
rules: function rules() {
return {
list: function list() {
return api._get(appUrl + '/services/' + serviceId + '/rules');
},
create: function create(data, params) {
return api._post(appUrl + '/services/' + serviceId + '/rules', data, params);
},
rule: function rule(ruleId) {
var ruleUrl = appUrl + '/services/' + serviceId + '/rules/' + ruleId;
return {
get: function get() {
return api._get(ruleUrl);
},
update: function update(data, params) {
return api._put(ruleUrl, { body: JSON.stringify(data), queryParams: params });
},
remove: function remove(params) {
return api._delete(ruleUrl, params);
}
};
}
};
},
incomingWebhooks: function incomingWebhooks() {
return {
list: function list() {
return api._get(appUrl + '/services/' + serviceId + '/incoming_webhooks');
},
create: function create(data) {
return api._post(appUrl + '/services/' + serviceId + '/incoming_webhooks', data);
},
incomingWebhook: function incomingWebhook(incomingWebhookId) {
var webhookUrl = appUrl + '/services/' + serviceId + '/incoming_webhooks/' + incomingWebhookId;
return {
get: function get() {
return api._get(webhookUrl);
},
update: function update(data) {
return api._put(webhookUrl, { body: JSON.stringify(data) });
},
remove: function remove() {
return api._delete(webhookUrl);
}
};
}
};
}
};
}
};
},
pushNotifications: function pushNotifications() {
return {
list: function list(filter) {
return api._get(appUrl + '/push/notifications', filter);
},
create: function create(data) {
return api._post(appUrl + '/push/notifications', data);
},
pushNotification: function pushNotification(messageId) {
return {
get: function get() {
return api._get(appUrl + '/push/notifications/' + messageId);
},
update: function update(data) {
return api._put(appUrl + '/push/notifications/' + messageId, {
body: JSON.stringify(data)
});
},
remove: function remove() {
return api._delete(appUrl + '/push/notifications/' + messageId);
},
send: function send() {
return api._post(appUrl + '/push/notifications/' + messageId + '/send');
}
};
}
};
},
users: function users() {
return {
count: function count() {
return api._get(appUrl + '/users_count');
},
list: function list(filter) {
return api._get(appUrl + '/users', filter);
},
create: function create(user) {
return api._post(appUrl + '/users', user);
},
user: function user(uid) {
return {
get: function get() {
return api._get(appUrl + '/users/' + uid);
},
devices: function devices() {
return {
get: function get() {
return api._get(appUrl + '/users/' + uid + '/devices');
}
};
},
logout: function logout() {
return api._put(appUrl + '/users/' + uid + '/logout');
},
enable: function enable() {
return api._put(appUrl + '/users/' + uid + '/enable');
},
disable: function disable() {
return api._put(appUrl + '/users/' + uid + '/disable');
},
remove: function remove() {
return api._delete(appUrl + '/users/' + uid);
}
};
}
};
},
userRegistrations: function userRegistrations() {
return {
sendConfirmationEmail: function sendConfirmationEmail(email) {
return api._post(appUrl + '/user_registrations/by_email/' + email + '/send_confirm');
},
runUserConfirmation: function runUserConfirmation(email) {
return api._post(appUrl + '/user_registrations/by_email/' + email + '/run_confirm');
},
confirmByEmail: function confirmByEmail(email) {
return api._post(appUrl + '/user_registrations/by_email/' + email + '/confirm');
},
listPending: function listPending(filter) {
return api._get(appUrl + '/user_registrations/pending_users', filter);
},
removePendingUserByEmail: function removePendingUserByEmail(email) {
return api._delete(appUrl + '/user_registrations/by_email/' + email);
},
removePendingUserByID: function removePendingUserByID(id) {
return api._delete(appUrl + '/user_registrations/by_id/' + id);
}
};
},
customUserData: function customUserData() {
return {
get: function get() {
return api._get(appUrl + '/custom_user_data');
},
update: function update(data) {
return api._patch(appUrl + '/custom_user_data', { body: JSON.stringify(data) });
}
};
},
debug: function debug() {
return {
executeFunction: function executeFunction(userId) {
for (var _len = arguments.length, args = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
args[_key - 2] = arguments[_key];
}
var name = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
return api._post(appUrl + '/debug/execute_function', { name: name, arguments: args }, { user_id: userId });
},
executeFunctionSource: function executeFunctionSource(_ref) {
var userId = _ref.userId,
_ref$source = _ref.source,
source = _ref$source === undefined ? '' : _ref$source,
_ref$evalSource = _ref.evalSource,
evalSource = _ref$evalSource === undefined ? '' : _ref$evalSource,
runAsSystem = _ref.runAsSystem;
return api._post(appUrl + '/debug/execute_function_source', { source: source, eval_source: evalSource }, { user_id: userId, run_as_system: runAsSystem });
}
};
},
authProviders: function authProviders() {
return {
list: function list() {
return api._get(appUrl + '/auth_providers');
},
create: function create(data) {
return api._post(appUrl + '/auth_providers', data);
},
authProvider: function authProvider(providerId) {
return {
get: function get() {
return api._get(appUrl + '/auth_providers/' + providerId);
},
update: function update(data) {
return api._patch(appUrl + '/auth_providers/' + providerId, {
body: JSON.stringify(data)
});
},
enable: function enable() {
return api._put(appUrl + '/auth_providers/' + providerId + '/enable');
},
disable: function disable() {
return api._put(appUrl + '/auth_providers/' + providerId + '/disable');
},
remove: function remove() {
return api._delete(appUrl + '/auth_providers/' + providerId);
}
};
}
};
},
security: function security() {
return {
allowedRequestOrigins: function allowedRequestOrigins() {
return {
get: function get() {
return api._get(appUrl + '/security/allowed_request_origins');
},
update: function update(data) {
return api._post(appUrl + '/security/allowed_request_origins', data);
}
};
}
};
},
logs: function logs() {
return {
list: function list(filter) {
return api._get(appUrl + '/logs', filter);
}
};
},
apiKeys: function apiKeys() {
return {
list: function list() {
return api._get(appUrl + '/api_keys');
},
create: function create(data) {
return api._post(appUrl + '/api_keys', data);
},
apiKey: function apiKey(apiKeyId) {
return {
get: function get() {
return api._get(appUrl + '/api_keys/' + apiKeyId);
},
remove: function remove() {
return api._delete(appUrl + '/api_keys/' + apiKeyId);
},
enable: function enable() {
return api._put(appUrl + '/api_keys/' + apiKeyId + '/enable');
},
disable: function disable() {
return api._put(appUrl + '/api_keys/' + apiKeyId + '/disable');
}
};
}
};
},
functions: function functions() {
return {
list: function list() {
return api._get(appUrl + '/functions');
},
create: function create(data) {
return api._post(appUrl + '/functions', data);
},
function: function _function(functionId) {
return {
get: function get() {
return api._get(appUrl + '/functions/' + functionId);
},
update: function update(data) {
return api._put(appUrl + '/functions/' + functionId, {
body: JSON.stringify(data)
});
},
remove: function remove() {
return api._delete(appUrl + '/functions/' + functionId);
}
};
}
};
},
eventSubscriptions: function eventSubscriptions() {
return {
list: function list(filter) {
return api._get(appUrl + '/event_subscriptions', filter);
},
create: function create(data) {
return api._post(appUrl + '/event_subscriptions', data);
},
eventSubscription: function eventSubscription(eventSubscriptionId) {
return {
get: function get() {
return api._get(appUrl + '/event_subscriptions/' + eventSubscriptionId);
},
update: function update(data) {
return api._put(appUrl + '/event_subscriptions/' + eventSubscriptionId, { body: JSON.stringify(data) });
},
remove: function remove() {
return api._delete(appUrl + '/event_subscriptions/' + eventSubscriptionId);
},
resume: function resume(data) {
return api._put(appUrl + '/event_subscriptions/' + eventSubscriptionId + '/resume', { body: JSON.stringify(data) });
}
};
}
};
},
validationSettings: function validationSettings() {
var validationSettingsUrl = appUrl + '/validation_settings';
return {
graphql: function graphql() {
var graphqlUrl = validationSettingsUrl + '/graphql';
return {
get: function get() {
return api._get(graphqlUrl);
},
update: function update(data) {
return api._put(graphqlUrl, { body: JSON.stringify(data) });
}
};
}
};
},
graphql: function graphql() {
var graphqlUrl = appUrl + '/graphql';
return {
config: function config() {
return {
get: function get() {
return api._get(graphqlUrl + '/config');
},
update: function update(data) {
return api._put(graphqlUrl + '/config', { body: JSON.stringify(data) });
}
};
},
post: function post(data) {
return api._post('' + graphqlUrl, data);
},
validate: function validate() {
return api._get(graphqlUrl + '/validate');
},
customResolvers: function customResolvers() {
return {
list: function list() {
return api._get(graphqlUrl + '/custom_resolvers');
},
create: function create(data) {
return api._post(graphqlUrl + '/custom_resolvers', data);
},
customResolver: function customResolver(id) {
return {
get: function get() {
return api._get(graphqlUrl + '/custom_resolvers/' + id);
},
update: function update(data) {
return api._put(graphqlUrl + '/custom_resolvers/' + id, { body: JSON.stringify(data) });
},
remove: function remove() {
return api._delete(graphqlUrl + '/custom_resolvers/' + id);
}
};
}
};
}
};
},
sync: function sync() {
var syncUrl = appUrl + '/sync';
return {
config: function config() {
var realmConfigUrl = syncUrl + '/config';
return {
get: function get() {
return api._get(realmConfigUrl);
},
update: function update(data) {
return api._put(realmConfigUrl, { body: JSON.stringify(data) });
}
};
},
clientSchemas: function clientSchemas() {
var realmClientSchemasUrl = syncUrl + '/client_schemas';
return {
get: function get(language, filter) {
return api._get(realmClientSchemasUrl + '/' + language, filter);
}
};
},
data: function data() {
var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
return api._get(syncUrl + '/data', params);
},
patchSchemas: function patchSchemas(data) {
return api._patch(syncUrl + '/schemas', { body: JSON.stringify(data) });
},
progress: function progress() {
return api._get(syncUrl + '/progress');
}
};
}
};
}
};
}
}, {
key: 'privateAdminTriggers',
value: function privateAdminTriggers(groupId, appId) {
var privateApi = this._v1[_constants.API_TYPE_PRIVATE];
var baseUrl = '/admin/groups/' + groupId + '/apps/' + appId + '/triggers';
return {
list: function list() {
return privateApi._get(baseUrl);
},
get: function get(triggerId) {
return privateApi._get(baseUrl + '/' + triggerId);
}
};
}
/**
* Manages an Atlas Cluster.
*
* @returns {Object}
*/
}, {
key: 'privateClusters',
value: function privateClusters(groupId, appId) {
var privateApi = this._v1[_constants.API_TYPE_PRIVATE];
var baseUrl = '/groups/' + groupId + '/apps/' + appId + '/atlas_clusters';
return {
create: function create(regionName) {
return privateApi._post(baseUrl, JSON.stringify({ region_name: regionName }), { credentials: 'include' });
}
};
}
/**
* Manages Atlas temporary API keys.
*
* @returns {Object}
*/
}, {
key: 'privateTempAPIKeys',
value: function privateTempAPIKeys() {
var privateApi = this._v1[_constants.API_TYPE_PRIVATE];
var baseUrl = '/auth/temp_api_keys';
return {
create: function create(desc) {
return privateApi._post(baseUrl, JSON.stringify({ desc: desc }));
}
};
}
}, {
key: 'type',
get: function get() {
return _common2.default;
}
}, {
key: '_v1',
get: function get() {
var _this3 = this;
var privateV1do = function privateV1do(url, method, options) {
return _get(StitchAdminClient.prototype.__proto__ || Object.getPrototypeOf(StitchAdminClient.prototype), '_do', _this3).call(_this3, url, method, Object.assign({ apiVersion: _constants.v1, apiType: _constants.API_TYPE_PRIVATE }, options)).then(function (response) {
var contentHeader = response.headers.get('content-type') || '';
if (contentHeader.split(',').indexOf('application/json') >= 0) {
return response.json();
}
return response;
});
};
return _defineProperty({}, _constants.API_TYPE_PRIVATE, {
_get: function _get(url, queryParams, headers, options) {
return privateV1do(url, 'GET', Object.assign({ queryParams: queryParams, headers: headers }, options));
},
_post: function _post(url, body) {
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
return privateV1do(url, 'POST', Object.assign({ body: body }, options));
}
});
}
}, {
key: '_v3',
get: function get() {
var _this4 = this;
var v3do = function v3do(url, method, options) {
return _get(StitchAdminClient.prototype.__proto__ || Object.getPrototypeOf(StitchAdminClient.prototype), '_do', _this4).call(_this4, url, method, Object.assign({}, { apiVersion: _constants.v3 }, options)).then(function (response) {
var contentHeader = response.headers.get('content-type') || '';
if (contentHeader.split(',').indexOf('application/json') >= 0) {
return response.json();
}
return response;
});
};
return {
_get: function _get(url, queryParams, headers, options) {
return v3do(url, 'GET', Object.assign({}, { queryParams: queryParams, headers: headers }, options));
},
_put: function _put(url, options) {
return options ? v3do(url, 'PUT', options) : v3do(url, 'PUT');
},
_patch: function _patch(url, options) {
return options ? v3do(url, 'PATCH', options) : v3do(url, 'PATCH');
},
_delete: function _delete(url, queryParams) {
return queryParams ? v3do(url, 'DELETE', { queryParams: queryParams }) : v3do(url, 'DELETE');
},
_post: function _post(url, body, queryParams) {
return queryParams ? v3do(url, 'POST', { body: JSON.stringify(body), queryParams: queryParams }) : v3do(url, 'POST', { body: JSON.stringify(body) });
},
_postRaw: function _postRaw(url, options) {
return v3do(url, 'POST', options);
}
};
}
}]);
return StitchAdminClient;
}(_client.StitchClient);
;