@zero-transfer/http 0.4.0 → 0.4.6
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/README.md +8 -1
- package/dist/index.cjs +15 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +294 -9
- package/dist/index.d.ts +294 -9
- package/dist/index.mjs +14 -0
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -2
package/dist/index.d.ts
CHANGED
|
@@ -394,7 +394,7 @@ interface TlsProfile {
|
|
|
394
394
|
* hex form with or without colons. When present, the TLS handshake additionally requires the
|
|
395
395
|
* leaf certificate's SHA-256 fingerprint to match one of these values.
|
|
396
396
|
*
|
|
397
|
-
* Not required for normal CA-trusted endpoints
|
|
397
|
+
* Not required for normal CA-trusted endpoints - public CAs and `ca` bundles already gate
|
|
398
398
|
* trust via `rejectUnauthorized`. Pinning is **recommended for production** when you control
|
|
399
399
|
* the server and want defence-in-depth against rogue certificates issued by trusted CAs.
|
|
400
400
|
*
|
|
@@ -833,7 +833,41 @@ interface TransferEngineOptions {
|
|
|
833
833
|
/** Clock used for receipts and progress events. Defaults to `new Date()`. */
|
|
834
834
|
now?: () => Date;
|
|
835
835
|
}
|
|
836
|
-
/**
|
|
836
|
+
/**
|
|
837
|
+
* Executes transfer jobs and produces audit-friendly receipts.
|
|
838
|
+
*
|
|
839
|
+
* The engine is the lowest-level entry point in the transfer stack: it owns
|
|
840
|
+
* retry policy, attempt history, abort propagation, progress event
|
|
841
|
+
* normalization, and receipt construction. Most callers reach the engine
|
|
842
|
+
* indirectly through {@link runRoute}, {@link uploadFile}, {@link downloadFile},
|
|
843
|
+
* {@link copyBetween}, or {@link TransferQueue}; instantiate it directly when
|
|
844
|
+
* you need full control over execution semantics.
|
|
845
|
+
*
|
|
846
|
+
* @example Execute a single job with a custom executor
|
|
847
|
+
* ```ts
|
|
848
|
+
* import { TransferEngine, type TransferExecutor, type TransferJob } from "@zero-transfer/sdk";
|
|
849
|
+
*
|
|
850
|
+
* const engine = new TransferEngine();
|
|
851
|
+
*
|
|
852
|
+
* const executor: TransferExecutor = async ({ job, signal, onProgress }) => {
|
|
853
|
+
* onProgress?.({ jobId: job.id, bytesTransferred: 0 });
|
|
854
|
+
* // … perform the bytes here, honoring `signal` …
|
|
855
|
+
* return { jobId: job.id, bytesTransferred: 1234, completedAt: new Date() };
|
|
856
|
+
* };
|
|
857
|
+
*
|
|
858
|
+
* const job: TransferJob = {
|
|
859
|
+
* id: "manual-1",
|
|
860
|
+
* operation: "upload",
|
|
861
|
+
* source: { profile: localProfile, path: "./data.bin" },
|
|
862
|
+
* destination: { profile: s3Profile, path: "/data/data.bin" },
|
|
863
|
+
* };
|
|
864
|
+
*
|
|
865
|
+
* const receipt = await engine.execute(job, executor, {
|
|
866
|
+
* retry: { maxAttempts: 3, baseDelayMs: 250 },
|
|
867
|
+
* });
|
|
868
|
+
* console.log(receipt.attempts.length); // 1 on success
|
|
869
|
+
* ```
|
|
870
|
+
*/
|
|
837
871
|
declare class TransferEngine {
|
|
838
872
|
private readonly now;
|
|
839
873
|
/**
|
|
@@ -1584,8 +1618,20 @@ interface ClientDiagnostics {
|
|
|
1584
1618
|
/**
|
|
1585
1619
|
* Returns a redaction-safe snapshot of the providers registered with a client.
|
|
1586
1620
|
*
|
|
1621
|
+
* Use this when rendering a setup screen, generating a support bundle, or
|
|
1622
|
+
* asserting in tests that the expected provider factories were registered.
|
|
1623
|
+
*
|
|
1587
1624
|
* @param client - Transfer client to inspect.
|
|
1588
1625
|
* @returns Provider id and capability snapshot tuples.
|
|
1626
|
+
*
|
|
1627
|
+
* @example List registered providers
|
|
1628
|
+
* ```ts
|
|
1629
|
+
* import { summarizeClientDiagnostics } from "@zero-transfer/sdk";
|
|
1630
|
+
*
|
|
1631
|
+
* for (const { id, capabilities } of summarizeClientDiagnostics(client).providers) {
|
|
1632
|
+
* console.log(`${id}: streaming=${capabilities.readStream} resume=${capabilities.resumeDownload}`);
|
|
1633
|
+
* }
|
|
1634
|
+
* ```
|
|
1589
1635
|
*/
|
|
1590
1636
|
declare function summarizeClientDiagnostics(client: TransferClient): ClientDiagnostics;
|
|
1591
1637
|
/** Per-step duration measurements collected by {@link runConnectionDiagnostics}. */
|
|
@@ -1638,8 +1684,36 @@ interface RunConnectionDiagnosticsOptions {
|
|
|
1638
1684
|
/**
|
|
1639
1685
|
* Connects to a profile, captures capability and listing samples, and returns a redaction-safe report.
|
|
1640
1686
|
*
|
|
1687
|
+
* Useful for connectivity "ping" pages, smoke tests, and bug reports. Secrets
|
|
1688
|
+
* in the profile are redacted via {@link redactConnectionProfile} before being
|
|
1689
|
+
* returned. The session is always disconnected before the function returns,
|
|
1690
|
+
* including when probes throw.
|
|
1691
|
+
*
|
|
1641
1692
|
* @param options - Diagnostic probe options.
|
|
1642
1693
|
* @returns Diagnostic report including timings and any captured error.
|
|
1694
|
+
*
|
|
1695
|
+
* @example Probe an SFTP connection
|
|
1696
|
+
* ```ts
|
|
1697
|
+
* import { runConnectionDiagnostics } from "@zero-transfer/sdk";
|
|
1698
|
+
*
|
|
1699
|
+
* const report = await runConnectionDiagnostics({
|
|
1700
|
+
* client,
|
|
1701
|
+
* profile: {
|
|
1702
|
+
* host: "sftp.example.com",
|
|
1703
|
+
* provider: "sftp",
|
|
1704
|
+
* username: "deploy",
|
|
1705
|
+
* ssh: { privateKey: { path: "./keys/id_ed25519" } },
|
|
1706
|
+
* },
|
|
1707
|
+
* listPath: "/uploads",
|
|
1708
|
+
* });
|
|
1709
|
+
*
|
|
1710
|
+
* if (!report.ok) {
|
|
1711
|
+
* console.error("connection failed:", report.error);
|
|
1712
|
+
* } else {
|
|
1713
|
+
* console.log(`connect=${report.timings.connectMs}ms list=${report.timings.listMs}ms`);
|
|
1714
|
+
* console.log(report.sample); // up to 5 entries from /uploads
|
|
1715
|
+
* }
|
|
1716
|
+
* ```
|
|
1643
1717
|
*/
|
|
1644
1718
|
declare function runConnectionDiagnostics(options: RunConnectionDiagnosticsOptions): Promise<ConnectionDiagnosticsResult>;
|
|
1645
1719
|
|
|
@@ -1648,7 +1722,7 @@ interface ConnectionPoolOptions {
|
|
|
1648
1722
|
/**
|
|
1649
1723
|
* Maximum number of *idle* sessions retained per pool key.
|
|
1650
1724
|
*
|
|
1651
|
-
* Active leases are not counted against this limit
|
|
1725
|
+
* Active leases are not counted against this limit - the cap only applies
|
|
1652
1726
|
* to sessions waiting in the pool. When more than `maxIdlePerKey` sessions
|
|
1653
1727
|
* become idle simultaneously, the oldest ones are disconnected. Defaults
|
|
1654
1728
|
* to `4`.
|
|
@@ -1746,8 +1820,29 @@ interface MemoryProviderOptions {
|
|
|
1746
1820
|
/**
|
|
1747
1821
|
* Creates a provider factory backed by deterministic in-memory fixture entries.
|
|
1748
1822
|
*
|
|
1823
|
+
* Useful for tests and examples where you want a real `TransferSession` without
|
|
1824
|
+
* touching disk or the network. Entries are pre-seeded; mutations made through
|
|
1825
|
+
* the session are visible to subsequent operations on the same provider.
|
|
1826
|
+
*
|
|
1749
1827
|
* @param options - Optional fixture entries to expose through the memory provider.
|
|
1750
1828
|
* @returns Provider factory suitable for `createTransferClient({ providers: [...] })`.
|
|
1829
|
+
*
|
|
1830
|
+
* @example Seed entries and read them back
|
|
1831
|
+
* ```ts
|
|
1832
|
+
* import { createMemoryProviderFactory, createTransferClient } from "@zero-transfer/sdk";
|
|
1833
|
+
*
|
|
1834
|
+
* const client = createTransferClient({
|
|
1835
|
+
* providers: [createMemoryProviderFactory({
|
|
1836
|
+
* entries: [
|
|
1837
|
+
* { path: "/fixtures/hello.txt", content: "hello world" },
|
|
1838
|
+
* { path: "/fixtures/data.bin", content: new Uint8Array([1, 2, 3]) },
|
|
1839
|
+
* ],
|
|
1840
|
+
* })],
|
|
1841
|
+
* });
|
|
1842
|
+
*
|
|
1843
|
+
* const session = await client.connect({ host: "fixtures", provider: "memory" });
|
|
1844
|
+
* console.log(await session.fs.list("/fixtures"));
|
|
1845
|
+
* ```
|
|
1751
1846
|
*/
|
|
1752
1847
|
declare function createMemoryProviderFactory(options?: MemoryProviderOptions): ProviderFactory;
|
|
1753
1848
|
|
|
@@ -2485,9 +2580,47 @@ interface TransferPlanSummary {
|
|
|
2485
2580
|
/** Counts grouped by action. */
|
|
2486
2581
|
actions: Record<string, number>;
|
|
2487
2582
|
}
|
|
2488
|
-
/**
|
|
2583
|
+
/**
|
|
2584
|
+
* Creates a transfer plan from dry-run planning input.
|
|
2585
|
+
*
|
|
2586
|
+
* Plans are immutable, structured descriptions of intended work. Pair with
|
|
2587
|
+
* {@link createSyncPlan} or {@link createAtomicDeployPlan} for end-to-end
|
|
2588
|
+
* planning, or build steps by hand when you need full control. Pass the plan
|
|
2589
|
+
* to {@link createTransferJobsFromPlan} to materialize executable jobs.
|
|
2590
|
+
*
|
|
2591
|
+
* @example Build a plan with two upload steps and inspect it
|
|
2592
|
+
* ```ts
|
|
2593
|
+
* import { createTransferPlan, summarizeTransferPlan } from "@zero-transfer/sdk";
|
|
2594
|
+
*
|
|
2595
|
+
* const plan = createTransferPlan({
|
|
2596
|
+
* id: "manual-batch",
|
|
2597
|
+
* steps: [
|
|
2598
|
+
* { action: "upload", source: "./a.bin", destination: "/lake/a.bin", expectedBytes: 1024 },
|
|
2599
|
+
* { action: "upload", source: "./b.bin", destination: "/lake/b.bin", expectedBytes: 2048 },
|
|
2600
|
+
* ],
|
|
2601
|
+
* });
|
|
2602
|
+
*
|
|
2603
|
+
* console.table(summarizeTransferPlan(plan));
|
|
2604
|
+
* ```
|
|
2605
|
+
*/
|
|
2489
2606
|
declare function createTransferPlan(input: TransferPlanInput): TransferPlan;
|
|
2490
|
-
/**
|
|
2607
|
+
/**
|
|
2608
|
+
* Summarizes a transfer plan for diagnostics, previews, and tests.
|
|
2609
|
+
*
|
|
2610
|
+
* Returns aggregate counts (total / executable / skipped / destructive),
|
|
2611
|
+
* total expected bytes, and a per-action histogram. Useful for printing a
|
|
2612
|
+
* one-line plan summary before executing or for asserting plan shape in
|
|
2613
|
+
* tests.
|
|
2614
|
+
*
|
|
2615
|
+
* @example Print a plan preview
|
|
2616
|
+
* ```ts
|
|
2617
|
+
* import { summarizeTransferPlan } from "@zero-transfer/sdk";
|
|
2618
|
+
*
|
|
2619
|
+
* const summary = summarizeTransferPlan(plan);
|
|
2620
|
+
* console.log(`${summary.executableSteps} steps, ${summary.totalExpectedBytes} bytes total`);
|
|
2621
|
+
* console.log("Actions:", summary.actions);
|
|
2622
|
+
* ```
|
|
2623
|
+
*/
|
|
2491
2624
|
declare function summarizeTransferPlan(plan: TransferPlan): TransferPlanSummary;
|
|
2492
2625
|
/** Converts executable plan steps into transfer jobs while preserving order. */
|
|
2493
2626
|
declare function createTransferJobsFromPlan(plan: TransferPlan): TransferJob[];
|
|
@@ -2564,7 +2697,41 @@ interface TransferQueueSummary {
|
|
|
2564
2697
|
/** Failed queue items in queue order. */
|
|
2565
2698
|
failures: TransferQueueItem[];
|
|
2566
2699
|
}
|
|
2567
|
-
/**
|
|
2700
|
+
/**
|
|
2701
|
+
* Minimal transfer queue with concurrency, pause/resume, cancellation, and drain summaries.
|
|
2702
|
+
*
|
|
2703
|
+
* Wrap a {@link TransferEngine} with a queue when you need to run many transfers
|
|
2704
|
+
* concurrently with bounded parallelism, observe per-job progress, or drive
|
|
2705
|
+
* a UI from a single source of truth. Items are FIFO; failures and successes
|
|
2706
|
+
* are surfaced via observers and in the final {@link TransferQueueSummary}.
|
|
2707
|
+
*
|
|
2708
|
+
* @example Run a batch of uploads with concurrency=4
|
|
2709
|
+
* ```ts
|
|
2710
|
+
* import {
|
|
2711
|
+
* TransferQueue,
|
|
2712
|
+
* createProviderTransferExecutor,
|
|
2713
|
+
* } from "@zero-transfer/sdk";
|
|
2714
|
+
*
|
|
2715
|
+
* const queue = new TransferQueue({
|
|
2716
|
+
* concurrency: 4,
|
|
2717
|
+
* executor: createProviderTransferExecutor({ client }),
|
|
2718
|
+
* onProgress: (e) => console.log(`${e.jobId}: ${e.bytesTransferred}`),
|
|
2719
|
+
* onError: (item, err) => console.error(`${item.job.id} failed`, err),
|
|
2720
|
+
* });
|
|
2721
|
+
*
|
|
2722
|
+
* for (const file of files) {
|
|
2723
|
+
* queue.enqueue({
|
|
2724
|
+
* id: file.name,
|
|
2725
|
+
* operation: "upload",
|
|
2726
|
+
* source: { profile: localProfile, path: file.path },
|
|
2727
|
+
* destination: { profile: s3Profile, path: `/lake/${file.name}` },
|
|
2728
|
+
* });
|
|
2729
|
+
* }
|
|
2730
|
+
*
|
|
2731
|
+
* const summary = await queue.drain();
|
|
2732
|
+
* console.log(`Completed ${summary.completed} / ${summary.total}`);
|
|
2733
|
+
* ```
|
|
2734
|
+
*/
|
|
2568
2735
|
declare class TransferQueue {
|
|
2569
2736
|
private readonly engine;
|
|
2570
2737
|
private readonly items;
|
|
@@ -2835,7 +3002,7 @@ interface DiffRemoteTreesOptions {
|
|
|
2835
3002
|
* Compares two remote subtrees and produces an entry-level diff.
|
|
2836
3003
|
*
|
|
2837
3004
|
* Source and destination paths are walked independently; entries are then aligned by
|
|
2838
|
-
* the relative path from each tree root. Directory equality is structural
|
|
3005
|
+
* the relative path from each tree root. Directory equality is structural - directories
|
|
2839
3006
|
* are equal when their relative paths match and the entry types agree.
|
|
2840
3007
|
*
|
|
2841
3008
|
* @param source - Source-side remote file system.
|
|
@@ -2844,6 +3011,26 @@ interface DiffRemoteTreesOptions {
|
|
|
2844
3011
|
* @param destinationPath - Destination-side root path being compared.
|
|
2845
3012
|
* @param options - Optional comparison controls.
|
|
2846
3013
|
* @returns Diff result containing entries and a summary.
|
|
3014
|
+
*
|
|
3015
|
+
* @example Diff two SFTP subtrees and feed the result into createSyncPlan
|
|
3016
|
+
* ```ts
|
|
3017
|
+
* import { createSyncPlan, diffRemoteTrees } from "@zero-transfer/sdk";
|
|
3018
|
+
*
|
|
3019
|
+
* const diff = await diffRemoteTrees(
|
|
3020
|
+
* srcSession.fs, "/exports",
|
|
3021
|
+
* dstSession.fs, "/exports",
|
|
3022
|
+
* { compareUniqueId: true },
|
|
3023
|
+
* );
|
|
3024
|
+
*
|
|
3025
|
+
* console.log(diff.summary); // { added, removed, changed, unchanged }
|
|
3026
|
+
*
|
|
3027
|
+
* const plan = createSyncPlan({
|
|
3028
|
+
* id: "exports-sync",
|
|
3029
|
+
* diff,
|
|
3030
|
+
* source: { provider: "sftp", rootPath: "/exports" },
|
|
3031
|
+
* destination: { provider: "sftp", rootPath: "/exports" },
|
|
3032
|
+
* });
|
|
3033
|
+
* ```
|
|
2847
3034
|
*/
|
|
2848
3035
|
declare function diffRemoteTrees(source: RemoteFileSystem, sourcePath: string, destination: RemoteFileSystem, destinationPath: string, options?: DiffRemoteTreesOptions): Promise<RemoteTreeDiff>;
|
|
2849
3036
|
|
|
@@ -2915,6 +3102,31 @@ interface CreateSyncPlanOptions {
|
|
|
2915
3102
|
* @param options - Inputs and policies that shape the plan.
|
|
2916
3103
|
* @returns Transfer plan ready for `createTransferJobsFromPlan` or queue execution.
|
|
2917
3104
|
* @throws {@link ConfigurationError} When `conflictPolicy: "error"` encounters a conflict.
|
|
3105
|
+
*
|
|
3106
|
+
* @example Mirror SFTP → S3 with deletes
|
|
3107
|
+
* ```ts
|
|
3108
|
+
* import {
|
|
3109
|
+
* createSyncPlan,
|
|
3110
|
+
* diffRemoteTrees,
|
|
3111
|
+
* summarizeTransferPlan,
|
|
3112
|
+
* } from "@zero-transfer/sdk";
|
|
3113
|
+
*
|
|
3114
|
+
* const diff = await diffRemoteTrees(
|
|
3115
|
+
* srcSession.fs, "/dist",
|
|
3116
|
+
* dstSession.fs, "/releases/current",
|
|
3117
|
+
* );
|
|
3118
|
+
*
|
|
3119
|
+
* const plan = createSyncPlan({
|
|
3120
|
+
* id: "release-mirror",
|
|
3121
|
+
* diff,
|
|
3122
|
+
* source: { provider: "sftp", rootPath: "/dist" },
|
|
3123
|
+
* destination: { provider: "s3", rootPath: "/releases/current" },
|
|
3124
|
+
* deletePolicy: "mirror",
|
|
3125
|
+
* conflictPolicy: "overwrite",
|
|
3126
|
+
* });
|
|
3127
|
+
*
|
|
3128
|
+
* console.table(summarizeTransferPlan(plan));
|
|
3129
|
+
* ```
|
|
2918
3130
|
*/
|
|
2919
3131
|
declare function createSyncPlan(options: CreateSyncPlanOptions): TransferPlan;
|
|
2920
3132
|
|
|
@@ -3030,9 +3242,39 @@ interface CreateAtomicDeployPlanOptions {
|
|
|
3030
3242
|
/**
|
|
3031
3243
|
* Builds an {@link AtomicDeployPlan} that stages a release, swaps it live, and prunes old releases.
|
|
3032
3244
|
*
|
|
3245
|
+
* The plan describes a blue/green-style deploy:
|
|
3246
|
+
* 1. Upload to a timestamped staging directory under `<destination>/.releases/`.
|
|
3247
|
+
* 2. Atomically swap the `current` symlink/rename to point at the new release.
|
|
3248
|
+
* 3. Optionally prune old releases beyond `retain`.
|
|
3249
|
+
*
|
|
3250
|
+
* No I/O is performed - the host executes the plan steps. Pair with
|
|
3251
|
+
* {@link createTransferPlan} or {@link createTransferJobsFromPlan} to execute.
|
|
3252
|
+
*
|
|
3033
3253
|
* @param options - Inputs and policies that shape the deploy.
|
|
3034
3254
|
* @returns Structured deploy plan ready for execution by the calling host.
|
|
3035
3255
|
* @throws {@link ConfigurationError} When `retain` is less than `1` or the destination root is empty.
|
|
3256
|
+
*
|
|
3257
|
+
* @example Plan a release with rollback path
|
|
3258
|
+
* ```ts
|
|
3259
|
+
* import { createAtomicDeployPlan } from "@zero-transfer/sdk";
|
|
3260
|
+
*
|
|
3261
|
+
* const plan = createAtomicDeployPlan({
|
|
3262
|
+
* id: "web-2026-04-28",
|
|
3263
|
+
* source: { rootPath: "./dist" },
|
|
3264
|
+
* destination: {
|
|
3265
|
+
* profile: { host: "web1.example.com", provider: "sftp", username: "deploy" },
|
|
3266
|
+
* rootPath: "/srv/www",
|
|
3267
|
+
* },
|
|
3268
|
+
* retain: 5,
|
|
3269
|
+
* existingReleases: [
|
|
3270
|
+
* "/srv/www/.releases/2026-04-21T00-00-00Z",
|
|
3271
|
+
* "/srv/www/.releases/2026-04-14T00-00-00Z",
|
|
3272
|
+
* ],
|
|
3273
|
+
* });
|
|
3274
|
+
*
|
|
3275
|
+
* console.log(plan.swap); // staging → current rename
|
|
3276
|
+
* console.log(plan.prune); // releases scheduled for removal
|
|
3277
|
+
* ```
|
|
3036
3278
|
*/
|
|
3037
3279
|
declare function createAtomicDeployPlan(options: CreateAtomicDeployPlanOptions): AtomicDeployPlan;
|
|
3038
3280
|
|
|
@@ -3225,6 +3467,12 @@ declare function joinRemotePath(...segments: string[]): string;
|
|
|
3225
3467
|
*/
|
|
3226
3468
|
declare function basenameRemotePath(input: string): string;
|
|
3227
3469
|
|
|
3470
|
+
/**
|
|
3471
|
+
* Returns `true` when the file containing `import.meta.url` is the entry point
|
|
3472
|
+
* of the current Node.js process. Returns `false` outside Node.
|
|
3473
|
+
*/
|
|
3474
|
+
declare function isMainModule(importMetaUrl: string): boolean;
|
|
3475
|
+
|
|
3228
3476
|
/** Fetch implementation accepted by web-family providers. */
|
|
3229
3477
|
type HttpFetch = (input: string, init?: RequestInit) => Promise<Response>;
|
|
3230
3478
|
|
|
@@ -3244,9 +3492,46 @@ interface HttpProviderOptions {
|
|
|
3244
3492
|
/**
|
|
3245
3493
|
* Creates a provider factory backed by HTTP(S) GET/HEAD.
|
|
3246
3494
|
*
|
|
3247
|
-
*
|
|
3495
|
+
* Read-only by design - use it to fetch artifacts from public URLs, signed
|
|
3496
|
+
* URLs, or HTTP-only artifact servers. Range-based resume is supported when
|
|
3497
|
+
* the server advertises `Accept-Ranges: bytes`. To upload to an HTTP endpoint,
|
|
3498
|
+
* use the WebDAV provider, the S3 provider, or a cloud-specific provider.
|
|
3499
|
+
*
|
|
3500
|
+
* @param options - Optional id, base path, secure flag, fetch override.
|
|
3248
3501
|
* @returns Provider factory suitable for `createTransferClient({ providers: [...] })`.
|
|
3502
|
+
*
|
|
3503
|
+
* @example Download a public artifact
|
|
3504
|
+
* ```ts
|
|
3505
|
+
* import { createHttpProviderFactory, createTransferClient, downloadFile } from "@zero-transfer/sdk";
|
|
3506
|
+
*
|
|
3507
|
+
* const client = createTransferClient({ providers: [createHttpProviderFactory()] });
|
|
3508
|
+
*
|
|
3509
|
+
* await downloadFile({
|
|
3510
|
+
* client,
|
|
3511
|
+
* localPath: "./tmp/release.tar.gz",
|
|
3512
|
+
* source: {
|
|
3513
|
+
* path: "/releases/v1.0.0/release.tar.gz",
|
|
3514
|
+
* profile: { host: "downloads.example.com", provider: "http" },
|
|
3515
|
+
* },
|
|
3516
|
+
* });
|
|
3517
|
+
* ```
|
|
3518
|
+
*
|
|
3519
|
+
* @example Bearer-token-protected endpoint
|
|
3520
|
+
* ```ts
|
|
3521
|
+
* await downloadFile({
|
|
3522
|
+
* client,
|
|
3523
|
+
* localPath: "./reports/today.json",
|
|
3524
|
+
* source: {
|
|
3525
|
+
* path: "/reports/today.json",
|
|
3526
|
+
* profile: {
|
|
3527
|
+
* host: "api.example.com",
|
|
3528
|
+
* provider: "http",
|
|
3529
|
+
* password: { env: "REPORTS_TOKEN" },
|
|
3530
|
+
* },
|
|
3531
|
+
* },
|
|
3532
|
+
* });
|
|
3533
|
+
* ```
|
|
3249
3534
|
*/
|
|
3250
3535
|
declare function createHttpProviderFactory(options?: HttpProviderOptions): ProviderFactory;
|
|
3251
3536
|
|
|
3252
|
-
export { AbortError, type AtomicDeployActivateOperation, type AtomicDeployActivateStep, type AtomicDeployPlan, type AtomicDeployPruneStep, type AtomicDeployStrategy, type AuthenticationCapability, AuthenticationError, AuthorizationError, type BandwidthSleep, type BandwidthThrottle, type BandwidthThrottleOptions, type Base64EnvSecretSource, type BuiltInProviderId, CLASSIC_PROVIDER_IDS, type CapabilitySet, type ChecksumCapability, type ClassicProviderId, type ClientDiagnostics, type CompareRemoteManifestsOptions, ConfigurationError, type ConnectionDiagnosticTimings, type ConnectionDiagnosticsResult, ConnectionError, type ConnectionPoolOptions, type ConnectionProfile, type CopyBetweenOptions, type CreateAtomicDeployPlanOptions, type CreateRemoteBrowserOptions, type CreateRemoteManifestOptions, type CreateSyncPlanOptions, type DiffRemoteTreesOptions, type DownloadFileOptions, type EnvSecretSource, type FileSecretSource, type FileZillaSite, type FriendlyTransferOptions, type FtpReplyErrorInput, type HttpFetch, type HttpProviderOptions, type ImportFileZillaSitesResult, type ImportOpenSshConfigOptions, type ImportOpenSshConfigResult, type ImportWinScpSessionsResult, type KnownHostsEntry, type KnownHostsMarker, type ListOptions, type LocalProviderOptions, type LogLevel, type LogRecord, type LogRecordInput, type LoggerMethod, type MemoryProviderEntry, type MemoryProviderOptions, type MetadataCapability, type MkdirOptions, type OAuthAccessToken, type OAuthRefreshCallback, type OAuthTokenSecretSourceOptions, type OpenSshConfigEntry, ParseError, PathAlreadyExistsError, PathNotFoundError, PermissionDeniedError, type PooledTransferClient, type ProgressEventInput, ProtocolError, type AuthenticationCapability as ProviderAuthenticationCapability, type CapabilitySet as ProviderCapabilities, type ChecksumCapability as ProviderChecksumCapability, type ProviderFactory, type ProviderId, type MetadataCapability as ProviderMetadataCapability, ProviderRegistry, type ProviderSelection, type ProviderTransferEndpointRole, type ProviderTransferExecutorOptions, type ProviderTransferOperations, type ProviderTransferReadRequest, type ProviderTransferReadResult, type ProviderTransferRequest, type ProviderTransferSessionResolver, type ProviderTransferSessionResolverInput, type ProviderTransferWriteRequest, type ProviderTransferWriteResult, REDACTED, REMOTE_MANIFEST_FORMAT_VERSION, type RemoteBreadcrumb, type RemoteBrowser, type RemoteBrowserFilter, type RemoteBrowserSnapshot, type RemoteEntry, type RemoteEntrySortKey, type RemoteEntrySortOrder, type RemoteEntryType, type RemoteFileAdapter, type RemoteFileEndpoint, type RemoteFileSystem, type RemoteManifest, type RemoteManifestEntry, type RemotePermissions, type RemoteProtocol, type RemoteStat, type RemoteTreeDiff, type RemoteTreeDiffEntry, type RemoteTreeDiffReason, type RemoteTreeDiffStatus, type RemoteTreeDiffSummary, type RemoteTreeEntry, type RemoteTreeFilter, type RemoveOptions, type RenameOptions, type ResolveSecretOptions, type ResolvedConnectionProfile, type ResolvedOpenSshHost, type ResolvedSshProfile, type ResolvedTlsProfile, type RmdirOptions, type RunConnectionDiagnosticsOptions, type SecretProvider, type SecretSource, type SecretValue, type SpecializedErrorDetails, type SshAgentSource, type SshAlgorithms, type SshKeyboardInteractiveChallenge, type SshKeyboardInteractiveHandler, type SshKeyboardInteractivePrompt, type SshKnownHostsSource, type SshProfile, type SshSocketFactory, type SshSocketFactoryContext, type StatOptions, type SyncConflictPolicy, type SyncDeletePolicy, type SyncDirection, type SyncEndpointInput, TimeoutError, type TlsProfile, type TlsSecretSource, type TransferAttempt, type TransferAttemptError, type TransferBandwidthLimit, type TransferByteRange, TransferClient, type TransferClientOptions, type TransferDataChunk, type TransferDataSource, type TransferEndpoint, TransferEngine, type TransferEngineExecuteOptions, type TransferEngineOptions, TransferError, type TransferExecutionContext, type TransferExecutionResult, type TransferExecutor, type TransferJob, type TransferOperation, type TransferPlan, type TransferPlanAction, type TransferPlanInput, type TransferPlanStep, type TransferPlanSummary, type TransferProgressEvent, type TransferProvider, TransferQueue, type TransferQueueExecutorResolver, type TransferQueueItem, type TransferQueueItemStatus, type TransferQueueOptions, type TransferQueueRunOptions, type TransferQueueSummary, type TransferReceipt, type TransferResult, type TransferResultInput, type TransferRetryDecisionInput, type TransferRetryPolicy, type TransferSession, type TransferTimeoutPolicy, type TransferVerificationResult, UnsupportedFeatureError, type UploadFileOptions, type ValueSecretSource, VerificationError, type WalkRemoteTreeOptions, type WinScpSession, ZeroTransfer, type ZeroTransferCapabilities, ZeroTransferError, type ZeroTransferErrorDetails, type ZeroTransferLogger, type ZeroTransferOptions, assertSafeFtpArgument, basenameRemotePath, buildRemoteBreadcrumbs, compareRemoteManifests, copyBetween, createAtomicDeployPlan, createBandwidthThrottle, createHttpProviderFactory, createLocalProviderFactory, createMemoryProviderFactory, createOAuthTokenSecretSource, createPooledTransferClient, createProgressEvent, createProviderTransferExecutor, createRemoteBrowser, createRemoteManifest, createSyncPlan, createTransferClient, createTransferJobsFromPlan, createTransferPlan, createTransferResult, diffRemoteTrees, downloadFile, emitLog, errorFromFtpReply, filterRemoteEntries, importFileZillaSites, importOpenSshConfig, importWinScpSessions, isClassicProviderId, isSensitiveKey, joinRemotePath, matchKnownHosts, matchKnownHostsEntry, noopLogger, normalizeRemotePath, parentRemotePath, parseKnownHosts, parseOpenSshConfig, parseRemoteManifest, redactCommand, redactConnectionProfile, redactObject, redactSecretSource, redactValue, resolveConnectionProfileSecrets, resolveOpenSshHost, resolveProviderId, resolveSecret, runConnectionDiagnostics, serializeRemoteManifest, sortRemoteEntries, summarizeClientDiagnostics, summarizeTransferPlan, throttleByteIterable, uploadFile, validateConnectionProfile, walkRemoteTree };
|
|
3537
|
+
export { AbortError, type AtomicDeployActivateOperation, type AtomicDeployActivateStep, type AtomicDeployPlan, type AtomicDeployPruneStep, type AtomicDeployStrategy, type AuthenticationCapability, AuthenticationError, AuthorizationError, type BandwidthSleep, type BandwidthThrottle, type BandwidthThrottleOptions, type Base64EnvSecretSource, type BuiltInProviderId, CLASSIC_PROVIDER_IDS, type CapabilitySet, type ChecksumCapability, type ClassicProviderId, type ClientDiagnostics, type CompareRemoteManifestsOptions, ConfigurationError, type ConnectionDiagnosticTimings, type ConnectionDiagnosticsResult, ConnectionError, type ConnectionPoolOptions, type ConnectionProfile, type CopyBetweenOptions, type CreateAtomicDeployPlanOptions, type CreateRemoteBrowserOptions, type CreateRemoteManifestOptions, type CreateSyncPlanOptions, type DiffRemoteTreesOptions, type DownloadFileOptions, type EnvSecretSource, type FileSecretSource, type FileZillaSite, type FriendlyTransferOptions, type FtpReplyErrorInput, type HttpFetch, type HttpProviderOptions, type ImportFileZillaSitesResult, type ImportOpenSshConfigOptions, type ImportOpenSshConfigResult, type ImportWinScpSessionsResult, type KnownHostsEntry, type KnownHostsMarker, type ListOptions, type LocalProviderOptions, type LogLevel, type LogRecord, type LogRecordInput, type LoggerMethod, type MemoryProviderEntry, type MemoryProviderOptions, type MetadataCapability, type MkdirOptions, type OAuthAccessToken, type OAuthRefreshCallback, type OAuthTokenSecretSourceOptions, type OpenSshConfigEntry, ParseError, PathAlreadyExistsError, PathNotFoundError, PermissionDeniedError, type PooledTransferClient, type ProgressEventInput, ProtocolError, type AuthenticationCapability as ProviderAuthenticationCapability, type CapabilitySet as ProviderCapabilities, type ChecksumCapability as ProviderChecksumCapability, type ProviderFactory, type ProviderId, type MetadataCapability as ProviderMetadataCapability, ProviderRegistry, type ProviderSelection, type ProviderTransferEndpointRole, type ProviderTransferExecutorOptions, type ProviderTransferOperations, type ProviderTransferReadRequest, type ProviderTransferReadResult, type ProviderTransferRequest, type ProviderTransferSessionResolver, type ProviderTransferSessionResolverInput, type ProviderTransferWriteRequest, type ProviderTransferWriteResult, REDACTED, REMOTE_MANIFEST_FORMAT_VERSION, type RemoteBreadcrumb, type RemoteBrowser, type RemoteBrowserFilter, type RemoteBrowserSnapshot, type RemoteEntry, type RemoteEntrySortKey, type RemoteEntrySortOrder, type RemoteEntryType, type RemoteFileAdapter, type RemoteFileEndpoint, type RemoteFileSystem, type RemoteManifest, type RemoteManifestEntry, type RemotePermissions, type RemoteProtocol, type RemoteStat, type RemoteTreeDiff, type RemoteTreeDiffEntry, type RemoteTreeDiffReason, type RemoteTreeDiffStatus, type RemoteTreeDiffSummary, type RemoteTreeEntry, type RemoteTreeFilter, type RemoveOptions, type RenameOptions, type ResolveSecretOptions, type ResolvedConnectionProfile, type ResolvedOpenSshHost, type ResolvedSshProfile, type ResolvedTlsProfile, type RmdirOptions, type RunConnectionDiagnosticsOptions, type SecretProvider, type SecretSource, type SecretValue, type SpecializedErrorDetails, type SshAgentSource, type SshAlgorithms, type SshKeyboardInteractiveChallenge, type SshKeyboardInteractiveHandler, type SshKeyboardInteractivePrompt, type SshKnownHostsSource, type SshProfile, type SshSocketFactory, type SshSocketFactoryContext, type StatOptions, type SyncConflictPolicy, type SyncDeletePolicy, type SyncDirection, type SyncEndpointInput, TimeoutError, type TlsProfile, type TlsSecretSource, type TransferAttempt, type TransferAttemptError, type TransferBandwidthLimit, type TransferByteRange, TransferClient, type TransferClientOptions, type TransferDataChunk, type TransferDataSource, type TransferEndpoint, TransferEngine, type TransferEngineExecuteOptions, type TransferEngineOptions, TransferError, type TransferExecutionContext, type TransferExecutionResult, type TransferExecutor, type TransferJob, type TransferOperation, type TransferPlan, type TransferPlanAction, type TransferPlanInput, type TransferPlanStep, type TransferPlanSummary, type TransferProgressEvent, type TransferProvider, TransferQueue, type TransferQueueExecutorResolver, type TransferQueueItem, type TransferQueueItemStatus, type TransferQueueOptions, type TransferQueueRunOptions, type TransferQueueSummary, type TransferReceipt, type TransferResult, type TransferResultInput, type TransferRetryDecisionInput, type TransferRetryPolicy, type TransferSession, type TransferTimeoutPolicy, type TransferVerificationResult, UnsupportedFeatureError, type UploadFileOptions, type ValueSecretSource, VerificationError, type WalkRemoteTreeOptions, type WinScpSession, ZeroTransfer, type ZeroTransferCapabilities, ZeroTransferError, type ZeroTransferErrorDetails, type ZeroTransferLogger, type ZeroTransferOptions, assertSafeFtpArgument, basenameRemotePath, buildRemoteBreadcrumbs, compareRemoteManifests, copyBetween, createAtomicDeployPlan, createBandwidthThrottle, createHttpProviderFactory, createLocalProviderFactory, createMemoryProviderFactory, createOAuthTokenSecretSource, createPooledTransferClient, createProgressEvent, createProviderTransferExecutor, createRemoteBrowser, createRemoteManifest, createSyncPlan, createTransferClient, createTransferJobsFromPlan, createTransferPlan, createTransferResult, diffRemoteTrees, downloadFile, emitLog, errorFromFtpReply, filterRemoteEntries, importFileZillaSites, importOpenSshConfig, importWinScpSessions, isClassicProviderId, isMainModule, isSensitiveKey, joinRemotePath, matchKnownHosts, matchKnownHostsEntry, noopLogger, normalizeRemotePath, parentRemotePath, parseKnownHosts, parseOpenSshConfig, parseRemoteManifest, redactCommand, redactConnectionProfile, redactObject, redactSecretSource, redactValue, resolveConnectionProfileSecrets, resolveOpenSshHost, resolveProviderId, resolveSecret, runConnectionDiagnostics, serializeRemoteManifest, sortRemoteEntries, summarizeClientDiagnostics, summarizeTransferPlan, throttleByteIterable, uploadFile, validateConnectionProfile, walkRemoteTree };
|
package/dist/index.mjs
CHANGED
|
@@ -4785,6 +4785,19 @@ function isModifiedAtDifferent2(source, destination, toleranceMs) {
|
|
|
4785
4785
|
return Math.abs(sourceTime - destinationTime) > toleranceMs;
|
|
4786
4786
|
}
|
|
4787
4787
|
|
|
4788
|
+
// src/utils/mainModule.ts
|
|
4789
|
+
import { fileURLToPath } from "url";
|
|
4790
|
+
function isMainModule(importMetaUrl) {
|
|
4791
|
+
if (typeof process === "undefined" || !process.argv || process.argv.length < 2) {
|
|
4792
|
+
return false;
|
|
4793
|
+
}
|
|
4794
|
+
try {
|
|
4795
|
+
return process.argv[1] === fileURLToPath(importMetaUrl);
|
|
4796
|
+
} catch {
|
|
4797
|
+
return false;
|
|
4798
|
+
}
|
|
4799
|
+
}
|
|
4800
|
+
|
|
4788
4801
|
// src/providers/web/HttpProvider.ts
|
|
4789
4802
|
import { Buffer as Buffer7 } from "buffer";
|
|
4790
4803
|
|
|
@@ -5176,6 +5189,7 @@ export {
|
|
|
5176
5189
|
importOpenSshConfig,
|
|
5177
5190
|
importWinScpSessions,
|
|
5178
5191
|
isClassicProviderId,
|
|
5192
|
+
isMainModule,
|
|
5179
5193
|
isSensitiveKey,
|
|
5180
5194
|
joinRemotePath,
|
|
5181
5195
|
matchKnownHosts,
|