(instanceId: string)
| 22 | * Strips dashes and prefixes `ki_` — result is `ki_{32-char-hex}` (35 chars). |
| 23 | */ |
| 24 | export function sandboxIdFromInstanceId(instanceId: string): string { |
| 25 | if (!isValidInstanceId(instanceId)) { |
| 26 | throw new Error('Invalid instanceId: must be a UUID'); |
| 27 | } |
| 28 | const hex = instanceId.replace(/-/g, ''); |
| 29 | const prefixed = `ki_${hex}`; |
| 30 | if (prefixed.length > MAX_SANDBOX_ID_LENGTH) { |
| 31 | throw new Error( |
| 32 | `instanceId too long: prefixed sandboxId would be ${prefixed.length} chars (max ${MAX_SANDBOX_ID_LENGTH})` |
| 33 | ); |
| 34 | } |
| 35 | return prefixed; |
| 36 | } |
| 37 | |
| 38 | /** Returns true if the sandboxId uses the `ki_` instance-keyed format. */ |
| 39 | export function isInstanceKeyedSandboxId(sandboxId: string): boolean { |
no test coverage detected