lakutata 2.0.66 → 2.0.68

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 (91) hide show
  1. package/com/cacher.cjs +1 -1
  2. package/com/cacher.mjs +1 -1
  3. package/com/entrypoint.cjs +3 -1
  4. package/com/entrypoint.mjs +3 -1
  5. package/decorator/ctrl.cjs +3 -1
  6. package/decorator/ctrl.mjs +3 -1
  7. package/helper.cjs +24 -18
  8. package/helper.d.ts +128 -2
  9. package/helper.mjs +6 -2
  10. package/lakutata.cjs +3 -1
  11. package/lakutata.d.ts +1 -1
  12. package/lakutata.mjs +3 -1
  13. package/package.json +1 -1
  14. package/src/components/cacher/Cacher.cjs +1 -1
  15. package/src/components/cacher/Cacher.mjs +1 -1
  16. package/src/components/cacher/adapters/CreateFileCacheAdapter.cjs +1 -1
  17. package/src/components/cacher/adapters/CreateFileCacheAdapter.mjs +1 -1
  18. package/src/components/cacher/adapters/CreateMemcacheCacheAdapter.cjs +2 -2
  19. package/src/components/cacher/adapters/CreateMemcacheCacheAdapter.mjs +2 -2
  20. package/src/components/cacher/adapters/CreateMongoCacheAdapter.cjs +2 -2
  21. package/src/components/cacher/adapters/CreateMongoCacheAdapter.mjs +2 -2
  22. package/src/components/cacher/adapters/CreateMysqlCacheAdapter.cjs +2 -2
  23. package/src/components/cacher/adapters/CreateMysqlCacheAdapter.mjs +2 -2
  24. package/src/components/cacher/adapters/CreatePostgresCacheAdapter.cjs +2 -2
  25. package/src/components/cacher/adapters/CreatePostgresCacheAdapter.mjs +2 -2
  26. package/src/components/cacher/adapters/CreateRedisCacheAdapter.cjs +2 -2
  27. package/src/components/cacher/adapters/CreateRedisCacheAdapter.mjs +2 -2
  28. package/src/components/cacher/adapters/CreateSqliteCacheAdapter.cjs +2 -2
  29. package/src/components/cacher/adapters/CreateSqliteCacheAdapter.mjs +2 -2
  30. package/src/components/entrypoint/Entrypoint.cjs +6 -1
  31. package/src/components/entrypoint/Entrypoint.mjs +6 -1
  32. package/src/decorators/ctrl/CLIAction.cjs +7 -5
  33. package/src/decorators/ctrl/CLIAction.mjs +3 -1
  34. package/src/decorators/ctrl/HTTPAction.cjs +8 -6
  35. package/src/decorators/ctrl/HTTPAction.mjs +3 -1
  36. package/src/decorators/ctrl/ServiceAction.cjs +3 -1
  37. package/src/decorators/ctrl/ServiceAction.mjs +7 -5
  38. package/src/decorators/ctrl/http/DELETE.cjs +3 -1
  39. package/src/decorators/ctrl/http/DELETE.mjs +3 -1
  40. package/src/decorators/ctrl/http/GET.cjs +3 -1
  41. package/src/decorators/ctrl/http/GET.mjs +3 -1
  42. package/src/decorators/ctrl/http/HEAD.cjs +3 -1
  43. package/src/decorators/ctrl/http/HEAD.mjs +3 -1
  44. package/src/decorators/ctrl/http/OPTIONS.cjs +3 -1
  45. package/src/decorators/ctrl/http/OPTIONS.mjs +3 -1
  46. package/src/decorators/ctrl/http/PATCH.cjs +3 -1
  47. package/src/decorators/ctrl/http/PATCH.mjs +3 -1
  48. package/src/decorators/ctrl/http/POST.cjs +3 -1
  49. package/src/decorators/ctrl/http/POST.mjs +3 -1
  50. package/src/decorators/ctrl/http/PUT.cjs +3 -1
  51. package/src/decorators/ctrl/http/PUT.mjs +3 -1
  52. package/src/lib/base/internal/ControllerEntrypoint.cjs +70 -610
  53. package/src/lib/base/internal/ControllerEntrypoint.mjs +87 -627
  54. package/src/lib/base/internal/StringifyPattern.cjs +1 -1
  55. package/src/lib/base/internal/StringifyPattern.mjs +1 -1
  56. package/src/lib/core/Application.cjs +3 -1
  57. package/src/lib/core/Application.mjs +3 -1
  58. package/src/lib/helpers/MD5.cjs +1 -1
  59. package/src/lib/helpers/MD5.mjs +1 -1
  60. package/src/lib/helpers/SHA1.cjs +1 -1
  61. package/src/lib/helpers/SHA1.mjs +1 -1
  62. package/src/lib/helpers/SHA256.cjs +1 -1
  63. package/src/lib/helpers/SHA256.mjs +1 -1
  64. package/src/lib/helpers/SortArray.cjs +1 -1
  65. package/src/lib/helpers/SortArray.mjs +1 -1
  66. package/src/lib/helpers/UUID.cjs +45 -0
  67. package/src/lib/helpers/UUID.mjs +39 -0
  68. package/vendor/Package.19.cjs +1 -1
  69. package/vendor/Package.19.mjs +176 -187
  70. package/vendor/Package.610.cjs +297 -113
  71. package/vendor/Package.610.mjs +285 -97
  72. package/vendor/Package.611.cjs +85 -103
  73. package/vendor/Package.611.mjs +80 -98
  74. package/vendor/Package.612.cjs +100 -121
  75. package/vendor/Package.612.mjs +97 -120
  76. package/vendor/Package.613.cjs +196 -0
  77. package/vendor/Package.613.mjs +180 -0
  78. package/vendor/Package.64.cjs +511 -134
  79. package/vendor/Package.64.mjs +491 -134
  80. package/vendor/Package.65.cjs +140 -4118
  81. package/vendor/Package.65.mjs +140 -4126
  82. package/vendor/Package.66.cjs +4142 -692
  83. package/vendor/Package.66.mjs +4151 -689
  84. package/vendor/Package.67.cjs +571 -535
  85. package/vendor/Package.67.mjs +586 -528
  86. package/vendor/Package.68.cjs +633 -96
  87. package/vendor/Package.68.mjs +619 -94
  88. package/vendor/Package.69.cjs +96 -294
  89. package/vendor/Package.69.mjs +95 -295
  90. package/vendor/TypeDef.internal.13.d.ts +1 -0
  91. package/vendor/TypeDef.internal.5.d.ts +1 -1
