@teepin/sdk 0.2.1 → 0.3.0-rc.1

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.
Files changed (134) hide show
  1. package/README.md +41 -36
  2. package/dist/cjs/client.js +42 -4
  3. package/dist/cjs/client.js.map +1 -1
  4. package/dist/cjs/direct/bytes.js +50 -0
  5. package/dist/cjs/direct/bytes.js.map +1 -0
  6. package/dist/cjs/direct/common.js +167 -0
  7. package/dist/cjs/direct/common.js.map +1 -0
  8. package/dist/cjs/direct/downloads-plan.js +127 -0
  9. package/dist/cjs/direct/downloads-plan.js.map +1 -0
  10. package/dist/cjs/direct/engine.js +405 -0
  11. package/dist/cjs/direct/engine.js.map +1 -0
  12. package/dist/cjs/direct/formats.js +44 -0
  13. package/dist/cjs/direct/formats.js.map +1 -0
  14. package/dist/cjs/direct/hpke.js +275 -0
  15. package/dist/cjs/direct/hpke.js.map +1 -0
  16. package/dist/cjs/direct/journal.js +80 -0
  17. package/dist/cjs/direct/journal.js.map +1 -0
  18. package/dist/cjs/direct/large.js +850 -0
  19. package/dist/cjs/direct/large.js.map +1 -0
  20. package/dist/cjs/direct/reads.js +1314 -0
  21. package/dist/cjs/direct/reads.js.map +1 -0
  22. package/dist/cjs/direct/sha256.js +122 -0
  23. package/dist/cjs/direct/sha256.js.map +1 -0
  24. package/dist/cjs/direct/tws1.js +480 -0
  25. package/dist/cjs/direct/tws1.js.map +1 -0
  26. package/dist/cjs/direct/uploads.js +1706 -0
  27. package/dist/cjs/direct/uploads.js.map +1 -0
  28. package/dist/cjs/errors.js +70 -13
  29. package/dist/cjs/errors.js.map +1 -1
  30. package/dist/cjs/index.js +5 -1
  31. package/dist/cjs/index.js.map +1 -1
  32. package/dist/cjs/links.js +195 -0
  33. package/dist/cjs/links.js.map +1 -0
  34. package/dist/cjs/node/downloads.js +835 -0
  35. package/dist/cjs/node/downloads.js.map +1 -0
  36. package/dist/cjs/node/journal.js +841 -0
  37. package/dist/cjs/node/journal.js.map +1 -0
  38. package/dist/cjs/node/uploads.js +219 -0
  39. package/dist/cjs/node/uploads.js.map +1 -0
  40. package/dist/cjs/node.js +26 -39
  41. package/dist/cjs/node.js.map +1 -1
  42. package/dist/cjs/storage.js +214 -184
  43. package/dist/cjs/storage.js.map +1 -1
  44. package/dist/cjs/transfer.js +18 -351
  45. package/dist/cjs/transfer.js.map +1 -1
  46. package/dist/esm/client.js +42 -4
  47. package/dist/esm/client.js.map +1 -1
  48. package/dist/esm/direct/bytes.js +42 -0
  49. package/dist/esm/direct/bytes.js.map +1 -0
  50. package/dist/esm/direct/common.js +155 -0
  51. package/dist/esm/direct/common.js.map +1 -0
  52. package/dist/esm/direct/downloads-plan.js +117 -0
  53. package/dist/esm/direct/downloads-plan.js.map +1 -0
  54. package/dist/esm/direct/engine.js +385 -0
  55. package/dist/esm/direct/engine.js.map +1 -0
  56. package/dist/esm/direct/formats.js +40 -0
  57. package/dist/esm/direct/formats.js.map +1 -0
  58. package/dist/esm/direct/hpke.js +262 -0
  59. package/dist/esm/direct/hpke.js.map +1 -0
  60. package/dist/esm/direct/journal.js +75 -0
  61. package/dist/esm/direct/journal.js.map +1 -0
  62. package/dist/esm/direct/large.js +816 -0
  63. package/dist/esm/direct/large.js.map +1 -0
  64. package/dist/esm/direct/reads.js +1275 -0
  65. package/dist/esm/direct/reads.js.map +1 -0
  66. package/dist/esm/direct/sha256.js +118 -0
  67. package/dist/esm/direct/sha256.js.map +1 -0
  68. package/dist/esm/direct/tws1.js +460 -0
  69. package/dist/esm/direct/tws1.js.map +1 -0
  70. package/dist/esm/direct/uploads.js +1660 -0
  71. package/dist/esm/direct/uploads.js.map +1 -0
  72. package/dist/esm/errors.js +64 -11
  73. package/dist/esm/errors.js.map +1 -1
  74. package/dist/esm/index.js +1 -0
  75. package/dist/esm/index.js.map +1 -1
  76. package/dist/esm/links.js +189 -0
  77. package/dist/esm/links.js.map +1 -0
  78. package/dist/esm/node/downloads.js +829 -0
  79. package/dist/esm/node/downloads.js.map +1 -0
  80. package/dist/esm/node/journal.js +824 -0
  81. package/dist/esm/node/journal.js.map +1 -0
  82. package/dist/esm/node/uploads.js +187 -0
  83. package/dist/esm/node/uploads.js.map +1 -0
  84. package/dist/esm/node.js +17 -14
  85. package/dist/esm/node.js.map +1 -1
  86. package/dist/esm/storage.js +214 -184
  87. package/dist/esm/storage.js.map +1 -1
  88. package/dist/esm/transfer.js +19 -349
  89. package/dist/esm/transfer.js.map +1 -1
  90. package/dist/types/client.d.ts +45 -4
  91. package/dist/types/client.d.ts.map +1 -1
  92. package/dist/types/direct/bytes.d.ts +11 -0
  93. package/dist/types/direct/bytes.d.ts.map +1 -0
  94. package/dist/types/direct/common.d.ts +47 -0
  95. package/dist/types/direct/common.d.ts.map +1 -0
  96. package/dist/types/direct/downloads-plan.d.ts +75 -0
  97. package/dist/types/direct/downloads-plan.d.ts.map +1 -0
  98. package/dist/types/direct/engine.d.ts +191 -0
  99. package/dist/types/direct/engine.d.ts.map +1 -0
  100. package/dist/types/direct/formats.d.ts +9 -0
  101. package/dist/types/direct/formats.d.ts.map +1 -0
  102. package/dist/types/direct/hpke.d.ts +55 -0
  103. package/dist/types/direct/hpke.d.ts.map +1 -0
  104. package/dist/types/direct/journal.d.ts +55 -0
  105. package/dist/types/direct/journal.d.ts.map +1 -0
  106. package/dist/types/direct/large.d.ts +170 -0
  107. package/dist/types/direct/large.d.ts.map +1 -0
  108. package/dist/types/direct/reads.d.ts +306 -0
  109. package/dist/types/direct/reads.d.ts.map +1 -0
  110. package/dist/types/direct/sha256.d.ts +16 -0
  111. package/dist/types/direct/sha256.d.ts.map +1 -0
  112. package/dist/types/direct/tws1.d.ts +157 -0
  113. package/dist/types/direct/tws1.d.ts.map +1 -0
  114. package/dist/types/direct/uploads.d.ts +461 -0
  115. package/dist/types/direct/uploads.d.ts.map +1 -0
  116. package/dist/types/errors.d.ts +47 -8
  117. package/dist/types/errors.d.ts.map +1 -1
  118. package/dist/types/index.d.ts +1 -0
  119. package/dist/types/index.d.ts.map +1 -1
  120. package/dist/types/links.d.ts +86 -0
  121. package/dist/types/links.d.ts.map +1 -0
  122. package/dist/types/node/downloads.d.ts +73 -0
  123. package/dist/types/node/downloads.d.ts.map +1 -0
  124. package/dist/types/node/journal.d.ts +162 -0
  125. package/dist/types/node/journal.d.ts.map +1 -0
  126. package/dist/types/node/uploads.d.ts +86 -0
  127. package/dist/types/node/uploads.d.ts.map +1 -0
  128. package/dist/types/node.d.ts +4 -2
  129. package/dist/types/node.d.ts.map +1 -1
  130. package/dist/types/storage.d.ts +107 -64
  131. package/dist/types/storage.d.ts.map +1 -1
  132. package/dist/types/transfer.d.ts +14 -23
  133. package/dist/types/transfer.d.ts.map +1 -1
  134. package/package.json +2 -2
