@mp-front/common 0.0.1 → 0.0.2-next.1
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/README.md +1006 -1
- package/dist/cache-providers/redis/redis-cache.d.ts +6 -5
- package/dist/cache-providers/redis/redis-cache.d.ts.map +1 -1
- package/dist/cache-providers/redis/types/index.d.ts +4 -4
- package/dist/cache-providers/redis/types/index.d.ts.map +1 -1
- package/dist/{client-Bv9OflsW.cjs → client-BVAQF7Tb.cjs} +1 -1
- package/dist/{client-Btua9wfS.js → client-DKI6Ntcl.js} +32 -28
- package/dist/mp-front-common-all.cjs +1 -1
- package/dist/mp-front-common-all.js +1 -1
- package/dist/mp-front-common-cache.cjs +1 -1
- package/dist/mp-front-common-cache.js +20 -20
- package/dist/mp-front-common-cacheProviders.cjs +1 -1
- package/dist/mp-front-common-cacheProviders.js +1 -1
- package/dist/mp-front-common-http.cjs +1 -1
- package/dist/mp-front-common-http.js +1 -1
- package/dist/mp-front-common-rxjs.cjs +1 -1
- package/dist/mp-front-common-rxjs.js +4 -2
- package/dist/redis-cache-BstIlgPR.cjs +1 -0
- package/dist/{redis-cache-BoKAFYQi.js → redis-cache-HiNx0Kbv.js} +24 -21
- package/dist/rxjs/index.d.ts +1 -0
- package/dist/rxjs/index.d.ts.map +1 -1
- package/dist/types.d.ts +1 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/redis-cache-DjKTqllz.cjs +0 -1
|
@@ -1,23 +1,24 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ISetStateParams } from './types';
|
|
2
2
|
export declare class RedisCache<T> {
|
|
3
3
|
private readonly encrypter;
|
|
4
4
|
private readonly initClient;
|
|
5
5
|
private getRootNode;
|
|
6
6
|
private getEntryPoint;
|
|
7
7
|
private setEntryPoint;
|
|
8
|
-
|
|
8
|
+
get<T>(prefix: string, idData: string): Promise<{
|
|
9
9
|
sha: string;
|
|
10
10
|
data: T;
|
|
11
11
|
}>;
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
delete(prefix: string, idData: string): Promise<void>;
|
|
13
|
+
set({ prefix, idData, body, expire, encrypted, refresh, }: ISetStateParams<T>): Promise<string>;
|
|
14
14
|
statusHost<T>(): Promise<T>;
|
|
15
15
|
killRedis(): void;
|
|
16
16
|
deleteKey(key: string): void;
|
|
17
17
|
ttl(key: string, time: number): void;
|
|
18
18
|
simpleGet(key: string): Promise<string>;
|
|
19
19
|
simpleHGet(key: string, field: string): Promise<string>;
|
|
20
|
-
|
|
20
|
+
simpleHGetBuffer(key: string, field: string): Promise<Buffer>;
|
|
21
|
+
simpleHSet<T extends string | number | Buffer = string>(key: string, field: string, value: T): Promise<number>;
|
|
21
22
|
simpleHGetAll(key: string): Promise<Record<string, string>>;
|
|
22
23
|
}
|
|
23
24
|
//# sourceMappingURL=redis-cache.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"redis-cache.d.ts","sourceRoot":"","sources":["../../../src/cache-providers/redis/redis-cache.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"redis-cache.d.ts","sourceRoot":"","sources":["../../../src/cache-providers/redis/redis-cache.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAA;AAKpE,qBAAa,UAAU,CAAC,CAAC;IACvB,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAkB;IAC5C,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAkB;IAE7C,OAAO,CAAC,WAAW;YAIL,aAAa;IAS3B,OAAO,CAAC,aAAa;IAKR,GAAG,CAAC,CAAC,EAChB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,GACb,OAAO,CAAC;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,CAAC,CAAA;KAAE,CAAC;IAkBvB,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;IAKrC,GAAG,CAAC,EACf,MAAM,EACN,MAAM,EACN,IAAI,EACJ,MAAM,EACN,SAAiB,EACjB,OAA8B,GAC/B,EAAE,eAAe,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC;IAc1B,UAAU,CAAC,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC;IAYjC,SAAS;IAIT,SAAS,CAAC,GAAG,EAAE,MAAM;IAIrB,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM;IAI7B,SAAS,CAAC,GAAG,EAAE,MAAM;IAKrB,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM;IAKrC,gBAAgB,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM;IAK3C,UAAU,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,EAC3D,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,CAAC;IAKH,aAAa,CAAC,GAAG,EAAE,MAAM;CAGjC"}
|
|
@@ -2,12 +2,12 @@ export declare enum RefreshState {
|
|
|
2
2
|
NOT_REFRESH = "NOT_REFRESH",
|
|
3
3
|
REFRESH = "REFRESH"
|
|
4
4
|
}
|
|
5
|
-
export interface
|
|
5
|
+
export interface ISetStateParams<T> {
|
|
6
6
|
/**
|
|
7
|
-
* ``
|
|
8
|
-
*
|
|
7
|
+
* ``prefix``
|
|
8
|
+
* Prefix to get url
|
|
9
9
|
*/
|
|
10
|
-
|
|
10
|
+
prefix: string;
|
|
11
11
|
/**
|
|
12
12
|
* ``idData``
|
|
13
13
|
* ID to get data
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/cache-providers/redis/types/index.ts"],"names":[],"mappings":"AAAA,oBAAY,YAAY;IACtB,WAAW,gBAAgB;IAC3B,OAAO,YAAY;CACpB;AAED,MAAM,WAAW,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/cache-providers/redis/types/index.ts"],"names":[],"mappings":"AAAA,oBAAY,YAAY;IACtB,WAAW,gBAAgB;IAC3B,OAAO,YAAY;CACpB;AAED,MAAM,WAAW,eAAe,CAAC,CAAC;IAChC;;;OAGG;IACH,MAAM,EAAE,MAAM,CAAA;IACd;;;OAGG;IACH,MAAM,EAAE,MAAM,CAAA;IACd;;;OAGG;IACH,IAAI,EAAE,CAAC,CAAA;IACP;;;OAGG;IACH,MAAM,EAAE,MAAM,CAAA;IACd;;;OAGG;IACH,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB;;;OAGG;IACH,OAAO,CAAC,EAAE,YAAY,CAAA;CACvB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var w=Object.defineProperty;var N=(c,e,t)=>e in c?w(c,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):c[e]=t;var o=(c,e,t)=>N(c,typeof e!="symbol"?e+"":e,t);const i=require("rxjs"),S=require("./logger-BMbeDoGU.cjs");require("./lodash-DNCgFYS7.cjs");require("node-jose");require("crypto");const l=require("./default-errors-DiEIEEE2.cjs"),
|
|
1
|
+
"use strict";var w=Object.defineProperty;var N=(c,e,t)=>e in c?w(c,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):c[e]=t;var o=(c,e,t)=>N(c,typeof e!="symbol"?e+"":e,t);const i=require("rxjs"),S=require("./logger-BMbeDoGU.cjs");require("./lodash-DNCgFYS7.cjs");require("node-jose");require("crypto");const l=require("./default-errors-DiEIEEE2.cjs"),y=require("./fetch-BZP9DZLg.cjs"),x=require("./authorization-service-DkLS18Us.cjs"),D=require("./encoder-BEp9qfLf.cjs"),p=require("./loading-handler-BrN0O37N.cjs"),b=require("./v5-BTqP79vV.cjs");class O{constructor(e={}){o(this,"logger",new S.Logger);o(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 x.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 L=process.env.ID_FRONT??"NOT_AVAILABLE";class ${constructor(){o(this,"httpHeaders",new O);o(this,"logger",new S.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:L,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 m of Object.keys(r.params))u.searchParams.append(m,`${r.params[m]}`);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=>y.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)))}}class J{constructor(){o(this,"httpHeaders",new O);o(this,"logger",new S.Logger);o(this,"encoder",new D.Encoder);o(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),f=r.params??{},B=Object.entries(f).reduce((h,H)=>{const[g,T]=H;if(h[g]=`${T}`,Object.hasOwn(f,g)){const E=f[g];E!=null&&(h[g]=E)}return h},{}),R=this.encoder.encode(B,u),q=JSON.parse(R);for(const h of Object.keys(q))d.searchParams.append(h,`${q[h]}`);return{...n,url:d.toString()}}if(new Headers(r.headers).get("Content-Type")==="multipart/form-data"){const d=s;return d.append("requestID",u),{...n,body:d}}return{...n,body:this.encoder.encode(s??{},u)}}request({url:e,...t}){return p.LoadingHandler.getInstance().setSubject(this.isLoadingEnabled),this.httpHeaders.get(!1).pipe(i.switchMap(s=>{const r={...s,...t.headers};return"Content-Type"in r&&r["Content-Type"]==="multipart/form-data"&&delete r["Content-Type"],y.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 p.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)}`),p.LoadingHandler.getInstance().setSubject(!1),l.ErrorHandler.getInstance().setSubject(n),i.EMPTY)))}))}}exports.HttpBackend=$;exports.HttpClient=J;exports.HttpHeaders=O;
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
var $ = Object.defineProperty;
|
|
2
2
|
var L = (o, e, t) => e in o ? $(o, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[e] = t;
|
|
3
3
|
var i = (o, e, t) => L(o, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
-
import { switchMap as
|
|
4
|
+
import { switchMap as d, of as m, catchError as R, filter as w, EMPTY as J } from "rxjs";
|
|
5
5
|
import { L as S } from "./logger-DtlFWyFO.js";
|
|
6
6
|
import "./lodash-QjAkD17S.js";
|
|
7
7
|
import "node-jose";
|
|
8
8
|
import "crypto";
|
|
9
|
-
import { R as b, a as
|
|
9
|
+
import { R as b, a as y, E as P } from "./default-errors-DsKmUZbG.js";
|
|
10
10
|
import { f as T } from "./fetch-CUIb9XhZ.js";
|
|
11
11
|
import { A } from "./authorization-service-DE-hoYji.js";
|
|
12
12
|
import { E as I } from "./encoder-CXAlLf5T.js";
|
|
13
13
|
import { L as E } from "./loading-handler-ivYFmS_V.js";
|
|
14
|
-
import { v as
|
|
14
|
+
import { v as B } from "./v5-Cu1sjPlx.js";
|
|
15
15
|
class q {
|
|
16
16
|
constructor(e = {}) {
|
|
17
17
|
i(this, "logger", new S());
|
|
@@ -24,14 +24,14 @@ class q {
|
|
|
24
24
|
}
|
|
25
25
|
addTokenBackend(e) {
|
|
26
26
|
return this.logger.logDebug("addTokenBackend HttpHeaders", JSON.stringify(e)), new A().get().pipe(
|
|
27
|
-
|
|
27
|
+
d((t) => m({ ...e, Authorization: `Bearer ${t}` }))
|
|
28
28
|
);
|
|
29
29
|
}
|
|
30
30
|
get(e) {
|
|
31
31
|
this.logger.logDebug("get HttpHeaders");
|
|
32
32
|
const t = m({ ...this.headers });
|
|
33
33
|
return e ? t.pipe(
|
|
34
|
-
|
|
34
|
+
d((s) => this.addTokenBackend(s))
|
|
35
35
|
) : t;
|
|
36
36
|
}
|
|
37
37
|
}
|
|
@@ -45,7 +45,7 @@ class Q {
|
|
|
45
45
|
var s, r, n;
|
|
46
46
|
if (e != null && e.errors)
|
|
47
47
|
throw new b(
|
|
48
|
-
((n = (r = (s = e.errors).at) == null ? void 0 : r.call(s, 0)) == null ? void 0 : n.code) ??
|
|
48
|
+
((n = (r = (s = e.errors).at) == null ? void 0 : r.call(s, 0)) == null ? void 0 : n.code) ?? y.DEFAULT,
|
|
49
49
|
t ?? ""
|
|
50
50
|
);
|
|
51
51
|
return !(e != null && e.errors);
|
|
@@ -102,7 +102,7 @@ class Q {
|
|
|
102
102
|
...r
|
|
103
103
|
}) {
|
|
104
104
|
return this.httpHeaders.get(s).pipe(
|
|
105
|
-
|
|
105
|
+
d(
|
|
106
106
|
(n) => T(e, {
|
|
107
107
|
...r,
|
|
108
108
|
headers: {
|
|
@@ -110,16 +110,16 @@ class Q {
|
|
|
110
110
|
...n
|
|
111
111
|
}
|
|
112
112
|
}).pipe(
|
|
113
|
-
|
|
113
|
+
R((a) => {
|
|
114
114
|
throw this.logger.logError(JSON.stringify(a)), this.logger.logError(
|
|
115
115
|
`HttpBackend \x1B[37m <URL>: \x1B[33m ${e} \x1B[37m <RequestID>: \x1B[33m ${t} \x1B[37m <HEADERS>: \x1B[33m ${JSON.stringify(
|
|
116
116
|
n
|
|
117
117
|
)} \x1B[37m <BODY>: \x1B[33m ${JSON.stringify(
|
|
118
118
|
this.formatParams(r.body, r.format)
|
|
119
119
|
)} \x1B[37m <RESPONSE>: \x1B[33m ${JSON.stringify(a)} \x1B[33m`
|
|
120
|
-
), new b(
|
|
120
|
+
), new b(y.DEFAULT, t);
|
|
121
121
|
}),
|
|
122
|
-
|
|
122
|
+
d((a) => (this.logger.logDebug(
|
|
123
123
|
`HttpBackend \x1B[37m <URL>: \x1B[33m ${e} \x1B[37m <RequestID>: \x1B[33m ${t} \x1B[37m <HEADERS>: \x1B[33m ${JSON.stringify(
|
|
124
124
|
n
|
|
125
125
|
)} \x1B[37m <BODY>: \x1B[33m ${JSON.stringify(
|
|
@@ -170,25 +170,29 @@ class X {
|
|
|
170
170
|
url: t,
|
|
171
171
|
headers: r.headers,
|
|
172
172
|
method: e,
|
|
173
|
-
selector: (
|
|
174
|
-
}, a = (/* @__PURE__ */ new Date()).toISOString(), u =
|
|
173
|
+
selector: (c) => c.json()
|
|
174
|
+
}, a = (/* @__PURE__ */ new Date()).toISOString(), u = B(a, B.URL);
|
|
175
175
|
if (e === "GET") {
|
|
176
|
-
const
|
|
177
|
-
const [l,
|
|
178
|
-
if (
|
|
176
|
+
const c = new URL(t, location.origin), f = r.params ?? {}, H = Object.entries(f).reduce((h, x) => {
|
|
177
|
+
const [l, D] = x;
|
|
178
|
+
if (h[l] = `${D}`, Object.hasOwn(f, l)) {
|
|
179
179
|
const p = f[l];
|
|
180
|
-
p != null && (
|
|
180
|
+
p != null && (h[l] = p);
|
|
181
181
|
}
|
|
182
|
-
return
|
|
182
|
+
return h;
|
|
183
183
|
}, {}), N = this.encoder.encode(H, u), O = JSON.parse(N);
|
|
184
|
-
for (const
|
|
185
|
-
|
|
186
|
-
return { ...n, url:
|
|
184
|
+
for (const h of Object.keys(O))
|
|
185
|
+
c.searchParams.append(h, `${O[h]}`);
|
|
186
|
+
return { ...n, url: c.toString() };
|
|
187
187
|
}
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
188
|
+
if (new Headers(r.headers).get("Content-Type") === "multipart/form-data") {
|
|
189
|
+
const c = s;
|
|
190
|
+
return c.append("requestID", u), {
|
|
191
|
+
...n,
|
|
192
|
+
body: c
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
return {
|
|
192
196
|
...n,
|
|
193
197
|
body: this.encoder.encode(s ?? {}, u)
|
|
194
198
|
};
|
|
@@ -198,7 +202,7 @@ class X {
|
|
|
198
202
|
...t
|
|
199
203
|
}) {
|
|
200
204
|
return E.getInstance().setSubject(this.isLoadingEnabled), this.httpHeaders.get(!1).pipe(
|
|
201
|
-
|
|
205
|
+
d((s) => {
|
|
202
206
|
const r = {
|
|
203
207
|
...s,
|
|
204
208
|
...t.headers
|
|
@@ -207,15 +211,15 @@ class X {
|
|
|
207
211
|
...t,
|
|
208
212
|
headers: r
|
|
209
213
|
}).pipe(
|
|
210
|
-
|
|
211
|
-
|
|
214
|
+
d((n) => m(this.encoder.decode(n))),
|
|
215
|
+
d((n) => {
|
|
212
216
|
if ("code" in n)
|
|
213
217
|
throw n;
|
|
214
218
|
return E.getInstance().setSubject(!1), this.logger.logDebug(
|
|
215
219
|
`HttpClient <URL>: ${e} <HEADERS>: ${JSON.stringify(t.headers)} <BODY> ${JSON.stringify(t.body)} <RESPONSE>: ${JSON.stringify(n)}`
|
|
216
220
|
), m(n);
|
|
217
221
|
}),
|
|
218
|
-
|
|
222
|
+
R((n) => (this.logger.logError(
|
|
219
223
|
`HttpClient <URL>: ${e} <HEADERS>: ${JSON.stringify(t.headers)} <BODY> ${JSON.stringify(t.body)} <ERROR>: ${JSON.stringify(n)}`
|
|
220
224
|
), E.getInstance().setSubject(!1), P.getInstance().setSubject(n), J))
|
|
221
225
|
);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var h=Object.defineProperty;var E=(a,r,e)=>r in a?h(a,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):a[r]=e;var l=(a,r,e)=>E(a,typeof r!="symbol"?r+"":r,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const g=require("./default-errors-DiEIEEE2.cjs"),f=require("./i18n-vIm9wuAG.cjs"),c=require("./client-
|
|
1
|
+
"use strict";var h=Object.defineProperty;var E=(a,r,e)=>r in a?h(a,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):a[r]=e;var l=(a,r,e)=>E(a,typeof r!="symbol"?r+"":r,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const g=require("./default-errors-DiEIEEE2.cjs"),f=require("./i18n-vIm9wuAG.cjs"),c=require("./client-BVAQF7Tb.cjs"),t=require("rxjs"),R=require("./logger-BMbeDoGU.cjs"),m=require("./encoder-BEp9qfLf.cjs");require("node-jose");require("crypto");class S{constructor(){l(this,"encoder",new m.Encoder);l(this,"logger",new R.Logger);l(this,"requestID","");l(this,"session",null)}setSession(r){this.session=r}getSession(){if(!this.session)throw new g.RuntimeError(g.RuntimeErrorCode.AUTHENTICATION_ERROR,this.requestID);return this.session}returnData(r,e){const s=this.encoder.encode(r,e);return new Response(s,{status:200})}returnError(r){return new Response(JSON.stringify(r),{status:520})}async getBody(r){if(r.method==="GET"){const{searchParams:n}=new URL(r.url);if(n!=null&&n.entries()){const i=[...n.entries()].reduce((u,[d,D])=>(u[d]=D,u),{}),o=i.requestID??"";return{data:i,requestID:o}}return{data:{},requestID:""}}const e=await r.json(),s=(e==null?void 0:e.requestID)??"";return{data:e,requestID:s}}get(r){return this.logger.logDebug("get ApiMiddleware"),async e=>{const{data:s,requestID:n}=await this.getBody(e);this.logger.logDebug("return ApiMiddleware",JSON.stringify(s)),this.requestID=n;try{const i=await t.firstValueFrom(t.of(e).pipe(t.switchMap(o=>t.forkJoin({params:t.of(this.encoder.decode(s)),headers:t.of(o.headers)})),t.switchMap(({params:o,headers:u})=>t.forkJoin({response:r(o,{requestID:this.requestID,headers:u}),headers:t.of(u),params:t.of(o)})),t.switchMap(({params:o,response:u,headers:d})=>(this.logger.logDebug(`ApiMiddleware \x1B[37m <URL>: \x1B[33m ${e.url} \x1B[37m <HEADERS>: \x1B[33m ${JSON.stringify(d)} \x1B[37m <REQUEST ID> \x1B[33m ${this.requestID} \x1B[37m <PARAMS> \x1B[33m ${JSON.stringify(o)} \x1B[37m <RESPONSE>: \x1B[33m ${JSON.stringify(u)}`),t.of(u)))));return this.logger.logDebug("ApiMiddleware subscribe next",JSON.stringify(i)),this.returnData(i,this.requestID)}catch(i){return this.logger.logError(`ApiMiddleware <URL>: ${e==null?void 0:e.url} <HEADERS>: ${JSON.stringify(e==null?void 0:e.headers)} <REQUEST ID> ${this.requestID} <PARAMS> ${JSON.stringify(e==null?void 0:e.body)} <ERROR>: ${JSON.stringify(i)}`),this.returnError({...i,requestID:this.requestID})}}}getFile(r){return this.logger.logDebug("get File ApiMiddleware"),async e=>{try{const s=await e.formData(),n=s.get("file");this.requestID=s.get("requestID");const i=await t.firstValueFrom(r(n).pipe(t.switchMap(o=>(this.logger.logDebug(`ApiMiddleware \x1B[37m <URL>: \x1B[33m ${e.url} \x1B[37m <REQUEST ID> \x1B[33m ${this.requestID} \x1B[37m <RESPONSE>: \x1B[33m ${JSON.stringify(o)}`),t.of(o)))));return this.logger.logDebug("ApiMiddleware File subscribe next",JSON.stringify(i)),this.returnData(i,this.requestID)}catch(s){return this.logger.logError(`ApiMiddleware <URL>: ${e==null?void 0:e.url} <HEADERS>: ${JSON.stringify(e==null?void 0:e.headers)} <REQUEST ID> ${this.requestID} <PARAMS> ${JSON.stringify(e==null?void 0:e.body)} <ERROR>: ${JSON.stringify(s)}`),this.returnError({...s,requestID:this.requestID})}}}}exports.ErrorHandler=g.ErrorHandler;exports.RuntimeError=g.RuntimeError;exports.RuntimeErrorCode=g.RuntimeErrorCode;exports.commonErrors=g.commonErrors;exports.errorTranslations=f.translation;exports.HttpBackend=c.HttpBackend;exports.HttpClient=c.HttpClient;exports.HttpHeaders=c.HttpHeaders;exports.ApiMiddleware=S;
|
|
@@ -4,7 +4,7 @@ var g = (u, e, t) => p(u, typeof e != "symbol" ? e + "" : e, t);
|
|
|
4
4
|
import { R as c, a as f } from "./default-errors-DsKmUZbG.js";
|
|
5
5
|
import { E as J, c as M } from "./default-errors-DsKmUZbG.js";
|
|
6
6
|
import { t as U } from "./i18n-CEBemBIX.js";
|
|
7
|
-
import { a as L, b as F, H as P } from "./client-
|
|
7
|
+
import { a as L, b as F, H as P } from "./client-DKI6Ntcl.js";
|
|
8
8
|
import { firstValueFrom as D, of as a, switchMap as l, forkJoin as h } from "rxjs";
|
|
9
9
|
import { L as R } from "./logger-DtlFWyFO.js";
|
|
10
10
|
import { E as I } from "./encoder-CXAlLf5T.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var T=Object.defineProperty;var C=(
|
|
1
|
+
"use strict";var T=Object.defineProperty;var C=(i,e,s)=>e in i?T(i,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):i[e]=s;var n=(i,e,s)=>C(i,typeof e!="symbol"?e+"":e,s);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const S=require("./redis-cache-BstIlgPR.cjs"),_=require("./logger-BMbeDoGU.cjs");require("./lodash-DNCgFYS7.cjs");require("node-jose");require("crypto");const G=require("./v5-BTqP79vV.cjs"),A=process.env.TIMEOUT_SESSION_MINUTES,N=process.env.PREFIX_TERMINAL||"PF:TERMINAL:",$="619abad7-0dea-46c5-aa49-fc1ec872a684",u="TERMINAL";class w{constructor(){n(this,"logger",new _.Logger);n(this,"redisCache",new S.RedisCache)}getIdApi(e){const s=G.v5(e,$);return`${N}${s}`}async set(e,s){return this.redisCache.set({prefix:this.getIdApi(e),idData:u,body:s,expire:A})}async get(e){return this.redisCache.get(this.getIdApi(e),u).then(({data:s})=>(this.logger.logDebug("getTerminal",JSON.stringify(s)),s)).catch(s=>(this.logger.logError("Error getTerminal",JSON.stringify(s)),null))}async delete(e){return this.redisCache.delete(this.getIdApi(e),u)}}const{TIMEOUT_SESSION_MINUTES:R}=process.env,{PREFIX_LOGIN:r}=process.env,O=process.env.REDIS_GET_USER_DATA_SESSION??"",U=`${r}:${O}`;`${process.env.APP_LOGS_NAME}${process.env.REDIS_GET_USER_APPS_PERMISSIONS}`;class M{constructor(e){n(this,"redisCache",new S.RedisCache);n(this,"userId","");n(this,"accountId","");this.userId=e}async updateSessionTimeout(e,s,a){if(!e)return;const t=new Date,c=R*6e4,o=new Date(t.getTime()+c);this.redisCache.simpleHSet(s,a,o.toISOString())}async getBasicSession(){const e="expires",s=await this.redisCache.simpleGet(`${r}:session:user:${this.userId}`)??"",a=await this.redisCache.simpleHGet(s,"sessionToken"),h=await this.redisCache.simpleHGet(`${r}:user:${this.userId}`,"email")??"",t=await this.redisCache.simpleGet(`${r}:account:user:${this.userId}`)??"",c=await this.redisCache.simpleHGet(t,"providerAccountId")??"",o=await this.redisCache.simpleHGet(s,e);if(this.updateSessionTimeout(o,s,e),this.accountId=c,a&&h&&t&&c){const d=await this.redisCache.simpleHGet(`${r}:user:${this.userId}`,"name"),I=await this.redisCache.simpleHGet(`${r}:user:${this.userId}`,"email")??"",p=await this.redisCache.simpleHGet(`${r}:user:${this.userId}`,"image"),m=await this.redisCache.simpleHGet(`${t}`,"cveUsuario"),l=await this.redisCache.simpleHGet(`${t}`,"appGroups"),E=await this.redisCache.simpleHGet(`${t}`,"rol"),g=l?JSON.parse(l):[];return{user:{name:d,email:I,image:p,cveUsuario:m,rol:E,appGroups:g}}}return{user:{name:null,email:null,image:null},expires:null}}async getUserAndShoppingStore(){var a;const e=await this.getBasicSession();if(e.user.image===null)return e;const s=await this.redisCache.get(U,this.accountId);return s.data.data?{user:{...e.user,...(a=s==null?void 0:s.data)==null?void 0:a.data}}:{user:{name:null,email:null,image:null},expires:null}}}exports.SessionCache=M;exports.Terminal=w;
|
|
@@ -1,49 +1,49 @@
|
|
|
1
1
|
var T = Object.defineProperty;
|
|
2
2
|
var _ = (t, e, s) => e in t ? T(t, e, { enumerable: !0, configurable: !0, writable: !0, value: s }) : t[e] = s;
|
|
3
3
|
var n = (t, e, s) => _(t, typeof e != "symbol" ? e + "" : e, s);
|
|
4
|
-
import { R as
|
|
4
|
+
import { R as S } from "./redis-cache-HiNx0Kbv.js";
|
|
5
5
|
import { L as C } from "./logger-DtlFWyFO.js";
|
|
6
6
|
import "./lodash-QjAkD17S.js";
|
|
7
7
|
import "node-jose";
|
|
8
8
|
import "crypto";
|
|
9
|
-
import { v as
|
|
10
|
-
const A = process.env.TIMEOUT_SESSION_MINUTES,
|
|
11
|
-
class
|
|
9
|
+
import { v as G } from "./v5-Cu1sjPlx.js";
|
|
10
|
+
const A = process.env.TIMEOUT_SESSION_MINUTES, N = process.env.PREFIX_TERMINAL || "PF:TERMINAL:", $ = "619abad7-0dea-46c5-aa49-fc1ec872a684", u = "TERMINAL";
|
|
11
|
+
class P {
|
|
12
12
|
constructor() {
|
|
13
13
|
n(this, "logger", new C());
|
|
14
|
-
n(this, "redisCache", new
|
|
14
|
+
n(this, "redisCache", new S());
|
|
15
15
|
}
|
|
16
16
|
getIdApi(e) {
|
|
17
|
-
const s =
|
|
18
|
-
return `${
|
|
17
|
+
const s = G(e, $);
|
|
18
|
+
return `${N}${s}`;
|
|
19
19
|
}
|
|
20
20
|
async set(e, s) {
|
|
21
|
-
return this.redisCache.
|
|
22
|
-
|
|
21
|
+
return this.redisCache.set({
|
|
22
|
+
prefix: this.getIdApi(e),
|
|
23
23
|
idData: u,
|
|
24
24
|
body: s,
|
|
25
25
|
expire: A
|
|
26
26
|
});
|
|
27
27
|
}
|
|
28
28
|
async get(e) {
|
|
29
|
-
return this.redisCache.
|
|
29
|
+
return this.redisCache.get(this.getIdApi(e), u).then(({ data: s }) => (this.logger.logDebug("getTerminal", JSON.stringify(s)), s)).catch((s) => (this.logger.logError("Error getTerminal", JSON.stringify(s)), null));
|
|
30
30
|
}
|
|
31
31
|
async delete(e) {
|
|
32
|
-
return this.redisCache.
|
|
32
|
+
return this.redisCache.delete(this.getIdApi(e), u);
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
|
-
const { TIMEOUT_SESSION_MINUTES:
|
|
35
|
+
const { TIMEOUT_SESSION_MINUTES: w } = process.env, { PREFIX_LOGIN: r } = process.env, R = process.env.REDIS_GET_USER_DATA_SESSION ?? "", O = `${r}:${R}`;
|
|
36
36
|
`${process.env.APP_LOGS_NAME}${process.env.REDIS_GET_USER_APPS_PERMISSIONS}`;
|
|
37
37
|
class y {
|
|
38
38
|
constructor(e) {
|
|
39
|
-
n(this, "redisCache", new
|
|
39
|
+
n(this, "redisCache", new S());
|
|
40
40
|
n(this, "userId", "");
|
|
41
41
|
n(this, "accountId", "");
|
|
42
42
|
this.userId = e;
|
|
43
43
|
}
|
|
44
44
|
async updateSessionTimeout(e, s, a) {
|
|
45
45
|
if (!e) return;
|
|
46
|
-
const i = /* @__PURE__ */ new Date(), o =
|
|
46
|
+
const i = /* @__PURE__ */ new Date(), o = w * 6e4, c = new Date(i.getTime() + o);
|
|
47
47
|
this.redisCache.simpleHSet(
|
|
48
48
|
s,
|
|
49
49
|
a,
|
|
@@ -66,7 +66,7 @@ class y {
|
|
|
66
66
|
e
|
|
67
67
|
);
|
|
68
68
|
if (this.updateSessionTimeout(c, s, e), this.accountId = o, a && h && i && o) {
|
|
69
|
-
const
|
|
69
|
+
const d = await this.redisCache.simpleHGet(
|
|
70
70
|
`${r}:user:${this.userId}`,
|
|
71
71
|
"name"
|
|
72
72
|
), p = await this.redisCache.simpleHGet(
|
|
@@ -78,13 +78,13 @@ class y {
|
|
|
78
78
|
), I = await this.redisCache.simpleHGet(
|
|
79
79
|
`${i}`,
|
|
80
80
|
"cveUsuario"
|
|
81
|
-
),
|
|
81
|
+
), l = await this.redisCache.simpleHGet(
|
|
82
82
|
`${i}`,
|
|
83
83
|
"appGroups"
|
|
84
|
-
), E = await this.redisCache.simpleHGet(`${i}`, "rol"), g =
|
|
84
|
+
), E = await this.redisCache.simpleHGet(`${i}`, "rol"), g = l ? JSON.parse(l) : [];
|
|
85
85
|
return {
|
|
86
86
|
user: {
|
|
87
|
-
name:
|
|
87
|
+
name: d,
|
|
88
88
|
email: p,
|
|
89
89
|
image: m,
|
|
90
90
|
cveUsuario: I,
|
|
@@ -107,7 +107,7 @@ class y {
|
|
|
107
107
|
const e = await this.getBasicSession();
|
|
108
108
|
if (e.user.image === null)
|
|
109
109
|
return e;
|
|
110
|
-
const s = await this.redisCache.
|
|
110
|
+
const s = await this.redisCache.get(
|
|
111
111
|
O,
|
|
112
112
|
this.accountId
|
|
113
113
|
);
|
|
@@ -128,5 +128,5 @@ class y {
|
|
|
128
128
|
}
|
|
129
129
|
export {
|
|
130
130
|
y as SessionCache,
|
|
131
|
-
|
|
131
|
+
P as Terminal
|
|
132
132
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./redis-cache-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./redis-cache-BstIlgPR.cjs");exports.RedisCache=e.RedisCache;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./client-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./client-BVAQF7Tb.cjs");exports.HttpBackend=t.HttpBackend;exports.HttpClient=t.HttpClient;exports.HttpHeaders=t.HttpHeaders;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./loading-handler-BrN0O37N.cjs");exports.LoadingHandler=e.LoadingHandler;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./loading-handler-BrN0O37N.cjs"),r=require("./rx-subject-manager-ZC9CWBWH.cjs");exports.LoadingHandler=e.LoadingHandler;exports.RxSubjectManager=r.RxSubjectManager;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var a=Object.defineProperty;var u=(n,t,e)=>t in n?a(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e;var o=(n,t,e)=>u(n,typeof t!="symbol"?t+"":t,e);const S=require("./ioredis-instance-PenLE7vi.cjs"),d=require("./encrypter-CgZLhLnj.cjs");var l=(n=>(n.NOT_REFRESH="NOT_REFRESH",n.REFRESH="REFRESH",n))(l||{});const h=process.env.TIMEOUT_SESSION_MINUTES;class R{constructor(){o(this,"encrypter",new d.Encrypter);o(this,"initClient",S.ioredisInstance)}getRootNode(t){return this.initClient.get(t)}async getEntryPoint(t){try{return await this.getRootNode(t)}catch{throw new Error("Not found entry point")}}setEntryPoint(t,e,i){const s=typeof e=="string"?e:JSON.stringify(e);this.initClient.set(t,s,"EX",60*i)}async get(t,e){const i=`${t}:${this.encrypter.generateSHA(e)}`,s=await this.getEntryPoint(i),c=await this.encrypter.isEncrypted(s)?await this.encrypter.decrypt(s??""):JSON.parse(s),r=Number(c==null?void 0:c.expires_in);return r&&this.ttl(i,r*60),{sha:i,data:c}}async delete(t,e){const i=`${t}:${this.encrypter.generateSHA(e)}`;this.initClient.del(i)}async set({prefix:t,idData:e,body:i,expire:s,encrypted:y=!1,refresh:c=l.REFRESH}){const r=`${t}:${this.encrypter.generateSHA(e)}`,E={expires_in:c===l.REFRESH?s:0,...i};if(y){const p=await this.encrypter.encrypt(E);return this.setEntryPoint(r,p,s),r}return this.setEntryPoint(r,E,s),r}async statusHost(){return new Promise((t,e)=>{this.initClient.on("error",i=>{this.killRedis(),e(i)}),this.initClient.on("connect",()=>{t("success")})})}killRedis(){this.initClient.disconnect()}deleteKey(t){this.initClient.del(t)}ttl(t,e){this.initClient.expire(t,e)}simpleGet(t){return this.ttl(t,h*60),this.initClient.get(t)}simpleHGet(t,e){return this.ttl(t,h*60),this.initClient.hget(t,e)}simpleHGetBuffer(t,e){return this.ttl(t,h*60),this.initClient.hgetBuffer(t,e)}simpleHSet(t,e,i){return this.initClient.hset(t,e,i)}simpleHGetAll(t){return this.initClient.hgetall(t)}}exports.RedisCache=R;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
var
|
|
2
|
-
var S = (n, t, e) => t in n ?
|
|
1
|
+
var a = Object.defineProperty;
|
|
2
|
+
var S = (n, t, e) => t in n ? a(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e;
|
|
3
3
|
var c = (n, t, e) => S(n, typeof t != "symbol" ? t + "" : t, e);
|
|
4
|
-
import { i as
|
|
5
|
-
import { E as
|
|
6
|
-
var
|
|
7
|
-
const
|
|
4
|
+
import { i as u } from "./ioredis-instance-BaXfqmqC.js";
|
|
5
|
+
import { E as R } from "./encrypter-ZTjrp3uD.js";
|
|
6
|
+
var h = /* @__PURE__ */ ((n) => (n.NOT_REFRESH = "NOT_REFRESH", n.REFRESH = "REFRESH", n))(h || {});
|
|
7
|
+
const l = process.env.TIMEOUT_SESSION_MINUTES;
|
|
8
8
|
class m {
|
|
9
9
|
constructor() {
|
|
10
|
-
c(this, "encrypter", new
|
|
11
|
-
c(this, "initClient",
|
|
10
|
+
c(this, "encrypter", new R());
|
|
11
|
+
c(this, "initClient", u);
|
|
12
12
|
}
|
|
13
13
|
getRootNode(t) {
|
|
14
14
|
return this.initClient.get(t);
|
|
@@ -24,28 +24,28 @@ class m {
|
|
|
24
24
|
const s = typeof e == "string" ? e : JSON.stringify(e);
|
|
25
25
|
this.initClient.set(t, s, "EX", 60 * i);
|
|
26
26
|
}
|
|
27
|
-
async
|
|
27
|
+
async get(t, e) {
|
|
28
28
|
const i = `${t}:${this.encrypter.generateSHA(e)}`, s = await this.getEntryPoint(i), o = await this.encrypter.isEncrypted(s) ? await this.encrypter.decrypt(s ?? "") : JSON.parse(s), r = Number(o == null ? void 0 : o.expires_in);
|
|
29
29
|
return r && this.ttl(i, r * 60), { sha: i, data: o };
|
|
30
30
|
}
|
|
31
|
-
async
|
|
31
|
+
async delete(t, e) {
|
|
32
32
|
const i = `${t}:${this.encrypter.generateSHA(e)}`;
|
|
33
33
|
this.initClient.del(i);
|
|
34
34
|
}
|
|
35
|
-
async
|
|
36
|
-
|
|
35
|
+
async set({
|
|
36
|
+
prefix: t,
|
|
37
37
|
idData: e,
|
|
38
38
|
body: i,
|
|
39
39
|
expire: s,
|
|
40
|
-
encrypted:
|
|
41
|
-
refresh: o =
|
|
40
|
+
encrypted: y = !1,
|
|
41
|
+
refresh: o = h.REFRESH
|
|
42
42
|
}) {
|
|
43
|
-
const r = `${t}:${this.encrypter.generateSHA(e)}`,
|
|
44
|
-
if (
|
|
45
|
-
const
|
|
46
|
-
return this.setEntryPoint(r,
|
|
43
|
+
const r = `${t}:${this.encrypter.generateSHA(e)}`, E = { expires_in: o === h.REFRESH ? s : 0, ...i };
|
|
44
|
+
if (y) {
|
|
45
|
+
const p = await this.encrypter.encrypt(E);
|
|
46
|
+
return this.setEntryPoint(r, p, s), r;
|
|
47
47
|
}
|
|
48
|
-
return this.setEntryPoint(r,
|
|
48
|
+
return this.setEntryPoint(r, E, s), r;
|
|
49
49
|
}
|
|
50
50
|
async statusHost() {
|
|
51
51
|
return new Promise((t, e) => {
|
|
@@ -66,10 +66,13 @@ class m {
|
|
|
66
66
|
this.initClient.expire(t, e);
|
|
67
67
|
}
|
|
68
68
|
simpleGet(t) {
|
|
69
|
-
return this.ttl(t,
|
|
69
|
+
return this.ttl(t, l * 60), this.initClient.get(t);
|
|
70
70
|
}
|
|
71
71
|
simpleHGet(t, e) {
|
|
72
|
-
return this.ttl(t,
|
|
72
|
+
return this.ttl(t, l * 60), this.initClient.hget(t, e);
|
|
73
|
+
}
|
|
74
|
+
simpleHGetBuffer(t, e) {
|
|
75
|
+
return this.ttl(t, l * 60), this.initClient.hgetBuffer(t, e);
|
|
73
76
|
}
|
|
74
77
|
simpleHSet(t, e, i) {
|
|
75
78
|
return this.initClient.hset(t, e, i);
|
package/dist/rxjs/index.d.ts
CHANGED
package/dist/rxjs/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/rxjs/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/rxjs/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAClD,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAA"}
|
package/dist/types.d.ts
CHANGED
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA;AAC5B,cAAc,oBAAoB,CAAA;AAClC,cAAc,+BAA+B,CAAA"}
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA;AAC5B,cAAc,oBAAoB,CAAA;AAClC,cAAc,+BAA+B,CAAA;AAC7C,cAAc,gCAAgC,CAAA"}
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";var p=Object.defineProperty;var S=(n,t,e)=>t in n?p(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e;var o=(n,t,e)=>S(n,typeof t!="symbol"?t+"":t,e);const d=require("./ioredis-instance-PenLE7vi.cjs"),R=require("./encrypter-CgZLhLnj.cjs");var h=(n=>(n.NOT_REFRESH="NOT_REFRESH",n.REFRESH="REFRESH",n))(h||{});const E=process.env.TIMEOUT_SESSION_MINUTES;class u{constructor(){o(this,"encrypter",new R.Encrypter);o(this,"initClient",d.ioredisInstance)}getRootNode(t){return this.initClient.get(t)}async getEntryPoint(t){try{return await this.getRootNode(t)}catch{throw new Error("Not found entry point")}}setEntryPoint(t,e,i){const s=typeof e=="string"?e:JSON.stringify(e);this.initClient.set(t,s,"EX",60*i)}async getRedisState(t,e){const i=`${t}:${this.encrypter.generateSHA(e)}`,s=await this.getEntryPoint(i),c=await this.encrypter.isEncrypted(s)?await this.encrypter.decrypt(s??""):JSON.parse(s),r=Number(c==null?void 0:c.expires_in);return r&&this.ttl(i,r*60),{sha:i,data:c}}async deleteRedisState(t,e){const i=`${t}:${this.encrypter.generateSHA(e)}`;this.initClient.del(i)}async setRedisState({idApi:t,idData:e,body:i,expire:s,encrypted:l=!1,refresh:c=h.REFRESH}){const r=`${t}:${this.encrypter.generateSHA(e)}`,y={expires_in:c===h.REFRESH?s:0,...i};if(l){const a=await this.encrypter.encrypt(y);return this.setEntryPoint(r,a,s),r}return this.setEntryPoint(r,y,s),r}async statusHost(){return new Promise((t,e)=>{this.initClient.on("error",i=>{this.killRedis(),e(i)}),this.initClient.on("connect",()=>{t("success")})})}killRedis(){this.initClient.disconnect()}deleteKey(t){this.initClient.del(t)}ttl(t,e){this.initClient.expire(t,e)}simpleGet(t){return this.ttl(t,E*60),this.initClient.get(t)}simpleHGet(t,e){return this.ttl(t,E*60),this.initClient.hget(t,e)}simpleHSet(t,e,i){return this.initClient.hset(t,e,i)}simpleHGetAll(t){return this.initClient.hgetall(t)}}exports.RedisCache=u;
|