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
|
@@ -1014,6 +1014,7 @@ export const testTransactionThrowsWhenUnsupported = async (alepha: Alepha) => {
|
|
|
1014
1014
|
original,
|
|
1015
1015
|
);
|
|
1016
1016
|
} else {
|
|
1017
|
+
// biome-ignore lint/performance/noDelete: setting to undefined fails because the prototype has a getter
|
|
1017
1018
|
delete provider.supportsTransactions;
|
|
1018
1019
|
}
|
|
1019
1020
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { type Alepha,
|
|
1
|
+
import { type Alepha, t } from "alepha";
|
|
2
2
|
import { sql } from "drizzle-orm";
|
|
3
3
|
import { expect } from "vitest";
|
|
4
4
|
import { PG_GENERATED } from "../core/constants/PG_SYMBOLS.ts";
|
|
5
|
-
import { $entity, $repository,
|
|
5
|
+
import { $entity, $repository, db, pgAttr } from "../core/index.ts";
|
|
6
6
|
|
|
7
7
|
// ============================================================================
|
|
8
8
|
// Shared entity definitions
|
|
@@ -425,68 +425,3 @@ export const testQueryCacheCustomKey = async (alepha: Alepha) => {
|
|
|
425
425
|
);
|
|
426
426
|
expect(cached).toHaveLength(1);
|
|
427
427
|
};
|
|
428
|
-
|
|
429
|
-
// ============================================================================
|
|
430
|
-
// Feature 8: Database Views
|
|
431
|
-
// ============================================================================
|
|
432
|
-
|
|
433
|
-
export const testViewReadOnly = async (alepha: Alepha) => {
|
|
434
|
-
// Create the underlying table
|
|
435
|
-
const itemEntity = $entity({
|
|
436
|
-
name: "view_items",
|
|
437
|
-
schema: t.object({
|
|
438
|
-
id: db.primaryKey(),
|
|
439
|
-
name: t.text(),
|
|
440
|
-
price: t.number(),
|
|
441
|
-
}),
|
|
442
|
-
});
|
|
443
|
-
|
|
444
|
-
// Create a view
|
|
445
|
-
const itemView = $view({
|
|
446
|
-
name: "view_items_summary",
|
|
447
|
-
schema: t.object({
|
|
448
|
-
id: t.integer(),
|
|
449
|
-
name: t.text(),
|
|
450
|
-
price: t.number(),
|
|
451
|
-
}),
|
|
452
|
-
query: sql`SELECT id, name, price FROM view_items`,
|
|
453
|
-
});
|
|
454
|
-
|
|
455
|
-
class App {
|
|
456
|
-
items = $repository(itemEntity);
|
|
457
|
-
summary = $repository(itemView);
|
|
458
|
-
}
|
|
459
|
-
|
|
460
|
-
const app = alepha.inject(App);
|
|
461
|
-
await alepha.start();
|
|
462
|
-
|
|
463
|
-
// Verify the repository detects it's a view
|
|
464
|
-
expect(app.summary.isReadOnly).toBe(true);
|
|
465
|
-
expect(app.items.isReadOnly).toBe(false);
|
|
466
|
-
|
|
467
|
-
// Write operations should throw on views
|
|
468
|
-
await expect(
|
|
469
|
-
app.summary.create({ id: 1, name: "test", price: 10 } as any),
|
|
470
|
-
).rejects.toThrow(AlephaError);
|
|
471
|
-
};
|
|
472
|
-
|
|
473
|
-
export const testViewRefreshThrowsForNonMaterialized = async (
|
|
474
|
-
alepha: Alepha,
|
|
475
|
-
) => {
|
|
476
|
-
const view = $view({
|
|
477
|
-
name: "non_mat_view",
|
|
478
|
-
schema: t.object({
|
|
479
|
-
id: t.integer(),
|
|
480
|
-
}),
|
|
481
|
-
query: sql`SELECT 1 as id`,
|
|
482
|
-
});
|
|
483
|
-
|
|
484
|
-
class App {
|
|
485
|
-
repo = $repository(view);
|
|
486
|
-
}
|
|
487
|
-
|
|
488
|
-
const app = alepha.inject(App);
|
|
489
|
-
await alepha.start();
|
|
490
|
-
|
|
491
|
-
await expect(app.repo.refresh()).rejects.toThrow(AlephaError);
|
|
492
|
-
};
|
|
@@ -14,8 +14,6 @@ import {
|
|
|
14
14
|
testPartialIndex,
|
|
15
15
|
testQueryCache,
|
|
16
16
|
testQueryCacheCustomKey,
|
|
17
|
-
testViewReadOnly,
|
|
18
|
-
testViewRefreshThrowsForNonMaterialized,
|
|
19
17
|
} from "./orm-next-tests.ts";
|
|
20
18
|
|
|
21
19
|
const sqlite = () =>
|
|
@@ -119,22 +117,3 @@ describe("query caching", () => {
|
|
|
119
117
|
await testQueryCacheCustomKey(postgres());
|
|
120
118
|
});
|
|
121
119
|
});
|
|
122
|
-
|
|
123
|
-
// =============================================================================
|
|
124
|
-
// Feature 8: Database Views
|
|
125
|
-
// =============================================================================
|
|
126
|
-
|
|
127
|
-
describe("database views", () => {
|
|
128
|
-
it("should block writes on view repositories (sqlite)", async () => {
|
|
129
|
-
await testViewReadOnly(sqlite());
|
|
130
|
-
});
|
|
131
|
-
it("should block writes on view repositories (postgres)", async () => {
|
|
132
|
-
await testViewReadOnly(postgres());
|
|
133
|
-
});
|
|
134
|
-
it("should throw on refresh for non-materialized view (sqlite)", async () => {
|
|
135
|
-
await testViewRefreshThrowsForNonMaterialized(sqlite());
|
|
136
|
-
});
|
|
137
|
-
it("should throw on refresh for non-materialized view (postgres)", async () => {
|
|
138
|
-
await testViewRefreshThrowsForNonMaterialized(postgres());
|
|
139
|
-
});
|
|
140
|
-
});
|
|
@@ -12,13 +12,11 @@ export * from "./errors/DbEntityNotFoundError.ts";
|
|
|
12
12
|
export * from "./errors/DbForeignKeyError.ts";
|
|
13
13
|
export * from "./errors/DbNotNullError.ts";
|
|
14
14
|
export * from "./errors/DbTableNotFoundError.ts";
|
|
15
|
-
export * from "./helpers/parseQueryString.ts";
|
|
16
15
|
export * from "./helpers/pgAttr.ts";
|
|
17
16
|
export * from "./interfaces/AggregateQuery.ts";
|
|
18
17
|
export * from "./interfaces/FilterOperators.ts";
|
|
19
18
|
export * from "./interfaces/PgQuery.ts";
|
|
20
19
|
export * from "./interfaces/PgQueryWhere.ts";
|
|
21
20
|
export * from "./primitives/$entity.ts";
|
|
22
|
-
export * from "./primitives/$view.ts";
|
|
23
21
|
export * from "./providers/DatabaseTypeProvider.ts";
|
|
24
22
|
export * from "./schemas/legacyIdSchema.ts";
|
package/src/orm/core/index.ts
CHANGED
|
@@ -4,7 +4,6 @@ import type { PgTransaction } from "drizzle-orm/pg-core";
|
|
|
4
4
|
import { DbMigrationMode } from "./modes/DbMigrationMode.ts";
|
|
5
5
|
import { $entity } from "./primitives/$entity.ts";
|
|
6
6
|
import { $sequence } from "./primitives/$sequence.ts";
|
|
7
|
-
import { $view } from "./primitives/$view.ts";
|
|
8
7
|
import { DrizzleKitProvider } from "./providers/DrizzleKitProvider.ts";
|
|
9
8
|
import { BunSqliteProvider } from "./providers/drivers/BunSqliteProvider.ts";
|
|
10
9
|
import { CloudflareD1Provider } from "./providers/drivers/CloudflareD1Provider.ts";
|
|
@@ -102,7 +101,7 @@ export const SqliteProvider = NodeSqliteProvider;
|
|
|
102
101
|
|
|
103
102
|
export const AlephaOrm = $module({
|
|
104
103
|
name: "alepha.orm",
|
|
105
|
-
primitives: [$sequence, $entity
|
|
104
|
+
primitives: [$sequence, $entity],
|
|
106
105
|
imports: [AlephaDateTime],
|
|
107
106
|
services: [
|
|
108
107
|
SqliteModelBuilder,
|
|
@@ -2,17 +2,14 @@ import { $context, $inject, type TObject } from "alepha";
|
|
|
2
2
|
import { RepositoryProvider } from "../providers/RepositoryProvider.ts";
|
|
3
3
|
import type { Repository } from "../services/Repository.ts";
|
|
4
4
|
import type { EntityPrimitive } from "./$entity.ts";
|
|
5
|
-
import type { ViewPrimitive } from "./$view.ts";
|
|
6
5
|
|
|
7
6
|
/**
|
|
8
|
-
* Get the repository for the given entity
|
|
7
|
+
* Get the repository for the given entity.
|
|
9
8
|
*/
|
|
10
9
|
export const $repository = <T extends TObject>(
|
|
11
|
-
entity: EntityPrimitive<T
|
|
10
|
+
entity: EntityPrimitive<T>,
|
|
12
11
|
): Repository<T> => {
|
|
13
12
|
const { alepha } = $context();
|
|
14
13
|
const repositoryProvider = alepha.inject(RepositoryProvider);
|
|
15
|
-
return $inject(
|
|
16
|
-
repositoryProvider.createClassRepository(entity as EntityPrimitive<T>),
|
|
17
|
-
);
|
|
14
|
+
return $inject(repositoryProvider.createClassRepository(entity));
|
|
18
15
|
};
|
|
@@ -22,7 +22,6 @@ import type {
|
|
|
22
22
|
SchemaToTableConfig,
|
|
23
23
|
} from "../../primitives/$entity.ts";
|
|
24
24
|
import type { SequencePrimitive } from "../../primitives/$sequence.ts";
|
|
25
|
-
import type { ViewPrimitive } from "../../primitives/$view.ts";
|
|
26
25
|
import { databaseEnvSchema } from "../../schemas/databaseEnvSchema.ts";
|
|
27
26
|
import type { ModelBuilder } from "../../services/ModelBuilder.ts";
|
|
28
27
|
import { DrizzleKitProvider } from "../DrizzleKitProvider.ts";
|
|
@@ -156,10 +155,6 @@ export abstract class DatabaseProvider {
|
|
|
156
155
|
this.builder.buildTable(entity, this);
|
|
157
156
|
}
|
|
158
157
|
|
|
159
|
-
public registerView(view: ViewPrimitive) {
|
|
160
|
-
this.builder.buildView(view, this);
|
|
161
|
-
}
|
|
162
|
-
|
|
163
158
|
public registerSequence(sequence: SequencePrimitive) {
|
|
164
159
|
this.sequencePrimitives.push(sequence);
|
|
165
160
|
this.builder.buildSequence(sequence, this);
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { mkdir } from "node:fs/promises";
|
|
2
|
-
import { createRequire } from "node:module";
|
|
3
2
|
import { dirname } from "node:path";
|
|
4
3
|
import type { DatabaseSync } from "node:sqlite";
|
|
5
4
|
import {
|
|
@@ -12,7 +11,11 @@ import {
|
|
|
12
11
|
type Static,
|
|
13
12
|
t,
|
|
14
13
|
} from "alepha";
|
|
14
|
+
import { migrate } from "drizzle-orm/better-sqlite3/migrator";
|
|
15
|
+
import { BetterSQLiteSession } from "drizzle-orm/better-sqlite3/session";
|
|
15
16
|
import type { PgDatabase } from "drizzle-orm/pg-core";
|
|
17
|
+
import { BaseSQLiteDatabase } from "drizzle-orm/sqlite-core/db";
|
|
18
|
+
import { SQLiteSyncDialect } from "drizzle-orm/sqlite-core/dialect";
|
|
16
19
|
import { databaseEnvSchema } from "../../schemas/databaseEnvSchema.ts";
|
|
17
20
|
import { SqliteModelBuilder } from "../../services/SqliteModelBuilder.ts";
|
|
18
21
|
import { DatabaseProvider, type SQLLike } from "./DatabaseProvider.ts";
|
|
@@ -162,7 +165,7 @@ export class NodeSqliteProvider extends DatabaseProvider {
|
|
|
162
165
|
protected readonly onStart = $hook({
|
|
163
166
|
on: "start",
|
|
164
167
|
handler: async () => {
|
|
165
|
-
const { DatabaseSync } =
|
|
168
|
+
const { DatabaseSync } = await import("node:sqlite");
|
|
166
169
|
|
|
167
170
|
const filepath = this.url.replace("sqlite://", "").replace("sqlite:", "");
|
|
168
171
|
|
|
@@ -323,13 +326,6 @@ export class NodeSqliteProvider extends DatabaseProvider {
|
|
|
323
326
|
protected initDrizzle(): void {
|
|
324
327
|
this.shimDatabaseSync();
|
|
325
328
|
|
|
326
|
-
const require = createRequire(import.meta.url);
|
|
327
|
-
const {
|
|
328
|
-
BetterSQLiteSession,
|
|
329
|
-
} = require("drizzle-orm/better-sqlite3/session");
|
|
330
|
-
const { SQLiteSyncDialect } = require("drizzle-orm/sqlite-core/dialect");
|
|
331
|
-
const { BaseSQLiteDatabase } = require("drizzle-orm/sqlite-core/db");
|
|
332
|
-
|
|
333
329
|
const dialect = new SQLiteSyncDialect();
|
|
334
330
|
const session = new BetterSQLiteSession(this.sqlite, dialect, undefined, {
|
|
335
331
|
logger: {
|
|
@@ -339,14 +335,16 @@ export class NodeSqliteProvider extends DatabaseProvider {
|
|
|
339
335
|
},
|
|
340
336
|
});
|
|
341
337
|
|
|
342
|
-
this.drizzleDb = new BaseSQLiteDatabase(
|
|
338
|
+
this.drizzleDb = new BaseSQLiteDatabase(
|
|
339
|
+
"sync",
|
|
340
|
+
dialect,
|
|
341
|
+
session,
|
|
342
|
+
undefined,
|
|
343
|
+
);
|
|
343
344
|
this.log.debug("Using node:sqlite with sync driver");
|
|
344
345
|
}
|
|
345
346
|
|
|
346
347
|
protected async executeMigrations(migrationsFolder: string): Promise<void> {
|
|
347
|
-
const { migrate } = createRequire(import.meta.url)(
|
|
348
|
-
"drizzle-orm/better-sqlite3/migrator",
|
|
349
|
-
);
|
|
350
348
|
migrate(this.drizzleDb, { migrationsFolder });
|
|
351
349
|
}
|
|
352
350
|
}
|
|
@@ -2,7 +2,6 @@ import { AlephaError } from "alepha";
|
|
|
2
2
|
import type { SQL } from "drizzle-orm";
|
|
3
3
|
import type { EntityPrimitive } from "../primitives/$entity.ts";
|
|
4
4
|
import type { SequencePrimitive } from "../primitives/$sequence.ts";
|
|
5
|
-
import type { ViewPrimitive } from "../primitives/$view.ts";
|
|
6
5
|
|
|
7
6
|
/**
|
|
8
7
|
* Database-specific table configuration functions
|
|
@@ -43,17 +42,6 @@ export abstract class ModelBuilder {
|
|
|
43
42
|
},
|
|
44
43
|
): void;
|
|
45
44
|
|
|
46
|
-
/**
|
|
47
|
-
* Build a view from a view primitive.
|
|
48
|
-
*/
|
|
49
|
-
abstract buildView(
|
|
50
|
-
view: ViewPrimitive,
|
|
51
|
-
options: {
|
|
52
|
-
tables: Map<string, unknown>;
|
|
53
|
-
schema: string;
|
|
54
|
-
},
|
|
55
|
-
): void;
|
|
56
|
-
|
|
57
45
|
/**
|
|
58
46
|
* Build a sequence from a sequence primitive.
|
|
59
47
|
*/
|
|
@@ -192,7 +180,7 @@ export abstract class ModelBuilder {
|
|
|
192
180
|
// Resolve foreign column references
|
|
193
181
|
const foreignColumns = fkDef.foreignColumns.map((colRef) => {
|
|
194
182
|
const entityCol = colRef();
|
|
195
|
-
if (!entityCol
|
|
183
|
+
if (!entityCol?.entity || !entityCol.name) {
|
|
196
184
|
throw new AlephaError(
|
|
197
185
|
`Invalid foreign column reference in ${entity.name}`,
|
|
198
186
|
);
|
|
@@ -114,11 +114,7 @@ export abstract class Repository<T extends TObject> {
|
|
|
114
114
|
constructor(entity: EntityPrimitive<T>, provider = DatabaseProvider) {
|
|
115
115
|
this.entity = entity;
|
|
116
116
|
this.provider = this.alepha.inject(provider);
|
|
117
|
-
|
|
118
|
-
this.provider.registerView(entity as any);
|
|
119
|
-
} else {
|
|
120
|
-
this.provider.registerEntity(entity as EntityPrimitive);
|
|
121
|
-
}
|
|
117
|
+
this.provider.registerEntity(entity as EntityPrimitive);
|
|
122
118
|
}
|
|
123
119
|
|
|
124
120
|
/**
|
|
@@ -150,13 +146,6 @@ export abstract class Repository<T extends TObject> {
|
|
|
150
146
|
return this.entity.name;
|
|
151
147
|
}
|
|
152
148
|
|
|
153
|
-
/**
|
|
154
|
-
* Whether this repository is backed by a view (read-only).
|
|
155
|
-
*/
|
|
156
|
-
public get isReadOnly(): boolean {
|
|
157
|
-
return (this.entity as any).isView === true;
|
|
158
|
-
}
|
|
159
|
-
|
|
160
149
|
/**
|
|
161
150
|
* Getter for the database connection from the database provider.
|
|
162
151
|
*
|
|
@@ -663,7 +652,6 @@ export abstract class Repository<T extends TObject> {
|
|
|
663
652
|
data: Static<TObjectInsert<T>>,
|
|
664
653
|
opts: StatementOptions = {},
|
|
665
654
|
): Promise<Static<T>> {
|
|
666
|
-
this.assertWritable();
|
|
667
655
|
this.stampOrganization(data);
|
|
668
656
|
await this.alepha.events.emit("repository:create:before", {
|
|
669
657
|
tableName: this.tableName,
|
|
@@ -705,7 +693,6 @@ export abstract class Repository<T extends TObject> {
|
|
|
705
693
|
values: Array<Static<TObjectInsert<T>>>,
|
|
706
694
|
opts: StatementOptions & { batchSize?: number } = {},
|
|
707
695
|
): Promise<Static<T>[]> {
|
|
708
|
-
this.assertWritable();
|
|
709
696
|
if (values.length === 0) {
|
|
710
697
|
return [];
|
|
711
698
|
}
|
|
@@ -784,7 +771,6 @@ export abstract class Repository<T extends TObject> {
|
|
|
784
771
|
set?: WithSQL<Static<TObjectUpdate<T>>>;
|
|
785
772
|
} = {},
|
|
786
773
|
): Promise<Static<T>> {
|
|
787
|
-
this.assertWritable();
|
|
788
774
|
this.stampOrganization(data);
|
|
789
775
|
await this.alepha.events.emit("repository:create:before", {
|
|
790
776
|
tableName: this.tableName,
|
|
@@ -857,7 +843,6 @@ export abstract class Repository<T extends TObject> {
|
|
|
857
843
|
data: WithSQL<Static<TObjectUpdate<T>>>,
|
|
858
844
|
opts: StatementOptions = {},
|
|
859
845
|
): Promise<Static<T>> {
|
|
860
|
-
this.assertWritable();
|
|
861
846
|
await this.alepha.events.emit("repository:update:before", {
|
|
862
847
|
tableName: this.tableName,
|
|
863
848
|
where,
|
|
@@ -938,7 +923,6 @@ export abstract class Repository<T extends TObject> {
|
|
|
938
923
|
entity: Static<T>,
|
|
939
924
|
opts: StatementOptions = {},
|
|
940
925
|
): Promise<void> {
|
|
941
|
-
this.assertWritable();
|
|
942
926
|
const row = entity as any;
|
|
943
927
|
|
|
944
928
|
const id = row[this.id.key];
|
|
@@ -1024,7 +1008,6 @@ export abstract class Repository<T extends TObject> {
|
|
|
1024
1008
|
data: WithSQL<Static<TObjectUpdate<T>>>,
|
|
1025
1009
|
opts: StatementOptions = {},
|
|
1026
1010
|
): Promise<Array<number | string>> {
|
|
1027
|
-
this.assertWritable();
|
|
1028
1011
|
await this.alepha.events.emit("repository:update:before", {
|
|
1029
1012
|
tableName: this.tableName,
|
|
1030
1013
|
where,
|
|
@@ -1076,7 +1059,6 @@ export abstract class Repository<T extends TObject> {
|
|
|
1076
1059
|
where: PgQueryWhereOrSQL<T> = {},
|
|
1077
1060
|
opts: StatementOptions = {},
|
|
1078
1061
|
): Promise<Array<number | string>> {
|
|
1079
|
-
this.assertWritable();
|
|
1080
1062
|
const deletedAt = this.deletedAt();
|
|
1081
1063
|
if (deletedAt && !opts.force) {
|
|
1082
1064
|
return await this.updateMany(
|
|
@@ -1639,29 +1621,6 @@ export abstract class Repository<T extends TObject> {
|
|
|
1639
1621
|
return entity as Static<T>;
|
|
1640
1622
|
}
|
|
1641
1623
|
|
|
1642
|
-
/**
|
|
1643
|
-
* Throw if this repository is read-only (backed by a view).
|
|
1644
|
-
*/
|
|
1645
|
-
protected assertWritable(): void {
|
|
1646
|
-
if (this.isReadOnly) {
|
|
1647
|
-
throw new AlephaError(
|
|
1648
|
-
`Cannot write to view '${this.tableName}'. Views are read-only.`,
|
|
1649
|
-
);
|
|
1650
|
-
}
|
|
1651
|
-
}
|
|
1652
|
-
|
|
1653
|
-
/**
|
|
1654
|
-
* Refresh a materialized view. PostgreSQL only.
|
|
1655
|
-
*/
|
|
1656
|
-
public async refresh(): Promise<void> {
|
|
1657
|
-
if (!(this.entity as any).materialized) {
|
|
1658
|
-
throw new AlephaError(
|
|
1659
|
-
`Cannot refresh '${this.tableName}'. Only materialized views support refresh.`,
|
|
1660
|
-
);
|
|
1661
|
-
}
|
|
1662
|
-
await this.provider.execute(`REFRESH MATERIALIZED VIEW ${this.tableName}`);
|
|
1663
|
-
}
|
|
1664
|
-
|
|
1665
1624
|
/**
|
|
1666
1625
|
* Build a cache key from method name and query parameters.
|
|
1667
1626
|
*/
|
|
@@ -16,7 +16,6 @@ import {
|
|
|
16
16
|
type SQLiteColumnBuilderBase,
|
|
17
17
|
type SQLiteTableWithColumns,
|
|
18
18
|
sqliteTable,
|
|
19
|
-
sqliteView,
|
|
20
19
|
unique,
|
|
21
20
|
uniqueIndex,
|
|
22
21
|
} from "drizzle-orm/sqlite-core";
|
|
@@ -33,7 +32,6 @@ import {
|
|
|
33
32
|
} from "../constants/PG_SYMBOLS.ts";
|
|
34
33
|
import type { EntityPrimitive } from "../primitives/$entity.ts";
|
|
35
34
|
import type { SequencePrimitive } from "../primitives/$sequence.ts";
|
|
36
|
-
import type { ViewPrimitive } from "../primitives/$view.ts";
|
|
37
35
|
import { ModelBuilder } from "./ModelBuilder.ts";
|
|
38
36
|
|
|
39
37
|
export class SqliteModelBuilder extends ModelBuilder {
|
|
@@ -66,33 +64,6 @@ export class SqliteModelBuilder extends ModelBuilder {
|
|
|
66
64
|
options.tables.set(tableName, table);
|
|
67
65
|
}
|
|
68
66
|
|
|
69
|
-
public buildView(
|
|
70
|
-
view: ViewPrimitive,
|
|
71
|
-
options: {
|
|
72
|
-
tables: Map<string, unknown>;
|
|
73
|
-
schema: string;
|
|
74
|
-
},
|
|
75
|
-
) {
|
|
76
|
-
const viewName = view.name;
|
|
77
|
-
if (options.tables.has(viewName)) {
|
|
78
|
-
return;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
if (view.materialized) {
|
|
82
|
-
throw new AlephaError("SQLite does not support materialized views");
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
const columns = this.schemaToSqliteColumns(
|
|
86
|
-
viewName,
|
|
87
|
-
view.schema,
|
|
88
|
-
new Map(),
|
|
89
|
-
options.tables,
|
|
90
|
-
);
|
|
91
|
-
|
|
92
|
-
const drizzleView = sqliteView(viewName, columns).existing();
|
|
93
|
-
options.tables.set(viewName, drizzleView);
|
|
94
|
-
}
|
|
95
|
-
|
|
96
67
|
public buildSequence(
|
|
97
68
|
sequence: SequencePrimitive,
|
|
98
69
|
options: {
|
|
@@ -193,10 +164,8 @@ export class SqliteModelBuilder extends ModelBuilder {
|
|
|
193
164
|
col = col.notNull();
|
|
194
165
|
}
|
|
195
166
|
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
[key]: col,
|
|
199
|
-
};
|
|
167
|
+
(columns as Record<string, unknown>)[key] = col;
|
|
168
|
+
return columns;
|
|
200
169
|
}, {}) as SchemaToSqliteBuilder<T>;
|
|
201
170
|
};
|
|
202
171
|
|
|
@@ -16,7 +16,6 @@ import {
|
|
|
16
16
|
type SequencePrimitive,
|
|
17
17
|
schema,
|
|
18
18
|
sql,
|
|
19
|
-
type ViewPrimitive,
|
|
20
19
|
} from "alepha/orm";
|
|
21
20
|
import type { BuildExtraConfigColumns } from "drizzle-orm";
|
|
22
21
|
import * as pg from "drizzle-orm/pg-core";
|
|
@@ -29,11 +28,9 @@ import {
|
|
|
29
28
|
type PgTableExtraConfigValue,
|
|
30
29
|
type PgTableWithColumns,
|
|
31
30
|
pgEnum,
|
|
32
|
-
pgMaterializedView,
|
|
33
31
|
pgSchema,
|
|
34
32
|
pgSequence,
|
|
35
33
|
pgTable,
|
|
36
|
-
pgView,
|
|
37
34
|
unique,
|
|
38
35
|
uniqueIndex,
|
|
39
36
|
} from "drizzle-orm/pg-core";
|
|
@@ -108,36 +105,6 @@ export class PostgresModelBuilder extends ModelBuilder {
|
|
|
108
105
|
options.tables.set(tableName, table);
|
|
109
106
|
}
|
|
110
107
|
|
|
111
|
-
public buildView(
|
|
112
|
-
view: ViewPrimitive,
|
|
113
|
-
options: {
|
|
114
|
-
tables: Map<string, unknown>;
|
|
115
|
-
schema: string;
|
|
116
|
-
},
|
|
117
|
-
) {
|
|
118
|
-
const viewName = view.name;
|
|
119
|
-
if (options.tables.has(viewName)) {
|
|
120
|
-
return;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
const columns = this.schemaToPgColumns(
|
|
124
|
-
viewName,
|
|
125
|
-
view.schema,
|
|
126
|
-
{ enum: pgEnum, table: pgTable, sequence: pgSequence } as any,
|
|
127
|
-
new Map(),
|
|
128
|
-
options.tables,
|
|
129
|
-
);
|
|
130
|
-
|
|
131
|
-
let drizzleView: unknown;
|
|
132
|
-
if (view.materialized) {
|
|
133
|
-
drizzleView = pgMaterializedView(viewName, columns).existing();
|
|
134
|
-
} else {
|
|
135
|
-
drizzleView = pgView(viewName, columns).existing();
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
options.tables.set(viewName, drizzleView);
|
|
139
|
-
}
|
|
140
|
-
|
|
141
108
|
public buildSequence(
|
|
142
109
|
sequence: SequencePrimitive,
|
|
143
110
|
options: {
|
|
@@ -244,10 +211,8 @@ export class PostgresModelBuilder extends ModelBuilder {
|
|
|
244
211
|
col = col.notNull();
|
|
245
212
|
}
|
|
246
213
|
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
[key]: col,
|
|
250
|
-
};
|
|
214
|
+
(columns as Record<string, unknown>)[key] = col;
|
|
215
|
+
return columns;
|
|
251
216
|
},
|
|
252
217
|
{},
|
|
253
218
|
) as FromSchema<T>;
|
|
@@ -325,7 +290,14 @@ export class PostgresModelBuilder extends ModelBuilder {
|
|
|
325
290
|
return pg.numeric(key);
|
|
326
291
|
}
|
|
327
292
|
|
|
328
|
-
|
|
293
|
+
const isTypeEnum = (value: any): value is { enum: any[] } =>
|
|
294
|
+
t.schema.isUnsafe(value) &&
|
|
295
|
+
"type" in value &&
|
|
296
|
+
value.type === "string" &&
|
|
297
|
+
"enum" in value &&
|
|
298
|
+
Array.isArray(value.enum);
|
|
299
|
+
|
|
300
|
+
if (t.schema.isString(value) && !isTypeEnum(value)) {
|
|
329
301
|
return this.mapStringToColumn(key, value);
|
|
330
302
|
}
|
|
331
303
|
|
|
@@ -341,13 +313,6 @@ export class PostgresModelBuilder extends ModelBuilder {
|
|
|
341
313
|
return schema(key, value);
|
|
342
314
|
}
|
|
343
315
|
|
|
344
|
-
const isTypeEnum = (value: any): value is { enum: any[] } =>
|
|
345
|
-
t.schema.isUnsafe(value) &&
|
|
346
|
-
"type" in value &&
|
|
347
|
-
value.type === "string" &&
|
|
348
|
-
"enum" in value &&
|
|
349
|
-
Array.isArray(value.enum);
|
|
350
|
-
|
|
351
316
|
if (t.schema.isArray(value)) {
|
|
352
317
|
if (t.schema.isObject(value.items)) {
|
|
353
318
|
return schema(key, value);
|
package/src/react/form/index.ts
CHANGED
|
@@ -9,6 +9,8 @@ export * from "./hooks/useForm.ts";
|
|
|
9
9
|
export * from "./hooks/useFormState.ts";
|
|
10
10
|
export * from "./hooks/useFormValues.ts";
|
|
11
11
|
export * from "./services/FormModel.ts";
|
|
12
|
+
export * from "./services/parseField.ts";
|
|
13
|
+
export * from "./services/prettyName.ts";
|
|
12
14
|
|
|
13
15
|
// ---------------------------------------------------------------------------------------------------------------------
|
|
14
16
|
|