mp-front-cli 0.0.53 → 0.0.55
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/core/errors/error-catalog.d.ts +15 -0
- package/dist/core/errors/error-catalog.d.ts.map +1 -0
- package/dist/core/errors/index.d.ts +2 -0
- package/dist/core/errors/index.d.ts.map +1 -0
- package/dist/core/errors/message-error.d.ts +16 -0
- package/dist/core/errors/message-error.d.ts.map +1 -0
- package/dist/core/index.d.ts +6 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/interfaces/api-response.d.ts +59 -0
- package/dist/core/interfaces/api-response.d.ts.map +1 -0
- package/dist/core/interfaces/index.d.ts +3 -0
- package/dist/core/interfaces/index.d.ts.map +1 -0
- package/dist/core/interfaces/message.d.ts +15 -0
- package/dist/core/interfaces/message.d.ts.map +1 -0
- package/dist/core/interfaces/method.d.ts +2 -0
- package/dist/core/interfaces/method.d.ts.map +1 -0
- package/dist/core/interfaces/session.d.ts +19 -0
- package/dist/core/interfaces/session.d.ts.map +1 -0
- package/dist/core/middleware/index.d.ts +17 -0
- package/dist/core/middleware/index.d.ts.map +1 -0
- package/dist/core/services/index.d.ts +2 -0
- package/dist/core/services/index.d.ts.map +1 -0
- package/dist/core/services/service-token.d.ts +13 -0
- package/dist/core/services/service-token.d.ts.map +1 -0
- package/dist/core/utils/api-request/fetch-service-be.d.ts +14 -0
- package/dist/core/utils/api-request/fetch-service-be.d.ts.map +1 -0
- package/dist/core/utils/api-request/fetch-service-fe.d.ts +14 -0
- package/dist/core/utils/api-request/fetch-service-fe.d.ts.map +1 -0
- package/dist/core/utils/api-request/index.d.ts +3 -0
- package/dist/core/utils/api-request/index.d.ts.map +1 -0
- package/dist/core/utils/custom-adapter.d.ts +16 -0
- package/dist/core/utils/custom-adapter.d.ts.map +1 -0
- package/dist/core/utils/custom-cache.d.ts +56 -0
- package/dist/core/utils/custom-cache.d.ts.map +1 -0
- package/dist/core/utils/custom-encoder.d.ts +8 -0
- package/dist/core/utils/custom-encoder.d.ts.map +1 -0
- package/dist/core/utils/custom-encrypter.d.ts +10 -0
- package/dist/core/utils/custom-encrypter.d.ts.map +1 -0
- package/dist/core/utils/custom-header.d.ts +9 -0
- package/dist/core/utils/custom-header.d.ts.map +1 -0
- package/dist/core/utils/custom-logger.d.ts +16 -0
- package/dist/core/utils/custom-logger.d.ts.map +1 -0
- package/dist/core/utils/index.d.ts +3 -0
- package/dist/core/utils/index.d.ts.map +1 -0
- package/dist/core/utils/rxjs/index.d.ts +4 -0
- package/dist/core/utils/rxjs/index.d.ts.map +1 -0
- package/dist/core/utils/rxjs/loading-handler.d.ts +7 -0
- package/dist/core/utils/rxjs/loading-handler.d.ts.map +1 -0
- package/dist/core/utils/rxjs/message-handler.d.ts +8 -0
- package/dist/core/utils/rxjs/message-handler.d.ts.map +1 -0
- package/dist/core/utils/rxjs/rx-subject-manager.d.ts +9 -0
- package/dist/core/utils/rxjs/rx-subject-manager.d.ts.map +1 -0
- package/dist/custom-encoder-70a77460.js +3734 -0
- package/dist/custom-encrypter-e3901c44.js +20104 -0
- package/dist/custom-header-db08aa72.js +866 -0
- package/dist/index-df4e0539.js +31 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/lang/common/errors/en_EN/index.d.ts +5 -0
- package/dist/lang/common/errors/en_EN/index.d.ts.map +1 -0
- package/dist/lang/common/errors/es_MX/index.d.ts +30 -0
- package/dist/lang/common/errors/es_MX/index.d.ts.map +1 -0
- package/dist/lang/common/errors/index.d.ts +3 -0
- package/dist/lang/common/errors/index.d.ts.map +1 -0
- package/dist/lang/common/index.d.ts +2 -0
- package/dist/lang/common/index.d.ts.map +1 -0
- package/dist/lang/index.d.ts +3 -0
- package/dist/lang/index.d.ts.map +1 -0
- package/dist/lang/validator/en_EN/index.d.ts +5 -0
- package/dist/lang/validator/en_EN/index.d.ts.map +1 -0
- package/dist/lang/validator/es_MX/index.d.ts +41 -0
- package/dist/lang/validator/es_MX/index.d.ts.map +1 -0
- package/dist/lang/validator/index.d.ts +3 -0
- package/dist/lang/validator/index.d.ts.map +1 -0
- package/dist/mp-front-cli-adapter.es.js +149 -0
- package/dist/mp-front-cli-all.es.js +20 -0
- package/dist/mp-front-cli-cache.es.js +87 -0
- package/dist/mp-front-cli-core.es.js +1807 -0
- package/dist/mp-front-cli-encoder.es.js +5 -0
- package/dist/mp-front-cli-encrypter.es.js +8 -0
- package/dist/mp-front-cli-header.es.js +10 -0
- package/dist/mp-front-cli-locale.es.js +50 -0
- package/dist/mp-front-cli-logger.es.js +55 -0
- package/dist/mp-front-cli-utils-rxjs.es.js +46 -0
- package/dist/v4-8464ab21.js +46 -0
- package/package.json +23 -15
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
const e = {
|
|
2
|
+
errors: {
|
|
3
|
+
default: {
|
|
4
|
+
title: "No pudimos cargar alguno de los datos solicitados.",
|
|
5
|
+
message: "Si continua apareciendo este mensaje por favor contacta a soporte."
|
|
6
|
+
},
|
|
7
|
+
"MP-001": {
|
|
8
|
+
title: "Error",
|
|
9
|
+
message: "Se esperaban parámetros"
|
|
10
|
+
},
|
|
11
|
+
"ERR-GENERAL-01": {
|
|
12
|
+
title: "Error",
|
|
13
|
+
message: "No se obtuvieron la configuración del sistema"
|
|
14
|
+
},
|
|
15
|
+
UnAuthorized: {
|
|
16
|
+
title: "La sesión a caducado",
|
|
17
|
+
message: "Inicia sesión nuevamente"
|
|
18
|
+
},
|
|
19
|
+
ErrorGeneral: {
|
|
20
|
+
title: "",
|
|
21
|
+
message: "{{ message }}"
|
|
22
|
+
},
|
|
23
|
+
internalError: {
|
|
24
|
+
title: "Error interno",
|
|
25
|
+
message: "Ocurrió un error interno"
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
export {
|
|
30
|
+
e as t
|
|
31
|
+
};
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/lang/common/errors/en_EN/index.ts"],"names":[],"mappings":"AAAA,QAAA,MAAM,WAAW;;CAEhB,CAAA;AAED,eAAe,WAAW,CAAA"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
declare const translation: {
|
|
2
|
+
errors: {
|
|
3
|
+
default: {
|
|
4
|
+
title: string;
|
|
5
|
+
message: string;
|
|
6
|
+
};
|
|
7
|
+
"MP-001": {
|
|
8
|
+
title: string;
|
|
9
|
+
message: string;
|
|
10
|
+
};
|
|
11
|
+
"ERR-GENERAL-01": {
|
|
12
|
+
title: string;
|
|
13
|
+
message: string;
|
|
14
|
+
};
|
|
15
|
+
UnAuthorized: {
|
|
16
|
+
title: string;
|
|
17
|
+
message: string;
|
|
18
|
+
};
|
|
19
|
+
ErrorGeneral: {
|
|
20
|
+
title: string;
|
|
21
|
+
message: string;
|
|
22
|
+
};
|
|
23
|
+
internalError: {
|
|
24
|
+
title: string;
|
|
25
|
+
message: string;
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
export default translation;
|
|
30
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/lang/common/errors/es_MX/index.ts"],"names":[],"mappings":"AAAA,QAAA,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4BhB,CAAA;AAED,eAAe,WAAW,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/lang/common/errors/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,SAAS,CAAA;AAC/C,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,SAAS,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lang/common/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/lang/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAA;AACxB,cAAc,aAAa,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/lang/validator/en_EN/index.ts"],"names":[],"mappings":"AAAA,QAAA,MAAM,WAAW;;CAEhB,CAAA;AAED,eAAe,WAAW,CAAA"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
declare const translation: {
|
|
2
|
+
validationMessages: {
|
|
3
|
+
mixed: {
|
|
4
|
+
required: string;
|
|
5
|
+
default: string;
|
|
6
|
+
notType: string;
|
|
7
|
+
min: string;
|
|
8
|
+
max: string;
|
|
9
|
+
matches: string;
|
|
10
|
+
};
|
|
11
|
+
number: {
|
|
12
|
+
min: string;
|
|
13
|
+
max: string;
|
|
14
|
+
lessThan: string;
|
|
15
|
+
moreThan: string;
|
|
16
|
+
positive: string;
|
|
17
|
+
negative: string;
|
|
18
|
+
integer: string;
|
|
19
|
+
};
|
|
20
|
+
string: {
|
|
21
|
+
length: string;
|
|
22
|
+
min: string;
|
|
23
|
+
max: string;
|
|
24
|
+
email: string;
|
|
25
|
+
url: string;
|
|
26
|
+
trim: string;
|
|
27
|
+
matches: string;
|
|
28
|
+
};
|
|
29
|
+
date: {
|
|
30
|
+
min: string;
|
|
31
|
+
max: string;
|
|
32
|
+
};
|
|
33
|
+
array: {
|
|
34
|
+
min: string;
|
|
35
|
+
max: string;
|
|
36
|
+
length: string;
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
export default translation;
|
|
41
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/lang/validator/es_MX/index.ts"],"names":[],"mappings":"AAAA,QAAA,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAsChB,CAAA;AAED,eAAe,WAAW,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lang/validator/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,SAAS,CAAA;AACnD,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,SAAS,CAAA"}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { v as R } from "./v4-8464ab21.js";
|
|
2
|
+
const F = process.env.PREFIX_LOGIN, O = process.env.TIMEOUT_SESSION_MINUTES, Z = {
|
|
3
|
+
baseKeyPrefix: `${F}:`,
|
|
4
|
+
userKeyPrefix: "user:",
|
|
5
|
+
accountKeyPrefix: "account:",
|
|
6
|
+
accountByUserIdPrefix: "account:user:",
|
|
7
|
+
sessionKeyPrefix: "session:",
|
|
8
|
+
sessionByUserIdPrefix: "session:user:",
|
|
9
|
+
userByEmailKeyPrefix: "user:email:",
|
|
10
|
+
verificationKeyPrefix: "verification:",
|
|
11
|
+
expire: O * 60
|
|
12
|
+
}, $ = (s) => {
|
|
13
|
+
for (const p in s)
|
|
14
|
+
return !1;
|
|
15
|
+
return !0;
|
|
16
|
+
}, G = /(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d\.\d+([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z))/, H = (s) => s && G.test(s) && !isNaN(Date.parse(s));
|
|
17
|
+
function v(s, p = { expire: O * 60 }) {
|
|
18
|
+
const r = {
|
|
19
|
+
...Z,
|
|
20
|
+
...p
|
|
21
|
+
}, a = r.baseKeyPrefix || "", B = a + r.userKeyPrefix, m = a + r.userByEmailKeyPrefix, A = a + r.accountKeyPrefix, k = a + r.accountByUserIdPrefix, T = a + r.sessionKeyPrefix, b = a + r.sessionByUserIdPrefix, j = a + r.verificationKeyPrefix, w = (e) => m + e, l = (e) => B + e, x = (e) => A + e, d = (e) => k + e, K = (e, t) => `${t}:${e}`, P = (e) => T + e, y = (e) => b + e, I = (e) => j + e, f = async (e, t) => {
|
|
22
|
+
const n = Object.entries(t).reduce((i, [g, o]) => (i[g] = o instanceof Date ? o.toISOString() : o, i), {});
|
|
23
|
+
await s.hset(e, n), await s.expire(e, r.expire);
|
|
24
|
+
}, u = async (e) => {
|
|
25
|
+
const t = await s.hgetall(e);
|
|
26
|
+
return !t || $(t) ? null : Object.entries(t).reduce((i, [g, o]) => (i[g] = H(o) ? new Date(o) : o, i), {});
|
|
27
|
+
}, E = async (e, t) => (await f(l(e), t), t.email && await s.set(
|
|
28
|
+
w(t.email),
|
|
29
|
+
e,
|
|
30
|
+
"EX",
|
|
31
|
+
r.expire
|
|
32
|
+
), t), c = async (e) => {
|
|
33
|
+
const t = await u(l(e));
|
|
34
|
+
return t ? { ...t } : null;
|
|
35
|
+
}, N = async (e, t) => {
|
|
36
|
+
const n = x(e);
|
|
37
|
+
await f(n, t), await s.set(
|
|
38
|
+
d(t.userId),
|
|
39
|
+
n,
|
|
40
|
+
"EX",
|
|
41
|
+
r.expire
|
|
42
|
+
);
|
|
43
|
+
}, V = async (e) => {
|
|
44
|
+
const t = await u(x(e));
|
|
45
|
+
return t ? { ...t } : null;
|
|
46
|
+
}, _ = async (e) => {
|
|
47
|
+
const t = x(e), n = await u(t);
|
|
48
|
+
if (!n)
|
|
49
|
+
return null;
|
|
50
|
+
await s.hdel(t), await s.del(d(n.userId));
|
|
51
|
+
}, S = async (e, t) => {
|
|
52
|
+
const n = P(e);
|
|
53
|
+
return await f(n, t), await s.set(
|
|
54
|
+
y(t.userId),
|
|
55
|
+
n,
|
|
56
|
+
"EX",
|
|
57
|
+
r.expire
|
|
58
|
+
), t;
|
|
59
|
+
}, U = async (e) => {
|
|
60
|
+
const t = await u(P(e));
|
|
61
|
+
return t ? {
|
|
62
|
+
id: t.id,
|
|
63
|
+
...t
|
|
64
|
+
} : null;
|
|
65
|
+
}, h = async (e) => {
|
|
66
|
+
const t = await U(e);
|
|
67
|
+
if (!t)
|
|
68
|
+
return null;
|
|
69
|
+
const n = P(e);
|
|
70
|
+
await s.del(n), await s.del(y(t.userId));
|
|
71
|
+
}, D = async (e, t) => {
|
|
72
|
+
const n = I(e);
|
|
73
|
+
return await f(n, t), t;
|
|
74
|
+
}, X = async (e) => {
|
|
75
|
+
const t = I(e), n = await u(t);
|
|
76
|
+
return n ? { identifier: n.identifier, ...n } : null;
|
|
77
|
+
}, M = async (e) => {
|
|
78
|
+
const t = I(e);
|
|
79
|
+
await s.del(t);
|
|
80
|
+
};
|
|
81
|
+
return {
|
|
82
|
+
async createUser(e) {
|
|
83
|
+
const t = R();
|
|
84
|
+
return await E(t, { ...e, id: t });
|
|
85
|
+
},
|
|
86
|
+
getUser: c,
|
|
87
|
+
async getUserByEmail(e) {
|
|
88
|
+
const t = await s.get(w(e));
|
|
89
|
+
return t ? await c(t) : null;
|
|
90
|
+
},
|
|
91
|
+
async getUserByAccount({ providerAccountId: e, provider: t }) {
|
|
92
|
+
const n = await V(
|
|
93
|
+
K(e, t)
|
|
94
|
+
);
|
|
95
|
+
return n ? await c(n.userId) : null;
|
|
96
|
+
},
|
|
97
|
+
async updateUser(e) {
|
|
98
|
+
const t = e.id, n = await c(t);
|
|
99
|
+
return await E(t, { ...n, ...e });
|
|
100
|
+
},
|
|
101
|
+
async deleteUser(e) {
|
|
102
|
+
const t = await c(e);
|
|
103
|
+
if (!t)
|
|
104
|
+
return null;
|
|
105
|
+
const n = await s.get(d(e)), i = await s.get(y(e));
|
|
106
|
+
await s.del(
|
|
107
|
+
w(t.email),
|
|
108
|
+
d(e),
|
|
109
|
+
y(e)
|
|
110
|
+
), i && await s.del(i), n && await s.del(n), await s.del(l(e));
|
|
111
|
+
},
|
|
112
|
+
async linkAccount(e) {
|
|
113
|
+
const t = K(e.providerAccountId, e.provider);
|
|
114
|
+
return await N(t, { ...e, id: t });
|
|
115
|
+
},
|
|
116
|
+
async unlinkAccount({ providerAccountId: e, provider: t }) {
|
|
117
|
+
const n = K(e, t);
|
|
118
|
+
await _(n);
|
|
119
|
+
},
|
|
120
|
+
async createSession(e) {
|
|
121
|
+
const t = e.sessionToken;
|
|
122
|
+
return await S(t, { ...e, id: t });
|
|
123
|
+
},
|
|
124
|
+
async getSessionAndUser(e) {
|
|
125
|
+
const n = await U(e);
|
|
126
|
+
if (!n)
|
|
127
|
+
return null;
|
|
128
|
+
const i = await c(n.userId);
|
|
129
|
+
return i ? { session: n, user: i } : null;
|
|
130
|
+
},
|
|
131
|
+
async updateSession(e) {
|
|
132
|
+
const t = e.sessionToken, n = await U(t);
|
|
133
|
+
return n ? await S(t, { ...n, ...e }) : null;
|
|
134
|
+
},
|
|
135
|
+
deleteSession: h,
|
|
136
|
+
async createVerificationToken(e) {
|
|
137
|
+
const t = e.identifier;
|
|
138
|
+
return await D(t, e), e;
|
|
139
|
+
},
|
|
140
|
+
async useVerificationToken(e) {
|
|
141
|
+
const t = e.identifier, n = await X(t);
|
|
142
|
+
return !n || e.token !== n.token ? null : (await M(t), n);
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
export {
|
|
147
|
+
v as IORedisAdapter,
|
|
148
|
+
Z as defaultOptions
|
|
149
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ApiMiddleware as d, ErrorCatalog as n, FetchServiceBE as S, FetchServiceFE as g } from "./mp-front-cli-core.es.js";
|
|
2
|
+
import { S as x } from "./custom-header-db08aa72.js";
|
|
3
|
+
import { LoadingHandler as s, MessageHandler as v, RxSubjectManager as E } from "./mp-front-cli-utils-rxjs.es.js";
|
|
4
|
+
import "./index-df4e0539.js";
|
|
5
|
+
import "./mp-front-cli-logger.es.js";
|
|
6
|
+
import "rxjs";
|
|
7
|
+
import "./custom-encrypter-e3901c44.js";
|
|
8
|
+
import "./custom-encoder-70a77460.js";
|
|
9
|
+
import "crypto";
|
|
10
|
+
import "./v4-8464ab21.js";
|
|
11
|
+
export {
|
|
12
|
+
d as ApiMiddleware,
|
|
13
|
+
n as ErrorCatalog,
|
|
14
|
+
S as FetchServiceBE,
|
|
15
|
+
g as FetchServiceFE,
|
|
16
|
+
s as LoadingHandler,
|
|
17
|
+
v as MessageHandler,
|
|
18
|
+
E as RxSubjectManager,
|
|
19
|
+
x as ServiceToken
|
|
20
|
+
};
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
var p = Object.defineProperty;
|
|
2
|
+
var a = (o, s, t) => s in o ? p(o, s, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[s] = t;
|
|
3
|
+
var S = (o, s, t) => (a(o, typeof s != "symbol" ? s + "" : s, t), t);
|
|
4
|
+
import y from "ioredis";
|
|
5
|
+
import { C as l } from "./custom-encrypter-e3901c44.js";
|
|
6
|
+
import "./custom-encoder-70a77460.js";
|
|
7
|
+
import "./mp-front-cli-logger.es.js";
|
|
8
|
+
import "crypto";
|
|
9
|
+
import "./v4-8464ab21.js";
|
|
10
|
+
class f extends l {
|
|
11
|
+
constructor() {
|
|
12
|
+
super(...arguments);
|
|
13
|
+
S(this, "REDIS_HOST", process.env.REDIS_HOST);
|
|
14
|
+
S(this, "REDIS_PORT", process.env.REDIS_PORT);
|
|
15
|
+
S(this, "REDIS_USER", process.env.REDIS_USER);
|
|
16
|
+
S(this, "REDIS_PASS", process.env.REDIS_PASS);
|
|
17
|
+
S(this, "initClient", new y({
|
|
18
|
+
host: this.REDIS_HOST,
|
|
19
|
+
port: this.REDIS_PORT,
|
|
20
|
+
username: this.REDIS_USER,
|
|
21
|
+
password: this.REDIS_PASS,
|
|
22
|
+
tls: {}
|
|
23
|
+
}));
|
|
24
|
+
}
|
|
25
|
+
getRootNode(t) {
|
|
26
|
+
return this.initClient.get(t);
|
|
27
|
+
}
|
|
28
|
+
async getEntryPoint(t) {
|
|
29
|
+
try {
|
|
30
|
+
return await this.getRootNode(t);
|
|
31
|
+
} catch {
|
|
32
|
+
throw new Error("Not found entry point");
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
setEntryPoint(t, e, n) {
|
|
36
|
+
const i = typeof e == "string" ? e : JSON.stringify(e);
|
|
37
|
+
this.initClient.set(t, i, "EX", 60 * n);
|
|
38
|
+
}
|
|
39
|
+
getSubNode(t, e) {
|
|
40
|
+
return t in e ? e[t] : null;
|
|
41
|
+
}
|
|
42
|
+
setSubNode(t, e, n) {
|
|
43
|
+
const i = { ...e };
|
|
44
|
+
return t in i || (i[t] = n), i;
|
|
45
|
+
}
|
|
46
|
+
async getRedisState(t, e) {
|
|
47
|
+
const n = `${t}:${this.generateSHA(e)}`, i = await this.getEntryPoint(n), c = await this.isEncrypted(i) ? await this.decrypt(i ?? "") : JSON.parse(i), r = Number(c == null ? void 0 : c.expires_in);
|
|
48
|
+
return r > 0 && this.ttl(n, r * 60), { sha: n, data: c };
|
|
49
|
+
}
|
|
50
|
+
async setRedisState({
|
|
51
|
+
idApi: t,
|
|
52
|
+
idData: e,
|
|
53
|
+
body: n,
|
|
54
|
+
expire: i,
|
|
55
|
+
encrypted: E = !1,
|
|
56
|
+
refresh: c = "REFRESH"
|
|
57
|
+
/* REFRESH */
|
|
58
|
+
}) {
|
|
59
|
+
const r = `${t}:${this.generateSHA(e)}`, h = { expires_in: c === "REFRESH" ? i : 0, ...n };
|
|
60
|
+
if (E) {
|
|
61
|
+
const R = await this.encrypt(h);
|
|
62
|
+
return this.setEntryPoint(r, R, i), r;
|
|
63
|
+
}
|
|
64
|
+
return this.setEntryPoint(r, h, i), r;
|
|
65
|
+
}
|
|
66
|
+
async statusHost() {
|
|
67
|
+
return new Promise((t, e) => {
|
|
68
|
+
this.initClient.on("error", (n) => {
|
|
69
|
+
this.killRedis(), e(n);
|
|
70
|
+
}), this.initClient.on("connect", () => {
|
|
71
|
+
t("success");
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
killRedis() {
|
|
76
|
+
this.initClient.disconnect();
|
|
77
|
+
}
|
|
78
|
+
deleteKey(t) {
|
|
79
|
+
this.initClient.del(t);
|
|
80
|
+
}
|
|
81
|
+
ttl(t, e) {
|
|
82
|
+
this.initClient.expire(t, e);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
export {
|
|
86
|
+
f as CustomCache
|
|
87
|
+
};
|