@db3.ai/app 0.1.0-beta.1
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/LICENSE +31 -0
- package/README.md +241 -0
- package/agent-instructions.md +69 -0
- package/bin/db3-agents.mjs +140 -0
- package/bin/db3.mjs +11 -0
- package/dist/ai/AIErrors.d.ts +33 -0
- package/dist/ai/AIErrors.js +43 -0
- package/dist/ai/AIFailover.d.ts +25 -0
- package/dist/ai/AIFailover.js +96 -0
- package/dist/ai/AIProviders.d.ts +35 -0
- package/dist/ai/AIProviders.js +197 -0
- package/dist/ai/AIQuotaDeferredError.d.ts +19 -0
- package/dist/ai/AIQuotaDeferredError.js +25 -0
- package/dist/ai/AIRateLimiter.d.ts +103 -0
- package/dist/ai/AIRateLimiter.js +690 -0
- package/dist/ai/Agent.d.ts +633 -0
- package/dist/ai/Agent.js +2976 -0
- package/dist/ai/AgentHistory.d.ts +11 -0
- package/dist/ai/AgentHistory.js +495 -0
- package/dist/ai/AgentRunJob.d.ts +21 -0
- package/dist/ai/AgentRunJob.js +53 -0
- package/dist/ai/Ai.d.ts +375 -0
- package/dist/ai/Ai.js +1771 -0
- package/dist/ai/AiConversation.d.ts +17 -0
- package/dist/ai/AiConversation.js +38 -0
- package/dist/ai/AiExecutionContext.d.ts +7 -0
- package/dist/ai/AiExecutionContext.js +16 -0
- package/dist/ai/AiMessage.d.ts +43 -0
- package/dist/ai/AiMessage.js +105 -0
- package/dist/ai/AiRateLimitBucket.d.ts +69 -0
- package/dist/ai/AiRateLimitBucket.js +138 -0
- package/dist/ai/AiRateLimitReservation.d.ts +56 -0
- package/dist/ai/AiRateLimitReservation.js +101 -0
- package/dist/ai/AiRequest.d.ts +78 -0
- package/dist/ai/AiRequest.js +384 -0
- package/dist/ai/Estimates.d.ts +26 -0
- package/dist/ai/Estimates.js +34 -0
- package/dist/ai/Models.d.ts +88 -0
- package/dist/ai/Models.js +328 -0
- package/dist/ai/OpenAIProviderError.d.ts +30 -0
- package/dist/ai/OpenAIProviderError.js +77 -0
- package/dist/ai/OpenAIQuotaRetry.d.ts +27 -0
- package/dist/ai/OpenAIQuotaRetry.js +144 -0
- package/dist/ai/ProviderCosts.d.ts +55 -0
- package/dist/ai/ProviderCosts.js +108 -0
- package/dist/ai/ResponsesProviderCall.d.ts +13 -0
- package/dist/ai/ResponsesProviderCall.js +29 -0
- package/dist/ai/agentCitations.d.ts +27 -0
- package/dist/ai/agentCitations.js +153 -0
- package/dist/ai/contracts/AI.d.ts +347 -0
- package/dist/ai/contracts/AI.js +13 -0
- package/dist/ai/contracts/Agent.d.ts +476 -0
- package/dist/ai/contracts/Agent.js +1 -0
- package/dist/ai/contracts/AiRequestRunCostSummary.d.ts +31 -0
- package/dist/ai/contracts/AiRequestRunCostSummary.js +1 -0
- package/dist/ai/contracts/Pricing.d.ts +88 -0
- package/dist/ai/contracts/Pricing.js +1 -0
- package/dist/ai/contracts/Providers.d.ts +68 -0
- package/dist/ai/contracts/Providers.js +1 -0
- package/dist/ai/contracts/QuotaRetry.d.ts +38 -0
- package/dist/ai/contracts/QuotaRetry.js +1 -0
- package/dist/ai/contracts/RateLimits.d.ts +45 -0
- package/dist/ai/contracts/RateLimits.js +1 -0
- package/dist/ai/contracts/ResponsesProviderCall.d.ts +28 -0
- package/dist/ai/contracts/ResponsesProviderCall.js +1 -0
- package/dist/ai/contracts/index.d.ts +8 -0
- package/dist/ai/contracts/index.js +8 -0
- package/dist/ai/index.d.ts +27 -0
- package/dist/ai/index.js +27 -0
- package/dist/ai/registry.d.ts +28 -0
- package/dist/ai/registry.js +49 -0
- package/dist/ai/sdkNodeCompatibility.d.ts +76 -0
- package/dist/ai/toolCallRecovery.d.ts +16 -0
- package/dist/ai/toolCallRecovery.js +71 -0
- package/dist/ai/toolHelpers.d.ts +65 -0
- package/dist/ai/toolHelpers.js +106 -0
- package/dist/auth/Auth.d.ts +641 -0
- package/dist/auth/Auth.js +927 -0
- package/dist/auth/AuthProvider.d.ts +104 -0
- package/dist/auth/AuthProvider.js +185 -0
- package/dist/auth/AuthToken.d.ts +123 -0
- package/dist/auth/AuthToken.js +156 -0
- package/dist/auth/PasswordResetToken.d.ts +33 -0
- package/dist/auth/PasswordResetToken.js +64 -0
- package/dist/auth/UserIdentity.d.ts +46 -0
- package/dist/auth/UserIdentity.js +72 -0
- package/dist/auth/contracts/AuthProviderDriver.d.ts +94 -0
- package/dist/auth/contracts/AuthProviderDriver.js +1 -0
- package/dist/auth/contracts/index.d.ts +1 -0
- package/dist/auth/contracts/index.js +1 -0
- package/dist/auth/index.d.ts +8 -0
- package/dist/auth/index.js +8 -0
- package/dist/auth/passwordHash.d.ts +26 -0
- package/dist/auth/passwordHash.js +96 -0
- package/dist/auth/providers/GoogleAuthProvider.d.ts +135 -0
- package/dist/auth/providers/GoogleAuthProvider.js +305 -0
- package/dist/auth/providers/PasswordAuthProvider.d.ts +115 -0
- package/dist/auth/providers/PasswordAuthProvider.js +195 -0
- package/dist/auth/providers/index.d.ts +3 -0
- package/dist/auth/providers/index.js +3 -0
- package/dist/auth/providers/resolveAuthProviders.d.ts +29 -0
- package/dist/auth/providers/resolveAuthProviders.js +111 -0
- package/dist/cache/Cache.d.ts +67 -0
- package/dist/cache/Cache.js +115 -0
- package/dist/cache/contracts/CacheDriver.d.ts +10 -0
- package/dist/cache/contracts/CacheDriver.js +1 -0
- package/dist/cache/contracts/CacheOperations.d.ts +26 -0
- package/dist/cache/contracts/CacheOperations.js +1 -0
- package/dist/cache/contracts/CacheOptions.d.ts +51 -0
- package/dist/cache/contracts/CacheOptions.js +1 -0
- package/dist/cache/contracts/CacheRepository.d.ts +45 -0
- package/dist/cache/contracts/CacheRepository.js +1 -0
- package/dist/cache/contracts/index.d.ts +4 -0
- package/dist/cache/contracts/index.js +4 -0
- package/dist/cache/drivers/CacheManagerDriver.d.ts +55 -0
- package/dist/cache/drivers/CacheManagerDriver.js +68 -0
- package/dist/cache/drivers/createCacheDriver.d.ts +8 -0
- package/dist/cache/drivers/createCacheDriver.js +147 -0
- package/dist/cache/index.d.ts +2 -0
- package/dist/cache/index.js +2 -0
- package/dist/cli/Cli.d.ts +17 -0
- package/dist/cli/Cli.js +120 -0
- package/dist/cli/commands/repl.d.ts +9 -0
- package/dist/cli/commands/repl.js +27 -0
- package/dist/cli/contracts/CliCommand.d.ts +30 -0
- package/dist/cli/contracts/CliCommand.js +1 -0
- package/dist/cli/contracts/CliConfig.d.ts +9 -0
- package/dist/cli/contracts/CliConfig.js +1 -0
- package/dist/cli/contracts/CliOptions.d.ts +13 -0
- package/dist/cli/contracts/CliOptions.js +1 -0
- package/dist/cli/contracts/CommandDefinition.d.ts +18 -0
- package/dist/cli/contracts/CommandDefinition.js +1 -0
- package/dist/cli/contracts/ReplOptions.d.ts +11 -0
- package/dist/cli/contracts/ReplOptions.js +1 -0
- package/dist/cli/contracts/index.d.ts +5 -0
- package/dist/cli/contracts/index.js +1 -0
- package/dist/cli/defineCommand.d.ts +10 -0
- package/dist/cli/defineCommand.js +25 -0
- package/dist/cli/index.d.ts +5 -0
- package/dist/cli/index.js +5 -0
- package/dist/cli/runDb3.d.ts +11 -0
- package/dist/cli/runDb3.js +70 -0
- package/dist/cli/runRepl.d.ts +12 -0
- package/dist/cli/runRepl.js +54 -0
- package/dist/config/Config.d.ts +48 -0
- package/dist/config/Config.js +80 -0
- package/dist/config/env.d.ts +26 -0
- package/dist/config/env.js +117 -0
- package/dist/config/index.d.ts +2 -0
- package/dist/config/index.js +2 -0
- package/dist/db/ActiveProjection.d.ts +90 -0
- package/dist/db/ActiveProjection.js +134 -0
- package/dist/db/ActiveQueryBuilder.d.ts +268 -0
- package/dist/db/ActiveQueryBuilder.js +621 -0
- package/dist/db/ActiveRecord.d.ts +483 -0
- package/dist/db/ActiveRecord.js +765 -0
- package/dist/db/Database.d.ts +277 -0
- package/dist/db/Database.js +827 -0
- package/dist/db/FieldType.d.ts +540 -0
- package/dist/db/FieldType.js +706 -0
- package/dist/db/SoftDeletes.d.ts +30 -0
- package/dist/db/SoftDeletes.js +93 -0
- package/dist/db/commands/check.d.ts +6 -0
- package/dist/db/commands/check.js +8 -0
- package/dist/db/commands/index.d.ts +6 -0
- package/dist/db/commands/index.js +17 -0
- package/dist/db/commands/makeMigration.d.ts +7 -0
- package/dist/db/commands/makeMigration.js +9 -0
- package/dist/db/commands/migrate.d.ts +6 -0
- package/dist/db/commands/migrate.js +8 -0
- package/dist/db/connection.d.ts +10 -0
- package/dist/db/connection.js +55 -0
- package/dist/db/contracts/ActiveRecordDefinition.d.ts +64 -0
- package/dist/db/contracts/ActiveRecordDefinition.js +1 -0
- package/dist/db/contracts/DatabaseBackup.d.ts +7 -0
- package/dist/db/contracts/DatabaseBackup.js +1 -0
- package/dist/db/contracts/DatabaseMigrationsConfig.d.ts +9 -0
- package/dist/db/contracts/DatabaseMigrationsConfig.js +1 -0
- package/dist/db/contracts/index.d.ts +3 -0
- package/dist/db/contracts/index.js +3 -0
- package/dist/db/dialects/columnTypes.d.ts +20 -0
- package/dist/db/dialects/columnTypes.js +67 -0
- package/dist/db/dialects/index.d.ts +6 -0
- package/dist/db/dialects/index.js +6 -0
- package/dist/db/dialects/mariadb.d.ts +7 -0
- package/dist/db/dialects/mariadb.js +35 -0
- package/dist/db/dialects/mysql.d.ts +14 -0
- package/dist/db/dialects/mysql.js +203 -0
- package/dist/db/dialects/postgres.d.ts +5 -0
- package/dist/db/dialects/postgres.js +106 -0
- package/dist/db/dialects/resolveDialect.d.ts +14 -0
- package/dist/db/dialects/resolveDialect.js +57 -0
- package/dist/db/dialects/types.d.ts +44 -0
- package/dist/db/dialects/types.js +1 -0
- package/dist/db/errors.d.ts +15 -0
- package/dist/db/errors.js +20 -0
- package/dist/db/fields/BooleanField.d.ts +29 -0
- package/dist/db/fields/BooleanField.js +89 -0
- package/dist/db/fields/CharUuidField.d.ts +29 -0
- package/dist/db/fields/CharUuidField.js +63 -0
- package/dist/db/fields/ChoiceStringField.d.ts +25 -0
- package/dist/db/fields/ChoiceStringField.js +58 -0
- package/dist/db/fields/DecimalField.d.ts +20 -0
- package/dist/db/fields/DecimalField.js +105 -0
- package/dist/db/fields/EmailField.d.ts +31 -0
- package/dist/db/fields/EmailField.js +52 -0
- package/dist/db/fields/EncryptedJsonField.d.ts +82 -0
- package/dist/db/fields/EncryptedJsonField.js +169 -0
- package/dist/db/fields/IntegerField.d.ts +35 -0
- package/dist/db/fields/IntegerField.js +139 -0
- package/dist/db/fields/JsonField.d.ts +40 -0
- package/dist/db/fields/JsonField.js +79 -0
- package/dist/db/fields/JsonStringField.d.ts +21 -0
- package/dist/db/fields/JsonStringField.js +41 -0
- package/dist/db/fields/LinkField.d.ts +180 -0
- package/dist/db/fields/LinkField.js +359 -0
- package/dist/db/fields/PasswordField.d.ts +93 -0
- package/dist/db/fields/PasswordField.js +180 -0
- package/dist/db/fields/StringField.d.ts +43 -0
- package/dist/db/fields/StringField.js +102 -0
- package/dist/db/fields/StringListField.d.ts +54 -0
- package/dist/db/fields/StringListField.js +124 -0
- package/dist/db/fields/TextField.d.ts +25 -0
- package/dist/db/fields/TextField.js +44 -0
- package/dist/db/fields/TimestampField.d.ts +47 -0
- package/dist/db/fields/TimestampField.js +97 -0
- package/dist/db/fields/UlidField.d.ts +69 -0
- package/dist/db/fields/UlidField.js +114 -0
- package/dist/db/fields/UrlField.d.ts +30 -0
- package/dist/db/fields/UrlField.js +61 -0
- package/dist/db/fields/VectorField.d.ts +64 -0
- package/dist/db/fields/VectorField.js +180 -0
- package/dist/db/fields/createField.d.ts +2 -0
- package/dist/db/fields/createField.js +13 -0
- package/dist/db/fields/field.d.ts +36 -0
- package/dist/db/fields/field.js +101 -0
- package/dist/db/fields/index.d.ts +18 -0
- package/dist/db/fields/index.js +18 -0
- package/dist/db/fields/resolveFields.d.ts +17 -0
- package/dist/db/fields/resolveFields.js +38 -0
- package/dist/db/index.d.ts +13 -0
- package/dist/db/index.js +13 -0
- package/dist/db/migrations/DatabaseMigrationManager.d.ts +57 -0
- package/dist/db/migrations/DatabaseMigrationManager.js +589 -0
- package/dist/db/migrations/DatabaseSchemaInspector.d.ts +19 -0
- package/dist/db/migrations/DatabaseSchemaInspector.js +384 -0
- package/dist/db/migrations/KnexMigrationRenderer.d.ts +11 -0
- package/dist/db/migrations/KnexMigrationRenderer.js +390 -0
- package/dist/db/migrations/ModelSchemaCollector.d.ts +29 -0
- package/dist/db/migrations/ModelSchemaCollector.js +183 -0
- package/dist/db/migrations/SchemaDiffer.d.ts +13 -0
- package/dist/db/migrations/SchemaDiffer.js +427 -0
- package/dist/db/migrations/SchemaNames.d.ts +27 -0
- package/dist/db/migrations/SchemaNames.js +46 -0
- package/dist/db/migrations/SchemaSnapshotSerializer.d.ts +30 -0
- package/dist/db/migrations/SchemaSnapshotSerializer.js +49 -0
- package/dist/db/migrations/contracts/DatabaseMigration.d.ts +118 -0
- package/dist/db/migrations/contracts/DatabaseMigration.js +1 -0
- package/dist/db/migrations/contracts/SchemaChange.d.ts +83 -0
- package/dist/db/migrations/contracts/SchemaChange.js +1 -0
- package/dist/db/migrations/contracts/SchemaSnapshot.d.ts +94 -0
- package/dist/db/migrations/contracts/SchemaSnapshot.js +1 -0
- package/dist/db/migrations/contracts/index.d.ts +3 -0
- package/dist/db/migrations/contracts/index.js +3 -0
- package/dist/db/migrations/errors.d.ts +35 -0
- package/dist/db/migrations/errors.js +45 -0
- package/dist/db/migrations/index.d.ts +10 -0
- package/dist/db/migrations/index.js +10 -0
- package/dist/db/migrations/promoteDestructiveSchemaChanges.d.ts +19 -0
- package/dist/db/migrations/promoteDestructiveSchemaChanges.js +102 -0
- package/dist/db/queryMonitor.d.ts +142 -0
- package/dist/db/queryMonitor.js +357 -0
- package/dist/db/sqlErrors.d.ts +11 -0
- package/dist/db/sqlErrors.js +17 -0
- package/dist/db/test/db.d.ts +11 -0
- package/dist/db/test/db.js +109 -0
- package/dist/devtools/HttpEventDispatcher.d.ts +19 -0
- package/dist/devtools/HttpEventDispatcher.js +180 -0
- package/dist/devtools/contracts/DevtoolsEventDispatcher.d.ts +53 -0
- package/dist/devtools/contracts/DevtoolsEventDispatcher.js +1 -0
- package/dist/devtools/contracts/index.d.ts +1 -0
- package/dist/devtools/contracts/index.js +1 -0
- package/dist/devtools/environment.d.ts +10 -0
- package/dist/devtools/environment.js +14 -0
- package/dist/devtools/index.d.ts +3 -0
- package/dist/devtools/index.js +3 -0
- package/dist/events/Events.d.ts +70 -0
- package/dist/events/Events.js +126 -0
- package/dist/events/contracts/EventConstructor.d.ts +12 -0
- package/dist/events/contracts/EventConstructor.js +1 -0
- package/dist/events/contracts/EventListener.d.ts +6 -0
- package/dist/events/contracts/EventListener.js +1 -0
- package/dist/events/contracts/EventUnsubscribe.d.ts +4 -0
- package/dist/events/contracts/EventUnsubscribe.js +1 -0
- package/dist/events/contracts/index.d.ts +3 -0
- package/dist/events/contracts/index.js +3 -0
- package/dist/events/index.d.ts +2 -0
- package/dist/events/index.js +2 -0
- package/dist/flows/FlowBlockRegistry.d.ts +39 -0
- package/dist/flows/FlowBlockRegistry.js +66 -0
- package/dist/flows/FlowCompiler.d.ts +26 -0
- package/dist/flows/FlowCompiler.js +488 -0
- package/dist/flows/FlowDefinitionError.d.ts +21 -0
- package/dist/flows/FlowDefinitionError.js +16 -0
- package/dist/flows/FlowStepJob.d.ts +28 -0
- package/dist/flows/FlowStepJob.js +31 -0
- package/dist/flows/FlowValueValidator.d.ts +32 -0
- package/dist/flows/FlowValueValidator.js +105 -0
- package/dist/flows/Flows.d.ts +102 -0
- package/dist/flows/Flows.js +871 -0
- package/dist/flows/blocks/FlowInput.d.ts +10 -0
- package/dist/flows/blocks/FlowInput.js +29 -0
- package/dist/flows/blocks/FlowOutput.d.ts +10 -0
- package/dist/flows/blocks/FlowOutput.js +29 -0
- package/dist/flows/blocks/Subflow.d.ts +10 -0
- package/dist/flows/blocks/Subflow.js +21 -0
- package/dist/flows/blocks/index.d.ts +6 -0
- package/dist/flows/blocks/index.js +8 -0
- package/dist/flows/constants.d.ts +55 -0
- package/dist/flows/constants.js +47 -0
- package/dist/flows/contracts/FlowBlock.d.ts +64 -0
- package/dist/flows/contracts/FlowBlock.js +1 -0
- package/dist/flows/contracts/FlowCompiler.d.ts +30 -0
- package/dist/flows/contracts/FlowCompiler.js +1 -0
- package/dist/flows/contracts/FlowDefinition.d.ts +118 -0
- package/dist/flows/contracts/FlowDefinition.js +1 -0
- package/dist/flows/contracts/FlowDefinitionStore.d.ts +47 -0
- package/dist/flows/contracts/FlowDefinitionStore.js +1 -0
- package/dist/flows/contracts/FlowRun.d.ts +40 -0
- package/dist/flows/contracts/FlowRun.js +1 -0
- package/dist/flows/contracts/FlowValue.d.ts +49 -0
- package/dist/flows/contracts/FlowValue.js +1 -0
- package/dist/flows/contracts/FlowsService.d.ts +37 -0
- package/dist/flows/contracts/FlowsService.js +1 -0
- package/dist/flows/contracts/index.d.ts +7 -0
- package/dist/flows/contracts/index.js +7 -0
- package/dist/flows/defineBlock.d.ts +18 -0
- package/dist/flows/defineBlock.js +19 -0
- package/dist/flows/drivers/FileFlowDefinitionStore.d.ts +53 -0
- package/dist/flows/drivers/FileFlowDefinitionStore.js +313 -0
- package/dist/flows/drivers/index.d.ts +1 -0
- package/dist/flows/drivers/index.js +1 -0
- package/dist/flows/errors.d.ts +8 -0
- package/dist/flows/errors.js +19 -0
- package/dist/flows/index.d.ts +13 -0
- package/dist/flows/index.js +13 -0
- package/dist/flows/models/FlowRun.d.ts +55 -0
- package/dist/flows/models/FlowRun.js +126 -0
- package/dist/flows/models/FlowRunEvent.d.ts +41 -0
- package/dist/flows/models/FlowRunEvent.js +85 -0
- package/dist/flows/models/FlowStepRun.d.ts +56 -0
- package/dist/flows/models/FlowStepRun.js +137 -0
- package/dist/flows/models/index.d.ts +10 -0
- package/dist/flows/models/index.js +14 -0
- package/dist/index.d.ts +25 -0
- package/dist/index.js +16 -0
- package/dist/logging/Log.d.ts +66 -0
- package/dist/logging/Log.js +79 -0
- package/dist/logging/contracts/HttpExchange.d.ts +50 -0
- package/dist/logging/contracts/HttpExchange.js +1 -0
- package/dist/logging/contracts/Logger.d.ts +41 -0
- package/dist/logging/contracts/Logger.js +1 -0
- package/dist/logging/contracts/LoggerDriver.d.ts +16 -0
- package/dist/logging/contracts/LoggerDriver.js +1 -0
- package/dist/logging/contracts/LoggingOptions.d.ts +49 -0
- package/dist/logging/contracts/LoggingOptions.js +1 -0
- package/dist/logging/contracts/index.d.ts +4 -0
- package/dist/logging/contracts/index.js +4 -0
- package/dist/logging/drivers/PinoLoggerDriver.d.ts +24 -0
- package/dist/logging/drivers/PinoLoggerDriver.js +291 -0
- package/dist/logging/drivers/index.d.ts +1 -0
- package/dist/logging/drivers/index.js +1 -0
- package/dist/logging/index.d.ts +3 -0
- package/dist/logging/index.js +3 -0
- package/dist/logging/transports/DevtoolsLogTransport.d.ts +35 -0
- package/dist/logging/transports/DevtoolsLogTransport.js +96 -0
- package/dist/mail/Mail.d.ts +62 -0
- package/dist/mail/Mail.js +98 -0
- package/dist/mail/index.d.ts +4 -0
- package/dist/mail/index.js +4 -0
- package/dist/mail/transports/FileMailTransport.d.ts +12 -0
- package/dist/mail/transports/FileMailTransport.js +41 -0
- package/dist/mail/transports/MailgunTransport.d.ts +22 -0
- package/dist/mail/transports/MailgunTransport.js +57 -0
- package/dist/mail/transports/ResendTransport.d.ts +14 -0
- package/dist/mail/transports/ResendTransport.js +55 -0
- package/dist/media/MediaFile.d.ts +48 -0
- package/dist/media/MediaFile.js +104 -0
- package/dist/media/MediaItem.d.ts +47 -0
- package/dist/media/MediaItem.js +106 -0
- package/dist/media/MediaLibrary.d.ts +42 -0
- package/dist/media/MediaLibrary.js +94 -0
- package/dist/media/MediaManager.d.ts +159 -0
- package/dist/media/MediaManager.js +754 -0
- package/dist/media/constants.d.ts +27 -0
- package/dist/media/constants.js +19 -0
- package/dist/media/contracts/MediaOptions.d.ts +8 -0
- package/dist/media/contracts/MediaOptions.js +1 -0
- package/dist/media/contracts/index.d.ts +1 -0
- package/dist/media/contracts/index.js +1 -0
- package/dist/media/image/ImageReconstructionError.d.ts +15 -0
- package/dist/media/image/ImageReconstructionError.js +18 -0
- package/dist/media/image/ImageVariantRenderer.d.ts +44 -0
- package/dist/media/image/ImageVariantRenderer.js +337 -0
- package/dist/media/image/ImageVariantRequest.d.ts +28 -0
- package/dist/media/image/ImageVariantRequest.js +55 -0
- package/dist/media/image/contracts/ImageProcessor.d.ts +46 -0
- package/dist/media/image/contracts/ImageProcessor.js +1 -0
- package/dist/media/image/contracts/ImageVariant.d.ts +31 -0
- package/dist/media/image/contracts/ImageVariant.js +7 -0
- package/dist/media/image/contracts/ImageVariantCacheOptions.d.ts +20 -0
- package/dist/media/image/contracts/ImageVariantCacheOptions.js +1 -0
- package/dist/media/image/contracts/index.d.ts +3 -0
- package/dist/media/image/contracts/index.js +3 -0
- package/dist/media/image/index.d.ts +5 -0
- package/dist/media/image/index.js +5 -0
- package/dist/media/image/processors/SharpImageProcessor.d.ts +25 -0
- package/dist/media/image/processors/SharpImageProcessor.js +112 -0
- package/dist/media/image/processors/index.d.ts +1 -0
- package/dist/media/image/processors/index.js +1 -0
- package/dist/media/index.d.ts +8 -0
- package/dist/media/index.js +8 -0
- package/dist/media/types.d.ts +129 -0
- package/dist/media/types.js +1 -0
- package/dist/queue/FailedJob.d.ts +31 -0
- package/dist/queue/FailedJob.js +41 -0
- package/dist/queue/Queue.d.ts +208 -0
- package/dist/queue/Queue.js +685 -0
- package/dist/queue/QueueEvents.d.ts +31 -0
- package/dist/queue/QueueEvents.js +49 -0
- package/dist/queue/QueueRetryLaterError.d.ts +23 -0
- package/dist/queue/QueueRetryLaterError.js +34 -0
- package/dist/queue/QueueWorker.d.ts +72 -0
- package/dist/queue/QueueWorker.js +236 -0
- package/dist/queue/QueueableJob.d.ts +109 -0
- package/dist/queue/QueueableJob.js +137 -0
- package/dist/queue/QueuedJob.d.ts +31 -0
- package/dist/queue/QueuedJob.js +52 -0
- package/dist/queue/RetryPolicy.d.ts +51 -0
- package/dist/queue/RetryPolicy.js +84 -0
- package/dist/queue/commands/index.d.ts +4 -0
- package/dist/queue/commands/index.js +11 -0
- package/dist/queue/commands/makeJob.d.ts +7 -0
- package/dist/queue/commands/makeJob.js +9 -0
- package/dist/queue/console.d.ts +60 -0
- package/dist/queue/console.js +348 -0
- package/dist/queue/contracts/CreateJob.d.ts +12 -0
- package/dist/queue/contracts/CreateJob.js +1 -0
- package/dist/queue/contracts/QueueDriver.d.ts +122 -0
- package/dist/queue/contracts/QueueDriver.js +1 -0
- package/dist/queue/contracts/QueueEvents.d.ts +61 -0
- package/dist/queue/contracts/QueueEvents.js +1 -0
- package/dist/queue/contracts/QueuePayload.d.ts +136 -0
- package/dist/queue/contracts/QueuePayload.js +1 -0
- package/dist/queue/contracts/QueueRetry.d.ts +43 -0
- package/dist/queue/contracts/QueueRetry.js +1 -0
- package/dist/queue/contracts/QueueService.d.ts +199 -0
- package/dist/queue/contracts/QueueService.js +1 -0
- package/dist/queue/contracts/QueueWorkerLifecycle.d.ts +65 -0
- package/dist/queue/contracts/QueueWorkerLifecycle.js +1 -0
- package/dist/queue/contracts/QueueableJob.d.ts +50 -0
- package/dist/queue/contracts/QueueableJob.js +1 -0
- package/dist/queue/contracts/RedisQueueDriver.d.ts +37 -0
- package/dist/queue/contracts/RedisQueueDriver.js +1 -0
- package/dist/queue/contracts/index.d.ts +9 -0
- package/dist/queue/contracts/index.js +9 -0
- package/dist/queue/createJob.d.ts +18 -0
- package/dist/queue/createJob.js +52 -0
- package/dist/queue/drivers/DatabaseQueueDriver.d.ts +83 -0
- package/dist/queue/drivers/DatabaseQueueDriver.js +393 -0
- package/dist/queue/drivers/RedisQueueDriver.d.ts +102 -0
- package/dist/queue/drivers/RedisQueueDriver.js +641 -0
- package/dist/queue/index.d.ts +13 -0
- package/dist/queue/index.js +13 -0
- package/dist/queue/queueMonitor.d.ts +133 -0
- package/dist/queue/queueMonitor.js +238 -0
- package/dist/scheduler/ScheduledCall.d.ts +25 -0
- package/dist/scheduler/ScheduledCall.js +31 -0
- package/dist/scheduler/ScheduledEvent.d.ts +74 -0
- package/dist/scheduler/ScheduledEvent.js +115 -0
- package/dist/scheduler/ScheduledJob.d.ts +34 -0
- package/dist/scheduler/ScheduledJob.js +50 -0
- package/dist/scheduler/ScheduledOccurrence.d.ts +74 -0
- package/dist/scheduler/ScheduledOccurrence.js +194 -0
- package/dist/scheduler/ScheduledOccurrenceRecorder.d.ts +34 -0
- package/dist/scheduler/ScheduledOccurrenceRecorder.js +106 -0
- package/dist/scheduler/Scheduler.d.ts +76 -0
- package/dist/scheduler/Scheduler.js +186 -0
- package/dist/scheduler/SchedulerWorker.d.ts +37 -0
- package/dist/scheduler/SchedulerWorker.js +119 -0
- package/dist/scheduler/console.d.ts +18 -0
- package/dist/scheduler/console.js +288 -0
- package/dist/scheduler/constants.d.ts +13 -0
- package/dist/scheduler/constants.js +23 -0
- package/dist/scheduler/contracts/Scheduler.d.ts +104 -0
- package/dist/scheduler/contracts/Scheduler.js +1 -0
- package/dist/scheduler/contracts/SchedulerConsole.d.ts +37 -0
- package/dist/scheduler/contracts/SchedulerConsole.js +1 -0
- package/dist/scheduler/contracts/SchedulerWorker.d.ts +18 -0
- package/dist/scheduler/contracts/SchedulerWorker.js +1 -0
- package/dist/scheduler/contracts/index.d.ts +3 -0
- package/dist/scheduler/contracts/index.js +3 -0
- package/dist/scheduler/index.d.ts +9 -0
- package/dist/scheduler/index.js +9 -0
- package/dist/scheduler/scheduleTime.d.ts +30 -0
- package/dist/scheduler/scheduleTime.js +64 -0
- package/dist/security/Security.d.ts +60 -0
- package/dist/security/Security.js +252 -0
- package/dist/security/SecurityError.d.ts +13 -0
- package/dist/security/SecurityError.js +16 -0
- package/dist/security/contracts/SecurityOptions.d.ts +17 -0
- package/dist/security/contracts/SecurityOptions.js +1 -0
- package/dist/security/contracts/SecurityPayload.d.ts +13 -0
- package/dist/security/contracts/SecurityPayload.js +1 -0
- package/dist/security/contracts/index.d.ts +2 -0
- package/dist/security/contracts/index.js +2 -0
- package/dist/security/ensureAppKey.d.ts +16 -0
- package/dist/security/ensureAppKey.js +69 -0
- package/dist/security/index.d.ts +4 -0
- package/dist/security/index.js +4 -0
- package/dist/serialization/Serializable.d.ts +17 -0
- package/dist/serialization/Serializable.js +1 -0
- package/dist/serialization/SerializationError.d.ts +40 -0
- package/dist/serialization/SerializationError.js +42 -0
- package/dist/serialization/SerializationRegistry.d.ts +76 -0
- package/dist/serialization/SerializationRegistry.js +153 -0
- package/dist/serialization/SerializationRegistryError.d.ts +18 -0
- package/dist/serialization/SerializationRegistryError.js +18 -0
- package/dist/serialization/Serializer.d.ts +37 -0
- package/dist/serialization/Serializer.js +477 -0
- package/dist/serialization/contracts/SerializableClass.d.ts +20 -0
- package/dist/serialization/contracts/SerializableClass.js +1 -0
- package/dist/serialization/contracts/SerializedValue.d.ts +59 -0
- package/dist/serialization/contracts/SerializedValue.js +19 -0
- package/dist/serialization/contracts/SerializerOptions.d.ts +17 -0
- package/dist/serialization/contracts/SerializerOptions.js +1 -0
- package/dist/serialization/contracts/SerializerService.d.ts +26 -0
- package/dist/serialization/contracts/SerializerService.js +1 -0
- package/dist/serialization/contracts/index.d.ts +4 -0
- package/dist/serialization/contracts/index.js +4 -0
- package/dist/serialization/index.d.ts +6 -0
- package/dist/serialization/index.js +6 -0
- package/dist/server/App.d.ts +141 -0
- package/dist/server/App.js +225 -0
- package/dist/server/RequestContext.d.ts +42 -0
- package/dist/server/RequestContext.js +95 -0
- package/dist/server/appContext.d.ts +34 -0
- package/dist/server/appContext.js +42 -0
- package/dist/server/index.d.ts +3 -0
- package/dist/server/index.js +3 -0
- package/dist/ssr/constants.d.ts +6 -0
- package/dist/ssr/constants.js +6 -0
- package/dist/ssr/contracts/DocumentHead.d.ts +32 -0
- package/dist/ssr/contracts/DocumentHead.js +1 -0
- package/dist/ssr/contracts/SsrRenderContext.d.ts +23 -0
- package/dist/ssr/contracts/SsrRenderContext.js +1 -0
- package/dist/ssr/contracts/SsrRenderResult.d.ts +21 -0
- package/dist/ssr/contracts/SsrRenderResult.js +1 -0
- package/dist/ssr/contracts/SsrRenderer.d.ts +9 -0
- package/dist/ssr/contracts/SsrRenderer.js +1 -0
- package/dist/ssr/contracts/SsrRequest.d.ts +16 -0
- package/dist/ssr/contracts/SsrRequest.js +1 -0
- package/dist/ssr/contracts/index.d.ts +5 -0
- package/dist/ssr/contracts/index.js +1 -0
- package/dist/ssr/createSsrRenderContext.d.ts +9 -0
- package/dist/ssr/createSsrRenderContext.js +20 -0
- package/dist/ssr/fastify/contracts/FastifySsrOptions.d.ts +21 -0
- package/dist/ssr/fastify/contracts/FastifySsrOptions.js +1 -0
- package/dist/ssr/fastify/contracts/index.d.ts +1 -0
- package/dist/ssr/fastify/contracts/index.js +1 -0
- package/dist/ssr/fastify/fastifySsr.d.ts +25 -0
- package/dist/ssr/fastify/fastifySsr.js +89 -0
- package/dist/ssr/fastify/index.d.ts +2 -0
- package/dist/ssr/fastify/index.js +1 -0
- package/dist/ssr/index.d.ts +6 -0
- package/dist/ssr/index.js +5 -0
- package/dist/ssr/renderDocumentHead.d.ts +8 -0
- package/dist/ssr/renderDocumentHead.js +62 -0
- package/dist/ssr/renderSsrDocument.d.ts +14 -0
- package/dist/ssr/renderSsrDocument.js +28 -0
- package/dist/ssr/serializeSsrState.d.ts +10 -0
- package/dist/ssr/serializeSsrState.js +18 -0
- package/dist/ssr/vite/contracts/ViteSsrOptions.d.ts +45 -0
- package/dist/ssr/vite/contracts/ViteSsrOptions.js +1 -0
- package/dist/ssr/vite/contracts/index.d.ts +1 -0
- package/dist/ssr/vite/contracts/index.js +1 -0
- package/dist/ssr/vite/fastifyViteSsr.d.ts +24 -0
- package/dist/ssr/vite/fastifyViteSsr.js +213 -0
- package/dist/ssr/vite/index.d.ts +4 -0
- package/dist/ssr/vite/index.js +2 -0
- package/dist/ssr/vite/viteSsrManifest.d.ts +16 -0
- package/dist/ssr/vite/viteSsrManifest.js +63 -0
- package/dist/storage/Storage.d.ts +244 -0
- package/dist/storage/Storage.js +348 -0
- package/dist/storage/contents.d.ts +8 -0
- package/dist/storage/contents.js +18 -0
- package/dist/storage/contracts/StorageListing.d.ts +50 -0
- package/dist/storage/contracts/StorageListing.js +1 -0
- package/dist/storage/contracts/index.d.ts +1 -0
- package/dist/storage/contracts/index.js +1 -0
- package/dist/storage/drivers/FlystorageDisk.d.ts +185 -0
- package/dist/storage/drivers/FlystorageDisk.js +250 -0
- package/dist/storage/drivers/FlystorageListing.d.ts +27 -0
- package/dist/storage/drivers/FlystorageListing.js +69 -0
- package/dist/storage/drivers/LocalStorageDisk.d.ts +25 -0
- package/dist/storage/drivers/LocalStorageDisk.js +38 -0
- package/dist/storage/drivers/S3StorageDisk.d.ts +17 -0
- package/dist/storage/drivers/S3StorageDisk.js +102 -0
- package/dist/storage/drivers/index.d.ts +3 -0
- package/dist/storage/drivers/index.js +3 -0
- package/dist/storage/index.d.ts +7 -0
- package/dist/storage/index.js +7 -0
- package/dist/storage/mime.d.ts +7 -0
- package/dist/storage/mime.js +28 -0
- package/dist/storage/path.d.ts +22 -0
- package/dist/storage/path.js +61 -0
- package/dist/storage/types.d.ts +218 -0
- package/dist/storage/types.js +1 -0
- package/dist/url/UrlGenerator.d.ts +32 -0
- package/dist/url/UrlGenerator.js +61 -0
- package/dist/url/contracts/UrlGeneratorOptions.d.ts +13 -0
- package/dist/url/contracts/UrlGeneratorOptions.js +1 -0
- package/dist/url/contracts/index.d.ts +1 -0
- package/dist/url/contracts/index.js +1 -0
- package/dist/url/index.d.ts +2 -0
- package/dist/url/index.js +2 -0
- package/dist/validation/index.d.ts +28 -0
- package/dist/validation/index.js +260 -0
- package/package.json +290 -0
- package/src/ai/AIErrors.ts +46 -0
- package/src/ai/AIFailover.ts +101 -0
- package/src/ai/AIProviders.ts +228 -0
- package/src/ai/AIQuotaDeferredError.ts +26 -0
- package/src/ai/AIRateLimiter.ts +880 -0
- package/src/ai/Agent.ts +3630 -0
- package/src/ai/AgentHistory.ts +576 -0
- package/src/ai/AgentRunJob.ts +65 -0
- package/src/ai/Ai.ts +2176 -0
- package/src/ai/AiConversation.ts +49 -0
- package/src/ai/AiExecutionContext.ts +19 -0
- package/src/ai/AiMessage.ts +131 -0
- package/src/ai/AiRateLimitBucket.ts +163 -0
- package/src/ai/AiRateLimitReservation.ts +117 -0
- package/src/ai/AiRequest.ts +466 -0
- package/src/ai/Estimates.ts +36 -0
- package/src/ai/Models.ts +373 -0
- package/src/ai/OpenAIProviderError.ts +98 -0
- package/src/ai/OpenAIQuotaRetry.ts +183 -0
- package/src/ai/ProviderCosts.ts +156 -0
- package/src/ai/README.md +187 -0
- package/src/ai/ResponsesProviderCall.ts +34 -0
- package/src/ai/agentCitations.ts +186 -0
- package/src/ai/contracts/AI.ts +380 -0
- package/src/ai/contracts/Agent.ts +539 -0
- package/src/ai/contracts/AiRequestRunCostSummary.ts +31 -0
- package/src/ai/contracts/Pricing.ts +95 -0
- package/src/ai/contracts/Providers.ts +73 -0
- package/src/ai/contracts/QuotaRetry.ts +39 -0
- package/src/ai/contracts/RateLimits.ts +49 -0
- package/src/ai/contracts/ResponsesProviderCall.ts +30 -0
- package/src/ai/contracts/index.ts +8 -0
- package/src/ai/examples/Conversation.ts +12 -0
- package/src/ai/examples/HelpAgent.ts +27 -0
- package/src/ai/examples/createHelpImage.ts +13 -0
- package/src/ai/index.ts +27 -0
- package/src/ai/registry.ts +70 -0
- package/src/ai/sdkNodeCompatibility.d.ts +76 -0
- package/src/ai/toolCallRecovery.ts +82 -0
- package/src/ai/toolHelpers.ts +145 -0
- package/src/auth/Auth.ts +1422 -0
- package/src/auth/AuthProvider.ts +251 -0
- package/src/auth/AuthToken.ts +239 -0
- package/src/auth/PasswordResetToken.ts +93 -0
- package/src/auth/README.md +396 -0
- package/src/auth/UserIdentity.ts +112 -0
- package/src/auth/contracts/AuthProviderDriver.ts +114 -0
- package/src/auth/contracts/index.ts +1 -0
- package/src/auth/examples/runPasswordAuth.ts +45 -0
- package/src/auth/index.ts +8 -0
- package/src/auth/passwordHash.ts +160 -0
- package/src/auth/providers/GoogleAuthProvider.ts +470 -0
- package/src/auth/providers/PasswordAuthProvider.ts +256 -0
- package/src/auth/providers/index.ts +3 -0
- package/src/auth/providers/resolveAuthProviders.ts +166 -0
- package/src/cache/Cache.ts +151 -0
- package/src/cache/README.md +137 -0
- package/src/cache/contracts/CacheDriver.ts +11 -0
- package/src/cache/contracts/CacheOperations.ts +28 -0
- package/src/cache/contracts/CacheOptions.ts +56 -0
- package/src/cache/contracts/CacheRepository.ts +62 -0
- package/src/cache/contracts/index.ts +4 -0
- package/src/cache/drivers/CacheManagerDriver.ts +84 -0
- package/src/cache/drivers/createCacheDriver.ts +191 -0
- package/src/cache/examples/runNoteCache.ts +37 -0
- package/src/cache/index.ts +2 -0
- package/src/cli/Cli.ts +110 -0
- package/src/cli/README.md +164 -0
- package/src/cli/commands/repl.ts +29 -0
- package/src/cli/contracts/CliCommand.ts +33 -0
- package/src/cli/contracts/CliConfig.ts +10 -0
- package/src/cli/contracts/CliOptions.ts +13 -0
- package/src/cli/contracts/CommandDefinition.ts +19 -0
- package/src/cli/contracts/ReplOptions.ts +11 -0
- package/src/cli/contracts/index.ts +5 -0
- package/src/cli/defineCommand.ts +25 -0
- package/src/cli/index.ts +5 -0
- package/src/cli/runDb3.ts +63 -0
- package/src/cli/runRepl.ts +55 -0
- package/src/config/Config.ts +110 -0
- package/src/config/README.md +142 -0
- package/src/config/env.ts +164 -0
- package/src/config/examples/loadNotesConfig.ts +29 -0
- package/src/config/examples/runConfig.ts +40 -0
- package/src/config/index.ts +2 -0
- package/src/db/ActiveProjection.ts +311 -0
- package/src/db/ActiveQueryBuilder.ts +831 -0
- package/src/db/ActiveRecord.ts +1317 -0
- package/src/db/Database.ts +1283 -0
- package/src/db/FieldType.ts +1243 -0
- package/src/db/README.md +508 -0
- package/src/db/SoftDeletes.ts +158 -0
- package/src/db/commands/check.ts +10 -0
- package/src/db/commands/index.ts +19 -0
- package/src/db/commands/makeMigration.ts +11 -0
- package/src/db/commands/migrate.ts +10 -0
- package/src/db/connection.ts +68 -0
- package/src/db/contracts/ActiveRecordDefinition.ts +69 -0
- package/src/db/contracts/DatabaseBackup.ts +7 -0
- package/src/db/contracts/DatabaseMigrationsConfig.ts +10 -0
- package/src/db/contracts/index.ts +3 -0
- package/src/db/dialects/columnTypes.ts +103 -0
- package/src/db/dialects/index.ts +6 -0
- package/src/db/dialects/mariadb.ts +51 -0
- package/src/db/dialects/mysql.ts +277 -0
- package/src/db/dialects/postgres.ts +143 -0
- package/src/db/dialects/resolveDialect.ts +88 -0
- package/src/db/dialects/types.ts +59 -0
- package/src/db/errors.ts +22 -0
- package/src/db/examples/DefinedUser.ts +20 -0
- package/src/db/examples/FieldNote.ts +27 -0
- package/src/db/examples/KnowledgeNote.ts +29 -0
- package/src/db/examples/NoteCodeField.ts +9 -0
- package/src/db/examples/createNotesTogether.ts +24 -0
- package/src/db/examples/outputs/workspace-notes.json +9 -0
- package/src/db/examples/runFieldNotes.ts +51 -0
- package/src/db/examples/runNoteMigrations.ts +64 -0
- package/src/db/examples/runWorkspaceNotes.ts +86 -0
- package/src/db/examples/workspaceNotes.ts +57 -0
- package/src/db/fields/BooleanField.ts +128 -0
- package/src/db/fields/CharUuidField.ts +91 -0
- package/src/db/fields/ChoiceStringField.ts +97 -0
- package/src/db/fields/DecimalField.ts +157 -0
- package/src/db/fields/EmailField.ts +79 -0
- package/src/db/fields/EncryptedJsonField.ts +211 -0
- package/src/db/fields/IntegerField.ts +200 -0
- package/src/db/fields/JsonField.ts +108 -0
- package/src/db/fields/JsonStringField.ts +63 -0
- package/src/db/fields/LinkField.ts +502 -0
- package/src/db/fields/PasswordField.ts +294 -0
- package/src/db/fields/StringField.ts +154 -0
- package/src/db/fields/StringListField.ts +179 -0
- package/src/db/fields/TextField.ts +71 -0
- package/src/db/fields/TimestampField.ts +164 -0
- package/src/db/fields/UlidField.ts +189 -0
- package/src/db/fields/UrlField.ts +97 -0
- package/src/db/fields/VectorField.ts +266 -0
- package/src/db/fields/createField.ts +22 -0
- package/src/db/fields/field.ts +209 -0
- package/src/db/fields/index.ts +76 -0
- package/src/db/fields/resolveFields.ts +69 -0
- package/src/db/index.ts +13 -0
- package/src/db/migrations/DatabaseMigrationManager.ts +756 -0
- package/src/db/migrations/DatabaseSchemaInspector.ts +541 -0
- package/src/db/migrations/KnexMigrationRenderer.ts +490 -0
- package/src/db/migrations/ModelSchemaCollector.ts +240 -0
- package/src/db/migrations/SchemaDiffer.ts +541 -0
- package/src/db/migrations/SchemaNames.ts +62 -0
- package/src/db/migrations/SchemaSnapshotSerializer.ts +59 -0
- package/src/db/migrations/contracts/DatabaseMigration.ts +143 -0
- package/src/db/migrations/contracts/SchemaChange.ts +113 -0
- package/src/db/migrations/contracts/SchemaSnapshot.ts +122 -0
- package/src/db/migrations/contracts/index.ts +3 -0
- package/src/db/migrations/errors.ts +45 -0
- package/src/db/migrations/index.ts +10 -0
- package/src/db/migrations/promoteDestructiveSchemaChanges.ts +120 -0
- package/src/db/queryMonitor.ts +549 -0
- package/src/db/sqlErrors.ts +36 -0
- package/src/db/test/db.ts +159 -0
- package/src/devtools/HttpEventDispatcher.ts +214 -0
- package/src/devtools/contracts/DevtoolsEventDispatcher.ts +57 -0
- package/src/devtools/contracts/index.ts +1 -0
- package/src/devtools/environment.ts +18 -0
- package/src/devtools/index.ts +3 -0
- package/src/events/Events.ts +165 -0
- package/src/events/README.md +106 -0
- package/src/events/contracts/EventConstructor.ts +12 -0
- package/src/events/contracts/EventListener.ts +8 -0
- package/src/events/contracts/EventUnsubscribe.ts +4 -0
- package/src/events/contracts/index.ts +3 -0
- package/src/events/examples/NoteSaved.ts +9 -0
- package/src/events/examples/runNoteEvents.ts +31 -0
- package/src/events/index.ts +2 -0
- package/src/flows/FlowBlockRegistry.ts +79 -0
- package/src/flows/FlowCompiler.ts +624 -0
- package/src/flows/FlowDefinitionError.ts +24 -0
- package/src/flows/FlowStepJob.ts +54 -0
- package/src/flows/FlowValueValidator.ts +120 -0
- package/src/flows/Flows.ts +1118 -0
- package/src/flows/README.md +144 -0
- package/src/flows/blocks/FlowInput.ts +32 -0
- package/src/flows/blocks/FlowOutput.ts +32 -0
- package/src/flows/blocks/Subflow.ts +24 -0
- package/src/flows/blocks/index.ts +11 -0
- package/src/flows/constants.ts +62 -0
- package/src/flows/contracts/FlowBlock.ts +73 -0
- package/src/flows/contracts/FlowCompiler.ts +32 -0
- package/src/flows/contracts/FlowDefinition.ts +126 -0
- package/src/flows/contracts/FlowDefinitionStore.ts +52 -0
- package/src/flows/contracts/FlowRun.ts +44 -0
- package/src/flows/contracts/FlowValue.ts +54 -0
- package/src/flows/contracts/FlowsService.ts +39 -0
- package/src/flows/contracts/index.ts +7 -0
- package/src/flows/defineBlock.ts +25 -0
- package/src/flows/drivers/FileFlowDefinitionStore.ts +372 -0
- package/src/flows/drivers/index.ts +1 -0
- package/src/flows/errors.ts +22 -0
- package/src/flows/examples/FlowExampleApp.ts +15 -0
- package/src/flows/examples/createTextFlow.ts +14 -0
- package/src/flows/examples/normalizeTextBlock.ts +15 -0
- package/src/flows/examples/runTextFlow.ts +46 -0
- package/src/flows/examples/uppercaseTextBlock.ts +11 -0
- package/src/flows/index.ts +13 -0
- package/src/flows/models/FlowRun.ts +164 -0
- package/src/flows/models/FlowRunEvent.ts +108 -0
- package/src/flows/models/FlowStepRun.ts +176 -0
- package/src/flows/models/index.ts +16 -0
- package/src/index.ts +40 -0
- package/src/logging/Log.ts +100 -0
- package/src/logging/README.md +139 -0
- package/src/logging/contracts/HttpExchange.ts +53 -0
- package/src/logging/contracts/Logger.ts +45 -0
- package/src/logging/contracts/LoggerDriver.ts +19 -0
- package/src/logging/contracts/LoggingOptions.ts +51 -0
- package/src/logging/contracts/index.ts +4 -0
- package/src/logging/drivers/PinoLoggerDriver.ts +376 -0
- package/src/logging/drivers/index.ts +1 -0
- package/src/logging/examples/runNoteLogs.ts +38 -0
- package/src/logging/index.ts +3 -0
- package/src/logging/transports/DevtoolsLogTransport.ts +142 -0
- package/src/mail/Mail.ts +188 -0
- package/src/mail/README.md +206 -0
- package/src/mail/examples/runMailPreview.ts +44 -0
- package/src/mail/examples/welcomeMessage.ts +26 -0
- package/src/mail/index.ts +4 -0
- package/src/mail/transports/FileMailTransport.ts +58 -0
- package/src/mail/transports/MailgunTransport.ts +85 -0
- package/src/mail/transports/ResendTransport.ts +80 -0
- package/src/media/MediaFile.ts +132 -0
- package/src/media/MediaItem.ts +132 -0
- package/src/media/MediaLibrary.ts +117 -0
- package/src/media/MediaManager.ts +874 -0
- package/src/media/README.md +358 -0
- package/src/media/constants.ts +31 -0
- package/src/media/contracts/MediaOptions.ts +9 -0
- package/src/media/contracts/index.ts +1 -0
- package/src/media/examples/createPrivateFileServer.ts +55 -0
- package/src/media/examples/runPrivateFiles.ts +45 -0
- package/src/media/examples/runProjectMedia.ts +46 -0
- package/src/media/image/ImageReconstructionError.ts +18 -0
- package/src/media/image/ImageVariantRenderer.ts +386 -0
- package/src/media/image/ImageVariantRequest.ts +65 -0
- package/src/media/image/contracts/ImageProcessor.ts +53 -0
- package/src/media/image/contracts/ImageVariant.ts +37 -0
- package/src/media/image/contracts/ImageVariantCacheOptions.ts +21 -0
- package/src/media/image/contracts/index.ts +3 -0
- package/src/media/image/index.ts +5 -0
- package/src/media/image/processors/SharpImageProcessor.ts +121 -0
- package/src/media/image/processors/index.ts +1 -0
- package/src/media/index.ts +8 -0
- package/src/media/types.ts +168 -0
- package/src/queue/FailedJob.ts +58 -0
- package/src/queue/Queue.ts +938 -0
- package/src/queue/QueueEvents.ts +57 -0
- package/src/queue/QueueRetryLaterError.ts +40 -0
- package/src/queue/QueueWorker.ts +296 -0
- package/src/queue/QueueableJob.ts +167 -0
- package/src/queue/QueuedJob.ts +69 -0
- package/src/queue/README.md +368 -0
- package/src/queue/RetryPolicy.ts +129 -0
- package/src/queue/commands/index.ts +13 -0
- package/src/queue/commands/makeJob.ts +11 -0
- package/src/queue/console.ts +518 -0
- package/src/queue/contracts/CreateJob.ts +13 -0
- package/src/queue/contracts/QueueDriver.ts +135 -0
- package/src/queue/contracts/QueueEvents.ts +77 -0
- package/src/queue/contracts/QueuePayload.ts +150 -0
- package/src/queue/contracts/QueueRetry.ts +47 -0
- package/src/queue/contracts/QueueService.ts +219 -0
- package/src/queue/contracts/QueueWorkerLifecycle.ts +71 -0
- package/src/queue/contracts/QueueableJob.ts +56 -0
- package/src/queue/contracts/RedisQueueDriver.ts +37 -0
- package/src/queue/contracts/index.ts +9 -0
- package/src/queue/createJob.ts +54 -0
- package/src/queue/drivers/DatabaseQueueDriver.ts +449 -0
- package/src/queue/drivers/RedisQueueDriver.ts +733 -0
- package/src/queue/examples/DeferredReportJob.ts +25 -0
- package/src/queue/examples/GenerateReportJob.ts +37 -0
- package/src/queue/examples/WriteReportJob.ts +37 -0
- package/src/queue/examples/createAndProcessReportJob.ts +29 -0
- package/src/queue/examples/dispatchReportWorkflows.ts +40 -0
- package/src/queue/examples/manageReportRetries.ts +47 -0
- package/src/queue/examples/outputs/create-and-process-report-job.json +6 -0
- package/src/queue/examples/outputs/dispatch-report-workflows.json +14 -0
- package/src/queue/examples/outputs/manage-report-retries.json +24 -0
- package/src/queue/examples/outputs/queue-reports.json +11 -0
- package/src/queue/examples/reportConsole.ts +47 -0
- package/src/queue/examples/runBackpressure.ts +27 -0
- package/src/queue/examples/runQueueReports.ts +80 -0
- package/src/queue/examples/runQueueWorkflows.ts +43 -0
- package/src/queue/index.ts +13 -0
- package/src/queue/queueMonitor.ts +368 -0
- package/src/scheduler/README.md +139 -0
- package/src/scheduler/ScheduledCall.ts +36 -0
- package/src/scheduler/ScheduledEvent.ts +149 -0
- package/src/scheduler/ScheduledJob.ts +58 -0
- package/src/scheduler/ScheduledOccurrence.ts +250 -0
- package/src/scheduler/ScheduledOccurrenceRecorder.ts +125 -0
- package/src/scheduler/Scheduler.ts +225 -0
- package/src/scheduler/SchedulerWorker.ts +151 -0
- package/src/scheduler/console.ts +368 -0
- package/src/scheduler/constants.ts +27 -0
- package/src/scheduler/contracts/Scheduler.ts +123 -0
- package/src/scheduler/contracts/SchedulerConsole.ts +40 -0
- package/src/scheduler/contracts/SchedulerWorker.ts +23 -0
- package/src/scheduler/contracts/index.ts +3 -0
- package/src/scheduler/examples/RecoverableSummaryJob.ts +18 -0
- package/src/scheduler/examples/WriteDailySummaryJob.ts +17 -0
- package/src/scheduler/examples/registerDailySummary.ts +13 -0
- package/src/scheduler/examples/runDailySummary.ts +46 -0
- package/src/scheduler/examples/runScheduledReplay.ts +60 -0
- package/src/scheduler/index.ts +9 -0
- package/src/scheduler/scheduleTime.ts +78 -0
- package/src/security/README.md +130 -0
- package/src/security/Security.ts +346 -0
- package/src/security/SecurityError.ts +16 -0
- package/src/security/contracts/SecurityOptions.ts +20 -0
- package/src/security/contracts/SecurityPayload.ts +14 -0
- package/src/security/contracts/index.ts +2 -0
- package/src/security/ensureAppKey.ts +82 -0
- package/src/security/examples/runSecretRoundTrip.ts +42 -0
- package/src/security/index.ts +4 -0
- package/src/serialization/README.md +169 -0
- package/src/serialization/Serializable.ts +17 -0
- package/src/serialization/SerializationError.ts +91 -0
- package/src/serialization/SerializationRegistry.ts +208 -0
- package/src/serialization/SerializationRegistryError.ts +24 -0
- package/src/serialization/Serializer.ts +793 -0
- package/src/serialization/contracts/SerializableClass.ts +26 -0
- package/src/serialization/contracts/SerializedValue.ts +71 -0
- package/src/serialization/contracts/SerializerOptions.ts +19 -0
- package/src/serialization/contracts/SerializerService.ts +29 -0
- package/src/serialization/contracts/index.ts +4 -0
- package/src/serialization/examples/ExportRequest.ts +25 -0
- package/src/serialization/examples/runExportSerialization.ts +24 -0
- package/src/serialization/index.ts +6 -0
- package/src/server/App.ts +326 -0
- package/src/server/README.md +219 -0
- package/src/server/RequestContext.ts +122 -0
- package/src/server/appContext.ts +59 -0
- package/src/server/examples/createFirstServer.ts +25 -0
- package/src/server/examples/startFirstServer.ts +19 -0
- package/src/server/index.ts +16 -0
- package/src/ssr/README.md +158 -0
- package/src/ssr/constants.ts +8 -0
- package/src/ssr/contracts/DocumentHead.ts +35 -0
- package/src/ssr/contracts/SsrRenderContext.ts +25 -0
- package/src/ssr/contracts/SsrRenderResult.ts +23 -0
- package/src/ssr/contracts/SsrRenderer.ts +12 -0
- package/src/ssr/contracts/SsrRequest.ts +17 -0
- package/src/ssr/contracts/index.ts +19 -0
- package/src/ssr/createSsrRenderContext.ts +25 -0
- package/src/ssr/examples/createPublicPageServer.ts +32 -0
- package/src/ssr/examples/runPublicPages.ts +25 -0
- package/src/ssr/fastify/contracts/FastifySsrOptions.ts +24 -0
- package/src/ssr/fastify/contracts/index.ts +5 -0
- package/src/ssr/fastify/fastifySsr.ts +110 -0
- package/src/ssr/fastify/index.ts +2 -0
- package/src/ssr/index.ts +10 -0
- package/src/ssr/renderDocumentHead.ts +72 -0
- package/src/ssr/renderSsrDocument.ts +35 -0
- package/src/ssr/serializeSsrState.ts +19 -0
- package/src/ssr/vite/contracts/ViteSsrOptions.ts +52 -0
- package/src/ssr/vite/contracts/index.ts +6 -0
- package/src/ssr/vite/fastifyViteSsr.ts +279 -0
- package/src/ssr/vite/index.ts +4 -0
- package/src/ssr/vite/viteSsrManifest.ts +92 -0
- package/src/storage/README.md +310 -0
- package/src/storage/Storage.ts +392 -0
- package/src/storage/contents.ts +23 -0
- package/src/storage/contracts/StorageListing.ts +55 -0
- package/src/storage/contracts/index.ts +1 -0
- package/src/storage/drivers/FlystorageDisk.ts +295 -0
- package/src/storage/drivers/FlystorageListing.ts +78 -0
- package/src/storage/drivers/LocalStorageDisk.ts +45 -0
- package/src/storage/drivers/S3StorageDisk.ts +114 -0
- package/src/storage/drivers/index.ts +3 -0
- package/src/storage/examples/runStorage.ts +37 -0
- package/src/storage/examples/runStreamExport.ts +41 -0
- package/src/storage/examples/writeCsvExport.ts +45 -0
- package/src/storage/index.ts +7 -0
- package/src/storage/mime.ts +30 -0
- package/src/storage/path.ts +76 -0
- package/src/storage/types.ts +251 -0
- package/src/url/README.md +41 -0
- package/src/url/UrlGenerator.ts +72 -0
- package/src/url/contracts/UrlGeneratorOptions.ts +14 -0
- package/src/url/contracts/index.ts +1 -0
- package/src/url/examples/runApplicationLinks.ts +33 -0
- package/src/url/index.ts +2 -0
- package/src/validation/README.md +433 -0
- package/src/validation/examples/runNoteValidation.ts +18 -0
- package/src/validation/examples/validateNoteInput.ts +31 -0
- package/src/validation/index.ts +398 -0
- package/templates/AGENTS.md +15 -0
|
@@ -0,0 +1,756 @@
|
|
|
1
|
+
import {
|
|
2
|
+
access,
|
|
3
|
+
mkdir,
|
|
4
|
+
open,
|
|
5
|
+
readdir,
|
|
6
|
+
readFile,
|
|
7
|
+
rename,
|
|
8
|
+
unlink,
|
|
9
|
+
writeFile,
|
|
10
|
+
} from 'node:fs/promises';
|
|
11
|
+
import {
|
|
12
|
+
basename,
|
|
13
|
+
dirname,
|
|
14
|
+
extname,
|
|
15
|
+
isAbsolute,
|
|
16
|
+
join,
|
|
17
|
+
} from 'node:path';
|
|
18
|
+
import type { Knex } from 'knex';
|
|
19
|
+
import type {
|
|
20
|
+
DatabaseCheckResult,
|
|
21
|
+
DatabaseMigrationManagerOptions,
|
|
22
|
+
DatabaseMigrationState,
|
|
23
|
+
DatabaseMigrationStatus,
|
|
24
|
+
DatabaseSyncResult,
|
|
25
|
+
MakeMigrationOptions,
|
|
26
|
+
MakeMigrationResult,
|
|
27
|
+
MigrateOptions,
|
|
28
|
+
MigrateResult,
|
|
29
|
+
SchemaMigrationPlan,
|
|
30
|
+
SchemaSnapshot,
|
|
31
|
+
} from './contracts';
|
|
32
|
+
import { inspectDatabaseSchema } from './DatabaseSchemaInspector';
|
|
33
|
+
import {
|
|
34
|
+
DatabaseMigrationBaselineError,
|
|
35
|
+
DatabaseMigrationLockError,
|
|
36
|
+
DatabaseMigrationSourceGenerationError,
|
|
37
|
+
} from './errors';
|
|
38
|
+
import { renderKnexMigration } from './KnexMigrationRenderer';
|
|
39
|
+
import { collectModelSchema } from './ModelSchemaCollector';
|
|
40
|
+
import { diffSchemaSnapshots } from './SchemaDiffer';
|
|
41
|
+
import { promoteDestructiveSchemaChanges } from './promoteDestructiveSchemaChanges';
|
|
42
|
+
import {
|
|
43
|
+
emptySchemaSnapshot,
|
|
44
|
+
parseSchemaSnapshot,
|
|
45
|
+
serializeSchemaSnapshot,
|
|
46
|
+
} from './SchemaSnapshotSerializer';
|
|
47
|
+
|
|
48
|
+
const DEFAULT_MIGRATION_TABLE = 'knex_migrations';
|
|
49
|
+
const DEFAULT_LOAD_EXTENSIONS = ['.ts', '.js', '.mjs', '.cjs'] as const;
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Reusable application-configured model migration service.
|
|
53
|
+
*
|
|
54
|
+
* CLI commands, development HTTP actions, and deployment scripts should call
|
|
55
|
+
* this service rather than duplicating model collection or Knex execution.
|
|
56
|
+
*/
|
|
57
|
+
export class DatabaseMigrationManager {
|
|
58
|
+
readonly #options: Required<Pick<
|
|
59
|
+
DatabaseMigrationManagerOptions,
|
|
60
|
+
'migrationTableName' | 'loadExtensions' | 'environment' | 'generationLockFile' | 'now'
|
|
61
|
+
>> & DatabaseMigrationManagerOptions;
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Creates a migration manager with app-owned models, paths, and ledger name.
|
|
65
|
+
*
|
|
66
|
+
* @param options - Database connection, model registry, and absolute source paths.
|
|
67
|
+
*/
|
|
68
|
+
constructor(options: DatabaseMigrationManagerOptions) {
|
|
69
|
+
assertAbsolutePath(options.migrationsDirectory, 'migrationsDirectory');
|
|
70
|
+
assertAbsolutePath(options.snapshotFile, 'snapshotFile');
|
|
71
|
+
|
|
72
|
+
const generationLockFile = options.generationLockFile
|
|
73
|
+
?? `${options.snapshotFile}.lock`;
|
|
74
|
+
|
|
75
|
+
assertAbsolutePath(generationLockFile, 'generationLockFile');
|
|
76
|
+
|
|
77
|
+
if (options.dialect.name !== 'mariadb') {
|
|
78
|
+
throw new Error('Generated database migrations currently support MariaDB only.');
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
this.#options = {
|
|
82
|
+
...options,
|
|
83
|
+
models: [...options.models],
|
|
84
|
+
migrationTableName: options.migrationTableName ?? DEFAULT_MIGRATION_TABLE,
|
|
85
|
+
loadExtensions: options.loadExtensions ?? DEFAULT_LOAD_EXTENSIONS,
|
|
86
|
+
environment: options.environment ?? process.env.NODE_ENV ?? 'development',
|
|
87
|
+
generationLockFile,
|
|
88
|
+
now: options.now ?? (() => new Date()),
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Returns model, snapshot, live database, and Knex migration status without
|
|
94
|
+
* creating the Knex migration ledger.
|
|
95
|
+
*
|
|
96
|
+
* @returns Structured status suitable for CLI or development UI rendering.
|
|
97
|
+
*/
|
|
98
|
+
async status(): Promise<DatabaseMigrationStatus> {
|
|
99
|
+
const desired = this.#collectModels();
|
|
100
|
+
const snapshot = await this.#readSnapshot();
|
|
101
|
+
const generationPlan = diffSchemaSnapshots(
|
|
102
|
+
snapshot ?? emptySchemaSnapshot(this.#options.dialect.name),
|
|
103
|
+
desired,
|
|
104
|
+
);
|
|
105
|
+
const database = await inspectDatabaseSchema(
|
|
106
|
+
this.#options.db,
|
|
107
|
+
desired,
|
|
108
|
+
this.#options.dialect,
|
|
109
|
+
);
|
|
110
|
+
const databasePlan = diffSchemaSnapshots(database, desired);
|
|
111
|
+
|
|
112
|
+
return {
|
|
113
|
+
snapshotExists: snapshot !== null,
|
|
114
|
+
modelsMatchSnapshot: !planHasChanges(generationPlan),
|
|
115
|
+
databaseMatchesModels: !planHasChanges(databasePlan),
|
|
116
|
+
generationPlan,
|
|
117
|
+
databasePlan,
|
|
118
|
+
migrations: await this.#readMigrationState(),
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Checks the live model-owned database subset against current models.
|
|
124
|
+
*
|
|
125
|
+
* Extra columns and tables are ignored to preserve additive blue/green
|
|
126
|
+
* compatibility, while missing or incompatible requirements are reported.
|
|
127
|
+
*
|
|
128
|
+
* @returns Structured database compatibility result.
|
|
129
|
+
*/
|
|
130
|
+
async check(): Promise<DatabaseCheckResult> {
|
|
131
|
+
const desired = this.#collectModels();
|
|
132
|
+
const snapshot = await this.#readSnapshot();
|
|
133
|
+
const database = await inspectDatabaseSchema(
|
|
134
|
+
this.#options.db,
|
|
135
|
+
desired,
|
|
136
|
+
this.#options.dialect,
|
|
137
|
+
);
|
|
138
|
+
const plan = diffSchemaSnapshots(database, desired);
|
|
139
|
+
const snapshotPlan = diffSchemaSnapshots(
|
|
140
|
+
snapshot ?? emptySchemaSnapshot(this.#options.dialect.name),
|
|
141
|
+
desired,
|
|
142
|
+
);
|
|
143
|
+
const migrations = await this.#readMigrationState();
|
|
144
|
+
const schemaMatches = !planHasChanges(plan);
|
|
145
|
+
const modelsMatchSnapshot = snapshot !== null
|
|
146
|
+
&& !planHasChanges(snapshotPlan);
|
|
147
|
+
|
|
148
|
+
return {
|
|
149
|
+
schemaMatches,
|
|
150
|
+
modelsMatchSnapshot,
|
|
151
|
+
matches: schemaMatches
|
|
152
|
+
&& modelsMatchSnapshot
|
|
153
|
+
&& migrations.pending.length === 0
|
|
154
|
+
&& migrations.missingFiles.length === 0,
|
|
155
|
+
plan,
|
|
156
|
+
snapshotPlan,
|
|
157
|
+
migrations,
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* Generates a frozen migration and advances the committed snapshot when
|
|
163
|
+
* current models contain only supported changes.
|
|
164
|
+
*
|
|
165
|
+
* @param options - Optional human-readable migration name.
|
|
166
|
+
* @returns Generation result including blocked changes or written file path.
|
|
167
|
+
*/
|
|
168
|
+
async makeMigration(
|
|
169
|
+
options: MakeMigrationOptions = {},
|
|
170
|
+
): Promise<MakeMigrationResult> {
|
|
171
|
+
this.#assertSourceGenerationAllowed();
|
|
172
|
+
|
|
173
|
+
return await this.#withGenerationLock(async () => {
|
|
174
|
+
return await this.#makeMigrationUnlocked(options);
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* Applies pending committed migrations through Knex's ledger and lock.
|
|
180
|
+
*
|
|
181
|
+
* @param options - Optional matching-database baseline policy.
|
|
182
|
+
* @returns Applied migration names, batch, and optional baselined filenames.
|
|
183
|
+
*/
|
|
184
|
+
async migrate(options: MigrateOptions = {}): Promise<MigrateResult> {
|
|
185
|
+
const baselined = options.baselineIfMatching
|
|
186
|
+
? await this.#baselinePendingMigrationsIfMatching()
|
|
187
|
+
: null;
|
|
188
|
+
const result = await this.#options.db.migrate.latest(this.#knexConfig());
|
|
189
|
+
const batch = Array.isArray(result) && typeof result[0] === 'number'
|
|
190
|
+
? result[0]
|
|
191
|
+
: null;
|
|
192
|
+
const applied = Array.isArray(result) && Array.isArray(result[1])
|
|
193
|
+
? result[1].map(String)
|
|
194
|
+
: [];
|
|
195
|
+
|
|
196
|
+
return {
|
|
197
|
+
applied,
|
|
198
|
+
batch,
|
|
199
|
+
baselined,
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* Runs the development convenience flow under one generation lock.
|
|
205
|
+
*
|
|
206
|
+
* A blocked model diff returns immediately without applying migrations. A
|
|
207
|
+
* successful flow always finishes with a live database compatibility check.
|
|
208
|
+
*
|
|
209
|
+
* @param options - Optional human-readable generated migration name.
|
|
210
|
+
* @returns Structured make, migrate, and check results.
|
|
211
|
+
*/
|
|
212
|
+
async sync(options: MakeMigrationOptions = {}): Promise<DatabaseSyncResult> {
|
|
213
|
+
this.#assertSourceGenerationAllowed();
|
|
214
|
+
|
|
215
|
+
return await this.#withGenerationLock(async () => {
|
|
216
|
+
const make = await this.#makeMigrationUnlocked(options);
|
|
217
|
+
|
|
218
|
+
if (make.blocked) {
|
|
219
|
+
return {
|
|
220
|
+
make,
|
|
221
|
+
migrate: null,
|
|
222
|
+
check: null,
|
|
223
|
+
};
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
const migrate = await this.migrate({ baselineIfMatching: true });
|
|
227
|
+
const check = await this.check();
|
|
228
|
+
|
|
229
|
+
return { make, migrate, check };
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
/**
|
|
234
|
+
* Performs source generation while the caller owns the cross-process lock.
|
|
235
|
+
*
|
|
236
|
+
* @param options - Optional human-readable migration name.
|
|
237
|
+
* @returns Generation result including blocked changes or written file path.
|
|
238
|
+
*/
|
|
239
|
+
async #makeMigrationUnlocked(
|
|
240
|
+
options: MakeMigrationOptions,
|
|
241
|
+
): Promise<MakeMigrationResult> {
|
|
242
|
+
const desired = this.#collectModels();
|
|
243
|
+
const snapshot = await this.#readSnapshot();
|
|
244
|
+
const previous = snapshot ?? emptySchemaSnapshot(this.#options.dialect.name);
|
|
245
|
+
const rawPlan = diffSchemaSnapshots(previous, desired);
|
|
246
|
+
const plan = options.allowDestructive
|
|
247
|
+
? promoteDestructiveSchemaChanges(rawPlan)
|
|
248
|
+
: rawPlan;
|
|
249
|
+
|
|
250
|
+
if (plan.blockedChanges.length > 0) {
|
|
251
|
+
return {
|
|
252
|
+
generated: false,
|
|
253
|
+
blocked: true,
|
|
254
|
+
file: null,
|
|
255
|
+
plan: rawPlan,
|
|
256
|
+
};
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
if (plan.safeChanges.length === 0) {
|
|
260
|
+
if (!snapshot) {
|
|
261
|
+
await writeSnapshotAtomically(this.#options.snapshotFile, desired);
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
return {
|
|
265
|
+
generated: false,
|
|
266
|
+
blocked: false,
|
|
267
|
+
file: null,
|
|
268
|
+
plan,
|
|
269
|
+
};
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
const name = migrationName(options.name, plan);
|
|
273
|
+
const file = join(
|
|
274
|
+
this.#options.migrationsDirectory,
|
|
275
|
+
`${formatMigrationTimestamp(this.#options.now())}_${name}.ts`,
|
|
276
|
+
);
|
|
277
|
+
const source = renderKnexMigration(plan);
|
|
278
|
+
|
|
279
|
+
await writeMigrationAndSnapshotAtomically(
|
|
280
|
+
file,
|
|
281
|
+
source,
|
|
282
|
+
this.#options.snapshotFile,
|
|
283
|
+
desired,
|
|
284
|
+
);
|
|
285
|
+
|
|
286
|
+
return {
|
|
287
|
+
generated: true,
|
|
288
|
+
blocked: false,
|
|
289
|
+
file,
|
|
290
|
+
plan,
|
|
291
|
+
};
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
/**
|
|
295
|
+
* Collects the current app model registry as a normalized snapshot.
|
|
296
|
+
*
|
|
297
|
+
* @returns Current desired database state.
|
|
298
|
+
*/
|
|
299
|
+
#collectModels(): SchemaSnapshot {
|
|
300
|
+
return collectModelSchema(this.#options.models, this.#options.dialect);
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
/**
|
|
304
|
+
* Reads the committed desired snapshot when one exists.
|
|
305
|
+
*
|
|
306
|
+
* @returns Parsed snapshot or null before the first generation.
|
|
307
|
+
*/
|
|
308
|
+
async #readSnapshot(): Promise<SchemaSnapshot | null> {
|
|
309
|
+
try {
|
|
310
|
+
return parseSchemaSnapshot(
|
|
311
|
+
await readFile(this.#options.snapshotFile, 'utf8'),
|
|
312
|
+
);
|
|
313
|
+
} catch (error) {
|
|
314
|
+
if (isNodeError(error, 'ENOENT')) return null;
|
|
315
|
+
|
|
316
|
+
throw error;
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
/**
|
|
321
|
+
* Reads migration files and any existing Knex ledger without causing Knex to
|
|
322
|
+
* create its ledger tables as a side effect.
|
|
323
|
+
*
|
|
324
|
+
* @returns Completed, pending, and corrupt missing-file migration names.
|
|
325
|
+
*/
|
|
326
|
+
async #readMigrationState(): Promise<DatabaseMigrationState> {
|
|
327
|
+
const files = await this.#readMigrationFiles();
|
|
328
|
+
const completed = await this.#readCompletedMigrations();
|
|
329
|
+
const fileSet = new Set(files);
|
|
330
|
+
const completedSet = new Set(completed);
|
|
331
|
+
|
|
332
|
+
return {
|
|
333
|
+
completed,
|
|
334
|
+
pending: files.filter(file => !completedSet.has(file)),
|
|
335
|
+
missingFiles: completed.filter(file => !fileSet.has(file)),
|
|
336
|
+
};
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
/**
|
|
340
|
+
* Adopts pending migrations when an existing untracked database exactly
|
|
341
|
+
* satisfies the committed schema snapshot.
|
|
342
|
+
*
|
|
343
|
+
* Empty databases execute migration DDL normally. A partial or mismatching
|
|
344
|
+
* database raises a structured baseline error instead of guessing. Once a
|
|
345
|
+
* second permanent migration exists, local databases that never recorded the
|
|
346
|
+
* initial ledger entry still need this path — matching against the snapshot
|
|
347
|
+
* end-state baselines every pending file without replaying create-table DDL.
|
|
348
|
+
*
|
|
349
|
+
* @returns Baselined filenames, or null when normal migration should proceed.
|
|
350
|
+
*/
|
|
351
|
+
async #baselinePendingMigrationsIfMatching(): Promise<string[] | null> {
|
|
352
|
+
const state = await this.#readMigrationState();
|
|
353
|
+
|
|
354
|
+
if (
|
|
355
|
+
state.completed.length > 0
|
|
356
|
+
|| state.pending.length === 0
|
|
357
|
+
|| state.missingFiles.length > 0
|
|
358
|
+
) {
|
|
359
|
+
return null;
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
const snapshot = await this.#readSnapshot();
|
|
363
|
+
|
|
364
|
+
if (!snapshot) {
|
|
365
|
+
throw new Error('Cannot baseline a database without a committed schema snapshot.');
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
const database = await inspectDatabaseSchema(
|
|
369
|
+
this.#options.db,
|
|
370
|
+
snapshot,
|
|
371
|
+
this.#options.dialect,
|
|
372
|
+
);
|
|
373
|
+
|
|
374
|
+
if (database.tables.length === 0) {
|
|
375
|
+
return null;
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
const plan = diffSchemaSnapshots(database, snapshot);
|
|
379
|
+
|
|
380
|
+
if (planHasChanges(plan)) {
|
|
381
|
+
throw new DatabaseMigrationBaselineError(plan);
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
const {
|
|
385
|
+
directory: _directory,
|
|
386
|
+
loadExtensions: _loadExtensions,
|
|
387
|
+
...baselineConfig
|
|
388
|
+
} = this.#knexConfig();
|
|
389
|
+
|
|
390
|
+
await this.#options.db.migrate.latest({
|
|
391
|
+
...baselineConfig,
|
|
392
|
+
migrationSource: new NoopMigrationSource(state.pending),
|
|
393
|
+
});
|
|
394
|
+
|
|
395
|
+
return [...state.pending];
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
/**
|
|
399
|
+
* Returns permanent migration filenames accepted by configured extensions.
|
|
400
|
+
*
|
|
401
|
+
* @returns Lexically sorted migration basenames.
|
|
402
|
+
*/
|
|
403
|
+
async #readMigrationFiles(): Promise<string[]> {
|
|
404
|
+
try {
|
|
405
|
+
const entries = await readdir(this.#options.migrationsDirectory, {
|
|
406
|
+
withFileTypes: true,
|
|
407
|
+
});
|
|
408
|
+
const extensions = new Set(this.#options.loadExtensions);
|
|
409
|
+
|
|
410
|
+
return entries
|
|
411
|
+
.filter(entry => entry.isFile() && extensions.has(extname(entry.name)))
|
|
412
|
+
.map(entry => entry.name)
|
|
413
|
+
.sort();
|
|
414
|
+
} catch (error) {
|
|
415
|
+
if (isNodeError(error, 'ENOENT')) return [];
|
|
416
|
+
|
|
417
|
+
throw error;
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
/**
|
|
422
|
+
* Reads completed migration names when the app's Knex ledger already exists.
|
|
423
|
+
*
|
|
424
|
+
* @returns Ordered completed migration names.
|
|
425
|
+
*/
|
|
426
|
+
async #readCompletedMigrations(): Promise<string[]> {
|
|
427
|
+
const schema = this.#options.migrationSchemaName
|
|
428
|
+
? this.#options.db.schema.withSchema(this.#options.migrationSchemaName)
|
|
429
|
+
: this.#options.db.schema;
|
|
430
|
+
const exists = await schema.hasTable(this.#options.migrationTableName);
|
|
431
|
+
|
|
432
|
+
if (!exists) return [];
|
|
433
|
+
|
|
434
|
+
const query = this.#options.migrationSchemaName
|
|
435
|
+
? this.#options.db
|
|
436
|
+
.withSchema(this.#options.migrationSchemaName)
|
|
437
|
+
.from<{ name: unknown }>(this.#options.migrationTableName)
|
|
438
|
+
: this.#options.db<{ name: unknown }>(this.#options.migrationTableName);
|
|
439
|
+
const rows = await query.select('name').orderBy('id');
|
|
440
|
+
|
|
441
|
+
return rows.map(row => String(row.name));
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
/**
|
|
445
|
+
* Returns the shared Knex migration configuration used by every execution.
|
|
446
|
+
*
|
|
447
|
+
* @returns Knex directory, ledger, extension, and MariaDB transaction policy.
|
|
448
|
+
*/
|
|
449
|
+
#knexConfig(): Knex.MigratorConfig {
|
|
450
|
+
return {
|
|
451
|
+
directory: this.#options.migrationsDirectory,
|
|
452
|
+
tableName: this.#options.migrationTableName,
|
|
453
|
+
schemaName: this.#options.migrationSchemaName,
|
|
454
|
+
loadExtensions: this.#options.loadExtensions,
|
|
455
|
+
disableTransactions: true,
|
|
456
|
+
};
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
/**
|
|
460
|
+
* Rejects all source-writing entry points in a production environment.
|
|
461
|
+
*/
|
|
462
|
+
#assertSourceGenerationAllowed(): void {
|
|
463
|
+
if (this.#options.environment.trim().toLowerCase() === 'production') {
|
|
464
|
+
throw new DatabaseMigrationSourceGenerationError();
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
/**
|
|
469
|
+
* Acquires and releases the app's cross-process source-generation lock.
|
|
470
|
+
*
|
|
471
|
+
* @param callback - Generation work that must have exclusive filesystem access.
|
|
472
|
+
* @returns Callback result.
|
|
473
|
+
*/
|
|
474
|
+
async #withGenerationLock<TResult>(
|
|
475
|
+
callback: () => Promise<TResult>,
|
|
476
|
+
): Promise<TResult> {
|
|
477
|
+
await mkdir(dirname(this.#options.generationLockFile), { recursive: true });
|
|
478
|
+
|
|
479
|
+
let handle;
|
|
480
|
+
|
|
481
|
+
try {
|
|
482
|
+
handle = await open(this.#options.generationLockFile, 'wx');
|
|
483
|
+
await handle.writeFile(JSON.stringify({
|
|
484
|
+
pid: process.pid,
|
|
485
|
+
createdAt: new Date().toISOString(),
|
|
486
|
+
}));
|
|
487
|
+
} catch (error) {
|
|
488
|
+
if (handle) {
|
|
489
|
+
await handle.close().catch(() => undefined);
|
|
490
|
+
await unlink(this.#options.generationLockFile).catch(() => undefined);
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
if (isNodeError(error, 'EEXIST')) {
|
|
494
|
+
throw new DatabaseMigrationLockError(this.#options.generationLockFile);
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
throw error;
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
try {
|
|
501
|
+
return await callback();
|
|
502
|
+
} finally {
|
|
503
|
+
await handle.close();
|
|
504
|
+
await unlink(this.#options.generationLockFile).catch(error => {
|
|
505
|
+
if (!isNodeError(error, 'ENOENT')) throw error;
|
|
506
|
+
});
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
/**
|
|
512
|
+
* Knex migration source that records matching migrations while intentionally
|
|
513
|
+
* performing no schema DDL.
|
|
514
|
+
*/
|
|
515
|
+
class NoopMigrationSource implements Knex.MigrationSource<string> {
|
|
516
|
+
readonly #migrationNames: readonly string[];
|
|
517
|
+
|
|
518
|
+
/**
|
|
519
|
+
* Creates a baseline migration source for one or more pending filenames.
|
|
520
|
+
*
|
|
521
|
+
* @param migrationNames - Permanent migration filenames to record as complete.
|
|
522
|
+
*/
|
|
523
|
+
constructor(migrationNames: readonly string[]) {
|
|
524
|
+
this.#migrationNames = [...migrationNames];
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
/**
|
|
528
|
+
* Returns the pending migration names being baselined.
|
|
529
|
+
*
|
|
530
|
+
* @returns Migration collection.
|
|
531
|
+
*/
|
|
532
|
+
async getMigrations(): Promise<string[]> {
|
|
533
|
+
return [...this.#migrationNames];
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
/**
|
|
537
|
+
* Returns the stable Knex ledger name for one source entry.
|
|
538
|
+
*
|
|
539
|
+
* @param migration - Source entry.
|
|
540
|
+
* @returns Knex ledger filename.
|
|
541
|
+
*/
|
|
542
|
+
getMigrationName(migration: string): string {
|
|
543
|
+
return migration;
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
/**
|
|
547
|
+
* Returns a no-op migration used only after an exact live schema match.
|
|
548
|
+
*
|
|
549
|
+
* @returns Knex-compatible migration implementation.
|
|
550
|
+
*/
|
|
551
|
+
async getMigration(): Promise<Knex.Migration> {
|
|
552
|
+
return {
|
|
553
|
+
/**
|
|
554
|
+
* Records the baseline without repeating already-installed DDL.
|
|
555
|
+
*
|
|
556
|
+
* @returns Already-resolved promise.
|
|
557
|
+
*/
|
|
558
|
+
async up(): Promise<void> {},
|
|
559
|
+
|
|
560
|
+
/**
|
|
561
|
+
* Refuses rollback of an adopted database baseline.
|
|
562
|
+
*
|
|
563
|
+
* @returns Promise that always rejects without changing the database.
|
|
564
|
+
*/
|
|
565
|
+
async down(): Promise<void> {
|
|
566
|
+
throw new Error('Database baselines are forward-only.');
|
|
567
|
+
},
|
|
568
|
+
};
|
|
569
|
+
}
|
|
570
|
+
}
|
|
571
|
+
|
|
572
|
+
/**
|
|
573
|
+
* Reports whether a schema plan contains any safe or blocked difference.
|
|
574
|
+
*
|
|
575
|
+
* @param plan - Pure schema comparison result.
|
|
576
|
+
* @returns True when snapshots do not match.
|
|
577
|
+
*/
|
|
578
|
+
function planHasChanges(plan: SchemaMigrationPlan): boolean {
|
|
579
|
+
return plan.safeChanges.length > 0 || plan.blockedChanges.length > 0;
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
/**
|
|
583
|
+
* Writes one generated migration and its new snapshot as a coordinated pair.
|
|
584
|
+
*
|
|
585
|
+
* Temporary files are fully written before either destination is renamed. If
|
|
586
|
+
* advancing the snapshot fails after the migration rename, the new migration
|
|
587
|
+
* is removed so the committed lineage cannot be left half-advanced.
|
|
588
|
+
*
|
|
589
|
+
* @param migrationFile - Final absolute migration filename.
|
|
590
|
+
* @param source - Frozen TypeScript migration source.
|
|
591
|
+
* @param snapshotFile - Final absolute snapshot filename.
|
|
592
|
+
* @param snapshot - New desired schema snapshot.
|
|
593
|
+
*/
|
|
594
|
+
async function writeMigrationAndSnapshotAtomically(
|
|
595
|
+
migrationFile: string,
|
|
596
|
+
source: string,
|
|
597
|
+
snapshotFile: string,
|
|
598
|
+
snapshot: SchemaSnapshot,
|
|
599
|
+
): Promise<void> {
|
|
600
|
+
await mkdir(dirname(migrationFile), { recursive: true });
|
|
601
|
+
await mkdir(dirname(snapshotFile), { recursive: true });
|
|
602
|
+
|
|
603
|
+
const migrationTemporary = temporaryFileName(migrationFile);
|
|
604
|
+
const snapshotTemporary = temporaryFileName(snapshotFile);
|
|
605
|
+
let migrationMoved = false;
|
|
606
|
+
|
|
607
|
+
try {
|
|
608
|
+
await access(migrationFile).then(
|
|
609
|
+
() => {
|
|
610
|
+
throw new Error(`Migration file already exists: ${migrationFile}`);
|
|
611
|
+
},
|
|
612
|
+
() => undefined,
|
|
613
|
+
);
|
|
614
|
+
await Promise.all([
|
|
615
|
+
writeFile(migrationTemporary, source, { encoding: 'utf8', flag: 'wx' }),
|
|
616
|
+
writeFile(snapshotTemporary, serializeSchemaSnapshot(snapshot), {
|
|
617
|
+
encoding: 'utf8',
|
|
618
|
+
flag: 'wx',
|
|
619
|
+
}),
|
|
620
|
+
]);
|
|
621
|
+
await rename(migrationTemporary, migrationFile);
|
|
622
|
+
migrationMoved = true;
|
|
623
|
+
await rename(snapshotTemporary, snapshotFile);
|
|
624
|
+
} catch (error) {
|
|
625
|
+
if (migrationMoved) {
|
|
626
|
+
await unlink(migrationFile).catch(() => undefined);
|
|
627
|
+
}
|
|
628
|
+
|
|
629
|
+
throw error;
|
|
630
|
+
} finally {
|
|
631
|
+
await Promise.all([
|
|
632
|
+
unlink(migrationTemporary).catch(() => undefined),
|
|
633
|
+
unlink(snapshotTemporary).catch(() => undefined),
|
|
634
|
+
]);
|
|
635
|
+
}
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
/**
|
|
639
|
+
* Writes a snapshot through a same-directory temporary file and atomic rename.
|
|
640
|
+
*
|
|
641
|
+
* @param snapshotFile - Final absolute snapshot filename.
|
|
642
|
+
* @param snapshot - New desired schema snapshot.
|
|
643
|
+
*/
|
|
644
|
+
async function writeSnapshotAtomically(
|
|
645
|
+
snapshotFile: string,
|
|
646
|
+
snapshot: SchemaSnapshot,
|
|
647
|
+
): Promise<void> {
|
|
648
|
+
await mkdir(dirname(snapshotFile), { recursive: true });
|
|
649
|
+
|
|
650
|
+
const temporary = temporaryFileName(snapshotFile);
|
|
651
|
+
|
|
652
|
+
try {
|
|
653
|
+
await writeFile(temporary, serializeSchemaSnapshot(snapshot), {
|
|
654
|
+
encoding: 'utf8',
|
|
655
|
+
flag: 'wx',
|
|
656
|
+
});
|
|
657
|
+
await rename(temporary, snapshotFile);
|
|
658
|
+
} finally {
|
|
659
|
+
await unlink(temporary).catch(() => undefined);
|
|
660
|
+
}
|
|
661
|
+
}
|
|
662
|
+
|
|
663
|
+
/**
|
|
664
|
+
* Creates a process-specific same-directory temporary filename.
|
|
665
|
+
*
|
|
666
|
+
* @param file - Final destination path.
|
|
667
|
+
* @returns Temporary filename safe for atomic rename.
|
|
668
|
+
*/
|
|
669
|
+
function temporaryFileName(file: string): string {
|
|
670
|
+
return join(dirname(file), `.${basename(file)}.${process.pid}.tmp`);
|
|
671
|
+
}
|
|
672
|
+
|
|
673
|
+
/**
|
|
674
|
+
* Produces a sortable UTC timestamp used by Knex migration filenames.
|
|
675
|
+
*
|
|
676
|
+
* @param date - Generation time.
|
|
677
|
+
* @returns Compact YYYYMMDDHHmmss timestamp.
|
|
678
|
+
*/
|
|
679
|
+
function formatMigrationTimestamp(date: Date): string {
|
|
680
|
+
if (!Number.isFinite(date.getTime())) {
|
|
681
|
+
throw new Error('Migration generation clock returned an invalid date.');
|
|
682
|
+
}
|
|
683
|
+
|
|
684
|
+
return date.toISOString().replace(/[-:T]/g, '').slice(0, 14);
|
|
685
|
+
}
|
|
686
|
+
|
|
687
|
+
/**
|
|
688
|
+
* Resolves a supplied or inferred migration name to a safe filename slug.
|
|
689
|
+
*
|
|
690
|
+
* @param requested - Optional caller-provided migration name.
|
|
691
|
+
* @param plan - Schema plan used for deterministic name inference.
|
|
692
|
+
* @returns Lower-case underscore-separated filename segment.
|
|
693
|
+
*/
|
|
694
|
+
function migrationName(
|
|
695
|
+
requested: string | undefined,
|
|
696
|
+
plan: SchemaMigrationPlan,
|
|
697
|
+
): string {
|
|
698
|
+
const inferred = requested?.trim() || inferMigrationName(plan);
|
|
699
|
+
const slug = inferred
|
|
700
|
+
.toLowerCase()
|
|
701
|
+
.replace(/[^a-z0-9]+/g, '_')
|
|
702
|
+
.replace(/^_+|_+$/g, '');
|
|
703
|
+
|
|
704
|
+
if (!slug) {
|
|
705
|
+
throw new Error('Migration name must contain at least one letter or number.');
|
|
706
|
+
}
|
|
707
|
+
|
|
708
|
+
return slug;
|
|
709
|
+
}
|
|
710
|
+
|
|
711
|
+
/**
|
|
712
|
+
* Infers a concise filename from a simple migration plan.
|
|
713
|
+
*
|
|
714
|
+
* @param plan - Safe non-empty migration plan.
|
|
715
|
+
* @returns Human-readable migration name.
|
|
716
|
+
*/
|
|
717
|
+
function inferMigrationName(plan: SchemaMigrationPlan): string {
|
|
718
|
+
if (plan.safeChanges.length === 1) {
|
|
719
|
+
const change = plan.safeChanges[0];
|
|
720
|
+
|
|
721
|
+
if (change?.kind === 'create_table') {
|
|
722
|
+
return `create_${change.table.name}`;
|
|
723
|
+
}
|
|
724
|
+
|
|
725
|
+
if (change?.kind === 'add_column') {
|
|
726
|
+
return `add_${change.column.name}_to_${change.tableName}`;
|
|
727
|
+
}
|
|
728
|
+
}
|
|
729
|
+
|
|
730
|
+
return 'update_database_schema';
|
|
731
|
+
}
|
|
732
|
+
|
|
733
|
+
/**
|
|
734
|
+
* Validates that app-owned source locations do not depend on process cwd.
|
|
735
|
+
*
|
|
736
|
+
* @param value - Configured path.
|
|
737
|
+
* @param option - Configuration field included in validation errors.
|
|
738
|
+
*/
|
|
739
|
+
function assertAbsolutePath(value: string, option: string): void {
|
|
740
|
+
if (!isAbsolute(value)) {
|
|
741
|
+
throw new Error(`${option} must be an absolute path.`);
|
|
742
|
+
}
|
|
743
|
+
}
|
|
744
|
+
|
|
745
|
+
/**
|
|
746
|
+
* Narrows a Node filesystem error to a specific code.
|
|
747
|
+
*
|
|
748
|
+
* @param error - Unknown caught error.
|
|
749
|
+
* @param code - Expected Node error code.
|
|
750
|
+
* @returns True when the error exposes the requested code.
|
|
751
|
+
*/
|
|
752
|
+
function isNodeError(error: unknown, code: string): error is NodeJS.ErrnoException {
|
|
753
|
+
return error instanceof Error
|
|
754
|
+
&& 'code' in error
|
|
755
|
+
&& (error as NodeJS.ErrnoException).code === code;
|
|
756
|
+
}
|