@pgxsinkit/pgwasm-pg-dump 0.6.2 → 0.6.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js.map CHANGED
@@ -3,11 +3,11 @@
3
3
  "sources": ["../src/errors.ts", "../src/pg-dump.ts", "../src/artefacts.ts", "../src/framing.ts", "../src/output.ts", "../src/session.ts", "../src/wasm.ts"],
4
4
  "sourcesContent": [
5
5
  "import { PgwasmError, UnsupportedFeatureError } from \"@pgxsinkit/pgwasm\";\n\n/**\n * The database's Postgres build cannot run pg_dump: its wire does not deliver a reply inside the call\n * that sends the message (`capabilities.synchronousExchange` is false). pg_dump's WebAssembly calls its\n * socket callbacks synchronously and needs each reply before the callback returns. Nothing was loaded\n * or run.\n */\nexport class PgDumpUnsupportedBuildError extends UnsupportedFeatureError {\n override name = \"PgDumpUnsupportedBuildError\";\n /** The build's name. */\n readonly build: string;\n\n constructor(build: string) {\n super(\n `pg_dump needs a Postgres build whose wire replies synchronously (capabilities.synchronousExchange); the ` +\n `\"${build}\" build does not.`,\n );\n this.build = build;\n }\n}\n\n/** pg_dump exited with a failure, or crashed (`exitCode` null). */\nexport class PgDumpError extends PgwasmError {\n override name = \"PgDumpError\";\n /** pg_dump's exit status; `null` when it crashed instead of exiting. */\n readonly exitCode: number | null;\n /** Everything pg_dump wrote to standard error. */\n readonly stderr: string;\n\n constructor(message: string, exitCode: number | null, stderr: string, options?: ErrorOptions) {\n super(message, options);\n this.exitCode = exitCode;\n this.stderr = stderr;\n }\n}\n\n/**\n * The database session was not in a state to dump from, or could not be put back as it was after the\n * dump. pg_dump runs on the database's own session: before it, the session must be outside any\n * transaction block (pg_dump opens and ends its own); after it, pg_dump's transaction is ended and every\n * session setting it changed is restored. `unrestored` names the settings that still differ.\n */\nexport class PgDumpSessionError extends PgwasmError {\n override name = \"PgDumpSessionError\";\n readonly unrestored: readonly string[];\n\n constructor(message: string, unrestored: readonly string[] = [], options?: ErrorOptions) {\n super(message, options);\n this.unrestored = unrestored;\n }\n}\n",
6
- "// Began as a copy of `@electric-sql/pglite-tools` (taken under PGlite's PostgreSQL License option,\n// © ElectricSQL — see NOTICE). Owned outright (ADR-0062); compatibility with PGlite is an anti-goal.\n\nimport type { Pgwasm } from \"@pgxsinkit/pgwasm\";\nimport { PgwasmClosedError, PgwasmFailedError } from \"@pgxsinkit/pgwasm\";\nimport { protocol, type PgwasmProtocol } from \"@pgxsinkit/pgwasm/protocol\";\n\nimport { createPgDumpModule, pgDumpWasm } from \"./artefacts\";\nimport { PgDumpError, PgDumpSessionError, PgDumpUnsupportedBuildError } from \"./errors\";\nimport { ByteQueue, FrontendFramer } from \"./framing\";\nimport { dumpFile } from \"./output\";\nimport { readSession, restoreSession, transactionStatus, type SessionState } from \"./session\";\nimport { compileModule } from \"./wasm\";\n\nexport interface PgDumpOptions {\n /** The database to dump. Its Postgres build must reply synchronously (`capabilities.synchronousExchange`). */\n readonly pg: Pgwasm;\n /**\n * More pg_dump arguments (https://www.postgresql.org/docs/current/app-pgdump.html), placed before the\n * fixed ones, which win: `-U postgres --inserts -j 1 -f <output>`.\n */\n readonly args?: readonly string[];\n /** The returned file's name. Defaults to `dump.sql`. */\n readonly fileName?: string;\n}\n\n/** Where pg_dump's own filesystem has it; `argv[0]`, which pg_dump resolves to find itself. */\nconst PG_DUMP_PATH = \"/bin/pg_dump\";\n/** The output file, in pg_dump's own filesystem, read back once it exits. */\nconst OUTPUT_PATH = \"/tmp/out.sql\";\n\nconst FIXED_ARGS: readonly string[] = [\n // The user named in the startup packet; the session already runs as the database's own role.\n \"-U\",\n \"postgres\",\n // INSERT statements rather than COPY … FROM stdin, so `exec()` can run the dump back.\n \"--inserts\",\n // One job: there is one session and no second connection.\n \"-j\",\n \"1\",\n // A file in pg_dump's filesystem, which pgDump returns.\n \"-f\",\n OUTPUT_PATH,\n];\n\ninterface PgDumpRun {\n /** pg_dump's exit status; null when it crashed. */\n readonly exitCode: number | null;\n readonly crash: unknown;\n readonly stderr: string;\n /** The output file, when pg_dump exited 0 and wrote one. */\n readonly output: Uint8Array | undefined;\n /** The first failure of the database's wire, which pg_dump only saw as a closed connection. */\n readonly wireFailure: { readonly error: unknown } | undefined;\n}\n\n/**\n * Run pg_dump once, in a fresh module over the compiled WebAssembly, its socket bridged to the database's\n * wire. pg_dump's WebAssembly calls the write and read callbacks synchronously: a whole frontend message\n * goes out on the build's synchronous exchange, whose reply is queued before the write callback returns,\n * for the read callback to hand back.\n */\nasync function runPgDump(wire: PgwasmProtocol, wasm: WebAssembly.Module, args: readonly string[]): Promise<PgDumpRun> {\n let stderr = \"\";\n let rejectInstantiation: (error: unknown) => void = () => undefined;\n const instantiationFailed = new Promise<never>((_, reject) => {\n rejectInstantiation = reject;\n });\n const module = await Promise.race([\n createPgDumpModule({\n thisProgram: PG_DUMP_PATH,\n noExitRuntime: false,\n // A stdin that is always at EOF, so a browser never prompts.\n stdin: () => null,\n print: () => undefined,\n printErr: (text) => {\n stderr += `${text}\\n`;\n },\n instantiateWasm: (imports, successCallback) => {\n // A throw from `successCallback` (the module's own start-up) must settle the race too, or pgDump\n // would wait forever while holding the session.\n WebAssembly.instantiate(wasm, imports)\n .then((instance) => successCallback(instance, wasm))\n .catch(rejectInstantiation);\n return {};\n },\n preRun: [\n (mod) => {\n mod.ENV[\"HOME\"] = \"/home/postgres\";\n mod.ENV[\"USER\"] = \"postgres\";\n mod.ENV[\"LOGNAME\"] = \"postgres\";\n // pg_dump looks for its own executable when it starts, and warns when it finds none.\n mod.FS.mkdirTree(PG_DUMP_PATH.slice(0, PG_DUMP_PATH.lastIndexOf(\"/\")));\n mod.FS.writeFile(PG_DUMP_PATH, \"\");\n mod.FS.chmod(PG_DUMP_PATH, 0o555);\n },\n ],\n }),\n instantiationFailed,\n ]);\n\n const framer = new FrontendFramer();\n const replies = new ByteQueue();\n const exchanges: Promise<void>[] = [];\n let wireFailure: { error: unknown } | undefined;\n const write = module.addFunction((pointer, length) => {\n for (const message of framer.push(module.HEAPU8.subarray(pointer, pointer + length))) {\n // pg_dump only reads: nothing to persist. The build's synchronous exchange has queued the whole\n // reply before this returns; a rejection is kept for after pg_dump exits.\n const exchange = wire.execProtocolRawStream(message, {\n persist: false,\n onRawData: (chunk) => replies.push(chunk),\n });\n exchanges.push(\n exchange.catch((error: unknown) => {\n wireFailure ??= { error };\n }),\n );\n }\n return length;\n }, \"iii\");\n const read = module.addFunction(\n (pointer, maxLength) => replies.read(module.HEAPU8.subarray(pointer, pointer + maxLength)),\n \"iii\",\n );\n module._pgwasm_set_rw_cbs(read, write);\n\n let exitCode: number | null;\n let crash: unknown;\n try {\n exitCode = module.callMain([...args, ...FIXED_ARGS]);\n } catch (error) {\n exitCode = null;\n crash = error;\n }\n await Promise.all(exchanges);\n\n let output: Uint8Array | undefined;\n if (exitCode === 0 && module.FS.analyzePath(OUTPUT_PATH).exists) {\n try {\n output = module.FS.readFile(OUTPUT_PATH);\n } catch (error) {\n crash = error;\n }\n }\n return { exitCode, crash, stderr, output, wireFailure };\n}\n\nfunction failureOf(run: PgDumpRun): Error | undefined {\n if (run.wireFailure !== undefined) {\n const { error } = run.wireFailure;\n return error instanceof Error ? error : new Error(String(error));\n }\n if (run.exitCode === null) {\n return new PgDumpError(\n `pg_dump crashed: ${run.crash instanceof Error ? run.crash.message : String(run.crash)}`,\n null,\n run.stderr,\n { cause: run.crash },\n );\n }\n if (run.exitCode !== 0) {\n return new PgDumpError(\n `pg_dump failed with exit code ${run.exitCode}${run.stderr === \"\" ? \"\" : `: ${run.stderr.trim()}`}`,\n run.exitCode,\n run.stderr,\n );\n }\n if (run.output === undefined) {\n return new PgDumpError(\n \"pg_dump exited without writing a single output file (the directory format writes several, which \" +\n \"pgDump does not return)\",\n 0,\n run.stderr,\n run.crash === undefined ? undefined : { cause: run.crash },\n );\n }\n return undefined;\n}\n\nconst messageOf = (error: unknown) => (error instanceof Error ? error.message : String(error));\n\n/**\n * What to throw when the session could not be restored after pg_dump. When pg_dump had failed as well,\n * its failure is not dropped: it is the cause of the error thrown.\n */\nfunction restoreError(restoreFailure: unknown, dumpFailure: { readonly error: unknown } | undefined): unknown {\n // A failed or closed database fails every exchange; that is the error to report.\n if (restoreFailure instanceof PgwasmFailedError || restoreFailure instanceof PgwasmClosedError) {\n return restoreFailure;\n }\n const sessionError = restoreFailure instanceof PgDumpSessionError ? restoreFailure : undefined;\n if (dumpFailure === undefined) {\n return (\n sessionError ??\n new PgDumpSessionError(\"The database's session could not be restored after pg_dump.\", [], {\n cause: restoreFailure,\n })\n );\n }\n const message =\n sessionError?.message ??\n `The database's session could not be restored after pg_dump (${messageOf(restoreFailure)}).`;\n return new PgDumpSessionError(\n `${message} pg_dump itself had failed: ${messageOf(dumpFailure.error)}`,\n sessionError?.unrestored ?? [],\n { cause: dumpFailure.error },\n );\n}\n\n/**\n * Dump a database with pg_dump, as a `File`: by default a plain SQL script of INSERT statements, which\n * `exec()` runs back into an empty database.\n *\n * pg_dump runs on the database's own session, which it holds for the whole dump: no query, transaction\n * or other dump of this database runs until it is done, and none can be running inside a transaction\n * block when it starts ({@link PgDumpSessionError}). Afterwards the session is as it was: pg_dump's\n * transaction ended, its prepared statements gone, every setting it changed restored. It must not be\n * called inside a `pg.transaction()` callback: it would wait forever for the session that transaction\n * holds.\n *\n * @throws {PgDumpUnsupportedBuildError} the database's build cannot run pg_dump (checked first).\n * @throws {PgDumpError} pg_dump failed; it carries the exit code and standard error.\n * @throws {PgDumpSessionError} the session was inside a transaction block, or could not be restored\n * (then, when pg_dump had failed too, its failure is the cause).\n */\nexport async function pgDump({ pg, args = [], fileName = \"dump.sql\" }: PgDumpOptions): Promise<File> {\n const wire = protocol(pg);\n if (!wire.capabilities.synchronousExchange) throw new PgDumpUnsupportedBuildError(pg.build.name);\n const wasm = compileModule(pgDumpWasm);\n\n return await wire.runExclusiveSession(async () => {\n if ((await transactionStatus(wire)) !== \"I\") {\n throw new PgDumpSessionError(\n \"The database's session is inside a transaction block; pg_dump opens and ends its own transaction, \" +\n \"so it runs only between transactions.\",\n );\n }\n const before: SessionState = await readSession(wire);\n\n let outcome: { readonly run: PgDumpRun } | { readonly failure: unknown };\n try {\n outcome = { run: await runPgDump(wire, await wasm, args) };\n } catch (failure) {\n outcome = { failure };\n }\n\n try {\n await restoreSession(wire, before);\n } catch (restoreFailure) {\n const dumpFailure = \"failure\" in outcome ? { error: outcome.failure } : failureOf(outcome.run);\n throw restoreError(restoreFailure, dumpFailure instanceof Error ? { error: dumpFailure } : dumpFailure);\n }\n\n if (\"failure\" in outcome) throw outcome.failure;\n const failure = failureOf(outcome.run);\n if (failure !== undefined) throw failure;\n return dumpFile(outcome.run.output ?? new Uint8Array(), fileName);\n });\n}\n",
6
+ "// Began as a copy of `@electric-sql/pglite-tools` (taken under PGlite's PostgreSQL License option,\n// © ElectricSQL — see NOTICE). Owned outright (ADR-0062); compatibility with PGlite is an anti-goal.\n\nimport type { Pgwasm } from \"@pgxsinkit/pgwasm\";\nimport { PgwasmClosedError, PgwasmFailedError } from \"@pgxsinkit/pgwasm\";\nimport { type PgwasmProtocol, protocol } from \"@pgxsinkit/pgwasm/protocol\";\n\nimport { createPgDumpModule, pgDumpWasm } from \"./artefacts\";\nimport { PgDumpError, PgDumpSessionError, PgDumpUnsupportedBuildError } from \"./errors\";\nimport { ByteQueue, FrontendFramer } from \"./framing\";\nimport { dumpFile } from \"./output\";\nimport { readSession, restoreSession, type SessionState, transactionStatus } from \"./session\";\nimport { compileModule } from \"./wasm\";\n\nexport interface PgDumpOptions {\n /** The database to dump. Its Postgres build must reply synchronously (`capabilities.synchronousExchange`). */\n readonly pg: Pgwasm;\n /**\n * More pg_dump arguments (https://www.postgresql.org/docs/current/app-pgdump.html), placed before the\n * fixed ones, which win: `-U postgres --inserts -j 1 -f <output>`.\n */\n readonly args?: readonly string[];\n /** The returned file's name. Defaults to `dump.sql`. */\n readonly fileName?: string;\n}\n\n/** Where pg_dump's own filesystem has it; `argv[0]`, which pg_dump resolves to find itself. */\nconst PG_DUMP_PATH = \"/bin/pg_dump\";\n/** The output file, in pg_dump's own filesystem, read back once it exits. */\nconst OUTPUT_PATH = \"/tmp/out.sql\";\n\nconst FIXED_ARGS: readonly string[] = [\n // The user named in the startup packet; the session already runs as the database's own role.\n \"-U\",\n \"postgres\",\n // INSERT statements rather than COPY … FROM stdin, so `exec()` can run the dump back.\n \"--inserts\",\n // One job: there is one session and no second connection.\n \"-j\",\n \"1\",\n // A file in pg_dump's filesystem, which pgDump returns.\n \"-f\",\n OUTPUT_PATH,\n];\n\ninterface PgDumpRun {\n /** pg_dump's exit status; null when it crashed. */\n readonly exitCode: number | null;\n readonly crash: unknown;\n readonly stderr: string;\n /** The output file, when pg_dump exited 0 and wrote one. */\n readonly output: Uint8Array | undefined;\n /** The first failure of the database's wire, which pg_dump only saw as a closed connection. */\n readonly wireFailure: { readonly error: unknown } | undefined;\n}\n\n/**\n * Run pg_dump once, in a fresh module over the compiled WebAssembly, its socket bridged to the database's\n * wire. pg_dump's WebAssembly calls the write and read callbacks synchronously: a whole frontend message\n * goes out on the build's synchronous exchange, whose reply is queued before the write callback returns,\n * for the read callback to hand back.\n */\nasync function runPgDump(wire: PgwasmProtocol, wasm: WebAssembly.Module, args: readonly string[]): Promise<PgDumpRun> {\n let stderr = \"\";\n let rejectInstantiation: (error: unknown) => void = () => undefined;\n const instantiationFailed = new Promise<never>((_, reject) => {\n rejectInstantiation = reject;\n });\n const module = await Promise.race([\n createPgDumpModule({\n thisProgram: PG_DUMP_PATH,\n noExitRuntime: false,\n // A stdin that is always at EOF, so a browser never prompts.\n stdin: () => null,\n print: () => undefined,\n printErr: (text) => {\n stderr += `${text}\\n`;\n },\n instantiateWasm: (imports, successCallback) => {\n // A throw from `successCallback` (the module's own start-up) must settle the race too, or pgDump\n // would wait forever while holding the session.\n WebAssembly.instantiate(wasm, imports)\n .then((instance) => successCallback(instance, wasm))\n .catch(rejectInstantiation);\n return {};\n },\n preRun: [\n (mod) => {\n mod.ENV[\"HOME\"] = \"/home/postgres\";\n mod.ENV[\"USER\"] = \"postgres\";\n mod.ENV[\"LOGNAME\"] = \"postgres\";\n // pg_dump looks for its own executable when it starts, and warns when it finds none.\n mod.FS.mkdirTree(PG_DUMP_PATH.slice(0, PG_DUMP_PATH.lastIndexOf(\"/\")));\n mod.FS.writeFile(PG_DUMP_PATH, \"\");\n mod.FS.chmod(PG_DUMP_PATH, 0o555);\n },\n ],\n }),\n instantiationFailed,\n ]);\n\n const framer = new FrontendFramer();\n const replies = new ByteQueue();\n const exchanges: Promise<void>[] = [];\n let wireFailure: { error: unknown } | undefined;\n const write = module.addFunction((pointer, length) => {\n for (const message of framer.push(module.HEAPU8.subarray(pointer, pointer + length))) {\n // pg_dump only reads: nothing to persist. The build's synchronous exchange has queued the whole\n // reply before this returns; a rejection is kept for after pg_dump exits.\n const exchange = wire.execProtocolRawStream(message, {\n persist: false,\n onRawData: (chunk) => replies.push(chunk),\n });\n exchanges.push(\n exchange.catch((error: unknown) => {\n wireFailure ??= { error };\n }),\n );\n }\n return length;\n }, \"iii\");\n const read = module.addFunction(\n (pointer, maxLength) => replies.read(module.HEAPU8.subarray(pointer, pointer + maxLength)),\n \"iii\",\n );\n module._pgwasm_set_rw_cbs(read, write);\n\n let exitCode: number | null;\n let crash: unknown;\n try {\n exitCode = module.callMain([...args, ...FIXED_ARGS]);\n } catch (error) {\n exitCode = null;\n crash = error;\n }\n await Promise.all(exchanges);\n\n let output: Uint8Array | undefined;\n if (exitCode === 0 && module.FS.analyzePath(OUTPUT_PATH).exists) {\n try {\n output = module.FS.readFile(OUTPUT_PATH);\n } catch (error) {\n crash = error;\n }\n }\n return { exitCode, crash, stderr, output, wireFailure };\n}\n\nfunction failureOf(run: PgDumpRun): Error | undefined {\n if (run.wireFailure !== undefined) {\n const { error } = run.wireFailure;\n return error instanceof Error ? error : new Error(String(error));\n }\n if (run.exitCode === null) {\n return new PgDumpError(\n `pg_dump crashed: ${run.crash instanceof Error ? run.crash.message : String(run.crash)}`,\n null,\n run.stderr,\n { cause: run.crash },\n );\n }\n if (run.exitCode !== 0) {\n return new PgDumpError(\n `pg_dump failed with exit code ${run.exitCode}${run.stderr === \"\" ? \"\" : `: ${run.stderr.trim()}`}`,\n run.exitCode,\n run.stderr,\n );\n }\n if (run.output === undefined) {\n return new PgDumpError(\n \"pg_dump exited without writing a single output file (the directory format writes several, which \" +\n \"pgDump does not return)\",\n 0,\n run.stderr,\n run.crash === undefined ? undefined : { cause: run.crash },\n );\n }\n return undefined;\n}\n\nconst messageOf = (error: unknown) => (error instanceof Error ? error.message : String(error));\n\n/**\n * What to throw when the session could not be restored after pg_dump. When pg_dump had failed as well,\n * its failure is not dropped: it is the cause of the error thrown.\n */\nfunction restoreError(restoreFailure: unknown, dumpFailure: { readonly error: unknown } | undefined): unknown {\n // A failed or closed database fails every exchange; that is the error to report.\n if (restoreFailure instanceof PgwasmFailedError || restoreFailure instanceof PgwasmClosedError) {\n return restoreFailure;\n }\n const sessionError = restoreFailure instanceof PgDumpSessionError ? restoreFailure : undefined;\n if (dumpFailure === undefined) {\n return (\n sessionError ??\n new PgDumpSessionError(\"The database's session could not be restored after pg_dump.\", [], {\n cause: restoreFailure,\n })\n );\n }\n const message =\n sessionError?.message ??\n `The database's session could not be restored after pg_dump (${messageOf(restoreFailure)}).`;\n return new PgDumpSessionError(\n `${message} pg_dump itself had failed: ${messageOf(dumpFailure.error)}`,\n sessionError?.unrestored ?? [],\n { cause: dumpFailure.error },\n );\n}\n\n/**\n * Dump a database with pg_dump, as a `File`: by default a plain SQL script of INSERT statements, which\n * `exec()` runs back into an empty database.\n *\n * pg_dump runs on the database's own session, which it holds for the whole dump: no query, transaction\n * or other dump of this database runs until it is done, and none can be running inside a transaction\n * block when it starts ({@link PgDumpSessionError}). Afterwards the session is as it was: pg_dump's\n * transaction ended, its prepared statements gone, every setting it changed restored. It must not be\n * called inside a `pg.transaction()` callback: it would wait forever for the session that transaction\n * holds.\n *\n * @throws {PgDumpUnsupportedBuildError} the database's build cannot run pg_dump (checked first).\n * @throws {PgDumpError} pg_dump failed; it carries the exit code and standard error.\n * @throws {PgDumpSessionError} the session was inside a transaction block, or could not be restored\n * (then, when pg_dump had failed too, its failure is the cause).\n */\nexport async function pgDump({ pg, args = [], fileName = \"dump.sql\" }: PgDumpOptions): Promise<File> {\n const wire = protocol(pg);\n if (!wire.capabilities.synchronousExchange) throw new PgDumpUnsupportedBuildError(pg.build.name);\n const wasm = compileModule(pgDumpWasm);\n\n return await wire.runExclusiveSession(async () => {\n if ((await transactionStatus(wire)) !== \"I\") {\n throw new PgDumpSessionError(\n \"The database's session is inside a transaction block; pg_dump opens and ends its own transaction, \" +\n \"so it runs only between transactions.\",\n );\n }\n const before: SessionState = await readSession(wire);\n\n let outcome: { readonly run: PgDumpRun } | { readonly failure: unknown };\n try {\n outcome = { run: await runPgDump(wire, await wasm, args) };\n } catch (failure) {\n outcome = { failure };\n }\n\n try {\n await restoreSession(wire, before);\n } catch (restoreFailure) {\n const dumpFailure = \"failure\" in outcome ? { error: outcome.failure } : failureOf(outcome.run);\n throw restoreError(restoreFailure, dumpFailure instanceof Error ? { error: dumpFailure } : dumpFailure);\n }\n\n if (\"failure\" in outcome) throw outcome.failure;\n const failure = failureOf(outcome.run);\n if (failure !== undefined) throw failure;\n return dumpFile(outcome.run.output ?? new Uint8Array(), fileName);\n });\n}\n",
7
7
  "/**\n * pg_dump's artefacts, referenced relative to this module so bundlers copy and fingerprint them.\n *\n * This is the ONLY module that names `../artefacts/`: Bun.build rewrites neither a relative external\n * import nor `new URL(\"…\", import.meta.url)` when it bundles a module into a shallower output, and this\n * file is bundled into `dist/index.js`, one level below the package root like itself\n * (tests/unit/pgwasm-artefacts.test.ts enforces the rule). The `new URL` stays a literal so bundlers can\n * see it.\n */\n\nimport createPgDumpModule from \"../artefacts/pg_dump.js\";\n\n/** The pg_dump WebAssembly module. */\nexport const pgDumpWasm = new URL(\"../artefacts/pg_dump.wasm\", import.meta.url);\n\nexport { createPgDumpModule };\n",
8
8
  "/**\n * Frontend messages out of libpq's `send()` calls.\n *\n * On a Unix-socket connection, which pg_dump's is, libpq sends its output in whole 8 KiB blocks as a\n * message is added and keeps the rest for its next send (`pqPutMsgEnd`), so a longer message reaches\n * pg_dump's write callback in pieces; one call can also carry several messages. The session must only\n * be handed whole messages: a piece makes the backend read past the end of its input. The first message of a connection is a startup packet (a length, then its body);\n * every later one is a type byte, then a length that counts itself.\n */\nexport class FrontendFramer {\n #pending: Uint8Array = new Uint8Array(0);\n #startup = true;\n\n /** Take a copy of `bytes`; return every message that is now complete, in order. */\n push(bytes: Uint8Array): Uint8Array[] {\n const joined = new Uint8Array(this.#pending.byteLength + bytes.byteLength);\n joined.set(this.#pending, 0);\n joined.set(bytes, this.#pending.byteLength);\n const messages: Uint8Array[] = [];\n let offset = 0;\n for (;;) {\n const header = this.#startup ? 4 : 5;\n if (joined.byteLength - offset < header) break;\n const lengthAt = offset + header - 4;\n const length = new DataView(joined.buffer, joined.byteOffset + lengthAt, 4).getUint32(0, false);\n if (length < 4) throw new Error(`pg_dump sent a frontend message with an invalid length (${length})`);\n const end = lengthAt + length;\n if (joined.byteLength < end) break;\n messages.push(joined.slice(offset, end));\n offset = end;\n this.#startup = false;\n }\n this.#pending = joined.slice(offset);\n return messages;\n }\n\n /** Bytes of an incomplete message, still waiting for the rest. */\n get pendingBytes(): number {\n return this.#pending.byteLength;\n }\n}\n\n/** Backend bytes waiting for libpq's `recv()`, read in whatever sizes it asks for. */\nexport class ByteQueue {\n readonly #chunks: Uint8Array[] = [];\n #head = 0;\n\n /** Keep a copy of `bytes`. */\n push(bytes: Uint8Array): void {\n if (bytes.byteLength > 0) this.#chunks.push(bytes.slice());\n }\n\n /** Move up to `target.byteLength` bytes into `target`; returns how many were moved. */\n read(target: Uint8Array): number {\n let written = 0;\n while (written < target.byteLength && this.#chunks.length > 0) {\n const chunk = this.#chunks[0];\n if (chunk === undefined) break;\n const take = Math.min(chunk.byteLength - this.#head, target.byteLength - written);\n target.set(chunk.subarray(this.#head, this.#head + take), written);\n written += take;\n this.#head += take;\n if (this.#head === chunk.byteLength) {\n this.#chunks.shift();\n this.#head = 0;\n }\n }\n return written;\n }\n}\n",
9
9
  "/**\n * pg_dump's output file, as the `File` pgDump returns.\n *\n * A plain-format dump is an SQL script. pg_dump brackets it in psql's `\\restrict <key>` /\n * `\\unrestrict <key>` meta-commands, which only psql understands; the script is meant for `exec()`, so\n * those two lines are removed. They are found by pg_dump's random key, so a row whose text happens to\n * hold a line starting `\\restrict` is left alone. The custom and tar formats and a compressed plain dump\n * are returned byte for byte.\n */\n\nconst encoder = new TextEncoder();\n\nfunction startsWith(bytes: Uint8Array, prefix: ArrayLike<number>, at = 0): boolean {\n if (at + prefix.length > bytes.byteLength) return false;\n for (let index = 0; index < prefix.length; index++) {\n if (bytes[at + index] !== prefix[index]) return false;\n }\n return true;\n}\n\n/** A format other than an uncompressed plain script: custom (`PGDMP`), tar (`ustar`), or gzip. */\nfunction isArchive(bytes: Uint8Array): boolean {\n return (\n startsWith(bytes, encoder.encode(\"PGDMP\")) ||\n startsWith(bytes, encoder.encode(\"ustar\"), 257) ||\n startsWith(bytes, [0x1f, 0x8b])\n );\n}\n\nfunction indexOfBytes(haystack: Uint8Array, needle: Uint8Array, from = 0): number {\n const first = needle[0];\n if (first === undefined) return -1;\n for (let at = haystack.indexOf(first, from); at !== -1; at = haystack.indexOf(first, at + 1)) {\n if (at + needle.byteLength > haystack.byteLength) return -1;\n if (startsWith(haystack, needle, at)) return at;\n }\n return -1;\n}\n\nfunction lastIndexOfBytes(haystack: Uint8Array, needle: Uint8Array): number {\n const first = needle[0];\n if (first === undefined) return -1;\n for (let at = haystack.lastIndexOf(first); at !== -1; at = at === 0 ? -1 : haystack.lastIndexOf(first, at - 1)) {\n if (startsWith(haystack, needle, at)) return at;\n }\n return -1;\n}\n\n/** The end of the line starting at `start`, past its newline. */\nfunction lineEnd(bytes: Uint8Array, start: number): number {\n const newline = bytes.indexOf(0x0a, start);\n return newline === -1 ? bytes.byteLength : newline + 1;\n}\n\n/** Remove the `\\restrict <key>` line and its matching `\\unrestrict <key>` line. */\nexport function withoutRestrictLines(script: Uint8Array): Uint8Array {\n const restrict = indexOfBytes(script, encoder.encode(\"\\n\\\\restrict \"));\n if (restrict === -1) return script;\n const lineStart = restrict + 1;\n const end = lineEnd(script, lineStart);\n const key = new TextDecoder().decode(script.subarray(lineStart + \"\\\\restrict \".length, end)).trim();\n if (!/^[A-Za-z0-9]+$/.test(key)) return script;\n const unrestrictLine = encoder.encode(`\\n\\\\unrestrict ${key}\\n`);\n const unrestrict = lastIndexOfBytes(script, unrestrictLine);\n const parts = [script.subarray(0, lineStart)];\n if (unrestrict > end) {\n parts.push(script.subarray(end, unrestrict + 1), script.subarray(unrestrict + unrestrictLine.byteLength));\n } else {\n parts.push(script.subarray(end));\n }\n const out = new Uint8Array(parts.reduce((sum, part) => sum + part.byteLength, 0));\n let offset = 0;\n for (const part of parts) {\n out.set(part, offset);\n offset += part.byteLength;\n }\n return out;\n}\n\n/** The dump as a `File`: a plain script without its psql-only lines, or an archive as it is. */\nexport function dumpFile(output: Uint8Array, fileName: string): File {\n if (isArchive(output)) {\n return new File([output.slice()], fileName, { type: \"application/octet-stream\" });\n }\n return new File([withoutRestrictLines(output).slice()], fileName, { type: \"text/plain\" });\n}\n",
10
- "/**\n * The database's own session, before and after pg_dump runs on it.\n *\n * pg_dump expects a connection of its own and leaves the session in a state a real disconnect would\n * discard: its read-only transaction open (it never commits; ending the connection ends it), its\n * prepared statements, and every setting it changed (`search_path`, `row_security`,\n * `restrict_nonsystem_relation_kind`, `extra_float_digits`, the timeouts, …). Here the session is the\n * database's, so each of those is undone explicitly, and nothing of the database's own is touched.\n * Every exchange runs over `/protocol` inside the exclusive session pgDump holds, without persisting\n * (nothing here writes data).\n */\n\nimport { PgwasmClosedError, PgwasmFailedError } from \"@pgxsinkit/pgwasm\";\nimport { messages, serialize, type BackendMessage, type PgwasmProtocol } from \"@pgxsinkit/pgwasm/protocol\";\n\nimport { PgDumpSessionError } from \"./errors\";\n\n/**\n * Every setting a session can change for itself, and the role (`SET ROLE`, which `pg_settings` does not\n * list). The three transaction-scoped settings end with the transaction.\n */\nconst SETTINGS_QUERY = `SELECT name, pg_catalog.current_setting(name) FROM pg_catalog.pg_settings\n WHERE context IN ('user', 'superuser')\n AND name NOT IN ('transaction_isolation', 'transaction_read_only', 'transaction_deferrable')\n UNION ALL SELECT 'role', pg_catalog.current_setting('role')`;\n\nconst PREPARED_STATEMENTS_QUERY = \"SELECT name FROM pg_catalog.pg_prepared_statements\";\n\nconst SET_CONFIG = \"SELECT pg_catalog.set_config($1, $2, false)\";\n\n/** What of the session pg_dump can change: its settings, by name, and its prepared statements. */\nexport interface SessionState {\n readonly settings: ReadonlyMap<string, string>;\n readonly preparedStatements: ReadonlySet<string>;\n}\n\nasync function exchange(wire: PgwasmProtocol, message: Uint8Array): Promise<BackendMessage[]> {\n return (await wire.execProtocol(message, { persist: false })).messages;\n}\n\nfunction concat(parts: readonly Uint8Array[]): Uint8Array {\n const out = new Uint8Array(parts.reduce((sum, part) => sum + part.byteLength, 0));\n let offset = 0;\n for (const part of parts) {\n out.set(part, offset);\n offset += part.byteLength;\n }\n return out;\n}\n\n/**\n * The transaction status: `I` idle, `T` in a transaction block, `E` in a failed one. A lone Sync runs\n * nothing: the backend only answers it with ReadyForQuery (and ends an extended-query cycle a failed\n * client left without its Sync).\n */\nexport async function transactionStatus(wire: PgwasmProtocol): Promise<string> {\n const replies = await exchange(wire, serialize.sync());\n const ready = replies.findLast((reply) => reply instanceof messages.ReadyForQueryMessage);\n if (!(ready instanceof messages.ReadyForQueryMessage)) {\n throw new Error(\"the database answered a Sync without ReadyForQuery\");\n }\n return ready.status;\n}\n\n/** Each data row's text fields. */\nasync function rows(wire: PgwasmProtocol, sql: string): Promise<(string | null)[][]> {\n return (await exchange(wire, serialize.query(sql)))\n .filter((reply) => reply instanceof messages.DataRowMessage)\n .map((row) => row.fields);\n}\n\nasync function readSettings(wire: PgwasmProtocol): Promise<Map<string, string>> {\n const settings = new Map<string, string>();\n for (const [name, value] of await rows(wire, SETTINGS_QUERY)) {\n if (typeof name === \"string\" && typeof value === \"string\") settings.set(name, value);\n }\n return settings;\n}\n\nasync function readPreparedStatements(wire: PgwasmProtocol): Promise<Set<string>> {\n return new Set((await rows(wire, PREPARED_STATEMENTS_QUERY)).flatMap(([name]) => (name == null ? [] : [name])));\n}\n\n/** The session's settings and prepared statements. */\nexport async function readSession(wire: PgwasmProtocol): Promise<SessionState> {\n return { settings: await readSettings(wire), preparedStatements: await readPreparedStatements(wire) };\n}\n\nfunction differing(before: ReadonlyMap<string, string>, now: ReadonlyMap<string, string>): string[] {\n return [...before].filter(([name, value]) => now.get(name) !== value).map(([name]) => name);\n}\n\nconst quoteIdentifier = (name: string) => `\"${name.replaceAll('\"', '\"\"')}\"`;\n\n/**\n * Put the session back as it was before pg_dump: end the transaction it left open, deallocate the\n * statements it prepared, and restore every setting it changed (the role last, undoing pg_dump's own\n * order). Every step is attempted even when an earlier one fails. Whatever still differs afterwards (the\n * transaction, a statement of pg_dump's, a setting) is a {@link PgDumpSessionError} naming all of it,\n * whose cause is what failed on the way. A failed or closed database fails every exchange: its error is\n * thrown as it is.\n */\nexport async function restoreSession(wire: PgwasmProtocol, before: SessionState): Promise<void> {\n const failures: unknown[] = [];\n const attempt = async <T>(step: () => Promise<T>): Promise<T | undefined> => {\n try {\n return await step();\n } catch (error) {\n if (error instanceof PgwasmFailedError || error instanceof PgwasmClosedError) throw error;\n failures.push(error);\n return undefined;\n }\n };\n const ownStatements = (names: ReadonlySet<string>) =>\n [...names].filter((name) => !before.preparedStatements.has(name));\n\n // pg_dump never ends its read-only transaction (a disconnect would); nothing it did needs keeping.\n await attempt(async () => {\n if ((await transactionStatus(wire)) !== \"I\") await exchange(wire, serialize.query(\"ROLLBACK\"));\n });\n // A disconnect would drop pg_dump's prepared statements; the database's own (a live query's) stay.\n for (const name of ownStatements((await attempt(() => readPreparedStatements(wire))) ?? new Set())) {\n await attempt(() => exchange(wire, serialize.query(`DEALLOCATE ${quoteIdentifier(name)}`)));\n }\n const settings = await attempt(() => readSettings(wire));\n const changed = (settings === undefined ? [] : differing(before.settings, settings)).sort((a, b) =>\n a === \"role\" ? 1 : b === \"role\" ? -1 : a.localeCompare(b),\n );\n for (const name of changed) {\n const value = before.settings.get(name) ?? \"\";\n await attempt(() =>\n exchange(\n wire,\n concat([\n serialize.parse({ text: SET_CONFIG }),\n serialize.bind({ values: [name, value] }),\n serialize.execute({}),\n serialize.sync(),\n ]),\n ),\n );\n }\n\n // What is left of pg_dump's, each checked on its own.\n const left: string[] = [];\n const status = await attempt(() => transactionStatus(wire));\n if (status !== \"I\") {\n left.push(\n status === undefined ? \"the transaction status could not be read\" : \"pg_dump's transaction is still open\",\n );\n }\n const statements = await attempt(() => readPreparedStatements(wire));\n const remaining = statements === undefined ? undefined : ownStatements(statements);\n if (remaining === undefined) left.push(\"the prepared statements could not be read\");\n else if (remaining.length > 0) left.push(`statements it prepared: ${remaining.join(\", \")}`);\n const settingsAfter = await attempt(() => readSettings(wire));\n const unrestored = settingsAfter === undefined ? [] : differing(before.settings, settingsAfter);\n if (settingsAfter === undefined) {\n left.push(\"the settings could not be read\");\n } else if (unrestored.length > 0) {\n left.push(`settings it changed, which keep pg_dump's values: ${unrestored.join(\", \")}`);\n }\n\n if (left.length > 0) {\n throw new PgDumpSessionError(\n `The database's session could not be fully restored after pg_dump: ${left.join(\"; \")}.`,\n unrestored,\n failures.length === 0\n ? undefined\n : { cause: failures.length === 1 ? failures[0] : new AggregateError(failures, \"restoring the session failed\") },\n );\n }\n}\n",
10
+ "/**\n * The database's own session, before and after pg_dump runs on it.\n *\n * pg_dump expects a connection of its own and leaves the session in a state a real disconnect would\n * discard: its read-only transaction open (it never commits; ending the connection ends it), its\n * prepared statements, and every setting it changed (`search_path`, `row_security`,\n * `restrict_nonsystem_relation_kind`, `extra_float_digits`, the timeouts, …). Here the session is the\n * database's, so each of those is undone explicitly, and nothing of the database's own is touched.\n * Every exchange runs over `/protocol` inside the exclusive session pgDump holds, without persisting\n * (nothing here writes data).\n */\n\nimport { PgwasmClosedError, PgwasmFailedError } from \"@pgxsinkit/pgwasm\";\nimport { type BackendMessage, messages, type PgwasmProtocol, serialize } from \"@pgxsinkit/pgwasm/protocol\";\n\nimport { PgDumpSessionError } from \"./errors\";\n\n/**\n * Every setting a session can change for itself, and the role (`SET ROLE`, which `pg_settings` does not\n * list). The three transaction-scoped settings end with the transaction.\n */\nconst SETTINGS_QUERY = `SELECT name, pg_catalog.current_setting(name) FROM pg_catalog.pg_settings\n WHERE context IN ('user', 'superuser')\n AND name NOT IN ('transaction_isolation', 'transaction_read_only', 'transaction_deferrable')\n UNION ALL SELECT 'role', pg_catalog.current_setting('role')`;\n\nconst PREPARED_STATEMENTS_QUERY = \"SELECT name FROM pg_catalog.pg_prepared_statements\";\n\nconst SET_CONFIG = \"SELECT pg_catalog.set_config($1, $2, false)\";\n\n/** What of the session pg_dump can change: its settings, by name, and its prepared statements. */\nexport interface SessionState {\n readonly settings: ReadonlyMap<string, string>;\n readonly preparedStatements: ReadonlySet<string>;\n}\n\nasync function exchange(wire: PgwasmProtocol, message: Uint8Array): Promise<BackendMessage[]> {\n return (await wire.execProtocol(message, { persist: false })).messages;\n}\n\nfunction concat(parts: readonly Uint8Array[]): Uint8Array {\n const out = new Uint8Array(parts.reduce((sum, part) => sum + part.byteLength, 0));\n let offset = 0;\n for (const part of parts) {\n out.set(part, offset);\n offset += part.byteLength;\n }\n return out;\n}\n\n/**\n * The transaction status: `I` idle, `T` in a transaction block, `E` in a failed one. A lone Sync runs\n * nothing: the backend only answers it with ReadyForQuery (and ends an extended-query cycle a failed\n * client left without its Sync).\n */\nexport async function transactionStatus(wire: PgwasmProtocol): Promise<string> {\n const replies = await exchange(wire, serialize.sync());\n const ready = replies.findLast((reply) => reply instanceof messages.ReadyForQueryMessage);\n if (!(ready instanceof messages.ReadyForQueryMessage)) {\n throw new Error(\"the database answered a Sync without ReadyForQuery\");\n }\n return ready.status;\n}\n\n/** Each data row's text fields. */\nasync function rows(wire: PgwasmProtocol, sql: string): Promise<(string | null)[][]> {\n return (await exchange(wire, serialize.query(sql)))\n .filter((reply) => reply instanceof messages.DataRowMessage)\n .map((row) => row.fields);\n}\n\nasync function readSettings(wire: PgwasmProtocol): Promise<Map<string, string>> {\n const settings = new Map<string, string>();\n for (const [name, value] of await rows(wire, SETTINGS_QUERY)) {\n if (typeof name === \"string\" && typeof value === \"string\") settings.set(name, value);\n }\n return settings;\n}\n\nasync function readPreparedStatements(wire: PgwasmProtocol): Promise<Set<string>> {\n return new Set((await rows(wire, PREPARED_STATEMENTS_QUERY)).flatMap(([name]) => (name == null ? [] : [name])));\n}\n\n/** The session's settings and prepared statements. */\nexport async function readSession(wire: PgwasmProtocol): Promise<SessionState> {\n return { settings: await readSettings(wire), preparedStatements: await readPreparedStatements(wire) };\n}\n\nfunction differing(before: ReadonlyMap<string, string>, now: ReadonlyMap<string, string>): string[] {\n return [...before].filter(([name, value]) => now.get(name) !== value).map(([name]) => name);\n}\n\nconst quoteIdentifier = (name: string) => `\"${name.replaceAll('\"', '\"\"')}\"`;\n\n/**\n * Put the session back as it was before pg_dump: end the transaction it left open, deallocate the\n * statements it prepared, and restore every setting it changed (the role last, undoing pg_dump's own\n * order). Every step is attempted even when an earlier one fails. Whatever still differs afterwards (the\n * transaction, a statement of pg_dump's, a setting) is a {@link PgDumpSessionError} naming all of it,\n * whose cause is what failed on the way. A failed or closed database fails every exchange: its error is\n * thrown as it is.\n */\nexport async function restoreSession(wire: PgwasmProtocol, before: SessionState): Promise<void> {\n const failures: unknown[] = [];\n const attempt = async <T>(step: () => Promise<T>): Promise<T | undefined> => {\n try {\n return await step();\n } catch (error) {\n if (error instanceof PgwasmFailedError || error instanceof PgwasmClosedError) throw error;\n failures.push(error);\n return undefined;\n }\n };\n const ownStatements = (names: ReadonlySet<string>) =>\n [...names].filter((name) => !before.preparedStatements.has(name));\n\n // pg_dump never ends its read-only transaction (a disconnect would); nothing it did needs keeping.\n await attempt(async () => {\n if ((await transactionStatus(wire)) !== \"I\") await exchange(wire, serialize.query(\"ROLLBACK\"));\n });\n // A disconnect would drop pg_dump's prepared statements; the database's own (a live query's) stay.\n for (const name of ownStatements((await attempt(() => readPreparedStatements(wire))) ?? new Set())) {\n await attempt(() => exchange(wire, serialize.query(`DEALLOCATE ${quoteIdentifier(name)}`)));\n }\n const settings = await attempt(() => readSettings(wire));\n const changed = (settings === undefined ? [] : differing(before.settings, settings)).sort((a, b) =>\n a === \"role\" ? 1 : b === \"role\" ? -1 : a.localeCompare(b),\n );\n for (const name of changed) {\n const value = before.settings.get(name) ?? \"\";\n await attempt(() =>\n exchange(\n wire,\n concat([\n serialize.parse({ text: SET_CONFIG }),\n serialize.bind({ values: [name, value] }),\n serialize.execute({}),\n serialize.sync(),\n ]),\n ),\n );\n }\n\n // What is left of pg_dump's, each checked on its own.\n const left: string[] = [];\n const status = await attempt(() => transactionStatus(wire));\n if (status !== \"I\") {\n left.push(\n status === undefined ? \"the transaction status could not be read\" : \"pg_dump's transaction is still open\",\n );\n }\n const statements = await attempt(() => readPreparedStatements(wire));\n const remaining = statements === undefined ? undefined : ownStatements(statements);\n if (remaining === undefined) left.push(\"the prepared statements could not be read\");\n else if (remaining.length > 0) left.push(`statements it prepared: ${remaining.join(\", \")}`);\n const settingsAfter = await attempt(() => readSettings(wire));\n const unrestored = settingsAfter === undefined ? [] : differing(before.settings, settingsAfter);\n if (settingsAfter === undefined) {\n left.push(\"the settings could not be read\");\n } else if (unrestored.length > 0) {\n left.push(`settings it changed, which keep pg_dump's values: ${unrestored.join(\", \")}`);\n }\n\n if (left.length > 0) {\n throw new PgDumpSessionError(\n `The database's session could not be fully restored after pg_dump: ${left.join(\"; \")}.`,\n unrestored,\n failures.length === 0\n ? undefined\n : { cause: failures.length === 1 ? failures[0] : new AggregateError(failures, \"restoring the session failed\") },\n );\n }\n}\n",
11
11
  "// Began as a copy of `@electric-sql/pglite` (taken under its PostgreSQL License option, © ElectricSQL\n// — see NOTICE). Owned outright (ADR-0062); compatibility with PGlite is an anti-goal — evolve freely.\n\n/**\n * pg_dump's WebAssembly module, fetched and compiled once per URL. One path for Bun and browsers: Bun's\n * `fetch` reads `file://` URLs and serves `.wasm` as `application/wasm`.\n */\n\nconst compiled = new Map<string, Promise<WebAssembly.Module>>();\n\nexport function compileModule(url: URL): Promise<WebAssembly.Module> {\n const key = url.href;\n let pending = compiled.get(key);\n if (pending === undefined) {\n pending = (async () => {\n const response = await fetch(url);\n if (!response.ok) throw new Error(`Could not load ${key}: HTTP ${response.status} ${response.statusText}`);\n try {\n // Bun's Response and the WebAssembly typings' Response are distinct declarations of one type.\n return await WebAssembly.compileStreaming(\n response.clone() as unknown as Parameters<typeof WebAssembly.compileStreaming>[0],\n );\n } catch (error) {\n // A server that sends the wrong MIME type defeats streaming compilation; compile the bytes.\n if (error instanceof TypeError) return await WebAssembly.compile(await response.arrayBuffer());\n throw error;\n }\n })();\n compiled.set(key, pending);\n // A failed download or compile is retried on the next dump rather than cached.\n pending.catch(() => compiled.delete(key));\n }\n return pending;\n}\n"
12
12
  ],
