@getstrata/core 2.2.59 → 3.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +27 -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 -254
- package/dist/entries/queue/failedJobRepository.js +19 -8
- package/dist/entries/queue/failedJobService.js +1 -0
- package/dist/entries/queue/jobRunner.js +141 -66
- package/dist/entries/queue/publicQueue.js +411 -255
- package/dist/entries/queue/queueConfig.js +61 -0
- package/dist/entries/queue/queueHandoff.js +318 -0
- package/dist/entries/queue/queueMetrics.js +989 -1384
- 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 +10433 -11347
- 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
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import type { OpenOutcome } from "../contracts/application";
|
|
2
|
+
import type { TransactionAcquisitionMetrics } from "./acquisitionMetrics";
|
|
3
|
+
import type { SqlDialect } from "./sqlDialects";
|
|
4
|
+
type SqlStatement = Readonly<{
|
|
5
|
+
text: string;
|
|
6
|
+
params: readonly unknown[];
|
|
7
|
+
}>;
|
|
8
|
+
type DatabaseDriver = "sqlite" | "pgsql" | "mysql";
|
|
9
|
+
type DatabaseCapabilities = Readonly<{
|
|
10
|
+
driver: DatabaseDriver;
|
|
11
|
+
transactions: true;
|
|
12
|
+
savepoints: boolean;
|
|
13
|
+
rowLocks: boolean;
|
|
14
|
+
postgresRls: boolean;
|
|
15
|
+
cancellableCheckout: boolean;
|
|
16
|
+
observableCheckout: boolean;
|
|
17
|
+
isolatedDiscard: boolean;
|
|
18
|
+
}>;
|
|
19
|
+
type SqliteDatabaseOptions = Readonly<{
|
|
20
|
+
driver: "sqlite";
|
|
21
|
+
filename: string;
|
|
22
|
+
}>;
|
|
23
|
+
type PostgresDatabaseOptions = Readonly<{
|
|
24
|
+
driver: "pgsql";
|
|
25
|
+
url: string;
|
|
26
|
+
max?: number;
|
|
27
|
+
idleTimeout?: number;
|
|
28
|
+
maxLifetime?: number;
|
|
29
|
+
connectionTimeout?: number;
|
|
30
|
+
}>;
|
|
31
|
+
type MysqlDatabaseOptions = Readonly<{
|
|
32
|
+
driver: "mysql";
|
|
33
|
+
url: string;
|
|
34
|
+
max?: number;
|
|
35
|
+
}>;
|
|
36
|
+
type DatabaseConnectionOptions = SqliteDatabaseOptions | PostgresDatabaseOptions | MysqlDatabaseOptions;
|
|
37
|
+
type DatabaseDefinition = Readonly<{
|
|
38
|
+
default: string;
|
|
39
|
+
connections: Readonly<Record<string, DatabaseConnectionOptions>>;
|
|
40
|
+
repositories?: readonly import("./definitions").AnyRepositoryDefinition[];
|
|
41
|
+
models?: readonly import("./definitions").AnyModelDefinition[];
|
|
42
|
+
repositoryEffects?: readonly import("./definitions").RepositoryEffectsDeclaration[];
|
|
43
|
+
preparation?: readonly import("../contracts/token").AnyServiceToken[];
|
|
44
|
+
}>;
|
|
45
|
+
type TransactionOptions = Readonly<{
|
|
46
|
+
acquisitionSignal?: AbortSignal;
|
|
47
|
+
acquisitionMetrics?: TransactionAcquisitionMetrics;
|
|
48
|
+
}>;
|
|
49
|
+
type CheckoutOptions = Readonly<{
|
|
50
|
+
signal?: AbortSignal;
|
|
51
|
+
metrics?: TransactionAcquisitionMetrics;
|
|
52
|
+
}>;
|
|
53
|
+
type FailureTag = Readonly<{
|
|
54
|
+
error: unknown;
|
|
55
|
+
}>;
|
|
56
|
+
type Decision<R> = Readonly<{
|
|
57
|
+
finish: "commit" | "rollback";
|
|
58
|
+
result: R;
|
|
59
|
+
}>;
|
|
60
|
+
type DecisionStage<R> = Readonly<{
|
|
61
|
+
kind: "callback-not-entered";
|
|
62
|
+
}> | Readonly<{
|
|
63
|
+
kind: "callback-running";
|
|
64
|
+
}> | Readonly<{
|
|
65
|
+
kind: "callback-failed";
|
|
66
|
+
error: unknown;
|
|
67
|
+
}> | Readonly<{
|
|
68
|
+
kind: "decided";
|
|
69
|
+
decision: Decision<R>;
|
|
70
|
+
}>;
|
|
71
|
+
type ControlPhase = "begin" | "savepoint" | "release-savepoint" | "rollback-to" | "commit" | "rollback";
|
|
72
|
+
type ControlEvidence = Readonly<{
|
|
73
|
+
phase: ControlPhase;
|
|
74
|
+
acknowledgement: "confirmed-reply" | "proven-not-applied" | "unknown";
|
|
75
|
+
failure: FailureTag | null;
|
|
76
|
+
}>;
|
|
77
|
+
type DataDisposition = "not-started" | "committed" | "rolled-back" | "unknown";
|
|
78
|
+
type NativeState = "idle" | "transaction-active" | "unknown";
|
|
79
|
+
type Terminal<R> = Readonly<{
|
|
80
|
+
data: DataDisposition;
|
|
81
|
+
nativeState: NativeState;
|
|
82
|
+
stage: DecisionStage<R>;
|
|
83
|
+
phases: readonly ControlEvidence[];
|
|
84
|
+
failure: FailureTag | null;
|
|
85
|
+
}>;
|
|
86
|
+
type SavepointTerminal<R> = Readonly<{
|
|
87
|
+
data: "not-started" | "released" | "rolled-back" | "unknown";
|
|
88
|
+
nativeState: NativeState;
|
|
89
|
+
stage: DecisionStage<R>;
|
|
90
|
+
phases: readonly ControlEvidence[];
|
|
91
|
+
failure: FailureTag | null;
|
|
92
|
+
}>;
|
|
93
|
+
type DisposeAck = Readonly<{
|
|
94
|
+
ok: true;
|
|
95
|
+
}> | Readonly<{
|
|
96
|
+
ok: false;
|
|
97
|
+
error: unknown;
|
|
98
|
+
ownership: "retained" | "unknown";
|
|
99
|
+
}>;
|
|
100
|
+
interface RawTransaction {
|
|
101
|
+
execute<Row>(statement: SqlStatement): Promise<readonly Row[]>;
|
|
102
|
+
savepoint<R>(work: (child: RawTransaction) => Promise<Decision<R>>): Promise<SavepointTerminal<R>>;
|
|
103
|
+
}
|
|
104
|
+
interface RawPin {
|
|
105
|
+
begin<R>(work: (tx: RawTransaction) => Promise<Decision<R>>): Promise<Terminal<R>>;
|
|
106
|
+
release(): Promise<DisposeAck>;
|
|
107
|
+
discard(): Promise<DisposeAck>;
|
|
108
|
+
}
|
|
109
|
+
interface RawPool {
|
|
110
|
+
readonly dialect: SqlDialect;
|
|
111
|
+
readonly capabilities: DatabaseCapabilities;
|
|
112
|
+
execute<Row>(statement: SqlStatement): Promise<readonly Row[]>;
|
|
113
|
+
checkout(options?: CheckoutOptions): Promise<OpenOutcome<RawPin>>;
|
|
114
|
+
close(): void | Promise<void>;
|
|
115
|
+
}
|
|
116
|
+
export type { CheckoutOptions, ControlEvidence, ControlPhase, DatabaseCapabilities, DatabaseConnectionOptions, DatabaseDefinition, DatabaseDriver, DataDisposition, Decision, DecisionStage, DisposeAck, FailureTag, MysqlDatabaseOptions, NativeState, PostgresDatabaseOptions, RawPin, RawPool, RawTransaction, SavepointTerminal, SqliteDatabaseOptions, SqlStatement, Terminal, TransactionOptions, };
|
|
@@ -1,4 +1,45 @@
|
|
|
1
|
-
|
|
1
|
+
/** A requested record does not exist, independent of its transport. */
|
|
2
|
+
declare class RecordNotFoundError extends Error {
|
|
3
|
+
constructor(message?: string);
|
|
4
|
+
}
|
|
5
|
+
/** Neutral persistence failures. Transport adapters choose response status and shape. */
|
|
6
|
+
declare const PERSISTENCE_MESSAGES: {
|
|
7
|
+
readonly DATABASE_CONFIG_INVALID: "Database configuration is invalid.";
|
|
8
|
+
readonly DATABASE_CONNECTION_UNKNOWN: "Database connection is not configured.";
|
|
9
|
+
readonly DATABASE_TRANSACTION_SCOPE: "Database transaction scope is not active.";
|
|
10
|
+
readonly DATABASE_UNSUPPORTED_CAPABILITY: "Database capability is not supported.";
|
|
11
|
+
readonly DATABASE_TRANSACTION_ROLLBACK_ONLY: "Transaction rolled back after a failed database operation.";
|
|
12
|
+
readonly DATABASE_TRANSACTION_FAILED: "Database transaction failed.";
|
|
13
|
+
readonly DATABASE_TRANSACTION_UNKNOWN: "Database transaction outcome is unknown.";
|
|
14
|
+
readonly DATABASE_POST_COMMIT_FAILED: "Database work failed after commit.";
|
|
15
|
+
readonly DATABASE_UNIQUE_CONSTRAINT: "A record with these values already exists.";
|
|
16
|
+
readonly DATABASE_FOREIGN_KEY_CONSTRAINT: "Referenced record does not exist.";
|
|
17
|
+
readonly DATABASE_REFERENCED_RECORD: "Record is still referenced by other records.";
|
|
18
|
+
readonly DATABASE_RELATED_RECORD_CONSTRAINT: "Operation conflicts with related records.";
|
|
19
|
+
readonly DATABASE_NOT_NULL_CONSTRAINT: "Required field is missing.";
|
|
20
|
+
readonly DATABASE_CHECK_CONSTRAINT: "Value violates a database constraint.";
|
|
21
|
+
readonly DATABASE_OPERATION_FAILED: "Database operation failed.";
|
|
22
|
+
};
|
|
23
|
+
type PersistenceErrorCode = keyof typeof PERSISTENCE_MESSAGES;
|
|
24
|
+
type TransactionDataDisposition = "not-started" | "committed" | "rolled-back" | "unknown";
|
|
25
|
+
type PersistenceResult = Readonly<{
|
|
26
|
+
ok: true;
|
|
27
|
+
value: unknown;
|
|
28
|
+
}> | Readonly<{
|
|
29
|
+
ok: false;
|
|
30
|
+
error: unknown;
|
|
31
|
+
}>;
|
|
32
|
+
interface PersistenceErrorOptions {
|
|
33
|
+
readonly cause?: unknown;
|
|
34
|
+
readonly data?: TransactionDataDisposition;
|
|
35
|
+
readonly result?: PersistenceResult;
|
|
36
|
+
}
|
|
37
|
+
declare class PersistenceError extends Error {
|
|
38
|
+
readonly code: PersistenceErrorCode;
|
|
39
|
+
readonly data?: TransactionDataDisposition;
|
|
40
|
+
readonly result?: PersistenceResult;
|
|
41
|
+
constructor(code: PersistenceErrorCode, options?: PersistenceErrorOptions);
|
|
42
|
+
}
|
|
2
43
|
interface PostgresErrorLike {
|
|
3
44
|
code?: string;
|
|
4
45
|
errno?: string | number;
|
|
@@ -7,11 +48,10 @@ interface PostgresErrorLike {
|
|
|
7
48
|
message?: string;
|
|
8
49
|
}
|
|
9
50
|
declare function isPostgresError(error: unknown): error is PostgresErrorLike;
|
|
10
|
-
/**
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
*/
|
|
14
|
-
declare function mapDatabaseError(error: unknown): HttpError;
|
|
51
|
+
/** Classify an actual database boundary; raw details remain an opaque, hidden cause. */
|
|
52
|
+
declare function mapDatabaseError(error: unknown): PersistenceError;
|
|
53
|
+
/** Generic operation wrappers preserve unrelated domain errors without knowing HTTP. */
|
|
15
54
|
declare function withDatabaseErrorHandling<TValue>(operation: () => Promise<TValue>): Promise<TValue>;
|
|
16
55
|
declare function isUniqueConstraintError(error: unknown): boolean;
|
|
17
|
-
export {
|
|
56
|
+
export type { PersistenceErrorCode, PersistenceErrorOptions, PersistenceResult, TransactionDataDisposition, };
|
|
57
|
+
export { isPostgresError, isUniqueConstraintError, mapDatabaseError, PersistenceError, RecordNotFoundError, withDatabaseErrorHandling, };
|
|
@@ -1,7 +1,44 @@
|
|
|
1
|
+
declare const construction: unique symbol;
|
|
2
|
+
declare const definitionType: unique symbol;
|
|
3
|
+
type FactoryPersist<R extends object> = (values: Partial<R>) => Promise<R>;
|
|
4
|
+
interface FactoryBehavior<R extends object> {
|
|
5
|
+
definition(): R;
|
|
6
|
+
persist?: FactoryPersist<R>;
|
|
7
|
+
}
|
|
8
|
+
interface FactoryConstruction<R extends object, D, S> {
|
|
9
|
+
initialState(): S;
|
|
10
|
+
forkState(state: Readonly<S>): S;
|
|
11
|
+
construct(state: S, dependencies: D): FactoryBehavior<R>;
|
|
12
|
+
}
|
|
13
|
+
interface StatelessFactoryConstruction<R extends object, D> {
|
|
14
|
+
construct(dependencies: D): FactoryBehavior<R>;
|
|
15
|
+
}
|
|
16
|
+
interface ConstructedFactory<R extends object> {
|
|
17
|
+
readonly behavior: FactoryBehavior<R>;
|
|
18
|
+
fork(): ConstructedFactory<R>;
|
|
19
|
+
}
|
|
20
|
+
interface FactoryDefinition<R extends object, D> {
|
|
21
|
+
readonly [definitionType]: {
|
|
22
|
+
readonly record: (record: R) => R;
|
|
23
|
+
readonly dependencies: (deps: D) => D;
|
|
24
|
+
};
|
|
25
|
+
readonly [construction]: (dependencies: D) => ConstructedFactory<R>;
|
|
26
|
+
}
|
|
27
|
+
declare function defineFactory<R extends object, D, S>(spec: FactoryConstruction<R, D, S>): FactoryDefinition<R, D>;
|
|
28
|
+
declare function defineFactory<R extends object, D = undefined>(spec: StatelessFactoryConstruction<R, D>): FactoryDefinition<R, D>;
|
|
29
|
+
type FactoryParent = {
|
|
30
|
+
id?: unknown;
|
|
31
|
+
getRepository?: () => {
|
|
32
|
+
getTable(): {
|
|
33
|
+
name: string;
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
};
|
|
1
37
|
type FactoryState<TRecord extends object> = Partial<TRecord> | ((record: TRecord) => Partial<TRecord>);
|
|
2
38
|
type FactorySequence<TRecord extends object> = Partial<TRecord> | ((index: number) => Partial<TRecord>);
|
|
3
39
|
type FactoryMakeResult<TRecord extends object, Counted extends boolean> = Counted extends true ? TRecord[] : TRecord;
|
|
4
40
|
declare class Factory<TRecord extends object, Counted extends boolean = false> {
|
|
41
|
+
private readonly instance;
|
|
5
42
|
private quantity;
|
|
6
43
|
private counted;
|
|
7
44
|
private sequenceIndex;
|
|
@@ -11,42 +48,25 @@ declare class Factory<TRecord extends object, Counted extends boolean = false> {
|
|
|
11
48
|
private children;
|
|
12
49
|
private afterMakingCallbacks;
|
|
13
50
|
private afterCreatingCallbacks;
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
};
|
|
19
|
-
protected definition(): TRecord;
|
|
20
|
-
protected clone(): this;
|
|
51
|
+
private constructor();
|
|
52
|
+
static from<R extends object>(definition: FactoryDefinition<R, undefined>): Factory<R>;
|
|
53
|
+
static from<R extends object, D>(definition: FactoryDefinition<R, D>, dependencies: D): Factory<R>;
|
|
54
|
+
private fork;
|
|
21
55
|
count(quantity: number): Factory<TRecord, true>;
|
|
22
56
|
state(state: FactoryState<TRecord>): Factory<TRecord, Counted>;
|
|
23
57
|
sequence(...items: Array<FactorySequence<TRecord>>): Factory<TRecord, Counted>;
|
|
24
|
-
for(parent:
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
getTable(): {
|
|
28
|
-
name: string;
|
|
29
|
-
};
|
|
30
|
-
};
|
|
31
|
-
}, foreignKey?: keyof TRecord & string): Factory<TRecord, Counted>;
|
|
32
|
-
recycle(parent: {
|
|
33
|
-
id?: unknown;
|
|
34
|
-
getRepository?: () => {
|
|
35
|
-
getTable(): {
|
|
36
|
-
name: string;
|
|
37
|
-
};
|
|
38
|
-
};
|
|
39
|
-
}, foreignKey?: keyof TRecord & string): Factory<TRecord, Counted>;
|
|
40
|
-
afterMaking(callback: (record: TRecord) => void): Factory<TRecord, Counted>;
|
|
58
|
+
for(parent: FactoryParent, foreignKey?: keyof TRecord & string): Factory<TRecord, Counted>;
|
|
59
|
+
recycle(parent: FactoryParent, foreignKey?: keyof TRecord & string): Factory<TRecord, Counted>;
|
|
60
|
+
afterMaking(callback: (record: TRecord) => undefined): Factory<TRecord, Counted>;
|
|
41
61
|
afterCreating(callback: (record: TRecord) => void | Promise<void>): Factory<TRecord, Counted>;
|
|
42
62
|
has<TRelated extends object, RelatedCounted extends boolean>(factory: Factory<TRelated, RelatedCounted>, foreignKey?: keyof TRelated & string): Factory<TRecord, Counted>;
|
|
43
63
|
make(overrides?: Partial<TRecord>): FactoryMakeResult<TRecord, Counted>;
|
|
44
64
|
create(overrides?: Partial<TRecord>): Promise<FactoryMakeResult<TRecord, Counted>>;
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
65
|
+
private makeOne;
|
|
66
|
+
private createOne;
|
|
67
|
+
private persistCreated;
|
|
68
|
+
private insertable;
|
|
69
|
+
private persist;
|
|
50
70
|
}
|
|
51
|
-
export type { FactoryMakeResult };
|
|
52
|
-
export { Factory };
|
|
71
|
+
export type { FactoryBehavior, FactoryConstruction, FactoryDefinition, FactoryMakeResult, FactoryParent, FactoryPersist, StatelessFactoryConstruction, };
|
|
72
|
+
export { defineFactory, Factory };
|
|
@@ -1,30 +1,29 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export type { AfterCommitRepositoryContext, AfterCommitRepositoryListener, BoundModel, ModelBinding, ModelDefinition, ModelObserver, ModelState, RepositoryBinding, RepositoryDefinition, RepositoryEffectsDeclaration, RepositoryHooks, TransactionalRepositoryListener, TypedRepositoryEffect, } from "@getstrata/core/database/definitions";
|
|
2
|
+
export { defineModel, defineRepository, repositoryEffects, } from "@getstrata/core/database/definitions";
|
|
3
|
+
export { mapDatabaseError, RecordNotFoundError, withDatabaseErrorHandling, } from "@getstrata/core/database/errors";
|
|
4
|
+
export type { FactoryBehavior, FactoryConstruction, FactoryDefinition, FactoryMakeResult, FactoryParent, FactoryPersist, StatelessFactoryConstruction, } from "@getstrata/core/database/factory";
|
|
5
|
+
export { defineFactory, Factory } from "@getstrata/core/database/factory";
|
|
6
|
+
export { BaseRepository, BelongsToManyRelationQuery, BelongsToRelationQuery, HasManyRelationQuery, HasManyThroughRelationQuery, HasOneRelationQuery, Model, ModelQuery, MorphManyRelationQuery, MorphOneRelationQuery, MorphToRelationQuery, RepositoryQuery, } from "#strata-orm-runtime";
|
|
2
7
|
export { createDatabaseConnection } from "./connection.ts";
|
|
3
8
|
export type { ActiveDatabaseHandle } from "./connectionContext.ts";
|
|
4
9
|
export { getActiveDatabaseConnection, hasActiveDatabaseConnection, runWithDatabaseConnection, } from "./connectionContext.ts";
|
|
5
10
|
export type { DatabaseConnection } from "./connectionContracts.ts";
|
|
6
11
|
export type { SqlDialect } from "./dialect.ts";
|
|
7
|
-
export { currentSqlDialect, dialectFor,
|
|
8
|
-
export { mapDatabaseError, withDatabaseErrorHandling } from "./errors.ts";
|
|
9
|
-
export { Factory } from "./factory.ts";
|
|
12
|
+
export { currentSqlDialect, dialectFor, runWithSqlDialect, } from "./dialect.ts";
|
|
10
13
|
export { foreignKeyFromTable, pivotTableName, singularize } from "./inflection.ts";
|
|
11
|
-
export type { CastType
|
|
12
|
-
export { applyCasts,
|
|
14
|
+
export type { CastType } from "./model.ts";
|
|
15
|
+
export { applyCasts, dehydrateValue, filterMassAssignable, hydrateValue, } from "./modelAttributes.ts";
|
|
13
16
|
export type { MysqlConnection, MysqlExecutable, MysqlPool } from "./mysqlConnection.ts";
|
|
14
17
|
export { createMysqlConnection, createMysqlConnectionFromPool, createMysqlPool, } from "./mysqlConnection.ts";
|
|
15
|
-
export type { NamedConnectionEntry } from "./namedConnections.ts";
|
|
16
|
-
export { getNamedConnection, hasNamedConnection, registerNamedConnection, resetNamedConnections, runOnNamedConnection, unregisterNamedConnection, } from "./namedConnections.ts";
|
|
17
18
|
export { projectPluck, uniqueColumnSelect } from "./pluck.ts";
|
|
18
19
|
export { buildAdvancedWhereClause, buildCountQuery, buildDeleteByIdQuery, buildGroupedCountQuery, buildInsertQuery, buildJoinClause, buildOrderByClause, buildProjectionQuery, buildQueryWhereClause, buildRestoreByIdQuery, buildSelectQuery, buildSoftDeleteByIdQuery, buildUpdateQuery, buildWhereClause, parseQualifiedColumn, qualifyColumn, quoteIdentifier, resolveQualifiedColumn, resolveSoftDeleteColumn, } from "./query.ts";
|
|
19
20
|
export type { BelongsToManyRelation, BelongsToRelation, HasManyRelation, HasManyThroughRelation, HasOneRelation, MorphManyRelation, MorphOneRelation, MorphToRelation, } from "./relationships.ts";
|
|
20
21
|
export { belongsTo, belongsToMany, hasMany, hasManyThrough, hasOne, indexBelongsToManyRelation, indexBelongsToRelation, indexHasManyRelation, indexHasManyThroughRelation, indexHasOneRelation, indexMorphManyRelation, indexMorphOneRelation, indexMorphToRelation, morphMany, morphOne, morphTo, } from "./relationships.ts";
|
|
21
|
-
export { RepositoryQuery } from "./repositoryQuery.ts";
|
|
22
22
|
export type { BlueprintAction, BlueprintCallback, ColumnKind, DatabaseDriver, ForeignKeyOptions, Grammar, IndexDefinition, IndexKind, ResolveDatabaseDriverOptions, SchemaBuilder, } from "./schema/index.ts";
|
|
23
23
|
export { Blueprint, ColumnDefinition, compileBlueprint, createSchemaBuilder, ForeignIdColumnDefinition, grammarForDriver, inferReferencedTable, MySqlGrammar, PostgresGrammar, resolveDatabaseDriver, Schema, SqliteGrammar, UnsupportedSchemaFeatureError, } from "./schema/index.ts";
|
|
24
24
|
export { createSqliteConnection } from "./sqliteConnection.ts";
|
|
25
25
|
export type { TableDefinition } from "./table.ts";
|
|
26
26
|
export { defineTable } from "./table.ts";
|
|
27
|
-
export { isActiveTransactionConnection, runInTransaction } from "./transaction.ts";
|
|
28
27
|
export type { DatabaseComparable, DatabaseScalar, MutationValues, QueryFilterValue, QueryJoin, QueryJoinOn, QueryOperator, QueryOptions, QueryOrder, QuerySelectItem, QueryWhere, UpdateValues, } from "./types.ts";
|
|
29
28
|
export type { WhereNode } from "./whereBuilder.ts";
|
|
30
29
|
export { WhereBuilder } from "./whereBuilder.ts";
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { KeysetCursor, KeysetOptions } from "../pagination/index.ts";
|
|
2
|
+
import type { SqlDialect } from "./sqlDialects.ts";
|
|
2
3
|
import type { TableDefinition } from "./table.ts";
|
|
3
4
|
import type { WhereNode } from "./whereBuilder.ts";
|
|
4
5
|
declare const KEYSET_ALIAS_PREFIX = "__strata_keyset_";
|
|
5
6
|
declare function validateKeyset<TEntity extends object, PK extends keyof TEntity & string>(table: TableDefinition<TEntity, PK>, options: KeysetOptions<TEntity>): KeysetCursor["order"];
|
|
6
|
-
declare function keysetBoundary<TEntity extends object>(order: KeysetCursor["order"], cursor?: KeysetCursor): WhereNode<TEntity>[];
|
|
7
|
+
declare function keysetBoundary<TEntity extends object>(dialect: SqlDialect, order: KeysetCursor["order"], cursor?: KeysetCursor): WhereNode<TEntity>[];
|
|
7
8
|
export { KEYSET_ALIAS_PREFIX, keysetBoundary, validateKeyset };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type ActiveDatabaseHandle } from "./connectionContext";
|
|
2
|
+
import type { RawPin } from "./driverPorts";
|
|
3
|
+
/** Only old explicit adapters enter legacy connection routing; raw pools never import this. */
|
|
4
|
+
declare function legacyNativeTransaction<R>(pin: RawPin, callback: (tx: ActiveDatabaseHandle) => Promise<R>, transactions: WeakSet<ActiveDatabaseHandle>): Promise<R>;
|
|
5
|
+
export { legacyNativeTransaction };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { DatabaseOwnership } from "#strata-orm-internal";
|
|
2
|
+
import type { RawPool } from "./driverPorts";
|
|
3
|
+
/** Resource-free immutable assembly over separately application-owned pools. */
|
|
4
|
+
declare class DatabaseManager {
|
|
5
|
+
readonly defaultConnection: string;
|
|
6
|
+
private readonly ownership;
|
|
7
|
+
private readonly pools;
|
|
8
|
+
constructor(defaultConnection: string, connections: readonly (readonly [string, RawPool])[], ownership: DatabaseOwnership);
|
|
9
|
+
configuredPool(pool: RawPool): object;
|
|
10
|
+
connection(name?: string): RawPool;
|
|
11
|
+
}
|
|
12
|
+
export { DatabaseManager };
|