@@ -0,0 +1,86 @@
1
+ import { LinkReads, type Session } from './direct/reads.js';
2
+ import type { ObjectInfo, StorageObject } from './storage.js';
3
+ import { type DownloadOptions, type DownloadSink } from './transfer.js';
4
+ /** How a share link is meant to be offered: previewed where that is safe ("inline"), or saved as a file ("attachment"). */
5
+ export type LinkDisposition = 'inline' | 'attachment';
6
+ export interface OpenLinkOptions {
7
+ /** The API's address (default: the TEEPIN_BASE_URL environment variable, else https://api.teepin.com). */
8
+ baseUrl?: string;
9
+ /** The fetch to use (default: the global one). */
10
+ fetch?: typeof fetch;
11
+ /** Aborting it stops every read of the link, as close() does. */
12
+ signal?: AbortSignal;
13
+ /** Windows read() fetches ahead of a reader reading straight on (default 2), as openObject's. */
14
+ prefetch?: number;
15
+ /** Milliseconds one call to the API may take (default 60000); also how long a read waits for its next bytes. */
16
+ timeout?: number;
17
+ /** How many times a request that failed for a passing reason is tried again (default 4). */
18
+ maxRetries?: number;
19
+ }
20
+ /** A link's token: the link itself when it is a bare token, else its URL's fragment (the console's /l#<token>). */
21
+ export declare function linkToken(link: string): string;
22
+ /**
23
+ * Opens a share link with no API key: the object's details, then its bytes from the storage network, every one
24
+ * verified before it is used. link is the link's URL or its token. The link opens whatever is at its key now; once
25
+ * open, every read is of that version (ObjectChangedError if it is replaced), and reads go on after the link expires:
26
+ * for up to 30 minutes between reads, and never past the link's expiry plus 24 hours.
27
+ *
28
+ * Errors: InvalidLinkError for a damaged or expired link, NotFoundError for an object deleted since the link was made,
29
+ * PaymentRequiredError (onHold) while its owner's stored data is on hold, and a TeepinError for an object still being
30
+ * moved into storage.
31
+ *
32
+ * ```ts
33
+ * const obj = await openLink('https://console.teepin.com/l#…');
34
+ * console.log(obj.name, obj.size);
35
+ * const body = obj.stream(); // the whole object, its SHA-256 checked at the end
36
+ * obj.close();
37
+ * ```
38
+ */
39
+ export declare function openLink(link: string, opts?: OpenLinkOptions): Promise<SharedObject>;
40
+ /**
41
+ * An object opened through a share link: its details, and its bytes three ways (read at any offset, one stream of the
42
+ * whole object, or downloadTo a sink). Close it when done: that stops its reads and zeroes its copy of the data key.
43
+ */
44
+ export declare class SharedObject {
45
+ private readonly reads;
46
+ private readonly session;
47
+ /** The name to save it as: the last segment of its key ("download" when there is none). */
48
+ readonly name: string;
49
+ /** Its size in bytes. */
50
+ readonly size: number;
51
+ /** Its content type ("application/octet-stream" when it has none). */
52
+ readonly contentType: string;
53
+ /** How the link is meant to be offered. */
54
+ readonly disposition: LinkDisposition;
55
+ /** Its download headers, as headObject gives them. */
56
+ readonly info: ObjectInfo;
57
+ private readonly file;
58
+ private readonly ctl;
59
+ private readonly unlinkSignal;
60
+ private dek;
61
+ private isClosed;
62
+ /** Made by openLink. */
63
+ constructor(reads: LinkReads, session: Session, opts?: Pick<OpenLinkOptions, 'signal' | 'prefetch'>);
64
+ get closed(): boolean;
65
+ /**
66
+ * Up to length bytes from offset: fewer only at the object's end, none past it. Reading straight on fetches a window
67
+ * at a time with the next ones ahead, as openObject's reader does; a read somewhere else fetches only what it needs.
68
+ */
69
+ read(offset: number, length: number): Promise<Uint8Array>;
70
+ /**
71
+ * The whole object as a stream of verified bytes, fetched only as they are read: a window at a time, its SHA-256
72
+ * checked as the last bytes arrive (ChecksumMismatchError). Read it to its end or cancel it.
73
+ */
74
+ stream(opts?: {
75
+ signal?: AbortSignal;
76
+ }): ReadableStream<Uint8Array>;
77
+ /**
78
+ * Downloads the object into sink, as parallel ranges of the version the link opened, every byte verified before it is
79
+ * written (the whole object's SHA-256 too, when it is read in one range: concurrency 1, or one window).
80
+ */
81
+ downloadTo(sink: DownloadSink, opts?: DownloadOptions): Promise<StorageObject>;
82
+ /** Stops every read (streams and downloads too) and zeroes this object's copy of the data key. */
83
+ close(): void;
84
+ private checkOpen;
85
+ }
86
+ //# sourceMappingURL=links.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"links.d.ts","sourceRoot":"","sources":["../../src/links.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,SAAS,EAAgC,KAAK,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAE1F,OAAO,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC9D,OAAO,EAAuB,KAAK,eAAe,EAAE,KAAK,YAAY,EAAE,MAAM,eAAe,CAAC;AAE7F,2HAA2H;AAC3H,MAAM,MAAM,eAAe,GAAG,QAAQ,GAAG,YAAY,CAAC;AAEtD,MAAM,WAAW,eAAe;IAC9B,0GAA0G;IAC1G,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,kDAAkD;IAClD,KAAK,CAAC,EAAE,OAAO,KAAK,CAAC;IACrB,iEAAiE;IACjE,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,iGAAiG;IACjG,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,gHAAgH;IAChH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,4FAA4F;IAC5F,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,mHAAmH;AACnH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAS9C;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAsB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,I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 -0,0 +1,73 @@
1
+ import { type DownloadResult } from '../direct/downloads-plan.js';
2
+ import type { StorageService } from '../storage.js';
3
+ export interface DownloadFilesOptions {
4
+ /**
5
+ * Leave a file that already has the object's size and SHA-256 (never compared by ETag): nothing is signed, or
6
+ * billed, for it.
7
+ */
8
+ skipExisting?: boolean;
9
+ /** Objects, or windows of a large object, fetched at once (default 8). */
10
+ concurrency?: number;
11
+ /** Bytes written so far, of all the objects being downloaded. */
12
+ onProgress?: (done: number, total: number) => void;
13
+ /**
14
+ * Keep a journal in the client's state directory (default true), so a download stopped part way goes on from what it
15
+ * wrote when it's run again. false keeps none.
16
+ */
17
+ journal?: boolean;
18
+ /** Aborting it stops every fetch at once: the call rejects with its reason, and the part files and journal stay for the next run. */
19
+ signal?: AbortSignal;
20
+ }
21
+ /** One event of a run's journal: an object being downloaded to path, one of its pieces written, and how it ended. */
22
+ export type JournalEvent = {
23
+ e: 'object';
24
+ path: string;
25
+ key: string;
26
+ version: string;
27
+ size: number;
28
+ } | {
29
+ e: 'range';
30
+ path: string;
31
+ a: number;
32
+ b: number;
33
+ } | {
34
+ e: 'saved';
35
+ path: string;
36
+ } | {
37
+ e: 'failed';
38
+ path: string;
39
+ error: string;
40
+ };
41
+ /** For tests only (a test checks that nothing under src sets it): called once each journal write is durable. */
42
+ export declare const testHooks: {
43
+ journaled?: (events: readonly JournalEvent[]) => void;
44
+ };
45
+ /**
46
+ * Downloads many objects, each to destDir joined with its key (a/b.jpg to destDir/a/b.jpg), and returns one
47
+ * DownloadResult per key, in order (a key given twice is one). One object's failure never fails another.
48
+ *
49
+ * Read sessions are signed 1,000 objects to a request. Up to concurrency objects, or windows of a large object, are
50
+ * fetched at once, each verified before it is written to <name>.teepin-part beside its target; an object is checked
51
+ * against its SHA-256 and renamed into place only when whole.
52
+ *
53
+ * A download stopped by a passing error (the network, the storage network unavailable, a revoked key), by an abort or
54
+ * by the process ending is pending: its part file and the run's journal stay, and running the same download again
55
+ * goes on from what was written, unless the object has changed since.
56
+ *
57
+ * A key that isn't a safe path under destDir fails (UnsafePathError): "..", an absolute path, a name Windows can't
58
+ * have (on every OS), a link under destDir leading out of it, or two keys for one file (names that differ only by case,
59
+ * where names ignore case). A key ending in "/" (a folder marker) is skipped.
60
+ */
61
+ export declare function downloadFiles(storage: StorageService, bucket: string, keys: readonly string[], destDir: string, opts?: DownloadFilesOptions): Promise<DownloadResult[]>;
62
+ /**
63
+ * Downloads every object under prefix (all of them for ""), each to destDir joined with its key after the prefix, as
64
+ * downloadFiles does. With skipExisting, the listing's size and SHA-256 decide, so a file already there costs nothing
65
+ * more.
66
+ */
67
+ export declare function downloadPrefix(storage: StorageService, bucket: string, prefix: string, destDir: string, opts?: DownloadFilesOptions): Promise<DownloadResult[]>;
68
+ /**
69
+ * Whether names under dir ignore case (Windows, macOS's default volumes), found by trying; true when it can't be told,
70
+ * the safe side. dir is made if it isn't there.
71
+ */
72
+ export declare function caseInsensitive(dir: string): Promise<boolean>;
73
+ //# sourceMappingURL=downloads.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"downloads.d.ts","sourceRoot":"","sources":["../../../src/node/downloads.ts"],"names":[],"mappings":"AAsCA,OAAO,EAAyD,KAAK,cAAc,EAAkB,MAAM,6BAA6B,CAAC;AAGzI,OAAO,KAAK,EAAiB,cAAc,EAAE,MAAM,eAAe,CAAC;AAGnE,MAAM,WAAW,oBAAoB;IACnC;;;OAGG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,0EAA0E;IAC1E,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,iEAAiE;IACjE,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACnD;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,qIAAqI;IACrI,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB;AAED,qHAAqH;AACrH,MAAM,MAAM,YAAY,GACpB;IAAE,CAAC,EAAE,QAAQ,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GACzE;IAAE,CAAC,EAAE,OAAO,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,GAClD;IAAE,CAAC,EAAE,OAAO,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAC5B;IAAE,CAAC,EAAE,QAAQ,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAEjD,gHAAgH;AAChH,eAAO,MAAM,SAAS,EAAE;IAAE,SAAS,CAAC,EAAE,CAAC,MAAM,EAAE,SAAS,YAAY,EAAE,KAAK,IAAI,CAAA;CAAO,CAAC;AAWvF;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,aAAa,CAC3B,OAAO,EAAE,cAAc,EACvB,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,SAAS,MAAM,EAAE,EACvB,OAAO,EAAE,MAAM,EACf,IAAI,GAAE,oBAAyB,GAC9B,OAAO,CAAC,cAAc,EAAE,CAAC,CAE3B;AAED;;;;GAIG;AACH,wBAAsB,cAAc,CAClC,OAAO,EAAE,cAAc,EACvB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,MAAM,EACf,IAAI,GAAE,oBAAyB,GAC9B,OAAO,CAAC,cAAc,EAAE,CAAC,CAW3B;AAkfD;;;GAGG;AACH,wBAAsB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAiBnE"}
@@ -0,0 +1,162 @@
1
+ import { type Entry, type Journal, type Row, type Table } from '../direct/journal.js';
2
+ import type { KeyPins, RunPlace } from '../direct/uploads.js';
3
+ export declare const STATE_ENV = "TEEPIN_STATE_DIR";
4
+ export declare const RUN_FILE = "run.json";
5
+ export declare const EVENTS_FILE = "events.jsonl";
6
+ export declare const LOCK_FILE = "lock";
7
+ export declare const PACKS_DIR = "packs";
8
+ export declare const KEYS_DIR = "keys";
9
+ export declare const HISTORY_FILE = "history.log";
10
+ /** The journal's own format version, in run.json. */
11
+ export declare const JOURNAL_FORMAT = 1;
12
+ /** A lock file whose content can't be read yet is being written: held for this long, then stale. */
13
+ export declare const LOCK_GRACE_MS = 10000;
14
+ /** The state directory for this OS (section 19.12), or TEEPIN_STATE_DIR. */
15
+ export declare function defaultStateDir(): string;
16
+ /** Creates path (and its parents) readable by its owner only. */
17
+ export declare function privateDir(path: string): Promise<string>;
18
+ /** fsyncs a directory, so a rename or a new file in it survives a crash; nothing where the OS can't (Windows). */
19
+ export declare function fsyncDir(path: string): Promise<void>;
20
+ /** How long a rename over a file another process has open is tried again on Windows (tests shorten it), and how often. */
21
+ export declare const sharing: {
22
+ retryMs: number;
23
+ };
24
+ /**
25
+ * Renames from over to, trying again for up to sharing.retryMs on Windows while another process holds to open
26
+ * (EPERM, EACCES or EBUSY: a reader of a lock, a history file being appended to). Elsewhere a rename replaces an open
27
+ * file, so it is tried once (profile 1's W-1; Go's journal does the same).
28
+ */
29
+ export declare function renameOver(from: string, to: string, retryMs?: number): Promise<void>;
30
+ /** Writes data to path all at once: a temporary file (0600), fsynced, then renamed over it, and the directory fsynced. */
31
+ export declare function writeAtomic(path: string, data: Uint8Array | string): Promise<void>;
32
+ /**
33
+ * One run's journal on disk: run.json, and events.jsonl appended a line per write. Writes resolve once they are
34
+ * fsynced; a batch is one line, so it lands whole or not at all. Only the run's lock holder opens it to write.
35
+ */
36
+ export declare class FileJournal implements Journal {
37
+ readonly dir: string;
38
+ readonly durable = true;
39
+ private readonly data;
40
+ private fh?;
41
+ private chain;
42
+ private closed;
43
+ private broken?;
44
+ private constructor();
45
+ /** Opens a run's journal to write: replayed, then compacted when it has more than one line or a torn one. */
46
+ static open(dir: string): Promise<FileJournal>;
47
+ /** A run's rows, read without writing anything (a run another process may hold). */
48
+ static read(dir: string): Promise<Pick<Journal, 'get' | 'rows'>>;
49
+ put(table: Table, id: string, row: Row): Promise<void>;
50
+ write(entries: readonly Entry[]): Promise<void>;
51
+ get(table: Table, id: string): Row | undefined;
52
+ rows(table: Table): Row[];
53
+ nextId(table: Table): string;
54
+ /** Rewrites the journal as one line, atomically. */
55
+ compact(): Promise<void>;
56
+ private rewrite;
57
+ close(): Promise<void>;
58
+ private check;
59
+ }
60
+ /**
61
+ * When process pid started, as this OS tells it: a token that is the same for the same process every time it's asked,
62
+ * and differs for a process that reused its PID. undefined when the OS can't tell (then a live PID counts as the
63
+ * holder). Linux: /proc's start time in ticks since boot, with the boot's id; macOS and the BSDs: ps's start time;
64
+ * Windows: the process's creation time, from PowerShell.
65
+ */
66
+ export declare function processStart(pid: number): Promise<string | undefined>;
67
+ /**
68
+ * An exclusive lock on a run, held while it is open, so two processes (or two runs in one process) never work one run
69
+ * (section 17.2). A process that ends without releasing it leaves it stale, and the next taker takes it over.
70
+ */
71
+ export declare class RunLock {
72
+ readonly path: string;
73
+ /** Our nonce while we hold it. */
74
+ private mine?;
75
+ constructor(path: string);
76
+ get held(): boolean;
77
+ private get key();
78
+ /** Takes the lock if no live process (this one included) holds it. */
79
+ acquire(): Promise<boolean>;
80
+ /**
81
+ * Whether a lock is stale: its process is gone (a dead PID on this host, or a reused one, whose start time differs),
82
+ * or it is this process's and no run here holds it (taking, when this lock object is the one taking it). A lock from
83
+ * another host is never stale: its PID means nothing here.
84
+ */
85
+ private stale;
86
+ /**
87
+ * Takes over a stale lock: only one taker's claim (an O_EXCL file named by the stale lock's identity) wins, and the
88
+ * winner replaces the lock whole only if it is still that stale one.
89
+ */
90
+ private takeOver;
91
+ private staleClaim;
92
+ /** Lets the lock go (deleting its file, if it is still ours). Safe to call twice. */
93
+ release(): Promise<void>;
94
+ /** Whether a live process (this one included, through another lock object) holds the lock. */
95
+ heldElsewhere(): Promise<boolean>;
96
+ }
97
+ /** Every run of a kind in the state directory, oldest first. */
98
+ export declare function runIds(stateDir: string, kind?: string): Promise<string[]>;
99
+ /** A run's directory in the state directory, with its lock and journal: a RunPlace for the upload engine. */
100
+ export declare class RunDir implements RunPlace {
101
+ readonly id: string;
102
+ readonly kind: string;
103
+ readonly path: string;
104
+ readonly lock: RunLock;
105
+ private j?;
106
+ private released;
107
+ private constructor();
108
+ get journal(): FileJournal;
109
+ /** A new run, locked by this process, its journal open. */
110
+ static create(stateDir: string, kind?: string): Promise<RunDir>;
111
+ /** A run, locked for this caller with its journal open; undefined when a live process (or another run here) holds it. */
112
+ static take(stateDir: string, id: string, kind?: string): Promise<RunDir | undefined>;
113
+ /** A run's journal read without taking it, and whether a live process holds it. */
114
+ static peek(stateDir: string, id: string, kind?: string): Promise<{
115
+ journal: Pick<Journal, 'get' | 'rows'>;
116
+ inUse: boolean;
117
+ }>;
118
+ private packPath;
119
+ private keyPath;
120
+ writePack(name: string, data: Uint8Array): Promise<void>;
121
+ readPack(name: string): Promise<Uint8Array | undefined>;
122
+ removePack(name: string): Promise<void>;
123
+ packNames(): Promise<string[]>;
124
+ writeKey(id: string, key: Uint8Array): Promise<void>;
125
+ readKey(id: string): Promise<Uint8Array | undefined>;
126
+ /** Overwrites the key's file with zeros (fsynced), then deletes it. */
127
+ removeKey(id: string): Promise<void>;
128
+ /** The ids of the keys kept; leftovers of a write cut short are deleted. */
129
+ keyNames(): Promise<string[]>;
130
+ release(): Promise<void>;
131
+ /** Deletes the run while it still holds the lock (run.json first, so it's no longer listed), then lets the lock go. */
132
+ remove(): Promise<void>;
133
+ }
134
+ /** An append that finds the history past this many bytes trims it to 7 days. */
135
+ export declare const HISTORY_TRIM_BYTES: number;
136
+ /**
137
+ * One line about a finished run (section 17.12). Every SDK on this machine shares the file, so a line is added with
138
+ * one append (O_APPEND) and the file is never rewritten here (profile 1's G-3). It's trimmed to 7 days by
139
+ * trimHistory: by cleanUploads, or here once it passes HISTORY_TRIM_BYTES.
140
+ */
141
+ export declare function appendHistory(stateDir: string, line: string, kind?: string, trimAt?: number): Promise<void>;
142
+ /**
143
+ * Keeps the history's last 7 days, in one atomic rewrite. A line another SDK appends during the rewrite can be lost,
144
+ * so this runs only at cleanUploads or past the size cap, never on each run.
145
+ */
146
+ export declare function trimHistory(stateDir: string, kind?: string): Promise<void>;
147
+ /** The bytes under path. */
148
+ export declare function directorySize(path: string): Promise<number>;
149
+ /**
150
+ * The first public key seen for each account and key version (section 11.4), kept in the state directory's keys.json
151
+ * (and in memory when it can't be written): a different key under the same version is refused.
152
+ */
153
+ export declare class FilePins implements KeyPins {
154
+ private readonly path;
155
+ private mem;
156
+ private chain;
157
+ constructor(stateDir: string);
158
+ check(accountId: string, version: number, publicKey: Uint8Array): Promise<boolean>;
159
+ private checkNow;
160
+ private load;
161
+ }
162
+ //# sourceMappingURL=journal.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"journal.d.ts","sourceRoot":"","sources":["../../../src/node/journal.ts"],"names":[],"mappings":"AA+BA,OAAO,EAAQ,KAAK,KAAK,EAAE,KAAK,OAAO,EAAE,KAAK,GAAG,EAAE,KAAK,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAC5F,OAAO,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAE9D,eAAO,MAAM,SAAS,qBAAqB,CAAC;AAC5C,eAAO,MAAM,QAAQ,aAAa,CAAC;AACnC,eAAO,MAAM,WAAW,iBAAiB,CAAC;AAC1C,eAAO,MAAM,SAAS,SAAS,CAAC;AAChC,eAAO,MAAM,SAAS,UAAU,CAAC;AACjC,eAAO,MAAM,QAAQ,SAAS,CAAC;AAC/B,eAAO,MAAM,YAAY,gBAAgB,CAAC;AAC1C,qDAAqD;AACrD,eAAO,MAAM,cAAc,IAAI,CAAC;AAChC,oGAAoG;AACpG,eAAO,MAAM,aAAa,QAAS,CAAC;AAIp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C;IAkB1C,4EAA4E;IACtE,QAAQ,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IAU7B,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAO9B,uHAAuH;IACjH,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;CAY9B;AAED,gFAAgF;AAChF,eAAO,MAAM,kBAAkB,QAAU,CAAC;AAE1C;;;;GAIG;AACH,wBAAsB,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,SAAY,EAAE,MAAM,SAAqB,GAAG,OAAO,CAAC,IAAI,CAAC,CAWhI;AAED;;;GAGG;AACH,wBAAsB,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,SAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAWnF;AAED,4BAA4B;AAC5B,wBAAsB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAejE;AAID;;;GAGG;AACH,qBAAa,QAAS,YAAW,OAAO;IACtC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAS;IAC9B,OAAO,CAAC,GAAG,CAA8C;IACzD,OAAO,CAAC,KAAK,CAAuC;gBAExC,QAAQ,EAAE,MAAM;IAI5B,KAAK,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,UAAU,GAAG,OAAO,CAAC,OAAO,CAAC;YAMpE,QAAQ;YAgBR,IAAI;CAanB"}
@@ -0,0 +1,86 @@
1
+ import type { StorageService } from '../storage.js';
2
+ import { type DirectUploads, type Digests, type FileHash, type RunHost, type RunPlace, type UploadResult, type UploadRun } from '../direct/uploads.js';
3
+ /** node:crypto's hashes: native, and far faster than the portable ones. */
4
+ export declare const nodeDigests: Digests;
5
+ /** The disk the upload engine's runs need, in a state directory. The method tests replace is hashFile. */
6
+ export declare class NodeRunHost implements RunHost {
7
+ readonly stateDir: string;
8
+ constructor(stateDir: string);
9
+ create(): Promise<RunPlace>;
10
+ ids(): Promise<string[]>;
11
+ take(id: string): Promise<RunPlace | undefined>;
12
+ peek(id: string): Promise<{
13
+ journal: Pick<RunPlace['journal'], 'get' | 'rows'>;
14
+ inUse: boolean;
15
+ } | undefined>;
16
+ history(line: string): Promise<void>;
17
+ trimHistory(): Promise<void>;
18
+ size(): Promise<number>;
19
+ /** A file's size, modification time and SHA-256, or the error reading it; a file that changes while it is read is a changed file. */
20
+ hashFile(path: string): Promise<FileHash | Error>;
21
+ readAt(path: string, offset: number, length: number): Promise<Uint8Array>;
22
+ readWhole(path: string, size: number): Promise<Uint8Array>;
23
+ /** In one pass, a file's whole SHA-256 and each part's. */
24
+ hashParts(path: string, size: number, partSize: number): Promise<{
25
+ whole: string;
26
+ parts: Map<number, string>;
27
+ }>;
28
+ contentType(path: string): string | undefined;
29
+ }
30
+ /** The storage service's upload engine, given the disk: run directories, key pins in the state directory, native hashes. */
31
+ export declare function engineFor(storage: StorageService): DirectUploads;
32
+ export interface UploadFilesOptions {
33
+ /** With a list of paths: put before each key. */
34
+ prefix?: string;
35
+ /** With a list of paths: each key is the path relative to root (with /); without root, the file's name. */
36
+ root?: string;
37
+ /** Default: guessed from each file's name. */
38
+ contentType?: string;
39
+ metadata?: Record<string, string>;
40
+ /** Write each object only if none is at its key. */
41
+ ifNoneMatch?: boolean;
42
+ /** Bytes saved so far and the total, as files are saved. */
43
+ onProgress?: (done: number, total: number) => void;
44
+ /** Journal the run in the state directory, so resumeUploads finishes it after a crash (default true); false keeps it in memory. */
45
+ journal?: boolean;
46
+ /** Bytes per part for files sent in parts (default 16 MiB). */
47
+ partSize?: number;
48
+ /** Stops the run: it is left in its journal, and resumeUploads (in this process or another) finishes it. */
49
+ signal?: AbortSignal;
50
+ }
51
+ /**
52
+ * Uploads many files at once, as one run, and returns one result per file, in order: saved, failed (with its error),
53
+ * or pending (kept for resumeUploads). One file's failure never fails another, and nothing is thrown for it: only for
54
+ * what stops the whole run (a revoked key, no permission, no credit), the state directory being unwritable, or an
55
+ * abort.
56
+ *
57
+ * files maps keys to paths, or lists paths: each key is then prefix plus the path relative to root (with /), or plus
58
+ * its name when there's no root.
59
+ *
60
+ * Small files are encrypted on this device and packed together; large ones go in parts. Each file is hashed when queued
61
+ * and checked again as it's sent, so a file that changes meanwhile fails with FileChangedError.
62
+ */
63
+ export declare function uploadFiles(storage: StorageService, bucket: string, files: Record<string, string> | readonly string[], opts?: UploadFilesOptions): Promise<UploadResult[]>;
64
+ /**
65
+ * Finishes every upload run an earlier process (or an aborted call in this one) left unfinished, from its journal in
66
+ * the state directory, and returns its files' results. Runs a live process is working on are left alone.
67
+ */
68
+ export declare function resumeUploads(storage: StorageService, opts?: {
69
+ onProgress?: (done: number, total: number) => void;
70
+ signal?: AbortSignal;
71
+ }): Promise<UploadResult[]>;
72
+ /**
73
+ * The upload runs kept in the state directory: how many files each has saved, failed and still pending, whether a
74
+ * live process is working on it, and whether it has expired (untouched for 7 days: its files were not uploaded).
75
+ */
76
+ export declare function listUploadRuns(storage: StorageService): Promise<UploadRun[]>;
77
+ /**
78
+ * Removes the local state of runs untouched for longer than olderThan ms (default 7 days) that no live process is
79
+ * working on, cancelling their open uploads, with a warning for each (their pending files are not uploaded): never
80
+ * done silently. Finished runs remove their own state.
81
+ */
82
+ export declare function cleanUploads(storage: StorageService, opts?: {
83
+ olderThan?: number;
84
+ signal?: AbortSignal;
85
+ }): Promise<UploadRun[]>;
86
+ //# sourceMappingURL=uploads.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"uploads.d.ts","sourceRoot":"","sources":["../../../src/node/uploads.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAEpD,OAAO,EAAiB,KAAK,aAAa,EAAE,KAAK,OAAO,EAAE,KAAK,QAAQ,EAAE,KAAK,OAAO,EAAE,KAAK,QAAQ,EAAE,KAAK,YAAY,EAAE,KAAK,SAAS,EAAE,MAAM,sBAAsB,CAAC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CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC,CAE5E;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,cAAc,EAAE,IAAI,GAAE;IAAE,SAAS,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,WAAW,CAAA;CAAO,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC,CAEnI"}
@@ -1,5 +1,7 @@
1
1
  import type { StorageObject, StorageService } from './storage.js';