13
13
  "mappings": ";;AAAA;AAAA;AAQO,MAAM,oCAAoC,wBAAwB;AAAA,EAC9D,OAAO;AAAA,EAEP;AAAA,EAET,WAAW,CAAC,OAAe;AAAA,IACzB,MACE,6GACE,IAAI,wBACR;AAAA,IACA,KAAK,QAAQ;AAAA;AAEjB;AAAA;AAGO,MAAM,oBAAoB,YAAY;AAAA,EAClC,OAAO;AAAA,EAEP;AAAA,EAEA;AAAA,EAET,WAAW,CAAC,SAAiB,UAAyB,QAAgB,SAAwB;AAAA,IAC5F,MAAM,SAAS,OAAO;AAAA,IACtB,KAAK,WAAW;AAAA,IAChB,KAAK,SAAS;AAAA;AAElB;AAAA;AAQO,MAAM,2BAA2B,YAAY;AAAA,EACzC,OAAO;AAAA,EACP;AAAA,EAET,WAA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YAAY;IAC3B,QAAQ,CAAC,QAAQ,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC/C,QAAQ,CAAC,kBAAkB,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;CAClD;AAgBD;;;;GAIG;AACH,wBAAsB,iBAAiB,CAAC,IAAI,EAAE,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC,CAO7E;AAqBD,sDAAsD;AACtD,wBAAsB,WAAW,CAAC,IAAI,EAAE,cAAc,GAAG,OAAO,CAAC,YAAY,CAAC,CAE7E;AAQD;;;;;;;GAOG;AACH,wBAAsB,cAAc,CAAC,IAAI,EAAE,cAAc,EAAE,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAsE9F"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pgxsinkit/pgwasm-pg-dump",
