{"version":3,"sources":["webpack:///./node_modules/aurelia-api/dist/native-modules/aurelia-api.js"],"names":["_class3","exports","__esModule","Endpoint","Config","Rest","undefined","_typeof","Symbol","iterator","obj","constructor","prototype","configure","frameworkConfig","configOrConfigure","config","container","get","_extend","_extend2","default","_aureliaPath","_aureliaFetchClient","_aureliaDependencyInjection","httpClient","endpoint","useTraditionalUriTemplates","this","defaults","headers","client","request","method","path","body","options","responseOutput","requestOptions","contentType","test","toLowerCase","JSON","stringify","buildQueryString","fetch","then","response","status","json","catch","find","resource","idOrCriteria","getRequestPath","findOne","id","criteria","post","update","updateOne","patch","patchOne","destroy","destroyOne","create","traditional","hasSlash","slice","join","String","endpoints","registerEndpoint","name","configureMethod","restOptions","_this","newClient","HttpClient","newClientConfig","withDefaults","defaultBaseUrl","withBaseUrl","getEndpoint","defaultEndpoint","endpointExists","setDefaultEndpoint","setDefaultBaseUrl","baseUrl","_this2","forEach","resolver","_dec","key","_key","of"],"mappings":"0FAKA,IAAUA,EAHVC,EAAQC,YAAa,EACrBD,EAAQE,SAAWF,EAAQG,OAASH,EAAQI,UAAOC,EAInD,IAAIC,EAA4B,mBAAXC,QAAoD,iBAApBA,OAAOC,SAAwB,SAAUC,GAAO,cAAcA,GAAS,SAAUA,GAAO,OAAOA,GAAyB,mBAAXF,QAAyBE,EAAIC,cAAgBH,QAAUE,IAAQF,OAAOI,UAAY,gBAAkBF,GAEtQT,EAAQY,UAwNR,SAAmBC,EAAiBC,GAClC,IAAIC,EAASF,EAAgBG,UAAUC,IAAId,GAE3C,GAAiC,mBAAtBW,EAGT,YAFAA,EAAkBC,GAKpBA,EAAOH,UAAUE,IA/NnB,IAUgCL,EAV5BS,EAAU,EAAQ,IAElBC,GAQ4BV,EARMS,IAQeT,EAAIR,WAAaQ,EAAM,CAAEW,QAASX,GANnFY,EAAe,EAAQ,IAEvBC,EAAsB,EAAQ,IAE9BC,EAA8B,EAAQ,IAM1C,IAAInB,EAAOJ,EAAQI,KAAO,WACxB,SAAS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,UAAUE,IAG1BrE,EAAOQ,UAAU0E,mBAAqB,SAA4Bb,GAGhE,OAFA7C,KAAKwD,gBAAkBxD,KAAKuD,YAAYV,GAEjC7C,MAGTxB,EAAOQ,UAAU2E,kBAAoB,SAA2BC,GAG9D,OAFA5D,KAAKqD,eAAiBO,EAEf5D,MAGTxB,EAAOQ,UAAUC,UAAY,SAAmBG,GAC9C,IAAIyE,EAAS7D,KAkBb,OAhBIZ,EAAOiE,iBACTrD,KAAKqD,eAAiBjE,EAAOiE,gBAG/BjE,EAAOuD,UAAUmB,QAAQ,SAAUhE,GACjC+D,EAAOjB,iBAAiB9C,EAAS+C,KAAM/C,EAASA,SAAUA,EAASV,QAE/DU,EAASL,SACXoE,EAAOH,mBAAmB5D,EAAS+C,QAInCzD,EAAOoE,iBACTxD,KAAK0D,mBAAmBtE,EAAOoE,iBAG1BxD,MAGFxB,EAjGqB,GAgHfH,EAAQE,UAAmB,EAAIqB,EAA4BmE,WAAaC,CAAK5F,EAAU,WACpG,SAASG,EAAS0F,GAGhBjE,KAAKkE,KAAOD,EAWd,OARA1F,EAASS,UAAUM,IAAM,SAAaD,GACpC,OAAOA,EAAUC,IAAId,GAAQ+E,YAAYvD,KAAKkE,OAGhD3F,EAAS4F,GAAK,SAAYF,GACxB,OAAO,IAAI1F,EAAS0F,IAGf1F,EAf6F,KAgB9FH","file":"npm.aurelia-api.7df3cb018f2b7fcb30f8.js","sourcesContent":["'use strict';\n\nexports.__esModule = true;\nexports.Endpoint = exports.Config = exports.Rest = undefined;\n\nvar _dec, _class3;\n\nvar _typeof = typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; };\n\nexports.configure = configure;\n\nvar _extend = require('extend');\n\nvar _extend2 = _interopRequireDefault(_extend);\n\nvar _aureliaPath = require('aurelia-path');\n\nvar _aureliaFetchClient = require('aurelia-fetch-client');\n\nvar _aureliaDependencyInjection = require('aurelia-dependency-injection');\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\n\n\nvar Rest = exports.Rest = function () {\n function Rest(httpClient, endpoint, useTraditionalUriTemplates) {\n \n\n this.defaults = {\n headers: {\n 'Accept': 'application/json',\n 'Content-Type': 'application/json'\n }\n };\n\n this.client = httpClient;\n this.endpoint = endpoint;\n this.useTraditionalUriTemplates = !!useTraditionalUriTemplates;\n }\n\n Rest.prototype.request = function request(method, path, body, options, responseOutput) {\n var requestOptions = (0, _extend2.default)(true, { headers: {} }, this.defaults || {}, options || {}, { method: method, body: body });\n var contentType = requestOptions.headers['Content-Type'] || requestOptions.headers['content-type'];\n\n if ((typeof body === 'undefined' ? 'undefined' : _typeof(body)) === 'object' && body !== null && contentType) {\n requestOptions.body = /^application\\/(.+\\+)?json/.test(contentType.toLowerCase()) ? JSON.stringify(body) : (0, _aureliaPath.buildQueryString)(body);\n }\n\n return this.client.fetch(path, requestOptions).then(function (response) {\n if (response.status >= 200 && response.status < 400) {\n if (responseOutput) {\n responseOutput.response = response;\n }\n\n return response.json().catch(function () {\n return null;\n });\n }\n\n throw response;\n });\n };\n\n Rest.prototype.find = function find(resource, idOrCriteria, options, responseOutput) {\n return this.request('GET', getRequestPath(resource, this.useTraditionalUriTemplates, idOrCriteria), undefined, options, responseOutput);\n };\n\n Rest.prototype.findOne = function findOne(resource, id, criteria, options, responseOutput) {\n return this.request('GET', getRequestPath(resource, this.useTraditionalUriTemplates, id, criteria), undefined, options, responseOutput);\n };\n\n Rest.prototype.post = function post(resource, body, options, responseOutput) {\n return this.request('POST', resource, body, options, responseOutput);\n };\n\n Rest.prototype.update = function update(resource, idOrCriteria, body, options, responseOutput) {\n return this.request('PUT', getRequestPath(resource, this.useTraditionalUriTemplates, idOrCriteria), body, options, responseOutput);\n };\n\n Rest.prototype.updateOne = function updateOne(resource, id, criteria, body, options, responseOutput) {\n return this.request('PUT', getRequestPath(resource, this.useTraditionalUriTemplates, id, criteria), body, options, responseOutput);\n };\n\n Rest.prototype.patch = function patch(resource, idOrCriteria, body, options, responseOutput) {\n return this.request('PATCH', getRequestPath(resource, this.useTraditionalUriTemplates, idOrCriteria), body, options, responseOutput);\n };\n\n Rest.prototype.patchOne = function patchOne(resource, id, criteria, body, options, responseOutput) {\n return this.request('PATCH', getRequestPath(resource, this.useTraditionalUriTemplates, id, criteria), body, options, responseOutput);\n };\n\n Rest.prototype.destroy = function destroy(resource, idOrCriteria, options, responseOutput) {\n return this.request('DELETE', getRequestPath(resource, this.useTraditionalUriTemplates, idOrCriteria), undefined, options, responseOutput);\n };\n\n Rest.prototype.destroyOne = function destroyOne(resource, id, criteria, options, responseOutput) {\n return this.request('DELETE', getRequestPath(resource, this.useTraditionalUriTemplates, id, criteria), undefined, options, responseOutput);\n };\n\n Rest.prototype.create = function create(resource, body, options, responseOutput) {\n return this.post(resource, body, options, responseOutput);\n };\n\n return Rest;\n}();\n\nfunction getRequestPath(resource, traditional, idOrCriteria, criteria) {\n var hasSlash = resource.slice(-1) === '/';\n\n if (typeof idOrCriteria === 'string' || typeof idOrCriteria === 'number') {\n resource = '' + (0, _aureliaPath.join)(resource, String(idOrCriteria)) + (hasSlash ? '/' : '');\n } else {\n criteria = idOrCriteria;\n }\n\n if ((typeof criteria === 'undefined' ? 'undefined' : _typeof(criteria)) === 'object' && criteria !== null) {\n resource += '?' + (0, _aureliaPath.buildQueryString)(criteria, traditional);\n } else if (criteria) {\n resource += '' + (hasSlash ? '' : '/') + criteria + (hasSlash ? '/' : '');\n }\n\n return resource;\n}\n\nvar Config = exports.Config = function () {\n function Config() {\n \n\n this.endpoints = {};\n }\n\n Config.prototype.registerEndpoint = function registerEndpoint(name, configureMethod, defaults, restOptions) {\n var _this = this;\n\n var newClient = new _aureliaFetchClient.HttpClient();\n var useTraditionalUriTemplates = void 0;\n\n if (restOptions !== undefined) {\n useTraditionalUriTemplates = restOptions.useTraditionalUriTemplates;\n }\n this.endpoints[name] = new Rest(newClient, name, useTraditionalUriTemplates);\n\n if (defaults !== undefined) {\n this.endpoints[name].defaults = defaults;\n }\n\n if (typeof configureMethod === 'function') {\n newClient.configure(function (newClientConfig) {\n return configureMethod(newClientConfig.withDefaults(_this.endpoints[name].defaults));\n });\n\n this.endpoints[name].defaults = newClient.defaults;\n\n return this;\n }\n\n if (typeof configureMethod !== 'string' && !this.defaultBaseUrl) {\n return this;\n }\n\n if (this.defaultBaseUrl && typeof configureMethod !== 'string' && typeof configureMethod !== 'function') {\n newClient.configure(function (configure) {\n configure.withBaseUrl(_this.defaultBaseUrl);\n });\n\n return this;\n }\n\n newClient.configure(function (configure) {\n configure.withBaseUrl(configureMethod);\n });\n\n return this;\n };\n\n Config.prototype.getEndpoint = function getEndpoint(name) {\n if (!name) {\n return this.defaultEndpoint || null;\n }\n\n return this.endpoints[name] || null;\n };\n\n Config.prototype.endpointExists = function endpointExists(name) {\n return !!this.endpoints[name];\n };\n\n Config.prototype.setDefaultEndpoint = function setDefaultEndpoint(name) {\n this.defaultEndpoint = this.getEndpoint(name);\n\n return this;\n };\n\n Config.prototype.setDefaultBaseUrl = function setDefaultBaseUrl(baseUrl) {\n this.defaultBaseUrl = baseUrl;\n\n return this;\n };\n\n Config.prototype.configure = function configure(config) {\n var _this2 = this;\n\n if (config.defaultBaseUrl) {\n this.defaultBaseUrl = config.defaultBaseUrl;\n }\n\n config.endpoints.forEach(function (endpoint) {\n _this2.registerEndpoint(endpoint.name, endpoint.endpoint, endpoint.config);\n\n if (endpoint.default) {\n _this2.setDefaultEndpoint(endpoint.name);\n }\n });\n\n if (config.defaultEndpoint) {\n this.setDefaultEndpoint(config.defaultEndpoint);\n }\n\n return this;\n };\n\n return Config;\n}();\n\nfunction configure(frameworkConfig, configOrConfigure) {\n var config = frameworkConfig.container.get(Config);\n\n if (typeof configOrConfigure === 'function') {\n configOrConfigure(config);\n\n return;\n }\n\n config.configure(configOrConfigure);\n}\n\nvar Endpoint = exports.Endpoint = (_dec = (0, _aureliaDependencyInjection.resolver)(), _dec(_class3 = function () {\n function Endpoint(key) {\n \n\n this._key = key;\n }\n\n Endpoint.prototype.get = function get(container) {\n return container.get(Config).getEndpoint(this._key);\n };\n\n Endpoint.of = function of(key) {\n return new Endpoint(key);\n };\n\n return Endpoint;\n}()) || _class3);"],"sourceRoot":""}