2
2
  import type { DownloadOptions, UploadOptions, UploadSource } from './transfer.js';
3
+ export { downloadFiles, downloadPrefix, type DownloadFilesOptions } from './node/downloads.js';
4
+ export { PART_SUFFIX, UnsafePathError, type DownloadResult, type DownloadStatus } from './direct/downloads-plan.js';
3
5
  /** A MIME type guessed from a file name, or undefined. */
4
6
  export declare function contentTypeOf(path: string): string | undefined;
5
7
  /** An UploadSource reading the file at path. Close it when done. */
@@ -15,6 +17,6 @@ export declare function uploadFile(storage: StorageService, bucket: string, key:
15
17
  * their SHA-256 first.
16
18
  */
17
19
  export declare function downloadFile(storage: StorageService, bucket: string, key: string, path: string, opts?: DownloadOptions): Promise<StorageObject>;
18
- /** Whether a local file holds the object's bytes: same size, and the same ETag computed with partBytes (default: the SDK's part size). */
19
- export declare function sameAsObject(path: string, obj: StorageObject, partBytes?: number): Promise<boolean>;
20
+ export { cleanUploads, listUploadRuns, resumeUploads, uploadFiles, type UploadFilesOptions } from './node/uploads.js';
21
+ export type { UploadResult, UploadRun } from './direct/uploads.js';
20
22
  //# sourceMappingURL=node.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../../src/node.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAClE,OAAO,KAAK,EAAE,eAAe,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAYlF,0DAA0D;AAC1D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