alepha 0.20.1 → 0.20.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/README.md +0 -1
- package/assets/swagger-ui/swagger-ui-bundle.js +1 -1
- package/assets/swagger-ui/swagger-ui.css +1 -1
- package/dist/api/audits/index.browser.js +49 -0
- package/dist/api/audits/index.browser.js.map +1 -1
- package/dist/api/audits/index.d.ts.map +1 -1
- package/dist/api/audits/index.js +49 -0
- package/dist/api/audits/index.js.map +1 -1
- package/dist/api/files/index.d.ts.map +1 -1
- package/dist/api/files/index.js +2 -1
- package/dist/api/files/index.js.map +1 -1
- package/dist/api/jobs/index.browser.js +64 -148
- package/dist/api/jobs/index.browser.js.map +1 -1
- package/dist/api/jobs/index.d.ts +339 -600
- package/dist/api/jobs/index.d.ts.map +1 -1
- package/dist/api/jobs/index.js +605 -1012
- package/dist/api/jobs/index.js.map +1 -1
- package/dist/api/keys/index.js.map +1 -1
- package/dist/api/notifications/index.d.ts +79 -27
- package/dist/api/notifications/index.d.ts.map +1 -1
- package/dist/api/notifications/index.js +90 -23
- package/dist/api/notifications/index.js.map +1 -1
- package/dist/api/organizations/index.d.ts.map +1 -1
- package/dist/api/parameters/index.browser.js +37 -0
- package/dist/api/parameters/index.browser.js.map +1 -1
- package/dist/api/parameters/index.d.ts +4 -65
- package/dist/api/parameters/index.d.ts.map +1 -1
- package/dist/api/parameters/index.js +37 -0
- package/dist/api/parameters/index.js.map +1 -1
- package/dist/api/payments/index.d.ts +2 -1
- package/dist/api/payments/index.d.ts.map +1 -1
- package/dist/api/payments/index.js +4 -2
- package/dist/api/payments/index.js.map +1 -1
- package/dist/api/users/index.d.ts +225 -5199
- package/dist/api/users/index.d.ts.map +1 -1
- package/dist/api/users/index.js +15 -11
- package/dist/api/users/index.js.map +1 -1
- package/dist/api/verifications/index.d.ts.map +1 -1
- package/dist/api/verifications/index.js +4 -2
- package/dist/api/verifications/index.js.map +1 -1
- package/dist/bucket/index.js +5 -1
- package/dist/bucket/index.js.map +1 -1
- package/dist/bucket/index.workerd.js +5 -1
- package/dist/bucket/index.workerd.js.map +1 -1
- package/dist/cache/core/index.js.map +1 -1
- package/dist/cache/core/index.workerd.js.map +1 -1
- package/dist/captcha/index.js.map +1 -1
- package/dist/cli/core/index.d.ts +225 -11681
- package/dist/cli/core/index.d.ts.map +1 -1
- package/dist/cli/core/index.js +732 -257
- package/dist/cli/core/index.js.map +1 -1
- package/dist/cli/devtools/index.js +7 -1
- package/dist/cli/devtools/index.js.map +1 -1
- package/dist/cli/platform/index.d.ts +65 -63
- package/dist/cli/platform/index.d.ts.map +1 -1
- package/dist/cli/platform/index.js +140 -27
- package/dist/cli/platform/index.js.map +1 -1
- package/dist/cli/vendor/index.js +15 -0
- package/dist/cli/vendor/index.js.map +1 -1
- package/dist/command/index.d.ts +1 -1
- package/dist/command/index.js +1 -1
- package/dist/command/index.js.map +1 -1
- package/dist/core/index.browser.js +6 -0
- package/dist/core/index.browser.js.map +1 -1
- package/dist/core/index.d.ts +8 -8
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +6 -0
- package/dist/core/index.js.map +1 -1
- package/dist/core/index.native.js +6 -0
- package/dist/core/index.native.js.map +1 -1
- package/dist/core/index.workerd.js +6 -0
- package/dist/core/index.workerd.js.map +1 -1
- package/dist/crypto/index.js.map +1 -1
- package/dist/datetime/index.js.map +1 -1
- package/dist/email/core/index.js.map +1 -1
- package/dist/email/smtp/index.js +2 -10522
- package/dist/email/smtp/index.js.map +1 -1
- package/dist/fake/index.d.ts +4 -8085
- package/dist/fake/index.d.ts.map +1 -1
- package/dist/fake/index.js +3 -33554
- package/dist/fake/index.js.map +1 -1
- package/dist/lock/core/index.js.map +1 -1
- package/dist/lock/redis/index.js.map +1 -1
- package/dist/logger/index.js +32 -1
- package/dist/logger/index.js.map +1 -1
- package/dist/mcp/index.js +5 -1
- package/dist/mcp/index.js.map +1 -1
- package/dist/orm/core/index.browser.js +1 -361
- package/dist/orm/core/index.browser.js.map +1 -1
- package/dist/orm/core/index.bun.js +14 -406
- package/dist/orm/core/index.bun.js.map +1 -1
- package/dist/orm/core/index.d.ts +96 -5117
- package/dist/orm/core/index.d.ts.map +1 -1
- package/dist/orm/core/index.js +23 -419
- package/dist/orm/core/index.js.map +1 -1
- package/dist/orm/postgres/index.bun.js +17 -20
- package/dist/orm/postgres/index.bun.js.map +1 -1
- package/dist/orm/postgres/index.d.ts +2 -613
- package/dist/orm/postgres/index.d.ts.map +1 -1
- package/dist/orm/postgres/index.js +17 -20
- package/dist/orm/postgres/index.js.map +1 -1
- package/dist/react/core/index.js.map +1 -1
- package/dist/react/form/index.d.ts +60 -1
- package/dist/react/form/index.d.ts.map +1 -1
- package/dist/react/form/index.js +86 -1
- package/dist/react/form/index.js.map +1 -1
- package/dist/react/head/index.browser.js +16 -1
- package/dist/react/head/index.browser.js.map +1 -1
- package/dist/react/head/index.d.ts +6 -0
- package/dist/react/head/index.d.ts.map +1 -1
- package/dist/react/head/index.js +16 -1
- package/dist/react/head/index.js.map +1 -1
- package/dist/react/i18n/index.js.map +1 -1
- package/dist/react/intro/index.js +22 -17
- package/dist/react/intro/index.js.map +1 -1
- package/dist/react/router/index.browser.js +78 -12
- package/dist/react/router/index.browser.js.map +1 -1
- package/dist/react/router/index.d.ts +57 -13
- package/dist/react/router/index.d.ts.map +1 -1
- package/dist/react/router/index.js +102 -14
- package/dist/react/router/index.js.map +1 -1
- package/dist/react/testing/index.d.ts +1 -411
- package/dist/react/testing/index.d.ts.map +1 -1
- package/dist/react/testing/index.js +13 -12293
- package/dist/react/testing/index.js.map +1 -1
- package/dist/react/ui/index.d.ts +124 -0
- package/dist/react/ui/index.d.ts.map +1 -0
- package/dist/react/ui/index.js +209 -0
- package/dist/react/ui/index.js.map +1 -0
- package/dist/react/websocket/index.js.map +1 -1
- package/dist/redis/index.js.map +1 -1
- package/dist/router/index.d.ts +13 -13
- package/dist/router/index.d.ts.map +1 -1
- package/dist/router/index.js +45 -32
- package/dist/router/index.js.map +1 -1
- package/dist/scheduler/index.d.ts +1 -83
- package/dist/scheduler/index.d.ts.map +1 -1
- package/dist/scheduler/index.js +2 -391
- package/dist/scheduler/index.js.map +1 -1
- package/dist/scheduler/index.workerd.js +2 -391
- package/dist/scheduler/index.workerd.js.map +1 -1
- package/dist/security/index.browser.js.map +1 -1
- package/dist/security/index.d.ts +2 -325
- package/dist/security/index.d.ts.map +1 -1
- package/dist/security/index.js +3 -1362
- package/dist/security/index.js.map +1 -1
- package/dist/server/auth/index.d.ts +1 -1054
- package/dist/server/auth/index.d.ts.map +1 -1
- package/dist/server/auth/index.js +16 -1224
- package/dist/server/auth/index.js.map +1 -1
- package/dist/server/cookies/index.js.map +1 -1
- package/dist/server/core/index.browser.js.map +1 -1
- package/dist/server/core/index.d.ts +1 -4
- package/dist/server/core/index.d.ts.map +1 -1
- package/dist/server/core/index.js +19 -4
- package/dist/server/core/index.js.map +1 -1
- package/dist/server/links/index.browser.js.map +1 -1
- package/dist/server/links/index.js.map +1 -1
- package/dist/server/metrics/index.d.ts +1 -514
- package/dist/server/metrics/index.d.ts.map +1 -1
- package/dist/server/metrics/index.js +4 -4356
- package/dist/server/metrics/index.js.map +1 -1
- package/dist/server/rate-limit/index.js.map +1 -1
- package/dist/server/static/index.js.map +1 -1
- package/dist/server/swagger/index.js +1 -1
- package/dist/server/swagger/index.js.map +1 -1
- package/dist/sms/index.js.map +1 -1
- package/dist/system/index.browser.js.map +1 -1
- package/dist/system/index.d.ts.map +1 -1
- package/dist/system/index.js +1 -0
- package/dist/system/index.js.map +1 -1
- package/dist/system/index.workerd.js.map +1 -1
- package/dist/topic/core/index.js +1 -1
- package/dist/topic/core/index.js.map +1 -1
- package/dist/websocket/index.browser.js +21 -0
- package/dist/websocket/index.browser.js.map +1 -1
- package/dist/websocket/index.js +21 -0
- package/dist/websocket/index.js.map +1 -1
- package/package.json +23 -37
- package/src/api/files/__tests__/FileController.spec.ts +1 -1
- package/src/api/files/jobs/FileJobs.ts +2 -1
- package/src/api/jobs/__tests__/$job.spec.ts +320 -2867
- package/src/api/jobs/controllers/AdminJobController.ts +29 -138
- package/src/api/jobs/entities/jobExecutionEntity.ts +27 -19
- package/src/api/jobs/index.browser.ts +5 -7
- package/src/api/jobs/index.ts +23 -51
- package/src/api/jobs/primitives/$job.ts +66 -58
- package/src/api/jobs/providers/JobProvider.ts +561 -566
- package/src/api/jobs/providers/JobQueueProvider.ts +18 -19
- package/src/api/jobs/schemas/jobConfigAtom.ts +20 -23
- package/src/api/jobs/schemas/jobExecutionQuerySchema.ts +3 -27
- package/src/api/jobs/schemas/jobExecutionResourceSchema.ts +5 -7
- package/src/api/jobs/schemas/jobRegistrationSchema.ts +7 -4
- package/src/api/jobs/schemas/triggerJobSchema.ts +0 -1
- package/src/api/jobs/services/JobService.ts +90 -483
- package/src/api/notifications/controllers/AdminNotificationController.ts +19 -12
- package/src/api/notifications/index.ts +7 -4
- package/src/api/notifications/jobs/NotificationJobs.ts +83 -12
- package/src/api/payments/services/PaymentService.ts +4 -2
- package/src/api/users/__tests__/UserJobs.spec.ts +10 -49
- package/src/api/users/audits/UserAudits.ts +3 -1
- package/src/api/users/buckets/UserBuckets.ts +2 -1
- package/src/api/users/index.ts +1 -4
- package/src/api/users/jobs/UserJobs.ts +5 -4
- package/src/api/users/schemas/userQuerySchema.ts +0 -1
- package/src/api/users/services/UserService.ts +1 -5
- package/src/api/verifications/__tests__/CodeVerification.spec.ts +14 -0
- package/src/api/verifications/__tests__/LinkVerification.spec.ts +14 -0
- package/src/api/verifications/jobs/VerificationJobs.ts +2 -1
- package/src/api/verifications/services/VerificationService.ts +1 -0
- package/src/cli/core/__tests__/init.spec.ts +209 -1
- package/src/cli/core/commands/init.ts +9 -9
- package/src/cli/core/services/PackageManagerUtils.ts +22 -12
- package/src/cli/core/services/ProjectScaffolder.ts +300 -70
- package/src/cli/core/tasks/BuildDockerTask.ts +9 -10
- package/src/cli/core/tasks/BuildServerTask.ts +8 -0
- package/src/cli/core/templates/agentMd.ts +2 -8
- package/src/cli/core/templates/apiIndexTs.ts +22 -14
- package/src/cli/core/templates/componentsJsonTs.ts +39 -0
- package/src/cli/core/templates/mainCss.ts +2 -36
- package/src/cli/core/templates/saasAdminLayoutTsx.ts +77 -0
- package/src/cli/core/templates/saasAdminPagesTsx.ts +26 -0
- package/src/cli/core/templates/saasAuthLayoutTsx.ts +20 -0
- package/src/cli/core/templates/saasAuthPagesTsx.ts +62 -0
- package/src/cli/core/templates/saasRealmProviderTs.ts +46 -0
- package/src/cli/core/templates/vitestConfigTs.ts +17 -0
- package/src/cli/core/templates/webAppRouterTs.ts +102 -82
- package/src/cli/core/templates/webIndexTs.ts +23 -1
- package/src/cli/platform/__tests__/CloudflareAdapter.spec.ts +22 -71
- package/src/cli/platform/__tests__/SecretsCommand.spec.ts +2 -0
- package/src/cli/platform/adapters/CloudflareAdapter.ts +12 -11
- package/src/cli/platform/atoms/platformOptions.ts +9 -0
- package/src/cli/platform/schemas/cloudflare.ts +3 -2
- package/src/cli/platform/services/CloudflareApi.ts +164 -25
- package/src/cli/platform/services/WranglerApi.ts +0 -17
- package/src/command/providers/CliProvider.ts +1 -1
- package/src/core/Alepha.ts +9 -0
- package/src/core/interfaces/Service.ts +3 -1
- package/src/core/providers/TypeProvider.ts +1 -1
- package/src/logger/services/Logger.ts +1 -1
- package/src/mcp/__tests__/$resource.spec.ts +1 -1
- package/src/mcp/__tests__/$tool.spec.ts +1 -1
- package/src/mcp/__tests__/McpServerProvider.spec.ts +1 -1
- package/src/orm/__tests__/$repository-tests.ts +1 -0
- package/src/orm/__tests__/orm-next-tests.ts +2 -67
- package/src/orm/__tests__/orm-next.spec.ts +0 -21
- package/src/orm/core/index.shared.ts +0 -2
- package/src/orm/core/index.ts +1 -2
- package/src/orm/core/primitives/$repository.ts +3 -6
- package/src/orm/core/providers/drivers/DatabaseProvider.ts +0 -5
- package/src/orm/core/providers/drivers/NodeSqliteProvider.ts +11 -13
- package/src/orm/core/services/ModelBuilder.ts +1 -13
- package/src/orm/core/services/Repository.ts +1 -42
- package/src/orm/core/services/SqliteModelBuilder.ts +2 -33
- package/src/orm/postgres/services/PostgresModelBuilder.ts +10 -45
- package/src/react/form/index.ts +2 -0
- package/src/react/form/services/parseField.ts +163 -0
- package/src/react/form/services/prettyName.ts +19 -0
- package/src/react/head/providers/BrowserHeadProvider.ts +31 -10
- package/src/react/intro/components/GettingStartedAuthSlide.tsx +11 -4
- package/src/react/router/__tests__/ReactBrowserProvider.browser.spec.ts +213 -2
- package/src/react/router/primitives/$page.ts +35 -12
- package/src/react/router/providers/ReactBrowserProvider.ts +73 -0
- package/src/react/router/providers/ReactBrowserRouterProvider.ts +1 -1
- package/src/react/router/providers/ReactPreloadProvider.ts +1 -1
- package/src/react/router/providers/ReactServerProvider.ts +1 -0
- package/src/react/ui/atoms/uiAtom.ts +28 -0
- package/src/react/ui/components/ColorScheme.tsx +36 -0
- package/src/react/ui/hooks/useColorMode.ts +49 -0
- package/src/react/ui/hooks/useSidebarState.ts +26 -0
- package/src/react/ui/hooks/useTheme.ts +22 -0
- package/src/react/ui/index.ts +35 -0
- package/src/react/ui/services/UiPersistence.ts +41 -0
- package/src/router/TemplatedPathParser.ts +50 -51
- package/src/router/__tests__/RouterProvider.spec.ts +62 -0
- package/src/router/__tests__/TemplatedPathParser.spec.ts +18 -0
- package/src/router/providers/RouterProvider.ts +10 -5
- package/src/scheduler/providers/CronProvider.ts +1 -1
- package/src/security/primitives/$basicAuth.ts +1 -1
- package/src/server/auth/providers/ServerAuthProvider.ts +5 -1
- package/src/server/core/interfaces/ServerRequest.ts +1 -0
- package/src/server/core/providers/ServerProvider.ts +1 -1
- package/src/server/core/providers/ServerRouterProvider.ts +2 -2
- package/src/server/core/services/HttpClient.ts +1 -1
- package/src/server/swagger/providers/ServerSwaggerProvider.ts +1 -1
- package/src/system/providers/NodeShellProvider.ts +1 -0
- package/src/topic/core/providers/TopicProvider.ts +1 -1
- package/dist/api/invitations/index.d.ts +0 -790
- package/dist/api/invitations/index.d.ts.map +0 -1
- package/dist/api/invitations/index.js +0 -662
- package/dist/api/invitations/index.js.map +0 -1
- package/dist/api/issues/index.d.ts +0 -810
- package/dist/api/issues/index.d.ts.map +0 -1
- package/dist/api/issues/index.js +0 -444
- package/dist/api/issues/index.js.map +0 -1
- package/dist/api/subscriptions/index.d.ts +0 -1692
- package/dist/api/subscriptions/index.d.ts.map +0 -1
- package/dist/api/subscriptions/index.js +0 -1867
- package/dist/api/subscriptions/index.js.map +0 -1
- package/dist/api/workflows/index.browser.js +0 -246
- package/dist/api/workflows/index.browser.js.map +0 -1
- package/dist/api/workflows/index.d.ts +0 -1618
- package/dist/api/workflows/index.d.ts.map +0 -1
- package/dist/api/workflows/index.js +0 -1495
- package/dist/api/workflows/index.js.map +0 -1
- package/dist/react/testing/chunk-DBEY4PJZ.js +0 -16
- package/src/api/invitations/__tests__/InvitationService.spec.ts +0 -439
- package/src/api/invitations/controllers/AdminInvitationController.ts +0 -86
- package/src/api/invitations/controllers/InvitationController.ts +0 -84
- package/src/api/invitations/entities/invitations.ts +0 -33
- package/src/api/invitations/index.ts +0 -58
- package/src/api/invitations/jobs/InvitationJobs.ts +0 -37
- package/src/api/invitations/providers/InvitationProvider.ts +0 -45
- package/src/api/invitations/schemas/createInvitationSchema.ts +0 -12
- package/src/api/invitations/schemas/invitationConfigAtom.ts +0 -20
- package/src/api/invitations/schemas/invitationQuerySchema.ts +0 -15
- package/src/api/invitations/schemas/invitationResourceSchema.ts +0 -6
- package/src/api/invitations/schemas/invitationWithResourceInfoSchema.ts +0 -22
- package/src/api/invitations/schemas/myInvitationsQuerySchema.ts +0 -10
- package/src/api/invitations/services/InvitationService.ts +0 -556
- package/src/api/issues/__tests__/IssueService.spec.ts +0 -263
- package/src/api/issues/controllers/AdminIssueController.ts +0 -149
- package/src/api/issues/controllers/IssueController.ts +0 -44
- package/src/api/issues/entities/issues.ts +0 -49
- package/src/api/issues/index.ts +0 -50
- package/src/api/issues/schemas/createIssueSchema.ts +0 -13
- package/src/api/issues/schemas/issueConfigAtom.ts +0 -13
- package/src/api/issues/schemas/issueQuerySchema.ts +0 -18
- package/src/api/issues/schemas/issueResourceSchema.ts +0 -6
- package/src/api/issues/schemas/myIssueQuerySchema.ts +0 -10
- package/src/api/issues/schemas/updateIssueSchema.ts +0 -13
- package/src/api/issues/services/IssueService.ts +0 -264
- package/src/api/jobs/__tests__/$job-middleware.spec.ts +0 -126
- package/src/api/jobs/__tests__/JobService.spec.ts +0 -31
- package/src/api/jobs/entities/jobExecutionLogEntity.ts +0 -13
- package/src/api/jobs/schemas/jobActivitySchema.ts +0 -15
- package/src/api/jobs/schemas/jobCronInfoSchema.ts +0 -22
- package/src/api/jobs/schemas/jobExecutionDetailResourceSchema.ts +0 -20
- package/src/api/jobs/schemas/jobFailureSchema.ts +0 -9
- package/src/api/jobs/schemas/jobQueueDepthSchema.ts +0 -14
- package/src/api/jobs/schemas/jobStatsSchema.ts +0 -14
- package/src/api/jobs/services/JobService-tests.ts +0 -157
- package/src/api/subscriptions/__tests__/BillingService.spec.ts +0 -218
- package/src/api/subscriptions/__tests__/SubscriptionService.spec.ts +0 -278
- package/src/api/subscriptions/controllers/AdminSubscriptionController.ts +0 -212
- package/src/api/subscriptions/controllers/SubscriptionController.ts +0 -189
- package/src/api/subscriptions/entities/subscriptionEvents.ts +0 -54
- package/src/api/subscriptions/entities/subscriptions.ts +0 -68
- package/src/api/subscriptions/index.ts +0 -133
- package/src/api/subscriptions/jobs/SubscriptionJobs.ts +0 -382
- package/src/api/subscriptions/middleware/$requireLimit.ts +0 -50
- package/src/api/subscriptions/middleware/$requirePlan.ts +0 -49
- package/src/api/subscriptions/notifications/SubscriptionNotifications.ts +0 -110
- package/src/api/subscriptions/schemas/cancelSubscriptionSchema.ts +0 -8
- package/src/api/subscriptions/schemas/changePlanSchema.ts +0 -9
- package/src/api/subscriptions/schemas/createSubscriptionSchema.ts +0 -11
- package/src/api/subscriptions/schemas/entitlementsSchema.ts +0 -21
- package/src/api/subscriptions/schemas/mrrSchema.ts +0 -13
- package/src/api/subscriptions/schemas/planDefinitionSchema.ts +0 -71
- package/src/api/subscriptions/schemas/planResourceSchema.ts +0 -25
- package/src/api/subscriptions/schemas/subscriptionEventResourceSchema.ts +0 -8
- package/src/api/subscriptions/schemas/subscriptionQuerySchema.ts +0 -19
- package/src/api/subscriptions/schemas/subscriptionResourceSchema.ts +0 -6
- package/src/api/subscriptions/schemas/subscriptionSettingsSchema.ts +0 -32
- package/src/api/subscriptions/schemas/subscriptionStatsSchema.ts +0 -23
- package/src/api/subscriptions/services/BillingService.ts +0 -437
- package/src/api/subscriptions/services/SubscriptionConfig.ts +0 -56
- package/src/api/subscriptions/services/SubscriptionService.ts +0 -867
- package/src/api/subscriptions/services/UsageService.ts +0 -118
- package/src/api/workflows/__tests__/$workflow.spec.ts +0 -616
- package/src/api/workflows/controllers/AdminWorkflowController.ts +0 -191
- package/src/api/workflows/entities/workflowExecutions.ts +0 -74
- package/src/api/workflows/entities/workflowStepExecutions.ts +0 -74
- package/src/api/workflows/entities/workflowStepLogs.ts +0 -13
- package/src/api/workflows/index.browser.ts +0 -22
- package/src/api/workflows/index.ts +0 -115
- package/src/api/workflows/jobs/WorkflowJobs.ts +0 -77
- package/src/api/workflows/primitives/$workflow.ts +0 -202
- package/src/api/workflows/providers/WorkflowProvider.ts +0 -1284
- package/src/api/workflows/schemas/workflowActivitySchema.ts +0 -15
- package/src/api/workflows/schemas/workflowConfigAtom.ts +0 -51
- package/src/api/workflows/schemas/workflowExecutionDetailSchema.ts +0 -18
- package/src/api/workflows/schemas/workflowExecutionQuerySchema.ts +0 -26
- package/src/api/workflows/schemas/workflowExecutionResourceSchema.ts +0 -30
- package/src/api/workflows/schemas/workflowRegistrationSchema.ts +0 -26
- package/src/api/workflows/schemas/workflowStatsSchema.ts +0 -16
- package/src/api/workflows/schemas/workflowStepExecutionResourceSchema.ts +0 -15
- package/src/api/workflows/services/WorkflowService.ts +0 -382
- package/src/cli/core/templates/apiAppSecurityTs.ts +0 -43
- package/src/cli/core/templates/webAdminDashboardTsx.ts +0 -17
- package/src/orm/core/__tests__/parseQueryString.spec.ts +0 -196
- package/src/orm/core/helpers/parseQueryString.ts +0 -502
- package/src/orm/core/primitives/$view.ts +0 -88
package/dist/router/index.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ declare abstract class RouterProvider<T extends Route = Route> {
|
|
|
3
3
|
protected routePathRegex: RegExp;
|
|
4
4
|
protected tree: Tree<T>;
|
|
5
5
|
protected cache: Map<string, RouteMatch<T>>;
|
|
6
|
+
protected maxCacheSize: number;
|
|
6
7
|
match(path: string): RouteMatch<T>;
|
|
7
8
|
protected test(path: string): void;
|
|
8
9
|
protected push(route: T): void;
|
|
@@ -67,17 +68,12 @@ interface Tree<T extends Route> {
|
|
|
67
68
|
*/
|
|
68
69
|
declare class TemplatedPathParser {
|
|
69
70
|
protected static readonly PARAM_REGEX: RegExp;
|
|
70
|
-
|
|
71
|
-
|
|
71
|
+
readonly template: string;
|
|
72
|
+
readonly separator: string;
|
|
73
|
+
readonly paramNames: readonly string[];
|
|
74
|
+
readonly hasParams: boolean;
|
|
75
|
+
protected readonly extractRegex: RegExp | null;
|
|
72
76
|
constructor(template: string, separator?: string);
|
|
73
|
-
/**
|
|
74
|
-
* Returns true if the template contains at least one `{param}` placeholder.
|
|
75
|
-
*/
|
|
76
|
-
get hasParams(): boolean;
|
|
77
|
-
/**
|
|
78
|
-
* Returns an ordered list of parameter names found in the template.
|
|
79
|
-
*/
|
|
80
|
-
get paramNames(): string[];
|
|
81
77
|
/**
|
|
82
78
|
* Replaces each `{param}` in the template with the corresponding value
|
|
83
79
|
* from the provided params record.
|
|
@@ -85,10 +81,12 @@ declare class TemplatedPathParser {
|
|
|
85
81
|
interpolate(params: Record<string, string>): string;
|
|
86
82
|
/**
|
|
87
83
|
* Extracts parameter values from a concrete path by matching it against
|
|
88
|
-
* the template structure.
|
|
89
|
-
*
|
|
84
|
+
* the template structure.
|
|
85
|
+
*
|
|
86
|
+
* Returns `null` when the path does not match the template.
|
|
87
|
+
* Returns `{}` when the template has no parameters and the path matches.
|
|
90
88
|
*/
|
|
91
|
-
extract(path: string): Record<string, string
|
|
89
|
+
extract(path: string): Record<string, string> | null;
|
|
92
90
|
/**
|
|
93
91
|
* Replaces each `{param}` placeholder in the template with the given
|
|
94
92
|
* wildcard string. Defaults to `"+"` (MQTT-style).
|
|
@@ -99,6 +97,8 @@ declare class TemplatedPathParser {
|
|
|
99
97
|
* trailing separator (unless the path is just the separator itself).
|
|
100
98
|
*/
|
|
101
99
|
normalize(path: string): string;
|
|
100
|
+
protected buildExtractRegex(): RegExp;
|
|
101
|
+
protected escapeRegex(s: string): string;
|
|
102
102
|
}
|
|
103
103
|
//#endregion
|
|
104
104
|
export { Route, RouteMatch, RouterProvider, TemplatedPathParser, Tree };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/router/providers/RouterProvider.ts","../../src/router/TemplatedPathParser.ts"],"mappings":";uBAEsB,cAAA,WAAyB,KAAA,GAAQ,KAAA;EAAA,UAC3C,cAAA,EAAgB,MAAA;EAAA,UAEhB,IAAA,EAAM,IAAA,CAAK,CAAA;EAAA,UACX,KAAA,EAAK,GAAA,SAAA,UAAA,CAAA,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/router/providers/RouterProvider.ts","../../src/router/TemplatedPathParser.ts"],"mappings":";uBAEsB,cAAA,WAAyB,KAAA,GAAQ,KAAA;EAAA,UAC3C,cAAA,EAAgB,MAAA;EAAA,UAEhB,IAAA,EAAM,IAAA,CAAK,CAAA;EAAA,UACX,KAAA,EAAK,GAAA,SAAA,UAAA,CAAA,CAAA;EAAA,UACL,YAAA;EAEH,KAAA,CAAM,IAAA,WAAe,UAAA,CAAW,CAAA;EAAA,UAY7B,IAAA,CAAK,IAAA;EAAA,UAML,IAAA,CAAK,KAAA,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} };
|
|
6
6
|
cache = /* @__PURE__ */ new Map();
|
|
7
|
+
maxCacheSize = 1e4;
|
|
7
8
|
match(path) {
|
|
8
|
-
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
const pathname = path.split("?", 1)[0];
|
|
10
|
+
const hit = this.cache.get(pathname);
|
|
11
|
+
if (hit) return {
|
|
12
|
+
route: hit.route,
|
|
13
|
+
params: { ...hit.params }
|
|
14
|
+
};
|
|
15
|
+
const result = this.mapParams(this.createRouteMatch(pathname));
|
|
16
|
+
if (this.cache.size >= this.maxCacheSize) this.cache.clear();
|
|
17
|
+
this.cache.set(pathname, result);
|
|
18
|
+
return {
|
|
19
|
+
route: result.route,
|
|
20
|
+
params: { ...result.params }
|
|
21
|
+
};
|
|
12
22
|
}
|
|
13
23
|
test(path) {
|
|
14
24
|
if (!this.routePathRegex.test(path)) throw new AlephaError(`Route '${path}' is not valid`);
|
|
@@ -16,6 +26,7 @@ var RouterProvider = class {
|
|
|
16
26
|
push(route) {
|
|
17
27
|
const path = route.path.replaceAll("//", "/");
|
|
18
28
|
this.test(path);
|
|
29
|
+
this.cache.clear();
|
|
19
30
|
const parts = this.createParts(path);
|
|
20
31
|
let cursor = this.tree;
|
|
21
32
|
for (let i = 0; i < parts.length; i++) {
|
|
@@ -128,50 +139,41 @@ var RouterProvider = class {
|
|
|
128
139
|
* parser.wildcardize("*"); // "cache:*:*"
|
|
129
140
|
* ```
|
|
130
141
|
*/
|
|
131
|
-
var TemplatedPathParser = class {
|
|
142
|
+
var TemplatedPathParser = class TemplatedPathParser {
|
|
132
143
|
static PARAM_REGEX = /\{([^}]+)\}/g;
|
|
133
144
|
template;
|
|
134
145
|
separator;
|
|
146
|
+
paramNames;
|
|
147
|
+
hasParams;
|
|
148
|
+
extractRegex;
|
|
135
149
|
constructor(template, separator = "/") {
|
|
150
|
+
if (separator.length !== 1) throw new AlephaError(`TemplatedPathParser separator must be a single character, got '${separator}'`);
|
|
136
151
|
this.template = template;
|
|
137
152
|
this.separator = separator;
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
*/
|
|
142
|
-
get hasParams() {
|
|
143
|
-
return /\{[^}]+\}/.test(this.template);
|
|
144
|
-
}
|
|
145
|
-
/**
|
|
146
|
-
* Returns an ordered list of parameter names found in the template.
|
|
147
|
-
*/
|
|
148
|
-
get paramNames() {
|
|
149
|
-
return [...this.template.matchAll(/\{([^}]+)\}/g)].map((m) => m[1]);
|
|
153
|
+
this.paramNames = [...template.matchAll(TemplatedPathParser.PARAM_REGEX)].map((m) => m[1]);
|
|
154
|
+
this.hasParams = this.paramNames.length > 0;
|
|
155
|
+
this.extractRegex = this.hasParams ? this.buildExtractRegex() : null;
|
|
150
156
|
}
|
|
151
157
|
/**
|
|
152
158
|
* Replaces each `{param}` in the template with the corresponding value
|
|
153
159
|
* from the provided params record.
|
|
154
160
|
*/
|
|
155
161
|
interpolate(params) {
|
|
156
|
-
return this.template.replace(
|
|
162
|
+
return this.template.replace(TemplatedPathParser.PARAM_REGEX, (_, name) => params[name] ?? `{${name}}`);
|
|
157
163
|
}
|
|
158
164
|
/**
|
|
159
165
|
* Extracts parameter values from a concrete path by matching it against
|
|
160
|
-
* the template structure.
|
|
161
|
-
*
|
|
166
|
+
* the template structure.
|
|
167
|
+
*
|
|
168
|
+
* Returns `null` when the path does not match the template.
|
|
169
|
+
* Returns `{}` when the template has no parameters and the path matches.
|
|
162
170
|
*/
|
|
163
171
|
extract(path) {
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
const regexSource = this.template.replace(/[.*+?^${}()|[\]\\]/g, (char) => {
|
|
168
|
-
if (char === "{" || char === "}") return char;
|
|
169
|
-
return `\\${char}`;
|
|
170
|
-
}).replace(/\{([^}]+)\}/g, `([^${escapedSeparator}]+)`);
|
|
171
|
-
const match = new RegExp(`^${regexSource}$`).exec(path);
|
|
172
|
-
if (!match) return {};
|
|
172
|
+
if (!this.extractRegex) return path === this.template ? {} : null;
|
|
173
|
+
const match = this.extractRegex.exec(path);
|
|
174
|
+
if (!match) return null;
|
|
173
175
|
const result = {};
|
|
174
|
-
for (let i = 0; i <
|
|
176
|
+
for (let i = 0; i < this.paramNames.length; i++) result[this.paramNames[i]] = match[i + 1];
|
|
175
177
|
return result;
|
|
176
178
|
}
|
|
177
179
|
/**
|
|
@@ -179,7 +181,7 @@ var TemplatedPathParser = class {
|
|
|
179
181
|
* wildcard string. Defaults to `"+"` (MQTT-style).
|
|
180
182
|
*/
|
|
181
183
|
wildcardize(wildcard = "+") {
|
|
182
|
-
return this.template.replace(
|
|
184
|
+
return this.template.replace(TemplatedPathParser.PARAM_REGEX, wildcard);
|
|
183
185
|
}
|
|
184
186
|
/**
|
|
185
187
|
* Normalises a path by collapsing repeated separators and stripping a
|
|
@@ -187,11 +189,22 @@ var TemplatedPathParser = class {
|
|
|
187
189
|
*/
|
|
188
190
|
normalize(path) {
|
|
189
191
|
const sep = this.separator;
|
|
190
|
-
const escapedSep =
|
|
192
|
+
const escapedSep = this.escapeRegex(sep);
|
|
191
193
|
let result = path.replace(new RegExp(`${escapedSep}{2,}`, "g"), sep);
|
|
192
194
|
if (result.endsWith(sep) && result.length > sep.length) result = result.slice(0, -sep.length);
|
|
193
195
|
return result;
|
|
194
196
|
}
|
|
197
|
+
buildExtractRegex() {
|
|
198
|
+
const escapedSeparator = this.escapeRegex(this.separator);
|
|
199
|
+
const regexSource = this.template.replace(/[.*+?^${}()|[\]\\]/g, (char) => {
|
|
200
|
+
if (char === "{" || char === "}") return char;
|
|
201
|
+
return `\\${char}`;
|
|
202
|
+
}).replace(/\{[^}]+\}/g, `([^${escapedSeparator}]+)`);
|
|
203
|
+
return new RegExp(`^${regexSource}$`);
|
|
204
|
+
}
|
|
205
|
+
escapeRegex(s) {
|
|
206
|
+
return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
207
|
+
}
|
|
195
208
|
};
|
|
196
209
|
//#endregion
|
|
197
210
|
export { RouterProvider, TemplatedPathParser };
|
package/dist/router/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../src/router/providers/RouterProvider.ts","../../src/router/TemplatedPathParser.ts"],"sourcesContent":["import { AlephaError } from \"alepha\";\n\nexport abstract class RouterProvider<T extends Route = Route> {\n protected routePathRegex: RegExp = /^\\/[A-Za-z0-9._~!$&%'()*+,;=:@{}?/-]*$/;\n\n protected tree: Tree<T> = { children: {} };\n protected cache = new Map<string, RouteMatch<T>>();\n\n public match(path: string): RouteMatch<T> {\n if (this.cache.has(path)) {\n return this.cache.get(path)!;\n }\n const result = this.mapParams(this.createRouteMatch(path));\n this.cache.set(path, result);\n return result;\n }\n\n protected test(path: string): void {\n if (!this.routePathRegex.test(path)) {\n throw new AlephaError(`Route '${path}' is not valid`);\n }\n }\n\n protected push(route: T): void {\n const path = route.path.replaceAll(\"//\", \"/\");\n\n this.test(path);\n\n const parts = this.createParts(path);\n\n let cursor = this.tree;\n for (let i = 0; i < parts.length; i++) {\n const isLast = i === parts.length - 1;\n let part = parts[i].toLowerCase(); // url is case-insensitive\n if (part === \"*\" && isLast) {\n cursor.wildcard = { route };\n break;\n }\n\n if (part.includes(\"*\")) {\n throw new AlephaError(`Route '${path}' has an invalid wildcard syntax`);\n }\n\n if (part.includes(\"{\") || part.includes(\"}\")) {\n if (part.startsWith(\"{\") && part.endsWith(\"}\")) {\n part = `:${part.slice(1, -1)}`; // convert {param} to :param\n } else {\n throw new AlephaError(`Route '${path}' has an invalid param syntax`);\n }\n }\n\n if (part.startsWith(\":\")) {\n const name = parts[i].slice(1).replaceAll(\"}\", \"\");\n if (!name) {\n throw new AlephaError(`Route '${path}' has an empty param name`);\n }\n if (!cursor.param) {\n cursor.param = { name, children: {} };\n } else if (cursor.param.name !== name) {\n // damn, 2 url params with different names\n // got this case with /customers/:id and /customers/:userId/payments\n route.mapParams ??= {};\n route.mapParams[cursor.param.name] = name;\n }\n\n if (isLast) {\n cursor.param.route = route;\n }\n\n cursor = cursor.param;\n continue;\n }\n\n if (!cursor.children[part]) {\n cursor.children[part] = { children: {} };\n }\n\n if (isLast) {\n cursor.children[part].route = route;\n }\n\n cursor = cursor.children[part];\n }\n }\n\n protected createRouteMatch(path: string): RouteMatch<T> {\n if (path[0] !== \"/\") {\n throw new AlephaError(`Path '${path}' must start with \"/\"`);\n }\n\n const parts = this.createParts(path);\n\n let cursor = this.tree;\n let wildcard: { route: T } | undefined;\n const params: Record<string, string> = {};\n\n for (let i = 0; i < parts.length; i++) {\n const part = parts[i].toLowerCase(); // url is case-insensitive\n if (cursor.children[part]) {\n if (cursor.wildcard) {\n wildcard = cursor.wildcard;\n }\n cursor = cursor.children[part];\n } else if (cursor.param) {\n if (cursor.wildcard) {\n wildcard = cursor.wildcard;\n }\n params[cursor.param.name] = parts[i];\n cursor = cursor.param;\n } else if (cursor.wildcard) {\n params[\"*\"] = parts.slice(i).join(\"/\");\n return { route: cursor.wildcard.route, params };\n } else {\n return { route: wildcard?.route, params };\n }\n }\n\n if (!cursor?.route) {\n // when \"/a/*\" - trigger if \"/a\"\n if (cursor.wildcard) {\n return { route: cursor.wildcard.route, params };\n }\n // return deep wildcard or nothing\n return { route: wildcard?.route, params };\n }\n\n return { route: cursor.route, params };\n }\n\n protected mapParams(match: RouteMatch<T>): RouteMatch<T> {\n if (match.route?.mapParams && match.params) {\n for (const [key, value] of Object.entries(match.route.mapParams)) {\n if (match.params[key]) {\n match.params[value] = match.params[key];\n delete match.params[key];\n }\n }\n }\n\n return match;\n }\n\n protected createParts(path: string): string[] {\n let pathname = path.split(\"?\")[0].replaceAll(\"//\", \"/\");\n\n // remove trailing slash\n if (pathname.endsWith(\"/\") && pathname.length > 1) {\n pathname = pathname.slice(0, -1);\n }\n\n return pathname.split(\"/\").slice(1);\n }\n}\n\nexport interface RouteMatch<T extends Route> {\n route?: T;\n params?: Record<string, string>;\n}\n\nexport interface Route {\n path: string;\n\n /**\n * Rename a param in the route.\n * This is automatically filled when you have scenarios like:\n * `/customers/:id` and `/customers/:userId/payments`\n *\n * In this case, `:id` will be renamed to `:userId` in the second route.\n */\n mapParams?: Record<string, string>;\n}\n\nexport interface Tree<T extends Route> {\n route?: T;\n children: {\n [key: string]: Tree<T>;\n };\n param?: {\n route?: T;\n name: string;\n children: {\n [key: string]: Tree<T>;\n };\n };\n wildcard?: {\n route: T;\n };\n}\n","/**\n * Parses and manipulates templated paths with `{param}` placeholders.\n *\n * Used by both RouterProvider (HTTP routes) and TopicProvider (pub/sub topics)\n * to handle parameterized path templates in a unified way.\n *\n * @example\n * ```ts\n * const parser = new TemplatedPathParser(\"/users/{userId}/posts/{postId}\");\n * parser.interpolate({ userId: \"7\", postId: \"42\" }); // \"/users/7/posts/42\"\n * parser.extract(\"/users/7/posts/42\"); // { userId: \"7\", postId: \"42\" }\n * parser.wildcardize(\"+\"); // \"/users/+/posts/+\"\n * ```\n *\n * @example\n * ```ts\n * // Redis-style colon-separated keys\n * const parser = new TemplatedPathParser(\"cache:{namespace}:{key}\", \":\");\n * parser.interpolate({ namespace: \"users\", key: \"42\" }); // \"cache:users:42\"\n * parser.wildcardize(\"*\"); // \"cache:*:*\"\n * ```\n */\nexport class TemplatedPathParser {\n protected static readonly PARAM_REGEX = /\\{([^}]+)\\}/g;\n\n protected readonly template: string;\n protected readonly separator: string;\n\n constructor(template: string, separator = \"/\") {\n this.template = template;\n this.separator = separator;\n }\n\n /**\n * Returns true if the template contains at least one `{param}` placeholder.\n */\n get hasParams(): boolean {\n return /\\{[^}]+\\}/.test(this.template);\n }\n\n /**\n * Returns an ordered list of parameter names found in the template.\n */\n get paramNames(): string[] {\n return [...this.template.matchAll(/\\{([^}]+)\\}/g)].map((m) => m[1]);\n }\n\n /**\n * Replaces each `{param}` in the template with the corresponding value\n * from the provided params record.\n */\n interpolate(params: Record<string, string>): string {\n return this.template.replace(\n /\\{([^}]+)\\}/g,\n (_, name: string) => params[name] ?? `{${name}}`,\n );\n }\n\n /**\n * Extracts parameter values from a concrete path by matching it against\n * the template structure. Returns an empty object when the template has\n * no parameters.\n */\n extract(path: string): Record<string, string> {\n const names = this.paramNames;\n if (names.length === 0) {\n return {};\n }\n\n const escapedSeparator = this.separator.replace(\n /[.*+?^${}()|[\\]\\\\]/g,\n \"\\\\$&\",\n );\n\n // Build a regex from the template: escape literal parts, replace {param} with a capture group\n const regexSource = this.template\n .replace(/[.*+?^${}()|[\\]\\\\]/g, (char) => {\n // Allow { and } through so we can then replace them as param groups\n if (char === \"{\" || char === \"}\") {\n return char;\n }\n return `\\\\${char}`;\n })\n // After escaping literal chars, replace {name} patterns with capture groups.\n // The separator is already escaped above, so we match anything that is not the separator.\n .replace(/\\{([^}]+)\\}/g, `([^${escapedSeparator}]+)`);\n\n const regex = new RegExp(`^${regexSource}$`);\n const match = regex.exec(path);\n\n if (!match) {\n return {};\n }\n\n const result: Record<string, string> = {};\n for (let i = 0; i < names.length; i++) {\n result[names[i]] = match[i + 1];\n }\n return result;\n }\n\n /**\n * Replaces each `{param}` placeholder in the template with the given\n * wildcard string. Defaults to `\"+\"` (MQTT-style).\n */\n wildcardize(wildcard = \"+\"): string {\n return this.template.replace(/\\{[^}]+\\}/g, wildcard);\n }\n\n /**\n * Normalises a path by collapsing repeated separators and stripping a\n * trailing separator (unless the path is just the separator itself).\n */\n normalize(path: string): string {\n const sep = this.separator;\n const escapedSep = sep.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n\n // Replace consecutive separators with a single one\n let result = path.replace(new RegExp(`${escapedSep}{2,}`, \"g\"), sep);\n\n // Strip trailing separator, but preserve a lone separator\n if (result.endsWith(sep) && result.length > sep.length) {\n result = result.slice(0, -sep.length);\n }\n\n return result;\n }\n}\n"],"mappings":";;AAEA,IAAsB,iBAAtB,MAA8D;CAC5D,iBAAmC;CAEnC,OAA0B,EAAE,UAAU,EAAE,EAAE;CAC1C,wBAAkB,IAAI,KAA4B;CAElD,MAAa,MAA6B;AACxC,MAAI,KAAK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I;AAE/B,SAAO;;;;;;CAOT,YAAY,WAAW,KAAa;AAClC,SAAO,KAAK,SAAS,QAAQ,cAAc,SAAS;;;;;;CAOtD,UAAU,MAAsB;EAC9B,MAAM,MAAM,KAAK;EACjB,MAAM,aAAa,IAAI,QAAQ,uBAAuB,OAAO;EAG7D,IAAI,SAAS,KAAK,QAAQ,IAAI,OAAO,GAAG,WAAW,OAAO,IAAI,EAAE,IAAI;AAGpE,MAAI,OAAO,SAAS,IAAI,IAAI,OAAO,SAAS,IAAI,OAC9C,UAAS,OAAO,MAAM,GAAG,CAAC,IAAI,OAAO;AAGvC,SAAO"}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../src/router/providers/RouterProvider.ts","../../src/router/TemplatedPathParser.ts"],"sourcesContent":["import { AlephaError } from \"alepha\";\n\nexport abstract class RouterProvider<T extends Route = Route> {\n protected routePathRegex: RegExp = /^\\/[A-Za-z0-9._~!$&%'()*+,;=:@{}?/-]*$/;\n\n protected tree: Tree<T> = { children: {} };\n protected cache = new Map<string, RouteMatch<T>>();\n protected maxCacheSize = 10_000;\n\n public match(path: string): RouteMatch<T> {\n const pathname = path.split(\"?\", 1)[0];\n const hit = this.cache.get(pathname);\n if (hit) {\n return { route: hit.route, params: { ...hit.params } };\n }\n const result = this.mapParams(this.createRouteMatch(pathname));\n if (this.cache.size >= this.maxCacheSize) this.cache.clear();\n this.cache.set(pathname, result);\n return { route: result.route, params: { ...result.params } };\n }\n\n protected test(path: string): void {\n if (!this.routePathRegex.test(path)) {\n throw new AlephaError(`Route '${path}' is not valid`);\n }\n }\n\n protected push(route: T): void {\n const path = route.path.replaceAll(\"//\", \"/\");\n\n this.test(path);\n this.cache.clear();\n\n const parts = this.createParts(path);\n\n let cursor = this.tree;\n for (let i = 0; i < parts.length; i++) {\n const isLast = i === parts.length - 1;\n let part = parts[i].toLowerCase(); // url is case-insensitive\n if (part === \"*\" && isLast) {\n cursor.wildcard = { route };\n break;\n }\n\n if (part.includes(\"*\")) {\n throw new AlephaError(`Route '${path}' has an invalid wildcard syntax`);\n }\n\n if (part.includes(\"{\") || part.includes(\"}\")) {\n if (part.startsWith(\"{\") && part.endsWith(\"}\")) {\n part = `:${part.slice(1, -1)}`; // convert {param} to :param\n } else {\n throw new AlephaError(`Route '${path}' has an invalid param syntax`);\n }\n }\n\n if (part.startsWith(\":\")) {\n const name = parts[i].slice(1).replaceAll(\"}\", \"\");\n if (!name) {\n throw new AlephaError(`Route '${path}' has an empty param name`);\n }\n if (!cursor.param) {\n cursor.param = { name, children: {} };\n } else if (cursor.param.name !== name) {\n // damn, 2 url params with different names\n // got this case with /customers/:id and /customers/:userId/payments\n route.mapParams ??= {};\n route.mapParams[cursor.param.name] = name;\n }\n\n if (isLast) {\n cursor.param.route = route;\n }\n\n cursor = cursor.param;\n continue;\n }\n\n if (!cursor.children[part]) {\n cursor.children[part] = { children: {} };\n }\n\n if (isLast) {\n cursor.children[part].route = route;\n }\n\n cursor = cursor.children[part];\n }\n }\n\n protected createRouteMatch(path: string): RouteMatch<T> {\n if (path[0] !== \"/\") {\n throw new AlephaError(`Path '${path}' must start with \"/\"`);\n }\n\n const parts = this.createParts(path);\n\n let cursor = this.tree;\n let wildcard: { route: T } | undefined;\n const params: Record<string, string> = {};\n\n for (let i = 0; i < parts.length; i++) {\n const part = parts[i].toLowerCase(); // url is case-insensitive\n if (cursor.children[part]) {\n if (cursor.wildcard) {\n wildcard = cursor.wildcard;\n }\n cursor = cursor.children[part];\n } else if (cursor.param) {\n if (cursor.wildcard) {\n wildcard = cursor.wildcard;\n }\n params[cursor.param.name] = parts[i];\n cursor = cursor.param;\n } else if (cursor.wildcard) {\n params[\"*\"] = parts.slice(i).join(\"/\");\n return { route: cursor.wildcard.route, params };\n } else {\n return { route: wildcard?.route, params };\n }\n }\n\n if (!cursor?.route) {\n // when \"/a/*\" - trigger if \"/a\"\n if (cursor.wildcard) {\n return { route: cursor.wildcard.route, params };\n }\n // return deep wildcard or nothing\n return { route: wildcard?.route, params };\n }\n\n return { route: cursor.route, params };\n }\n\n protected mapParams(match: RouteMatch<T>): RouteMatch<T> {\n if (match.route?.mapParams && match.params) {\n for (const [key, value] of Object.entries(match.route.mapParams)) {\n if (match.params[key]) {\n match.params[value] = match.params[key];\n delete match.params[key];\n }\n }\n }\n\n return match;\n }\n\n protected createParts(path: string): string[] {\n let pathname = path.split(\"?\")[0].replaceAll(\"//\", \"/\");\n\n // remove trailing slash\n if (pathname.endsWith(\"/\") && pathname.length > 1) {\n pathname = pathname.slice(0, -1);\n }\n\n return pathname.split(\"/\").slice(1);\n }\n}\n\nexport interface RouteMatch<T extends Route> {\n route?: T;\n params?: Record<string, string>;\n}\n\nexport interface Route {\n path: string;\n\n /**\n * Rename a param in the route.\n * This is automatically filled when you have scenarios like:\n * `/customers/:id` and `/customers/:userId/payments`\n *\n * In this case, `:id` will be renamed to `:userId` in the second route.\n */\n mapParams?: Record<string, string>;\n}\n\nexport interface Tree<T extends Route> {\n route?: T;\n children: {\n [key: string]: Tree<T>;\n };\n param?: {\n route?: T;\n name: string;\n children: {\n [key: string]: Tree<T>;\n };\n };\n wildcard?: {\n route: T;\n };\n}\n","import { AlephaError } from \"alepha\";\n\n/**\n * Parses and manipulates templated paths with `{param}` placeholders.\n *\n * Used by both RouterProvider (HTTP routes) and TopicProvider (pub/sub topics)\n * to handle parameterized path templates in a unified way.\n *\n * @example\n * ```ts\n * const parser = new TemplatedPathParser(\"/users/{userId}/posts/{postId}\");\n * parser.interpolate({ userId: \"7\", postId: \"42\" }); // \"/users/7/posts/42\"\n * parser.extract(\"/users/7/posts/42\"); // { userId: \"7\", postId: \"42\" }\n * parser.wildcardize(\"+\"); // \"/users/+/posts/+\"\n * ```\n *\n * @example\n * ```ts\n * // Redis-style colon-separated keys\n * const parser = new TemplatedPathParser(\"cache:{namespace}:{key}\", \":\");\n * parser.interpolate({ namespace: \"users\", key: \"42\" }); // \"cache:users:42\"\n * parser.wildcardize(\"*\"); // \"cache:*:*\"\n * ```\n */\nexport class TemplatedPathParser {\n protected static readonly PARAM_REGEX = /\\{([^}]+)\\}/g;\n\n public readonly template: string;\n public readonly separator: string;\n public readonly paramNames: readonly string[];\n public readonly hasParams: boolean;\n protected readonly extractRegex: RegExp | null;\n\n constructor(template: string, separator = \"/\") {\n if (separator.length !== 1) {\n throw new AlephaError(\n `TemplatedPathParser separator must be a single character, got '${separator}'`,\n );\n }\n this.template = template;\n this.separator = separator;\n this.paramNames = [\n ...template.matchAll(TemplatedPathParser.PARAM_REGEX),\n ].map((m) => m[1]);\n this.hasParams = this.paramNames.length > 0;\n this.extractRegex = this.hasParams ? this.buildExtractRegex() : null;\n }\n\n /**\n * Replaces each `{param}` in the template with the corresponding value\n * from the provided params record.\n */\n interpolate(params: Record<string, string>): string {\n return this.template.replace(\n TemplatedPathParser.PARAM_REGEX,\n (_, name: string) => params[name] ?? `{${name}}`,\n );\n }\n\n /**\n * Extracts parameter values from a concrete path by matching it against\n * the template structure.\n *\n * Returns `null` when the path does not match the template.\n * Returns `{}` when the template has no parameters and the path matches.\n */\n extract(path: string): Record<string, string> | null {\n if (!this.extractRegex) {\n return path === this.template ? {} : null;\n }\n\n const match = this.extractRegex.exec(path);\n if (!match) {\n return null;\n }\n\n const result: Record<string, string> = {};\n for (let i = 0; i < this.paramNames.length; i++) {\n result[this.paramNames[i]] = match[i + 1];\n }\n return result;\n }\n\n /**\n * Replaces each `{param}` placeholder in the template with the given\n * wildcard string. Defaults to `\"+\"` (MQTT-style).\n */\n wildcardize(wildcard = \"+\"): string {\n return this.template.replace(TemplatedPathParser.PARAM_REGEX, wildcard);\n }\n\n /**\n * Normalises a path by collapsing repeated separators and stripping a\n * trailing separator (unless the path is just the separator itself).\n */\n normalize(path: string): string {\n const sep = this.separator;\n const escapedSep = this.escapeRegex(sep);\n\n let result = path.replace(new RegExp(`${escapedSep}{2,}`, \"g\"), sep);\n\n if (result.endsWith(sep) && result.length > sep.length) {\n result = result.slice(0, -sep.length);\n }\n\n return result;\n }\n\n protected buildExtractRegex(): RegExp {\n const escapedSeparator = this.escapeRegex(this.separator);\n\n const regexSource = this.template\n .replace(/[.*+?^${}()|[\\]\\\\]/g, (char) => {\n if (char === \"{\" || char === \"}\") {\n return char;\n }\n return `\\\\${char}`;\n })\n .replace(/\\{[^}]+\\}/g, `([^${escapedSeparator}]+)`);\n\n return new RegExp(`^${regexSource}$`);\n }\n\n protected escapeRegex(s: string): string {\n return s.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n }\n}\n"],"mappings":";;AAEA,IAAsB,iBAAtB,MAA8D;CAC5D,iBAAmC;CAEnC,OAA0B,EAAE,UAAU,EAAE,EAAE;CAC1C,wBAAkB,IAAI,KAA4B;CAClD,eAAyB;CAEzB,MAAa,MAA6B;EACxC,MAAM,WAAW,KAAK,MAAM,KAAK,EAAE,CAAC;EACpC,MAAM,MAAM,KAAK,MAAM,IAAI,SAAS;AACpC,MAAI,IACF,QAAO;GAAE,OAAO,IAAI;GAAO,QAAQ,EAAE,GAAG,IAAI,QAAQ;GAAE;EAExD,MAAM,SAAS,KAAK,UAAU,KAAK,iBAAiB,SAAS,CAAC;AAC9D,MAAI,KAAK,MAAM,QAAQ,KAAK,aAAc,MAAK,MAAM,OAAO;AAC5D,OAAK,MAAM,IAAI,UAAU,OAAO;AAChC,SAAO;GAAE,OAAO,OAAO;GAAO,QAAQ,EAAE,GAAG,OAAO,QAAQ;GAAE;;CAG9D,KAAe,MAAoB;AACjC,MAAI,CAAC,KAAK,eAAe,KAAK,KAAK,CACjC,OAAM,IAAI,YAAY,UAAU,KAAK,gBAAgB;;CAIzD,KAAe,OAAgB;EAC7B,MAAM,OAAO,MAAM,KAAK,WAAW,MAAM,IAAI;AAE7C,OAAK,KAAK,KAAK;AACf,OAAK,MAAM,OAAO;EAElB,MAAM,QAAQ,KAAK,YAAY,KAAK;EAEpC,IAAI,SAAS,KAAK;AAClB,OAAK,IAAI,IAAI,GAAG,IAAI,MAAM,QAAQ,KAAK;GAC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D,SAAO,IAAI,OAAO,IAAI,YAAY,GAAG;;CAGvC,YAAsB,GAAmB;AACvC,SAAO,EAAE,QAAQ,uBAAuB,OAAO"}
|
|
@@ -2,6 +2,7 @@ import * as _$alepha from "alepha";
|
|
|
2
2
|
import { Alepha, Async, KIND, Primitive, Static } from "alepha";
|
|
3
3
|
import { DateTime, DateTimeProvider, DurationLike } from "alepha/datetime";
|
|
4
4
|
import * as _$alepha_logger0 from "alepha/logger";
|
|
5
|
+
import { Cron } from "cron-schedule";
|
|
5
6
|
import * as _$dayjs from "dayjs";
|
|
6
7
|
|
|
7
8
|
//#region ../../src/scheduler/constants/CRON.d.ts
|
|
@@ -14,89 +15,6 @@ declare const CRON: {
|
|
|
14
15
|
EVERY_DAY_AT_MIDNIGHT: string;
|
|
15
16
|
};
|
|
16
17
|
//#endregion
|
|
17
|
-
//#region ../../../../node_modules/cron-schedule/dist/cron.d.ts
|
|
18
|
-
/**
|
|
19
|
-
* An object with contains for each element of a date, which values are allowed.
|
|
20
|
-
* Everything starting at 0, except for days.
|
|
21
|
-
*/
|
|
22
|
-
interface ICronDefinition {
|
|
23
|
-
readonly seconds: Set<number>;
|
|
24
|
-
readonly minutes: Set<number>;
|
|
25
|
-
readonly hours: Set<number>;
|
|
26
|
-
readonly days: Set<number>;
|
|
27
|
-
readonly months: Set<number>;
|
|
28
|
-
readonly weekdays: Set<number>;
|
|
29
|
-
}
|
|
30
|
-
declare class Cron {
|
|
31
|
-
readonly seconds: ReadonlyArray<number>;
|
|
32
|
-
readonly minutes: ReadonlyArray<number>;
|
|
33
|
-
readonly hours: ReadonlyArray<number>;
|
|
34
|
-
readonly days: ReadonlyArray<number>;
|
|
35
|
-
readonly months: ReadonlyArray<number>;
|
|
36
|
-
readonly weekdays: ReadonlyArray<number>;
|
|
37
|
-
readonly reversed: {
|
|
38
|
-
seconds: ReadonlyArray<number>;
|
|
39
|
-
minutes: ReadonlyArray<number>;
|
|
40
|
-
hours: ReadonlyArray<number>;
|
|
41
|
-
days: ReadonlyArray<number>;
|
|
42
|
-
months: ReadonlyArray<number>;
|
|
43
|
-
weekdays: ReadonlyArray<number>;
|
|
44
|
-
};
|
|
45
|
-
constructor({
|
|
46
|
-
seconds,
|
|
47
|
-
minutes,
|
|
48
|
-
hours,
|
|
49
|
-
days,
|
|
50
|
-
months,
|
|
51
|
-
weekdays
|
|
52
|
-
}: ICronDefinition);
|
|
53
|
-
/**
|
|
54
|
-
* Find the next or previous hour, starting from the given start hour that matches the hour constraint.
|
|
55
|
-
* startHour itself might also be allowed.
|
|
56
|
-
*/
|
|
57
|
-
private findAllowedHour;
|
|
58
|
-
/**
|
|
59
|
-
* Find the next or previous minute, starting from the given start minute that matches the minute constraint.
|
|
60
|
-
* startMinute itself might also be allowed.
|
|
61
|
-
*/
|
|
62
|
-
private findAllowedMinute;
|
|
63
|
-
/**
|
|
64
|
-
* Find the next or previous second, starting from the given start second that matches the second constraint.
|
|
65
|
-
* startSecond itself IS NOT allowed.
|
|
66
|
-
*/
|
|
67
|
-
private findAllowedSecond;
|
|
68
|
-
/**
|
|
69
|
-
* Find the next or previous time, starting from the given start time that matches the hour, minute
|
|
70
|
-
* and second constraints. startTime itself might also be allowed.
|
|
71
|
-
*/
|
|
72
|
-
private findAllowedTime;
|
|
73
|
-
/**
|
|
74
|
-
* Find the next or previous day in the given month, starting from the given startDay
|
|
75
|
-
* that matches either the day or the weekday constraint. startDay itself might also be allowed.
|
|
76
|
-
*/
|
|
77
|
-
private findAllowedDayInMonth;
|
|
78
|
-
/** Gets the next date starting from the given start date or now. */
|
|
79
|
-
getNextDate(startDate?: Date): Date;
|
|
80
|
-
/** Gets the specified amount of future dates starting from the given start date or now. */
|
|
81
|
-
getNextDates(amount: number, startDate?: Date): Date[];
|
|
82
|
-
/**
|
|
83
|
-
* Get an ES6 compatible iterator which iterates over the next dates starting from startDate or now.
|
|
84
|
-
* The iterator runs until the optional endDate is reached or forever.
|
|
85
|
-
*/
|
|
86
|
-
getNextDatesIterator(startDate?: Date, endDate?: Date): Generator<Date, undefined, undefined>;
|
|
87
|
-
/** Gets the previous date starting from the given start date or now. */
|
|
88
|
-
getPrevDate(startDate?: Date): Date;
|
|
89
|
-
/** Gets the specified amount of previous dates starting from the given start date or now. */
|
|
90
|
-
getPrevDates(amount: number, startDate?: Date): Date[];
|
|
91
|
-
/**
|
|
92
|
-
* Get an ES6 compatible iterator which iterates over the previous dates starting from startDate or now.
|
|
93
|
-
* The iterator runs until the optional endDate is reached or forever.
|
|
94
|
-
*/
|
|
95
|
-
getPrevDatesIterator(startDate?: Date, endDate?: Date): Generator<Date, undefined, undefined>;
|
|
96
|
-
/** Returns true when there is a cron date at the given date. */
|
|
97
|
-
matchDate(date: Date): boolean;
|
|
98
|
-
}
|
|
99
|
-
//#endregion
|
|
100
18
|
//#region ../../src/scheduler/providers/CronProvider.d.ts
|
|
101
19
|
declare class CronProvider {
|
|
102
20
|
protected readonly dt: DateTimeProvider;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/scheduler/constants/CRON.ts","../../src/scheduler/providers/CronProvider.ts","../../src/scheduler/primitives/$scheduler.ts","../../src/scheduler/providers/WorkerdCronProvider.ts","../../src/scheduler/index.ts"],"mappings":";;;;;;;;cAAa,IAAA;;;;;;;;;;cCKA,YAAA;EAAA,mBACQ,EAAA,EAAE,gBAAA;EAAA,mBACF,MAAA,EAAM,MAAA;EAAA,mBACN,GAAA,EADM,gBAAA,CACH,MAAA;EAAA,mBACH,QAAA,EAAU,KAAA,CAAM,OAAA;EAE5B,WAAA,CAAA,GAAe,KAAA,CAAM,OAAA;EAAA,mBAIT,KAAA,EAJQ,QAAA,CAIH,aAAA;EAAA,mBAoBL,IAAA,EApBK,QAAA,CAoBD,aAAA;EAAA,UASb,IAAA,CAAK,IAAA,WAAe,OAAA;EAmBvB,KAAA,CAAM,IAAA,WAAe,OAAA;;;;;;EAoB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