lakutata 2.0.80 → 2.0.81
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 +8 -10
- package/com/cacher.d.ts +83 -14
- package/com/cacher.mjs +8 -10
- package/com/database.cjs +11 -11
- package/com/database.mjs +11 -11
- package/com/docker.cjs +17 -19
- package/com/docker.d.ts +3 -141
- package/com/docker.mjs +13 -15
- package/com/entrypoint.cjs +7 -5
- package/com/entrypoint.mjs +7 -5
- package/com/logger.cjs +7 -7
- package/com/logger.mjs +7 -7
- package/com/monitor.cjs +5 -3
- package/com/monitor.mjs +5 -3
- package/decorator/ctrl.cjs +3 -3
- package/decorator/ctrl.mjs +3 -3
- package/decorator/orm.cjs +98 -98
- package/decorator/orm.mjs +142 -56
- package/helper.cjs +9 -11
- package/helper.mjs +5 -7
- package/lakutata.cjs +23 -30
- package/lakutata.mjs +14 -18
- package/orm.cjs +1423 -886
- package/orm.mjs +1474 -724
- package/package.json +1 -1
- package/provider/database.cjs +11 -11
- package/provider/database.mjs +11 -11
- package/provider/passwordHash.cjs +4 -2
- package/provider/passwordHash.mjs +4 -2
- package/src/components/Database.cjs +11 -11
- package/src/components/Database.mjs +11 -11
- package/src/components/Logger.cjs +7 -7
- package/src/components/Logger.mjs +7 -7
- package/src/components/cacher/Cacher.cjs +1178 -264
- package/src/components/cacher/Cacher.mjs +1087 -173
- package/src/components/cacher/adapters/CreateFileCacheAdapter.cjs +479 -2963
- package/src/components/cacher/adapters/CreateFileCacheAdapter.mjs +469 -2947
- package/src/components/docker/ConnectionOptionsBuilder.cjs +15 -17
- package/src/components/docker/ConnectionOptionsBuilder.mjs +13 -15
- package/src/components/docker/Docker.cjs +4884 -4945
- package/src/components/docker/Docker.mjs +4902 -4963
- package/src/components/docker/lib/DockerContainer.cjs +23 -25
- package/src/components/docker/lib/DockerContainer.mjs +17 -19
- package/src/components/docker/lib/DockerContainerTTY.cjs +9 -11
- package/src/components/docker/lib/DockerContainerTTY.mjs +9 -11
- package/src/components/docker/lib/DockerImage.cjs +4 -2
- package/src/components/docker/lib/DockerImage.mjs +4 -2
- package/src/components/entrypoint/Entrypoint.cjs +2170 -1678
- package/src/components/entrypoint/Entrypoint.mjs +2126 -1634
- package/src/components/entrypoint/lib/AccessControl.cjs +4 -2
- package/src/components/entrypoint/lib/AccessControl.mjs +4 -2
- package/src/components/entrypoint/lib/AccessControlRule.cjs +4 -2
- package/src/components/entrypoint/lib/AccessControlRule.mjs +4 -2
- package/src/components/entrypoint/lib/Controller.cjs +4 -2
- package/src/components/entrypoint/lib/Controller.mjs +4 -2
- package/src/components/monitor/AliveMonitor.cjs +4 -2
- package/src/components/monitor/AliveMonitor.mjs +4 -2
- package/src/components/monitor/CpuMonitor.cjs +5 -3
- package/src/components/monitor/CpuMonitor.mjs +5 -3
- package/src/components/monitor/EventLoopMonitor.cjs +4 -2
- package/src/components/monitor/EventLoopMonitor.mjs +4 -2
- package/src/components/monitor/HttpRequestMonitor.cjs +5 -3
- package/src/components/monitor/HttpRequestMonitor.mjs +5 -3
- package/src/components/monitor/MemoryMonitor.cjs +5 -3
- package/src/components/monitor/MemoryMonitor.mjs +5 -3
- package/src/decorators/ctrl/CLIAction.cjs +3 -3
- package/src/decorators/ctrl/CLIAction.mjs +3 -3
- package/src/decorators/ctrl/HTTPAction.cjs +3 -3
- package/src/decorators/ctrl/HTTPAction.mjs +3 -3
- package/src/decorators/ctrl/ServiceAction.cjs +3 -3
- package/src/decorators/ctrl/ServiceAction.mjs +3 -3
- package/src/decorators/ctrl/http/DELETE.cjs +3 -3
- package/src/decorators/ctrl/http/DELETE.mjs +3 -3
- package/src/decorators/ctrl/http/GET.cjs +3 -3
- package/src/decorators/ctrl/http/GET.mjs +3 -3
- package/src/decorators/ctrl/http/HEAD.cjs +3 -3
- package/src/decorators/ctrl/http/HEAD.mjs +3 -3
- package/src/decorators/ctrl/http/OPTIONS.cjs +3 -3
- package/src/decorators/ctrl/http/OPTIONS.mjs +3 -3
- package/src/decorators/ctrl/http/PATCH.cjs +3 -3
- package/src/decorators/ctrl/http/PATCH.mjs +3 -3
- package/src/decorators/ctrl/http/POST.cjs +3 -3
- package/src/decorators/ctrl/http/POST.mjs +3 -3
- package/src/decorators/ctrl/http/PUT.cjs +3 -3
- package/src/decorators/ctrl/http/PUT.mjs +3 -3
- package/src/decorators/orm/AfterInsert.cjs +17 -39
- package/src/decorators/orm/AfterInsert.mjs +18 -38
- package/src/decorators/orm/AfterLoad.cjs +17 -39
- package/src/decorators/orm/AfterLoad.mjs +18 -38
- package/src/decorators/orm/AfterRecover.cjs +17 -39
- package/src/decorators/orm/AfterRecover.mjs +18 -38
- package/src/decorators/orm/AfterRemove.cjs +17 -39
- package/src/decorators/orm/AfterRemove.mjs +18 -38
- package/src/decorators/orm/AfterSoftRemove.cjs +17 -39
- package/src/decorators/orm/AfterSoftRemove.mjs +18 -38
- package/src/decorators/orm/AfterUpdate.cjs +17 -39
- package/src/decorators/orm/AfterUpdate.mjs +18 -38
- package/src/decorators/orm/BeforeInsert.cjs +17 -39
- package/src/decorators/orm/BeforeInsert.mjs +18 -38
- package/src/decorators/orm/BeforeRecover.cjs +17 -39
- package/src/decorators/orm/BeforeRecover.mjs +18 -38
- package/src/decorators/orm/BeforeRemove.cjs +17 -39
- package/src/decorators/orm/BeforeRemove.mjs +18 -38
- package/src/decorators/orm/BeforeSoftRemove.cjs +17 -39
- package/src/decorators/orm/BeforeSoftRemove.mjs +18 -38
- package/src/decorators/orm/BeforeUpdate.cjs +17 -39
- package/src/decorators/orm/BeforeUpdate.mjs +18 -38
- package/src/decorators/orm/Check.cjs +17 -42
- package/src/decorators/orm/Check.mjs +18 -41
- package/src/decorators/orm/ChildEntity.cjs +17 -42
- package/src/decorators/orm/ChildEntity.mjs +18 -41
- package/src/decorators/orm/Column.cjs +17 -74
- package/src/decorators/orm/Column.mjs +19 -74
- package/src/decorators/orm/CreateDateColumn.cjs +17 -38
- package/src/decorators/orm/CreateDateColumn.mjs +18 -37
- package/src/decorators/orm/DeleteDateColumn.cjs +17 -38
- package/src/decorators/orm/DeleteDateColumn.mjs +17 -36
- package/src/decorators/orm/Entity.cjs +17 -48
- package/src/decorators/orm/Entity.mjs +17 -46
- package/src/decorators/orm/EventSubscriber.cjs +17 -35
- package/src/decorators/orm/EventSubscriber.mjs +18 -34
- package/src/decorators/orm/Exclusion.cjs +17 -42
- package/src/decorators/orm/Exclusion.mjs +18 -41
- package/src/decorators/orm/Generated.cjs +17 -37
- package/src/decorators/orm/Generated.mjs +18 -36
- package/src/decorators/orm/Index.cjs +17 -54
- package/src/decorators/orm/Index.mjs +19 -54
- package/src/decorators/orm/JoinColumn.cjs +17 -42
- package/src/decorators/orm/JoinColumn.mjs +18 -41
- package/src/decorators/orm/JoinTable.cjs +17 -43
- package/src/decorators/orm/JoinTable.mjs +17 -41
- package/src/decorators/orm/ManyToMany.cjs +17 -55
- package/src/decorators/orm/ManyToMany.mjs +17 -53
- package/src/decorators/orm/ManyToOne.cjs +17 -55
- package/src/decorators/orm/ManyToOne.mjs +17 -53
- package/src/decorators/orm/ObjectIdColumn.cjs +17 -41
- package/src/decorators/orm/ObjectIdColumn.mjs +18 -40
- package/src/decorators/orm/OneToMany.cjs +17 -47
- package/src/decorators/orm/OneToMany.mjs +19 -47
- package/src/decorators/orm/OneToOne.cjs +17 -55
- package/src/decorators/orm/OneToOne.mjs +17 -53
- package/src/decorators/orm/PrimaryColumn.cjs +17 -62
- package/src/decorators/orm/PrimaryColumn.mjs +19 -62
- package/src/decorators/orm/PrimaryGeneratedColumn.cjs +17 -67
- package/src/decorators/orm/PrimaryGeneratedColumn.mjs +19 -67
- package/src/decorators/orm/RelationId.cjs +17 -39
- package/src/decorators/orm/RelationId.mjs +18 -38
- package/src/decorators/orm/TableInheritance.cjs +17 -39
- package/src/decorators/orm/TableInheritance.mjs +18 -38
- package/src/decorators/orm/Tree.cjs +17 -37
- package/src/decorators/orm/Tree.mjs +18 -36
- package/src/decorators/orm/TreeChildren.cjs +17 -44
- package/src/decorators/orm/TreeChildren.mjs +17 -42
- package/src/decorators/orm/TreeLevelColumn.cjs +17 -38
- package/src/decorators/orm/TreeLevelColumn.mjs +17 -36
- package/src/decorators/orm/TreeParent.cjs +17 -44
- package/src/decorators/orm/TreeParent.mjs +17 -42
- package/src/decorators/orm/Unique.cjs +17 -57
- package/src/decorators/orm/Unique.mjs +19 -57
- package/src/decorators/orm/UpdateDateColumn.cjs +17 -38
- package/src/decorators/orm/UpdateDateColumn.mjs +18 -37
- package/src/decorators/orm/VersionColumn.cjs +17 -38
- package/src/decorators/orm/VersionColumn.mjs +18 -37
- package/src/decorators/orm/ViewColumn.cjs +17 -38
- package/src/decorators/orm/ViewColumn.mjs +18 -37
- package/src/decorators/orm/ViewEntity.cjs +17 -47
- package/src/decorators/orm/ViewEntity.mjs +18 -46
- package/src/decorators/orm/VirtualColumn.cjs +17 -55
- package/src/decorators/orm/VirtualColumn.mjs +17 -53
- package/src/lib/base/BaseObject.cjs +4 -2
- package/src/lib/base/BaseObject.mjs +4 -2
- package/src/lib/base/EventEmitter.cjs +1200 -1193
- package/src/lib/base/EventEmitter.mjs +1201 -1194
- package/src/lib/base/internal/ApplicationConfigLoader.cjs +4 -2
- package/src/lib/base/internal/ApplicationConfigLoader.mjs +4 -2
- package/src/lib/base/internal/ControllerEntrypoint.cjs +3 -3
- package/src/lib/base/internal/ControllerEntrypoint.mjs +3 -3
- package/src/lib/base/internal/DataValidator.cjs +176 -179
- package/src/lib/base/internal/DataValidator.mjs +177 -180
- package/src/lib/base/internal/ModuleConfigLoader.cjs +4 -3
- package/src/lib/base/internal/ModuleConfigLoader.mjs +4 -3
- package/src/lib/base/internal/ObjectType.cjs +4 -2
- package/src/lib/base/internal/ObjectType.mjs +4 -2
- package/src/lib/base/internal/PatternManager.cjs +740 -735
- package/src/lib/base/internal/PatternManager.mjs +745 -740
- package/src/lib/base/internal/StringifyPattern.cjs +1 -1
- package/src/lib/base/internal/StringifyPattern.mjs +1 -1
- package/src/lib/core/Application.cjs +151 -147
- package/src/lib/core/Application.mjs +199 -197
- package/src/lib/core/Component.cjs +4 -2
- package/src/lib/core/Component.mjs +4 -2
- package/src/lib/core/Container.cjs +4 -2
- package/src/lib/core/Container.mjs +4 -2
- package/src/lib/core/Module.cjs +5 -3
- package/src/lib/core/Module.mjs +5 -3
- package/src/lib/core/Provider.cjs +4 -2
- package/src/lib/core/Provider.mjs +4 -2
- package/src/lib/helpers/Glob.cjs +970 -721
- package/src/lib/helpers/Glob.mjs +1036 -787
- package/src/lib/helpers/IsHtml.cjs +7 -13
- package/src/lib/helpers/IsHtml.mjs +7 -13
- package/src/lib/helpers/IsXML.cjs +1158 -1016
- package/src/lib/helpers/IsXML.mjs +871 -729
- package/src/lib/helpers/MD5.cjs +1 -1
- package/src/lib/helpers/MD5.mjs +1 -1
- package/src/lib/helpers/NonceStr.cjs +1 -1
- package/src/lib/helpers/NonceStr.mjs +1 -1
- package/src/lib/helpers/ObjectHash.cjs +379 -372
- package/src/lib/helpers/ObjectHash.mjs +379 -372
- package/src/lib/helpers/RandomString.cjs +168 -147
- package/src/lib/helpers/RandomString.mjs +167 -146
- 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/Statistics.cjs +1 -1
- package/src/lib/helpers/Statistics.mjs +1 -1
- package/src/lib/helpers/URLBuilder.cjs +355 -355
- package/src/lib/helpers/URLBuilder.mjs +350 -350
- package/src/lib/helpers/UUID.cjs +1 -1
- package/src/lib/helpers/UUID.mjs +1 -1
- package/src/lib/ioc/DependencyInjectionContainer.cjs +32 -30
- package/src/lib/ioc/DependencyInjectionContainer.mjs +12 -10
- package/src/lib/ioc/ListModules.cjs +5174 -5249
- package/src/lib/ioc/ListModules.mjs +5177 -5252
- package/src/lib/validation/VLD.cjs +4080 -3902
- package/src/lib/validation/VLD.mjs +2970 -2792
- package/src/options/ApplicationOptions.cjs +4 -2
- package/src/options/ApplicationOptions.mjs +4 -2
- package/src/options/LoadAnonymousObjectOptions.cjs +4 -2
- package/src/options/LoadAnonymousObjectOptions.mjs +4 -2
- package/src/options/LoadNamedObjectOptions.cjs +4 -2
- package/src/options/LoadNamedObjectOptions.mjs +4 -2
- package/src/options/LoadObjectOptions.cjs +4 -2
- package/src/options/LoadObjectOptions.mjs +4 -2
- package/src/options/ModuleLoadObjectsOptions.cjs +4 -2
- package/src/options/ModuleLoadObjectsOptions.mjs +4 -2
- package/src/options/ModuleOptions.cjs +4 -4
- package/src/options/ModuleOptions.mjs +4 -4
- package/src/options/OverridableNamedObjectOptions.cjs +4 -2
- package/src/options/OverridableNamedObjectOptions.mjs +4 -2
- package/src/options/OverridableObjectOptions.cjs +4 -2
- package/src/options/OverridableObjectOptions.mjs +4 -2
- package/src/providers/Database.cjs +11 -11
- package/src/providers/Database.mjs +11 -11
- package/src/providers/PasswordHash.cjs +5 -3
- package/src/providers/PasswordHash.mjs +190 -188
- package/src/providers/migration/GenerateMigration.cjs +15 -19
- package/src/providers/migration/GenerateMigration.mjs +15 -19
- package/vendor/Package.10.cjs +2 -8
- package/vendor/Package.10.mjs +2 -8
- package/vendor/Package.11.cjs +5 -83
- package/vendor/Package.11.mjs +5 -77
- package/vendor/Package.112.cjs +48900 -0
- package/vendor/Package.112.mjs +48764 -0
- package/vendor/Package.12.cjs +4 -2
- package/vendor/Package.12.mjs +6 -4
- package/vendor/Package.13.cjs +87 -1
- package/vendor/Package.13.mjs +81 -1
- package/vendor/Package.14.cjs +1 -14057
- package/vendor/Package.14.mjs +1 -14031
- package/vendor/Package.15.cjs +1 -1
- package/vendor/Package.15.mjs +1 -1
- package/vendor/Package.16.cjs +18129 -1935
- package/vendor/Package.16.mjs +18115 -1839
- package/vendor/Package.17.cjs +1922 -47918
- package/vendor/Package.17.mjs +1874 -47937
- package/vendor/Package.18.cjs +35 -1
- package/vendor/Package.18.mjs +35 -1
- package/vendor/Package.19.cjs +37 -0
- package/vendor/Package.19.mjs +35 -0
- package/vendor/Package.2.cjs +5739 -5710
- package/vendor/Package.2.mjs +5733 -5704
- package/vendor/Package.20.cjs +37 -0
- package/vendor/Package.20.mjs +35 -0
- package/vendor/Package.21.cjs +37 -0
- package/vendor/Package.21.mjs +35 -0
- package/vendor/Package.22.cjs +37 -0
- package/vendor/Package.22.mjs +35 -0
- package/vendor/Package.23.cjs +37 -0
- package/vendor/Package.23.mjs +35 -0
- package/vendor/Package.24.cjs +37 -0
- package/vendor/Package.24.mjs +35 -0
- package/vendor/Package.25.cjs +37 -0
- package/vendor/Package.25.mjs +35 -0
- package/vendor/Package.26.cjs +37 -0
- package/vendor/Package.26.mjs +35 -0
- package/vendor/Package.27.cjs +37 -0
- package/vendor/Package.27.mjs +35 -0
- package/vendor/Package.28.cjs +37 -0
- package/vendor/Package.28.mjs +35 -0
- package/vendor/Package.29.cjs +40 -0
- package/vendor/Package.29.mjs +38 -0
- package/vendor/Package.30.cjs +41 -0
- package/vendor/Package.30.mjs +39 -0
- package/vendor/Package.31.cjs +72 -0
- package/vendor/Package.31.mjs +70 -0
- package/vendor/Package.32.cjs +37 -0
- package/vendor/Package.32.mjs +35 -0
- package/vendor/Package.33.cjs +37 -0
- package/vendor/Package.33.mjs +35 -0
- package/vendor/Package.34.cjs +46 -0
- package/vendor/Package.34.mjs +44 -0
- package/vendor/Package.35.cjs +34 -0
- package/vendor/Package.35.mjs +32 -0
- package/vendor/Package.36.cjs +40 -0
- package/vendor/Package.36.mjs +38 -0
- package/vendor/Package.37.cjs +36 -0
- package/vendor/Package.37.mjs +34 -0
- package/vendor/Package.38.cjs +52 -0
- package/vendor/Package.38.mjs +50 -0
- package/vendor/Package.39.cjs +41 -0
- package/vendor/Package.39.mjs +39 -0
- package/vendor/Package.4.cjs +884 -874
- package/vendor/Package.4.mjs +884 -874
- package/vendor/Package.40.cjs +42 -0
- package/vendor/Package.40.mjs +40 -0
- package/vendor/Package.41.cjs +53 -0
- package/vendor/Package.41.mjs +51 -0
- package/vendor/Package.42.cjs +53 -0
- package/vendor/Package.42.mjs +51 -0
- package/vendor/Package.43.cjs +40 -0
- package/vendor/Package.43.mjs +38 -0
- package/vendor/Package.44.cjs +46 -0
- package/vendor/Package.44.mjs +44 -0
- package/vendor/Package.45.cjs +53 -0
- package/vendor/Package.45.mjs +51 -0
- package/vendor/Package.46.cjs +59 -0
- package/vendor/Package.46.mjs +57 -0
- package/vendor/Package.47.cjs +65 -0
- package/vendor/Package.47.mjs +63 -0
- package/vendor/Package.48.cjs +38 -0
- package/vendor/Package.48.mjs +36 -0
- package/vendor/Package.49.cjs +38 -0
- package/vendor/Package.49.mjs +36 -0
- package/vendor/Package.5.cjs +15 -11
- package/vendor/Package.5.mjs +11 -7
- package/vendor/Package.50.cjs +36 -0
- package/vendor/Package.50.mjs +34 -0
- package/vendor/Package.51.cjs +43 -0
- package/vendor/Package.51.mjs +41 -0
- package/vendor/Package.52.cjs +37 -0
- package/vendor/Package.52.mjs +35 -0
- package/vendor/Package.53.cjs +43 -0
- package/vendor/Package.53.mjs +41 -0
- package/vendor/Package.54.cjs +55 -0
- package/vendor/Package.54.mjs +53 -0
- package/vendor/Package.55.cjs +37 -0
- package/vendor/Package.55.mjs +35 -0
- package/vendor/Package.56.cjs +37 -0
- package/vendor/Package.56.mjs +35 -0
- package/vendor/Package.57.cjs +37 -0
- package/vendor/Package.57.mjs +35 -0
- package/vendor/Package.58.cjs +45 -0
- package/vendor/Package.58.mjs +43 -0
- package/vendor/Package.59.cjs +53 -0
- package/vendor/Package.59.mjs +51 -0
- package/vendor/Package.6.cjs +520 -511
- package/vendor/Package.6.mjs +543 -534
- package/vendor/Package.60.cjs +47649 -0
- package/vendor/Package.60.mjs +47606 -0
- package/vendor/Package.610.cjs +11 -11
- package/vendor/Package.610.mjs +11 -11
- package/vendor/Package.611.cjs +33 -23
- package/vendor/Package.611.mjs +19 -9
- package/vendor/Package.612.cjs +42 -36
- package/vendor/Package.612.mjs +35 -29
- package/vendor/Package.613.cjs +5 -4
- package/vendor/Package.613.mjs +5 -4
- package/vendor/Package.62.cjs +92 -89
- package/vendor/Package.62.mjs +185 -182
- package/vendor/Package.63.cjs +509 -166
- package/vendor/Package.63.mjs +490 -165
- package/vendor/Package.64.cjs +139 -511
- package/vendor/Package.64.mjs +139 -491
- package/vendor/Package.65.cjs +4135 -150
- package/vendor/Package.65.mjs +4143 -150
- package/vendor/Package.66.cjs +346 -4150
- package/vendor/Package.66.mjs +346 -4158
- package/vendor/Package.67.cjs +412 -261
- package/vendor/Package.67.mjs +410 -259
- package/vendor/Package.68.cjs +397 -405
- package/vendor/Package.68.mjs +227 -242
- package/vendor/Package.8.cjs +0 -4
- package/vendor/Package.8.mjs +0 -4
- package/vendor/Package.9.cjs +132 -118
- package/vendor/Package.9.mjs +138 -124
- package/vendor/TypeDef.internal.3.d.ts +0 -4
- package/vendor/Package.102.cjs +0 -48773
- package/vendor/Package.102.mjs +0 -48697
- package/vendor/Package.122.cjs +0 -3
- package/vendor/Package.122.mjs +0 -1
package/vendor/Package.67.cjs
CHANGED
|
@@ -1,57 +1,59 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
const
|
|
3
|
+
const t = require("buffer");
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var e = (s, i = true) => {
|
|
6
6
|
if (s === void 0 || s === null) {
|
|
7
7
|
return "null";
|
|
8
8
|
}
|
|
9
9
|
if (typeof s === "string") {
|
|
10
|
-
return JSON.stringify(s.startsWith(":") ?
|
|
10
|
+
return JSON.stringify(i && s.startsWith(":") ? `:${s}` : s);
|
|
11
11
|
}
|
|
12
|
-
if (
|
|
13
|
-
return JSON.stringify(
|
|
12
|
+
if (t.Buffer.isBuffer(s)) {
|
|
13
|
+
return JSON.stringify(`:base64:${s.toString("base64")}`);
|
|
14
14
|
}
|
|
15
15
|
if (s?.toJSON) {
|
|
16
16
|
s = s.toJSON();
|
|
17
17
|
}
|
|
18
18
|
if (typeof s === "object") {
|
|
19
|
-
let
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
let
|
|
23
|
-
for (const
|
|
24
|
-
const
|
|
25
|
-
if (!Object.hasOwn(s,
|
|
19
|
+
let t = "";
|
|
20
|
+
const r = Array.isArray(s);
|
|
21
|
+
t = r ? "[" : "{";
|
|
22
|
+
let o = true;
|
|
23
|
+
for (const a in s) {
|
|
24
|
+
const n = typeof s[a] === "function" || !r && s[a] === void 0;
|
|
25
|
+
if (!Object.hasOwn(s, a) || n) {
|
|
26
26
|
continue;
|
|
27
27
|
}
|
|
28
|
-
if (!
|
|
29
|
-
|
|
28
|
+
if (!o) {
|
|
29
|
+
t += ",";
|
|
30
30
|
}
|
|
31
|
-
|
|
32
|
-
if (
|
|
33
|
-
|
|
34
|
-
} else if (s[
|
|
35
|
-
|
|
31
|
+
o = false;
|
|
32
|
+
if (r) {
|
|
33
|
+
t += e(s[a], i);
|
|
34
|
+
} else if (s[a] !== void 0) {
|
|
35
|
+
t += `${e(a, false)}:${e(s[a], i)}`;
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
|
-
|
|
39
|
-
return
|
|
38
|
+
t += r ? "]" : "}";
|
|
39
|
+
return t;
|
|
40
40
|
}
|
|
41
41
|
return JSON.stringify(s);
|
|
42
42
|
};
|
|
43
43
|
|
|
44
|
-
var s = t =>
|
|
44
|
+
var s = t => e(t, true);
|
|
45
|
+
|
|
46
|
+
var i = e => JSON.parse(e, ((e, s) => {
|
|
45
47
|
if (typeof s === "string") {
|
|
46
48
|
if (s.startsWith(":base64:")) {
|
|
47
|
-
return
|
|
49
|
+
return t.Buffer.from(s.slice(8), "base64");
|
|
48
50
|
}
|
|
49
51
|
return s.startsWith(":") ? s.slice(1) : s;
|
|
50
52
|
}
|
|
51
53
|
return s;
|
|
52
54
|
}));
|
|
53
55
|
|
|
54
|
-
var
|
|
56
|
+
var r = class {
|
|
55
57
|
_eventListeners;
|
|
56
58
|
_maxListeners;
|
|
57
59
|
constructor() {
|
|
@@ -61,98 +63,98 @@ var i = class {
|
|
|
61
63
|
maxListeners() {
|
|
62
64
|
return this._maxListeners;
|
|
63
65
|
}
|
|
64
|
-
addListener(
|
|
65
|
-
this.on(
|
|
66
|
+
addListener(t, e) {
|
|
67
|
+
this.on(t, e);
|
|
66
68
|
}
|
|
67
|
-
on(
|
|
68
|
-
if (!this._eventListeners.has(
|
|
69
|
-
this._eventListeners.set(
|
|
69
|
+
on(t, e) {
|
|
70
|
+
if (!this._eventListeners.has(t)) {
|
|
71
|
+
this._eventListeners.set(t, []);
|
|
70
72
|
}
|
|
71
|
-
const s = this._eventListeners.get(
|
|
73
|
+
const s = this._eventListeners.get(t);
|
|
72
74
|
if (s) {
|
|
73
75
|
if (s.length >= this._maxListeners) {
|
|
74
|
-
console.warn(`MaxListenersExceededWarning: Possible event memory leak detected. ${s.length + 1} ${
|
|
76
|
+
console.warn(`MaxListenersExceededWarning: Possible event memory leak detected. ${s.length + 1} ${t} listeners added. Use setMaxListeners() to increase limit.`);
|
|
75
77
|
}
|
|
76
|
-
s.push(
|
|
78
|
+
s.push(e);
|
|
77
79
|
}
|
|
78
80
|
return this;
|
|
79
81
|
}
|
|
80
|
-
removeListener(
|
|
81
|
-
this.off(
|
|
82
|
+
removeListener(t, e) {
|
|
83
|
+
this.off(t, e);
|
|
82
84
|
}
|
|
83
|
-
off(
|
|
84
|
-
const s = this._eventListeners.get(
|
|
85
|
-
const i = s.indexOf(
|
|
85
|
+
off(t, e) {
|
|
86
|
+
const s = this._eventListeners.get(t) ?? [];
|
|
87
|
+
const i = s.indexOf(e);
|
|
86
88
|
if (i !== -1) {
|
|
87
89
|
s.splice(i, 1);
|
|
88
90
|
}
|
|
89
91
|
if (s.length === 0) {
|
|
90
|
-
this._eventListeners.delete(
|
|
92
|
+
this._eventListeners.delete(t);
|
|
91
93
|
}
|
|
92
94
|
}
|
|
93
|
-
once(
|
|
95
|
+
once(t, e) {
|
|
94
96
|
const s = (...i) => {
|
|
95
|
-
|
|
96
|
-
this.off(
|
|
97
|
+
e(...i);
|
|
98
|
+
this.off(t, s);
|
|
97
99
|
};
|
|
98
|
-
this.on(
|
|
100
|
+
this.on(t, s);
|
|
99
101
|
}
|
|
100
|
-
emit(
|
|
101
|
-
const s = this._eventListeners.get(
|
|
102
|
+
emit(t, ...e) {
|
|
103
|
+
const s = this._eventListeners.get(t);
|
|
102
104
|
if (s && s.length > 0) {
|
|
103
|
-
for (const
|
|
104
|
-
|
|
105
|
+
for (const t of s) {
|
|
106
|
+
t(...e);
|
|
105
107
|
}
|
|
106
108
|
}
|
|
107
109
|
}
|
|
108
|
-
listeners(
|
|
109
|
-
return this._eventListeners.get(
|
|
110
|
+
listeners(t) {
|
|
111
|
+
return this._eventListeners.get(t) ?? [];
|
|
110
112
|
}
|
|
111
|
-
removeAllListeners(
|
|
112
|
-
if (
|
|
113
|
-
this._eventListeners.delete(
|
|
113
|
+
removeAllListeners(t) {
|
|
114
|
+
if (t) {
|
|
115
|
+
this._eventListeners.delete(t);
|
|
114
116
|
} else {
|
|
115
117
|
this._eventListeners.clear();
|
|
116
118
|
}
|
|
117
119
|
}
|
|
118
|
-
setMaxListeners(
|
|
119
|
-
this._maxListeners =
|
|
120
|
+
setMaxListeners(t) {
|
|
121
|
+
this._maxListeners = t;
|
|
120
122
|
}
|
|
121
123
|
};
|
|
122
124
|
|
|
123
|
-
var
|
|
125
|
+
var o = r;
|
|
124
126
|
|
|
125
|
-
var
|
|
127
|
+
var a = class extends o {
|
|
126
128
|
_hookHandlers;
|
|
127
129
|
constructor() {
|
|
128
130
|
super();
|
|
129
131
|
this._hookHandlers = new Map;
|
|
130
132
|
}
|
|
131
|
-
addHandler(
|
|
132
|
-
const s = this._hookHandlers.get(
|
|
133
|
+
addHandler(t, e) {
|
|
134
|
+
const s = this._hookHandlers.get(t);
|
|
133
135
|
if (s) {
|
|
134
|
-
s.push(
|
|
136
|
+
s.push(e);
|
|
135
137
|
} else {
|
|
136
|
-
this._hookHandlers.set(
|
|
138
|
+
this._hookHandlers.set(t, [ e ]);
|
|
137
139
|
}
|
|
138
140
|
}
|
|
139
|
-
removeHandler(
|
|
140
|
-
const s = this._hookHandlers.get(
|
|
141
|
+
removeHandler(t, e) {
|
|
142
|
+
const s = this._hookHandlers.get(t);
|
|
141
143
|
if (s) {
|
|
142
|
-
const
|
|
143
|
-
if (
|
|
144
|
-
s.splice(
|
|
144
|
+
const t = s.indexOf(e);
|
|
145
|
+
if (t !== -1) {
|
|
146
|
+
s.splice(t, 1);
|
|
145
147
|
}
|
|
146
148
|
}
|
|
147
149
|
}
|
|
148
|
-
trigger(
|
|
149
|
-
const s = this._hookHandlers.get(
|
|
150
|
+
trigger(t, e) {
|
|
151
|
+
const s = this._hookHandlers.get(t);
|
|
150
152
|
if (s) {
|
|
151
153
|
for (const i of s) {
|
|
152
154
|
try {
|
|
153
|
-
i(
|
|
154
|
-
} catch (
|
|
155
|
-
this.emit("error", new Error(`Error in hook handler for event "${
|
|
155
|
+
i(e);
|
|
156
|
+
} catch (e) {
|
|
157
|
+
this.emit("error", new Error(`Error in hook handler for event "${t}": ${e.message}`));
|
|
156
158
|
}
|
|
157
159
|
}
|
|
158
160
|
}
|
|
@@ -162,19 +164,19 @@ var o = class extends r {
|
|
|
162
164
|
}
|
|
163
165
|
};
|
|
164
166
|
|
|
165
|
-
var
|
|
167
|
+
var n = a;
|
|
166
168
|
|
|
167
|
-
var
|
|
169
|
+
var h = class extends o {
|
|
168
170
|
enabled=true;
|
|
169
171
|
hits=0;
|
|
170
172
|
misses=0;
|
|
171
173
|
sets=0;
|
|
172
174
|
deletes=0;
|
|
173
175
|
errors=0;
|
|
174
|
-
constructor(
|
|
176
|
+
constructor(t) {
|
|
175
177
|
super();
|
|
176
|
-
if (
|
|
177
|
-
this.enabled =
|
|
178
|
+
if (t !== void 0) {
|
|
179
|
+
this.enabled = t;
|
|
178
180
|
}
|
|
179
181
|
this.reset();
|
|
180
182
|
}
|
|
@@ -198,6 +200,15 @@ var n = class extends r {
|
|
|
198
200
|
this.deletes++;
|
|
199
201
|
}
|
|
200
202
|
}
|
|
203
|
+
hitsOrMisses(t) {
|
|
204
|
+
for (const e of t) {
|
|
205
|
+
if (e === void 0) {
|
|
206
|
+
this.miss();
|
|
207
|
+
} else {
|
|
208
|
+
this.hit();
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
}
|
|
201
212
|
reset() {
|
|
202
213
|
this.hits = 0;
|
|
203
214
|
this.misses = 0;
|
|
@@ -207,52 +218,57 @@ var n = class extends r {
|
|
|
207
218
|
}
|
|
208
219
|
};
|
|
209
220
|
|
|
210
|
-
var
|
|
221
|
+
var l = h;
|
|
211
222
|
|
|
212
|
-
var
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
+
var c = (t => {
|
|
224
|
+
t["PRE_SET"] = "preSet";
|
|
225
|
+
t["POST_SET"] = "postSet";
|
|
226
|
+
t["PRE_GET"] = "preGet";
|
|
227
|
+
t["POST_GET"] = "postGet";
|
|
228
|
+
t["PRE_GET_MANY"] = "preGetMany";
|
|
229
|
+
t["POST_GET_MANY"] = "postGetMany";
|
|
230
|
+
t["PRE_GET_RAW"] = "preGetRaw";
|
|
231
|
+
t["POST_GET_RAW"] = "postGetRaw";
|
|
232
|
+
t["PRE_GET_MANY_RAW"] = "preGetManyRaw";
|
|
233
|
+
t["POST_GET_MANY_RAW"] = "postGetManyRaw";
|
|
234
|
+
t["PRE_DELETE"] = "preDelete";
|
|
235
|
+
t["POST_DELETE"] = "postDelete";
|
|
236
|
+
return t;
|
|
237
|
+
})(c || {});
|
|
223
238
|
|
|
224
|
-
var
|
|
239
|
+
var f = [ "sqlite", "postgres", "mysql", "mongo", "redis", "valkey", "etcd" ];
|
|
225
240
|
|
|
226
|
-
var
|
|
241
|
+
var p = class extends o {
|
|
227
242
|
opts;
|
|
228
243
|
iterator;
|
|
229
|
-
hooks=new
|
|
230
|
-
stats=new
|
|
244
|
+
hooks=new n;
|
|
245
|
+
stats=new l(false);
|
|
231
246
|
_ttl;
|
|
232
247
|
_namespace;
|
|
233
248
|
_store=new Map;
|
|
234
|
-
_serialize=
|
|
235
|
-
_deserialize=
|
|
249
|
+
_serialize=s;
|
|
250
|
+
_deserialize=i;
|
|
236
251
|
_compression;
|
|
237
252
|
_useKeyPrefix=true;
|
|
238
|
-
|
|
253
|
+
_throwOnErrors=false;
|
|
254
|
+
constructor(t, e) {
|
|
239
255
|
super();
|
|
240
|
-
i ??= {};
|
|
241
256
|
e ??= {};
|
|
257
|
+
t ??= {};
|
|
242
258
|
this.opts = {
|
|
243
259
|
namespace: "keyv",
|
|
244
|
-
serialize:
|
|
245
|
-
deserialize:
|
|
260
|
+
serialize: s,
|
|
261
|
+
deserialize: i,
|
|
246
262
|
emitErrors: true,
|
|
247
263
|
store: new Map,
|
|
248
|
-
...
|
|
264
|
+
...e
|
|
249
265
|
};
|
|
250
|
-
if (
|
|
251
|
-
this.opts.store =
|
|
266
|
+
if (t && t.get) {
|
|
267
|
+
this.opts.store = t;
|
|
252
268
|
} else {
|
|
253
269
|
this.opts = {
|
|
254
270
|
...this.opts,
|
|
255
|
-
...
|
|
271
|
+
...t
|
|
256
272
|
};
|
|
257
273
|
}
|
|
258
274
|
this._store = this.opts.store ?? new Map;
|
|
@@ -267,7 +283,7 @@ var f = class extends r {
|
|
|
267
283
|
throw new Error("Invalid storage adapter");
|
|
268
284
|
}
|
|
269
285
|
if (typeof this._store.on === "function") {
|
|
270
|
-
this._store.on("error", (
|
|
286
|
+
this._store.on("error", (t => this.emit("error", t)));
|
|
271
287
|
}
|
|
272
288
|
this._store.namespace = this._namespace;
|
|
273
289
|
if (typeof this._store[Symbol.iterator] === "function" && this._store instanceof Map) {
|
|
@@ -285,24 +301,27 @@ var f = class extends r {
|
|
|
285
301
|
if (this.opts.useKeyPrefix !== void 0) {
|
|
286
302
|
this._useKeyPrefix = this.opts.useKeyPrefix;
|
|
287
303
|
}
|
|
304
|
+
if (this.opts.throwOnErrors !== void 0) {
|
|
305
|
+
this._throwOnErrors = this.opts.throwOnErrors;
|
|
306
|
+
}
|
|
288
307
|
}
|
|
289
308
|
get store() {
|
|
290
309
|
return this._store;
|
|
291
310
|
}
|
|
292
|
-
set store(
|
|
293
|
-
if (this._isValidStorageAdapter(
|
|
294
|
-
this._store =
|
|
295
|
-
this.opts.store =
|
|
296
|
-
if (typeof
|
|
297
|
-
|
|
311
|
+
set store(t) {
|
|
312
|
+
if (this._isValidStorageAdapter(t)) {
|
|
313
|
+
this._store = t;
|
|
314
|
+
this.opts.store = t;
|
|
315
|
+
if (typeof t.on === "function") {
|
|
316
|
+
t.on("error", (t => this.emit("error", t)));
|
|
298
317
|
}
|
|
299
318
|
if (this._namespace) {
|
|
300
319
|
this._store.namespace = this._namespace;
|
|
301
320
|
}
|
|
302
|
-
if (typeof
|
|
303
|
-
this.iterator = this.generateIterator(
|
|
304
|
-
} else if ("iterator" in
|
|
305
|
-
this.iterator = this.generateIterator(
|
|
321
|
+
if (typeof t[Symbol.iterator] === "function" && t instanceof Map) {
|
|
322
|
+
this.iterator = this.generateIterator(t);
|
|
323
|
+
} else if ("iterator" in t && t.opts && this._checkIterableAdapter()) {
|
|
324
|
+
this.iterator = this.generateIterator(t.iterator?.bind(t));
|
|
306
325
|
}
|
|
307
326
|
} else {
|
|
308
327
|
throw new Error("Invalid storage adapter");
|
|
@@ -311,120 +330,142 @@ var f = class extends r {
|
|
|
311
330
|
get compression() {
|
|
312
331
|
return this._compression;
|
|
313
332
|
}
|
|
314
|
-
set compression(
|
|
315
|
-
this._compression =
|
|
333
|
+
set compression(t) {
|
|
334
|
+
this._compression = t;
|
|
316
335
|
}
|
|
317
336
|
get namespace() {
|
|
318
337
|
return this._namespace;
|
|
319
338
|
}
|
|
320
|
-
set namespace(
|
|
321
|
-
this._namespace =
|
|
322
|
-
this.opts.namespace =
|
|
323
|
-
this._store.namespace =
|
|
339
|
+
set namespace(t) {
|
|
340
|
+
this._namespace = t;
|
|
341
|
+
this.opts.namespace = t;
|
|
342
|
+
this._store.namespace = t;
|
|
324
343
|
if (this.opts.store) {
|
|
325
|
-
this.opts.store.namespace =
|
|
344
|
+
this.opts.store.namespace = t;
|
|
326
345
|
}
|
|
327
346
|
}
|
|
328
347
|
get ttl() {
|
|
329
348
|
return this._ttl;
|
|
330
349
|
}
|
|
331
|
-
set ttl(
|
|
332
|
-
this.opts.ttl =
|
|
333
|
-
this._ttl =
|
|
350
|
+
set ttl(t) {
|
|
351
|
+
this.opts.ttl = t;
|
|
352
|
+
this._ttl = t;
|
|
334
353
|
}
|
|
335
354
|
get serialize() {
|
|
336
355
|
return this._serialize;
|
|
337
356
|
}
|
|
338
|
-
set serialize(
|
|
339
|
-
this.opts.serialize =
|
|
340
|
-
this._serialize =
|
|
357
|
+
set serialize(t) {
|
|
358
|
+
this.opts.serialize = t;
|
|
359
|
+
this._serialize = t;
|
|
341
360
|
}
|
|
342
361
|
get deserialize() {
|
|
343
362
|
return this._deserialize;
|
|
344
363
|
}
|
|
345
|
-
set deserialize(
|
|
346
|
-
this.opts.deserialize =
|
|
347
|
-
this._deserialize =
|
|
364
|
+
set deserialize(t) {
|
|
365
|
+
this.opts.deserialize = t;
|
|
366
|
+
this._deserialize = t;
|
|
348
367
|
}
|
|
349
368
|
get useKeyPrefix() {
|
|
350
369
|
return this._useKeyPrefix;
|
|
351
370
|
}
|
|
352
|
-
set useKeyPrefix(
|
|
353
|
-
this._useKeyPrefix =
|
|
354
|
-
this.opts.useKeyPrefix =
|
|
371
|
+
set useKeyPrefix(t) {
|
|
372
|
+
this._useKeyPrefix = t;
|
|
373
|
+
this.opts.useKeyPrefix = t;
|
|
374
|
+
}
|
|
375
|
+
get throwOnErrors() {
|
|
376
|
+
return this._throwOnErrors;
|
|
377
|
+
}
|
|
378
|
+
set throwOnErrors(t) {
|
|
379
|
+
this._throwOnErrors = t;
|
|
380
|
+
this.opts.throwOnErrors = t;
|
|
355
381
|
}
|
|
356
|
-
generateIterator(
|
|
357
|
-
const
|
|
358
|
-
for await (const [
|
|
359
|
-
const
|
|
360
|
-
if (this._useKeyPrefix && this._store.namespace && !
|
|
382
|
+
generateIterator(t) {
|
|
383
|
+
const e = async function*() {
|
|
384
|
+
for await (const [e, s] of typeof t === "function" ? t(this._store.namespace) : t) {
|
|
385
|
+
const t = await this.deserializeData(s);
|
|
386
|
+
if (this._useKeyPrefix && this._store.namespace && !e.includes(this._store.namespace)) {
|
|
361
387
|
continue;
|
|
362
388
|
}
|
|
363
|
-
if (typeof
|
|
364
|
-
this.delete(
|
|
389
|
+
if (typeof t.expires === "number" && Date.now() > t.expires) {
|
|
390
|
+
this.delete(e);
|
|
365
391
|
continue;
|
|
366
392
|
}
|
|
367
|
-
yield [ this._getKeyUnprefix(
|
|
393
|
+
yield [ this._getKeyUnprefix(e), t.value ];
|
|
368
394
|
}
|
|
369
395
|
};
|
|
370
|
-
return
|
|
396
|
+
return e.bind(this);
|
|
371
397
|
}
|
|
372
398
|
_checkIterableAdapter() {
|
|
373
|
-
return
|
|
399
|
+
return f.includes(this._store.opts.dialect) || f.some((t => this._store.opts.url.includes(t)));
|
|
374
400
|
}
|
|
375
|
-
_getKeyPrefix(
|
|
401
|
+
_getKeyPrefix(t) {
|
|
376
402
|
if (!this._useKeyPrefix) {
|
|
377
|
-
return
|
|
403
|
+
return t;
|
|
378
404
|
}
|
|
379
405
|
if (!this._namespace) {
|
|
380
|
-
return
|
|
406
|
+
return t;
|
|
381
407
|
}
|
|
382
|
-
return `${this._namespace}:${
|
|
408
|
+
return `${this._namespace}:${t}`;
|
|
383
409
|
}
|
|
384
|
-
_getKeyPrefixArray(
|
|
410
|
+
_getKeyPrefixArray(t) {
|
|
385
411
|
if (!this._useKeyPrefix) {
|
|
386
|
-
return
|
|
412
|
+
return t;
|
|
387
413
|
}
|
|
388
414
|
if (!this._namespace) {
|
|
389
|
-
return
|
|
415
|
+
return t;
|
|
390
416
|
}
|
|
391
|
-
return
|
|
417
|
+
return t.map((t => `${this._namespace}:${t}`));
|
|
392
418
|
}
|
|
393
|
-
_getKeyUnprefix(
|
|
419
|
+
_getKeyUnprefix(t) {
|
|
394
420
|
if (!this._useKeyPrefix) {
|
|
395
|
-
return
|
|
421
|
+
return t;
|
|
396
422
|
}
|
|
397
|
-
return
|
|
423
|
+
return t.split(":").splice(1).join(":");
|
|
398
424
|
}
|
|
399
|
-
_isValidStorageAdapter(
|
|
400
|
-
return
|
|
425
|
+
_isValidStorageAdapter(t) {
|
|
426
|
+
return t instanceof Map || typeof t.get === "function" && typeof t.set === "function" && typeof t.delete === "function" && typeof t.clear === "function";
|
|
401
427
|
}
|
|
402
|
-
async get(
|
|
428
|
+
async get(t, e) {
|
|
403
429
|
const {store: s} = this.opts;
|
|
404
|
-
const i = Array.isArray(
|
|
405
|
-
const r = i ? this._getKeyPrefixArray(
|
|
406
|
-
const o =
|
|
430
|
+
const i = Array.isArray(t);
|
|
431
|
+
const r = i ? this._getKeyPrefixArray(t) : this._getKeyPrefix(t);
|
|
432
|
+
const o = t => typeof t.expires === "number" && Date.now() > t.expires;
|
|
407
433
|
if (i) {
|
|
408
|
-
if (
|
|
409
|
-
return this.getMany(
|
|
434
|
+
if (e?.raw === true) {
|
|
435
|
+
return this.getMany(t, {
|
|
410
436
|
raw: true
|
|
411
437
|
});
|
|
412
438
|
}
|
|
413
|
-
return this.getMany(
|
|
439
|
+
return this.getMany(t, {
|
|
414
440
|
raw: false
|
|
415
441
|
});
|
|
416
442
|
}
|
|
417
443
|
this.hooks.trigger("preGet", {
|
|
418
444
|
key: r
|
|
419
445
|
});
|
|
420
|
-
|
|
446
|
+
let a;
|
|
447
|
+
try {
|
|
448
|
+
a = await s.get(r);
|
|
449
|
+
} catch (t) {
|
|
450
|
+
if (this.throwOnErrors) {
|
|
451
|
+
throw t;
|
|
452
|
+
}
|
|
453
|
+
}
|
|
421
454
|
const n = typeof a === "string" || this.opts.compression ? await this.deserializeData(a) : a;
|
|
422
455
|
if (n === void 0 || n === null) {
|
|
456
|
+
this.hooks.trigger("postGet", {
|
|
457
|
+
key: r,
|
|
458
|
+
value: void 0
|
|
459
|
+
});
|
|
423
460
|
this.stats.miss();
|
|
424
461
|
return void 0;
|
|
425
462
|
}
|
|
426
463
|
if (o(n)) {
|
|
427
|
-
await this.delete(
|
|
464
|
+
await this.delete(t);
|
|
465
|
+
this.hooks.trigger("postGet", {
|
|
466
|
+
key: r,
|
|
467
|
+
value: void 0
|
|
468
|
+
});
|
|
428
469
|
this.stats.miss();
|
|
429
470
|
return void 0;
|
|
430
471
|
}
|
|
@@ -433,30 +474,30 @@ var f = class extends r {
|
|
|
433
474
|
value: n
|
|
434
475
|
});
|
|
435
476
|
this.stats.hit();
|
|
436
|
-
return
|
|
477
|
+
return e?.raw ? n : n.value;
|
|
437
478
|
}
|
|
438
|
-
async getMany(
|
|
479
|
+
async getMany(t, e) {
|
|
439
480
|
const {store: s} = this.opts;
|
|
440
|
-
const i = this._getKeyPrefixArray(
|
|
441
|
-
const r =
|
|
481
|
+
const i = this._getKeyPrefixArray(t);
|
|
482
|
+
const r = t => typeof t.expires === "number" && Date.now() > t.expires;
|
|
442
483
|
this.hooks.trigger("preGetMany", {
|
|
443
484
|
keys: i
|
|
444
485
|
});
|
|
445
486
|
if (s.getMany === void 0) {
|
|
446
|
-
const
|
|
447
|
-
const i = await s.get(
|
|
487
|
+
const t = i.map((async t => {
|
|
488
|
+
const i = await s.get(t);
|
|
448
489
|
const o = typeof i === "string" || this.opts.compression ? await this.deserializeData(i) : i;
|
|
449
490
|
if (o === void 0 || o === null) {
|
|
450
491
|
return void 0;
|
|
451
492
|
}
|
|
452
493
|
if (r(o)) {
|
|
453
|
-
await this.delete(
|
|
494
|
+
await this.delete(t);
|
|
454
495
|
return void 0;
|
|
455
496
|
}
|
|
456
|
-
return
|
|
497
|
+
return e?.raw ? o : o.value;
|
|
457
498
|
}));
|
|
458
|
-
const o = await Promise.allSettled(
|
|
459
|
-
const a = o.map((
|
|
499
|
+
const o = await Promise.allSettled(t);
|
|
500
|
+
const a = o.map((t => t.value));
|
|
460
501
|
this.hooks.trigger("postGetMany", a);
|
|
461
502
|
if (a.length > 0) {
|
|
462
503
|
this.stats.hit();
|
|
@@ -465,6 +506,7 @@ var f = class extends r {
|
|
|
465
506
|
}
|
|
466
507
|
const o = await s.getMany(i);
|
|
467
508
|
const a = [];
|
|
509
|
+
const n = [];
|
|
468
510
|
for (const s in o) {
|
|
469
511
|
let i = o[s];
|
|
470
512
|
if (typeof i === "string") {
|
|
@@ -475,12 +517,15 @@ var f = class extends r {
|
|
|
475
517
|
continue;
|
|
476
518
|
}
|
|
477
519
|
if (r(i)) {
|
|
478
|
-
|
|
520
|
+
n.push(t[s]);
|
|
479
521
|
a.push(void 0);
|
|
480
522
|
continue;
|
|
481
523
|
}
|
|
482
|
-
const
|
|
483
|
-
a.push(
|
|
524
|
+
const h = e?.raw ? i : i.value;
|
|
525
|
+
a.push(h);
|
|
526
|
+
}
|
|
527
|
+
if (n.length > 0) {
|
|
528
|
+
await this.deleteMany(n);
|
|
484
529
|
}
|
|
485
530
|
this.hooks.trigger("postGetMany", a);
|
|
486
531
|
if (a.length > 0) {
|
|
@@ -488,10 +533,95 @@ var f = class extends r {
|
|
|
488
533
|
}
|
|
489
534
|
return a;
|
|
490
535
|
}
|
|
491
|
-
async
|
|
536
|
+
async getRaw(t) {
|
|
537
|
+
const {store: e} = this.opts;
|
|
538
|
+
const s = this._getKeyPrefix(t);
|
|
539
|
+
this.hooks.trigger("preGetRaw", {
|
|
540
|
+
key: s
|
|
541
|
+
});
|
|
542
|
+
const i = await e.get(s);
|
|
543
|
+
if (i === void 0 || i === null) {
|
|
544
|
+
this.hooks.trigger("postGetRaw", {
|
|
545
|
+
key: s,
|
|
546
|
+
value: void 0
|
|
547
|
+
});
|
|
548
|
+
this.stats.miss();
|
|
549
|
+
return void 0;
|
|
550
|
+
}
|
|
551
|
+
const r = typeof i === "string" || this.opts.compression ? await this.deserializeData(i) : i;
|
|
552
|
+
if (r !== void 0 && r.expires !== void 0 && r.expires !== null && r.expires < Date.now()) {
|
|
553
|
+
this.hooks.trigger("postGetRaw", {
|
|
554
|
+
key: s,
|
|
555
|
+
value: void 0
|
|
556
|
+
});
|
|
557
|
+
this.stats.miss();
|
|
558
|
+
await this.delete(t);
|
|
559
|
+
return void 0;
|
|
560
|
+
}
|
|
561
|
+
this.stats.hit();
|
|
562
|
+
this.hooks.trigger("postGetRaw", {
|
|
563
|
+
key: s,
|
|
564
|
+
value: r
|
|
565
|
+
});
|
|
566
|
+
return r;
|
|
567
|
+
}
|
|
568
|
+
async getManyRaw(t) {
|
|
569
|
+
const {store: e} = this.opts;
|
|
570
|
+
const s = this._getKeyPrefixArray(t);
|
|
571
|
+
if (t.length === 0) {
|
|
572
|
+
const e = Array.from({
|
|
573
|
+
length: t.length
|
|
574
|
+
}).fill(void 0);
|
|
575
|
+
this.stats.misses += t.length;
|
|
576
|
+
this.hooks.trigger("postGetManyRaw", {
|
|
577
|
+
keys: s,
|
|
578
|
+
values: e
|
|
579
|
+
});
|
|
580
|
+
return e;
|
|
581
|
+
}
|
|
582
|
+
let i = [];
|
|
583
|
+
if (e.getMany === void 0) {
|
|
584
|
+
const t = s.map((async t => {
|
|
585
|
+
const s = await e.get(t);
|
|
586
|
+
if (s !== void 0 && s !== null) {
|
|
587
|
+
return this.deserializeData(s);
|
|
588
|
+
}
|
|
589
|
+
return void 0;
|
|
590
|
+
}));
|
|
591
|
+
const r = await Promise.allSettled(t);
|
|
592
|
+
i = r.map((t => t.value));
|
|
593
|
+
} else {
|
|
594
|
+
const t = await e.getMany(s);
|
|
595
|
+
for (const e of t) {
|
|
596
|
+
if (e !== void 0 && e !== null) {
|
|
597
|
+
i.push(await this.deserializeData(e));
|
|
598
|
+
} else {
|
|
599
|
+
i.push(void 0);
|
|
600
|
+
}
|
|
601
|
+
}
|
|
602
|
+
}
|
|
603
|
+
const r = [];
|
|
604
|
+
const o = t => typeof t.expires === "number" && Date.now() > t.expires;
|
|
605
|
+
for (const [t, e] of i.entries()) {
|
|
606
|
+
if (e !== void 0 && o(e)) {
|
|
607
|
+
r.push(s[t]);
|
|
608
|
+
i[t] = void 0;
|
|
609
|
+
}
|
|
610
|
+
}
|
|
611
|
+
if (r.length > 0) {
|
|
612
|
+
await this.deleteMany(r);
|
|
613
|
+
}
|
|
614
|
+
this.stats.hitsOrMisses(i);
|
|
615
|
+
this.hooks.trigger("postGetManyRaw", {
|
|
616
|
+
keys: s,
|
|
617
|
+
values: i
|
|
618
|
+
});
|
|
619
|
+
return i;
|
|
620
|
+
}
|
|
621
|
+
async set(t, e, s) {
|
|
492
622
|
const i = {
|
|
493
|
-
key:
|
|
494
|
-
value:
|
|
623
|
+
key: t,
|
|
624
|
+
value: e,
|
|
495
625
|
ttl: s
|
|
496
626
|
};
|
|
497
627
|
this.hooks.trigger("preSet", i);
|
|
@@ -513,13 +643,16 @@ var f = class extends r {
|
|
|
513
643
|
const h = await this.serializeData(n);
|
|
514
644
|
let l = true;
|
|
515
645
|
try {
|
|
516
|
-
const
|
|
517
|
-
if (typeof
|
|
518
|
-
l =
|
|
646
|
+
const t = await o.set(r, h, i.ttl);
|
|
647
|
+
if (typeof t === "boolean") {
|
|
648
|
+
l = t;
|
|
519
649
|
}
|
|
520
|
-
} catch (
|
|
650
|
+
} catch (t) {
|
|
521
651
|
l = false;
|
|
522
|
-
this.emit("error",
|
|
652
|
+
this.emit("error", t);
|
|
653
|
+
if (this._throwOnErrors) {
|
|
654
|
+
throw t;
|
|
655
|
+
}
|
|
523
656
|
}
|
|
524
657
|
this.hooks.trigger("postSet", {
|
|
525
658
|
key: r,
|
|
@@ -529,63 +662,71 @@ var f = class extends r {
|
|
|
529
662
|
this.stats.set();
|
|
530
663
|
return l;
|
|
531
664
|
}
|
|
532
|
-
async setMany(
|
|
533
|
-
let
|
|
665
|
+
async setMany(t) {
|
|
666
|
+
let e = [];
|
|
534
667
|
try {
|
|
535
|
-
if (this._store.setMany
|
|
536
|
-
const s =
|
|
668
|
+
if (this._store.setMany === void 0) {
|
|
669
|
+
const s = [];
|
|
670
|
+
for (const e of t) {
|
|
671
|
+
s.push(this.set(e.key, e.value, e.ttl));
|
|
672
|
+
}
|
|
673
|
+
const i = await Promise.all(s);
|
|
674
|
+
e = i;
|
|
675
|
+
} else {
|
|
676
|
+
const s = await Promise.all(t.map((async ({key: t, value: e, ttl: s}) => {
|
|
537
677
|
s ??= this._ttl;
|
|
538
678
|
if (s === 0) {
|
|
539
679
|
s = void 0;
|
|
540
680
|
}
|
|
541
681
|
const i = typeof s === "number" ? Date.now() + s : void 0;
|
|
542
|
-
if (typeof
|
|
682
|
+
if (typeof e === "symbol") {
|
|
543
683
|
this.emit("error", "symbol cannot be serialized");
|
|
544
684
|
throw new Error("symbol cannot be serialized");
|
|
545
685
|
}
|
|
546
686
|
const r = {
|
|
547
|
-
value:
|
|
687
|
+
value: e,
|
|
548
688
|
expires: i
|
|
549
689
|
};
|
|
550
690
|
const o = await this.serializeData(r);
|
|
691
|
+
const a = this._getKeyPrefix(t);
|
|
551
692
|
return {
|
|
552
|
-
key:
|
|
693
|
+
key: a,
|
|
553
694
|
value: o,
|
|
554
695
|
ttl: s
|
|
555
696
|
};
|
|
556
697
|
})));
|
|
557
|
-
|
|
558
|
-
}
|
|
559
|
-
const s = [];
|
|
560
|
-
for (const t of e) {
|
|
561
|
-
s.push(this.set(t.key, t.value, t.ttl));
|
|
698
|
+
e = await this._store.setMany(s);
|
|
562
699
|
}
|
|
563
|
-
const i = await Promise.allSettled(s);
|
|
564
|
-
t = i.map((e => e.value));
|
|
565
700
|
} catch (s) {
|
|
566
701
|
this.emit("error", s);
|
|
567
|
-
|
|
702
|
+
if (this._throwOnErrors) {
|
|
703
|
+
throw s;
|
|
704
|
+
}
|
|
705
|
+
e = t.map((() => false));
|
|
568
706
|
}
|
|
569
|
-
return
|
|
707
|
+
return e;
|
|
570
708
|
}
|
|
571
|
-
async delete(
|
|
572
|
-
const {store:
|
|
573
|
-
if (Array.isArray(
|
|
574
|
-
return this.deleteMany(
|
|
709
|
+
async delete(t) {
|
|
710
|
+
const {store: e} = this.opts;
|
|
711
|
+
if (Array.isArray(t)) {
|
|
712
|
+
return this.deleteMany(t);
|
|
575
713
|
}
|
|
576
|
-
const s = this._getKeyPrefix(
|
|
714
|
+
const s = this._getKeyPrefix(t);
|
|
577
715
|
this.hooks.trigger("preDelete", {
|
|
578
716
|
key: s
|
|
579
717
|
});
|
|
580
718
|
let i = true;
|
|
581
719
|
try {
|
|
582
|
-
const
|
|
583
|
-
if (typeof
|
|
584
|
-
i =
|
|
720
|
+
const t = await e.delete(s);
|
|
721
|
+
if (typeof t === "boolean") {
|
|
722
|
+
i = t;
|
|
585
723
|
}
|
|
586
|
-
} catch (
|
|
724
|
+
} catch (t) {
|
|
587
725
|
i = false;
|
|
588
|
-
this.emit("error",
|
|
726
|
+
this.emit("error", t);
|
|
727
|
+
if (this._throwOnErrors) {
|
|
728
|
+
throw t;
|
|
729
|
+
}
|
|
589
730
|
}
|
|
590
731
|
this.hooks.trigger("postDelete", {
|
|
591
732
|
key: s,
|
|
@@ -594,69 +735,79 @@ var f = class extends r {
|
|
|
594
735
|
this.stats.delete();
|
|
595
736
|
return i;
|
|
596
737
|
}
|
|
597
|
-
async deleteMany(
|
|
738
|
+
async deleteMany(t) {
|
|
598
739
|
try {
|
|
599
|
-
const {store:
|
|
600
|
-
const s = this._getKeyPrefixArray(
|
|
740
|
+
const {store: e} = this.opts;
|
|
741
|
+
const s = this._getKeyPrefixArray(t);
|
|
601
742
|
this.hooks.trigger("preDelete", {
|
|
602
743
|
key: s
|
|
603
744
|
});
|
|
604
|
-
if (
|
|
605
|
-
return await
|
|
745
|
+
if (e.deleteMany !== void 0) {
|
|
746
|
+
return await e.deleteMany(s);
|
|
606
747
|
}
|
|
607
|
-
const i = s.map((async
|
|
608
|
-
const r = await Promise.
|
|
609
|
-
const o = r.every(
|
|
748
|
+
const i = s.map((async t => e.delete(t)));
|
|
749
|
+
const r = await Promise.all(i);
|
|
750
|
+
const o = r.every(Boolean);
|
|
610
751
|
this.hooks.trigger("postDelete", {
|
|
611
752
|
key: s,
|
|
612
753
|
value: o
|
|
613
754
|
});
|
|
614
755
|
return o;
|
|
615
|
-
} catch (
|
|
616
|
-
this.emit("error",
|
|
756
|
+
} catch (t) {
|
|
757
|
+
this.emit("error", t);
|
|
758
|
+
if (this._throwOnErrors) {
|
|
759
|
+
throw t;
|
|
760
|
+
}
|
|
617
761
|
return false;
|
|
618
762
|
}
|
|
619
763
|
}
|
|
620
764
|
async clear() {
|
|
621
765
|
this.emit("clear");
|
|
622
|
-
const {store:
|
|
766
|
+
const {store: t} = this.opts;
|
|
623
767
|
try {
|
|
624
|
-
await
|
|
625
|
-
} catch (
|
|
626
|
-
this.emit("error",
|
|
768
|
+
await t.clear();
|
|
769
|
+
} catch (t) {
|
|
770
|
+
this.emit("error", t);
|
|
771
|
+
if (this._throwOnErrors) {
|
|
772
|
+
throw t;
|
|
773
|
+
}
|
|
627
774
|
}
|
|
628
775
|
}
|
|
629
|
-
async has(
|
|
630
|
-
if (Array.isArray(
|
|
631
|
-
return this.hasMany(
|
|
776
|
+
async has(t) {
|
|
777
|
+
if (Array.isArray(t)) {
|
|
778
|
+
return this.hasMany(t);
|
|
632
779
|
}
|
|
633
|
-
const
|
|
780
|
+
const e = this._getKeyPrefix(t);
|
|
634
781
|
const {store: s} = this.opts;
|
|
635
782
|
if (s.has !== void 0 && !(s instanceof Map)) {
|
|
636
|
-
return s.has(
|
|
783
|
+
return s.has(e);
|
|
637
784
|
}
|
|
638
785
|
let i;
|
|
639
786
|
try {
|
|
640
|
-
i = await s.get(
|
|
641
|
-
} catch (
|
|
642
|
-
this.emit("error",
|
|
787
|
+
i = await s.get(e);
|
|
788
|
+
} catch (t) {
|
|
789
|
+
this.emit("error", t);
|
|
790
|
+
if (this._throwOnErrors) {
|
|
791
|
+
throw t;
|
|
792
|
+
}
|
|
793
|
+
return false;
|
|
643
794
|
}
|
|
644
795
|
if (i) {
|
|
645
|
-
const
|
|
646
|
-
if (
|
|
647
|
-
if (
|
|
796
|
+
const t = await this.deserializeData(i);
|
|
797
|
+
if (t) {
|
|
798
|
+
if (t.expires === void 0 || t.expires === null) {
|
|
648
799
|
return true;
|
|
649
800
|
}
|
|
650
|
-
return
|
|
801
|
+
return t.expires > Date.now();
|
|
651
802
|
}
|
|
652
803
|
}
|
|
653
804
|
return false;
|
|
654
805
|
}
|
|
655
|
-
async hasMany(
|
|
656
|
-
const
|
|
806
|
+
async hasMany(t) {
|
|
807
|
+
const e = this._getKeyPrefixArray(t);
|
|
657
808
|
const {store: s} = this.opts;
|
|
658
809
|
if (s.hasMany !== void 0) {
|
|
659
|
-
return s.hasMany(
|
|
810
|
+
return s.hasMany(e);
|
|
660
811
|
}
|
|
661
812
|
const i = [];
|
|
662
813
|
for (const e of t) {
|
|
@@ -665,52 +816,52 @@ var f = class extends r {
|
|
|
665
816
|
return i;
|
|
666
817
|
}
|
|
667
818
|
async disconnect() {
|
|
668
|
-
const {store:
|
|
819
|
+
const {store: t} = this.opts;
|
|
669
820
|
this.emit("disconnect");
|
|
670
|
-
if (typeof
|
|
671
|
-
return
|
|
821
|
+
if (typeof t.disconnect === "function") {
|
|
822
|
+
return t.disconnect();
|
|
672
823
|
}
|
|
673
824
|
}
|
|
674
|
-
emit(
|
|
675
|
-
if (
|
|
825
|
+
emit(t, ...e) {
|
|
826
|
+
if (t === "error" && !this.opts.emitErrors) {
|
|
676
827
|
return;
|
|
677
828
|
}
|
|
678
|
-
super.emit(
|
|
829
|
+
super.emit(t, ...e);
|
|
679
830
|
}
|
|
680
|
-
async serializeData(
|
|
831
|
+
async serializeData(t) {
|
|
681
832
|
if (!this._serialize) {
|
|
682
|
-
return
|
|
833
|
+
return t;
|
|
683
834
|
}
|
|
684
835
|
if (this._compression?.compress) {
|
|
685
836
|
return this._serialize({
|
|
686
|
-
value: await this._compression.compress(
|
|
687
|
-
expires:
|
|
837
|
+
value: await this._compression.compress(t.value),
|
|
838
|
+
expires: t.expires
|
|
688
839
|
});
|
|
689
840
|
}
|
|
690
|
-
return this._serialize(
|
|
841
|
+
return this._serialize(t);
|
|
691
842
|
}
|
|
692
|
-
async deserializeData(
|
|
843
|
+
async deserializeData(t) {
|
|
693
844
|
if (!this._deserialize) {
|
|
694
|
-
return
|
|
845
|
+
return t;
|
|
695
846
|
}
|
|
696
|
-
if (this._compression?.decompress && typeof
|
|
697
|
-
const
|
|
847
|
+
if (this._compression?.decompress && typeof t === "string") {
|
|
848
|
+
const e = await this._deserialize(t);
|
|
698
849
|
return {
|
|
699
|
-
value: await this._compression.decompress(
|
|
700
|
-
expires:
|
|
850
|
+
value: await this._compression.decompress(e?.value),
|
|
851
|
+
expires: e?.expires
|
|
701
852
|
};
|
|
702
853
|
}
|
|
703
|
-
if (typeof
|
|
704
|
-
return this._deserialize(
|
|
854
|
+
if (typeof t === "string") {
|
|
855
|
+
return this._deserialize(t);
|
|
705
856
|
}
|
|
706
857
|
return void 0;
|
|
707
858
|
}
|
|
708
859
|
};
|
|
709
860
|
|
|
710
|
-
var
|
|
861
|
+
var u = p;
|
|
711
862
|
|
|
712
|
-
exports.Keyv =
|
|
863
|
+
exports.Keyv = p;
|
|
713
864
|
|
|
714
|
-
exports.defaultDeserialize =
|
|
865
|
+
exports.defaultDeserialize = i;
|
|
715
866
|
|
|
716
|
-
exports.index_default =
|
|
867
|
+
exports.index_default = u;
|