lakutata 2.0.34 → 2.0.35

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.
Files changed (210) hide show
  1. package/com/cacher.cjs +211 -0
  2. package/com/cacher.d.ts +514 -0
  3. package/com/cacher.mjs +185 -0
  4. package/com/database.cjs +6 -2
  5. package/com/database.mjs +6 -2
  6. package/com/docker.cjs +23 -17
  7. package/com/docker.mjs +19 -13
  8. package/com/entrypoint.cjs +1 -1
  9. package/com/entrypoint.mjs +1 -1
  10. package/com/logger.cjs +6 -2
  11. package/com/logger.mjs +6 -2
  12. package/decorator/ctrl.cjs +1 -1
  13. package/decorator/ctrl.mjs +1 -1
  14. package/decorator/orm.cjs +22 -18
  15. package/decorator/orm.mjs +6 -2
  16. package/helper.cjs +1 -1
  17. package/helper.mjs +1 -1
  18. package/lakutata.cjs +7 -3
  19. package/lakutata.mjs +7 -3
  20. package/orm.cjs +19 -15
  21. package/orm.mjs +15 -11
  22. package/package.json +6 -1
  23. package/provider/database.cjs +6 -2
  24. package/provider/database.mjs +6 -2
  25. package/src/components/Database.cjs +6 -2
  26. package/src/components/Database.mjs +6 -2
  27. package/src/components/Logger.cjs +6 -2
  28. package/src/components/Logger.mjs +6 -2
  29. package/src/components/cacher/Cacher.cjs +193 -0
  30. package/src/components/cacher/Cacher.mjs +183 -0
  31. package/src/components/cacher/options/CacherOptions.cjs +93 -0
  32. package/src/components/cacher/options/CacherOptions.mjs +87 -0
  33. package/src/components/cacher/options/FileCacheOptions.cjs +77 -0
  34. package/src/components/cacher/options/FileCacheOptions.mjs +71 -0
  35. package/src/components/cacher/options/MemcacheCacheOptions.cjs +79 -0
  36. package/src/components/cacher/options/MemcacheCacheOptions.mjs +73 -0
  37. package/src/components/cacher/options/MongoCacheOptions.cjs +83 -0
  38. package/src/components/cacher/options/MongoCacheOptions.mjs +77 -0
  39. package/src/components/cacher/options/MysqlCacheOptions.cjs +83 -0
  40. package/src/components/cacher/options/MysqlCacheOptions.mjs +77 -0
  41. package/src/components/cacher/options/PostgresCacheOptions.cjs +87 -0
  42. package/src/components/cacher/options/PostgresCacheOptions.mjs +81 -0
  43. package/src/components/cacher/options/RedisCacheOptions.cjs +99 -0
  44. package/src/components/cacher/options/RedisCacheOptions.mjs +93 -0
  45. package/src/components/cacher/options/SqliteCacheOptions.cjs +77 -0
  46. package/src/components/cacher/options/SqliteCacheOptions.mjs +71 -0
  47. package/src/components/cacher/types/CacheStoreOptions.cjs +1 -0
  48. package/src/components/cacher/types/CacheStoreOptions.mjs +1 -0
  49. package/src/components/docker/ConnectionOptionsBuilder.cjs +19 -13
  50. package/src/components/docker/ConnectionOptionsBuilder.mjs +19 -13
  51. package/src/components/docker/Docker.cjs +19 -13
  52. package/src/components/docker/Docker.mjs +19 -13
  53. package/src/components/docker/lib/DockerContainer.cjs +26 -20
  54. package/src/components/docker/lib/DockerContainer.mjs +20 -14
  55. package/src/components/docker/lib/DockerContainerTTY.cjs +15 -9
  56. package/src/components/docker/lib/DockerContainerTTY.mjs +15 -9
  57. package/src/components/entrypoint/Entrypoint.cjs +1 -1
  58. package/src/components/entrypoint/Entrypoint.mjs +1 -1
  59. package/src/decorators/ctrl/CLIAction.cjs +1 -1
  60. package/src/decorators/ctrl/CLIAction.mjs +1 -1
  61. package/src/decorators/ctrl/HTTPAction.cjs +1 -1
  62. package/src/decorators/ctrl/HTTPAction.mjs +1 -1
  63. package/src/decorators/ctrl/ServiceAction.cjs +1 -1
  64. package/src/decorators/ctrl/ServiceAction.mjs +1 -1
  65. package/src/decorators/ctrl/http/DELETE.cjs +1 -1
  66. package/src/decorators/ctrl/http/DELETE.mjs +1 -1
  67. package/src/decorators/ctrl/http/GET.cjs +1 -1
  68. package/src/decorators/ctrl/http/GET.mjs +1 -1
  69. package/src/decorators/ctrl/http/HEAD.cjs +1 -1
  70. package/src/decorators/ctrl/http/HEAD.mjs +1 -1
  71. package/src/decorators/ctrl/http/OPTIONS.cjs +1 -1
  72. package/src/decorators/ctrl/http/OPTIONS.mjs +1 -1
  73. package/src/decorators/ctrl/http/PATCH.cjs +1 -1
  74. package/src/decorators/ctrl/http/PATCH.mjs +1 -1
  75. package/src/decorators/ctrl/http/POST.cjs +1 -1
  76. package/src/decorators/ctrl/http/POST.mjs +1 -1
  77. package/src/decorators/ctrl/http/PUT.cjs +1 -1
  78. package/src/decorators/ctrl/http/PUT.mjs +1 -1
  79. package/src/decorators/orm/AfterInsert.cjs +6 -2
  80. package/src/decorators/orm/AfterInsert.mjs +13 -9
  81. package/src/decorators/orm/AfterLoad.cjs +6 -2
  82. package/src/decorators/orm/AfterLoad.mjs +16 -12
  83. package/src/decorators/orm/AfterRecover.cjs +6 -2
  84. package/src/decorators/orm/AfterRecover.mjs +10 -6
  85. package/src/decorators/orm/AfterRemove.cjs +6 -2
  86. package/src/decorators/orm/AfterRemove.mjs +10 -6
  87. package/src/decorators/orm/AfterSoftRemove.cjs +6 -2
  88. package/src/decorators/orm/AfterSoftRemove.mjs +10 -6
  89. package/src/decorators/orm/AfterUpdate.cjs +6 -2
  90. package/src/decorators/orm/AfterUpdate.mjs +14 -10
  91. package/src/decorators/orm/BeforeInsert.cjs +6 -2
  92. package/src/decorators/orm/BeforeInsert.mjs +10 -6
  93. package/src/decorators/orm/BeforeRecover.cjs +13 -9
  94. package/src/decorators/orm/BeforeRecover.mjs +6 -2
  95. package/src/decorators/orm/BeforeRemove.cjs +13 -9
  96. package/src/decorators/orm/BeforeRemove.mjs +6 -2
  97. package/src/decorators/orm/BeforeSoftRemove.cjs +10 -6
  98. package/src/decorators/orm/BeforeSoftRemove.mjs +6 -2
  99. package/src/decorators/orm/BeforeUpdate.cjs +6 -2
  100. package/src/decorators/orm/BeforeUpdate.mjs +11 -7
  101. package/src/decorators/orm/Check.cjs +6 -2
  102. package/src/decorators/orm/Check.mjs +6 -2
  103. package/src/decorators/orm/ChildEntity.cjs +11 -7
  104. package/src/decorators/orm/ChildEntity.mjs +6 -2
  105. package/src/decorators/orm/Column.cjs +23 -19
  106. package/src/decorators/orm/Column.mjs +6 -2
  107. package/src/decorators/orm/CreateDateColumn.cjs +8 -4
  108. package/src/decorators/orm/CreateDateColumn.mjs +6 -2
  109. package/src/decorators/orm/DeleteDateColumn.cjs +6 -2
  110. package/src/decorators/orm/DeleteDateColumn.mjs +6 -2
  111. package/src/decorators/orm/Entity.cjs +6 -2
  112. package/src/decorators/orm/Entity.mjs +12 -8
  113. package/src/decorators/orm/EventSubscriber.cjs +6 -2
  114. package/src/decorators/orm/EventSubscriber.mjs +6 -2
  115. package/src/decorators/orm/Exclusion.cjs +6 -2
  116. package/src/decorators/orm/Exclusion.mjs +12 -8
  117. package/src/decorators/orm/Generated.cjs +10 -6
  118. package/src/decorators/orm/Generated.mjs +12 -8
  119. package/src/decorators/orm/Index.cjs +14 -10
  120. package/src/decorators/orm/Index.mjs +24 -20
  121. package/src/decorators/orm/JoinColumn.cjs +6 -2
  122. package/src/decorators/orm/JoinColumn.mjs +6 -2
  123. package/src/decorators/orm/JoinTable.cjs +6 -2
  124. package/src/decorators/orm/JoinTable.mjs +8 -4
  125. package/src/decorators/orm/ManyToMany.cjs +13 -9
  126. package/src/decorators/orm/ManyToMany.mjs +17 -13
  127. package/src/decorators/orm/ManyToOne.cjs +6 -2
  128. package/src/decorators/orm/ManyToOne.mjs +6 -2
  129. package/src/decorators/orm/ObjectIdColumn.cjs +6 -2
  130. package/src/decorators/orm/ObjectIdColumn.mjs +12 -8
  131. package/src/decorators/orm/OneToMany.cjs +14 -10
  132. package/src/decorators/orm/OneToMany.mjs +6 -2
  133. package/src/decorators/orm/OneToOne.cjs +15 -11
  134. package/src/decorators/orm/OneToOne.mjs +13 -9
  135. package/src/decorators/orm/PrimaryColumn.cjs +6 -2
  136. package/src/decorators/orm/PrimaryColumn.mjs +26 -22
  137. package/src/decorators/orm/PrimaryGeneratedColumn.cjs +6 -2
  138. package/src/decorators/orm/PrimaryGeneratedColumn.mjs +8 -4
  139. package/src/decorators/orm/RelationId.cjs +11 -7
  140. package/src/decorators/orm/RelationId.mjs +12 -8
  141. package/src/decorators/orm/TableInheritance.cjs +6 -2
  142. package/src/decorators/orm/TableInheritance.mjs +10 -6
  143. package/src/decorators/orm/Tree.cjs +6 -2
  144. package/src/decorators/orm/Tree.mjs +6 -2
  145. package/src/decorators/orm/TreeChildren.cjs +6 -2
  146. package/src/decorators/orm/TreeChildren.mjs +17 -13
  147. package/src/decorators/orm/TreeLevelColumn.cjs +6 -2
  148. package/src/decorators/orm/TreeLevelColumn.mjs +6 -2
  149. package/src/decorators/orm/TreeParent.cjs +12 -8
  150. package/src/decorators/orm/TreeParent.mjs +6 -2
  151. package/src/decorators/orm/Unique.cjs +6 -2
  152. package/src/decorators/orm/Unique.mjs +6 -2
  153. package/src/decorators/orm/UpdateDateColumn.cjs +8 -4
  154. package/src/decorators/orm/UpdateDateColumn.mjs +6 -2
  155. package/src/decorators/orm/VersionColumn.cjs +6 -2
  156. package/src/decorators/orm/VersionColumn.mjs +6 -2
  157. package/src/decorators/orm/ViewColumn.cjs +6 -2
  158. package/src/decorators/orm/ViewColumn.mjs +6 -2
  159. package/src/decorators/orm/ViewEntity.cjs +8 -4
  160. package/src/decorators/orm/ViewEntity.mjs +6 -2
  161. package/src/decorators/orm/VirtualColumn.cjs +6 -2
  162. package/src/decorators/orm/VirtualColumn.mjs +10 -6
  163. package/src/lib/base/internal/ControllerEntrypoint.cjs +1 -1
  164. package/src/lib/base/internal/ControllerEntrypoint.mjs +1 -1
  165. package/src/lib/core/Application.cjs +11 -7
  166. package/src/lib/core/Application.mjs +7 -3
  167. package/src/lib/core/Module.cjs +1 -1
  168. package/src/lib/core/Module.mjs +1 -1
  169. package/src/lib/helpers/NonceStr.cjs +1 -1
  170. package/src/lib/helpers/NonceStr.mjs +1 -1
  171. package/src/lib/helpers/ObjectHash.cjs +1 -1
  172. package/src/lib/helpers/ObjectHash.mjs +1 -1
  173. package/src/lib/helpers/RandomString.cjs +1 -1
  174. package/src/lib/helpers/RandomString.mjs +1 -1
  175. package/src/providers/Database.cjs +6 -2
  176. package/src/providers/Database.mjs +6 -2
  177. package/vendor/Package.112.cjs +5498 -5500
  178. package/vendor/Package.112.mjs +5504 -5506
  179. package/vendor/Package.12.cjs +4 -80
  180. package/vendor/Package.12.mjs +4 -74
  181. package/vendor/Package.122.cjs +87 -0
  182. package/vendor/Package.122.mjs +79 -0
  183. package/vendor/Package.13.cjs +1 -1
  184. package/vendor/Package.13.mjs +1 -1
  185. package/vendor/Package.14.cjs +1 -14055
  186. package/vendor/Package.14.mjs +1 -14029
  187. package/vendor/Package.15.cjs +12449 -46635
  188. package/vendor/Package.15.mjs +12435 -46611
  189. package/vendor/Package.16.cjs +3 -0
  190. package/vendor/Package.16.mjs +1 -0
  191. package/vendor/Package.17.cjs +48245 -0
  192. package/vendor/Package.17.mjs +48202 -0
  193. package/vendor/Package.18.cjs +3 -0
  194. package/vendor/Package.18.mjs +1 -0
  195. package/vendor/Package.19.cjs +4466 -0
  196. package/vendor/Package.19.mjs +4442 -0
  197. package/vendor/Package.610.cjs +196 -0
  198. package/vendor/Package.610.mjs +180 -0
  199. package/vendor/Package.62.cjs +1 -1
  200. package/vendor/Package.62.mjs +1 -1
  201. package/vendor/Package.65.cjs +860 -0
  202. package/vendor/Package.65.mjs +832 -0
  203. package/vendor/Package.66.cjs +321 -0
  204. package/vendor/Package.66.mjs +305 -0
  205. package/vendor/Package.67.cjs +341 -0
  206. package/vendor/Package.67.mjs +327 -0
  207. package/vendor/Package.68.cjs +333 -0
  208. package/vendor/Package.68.mjs +315 -0
  209. package/vendor/Package.69.cjs +353 -0
  210. package/vendor/Package.69.mjs +335 -0
