From 61be9f4ffef22dcb6bab8843a9cb50fe1291aff7 Mon Sep 17 00:00:00 2001 From: Brett Willemsen Date: Tue, 24 Nov 2020 11:19:20 -0500 Subject: [PATCH 1/4] Update dependencies and roll v2.0.2 --- dist/pdjs-legacy.js | 2 +- dist/pdjs-legacy.js.map | 2 +- dist/pdjs.js | 2 +- dist/pdjs.js.map | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/dist/pdjs-legacy.js b/dist/pdjs-legacy.js index 124fabf..e1b1a7e 100644 --- a/dist/pdjs-legacy.js +++ b/dist/pdjs-legacy.js @@ -1,2 +1,2 @@ -var PagerDuty;PagerDuty=(()=>{var t={988:(t,e)=>{"use strict";function r(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function n(t,e){for(var r=0;r{"use strict";r.r(e),r.d(e,{acknowledge:()=>F,all:()=>A,api:()=>T,change:()=>C,event:()=>q,resolve:()=>L,trigger:()=>M});var n=r(98),o=r.n(n),i=r(988),u=r(818);function s(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function a(t){for(var e=1;e=0||(o[r]=t[r]);return o}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(t,r)&&(o[r]=t[r])}return o}function l(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=e,o=r.queryParameters,i=r.requestTimeout,u=void 0===i?3e4:i,s=f(r,["queryParameters","requestTimeout"]);return t=d(t=new URL(t.toString()),o),e=b(e,u),p(t.toString(),3,a(a({},s),{},{headers:new n.Headers(a(a({"Content-Type":"application/json; charset=utf-8"},h()),s.headers))}))}function p(t,e,r){return new Promise((function(n,i){o()(t,r).then((function(o){if(0===e)return n(o);if(429===o.status){var u=r.retryTimeout;y(void 0===u?2e4:u).then((function(){p(t,e-1,r).then(n).catch(i)}))}else n(o)}))}))}var y=function(t){return new Promise((function(e){return setTimeout(e,t)}))};function h(){return u.jU?{}:{"User-Agent":"pdjs/".concat("2.0.0"," (").concat(process.version,"/").concat(process.platform,")")}}function d(t,e){if(!e)return t;for(var r=t.searchParams,n=function(){var t=i[o],n=e[t];Array.isArray(n)?n.forEach((function(e){r.append(t,e)})):r.append(t,n)},o=0,i=Object.keys(e);o]+)>/g,(function(t,e){return"$"+r[e]})))}if("function"==typeof e){var i=this;return n[Symbol.replace].call(this,t,(function(){var t=[];return t.push.apply(t,arguments),"object"!==v(t[t.length-1])&&t.push(u(t,i)),e.apply(this,t)}))}return n[Symbol.replace].call(this,t,e)},m.apply(this,arguments)}function g(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&P(t,e)}function O(t){var e="function"==typeof Map?new Map:void 0;return(O=function(t){if(null===t||(r=t,-1===Function.toString.call(r).indexOf("[native code]")))return t;var r;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,n)}function n(){return w(t,arguments,E(this).constructor)}return n.prototype=Object.create(t.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),P(n,t)})(t)}function w(t,e,r){return(w=j()?Reflect.construct:function(t,e,r){var n=[null];n.push.apply(n,e);var o=new(Function.bind.apply(t,n));return r&&P(o,r.prototype),o}).apply(null,arguments)}function j(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(t){return!1}}function P(t,e){return(P=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function E(t){return(E=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function S(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function x(t){for(var e=1;e=0||(o[r]=t[r]);return o}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(t,r)&&(o[r]=t[r])}return o}(t,["endpoint","server","token","url","version","data"]),y=x(x({method:"GET"},p),{},{headers:x({Accept:"application/vnd.pagerduty+json;version=".concat(f),Authorization:"Token token=".concat(s)},p.headers)});return r=y.method,!["PUT","POST","DELETE","PATCH"].includes(null!==(n=r.toUpperCase())&&void 0!==n?n:"GET")&&l?y.queryParameters=null!==(e=y.queryParameters)&&void 0!==e?e:l:y.body=JSON.stringify(l),R(null!=a?a:"https://".concat(u,"/").concat(o.replace(/^\/+/,"")),y)}function A(t){return T(t).then((function(t){return D([t])}))}function D(t){var e=t[t.length-1];return e.next?e.next().then((function(e){return D(t.concat([e]))})):Promise.resolve(t)}function R(t,e){return l(t,e).then((function(r){var n=r;n.response=r;var o=function(t){var e=t.match(m(/.+.com\/([0-9A-Z_a-z]+)/,{resource:1}));return e?e[1]:null}(t);return r.json().then((function(r){return n.next=function(t,e,r){if(function(t){return void 0!==t.offset}(r)){if((null==r?void 0:r.more)&&void 0!==v(r.offset)&&r.limit)return function(){return R(t,x(x({},e),{},{queryParameters:x(x({},e.queryParameters),{},{limit:r.limit.toString(),offset:(r.limit+r.offset).toString()})}))}}else if(function(t){return void 0!==t.cursor}(r)&&(null==r?void 0:r.cursor))return function(){return R(t,x(x({},e),{},{queryParameters:x(x({},e.queryParameters),{},{cursor:r.cursor,limit:r.limit.toString()})}))}}(t,e,r),n.data=r,n.resource=o?r[o]:null,n})).catch((function(){return Promise.resolve(n)}))}))}function B(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function U(t){for(var e=1;e=0||(o[r]=t[r]);return o}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(t,r)&&(o[r]=t[r])}return o}(t,["server","type","data"]),s="https://".concat(r,"/v2/enqueue");return"change"===o&&(s="https://".concat(r,"/v2/change/enqueue")),function(t,e){return l(t,e).then((function(t){var e=t;return t.json().then((function(r){return e.data=r,e.response=t,e}))}))}(s,U({method:"POST",body:JSON.stringify(i)},u))}var I=function(t){return function(e){return q(U(U({},e),{},{data:U(U({},e.data),{},k({},"event_action",t))}))}},M=I("trigger"),F=I("acknowledge"),L=I("resolve"),C=function(t){return q(U(U({},t),{},{type:"change"}))}},818:(t,e)=>{"use strict";var r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},n="undefined"!=typeof window&&void 0!==window.document;"object"===("undefined"==typeof self?"undefined":r(self))&&self.constructor&&self.constructor.name,"undefined"!=typeof process&&null!=process.versions&&process.versions.node;e.jU=n},98:function(t,e){var r=function(t){function e(){this.fetch=!1,this.DOMException=t.DOMException}return e.prototype=t,new e}("undefined"!=typeof self?self:this);!function(t){!function(e){var r="URLSearchParams"in t,n="Symbol"in t&&"iterator"in Symbol,o="FileReader"in t&&"Blob"in t&&function(){try{return new Blob,!0}catch(t){return!1}}(),i="FormData"in t,u="ArrayBuffer"in t;if(u)var s=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],a=ArrayBuffer.isView||function(t){return t&&s.indexOf(Object.prototype.toString.call(t))>-1};function c(t){if("string"!=typeof t&&(t=String(t)),/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(t))throw new TypeError("Invalid character in header field name");return t.toLowerCase()}function f(t){return"string"!=typeof t&&(t=String(t)),t}function l(t){var e={next:function(){var e=t.shift();return{done:void 0===e,value:e}}};return n&&(e[Symbol.iterator]=function(){return e}),e}function p(t){this.map={},t instanceof p?t.forEach((function(t,e){this.append(e,t)}),this):Array.isArray(t)?t.forEach((function(t){this.append(t[0],t[1])}),this):t&&Object.getOwnPropertyNames(t).forEach((function(e){this.append(e,t[e])}),this)}function y(t){if(t.bodyUsed)return Promise.reject(new TypeError("Already read"));t.bodyUsed=!0}function h(t){return new Promise((function(e,r){t.onload=function(){e(t.result)},t.onerror=function(){r(t.error)}}))}function d(t){var e=new FileReader,r=h(e);return e.readAsArrayBuffer(t),r}function b(t){if(t.slice)return t.slice(0);var e=new Uint8Array(t.byteLength);return e.set(new Uint8Array(t)),e.buffer}function v(){return this.bodyUsed=!1,this._initBody=function(t){var e;this._bodyInit=t,t?"string"==typeof t?this._bodyText=t:o&&Blob.prototype.isPrototypeOf(t)?this._bodyBlob=t:i&&FormData.prototype.isPrototypeOf(t)?this._bodyFormData=t:r&&URLSearchParams.prototype.isPrototypeOf(t)?this._bodyText=t.toString():u&&o&&(e=t)&&DataView.prototype.isPrototypeOf(e)?(this._bodyArrayBuffer=b(t.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):u&&(ArrayBuffer.prototype.isPrototypeOf(t)||a(t))?this._bodyArrayBuffer=b(t):this._bodyText=t=Object.prototype.toString.call(t):this._bodyText="",this.headers.get("content-type")||("string"==typeof t?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):r&&URLSearchParams.prototype.isPrototypeOf(t)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},o&&(this.blob=function(){var t=y(this);if(t)return t;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){return this._bodyArrayBuffer?y(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(d)}),this.text=function(){var t,e,r,n=y(this);if(n)return n;if(this._bodyBlob)return t=this._bodyBlob,r=h(e=new FileReader),e.readAsText(t),r;if(this._bodyArrayBuffer)return Promise.resolve(function(t){for(var e=new Uint8Array(t),r=new Array(e.length),n=0;n-1?n:r),this.mode=e.mode||this.mode||null,this.signal=e.signal||this.signal,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&o)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(o)}function O(t){var e=new FormData;return t.trim().split("&").forEach((function(t){if(t){var r=t.split("="),n=r.shift().replace(/\+/g," "),o=r.join("=").replace(/\+/g," ");e.append(decodeURIComponent(n),decodeURIComponent(o))}})),e}function w(t,e){e||(e={}),this.type="default",this.status=void 0===e.status?200:e.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in e?e.statusText:"OK",this.headers=new p(e.headers),this.url=e.url||"",this._initBody(t)}g.prototype.clone=function(){return new g(this,{body:this._bodyInit})},v.call(g.prototype),v.call(w.prototype),w.prototype.clone=function(){return new w(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new p(this.headers),url:this.url})},w.error=function(){var t=new w(null,{status:0,statusText:""});return t.type="error",t};var j=[301,302,303,307,308];w.redirect=function(t,e){if(-1===j.indexOf(e))throw new RangeError("Invalid status code");return new w(null,{status:e,headers:{location:t}})},e.DOMException=t.DOMException;try{new e.DOMException}catch(t){e.DOMException=function(t,e){this.message=t,this.name=e;var r=Error(t);this.stack=r.stack},e.DOMException.prototype=Object.create(Error.prototype),e.DOMException.prototype.constructor=e.DOMException}function P(t,r){return new Promise((function(n,i){var u=new g(t,r);if(u.signal&&u.signal.aborted)return i(new e.DOMException("Aborted","AbortError"));var s=new XMLHttpRequest;function a(){s.abort()}s.onload=function(){var t,e,r={status:s.status,statusText:s.statusText,headers:(t=s.getAllResponseHeaders()||"",e=new p,t.replace(/\r?\n[\t ]+/g," ").split(/\r?\n/).forEach((function(t){var r=t.split(":"),n=r.shift().trim();if(n){var o=r.join(":").trim();e.append(n,o)}})),e)};r.url="responseURL"in s?s.responseURL:r.headers.get("X-Request-URL");var o="response"in s?s.response:s.responseText;n(new w(o,r))},s.onerror=function(){i(new TypeError("Network request failed"))},s.ontimeout=function(){i(new TypeError("Network request failed"))},s.onabort=function(){i(new e.DOMException("Aborted","AbortError"))},s.open(u.method,u.url,!0),"include"===u.credentials?s.withCredentials=!0:"omit"===u.credentials&&(s.withCredentials=!1),"responseType"in s&&o&&(s.responseType="blob"),u.headers.forEach((function(t,e){s.setRequestHeader(e,t)})),u.signal&&(u.signal.addEventListener("abort",a),s.onreadystatechange=function(){4===s.readyState&&u.signal.removeEventListener("abort",a)}),s.send(void 0===u._bodyInit?null:u._bodyInit)}))}P.polyfill=!0,t.fetch||(t.fetch=P,t.Headers=p,t.Request=g,t.Response=w),e.Headers=p,e.Request=g,e.Response=w,e.fetch=P}({})}(r),delete r.fetch.polyfill,(e=r.fetch).default=r.fetch,e.fetch=r.fetch,e.Headers=r.Headers,e.Request=r.Request,e.Response=r.Response,t.exports=e}},e={};function r(n){if(e[n])return e[n].exports;var o=e[n]={exports:{}};return t[n].call(o.exports,o,o.exports,r),o.exports}return r.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return r.d(e,{a:e}),e},r.d=(t,e)=>{for(var n in e)r.o(e,n)&&!r.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},r.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r(47)})(); +var PagerDuty;PagerDuty=(()=>{var t={988:(t,e)=>{"use strict";function r(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function n(t,e){for(var r=0;r{"use strict";r.r(e),r.d(e,{acknowledge:()=>F,all:()=>A,api:()=>T,change:()=>C,event:()=>q,resolve:()=>L,trigger:()=>M});var n=r(98),o=r.n(n),i=r(988),u=r(818);function s(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function a(t){for(var e=1;e=0||(o[r]=t[r]);return o}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(t,r)&&(o[r]=t[r])}return o}function l(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=e,o=r.queryParameters,i=r.requestTimeout,u=void 0===i?3e4:i,s=f(r,["queryParameters","requestTimeout"]);return t=d(t=new URL(t.toString()),o),e=b(e,u),p(t.toString(),3,a(a({},s),{},{headers:new n.Headers(a(a({"Content-Type":"application/json; charset=utf-8"},h()),s.headers))}))}function p(t,e,r){return new Promise((function(n,i){o()(t,r).then((function(o){if(0===e)return n(o);if(429===o.status){var u=r.retryTimeout;y(void 0===u?2e4:u).then((function(){p(t,e-1,r).then(n).catch(i)}))}else n(o)}))}))}var y=function(t){return new Promise((function(e){return setTimeout(e,t)}))};function h(){return u.jU?{}:{"User-Agent":"pdjs/".concat("2.0.0"," (").concat(process.version,"/").concat(process.platform,")")}}function d(t,e){if(!e)return t;for(var r=t.searchParams,n=function(){var t=i[o],n=e[t];Array.isArray(n)?n.forEach((function(e){r.append(t,e)})):r.append(t,n)},o=0,i=Object.keys(e);o]+)>/g,(function(t,e){return"$"+r[e]})))}if("function"==typeof e){var i=this;return n[Symbol.replace].call(this,t,(function(){var t=[];return t.push.apply(t,arguments),"object"!==v(t[t.length-1])&&t.push(u(t,i)),e.apply(this,t)}))}return n[Symbol.replace].call(this,t,e)},m.apply(this,arguments)}function g(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&P(t,e)}function O(t){var e="function"==typeof Map?new Map:void 0;return(O=function(t){if(null===t||(r=t,-1===Function.toString.call(r).indexOf("[native code]")))return t;var r;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,n)}function n(){return w(t,arguments,E(this).constructor)}return n.prototype=Object.create(t.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),P(n,t)})(t)}function w(t,e,r){return(w=j()?Reflect.construct:function(t,e,r){var n=[null];n.push.apply(n,e);var o=new(Function.bind.apply(t,n));return r&&P(o,r.prototype),o}).apply(null,arguments)}function j(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(t){return!1}}function P(t,e){return(P=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function E(t){return(E=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function S(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function x(t){for(var e=1;e=0||(o[r]=t[r]);return o}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(t,r)&&(o[r]=t[r])}return o}(t,["endpoint","server","token","url","version","data"]),y=x(x({method:"GET"},p),{},{headers:x({Accept:"application/vnd.pagerduty+json;version=".concat(f),Authorization:"Token token=".concat(s)},p.headers)});return r=y.method,!["PUT","POST","DELETE","PATCH"].includes(null!==(n=r.toUpperCase())&&void 0!==n?n:"GET")&&l?y.queryParameters=null!==(e=y.queryParameters)&&void 0!==e?e:l:y.body=JSON.stringify(l),R(null!=a?a:"https://".concat(u,"/").concat(o.replace(/^\/+/,"")),y)}function A(t){return T(t).then((function(t){return D([t])}))}function D(t){var e=t[t.length-1];return e.next?e.next().then((function(e){return D(t.concat([e]))})):Promise.resolve(t)}function R(t,e){return l(t,e).then((function(r){var n=r;n.response=r;var o=function(t){var e=t.match(m(/.+.com\/([0-9A-Z_a-z]+)/,{resource:1}));return e?e[1]:null}(t);return r.json().then((function(r){return n.next=function(t,e,r){if(function(t){return void 0!==t.offset}(r)){if(null!=r&&r.more&&void 0!==v(r.offset)&&r.limit)return function(){return R(t,x(x({},e),{},{queryParameters:x(x({},e.queryParameters),{},{limit:r.limit.toString(),offset:(r.limit+r.offset).toString()})}))}}else if(function(t){return void 0!==t.cursor}(r)&&null!=r&&r.cursor)return function(){return R(t,x(x({},e),{},{queryParameters:x(x({},e.queryParameters),{},{cursor:r.cursor,limit:r.limit.toString()})}))}}(t,e,r),n.data=r,n.resource=o?r[o]:null,n})).catch((function(){return Promise.resolve(n)}))}))}function B(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function U(t){for(var e=1;e=0||(o[r]=t[r]);return o}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(t,r)&&(o[r]=t[r])}return o}(t,["server","type","data"]),s="https://".concat(r,"/v2/enqueue");return"change"===o&&(s="https://".concat(r,"/v2/change/enqueue")),function(t,e){return l(t,e).then((function(t){var e=t;return t.json().then((function(r){return e.data=r,e.response=t,e}))}))}(s,U({method:"POST",body:JSON.stringify(i)},u))}var I=function(t){return function(e){return q(U(U({},e),{},{data:U(U({},e.data),{},k({},"event_action",t))}))}},M=I("trigger"),F=I("acknowledge"),L=I("resolve"),C=function(t){return q(U(U({},t),{},{type:"change"}))}},818:(t,e)=>{"use strict";var r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},n="undefined"!=typeof window&&void 0!==window.document;"object"===("undefined"==typeof self?"undefined":r(self))&&self.constructor&&self.constructor.name,"undefined"!=typeof process&&null!=process.versions&&process.versions.node;e.jU=n},98:function(t,e){var r=function(t){function e(){this.fetch=!1,this.DOMException=t.DOMException}return e.prototype=t,new e}("undefined"!=typeof self?self:this);!function(t){!function(e){var r="URLSearchParams"in t,n="Symbol"in t&&"iterator"in Symbol,o="FileReader"in t&&"Blob"in t&&function(){try{return new Blob,!0}catch(t){return!1}}(),i="FormData"in t,u="ArrayBuffer"in t;if(u)var s=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],a=ArrayBuffer.isView||function(t){return t&&s.indexOf(Object.prototype.toString.call(t))>-1};function c(t){if("string"!=typeof t&&(t=String(t)),/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(t))throw new TypeError("Invalid character in header field name");return t.toLowerCase()}function f(t){return"string"!=typeof t&&(t=String(t)),t}function l(t){var e={next:function(){var e=t.shift();return{done:void 0===e,value:e}}};return n&&(e[Symbol.iterator]=function(){return e}),e}function p(t){this.map={},t instanceof p?t.forEach((function(t,e){this.append(e,t)}),this):Array.isArray(t)?t.forEach((function(t){this.append(t[0],t[1])}),this):t&&Object.getOwnPropertyNames(t).forEach((function(e){this.append(e,t[e])}),this)}function y(t){if(t.bodyUsed)return Promise.reject(new TypeError("Already read"));t.bodyUsed=!0}function h(t){return new Promise((function(e,r){t.onload=function(){e(t.result)},t.onerror=function(){r(t.error)}}))}function d(t){var e=new FileReader,r=h(e);return e.readAsArrayBuffer(t),r}function b(t){if(t.slice)return t.slice(0);var e=new Uint8Array(t.byteLength);return e.set(new Uint8Array(t)),e.buffer}function v(){return this.bodyUsed=!1,this._initBody=function(t){var e;this._bodyInit=t,t?"string"==typeof t?this._bodyText=t:o&&Blob.prototype.isPrototypeOf(t)?this._bodyBlob=t:i&&FormData.prototype.isPrototypeOf(t)?this._bodyFormData=t:r&&URLSearchParams.prototype.isPrototypeOf(t)?this._bodyText=t.toString():u&&o&&(e=t)&&DataView.prototype.isPrototypeOf(e)?(this._bodyArrayBuffer=b(t.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):u&&(ArrayBuffer.prototype.isPrototypeOf(t)||a(t))?this._bodyArrayBuffer=b(t):this._bodyText=t=Object.prototype.toString.call(t):this._bodyText="",this.headers.get("content-type")||("string"==typeof t?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):r&&URLSearchParams.prototype.isPrototypeOf(t)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},o&&(this.blob=function(){var t=y(this);if(t)return t;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){return this._bodyArrayBuffer?y(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(d)}),this.text=function(){var t,e,r,n=y(this);if(n)return n;if(this._bodyBlob)return t=this._bodyBlob,r=h(e=new FileReader),e.readAsText(t),r;if(this._bodyArrayBuffer)return Promise.resolve(function(t){for(var e=new Uint8Array(t),r=new Array(e.length),n=0;n-1?n:r),this.mode=e.mode||this.mode||null,this.signal=e.signal||this.signal,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&o)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(o)}function O(t){var e=new FormData;return t.trim().split("&").forEach((function(t){if(t){var r=t.split("="),n=r.shift().replace(/\+/g," "),o=r.join("=").replace(/\+/g," ");e.append(decodeURIComponent(n),decodeURIComponent(o))}})),e}function w(t,e){e||(e={}),this.type="default",this.status=void 0===e.status?200:e.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in e?e.statusText:"OK",this.headers=new p(e.headers),this.url=e.url||"",this._initBody(t)}g.prototype.clone=function(){return new g(this,{body:this._bodyInit})},v.call(g.prototype),v.call(w.prototype),w.prototype.clone=function(){return new w(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new p(this.headers),url:this.url})},w.error=function(){var t=new w(null,{status:0,statusText:""});return t.type="error",t};var j=[301,302,303,307,308];w.redirect=function(t,e){if(-1===j.indexOf(e))throw new RangeError("Invalid status code");return new w(null,{status:e,headers:{location:t}})},e.DOMException=t.DOMException;try{new e.DOMException}catch(t){e.DOMException=function(t,e){this.message=t,this.name=e;var r=Error(t);this.stack=r.stack},e.DOMException.prototype=Object.create(Error.prototype),e.DOMException.prototype.constructor=e.DOMException}function P(t,r){return new Promise((function(n,i){var u=new g(t,r);if(u.signal&&u.signal.aborted)return i(new e.DOMException("Aborted","AbortError"));var s=new XMLHttpRequest;function a(){s.abort()}s.onload=function(){var t,e,r={status:s.status,statusText:s.statusText,headers:(t=s.getAllResponseHeaders()||"",e=new p,t.replace(/\r?\n[\t ]+/g," ").split(/\r?\n/).forEach((function(t){var r=t.split(":"),n=r.shift().trim();if(n){var o=r.join(":").trim();e.append(n,o)}})),e)};r.url="responseURL"in s?s.responseURL:r.headers.get("X-Request-URL");var o="response"in s?s.response:s.responseText;n(new w(o,r))},s.onerror=function(){i(new TypeError("Network request failed"))},s.ontimeout=function(){i(new TypeError("Network request failed"))},s.onabort=function(){i(new e.DOMException("Aborted","AbortError"))},s.open(u.method,u.url,!0),"include"===u.credentials?s.withCredentials=!0:"omit"===u.credentials&&(s.withCredentials=!1),"responseType"in s&&o&&(s.responseType="blob"),u.headers.forEach((function(t,e){s.setRequestHeader(e,t)})),u.signal&&(u.signal.addEventListener("abort",a),s.onreadystatechange=function(){4===s.readyState&&u.signal.removeEventListener("abort",a)}),s.send(void 0===u._bodyInit?null:u._bodyInit)}))}P.polyfill=!0,t.fetch||(t.fetch=P,t.Headers=p,t.Request=g,t.Response=w),e.Headers=p,e.Request=g,e.Response=w,e.fetch=P}({})}(r),delete r.fetch.polyfill,(e=r.fetch).default=r.fetch,e.fetch=r.fetch,e.Headers=r.Headers,e.Request=r.Request,e.Response=r.Response,t.exports=e}},e={};function r(n){if(e[n])return e[n].exports;var o=e[n]={exports:{}};return t[n].call(o.exports,o,o.exports,r),o.exports}return r.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return r.d(e,{a:e}),e},r.d=(t,e)=>{for(var n in e)r.o(e,n)&&!r.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},r.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r(47)})(); //# sourceMappingURL=pdjs-legacy.js.map \ No newline at end of file diff --git a/dist/pdjs-legacy.js.map b/dist/pdjs-legacy.js.map index 16fc50a..90aa916 100644 --- a/dist/pdjs-legacy.js.map +++ b/dist/pdjs-legacy.js.map @@ -1 +1 @@ -{"version":3,"sources":["webpack://PagerDuty/./node_modules/abortcontroller-polyfill/dist/cjs-ponyfill.js","webpack://PagerDuty/./src/common.ts","webpack://PagerDuty/./src/api.ts","webpack://PagerDuty/./src/events.ts","webpack://PagerDuty/./node_modules/browser-or-node/lib/index.js","webpack://PagerDuty/./node_modules/cross-fetch/dist/browser-ponyfill.js","webpack://PagerDuty/webpack/bootstrap","webpack://PagerDuty/webpack/startup","webpack://PagerDuty/webpack/runtime/compat get default export","webpack://PagerDuty/webpack/runtime/define property getters","webpack://PagerDuty/webpack/runtime/hasOwnProperty shorthand","webpack://PagerDuty/webpack/runtime/make namespace object"],"names":["_classCallCheck","instance","Constructor","TypeError","_defineProperties","target","props","i","length","descriptor","enumerable","configurable","writable","Object","defineProperty","key","_createClass","protoProps","staticProps","prototype","_getPrototypeOf","o","setPrototypeOf","getPrototypeOf","__proto__","_setPrototypeOf","p","_assertThisInitialized","self","ReferenceError","_possibleConstructorReturn","call","_get","property","receiver","Reflect","get","base","object","hasOwnProperty","_superPropBase","desc","getOwnPropertyDescriptor","value","Emitter","this","type","callback","listeners","push","stack","l","splice","event","_this","debounce","setTimeout","defaultPrevented","AbortSignal","_Emitter","subClass","superClass","create","constructor","_inherits","Derived","hasNativeReflectConstruct","_super","construct","sham","Proxy","Date","toString","e","_isNativeReflectConstruct","result","Super","NewTarget","arguments","apply","_this2","aborted","onabort","AbortController","Event","document","createEvent","initEvent","createEventObject","bubbles","cancelable","signal","dispatchEvent","Symbol","toStringTag","exports","request","url","options","queryParameters","requestTimeout","rest","applyParameters","URL","applyTimeout","fetch_retry","headers","Headers","userAgentHeader","retries","Promise","resolve","reject","fetch","then","response","status","retryTimeout","retryTimeoutPromise","milliseconds","isBrowser","process","version","platform","combinedParameters","searchParams","parameter","Array","isArray","forEach","item","append","keys","search","init","timeout","controller","abort","api","apiParameters","endpoint","partialParameters","partial","shorthand","method","shorthandParameters","post","put","patch","all","partialCall","server","token","data","config","Accept","Authorization","includes","toUpperCase","body","JSON","stringify","apiRequest","replace","allInner","responses","next","concat","apiResponse","resource","match","resourceKey","json","undefined","offset","isOffsetPagination","more","limit","cursor","isCursorPagination","nextFunc","eventParameters","eventFetch","action","trigger","acknowledge","change","_typeof","iterator","obj","window","name","versions","node","__self__","root","F","DOMException","support","Blob","viewClasses","isArrayBufferView","ArrayBuffer","isView","indexOf","normalizeName","String","test","toLowerCase","normalizeValue","iteratorFor","items","shift","done","map","header","getOwnPropertyNames","consumed","bodyUsed","fileReaderReady","reader","onload","onerror","error","readBlobAsArrayBuffer","blob","FileReader","promise","readAsArrayBuffer","bufferClone","buf","slice","view","Uint8Array","byteLength","set","buffer","Body","_initBody","_bodyInit","_bodyText","isPrototypeOf","_bodyBlob","FormData","_bodyFormData","URLSearchParams","DataView","_bodyArrayBuffer","rejected","Error","arrayBuffer","text","readAsText","chars","fromCharCode","join","readArrayBufferAsText","formData","decode","parse","oldValue","has","thisArg","values","entries","methods","Request","input","upcased","credentials","mode","referrer","form","trim","split","bytes","decodeURIComponent","Response","bodyInit","ok","statusText","clone","redirectStatuses","redirect","RangeError","location","err","message","xhr","XMLHttpRequest","abortXhr","rawHeaders","getAllResponseHeaders","line","parts","responseURL","responseText","ontimeout","open","withCredentials","responseType","setRequestHeader","addEventListener","onreadystatechange","readyState","removeEventListener","send","polyfill","default","module","__webpack_module_cache__","__webpack_require__","moduleId","__webpack_modules__","n","getter","__esModule","d","a","definition","prop","r"],"mappings":"8DAIA,SAASA,EAAgBC,EAAUC,GACjC,KAAMD,aAAoBC,GACxB,MAAM,IAAIC,UAAU,qCAIxB,SAASC,EAAkBC,EAAQC,GACjC,IAAK,IAAIC,EAAI,EAAGA,EAAID,EAAME,OAAQD,IAAK,CACrC,IAAIE,EAAaH,EAAMC,GACvBE,EAAWC,WAAaD,EAAWC,aAAc,EACjDD,EAAWE,cAAe,EACtB,UAAWF,IAAYA,EAAWG,UAAW,GACjDC,OAAOC,eAAeT,EAAQI,EAAWM,IAAKN,IAIlD,SAASO,EAAad,EAAae,EAAYC,GAG7C,OAFID,GAAYb,EAAkBF,EAAYiB,UAAWF,GACrDC,GAAad,EAAkBF,EAAagB,GACzChB,EAkBT,SAASkB,EAAgBC,GAIvB,OAHAD,EAAkBP,OAAOS,eAAiBT,OAAOU,eAAiB,SAAyBF,GACzF,OAAOA,EAAEG,WAAaX,OAAOU,eAAeF,KAEvBA,GAGzB,SAASI,EAAgBJ,EAAGK,GAM1B,OALAD,EAAkBZ,OAAOS,gBAAkB,SAAyBD,EAAGK,GAErE,OADAL,EAAEG,UAAYE,EACPL,IAGcA,EAAGK,GAgB5B,SAASC,EAAuBC,GAC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,KAAK8J,EAAKmI,GCCjFT,EAAoBU,EAAKlO,IACH,oBAAXF,QAA0BA,OAAOC,aAC1CjF,OAAOC,eAAeiF,EAASF,OAAOC,YAAa,CAAEnD,MAAO,WAE7D9B,OAAOC,eAAeiF,EAAS,aAAc,CAAEpD,OAAO,KJFhD4Q,EAAoB,K","file":"pdjs-legacy.js","sourcesContent":["'use strict';\n\nObject.defineProperty(exports, '__esModule', { value: true });\n\nfunction _classCallCheck(instance, Constructor) {\n if (!(instance instanceof Constructor)) {\n throw new TypeError(\"Cannot call a class as a function\");\n }\n}\n\nfunction _defineProperties(target, props) {\n for (var i = 0; i < props.length; i++) {\n var descriptor = props[i];\n descriptor.enumerable = descriptor.enumerable || false;\n descriptor.configurable = true;\n if (\"value\" in descriptor) descriptor.writable = true;\n Object.defineProperty(target, descriptor.key, descriptor);\n }\n}\n\nfunction _createClass(Constructor, protoProps, staticProps) {\n if (protoProps) _defineProperties(Constructor.prototype, protoProps);\n if (staticProps) _defineProperties(Constructor, staticProps);\n return Constructor;\n}\n\nfunction _inherits(subClass, superClass) {\n if (typeof superClass !== \"function\" && superClass !== null) {\n throw new TypeError(\"Super expression must either be null or a function\");\n }\n\n subClass.prototype = Object.create(superClass && superClass.prototype, {\n constructor: {\n value: subClass,\n writable: true,\n configurable: true\n }\n });\n if (superClass) _setPrototypeOf(subClass, superClass);\n}\n\nfunction _getPrototypeOf(o) {\n _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {\n return o.__proto__ || Object.getPrototypeOf(o);\n };\n return _getPrototypeOf(o);\n}\n\nfunction _setPrototypeOf(o, p) {\n _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {\n o.__proto__ = p;\n return o;\n };\n\n return _setPrototypeOf(o, p);\n}\n\nfunction _isNativeReflectConstruct() {\n if (typeof Reflect === \"undefined\" || !Reflect.construct) return false;\n if (Reflect.construct.sham) return false;\n if (typeof Proxy === \"function\") return true;\n\n try {\n Date.prototype.toString.call(Reflect.construct(Date, [], function () {}));\n return true;\n } catch (e) {\n return false;\n }\n}\n\nfunction _assertThisInitialized(self) {\n if (self === void 0) {\n throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\");\n }\n\n return self;\n}\n\nfunction _possibleConstructorReturn(self, call) {\n if (call && (typeof call === \"object\" || typeof call === \"function\")) {\n return call;\n }\n\n return _assertThisInitialized(self);\n}\n\nfunction _createSuper(Derived) {\n var hasNativeReflectConstruct = _isNativeReflectConstruct();\n\n return function _createSuperInternal() {\n var Super = _getPrototypeOf(Derived),\n result;\n\n if (hasNativeReflectConstruct) {\n var NewTarget = _getPrototypeOf(this).constructor;\n\n result = Reflect.construct(Super, arguments, NewTarget);\n } else {\n result = Super.apply(this, arguments);\n }\n\n return _possibleConstructorReturn(this, result);\n };\n}\n\nfunction _superPropBase(object, property) {\n while (!Object.prototype.hasOwnProperty.call(object, property)) {\n object = _getPrototypeOf(object);\n if (object === null) break;\n }\n\n return object;\n}\n\nfunction _get(target, property, receiver) {\n if (typeof Reflect !== \"undefined\" && Reflect.get) {\n _get = Reflect.get;\n } else {\n _get = function _get(target, property, receiver) {\n var base = _superPropBase(target, property);\n\n if (!base) return;\n var desc = Object.getOwnPropertyDescriptor(base, property);\n\n if (desc.get) {\n return desc.get.call(receiver);\n }\n\n return desc.value;\n };\n }\n\n return _get(target, property, receiver || target);\n}\n\nvar Emitter = /*#__PURE__*/function () {\n function Emitter() {\n _classCallCheck(this, Emitter);\n\n Object.defineProperty(this, 'listeners', {\n value: {},\n writable: true,\n configurable: true\n });\n }\n\n _createClass(Emitter, [{\n key: \"addEventListener\",\n value: function addEventListener(type, callback) {\n if (!(type in this.listeners)) {\n this.listeners[type] = [];\n }\n\n this.listeners[type].push(callback);\n }\n }, {\n key: \"removeEventListener\",\n value: function removeEventListener(type, callback) {\n if (!(type in this.listeners)) {\n return;\n }\n\n var stack = this.listeners[type];\n\n for (var i = 0, l = stack.length; i < l; i++) {\n if (stack[i] === callback) {\n stack.splice(i, 1);\n return;\n }\n }\n }\n }, {\n key: \"dispatchEvent\",\n value: function dispatchEvent(event) {\n var _this = this;\n\n if (!(event.type in this.listeners)) {\n return;\n }\n\n var debounce = function debounce(callback) {\n setTimeout(function () {\n return callback.call(_this, event);\n });\n };\n\n var stack = this.listeners[event.type];\n\n for (var i = 0, l = stack.length; i < l; i++) {\n debounce(stack[i]);\n }\n\n return !event.defaultPrevented;\n }\n }]);\n\n return Emitter;\n}();\n\nvar AbortSignal = /*#__PURE__*/function (_Emitter) {\n _inherits(AbortSignal, _Emitter);\n\n var _super = _createSuper(AbortSignal);\n\n function AbortSignal() {\n var _this2;\n\n _classCallCheck(this, AbortSignal);\n\n _this2 = _super.call(this); // Some versions of babel does not transpile super() correctly for IE <= 10, if the parent\n // constructor has failed to run, then \"this.listeners\" will still be undefined and then we call\n // the parent constructor directly instead as a workaround. For general details, see babel bug:\n // https://github.com/babel/babel/issues/3041\n // This hack was added as a fix for the issue described here:\n // https://github.com/Financial-Times/polyfill-library/pull/59#issuecomment-477558042\n\n if (!_this2.listeners) {\n Emitter.call(_assertThisInitialized(_this2));\n } // Compared to assignment, Object.defineProperty makes properties non-enumerable by default and\n // we want Object.keys(new AbortController().signal) to be [] for compat with the native impl\n\n\n Object.defineProperty(_assertThisInitialized(_this2), 'aborted', {\n value: false,\n writable: true,\n configurable: true\n });\n Object.defineProperty(_assertThisInitialized(_this2), 'onabort', {\n value: null,\n writable: true,\n configurable: true\n });\n return _this2;\n }\n\n _createClass(AbortSignal, [{\n key: \"toString\",\n value: function toString() {\n return '[object AbortSignal]';\n }\n }, {\n key: \"dispatchEvent\",\n value: function dispatchEvent(event) {\n if (event.type === 'abort') {\n this.aborted = true;\n\n if (typeof this.onabort === 'function') {\n this.onabort.call(this, event);\n }\n }\n\n _get(_getPrototypeOf(AbortSignal.prototype), \"dispatchEvent\", this).call(this, event);\n }\n }]);\n\n return AbortSignal;\n}(Emitter);\nvar AbortController = /*#__PURE__*/function () {\n function AbortController() {\n _classCallCheck(this, AbortController);\n\n // Compared to assignment, Object.defineProperty makes properties non-enumerable by default and\n // we want Object.keys(new AbortController()) to be [] for compat with the native impl\n Object.defineProperty(this, 'signal', {\n value: new AbortSignal(),\n writable: true,\n configurable: true\n });\n }\n\n _createClass(AbortController, [{\n key: \"abort\",\n value: function abort() {\n var event;\n\n try {\n event = new Event('abort');\n } catch (e) {\n if (typeof document !== 'undefined') {\n if (!document.createEvent) {\n // For Internet Explorer 8:\n event = document.createEventObject();\n event.type = 'abort';\n } else {\n // For Internet Explorer 11:\n event = document.createEvent('Event');\n event.initEvent('abort', false, false);\n }\n } else {\n // Fallback where document isn't available:\n event = {\n type: 'abort',\n bubbles: false,\n cancelable: false\n };\n }\n }\n\n this.signal.dispatchEvent(event);\n }\n }, {\n key: \"toString\",\n value: function toString() {\n return '[object AbortController]';\n }\n }]);\n\n return AbortController;\n}();\n\nif (typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n // These are necessary to make sure that we get correct output for:\n // Object.prototype.toString.call(new AbortController())\n AbortController.prototype[Symbol.toStringTag] = 'AbortController';\n AbortSignal.prototype[Symbol.toStringTag] = 'AbortSignal';\n}\n\nfunction polyfillNeeded(self) {\n if (self.__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL) {\n console.log('__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL=true is set, will force install polyfill');\n return true;\n } // Note that the \"unfetch\" minimal fetch polyfill defines fetch() without\n // defining window.Request, and this polyfill need to work on top of unfetch\n // so the below feature detection needs the !self.AbortController part.\n // The Request.prototype check is also needed because Safari versions 11.1.2\n // up to and including 12.1.x has a window.AbortController present but still\n // does NOT correctly implement abortable fetch:\n // https://bugs.webkit.org/show_bug.cgi?id=174980#c2\n\n\n return typeof self.Request === 'function' && !self.Request.prototype.hasOwnProperty('signal') || !self.AbortController;\n}\n\n/**\n * Note: the \"fetch.Request\" default value is available for fetch imported from\n * the \"node-fetch\" package and not in browsers. This is OK since browsers\n * will be importing umd-polyfill.js from that path \"self\" is passed the\n * decorator so the default value will not be used (because browsers that define\n * fetch also has Request). One quirky setup where self.fetch exists but\n * self.Request does not is when the \"unfetch\" minimal fetch polyfill is used\n * on top of IE11; for this case the browser will try to use the fetch.Request\n * default value which in turn will be undefined but then then \"if (Request)\"\n * will ensure that you get a patched fetch but still no Request (as expected).\n * @param {fetch, Request = fetch.Request}\n * @returns {fetch: abortableFetch, Request: AbortableRequest}\n */\n\nfunction abortableFetchDecorator(patchTargets) {\n if ('function' === typeof patchTargets) {\n patchTargets = {\n fetch: patchTargets\n };\n }\n\n var _patchTargets = patchTargets,\n fetch = _patchTargets.fetch,\n _patchTargets$Request = _patchTargets.Request,\n NativeRequest = _patchTargets$Request === void 0 ? fetch.Request : _patchTargets$Request,\n NativeAbortController = _patchTargets.AbortController,\n _patchTargets$__FORCE = _patchTargets.__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL,\n __FORCE_INSTALL_ABORTCONTROLLER_POLYFILL = _patchTargets$__FORCE === void 0 ? false : _patchTargets$__FORCE;\n\n if (!polyfillNeeded({\n fetch: fetch,\n Request: NativeRequest,\n AbortController: NativeAbortController,\n __FORCE_INSTALL_ABORTCONTROLLER_POLYFILL: __FORCE_INSTALL_ABORTCONTROLLER_POLYFILL\n })) {\n return {\n fetch: fetch,\n Request: Request\n };\n }\n\n var Request = NativeRequest; // Note that the \"unfetch\" minimal fetch polyfill defines fetch() without\n // defining window.Request, and this polyfill need to work on top of unfetch\n // hence we only patch it if it's available. Also we don't patch it if signal\n // is already available on the Request prototype because in this case support\n // is present and the patching below can cause a crash since it assigns to\n // request.signal which is technically a read-only property. This latter error\n // happens when you run the main5.js node-fetch example in the repo\n // \"abortcontroller-polyfill-examples\". The exact error is:\n // request.signal = init.signal;\n // ^\n // TypeError: Cannot set property signal of # which has only a getter\n\n if (Request && !Request.prototype.hasOwnProperty('signal') || __FORCE_INSTALL_ABORTCONTROLLER_POLYFILL) {\n Request = function Request(input, init) {\n var signal;\n\n if (init && init.signal) {\n signal = init.signal; // Never pass init.signal to the native Request implementation when the polyfill has\n // been installed because if we're running on top of a browser with a\n // working native AbortController (i.e. the polyfill was installed due to\n // __FORCE_INSTALL_ABORTCONTROLLER_POLYFILL being set), then passing our\n // fake AbortSignal to the native fetch will trigger:\n // TypeError: Failed to construct 'Request': member signal is not of type AbortSignal.\n\n delete init.signal;\n }\n\n var request = new NativeRequest(input, init);\n\n if (signal) {\n Object.defineProperty(request, 'signal', {\n writable: false,\n enumerable: false,\n configurable: true,\n value: signal\n });\n }\n\n return request;\n };\n\n Request.prototype = NativeRequest.prototype;\n }\n\n var realFetch = fetch;\n\n var abortableFetch = function abortableFetch(input, init) {\n var signal = Request && Request.prototype.isPrototypeOf(input) ? input.signal : init ? init.signal : undefined;\n\n if (signal) {\n var abortError;\n\n try {\n abortError = new DOMException('Aborted', 'AbortError');\n } catch (err) {\n // IE 11 does not support calling the DOMException constructor, use a\n // regular error object on it instead.\n abortError = new Error('Aborted');\n abortError.name = 'AbortError';\n } // Return early if already aborted, thus avoiding making an HTTP request\n\n\n if (signal.aborted) {\n return Promise.reject(abortError);\n } // Turn an event into a promise, reject it once `abort` is dispatched\n\n\n var cancellation = new Promise(function (_, reject) {\n signal.addEventListener('abort', function () {\n return reject(abortError);\n }, {\n once: true\n });\n });\n\n if (init && init.signal) {\n // Never pass .signal to the native implementation when the polyfill has\n // been installed because if we're running on top of a browser with a\n // working native AbortController (i.e. the polyfill was installed due to\n // __FORCE_INSTALL_ABORTCONTROLLER_POLYFILL being set), then passing our\n // fake AbortSignal to the native fetch will trigger:\n // TypeError: Failed to execute 'fetch' on 'Window': member signal is not of type AbortSignal.\n delete init.signal;\n } // Return the fastest promise (don't need to wait for request to finish)\n\n\n return Promise.race([cancellation, realFetch(input, init)]);\n }\n\n return realFetch(input, init);\n };\n\n return {\n fetch: abortableFetch,\n Request: Request\n };\n}\n\nexports.AbortController = AbortController;\nexports.AbortSignal = AbortSignal;\nexports.abortableFetch = abortableFetchDecorator;\n","/* LEGACY-BROWSER-SUPPORT-START */\nimport fetch, {Headers} from 'cross-fetch';\nimport {AbortController} from 'abortcontroller-polyfill/dist/cjs-ponyfill';\nimport {isBrowser} from 'browser-or-node';\n/* LEGACY-BROWSER-SUPPORT-END */\n\nconst VERSION = '2.0.0';\n\ntype QueryParameter = Record>;\n\nexport interface RequestOptions extends RequestInit {\n queryParameters?: QueryParameter;\n retryCount?: number;\n requestTimeout?: number;\n retryTimeout?: number;\n timeout?: number;\n}\n\nexport function request(\n url: string | URL,\n options: RequestOptions = {}\n): Promise {\n const {queryParameters, requestTimeout = 30000, ...rest} = options;\n\n url = new URL(url.toString());\n\n url = applyParameters(url, queryParameters);\n options = applyTimeout(options, requestTimeout);\n\n return fetch_retry(url.toString(), 3, {\n ...rest,\n headers: new Headers({\n 'Content-Type': 'application/json; charset=utf-8',\n /* LEGACY-BROWSER-SUPPORT-START */\n ...userAgentHeader(),\n /* LEGACY-BROWSER-SUPPORT-END */\n ...rest.headers,\n }),\n });\n}\n\nfunction fetch_retry(\n url: string,\n retries: number,\n options: RequestOptions\n): Promise {\n return new Promise((resolve, reject) => {\n fetch(url, options).then(response => {\n // We don't want to `reject` when retries have finished\n // Instead simply stop trying and return.\n if (retries === 0) return resolve(response);\n if (response.status === 429) {\n const {retryTimeout = 20000} = options;\n retryTimeoutPromise(retryTimeout).then(() => {\n fetch_retry(url, retries - 1, options)\n .then(resolve)\n .catch(reject);\n });\n } else {\n resolve(response);\n }\n });\n });\n}\n\nconst retryTimeoutPromise = (milliseconds: number) => {\n return new Promise(resolve => setTimeout(resolve, milliseconds));\n};\n\nfunction userAgentHeader(): object {\n if (isBrowser) return {};\n\n return {\n 'User-Agent': `pdjs/${VERSION} (${process.version}/${process.platform})`,\n };\n}\n\nfunction applyParameters(url: URL, queryParameters?: QueryParameter): URL {\n if (!queryParameters) return url;\n\n const combinedParameters = url.searchParams;\n\n for (const key of Object.keys(queryParameters)) {\n const parameter = queryParameters[key];\n if (Array.isArray(parameter)) {\n // Support for array based keys like `additional_fields[]`\n parameter.forEach(item => {\n combinedParameters.append(key, item);\n });\n } else {\n combinedParameters.append(key, parameter);\n }\n }\n\n url.search = combinedParameters.toString();\n return url;\n}\n\nfunction applyTimeout(init: RequestOptions, timeout?: number): RequestOptions {\n if (!timeout) return init;\n\n const controller = new AbortController();\n setTimeout(() => controller.abort(), timeout);\n\n return {\n ...init,\n signal: controller.signal,\n };\n}\n","import {request, RequestOptions} from './common';\n\nexport interface ShorthandCall {\n (res: string, apiParameters?: Partial): APIPromise;\n}\n\nexport interface PartialCall {\n (apiParameters: APIParameters): APIPromise;\n (apiParameters: Partial): PartialCall;\n get: ShorthandCall;\n post: ShorthandCall;\n put: ShorthandCall;\n patch: ShorthandCall;\n delete: ShorthandCall;\n all: (apiParameters: APIParameters) => Promise;\n}\n\nexport type APIParameters = RequestOptions & {\n endpoint?: string;\n url?: string;\n data?: object;\n token?: string;\n server?: string;\n version?: number;\n} & ({endpoint: string} | {url: string});\n\nexport type APIPromise = Promise;\n\nexport interface APIResponse extends Response {\n data: any;\n resource: any;\n response: Response;\n next?: () => APIPromise;\n}\n\nexport function api(apiParameters: APIParameters): APIPromise;\nexport function api(apiParameters: Partial): PartialCall;\nexport function api(\n apiParameters: Partial\n): APIPromise | PartialCall {\n // If the apiParameters don't include `endpoint` treat it as a partial\n // application.\n if (!apiParameters.endpoint && !apiParameters.url) {\n return partialCall(apiParameters);\n }\n\n const {\n endpoint,\n server = 'api.pagerduty.com',\n token,\n url,\n version = 2,\n data,\n ...rest\n } = apiParameters;\n\n const config: RequestOptions = {\n method: 'GET',\n ...rest,\n headers: {\n Accept: `application/vnd.pagerduty+json;version=${version}`,\n Authorization: `Token token=${token!}`,\n ...rest.headers,\n },\n };\n\n // Allow `data` for `queryParameters` for requests without bodies.\n if (isReadonlyRequest(config.method!) && data) {\n config.queryParameters =\n config.queryParameters ?? (data as Record);\n } else {\n config.body = JSON.stringify(data);\n }\n\n return apiRequest(\n url ?? `https://${server}/${endpoint!.replace(/^\\/+/, '')}`,\n config\n );\n}\n\nexport function all(apiParameters: APIParameters): Promise {\n return (api(apiParameters) as APIPromise).then(response =>\n allInner([response])\n );\n}\n\nfunction allInner(responses: APIResponse[]): Promise {\n const response = responses[responses.length - 1];\n\n if (!response.next) {\n return Promise.resolve(responses);\n }\n\n return response\n .next()\n .then(response => allInner(responses.concat([response])));\n}\n\nfunction apiRequest(url: string, options: RequestOptions): APIPromise {\n return request(url, options).then(\n (response: Response): APIPromise => {\n const apiResponse = response as APIResponse;\n apiResponse.response = response;\n const resource = resourceKey(url);\n return response\n .json()\n .then(\n (data): APIResponse => {\n apiResponse.next = nextFunc(url, options, data);\n apiResponse.data = data;\n apiResponse.resource = resource ? data[resource] : null;\n return apiResponse;\n }\n )\n .catch(() => Promise.resolve(apiResponse));\n }\n );\n}\n\nfunction resourceKey(url: string) {\n const resource = url.match(/.+.com\\/(?[\\w]+)/);\n if (resource) {\n return resource[1];\n }\n return null;\n}\n\nfunction isReadonlyRequest(method: string) {\n return !['PUT', 'POST', 'DELETE', 'PATCH'].includes(\n method.toUpperCase() ?? 'GET'\n );\n}\n\ninterface OffsetPagination {\n type: 'offset';\n more?: boolean;\n offset?: number;\n limit?: number;\n}\n\ninterface CursorPagination {\n type: 'cursor';\n cursor?: string;\n limit?: number;\n}\n\nfunction isOffsetPagination(\n data: OffsetPagination | CursorPagination\n): data is OffsetPagination {\n if ((data as OffsetPagination).offset !== undefined) {\n return true;\n }\n return false;\n}\n\nfunction isCursorPagination(\n data: OffsetPagination | CursorPagination\n): data is CursorPagination {\n if ((data as CursorPagination).cursor !== undefined) {\n return true;\n }\n return false;\n}\n\nfunction nextFunc(\n url: string,\n options: RequestOptions,\n data: OffsetPagination | CursorPagination\n) {\n if (isOffsetPagination(data)) {\n if (data?.more && typeof data.offset !== undefined && data.limit) {\n return () =>\n apiRequest(url, {\n ...options,\n queryParameters: {\n ...options.queryParameters,\n limit: data.limit!.toString(),\n offset: (data.limit! + data.offset!).toString(),\n },\n });\n }\n } else if (isCursorPagination(data)) {\n if (data?.cursor) {\n return () =>\n apiRequest(url, {\n ...options,\n queryParameters: {\n ...options.queryParameters,\n cursor: data.cursor!,\n limit: data.limit!.toString(),\n },\n });\n }\n }\n\n return undefined;\n}\n\nfunction partialCall(apiParameters: Partial) {\n const partialParameters = apiParameters;\n const partial = ((apiParameters: Partial) =>\n api({...partialParameters, ...apiParameters})) as PartialCall;\n\n const shorthand = (method: string) => (\n endpoint: string,\n shorthandParameters?: Partial\n ): APIPromise =>\n api({\n endpoint,\n method,\n ...partialParameters,\n ...shorthandParameters,\n }) as APIPromise;\n\n partial.get = shorthand('get');\n partial.post = shorthand('post');\n partial.put = shorthand('put');\n partial.patch = shorthand('patch');\n partial.delete = shorthand('delete');\n\n partial.all = (apiParameters: APIParameters) => all(apiParameters);\n\n return partial;\n}\n","import {request, RequestOptions} from './common';\n\nexport type Action = 'trigger' | 'acknowledge' | 'resolve';\n\nexport type EventPromise = Promise;\n\nexport interface EventResponse extends Response {\n data: any;\n response: Response;\n}\n\nexport type Severity = 'critical' | 'error' | 'warning' | 'info';\n\nexport interface Image {\n src: string;\n href?: string;\n alt?: string;\n}\n\nexport interface Link {\n href: string;\n text?: string;\n}\n\nexport interface EventPayloadV2 {\n routing_key: string;\n event_action: Action;\n dedup_key?: string;\n payload: {\n summary: string;\n source: string;\n severity: Severity;\n timestamp?: string;\n component?: string;\n group?: string;\n class?: string;\n custom_details?: object;\n };\n images?: Array;\n links?: Array;\n}\n\nexport interface EventParameters extends RequestOptions {\n data: EventPayloadV2;\n type?: string;\n server?: string;\n}\n\nexport interface ChangePayload {\n routing_key: string;\n payload: {\n summary: string;\n source?: string;\n timestamp: string;\n custom_details: object;\n };\n links: Array;\n}\nexport interface ChangeParameters extends RequestOptions {\n data: ChangePayload;\n server?: string;\n}\n\nexport function event(eventParameters: EventParameters): EventPromise {\n const {\n server = 'events.pagerduty.com',\n type = 'event',\n data,\n ...config\n } = eventParameters;\n\n let url = `https://${server}/v2/enqueue`;\n if (type === 'change') {\n url = `https://${server}/v2/change/enqueue`;\n }\n\n return eventFetch(url, {\n method: 'POST',\n body: JSON.stringify(data),\n ...config,\n });\n}\n\nconst shorthand = (action: Action) => (\n eventParameters: EventParameters\n): EventPromise => {\n const typeField = 'event_action';\n\n return event({\n ...eventParameters,\n data: {\n ...eventParameters.data,\n [typeField]: action,\n },\n });\n};\n\nexport const trigger = shorthand('trigger');\nexport const acknowledge = shorthand('acknowledge');\nexport const resolve = shorthand('resolve');\nexport const change = (eventParameters: EventParameters) =>\n event({...eventParameters, type: 'change'});\n\nfunction eventFetch(url: string, options: RequestOptions): EventPromise {\n return request(url, options).then(\n (response: Response): EventPromise => {\n const apiResponse = response as EventResponse;\n return response.json().then(\n (data): EventResponse => {\n apiResponse.data = data;\n apiResponse.response = response;\n return apiResponse;\n }\n );\n }\n );\n}\n","'use strict';\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\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\n/* global window self */\n\nvar isBrowser = typeof window !== 'undefined' && typeof window.document !== 'undefined';\n\n/* eslint-disable no-restricted-globals */\nvar isWebWorker = (typeof self === 'undefined' ? 'undefined' : _typeof(self)) === 'object' && self.constructor && self.constructor.name === 'DedicatedWorkerGlobalScope';\n/* eslint-enable no-restricted-globals */\n\nvar isNode = typeof process !== 'undefined' && process.versions != null && process.versions.node != null;\n\n/**\n * @see https://github.com/jsdom/jsdom/releases/tag/12.0.0\n * @see https://github.com/jsdom/jsdom/issues/1537\n */\n/* eslint-disable no-undef */\nvar isJsDom = function isJsDom() {\n return typeof window !== 'undefined' && window.name === 'nodejs' || navigator.userAgent.includes('Node.js') || navigator.userAgent.includes('jsdom');\n};\n\nexports.isBrowser = isBrowser;\nexports.isWebWorker = isWebWorker;\nexports.isNode = isNode;\nexports.isJsDom = isJsDom;","var __self__ = (function (root) {\nfunction F() {\nthis.fetch = false;\nthis.DOMException = root.DOMException\n}\nF.prototype = root;\nreturn new F();\n})(typeof self !== 'undefined' ? self : this);\n(function(self) {\n\nvar irrelevant = (function (exports) {\n\n var support = {\n searchParams: 'URLSearchParams' in self,\n iterable: 'Symbol' in self && 'iterator' in Symbol,\n blob:\n 'FileReader' in self &&\n 'Blob' in self &&\n (function() {\n try {\n new Blob();\n return true\n } catch (e) {\n return false\n }\n })(),\n formData: 'FormData' in self,\n arrayBuffer: 'ArrayBuffer' in self\n };\n\n function isDataView(obj) {\n return obj && DataView.prototype.isPrototypeOf(obj)\n }\n\n if (support.arrayBuffer) {\n var viewClasses = [\n '[object Int8Array]',\n '[object Uint8Array]',\n '[object Uint8ClampedArray]',\n '[object Int16Array]',\n '[object Uint16Array]',\n '[object Int32Array]',\n '[object Uint32Array]',\n '[object Float32Array]',\n '[object Float64Array]'\n ];\n\n var isArrayBufferView =\n ArrayBuffer.isView ||\n function(obj) {\n return obj && viewClasses.indexOf(Object.prototype.toString.call(obj)) > -1\n };\n }\n\n function normalizeName(name) {\n if (typeof name !== 'string') {\n name = String(name);\n }\n if (/[^a-z0-9\\-#$%&'*+.^_`|~]/i.test(name)) {\n throw new TypeError('Invalid character in header field name')\n }\n return name.toLowerCase()\n }\n\n function normalizeValue(value) {\n if (typeof value !== 'string') {\n value = String(value);\n }\n return value\n }\n\n // Build a destructive iterator for the value list\n function iteratorFor(items) {\n var iterator = {\n next: function() {\n var value = items.shift();\n return {done: value === undefined, value: value}\n }\n };\n\n if (support.iterable) {\n iterator[Symbol.iterator] = function() {\n return iterator\n };\n }\n\n return iterator\n }\n\n function Headers(headers) {\n this.map = {};\n\n if (headers instanceof Headers) {\n headers.forEach(function(value, name) {\n this.append(name, value);\n }, this);\n } else if (Array.isArray(headers)) {\n headers.forEach(function(header) {\n this.append(header[0], header[1]);\n }, this);\n } else if (headers) {\n Object.getOwnPropertyNames(headers).forEach(function(name) {\n this.append(name, headers[name]);\n }, this);\n }\n }\n\n Headers.prototype.append = function(name, value) {\n name = normalizeName(name);\n value = normalizeValue(value);\n var oldValue = this.map[name];\n this.map[name] = oldValue ? oldValue + ', ' + value : value;\n };\n\n Headers.prototype['delete'] = function(name) {\n delete this.map[normalizeName(name)];\n };\n\n Headers.prototype.get = function(name) {\n name = normalizeName(name);\n return this.has(name) ? this.map[name] : null\n };\n\n Headers.prototype.has = function(name) {\n return this.map.hasOwnProperty(normalizeName(name))\n };\n\n Headers.prototype.set = function(name, value) {\n this.map[normalizeName(name)] = normalizeValue(value);\n };\n\n Headers.prototype.forEach = function(callback, thisArg) {\n for (var name in this.map) {\n if (this.map.hasOwnProperty(name)) {\n callback.call(thisArg, this.map[name], name, this);\n }\n }\n };\n\n Headers.prototype.keys = function() {\n var items = [];\n this.forEach(function(value, name) {\n items.push(name);\n });\n return iteratorFor(items)\n };\n\n Headers.prototype.values = function() {\n var items = [];\n this.forEach(function(value) {\n items.push(value);\n });\n return iteratorFor(items)\n };\n\n Headers.prototype.entries = function() {\n var items = [];\n this.forEach(function(value, name) {\n items.push([name, value]);\n });\n return iteratorFor(items)\n };\n\n if (support.iterable) {\n Headers.prototype[Symbol.iterator] = Headers.prototype.entries;\n }\n\n function consumed(body) {\n if (body.bodyUsed) {\n return Promise.reject(new TypeError('Already read'))\n }\n body.bodyUsed = true;\n }\n\n function fileReaderReady(reader) {\n return new Promise(function(resolve, reject) {\n reader.onload = function() {\n resolve(reader.result);\n };\n reader.onerror = function() {\n reject(reader.error);\n };\n })\n }\n\n function readBlobAsArrayBuffer(blob) {\n var reader = new FileReader();\n var promise = fileReaderReady(reader);\n reader.readAsArrayBuffer(blob);\n return promise\n }\n\n function readBlobAsText(blob) {\n var reader = new FileReader();\n var promise = fileReaderReady(reader);\n reader.readAsText(blob);\n return promise\n }\n\n function readArrayBufferAsText(buf) {\n var view = new Uint8Array(buf);\n var chars = new Array(view.length);\n\n for (var i = 0; i < view.length; i++) {\n chars[i] = String.fromCharCode(view[i]);\n }\n return chars.join('')\n }\n\n function bufferClone(buf) {\n if (buf.slice) {\n return buf.slice(0)\n } else {\n var view = new Uint8Array(buf.byteLength);\n view.set(new Uint8Array(buf));\n return view.buffer\n }\n }\n\n function Body() {\n this.bodyUsed = false;\n\n this._initBody = function(body) {\n this._bodyInit = body;\n if (!body) {\n this._bodyText = '';\n } else if (typeof body === 'string') {\n this._bodyText = body;\n } else if (support.blob && Blob.prototype.isPrototypeOf(body)) {\n this._bodyBlob = body;\n } else if (support.formData && FormData.prototype.isPrototypeOf(body)) {\n this._bodyFormData = body;\n } else if (support.searchParams && URLSearchParams.prototype.isPrototypeOf(body)) {\n this._bodyText = body.toString();\n } else if (support.arrayBuffer && support.blob && isDataView(body)) {\n this._bodyArrayBuffer = bufferClone(body.buffer);\n // IE 10-11 can't handle a DataView body.\n this._bodyInit = new Blob([this._bodyArrayBuffer]);\n } else if (support.arrayBuffer && (ArrayBuffer.prototype.isPrototypeOf(body) || isArrayBufferView(body))) {\n this._bodyArrayBuffer = bufferClone(body);\n } else {\n this._bodyText = body = Object.prototype.toString.call(body);\n }\n\n if (!this.headers.get('content-type')) {\n if (typeof body === 'string') {\n this.headers.set('content-type', 'text/plain;charset=UTF-8');\n } else if (this._bodyBlob && this._bodyBlob.type) {\n this.headers.set('content-type', this._bodyBlob.type);\n } else if (support.searchParams && URLSearchParams.prototype.isPrototypeOf(body)) {\n this.headers.set('content-type', 'application/x-www-form-urlencoded;charset=UTF-8');\n }\n }\n };\n\n if (support.blob) {\n this.blob = function() {\n var rejected = consumed(this);\n if (rejected) {\n return rejected\n }\n\n if (this._bodyBlob) {\n return Promise.resolve(this._bodyBlob)\n } else if (this._bodyArrayBuffer) {\n return Promise.resolve(new Blob([this._bodyArrayBuffer]))\n } else if (this._bodyFormData) {\n throw new Error('could not read FormData body as blob')\n } else {\n return Promise.resolve(new Blob([this._bodyText]))\n }\n };\n\n this.arrayBuffer = function() {\n if (this._bodyArrayBuffer) {\n return consumed(this) || Promise.resolve(this._bodyArrayBuffer)\n } else {\n return this.blob().then(readBlobAsArrayBuffer)\n }\n };\n }\n\n this.text = function() {\n var rejected = consumed(this);\n if (rejected) {\n return rejected\n }\n\n if (this._bodyBlob) {\n return readBlobAsText(this._bodyBlob)\n } else if (this._bodyArrayBuffer) {\n return Promise.resolve(readArrayBufferAsText(this._bodyArrayBuffer))\n } else if (this._bodyFormData) {\n throw new Error('could not read FormData body as text')\n } else {\n return Promise.resolve(this._bodyText)\n }\n };\n\n if (support.formData) {\n this.formData = function() {\n return this.text().then(decode)\n };\n }\n\n this.json = function() {\n return this.text().then(JSON.parse)\n };\n\n return this\n }\n\n // HTTP methods whose capitalization should be normalized\n var methods = ['DELETE', 'GET', 'HEAD', 'OPTIONS', 'POST', 'PUT'];\n\n function normalizeMethod(method) {\n var upcased = method.toUpperCase();\n return methods.indexOf(upcased) > -1 ? upcased : method\n }\n\n function Request(input, options) {\n options = options || {};\n var body = options.body;\n\n if (input instanceof Request) {\n if (input.bodyUsed) {\n throw new TypeError('Already read')\n }\n this.url = input.url;\n this.credentials = input.credentials;\n if (!options.headers) {\n this.headers = new Headers(input.headers);\n }\n this.method = input.method;\n this.mode = input.mode;\n this.signal = input.signal;\n if (!body && input._bodyInit != null) {\n body = input._bodyInit;\n input.bodyUsed = true;\n }\n } else {\n this.url = String(input);\n }\n\n this.credentials = options.credentials || this.credentials || 'same-origin';\n if (options.headers || !this.headers) {\n this.headers = new Headers(options.headers);\n }\n this.method = normalizeMethod(options.method || this.method || 'GET');\n this.mode = options.mode || this.mode || null;\n this.signal = options.signal || this.signal;\n this.referrer = null;\n\n if ((this.method === 'GET' || this.method === 'HEAD') && body) {\n throw new TypeError('Body not allowed for GET or HEAD requests')\n }\n this._initBody(body);\n }\n\n Request.prototype.clone = function() {\n return new Request(this, {body: this._bodyInit})\n };\n\n function decode(body) {\n var form = new FormData();\n body\n .trim()\n .split('&')\n .forEach(function(bytes) {\n if (bytes) {\n var split = bytes.split('=');\n var name = split.shift().replace(/\\+/g, ' ');\n var value = split.join('=').replace(/\\+/g, ' ');\n form.append(decodeURIComponent(name), decodeURIComponent(value));\n }\n });\n return form\n }\n\n function parseHeaders(rawHeaders) {\n var headers = new Headers();\n // Replace instances of \\r\\n and \\n followed by at least one space or horizontal tab with a space\n // https://tools.ietf.org/html/rfc7230#section-3.2\n var preProcessedHeaders = rawHeaders.replace(/\\r?\\n[\\t ]+/g, ' ');\n preProcessedHeaders.split(/\\r?\\n/).forEach(function(line) {\n var parts = line.split(':');\n var key = parts.shift().trim();\n if (key) {\n var value = parts.join(':').trim();\n headers.append(key, value);\n }\n });\n return headers\n }\n\n Body.call(Request.prototype);\n\n function Response(bodyInit, options) {\n if (!options) {\n options = {};\n }\n\n this.type = 'default';\n this.status = options.status === undefined ? 200 : options.status;\n this.ok = this.status >= 200 && this.status < 300;\n this.statusText = 'statusText' in options ? options.statusText : 'OK';\n this.headers = new Headers(options.headers);\n this.url = options.url || '';\n this._initBody(bodyInit);\n }\n\n Body.call(Response.prototype);\n\n Response.prototype.clone = function() {\n return new Response(this._bodyInit, {\n status: this.status,\n statusText: this.statusText,\n headers: new Headers(this.headers),\n url: this.url\n })\n };\n\n Response.error = function() {\n var response = new Response(null, {status: 0, statusText: ''});\n response.type = 'error';\n return response\n };\n\n var redirectStatuses = [301, 302, 303, 307, 308];\n\n Response.redirect = function(url, status) {\n if (redirectStatuses.indexOf(status) === -1) {\n throw new RangeError('Invalid status code')\n }\n\n return new Response(null, {status: status, headers: {location: url}})\n };\n\n exports.DOMException = self.DOMException;\n try {\n new exports.DOMException();\n } catch (err) {\n exports.DOMException = function(message, name) {\n this.message = message;\n this.name = name;\n var error = Error(message);\n this.stack = error.stack;\n };\n exports.DOMException.prototype = Object.create(Error.prototype);\n exports.DOMException.prototype.constructor = exports.DOMException;\n }\n\n function fetch(input, init) {\n return new Promise(function(resolve, reject) {\n var request = new Request(input, init);\n\n if (request.signal && request.signal.aborted) {\n return reject(new exports.DOMException('Aborted', 'AbortError'))\n }\n\n var xhr = new XMLHttpRequest();\n\n function abortXhr() {\n xhr.abort();\n }\n\n xhr.onload = function() {\n var options = {\n status: xhr.status,\n statusText: xhr.statusText,\n headers: parseHeaders(xhr.getAllResponseHeaders() || '')\n };\n options.url = 'responseURL' in xhr ? xhr.responseURL : options.headers.get('X-Request-URL');\n var body = 'response' in xhr ? xhr.response : xhr.responseText;\n resolve(new Response(body, options));\n };\n\n xhr.onerror = function() {\n reject(new TypeError('Network request failed'));\n };\n\n xhr.ontimeout = function() {\n reject(new TypeError('Network request failed'));\n };\n\n xhr.onabort = function() {\n reject(new exports.DOMException('Aborted', 'AbortError'));\n };\n\n xhr.open(request.method, request.url, true);\n\n if (request.credentials === 'include') {\n xhr.withCredentials = true;\n } else if (request.credentials === 'omit') {\n xhr.withCredentials = false;\n }\n\n if ('responseType' in xhr && support.blob) {\n xhr.responseType = 'blob';\n }\n\n request.headers.forEach(function(value, name) {\n xhr.setRequestHeader(name, value);\n });\n\n if (request.signal) {\n request.signal.addEventListener('abort', abortXhr);\n\n xhr.onreadystatechange = function() {\n // DONE (success or failure)\n if (xhr.readyState === 4) {\n request.signal.removeEventListener('abort', abortXhr);\n }\n };\n }\n\n xhr.send(typeof request._bodyInit === 'undefined' ? null : request._bodyInit);\n })\n }\n\n fetch.polyfill = true;\n\n if (!self.fetch) {\n self.fetch = fetch;\n self.Headers = Headers;\n self.Request = Request;\n self.Response = Response;\n }\n\n exports.Headers = Headers;\n exports.Request = Request;\n exports.Response = Response;\n exports.fetch = fetch;\n\n return exports;\n\n}({}));\n})(__self__);\ndelete __self__.fetch.polyfill\nexports = __self__.fetch // To enable: import fetch from 'cross-fetch'\nexports.default = __self__.fetch // For TypeScript consumers without esModuleInterop.\nexports.fetch = __self__.fetch // To enable: import {fetch} from 'cross-fetch'\nexports.Headers = __self__.Headers\nexports.Request = __self__.Request\nexports.Response = __self__.Response\nmodule.exports = exports\n","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tif(__webpack_module_cache__[moduleId]) {\n\t\treturn __webpack_module_cache__[moduleId].exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// module exports must be returned from runtime so entry inlining is disabled\n// startup\n// Load entry module and return exports\nreturn __webpack_require__(47);\n","// getDefaultExport function for compatibility with non-harmony modules\n__webpack_require__.n = (module) => {\n\tvar getter = module && module.__esModule ?\n\t\t() => module['default'] :\n\t\t() => module;\n\t__webpack_require__.d(getter, { a: getter });\n\treturn getter;\n};","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop)","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};"],"sourceRoot":""} \ No newline at end of file +{"version":3,"sources":["webpack://PagerDuty/./node_modules/abortcontroller-polyfill/dist/cjs-ponyfill.js","webpack://PagerDuty/./src/common.ts","webpack://PagerDuty/./src/api.ts","webpack://PagerDuty/./src/events.ts","webpack://PagerDuty/./node_modules/browser-or-node/lib/index.js","webpack://PagerDuty/./node_modules/cross-fetch/dist/browser-ponyfill.js","webpack://PagerDuty/webpack/bootstrap","webpack://PagerDuty/webpack/startup","webpack://PagerDuty/webpack/runtime/compat get default export","webpack://PagerDuty/webpack/runtime/define property getters","webpack://PagerDuty/webpack/runtime/hasOwnProperty shorthand","webpack://PagerDuty/webpack/runtime/make namespace object"],"names":["_classCallCheck","instance","Constructor","TypeError","_defineProperties","target","props","i","length","descriptor","enumerable","configurable","writable","Object","defineProperty","key","_createClass","protoProps","staticProps","prototype","_getPrototypeOf","o","setPrototypeOf","getPrototypeOf","__proto__","_setPrototypeOf","p","_assertThisInitialized","self","ReferenceError","_possibleConstructorReturn","call","_get","property","receiver","Reflect","get","base","object","hasOwnProperty","_superPropBase","desc","getOwnPropertyDescriptor","value","Emitter","this","type","callback","listeners","push","stack","l","splice","event","_this","debounce","setTimeout","defaultPrevented","AbortSignal","_Emitter","subClass","superClass","create","constructor","_inherits","Derived","hasNativeReflectConstruct","_super","construct","sham","Proxy","Date","toString","e","_isNativeReflectConstruct","result","Super","NewTarget","arguments","apply","_this2","aborted","onabort","AbortController","Event","document","createEvent","initEvent","createEventObject","bubbles","cancelable","signal","dispatchEvent","Symbol","toStringTag","exports","request","url","options","queryParameters","requestTimeout","rest","applyParameters","URL","applyTimeout","fetch_retry","headers","Headers","userAgentHeader","retries","Promise","resolve","reject","fetch","then","response","status","retryTimeout","retryTimeoutPromise","milliseconds","isBrowser","process","version","platform","combinedParameters","searchParams","parameter","Array","isArray","forEach","item","append","keys","search","init","timeout","controller","abort","api","apiParameters","endpoint","partialParameters","partial","shorthand","method","shorthandParameters","post","put","patch","all","partialCall","server","token","data","config","Accept","Authorization","includes","toUpperCase","body","JSON","stringify","apiRequest","replace","allInner","responses","next","concat","apiResponse","resource","match","resourceKey","json","undefined","offset","isOffsetPagination","more","limit","cursor","isCursorPagination","nextFunc","eventParameters","eventFetch","action","trigger","acknowledge","change","_typeof","iterator","obj","window","name","versions","node","__self__","root","F","DOMException","support","Blob","viewClasses","isArrayBufferView","ArrayBuffer","isView","indexOf","normalizeName","String","test","toLowerCase","normalizeValue","iteratorFor","items","shift","done","map","header","getOwnPropertyNames","consumed","bodyUsed","fileReaderReady","reader","onload","onerror","error","readBlobAsArrayBuffer","blob","FileReader","promise","readAsArrayBuffer","bufferClone","buf","slice","view","Uint8Array","byteLength","set","buffer","Body","_initBody","_bodyInit","_bodyText","isPrototypeOf","_bodyBlob","FormData","_bodyFormData","URLSearchParams","DataView","_bodyArrayBuffer","rejected","Error","arrayBuffer","text","readAsText","chars","fromCharCode","join","readArrayBufferAsText","formData","decode","parse","oldValue","has","thisArg","values","entries","methods","Request","input","upcased","credentials","mode","referrer","form","trim","split","bytes","decodeURIComponent","Response","bodyInit","ok","statusText","clone","redirectStatuses","redirect","RangeError","location","err","message","xhr","XMLHttpRequest","abortXhr","rawHeaders","getAllResponseHeaders","line","parts","responseURL","responseText","ontimeout","open","withCredentials","responseType","setRequestHeader","addEventListener","onreadystatechange","readyState","removeEventListener","send","polyfill","default","module","__webpack_module_cache__","__webpack_require__","moduleId","__webpack_modules__","n","getter","__esModule","d","a","definition","prop","r"],"mappings":"8DAIA,SAASA,EAAgBC,EAAUC,GACjC,KAAMD,aAAoBC,GACxB,MAAM,IAAIC,UAAU,qCAIxB,SAASC,EAAkBC,EAAQC,GACjC,IAAK,IAAIC,EAAI,EAAGA,EAAID,EAAME,OAAQD,IAAK,CACrC,IAAIE,EAAaH,EAAMC,GACvBE,EAAWC,WAAaD,EAAWC,aAAc,EACjDD,EAAWE,cAAe,EACtB,UAAWF,IAAYA,EAAWG,UAAW,GACjDC,OAAOC,eAAeT,EAAQI,EAAWM,IAAKN,IAIlD,SAASO,EAAad,EAAae,EAAYC,GAG7C,OAFID,GAAYb,EAAkBF,EAAYiB,UAAWF,GACrDC,GAAad,EAAkBF,EAAagB,GACzChB,EAkBT,SAASkB,EAAgBC,GAIvB,OAHAD,EAAkBP,OAAOS,eAAiBT,OAAOU,eAAiB,SAAyBF,GACzF,OAAOA,EAAEG,WAAaX,OAAOU,eAAeF,KAEvBA,GAGzB,SAASI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F,EAAK,CAAEL,YAAY,EAAM0B,IAAK2R,EAAWhT,MCJ3EwS,EAAoBlS,EAAI,CAACwK,EAAKmI,IAASnT,OAAOM,UAAUoB,eAAeR,KAAK8J,EAAKmI,GCCjFT,EAAoBU,EAAKlO,IACH,oBAAXF,QAA0BA,OAAOC,aAC1CjF,OAAOC,eAAeiF,EAASF,OAAOC,YAAa,CAAEnD,MAAO,WAE7D9B,OAAOC,eAAeiF,EAAS,aAAc,CAAEpD,OAAO,KJFhD4Q,EAAoB,K","file":"pdjs-legacy.js","sourcesContent":["'use strict';\n\nObject.defineProperty(exports, '__esModule', { value: true });\n\nfunction _classCallCheck(instance, Constructor) {\n if (!(instance instanceof Constructor)) {\n throw new TypeError(\"Cannot call a class as a function\");\n }\n}\n\nfunction _defineProperties(target, props) {\n for (var i = 0; i < props.length; i++) {\n var descriptor = props[i];\n descriptor.enumerable = descriptor.enumerable || false;\n descriptor.configurable = true;\n if (\"value\" in descriptor) descriptor.writable = true;\n Object.defineProperty(target, descriptor.key, descriptor);\n }\n}\n\nfunction _createClass(Constructor, protoProps, staticProps) {\n if (protoProps) _defineProperties(Constructor.prototype, protoProps);\n if (staticProps) _defineProperties(Constructor, staticProps);\n return Constructor;\n}\n\nfunction _inherits(subClass, superClass) {\n if (typeof superClass !== \"function\" && superClass !== null) {\n throw new TypeError(\"Super expression must either be null or a function\");\n }\n\n subClass.prototype = Object.create(superClass && superClass.prototype, {\n constructor: {\n value: subClass,\n writable: true,\n configurable: true\n }\n });\n if (superClass) _setPrototypeOf(subClass, superClass);\n}\n\nfunction _getPrototypeOf(o) {\n _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {\n return o.__proto__ || Object.getPrototypeOf(o);\n };\n return _getPrototypeOf(o);\n}\n\nfunction _setPrototypeOf(o, p) {\n _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {\n o.__proto__ = p;\n return o;\n };\n\n return _setPrototypeOf(o, p);\n}\n\nfunction _isNativeReflectConstruct() {\n if (typeof Reflect === \"undefined\" || !Reflect.construct) return false;\n if (Reflect.construct.sham) return false;\n if (typeof Proxy === \"function\") return true;\n\n try {\n Date.prototype.toString.call(Reflect.construct(Date, [], function () {}));\n return true;\n } catch (e) {\n return false;\n }\n}\n\nfunction _assertThisInitialized(self) {\n if (self === void 0) {\n throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\");\n }\n\n return self;\n}\n\nfunction _possibleConstructorReturn(self, call) {\n if (call && (typeof call === \"object\" || typeof call === \"function\")) {\n return call;\n }\n\n return _assertThisInitialized(self);\n}\n\nfunction _createSuper(Derived) {\n var hasNativeReflectConstruct = _isNativeReflectConstruct();\n\n return function _createSuperInternal() {\n var Super = _getPrototypeOf(Derived),\n result;\n\n if (hasNativeReflectConstruct) {\n var NewTarget = _getPrototypeOf(this).constructor;\n\n result = Reflect.construct(Super, arguments, NewTarget);\n } else {\n result = Super.apply(this, arguments);\n }\n\n return _possibleConstructorReturn(this, result);\n };\n}\n\nfunction _superPropBase(object, property) {\n while (!Object.prototype.hasOwnProperty.call(object, property)) {\n object = _getPrototypeOf(object);\n if (object === null) break;\n }\n\n return object;\n}\n\nfunction _get(target, property, receiver) {\n if (typeof Reflect !== \"undefined\" && Reflect.get) {\n _get = Reflect.get;\n } else {\n _get = function _get(target, property, receiver) {\n var base = _superPropBase(target, property);\n\n if (!base) return;\n var desc = Object.getOwnPropertyDescriptor(base, property);\n\n if (desc.get) {\n return desc.get.call(receiver);\n }\n\n return desc.value;\n };\n }\n\n return _get(target, property, receiver || target);\n}\n\nvar Emitter = /*#__PURE__*/function () {\n function Emitter() {\n _classCallCheck(this, Emitter);\n\n Object.defineProperty(this, 'listeners', {\n value: {},\n writable: true,\n configurable: true\n });\n }\n\n _createClass(Emitter, [{\n key: \"addEventListener\",\n value: function addEventListener(type, callback) {\n if (!(type in this.listeners)) {\n this.listeners[type] = [];\n }\n\n this.listeners[type].push(callback);\n }\n }, {\n key: \"removeEventListener\",\n value: function removeEventListener(type, callback) {\n if (!(type in this.listeners)) {\n return;\n }\n\n var stack = this.listeners[type];\n\n for (var i = 0, l = stack.length; i < l; i++) {\n if (stack[i] === callback) {\n stack.splice(i, 1);\n return;\n }\n }\n }\n }, {\n key: \"dispatchEvent\",\n value: function dispatchEvent(event) {\n var _this = this;\n\n if (!(event.type in this.listeners)) {\n return;\n }\n\n var debounce = function debounce(callback) {\n setTimeout(function () {\n return callback.call(_this, event);\n });\n };\n\n var stack = this.listeners[event.type];\n\n for (var i = 0, l = stack.length; i < l; i++) {\n debounce(stack[i]);\n }\n\n return !event.defaultPrevented;\n }\n }]);\n\n return Emitter;\n}();\n\nvar AbortSignal = /*#__PURE__*/function (_Emitter) {\n _inherits(AbortSignal, _Emitter);\n\n var _super = _createSuper(AbortSignal);\n\n function AbortSignal() {\n var _this2;\n\n _classCallCheck(this, AbortSignal);\n\n _this2 = _super.call(this); // Some versions of babel does not transpile super() correctly for IE <= 10, if the parent\n // constructor has failed to run, then \"this.listeners\" will still be undefined and then we call\n // the parent constructor directly instead as a workaround. For general details, see babel bug:\n // https://github.com/babel/babel/issues/3041\n // This hack was added as a fix for the issue described here:\n // https://github.com/Financial-Times/polyfill-library/pull/59#issuecomment-477558042\n\n if (!_this2.listeners) {\n Emitter.call(_assertThisInitialized(_this2));\n } // Compared to assignment, Object.defineProperty makes properties non-enumerable by default and\n // we want Object.keys(new AbortController().signal) to be [] for compat with the native impl\n\n\n Object.defineProperty(_assertThisInitialized(_this2), 'aborted', {\n value: false,\n writable: true,\n configurable: true\n });\n Object.defineProperty(_assertThisInitialized(_this2), 'onabort', {\n value: null,\n writable: true,\n configurable: true\n });\n return _this2;\n }\n\n _createClass(AbortSignal, [{\n key: \"toString\",\n value: function toString() {\n return '[object AbortSignal]';\n }\n }, {\n key: \"dispatchEvent\",\n value: function dispatchEvent(event) {\n if (event.type === 'abort') {\n this.aborted = true;\n\n if (typeof this.onabort === 'function') {\n this.onabort.call(this, event);\n }\n }\n\n _get(_getPrototypeOf(AbortSignal.prototype), \"dispatchEvent\", this).call(this, event);\n }\n }]);\n\n return AbortSignal;\n}(Emitter);\nvar AbortController = /*#__PURE__*/function () {\n function AbortController() {\n _classCallCheck(this, AbortController);\n\n // Compared to assignment, Object.defineProperty makes properties non-enumerable by default and\n // we want Object.keys(new AbortController()) to be [] for compat with the native impl\n Object.defineProperty(this, 'signal', {\n value: new AbortSignal(),\n writable: true,\n configurable: true\n });\n }\n\n _createClass(AbortController, [{\n key: \"abort\",\n value: function abort() {\n var event;\n\n try {\n event = new Event('abort');\n } catch (e) {\n if (typeof document !== 'undefined') {\n if (!document.createEvent) {\n // For Internet Explorer 8:\n event = document.createEventObject();\n event.type = 'abort';\n } else {\n // For Internet Explorer 11:\n event = document.createEvent('Event');\n event.initEvent('abort', false, false);\n }\n } else {\n // Fallback where document isn't available:\n event = {\n type: 'abort',\n bubbles: false,\n cancelable: false\n };\n }\n }\n\n this.signal.dispatchEvent(event);\n }\n }, {\n key: \"toString\",\n value: function toString() {\n return '[object AbortController]';\n }\n }]);\n\n return AbortController;\n}();\n\nif (typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n // These are necessary to make sure that we get correct output for:\n // Object.prototype.toString.call(new AbortController())\n AbortController.prototype[Symbol.toStringTag] = 'AbortController';\n AbortSignal.prototype[Symbol.toStringTag] = 'AbortSignal';\n}\n\nfunction polyfillNeeded(self) {\n if (self.__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL) {\n console.log('__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL=true is set, will force install polyfill');\n return true;\n } // Note that the \"unfetch\" minimal fetch polyfill defines fetch() without\n // defining window.Request, and this polyfill need to work on top of unfetch\n // so the below feature detection needs the !self.AbortController part.\n // The Request.prototype check is also needed because Safari versions 11.1.2\n // up to and including 12.1.x has a window.AbortController present but still\n // does NOT correctly implement abortable fetch:\n // https://bugs.webkit.org/show_bug.cgi?id=174980#c2\n\n\n return typeof self.Request === 'function' && !self.Request.prototype.hasOwnProperty('signal') || !self.AbortController;\n}\n\n/**\n * Note: the \"fetch.Request\" default value is available for fetch imported from\n * the \"node-fetch\" package and not in browsers. This is OK since browsers\n * will be importing umd-polyfill.js from that path \"self\" is passed the\n * decorator so the default value will not be used (because browsers that define\n * fetch also has Request). One quirky setup where self.fetch exists but\n * self.Request does not is when the \"unfetch\" minimal fetch polyfill is used\n * on top of IE11; for this case the browser will try to use the fetch.Request\n * default value which in turn will be undefined but then then \"if (Request)\"\n * will ensure that you get a patched fetch but still no Request (as expected).\n * @param {fetch, Request = fetch.Request}\n * @returns {fetch: abortableFetch, Request: AbortableRequest}\n */\n\nfunction abortableFetchDecorator(patchTargets) {\n if ('function' === typeof patchTargets) {\n patchTargets = {\n fetch: patchTargets\n };\n }\n\n var _patchTargets = patchTargets,\n fetch = _patchTargets.fetch,\n _patchTargets$Request = _patchTargets.Request,\n NativeRequest = _patchTargets$Request === void 0 ? fetch.Request : _patchTargets$Request,\n NativeAbortController = _patchTargets.AbortController,\n _patchTargets$__FORCE = _patchTargets.__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL,\n __FORCE_INSTALL_ABORTCONTROLLER_POLYFILL = _patchTargets$__FORCE === void 0 ? false : _patchTargets$__FORCE;\n\n if (!polyfillNeeded({\n fetch: fetch,\n Request: NativeRequest,\n AbortController: NativeAbortController,\n __FORCE_INSTALL_ABORTCONTROLLER_POLYFILL: __FORCE_INSTALL_ABORTCONTROLLER_POLYFILL\n })) {\n return {\n fetch: fetch,\n Request: Request\n };\n }\n\n var Request = NativeRequest; // Note that the \"unfetch\" minimal fetch polyfill defines fetch() without\n // defining window.Request, and this polyfill need to work on top of unfetch\n // hence we only patch it if it's available. Also we don't patch it if signal\n // is already available on the Request prototype because in this case support\n // is present and the patching below can cause a crash since it assigns to\n // request.signal which is technically a read-only property. This latter error\n // happens when you run the main5.js node-fetch example in the repo\n // \"abortcontroller-polyfill-examples\". The exact error is:\n // request.signal = init.signal;\n // ^\n // TypeError: Cannot set property signal of # which has only a getter\n\n if (Request && !Request.prototype.hasOwnProperty('signal') || __FORCE_INSTALL_ABORTCONTROLLER_POLYFILL) {\n Request = function Request(input, init) {\n var signal;\n\n if (init && init.signal) {\n signal = init.signal; // Never pass init.signal to the native Request implementation when the polyfill has\n // been installed because if we're running on top of a browser with a\n // working native AbortController (i.e. the polyfill was installed due to\n // __FORCE_INSTALL_ABORTCONTROLLER_POLYFILL being set), then passing our\n // fake AbortSignal to the native fetch will trigger:\n // TypeError: Failed to construct 'Request': member signal is not of type AbortSignal.\n\n delete init.signal;\n }\n\n var request = new NativeRequest(input, init);\n\n if (signal) {\n Object.defineProperty(request, 'signal', {\n writable: false,\n enumerable: false,\n configurable: true,\n value: signal\n });\n }\n\n return request;\n };\n\n Request.prototype = NativeRequest.prototype;\n }\n\n var realFetch = fetch;\n\n var abortableFetch = function abortableFetch(input, init) {\n var signal = Request && Request.prototype.isPrototypeOf(input) ? input.signal : init ? init.signal : undefined;\n\n if (signal) {\n var abortError;\n\n try {\n abortError = new DOMException('Aborted', 'AbortError');\n } catch (err) {\n // IE 11 does not support calling the DOMException constructor, use a\n // regular error object on it instead.\n abortError = new Error('Aborted');\n abortError.name = 'AbortError';\n } // Return early if already aborted, thus avoiding making an HTTP request\n\n\n if (signal.aborted) {\n return Promise.reject(abortError);\n } // Turn an event into a promise, reject it once `abort` is dispatched\n\n\n var cancellation = new Promise(function (_, reject) {\n signal.addEventListener('abort', function () {\n return reject(abortError);\n }, {\n once: true\n });\n });\n\n if (init && init.signal) {\n // Never pass .signal to the native implementation when the polyfill has\n // been installed because if we're running on top of a browser with a\n // working native AbortController (i.e. the polyfill was installed due to\n // __FORCE_INSTALL_ABORTCONTROLLER_POLYFILL being set), then passing our\n // fake AbortSignal to the native fetch will trigger:\n // TypeError: Failed to execute 'fetch' on 'Window': member signal is not of type AbortSignal.\n delete init.signal;\n } // Return the fastest promise (don't need to wait for request to finish)\n\n\n return Promise.race([cancellation, realFetch(input, init)]);\n }\n\n return realFetch(input, init);\n };\n\n return {\n fetch: abortableFetch,\n Request: Request\n };\n}\n\nexports.AbortController = AbortController;\nexports.AbortSignal = AbortSignal;\nexports.abortableFetch = abortableFetchDecorator;\n","/* LEGACY-BROWSER-SUPPORT-START */\nimport fetch, {Headers} from 'cross-fetch';\nimport {AbortController} from 'abortcontroller-polyfill/dist/cjs-ponyfill';\nimport {isBrowser} from 'browser-or-node';\n/* LEGACY-BROWSER-SUPPORT-END */\n\nconst VERSION = '2.0.0';\n\ntype QueryParameter = Record>;\n\nexport interface RequestOptions extends RequestInit {\n queryParameters?: QueryParameter;\n retryCount?: number;\n requestTimeout?: number;\n retryTimeout?: number;\n timeout?: number;\n}\n\nexport function request(\n url: string | URL,\n options: RequestOptions = {}\n): Promise {\n const {queryParameters, requestTimeout = 30000, ...rest} = options;\n\n url = new URL(url.toString());\n\n url = applyParameters(url, queryParameters);\n options = applyTimeout(options, requestTimeout);\n\n return fetch_retry(url.toString(), 3, {\n ...rest,\n headers: new Headers({\n 'Content-Type': 'application/json; charset=utf-8',\n /* LEGACY-BROWSER-SUPPORT-START */\n ...userAgentHeader(),\n /* LEGACY-BROWSER-SUPPORT-END */\n ...rest.headers,\n }),\n });\n}\n\nfunction fetch_retry(\n url: string,\n retries: number,\n options: RequestOptions\n): Promise {\n return new Promise((resolve, reject) => {\n fetch(url, options).then(response => {\n // We don't want to `reject` when retries have finished\n // Instead simply stop trying and return.\n if (retries === 0) return resolve(response);\n if (response.status === 429) {\n const {retryTimeout = 20000} = options;\n retryTimeoutPromise(retryTimeout).then(() => {\n fetch_retry(url, retries - 1, options)\n .then(resolve)\n .catch(reject);\n });\n } else {\n resolve(response);\n }\n });\n });\n}\n\nconst retryTimeoutPromise = (milliseconds: number) => {\n return new Promise(resolve => setTimeout(resolve, milliseconds));\n};\n\nfunction userAgentHeader(): object {\n if (isBrowser) return {};\n\n return {\n 'User-Agent': `pdjs/${VERSION} (${process.version}/${process.platform})`,\n };\n}\n\nfunction applyParameters(url: URL, queryParameters?: QueryParameter): URL {\n if (!queryParameters) return url;\n\n const combinedParameters = url.searchParams;\n\n for (const key of Object.keys(queryParameters)) {\n const parameter = queryParameters[key];\n if (Array.isArray(parameter)) {\n // Support for array based keys like `additional_fields[]`\n parameter.forEach(item => {\n combinedParameters.append(key, item);\n });\n } else {\n combinedParameters.append(key, parameter);\n }\n }\n\n url.search = combinedParameters.toString();\n return url;\n}\n\nfunction applyTimeout(init: RequestOptions, timeout?: number): RequestOptions {\n if (!timeout) return init;\n\n const controller = new AbortController();\n setTimeout(() => controller.abort(), timeout);\n\n return {\n ...init,\n signal: controller.signal,\n };\n}\n","import {request, RequestOptions} from './common';\n\nexport interface ShorthandCall {\n (res: string, apiParameters?: Partial): APIPromise;\n}\n\nexport interface PartialCall {\n (apiParameters: APIParameters): APIPromise;\n (apiParameters: Partial): PartialCall;\n get: ShorthandCall;\n post: ShorthandCall;\n put: ShorthandCall;\n patch: ShorthandCall;\n delete: ShorthandCall;\n all: (apiParameters: APIParameters) => Promise;\n}\n\nexport type APIParameters = RequestOptions & {\n endpoint?: string;\n url?: string;\n data?: object;\n token?: string;\n server?: string;\n version?: number;\n} & ({endpoint: string} | {url: string});\n\nexport type APIPromise = Promise;\n\nexport interface APIResponse extends Response {\n data: any;\n resource: any;\n response: Response;\n next?: () => APIPromise;\n}\n\nexport function api(apiParameters: APIParameters): APIPromise;\nexport function api(apiParameters: Partial): PartialCall;\nexport function api(\n apiParameters: Partial\n): APIPromise | PartialCall {\n // If the apiParameters don't include `endpoint` treat it as a partial\n // application.\n if (!apiParameters.endpoint && !apiParameters.url) {\n return partialCall(apiParameters);\n }\n\n const {\n endpoint,\n server = 'api.pagerduty.com',\n token,\n url,\n version = 2,\n data,\n ...rest\n } = apiParameters;\n\n const config: RequestOptions = {\n method: 'GET',\n ...rest,\n headers: {\n Accept: `application/vnd.pagerduty+json;version=${version}`,\n Authorization: `Token token=${token!}`,\n ...rest.headers,\n },\n };\n\n // Allow `data` for `queryParameters` for requests without bodies.\n if (isReadonlyRequest(config.method!) && data) {\n config.queryParameters =\n config.queryParameters ?? (data as Record);\n } else {\n config.body = JSON.stringify(data);\n }\n\n return apiRequest(\n url ?? `https://${server}/${endpoint!.replace(/^\\/+/, '')}`,\n config\n );\n}\n\nexport function all(apiParameters: APIParameters): Promise {\n return (api(apiParameters) as APIPromise).then(response =>\n allInner([response])\n );\n}\n\nfunction allInner(responses: APIResponse[]): Promise {\n const response = responses[responses.length - 1];\n\n if (!response.next) {\n return Promise.resolve(responses);\n }\n\n return response\n .next()\n .then(response => allInner(responses.concat([response])));\n}\n\nfunction apiRequest(url: string, options: RequestOptions): APIPromise {\n return request(url, options).then(\n (response: Response): APIPromise => {\n const apiResponse = response as APIResponse;\n apiResponse.response = response;\n const resource = resourceKey(url);\n return response\n .json()\n .then(\n (data): APIResponse => {\n apiResponse.next = nextFunc(url, options, data);\n apiResponse.data = data;\n apiResponse.resource = resource ? data[resource] : null;\n return apiResponse;\n }\n )\n .catch(() => Promise.resolve(apiResponse));\n }\n );\n}\n\nfunction resourceKey(url: string) {\n const resource = url.match(/.+.com\\/(?[\\w]+)/);\n if (resource) {\n return resource[1];\n }\n return null;\n}\n\nfunction isReadonlyRequest(method: string) {\n return !['PUT', 'POST', 'DELETE', 'PATCH'].includes(\n method.toUpperCase() ?? 'GET'\n );\n}\n\ninterface OffsetPagination {\n type: 'offset';\n more?: boolean;\n offset?: number;\n limit?: number;\n}\n\ninterface CursorPagination {\n type: 'cursor';\n cursor?: string;\n limit?: number;\n}\n\nfunction isOffsetPagination(\n data: OffsetPagination | CursorPagination\n): data is OffsetPagination {\n if ((data as OffsetPagination).offset !== undefined) {\n return true;\n }\n return false;\n}\n\nfunction isCursorPagination(\n data: OffsetPagination | CursorPagination\n): data is CursorPagination {\n if ((data as CursorPagination).cursor !== undefined) {\n return true;\n }\n return false;\n}\n\nfunction nextFunc(\n url: string,\n options: RequestOptions,\n data: OffsetPagination | CursorPagination\n) {\n if (isOffsetPagination(data)) {\n if (data?.more && typeof data.offset !== undefined && data.limit) {\n return () =>\n apiRequest(url, {\n ...options,\n queryParameters: {\n ...options.queryParameters,\n limit: data.limit!.toString(),\n offset: (data.limit! + data.offset!).toString(),\n },\n });\n }\n } else if (isCursorPagination(data)) {\n if (data?.cursor) {\n return () =>\n apiRequest(url, {\n ...options,\n queryParameters: {\n ...options.queryParameters,\n cursor: data.cursor!,\n limit: data.limit!.toString(),\n },\n });\n }\n }\n\n return undefined;\n}\n\nfunction partialCall(apiParameters: Partial) {\n const partialParameters = apiParameters;\n const partial = ((apiParameters: Partial) =>\n api({...partialParameters, ...apiParameters})) as PartialCall;\n\n const shorthand = (method: string) => (\n endpoint: string,\n shorthandParameters?: Partial\n ): APIPromise =>\n api({\n endpoint,\n method,\n ...partialParameters,\n ...shorthandParameters,\n }) as APIPromise;\n\n partial.get = shorthand('get');\n partial.post = shorthand('post');\n partial.put = shorthand('put');\n partial.patch = shorthand('patch');\n partial.delete = shorthand('delete');\n\n partial.all = (apiParameters: APIParameters) => all(apiParameters);\n\n return partial;\n}\n","import {request, RequestOptions} from './common';\n\nexport type Action = 'trigger' | 'acknowledge' | 'resolve';\n\nexport type EventPromise = Promise;\n\nexport interface EventResponse extends Response {\n data: any;\n response: Response;\n}\n\nexport type Severity = 'critical' | 'error' | 'warning' | 'info';\n\nexport interface Image {\n src: string;\n href?: string;\n alt?: string;\n}\n\nexport interface Link {\n href: string;\n text?: string;\n}\n\nexport interface EventPayloadV2 {\n routing_key: string;\n event_action: Action;\n dedup_key?: string;\n payload: {\n summary: string;\n source: string;\n severity: Severity;\n timestamp?: string;\n component?: string;\n group?: string;\n class?: string;\n custom_details?: object;\n };\n images?: Array;\n links?: Array;\n}\n\nexport interface EventParameters extends RequestOptions {\n data: EventPayloadV2;\n type?: string;\n server?: string;\n}\n\nexport interface ChangePayload {\n routing_key: string;\n payload: {\n summary: string;\n source?: string;\n timestamp: string;\n custom_details: object;\n };\n links: Array;\n}\nexport interface ChangeParameters extends RequestOptions {\n data: ChangePayload;\n server?: string;\n}\n\nexport function event(eventParameters: EventParameters): EventPromise {\n const {\n server = 'events.pagerduty.com',\n type = 'event',\n data,\n ...config\n } = eventParameters;\n\n let url = `https://${server}/v2/enqueue`;\n if (type === 'change') {\n url = `https://${server}/v2/change/enqueue`;\n }\n\n return eventFetch(url, {\n method: 'POST',\n body: JSON.stringify(data),\n ...config,\n });\n}\n\nconst shorthand = (action: Action) => (\n eventParameters: EventParameters\n): EventPromise => {\n const typeField = 'event_action';\n\n return event({\n ...eventParameters,\n data: {\n ...eventParameters.data,\n [typeField]: action,\n },\n });\n};\n\nexport const trigger = shorthand('trigger');\nexport const acknowledge = shorthand('acknowledge');\nexport const resolve = shorthand('resolve');\nexport const change = (eventParameters: EventParameters) =>\n event({...eventParameters, type: 'change'});\n\nfunction eventFetch(url: string, options: RequestOptions): EventPromise {\n return request(url, options).then(\n (response: Response): EventPromise => {\n const apiResponse = response as EventResponse;\n return response.json().then(\n (data): EventResponse => {\n apiResponse.data = data;\n apiResponse.response = response;\n return apiResponse;\n }\n );\n }\n );\n}\n","'use strict';\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\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\n/* global window self */\n\nvar isBrowser = typeof window !== 'undefined' && typeof window.document !== 'undefined';\n\n/* eslint-disable no-restricted-globals */\nvar isWebWorker = (typeof self === 'undefined' ? 'undefined' : _typeof(self)) === 'object' && self.constructor && self.constructor.name === 'DedicatedWorkerGlobalScope';\n/* eslint-enable no-restricted-globals */\n\nvar isNode = typeof process !== 'undefined' && process.versions != null && process.versions.node != null;\n\n/**\n * @see https://github.com/jsdom/jsdom/releases/tag/12.0.0\n * @see https://github.com/jsdom/jsdom/issues/1537\n */\n/* eslint-disable no-undef */\nvar isJsDom = function isJsDom() {\n return typeof window !== 'undefined' && window.name === 'nodejs' || navigator.userAgent.includes('Node.js') || navigator.userAgent.includes('jsdom');\n};\n\nexports.isBrowser = isBrowser;\nexports.isWebWorker = isWebWorker;\nexports.isNode = isNode;\nexports.isJsDom = isJsDom;","var __self__ = (function (root) {\nfunction F() {\nthis.fetch = false;\nthis.DOMException = root.DOMException\n}\nF.prototype = root;\nreturn new F();\n})(typeof self !== 'undefined' ? self : this);\n(function(self) {\n\nvar irrelevant = (function (exports) {\n\n var support = {\n searchParams: 'URLSearchParams' in self,\n iterable: 'Symbol' in self && 'iterator' in Symbol,\n blob:\n 'FileReader' in self &&\n 'Blob' in self &&\n (function() {\n try {\n new Blob();\n return true\n } catch (e) {\n return false\n }\n })(),\n formData: 'FormData' in self,\n arrayBuffer: 'ArrayBuffer' in self\n };\n\n function isDataView(obj) {\n return obj && DataView.prototype.isPrototypeOf(obj)\n }\n\n if (support.arrayBuffer) {\n var viewClasses = [\n '[object Int8Array]',\n '[object Uint8Array]',\n '[object Uint8ClampedArray]',\n '[object Int16Array]',\n '[object Uint16Array]',\n '[object Int32Array]',\n '[object Uint32Array]',\n '[object Float32Array]',\n '[object Float64Array]'\n ];\n\n var isArrayBufferView =\n ArrayBuffer.isView ||\n function(obj) {\n return obj && viewClasses.indexOf(Object.prototype.toString.call(obj)) > -1\n };\n }\n\n function normalizeName(name) {\n if (typeof name !== 'string') {\n name = String(name);\n }\n if (/[^a-z0-9\\-#$%&'*+.^_`|~]/i.test(name)) {\n throw new TypeError('Invalid character in header field name')\n }\n return name.toLowerCase()\n }\n\n function normalizeValue(value) {\n if (typeof value !== 'string') {\n value = String(value);\n }\n return value\n }\n\n // Build a destructive iterator for the value list\n function iteratorFor(items) {\n var iterator = {\n next: function() {\n var value = items.shift();\n return {done: value === undefined, value: value}\n }\n };\n\n if (support.iterable) {\n iterator[Symbol.iterator] = function() {\n return iterator\n };\n }\n\n return iterator\n }\n\n function Headers(headers) {\n this.map = {};\n\n if (headers instanceof Headers) {\n headers.forEach(function(value, name) {\n this.append(name, value);\n }, this);\n } else if (Array.isArray(headers)) {\n headers.forEach(function(header) {\n this.append(header[0], header[1]);\n }, this);\n } else if (headers) {\n Object.getOwnPropertyNames(headers).forEach(function(name) {\n this.append(name, headers[name]);\n }, this);\n }\n }\n\n Headers.prototype.append = function(name, value) {\n name = normalizeName(name);\n value = normalizeValue(value);\n var oldValue = this.map[name];\n this.map[name] = oldValue ? oldValue + ', ' + value : value;\n };\n\n Headers.prototype['delete'] = function(name) {\n delete this.map[normalizeName(name)];\n };\n\n Headers.prototype.get = function(name) {\n name = normalizeName(name);\n return this.has(name) ? this.map[name] : null\n };\n\n Headers.prototype.has = function(name) {\n return this.map.hasOwnProperty(normalizeName(name))\n };\n\n Headers.prototype.set = function(name, value) {\n this.map[normalizeName(name)] = normalizeValue(value);\n };\n\n Headers.prototype.forEach = function(callback, thisArg) {\n for (var name in this.map) {\n if (this.map.hasOwnProperty(name)) {\n callback.call(thisArg, this.map[name], name, this);\n }\n }\n };\n\n Headers.prototype.keys = function() {\n var items = [];\n this.forEach(function(value, name) {\n items.push(name);\n });\n return iteratorFor(items)\n };\n\n Headers.prototype.values = function() {\n var items = [];\n this.forEach(function(value) {\n items.push(value);\n });\n return iteratorFor(items)\n };\n\n Headers.prototype.entries = function() {\n var items = [];\n this.forEach(function(value, name) {\n items.push([name, value]);\n });\n return iteratorFor(items)\n };\n\n if (support.iterable) {\n Headers.prototype[Symbol.iterator] = Headers.prototype.entries;\n }\n\n function consumed(body) {\n if (body.bodyUsed) {\n return Promise.reject(new TypeError('Already read'))\n }\n body.bodyUsed = true;\n }\n\n function fileReaderReady(reader) {\n return new Promise(function(resolve, reject) {\n reader.onload = function() {\n resolve(reader.result);\n };\n reader.onerror = function() {\n reject(reader.error);\n };\n })\n }\n\n function readBlobAsArrayBuffer(blob) {\n var reader = new FileReader();\n var promise = fileReaderReady(reader);\n reader.readAsArrayBuffer(blob);\n return promise\n }\n\n function readBlobAsText(blob) {\n var reader = new FileReader();\n var promise = fileReaderReady(reader);\n reader.readAsText(blob);\n return promise\n }\n\n function readArrayBufferAsText(buf) {\n var view = new Uint8Array(buf);\n var chars = new Array(view.length);\n\n for (var i = 0; i < view.length; i++) {\n chars[i] = String.fromCharCode(view[i]);\n }\n return chars.join('')\n }\n\n function bufferClone(buf) {\n if (buf.slice) {\n return buf.slice(0)\n } else {\n var view = new Uint8Array(buf.byteLength);\n view.set(new Uint8Array(buf));\n return view.buffer\n }\n }\n\n function Body() {\n this.bodyUsed = false;\n\n this._initBody = function(body) {\n this._bodyInit = body;\n if (!body) {\n this._bodyText = '';\n } else if (typeof body === 'string') {\n this._bodyText = body;\n } else if (support.blob && Blob.prototype.isPrototypeOf(body)) {\n this._bodyBlob = body;\n } else if (support.formData && FormData.prototype.isPrototypeOf(body)) {\n this._bodyFormData = body;\n } else if (support.searchParams && URLSearchParams.prototype.isPrototypeOf(body)) {\n this._bodyText = body.toString();\n } else if (support.arrayBuffer && support.blob && isDataView(body)) {\n this._bodyArrayBuffer = bufferClone(body.buffer);\n // IE 10-11 can't handle a DataView body.\n this._bodyInit = new Blob([this._bodyArrayBuffer]);\n } else if (support.arrayBuffer && (ArrayBuffer.prototype.isPrototypeOf(body) || isArrayBufferView(body))) {\n this._bodyArrayBuffer = bufferClone(body);\n } else {\n this._bodyText = body = Object.prototype.toString.call(body);\n }\n\n if (!this.headers.get('content-type')) {\n if (typeof body === 'string') {\n this.headers.set('content-type', 'text/plain;charset=UTF-8');\n } else if (this._bodyBlob && this._bodyBlob.type) {\n this.headers.set('content-type', this._bodyBlob.type);\n } else if (support.searchParams && URLSearchParams.prototype.isPrototypeOf(body)) {\n this.headers.set('content-type', 'application/x-www-form-urlencoded;charset=UTF-8');\n }\n }\n };\n\n if (support.blob) {\n this.blob = function() {\n var rejected = consumed(this);\n if (rejected) {\n return rejected\n }\n\n if (this._bodyBlob) {\n return Promise.resolve(this._bodyBlob)\n } else if (this._bodyArrayBuffer) {\n return Promise.resolve(new Blob([this._bodyArrayBuffer]))\n } else if (this._bodyFormData) {\n throw new Error('could not read FormData body as blob')\n } else {\n return Promise.resolve(new Blob([this._bodyText]))\n }\n };\n\n this.arrayBuffer = function() {\n if (this._bodyArrayBuffer) {\n return consumed(this) || Promise.resolve(this._bodyArrayBuffer)\n } else {\n return this.blob().then(readBlobAsArrayBuffer)\n }\n };\n }\n\n this.text = function() {\n var rejected = consumed(this);\n if (rejected) {\n return rejected\n }\n\n if (this._bodyBlob) {\n return readBlobAsText(this._bodyBlob)\n } else if (this._bodyArrayBuffer) {\n return Promise.resolve(readArrayBufferAsText(this._bodyArrayBuffer))\n } else if (this._bodyFormData) {\n throw new Error('could not read FormData body as text')\n } else {\n return Promise.resolve(this._bodyText)\n }\n };\n\n if (support.formData) {\n this.formData = function() {\n return this.text().then(decode)\n };\n }\n\n this.json = function() {\n return this.text().then(JSON.parse)\n };\n\n return this\n }\n\n // HTTP methods whose capitalization should be normalized\n var methods = ['DELETE', 'GET', 'HEAD', 'OPTIONS', 'POST', 'PUT'];\n\n function normalizeMethod(method) {\n var upcased = method.toUpperCase();\n return methods.indexOf(upcased) > -1 ? upcased : method\n }\n\n function Request(input, options) {\n options = options || {};\n var body = options.body;\n\n if (input instanceof Request) {\n if (input.bodyUsed) {\n throw new TypeError('Already read')\n }\n this.url = input.url;\n this.credentials = input.credentials;\n if (!options.headers) {\n this.headers = new Headers(input.headers);\n }\n this.method = input.method;\n this.mode = input.mode;\n this.signal = input.signal;\n if (!body && input._bodyInit != null) {\n body = input._bodyInit;\n input.bodyUsed = true;\n }\n } else {\n this.url = String(input);\n }\n\n this.credentials = options.credentials || this.credentials || 'same-origin';\n if (options.headers || !this.headers) {\n this.headers = new Headers(options.headers);\n }\n this.method = normalizeMethod(options.method || this.method || 'GET');\n this.mode = options.mode || this.mode || null;\n this.signal = options.signal || this.signal;\n this.referrer = null;\n\n if ((this.method === 'GET' || this.method === 'HEAD') && body) {\n throw new TypeError('Body not allowed for GET or HEAD requests')\n }\n this._initBody(body);\n }\n\n Request.prototype.clone = function() {\n return new Request(this, {body: this._bodyInit})\n };\n\n function decode(body) {\n var form = new FormData();\n body\n .trim()\n .split('&')\n .forEach(function(bytes) {\n if (bytes) {\n var split = bytes.split('=');\n var name = split.shift().replace(/\\+/g, ' ');\n var value = split.join('=').replace(/\\+/g, ' ');\n form.append(decodeURIComponent(name), decodeURIComponent(value));\n }\n });\n return form\n }\n\n function parseHeaders(rawHeaders) {\n var headers = new Headers();\n // Replace instances of \\r\\n and \\n followed by at least one space or horizontal tab with a space\n // https://tools.ietf.org/html/rfc7230#section-3.2\n var preProcessedHeaders = rawHeaders.replace(/\\r?\\n[\\t ]+/g, ' ');\n preProcessedHeaders.split(/\\r?\\n/).forEach(function(line) {\n var parts = line.split(':');\n var key = parts.shift().trim();\n if (key) {\n var value = parts.join(':').trim();\n headers.append(key, value);\n }\n });\n return headers\n }\n\n Body.call(Request.prototype);\n\n function Response(bodyInit, options) {\n if (!options) {\n options = {};\n }\n\n this.type = 'default';\n this.status = options.status === undefined ? 200 : options.status;\n this.ok = this.status >= 200 && this.status < 300;\n this.statusText = 'statusText' in options ? options.statusText : 'OK';\n this.headers = new Headers(options.headers);\n this.url = options.url || '';\n this._initBody(bodyInit);\n }\n\n Body.call(Response.prototype);\n\n Response.prototype.clone = function() {\n return new Response(this._bodyInit, {\n status: this.status,\n statusText: this.statusText,\n headers: new Headers(this.headers),\n url: this.url\n })\n };\n\n Response.error = function() {\n var response = new Response(null, {status: 0, statusText: ''});\n response.type = 'error';\n return response\n };\n\n var redirectStatuses = [301, 302, 303, 307, 308];\n\n Response.redirect = function(url, status) {\n if (redirectStatuses.indexOf(status) === -1) {\n throw new RangeError('Invalid status code')\n }\n\n return new Response(null, {status: status, headers: {location: url}})\n };\n\n exports.DOMException = self.DOMException;\n try {\n new exports.DOMException();\n } catch (err) {\n exports.DOMException = function(message, name) {\n this.message = message;\n this.name = name;\n var error = Error(message);\n this.stack = error.stack;\n };\n exports.DOMException.prototype = Object.create(Error.prototype);\n exports.DOMException.prototype.constructor = exports.DOMException;\n }\n\n function fetch(input, init) {\n return new Promise(function(resolve, reject) {\n var request = new Request(input, init);\n\n if (request.signal && request.signal.aborted) {\n return reject(new exports.DOMException('Aborted', 'AbortError'))\n }\n\n var xhr = new XMLHttpRequest();\n\n function abortXhr() {\n xhr.abort();\n }\n\n xhr.onload = function() {\n var options = {\n status: xhr.status,\n statusText: xhr.statusText,\n headers: parseHeaders(xhr.getAllResponseHeaders() || '')\n };\n options.url = 'responseURL' in xhr ? xhr.responseURL : options.headers.get('X-Request-URL');\n var body = 'response' in xhr ? xhr.response : xhr.responseText;\n resolve(new Response(body, options));\n };\n\n xhr.onerror = function() {\n reject(new TypeError('Network request failed'));\n };\n\n xhr.ontimeout = function() {\n reject(new TypeError('Network request failed'));\n };\n\n xhr.onabort = function() {\n reject(new exports.DOMException('Aborted', 'AbortError'));\n };\n\n xhr.open(request.method, request.url, true);\n\n if (request.credentials === 'include') {\n xhr.withCredentials = true;\n } else if (request.credentials === 'omit') {\n xhr.withCredentials = false;\n }\n\n if ('responseType' in xhr && support.blob) {\n xhr.responseType = 'blob';\n }\n\n request.headers.forEach(function(value, name) {\n xhr.setRequestHeader(name, value);\n });\n\n if (request.signal) {\n request.signal.addEventListener('abort', abortXhr);\n\n xhr.onreadystatechange = function() {\n // DONE (success or failure)\n if (xhr.readyState === 4) {\n request.signal.removeEventListener('abort', abortXhr);\n }\n };\n }\n\n xhr.send(typeof request._bodyInit === 'undefined' ? null : request._bodyInit);\n })\n }\n\n fetch.polyfill = true;\n\n if (!self.fetch) {\n self.fetch = fetch;\n self.Headers = Headers;\n self.Request = Request;\n self.Response = Response;\n }\n\n exports.Headers = Headers;\n exports.Request = Request;\n exports.Response = Response;\n exports.fetch = fetch;\n\n return exports;\n\n}({}));\n})(__self__);\ndelete __self__.fetch.polyfill\nexports = __self__.fetch // To enable: import fetch from 'cross-fetch'\nexports.default = __self__.fetch // For TypeScript consumers without esModuleInterop.\nexports.fetch = __self__.fetch // To enable: import {fetch} from 'cross-fetch'\nexports.Headers = __self__.Headers\nexports.Request = __self__.Request\nexports.Response = __self__.Response\nmodule.exports = exports\n","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tif(__webpack_module_cache__[moduleId]) {\n\t\treturn __webpack_module_cache__[moduleId].exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// module exports must be returned from runtime so entry inlining is disabled\n// startup\n// Load entry module and return exports\nreturn __webpack_require__(47);\n","// getDefaultExport function for compatibility with non-harmony modules\n__webpack_require__.n = (module) => {\n\tvar getter = module && module.__esModule ?\n\t\t() => module['default'] :\n\t\t() => module;\n\t__webpack_require__.d(getter, { a: getter });\n\treturn getter;\n};","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop)","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};"],"sourceRoot":""} \ No newline at end of file diff --git a/dist/pdjs.js b/dist/pdjs.js index 6097a00..383c0bc 100644 --- a/dist/pdjs.js +++ b/dist/pdjs.js @@ -1,2 +1,2 @@ -var PagerDuty;PagerDuty=(()=>{"use strict";var e={337:(e,t,r)=>{function n(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function o(e){for(var t=1;t=0||(o[r]=e[r]);return o}(e,t);if(Object.getOwnPropertySymbols){var u=Object.getOwnPropertySymbols(e);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o}function i(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=t,n=r.queryParameters,u=r.requestTimeout,i=void 0===u?3e4:u,f=c(r,["queryParameters","requestTimeout"]);return e=l(e=new URL(e.toString()),n),t=p(t,i),a(e.toString(),3,o(o({},f),{},{headers:new Headers(o({"Content-Type":"application/json; charset=utf-8"},f.headers))}))}function a(e,t,r){return new Promise((function(n,o){fetch(e,r).then((function(u){if(0===t)return n(u);if(429===u.status){var c=r.retryTimeout;f(void 0===c?2e4:c).then((function(){a(e,t-1,r).then(n).catch(o)}))}else n(u)}))}))}r.r(t),r.d(t,{acknowledge:()=>A,all:()=>S,api:()=>w,change:()=>C,event:()=>q,resolve:()=>M,trigger:()=>R});var f=function(e){return new Promise((function(t){return setTimeout(t,e)}))};function l(e,t){if(!t)return e;for(var r=e.searchParams,n=function(){var e=u[o],n=t[e];Array.isArray(n)?n.forEach((function(t){r.append(e,t)})):r.append(e,n)},o=0,u=Object.keys(t);o]+)>/g,(function(e,t){return"$"+r[t]})))}if("function"==typeof t){var u=this;return n[Symbol.replace].call(this,e,(function(){var e=[];return e.push.apply(e,arguments),"object"!==s(e[e.length-1])&&e.push(c(e,u)),t.apply(this,e)}))}return n[Symbol.replace].call(this,e,t)},y.apply(this,arguments)}function b(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&d(e,t)}function O(e){var t="function"==typeof Map?new Map:void 0;return(O=function(e){if(null===e||(r=e,-1===Function.toString.call(r).indexOf("[native code]")))return e;var r;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return v(e,arguments,h(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),d(n,e)})(e)}function v(e,t,r){return(v=g()?Reflect.construct:function(e,t,r){var n=[null];n.push.apply(n,t);var o=new(Function.bind.apply(e,n));return r&&d(o,r.prototype),o}).apply(null,arguments)}function g(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}function d(e,t){return(d=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function h(e){return(h=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function m(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function j(e){for(var t=1;t=0||(o[r]=e[r]);return o}(e,t);if(Object.getOwnPropertySymbols){var u=Object.getOwnPropertySymbols(e);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o}(e,["endpoint","server","token","url","version","data"]),y=j(j({method:"GET"},s),{},{headers:j({Accept:"application/vnd.pagerduty+json;version=".concat(l),Authorization:"Token token=".concat(i)},s.headers)});return r=y.method,!["PUT","POST","DELETE","PATCH"].includes(null!==(n=r.toUpperCase())&&void 0!==n?n:"GET")&&p?y.queryParameters=null!==(t=y.queryParameters)&&void 0!==t?t:p:y.body=JSON.stringify(p),E(null!=a?a:"https://".concat(c,"/").concat(o.replace(/^\/+/,"")),y)}function S(e){return w(e).then((function(e){return x([e])}))}function x(e){var t=e[e.length-1];return t.next?t.next().then((function(t){return x(e.concat([t]))})):Promise.resolve(e)}function E(e,t){return i(e,t).then((function(r){var n=r;n.response=r;var o=function(e){var t=e.match(y(/.+.com\/([0-9A-Z_a-z]+)/,{resource:1}));return t?t[1]:null}(e);return r.json().then((function(r){return n.next=function(e,t,r){if(function(e){return void 0!==e.offset}(r)){if((null==r?void 0:r.more)&&void 0!==s(r.offset)&&r.limit)return function(){return E(e,j(j({},t),{},{queryParameters:j(j({},t.queryParameters),{},{limit:r.limit.toString(),offset:(r.limit+r.offset).toString()})}))}}else if(function(e){return void 0!==e.cursor}(r)&&(null==r?void 0:r.cursor))return function(){return E(e,j(j({},t),{},{queryParameters:j(j({},t.queryParameters),{},{cursor:r.cursor,limit:r.limit.toString()})}))}}(e,t,r),n.data=r,n.resource=o?r[o]:null,n})).catch((function(){return Promise.resolve(n)}))}))}function T(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function D(e){for(var t=1;t=0||(o[r]=e[r]);return o}(e,t);if(Object.getOwnPropertySymbols){var u=Object.getOwnPropertySymbols(e);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o}(e,["server","type","data"]),a="https://".concat(r,"/v2/enqueue");return"change"===o&&(a="https://".concat(r,"/v2/change/enqueue")),function(e,t){return i(e,t).then((function(e){var t=e;return e.json().then((function(r){return t.data=r,t.response=e,t}))}))}(a,D({method:"POST",body:JSON.stringify(u)},c))}var _=function(e){return function(t){return q(D(D({},t),{},{data:D(D({},t.data),{},k({},"event_action",e))}))}},R=_("trigger"),A=_("acknowledge"),M=_("resolve"),C=function(e){return q(D(D({},e),{},{type:"change"}))}}},t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={exports:{}};return e[n](o,o.exports,r),o.exports}return r.d=(e,t)=>{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r(337)})(); +var PagerDuty;PagerDuty=(()=>{"use strict";var e={337:(e,t,r)=>{function n(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function o(e){for(var t=1;t=0||(o[r]=e[r]);return o}(e,t);if(Object.getOwnPropertySymbols){var u=Object.getOwnPropertySymbols(e);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o}function i(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=t,n=r.queryParameters,u=r.requestTimeout,i=void 0===u?3e4:u,f=c(r,["queryParameters","requestTimeout"]);return e=l(e=new URL(e.toString()),n),t=p(t,i),a(e.toString(),3,o(o({},f),{},{headers:new Headers(o({"Content-Type":"application/json; charset=utf-8"},f.headers))}))}function a(e,t,r){return new Promise((function(n,o){fetch(e,r).then((function(u){if(0===t)return n(u);if(429===u.status){var c=r.retryTimeout;f(void 0===c?2e4:c).then((function(){a(e,t-1,r).then(n).catch(o)}))}else n(u)}))}))}r.r(t),r.d(t,{acknowledge:()=>A,all:()=>S,api:()=>w,change:()=>C,event:()=>q,resolve:()=>M,trigger:()=>R});var f=function(e){return new Promise((function(t){return setTimeout(t,e)}))};function l(e,t){if(!t)return e;for(var r=e.searchParams,n=function(){var e=u[o],n=t[e];Array.isArray(n)?n.forEach((function(t){r.append(e,t)})):r.append(e,n)},o=0,u=Object.keys(t);o]+)>/g,(function(e,t){return"$"+r[t]})))}if("function"==typeof t){var u=this;return n[Symbol.replace].call(this,e,(function(){var e=[];return e.push.apply(e,arguments),"object"!==s(e[e.length-1])&&e.push(c(e,u)),t.apply(this,e)}))}return n[Symbol.replace].call(this,e,t)},y.apply(this,arguments)}function b(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&d(e,t)}function O(e){var t="function"==typeof Map?new Map:void 0;return(O=function(e){if(null===e||(r=e,-1===Function.toString.call(r).indexOf("[native code]")))return e;var r;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return v(e,arguments,h(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),d(n,e)})(e)}function v(e,t,r){return(v=g()?Reflect.construct:function(e,t,r){var n=[null];n.push.apply(n,t);var o=new(Function.bind.apply(e,n));return r&&d(o,r.prototype),o}).apply(null,arguments)}function g(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}function d(e,t){return(d=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function h(e){return(h=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function m(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function j(e){for(var t=1;t=0||(o[r]=e[r]);return o}(e,t);if(Object.getOwnPropertySymbols){var u=Object.getOwnPropertySymbols(e);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o}(e,["endpoint","server","token","url","version","data"]),y=j(j({method:"GET"},s),{},{headers:j({Accept:"application/vnd.pagerduty+json;version=".concat(l),Authorization:"Token token=".concat(i)},s.headers)});return r=y.method,!["PUT","POST","DELETE","PATCH"].includes(null!==(n=r.toUpperCase())&&void 0!==n?n:"GET")&&p?y.queryParameters=null!==(t=y.queryParameters)&&void 0!==t?t:p:y.body=JSON.stringify(p),E(null!=a?a:"https://".concat(c,"/").concat(o.replace(/^\/+/,"")),y)}function S(e){return w(e).then((function(e){return x([e])}))}function x(e){var t=e[e.length-1];return t.next?t.next().then((function(t){return x(e.concat([t]))})):Promise.resolve(e)}function E(e,t){return i(e,t).then((function(r){var n=r;n.response=r;var o=function(e){var t=e.match(y(/.+.com\/([0-9A-Z_a-z]+)/,{resource:1}));return t?t[1]:null}(e);return r.json().then((function(r){return n.next=function(e,t,r){if(function(e){return void 0!==e.offset}(r)){if(null!=r&&r.more&&void 0!==s(r.offset)&&r.limit)return function(){return E(e,j(j({},t),{},{queryParameters:j(j({},t.queryParameters),{},{limit:r.limit.toString(),offset:(r.limit+r.offset).toString()})}))}}else if(function(e){return void 0!==e.cursor}(r)&&null!=r&&r.cursor)return function(){return E(e,j(j({},t),{},{queryParameters:j(j({},t.queryParameters),{},{cursor:r.cursor,limit:r.limit.toString()})}))}}(e,t,r),n.data=r,n.resource=o?r[o]:null,n})).catch((function(){return Promise.resolve(n)}))}))}function T(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function D(e){for(var t=1;t=0||(o[r]=e[r]);return o}(e,t);if(Object.getOwnPropertySymbols){var u=Object.getOwnPropertySymbols(e);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o}(e,["server","type","data"]),a="https://".concat(r,"/v2/enqueue");return"change"===o&&(a="https://".concat(r,"/v2/change/enqueue")),function(e,t){return i(e,t).then((function(e){var t=e;return e.json().then((function(r){return t.data=r,t.response=e,t}))}))}(a,D({method:"POST",body:JSON.stringify(u)},c))}var _=function(e){return function(t){return q(D(D({},t),{},{data:D(D({},t.data),{},k({},"event_action",e))}))}},R=_("trigger"),A=_("acknowledge"),M=_("resolve"),C=function(e){return q(D(D({},e),{},{type:"change"}))}}},t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={exports:{}};return e[n](o,o.exports,r),o.exports}return r.d=(e,t)=>{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r(337)})(); //# sourceMappingURL=pdjs.js.map \ No newline at end of file diff --git a/dist/pdjs.js.map b/dist/pdjs.js.map index 4862f32..d95bf69 100644 --- a/dist/pdjs.js.map +++ b/dist/pdjs.js.map @@ -1 +1 @@ -{"version":3,"sources":["webpack://PagerDuty/./src/common.ts","webpack://PagerDuty/./src/api.ts","webpack://PagerDuty/./src/events.ts","webpack://PagerDuty/webpack/bootstrap","webpack://PagerDuty/webpack/startup","webpack://PagerDuty/webpack/runtime/define property getters","webpack://PagerDuty/webpack/runtime/hasOwnProperty shorthand","webpack://PagerDuty/webpack/runtime/make namespace object"],"names":["request","url","options","queryParameters","requestTimeout","rest","applyParameters","URL","toString","applyTimeout","fetch_retry","headers","Headers","retries","Promise","resolve","reject","fetch","then","response","status","retryTimeout","retryTimeoutPromise","milliseconds","setTimeout","combinedParameters","searchParams","key","parameter","Array","isArray","forEach","item","append","Object","keys","search","init","timeout","controller","AbortController","abort","signal","api","apiParameters","endpoint","partialParameters","partial","shorthand","method","shorthandParameters","get","post","put","patch","all","partialCall","server","token","version","data","config","Accept","Authorization","includes","toUpperCase","body","JSON","stringify","apiRequest","replace","allInner","responses","length","next","concat","apiResponse","resource","match","resourceKey","json","undefined","offset","isOffsetPagination","more","limit","cursor","isCursorPagination","nextFunc","event","eventParameters","type","eventFetch","action","trigger","acknowledge","change","__webpack_module_cache__","__webpack_require__","moduleId","exports","module","__webpack_modules__","d","definition","o","defineProperty","enumerable","obj","prop","prototype","hasOwnProperty","call","r","Symbol","toStringTag","value"],"mappings":"2mCAcO,SAASA,EACdC,GAEmB,IADnBC,EACmB,uDADO,GACP,EACwCA,EAApDC,EADY,EACZA,gBADY,IACKC,sBADL,MACsB,IADtB,EACgCC,EADhC,0CAQnB,OAHAJ,EAAMK,EAFNL,EAAM,IAAIM,IAAIN,EAAIO,YAESL,GAC3BD,EAAUO,EAAaP,EAASE,GAEzBM,EAAYT,EAAIO,WAAY,EAAjB,OACbH,GADa,IAEhBM,QAAS,IAAIC,QAAJ,GACP,eAAgB,mCAEbP,EAAKM,aAKd,SAASD,EACPT,EACAY,EACAX,GAEA,OAAO,IAAIY,SAAQ,SAACC,EAASC,GAC3BC,MAAMhB,EAAKC,GAASgB,MAAK,SAAAC,GAGvB,GAAgB,IAAZN,EAAe,OAAOE,EAAQI,GAClC,GAAwB,MAApBA,EAASC,OAAgB,OACIlB,EAAxBmB,aACPC,OAF2B,MACL,IADK,GAEOJ,MAAK,WACrCR,EAAYT,EAAKY,EAAU,EAAGX,GAC3BgB,KAAKH,GADR,MAESC,WAGXD,EAAQI,S,2GAMhB,IAAMG,EAAsB,SAACC,GAC3B,OAAO,IAAIT,SAAQ,SAAAC,GAAO,OAAIS,WAAWT,EAASQ,OAWpD,SAASjB,EAAgBL,EAAUE,GACjC,IAAKA,EAAiB,OAAOF,EAI7B,IAFA,IAAMwB,EAAqBxB,EAAIyB,aAHyC,aAKnE,IAAMC,EAAG,KACNC,EAAYzB,EAAgBwB,GAC9BE,MAAMC,QAAQF,GAEhBA,EAAUG,SAAQ,SAAAC,GAChBP,EAAmBQ,OAAON,EAAKK,MAGjCP,EAAmBQ,OAAON,EAAKC,IARnC,MAAkBM,OAAOC,KAAKhC,GAA9B,e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D,QCjBf,OCFAF,EAAoBK,EAAI,CAACH,EAASI,KACjC,IAAI,IAAI7E,KAAO6E,EACXN,EAAoBO,EAAED,EAAY7E,KAASuE,EAAoBO,EAAEL,EAASzE,IAC5EO,OAAOwE,eAAeN,EAASzE,EAAK,CAAEgF,YAAY,EAAMxD,IAAKqD,EAAW7E,MCJ3EuE,EAAoBO,EAAI,CAACG,EAAKC,IAAS3E,OAAO4E,UAAUC,eAAeC,KAAKJ,EAAKC,GCCjFX,EAAoBe,EAAKb,IACH,oBAAXc,QAA0BA,OAAOC,aAC1CjF,OAAOwE,eAAeN,EAASc,OAAOC,YAAa,CAAEC,MAAO,WAE7DlF,OAAOwE,eAAeN,EAAS,aAAc,CAAEgB,OAAO,KHFhDlB,EAAoB,M","file":"pdjs.js","sourcesContent":["/* webpack-strip-block:removed */\n\nconst VERSION = '2.0.0';\n\ntype QueryParameter = Record>;\n\nexport interface RequestOptions extends RequestInit {\n queryParameters?: QueryParameter;\n retryCount?: number;\n requestTimeout?: number;\n retryTimeout?: number;\n timeout?: number;\n}\n\nexport function request(\n url: string | URL,\n options: RequestOptions = {}\n): Promise {\n const {queryParameters, requestTimeout = 30000, ...rest} = options;\n\n url = new URL(url.toString());\n\n url = applyParameters(url, queryParameters);\n options = applyTimeout(options, requestTimeout);\n\n return fetch_retry(url.toString(), 3, {\n ...rest,\n headers: new Headers({\n 'Content-Type': 'application/json; charset=utf-8',\n /* webpack-strip-block:removed */\n ...rest.headers,\n }),\n });\n}\n\nfunction fetch_retry(\n url: string,\n retries: number,\n options: RequestOptions\n): Promise {\n return new Promise((resolve, reject) => {\n fetch(url, options).then(response => {\n // We don't want to `reject` when retries have finished\n // Instead simply stop trying and return.\n if (retries === 0) return resolve(response);\n if (response.status === 429) {\n const {retryTimeout = 20000} = options;\n retryTimeoutPromise(retryTimeout).then(() => {\n fetch_retry(url, retries - 1, options)\n .then(resolve)\n .catch(reject);\n });\n } else {\n resolve(response);\n }\n });\n });\n}\n\nconst retryTimeoutPromise = (milliseconds: number) => {\n return new Promise(resolve => setTimeout(resolve, milliseconds));\n};\n\nfunction userAgentHeader(): object {\n if (isBrowser) return {};\n\n return {\n 'User-Agent': `pdjs/${VERSION} (${process.version}/${process.platform})`,\n };\n}\n\nfunction applyParameters(url: URL, queryParameters?: QueryParameter): URL {\n if (!queryParameters) return url;\n\n const combinedParameters = url.searchParams;\n\n for (const key of Object.keys(queryParameters)) {\n const parameter = queryParameters[key];\n if (Array.isArray(parameter)) {\n // Support for array based keys like `additional_fields[]`\n parameter.forEach(item => {\n combinedParameters.append(key, item);\n });\n } else {\n combinedParameters.append(key, parameter);\n }\n }\n\n url.search = combinedParameters.toString();\n return url;\n}\n\nfunction applyTimeout(init: RequestOptions, timeout?: number): RequestOptions {\n if (!timeout) return init;\n\n const controller = new AbortController();\n setTimeout(() => controller.abort(), timeout);\n\n return {\n ...init,\n signal: controller.signal,\n };\n}\n","import {request, RequestOptions} from './common';\n\nexport interface ShorthandCall {\n (res: string, apiParameters?: Partial): APIPromise;\n}\n\nexport interface PartialCall {\n (apiParameters: APIParameters): APIPromise;\n (apiParameters: Partial): PartialCall;\n get: ShorthandCall;\n post: ShorthandCall;\n put: ShorthandCall;\n patch: ShorthandCall;\n delete: ShorthandCall;\n all: (apiParameters: APIParameters) => Promise;\n}\n\nexport type APIParameters = RequestOptions & {\n endpoint?: string;\n url?: string;\n data?: object;\n token?: string;\n server?: string;\n version?: number;\n} & ({endpoint: string} | {url: string});\n\nexport type APIPromise = Promise;\n\nexport interface APIResponse extends Response {\n data: any;\n resource: any;\n response: Response;\n next?: () => APIPromise;\n}\n\nexport function api(apiParameters: APIParameters): APIPromise;\nexport function api(apiParameters: Partial): PartialCall;\nexport function api(\n apiParameters: Partial\n): APIPromise | PartialCall {\n // If the apiParameters don't include `endpoint` treat it as a partial\n // application.\n if (!apiParameters.endpoint && !apiParameters.url) {\n return partialCall(apiParameters);\n }\n\n const {\n endpoint,\n server = 'api.pagerduty.com',\n token,\n url,\n version = 2,\n data,\n ...rest\n } = apiParameters;\n\n const config: RequestOptions = {\n method: 'GET',\n ...rest,\n headers: {\n Accept: `application/vnd.pagerduty+json;version=${version}`,\n Authorization: `Token token=${token!}`,\n ...rest.headers,\n },\n };\n\n // Allow `data` for `queryParameters` for requests without bodies.\n if (isReadonlyRequest(config.method!) && data) {\n config.queryParameters =\n config.queryParameters ?? (data as Record);\n } else {\n config.body = JSON.stringify(data);\n }\n\n return apiRequest(\n url ?? `https://${server}/${endpoint!.replace(/^\\/+/, '')}`,\n config\n );\n}\n\nexport function all(apiParameters: APIParameters): Promise {\n return (api(apiParameters) as APIPromise).then(response =>\n allInner([response])\n );\n}\n\nfunction allInner(responses: APIResponse[]): Promise {\n const response = responses[responses.length - 1];\n\n if (!response.next) {\n return Promise.resolve(responses);\n }\n\n return response\n .next()\n .then(response => allInner(responses.concat([response])));\n}\n\nfunction apiRequest(url: string, options: RequestOptions): APIPromise {\n return request(url, options).then(\n (response: Response): APIPromise => {\n const apiResponse = response as APIResponse;\n apiResponse.response = response;\n const resource = resourceKey(url);\n return response\n .json()\n .then(\n (data): APIResponse => {\n apiResponse.next = nextFunc(url, options, data);\n apiResponse.data = data;\n apiResponse.resource = resource ? data[resource] : null;\n return apiResponse;\n }\n )\n .catch(() => Promise.resolve(apiResponse));\n }\n );\n}\n\nfunction resourceKey(url: string) {\n const resource = url.match(/.+.com\\/(?[\\w]+)/);\n if (resource) {\n return resource[1];\n }\n return null;\n}\n\nfunction isReadonlyRequest(method: string) {\n return !['PUT', 'POST', 'DELETE', 'PATCH'].includes(\n method.toUpperCase() ?? 'GET'\n );\n}\n\ninterface OffsetPagination {\n type: 'offset';\n more?: boolean;\n offset?: number;\n limit?: number;\n}\n\ninterface CursorPagination {\n type: 'cursor';\n cursor?: string;\n limit?: number;\n}\n\nfunction isOffsetPagination(\n data: OffsetPagination | CursorPagination\n): data is OffsetPagination {\n if ((data as OffsetPagination).offset !== undefined) {\n return true;\n }\n return false;\n}\n\nfunction isCursorPagination(\n data: OffsetPagination | CursorPagination\n): data is CursorPagination {\n if ((data as CursorPagination).cursor !== undefined) {\n return true;\n }\n return false;\n}\n\nfunction nextFunc(\n url: string,\n options: RequestOptions,\n data: OffsetPagination | CursorPagination\n) {\n if (isOffsetPagination(data)) {\n if (data?.more && typeof data.offset !== undefined && data.limit) {\n return () =>\n apiRequest(url, {\n ...options,\n queryParameters: {\n ...options.queryParameters,\n limit: data.limit!.toString(),\n offset: (data.limit! + data.offset!).toString(),\n },\n });\n }\n } else if (isCursorPagination(data)) {\n if (data?.cursor) {\n return () =>\n apiRequest(url, {\n ...options,\n queryParameters: {\n ...options.queryParameters,\n cursor: data.cursor!,\n limit: data.limit!.toString(),\n },\n });\n }\n }\n\n return undefined;\n}\n\nfunction partialCall(apiParameters: Partial) {\n const partialParameters = apiParameters;\n const partial = ((apiParameters: Partial) =>\n api({...partialParameters, ...apiParameters})) as PartialCall;\n\n const shorthand = (method: string) => (\n endpoint: string,\n shorthandParameters?: Partial\n ): APIPromise =>\n api({\n endpoint,\n method,\n ...partialParameters,\n ...shorthandParameters,\n }) as APIPromise;\n\n partial.get = shorthand('get');\n partial.post = shorthand('post');\n partial.put = shorthand('put');\n partial.patch = shorthand('patch');\n partial.delete = shorthand('delete');\n\n partial.all = (apiParameters: APIParameters) => all(apiParameters);\n\n return partial;\n}\n","import {request, RequestOptions} from './common';\n\nexport type Action = 'trigger' | 'acknowledge' | 'resolve';\n\nexport type EventPromise = Promise;\n\nexport interface EventResponse extends Response {\n data: any;\n response: Response;\n}\n\nexport type Severity = 'critical' | 'error' | 'warning' | 'info';\n\nexport interface Image {\n src: string;\n href?: string;\n alt?: string;\n}\n\nexport interface Link {\n href: string;\n text?: string;\n}\n\nexport interface EventPayloadV2 {\n routing_key: string;\n event_action: Action;\n dedup_key?: string;\n payload: {\n summary: string;\n source: string;\n severity: Severity;\n timestamp?: string;\n component?: string;\n group?: string;\n class?: string;\n custom_details?: object;\n };\n images?: Array;\n links?: Array;\n}\n\nexport interface EventParameters extends RequestOptions {\n data: EventPayloadV2;\n type?: string;\n server?: string;\n}\n\nexport interface ChangePayload {\n routing_key: string;\n payload: {\n summary: string;\n source?: string;\n timestamp: string;\n custom_details: object;\n };\n links: Array;\n}\nexport interface ChangeParameters extends RequestOptions {\n data: ChangePayload;\n server?: string;\n}\n\nexport function event(eventParameters: EventParameters): EventPromise {\n const {\n server = 'events.pagerduty.com',\n type = 'event',\n data,\n ...config\n } = eventParameters;\n\n let url = `https://${server}/v2/enqueue`;\n if (type === 'change') {\n url = `https://${server}/v2/change/enqueue`;\n }\n\n return eventFetch(url, {\n method: 'POST',\n body: JSON.stringify(data),\n ...config,\n });\n}\n\nconst shorthand = (action: Action) => (\n eventParameters: EventParameters\n): EventPromise => {\n const typeField = 'event_action';\n\n return event({\n ...eventParameters,\n data: {\n ...eventParameters.data,\n [typeField]: action,\n },\n });\n};\n\nexport const trigger = shorthand('trigger');\nexport const acknowledge = shorthand('acknowledge');\nexport const resolve = shorthand('resolve');\nexport const change = (eventParameters: EventParameters) =>\n event({...eventParameters, type: 'change'});\n\nfunction eventFetch(url: string, options: RequestOptions): EventPromise {\n return request(url, options).then(\n (response: Response): EventPromise => {\n const apiResponse = response as EventResponse;\n return response.json().then(\n (data): EventResponse => {\n apiResponse.data = data;\n apiResponse.response = response;\n return apiResponse;\n }\n );\n }\n );\n}\n","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tif(__webpack_module_cache__[moduleId]) {\n\t\treturn __webpack_module_cache__[moduleId].exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// module exports must be returned from runtime so entry inlining is disabled\n// startup\n// Load entry module and return exports\nreturn __webpack_require__(337);\n","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop)","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};"],"sourceRoot":""} \ No newline at end of file +{"version":3,"sources":["webpack://PagerDuty/./src/common.ts","webpack://PagerDuty/./src/api.ts","webpack://PagerDuty/./src/events.ts","webpack://PagerDuty/webpack/bootstrap","webpack://PagerDuty/webpack/startup","webpack://PagerDuty/webpack/runtime/define property getters","webpack://PagerDuty/webpack/runtime/hasOwnProperty shorthand","webpack://PagerDuty/webpack/runtime/make namespace object"],"names":["request","url","options","queryParameters","requestTimeout","rest","applyParameters","URL","toString","applyTimeout","fetch_retry","headers","Headers","retries","Promise","resolve","reject","fetch","then","response","status","retryTimeout","retryTimeoutPromise","milliseconds","setTimeout","combinedParameters","searchParams","key","parameter","Array","isArray","forEach","item","append","Object","keys","search","init","timeout","controller","AbortController","abort","signal","api","apiParameters","endpoint","partialParameters","partial","shorthand","method","shorthandParameters","get","post","put","patch","all","partialCall","server","token","version","data","config","Accept","Authorization","includes","toUpperCase","body","JSON","stringify","apiRequest","replace","allInner","responses","length","next","concat","apiResponse","resource","match","resourceKey","json","undefined","offset","isOffsetPagination","more","limit","cursor","isCursorPagination","nextFunc","event","eventParameters","type","eventFetch","action","trigger","acknowledge","change","__webpack_module_cache__","__webpack_require__","moduleId","exports","module","__webpack_modules__","d","definition","o","defineProperty","enumerable","obj","prop","prototype","hasOwnProperty","call","r","Symbol","toStringTag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EuE,EAAoBO,EAAI,CAACG,EAAKC,IAAS3E,OAAO4E,UAAUC,eAAeC,KAAKJ,EAAKC,GCCjFX,EAAoBe,EAAKb,IACH,oBAAXc,QAA0BA,OAAOC,aAC1CjF,OAAOwE,eAAeN,EAASc,OAAOC,YAAa,CAAEC,MAAO,WAE7DlF,OAAOwE,eAAeN,EAAS,aAAc,CAAEgB,OAAO,KHFhDlB,EAAoB,M","file":"pdjs.js","sourcesContent":["/* webpack-strip-block:removed */\n\nconst VERSION = '2.0.0';\n\ntype QueryParameter = Record>;\n\nexport interface RequestOptions extends RequestInit {\n queryParameters?: QueryParameter;\n retryCount?: number;\n requestTimeout?: number;\n retryTimeout?: number;\n timeout?: number;\n}\n\nexport function request(\n url: string | URL,\n options: RequestOptions = {}\n): Promise {\n const {queryParameters, requestTimeout = 30000, ...rest} = options;\n\n url = new URL(url.toString());\n\n url = applyParameters(url, queryParameters);\n options = applyTimeout(options, requestTimeout);\n\n return fetch_retry(url.toString(), 3, {\n ...rest,\n headers: new Headers({\n 'Content-Type': 'application/json; charset=utf-8',\n /* webpack-strip-block:removed */\n ...rest.headers,\n }),\n });\n}\n\nfunction fetch_retry(\n url: string,\n retries: number,\n options: RequestOptions\n): Promise {\n return new Promise((resolve, reject) => {\n fetch(url, options).then(response => {\n // We don't want to `reject` when retries have finished\n // Instead simply stop trying and return.\n if (retries === 0) return resolve(response);\n if (response.status === 429) {\n const {retryTimeout = 20000} = options;\n retryTimeoutPromise(retryTimeout).then(() => {\n fetch_retry(url, retries - 1, options)\n .then(resolve)\n .catch(reject);\n });\n } else {\n resolve(response);\n }\n });\n });\n}\n\nconst retryTimeoutPromise = (milliseconds: number) => {\n return new Promise(resolve => setTimeout(resolve, milliseconds));\n};\n\nfunction userAgentHeader(): object {\n if (isBrowser) return {};\n\n return {\n 'User-Agent': `pdjs/${VERSION} (${process.version}/${process.platform})`,\n };\n}\n\nfunction applyParameters(url: URL, queryParameters?: QueryParameter): URL {\n if (!queryParameters) return url;\n\n const combinedParameters = url.searchParams;\n\n for (const key of Object.keys(queryParameters)) {\n const parameter = queryParameters[key];\n if (Array.isArray(parameter)) {\n // Support for array based keys like `additional_fields[]`\n parameter.forEach(item => {\n combinedParameters.append(key, item);\n });\n } else {\n combinedParameters.append(key, parameter);\n }\n }\n\n url.search = combinedParameters.toString();\n return url;\n}\n\nfunction applyTimeout(init: RequestOptions, timeout?: number): RequestOptions {\n if (!timeout) return init;\n\n const controller = new AbortController();\n setTimeout(() => controller.abort(), timeout);\n\n return {\n ...init,\n signal: controller.signal,\n };\n}\n","import {request, RequestOptions} from './common';\n\nexport interface ShorthandCall {\n (res: string, apiParameters?: Partial): APIPromise;\n}\n\nexport interface PartialCall {\n (apiParameters: APIParameters): APIPromise;\n (apiParameters: Partial): PartialCall;\n get: ShorthandCall;\n post: ShorthandCall;\n put: ShorthandCall;\n patch: ShorthandCall;\n delete: ShorthandCall;\n all: (apiParameters: APIParameters) => Promise;\n}\n\nexport type APIParameters = RequestOptions & {\n endpoint?: string;\n url?: string;\n data?: object;\n token?: string;\n server?: string;\n version?: number;\n} & ({endpoint: string} | {url: string});\n\nexport type APIPromise = Promise;\n\nexport interface APIResponse extends Response {\n data: any;\n resource: any;\n response: Response;\n next?: () => APIPromise;\n}\n\nexport function api(apiParameters: APIParameters): APIPromise;\nexport function api(apiParameters: Partial): PartialCall;\nexport function api(\n apiParameters: Partial\n): APIPromise | PartialCall {\n // If the apiParameters don't include `endpoint` treat it as a partial\n // application.\n if (!apiParameters.endpoint && !apiParameters.url) {\n return partialCall(apiParameters);\n }\n\n const {\n endpoint,\n server = 'api.pagerduty.com',\n token,\n url,\n version = 2,\n data,\n ...rest\n } = apiParameters;\n\n const config: RequestOptions = {\n method: 'GET',\n ...rest,\n headers: {\n Accept: `application/vnd.pagerduty+json;version=${version}`,\n Authorization: `Token token=${token!}`,\n ...rest.headers,\n },\n };\n\n // Allow `data` for `queryParameters` for requests without bodies.\n if (isReadonlyRequest(config.method!) && data) {\n config.queryParameters =\n config.queryParameters ?? (data as Record);\n } else {\n config.body = JSON.stringify(data);\n }\n\n return apiRequest(\n url ?? `https://${server}/${endpoint!.replace(/^\\/+/, '')}`,\n config\n );\n}\n\nexport function all(apiParameters: APIParameters): Promise {\n return (api(apiParameters) as APIPromise).then(response =>\n allInner([response])\n );\n}\n\nfunction allInner(responses: APIResponse[]): Promise {\n const response = responses[responses.length - 1];\n\n if (!response.next) {\n return Promise.resolve(responses);\n }\n\n return response\n .next()\n .then(response => allInner(responses.concat([response])));\n}\n\nfunction apiRequest(url: string, options: RequestOptions): APIPromise {\n return request(url, options).then(\n (response: Response): APIPromise => {\n const apiResponse = response as APIResponse;\n apiResponse.response = response;\n const resource = resourceKey(url);\n return response\n .json()\n .then(\n (data): APIResponse => {\n apiResponse.next = nextFunc(url, options, data);\n apiResponse.data = data;\n apiResponse.resource = resource ? data[resource] : null;\n return apiResponse;\n }\n )\n .catch(() => Promise.resolve(apiResponse));\n }\n );\n}\n\nfunction resourceKey(url: string) {\n const resource = url.match(/.+.com\\/(?[\\w]+)/);\n if (resource) {\n return resource[1];\n }\n return null;\n}\n\nfunction isReadonlyRequest(method: string) {\n return !['PUT', 'POST', 'DELETE', 'PATCH'].includes(\n method.toUpperCase() ?? 'GET'\n );\n}\n\ninterface OffsetPagination {\n type: 'offset';\n more?: boolean;\n offset?: number;\n limit?: number;\n}\n\ninterface CursorPagination {\n type: 'cursor';\n cursor?: string;\n limit?: number;\n}\n\nfunction isOffsetPagination(\n data: OffsetPagination | CursorPagination\n): data is OffsetPagination {\n if ((data as OffsetPagination).offset !== undefined) {\n return true;\n }\n return false;\n}\n\nfunction isCursorPagination(\n data: OffsetPagination | CursorPagination\n): data is CursorPagination {\n if ((data as CursorPagination).cursor !== undefined) {\n return true;\n }\n return false;\n}\n\nfunction nextFunc(\n url: string,\n options: RequestOptions,\n data: OffsetPagination | CursorPagination\n) {\n if (isOffsetPagination(data)) {\n if (data?.more && typeof data.offset !== undefined && data.limit) {\n return () =>\n apiRequest(url, {\n ...options,\n queryParameters: {\n ...options.queryParameters,\n limit: data.limit!.toString(),\n offset: (data.limit! + data.offset!).toString(),\n },\n });\n }\n } else if (isCursorPagination(data)) {\n if (data?.cursor) {\n return () =>\n apiRequest(url, {\n ...options,\n queryParameters: {\n ...options.queryParameters,\n cursor: data.cursor!,\n limit: data.limit!.toString(),\n },\n });\n }\n }\n\n return undefined;\n}\n\nfunction partialCall(apiParameters: Partial) {\n const partialParameters = apiParameters;\n const partial = ((apiParameters: Partial) =>\n api({...partialParameters, ...apiParameters})) as PartialCall;\n\n const shorthand = (method: string) => (\n endpoint: string,\n shorthandParameters?: Partial\n ): APIPromise =>\n api({\n endpoint,\n method,\n ...partialParameters,\n ...shorthandParameters,\n }) as APIPromise;\n\n partial.get = shorthand('get');\n partial.post = shorthand('post');\n partial.put = shorthand('put');\n partial.patch = shorthand('patch');\n partial.delete = shorthand('delete');\n\n partial.all = (apiParameters: APIParameters) => all(apiParameters);\n\n return partial;\n}\n","import {request, RequestOptions} from './common';\n\nexport type Action = 'trigger' | 'acknowledge' | 'resolve';\n\nexport type EventPromise = Promise;\n\nexport interface EventResponse extends Response {\n data: any;\n response: Response;\n}\n\nexport type Severity = 'critical' | 'error' | 'warning' | 'info';\n\nexport interface Image {\n src: string;\n href?: string;\n alt?: string;\n}\n\nexport interface Link {\n href: string;\n text?: string;\n}\n\nexport interface EventPayloadV2 {\n routing_key: string;\n event_action: Action;\n dedup_key?: string;\n payload: {\n summary: string;\n source: string;\n severity: Severity;\n timestamp?: string;\n component?: string;\n group?: string;\n class?: string;\n custom_details?: object;\n };\n images?: Array;\n links?: Array;\n}\n\nexport interface EventParameters extends RequestOptions {\n data: EventPayloadV2;\n type?: string;\n server?: string;\n}\n\nexport interface ChangePayload {\n routing_key: string;\n payload: {\n summary: string;\n source?: string;\n timestamp: string;\n custom_details: object;\n };\n links: Array;\n}\nexport interface ChangeParameters extends RequestOptions {\n data: ChangePayload;\n server?: string;\n}\n\nexport function event(eventParameters: EventParameters): EventPromise {\n const {\n server = 'events.pagerduty.com',\n type = 'event',\n data,\n ...config\n } = eventParameters;\n\n let url = `https://${server}/v2/enqueue`;\n if (type === 'change') {\n url = `https://${server}/v2/change/enqueue`;\n }\n\n return eventFetch(url, {\n method: 'POST',\n body: JSON.stringify(data),\n ...config,\n });\n}\n\nconst shorthand = (action: Action) => (\n eventParameters: EventParameters\n): EventPromise => {\n const typeField = 'event_action';\n\n return event({\n ...eventParameters,\n data: {\n ...eventParameters.data,\n [typeField]: action,\n },\n });\n};\n\nexport const trigger = shorthand('trigger');\nexport const acknowledge = shorthand('acknowledge');\nexport const resolve = shorthand('resolve');\nexport const change = (eventParameters: EventParameters) =>\n event({...eventParameters, type: 'change'});\n\nfunction eventFetch(url: string, options: RequestOptions): EventPromise {\n return request(url, options).then(\n (response: Response): EventPromise => {\n const apiResponse = response as EventResponse;\n return response.json().then(\n (data): EventResponse => {\n apiResponse.data = data;\n apiResponse.response = response;\n return apiResponse;\n }\n );\n }\n );\n}\n","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tif(__webpack_module_cache__[moduleId]) {\n\t\treturn __webpack_module_cache__[moduleId].exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// module exports must be returned from runtime so entry inlining is disabled\n// startup\n// Load entry module and return exports\nreturn __webpack_require__(337);\n","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop)","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};"],"sourceRoot":""} \ No newline at end of file From d58324c6e0b26e085232730a56983cf13f3d7f91 Mon Sep 17 00:00:00 2001 From: Brett Willemsen Date: Tue, 24 Nov 2020 17:23:47 -0500 Subject: [PATCH 2/4] Update version in package.json. --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 2408e08..7ff4da0 100644 --- a/package.json +++ b/package.json @@ -1,11 +1,11 @@ { "name": "@pagerduty/pdjs", - "version": "2.0.1", + "version": "2.0.2", "description": "A new simple JavaScript wrapper for the PagerDuty API", "main": "build/src/index.js", "types": "build/src/index.d.ts", "files": [ - "build/src" + "build/src", ], "license": "Apache-2.0", "keywords": [ From 425e15da1f10f5bf94472bdc4e7aef76a0d552f7 Mon Sep 17 00:00:00 2001 From: Brett Willemsen Date: Tue, 24 Nov 2020 17:24:21 -0500 Subject: [PATCH 3/4] hanging comma. --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 7ff4da0..4003e03 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "main": "build/src/index.js", "types": "build/src/index.d.ts", "files": [ - "build/src", + "build/src" ], "license": "Apache-2.0", "keywords": [ From 72f100b9b85b9d8966a7caa71772786a4b762712 Mon Sep 17 00:00:00 2001 From: Brett Willemsen Date: Tue, 24 Nov 2020 17:25:23 -0500 Subject: [PATCH 4/4] Unhide build directory as we are publishing it to NPM. --- .gitignore | 1 - build/src/api.d.ts | 36 +++++ build/src/api.js | 128 +++++++++++++++++ build/src/api.js.map | 1 + build/src/api.test.d.ts | 1 + build/src/api.test.js | 241 ++++++++++++++++++++++++++++++++ build/src/api.test.js.map | 1 + build/src/common.d.ts | 10 ++ build/src/common.js | 87 ++++++++++++ build/src/common.js.map | 1 + build/src/convience.test.d.ts | 1 + build/src/convience.test.js | 30 ++++ build/src/convience.test.js.map | 1 + build/src/events.d.ts | 58 ++++++++ build/src/events.js | 43 ++++++ build/src/events.js.map | 1 + build/src/events.test.d.ts | 1 + build/src/events.test.js | 131 +++++++++++++++++ build/src/events.test.js.map | 1 + build/src/index.d.ts | 2 + build/src/index.js | 13 ++ build/src/index.js.map | 1 + build/src/retries.test.d.ts | 1 + build/src/retries.test.js | 52 +++++++ build/src/retries.test.js.map | 1 + 25 files changed, 843 insertions(+), 1 deletion(-) create mode 100644 build/src/api.d.ts create mode 100644 build/src/api.js create mode 100644 build/src/api.js.map create mode 100644 build/src/api.test.d.ts create mode 100644 build/src/api.test.js create mode 100644 build/src/api.test.js.map create mode 100644 build/src/common.d.ts create mode 100644 build/src/common.js create mode 100644 build/src/common.js.map create mode 100644 build/src/convience.test.d.ts create mode 100644 build/src/convience.test.js create mode 100644 build/src/convience.test.js.map create mode 100644 build/src/events.d.ts create mode 100644 build/src/events.js create mode 100644 build/src/events.js.map create mode 100644 build/src/events.test.d.ts create mode 100644 build/src/events.test.js create mode 100644 build/src/events.test.js.map create mode 100644 build/src/index.d.ts create mode 100644 build/src/index.js create mode 100644 build/src/index.js.map create mode 100644 build/src/retries.test.d.ts create mode 100644 build/src/retries.test.js create mode 100644 build/src/retries.test.js.map diff --git a/.gitignore b/.gitignore index dd87e2d..3c3629e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1 @@ node_modules -build diff --git a/build/src/api.d.ts b/build/src/api.d.ts new file mode 100644 index 0000000..d3541a4 --- /dev/null +++ b/build/src/api.d.ts @@ -0,0 +1,36 @@ +import { RequestOptions } from './common'; +export interface ShorthandCall { + (res: string, apiParameters?: Partial): APIPromise; +} +export interface PartialCall { + (apiParameters: APIParameters): APIPromise; + (apiParameters: Partial): PartialCall; + get: ShorthandCall; + post: ShorthandCall; + put: ShorthandCall; + patch: ShorthandCall; + delete: ShorthandCall; + all: (apiParameters: APIParameters) => Promise; +} +export declare type APIParameters = RequestOptions & { + endpoint?: string; + url?: string; + data?: object; + token?: string; + server?: string; + version?: number; +} & ({ + endpoint: string; +} | { + url: string; +}); +export declare type APIPromise = Promise; +export interface APIResponse extends Response { + data: any; + resource: any; + response: Response; + next?: () => APIPromise; +} +export declare function api(apiParameters: APIParameters): APIPromise; +export declare function api(apiParameters: Partial): PartialCall; +export declare function all(apiParameters: APIParameters): Promise; diff --git a/build/src/api.js b/build/src/api.js new file mode 100644 index 0000000..9be8912 --- /dev/null +++ b/build/src/api.js @@ -0,0 +1,128 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.all = exports.api = void 0; +const common_1 = require("./common"); +function api(apiParameters) { + var _a; + // If the apiParameters don't include `endpoint` treat it as a partial + // application. + if (!apiParameters.endpoint && !apiParameters.url) { + return partialCall(apiParameters); + } + const { endpoint, server = 'api.pagerduty.com', token, url, version = 2, data, ...rest } = apiParameters; + const config = { + method: 'GET', + ...rest, + headers: { + Accept: `application/vnd.pagerduty+json;version=${version}`, + Authorization: `Token token=${token}`, + ...rest.headers, + }, + }; + // Allow `data` for `queryParameters` for requests without bodies. + if (isReadonlyRequest(config.method) && data) { + config.queryParameters = (_a = config.queryParameters) !== null && _a !== void 0 ? _a : data; + } + else { + config.body = JSON.stringify(data); + } + return apiRequest(url !== null && url !== void 0 ? url : `https://${server}/${endpoint.replace(/^\/+/, '')}`, config); +} +exports.api = api; +function all(apiParameters) { + return api(apiParameters).then(response => allInner([response])); +} +exports.all = all; +function allInner(responses) { + const response = responses[responses.length - 1]; + if (!response.next) { + return Promise.resolve(responses); + } + return response + .next() + .then(response => allInner(responses.concat([response]))); +} +function apiRequest(url, options) { + return common_1.request(url, options).then((response) => { + const apiResponse = response; + apiResponse.response = response; + const resource = resourceKey(url); + return response + .json() + .then((data) => { + apiResponse.next = nextFunc(url, options, data); + apiResponse.data = data; + apiResponse.resource = resource ? data[resource] : null; + return apiResponse; + }) + .catch(() => Promise.resolve(apiResponse)); + }); +} +function resourceKey(url) { + const resource = url.match(/.+.com\/(?[\w]+)/); + if (resource) { + return resource[1]; + } + return null; +} +function isReadonlyRequest(method) { + var _a; + return !['PUT', 'POST', 'DELETE', 'PATCH'].includes((_a = method.toUpperCase()) !== null && _a !== void 0 ? _a : 'GET'); +} +function isOffsetPagination(data) { + if (data.offset !== undefined) { + return true; + } + return false; +} +function isCursorPagination(data) { + if (data.cursor !== undefined) { + return true; + } + return false; +} +function nextFunc(url, options, data) { + if (isOffsetPagination(data)) { + if ((data === null || data === void 0 ? void 0 : data.more) && typeof data.offset !== undefined && data.limit) { + return () => apiRequest(url, { + ...options, + queryParameters: { + ...options.queryParameters, + limit: data.limit.toString(), + offset: (data.limit + data.offset).toString(), + }, + }); + } + } + else if (isCursorPagination(data)) { + if (data === null || data === void 0 ? void 0 : data.cursor) { + return () => apiRequest(url, { + ...options, + queryParameters: { + ...options.queryParameters, + cursor: data.cursor, + limit: data.limit.toString(), + }, + }); + } + } + return undefined; +} +function partialCall(apiParameters) { + const partialParameters = apiParameters; + const partial = ((apiParameters) => api({ ...partialParameters, ...apiParameters })); + const shorthand = (method) => (endpoint, shorthandParameters) => api({ + endpoint, + method, + ...partialParameters, + ...shorthandParameters, + }); + partial.get = shorthand('get'); + partial.post = shorthand('post'); + partial.put = shorthand('put'); + partial.patch = shorthand('patch'); + partial.delete = shorthand('delete'); + partial.all = (apiParameters) => all(apiParameters); + return partial; +} +//# sourceMappingURL=api.js.map \ No newline at end of file diff --git a/build/src/api.js.map b/build/src/api.js.map new file mode 100644 index 0000000..6394fc9 --- /dev/null +++ b/build/src/api.js.map @@ -0,0 +1 @@ +{"version":3,"file":"api.js","sourceRoot":"","sources":["../../src/api.ts"],"names":[],"mappings":";;;AAAA,qCAAiD;AAqCjD,SAAgB,GAAG,CACjB,aAAqC;;IAErC,sEAAsE;IACtE,eAAe;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M,EAAE,IAAI,CAAC,MAAO;oBACpB,KAAK,EAAE,IAAI,CAAC,KAAM,CAAC,QAAQ,EAAE;iBAC9B;aACF,CAAC,CAAC;SACN;KACF;IAED,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,SAAS,WAAW,CAAC,aAAqC;IACxD,MAAM,iBAAiB,GAAG,aAAa,CAAC;IACxC,MAAM,OAAO,GAAG,CAAC,CAAC,aAAqC,EAAE,EAAE,CACzD,GAAG,CAAC,EAAC,GAAG,iBAAiB,EAAE,GAAG,aAAa,EAAC,CAAC,CAAgB,CAAC;IAEhE,MAAM,SAAS,GAAG,CAAC,MAAc,EAAE,EAAE,CAAC,CACpC,QAAgB,EAChB,mBAA4C,EAChC,EAAE,CACd,GAAG,CAAC;QACF,QAAQ;QACR,MAAM;QACN,GAAG,iBAAiB;QACpB,GAAG,mBAAmB;KACvB,CAAe,CAAC;IAEnB,OAAO,CAAC,GAAG,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC;IAC/B,OAAO,CAAC,IAAI,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC;IACjC,OAAO,CAAC,GAAG,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC;IAC/B,OAAO,CAAC,KAAK,GAAG,SAAS,CAAC,OAAO,CAAC,CAAC;IACnC,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAC;IAErC,OAAO,CAAC,GAAG,GAAG,CAAC,aAA4B,EAAE,EAAE,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;IAEnE,OAAO,OAAO,CAAC;AACjB,CAAC"} \ No newline at end of file diff --git a/build/src/api.test.d.ts b/build/src/api.test.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/build/src/api.test.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/build/src/api.test.js b/build/src/api.test.js new file mode 100644 index 0000000..2f6076b --- /dev/null +++ b/build/src/api.test.js @@ -0,0 +1,241 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const nock = require("nock"); +const index_1 = require("./index"); +const EMPTY_BODY = { + incidents: [], + limit: 25, + offset: 0, + total: null, + more: false, +}; +test('API calls return JSON for basic API calls with server', async (done) => { + nock('https://api.pagerduty.com', { + reqheaders: { + Authorization: 'Token token=someToken1234567890', + 'User-Agent': header => header.startsWith('pdjs'), + }, + }) + .get('/incidents') + .reply(200, EMPTY_BODY); + const resp = await index_1.api({ + token: 'someToken1234567890', + server: 'api.pagerduty.com', + endpoint: 'incidents', + }); + expect(resp.url).toEqual('https://api.pagerduty.com/incidents'); + expect(resp.data).toEqual(EMPTY_BODY); + done(); +}); +test('API calls return JSON for basic API calls with url', async (done) => { + nock('https://api.pagerduty.com', { + reqheaders: { + Authorization: 'Token token=someToken1234567890', + 'User-Agent': header => header.startsWith('pdjs'), + }, + }) + .get('/incidents') + .reply(200, EMPTY_BODY); + const resp = await index_1.api({ + token: 'someToken1234567890', + url: 'https://api.pagerduty.com/incidents', + }); + expect(resp.url).toEqual('https://api.pagerduty.com/incidents'); + expect(resp.data).toEqual(EMPTY_BODY); + done(); +}); +test('API calls return JSON for basic API calls with endpoint', async (done) => { + nock('https://api.pagerduty.com', { + reqheaders: { + Authorization: 'Token token=someToken1234567890', + 'User-Agent': header => header.startsWith('pdjs'), + }, + }) + .get('/incidents') + .reply(200, EMPTY_BODY); + const resp = await index_1.api({ + token: 'someToken1234567890', + endpoint: 'incidents', + }); + expect(resp.url).toEqual('https://api.pagerduty.com/incidents'); + expect(resp.data).toEqual(EMPTY_BODY); + done(); +}); +test('API calls support partial application with url', async (done) => { + nock('https://api.pagerduty.com', { + reqheaders: { + Authorization: 'Token token=someToken1234567890', + 'User-Agent': header => header.startsWith('pdjs'), + }, + }) + .get('/incidents') + .reply(200, EMPTY_BODY); + const pd = index_1.api({ token: 'someToken1234567890' }); + const resp = await pd({ + url: 'https://api.pagerduty.com/incidents', + }); + expect(resp.url).toEqual('https://api.pagerduty.com/incidents'); + expect(resp.data).toEqual(EMPTY_BODY); + done(); +}); +test('API calls support partial application with convenience methods', async (done) => { + nock('https://api.pagerduty.com', { + reqheaders: { + Authorization: 'Token token=someToken1234567890', + 'User-Agent': header => header.startsWith('pdjs'), + }, + }) + .get('/incidents') + .reply(200, EMPTY_BODY); + const resp = await index_1.api({ token: 'someToken1234567890' }).get('/incidents'); + expect(resp.url).toEqual('https://api.pagerduty.com/incidents'); + expect(resp.data).toEqual(EMPTY_BODY); + done(); +}); +test('API calls use data in place of queryParameters when provided on GET requests', async (done) => { + nock('https://api.pagerduty.com') + .get('/incidents?sort_by=created_at&total=true') + .reply(200, EMPTY_BODY); + const resp = await index_1.api({ + token: 'someToken1234567890', + endpoint: '/incidents', + data: { sort_by: 'created_at', total: true }, + }); + expect(resp.url).toEqual('https://api.pagerduty.com/incidents?sort_by=created_at&total=true'); + expect(resp.data).toEqual(EMPTY_BODY); + done(); +}); +test('API calls populate resource field', async (done) => { + nock('https://api.pagerduty.com') + .get('/incidents') + .reply(200, { + incidents: ['one', 1, null], + limit: 25, + offset: 0, + total: null, + more: false, + }); + const resp = await index_1.api({ + token: 'someToken1234567890', + endpoint: '/incidents', + }); + expect(resp.resource).toEqual(['one', 1, null]); + done(); +}); +test('API explodes list based parameters properly', async (done) => { + nock('https://api.pagerduty.com') + .get('/incidents?additional_fields[]=one&additional_fields[]=two&additional_fields[]=three') + .reply(200, { + incidents: ['one', 1, null], + limit: 25, + offset: 0, + total: null, + more: false, + }); + const resp = await index_1.api({ + token: 'someToken1234567890', + endpoint: '/incidents', + queryParameters: { + 'additional_fields[]': ['one', 'two', 'three'], + }, + }); + expect(resp.url).toEqual('https://api.pagerduty.com/incidents?additional_fields%5B%5D=one&additional_fields%5B%5D=two&additional_fields%5B%5D=three'); + done(); +}); +test('API `all` calls for offset should generate requests until no more results', async (done) => { + const body = { + incidents: [], + limit: 1, + offset: 0, + total: null, + more: true, + }; + nock('https://api.pagerduty.com').get('/incidents?limit=1').reply(200, body); + nock('https://api.pagerduty.com') + .get('/incidents?limit=1&offset=1') + .reply(200, { + ...body, + offset: 1, + }); + nock('https://api.pagerduty.com') + .get('/incidents?limit=1&offset=2') + .reply(200, { + ...body, + offset: 2, + more: false, + }); + const resps = await index_1.all({ + token: 'someToken1234567890', + endpoint: '/incidents', + data: { limit: 1 }, + }); + expect(resps.length).toEqual(3); + expect(resps[0].data.offset).toEqual(0); + expect(resps[1].data.offset).toEqual(1); + expect(resps[2].data.offset).toEqual(2); + done(); +}); +test('API `all` calls for cursor should generate requests until no more results', async (done) => { + const body = { + incidents: [], + limit: 1, + cursor: 'one', + }; + nock('https://api.pagerduty.com').get('/incidents?limit=1').reply(200, body); + nock('https://api.pagerduty.com') + .get('/incidents?limit=1&cursor=one') + .reply(200, { + ...body, + cursor: 'two', + }); + nock('https://api.pagerduty.com') + .get('/incidents?limit=1&cursor=two') + .reply(200, { + ...body, + cursor: null, + }); + const responses = await index_1.all({ + token: 'someToken1234567890', + endpoint: '/incidents', + data: { limit: 1 }, + }); + expect(responses.length).toEqual(3); + expect(responses[0].data.cursor).toEqual('one'); + expect(responses[1].data.cursor).toEqual('two'); + expect(responses[2].data.offset).toEqual(undefined); + done(); +}); +test('API `all` calls on partials should generate requests until no more results', async (done) => { + const body = { + incidents: [], + limit: 1, + offset: 0, + total: null, + more: true, + }; + nock('https://api.pagerduty.com').get('/incidents?limit=1').reply(200, body); + nock('https://api.pagerduty.com') + .get('/incidents?limit=1&offset=1') + .reply(200, { + ...body, + offset: 1, + }); + nock('https://api.pagerduty.com') + .get('/incidents?limit=1&offset=2') + .reply(200, { + ...body, + offset: 2, + more: false, + }); + const pd = index_1.api({ token: 'someToken1234567890' }); + const resps = await pd.all({ + endpoint: '/incidents', + data: { limit: 1 }, + }); + expect(resps.length).toEqual(3); + expect(resps[0].data.offset).toEqual(0); + expect(resps[1].data.offset).toEqual(1); + expect(resps[2].data.offset).toEqual(2); + done(); +}); +//# sourceMappingURL=api.test.js.map \ No newline at end of file diff --git a/build/src/api.test.js.map b/build/src/api.test.js.map new file mode 100644 index 0000000..8816cc6 --- /dev/null +++ b/build/src/api.test.js.map @@ -0,0 +1 @@ +{"version":3,"file":"api.test.js","sourceRoot":"","sources":["../../src/api.test.ts"],"names":[],"mappings":";;AAAA,6BAA8B;AAC9B,mCAAiC;AAEjC,MAAM,UAAU,GAAG;IACjB,SAAS,EAAE,EAAE;IACb,KAAK,EAAE,EAAE;IACT,MAAM,EAAE,CAAC;IACT,KAAK,EAAE,IAAI;IACX,IAAI,EAAE,KAAK;CACZ,CAAC;AAEF,IAAI,CAAC,uDAAuD,EAAE,KAAK,EAAC,IAAI,EAAC,EAAE;IACzE,IAAI,CAAC,2BAA2B,EAAE;QAChC,UAAU,EAAE;YACV,aAAa,EAAE,iCAAiC;YAChD,YAAY,EAAE,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC;SAClD;KACF,CAAC;SACC,GAAG,CAAC,YAAY,CAAC;SACjB,KAAK,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC;IAE1B,MAAM,IAAI,GAAG,MAAM,WAAG,CAAC;QACrB,KAAK,EAAE,qBAAqB;QAC5B,MAAM,EAAE,mBAAmB;QAC3B,QAAQ,EAAE,WAAW;KACtB,CAAC,CAAC;IAEH,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,qCAAqC,CAAC,CAAC;IAChE,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;IACtC,IAAI,EAAE,CAAC;AACT,CAAC,CAAC,CAAC;AAEH,IAAI,CAAC,oDAAoD,EAAE,KAAK,EAAC,IAAI,EAAC,EAAE;IACtE,IAAI,CAAC,2BAA2B,EAAE;QAChC,UAAU,EAAE;YACV,aAAa,EAAE,iCAAiC;YAChD,YAAY,EAAE,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC;SAClD;KACF,CAAC;SACC,GAAG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K,GAAG,MAAM,EAAE,CAAC,GAAG,CAAC;QACzB,QAAQ,EAAE,YAAY;QACtB,IAAI,EAAE,EAAC,KAAK,EAAE,CAAC,EAAC;KACjB,CAAC,CAAC;IAEH,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IAChC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IACxC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IACxC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IACxC,IAAI,EAAE,CAAC;AACT,CAAC,CAAC,CAAC"} \ No newline at end of file diff --git a/build/src/common.d.ts b/build/src/common.d.ts new file mode 100644 index 0000000..284c354 --- /dev/null +++ b/build/src/common.d.ts @@ -0,0 +1,10 @@ +declare type QueryParameter = Record>; +export interface RequestOptions extends RequestInit { + queryParameters?: QueryParameter; + retryCount?: number; + requestTimeout?: number; + retryTimeout?: number; + timeout?: number; +} +export declare function request(url: string | URL, options?: RequestOptions): Promise; +export {}; diff --git a/build/src/common.js b/build/src/common.js new file mode 100644 index 0000000..4ed18b0 --- /dev/null +++ b/build/src/common.js @@ -0,0 +1,87 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.request = void 0; +/* LEGACY-BROWSER-SUPPORT-START */ +const cross_fetch_1 = require("cross-fetch"); +const cjs_ponyfill_1 = require("abortcontroller-polyfill/dist/cjs-ponyfill"); +const browser_or_node_1 = require("browser-or-node"); +/* LEGACY-BROWSER-SUPPORT-END */ +const VERSION = '2.0.0'; +function request(url, options = {}) { + const { queryParameters, requestTimeout = 30000, ...rest } = options; + url = new URL(url.toString()); + url = applyParameters(url, queryParameters); + options = applyTimeout(options, requestTimeout); + return fetch_retry(url.toString(), 3, { + ...rest, + headers: new cross_fetch_1.Headers({ + 'Content-Type': 'application/json; charset=utf-8', + /* LEGACY-BROWSER-SUPPORT-START */ + ...userAgentHeader(), + /* LEGACY-BROWSER-SUPPORT-END */ + ...rest.headers, + }), + }); +} +exports.request = request; +function fetch_retry(url, retries, options) { + return new Promise((resolve, reject) => { + cross_fetch_1.default(url, options).then(response => { + // We don't want to `reject` when retries have finished + // Instead simply stop trying and return. + if (retries === 0) + return resolve(response); + if (response.status === 429) { + const { retryTimeout = 20000 } = options; + retryTimeoutPromise(retryTimeout).then(() => { + fetch_retry(url, retries - 1, options) + .then(resolve) + .catch(reject); + }); + } + else { + resolve(response); + } + }); + }); +} +const retryTimeoutPromise = (milliseconds) => { + return new Promise(resolve => setTimeout(resolve, milliseconds)); +}; +function userAgentHeader() { + if (browser_or_node_1.isBrowser) + return {}; + return { + 'User-Agent': `pdjs/${VERSION} (${process.version}/${process.platform})`, + }; +} +function applyParameters(url, queryParameters) { + if (!queryParameters) + return url; + const combinedParameters = url.searchParams; + for (const key of Object.keys(queryParameters)) { + const parameter = queryParameters[key]; + if (Array.isArray(parameter)) { + // Support for array based keys like `additional_fields[]` + parameter.forEach(item => { + combinedParameters.append(key, item); + }); + } + else { + combinedParameters.append(key, parameter); + } + } + url.search = combinedParameters.toString(); + return url; +} +function applyTimeout(init, timeout) { + if (!timeout) + return init; + const controller = new cjs_ponyfill_1.AbortController(); + setTimeout(() => controller.abort(), timeout); + return { + ...init, + signal: controller.signal, + }; +} +//# sourceMappingURL=common.js.map \ No newline at end of file diff --git a/build/src/common.js.map b/build/src/common.js.map new file mode 100644 index 0000000..851a97e --- /dev/null +++ b/build/src/common.js.map @@ -0,0 +1 @@ +{"version":3,"file":"common.js","sourceRoot":"","sources":["../../src/common.ts"],"names":[],"mappings":";;;AAAA,kCAAkC;AAClC,6CAA2C;AAC3C,6EAA2E;AAC3E,qDA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AAS,YAAY,CAAC,IAAoB,EAAE,OAAgB;IAC1D,IAAI,CAAC,OAAO;QAAE,OAAO,IAAI,CAAC;IAE1B,MAAM,UAAU,GAAG,IAAI,8BAAe,EAAE,CAAC;IACzC,UAAU,CAAC,GAAG,EAAE,CAAC,UAAU,CAAC,KAAK,EAAE,EAAE,OAAO,CAAC,CAAC;IAE9C,OAAO;QACL,GAAG,IAAI;QACP,MAAM,EAAE,UAAU,CAAC,MAAM;KAC1B,CAAC;AACJ,CAAC"} \ No newline at end of file diff --git a/build/src/convience.test.d.ts b/build/src/convience.test.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/build/src/convience.test.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/build/src/convience.test.js b/build/src/convience.test.js new file mode 100644 index 0000000..c6af390 --- /dev/null +++ b/build/src/convience.test.js @@ -0,0 +1,30 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const nock = require("nock"); +const index_1 = require("./index"); +const EMPTY_BODY = { + incidents: [], + limit: 25, + offset: 0, + total: null, + more: false, +}; +test('Blah blah test retry', async (done) => { + const body = { + incidents: [], + limit: 1, + offset: 0, + total: null, + more: true, + }; + nock('https://api.pagerduty.com') + .get('/incidents') + .reply(429, body) + .get('/incidents') + .reply(200, body); + const pd = index_1.api({ token: 'someToken1234567890' }); + const resps = await pd.get('/incidents'); + expect(resps.data).toEqual(body); + done(); +}); +//# sourceMappingURL=convience.test.js.map \ No newline at end of file diff --git a/build/src/convience.test.js.map b/build/src/convience.test.js.map new file mode 100644 index 0000000..7943368 --- /dev/null +++ b/build/src/convience.test.js.map @@ -0,0 +1 @@ +{"version":3,"file":"convience.test.js","sourceRoot":"","sources":["../../src/convience.test.ts"],"names":[],"mappings":";;AAAA,6BAA8B;AAC9B,mCAAiC;AAEjC,MAAM,UAAU,GAAG;IACjB,SAAS,EAAE,EAAE;IACb,KAAK,EAAE,EAAE;IACT,MAAM,EAAE,CAAC;IACT,KAAK,EAAE,IAAI;IACX,IAAI,EAAE,KAAK;CACZ,CAAC;AAEF,IAAI,CAAC,sBAAsB,EAAE,KAAK,EAAC,IAAI,EAAC,EAAE;IACxC,MAAM,IAAI,GAAG;QACX,SAAS,EAAE,EAAE;QACb,KAAK,EAAE,CAAC;QACR,MAAM,EAAE,CAAC;QACT,KAAK,EAAE,IAAI;QACX,IAAI,EAAE,IAAI;KACX,CAAC;IAEF,IAAI,CAAC,2BAA2B,CAAC;SAC9B,GAAG,CAAC,YAAY,CAAC;SACjB,KAAK,CAAC,GAAG,EAAE,IAAI,CAAC;SAChB,GAAG,CAAC,YAAY,CAAC;SACjB,KAAK,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;IAEpB,MAAM,EAAE,GAAG,WAAG,CAAC,EAAC,KAAK,EAAE,qBAAqB,EAAC,CAAC,CAAC;IAE/C,MAAM,KAAK,GAAG,MAAM,EAAE,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;IAEzC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IACjC,IAAI,EAAE,CAAC;AACT,CAAC,CAAC,CAAC"} \ No newline at end of file diff --git a/build/src/events.d.ts b/build/src/events.d.ts new file mode 100644 index 0000000..aa32027 --- /dev/null +++ b/build/src/events.d.ts @@ -0,0 +1,58 @@ +import { RequestOptions } from './common'; +export declare type Action = 'trigger' | 'acknowledge' | 'resolve'; +export declare type EventPromise = Promise; +export interface EventResponse extends Response { + data: any; + response: Response; +} +export declare type Severity = 'critical' | 'error' | 'warning' | 'info'; +export interface Image { + src: string; + href?: string; + alt?: string; +} +export interface Link { + href: string; + text?: string; +} +export interface EventPayloadV2 { + routing_key: string; + event_action: Action; + dedup_key?: string; + payload: { + summary: string; + source: string; + severity: Severity; + timestamp?: string; + component?: string; + group?: string; + class?: string; + custom_details?: object; + }; + images?: Array; + links?: Array; +} +export interface EventParameters extends RequestOptions { + data: EventPayloadV2; + type?: string; + server?: string; +} +export interface ChangePayload { + routing_key: string; + payload: { + summary: string; + source?: string; + timestamp: string; + custom_details: object; + }; + links: Array; +} +export interface ChangeParameters extends RequestOptions { + data: ChangePayload; + server?: string; +} +export declare function event(eventParameters: EventParameters): EventPromise; +export declare const trigger: (eventParameters: EventParameters) => EventPromise; +export declare const acknowledge: (eventParameters: EventParameters) => EventPromise; +export declare const resolve: (eventParameters: EventParameters) => EventPromise; +export declare const change: (eventParameters: EventParameters) => EventPromise; diff --git a/build/src/events.js b/build/src/events.js new file mode 100644 index 0000000..3fa043b --- /dev/null +++ b/build/src/events.js @@ -0,0 +1,43 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.change = exports.resolve = exports.acknowledge = exports.trigger = exports.event = void 0; +const common_1 = require("./common"); +function event(eventParameters) { + const { server = 'events.pagerduty.com', type = 'event', data, ...config } = eventParameters; + let url = `https://${server}/v2/enqueue`; + if (type === 'change') { + url = `https://${server}/v2/change/enqueue`; + } + return eventFetch(url, { + method: 'POST', + body: JSON.stringify(data), + ...config, + }); +} +exports.event = event; +const shorthand = (action) => (eventParameters) => { + const typeField = 'event_action'; + return event({ + ...eventParameters, + data: { + ...eventParameters.data, + [typeField]: action, + }, + }); +}; +exports.trigger = shorthand('trigger'); +exports.acknowledge = shorthand('acknowledge'); +exports.resolve = shorthand('resolve'); +const change = (eventParameters) => event({ ...eventParameters, type: 'change' }); +exports.change = change; +function eventFetch(url, options) { + return common_1.request(url, options).then((response) => { + const apiResponse = response; + return response.json().then((data) => { + apiResponse.data = data; + apiResponse.response = response; + return apiResponse; + }); + }); +} +//# sourceMappingURL=events.js.map \ No newline at end of file diff --git a/build/src/events.js.map b/build/src/events.js.map new file mode 100644 index 0000000..8755162 --- /dev/null +++ b/build/src/events.js.map @@ -0,0 +1 @@ +{"version":3,"file":"events.js","sourceRoot":"","sources":["../../src/events.ts"],"names":[],"mappings":";;;AAAA,qCAAiD;AA+DjD,SAAgB,KAAK,CAAC,eAAgC;IACpD,MAAM,EACJ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IAAI,CACzB,CAAC,IAAI,EAAiB,EAAE;YACtB,WAAW,CAAC,IAAI,GAAG,IAAI,CAAC;YACxB,WAAW,CAAC,QAAQ,GAAG,QAAQ,CAAC;YAChC,OAAO,WAAW,CAAC;QACrB,CAAC,CACF,CAAC;IACJ,CAAC,CACF,CAAC;AACJ,CAAC"} \ No newline at end of file diff --git a/build/src/events.test.d.ts b/build/src/events.test.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/build/src/events.test.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/build/src/events.test.js b/build/src/events.test.js new file mode 100644 index 0000000..54bcc83 --- /dev/null +++ b/build/src/events.test.js @@ -0,0 +1,131 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const nock = require("nock"); +const index_1 = require("./index"); +const eventPayloadV2 = { + data: { + routing_key: 'someRoutingKeybfa2a710673888f520', + event_action: 'trigger', + dedup_key: 'test_incident_2_88f520', + payload: { + summary: 'Test Event V2', + source: 'test-source', + severity: 'error', + }, + }, +}; +test('Events API properly passes Events V2 requests', async (done) => { + const body = { + data: { + status: 'success', + message: 'Event processed', + dedup_key: 'test_incident_2_88f520', + }, + }; + nock('https://events.pagerduty.com', { + reqheaders: { + 'User-Agent': header => header.startsWith('pdjs'), + }, + }) + .post('/v2/enqueue') + .reply(200, body); + const response = await index_1.event(eventPayloadV2); + expect(response.url).toEqual('https://events.pagerduty.com/v2/enqueue'); + expect(response.data).toEqual(body); + done(); +}); +test('Events API properly passes Change Events requests', async (done) => { + const body = { + data: { + status: 'success', + message: 'Event processed', + dedup_key: 'test_incident_2_88f520', + }, + }; + nock('https://events.pagerduty.com', { + reqheaders: { + 'User-Agent': header => header.startsWith('pdjs'), + }, + }) + .post('/v2/change/enqueue') + .reply(200, body); + const response = await index_1.change(eventPayloadV2); + expect(response.url).toEqual('https://events.pagerduty.com/v2/change/enqueue'); + expect(response.data).toEqual(body); + done(); +}); +test('Events API properly passes Events V2 requests with images/links/details', async (done) => { + const body = { + data: { + status: 'success', + message: 'Event processed', + dedup_key: 'test_incident_2_88f520', + }, + }; + nock('https://events.pagerduty.com', { + reqheaders: { + 'User-Agent': header => header.startsWith('pdjs'), + }, + }) + .post('/v2/enqueue') + .reply(200, body); + const response = await index_1.event({ + data: { + routing_key: 'someRoutingKeybfa2a710673888f520', + event_action: 'trigger', + dedup_key: 'test_incident_3_88f520', + payload: { + summary: 'Test Event V2', + source: 'test-source', + severity: 'error', + custom_details: { + foo: 'bar', + }, + }, + images: [ + { + src: 'foo.jpg', + }, + ], + links: [ + { + href: 'https://www.pagerduty.com', + }, + ], + }, + }); + expect(response.url).toEqual('https://events.pagerduty.com/v2/enqueue'); + expect(response.data).toEqual(body); + done(); +}); +test('Events API shorthands should send corresponding events', async (done) => { + const body = { + data: { + status: 'success', + message: 'Event processed', + dedup_key: 'test_incident_2_88f520', + }, + }; + nock('https://events.pagerduty.com', { + reqheaders: { + 'User-Agent': header => header.startsWith('pdjs'), + }, + }) + .post('/v2/enqueue') + .reply(200, body) + .post('/v2/enqueue') + .reply(200, body) + .post('/v2/enqueue') + .reply(200, body); + let response = await index_1.acknowledge(eventPayloadV2); + expect(response.url).toEqual('https://events.pagerduty.com/v2/enqueue'); + expect(response.data).toEqual(body); + response = await index_1.resolve(eventPayloadV2); + expect(response.url).toEqual('https://events.pagerduty.com/v2/enqueue'); + expect(response.data).toEqual(body); + response = await index_1.trigger(eventPayloadV2); + expect(response.url).toEqual('https://events.pagerduty.com/v2/enqueue'); + expect(response.data).toEqual(body); + done(); +}); +//# sourceMappingURL=events.test.js.map \ No newline at end of file diff --git a/build/src/events.test.js.map b/build/src/events.test.js.map new file mode 100644 index 0000000..de38f1f --- /dev/null +++ b/build/src/events.test.js.map @@ -0,0 +1 @@ +{"version":3,"file":"events.test.js","sourceRoot":"","sources":["../../src/events.test.ts"],"names":[],"mappings":";;AAAA,6BAA8B;AAE9B,mCAAqE;AAErE,MAAM,cAAc,GAAG;IACrB,IAAI,EAAE;QAC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C,CAAC;IAEzC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,yCAAyC,CAAC,CAAC;IACxE,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IACpC,IAAI,EAAE,CAAC;AACT,CAAC,CAAC,CAAC"} \ No newline at end of file diff --git a/build/src/index.d.ts b/build/src/index.d.ts new file mode 100644 index 0000000..bcd06ae --- /dev/null +++ b/build/src/index.d.ts @@ -0,0 +1,2 @@ +export { all, api } from './api'; +export { event, change, trigger, acknowledge, resolve } from './events'; diff --git a/build/src/index.js b/build/src/index.js new file mode 100644 index 0000000..07211ef --- /dev/null +++ b/build/src/index.js @@ -0,0 +1,13 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.resolve = exports.acknowledge = exports.trigger = exports.change = exports.event = exports.api = exports.all = void 0; +var api_1 = require("./api"); +Object.defineProperty(exports, "all", { enumerable: true, get: function () { return api_1.all; } }); +Object.defineProperty(exports, "api", { enumerable: true, get: function () { return api_1.api; } }); +var events_1 = require("./events"); +Object.defineProperty(exports, "event", { enumerable: true, get: function () { return events_1.event; } }); +Object.defineProperty(exports, "change", { enumerable: true, get: function () { return events_1.change; } }); +Object.defineProperty(exports, "trigger", { enumerable: true, get: function () { return events_1.trigger; } }); +Object.defineProperty(exports, "acknowledge", { enumerable: true, get: function () { return events_1.acknowledge; } }); +Object.defineProperty(exports, "resolve", { enumerable: true, get: function () { return events_1.resolve; } }); +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/build/src/index.js.map b/build/src/index.js.map new file mode 100644 index 0000000..a05d596 --- /dev/null +++ b/build/src/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAA,6BAA+B;AAAvB,0FAAA,GAAG,OAAA;AAAE,0FAAA,GAAG,OAAA;AAChB,mCAAsE;AAA9D,+FAAA,KAAK,OAAA;AAAE,gGAAA,MAAM,OAAA;AAAE,iGAAA,OAAO,OAAA;AAAE,qGAAA,WAAW,OAAA;AAAE,iGAAA,OAAO,OAAA"} \ No newline at end of file diff --git a/build/src/retries.test.d.ts b/build/src/retries.test.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/build/src/retries.test.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/build/src/retries.test.js b/build/src/retries.test.js new file mode 100644 index 0000000..a5291df --- /dev/null +++ b/build/src/retries.test.js @@ -0,0 +1,52 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const nock = require("nock"); +const index_1 = require("./index"); +test('API request should return after 3 rate limited requests', async (done) => { + const body = { + incidents: [], + limit: 1, + offset: 0, + total: null, + more: true, + }; + nock('https://api.pagerduty.com') + .get('/incidents') + .reply(429, body) + .get('/incidents') + .reply(429, body) + .get('/incidents') + .reply(429, body) + .get('/incidents') + .reply(429, body); + const response = await index_1.api({ + token: 'someToken1234567890', + endpoint: '/incidents', + retryTimeout: 20, + }); + expect(response.response.status).toEqual(429); + done(); +}); +test('API should return data after getting rate limited once.', async (done) => { + const body = { + incidents: [], + limit: 1, + offset: 0, + total: null, + more: true, + }; + nock('https://api.pagerduty.com') + .get('/incidents') + .reply(429, body) + .get('/incidents') + .reply(200, body); + const response = await index_1.api({ + token: 'someToken1234567890', + endpoint: '/incidents', + retryTimeout: 20, + }); + expect(response.response.status).toEqual(200); + expect(response.data).toEqual(body); + done(); +}); +//# sourceMappingURL=retries.test.js.map \ No newline at end of file diff --git a/build/src/retries.test.js.map b/build/src/retries.test.js.map new file mode 100644 index 0000000..f4bcac1 --- /dev/null +++ b/build/src/retries.test.js.map @@ -0,0 +1 @@ +{"version":3,"file":"retries.test.js","sourceRoot":"","sources":["../../src/retries.test.ts"],"names":[],"mappings":";;AAAA,6BAA8B;AAC9B,mCAA4B;AAE5B,IAAI,CAAC,yDAAyD,EAAE,KAAK,EAAC,IAAI,EAAC,EAAE;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