diff --git a/dist/main.js b/dist/main.js index cfc7f128..b893ece8 100644 --- a/dist/main.js +++ b/dist/main.js @@ -1 +1 @@ -!function(e){var t={};function n(r){if(t[r])return t[r].exports;var i=t[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}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 i in e)n.d(r,i,function(t){return e[t]}.bind(null,i));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=3)}([function(e,t){const n="undefined"!=typeof window&&void 0!==window.document;e.exports={convertToArrayIfNeeded:e=>Array.isArray(e)?e:[e],isBrowser:n}},function(e,t,n){e.exports=n(5)},function(e,t,n){(function(t){const{isBrowser:r}=n(0),i=!r&&!1,o=i&&t.env.MONDAY_COM_PROTOCOL||"https",s=i&&t.env.MONDAY_COM_DOMAIN||"monday.com",a=`${o}://api.${s}/v2`,c=`${o}://auth.${s}/oauth2/authorize`,u=`${o}://auth.${s}/oauth2/token`;e.exports={MONDAY_DOMAIN:s,MONDAY_PROTOCOL:o,MONDAY_API_URL:a,MONDAY_OAUTH_URL:c,MONDAY_OAUTH_TOKEN_URL:u}}).call(this,n(6))},function(e,t,n){var r,i;const{isBrowser:o}=n(0),s=n(o?4:12);"undefined"!=typeof self&&self,void 0===(i="function"==typeof(r=function(){return window.mondaySdk=s,s})?r.call(t,n,t,e):r)||(e.exports=i)},function(e,t,n){const r=n(1),{MONDAY_OAUTH_URL:i}=n(2),{convertToArrayIfNeeded:o}=n(0),{initScrollHelperIfNeeded:s}=n(9),{initBackgroundTracking:a}=n(10),c=[];class u{constructor(e={}){this._clientId=e.clientId,this._apiToken=e.apiToken,this.listeners={},this.setClientId=this.setClientId.bind(this),this.setToken=this.setToken.bind(this),this.api=this.api.bind(this),this.listen=this.listen.bind(this),this.get=this.get.bind(this),this.set=this.set.bind(this),this.execute=this.execute.bind(this),this.oauth=this.oauth.bind(this),this._receiveMessage=this._receiveMessage.bind(this),this.storage={instance:{setItem:this.setStorageInstanceItem.bind(this),getItem:this.getStorageInstanceItem.bind(this),deleteItem:this.deleteStorageInstanceItem.bind(this)}},window.addEventListener("message",this._receiveMessage,!1),e.withoutScrollHelper||s(),a(this)}setClientId(e){this._clientId=e}setToken(e){this._apiToken=e}api(e,t={}){const n={query:e,variables:t.variables},i=t.token||this._apiToken;return i?r.execute(n,i):new Promise((e,t)=>{this._localApi("api",{params:n}).then(t=>{e(t.data)}).catch(e=>t(e))})}listen(e,t,n){const r=o(e),i=[];return r.forEach(e=>{i.push(this._addListener(e,t)),this._localApi("listen",{type:e,params:n})}),()=>{i.forEach(e=>e())}}get(e,t){return this._localApi("get",{type:e,params:t})}set(e,t){return this._localApi("set",{type:e,params:t})}execute(e,t){return this._localApi("execute",{type:e,params:t})}track(e,t){return this.execute("track",{name:e,data:t})}oauth(e={}){const t=e.clientId||this._clientId;if(!t)throw new Error("clientId is required");const n=`${e.mondayOauthUrl||i}?client_id=${t}`;window.location=n}setStorageInstanceItem(e,t,n={}){return this._localApi("storage",{method:"set",key:e,value:t,options:n,segment:"instance"})}getStorageInstanceItem(e,t={}){return this._localApi("storage",{method:"get",key:e,options:t,segment:"instance"})}deleteStorageInstanceItem(e,t={}){return this._localApi("storage",{method:"delete",key:e,options:t,segment:"instance"})}_localApi(e,t){return new Promise((r,i)=>{const o=this._generateRequestId(),s=this._clientId,a=n(11).version;window.parent.postMessage({method:e,args:t,requestId:o,clientId:s,version:a},"*");const c=this._addListener(o,e=>{if(c(),e.errorMessage){const t=new Error(e.errorMessage);t.data=e.data,i(t)}else r(e)})})}_receiveMessage(e){const{method:t,type:n,requestId:r}=e.data,i=this.listeners[t]||c,o=this.listeners[n]||c,s=this.listeners[r]||c;let a=new Set([...i,...o,...s]);a&&a.forEach(t=>{try{t(e.data)}catch(e){console.error("Message callback error: ",e)}})}_addListener(e,t){return this.listeners[e]=this.listeners[e]||new Set,this.listeners[e].add(t),()=>{this.listeners[e].delete(t),0===this.listeners[e].size&&delete this.listeners[e]}}_generateRequestId(){return Math.random().toString(36).substring(2,9)}_removeEventListener(){window.removeEventListener("message",this._receiveMessage,!1)}_clearListeners(){this.listeners=[]}}e.exports=function(e={}){return new u(e)}},function(e,t,n){const{MONDAY_API_URL:r,MONDAY_OAUTH_TOKEN_URL:i}=n(2),o=n(7);e.exports={execute:async function(e,t,n={}){if(!t&&n.url!==i)throw new Error("Token is required");const s=`${n.url||r}${n.path||""}`;let a=await function(e,t,n,r={}){return o.nodeFetch(e,{method:r.method||"POST",body:JSON.stringify(t||{}),headers:{Authorization:n,"Content-Type":"application/json"}})}(s,e,t,n);const c=a.status,u=a.headers.get("content-type");if(!u||!u.includes("application/json")){if(504===c)throw new Error("Received timeout from monday.com's GraphQL API");const e=await a.text();throw new Error(e)}try{return await a.json()}catch(e){throw new Error("Could not parse JSON from monday.com's GraphQL API response")}},COULD_NOT_PARSE_JSON_RESPONSE_ERROR:"Could not parse JSON from monday.com's GraphQL API response",TOKEN_IS_REQUIRED_ERROR:"Token is required",API_TIMEOUT_ERROR:"Received timeout from monday.com's GraphQL API"}},function(e,t){var n,r,i=e.exports={};function o(){throw new Error("setTimeout has not been defined")}function s(){throw new Error("clearTimeout has not been defined")}function a(e){if(n===setTimeout)return setTimeout(e,0);if((n===o||!n)&&setTimeout)return n=setTimeout,setTimeout(e,0);try{return n(e,0)}catch(t){try{return n.call(null,e,0)}catch(t){return n.call(this,e,0)}}}!function(){try{n="function"==typeof setTimeout?setTimeout:o}catch(e){n=o}try{r="function"==typeof clearTimeout?clearTimeout:s}catch(e){r=s}}();var c,u=[],l=!1,d=-1;function h(){l&&c&&(l=!1,c.length?u=c.concat(u):d=-1,u.length&&p())}function p(){if(!l){var e=a(h);l=!0;for(var t=u.length;t;){for(c=u,u=[];++d1)for(var n=1;n{if(n)return;n=!0;const t=()=>{e.track("ping")};t(),setInterval(t,3e5)}}},function(e){e.exports=JSON.parse('{"name":"monday-sdk-js","version":"0.1.6","private":false,"repository":"https://github.com/mondaycom/monday-sdk-js","main":"src/index.js","author":"talharamati ","license":"MIT","files":["LICENSE","README.md","dist/","src/","server-sdk.js"],"dependencies":{"@types/source-map":"^0.5.2","node-fetch":"^2.6.0"},"devDependencies":{"@babel/cli":"^7.6.0","@babel/core":"^7.6.0","@babel/node":"^7.6.1","@babel/preset-env":"^7.6.0","@babel/preset-react":"^7.0.0","@babel/register":"^7.6.0","babel-loader":"^8.0.6","chai":"^4.2.0","eslint":"^6.8.0","jsdom":"^16.2.0","mocha":"^7.1.0","prettier":"^1.19.1","sinon":"^9.0.0","sinon-chai":"^3.5.0","webpack":"^4.38.0","webpack-cli":"^3.3.6","webpack-dev-server":"^3.7.2"},"scripts":{"start":"webpack-dev-server","build":"webpack --mode=production --env.WEBPACK_BUILD=true","test":"mocha \'./src/**/*-test.js\'","test:watch":"mocha \'./src/**/*-test.js\' --watch","precommit":"yarn lint && yarn style-check","lint":"eslint \'./src/**/*.*\'","style-check":"prettier --check \'./src/**/*.js\'"}}')},function(e,t,n){const r=n(1),{oauthToken:i}=n(13);class o{constructor(e={}){this._token=e.token,this.setToken=this.setToken.bind(this),this.api=this.api.bind(this)}setToken(e){this._token=e}async api(e,t={}){const n={query:e,variables:t.variables},i=t.token||this._token;if(!i)throw new Error("Should send 'token' as an option or call mondaySdk.setToken(TOKEN)");return await r.execute(n,i)}oauthToken(e,t,n){return i(e,t,n)}}e.exports=function(e={}){return new o(e)}},function(e,t,n){const{execute:r}=n(1),{MONDAY_OAUTH_TOKEN_URL:i}=n(2);e.exports={oauthToken:(e,t,n)=>r({code:e,client_id:t,client_secret:n},null,{url:i})}}]); \ No newline at end of file +!function(e){var t={};function n(i){if(t[i])return t[i].exports;var r=t[i]={i:i,l:!1,exports:{}};return e[i].call(r.exports,r,r.exports,n),r.l=!0,r.exports}n.m=e,n.c=t,n.d=function(e,t,i){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:i})},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 i=Object.create(null);if(n.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)n.d(i,r,function(t){return e[t]}.bind(null,r));return i},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=4)}([function(e,t,n){e.exports=n(6)},function(e,t,n){(function(t){function n(){return void 0!==t&&!1}const i=(e,i)=>n()&&"undefined"!==t.env[e]&&void 0!==t.env[e]?t.env[e]:i,r=()=>i("MONDAY_COM_PROTOCOL","https"),s=()=>i("MONDAY_COM_DOMAIN","monday.com"),o=()=>i("MONDAY_OAUTH_SUBDOMAIN","auth."),a=()=>`${r()}://${(()=>i("MONDAY_SUBDOMAIN_API","api."))()}${s()}/v2`;e.exports={get MONDAY_DOMAIN(){return s()},get MONDAY_PROTOCOL(){return r()},get MONDAY_API_URL(){return a()},get MONDAY_OAUTH_URL(){return(()=>`${r()}://${o()}${s()}/oauth2/authorize`)()},get MONDAY_OAUTH_TOKEN_URL(){return(()=>`${r()}://${o()}${s()}/oauth2/token`)()}}}).call(this,n(7))},function(e,t){const n="undefined"!=typeof window&&void 0!==window.document;e.exports={convertToArrayIfNeeded:e=>Array.isArray(e)?e:[e],isBrowser:n}},function(e,t){e.exports={logWarnings:e=>{const t=e&&e.extensions&&e.extensions.warnings;return t&&Array.isArray(t)?(t.forEach(e=>{if(e&&e.message)try{const t=e.locations&&e.locations.map(e=>`line ${e.line}, column ${e.column}`).join("; "),n=e.path&&e.path.join(" → ");let i=e.message;const r=["[monday API]",`${n}:`,i=(i=i.replace(/\.$/,"")).charAt(0).toLowerCase()+i.slice(1),t&&`@ ${t}`,e.extensions?["\n\nAdditional details:",e.extensions]:void 0].flat().filter(Boolean);console.warn(...r)}catch(t){e&&console.warn("[monday API] Warning:",e)}}),e):e}}},function(e,t,n){var i,r;const{isBrowser:s}=n(2),o=n(s?5:13);"undefined"!=typeof self&&self,void 0===(r="function"==typeof(i=function(){return window.mondaySdk=o,o})?i.call(t,n,t,e):i)||(e.exports=r)},function(e,t,n){const i=n(0),{MONDAY_OAUTH_URL:r}=n(1),{convertToArrayIfNeeded:s}=n(2),{initScrollHelperIfNeeded:o}=n(10),{initBackgroundTracking:a}=n(11),{logWarnings:c}=n(3),l=[],u={GLOBAL:"v2",INSTANCE:"instance"};class d{constructor(e={}){this._clientId=e.clientId,this._apiToken=e.apiToken,this._apiVersion=e.apiVersion,this.listeners={},this.setClientId=this.setClientId.bind(this),this.setToken=this.setToken.bind(this),this.setApiVersion=this.setApiVersion.bind(this),this.api=this.api.bind(this),this.listen=this.listen.bind(this),this.get=this.get.bind(this),this.set=this.set.bind(this),this.execute=this.execute.bind(this),this.oauth=this.oauth.bind(this),this._receiveMessage=this._receiveMessage.bind(this),this.storage={setItem:this.setStorageItem.bind(this),getItem:this.getStorageItem.bind(this),deleteItem:this.deleteStorageItem.bind(this),instance:{setItem:this.setStorageInstanceItem.bind(this),getItem:this.getStorageInstanceItem.bind(this),deleteItem:this.deleteStorageInstanceItem.bind(this)}},window.addEventListener("message",this._receiveMessage,!1),e.withoutScrollHelper||o(),a(this)}setClientId(e){this._clientId=e}setToken(e){this._apiToken=e}setApiVersion(e){this._apiVersion=e}api(e,t={}){const n={query:e,variables:t.variables},r=t.token||this._apiToken,s=t.apiVersion||this._apiVersion;let o;return(o=r?i.execute(n,r,{apiVersion:s}):this._localApi("api",{params:n,apiVersion:s}).then(e=>e.data)).then(c)}listen(e,t,n){const i=s(e),r=[];return i.forEach(e=>{r.push(this._addListener(e,t)),this._localApi("listen",{type:e,params:n})}),()=>{r.forEach(e=>e())}}get(e,t){return this._localApi("get",{type:e,params:t})}set(e,t){return this._localApi("set",{type:e,params:t})}execute(e,t){return this._localApi("execute",{type:e,params:t})}track(e,t){return this.execute("track",{name:e,data:t})}oauth(e={}){const t=e.clientId||this._clientId;if(!t)throw new Error("clientId is required");const n=`${e.mondayOauthUrl||r}?client_id=${t}`;window.location=n}setStorageItem(e,t,n={}){return this._localApi("storage",{method:"set",key:e,value:t,options:n,segment:u.GLOBAL})}getStorageItem(e,t={}){return this._localApi("storage",{method:"get",key:e,options:t,segment:u.GLOBAL})}deleteStorageItem(e,t={}){return this._localApi("storage",{method:"delete",key:e,options:t,segment:u.GLOBAL})}setStorageInstanceItem(e,t,n={}){return this._localApi("storage",{method:"set",key:e,value:t,options:n,segment:u.INSTANCE})}getStorageInstanceItem(e,t={}){return this._localApi("storage",{method:"get",key:e,options:t,segment:u.INSTANCE})}deleteStorageInstanceItem(e,t={}){return this._localApi("storage",{method:"delete",key:e,options:t,segment:u.INSTANCE})}_localApi(e,t){return new Promise((i,r)=>{const s=this._generateRequestId(),o=this._clientId,a=n(12).version;window.parent.postMessage({method:e,args:t,requestId:s,clientId:o,version:a},"*");const c=this._addListener(s,e=>{if(c(),e.errorMessage){const t=new Error(e.errorMessage);t.data=e.data,r(t)}else i(e)})})}_receiveMessage(e){const{method:t,type:n,requestId:i}=e.data,r=this.listeners[t]||l,s=this.listeners[n]||l,o=this.listeners[i]||l;let a=new Set([...r,...s,...o]);a&&a.forEach(t=>{try{t(e.data)}catch(e){console.error("Message callback error: ",e)}})}_addListener(e,t){return this.listeners[e]=this.listeners[e]||new Set,this.listeners[e].add(t),()=>{this.listeners[e].delete(t),0===this.listeners[e].size&&delete this.listeners[e]}}_generateRequestId(){return Math.random().toString(36).substring(2,9)}_removeEventListener(){window.removeEventListener("message",this._receiveMessage,!1)}_clearListeners(){this.listeners=[]}}e.exports=function(e={}){return new d(e)}},function(e,t,n){const{MONDAY_API_URL:i,MONDAY_OAUTH_TOKEN_URL:r}=n(1),s=n(8),o="Could not parse JSON from monday.com's GraphQL API response",a="Token is required",c="Received timeout from monday.com's GraphQL API";e.exports={execute:async function(e,t,n={}){if(!t&&n.url!==r)throw new Error(a);const l=`${n.url||i}${n.path||""}`;let u=await function(e,t,n,i={}){return s.nodeFetch(e,{method:i.method||"POST",body:JSON.stringify(t||{}),headers:{Authorization:n,"Content-Type":"application/json",...i.apiVersion?{"API-Version":i.apiVersion}:{}}})}(l,e,t,n);const d=u.status,h=u.headers.get("content-type");if(!h||!h.includes("application/json")){if(504===d)throw new Error(c);const e=await u.text();throw new Error(e)}try{return await u.json()}catch(e){throw new Error(o)}},COULD_NOT_PARSE_JSON_RESPONSE_ERROR:o,TOKEN_IS_REQUIRED_ERROR:a,API_TIMEOUT_ERROR:c}},function(e,t){var n,i,r=e.exports={};function s(){throw new Error("setTimeout has not been defined")}function o(){throw new Error("clearTimeout has not been defined")}function a(e){if(n===setTimeout)return setTimeout(e,0);if((n===s||!n)&&setTimeout)return n=setTimeout,setTimeout(e,0);try{return n(e,0)}catch(t){try{return n.call(null,e,0)}catch(t){return n.call(this,e,0)}}}!function(){try{n="function"==typeof setTimeout?setTimeout:s}catch(e){n=s}try{i="function"==typeof clearTimeout?clearTimeout:o}catch(e){i=o}}();var c,l=[],u=!1,d=-1;function h(){u&&c&&(u=!1,c.length?l=c.concat(l):d=-1,l.length&&p())}function p(){if(!u){var e=a(h);u=!0;for(var t=l.length;t;){for(c=l,l=[];++d1)for(var n=1;n{if(n)return;n=!0;const t=()=>{e.track("ping")};t(),setInterval(t,3e5)}}},function(e){e.exports=JSON.parse('{"name":"monday-sdk-js","version":"0.4.11","private":false,"repository":"https://github.com/mondaycom/monday-sdk-js","main":"src/index.js","types":"types/index.d.ts","author":"talharamati ","license":"MIT","files":["LICENSE","README.md","dist/","src/","types/","server-sdk.js"],"dependencies":{"node-fetch":"^2.6.0"},"devDependencies":{"@babel/cli":"^7.6.0","@babel/core":"^7.6.0","@babel/node":"^7.6.1","@babel/preset-env":"^7.6.0","@babel/preset-react":"^7.0.0","@babel/register":"^7.6.0","@types/source-map":"^0.5.2","babel-loader":"^8.0.6","chai":"^4.2.0","eslint":"^6.8.0","jsdom":"^16.2.0","mocha":"^7.1.0","prettier":"^1.19.1","sinon":"^9.0.0","sinon-chai":"^3.5.0","typescript":"^4.9.5","webpack":"^4.38.0","webpack-cli":"^3.3.6","webpack-dev-server":"^3.7.2"},"scripts":{"start":"webpack-dev-server","build":"webpack --mode=production --env.WEBPACK_BUILD=true","test":"mocha \'./src/**/*-test.js\'","test:watch":"mocha \'./src/**/*-test.js\' --watch","precommit":"yarn lint && yarn style-check","lint":"eslint \'./src/**/*.*\'","style-check":"prettier --check \'./src/**/*.js\'","style-fix":"prettier --write \'./src/**/*.js\'","compile-types":"tsc --noEmit"}}')},function(e,t,n){const{logWarnings:i}=n(3),r=n(0),{oauthToken:s}=n(14),o="Should send 'token' as an option or call mondaySdk.setToken(TOKEN)";class a{constructor(e={}){this._token=e.token,this._apiVersion=e.apiVersion,this.setToken=this.setToken.bind(this),this.setApiVersion=this.setApiVersion.bind(this),this.api=this.api.bind(this)}setToken(e){this._token=e}setApiVersion(e){this._apiVersion=e}api(e,t={}){const n={query:e,variables:t.variables},s=t.token||this._token,a=t.apiVersion||this._apiVersion;if(!s)throw new Error(o);return r.execute(n,s,{apiVersion:a}).then(i)}oauthToken(e,t,n){return s(e,t,n)}}e.exports=function(e={}){return new a(e)}},function(e,t,n){const{execute:i}=n(0),{MONDAY_OAUTH_TOKEN_URL:r}=n(1);e.exports={oauthToken:(e,t,n)=>{return i({code:e,client_id:t,client_secret:n},null,{url:r})}}}]); \ No newline at end of file diff --git a/package.json b/package.json index 05702ba8..7b66bafa 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "monday-sdk-js", - "version": "0.4.11", + "version": "0.4.12", "private": false, "repository": "https://github.com/mondaycom/monday-sdk-js", "main": "src/index.js",