lakutata 2.0.65 → 2.0.67
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/com/cacher.cjs +1 -1
- package/com/cacher.d.ts +4 -4
- package/com/cacher.mjs +1 -1
- package/com/database.cjs +0 -2
- package/com/database.d.ts +4 -4
- package/com/database.mjs +0 -2
- package/com/docker.d.ts +5 -5
- package/com/entrypoint.cjs +3 -1
- package/com/entrypoint.d.ts +2 -2
- package/com/entrypoint.mjs +3 -1
- package/com/logger.d.ts +1 -1
- package/com/monitor.d.ts +2 -2
- package/decorator/asst.d.ts +1 -1
- package/decorator/ctrl.cjs +3 -1
- package/decorator/ctrl.d.ts +4 -4
- package/decorator/ctrl.mjs +3 -1
- package/decorator/di.d.ts +3 -3
- package/decorator/dto.d.ts +3 -3
- package/decorator/orm.cjs +86 -88
- package/decorator/orm.d.ts +51 -75
- package/decorator/orm.mjs +44 -46
- package/helper.cjs +24 -18
- package/helper.d.ts +129 -3
- package/helper.mjs +6 -2
- package/lakutata.cjs +3 -1
- package/lakutata.d.ts +10 -10
- package/lakutata.mjs +3 -1
- package/orm.cjs +1075 -112
- package/orm.d.ts +6 -6
- package/orm.mjs +1015 -17
- package/package.json +1 -1
- package/provider/database.cjs +0 -2
- package/provider/database.d.ts +4 -4
- package/provider/database.mjs +0 -2
- package/provider/passwordHash.d.ts +1 -1
- package/src/components/Database.cjs +0 -2
- package/src/components/Database.mjs +0 -2
- package/src/components/cacher/Cacher.cjs +1 -1
- package/src/components/cacher/Cacher.mjs +1 -1
- package/src/components/cacher/adapters/CreateFileCacheAdapter.cjs +1 -1
- package/src/components/cacher/adapters/CreateFileCacheAdapter.mjs +1 -1
- package/src/components/cacher/adapters/CreateMemcacheCacheAdapter.cjs +2 -2
- package/src/components/cacher/adapters/CreateMemcacheCacheAdapter.mjs +2 -2
- package/src/components/cacher/adapters/CreateMongoCacheAdapter.cjs +2 -2
- package/src/components/cacher/adapters/CreateMongoCacheAdapter.mjs +2 -2
- package/src/components/cacher/adapters/CreateMysqlCacheAdapter.cjs +2 -2
- package/src/components/cacher/adapters/CreateMysqlCacheAdapter.mjs +2 -2
- package/src/components/cacher/adapters/CreatePostgresCacheAdapter.cjs +2 -2
- package/src/components/cacher/adapters/CreatePostgresCacheAdapter.mjs +2 -2
- package/src/components/cacher/adapters/CreateRedisCacheAdapter.cjs +2 -2
- package/src/components/cacher/adapters/CreateRedisCacheAdapter.mjs +2 -2
- package/src/components/cacher/adapters/CreateSqliteCacheAdapter.cjs +2 -2
- package/src/components/cacher/adapters/CreateSqliteCacheAdapter.mjs +2 -2
- package/src/components/entrypoint/Entrypoint.cjs +3 -1
- package/src/components/entrypoint/Entrypoint.mjs +3 -1
- package/src/decorators/ctrl/CLIAction.cjs +7 -5
- package/src/decorators/ctrl/CLIAction.mjs +3 -1
- package/src/decorators/ctrl/HTTPAction.cjs +8 -6
- package/src/decorators/ctrl/HTTPAction.mjs +3 -1
- package/src/decorators/ctrl/ServiceAction.cjs +3 -1
- package/src/decorators/ctrl/ServiceAction.mjs +7 -5
- package/src/decorators/ctrl/http/DELETE.cjs +3 -1
- package/src/decorators/ctrl/http/DELETE.mjs +3 -1
- package/src/decorators/ctrl/http/GET.cjs +3 -1
- package/src/decorators/ctrl/http/GET.mjs +3 -1
- package/src/decorators/ctrl/http/HEAD.cjs +3 -1
- package/src/decorators/ctrl/http/HEAD.mjs +3 -1
- package/src/decorators/ctrl/http/OPTIONS.cjs +3 -1
- package/src/decorators/ctrl/http/OPTIONS.mjs +3 -1
- package/src/decorators/ctrl/http/PATCH.cjs +3 -1
- package/src/decorators/ctrl/http/PATCH.mjs +3 -1
- package/src/decorators/ctrl/http/POST.cjs +3 -1
- package/src/decorators/ctrl/http/POST.mjs +3 -1
- package/src/decorators/ctrl/http/PUT.cjs +3 -1
- package/src/decorators/ctrl/http/PUT.mjs +3 -1
- package/src/decorators/orm/AfterInsert.cjs +27 -7
- package/src/decorators/orm/AfterInsert.mjs +28 -6
- package/src/decorators/orm/AfterLoad.cjs +27 -7
- package/src/decorators/orm/AfterLoad.mjs +28 -6
- package/src/decorators/orm/AfterRecover.cjs +27 -7
- package/src/decorators/orm/AfterRecover.mjs +28 -6
- package/src/decorators/orm/AfterRemove.cjs +27 -7
- package/src/decorators/orm/AfterRemove.mjs +28 -6
- package/src/decorators/orm/AfterSoftRemove.cjs +27 -7
- package/src/decorators/orm/AfterSoftRemove.mjs +28 -6
- package/src/decorators/orm/AfterUpdate.cjs +27 -7
- package/src/decorators/orm/AfterUpdate.mjs +28 -6
- package/src/decorators/orm/BeforeInsert.cjs +27 -7
- package/src/decorators/orm/BeforeInsert.mjs +28 -6
- package/src/decorators/orm/BeforeRecover.cjs +27 -7
- package/src/decorators/orm/BeforeRecover.mjs +28 -6
- package/src/decorators/orm/BeforeRemove.cjs +27 -7
- package/src/decorators/orm/BeforeRemove.mjs +28 -6
- package/src/decorators/orm/BeforeSoftRemove.cjs +27 -7
- package/src/decorators/orm/BeforeSoftRemove.mjs +28 -6
- package/src/decorators/orm/BeforeUpdate.cjs +27 -7
- package/src/decorators/orm/BeforeUpdate.mjs +28 -6
- package/src/decorators/orm/Check.cjs +30 -7
- package/src/decorators/orm/Check.mjs +31 -6
- package/src/decorators/orm/ChildEntity.cjs +30 -7
- package/src/decorators/orm/ChildEntity.mjs +31 -6
- package/src/decorators/orm/Column.cjs +62 -7
- package/src/decorators/orm/Column.mjs +63 -6
- package/src/decorators/orm/CreateDateColumn.cjs +26 -7
- package/src/decorators/orm/CreateDateColumn.mjs +27 -6
- package/src/decorators/orm/DeleteDateColumn.cjs +26 -7
- package/src/decorators/orm/DeleteDateColumn.mjs +27 -6
- package/src/decorators/orm/Entity.cjs +36 -7
- package/src/decorators/orm/Entity.mjs +37 -6
- package/src/decorators/orm/EventSubscriber.cjs +23 -7
- package/src/decorators/orm/EventSubscriber.mjs +24 -6
- package/src/decorators/orm/Exclusion.cjs +30 -7
- package/src/decorators/orm/Exclusion.mjs +31 -6
- package/src/decorators/orm/Generated.cjs +25 -7
- package/src/decorators/orm/Generated.mjs +26 -6
- package/src/decorators/orm/Index.cjs +42 -7
- package/src/decorators/orm/Index.mjs +43 -6
- package/src/decorators/orm/JoinColumn.cjs +30 -7
- package/src/decorators/orm/JoinColumn.mjs +31 -6
- package/src/decorators/orm/JoinTable.cjs +31 -7
- package/src/decorators/orm/JoinTable.mjs +32 -6
- package/src/decorators/orm/ManyToMany.cjs +43 -7
- package/src/decorators/orm/ManyToMany.mjs +44 -6
- package/src/decorators/orm/ManyToOne.cjs +43 -7
- package/src/decorators/orm/ManyToOne.mjs +44 -6
- package/src/decorators/orm/ObjectIdColumn.cjs +29 -7
- package/src/decorators/orm/ObjectIdColumn.mjs +30 -6
- package/src/decorators/orm/OneToMany.cjs +35 -7
- package/src/decorators/orm/OneToMany.mjs +36 -6
- package/src/decorators/orm/OneToOne.cjs +43 -7
- package/src/decorators/orm/OneToOne.mjs +44 -6
- package/src/decorators/orm/PrimaryColumn.cjs +50 -7
- package/src/decorators/orm/PrimaryColumn.mjs +51 -6
- package/src/decorators/orm/PrimaryGeneratedColumn.cjs +55 -7
- package/src/decorators/orm/PrimaryGeneratedColumn.mjs +56 -6
- package/src/decorators/orm/RelationId.cjs +27 -7
- package/src/decorators/orm/RelationId.mjs +28 -6
- package/src/decorators/orm/TableInheritance.cjs +27 -7
- package/src/decorators/orm/TableInheritance.mjs +28 -6
- package/src/decorators/orm/Tree.cjs +25 -7
- package/src/decorators/orm/Tree.mjs +26 -6
- package/src/decorators/orm/TreeChildren.cjs +32 -7
- package/src/decorators/orm/TreeChildren.mjs +33 -6
- package/src/decorators/orm/TreeLevelColumn.cjs +26 -7
- package/src/decorators/orm/TreeLevelColumn.mjs +27 -6
- package/src/decorators/orm/TreeParent.cjs +32 -7
- package/src/decorators/orm/TreeParent.mjs +33 -6
- package/src/decorators/orm/Unique.cjs +45 -7
- package/src/decorators/orm/Unique.mjs +46 -6
- package/src/decorators/orm/UpdateDateColumn.cjs +26 -7
- package/src/decorators/orm/UpdateDateColumn.mjs +27 -6
- package/src/decorators/orm/VersionColumn.cjs +26 -7
- package/src/decorators/orm/VersionColumn.mjs +27 -6
- package/src/decorators/orm/ViewColumn.cjs +26 -7
- package/src/decorators/orm/ViewColumn.mjs +27 -6
- package/src/decorators/orm/ViewEntity.cjs +35 -7
- package/src/decorators/orm/ViewEntity.mjs +36 -6
- package/src/decorators/orm/VirtualColumn.cjs +43 -7
- package/src/decorators/orm/VirtualColumn.mjs +44 -6
- package/src/lib/base/internal/ControllerEntrypoint.cjs +70 -610
- package/src/lib/base/internal/ControllerEntrypoint.mjs +87 -627
- package/src/lib/base/internal/StringifyPattern.cjs +1 -1
- package/src/lib/base/internal/StringifyPattern.mjs +1 -1
- package/src/lib/core/Application.cjs +3 -1
- package/src/lib/core/Application.mjs +3 -1
- package/src/lib/helpers/MD5.cjs +1 -1
- package/src/lib/helpers/MD5.mjs +1 -1
- package/src/lib/helpers/SHA1.cjs +1 -1
- package/src/lib/helpers/SHA1.mjs +1 -1
- package/src/lib/helpers/SHA256.cjs +1 -1
- package/src/lib/helpers/SHA256.mjs +1 -1
- package/src/lib/helpers/SortArray.cjs +1 -1
- package/src/lib/helpers/SortArray.mjs +1 -1
- package/src/lib/helpers/UUID.cjs +45 -0
- package/src/lib/helpers/UUID.mjs +39 -0
- package/src/providers/Database.cjs +0 -2
- package/src/providers/Database.mjs +0 -2
- package/vendor/Package.122.cjs +13223 -16706
- package/vendor/Package.122.mjs +13498 -16881
- package/vendor/Package.19.cjs +184 -195
- package/vendor/Package.19.mjs +176 -187
- package/vendor/Package.610.cjs +297 -113
- package/vendor/Package.610.mjs +285 -97
- package/vendor/Package.611.cjs +85 -103
- package/vendor/Package.611.mjs +80 -98
- package/vendor/Package.612.cjs +100 -121
- package/vendor/Package.612.mjs +97 -120
- package/vendor/Package.613.cjs +196 -0
- package/vendor/Package.613.mjs +180 -0
- package/vendor/Package.64.cjs +511 -134
- package/vendor/Package.64.mjs +491 -134
- package/vendor/Package.65.cjs +140 -4118
- package/vendor/Package.65.mjs +140 -4126
- package/vendor/Package.66.cjs +4142 -692
- package/vendor/Package.66.mjs +4151 -689
- package/vendor/Package.67.cjs +571 -535
- package/vendor/Package.67.mjs +586 -528
- package/vendor/Package.68.cjs +633 -96
- package/vendor/Package.68.mjs +619 -94
- package/vendor/Package.69.cjs +96 -294
- package/vendor/Package.69.mjs +95 -295
- package/vendor/TypeDef.internal.1.d.ts +1 -1
- package/vendor/TypeDef.internal.10.d.ts +1 -1
- package/vendor/TypeDef.internal.11.d.ts +2 -2
- package/vendor/TypeDef.internal.12.d.ts +2 -2
- package/vendor/TypeDef.internal.13.d.ts +6 -6
- package/vendor/TypeDef.internal.3.d.ts +3 -3
- package/vendor/TypeDef.internal.4.d.ts +181 -347
- package/vendor/TypeDef.internal.5.d.ts +2 -2
- package/vendor/TypeDef.internal.6.d.ts +2 -2
- package/vendor/TypeDef.internal.7.d.ts +1 -1
- package/vendor/TypeDef.internal.8.d.ts +1 -1
- package/vendor/TypeDef.internal.9.d.ts +1 -1
package/vendor/Package.612.mjs
CHANGED
|
@@ -1,180 +1,157 @@
|
|
|
1
1
|
import t from "events";
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import { i as s } from "./Package.67.mjs";
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
import e from "pg";
|
|
6
|
+
|
|
7
|
+
import "buffer";
|
|
6
8
|
|
|
7
9
|
var a;
|
|
8
10
|
|
|
9
|
-
var
|
|
10
|
-
t = t.replace(/#/g, "%23");
|
|
11
|
-
const e = new URL(t);
|
|
12
|
-
const s = {
|
|
13
|
-
user: decodeURIComponent(e.username),
|
|
14
|
-
password: decodeURIComponent(e.password) || void 0,
|
|
15
|
-
host: e.hostname,
|
|
16
|
-
port: e.port ? Number.parseInt(e.port, 10) : void 0,
|
|
17
|
-
database: decodeURIComponent(e.pathname.slice(1))
|
|
18
|
-
};
|
|
19
|
-
for (const t of Object.keys(s)) {
|
|
20
|
-
if (s[t] === void 0) {
|
|
21
|
-
delete s[t];
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
return s;
|
|
25
|
-
};
|
|
11
|
+
var i;
|
|
26
12
|
|
|
27
|
-
var
|
|
28
|
-
if (
|
|
29
|
-
|
|
30
|
-
|
|
13
|
+
var o = (t, s = {}) => {
|
|
14
|
+
if (i !== t) {
|
|
15
|
+
a = void 0;
|
|
16
|
+
i = t;
|
|
31
17
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
...
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
s ??= e.createPool(r);
|
|
38
|
-
return s.promise();
|
|
18
|
+
a ??= new e.Pool({
|
|
19
|
+
connectionString: t,
|
|
20
|
+
...s
|
|
21
|
+
});
|
|
22
|
+
return a;
|
|
39
23
|
};
|
|
40
24
|
|
|
41
|
-
var
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}
|
|
45
|
-
a = void 0;
|
|
25
|
+
var r = async () => {
|
|
26
|
+
await a.end();
|
|
27
|
+
i = void 0;
|
|
46
28
|
};
|
|
47
29
|
|
|
48
|
-
var
|
|
49
|
-
|
|
50
|
-
var c = class extends t {
|
|
51
|
-
ttlSupport=false;
|
|
30
|
+
var n = class extends t {
|
|
31
|
+
ttlSupport;
|
|
52
32
|
opts;
|
|
53
|
-
namespace;
|
|
54
33
|
query;
|
|
34
|
+
namespace;
|
|
55
35
|
constructor(t) {
|
|
56
36
|
super();
|
|
57
|
-
|
|
58
|
-
dialect: "mysql",
|
|
59
|
-
uri: "mysql://localhost"
|
|
60
|
-
};
|
|
37
|
+
this.ttlSupport = false;
|
|
61
38
|
if (typeof t === "string") {
|
|
62
|
-
|
|
39
|
+
const s = t;
|
|
40
|
+
t = {
|
|
41
|
+
dialect: "postgres",
|
|
42
|
+
uri: s
|
|
43
|
+
};
|
|
63
44
|
} else {
|
|
64
|
-
|
|
65
|
-
|
|
45
|
+
t = {
|
|
46
|
+
dialect: "postgres",
|
|
47
|
+
uri: "postgresql://localhost:5432",
|
|
66
48
|
...t
|
|
67
49
|
};
|
|
68
50
|
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
delete s.serialize;
|
|
75
|
-
delete s.deserialize;
|
|
76
|
-
const a = async () => {
|
|
77
|
-
const t = i(e.uri, s);
|
|
78
|
-
return async e => {
|
|
79
|
-
const s = await t.query(e);
|
|
80
|
-
return s[0];
|
|
51
|
+
const s = async () => {
|
|
52
|
+
const s = o(t.uri, t);
|
|
53
|
+
return async (t, e) => {
|
|
54
|
+
const a = await s.query(t, e);
|
|
55
|
+
return a.rows;
|
|
81
56
|
};
|
|
82
57
|
};
|
|
83
58
|
this.opts = {
|
|
84
59
|
table: "keyv",
|
|
60
|
+
schema: "public",
|
|
85
61
|
keySize: 255,
|
|
86
|
-
...
|
|
62
|
+
...t
|
|
87
63
|
};
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
await t(
|
|
64
|
+
let e = `CREATE${this.opts.useUnloggedTable ? " UNLOGGED " : " "}TABLE IF NOT EXISTS ${this.opts.schema}.${this.opts.table}(key VARCHAR(${Number(this.opts.keySize)}) PRIMARY KEY, value TEXT )`;
|
|
65
|
+
if (this.opts.schema !== "public") {
|
|
66
|
+
e = `CREATE SCHEMA IF NOT EXISTS ${this.opts.schema}; ${e}`;
|
|
67
|
+
}
|
|
68
|
+
const a = s().then((async t => {
|
|
69
|
+
try {
|
|
70
|
+
await t(e);
|
|
71
|
+
} catch (s) {
|
|
72
|
+
if (s.code !== "23505") {
|
|
73
|
+
this.emit("error", s);
|
|
74
|
+
}
|
|
75
|
+
return t;
|
|
95
76
|
}
|
|
96
77
|
return t;
|
|
97
78
|
})).catch((t => this.emit("error", t)));
|
|
98
|
-
this.query = async t =>
|
|
99
|
-
const e = await n;
|
|
100
|
-
return e(t);
|
|
101
|
-
};
|
|
79
|
+
this.query = async (t, s) => a.then((e => e(t, s)));
|
|
102
80
|
}
|
|
103
81
|
async get(t) {
|
|
104
|
-
const s = `SELECT * FROM ${this.opts.table} WHERE
|
|
105
|
-
const
|
|
106
|
-
const
|
|
107
|
-
|
|
108
|
-
return i?.value;
|
|
82
|
+
const s = `SELECT * FROM ${this.opts.schema}.${this.opts.table} WHERE key = $1`;
|
|
83
|
+
const e = await this.query(s, [ t ]);
|
|
84
|
+
const a = e[0];
|
|
85
|
+
return a === void 0 ? void 0 : a.value;
|
|
109
86
|
}
|
|
110
87
|
async getMany(t) {
|
|
111
|
-
const s = `SELECT * FROM ${this.opts.table} WHERE
|
|
112
|
-
const
|
|
113
|
-
const
|
|
114
|
-
const
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
i.push(t === -1 ? void 0 : o[t].value);
|
|
88
|
+
const s = `SELECT * FROM ${this.opts.schema}.${this.opts.table} WHERE key = ANY($1)`;
|
|
89
|
+
const e = await this.query(s, [ t ]);
|
|
90
|
+
const a = [];
|
|
91
|
+
for (const s of t) {
|
|
92
|
+
const t = e?.findIndex((t => t.key === s));
|
|
93
|
+
a.push(t > -1 ? e[t].value : void 0);
|
|
118
94
|
}
|
|
119
|
-
return
|
|
95
|
+
return a;
|
|
120
96
|
}
|
|
121
97
|
async set(t, s) {
|
|
122
|
-
const
|
|
123
|
-
|
|
124
|
-
const i = e.format(a, o);
|
|
125
|
-
return this.query(i);
|
|
98
|
+
const e = `INSERT INTO ${this.opts.schema}.${this.opts.table} (key, value)\n VALUES($1, $2) \n ON CONFLICT(key) \n DO UPDATE SET value=excluded.value;`;
|
|
99
|
+
await this.query(e, [ t, s ]);
|
|
126
100
|
}
|
|
127
101
|
async delete(t) {
|
|
128
|
-
const s = `SELECT * FROM ${this.opts.table} WHERE
|
|
129
|
-
const
|
|
130
|
-
const
|
|
131
|
-
|
|
132
|
-
const n = await this.query(a);
|
|
133
|
-
const r = n[0];
|
|
134
|
-
if (r === void 0) {
|
|
102
|
+
const s = `SELECT * FROM ${this.opts.schema}.${this.opts.table} WHERE key = $1`;
|
|
103
|
+
const e = `DELETE FROM ${this.opts.schema}.${this.opts.table} WHERE key = $1`;
|
|
104
|
+
const a = await this.query(s, [ t ]);
|
|
105
|
+
if (a[0] === void 0) {
|
|
135
106
|
return false;
|
|
136
107
|
}
|
|
137
|
-
await this.query(
|
|
108
|
+
await this.query(e, [ t ]);
|
|
138
109
|
return true;
|
|
139
110
|
}
|
|
140
111
|
async deleteMany(t) {
|
|
141
|
-
const s = `
|
|
142
|
-
const
|
|
143
|
-
const
|
|
144
|
-
|
|
112
|
+
const s = `SELECT * FROM ${this.opts.schema}.${this.opts.table} WHERE key = ANY($1)`;
|
|
113
|
+
const e = `DELETE FROM ${this.opts.schema}.${this.opts.table} WHERE key = ANY($1)`;
|
|
114
|
+
const a = await this.query(s, [ t ]);
|
|
115
|
+
if (a[0] === void 0) {
|
|
116
|
+
return false;
|
|
117
|
+
}
|
|
118
|
+
await this.query(e, [ t ]);
|
|
119
|
+
return true;
|
|
145
120
|
}
|
|
146
121
|
async clear() {
|
|
147
|
-
const t = `DELETE FROM ${this.opts.table} WHERE
|
|
148
|
-
|
|
149
|
-
await this.query(s);
|
|
122
|
+
const t = `DELETE FROM ${this.opts.schema}.${this.opts.table} WHERE key LIKE $1`;
|
|
123
|
+
await this.query(t, [ this.namespace ? `${this.namespace}:%` : "%" ]);
|
|
150
124
|
}
|
|
151
125
|
async* iterator(t) {
|
|
152
|
-
const s = Number.parseInt(this.opts.iterationLimit, 10) || 10;
|
|
153
|
-
async function* a
|
|
154
|
-
const r = `SELECT * FROM ${i.table} WHERE
|
|
155
|
-
const
|
|
156
|
-
|
|
157
|
-
if (E.length === 0) {
|
|
126
|
+
const s = Number.parseInt(String(this.opts.iterationLimit), 10) || 10;
|
|
127
|
+
async function* e(a, i, o) {
|
|
128
|
+
const r = `SELECT * FROM ${i.schema}.${i.table} WHERE key LIKE $1 LIMIT $2 OFFSET $3`;
|
|
129
|
+
const n = await o(r, [ `${t ? t + ":" : ""}%`, s, a ]);
|
|
130
|
+
if (n.length === 0) {
|
|
158
131
|
return;
|
|
159
132
|
}
|
|
160
|
-
for (const t of
|
|
161
|
-
|
|
162
|
-
yield [ t.
|
|
133
|
+
for (const t of n) {
|
|
134
|
+
a += 1;
|
|
135
|
+
yield [ t.key, t.value ];
|
|
163
136
|
}
|
|
164
|
-
yield* a
|
|
137
|
+
yield* e(a, i, o);
|
|
165
138
|
}
|
|
166
|
-
yield*
|
|
139
|
+
yield* e(0, this.opts, this.query);
|
|
167
140
|
}
|
|
168
141
|
async has(t) {
|
|
169
|
-
const
|
|
170
|
-
const
|
|
171
|
-
return
|
|
142
|
+
const s = `SELECT EXISTS ( SELECT * FROM ${this.opts.schema}.${this.opts.table} WHERE key = $1 )`;
|
|
143
|
+
const e = await this.query(s, [ t ]);
|
|
144
|
+
return e[0].exists;
|
|
172
145
|
}
|
|
173
146
|
async disconnect() {
|
|
174
|
-
|
|
147
|
+
await r();
|
|
175
148
|
}
|
|
176
149
|
};
|
|
177
150
|
|
|
178
|
-
var
|
|
151
|
+
var c = t => new s({
|
|
152
|
+
store: new n(t)
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
var h = n;
|
|
179
156
|
|
|
180
|
-
export { c as
|
|
157
|
+
export { n as KeyvPostgres, c as createKeyv, h as default };
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, {
|
|
4
|
+
value: "Module"
|
|
5
|
+
});
|
|
6
|
+
|
|
7
|
+
const t = require("events");
|
|
8
|
+
|
|
9
|
+
const e = require("mysql2");
|
|
10
|
+
|
|
11
|
+
const s = t => t && t.__esModule ? t : {
|
|
12
|
+
default: t
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
const a = s(t);
|
|
16
|
+
|
|
17
|
+
const o = s(e);
|
|
18
|
+
|
|
19
|
+
var n;
|
|
20
|
+
|
|
21
|
+
var i;
|
|
22
|
+
|
|
23
|
+
var r = t => {
|
|
24
|
+
t = t.replace(/#/g, "%23");
|
|
25
|
+
const e = new URL(t);
|
|
26
|
+
const s = {
|
|
27
|
+
user: decodeURIComponent(e.username),
|
|
28
|
+
password: decodeURIComponent(e.password) || void 0,
|
|
29
|
+
host: e.hostname,
|
|
30
|
+
port: e.port ? Number.parseInt(e.port, 10) : void 0,
|
|
31
|
+
database: decodeURIComponent(e.pathname.slice(1))
|
|
32
|
+
};
|
|
33
|
+
for (const t of Object.keys(s)) {
|
|
34
|
+
if (s[t] === void 0) {
|
|
35
|
+
delete s[t];
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return s;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
var c = (t, e = {}) => {
|
|
42
|
+
if (i !== t) {
|
|
43
|
+
n = void 0;
|
|
44
|
+
i = t;
|
|
45
|
+
}
|
|
46
|
+
const s = r(t);
|
|
47
|
+
const a = {
|
|
48
|
+
...s,
|
|
49
|
+
...e
|
|
50
|
+
};
|
|
51
|
+
n ??= o.default.createPool(a);
|
|
52
|
+
return n.promise();
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
var E = () => {
|
|
56
|
+
if (n) {
|
|
57
|
+
n.end();
|
|
58
|
+
}
|
|
59
|
+
i = void 0;
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
var l = new Set([ "adapter", "compression", "connect", "dialect", "keySize", "table", "ttl", "uri" ]);
|
|
63
|
+
|
|
64
|
+
var u = class extends a.default {
|
|
65
|
+
ttlSupport=false;
|
|
66
|
+
opts;
|
|
67
|
+
namespace;
|
|
68
|
+
query;
|
|
69
|
+
constructor(t) {
|
|
70
|
+
super();
|
|
71
|
+
let e = {
|
|
72
|
+
dialect: "mysql",
|
|
73
|
+
uri: "mysql://localhost"
|
|
74
|
+
};
|
|
75
|
+
if (typeof t === "string") {
|
|
76
|
+
e.uri = t;
|
|
77
|
+
} else {
|
|
78
|
+
e = {
|
|
79
|
+
...e,
|
|
80
|
+
...t
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
if (e.intervalExpiration !== void 0 && e.intervalExpiration > 0) {
|
|
84
|
+
this.ttlSupport = true;
|
|
85
|
+
}
|
|
86
|
+
const s = Object.fromEntries(Object.entries(e).filter((([t]) => !l.has(t))));
|
|
87
|
+
delete s.namespace;
|
|
88
|
+
delete s.serialize;
|
|
89
|
+
delete s.deserialize;
|
|
90
|
+
const a = async () => {
|
|
91
|
+
const t = c(e.uri, s);
|
|
92
|
+
return async e => {
|
|
93
|
+
const s = await t.query(e);
|
|
94
|
+
return s[0];
|
|
95
|
+
};
|
|
96
|
+
};
|
|
97
|
+
this.opts = {
|
|
98
|
+
table: "keyv",
|
|
99
|
+
keySize: 255,
|
|
100
|
+
...e
|
|
101
|
+
};
|
|
102
|
+
const o = `CREATE TABLE IF NOT EXISTS ${this.opts.table}(id VARCHAR(${Number(this.opts.keySize)}) PRIMARY KEY, value TEXT)`;
|
|
103
|
+
const n = a().then((async t => {
|
|
104
|
+
await t(o);
|
|
105
|
+
if (this.opts.intervalExpiration !== void 0 && this.opts.intervalExpiration > 0) {
|
|
106
|
+
await t("SET GLOBAL event_scheduler = ON;");
|
|
107
|
+
await t("DROP EVENT IF EXISTS keyv_delete_expired_keys;");
|
|
108
|
+
await t(`CREATE EVENT IF NOT EXISTS keyv_delete_expired_keys ON SCHEDULE EVERY ${this.opts.intervalExpiration} SECOND\n\t\t\t\t\tDO DELETE FROM ${this.opts.table}\n\t\t\t\t\tWHERE CAST(value->'$.expires' AS UNSIGNED) BETWEEN 1 AND UNIX_TIMESTAMP(NOW(3)) * 1000;`);
|
|
109
|
+
}
|
|
110
|
+
return t;
|
|
111
|
+
})).catch((t => this.emit("error", t)));
|
|
112
|
+
this.query = async t => {
|
|
113
|
+
const e = await n;
|
|
114
|
+
return e(t);
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
async get(t) {
|
|
118
|
+
const e = `SELECT * FROM ${this.opts.table} WHERE id = ?`;
|
|
119
|
+
const s = o.default.format(e, [ t ]);
|
|
120
|
+
const a = await this.query(s);
|
|
121
|
+
const n = a[0];
|
|
122
|
+
return n?.value;
|
|
123
|
+
}
|
|
124
|
+
async getMany(t) {
|
|
125
|
+
const e = `SELECT * FROM ${this.opts.table} WHERE id IN (?)`;
|
|
126
|
+
const s = o.default.format(e, [ t ]);
|
|
127
|
+
const a = await this.query(s);
|
|
128
|
+
const n = [];
|
|
129
|
+
for (const e of t) {
|
|
130
|
+
const t = a.findIndex((t => t.id === e));
|
|
131
|
+
n.push(t === -1 ? void 0 : a[t].value);
|
|
132
|
+
}
|
|
133
|
+
return n;
|
|
134
|
+
}
|
|
135
|
+
async set(t, e) {
|
|
136
|
+
const s = `INSERT INTO ${this.opts.table} (id, value)\n\t\t\tVALUES(?, ?) \n\t\t\tON DUPLICATE KEY UPDATE value=?;`;
|
|
137
|
+
const a = [ t, e, e ];
|
|
138
|
+
const n = o.default.format(s, a);
|
|
139
|
+
return this.query(n);
|
|
140
|
+
}
|
|
141
|
+
async delete(t) {
|
|
142
|
+
const e = `SELECT * FROM ${this.opts.table} WHERE id = ?`;
|
|
143
|
+
const s = o.default.format(e, [ t ]);
|
|
144
|
+
const a = `DELETE FROM ${this.opts.table} WHERE id = ?`;
|
|
145
|
+
const n = o.default.format(a, [ t ]);
|
|
146
|
+
const i = await this.query(s);
|
|
147
|
+
const r = i[0];
|
|
148
|
+
if (r === void 0) {
|
|
149
|
+
return false;
|
|
150
|
+
}
|
|
151
|
+
await this.query(n);
|
|
152
|
+
return true;
|
|
153
|
+
}
|
|
154
|
+
async deleteMany(t) {
|
|
155
|
+
const e = `DELETE FROM ${this.opts.table} WHERE id IN (?)`;
|
|
156
|
+
const s = o.default.format(e, [ t ]);
|
|
157
|
+
const a = await this.query(s);
|
|
158
|
+
return a.affectedRows !== 0;
|
|
159
|
+
}
|
|
160
|
+
async clear() {
|
|
161
|
+
const t = `DELETE FROM ${this.opts.table} WHERE id LIKE ?`;
|
|
162
|
+
const e = o.default.format(t, [ this.namespace ? `${this.namespace}:%` : "%" ]);
|
|
163
|
+
await this.query(e);
|
|
164
|
+
}
|
|
165
|
+
async* iterator(t) {
|
|
166
|
+
const e = Number.parseInt(this.opts.iterationLimit, 10) || 10;
|
|
167
|
+
async function* s(a, n, i) {
|
|
168
|
+
const r = `SELECT * FROM ${n.table} WHERE id LIKE ? LIMIT ? OFFSET ?`;
|
|
169
|
+
const c = o.default.format(r, [ `${t ? t + ":" : ""}%`, e, a ]);
|
|
170
|
+
const E = await i(c);
|
|
171
|
+
if (E.length === 0) {
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
for (const t of E) {
|
|
175
|
+
a += 1;
|
|
176
|
+
yield [ t.id, t.value ];
|
|
177
|
+
}
|
|
178
|
+
yield* s(a, n, i);
|
|
179
|
+
}
|
|
180
|
+
yield* s(0, this.opts, this.query);
|
|
181
|
+
}
|
|
182
|
+
async has(t) {
|
|
183
|
+
const e = `SELECT EXISTS ( SELECT * FROM ${this.opts.table} WHERE id = '${t}' )`;
|
|
184
|
+
const s = await this.query(e);
|
|
185
|
+
return Object.values(s[0])[0] === 1;
|
|
186
|
+
}
|
|
187
|
+
async disconnect() {
|
|
188
|
+
E();
|
|
189
|
+
}
|
|
190
|
+
};
|
|
191
|
+
|
|
192
|
+
var d = u;
|
|
193
|
+
|
|
194
|
+
exports.KeyvMysql = u;
|
|
195
|
+
|
|
196
|
+
exports.default = d;
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import t from "events";
|
|
2
|
+
|
|
3
|
+
import e from "mysql2";
|
|
4
|
+
|
|
5
|
+
var s;
|
|
6
|
+
|
|
7
|
+
var a;
|
|
8
|
+
|
|
9
|
+
var o = t => {
|
|
10
|
+
t = t.replace(/#/g, "%23");
|
|
11
|
+
const e = new URL(t);
|
|
12
|
+
const s = {
|
|
13
|
+
user: decodeURIComponent(e.username),
|
|
14
|
+
password: decodeURIComponent(e.password) || void 0,
|
|
15
|
+
host: e.hostname,
|
|
16
|
+
port: e.port ? Number.parseInt(e.port, 10) : void 0,
|
|
17
|
+
database: decodeURIComponent(e.pathname.slice(1))
|
|
18
|
+
};
|
|
19
|
+
for (const t of Object.keys(s)) {
|
|
20
|
+
if (s[t] === void 0) {
|
|
21
|
+
delete s[t];
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return s;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
var i = (t, i = {}) => {
|
|
28
|
+
if (a !== t) {
|
|
29
|
+
s = void 0;
|
|
30
|
+
a = t;
|
|
31
|
+
}
|
|
32
|
+
const n = o(t);
|
|
33
|
+
const r = {
|
|
34
|
+
...n,
|
|
35
|
+
...i
|
|
36
|
+
};
|
|
37
|
+
s ??= e.createPool(r);
|
|
38
|
+
return s.promise();
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
var n = () => {
|
|
42
|
+
if (s) {
|
|
43
|
+
s.end();
|
|
44
|
+
}
|
|
45
|
+
a = void 0;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
var r = new Set([ "adapter", "compression", "connect", "dialect", "keySize", "table", "ttl", "uri" ]);
|
|
49
|
+
|
|
50
|
+
var c = class extends t {
|
|
51
|
+
ttlSupport=false;
|
|
52
|
+
opts;
|
|
53
|
+
namespace;
|
|
54
|
+
query;
|
|
55
|
+
constructor(t) {
|
|
56
|
+
super();
|
|
57
|
+
let e = {
|
|
58
|
+
dialect: "mysql",
|
|
59
|
+
uri: "mysql://localhost"
|
|
60
|
+
};
|
|
61
|
+
if (typeof t === "string") {
|
|
62
|
+
e.uri = t;
|
|
63
|
+
} else {
|
|
64
|
+
e = {
|
|
65
|
+
...e,
|
|
66
|
+
...t
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
if (e.intervalExpiration !== void 0 && e.intervalExpiration > 0) {
|
|
70
|
+
this.ttlSupport = true;
|
|
71
|
+
}
|
|
72
|
+
const s = Object.fromEntries(Object.entries(e).filter((([t]) => !r.has(t))));
|
|
73
|
+
delete s.namespace;
|
|
74
|
+
delete s.serialize;
|
|
75
|
+
delete s.deserialize;
|
|
76
|
+
const a = async () => {
|
|
77
|
+
const t = i(e.uri, s);
|
|
78
|
+
return async e => {
|
|
79
|
+
const s = await t.query(e);
|
|
80
|
+
return s[0];
|
|
81
|
+
};
|
|
82
|
+
};
|
|
83
|
+
this.opts = {
|
|
84
|
+
table: "keyv",
|
|
85
|
+
keySize: 255,
|
|
86
|
+
...e
|
|
87
|
+
};
|
|
88
|
+
const o = `CREATE TABLE IF NOT EXISTS ${this.opts.table}(id VARCHAR(${Number(this.opts.keySize)}) PRIMARY KEY, value TEXT)`;
|
|
89
|
+
const n = a().then((async t => {
|
|
90
|
+
await t(o);
|
|
91
|
+
if (this.opts.intervalExpiration !== void 0 && this.opts.intervalExpiration > 0) {
|
|
92
|
+
await t("SET GLOBAL event_scheduler = ON;");
|
|
93
|
+
await t("DROP EVENT IF EXISTS keyv_delete_expired_keys;");
|
|
94
|
+
await t(`CREATE EVENT IF NOT EXISTS keyv_delete_expired_keys ON SCHEDULE EVERY ${this.opts.intervalExpiration} SECOND\n\t\t\t\t\tDO DELETE FROM ${this.opts.table}\n\t\t\t\t\tWHERE CAST(value->'$.expires' AS UNSIGNED) BETWEEN 1 AND UNIX_TIMESTAMP(NOW(3)) * 1000;`);
|
|
95
|
+
}
|
|
96
|
+
return t;
|
|
97
|
+
})).catch((t => this.emit("error", t)));
|
|
98
|
+
this.query = async t => {
|
|
99
|
+
const e = await n;
|
|
100
|
+
return e(t);
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
async get(t) {
|
|
104
|
+
const s = `SELECT * FROM ${this.opts.table} WHERE id = ?`;
|
|
105
|
+
const a = e.format(s, [ t ]);
|
|
106
|
+
const o = await this.query(a);
|
|
107
|
+
const i = o[0];
|
|
108
|
+
return i?.value;
|
|
109
|
+
}
|
|
110
|
+
async getMany(t) {
|
|
111
|
+
const s = `SELECT * FROM ${this.opts.table} WHERE id IN (?)`;
|
|
112
|
+
const a = e.format(s, [ t ]);
|
|
113
|
+
const o = await this.query(a);
|
|
114
|
+
const i = [];
|
|
115
|
+
for (const e of t) {
|
|
116
|
+
const t = o.findIndex((t => t.id === e));
|
|
117
|
+
i.push(t === -1 ? void 0 : o[t].value);
|
|
118
|
+
}
|
|
119
|
+
return i;
|
|
120
|
+
}
|
|
121
|
+
async set(t, s) {
|
|
122
|
+
const a = `INSERT INTO ${this.opts.table} (id, value)\n\t\t\tVALUES(?, ?) \n\t\t\tON DUPLICATE KEY UPDATE value=?;`;
|
|
123
|
+
const o = [ t, s, s ];
|
|
124
|
+
const i = e.format(a, o);
|
|
125
|
+
return this.query(i);
|
|
126
|
+
}
|
|
127
|
+
async delete(t) {
|
|
128
|
+
const s = `SELECT * FROM ${this.opts.table} WHERE id = ?`;
|
|
129
|
+
const a = e.format(s, [ t ]);
|
|
130
|
+
const o = `DELETE FROM ${this.opts.table} WHERE id = ?`;
|
|
131
|
+
const i = e.format(o, [ t ]);
|
|
132
|
+
const n = await this.query(a);
|
|
133
|
+
const r = n[0];
|
|
134
|
+
if (r === void 0) {
|
|
135
|
+
return false;
|
|
136
|
+
}
|
|
137
|
+
await this.query(i);
|
|
138
|
+
return true;
|
|
139
|
+
}
|
|
140
|
+
async deleteMany(t) {
|
|
141
|
+
const s = `DELETE FROM ${this.opts.table} WHERE id IN (?)`;
|
|
142
|
+
const a = e.format(s, [ t ]);
|
|
143
|
+
const o = await this.query(a);
|
|
144
|
+
return o.affectedRows !== 0;
|
|
145
|
+
}
|
|
146
|
+
async clear() {
|
|
147
|
+
const t = `DELETE FROM ${this.opts.table} WHERE id LIKE ?`;
|
|
148
|
+
const s = e.format(t, [ this.namespace ? `${this.namespace}:%` : "%" ]);
|
|
149
|
+
await this.query(s);
|
|
150
|
+
}
|
|
151
|
+
async* iterator(t) {
|
|
152
|
+
const s = Number.parseInt(this.opts.iterationLimit, 10) || 10;
|
|
153
|
+
async function* a(o, i, n) {
|
|
154
|
+
const r = `SELECT * FROM ${i.table} WHERE id LIKE ? LIMIT ? OFFSET ?`;
|
|
155
|
+
const c = e.format(r, [ `${t ? t + ":" : ""}%`, s, o ]);
|
|
156
|
+
const E = await n(c);
|
|
157
|
+
if (E.length === 0) {
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
for (const t of E) {
|
|
161
|
+
o += 1;
|
|
162
|
+
yield [ t.id, t.value ];
|
|
163
|
+
}
|
|
164
|
+
yield* a(o, i, n);
|
|
165
|
+
}
|
|
166
|
+
yield* a(0, this.opts, this.query);
|
|
167
|
+
}
|
|
168
|
+
async has(t) {
|
|
169
|
+
const e = `SELECT EXISTS ( SELECT * FROM ${this.opts.table} WHERE id = '${t}' )`;
|
|
170
|
+
const s = await this.query(e);
|
|
171
|
+
return Object.values(s[0])[0] === 1;
|
|
172
|
+
}
|
|
173
|
+
async disconnect() {
|
|
174
|
+
n();
|
|
175
|
+
}
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
var E = c;
|
|
179
|
+
|
|
180
|
+
export { c as KeyvMysql, E as default };
|