@getstrata/core 2.2.60 → 3.0.4
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/CHANGELOG.md +26 -0
- package/dist/core/audit/exportAuditLogs.d.ts +12 -3
- package/dist/core/audit/exportStore.d.ts +6 -2
- package/dist/core/audit/siemFormatter.d.ts +2 -2
- package/dist/core/auth/abilityCatalog.d.ts +1 -9
- package/dist/core/auth/authContext.d.ts +2 -0
- package/dist/core/auth/authOutcome.d.ts +32 -0
- package/dist/core/auth/authReader.d.ts +22 -0
- package/dist/core/auth/basicAuthGuard.d.ts +19 -3
- package/dist/core/auth/emailVerification.d.ts +1 -1
- package/dist/core/auth/guard.d.ts +27 -6
- package/dist/core/auth/intendedUrlCookie.d.ts +13 -7
- package/dist/core/auth/jwt.d.ts +5 -4
- package/dist/core/auth/jwtGuard.d.ts +7 -6
- package/dist/core/auth/membershipContext.d.ts +10 -7
- package/dist/core/auth/membershipContextMiddleware.d.ts +3 -3
- package/dist/core/auth/membershipMiddleware.d.ts +1 -2
- package/dist/core/auth/membershipServiceImplementation.d.ts +1 -1
- package/dist/core/auth/oauth/oidcIdToken.d.ts +25 -16
- package/dist/core/auth/oauth/oidcProvider.d.ts +6 -4
- package/dist/core/auth/oauth/providers.d.ts +3 -1
- package/dist/core/auth/oneTimeToken.d.ts +2 -3
- package/dist/core/auth/passwordConfirmCookie.d.ts +15 -6
- package/dist/core/auth/passwordLogin.d.ts +5 -5
- package/dist/core/auth/pendingMfaCookie.d.ts +2 -2
- package/dist/core/auth/policy.d.ts +23 -10
- package/dist/core/auth/requireAuthCapability.d.ts +3 -0
- package/dist/core/auth/resolveMembershipService.d.ts +3 -2
- package/dist/core/auth/saml/samlAssertionReplay.d.ts +4 -4
- package/dist/core/auth/saml/samlServiceProvider.d.ts +11 -7
- package/dist/core/auth/scimAuthMiddleware.d.ts +10 -3
- package/dist/core/auth/sessionCookie.d.ts +20 -9
- package/dist/core/auth/sessionGuard.d.ts +14 -3
- package/dist/core/cache/createCacheStore.d.ts +6 -3
- package/dist/core/cache/redisCacheStore.d.ts +5 -1
- package/dist/core/cache/repository.d.ts +5 -1
- package/dist/core/cache/simpleCache.d.ts +2 -1
- package/dist/core/cache/tokens.d.ts +8 -0
- package/dist/core/config/applicationConfig.d.ts +21 -0
- package/dist/core/config/configSnapshot.d.ts +3 -0
- package/dist/core/config/envSchema.d.ts +3 -2
- package/dist/core/contracts/application.d.ts +153 -0
- package/dist/core/contracts/authUserDirectory.d.ts +24 -7
- package/dist/core/contracts/container.d.ts +20 -23
- package/dist/core/contracts/di.d.ts +4 -2
- package/dist/core/contracts/executionContext.d.ts +5 -0
- package/dist/core/contracts/executionOperations.d.ts +10 -0
- package/dist/core/contracts/executionOwnership.d.ts +38 -0
- package/dist/core/contracts/persistence.d.ts +20 -0
- package/dist/core/contracts/serviceTokens.d.ts +32 -18
- package/dist/core/contracts/services.d.ts +63 -0
- package/dist/core/contracts/token.d.ts +19 -0
- package/dist/core/crypto/fieldEncryption.d.ts +19 -7
- package/dist/core/crypto/fieldEncryptionRotation.d.ts +21 -5
- package/dist/core/crypto/mfaSecret.d.ts +10 -3
- package/dist/core/database/baseRepository.d.ts +14 -10
- package/dist/core/database/bindings.d.ts +6 -0
- package/dist/core/database/bunSql.d.ts +3 -12
- package/dist/core/database/definitions.d.ts +209 -0
- package/dist/core/database/dialect.d.ts +5 -24
- package/dist/core/database/driverPorts.d.ts +116 -0
- package/dist/core/database/errors.d.ts +47 -7
- package/dist/core/database/factory.d.ts +51 -31
- package/dist/core/database/index.d.ts +9 -10
- package/dist/core/database/keyset.d.ts +2 -1
- package/dist/core/database/legacyNativeTransaction.d.ts +5 -0
- package/dist/core/database/manager.d.ts +12 -0
- package/dist/core/database/model.d.ts +91 -97
- package/dist/core/database/modelQuery.d.ts +9 -5
- package/dist/core/database/modelRegistry.d.ts +52 -33
- package/dist/core/database/mysqlConnection.d.ts +1 -19
- package/dist/core/database/mysqlNative.d.ts +38 -0
- package/dist/core/database/nativeTransactions.d.ts +16 -0
- package/dist/core/database/ormInternal.d.ts +85 -0
- package/dist/core/database/ormRuntime.d.ts +4 -0
- package/dist/core/database/ownedReadOnlyObservation.d.ts +16 -0
- package/dist/core/database/postgresNative.d.ts +11 -0
- package/dist/core/database/query.d.ts +24 -23
- package/dist/core/database/queryPlanSnapshot.d.ts +7 -0
- package/dist/core/database/rawMysql.d.ts +7 -0
- package/dist/core/database/rawPostgres.d.ts +23 -0
- package/dist/core/database/rawSqlite.d.ts +6 -0
- package/dist/core/database/relationQueries.d.ts +3 -2
- package/dist/core/database/relationQuery.d.ts +24 -6
- package/dist/core/database/repositoryQuery.d.ts +6 -1
- package/dist/core/database/schema/driver.d.ts +1 -1
- package/dist/core/database/seeders/types.d.ts +1 -1
- package/dist/core/database/session.d.ts +13 -0
- package/dist/core/database/sessionFactory.d.ts +9 -0
- package/dist/core/database/sqlDialects.d.ts +22 -0
- package/dist/core/database/tokens.d.ts +7 -0
- package/dist/core/database/transactionSession.d.ts +43 -0
- package/dist/core/errors/http.d.ts +4 -1
- package/dist/core/events/{eventBus.d.ts → eventBusClass.d.ts} +1 -3
- package/dist/core/events/index.d.ts +2 -3
- package/dist/core/events/outbox/index.d.ts +44 -13
- package/dist/core/events/outbox/metrics.d.ts +4 -4
- package/dist/core/events/outbox/workerTransport.d.ts +17 -0
- package/dist/core/http/authMiddleware.d.ts +2 -2
- package/dist/core/http/authorizeMiddleware.d.ts +2 -2
- package/dist/core/http/bodySizeLimitMiddleware.d.ts +1 -1
- package/dist/core/http/conditionalResponse.d.ts +7 -2
- package/dist/core/http/contentSecurityPolicy.d.ts +4 -3
- package/dist/core/http/corsMiddleware.d.ts +2 -1
- package/dist/core/http/csrfMiddleware.d.ts +6 -1
- package/dist/core/http/csrfToken.d.ts +17 -7
- package/dist/core/http/databaseError.d.ts +4 -0
- package/dist/core/http/etag.d.ts +5 -2
- package/dist/core/http/flashMiddleware.d.ts +1 -1
- package/dist/core/http/flashSession.d.ts +13 -7
- package/dist/core/http/index.d.ts +1 -1
- package/dist/core/http/loginThrottleMiddleware.d.ts +3 -3
- package/dist/core/http/memoryThrottleMiddleware.d.ts +2 -2
- package/dist/core/http/parseMultipartUpload.d.ts +3 -2
- package/dist/core/http/requestMetaContext.d.ts +5 -0
- package/dist/core/http/requireAbilityMiddleware.d.ts +1 -1
- package/dist/core/http/requireAuthMiddleware.d.ts +2 -2
- package/dist/core/http/requirePasswordConfirmMiddleware.d.ts +2 -1
- package/dist/core/http/requireVerifiedMiddleware.d.ts +2 -2
- package/dist/core/http/requireWebAuthMiddleware.d.ts +2 -2
- package/dist/core/http/response.d.ts +4 -3
- package/dist/core/http/scimThrottleMiddleware.d.ts +4 -3
- package/dist/core/http/securedRouteModelBinding.d.ts +10 -3
- package/dist/core/http/securityHeadersMiddleware.d.ts +1 -2
- package/dist/core/http/signedUrl.d.ts +8 -6
- package/dist/core/http/throttleMiddleware.d.ts +9 -5
- package/dist/core/http/uploads.d.ts +9 -3
- package/dist/core/http/webErrorResponse.d.ts +8 -2
- package/dist/core/jobs/exportAuditLogsJob.d.ts +5 -2
- package/dist/core/jobs/invalidateCacheTagsJob.d.ts +5 -4
- package/dist/core/lifecycle/gracefulShutdown.d.ts +2 -5
- package/dist/core/logging/requestLoggingMiddleware.d.ts +1 -1
- package/dist/core/mail/mailer.d.ts +7 -5
- package/dist/core/openapi/generator.d.ts +12 -4
- package/dist/core/openapi/registeredRoute.d.ts +4 -4
- package/dist/core/queue/createAppQueue.d.ts +9 -4
- package/dist/core/queue/failedJobMetrics.d.ts +11 -2
- package/dist/core/queue/failedJobRepository.d.ts +6 -3
- package/dist/core/queue/failedJobService.d.ts +1 -0
- package/dist/core/queue/index.d.ts +16 -6
- package/dist/core/queue/jobRegistry.d.ts +3 -2
- package/dist/core/queue/jobRunner.d.ts +10 -4
- package/dist/core/queue/publicQueue.d.ts +18 -9
- package/dist/core/queue/queueConfig.d.ts +20 -10
- package/dist/core/queue/queueHandoff.d.ts +31 -0
- package/dist/core/queue/queueMetrics.d.ts +10 -3
- package/dist/core/queue/queueServices.d.ts +28 -0
- package/dist/core/queue/queueWorkerTransport.d.ts +28 -0
- package/dist/core/queue/redisQueue.d.ts +19 -10
- package/dist/core/queue/redisQueueKeys.d.ts +5 -5
- package/dist/core/queue/redisStreams.d.ts +17 -10
- package/dist/core/queue/resilientQueue.d.ts +10 -4
- package/dist/core/queue/types.d.ts +1 -0
- package/dist/core/runtime/appKeyPrefix.d.ts +5 -5
- package/dist/core/runtime/application.d.ts +7 -0
- package/dist/core/runtime/executionContext.d.ts +9 -0
- package/dist/core/runtime/executionTasks.d.ts +49 -0
- package/dist/core/runtime/resourceJournal.d.ts +67 -0
- package/dist/core/runtime/serviceGraph.d.ts +14 -0
- package/dist/core/security/oauthState.d.ts +13 -9
- package/dist/core/security/publicReads.d.ts +2 -2
- package/dist/core/security/safeFetch.d.ts +1 -0
- package/dist/core/security/safeUrl.d.ts +3 -0
- package/dist/core/security/scimTenantTokens.d.ts +1 -1
- package/dist/core/security/tokenExpiry.d.ts +1 -1
- package/dist/core/security/webhookSignature.d.ts +1 -1
- package/dist/core/storage/storage.d.ts +24 -16
- package/dist/core/tenant/databaseTenantContext.d.ts +5 -7
- package/dist/core/tenant/resolveTenant.d.ts +2 -2
- package/dist/core/tenant/scopedDatabasePolicy.d.ts +8 -0
- package/dist/core/tenant/tenantDatabaseScope.d.ts +3 -7
- package/dist/core/tenant/tenantMiddleware.d.ts +15 -4
- package/dist/core/tracing/otel.d.ts +4 -6
- package/dist/core/tracing/tracingMiddleware.d.ts +3 -3
- package/dist/core/view/etaViewEngine.d.ts +1 -1
- package/dist/core/view/index.d.ts +5 -4
- package/dist/core/view/tokens.d.ts +8 -0
- package/dist/core/view/viewRenderer.d.ts +2 -2
- package/dist/core/view/webErrorView.d.ts +8 -7
- package/dist/core/view/webLayoutData.d.ts +6 -4
- package/dist/entries/audit/exportAuditLogs.js +87 -1024
- package/dist/entries/audit/siemFormatter.js +4 -90
- package/dist/entries/auth/abilityCatalog.js +28 -0
- package/dist/entries/auth/accessControl.js +5 -16
- package/dist/entries/auth/accountStateMigration.js +216 -236
- package/dist/entries/auth/authOutcome.js +80 -0
- package/dist/entries/auth/authReader.js +68 -0
- package/dist/entries/auth/basicAuthGuard.js +144 -1249
- package/dist/entries/auth/emailVerification.js +2 -2
- package/dist/entries/auth/intendedUrlCookie.js +35 -59
- package/dist/entries/auth/jwt.js +22 -47
- package/dist/entries/auth/jwtGuard.js +99 -231
- package/dist/entries/auth/membershipMiddleware.js +71 -10
- package/dist/entries/auth/membershipScope.js +16 -22
- package/dist/entries/auth/membershipService.js +11 -28
- package/dist/entries/auth/oauth/oidcProvider.js +59 -64
- package/dist/entries/auth/oauth/providers.js +12 -95
- package/dist/entries/auth/oauth/samlProvider.js +53 -1080
- package/dist/entries/auth/oneTimeToken.js +27 -289
- package/dist/entries/auth/passwordConfirmCookie.js +40 -63
- package/dist/entries/auth/passwordLogin.js +94 -399
- package/dist/entries/auth/pendingMfaCookie.js +6 -6
- package/dist/entries/auth/policy.js +22 -56
- package/dist/entries/auth/saml/samlServiceProvider.js +55 -1084
- package/dist/entries/auth/scimAuthMiddleware.js +16 -3358
- package/dist/entries/auth/sessionCookie.js +58 -73
- package/dist/entries/auth/sessionGuard.js +95 -248
- package/dist/entries/auth/tokenHash.js +11 -43
- package/dist/entries/cache/createCacheStore.js +126 -117
- package/dist/entries/cache/repository.js +25 -0
- package/dist/entries/cache/simpleCache.js +12 -7
- package/dist/entries/cache/tokens.js +9 -0
- package/dist/entries/config/applicationConfig.js +163 -0
- package/dist/entries/config/envSchema.js +21 -4
- package/dist/entries/contracts/application.js +1 -0
- package/dist/entries/contracts/authUserDirectory.js +10 -0
- package/dist/entries/contracts/container.js +99 -26
- package/dist/entries/contracts/di.js +3 -0
- package/dist/entries/contracts/executionContext.js +7 -0
- package/dist/entries/contracts/executionOperations.js +7 -0
- package/dist/entries/contracts/executionOwnership.js +7 -0
- package/dist/entries/contracts/membership.js +1 -0
- package/dist/entries/contracts/persistence.js +1 -0
- package/dist/entries/contracts/serviceTokens.js +26 -116
- package/dist/entries/contracts/services.js +98 -0
- package/dist/entries/contracts/token.js +41 -0
- package/dist/entries/crypto/fieldEncryption.js +49 -50
- package/dist/entries/crypto/mfaSecret.js +86 -82
- package/dist/entries/database/acquisitionMetrics.js +107 -0
- package/dist/entries/database/baseRepository.d.ts +2 -0
- package/dist/entries/database/bindings.js +2082 -0
- package/dist/entries/database/definitions.js +175 -0
- package/dist/entries/database/errors.js +114 -89
- package/dist/entries/database/factory.js +67 -28
- package/dist/entries/database/migrations.js +172 -224
- package/dist/entries/database/model.d.ts +1 -0
- package/dist/entries/database/ownedReadOnlyObservation.js +1282 -0
- package/dist/entries/database/query.js +159 -161
- package/dist/entries/database/repositoryQuery.d.ts +1 -0
- package/dist/entries/database/repositoryQuery.js +1 -1373
- package/dist/entries/database/schema.js +216 -236
- package/dist/entries/database/session.js +1 -0
- package/dist/entries/database/sqliteConnection.js +525 -83
- package/dist/entries/database/tokens.js +9 -0
- package/dist/entries/errors/http.js +118 -1
- package/dist/entries/http/authMiddleware.js +8 -5
- package/dist/entries/http/authorizeMiddleware.js +1 -1
- package/dist/entries/http/bodySizeLimitMiddleware.js +2 -2
- package/dist/entries/http/clientIp.js +2 -2
- package/dist/entries/http/conditionalResponse.js +19 -7
- package/dist/entries/http/corsMiddleware.js +6 -101
- package/dist/entries/http/csrfMiddleware.js +92 -106
- package/dist/entries/http/csrfToken.js +58 -94
- package/dist/entries/http/etag.js +7 -4
- package/dist/entries/http/flashMiddleware.js +57 -99
- package/dist/entries/http/flashSession.js +41 -68
- package/dist/entries/http/memoryThrottleMiddleware.js +43 -186
- package/dist/entries/http/metricsMiddleware.js +2 -16
- package/dist/entries/http/parseMultipartUpload.js +15 -29
- package/dist/entries/http/requireAbilityMiddleware.js +2 -2
- package/dist/entries/http/requirePasswordConfirmMiddleware.js +19 -31
- package/dist/entries/http/requireVerifiedMiddleware.js +4 -7
- package/dist/entries/http/requireWebAuthMiddleware.js +2 -2
- package/dist/entries/http/response.js +67 -233
- package/dist/entries/http/routeMiddleware.js +0 -14
- package/dist/entries/http/scimThrottleMiddleware.js +43 -237
- package/dist/entries/http/securedRouteModelBinding.js +37 -25
- package/dist/entries/http/securityHeadersMiddleware.js +8 -25
- package/dist/entries/http/signedUrl.js +20 -110
- package/dist/entries/http/throttleMiddleware.js +41 -185
- package/dist/entries/http/uploads.js +9 -24
- package/dist/entries/jobs/exportAuditLogsJob.js +17 -1498
- package/dist/entries/jobs/invalidateCacheTagsJob.js +12 -47
- package/dist/entries/logging/requestLoggingMiddleware.js +4 -4
- package/dist/entries/mail/mailer.js +68 -78
- package/dist/entries/openapi/generator.js +33 -100
- package/dist/entries/queue/createAppQueue.js +416 -256
- package/dist/entries/queue/failedJobRepository.js +17 -8
- package/dist/entries/queue/failedJobService.js +1 -0
- package/dist/entries/queue/jobRunner.js +141 -66
- package/dist/entries/queue/publicQueue.js +411 -257
- package/dist/entries/queue/queueConfig.js +61 -0
- package/dist/entries/queue/queueHandoff.js +318 -0
- package/dist/entries/queue/queueMetrics.js +989 -1386
- package/dist/entries/queue/queueServices.js +133 -0
- package/dist/entries/queue/queueWorkerTransport.js +1703 -0
- package/dist/entries/queue/redisQueue.js +282 -180
- package/dist/entries/queue.js +6 -45
- package/dist/entries/runtime/application.js +1585 -0
- package/dist/entries/runtime/asyncContextStore.js +0 -16
- package/dist/entries/security/oauthState.js +35 -67
- package/dist/entries/security/publicReads.js +4 -4
- package/dist/entries/security/safeFetch.js +1 -0
- package/dist/entries/security/scimTenantTokens.js +3 -3
- package/dist/entries/security/tokenExpiry.js +2 -2
- package/dist/entries/security/totp.js +1 -87
- package/dist/entries/security/webhookSignature.js +2 -90
- package/dist/entries/storage/storage.js +120 -45
- package/dist/entries/tenant/databaseTenantContext.js +6 -907
- package/dist/entries/tenant/publicTenantHost.js +78 -0
- package/dist/entries/tenant/resolveTenant.js +14 -0
- package/dist/entries/tenant/scopedDatabasePolicy.js +75 -0
- package/dist/entries/tenant/tenancyConfig.js +1 -19
- package/dist/entries/tenant/tenantDatabaseScope.js +3 -892
- package/dist/entries/tracing/tracingMiddleware.js +104 -173
- package/dist/entries/view/tokens.js +11 -0
- package/dist/framework/public-api.d.ts +62 -44
- package/dist/index.js +10435 -11351
- package/dist/internal/ormInternal.js +117 -0
- package/dist/internal/ormRuntime.js +5000 -0
- package/package.json +158 -46
- package/dist/core/database/bindConnection.d.ts +0 -1
- package/dist/core/database/boundConnection.d.ts +0 -5
- package/dist/core/database/defaultConnection.d.ts +0 -7
- package/dist/core/database/namedConnections.d.ts +0 -15
- package/dist/core/database/readOnlyCollector.d.ts +0 -7
- package/dist/core/database/repositoryConnection.d.ts +0 -4
- package/dist/core/database/transaction.d.ts +0 -23
- package/dist/core/database/transactionControl.d.ts +0 -6
- package/dist/core/events/deferredModelEvents.d.ts +0 -7
- package/dist/core/facades/index.d.ts +0 -10
- package/dist/core/runtime/applicationRegistry.d.ts +0 -18
- package/dist/entries/database/bindConnection.js +0 -1
- package/dist/entries/database/boundConnection.js +0 -1
- package/dist/entries/database/defaultConnection.js +0 -1
- package/dist/entries/database/namedConnections.js +0 -1
- package/dist/entries/database/repositoryConnection.js +0 -1
- package/dist/entries/database/transaction.js +0 -1
- package/dist/entries/facades.js +0 -711
- package/dist/entries/runtime/applicationRegistry.js +0 -1
|
@@ -1,232 +1,4 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
var __esm = (fn, res, err) => () => {
|
|
3
|
-
if (fn)
|
|
4
|
-
try {
|
|
5
|
-
res = fn(fn = 0);
|
|
6
|
-
} catch (e) {
|
|
7
|
-
err = [e];
|
|
8
|
-
}
|
|
9
|
-
if (err)
|
|
10
|
-
throw err[0];
|
|
11
|
-
return res;
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
// ../../src/core/database/schema/driver.ts
|
|
15
|
-
function normalizeConnectionName(connection) {
|
|
16
|
-
const normalized = connection.trim().toLowerCase();
|
|
17
|
-
if (normalized === "pgsql" || normalized === "postgres" || normalized === "postgresql") {
|
|
18
|
-
return "pgsql";
|
|
19
|
-
}
|
|
20
|
-
if (normalized === "mysql" || normalized === "mariadb") {
|
|
21
|
-
return "mysql";
|
|
22
|
-
}
|
|
23
|
-
if (normalized === "sqlite") {
|
|
24
|
-
return "sqlite";
|
|
25
|
-
}
|
|
26
|
-
throw new Error(`Unsupported DB_CONNECTION: ${connection}`);
|
|
27
|
-
}
|
|
28
|
-
function resolveDriverFromUrl(url) {
|
|
29
|
-
const normalized = url.trim().toLowerCase();
|
|
30
|
-
if (normalized.startsWith("postgres://") || normalized.startsWith("postgresql://") || normalized.startsWith("postgres:")) {
|
|
31
|
-
return "pgsql";
|
|
32
|
-
}
|
|
33
|
-
if (normalized.startsWith("mysql://") || normalized.startsWith("mysql:")) {
|
|
34
|
-
return "mysql";
|
|
35
|
-
}
|
|
36
|
-
if (normalized.startsWith("sqlite:")) {
|
|
37
|
-
return "sqlite";
|
|
38
|
-
}
|
|
39
|
-
return null;
|
|
40
|
-
}
|
|
41
|
-
function resolveDatabaseDriver(options = {}) {
|
|
42
|
-
const connection = options.connection ?? process.env.DB_CONNECTION;
|
|
43
|
-
if (connection) {
|
|
44
|
-
return normalizeConnectionName(connection);
|
|
45
|
-
}
|
|
46
|
-
const url = options.url ?? process.env.DATABASE_URL ?? "";
|
|
47
|
-
const fromUrl = resolveDriverFromUrl(url);
|
|
48
|
-
if (fromUrl) {
|
|
49
|
-
return fromUrl;
|
|
50
|
-
}
|
|
51
|
-
return "pgsql";
|
|
52
|
-
}
|
|
53
|
-
var init_driver = () => {};
|
|
54
|
-
|
|
55
|
-
// ../../src/core/runtime/asyncContextStore.ts
|
|
56
|
-
import { AsyncLocalStorage } from "async_hooks";
|
|
57
|
-
function createAsyncContextStore(key) {
|
|
58
|
-
const symbol = Symbol.for(key);
|
|
59
|
-
const globalRecord = globalThis;
|
|
60
|
-
const existing = globalRecord[symbol];
|
|
61
|
-
if (existing) {
|
|
62
|
-
return existing;
|
|
63
|
-
}
|
|
64
|
-
const store = new AsyncLocalStorage;
|
|
65
|
-
globalRecord[symbol] = store;
|
|
66
|
-
return store;
|
|
67
|
-
}
|
|
68
|
-
var init_asyncContextStore = () => {};
|
|
69
|
-
|
|
70
|
-
// ../../src/core/database/dialect.ts
|
|
71
|
-
function assertSafeIdentifier(identifier) {
|
|
72
|
-
if (!/^[A-Za-z_][A-Za-z0-9_]*$/.test(identifier)) {
|
|
73
|
-
throw new Error(`Invalid SQL identifier: ${identifier}`);
|
|
74
|
-
}
|
|
75
|
-
return identifier;
|
|
76
|
-
}
|
|
77
|
-
function quoteIdentifierFor(dialect, column) {
|
|
78
|
-
return dialect.quoteIdentifier(column);
|
|
79
|
-
}
|
|
80
|
-
function dialectFor(driver) {
|
|
81
|
-
return dialects[driver];
|
|
82
|
-
}
|
|
83
|
-
function currentSqlDialect() {
|
|
84
|
-
return dialectContext.getStore() ?? dialectOverride ?? dialectFor(resolveDatabaseDriver());
|
|
85
|
-
}
|
|
86
|
-
var postgresDialect, mysqlDialect, sqliteDialect, dialects, dialectContext, dialectOverride = null;
|
|
87
|
-
var init_dialect = __esm(() => {
|
|
88
|
-
init_asyncContextStore();
|
|
89
|
-
init_driver();
|
|
90
|
-
postgresDialect = {
|
|
91
|
-
driver: "pgsql",
|
|
92
|
-
placeholder(index) {
|
|
93
|
-
return `$${index}`;
|
|
94
|
-
},
|
|
95
|
-
quoteIdentifier(identifier) {
|
|
96
|
-
return `"${assertSafeIdentifier(identifier)}"`;
|
|
97
|
-
},
|
|
98
|
-
nowExpression() {
|
|
99
|
-
return "NOW()";
|
|
100
|
-
},
|
|
101
|
-
epochMillisecondsExpression() {
|
|
102
|
-
return "CAST(EXTRACT(EPOCH FROM clock_timestamp()) * 1000 AS BIGINT)";
|
|
103
|
-
},
|
|
104
|
-
rowLockClause(skipLocked = false) {
|
|
105
|
-
return ` FOR UPDATE${skipLocked ? " SKIP LOCKED" : ""}`;
|
|
106
|
-
},
|
|
107
|
-
timestampValue(value) {
|
|
108
|
-
return value.toISOString();
|
|
109
|
-
},
|
|
110
|
-
returningClause(columns) {
|
|
111
|
-
return ` RETURNING ${columns}`;
|
|
112
|
-
},
|
|
113
|
-
ilikeOperator() {
|
|
114
|
-
return "ILIKE";
|
|
115
|
-
},
|
|
116
|
-
nullsLastSuffix() {
|
|
117
|
-
return " NULLS LAST";
|
|
118
|
-
},
|
|
119
|
-
castToText(expression) {
|
|
120
|
-
return `${expression}::text`;
|
|
121
|
-
},
|
|
122
|
-
upsertSuffix(conflictColumns, updateColumns) {
|
|
123
|
-
const target = conflictColumns.map((column) => quoteIdentifierFor(this, column)).join(", ");
|
|
124
|
-
if (updateColumns.length === 0) {
|
|
125
|
-
return ` ON CONFLICT (${target}) DO NOTHING`;
|
|
126
|
-
}
|
|
127
|
-
const assignments = updateColumns.map((column) => {
|
|
128
|
-
const quoted = quoteIdentifierFor(this, column);
|
|
129
|
-
return `${quoted} = excluded.${quoted}`;
|
|
130
|
-
}).join(", ");
|
|
131
|
-
return ` ON CONFLICT (${target}) DO UPDATE SET ${assignments}`;
|
|
132
|
-
}
|
|
133
|
-
};
|
|
134
|
-
mysqlDialect = {
|
|
135
|
-
driver: "mysql",
|
|
136
|
-
placeholder() {
|
|
137
|
-
return "?";
|
|
138
|
-
},
|
|
139
|
-
quoteIdentifier(identifier) {
|
|
140
|
-
return `\`${assertSafeIdentifier(identifier)}\``;
|
|
141
|
-
},
|
|
142
|
-
nowExpression() {
|
|
143
|
-
return "CURRENT_TIMESTAMP";
|
|
144
|
-
},
|
|
145
|
-
epochMillisecondsExpression() {
|
|
146
|
-
return "CAST(UNIX_TIMESTAMP(CURRENT_TIMESTAMP(3)) * 1000 AS UNSIGNED)";
|
|
147
|
-
},
|
|
148
|
-
rowLockClause(skipLocked = false) {
|
|
149
|
-
return ` FOR UPDATE${skipLocked ? " SKIP LOCKED" : ""}`;
|
|
150
|
-
},
|
|
151
|
-
timestampValue(value) {
|
|
152
|
-
return value.toISOString().slice(0, 19).replace("T", " ");
|
|
153
|
-
},
|
|
154
|
-
returningClause() {
|
|
155
|
-
return "";
|
|
156
|
-
},
|
|
157
|
-
ilikeOperator() {
|
|
158
|
-
return "LIKE";
|
|
159
|
-
},
|
|
160
|
-
nullsLastSuffix() {
|
|
161
|
-
return "";
|
|
162
|
-
},
|
|
163
|
-
castToText(expression) {
|
|
164
|
-
return `CAST(${expression} AS CHAR)`;
|
|
165
|
-
},
|
|
166
|
-
upsertSuffix(conflictColumns, updateColumns) {
|
|
167
|
-
if (updateColumns.length === 0) {
|
|
168
|
-
const anchor = quoteIdentifierFor(this, conflictColumns[0] ?? "");
|
|
169
|
-
return ` ON DUPLICATE KEY UPDATE ${anchor} = ${anchor}`;
|
|
170
|
-
}
|
|
171
|
-
const assignments = updateColumns.map((column) => {
|
|
172
|
-
const quoted = quoteIdentifierFor(this, column);
|
|
173
|
-
return `${quoted} = VALUES(${quoted})`;
|
|
174
|
-
}).join(", ");
|
|
175
|
-
return ` ON DUPLICATE KEY UPDATE ${assignments}`;
|
|
176
|
-
}
|
|
177
|
-
};
|
|
178
|
-
sqliteDialect = {
|
|
179
|
-
driver: "sqlite",
|
|
180
|
-
placeholder() {
|
|
181
|
-
return "?";
|
|
182
|
-
},
|
|
183
|
-
quoteIdentifier(identifier) {
|
|
184
|
-
return `"${assertSafeIdentifier(identifier)}"`;
|
|
185
|
-
},
|
|
186
|
-
nowExpression() {
|
|
187
|
-
return "strftime('%Y-%m-%dT%H:%M:%fZ', 'now')";
|
|
188
|
-
},
|
|
189
|
-
epochMillisecondsExpression() {
|
|
190
|
-
return "CAST((julianday('now') - 2440587.5) * 86400000 AS INTEGER)";
|
|
191
|
-
},
|
|
192
|
-
rowLockClause() {
|
|
193
|
-
return "";
|
|
194
|
-
},
|
|
195
|
-
timestampValue(value) {
|
|
196
|
-
return value.toISOString();
|
|
197
|
-
},
|
|
198
|
-
returningClause(columns) {
|
|
199
|
-
return ` RETURNING ${columns}`;
|
|
200
|
-
},
|
|
201
|
-
ilikeOperator() {
|
|
202
|
-
return "LIKE";
|
|
203
|
-
},
|
|
204
|
-
nullsLastSuffix() {
|
|
205
|
-
return "";
|
|
206
|
-
},
|
|
207
|
-
castToText(expression) {
|
|
208
|
-
return `CAST(${expression} AS TEXT)`;
|
|
209
|
-
},
|
|
210
|
-
upsertSuffix(conflictColumns, updateColumns) {
|
|
211
|
-
const target = conflictColumns.map((column) => quoteIdentifierFor(this, column)).join(", ");
|
|
212
|
-
if (updateColumns.length === 0) {
|
|
213
|
-
return ` ON CONFLICT (${target}) DO NOTHING`;
|
|
214
|
-
}
|
|
215
|
-
const assignments = updateColumns.map((column) => {
|
|
216
|
-
const quoted = quoteIdentifierFor(this, column);
|
|
217
|
-
return `${quoted} = excluded.${quoted}`;
|
|
218
|
-
}).join(", ");
|
|
219
|
-
return ` ON CONFLICT (${target}) DO UPDATE SET ${assignments}`;
|
|
220
|
-
}
|
|
221
|
-
};
|
|
222
|
-
dialects = {
|
|
223
|
-
pgsql: postgresDialect,
|
|
224
|
-
mysql: mysqlDialect,
|
|
225
|
-
sqlite: sqliteDialect
|
|
226
|
-
};
|
|
227
|
-
dialectContext = createAsyncContextStore("@getstrata/sqlDialect");
|
|
228
|
-
});
|
|
229
|
-
|
|
230
2
|
// ../../src/core/database/schema/columnDefinition.ts
|
|
231
3
|
class ColumnDefinition {
|
|
232
4
|
name;
|
|
@@ -482,10 +254,45 @@ class Blueprint {
|
|
|
482
254
|
});
|
|
483
255
|
}
|
|
484
256
|
}
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
257
|
+
// ../../src/core/database/schema/driver.ts
|
|
258
|
+
function normalizeConnectionName(connection) {
|
|
259
|
+
const normalized = connection.trim().toLowerCase();
|
|
260
|
+
if (normalized === "pgsql" || normalized === "postgres" || normalized === "postgresql") {
|
|
261
|
+
return "pgsql";
|
|
262
|
+
}
|
|
263
|
+
if (normalized === "mysql" || normalized === "mariadb") {
|
|
264
|
+
return "mysql";
|
|
265
|
+
}
|
|
266
|
+
if (normalized === "sqlite") {
|
|
267
|
+
return "sqlite";
|
|
268
|
+
}
|
|
269
|
+
throw new Error(`Unsupported DB_CONNECTION: ${connection}`);
|
|
270
|
+
}
|
|
271
|
+
function resolveDriverFromUrl(url) {
|
|
272
|
+
const normalized = url.trim().toLowerCase();
|
|
273
|
+
if (normalized.startsWith("postgres://") || normalized.startsWith("postgresql://") || normalized.startsWith("postgres:")) {
|
|
274
|
+
return "pgsql";
|
|
275
|
+
}
|
|
276
|
+
if (normalized.startsWith("mysql://") || normalized.startsWith("mysql:")) {
|
|
277
|
+
return "mysql";
|
|
278
|
+
}
|
|
279
|
+
if (normalized.startsWith("sqlite:")) {
|
|
280
|
+
return "sqlite";
|
|
281
|
+
}
|
|
282
|
+
return null;
|
|
283
|
+
}
|
|
284
|
+
function resolveDatabaseDriver(options) {
|
|
285
|
+
const connection = options.connection;
|
|
286
|
+
if (connection) {
|
|
287
|
+
return normalizeConnectionName(connection);
|
|
288
|
+
}
|
|
289
|
+
const url = options.url ?? "";
|
|
290
|
+
const fromUrl = resolveDriverFromUrl(url);
|
|
291
|
+
if (fromUrl) {
|
|
292
|
+
return fromUrl;
|
|
293
|
+
}
|
|
294
|
+
throw new Error("An explicit database connection or supported database URL is required.");
|
|
295
|
+
}
|
|
489
296
|
// ../../src/core/database/schema/errors.ts
|
|
490
297
|
class UnsupportedSchemaFeatureError extends Error {
|
|
491
298
|
constructor(feature, driver) {
|
|
@@ -493,8 +300,182 @@ class UnsupportedSchemaFeatureError extends Error {
|
|
|
493
300
|
this.name = "UnsupportedSchemaFeatureError";
|
|
494
301
|
}
|
|
495
302
|
}
|
|
496
|
-
// ../../src/core/
|
|
497
|
-
|
|
303
|
+
// ../../src/core/runtime/asyncContextStore.ts
|
|
304
|
+
import { AsyncLocalStorage } from "async_hooks";
|
|
305
|
+
function createAsyncContextStore(key) {
|
|
306
|
+
const symbol = Symbol.for(key);
|
|
307
|
+
const globalRecord = globalThis;
|
|
308
|
+
const existing = globalRecord[symbol];
|
|
309
|
+
if (existing) {
|
|
310
|
+
return existing;
|
|
311
|
+
}
|
|
312
|
+
const store = new AsyncLocalStorage;
|
|
313
|
+
globalRecord[symbol] = store;
|
|
314
|
+
return store;
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
// ../../src/core/database/sqlDialects.ts
|
|
318
|
+
function assertSafeIdentifier(identifier) {
|
|
319
|
+
if (!/^[A-Za-z_][A-Za-z0-9_]*$/.test(identifier)) {
|
|
320
|
+
throw new Error(`Invalid SQL identifier: ${identifier}`);
|
|
321
|
+
}
|
|
322
|
+
return identifier;
|
|
323
|
+
}
|
|
324
|
+
function quoteIdentifierFor(dialect, column) {
|
|
325
|
+
return dialect.quoteIdentifier(column);
|
|
326
|
+
}
|
|
327
|
+
var postgresDialect = Object.freeze({
|
|
328
|
+
driver: "pgsql",
|
|
329
|
+
placeholder(index) {
|
|
330
|
+
return `$${index}`;
|
|
331
|
+
},
|
|
332
|
+
quoteIdentifier(identifier) {
|
|
333
|
+
return `"${assertSafeIdentifier(identifier)}"`;
|
|
334
|
+
},
|
|
335
|
+
nowExpression() {
|
|
336
|
+
return "NOW()";
|
|
337
|
+
},
|
|
338
|
+
epochMillisecondsExpression() {
|
|
339
|
+
return "CAST(EXTRACT(EPOCH FROM clock_timestamp()) * 1000 AS BIGINT)";
|
|
340
|
+
},
|
|
341
|
+
rowLockClause(skipLocked = false) {
|
|
342
|
+
return ` FOR UPDATE${skipLocked ? " SKIP LOCKED" : ""}`;
|
|
343
|
+
},
|
|
344
|
+
timestampValue(value) {
|
|
345
|
+
return value.toISOString();
|
|
346
|
+
},
|
|
347
|
+
returningClause(columns) {
|
|
348
|
+
return ` RETURNING ${columns}`;
|
|
349
|
+
},
|
|
350
|
+
ilikeOperator() {
|
|
351
|
+
return "ILIKE";
|
|
352
|
+
},
|
|
353
|
+
nullsLastSuffix() {
|
|
354
|
+
return " NULLS LAST";
|
|
355
|
+
},
|
|
356
|
+
castToText(expression) {
|
|
357
|
+
return `${expression}::text`;
|
|
358
|
+
},
|
|
359
|
+
upsertSuffix(conflictColumns, updateColumns) {
|
|
360
|
+
const target = conflictColumns.map((column) => quoteIdentifierFor(this, column)).join(", ");
|
|
361
|
+
if (updateColumns.length === 0) {
|
|
362
|
+
return ` ON CONFLICT (${target}) DO NOTHING`;
|
|
363
|
+
}
|
|
364
|
+
const assignments = updateColumns.map((column) => {
|
|
365
|
+
const quoted = quoteIdentifierFor(this, column);
|
|
366
|
+
return `${quoted} = excluded.${quoted}`;
|
|
367
|
+
}).join(", ");
|
|
368
|
+
return ` ON CONFLICT (${target}) DO UPDATE SET ${assignments}`;
|
|
369
|
+
}
|
|
370
|
+
});
|
|
371
|
+
var mysqlDialect = Object.freeze({
|
|
372
|
+
driver: "mysql",
|
|
373
|
+
placeholder() {
|
|
374
|
+
return "?";
|
|
375
|
+
},
|
|
376
|
+
quoteIdentifier(identifier) {
|
|
377
|
+
return `\`${assertSafeIdentifier(identifier)}\``;
|
|
378
|
+
},
|
|
379
|
+
nowExpression() {
|
|
380
|
+
return "CURRENT_TIMESTAMP";
|
|
381
|
+
},
|
|
382
|
+
epochMillisecondsExpression() {
|
|
383
|
+
return "CAST(UNIX_TIMESTAMP(CURRENT_TIMESTAMP(3)) * 1000 AS UNSIGNED)";
|
|
384
|
+
},
|
|
385
|
+
rowLockClause(skipLocked = false) {
|
|
386
|
+
return ` FOR UPDATE${skipLocked ? " SKIP LOCKED" : ""}`;
|
|
387
|
+
},
|
|
388
|
+
timestampValue(value) {
|
|
389
|
+
return value.toISOString().slice(0, 19).replace("T", " ");
|
|
390
|
+
},
|
|
391
|
+
returningClause() {
|
|
392
|
+
return "";
|
|
393
|
+
},
|
|
394
|
+
ilikeOperator() {
|
|
395
|
+
return "LIKE";
|
|
396
|
+
},
|
|
397
|
+
nullsLastSuffix() {
|
|
398
|
+
return "";
|
|
399
|
+
},
|
|
400
|
+
castToText(expression) {
|
|
401
|
+
return `CAST(${expression} AS CHAR)`;
|
|
402
|
+
},
|
|
403
|
+
upsertSuffix(conflictColumns, updateColumns) {
|
|
404
|
+
if (updateColumns.length === 0) {
|
|
405
|
+
const anchor = quoteIdentifierFor(this, conflictColumns[0] ?? "");
|
|
406
|
+
return ` ON DUPLICATE KEY UPDATE ${anchor} = ${anchor}`;
|
|
407
|
+
}
|
|
408
|
+
const assignments = updateColumns.map((column) => {
|
|
409
|
+
const quoted = quoteIdentifierFor(this, column);
|
|
410
|
+
return `${quoted} = VALUES(${quoted})`;
|
|
411
|
+
}).join(", ");
|
|
412
|
+
return ` ON DUPLICATE KEY UPDATE ${assignments}`;
|
|
413
|
+
}
|
|
414
|
+
});
|
|
415
|
+
var sqliteDialect = Object.freeze({
|
|
416
|
+
driver: "sqlite",
|
|
417
|
+
placeholder() {
|
|
418
|
+
return "?";
|
|
419
|
+
},
|
|
420
|
+
quoteIdentifier(identifier) {
|
|
421
|
+
return `"${assertSafeIdentifier(identifier)}"`;
|
|
422
|
+
},
|
|
423
|
+
nowExpression() {
|
|
424
|
+
return "strftime('%Y-%m-%dT%H:%M:%fZ', 'now')";
|
|
425
|
+
},
|
|
426
|
+
epochMillisecondsExpression() {
|
|
427
|
+
return "CAST((julianday('now') - 2440587.5) * 86400000 AS INTEGER)";
|
|
428
|
+
},
|
|
429
|
+
rowLockClause() {
|
|
430
|
+
return "";
|
|
431
|
+
},
|
|
432
|
+
timestampValue(value) {
|
|
433
|
+
return value.toISOString();
|
|
434
|
+
},
|
|
435
|
+
returningClause(columns) {
|
|
436
|
+
return ` RETURNING ${columns}`;
|
|
437
|
+
},
|
|
438
|
+
ilikeOperator() {
|
|
439
|
+
return "LIKE";
|
|
440
|
+
},
|
|
441
|
+
nullsLastSuffix() {
|
|
442
|
+
return "";
|
|
443
|
+
},
|
|
444
|
+
castToText(expression) {
|
|
445
|
+
return `CAST(${expression} AS TEXT)`;
|
|
446
|
+
},
|
|
447
|
+
upsertSuffix(conflictColumns, updateColumns) {
|
|
448
|
+
const target = conflictColumns.map((column) => quoteIdentifierFor(this, column)).join(", ");
|
|
449
|
+
if (updateColumns.length === 0) {
|
|
450
|
+
return ` ON CONFLICT (${target}) DO NOTHING`;
|
|
451
|
+
}
|
|
452
|
+
const assignments = updateColumns.map((column) => {
|
|
453
|
+
const quoted = quoteIdentifierFor(this, column);
|
|
454
|
+
return `${quoted} = excluded.${quoted}`;
|
|
455
|
+
}).join(", ");
|
|
456
|
+
return ` ON CONFLICT (${target}) DO UPDATE SET ${assignments}`;
|
|
457
|
+
}
|
|
458
|
+
});
|
|
459
|
+
var dialects = Object.freeze({
|
|
460
|
+
pgsql: postgresDialect,
|
|
461
|
+
mysql: mysqlDialect,
|
|
462
|
+
sqlite: sqliteDialect
|
|
463
|
+
});
|
|
464
|
+
function dialectFor(driver) {
|
|
465
|
+
if (!Object.hasOwn(dialects, driver))
|
|
466
|
+
throw new TypeError("Unsupported SQL driver.");
|
|
467
|
+
return dialects[driver];
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
// ../../src/core/database/dialect.ts
|
|
471
|
+
var dialectContext = createAsyncContextStore("@getstrata/sqlDialect");
|
|
472
|
+
function currentSqlDialect() {
|
|
473
|
+
const dialect = dialectContext.getStore();
|
|
474
|
+
if (!dialect) {
|
|
475
|
+
throw new Error("SQL dialect context is required. Use runWithSqlDialect(driver, callback).");
|
|
476
|
+
}
|
|
477
|
+
return dialect;
|
|
478
|
+
}
|
|
498
479
|
|
|
499
480
|
// ../../src/core/database/schema/grammars/grammar.ts
|
|
500
481
|
function compileColumnType(driver, column) {
|
|
@@ -839,7 +820,6 @@ function grammarForDriver(driver) {
|
|
|
839
820
|
}
|
|
840
821
|
}
|
|
841
822
|
// ../../src/core/database/schema/schema.ts
|
|
842
|
-
init_driver();
|
|
843
823
|
class SchemaBuilder {
|
|
844
824
|
#driver;
|
|
845
825
|
#statements = [];
|
|
@@ -875,7 +855,7 @@ class SchemaBuilder {
|
|
|
875
855
|
|
|
876
856
|
class Schema {
|
|
877
857
|
static builder(driver) {
|
|
878
|
-
return new SchemaBuilder(driver ??
|
|
858
|
+
return new SchemaBuilder(driver ?? currentSqlDialect().driver);
|
|
879
859
|
}
|
|
880
860
|
static async run(db, driver, callback) {
|
|
881
861
|
const schema = Schema.builder(driver);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
// @bun
|