@kodaris/krubble-app-components 1.0.2 → 1.0.3

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,8 +1,8 @@
1
1
  (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@kodaris/krubble-components')) :
3
- typeof define === 'function' && define.amd ? define(['exports', '@kodaris/krubble-components'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.krApp = {}, global.kr));
5
- })(this, (function (exports, krubbleComponents) { 'use strict';
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@kodaris/krubble-components'), require('@kodaris/krubble-data')) :
3
+ typeof define === 'function' && define.amd ? define(['exports', '@kodaris/krubble-components', '@kodaris/krubble-data'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.krApp = {}, global.kr, global.krubbleData));
5
+ })(this, (function (exports, krubbleComponents, krubbleData) { 'use strict';
6
6
 
7
7
  /**
8
8
  * @license
@@ -923,74 +923,6 @@
923
923
  t$1('kr-shell')
924
924
  ], exports.KRShell);
925
925
 
926
- class KRClient {
927
- constructor() {
928
- this._url = `https://content.kodaris.com`;
929
- }
930
- static getInstance() {
931
- if (!KRClient._instance) {
932
- KRClient._instance = new KRClient();
933
- }
934
- return KRClient._instance;
935
- }
936
- fetch(options) {
937
- let url = options.url;
938
- // Add on the default base url if user
939
- // has not provided the full url
940
- if (url.indexOf('http') !== 0) {
941
- url = this._url + url;
942
- }
943
- if (options.params) {
944
- url += '?';
945
- Object.keys(options.params).forEach((key, keyIdx) => {
946
- if (keyIdx > 0) {
947
- url += '&';
948
- }
949
- url += `${key}=${options.params[key]}`;
950
- });
951
- }
952
- // fixme
953
- if (!options) {
954
- options = {};
955
- }
956
- if (!options.headers) {
957
- options.headers = {};
958
- }
959
- if (!options.headers['Content-Type']) {
960
- options.headers['Content-Type'] = 'application/json';
961
- }
962
- options.credentials = 'include';
963
- // User and Customer apis require CSRF tokens on non-GET reequests
964
- let token;
965
- if (url.indexOf('/api/user/') > -1 || url.indexOf('/api/customer/') > -1) {
966
- token = fetch(`${this._url}/api/user/customer/authToken`, { credentials: 'include' });
967
- }
968
- else {
969
- token = Promise.resolve(null);
970
- }
971
- let response;
972
- return token
973
- .then(res => res?.json())
974
- .then(res => {
975
- if (res?.data) {
976
- options.headers['X-CSRF-TOKEN'] = res.data;
977
- }
978
- return fetch(url, options);
979
- })
980
- .then(res => {
981
- response = res;
982
- return res.json();
983
- })
984
- .then(json => {
985
- if (!response?.ok) {
986
- return Promise.reject(json);
987
- }
988
- return Promise.resolve(json);
989
- });
990
- }
991
- }
992
- KRClient._instance = null;
993
-
994
926
  var __decorate$4 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
995
927
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
996
928
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -1266,7 +1198,7 @@
1266
1198
  /**
1267
1199
  * HTTP client for API calls
1268
1200
  */
1269
- this.http = KRClient.getInstance();
1201
+ this.http = krubbleData.KRClient.getInstance();
1270
1202
  /**
1271
1203
  * Default icon for nav items without an icon (shown at top level)
1272
1204
  */