@foldrun/core 19.1.0 → 19.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/data-import.d.ts +156 -0
- package/dist/src/data-import.js +670 -0
- package/dist/src/storage.d.ts +12 -1
- package/dist/src/storage.js +50 -16
- package/package.json +1 -1
- package/src/data-import.ts +764 -0
- package/src/storage.ts +45 -15
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import { type Deps } from "./publish.ts";
|
|
2
|
+
export declare const IMPORT_BY = "import:data-folder";
|
|
3
|
+
/** Files at or under this are read whole for the publish; a larger one is
|
|
4
|
+
* streamed from disk. */
|
|
5
|
+
export declare const LARGE_FILE_BYTES: number;
|
|
6
|
+
export interface SourceFile {
|
|
7
|
+
/** The manifest path (a conflict copy's path differs from `from`). */
|
|
8
|
+
path: string;
|
|
9
|
+
abs: string;
|
|
10
|
+
sha: string;
|
|
11
|
+
size: number;
|
|
12
|
+
mode: number;
|
|
13
|
+
side: "authored" | "state";
|
|
14
|
+
/** Set when this file is kept under a conflict-copy name; the path it wanted. */
|
|
15
|
+
from?: string;
|
|
16
|
+
}
|
|
17
|
+
export interface Unmapped {
|
|
18
|
+
path: string;
|
|
19
|
+
reason: string;
|
|
20
|
+
/** Files inside (a folder), when counted. */
|
|
21
|
+
files?: number;
|
|
22
|
+
bytes?: number;
|
|
23
|
+
}
|
|
24
|
+
export interface WorkspaceScan {
|
|
25
|
+
tenant: string;
|
|
26
|
+
workspace: string;
|
|
27
|
+
dir: string;
|
|
28
|
+
files: SourceFile[];
|
|
29
|
+
bytes: number;
|
|
30
|
+
unmapped: Unmapped[];
|
|
31
|
+
conflicts: {
|
|
32
|
+
path: string;
|
|
33
|
+
keptAs: string;
|
|
34
|
+
}[];
|
|
35
|
+
/** What runs/ holds on the volume, counted and never read: record files
|
|
36
|
+
* (FOL-152 moved those to rows) and output folders (runs/<id>/). */
|
|
37
|
+
runs: {
|
|
38
|
+
recordFiles: number;
|
|
39
|
+
outputFolders: number;
|
|
40
|
+
outputFiles: number;
|
|
41
|
+
outputBytes: number;
|
|
42
|
+
};
|
|
43
|
+
/** Set when the workspace cannot be imported at all (reason). */
|
|
44
|
+
error?: string;
|
|
45
|
+
}
|
|
46
|
+
export interface TenantScan {
|
|
47
|
+
tenant: string;
|
|
48
|
+
workspaces: WorkspaceScan[];
|
|
49
|
+
/** Account-level folders and files nothing maps here (library/, .history/, storage/, secrets …). */
|
|
50
|
+
unmapped: Unmapped[];
|
|
51
|
+
}
|
|
52
|
+
export interface SourceScan {
|
|
53
|
+
source: string;
|
|
54
|
+
tenants: TenantScan[];
|
|
55
|
+
scannedAt: string;
|
|
56
|
+
}
|
|
57
|
+
export interface ScanOptions {
|
|
58
|
+
source: string;
|
|
59
|
+
/** Only these accounts / "account/workspace" pairs. */
|
|
60
|
+
tenants?: string[];
|
|
61
|
+
workspaces?: string[];
|
|
62
|
+
}
|
|
63
|
+
export declare function hashFile(abs: string): Promise<string>;
|
|
64
|
+
/**
|
|
65
|
+
* Two names that differ only by case cannot share a manifest. The first in
|
|
66
|
+
* byte order keeps its name; each later one is kept as a conflict copy beside
|
|
67
|
+
* it (deterministic, so a rerun names the same file). `rels` must be sorted.
|
|
68
|
+
* Pure, because a case-insensitive disk (a Mac) cannot hold the pair to test
|
|
69
|
+
* the scanner with.
|
|
70
|
+
*/
|
|
71
|
+
export declare function placeCaseVariants(rels: string[], seed: string): {
|
|
72
|
+
rel: string;
|
|
73
|
+
from?: string;
|
|
74
|
+
}[];
|
|
75
|
+
export declare function scanSource(opts: ScanOptions): Promise<SourceScan>;
|
|
76
|
+
export interface ImportOptions {
|
|
77
|
+
deps: Deps;
|
|
78
|
+
/** Delete head paths the folder does not have. Default off: an import never
|
|
79
|
+
* removes anything from the destination. */
|
|
80
|
+
mirror?: boolean;
|
|
81
|
+
/** Import a workspace whose history has revisions the importer did not make. */
|
|
82
|
+
force?: boolean;
|
|
83
|
+
by?: string;
|
|
84
|
+
}
|
|
85
|
+
export type WorkspaceStatus = "imported" | "unchanged" | "skipped" | "failed" | "empty";
|
|
86
|
+
export interface WorkspaceResult {
|
|
87
|
+
tenant: string;
|
|
88
|
+
workspace: string;
|
|
89
|
+
status: WorkspaceStatus;
|
|
90
|
+
reason?: string;
|
|
91
|
+
revisions: string[];
|
|
92
|
+
conflictsKept: number;
|
|
93
|
+
filesPublished: number;
|
|
94
|
+
/** Files streamed from disk (over LARGE_FILE_BYTES) rather than read whole. */
|
|
95
|
+
filesStreamed: number;
|
|
96
|
+
}
|
|
97
|
+
export interface ImportReport {
|
|
98
|
+
startedAt: string;
|
|
99
|
+
finishedAt: string;
|
|
100
|
+
results: WorkspaceResult[];
|
|
101
|
+
}
|
|
102
|
+
export declare function importWorkspace(scan: WorkspaceScan, opts: ImportOptions): Promise<WorkspaceResult>;
|
|
103
|
+
export declare function runImport(scan: SourceScan, opts: ImportOptions): Promise<ImportReport>;
|
|
104
|
+
export interface PlanWorkspace {
|
|
105
|
+
tenant: string;
|
|
106
|
+
workspace: string;
|
|
107
|
+
files: number;
|
|
108
|
+
bytes: number;
|
|
109
|
+
authoredFiles: number;
|
|
110
|
+
stateFiles: number;
|
|
111
|
+
revisionsToMake: number | "unknown";
|
|
112
|
+
alreadyThere: "yes" | "partly" | "no" | "unknown";
|
|
113
|
+
note?: string;
|
|
114
|
+
}
|
|
115
|
+
/** What an import would do, per workspace. Reads the destination's heads when
|
|
116
|
+
* given a Deps (never writes); without one, "unknown". */
|
|
117
|
+
export declare function planImport(scan: SourceScan, deps?: Deps): Promise<PlanWorkspace[]>;
|
|
118
|
+
export declare function renderPlan(scan: SourceScan, plan: PlanWorkspace[]): string;
|
|
119
|
+
export interface VerifyWorkspace {
|
|
120
|
+
tenant: string;
|
|
121
|
+
workspace: string;
|
|
122
|
+
pass: boolean;
|
|
123
|
+
expected: number;
|
|
124
|
+
inHead: number;
|
|
125
|
+
matched: number;
|
|
126
|
+
missing: string[];
|
|
127
|
+
mismatched: string[];
|
|
128
|
+
extra: string[];
|
|
129
|
+
/** Absent from the store, the wrong size, or (deep) bytes that do not hash to their name. */
|
|
130
|
+
badBlobs: string[];
|
|
131
|
+
notes: string[];
|
|
132
|
+
}
|
|
133
|
+
export interface VerifyReport {
|
|
134
|
+
verifiedAt: string;
|
|
135
|
+
source: string;
|
|
136
|
+
pass: boolean;
|
|
137
|
+
workspaces: VerifyWorkspace[];
|
|
138
|
+
}
|
|
139
|
+
export interface VerifyOptions {
|
|
140
|
+
deps: Deps;
|
|
141
|
+
/** Stream every blob back and hash it (default: confirm each exists with the right size). */
|
|
142
|
+
deep?: boolean;
|
|
143
|
+
/** Paths in the head that the folder does not have are fine. */
|
|
144
|
+
allowExtra?: boolean;
|
|
145
|
+
}
|
|
146
|
+
/** Compare every workspace's heads with the folder, by path, sha256 and mode —
|
|
147
|
+
* the folder's hashes are taken again now, not trusted from the scan. */
|
|
148
|
+
export declare function verifyImport(scan: SourceScan, opts: VerifyOptions): Promise<VerifyReport>;
|
|
149
|
+
export declare function renderVerify(r: VerifyReport): string;
|
|
150
|
+
/** Write import-verify.json and import-verify.txt. Refuses a folder inside the
|
|
151
|
+
* source, compared by real paths, so a link cannot point the report into it
|
|
152
|
+
* (Codex review). */
|
|
153
|
+
export declare function writeVerifyReport(dir: string, source: string, r: VerifyReport): {
|
|
154
|
+
json: string;
|
|
155
|
+
txt: string;
|
|
156
|
+
};
|