@netscript/database@0.0.10Built and signed on GitHub ActionsBuilt and signed on GitHub Actions
The database integration layer for NetScript: one provider-agnostic adapter contract plus Prisma v7 driver adapters for PostgreSQL, SQL Server, and MySQL, with connection-string helpers, JSON extensions, and OpenTelemetry tracing.
Database Scripts - Barrel Export
Re-exports all database utility scripts.
Functions
Fix relative imports in generated Zod files by adding .ts extensions and optionally fix Decimal imports for browser compatibility.
Generate Zod schemas from Prisma models
CLI runner for Zod generation Exits with the command's exit code
Determine whether a failed Prisma invocation matches the transient, retriable signature.
Patch a Prisma-generated directory for isomorphic imports.
CLI runner for fix-zod-imports Call this from your database-specific script
Run Prisma migration
CLI runner for migrations Parses --config=
Create a migration and verify its filesystem artifact and applied database state.
CLI runner: patch a single generated directory and log a summary.
Run a single Prisma CLI invocation with a bounded retry that fires only on the transient schema-engine premature-close signature. Interactive runs execute exactly once and are never retried (a prompt is not a transient engine crash). Every non-transient failure returns immediately so real schema/SQL errors are never masked.
CLI-friendly wrapper for writing the complete generated CRUD Zod alias barrel.
Write a generated CRUD alias barrel containing every discovered Prisma model.
Interfaces
Options for generated Zod schema post-processing.
- fixDecimalImports: boolean
Whether to replace Prisma Decimal imports with duck-typed validators.
- verbose: boolean
Whether to print progress messages.
Summary of generated Zod schema post-processing changes.
- decimalFilesFixed: number
Number of files with Decimal compatibility fixes.
- decimalImportsFixed: number
Number of Decimal references fixed.
- filesFixed: number
Number of files with relative imports fixed.
- importsFixed: number
Number of relative import specifiers fixed.
Options for Prisma Zod schema generation.
- configPath: string
Path to prisma.config.ts (relative to working directory)
- verbose: boolean
Enable verbose logging
- zodOutputDir: string
Path to the generated Zod output directory
Verified artifacts produced and applied by one migration invocation.
Application migration inputs, execution bounds and injectable process boundary.
- attemptTimeoutMs: number
Maximum duration in milliseconds for one non-interactive Prisma child process attempt before it is killed and treated as a transient engine lifecycle failure. This prevents Aspire db-init executables from sitting in a non-terminal state until the outer operation timeout expires.
- baseRetryDelayMs: number
Base delay in milliseconds between transient-failure retries. Backoff is exponential in the attempt index and capped by
maxRetryDelayMs. - configPath: string
Path to prisma.config.ts (relative to working directory)
- interactive: boolean
Override terminal detection for hosts and deterministic tests.
- log: (message: string) => void
Diagnostic sink; defaults to
console.logwhen verbose. - maxAttempts: number
Maximum number of attempts for a single Prisma invocation. The Prisma schema engine is a separate subprocess that intermittently dies on Windows with
ERR_STREAM_PREMATURE_CLOSEduring itscan-connect-to-databasepreflight (engine binary first-touch / AV scan / cold cache). That failure occurs before any migration SQL is written, so re-running is idempotent. Only that transient signature is retried; every other failure returns immediately so real schema/SQL errors are never masked. The default budget allows cold Windows engine startup / antivirus first-touch delays to clear without making permanent failures look successful. - maxRetryDelayMs: number
Maximum delay in milliseconds between transient-failure retries.
- migrationName: string
Explicit migration name override.
- migrationsPath: string
Migration directory to inventory before and after creation.
- provider: "mssql" | "postgres" | "mysql" | "sqlite"
Database provider ('mssql' | 'postgres' | 'mysql' | 'sqlite')
- schemaPath: string
Schema directory containing installed *.migration.sql contributions (default schema).
- spawn: PrismaSpawn
Injectable Prisma process boundary.
- verbose: boolean
Enable verbose logging
Options for Prisma client patching.
- verbose: boolean
Enable console logging (default: true)
Summary of Prisma client patching changes.
- clientPatched: boolean
Whether client.ts was patched to an isomorphic façade
- decimalTypeAdded: boolean
Whether export type Decimal was added to prismaNamespaceBrowser.ts
A single Prisma CLI command invocation managed by the retry runner.
Per-attempt execution controls passed to a Prisma spawner.
- timeoutMs: number
Optional timeout for non-interactive child processes, in milliseconds.
Result of a single Prisma subprocess invocation.
Options governing a bounded, signature-scoped Prisma retry.
- attemptTimeoutMs: number
Timeout for one non-interactive Prisma subprocess attempt, in milliseconds.
- baseRetryDelayMs: number
Base retry delay in milliseconds.
- interactive: boolean
Whether the invocation may prompt and therefore must not be retried.
- log: (message: string) => void
Diagnostic sink for retry and exhaustion messages.
- maxAttempts: number
Maximum number of attempts for a non-interactive transient failure.
- maxRetryDelayMs: number
Maximum retry delay in milliseconds after exponential backoff.
- sleep: (ms: number) => Promise<void>
Injectable delay (defaults to
setTimeout). - spawn: PrismaSpawn
Injectable spawner (defaults to a real
Deno.Command).
Options for writing the generated CRUD Zod alias barrel.
- modelName: string
Scaffold's primary Prisma model, used when generated model discovery is unavailable.
- zodOutputDir: string
Generated Zod output directory.
Type Aliases
Spawns a single deno run -A npm:prisma <args> invocation.