swarm-deploy 0.0.0 → 0.2.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/CHANGELOG.md +76 -0
- package/LICENSE.md +201 -0
- package/NOTICE.md +13 -0
- package/README.md +1283 -0
- package/RELEASING.md +71 -0
- package/SECURITY.md +40 -0
- package/dist/abort.d.ts +16 -0
- package/dist/abort.js +52 -0
- package/dist/abort.js.map +1 -0
- package/dist/allowlist.d.ts +2 -0
- package/dist/allowlist.js +21 -0
- package/dist/allowlist.js.map +1 -0
- package/dist/bin/swarm-deploy.d.ts +2 -0
- package/dist/bin/swarm-deploy.js +41 -0
- package/dist/bin/swarm-deploy.js.map +1 -0
- package/dist/cli.d.ts +27 -0
- package/dist/cli.js +751 -0
- package/dist/cli.js.map +1 -0
- package/dist/client.d.ts +111 -0
- package/dist/client.js +276 -0
- package/dist/client.js.map +1 -0
- package/dist/direct-dht.d.ts +81 -0
- package/dist/direct-dht.js +254 -0
- package/dist/direct-dht.js.map +1 -0
- package/dist/error-code.d.ts +15 -0
- package/dist/error-code.js +30 -0
- package/dist/error-code.js.map +1 -0
- package/dist/errors.d.ts +31 -0
- package/dist/errors.js +37 -0
- package/dist/errors.js.map +1 -0
- package/dist/events-node.d.ts +2 -0
- package/dist/events-node.js +7 -0
- package/dist/events-node.js.map +1 -0
- package/dist/files.d.ts +32 -0
- package/dist/files.js +85 -0
- package/dist/files.js.map +1 -0
- package/dist/fs-node.d.ts +2 -0
- package/dist/fs-node.js +7 -0
- package/dist/fs-node.js.map +1 -0
- package/dist/hooks-module.d.ts +9 -0
- package/dist/hooks-module.js +118 -0
- package/dist/hooks-module.js.map +1 -0
- package/dist/hooks.d.ts +69 -0
- package/dist/hooks.js +88 -0
- package/dist/hooks.js.map +1 -0
- package/dist/identity.d.ts +7 -0
- package/dist/identity.js +50 -0
- package/dist/identity.js.map +1 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +21 -0
- package/dist/index.js.map +1 -0
- package/dist/os-node.d.ts +2 -0
- package/dist/os-node.js +7 -0
- package/dist/os-node.js.map +1 -0
- package/dist/path-node.d.ts +2 -0
- package/dist/path-node.js +7 -0
- package/dist/path-node.js.map +1 -0
- package/dist/process-node.d.ts +2 -0
- package/dist/process-node.js +7 -0
- package/dist/process-node.js.map +1 -0
- package/dist/release.d.ts +26 -0
- package/dist/release.js +419 -0
- package/dist/release.js.map +1 -0
- package/dist/server.d.ts +239 -0
- package/dist/server.js +928 -0
- package/dist/server.js.map +1 -0
- package/dist/storage/atomic-file.d.ts +15 -0
- package/dist/storage/atomic-file.js +172 -0
- package/dist/storage/atomic-file.js.map +1 -0
- package/dist/storage/commit-journal.d.ts +120 -0
- package/dist/storage/commit-journal.js +417 -0
- package/dist/storage/commit-journal.js.map +1 -0
- package/dist/storage/commit-store.d.ts +307 -0
- package/dist/storage/commit-store.js +1691 -0
- package/dist/storage/commit-store.js.map +1 -0
- package/dist/storage/layout.d.ts +16 -0
- package/dist/storage/layout.js +409 -0
- package/dist/storage/layout.js.map +1 -0
- package/dist/storage/link-store.d.ts +70 -0
- package/dist/storage/link-store.js +363 -0
- package/dist/storage/link-store.js.map +1 -0
- package/dist/storage/recovery.d.ts +100 -0
- package/dist/storage/recovery.js +260 -0
- package/dist/storage/recovery.js.map +1 -0
- package/dist/storage/retention.d.ts +183 -0
- package/dist/storage/retention.js +619 -0
- package/dist/storage/retention.js.map +1 -0
- package/dist/storage/root-coordinator.d.ts +7 -0
- package/dist/storage/root-coordinator.js +27 -0
- package/dist/storage/root-coordinator.js.map +1 -0
- package/dist/storage/session-store.d.ts +2 -0
- package/dist/storage/session-store.js +7 -0
- package/dist/storage/session-store.js.map +1 -0
- package/dist/storage/tar-session-store.d.ts +147 -0
- package/dist/storage/tar-session-store.js +1044 -0
- package/dist/storage/tar-session-store.js.map +1 -0
- package/dist/storage/tree-fs.d.ts +44 -0
- package/dist/storage/tree-fs.js +580 -0
- package/dist/storage/tree-fs.js.map +1 -0
- package/dist/storage/tree-staging.d.ts +9 -0
- package/dist/storage/tree-staging.js +64 -0
- package/dist/storage/tree-staging.js.map +1 -0
- package/dist/storage/types.d.ts +77 -0
- package/dist/storage/types.js +3 -0
- package/dist/storage/types.js.map +1 -0
- package/dist/symlinks.d.ts +36 -0
- package/dist/symlinks.js +128 -0
- package/dist/symlinks.js.map +1 -0
- package/dist/tar-protocol/controls.d.ts +73 -0
- package/dist/tar-protocol/controls.js +291 -0
- package/dist/tar-protocol/controls.js.map +1 -0
- package/dist/tar-protocol/direct-wire.d.ts +43 -0
- package/dist/tar-protocol/direct-wire.js +194 -0
- package/dist/tar-protocol/direct-wire.js.map +1 -0
- package/dist/tar-protocol/extract.d.ts +18 -0
- package/dist/tar-protocol/extract.js +124 -0
- package/dist/tar-protocol/extract.js.map +1 -0
- package/dist/tar-protocol/hash.d.ts +10 -0
- package/dist/tar-protocol/hash.js +44 -0
- package/dist/tar-protocol/hash.js.map +1 -0
- package/dist/tar-protocol/lifecycle.d.ts +13 -0
- package/dist/tar-protocol/lifecycle.js +90 -0
- package/dist/tar-protocol/lifecycle.js.map +1 -0
- package/dist/tar-protocol/manifest.d.ts +58 -0
- package/dist/tar-protocol/manifest.js +312 -0
- package/dist/tar-protocol/manifest.js.map +1 -0
- package/dist/tar-protocol/tree-extract.d.ts +37 -0
- package/dist/tar-protocol/tree-extract.js +240 -0
- package/dist/tar-protocol/tree-extract.js.map +1 -0
- package/dist/tar-protocol/tree-manifest.d.ts +45 -0
- package/dist/tar-protocol/tree-manifest.js +277 -0
- package/dist/tar-protocol/tree-manifest.js.map +1 -0
- package/dist/tar-protocol/tree-path.d.ts +15 -0
- package/dist/tar-protocol/tree-path.js +68 -0
- package/dist/tar-protocol/tree-path.js.map +1 -0
- package/dist/tar-protocol/tree.d.ts +68 -0
- package/dist/tar-protocol/tree.js +269 -0
- package/dist/tar-protocol/tree.js.map +1 -0
- package/dist/tar-protocol/ustar.d.ts +36 -0
- package/dist/tar-protocol/ustar.js +167 -0
- package/dist/tar-protocol/ustar.js.map +1 -0
- package/dist/types.d.ts +61 -0
- package/dist/types.js +3 -0
- package/dist/types.js.map +1 -0
- package/dist/validation.d.ts +4 -0
- package/dist/validation.js +26 -0
- package/dist/validation.js.map +1 -0
- package/package.json +103 -1
|
@@ -0,0 +1,307 @@
|
|
|
1
|
+
import type { ReleaseCoordinates } from '../release.js';
|
|
2
|
+
import { CorruptJournalError, COMMIT_VERSION, MAX_COMMIT_METADATA_BYTES } from './commit-journal.js';
|
|
3
|
+
import type { AnyCommitJournal, CommitJournal, CommitRecord, CommitRelease, FileIdentity, DirectoryCommitJournal, DirectoryPhase, ReplacementJournal, ReplacementPhase } from './commit-journal.js';
|
|
4
|
+
import { type TreePathState } from './tree-fs.js';
|
|
5
|
+
import type { StorageAdapter, StorageLayout, StorageStat } from './types.js';
|
|
6
|
+
interface AbortSignalLike {
|
|
7
|
+
aborted: boolean;
|
|
8
|
+
}
|
|
9
|
+
interface CommitSession {
|
|
10
|
+
id: string;
|
|
11
|
+
transferId: Uint8Array;
|
|
12
|
+
ownerKey: Uint8Array;
|
|
13
|
+
kind?: 'file' | 'directory';
|
|
14
|
+
name: string;
|
|
15
|
+
sourceParent?: string;
|
|
16
|
+
size: number;
|
|
17
|
+
digest: Uint8Array;
|
|
18
|
+
entryCount?: number;
|
|
19
|
+
/** Direct-TAR sessions carry these immutable archive fields. */
|
|
20
|
+
tarSize: number;
|
|
21
|
+
tarDigest: Uint8Array;
|
|
22
|
+
state: string;
|
|
23
|
+
}
|
|
24
|
+
interface CommitOffer {
|
|
25
|
+
name: string;
|
|
26
|
+
kind?: 'file' | 'directory';
|
|
27
|
+
size: number;
|
|
28
|
+
digest: Uint8Array;
|
|
29
|
+
entryCount?: number;
|
|
30
|
+
transferId: Uint8Array;
|
|
31
|
+
/** Matched release identity; transfer and release must agree for an idempotent result. */
|
|
32
|
+
release?: ReleaseCoordinates | null;
|
|
33
|
+
}
|
|
34
|
+
interface RetentionManager {
|
|
35
|
+
run(options?: {
|
|
36
|
+
trigger?: string;
|
|
37
|
+
}): Promise<unknown>;
|
|
38
|
+
afterCommit(): Promise<unknown>;
|
|
39
|
+
_runUnlocked(options: {
|
|
40
|
+
incomingBytes: number;
|
|
41
|
+
trigger: 'commit';
|
|
42
|
+
}): Promise<unknown>;
|
|
43
|
+
_afterCommitUnlocked(): Promise<unknown>;
|
|
44
|
+
}
|
|
45
|
+
interface SessionStore {
|
|
46
|
+
readVerified(transferId: Uint8Array): Promise<CommitSession>;
|
|
47
|
+
sessions?: Map<string, CommitSession>;
|
|
48
|
+
}
|
|
49
|
+
interface Logger {
|
|
50
|
+
warn?: (message: string, details: Record<string, unknown>) => void;
|
|
51
|
+
}
|
|
52
|
+
interface CommitStoreOptions {
|
|
53
|
+
layout: StorageLayout;
|
|
54
|
+
clock?: {
|
|
55
|
+
now(): number;
|
|
56
|
+
};
|
|
57
|
+
storage?: StorageAdapter;
|
|
58
|
+
logger?: Logger | null;
|
|
59
|
+
}
|
|
60
|
+
interface ReplacePolicy {
|
|
61
|
+
replaceNames?: Iterable<string>;
|
|
62
|
+
}
|
|
63
|
+
/** The visible state of one top-level path, without following symlinks. */
|
|
64
|
+
interface RootPathState {
|
|
65
|
+
present: boolean;
|
|
66
|
+
/** Set only for a regular file; an unmanaged non-regular path leaves it null. */
|
|
67
|
+
stat: StorageStat | null;
|
|
68
|
+
}
|
|
69
|
+
type ReplacementPlan = {
|
|
70
|
+
mode: 'create';
|
|
71
|
+
} | {
|
|
72
|
+
mode: 'idempotent';
|
|
73
|
+
record: CommitRecord;
|
|
74
|
+
} | {
|
|
75
|
+
mode: 'replace';
|
|
76
|
+
oldRecord: CommitRecord;
|
|
77
|
+
finalIdentity: FileIdentity;
|
|
78
|
+
};
|
|
79
|
+
declare class CommitStore {
|
|
80
|
+
layout: StorageLayout;
|
|
81
|
+
clock: {
|
|
82
|
+
now(): number;
|
|
83
|
+
};
|
|
84
|
+
storage: StorageAdapter;
|
|
85
|
+
logger: Logger | null;
|
|
86
|
+
journalAttempts: Map<string, string>;
|
|
87
|
+
constructor({ layout, clock, storage, logger }: CommitStoreOptions);
|
|
88
|
+
_stagingPath(id: string): string;
|
|
89
|
+
_tarStagingPath(id: string): string;
|
|
90
|
+
_treeStagingPath(id: string): string;
|
|
91
|
+
_trashTreePath(id: string): string;
|
|
92
|
+
/** The visible state of one top-level directory path, without following links. */
|
|
93
|
+
_rootTreeState(name: string): Promise<TreePathState>;
|
|
94
|
+
_sessionPath(id: string): string;
|
|
95
|
+
_journalPath(id: string): string;
|
|
96
|
+
_recordPath(id: string): string;
|
|
97
|
+
_finalPath(name: string): string;
|
|
98
|
+
_publicationPath(name: string): string;
|
|
99
|
+
_assertLayout(): Promise<void>;
|
|
100
|
+
/** Inspects one top-level path without following or trusting symlinks. */
|
|
101
|
+
_rootPathState(name: string): Promise<RootPathState>;
|
|
102
|
+
_syncRoot(): Promise<void>;
|
|
103
|
+
_safeFileOrAbsent(filePath: string, directory: string): Promise<StorageStat | null>;
|
|
104
|
+
_readRecordOrAbsent(recordPath: string): Promise<CommitRecord | null>;
|
|
105
|
+
_writeRecord(record: CommitRecord): Promise<boolean>;
|
|
106
|
+
/** Persists a sidecar transition over its own previous durable content. */
|
|
107
|
+
_rewriteRecord(record: CommitRecord): Promise<void>;
|
|
108
|
+
_removeFile(filePath: string, directory: string): Promise<boolean>;
|
|
109
|
+
_removeManagedFinalOrAbsent(record: CommitRecord): Promise<{
|
|
110
|
+
removed: boolean;
|
|
111
|
+
preservedPath: boolean;
|
|
112
|
+
}>;
|
|
113
|
+
_linkJournal(id: string, journal: AnyCommitJournal, attempt: string): Promise<void>;
|
|
114
|
+
_writeJournal(record: CommitRecord, sourceStagingIdentity: FileIdentity): Promise<string>;
|
|
115
|
+
/** A replacement or directory commit always starts a fresh attempt; leftovers belong to recovery. */
|
|
116
|
+
_writeFreshJournal(journal: ReplacementJournal | DirectoryCommitJournal): Promise<void>;
|
|
117
|
+
/**
|
|
118
|
+
* Records the boundary an attempt has already passed. The observable
|
|
119
|
+
* filesystem state stays authoritative during recovery; the phase is the
|
|
120
|
+
* durable intent trail the journal must carry.
|
|
121
|
+
*/
|
|
122
|
+
_setReplacementPhase(journal: ReplacementJournal, phase: ReplacementPhase): Promise<ReplacementJournal>;
|
|
123
|
+
retireCorruptJournal(id: string): Promise<boolean>;
|
|
124
|
+
retireCorruptAttempt(id: string): Promise<{
|
|
125
|
+
retired: boolean;
|
|
126
|
+
removedStaging: boolean;
|
|
127
|
+
}>;
|
|
128
|
+
_discardJournal(id: string, expectedAttemptId: string): Promise<boolean>;
|
|
129
|
+
_markAttemptAborting(id: string, expectedAttemptId: string): Promise<AnyCommitJournal>;
|
|
130
|
+
_linkStaging(stagingPath: string, finalPath: string, expectedIdentity: FileIdentity, signal: AbortSignalLike | null): Promise<void>;
|
|
131
|
+
_removeAbortedPublication(record: CommitRecord, expectedIdentity: FileIdentity): Promise<void>;
|
|
132
|
+
_reportCleanupPending(record: CommitRecord, err: unknown): void;
|
|
133
|
+
_abortAttempt(record: CommitRecord, expectedIdentity: FileIdentity, attemptId: string, aborted: unknown): Promise<never>;
|
|
134
|
+
_removeOwnedFile(filePath: string, directory: string, identity: FileIdentity): Promise<boolean>;
|
|
135
|
+
_matchesRecord(filePath: string, directory: string, record: CommitRecord, syncFirst?: boolean): Promise<boolean>;
|
|
136
|
+
_recordFromSession(session: CommitSession, release?: CommitRelease): CommitRecord;
|
|
137
|
+
inspect(name: string, offer: CommitOffer, { replaceNames }?: ReplacePolicy): Promise<{
|
|
138
|
+
status: 'AVAILABLE';
|
|
139
|
+
} | {
|
|
140
|
+
status: 'ALREADY_COMMITTED';
|
|
141
|
+
record: CommitRecord;
|
|
142
|
+
} | {
|
|
143
|
+
status: 'REPLACEABLE';
|
|
144
|
+
record: CommitRecord;
|
|
145
|
+
} | {
|
|
146
|
+
status: 'FILE_EXISTS';
|
|
147
|
+
}>;
|
|
148
|
+
_inspect(name: string, offer: CommitOffer, mutable: Set<string>, release: CommitRelease | undefined): Promise<{
|
|
149
|
+
status: 'AVAILABLE';
|
|
150
|
+
} | {
|
|
151
|
+
status: 'ALREADY_COMMITTED';
|
|
152
|
+
record: CommitRecord;
|
|
153
|
+
} | {
|
|
154
|
+
status: 'REPLACEABLE';
|
|
155
|
+
record: CommitRecord;
|
|
156
|
+
} | {
|
|
157
|
+
status: 'FILE_EXISTS';
|
|
158
|
+
}>;
|
|
159
|
+
_inspectDirectory(name: string, offer: CommitOffer): Promise<{
|
|
160
|
+
status: 'AVAILABLE';
|
|
161
|
+
} | {
|
|
162
|
+
status: 'ALREADY_COMMITTED';
|
|
163
|
+
record: CommitRecord;
|
|
164
|
+
} | {
|
|
165
|
+
status: 'FILE_EXISTS';
|
|
166
|
+
}>;
|
|
167
|
+
/** The managed record whose verified content currently owns a visible name. */
|
|
168
|
+
_managedCurrent(name: string): Promise<{
|
|
169
|
+
record: CommitRecord;
|
|
170
|
+
identity: FileIdentity;
|
|
171
|
+
} | null>;
|
|
172
|
+
_assertSessionMatchesRecord(session: CommitSession, record: CommitRecord, message: string): void;
|
|
173
|
+
_validateAttemptLeftovers(id: string, journal: CommitJournal, sessionStore: SessionStore): Promise<{
|
|
174
|
+
sessionFile: StorageStat | null;
|
|
175
|
+
staging: StorageStat | null;
|
|
176
|
+
}>;
|
|
177
|
+
commit(session: CommitSession, { retentionManager, signal, replaceNames, release, deferPostCommitRetention }?: {
|
|
178
|
+
retentionManager?: RetentionManager | null;
|
|
179
|
+
signal?: AbortSignalLike | null;
|
|
180
|
+
replaceNames?: Iterable<string>;
|
|
181
|
+
release?: ReleaseCoordinates | null;
|
|
182
|
+
/**
|
|
183
|
+
* Skips the post-commit retention pass so the caller can run it later
|
|
184
|
+
* (via the retention manager) once work that needs the committed files
|
|
185
|
+
* has finished. Pre-commit quota and age checks still run.
|
|
186
|
+
*/
|
|
187
|
+
deferPostCommitRetention?: boolean;
|
|
188
|
+
}): Promise<CommitRecord>;
|
|
189
|
+
_commit(session: CommitSession, retentionManager: RetentionManager | null, signal: AbortSignalLike | null, mutable?: Set<string>, release?: CommitRelease, deferPostCommitRetention?: boolean): Promise<CommitRecord>;
|
|
190
|
+
/**
|
|
191
|
+
* Publishes one verified staging tree by rename. Directory artifacts are
|
|
192
|
+
* create-only: a configured mutable name, an occupied destination, and a
|
|
193
|
+
* kind change are all existing-name conflicts.
|
|
194
|
+
*/
|
|
195
|
+
_commitDirectory(record: CommitRecord, retentionManager: RetentionManager | null, signal: AbortSignalLike | null, mutable: Set<string>, deferPostCommitRetention?: boolean): Promise<CommitRecord>;
|
|
196
|
+
_setDirectoryPhase(journal: DirectoryCommitJournal, phase: DirectoryPhase): Promise<DirectoryCommitJournal>;
|
|
197
|
+
/** Returns a proven renamed tree to staging; a foreign destination is preserved. */
|
|
198
|
+
_rollbackDirectory(journal: DirectoryCommitJournal): Promise<void>;
|
|
199
|
+
/**
|
|
200
|
+
* Classifies a configured mutable name. Only an exact managed current record
|
|
201
|
+
* whose verified content owns the visible path may be replaced; every other
|
|
202
|
+
* occupied path is an existing-name conflict.
|
|
203
|
+
*/
|
|
204
|
+
_planReplacement(record: CommitRecord): Promise<ReplacementPlan>;
|
|
205
|
+
/**
|
|
206
|
+
* A repeated A→B→A sequence reuses a transfer ID that already owns a history
|
|
207
|
+
* artifact of identical content. The superseded duplicate is dropped inside
|
|
208
|
+
* the transaction so the returning content becomes the only copy.
|
|
209
|
+
*/
|
|
210
|
+
_dedupHistory(record: CommitRecord): Promise<{
|
|
211
|
+
name: string;
|
|
212
|
+
identity: FileIdentity | null;
|
|
213
|
+
} | null>;
|
|
214
|
+
_replace(record: CommitRecord, stagingIdentity: FileIdentity, plan: {
|
|
215
|
+
oldRecord: CommitRecord;
|
|
216
|
+
finalIdentity: FileIdentity;
|
|
217
|
+
}, retentionManager: RetentionManager | null, signal: AbortSignalLike | null, deferPostCommitRetention?: boolean): Promise<CommitRecord>;
|
|
218
|
+
/**
|
|
219
|
+
* Restores the exact pinned old inode at the mutable name and removes only
|
|
220
|
+
* transaction-owned history, publication, and sidecar paths. A foreign
|
|
221
|
+
* destination is never overwritten or removed.
|
|
222
|
+
*/
|
|
223
|
+
_rollbackReplacement(journal: ReplacementJournal): Promise<void>;
|
|
224
|
+
_readJournal(id: string): Promise<AnyCommitJournal | null>;
|
|
225
|
+
/** Every parsable v2 journal, used to explain transient duplicate names. */
|
|
226
|
+
_pendingReplacements(): Promise<ReplacementJournal[]>;
|
|
227
|
+
/**
|
|
228
|
+
* Finalizes or rolls back one v2 attempt. The durable new current sidecar is
|
|
229
|
+
* the linearization point: before it the old content is restored, after it
|
|
230
|
+
* the new content is preserved while history metadata and cleanup converge.
|
|
231
|
+
*/
|
|
232
|
+
_convergeReplacement(id: string, journal: ReplacementJournal, sessionStore: SessionStore | null, { forceAbort }?: {
|
|
233
|
+
forceAbort?: boolean;
|
|
234
|
+
}): Promise<{
|
|
235
|
+
status: 'COMMITTED' | 'ABORTED' | 'RESUMABLE';
|
|
236
|
+
record: CommitRecord;
|
|
237
|
+
}>;
|
|
238
|
+
/**
|
|
239
|
+
* Startup recovery for one v2 attempt. Revocation of a still-live session
|
|
240
|
+
* aborts the attempt first so the same rollback path converges.
|
|
241
|
+
*/
|
|
242
|
+
_recoverReplacementJournal(id: string, journal: ReplacementJournal, sessionStore: SessionStore, isAuthorized: ((ownerKey: Uint8Array) => boolean) | null): Promise<{
|
|
243
|
+
status: 'COMMITTED' | 'ABORTED' | 'RESUMABLE';
|
|
244
|
+
record: CommitRecord;
|
|
245
|
+
}>;
|
|
246
|
+
/** Writes or drops the history sidecar for an already linearized attempt. */
|
|
247
|
+
_repairHistorySidecar(journal: ReplacementJournal): Promise<void>;
|
|
248
|
+
_cleanupReplacementLeftovers(id: string, journal: ReplacementJournal, sessionStore: SessionStore | null): Promise<void>;
|
|
249
|
+
/** Proves the verified session and staging an aborted attempt must retain. */
|
|
250
|
+
/**
|
|
251
|
+
* Converges one directory attempt. The durable sidecar is the linearization
|
|
252
|
+
* point: before it a proven renamed tree returns to staging, after it the
|
|
253
|
+
* published tree is kept and only residue is removed. A destination that
|
|
254
|
+
* cannot be proven is preserved and fails closed.
|
|
255
|
+
*/
|
|
256
|
+
_recoverDirectoryJournal(id: string, journal: DirectoryCommitJournal, sessionStore: SessionStore, isAuthorized?: ((ownerKey: Uint8Array) => boolean) | null): Promise<{
|
|
257
|
+
status: 'COMMITTED' | 'RESUMABLE';
|
|
258
|
+
record: CommitRecord;
|
|
259
|
+
}>;
|
|
260
|
+
_assertReplacementRetryable(id: string, journal: ReplacementJournal, sessionStore: SessionStore | null): Promise<boolean>;
|
|
261
|
+
recoverJournal(id: string, sessionStore: SessionStore, { isAuthorized }?: {
|
|
262
|
+
isAuthorized?: ((ownerKey: Uint8Array) => boolean) | null;
|
|
263
|
+
}): Promise<{
|
|
264
|
+
status: 'MISSING' | 'FILE_EXISTS' | 'COMMITTED' | 'ABORTED' | 'RESUMABLE';
|
|
265
|
+
record?: CommitRecord;
|
|
266
|
+
}>;
|
|
267
|
+
_scanRecords(): Promise<CommitRecord[]>;
|
|
268
|
+
scrubRecords(): Promise<{
|
|
269
|
+
records: CommitRecord[];
|
|
270
|
+
deleted: number;
|
|
271
|
+
}>;
|
|
272
|
+
_resolveRecords(records: CommitRecord[]): Promise<CommitRecord[]>;
|
|
273
|
+
/**
|
|
274
|
+
* A replacement makes the old sidecar the history record after its new
|
|
275
|
+
* current sidecar is durable, so one name can briefly carry two records.
|
|
276
|
+
* Only a journal-owned duplicate is tolerated, reported at the history name
|
|
277
|
+
* that recovery will persist; anything else fails closed.
|
|
278
|
+
*/
|
|
279
|
+
list(): Promise<CommitRecord[]>;
|
|
280
|
+
/**
|
|
281
|
+
* Locates the durable record a caller is deleting. A pending replacement may
|
|
282
|
+
* still carry the mutable name on the sidecar the caller knows as history.
|
|
283
|
+
*/
|
|
284
|
+
_storedRecordFor(record: CommitRecord): Promise<CommitRecord | null>;
|
|
285
|
+
/**
|
|
286
|
+
* Removes proven private trash trees left by an interrupted deletion. Only a
|
|
287
|
+
* `<64-hex>.tree` entry is ours; anything else in the directory is left alone.
|
|
288
|
+
*/
|
|
289
|
+
sweepTrash(): Promise<number>;
|
|
290
|
+
/**
|
|
291
|
+
* Removes a managed directory by renaming it into the private trash first, so
|
|
292
|
+
* the visible name disappears atomically, and only then removing the sidecar
|
|
293
|
+
* and recursively deleting the trash tree.
|
|
294
|
+
*/
|
|
295
|
+
_removeManagedTree(record: CommitRecord): Promise<{
|
|
296
|
+
removed: boolean;
|
|
297
|
+
preservedPath: boolean;
|
|
298
|
+
}>;
|
|
299
|
+
delete(record: CommitRecord): Promise<boolean>;
|
|
300
|
+
purge(record: CommitRecord, { preservePath }?: {
|
|
301
|
+
preservePath?: boolean;
|
|
302
|
+
}): Promise<false | {
|
|
303
|
+
purged: true;
|
|
304
|
+
preservedPath: boolean;
|
|
305
|
+
}>;
|
|
306
|
+
}
|
|
307
|
+
export { CommitStore, CorruptJournalError, COMMIT_VERSION, MAX_COMMIT_METADATA_BYTES };
|