@adobe/reactor-sdk
Version:
JavaScript SDK for the Reactor API
1 lines • 15.5 kB
JavaScript
(()=>{function t(t,e,r,n){Object.defineProperty(t,e,{get:r,set:n,enumerable:!0,configurable:!0})}var e={};Object.defineProperty(e,"__esModule",{value:!0,configurable:!0}),t(e,"default",()=>ex);let r="1.2.0";var n={};function i(t,e){return this.post(`/properties/${t}/hosts`,{data:e})}function s(t){return this.delete(`/hosts/${t}`)}function o(t){return this.get(`/hosts/${t}`)}function a(t){return this.get(`/hosts/${t}/property`)}function u(t,e){return this.get(`/properties/${t}/hosts`,e)}function l(t){return this.patch(`/hosts/${t.id}`,{data:t})}t(n,"createHost",()=>i),t(n,"deleteHost",()=>s),t(n,"getHost",()=>o),t(n,"getPropertyForHost",()=>a),t(n,"listHostsForProperty",()=>u),t(n,"updateHost",()=>l);var c={};function p(t){return this.get(`/audit_events/${t}`)}function h(t){return this.get("/audit_events",t)}t(c,"getAuditEvent",()=>p),t(c,"listAuditEvents",()=>h);var d={};function g(t){return this.post(`/libraries/${t}/builds`)}function f(t){return this.get(`/builds/${t}`)}function $(t){return this.get(`/builds/${t}/environment`)}function b(t){return this.get(`/builds/${t}/library`)}function m(t){return this.get(`/builds/${t}/data_elements`)}function y(t,e){return this.get(`/libraries/${t}/builds`,e)}function v(t,e){return this.get(`/builds/${t}/extensions`,e)}function E(t,e){return this.get(`/builds/${t}/rules`,e)}t(d,"createBuild",()=>g),t(d,"getBuild",()=>f),t(d,"getEnvironmentForBuild",()=>$),t(d,"getLibraryForBuild",()=>b),t(d,"getDataElementsForBuild",()=>m),t(d,"listBuildsForLibrary",()=>y),t(d,"listExtensionsForBuild",()=>v),t(d,"listRulesForBuild",()=>E);var F={};function x(t,e){return this.post(`/properties/${t}/callbacks`,{data:e})}function R(t){return this.delete(`/callbacks/${t}`)}function L(t){return this.get(`/callbacks/${t}`)}function _(t){return this.get(`/callbacks/${t}/property`)}function P(t,e){return this.get(`/properties/${t}/callbacks`,e)}function k(t){return this.patch(`/callbacks/${t.id}`,{data:t})}t(F,"createCallback",()=>x),t(F,"deleteCallback",()=>R),t(F,"getCallback",()=>L),t(F,"getPropertyForCallback",()=>_),t(F,"listCallbacksForProperty",()=>P),t(F,"updateCallback",()=>k);var D={};function C(t){return this.get(`/companies/${t}`)}function B(t){return this.get("/companies",t)}t(D,"getCompany",()=>C),t(D,"listCompanies",()=>B);var T={};function w(t,e){return this.post(`/properties/${t}/data_elements`,{data:e})}function H(t){return this.delete(`/data_elements/${t}`)}function A(t){return this.get(`/data_elements/${t}`)}function O(t){return this.get(`/data_elements/${t}/extension`)}function U(t){return this.get(`/data_elements/${t}/property`)}function j(t){return this.get(`/data_elements/${t}/origin`)}function q(t,e){return this.get(`/properties/${t}/data_elements`,e)}function S(t,e){return this.get(`/data_elements/${t}/libraries`,e)}function N(t){return this.get(`/data_elements/${t}/revisions`)}function M(t){return this.patch(`/data_elements/${t}`,this.createReviseBody("data_elements",t))}function I(t){return this.patch(`/data_elements/${t.id}`,{data:t})}function K(t,e){return this.post(`/data_elements/${t}/notes`,{data:e})}t(T,"createDataElement",()=>w),t(T,"deleteDataElement",()=>H),t(T,"getDataElement",()=>A),t(T,"getExtensionForDataElement",()=>O),t(T,"getPropertyForDataElement",()=>U),t(T,"getOriginForDataElement",()=>j),t(T,"listDataElementsForProperty",()=>q),t(T,"listLibrariesForDataElement",()=>S),t(T,"listRevisionsForDataElement",()=>N),t(T,"reviseDataElement",()=>M),t(T,"updateDataElement",()=>I),t(T,"createNoteForDataElement",()=>K);var z={};function G(t,e){return this.post(`/properties/${t}/environments`,{data:e})}function J(t){return this.delete(`/environments/${t}`)}function W(t){return this.get(`/environments/${t}`)}function X(t){return this.get(`/environments/${t}/host`)}function Q(t){return this.get(`/environments/${t}/relationships/host`)}function V(t){return this.get(`/environments/${t}/library`)}function Y(t){return this.get(`/environments/${t}/property`)}function Z(t,e){return this.get(`/environments/${t}/builds`,e)}function tt(t,e){return this.get(`/properties/${t}/environments`,e)}function te(t){return this.patch(`/environments/${t.id}`,{data:t})}t(z,"createEnvironment",()=>G),t(z,"deleteEnvironment",()=>J),t(z,"getEnvironment",()=>W),t(z,"getHostForEnvironment",()=>X),t(z,"getHostRelationshipForEnvironment",()=>Q),t(z,"getLibraryForEnvironment",()=>V),t(z,"getPropertyForEnvironment",()=>Y),t(z,"listBuildsForEnvironment",()=>Z),t(z,"listEnvironmentsForProperty",()=>tt),t(z,"updateEnvironment",()=>te);var tr={};function tn(t){return this.sendMultipartFile("POST","/extension_packages",t)}function ti(t){return this.get(`/extension_packages/${t}`)}function ts(t){return this.get("/extension_packages",t)}function to(t){return this.patch(`/extension_packages/${t}`,{attributes:{},meta:{action:"release_private"},id:t,type:"extension_packages"})}function ta(t,e){let r=`/extension_packages/${t}`;return this.sendMultipartFile("PATCH",r,e)}t(tr,"createExtensionPackage",()=>tn),t(tr,"getExtensionPackage",()=>ti),t(tr,"listExtensionPackages",()=>ts),t(tr,"privateReleaseExtensionPackage",()=>to),t(tr,"updateExtensionPackage",()=>ta);var tu={};function tl(t,e){return this.post(`/properties/${t}/extensions`,{data:e})}function tc(t){return this.delete(`/extensions/${t}`)}function tp(t){return this.get(`/extensions/${t}`)}function th(t){return this.get(`/extensions/${t}/extension_package`)}function td(t){return this.get(`/extensions/${t}/origin`)}function tg(t){return this.get(`/extensions/${t}/property`)}function tf(t,e){return this.get(`/properties/${t}/extensions`,e)}function t$(t){return this.get(`/extensions/${t}/libraries`)}function tb(t){return this.get(`/extensions/${t}/revisions`)}function tm(t){return this.patch(`/extensions/${t}`,this.createReviseBody("extensions",t))}function ty(t,e){return this.patch(`/extensions/${t}`,{data:e})}function tv(t,e){return this.post(`/extensions/${t}/notes`,{data:e})}t(tu,"createExtension",()=>tl),t(tu,"deleteExtension",()=>tc),t(tu,"getExtension",()=>tp),t(tu,"getExtensionPackageForExtension",()=>th),t(tu,"getOriginForExtension",()=>td),t(tu,"getPropertyForExtension",()=>tg),t(tu,"listExtensionsForProperty",()=>tf),t(tu,"listLibrariesForExtension",()=>t$),t(tu,"listRevisionsForExtension",()=>tb),t(tu,"reviseExtension",()=>tm),t(tu,"updateExtension",()=>ty),t(tu,"createNoteForExtension",()=>tv);var tE={};function tF(){return this.get("/heartbeat")}t(tE,"heartbeat",()=>tF);var tx={};function tR(t,e){return this.post(`/libraries/${t}/relationships/data_elements`,{data:e})}function tL(t,e){return this.post(`/libraries/${t}/relationships/extensions`,{data:e})}function t_(t,e){return this.post(`/libraries/${t}/relationships/rules`,{data:e})}function tP(t,e){return this.post(`/properties/${t}/libraries`,{data:e})}function tk(t){return this.delete(`/libraries/${t}`)}function tD(t){return this.get(`/libraries/${t}/environment`)}function tC(t){return this.get(`/libraries/${t}/relationships/environment`)}function tB(t){return this.get(`/libraries/${t}`)}function tT(t){return this.get(`/libraries/${t}/property`)}function tw(t){return this.get(`/libraries/${t}/upstream_library`)}function tH(t,e){return this.get(`/libraries/${t}/data_elements`,e)}function tA(t,e){return this.get(`/libraries/${t}/relationships/data_elements`,e)}function tO(t,e){return this.get(`/libraries/${t}/extensions`,e)}function tU(t,e){return this.get(`/libraries/${t}/relationships/extensions`,e)}function tj(t,e){return this.get(`/properties/${t}/libraries`,e)}function tq(t,e){return this.get(`/libraries/${t}/relationships/rules`,e)}function tS(t,e){return this.get(`/libraries/${t}/rules`,e)}function tN(t){return this.createBuild(t)}function tM(t,e){return this.delete(`/libraries/${t}/relationships/data_elements`,{data:e})}function tI(t,e){return this.delete(`/libraries/${t}/relationships/extensions`,{data:e})}function tK(t,e){return this.delete(`/libraries/${t}/relationships/environment`,{data:{id:e,type:"environments"},id:t})}function tz(t,e){return this.delete(`/libraries/${t}/relationships/rules`,{data:e})}function tG(t,e){return this.patch(`/libraries/${t}/relationships/extensions`,{data:e})}function tJ(t,e){return this.patch(`/libraries/${t}/relationships/data_elements`,{data:e})}function tW(t,e){return this.patch(`/libraries/${t}/relationships/rules`,{data:e})}function tX(t,e){return this.patch(`/libraries/${t}/relationships/environment`,{data:{id:e,type:"environments"},id:t})}function tQ(t,e){return this.patch(`/libraries/${t}`,{data:{id:t,type:"libraries",meta:{action:e}}})}function tV(t){return this.patch(`/libraries/${t.id}`,{data:t})}function tY(t,e){return this.post(`/libraries/${t}/notes`,{data:e})}t(tx,"addDataElementRelationshipsToLibrary",()=>tR),t(tx,"addExtensionRelationshipsToLibrary",()=>tL),t(tx,"addRuleRelationshipsToLibrary",()=>t_),t(tx,"createLibrary",()=>tP),t(tx,"deleteLibrary",()=>tk),t(tx,"getEnvironmentForLibrary",()=>tD),t(tx,"getEnvironmentRelationshipForLibrary",()=>tC),t(tx,"getLibrary",()=>tB),t(tx,"getPropertyForLibrary",()=>tT),t(tx,"getUpstreamLibraryForLibrary",()=>tw),t(tx,"listDataElementsForLibrary",()=>tH),t(tx,"listDataElementRelationshipsForLibrary",()=>tA),t(tx,"listExtensionsForLibrary",()=>tO),t(tx,"listExtensionRelationshipsForLibrary",()=>tU),t(tx,"listLibrariesForProperty",()=>tj),t(tx,"listRuleRelationshipsForLibrary",()=>tq),t(tx,"listRulesForLibrary",()=>tS),t(tx,"publishLibrary",()=>tN),t(tx,"removeDataElementRelationshipsFromLibrary",()=>tM),t(tx,"removeExtensionRelationshipsFromLibrary",()=>tI),t(tx,"removeEnvironmentRelationshipFromLibrary",()=>tK),t(tx,"removeRuleRelationshipsFromLibrary",()=>tz),t(tx,"replaceExtensionRelationshipsForLibrary",()=>tG),t(tx,"replaceDataElementRelationshipsForLibrary",()=>tJ),t(tx,"replaceRuleRelationshipsForLibrary",()=>tW),t(tx,"setEnvironmentRelationshipForLibrary",()=>tX),t(tx,"transitionLibrary",()=>tQ),t(tx,"updateLibrary",()=>tV),t(tx,"createNoteForLibrary",()=>tY);var tZ={};function t0(){return this.get("/profile")}t(tZ,"getProfile",()=>t0);var t1={};function t2(t,e){return this.post(`/companies/${t}/properties`,{data:e})}function t3(t){return this.get(`/properties/${t}`)}function t4(t){return this.get(`/properties/${t}/company`)}function t5(t,e){return this.get(`/companies/${t}/properties`,e)}function t9(t){return this.patch(`/properties/${t.id}`,{data:t})}function t6(t){return this.delete(`/properties/${t}`)}function t7(t,e){return this.post(`/properties/${t}/notes`,{data:e})}t(t1,"createProperty",()=>t2),t(t1,"getProperty",()=>t3),t(t1,"getCompanyForProperty",()=>t4),t(t1,"listPropertiesForCompany",()=>t5),t(t1,"updateProperty",()=>t9),t(t1,"deleteProperty",()=>t6),t(t1,"createNoteForProperty",()=>t7);var t8={};function et(t,e){return this.post(`/properties/${t}/rule_components`,{data:e})}function ee(t){return this.delete(`/rule_components/${t}`)}function er(t){return this.get(`/rule_components/${t}`)}function en(t){return this.get(`/rule_components/${t}/extension`)}function ei(t){return this.get(`/rule_components/${t}/rules`)}function es(t){return this.get(`/rule_components/${t}/origin`)}function eo(t,e){return this.get(`/rules/${t}/rule_components`,e)}function ea(t){return this.patch(`/rule_components/${t.id}`,{data:t})}function eu(t,e){return this.post(`/rule_components/${t}/notes`,{data:e})}t(t8,"createRuleComponent",()=>et),t(t8,"deleteRuleComponent",()=>ee),t(t8,"getRuleComponent",()=>er),t(t8,"getExtensionForRuleComponent",()=>en),t(t8,"listRulesForRuleComponent",()=>ei),t(t8,"getOriginForRuleComponent",()=>es),t(t8,"listRuleComponentsForRule",()=>eo),t(t8,"updateRuleComponent",()=>ea),t(t8,"createNoteForRuleComponent",()=>eu);var el={};function ec(t,e){return this.post(`/properties/${t}/rules`,{data:e})}function ep(t){return this.delete(`/rules/${t}`)}function eh(t){return this.get(`/rules/${t}`)}function ed(t){return this.get(`/rules/${t}/property`)}function eg(t,e){return this.get(`/rules/${t}/libraries`,e)}function ef(t,e){return this.get(`/builds/${t}/rules`,e)}function e$(t,e){return this.get(`/properties/${t}/rules`,e)}function eb(t,e){return this.get(`/rules/${t}/revisions`,e)}function em(t){return this.patch(`/rules/${t}`,this.createReviseBody("rules",t))}function ey(t){return this.get(`/rules/${t}/origin`)}function ev(t){return this.patch(`/rules/${t.id}`,{data:t})}function eE(t,e){return this.post(`/rules/${t}/notes`,{data:e})}t(el,"createRule",()=>ec),t(el,"deleteRule",()=>ep),t(el,"getRule",()=>eh),t(el,"getPropertyForRule",()=>ed),t(el,"listLibrariesForRule",()=>eg),t(el,"listRulesForBuild",()=>ef),t(el,"listRulesForProperty",()=>e$),t(el,"listRevisionsForRule",()=>eb),t(el,"reviseRule",()=>em),t(el,"getOriginForRule",()=>ey),t(el,"updateRule",()=>ev),t(el,"createNoteForRule",()=>eE);let eF={reactorUrl:"https://reactor.adobe.io",enableLogging:!1};class ex{constructor(t,e={}){const r={...eF,...e};this.baseUrl=function(t){return t.endsWith("/")?t.slice(0,-1):t}(r.reactorUrl),this.enableLogging=r.enableLogging,this.customHeaders=r.customHeaders||{},this.headers={...this.reactorHeaders(t),...this.customHeaders},this.enableLogging&&console.info(`Using Reactor at ${this.baseUrl}`)}reactorHeaders(t){return{Accept:"application/vnd.api+json;revision=1","Content-Type":"application/vnd.api+json",Authorization:`Bearer ${t}`,"X-Api-Key":"Activation-DTM","User-Agent":`adobe/reactor-sdk/javascript/${r}`}}createReviseBody(t,e){return{data:{id:e,attributes:{},type:t,meta:{action:"revise"}}}}async requestAndLog(t,e,r){let n,i=await fetch(t.toString(),e),s=(n=i.headers.get("content-type"))&&n.includes("application/vnd.api+json")?await i.json():null,o={status:`${i.status} ${i.statusText}`,source:`${e.method} ${t.toString()}`,url:t,request:e,response:i,requestBody:r||{},responseBody:s||{}},a=`${o.status} <- ${o.source}`;if(!i.ok)throw this.enableLogging&&console.info("[Reactor SDK]",a,o),new eR(o);return this.enableLogging&&console.debug("[Reactor SDK]",a,o),s}async request(t,e,r=null,n=0){let i=r&&JSON.stringify(r),s={method:t,headers:this.headers,body:i};try{return await this.requestAndLog(e,s,r)}catch(i){if(i instanceof eR&&429===i.status&&n<3){let s=i.traceData.response.headers.get("retry-after"),o=(s?parseInt(s,10):5)+1,a=1e3*o;return console.info(`[Blacksmith API] --------------- The API has asked us to wait ${o} seconds before making calls again. ---------------`),await new Promise(t=>setTimeout(t,a)),await this.request(t,e,r,n+1)}throw i}}async sendMultipartFile(t,e,r){let n={method:t,headers:Object.assign({},this.headers,{"Content-Type":"multipart/form-data"}),body:r};return await this.requestAndLog(e,n,r)}get(t,e={}){let r=new URL(this.baseUrl+t);return Object.entries(e).forEach(([t,e])=>r.searchParams.append(t,e)),this.request("GET",r)}post(t,e){return this.request("POST",this.baseUrl+t,e)}patch(t,e){return this.request("PATCH",this.baseUrl+t,e)}delete(t,e){return this.request("DELETE",this.baseUrl+t,e)}}class eR extends Error{constructor(t){const e=t.status;super(e+function(t){let e=t.responseBody.errors||[],r=[t.response,...e].map(t=>t.detail).filter(t=>void 0!==t).map(t=>`'${t}'`).join("; also, ");return""!==r?` (${r})`:""}(t)+` on ${t.source}`),Error.captureStackTrace&&Error.captureStackTrace(this,eR),this.status=t.response.status,this.statusText=t.response.statusText,this.traceData=t}}Object.assign(ex.prototype,c,d,F,D,T,z,tr,tu,tE,n,tx,tZ,t1,t8,el),ex.prototype.version=r,"undefined"!=typeof window&&(window.Reactor=ex)})();