UNPKG

clayful

Version:

JavaScript & Node.js SDK for Clayful API

1 lines 2.63 kB
!function(){function r(e,t,n){function o(u,a){if(!t[u]){if(!e[u]){var s="function"==typeof require&&require;if(!a&&s)return s(u,!0);if(i)return i(u,!0);var c=new Error("Cannot find module '"+u+"'");throw c.code="MODULE_NOT_FOUND",c}var l=t[u]={exports:{}};e[u][0].call(l.exports,function(r){return o(e[u][1][r]||r)},l,l.exports,r,e,t,n)}return t[u].exports}for(var i="function"==typeof require&&require,u=0;u<n.length;u++)o(n[u]);return o}return r}()({1:[function(r,e,t){"use strict";e.exports=function(r){var e=void 0,t=void 0,n=r.Promise?new r.Promise(function(r,n){e=r,t=n}):null;return r=n?function(r,n){return r?t(r):e(n)}:r,{promise:n,callback:r}}},{}],2:[function(r,e,t){"use strict";var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(r){return typeof r}:function(r){return r&&"function"==typeof Symbol&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},o=function(){function r(r,e){var t=[],n=!0,o=!1,i=void 0;try{for(var u,a=r[Symbol.iterator]();!(n=(u=a.next()).done)&&(t.push(u.value),!e||t.length!==e);n=!0);}catch(r){o=!0,i=r}finally{try{!n&&a.return&&a.return()}finally{if(o)throw i}}return t}return function(e,t){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return r(e,t);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),i=r("../lib/callbackAsPromise"),u=function(r){return r.split("\n").filter(function(r){return r}).map(function(r){return r.match(/^([\w-]+):\s*(.+)/)}).filter(function(r){return r}).reduce(function(r,e){var t=o(e,3),n=t[1],i=t[2];return r[n]=i,r},{})},a=function(r){return r.support.cors=!0,function(e,t,n){var o=i(n),a=o.promise,s=o.callback;n=s;var c=r.param(e.query);c=c?"?"+c:"";var l={crossDomain:!0,method:e.httpMethod,url:e.requestUrl+c,headers:e.headers,xhrFields:{withCredentials:!0},converters:{"text json":function(e){return r.parseJSON(e||"null")}}};return e.payload&&(l.data=e.payload,e.usesFormData?(l.contentType=!1,l.processData=!1):(l.dataType="json",l.contentType="application/json; charset=utf-8",l.data=JSON.stringify(e.payload))),r.ajax(l).done(function(r,e,t){return n(null,{status:t.status,data:r,headers:u(t.getAllResponseHeaders())})}).fail(function(r){if(!r.responseJSON)return n(r);var o=new t(e.modelName,e.methodName,r.status,u(r.getAllResponseHeaders()),r.responseJSON.errorCode,r.responseJSON.message||r.responseJSON.error,r.responseJSON.validation||null);return n(o)}),a}};"object"===(void 0===e?"undefined":n(e))&&e.exports&&(e.exports=a),"object"===("undefined"==typeof window?"undefined":n(window))&&(window.jQueryRequestMiddleware=a)},{"../lib/callbackAsPromise":1}]},{},[2]);