3
- "version": "0.6.2",
3
+ "version": "0.6.4",
4
4
  "license": "PostgreSQL",
5
5
  "files": [
6
6
  "artefacts",
@@ -39,7 +39,7 @@
39
39
  "build": "bun --cwd ../.. run build:public-packages"
40
40
  },
41
41
  "peerDependencies": {
42
- "@pgxsinkit/pgwasm": "0.6.2"
42
+ "@pgxsinkit/pgwasm": "0.6.4"
43
43
  },
44
44
  "repository": {
45
45
  "type": "git",
package/src/pg-dump.ts CHANGED
@@ -3,13 +3,13 @@
3
3
 
4
4
  import type { Pgwasm } from "@pgxsinkit/pgwasm";
5
5
  import { PgwasmClosedError, PgwasmFailedError } from "@pgxsinkit/pgwasm";
6
- import { protocol, type PgwasmProtocol } from "@pgxsinkit/pgwasm/protocol";
6
+ import { type PgwasmProtocol, protocol } from "@pgxsinkit/pgwasm/protocol";
7
7
 
8
8
  import { createPgDumpModule, pgDumpWasm } from "./artefacts";
9
9
  import { PgDumpError, PgDumpSessionError, PgDumpUnsupportedBuildError } from "./errors";
10
10
  import { ByteQueue, FrontendFramer } from "./framing";
11
11
  import { dumpFile } from "./output";
12
- import { readSession, restoreSession, transactionStatus, type SessionState } from "./session";
12
+ import { readSession, restoreSession, type SessionState, transactionStatus } from "./session";
13
13
  import { compileModule } from "./wasm";
14
14
 
15
15
  export interface PgDumpOptions {
package/src/session.ts CHANGED
@@ -11,7 +11,7 @@
11
11
  */
12
12
 
13
13
  import { PgwasmClosedError, PgwasmFailedError } from "@pgxsinkit/pgwasm";
14
- import { messages, serialize, type BackendMessage, type PgwasmProtocol } from "@pgxsinkit/pgwasm/protocol";
14
+ import { type BackendMessage, messages, type PgwasmProtocol, serialize } from "@pgxsinkit/pgwasm/protocol";
15
15
 
16
16
  import { PgDumpSessionError } from "./errors";
17
17