alepha 0.18.2 → 0.18.3
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/assets/devtools-ui/200.html +2 -2
- package/assets/devtools-ui/200.html.br +0 -0
- package/assets/devtools-ui/404.html +2 -2
- package/assets/devtools-ui/404.html.br +0 -0
- package/assets/devtools-ui/{asset.BfSBZ5Dd.css → asset.hG_f8HuK.css} +1 -1
- package/assets/devtools-ui/asset.hG_f8HuK.css.br +0 -0
- package/assets/devtools-ui/chunk.B3au4Lhg.js +1 -0
- package/assets/devtools-ui/chunk.B3au4Lhg.js.br +0 -0
- package/assets/devtools-ui/chunk.BLOrlnMB.js +1 -0
- package/assets/devtools-ui/chunk.BLOrlnMB.js.br +0 -0
- package/assets/devtools-ui/chunk.BLR01ljW.js +1 -0
- package/assets/devtools-ui/chunk.BLR01ljW.js.br +0 -0
- package/assets/devtools-ui/chunk.BTXaIUlA.js +1 -0
- package/assets/devtools-ui/chunk.BTXaIUlA.js.br +0 -0
- package/assets/devtools-ui/{chunk.lJL-lgnW.js → chunk.BhJaxmm8.js} +1 -1
- package/assets/devtools-ui/chunk.BhJaxmm8.js.br +0 -0
- package/assets/devtools-ui/chunk.BtoNxFuL.js +1 -0
- package/assets/devtools-ui/chunk.BtoNxFuL.js.br +0 -0
- package/assets/devtools-ui/chunk.C8YUV2Wd.js +1 -0
- package/assets/devtools-ui/chunk.C8YUV2Wd.js.br +0 -0
- package/assets/devtools-ui/{chunk.M6wyKO_3.js → chunk.CBbIgDzE.js} +2 -2
- package/assets/devtools-ui/chunk.CBbIgDzE.js.br +0 -0
- package/assets/devtools-ui/chunk.CFqIniwA.js +1 -0
- package/assets/devtools-ui/chunk.CFqIniwA.js.br +0 -0
- package/assets/devtools-ui/chunk.CLFF7f7-.js +1 -0
- package/assets/devtools-ui/chunk.CLFF7f7-.js.br +0 -0
- package/assets/devtools-ui/chunk.CRsBbA10.js +1 -0
- package/assets/devtools-ui/chunk.CRsBbA10.js.br +0 -0
- package/assets/devtools-ui/{chunk.DbEH1oOB.js → chunk.CZPo6v95.js} +1 -1
- package/assets/devtools-ui/chunk.CZPo6v95.js.br +0 -0
- package/assets/devtools-ui/chunk.D0fWgNos.js +1 -0
- package/assets/devtools-ui/chunk.D0fWgNos.js.br +1 -0
- package/assets/devtools-ui/chunk.D7-0ziQ6.js +1 -0
- package/assets/devtools-ui/chunk.D7-0ziQ6.js.br +0 -0
- package/assets/devtools-ui/chunk.DAewe0vm.js +1 -0
- package/assets/devtools-ui/chunk.DAewe0vm.js.br +0 -0
- package/assets/devtools-ui/chunk.DJRQEYqK.js +1 -0
- package/assets/devtools-ui/chunk.DJRQEYqK.js.br +0 -0
- package/assets/devtools-ui/{chunk.CZl6J9DF.js → chunk.DMAxv14p.js} +1 -1
- package/assets/devtools-ui/chunk.DMAxv14p.js.br +0 -0
- package/assets/devtools-ui/{chunk.BT2IiBkZ.js → chunk.DMImnNjU.js} +1 -1
- package/assets/devtools-ui/chunk.DMImnNjU.js.br +0 -0
- package/assets/devtools-ui/chunk.DeeQsidk.js +9 -0
- package/assets/devtools-ui/chunk.DeeQsidk.js.br +0 -0
- package/assets/devtools-ui/chunk.DqEwn9Vj.js +7 -0
- package/assets/devtools-ui/chunk.DqEwn9Vj.js.br +0 -0
- package/assets/devtools-ui/chunk.Dt8OsQey.js +1 -0
- package/assets/devtools-ui/chunk.Dt8OsQey.js.br +0 -0
- package/assets/devtools-ui/{chunk.B9pX3zit.js → chunk.Dtp8oa_f.js} +1 -1
- package/assets/devtools-ui/chunk.Dtp8oa_f.js.br +0 -0
- package/assets/devtools-ui/chunk.Dx3JzAYM.js +1 -0
- package/assets/devtools-ui/chunk.Dx3JzAYM.js.br +0 -0
- package/assets/devtools-ui/chunk.GCOj1-5E.js +1 -0
- package/assets/devtools-ui/chunk.GCOj1-5E.js.br +0 -0
- package/assets/devtools-ui/chunk.IC1LD8BH.js +1 -0
- package/assets/devtools-ui/chunk.IC1LD8BH.js.br +0 -0
- package/assets/devtools-ui/chunk.IwuB_TqW.js +1 -0
- package/assets/devtools-ui/chunk.IwuB_TqW.js.br +0 -0
- package/assets/devtools-ui/chunk.Qqapj2zq.js +1 -0
- package/assets/devtools-ui/chunk.Qqapj2zq.js.br +0 -0
- package/assets/devtools-ui/{chunk.C79YouPp.js → chunk.TKKKndOy.js} +1 -1
- package/assets/devtools-ui/chunk.TKKKndOy.js.br +0 -0
- package/assets/devtools-ui/chunk.YHTVhFQT.js +1 -0
- package/assets/devtools-ui/chunk.YHTVhFQT.js.br +0 -0
- package/assets/devtools-ui/chunk.fnod6uEi.js +1 -0
- package/assets/devtools-ui/chunk.fnod6uEi.js.br +0 -0
- package/assets/devtools-ui/chunk.mOCRmXjo.js +1 -0
- package/assets/devtools-ui/chunk.mOCRmXjo.js.br +0 -0
- package/assets/devtools-ui/chunk.qZTNEAK0.js +1 -0
- package/assets/devtools-ui/chunk.qZTNEAK0.js.br +0 -0
- package/assets/devtools-ui/chunk.rc9m0y4-.js +1 -0
- package/assets/devtools-ui/chunk.rc9m0y4-.js.br +0 -0
- package/assets/devtools-ui/entry.Cxc5QLCU.js +80 -0
- package/assets/devtools-ui/entry.Cxc5QLCU.js.br +0 -0
- package/assets/devtools-ui/index.html +2 -2
- package/assets/devtools-ui/index.html.br +0 -0
- package/assets/swagger-ui/swagger-ui-bundle.js +1 -1
- package/assets/swagger-ui/swagger-ui.css +1 -1
- package/dist/api/audits/index.d.ts +61 -5
- package/dist/api/audits/index.d.ts.map +1 -1
- package/dist/api/files/index.d.ts +61 -5
- package/dist/api/files/index.d.ts.map +1 -1
- package/dist/api/jobs/index.d.ts +61 -5
- package/dist/api/jobs/index.d.ts.map +1 -1
- package/dist/api/jobs/index.js +4 -2
- package/dist/api/jobs/index.js.map +1 -1
- package/dist/api/keys/index.d.ts +5 -5
- package/dist/api/notifications/index.browser.js +44 -1
- package/dist/api/notifications/index.browser.js.map +1 -1
- package/dist/api/notifications/index.d.ts +187 -2
- package/dist/api/notifications/index.d.ts.map +1 -1
- package/dist/api/notifications/index.js +143 -8
- package/dist/api/notifications/index.js.map +1 -1
- package/dist/api/parameters/index.d.ts +61 -5
- package/dist/api/parameters/index.d.ts.map +1 -1
- package/dist/api/users/index.d.ts +330 -93
- package/dist/api/users/index.d.ts.map +1 -1
- package/dist/api/users/index.js +27 -36
- package/dist/api/users/index.js.map +1 -1
- package/dist/cli/config/index.d.ts +46 -0
- package/dist/cli/config/index.d.ts.map +1 -0
- package/dist/cli/config/index.js +20 -0
- package/dist/cli/config/index.js.map +1 -0
- package/dist/cli/core/index.d.ts +69 -66
- package/dist/cli/core/index.d.ts.map +1 -1
- package/dist/cli/core/index.js +329 -196
- package/dist/cli/core/index.js.map +1 -1
- package/dist/cli/platform/index.d.ts +302 -63
- package/dist/cli/platform/index.d.ts.map +1 -1
- package/dist/cli/platform/index.js +455 -25
- package/dist/cli/platform/index.js.map +1 -1
- package/dist/core/index.browser.js +125 -87
- package/dist/core/index.browser.js.map +1 -1
- package/dist/core/index.d.ts +62 -53
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +125 -87
- package/dist/core/index.js.map +1 -1
- package/dist/core/index.native.js +125 -87
- package/dist/core/index.native.js.map +1 -1
- package/dist/core/index.workerd.js +125 -87
- package/dist/core/index.workerd.js.map +1 -1
- package/dist/crypto/index.d.ts +18 -1
- package/dist/crypto/index.d.ts.map +1 -1
- package/dist/crypto/index.js +29 -3
- package/dist/crypto/index.js.map +1 -1
- package/dist/devtools/index.js +3 -12
- package/dist/devtools/index.js.map +1 -1
- package/dist/logger/index.d.ts +10 -1
- package/dist/logger/index.d.ts.map +1 -1
- package/dist/logger/index.js +19 -9
- package/dist/logger/index.js.map +1 -1
- package/dist/orm/core/index.browser.js +57 -1
- package/dist/orm/core/index.browser.js.map +1 -1
- package/dist/orm/core/index.bun.js +378 -19
- package/dist/orm/core/index.bun.js.map +1 -1
- package/dist/orm/core/index.d.ts +328 -9
- package/dist/orm/core/index.d.ts.map +1 -1
- package/dist/orm/core/index.js +384 -21
- package/dist/orm/core/index.js.map +1 -1
- package/dist/orm/postgres/index.bun.js +49 -17
- package/dist/orm/postgres/index.bun.js.map +1 -1
- package/dist/orm/postgres/index.d.ts +47 -21
- package/dist/orm/postgres/index.d.ts.map +1 -1
- package/dist/orm/postgres/index.js +52 -17
- package/dist/orm/postgres/index.js.map +1 -1
- package/dist/react/core/index.d.ts +1 -1
- package/dist/react/core/index.d.ts.map +1 -1
- package/dist/react/core/index.js +6 -1
- package/dist/react/core/index.js.map +1 -1
- package/dist/react/form/index.d.ts +28 -18
- package/dist/react/form/index.d.ts.map +1 -1
- package/dist/react/form/index.js +92 -56
- package/dist/react/form/index.js.map +1 -1
- package/dist/react/router/index.browser.js +448 -116
- package/dist/react/router/index.browser.js.map +1 -1
- package/dist/react/router/index.d.ts +102 -40
- package/dist/react/router/index.d.ts.map +1 -1
- package/dist/react/router/index.js +453 -92
- package/dist/react/router/index.js.map +1 -1
- package/dist/security/index.d.ts +3 -11
- package/dist/security/index.d.ts.map +1 -1
- package/dist/security/index.js +6 -11
- package/dist/security/index.js.map +1 -1
- package/dist/server/auth/index.d.ts +22 -24
- package/dist/server/auth/index.d.ts.map +1 -1
- package/dist/server/auth/index.js +102 -82
- package/dist/server/auth/index.js.map +1 -1
- package/dist/server/cookies/index.d.ts +7 -4
- package/dist/server/cookies/index.d.ts.map +1 -1
- package/dist/server/cookies/index.js +13 -12
- package/dist/server/cookies/index.js.map +1 -1
- package/dist/server/core/index.d.ts +288 -4
- package/dist/server/core/index.d.ts.map +1 -1
- package/dist/server/core/index.js +375 -2
- package/dist/server/core/index.js.map +1 -1
- package/dist/server/links/index.browser.js +10 -71
- package/dist/server/links/index.browser.js.map +1 -1
- package/dist/server/links/index.d.ts +32 -49
- package/dist/server/links/index.d.ts.map +1 -1
- package/dist/server/links/index.js +73 -100
- package/dist/server/links/index.js.map +1 -1
- package/dist/system/index.browser.js +221 -2
- package/dist/system/index.browser.js.map +1 -1
- package/dist/system/index.d.ts +63 -1
- package/dist/system/index.d.ts.map +1 -1
- package/dist/system/index.js +221 -1
- package/dist/system/index.js.map +1 -1
- package/dist/system/index.workerd.js +224 -4
- package/dist/system/index.workerd.js.map +1 -1
- package/package.json +10 -5
- package/src/api/jobs/providers/JobProvider.ts +6 -3
- package/src/api/notifications/controllers/AdminNotificationController.ts +83 -0
- package/src/api/notifications/index.browser.ts +3 -0
- package/src/api/notifications/index.ts +14 -2
- package/src/api/notifications/jobs/NotificationJobs.ts +11 -2
- package/src/api/notifications/schemas/notificationDetailResourceSchema.ts +20 -0
- package/src/api/notifications/schemas/notificationQuerySchema.ts +19 -0
- package/src/api/notifications/schemas/notificationResourceSchema.ts +18 -0
- package/src/api/notifications/services/NotificationSenderService.ts +15 -2
- package/src/api/users/atoms/realmAuthSettingsAtom.ts +28 -32
- package/src/api/users/buckets/UserBuckets.ts +1 -1
- package/src/api/users/jobs/UserJobs.ts +1 -1
- package/src/api/users/primitives/$realm.ts +8 -49
- package/src/api/users/providers/RealmProvider.ts +2 -3
- package/src/api/users/services/RegistrationService.spec.ts +7 -7
- package/src/api/users/services/RegistrationService.ts +3 -3
- package/src/api/users/services/SessionService.spec.ts +4 -4
- package/src/api/users/services/SessionService.ts +3 -3
- package/src/cli/{core → config}/defineConfig.ts +14 -20
- package/src/cli/config/index.ts +1 -0
- package/src/cli/core/commands/db.ts +65 -1
- package/src/cli/core/commands/dev.ts +1 -0
- package/src/cli/core/commands/init.ts +2 -192
- package/src/cli/core/index.ts +34 -11
- package/src/cli/core/providers/ViteDevServerProvider.ts +52 -13
- package/src/cli/core/services/PackageManagerUtils.ts +43 -21
- package/src/cli/core/services/ProjectScaffolder.ts +214 -2
- package/src/cli/core/services/ViteUtils.ts +57 -0
- package/src/cli/core/tasks/BuildClientTask.ts +7 -2
- package/src/cli/core/tasks/BuildCloudflareTask.ts +4 -12
- package/src/cli/core/tasks/BuildServerTask.ts +2 -0
- package/src/cli/core/tasks/BuildVercelTask.ts +165 -168
- package/src/cli/core/templates/alephaConfigTs.ts +1 -1
- package/src/cli/core/templates/apiAppSecurityTs.ts +5 -8
- package/src/cli/core/templates/tsconfigJson.ts +6 -1
- package/src/cli/platform/adapters/CloudflareAdapter.spec.ts +1 -1
- package/src/cli/platform/adapters/CloudflareAdapter.ts +30 -29
- package/src/cli/platform/atoms/platformOptions.ts +21 -0
- package/src/cli/platform/commands/SecretsCommand.spec.ts +298 -0
- package/src/cli/platform/commands/SecretsCommand.ts +283 -0
- package/src/cli/platform/commands/platform.ts +12 -0
- package/src/cli/platform/index.ts +14 -28
- package/src/cli/platform/providers/GitHubSecretStore.spec.ts +153 -0
- package/src/cli/platform/providers/GitHubSecretStore.ts +112 -0
- package/src/cli/platform/providers/MemorySecretStore.ts +114 -0
- package/src/cli/platform/providers/SecretStoreProvider.ts +39 -0
- package/src/cli/platform/schemas/cloudflare.ts +2 -0
- package/src/cli/platform/services/CloudflareApi.ts +5 -2
- package/src/cli/platform/services/DockerComposeGenerator.spec.ts +115 -0
- package/src/cli/platform/services/DockerComposeGenerator.ts +46 -1
- package/src/cli/platform/services/SecretFilterService.spec.ts +111 -0
- package/src/cli/platform/services/SecretFilterService.ts +54 -0
- package/src/core/Alepha.ts +94 -25
- package/src/core/__tests__/Alepha-parseEnv.spec.ts +20 -0
- package/src/core/primitives/$memoize.ts +38 -26
- package/src/core/providers/AlsProvider.ts +2 -0
- package/src/core/providers/EventManager.ts +4 -0
- package/src/core/providers/KeylessJsonSchemaCodec.spec.ts +1 -4
- package/src/core/providers/KeylessJsonSchemaCodec.ts +19 -125
- package/src/core/providers/SchemaValidator.spec.ts +36 -0
- package/src/core/providers/SchemaValidator.ts +9 -0
- package/src/crypto/index.ts +6 -1
- package/src/crypto/providers/SecretProvider.ts +36 -0
- package/src/devtools/providers/DevToolsProvider.ts +3 -12
- package/src/logger/index.ts +33 -6
- package/src/logger/providers/PrettyFormatterProvider.ts +5 -3
- package/src/orm/__tests__/orm-next-tests.ts +492 -0
- package/src/orm/__tests__/orm-next.spec.ts +140 -0
- package/src/orm/core/constants/PG_SYMBOLS.ts +17 -0
- package/src/orm/core/index.bun.ts +3 -6
- package/src/orm/core/index.shared-server.ts +2 -0
- package/src/orm/core/index.shared.ts +2 -0
- package/src/orm/core/index.ts +5 -7
- package/src/orm/core/interfaces/AggregateQuery.ts +103 -0
- package/src/orm/core/interfaces/PgQueryWhere.ts +7 -0
- package/src/orm/core/primitives/$entity.ts +8 -0
- package/src/orm/core/primitives/$repository.ts +6 -3
- package/src/orm/core/primitives/$view.ts +88 -0
- package/src/orm/core/providers/DbCacheProvider.ts +66 -0
- package/src/orm/core/providers/DrizzleKitProvider.ts +42 -0
- package/src/orm/core/providers/drivers/BunSqliteProvider.ts +2 -3
- package/src/orm/core/providers/drivers/CloudflareD1Provider.ts +12 -0
- package/src/orm/core/providers/drivers/DatabaseProvider.ts +39 -0
- package/src/orm/core/providers/drivers/NodeSqliteProvider.ts +2 -3
- package/src/orm/core/schemas/databaseEnvSchema.ts +31 -0
- package/src/orm/core/schemas/insertSchema.ts +13 -3
- package/src/orm/core/schemas/updateSchema.ts +14 -3
- package/src/orm/core/services/ModelBuilder.ts +26 -14
- package/src/orm/core/services/QueryManager.ts +13 -0
- package/src/orm/core/services/Repository.ts +307 -5
- package/src/orm/core/services/SqliteModelBuilder.ts +38 -0
- package/src/orm/postgres/index.bun.ts +4 -7
- package/src/orm/postgres/index.ts +4 -7
- package/src/orm/postgres/providers/BunPostgresProvider.ts +12 -2
- package/src/orm/postgres/providers/NodePostgresProvider.ts +7 -0
- package/src/orm/postgres/providers/PglitePostgresProvider.ts +10 -17
- package/src/orm/postgres/providers/PostgresProvider.ts +7 -36
- package/src/orm/postgres/schemas/postgresEnvSchema.ts +32 -0
- package/src/orm/postgres/services/PostgresModelBuilder.ts +40 -0
- package/src/react/core/components/ErrorBoundary.tsx +5 -2
- package/src/react/form/hooks/useFieldValue.ts +34 -0
- package/src/react/form/hooks/useForm.browser.spec.tsx +94 -9
- package/src/react/form/hooks/useForm.ts +14 -2
- package/src/react/form/hooks/useFormState.ts +10 -10
- package/src/react/form/hooks/useFormValues.ts +29 -0
- package/src/react/form/index.ts +3 -1
- package/src/react/form/services/FormModel.ts +53 -122
- package/src/react/router/components/ErrorViewer.tsx +333 -34
- package/src/react/router/components/NestedView.tsx +10 -3
- package/src/react/router/primitives/$page.browser.spec.tsx +34 -0
- package/src/react/router/primitives/$page.spec.tsx +20 -0
- package/src/react/router/primitives/$page.ts +24 -0
- package/src/react/router/providers/ReactBrowserRouterProvider.ts +14 -2
- package/src/react/router/providers/ReactPageProvider.ts +156 -73
- package/src/react/router/providers/ReactServerProvider.ts +40 -2
- package/src/react/router/providers/ReactServerTemplateProvider.ts +13 -1
- package/src/security/providers/SecurityProvider.ts +5 -27
- package/src/server/auth/primitives/$auth.ts +52 -19
- package/src/server/auth/providers/ServerAuthProvider.ts +145 -139
- package/src/server/cookies/providers/ServerCookiesProvider.ts +12 -24
- package/src/server/core/index.ts +3 -1
- package/src/server/core/primitives/$sse.spec.ts +315 -0
- package/src/server/core/primitives/$sse.ts +715 -0
- package/src/server/links/index.browser.ts +1 -3
- package/src/server/links/index.ts +0 -3
- package/src/server/links/providers/LinkProvider.spec.ts +12 -21
- package/src/server/links/providers/LinkProvider.ts +20 -52
- package/src/server/links/providers/ServerLinksProvider.spec.ts +106 -0
- package/src/server/links/providers/ServerLinksProvider.ts +113 -73
- package/src/server/links/schemas/apiLinksResponseSchema.ts +4 -21
- package/src/server/links/services/BatchCollector.ts +5 -3
- package/src/system/index.browser.ts +1 -0
- package/src/system/index.ts +3 -0
- package/src/system/index.workerd.ts +39 -1
- package/src/system/providers/WorkerdFileSystemProvider.ts +365 -0
- package/assets/devtools-ui/asset.BfSBZ5Dd.css.br +0 -0
- package/assets/devtools-ui/chunk.2NYaoqWt.js +0 -1
- package/assets/devtools-ui/chunk.2NYaoqWt.js.br +0 -0
- package/assets/devtools-ui/chunk.B052Z_xQ.js +0 -1
- package/assets/devtools-ui/chunk.B052Z_xQ.js.br +0 -0
- package/assets/devtools-ui/chunk.B4kVY90C.js +0 -1
- package/assets/devtools-ui/chunk.B4kVY90C.js.br +0 -0
- package/assets/devtools-ui/chunk.B7QJXctB.js +0 -1
- package/assets/devtools-ui/chunk.B7QJXctB.js.br +0 -0
- package/assets/devtools-ui/chunk.B9pX3zit.js.br +0 -0
- package/assets/devtools-ui/chunk.BKF9JxIo.js +0 -1
- package/assets/devtools-ui/chunk.BKF9JxIo.js.br +0 -0
- package/assets/devtools-ui/chunk.BOHgdTP-.js +0 -1
- package/assets/devtools-ui/chunk.BOHgdTP-.js.br +0 -0
- package/assets/devtools-ui/chunk.BOVFxkYC.js +0 -1
- package/assets/devtools-ui/chunk.BOVFxkYC.js.br +0 -0
- package/assets/devtools-ui/chunk.BR842zj5.js +0 -1
- package/assets/devtools-ui/chunk.BR842zj5.js.br +0 -0
- package/assets/devtools-ui/chunk.BT2IiBkZ.js.br +0 -0
- package/assets/devtools-ui/chunk.C79YouPp.js.br +0 -0
- package/assets/devtools-ui/chunk.C8mlBrjW.js +0 -9
- package/assets/devtools-ui/chunk.C8mlBrjW.js.br +0 -0
- package/assets/devtools-ui/chunk.CK0ow3AZ.js +0 -1
- package/assets/devtools-ui/chunk.CK0ow3AZ.js.br +0 -0
- package/assets/devtools-ui/chunk.CZl6J9DF.js.br +0 -0
- package/assets/devtools-ui/chunk.CdNr0YzS.js +0 -1
- package/assets/devtools-ui/chunk.CdNr0YzS.js.br +0 -0
- package/assets/devtools-ui/chunk.Ce6_6iIF.js +0 -1
- package/assets/devtools-ui/chunk.Ce6_6iIF.js.br +0 -0
- package/assets/devtools-ui/chunk.CpyDMr6O.js +0 -1
- package/assets/devtools-ui/chunk.CpyDMr6O.js.br +0 -0
- package/assets/devtools-ui/chunk.CyPmvPnY.js +0 -1
- package/assets/devtools-ui/chunk.CyPmvPnY.js.br +0 -0
- package/assets/devtools-ui/chunk.DTI_geWu.js +0 -1
- package/assets/devtools-ui/chunk.DTI_geWu.js.br +0 -0
- package/assets/devtools-ui/chunk.DbEH1oOB.js.br +0 -0
- package/assets/devtools-ui/chunk.Ddeqj5gv.js +0 -1
- package/assets/devtools-ui/chunk.Ddeqj5gv.js.br +0 -0
- package/assets/devtools-ui/chunk.DpRnB4vJ.js +0 -1
- package/assets/devtools-ui/chunk.DpRnB4vJ.js.br +0 -0
- package/assets/devtools-ui/chunk.DxPGTlsg.js +0 -1
- package/assets/devtools-ui/chunk.DxPGTlsg.js.br +0 -0
- package/assets/devtools-ui/chunk.G7_MMBJS.js +0 -1
- package/assets/devtools-ui/chunk.G7_MMBJS.js.br +0 -0
- package/assets/devtools-ui/chunk.M6wyKO_3.js.br +0 -0
- package/assets/devtools-ui/chunk.OUxNGmQ6.js +0 -1
- package/assets/devtools-ui/chunk.OUxNGmQ6.js.br +0 -0
- package/assets/devtools-ui/chunk.T1kle-fF.js +0 -1
- package/assets/devtools-ui/chunk.T1kle-fF.js.br +0 -0
- package/assets/devtools-ui/chunk.WjpsbQAv.js +0 -1
- package/assets/devtools-ui/chunk.WjpsbQAv.js.br +0 -0
- package/assets/devtools-ui/chunk.c6YgVx86.js +0 -1
- package/assets/devtools-ui/chunk.c6YgVx86.js.br +0 -0
- package/assets/devtools-ui/chunk.dwU3E_MU.js +0 -1
- package/assets/devtools-ui/chunk.dwU3E_MU.js.br +0 -0
- package/assets/devtools-ui/chunk.lJL-lgnW.js.br +0 -0
- package/assets/devtools-ui/chunk.lPWRmvA-.js +0 -7
- package/assets/devtools-ui/chunk.lPWRmvA-.js.br +0 -0
- package/assets/devtools-ui/chunk.p3HJvugM.js +0 -1
- package/assets/devtools-ui/chunk.p3HJvugM.js.br +0 -0
- package/assets/devtools-ui/chunk.r_Xoa_CI.js +0 -1
- package/assets/devtools-ui/chunk.r_Xoa_CI.js.br +0 -0
- package/assets/devtools-ui/chunk.sRNuTYXb.js +0 -1
- package/assets/devtools-ui/chunk.sRNuTYXb.js.br +0 -0
- package/assets/devtools-ui/chunk.tUjcyX5C.js +0 -1
- package/assets/devtools-ui/chunk.tUjcyX5C.js.br +0 -0
- package/assets/devtools-ui/chunk.thjBxvCA.js +0 -1
- package/assets/devtools-ui/chunk.thjBxvCA.js.br +0 -0
- package/assets/devtools-ui/entry.GYhBVRpC.js +0 -78
- package/assets/devtools-ui/entry.GYhBVRpC.js.br +0 -0
- package/src/server/links/services/DefinitionsPool.spec.ts +0 -86
- package/src/server/links/services/DefinitionsPool.ts +0 -43
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import * as alepha from "alepha";
|
|
2
2
|
import { Alepha, KIND, Primitive, Static, StaticEncode, TObject } from "alepha";
|
|
3
3
|
import * as alepha_api_jobs0 from "alepha/api/jobs";
|
|
4
|
+
import { JobService } from "alepha/api/jobs";
|
|
5
|
+
import * as alepha_server0 from "alepha/server";
|
|
6
|
+
import * as alepha_orm0 from "alepha/orm";
|
|
4
7
|
import { EmailProvider } from "alepha/email";
|
|
5
8
|
import * as alepha_logger0 from "alepha/logger";
|
|
6
9
|
import { SmsProvider } from "alepha/sms";
|
|
@@ -88,7 +91,19 @@ declare class NotificationSenderService {
|
|
|
88
91
|
protected readonly log: alepha_logger0.Logger;
|
|
89
92
|
protected readonly emailProvider: EmailProvider;
|
|
90
93
|
protected readonly smsProvider: SmsProvider;
|
|
91
|
-
send(payload: NotificationPayload): Promise<
|
|
94
|
+
send(payload: NotificationPayload): Promise<{
|
|
95
|
+
type: "email";
|
|
96
|
+
to: string;
|
|
97
|
+
subject: string;
|
|
98
|
+
body: string;
|
|
99
|
+
message?: undefined;
|
|
100
|
+
} | {
|
|
101
|
+
type: "sms";
|
|
102
|
+
to: string;
|
|
103
|
+
message: string;
|
|
104
|
+
subject?: undefined;
|
|
105
|
+
body?: undefined;
|
|
106
|
+
} | undefined>;
|
|
92
107
|
renderSms(payload: NotificationPayload): {
|
|
93
108
|
to: string;
|
|
94
109
|
message: string;
|
|
@@ -116,6 +131,28 @@ declare class NotificationSenderService {
|
|
|
116
131
|
//#region ../../src/api/notifications/jobs/NotificationJobs.d.ts
|
|
117
132
|
declare class NotificationJobs {
|
|
118
133
|
protected readonly notificationSenderService: NotificationSenderService;
|
|
134
|
+
protected readonly executions: alepha_orm0.Repository<alepha.TObject<{
|
|
135
|
+
id: alepha_orm0.PgAttr<alepha_orm0.PgAttr<alepha.TString, typeof alepha_orm0.PG_PRIMARY_KEY>, typeof alepha_orm0.PG_DEFAULT>;
|
|
136
|
+
createdAt: alepha_orm0.PgAttr<alepha_orm0.PgAttr<alepha.TString, typeof alepha_orm0.PG_CREATED_AT>, typeof alepha_orm0.PG_DEFAULT>;
|
|
137
|
+
updatedAt: alepha_orm0.PgAttr<alepha_orm0.PgAttr<alepha.TString, typeof alepha_orm0.PG_UPDATED_AT>, typeof alepha_orm0.PG_DEFAULT>;
|
|
138
|
+
jobName: alepha.TString;
|
|
139
|
+
key: alepha.TOptional<alepha.TUnion<[alepha.TNull, alepha.TString]>>;
|
|
140
|
+
payload: alepha.TOptional<alepha.TRecord<"^.*$", alepha.TAny>>;
|
|
141
|
+
status: alepha_orm0.PgAttr<alepha.TUnsafe<"pending" | "scheduled" | "retrying" | "running" | "completed" | "failed" | "dead" | "cancelled">, typeof alepha_orm0.PG_DEFAULT>;
|
|
142
|
+
priority: alepha_orm0.PgAttr<alepha.TInteger, typeof alepha_orm0.PG_DEFAULT>;
|
|
143
|
+
attempt: alepha_orm0.PgAttr<alepha.TInteger, typeof alepha_orm0.PG_DEFAULT>;
|
|
144
|
+
maxAttempts: alepha_orm0.PgAttr<alepha.TInteger, typeof alepha_orm0.PG_DEFAULT>;
|
|
145
|
+
scheduledAt: alepha.TOptional<alepha.TString>;
|
|
146
|
+
startedAt: alepha.TOptional<alepha.TString>;
|
|
147
|
+
completedAt: alepha.TOptional<alepha.TString>;
|
|
148
|
+
result: alepha.TOptional<alepha.TRecord<"^.*$", alepha.TAny>>;
|
|
149
|
+
error: alepha.TOptional<alepha.TString>;
|
|
150
|
+
workerId: alepha.TOptional<alepha.TString>;
|
|
151
|
+
triggeredBy: alepha.TOptional<alepha.TString>;
|
|
152
|
+
triggeredByName: alepha.TOptional<alepha.TString>;
|
|
153
|
+
cancelledBy: alepha.TOptional<alepha.TString>;
|
|
154
|
+
cancelledByName: alepha.TOptional<alepha.TString>;
|
|
155
|
+
}>>;
|
|
119
156
|
readonly sendNotification: alepha_api_jobs0.JobPrimitive<alepha.TObject<{
|
|
120
157
|
type: alepha.TUnsafe<"email" | "sms">;
|
|
121
158
|
template: alepha.TString;
|
|
@@ -127,6 +164,99 @@ declare class NotificationJobs {
|
|
|
127
164
|
}>>;
|
|
128
165
|
}
|
|
129
166
|
//#endregion
|
|
167
|
+
//#region ../../src/api/notifications/controllers/AdminNotificationController.d.ts
|
|
168
|
+
declare class AdminNotificationController {
|
|
169
|
+
protected readonly url: string;
|
|
170
|
+
protected readonly group: string;
|
|
171
|
+
protected readonly jobService: JobService;
|
|
172
|
+
protected readonly notificationJobs: NotificationJobs;
|
|
173
|
+
protected get jobName(): string;
|
|
174
|
+
readonly findNotifications: alepha_server0.ActionPrimitiveFn<{
|
|
175
|
+
query: alepha.TObject<{
|
|
176
|
+
page: alepha.TOptional<alepha.TInteger>;
|
|
177
|
+
size: alepha.TOptional<alepha.TInteger>;
|
|
178
|
+
sort: alepha.TOptional<alepha.TString>;
|
|
179
|
+
status: alepha.TOptional<alepha.TUnsafe<"pending" | "scheduled" | "retrying" | "running" | "completed" | "failed" | "dead" | "cancelled">>;
|
|
180
|
+
}>;
|
|
181
|
+
response: alepha.TPage<alepha.TObject<{
|
|
182
|
+
id: alepha.TString;
|
|
183
|
+
createdAt: alepha.TString;
|
|
184
|
+
status: alepha.TString;
|
|
185
|
+
template: alepha.TOptional<alepha.TString>;
|
|
186
|
+
type: alepha.TOptional<alepha.TString>;
|
|
187
|
+
contact: alepha.TOptional<alepha.TString>;
|
|
188
|
+
category: alepha.TOptional<alepha.TString>;
|
|
189
|
+
critical: alepha.TOptional<alepha.TBoolean>;
|
|
190
|
+
sensitive: alepha.TOptional<alepha.TBoolean>;
|
|
191
|
+
startedAt: alepha.TOptional<alepha.TString>;
|
|
192
|
+
completedAt: alepha.TOptional<alepha.TString>;
|
|
193
|
+
error: alepha.TOptional<alepha.TString>;
|
|
194
|
+
}>>;
|
|
195
|
+
}>;
|
|
196
|
+
readonly getNotification: alepha_server0.ActionPrimitiveFn<{
|
|
197
|
+
params: alepha.TObject<{
|
|
198
|
+
id: alepha.TString;
|
|
199
|
+
}>;
|
|
200
|
+
response: alepha.TObject<{
|
|
201
|
+
id: alepha.TString;
|
|
202
|
+
createdAt: alepha.TString;
|
|
203
|
+
status: alepha.TString;
|
|
204
|
+
template: alepha.TOptional<alepha.TString>;
|
|
205
|
+
type: alepha.TOptional<alepha.TString>;
|
|
206
|
+
contact: alepha.TOptional<alepha.TString>;
|
|
207
|
+
category: alepha.TOptional<alepha.TString>;
|
|
208
|
+
critical: alepha.TOptional<alepha.TBoolean>;
|
|
209
|
+
sensitive: alepha.TOptional<alepha.TBoolean>;
|
|
210
|
+
startedAt: alepha.TOptional<alepha.TString>;
|
|
211
|
+
completedAt: alepha.TOptional<alepha.TString>;
|
|
212
|
+
error: alepha.TOptional<alepha.TString>;
|
|
213
|
+
variables: alepha.TOptional<alepha.TRecord<"^.*$", alepha.TAny>>;
|
|
214
|
+
rendered: alepha.TOptional<alepha.TRecord<"^.*$", alepha.TAny>>;
|
|
215
|
+
logs: alepha.TOptional<alepha.TArray<alepha.TObject<{
|
|
216
|
+
level: alepha.TUnsafe<"TRACE" | "SILENT" | "DEBUG" | "INFO" | "WARN" | "ERROR">;
|
|
217
|
+
message: alepha.TString;
|
|
218
|
+
service: alepha.TString;
|
|
219
|
+
module: alepha.TString;
|
|
220
|
+
context: alepha.TOptional<alepha.TString>;
|
|
221
|
+
app: alepha.TOptional<alepha.TString>;
|
|
222
|
+
data: alepha.TOptional<alepha.TAny>;
|
|
223
|
+
timestamp: alepha.TNumber;
|
|
224
|
+
}>>>;
|
|
225
|
+
}>;
|
|
226
|
+
}>;
|
|
227
|
+
protected toResource(exec: Record<string, unknown>): {
|
|
228
|
+
id: unknown;
|
|
229
|
+
createdAt: unknown;
|
|
230
|
+
status: unknown;
|
|
231
|
+
template: unknown;
|
|
232
|
+
type: unknown;
|
|
233
|
+
contact: unknown;
|
|
234
|
+
category: unknown;
|
|
235
|
+
critical: unknown;
|
|
236
|
+
sensitive: unknown;
|
|
237
|
+
startedAt: unknown;
|
|
238
|
+
completedAt: unknown;
|
|
239
|
+
error: unknown;
|
|
240
|
+
};
|
|
241
|
+
protected toDetailResource(exec: Record<string, unknown>): {
|
|
242
|
+
variables: unknown;
|
|
243
|
+
rendered: unknown;
|
|
244
|
+
logs: unknown;
|
|
245
|
+
id: unknown;
|
|
246
|
+
createdAt: unknown;
|
|
247
|
+
status: unknown;
|
|
248
|
+
template: unknown;
|
|
249
|
+
type: unknown;
|
|
250
|
+
contact: unknown;
|
|
251
|
+
category: unknown;
|
|
252
|
+
critical: unknown;
|
|
253
|
+
sensitive: unknown;
|
|
254
|
+
startedAt: unknown;
|
|
255
|
+
completedAt: unknown;
|
|
256
|
+
error: unknown;
|
|
257
|
+
};
|
|
258
|
+
}
|
|
259
|
+
//#endregion
|
|
130
260
|
//#region ../../src/api/notifications/schemas/notificationContactPreferencesSchema.d.ts
|
|
131
261
|
declare const notificationContactPreferencesSchema: alepha.TObject<{
|
|
132
262
|
language: alepha.TOptional<alepha.TString>;
|
|
@@ -144,6 +274,61 @@ declare const notificationContactSchema: alepha.TObject<{
|
|
|
144
274
|
}>;
|
|
145
275
|
type NotificationContact = Static<typeof notificationContactSchema>;
|
|
146
276
|
//#endregion
|
|
277
|
+
//#region ../../src/api/notifications/schemas/notificationDetailResourceSchema.d.ts
|
|
278
|
+
declare const notificationDetailResourceSchema: alepha.TObject<{
|
|
279
|
+
id: alepha.TString;
|
|
280
|
+
createdAt: alepha.TString;
|
|
281
|
+
status: alepha.TString;
|
|
282
|
+
template: alepha.TOptional<alepha.TString>;
|
|
283
|
+
type: alepha.TOptional<alepha.TString>;
|
|
284
|
+
contact: alepha.TOptional<alepha.TString>;
|
|
285
|
+
category: alepha.TOptional<alepha.TString>;
|
|
286
|
+
critical: alepha.TOptional<alepha.TBoolean>;
|
|
287
|
+
sensitive: alepha.TOptional<alepha.TBoolean>;
|
|
288
|
+
startedAt: alepha.TOptional<alepha.TString>;
|
|
289
|
+
completedAt: alepha.TOptional<alepha.TString>;
|
|
290
|
+
error: alepha.TOptional<alepha.TString>;
|
|
291
|
+
variables: alepha.TOptional<alepha.TRecord<"^.*$", alepha.TAny>>;
|
|
292
|
+
rendered: alepha.TOptional<alepha.TRecord<"^.*$", alepha.TAny>>;
|
|
293
|
+
logs: alepha.TOptional<alepha.TArray<alepha.TObject<{
|
|
294
|
+
level: alepha.TUnsafe<"TRACE" | "SILENT" | "DEBUG" | "INFO" | "WARN" | "ERROR">;
|
|
295
|
+
message: alepha.TString;
|
|
296
|
+
service: alepha.TString;
|
|
297
|
+
module: alepha.TString;
|
|
298
|
+
context: alepha.TOptional<alepha.TString>;
|
|
299
|
+
app: alepha.TOptional<alepha.TString>;
|
|
300
|
+
data: alepha.TOptional<alepha.TAny>;
|
|
301
|
+
timestamp: alepha.TNumber;
|
|
302
|
+
}>>>;
|
|
303
|
+
}>;
|
|
304
|
+
type NotificationDetailResource = Static<typeof notificationDetailResourceSchema>;
|
|
305
|
+
//#endregion
|
|
306
|
+
//#region ../../src/api/notifications/schemas/notificationQuerySchema.d.ts
|
|
307
|
+
declare const notificationQuerySchema: alepha.TObject<{
|
|
308
|
+
page: alepha.TOptional<alepha.TInteger>;
|
|
309
|
+
size: alepha.TOptional<alepha.TInteger>;
|
|
310
|
+
sort: alepha.TOptional<alepha.TString>;
|
|
311
|
+
status: alepha.TOptional<alepha.TUnsafe<"pending" | "scheduled" | "retrying" | "running" | "completed" | "failed" | "dead" | "cancelled">>;
|
|
312
|
+
}>;
|
|
313
|
+
type NotificationQuery = Static<typeof notificationQuerySchema>;
|
|
314
|
+
//#endregion
|
|
315
|
+
//#region ../../src/api/notifications/schemas/notificationResourceSchema.d.ts
|
|
316
|
+
declare const notificationResourceSchema: alepha.TObject<{
|
|
317
|
+
id: alepha.TString;
|
|
318
|
+
createdAt: alepha.TString;
|
|
319
|
+
status: alepha.TString;
|
|
320
|
+
template: alepha.TOptional<alepha.TString>;
|
|
321
|
+
type: alepha.TOptional<alepha.TString>;
|
|
322
|
+
contact: alepha.TOptional<alepha.TString>;
|
|
323
|
+
category: alepha.TOptional<alepha.TString>;
|
|
324
|
+
critical: alepha.TOptional<alepha.TBoolean>;
|
|
325
|
+
sensitive: alepha.TOptional<alepha.TBoolean>;
|
|
326
|
+
startedAt: alepha.TOptional<alepha.TString>;
|
|
327
|
+
completedAt: alepha.TOptional<alepha.TString>;
|
|
328
|
+
error: alepha.TOptional<alepha.TString>;
|
|
329
|
+
}>;
|
|
330
|
+
type NotificationResource = Static<typeof notificationResourceSchema>;
|
|
331
|
+
//#endregion
|
|
147
332
|
//#region ../../src/api/notifications/index.d.ts
|
|
148
333
|
/**
|
|
149
334
|
* User notification management.
|
|
@@ -158,5 +343,5 @@ type NotificationContact = Static<typeof notificationContactSchema>;
|
|
|
158
343
|
*/
|
|
159
344
|
declare const AlephaApiNotifications: alepha.Service<alepha.Module>;
|
|
160
345
|
//#endregion
|
|
161
|
-
export { $notification, AlephaApiNotifications, NotificationContact, NotificationContactPreferences, NotificationJobs, NotificationMessage, NotificationPayload, NotificationPrimitive, NotificationPrimitiveOptions, NotificationPushOptions, NotificationSenderService, notificationContactPreferencesSchema, notificationContactSchema, notificationPayloadSchema };
|
|
346
|
+
export { $notification, AdminNotificationController, AlephaApiNotifications, NotificationContact, NotificationContactPreferences, NotificationDetailResource, NotificationJobs, NotificationMessage, NotificationPayload, NotificationPrimitive, NotificationPrimitiveOptions, NotificationPushOptions, NotificationQuery, NotificationResource, NotificationSenderService, notificationContactPreferencesSchema, notificationContactSchema, notificationDetailResourceSchema, notificationPayloadSchema, notificationQuerySchema, notificationResourceSchema };
|
|
162
347
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../../../src/api/notifications/primitives/$notification.ts","../../../src/api/notifications/schemas/notificationPayloadSchema.ts","../../../src/api/notifications/services/NotificationSenderService.ts","../../../src/api/notifications/jobs/NotificationJobs.ts","../../../src/api/notifications/schemas/notificationContactPreferencesSchema.ts","../../../src/api/notifications/schemas/notificationContactSchema.ts","../../../src/api/notifications/index.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../../src/api/notifications/primitives/$notification.ts","../../../src/api/notifications/schemas/notificationPayloadSchema.ts","../../../src/api/notifications/services/NotificationSenderService.ts","../../../src/api/notifications/jobs/NotificationJobs.ts","../../../src/api/notifications/controllers/AdminNotificationController.ts","../../../src/api/notifications/schemas/notificationContactPreferencesSchema.ts","../../../src/api/notifications/schemas/notificationContactSchema.ts","../../../src/api/notifications/schemas/notificationDetailResourceSchema.ts","../../../src/api/notifications/schemas/notificationQuerySchema.ts","../../../src/api/notifications/schemas/notificationResourceSchema.ts","../../../src/api/notifications/index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAuCA;;;;;;;;;;;;;;;;;;cAAa,aAAA;EAAA,WAA2B,OAAA,EAAO,OAAA,EACpC,4BAAA,CAA6B,CAAA,IAAE,qBAAA,CAAA,CAAA;EAAA;;UAKzB,4BAAA,WAAuC,OAAA,UAC9C,mBAAA,CAAoB,CAAA;EAC5B,IAAA;EACA,WAAA;EACA,QAAA;EACA,QAAA;EACA,SAAA;EACA,YAAA;IAAA,CAEG,IAAA,WAAe,mBAAA,CAAoB,CAAA;EAAA;EAEtC,MAAA,EAAQ,CAAA;AAAA;AAAA,cAKG,qBAAA,WAAgC,OAAA,UAAiB,SAAA,CAC5D,4BAAA,CAA6B,CAAA;EAAA,mBAEV,gBAAA,EAAgB,gBAA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AA,EAAU,UAAA;EAAA,mBACV,gBAAA,EAAgB,gBAAA;EAAA,cAErB,OAAA,CAAA;EAAA,SAIE,iBAAA,iBAAiB,iBAAA;;6BANE,MAAA,CAAA,QAAA;;;;;;;;;;;;;;;;;;;;WA0BnB,eAAA,iBAAe,iBAAA;;UApBE,MAAA,CAAA,OAAA;IAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;YAoCvB,UAAA,CAAW,IAAA,EAAM,MAAA;;;;;;;;;;;;;;YAkBjB,gBAAA,CAAiB,IAAA,EAAM,MAAA;;;;;;;;;;;;;;;;;;;;cCvEtB,oCAAA,SAAoC,OAAA;6BAG/C,MAAA,CAAA,OAAA;;;KAEU,8BAAA,GAAiC,MAAA,QACpC,oCAAA;;;cCNI,yBAAA,SAAyB,OAAA;0BAMpC,MAAA,CAAA,OAAA;;;;;;KAEU,mBAAA,GAAsB,MAAA,QAAc,yBAAA;;;cCNnC,gCAAA,SAAgC,OAAA;MAW5C,MAAA,CAAA,OAAA;;;;;;;;;;;;;;;;;;;;;;;;;KAEW,0BAAA,GAA6B,MAAA,QAChC,gCAAA;;;cCfI,uBAAA,SAAuB,OAAA;yBAalC,MAAA,CAAA,QAAA;;;;;KAEU,iBAAA,GAAoB,MAAA,QAAc,uBAAA;;;cChBjC,0BAAA,SAA0B,OAAA;MAarC,MAAA,CAAA,OAAA;;;;;;;;;;;;;KAEU,oBAAA,GAAuB,MAAA,QAAc,0BAAA;;;;;ATsBjD;;;;;;;;;cUPa,sBAAA,EAAsB,MAAA,CAAA,OAAA,CAcjC,MAAA,CAdiC,MAAA"}
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { $inject, $module, Alepha, AlephaError, KIND, Primitive, createPrimitive, t } from "alepha";
|
|
2
|
-
import { $job } from "alepha/api/jobs";
|
|
2
|
+
import { $job, JobService, jobExecutionEntity } from "alepha/api/jobs";
|
|
3
|
+
import { $secure } from "alepha/security";
|
|
4
|
+
import { $action } from "alepha/server";
|
|
5
|
+
import { $repository, pageQuerySchema } from "alepha/orm";
|
|
3
6
|
import { EmailProvider } from "alepha/email";
|
|
4
|
-
import { $logger } from "alepha/logger";
|
|
7
|
+
import { $logger, logEntrySchema } from "alepha/logger";
|
|
5
8
|
import { SmsProvider } from "alepha/sms";
|
|
6
9
|
|
|
7
10
|
//#region ../../src/api/notifications/schemas/notificationPayloadSchema.ts
|
|
@@ -92,18 +95,31 @@ var NotificationSenderService = class {
|
|
|
92
95
|
contact: payload.contact
|
|
93
96
|
});
|
|
94
97
|
if (payload.type === "email") {
|
|
95
|
-
|
|
98
|
+
const rendered = this.renderEmail(payload);
|
|
99
|
+
await this.emailProvider.send(rendered);
|
|
96
100
|
this.log.info("Email notification sent", {
|
|
97
101
|
template: payload.template,
|
|
98
102
|
contact: payload.contact
|
|
99
103
|
});
|
|
104
|
+
return {
|
|
105
|
+
type: "email",
|
|
106
|
+
to: rendered.to,
|
|
107
|
+
subject: rendered.subject,
|
|
108
|
+
body: rendered.body
|
|
109
|
+
};
|
|
100
110
|
}
|
|
101
111
|
if (payload.type === "sms") {
|
|
102
|
-
|
|
112
|
+
const rendered = this.renderSms(payload);
|
|
113
|
+
await this.smsProvider.send(rendered);
|
|
103
114
|
this.log.info("SMS notification sent", {
|
|
104
115
|
template: payload.template,
|
|
105
116
|
contact: payload.contact
|
|
106
117
|
});
|
|
118
|
+
return {
|
|
119
|
+
type: "sms",
|
|
120
|
+
to: rendered.to,
|
|
121
|
+
message: rendered.message
|
|
122
|
+
};
|
|
107
123
|
}
|
|
108
124
|
}
|
|
109
125
|
renderSms(payload) {
|
|
@@ -142,6 +158,7 @@ var NotificationSenderService = class {
|
|
|
142
158
|
//#region ../../src/api/notifications/jobs/NotificationJobs.ts
|
|
143
159
|
var NotificationJobs = class {
|
|
144
160
|
notificationSenderService = $inject(NotificationSenderService);
|
|
161
|
+
executions = $repository(jobExecutionEntity);
|
|
145
162
|
sendNotification = $job({
|
|
146
163
|
schema: notificationPayloadSchema,
|
|
147
164
|
retry: {
|
|
@@ -156,9 +173,123 @@ var NotificationJobs = class {
|
|
|
156
173
|
timeout: [30, "seconds"],
|
|
157
174
|
concurrency: 5,
|
|
158
175
|
handler: async ({ items }) => {
|
|
159
|
-
for (const item of items)
|
|
176
|
+
for (const item of items) {
|
|
177
|
+
const rendered = await this.notificationSenderService.send(item.payload);
|
|
178
|
+
if (rendered) await this.executions.updateById(item.id, { result: rendered });
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
});
|
|
182
|
+
};
|
|
183
|
+
|
|
184
|
+
//#endregion
|
|
185
|
+
//#region ../../src/api/notifications/schemas/notificationResourceSchema.ts
|
|
186
|
+
const notificationResourceSchema = t.object({
|
|
187
|
+
id: t.uuid(),
|
|
188
|
+
createdAt: t.datetime(),
|
|
189
|
+
status: t.text(),
|
|
190
|
+
template: t.optional(t.text()),
|
|
191
|
+
type: t.optional(t.text()),
|
|
192
|
+
contact: t.optional(t.text()),
|
|
193
|
+
category: t.optional(t.text()),
|
|
194
|
+
critical: t.optional(t.boolean()),
|
|
195
|
+
sensitive: t.optional(t.boolean()),
|
|
196
|
+
startedAt: t.optional(t.datetime()),
|
|
197
|
+
completedAt: t.optional(t.datetime()),
|
|
198
|
+
error: t.optional(t.text())
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
//#endregion
|
|
202
|
+
//#region ../../src/api/notifications/schemas/notificationDetailResourceSchema.ts
|
|
203
|
+
const notificationDetailResourceSchema = t.extend(notificationResourceSchema, {
|
|
204
|
+
variables: t.optional(t.record(t.text(), t.any())),
|
|
205
|
+
rendered: t.optional(t.record(t.text(), t.any())),
|
|
206
|
+
logs: t.optional(t.array(logEntrySchema))
|
|
207
|
+
}, {
|
|
208
|
+
title: "NotificationDetailResource",
|
|
209
|
+
description: "A notification resource with rendered content and logs."
|
|
210
|
+
});
|
|
211
|
+
|
|
212
|
+
//#endregion
|
|
213
|
+
//#region ../../src/api/notifications/schemas/notificationQuerySchema.ts
|
|
214
|
+
const notificationQuerySchema = t.extend(pageQuerySchema, { status: t.optional(t.enum([
|
|
215
|
+
"pending",
|
|
216
|
+
"scheduled",
|
|
217
|
+
"retrying",
|
|
218
|
+
"running",
|
|
219
|
+
"completed",
|
|
220
|
+
"failed",
|
|
221
|
+
"dead",
|
|
222
|
+
"cancelled"
|
|
223
|
+
])) });
|
|
224
|
+
|
|
225
|
+
//#endregion
|
|
226
|
+
//#region ../../src/api/notifications/controllers/AdminNotificationController.ts
|
|
227
|
+
var AdminNotificationController = class {
|
|
228
|
+
url = "/notifications";
|
|
229
|
+
group = "admin:notifications";
|
|
230
|
+
jobService = $inject(JobService);
|
|
231
|
+
notificationJobs = $inject(NotificationJobs);
|
|
232
|
+
get jobName() {
|
|
233
|
+
return this.notificationJobs.sendNotification.name;
|
|
234
|
+
}
|
|
235
|
+
findNotifications = $action({
|
|
236
|
+
path: this.url,
|
|
237
|
+
group: this.group,
|
|
238
|
+
use: [$secure({ permissions: ["admin:notification:read"] })],
|
|
239
|
+
schema: {
|
|
240
|
+
query: notificationQuerySchema,
|
|
241
|
+
response: t.page(notificationResourceSchema)
|
|
242
|
+
},
|
|
243
|
+
handler: async ({ query }) => {
|
|
244
|
+
const result = await this.jobService.findExecutions({
|
|
245
|
+
...query,
|
|
246
|
+
job: this.jobName
|
|
247
|
+
});
|
|
248
|
+
return {
|
|
249
|
+
...result,
|
|
250
|
+
content: result.content.map((exec) => this.toResource(exec))
|
|
251
|
+
};
|
|
252
|
+
}
|
|
253
|
+
});
|
|
254
|
+
getNotification = $action({
|
|
255
|
+
path: `${this.url}/:id`,
|
|
256
|
+
group: this.group,
|
|
257
|
+
use: [$secure({ permissions: ["admin:notification:read"] })],
|
|
258
|
+
schema: {
|
|
259
|
+
params: t.object({ id: t.uuid() }),
|
|
260
|
+
response: notificationDetailResourceSchema
|
|
261
|
+
},
|
|
262
|
+
handler: async ({ params }) => {
|
|
263
|
+
const detail = await this.jobService.getExecution(params.id);
|
|
264
|
+
return this.toDetailResource(detail);
|
|
160
265
|
}
|
|
161
266
|
});
|
|
267
|
+
toResource(exec) {
|
|
268
|
+
const payload = exec.payload ?? {};
|
|
269
|
+
return {
|
|
270
|
+
id: exec.id,
|
|
271
|
+
createdAt: exec.createdAt,
|
|
272
|
+
status: exec.status,
|
|
273
|
+
template: payload.template,
|
|
274
|
+
type: payload.type,
|
|
275
|
+
contact: payload.contact,
|
|
276
|
+
category: payload.category,
|
|
277
|
+
critical: payload.critical,
|
|
278
|
+
sensitive: payload.sensitive,
|
|
279
|
+
startedAt: exec.startedAt,
|
|
280
|
+
completedAt: exec.completedAt,
|
|
281
|
+
error: exec.error
|
|
282
|
+
};
|
|
283
|
+
}
|
|
284
|
+
toDetailResource(exec) {
|
|
285
|
+
const payload = exec.payload ?? {};
|
|
286
|
+
return {
|
|
287
|
+
...this.toResource(exec),
|
|
288
|
+
variables: payload.variables,
|
|
289
|
+
rendered: exec.result,
|
|
290
|
+
logs: exec.logs
|
|
291
|
+
};
|
|
292
|
+
}
|
|
162
293
|
};
|
|
163
294
|
|
|
164
295
|
//#endregion
|
|
@@ -194,12 +325,16 @@ const notificationContactSchema = t.object({
|
|
|
194
325
|
const AlephaApiNotifications = $module({
|
|
195
326
|
name: "alepha.api.notifications",
|
|
196
327
|
primitives: [$notification],
|
|
197
|
-
services: [
|
|
328
|
+
services: [
|
|
329
|
+
NotificationSenderService,
|
|
330
|
+
NotificationJobs,
|
|
331
|
+
AdminNotificationController
|
|
332
|
+
],
|
|
198
333
|
register: (alepha) => {
|
|
199
|
-
alepha.with(NotificationSenderService).with(NotificationJobs);
|
|
334
|
+
alepha.with(NotificationSenderService).with(NotificationJobs).with(AdminNotificationController);
|
|
200
335
|
}
|
|
201
336
|
});
|
|
202
337
|
|
|
203
338
|
//#endregion
|
|
204
|
-
export { $notification, AlephaApiNotifications, NotificationJobs, NotificationPrimitive, NotificationSenderService, notificationContactPreferencesSchema, notificationContactSchema, notificationPayloadSchema };
|
|
339
|
+
export { $notification, AdminNotificationController, AlephaApiNotifications, NotificationJobs, NotificationPrimitive, NotificationSenderService, notificationContactPreferencesSchema, notificationContactSchema, notificationDetailResourceSchema, notificationPayloadSchema, notificationQuerySchema, notificationResourceSchema };
|
|
205
340
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../src/api/notifications/schemas/notificationPayloadSchema.ts","../../../src/api/notifications/primitives/$notification.ts","../../../src/api/notifications/services/NotificationSenderService.ts","../../../src/api/notifications/jobs/NotificationJobs.ts","../../../src/api/notifications/schemas/notificationContactPreferencesSchema.ts","../../../src/api/notifications/schemas/notificationContactSchema.ts","../../../src/api/notifications/index.ts"],"sourcesContent":["import { type Static, t } from \"alepha\";\n\nexport const notificationPayloadSchema = t.object({\n type: t.enum([\"email\", \"sms\"]),\n template: t.text(),\n contact: t.text(),\n variables: t.optional(t.record(t.text(), t.any())),\n category: t.optional(t.text()),\n critical: t.optional(t.boolean()),\n sensitive: t.optional(t.boolean()),\n});\n\nexport type NotificationPayload = Static<typeof notificationPayloadSchema>;\n","import {\n $inject,\n createPrimitive,\n KIND,\n Primitive,\n type Static,\n type StaticEncode,\n type TObject,\n} from \"alepha\";\nimport { NotificationJobs } from \"../jobs/NotificationJobs.ts\";\n\n/**\n * Creates a notification primitive for managing email/SMS notification templates.\n *\n * Provides type-safe, reusable notification templates with multi-language support,\n * variable substitution, and categorization for different notification channels.\n *\n * @example\n * ```ts\n * class NotificationTemplates {\n * welcomeEmail = $notification({\n * name: \"welcome-email\",\n * category: \"onboarding\",\n * schema: t.object({ username: t.text(), activationLink: t.text() }),\n * email: {\n * subject: \"Welcome to our platform!\",\n * body: (vars) => `Hello ${vars.username}, click: ${vars.activationLink}`\n * }\n * });\n *\n * async sendWelcome(user: User) {\n * await this.welcomeEmail.push({\n * variables: { username: user.name, activationLink: generateLink() },\n * contact: user.email\n * });\n * }\n * }\n * ```\n */\nexport const $notification = <T extends TObject>(\n options: NotificationPrimitiveOptions<T>,\n) => createPrimitive(NotificationPrimitive<T>, options);\n\n// ---------------------------------------------------------------------------------------------------------------------\n\nexport interface NotificationPrimitiveOptions<T extends TObject>\n extends NotificationMessage<T> {\n name?: string;\n description?: string;\n category?: string;\n critical?: boolean;\n sensitive?: boolean;\n translations?: {\n // e.g., \"en\", \"fr\", even \"en-US\"\n [lang: string]: NotificationMessage<T>;\n };\n schema: T;\n}\n\n// ---------------------------------------------------------------------------------------------------------------------\n\nexport class NotificationPrimitive<T extends TObject> extends Primitive<\n NotificationPrimitiveOptions<T>\n> {\n protected readonly notificationJobs = $inject(NotificationJobs);\n\n public get name() {\n return this.options.name ?? `${this.config.propertyKey}`;\n }\n\n public async push(options: NotificationPushOptions<T>) {\n const pushOpts = this.options.critical\n ? ({ priority: \"critical\" } as const)\n : undefined;\n\n if (this.options.email) {\n await this.notificationJobs.sendNotification.push(\n {\n type: \"email\",\n template: this.name,\n contact: options.contact,\n variables: options.variables as Record<string, unknown>,\n category: this.options.category,\n critical: this.options.critical,\n sensitive: this.options.sensitive,\n },\n pushOpts,\n );\n }\n\n if (this.options.sms) {\n await this.notificationJobs.sendNotification.push(\n {\n type: \"sms\",\n template: this.name,\n contact: options.contact,\n variables: options.variables as Record<string, unknown>,\n category: this.options.category,\n critical: this.options.critical,\n sensitive: this.options.sensitive,\n },\n pushOpts,\n );\n }\n }\n\n public configure(options: Partial<NotificationPrimitiveOptions<T>>) {\n Object.assign(this.options, options);\n }\n}\n\n$notification[KIND] = NotificationPrimitive;\n\n// ---------------------------------------------------------------------------------------------------------------------\n\nexport interface NotificationPushOptions<T extends TObject> {\n variables: StaticEncode<T>;\n contact: string;\n}\n\nexport interface NotificationMessage<T extends TObject> {\n email?: {\n subject: string;\n body: string | ((variables: Static<T>) => string);\n };\n sms?: {\n message: string | ((variables: Static<T>) => string);\n };\n}\n","import { $inject, Alepha, AlephaError } from \"alepha\";\nimport { EmailProvider } from \"alepha/email\";\nimport { $logger } from \"alepha/logger\";\nimport { SmsProvider } from \"alepha/sms\";\nimport { $notification } from \"../primitives/$notification.ts\";\nimport type { NotificationPayload } from \"../schemas/notificationPayloadSchema.ts\";\n\nexport class NotificationSenderService {\n protected readonly alepha = $inject(Alepha);\n protected readonly log = $logger();\n protected readonly emailProvider = $inject(EmailProvider);\n protected readonly smsProvider = $inject(SmsProvider);\n\n public async send(payload: NotificationPayload) {\n this.log.debug(\"Processing notification\", {\n type: payload.type,\n template: payload.template,\n contact: payload.contact,\n });\n\n if (payload.type === \"email\") {\n await this.emailProvider.send(this.renderEmail(payload));\n this.log.info(\"Email notification sent\", {\n template: payload.template,\n contact: payload.contact,\n });\n }\n\n if (payload.type === \"sms\") {\n await this.smsProvider.send(this.renderSms(payload));\n this.log.info(\"SMS notification sent\", {\n template: payload.template,\n contact: payload.contact,\n });\n }\n }\n\n public renderSms(payload: NotificationPayload) {\n const { variables, contact, template } = this.load(payload);\n\n const sms = template.options.sms;\n if (!sms) {\n throw new AlephaError(\n `Notification template ${payload.template} has no sms defined`,\n );\n }\n\n const message =\n typeof sms.message === \"function\"\n ? sms.message(variables as any)\n : sms.message;\n\n return { to: contact, message };\n }\n\n public renderEmail(payload: NotificationPayload) {\n const { variables, contact, template } = this.load(payload);\n\n const email = template.options.email;\n if (!email) {\n throw new AlephaError(\n `Notification template ${payload.template} has no email defined`,\n );\n }\n\n const subject = email.subject;\n const body =\n typeof email.body === \"function\"\n ? email.body(variables as any)\n : email.body;\n\n return { to: contact, subject, body };\n }\n\n protected load(payload: NotificationPayload) {\n const variables = payload.variables || {};\n const contact = payload.contact;\n const template = this.alepha\n .primitives($notification)\n .find((it) => it.name === payload.template);\n\n if (!template) {\n throw new AlephaError(\n `No notification template found for ${payload.template}`,\n );\n }\n\n return { template, variables, contact };\n }\n}\n","import { $inject } from \"alepha\";\nimport { $job } from \"alepha/api/jobs\";\nimport { notificationPayloadSchema } from \"../schemas/notificationPayloadSchema.ts\";\nimport { NotificationSenderService } from \"../services/NotificationSenderService.ts\";\n\nexport class NotificationJobs {\n protected readonly notificationSenderService = $inject(\n NotificationSenderService,\n );\n\n public readonly sendNotification = $job({\n schema: notificationPayloadSchema,\n retry: {\n retries: 3,\n backoff: {\n initial: [5, \"seconds\"],\n factor: 4,\n max: [10, \"minutes\"],\n jitter: true,\n },\n },\n timeout: [30, \"seconds\"],\n concurrency: 5,\n handler: async ({ items }) => {\n for (const item of items) {\n await this.notificationSenderService.send(item.payload);\n }\n },\n });\n}\n","import { type Static, t } from \"alepha\";\n\nexport const notificationContactPreferencesSchema = t.object({\n language: t.optional(t.text()),\n exclude: t.array(t.text()),\n});\n\nexport type NotificationContactPreferences = Static<\n typeof notificationContactPreferencesSchema\n>;\n","import { type Static, t } from \"alepha\";\n\nexport const notificationContactSchema = t.object({\n email: t.optional(t.email()),\n phoneNumber: t.optional(t.e164()),\n firstName: t.optional(t.shortText()),\n lastName: t.optional(t.text({ size: \"short\" })),\n language: t.optional(t.bcp47()),\n});\n\nexport type NotificationContact = Static<typeof notificationContactSchema>;\n","import { $module } from \"alepha\";\nimport { NotificationJobs } from \"./jobs/NotificationJobs.ts\";\nimport { $notification } from \"./primitives/$notification.ts\";\nimport { NotificationSenderService } from \"./services/NotificationSenderService.ts\";\n\n// ---------------------------------------------------------------------------------------------------------------------\n\nexport * from \"./jobs/NotificationJobs.ts\";\nexport * from \"./primitives/$notification.ts\";\nexport * from \"./schemas/notificationContactPreferencesSchema.ts\";\nexport * from \"./schemas/notificationContactSchema.ts\";\nexport * from \"./schemas/notificationPayloadSchema.ts\";\nexport * from \"./services/NotificationSenderService.ts\";\n\n// ---------------------------------------------------------------------------------------------------------------------\n\n/**\n * User notification management.\n *\n * **Features:**\n * - Notification definitions\n * - Email/SMS notification sending\n * - Job-based delivery with retry and tracking\n * - User preferences\n *\n * @module alepha.api.notifications\n */\nexport const AlephaApiNotifications = $module({\n name: \"alepha.api.notifications\",\n primitives: [$notification],\n services: [NotificationSenderService, NotificationJobs],\n register: (alepha) => {\n alepha.with(NotificationSenderService).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B,SAAO,KAAK,0BAA0B,CAAC,KAAK,iBAAiB;;CAEhE,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/api/notifications/schemas/notificationPayloadSchema.ts","../../../src/api/notifications/primitives/$notification.ts","../../../src/api/notifications/services/NotificationSenderService.ts","../../../src/api/notifications/jobs/NotificationJobs.ts","../../../src/api/notifications/schemas/notificationResourceSchema.ts","../../../src/api/notifications/schemas/notificationDetailResourceSchema.ts","../../../src/api/notifications/schemas/notificationQuerySchema.ts","../../../src/api/notifications/controllers/AdminNotificationController.ts","../../../src/api/notifications/schemas/notificationContactPreferencesSchema.ts","../../../src/api/notifications/schemas/notificationContactSchema.ts","../../../src/api/notifications/index.ts"],"sourcesContent":["import { type Static, t } from \"alepha\";\n\nexport const notificationPayloadSchema = t.object({\n type: t.enum([\"email\", \"sms\"]),\n template: t.text(),\n contact: t.text(),\n variables: t.optional(t.record(t.text(), t.any())),\n category: t.optional(t.text()),\n critical: t.optional(t.boolean()),\n sensitive: t.optional(t.boolean()),\n});\n\nexport type NotificationPayload = Static<typeof notificationPayloadSchema>;\n","import {\n $inject,\n createPrimitive,\n KIND,\n Primitive,\n type Static,\n type StaticEncode,\n type TObject,\n} from \"alepha\";\nimport { NotificationJobs } from \"../jobs/NotificationJobs.ts\";\n\n/**\n * Creates a notification primitive for managing email/SMS notification templates.\n *\n * Provides type-safe, reusable notification templates with multi-language support,\n * variable substitution, and categorization for different notification channels.\n *\n * @example\n * ```ts\n * class NotificationTemplates {\n * welcomeEmail = $notification({\n * name: \"welcome-email\",\n * category: \"onboarding\",\n * schema: t.object({ username: t.text(), activationLink: t.text() }),\n * email: {\n * subject: \"Welcome to our platform!\",\n * body: (vars) => `Hello ${vars.username}, click: ${vars.activationLink}`\n * }\n * });\n *\n * async sendWelcome(user: User) {\n * await this.welcomeEmail.push({\n * variables: { username: user.name, activationLink: generateLink() },\n * contact: user.email\n * });\n * }\n * }\n * ```\n */\nexport const $notification = <T extends TObject>(\n options: NotificationPrimitiveOptions<T>,\n) => createPrimitive(NotificationPrimitive<T>, options);\n\n// ---------------------------------------------------------------------------------------------------------------------\n\nexport interface NotificationPrimitiveOptions<T extends TObject>\n extends NotificationMessage<T> {\n name?: string;\n description?: string;\n category?: string;\n critical?: boolean;\n sensitive?: boolean;\n translations?: {\n // e.g., \"en\", \"fr\", even \"en-US\"\n [lang: string]: NotificationMessage<T>;\n };\n schema: T;\n}\n\n// ---------------------------------------------------------------------------------------------------------------------\n\nexport class NotificationPrimitive<T extends TObject> extends Primitive<\n NotificationPrimitiveOptions<T>\n> {\n protected readonly notificationJobs = $inject(NotificationJobs);\n\n public get name() {\n return this.options.name ?? `${this.config.propertyKey}`;\n }\n\n public async push(options: NotificationPushOptions<T>) {\n const pushOpts = this.options.critical\n ? ({ priority: \"critical\" } as const)\n : undefined;\n\n if (this.options.email) {\n await this.notificationJobs.sendNotification.push(\n {\n type: \"email\",\n template: this.name,\n contact: options.contact,\n variables: options.variables as Record<string, unknown>,\n category: this.options.category,\n critical: this.options.critical,\n sensitive: this.options.sensitive,\n },\n pushOpts,\n );\n }\n\n if (this.options.sms) {\n await this.notificationJobs.sendNotification.push(\n {\n type: \"sms\",\n template: this.name,\n contact: options.contact,\n variables: options.variables as Record<string, unknown>,\n category: this.options.category,\n critical: this.options.critical,\n sensitive: this.options.sensitive,\n },\n pushOpts,\n );\n }\n }\n\n public configure(options: Partial<NotificationPrimitiveOptions<T>>) {\n Object.assign(this.options, options);\n }\n}\n\n$notification[KIND] = NotificationPrimitive;\n\n// ---------------------------------------------------------------------------------------------------------------------\n\nexport interface NotificationPushOptions<T extends TObject> {\n variables: StaticEncode<T>;\n contact: string;\n}\n\nexport interface NotificationMessage<T extends TObject> {\n email?: {\n subject: string;\n body: string | ((variables: Static<T>) => string);\n };\n sms?: {\n message: string | ((variables: Static<T>) => string);\n };\n}\n","import { $inject, Alepha, AlephaError } from \"alepha\";\nimport { EmailProvider } from \"alepha/email\";\nimport { $logger } from \"alepha/logger\";\nimport { SmsProvider } from \"alepha/sms\";\nimport { $notification } from \"../primitives/$notification.ts\";\nimport type { NotificationPayload } from \"../schemas/notificationPayloadSchema.ts\";\n\nexport class NotificationSenderService {\n protected readonly alepha = $inject(Alepha);\n protected readonly log = $logger();\n protected readonly emailProvider = $inject(EmailProvider);\n protected readonly smsProvider = $inject(SmsProvider);\n\n public async send(payload: NotificationPayload) {\n this.log.debug(\"Processing notification\", {\n type: payload.type,\n template: payload.template,\n contact: payload.contact,\n });\n\n if (payload.type === \"email\") {\n const rendered = this.renderEmail(payload);\n await this.emailProvider.send(rendered);\n this.log.info(\"Email notification sent\", {\n template: payload.template,\n contact: payload.contact,\n });\n return {\n type: \"email\" as const,\n to: rendered.to,\n subject: rendered.subject,\n body: rendered.body,\n };\n }\n\n if (payload.type === \"sms\") {\n const rendered = this.renderSms(payload);\n await this.smsProvider.send(rendered);\n this.log.info(\"SMS notification sent\", {\n template: payload.template,\n contact: payload.contact,\n });\n return {\n type: \"sms\" as const,\n to: rendered.to,\n message: rendered.message,\n };\n }\n }\n\n public renderSms(payload: NotificationPayload) {\n const { variables, contact, template } = this.load(payload);\n\n const sms = template.options.sms;\n if (!sms) {\n throw new AlephaError(\n `Notification template ${payload.template} has no sms defined`,\n );\n }\n\n const message =\n typeof sms.message === \"function\"\n ? sms.message(variables as any)\n : sms.message;\n\n return { to: contact, message };\n }\n\n public renderEmail(payload: NotificationPayload) {\n const { variables, contact, template } = this.load(payload);\n\n const email = template.options.email;\n if (!email) {\n throw new AlephaError(\n `Notification template ${payload.template} has no email defined`,\n );\n }\n\n const subject = email.subject;\n const body =\n typeof email.body === \"function\"\n ? email.body(variables as any)\n : email.body;\n\n return { to: contact, subject, body };\n }\n\n protected load(payload: NotificationPayload) {\n const variables = payload.variables || {};\n const contact = payload.contact;\n const template = this.alepha\n .primitives($notification)\n .find((it) => it.name === payload.template);\n\n if (!template) {\n throw new AlephaError(\n `No notification template found for ${payload.template}`,\n );\n }\n\n return { template, variables, contact };\n }\n}\n","import { $inject } from \"alepha\";\nimport { $job, jobExecutionEntity } from \"alepha/api/jobs\";\nimport { $repository } from \"alepha/orm\";\nimport { notificationPayloadSchema } from \"../schemas/notificationPayloadSchema.ts\";\nimport { NotificationSenderService } from \"../services/NotificationSenderService.ts\";\n\nexport class NotificationJobs {\n protected readonly notificationSenderService = $inject(\n NotificationSenderService,\n );\n protected readonly executions = $repository(jobExecutionEntity);\n\n public readonly sendNotification = $job({\n schema: notificationPayloadSchema,\n retry: {\n retries: 3,\n backoff: {\n initial: [5, \"seconds\"],\n factor: 4,\n max: [10, \"minutes\"],\n jitter: true,\n },\n },\n timeout: [30, \"seconds\"],\n concurrency: 5,\n handler: async ({ items }) => {\n for (const item of items) {\n const rendered = await this.notificationSenderService.send(\n item.payload,\n );\n if (rendered) {\n await this.executions.updateById(item.id, {\n result: rendered as Record<string, unknown>,\n });\n }\n }\n },\n });\n}\n","import { type Static, t } from \"alepha\";\n\nexport const notificationResourceSchema = t.object({\n id: t.uuid(),\n createdAt: t.datetime(),\n status: t.text(),\n template: t.optional(t.text()),\n type: t.optional(t.text()),\n contact: t.optional(t.text()),\n category: t.optional(t.text()),\n critical: t.optional(t.boolean()),\n sensitive: t.optional(t.boolean()),\n startedAt: t.optional(t.datetime()),\n completedAt: t.optional(t.datetime()),\n error: t.optional(t.text()),\n});\n\nexport type NotificationResource = Static<typeof notificationResourceSchema>;\n","import { type Static, t } from \"alepha\";\nimport { logEntrySchema } from \"alepha/logger\";\nimport { notificationResourceSchema } from \"./notificationResourceSchema.ts\";\n\nexport const notificationDetailResourceSchema = t.extend(\n notificationResourceSchema,\n {\n variables: t.optional(t.record(t.text(), t.any())),\n rendered: t.optional(t.record(t.text(), t.any())),\n logs: t.optional(t.array(logEntrySchema)),\n },\n {\n title: \"NotificationDetailResource\",\n description: \"A notification resource with rendered content and logs.\",\n },\n);\n\nexport type NotificationDetailResource = Static<\n typeof notificationDetailResourceSchema\n>;\n","import { type Static, t } from \"alepha\";\nimport { pageQuerySchema } from \"alepha/orm\";\n\nexport const notificationQuerySchema = t.extend(pageQuerySchema, {\n status: t.optional(\n t.enum([\n \"pending\",\n \"scheduled\",\n \"retrying\",\n \"running\",\n \"completed\",\n \"failed\",\n \"dead\",\n \"cancelled\",\n ]),\n ),\n});\n\nexport type NotificationQuery = Static<typeof notificationQuerySchema>;\n","import { $inject, t } from \"alepha\";\nimport { JobService } from \"alepha/api/jobs\";\nimport { $secure } from \"alepha/security\";\nimport { $action } from \"alepha/server\";\nimport { NotificationJobs } from \"../jobs/NotificationJobs.ts\";\nimport { notificationDetailResourceSchema } from \"../schemas/notificationDetailResourceSchema.ts\";\nimport { notificationQuerySchema } from \"../schemas/notificationQuerySchema.ts\";\nimport { notificationResourceSchema } from \"../schemas/notificationResourceSchema.ts\";\n\nexport class AdminNotificationController {\n protected readonly url: string = \"/notifications\";\n protected readonly group: string = \"admin:notifications\";\n protected readonly jobService = $inject(JobService);\n protected readonly notificationJobs = $inject(NotificationJobs);\n\n protected get jobName(): string {\n return this.notificationJobs.sendNotification.name;\n }\n\n public readonly findNotifications = $action({\n path: this.url,\n group: this.group,\n use: [$secure({ permissions: [\"admin:notification:read\"] })],\n schema: {\n query: notificationQuerySchema,\n response: t.page(notificationResourceSchema),\n },\n handler: async ({ query }) => {\n const result = await this.jobService.findExecutions({\n ...query,\n job: this.jobName,\n });\n return {\n ...result,\n content: result.content.map((exec) => this.toResource(exec)),\n } as any;\n },\n });\n\n public readonly getNotification = $action({\n path: `${this.url}/:id`,\n group: this.group,\n use: [$secure({ permissions: [\"admin:notification:read\"] })],\n schema: {\n params: t.object({\n id: t.uuid(),\n }),\n response: notificationDetailResourceSchema,\n },\n handler: async ({ params }) => {\n const detail = await this.jobService.getExecution(params.id);\n return this.toDetailResource(detail) as any;\n },\n });\n\n protected toResource(exec: Record<string, unknown>) {\n const payload = (exec.payload ?? {}) as Record<string, unknown>;\n return {\n id: exec.id,\n createdAt: exec.createdAt,\n status: exec.status,\n template: payload.template,\n type: payload.type,\n contact: payload.contact,\n category: payload.category,\n critical: payload.critical,\n sensitive: payload.sensitive,\n startedAt: exec.startedAt,\n completedAt: exec.completedAt,\n error: exec.error,\n };\n }\n\n protected toDetailResource(exec: Record<string, unknown>) {\n const payload = (exec.payload ?? {}) as Record<string, unknown>;\n return {\n ...this.toResource(exec),\n variables: payload.variables,\n rendered: exec.result,\n logs: exec.logs,\n };\n }\n}\n","import { type Static, t } from \"alepha\";\n\nexport const notificationContactPreferencesSchema = t.object({\n language: t.optional(t.text()),\n exclude: t.array(t.text()),\n});\n\nexport type NotificationContactPreferences = Static<\n typeof notificationContactPreferencesSchema\n>;\n","import { type Static, t } from \"alepha\";\n\nexport const notificationContactSchema = t.object({\n email: t.optional(t.email()),\n phoneNumber: t.optional(t.e164()),\n firstName: t.optional(t.shortText()),\n lastName: t.optional(t.text({ size: \"short\" })),\n language: t.optional(t.bcp47()),\n});\n\nexport type NotificationContact = Static<typeof notificationContactSchema>;\n","import { $module } from \"alepha\";\nimport { AdminNotificationController } from \"./controllers/AdminNotificationController.ts\";\nimport { NotificationJobs } from \"./jobs/NotificationJobs.ts\";\nimport { $notification } from \"./primitives/$notification.ts\";\nimport { NotificationSenderService } from \"./services/NotificationSenderService.ts\";\n\n// ---------------------------------------------------------------------------------------------------------------------\n\nexport * from \"./controllers/AdminNotificationController.ts\";\nexport * from \"./jobs/NotificationJobs.ts\";\nexport * from \"./primitives/$notification.ts\";\nexport * from \"./schemas/notificationContactPreferencesSchema.ts\";\nexport * from \"./schemas/notificationContactSchema.ts\";\nexport * from \"./schemas/notificationDetailResourceSchema.ts\";\nexport * from \"./schemas/notificationPayloadSchema.ts\";\nexport * from \"./schemas/notificationQuerySchema.ts\";\nexport * from \"./schemas/notificationResourceSchema.ts\";\nexport * from \"./services/NotificationSenderService.ts\";\n\n// ---------------------------------------------------------------------------------------------------------------------\n\n/**\n * User notification management.\n *\n * **Features:**\n * - Notification definitions\n * - Email/SMS notification sending\n * - Job-based delivery with retry and tracking\n * - User preferences\n *\n * @module alepha.api.notifications\n */\nexport const AlephaApiNotifications = $module({\n name: \"alepha.api.notifications\",\n primitives: [$notification],\n services: [\n NotificationSenderService,\n NotificationJobs,\n AdminNotificationController,\n ],\n register: (alepha) => {\n alepha\n .with(NotificationSenderService)\n .with(NotificationJobs)\n .with(AdminNotificationController);\n },\n});\n"],"mappings":";;;;;;;;;;AAEA,MAAa,4BAA4B,EAAE,OAAO;CAChD,MAAM,EAAE,KAAK,CAAC,SAAS,MAAM,CAAC;CAC9B,UAAU,EAAE,MAAM;CAClB,SAAS,EAAE,MAAM;CACjB,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,KAAK,CAAC,CAAC;CAClD,UAAU,EAAE,SAAS,EAAE,MAAM,CAAC;CAC9B,UAAU,EAAE,SAAS,EAAE,SAAS,CAAC;CACjC,WAAW,EAAE,SAAS,EAAE,SAAS,CAAC;CACnC,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AC6BF,MAAa,iBACX,YACG,gBAAgB,uBAA0B,QAAQ;AAoBvD,IAAa,wBAAb,cAA8D,UAE5D;CACA,AAAmB,mBAAmB,QAAQ,iBAAiB;CAE/D,IAAW,OAAO;AAChB,SAAO,KAAK,QAAQ,QAAQ,GAAG,KAAK,OAAO;;CAG7C,MAAa,KAAK,SAAqC;EACrD,MAAM,WAAW,KAAK,QAAQ,WACzB,EAAE,UAAU,YAAY,GACzB;AAEJ,MAAI,KAAK,QAAQ,MACf,OAAM,KAAK,iBAAiB,iBAAiB,KAC3C;GACE,MAAM;GACN,UAAU,KAAK;GACf,SAAS,QAAQ;GACjB,WAAW,QAAQ;GACnB,UAAU,KAAK,QAAQ;GACvB,UAAU,KAAK,QAAQ;GACvB,WAAW,KAAK,QAAQ;GACzB,EACD,SACD;AAGH,MAAI,KAAK,QAAQ,IACf,OAAM,KAAK,iBAAiB,iBAAiB,KAC3C;GACE,MAAM;GACN,UAAU,KAAK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AAC;CAC3B,CAAC;;;;ACHF,MAAa,4BAA4B,EAAE,OAAO;CAChD,OAAO,EAAE,SAAS,EAAE,OAAO,CAAC;CAC5B,aAAa,EAAE,SAAS,EAAE,MAAM,CAAC;CACjC,WAAW,EAAE,SAAS,EAAE,WAAW,CAAC;CACpC,UAAU,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC,CAAC;CAC/C,UAAU,EAAE,SAAS,EAAE,OAAO,CAAC;CAChC,CAAC;;;;;;;;;;;;;;;ACwBF,MAAa,yBAAyB,QAAQ;CAC5C,MAAM;CACN,YAAY,CAAC,cAAc;CAC3B,UAAU;EACR;EACA;EACA;EACD;CACD,WAAW,WAAW;AACpB,SACG,KAAK,0BAA0B,CAC/B,KAAK,iBAAiB,CACtB,KAAK,4BAA4B;;CAEvC,CAAC"}
|
|
@@ -18,12 +18,15 @@ import "drizzle-orm/sqlite-core";
|
|
|
18
18
|
/**
|
|
19
19
|
* Transforms a TObject schema for insert operations.
|
|
20
20
|
* All default properties at the root level are made optional.
|
|
21
|
+
* Generated columns are excluded entirely.
|
|
21
22
|
*
|
|
22
23
|
* @example
|
|
23
|
-
* Before: { name: string; age: number(default=0); }
|
|
24
|
+
* Before: { name: string; age: number(default=0); fullName: generated }
|
|
24
25
|
* After: { name: string; age?: number; }
|
|
25
26
|
*/
|
|
26
|
-
type TObjectInsert<T extends TObject> = TObject<{ [K in keyof T["properties"]
|
|
27
|
+
type TObjectInsert<T extends TObject> = TObject<{ [K in keyof T["properties"] as T["properties"][K] extends {
|
|
28
|
+
[PG_GENERATED]: any;
|
|
29
|
+
} ? never : K]: T["properties"][K] extends {
|
|
27
30
|
[PG_DEFAULT]: any;
|
|
28
31
|
} | {
|
|
29
32
|
"~optional": true;
|
|
@@ -33,13 +36,15 @@ type TObjectInsert<T extends TObject> = TObject<{ [K in keyof T["properties"]]:
|
|
|
33
36
|
/**
|
|
34
37
|
* Transforms a TObject schema for update operations.
|
|
35
38
|
* All optional properties at the root level are made nullable (i.e., `T | null`).
|
|
36
|
-
*
|
|
39
|
+
* Generated columns are excluded entirely.
|
|
37
40
|
*
|
|
38
41
|
* @example
|
|
39
|
-
* Before: { name?: string; age: number; }
|
|
42
|
+
* Before: { name?: string; age: number; fullName: generated }
|
|
40
43
|
* After: { name?: string | null; age: number; }
|
|
41
44
|
*/
|
|
42
|
-
type TObjectUpdate<T extends TObject> = TObject<{ [K in keyof T["properties"]
|
|
45
|
+
type TObjectUpdate<T extends TObject> = TObject<{ [K in keyof T["properties"] as T["properties"][K] extends {
|
|
46
|
+
[PG_GENERATED]: any;
|
|
47
|
+
} ? never : K]: T["properties"][K] extends TOptional<infer U> ? TOptional<TUnion<[U, TNull]>> : T["properties"][K] }>;
|
|
43
48
|
//#endregion
|
|
44
49
|
//#region ../../src/orm/core/primitives/$entity.d.ts
|
|
45
50
|
interface EntityPrimitiveOptions<T extends TObject, Keys = keyof Static<T>> {
|
|
@@ -68,6 +73,10 @@ interface EntityPrimitiveOptions<T extends TObject, Keys = keyof Static<T>> {
|
|
|
68
73
|
* Custom name for the index. If not provided, generates name automatically.
|
|
69
74
|
*/
|
|
70
75
|
name?: string;
|
|
76
|
+
/**
|
|
77
|
+
* Partial index condition. Only rows matching this SQL expression are indexed.
|
|
78
|
+
*/
|
|
79
|
+
where?: SQL;
|
|
71
80
|
} | {
|
|
72
81
|
/**
|
|
73
82
|
* Multiple columns for composite index (order matters for query optimization).
|
|
@@ -81,6 +90,10 @@ interface EntityPrimitiveOptions<T extends TObject, Keys = keyof Static<T>> {
|
|
|
81
90
|
* Custom name for the index. If not provided, generates name automatically.
|
|
82
91
|
*/
|
|
83
92
|
name?: string;
|
|
93
|
+
/**
|
|
94
|
+
* Partial index condition. Only rows matching this SQL expression are indexed.
|
|
95
|
+
*/
|
|
96
|
+
where?: SQL;
|
|
84
97
|
})[];
|
|
85
98
|
/**
|
|
86
99
|
* Foreign key constraints to maintain referential integrity.
|
|
@@ -184,6 +197,7 @@ declare const PG_VERSION: unique symbol;
|
|
|
184
197
|
declare const PG_IDENTITY: unique symbol;
|
|
185
198
|
declare const PG_ENUM: unique symbol;
|
|
186
199
|
declare const PG_REF: unique symbol;
|
|
200
|
+
declare const PG_GENERATED: unique symbol;
|
|
187
201
|
/**
|
|
188
202
|
* @deprecated Use `PG_IDENTITY` instead.
|
|
189
203
|
*/
|
|
@@ -198,6 +212,7 @@ type PgSymbols = {
|
|
|
198
212
|
[PG_IDENTITY]: PgIdentityOptions;
|
|
199
213
|
[PG_REF]: PgRefOptions;
|
|
200
214
|
[PG_ENUM]: PgEnumOptions;
|
|
215
|
+
[PG_GENERATED]: PgGeneratedOptions;
|
|
201
216
|
/**
|
|
202
217
|
* @deprecated Use `PG_IDENTITY` instead.
|
|
203
218
|
*/
|
|
@@ -213,6 +228,18 @@ interface PgEnumOptions {
|
|
|
213
228
|
name?: string;
|
|
214
229
|
description?: string;
|
|
215
230
|
}
|
|
231
|
+
interface PgGeneratedOptions {
|
|
232
|
+
/**
|
|
233
|
+
* SQL expression for the generated column.
|
|
234
|
+
*/
|
|
235
|
+
expression: SQL;
|
|
236
|
+
/**
|
|
237
|
+
* Storage mode for the generated column.
|
|
238
|
+
* - `"stored"` — value is computed on write and stored on disk (default for PostgreSQL).
|
|
239
|
+
* - `"virtual"` — value is computed on read (default for SQLite).
|
|
240
|
+
*/
|
|
241
|
+
mode?: "stored" | "virtual";
|
|
242
|
+
}
|
|
216
243
|
interface PgRefOptions {
|
|
217
244
|
ref: () => {
|
|
218
245
|
name: string;
|
|
@@ -230,6 +257,35 @@ interface PgRefOptions {
|
|
|
230
257
|
*/
|
|
231
258
|
type PgAttr<T extends TSchema, TAttr extends PgSymbolKeys> = T & { [K in TAttr]: PgSymbols[K] };
|
|
232
259
|
//#endregion
|
|
260
|
+
//#region ../../src/orm/core/schemas/databaseEnvSchema.d.ts
|
|
261
|
+
/**
|
|
262
|
+
* Base database environment schema.
|
|
263
|
+
*
|
|
264
|
+
* Defines the `DATABASE_URL` connection string used by all ORM providers
|
|
265
|
+
* to determine the database driver and connection target.
|
|
266
|
+
*
|
|
267
|
+
* Supported URL formats:
|
|
268
|
+
* - `sqlite://:memory:` or `sqlite://./path/to/db` — SQLite (Node.js or Bun)
|
|
269
|
+
* - `postgres://user:password@host:port/database` — PostgreSQL (Node.js or Bun)
|
|
270
|
+
* - `pglite://:memory:` or `pglite://./path` — PGlite (embedded Postgres)
|
|
271
|
+
* - `d1://BINDING_NAME` — Cloudflare D1
|
|
272
|
+
* - `hyperdrive://BINDING_NAME` — Cloudflare Hyperdrive
|
|
273
|
+
*/
|
|
274
|
+
declare const databaseEnvSchema: alepha.TObject<{
|
|
275
|
+
DATABASE_URL: alepha.TOptional<alepha.TString>;
|
|
276
|
+
/**
|
|
277
|
+
* Enable or disable push-based schema synchronization (drizzle-kit push).
|
|
278
|
+
*
|
|
279
|
+
* Defaults to `true` in development and test, `false` in production.
|
|
280
|
+
* Set to `false` in development to skip automatic schema sync
|
|
281
|
+
* (e.g. when managing migrations manually).
|
|
282
|
+
*/
|
|
283
|
+
DATABASE_SYNC: alepha.TOptional<alepha.TBoolean>;
|
|
284
|
+
}>;
|
|
285
|
+
declare module "alepha" {
|
|
286
|
+
interface Env extends Partial<Static<typeof databaseEnvSchema>> {}
|
|
287
|
+
} //# sourceMappingURL=databaseEnvSchema.d.ts.map
|
|
288
|
+
//#endregion
|
|
233
289
|
//#region ../../src/api/parameters/entities/parameters.d.ts
|
|
234
290
|
/**
|
|
235
291
|
* Configuration parameter entity for versioned configuration management.
|