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.611.mjs
CHANGED
|
@@ -1,157 +1,139 @@
|
|
|
1
1
|
import t from "events";
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { promisify as e } from "util";
|
|
4
4
|
|
|
5
|
-
import
|
|
5
|
+
import { i as s } from "./Package.67.mjs";
|
|
6
6
|
|
|
7
|
-
import "
|
|
8
|
-
|
|
9
|
-
var a;
|
|
10
|
-
|
|
11
|
-
var i;
|
|
7
|
+
import a from "sqlite3";
|
|
12
8
|
|
|
13
|
-
|
|
14
|
-
if (i !== t) {
|
|
15
|
-
a = void 0;
|
|
16
|
-
i = t;
|
|
17
|
-
}
|
|
18
|
-
a ??= new e.Pool({
|
|
19
|
-
connectionString: t,
|
|
20
|
-
...s
|
|
21
|
-
});
|
|
22
|
-
return a;
|
|
23
|
-
};
|
|
9
|
+
import "buffer";
|
|
24
10
|
|
|
25
|
-
var
|
|
26
|
-
await a.end();
|
|
27
|
-
i = void 0;
|
|
28
|
-
};
|
|
11
|
+
var i = t => String(t).search(/^[a-zA-Z]+$/) < 0 ? "_" + t : t;
|
|
29
12
|
|
|
30
13
|
var n = class extends t {
|
|
31
14
|
ttlSupport;
|
|
32
15
|
opts;
|
|
33
|
-
query;
|
|
34
16
|
namespace;
|
|
17
|
+
close;
|
|
18
|
+
query;
|
|
35
19
|
constructor(t) {
|
|
36
20
|
super();
|
|
37
21
|
this.ttlSupport = false;
|
|
22
|
+
let s = {
|
|
23
|
+
dialect: "sqlite",
|
|
24
|
+
uri: "sqlite://:memory:"
|
|
25
|
+
};
|
|
38
26
|
if (typeof t === "string") {
|
|
39
|
-
|
|
40
|
-
t = {
|
|
41
|
-
dialect: "postgres",
|
|
42
|
-
uri: s
|
|
43
|
-
};
|
|
27
|
+
s.uri = t;
|
|
44
28
|
} else {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
uri: "postgresql://localhost:5432",
|
|
29
|
+
s = {
|
|
30
|
+
...s,
|
|
48
31
|
...t
|
|
49
32
|
};
|
|
50
33
|
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
34
|
+
s.db = s.uri.replace(/^sqlite:\/\//, "");
|
|
35
|
+
s.connect = async () => new Promise(((t, e) => {
|
|
36
|
+
const i = new a.Database(s.db, (a => {
|
|
37
|
+
if (a) {
|
|
38
|
+
e(a);
|
|
39
|
+
} else {
|
|
40
|
+
if (s.busyTimeout) {
|
|
41
|
+
i.configure("busyTimeout", s.busyTimeout);
|
|
42
|
+
}
|
|
43
|
+
t(i);
|
|
44
|
+
}
|
|
45
|
+
}));
|
|
46
|
+
})).then((t => ({
|
|
47
|
+
query: e(t.all).bind(t),
|
|
48
|
+
close: e(t.close).bind(t)
|
|
49
|
+
})));
|
|
58
50
|
this.opts = {
|
|
59
51
|
table: "keyv",
|
|
60
|
-
schema: "public",
|
|
61
52
|
keySize: 255,
|
|
62
|
-
...
|
|
53
|
+
...s
|
|
63
54
|
};
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
try {
|
|
70
|
-
await t(e);
|
|
71
|
-
} catch (s) {
|
|
72
|
-
if (s.code !== "23505") {
|
|
73
|
-
this.emit("error", s);
|
|
74
|
-
}
|
|
75
|
-
return t;
|
|
76
|
-
}
|
|
77
|
-
return t;
|
|
78
|
-
})).catch((t => this.emit("error", t)));
|
|
79
|
-
this.query = async (t, s) => a.then((e => e(t, s)));
|
|
55
|
+
this.opts.table = i(this.opts.table);
|
|
56
|
+
const n = `CREATE TABLE IF NOT EXISTS ${this.opts.table}(key VARCHAR(${Number(this.opts.keySize)}) PRIMARY KEY, value TEXT )`;
|
|
57
|
+
const o = this.opts.connect().then((async t => t.query(n).then((() => t)))).catch((t => this.emit("error", t)));
|
|
58
|
+
this.query = async (t, ...e) => o.then((async s => s.query(t, ...e)));
|
|
59
|
+
this.close = async () => o.then((t => t.close()));
|
|
80
60
|
}
|
|
81
61
|
async get(t) {
|
|
82
|
-
const
|
|
83
|
-
const
|
|
84
|
-
const a =
|
|
85
|
-
|
|
62
|
+
const e = `SELECT * FROM ${this.opts.table} WHERE key = ?`;
|
|
63
|
+
const s = await this.query(e, t);
|
|
64
|
+
const a = s[0];
|
|
65
|
+
if (a === void 0) {
|
|
66
|
+
return void 0;
|
|
67
|
+
}
|
|
68
|
+
return a.value;
|
|
86
69
|
}
|
|
87
70
|
async getMany(t) {
|
|
88
|
-
const
|
|
89
|
-
const
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
}
|
|
95
|
-
return a;
|
|
71
|
+
const e = `SELECT * FROM ${this.opts.table} WHERE key IN (SELECT value FROM json_each(?))`;
|
|
72
|
+
const s = await this.query(e, JSON.stringify(t));
|
|
73
|
+
return t.map((t => {
|
|
74
|
+
const e = s.find((e => e.key === t));
|
|
75
|
+
return e ? e.value : void 0;
|
|
76
|
+
}));
|
|
96
77
|
}
|
|
97
|
-
async set(t,
|
|
98
|
-
const
|
|
99
|
-
|
|
78
|
+
async set(t, e) {
|
|
79
|
+
const s = `INSERT INTO ${this.opts.table} (key, value)\n\t\t\tVALUES(?, ?) \n\t\t\tON CONFLICT(key) \n\t\t\tDO UPDATE SET value=excluded.value;`;
|
|
80
|
+
return this.query(s, t, e);
|
|
100
81
|
}
|
|
101
82
|
async delete(t) {
|
|
102
|
-
const
|
|
103
|
-
const
|
|
104
|
-
const a = await this.query(
|
|
105
|
-
|
|
83
|
+
const e = `SELECT * FROM ${this.opts.table} WHERE key = ?`;
|
|
84
|
+
const s = `DELETE FROM ${this.opts.table} WHERE key = ?`;
|
|
85
|
+
const a = await this.query(e, t);
|
|
86
|
+
const i = a[0];
|
|
87
|
+
if (i === void 0) {
|
|
106
88
|
return false;
|
|
107
89
|
}
|
|
108
|
-
await this.query(
|
|
90
|
+
await this.query(s, t);
|
|
109
91
|
return true;
|
|
110
92
|
}
|
|
111
93
|
async deleteMany(t) {
|
|
112
|
-
const
|
|
113
|
-
const
|
|
114
|
-
|
|
115
|
-
if (a[0] === void 0) {
|
|
94
|
+
const e = `DELETE FROM ${this.opts.table} WHERE key IN (SELECT value FROM json_each(?))`;
|
|
95
|
+
const s = await this.getMany(t);
|
|
96
|
+
if (s.every((t => t === void 0))) {
|
|
116
97
|
return false;
|
|
117
98
|
}
|
|
118
|
-
await this.query(e,
|
|
99
|
+
await this.query(e, JSON.stringify(t));
|
|
119
100
|
return true;
|
|
120
101
|
}
|
|
121
102
|
async clear() {
|
|
122
|
-
const t = `DELETE FROM ${this.opts.
|
|
123
|
-
await this.query(t,
|
|
103
|
+
const t = `DELETE FROM ${this.opts.table} WHERE key LIKE ?`;
|
|
104
|
+
await this.query(t, this.namespace ? `${this.namespace}:%` : "%");
|
|
124
105
|
}
|
|
125
106
|
async* iterator(t) {
|
|
126
|
-
const
|
|
127
|
-
async function*
|
|
128
|
-
const
|
|
129
|
-
const
|
|
130
|
-
|
|
107
|
+
const e = Number.parseInt(this.opts.iterationLimit, 10) || 10;
|
|
108
|
+
async function* s(a, i, n) {
|
|
109
|
+
const o = `SELECT * FROM ${i.table} WHERE key LIKE ? LIMIT ? OFFSET ?`;
|
|
110
|
+
const r = await n(o, [ `${t ? t + ":" : ""}%`, e, a ]);
|
|
111
|
+
const c = [ ...r ];
|
|
112
|
+
if (c.length === 0) {
|
|
131
113
|
return;
|
|
132
114
|
}
|
|
133
|
-
for (const t of
|
|
115
|
+
for (const t of c) {
|
|
134
116
|
a += 1;
|
|
135
117
|
yield [ t.key, t.value ];
|
|
136
118
|
}
|
|
137
|
-
yield*
|
|
119
|
+
yield* s(a, i, n);
|
|
138
120
|
}
|
|
139
|
-
yield*
|
|
121
|
+
yield* s(0, this.opts, this.query);
|
|
140
122
|
}
|
|
141
123
|
async has(t) {
|
|
142
|
-
const
|
|
143
|
-
const
|
|
144
|
-
return
|
|
124
|
+
const e = `SELECT EXISTS ( SELECT * FROM ${this.opts.table} WHERE key = ? )`;
|
|
125
|
+
const s = await this.query(e, t);
|
|
126
|
+
return Object.values(s[0])[0] === 1;
|
|
145
127
|
}
|
|
146
128
|
async disconnect() {
|
|
147
|
-
await
|
|
129
|
+
await this.close();
|
|
148
130
|
}
|
|
149
131
|
};
|
|
150
132
|
|
|
151
|
-
var
|
|
133
|
+
var o = t => new s({
|
|
152
134
|
store: new n(t)
|
|
153
135
|
});
|
|
154
136
|
|
|
155
|
-
var
|
|
137
|
+
var r = n;
|
|
156
138
|
|
|
157
|
-
export { n as
|
|
139
|
+
export { n as KeyvSqlite, o as createKeyv, r as default };
|
package/vendor/Package.612.cjs
CHANGED
|
@@ -6,191 +6,170 @@ Object.defineProperty(exports, Symbol.toStringTag, {
|
|
|
6
6
|
|
|
7
7
|
const t = require("events");
|
|
8
8
|
|
|
9
|
-
const e = require("
|
|
9
|
+
const e = require("./Package.67.cjs");
|
|
10
10
|
|
|
11
|
-
const s =
|
|
11
|
+
const s = require("pg");
|
|
12
|
+
|
|
13
|
+
require("buffer");
|
|
14
|
+
|
|
15
|
+
const a = t => t && t.__esModule ? t : {
|
|
12
16
|
default: t
|
|
13
17
|
};
|
|
14
18
|
|
|
15
|
-
const
|
|
19
|
+
const i = a(t);
|
|
16
20
|
|
|
17
|
-
const o = s
|
|
21
|
+
const o = a(s);
|
|
18
22
|
|
|
19
|
-
var
|
|
23
|
+
var r;
|
|
20
24
|
|
|
21
|
-
var
|
|
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
|
-
};
|
|
25
|
+
var n;
|
|
40
26
|
|
|
41
27
|
var c = (t, e = {}) => {
|
|
42
|
-
if (
|
|
43
|
-
|
|
44
|
-
|
|
28
|
+
if (n !== t) {
|
|
29
|
+
r = void 0;
|
|
30
|
+
n = t;
|
|
45
31
|
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
...s,
|
|
32
|
+
r ??= new o.default.Pool({
|
|
33
|
+
connectionString: t,
|
|
49
34
|
...e
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
return n.promise();
|
|
35
|
+
});
|
|
36
|
+
return r;
|
|
53
37
|
};
|
|
54
38
|
|
|
55
|
-
var
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
}
|
|
59
|
-
i = void 0;
|
|
39
|
+
var h = async () => {
|
|
40
|
+
await r.end();
|
|
41
|
+
n = void 0;
|
|
60
42
|
};
|
|
61
43
|
|
|
62
|
-
var
|
|
63
|
-
|
|
64
|
-
var u = class extends a.default {
|
|
65
|
-
ttlSupport=false;
|
|
44
|
+
var u = class extends i.default {
|
|
45
|
+
ttlSupport;
|
|
66
46
|
opts;
|
|
67
|
-
namespace;
|
|
68
47
|
query;
|
|
48
|
+
namespace;
|
|
69
49
|
constructor(t) {
|
|
70
50
|
super();
|
|
71
|
-
|
|
72
|
-
dialect: "mysql",
|
|
73
|
-
uri: "mysql://localhost"
|
|
74
|
-
};
|
|
51
|
+
this.ttlSupport = false;
|
|
75
52
|
if (typeof t === "string") {
|
|
76
|
-
e
|
|
53
|
+
const e = t;
|
|
54
|
+
t = {
|
|
55
|
+
dialect: "postgres",
|
|
56
|
+
uri: e
|
|
57
|
+
};
|
|
77
58
|
} else {
|
|
78
|
-
|
|
79
|
-
|
|
59
|
+
t = {
|
|
60
|
+
dialect: "postgres",
|
|
61
|
+
uri: "postgresql://localhost:5432",
|
|
80
62
|
...t
|
|
81
63
|
};
|
|
82
64
|
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
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];
|
|
65
|
+
const e = async () => {
|
|
66
|
+
const e = c(t.uri, t);
|
|
67
|
+
return async (t, s) => {
|
|
68
|
+
const a = await e.query(t, s);
|
|
69
|
+
return a.rows;
|
|
95
70
|
};
|
|
96
71
|
};
|
|
97
72
|
this.opts = {
|
|
98
73
|
table: "keyv",
|
|
74
|
+
schema: "public",
|
|
99
75
|
keySize: 255,
|
|
100
|
-
...
|
|
76
|
+
...t
|
|
101
77
|
};
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
await t(
|
|
78
|
+
let s = `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 )`;
|
|
79
|
+
if (this.opts.schema !== "public") {
|
|
80
|
+
s = `CREATE SCHEMA IF NOT EXISTS ${this.opts.schema}; ${s}`;
|
|
81
|
+
}
|
|
82
|
+
const a = e().then((async t => {
|
|
83
|
+
try {
|
|
84
|
+
await t(s);
|
|
85
|
+
} catch (e) {
|
|
86
|
+
if (e.code !== "23505") {
|
|
87
|
+
this.emit("error", e);
|
|
88
|
+
}
|
|
89
|
+
return t;
|
|
109
90
|
}
|
|
110
91
|
return t;
|
|
111
92
|
})).catch((t => this.emit("error", t)));
|
|
112
|
-
this.query = async t =>
|
|
113
|
-
const e = await n;
|
|
114
|
-
return e(t);
|
|
115
|
-
};
|
|
93
|
+
this.query = async (t, e) => a.then((s => s(t, e)));
|
|
116
94
|
}
|
|
117
95
|
async get(t) {
|
|
118
|
-
const e = `SELECT * FROM ${this.opts.table} WHERE
|
|
119
|
-
const s =
|
|
120
|
-
const a =
|
|
121
|
-
|
|
122
|
-
return n?.value;
|
|
96
|
+
const e = `SELECT * FROM ${this.opts.schema}.${this.opts.table} WHERE key = $1`;
|
|
97
|
+
const s = await this.query(e, [ t ]);
|
|
98
|
+
const a = s[0];
|
|
99
|
+
return a === void 0 ? void 0 : a.value;
|
|
123
100
|
}
|
|
124
101
|
async getMany(t) {
|
|
125
|
-
const e = `SELECT * FROM ${this.opts.table} WHERE
|
|
126
|
-
const s =
|
|
127
|
-
const a =
|
|
128
|
-
const n = [];
|
|
102
|
+
const e = `SELECT * FROM ${this.opts.schema}.${this.opts.table} WHERE key = ANY($1)`;
|
|
103
|
+
const s = await this.query(e, [ t ]);
|
|
104
|
+
const a = [];
|
|
129
105
|
for (const e of t) {
|
|
130
|
-
const t =
|
|
131
|
-
|
|
106
|
+
const t = s?.findIndex((t => t.key === e));
|
|
107
|
+
a.push(t > -1 ? s[t].value : void 0);
|
|
132
108
|
}
|
|
133
|
-
return
|
|
109
|
+
return a;
|
|
134
110
|
}
|
|
135
111
|
async set(t, e) {
|
|
136
|
-
const s = `INSERT INTO ${this.opts.table} (
|
|
137
|
-
|
|
138
|
-
const n = o.default.format(s, a);
|
|
139
|
-
return this.query(n);
|
|
112
|
+
const s = `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;`;
|
|
113
|
+
await this.query(s, [ t, e ]);
|
|
140
114
|
}
|
|
141
115
|
async delete(t) {
|
|
142
|
-
const e = `SELECT * FROM ${this.opts.table} WHERE
|
|
143
|
-
const s =
|
|
144
|
-
const a =
|
|
145
|
-
|
|
146
|
-
const i = await this.query(s);
|
|
147
|
-
const r = i[0];
|
|
148
|
-
if (r === void 0) {
|
|
116
|
+
const e = `SELECT * FROM ${this.opts.schema}.${this.opts.table} WHERE key = $1`;
|
|
117
|
+
const s = `DELETE FROM ${this.opts.schema}.${this.opts.table} WHERE key = $1`;
|
|
118
|
+
const a = await this.query(e, [ t ]);
|
|
119
|
+
if (a[0] === void 0) {
|
|
149
120
|
return false;
|
|
150
121
|
}
|
|
151
|
-
await this.query(
|
|
122
|
+
await this.query(s, [ t ]);
|
|
152
123
|
return true;
|
|
153
124
|
}
|
|
154
125
|
async deleteMany(t) {
|
|
155
|
-
const e = `
|
|
156
|
-
const s =
|
|
157
|
-
const a = await this.query(
|
|
158
|
-
|
|
126
|
+
const e = `SELECT * FROM ${this.opts.schema}.${this.opts.table} WHERE key = ANY($1)`;
|
|
127
|
+
const s = `DELETE FROM ${this.opts.schema}.${this.opts.table} WHERE key = ANY($1)`;
|
|
128
|
+
const a = await this.query(e, [ t ]);
|
|
129
|
+
if (a[0] === void 0) {
|
|
130
|
+
return false;
|
|
131
|
+
}
|
|
132
|
+
await this.query(s, [ t ]);
|
|
133
|
+
return true;
|
|
159
134
|
}
|
|
160
135
|
async clear() {
|
|
161
|
-
const t = `DELETE FROM ${this.opts.table} WHERE
|
|
162
|
-
|
|
163
|
-
await this.query(e);
|
|
136
|
+
const t = `DELETE FROM ${this.opts.schema}.${this.opts.table} WHERE key LIKE $1`;
|
|
137
|
+
await this.query(t, [ this.namespace ? `${this.namespace}:%` : "%" ]);
|
|
164
138
|
}
|
|
165
139
|
async* iterator(t) {
|
|
166
|
-
const e = Number.parseInt(this.opts.iterationLimit, 10) || 10;
|
|
167
|
-
async function* s(a,
|
|
168
|
-
const r = `SELECT * FROM ${
|
|
169
|
-
const
|
|
170
|
-
|
|
171
|
-
if (E.length === 0) {
|
|
140
|
+
const e = Number.parseInt(String(this.opts.iterationLimit), 10) || 10;
|
|
141
|
+
async function* s(a, i, o) {
|
|
142
|
+
const r = `SELECT * FROM ${i.schema}.${i.table} WHERE key LIKE $1 LIMIT $2 OFFSET $3`;
|
|
143
|
+
const n = await o(r, [ `${t ? t + ":" : ""}%`, e, a ]);
|
|
144
|
+
if (n.length === 0) {
|
|
172
145
|
return;
|
|
173
146
|
}
|
|
174
|
-
for (const t of
|
|
147
|
+
for (const t of n) {
|
|
175
148
|
a += 1;
|
|
176
|
-
yield [ t.
|
|
149
|
+
yield [ t.key, t.value ];
|
|
177
150
|
}
|
|
178
|
-
yield* s(a,
|
|
151
|
+
yield* s(a, i, o);
|
|
179
152
|
}
|
|
180
153
|
yield* s(0, this.opts, this.query);
|
|
181
154
|
}
|
|
182
155
|
async has(t) {
|
|
183
|
-
const e = `SELECT EXISTS ( SELECT * FROM ${this.opts.table} WHERE
|
|
184
|
-
const s = await this.query(e);
|
|
185
|
-
return
|
|
156
|
+
const e = `SELECT EXISTS ( SELECT * FROM ${this.opts.schema}.${this.opts.table} WHERE key = $1 )`;
|
|
157
|
+
const s = await this.query(e, [ t ]);
|
|
158
|
+
return s[0].exists;
|
|
186
159
|
}
|
|
187
160
|
async disconnect() {
|
|
188
|
-
|
|
161
|
+
await h();
|
|
189
162
|
}
|
|
190
163
|
};
|
|
191
164
|
|
|
192
|
-
var
|
|
165
|
+
var E = t => new e.index_default({
|
|
166
|
+
store: new u(t)
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
var y = u;
|
|
170
|
+
|
|
171
|
+
exports.KeyvPostgres = u;
|
|
193
172
|
|
|
194
|
-
exports.
|
|
173
|
+
exports.createKeyv = E;
|
|
195
174
|
|
|
196
|
-
exports.default =
|
|
175
|
+
exports.default = y;
|