@@ -0,0 +1,860 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, Symbol.toStringTag, {
4
+ value: "Module"
5
+ });
6
+
7
+ const e = require("@redis/client");
8
+
9
+ const t = require("./Package.19.cjs");
10
+
11
+ const r = require("cluster-key-slot");
12
+
13
+ require("./Package.1.cjs");
14
+
15
+ require("events");
16
+
17
+ require("buffer");
18
+
19
+ require("./Package.5.cjs");
20
+
21
+ require("./Package.12.cjs");
22
+
23
+ require("./Package.8.cjs");
24
+
25
+ require("os");
26
+
27
+ require("path");
28
+
29
+ require("stream");
30
+
31
+ require("fs");
32
+
33
+ require("./Package.18.cjs");
34
+
35
+ require("constants");
36
+
37
+ require("./Package.10.cjs");
38
+
39
+ require("url");
40
+
41
+ require("util");
42
+
43
+ require("./Package.16.cjs");
44
+
45
+ require("assert");
46
+
47
+ require("./Package.13.cjs");
48
+
49
+ require("../src/components/cacher/options/CacherOptions.cjs");
50
+
51
+ require("./Package.2.cjs");
52
+
53
+ require("../src/lib/base/internal/DataValidator.cjs");
54
+
55
+ require("./Package.4.cjs");
56
+
57
+ require("node:util/types");
58
+
59
+ require("../src/lib/validation/VLD.cjs");
60
+
61
+ require("../src/exceptions/dto/InvalidValueException.cjs");
62
+
63
+ require("../src/lib/base/abstracts/Exception.cjs");
64
+
65
+ require("../src/lib/base/internal/BasicInfo.cjs");
66
+
67
+ require("../src/lib/helpers/As.cjs");
68
+
69
+ require("./Package.6.cjs");
70
+
71
+ require("./Package.7.cjs");
72
+
73
+ require("../src/lib/base/internal/ThrowWarning.cjs");
74
+
75
+ require("../src/lib/helpers/Templating.cjs");
76
+
77
+ require("../src/lib/base/internal/CamelCase.cjs");
78
+
79
+ require("../src/lib/helpers/NoCase.cjs");
80
+
81
+ require("./Package.9.cjs");
82
+
83
+ require("../src/lib/helpers/IsHtml.cjs");
84
+
85
+ require("../src/lib/helpers/IsXML.cjs");
86
+
87
+ require("../src/constants/DTOMetadataKey.cjs");
88
+
89
+ require("../src/lib/helpers/ObjectConstructor.cjs");
90
+
91
+ require("../src/lib/helpers/ObjectParentConstructors.cjs");
92
+
93
+ require("../src/lib/helpers/ObjectParentConstructor.cjs");
94
+
95
+ require("../src/lib/helpers/ObjectPrototype.cjs");
96
+
97
+ require("../src/decorators/dto/Expect.cjs");
98
+
99
+ require("../src/components/cacher/options/FileCacheOptions.cjs");
100
+
101
+ require("../src/components/cacher/options/MemcacheCacheOptions.cjs");
102
+
103
+ require("../src/components/cacher/options/MongoCacheOptions.cjs");
104
+
105
+ require("../src/components/cacher/options/PostgresCacheOptions.cjs");
106
+
107
+ require("../src/components/cacher/options/MysqlCacheOptions.cjs");
108
+
109
+ require("../src/components/cacher/options/SqliteCacheOptions.cjs");
110
+
111
+ require("../src/components/cacher/options/RedisCacheOptions.cjs");
112
+
113
+ require("../src/lib/core/Component.cjs");
114
+
115
+ require("./Package.3.cjs");
116
+
117
+ require("../src/lib/base/async-constructor/AsyncConstructor.cjs");
118
+
119
+ require("../src/lib/base/async-constructor/Append.cjs");
120
+
121
+ require("../src/lib/helpers/IsPromiseLike.cjs");
122
+
123
+ require("../src/lib/helpers/IsPromise.cjs");
124
+
125
+ require("util/types");
126
+
127
+ require("../src/decorators/di/Lifetime.cjs");
128
+
129
+ require("../src/lib/base/internal/ObjectLifetime.cjs");
130
+
131
+ require("../src/constants/DIMetadataKey.cjs");
132
+
133
+ require("../src/exceptions/di/LifetimeLockedException.cjs");
134
+
135
+ require("../src/exceptions/MethodNotFoundException.cjs");
136
+
137
+ require("../src/lib/ioc/DependencyInjectionContainer.cjs");
138
+
139
+ require("../src/lib/ioc/Errors.cjs");
140
+
141
+ require("../src/exceptions/di/DependencyInjectionException.cjs");
142
+
143
+ require("../src/lib/base/internal/ConstructorSymbol.cjs");
144
+
145
+ require("node:crypto");
146
+
147
+ require("../src/lib/ioc/InjectionMode.cjs");
148
+
149
+ require("../src/lib/ioc/Lifetime.cjs");
150
+
151
+ require("../src/lib/ioc/ListModules.cjs");
152
+
153
+ require("../src/lib/ioc/Utils.cjs");
154
+
155
+ require("../src/lib/ioc/FunctionTokenizer.cjs");
156
+
157
+ require("../src/lib/ioc/LoadModules.cjs");
158
+
159
+ require("../src/lib/ioc/Resolvers.cjs");
160
+
161
+ require("../src/lib/ioc/ParamParser.cjs");
162
+
163
+ require("../src/lib/base/internal/ObjectWeakRefs.cjs");
164
+
165
+ require("../src/lib/base/internal/ConfigurableRecordsInjection.cjs");
166
+
167
+ require("../src/lib/base/internal/ObjectConfiguration.cjs");
168
+
169
+ require("../src/lib/base/internal/ObjectInjection.cjs");
170
+
171
+ require("../src/lib/base/internal/ObjectContainer.cjs");
172
+
173
+ require("../src/lib/helpers/DevNull.cjs");
174
+
175
+ require("../src/decorators/dto/IndexSignature.cjs");
176
+
177
+ require("../src/decorators/dto/Accept.cjs");
178
+
179
+ require("../src/lib/base/internal/MethodValidation.cjs");
180
+
181
+ require("../src/exceptions/dto/InvalidMethodAcceptException.cjs");
182
+
183
+ require("../src/exceptions/dto/InvalidMethodReturnException.cjs");
184
+
185
+ require("../src/lib/helpers/IsEmptyObject.cjs");
186
+
187
+ require("../src/lib/base/EventEmitter.cjs");
188
+
189
+ require("../src/lib/core/Provider.cjs");
190
+
191
+ require("../src/decorators/di/Configurable.cjs");
192
+
193
+ require("../src/lib/helpers/URLBuilder.cjs");
194
+
195
+ const s = e => e && e.__esModule ? e : {
196
+ default: e
197
+ };
198
+
199
+ const i = s(r);
200
+
201
+ var n = class {
202
+ _eventListeners;
203
+ _maxListeners;
204
+ _logger;
205
+ constructor(e) {
206
+ this._eventListeners = new Map, this._maxListeners = 100, this._logger = e?.logger;
207
+ }
208
+ once(e, t) {
209
+ let r = (...s) => {
210
+ this.off(e, r), t(...s);
211
+ };
212
+ return this.on(e, r), this;
213
+ }
214
+ listenerCount(e) {
215
+ if (!e) return this.getAllListeners().length;
216
+ let t = this._eventListeners.get(e);
217
+ return t ? t.length : 0;
218
+ }
219
+ eventNames() {
220
+ return [ ...this._eventListeners.keys() ];
221
+ }
222
+ rawListeners(e) {
223
+ return e ? this._eventListeners.get(e) ?? [] : this.getAllListeners();
224
+ }
225
+ prependListener(e, t) {
226
+ let r = this._eventListeners.get(e) ?? [];
227
+ return r.unshift(t), this._eventListeners.set(e, r), this;
228
+ }
229
+ prependOnceListener(e, t) {
230
+ let r = (...s) => {
231
+ this.off(e, r), t(...s);
232
+ };
233
+ return this.prependListener(e, r), this;
234
+ }
235
+ maxListeners() {
236
+ return this._maxListeners;
237
+ }
238
+ addListener(e, t) {
239
+ return this.on(e, t), this;
240
+ }
241
+ on(e, t) {
242
+ this._eventListeners.has(e) || this._eventListeners.set(e, []);
243
+ let r = this._eventListeners.get(e);
244
+ return r && (r.length >= this._maxListeners && console.warn(`MaxListenersExceededWarning: Possible event memory leak detected. ${r.length + 1} ${e} listeners added. Use setMaxListeners() to increase limit.`),
245
+ r.push(t)), this;
246
+ }
247
+ removeListener(e, t) {
248
+ return this.off(e, t), this;
249
+ }
250
+ off(e, t) {
251
+ let r = this._eventListeners.get(e) ?? [], s = r.indexOf(t);
252
+ return s !== -1 && r.splice(s, 1), r.length === 0 && this._eventListeners.delete(e),
253
+ this;
254
+ }
255
+ emit(e, ...t) {
256
+ let r = !1, s = this._eventListeners.get(e);
257
+ if (s && s.length > 0) for (let e of s) e(...t), r = !0;
258
+ return r;
259
+ }
260
+ listeners(e) {
261
+ return this._eventListeners.get(e) ?? [];
262
+ }
263
+ removeAllListeners(e) {
264
+ return e ? this._eventListeners.delete(e) : this._eventListeners.clear(), this;
265
+ }
266
+ setMaxListeners(e) {
267
+ this._maxListeners = e;
268
+ for (let t of this._eventListeners.values()) t.length > e && t.splice(e);
269
+ }
270
+ getAllListeners() {
271
+ let e = new Array;
272
+ for (let t of this._eventListeners.values()) e = [ ...e, ...t ];
273
+ return e;
274
+ }
275
+ };
276
+
277
+ var o = class extends n {
278
+ _hooks;
279
+ _throwHookErrors=!1;
280
+ constructor(e) {
281
+ super({
282
+ logger: e?.logger
283
+ }), this._hooks = new Map, e?.throwHookErrors !== void 0 && (this._throwHookErrors = e.throwHookErrors);
284
+ }
285
+ get hooks() {
286
+ return this._hooks;
287
+ }
288
+ get throwHookErrors() {
289
+ return this._throwHookErrors;
290
+ }
291
+ set throwHookErrors(e) {
292
+ this._throwHookErrors = e;
293
+ }
294
+ get logger() {
295
+ return this._logger;
296
+ }
297
+ set logger(e) {
298
+ this._logger = e;
299
+ }
300
+ onHook(e, t) {
301
+ let r = this._hooks.get(e);
302
+ r ? r.push(t) : this._hooks.set(e, [ t ]);
303
+ }
304
+ addHook(e, t) {
305
+ this.onHook(e, t);
306
+ }
307
+ onHooks(e) {
308
+ for (let t of e) this.onHook(t.event, t.handler);
309
+ }
310
+ prependHook(e, t) {
311
+ let r = this._hooks.get(e);
312
+ r ? r.unshift(t) : this._hooks.set(e, [ t ]);
313
+ }
314
+ prependOnceHook(e, t) {
315
+ let r = async (...s) => (this.removeHook(e, r), t(...s));
316
+ this.prependHook(e, r);
317
+ }
318
+ onceHook(e, t) {
319
+ let r = async (...s) => (this.removeHook(e, r), t(...s));
320
+ this.onHook(e, r);
321
+ }
322
+ removeHook(e, t) {
323
+ let r = this._hooks.get(e);
324
+ if (r) {
325
+ let e = r.indexOf(t);
326
+ e !== -1 && r.splice(e, 1);
327
+ }
328
+ }
329
+ removeHooks(e) {
330
+ for (let t of e) this.removeHook(t.event, t.handler);
331
+ }
332
+ async hook(e, ...t) {
333
+ let r = this._hooks.get(e);
334
+ if (r) for (let s of r) try {
335
+ await s(...t);
336
+ } catch (t) {
337
+ let r = `${e}: ${t.message}`;
338
+ if (this.emit("error", new Error(r)), this._logger && this._logger.error(r), this._throwHookErrors) throw new Error(r);
339
+ }
340
+ }
341
+ async callHook(e, ...t) {
342
+ await this.hook(e, ...t);
343
+ }
344
+ getHooks(e) {
345
+ return this._hooks.get(e);
346
+ }
347
+ clearHooks() {
348
+ this._hooks.clear();
349
+ }
350
+ };
351
+
352
+ var c = (e => {
353
+ e["RedisClientNotConnectedThrown"] = "Redis client is not connected or has failed to connect. This is thrown because throwOnConnectError is set to true.";
354
+ return e;
355
+ })(c || {});
356
+
357
+ var a = e => {
358
+ const t = Math.min(2 ** e * 100, 2e3);
359
+ const r = (Math.random() - .5) * 100;
360
+ return t + r;
361
+ };
362
+
363
+ var l = class extends o {
364
+ _client=e.createClient();
365
+ _namespace;
366
+ _keyPrefixSeparator="::";
367
+ _clearBatchSize=1e3;
368
+ _useUnlink=true;
369
+ _noNamespaceAffectsAll=false;
370
+ _throwOnConnectError=true;
371
+ _throwErrors=false;
372
+ _connectionTimeout;
373
+ constructor(t, r) {
374
+ super();
375
+ const s = {
376
+ reconnectStrategy: a
377
+ };
378
+ if (t) {
379
+ if (typeof t === "string") {
380
+ this._client = e.createClient({
381
+ url: t,
382
+ socket: s
383
+ });
384
+ } else if (t.connect !== void 0) {
385
+ this._client = this.isClientCluster(t) ? t : t;
386
+ } else if (t instanceof Object) {
387
+ this._client = t.rootNodes === void 0 ? e.createClient(t) : e.createCluster(t);
388
+ }
389
+ }
390
+ this.setOptions(r);
391
+ this.initClient();
392
+ }
393
+ get client() {
394
+ return this._client;
395
+ }
396
+ set client(e) {
397
+ this._client = e;
398
+ this.initClient();
399
+ }
400
+ get opts() {
401
+ let e = "redis://localhost:6379";
402
+ if (this._client.options) {
403
+ const t = this._client.options?.url;
404
+ if (t) {
405
+ e = t;
406
+ }
407
+ }
408
+ const t = {
409
+ namespace: this._namespace,
410
+ keyPrefixSeparator: this._keyPrefixSeparator,
411
+ clearBatchSize: this._clearBatchSize,
412
+ noNamespaceAffectsAll: this._noNamespaceAffectsAll,
413
+ useUnlink: this._useUnlink,
414
+ throwOnConnectError: this._throwOnConnectError,
415
+ throwErrors: this._throwErrors,
416
+ connectionTimeout: this._connectionTimeout,
417
+ dialect: "redis",
418
+ url: e
419
+ };
420
+ return t;
421
+ }
422
+ set opts(e) {
423
+ this.setOptions(e);
424
+ }
425
+ get namespace() {
426
+ return this._namespace;
427
+ }
428
+ set namespace(e) {
429
+ this._namespace = e;
430
+ }
431
+ get keyPrefixSeparator() {
432
+ return this._keyPrefixSeparator;
433
+ }
434
+ set keyPrefixSeparator(e) {
435
+ this._keyPrefixSeparator = e;
436
+ }
437
+ get clearBatchSize() {
438
+ return this._clearBatchSize;
439
+ }
440
+ set clearBatchSize(e) {
441
+ if (e > 0) {
442
+ this._clearBatchSize = e;
443
+ } else {
444
+ this.emit("error", "clearBatchSize must be greater than 0");
445
+ }
446
+ }
447
+ get useUnlink() {
448
+ return this._useUnlink;
449
+ }
450
+ set useUnlink(e) {
451
+ this._useUnlink = e;
452
+ }
453
+ get noNamespaceAffectsAll() {
454
+ return this._noNamespaceAffectsAll;
455
+ }
456
+ set noNamespaceAffectsAll(e) {
457
+ this._noNamespaceAffectsAll = e;
458
+ }
459
+ get throwOnConnectError() {
460
+ return this._throwOnConnectError;
461
+ }
462
+ set throwOnConnectError(e) {
463
+ this._throwOnConnectError = e;
464
+ }
465
+ get throwErrors() {
466
+ return this._throwErrors;
467
+ }
468
+ set throwErrors(e) {
469
+ this._throwErrors = e;
470
+ }
471
+ get connectionTimeout() {
472
+ return this._connectionTimeout;
473
+ }
474
+ set connectionTimeout(e) {
475
+ this._connectionTimeout = e;
476
+ }
477
+ async getClient() {
478
+ if (this._client.isOpen) {
479
+ return this._client;
480
+ }
481
+ try {
482
+ if (this._connectionTimeout === void 0) {
483
+ await this._client.connect();
484
+ } else {
485
+ await Promise.race([ this._client.connect(), this.createTimeoutPromise(this._connectionTimeout) ]);
486
+ }
487
+ } catch (e) {
488
+ this.emit("error", e);
489
+ if (this._throwOnConnectError) {
490
+ throw new Error("Redis client is not connected or has failed to connect. This is thrown because throwOnConnectError is set to true.");
491
+ }
492
+ await this.disconnect(true);
493
+ }
494
+ this.initClient();
495
+ return this._client;
496
+ }
497
+ async set(e, t, r) {
498
+ const s = await this.getClient();
499
+ try {
500
+ e = this.createKeyPrefix(e, this._namespace);
501
+ if (r) {
502
+ await s.set(e, t, {
503
+ PX: r
504
+ });
505
+ } else {
506
+ await s.set(e, t);
507
+ }
508
+ } catch (e) {
509
+ this.emit("error", e);
510
+ if (this._throwErrors) {
511
+ throw e;
512
+ }
513
+ }
514
+ }
515
+ async setMany(e) {
516
+ const t = await this.getClient();
517
+ try {
518
+ const r = t.multi();
519
+ for (const {key: t, value: s, ttl: i} of e) {
520
+ const e = this.createKeyPrefix(t, this._namespace);
521
+ if (i) {
522
+ r.set(e, s, {
523
+ PX: i
524
+ });
525
+ } else {
526
+ r.set(e, s);
527
+ }
528
+ }
529
+ await r.exec();
530
+ } catch (e) {
531
+ this.emit("error", e);
532
+ if (this._throwErrors) {
533
+ throw e;
534
+ }
535
+ }
536
+ }
537
+ async has(e) {
538
+ const t = await this.getClient();
539
+ try {
540
+ e = this.createKeyPrefix(e, this._namespace);
541
+ const r = await t.exists(e);
542
+ return r === 1;
543
+ } catch (e) {
544
+ this.emit("error", e);
545
+ if (this._throwErrors) {
546
+ throw e;
547
+ }
548
+ return false;
549
+ }
550
+ }
551
+ async hasMany(e) {
552
+ const t = await this.getClient();
553
+ try {
554
+ const r = t.multi();
555
+ for (const t of e) {
556
+ const e = this.createKeyPrefix(t, this._namespace);
557
+ r.exists(e);
558
+ }
559
+ const s = await r.exec();
560
+ return s.map((e => e === 1));
561
+ } catch (t) {
562
+ this.emit("error", t);
563
+ if (this._throwErrors) {
564
+ throw t;
565
+ }
566
+ return Array.from({
567
+ length: e.length
568
+ }).fill(false);
569
+ }
570
+ }
571
+ async get(e) {
572
+ const t = await this.getClient();
573
+ try {
574
+ e = this.createKeyPrefix(e, this._namespace);
575
+ const r = await t.get(e);
576
+ if (r === null) {
577
+ return void 0;
578
+ }
579
+ return r;
580
+ } catch (e) {
581
+ this.emit("error", e);
582
+ if (this._throwErrors) {
583
+ throw e;
584
+ }
585
+ return void 0;
586
+ }
587
+ }
588
+ async getMany(e) {
589
+ if (e.length === 0) {
590
+ return [];
591
+ }
592
+ e = e.map((e => this.createKeyPrefix(e, this._namespace)));
593
+ try {
594
+ const t = await this.mget(e);
595
+ return t;
596
+ } catch (t) {
597
+ this.emit("error", t);
598
+ if (this._throwErrors) {
599
+ throw t;
600
+ }
601
+ return Array.from({
602
+ length: e.length
603
+ }).fill(void 0);
604
+ }
605
+ }
606
+ async delete(e) {
607
+ const t = await this.getClient();
608
+ try {
609
+ e = this.createKeyPrefix(e, this._namespace);
610
+ let r = 0;
611
+ r = await (this._useUnlink ? t.unlink(e) : t.del(e));
612
+ return r > 0;
613
+ } catch (e) {
614
+ this.emit("error", e);
615
+ if (this._throwErrors) {
616
+ throw e;
617
+ }
618
+ return false;
619
+ }
620
+ }
621
+ async deleteMany(e) {
622
+ let t = false;
623
+ const r = await this.getClient();
624
+ try {
625
+ const s = r.multi();
626
+ for (const t of e) {
627
+ const e = this.createKeyPrefix(t, this._namespace);
628
+ if (this._useUnlink) {
629
+ s.unlink(e);
630
+ } else {
631
+ s.del(e);
632
+ }
633
+ }
634
+ const i = await s.exec();
635
+ for (const e of i) {
636
+ if (typeof e === "number" && e > 0) {
637
+ t = true;
638
+ }
639
+ }
640
+ } catch (e) {
641
+ this.emit("error", e);
642
+ if (this._throwErrors) {
643
+ throw e;
644
+ }
645
+ }
646
+ return t;
647
+ }
648
+ async disconnect(e) {
649
+ if (this._client.isOpen) {
650
+ await (e ? this._client.disconnect() : this._client.quit());
651
+ }
652
+ }
653
+ createKeyPrefix(e, t) {
654
+ if (t) {
655
+ return `${t}${this._keyPrefixSeparator}${e}`;
656
+ }
657
+ return e;
658
+ }
659
+ getKeyWithoutPrefix(e, t) {
660
+ if (t) {
661
+ return e.replace(`${t}${this._keyPrefixSeparator}`, "");
662
+ }
663
+ return e;
664
+ }
665
+ isCluster() {
666
+ return this.isClientCluster(this._client);
667
+ }
668
+ async getMasterNodes() {
669
+ if (this.isCluster()) {
670
+ const e = await this.getClient();
671
+ return Promise.all(e.masters.map((async t => e.nodeClient(t))));
672
+ }
673
+ return [ await this.getClient() ];
674
+ }
675
+ async* iterator(e) {
676
+ const t = await this.getMasterNodes();
677
+ for (const r of t) {
678
+ const t = e ? `${e}${this._keyPrefixSeparator}*` : "*";
679
+ let s = "0";
680
+ do {
681
+ const i = await r.scan(Number.parseInt(s, 10), {
682
+ MATCH: t,
683
+ TYPE: "string"
684
+ });
685
+ s = i.cursor.toString();
686
+ let {keys: n} = i;
687
+ if (!e && !this._noNamespaceAffectsAll) {
688
+ n = n.filter((e => !e.includes(this._keyPrefixSeparator)));
689
+ }
690
+ if (n.length > 0) {
691
+ const t = await this.mget(n);
692
+ for (const r of n.keys()) {
693
+ const s = this.getKeyWithoutPrefix(n[r], e);
694
+ const i = t[r];
695
+ yield [ s, i ];
696
+ }
697
+ }
698
+ } while (s !== "0");
699
+ }
700
+ }
701
+ async clear() {
702
+ try {
703
+ const e = await this.getMasterNodes();
704
+ await Promise.all(e.map((async e => {
705
+ if (!this._namespace && this._noNamespaceAffectsAll) {
706
+ await e.flushDb();
707
+ return;
708
+ }
709
+ let t = "0";
710
+ const r = this._clearBatchSize;
711
+ const s = this._namespace ? `${this._namespace}${this._keyPrefixSeparator}*` : "*";
712
+ const i = [];
713
+ do {
714
+ const n = await e.scan(Number.parseInt(t, 10), {
715
+ MATCH: s,
716
+ COUNT: r,
717
+ TYPE: "string"
718
+ });
719
+ t = n.cursor.toString();
720
+ let {keys: o} = n;
721
+ if (o.length === 0) {
722
+ continue;
723
+ }
724
+ if (!this._namespace) {
725
+ o = o.filter((e => !e.includes(this._keyPrefixSeparator)));
726
+ }
727
+ i.push(this.clearWithClusterSupport(o));
728
+ } while (t !== "0");
729
+ await Promise.all(i);
730
+ })));
731
+ } catch (e) {
732
+ this.emit("error", e);
733
+ }
734
+ }
735
+ async mget(e) {
736
+ const t = this.getSlotMap(e);
737
+ const r = new Map;
738
+ await Promise.all(Array.from(t.entries(), (async ([e, t]) => {
739
+ const s = await this.getSlotMaster(e);
740
+ const i = await s.mGet(t);
741
+ for (const [e, s] of i.entries()) {
742
+ r.set(t[e], s ?? void 0);
743
+ }
744
+ })));
745
+ return e.map((e => r.get(e)));
746
+ }
747
+ async clearWithClusterSupport(e) {
748
+ if (e.length > 0) {
749
+ const t = this.getSlotMap(e);
750
+ await Promise.all(Array.from(t.entries(), (async ([e, t]) => {
751
+ const r = await this.getSlotMaster(e);
752
+ return this._useUnlink ? r.unlink(t) : r.del(t);
753
+ })));
754
+ }
755
+ }
756
+ async getSlotMaster(e) {
757
+ const t = await this.getClient();
758
+ if (this.isCluster()) {
759
+ const r = t;
760
+ const s = r.slots[e].master;
761
+ return r.nodeClient(s);
762
+ }
763
+ return t;
764
+ }
765
+ getSlotMap(e) {
766
+ const t = new Map;
767
+ if (this.isCluster()) {
768
+ for (const r of e) {
769
+ const e = i.default(r);
770
+ const s = t.get(e) ?? [];
771
+ s.push(r);
772
+ t.set(e, s);
773
+ }
774
+ } else {
775
+ t.set(0, e);
776
+ }
777
+ return t;
778
+ }
779
+ isClientCluster(e) {
780
+ if (e.options === void 0 && e.scan === void 0) {
781
+ return true;
782
+ }
783
+ return false;
784
+ }
785
+ setOptions(e) {
786
+ if (!e) {
787
+ return;
788
+ }
789
+ if (e.namespace) {
790
+ this._namespace = e.namespace;
791
+ }
792
+ if (e.keyPrefixSeparator !== void 0) {
793
+ this._keyPrefixSeparator = e.keyPrefixSeparator;
794
+ }
795
+ if (e.clearBatchSize !== void 0 && e.clearBatchSize > 0) {
796
+ this._clearBatchSize = e.clearBatchSize;
797
+ }
798
+ if (e.useUnlink !== void 0) {
799
+ this._useUnlink = e.useUnlink;
800
+ }
801
+ if (e.noNamespaceAffectsAll !== void 0) {
802
+ this._noNamespaceAffectsAll = e.noNamespaceAffectsAll;
803
+ }
804
+ if (e.throwOnConnectError !== void 0) {
805
+ this._throwOnConnectError = e.throwOnConnectError;
806
+ }
807
+ if (e.throwErrors !== void 0) {
808
+ this._throwErrors = e.throwErrors;
809
+ }
810
+ if (e.connectionTimeout !== void 0) {
811
+ this._connectionTimeout = e.connectionTimeout;
812
+ }
813
+ }
814
+ initClient() {
815
+ this._client.on("connect", (() => {
816
+ this.emit("connect", this._client);
817
+ }));
818
+ this._client.on("disconnect", (() => {
819
+ this.emit("disconnect", this._client);
820
+ }));
821
+ this._client.on("reconnecting", (e => {
822
+ this.emit("reconnecting", e);
823
+ }));
824
+ }
825
+ async createTimeoutPromise(e) {
826
+ return new Promise(((t, r) => setTimeout((() => {
827
+ r(new Error(`Redis timed out after ${e}ms`));
828
+ }), e)));
829
+ }
830
+ };
831
+
832
+ function h(e, r) {
833
+ e ??= "redis://localhost:6379";
834
+ const s = new l(e, r);
835
+ const i = new t.Keyv(s, {
836
+ namespace: r?.namespace,
837
+ useKeyPrefix: false
838
+ });
839
+ return i;
840
+ }
841
+
842
+ Object.defineProperty(exports, "createClient", {
843
+ enumerable: true,
844
+ get: () => e.createClient
845
+ });
846
+
847
+ Object.defineProperty(exports, "createCluster", {
848
+ enumerable: true,
849
+ get: () => e.createCluster
850
+ });
851
+
852
+ exports.Keyv = t.Keyv;
853
+
854
+ exports.RedisErrorMessages = c;
855
+
856
+ exports.createKeyv = h;
857
+
858
+ exports.default = l;
859
+
860
+ exports.defaultReconnectStrategy = a;