-
Notifications
You must be signed in to change notification settings - Fork 0
/
domo.js
6 lines (6 loc) · 42.8 KB
/
domo.js
1
2
3
4
5
6
/*!
* domo.js v4.1.1
* Optional utility library for Custom Apps
*/
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.domo=t():e.domo=t()}(window,(function(){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=1)}([function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(2);t.RequestMethods=r.RequestMethods;var o=n(3);t.DataFormats=o.DataFormats;var a=n(4);t.FilterDataTypes=a.FilterDataTypes},function(e,t,n){"use strict";var r=n(0),o=n(5),a=function(){function e(){}return e.post=function(e,t,n){return i(r.RequestMethods.POST,e,n,!0,t)},e.put=function(e,t,n){return i(r.RequestMethods.PUT,e,n,!0,t)},e.get=function(e,t){return i(r.RequestMethods.GET,e,t)},e.delete=function(e,t){return i(r.RequestMethods.DELETE,e,t)},e.getAll=function(t,n){return Promise.all(t.map((function(t){return e.get(t,n)})))},e.onDataUpdate=function(e){function t(t){if(c(t.origin)&&"string"==typeof t.data&&t.data.length>0)try{var n=JSON.parse(t.data);if(!n.hasOwnProperty("alias"))return;var r=n.alias,o=JSON.stringify({event:"ack",alias:r});t.source instanceof MessagePort||t.source instanceof ServiceWorker||t.source.postMessage(o,t.origin),e(r)}catch(e){console.warn("There was an error in onDataUpdate! It may be that our event listener caught a message from another source and tried to parse it, so your update still may have worked. If you would like more info, here is the error: \n",e)}}return window.addEventListener("message",t),function(){return window.removeEventListener("message",t)}},e.navigate=function(e,t){var n=JSON.stringify({event:"navigate",url:e,isNewWindow:t});window.parent.postMessage(n,"*")},e.filterContainer=function(e){var t=window.navigator.userAgent.toLowerCase(),n=/safari/.test(t),r=/iphone|ipod|ipad/.test(t),o=JSON.stringify({event:"filter",filter:e&&e.map((function(e){return{columnName:e.column,operator:e.operator||e.operand,values:e.values,dataType:e.dataType}}))});r&&!n?window.webkit.messageHandlers.domofilter.postMessage(e.map((function(e){return{column:e.column,operand:e.operator||e.operand,values:e.values,dataType:e.dataType}}))):window.parent.postMessage(o,"*")},e.connected=!1,e.listeners={onFiltersUpdate:[]},e.connect=function(){e.connected||(e.connected=!0,e.channel=new MessageChannel,window.parent.postMessage(JSON.stringify({event:"subscribe"}),"*",[e.channel.port2]))},e.onFiltersUpdate=function(t){e.connect();var n=e.listeners.onFiltersUpdate.push(t)-1;return e.channel.port1.onmessage=function(t){var n=t.ports[0];void 0!==n&&"filtersUpdated"===t.data.event&&e.listeners.onFiltersUpdate.length>0&&(n.postMessage({}),e.listeners.onFiltersUpdate.forEach((function(e){return e(t.data.filters)})))},function(){e.listeners.onFiltersUpdate.splice(n,1)}},e.env=d(),e.__util={isVerifiedOrigin:c,getQueryParams:d,setFormatHeaders:f,isSuccess:u},e}(),s=window.__RYUU_AUTHENTICATION_TOKEN__;function i(e,t,n,o,a){return n=n||{},new Promise((function(i,c){var d=new XMLHttpRequest;if(o?d.open(e,t,o):d.open(e,t),f(d,t,n),function(e,t){t.contentType?"multipart"!==t.contentType&&e.setRequestHeader("Content-Type",t.contentType):e.setRequestHeader("Content-Type",r.DataFormats.JSON)}(d,n),function(e){s&&e.setRequestHeader("X-DOMO-Ryuu-Token",s)}(d),function(e,t){void 0!==t.responseType&&(e.responseType=t.responseType)}(d,n),d.onload=function(){var e;if(u(d.status)){!["csv","excel"].includes(n.format)&&d.response||i(d.response),"blob"===n.responseType&&i(new Blob([d.response],{type:d.getResponseHeader("content-type")}));var t=d.response;try{e=JSON.parse(t)}catch(e){return void c(Error("Invalid JSON response"))}i(e)}else c(Error(d.statusText))},d.onerror=function(){c(Error("Network Error"))},a)if(n.contentType&&n.contentType!==r.DataFormats.JSON)d.send(a);else{var p=JSON.stringify(a);d.send(p)}else d.send()}))}function u(e){return e>=200&&e<300}function c(e){var t=e.match("^https?://([^/]+[.])?(domo|domotech|domorig).(com|io)?(/.*)?$"),n=e.match("(.*).(domoapps).(.*)");return!!t&&!n}function d(){var e=location.search.substr(1),t={};return e.split("&").forEach((function(e){var n=e.split("=");t[n[0]]=decodeURIComponent(n[1])})),t}function f(e,t,n){if(-1!==t.indexOf("data/v1")){var a=void 0!==n.format?o.domoFormatToRequestFormat(n.format):r.DataFormats.DEFAULT;e.setRequestHeader("Accept",a)}}function p(e){if(e===document.body)return function(e){for(var t=0;t<e.children.length;t++)p(e.children[t])}(e);var t,n;if(e.dataset&&e.dataset.domoHref?(t="href",n=e.dataset.domoHref):e.dataset&&e.dataset.domoSrc?(t="src",n=e.dataset.domoSrc):e.hasAttribute&&e.hasAttribute("href")?(t="href",n=e.getAttribute("href")):e.hasAttribute&&e.hasAttribute("src")&&(t="src",n=e.getAttribute("src")),n&&s){var r=new URL(n,document.location.origin);r.origin===document.location.origin&&(r.searchParams.append("rpt",s),e.setAttribute(t,r.href))}}var l=new MutationObserver((function(e){for(var t=0,n=e;t<n.length;t++){n[t].addedNodes.forEach(p)}}));l.observe(document.documentElement,{childList:!0}),l.observe(document.head,{childList:!0}),e.exports=a},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),function(e){e.get="GET",e.GET="GET",e.post="POST",e.POST="POST",e.put="PUT",e.PUT="PUT",e.delete="DELETE",e.DELETE="DELETE"}(t.RequestMethods||(t.RequestMethods={}))},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),function(e){e.DEFAULT="application/array-of-objects",e.ARRAY_OF_OBJECTS="application/array-of-objects",e.JSON="application/json",e.CSV="text/csv",e.EXCEL="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",e.PLAIN="text/plain"}(t.DataFormats||(t.DataFormats={}))},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),function(e){e.NUMERIC="NUMERIC",e.DATE="DATE",e.DATETIME="DATETIME",e.STRING="STRING"}(t.FilterDataTypes||(t.FilterDataTypes={}))},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(0);t.domoFormatToRequestFormat=function(e){switch(e){case"array-of-objects":return r.DataFormats.ARRAY_OF_OBJECTS;case"array-of-arrays":return r.DataFormats.JSON;case"excel":return r.DataFormats.EXCEL;case"csv":return r.DataFormats.CSV;default:return r.DataFormats.DEFAULT}}}])}));
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIndlYnBhY2s6Ly9kb21vL3dlYnBhY2svdW5pdmVyc2FsTW9kdWxlRGVmaW5pdGlvbiIsIndlYnBhY2s6Ly9kb21vL3dlYnBhY2svYm9vdHN0cmFwIiwid2VicGFjazovL2RvbW8vLi9zcmMvbW9kZWxzL2luZGV4LnRzIiwid2VicGFjazovL2RvbW8vLi9zcmMvZG9tby50cyIsIndlYnBhY2s6Ly9kb21vLy4vc3JjL21vZGVscy9lbnVtcy9yZXF1ZXN0LW1ldGhvZHMudHMiLCJ3ZWJwYWNrOi8vZG9tby8uL3NyYy9tb2RlbHMvZW51bXMvZGF0YS1mb3JtYXRzLnRzIiwid2VicGFjazovL2RvbW8vLi9zc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gICAgfSlcbiAgICAgICAgICApO1xuICAgICAgICB9XG5cbiAgICAgICAgbGV0IHJlc3BvbnNlU3RyID0gcmVxLnJlc3BvbnNlO1xuICAgICAgICB0cnkge1xuICAgICAgICAgIC8vIGlmKCFyZXNwb25zZVN0cikge1xuICAgICAgICAgIC8vICAgcmVzcG9uc2VTdHIgPSBcInt9XCI7XG4gICAgICAgICAgLy8gfVxuICAgICAgICAgIGRhdGEgPSBKU09OLnBhcnNlKHJlc3BvbnNlU3RyKTtcbiAgICAgICAgfSBjYXRjaCAoZXgpIHtcbiAgICAgICAgICByZWplY3QoRXJyb3IoXCJJbnZhbGlkIEpTT04gcmVzcG9uc2VcIikpO1xuICAgICAgICAgIHJldHVybjtcbiAgICAgICAgfVxuICAgICAgICAvLyBSZXNvbHZlIHRoZSBwcm9taXNlIHdpdGggdGhlIHJlc3BvbnNlIHRleHRcbiAgICAgICAgcmVzb2x2ZShkYXRhKTtcbiAgICAgIH0gZWxzZSB7XG4gICAgICAgIC8vIE90aGVyd2lzZSByZWplY3Qgd2l0aCB0aGUgc3RhdHVzIHRleHRcbiAgICAgICAgLy8gd2hpY2ggd2lsbCBob3BlZnVsbHkgYmUgYSBtZWFuaW5nZnVsIGVycm9yXG4gICAgICAgIHJlamVjdChFcnJvcihyZXEuc3RhdHVzVGV4dCkpO1xuICAgICAgfVxuICAgIH07XG5cbiAgICAvLyBIYW5kbGUgbmV0d29yayBlcnJvcnNcbiAgICByZXEub25lcnJvciA9IGZ1bmN0aW9uICgpIHtcbiAgICAgIHJlamVjdChFcnJvcihcIk5ldHdvcmsgRXJyb3JcIikpO1xuICAgIH07XG5cbiAgICAvLyBNYWtlIHRoZSByZXF1ZXN0XG4gICAgaWYgKGJvZHkpIHtcbiAgICAgIGlmICghb3B0aW9ucy5jb250ZW50VHlwZSB8fCBvcHRpb25zLmNvbnRlbnRUeXBlID09PSBEYXRhRm9ybWF0cy5KU09OKSB7XG4gICAgICAgIGNvbnN0IGpzb24gPSBKU09OL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