lakutata 2.0.34 → 2.0.36
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 +229 -0
- package/com/cacher.d.ts +514 -0
- package/com/cacher.mjs +203 -0
- package/com/database.cjs +11 -5
- package/com/database.mjs +11 -5
- package/com/docker.cjs +26 -18
- package/com/docker.mjs +22 -14
- package/com/entrypoint.cjs +4 -2
- package/com/entrypoint.mjs +4 -2
- package/com/logger.cjs +9 -3
- package/com/logger.mjs +9 -3
- package/decorator/ctrl.cjs +4 -2
- package/decorator/ctrl.mjs +4 -2
- package/decorator/di.cjs +3 -1
- package/decorator/di.mjs +3 -1
- package/decorator/dto.cjs +3 -1
- package/decorator/dto.mjs +3 -1
- package/decorator/orm.cjs +27 -21
- package/decorator/orm.mjs +11 -5
- package/helper.cjs +17 -15
- package/helper.mjs +4 -2
- package/lakutata.cjs +14 -8
- package/lakutata.mjs +10 -4
- package/orm.cjs +25 -19
- package/orm.mjs +22 -16
- package/package.json +6 -1
- package/provider/database.cjs +11 -5
- package/provider/database.mjs +11 -5
- package/provider/passwordHash.cjs +3 -1
- package/provider/passwordHash.mjs +3 -1
- package/src/components/Database.cjs +11 -5
- package/src/components/Database.mjs +11 -5
- package/src/components/Logger.cjs +9 -3
- package/src/components/Logger.mjs +9 -3
- package/src/components/cacher/Cacher.cjs +734 -0
- package/src/components/cacher/Cacher.mjs +720 -0
- package/src/components/cacher/adapters/CreateFileCacheAdapter.cjs +3094 -0
- package/src/components/cacher/adapters/CreateFileCacheAdapter.mjs +3066 -0
- package/src/components/cacher/adapters/CreateMemcacheCacheAdapter.cjs +33 -0
- package/src/components/cacher/adapters/CreateMemcacheCacheAdapter.mjs +35 -0
- package/src/components/cacher/adapters/CreateMongoCacheAdapter.cjs +38 -0
- package/src/components/cacher/adapters/CreateMongoCacheAdapter.mjs +40 -0
- package/src/components/cacher/adapters/CreateMysqlCacheAdapter.cjs +31 -0
- package/src/components/cacher/adapters/CreateMysqlCacheAdapter.mjs +33 -0
- package/src/components/cacher/adapters/CreatePostgresCacheAdapter.cjs +40 -0
- package/src/components/cacher/adapters/CreatePostgresCacheAdapter.mjs +42 -0
- package/src/components/cacher/adapters/CreateRedisCacheAdapter.cjs +43 -0
- package/src/components/cacher/adapters/CreateRedisCacheAdapter.mjs +45 -0
- package/src/components/cacher/adapters/CreateSqliteCacheAdapter.cjs +35 -0
- package/src/components/cacher/adapters/CreateSqliteCacheAdapter.mjs +37 -0
- package/src/components/cacher/options/CacherOptions.cjs +95 -0
- package/src/components/cacher/options/CacherOptions.mjs +89 -0
- package/src/components/cacher/options/FileCacheOptions.cjs +79 -0
- package/src/components/cacher/options/FileCacheOptions.mjs +73 -0
- package/src/components/cacher/options/MemcacheCacheOptions.cjs +81 -0
- package/src/components/cacher/options/MemcacheCacheOptions.mjs +75 -0
- package/src/components/cacher/options/MongoCacheOptions.cjs +85 -0
- package/src/components/cacher/options/MongoCacheOptions.mjs +79 -0
- package/src/components/cacher/options/MysqlCacheOptions.cjs +85 -0
- package/src/components/cacher/options/MysqlCacheOptions.mjs +79 -0
- package/src/components/cacher/options/PostgresCacheOptions.cjs +89 -0
- package/src/components/cacher/options/PostgresCacheOptions.mjs +83 -0
- package/src/components/cacher/options/RedisCacheOptions.cjs +101 -0
- package/src/components/cacher/options/RedisCacheOptions.mjs +95 -0
- package/src/components/cacher/options/SqliteCacheOptions.cjs +79 -0
- package/src/components/cacher/options/SqliteCacheOptions.mjs +73 -0
- package/src/components/cacher/types/CacheStoreOptions.cjs +1 -0
- package/src/components/cacher/types/CacheStoreOptions.mjs +1 -0
- package/src/components/docker/ConnectionOptionsBuilder.cjs +22 -14
- package/src/components/docker/ConnectionOptionsBuilder.mjs +22 -14
- package/src/components/docker/Docker.cjs +22 -14
- package/src/components/docker/Docker.mjs +22 -14
- package/src/components/docker/lib/DockerContainer.cjs +34 -26
- package/src/components/docker/lib/DockerContainer.mjs +26 -18
- package/src/components/docker/lib/DockerContainerTTY.cjs +18 -10
- package/src/components/docker/lib/DockerContainerTTY.mjs +18 -10
- package/src/components/docker/lib/DockerImage.cjs +11 -9
- package/src/components/docker/lib/DockerImage.mjs +3 -1
- package/src/components/docker/options/DockerPruneOptions.cjs +3 -1
- package/src/components/docker/options/DockerPruneOptions.mjs +3 -1
- package/src/components/docker/options/auth/DockerAuthOptions.cjs +3 -1
- package/src/components/docker/options/auth/DockerAuthOptions.mjs +3 -1
- package/src/components/docker/options/container/ContainerCommitOptions.cjs +3 -1
- package/src/components/docker/options/container/ContainerCommitOptions.mjs +3 -1
- package/src/components/docker/options/container/ContainerCreateTTYOptions.cjs +3 -1
- package/src/components/docker/options/container/ContainerCreateTTYOptions.mjs +3 -1
- package/src/components/docker/options/container/ContainerExecOptions.cjs +3 -1
- package/src/components/docker/options/container/ContainerExecOptions.mjs +5 -3
- package/src/components/docker/options/container/ContainerExportDirectoryOptions.cjs +3 -1
- package/src/components/docker/options/container/ContainerExportDirectoryOptions.mjs +3 -1
- package/src/components/docker/options/container/ContainerKillOptions.cjs +3 -1
- package/src/components/docker/options/container/ContainerKillOptions.mjs +3 -1
- package/src/components/docker/options/container/ContainerLogsOptions.cjs +3 -1
- package/src/components/docker/options/container/ContainerLogsOptions.mjs +3 -1
- package/src/components/docker/options/container/ContainerRemoveOptions.cjs +3 -1
- package/src/components/docker/options/container/ContainerRemoveOptions.mjs +3 -1
- package/src/components/docker/options/container/ContainerSettingOptions.cjs +3 -1
- package/src/components/docker/options/container/ContainerSettingOptions.mjs +3 -1
- package/src/components/docker/options/container/ContainerStopOptions.cjs +3 -1
- package/src/components/docker/options/container/ContainerStopOptions.mjs +3 -1
- package/src/components/docker/options/container/ContainerTTYConsoleSizeOptions.cjs +3 -1
- package/src/components/docker/options/container/ContainerTTYConsoleSizeOptions.mjs +3 -1
- package/src/components/docker/options/image/ImageBuildOptions.cjs +3 -1
- package/src/components/docker/options/image/ImageBuildOptions.mjs +5 -3
- package/src/components/docker/options/image/ImageExportOptions.cjs +3 -1
- package/src/components/docker/options/image/ImageExportOptions.mjs +3 -1
- package/src/components/docker/options/image/ImageImportOptions.cjs +3 -1
- package/src/components/docker/options/image/ImageImportOptions.mjs +3 -1
- package/src/components/docker/options/image/ImagePullOptions.cjs +3 -1
- package/src/components/docker/options/image/ImagePullOptions.mjs +3 -1
- package/src/components/docker/options/image/ImagePushOptions.cjs +3 -1
- package/src/components/docker/options/image/ImagePushOptions.mjs +3 -1
- package/src/components/docker/options/image/ImageRemoveOptions.cjs +3 -1
- package/src/components/docker/options/image/ImageRemoveOptions.mjs +3 -1
- package/src/components/docker/options/image/ImageTagOptions.cjs +3 -1
- package/src/components/docker/options/image/ImageTagOptions.mjs +3 -1
- package/src/components/docker/options/network/NetworkCreateOptions.cjs +3 -1
- package/src/components/docker/options/network/NetworkCreateOptions.mjs +3 -1
- package/src/components/entrypoint/Entrypoint.cjs +4 -2
- package/src/components/entrypoint/Entrypoint.mjs +49 -47
- package/src/components/entrypoint/lib/Controller.cjs +3 -1
- package/src/components/entrypoint/lib/Controller.mjs +3 -1
- package/src/decorators/ctrl/CLIAction.cjs +6 -4
- package/src/decorators/ctrl/CLIAction.mjs +4 -2
- package/src/decorators/ctrl/HTTPAction.cjs +4 -2
- package/src/decorators/ctrl/HTTPAction.mjs +9 -7
- package/src/decorators/ctrl/ServiceAction.cjs +8 -6
- package/src/decorators/ctrl/ServiceAction.mjs +4 -2
- package/src/decorators/ctrl/http/DELETE.cjs +4 -2
- package/src/decorators/ctrl/http/DELETE.mjs +4 -2
- package/src/decorators/ctrl/http/GET.cjs +4 -2
- package/src/decorators/ctrl/http/GET.mjs +4 -2
- package/src/decorators/ctrl/http/HEAD.cjs +4 -2
- package/src/decorators/ctrl/http/HEAD.mjs +4 -2
- package/src/decorators/ctrl/http/OPTIONS.cjs +4 -2
- package/src/decorators/ctrl/http/OPTIONS.mjs +4 -2
- package/src/decorators/ctrl/http/PATCH.cjs +4 -2
- package/src/decorators/ctrl/http/PATCH.mjs +4 -2
- package/src/decorators/ctrl/http/POST.cjs +4 -2
- package/src/decorators/ctrl/http/POST.mjs +4 -2
- package/src/decorators/ctrl/http/PUT.cjs +4 -2
- package/src/decorators/ctrl/http/PUT.mjs +4 -2
- package/src/decorators/di/Configurable.cjs +3 -1
- package/src/decorators/di/Configurable.mjs +3 -1
- package/src/decorators/di/Inject.cjs +11 -9
- package/src/decorators/di/Inject.mjs +10 -8
- package/src/decorators/dto/Accept.cjs +3 -1
- package/src/decorators/dto/Accept.mjs +3 -1
- package/src/decorators/dto/Expect.cjs +3 -1
- package/src/decorators/dto/Expect.mjs +3 -1
- package/src/decorators/dto/IndexSignature.cjs +3 -1
- package/src/decorators/dto/IndexSignature.mjs +3 -1
- package/src/decorators/dto/Return.cjs +3 -1
- package/src/decorators/dto/Return.mjs +3 -1
- package/src/decorators/orm/AfterInsert.cjs +11 -5
- package/src/decorators/orm/AfterInsert.mjs +17 -11
- package/src/decorators/orm/AfterLoad.cjs +15 -9
- package/src/decorators/orm/AfterLoad.mjs +20 -14
- package/src/decorators/orm/AfterRecover.cjs +15 -9
- package/src/decorators/orm/AfterRecover.mjs +16 -10
- package/src/decorators/orm/AfterRemove.cjs +15 -9
- package/src/decorators/orm/AfterRemove.mjs +16 -10
- package/src/decorators/orm/AfterSoftRemove.cjs +11 -5
- package/src/decorators/orm/AfterSoftRemove.mjs +16 -10
- package/src/decorators/orm/AfterUpdate.cjs +11 -5
- package/src/decorators/orm/AfterUpdate.mjs +18 -12
- package/src/decorators/orm/BeforeInsert.cjs +17 -11
- package/src/decorators/orm/BeforeInsert.mjs +15 -9
- package/src/decorators/orm/BeforeRecover.cjs +18 -12
- package/src/decorators/orm/BeforeRecover.mjs +13 -7
- package/src/decorators/orm/BeforeRemove.cjs +18 -12
- package/src/decorators/orm/BeforeRemove.mjs +13 -7
- package/src/decorators/orm/BeforeSoftRemove.cjs +17 -11
- package/src/decorators/orm/BeforeSoftRemove.mjs +13 -7
- package/src/decorators/orm/BeforeUpdate.cjs +15 -9
- package/src/decorators/orm/BeforeUpdate.mjs +16 -10
- package/src/decorators/orm/Check.cjs +11 -5
- package/src/decorators/orm/Check.mjs +11 -5
- package/src/decorators/orm/ChildEntity.cjs +16 -10
- package/src/decorators/orm/ChildEntity.mjs +13 -7
- package/src/decorators/orm/Column.cjs +28 -22
- package/src/decorators/orm/Column.mjs +11 -5
- package/src/decorators/orm/CreateDateColumn.cjs +13 -7
- package/src/decorators/orm/CreateDateColumn.mjs +11 -5
- package/src/decorators/orm/DeleteDateColumn.cjs +13 -7
- package/src/decorators/orm/DeleteDateColumn.mjs +11 -5
- package/src/decorators/orm/Entity.cjs +15 -9
- package/src/decorators/orm/Entity.mjs +17 -11
- package/src/decorators/orm/EventSubscriber.cjs +11 -5
- package/src/decorators/orm/EventSubscriber.mjs +11 -5
- package/src/decorators/orm/Exclusion.cjs +11 -5
- package/src/decorators/orm/Exclusion.mjs +17 -11
- package/src/decorators/orm/Generated.cjs +13 -7
- package/src/decorators/orm/Generated.mjs +17 -11
- package/src/decorators/orm/Index.cjs +19 -13
- package/src/decorators/orm/Index.mjs +29 -23
- package/src/decorators/orm/JoinColumn.cjs +15 -9
- package/src/decorators/orm/JoinColumn.mjs +11 -5
- package/src/decorators/orm/JoinTable.cjs +11 -5
- package/src/decorators/orm/JoinTable.mjs +15 -9
- package/src/decorators/orm/ManyToMany.cjs +18 -12
- package/src/decorators/orm/ManyToMany.mjs +22 -16
- package/src/decorators/orm/ManyToOne.cjs +21 -15
- package/src/decorators/orm/ManyToOne.mjs +22 -16
- package/src/decorators/orm/ObjectIdColumn.cjs +11 -5
- package/src/decorators/orm/ObjectIdColumn.mjs +17 -11
- package/src/decorators/orm/OneToMany.cjs +19 -13
- package/src/decorators/orm/OneToMany.mjs +11 -5
- package/src/decorators/orm/OneToOne.cjs +20 -14
- package/src/decorators/orm/OneToOne.mjs +18 -12
- package/src/decorators/orm/PrimaryColumn.cjs +15 -9
- package/src/decorators/orm/PrimaryColumn.mjs +30 -24
- package/src/decorators/orm/PrimaryGeneratedColumn.cjs +11 -5
- package/src/decorators/orm/PrimaryGeneratedColumn.mjs +13 -7
- package/src/decorators/orm/RelationId.cjs +16 -10
- package/src/decorators/orm/RelationId.mjs +17 -11
- package/src/decorators/orm/TableInheritance.cjs +13 -7
- package/src/decorators/orm/TableInheritance.mjs +15 -9
- package/src/decorators/orm/Tree.cjs +11 -5
- package/src/decorators/orm/Tree.mjs +11 -5
- package/src/decorators/orm/TreeChildren.cjs +11 -5
- package/src/decorators/orm/TreeChildren.mjs +22 -16
- package/src/decorators/orm/TreeLevelColumn.cjs +11 -5
- package/src/decorators/orm/TreeLevelColumn.mjs +11 -5
- package/src/decorators/orm/TreeParent.cjs +17 -11
- package/src/decorators/orm/TreeParent.mjs +11 -5
- package/src/decorators/orm/Unique.cjs +18 -12
- package/src/decorators/orm/Unique.mjs +11 -5
- package/src/decorators/orm/UpdateDateColumn.cjs +13 -7
- package/src/decorators/orm/UpdateDateColumn.mjs +17 -11
- package/src/decorators/orm/VersionColumn.cjs +11 -5
- package/src/decorators/orm/VersionColumn.mjs +11 -5
- package/src/decorators/orm/ViewColumn.cjs +11 -5
- package/src/decorators/orm/ViewColumn.mjs +11 -5
- package/src/decorators/orm/ViewEntity.cjs +13 -7
- package/src/decorators/orm/ViewEntity.mjs +11 -5
- package/src/decorators/orm/VirtualColumn.cjs +11 -5
- package/src/decorators/orm/VirtualColumn.mjs +15 -9
- package/src/lib/base/BaseObject.cjs +3 -1
- package/src/lib/base/BaseObject.mjs +3 -1
- package/src/lib/base/Context.cjs +3 -1
- package/src/lib/base/Context.mjs +3 -1
- package/src/lib/base/internal/ApplicationConfigLoader.cjs +3 -1
- package/src/lib/base/internal/ApplicationConfigLoader.mjs +3 -1
- package/src/lib/base/internal/ControllerEntrypoint.cjs +1 -1
- package/src/lib/base/internal/ControllerEntrypoint.mjs +1 -1
- package/src/lib/base/internal/DataValidator.cjs +16 -14
- package/src/lib/base/internal/DataValidator.mjs +3 -1
- package/src/lib/base/internal/FlexibleDTO.cjs +3 -1
- package/src/lib/base/internal/FlexibleDTO.mjs +3 -1
- package/src/lib/base/internal/MethodValidation.cjs +18 -16
- package/src/lib/base/internal/MethodValidation.mjs +3 -1
- package/src/lib/base/internal/ModuleConfigLoader.cjs +3 -1
- package/src/lib/base/internal/ModuleConfigLoader.mjs +24 -22
- package/src/lib/base/internal/ObjectConfiguration.cjs +3 -1
- package/src/lib/base/internal/ObjectConfiguration.mjs +3 -1
- package/src/lib/base/internal/ObjectSchemaValidation.cjs +3 -1
- package/src/lib/base/internal/ObjectSchemaValidation.mjs +3 -1
- package/src/lib/base/internal/ObjectType.cjs +3 -1
- package/src/lib/base/internal/ObjectType.mjs +3 -1
- package/src/lib/context/CLIContext.cjs +3 -1
- package/src/lib/context/CLIContext.mjs +3 -1
- package/src/lib/context/HTTPContext.cjs +3 -1
- package/src/lib/context/HTTPContext.mjs +3 -1
- package/src/lib/context/ServiceContext.cjs +3 -1
- package/src/lib/context/ServiceContext.mjs +3 -1
- package/src/lib/core/Application.cjs +19 -13
- package/src/lib/core/Application.mjs +15 -9
- package/src/lib/core/Component.cjs +3 -1
- package/src/lib/core/Component.mjs +3 -1
- package/src/lib/core/Container.cjs +2 -0
- package/src/lib/core/Container.mjs +2 -0
- package/src/lib/core/DTO.cjs +3 -1
- package/src/lib/core/DTO.mjs +3 -1
- package/src/lib/core/Module.cjs +4 -2
- package/src/lib/core/Module.mjs +4 -2
- package/src/lib/core/Provider.cjs +3 -1
- package/src/lib/core/Provider.mjs +3 -1
- package/src/lib/helpers/IsSymbol.cjs +3 -1
- package/src/lib/helpers/IsSymbol.mjs +3 -1
- package/src/lib/helpers/NonceStr.cjs +1 -1
- package/src/lib/helpers/NonceStr.mjs +1 -1
- package/src/lib/helpers/ObjectHash.cjs +1 -1
- package/src/lib/helpers/ObjectHash.mjs +1 -1
- package/src/lib/helpers/RandomString.cjs +1 -1
- package/src/lib/helpers/RandomString.mjs +1 -1
- package/src/lib/ioc/DependencyInjectionContainer.cjs +3 -1
- package/src/lib/ioc/DependencyInjectionContainer.mjs +13 -11
- package/src/lib/ioc/Errors.cjs +3 -1
- package/src/lib/ioc/Errors.mjs +3 -1
- package/src/lib/ioc/ListModules.cjs +104 -102
- package/src/lib/ioc/ListModules.mjs +4 -2
- package/src/lib/ioc/LoadModules.cjs +2 -0
- package/src/lib/ioc/LoadModules.mjs +2 -0
- package/src/lib/ioc/Resolvers.cjs +9 -7
- package/src/lib/ioc/Resolvers.mjs +3 -1
- package/src/lib/ioc/Utils.cjs +3 -1
- package/src/lib/ioc/Utils.mjs +3 -1
- package/src/lib/validation/VLD.cjs +3 -1
- package/src/lib/validation/VLD.mjs +3 -1
- package/src/options/ApplicationOptions.cjs +3 -1
- package/src/options/ApplicationOptions.mjs +3 -1
- package/src/options/LoadAnonymousObjectOptions.cjs +3 -1
- package/src/options/LoadAnonymousObjectOptions.mjs +3 -1
- package/src/options/LoadNamedObjectOptions.cjs +3 -1
- package/src/options/LoadNamedObjectOptions.mjs +3 -1
- package/src/options/LoadObjectOptions.cjs +3 -1
- package/src/options/LoadObjectOptions.mjs +3 -1
- package/src/options/ModuleLoadObjectsOptions.cjs +3 -1
- package/src/options/ModuleLoadObjectsOptions.mjs +3 -1
- package/src/options/ModuleOptions.cjs +3 -1
- package/src/options/ModuleOptions.mjs +3 -1
- package/src/options/OverridableNamedObjectOptions.cjs +3 -1
- package/src/options/OverridableNamedObjectOptions.mjs +3 -1
- package/src/options/OverridableObjectOptions.cjs +3 -1
- package/src/options/OverridableObjectOptions.mjs +3 -1
- package/src/providers/Database.cjs +11 -5
- package/src/providers/Database.mjs +11 -5
- package/src/providers/PasswordHash.cjs +17 -15
- package/src/providers/PasswordHash.mjs +212 -210
- package/vendor/Package.10.cjs +0 -2
- package/vendor/Package.10.mjs +0 -2
- package/vendor/Package.11.cjs +1 -9
- package/vendor/Package.11.mjs +1 -9
- package/vendor/Package.12.cjs +5 -79
- package/vendor/Package.12.mjs +5 -73
- package/vendor/{Package.112.cjs → Package.122.cjs} +5501 -5501
- package/vendor/{Package.112.mjs → Package.122.mjs} +5507 -5507
- package/vendor/Package.13.cjs +7 -1
- package/vendor/Package.13.mjs +7 -1
- package/vendor/Package.132.cjs +87 -0
- package/vendor/Package.132.mjs +79 -0
- package/vendor/Package.14.cjs +1 -14055
- package/vendor/Package.14.mjs +1 -14029
- package/vendor/Package.15.cjs +1 -48245
- package/vendor/Package.15.mjs +1 -48209
- package/vendor/Package.16.cjs +14063 -0
- package/vendor/Package.16.mjs +14035 -0
- package/vendor/Package.17.cjs +3 -0
- package/vendor/Package.17.mjs +1 -0
- package/vendor/Package.18.cjs +48255 -0
- package/vendor/Package.18.mjs +48215 -0
- package/vendor/Package.19.cjs +3 -0
- package/vendor/Package.19.mjs +1 -0
- package/vendor/Package.610.cjs +175 -0
- package/vendor/Package.610.mjs +157 -0
- package/vendor/Package.611.cjs +196 -0
- package/vendor/Package.611.mjs +180 -0
- package/vendor/Package.62.cjs +1 -1
- package/vendor/Package.62.mjs +1 -1
- package/vendor/Package.65.cjs +716 -0
- package/vendor/Package.65.mjs +710 -0
- package/vendor/Package.66.cjs +680 -0
- package/vendor/Package.66.mjs +652 -0
- package/vendor/Package.67.cjs +143 -0
- package/vendor/Package.67.mjs +127 -0
- package/vendor/Package.68.cjs +341 -0
- package/vendor/Package.68.mjs +327 -0
- package/vendor/Package.69.cjs +157 -0
- package/vendor/Package.69.mjs +139 -0
|
@@ -0,0 +1,716 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const e = require("buffer");
|
|
4
|
+
|
|
5
|
+
var t = s => {
|
|
6
|
+
if (s === void 0 || s === null) {
|
|
7
|
+
return "null";
|
|
8
|
+
}
|
|
9
|
+
if (typeof s === "string") {
|
|
10
|
+
return JSON.stringify(s.startsWith(":") ? ":" + s : s);
|
|
11
|
+
}
|
|
12
|
+
if (e.Buffer.isBuffer(s)) {
|
|
13
|
+
return JSON.stringify(":base64:" + s.toString("base64"));
|
|
14
|
+
}
|
|
15
|
+
if (s?.toJSON) {
|
|
16
|
+
s = s.toJSON();
|
|
17
|
+
}
|
|
18
|
+
if (typeof s === "object") {
|
|
19
|
+
let e = "";
|
|
20
|
+
const i = Array.isArray(s);
|
|
21
|
+
e = i ? "[" : "{";
|
|
22
|
+
let r = true;
|
|
23
|
+
for (const o in s) {
|
|
24
|
+
const a = typeof s[o] === "function" || !i && s[o] === void 0;
|
|
25
|
+
if (!Object.hasOwn(s, o) || a) {
|
|
26
|
+
continue;
|
|
27
|
+
}
|
|
28
|
+
if (!r) {
|
|
29
|
+
e += ",";
|
|
30
|
+
}
|
|
31
|
+
r = false;
|
|
32
|
+
if (i) {
|
|
33
|
+
e += t(s[o]);
|
|
34
|
+
} else if (s[o] !== void 0) {
|
|
35
|
+
e += t(o) + ":" + t(s[o]);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
e += i ? "]" : "}";
|
|
39
|
+
return e;
|
|
40
|
+
}
|
|
41
|
+
return JSON.stringify(s);
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
var s = t => JSON.parse(t, ((t, s) => {
|
|
45
|
+
if (typeof s === "string") {
|
|
46
|
+
if (s.startsWith(":base64:")) {
|
|
47
|
+
return e.Buffer.from(s.slice(8), "base64");
|
|
48
|
+
}
|
|
49
|
+
return s.startsWith(":") ? s.slice(1) : s;
|
|
50
|
+
}
|
|
51
|
+
return s;
|
|
52
|
+
}));
|
|
53
|
+
|
|
54
|
+
var i = class {
|
|
55
|
+
_eventListeners;
|
|
56
|
+
_maxListeners;
|
|
57
|
+
constructor() {
|
|
58
|
+
this._eventListeners = new Map;
|
|
59
|
+
this._maxListeners = 100;
|
|
60
|
+
}
|
|
61
|
+
maxListeners() {
|
|
62
|
+
return this._maxListeners;
|
|
63
|
+
}
|
|
64
|
+
addListener(e, t) {
|
|
65
|
+
this.on(e, t);
|
|
66
|
+
}
|
|
67
|
+
on(e, t) {
|
|
68
|
+
if (!this._eventListeners.has(e)) {
|
|
69
|
+
this._eventListeners.set(e, []);
|
|
70
|
+
}
|
|
71
|
+
const s = this._eventListeners.get(e);
|
|
72
|
+
if (s) {
|
|
73
|
+
if (s.length >= this._maxListeners) {
|
|
74
|
+
console.warn(`MaxListenersExceededWarning: Possible event memory leak detected. ${s.length + 1} ${e} listeners added. Use setMaxListeners() to increase limit.`);
|
|
75
|
+
}
|
|
76
|
+
s.push(t);
|
|
77
|
+
}
|
|
78
|
+
return this;
|
|
79
|
+
}
|
|
80
|
+
removeListener(e, t) {
|
|
81
|
+
this.off(e, t);
|
|
82
|
+
}
|
|
83
|
+
off(e, t) {
|
|
84
|
+
const s = this._eventListeners.get(e) ?? [];
|
|
85
|
+
const i = s.indexOf(t);
|
|
86
|
+
if (i !== -1) {
|
|
87
|
+
s.splice(i, 1);
|
|
88
|
+
}
|
|
89
|
+
if (s.length === 0) {
|
|
90
|
+
this._eventListeners.delete(e);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
once(e, t) {
|
|
94
|
+
const s = (...i) => {
|
|
95
|
+
t(...i);
|
|
96
|
+
this.off(e, s);
|
|
97
|
+
};
|
|
98
|
+
this.on(e, s);
|
|
99
|
+
}
|
|
100
|
+
emit(e, ...t) {
|
|
101
|
+
const s = this._eventListeners.get(e);
|
|
102
|
+
if (s && s.length > 0) {
|
|
103
|
+
for (const e of s) {
|
|
104
|
+
e(...t);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
listeners(e) {
|
|
109
|
+
return this._eventListeners.get(e) ?? [];
|
|
110
|
+
}
|
|
111
|
+
removeAllListeners(e) {
|
|
112
|
+
if (e) {
|
|
113
|
+
this._eventListeners.delete(e);
|
|
114
|
+
} else {
|
|
115
|
+
this._eventListeners.clear();
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
setMaxListeners(e) {
|
|
119
|
+
this._maxListeners = e;
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
var r = i;
|
|
124
|
+
|
|
125
|
+
var o = class extends r {
|
|
126
|
+
_hookHandlers;
|
|
127
|
+
constructor() {
|
|
128
|
+
super();
|
|
129
|
+
this._hookHandlers = new Map;
|
|
130
|
+
}
|
|
131
|
+
addHandler(e, t) {
|
|
132
|
+
const s = this._hookHandlers.get(e);
|
|
133
|
+
if (s) {
|
|
134
|
+
s.push(t);
|
|
135
|
+
} else {
|
|
136
|
+
this._hookHandlers.set(e, [ t ]);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
removeHandler(e, t) {
|
|
140
|
+
const s = this._hookHandlers.get(e);
|
|
141
|
+
if (s) {
|
|
142
|
+
const e = s.indexOf(t);
|
|
143
|
+
if (e !== -1) {
|
|
144
|
+
s.splice(e, 1);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
trigger(e, t) {
|
|
149
|
+
const s = this._hookHandlers.get(e);
|
|
150
|
+
if (s) {
|
|
151
|
+
for (const i of s) {
|
|
152
|
+
try {
|
|
153
|
+
i(t);
|
|
154
|
+
} catch (t) {
|
|
155
|
+
this.emit("error", new Error(`Error in hook handler for event "${e}": ${t.message}`));
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
get handlers() {
|
|
161
|
+
return new Map(this._hookHandlers);
|
|
162
|
+
}
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
var a = o;
|
|
166
|
+
|
|
167
|
+
var n = class extends r {
|
|
168
|
+
enabled=true;
|
|
169
|
+
hits=0;
|
|
170
|
+
misses=0;
|
|
171
|
+
sets=0;
|
|
172
|
+
deletes=0;
|
|
173
|
+
errors=0;
|
|
174
|
+
constructor(e) {
|
|
175
|
+
super();
|
|
176
|
+
if (e !== void 0) {
|
|
177
|
+
this.enabled = e;
|
|
178
|
+
}
|
|
179
|
+
this.reset();
|
|
180
|
+
}
|
|
181
|
+
hit() {
|
|
182
|
+
if (this.enabled) {
|
|
183
|
+
this.hits++;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
miss() {
|
|
187
|
+
if (this.enabled) {
|
|
188
|
+
this.misses++;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
set() {
|
|
192
|
+
if (this.enabled) {
|
|
193
|
+
this.sets++;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
delete() {
|
|
197
|
+
if (this.enabled) {
|
|
198
|
+
this.deletes++;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
reset() {
|
|
202
|
+
this.hits = 0;
|
|
203
|
+
this.misses = 0;
|
|
204
|
+
this.sets = 0;
|
|
205
|
+
this.deletes = 0;
|
|
206
|
+
this.errors = 0;
|
|
207
|
+
}
|
|
208
|
+
};
|
|
209
|
+
|
|
210
|
+
var h = n;
|
|
211
|
+
|
|
212
|
+
var l = (e => {
|
|
213
|
+
e["PRE_SET"] = "preSet";
|
|
214
|
+
e["POST_SET"] = "postSet";
|
|
215
|
+
e["PRE_GET"] = "preGet";
|
|
216
|
+
e["POST_GET"] = "postGet";
|
|
217
|
+
e["PRE_GET_MANY"] = "preGetMany";
|
|
218
|
+
e["POST_GET_MANY"] = "postGetMany";
|
|
219
|
+
e["PRE_DELETE"] = "preDelete";
|
|
220
|
+
e["POST_DELETE"] = "postDelete";
|
|
221
|
+
return e;
|
|
222
|
+
})(l || {});
|
|
223
|
+
|
|
224
|
+
var c = [ "sqlite", "postgres", "mysql", "mongo", "redis", "valkey", "etcd" ];
|
|
225
|
+
|
|
226
|
+
var f = class extends r {
|
|
227
|
+
opts;
|
|
228
|
+
iterator;
|
|
229
|
+
hooks=new a;
|
|
230
|
+
stats=new h(false);
|
|
231
|
+
_ttl;
|
|
232
|
+
_namespace;
|
|
233
|
+
_store=new Map;
|
|
234
|
+
_serialize=t;
|
|
235
|
+
_deserialize=s;
|
|
236
|
+
_compression;
|
|
237
|
+
_useKeyPrefix=true;
|
|
238
|
+
constructor(e, i) {
|
|
239
|
+
super();
|
|
240
|
+
i ??= {};
|
|
241
|
+
e ??= {};
|
|
242
|
+
this.opts = {
|
|
243
|
+
namespace: "keyv",
|
|
244
|
+
serialize: t,
|
|
245
|
+
deserialize: s,
|
|
246
|
+
emitErrors: true,
|
|
247
|
+
store: new Map,
|
|
248
|
+
...i
|
|
249
|
+
};
|
|
250
|
+
if (e && e.get) {
|
|
251
|
+
this.opts.store = e;
|
|
252
|
+
} else {
|
|
253
|
+
this.opts = {
|
|
254
|
+
...this.opts,
|
|
255
|
+
...e
|
|
256
|
+
};
|
|
257
|
+
}
|
|
258
|
+
this._store = this.opts.store ?? new Map;
|
|
259
|
+
this._compression = this.opts.compression;
|
|
260
|
+
this._serialize = this.opts.serialize;
|
|
261
|
+
this._deserialize = this.opts.deserialize;
|
|
262
|
+
if (this.opts.namespace) {
|
|
263
|
+
this._namespace = this.opts.namespace;
|
|
264
|
+
}
|
|
265
|
+
if (this._store) {
|
|
266
|
+
if (!this._isValidStorageAdapter(this._store)) {
|
|
267
|
+
throw new Error("Invalid storage adapter");
|
|
268
|
+
}
|
|
269
|
+
if (typeof this._store.on === "function") {
|
|
270
|
+
this._store.on("error", (e => this.emit("error", e)));
|
|
271
|
+
}
|
|
272
|
+
this._store.namespace = this._namespace;
|
|
273
|
+
if (typeof this._store[Symbol.iterator] === "function" && this._store instanceof Map) {
|
|
274
|
+
this.iterator = this.generateIterator(this._store);
|
|
275
|
+
} else if ("iterator" in this._store && this._store.opts && this._checkIterableAdapter()) {
|
|
276
|
+
this.iterator = this.generateIterator(this._store.iterator.bind(this._store));
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
if (this.opts.stats) {
|
|
280
|
+
this.stats.enabled = this.opts.stats;
|
|
281
|
+
}
|
|
282
|
+
if (this.opts.ttl) {
|
|
283
|
+
this._ttl = this.opts.ttl;
|
|
284
|
+
}
|
|
285
|
+
if (this.opts.useKeyPrefix !== void 0) {
|
|
286
|
+
this._useKeyPrefix = this.opts.useKeyPrefix;
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
get store() {
|
|
290
|
+
return this._store;
|
|
291
|
+
}
|
|
292
|
+
set store(e) {
|
|
293
|
+
if (this._isValidStorageAdapter(e)) {
|
|
294
|
+
this._store = e;
|
|
295
|
+
this.opts.store = e;
|
|
296
|
+
if (typeof e.on === "function") {
|
|
297
|
+
e.on("error", (e => this.emit("error", e)));
|
|
298
|
+
}
|
|
299
|
+
if (this._namespace) {
|
|
300
|
+
this._store.namespace = this._namespace;
|
|
301
|
+
}
|
|
302
|
+
if (typeof e[Symbol.iterator] === "function" && e instanceof Map) {
|
|
303
|
+
this.iterator = this.generateIterator(e);
|
|
304
|
+
} else if ("iterator" in e && e.opts && this._checkIterableAdapter()) {
|
|
305
|
+
this.iterator = this.generateIterator(e.iterator.bind(e));
|
|
306
|
+
}
|
|
307
|
+
} else {
|
|
308
|
+
throw new Error("Invalid storage adapter");
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
get compression() {
|
|
312
|
+
return this._compression;
|
|
313
|
+
}
|
|
314
|
+
set compression(e) {
|
|
315
|
+
this._compression = e;
|
|
316
|
+
}
|
|
317
|
+
get namespace() {
|
|
318
|
+
return this._namespace;
|
|
319
|
+
}
|
|
320
|
+
set namespace(e) {
|
|
321
|
+
this._namespace = e;
|
|
322
|
+
this.opts.namespace = e;
|
|
323
|
+
this._store.namespace = e;
|
|
324
|
+
if (this.opts.store) {
|
|
325
|
+
this.opts.store.namespace = e;
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
get ttl() {
|
|
329
|
+
return this._ttl;
|
|
330
|
+
}
|
|
331
|
+
set ttl(e) {
|
|
332
|
+
this.opts.ttl = e;
|
|
333
|
+
this._ttl = e;
|
|
334
|
+
}
|
|
335
|
+
get serialize() {
|
|
336
|
+
return this._serialize;
|
|
337
|
+
}
|
|
338
|
+
set serialize(e) {
|
|
339
|
+
this.opts.serialize = e;
|
|
340
|
+
this._serialize = e;
|
|
341
|
+
}
|
|
342
|
+
get deserialize() {
|
|
343
|
+
return this._deserialize;
|
|
344
|
+
}
|
|
345
|
+
set deserialize(e) {
|
|
346
|
+
this.opts.deserialize = e;
|
|
347
|
+
this._deserialize = e;
|
|
348
|
+
}
|
|
349
|
+
get useKeyPrefix() {
|
|
350
|
+
return this._useKeyPrefix;
|
|
351
|
+
}
|
|
352
|
+
set useKeyPrefix(e) {
|
|
353
|
+
this._useKeyPrefix = e;
|
|
354
|
+
this.opts.useKeyPrefix = e;
|
|
355
|
+
}
|
|
356
|
+
generateIterator(e) {
|
|
357
|
+
const t = async function*() {
|
|
358
|
+
for await (const [t, s] of typeof e === "function" ? e(this._store.namespace) : e) {
|
|
359
|
+
const e = await this.deserializeData(s);
|
|
360
|
+
if (this._useKeyPrefix && this._store.namespace && !t.includes(this._store.namespace)) {
|
|
361
|
+
continue;
|
|
362
|
+
}
|
|
363
|
+
if (typeof e.expires === "number" && Date.now() > e.expires) {
|
|
364
|
+
this.delete(t);
|
|
365
|
+
continue;
|
|
366
|
+
}
|
|
367
|
+
yield [ this._getKeyUnprefix(t), e.value ];
|
|
368
|
+
}
|
|
369
|
+
};
|
|
370
|
+
return t.bind(this);
|
|
371
|
+
}
|
|
372
|
+
_checkIterableAdapter() {
|
|
373
|
+
return c.includes(this._store.opts.dialect) || c.some((e => this._store.opts.url.includes(e)));
|
|
374
|
+
}
|
|
375
|
+
_getKeyPrefix(e) {
|
|
376
|
+
if (!this._useKeyPrefix) {
|
|
377
|
+
return e;
|
|
378
|
+
}
|
|
379
|
+
if (!this._namespace) {
|
|
380
|
+
return e;
|
|
381
|
+
}
|
|
382
|
+
return `${this._namespace}:${e}`;
|
|
383
|
+
}
|
|
384
|
+
_getKeyPrefixArray(e) {
|
|
385
|
+
if (!this._useKeyPrefix) {
|
|
386
|
+
return e;
|
|
387
|
+
}
|
|
388
|
+
if (!this._namespace) {
|
|
389
|
+
return e;
|
|
390
|
+
}
|
|
391
|
+
return e.map((e => `${this._namespace}:${e}`));
|
|
392
|
+
}
|
|
393
|
+
_getKeyUnprefix(e) {
|
|
394
|
+
if (!this._useKeyPrefix) {
|
|
395
|
+
return e;
|
|
396
|
+
}
|
|
397
|
+
return e.split(":").splice(1).join(":");
|
|
398
|
+
}
|
|
399
|
+
_isValidStorageAdapter(e) {
|
|
400
|
+
return e instanceof Map || typeof e.get === "function" && typeof e.set === "function" && typeof e.delete === "function" && typeof e.clear === "function";
|
|
401
|
+
}
|
|
402
|
+
async get(e, t) {
|
|
403
|
+
const {store: s} = this.opts;
|
|
404
|
+
const i = Array.isArray(e);
|
|
405
|
+
const r = i ? this._getKeyPrefixArray(e) : this._getKeyPrefix(e);
|
|
406
|
+
const o = e => typeof e.expires === "number" && Date.now() > e.expires;
|
|
407
|
+
if (i) {
|
|
408
|
+
if (t?.raw === true) {
|
|
409
|
+
return this.getMany(e, {
|
|
410
|
+
raw: true
|
|
411
|
+
});
|
|
412
|
+
}
|
|
413
|
+
return this.getMany(e, {
|
|
414
|
+
raw: false
|
|
415
|
+
});
|
|
416
|
+
}
|
|
417
|
+
this.hooks.trigger("preGet", {
|
|
418
|
+
key: r
|
|
419
|
+
});
|
|
420
|
+
const a = await s.get(r);
|
|
421
|
+
const n = typeof a === "string" || this.opts.compression ? await this.deserializeData(a) : a;
|
|
422
|
+
if (n === void 0 || n === null) {
|
|
423
|
+
this.stats.miss();
|
|
424
|
+
return void 0;
|
|
425
|
+
}
|
|
426
|
+
if (o(n)) {
|
|
427
|
+
await this.delete(e);
|
|
428
|
+
this.stats.miss();
|
|
429
|
+
return void 0;
|
|
430
|
+
}
|
|
431
|
+
this.hooks.trigger("postGet", {
|
|
432
|
+
key: r,
|
|
433
|
+
value: n
|
|
434
|
+
});
|
|
435
|
+
this.stats.hit();
|
|
436
|
+
return t?.raw ? n : n.value;
|
|
437
|
+
}
|
|
438
|
+
async getMany(e, t) {
|
|
439
|
+
const {store: s} = this.opts;
|
|
440
|
+
const i = this._getKeyPrefixArray(e);
|
|
441
|
+
const r = e => typeof e.expires === "number" && Date.now() > e.expires;
|
|
442
|
+
this.hooks.trigger("preGetMany", {
|
|
443
|
+
keys: i
|
|
444
|
+
});
|
|
445
|
+
if (s.getMany === void 0) {
|
|
446
|
+
const e = i.map((async e => {
|
|
447
|
+
const i = await s.get(e);
|
|
448
|
+
const o = typeof i === "string" || this.opts.compression ? await this.deserializeData(i) : i;
|
|
449
|
+
if (o === void 0 || o === null) {
|
|
450
|
+
return void 0;
|
|
451
|
+
}
|
|
452
|
+
if (r(o)) {
|
|
453
|
+
await this.delete(e);
|
|
454
|
+
return void 0;
|
|
455
|
+
}
|
|
456
|
+
return t?.raw ? o : o.value;
|
|
457
|
+
}));
|
|
458
|
+
const o = await Promise.allSettled(e);
|
|
459
|
+
const a = o.map((e => e.value));
|
|
460
|
+
this.hooks.trigger("postGetMany", a);
|
|
461
|
+
if (a.length > 0) {
|
|
462
|
+
this.stats.hit();
|
|
463
|
+
}
|
|
464
|
+
return a;
|
|
465
|
+
}
|
|
466
|
+
const o = await s.getMany(i);
|
|
467
|
+
const a = [];
|
|
468
|
+
for (const s in o) {
|
|
469
|
+
let i = o[s];
|
|
470
|
+
if (typeof i === "string") {
|
|
471
|
+
i = await this.deserializeData(i);
|
|
472
|
+
}
|
|
473
|
+
if (i === void 0 || i === null) {
|
|
474
|
+
a.push(void 0);
|
|
475
|
+
continue;
|
|
476
|
+
}
|
|
477
|
+
if (r(i)) {
|
|
478
|
+
await this.delete(e[s]);
|
|
479
|
+
a.push(void 0);
|
|
480
|
+
continue;
|
|
481
|
+
}
|
|
482
|
+
const n = t?.raw ? i : i.value;
|
|
483
|
+
a.push(n);
|
|
484
|
+
}
|
|
485
|
+
this.hooks.trigger("postGetMany", a);
|
|
486
|
+
if (a.length > 0) {
|
|
487
|
+
this.stats.hit();
|
|
488
|
+
}
|
|
489
|
+
return a;
|
|
490
|
+
}
|
|
491
|
+
async set(e, t, s) {
|
|
492
|
+
const i = {
|
|
493
|
+
key: e,
|
|
494
|
+
value: t,
|
|
495
|
+
ttl: s
|
|
496
|
+
};
|
|
497
|
+
this.hooks.trigger("preSet", i);
|
|
498
|
+
const r = this._getKeyPrefix(i.key);
|
|
499
|
+
i.ttl ??= this._ttl;
|
|
500
|
+
if (i.ttl === 0) {
|
|
501
|
+
i.ttl = void 0;
|
|
502
|
+
}
|
|
503
|
+
const {store: o} = this.opts;
|
|
504
|
+
const a = typeof i.ttl === "number" ? Date.now() + i.ttl : void 0;
|
|
505
|
+
if (typeof i.value === "symbol") {
|
|
506
|
+
this.emit("error", "symbol cannot be serialized");
|
|
507
|
+
throw new Error("symbol cannot be serialized");
|
|
508
|
+
}
|
|
509
|
+
const n = {
|
|
510
|
+
value: i.value,
|
|
511
|
+
expires: a
|
|
512
|
+
};
|
|
513
|
+
const h = await this.serializeData(n);
|
|
514
|
+
let l = true;
|
|
515
|
+
try {
|
|
516
|
+
const e = await o.set(r, h, i.ttl);
|
|
517
|
+
if (typeof e === "boolean") {
|
|
518
|
+
l = e;
|
|
519
|
+
}
|
|
520
|
+
} catch (e) {
|
|
521
|
+
l = false;
|
|
522
|
+
this.emit("error", e);
|
|
523
|
+
}
|
|
524
|
+
this.hooks.trigger("postSet", {
|
|
525
|
+
key: r,
|
|
526
|
+
value: h,
|
|
527
|
+
ttl: s
|
|
528
|
+
});
|
|
529
|
+
this.stats.set();
|
|
530
|
+
return l;
|
|
531
|
+
}
|
|
532
|
+
async setMany(e) {
|
|
533
|
+
let t = [];
|
|
534
|
+
try {
|
|
535
|
+
if (this._store.setMany !== void 0) {
|
|
536
|
+
const s = await Promise.all(e.map((async ({key: e, value: t, ttl: s}) => {
|
|
537
|
+
s ??= this._ttl;
|
|
538
|
+
if (s === 0) {
|
|
539
|
+
s = void 0;
|
|
540
|
+
}
|
|
541
|
+
const i = typeof s === "number" ? Date.now() + s : void 0;
|
|
542
|
+
if (typeof t === "symbol") {
|
|
543
|
+
this.emit("error", "symbol cannot be serialized");
|
|
544
|
+
throw new Error("symbol cannot be serialized");
|
|
545
|
+
}
|
|
546
|
+
const r = {
|
|
547
|
+
value: t,
|
|
548
|
+
expires: i
|
|
549
|
+
};
|
|
550
|
+
const o = await this.serializeData(r);
|
|
551
|
+
return {
|
|
552
|
+
key: e,
|
|
553
|
+
value: o,
|
|
554
|
+
ttl: s
|
|
555
|
+
};
|
|
556
|
+
})));
|
|
557
|
+
t = await this._store.setMany(s);
|
|
558
|
+
}
|
|
559
|
+
const s = [];
|
|
560
|
+
for (const t of e) {
|
|
561
|
+
s.push(this.set(t.key, t.value, t.ttl));
|
|
562
|
+
}
|
|
563
|
+
const i = await Promise.allSettled(s);
|
|
564
|
+
t = i.map((e => e.value));
|
|
565
|
+
} catch (s) {
|
|
566
|
+
this.emit("error", s);
|
|
567
|
+
t = e.map((() => false));
|
|
568
|
+
}
|
|
569
|
+
return t;
|
|
570
|
+
}
|
|
571
|
+
async delete(e) {
|
|
572
|
+
const {store: t} = this.opts;
|
|
573
|
+
if (Array.isArray(e)) {
|
|
574
|
+
return this.deleteMany(e);
|
|
575
|
+
}
|
|
576
|
+
const s = this._getKeyPrefix(e);
|
|
577
|
+
this.hooks.trigger("preDelete", {
|
|
578
|
+
key: s
|
|
579
|
+
});
|
|
580
|
+
let i = true;
|
|
581
|
+
try {
|
|
582
|
+
const e = await t.delete(s);
|
|
583
|
+
if (typeof e === "boolean") {
|
|
584
|
+
i = e;
|
|
585
|
+
}
|
|
586
|
+
} catch (e) {
|
|
587
|
+
i = false;
|
|
588
|
+
this.emit("error", e);
|
|
589
|
+
}
|
|
590
|
+
this.hooks.trigger("postDelete", {
|
|
591
|
+
key: s,
|
|
592
|
+
value: i
|
|
593
|
+
});
|
|
594
|
+
this.stats.delete();
|
|
595
|
+
return i;
|
|
596
|
+
}
|
|
597
|
+
async deleteMany(e) {
|
|
598
|
+
try {
|
|
599
|
+
const {store: t} = this.opts;
|
|
600
|
+
const s = this._getKeyPrefixArray(e);
|
|
601
|
+
this.hooks.trigger("preDelete", {
|
|
602
|
+
key: s
|
|
603
|
+
});
|
|
604
|
+
if (t.deleteMany !== void 0) {
|
|
605
|
+
return await t.deleteMany(s);
|
|
606
|
+
}
|
|
607
|
+
const i = s.map((async e => t.delete(e)));
|
|
608
|
+
const r = await Promise.allSettled(i);
|
|
609
|
+
const o = r.every((e => e.value === true));
|
|
610
|
+
this.hooks.trigger("postDelete", {
|
|
611
|
+
key: s,
|
|
612
|
+
value: o
|
|
613
|
+
});
|
|
614
|
+
return o;
|
|
615
|
+
} catch (e) {
|
|
616
|
+
this.emit("error", e);
|
|
617
|
+
return false;
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
async clear() {
|
|
621
|
+
this.emit("clear");
|
|
622
|
+
const {store: e} = this.opts;
|
|
623
|
+
try {
|
|
624
|
+
await e.clear();
|
|
625
|
+
} catch (e) {
|
|
626
|
+
this.emit("error", e);
|
|
627
|
+
}
|
|
628
|
+
}
|
|
629
|
+
async has(e) {
|
|
630
|
+
if (Array.isArray(e)) {
|
|
631
|
+
return this.hasMany(e);
|
|
632
|
+
}
|
|
633
|
+
const t = this._getKeyPrefix(e);
|
|
634
|
+
const {store: s} = this.opts;
|
|
635
|
+
if (s.has !== void 0 && !(s instanceof Map)) {
|
|
636
|
+
return s.has(t);
|
|
637
|
+
}
|
|
638
|
+
let i;
|
|
639
|
+
try {
|
|
640
|
+
i = await s.get(t);
|
|
641
|
+
} catch (e) {
|
|
642
|
+
this.emit("error", e);
|
|
643
|
+
}
|
|
644
|
+
if (i) {
|
|
645
|
+
const e = await this.deserializeData(i);
|
|
646
|
+
if (e) {
|
|
647
|
+
if (e.expires === void 0 || e.expires === null) {
|
|
648
|
+
return true;
|
|
649
|
+
}
|
|
650
|
+
return e.expires > Date.now();
|
|
651
|
+
}
|
|
652
|
+
}
|
|
653
|
+
return false;
|
|
654
|
+
}
|
|
655
|
+
async hasMany(e) {
|
|
656
|
+
const t = this._getKeyPrefixArray(e);
|
|
657
|
+
const {store: s} = this.opts;
|
|
658
|
+
if (s.hasMany !== void 0) {
|
|
659
|
+
return s.hasMany(t);
|
|
660
|
+
}
|
|
661
|
+
const i = [];
|
|
662
|
+
for (const e of t) {
|
|
663
|
+
i.push(await this.has(e));
|
|
664
|
+
}
|
|
665
|
+
return i;
|
|
666
|
+
}
|
|
667
|
+
async disconnect() {
|
|
668
|
+
const {store: e} = this.opts;
|
|
669
|
+
this.emit("disconnect");
|
|
670
|
+
if (typeof e.disconnect === "function") {
|
|
671
|
+
return e.disconnect();
|
|
672
|
+
}
|
|
673
|
+
}
|
|
674
|
+
emit(e, ...t) {
|
|
675
|
+
if (e === "error" && !this.opts.emitErrors) {
|
|
676
|
+
return;
|
|
677
|
+
}
|
|
678
|
+
super.emit(e, ...t);
|
|
679
|
+
}
|
|
680
|
+
async serializeData(e) {
|
|
681
|
+
if (!this._serialize) {
|
|
682
|
+
return e;
|
|
683
|
+
}
|
|
684
|
+
if (this._compression?.compress) {
|
|
685
|
+
return this._serialize({
|
|
686
|
+
value: await this._compression.compress(e.value),
|
|
687
|
+
expires: e.expires
|
|
688
|
+
});
|
|
689
|
+
}
|
|
690
|
+
return this._serialize(e);
|
|
691
|
+
}
|
|
692
|
+
async deserializeData(e) {
|
|
693
|
+
if (!this._deserialize) {
|
|
694
|
+
return e;
|
|
695
|
+
}
|
|
696
|
+
if (this._compression?.decompress && typeof e === "string") {
|
|
697
|
+
const t = await this._deserialize(e);
|
|
698
|
+
return {
|
|
699
|
+
value: await this._compression.decompress(t?.value),
|
|
700
|
+
expires: t?.expires
|
|
701
|
+
};
|
|
702
|
+
}
|
|
703
|
+
if (typeof e === "string") {
|
|
704
|
+
return this._deserialize(e);
|
|
705
|
+
}
|
|
706
|
+
return void 0;
|
|
707
|
+
}
|
|
708
|
+
};
|
|
709
|
+
|
|
710
|
+
var p = f;
|
|
711
|
+
|
|
712
|
+
exports.Keyv = f;
|
|
713
|
+
|
|
714
|
+
exports.defaultDeserialize = s;
|
|
715
|
+
|
|
716
|
+
exports.index_default = p;
|