The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 06:00 UTC
| 1 | import * as looker from "@distilled.cloud/gcp/looker_v1"; |
| 2 | import * as Effect from "effect/Effect"; |
| 3 | import { waitForOperation as waitForGcpOperation } from "../Operation.ts"; |
| 4 | |
| 5 | /** |
| 6 | * Wait for a Looker operation; instance backups take several minutes. |
| 7 | * ALREADY_EXISTS (code 6) counts as success (create race); with |
| 8 | * `notFoundOk`, so does NOT_FOUND (code 5, delete race) and an operation |
| 9 | * that is already gone. |
| 10 | */ |
| 11 | export const waitForOperation = (operation: looker.Operation, options?: { notFoundOk?: boolean }) => |
| 12 | waitForGcpOperation(operation, (name) => looker.getProjectsLocationsOperations({ name }), { |
| 13 | budget: "30 minutes", |
| 14 | interval: "10 seconds", |
| 15 | }).pipe( |
| 16 | Effect.catchIf( |
| 17 | (error) => |
| 18 | (error._tag === "GCP.OperationFailed" && |
| 19 | (error.code === 6 || (options?.notFoundOk === true && error.code === 5))) || |
| 20 | (options?.notFoundOk === true && error._tag === "NotFound"), |
| 21 | () => Effect.succeed(operation), |
| 22 | ), |
| 23 | ); |