@adobe/reactor-sdk
Version:
JavaScript SDK for the Reactor API
3 lines (2 loc) • 15.6 kB
JavaScript
var t,e=(t=require("node-fetch"))&&t.__esModule?t.default:t;function r(t,e,r,n){Object.defineProperty(t,e,{get:r,set:n,enumerable:!0,configurable:!0})}!function(t){Object.defineProperty(t,"__esModule",{value:!0,configurable:!0})}(module.exports),r(module.exports,"default",(()=>He));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})}r(n,"listHostsForProperty",(()=>u)),r(n,"getPropertyForHost",(()=>a)),r(n,"updateHost",(()=>l)),r(n,"createHost",(()=>i)),r(n,"deleteHost",(()=>s)),r(n,"getHost",(()=>o));var c={};function p(t){return this.get(`/audit_events/${t}`)}function h(t){return this.get("/audit_events",t)}r(c,"getAuditEvent",(()=>p)),r(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)}r(d,"listRulesForBuild",(()=>E)),r(d,"getLibraryForBuild",(()=>b)),r(d,"createBuild",(()=>g)),r(d,"getDataElementsForBuild",(()=>m)),r(d,"listBuildsForLibrary",(()=>y)),r(d,"getEnvironmentForBuild",(()=>$)),r(d,"getBuild",(()=>f)),r(d,"listExtensionsForBuild",(()=>v));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})}r(F,"deleteCallback",(()=>R)),r(F,"updateCallback",(()=>k)),r(F,"getPropertyForCallback",(()=>_)),r(F,"listCallbacksForProperty",(()=>P)),r(F,"getCallback",(()=>L)),r(F,"createCallback",(()=>x));var C={};function D(t){return this.get(`/companies/${t}`)}function B(t){return this.get("/companies",t)}r(C,"listCompanies",(()=>B)),r(C,"getCompany",(()=>D));var T={};function H(t,e){return this.post(`/properties/${t}/data_elements`,{data:e})}function w(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 K(t){return this.patch(`/data_elements/${t.id}`,{data:t})}function z(t,e){return this.post(`/data_elements/${t}/notes`,{data:e})}r(T,"getPropertyForDataElement",(()=>U)),r(T,"getDataElement",(()=>A)),r(T,"reviseDataElement",(()=>M)),r(T,"getExtensionForDataElement",(()=>O)),r(T,"listLibrariesForDataElement",(()=>S)),r(T,"updateDataElement",(()=>K)),r(T,"getOriginForDataElement",(()=>j)),r(T,"createNoteForDataElement",(()=>z)),r(T,"createDataElement",(()=>H)),r(T,"deleteDataElement",(()=>w)),r(T,"listDataElementsForProperty",(()=>q)),r(T,"listRevisionsForDataElement",(()=>N));var G={};function J(t,e){return this.post(`/properties/${t}/environments`,{data:e})}function W(t){return this.delete(`/environments/${t}`)}function X(t){return this.get(`/environments/${t}`)}function I(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 et(t){return this.patch(`/environments/${t.id}`,{data:t})}r(G,"getHostForEnvironment",(()=>I)),r(G,"getLibraryForEnvironment",(()=>V)),r(G,"listEnvironmentsForProperty",(()=>tt)),r(G,"updateEnvironment",(()=>et)),r(G,"createEnvironment",(()=>J)),r(G,"getHostRelationshipForEnvironment",(()=>Q)),r(G,"getPropertyForEnvironment",(()=>Y)),r(G,"getEnvironment",(()=>X)),r(G,"deleteEnvironment",(()=>W)),r(G,"listBuildsForEnvironment",(()=>Z));var rt={};function nt(t){return this.sendMultipartFile("POST","/extension_packages",t)}function it(t){return this.get(`/extension_packages/${t}`)}function st(t){return this.get("/extension_packages",t)}function ot(t){return this.patch(`/extension_packages/${t}`,{attributes:{},meta:{action:"release_private"},id:t,type:"extension_packages"})}function at(t,e){const r=`/extension_packages/${t}`;return this.sendMultipartFile("PATCH",r,e)}r(rt,"privateReleaseExtensionPackage",(()=>ot)),r(rt,"getExtensionPackage",(()=>it)),r(rt,"listExtensionPackages",(()=>st)),r(rt,"createExtensionPackage",(()=>nt)),r(rt,"updateExtensionPackage",(()=>at));var ut={};function lt(t,e){return this.post(`/properties/${t}/extensions`,{data:e})}function ct(t){return this.delete(`/extensions/${t}`)}function pt(t){return this.get(`/extensions/${t}`)}function ht(t){return this.get(`/extensions/${t}/extension_package`)}function dt(t){return this.get(`/extensions/${t}/origin`)}function gt(t){return this.get(`/extensions/${t}/property`)}function ft(t,e){return this.get(`/properties/${t}/extensions`,e)}function $t(t){return this.get(`/extensions/${t}/libraries`)}function bt(t){return this.get(`/extensions/${t}/revisions`)}function mt(t){return this.patch(`/extensions/${t}`,this.createReviseBody("extensions",t))}function yt(t,e){return this.patch(`/extensions/${t}`,{data:e})}function vt(t,e){return this.post(`/extensions/${t}/notes`,{data:e})}r(ut,"getPropertyForExtension",(()=>gt)),r(ut,"listLibrariesForExtension",(()=>$t)),r(ut,"getExtensionPackageForExtension",(()=>ht)),r(ut,"updateExtension",(()=>yt)),r(ut,"createExtension",(()=>lt)),r(ut,"listRevisionsForExtension",(()=>bt)),r(ut,"reviseExtension",(()=>mt)),r(ut,"getExtension",(()=>pt)),r(ut,"createNoteForExtension",(()=>vt)),r(ut,"getOriginForExtension",(()=>dt)),r(ut,"listExtensionsForProperty",(()=>ft)),r(ut,"deleteExtension",(()=>ct));var Et={};function Ft(){return this.get("/heartbeat")}r(Et,"heartbeat",(()=>Ft));var xt={};function Rt(t,e){return this.post(`/libraries/${t}/relationships/data_elements`,{data:e})}function Lt(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 Pt(t,e){return this.post(`/properties/${t}/libraries`,{data:e})}function kt(t){return this.delete(`/libraries/${t}`)}function Ct(t){return this.get(`/libraries/${t}/environment`)}function Dt(t){return this.get(`/libraries/${t}/relationships/environment`)}function Bt(t){return this.get(`/libraries/${t}`)}function Tt(t){return this.get(`/libraries/${t}/property`)}function Ht(t){return this.get(`/libraries/${t}/upstream_library`)}function wt(t,e){return this.get(`/libraries/${t}/data_elements`,e)}function At(t,e){return this.get(`/libraries/${t}/relationships/data_elements`,e)}function Ot(t,e){return this.get(`/libraries/${t}/extensions`,e)}function Ut(t,e){return this.get(`/libraries/${t}/relationships/extensions`,e)}function jt(t,e){return this.get(`/properties/${t}/libraries`,e)}function qt(t,e){return this.get(`/libraries/${t}/relationships/rules`,e)}function St(t,e){return this.get(`/libraries/${t}/rules`,e)}function Nt(t){return this.createBuild(t)}function Mt(t,e){return this.delete(`/libraries/${t}/relationships/data_elements`,{data:e})}function Kt(t,e){return this.delete(`/libraries/${t}/relationships/extensions`,{data:e})}function zt(t,e){return this.delete(`/libraries/${t}/relationships/environment`,{data:{id:e,type:"environments"},id:t})}function Gt(t,e){return this.delete(`/libraries/${t}/relationships/rules`,{data:e})}function Jt(t,e){return this.patch(`/libraries/${t}/relationships/extensions`,{data:e})}function Wt(t,e){return this.patch(`/libraries/${t}/relationships/data_elements`,{data:e})}function Xt(t,e){return this.patch(`/libraries/${t}/relationships/rules`,{data:e})}function It(t,e){return this.patch(`/libraries/${t}/relationships/environment`,{data:{id:e,type:"environments"},id:t})}function Qt(t,e){return this.patch(`/libraries/${t}`,{data:{id:t,type:"libraries",meta:{action:e}}})}function Vt(t){return this.patch(`/libraries/${t.id}`,{data:t})}function Yt(t,e){return this.post(`/libraries/${t}/notes`,{data:e})}r(xt,"addRuleRelationshipsToLibrary",(()=>_t)),r(xt,"removeDataElementRelationshipsFromLibrary",(()=>Mt)),r(xt,"getUpstreamLibraryForLibrary",(()=>Ht)),r(xt,"updateLibrary",(()=>Vt)),r(xt,"listRuleRelationshipsForLibrary",(()=>qt)),r(xt,"replaceDataElementRelationshipsForLibrary",(()=>Wt)),r(xt,"getEnvironmentForLibrary",(()=>Ct)),r(xt,"listExtensionRelationshipsForLibrary",(()=>Ut)),r(xt,"getLibrary",(()=>Bt)),r(xt,"removeEnvironmentRelationshipFromLibrary",(()=>zt)),r(xt,"publishLibrary",(()=>Nt)),r(xt,"replaceExtensionRelationshipsForLibrary",(()=>Jt)),r(xt,"removeRuleRelationshipsFromLibrary",(()=>Gt)),r(xt,"setEnvironmentRelationshipForLibrary",(()=>It)),r(xt,"createNoteForLibrary",(()=>Yt)),r(xt,"listExtensionsForLibrary",(()=>Ot)),r(xt,"deleteLibrary",(()=>kt)),r(xt,"replaceRuleRelationshipsForLibrary",(()=>Xt)),r(xt,"addDataElementRelationshipsToLibrary",(()=>Rt)),r(xt,"removeExtensionRelationshipsFromLibrary",(()=>Kt)),r(xt,"listDataElementRelationshipsForLibrary",(()=>At)),r(xt,"getEnvironmentRelationshipForLibrary",(()=>Dt)),r(xt,"listDataElementsForLibrary",(()=>wt)),r(xt,"listRulesForLibrary",(()=>St)),r(xt,"listLibrariesForProperty",(()=>jt)),r(xt,"addExtensionRelationshipsToLibrary",(()=>Lt)),r(xt,"transitionLibrary",(()=>Qt)),r(xt,"createLibrary",(()=>Pt)),r(xt,"getPropertyForLibrary",(()=>Tt));var Zt={};function te(){return this.get("/profile")}r(Zt,"getProfile",(()=>te));var ee={};function re(t,e){return this.post(`/companies/${t}/properties`,{data:e})}function ne(t){return this.get(`/properties/${t}`)}function ie(t){return this.get(`/properties/${t}/company`)}function se(t,e){return this.get(`/companies/${t}/properties`,e)}function oe(t){return this.patch(`/properties/${t.id}`,{data:t})}function ae(t){return this.delete(`/properties/${t}`)}function ue(t,e){return this.post(`/properties/${t}/notes`,{data:e})}r(ee,"createProperty",(()=>re)),r(ee,"getProperty",(()=>ne)),r(ee,"createNoteForProperty",(()=>ue)),r(ee,"updateProperty",(()=>oe)),r(ee,"listPropertiesForCompany",(()=>se)),r(ee,"getCompanyForProperty",(()=>ie)),r(ee,"deleteProperty",(()=>ae));var le={};function ce(t,e){return this.post(`/properties/${t}/rule_components`,{data:e})}function pe(t){return this.delete(`/rule_components/${t}`)}function he(t){return this.get(`/rule_components/${t}`)}function de(t){return this.get(`/rule_components/${t}/extension`)}function ge(t){return this.get(`/rule_components/${t}/rules`)}function fe(t){return this.get(`/rule_components/${t}/origin`)}function $e(t,e){return this.get(`/rules/${t}/rule_components`,e)}function be(t){return this.patch(`/rule_components/${t.id}`,{data:t})}function me(t,e){return this.post(`/rule_components/${t}/notes`,{data:e})}r(le,"getOriginForRuleComponent",(()=>fe)),r(le,"updateRuleComponent",(()=>be)),r(le,"getRuleComponent",(()=>he)),r(le,"getExtensionForRuleComponent",(()=>de)),r(le,"deleteRuleComponent",(()=>pe)),r(le,"createRuleComponent",(()=>ce)),r(le,"listRulesForRuleComponent",(()=>ge)),r(le,"createNoteForRuleComponent",(()=>me)),r(le,"listRuleComponentsForRule",(()=>$e));var ye={};function ve(t,e){return this.post(`/properties/${t}/rules`,{data:e})}function Ee(t){return this.delete(`/rules/${t}`)}function Fe(t){return this.get(`/rules/${t}`)}function xe(t){return this.get(`/rules/${t}/property`)}function Re(t,e){return this.get(`/rules/${t}/libraries`,e)}function Le(t,e){return this.get(`/builds/${t}/rules`,e)}function _e(t,e){return this.get(`/properties/${t}/rules`,e)}function Pe(t,e){return this.get(`/rules/${t}/revisions`,e)}function ke(t){return this.patch(`/rules/${t}`,this.createReviseBody("rules",t))}function Ce(t){return this.get(`/rules/${t}/origin`)}function De(t){return this.patch(`/rules/${t.id}`,{data:t})}function Be(t,e){return this.post(`/rules/${t}/notes`,{data:e})}r(ye,"getRule",(()=>Fe)),r(ye,"createRule",(()=>ve)),r(ye,"deleteRule",(()=>Ee)),r(ye,"createNoteForRule",(()=>Be)),r(ye,"listRulesForProperty",(()=>_e)),r(ye,"updateRule",(()=>De)),r(ye,"reviseRule",(()=>ke)),r(ye,"listLibrariesForRule",(()=>Re)),r(ye,"listRulesForBuild",(()=>Le)),r(ye,"listRevisionsForRule",(()=>Pe)),r(ye,"getPropertyForRule",(()=>xe)),r(ye,"getOriginForRule",(()=>Ce));const Te={reactorUrl:"https://reactor.adobe.io",enableLogging:!1};class He{reactorHeaders(t){return{Accept:"application/vnd.api+json;revision=1","Content-Type":"application/vnd.api+json","Cache-control":"no-cache",Authorization:`Bearer ${t}`,"X-Api-Key":"Activation-DTM","User-Agent":"adobe/reactor-sdk/javascript/1.2.0"}}createReviseBody(t,e){return{data:{id:e,attributes:{},type:t,meta:{action:"revise"}}}}async requestAndLog(t,r,n){const i=await e(t.toString(),r),s=function(t){const e=t.headers.get("content-type");return e&&e.includes("application/vnd.api+json")}(i)?await i.json():null,o=(i.status,i.statusText,r.method,t.toString(),{status:`${i.status} ${i.statusText}`,source:`${r.method} ${t.toString()}`,url:t,request:r,response:i,requestBody:n||{},responseBody:s||{}}),a=`${o.status} <- ${o.source}`;if(!i.ok)throw this.enableLogging&&console.info("[Reactor SDK]",a,o),new we(o);return this.enableLogging&&console.debug("[Reactor SDK]",a,o),s}async request(t,e,r=null){const n=r&&JSON.stringify(r),i={method:t,headers:this.headers,body:n};return await this.requestAndLog(e,i,r)}async sendMultipartFile(t,e,r){const 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={}){const 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)}constructor(t,e={}){const r={...Te,...e};var n;this.baseUrl=(n=r.reactorUrl).endsWith("/")?n.slice(0,-1):n,this.enableLogging=r.enableLogging,this.customHeaders=r.customHeaders||{},this.headers={...this.reactorHeaders(t),...this.customHeaders},this.enableLogging&&console.info(`Using Reactor at ${this.baseUrl}`)}}class we extends Error{constructor(t){super(t.status+function(t){const 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,we),this.status=t.response.status,this.statusText=t.response.statusText,this.traceData=t}}Object.assign(He.prototype,c,d,F,C,T,G,rt,ut,Et,n,xt,Zt,ee,le,ye),"undefined"!=typeof window&&void 0!==window.document&&(window.Reactor=He);
//# sourceMappingURL=reactor-sdk-library.min.js.map