@@ -6,336 +6,138 @@ Object.defineProperty(exports, Symbol.toStringTag, {
6
6
 
7
7
  const e = require("events");
8
8
 
9
- const t = require("buffer");
9
+ const t = require("memjs");
10
10
 
11
- const n = require("mongodb");
11
+ const s = require("./Package.67.cjs");
12
12
 
13
- const s = e => e && e.__esModule ? e : {
13
+ require("buffer");
14
+
15
+ const r = e => e && e.__esModule ? e : {
14
16
  default: e
15
17
  };
16
18
 
17
- const o = s(e);
19
+ const i = r(e);
18
20
 
19
- var a = new Set([ "url", "collection", "namespace", "serialize", "deserialize", "uri", "useGridFS", "dialect", "db" ]);
21
+ const a = r(t);
20
22
 
21
- var i = class extends o.default {
22
- ttlSupport=false;
23
- opts;
24
- connect;
23
+ var n = class extends i.default {
24
+ ttlSupport=true;
25
25
  namespace;
26
+ client;
27
+ opts;
26
28
  constructor(e, t) {
27
29
  super();
28
- e ??= {};
29
- if (typeof e === "string") {
30
- e = {
31
- url: e
32
- };
33
- }
34
- if (e.uri) {
35
- e = {
36
- url: e.uri,
37
- ...e
38
- };
39
- }
40
- this.opts = {
41
- url: "mongodb://127.0.0.1:27017",
42
- collection: "keyv",
43
- ...e,
30
+ t = {
31
+ ...typeof e === "string" ? {
32
+ uri: e
33
+ } : e,
44
34
  ...t
45
35
  };
46
- delete this.opts.emitErrors;
47
- const s = Object.fromEntries(Object.entries(this.opts).filter((([e]) => !a.has(e))));
48
- this.opts = Object.fromEntries(Object.entries(this.opts).filter((([e]) => a.has(e))));
49
- this.connect = new Promise((async (e, t) => {
50
- try {
51
- let t = "";
52
- if (this.opts.url) {
53
- t = this.opts.url;
54
- }
55
- const o = new n.MongoClient(t, s);
56
- await o.connect();
57
- const a = o.db(this.opts.db);
58
- if (this.opts.useGridFS) {
59
- const t = new n.GridFSBucket(a, {
60
- readPreference: this.opts.readPreference,
61
- bucketName: this.opts.collection
62
- });
63
- const s = a.collection(`${this.opts.collection}.files`);
64
- await s.createIndex({
65
- uploadDate: -1
66
- });
67
- await s.createIndex({
68
- "metadata.expiresAt": 1
69
- });
70
- await s.createIndex({
71
- "metadata.lastAccessed": 1
72
- });
73
- await s.createIndex({
74
- "metadata.filename": 1
75
- });
76
- e({
77
- bucket: t,
78
- store: s,
79
- db: a,
80
- mongoClient: o
81
- });
82
- } else {
83
- let t = "keyv";
84
- if (this.opts.collection) {
85
- t = this.opts.collection;
86
- }
87
- const n = a.collection(t);
88
- await n.createIndex({
89
- key: 1
90
- }, {
91
- unique: true,
92
- background: true
93
- });
94
- await n.createIndex({
95
- expiresAt: 1
96
- }, {
97
- expireAfterSeconds: 0,
98
- background: true
99
- });
100
- e({
101
- store: n,
102
- mongoClient: o
103
- });
104
- }
105
- } catch (e) {
106
- this.emit("error", e);
107
- }
108
- }));
36
+ if (t.uri && t.url === void 0) {
37
+ t.url = t.uri;
38
+ }
39
+ if (e === void 0) {
40
+ e = "localhost:11211";
41
+ t.url = t.uri = e;
42
+ }
43
+ this.opts = t;
44
+ this.client = a.default.Client.create(e, t);
45
+ }
46
+ _getNamespace() {
47
+ return `namespace:${this.namespace}`;
109
48
  }
110
49
  async get(e) {
111
- const n = await this.connect;
112
- if (this.opts.useGridFS) {
113
- await n.store.updateOne({
114
- filename: e
115
- }, {
116
- $set: {
117
- "metadata.lastAccessed": new Date
50
+ return new Promise(((t, r) => {
51
+ this.client.get(this.formatKey(e), ((e, i) => {
52
+ if (e) {
53
+ this.emit("error", e);
54
+ r(e);
55
+ } else {
56
+ let e;
57
+ if (i === null) {
58
+ e = {
59
+ value: void 0,
60
+ expires: 0
61
+ };
62
+ } else {
63
+ e = this.opts.deserialize ? this.opts.deserialize(i) : s.defaultDeserialize(i);
64
+ }
65
+ t(e);
118
66
  }
119
- });
120
- const s = n.bucket.openDownloadStreamByName(e);
121
- return new Promise((e => {
122
- const n = [];
123
- s.on("error", (() => {
124
- e(void 0);
125
- }));
126
- s.on("end", (() => {
127
- const s = t.Buffer.concat(n).toString("utf8");
128
- e(s);
129
- }));
130
- s.on("data", (e => {
131
- n.push(e);
132
- }));
133
67
  }));
134
- }
135
- const s = await n.store.findOne({
136
- key: {
137
- $eq: e
138
- }
139
- });
140
- if (!s) {
141
- return void 0;
142
- }
143
- return s.value;
68
+ }));
144
69
  }
145
70
  async getMany(e) {
146
- if (this.opts.useGridFS) {
147
- const t = [];
148
- for (const n of e) {
149
- t.push(this.get(n));
150
- }
151
- const n = await Promise.allSettled(t);
152
- const s = [];
153
- for (const e of n) {
154
- s.push(e.value);
155
- }
156
- return s;
71
+ const t = [];
72
+ for (const s of e) {
73
+ t.push(this.get(s));
157
74
  }
158
- const t = await this.connect;
159
- const n = await t.store.s.db.collection(this.opts.collection).find({
160
- key: {
161
- $in: e
75
+ return Promise.allSettled(t).then((e => {
76
+ const t = [];
77
+ for (const s of e) {
78
+ t.push(s.value);
162
79
  }
163
- }).project({
164
- _id: 0,
165
- value: 1,
166
- key: 1
167
- }).toArray();
168
- const s = [ ...e ];
169
- let o = 0;
170
- for (const t of e) {
171
- const e = n.findIndex((e => e.key === t));
172
- s[o] = e > -1 ? n[e].value : void 0;
173
- o++;
174
- }
175
- return s;
80
+ return t;
81
+ }));
176
82
  }
177
- async set(e, t, n) {
178
- const s = typeof n === "number" ? new Date(Date.now() + n) : null;
179
- if (this.opts.useGridFS) {
180
- const n = await this.connect;
181
- const o = n.bucket.openUploadStream(e, {
182
- metadata: {
183
- expiresAt: s,
184
- lastAccessed: new Date
185
- }
186
- });
187
- return new Promise((e => {
188
- o.on("finish", (() => {
189
- e(o);
190
- }));
191
- o.end(t);
192
- }));
83
+ async set(e, t, s) {
84
+ const r = {};
85
+ if (s !== void 0) {
86
+ r.expires = r.ttl = Math.floor(s / 1e3);
193
87
  }
194
- const o = await this.connect;
195
- await o.store.updateOne({
196
- key: {
197
- $eq: e
198
- }
199
- }, {
200
- $set: {
201
- key: e,
202
- value: t,
203
- expiresAt: s
204
- }
205
- }, {
206
- upsert: true
207
- });
88
+ await this.client.set(this.formatKey(e), t, r);
208
89
  }
209
90
  async delete(e) {
210
- if (typeof e !== "string") {
211
- return false;
212
- }
213
- const t = await this.connect;
214
- if (this.opts.useGridFS) {
215
- try {
216
- const s = t.db;
217
- const o = new n.GridFSBucket(s, {
218
- bucketName: this.opts.collection
219
- });
220
- const a = await o.find({
221
- filename: e
222
- }).toArray();
223
- await t.bucket.delete(a[0]._id);
224
- return true;
225
- } catch {
226
- return false;
227
- }
228
- }
229
- const s = await t.store.deleteOne({
230
- key: {
231
- $eq: e
232
- }
233
- });
234
- return s.deletedCount > 0;
91
+ return new Promise(((t, s) => {
92
+ this.client.delete(this.formatKey(e), ((e, r) => {
93
+ if (e) {
94
+ this.emit("error", e);
95
+ s(e);
96
+ } else {
97
+ t(Boolean(r));
98
+ }
99
+ }));
100
+ }));
235
101
  }
236
102
  async deleteMany(e) {
237
- const t = await this.connect;
238
- if (this.opts.useGridFS) {
239
- const s = t.db;
240
- const o = new n.GridFSBucket(s, {
241
- bucketName: this.opts.collection
242
- });
243
- const a = await o.find({
244
- filename: {
245
- $in: e
246
- }
247
- }).toArray();
248
- if (a.length === 0) {
249
- return false;
250
- }
251
- await Promise.all(a.map((async e => t.bucket.delete(e._id))));
252
- return true;
253
- }
254
- const s = await t.store.deleteMany({
255
- key: {
256
- $in: e
257
- }
258
- });
259
- return s.deletedCount > 0;
103
+ const t = e.map((async e => this.delete(e)));
104
+ const s = await Promise.allSettled(t);
105
+ return s.every((e => e.value === true));
260
106
  }
261
107
  async clear() {
262
- const e = await this.connect;
263
- if (this.opts.useGridFS) {
264
- try {
265
- await e.bucket.drop();
266
- } catch (e) {
267
- if (!(e instanceof n.MongoServerError && e.code === 26)) {
268
- throw e;
269
- }
270
- }
271
- }
272
- await e.store.deleteMany({
273
- key: {
274
- $regex: this.namespace ? `^${this.namespace}:*` : ""
275
- }
276
- });
277
- }
278
- async clearExpired() {
279
- if (!this.opts.useGridFS) {
280
- return false;
281
- }
282
- return this.connect.then((async e => {
283
- const t = e.db;
284
- const s = new n.GridFSBucket(t, {
285
- bucketName: this.opts.collection
286
- });
287
- return s.find({
288
- "metadata.expiresAt": {
289
- $lte: new Date(Date.now())
108
+ return new Promise(((e, t) => {
109
+ this.client.flush((s => {
110
+ if (s) {
111
+ this.emit("error", s);
112
+ t(s);
113
+ } else {
114
+ e(void 0);
290
115
  }
291
- }).toArray().then((async t => Promise.all(t.map((async t => e.bucket.delete(t._id)))).then((() => true))));
116
+ }));
292
117
  }));
293
118
  }
294
- async clearUnusedFor(e) {
295
- if (!this.opts.useGridFS) {
296
- return false;
119
+ formatKey(e) {
120
+ let t = e;
121
+ if (this.namespace) {
122
+ t = this.namespace.trim() + ":" + e.trim();
297
123
  }
298
- const t = await this.connect;
299
- const s = t.db;
300
- const o = new n.GridFSBucket(s, {
301
- bucketName: this.opts.collection
302
- });
303
- const a = await o.find({
304
- "metadata.lastAccessed": {
305
- $lte: new Date(Date.now() - e * 1e3)
306
- }
307
- }).toArray();
308
- await Promise.all(a.map((async e => t.bucket.delete(e._id))));
309
- return true;
310
- }
311
- async* iterator(e) {
312
- const t = await this.connect;
313
- const n = new RegExp(`^${e ? e + ":" : ".*"}`);
314
- const s = this.opts.useGridFS ? t.store.find({
315
- filename: n
316
- }).map((async e => [ e.filename, await this.get(e.filename) ])) : t.store.find({
317
- key: n
318
- }).map((e => [ e.key, e.value ]));
319
- yield* s;
124
+ return t;
320
125
  }
321
126
  async has(e) {
322
- const t = await this.connect;
323
- const n = {
324
- [this.opts.useGridFS ? "filename" : "key"]: {
325
- $eq: e
326
- }
327
- };
328
- const s = await t.store.count(n);
329
- return s !== 0;
330
- }
331
- async disconnect() {
332
- const e = await this.connect;
333
- await e.mongoClient.close();
127
+ return new Promise((t => {
128
+ this.client.get(this.formatKey(e), ((e, s) => {
129
+ if (e) {
130
+ t(false);
131
+ } else {
132
+ t(s !== null);
133
+ }
134
+ }));
135
+ }));
334
136
  }
335
137
  };
336
138
 
337
- var c = i;
139
+ var o = n;
338
140
 
339
- exports.KeyvMongo = i;
141
+ exports.KeyvMemcache = n;
340
142
 
341
- exports.default = c;
143
+ exports.default = o;