@colabo-knalledge/i-core-services 1.0.0 → 1.1.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.
- package/CHANGELOG.md +22 -0
- package/dist/cjs/index.js +24 -7
- package/dist/cjs/index.js.map +2 -2
- package/dist/esm/index.js +23 -7
- package/dist/esm/index.js.map +2 -2
- package/dist/types/lib/cf.service.isomorphic.d.ts +3 -3
- package/dist/types/lib/colabo-api-core.service.d.ts +6 -2
- package/dist/types/lib/kContainer-service.d.ts +1 -1
- package/dist/types/lib/kEdge-service-extended.d.ts +1 -1
- package/dist/types/lib/kEdge-service.d.ts +1 -1
- package/dist/types/lib/kNode-service-extended.d.ts +1 -1
- package/dist/types/lib/kNode-service.d.ts +1 -1
- package/package.json +36 -14
package/dist/esm/index.js
CHANGED
|
@@ -185,27 +185,43 @@ var errorInterceptor = (error) => {
|
|
|
185
185
|
return Promise.reject(error);
|
|
186
186
|
};
|
|
187
187
|
if (DEBUG_VERBOSE) console.log("[ColaboApiCoreService] declaring ColaboApiCoreService class");
|
|
188
|
-
var ColaboApiCoreService = class
|
|
188
|
+
var ColaboApiCoreService = class {
|
|
189
189
|
// Add a response interceptor to remove JSONP prefix that Colabo.Space is sending
|
|
190
190
|
// https://docs.angularjs.org/api/ng/service/$http#json-vulnerability-protection
|
|
191
191
|
// https://stackoverflow.com/questions/33967189/angular-not-removing-json-prefix
|
|
192
192
|
// [Ejecting an interceptor #2615](https://github.com/axios/axios/issues/2615#issuecomment-567964331)
|
|
193
193
|
static initialize(namespace, specificAxios = axios) {
|
|
194
194
|
if (DEBUG_VERBOSE) console.log("[ColaboApiCoreService:initialize] Initializing interceptor for the namespace: ", namespace);
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
195
|
+
let axiosImplementation = this.interceptorsForAxios.get(specificAxios);
|
|
196
|
+
if (!axiosImplementation || typeof axiosImplementation.colaboApiInterceptorId === "undefined") {
|
|
197
|
+
const colaboApiInterceptorId = specificAxios.interceptors.response.use(responseInterceptor, errorInterceptor);
|
|
198
|
+
if (!axiosImplementation) {
|
|
199
|
+
axiosImplementation = {
|
|
200
|
+
colaboApiInterceptorId,
|
|
201
|
+
colaboApiInterceptorNamespace: namespace
|
|
202
|
+
};
|
|
203
|
+
this.interceptorsForAxios.set(specificAxios, axiosImplementation);
|
|
204
|
+
} else {
|
|
205
|
+
axiosImplementation.colaboApiInterceptorNamespace = namespace;
|
|
206
|
+
axiosImplementation.colaboApiInterceptorId = colaboApiInterceptorId;
|
|
207
|
+
}
|
|
198
208
|
if (DEBUG_VERBOSE) console.log("[ColaboApiCoreService:initialize] Initialized interceptor for the namespace: ", namespace);
|
|
199
209
|
} else {
|
|
200
|
-
if (DEBUG_VERBOSE) console.log("[ColaboApiCoreService:initialize] Skipping initialization. The colabo interceptor was already initialized for the namespace: ",
|
|
210
|
+
if (DEBUG_VERBOSE) console.log("[ColaboApiCoreService:initialize] Skipping initialization. The colabo interceptor was already initialized for the namespace: ", axiosImplementation.colaboApiInterceptorNamespace);
|
|
201
211
|
}
|
|
202
|
-
return
|
|
212
|
+
return axiosImplementation.colaboApiInterceptorId;
|
|
203
213
|
}
|
|
204
214
|
static destroy(namespace, specificAxios = axios) {
|
|
205
215
|
if (DEBUG_VERBOSE) console.log("[ColaboApiCoreService:initialize] Destroying interceptor for the namespace: ", namespace);
|
|
206
|
-
|
|
216
|
+
let axiosImplementation = this.interceptorsForAxios.get(specificAxios);
|
|
217
|
+
if (axiosImplementation) {
|
|
218
|
+
specificAxios.interceptors.request.eject(axiosImplementation.colaboApiInterceptorId);
|
|
219
|
+
} else {
|
|
220
|
+
console.log(`[ColaboApiCoreService:initialize] no axiosImplementation found for the provided axios`);
|
|
221
|
+
}
|
|
207
222
|
}
|
|
208
223
|
};
|
|
224
|
+
ColaboApiCoreService.interceptorsForAxios = /* @__PURE__ */ new Map();
|
|
209
225
|
injectInterceptorService(ColaboApiCoreService);
|
|
210
226
|
|
|
211
227
|
// lib/kContainer-service.ts
|