@epigraph/epigraph-std-lib 4.1.0 → 4.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("../EpigraphLibs/EpigraphLogger/epigraphLogger.cjs"),p=require("../EpigraphLibs/EpigraphUrlProcessor/epigraphUrlProcessor.cjs");var r=(n=>(n.DEVELOPMENT="development",n.STAGING="staging",n.PRODUCTION="production",n))(r||{});class g{constructor(e){if(this._loggerContext="EPIGRAPH",this._isReady=!1,this._logger=new s.EpigraphLogger("EPIGRAPH LOGGER"),this._environment=r.DEVELOPMENT,this._activeComponentsInSession=new Map,this._staleComponentsInSession=new Map,window.epigraph)return window.epigraph.registerActiveComponent(e),window.epigraph;window.epigraph=this,window.epigraph.registerActiveComponent(e),this.logBranding(),this._initializer=e,this._environment=this._initializer.environment;const t=this.getLoggerModeNameFromEnvironment();this._logger.setCurrentMode(t),this._urlProcessor=new p.EpigraphUrlProcessor,this.id=g.safeGenerateUuid();const i=this._urlProcessor.getParameterInUrl(p.QUERY_PARAMETER_NAMES.epigraphSessionId);this._epigraphSessionId=i??g.safeGenerateUuid(),this._logger.info({title:"Epigraph Object Ready!!",details:this,contextOverride:this._loggerContext}),this._isReady=!0}get isReady(){return this._isReady}get logger(){return this._logger}get urlProcessor(){return this._urlProcessor}get epigraphSessionId(){return this._epigraphSessionId}get environment(){return this._environment}get initializer(){return this._initializer}get activeComponentsInSession(){return this._activeComponentsInSession}get staleComponentsInSession(){return this._staleComponentsInSession}logBranding(){console.group("Powered by: "),console.log("%cEPIGRAPH","font-weight: bold; font-size: 50px; text-shadow: 3px 3px 0 rgb(100,100,100)"),console.log("Visit for more details: www.epigraph.us"),console.groupEnd()}registerActiveComponent(e){this._activeComponentsInSession.set(e.uuid,e),this._logger.info({title:"Registered a new Active Component",details:e,contextOverride:this._loggerContext})}deregisterActiveComponent(e){const t=this._activeComponentsInSession.get(e.uuid);t&&(this._staleComponentsInSession.set(t.uuid,t),this._activeComponentsInSession.delete(t.uuid),this._logger.info({title:"Deregistered a new Active Component",details:e,contextOverride:this._loggerContext}))}getLoggerModeNameFromEnvironment(){let e=s.LoggerModeNames.Dev;return this._environment===r.STAGING?e=s.LoggerModeNames.Staging:this._environment===r.PRODUCTION&&(e=s.LoggerModeNames.Release),e}static safeGenerateUuid(){let e="";try{e=crypto.randomUUID()}catch{console.error("crypto not available. Not generating a UUID")}return e}static generateXPath(e){let t="",i=e;for(;i;){let a=1,o=i.previousSibling;for(;o;)o.nodeName===i.nodeName&&a++,o=o.previousSibling;t=`/${i.nodeName.toLowerCase()+(a>1?`[${a}]`:"")}${t}`,i=i.parentNode}return t}}exports.ENVIRONMENT_TYPE=r;exports.Epigraph=g;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("../EpigraphLibs/EpigraphLogger/epigraphLogger.cjs"),p=require("../EpigraphLibs/EpigraphUrlProcessor/epigraphUrlProcessor.cjs");var n=(r=>(r.DEVELOPMENT="development",r.STAGING="staging",r.PRODUCTION="production",r))(n||{});class a{constructor(e){if(this._loggerContext="EPIGRAPH",this._isReady=!1,this._logger=new s.EpigraphLogger("EPIGRAPH LOGGER"),this._environment=n.DEVELOPMENT,this._activeComponentsInSession=new Map,this._staleComponentsInSession=new Map,this._isSessionWebGL2Compatible=!1,window.epigraph)return window.epigraph.registerActiveComponent(e),window.epigraph;this._isSessionWebGL2Compatible=this._checkIfWebGL2IsAvailable(),window.epigraph=this,window.epigraph.registerActiveComponent(e),this.logBranding(),this._initializer=e,this._environment=this._initializer.environment;const t=this.getLoggerModeNameFromEnvironment();this._logger.setCurrentMode(t),this._urlProcessor=new p.EpigraphUrlProcessor,this.id=a.safeGenerateUuid();const i=this._urlProcessor.getParameterInUrl(p.QUERY_PARAMETER_NAMES.epigraphSessionId);this._epigraphSessionId=i??a.safeGenerateUuid(),this._logger.info({title:"Epigraph Object Ready!!",details:this,contextOverride:this._loggerContext}),this._isReady=!0}get isReady(){return this._isReady}get logger(){return this._logger}get urlProcessor(){return this._urlProcessor}get epigraphSessionId(){return this._epigraphSessionId}get environment(){return this._environment}get initializer(){return this._initializer}get activeComponentsInSession(){return this._activeComponentsInSession}get staleComponentsInSession(){return this._staleComponentsInSession}isSessionWebGL2Compatible(){return this._isSessionWebGL2Compatible}logBranding(){console.group("Powered by: "),console.log("%cEPIGRAPH","font-weight: bold; font-size: 50px; text-shadow: 3px 3px 0 rgb(100,100,100)"),console.log("Visit for more details: www.epigraph.us"),console.groupEnd()}_checkIfWebGL2IsAvailable(){try{const e=document.createElement("canvas");return!!(window.WebGL2RenderingContext&&e.getContext("webgl2"))}catch{return!1}}registerActiveComponent(e){this._activeComponentsInSession.set(e.uuid,e),this._logger.info({title:"Registered a new Active Component",details:e,contextOverride:this._loggerContext})}deregisterActiveComponent(e){const t=this._activeComponentsInSession.get(e.uuid);t&&(this._staleComponentsInSession.set(t.uuid,t),this._activeComponentsInSession.delete(t.uuid),this._logger.info({title:"Deregistered a new Active Component",details:e,contextOverride:this._loggerContext}))}getLoggerModeNameFromEnvironment(){let e=s.LoggerModeNames.Dev;return this._environment===n.STAGING?e=s.LoggerModeNames.Staging:this._environment===n.PRODUCTION&&(e=s.LoggerModeNames.Release),e}static safeGenerateUuid(){let e="";try{e=crypto.randomUUID()}catch{console.error("crypto not available. Not generating a UUID")}return e}static generateXPath(e){let t="",i=e;for(;i;){let g=1,o=i.previousSibling;for(;o;)o.nodeName===i.nodeName&&g++,o=o.previousSibling;t=`/${i.nodeName.toLowerCase()+(g>1?`[${g}]`:"")}${t}`,i=i.parentNode}return t}}exports.ENVIRONMENT_TYPE=n;exports.Epigraph=a;
@@ -21,6 +21,7 @@ export declare class Epigraph {
21
21
  private _environment;
22
22
  private _activeComponentsInSession;
23
23
  private _staleComponentsInSession;
24
+ private _isSessionWebGL2Compatible;
24
25
  constructor(initializer: EpigraphBaseSolutionTypes);
25
26
  get isReady(): boolean;
26
27
  get logger(): EpigraphLogger;
@@ -30,10 +31,17 @@ export declare class Epigraph {
30
31
  get initializer(): EpigraphBaseSolutionTypes;
31
32
  get activeComponentsInSession(): Map<string, EpigraphBaseSolutionTypes>;
32
33
  get staleComponentsInSession(): Map<string, EpigraphBaseSolutionTypes>;
34
+ isSessionWebGL2Compatible(): boolean;
33
35
  /**
34
36
  * Logs Epigraph Branding in the console to help redirect potential interests in the right direction.
35
37
  */
36
38
  logBranding(): void;
39
+ /**
40
+ * Used to check if the current session can support WebGL2 or not.
41
+ *
42
+ * @returns {boolean}
43
+ */
44
+ private _checkIfWebGL2IsAvailable;
37
45
  /**
38
46
  * Registers a new component that was initialized on this page.
39
47
  * This is optional from the perspective of the initialization flow but highly recommend
@@ -1,15 +1,15 @@
1
- import { EpigraphLogger as p, LoggerModeNames as g } from "../EpigraphLibs/EpigraphLogger/epigraphLogger.js";
2
- import { EpigraphUrlProcessor as h, QUERY_PARAMETER_NAMES as l } from "../EpigraphLibs/EpigraphUrlProcessor/epigraphUrlProcessor.js";
3
- var r = /* @__PURE__ */ ((i) => (i.DEVELOPMENT = "development", i.STAGING = "staging", i.PRODUCTION = "production", i))(r || {});
4
- class a {
1
+ import { EpigraphLogger as l, LoggerModeNames as a } from "../EpigraphLibs/EpigraphLogger/epigraphLogger.js";
2
+ import { EpigraphUrlProcessor as h, QUERY_PARAMETER_NAMES as p } from "../EpigraphLibs/EpigraphUrlProcessor/epigraphUrlProcessor.js";
3
+ var s = /* @__PURE__ */ ((i) => (i.DEVELOPMENT = "development", i.STAGING = "staging", i.PRODUCTION = "production", i))(s || {});
4
+ class g {
5
5
  constructor(e) {
6
- if (this._loggerContext = "EPIGRAPH", this._isReady = !1, this._logger = new p("EPIGRAPH LOGGER"), this._environment = r.DEVELOPMENT, this._activeComponentsInSession = /* @__PURE__ */ new Map(), this._staleComponentsInSession = /* @__PURE__ */ new Map(), window.epigraph)
6
+ if (this._loggerContext = "EPIGRAPH", this._isReady = !1, this._logger = new l("EPIGRAPH LOGGER"), this._environment = s.DEVELOPMENT, this._activeComponentsInSession = /* @__PURE__ */ new Map(), this._staleComponentsInSession = /* @__PURE__ */ new Map(), this._isSessionWebGL2Compatible = !1, window.epigraph)
7
7
  return window.epigraph.registerActiveComponent(e), window.epigraph;
8
- window.epigraph = this, window.epigraph.registerActiveComponent(e), this.logBranding(), this._initializer = e, this._environment = this._initializer.environment;
8
+ this._isSessionWebGL2Compatible = this._checkIfWebGL2IsAvailable(), window.epigraph = this, window.epigraph.registerActiveComponent(e), this.logBranding(), this._initializer = e, this._environment = this._initializer.environment;
9
9
  const t = this.getLoggerModeNameFromEnvironment();
10
- this._logger.setCurrentMode(t), this._urlProcessor = new h(), this.id = a.safeGenerateUuid();
11
- const n = this._urlProcessor.getParameterInUrl(l.epigraphSessionId);
12
- this._epigraphSessionId = n ?? a.safeGenerateUuid(), this._logger.info({ title: "Epigraph Object Ready!!", details: this, contextOverride: this._loggerContext }), this._isReady = !0;
10
+ this._logger.setCurrentMode(t), this._urlProcessor = new h(), this.id = g.safeGenerateUuid();
11
+ const n = this._urlProcessor.getParameterInUrl(p.epigraphSessionId);
12
+ this._epigraphSessionId = n ?? g.safeGenerateUuid(), this._logger.info({ title: "Epigraph Object Ready!!", details: this, contextOverride: this._loggerContext }), this._isReady = !0;
13
13
  }
14
14
  get isReady() {
15
15
  return this._isReady;
@@ -35,12 +35,28 @@ class a {
35
35
  get staleComponentsInSession() {
36
36
  return this._staleComponentsInSession;
37
37
  }
38
+ isSessionWebGL2Compatible() {
39
+ return this._isSessionWebGL2Compatible;
40
+ }
38
41
  /**
39
42
  * Logs Epigraph Branding in the console to help redirect potential interests in the right direction.
40
43
  */
41
44
  logBranding() {
42
45
  console.group("Powered by: "), console.log("%cEPIGRAPH", "font-weight: bold; font-size: 50px; text-shadow: 3px 3px 0 rgb(100,100,100)"), console.log("Visit for more details: www.epigraph.us"), console.groupEnd();
43
46
  }
47
+ /**
48
+ * Used to check if the current session can support WebGL2 or not.
49
+ *
50
+ * @returns {boolean}
51
+ */
52
+ _checkIfWebGL2IsAvailable() {
53
+ try {
54
+ const e = document.createElement("canvas");
55
+ return !!(window.WebGL2RenderingContext && e.getContext("webgl2"));
56
+ } catch {
57
+ return !1;
58
+ }
59
+ }
44
60
  /**
45
61
  * Registers a new component that was initialized on this page.
46
62
  * This is optional from the perspective of the initialization flow but highly recommend
@@ -70,8 +86,8 @@ class a {
70
86
  * @returns {LoggerModeNames} A valid logger mode name.
71
87
  */
72
88
  getLoggerModeNameFromEnvironment() {
73
- let e = g.Dev;
74
- return this._environment === r.STAGING ? e = g.Staging : this._environment === r.PRODUCTION && (e = g.Release), e;
89
+ let e = a.Dev;
90
+ return this._environment === s.STAGING ? e = a.Staging : this._environment === s.PRODUCTION && (e = a.Release), e;
75
91
  }
76
92
  /**
77
93
  * Generates a random UUID using crypto.randomUUID with a fallback on custom generator,
@@ -97,15 +113,15 @@ class a {
97
113
  static generateXPath(e) {
98
114
  let t = "", n = e;
99
115
  for (; n; ) {
100
- let s = 1, o = n.previousSibling;
116
+ let r = 1, o = n.previousSibling;
101
117
  for (; o; )
102
- o.nodeName === n.nodeName && s++, o = o.previousSibling;
103
- t = `/${n.nodeName.toLowerCase() + (s > 1 ? `[${s}]` : "")}${t}`, n = n.parentNode;
118
+ o.nodeName === n.nodeName && r++, o = o.previousSibling;
119
+ t = `/${n.nodeName.toLowerCase() + (r > 1 ? `[${r}]` : "")}${t}`, n = n.parentNode;
104
120
  }
105
121
  return t;
106
122
  }
107
123
  }
108
124
  export {
109
- r as ENVIRONMENT_TYPE,
110
- a as Epigraph
125
+ s as ENVIRONMENT_TYPE,
126
+ g as Epigraph
111
127
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("lit"),e=require("./epigraph.cjs");class s extends HTMLElement{constructor(t,i){super(),this._isReady=!1,this._elementName="epigraph-base-solution-html",this._solutionVersion="",this._loggerContextOverride="[EPIGRAPH BASE SOLUTION]",this.attachShadow({mode:"open"}),this._environment=i,this._solutionVersion=t,this._xPath=e.Epigraph.generateXPath(this),this._uuid=e.Epigraph.safeGenerateUuid()??this._xPath,new e.Epigraph(this),window.epigraph.logger.info({title:"Epigraph Base Solution Ready",contextOverride:this._loggerContextOverride})}get isReady(){return this._isReady}get environment(){return this._environment}get elementName(){return this._elementName}get solutionVersion(){return this._solutionVersion}get uuid(){return this._uuid}get xPath(){return this._xPath}disconnectedCallback(){window.epigraph.deregisterActiveComponent(this)}}class o extends r.LitElement{constructor(t,i){super(),this._isReady=!1,this._elementName="epigraph-base-solution-lit",this._solutionVersion="",this._loggerContextOverride="[EPIGRAPH BASE SOLUTION]",this._environment=i,this._solutionVersion=t,this._xPath=e.Epigraph.generateXPath(this),this._uuid=e.Epigraph.safeGenerateUuid()??this._xPath,new e.Epigraph(this),this._isReady=!0,window.epigraph.logger.info({title:"Epigraph Base Solution Ready",contextOverride:this._loggerContextOverride})}get isReady(){return this._isReady}get environment(){return this._environment}get elementName(){return this._elementName}get solutionVersion(){return this._solutionVersion}get uuid(){return this._uuid}get xPath(){return this._xPath}disconnectedCallback(){window.epigraph.deregisterActiveComponent(this)}}exports.EpigraphBaseSolutionHtmlElement=s;exports.EpigraphBaseSolutionLitElement=o;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("../lit-element-CYaaFRfk.cjs"),e=require("./epigraph.cjs");class s extends HTMLElement{constructor(t,i){super(),this._isReady=!1,this._elementName="epigraph-base-solution-html",this._solutionVersion="",this._loggerContextOverride="[EPIGRAPH BASE SOLUTION]",this.attachShadow({mode:"open"}),this._environment=i,this._solutionVersion=t,this._xPath=e.Epigraph.generateXPath(this),this._uuid=e.Epigraph.safeGenerateUuid()??this._xPath,new e.Epigraph(this),window.epigraph.logger.info({title:"Epigraph Base Solution Ready",contextOverride:this._loggerContextOverride})}get isReady(){return this._isReady}get environment(){return this._environment}get elementName(){return this._elementName}get solutionVersion(){return this._solutionVersion}get uuid(){return this._uuid}get xPath(){return this._xPath}disconnectedCallback(){window.epigraph.deregisterActiveComponent(this)}}class o extends r.i{constructor(t,i){super(),this._isReady=!1,this._elementName="epigraph-base-solution-lit",this._solutionVersion="",this._loggerContextOverride="[EPIGRAPH BASE SOLUTION]",this._environment=i,this._solutionVersion=t,this._xPath=e.Epigraph.generateXPath(this),this._uuid=e.Epigraph.safeGenerateUuid()??this._xPath,new e.Epigraph(this),this._isReady=!0,window.epigraph.logger.info({title:"Epigraph Base Solution Ready",contextOverride:this._loggerContextOverride})}get isReady(){return this._isReady}get environment(){return this._environment}get elementName(){return this._elementName}get solutionVersion(){return this._solutionVersion}get uuid(){return this._uuid}get xPath(){return this._xPath}disconnectedCallback(){window.epigraph.deregisterActiveComponent(this)}}exports.EpigraphBaseSolutionHtmlElement=s;exports.EpigraphBaseSolutionLitElement=o;
@@ -1,4 +1,4 @@
1
- import { LitElement as s } from "lit";
1
+ import { i as s } from "../lit-element-C3moVMGu.js";
2
2
  import { Epigraph as e } from "./epigraph.js";
3
3
  class h extends HTMLElement {
4
4
  constructor(t, i) {
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("../EpigraphResultFactory/epigraphResultFactory.cjs");class P{constructor(e="https://api.myepigraph.com/api/",i,r,s="",a="",n="v1/"){this.epigraphXPath="",this.epigraphComponentVersion=s,this.epigraphSessionId=r,this.epigraphXPath=a,this.baseUrl=e+n,this.epgLocation=i}async getConfiguratorByExperienceId(e,i=""){const r={};i!==""&&(r.version_id=i);const s=`experience/configurator/experience_id/${e}`,a=this.buildNexusUrl(s,r);return await this.callNexusAPI(a,"GET")}async getConfiguratorByClientAccessKey(e,i=""){const r={};i!==""&&(r.version_id=i);const s=`experience/configurator/client_access_key/${e}`,a=this.buildNexusUrl(s,r);return await this.callNexusAPI(a,"GET")}async getConfiguratorLiteByExperienceId(e,i=""){const r={};i!==""&&(r.version_id=i);const s=`experience/configurator-lite/experience_id/${e}`,a=this.buildNexusUrl(s,r);return await this.callNexusAPI(a,"GET")}async getConfiguratorLiteByProjectId(e,i=""){const r={};i!==""&&(r.version_id=i);const s=`experience/configurator-lite/project_id/${e}`,a=this.buildNexusUrl(s,r);return await this.callNexusAPI(a,"GET")}async postExperienceSaveAndShare(e,i){const r="experience/"+e+"/save/",s=this.buildNexusUrl(r),a={save_data:JSON.stringify(i)},n=new Headers;return n.set("Content-Type","application/json"),await this.callNexusAPI(s,"POST",JSON.stringify(a),n)}async getExperienceSaveAndShare(e,i){const r="experience/"+e+"/save/"+i,s=this.buildNexusUrl(r);return await this.callNexusAPI(s,"GET")}async callNexusAPI(e,i="GET",r,s=new Headers){s=this.addRequiredHeaders(s);const a={method:i,body:r,headers:s};try{const n=await fetch(e,a),o=await n.json();if(!n.ok){let u="Unable to retrieve configurator experience";return o.message&&(u=o.message),Promise.resolve(c.failureResult(o,n.status,u))}return Promise.resolve(c.successResult(o,n.status))}catch{return Promise.resolve(c.failureResult({},500,"Unknown error"))}}buildNexusUrl(e,i={}){let r=new URL(this.baseUrl);r.pathname+=e;for(const[s,a]of Object.entries(i))r.searchParams.set(s,a);return r}addRequiredHeaders(e){return e.has("accept")||e.set("accept","application/json"),e.has("EPG-Location")||e.set("EPG-location",this.epgLocation),e.has("EPG-Session-ID")||e.set("EPG-Session-ID",this.epigraphSessionId),e.has("EPG-XPATH")||e.set("EPG-XPATH",this.epigraphXPath),e.has("EPG-Version")||e.set("EPG-Version",this.epigraphComponentVersion),e}}var p=(t=>(t.PRODUCTION="https://api.myepigraph.com/api/",t.STAGING="https://nexus.epigraph.dev/api/",t.LOCAL="https://nexus.test/api/",t))(p||{}),l=(t=>(t.CLIENT_ACCESS_KEY="client_access_key",t.EXPERIENCE_ID="experience_id",t.PROJECT_ID="project_id",t))(l||{}),h=(t=>(t.CONFIGURATOR="experience/configurator/",t.CONFIGURATOR_LITE="experience/configurator-lite/",t.EXPERIENCE="experience/",t.SAVE="save/",t))(h||{}),E=(t=>(t.V1="v1/",t))(E||{}),g=(t=>(t.GET="GET",t.POST="POST",t.PUT="PUT",t.DELETE="DELETE",t))(g||{});exports.EpigraphNexusAPI=P;exports.HTTPMethod=g;exports.NexusAPIResourceIdentifier=l;exports.NexusAPIRoutes=h;exports.NexusAPIVersions=E;exports.NexusEndpoints=p;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("../EpigraphResultFactory/epigraphResultFactory.cjs");class E{constructor(i="https://api.myepigraph.com/api/",t,e,r="",s="",a="v1/"){this.epigraphXPath="",this.epigraphComponentVersion=r,this.epigraphSessionId=e,this.epigraphXPath=s,this.baseUrl=i+a,this.epgLocation=t}async getButtonBySku(i,t=""){const e={};t!==""&&(e.version_id=t);const r=`experience/button/sku/${i}`,s=this.buildNexusUrl(r,e);return await this.callNexusAPI(s,"GET")}async getButtonByShopifyVariantId(i,t=""){const e={};t!==""&&(e.version_id=t);const r=`experience/button/shopify_variant_id/${i}`,s=this.buildNexusUrl(r,e);return await this.callNexusAPI(s,"GET")}async getButtonByUpc(i,t=""){const e={};t!==""&&(e.version_id=t);const r=`experience/button/upc/${i}`,s=this.buildNexusUrl(r,e);return await this.callNexusAPI(s,"GET")}async getButtonByAsin(i,t=""){const e={};t!==""&&(e.version_id=t);const r=`experience/button/asin/${i}`,s=this.buildNexusUrl(r,e);return await this.callNexusAPI(s,"GET")}async getViewerBySku(i,t=""){const e={};t!==""&&(e.version_id=t);const r=`experience/viewer/sku/${i}`,s=this.buildNexusUrl(r,e);return await this.callNexusAPI(s,"GET")}async getViewerByShopifyVariantId(i,t=""){const e={};t!==""&&(e.version_id=t);const r=`experience/viewer/shopify_variant_id/${i}`,s=this.buildNexusUrl(r,e);return await this.callNexusAPI(s,"GET")}async getViewerByUpc(i,t=""){const e={};t!==""&&(e.version_id=t);const r=`experience/viewer/upc/${i}`,s=this.buildNexusUrl(r,e);return await this.callNexusAPI(s,"GET")}async getViewerByAsin(i,t=""){const e={};t!==""&&(e.version_id=t);const r=`experience/viewer/asin/${i}`,s=this.buildNexusUrl(r,e);return await this.callNexusAPI(s,"GET")}async getTourBySku(i,t=""){const e={};t!==""&&(e.version_id=t);const r=`experience/tour/sku/${i}`,s=this.buildNexusUrl(r,e);return await this.callNexusAPI(s,"GET")}async getTourByShopifyVariantId(i,t=""){const e={};t!==""&&(e.version_id=t);const r=`experience/tour/shopify_variant_id/${i}`,s=this.buildNexusUrl(r,e);return await this.callNexusAPI(s,"GET")}async getTourByUpc(i,t=""){const e={};t!==""&&(e.version_id=t);const r=`experience/tour/upc/${i}`,s=this.buildNexusUrl(r,e);return await this.callNexusAPI(s,"GET")}async getTourByAsin(i,t=""){const e={};t!==""&&(e.version_id=t);const r=`experience/tour/asin/${i}`,s=this.buildNexusUrl(r,e);return await this.callNexusAPI(s,"GET")}async getConfiguratorByExperienceId(i,t=""){const e={};t!==""&&(e.version_id=t);const r=`experience/configurator/experience_id/${i}`,s=this.buildNexusUrl(r,e);return await this.callNexusAPI(s,"GET")}async getConfiguratorByClientAccessKey(i,t=""){const e={};t!==""&&(e.version_id=t);const r=`experience/configurator/client_access_key/${i}`,s=this.buildNexusUrl(r,e);return await this.callNexusAPI(s,"GET")}async getConfiguratorLiteByExperienceId(i,t=""){const e={};t!==""&&(e.version_id=t);const r=`experience/configurator-lite/experience_id/${i}`,s=this.buildNexusUrl(r,e);return await this.callNexusAPI(s,"GET")}async getConfiguratorLiteByProjectId(i,t=""){const e={};t!==""&&(e.version_id=t);const r=`experience/configurator-lite/project_id/${i}`,s=this.buildNexusUrl(r,e);return await this.callNexusAPI(s,"GET")}async postExperienceSaveAndShare(i,t){const e=`experience/${i}/save`,r=this.buildNexusUrl(e),s={save_data:JSON.stringify(t)},a=new Headers;return a.set("Content-Type","application/json"),await this.callNexusAPI(r,"POST",JSON.stringify(s),a)}async getExperienceSaveAndShare(i,t){const e=`experience/${i}/save/${t}`,r=this.buildNexusUrl(e);return await this.callNexusAPI(r,"GET")}async callNexusAPI(i,t="GET",e,r=new Headers){r=this.addRequiredHeaders(r);const s={method:t,body:e,headers:r};try{const a=await fetch(i,s),c=await a.json();if(!a.ok){let u="Unable to retrieve configurator experience";return c.message&&(u=c.message),Promise.resolve(o.failureResult(c,a.status,u))}return Promise.resolve(o.successResult(c,a.status))}catch{return Promise.resolve(o.failureResult({},500,"Unknown error"))}}buildNexusUrl(i,t={}){let e=new URL(this.baseUrl);e.pathname+=i;for(const[r,s]of Object.entries(t))e.searchParams.set(r,s);return e}addRequiredHeaders(i){return i.has("accept")||i.set("accept","application/json"),i.has("EPG-Location")||i.set("EPG-location",this.epgLocation),i.has("EPG-Session-ID")||i.set("EPG-Session-ID",this.epigraphSessionId),i.has("EPG-XPATH")||i.set("EPG-XPATH",this.epigraphXPath),i.has("EPG-Version")||i.set("EPG-Version",this.epigraphComponentVersion),i}}var l=(n=>(n.PRODUCTION="https://api.myepigraph.com/api/",n.STAGING="https://nexus.epigraph.dev/api/",n.LOCAL="https://nexus.test/api/",n))(l||{}),p=(n=>(n.CLIENT_ACCESS_KEY="client_access_key",n.EXPERIENCE_ID="experience_id",n.PROJECT_ID="project_id",n.SKU="sku",n.SHOPIFY_VARIANT_ID="shopify_variant_id",n.UPC="upc",n.ASIN="asin",n))(p||{}),h=(n=>(n.BUTTON="experience/button",n.VIEWER="experience/viewer",n.TOUR="experience/tour",n.CUSTOMIZER="experience/customizer",n.CONFIGURATOR="experience/configurator",n.CONFIGURATOR_LITE="experience/configurator-lite",n.EXPERIENCE="experience",n.SAVE="save",n))(h||{}),y=(n=>(n.V1="v1/",n))(y||{}),x=(n=>(n.GET="GET",n.POST="POST",n.PUT="PUT",n.DELETE="DELETE",n))(x||{});exports.EpigraphNexusAPI=E;exports.HTTPMethod=x;exports.NexusAPIResourceIdentifier=p;exports.NexusAPIRoutes=h;exports.NexusAPIVersions=y;exports.NexusEndpoints=l;
@@ -17,6 +17,27 @@ export declare class EpigraphNexusAPI {
17
17
  * @return {void}
18
18
  */
19
19
  constructor(baseUrl: NexusEndpoints | undefined, epgLocation: string, epigraphSessionId: string, epigraphComponentVersion?: string, epigraphXPath?: string, apiVersion?: NexusAPIVersions);
20
+ /*******************************************************************************************************************
21
+ * Epigraph Button API Calls *
22
+ ******************************************************************************************************************/
23
+ getButtonBySku(sku: string, versionId?: string): Promise<Result>;
24
+ getButtonByShopifyVariantId(shopify_variant_id: string, versionId?: string): Promise<Result>;
25
+ getButtonByUpc(upc: string, versionId?: string): Promise<Result>;
26
+ getButtonByAsin(asin: string, versionId?: string): Promise<Result>;
27
+ /*******************************************************************************************************************
28
+ * Epigraph Viewer API Calls *
29
+ ******************************************************************************************************************/
30
+ getViewerBySku(sku: string, versionId?: string): Promise<Result>;
31
+ getViewerByShopifyVariantId(shopify_variant_id: string, versionId?: string): Promise<Result>;
32
+ getViewerByUpc(upc: string, versionId?: string): Promise<Result>;
33
+ getViewerByAsin(asin: string, versionId?: string): Promise<Result>;
34
+ /*******************************************************************************************************************
35
+ * Epigraph Tour API Calls *
36
+ ******************************************************************************************************************/
37
+ getTourBySku(sku: string, versionId?: string): Promise<Result>;
38
+ getTourByShopifyVariantId(shopify_variant_id: string, versionId?: string): Promise<Result>;
39
+ getTourByUpc(upc: string, versionId?: string): Promise<Result>;
40
+ getTourByAsin(asin: string, versionId?: string): Promise<Result>;
20
41
  /*******************************************************************************************************************
21
42
  * Configurator API Calls *
22
43
  ******************************************************************************************************************/
@@ -63,13 +84,21 @@ export declare enum NexusEndpoints {
63
84
  export declare enum NexusAPIResourceIdentifier {
64
85
  CLIENT_ACCESS_KEY = "client_access_key",
65
86
  EXPERIENCE_ID = "experience_id",
66
- PROJECT_ID = "project_id"
87
+ PROJECT_ID = "project_id",
88
+ SKU = "sku",
89
+ SHOPIFY_VARIANT_ID = "shopify_variant_id",
90
+ UPC = "upc",
91
+ ASIN = "asin"
67
92
  }
68
93
  export declare enum NexusAPIRoutes {
69
- CONFIGURATOR = "experience/configurator/",
70
- CONFIGURATOR_LITE = "experience/configurator-lite/",
71
- EXPERIENCE = "experience/",
72
- SAVE = "save/"
94
+ BUTTON = "experience/button",
95
+ VIEWER = "experience/viewer",
96
+ TOUR = "experience/tour",
97
+ CUSTOMIZER = "experience/customizer",
98
+ CONFIGURATOR = "experience/configurator",
99
+ CONFIGURATOR_LITE = "experience/configurator-lite",
100
+ EXPERIENCE = "experience",
101
+ SAVE = "save"
73
102
  }
74
103
  export declare enum NexusAPIVersions {
75
104
  V1 = "v1/"
@@ -1,5 +1,5 @@
1
- import { failureResult as p, successResult as u } from "../EpigraphResultFactory/epigraphResultFactory.js";
2
- class x {
1
+ import { failureResult as u, successResult as l } from "../EpigraphResultFactory/epigraphResultFactory.js";
2
+ class P {
3
3
  /**
4
4
  * Constructs a new instance of the class with the provided parameters.
5
5
  *
@@ -11,63 +11,228 @@ class x {
11
11
  * @param {NexusAPIVersions} [apiVersion=NexusAPIVersions.V1] - The API version to use, defaulting to version 1.
12
12
  * @return {void}
13
13
  */
14
- constructor(e = "https://api.myepigraph.com/api/", i, r, s = "", n = "", a = "v1/") {
15
- this.epigraphXPath = "", this.epigraphComponentVersion = s, this.epigraphSessionId = r, this.epigraphXPath = n, this.baseUrl = e + a, this.epgLocation = i;
14
+ constructor(i = "https://api.myepigraph.com/api/", t, e, r = "", s = "", a = "v1/") {
15
+ this.epigraphXPath = "", this.epigraphComponentVersion = r, this.epigraphSessionId = e, this.epigraphXPath = s, this.baseUrl = i + a, this.epgLocation = t;
16
16
  }
17
17
  /*******************************************************************************************************************
18
- * Configurator API Calls *
18
+ * Epigraph Button API Calls *
19
19
  ******************************************************************************************************************/
20
- async getConfiguratorByExperienceId(e, i = "") {
21
- const r = {};
22
- i !== "" && (r.version_id = i);
23
- const s = `experience/configurator/experience_id/${e}`, n = this.buildNexusUrl(
20
+ async getButtonBySku(i, t = "") {
21
+ const e = {};
22
+ t !== "" && (e.version_id = t);
23
+ const r = `experience/button/sku/${i}`, s = this.buildNexusUrl(
24
+ r,
25
+ e
26
+ );
27
+ return await this.callNexusAPI(
24
28
  s,
25
- r
29
+ "GET"
30
+ /* GET */
31
+ );
32
+ }
33
+ async getButtonByShopifyVariantId(i, t = "") {
34
+ const e = {};
35
+ t !== "" && (e.version_id = t);
36
+ const r = `experience/button/shopify_variant_id/${i}`, s = this.buildNexusUrl(
37
+ r,
38
+ e
26
39
  );
27
40
  return await this.callNexusAPI(
28
- n,
41
+ s,
29
42
  "GET"
30
43
  /* GET */
31
44
  );
32
45
  }
33
- async getConfiguratorByClientAccessKey(e, i = "") {
34
- const r = {};
35
- i !== "" && (r.version_id = i);
36
- const s = `experience/configurator/client_access_key/${e}`, n = this.buildNexusUrl(
46
+ async getButtonByUpc(i, t = "") {
47
+ const e = {};
48
+ t !== "" && (e.version_id = t);
49
+ const r = `experience/button/upc/${i}`, s = this.buildNexusUrl(
50
+ r,
51
+ e
52
+ );
53
+ return await this.callNexusAPI(
37
54
  s,
38
- r
55
+ "GET"
56
+ /* GET */
57
+ );
58
+ }
59
+ async getButtonByAsin(i, t = "") {
60
+ const e = {};
61
+ t !== "" && (e.version_id = t);
62
+ const r = `experience/button/asin/${i}`, s = this.buildNexusUrl(
63
+ r,
64
+ e
39
65
  );
40
66
  return await this.callNexusAPI(
41
- n,
67
+ s,
42
68
  "GET"
43
69
  /* GET */
44
70
  );
45
71
  }
46
72
  /*******************************************************************************************************************
47
- * ConfiguratorLite API Calls *
73
+ * Epigraph Viewer API Calls *
48
74
  ******************************************************************************************************************/
49
- async getConfiguratorLiteByExperienceId(e, i = "") {
50
- const r = {};
51
- i !== "" && (r.version_id = i);
52
- const s = `experience/configurator-lite/experience_id/${e}`, n = this.buildNexusUrl(
75
+ async getViewerBySku(i, t = "") {
76
+ const e = {};
77
+ t !== "" && (e.version_id = t);
78
+ const r = `experience/viewer/sku/${i}`, s = this.buildNexusUrl(
79
+ r,
80
+ e
81
+ );
82
+ return await this.callNexusAPI(
53
83
  s,
54
- r
84
+ "GET"
85
+ /* GET */
86
+ );
87
+ }
88
+ async getViewerByShopifyVariantId(i, t = "") {
89
+ const e = {};
90
+ t !== "" && (e.version_id = t);
91
+ const r = `experience/viewer/shopify_variant_id/${i}`, s = this.buildNexusUrl(
92
+ r,
93
+ e
55
94
  );
56
95
  return await this.callNexusAPI(
57
- n,
96
+ s,
58
97
  "GET"
59
98
  /* GET */
60
99
  );
61
100
  }
62
- async getConfiguratorLiteByProjectId(e, i = "") {
63
- const r = {};
64
- i !== "" && (r.version_id = i);
65
- const s = `experience/configurator-lite/project_id/${e}`, n = this.buildNexusUrl(
101
+ async getViewerByUpc(i, t = "") {
102
+ const e = {};
103
+ t !== "" && (e.version_id = t);
104
+ const r = `experience/viewer/upc/${i}`, s = this.buildNexusUrl(
105
+ r,
106
+ e
107
+ );
108
+ return await this.callNexusAPI(
66
109
  s,
67
- r
110
+ "GET"
111
+ /* GET */
112
+ );
113
+ }
114
+ async getViewerByAsin(i, t = "") {
115
+ const e = {};
116
+ t !== "" && (e.version_id = t);
117
+ const r = `experience/viewer/asin/${i}`, s = this.buildNexusUrl(
118
+ r,
119
+ e
68
120
  );
69
121
  return await this.callNexusAPI(
70
- n,
122
+ s,
123
+ "GET"
124
+ /* GET */
125
+ );
126
+ }
127
+ /*******************************************************************************************************************
128
+ * Epigraph Tour API Calls *
129
+ ******************************************************************************************************************/
130
+ async getTourBySku(i, t = "") {
131
+ const e = {};
132
+ t !== "" && (e.version_id = t);
133
+ const r = `experience/tour/sku/${i}`, s = this.buildNexusUrl(
134
+ r,
135
+ e
136
+ );
137
+ return await this.callNexusAPI(
138
+ s,
139
+ "GET"
140
+ /* GET */
141
+ );
142
+ }
143
+ async getTourByShopifyVariantId(i, t = "") {
144
+ const e = {};
145
+ t !== "" && (e.version_id = t);
146
+ const r = `experience/tour/shopify_variant_id/${i}`, s = this.buildNexusUrl(
147
+ r,
148
+ e
149
+ );
150
+ return await this.callNexusAPI(
151
+ s,
152
+ "GET"
153
+ /* GET */
154
+ );
155
+ }
156
+ async getTourByUpc(i, t = "") {
157
+ const e = {};
158
+ t !== "" && (e.version_id = t);
159
+ const r = `experience/tour/upc/${i}`, s = this.buildNexusUrl(
160
+ r,
161
+ e
162
+ );
163
+ return await this.callNexusAPI(
164
+ s,
165
+ "GET"
166
+ /* GET */
167
+ );
168
+ }
169
+ async getTourByAsin(i, t = "") {
170
+ const e = {};
171
+ t !== "" && (e.version_id = t);
172
+ const r = `experience/tour/asin/${i}`, s = this.buildNexusUrl(
173
+ r,
174
+ e
175
+ );
176
+ return await this.callNexusAPI(
177
+ s,
178
+ "GET"
179
+ /* GET */
180
+ );
181
+ }
182
+ /*******************************************************************************************************************
183
+ * Configurator API Calls *
184
+ ******************************************************************************************************************/
185
+ async getConfiguratorByExperienceId(i, t = "") {
186
+ const e = {};
187
+ t !== "" && (e.version_id = t);
188
+ const r = `experience/configurator/experience_id/${i}`, s = this.buildNexusUrl(
189
+ r,
190
+ e
191
+ );
192
+ return await this.callNexusAPI(
193
+ s,
194
+ "GET"
195
+ /* GET */
196
+ );
197
+ }
198
+ async getConfiguratorByClientAccessKey(i, t = "") {
199
+ const e = {};
200
+ t !== "" && (e.version_id = t);
201
+ const r = `experience/configurator/client_access_key/${i}`, s = this.buildNexusUrl(
202
+ r,
203
+ e
204
+ );
205
+ return await this.callNexusAPI(
206
+ s,
207
+ "GET"
208
+ /* GET */
209
+ );
210
+ }
211
+ /*******************************************************************************************************************
212
+ * ConfiguratorLite API Calls *
213
+ ******************************************************************************************************************/
214
+ async getConfiguratorLiteByExperienceId(i, t = "") {
215
+ const e = {};
216
+ t !== "" && (e.version_id = t);
217
+ const r = `experience/configurator-lite/experience_id/${i}`, s = this.buildNexusUrl(
218
+ r,
219
+ e
220
+ );
221
+ return await this.callNexusAPI(
222
+ s,
223
+ "GET"
224
+ /* GET */
225
+ );
226
+ }
227
+ async getConfiguratorLiteByProjectId(i, t = "") {
228
+ const e = {};
229
+ t !== "" && (e.version_id = t);
230
+ const r = `experience/configurator-lite/project_id/${i}`, s = this.buildNexusUrl(
231
+ r,
232
+ e
233
+ );
234
+ return await this.callNexusAPI(
235
+ s,
71
236
  "GET"
72
237
  /* GET */
73
238
  );
@@ -75,20 +240,20 @@ class x {
75
240
  /*******************************************************************************************************************
76
241
  * Save & Share Calls *
77
242
  ******************************************************************************************************************/
78
- async postExperienceSaveAndShare(e, i) {
79
- const r = "experience/" + e + "/save/", s = this.buildNexusUrl(
80
- r
81
- ), n = {
82
- save_data: JSON.stringify(i)
243
+ async postExperienceSaveAndShare(i, t) {
244
+ const e = `experience/${i}/save`, r = this.buildNexusUrl(
245
+ e
246
+ ), s = {
247
+ save_data: JSON.stringify(t)
83
248
  }, a = new Headers();
84
- return a.set("Content-Type", "application/json"), await this.callNexusAPI(s, "POST", JSON.stringify(n), a);
249
+ return a.set("Content-Type", "application/json"), await this.callNexusAPI(r, "POST", JSON.stringify(s), a);
85
250
  }
86
- async getExperienceSaveAndShare(e, i) {
87
- const r = "experience/" + e + "/save/" + i, s = this.buildNexusUrl(
88
- r
251
+ async getExperienceSaveAndShare(i, t) {
252
+ const e = `experience/${i}/save/${t}`, r = this.buildNexusUrl(
253
+ e
89
254
  );
90
255
  return await this.callNexusAPI(
91
- s,
256
+ r,
92
257
  "GET"
93
258
  /* GET */
94
259
  );
@@ -103,32 +268,32 @@ class x {
103
268
  * @param headers
104
269
  * @return {Promise<Result>} A promise that resolves with the API response, encapsulated in a success or failure result format.
105
270
  */
106
- async callNexusAPI(e, i = "GET", r, s = new Headers()) {
107
- s = this.addRequiredHeaders(s);
108
- const n = {
109
- method: i,
110
- body: r,
111
- headers: s
271
+ async callNexusAPI(i, t = "GET", e, r = new Headers()) {
272
+ r = this.addRequiredHeaders(r);
273
+ const s = {
274
+ method: t,
275
+ body: e,
276
+ headers: r
112
277
  };
113
278
  try {
114
- const a = await fetch(e, n), c = await a.json();
279
+ const a = await fetch(i, s), c = await a.json();
115
280
  if (!a.ok) {
116
281
  let o = "Unable to retrieve configurator experience";
117
282
  return c.message && (o = c.message), Promise.resolve(
118
- p(c, a.status, o)
283
+ u(c, a.status, o)
119
284
  );
120
285
  }
121
- return Promise.resolve(u(c, a.status));
286
+ return Promise.resolve(l(c, a.status));
122
287
  } catch {
123
- return Promise.resolve(p({}, 500, "Unknown error"));
288
+ return Promise.resolve(u({}, 500, "Unknown error"));
124
289
  }
125
290
  }
126
- buildNexusUrl(e, i = {}) {
127
- let r = new URL(this.baseUrl);
128
- r.pathname += e;
129
- for (const [s, n] of Object.entries(i))
130
- r.searchParams.set(s, n);
131
- return r;
291
+ buildNexusUrl(i, t = {}) {
292
+ let e = new URL(this.baseUrl);
293
+ e.pathname += i;
294
+ for (const [r, s] of Object.entries(t))
295
+ e.searchParams.set(r, s);
296
+ return e;
132
297
  }
133
298
  /**
134
299
  * Adds required headers to the provided headers object if they are not already present.
@@ -138,16 +303,16 @@ class x {
138
303
  * @param {Headers} headers - The headers object to which the required headers will be added.
139
304
  * @return {Headers} The updated headers object containing all required headers.
140
305
  */
141
- addRequiredHeaders(e) {
142
- return e.has("accept") || e.set("accept", "application/json"), e.has("EPG-Location") || e.set("EPG-location", this.epgLocation), e.has("EPG-Session-ID") || e.set("EPG-Session-ID", this.epigraphSessionId), e.has("EPG-XPATH") || e.set("EPG-XPATH", this.epigraphXPath), e.has("EPG-Version") || e.set("EPG-Version", this.epigraphComponentVersion), e;
306
+ addRequiredHeaders(i) {
307
+ return i.has("accept") || i.set("accept", "application/json"), i.has("EPG-Location") || i.set("EPG-location", this.epgLocation), i.has("EPG-Session-ID") || i.set("EPG-Session-ID", this.epigraphSessionId), i.has("EPG-XPATH") || i.set("EPG-XPATH", this.epigraphXPath), i.has("EPG-Version") || i.set("EPG-Version", this.epigraphComponentVersion), i;
143
308
  }
144
309
  }
145
- var l = /* @__PURE__ */ ((t) => (t.PRODUCTION = "https://api.myepigraph.com/api/", t.STAGING = "https://nexus.epigraph.dev/api/", t.LOCAL = "https://nexus.test/api/", t))(l || {}), h = /* @__PURE__ */ ((t) => (t.CLIENT_ACCESS_KEY = "client_access_key", t.EXPERIENCE_ID = "experience_id", t.PROJECT_ID = "project_id", t))(h || {}), E = /* @__PURE__ */ ((t) => (t.CONFIGURATOR = "experience/configurator/", t.CONFIGURATOR_LITE = "experience/configurator-lite/", t.EXPERIENCE = "experience/", t.SAVE = "save/", t))(E || {}), g = /* @__PURE__ */ ((t) => (t.V1 = "v1/", t))(g || {}), P = /* @__PURE__ */ ((t) => (t.GET = "GET", t.POST = "POST", t.PUT = "PUT", t.DELETE = "DELETE", t))(P || {});
310
+ var p = /* @__PURE__ */ ((n) => (n.PRODUCTION = "https://api.myepigraph.com/api/", n.STAGING = "https://nexus.epigraph.dev/api/", n.LOCAL = "https://nexus.test/api/", n))(p || {}), h = /* @__PURE__ */ ((n) => (n.CLIENT_ACCESS_KEY = "client_access_key", n.EXPERIENCE_ID = "experience_id", n.PROJECT_ID = "project_id", n.SKU = "sku", n.SHOPIFY_VARIANT_ID = "shopify_variant_id", n.UPC = "upc", n.ASIN = "asin", n))(h || {}), y = /* @__PURE__ */ ((n) => (n.BUTTON = "experience/button", n.VIEWER = "experience/viewer", n.TOUR = "experience/tour", n.CUSTOMIZER = "experience/customizer", n.CONFIGURATOR = "experience/configurator", n.CONFIGURATOR_LITE = "experience/configurator-lite", n.EXPERIENCE = "experience", n.SAVE = "save", n))(y || {}), x = /* @__PURE__ */ ((n) => (n.V1 = "v1/", n))(x || {}), $ = /* @__PURE__ */ ((n) => (n.GET = "GET", n.POST = "POST", n.PUT = "PUT", n.DELETE = "DELETE", n))($ || {});
146
311
  export {
147
- x as EpigraphNexusAPI,
148
- P as HTTPMethod,
312
+ P as EpigraphNexusAPI,
313
+ $ as HTTPMethod,
149
314
  h as NexusAPIResourceIdentifier,
150
- E as NexusAPIRoutes,
151
- g as NexusAPIVersions,
152
- l as NexusEndpoints
315
+ y as NexusAPIRoutes,
316
+ x as NexusAPIVersions,
317
+ p as NexusEndpoints
153
318
  };