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