UNPKG

@adobe/reactor-sdk

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