@mp-front/common 0.0.2-next.2 → 0.0.2-next.4
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/dist/cache-providers/redis/redis-cache.d.ts +1 -1
- package/dist/{client-DuXI9Ldu.js → client-Bdo9xBca.js} +65 -65
- package/dist/client-CCn8WzaX.cjs +1 -0
- package/dist/{encoder-CXAlLf5T.js → encoder-DQ28XRzN.js} +1 -1
- package/dist/{encoder-BEp9qfLf.cjs → encoder-DrKsNmKq.cjs} +1 -1
- package/dist/{encrypter-CgZLhLnj.cjs → encrypter-BQWKlKtz.cjs} +1 -1
- package/dist/{encrypter-ZTjrp3uD.js → encrypter-BXo3FT6G.js} +1 -1
- package/dist/http/client.d.ts.map +1 -1
- package/dist/{lodash-QjAkD17S.js → lodash-BzOkiDvV.js} +291 -274
- package/dist/{lodash-DNCgFYS7.cjs → lodash-DahFf0th.cjs} +5 -5
- package/dist/mp-front-common-all.cjs +1 -1
- package/dist/mp-front-common-all.js +3 -3
- package/dist/mp-front-common-cache.cjs +1 -1
- package/dist/mp-front-common-cache.js +2 -2
- package/dist/mp-front-common-cacheProviders.cjs +1 -1
- package/dist/mp-front-common-cacheProviders.js +1 -1
- package/dist/mp-front-common-engine.cjs +1 -1
- package/dist/mp-front-common-engine.js +1 -1
- package/dist/mp-front-common-helpers.cjs +1 -1
- package/dist/mp-front-common-helpers.js +2 -2
- package/dist/mp-front-common-http.cjs +1 -1
- package/dist/mp-front-common-http.js +1 -1
- package/dist/{redis-cache-HiNx0Kbv.js → redis-cache-BWqtENoP.js} +1 -1
- package/dist/{redis-cache-BstIlgPR.cjs → redis-cache-xm1YpsCP.cjs} +1 -1
- package/package.json +2 -2
- package/dist/client-AVep4jK5.cjs +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mp-front/common",
|
|
3
|
-
"version": "0.0.2-next.
|
|
3
|
+
"version": "0.0.2-next.4",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/mp-front-common-all.cjs",
|
|
@@ -83,7 +83,7 @@
|
|
|
83
83
|
"rxjs": "7.8.1"
|
|
84
84
|
},
|
|
85
85
|
"dependencies": {
|
|
86
|
-
"lodash": "4.17.
|
|
86
|
+
"lodash": "4.17.23",
|
|
87
87
|
"uuid": "9.0.1"
|
|
88
88
|
},
|
|
89
89
|
"devDependencies": {
|
package/dist/client-AVep4jK5.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";var D=Object.defineProperty;var x=(o,e,t)=>e in o?D(o,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[e]=t;var c=(o,e,t)=>x(o,typeof e!="symbol"?e+"":e,t);const i=require("rxjs"),O=require("./logger-BMbeDoGU.cjs");require("./lodash-DNCgFYS7.cjs");require("node-jose");require("crypto");const l=require("./default-errors-DiEIEEE2.cjs"),B=require("./fetch-BZP9DZLg.cjs"),L=require("./authorization-service-DkLS18Us.cjs"),$=require("./encoder-BEp9qfLf.cjs"),S=require("./loading-handler-BrN0O37N.cjs"),b=require("./v5-BTqP79vV.cjs");class q{constructor(e={}){c(this,"logger",new O.Logger);c(this,"headers");this.headers={Accept:"application/json","Content-Type":"application/vnd.api+json",...e}}addTokenBackend(e){return this.logger.logDebug("addTokenBackend HttpHeaders",JSON.stringify(e)),new L.AuthorizationService().get().pipe(i.switchMap(t=>i.of({...e,Authorization:`Bearer ${t}`})))}get(e){this.logger.logDebug("get HttpHeaders");const t=i.of({...this.headers});return e?t.pipe(i.switchMap(s=>this.addTokenBackend(s))):t}}const P=process.env.ID_FRONT??"NOT_AVAILABLE";class J{constructor(){c(this,"httpHeaders",new q);c(this,"logger",new O.Logger)}errorCatcher(e,t){var s,r,n;if(e!=null&&e.errors)throw new l.RuntimeError(((n=(r=(s=e.errors).at)==null?void 0:r.call(s,0))==null?void 0:n.code)??l.RuntimeErrorCode.DEFAULT,t??"");return!(e!=null&&e.errors)}get(e,t={}){const s=this.buildRequest("GET",e,null,t);return this.request(s)}post(e,t,s={}){const r=this.buildRequest("POST",e,t,s);return this.request(r)}put(e,t,s={}){const r=this.buildRequest("PUT",e,t,s);return this.request(r)}delete(e,t={}){const s=this.buildRequest("DELETE",e,null,t);return this.request(s)}formatParams(e,t){return JSON.stringify(t==="JSON:API"?{data:{type:P,attributes:e}}:e)}buildRequest(e,t,s,r){const n=r.format??"JSON:API",a={requestID:r==null?void 0:r.requestID,withCredentials:(r==null?void 0:r.withCredentials)??!0,url:t,headers:r.headers,method:e,selector:u=>u.json()};if(e==="GET"){const u=new URL(t);if(r.params)for(const E of Object.keys(r.params))u.searchParams.append(E,`${r.params[E]}`);return{...a,url:u.toString()}}return{...a,body:this.formatParams(s,n)}}request({url:e,requestID:t,withCredentials:s=!1,...r}){return this.httpHeaders.get(s).pipe(i.switchMap(n=>B.fromFetch(e,{...r,headers:{...r.headers,...n}}).pipe(i.catchError(a=>{throw this.logger.logError(JSON.stringify(a)),this.logger.logError(`HttpBackend \x1B[37m <URL>: \x1B[33m ${e} \x1B[37m <RequestID>: \x1B[33m ${t} \x1B[37m <HEADERS>: \x1B[33m ${JSON.stringify(n)} \x1B[37m <BODY>: \x1B[33m ${JSON.stringify(this.formatParams(r.body,r.format))} \x1B[37m <RESPONSE>: \x1B[33m ${JSON.stringify(a)} \x1B[33m`),new l.RuntimeError(l.RuntimeErrorCode.DEFAULT,t)}),i.switchMap(a=>(this.logger.logDebug(`HttpBackend \x1B[37m <URL>: \x1B[33m ${e} \x1B[37m <RequestID>: \x1B[33m ${t} \x1B[37m <HEADERS>: \x1B[33m ${JSON.stringify(n)} \x1B[37m <BODY>: \x1B[33m ${JSON.stringify(this.formatParams(r.body,r.format))} \x1B[37m <RESPONSE>: \x1B[33m ${JSON.stringify(a)} \x1B[33m`),i.of(a))))),i.filter(n=>this.errorCatcher(n,t)))}}const y="requestID",p="Content-Type";class I{constructor(){c(this,"httpHeaders",new q);c(this,"logger",new O.Logger);c(this,"encoder",new $.Encoder);c(this,"isLoadingEnabled",!0)}setIsLoadingEnabled(e){this.isLoadingEnabled=e}get(e,t={}){const s=this.buildRequest("GET",e,null,t);return this.request(s)}post(e,t,s={}){const r=this.buildRequest("POST",e,t,s);return this.request(r)}put(e,t,s={}){const r=this.buildRequest("PUT",e,t,s);return this.request(r)}patch(e,t,s={}){const r=this.buildRequest("PATCH",e,t,s);return this.request(r)}delete(e,t={}){const s=this.buildRequest("DELETE",e,null,t);return this.request(s)}buildRequest(e,t,s,r){const n={url:t,headers:r.headers,method:e,selector:d=>d.json()},a=new Date().toISOString(),u=b.v5(a,b.v5.URL);if(e==="GET"){const d=new URL(t,location.origin),m=r.params??{},H=Object.entries(m).reduce((h,N)=>{const[g,w]=N;if(h[g]=`${w}`,Object.hasOwn(m,g)){const f=m[g];f!=null&&(h[g]=f)}return h},{}),T=this.encoder.encode(H,u),R=JSON.parse(T);for(const h of Object.keys(R))d.searchParams.append(h,`${R[h]}`);return{...n,url:d.toString()}}if(new Headers(r.headers).get("Content-Type")==="multipart/form-data"){const d=s;return d.append(y,u),{...n,body:d}}return{...n,body:this.encoder.encode(s??{},u)}}request({url:e,...t}){return S.LoadingHandler.getInstance().setSubject(this.isLoadingEnabled),this.httpHeaders.get(!1).pipe(i.switchMap(s=>{const r={...s,...t.headers};return p in r&&r[p]==="multipart/form-data"&&delete r[p],B.fromFetch(e,{...t,headers:r}).pipe(i.switchMap(n=>i.of(this.encoder.decode(n))),i.switchMap(n=>{if("code"in n)throw n;return S.LoadingHandler.getInstance().setSubject(!1),this.logger.logDebug(`HttpClient <URL>: ${e} <HEADERS>: ${JSON.stringify(t.headers)} <BODY> ${JSON.stringify(t.body)} <RESPONSE>: ${JSON.stringify(n)}`),i.of(n)}),i.catchError(n=>(this.logger.logError(`HttpClient <URL>: ${e} <HEADERS>: ${JSON.stringify(t.headers)} <BODY> ${JSON.stringify(t.body)} <ERROR>: ${JSON.stringify(n)}`),S.LoadingHandler.getInstance().setSubject(!1),l.ErrorHandler.getInstance().setSubject(n),i.EMPTY)))}))}}exports.HttpBackend=J;exports.HttpClient=I;exports.HttpHeaders=q;exports.REQUEST_ID_KEY=y;
|