Skip to main content

Built and signed on GitHub Actions

Works with
This package works with DenoIt is unknown whether this package works with Cloudflare Workers, Node.js, Bun, Browsers
It is unknown whether this package works with Cloudflare Workers
It is unknown whether this package works with Node.js
This package works with Deno
It is unknown whether this package works with Bun
It is unknown whether this package works with Browsers
•JSR Score100%•
License
Apache-2.0
•
Downloads292/wk
•
Publisheda day ago (0.0.10)

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

f
fixZodImports(
zodOutputDir: string,
options?: FixZodImportsOptions
): Promise<FixZodImportsResult>

Fix relative imports in generated Zod files by adding .ts extensions and optionally fix Decimal imports for browser compatibility.

f
generateZodSchemas(options: GenerateZodOptions): Promise<number>

Generate Zod schemas from Prisma models

f
generateZodSchemasCli(options: GenerateZodOptions): Promise<never>

CLI runner for Zod generation Exits with the command's exit code

f
isRetriableMigrationFailure(stderr: string): boolean

Determine whether a failed Prisma invocation matches the transient, retriable signature.

f
patchPrismaClient(
generatedDir: string,
options?: PatchPrismaClientOptions
): Promise<PatchPrismaClientResult>

Patch a Prisma-generated directory for isomorphic imports.

f
runFixZodImports(
zodOutputDir: string,
options?: FixZodImportsOptions
): Promise<void>

CLI runner for fix-zod-imports Call this from your database-specific script

f
runMigration(options: MigrationOptions): Promise<number>

Run Prisma migration

f
runMigrationCli(options: MigrationOptions): Promise<never>

CLI runner for migrations Parses --config=

f
runMigrationWithArtifacts(options: MigrationOptions): Promise<MigrationExecutionResult>

Create a migration and verify its filesystem artifact and applied database state.

f
runPatchPrismaClient(
generatedDir: string,
options?: PatchPrismaClientOptions
): Promise<void>

CLI runner: patch a single generated directory and log a summary.

f
runPrismaWithRetry(
invocation: PrismaInvocation,
options: RunPrismaWithRetryOptions
): Promise<number>

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.

f
runWriteCrudZodBarrel(
zodOutputDir: string,
modelName: string
): Promise<void>

CLI-friendly wrapper for writing the complete generated CRUD Zod alias barrel.

f
writeCrudZodBarrel(options: WriteCrudZodBarrelOptions): Promise<string>

Write a generated CRUD alias barrel containing every discovered Prisma model.

Interfaces

I

Options for generated Zod schema post-processing.

  • Whether to replace Prisma Decimal imports with duck-typed validators.

  • verbose: boolean

    Whether to print progress messages.

I

Summary of generated Zod schema post-processing changes.

I

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

I

Verified artifacts produced and applied by one migration invocation.

  • applied: readonly string[]

    Created migration names verified as applied to the database.

  • code: number

    Process-style exit code.

  • created: readonly string[]

    Migration directory names created by this invocation.

I

Application migration inputs, execution bounds and injectable process boundary.

  • 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.

  • 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.log when 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_CLOSE during its can-connect-to-database preflight (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.

  • Maximum delay in milliseconds between transient-failure retries.

  • Explicit migration name override.

  • 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

I

Options for Prisma client patching.

  • verbose: boolean

    Enable console logging (default: true)

I

Summary of Prisma client patching changes.

  • clientPatched: boolean

    Whether client.ts was patched to an isomorphic façade

  • Whether export type Decimal was added to prismaNamespaceBrowser.ts

I

A single Prisma CLI command invocation managed by the retry runner.

  • args: readonly string[]

    Prisma CLI arguments passed after deno run -A npm:prisma.

  • label: string

    Human-readable command label used in diagnostics.

I

Per-attempt execution controls passed to a Prisma spawner.

  • timeoutMs: number

    Optional timeout for non-interactive child processes, in milliseconds.

I

Result of a single Prisma subprocess invocation.

  • code: number

    Process exit code.

  • stderr: string

    Captured stderr text (empty when stderr was inherited).

I

Options governing a bounded, signature-scoped Prisma retry.

  • Timeout for one non-interactive Prisma subprocess attempt, in milliseconds.

  • 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.

  • 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).

I

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

T
PrismaSpawn = (
args: readonly string[],
interactive: boolean,
options: PrismaSpawnOptions
) => Promise<PrismaSpawnResult>

Spawns a single deno run -A npm:prisma <args> invocation.