@one-commerce/sdk-core 1.19.6 → 1.19.8
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.
- package/lib/bundles/bundle.esm.js +3 -5
- package/lib/bundles/bundle.esm.js.map +1 -1
- package/lib/bundles/bundle.esm.min.js +1 -1
- package/lib/bundles/bundle.esm.min.js.map +1 -1
- package/lib/bundles/bundle.umd.js +3 -5
- package/lib/bundles/bundle.umd.js.map +1 -1
- package/lib/bundles/bundle.umd.min.js +1 -1
- package/lib/bundles/bundle.umd.min.js.map +1 -1
- package/lib/cjs/backoffice/context.js +2 -2
- package/lib/cjs/backoffice/context.js.map +1 -1
- package/lib/cjs/backoffice/services.js +2 -2
- package/lib/cjs/backoffice/services.js.map +1 -1
- package/lib/cjs/events.js.map +1 -1
- package/lib/cjs/index.js +3 -4
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/shop/services.js +2 -2
- package/lib/cjs/shop/services.js.map +1 -1
- package/lib/cjs/utils.js.map +1 -1
- package/lib/esm/backoffice/context.js.map +1 -1
- package/lib/esm/backoffice/services.js.map +1 -1
- package/lib/esm/events.js.map +1 -1
- package/lib/esm/index.js +1 -1
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/shop/services.js.map +1 -1
- package/lib/esm/utils.js.map +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"services.js","names":["BackofficeCatalog","call","id","BaseCallClass","BackofficeUser","BackofficeTenant","BackofficeLayout","BackofficeAuthorization","BackofficeCustomer","BackofficePlugin"],"sources":["../../../src/backoffice/services.ts"],"sourcesContent":["import { Backoffice } from \"@one-commerce/sdk-shared\";\nimport { BaseCallClass } from \"../utils\";\n\nexport class BackofficeCatalog extends BaseCallClass implements Backoffice.Catalog {\n serviceName = 'catalog'\n\n fetchCategories(): Promise<Array<unknown>> {\n return this.call('fetchCategories')\n }\n public fetchProduct(id: string): Promise<unknown> {\n return this.call('fetchProduct', id)\n }\n}\n\nexport class BackofficeUser extends BaseCallClass implements Backoffice.User {\n serviceName = 'user'\n email?: string;\n id!: string;\n name?: string;\n authorities!: Array<string>;\n}\n\nexport class BackofficeTenant extends BaseCallClass implements Backoffice.Tenant {\n serviceName = 'tenant'\n tenantKey?: string;\n language?: string;\n currency?: string;\n}\n\nexport class BackofficeLayout extends BaseCallClass implements Backoffice.Layout {\n serviceName = 'layout'\n isAsideOpened!: boolean;\n}\n\nexport class BackofficeAuthorization extends BaseCallClass implements Backoffice.Authorization {\n serviceName = 'authorization'\n\n getAuthToken(): Promise<string> {\n return this.call('getAuthToken')\n }\n}\n\nexport class BackofficeCustomer extends BaseCallClass implements Backoffice.Customer {\n serviceName = 'customer'\n id?: string;\n name?: string;\n}\n\nexport class BackofficePlugin extends BaseCallClass implements Backoffice.Plugin {\n serviceName = 'plugin'\n id: string;\n srcUrl?: string;\n name?: string;\n}\n"],"mappings":";;;;;;;;;AACA;;;;;;;;;;;;;;;;;;;;;;;;IAEaA,iB;;;;;;;;;;;;;;;;kEACG,S;;;;;;;WAEd,2BAA2C;MACzC,OAAO,KAAKC,IAAL,CAAU,iBAAV,CAAP;IACD;;;WACD,sBAAoBC,EAApB,EAAkD;MAChD,OAAO,KAAKD,IAAL,CAAU,cAAV,EAA0BC,EAA1B,CAAP;IACD;;;;EARoCC,oB;;;;IAW1BC,c;;;;;;;;;;;;;;;;mEACG,M;;;;;;;;;;;;;;EADoBD,oB;;;;IAQvBE,gB;;;;;;;;;;;;;;;;mEACG,Q;;;;;;;;;;;;EADsBF,oB;;;;IAOzBG,gB;;;;;;;;;;;;;;;;mEACG,Q;;;;;;;;EADsBH,oB;;;;IAKzBI,uB;;;;;;;;;;;;;;;;mEACG,e;;;;;;;WAEd,wBAAgC;MAC9B,OAAO,KAAKN,IAAL,CAAU,cAAV,CAAP;IACD;;;;EAL0CE,oB;;;;IAQhCK,kB;;;;;;;;;;;;;;;;mEACG,U;;;;;;;;;;EADwBL,oB;;;;IAM3BM,gB;;;;;;;;;;;;;;;;mEACG,Q;;;;;;;;;;;;EADsBN,oB"}
|
package/lib/cjs/events.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"events.js","names":["Events","_callbacks","key","callback","undefined","push","params","i","length"],"sources":["../../src/events.ts"],"sourcesContent":["class Events {\n _callbacks: Record<string, any>\n constructor () {\n this._callbacks = {}\n }\n\n on<T>(key: string, callback: (arg: T) => void) {\n // create an empty array for the event key\n if (this._callbacks[key] === undefined) { this._callbacks[key] = [] }\n // save the callback in the array for the event key\n this._callbacks[key].push(callback)\n }\n\n emit(key: string, ...params: Array<any>) {\n // if the key exists\n if (this._callbacks[key] !== undefined) {\n // iterate through the callbacks for the event key\n for (let i=0; i<this._callbacks[key].length; i++) {\n // trigger the callbacks with all provided params\n this._callbacks[key][i](...params)\n }\n }\n }\n}\n\nexport default Events\n"],"mappings":";;;;;;;;;;;;;;;IAAMA,M;EAEJ,kBAAe;IAAA;;IAAA;;IACb,KAAKC,UAAL,GAAkB,EAAlB;EACD;;;;WAED,YAAMC,GAAN,EAAmBC,QAAnB,EAA+C;MAC7C;MACA,IAAI,KAAKF,UAAL,CAAgBC,GAAhB,MAAyBE,SAA7B,EAAwC;QAAE,KAAKH,UAAL,CAAgBC,GAAhB,IAAuB,EAAvB;MAA2B,CAFxB,CAG7C;;;MACA,KAAKD,UAAL,CAAgBC,GAAhB,EAAqBG,IAArB,CAA0BF,QAA1B;IACD;;;WAED,cAAKD,GAAL,EAAyC;MACvC;MACA,IAAI,KAAKD,UAAL,CAAgBC,GAAhB,MAAyBE,SAA7B,EAAwC;QAAA,kCAFrBE,MAEqB;UAFrBA,MAEqB;QAAA;;QACtC;QACA,KAAK,IAAIC,CAAC,GAAC,CAAX,EAAcA,CAAC,GAAC,KAAKN,UAAL,CAAgBC,GAAhB,EAAqBM,MAArC,EAA6CD,CAAC,EAA9C,EAAkD;UAAA;;UAChD;UACA,6BAAKN,UAAL,CAAgBC,GAAhB,GAAqBK,CAArB,8BAA2BD,MAA3B;QACD;MACF;IACF;;;;;;eAGYN,M"}
|
package/lib/cjs/index.js
CHANGED
|
@@ -49,7 +49,7 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
|
|
|
49
49
|
|
|
50
50
|
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
51
51
|
|
|
52
|
-
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf
|
|
52
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
53
53
|
|
|
54
54
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
55
55
|
|
|
@@ -59,7 +59,7 @@ function _assertThisInitialized(self) { if (self === void 0) { throw new Referen
|
|
|
59
59
|
|
|
60
60
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
61
61
|
|
|
62
|
-
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
62
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
63
63
|
|
|
64
64
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
65
65
|
|
|
@@ -132,10 +132,9 @@ var Sdk = /*#__PURE__*/function (_Events) {
|
|
|
132
132
|
}
|
|
133
133
|
});
|
|
134
134
|
Sdk.log('Emitting INIT with payload ', _this.instances);
|
|
135
|
+
_this.isInitialized = true;
|
|
135
136
|
|
|
136
137
|
_this.emit(SdkInternalEvents.INIT, _this.instances);
|
|
137
|
-
|
|
138
|
-
_this.isInitialized = true;
|
|
139
138
|
});
|
|
140
139
|
|
|
141
140
|
_this.channel.subscribe(_sdkShared.Message.UPDATE, function (payload) {
|
package/lib/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.ts"],"names":["SdkInternalEvents","SdkEvents","Sdk","options","initializeServiceGetters","origin","channel","Channel","targetOrigin","target","window","parent","subscribe","Message","INIT","payload","log","Object","entries","instances","forEach","key","value","BaseCallClass","update","attributesForKey","warn","emit","isInitialized","UPDATE","FRAME_HEIGHT_REQUEST","autoheight","sendFrameHeight","connect","then","initializeHeightObserver","setupOptions","contextClass","callFunction","bind","keys","serviceName","defineProperty","get","body","document","html","documentElement","height","Math","max","scrollHeight","offsetHeight","clientHeight","postMessage","FRAME_HEIGHT_CHANGE","onMutationObserved","querySelector","config","attributes","attributeOldValue","characterData","characterDataOldValue","childList","subtree","heightMutationObserver","MutationObserver","observe","debug","context","service","fun","callId","METHOD_CALL","method","Promise","resolve","reject","onChannelMessage","response","unsubscribe","METHOD_RESULT","isException","result","event","NAVIGATION_PUSH","data","console","Events","BackofficeSdk","route","hash","query","catalog","BackofficeCatalog","user","BackofficeUser","tenant","BackofficeTenant","layout","BackofficeLayout","authorization","BackofficeAuthorization","customer","BackofficeCustomer","plugin","BackofficePlugin","initializeContextClass","ShopSdk","ShopAuthorization","cart","ShopCart","ShopCatalog","account","ShopAccount","utils","ShopUtils","ShopConfig","wishlist","ShopWishlist"],"mappings":";;;;;;;;;;;;;;;AAAA;;AAMA;;AAEA;;AAGA;;AASA;;AACA;;AASA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAIKA,iB;;WAAAA,iB;AAAAA,EAAAA,iB;AAAAA,EAAAA,iB;GAAAA,iB,KAAAA,iB;;IAIOC,S;;;WAAAA,S;AAAAA,EAAAA,S;AAAAA,EAAAA,S;GAAAA,S,yBAAAA,S;;IAuBGC,G;;;;;AAqCb,eAAYC,OAAZ,EAAiC;AAAA;;AAAA;;AAC/B;;AAD+B;;AAAA,iEAlCZ,IAkCY;;AAAA,6EAjCA,IAiCA;;AAAA;;AAAA,oEA/BjB,KA+BiB;;AAAA;;AAAA;;AAE/B,UAAKC,wBAAL;;AACA,UAAKC,MAAL,GAAcF,OAAO,CAACE,MAAtB;AACA,UAAKC,OAAL,GAAe,IAAIC,yBAAJ,CAAY;AACzBC,MAAAA,YAAY,EAAE,MAAKH,MADM;AAEzBI,MAAAA,MAAM,EAAEC,MAAM,CAACC;AAFU,KAAZ,CAAf;;AAIA,UAAKL,OAAL,CAAaM,SAAb,CAAuBC,mBAAQC,IAA/B,EAAqC,UAACC,OAAD,EAAkB;AACrDb,MAAAA,GAAG,CAACc,GAAJ,CAAQ,uBAAR;AACAC,MAAAA,MAAM,CAACC,OAAP,CAAe,MAAKC,SAApB,EAAgCC,OAAhC,CAAwC,gBAA6E;AAAA;AAAA,YAA3EC,GAA2E;AAAA,YAAtEC,KAAsE;;AACnH,YAAIA,KAAK,YAAYC,oBAArB,EAAoC;AAClCD,UAAAA,KAAK,CAACE,MAAN,CAAaT,OAAb;AACD,SAF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IC,sBAAJ,CAAgB,OAAK5E,YAAL,CAAkBC,IAAlB,gCAAhB,CARC;AASV4E,MAAAA,KAAK,EAAE,IAAIC,oBAAJ,CAAc,OAAK9E,YAAL,CAAkBC,IAAlB,gCAAd,CATG;AAUVmB,MAAAA,MAAM,EAAE,IAAI2D,qBAAJ,CAAe,OAAK/E,YAAL,CAAkBC,IAAlB,gCAAf,CAVE;AAWV+E,MAAAA,QAAQ,EAAE,IAAIC,uBAAJ,CAAiB,OAAKjF,YAAL,CAAkBC,IAAlB,gCAAjB;AAXA,K;;;;;;EADerC,G","sourcesContent":["import {\n Backoffice,\n Message,\n Route,\n Shop\n} from \"@one-commerce/sdk-shared\";\nimport Channel from \"iframe-channel\"\n\nimport {\n AddToCartContext,\n} from \"./backoffice/context\";\nimport {\n BackofficeAuthorization,\n BackofficeCatalog,\n BackofficeCustomer,\n BackofficeLayout,\n BackofficePlugin,\n BackofficeTenant,\n BackofficeUser,\n} from \"./backoffice/services\";\nimport Events from \"./events\";\nimport {\n ShopAccount,\n ShopAuthorization,\n ShopCart,\n ShopCatalog,\n ShopConfig,\n ShopUtils,\n ShopWishlist,\n} from \"./shop/services\";\nimport { BaseCallClass, generateCallId } from \"./utils\";\n\nexport type AvailableContext = AddToCartContext\n\nenum SdkInternalEvents {\n INIT='INIT',\n UPDATE='UPDATE'\n}\nexport enum SdkEvents {\n INIT='INIT',\n UPDATE='UPDATE',\n}\nexport interface SdkOptions {\n debug?: boolean\n autoheight?: boolean\n origin: string,\n context?: Class<AvailableContext>;\n}\n\ninterface NamedNavigationPayload {\n name: string\n params: any\n}\n\ninterface PathNavigationPayload {\n path: string\n params: any\n}\n\nexport type Class<T = any> = new (...args: any[]) => T;\n\nabstract class Sdk<T> extends Events {\n private channel!: Channel;\n private static debug = false\n private autoheight = true\n private heightMutationObserver = null\n origin: string;\n isInitialized = false\n instances!: T;\n contextClass?: Class<AvailableContext>;\n\n private static log(...data: any[]) {\n Sdk.debug && console.log('[SDK Core] ', ...data)\n }\n\n private static warn(...data: any[]) {\n console.warn('[SDK Core] ', ...data)\n }\n\n public initializeContextClass(): AvailableContext {\n if (this.contextClass) {\n return new this.contextClass(this.callFunction.bind(this))\n }\n return {} as AvailableContext\n }\n\n private initializeServiceGetters(): void {\n if (this.instances) {\n Object.keys(this.instances).forEach((serviceName: string) => {\n Object.defineProperty(this, serviceName, {\n get: () => {\n return this.isInitialized ? this.instances![serviceName as keyof T] : null\n }\n })\n })\n }\n }\n\n constructor(options: SdkOptions) {\n super()\n this.initializeServiceGetters()\n this.origin = options.origin\n this.channel = new Channel({\n targetOrigin: this.origin,\n target: window.parent,\n })\n this.channel.subscribe(Message.INIT, (payload: any) => {\n Sdk.log('Handling INIT message')\n Object.entries(this.instances!).forEach(([key, value]: [key: string, value: BaseCallClass | Record<string, any>]) => {\n if (value instanceof BaseCallClass) {\n value.update(payload)\n } else {\n const attributesForKey = payload[key]\n if (typeof attributesForKey !== 'undefined') {\n BaseCallClass.update(value as Record<string, any>, payload[key])\n } else {\n Sdk.warn(`Missing attributes for ${key} in `, payload)\n }\n }\n })\n Sdk.log('Emitting INIT with payload ', this.instances)\n this.emit(SdkInternalEvents.INIT, this.instances)\n this.isInitialized = true\n })\n this.channel.subscribe(Message.UPDATE, (payload: any) => {\n Sdk.log('Emitting UPDATE with payload ', payload)\n this.emit(SdkInternalEvents.UPDATE, payload)\n })\n this.channel.subscribe(Message.FRAME_HEIGHT_REQUEST, (payload: any) => {\n if (this.autoheight) {\n Sdk.log('Request for iframe height')\n this.sendFrameHeight()\n }\n })\n this.channel.connect().then(() => {\n Sdk.log('Connected with ONe SDK')\n if(this.autoheight) {\n this.initializeHeightObserver()\n }\n })\n this.setupOptions(options)\n Sdk.log('Initialized.')\n }\n\n private sendFrameHeight() {\n const body = document.body, html = document.documentElement;\n const height = Math.max(body.scrollHeight, body.offsetHeight,\n html.clientHeight, html.scrollHeight, html.offsetHeight);\n this.channel.postMessage(Message.FRAME_HEIGHT_CHANGE, height)\n }\n\n private initializeHeightObserver() {\n if (\"MutationObserver\" in window) {\n const onMutationObserved = () => {\n this.sendFrameHeight()\n }\n const target = document.querySelector('body'),\n config = {\n attributes: true,\n attributeOldValue: false,\n characterData: true,\n characterDataOldValue: false,\n childList: true,\n subtree: true\n }\n\n this.heightMutationObserver = new MutationObserver(onMutationObserved)\n\n Sdk.log('Create body MutationObserver')\n this.heightMutationObserver.observe(target, config)\n } else {\n Sdk.warn('MutationObserver not available. Auto-height functionality disabled.')\n }\n }\n\n private setupOptions(options?: SdkOptions) {\n if (options) {\n if (typeof options.debug !== 'undefined') {\n Sdk.debug = options.debug\n }\n if (typeof options.autoheight !== 'undefined') {\n this.autoheight = options.autoheight\n }\n this.contextClass = options.context\n }\n }\n protected callFunction(service: string, fun: string, ...payload: any) {\n const callId: string = generateCallId()\n if (this.isInitialized) {\n Sdk.log(`Call ID ${callId} for ${service}:${fun}`, payload)\n this.channel.postMessage(Message.METHOD_CALL, {\n callId,\n service,\n method: fun,\n payload: payload,\n })\n return new Promise((resolve, reject) => {\n const onChannelMessage = (response: any) => {\n if (response.callId === callId) {\n this.channel.unsubscribe(Message.METHOD_RESULT, onChannelMessage)\n if (response?.isException) {\n return reject(response.result);\n }\n\n return resolve(response.result);\n }\n }\n this.channel.subscribe(Message.METHOD_RESULT, onChannelMessage)\n })\n }\n Sdk.log('SDK is not initialized!')\n return Promise.resolve(null)\n }\n\n public navigate(event: NamedNavigationPayload | PathNavigationPayload) {\n this.channel.postMessage(Message.NAVIGATION_PUSH, event)\n }\n\n}\n\nexport interface BackofficeInstances extends Backoffice.Api {\n route: Route,\n catalog: BackofficeCatalog,\n user: BackofficeUser,\n tenant: BackofficeTenant,\n layout: BackofficeLayout,\n authorization: BackofficeAuthorization,\n customer: BackofficeCustomer,\n plugin: BackofficePlugin,\n context: AvailableContext\n}\n\nexport interface ShopInstances extends Shop.Api {\n authorization: ShopAuthorization,\n route: Route,\n cart: ShopCart,\n catalog: ShopCatalog,\n account: ShopAccount,\n utils: ShopUtils\n config: ShopConfig,\n wishlist: ShopWishlist,\n}\n\nexport class BackofficeSdk extends Sdk<BackofficeInstances> {\n instances = {\n route: {\n hash: '',\n query: {},\n },\n catalog: new BackofficeCatalog(this.callFunction.bind(this)),\n user: new BackofficeUser(this.callFunction.bind(this)),\n tenant: new BackofficeTenant(this.callFunction.bind(this)),\n layout: new BackofficeLayout(this.callFunction.bind(this)),\n authorization: new BackofficeAuthorization(this.callFunction.bind(this)),\n customer: new BackofficeCustomer(this.callFunction.bind(this)),\n plugin: new BackofficePlugin(this.callFunction.bind(this)),\n context: this.initializeContextClass()\n }\n}\n\nexport class ShopSdk extends Sdk<ShopInstances> {\n instances = {\n route: {\n hash: '',\n query: {},\n },\n authorization: new ShopAuthorization(this.callFunction.bind(this)),\n cart: new ShopCart(this.callFunction.bind(this)),\n catalog: new ShopCatalog(this.callFunction.bind(this)),\n account: new ShopAccount(this.callFunction.bind(this)),\n utils: new ShopUtils(this.callFunction.bind(this)),\n config: new ShopConfig(this.callFunction.bind(this)),\n wishlist: new ShopWishlist(this.callFunction.bind(this)),\n }\n}\n\nexport {\n AddToCartContext\n}\n"],"file":"index.js"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["SdkInternalEvents","SdkEvents","Sdk","options","initializeServiceGetters","origin","channel","Channel","targetOrigin","target","window","parent","subscribe","Message","INIT","payload","log","Object","entries","instances","forEach","key","value","BaseCallClass","update","attributesForKey","warn","isInitialized","emit","UPDATE","FRAME_HEIGHT_REQUEST","autoheight","sendFrameHeight","connect","then","initializeHeightObserver","setupOptions","contextClass","callFunction","bind","keys","serviceName","defineProperty","get","body","document","html","documentElement","height","Math","max","scrollHeight","offsetHeight","clientHeight","postMessage","FRAME_HEIGHT_CHANGE","onMutationObserved","querySelector","config","attributes","attributeOldValue","characterData","characterDataOldValue","childList","subtree","heightMutationObserver","MutationObserver","observe","debug","context","service","fun","callId","generateCallId","METHOD_CALL","method","Promise","resolve","reject","onChannelMessage","response","unsubscribe","METHOD_RESULT","isException","result","event","NAVIGATION_PUSH","data","console","Events","BackofficeSdk","route","hash","query","catalog","BackofficeCatalog","user","BackofficeUser","tenant","BackofficeTenant","layout","BackofficeLayout","authorization","BackofficeAuthorization","customer","BackofficeCustomer","plugin","BackofficePlugin","initializeContextClass","ShopSdk","ShopAuthorization","cart","ShopCart","ShopCatalog","account","ShopAccount","utils","ShopUtils","ShopConfig","wishlist","ShopWishlist"],"sources":["../../src/index.ts"],"sourcesContent":["import {\n Backoffice,\n Message,\n Route,\n Shop\n} from \"@one-commerce/sdk-shared\";\nimport Channel from \"iframe-channel\"\n\nimport {\n AddToCartContext,\n} from \"./backoffice/context\";\nimport {\n BackofficeAuthorization,\n BackofficeCatalog,\n BackofficeCustomer,\n BackofficeLayout,\n BackofficePlugin,\n BackofficeTenant,\n BackofficeUser,\n} from \"./backoffice/services\";\nimport Events from \"./events\";\nimport {\n ShopAccount,\n ShopAuthorization,\n ShopCart,\n ShopCatalog,\n ShopConfig,\n ShopUtils,\n ShopWishlist,\n} from \"./shop/services\";\nimport { BaseCallClass, generateCallId } from \"./utils\";\n\nexport type AvailableContext = AddToCartContext\n\nenum SdkInternalEvents {\n INIT='INIT',\n UPDATE='UPDATE'\n}\nexport enum SdkEvents {\n INIT='INIT',\n UPDATE='UPDATE',\n}\nexport interface SdkOptions {\n debug?: boolean\n autoheight?: boolean\n origin: string,\n context?: Class<AvailableContext>;\n}\n\ninterface NamedNavigationPayload {\n name: string\n params: any\n}\n\ninterface PathNavigationPayload {\n path: string\n params: any\n}\n\nexport type Class<T = any> = new (...args: any[]) => T;\n\nabstract class Sdk<T> extends Events {\n private channel!: Channel;\n private static debug = false\n private autoheight = true\n private heightMutationObserver = null\n origin: string;\n isInitialized = false\n instances!: T;\n contextClass?: Class<AvailableContext>;\n\n private static log(...data: any[]) {\n Sdk.debug && console.log('[SDK Core] ', ...data)\n }\n\n private static warn(...data: any[]) {\n console.warn('[SDK Core] ', ...data)\n }\n\n public initializeContextClass(): AvailableContext {\n if (this.contextClass) {\n return new this.contextClass(this.callFunction.bind(this))\n }\n return {} as AvailableContext\n }\n\n private initializeServiceGetters(): void {\n if (this.instances) {\n Object.keys(this.instances).forEach((serviceName: string) => {\n Object.defineProperty(this, serviceName, {\n get: () => {\n return this.isInitialized ? this.instances![serviceName as keyof T] : null\n }\n })\n })\n }\n }\n\n constructor(options: SdkOptions) {\n super()\n this.initializeServiceGetters()\n this.origin = options.origin\n this.channel = new Channel({\n targetOrigin: this.origin,\n target: window.parent,\n })\n this.channel.subscribe(Message.INIT, (payload: any) => {\n Sdk.log('Handling INIT message')\n Object.entries(this.instances!).forEach(([key, value]: [key: string, value: BaseCallClass | Record<string, any>]) => {\n if (value instanceof BaseCallClass) {\n value.update(payload)\n } else {\n const attributesForKey = payload[key]\n if (typeof attributesForKey !== 'undefined') {\n BaseCallClass.update(value as Record<string, any>, payload[key])\n } else {\n Sdk.warn(`Missing attributes for ${key} in `, payload)\n }\n }\n })\n Sdk.log('Emitting INIT with payload ', this.instances)\n this.isInitialized = true\n this.emit(SdkInternalEvents.INIT, this.instances)\n })\n this.channel.subscribe(Message.UPDATE, (payload: any) => {\n Sdk.log('Emitting UPDATE with payload ', payload)\n this.emit(SdkInternalEvents.UPDATE, payload)\n })\n this.channel.subscribe(Message.FRAME_HEIGHT_REQUEST, (payload: any) => {\n if (this.autoheight) {\n Sdk.log('Request for iframe height')\n this.sendFrameHeight()\n }\n })\n this.channel.connect().then(() => {\n Sdk.log('Connected with ONe SDK')\n if(this.autoheight) {\n this.initializeHeightObserver()\n }\n })\n this.setupOptions(options)\n Sdk.log('Initialized.')\n }\n\n private sendFrameHeight() {\n const body = document.body, html = document.documentElement;\n const height = Math.max(body.scrollHeight, body.offsetHeight,\n html.clientHeight, html.scrollHeight, html.offsetHeight);\n this.channel.postMessage(Message.FRAME_HEIGHT_CHANGE, height)\n }\n\n private initializeHeightObserver() {\n if (\"MutationObserver\" in window) {\n const onMutationObserved = () => {\n this.sendFrameHeight()\n }\n const target = document.querySelector('body'),\n config = {\n attributes: true,\n attributeOldValue: false,\n characterData: true,\n characterDataOldValue: false,\n childList: true,\n subtree: true\n }\n\n this.heightMutationObserver = new MutationObserver(onMutationObserved)\n\n Sdk.log('Create body MutationObserver')\n this.heightMutationObserver.observe(target, config)\n } else {\n Sdk.warn('MutationObserver not available. Auto-height functionality disabled.')\n }\n }\n\n private setupOptions(options?: SdkOptions) {\n if (options) {\n if (typeof options.debug !== 'undefined') {\n Sdk.debug = options.debug\n }\n if (typeof options.autoheight !== 'undefined') {\n this.autoheight = options.autoheight\n }\n this.contextClass = options.context\n }\n }\n protected callFunction(service: string, fun: string, ...payload: any) {\n const callId: string = generateCallId()\n if (this.isInitialized) {\n Sdk.log(`Call ID ${callId} for ${service}:${fun}`, payload)\n this.channel.postMessage(Message.METHOD_CALL, {\n callId,\n service,\n method: fun,\n payload: payload,\n })\n return new Promise((resolve, reject) => {\n const onChannelMessage = (response: any) => {\n if (response.callId === callId) {\n this.channel.unsubscribe(Message.METHOD_RESULT, onChannelMessage)\n if (response?.isException) {\n return reject(response.result);\n }\n\n return resolve(response.result);\n }\n }\n this.channel.subscribe(Message.METHOD_RESULT, onChannelMessage)\n })\n }\n Sdk.log('SDK is not initialized!')\n return Promise.resolve(null)\n }\n\n public navigate(event: NamedNavigationPayload | PathNavigationPayload) {\n this.channel.postMessage(Message.NAVIGATION_PUSH, event)\n }\n\n}\n\nexport interface BackofficeInstances extends Backoffice.Api {\n route: Route,\n catalog: BackofficeCatalog,\n user: BackofficeUser,\n tenant: BackofficeTenant,\n layout: BackofficeLayout,\n authorization: BackofficeAuthorization,\n customer: BackofficeCustomer,\n plugin: BackofficePlugin,\n context: AvailableContext\n}\n\nexport interface ShopInstances extends Shop.Api {\n authorization: ShopAuthorization,\n route: Route,\n cart: ShopCart,\n catalog: ShopCatalog,\n account: ShopAccount,\n utils: ShopUtils\n config: ShopConfig,\n wishlist: ShopWishlist,\n}\n\nexport class BackofficeSdk extends Sdk<BackofficeInstances> {\n instances = {\n route: {\n hash: '',\n query: {},\n },\n catalog: new BackofficeCatalog(this.callFunction.bind(this)),\n user: new BackofficeUser(this.callFunction.bind(this)),\n tenant: new BackofficeTenant(this.callFunction.bind(this)),\n layout: new BackofficeLayout(this.callFunction.bind(this)),\n authorization: new BackofficeAuthorization(this.callFunction.bind(this)),\n customer: new BackofficeCustomer(this.callFunction.bind(this)),\n plugin: new BackofficePlugin(this.callFunction.bind(this)),\n context: this.initializeContextClass()\n }\n}\n\nexport class ShopSdk extends Sdk<ShopInstances> {\n instances = {\n route: {\n hash: '',\n query: {},\n },\n authorization: new ShopAuthorization(this.callFunction.bind(this)),\n cart: new ShopCart(this.callFunction.bind(this)),\n catalog: new ShopCatalog(this.callFunction.bind(this)),\n account: new ShopAccount(this.callFunction.bind(this)),\n utils: new ShopUtils(this.callFunction.bind(this)),\n config: new ShopConfig(this.callFunction.bind(this)),\n wishlist: new ShopWishlist(this.callFunction.bind(this)),\n }\n}\n\nexport {\n AddToCartContext\n}\n"],"mappings":";;;;;;;;;;;;;;;AAAA;;AAMA;;AAEA;;AAGA;;AASA;;AACA;;AASA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAIKA,iB;;WAAAA,iB;EAAAA,iB;EAAAA,iB;GAAAA,iB,KAAAA,iB;;IAIOC,S;;;WAAAA,S;EAAAA,S;EAAAA,S;GAAAA,S,yBAAAA,S;;IAuBGC,G;;;;;EAqCb,aAAYC,OAAZ,EAAiC;IAAA;;IAAA;;IAC/B;;IAD+B;;IAAA,6DAlCZ,IAkCY;;IAAA,yEAjCA,IAiCA;;IAAA;;IAAA,gEA/BjB,KA+BiB;;IAAA;;IAAA;;IAE/B,MAAKC,wBAAL;;IACA,MAAKC,MAAL,GAAcF,OAAO,CAACE,MAAtB;IACA,MAAKC,OAAL,GAAe,IAAIC,yBAAJ,CAAY;MACzBC,YAAY,EAAE,MAAKH,MADM;MAEzBI,MAAM,EAAEC,MAAM,CAACC;IAFU,C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,YAAL,CAAkBC,IAAlB,gCAAhB,CAPC;MAQV2E,OAAO,EAAE,IAAIC,sBAAJ,CAAgB,OAAK7E,YAAL,CAAkBC,IAAlB,gCAAhB,CARC;MASV6E,KAAK,EAAE,IAAIC,oBAAJ,CAAc,OAAK/E,YAAL,CAAkBC,IAAlB,gCAAd,CATG;MAUVmB,MAAM,EAAE,IAAI4D,qBAAJ,CAAe,OAAKhF,YAAL,CAAkBC,IAAlB,gCAAf,CAVE;MAWVgF,QAAQ,EAAE,IAAIC,uBAAJ,CAAiB,OAAKlF,YAAL,CAAkBC,IAAlB,gCAAjB;IAXA,C;;;;;;EADerC,G"}
|
package/lib/cjs/shop/services.js
CHANGED
|
@@ -17,7 +17,7 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
|
|
|
17
17
|
|
|
18
18
|
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
19
19
|
|
|
20
|
-
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf
|
|
20
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
21
21
|
|
|
22
22
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
23
23
|
|
|
@@ -27,7 +27,7 @@ function _assertThisInitialized(self) { if (self === void 0) { throw new Referen
|
|
|
27
27
|
|
|
28
28
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
29
29
|
|
|
30
|
-
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
30
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
31
31
|
|
|
32
32
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
33
33
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"services.js","names":["ShopCatalog","productId","call","categoryId","BaseCallClass","ShopWishlist","wishlistId","newProduct","name","ShopAccount","ShopCart","amount","where","cartId","ShopAuthorization","ShopUtils","routes","getCategoryPath","getManufacturerSearchUrl","getProductUrl","isExternalUrl","id","manufacturer","product","url","ShopConfig"],"sources":["../../../src/shop/services.ts"],"sourcesContent":["import {Shop} from \"@one-commerce/sdk-shared\";\n\nimport {BaseCallClass} from \"../utils\";\n\nexport class ShopCatalog extends BaseCallClass implements Shop.Catalog {\n serviceName = 'catalog'\n categories!: Array<any>;\n selectedCategoryId!: string | null;\n\n fetchProduct(productId: string): Promise<any> {\n return this.call('fetchProduct', productId)\n }\n\n getCategoryById(categoryId: string): Promise<any> {\n return this.call('getCategoryById', categoryId)\n }\n}\nexport class ShopWishlist extends BaseCallClass implements Shop.Wishlist {\n serviceName = 'wishlist'\n\n addProductsToWishlist(wishlistId: string, newProduct: any): Promise<void> {\n return this.call('addProductsToWishlist', wishlistId, newProduct)\n }\n\n getWishlists(): Promise<any> {\n return this.call('getWishlists')\n }\n\n createWishlist(name: string): Promise<any> {\n return this.call('createWishlist', name)\n }\n}\nexport class ShopAccount extends BaseCallClass implements Shop.Account {\n serviceName = 'account'\n client!: {\n id: string;\n name: string;\n externalId?: string;\n tin?: string;\n phone?: string;\n segmentId?: string;\n segments: {\n additionalSegments?: Array<{\n id: string;\n name: string;\n externalId?: string;\n parentSegmentId?: string;\n }>;\n mainSegment: {\n id: string;\n name: string;\n externalId?: string;\n parentSegmentId?: string;\n };\n };\n warehouseId?: string;\n termPayment?: {\n id: string;\n label?: string;\n paymentDaysPeriod?: number;\n };\n isTaxPayer?: boolean;\n billingAddress?: {\n city: string;\n country: string;\n id: string;\n isDefault: boolean;\n name: string;\n phone: string;\n street: string;\n type: string;\n zipCode: string\n }\n };\n isAuthenticated!: boolean;\n user!: {\n id?: string,\n clientId?: string,\n email?: string;\n name?: string;\n phone?: string;\n rol?: {\n name: string;\n id: string;\n }\n /**\n * @deprecated Use non-nested function instead\n */\n hasSegment(name: string): Promise<boolean>\n };\n\n hasSegment(name: string): Promise<boolean> {\n return this.call('hasSegment', name)\n }\n\n manager!: {\n additionalEmail?: string;\n email: string; id: string;\n landlinePhone?: string;\n mobilePhone?: string;\n name: string;\n photo?: string\n };\n\n logout(): void {\n // NotImplementedYet\n }\n}\n\nexport class ShopCart extends BaseCallClass implements Shop.Cart {\n serviceName = 'cart'\n carts!: Array<any>;\n currentCart!: any;\n totalCartPrice!: number;\n\n addToCart(productId: string, amount: number, where: string, cartId?: string): Promise<void> {\n return this.call('addToCart', productId, amount, where, cartId)\n }\n}\n\nexport class ShopAuthorization extends BaseCallClass implements Shop.Authorization {\n serviceName = 'authorization'\n\n getAuthToken(): Promise<string> {\n return this.call('getAuthToken')\n }\n}\n\nexport class ShopUtils extends BaseCallClass implements Shop.Utils {\n serviceName = 'utils'\n currency!: any;\n isAnonymousAndPurchaseDisabled!: boolean;\n isB2B!: boolean;\n isB2BAndPlatformIsNotOpened!: boolean;\n isIndexPage!: boolean;\n isPurchaseEnabledOrAuthenticated!: boolean;\n\n constructor(call: (service: string, fun: string, ...arg: any) => Promise<any>) {\n super(call)\n this.routes = {\n getCategoryPath: this.getCategoryPath,\n getManufacturerSearchUrl: this.getManufacturerSearchUrl,\n getProductUrl: this.getProductUrl,\n isExternalUrl: this.isExternalUrl\n }\n }\n\n getCategoryPath(id?: string): Promise<string | null> {\n return this.call('getCategoryPath', id)\n }\n\n getManufacturerSearchUrl(manufacturer: string): Promise<string> {\n return this.call('getManufacturerSearchUrl', manufacturer)\n }\n\n getProductUrl(product: any): Promise<string | null> {\n return this.call('getProductUrl', product)\n }\n\n isExternalUrl(url: string): Promise<boolean> {\n return this.call('isExternalUrl', url)\n }\n\n routes: {\n /**\n * @deprecated Use non-nested function instead\n */\n getCategoryPath(id?: string): (Promise<string | null> | string | null);\n /**\n * @deprecated Use non-nested function instead\n */\n getManufacturerSearchUrl(manufacturer: string): (Promise<string> | string);\n /**\n * @deprecated Use non-nested function instead\n */\n getProductUrl(product: any): (Promise<string | null> | string | null);\n /**\n * @deprecated Use non-nested function instead\n */\n isExternalUrl(url: string): (Promise<boolean> | boolean)\n };\n}\n\nexport class ShopConfig extends BaseCallClass implements Shop.Config {\n serviceName = 'config'\n accessMode!: string;\n isB2CRegistrationEnabled!: boolean;\n isCatalogOpened!: boolean;\n isGrossSelected!: boolean;\n isPlatformClosed!: boolean;\n isPlatformOpened!: boolean;\n isPurchaseEnabled!: boolean;\n isRegistrationEnabled!: boolean;\n currency: any;\n}\n"],"mappings":";;;;;;;;;AAEA;;;;;;;;;;;;;;;;;;;;;;;;IAEaA,W;;;;;;;;;;;;;;;;kEACG,S;;;;;;;;;;;WAId,sBAAaC,SAAb,EAA8C;MAC5C,OAAO,KAAKC,IAAL,CAAU,cAAV,EAA0BD,SAA1B,CAAP;IACD;;;WAED,yBAAgBE,UAAhB,EAAkD;MAChD,OA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wB,EAAE,OAAKA,wBAFnB;MAGZC,aAAa,EAAE,OAAKA,aAHR;MAIZC,aAAa,EAAE,OAAKA;IAJR,CAAd;IAF6E;EAQ9E;;;;WAED,yBAAgBC,EAAhB,EAAqD;MACnD,OAAO,KAAKnB,IAAL,CAAU,iBAAV,EAA6BmB,EAA7B,CAAP;IACD;;;WAED,kCAAyBC,YAAzB,EAAgE;MAC9D,OAAO,KAAKpB,IAAL,CAAU,0BAAV,EAAsCoB,YAAtC,CAAP;IACD;;;WAED,uBAAcC,OAAd,EAAoD;MAClD,OAAO,KAAKrB,IAAL,CAAU,eAAV,EAA2BqB,OAA3B,CAAP;IACD;;;WAED,uBAAcC,GAAd,EAA6C;MAC3C,OAAO,KAAKtB,IAAL,CAAU,eAAV,EAA2BsB,GAA3B,CAAP;IACD;;;;EAjC4BpB,oB;;;;IAuDlBqB,U;;;;;;;;;;;;;;;;mEACG,Q;;;;;;;;;;;;;;;;;;;;;;;;EADgBrB,oB"}
|
package/lib/cjs/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"utils.js","names":["dec2hex","dec","toString","padStart","generateCallId","arr","Uint8Array","window","crypto","getRandomValues","Array","from","join","BaseCallClass","call","fun","arg","serviceName","payload","attributes","update","target","Object","keys","forEach","key"],"sources":["../../src/utils.ts"],"sourcesContent":["const dec2hex = (dec: number): string => {\n return dec.toString(16).padStart(2, \"0\")\n}\n\n// generateId :: Integer -> String\nexport function generateCallId () {\n const arr = new Uint8Array((10 || 40) / 2)\n window.crypto.getRandomValues(arr)\n return Array.from(arr, dec2hex).join('')\n}\n\nexport class BaseCallClass {\n serviceName = ''\n call: (fun: string, ...arg: any[]) => Promise<any>;\n constructor(call: (service: string, fun: string, ...arg: any) => Promise<any>) {\n this.call = (fun: string, ...arg: any) => {\n return call(this.serviceName, fun, ...arg)\n }\n }\n static update(target: Record<string, any>, payload: Record<string, any>) {\n Object.keys(payload).forEach((key: string) => {\n target[key] = payload[key]\n })\n }\n update(payload: any) {\n const attributes: any = payload[this.serviceName]\n if (attributes) {\n BaseCallClass.update(this, attributes)\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAAA,IAAMA,OAAO,GAAI,SAAXA,OAAW,CAACC,GAAD,EAAyB;EACxC,OAAOA,GAAG,CAACC,QAAJ,CAAa,EAAb,EAAiBC,QAAjB,CAA0B,CAA1B,EAA6B,GAA7B,CAAP;AACD,CAFD,C,CAIA;;;AACO,SAASC,cAAT,GAA2B;EAChC,IAAMC,GAAG,GAAG,IAAIC,UAAJ,CAAe,CAAC,MAAM,EAAP,IAAa,CAA5B,CAAZ;EACAC,MAAM,CAACC,MAAP,CAAcC,eAAd,CAA8BJ,GAA9B;EACA,OAAOK,KAAK,CAACC,IAAN,CAAWN,GAAX,EAAgBL,OAAhB,EAAyBY,IAAzB,CAA8B,EAA9B,CAAP;AACD;;IAEYC,a;EAGX,uBAAYC,IAAZ,EAA+E;IAAA;;IAAA;;IAAA,qCAFjE,EAEiE;;IAAA;;IAC7E,KAAKA,IAAL,GAAY,UAACC,GAAD,EAA8B;MAAA,kCAAbC,GAAa;QAAbA,GAAa;MAAA;;MACxC,OAAOF,IAAI,MAAJ,UAAK,KAAI,CAACG,WAAV,EAAuBF,GAAvB,SAA+BC,GAA/B,EAAP;IACD,CAFD;EAGD;;;;WAMD,gBAAOE,OAAP,EAAqB;MACnB,IAAMC,UAAe,GAAGD,OAAO,CAAC,KAAKD,WAAN,CAA/B;;MACA,IAAIE,UAAJ,EAAgB;QACdN,aAAa,CAACO,MAAd,CAAqB,IAArB,EAA2BD,UAA3B;MACD;IACF;;;WAVD,gBAAcE,MAAd,EAA2CH,OAA3C,EAAyE;MACvEI,MAAM,CAACC,IAAP,CAAYL,OAAZ,EAAqBM,OAArB,CAA6B,UAACC,GAAD,EAAiB;QAC5CJ,MAAM,CAACI,GAAD,CAAN,GAAcP,OAAO,CAACO,GAAD,CAArB;MACD,CAFD;IAGD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"context.js","names":["BaseCallClass","ContextCallClass","AddToCartContext","closePlugin","call","closePluginAndAddToCart","closePluginAndRefreshCart"],"sources":["../../../src/backoffice/context.ts"],"sourcesContent":["import {Backoffice} from \"@one-commerce/sdk-shared\";\nimport {BaseCallClass} from \"../utils\";\n\nclass ContextCallClass extends BaseCallClass {\n serviceName = 'context'\n}\n\nexport class AddToCartContext extends ContextCallClass implements Backoffice.Context.AddToCart {\n productId: string;\n cartId: string;\n warehouses: Array<any>;\n meta: unknown;\n closePlugin(): Promise<void> {\n return this.call('closePlugin')\n }\n closePluginAndAddToCart(): Promise<void> {\n return this.call('closePluginAndAddToCart')\n }\n closePluginAndRefreshCart(): Promise<void> {\n return this.call('closePluginAndRefreshCart')\n }\n}\n\nexport type AvailableContext = AddToCartContext\n"],"mappings":";;AACA,SAAQA,aAAR,QAA4B,UAA5B;;AAEA,MAAMC,gBAAN,SAA+BD,aAA/B,CAA6C;EAAA;IAAA;;IAAA,qCAC7B,SAD6B;EAAA;;AAAA;;AAI7C,OAAO,MAAME,gBAAN,SAA+BD,gBAA/B,CAAwF;EAAA;IAAA;;IAAA;;IAAA;;IAAA;;IAAA;EAAA;;EAK7FE,WAAW,GAAkB;IAC3B,OAAO,KAAKC,IAAL,CAAU,aAAV,CAAP;EACD;;EACDC,uBAAuB,GAAkB;IACvC,OAAO,KAAKD,IAAL,CAAU,yBAAV,CAAP;EACD;;EACDE,yBAAyB,GAAkB;IACzC,OAAO,KAAKF,IAAL,CAAU,2BAAV,CAAP;EACD;;AAb4F"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"services.js","names":["BaseCallClass","BackofficeCatalog","fetchCategories","call","fetchProduct","id","BackofficeUser","BackofficeTenant","BackofficeLayout","BackofficeAuthorization","getAuthToken","BackofficeCustomer","BackofficePlugin"],"sources":["../../../src/backoffice/services.ts"],"sourcesContent":["import { Backoffice } from \"@one-commerce/sdk-shared\";\nimport { BaseCallClass } from \"../utils\";\n\nexport class BackofficeCatalog extends BaseCallClass implements Backoffice.Catalog {\n serviceName = 'catalog'\n\n fetchCategories(): Promise<Array<unknown>> {\n return this.call('fetchCategories')\n }\n public fetchProduct(id: string): Promise<unknown> {\n return this.call('fetchProduct', id)\n }\n}\n\nexport class BackofficeUser extends BaseCallClass implements Backoffice.User {\n serviceName = 'user'\n email?: string;\n id!: string;\n name?: string;\n authorities!: Array<string>;\n}\n\nexport class BackofficeTenant extends BaseCallClass implements Backoffice.Tenant {\n serviceName = 'tenant'\n tenantKey?: string;\n language?: string;\n currency?: string;\n}\n\nexport class BackofficeLayout extends BaseCallClass implements Backoffice.Layout {\n serviceName = 'layout'\n isAsideOpened!: boolean;\n}\n\nexport class BackofficeAuthorization extends BaseCallClass implements Backoffice.Authorization {\n serviceName = 'authorization'\n\n getAuthToken(): Promise<string> {\n return this.call('getAuthToken')\n }\n}\n\nexport class BackofficeCustomer extends BaseCallClass implements Backoffice.Customer {\n serviceName = 'customer'\n id?: string;\n name?: string;\n}\n\nexport class BackofficePlugin extends BaseCallClass implements Backoffice.Plugin {\n serviceName = 'plugin'\n id: string;\n srcUrl?: string;\n name?: string;\n}\n"],"mappings":";;AACA,SAASA,aAAT,QAA8B,UAA9B;AAEA,OAAO,MAAMC,iBAAN,SAAgCD,aAAhC,CAA4E;EAAA;IAAA;;IAAA,qCACnE,SADmE;EAAA;;EAGjFE,eAAe,GAA4B;IACzC,OAAO,KAAKC,IAAL,CAAU,iBAAV,CAAP;EACD;;EACMC,YAAY,CAACC,EAAD,EAA+B;IAChD,OAAO,KAAKF,IAAL,CAAU,cAAV,EAA0BE,EAA1B,CAAP;EACD;;AARgF;AAWnF,OAAO,MAAMC,cAAN,SAA6BN,aAA7B,CAAsE;EAAA;IAAA;;IAAA,qCAC7D,MAD6D;;IAAA;;IAAA;;IAAA;;IAAA;EAAA;;AAAA;AAQ7E,OAAO,MAAMO,gBAAN,SAA+BP,aAA/B,CAA0E;EAAA;IAAA;;IAAA,qCACjE,QADiE;;IAAA;;IAAA;;IAAA;EAAA;;AAAA;AAOjF,OAAO,MAAMQ,gBAAN,SAA+BR,aAA/B,CAA0E;EAAA;IAAA;;IAAA,qCACjE,QADiE;;IAAA;EAAA;;AAAA;AAKjF,OAAO,MAAMS,uBAAN,SAAsCT,aAAtC,CAAwF;EAAA;IAAA;;IAAA,qCAC/E,eAD+E;EAAA;;EAG7FU,YAAY,GAAoB;IAC9B,OAAO,KAAKP,IAAL,CAAU,cAAV,CAAP;EACD;;AAL4F;AAQ/F,OAAO,MAAMQ,kBAAN,SAAiCX,aAAjC,CAA8E;EAAA;IAAA;;IAAA,qCACrE,UADqE;;IAAA;;IAAA;EAAA;;AAAA;AAMrF,OAAO,MAAMY,gBAAN,SAA+BZ,aAA/B,CAA0E;EAAA;IAAA;;IAAA,qCACjE,QADiE;;IAAA;;IAAA;;IAAA;EAAA;;AAAA"}
|
package/lib/esm/events.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"events.js","names":["Events","constructor","_callbacks","on","key","callback","undefined","push","emit","params","i","length"],"sources":["../../src/events.ts"],"sourcesContent":["class Events {\n _callbacks: Record<string, any>\n constructor () {\n this._callbacks = {}\n }\n\n on<T>(key: string, callback: (arg: T) => void) {\n // create an empty array for the event key\n if (this._callbacks[key] === undefined) { this._callbacks[key] = [] }\n // save the callback in the array for the event key\n this._callbacks[key].push(callback)\n }\n\n emit(key: string, ...params: Array<any>) {\n // if the key exists\n if (this._callbacks[key] !== undefined) {\n // iterate through the callbacks for the event key\n for (let i=0; i<this._callbacks[key].length; i++) {\n // trigger the callbacks with all provided params\n this._callbacks[key][i](...params)\n }\n }\n }\n}\n\nexport default Events\n"],"mappings":";;AAAA,MAAMA,MAAN,CAAa;EAEXC,WAAW,GAAI;IAAA;;IACb,KAAKC,UAAL,GAAkB,EAAlB;EACD;;EAEDC,EAAE,CAAIC,GAAJ,EAAiBC,QAAjB,EAA6C;IAC7C;IACA,IAAI,KAAKH,UAAL,CAAgBE,GAAhB,MAAyBE,SAA7B,EAAwC;MAAE,KAAKJ,UAAL,CAAgBE,GAAhB,IAAuB,EAAvB;IAA2B,CAFxB,CAG7C;;;IACA,KAAKF,UAAL,CAAgBE,GAAhB,EAAqBG,IAArB,CAA0BF,QAA1B;EACD;;EAEDG,IAAI,CAACJ,GAAD,EAAc,GAAGK,MAAjB,EAAqC;IACvC;IACA,IAAI,KAAKP,UAAL,CAAgBE,GAAhB,MAAyBE,SAA7B,EAAwC;MACtC;MACA,KAAK,IAAII,CAAC,GAAC,CAAX,EAAcA,CAAC,GAAC,KAAKR,UAAL,CAAgBE,GAAhB,EAAqBO,MAArC,EAA6CD,CAAC,EAA9C,EAAkD;QAChD;QACA,KAAKR,UAAL,CAAgBE,GAAhB,EAAqBM,CAArB,EAAwB,GAAGD,MAA3B;MACD;IACF;EACF;;AAtBU;;AAyBb,eAAeT,MAAf"}
|
package/lib/esm/index.js
CHANGED
|
@@ -89,8 +89,8 @@ class Sdk extends Events {
|
|
|
89
89
|
}
|
|
90
90
|
});
|
|
91
91
|
Sdk.log('Emitting INIT with payload ', this.instances);
|
|
92
|
-
this.emit(SdkInternalEvents.INIT, this.instances);
|
|
93
92
|
this.isInitialized = true;
|
|
93
|
+
this.emit(SdkInternalEvents.INIT, this.instances);
|
|
94
94
|
});
|
|
95
95
|
this.channel.subscribe(Message.UPDATE, payload => {
|
|
96
96
|
Sdk.log('Emitting UPDATE with payload ', payload);
|
package/lib/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.ts"],"names":["Message","Channel","AddToCartContext","BackofficeAuthorization","BackofficeCatalog","BackofficeCustomer","BackofficeLayout","BackofficePlugin","BackofficeTenant","BackofficeUser","Events","ShopAccount","ShopAuthorization","ShopCart","ShopCatalog","ShopConfig","ShopUtils","ShopWishlist","BaseCallClass","generateCallId","SdkInternalEvents","SdkEvents","Sdk","log","data","debug","console","warn","initializeContextClass","contextClass","callFunction","bind","initializeServiceGetters","instances","Object","keys","forEach","serviceName","defineProperty","get","isInitialized","constructor","options","origin","channel","targetOrigin","target","window","parent","subscribe","INIT","payload","entries","key","value","update","attributesForKey","emit","UPDATE","FRAME_HEIGHT_REQUEST","autoheight","sendFrameHeight","connect","then","initializeHeightObserver","setupOptions","body","document","html","documentElement","height","Math","max","scrollHeight","offsetHeight","clientHeight","postMessage","FRAME_HEIGHT_CHANGE","onMutationObserved","querySelector","config","attributes","attributeOldValue","characterData","characterDataOldValue","childList","subtree","heightMutationObserver","MutationObserver","observe","context","service","fun","callId","METHOD_CALL","method","Promise","resolve","reject","onChannelMessage","response","unsubscribe","METHOD_RESULT","isException","result","navigate","event","NAVIGATION_PUSH","BackofficeSdk","route","hash","query","catalog","user","tenant","layout","authorization","customer","plugin","ShopSdk","cart","account","utils","wishlist"],"mappings":";;AAAA,SAEEA,OAFF,QAKO,0BALP;AAMA,OAAOC,OAAP,MAAoB,gBAApB;AAEA,SACEC,gBADF,QAEO,sBAFP;AAGA,SACEC,uBADF,EAEEC,iBAFF,EAGEC,kBAHF,EAIEC,gBAJF,EAKEC,gBALF,EAMEC,gBANF,EAOEC,cAPF,QAQO,uBARP;AASA,OAAOC,MAAP,MAAmB,UAAnB;AACA,SACEC,WADF,EAEEC,iBAFF,EAGEC,QAHF,EAIEC,WAJF,EAKEC,UALF,EAMEC,SANF,EAOEC,YAPF,QAQO,iBARP;AASA,SAASC,aAAT,EAAwBC,cAAxB,QAA8C,SAA9C;IAIKC,iB;;WAAAA,iB;AAAAA,EAAAA,iB;AAAAA,EAAAA,iB;GAAAA,iB,KAAAA,iB;;AAIL,WAAYC,SAAZ;;WAAYA,S;AAAAA,EAAAA,S;AAAAA,EAAAA,S;GAAAA,S,KAAAA,S;;AAuBZ,MAAeC,GAAf,SAA8BZ,MAA9B,CAA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;AAAA;;AAAA;AAgBhD,SACE7B,gBADF","sourcesContent":["import {\n Backoffice,\n Message,\n Route,\n Shop\n} from \"@one-commerce/sdk-shared\";\nimport Channel from \"iframe-channel\"\n\nimport {\n AddToCartContext,\n} from \"./backoffice/context\";\nimport {\n BackofficeAuthorization,\n BackofficeCatalog,\n BackofficeCustomer,\n BackofficeLayout,\n BackofficePlugin,\n BackofficeTenant,\n BackofficeUser,\n} from \"./backoffice/services\";\nimport Events from \"./events\";\nimport {\n ShopAccount,\n ShopAuthorization,\n ShopCart,\n ShopCatalog,\n ShopConfig,\n ShopUtils,\n ShopWishlist,\n} from \"./shop/services\";\nimport { BaseCallClass, generateCallId } from \"./utils\";\n\nexport type AvailableContext = AddToCartContext\n\nenum SdkInternalEvents {\n INIT='INIT',\n UPDATE='UPDATE'\n}\nexport enum SdkEvents {\n INIT='INIT',\n UPDATE='UPDATE',\n}\nexport interface SdkOptions {\n debug?: boolean\n autoheight?: boolean\n origin: string,\n context?: Class<AvailableContext>;\n}\n\ninterface NamedNavigationPayload {\n name: string\n params: any\n}\n\ninterface PathNavigationPayload {\n path: string\n params: any\n}\n\nexport type Class<T = any> = new (...args: any[]) => T;\n\nabstract class Sdk<T> extends Events {\n private channel!: Channel;\n private static debug = false\n private autoheight = true\n private heightMutationObserver = null\n origin: string;\n isInitialized = false\n instances!: T;\n contextClass?: Class<AvailableContext>;\n\n private static log(...data: any[]) {\n Sdk.debug && console.log('[SDK Core] ', ...data)\n }\n\n private static warn(...data: any[]) {\n console.warn('[SDK Core] ', ...data)\n }\n\n public initializeContextClass(): AvailableContext {\n if (this.contextClass) {\n return new this.contextClass(this.callFunction.bind(this))\n }\n return {} as AvailableContext\n }\n\n private initializeServiceGetters(): void {\n if (this.instances) {\n Object.keys(this.instances).forEach((serviceName: string) => {\n Object.defineProperty(this, serviceName, {\n get: () => {\n return this.isInitialized ? this.instances![serviceName as keyof T] : null\n }\n })\n })\n }\n }\n\n constructor(options: SdkOptions) {\n super()\n this.initializeServiceGetters()\n this.origin = options.origin\n this.channel = new Channel({\n targetOrigin: this.origin,\n target: window.parent,\n })\n this.channel.subscribe(Message.INIT, (payload: any) => {\n Sdk.log('Handling INIT message')\n Object.entries(this.instances!).forEach(([key, value]: [key: string, value: BaseCallClass | Record<string, any>]) => {\n if (value instanceof BaseCallClass) {\n value.update(payload)\n } else {\n const attributesForKey = payload[key]\n if (typeof attributesForKey !== 'undefined') {\n BaseCallClass.update(value as Record<string, any>, payload[key])\n } else {\n Sdk.warn(`Missing attributes for ${key} in `, payload)\n }\n }\n })\n Sdk.log('Emitting INIT with payload ', this.instances)\n this.emit(SdkInternalEvents.INIT, this.instances)\n this.isInitialized = true\n })\n this.channel.subscribe(Message.UPDATE, (payload: any) => {\n Sdk.log('Emitting UPDATE with payload ', payload)\n this.emit(SdkInternalEvents.UPDATE, payload)\n })\n this.channel.subscribe(Message.FRAME_HEIGHT_REQUEST, (payload: any) => {\n if (this.autoheight) {\n Sdk.log('Request for iframe height')\n this.sendFrameHeight()\n }\n })\n this.channel.connect().then(() => {\n Sdk.log('Connected with ONe SDK')\n if(this.autoheight) {\n this.initializeHeightObserver()\n }\n })\n this.setupOptions(options)\n Sdk.log('Initialized.')\n }\n\n private sendFrameHeight() {\n const body = document.body, html = document.documentElement;\n const height = Math.max(body.scrollHeight, body.offsetHeight,\n html.clientHeight, html.scrollHeight, html.offsetHeight);\n this.channel.postMessage(Message.FRAME_HEIGHT_CHANGE, height)\n }\n\n private initializeHeightObserver() {\n if (\"MutationObserver\" in window) {\n const onMutationObserved = () => {\n this.sendFrameHeight()\n }\n const target = document.querySelector('body'),\n config = {\n attributes: true,\n attributeOldValue: false,\n characterData: true,\n characterDataOldValue: false,\n childList: true,\n subtree: true\n }\n\n this.heightMutationObserver = new MutationObserver(onMutationObserved)\n\n Sdk.log('Create body MutationObserver')\n this.heightMutationObserver.observe(target, config)\n } else {\n Sdk.warn('MutationObserver not available. Auto-height functionality disabled.')\n }\n }\n\n private setupOptions(options?: SdkOptions) {\n if (options) {\n if (typeof options.debug !== 'undefined') {\n Sdk.debug = options.debug\n }\n if (typeof options.autoheight !== 'undefined') {\n this.autoheight = options.autoheight\n }\n this.contextClass = options.context\n }\n }\n protected callFunction(service: string, fun: string, ...payload: any) {\n const callId: string = generateCallId()\n if (this.isInitialized) {\n Sdk.log(`Call ID ${callId} for ${service}:${fun}`, payload)\n this.channel.postMessage(Message.METHOD_CALL, {\n callId,\n service,\n method: fun,\n payload: payload,\n })\n return new Promise((resolve, reject) => {\n const onChannelMessage = (response: any) => {\n if (response.callId === callId) {\n this.channel.unsubscribe(Message.METHOD_RESULT, onChannelMessage)\n if (response?.isException) {\n return reject(response.result);\n }\n\n return resolve(response.result);\n }\n }\n this.channel.subscribe(Message.METHOD_RESULT, onChannelMessage)\n })\n }\n Sdk.log('SDK is not initialized!')\n return Promise.resolve(null)\n }\n\n public navigate(event: NamedNavigationPayload | PathNavigationPayload) {\n this.channel.postMessage(Message.NAVIGATION_PUSH, event)\n }\n\n}\n\nexport interface BackofficeInstances extends Backoffice.Api {\n route: Route,\n catalog: BackofficeCatalog,\n user: BackofficeUser,\n tenant: BackofficeTenant,\n layout: BackofficeLayout,\n authorization: BackofficeAuthorization,\n customer: BackofficeCustomer,\n plugin: BackofficePlugin,\n context: AvailableContext\n}\n\nexport interface ShopInstances extends Shop.Api {\n authorization: ShopAuthorization,\n route: Route,\n cart: ShopCart,\n catalog: ShopCatalog,\n account: ShopAccount,\n utils: ShopUtils\n config: ShopConfig,\n wishlist: ShopWishlist,\n}\n\nexport class BackofficeSdk extends Sdk<BackofficeInstances> {\n instances = {\n route: {\n hash: '',\n query: {},\n },\n catalog: new BackofficeCatalog(this.callFunction.bind(this)),\n user: new BackofficeUser(this.callFunction.bind(this)),\n tenant: new BackofficeTenant(this.callFunction.bind(this)),\n layout: new BackofficeLayout(this.callFunction.bind(this)),\n authorization: new BackofficeAuthorization(this.callFunction.bind(this)),\n customer: new BackofficeCustomer(this.callFunction.bind(this)),\n plugin: new BackofficePlugin(this.callFunction.bind(this)),\n context: this.initializeContextClass()\n }\n}\n\nexport class ShopSdk extends Sdk<ShopInstances> {\n instances = {\n route: {\n hash: '',\n query: {},\n },\n authorization: new ShopAuthorization(this.callFunction.bind(this)),\n cart: new ShopCart(this.callFunction.bind(this)),\n catalog: new ShopCatalog(this.callFunction.bind(this)),\n account: new ShopAccount(this.callFunction.bind(this)),\n utils: new ShopUtils(this.callFunction.bind(this)),\n config: new ShopConfig(this.callFunction.bind(this)),\n wishlist: new ShopWishlist(this.callFunction.bind(this)),\n }\n}\n\nexport {\n AddToCartContext\n}\n"],"file":"index.js"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["Message","Channel","AddToCartContext","BackofficeAuthorization","BackofficeCatalog","BackofficeCustomer","BackofficeLayout","BackofficePlugin","BackofficeTenant","BackofficeUser","Events","ShopAccount","ShopAuthorization","ShopCart","ShopCatalog","ShopConfig","ShopUtils","ShopWishlist","BaseCallClass","generateCallId","SdkInternalEvents","SdkEvents","Sdk","log","data","debug","console","warn","initializeContextClass","contextClass","callFunction","bind","initializeServiceGetters","instances","Object","keys","forEach","serviceName","defineProperty","get","isInitialized","constructor","options","origin","channel","targetOrigin","target","window","parent","subscribe","INIT","payload","entries","key","value","update","attributesForKey","emit","UPDATE","FRAME_HEIGHT_REQUEST","autoheight","sendFrameHeight","connect","then","initializeHeightObserver","setupOptions","body","document","html","documentElement","height","Math","max","scrollHeight","offsetHeight","clientHeight","postMessage","FRAME_HEIGHT_CHANGE","onMutationObserved","querySelector","config","attributes","attributeOldValue","characterData","characterDataOldValue","childList","subtree","heightMutationObserver","MutationObserver","observe","context","service","fun","callId","METHOD_CALL","method","Promise","resolve","reject","onChannelMessage","response","unsubscribe","METHOD_RESULT","isException","result","navigate","event","NAVIGATION_PUSH","BackofficeSdk","route","hash","query","catalog","user","tenant","layout","authorization","customer","plugin","ShopSdk","cart","account","utils","wishlist"],"sources":["../../src/index.ts"],"sourcesContent":["import {\n Backoffice,\n Message,\n Route,\n Shop\n} from \"@one-commerce/sdk-shared\";\nimport Channel from \"iframe-channel\"\n\nimport {\n AddToCartContext,\n} from \"./backoffice/context\";\nimport {\n BackofficeAuthorization,\n BackofficeCatalog,\n BackofficeCustomer,\n BackofficeLayout,\n BackofficePlugin,\n BackofficeTenant,\n BackofficeUser,\n} from \"./backoffice/services\";\nimport Events from \"./events\";\nimport {\n ShopAccount,\n ShopAuthorization,\n ShopCart,\n ShopCatalog,\n ShopConfig,\n ShopUtils,\n ShopWishlist,\n} from \"./shop/services\";\nimport { BaseCallClass, generateCallId } from \"./utils\";\n\nexport type AvailableContext = AddToCartContext\n\nenum SdkInternalEvents {\n INIT='INIT',\n UPDATE='UPDATE'\n}\nexport enum SdkEvents {\n INIT='INIT',\n UPDATE='UPDATE',\n}\nexport interface SdkOptions {\n debug?: boolean\n autoheight?: boolean\n origin: string,\n context?: Class<AvailableContext>;\n}\n\ninterface NamedNavigationPayload {\n name: string\n params: any\n}\n\ninterface PathNavigationPayload {\n path: string\n params: any\n}\n\nexport type Class<T = any> = new (...args: any[]) => T;\n\nabstract class Sdk<T> extends Events {\n private channel!: Channel;\n private static debug = false\n private autoheight = true\n private heightMutationObserver = null\n origin: string;\n isInitialized = false\n instances!: T;\n contextClass?: Class<AvailableContext>;\n\n private static log(...data: any[]) {\n Sdk.debug && console.log('[SDK Core] ', ...data)\n }\n\n private static warn(...data: any[]) {\n console.warn('[SDK Core] ', ...data)\n }\n\n public initializeContextClass(): AvailableContext {\n if (this.contextClass) {\n return new this.contextClass(this.callFunction.bind(this))\n }\n return {} as AvailableContext\n }\n\n private initializeServiceGetters(): void {\n if (this.instances) {\n Object.keys(this.instances).forEach((serviceName: string) => {\n Object.defineProperty(this, serviceName, {\n get: () => {\n return this.isInitialized ? this.instances![serviceName as keyof T] : null\n }\n })\n })\n }\n }\n\n constructor(options: SdkOptions) {\n super()\n this.initializeServiceGetters()\n this.origin = options.origin\n this.channel = new Channel({\n targetOrigin: this.origin,\n target: window.parent,\n })\n this.channel.subscribe(Message.INIT, (payload: any) => {\n Sdk.log('Handling INIT message')\n Object.entries(this.instances!).forEach(([key, value]: [key: string, value: BaseCallClass | Record<string, any>]) => {\n if (value instanceof BaseCallClass) {\n value.update(payload)\n } else {\n const attributesForKey = payload[key]\n if (typeof attributesForKey !== 'undefined') {\n BaseCallClass.update(value as Record<string, any>, payload[key])\n } else {\n Sdk.warn(`Missing attributes for ${key} in `, payload)\n }\n }\n })\n Sdk.log('Emitting INIT with payload ', this.instances)\n this.isInitialized = true\n this.emit(SdkInternalEvents.INIT, this.instances)\n })\n this.channel.subscribe(Message.UPDATE, (payload: any) => {\n Sdk.log('Emitting UPDATE with payload ', payload)\n this.emit(SdkInternalEvents.UPDATE, payload)\n })\n this.channel.subscribe(Message.FRAME_HEIGHT_REQUEST, (payload: any) => {\n if (this.autoheight) {\n Sdk.log('Request for iframe height')\n this.sendFrameHeight()\n }\n })\n this.channel.connect().then(() => {\n Sdk.log('Connected with ONe SDK')\n if(this.autoheight) {\n this.initializeHeightObserver()\n }\n })\n this.setupOptions(options)\n Sdk.log('Initialized.')\n }\n\n private sendFrameHeight() {\n const body = document.body, html = document.documentElement;\n const height = Math.max(body.scrollHeight, body.offsetHeight,\n html.clientHeight, html.scrollHeight, html.offsetHeight);\n this.channel.postMessage(Message.FRAME_HEIGHT_CHANGE, height)\n }\n\n private initializeHeightObserver() {\n if (\"MutationObserver\" in window) {\n const onMutationObserved = () => {\n this.sendFrameHeight()\n }\n const target = document.querySelector('body'),\n config = {\n attributes: true,\n attributeOldValue: false,\n characterData: true,\n characterDataOldValue: false,\n childList: true,\n subtree: true\n }\n\n this.heightMutationObserver = new MutationObserver(onMutationObserved)\n\n Sdk.log('Create body MutationObserver')\n this.heightMutationObserver.observe(target, config)\n } else {\n Sdk.warn('MutationObserver not available. Auto-height functionality disabled.')\n }\n }\n\n private setupOptions(options?: SdkOptions) {\n if (options) {\n if (typeof options.debug !== 'undefined') {\n Sdk.debug = options.debug\n }\n if (typeof options.autoheight !== 'undefined') {\n this.autoheight = options.autoheight\n }\n this.contextClass = options.context\n }\n }\n protected callFunction(service: string, fun: string, ...payload: any) {\n const callId: string = generateCallId()\n if (this.isInitialized) {\n Sdk.log(`Call ID ${callId} for ${service}:${fun}`, payload)\n this.channel.postMessage(Message.METHOD_CALL, {\n callId,\n service,\n method: fun,\n payload: payload,\n })\n return new Promise((resolve, reject) => {\n const onChannelMessage = (response: any) => {\n if (response.callId === callId) {\n this.channel.unsubscribe(Message.METHOD_RESULT, onChannelMessage)\n if (response?.isException) {\n return reject(response.result);\n }\n\n return resolve(response.result);\n }\n }\n this.channel.subscribe(Message.METHOD_RESULT, onChannelMessage)\n })\n }\n Sdk.log('SDK is not initialized!')\n return Promise.resolve(null)\n }\n\n public navigate(event: NamedNavigationPayload | PathNavigationPayload) {\n this.channel.postMessage(Message.NAVIGATION_PUSH, event)\n }\n\n}\n\nexport interface BackofficeInstances extends Backoffice.Api {\n route: Route,\n catalog: BackofficeCatalog,\n user: BackofficeUser,\n tenant: BackofficeTenant,\n layout: BackofficeLayout,\n authorization: BackofficeAuthorization,\n customer: BackofficeCustomer,\n plugin: BackofficePlugin,\n context: AvailableContext\n}\n\nexport interface ShopInstances extends Shop.Api {\n authorization: ShopAuthorization,\n route: Route,\n cart: ShopCart,\n catalog: ShopCatalog,\n account: ShopAccount,\n utils: ShopUtils\n config: ShopConfig,\n wishlist: ShopWishlist,\n}\n\nexport class BackofficeSdk extends Sdk<BackofficeInstances> {\n instances = {\n route: {\n hash: '',\n query: {},\n },\n catalog: new BackofficeCatalog(this.callFunction.bind(this)),\n user: new BackofficeUser(this.callFunction.bind(this)),\n tenant: new BackofficeTenant(this.callFunction.bind(this)),\n layout: new BackofficeLayout(this.callFunction.bind(this)),\n authorization: new BackofficeAuthorization(this.callFunction.bind(this)),\n customer: new BackofficeCustomer(this.callFunction.bind(this)),\n plugin: new BackofficePlugin(this.callFunction.bind(this)),\n context: this.initializeContextClass()\n }\n}\n\nexport class ShopSdk extends Sdk<ShopInstances> {\n instances = {\n route: {\n hash: '',\n query: {},\n },\n authorization: new ShopAuthorization(this.callFunction.bind(this)),\n cart: new ShopCart(this.callFunction.bind(this)),\n catalog: new ShopCatalog(this.callFunction.bind(this)),\n account: new ShopAccount(this.callFunction.bind(this)),\n utils: new ShopUtils(this.callFunction.bind(this)),\n config: new ShopConfig(this.callFunction.bind(this)),\n wishlist: new ShopWishlist(this.callFunction.bind(this)),\n }\n}\n\nexport {\n AddToCartContext\n}\n"],"mappings":";;AAAA,SAEEA,OAFF,QAKO,0BALP;AAMA,OAAOC,OAAP,MAAoB,gBAApB;AAEA,SACEC,gBADF,QAEO,sBAFP;AAGA,SACEC,uBADF,EAEEC,iBAFF,EAGEC,kBAHF,EAIEC,gBAJF,EAKEC,gBALF,EAMEC,gBANF,EAOEC,cAPF,QAQO,uBARP;AASA,OAAOC,MAAP,MAAmB,UAAnB;AACA,SACEC,WADF,EAEEC,iBAFF,EAGEC,QAHF,EAIEC,WAJF,EAKEC,UALF,EAMEC,SANF,EAOEC,YAPF,QAQO,iBARP;AASA,SAASC,aAAT,EAAwBC,cAAxB,QAA8C,SAA9C;IAIKC,iB;;WAAAA,iB;EAAAA,iB;EAAAA,iB;GAAAA,iB,KAAAA,iB;;AAIL,WAAYC,SAAZ;;WAAYA,S;EAAAA,S;EAAAA,S;GAAAA,S,KAAAA,S;;AAuBZ,MAAeC,GAAf,SAA8BZ,MAA9B,CAAqC;EAUjB,OAAHa,GAAG,CAAC,GAAGC,IAAJ,EAAiB;IACjCF,GAAG,CAACG,KAAJ,IAAaC,OAAO,CAACH,GAAR,CAAY,aAAZ,EAA2B,GAAGC,IAA9B,CAAb;EACD;;EAEkB,OAAJG,IAAI,CAAC,GAAGH,IAAJ,EAAiB;IAClCE,OAAO,CAACC,IAAR,CAAa,aAAb,EAA4B,GAAGH,IAA/B;EACD;;EAEMI,sBAAsB,GAAqB;IAChD,IAAI,KAAKC,YAAT,EAAuB;M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,CAAgB,KAAKgB,YAAL,CAAkBC,IAAlB,CAAuB,IAAvB,CAAhB,CAPC;MAQV0F,OAAO,EAAE,IAAI9G,WAAJ,CAAgB,KAAKmB,YAAL,CAAkBC,IAAlB,CAAuB,IAAvB,CAAhB,CARC;MASV2F,KAAK,EAAE,IAAI1G,SAAJ,CAAc,KAAKc,YAAL,CAAkBC,IAAlB,CAAuB,IAAvB,CAAd,CATG;MAUViD,MAAM,EAAE,IAAIjE,UAAJ,CAAe,KAAKe,YAAL,CAAkBC,IAAlB,CAAuB,IAAvB,CAAf,CAVE;MAWV4F,QAAQ,EAAE,IAAI1G,YAAJ,CAAiB,KAAKa,YAAL,CAAkBC,IAAlB,CAAuB,IAAvB,CAAjB;IAXA,CADkC;EAAA;;AAAA;AAgBhD,SACE7B,gBADF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"services.js","names":["BaseCallClass","ShopCatalog","fetchProduct","productId","call","getCategoryById","categoryId","ShopWishlist","addProductsToWishlist","wishlistId","newProduct","getWishlists","createWishlist","name","ShopAccount","hasSegment","logout","ShopCart","addToCart","amount","where","cartId","ShopAuthorization","getAuthToken","ShopUtils","constructor","routes","getCategoryPath","getManufacturerSearchUrl","getProductUrl","isExternalUrl","id","manufacturer","product","url","ShopConfig"],"sources":["../../../src/shop/services.ts"],"sourcesContent":["import {Shop} from \"@one-commerce/sdk-shared\";\n\nimport {BaseCallClass} from \"../utils\";\n\nexport class ShopCatalog extends BaseCallClass implements Shop.Catalog {\n serviceName = 'catalog'\n categories!: Array<any>;\n selectedCategoryId!: string | null;\n\n fetchProduct(productId: string): Promise<any> {\n return this.call('fetchProduct', productId)\n }\n\n getCategoryById(categoryId: string): Promise<any> {\n return this.call('getCategoryById', categoryId)\n }\n}\nexport class ShopWishlist extends BaseCallClass implements Shop.Wishlist {\n serviceName = 'wishlist'\n\n addProductsToWishlist(wishlistId: string, newProduct: any): Promise<void> {\n return this.call('addProductsToWishlist', wishlistId, newProduct)\n }\n\n getWishlists(): Promise<any> {\n return this.call('getWishlists')\n }\n\n createWishlist(name: string): Promise<any> {\n return this.call('createWishlist', name)\n }\n}\nexport class ShopAccount extends BaseCallClass implements Shop.Account {\n serviceName = 'account'\n client!: {\n id: string;\n name: string;\n externalId?: string;\n tin?: string;\n phone?: string;\n segmentId?: string;\n segments: {\n additionalSegments?: Array<{\n id: string;\n name: string;\n externalId?: string;\n parentSegmentId?: string;\n }>;\n mainSegment: {\n id: string;\n name: string;\n externalId?: string;\n parentSegmentId?: string;\n };\n };\n warehouseId?: string;\n termPayment?: {\n id: string;\n label?: string;\n paymentDaysPeriod?: number;\n };\n isTaxPayer?: boolean;\n billingAddress?: {\n city: string;\n country: string;\n id: string;\n isDefault: boolean;\n name: string;\n phone: string;\n street: string;\n type: string;\n zipCode: string\n }\n };\n isAuthenticated!: boolean;\n user!: {\n id?: string,\n clientId?: string,\n email?: string;\n name?: string;\n phone?: string;\n rol?: {\n name: string;\n id: string;\n }\n /**\n * @deprecated Use non-nested function instead\n */\n hasSegment(name: string): Promise<boolean>\n };\n\n hasSegment(name: string): Promise<boolean> {\n return this.call('hasSegment', name)\n }\n\n manager!: {\n additionalEmail?: string;\n email: string; id: string;\n landlinePhone?: string;\n mobilePhone?: string;\n name: string;\n photo?: string\n };\n\n logout(): void {\n // NotImplementedYet\n }\n}\n\nexport class ShopCart extends BaseCallClass implements Shop.Cart {\n serviceName = 'cart'\n carts!: Array<any>;\n currentCart!: any;\n totalCartPrice!: number;\n\n addToCart(productId: string, amount: number, where: string, cartId?: string): Promise<void> {\n return this.call('addToCart', productId, amount, where, cartId)\n }\n}\n\nexport class ShopAuthorization extends BaseCallClass implements Shop.Authorization {\n serviceName = 'authorization'\n\n getAuthToken(): Promise<string> {\n return this.call('getAuthToken')\n }\n}\n\nexport class ShopUtils extends BaseCallClass implements Shop.Utils {\n serviceName = 'utils'\n currency!: any;\n isAnonymousAndPurchaseDisabled!: boolean;\n isB2B!: boolean;\n isB2BAndPlatformIsNotOpened!: boolean;\n isIndexPage!: boolean;\n isPurchaseEnabledOrAuthenticated!: boolean;\n\n constructor(call: (service: string, fun: string, ...arg: any) => Promise<any>) {\n super(call)\n this.routes = {\n getCategoryPath: this.getCategoryPath,\n getManufacturerSearchUrl: this.getManufacturerSearchUrl,\n getProductUrl: this.getProductUrl,\n isExternalUrl: this.isExternalUrl\n }\n }\n\n getCategoryPath(id?: string): Promise<string | null> {\n return this.call('getCategoryPath', id)\n }\n\n getManufacturerSearchUrl(manufacturer: string): Promise<string> {\n return this.call('getManufacturerSearchUrl', manufacturer)\n }\n\n getProductUrl(product: any): Promise<string | null> {\n return this.call('getProductUrl', product)\n }\n\n isExternalUrl(url: string): Promise<boolean> {\n return this.call('isExternalUrl', url)\n }\n\n routes: {\n /**\n * @deprecated Use non-nested function instead\n */\n getCategoryPath(id?: string): (Promise<string | null> | string | null);\n /**\n * @deprecated Use non-nested function instead\n */\n getManufacturerSearchUrl(manufacturer: string): (Promise<string> | string);\n /**\n * @deprecated Use non-nested function instead\n */\n getProductUrl(product: any): (Promise<string | null> | string | null);\n /**\n * @deprecated Use non-nested function instead\n */\n isExternalUrl(url: string): (Promise<boolean> | boolean)\n };\n}\n\nexport class ShopConfig extends BaseCallClass implements Shop.Config {\n serviceName = 'config'\n accessMode!: string;\n isB2CRegistrationEnabled!: boolean;\n isCatalogOpened!: boolean;\n isGrossSelected!: boolean;\n isPlatformClosed!: boolean;\n isPlatformOpened!: boolean;\n isPurchaseEnabled!: boolean;\n isRegistrationEnabled!: boolean;\n currency: any;\n}\n"],"mappings":";;AAEA,SAAQA,aAAR,QAA4B,UAA5B;AAEA,OAAO,MAAMC,WAAN,SAA0BD,aAA1B,CAAgE;EAAA;IAAA;;IAAA,qCACvD,SADuD;;IAAA;;IAAA;EAAA;;EAKrEE,YAAY,CAACC,SAAD,EAAkC;IAC5C,OAAO,KAAKC,IAAL,CAAU,cAAV,EAA0BD,SAA1B,CAAP;EACD;;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CAAP;EACD;;AALgF;AAQnF,OAAO,MAAMoB,SAAN,SAAwBxB,aAAxB,CAA4D;EASjEyB,WAAW,CAACrB,IAAD,EAAoE;IAC7E,MAAMA,IAAN;;IAD6E,qCARjE,OAQiE;;IAAA;;IAAA;;IAAA;;IAAA;;IAAA;;IAAA;;IAAA;;IAE7E,KAAKsB,MAAL,GAAc;MACZC,eAAe,EAAE,KAAKA,eADV;MAEZC,wBAAwB,EAAE,KAAKA,wBAFnB;MAGZC,aAAa,EAAE,KAAKA,aAHR;MAIZC,aAAa,EAAE,KAAKA;IAJR,CAAd;EAMD;;EAEDH,eAAe,CAACI,EAAD,EAAsC;IACnD,OAAO,KAAK3B,IAAL,CAAU,iBAAV,EAA6B2B,EAA7B,CAAP;EACD;;EAEDH,wBAAwB,CAACI,YAAD,EAAwC;IAC9D,OAAO,KAAK5B,IAAL,CAAU,0BAAV,EAAsC4B,YAAtC,CAAP;EACD;;EAEDH,aAAa,CAACI,OAAD,EAAuC;IAClD,OAAO,KAAK7B,IAAL,CAAU,eAAV,EAA2B6B,OAA3B,CAAP;EACD;;EAEDH,aAAa,CAACI,GAAD,EAAgC;IAC3C,OAAO,KAAK9B,IAAL,CAAU,eAAV,EAA2B8B,GAA3B,CAAP;EACD;;AAjCgE;AAuDnE,OAAO,MAAMC,UAAN,SAAyBnC,aAAzB,CAA8D;EAAA;IAAA;;IAAA,qCACrD,QADqD;;IAAA;;IAAA;;IAAA;;IAAA;;IAAA;;IAAA;;IAAA;;IAAA;;IAAA;EAAA;;AAAA"}
|
package/lib/esm/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"utils.js","names":["dec2hex","dec","toString","padStart","generateCallId","arr","Uint8Array","window","crypto","getRandomValues","Array","from","join","BaseCallClass","constructor","call","fun","arg","serviceName","update","target","payload","Object","keys","forEach","key","attributes"],"sources":["../../src/utils.ts"],"sourcesContent":["const dec2hex = (dec: number): string => {\n return dec.toString(16).padStart(2, \"0\")\n}\n\n// generateId :: Integer -> String\nexport function generateCallId () {\n const arr = new Uint8Array((10 || 40) / 2)\n window.crypto.getRandomValues(arr)\n return Array.from(arr, dec2hex).join('')\n}\n\nexport class BaseCallClass {\n serviceName = ''\n call: (fun: string, ...arg: any[]) => Promise<any>;\n constructor(call: (service: string, fun: string, ...arg: any) => Promise<any>) {\n this.call = (fun: string, ...arg: any) => {\n return call(this.serviceName, fun, ...arg)\n }\n }\n static update(target: Record<string, any>, payload: Record<string, any>) {\n Object.keys(payload).forEach((key: string) => {\n target[key] = payload[key]\n })\n }\n update(payload: any) {\n const attributes: any = payload[this.serviceName]\n if (attributes) {\n BaseCallClass.update(this, attributes)\n }\n }\n}\n"],"mappings":";;AAAA,MAAMA,OAAO,GAAKC,GAAD,IAAyB;EACxC,OAAOA,GAAG,CAACC,QAAJ,CAAa,EAAb,EAAiBC,QAAjB,CAA0B,CAA1B,EAA6B,GAA7B,CAAP;AACD,CAFD,C,CAIA;;;AACA,OAAO,SAASC,cAAT,GAA2B;EAChC,MAAMC,GAAG,GAAG,IAAIC,UAAJ,CAAe,CAAC,MAAM,EAAP,IAAa,CAA5B,CAAZ;EACAC,MAAM,CAACC,MAAP,CAAcC,eAAd,CAA8BJ,GAA9B;EACA,OAAOK,KAAK,CAACC,IAAN,CAAWN,GAAX,EAAgBL,OAAhB,EAAyBY,IAAzB,CAA8B,EAA9B,CAAP;AACD;AAED,OAAO,MAAMC,aAAN,CAAoB;EAGzBC,WAAW,CAACC,IAAD,EAAoE;IAAA,qCAFjE,EAEiE;;IAAA;;IAC7E,KAAKA,IAAL,GAAY,CAACC,GAAD,EAAc,GAAGC,GAAjB,KAA8B;MACxC,OAAOF,IAAI,CAAC,KAAKG,WAAN,EAAmBF,GAAnB,EAAwB,GAAGC,GAA3B,CAAX;IACD,CAFD;EAGD;;EACY,OAANE,MAAM,CAACC,MAAD,EAA8BC,OAA9B,EAA4D;IACvEC,MAAM,CAACC,IAAP,CAAYF,OAAZ,EAAqBG,OAArB,CAA8BC,GAAD,IAAiB;MAC5CL,MAAM,CAACK,GAAD,CAAN,GAAcJ,OAAO,CAACI,GAAD,CAArB;IACD,CAFD;EAGD;;EACDN,MAAM,CAACE,OAAD,EAAe;IACnB,MAAMK,UAAe,GAAGL,OAAO,CAAC,KAAKH,WAAN,CAA/B;;IACA,IAAIQ,UAAJ,EAAgB;MACdb,aAAa,CAACM,MAAd,CAAqB,IAArB,EAA2BO,UAA3B;IACD;EACF;;AAlBwB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@one-commerce/sdk-core",
|
|
3
|
-
"version": "1.19.
|
|
3
|
+
"version": "1.19.8",
|
|
4
4
|
"description": "Core package for One Plugins",
|
|
5
5
|
"module": "lib/esm/index.js",
|
|
6
6
|
"main": "lib/cjs/index.js",
|
|
@@ -125,5 +125,5 @@
|
|
|
125
125
|
"**/*.spec.js"
|
|
126
126
|
]
|
|
127
127
|
},
|
|
128
|
-
"gitHead": "
|
|
128
|
+
"gitHead": "4fc075088ad4391fd1ab0d9a6c52b764f7487d4f"
|
|
129
129
|
}
|