swarm-deploy 0.3.0 → 0.4.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.
- package/CHANGELOG.md +69 -0
- package/README.md +89 -1257
- package/RELEASING.md +15 -8
- package/dist/cli.d.ts +7 -0
- package/dist/cli.js +127 -2
- package/dist/cli.js.map +1 -1
- package/dist/hooks-module.d.ts +3 -2
- package/dist/hooks-module.js +4 -4
- package/dist/hooks-module.js.map +1 -1
- package/dist/hooks.d.ts +73 -2
- package/dist/hooks.js +57 -3
- package/dist/hooks.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js.map +1 -1
- package/dist/server.d.ts +58 -8
- package/dist/server.js +287 -57
- package/dist/server.js.map +1 -1
- package/dist/storage/commit-store.d.ts +6 -0
- package/dist/storage/commit-store.js +65 -3
- package/dist/storage/commit-store.js.map +1 -1
- package/dist/storage/layout.d.ts +29 -0
- package/dist/storage/layout.js +53 -4
- package/dist/storage/layout.js.map +1 -1
- package/dist/storage/reset.d.ts +95 -0
- package/dist/storage/reset.js +667 -0
- package/dist/storage/reset.js.map +1 -0
- package/dist/storage/tree-fs.d.ts +22 -1
- package/dist/storage/tree-fs.js +153 -1
- package/dist/storage/tree-fs.js.map +1 -1
- package/dist/storage/types.d.ts +7 -0
- package/package.json +1 -1
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import type { StorageAdapter } from './types.js';
|
|
2
|
+
/** Every private metadata directory a reset archives, in archive order. */
|
|
3
|
+
export declare const METADATA_DIRECTORIES: readonly ['staging', 'sessions', 'commits', 'journals', 'publications', 'links', 'trash'];
|
|
4
|
+
export type MetadataDirectoryName = (typeof METADATA_DIRECTORIES)[number];
|
|
5
|
+
export declare const ARCHIVE_DIRECTORY_NAME = "archive";
|
|
6
|
+
export declare const ARCHIVE_MARKER_NAME = "reset.json";
|
|
7
|
+
/** Verbatim copy of a version 1 marker, kept when a retry upgrades it to the bounded format. */
|
|
8
|
+
export declare const ARCHIVE_LEGACY_MARKER_NAME = "reset.v1.json";
|
|
9
|
+
export interface StorageResetOptions {
|
|
10
|
+
storageDir: string;
|
|
11
|
+
/** Archive the metadata. Without it the reset is a read-only preview. */
|
|
12
|
+
apply?: boolean;
|
|
13
|
+
/** Milliseconds to keep polling a live lock before failing closed. */
|
|
14
|
+
wait?: number;
|
|
15
|
+
storage?: StorageAdapter;
|
|
16
|
+
isProcessAlive?: (pid: number) => boolean;
|
|
17
|
+
clock?: {
|
|
18
|
+
now(): number;
|
|
19
|
+
};
|
|
20
|
+
pid?: number;
|
|
21
|
+
pollInterval?: number;
|
|
22
|
+
sleep?: (ms: number) => Promise<void>;
|
|
23
|
+
}
|
|
24
|
+
export type ResetLockState = {
|
|
25
|
+
status: 'free';
|
|
26
|
+
} | {
|
|
27
|
+
status: 'held';
|
|
28
|
+
pid: number;
|
|
29
|
+
ageMs: number;
|
|
30
|
+
} | {
|
|
31
|
+
status: 'stale';
|
|
32
|
+
pid: number;
|
|
33
|
+
ageMs: number;
|
|
34
|
+
} | {
|
|
35
|
+
status: 'malformed';
|
|
36
|
+
} | {
|
|
37
|
+
status: 'unsafe';
|
|
38
|
+
};
|
|
39
|
+
/** What an archive physically holds. Lock residue is counted; its names stay in `locks/`. */
|
|
40
|
+
export interface ArchiveHoldings {
|
|
41
|
+
directories: string[];
|
|
42
|
+
lockEntries: number;
|
|
43
|
+
}
|
|
44
|
+
export interface ArchiveSummary {
|
|
45
|
+
name: string;
|
|
46
|
+
path: string;
|
|
47
|
+
/** What the marker claims; an `in-progress` marker can lag the archive after a hard stop. */
|
|
48
|
+
status: 'completed' | 'in-progress' | 'unknown';
|
|
49
|
+
/** What the archive physically holds, read from the filesystem rather than the marker. */
|
|
50
|
+
held: ArchiveHoldings;
|
|
51
|
+
}
|
|
52
|
+
export interface StorageResetReport {
|
|
53
|
+
root: string;
|
|
54
|
+
applied: boolean;
|
|
55
|
+
lock: ResetLockState;
|
|
56
|
+
/** Entry counts per private metadata directory before the reset. */
|
|
57
|
+
metadata: Record<MetadataDirectoryName, number>;
|
|
58
|
+
commits: {
|
|
59
|
+
records: number;
|
|
60
|
+
missingPayloads: string[];
|
|
61
|
+
invalid: number;
|
|
62
|
+
};
|
|
63
|
+
links: {
|
|
64
|
+
records: number;
|
|
65
|
+
invalid: number;
|
|
66
|
+
};
|
|
67
|
+
obsoleteLocks: number;
|
|
68
|
+
/** Entries in the internal directory the reset does not recognise and leaves alone. */
|
|
69
|
+
unknownInternal: string[];
|
|
70
|
+
archives: ArchiveSummary[];
|
|
71
|
+
/** Visible root entries the reset never touches; they stay after the reset. */
|
|
72
|
+
remaining: {
|
|
73
|
+
payloads: string[];
|
|
74
|
+
symlinks: string[];
|
|
75
|
+
other: string[];
|
|
76
|
+
};
|
|
77
|
+
/** True only when nothing visible remains, so the next server really starts empty. */
|
|
78
|
+
freshStart: boolean;
|
|
79
|
+
resetPending: boolean;
|
|
80
|
+
/** The archive an interrupted reset left pending, which the next apply resumes. */
|
|
81
|
+
pendingArchive: string | null;
|
|
82
|
+
/** The archive this run created or resumed, when applied. */
|
|
83
|
+
archive: string | null;
|
|
84
|
+
/** What a resumed archive already held before this run; null when a new archive was made. */
|
|
85
|
+
resumed: ArchiveHoldings | null;
|
|
86
|
+
}
|
|
87
|
+
/** Read-only inspection of a storage root: never creates, moves, or locks anything. */
|
|
88
|
+
export declare function inspectStorageReset(options: StorageResetOptions): Promise<StorageResetReport>;
|
|
89
|
+
/**
|
|
90
|
+
* Archives every private metadata directory of a storage root into
|
|
91
|
+
* `.swarm-deploy/archive/<reset-stamp>/` and recreates them empty, under the
|
|
92
|
+
* storage lock. Visible payloads and symlinks in the root are never touched,
|
|
93
|
+
* and nothing is deleted: the archive is restorable by moving it back.
|
|
94
|
+
*/
|
|
95
|
+
export declare function resetStorage(options: StorageResetOptions): Promise<StorageResetReport>;
|