|
2 | 2 | // |
3 | 3 | // state/<org>/state.json resource name → Vapi UUID (committed) |
4 | 4 | // state/<org>/org.json the Vapi org this folder is pinned to (committed) |
| 5 | +// state/<org>/<record>.json what the engine records beside them (committed) |
5 | 6 | // state/<org>/local/baselines/ drift baselines, one file per UUID (this machine only) |
6 | 7 | // state/<org>/local/snapshots/ push snapshots for rollback (this machine only) |
7 | 8 | // state/commit-step.json a person's word that their commit step stages state/ (committed) |
@@ -184,6 +185,41 @@ export function orgPinFileRead(rootDir: string, org: string): string { |
184 | 185 | /** The org pin to write: the one that is read. */ |
185 | 186 | export const orgPinFileWrite = orgPinFileRead; |
186 | 187 |
|
| 188 | +/** The records the engine keeps beside an org's state file, by name. */ |
| 189 | +export const STATE_RECORDS = ["credential-providers"] as const; |
| 190 | +export type StateRecord = (typeof STATE_RECORDS)[number]; |
| 191 | + |
| 192 | +function recordPath(rootDir: string, org: string, name: StateRecord): string { |
| 193 | + return join(stateOrgDir(rootDir, org), `${name}.json`); |
| 194 | +} |
| 195 | + |
| 196 | +function recordLegacyPath( |
| 197 | + rootDir: string, |
| 198 | + org: string, |
| 199 | + name: StateRecord, |
| 200 | +): string { |
| 201 | + return join(rootDir, "resources", org, `.vapi-${name}.json`); |
| 202 | +} |
| 203 | + |
| 204 | +/** |
| 205 | + * A record the engine keeps beside the state file: where it is, else where |
| 206 | + * its first write goes. For an org in the old layout that is |
| 207 | + * resources/<org>/.vapi-<name>.json, beside the old org pin, which a commit |
| 208 | + * step from before state/ already stages with the folder. |
| 209 | + */ |
| 210 | +export function stateRecordPath( |
| 211 | + rootDir: string, |
| 212 | + org: string, |
| 213 | + name: StateRecord, |
| 214 | +): string { |
| 215 | + return fileInLayout( |
| 216 | + recordPath(rootDir, org, name), |
| 217 | + recordLegacyPath(rootDir, org, name), |
| 218 | + rootDir, |
| 219 | + org, |
| 220 | + ); |
| 221 | +} |
| 222 | + |
187 | 223 | /** The state file as a person names it: its path from the repository root. */ |
188 | 224 | export function stateFileLabel(rootDir: string, org: string): string { |
189 | 225 | return relative(rootDir, stateFileRead(rootDir, org)).replaceAll("\\", "/"); |
@@ -237,6 +273,12 @@ function committedFiles(rootDir: string, org: string): CommittedFile[] { |
237 | 273 | legacyLabel: `resources/${org}/.vapi-org.json`, |
238 | 274 | nextLabel: `${STATE_DIR}/${org}/org.json`, |
239 | 275 | }, |
| 276 | + ...STATE_RECORDS.map((name) => ({ |
| 277 | + legacy: recordLegacyPath(rootDir, org, name), |
| 278 | + next: recordPath(rootDir, org, name), |
| 279 | + legacyLabel: `resources/${org}/.vapi-${name}.json`, |
| 280 | + nextLabel: `${STATE_DIR}/${org}/${name}.json`, |
| 281 | + })), |
240 | 282 | ]; |
241 | 283 | } |
242 | 284 |
|
|
0 commit comments