alepha 0.15.0 → 0.15.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +43 -98
- package/dist/api/audits/index.d.ts +630 -653
- package/dist/api/audits/index.d.ts.map +1 -1
- package/dist/api/audits/index.js +12 -35
- package/dist/api/audits/index.js.map +1 -1
- package/dist/api/files/index.d.ts +365 -358
- package/dist/api/files/index.d.ts.map +1 -1
- package/dist/api/files/index.js +12 -5
- package/dist/api/files/index.js.map +1 -1
- package/dist/api/jobs/index.d.ts +255 -248
- package/dist/api/jobs/index.d.ts.map +1 -1
- package/dist/api/jobs/index.js +10 -3
- package/dist/api/jobs/index.js.map +1 -1
- package/dist/api/keys/index.d.ts +413 -0
- package/dist/api/keys/index.d.ts.map +1 -0
- package/dist/api/keys/index.js +476 -0
- package/dist/api/keys/index.js.map +1 -0
- package/dist/api/notifications/index.browser.js +4 -4
- package/dist/api/notifications/index.browser.js.map +1 -1
- package/dist/api/notifications/index.d.ts +84 -78
- package/dist/api/notifications/index.d.ts.map +1 -1
- package/dist/api/notifications/index.js +14 -8
- package/dist/api/notifications/index.js.map +1 -1
- package/dist/api/parameters/index.d.ts +528 -535
- package/dist/api/parameters/index.d.ts.map +1 -1
- package/dist/api/parameters/index.js +30 -37
- package/dist/api/parameters/index.js.map +1 -1
- package/dist/api/users/index.d.ts +1221 -910
- package/dist/api/users/index.d.ts.map +1 -1
- package/dist/api/users/index.js +2556 -248
- package/dist/api/users/index.js.map +1 -1
- package/dist/api/verifications/index.d.ts +142 -136
- package/dist/api/verifications/index.d.ts.map +1 -1
- package/dist/api/verifications/index.js +12 -4
- package/dist/api/verifications/index.js.map +1 -1
- package/dist/batch/index.d.ts +142 -162
- package/dist/batch/index.d.ts.map +1 -1
- package/dist/batch/index.js +31 -44
- package/dist/batch/index.js.map +1 -1
- package/dist/bucket/index.d.ts +595 -171
- package/dist/bucket/index.d.ts.map +1 -1
- package/dist/bucket/index.js +1856 -12
- package/dist/bucket/index.js.map +1 -1
- package/dist/cache/core/index.d.ts +225 -53
- package/dist/cache/core/index.d.ts.map +1 -1
- package/dist/cache/core/index.js +213 -7
- package/dist/cache/core/index.js.map +1 -1
- package/dist/cache/redis/index.d.ts +1 -0
- package/dist/cache/redis/index.d.ts.map +1 -1
- package/dist/cache/redis/index.js +6 -2
- package/dist/cache/redis/index.js.map +1 -1
- package/dist/cli/index.d.ts +834 -226
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +2872 -417
- package/dist/cli/index.js.map +1 -1
- package/dist/command/index.d.ts +458 -310
- package/dist/command/index.d.ts.map +1 -1
- package/dist/command/index.js +2011 -76
- package/dist/command/index.js.map +1 -1
- package/dist/core/index.browser.js +309 -97
- package/dist/core/index.browser.js.map +1 -1
- package/dist/core/index.d.ts +796 -701
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +329 -97
- package/dist/core/index.js.map +1 -1
- package/dist/core/index.native.js +309 -97
- package/dist/core/index.native.js.map +1 -1
- package/dist/datetime/index.d.ts +59 -44
- package/dist/datetime/index.d.ts.map +1 -1
- package/dist/datetime/index.js +15 -0
- package/dist/datetime/index.js.map +1 -1
- package/dist/email/index.d.ts +314 -19
- package/dist/email/index.d.ts.map +1 -1
- package/dist/email/index.js +1852 -7
- package/dist/email/index.js.map +1 -1
- package/dist/fake/index.d.ts +5500 -5418
- package/dist/fake/index.d.ts.map +1 -1
- package/dist/fake/index.js +113 -42
- package/dist/fake/index.js.map +1 -1
- package/dist/lock/core/index.d.ts +219 -212
- package/dist/lock/core/index.d.ts.map +1 -1
- package/dist/lock/core/index.js +11 -4
- package/dist/lock/core/index.js.map +1 -1
- package/dist/lock/redis/index.d.ts.map +1 -1
- package/dist/logger/index.d.ts +41 -90
- package/dist/logger/index.d.ts.map +1 -1
- package/dist/logger/index.js +15 -68
- package/dist/logger/index.js.map +1 -1
- package/dist/mcp/index.d.ts +228 -230
- package/dist/mcp/index.d.ts.map +1 -1
- package/dist/mcp/index.js +32 -31
- package/dist/mcp/index.js.map +1 -1
- package/dist/orm/index.browser.js +12 -12
- package/dist/orm/index.browser.js.map +1 -1
- package/dist/orm/index.bun.js +90 -80
- package/dist/orm/index.bun.js.map +1 -1
- package/dist/orm/index.d.ts +1434 -1459
- package/dist/orm/index.d.ts.map +1 -1
- package/dist/orm/index.js +112 -130
- package/dist/orm/index.js.map +1 -1
- package/dist/queue/core/index.d.ts +262 -254
- package/dist/queue/core/index.d.ts.map +1 -1
- package/dist/queue/core/index.js +14 -6
- package/dist/queue/core/index.js.map +1 -1
- package/dist/queue/redis/index.d.ts.map +1 -1
- package/dist/react/auth/index.browser.js +108 -0
- package/dist/react/auth/index.browser.js.map +1 -0
- package/dist/react/auth/index.d.ts +100 -0
- package/dist/react/auth/index.d.ts.map +1 -0
- package/dist/react/auth/index.js +145 -0
- package/dist/react/auth/index.js.map +1 -0
- package/dist/react/core/index.d.ts +469 -0
- package/dist/react/core/index.d.ts.map +1 -0
- package/dist/react/core/index.js +464 -0
- package/dist/react/core/index.js.map +1 -0
- package/dist/react/form/index.d.ts +232 -0
- package/dist/react/form/index.d.ts.map +1 -0
- package/dist/react/form/index.js +432 -0
- package/dist/react/form/index.js.map +1 -0
- package/dist/react/head/index.browser.js +423 -0
- package/dist/react/head/index.browser.js.map +1 -0
- package/dist/react/head/index.d.ts +288 -0
- package/dist/react/head/index.d.ts.map +1 -0
- package/dist/react/head/index.js +465 -0
- package/dist/react/head/index.js.map +1 -0
- package/dist/react/i18n/index.d.ts +175 -0
- package/dist/react/i18n/index.d.ts.map +1 -0
- package/dist/react/i18n/index.js +224 -0
- package/dist/react/i18n/index.js.map +1 -0
- package/dist/react/router/index.browser.js +1980 -0
- package/dist/react/router/index.browser.js.map +1 -0
- package/dist/react/router/index.d.ts +2068 -0
- package/dist/react/router/index.d.ts.map +1 -0
- package/dist/react/router/index.js +4932 -0
- package/dist/react/router/index.js.map +1 -0
- package/dist/react/websocket/index.d.ts +117 -0
- package/dist/react/websocket/index.d.ts.map +1 -0
- package/dist/react/websocket/index.js +107 -0
- package/dist/react/websocket/index.js.map +1 -0
- package/dist/redis/index.bun.js +4 -0
- package/dist/redis/index.bun.js.map +1 -1
- package/dist/redis/index.d.ts +127 -130
- package/dist/redis/index.d.ts.map +1 -1
- package/dist/redis/index.js +16 -25
- package/dist/redis/index.js.map +1 -1
- package/dist/retry/index.d.ts +80 -71
- package/dist/retry/index.d.ts.map +1 -1
- package/dist/retry/index.js +11 -2
- package/dist/retry/index.js.map +1 -1
- package/dist/router/index.d.ts +6 -6
- package/dist/router/index.d.ts.map +1 -1
- package/dist/scheduler/index.d.ts +119 -28
- package/dist/scheduler/index.d.ts.map +1 -1
- package/dist/scheduler/index.js +404 -3
- package/dist/scheduler/index.js.map +1 -1
- package/dist/security/index.d.ts +642 -228
- package/dist/security/index.d.ts.map +1 -1
- package/dist/security/index.js +1579 -37
- package/dist/security/index.js.map +1 -1
- package/dist/server/auth/index.d.ts +1141 -111
- package/dist/server/auth/index.d.ts.map +1 -1
- package/dist/server/auth/index.js +1261 -25
- package/dist/server/auth/index.js.map +1 -1
- package/dist/server/cache/index.d.ts +63 -78
- package/dist/server/cache/index.d.ts.map +1 -1
- package/dist/server/cache/index.js +7 -22
- package/dist/server/cache/index.js.map +1 -1
- package/dist/server/compress/index.d.ts +13 -5
- package/dist/server/compress/index.d.ts.map +1 -1
- package/dist/server/compress/index.js +10 -2
- package/dist/server/compress/index.js.map +1 -1
- package/dist/server/cookies/index.d.ts +46 -22
- package/dist/server/cookies/index.d.ts.map +1 -1
- package/dist/server/cookies/index.js +7 -5
- package/dist/server/cookies/index.js.map +1 -1
- package/dist/server/core/index.d.ts +307 -196
- package/dist/server/core/index.d.ts.map +1 -1
- package/dist/server/core/index.js +271 -38
- package/dist/server/core/index.js.map +1 -1
- package/dist/server/cors/index.d.ts +24 -34
- package/dist/server/cors/index.d.ts.map +1 -1
- package/dist/server/cors/index.js +7 -21
- package/dist/server/cors/index.js.map +1 -1
- package/dist/server/health/index.d.ts +25 -19
- package/dist/server/health/index.d.ts.map +1 -1
- package/dist/server/health/index.js +8 -2
- package/dist/server/health/index.js.map +1 -1
- package/dist/server/helmet/index.d.ts +13 -5
- package/dist/server/helmet/index.d.ts.map +1 -1
- package/dist/server/helmet/index.js +11 -3
- package/dist/server/helmet/index.js.map +1 -1
- package/dist/server/links/index.browser.js +9 -1
- package/dist/server/links/index.browser.js.map +1 -1
- package/dist/server/links/index.d.ts +133 -128
- package/dist/server/links/index.d.ts.map +1 -1
- package/dist/server/links/index.js +24 -11
- package/dist/server/links/index.js.map +1 -1
- package/dist/server/metrics/index.d.ts +524 -4
- package/dist/server/metrics/index.d.ts.map +1 -1
- package/dist/server/metrics/index.js +4472 -7
- package/dist/server/metrics/index.js.map +1 -1
- package/dist/server/multipart/index.d.ts +15 -9
- package/dist/server/multipart/index.d.ts.map +1 -1
- package/dist/server/multipart/index.js +9 -3
- package/dist/server/multipart/index.js.map +1 -1
- package/dist/server/proxy/index.d.ts +110 -104
- package/dist/server/proxy/index.d.ts.map +1 -1
- package/dist/server/proxy/index.js +8 -2
- package/dist/server/proxy/index.js.map +1 -1
- package/dist/server/rate-limit/index.d.ts +46 -51
- package/dist/server/rate-limit/index.d.ts.map +1 -1
- package/dist/server/rate-limit/index.js +18 -55
- package/dist/server/rate-limit/index.js.map +1 -1
- package/dist/server/static/index.d.ts +181 -48
- package/dist/server/static/index.d.ts.map +1 -1
- package/dist/server/static/index.js +1848 -5
- package/dist/server/static/index.js.map +1 -1
- package/dist/server/swagger/index.d.ts +348 -53
- package/dist/server/swagger/index.d.ts.map +1 -1
- package/dist/server/swagger/index.js +1849 -6
- package/dist/server/swagger/index.js.map +1 -1
- package/dist/sms/index.d.ts +312 -18
- package/dist/sms/index.d.ts.map +1 -1
- package/dist/sms/index.js +1854 -10
- package/dist/sms/index.js.map +1 -1
- package/dist/system/index.browser.js +496 -0
- package/dist/system/index.browser.js.map +1 -0
- package/dist/system/index.d.ts +1158 -0
- package/dist/system/index.d.ts.map +1 -0
- package/dist/{file → system}/index.js +412 -20
- package/dist/system/index.js.map +1 -0
- package/dist/thread/index.d.ts +82 -73
- package/dist/thread/index.d.ts.map +1 -1
- package/dist/thread/index.js +13 -4
- package/dist/thread/index.js.map +1 -1
- package/dist/topic/core/index.d.ts +330 -323
- package/dist/topic/core/index.d.ts.map +1 -1
- package/dist/topic/core/index.js +12 -5
- package/dist/topic/core/index.js.map +1 -1
- package/dist/topic/redis/index.d.ts +6 -6
- package/dist/topic/redis/index.d.ts.map +1 -1
- package/dist/vite/index.d.ts +163 -5825
- package/dist/vite/index.d.ts.map +1 -1
- package/dist/vite/index.js +130 -477
- package/dist/vite/index.js.map +1 -1
- package/dist/websocket/index.browser.js +3 -3
- package/dist/websocket/index.browser.js.map +1 -1
- package/dist/websocket/index.d.ts +287 -283
- package/dist/websocket/index.d.ts.map +1 -1
- package/dist/websocket/index.js +15 -11
- package/dist/websocket/index.js.map +1 -1
- package/package.json +86 -17
- package/src/api/audits/index.ts +10 -33
- package/src/api/files/__tests__/$bucket.spec.ts +1 -1
- package/src/api/files/controllers/AdminFileStatsController.spec.ts +1 -1
- package/src/api/files/controllers/FileController.spec.ts +1 -1
- package/src/api/files/index.ts +10 -3
- package/src/api/files/jobs/FileJobs.spec.ts +1 -1
- package/src/api/files/services/FileService.spec.ts +1 -1
- package/src/api/jobs/index.ts +10 -3
- package/src/api/keys/controllers/AdminApiKeyController.ts +75 -0
- package/src/api/keys/controllers/ApiKeyController.ts +103 -0
- package/src/api/keys/entities/apiKeyEntity.ts +41 -0
- package/src/api/keys/index.ts +49 -0
- package/src/api/keys/schemas/adminApiKeyQuerySchema.ts +7 -0
- package/src/api/keys/schemas/adminApiKeyResourceSchema.ts +17 -0
- package/src/api/keys/schemas/createApiKeyBodySchema.ts +7 -0
- package/src/api/keys/schemas/createApiKeyResponseSchema.ts +11 -0
- package/src/api/keys/schemas/listApiKeyResponseSchema.ts +15 -0
- package/src/api/keys/schemas/revokeApiKeyParamsSchema.ts +5 -0
- package/src/api/keys/schemas/revokeApiKeyResponseSchema.ts +5 -0
- package/src/api/keys/services/ApiKeyService.spec.ts +553 -0
- package/src/api/keys/services/ApiKeyService.ts +306 -0
- package/src/api/logs/TODO.md +52 -0
- package/src/api/notifications/index.ts +10 -4
- package/src/api/parameters/index.ts +9 -30
- package/src/api/parameters/primitives/$config.ts +12 -4
- package/src/api/parameters/services/ConfigStore.ts +9 -3
- package/src/api/users/__tests__/ApiKeys-integration.spec.ts +1035 -0
- package/src/api/users/__tests__/ApiKeys.spec.ts +401 -0
- package/src/api/users/index.ts +14 -3
- package/src/api/users/primitives/$realm.ts +33 -5
- package/src/api/users/providers/RealmProvider.ts +1 -12
- package/src/api/users/services/SessionService.ts +1 -11
- package/src/api/verifications/controllers/VerificationController.ts +2 -0
- package/src/api/verifications/index.ts +10 -4
- package/src/batch/index.ts +9 -36
- package/src/batch/primitives/$batch.ts +0 -8
- package/src/batch/providers/BatchProvider.ts +29 -2
- package/src/bucket/__tests__/shared.ts +1 -1
- package/src/bucket/index.ts +13 -6
- package/src/bucket/primitives/$bucket.ts +1 -1
- package/src/bucket/providers/LocalFileStorageProvider.ts +1 -1
- package/src/bucket/providers/MemoryFileStorageProvider.ts +1 -1
- package/src/cache/core/__tests__/shared.ts +30 -0
- package/src/cache/core/index.ts +11 -6
- package/src/cache/core/primitives/$cache.spec.ts +5 -0
- package/src/cache/core/providers/CacheProvider.ts +17 -0
- package/src/cache/core/providers/MemoryCacheProvider.ts +300 -1
- package/src/cache/redis/__tests__/cache-redis.spec.ts +5 -0
- package/src/cache/redis/providers/RedisCacheProvider.ts +9 -0
- package/src/cli/apps/AlephaCli.ts +3 -16
- package/src/cli/apps/AlephaPackageBuilderCli.ts +10 -2
- package/src/cli/atoms/appEntryOptions.ts +13 -0
- package/src/cli/atoms/buildOptions.ts +1 -1
- package/src/cli/atoms/changelogOptions.ts +1 -1
- package/src/cli/commands/build.ts +64 -52
- package/src/cli/commands/db.ts +17 -11
- package/src/cli/commands/deploy.ts +1 -1
- package/src/cli/commands/dev.ts +13 -49
- package/src/cli/commands/gen/env.ts +6 -3
- package/src/cli/commands/gen/openapi.ts +5 -2
- package/src/cli/commands/init.spec.ts +544 -0
- package/src/cli/commands/init.ts +101 -58
- package/src/cli/commands/lint.ts +8 -2
- package/src/cli/commands/typecheck.ts +11 -0
- package/src/cli/defineConfig.ts +9 -0
- package/src/cli/index.ts +2 -1
- package/src/cli/providers/AppEntryProvider.ts +131 -0
- package/src/cli/providers/ViteBuildProvider.ts +40 -0
- package/src/cli/providers/ViteDevServerProvider.ts +378 -0
- package/src/cli/services/AlephaCliUtils.ts +39 -93
- package/src/cli/services/PackageManagerUtils.ts +140 -17
- package/src/cli/services/ProjectScaffolder.ts +169 -101
- package/src/cli/services/ViteUtils.ts +82 -0
- package/src/cli/{assets/claudeMd.ts → templates/agentMd.ts} +41 -28
- package/src/cli/{assets → templates}/apiHelloControllerTs.ts +2 -1
- package/src/cli/{assets → templates}/biomeJson.ts +2 -1
- package/src/cli/{assets → templates}/dummySpecTs.ts +2 -1
- package/src/cli/{assets → templates}/editorconfig.ts +2 -1
- package/src/cli/templates/gitignore.ts +39 -0
- package/src/cli/{assets → templates}/mainBrowserTs.ts +2 -1
- package/src/cli/templates/mainCss.ts +33 -0
- package/src/cli/templates/mainServerTs.ts +33 -0
- package/src/cli/{assets → templates}/tsconfigJson.ts +2 -1
- package/src/cli/templates/webAppRouterTs.ts +50 -0
- package/src/cli/templates/webHelloComponentTsx.ts +20 -0
- package/src/command/helpers/Runner.spec.ts +4 -0
- package/src/command/helpers/Runner.ts +3 -21
- package/src/command/index.ts +12 -4
- package/src/command/providers/CliProvider.spec.ts +1067 -0
- package/src/command/providers/CliProvider.ts +203 -40
- package/src/core/Alepha.ts +3 -9
- package/src/core/__tests__/Alepha-start.spec.ts +4 -4
- package/src/core/helpers/jsonSchemaToTypeBox.spec.ts +771 -0
- package/src/core/helpers/jsonSchemaToTypeBox.ts +62 -10
- package/src/core/index.shared.ts +1 -0
- package/src/core/index.ts +20 -0
- package/src/core/primitives/$module.ts +12 -0
- package/src/core/providers/EventManager.spec.ts +0 -71
- package/src/core/providers/EventManager.ts +3 -15
- package/src/core/providers/Json.ts +2 -14
- package/src/core/providers/KeylessJsonSchemaCodec.spec.ts +257 -0
- package/src/core/providers/KeylessJsonSchemaCodec.ts +396 -14
- package/src/core/providers/SchemaValidator.spec.ts +236 -0
- package/src/datetime/index.ts +15 -0
- package/src/email/index.ts +10 -5
- package/src/email/providers/LocalEmailProvider.spec.ts +1 -1
- package/src/email/providers/LocalEmailProvider.ts +1 -1
- package/src/fake/__tests__/keyName.example.ts +1 -1
- package/src/fake/__tests__/keyName.spec.ts +5 -5
- package/src/fake/index.ts +9 -6
- package/src/fake/providers/FakeProvider.spec.ts +258 -40
- package/src/fake/providers/FakeProvider.ts +133 -19
- package/src/lock/core/index.ts +11 -4
- package/src/logger/index.ts +17 -66
- package/src/logger/providers/PrettyFormatterProvider.ts +0 -9
- package/src/mcp/errors/McpError.ts +30 -0
- package/src/mcp/index.ts +13 -27
- package/src/mcp/transports/SseMcpTransport.ts +6 -7
- package/src/orm/__tests__/PostgresProvider.spec.ts +2 -2
- package/src/orm/index.browser.ts +2 -2
- package/src/orm/index.bun.ts +4 -2
- package/src/orm/index.ts +21 -47
- package/src/orm/providers/DrizzleKitProvider.ts +3 -5
- package/src/orm/providers/drivers/BunSqliteProvider.ts +1 -0
- package/src/orm/services/Repository.ts +18 -3
- package/src/queue/core/index.ts +14 -6
- package/src/react/auth/__tests__/$auth.spec.ts +202 -0
- package/src/react/auth/hooks/useAuth.ts +32 -0
- package/src/react/auth/index.browser.ts +13 -0
- package/src/react/auth/index.shared.ts +2 -0
- package/src/react/auth/index.ts +48 -0
- package/src/react/auth/providers/ReactAuthProvider.ts +16 -0
- package/src/react/auth/services/ReactAuth.ts +135 -0
- package/src/react/core/__tests__/Router.spec.tsx +169 -0
- package/src/react/core/components/ClientOnly.tsx +49 -0
- package/src/react/core/components/ErrorBoundary.tsx +73 -0
- package/src/react/core/contexts/AlephaContext.ts +7 -0
- package/src/react/core/contexts/AlephaProvider.tsx +42 -0
- package/src/react/core/hooks/useAction.browser.spec.tsx +569 -0
- package/src/react/core/hooks/useAction.ts +480 -0
- package/src/react/core/hooks/useAlepha.ts +26 -0
- package/src/react/core/hooks/useClient.ts +17 -0
- package/src/react/core/hooks/useEvents.ts +51 -0
- package/src/react/core/hooks/useInject.ts +12 -0
- package/src/react/core/hooks/useStore.ts +52 -0
- package/src/react/core/index.ts +90 -0
- package/src/react/form/components/FormState.tsx +17 -0
- package/src/react/form/errors/FormValidationError.ts +18 -0
- package/src/react/form/hooks/useForm.browser.spec.tsx +366 -0
- package/src/react/form/hooks/useForm.ts +47 -0
- package/src/react/form/hooks/useFormState.ts +130 -0
- package/src/react/form/index.ts +44 -0
- package/src/react/form/services/FormModel.ts +614 -0
- package/src/react/head/helpers/SeoExpander.spec.ts +203 -0
- package/src/react/head/helpers/SeoExpander.ts +142 -0
- package/src/react/head/hooks/useHead.spec.tsx +288 -0
- package/src/react/head/hooks/useHead.ts +62 -0
- package/src/react/head/index.browser.ts +26 -0
- package/src/react/head/index.ts +44 -0
- package/src/react/head/interfaces/Head.ts +105 -0
- package/src/react/head/primitives/$head.ts +25 -0
- package/src/react/head/providers/BrowserHeadProvider.browser.spec.ts +196 -0
- package/src/react/head/providers/BrowserHeadProvider.ts +212 -0
- package/src/react/head/providers/HeadProvider.ts +168 -0
- package/src/react/head/providers/ServerHeadProvider.ts +31 -0
- package/src/react/i18n/__tests__/integration.spec.tsx +239 -0
- package/src/react/i18n/components/Localize.spec.tsx +357 -0
- package/src/react/i18n/components/Localize.tsx +35 -0
- package/src/react/i18n/hooks/useI18n.browser.spec.tsx +438 -0
- package/src/react/i18n/hooks/useI18n.ts +18 -0
- package/src/react/i18n/index.ts +41 -0
- package/src/react/i18n/primitives/$dictionary.ts +69 -0
- package/src/react/i18n/providers/I18nProvider.spec.ts +389 -0
- package/src/react/i18n/providers/I18nProvider.ts +278 -0
- package/src/react/router/__tests__/page-head-browser.browser.spec.ts +95 -0
- package/src/react/router/__tests__/page-head.spec.ts +48 -0
- package/src/react/router/__tests__/seo-head.spec.ts +125 -0
- package/src/react/router/atoms/ssrManifestAtom.ts +58 -0
- package/src/react/router/components/ErrorViewer.tsx +872 -0
- package/src/react/router/components/Link.tsx +23 -0
- package/src/react/router/components/NestedView.tsx +223 -0
- package/src/react/router/components/NotFound.tsx +30 -0
- package/src/react/router/constants/PAGE_PRELOAD_KEY.ts +6 -0
- package/src/react/router/contexts/RouterLayerContext.ts +12 -0
- package/src/react/router/errors/Redirection.ts +28 -0
- package/src/react/router/hooks/useActive.ts +52 -0
- package/src/react/router/hooks/useQueryParams.ts +63 -0
- package/src/react/router/hooks/useRouter.ts +20 -0
- package/src/react/router/hooks/useRouterState.ts +11 -0
- package/src/react/router/index.browser.ts +45 -0
- package/src/react/router/index.shared.ts +19 -0
- package/src/react/router/index.ts +142 -0
- package/src/react/router/primitives/$page.browser.spec.tsx +851 -0
- package/src/react/router/primitives/$page.spec.tsx +708 -0
- package/src/react/router/primitives/$page.ts +497 -0
- package/src/react/router/providers/ReactBrowserProvider.ts +309 -0
- package/src/react/router/providers/ReactBrowserRendererProvider.ts +25 -0
- package/src/react/router/providers/ReactBrowserRouterProvider.ts +168 -0
- package/src/react/router/providers/ReactPageProvider.ts +726 -0
- package/src/react/router/providers/ReactServerProvider.spec.tsx +316 -0
- package/src/react/router/providers/ReactServerProvider.ts +558 -0
- package/src/react/router/providers/ReactServerTemplateProvider.ts +979 -0
- package/src/react/router/providers/SSRManifestProvider.ts +334 -0
- package/src/react/router/services/ReactPageServerService.ts +48 -0
- package/src/react/router/services/ReactPageService.ts +27 -0
- package/src/react/router/services/ReactRouter.ts +262 -0
- package/src/react/websocket/hooks/useRoom.tsx +242 -0
- package/src/react/websocket/index.ts +7 -0
- package/src/redis/__tests__/redis.spec.ts +13 -0
- package/src/redis/index.ts +9 -25
- package/src/redis/providers/BunRedisProvider.ts +9 -0
- package/src/redis/providers/NodeRedisProvider.ts +8 -0
- package/src/redis/providers/RedisProvider.ts +16 -0
- package/src/retry/index.ts +11 -2
- package/src/router/index.ts +15 -0
- package/src/scheduler/index.ts +11 -2
- package/src/security/__tests__/BasicAuth.spec.ts +2 -0
- package/src/security/__tests__/ServerSecurityProvider.spec.ts +13 -5
- package/src/security/index.ts +15 -10
- package/src/security/interfaces/IssuerResolver.ts +27 -0
- package/src/security/primitives/$issuer.ts +55 -0
- package/src/security/providers/SecurityProvider.ts +179 -0
- package/src/security/providers/ServerBasicAuthProvider.ts +6 -2
- package/src/security/providers/ServerSecurityProvider.ts +36 -22
- package/src/server/auth/index.ts +12 -7
- package/src/server/cache/index.ts +7 -22
- package/src/server/compress/index.ts +10 -2
- package/src/server/cookies/index.ts +7 -5
- package/src/server/cookies/primitives/$cookie.ts +33 -11
- package/src/server/core/index.ts +17 -7
- package/src/server/core/interfaces/ServerRequest.ts +83 -1
- package/src/server/core/primitives/$action.spec.ts +1 -1
- package/src/server/core/primitives/$action.ts +8 -3
- package/src/server/core/providers/BunHttpServerProvider.ts +1 -1
- package/src/server/core/providers/NodeHttpServerProvider.spec.ts +125 -0
- package/src/server/core/providers/NodeHttpServerProvider.ts +77 -22
- package/src/server/core/providers/ServerLoggerProvider.ts +2 -2
- package/src/server/core/providers/ServerProvider.ts +9 -12
- package/src/server/core/services/ServerRequestParser.spec.ts +520 -0
- package/src/server/core/services/ServerRequestParser.ts +306 -13
- package/src/server/cors/index.ts +7 -21
- package/src/server/cors/primitives/$cors.ts +6 -2
- package/src/server/health/index.ts +8 -2
- package/src/server/helmet/index.ts +11 -3
- package/src/server/links/atoms/apiLinksAtom.ts +7 -0
- package/src/server/links/index.browser.ts +2 -0
- package/src/server/links/index.ts +13 -6
- package/src/server/metrics/index.ts +10 -3
- package/src/server/multipart/index.ts +9 -3
- package/src/server/proxy/index.ts +8 -2
- package/src/server/rate-limit/index.ts +21 -25
- package/src/server/rate-limit/primitives/$rateLimit.ts +6 -2
- package/src/server/rate-limit/providers/ServerRateLimitProvider.spec.ts +38 -14
- package/src/server/rate-limit/providers/ServerRateLimitProvider.ts +22 -56
- package/src/server/static/index.ts +8 -2
- package/src/server/static/providers/ServerStaticProvider.ts +1 -1
- package/src/server/swagger/index.ts +9 -4
- package/src/server/swagger/providers/ServerSwaggerProvider.ts +1 -1
- package/src/sms/index.ts +9 -5
- package/src/sms/providers/LocalSmsProvider.spec.ts +1 -1
- package/src/sms/providers/LocalSmsProvider.ts +1 -1
- package/src/system/index.browser.ts +11 -0
- package/src/system/index.ts +62 -0
- package/src/{file → system}/providers/FileSystemProvider.ts +16 -0
- package/src/{file → system}/providers/MemoryFileSystemProvider.ts +116 -3
- package/src/system/providers/MemoryShellProvider.ts +164 -0
- package/src/{file → system}/providers/NodeFileSystemProvider.spec.ts +2 -2
- package/src/{file → system}/providers/NodeFileSystemProvider.ts +36 -0
- package/src/system/providers/NodeShellProvider.ts +184 -0
- package/src/system/providers/ShellProvider.ts +74 -0
- package/src/{file → system}/services/FileDetector.spec.ts +2 -2
- package/src/thread/index.ts +11 -2
- package/src/topic/core/index.ts +12 -5
- package/src/vite/index.ts +3 -2
- package/src/vite/tasks/buildClient.ts +2 -8
- package/src/vite/tasks/buildServer.ts +84 -21
- package/src/vite/tasks/copyAssets.ts +5 -4
- package/src/vite/tasks/generateSitemap.ts +64 -23
- package/src/vite/tasks/index.ts +0 -2
- package/src/vite/tasks/prerenderPages.ts +49 -24
- package/src/websocket/index.ts +12 -8
- package/dist/file/index.d.ts +0 -839
- package/dist/file/index.d.ts.map +0 -1
- package/dist/file/index.js.map +0 -1
- package/src/cli/assets/indexHtml.ts +0 -15
- package/src/cli/assets/mainServerTs.ts +0 -24
- package/src/cli/assets/webAppRouterTs.ts +0 -15
- package/src/cli/assets/webHelloComponentTsx.ts +0 -16
- package/src/cli/commands/format.ts +0 -23
- package/src/file/index.ts +0 -43
- package/src/vite/helpers/boot.ts +0 -117
- package/src/vite/plugins/viteAlephaDev.ts +0 -177
- package/src/vite/tasks/devServer.ts +0 -71
- package/src/vite/tasks/runAlepha.ts +0 -270
- /package/dist/orm/{chunk-DtkW-qnP.js → chunk-DH6iiROE.js} +0 -0
- /package/src/cli/{assets → templates}/apiIndexTs.ts +0 -0
- /package/src/cli/{assets → templates}/webIndexTs.ts +0 -0
- /package/src/{file → system}/errors/FileError.ts +0 -0
- /package/src/{file → system}/services/FileDetector.ts +0 -0
package/dist/orm/index.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { n as __reExport, t as __exportAll } from "./chunk-
|
|
2
|
-
import * as
|
|
1
|
+
import { n as __reExport, t as __exportAll } from "./chunk-DH6iiROE.js";
|
|
2
|
+
import * as alepha26 from "alepha";
|
|
3
3
|
import { Alepha, AlephaError, KIND, Page, Page as Page$1, PageQuery, PageQuery as PageQuery$1, Primitive, Service, Static, StaticEncode, TBigInt, TInteger, TNull, TNumber, TNumberOptions, TObject, TObjectOptions, TOptional, TPage, TSchema, TString, TStringOptions, TUnion, TUnsafe, pageQuerySchema, pageSchema } from "alepha";
|
|
4
4
|
import { DateTime, DateTimeProvider } from "alepha/datetime";
|
|
5
5
|
import * as drizzle_orm_pg_core0 from "drizzle-orm/pg-core";
|
|
6
6
|
import { LockConfig, LockStrength, PgColumn, PgColumnBuilderBase, PgDatabase, PgInsertValue, PgSchema, PgSelectBase, PgSequenceOptions, PgTableExtraConfigValue, PgTableWithColumns, PgTransaction, UpdateDeleteAction } from "drizzle-orm/pg-core";
|
|
7
7
|
import * as drizzle_orm0 from "drizzle-orm";
|
|
8
8
|
import { BuildColumns, BuildExtraConfigColumns, SQL, SQLWrapper, sql } from "drizzle-orm";
|
|
9
|
-
import * as
|
|
9
|
+
import * as alepha_logger4 from "alepha/logger";
|
|
10
10
|
import * as alepha_lock0 from "alepha/lock";
|
|
11
11
|
import * as pg$1 from "drizzle-orm/sqlite-core";
|
|
12
12
|
import { SQLiteColumnBuilderBase } from "drizzle-orm/sqlite-core";
|
|
@@ -18,12 +18,65 @@ import { BunSQLDatabase } from "drizzle-orm/bun-sql";
|
|
|
18
18
|
import { BunSQLiteDatabase } from "drizzle-orm/bun-sqlite";
|
|
19
19
|
import { DrizzleD1Database } from "drizzle-orm/d1";
|
|
20
20
|
import { DatabaseSync } from "node:sqlite";
|
|
21
|
+
import * as typebox0 from "typebox";
|
|
22
|
+
import * as DrizzleKit from "drizzle-kit/api";
|
|
21
23
|
import { UpdateDeleteAction as UpdateDeleteAction$1 } from "drizzle-orm/pg-core/foreign-keys";
|
|
22
24
|
import { PgTransactionConfig } from "drizzle-orm/pg-core/session";
|
|
23
|
-
import * as DrizzleKit from "drizzle-kit/api";
|
|
24
|
-
import * as typebox1 from "typebox";
|
|
25
25
|
export * from "drizzle-orm/pg-core";
|
|
26
26
|
|
|
27
|
+
//#region ../../src/orm/constants/PG_SYMBOLS.d.ts
|
|
28
|
+
declare const PG_DEFAULT: unique symbol;
|
|
29
|
+
declare const PG_PRIMARY_KEY: unique symbol;
|
|
30
|
+
declare const PG_CREATED_AT: unique symbol;
|
|
31
|
+
declare const PG_UPDATED_AT: unique symbol;
|
|
32
|
+
declare const PG_DELETED_AT: unique symbol;
|
|
33
|
+
declare const PG_VERSION: unique symbol;
|
|
34
|
+
declare const PG_IDENTITY: unique symbol;
|
|
35
|
+
declare const PG_ENUM: unique symbol;
|
|
36
|
+
declare const PG_REF: unique symbol;
|
|
37
|
+
/**
|
|
38
|
+
* @deprecated Use `PG_IDENTITY` instead.
|
|
39
|
+
*/
|
|
40
|
+
declare const PG_SERIAL: unique symbol;
|
|
41
|
+
type PgDefault = typeof PG_DEFAULT;
|
|
42
|
+
type PgRef = typeof PG_REF;
|
|
43
|
+
type PgPrimaryKey = typeof PG_PRIMARY_KEY;
|
|
44
|
+
type PgSymbols = {
|
|
45
|
+
[PG_DEFAULT]: {};
|
|
46
|
+
[PG_PRIMARY_KEY]: {};
|
|
47
|
+
[PG_CREATED_AT]: {};
|
|
48
|
+
[PG_UPDATED_AT]: {};
|
|
49
|
+
[PG_DELETED_AT]: {};
|
|
50
|
+
[PG_VERSION]: {};
|
|
51
|
+
[PG_IDENTITY]: PgIdentityOptions;
|
|
52
|
+
[PG_REF]: PgRefOptions;
|
|
53
|
+
[PG_ENUM]: PgEnumOptions;
|
|
54
|
+
/**
|
|
55
|
+
* @deprecated Use `PG_IDENTITY` instead.
|
|
56
|
+
*/
|
|
57
|
+
[PG_SERIAL]: {};
|
|
58
|
+
};
|
|
59
|
+
type PgSymbolKeys = keyof PgSymbols;
|
|
60
|
+
type PgIdentityOptions = {
|
|
61
|
+
mode: "always" | "byDefault";
|
|
62
|
+
} & PgSequenceOptions & {
|
|
63
|
+
name?: string;
|
|
64
|
+
};
|
|
65
|
+
interface PgEnumOptions {
|
|
66
|
+
name?: string;
|
|
67
|
+
description?: string;
|
|
68
|
+
}
|
|
69
|
+
interface PgRefOptions {
|
|
70
|
+
ref: () => {
|
|
71
|
+
name: string;
|
|
72
|
+
entity: EntityPrimitive;
|
|
73
|
+
};
|
|
74
|
+
actions?: {
|
|
75
|
+
onUpdate?: UpdateDeleteAction;
|
|
76
|
+
onDelete?: UpdateDeleteAction;
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
//#endregion
|
|
27
80
|
//#region ../../src/orm/schemas/insertSchema.d.ts
|
|
28
81
|
/**
|
|
29
82
|
* Transforms a TObject schema for insert operations.
|
|
@@ -73,119 +126,119 @@ declare const updateSchema: <T extends TObject>(schema: T) => TObjectUpdate<T>;
|
|
|
73
126
|
* ```
|
|
74
127
|
*/
|
|
75
128
|
declare const $entity: {
|
|
76
|
-
<TSchema
|
|
129
|
+
<TSchema extends TObject>(options: EntityPrimitiveOptions<TSchema>): EntityPrimitive<TSchema>;
|
|
77
130
|
[KIND]: typeof EntityPrimitive;
|
|
78
131
|
};
|
|
79
132
|
interface EntityPrimitiveOptions<T extends TObject, Keys = keyof Static<T>> {
|
|
80
133
|
/**
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
134
|
+
* The database table name that will be created for this entity.
|
|
135
|
+
* If not provided, name will be inferred from the $repository variable name.
|
|
136
|
+
*/
|
|
84
137
|
name: string;
|
|
85
138
|
/**
|
|
86
|
-
|
|
87
|
-
|
|
139
|
+
* TypeBox schema defining the table structure and column types.
|
|
140
|
+
*/
|
|
88
141
|
schema: T;
|
|
89
142
|
/**
|
|
90
|
-
|
|
91
|
-
|
|
143
|
+
* Database indexes to create for query optimization.
|
|
144
|
+
*/
|
|
92
145
|
indexes?: (Keys | {
|
|
93
146
|
/**
|
|
94
|
-
|
|
95
|
-
|
|
147
|
+
* Single column to index.
|
|
148
|
+
*/
|
|
96
149
|
column: Keys;
|
|
97
150
|
/**
|
|
98
|
-
|
|
99
|
-
|
|
151
|
+
* Whether this should be a unique index (enforces uniqueness constraint).
|
|
152
|
+
*/
|
|
100
153
|
unique?: boolean;
|
|
101
154
|
/**
|
|
102
|
-
|
|
103
|
-
|
|
155
|
+
* Custom name for the index. If not provided, generates name automatically.
|
|
156
|
+
*/
|
|
104
157
|
name?: string;
|
|
105
158
|
} | {
|
|
106
159
|
/**
|
|
107
|
-
|
|
108
|
-
|
|
160
|
+
* Multiple columns for composite index (order matters for query optimization).
|
|
161
|
+
*/
|
|
109
162
|
columns: Keys[];
|
|
110
163
|
/**
|
|
111
|
-
|
|
112
|
-
|
|
164
|
+
* Whether this should be a unique index (enforces uniqueness constraint).
|
|
165
|
+
*/
|
|
113
166
|
unique?: boolean;
|
|
114
167
|
/**
|
|
115
|
-
|
|
116
|
-
|
|
168
|
+
* Custom name for the index. If not provided, generates name automatically.
|
|
169
|
+
*/
|
|
117
170
|
name?: string;
|
|
118
171
|
})[];
|
|
119
172
|
/**
|
|
120
|
-
|
|
121
|
-
|
|
173
|
+
* Foreign key constraints to maintain referential integrity.
|
|
174
|
+
*/
|
|
122
175
|
foreignKeys?: Array<{
|
|
123
176
|
/**
|
|
124
|
-
|
|
125
|
-
|
|
177
|
+
* Optional name for the foreign key constraint.
|
|
178
|
+
*/
|
|
126
179
|
name?: string;
|
|
127
180
|
/**
|
|
128
|
-
|
|
129
|
-
|
|
181
|
+
* Local columns that reference the foreign table.
|
|
182
|
+
*/
|
|
130
183
|
columns: Array<keyof Static<T>>;
|
|
131
184
|
/**
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
185
|
+
* Referenced columns in the foreign table.
|
|
186
|
+
* Must be EntityColumn references from other entities.
|
|
187
|
+
*/
|
|
135
188
|
foreignColumns: Array<() => EntityColumn<any>>;
|
|
136
189
|
}>;
|
|
137
190
|
/**
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
191
|
+
* Additional table constraints for data validation.
|
|
192
|
+
*
|
|
193
|
+
* Constraints enforce business rules at the database level, providing
|
|
194
|
+
* an additional layer of data integrity beyond application validation.
|
|
195
|
+
*
|
|
196
|
+
* **Constraint Types**:
|
|
197
|
+
* - **Unique constraints**: Prevent duplicate values across columns
|
|
198
|
+
* - **Check constraints**: Enforce custom validation rules with SQL expressions
|
|
199
|
+
*
|
|
200
|
+
* @example
|
|
201
|
+
* ```ts
|
|
202
|
+
* constraints: [
|
|
203
|
+
* {
|
|
204
|
+
* name: "unique_user_email",
|
|
205
|
+
* columns: ["email"],
|
|
206
|
+
* unique: true
|
|
207
|
+
* },
|
|
208
|
+
* {
|
|
209
|
+
* name: "valid_age_range",
|
|
210
|
+
* columns: ["age"],
|
|
211
|
+
* check: sql`age >= 0 AND age <= 150`
|
|
212
|
+
* },
|
|
213
|
+
* {
|
|
214
|
+
* name: "unique_user_username_per_tenant",
|
|
215
|
+
* columns: ["tenantId", "username"],
|
|
216
|
+
* unique: true
|
|
217
|
+
* }
|
|
218
|
+
* ]
|
|
219
|
+
* ```
|
|
220
|
+
*/
|
|
168
221
|
constraints?: Array<{
|
|
169
222
|
/**
|
|
170
|
-
|
|
171
|
-
|
|
223
|
+
* Columns involved in this constraint.
|
|
224
|
+
*/
|
|
172
225
|
columns: Array<keyof Static<T>>;
|
|
173
226
|
/**
|
|
174
|
-
|
|
175
|
-
|
|
227
|
+
* Optional name for the constraint.
|
|
228
|
+
*/
|
|
176
229
|
name?: string;
|
|
177
230
|
/**
|
|
178
|
-
|
|
179
|
-
|
|
231
|
+
* Whether this is a unique constraint.
|
|
232
|
+
*/
|
|
180
233
|
unique?: boolean | {};
|
|
181
234
|
/**
|
|
182
|
-
|
|
183
|
-
|
|
235
|
+
* SQL expression for check constraint validation.
|
|
236
|
+
*/
|
|
184
237
|
check?: SQL;
|
|
185
238
|
}>;
|
|
186
239
|
/**
|
|
187
|
-
|
|
188
|
-
|
|
240
|
+
* Advanced Drizzle ORM configuration for complex table setups.
|
|
241
|
+
*/
|
|
189
242
|
config?: (self: BuildExtraConfigColumns<string, FromSchema<T>, "pg">) => PgTableExtraConfigValue[];
|
|
190
243
|
}
|
|
191
244
|
declare class EntityPrimitive<T extends TObject = TObject> {
|
|
@@ -214,57 +267,382 @@ type EntityColumn<T extends TObject> = {
|
|
|
214
267
|
};
|
|
215
268
|
type EntityColumns<T extends TObject> = { [key in keyof T["properties"]]: EntityColumn<T> };
|
|
216
269
|
//#endregion
|
|
217
|
-
//#region ../../src/orm/
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
270
|
+
//#region ../../src/orm/services/ModelBuilder.d.ts
|
|
271
|
+
/**
|
|
272
|
+
* Database-specific table configuration functions
|
|
273
|
+
*/
|
|
274
|
+
interface TableConfigBuilders<TConfig> {
|
|
275
|
+
index: (name: string) => {
|
|
276
|
+
on: (...columns: any[]) => TConfig;
|
|
277
|
+
};
|
|
278
|
+
uniqueIndex: (name: string) => {
|
|
279
|
+
on: (...columns: any[]) => TConfig;
|
|
280
|
+
};
|
|
281
|
+
unique: (name: string) => {
|
|
282
|
+
on: (...columns: any[]) => TConfig;
|
|
283
|
+
};
|
|
284
|
+
check: (name: string, sql: SQL) => TConfig;
|
|
285
|
+
foreignKey: (config: {
|
|
286
|
+
name: string;
|
|
287
|
+
columns: any[];
|
|
288
|
+
foreignColumns: any[];
|
|
289
|
+
}) => TConfig;
|
|
290
|
+
}
|
|
291
|
+
/**
|
|
292
|
+
* Abstract base class for transforming Alepha Primitives (Entity, Sequence, etc...)
|
|
293
|
+
* into drizzle models (tables, enums, sequences, etc...).
|
|
294
|
+
*/
|
|
295
|
+
declare abstract class ModelBuilder {
|
|
296
|
+
/**
|
|
297
|
+
* Build a table from an entity primitive.
|
|
298
|
+
*/
|
|
299
|
+
abstract buildTable(entity: EntityPrimitive, options: {
|
|
300
|
+
tables: Map<string, unknown>;
|
|
301
|
+
enums: Map<string, unknown>;
|
|
302
|
+
schema: string;
|
|
303
|
+
}): void;
|
|
304
|
+
/**
|
|
305
|
+
* Build a sequence from a sequence primitive.
|
|
306
|
+
*/
|
|
307
|
+
abstract buildSequence(sequence: SequencePrimitive, options: {
|
|
308
|
+
sequences: Map<string, unknown>;
|
|
309
|
+
schema: string;
|
|
310
|
+
}): void;
|
|
311
|
+
/**
|
|
312
|
+
* Convert camelCase to snake_case for column names.
|
|
313
|
+
*/
|
|
314
|
+
protected toColumnName(str: string): string;
|
|
315
|
+
/**
|
|
316
|
+
* Build the table configuration function for any database.
|
|
317
|
+
* This includes indexes, foreign keys, constraints, and custom config.
|
|
318
|
+
*
|
|
319
|
+
* @param entity - The entity primitive
|
|
320
|
+
* @param builders - Database-specific builder functions
|
|
321
|
+
* @param tableResolver - Function to resolve entity references to table columns
|
|
322
|
+
* @param customConfigHandler - Optional handler for custom config
|
|
323
|
+
*/
|
|
324
|
+
protected buildTableConfig<TConfig, TSelf>(entity: EntityPrimitive, builders: TableConfigBuilders<TConfig>, tableResolver?: (entityName: string) => any, customConfigHandler?: (config: any, self: TSelf) => TConfig[]): ((self: TSelf) => TConfig[]) | undefined;
|
|
325
|
+
}
|
|
326
|
+
//#endregion
|
|
327
|
+
//#region ../../src/orm/providers/DrizzleKitProvider.d.ts
|
|
328
|
+
declare class DrizzleKitProvider {
|
|
329
|
+
protected readonly log: alepha_logger4.Logger;
|
|
330
|
+
protected readonly alepha: Alepha;
|
|
331
|
+
/**
|
|
332
|
+
* Synchronize database with current schema definitions.
|
|
333
|
+
*
|
|
334
|
+
* In development mode, it will generate and execute migrations based on the current state.
|
|
335
|
+
* In testing mode, it will generate migrations from scratch without applying them.
|
|
336
|
+
*
|
|
337
|
+
* Does nothing in production mode, you must handle migrations manually.
|
|
338
|
+
*/
|
|
339
|
+
synchronize(provider: DatabaseProvider): Promise<void>;
|
|
340
|
+
/**
|
|
341
|
+
* Mostly used for testing purposes. You can generate SQL migration statements without executing them.
|
|
342
|
+
*/
|
|
343
|
+
generateMigration(provider: DatabaseProvider, prevSnapshot?: any): Promise<{
|
|
344
|
+
statements: string[];
|
|
345
|
+
models: Record<string, unknown>;
|
|
346
|
+
snapshot?: any;
|
|
347
|
+
}>;
|
|
348
|
+
/**
|
|
349
|
+
* Load all tables, enums, sequences, etc. from the provider's repositories.
|
|
350
|
+
*/
|
|
351
|
+
getModels(provider: DatabaseProvider): Record<string, unknown>;
|
|
352
|
+
/**
|
|
353
|
+
* Load the migration snapshot from the database.
|
|
354
|
+
*/
|
|
355
|
+
protected loadDevMigrations(provider: DatabaseProvider): Promise<DevMigrations | undefined>;
|
|
356
|
+
protected saveDevMigrations(provider: DatabaseProvider, curr: Record<string, any>, devMigrations?: DevMigrations): Promise<void>;
|
|
357
|
+
protected executeStatements(statements: string[], provider: DatabaseProvider, catchErrors?: boolean): Promise<void>;
|
|
358
|
+
protected createSchemaIfNotExists(provider: DatabaseProvider, schemaName: string): Promise<void>;
|
|
359
|
+
/**
|
|
360
|
+
* Try to load the official Drizzle Kit API.
|
|
361
|
+
* If not available, fallback to the local kit import.
|
|
362
|
+
*/
|
|
363
|
+
importDrizzleKit(): typeof DrizzleKit;
|
|
364
|
+
}
|
|
365
|
+
declare const devMigrationsSchema: alepha26.TObject<{
|
|
366
|
+
id: alepha26.TNumber;
|
|
367
|
+
name: alepha26.TString;
|
|
368
|
+
snapshot: alepha26.TString;
|
|
369
|
+
created_at: alepha26.TString;
|
|
370
|
+
}>;
|
|
371
|
+
type DevMigrations = Static<typeof devMigrationsSchema>;
|
|
372
|
+
//#endregion
|
|
373
|
+
//#region ../../src/orm/providers/drivers/DatabaseProvider.d.ts
|
|
374
|
+
type SQLLike = SQLWrapper | string;
|
|
375
|
+
declare abstract class DatabaseProvider {
|
|
376
|
+
protected readonly alepha: Alepha;
|
|
377
|
+
protected readonly log: alepha_logger4.Logger;
|
|
378
|
+
protected abstract readonly builder: ModelBuilder;
|
|
379
|
+
protected abstract readonly kit: DrizzleKitProvider;
|
|
380
|
+
abstract readonly db: PgDatabase<any>;
|
|
381
|
+
abstract readonly dialect: "postgresql" | "sqlite";
|
|
382
|
+
abstract readonly url: string;
|
|
383
|
+
readonly enums: Map<string, unknown>;
|
|
384
|
+
readonly tables: Map<string, unknown>;
|
|
385
|
+
readonly sequences: Map<string, unknown>;
|
|
386
|
+
get name(): string;
|
|
387
|
+
get driver(): string;
|
|
388
|
+
get schema(): string;
|
|
389
|
+
table<T extends TObject>(entity: EntityPrimitive<T>): PgTableWithColumns<SchemaToTableConfig<T>>;
|
|
390
|
+
registerEntity(entity: EntityPrimitive): void;
|
|
391
|
+
registerSequence(sequence: SequencePrimitive): void;
|
|
392
|
+
abstract execute(statement: SQLLike): Promise<Record<string, unknown>[]>;
|
|
393
|
+
run<T extends TObject>(statement: SQLLike, schema: T): Promise<Array<Static<T>>>;
|
|
394
|
+
/**
|
|
395
|
+
* Get migrations folder path - can be overridden
|
|
396
|
+
*/
|
|
397
|
+
protected getMigrationsFolder(): string;
|
|
398
|
+
/**
|
|
399
|
+
* Base migration orchestration - handles environment logic
|
|
400
|
+
*/
|
|
401
|
+
migrate(): Promise<void>;
|
|
402
|
+
/**
|
|
403
|
+
* Production: run migrations from folder
|
|
404
|
+
*/
|
|
405
|
+
protected runProductionMigration(migrationsFolder: string): Promise<void>;
|
|
406
|
+
/**
|
|
407
|
+
* Test: always synchronize
|
|
408
|
+
*/
|
|
409
|
+
protected runTestMigration(): Promise<void>;
|
|
410
|
+
/**
|
|
411
|
+
* Development: default to synchronize (can be overridden)
|
|
412
|
+
*/
|
|
413
|
+
protected runDevelopmentMigration(migrationsFolder: string): Promise<void>;
|
|
414
|
+
/**
|
|
415
|
+
* Common synchronization with error handling
|
|
416
|
+
*/
|
|
417
|
+
protected synchronizeSchema(): Promise<void>;
|
|
418
|
+
/**
|
|
419
|
+
* Provider-specific migration execution
|
|
420
|
+
* MUST be implemented by each provider
|
|
421
|
+
*/
|
|
422
|
+
protected abstract executeMigrations(migrationsFolder: string): Promise<void>;
|
|
423
|
+
/**
|
|
424
|
+
* For testing purposes, generate a unique schema name.
|
|
425
|
+
* The schema name will be generated based on the current date and time.
|
|
426
|
+
* It will be in the format of `test_YYYYMMDD_HHMMSS_randomSuffix`.
|
|
427
|
+
*/
|
|
428
|
+
protected generateTestSchemaName(): string;
|
|
429
|
+
}
|
|
430
|
+
//#endregion
|
|
431
|
+
//#region ../../src/orm/primitives/$sequence.d.ts
|
|
432
|
+
/**
|
|
433
|
+
* Creates a PostgreSQL sequence primitive for generating unique numeric values.
|
|
434
|
+
*/
|
|
435
|
+
declare const $sequence: {
|
|
436
|
+
(options?: SequencePrimitiveOptions): SequencePrimitive;
|
|
437
|
+
[KIND]: typeof SequencePrimitive;
|
|
438
|
+
};
|
|
439
|
+
interface SequencePrimitiveOptions extends PgSequenceOptions {
|
|
440
|
+
/**
|
|
441
|
+
* The name of the sequence. If not provided, the property key will be used.
|
|
442
|
+
*/
|
|
443
|
+
name?: string;
|
|
444
|
+
provider?: DatabaseProvider;
|
|
445
|
+
}
|
|
446
|
+
declare class SequencePrimitive extends Primitive<SequencePrimitiveOptions> {
|
|
447
|
+
readonly provider: DatabaseProvider;
|
|
448
|
+
onInit(): void;
|
|
449
|
+
get name(): string;
|
|
450
|
+
next(): Promise<number>;
|
|
451
|
+
current(): Promise<number>;
|
|
452
|
+
protected $provider(): DatabaseProvider;
|
|
453
|
+
}
|
|
454
|
+
//#endregion
|
|
455
|
+
//#region ../../src/orm/services/SqliteModelBuilder.d.ts
|
|
456
|
+
declare class SqliteModelBuilder extends ModelBuilder {
|
|
457
|
+
buildTable(entity: EntityPrimitive<any>, options: {
|
|
458
|
+
tables: Map<string, unknown>;
|
|
459
|
+
enums: Map<string, unknown>;
|
|
460
|
+
schema: string;
|
|
461
|
+
}): void;
|
|
462
|
+
buildSequence(sequence: SequencePrimitive, options: {
|
|
463
|
+
sequences: Map<string, unknown>;
|
|
464
|
+
schema: string;
|
|
465
|
+
}): void;
|
|
466
|
+
/**
|
|
467
|
+
* Get SQLite-specific config builder for the table.
|
|
468
|
+
*/
|
|
469
|
+
protected getTableConfig(entity: EntityPrimitive, tables: Map<string, unknown>): ((self: BuildColumns<string, any, "sqlite">) => any) | undefined;
|
|
470
|
+
schemaToSqliteColumns: <T extends TObject>(tableName: string, schema: T, enums: Map<string, unknown>, tables: Map<string, unknown>) => SchemaToSqliteBuilder<T>;
|
|
471
|
+
mapFieldToSqliteColumn: (tableName: string, fieldName: string, value: TSchema, enums: Map<string, any>) => pg$1.SQLiteIntegerBuilderInitial<string> | pg$1.SQLiteNumericBuilderInitial<string> | pg$1.SQLiteTextBuilderInitial<string, [string, ...string[]], number | undefined> | drizzle_orm0.$Type<pg$1.SQLiteCustomColumnBuilder<{
|
|
472
|
+
name: string;
|
|
473
|
+
dataType: "custom";
|
|
474
|
+
columnType: "SQLiteCustomColumn";
|
|
475
|
+
data: string;
|
|
476
|
+
driverParam: string;
|
|
477
|
+
enumValues: undefined;
|
|
478
|
+
}>, string> | pg$1.SQLiteCustomColumnBuilder<{
|
|
479
|
+
name: string;
|
|
480
|
+
dataType: "custom";
|
|
481
|
+
columnType: "SQLiteCustomColumn";
|
|
482
|
+
data: string;
|
|
483
|
+
driverParam: number;
|
|
484
|
+
enumValues: undefined;
|
|
485
|
+
}> | pg$1.SQLiteCustomColumnBuilder<{
|
|
486
|
+
name: string;
|
|
487
|
+
dataType: "custom";
|
|
488
|
+
columnType: "SQLiteCustomColumn";
|
|
489
|
+
data: boolean;
|
|
490
|
+
driverParam: number;
|
|
491
|
+
enumValues: undefined;
|
|
492
|
+
}> | drizzle_orm0.$Type<pg$1.SQLiteCustomColumnBuilder<{
|
|
493
|
+
name: string;
|
|
494
|
+
dataType: "custom";
|
|
495
|
+
columnType: "SQLiteCustomColumn";
|
|
496
|
+
data: {
|
|
497
|
+
[x: string]: unknown;
|
|
498
|
+
[x: number]: unknown;
|
|
499
|
+
[x: symbol]: unknown;
|
|
500
|
+
};
|
|
501
|
+
driverParam: string;
|
|
502
|
+
enumValues: undefined;
|
|
503
|
+
}>, {
|
|
504
|
+
[x: string]: unknown;
|
|
505
|
+
[x: number]: unknown;
|
|
506
|
+
[x: symbol]: unknown;
|
|
507
|
+
}> | drizzle_orm0.$Type<pg$1.SQLiteCustomColumnBuilder<{
|
|
508
|
+
name: string;
|
|
509
|
+
dataType: "custom";
|
|
510
|
+
columnType: "SQLiteCustomColumn";
|
|
511
|
+
data: typebox0.StaticRecord<[], "Decode", {}, {}, string, TSchema>;
|
|
512
|
+
driverParam: string;
|
|
513
|
+
enumValues: undefined;
|
|
514
|
+
}>, typebox0.StaticRecord<[], "Decode", {}, {}, string, TSchema>> | drizzle_orm0.$Type<pg$1.SQLiteCustomColumnBuilder<{
|
|
515
|
+
name: string;
|
|
516
|
+
dataType: "custom";
|
|
517
|
+
columnType: "SQLiteCustomColumn";
|
|
518
|
+
data: any;
|
|
519
|
+
driverParam: string;
|
|
520
|
+
enumValues: undefined;
|
|
521
|
+
}>, any> | drizzle_orm0.$Type<pg$1.SQLiteCustomColumnBuilder<{
|
|
522
|
+
name: string;
|
|
523
|
+
dataType: "custom";
|
|
524
|
+
columnType: "SQLiteCustomColumn";
|
|
525
|
+
data: unknown[];
|
|
526
|
+
driverParam: string;
|
|
527
|
+
enumValues: undefined;
|
|
528
|
+
}>, unknown[]>;
|
|
529
|
+
mapStringToSqliteColumn: (key: string, value: TString) => pg$1.SQLiteTextBuilderInitial<string, [string, ...string[]], number | undefined> | drizzle_orm0.$Type<pg$1.SQLiteCustomColumnBuilder<{
|
|
530
|
+
name: string;
|
|
531
|
+
dataType: "custom";
|
|
532
|
+
columnType: "SQLiteCustomColumn";
|
|
533
|
+
data: string;
|
|
534
|
+
driverParam: string;
|
|
535
|
+
enumValues: undefined;
|
|
536
|
+
}>, string> | pg$1.SQLiteCustomColumnBuilder<{
|
|
537
|
+
name: string;
|
|
538
|
+
dataType: "custom";
|
|
539
|
+
columnType: "SQLiteCustomColumn";
|
|
540
|
+
data: string;
|
|
541
|
+
driverParam: number;
|
|
542
|
+
enumValues: undefined;
|
|
543
|
+
}>;
|
|
544
|
+
sqliteJson: <TDocument extends TSchema>(name: string, document: TDocument) => drizzle_orm0.$Type<pg$1.SQLiteCustomColumnBuilder<{
|
|
545
|
+
name: string;
|
|
546
|
+
dataType: "custom";
|
|
547
|
+
columnType: "SQLiteCustomColumn";
|
|
548
|
+
data: typebox0.StaticType<[], "Decode", {}, {}, TDocument>;
|
|
549
|
+
driverParam: string;
|
|
550
|
+
enumValues: undefined;
|
|
551
|
+
}>, typebox0.StaticType<[], "Decode", {}, {}, TDocument>>;
|
|
552
|
+
sqliteDateTime: {
|
|
553
|
+
<TConfig extends Record<string, any>>(fieldConfig: TConfig): pg$1.SQLiteCustomColumnBuilder<{
|
|
554
|
+
name: "";
|
|
555
|
+
dataType: "custom";
|
|
556
|
+
columnType: "SQLiteCustomColumn";
|
|
557
|
+
data: string;
|
|
558
|
+
driverParam: number;
|
|
559
|
+
enumValues: undefined;
|
|
560
|
+
}>;
|
|
561
|
+
<TName extends string>(dbName: TName, fieldConfig: unknown): pg$1.SQLiteCustomColumnBuilder<{
|
|
562
|
+
name: TName;
|
|
563
|
+
dataType: "custom";
|
|
564
|
+
columnType: "SQLiteCustomColumn";
|
|
565
|
+
data: string;
|
|
566
|
+
driverParam: number;
|
|
567
|
+
enumValues: undefined;
|
|
568
|
+
}>;
|
|
569
|
+
};
|
|
570
|
+
sqliteBool: {
|
|
571
|
+
<TConfig extends Record<string, any>>(fieldConfig: TConfig): pg$1.SQLiteCustomColumnBuilder<{
|
|
572
|
+
name: "";
|
|
573
|
+
dataType: "custom";
|
|
574
|
+
columnType: "SQLiteCustomColumn";
|
|
575
|
+
data: boolean;
|
|
576
|
+
driverParam: number;
|
|
577
|
+
enumValues: undefined;
|
|
578
|
+
}>;
|
|
579
|
+
<TName extends string>(dbName: TName, fieldConfig: unknown): pg$1.SQLiteCustomColumnBuilder<{
|
|
580
|
+
name: TName;
|
|
581
|
+
dataType: "custom";
|
|
582
|
+
columnType: "SQLiteCustomColumn";
|
|
583
|
+
data: boolean;
|
|
584
|
+
driverParam: number;
|
|
585
|
+
enumValues: undefined;
|
|
586
|
+
}>;
|
|
587
|
+
};
|
|
588
|
+
sqliteDate: {
|
|
589
|
+
<TConfig extends Record<string, any>>(fieldConfig: TConfig): pg$1.SQLiteCustomColumnBuilder<{
|
|
590
|
+
name: "";
|
|
591
|
+
dataType: "custom";
|
|
592
|
+
columnType: "SQLiteCustomColumn";
|
|
593
|
+
data: string;
|
|
594
|
+
driverParam: number;
|
|
595
|
+
enumValues: undefined;
|
|
596
|
+
}>;
|
|
597
|
+
<TName extends string>(dbName: TName, fieldConfig: unknown): pg$1.SQLiteCustomColumnBuilder<{
|
|
598
|
+
name: TName;
|
|
599
|
+
dataType: "custom";
|
|
600
|
+
columnType: "SQLiteCustomColumn";
|
|
601
|
+
data: string;
|
|
602
|
+
driverParam: number;
|
|
603
|
+
enumValues: undefined;
|
|
604
|
+
}>;
|
|
605
|
+
};
|
|
606
|
+
}
|
|
607
|
+
type SchemaToSqliteBuilder<T extends TObject> = { [key in keyof T["properties"]]: SQLiteColumnBuilderBase };
|
|
608
|
+
//#endregion
|
|
609
|
+
//#region ../../src/orm/providers/drivers/NodeSqliteProvider.d.ts
|
|
227
610
|
/**
|
|
228
|
-
*
|
|
611
|
+
* Configuration options for the Node.js SQLite database provider.
|
|
229
612
|
*/
|
|
230
|
-
declare const
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
type
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
[PG_UPDATED_AT]: {};
|
|
239
|
-
[PG_DELETED_AT]: {};
|
|
240
|
-
[PG_VERSION]: {};
|
|
241
|
-
[PG_IDENTITY]: PgIdentityOptions;
|
|
242
|
-
[PG_REF]: PgRefOptions;
|
|
243
|
-
[PG_ENUM]: PgEnumOptions;
|
|
244
|
-
/**
|
|
245
|
-
* @deprecated Use `PG_IDENTITY` instead.
|
|
246
|
-
*/
|
|
247
|
-
[PG_SERIAL]: {};
|
|
248
|
-
};
|
|
249
|
-
type PgSymbolKeys = keyof PgSymbols;
|
|
250
|
-
type PgIdentityOptions = {
|
|
251
|
-
mode: "always" | "byDefault";
|
|
252
|
-
} & PgSequenceOptions & {
|
|
253
|
-
name?: string;
|
|
254
|
-
};
|
|
255
|
-
interface PgEnumOptions {
|
|
256
|
-
name?: string;
|
|
257
|
-
description?: string;
|
|
613
|
+
declare const nodeSqliteOptions: alepha26.Atom<alepha26.TObject<{
|
|
614
|
+
path: alepha26.TOptional<alepha26.TString>;
|
|
615
|
+
}>, "alepha.postgres.node-sqlite.options">;
|
|
616
|
+
type NodeSqliteProviderOptions = Static<typeof nodeSqliteOptions.schema>;
|
|
617
|
+
declare module "alepha" {
|
|
618
|
+
interface State {
|
|
619
|
+
[nodeSqliteOptions.key]: NodeSqliteProviderOptions;
|
|
620
|
+
}
|
|
258
621
|
}
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
622
|
+
/**
|
|
623
|
+
* Add a fake support for SQLite in Node.js based on Postgres interfaces.
|
|
624
|
+
*
|
|
625
|
+
* This is NOT a real SQLite provider, it's a workaround to use SQLite with Drizzle ORM.
|
|
626
|
+
* This is NOT recommended for production use.
|
|
627
|
+
*/
|
|
628
|
+
declare class NodeSqliteProvider extends DatabaseProvider {
|
|
629
|
+
protected readonly kit: DrizzleKitProvider;
|
|
630
|
+
protected readonly log: alepha_logger4.Logger;
|
|
631
|
+
protected readonly env: {
|
|
632
|
+
DATABASE_URL?: string | undefined;
|
|
267
633
|
};
|
|
634
|
+
protected readonly builder: SqliteModelBuilder;
|
|
635
|
+
protected readonly options: Readonly<{
|
|
636
|
+
path?: string | undefined;
|
|
637
|
+
}>;
|
|
638
|
+
protected sqlite: DatabaseSync;
|
|
639
|
+
get name(): string;
|
|
640
|
+
readonly dialect = "sqlite";
|
|
641
|
+
get url(): string;
|
|
642
|
+
execute(query: SQLLike): Promise<Array<Record<string, unknown>>>;
|
|
643
|
+
readonly db: PgDatabase<any>;
|
|
644
|
+
protected readonly onStart: alepha26.HookPrimitive<"start">;
|
|
645
|
+
protected executeMigrations(migrationsFolder: string): Promise<void>;
|
|
268
646
|
}
|
|
269
647
|
//#endregion
|
|
270
648
|
//#region ../../src/orm/errors/DbError.d.ts
|
|
@@ -306,416 +684,416 @@ declare class DbEntityNotFoundError extends DbError {
|
|
|
306
684
|
//#region ../../src/orm/interfaces/FilterOperators.d.ts
|
|
307
685
|
interface FilterOperators<TValue> {
|
|
308
686
|
/**
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
687
|
+
* Test that two values are equal.
|
|
688
|
+
*
|
|
689
|
+
* Remember that the SQL standard dictates that
|
|
690
|
+
* two NULL values are not equal, so if you want to test
|
|
691
|
+
* whether a value is null, you may want to use
|
|
692
|
+
* `isNull` instead.
|
|
693
|
+
*
|
|
694
|
+
* ## Examples
|
|
695
|
+
*
|
|
696
|
+
* ```ts
|
|
697
|
+
* // Select cars made by Ford
|
|
698
|
+
* db.select().from(cars)
|
|
699
|
+
* .where(eq(cars.make, 'Ford'))
|
|
700
|
+
* ```
|
|
701
|
+
*
|
|
702
|
+
* @see isNull for a way to test equality to NULL.
|
|
703
|
+
*/
|
|
326
704
|
eq?: TValue;
|
|
327
705
|
/**
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
706
|
+
* Test that two values are not equal.
|
|
707
|
+
*
|
|
708
|
+
* Remember that the SQL standard dictates that
|
|
709
|
+
* two NULL values are not equal, so if you want to test
|
|
710
|
+
* whether a value is not null, you may want to use
|
|
711
|
+
* `isNotNull` instead.
|
|
712
|
+
*
|
|
713
|
+
* ## Examples
|
|
714
|
+
*
|
|
715
|
+
* ```ts
|
|
716
|
+
* // Select cars not made by Ford
|
|
717
|
+
* db.select().from(cars)
|
|
718
|
+
* .where(ne(cars.make, 'Ford'))
|
|
719
|
+
* ```
|
|
720
|
+
*
|
|
721
|
+
* @see isNotNull for a way to test whether a value is not null.
|
|
722
|
+
*/
|
|
345
723
|
ne?: TValue;
|
|
346
724
|
/**
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
725
|
+
* Test that the first expression passed is greater than
|
|
726
|
+
* the second expression.
|
|
727
|
+
*
|
|
728
|
+
* ## Examples
|
|
729
|
+
*
|
|
730
|
+
* ```ts
|
|
731
|
+
* // Select cars made after 2000.
|
|
732
|
+
* db.select().from(cars)
|
|
733
|
+
* .where(gt(cars.year, 2000))
|
|
734
|
+
* ```
|
|
735
|
+
*
|
|
736
|
+
* @see gte for greater-than-or-equal
|
|
737
|
+
*/
|
|
360
738
|
gt?: TValue;
|
|
361
739
|
/**
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
740
|
+
* Test that the first expression passed is greater than
|
|
741
|
+
* or equal to the second expression. Use `gt` to
|
|
742
|
+
* test whether an expression is strictly greater
|
|
743
|
+
* than another.
|
|
744
|
+
*
|
|
745
|
+
* ## Examples
|
|
746
|
+
*
|
|
747
|
+
* ```ts
|
|
748
|
+
* // Select cars made on or after 2000.
|
|
749
|
+
* db.select().from(cars)
|
|
750
|
+
* .where(gte(cars.year, 2000))
|
|
751
|
+
* ```
|
|
752
|
+
*
|
|
753
|
+
* @see gt for a strictly greater-than condition
|
|
754
|
+
*/
|
|
377
755
|
gte?: TValue;
|
|
378
756
|
/**
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
757
|
+
* Test that the first expression passed is less than
|
|
758
|
+
* the second expression.
|
|
759
|
+
*
|
|
760
|
+
* ## Examples
|
|
761
|
+
*
|
|
762
|
+
* ```ts
|
|
763
|
+
* // Select cars made before 2000.
|
|
764
|
+
* db.select().from(cars)
|
|
765
|
+
* .where(lt(cars.year, 2000))
|
|
766
|
+
* ```
|
|
767
|
+
*
|
|
768
|
+
* @see lte for greater-than-or-equal
|
|
769
|
+
*/
|
|
392
770
|
lt?: TValue;
|
|
393
771
|
/**
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
772
|
+
* Test that the first expression passed is less than
|
|
773
|
+
* or equal to the second expression.
|
|
774
|
+
*
|
|
775
|
+
* ## Examples
|
|
776
|
+
*
|
|
777
|
+
* ```ts
|
|
778
|
+
* // Select cars made before 2000.
|
|
779
|
+
* db.select().from(cars)
|
|
780
|
+
* .where(lte(cars.year, 2000))
|
|
781
|
+
* ```
|
|
782
|
+
*
|
|
783
|
+
* @see lt for a strictly less-than condition
|
|
784
|
+
*/
|
|
407
785
|
lte?: TValue;
|
|
408
786
|
/**
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
787
|
+
* Test whether the first parameter, a column or expression,
|
|
788
|
+
* has a value from a list passed as the second argument.
|
|
789
|
+
*
|
|
790
|
+
* ## Throws
|
|
791
|
+
*
|
|
792
|
+
* The argument passed in the second array can't be empty:
|
|
793
|
+
* if an empty is provided, this method will throw.
|
|
794
|
+
*
|
|
795
|
+
* ## Examples
|
|
796
|
+
*
|
|
797
|
+
* ```ts
|
|
798
|
+
* // Select cars made by Ford or GM.
|
|
799
|
+
* db.select().from(cars)
|
|
800
|
+
* .where(inArray(cars.make, ['Ford', 'GM']))
|
|
801
|
+
* ```
|
|
802
|
+
*
|
|
803
|
+
* @see notInArray for the inverse of this test
|
|
804
|
+
*/
|
|
427
805
|
inArray?: TValue[];
|
|
428
806
|
/**
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
807
|
+
* Test whether the first parameter, a column or expression,
|
|
808
|
+
* has a value that is not present in a list passed as the
|
|
809
|
+
* second argument.
|
|
810
|
+
*
|
|
811
|
+
* ## Throws
|
|
812
|
+
*
|
|
813
|
+
* The argument passed in the second array can't be empty:
|
|
814
|
+
* if an empty is provided, this method will throw.
|
|
815
|
+
*
|
|
816
|
+
* ## Examples
|
|
817
|
+
*
|
|
818
|
+
* ```ts
|
|
819
|
+
* // Select cars made by any company except Ford or GM.
|
|
820
|
+
* db.select().from(cars)
|
|
821
|
+
* .where(notInArray(cars.make, ['Ford', 'GM']))
|
|
822
|
+
* ```
|
|
823
|
+
*
|
|
824
|
+
* @see inArray for the inverse of this test
|
|
825
|
+
*/
|
|
448
826
|
notInArray?: TValue[];
|
|
449
827
|
/**
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
828
|
+
* Test whether an expression is not NULL. By the SQL standard,
|
|
829
|
+
* NULL is neither equal nor not equal to itself, so
|
|
830
|
+
* it's recommended to use `isNull` and `notIsNull` for
|
|
831
|
+
* comparisons to NULL.
|
|
832
|
+
*
|
|
833
|
+
* ## Examples
|
|
834
|
+
*
|
|
835
|
+
* ```ts
|
|
836
|
+
* // Select cars that have been discontinued.
|
|
837
|
+
* db.select().from(cars)
|
|
838
|
+
* .where(isNotNull(cars.discontinuedAt))
|
|
839
|
+
* ```
|
|
840
|
+
*
|
|
841
|
+
* @see isNull for the inverse of this test
|
|
842
|
+
*/
|
|
465
843
|
isNotNull?: true;
|
|
466
844
|
/**
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
845
|
+
* Test whether an expression is NULL. By the SQL standard,
|
|
846
|
+
* NULL is neither equal nor not equal to itself, so
|
|
847
|
+
* it's recommended to use `isNull` and `notIsNull` for
|
|
848
|
+
* comparisons to NULL.
|
|
849
|
+
*
|
|
850
|
+
* ## Examples
|
|
851
|
+
*
|
|
852
|
+
* ```ts
|
|
853
|
+
* // Select cars that have no discontinuedAt date.
|
|
854
|
+
* db.select().from(cars)
|
|
855
|
+
* .where(isNull(cars.discontinuedAt))
|
|
856
|
+
* ```
|
|
857
|
+
*
|
|
858
|
+
* @see isNotNull for the inverse of this test
|
|
859
|
+
*/
|
|
482
860
|
isNull?: true;
|
|
483
861
|
/**
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
862
|
+
* Test whether an expression is between two values. This
|
|
863
|
+
* is an easier way to express range tests, which would be
|
|
864
|
+
* expressed mathematically as `x <= a <= y` but in SQL
|
|
865
|
+
* would have to be like `a >= x AND a <= y`.
|
|
866
|
+
*
|
|
867
|
+
* Between is inclusive of the endpoints: if `column`
|
|
868
|
+
* is equal to `min` or `max`, it will be TRUE.
|
|
869
|
+
*
|
|
870
|
+
* ## Examples
|
|
871
|
+
*
|
|
872
|
+
* ```ts
|
|
873
|
+
* // Select cars made between 1990 and 2000
|
|
874
|
+
* db.select().from(cars)
|
|
875
|
+
* .where(between(cars.year, 1990, 2000))
|
|
876
|
+
* ```
|
|
877
|
+
*
|
|
878
|
+
* @see notBetween for the inverse of this test
|
|
879
|
+
*/
|
|
502
880
|
between?: [number, number];
|
|
503
881
|
/**
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
882
|
+
* Test whether an expression is not between two values.
|
|
883
|
+
*
|
|
884
|
+
* This, like `between`, includes its endpoints, so if
|
|
885
|
+
* the `column` is equal to `min` or `max`, in this case
|
|
886
|
+
* it will evaluate to FALSE.
|
|
887
|
+
*
|
|
888
|
+
* ## Examples
|
|
889
|
+
*
|
|
890
|
+
* ```ts
|
|
891
|
+
* // Exclude cars made in the 1970s
|
|
892
|
+
* db.select().from(cars)
|
|
893
|
+
* .where(notBetween(cars.year, 1970, 1979))
|
|
894
|
+
* ```
|
|
895
|
+
*
|
|
896
|
+
* @see between for the inverse of this test
|
|
897
|
+
*/
|
|
520
898
|
notBetween?: [number, number];
|
|
521
899
|
/**
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
900
|
+
* Compare a column to a pattern, which can include `%` and `_`
|
|
901
|
+
* characters to match multiple variations. Including `%`
|
|
902
|
+
* in the pattern matches zero or more characters, and including
|
|
903
|
+
* `_` will match a single character.
|
|
904
|
+
*
|
|
905
|
+
* ## Examples
|
|
906
|
+
*
|
|
907
|
+
* ```ts
|
|
908
|
+
* // Select all cars with 'Turbo' in their names.
|
|
909
|
+
* db.select().from(cars)
|
|
910
|
+
* .where(like(cars.name, '%Turbo%'))
|
|
911
|
+
* ```
|
|
912
|
+
*
|
|
913
|
+
* @see ilike for a case-insensitive version of this condition
|
|
914
|
+
*/
|
|
537
915
|
like?: string;
|
|
538
916
|
/**
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
917
|
+
* The inverse of like - this tests that a given column
|
|
918
|
+
* does not match a pattern, which can include `%` and `_`
|
|
919
|
+
* characters to match multiple variations. Including `%`
|
|
920
|
+
* in the pattern matches zero or more characters, and including
|
|
921
|
+
* `_` will match a single character.
|
|
922
|
+
*
|
|
923
|
+
* ## Examples
|
|
924
|
+
*
|
|
925
|
+
* ```ts
|
|
926
|
+
* // Select all cars that don't have "ROver" in their name.
|
|
927
|
+
* db.select().from(cars)
|
|
928
|
+
* .where(notLike(cars.name, '%Rover%'))
|
|
929
|
+
* ```
|
|
930
|
+
*
|
|
931
|
+
* @see like for the inverse condition
|
|
932
|
+
* @see notIlike for a case-insensitive version of this condition
|
|
933
|
+
*/
|
|
556
934
|
notLike?: string;
|
|
557
935
|
/**
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
936
|
+
* Case-insensitively compare a column to a pattern,
|
|
937
|
+
* which can include `%` and `_`
|
|
938
|
+
* characters to match multiple variations. Including `%`
|
|
939
|
+
* in the pattern matches zero or more characters, and including
|
|
940
|
+
* `_` will match a single character.
|
|
941
|
+
*
|
|
942
|
+
* Unlike like, this performs a case-insensitive comparison.
|
|
943
|
+
*
|
|
944
|
+
* ## Examples
|
|
945
|
+
*
|
|
946
|
+
* ```ts
|
|
947
|
+
* // Select all cars with 'Turbo' in their names.
|
|
948
|
+
* db.select().from(cars)
|
|
949
|
+
* .where(ilike(cars.name, '%Turbo%'))
|
|
950
|
+
* ```
|
|
951
|
+
*
|
|
952
|
+
* @see like for a case-sensitive version of this condition
|
|
953
|
+
*/
|
|
576
954
|
ilike?: string;
|
|
577
955
|
/**
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
956
|
+
* The inverse of ilike - this case-insensitively tests that a given column
|
|
957
|
+
* does not match a pattern, which can include `%` and `_`
|
|
958
|
+
* characters to match multiple variations. Including `%`
|
|
959
|
+
* in the pattern matches zero or more characters, and including
|
|
960
|
+
* `_` will match a single character.
|
|
961
|
+
*
|
|
962
|
+
* ## Examples
|
|
963
|
+
*
|
|
964
|
+
* ```ts
|
|
965
|
+
* // Select all cars that don't have "Rover" in their name.
|
|
966
|
+
* db.select().from(cars)
|
|
967
|
+
* .where(notLike(cars.name, '%Rover%'))
|
|
968
|
+
* ```
|
|
969
|
+
*
|
|
970
|
+
* @see ilike for the inverse condition
|
|
971
|
+
* @see notLike for a case-sensitive version of this condition
|
|
972
|
+
*/
|
|
595
973
|
notIlike?: string;
|
|
596
974
|
/**
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
975
|
+
* Syntactic sugar for case-insensitive substring matching.
|
|
976
|
+
* Automatically wraps the value with `%` wildcards on both sides.
|
|
977
|
+
*
|
|
978
|
+
* Equivalent to: `ilike: '%value%'`
|
|
979
|
+
*
|
|
980
|
+
* ## Examples
|
|
981
|
+
*
|
|
982
|
+
* ```ts
|
|
983
|
+
* // Select all cars with "Turbo" anywhere in their name.
|
|
984
|
+
* db.select().from(cars)
|
|
985
|
+
* .where({ name: { contains: 'Turbo' } })
|
|
986
|
+
* // Same as: .where(ilike(cars.name, '%Turbo%'))
|
|
987
|
+
* ```
|
|
988
|
+
*
|
|
989
|
+
* @see ilike for manual pattern matching
|
|
990
|
+
* @see startsWith for prefix matching
|
|
991
|
+
* @see endsWith for suffix matching
|
|
992
|
+
*/
|
|
615
993
|
contains?: string;
|
|
616
994
|
/**
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
995
|
+
* Syntactic sugar for case-insensitive prefix matching.
|
|
996
|
+
* Automatically appends a `%` wildcard to the end of the value.
|
|
997
|
+
*
|
|
998
|
+
* Equivalent to: `ilike: 'value%'`
|
|
999
|
+
*
|
|
1000
|
+
* ## Examples
|
|
1001
|
+
*
|
|
1002
|
+
* ```ts
|
|
1003
|
+
* // Select all cars whose names start with "Ford".
|
|
1004
|
+
* db.select().from(cars)
|
|
1005
|
+
* .where({ name: { startsWith: 'Ford' } })
|
|
1006
|
+
* // Same as: .where(ilike(cars.name, 'Ford%'))
|
|
1007
|
+
* ```
|
|
1008
|
+
*
|
|
1009
|
+
* @see ilike for manual pattern matching
|
|
1010
|
+
* @see contains for substring matching
|
|
1011
|
+
* @see endsWith for suffix matching
|
|
1012
|
+
*/
|
|
635
1013
|
startsWith?: string;
|
|
636
1014
|
/**
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
1015
|
+
* Syntactic sugar for case-insensitive suffix matching.
|
|
1016
|
+
* Automatically prepends a `%` wildcard to the beginning of the value.
|
|
1017
|
+
*
|
|
1018
|
+
* Equivalent to: `ilike: '%value'`
|
|
1019
|
+
*
|
|
1020
|
+
* ## Examples
|
|
1021
|
+
*
|
|
1022
|
+
* ```ts
|
|
1023
|
+
* // Select all cars whose names end with "Turbo".
|
|
1024
|
+
* db.select().from(cars)
|
|
1025
|
+
* .where({ name: { endsWith: 'Turbo' } })
|
|
1026
|
+
* // Same as: .where(ilike(cars.name, '%Turbo'))
|
|
1027
|
+
* ```
|
|
1028
|
+
*
|
|
1029
|
+
* @see ilike for manual pattern matching
|
|
1030
|
+
* @see contains for substring matching
|
|
1031
|
+
* @see startsWith for prefix matching
|
|
1032
|
+
*/
|
|
655
1033
|
endsWith?: string;
|
|
656
1034
|
/**
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
1035
|
+
* Test that a column or expression contains all elements of
|
|
1036
|
+
* the list passed as the second argument.
|
|
1037
|
+
*
|
|
1038
|
+
* ## Throws
|
|
1039
|
+
*
|
|
1040
|
+
* The argument passed in the second array can't be empty:
|
|
1041
|
+
* if an empty is provided, this method will throw.
|
|
1042
|
+
*
|
|
1043
|
+
* ## Examples
|
|
1044
|
+
*
|
|
1045
|
+
* ```ts
|
|
1046
|
+
* // Select posts where its tags contain "Typescript" and "ORM".
|
|
1047
|
+
* db.select().from(posts)
|
|
1048
|
+
* .where(arrayContains(posts.tags, ['Typescript', 'ORM']))
|
|
1049
|
+
* ```
|
|
1050
|
+
*
|
|
1051
|
+
* @see arrayContained to find if an array contains all elements of a column or expression
|
|
1052
|
+
* @see arrayOverlaps to find if a column or expression contains any elements of an array
|
|
1053
|
+
*/
|
|
676
1054
|
arrayContains?: TValue;
|
|
677
1055
|
/**
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
1056
|
+
* Test that the list passed as the second argument contains
|
|
1057
|
+
* all elements of a column or expression.
|
|
1058
|
+
*
|
|
1059
|
+
* ## Throws
|
|
1060
|
+
*
|
|
1061
|
+
* The argument passed in the second array can't be empty:
|
|
1062
|
+
* if an empty is provided, this method will throw.
|
|
1063
|
+
*
|
|
1064
|
+
* ## Examples
|
|
1065
|
+
*
|
|
1066
|
+
* ```ts
|
|
1067
|
+
* // Select posts where its tags contain "Typescript", "ORM" or both,
|
|
1068
|
+
* // but filtering posts that have additional tags.
|
|
1069
|
+
* db.select().from(posts)
|
|
1070
|
+
* .where(arrayContained(posts.tags, ['Typescript', 'ORM']))
|
|
1071
|
+
* ```
|
|
1072
|
+
*
|
|
1073
|
+
* @see arrayContains to find if a column or expression contains all elements of an array
|
|
1074
|
+
* @see arrayOverlaps to find if a column or expression contains any elements of an array
|
|
1075
|
+
*/
|
|
698
1076
|
arrayContained?: TValue;
|
|
699
1077
|
/**
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
1078
|
+
* Test that a column or expression contains any elements of
|
|
1079
|
+
* the list passed as the second argument.
|
|
1080
|
+
*
|
|
1081
|
+
* ## Throws
|
|
1082
|
+
*
|
|
1083
|
+
* The argument passed in the second array can't be empty:
|
|
1084
|
+
* if an empty is provided, this method will throw.
|
|
1085
|
+
*
|
|
1086
|
+
* ## Examples
|
|
1087
|
+
*
|
|
1088
|
+
* ```ts
|
|
1089
|
+
* // Select posts where its tags contain "Typescript", "ORM" or both.
|
|
1090
|
+
* db.select().from(posts)
|
|
1091
|
+
* .where(arrayOverlaps(posts.tags, ['Typescript', 'ORM']))
|
|
1092
|
+
* ```
|
|
1093
|
+
*
|
|
1094
|
+
* @see arrayContains to find if a column or expression contains all elements of an array
|
|
1095
|
+
* @see arrayContained to find if an array contains all elements of a column or expression
|
|
1096
|
+
*/
|
|
719
1097
|
arrayOverlaps?: TValue;
|
|
720
1098
|
}
|
|
721
1099
|
//#endregion
|
|
@@ -774,71 +1152,71 @@ type PgQueryWhereOrSQL<T extends TObject, Relations extends PgRelationMap<TObjec
|
|
|
774
1152
|
type PgQueryWhereOperators<T extends TObject> = { [Key in keyof Static<T>]?: FilterOperators<Static<T>[Key]> | Static<T>[Key] };
|
|
775
1153
|
type PgQueryWhereConditions<T extends TObject, Relations extends PgRelationMap<TObject> | undefined = undefined> = {
|
|
776
1154
|
/**
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
1155
|
+
* Combine a list of conditions with the `and` operator. Conditions
|
|
1156
|
+
* that are equal `undefined` are automatically ignored.
|
|
1157
|
+
*
|
|
1158
|
+
* ## Examples
|
|
1159
|
+
*
|
|
1160
|
+
* ```ts
|
|
1161
|
+
* db.select().from(cars)
|
|
1162
|
+
* .where(
|
|
1163
|
+
* and(
|
|
1164
|
+
* eq(cars.make, 'Volvo'),
|
|
1165
|
+
* eq(cars.year, 1950),
|
|
1166
|
+
* )
|
|
1167
|
+
* )
|
|
1168
|
+
* ```
|
|
1169
|
+
*/
|
|
792
1170
|
and?: Array<PgQueryWhereOrSQL<T, Relations>>;
|
|
793
1171
|
/**
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
1172
|
+
* Combine a list of conditions with the `or` operator. Conditions
|
|
1173
|
+
* that are equal `undefined` are automatically ignored.
|
|
1174
|
+
*
|
|
1175
|
+
* ## Examples
|
|
1176
|
+
*
|
|
1177
|
+
* ```ts
|
|
1178
|
+
* db.select().from(cars)
|
|
1179
|
+
* .where(
|
|
1180
|
+
* or(
|
|
1181
|
+
* eq(cars.make, 'GM'),
|
|
1182
|
+
* eq(cars.make, 'Ford'),
|
|
1183
|
+
* )
|
|
1184
|
+
* )
|
|
1185
|
+
* ```
|
|
1186
|
+
*/
|
|
809
1187
|
or?: Array<PgQueryWhereOrSQL<T, Relations>>;
|
|
810
1188
|
/**
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
1189
|
+
* Negate the meaning of an expression using the `not` keyword.
|
|
1190
|
+
*
|
|
1191
|
+
* ## Examples
|
|
1192
|
+
*
|
|
1193
|
+
* ```ts
|
|
1194
|
+
* // Select cars _not_ made by GM or Ford.
|
|
1195
|
+
* db.select().from(cars)
|
|
1196
|
+
* .where(not(inArray(cars.make, ['GM', 'Ford'])))
|
|
1197
|
+
* ```
|
|
1198
|
+
*/
|
|
821
1199
|
not?: PgQueryWhereOrSQL<T, Relations>;
|
|
822
1200
|
/**
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
1201
|
+
* Test whether a subquery evaluates to have any rows.
|
|
1202
|
+
*
|
|
1203
|
+
* ## Examples
|
|
1204
|
+
*
|
|
1205
|
+
* ```ts
|
|
1206
|
+
* // Users whose `homeCity` column has a match in a cities
|
|
1207
|
+
* // table.
|
|
1208
|
+
* db
|
|
1209
|
+
* .select()
|
|
1210
|
+
* .from(users)
|
|
1211
|
+
* .where(
|
|
1212
|
+
* exists(db.select()
|
|
1213
|
+
* .from(cities)
|
|
1214
|
+
* .where(eq(users.homeCity, cities.id))),
|
|
1215
|
+
* );
|
|
1216
|
+
* ```
|
|
1217
|
+
*
|
|
1218
|
+
* @see notExists for the inverse of this test
|
|
1219
|
+
*/
|
|
842
1220
|
exists?: SQLWrapper;
|
|
843
1221
|
};
|
|
844
1222
|
type PgQueryWhereRelations<Relations extends PgRelationMap<TObject> | undefined = undefined> = Relations extends PgRelationMap<TObject> ? { [K in keyof Relations]?: PgQueryWhere<Relations[K]["join"]["schema"], Relations[K]["with"]> } : {};
|
|
@@ -943,307 +1321,122 @@ interface PgAttrField {
|
|
|
943
1321
|
one?: boolean;
|
|
944
1322
|
}
|
|
945
1323
|
//#endregion
|
|
946
|
-
//#region ../../src/orm/providers/DatabaseTypeProvider.d.ts
|
|
947
|
-
declare class DatabaseTypeProvider {
|
|
948
|
-
readonly attr: <T extends TSchema, Attr extends PgSymbolKeys>(type: T, attr: Attr, value?: PgSymbols[Attr]) => PgAttr<T, Attr>;
|
|
949
|
-
/**
|
|
950
|
-
* Creates a primary key with an identity column.
|
|
951
|
-
*/
|
|
952
|
-
readonly identityPrimaryKey: (identity?: PgIdentityOptions, options?: TNumberOptions) => PgAttr<PgAttr<PgAttr<TInteger, typeof PG_PRIMARY_KEY>, typeof PG_IDENTITY>, typeof PG_DEFAULT>;
|
|
953
|
-
/**
|
|
954
|
-
* Creates a primary key with a big identity column. (default)
|
|
955
|
-
*/
|
|
956
|
-
readonly bigIdentityPrimaryKey: (identity?: PgIdentityOptions, options?: TNumberOptions) => PgAttr<PgAttr<PgAttr<TNumber, typeof PG_PRIMARY_KEY>, typeof PG_IDENTITY>, typeof PG_DEFAULT>;
|
|
957
|
-
/**
|
|
958
|
-
* Creates a primary key with a UUID column.
|
|
959
|
-
*/
|
|
960
|
-
readonly uuidPrimaryKey: () => PgAttr<PgAttr<TString, typeof PG_PRIMARY_KEY>, typeof PG_DEFAULT>;
|
|
961
|
-
/**
|
|
962
|
-
* Creates a primary key for a given type. Supports:
|
|
963
|
-
* - `t.integer()` -> PG INT (default)
|
|
964
|
-
* - `t.bigint()` -> PG BIGINT
|
|
965
|
-
* - `t.uuid()` -> PG UUID
|
|
966
|
-
*/
|
|
967
|
-
primaryKey(): PgAttr<PgAttr<TInteger, PgPrimaryKey>, PgDefault>;
|
|
968
|
-
primaryKey(type: TString, options?: TStringOptions): PgAttr<PgAttr<TString, PgPrimaryKey>, PgDefault>;
|
|
969
|
-
primaryKey(type: TInteger, options?: TNumberOptions, identity?: PgIdentityOptions): PgAttr<PgAttr<TInteger, PgPrimaryKey>, PgDefault>;
|
|
970
|
-
primaryKey(type: TNumber, options?: TNumberOptions, identity?: PgIdentityOptions): PgAttr<PgAttr<TNumber, PgPrimaryKey>, PgDefault>;
|
|
971
|
-
primaryKey(type: TBigInt, options?: TNumberOptions, identity?: PgIdentityOptions): PgAttr<PgAttr<TBigInt, PgPrimaryKey>, PgDefault>;
|
|
972
|
-
/**
|
|
973
|
-
* Wrap a schema with "default" attribute.
|
|
974
|
-
* This is used to set a default value for a column in the database.
|
|
975
|
-
*/
|
|
976
|
-
readonly default: <T extends TSchema>(type: T, value?: Static<T>) => PgAttr<T, PgDefault>;
|
|
977
|
-
/**
|
|
978
|
-
* Creates a column 'version'.
|
|
979
|
-
*
|
|
980
|
-
* This is used to track the version of a row in the database.
|
|
981
|
-
*
|
|
982
|
-
* You can use it for optimistic concurrency control (OCC) with {@link RepositoryPrimitive#save}.
|
|
983
|
-
*
|
|
984
|
-
* @see {@link RepositoryPrimitive#save}
|
|
985
|
-
* @see {@link PgVersionMismatchError}
|
|
986
|
-
*/
|
|
987
|
-
readonly version: (options?: TNumberOptions) => PgAttr<PgAttr<TInteger, typeof PG_VERSION>, typeof PG_DEFAULT>;
|
|
988
|
-
/**
|
|
989
|
-
* Creates a column Created At. So just a datetime column with a default value of the current timestamp.
|
|
990
|
-
*/
|
|
991
|
-
readonly createdAt: (options?: TStringOptions) => PgAttr<PgAttr<TString, typeof PG_CREATED_AT>, typeof PG_DEFAULT>;
|
|
992
|
-
/**
|
|
993
|
-
* Creates a column Updated At. Like createdAt, but it is updated on every update of the row.
|
|
994
|
-
*/
|
|
995
|
-
readonly updatedAt: (options?: TStringOptions) => PgAttr<PgAttr<TString, typeof PG_UPDATED_AT>, typeof PG_DEFAULT>;
|
|
996
|
-
/**
|
|
997
|
-
* Creates a column Deleted At for soft delete functionality.
|
|
998
|
-
* This is used to mark rows as deleted without actually removing them from the database.
|
|
999
|
-
* The column is nullable - NULL means not deleted, timestamp means deleted.
|
|
1000
|
-
*/
|
|
1001
|
-
readonly deletedAt: (options?: TStringOptions) => PgAttr<alepha34.TOptional<TString>, typeof PG_DELETED_AT>;
|
|
1002
|
-
/**
|
|
1003
|
-
* Creates a Postgres ENUM type.
|
|
1004
|
-
*
|
|
1005
|
-
* > By default, `t.enum()` is mapped to a TEXT column in Postgres.
|
|
1006
|
-
* > Using this method, you can create a real ENUM type in the database.
|
|
1007
|
-
*
|
|
1008
|
-
* @example
|
|
1009
|
-
* ```ts
|
|
1010
|
-
* const statusEnum = pg.enum(["pending", "active", "archived"], { name: "status_enum" });
|
|
1011
|
-
* ```
|
|
1012
|
-
*/
|
|
1013
|
-
readonly enum: <T extends string[]>(values: [...T], pgEnumOptions?: PgEnumOptions, typeOptions?: TStringOptions) => PgAttr<TUnsafe<T[number]>, typeof PG_ENUM>;
|
|
1014
|
-
/**
|
|
1015
|
-
* Creates a reference to another table or schema. Basically a foreign key.
|
|
1016
|
-
*/
|
|
1017
|
-
readonly ref: <T extends TSchema>(type: T, ref: () => any, actions?: {
|
|
1018
|
-
onUpdate?: UpdateDeleteAction$1;
|
|
1019
|
-
onDelete?: UpdateDeleteAction$1;
|
|
1020
|
-
}) => PgAttr<T, PgRef>;
|
|
1021
|
-
/**
|
|
1022
|
-
* Creates a page schema for a given object schema.
|
|
1023
|
-
* It's used by {@link Repository#paginate} method.
|
|
1024
|
-
*/
|
|
1025
|
-
readonly page: <T extends TObject>(resource: T, options?: TObjectOptions) => TPage<T>;
|
|
1026
|
-
}
|
|
1027
|
-
/**
|
|
1028
|
-
* Wrapper of TypeProvider (`t`) for database types.
|
|
1029
|
-
*
|
|
1030
|
-
* Use `db` for improve TypeBox schema definitions with database-specific attributes.
|
|
1031
|
-
*
|
|
1032
|
-
* @example
|
|
1033
|
-
* ```ts
|
|
1034
|
-
* import { t } from "alepha";
|
|
1035
|
-
* import { db } from "alepha/orm";
|
|
1036
|
-
*
|
|
1037
|
-
* const userSchema = t.object({
|
|
1038
|
-
* id: db.primaryKey(t.uuid()),
|
|
1039
|
-
* email: t.email(),
|
|
1040
|
-
* createdAt: db.createdAt(),
|
|
1041
|
-
* });
|
|
1042
|
-
* ```
|
|
1043
|
-
*/
|
|
1044
|
-
declare const db: DatabaseTypeProvider;
|
|
1045
|
-
/**
|
|
1046
|
-
* @deprecated Use `db` instead.
|
|
1047
|
-
*/
|
|
1048
|
-
declare const pg: DatabaseTypeProvider;
|
|
1049
|
-
//#endregion
|
|
1050
|
-
//#region ../../src/orm/schemas/legacyIdSchema.d.ts
|
|
1051
|
-
/**
|
|
1052
|
-
* @deprecated Use `pg.primaryKey()` instead.
|
|
1053
|
-
*/
|
|
1054
|
-
declare const legacyIdSchema: PgAttr<PgAttr<PgAttr<alepha34.TInteger, typeof PG_PRIMARY_KEY>, typeof PG_SERIAL>, typeof PG_DEFAULT>;
|
|
1055
|
-
//#endregion
|
|
1056
|
-
//#region ../../src/orm/primitives/$sequence.d.ts
|
|
1057
|
-
/**
|
|
1058
|
-
* Creates a PostgreSQL sequence primitive for generating unique numeric values.
|
|
1059
|
-
*/
|
|
1060
|
-
declare const $sequence: {
|
|
1061
|
-
(options?: SequencePrimitiveOptions): SequencePrimitive;
|
|
1062
|
-
[KIND]: typeof SequencePrimitive;
|
|
1063
|
-
};
|
|
1064
|
-
interface SequencePrimitiveOptions extends PgSequenceOptions {
|
|
1065
|
-
/**
|
|
1066
|
-
* The name of the sequence. If not provided, the property key will be used.
|
|
1067
|
-
*/
|
|
1068
|
-
name?: string;
|
|
1069
|
-
provider?: DatabaseProvider;
|
|
1070
|
-
}
|
|
1071
|
-
declare class SequencePrimitive extends Primitive<SequencePrimitiveOptions> {
|
|
1072
|
-
readonly provider: DatabaseProvider;
|
|
1073
|
-
onInit(): void;
|
|
1074
|
-
get name(): string;
|
|
1075
|
-
next(): Promise<number>;
|
|
1076
|
-
current(): Promise<number>;
|
|
1077
|
-
protected $provider(): DatabaseProvider;
|
|
1078
|
-
}
|
|
1079
|
-
//#endregion
|
|
1080
|
-
//#region ../../src/orm/services/ModelBuilder.d.ts
|
|
1081
|
-
/**
|
|
1082
|
-
* Database-specific table configuration functions
|
|
1083
|
-
*/
|
|
1084
|
-
interface TableConfigBuilders<TConfig> {
|
|
1085
|
-
index: (name: string) => {
|
|
1086
|
-
on: (...columns: any[]) => TConfig;
|
|
1087
|
-
};
|
|
1088
|
-
uniqueIndex: (name: string) => {
|
|
1089
|
-
on: (...columns: any[]) => TConfig;
|
|
1090
|
-
};
|
|
1091
|
-
unique: (name: string) => {
|
|
1092
|
-
on: (...columns: any[]) => TConfig;
|
|
1093
|
-
};
|
|
1094
|
-
check: (name: string, sql: SQL) => TConfig;
|
|
1095
|
-
foreignKey: (config: {
|
|
1096
|
-
name: string;
|
|
1097
|
-
columns: any[];
|
|
1098
|
-
foreignColumns: any[];
|
|
1099
|
-
}) => TConfig;
|
|
1100
|
-
}
|
|
1101
|
-
/**
|
|
1102
|
-
* Abstract base class for transforming Alepha Primitives (Entity, Sequence, etc...)
|
|
1103
|
-
* into drizzle models (tables, enums, sequences, etc...).
|
|
1104
|
-
*/
|
|
1105
|
-
declare abstract class ModelBuilder {
|
|
1106
|
-
/**
|
|
1107
|
-
* Build a table from an entity primitive.
|
|
1108
|
-
*/
|
|
1109
|
-
abstract buildTable(entity: EntityPrimitive, options: {
|
|
1110
|
-
tables: Map<string, unknown>;
|
|
1111
|
-
enums: Map<string, unknown>;
|
|
1112
|
-
schema: string;
|
|
1113
|
-
}): void;
|
|
1114
|
-
/**
|
|
1115
|
-
* Build a sequence from a sequence primitive.
|
|
1116
|
-
*/
|
|
1117
|
-
abstract buildSequence(sequence: SequencePrimitive, options: {
|
|
1118
|
-
sequences: Map<string, unknown>;
|
|
1119
|
-
schema: string;
|
|
1120
|
-
}): void;
|
|
1121
|
-
/**
|
|
1122
|
-
* Convert camelCase to snake_case for column names.
|
|
1123
|
-
*/
|
|
1124
|
-
protected toColumnName(str: string): string;
|
|
1125
|
-
/**
|
|
1126
|
-
* Build the table configuration function for any database.
|
|
1127
|
-
* This includes indexes, foreign keys, constraints, and custom config.
|
|
1128
|
-
*
|
|
1129
|
-
* @param entity - The entity primitive
|
|
1130
|
-
* @param builders - Database-specific builder functions
|
|
1131
|
-
* @param tableResolver - Function to resolve entity references to table columns
|
|
1132
|
-
* @param customConfigHandler - Optional handler for custom config
|
|
1133
|
-
*/
|
|
1134
|
-
protected buildTableConfig<TConfig, TSelf>(entity: EntityPrimitive, builders: TableConfigBuilders<TConfig>, tableResolver?: (entityName: string) => any, customConfigHandler?: (config: any, self: TSelf) => TConfig[]): ((self: TSelf) => TConfig[]) | undefined;
|
|
1135
|
-
}
|
|
1136
|
-
//#endregion
|
|
1137
|
-
//#region ../../src/orm/providers/DrizzleKitProvider.d.ts
|
|
1138
|
-
declare class DrizzleKitProvider {
|
|
1139
|
-
protected readonly log: alepha_logger3.Logger;
|
|
1140
|
-
protected readonly alepha: Alepha;
|
|
1141
|
-
/**
|
|
1142
|
-
* Synchronize database with current schema definitions.
|
|
1143
|
-
*
|
|
1144
|
-
* In development mode, it will generate and execute migrations based on the current state.
|
|
1145
|
-
* In testing mode, it will generate migrations from scratch without applying them.
|
|
1146
|
-
*
|
|
1147
|
-
* Does nothing in production mode, you must handle migrations manually.
|
|
1148
|
-
*/
|
|
1149
|
-
synchronize(provider: DatabaseProvider): Promise<void>;
|
|
1150
|
-
/**
|
|
1151
|
-
* Mostly used for testing purposes. You can generate SQL migration statements without executing them.
|
|
1152
|
-
*/
|
|
1153
|
-
generateMigration(provider: DatabaseProvider, prevSnapshot?: any): Promise<{
|
|
1154
|
-
statements: string[];
|
|
1155
|
-
models: Record<string, unknown>;
|
|
1156
|
-
snapshot?: any;
|
|
1157
|
-
}>;
|
|
1158
|
-
/**
|
|
1159
|
-
* Load all tables, enums, sequences, etc. from the provider's repositories.
|
|
1160
|
-
*/
|
|
1161
|
-
getModels(provider: DatabaseProvider): Record<string, unknown>;
|
|
1162
|
-
/**
|
|
1163
|
-
* Load the migration snapshot from the database.
|
|
1164
|
-
*/
|
|
1165
|
-
protected loadDevMigrations(provider: DatabaseProvider): Promise<DevMigrations | undefined>;
|
|
1166
|
-
protected saveDevMigrations(provider: DatabaseProvider, curr: Record<string, any>, devMigrations?: DevMigrations): Promise<void>;
|
|
1167
|
-
protected executeStatements(statements: string[], provider: DatabaseProvider, catchErrors?: boolean): Promise<void>;
|
|
1168
|
-
protected createSchemaIfNotExists(provider: DatabaseProvider, schemaName: string): Promise<void>;
|
|
1169
|
-
/**
|
|
1170
|
-
* Try to load the official Drizzle Kit API.
|
|
1171
|
-
* If not available, fallback to the local kit import.
|
|
1172
|
-
*/
|
|
1173
|
-
importDrizzleKit(): typeof DrizzleKit;
|
|
1174
|
-
}
|
|
1175
|
-
declare const devMigrationsSchema: alepha34.TObject<{
|
|
1176
|
-
id: alepha34.TNumber;
|
|
1177
|
-
name: alepha34.TString;
|
|
1178
|
-
snapshot: alepha34.TString;
|
|
1179
|
-
created_at: alepha34.TString;
|
|
1180
|
-
}>;
|
|
1181
|
-
type DevMigrations = Static<typeof devMigrationsSchema>;
|
|
1182
|
-
//#endregion
|
|
1183
|
-
//#region ../../src/orm/providers/drivers/DatabaseProvider.d.ts
|
|
1184
|
-
type SQLLike = SQLWrapper | string;
|
|
1185
|
-
declare abstract class DatabaseProvider {
|
|
1186
|
-
protected readonly alepha: Alepha;
|
|
1187
|
-
protected readonly log: alepha_logger3.Logger;
|
|
1188
|
-
protected abstract readonly builder: ModelBuilder;
|
|
1189
|
-
protected abstract readonly kit: DrizzleKitProvider;
|
|
1190
|
-
abstract readonly db: PgDatabase<any>;
|
|
1191
|
-
abstract readonly dialect: "postgresql" | "sqlite";
|
|
1192
|
-
abstract readonly url: string;
|
|
1193
|
-
readonly enums: Map<string, unknown>;
|
|
1194
|
-
readonly tables: Map<string, unknown>;
|
|
1195
|
-
readonly sequences: Map<string, unknown>;
|
|
1196
|
-
get name(): string;
|
|
1197
|
-
get driver(): string;
|
|
1198
|
-
get schema(): string;
|
|
1199
|
-
table<T extends TObject>(entity: EntityPrimitive<T>): PgTableWithColumns<SchemaToTableConfig<T>>;
|
|
1200
|
-
registerEntity(entity: EntityPrimitive): void;
|
|
1201
|
-
registerSequence(sequence: SequencePrimitive): void;
|
|
1202
|
-
abstract execute(statement: SQLLike): Promise<Record<string, unknown>[]>;
|
|
1203
|
-
run<T extends TObject>(statement: SQLLike, schema: T): Promise<Array<Static<T>>>;
|
|
1324
|
+
//#region ../../src/orm/providers/DatabaseTypeProvider.d.ts
|
|
1325
|
+
declare class DatabaseTypeProvider {
|
|
1326
|
+
readonly attr: <T extends TSchema, Attr extends PgSymbolKeys>(type: T, attr: Attr, value?: PgSymbols[Attr]) => PgAttr<T, Attr>;
|
|
1204
1327
|
/**
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1328
|
+
* Creates a primary key with an identity column.
|
|
1329
|
+
*/
|
|
1330
|
+
readonly identityPrimaryKey: (identity?: PgIdentityOptions, options?: TNumberOptions) => PgAttr<PgAttr<PgAttr<TInteger, typeof PG_PRIMARY_KEY>, typeof PG_IDENTITY>, typeof PG_DEFAULT>;
|
|
1208
1331
|
/**
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1332
|
+
* Creates a primary key with a big identity column. (default)
|
|
1333
|
+
*/
|
|
1334
|
+
readonly bigIdentityPrimaryKey: (identity?: PgIdentityOptions, options?: TNumberOptions) => PgAttr<PgAttr<PgAttr<TNumber, typeof PG_PRIMARY_KEY>, typeof PG_IDENTITY>, typeof PG_DEFAULT>;
|
|
1212
1335
|
/**
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1336
|
+
* Creates a primary key with a UUID column.
|
|
1337
|
+
*/
|
|
1338
|
+
readonly uuidPrimaryKey: () => PgAttr<PgAttr<TString, typeof PG_PRIMARY_KEY>, typeof PG_DEFAULT>;
|
|
1216
1339
|
/**
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1340
|
+
* Creates a primary key for a given type. Supports:
|
|
1341
|
+
* - `t.integer()` -> PG INT (default)
|
|
1342
|
+
* - `t.bigint()` -> PG BIGINT
|
|
1343
|
+
* - `t.uuid()` -> PG UUID
|
|
1344
|
+
*/
|
|
1345
|
+
primaryKey(): PgAttr<PgAttr<TInteger, PgPrimaryKey>, PgDefault>;
|
|
1346
|
+
primaryKey(type: TString, options?: TStringOptions): PgAttr<PgAttr<TString, PgPrimaryKey>, PgDefault>;
|
|
1347
|
+
primaryKey(type: TInteger, options?: TNumberOptions, identity?: PgIdentityOptions): PgAttr<PgAttr<TInteger, PgPrimaryKey>, PgDefault>;
|
|
1348
|
+
primaryKey(type: TNumber, options?: TNumberOptions, identity?: PgIdentityOptions): PgAttr<PgAttr<TNumber, PgPrimaryKey>, PgDefault>;
|
|
1349
|
+
primaryKey(type: TBigInt, options?: TNumberOptions, identity?: PgIdentityOptions): PgAttr<PgAttr<TBigInt, PgPrimaryKey>, PgDefault>;
|
|
1220
1350
|
/**
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1351
|
+
* Wrap a schema with "default" attribute.
|
|
1352
|
+
* This is used to set a default value for a column in the database.
|
|
1353
|
+
*/
|
|
1354
|
+
readonly default: <T extends TSchema>(type: T, value?: Static<T>) => PgAttr<T, PgDefault>;
|
|
1224
1355
|
/**
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1356
|
+
* Creates a column 'version'.
|
|
1357
|
+
*
|
|
1358
|
+
* This is used to track the version of a row in the database.
|
|
1359
|
+
*
|
|
1360
|
+
* You can use it for optimistic concurrency control (OCC) with {@link RepositoryPrimitive#save}.
|
|
1361
|
+
*
|
|
1362
|
+
* @see {@link RepositoryPrimitive#save}
|
|
1363
|
+
* @see {@link PgVersionMismatchError}
|
|
1364
|
+
*/
|
|
1365
|
+
readonly version: (options?: TNumberOptions) => PgAttr<PgAttr<TInteger, typeof PG_VERSION>, typeof PG_DEFAULT>;
|
|
1228
1366
|
/**
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
protected abstract executeMigrations(migrationsFolder: string): Promise<void>;
|
|
1367
|
+
* Creates a column Created At. So just a datetime column with a default value of the current timestamp.
|
|
1368
|
+
*/
|
|
1369
|
+
readonly createdAt: (options?: TStringOptions) => PgAttr<PgAttr<TString, typeof PG_CREATED_AT>, typeof PG_DEFAULT>;
|
|
1233
1370
|
/**
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1371
|
+
* Creates a column Updated At. Like createdAt, but it is updated on every update of the row.
|
|
1372
|
+
*/
|
|
1373
|
+
readonly updatedAt: (options?: TStringOptions) => PgAttr<PgAttr<TString, typeof PG_UPDATED_AT>, typeof PG_DEFAULT>;
|
|
1374
|
+
/**
|
|
1375
|
+
* Creates a column Deleted At for soft delete functionality.
|
|
1376
|
+
* This is used to mark rows as deleted without actually removing them from the database.
|
|
1377
|
+
* The column is nullable - NULL means not deleted, timestamp means deleted.
|
|
1378
|
+
*/
|
|
1379
|
+
readonly deletedAt: (options?: TStringOptions) => PgAttr<alepha26.TOptional<TString>, typeof PG_DELETED_AT>;
|
|
1380
|
+
/**
|
|
1381
|
+
* Creates a Postgres ENUM type.
|
|
1382
|
+
*
|
|
1383
|
+
* > By default, `t.enum()` is mapped to a TEXT column in Postgres.
|
|
1384
|
+
* > Using this method, you can create a real ENUM type in the database.
|
|
1385
|
+
*
|
|
1386
|
+
* @example
|
|
1387
|
+
* ```ts
|
|
1388
|
+
* const statusEnum = pg.enum(["pending", "active", "archived"], { name: "status_enum" });
|
|
1389
|
+
* ```
|
|
1390
|
+
*/
|
|
1391
|
+
readonly enum: <T extends string[]>(values: [...T], pgEnumOptions?: PgEnumOptions, typeOptions?: TStringOptions) => PgAttr<TUnsafe<T[number]>, typeof PG_ENUM>;
|
|
1392
|
+
/**
|
|
1393
|
+
* Creates a reference to another table or schema. Basically a foreign key.
|
|
1394
|
+
*/
|
|
1395
|
+
readonly ref: <T extends TSchema>(type: T, ref: () => any, actions?: {
|
|
1396
|
+
onUpdate?: UpdateDeleteAction$1;
|
|
1397
|
+
onDelete?: UpdateDeleteAction$1;
|
|
1398
|
+
}) => PgAttr<T, PgRef>;
|
|
1399
|
+
/**
|
|
1400
|
+
* Creates a page schema for a given object schema.
|
|
1401
|
+
* It's used by {@link Repository#paginate} method.
|
|
1402
|
+
*/
|
|
1403
|
+
readonly page: <T extends TObject>(resource: T, options?: TObjectOptions) => TPage<T>;
|
|
1239
1404
|
}
|
|
1405
|
+
/**
|
|
1406
|
+
* Wrapper of TypeProvider (`t`) for database types.
|
|
1407
|
+
*
|
|
1408
|
+
* Use `db` for improve TypeBox schema definitions with database-specific attributes.
|
|
1409
|
+
*
|
|
1410
|
+
* @example
|
|
1411
|
+
* ```ts
|
|
1412
|
+
* import { t } from "alepha";
|
|
1413
|
+
* import { db } from "alepha/orm";
|
|
1414
|
+
*
|
|
1415
|
+
* const userSchema = t.object({
|
|
1416
|
+
* id: db.primaryKey(t.uuid()),
|
|
1417
|
+
* email: t.email(),
|
|
1418
|
+
* createdAt: db.createdAt(),
|
|
1419
|
+
* });
|
|
1420
|
+
* ```
|
|
1421
|
+
*/
|
|
1422
|
+
declare const db: DatabaseTypeProvider;
|
|
1423
|
+
/**
|
|
1424
|
+
* @deprecated Use `db` instead.
|
|
1425
|
+
*/
|
|
1426
|
+
declare const pg: DatabaseTypeProvider;
|
|
1427
|
+
//#endregion
|
|
1428
|
+
//#region ../../src/orm/schemas/legacyIdSchema.d.ts
|
|
1429
|
+
/**
|
|
1430
|
+
* @deprecated Use `pg.primaryKey()` instead.
|
|
1431
|
+
*/
|
|
1432
|
+
declare const legacyIdSchema: PgAttr<PgAttr<PgAttr<alepha26.TInteger, typeof PG_PRIMARY_KEY>, typeof PG_SERIAL>, typeof PG_DEFAULT>;
|
|
1240
1433
|
//#endregion
|
|
1241
1434
|
//#region ../../src/orm/services/QueryManager.d.ts
|
|
1242
1435
|
declare class QueryManager {
|
|
1243
1436
|
protected readonly alepha: Alepha;
|
|
1244
1437
|
/**
|
|
1245
|
-
|
|
1246
|
-
|
|
1438
|
+
* Convert a query object to a SQL query.
|
|
1439
|
+
*/
|
|
1247
1440
|
toSQL(query: PgQueryWhereOrSQL<TObject>, options: {
|
|
1248
1441
|
schema: TObject;
|
|
1249
1442
|
col: (key: string) => PgColumn;
|
|
@@ -1251,22 +1444,22 @@ declare class QueryManager {
|
|
|
1251
1444
|
dialect: "postgresql" | "sqlite";
|
|
1252
1445
|
}): SQL | undefined;
|
|
1253
1446
|
/**
|
|
1254
|
-
|
|
1255
|
-
|
|
1447
|
+
* Check if an object has any filter operator properties.
|
|
1448
|
+
*/
|
|
1256
1449
|
protected hasFilterOperatorProperties(obj: any): boolean;
|
|
1257
1450
|
/**
|
|
1258
|
-
|
|
1259
|
-
|
|
1451
|
+
* Map a filter operator to a SQL query.
|
|
1452
|
+
*/
|
|
1260
1453
|
mapOperatorToSql(operator: FilterOperators<any> | any, column: PgColumn, columnSchema?: TObject, columnName?: string, dialect?: "postgresql" | "sqlite"): SQL | undefined;
|
|
1261
1454
|
/**
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1455
|
+
* Parse pagination sort string to orderBy format.
|
|
1456
|
+
* Format: "firstName,-lastName" -> [{ column: "firstName", direction: "asc" }, { column: "lastName", direction: "desc" }]
|
|
1457
|
+
* - Columns separated by comma
|
|
1458
|
+
* - Prefix with '-' for DESC direction
|
|
1459
|
+
*
|
|
1460
|
+
* @param sort Pagination sort string
|
|
1461
|
+
* @returns OrderBy array or single object
|
|
1462
|
+
*/
|
|
1270
1463
|
parsePaginationSort(sort: string): Array<{
|
|
1271
1464
|
column: string;
|
|
1272
1465
|
direction: "asc" | "desc";
|
|
@@ -1275,34 +1468,34 @@ declare class QueryManager {
|
|
|
1275
1468
|
direction: "asc" | "desc";
|
|
1276
1469
|
};
|
|
1277
1470
|
/**
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1471
|
+
* Normalize orderBy parameter to array format.
|
|
1472
|
+
* Supports 3 modes:
|
|
1473
|
+
* 1. String: "name" -> [{ column: "name", direction: "asc" }]
|
|
1474
|
+
* 2. Object: { column: "name", direction: "desc" } -> [{ column: "name", direction: "desc" }]
|
|
1475
|
+
* 3. Array: [{ column: "name" }, { column: "age", direction: "desc" }] -> normalized array
|
|
1476
|
+
*
|
|
1477
|
+
* @param orderBy The orderBy parameter
|
|
1478
|
+
* @returns Normalized array of order by clauses
|
|
1479
|
+
*/
|
|
1287
1480
|
normalizeOrderBy(orderBy: any): Array<{
|
|
1288
1481
|
column: string;
|
|
1289
1482
|
direction: "asc" | "desc";
|
|
1290
1483
|
}>;
|
|
1291
1484
|
/**
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1485
|
+
* Create a pagination object.
|
|
1486
|
+
*
|
|
1487
|
+
* @deprecated Use `createPagination` from alepha instead.
|
|
1488
|
+
* This method now delegates to the framework-level helper.
|
|
1489
|
+
*
|
|
1490
|
+
* @param entities The entities to paginate.
|
|
1491
|
+
* @param limit The limit of the pagination.
|
|
1492
|
+
* @param offset The offset of the pagination.
|
|
1493
|
+
* @param sort Optional sort metadata to include in response.
|
|
1494
|
+
*/
|
|
1302
1495
|
createPagination<T>(entities: T[], limit?: number, offset?: number, sort?: Array<{
|
|
1303
1496
|
column: string;
|
|
1304
1497
|
direction: "asc" | "desc";
|
|
1305
|
-
}>):
|
|
1498
|
+
}>): alepha26.Page<T>;
|
|
1306
1499
|
}
|
|
1307
1500
|
interface PgJoin {
|
|
1308
1501
|
table: string;
|
|
@@ -1315,20 +1508,20 @@ interface PgJoin {
|
|
|
1315
1508
|
//#region ../../src/orm/services/PgRelationManager.d.ts
|
|
1316
1509
|
declare class PgRelationManager {
|
|
1317
1510
|
/**
|
|
1318
|
-
|
|
1319
|
-
|
|
1511
|
+
* Recursively build joins for the query builder based on the relations map
|
|
1512
|
+
*/
|
|
1320
1513
|
buildJoins(provider: DatabaseProvider, builder: PgSelectBase<any, any, any>, joins: Array<PgJoin>, withRelations: PgRelationMap<TObject>, table: PgTableWithColumns<any>, parentKey?: string): void;
|
|
1321
1514
|
/**
|
|
1322
|
-
|
|
1323
|
-
|
|
1515
|
+
* Map a row with its joined relations based on the joins definition
|
|
1516
|
+
*/
|
|
1324
1517
|
mapRowWithJoins(record: Record<string, unknown>, row: Record<string, unknown>, schema: TObject, joins: PgJoin[], parentKey?: string): Record<string, unknown>;
|
|
1325
1518
|
/**
|
|
1326
|
-
|
|
1327
|
-
|
|
1519
|
+
* Check if all values in an object are null (indicates a left join with no match)
|
|
1520
|
+
*/
|
|
1328
1521
|
private isAllNull;
|
|
1329
1522
|
/**
|
|
1330
|
-
|
|
1331
|
-
|
|
1523
|
+
* Build a schema that includes all join properties recursively
|
|
1524
|
+
*/
|
|
1332
1525
|
buildSchemaWithJoins(baseSchema: TObject, joins: PgJoin[], parentPath?: string): TObject;
|
|
1333
1526
|
}
|
|
1334
1527
|
//#endregion
|
|
@@ -1336,217 +1529,218 @@ declare class PgRelationManager {
|
|
|
1336
1529
|
declare abstract class Repository<T extends TObject> {
|
|
1337
1530
|
readonly entity: EntityPrimitive<T>;
|
|
1338
1531
|
readonly provider: DatabaseProvider;
|
|
1339
|
-
protected readonly log:
|
|
1532
|
+
protected readonly log: alepha_logger4.Logger;
|
|
1340
1533
|
protected readonly relationManager: PgRelationManager;
|
|
1341
1534
|
protected readonly queryManager: QueryManager;
|
|
1342
1535
|
protected readonly dateTimeProvider: DateTimeProvider;
|
|
1343
1536
|
protected readonly alepha: Alepha;
|
|
1537
|
+
static of<T extends TObject>(entity: EntityPrimitive<T>, provider?: typeof DatabaseProvider): new () => Repository<T>;
|
|
1344
1538
|
constructor(entity: EntityPrimitive<T>, provider?: typeof DatabaseProvider);
|
|
1345
1539
|
/**
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1540
|
+
* Represents the primary key of the table.
|
|
1541
|
+
* - Key is the name of the primary key column.
|
|
1542
|
+
* - Type is the type (TypeBox) of the primary key column.
|
|
1543
|
+
*
|
|
1544
|
+
* ID is mandatory. If the table does not have a primary key, it will throw an error.
|
|
1545
|
+
*/
|
|
1352
1546
|
get id(): {
|
|
1353
1547
|
type: TSchema;
|
|
1354
1548
|
key: keyof T["properties"];
|
|
1355
1549
|
col: PgColumn;
|
|
1356
1550
|
};
|
|
1357
1551
|
/**
|
|
1358
|
-
|
|
1359
|
-
|
|
1552
|
+
* Get Drizzle table object.
|
|
1553
|
+
*/
|
|
1360
1554
|
get table(): PgTableWithColumns<SchemaToTableConfig<T>>;
|
|
1361
1555
|
/**
|
|
1362
|
-
|
|
1363
|
-
|
|
1556
|
+
* Get SQL table name. (from Drizzle table object)
|
|
1557
|
+
*/
|
|
1364
1558
|
get tableName(): string;
|
|
1365
1559
|
/**
|
|
1366
|
-
|
|
1367
|
-
|
|
1560
|
+
* Getter for the database connection from the database provider.
|
|
1561
|
+
*/
|
|
1368
1562
|
protected get db(): PgDatabase<any>;
|
|
1369
1563
|
/**
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1564
|
+
* Execute a SQL query.
|
|
1565
|
+
*
|
|
1566
|
+
* This method allows executing raw SQL queries against the database.
|
|
1567
|
+
* This is by far the easiest way to run custom queries that are not covered by the repository's built-in methods!
|
|
1568
|
+
*
|
|
1569
|
+
* You must use the `sql` tagged template function from Drizzle ORM to create the query. https://orm.drizzle.team/docs/sql
|
|
1570
|
+
*
|
|
1571
|
+
* @example
|
|
1572
|
+
* ```ts
|
|
1573
|
+
* class App {
|
|
1574
|
+
* repository = $repository({ ... });
|
|
1575
|
+
* async getAdults() {
|
|
1576
|
+
* const users = repository.table; // Drizzle table object
|
|
1577
|
+
* await repository.query(sql`SELECT * FROM ${users} WHERE ${users.age} > ${18}`);
|
|
1578
|
+
* // or better
|
|
1579
|
+
* await repository.query((users) => sql`SELECT * FROM ${users} WHERE ${users.age} > ${18}`);
|
|
1580
|
+
* }
|
|
1581
|
+
* }
|
|
1582
|
+
* ```
|
|
1583
|
+
*/
|
|
1390
1584
|
query<R extends TObject = T>(query: SQLLike | ((table: PgTableWithColumns<SchemaToTableConfig<T>>, db: PgDatabase<any>) => SQLLike), schema?: R): Promise<Static<R>[]>;
|
|
1391
1585
|
/**
|
|
1392
|
-
|
|
1393
|
-
|
|
1586
|
+
* Map raw database fields to entity fields. (handles column name differences)
|
|
1587
|
+
*/
|
|
1394
1588
|
protected mapRawFieldsToEntity(row: Record<string, unknown>): any;
|
|
1395
1589
|
/**
|
|
1396
|
-
|
|
1397
|
-
|
|
1590
|
+
* Get a Drizzle column from the table by his name.
|
|
1591
|
+
*/
|
|
1398
1592
|
protected col(name: keyof StaticEncode<T>): PgColumn;
|
|
1399
1593
|
/**
|
|
1400
|
-
|
|
1401
|
-
|
|
1594
|
+
* Run a transaction.
|
|
1595
|
+
*/
|
|
1402
1596
|
transaction<T>(transaction: (tx: PgTransaction<any, Record<string, any>, any>) => Promise<T>, config?: PgTransactionConfig): Promise<T>;
|
|
1403
1597
|
/**
|
|
1404
|
-
|
|
1405
|
-
|
|
1598
|
+
* Start a SELECT query on the table.
|
|
1599
|
+
*/
|
|
1406
1600
|
protected rawSelect(opts?: StatementOptions): drizzle_orm_pg_core0.PgSelectBase<string, Record<string, PgColumn<drizzle_orm0.ColumnBaseConfig<drizzle_orm0.ColumnDataType, string>, {}, {}>>, "single", Record<string, "not-null">, false, never, {
|
|
1407
1601
|
[x: string]: unknown;
|
|
1408
1602
|
}[], {
|
|
1409
1603
|
[x: string]: PgColumn<drizzle_orm0.ColumnBaseConfig<drizzle_orm0.ColumnDataType, string>, {}, {}>;
|
|
1410
1604
|
}>;
|
|
1411
1605
|
/**
|
|
1412
|
-
|
|
1413
|
-
|
|
1606
|
+
* Start a SELECT DISTINCT query on the table.
|
|
1607
|
+
*/
|
|
1414
1608
|
protected rawSelectDistinct(opts?: StatementOptions, columns?: (keyof Static<T>)[]): drizzle_orm_pg_core0.PgSelectBase<string, Record<string, any>, "partial", Record<string, "not-null">, false, never, {
|
|
1415
1609
|
[x: string]: any;
|
|
1416
1610
|
}[], {
|
|
1417
1611
|
[x: string]: any;
|
|
1418
1612
|
}>;
|
|
1419
1613
|
/**
|
|
1420
|
-
|
|
1421
|
-
|
|
1614
|
+
* Start an INSERT query on the table.
|
|
1615
|
+
*/
|
|
1422
1616
|
protected rawInsert(opts?: StatementOptions): drizzle_orm_pg_core0.PgInsertBuilder<PgTableWithColumns<SchemaToTableConfig<T>>, any, false>;
|
|
1423
1617
|
/**
|
|
1424
|
-
|
|
1425
|
-
|
|
1618
|
+
* Start an UPDATE query on the table.
|
|
1619
|
+
*/
|
|
1426
1620
|
protected rawUpdate(opts?: StatementOptions): drizzle_orm_pg_core0.PgUpdateBuilder<PgTableWithColumns<SchemaToTableConfig<T>>, any>;
|
|
1427
1621
|
/**
|
|
1428
|
-
|
|
1429
|
-
|
|
1622
|
+
* Start a DELETE query on the table.
|
|
1623
|
+
*/
|
|
1430
1624
|
protected rawDelete(opts?: StatementOptions): drizzle_orm_pg_core0.PgDeleteBase<PgTableWithColumns<SchemaToTableConfig<T>>, any, undefined, undefined, false, never>;
|
|
1431
1625
|
/**
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1626
|
+
* Create a Drizzle `select` query based on a JSON query object.
|
|
1627
|
+
*
|
|
1628
|
+
* > This method is the base for `find`, `findOne`, `findById`, and `paginate`.
|
|
1629
|
+
*/
|
|
1436
1630
|
findMany<R extends PgRelationMap<T>>(query?: PgQueryRelations<T, R>, opts?: StatementOptions): Promise<PgStatic<T, R>[]>;
|
|
1437
1631
|
/**
|
|
1438
|
-
|
|
1439
|
-
|
|
1632
|
+
* Find a single entity.
|
|
1633
|
+
*/
|
|
1440
1634
|
findOne<R extends PgRelationMap<T>>(query: Pick<PgQueryRelations<T, R>, "with" | "where">, opts?: StatementOptions): Promise<PgStatic<T, R>>;
|
|
1441
1635
|
/**
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1636
|
+
* Find entities with pagination.
|
|
1637
|
+
*
|
|
1638
|
+
* It uses the same parameters as `find()`, but adds pagination metadata to the response.
|
|
1639
|
+
*
|
|
1640
|
+
* > Pagination CAN also do a count query to get the total number of elements.
|
|
1641
|
+
*/
|
|
1448
1642
|
paginate<R extends PgRelationMap<T>>(pagination?: PageQuery$1, query?: PgQueryRelations<T, R>, opts?: StatementOptions & {
|
|
1449
1643
|
count?: boolean;
|
|
1450
1644
|
}): Promise<Page$1<PgStatic<T, R>>>;
|
|
1451
1645
|
/**
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1646
|
+
* Find an entity by ID.
|
|
1647
|
+
*
|
|
1648
|
+
* This is a convenience method for `findOne` with a where clause on the primary key.
|
|
1649
|
+
* If you need more complex queries, use `findOne` instead.
|
|
1650
|
+
*/
|
|
1457
1651
|
findById(id: string | number, opts?: StatementOptions): Promise<Static<T>>;
|
|
1458
1652
|
/**
|
|
1459
|
-
|
|
1460
|
-
|
|
1653
|
+
* Helper to create a type-safe query object.
|
|
1654
|
+
*/
|
|
1461
1655
|
createQuery(): PgQuery<T>;
|
|
1462
1656
|
/**
|
|
1463
|
-
|
|
1464
|
-
|
|
1657
|
+
* Helper to create a type-safe where clause.
|
|
1658
|
+
*/
|
|
1465
1659
|
createQueryWhere(): PgQueryWhere<T>;
|
|
1466
1660
|
/**
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1661
|
+
* Create an entity.
|
|
1662
|
+
*
|
|
1663
|
+
* @param data The entity to create.
|
|
1664
|
+
* @param opts The options for creating the entity.
|
|
1665
|
+
* @returns The ID of the created entity.
|
|
1666
|
+
*/
|
|
1473
1667
|
create(data: Static<TObjectInsert<T>>, opts?: StatementOptions): Promise<Static<T>>;
|
|
1474
1668
|
/**
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1669
|
+
* Create many entities.
|
|
1670
|
+
*
|
|
1671
|
+
* Inserts are batched in chunks of 1000 to avoid hitting database limits.
|
|
1672
|
+
*
|
|
1673
|
+
* @param values The entities to create.
|
|
1674
|
+
* @param opts The statement options.
|
|
1675
|
+
* @returns The created entities.
|
|
1676
|
+
*/
|
|
1483
1677
|
createMany(values: Array<Static<TObjectInsert<T>>>, opts?: StatementOptions & {
|
|
1484
1678
|
batchSize?: number;
|
|
1485
1679
|
}): Promise<Static<T>[]>;
|
|
1486
1680
|
/**
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
updateOne(where: PgQueryWhereOrSQL<T>, data:
|
|
1490
|
-
/**
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1681
|
+
* Find an entity and update it.
|
|
1682
|
+
*/
|
|
1683
|
+
updateOne(where: PgQueryWhereOrSQL<T>, data: WithSQL<Static<TObjectUpdate<T>>>, opts?: StatementOptions): Promise<Static<T>>;
|
|
1684
|
+
/**
|
|
1685
|
+
* Save a given entity.
|
|
1686
|
+
*
|
|
1687
|
+
* @example
|
|
1688
|
+
* ```ts
|
|
1689
|
+
* const entity = await repository.findById(1);
|
|
1690
|
+
* entity.name = "New Name"; // update a field
|
|
1691
|
+
* delete entity.description; // delete a field
|
|
1692
|
+
* await repository.save(entity);
|
|
1693
|
+
* ```
|
|
1694
|
+
*
|
|
1695
|
+
* Difference with `updateById/updateOne`:
|
|
1696
|
+
*
|
|
1697
|
+
* - requires the entity to be fetched first (whole object is expected)
|
|
1698
|
+
* - check pg.version() if present -> optimistic locking
|
|
1699
|
+
* - validate entity against schema
|
|
1700
|
+
* - undefined values will be set to null, not ignored!
|
|
1701
|
+
*
|
|
1702
|
+
* @see {@link DbVersionMismatchError}
|
|
1703
|
+
*/
|
|
1510
1704
|
save(entity: Static<T>, opts?: StatementOptions): Promise<void>;
|
|
1511
1705
|
/**
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
updateById(id: string | number, data:
|
|
1706
|
+
* Find an entity by ID and update it.
|
|
1707
|
+
*/
|
|
1708
|
+
updateById(id: string | number, data: WithSQL<Static<TObjectUpdate<T>>>, opts?: StatementOptions): Promise<Static<T>>;
|
|
1515
1709
|
/**
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
updateMany(where: PgQueryWhereOrSQL<T>, data:
|
|
1710
|
+
* Find many entities and update all of them.
|
|
1711
|
+
*/
|
|
1712
|
+
updateMany(where: PgQueryWhereOrSQL<T>, data: WithSQL<Static<TObjectUpdate<T>>>, opts?: StatementOptions): Promise<Array<number | string>>;
|
|
1519
1713
|
/**
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1714
|
+
* Find many and delete all of them.
|
|
1715
|
+
* @returns Array of deleted entity IDs
|
|
1716
|
+
*/
|
|
1523
1717
|
deleteMany(where?: PgQueryWhereOrSQL<T>, opts?: StatementOptions): Promise<Array<number | string>>;
|
|
1524
1718
|
/**
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1719
|
+
* Delete all entities.
|
|
1720
|
+
* @returns Array of deleted entity IDs
|
|
1721
|
+
*/
|
|
1528
1722
|
clear(opts?: StatementOptions): Promise<Array<number | string>>;
|
|
1529
1723
|
/**
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1724
|
+
* Delete the given entity.
|
|
1725
|
+
*
|
|
1726
|
+
* You must fetch the entity first in order to delete it.
|
|
1727
|
+
* @returns Array containing the deleted entity ID
|
|
1728
|
+
*/
|
|
1535
1729
|
destroy(entity: Static<T>, opts?: StatementOptions): Promise<Array<number | string>>;
|
|
1536
1730
|
/**
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1731
|
+
* Find an entity and delete it.
|
|
1732
|
+
* @returns Array of deleted entity IDs (should contain at most one ID)
|
|
1733
|
+
*/
|
|
1540
1734
|
deleteOne(where?: PgQueryWhereOrSQL<T>, opts?: StatementOptions): Promise<Array<number | string>>;
|
|
1541
1735
|
/**
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1736
|
+
* Find an entity by ID and delete it.
|
|
1737
|
+
* @returns Array containing the deleted entity ID
|
|
1738
|
+
* @throws DbEntityNotFoundError if the entity is not found
|
|
1739
|
+
*/
|
|
1546
1740
|
deleteById(id: string | number, opts?: StatementOptions): Promise<Array<number | string>>;
|
|
1547
1741
|
/**
|
|
1548
|
-
|
|
1549
|
-
|
|
1742
|
+
* Count entities.
|
|
1743
|
+
*/
|
|
1550
1744
|
count(where?: PgQueryWhereOrSQL<T>, opts?: StatementOptions): Promise<number>;
|
|
1551
1745
|
protected conflictMessagePattern: string;
|
|
1552
1746
|
protected handleError(error: unknown, message: string): DbError;
|
|
@@ -1555,31 +1749,31 @@ declare abstract class Repository<T extends TObject> {
|
|
|
1555
1749
|
}): PgQueryWhereOrSQL<T>;
|
|
1556
1750
|
protected deletedAt(): PgAttrField | undefined;
|
|
1557
1751
|
/**
|
|
1558
|
-
|
|
1559
|
-
|
|
1752
|
+
* Convert something to valid Pg Insert Value.
|
|
1753
|
+
*/
|
|
1560
1754
|
protected cast(data: any, insert: boolean): PgInsertValue<PgTableWithColumns<SchemaToTableConfig<T>>>;
|
|
1561
1755
|
/**
|
|
1562
|
-
|
|
1563
|
-
|
|
1756
|
+
* Transform a row from the database into a clean entity.
|
|
1757
|
+
*/
|
|
1564
1758
|
protected clean<T extends TObject>(row: Record<string, unknown>, schema: T): Static<T>;
|
|
1565
1759
|
/**
|
|
1566
|
-
|
|
1567
|
-
|
|
1760
|
+
* Clean a row with joins recursively
|
|
1761
|
+
*/
|
|
1568
1762
|
protected cleanWithJoins<T extends TObject>(row: Record<string, unknown>, schema: T, joins: PgJoin[], parentPath?: string): Static<T>;
|
|
1569
1763
|
/**
|
|
1570
|
-
|
|
1571
|
-
|
|
1764
|
+
* Convert a where clause to SQL.
|
|
1765
|
+
*/
|
|
1572
1766
|
protected toSQL(where: PgQueryWhereOrSQL<T>, joins?: PgJoin[]): SQL | undefined;
|
|
1573
1767
|
/**
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1768
|
+
* Get the where clause for an ID.
|
|
1769
|
+
*
|
|
1770
|
+
* @param id The ID to get the where clause for.
|
|
1771
|
+
* @returns The where clause for the ID.
|
|
1772
|
+
*/
|
|
1579
1773
|
protected getWhereId(id: string | number): PgQueryWhere<T>;
|
|
1580
1774
|
/**
|
|
1581
|
-
|
|
1582
|
-
|
|
1775
|
+
* Find a primary key in the schema.
|
|
1776
|
+
*/
|
|
1583
1777
|
protected getPrimaryKey(schema: TObject): {
|
|
1584
1778
|
key: string;
|
|
1585
1779
|
col: PgColumn<drizzle_orm0.ColumnBaseConfig<drizzle_orm0.ColumnDataType, string>, {}, {}>;
|
|
@@ -1591,25 +1785,26 @@ declare abstract class Repository<T extends TObject> {
|
|
|
1591
1785
|
*/
|
|
1592
1786
|
interface StatementOptions {
|
|
1593
1787
|
/**
|
|
1594
|
-
|
|
1595
|
-
|
|
1788
|
+
* Transaction to use.
|
|
1789
|
+
*/
|
|
1596
1790
|
tx?: PgTransaction<any, Record<string, any>>;
|
|
1597
1791
|
/**
|
|
1598
|
-
|
|
1599
|
-
|
|
1792
|
+
* Lock strength.
|
|
1793
|
+
*/
|
|
1600
1794
|
for?: LockStrength | {
|
|
1601
1795
|
config: LockConfig;
|
|
1602
1796
|
strength: LockStrength;
|
|
1603
1797
|
};
|
|
1604
1798
|
/**
|
|
1605
|
-
|
|
1606
|
-
|
|
1799
|
+
* If true, ignore soft delete.
|
|
1800
|
+
*/
|
|
1607
1801
|
force?: boolean;
|
|
1608
1802
|
/**
|
|
1609
|
-
|
|
1610
|
-
|
|
1803
|
+
* Force the current time.
|
|
1804
|
+
*/
|
|
1611
1805
|
now?: DateTime | string;
|
|
1612
1806
|
}
|
|
1807
|
+
type WithSQL<T> = { [P in keyof T]?: T[P] | SQL };
|
|
1613
1808
|
//#endregion
|
|
1614
1809
|
//#region ../../src/orm/primitives/$repository.d.ts
|
|
1615
1810
|
/**
|
|
@@ -1636,262 +1831,108 @@ declare const $repository: <T extends TObject>(entity: EntityPrimitive<T>) => Re
|
|
|
1636
1831
|
declare const $transaction: <T extends any[], R>(opts: TransactionPrimitiveOptions<T, R>) => alepha_retry0.RetryPrimitiveFn<(...args: T) => Promise<R>>;
|
|
1637
1832
|
interface TransactionPrimitiveOptions<T extends any[], R> {
|
|
1638
1833
|
/**
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1834
|
+
* Transaction handler function that contains all database operations to be executed atomically.
|
|
1835
|
+
*
|
|
1836
|
+
* This function:
|
|
1837
|
+
* - Receives a transaction object as the first parameter
|
|
1838
|
+
* - Should pass the transaction to all repository operations via `{ tx }` option
|
|
1839
|
+
* - All operations within are automatically rolled back if any error occurs
|
|
1840
|
+
* - Has access to the full Alepha dependency injection container
|
|
1841
|
+
* - Will be automatically retried if a `PgVersionMismatchError` occurs
|
|
1842
|
+
*
|
|
1843
|
+
* **Transaction Guidelines**:
|
|
1844
|
+
* - Keep transactions as short as possible to minimize lock contention
|
|
1845
|
+
* - Always pass the `tx` parameter to repository operations
|
|
1846
|
+
* - Handle expected business errors gracefully
|
|
1847
|
+
* - Log important operations for debugging and audit trails
|
|
1848
|
+
* - Consider the impact of long-running transactions on performance
|
|
1849
|
+
*
|
|
1850
|
+
* **Error Handling**:
|
|
1851
|
+
* - Throwing any error will automatically roll back the transaction
|
|
1852
|
+
* - `PgVersionMismatchError` triggers automatic retry logic
|
|
1853
|
+
* - Other database errors will be propagated after rollback
|
|
1854
|
+
* - Use try-catch within the handler for business-specific error handling
|
|
1855
|
+
*
|
|
1856
|
+
* @param tx - The PostgreSQL transaction object to use for all database operations
|
|
1857
|
+
* @param ...args - Additional arguments passed to the transaction function
|
|
1858
|
+
* @returns Promise resolving to the transaction result
|
|
1859
|
+
*
|
|
1860
|
+
* @example
|
|
1861
|
+
* ```ts
|
|
1862
|
+
* handler: async (tx, orderId: string, newStatus: string) => {
|
|
1863
|
+
* // Get the current order (with transaction)
|
|
1864
|
+
* const order = await this.orders.findById(orderId, { tx });
|
|
1865
|
+
*
|
|
1866
|
+
* // Validate business rules
|
|
1867
|
+
* if (!this.isValidStatusTransition(order.status, newStatus)) {
|
|
1868
|
+
* throw new Error(`Invalid status transition: ${order.status} -> ${newStatus}`);
|
|
1869
|
+
* }
|
|
1870
|
+
*
|
|
1871
|
+
* // Update order status (with transaction)
|
|
1872
|
+
* const updatedOrder = await this.orders.updateById(
|
|
1873
|
+
* orderId,
|
|
1874
|
+
* { status: newStatus },
|
|
1875
|
+
* { tx }
|
|
1876
|
+
* );
|
|
1877
|
+
*
|
|
1878
|
+
* // Create audit log (with transaction)
|
|
1879
|
+
* await this.auditLogs.create({
|
|
1880
|
+
* id: generateUUID(),
|
|
1881
|
+
* entityId: orderId,
|
|
1882
|
+
* action: 'status_change',
|
|
1883
|
+
* oldValue: order.status,
|
|
1884
|
+
* newValue: newStatus,
|
|
1885
|
+
* timestamp: new Date().toISOString()
|
|
1886
|
+
* }, { tx });
|
|
1887
|
+
*
|
|
1888
|
+
* return updatedOrder;
|
|
1889
|
+
* }
|
|
1890
|
+
* ```
|
|
1891
|
+
*/
|
|
1697
1892
|
handler: (tx: PgTransaction<any, any, any>, ...args: T) => Promise<R>;
|
|
1698
1893
|
/**
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1894
|
+
* PostgreSQL transaction configuration options.
|
|
1895
|
+
*
|
|
1896
|
+
* This allows you to customize transaction behavior including:
|
|
1897
|
+
* - **Isolation Level**: Controls visibility of concurrent transaction changes
|
|
1898
|
+
* - **Access Mode**: Whether the transaction is read-only or read-write
|
|
1899
|
+
* - **Deferrable**: For serializable transactions, allows deferring to avoid conflicts
|
|
1900
|
+
*
|
|
1901
|
+
* **Isolation Levels**:
|
|
1902
|
+
* - **read_uncommitted**: Lowest isolation, allows dirty reads (rarely used)
|
|
1903
|
+
* - **read_committed**: Default level, prevents dirty reads
|
|
1904
|
+
* - **repeatable_read**: Prevents dirty and non-repeatable reads
|
|
1905
|
+
* - **serializable**: Highest isolation, full ACID compliance
|
|
1906
|
+
*
|
|
1907
|
+
* **Access Modes**:
|
|
1908
|
+
* - **read_write**: Default, allows both read and write operations
|
|
1909
|
+
* - **read_only**: Only allows read operations, can provide performance benefits
|
|
1910
|
+
*
|
|
1911
|
+
* **When to Use Different Isolation Levels**:
|
|
1912
|
+
* - **read_committed**: Most common operations, good balance of consistency and performance
|
|
1913
|
+
* - **repeatable_read**: When you need consistent reads throughout the transaction
|
|
1914
|
+
* - **serializable**: Critical financial operations, when absolute consistency is required
|
|
1915
|
+
*
|
|
1916
|
+
* @example
|
|
1917
|
+
* ```ts
|
|
1918
|
+
* config: {
|
|
1919
|
+
* isolationLevel: 'serializable', // Highest consistency for financial operations
|
|
1920
|
+
* accessMode: 'read_write'
|
|
1921
|
+
* }
|
|
1922
|
+
* ```
|
|
1923
|
+
*
|
|
1924
|
+
* @example
|
|
1925
|
+
* ```ts
|
|
1926
|
+
* config: {
|
|
1927
|
+
* isolationLevel: 'read_committed', // Default level for most operations
|
|
1928
|
+
* accessMode: 'read_only' // Performance optimization for read-only operations
|
|
1929
|
+
* }
|
|
1930
|
+
* ```
|
|
1931
|
+
*/
|
|
1737
1932
|
config?: PgTransactionConfig;
|
|
1738
1933
|
}
|
|
1739
1934
|
type TransactionContext = PgTransaction<any, any, any>;
|
|
1740
1935
|
//#endregion
|
|
1741
|
-
//#region ../../src/orm/services/SqliteModelBuilder.d.ts
|
|
1742
|
-
declare class SqliteModelBuilder extends ModelBuilder {
|
|
1743
|
-
buildTable(entity: EntityPrimitive<any>, options: {
|
|
1744
|
-
tables: Map<string, unknown>;
|
|
1745
|
-
enums: Map<string, unknown>;
|
|
1746
|
-
schema: string;
|
|
1747
|
-
}): void;
|
|
1748
|
-
buildSequence(sequence: SequencePrimitive, options: {
|
|
1749
|
-
sequences: Map<string, unknown>;
|
|
1750
|
-
schema: string;
|
|
1751
|
-
}): void;
|
|
1752
|
-
/**
|
|
1753
|
-
* Get SQLite-specific config builder for the table.
|
|
1754
|
-
*/
|
|
1755
|
-
protected getTableConfig(entity: EntityPrimitive, tables: Map<string, unknown>): ((self: BuildColumns<string, any, "sqlite">) => any) | undefined;
|
|
1756
|
-
schemaToSqliteColumns: <T extends TObject>(tableName: string, schema: T, enums: Map<string, unknown>, tables: Map<string, unknown>) => SchemaToSqliteBuilder<T>;
|
|
1757
|
-
mapFieldToSqliteColumn: (tableName: string, fieldName: string, value: TSchema, enums: Map<string, any>) => pg$1.SQLiteIntegerBuilderInitial<string> | pg$1.SQLiteNumericBuilderInitial<string> | pg$1.SQLiteTextBuilderInitial<string, [string, ...string[]], number | undefined> | drizzle_orm0.$Type<pg$1.SQLiteCustomColumnBuilder<{
|
|
1758
|
-
name: string;
|
|
1759
|
-
dataType: "custom";
|
|
1760
|
-
columnType: "SQLiteCustomColumn";
|
|
1761
|
-
data: string;
|
|
1762
|
-
driverParam: string;
|
|
1763
|
-
enumValues: undefined;
|
|
1764
|
-
}>, string> | pg$1.SQLiteCustomColumnBuilder<{
|
|
1765
|
-
name: string;
|
|
1766
|
-
dataType: "custom";
|
|
1767
|
-
columnType: "SQLiteCustomColumn";
|
|
1768
|
-
data: string;
|
|
1769
|
-
driverParam: number;
|
|
1770
|
-
enumValues: undefined;
|
|
1771
|
-
}> | pg$1.SQLiteCustomColumnBuilder<{
|
|
1772
|
-
name: string;
|
|
1773
|
-
dataType: "custom";
|
|
1774
|
-
columnType: "SQLiteCustomColumn";
|
|
1775
|
-
data: boolean;
|
|
1776
|
-
driverParam: number;
|
|
1777
|
-
enumValues: undefined;
|
|
1778
|
-
}> | drizzle_orm0.$Type<pg$1.SQLiteCustomColumnBuilder<{
|
|
1779
|
-
name: string;
|
|
1780
|
-
dataType: "custom";
|
|
1781
|
-
columnType: "SQLiteCustomColumn";
|
|
1782
|
-
data: {
|
|
1783
|
-
[x: string]: unknown;
|
|
1784
|
-
[x: number]: unknown;
|
|
1785
|
-
[x: symbol]: unknown;
|
|
1786
|
-
};
|
|
1787
|
-
driverParam: string;
|
|
1788
|
-
enumValues: undefined;
|
|
1789
|
-
}>, {
|
|
1790
|
-
[x: string]: unknown;
|
|
1791
|
-
[x: number]: unknown;
|
|
1792
|
-
[x: symbol]: unknown;
|
|
1793
|
-
}> | drizzle_orm0.$Type<pg$1.SQLiteCustomColumnBuilder<{
|
|
1794
|
-
name: string;
|
|
1795
|
-
dataType: "custom";
|
|
1796
|
-
columnType: "SQLiteCustomColumn";
|
|
1797
|
-
data: typebox1.StaticRecord<[], "Decode", {}, {}, string, TSchema>;
|
|
1798
|
-
driverParam: string;
|
|
1799
|
-
enumValues: undefined;
|
|
1800
|
-
}>, typebox1.StaticRecord<[], "Decode", {}, {}, string, TSchema>> | drizzle_orm0.$Type<pg$1.SQLiteCustomColumnBuilder<{
|
|
1801
|
-
name: string;
|
|
1802
|
-
dataType: "custom";
|
|
1803
|
-
columnType: "SQLiteCustomColumn";
|
|
1804
|
-
data: any;
|
|
1805
|
-
driverParam: string;
|
|
1806
|
-
enumValues: undefined;
|
|
1807
|
-
}>, any> | drizzle_orm0.$Type<pg$1.SQLiteCustomColumnBuilder<{
|
|
1808
|
-
name: string;
|
|
1809
|
-
dataType: "custom";
|
|
1810
|
-
columnType: "SQLiteCustomColumn";
|
|
1811
|
-
data: unknown[];
|
|
1812
|
-
driverParam: string;
|
|
1813
|
-
enumValues: undefined;
|
|
1814
|
-
}>, unknown[]>;
|
|
1815
|
-
mapStringToSqliteColumn: (key: string, value: TString) => pg$1.SQLiteTextBuilderInitial<string, [string, ...string[]], number | undefined> | drizzle_orm0.$Type<pg$1.SQLiteCustomColumnBuilder<{
|
|
1816
|
-
name: string;
|
|
1817
|
-
dataType: "custom";
|
|
1818
|
-
columnType: "SQLiteCustomColumn";
|
|
1819
|
-
data: string;
|
|
1820
|
-
driverParam: string;
|
|
1821
|
-
enumValues: undefined;
|
|
1822
|
-
}>, string> | pg$1.SQLiteCustomColumnBuilder<{
|
|
1823
|
-
name: string;
|
|
1824
|
-
dataType: "custom";
|
|
1825
|
-
columnType: "SQLiteCustomColumn";
|
|
1826
|
-
data: string;
|
|
1827
|
-
driverParam: number;
|
|
1828
|
-
enumValues: undefined;
|
|
1829
|
-
}>;
|
|
1830
|
-
sqliteJson: <TDocument extends TSchema>(name: string, document: TDocument) => drizzle_orm0.$Type<pg$1.SQLiteCustomColumnBuilder<{
|
|
1831
|
-
name: string;
|
|
1832
|
-
dataType: "custom";
|
|
1833
|
-
columnType: "SQLiteCustomColumn";
|
|
1834
|
-
data: typebox1.StaticType<[], "Decode", {}, {}, TDocument>;
|
|
1835
|
-
driverParam: string;
|
|
1836
|
-
enumValues: undefined;
|
|
1837
|
-
}>, typebox1.StaticType<[], "Decode", {}, {}, TDocument>>;
|
|
1838
|
-
sqliteDateTime: {
|
|
1839
|
-
<TConfig extends Record<string, any>>(fieldConfig: TConfig): pg$1.SQLiteCustomColumnBuilder<{
|
|
1840
|
-
name: "";
|
|
1841
|
-
dataType: "custom";
|
|
1842
|
-
columnType: "SQLiteCustomColumn";
|
|
1843
|
-
data: string;
|
|
1844
|
-
driverParam: number;
|
|
1845
|
-
enumValues: undefined;
|
|
1846
|
-
}>;
|
|
1847
|
-
<TName extends string>(dbName: TName, fieldConfig: unknown): pg$1.SQLiteCustomColumnBuilder<{
|
|
1848
|
-
name: TName;
|
|
1849
|
-
dataType: "custom";
|
|
1850
|
-
columnType: "SQLiteCustomColumn";
|
|
1851
|
-
data: string;
|
|
1852
|
-
driverParam: number;
|
|
1853
|
-
enumValues: undefined;
|
|
1854
|
-
}>;
|
|
1855
|
-
};
|
|
1856
|
-
sqliteBool: {
|
|
1857
|
-
<TConfig extends Record<string, any>>(fieldConfig: TConfig): pg$1.SQLiteCustomColumnBuilder<{
|
|
1858
|
-
name: "";
|
|
1859
|
-
dataType: "custom";
|
|
1860
|
-
columnType: "SQLiteCustomColumn";
|
|
1861
|
-
data: boolean;
|
|
1862
|
-
driverParam: number;
|
|
1863
|
-
enumValues: undefined;
|
|
1864
|
-
}>;
|
|
1865
|
-
<TName extends string>(dbName: TName, fieldConfig: unknown): pg$1.SQLiteCustomColumnBuilder<{
|
|
1866
|
-
name: TName;
|
|
1867
|
-
dataType: "custom";
|
|
1868
|
-
columnType: "SQLiteCustomColumn";
|
|
1869
|
-
data: boolean;
|
|
1870
|
-
driverParam: number;
|
|
1871
|
-
enumValues: undefined;
|
|
1872
|
-
}>;
|
|
1873
|
-
};
|
|
1874
|
-
sqliteDate: {
|
|
1875
|
-
<TConfig extends Record<string, any>>(fieldConfig: TConfig): pg$1.SQLiteCustomColumnBuilder<{
|
|
1876
|
-
name: "";
|
|
1877
|
-
dataType: "custom";
|
|
1878
|
-
columnType: "SQLiteCustomColumn";
|
|
1879
|
-
data: string;
|
|
1880
|
-
driverParam: number;
|
|
1881
|
-
enumValues: undefined;
|
|
1882
|
-
}>;
|
|
1883
|
-
<TName extends string>(dbName: TName, fieldConfig: unknown): pg$1.SQLiteCustomColumnBuilder<{
|
|
1884
|
-
name: TName;
|
|
1885
|
-
dataType: "custom";
|
|
1886
|
-
columnType: "SQLiteCustomColumn";
|
|
1887
|
-
data: string;
|
|
1888
|
-
driverParam: number;
|
|
1889
|
-
enumValues: undefined;
|
|
1890
|
-
}>;
|
|
1891
|
-
};
|
|
1892
|
-
}
|
|
1893
|
-
type SchemaToSqliteBuilder<T extends TObject> = { [key in keyof T["properties"]]: SQLiteColumnBuilderBase };
|
|
1894
|
-
//#endregion
|
|
1895
1936
|
//#region ../../src/orm/providers/drivers/CloudflareD1Provider.d.ts
|
|
1896
1937
|
/**
|
|
1897
1938
|
* D1Database interface matching Cloudflare's D1 API.
|
|
@@ -1938,7 +1979,7 @@ interface D1ExecResult {
|
|
|
1938
1979
|
*/
|
|
1939
1980
|
declare class CloudflareD1Provider extends DatabaseProvider {
|
|
1940
1981
|
protected readonly kit: DrizzleKitProvider;
|
|
1941
|
-
protected readonly log:
|
|
1982
|
+
protected readonly log: alepha_logger4.Logger;
|
|
1942
1983
|
protected readonly builder: SqliteModelBuilder;
|
|
1943
1984
|
protected readonly env: {
|
|
1944
1985
|
DATABASE_URL: string;
|
|
@@ -1951,17 +1992,17 @@ declare class CloudflareD1Provider extends DatabaseProvider {
|
|
|
1951
1992
|
get url(): string;
|
|
1952
1993
|
get db(): PgDatabase<any>;
|
|
1953
1994
|
execute(query: SQLLike): Promise<Array<Record<string, unknown>>>;
|
|
1954
|
-
protected readonly onStart:
|
|
1995
|
+
protected readonly onStart: alepha26.HookPrimitive<"start">;
|
|
1955
1996
|
protected executeMigrations(migrationsFolder: string): Promise<void>;
|
|
1956
1997
|
/**
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1998
|
+
* Override development migration to skip sync (not supported on D1).
|
|
1999
|
+
* D1 requires proper migrations to be applied.
|
|
2000
|
+
*/
|
|
1960
2001
|
protected runDevelopmentMigration(migrationsFolder: string): Promise<void>;
|
|
1961
2002
|
/**
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
2003
|
+
* Override test migration to run migrations instead of sync.
|
|
2004
|
+
* D1 doesn't support schema synchronization.
|
|
2005
|
+
*/
|
|
1965
2006
|
protected runTestMigration(): Promise<void>;
|
|
1966
2007
|
}
|
|
1967
2008
|
//#endregion
|
|
@@ -1969,7 +2010,7 @@ declare class CloudflareD1Provider extends DatabaseProvider {
|
|
|
1969
2010
|
declare class RepositoryProvider {
|
|
1970
2011
|
protected readonly alepha: Alepha;
|
|
1971
2012
|
protected readonly registry: Map<EntityPrimitive<any>, Service<Repository<any>>>;
|
|
1972
|
-
getRepositories(provider?: DatabaseProvider): Repository<TObject<
|
|
2013
|
+
getRepositories(provider?: DatabaseProvider): Repository<TObject<alepha26.TProperties>>[];
|
|
1973
2014
|
getRepository<T extends TObject>(entity: EntityPrimitive<T>): Repository<T>;
|
|
1974
2015
|
createClassRepository<T extends TObject>(entity: EntityPrimitive<T>): Service<Repository<T>>;
|
|
1975
2016
|
}
|
|
@@ -1982,10 +2023,10 @@ declare const schema: <TDocument extends TSchema>(name: string, document: TDocum
|
|
|
1982
2023
|
name: string;
|
|
1983
2024
|
dataType: "custom";
|
|
1984
2025
|
columnType: "PgCustomColumn";
|
|
1985
|
-
data:
|
|
2026
|
+
data: typebox0.StaticType<[], "Decode", {}, {}, TDocument>;
|
|
1986
2027
|
driverParam: string;
|
|
1987
2028
|
enumValues: undefined;
|
|
1988
|
-
}>,
|
|
2029
|
+
}>, typebox0.StaticType<[], "Decode", {}, {}, TDocument>>;
|
|
1989
2030
|
//#endregion
|
|
1990
2031
|
//#region ../../src/orm/services/PostgresModelBuilder.d.ts
|
|
1991
2032
|
declare class PostgresModelBuilder extends ModelBuilder {
|
|
@@ -2001,17 +2042,17 @@ declare class PostgresModelBuilder extends ModelBuilder {
|
|
|
2001
2042
|
schema: string;
|
|
2002
2043
|
}): void;
|
|
2003
2044
|
/**
|
|
2004
|
-
|
|
2005
|
-
|
|
2045
|
+
* Get PostgreSQL-specific config builder for the table.
|
|
2046
|
+
*/
|
|
2006
2047
|
protected getTableConfig(entity: EntityPrimitive, tables: Map<string, unknown>): ((self: BuildExtraConfigColumns<string, any, "pg">) => PgTableExtraConfigValue[]) | undefined;
|
|
2007
2048
|
schemaToPgColumns: <T extends TObject>(tableName: string, schema: T, nsp: PgSchema, enums: Map<string, unknown>, tables: Map<string, unknown>) => FromSchema<T>;
|
|
2008
2049
|
mapFieldToColumn: (tableName: string, fieldName: string, value: TSchema, nsp: PgSchema, enums: Map<string, any>) => any;
|
|
2009
2050
|
/**
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2051
|
+
* Map a string to a PG column.
|
|
2052
|
+
*
|
|
2053
|
+
* @param key The key of the field.
|
|
2054
|
+
* @param value The value of the field.
|
|
2055
|
+
*/
|
|
2015
2056
|
mapStringToColumn: (key: string, value: TSchema) => drizzle_orm_pg_core0.PgUUIDBuilderInitial<string> | drizzle_orm_pg_core0.PgCustomColumnBuilder<{
|
|
2016
2057
|
name: string;
|
|
2017
2058
|
dataType: "custom";
|
|
@@ -2026,19 +2067,19 @@ declare class PostgresModelBuilder extends ModelBuilder {
|
|
|
2026
2067
|
declare module "alepha" {
|
|
2027
2068
|
interface Env extends Partial<Static<typeof envSchema$1>> {}
|
|
2028
2069
|
}
|
|
2029
|
-
declare const envSchema$1:
|
|
2030
|
-
/**
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
DATABASE_URL:
|
|
2038
|
-
/**
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
POSTGRES_SCHEMA:
|
|
2070
|
+
declare const envSchema$1: alepha26.TObject<{
|
|
2071
|
+
/**
|
|
2072
|
+
* Main configuration for database connection.
|
|
2073
|
+
* Accept a string in the format of a Postgres connection URL.
|
|
2074
|
+
* Example: postgres://user:password@localhost:5432/database
|
|
2075
|
+
* or
|
|
2076
|
+
* Example: postgres://user:password@localhost:5432/database?sslmode=require
|
|
2077
|
+
*/
|
|
2078
|
+
DATABASE_URL: alepha26.TOptional<alepha26.TString>;
|
|
2079
|
+
/**
|
|
2080
|
+
* In addition to the DATABASE_URL, you can specify the postgres schema name.
|
|
2081
|
+
*/
|
|
2082
|
+
POSTGRES_SCHEMA: alepha26.TOptional<alepha26.TString>;
|
|
2042
2083
|
}>;
|
|
2043
2084
|
/**
|
|
2044
2085
|
* Bun PostgreSQL provider using Drizzle ORM with Bun's native SQL client.
|
|
@@ -2059,7 +2100,7 @@ declare const envSchema$1: alepha34.TObject<{
|
|
|
2059
2100
|
* ```
|
|
2060
2101
|
*/
|
|
2061
2102
|
declare class BunPostgresProvider extends DatabaseProvider {
|
|
2062
|
-
protected readonly log:
|
|
2103
|
+
protected readonly log: alepha_logger4.Logger;
|
|
2063
2104
|
protected readonly env: {
|
|
2064
2105
|
DATABASE_URL?: string | undefined;
|
|
2065
2106
|
POSTGRES_SCHEMA?: string | undefined;
|
|
@@ -2071,25 +2112,25 @@ declare class BunPostgresProvider extends DatabaseProvider {
|
|
|
2071
2112
|
readonly dialect = "postgresql";
|
|
2072
2113
|
get name(): string;
|
|
2073
2114
|
/**
|
|
2074
|
-
|
|
2075
|
-
|
|
2115
|
+
* In testing mode, the schema name will be generated and deleted after the test.
|
|
2116
|
+
*/
|
|
2076
2117
|
protected schemaForTesting: string | undefined;
|
|
2077
2118
|
get url(): string;
|
|
2078
2119
|
/**
|
|
2079
|
-
|
|
2080
|
-
|
|
2120
|
+
* Execute a SQL statement.
|
|
2121
|
+
*/
|
|
2081
2122
|
execute(statement: SQLLike): Promise<Array<Record<string, unknown>>>;
|
|
2082
2123
|
/**
|
|
2083
|
-
|
|
2084
|
-
|
|
2124
|
+
* Get Postgres schema used by this provider.
|
|
2125
|
+
*/
|
|
2085
2126
|
get schema(): string;
|
|
2086
2127
|
/**
|
|
2087
|
-
|
|
2088
|
-
|
|
2128
|
+
* Get the Drizzle Postgres database instance.
|
|
2129
|
+
*/
|
|
2089
2130
|
get db(): PgDatabase<any>;
|
|
2090
2131
|
protected executeMigrations(migrationsFolder: string): Promise<void>;
|
|
2091
|
-
protected readonly onStart:
|
|
2092
|
-
protected readonly onStop:
|
|
2132
|
+
protected readonly onStart: alepha26.HookPrimitive<"start">;
|
|
2133
|
+
protected readonly onStop: alepha26.HookPrimitive<"stop">;
|
|
2093
2134
|
connect(): Promise<void>;
|
|
2094
2135
|
close(): Promise<void>;
|
|
2095
2136
|
protected migrateLock: alepha_lock0.LockPrimitive<() => Promise<void>>;
|
|
@@ -2099,8 +2140,8 @@ declare class BunPostgresProvider extends DatabaseProvider {
|
|
|
2099
2140
|
/**
|
|
2100
2141
|
* Configuration options for the Bun SQLite database provider.
|
|
2101
2142
|
*/
|
|
2102
|
-
declare const bunSqliteOptions:
|
|
2103
|
-
path:
|
|
2143
|
+
declare const bunSqliteOptions: alepha26.Atom<alepha26.TObject<{
|
|
2144
|
+
path: alepha26.TOptional<alepha26.TString>;
|
|
2104
2145
|
}>, "alepha.postgres.bun-sqlite.options">;
|
|
2105
2146
|
type BunSqliteProviderOptions = Static<typeof bunSqliteOptions.schema>;
|
|
2106
2147
|
declare module "alepha" {
|
|
@@ -2134,7 +2175,7 @@ declare module "alepha" {
|
|
|
2134
2175
|
*/
|
|
2135
2176
|
declare class BunSqliteProvider extends DatabaseProvider {
|
|
2136
2177
|
protected readonly kit: DrizzleKitProvider;
|
|
2137
|
-
protected readonly log:
|
|
2178
|
+
protected readonly log: alepha_logger4.Logger;
|
|
2138
2179
|
protected readonly env: {
|
|
2139
2180
|
DATABASE_URL?: string | undefined;
|
|
2140
2181
|
};
|
|
@@ -2149,8 +2190,8 @@ declare class BunSqliteProvider extends DatabaseProvider {
|
|
|
2149
2190
|
get url(): string;
|
|
2150
2191
|
get db(): PgDatabase<any>;
|
|
2151
2192
|
execute(query: SQLLike): Promise<Array<Record<string, unknown>>>;
|
|
2152
|
-
protected readonly onStart:
|
|
2153
|
-
protected readonly onStop:
|
|
2193
|
+
protected readonly onStart: alepha26.HookPrimitive<"start">;
|
|
2194
|
+
protected readonly onStop: alepha26.HookPrimitive<"stop">;
|
|
2154
2195
|
protected executeMigrations(migrationsFolder: string): Promise<void>;
|
|
2155
2196
|
}
|
|
2156
2197
|
//#endregion
|
|
@@ -2158,25 +2199,25 @@ declare class BunSqliteProvider extends DatabaseProvider {
|
|
|
2158
2199
|
declare module "alepha" {
|
|
2159
2200
|
interface Env extends Partial<Static<typeof envSchema>> {}
|
|
2160
2201
|
}
|
|
2161
|
-
declare const envSchema:
|
|
2162
|
-
/**
|
|
2163
|
-
|
|
2164
|
-
|
|
2165
|
-
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
|
|
2169
|
-
DATABASE_URL:
|
|
2170
|
-
/**
|
|
2171
|
-
|
|
2172
|
-
|
|
2173
|
-
|
|
2174
|
-
|
|
2175
|
-
POSTGRES_SCHEMA:
|
|
2202
|
+
declare const envSchema: alepha26.TObject<{
|
|
2203
|
+
/**
|
|
2204
|
+
* Main configuration for database connection.
|
|
2205
|
+
* Accept a string in the format of a Postgres connection URL.
|
|
2206
|
+
* Example: postgres://user:password@localhost:5432/database
|
|
2207
|
+
* or
|
|
2208
|
+
* Example: postgres://user:password@localhost:5432/database?sslmode=require
|
|
2209
|
+
*/
|
|
2210
|
+
DATABASE_URL: alepha26.TOptional<alepha26.TString>;
|
|
2211
|
+
/**
|
|
2212
|
+
* In addition to the DATABASE_URL, you can specify the postgres schema name.
|
|
2213
|
+
*
|
|
2214
|
+
* It will monkey patch drizzle tables.
|
|
2215
|
+
*/
|
|
2216
|
+
POSTGRES_SCHEMA: alepha26.TOptional<alepha26.TString>;
|
|
2176
2217
|
}>;
|
|
2177
2218
|
declare class NodePostgresProvider extends DatabaseProvider {
|
|
2178
2219
|
static readonly SSL_MODES: readonly ["require", "allow", "prefer", "verify-full"];
|
|
2179
|
-
protected readonly log:
|
|
2220
|
+
protected readonly log: alepha_logger4.Logger;
|
|
2180
2221
|
protected readonly env: {
|
|
2181
2222
|
DATABASE_URL?: string | undefined;
|
|
2182
2223
|
POSTGRES_SCHEMA?: string | undefined;
|
|
@@ -2188,104 +2229,65 @@ declare class NodePostgresProvider extends DatabaseProvider {
|
|
|
2188
2229
|
readonly dialect = "postgresql";
|
|
2189
2230
|
get name(): string;
|
|
2190
2231
|
/**
|
|
2191
|
-
|
|
2192
|
-
|
|
2232
|
+
* In testing mode, the schema name will be generated and deleted after the test.
|
|
2233
|
+
*/
|
|
2193
2234
|
protected schemaForTesting: string | undefined;
|
|
2194
2235
|
get url(): string;
|
|
2195
2236
|
/**
|
|
2196
|
-
|
|
2197
|
-
|
|
2237
|
+
* Execute a SQL statement.
|
|
2238
|
+
*/
|
|
2198
2239
|
execute(statement: SQLLike): Promise<Array<Record<string, unknown>>>;
|
|
2199
2240
|
/**
|
|
2200
|
-
|
|
2201
|
-
|
|
2241
|
+
* Get Postgres schema used by this provider.
|
|
2242
|
+
*/
|
|
2202
2243
|
get schema(): string;
|
|
2203
2244
|
/**
|
|
2204
|
-
|
|
2205
|
-
|
|
2245
|
+
* Get the Drizzle Postgres database instance.
|
|
2246
|
+
*/
|
|
2206
2247
|
get db(): PostgresJsDatabase;
|
|
2207
2248
|
protected executeMigrations(migrationsFolder: string): Promise<void>;
|
|
2208
|
-
protected readonly onStart:
|
|
2209
|
-
protected readonly onStop:
|
|
2249
|
+
protected readonly onStart: alepha26.HookPrimitive<"start">;
|
|
2250
|
+
protected readonly onStop: alepha26.HookPrimitive<"stop">;
|
|
2210
2251
|
connect(): Promise<void>;
|
|
2211
2252
|
close(): Promise<void>;
|
|
2212
2253
|
protected migrateLock: alepha_lock0.LockPrimitive<() => Promise<void>>;
|
|
2213
2254
|
/**
|
|
2214
|
-
|
|
2215
|
-
|
|
2255
|
+
* Map the DATABASE_URL to postgres client options.
|
|
2256
|
+
*/
|
|
2216
2257
|
protected getClientOptions(): postgres.Options<any>;
|
|
2217
2258
|
protected ssl(url: URL): "require" | "allow" | "prefer" | "verify-full" | undefined;
|
|
2218
2259
|
}
|
|
2219
|
-
//#endregion
|
|
2220
|
-
//#region ../../src/orm/providers/drivers/NodeSqliteProvider.d.ts
|
|
2221
|
-
/**
|
|
2222
|
-
* Configuration options for the Node.js SQLite database provider.
|
|
2223
|
-
*/
|
|
2224
|
-
declare const nodeSqliteOptions: alepha34.Atom<alepha34.TObject<{
|
|
2225
|
-
path: alepha34.TOptional<alepha34.TString>;
|
|
2226
|
-
}>, "alepha.postgres.node-sqlite.options">;
|
|
2227
|
-
type NodeSqliteProviderOptions = Static<typeof nodeSqliteOptions.schema>;
|
|
2228
|
-
declare module "alepha" {
|
|
2229
|
-
interface State {
|
|
2230
|
-
[nodeSqliteOptions.key]: NodeSqliteProviderOptions;
|
|
2231
|
-
}
|
|
2232
|
-
}
|
|
2233
|
-
/**
|
|
2234
|
-
* Add a fake support for SQLite in Node.js based on Postgres interfaces.
|
|
2235
|
-
*
|
|
2236
|
-
* This is NOT a real SQLite provider, it's a workaround to use SQLite with Drizzle ORM.
|
|
2237
|
-
* This is NOT recommended for production use.
|
|
2238
|
-
*/
|
|
2239
|
-
declare class NodeSqliteProvider extends DatabaseProvider {
|
|
2240
|
-
protected readonly kit: DrizzleKitProvider;
|
|
2241
|
-
protected readonly log: alepha_logger3.Logger;
|
|
2242
|
-
protected readonly env: {
|
|
2243
|
-
DATABASE_URL?: string | undefined;
|
|
2244
|
-
};
|
|
2245
|
-
protected readonly builder: SqliteModelBuilder;
|
|
2246
|
-
protected readonly options: Readonly<{
|
|
2247
|
-
path?: string | undefined;
|
|
2248
|
-
}>;
|
|
2249
|
-
protected sqlite: DatabaseSync;
|
|
2250
|
-
get name(): string;
|
|
2251
|
-
readonly dialect = "sqlite";
|
|
2252
|
-
get url(): string;
|
|
2253
|
-
execute(query: SQLLike): Promise<Array<Record<string, unknown>>>;
|
|
2254
|
-
readonly db: PgDatabase<any>;
|
|
2255
|
-
protected readonly onStart: alepha34.HookPrimitive<"start">;
|
|
2256
|
-
protected executeMigrations(migrationsFolder: string): Promise<void>;
|
|
2257
|
-
}
|
|
2258
2260
|
declare namespace index_d_exports {
|
|
2259
|
-
export { $entity, $repository, $sequence, $transaction,
|
|
2261
|
+
export { $entity, $repository, $sequence, $transaction, AlephaOrm, BunPostgresProvider, BunSqliteProvider, BunSqliteProviderOptions, CloudflareD1Provider, D1Database, D1ExecResult, D1PreparedStatement, D1Result, DatabaseProvider, DatabaseTypeProvider, DbConflictError, DbEntityNotFoundError, DbError, DbMigrationError, DbVersionMismatchError, DrizzleKitProvider, EntityColumn, EntityColumns, EntityPrimitive, EntityPrimitiveOptions, FilterOperators, FromSchema, NodePostgresProvider, NodeSqliteProvider, NodeSqliteProviderOptions, OrderBy, OrderByClause, OrderDirection, PG_CREATED_AT, PG_DEFAULT, PG_DELETED_AT, PG_ENUM, PG_IDENTITY, PG_PRIMARY_KEY, PG_REF, PG_SERIAL, PG_UPDATED_AT, PG_VERSION, Page, PageQuery, PgAttr, PgAttrField, PgDefault, PgEnumOptions, PgIdentityOptions, PgPrimaryKey, PgQuery, PgQueryRelations, PgQueryWhere, PgQueryWhereOrSQL, PgRef, PgRefOptions, PgRelation, PgRelationMap, PgStatic, PgSymbolKeys, PgSymbols, Repository, RepositoryProvider, SQLLike, SchemaToTableConfig, SequencePrimitive, SequencePrimitiveOptions, SqliteProvider, StatementOptions, TObjectInsert, TObjectUpdate, TransactionContext, TransactionPrimitiveOptions, buildQueryString, bunSqliteOptions, db, drizzle_orm0 as drizzle, getAttrFields, insertSchema, legacyIdSchema, nodeSqliteOptions, pageQuerySchema, pageSchema, parseQueryString, pg, pgAttr, schema, sql, updateSchema };
|
|
2260
2262
|
}
|
|
2261
2263
|
declare module "alepha" {
|
|
2262
2264
|
interface Hooks {
|
|
2263
2265
|
/**
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
+
* Fires before creating an entity in the repository.
|
|
2267
|
+
*/
|
|
2266
2268
|
"repository:create:before": {
|
|
2267
2269
|
tableName: string;
|
|
2268
2270
|
data: any;
|
|
2269
2271
|
};
|
|
2270
2272
|
/**
|
|
2271
|
-
|
|
2272
|
-
|
|
2273
|
+
* Fires after creating an entity in the repository.
|
|
2274
|
+
*/
|
|
2273
2275
|
"repository:create:after": {
|
|
2274
2276
|
tableName: string;
|
|
2275
2277
|
data: any;
|
|
2276
2278
|
entity: any;
|
|
2277
2279
|
};
|
|
2278
2280
|
/**
|
|
2279
|
-
|
|
2280
|
-
|
|
2281
|
+
* Fires before updating entities in the repository.
|
|
2282
|
+
*/
|
|
2281
2283
|
"repository:update:before": {
|
|
2282
2284
|
tableName: string;
|
|
2283
2285
|
where: any;
|
|
2284
2286
|
data: any;
|
|
2285
2287
|
};
|
|
2286
2288
|
/**
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
+
* Fires after updating entities in the repository.
|
|
2290
|
+
*/
|
|
2289
2291
|
"repository:update:after": {
|
|
2290
2292
|
tableName: string;
|
|
2291
2293
|
where: any;
|
|
@@ -2293,30 +2295,30 @@ declare module "alepha" {
|
|
|
2293
2295
|
entities: any[];
|
|
2294
2296
|
};
|
|
2295
2297
|
/**
|
|
2296
|
-
|
|
2297
|
-
|
|
2298
|
+
* Fires before deleting entities from the repository.
|
|
2299
|
+
*/
|
|
2298
2300
|
"repository:delete:before": {
|
|
2299
2301
|
tableName: string;
|
|
2300
2302
|
where: any;
|
|
2301
2303
|
};
|
|
2302
2304
|
/**
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
+
* Fires after deleting entities from the repository.
|
|
2306
|
+
*/
|
|
2305
2307
|
"repository:delete:after": {
|
|
2306
2308
|
tableName: string;
|
|
2307
2309
|
where: any;
|
|
2308
2310
|
ids: Array<string | number>;
|
|
2309
2311
|
};
|
|
2310
2312
|
/**
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
+
* Fires before reading entities from the repository.
|
|
2314
|
+
*/
|
|
2313
2315
|
"repository:read:before": {
|
|
2314
2316
|
tableName: string;
|
|
2315
2317
|
query: any;
|
|
2316
2318
|
};
|
|
2317
2319
|
/**
|
|
2318
|
-
|
|
2319
|
-
|
|
2320
|
+
* Fires after reading entities from the repository.
|
|
2321
|
+
*/
|
|
2320
2322
|
"repository:read:after": {
|
|
2321
2323
|
tableName: string;
|
|
2322
2324
|
query: any;
|
|
@@ -2324,58 +2326,31 @@ declare module "alepha" {
|
|
|
2324
2326
|
};
|
|
2325
2327
|
}
|
|
2326
2328
|
}
|
|
2329
|
+
declare const SqliteProvider: typeof NodeSqliteProvider;
|
|
2327
2330
|
/**
|
|
2328
|
-
*
|
|
2329
|
-
*
|
|
2330
|
-
*
|
|
2331
|
-
* - Bun: Uses `BunPostgresProvider` or `BunSqliteProvider`
|
|
2332
|
-
* - Node.js: Uses `NodePostgresProvider` or `NodeSqliteProvider`
|
|
2333
|
-
*
|
|
2334
|
-
* ```ts
|
|
2335
|
-
* import { t } from "alepha";
|
|
2336
|
-
* import { $entity, $repository, db } from "alepha/postgres";
|
|
2337
|
-
*
|
|
2338
|
-
* const users = $entity({
|
|
2339
|
-
* name: "users",
|
|
2340
|
-
* schema: t.object({
|
|
2341
|
-
* id: db.primaryKey(),
|
|
2342
|
-
* name: t.text(),
|
|
2343
|
-
* email: t.text(),
|
|
2344
|
-
* }),
|
|
2345
|
-
* });
|
|
2346
|
-
*
|
|
2347
|
-
* class App {
|
|
2348
|
-
* users = $repository(users);
|
|
2349
|
-
*
|
|
2350
|
-
* getUserByName(name: string) {
|
|
2351
|
-
* return this.users.findOne({ name: { eq: name } });
|
|
2352
|
-
* }
|
|
2353
|
-
* }
|
|
2354
|
-
* ```
|
|
2355
|
-
*
|
|
2356
|
-
* This is not a full ORM, but rather a set of tools to work with Postgres databases in a type-safe way.
|
|
2331
|
+
* | type | quality | stability |
|
|
2332
|
+
* |------|---------|-----------|
|
|
2333
|
+
* | backend | epic | stable |
|
|
2357
2334
|
*
|
|
2358
|
-
*
|
|
2359
|
-
* - A type-safe way to define entities and repositories. (via `$entity` and `$repository`)
|
|
2360
|
-
* - Custom query builders and filters.
|
|
2361
|
-
* - Built-in special columns like `createdAt`, `updatedAt`, `deletedAt`, `version`.
|
|
2362
|
-
* - Automatic JSONB support.
|
|
2363
|
-
* - Automatic synchronization of entities with the database schema (for testing and development).
|
|
2364
|
-
* - Fallback to raw SQL via Drizzle ORM `sql` function.
|
|
2335
|
+
* Full-featured database abstraction built on Drizzle ORM with complete type safety.
|
|
2365
2336
|
*
|
|
2366
|
-
*
|
|
2337
|
+
* **Features:**
|
|
2338
|
+
* - Define database entities with TypeBox schemas
|
|
2339
|
+
* - Automatic timestamps, soft deletes, and versioning columns
|
|
2340
|
+
* - Type-safe CRUD operations with filtering, pagination, sorting, and relationships
|
|
2341
|
+
* - Database transaction support with automatic rollback
|
|
2342
|
+
* - Auto-incrementing sequences for IDs
|
|
2343
|
+
* - PostgreSQL support (Node.js, Bun, Cloudflare Workers via pglite)
|
|
2344
|
+
* - SQLite support (Node.js, Bun, Cloudflare D1)
|
|
2345
|
+
* - Automatic schema sync for development/testing
|
|
2346
|
+
* - Drizzle Kit migrations for production
|
|
2347
|
+
* - Type-safe filters: `eq`, `ne`, `gt`, `gte`, `lt`, `lte`, `in`, `nin`, `like`, `between`
|
|
2348
|
+
* - JSONB column support
|
|
2349
|
+
* - Relationship joins
|
|
2367
2350
|
*
|
|
2368
|
-
* @see {@link $entity}
|
|
2369
|
-
* @see {@link $sequence}
|
|
2370
|
-
* @see {@link $repository}
|
|
2371
|
-
* @see {@link $transaction}
|
|
2372
|
-
* @see {@link NodePostgresProvider} - Node.js Postgres implementation
|
|
2373
|
-
* @see {@link NodeSqliteProvider} - Node.js SQLite implementation
|
|
2374
|
-
* @see {@link BunPostgresProvider} - Bun Postgres implementation
|
|
2375
|
-
* @see {@link BunSqliteProvider} - Bun SQLite implementation
|
|
2376
2351
|
* @module alepha.postgres
|
|
2377
2352
|
*/
|
|
2378
|
-
declare const
|
|
2353
|
+
declare const AlephaOrm: alepha26.Service<alepha26.Module>;
|
|
2379
2354
|
//#endregion
|
|
2380
|
-
export { $entity, $repository, $sequence, $transaction,
|
|
2355
|
+
export { $entity, $repository, $sequence, $transaction, AlephaOrm, BunPostgresProvider, BunSqliteProvider, BunSqliteProviderOptions, CloudflareD1Provider, D1Database, D1ExecResult, D1PreparedStatement, D1Result, DatabaseProvider, DatabaseTypeProvider, DbConflictError, DbEntityNotFoundError, DbError, DbMigrationError, DbVersionMismatchError, DrizzleKitProvider, EntityColumn, EntityColumns, EntityPrimitive, EntityPrimitiveOptions, FilterOperators, FromSchema, NodePostgresProvider, NodeSqliteProvider, NodeSqliteProviderOptions, OrderBy, OrderByClause, OrderDirection, PG_CREATED_AT, PG_DEFAULT, PG_DELETED_AT, PG_ENUM, PG_IDENTITY, PG_PRIMARY_KEY, PG_REF, PG_SERIAL, PG_UPDATED_AT, PG_VERSION, type Page, type PageQuery, PgAttr, PgAttrField, PgDefault, PgEnumOptions, PgIdentityOptions, PgPrimaryKey, PgQuery, PgQueryRelations, PgQueryWhere, PgQueryWhereOrSQL, PgRef, PgRefOptions, PgRelation, PgRelationMap, PgStatic, PgSymbolKeys, PgSymbols, Repository, RepositoryProvider, SQLLike, SchemaToTableConfig, SequencePrimitive, SequencePrimitiveOptions, SqliteProvider, StatementOptions, TObjectInsert, TObjectUpdate, TransactionContext, TransactionPrimitiveOptions, buildQueryString, bunSqliteOptions, db, drizzle_orm0 as drizzle, getAttrFields, insertSchema, legacyIdSchema, nodeSqliteOptions, pageQuerySchema, pageSchema, parseQueryString, pg, pgAttr, schema, sql, updateSchema };
|
|
2381
2356
|
//# sourceMappingURL=index.d.ts.map
|