@voltro/data-transfer 0.33.0 → 0.35.0

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.d.ts CHANGED
@@ -20,15 +20,25 @@ import { YieldableError } from 'effect/Cause';
20
20
  export declare const applyAction: (action: MaskAction, input: MaskInput) => unknown;
21
21
 
22
22
  /**
23
- * Refuse a direct/native import when a live instance is detected, unless the
24
- * operator passed `--allow-live`. `liveInstance` is a human label (url/name) of
25
- * the detected instance, or `null` when none was found (or detection was
26
- * inconclusive the CLI treats "can't tell" as "not detected" so the common
27
- * import-into-a-stopped-target case isn't blocked).
23
+ * Refuse a direct/native import when a live instance is writing to the SAME
24
+ * database, unless the operator passed `--allow-live`.
25
+ *
26
+ * @param liveInstance human label (url/name) of a detected instance, or `null`
27
+ * when none answered — detection is best-effort, and "can't tell" is treated
28
+ * as "not detected" so importing into a stopped target is not blocked.
29
+ * @param sameTarget whether that instance is connected to the database being
30
+ * written. `'unknown'` when either side could not be identified (an older
31
+ * instance, an unparseable connection) — and it must behave like `'same'`,
32
+ * because the alternative is a guard that steps aside whenever it is unsure.
33
+ * @param targetLabel what the CLI resolved as the target, for the message. A
34
+ * refusal that names only one of the two things it is comparing is why
35
+ * `--allow-live` became a reflex.
28
36
  */
29
37
  export declare const assessLiveImport: (opts: {
30
38
  readonly liveInstance: string | null;
31
39
  readonly allowLive: boolean;
40
+ readonly sameTarget?: "same" | "different" | "unknown";
41
+ readonly targetLabel?: string;
32
42
  }) => LiveGuardResult;
33
43
 
34
44
  export declare const ASSET_INDEX_FILE = "assets/index.ndjson";
@@ -499,6 +509,28 @@ export declare const formatIssue: (i: PortabilityIssue) => string;
499
509
  /** True when this Node build exposes the native zstd streams (Node ≥ 22.15). */
500
510
  export declare const hasZstd: () => boolean;
501
511
 
512
+ /**
513
+ * A dialect-native bulk loader the CALLER wires in (PERF-13). The importer
514
+ * never imports a dialect package; the CLI hands it `@voltro/sql-postgres`'s
515
+ * `makePgCopySession(...)` when the target is postgres, and the importer uses
516
+ * it ONLY where plain-INSERT semantics provably hold (see `tablePhase`).
517
+ *
518
+ * Contract the fast path relies on: `copyInto` is atomic per call — a failed
519
+ * batch applied NOTHING, so the importer can replay exactly that batch through
520
+ * the per-row path (held-row / deferred-FK semantics intact) without
521
+ * double-writing a prefix.
522
+ */
523
+ export declare interface ImportCopyLoader {
524
+ /** Dialect this loader serves; the importer only engages it for `postgres`. */
525
+ readonly dialect: string;
526
+ readonly copyInto: (batch: {
527
+ readonly table: string;
528
+ readonly columns: ReadonlyArray<string>;
529
+ readonly columnTypes?: Readonly<Record<string, string>>;
530
+ readonly rows: ReadonlyArray<Row>;
531
+ }) => Promise<number>;
532
+ }
533
+
502
534
  export declare type ImportError = BundleError | CodecError | IntegrityError | CrossDialectError | ImportModeError | DanglingReferenceError | SchemaDriftError | StorageError;
503
535
 
504
536
  /**
@@ -580,6 +612,19 @@ export declare interface ImportOptions {
580
612
  * event per table — off the per-row hot path. Independent of the always-on
581
613
  * `Effect.withSpan` + metrics per table. */
582
614
  readonly onProgress?: OnProgress;
615
+ /**
616
+ * Optional dialect-native bulk loader (postgres `COPY … FROM STDIN`). Used
617
+ * per table only when plain-INSERT semantics hold: `replace` mode (tables
618
+ * pre-truncated) or `upsert` into a table that is EMPTY at import time — and
619
+ * never under `atomic` (the loader runs on its own connection, outside the
620
+ * transaction). Everything else keeps the per-row `DataStore` writes. A
621
+ * failed COPY batch falls back to the per-row path for exactly that batch,
622
+ * so held-row / deferred-FK semantics are preserved.
623
+ */
624
+ readonly copyLoader?: ImportCopyLoader;
625
+ /** Rows per COPY statement on the fast path. Default 5000 — bounds the
626
+ * batch the importer holds in memory AND the batch a fallback replays. */
627
+ readonly copyBatchSize?: number;
583
628
  }
584
629
 
585
630
  /** An integrity check failed — a table's content checksum or row count did not