alepha 0.13.0 → 0.13.2
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/README.md +1 -1
- package/dist/api-files/index.d.ts +28 -91
- package/dist/api-files/index.js +10 -755
- package/dist/api-files/index.js.map +1 -1
- package/dist/api-jobs/index.d.ts +67 -67
- package/dist/api-jobs/index.js +13 -13
- package/dist/api-jobs/index.js.map +1 -1
- package/dist/api-notifications/index.d.ts +129 -146
- package/dist/api-notifications/index.js +17 -39
- package/dist/api-notifications/index.js.map +1 -1
- package/dist/api-parameters/index.d.ts +21 -22
- package/dist/api-parameters/index.js +22 -22
- package/dist/api-parameters/index.js.map +1 -1
- package/dist/api-users/index.d.ts +224 -2001
- package/dist/api-users/index.js +914 -4787
- package/dist/api-users/index.js.map +1 -1
- package/dist/api-verifications/index.d.ts +96 -96
- package/dist/batch/index.d.ts +13 -13
- package/dist/batch/index.js +8 -8
- package/dist/batch/index.js.map +1 -1
- package/dist/bucket/index.d.ts +14 -14
- package/dist/bucket/index.js +12 -12
- package/dist/bucket/index.js.map +1 -1
- package/dist/cache/index.d.ts +11 -11
- package/dist/cache/index.js +9 -9
- package/dist/cache/index.js.map +1 -1
- package/dist/cli/{dist-Sz2EXvQX.cjs → dist-Dl9Vl7Ur.js} +17 -13
- package/dist/cli/{dist-BBPjuQ56.js.map → dist-Dl9Vl7Ur.js.map} +1 -1
- package/dist/cli/index.d.ts +31 -37
- package/dist/cli/index.js +152 -83
- package/dist/cli/index.js.map +1 -1
- package/dist/command/index.d.ts +19 -19
- package/dist/command/index.js +25 -25
- package/dist/command/index.js.map +1 -1
- package/dist/core/index.browser.js +218 -218
- package/dist/core/index.browser.js.map +1 -1
- package/dist/core/index.d.ts +232 -232
- package/dist/core/index.js +218 -218
- package/dist/core/index.js.map +1 -1
- package/dist/core/{index.cjs → index.native.js} +304 -455
- package/dist/core/index.native.js.map +1 -0
- package/dist/datetime/index.d.ts +9 -9
- package/dist/datetime/index.js +7 -7
- package/dist/datetime/index.js.map +1 -1
- package/dist/email/index.d.ts +16 -16
- package/dist/email/index.js +80 -82
- package/dist/email/index.js.map +1 -1
- package/dist/file/index.js +1 -1
- package/dist/file/index.js.map +1 -1
- package/dist/lock/index.d.ts +9 -9
- package/dist/lock/index.js +8 -8
- package/dist/lock/index.js.map +1 -1
- package/dist/lock-redis/index.js +3 -66
- package/dist/lock-redis/index.js.map +1 -1
- package/dist/logger/index.d.ts +5 -5
- package/dist/logger/index.js +8 -8
- package/dist/logger/index.js.map +1 -1
- package/dist/orm/index.browser.js +114 -114
- package/dist/orm/index.browser.js.map +1 -1
- package/dist/orm/index.d.ts +219 -219
- package/dist/orm/index.js +46 -46
- package/dist/orm/index.js.map +1 -1
- package/dist/queue/index.d.ts +25 -25
- package/dist/queue/index.js +20 -20
- package/dist/queue/index.js.map +1 -1
- package/dist/queue-redis/index.d.ts +2 -2
- package/dist/redis/index.d.ts +10 -10
- package/dist/retry/index.d.ts +20 -20
- package/dist/retry/index.js +9 -9
- package/dist/retry/index.js.map +1 -1
- package/dist/scheduler/index.d.ts +12 -12
- package/dist/scheduler/index.js +9 -9
- package/dist/scheduler/index.js.map +1 -1
- package/dist/security/index.d.ts +53 -53
- package/dist/security/index.js +32 -32
- package/dist/security/index.js.map +1 -1
- package/dist/server/index.browser.js +1 -1
- package/dist/server/index.browser.js.map +1 -1
- package/dist/server/index.d.ts +101 -101
- package/dist/server/index.js +17 -17
- package/dist/server/index.js.map +1 -1
- package/dist/server-auth/index.browser.js +4 -982
- package/dist/server-auth/index.browser.js.map +1 -1
- package/dist/server-auth/index.d.ts +204 -785
- package/dist/server-auth/index.js +47 -1239
- package/dist/server-auth/index.js.map +1 -1
- package/dist/server-cache/index.d.ts +10 -10
- package/dist/server-cache/index.js +2 -2
- package/dist/server-cache/index.js.map +1 -1
- package/dist/server-compress/index.d.ts +4 -4
- package/dist/server-compress/index.js +1 -1
- package/dist/server-compress/index.js.map +1 -1
- package/dist/server-cookies/index.browser.js +8 -8
- package/dist/server-cookies/index.browser.js.map +1 -1
- package/dist/server-cookies/index.d.ts +17 -17
- package/dist/server-cookies/index.js +10 -10
- package/dist/server-cookies/index.js.map +1 -1
- package/dist/server-cors/index.d.ts +17 -17
- package/dist/server-cors/index.js +9 -9
- package/dist/server-cors/index.js.map +1 -1
- package/dist/server-health/index.d.ts +2 -2
- package/dist/server-helmet/index.d.ts +1 -1
- package/dist/server-links/index.browser.js +12 -12
- package/dist/server-links/index.browser.js.map +1 -1
- package/dist/server-links/index.d.ts +59 -251
- package/dist/server-links/index.js +23 -502
- package/dist/server-links/index.js.map +1 -1
- package/dist/server-metrics/index.d.ts +4 -4
- package/dist/server-metrics/index.js +170 -174
- package/dist/server-metrics/index.js.map +1 -1
- package/dist/server-multipart/index.d.ts +2 -2
- package/dist/server-proxy/index.d.ts +12 -12
- package/dist/server-proxy/index.js +10 -10
- package/dist/server-proxy/index.js.map +1 -1
- package/dist/server-rate-limit/index.d.ts +22 -22
- package/dist/server-rate-limit/index.js +12 -12
- package/dist/server-rate-limit/index.js.map +1 -1
- package/dist/server-security/index.d.ts +24 -24
- package/dist/server-security/index.js +15 -15
- package/dist/server-security/index.js.map +1 -1
- package/dist/server-static/index.d.ts +14 -14
- package/dist/server-static/index.js +8 -8
- package/dist/server-static/index.js.map +1 -1
- package/dist/server-swagger/index.d.ts +25 -184
- package/dist/server-swagger/index.js +21 -724
- package/dist/server-swagger/index.js.map +1 -1
- package/dist/sms/index.d.ts +14 -14
- package/dist/sms/index.js +9 -9
- package/dist/sms/index.js.map +1 -1
- package/dist/thread/index.d.ts +11 -11
- package/dist/thread/index.js +17 -17
- package/dist/thread/index.js.map +1 -1
- package/dist/topic/index.d.ts +26 -26
- package/dist/topic/index.js +16 -16
- package/dist/topic/index.js.map +1 -1
- package/dist/topic-redis/index.d.ts +1 -1
- package/dist/vite/index.d.ts +3 -3
- package/dist/vite/index.js +12 -13
- package/dist/vite/index.js.map +1 -1
- package/dist/websocket/index.browser.js +11 -11
- package/dist/websocket/index.browser.js.map +1 -1
- package/dist/websocket/index.d.ts +51 -51
- package/dist/websocket/index.js +13 -13
- package/dist/websocket/index.js.map +1 -1
- package/package.json +62 -52
- package/src/api-files/services/FileService.ts +5 -7
- package/src/api-jobs/index.ts +1 -1
- package/src/api-jobs/{descriptors → primitives}/$job.ts +8 -8
- package/src/api-jobs/providers/JobProvider.ts +9 -9
- package/src/api-jobs/services/JobService.ts +5 -5
- package/src/api-notifications/index.ts +5 -15
- package/src/api-notifications/{descriptors → primitives}/$notification.ts +10 -10
- package/src/api-notifications/services/NotificationSenderService.ts +3 -3
- package/src/api-parameters/index.ts +1 -1
- package/src/api-parameters/{descriptors → primitives}/$config.ts +7 -12
- package/src/api-users/index.ts +1 -1
- package/src/api-users/{descriptors → primitives}/$userRealm.ts +8 -8
- package/src/api-users/providers/UserRealmProvider.ts +1 -1
- package/src/batch/index.ts +3 -3
- package/src/batch/{descriptors → primitives}/$batch.ts +13 -16
- package/src/bucket/index.ts +8 -8
- package/src/bucket/{descriptors → primitives}/$bucket.ts +8 -8
- package/src/bucket/providers/LocalFileStorageProvider.ts +3 -3
- package/src/cache/index.ts +4 -4
- package/src/cache/{descriptors → primitives}/$cache.ts +15 -15
- package/src/cli/apps/AlephaPackageBuilderCli.ts +30 -3
- package/src/cli/assets/appRouterTs.ts +9 -0
- package/src/cli/assets/indexHtml.ts +2 -1
- package/src/cli/assets/mainBrowserTs.ts +10 -0
- package/src/cli/commands/CoreCommands.ts +6 -5
- package/src/cli/commands/DrizzleCommands.ts +69 -61
- package/src/cli/commands/VerifyCommands.ts +2 -2
- package/src/cli/commands/ViteCommands.ts +6 -1
- package/src/cli/services/ProjectUtils.ts +78 -41
- package/src/command/index.ts +5 -5
- package/src/command/{descriptors → primitives}/$command.ts +9 -12
- package/src/command/providers/CliProvider.ts +10 -10
- package/src/core/Alepha.ts +30 -33
- package/src/core/constants/KIND.ts +1 -1
- package/src/core/constants/OPTIONS.ts +1 -1
- package/src/core/helpers/{descriptor.ts → primitive.ts} +18 -18
- package/src/core/helpers/ref.ts +1 -1
- package/src/core/index.shared.ts +8 -8
- package/src/core/{descriptors → primitives}/$context.ts +5 -5
- package/src/core/{descriptors → primitives}/$hook.ts +4 -4
- package/src/core/{descriptors → primitives}/$inject.ts +2 -2
- package/src/core/{descriptors → primitives}/$module.ts +9 -9
- package/src/core/{descriptors → primitives}/$use.ts +2 -2
- package/src/core/providers/CodecManager.ts +1 -1
- package/src/core/providers/JsonSchemaCodec.ts +1 -1
- package/src/core/providers/StateManager.ts +2 -2
- package/src/datetime/index.ts +3 -3
- package/src/datetime/{descriptors → primitives}/$interval.ts +6 -6
- package/src/email/index.ts +4 -4
- package/src/email/{descriptors → primitives}/$email.ts +8 -8
- package/src/file/index.ts +1 -1
- package/src/lock/index.ts +3 -3
- package/src/lock/{descriptors → primitives}/$lock.ts +10 -10
- package/src/logger/index.ts +8 -8
- package/src/logger/{descriptors → primitives}/$logger.ts +2 -2
- package/src/logger/services/Logger.ts +1 -1
- package/src/orm/constants/PG_SYMBOLS.ts +2 -2
- package/src/orm/index.browser.ts +2 -2
- package/src/orm/index.ts +8 -8
- package/src/orm/{descriptors → primitives}/$entity.ts +11 -11
- package/src/orm/{descriptors → primitives}/$repository.ts +2 -2
- package/src/orm/{descriptors → primitives}/$sequence.ts +8 -8
- package/src/orm/{descriptors → primitives}/$transaction.ts +4 -4
- package/src/orm/providers/DrizzleKitProvider.ts +1 -1
- package/src/orm/providers/PostgresTypeProvider.ts +3 -3
- package/src/orm/providers/RepositoryProvider.ts +4 -4
- package/src/orm/providers/drivers/DatabaseProvider.ts +7 -7
- package/src/orm/services/ModelBuilder.ts +9 -9
- package/src/orm/services/PgRelationManager.ts +2 -2
- package/src/orm/services/PostgresModelBuilder.ts +5 -5
- package/src/orm/services/Repository.ts +7 -7
- package/src/orm/services/SqliteModelBuilder.ts +5 -5
- package/src/queue/index.ts +7 -7
- package/src/queue/{descriptors → primitives}/$consumer.ts +15 -15
- package/src/queue/{descriptors → primitives}/$queue.ts +12 -12
- package/src/queue/providers/WorkerProvider.ts +7 -7
- package/src/retry/index.ts +3 -3
- package/src/retry/{descriptors → primitives}/$retry.ts +19 -17
- package/src/scheduler/index.ts +3 -3
- package/src/scheduler/{descriptors → primitives}/$scheduler.ts +9 -9
- package/src/scheduler/providers/CronProvider.ts +1 -1
- package/src/security/index.ts +9 -9
- package/src/security/{descriptors → primitives}/$permission.ts +7 -7
- package/src/security/{descriptors → primitives}/$realm.ts +6 -12
- package/src/security/{descriptors → primitives}/$role.ts +12 -12
- package/src/security/{descriptors → primitives}/$serviceAccount.ts +8 -8
- package/src/server/index.browser.ts +1 -1
- package/src/server/index.ts +14 -14
- package/src/server/{descriptors → primitives}/$action.ts +13 -13
- package/src/server/{descriptors → primitives}/$route.ts +9 -9
- package/src/server/providers/NodeHttpServerProvider.ts +2 -2
- package/src/server/services/HttpClient.ts +1 -1
- package/src/server-auth/index.browser.ts +1 -1
- package/src/server-auth/index.ts +6 -6
- package/src/server-auth/{descriptors → primitives}/$auth.ts +10 -10
- package/src/server-auth/{descriptors → primitives}/$authCredentials.ts +4 -4
- package/src/server-auth/{descriptors → primitives}/$authGithub.ts +4 -4
- package/src/server-auth/{descriptors → primitives}/$authGoogle.ts +4 -4
- package/src/server-auth/providers/ServerAuthProvider.ts +4 -4
- package/src/server-cache/providers/ServerCacheProvider.ts +7 -7
- package/src/server-compress/providers/ServerCompressProvider.ts +3 -3
- package/src/server-cookies/index.browser.ts +2 -2
- package/src/server-cookies/index.ts +5 -5
- package/src/server-cookies/{descriptors → primitives}/$cookie.browser.ts +12 -12
- package/src/server-cookies/{descriptors → primitives}/$cookie.ts +13 -13
- package/src/server-cookies/providers/ServerCookiesProvider.ts +4 -4
- package/src/server-cookies/services/CookieParser.ts +1 -1
- package/src/server-cors/index.ts +3 -3
- package/src/server-cors/{descriptors → primitives}/$cors.ts +11 -13
- package/src/server-cors/providers/ServerCorsProvider.ts +5 -5
- package/src/server-links/index.browser.ts +5 -5
- package/src/server-links/index.ts +9 -9
- package/src/server-links/{descriptors → primitives}/$remote.ts +11 -11
- package/src/server-links/providers/LinkProvider.ts +7 -7
- package/src/server-links/providers/{RemoteDescriptorProvider.ts → RemotePrimitiveProvider.ts} +6 -6
- package/src/server-links/providers/ServerLinksProvider.ts +3 -3
- package/src/server-proxy/index.ts +3 -3
- package/src/server-proxy/{descriptors → primitives}/$proxy.ts +8 -8
- package/src/server-proxy/providers/ServerProxyProvider.ts +4 -4
- package/src/server-rate-limit/index.ts +6 -6
- package/src/server-rate-limit/{descriptors → primitives}/$rateLimit.ts +13 -13
- package/src/server-rate-limit/providers/ServerRateLimitProvider.ts +5 -5
- package/src/server-security/index.ts +3 -3
- package/src/server-security/{descriptors → primitives}/$basicAuth.ts +13 -13
- package/src/server-security/providers/ServerBasicAuthProvider.ts +5 -5
- package/src/server-security/providers/ServerSecurityProvider.ts +4 -4
- package/src/server-static/index.ts +3 -3
- package/src/server-static/{descriptors → primitives}/$serve.ts +8 -10
- package/src/server-static/providers/ServerStaticProvider.ts +6 -6
- package/src/server-swagger/index.ts +5 -5
- package/src/server-swagger/{descriptors → primitives}/$swagger.ts +9 -9
- package/src/server-swagger/providers/ServerSwaggerProvider.ts +11 -10
- package/src/sms/index.ts +4 -4
- package/src/sms/{descriptors → primitives}/$sms.ts +8 -8
- package/src/thread/index.ts +3 -3
- package/src/thread/{descriptors → primitives}/$thread.ts +13 -13
- package/src/thread/providers/ThreadProvider.ts +7 -9
- package/src/topic/index.ts +5 -5
- package/src/topic/{descriptors → primitives}/$subscriber.ts +14 -14
- package/src/topic/{descriptors → primitives}/$topic.ts +10 -10
- package/src/topic/providers/TopicProvider.ts +4 -4
- package/src/vite/helpers/boot.ts +3 -3
- package/src/vite/tasks/copyAssets.ts +1 -1
- package/src/vite/tasks/generateSitemap.ts +3 -3
- package/src/vite/tasks/prerenderPages.ts +2 -2
- package/src/vite/tasks/runAlepha.ts +2 -2
- package/src/websocket/index.browser.ts +3 -3
- package/src/websocket/index.shared.ts +2 -2
- package/src/websocket/index.ts +4 -4
- package/src/websocket/interfaces/WebSocketInterfaces.ts +3 -3
- package/src/websocket/{descriptors → primitives}/$channel.ts +10 -10
- package/src/websocket/{descriptors → primitives}/$websocket.ts +8 -8
- package/src/websocket/providers/NodeWebSocketServerProvider.ts +7 -7
- package/src/websocket/providers/WebSocketServerProvider.ts +3 -3
- package/src/websocket/services/WebSocketClient.ts +5 -5
- package/dist/api-files/index.cjs +0 -1293
- package/dist/api-files/index.cjs.map +0 -1
- package/dist/api-files/index.d.cts +0 -829
- package/dist/api-jobs/index.cjs +0 -274
- package/dist/api-jobs/index.cjs.map +0 -1
- package/dist/api-jobs/index.d.cts +0 -654
- package/dist/api-notifications/index.cjs +0 -380
- package/dist/api-notifications/index.cjs.map +0 -1
- package/dist/api-notifications/index.d.cts +0 -289
- package/dist/api-parameters/index.cjs +0 -66
- package/dist/api-parameters/index.cjs.map +0 -1
- package/dist/api-parameters/index.d.cts +0 -84
- package/dist/api-users/index.cjs +0 -6009
- package/dist/api-users/index.cjs.map +0 -1
- package/dist/api-users/index.d.cts +0 -4740
- package/dist/api-verifications/index.cjs +0 -407
- package/dist/api-verifications/index.cjs.map +0 -1
- package/dist/api-verifications/index.d.cts +0 -207
- package/dist/batch/index.cjs +0 -408
- package/dist/batch/index.cjs.map +0 -1
- package/dist/batch/index.d.cts +0 -330
- package/dist/bin/index.cjs +0 -17
- package/dist/bin/index.cjs.map +0 -1
- package/dist/bin/index.d.cts +0 -1
- package/dist/bucket/index.cjs +0 -303
- package/dist/bucket/index.cjs.map +0 -1
- package/dist/bucket/index.d.cts +0 -355
- package/dist/cache/index.cjs +0 -241
- package/dist/cache/index.cjs.map +0 -1
- package/dist/cache/index.d.cts +0 -202
- package/dist/cache-redis/index.cjs +0 -84
- package/dist/cache-redis/index.cjs.map +0 -1
- package/dist/cache-redis/index.d.cts +0 -40
- package/dist/cli/chunk-DSlc6foC.cjs +0 -43
- package/dist/cli/dist-BBPjuQ56.js +0 -2778
- package/dist/cli/dist-Sz2EXvQX.cjs.map +0 -1
- package/dist/cli/index.cjs +0 -1241
- package/dist/cli/index.cjs.map +0 -1
- package/dist/cli/index.d.cts +0 -422
- package/dist/command/index.cjs +0 -693
- package/dist/command/index.cjs.map +0 -1
- package/dist/command/index.d.cts +0 -340
- package/dist/core/index.cjs.map +0 -1
- package/dist/core/index.d.cts +0 -1927
- package/dist/datetime/index.cjs +0 -318
- package/dist/datetime/index.cjs.map +0 -1
- package/dist/datetime/index.d.cts +0 -145
- package/dist/email/index.cjs +0 -10874
- package/dist/email/index.cjs.map +0 -1
- package/dist/email/index.d.cts +0 -186
- package/dist/fake/index.cjs +0 -34641
- package/dist/fake/index.cjs.map +0 -1
- package/dist/fake/index.d.cts +0 -74
- package/dist/file/index.cjs +0 -1212
- package/dist/file/index.cjs.map +0 -1
- package/dist/file/index.d.cts +0 -698
- package/dist/lock/index.cjs +0 -226
- package/dist/lock/index.cjs.map +0 -1
- package/dist/lock/index.d.cts +0 -361
- package/dist/lock-redis/index.cjs +0 -113
- package/dist/lock-redis/index.cjs.map +0 -1
- package/dist/lock-redis/index.d.cts +0 -24
- package/dist/logger/index.cjs +0 -521
- package/dist/logger/index.cjs.map +0 -1
- package/dist/logger/index.d.cts +0 -281
- package/dist/orm/index.cjs +0 -2986
- package/dist/orm/index.cjs.map +0 -1
- package/dist/orm/index.d.cts +0 -2213
- package/dist/queue/index.cjs +0 -1044
- package/dist/queue/index.cjs.map +0 -1
- package/dist/queue/index.d.cts +0 -1265
- package/dist/queue-redis/index.cjs +0 -873
- package/dist/queue-redis/index.cjs.map +0 -1
- package/dist/queue-redis/index.d.cts +0 -82
- package/dist/redis/index.cjs +0 -153
- package/dist/redis/index.cjs.map +0 -1
- package/dist/redis/index.d.cts +0 -82
- package/dist/retry/index.cjs +0 -146
- package/dist/retry/index.cjs.map +0 -1
- package/dist/retry/index.d.cts +0 -172
- package/dist/router/index.cjs +0 -111
- package/dist/router/index.cjs.map +0 -1
- package/dist/router/index.d.cts +0 -46
- package/dist/scheduler/index.cjs +0 -576
- package/dist/scheduler/index.cjs.map +0 -1
- package/dist/scheduler/index.d.cts +0 -145
- package/dist/security/index.cjs +0 -2402
- package/dist/security/index.cjs.map +0 -1
- package/dist/security/index.d.cts +0 -598
- package/dist/server/index.cjs +0 -1680
- package/dist/server/index.cjs.map +0 -1
- package/dist/server/index.d.cts +0 -810
- package/dist/server-auth/index.cjs +0 -3146
- package/dist/server-auth/index.cjs.map +0 -1
- package/dist/server-auth/index.d.cts +0 -1164
- package/dist/server-cache/index.cjs +0 -252
- package/dist/server-cache/index.cjs.map +0 -1
- package/dist/server-cache/index.d.cts +0 -164
- package/dist/server-compress/index.cjs +0 -141
- package/dist/server-compress/index.cjs.map +0 -1
- package/dist/server-compress/index.d.cts +0 -38
- package/dist/server-cookies/index.cjs +0 -234
- package/dist/server-cookies/index.cjs.map +0 -1
- package/dist/server-cookies/index.d.cts +0 -144
- package/dist/server-cors/index.cjs +0 -201
- package/dist/server-cors/index.cjs.map +0 -1
- package/dist/server-cors/index.d.cts +0 -140
- package/dist/server-health/index.cjs +0 -62
- package/dist/server-health/index.cjs.map +0 -1
- package/dist/server-health/index.d.cts +0 -58
- package/dist/server-helmet/index.cjs +0 -131
- package/dist/server-helmet/index.cjs.map +0 -1
- package/dist/server-helmet/index.d.cts +0 -97
- package/dist/server-links/index.cjs +0 -992
- package/dist/server-links/index.cjs.map +0 -1
- package/dist/server-links/index.d.cts +0 -513
- package/dist/server-metrics/index.cjs +0 -4535
- package/dist/server-metrics/index.cjs.map +0 -1
- package/dist/server-metrics/index.d.cts +0 -35
- package/dist/server-multipart/index.cjs +0 -237
- package/dist/server-multipart/index.cjs.map +0 -1
- package/dist/server-multipart/index.d.cts +0 -50
- package/dist/server-proxy/index.cjs +0 -186
- package/dist/server-proxy/index.cjs.map +0 -1
- package/dist/server-proxy/index.d.cts +0 -234
- package/dist/server-rate-limit/index.cjs +0 -241
- package/dist/server-rate-limit/index.cjs.map +0 -1
- package/dist/server-rate-limit/index.d.cts +0 -183
- package/dist/server-security/index.cjs +0 -316
- package/dist/server-security/index.cjs.map +0 -1
- package/dist/server-security/index.d.cts +0 -173
- package/dist/server-static/index.cjs +0 -170
- package/dist/server-static/index.cjs.map +0 -1
- package/dist/server-static/index.d.cts +0 -121
- package/dist/server-swagger/index.cjs +0 -1021
- package/dist/server-swagger/index.cjs.map +0 -1
- package/dist/server-swagger/index.d.cts +0 -382
- package/dist/sms/index.cjs +0 -221
- package/dist/sms/index.cjs.map +0 -1
- package/dist/sms/index.d.cts +0 -130
- package/dist/thread/index.cjs +0 -350
- package/dist/thread/index.cjs.map +0 -1
- package/dist/thread/index.d.cts +0 -260
- package/dist/topic/index.cjs +0 -282
- package/dist/topic/index.cjs.map +0 -1
- package/dist/topic/index.d.cts +0 -523
- package/dist/topic-redis/index.cjs +0 -71
- package/dist/topic-redis/index.cjs.map +0 -1
- package/dist/topic-redis/index.d.cts +0 -42
- package/dist/vite/index.cjs +0 -1077
- package/dist/vite/index.cjs.map +0 -1
- package/dist/vite/index.d.cts +0 -542
- package/dist/websocket/index.cjs +0 -1117
- package/dist/websocket/index.cjs.map +0 -1
- package/dist/websocket/index.d.cts +0 -861
- package/src/api-notifications/providers/MemorySmsProvider.ts +0 -20
- package/src/api-notifications/providers/SmsProvider.ts +0 -8
- /package/src/core/{descriptors → primitives}/$atom.ts +0 -0
- /package/src/core/{descriptors → primitives}/$env.ts +0 -0
- /package/src/server-auth/{descriptors → primitives}/$authApple.ts +0 -0
- /package/src/server-links/{descriptors → primitives}/$client.ts +0 -0
package/dist/batch/index.cjs
DELETED
|
@@ -1,408 +0,0 @@
|
|
|
1
|
-
let alepha = require("alepha");
|
|
2
|
-
let node_crypto = require("node:crypto");
|
|
3
|
-
let alepha_datetime = require("alepha/datetime");
|
|
4
|
-
let alepha_logger = require("alepha/logger");
|
|
5
|
-
let alepha_retry = require("alepha/retry");
|
|
6
|
-
|
|
7
|
-
//#region src/batch/providers/BatchProvider.ts
|
|
8
|
-
/**
|
|
9
|
-
* Service for batch processing operations.
|
|
10
|
-
* Provides methods to manage batches of items with automatic flushing based on size or time.
|
|
11
|
-
*/
|
|
12
|
-
var BatchProvider = class {
|
|
13
|
-
log = (0, alepha_logger.$logger)();
|
|
14
|
-
dateTime = (0, alepha.$inject)(alepha_datetime.DateTimeProvider);
|
|
15
|
-
retryProvider = (0, alepha.$inject)(alepha_retry.RetryProvider);
|
|
16
|
-
/**
|
|
17
|
-
* Creates a new batch context with the given options.
|
|
18
|
-
*/
|
|
19
|
-
createContext(alepha$1, options) {
|
|
20
|
-
return {
|
|
21
|
-
options,
|
|
22
|
-
itemStates: /* @__PURE__ */ new Map(),
|
|
23
|
-
partitions: /* @__PURE__ */ new Map(),
|
|
24
|
-
activeHandlers: [],
|
|
25
|
-
isShuttingDown: false,
|
|
26
|
-
isReady: false,
|
|
27
|
-
alepha: alepha$1
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Get the effective maxSize for a context.
|
|
32
|
-
*/
|
|
33
|
-
getMaxSize(context) {
|
|
34
|
-
return context.options.maxSize ?? 10;
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Get the effective concurrency for a context.
|
|
38
|
-
*/
|
|
39
|
-
getConcurrency(context) {
|
|
40
|
-
return context.options.concurrency ?? 1;
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* Get the effective maxDuration for a context.
|
|
44
|
-
*/
|
|
45
|
-
getMaxDuration(context) {
|
|
46
|
-
return context.options.maxDuration ?? [1, "second"];
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* Pushes an item into the batch and returns immediately with a unique ID.
|
|
50
|
-
* The item will be processed asynchronously with other items when the batch is flushed.
|
|
51
|
-
* Use wait(id) to get the processing result.
|
|
52
|
-
*
|
|
53
|
-
* @throws Error if maxQueueSize is exceeded
|
|
54
|
-
*/
|
|
55
|
-
push(context, item) {
|
|
56
|
-
const id = (0, node_crypto.randomUUID)();
|
|
57
|
-
let partitionKey;
|
|
58
|
-
try {
|
|
59
|
-
partitionKey = context.options.partitionBy ? context.options.partitionBy(item) : "default";
|
|
60
|
-
} catch (error) {
|
|
61
|
-
this.log.warn("partitionBy function threw an error, using 'default' partition", { error });
|
|
62
|
-
partitionKey = "default";
|
|
63
|
-
}
|
|
64
|
-
const itemState = {
|
|
65
|
-
id,
|
|
66
|
-
item,
|
|
67
|
-
partitionKey,
|
|
68
|
-
status: "pending"
|
|
69
|
-
};
|
|
70
|
-
this.log.trace("Pushing item to batch", {
|
|
71
|
-
id,
|
|
72
|
-
partitionKey,
|
|
73
|
-
item
|
|
74
|
-
});
|
|
75
|
-
context.itemStates.set(id, itemState);
|
|
76
|
-
if (!context.partitions.has(partitionKey)) context.partitions.set(partitionKey, {
|
|
77
|
-
itemIds: [],
|
|
78
|
-
flushing: false
|
|
79
|
-
});
|
|
80
|
-
const partition = context.partitions.get(partitionKey);
|
|
81
|
-
if (context.options.maxQueueSize !== void 0 && partition.itemIds.length >= context.options.maxQueueSize) throw new Error(`Batch queue size exceeded for partition '${partitionKey}' (max: ${context.options.maxQueueSize})`);
|
|
82
|
-
partition.itemIds.push(id);
|
|
83
|
-
const maxSize = this.getMaxSize(context);
|
|
84
|
-
const maxDuration = this.getMaxDuration(context);
|
|
85
|
-
if (context.isReady) {
|
|
86
|
-
if (partition.itemIds.length >= maxSize) {
|
|
87
|
-
this.log.trace(`Batch partition '${partitionKey}' is full, flushing...`);
|
|
88
|
-
this.flushPartition(context, partitionKey).catch((error) => this.log.error(`Failed to flush batch partition '${partitionKey}' on max size`, error));
|
|
89
|
-
} else if (!partition.timeout && !partition.flushing) partition.timeout = this.dateTime.createTimeout(() => {
|
|
90
|
-
this.log.trace(`Batch partition '${partitionKey}' timed out, flushing...`);
|
|
91
|
-
this.flushPartition(context, partitionKey).catch((error) => this.log.error(`Failed to flush batch partition '${partitionKey}' on timeout`, error));
|
|
92
|
-
}, maxDuration);
|
|
93
|
-
} else this.log.trace(`Buffering item in partition '${partitionKey}' (app not ready yet, ${partition.itemIds.length} items buffered)`);
|
|
94
|
-
return id;
|
|
95
|
-
}
|
|
96
|
-
/**
|
|
97
|
-
* Wait for a specific item to be processed and get its result.
|
|
98
|
-
* @param id The item ID returned from push()
|
|
99
|
-
* @returns The processing result
|
|
100
|
-
* @throws If the item doesn't exist or processing failed
|
|
101
|
-
*/
|
|
102
|
-
async wait(context, id) {
|
|
103
|
-
const itemState = context.itemStates.get(id);
|
|
104
|
-
if (!itemState) throw new Error(`Item with id '${id}' not found`);
|
|
105
|
-
if (itemState.status === "completed") return itemState.result;
|
|
106
|
-
if (itemState.status === "failed") throw itemState.error;
|
|
107
|
-
if (!itemState.promise) itemState.promise = new Promise((resolve, reject) => {
|
|
108
|
-
itemState.resolve = resolve;
|
|
109
|
-
itemState.reject = reject;
|
|
110
|
-
});
|
|
111
|
-
return itemState.promise;
|
|
112
|
-
}
|
|
113
|
-
/**
|
|
114
|
-
* Get the current status of an item.
|
|
115
|
-
* @param id The item ID returned from push()
|
|
116
|
-
* @returns Status information or undefined if item doesn't exist
|
|
117
|
-
*/
|
|
118
|
-
status(context, id) {
|
|
119
|
-
const itemState = context.itemStates.get(id);
|
|
120
|
-
if (!itemState) return;
|
|
121
|
-
if (itemState.status === "completed") return {
|
|
122
|
-
status: "completed",
|
|
123
|
-
result: itemState.result
|
|
124
|
-
};
|
|
125
|
-
if (itemState.status === "failed") return {
|
|
126
|
-
status: "failed",
|
|
127
|
-
error: itemState.error
|
|
128
|
-
};
|
|
129
|
-
return { status: itemState.status };
|
|
130
|
-
}
|
|
131
|
-
/**
|
|
132
|
-
* Clears completed and failed items from the context to free memory.
|
|
133
|
-
* Returns the number of items cleared.
|
|
134
|
-
*
|
|
135
|
-
* @param context The batch context
|
|
136
|
-
* @param status Optional: only clear items with this specific status ('completed' or 'failed')
|
|
137
|
-
* @returns The number of items cleared
|
|
138
|
-
*/
|
|
139
|
-
clearCompleted(context, status) {
|
|
140
|
-
let count = 0;
|
|
141
|
-
for (const [id, state] of context.itemStates) if (status) {
|
|
142
|
-
if (state.status === status) {
|
|
143
|
-
context.itemStates.delete(id);
|
|
144
|
-
count++;
|
|
145
|
-
}
|
|
146
|
-
} else if (state.status === "completed" || state.status === "failed") {
|
|
147
|
-
context.itemStates.delete(id);
|
|
148
|
-
count++;
|
|
149
|
-
}
|
|
150
|
-
return count;
|
|
151
|
-
}
|
|
152
|
-
/**
|
|
153
|
-
* Flush all partitions or a specific partition.
|
|
154
|
-
*/
|
|
155
|
-
async flush(context, partitionKey) {
|
|
156
|
-
const promises = [];
|
|
157
|
-
if (partitionKey) {
|
|
158
|
-
if (context.partitions.has(partitionKey)) promises.push(this.flushPartition(context, partitionKey));
|
|
159
|
-
} else for (const key of context.partitions.keys()) promises.push(this.flushPartition(context, key));
|
|
160
|
-
await Promise.all(promises);
|
|
161
|
-
}
|
|
162
|
-
/**
|
|
163
|
-
* Flush a specific partition.
|
|
164
|
-
*/
|
|
165
|
-
async flushPartition(context, partitionKey, limit) {
|
|
166
|
-
const partition = context.partitions.get(partitionKey);
|
|
167
|
-
if (!partition || partition.itemIds.length === 0) {
|
|
168
|
-
context.partitions.delete(partitionKey);
|
|
169
|
-
return;
|
|
170
|
-
}
|
|
171
|
-
partition.timeout?.clear();
|
|
172
|
-
partition.timeout = void 0;
|
|
173
|
-
const itemsToTake = limit !== void 0 ? Math.min(limit, partition.itemIds.length) : partition.itemIds.length;
|
|
174
|
-
const itemIdsToProcess = partition.itemIds.splice(0, itemsToTake);
|
|
175
|
-
partition.flushing = true;
|
|
176
|
-
const itemsToProcess = [];
|
|
177
|
-
for (const id of itemIdsToProcess) {
|
|
178
|
-
const itemState = context.itemStates.get(id);
|
|
179
|
-
if (itemState) {
|
|
180
|
-
itemState.status = "processing";
|
|
181
|
-
itemsToProcess.push(itemState.item);
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
const concurrency = this.getConcurrency(context);
|
|
185
|
-
const maxDuration = this.getMaxDuration(context);
|
|
186
|
-
while (context.activeHandlers.length >= concurrency) {
|
|
187
|
-
this.log.trace(`Batch handler is at concurrency limit, waiting for a slot...`);
|
|
188
|
-
await Promise.race(context.activeHandlers.map((it) => it.promise));
|
|
189
|
-
}
|
|
190
|
-
const promise = Promise.withResolvers();
|
|
191
|
-
context.activeHandlers.push(promise);
|
|
192
|
-
let result;
|
|
193
|
-
try {
|
|
194
|
-
result = await context.alepha.context.run(() => context.isShuttingDown ? context.options.handler(itemsToProcess) : this.retryProvider.retry({
|
|
195
|
-
...context.options.retry,
|
|
196
|
-
handler: context.options.handler
|
|
197
|
-
}, itemsToProcess));
|
|
198
|
-
for (const id of itemIdsToProcess) {
|
|
199
|
-
const itemState = context.itemStates.get(id);
|
|
200
|
-
if (itemState) {
|
|
201
|
-
itemState.status = "completed";
|
|
202
|
-
itemState.result = result;
|
|
203
|
-
itemState.resolve?.(result);
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
} catch (error) {
|
|
207
|
-
this.log.error(`Batch handler failed`, error);
|
|
208
|
-
for (const id of itemIdsToProcess) {
|
|
209
|
-
const itemState = context.itemStates.get(id);
|
|
210
|
-
if (itemState) {
|
|
211
|
-
itemState.status = "failed";
|
|
212
|
-
itemState.error = error;
|
|
213
|
-
itemState.reject?.(error);
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
} finally {
|
|
217
|
-
promise.resolve();
|
|
218
|
-
context.activeHandlers = context.activeHandlers.filter((it) => it !== promise);
|
|
219
|
-
const currentPartition = context.partitions.get(partitionKey);
|
|
220
|
-
if (currentPartition?.flushing && currentPartition.itemIds.length === 0) context.partitions.delete(partitionKey);
|
|
221
|
-
else if (currentPartition) {
|
|
222
|
-
currentPartition.flushing = false;
|
|
223
|
-
if (currentPartition.itemIds.length > 0 && !currentPartition.timeout) currentPartition.timeout = this.dateTime.createTimeout(() => {
|
|
224
|
-
this.log.trace(`Batch partition '${partitionKey}' timed out, flushing...`);
|
|
225
|
-
this.flushPartition(context, partitionKey).catch((error) => this.log.error(`Failed to flush batch partition '${partitionKey}' on timeout`, error));
|
|
226
|
-
}, maxDuration);
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
/**
|
|
231
|
-
* Mark the context as ready and start processing buffered items.
|
|
232
|
-
* Called after the "ready" hook.
|
|
233
|
-
*/
|
|
234
|
-
async markReady(context) {
|
|
235
|
-
this.log.debug("Batch processor is now ready, starting to process buffered items...");
|
|
236
|
-
context.isReady = true;
|
|
237
|
-
await this.startProcessing(context);
|
|
238
|
-
}
|
|
239
|
-
/**
|
|
240
|
-
* Mark the context as shutting down and flush all remaining items.
|
|
241
|
-
*/
|
|
242
|
-
async shutdown(context) {
|
|
243
|
-
this.log.debug("Flushing all remaining batch partitions on shutdown...");
|
|
244
|
-
context.isShuttingDown = true;
|
|
245
|
-
await this.flush(context);
|
|
246
|
-
this.log.debug("All batch partitions flushed");
|
|
247
|
-
}
|
|
248
|
-
/**
|
|
249
|
-
* Called after the "ready" hook to start processing buffered items that were
|
|
250
|
-
* pushed during startup. This checks all partitions and starts timeouts/flushes
|
|
251
|
-
* for items that were accumulated before the app was ready.
|
|
252
|
-
*/
|
|
253
|
-
async startProcessing(context) {
|
|
254
|
-
const maxSize = this.getMaxSize(context);
|
|
255
|
-
const maxDuration = this.getMaxDuration(context);
|
|
256
|
-
for (const [partitionKey, partition] of context.partitions.entries()) {
|
|
257
|
-
if (partition.itemIds.length === 0) continue;
|
|
258
|
-
this.log.trace(`Starting processing for partition '${partitionKey}' with ${partition.itemIds.length} buffered items`);
|
|
259
|
-
while (partition.itemIds.length >= maxSize) {
|
|
260
|
-
this.log.trace(`Partition '${partitionKey}' has ${partition.itemIds.length} items, flushing batch of ${maxSize}...`);
|
|
261
|
-
await this.flushPartition(context, partitionKey, maxSize);
|
|
262
|
-
}
|
|
263
|
-
if (partition.itemIds.length > 0 && !partition.timeout && !partition.flushing) {
|
|
264
|
-
this.log.trace(`Starting timeout for partition '${partitionKey}' with ${partition.itemIds.length} remaining items`);
|
|
265
|
-
partition.timeout = this.dateTime.createTimeout(() => {
|
|
266
|
-
this.log.trace(`Batch partition '${partitionKey}' timed out, flushing...`);
|
|
267
|
-
this.flushPartition(context, partitionKey).catch((error) => this.log.error(`Failed to flush partition '${partitionKey}' on timeout after startup`, error));
|
|
268
|
-
}, maxDuration);
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
};
|
|
273
|
-
|
|
274
|
-
//#endregion
|
|
275
|
-
//#region src/batch/descriptors/$batch.ts
|
|
276
|
-
/**
|
|
277
|
-
* Creates a batch processing descriptor for efficient grouping and processing of multiple operations.
|
|
278
|
-
*/
|
|
279
|
-
const $batch = (options) => (0, alepha.createDescriptor)(BatchDescriptor, options);
|
|
280
|
-
var BatchDescriptor = class extends alepha.Descriptor {
|
|
281
|
-
batchProvider = (0, alepha.$inject)(BatchProvider);
|
|
282
|
-
context;
|
|
283
|
-
constructor(...args) {
|
|
284
|
-
super(...args);
|
|
285
|
-
this.context = this.batchProvider.createContext(this.alepha, {
|
|
286
|
-
handler: this.options.handler,
|
|
287
|
-
maxSize: this.options.maxSize,
|
|
288
|
-
maxQueueSize: this.options.maxQueueSize,
|
|
289
|
-
maxDuration: this.options.maxDuration,
|
|
290
|
-
partitionBy: this.options.partitionBy,
|
|
291
|
-
concurrency: this.options.concurrency,
|
|
292
|
-
retry: this.options.retry
|
|
293
|
-
});
|
|
294
|
-
}
|
|
295
|
-
/**
|
|
296
|
-
* Pushes an item into the batch and returns immediately with a unique ID.
|
|
297
|
-
* The item will be processed asynchronously with other items when the batch is flushed.
|
|
298
|
-
* Use wait(id) to get the processing result.
|
|
299
|
-
*/
|
|
300
|
-
async push(item) {
|
|
301
|
-
const validatedItem = this.alepha.codec.validate(this.options.schema, item);
|
|
302
|
-
return this.batchProvider.push(this.context, validatedItem);
|
|
303
|
-
}
|
|
304
|
-
/**
|
|
305
|
-
* Wait for a specific item to be processed and get its result.
|
|
306
|
-
* @param id The item ID returned from push()
|
|
307
|
-
* @returns The processing result
|
|
308
|
-
* @throws If the item doesn't exist or processing failed
|
|
309
|
-
*/
|
|
310
|
-
async wait(id) {
|
|
311
|
-
return this.batchProvider.wait(this.context, id);
|
|
312
|
-
}
|
|
313
|
-
/**
|
|
314
|
-
* Get the current status of an item.
|
|
315
|
-
* @param id The item ID returned from push()
|
|
316
|
-
* @returns Status information or undefined if item doesn't exist
|
|
317
|
-
*/
|
|
318
|
-
status(id) {
|
|
319
|
-
return this.batchProvider.status(this.context, id);
|
|
320
|
-
}
|
|
321
|
-
/**
|
|
322
|
-
* Flush all partitions or a specific partition.
|
|
323
|
-
*/
|
|
324
|
-
async flush(partitionKey) {
|
|
325
|
-
return this.batchProvider.flush(this.context, partitionKey);
|
|
326
|
-
}
|
|
327
|
-
/**
|
|
328
|
-
* Clears completed and failed items from memory.
|
|
329
|
-
* Call this periodically in long-running applications to prevent memory leaks.
|
|
330
|
-
*
|
|
331
|
-
* @param status Optional: only clear items with this specific status ('completed' or 'failed')
|
|
332
|
-
* @returns The number of items cleared
|
|
333
|
-
*/
|
|
334
|
-
clearCompleted(status) {
|
|
335
|
-
return this.batchProvider.clearCompleted(this.context, status);
|
|
336
|
-
}
|
|
337
|
-
onReady = (0, alepha.$hook)({
|
|
338
|
-
on: "ready",
|
|
339
|
-
handler: async () => {
|
|
340
|
-
await this.batchProvider.markReady(this.context);
|
|
341
|
-
}
|
|
342
|
-
});
|
|
343
|
-
dispose = (0, alepha.$hook)({
|
|
344
|
-
on: "stop",
|
|
345
|
-
priority: "first",
|
|
346
|
-
handler: async () => {
|
|
347
|
-
await this.batchProvider.shutdown(this.context);
|
|
348
|
-
}
|
|
349
|
-
});
|
|
350
|
-
};
|
|
351
|
-
$batch[alepha.KIND] = BatchDescriptor;
|
|
352
|
-
|
|
353
|
-
//#endregion
|
|
354
|
-
//#region src/batch/index.ts
|
|
355
|
-
/**
|
|
356
|
-
* This module allows you to group multiple asynchronous operations into a single "batch," which is then processed together.
|
|
357
|
-
* This is an essential pattern for improving performance, reducing I/O, and interacting efficiently with rate-limited APIs or databases.
|
|
358
|
-
*
|
|
359
|
-
* ```ts
|
|
360
|
-
* import { Alepha, $hook, run, t } from "alepha";
|
|
361
|
-
* import { $batch } from "alepha/batch";
|
|
362
|
-
*
|
|
363
|
-
* class LoggingService {
|
|
364
|
-
* // define the batch processor
|
|
365
|
-
* logBatch = $batch({
|
|
366
|
-
* schema: t.text(),
|
|
367
|
-
* maxSize: 10,
|
|
368
|
-
* maxDuration: [5, "seconds"],
|
|
369
|
-
* handler: async (items) => {
|
|
370
|
-
* console.log(`[BATCH LOG] Processing ${items.length} events:`, items);
|
|
371
|
-
* },
|
|
372
|
-
* });
|
|
373
|
-
*
|
|
374
|
-
* // example of how to use it
|
|
375
|
-
* onReady = $hook({
|
|
376
|
-
* on: "ready",
|
|
377
|
-
* handler: async () => {
|
|
378
|
-
* // push() returns an ID immediately
|
|
379
|
-
* const id1 = await this.logBatch.push("Application started.");
|
|
380
|
-
* const id2 = await this.logBatch.push("User authenticated.");
|
|
381
|
-
*
|
|
382
|
-
* // optionally wait for processing to complete
|
|
383
|
-
* await this.logBatch.wait(id1);
|
|
384
|
-
*
|
|
385
|
-
* // or check the status
|
|
386
|
-
* const status = this.logBatch.status(id2);
|
|
387
|
-
* console.log(status?.status); // "pending" | "processing" | "completed" | "failed"
|
|
388
|
-
* },
|
|
389
|
-
* });
|
|
390
|
-
* }
|
|
391
|
-
* ```
|
|
392
|
-
*
|
|
393
|
-
* @see {@link $batch}
|
|
394
|
-
* @see {@link BatchProvider}
|
|
395
|
-
* @module alepha.batch
|
|
396
|
-
*/
|
|
397
|
-
const AlephaBatch = (0, alepha.$module)({
|
|
398
|
-
name: "alepha.batch",
|
|
399
|
-
descriptors: [$batch],
|
|
400
|
-
services: [BatchProvider]
|
|
401
|
-
});
|
|
402
|
-
|
|
403
|
-
//#endregion
|
|
404
|
-
exports.$batch = $batch;
|
|
405
|
-
exports.AlephaBatch = AlephaBatch;
|
|
406
|
-
exports.BatchDescriptor = BatchDescriptor;
|
|
407
|
-
exports.BatchProvider = BatchProvider;
|
|
408
|
-
//# sourceMappingURL=index.cjs.map
|
package/dist/batch/index.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["DateTimeProvider","RetryProvider","partitionKey: string","itemState: BatchItemState<TItem, TResponse>","promises: Promise<void>[]","itemsToProcess: TItem[]","result: any","Descriptor","KIND"],"sources":["../../src/batch/providers/BatchProvider.ts","../../src/batch/descriptors/$batch.ts","../../src/batch/index.ts"],"sourcesContent":["import { randomUUID } from \"node:crypto\";\nimport { $inject, type Alepha } from \"alepha\";\nimport { DateTimeProvider, type DurationLike } from \"alepha/datetime\";\nimport { $logger } from \"alepha/logger\";\nimport { type RetryBackoffOptions, RetryProvider } from \"alepha/retry\";\n\n// ---------------------------------------------------------------------------------------------------------------------\n\nexport interface BatchOptions<TItem, TResponse = any> {\n /**\n * The batch processing handler function that processes arrays of validated items.\n */\n handler: (items: TItem[]) => TResponse;\n\n /**\n * Maximum number of items to collect before automatically flushing the batch.\n *\n * @default 10\n */\n maxSize?: number;\n\n /**\n * Maximum number of items that can be queued in a single partition.\n * If exceeded, push() will throw an error.\n */\n maxQueueSize?: number;\n\n /**\n * Maximum time to wait before flushing a batch, even if it hasn't reached maxSize.\n *\n * @default [1, \"second\"]\n */\n maxDuration?: DurationLike;\n\n /**\n * Function to determine partition keys for grouping items into separate batches.\n */\n partitionBy?: (item: TItem) => string;\n\n /**\n * Maximum number of batch handlers that can execute simultaneously.\n *\n * @default 1\n */\n concurrency?: number;\n\n /**\n * Retry configuration for failed batch processing operations.\n */\n retry?: {\n /**\n * The maximum number of attempts.\n *\n * @default 3\n */\n max?: number;\n\n /**\n * The backoff strategy for delays between retries.\n * Can be a fixed number (in ms) or a configuration object for exponential backoff.\n *\n * @default { initial: 200, factor: 2, jitter: true }\n */\n backoff?: number | RetryBackoffOptions;\n\n /**\n * An overall time limit for all retry attempts combined.\n *\n * e.g., `[5, 'seconds']`\n */\n maxDuration?: DurationLike;\n\n /**\n * A function that determines if a retry should be attempted based on the error.\n *\n * @default (error) => true (retries on any error)\n */\n when?: (error: Error) => boolean;\n\n /**\n * A custom callback for when a retry attempt fails.\n * This is called before the delay.\n */\n onError?: (error: Error, attempt: number) => void;\n };\n}\n\n// ---------------------------------------------------------------------------------------------------------------------\n\nexport type BatchItemStatus = \"pending\" | \"processing\" | \"completed\" | \"failed\";\n\nexport interface BatchItemState<TItem, TResponse> {\n id: string;\n item: TItem;\n partitionKey: string;\n status: BatchItemStatus;\n result?: TResponse;\n error?: Error;\n promise?: Promise<TResponse>;\n resolve?: (value: TResponse) => void;\n reject?: (error: Error) => void;\n}\n\nexport interface PartitionState {\n itemIds: string[];\n timeout?: { clear: () => void };\n flushing: boolean;\n}\n\n/**\n * Context object that holds all state for a batch processor instance.\n */\nexport interface BatchContext<TItem, TResponse> {\n options: BatchOptions<TItem, TResponse>;\n itemStates: Map<string, BatchItemState<TItem, TResponse>>;\n partitions: Map<string, PartitionState>;\n activeHandlers: PromiseWithResolvers<void>[];\n isShuttingDown: boolean;\n isReady: boolean;\n alepha: Alepha;\n}\n\n// ---------------------------------------------------------------------------------------------------------------------\n\n/**\n * Service for batch processing operations.\n * Provides methods to manage batches of items with automatic flushing based on size or time.\n */\nexport class BatchProvider {\n protected readonly log = $logger();\n protected readonly dateTime = $inject(DateTimeProvider);\n protected readonly retryProvider = $inject(RetryProvider);\n\n /**\n * Creates a new batch context with the given options.\n */\n createContext<TItem, TResponse>(\n alepha: Alepha,\n options: BatchOptions<TItem, TResponse>,\n ): BatchContext<TItem, TResponse> {\n return {\n options,\n itemStates: new Map(),\n partitions: new Map(),\n activeHandlers: [],\n isShuttingDown: false,\n isReady: false,\n alepha,\n };\n }\n\n /**\n * Get the effective maxSize for a context.\n */\n protected getMaxSize<TItem, TResponse>(\n context: BatchContext<TItem, TResponse>,\n ): number {\n return context.options.maxSize ?? 10;\n }\n\n /**\n * Get the effective concurrency for a context.\n */\n protected getConcurrency<TItem, TResponse>(\n context: BatchContext<TItem, TResponse>,\n ): number {\n return context.options.concurrency ?? 1;\n }\n\n /**\n * Get the effective maxDuration for a context.\n */\n protected getMaxDuration<TItem, TResponse>(\n context: BatchContext<TItem, TResponse>,\n ): DurationLike {\n return context.options.maxDuration ?? [1, \"second\"];\n }\n\n /**\n * Pushes an item into the batch and returns immediately with a unique ID.\n * The item will be processed asynchronously with other items when the batch is flushed.\n * Use wait(id) to get the processing result.\n *\n * @throws Error if maxQueueSize is exceeded\n */\n push<TItem, TResponse>(\n context: BatchContext<TItem, TResponse>,\n item: TItem,\n ): string {\n // 1. Generate unique ID\n const id = randomUUID();\n\n // 2. Determine the partition key (with error handling)\n let partitionKey: string;\n try {\n partitionKey = context.options.partitionBy\n ? context.options.partitionBy(item)\n : \"default\";\n } catch (error) {\n this.log.warn(\n \"partitionBy function threw an error, using 'default' partition\",\n { error },\n );\n partitionKey = \"default\";\n }\n\n // 3. Create item state\n const itemState: BatchItemState<TItem, TResponse> = {\n id,\n item,\n partitionKey,\n status: \"pending\",\n };\n\n // CAUTION: Do not log.debug/info here as it may cause infinite loops if logging is batched\n // log.trace is safe\n\n this.log.trace(\"Pushing item to batch\", {\n id,\n partitionKey,\n item,\n });\n\n context.itemStates.set(id, itemState);\n\n // 4. Get or create the partition state\n if (!context.partitions.has(partitionKey)) {\n context.partitions.set(partitionKey, {\n itemIds: [],\n flushing: false,\n });\n }\n const partition = context.partitions.get(partitionKey)!;\n\n // 5. Check maxQueueSize before adding\n if (\n context.options.maxQueueSize !== undefined &&\n partition.itemIds.length >= context.options.maxQueueSize\n ) {\n throw new Error(\n `Batch queue size exceeded for partition '${partitionKey}' (max: ${context.options.maxQueueSize})`,\n );\n }\n\n // 6. Add item ID to partition\n partition.itemIds.push(id);\n\n const maxSize = this.getMaxSize(context);\n const maxDuration = this.getMaxDuration(context);\n\n // 7. Only start processing if the app is ready (after \"ready\" hook)\n // During startup, items are just buffered in memory\n if (context.isReady) {\n // Check if the batch is full\n if (partition.itemIds.length >= maxSize) {\n this.log.trace(\n `Batch partition '${partitionKey}' is full, flushing...`,\n );\n this.flushPartition(context, partitionKey).catch((error) =>\n this.log.error(\n `Failed to flush batch partition '${partitionKey}' on max size`,\n error,\n ),\n );\n } else if (!partition.timeout && !partition.flushing) {\n // 8. Start the timeout if it's not already running for this partition and not currently flushing\n partition.timeout = this.dateTime.createTimeout(() => {\n this.log.trace(\n `Batch partition '${partitionKey}' timed out, flushing...`,\n );\n this.flushPartition(context, partitionKey).catch((error) =>\n this.log.error(\n `Failed to flush batch partition '${partitionKey}' on timeout`,\n error,\n ),\n );\n }, maxDuration);\n }\n } else {\n // Not ready yet - just buffer items, no size checks or timeouts\n this.log.trace(\n `Buffering item in partition '${partitionKey}' (app not ready yet, ${partition.itemIds.length} items buffered)`,\n );\n }\n\n // 9. Return ID immediately\n return id;\n }\n\n /**\n * Wait for a specific item to be processed and get its result.\n * @param id The item ID returned from push()\n * @returns The processing result\n * @throws If the item doesn't exist or processing failed\n */\n async wait<TItem, TResponse>(\n context: BatchContext<TItem, TResponse>,\n id: string,\n ): Promise<TResponse> {\n const itemState = context.itemStates.get(id);\n if (!itemState) {\n throw new Error(`Item with id '${id}' not found`);\n }\n\n // If already completed or failed, return immediately\n if (itemState.status === \"completed\") {\n return itemState.result!;\n }\n if (itemState.status === \"failed\") {\n throw itemState.error!;\n }\n\n // Create promise on-demand if not already created\n if (!itemState.promise) {\n itemState.promise = new Promise<TResponse>((resolve, reject) => {\n itemState.resolve = resolve;\n itemState.reject = reject;\n });\n }\n\n return itemState.promise;\n }\n\n /**\n * Get the current status of an item.\n * @param id The item ID returned from push()\n * @returns Status information or undefined if item doesn't exist\n */\n status<TItem, TResponse>(\n context: BatchContext<TItem, TResponse>,\n id: string,\n ):\n | { status: \"pending\" | \"processing\" }\n | { status: \"completed\"; result: TResponse }\n | { status: \"failed\"; error: Error }\n | undefined {\n const itemState = context.itemStates.get(id);\n if (!itemState) {\n return undefined;\n }\n\n if (itemState.status === \"completed\") {\n return { status: \"completed\", result: itemState.result! };\n }\n if (itemState.status === \"failed\") {\n return { status: \"failed\", error: itemState.error! };\n }\n return { status: itemState.status };\n }\n\n /**\n * Clears completed and failed items from the context to free memory.\n * Returns the number of items cleared.\n *\n * @param context The batch context\n * @param status Optional: only clear items with this specific status ('completed' or 'failed')\n * @returns The number of items cleared\n */\n clearCompleted<TItem, TResponse>(\n context: BatchContext<TItem, TResponse>,\n status?: \"completed\" | \"failed\",\n ): number {\n let count = 0;\n for (const [id, state] of context.itemStates) {\n if (status) {\n if (state.status === status) {\n context.itemStates.delete(id);\n count++;\n }\n } else if (state.status === \"completed\" || state.status === \"failed\") {\n context.itemStates.delete(id);\n count++;\n }\n }\n return count;\n }\n\n /**\n * Flush all partitions or a specific partition.\n */\n async flush<TItem, TResponse>(\n context: BatchContext<TItem, TResponse>,\n partitionKey?: string,\n ): Promise<void> {\n const promises: Promise<void>[] = [];\n if (partitionKey) {\n if (context.partitions.has(partitionKey)) {\n promises.push(this.flushPartition(context, partitionKey));\n }\n } else {\n for (const key of context.partitions.keys()) {\n promises.push(this.flushPartition(context, key));\n }\n }\n await Promise.all(promises);\n }\n\n /**\n * Flush a specific partition.\n */\n protected async flushPartition<TItem, TResponse>(\n context: BatchContext<TItem, TResponse>,\n partitionKey: string,\n limit?: number,\n ): Promise<void> {\n const partition = context.partitions.get(partitionKey);\n if (!partition || partition.itemIds.length === 0) {\n context.partitions.delete(partitionKey);\n return;\n }\n\n // Clear the timeout and grab the item IDs (up to limit if specified)\n partition.timeout?.clear();\n partition.timeout = undefined;\n const itemsToTake =\n limit !== undefined\n ? Math.min(limit, partition.itemIds.length)\n : partition.itemIds.length;\n const itemIdsToProcess = partition.itemIds.splice(0, itemsToTake);\n\n // Mark partition as flushing to prevent race conditions\n partition.flushing = true;\n\n // Get the items and mark them as processing\n const itemsToProcess: TItem[] = [];\n for (const id of itemIdsToProcess) {\n const itemState = context.itemStates.get(id);\n if (itemState) {\n itemState.status = \"processing\";\n itemsToProcess.push(itemState.item);\n }\n }\n\n const concurrency = this.getConcurrency(context);\n const maxDuration = this.getMaxDuration(context);\n\n // Wait until there's a free slot (if at concurrency limit)\n while (context.activeHandlers.length >= concurrency) {\n this.log.trace(\n `Batch handler is at concurrency limit, waiting for a slot...`,\n );\n // Wait for any single handler to complete, not all of them\n await Promise.race(context.activeHandlers.map((it) => it.promise));\n }\n\n const promise = Promise.withResolvers<void>();\n context.activeHandlers.push(promise);\n let result: any;\n try {\n result = await context.alepha.context.run(() =>\n // during shutdown, call handler directly to avoid retry cancellation\n context.isShuttingDown\n ? context.options.handler(itemsToProcess)\n : this.retryProvider.retry(\n {\n ...context.options.retry,\n handler: context.options.handler,\n },\n itemsToProcess,\n ),\n );\n\n // Mark all items as completed and resolve their promises\n for (const id of itemIdsToProcess) {\n const itemState = context.itemStates.get(id);\n if (itemState) {\n itemState.status = \"completed\";\n itemState.result = result;\n // Only resolve if someone is waiting\n itemState.resolve?.(result);\n }\n }\n } catch (error) {\n this.log.error(`Batch handler failed`, error);\n\n // Mark all items as failed and reject their promises\n for (const id of itemIdsToProcess) {\n const itemState = context.itemStates.get(id);\n if (itemState) {\n itemState.status = \"failed\";\n itemState.error = error as Error;\n // Only reject if someone is waiting (promise was created)\n itemState.reject?.(error as Error);\n }\n }\n } finally {\n promise.resolve();\n context.activeHandlers = context.activeHandlers.filter(\n (it) => it !== promise,\n );\n\n // Only delete partition if no new items arrived during processing\n const currentPartition = context.partitions.get(partitionKey);\n if (currentPartition?.flushing && currentPartition.itemIds.length === 0) {\n context.partitions.delete(partitionKey);\n } else if (currentPartition) {\n // Reset flushing flag if partition still exists with items\n currentPartition.flushing = false;\n\n // Restart timeout for items that arrived during flush\n if (currentPartition.itemIds.length > 0 && !currentPartition.timeout) {\n currentPartition.timeout = this.dateTime.createTimeout(() => {\n this.log.trace(\n `Batch partition '${partitionKey}' timed out, flushing...`,\n );\n this.flushPartition(context, partitionKey).catch((error) =>\n this.log.error(\n `Failed to flush batch partition '${partitionKey}' on timeout`,\n error,\n ),\n );\n }, maxDuration);\n }\n }\n }\n }\n\n /**\n * Mark the context as ready and start processing buffered items.\n * Called after the \"ready\" hook.\n */\n async markReady<TItem, TResponse>(\n context: BatchContext<TItem, TResponse>,\n ): Promise<void> {\n this.log.debug(\n \"Batch processor is now ready, starting to process buffered items...\",\n );\n context.isReady = true;\n await this.startProcessing(context);\n }\n\n /**\n * Mark the context as shutting down and flush all remaining items.\n */\n async shutdown<TItem, TResponse>(\n context: BatchContext<TItem, TResponse>,\n ): Promise<void> {\n this.log.debug(\"Flushing all remaining batch partitions on shutdown...\");\n context.isShuttingDown = true;\n await this.flush(context);\n this.log.debug(\"All batch partitions flushed\");\n }\n\n /**\n * Called after the \"ready\" hook to start processing buffered items that were\n * pushed during startup. This checks all partitions and starts timeouts/flushes\n * for items that were accumulated before the app was ready.\n */\n protected async startProcessing<TItem, TResponse>(\n context: BatchContext<TItem, TResponse>,\n ): Promise<void> {\n const maxSize = this.getMaxSize(context);\n const maxDuration = this.getMaxDuration(context);\n\n for (const [partitionKey, partition] of context.partitions.entries()) {\n if (partition.itemIds.length === 0) {\n continue;\n }\n\n this.log.trace(\n `Starting processing for partition '${partitionKey}' with ${partition.itemIds.length} buffered items`,\n );\n\n // Flush batches of maxSize while we have items >= maxSize\n while (partition.itemIds.length >= maxSize) {\n this.log.trace(\n `Partition '${partitionKey}' has ${partition.itemIds.length} items, flushing batch of ${maxSize}...`,\n );\n await this.flushPartition(context, partitionKey, maxSize);\n }\n\n // After flushing full batches, start timeout for any remaining items\n if (\n partition.itemIds.length > 0 &&\n !partition.timeout &&\n !partition.flushing\n ) {\n this.log.trace(\n `Starting timeout for partition '${partitionKey}' with ${partition.itemIds.length} remaining items`,\n );\n partition.timeout = this.dateTime.createTimeout(() => {\n this.log.trace(\n `Batch partition '${partitionKey}' timed out, flushing...`,\n );\n this.flushPartition(context, partitionKey).catch((error) =>\n this.log.error(\n `Failed to flush partition '${partitionKey}' on timeout after startup`,\n error,\n ),\n );\n }, maxDuration);\n }\n }\n }\n}\n","import {\n $hook,\n $inject,\n createDescriptor,\n Descriptor,\n KIND,\n type Static,\n type TSchema,\n} from \"alepha\";\nimport type { DurationLike } from \"alepha/datetime\";\nimport type { RetryDescriptorOptions } from \"alepha/retry\";\nimport {\n type BatchContext,\n type BatchItemState,\n type BatchItemStatus,\n BatchProvider,\n} from \"../providers/BatchProvider.ts\";\n\n/**\n * Creates a batch processing descriptor for efficient grouping and processing of multiple operations.\n */\nexport const $batch = <TItem extends TSchema, TResponse>(\n options: BatchDescriptorOptions<TItem, TResponse>,\n): BatchDescriptor<TItem, TResponse> =>\n createDescriptor(BatchDescriptor<TItem, TResponse>, options);\n\n// ---------------------------------------------------------------------------------------------------------------------\n\nexport interface BatchDescriptorOptions<\n TItem extends TSchema,\n TResponse = any,\n> {\n /**\n * TypeBox schema for validating each item added to the batch.\n */\n schema: TItem;\n\n /**\n * The batch processing handler function that processes arrays of validated items.\n */\n handler: (items: Static<TItem>[]) => TResponse;\n\n /**\n * Maximum number of items to collect before automatically flushing the batch.\n */\n maxSize?: number;\n\n /**\n * Maximum number of items that can be queued in a single partition.\n * If exceeded, push() will throw an error.\n */\n maxQueueSize?: number;\n\n /**\n * Maximum time to wait before flushing a batch, even if it hasn't reached maxSize.\n */\n maxDuration?: DurationLike;\n\n /**\n * Function to determine partition keys for grouping items into separate batches.\n */\n partitionBy?: (item: Static<TItem>) => string;\n\n /**\n * Maximum number of batch handlers that can execute simultaneously.\n */\n concurrency?: number;\n\n /**\n * Retry configuration for failed batch processing operations.\n */\n retry?: Omit<RetryDescriptorOptions<() => Array<Static<TItem>>>, \"handler\">;\n}\n\n// ---------------------------------------------------------------------------------------------------------------------\n\nexport type { BatchItemState, BatchItemStatus };\n\n// ---------------------------------------------------------------------------------------------------------------------\n\nexport class BatchDescriptor<\n TItem extends TSchema,\n TResponse = any,\n> extends Descriptor<BatchDescriptorOptions<TItem, TResponse>> {\n protected readonly batchProvider = $inject(BatchProvider);\n protected readonly context: BatchContext<Static<TItem>, TResponse>;\n\n constructor(\n ...args: ConstructorParameters<\n typeof Descriptor<BatchDescriptorOptions<TItem, TResponse>>\n >\n ) {\n super(...args);\n this.context = this.batchProvider.createContext(this.alepha, {\n handler: this.options.handler,\n maxSize: this.options.maxSize,\n maxQueueSize: this.options.maxQueueSize,\n maxDuration: this.options.maxDuration,\n partitionBy: this.options.partitionBy,\n concurrency: this.options.concurrency,\n retry: this.options.retry,\n });\n }\n\n /**\n * Pushes an item into the batch and returns immediately with a unique ID.\n * The item will be processed asynchronously with other items when the batch is flushed.\n * Use wait(id) to get the processing result.\n */\n public async push(item: Static<TItem>): Promise<string> {\n // Validate the item against the schema\n const validatedItem = this.alepha.codec.validate(this.options.schema, item);\n return this.batchProvider.push(this.context, validatedItem);\n }\n\n /**\n * Wait for a specific item to be processed and get its result.\n * @param id The item ID returned from push()\n * @returns The processing result\n * @throws If the item doesn't exist or processing failed\n */\n public async wait(id: string): Promise<TResponse> {\n return this.batchProvider.wait(this.context, id);\n }\n\n /**\n * Get the current status of an item.\n * @param id The item ID returned from push()\n * @returns Status information or undefined if item doesn't exist\n */\n public status(\n id: string,\n ):\n | { status: \"pending\" | \"processing\" }\n | { status: \"completed\"; result: TResponse }\n | { status: \"failed\"; error: Error }\n | undefined {\n return this.batchProvider.status(this.context, id);\n }\n\n /**\n * Flush all partitions or a specific partition.\n */\n public async flush(partitionKey?: string): Promise<void> {\n return this.batchProvider.flush(this.context, partitionKey);\n }\n\n /**\n * Clears completed and failed items from memory.\n * Call this periodically in long-running applications to prevent memory leaks.\n *\n * @param status Optional: only clear items with this specific status ('completed' or 'failed')\n * @returns The number of items cleared\n */\n public clearCompleted(status?: \"completed\" | \"failed\"): number {\n return this.batchProvider.clearCompleted(this.context, status);\n }\n\n protected readonly onReady = $hook({\n on: \"ready\",\n handler: async () => {\n await this.batchProvider.markReady(this.context);\n },\n });\n\n protected readonly dispose = $hook({\n on: \"stop\",\n priority: \"first\",\n handler: async () => {\n await this.batchProvider.shutdown(this.context);\n },\n });\n}\n\n$batch[KIND] = BatchDescriptor;\n","import { $module } from \"alepha\";\nimport { $batch } from \"./descriptors/$batch.ts\";\nimport { BatchProvider } from \"./providers/BatchProvider.ts\";\n\n// ---------------------------------------------------------------------------------------------------------------------\n\nexport * from \"./descriptors/$batch.ts\";\nexport * from \"./providers/BatchProvider.ts\";\n\n// ---------------------------------------------------------------------------------------------------------------------\n\n/**\n * This module allows you to group multiple asynchronous operations into a single \"batch,\" which is then processed together.\n * This is an essential pattern for improving performance, reducing I/O, and interacting efficiently with rate-limited APIs or databases.\n *\n * ```ts\n * import { Alepha, $hook, run, t } from \"alepha\";\n * import { $batch } from \"alepha/batch\";\n *\n * class LoggingService {\n * // define the batch processor\n * logBatch = $batch({\n * schema: t.text(),\n * maxSize: 10,\n * maxDuration: [5, \"seconds\"],\n * handler: async (items) => {\n * console.log(`[BATCH LOG] Processing ${items.length} events:`, items);\n * },\n * });\n *\n * // example of how to use it\n * onReady = $hook({\n * on: \"ready\",\n * handler: async () => {\n * // push() returns an ID immediately\n * const id1 = await this.logBatch.push(\"Application started.\");\n * const id2 = await this.logBatch.push(\"User authenticated.\");\n *\n * // optionally wait for processing to complete\n * await this.logBatch.wait(id1);\n *\n * // or check the status\n * const status = this.logBatch.status(id2);\n * console.log(status?.status); // \"pending\" | \"processing\" | \"completed\" | \"failed\"\n * },\n * });\n * }\n * ```\n *\n * @see {@link $batch}\n * @see {@link BatchProvider}\n * @module alepha.batch\n */\nexport const AlephaBatch = $module({\n name: \"alepha.batch\",\n descriptors: [$batch],\n services: [BatchProvider],\n});\n"],"mappings":";;;;;;;;;;;AAgIA,IAAa,gBAAb,MAA2B;CACzB,AAAmB,kCAAe;CAClC,AAAmB,+BAAm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