@devries-cameron20 / t3code Mirror · read-only
Fork 0

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

main
ts 84 lines 2.93 KB
Raw
1 import * as cloudchannel from "@distilled.cloud/gcp/cloudchannel_v1";
2 import * as Effect from "effect/Effect";
3 import { MinimumLogLevel } from "effect/References";
4 import * as Schedule from "effect/Schedule";
5
6 export const logLevel = Effect.provideService(
7 MinimumLogLevel,
8 process.env.DEBUG ? "Debug" : "Info",
9 );
10
11 // Cloud Channel needs a reseller/distributor account and credentials with the
12 // apps.order scope; the service account profile is rejected with Forbidden:
13 // "Request had insufficient authentication scopes." Set
14 // GOOGLE_CLOUDCHANNEL_ACCOUNT to the reseller account to run the lifecycles.
15 export const runLifecycle = !!process.env.GOOGLE_CLOUDCHANNEL_ACCOUNT?.trim();
16
17 export const probeAccount = process.env.GOOGLE_CLOUDCHANNEL_ACCOUNT?.trim() || "C00000000";
18
19 export const probeAccountName = probeAccount.startsWith("accounts/")
20 ? probeAccount
21 : `accounts/${probeAccount}`;
22
23 export const probePostalAddress: cloudchannel.GoogleTypePostalAddress = {
24 regionCode: "US",
25 postalCode: "94105",
26 administrativeArea: "CA",
27 locality: "San Francisco",
28 addressLines: ["100 Market Street"],
29 };
30
31 export const probeCustomerBody = {
32 orgDisplayName: "Alchemy Cloudchannel Probe",
33 domain: "alchemy-cloudchannel-probe.example.com",
34 orgPostalAddress: probePostalAddress,
35 primaryContactInfo: {
36 firstName: "Alchemy",
37 lastName: "Probe",
38 email: "admin@alchemy-cloudchannel-probe.example.com",
39 },
40 } satisfies cloudchannel.GoogleCloudChannelV1Customer;
41
42 export const waitUntilCustomerGone = (name: string) =>
43 cloudchannel.getAccountsCustomers({ name }).pipe(
44 Effect.as("found" as const),
45 Effect.catchTag("NotFound", () => Effect.succeed("gone" as const)),
46 Effect.repeat({
47 schedule: Schedule.spaced("1 second"),
48 until: (status) => status === "gone",
49 times: 10,
50 }),
51 );
52
53 export const waitUntilPartnerCustomerGone = (name: string) =>
54 cloudchannel.getAccountsChannelPartnerLinksCustomers({ name }).pipe(
55 Effect.as("found" as const),
56 Effect.catchTag("NotFound", () => Effect.succeed("gone" as const)),
57 Effect.repeat({
58 schedule: Schedule.spaced("1 second"),
59 until: (status) => status === "gone",
60 times: 10,
61 }),
62 );
63
64 export const waitUntilCustomerRepricingGone = (name: string) =>
65 cloudchannel.getAccountsCustomersCustomerRepricingConfigs({ name }).pipe(
66 Effect.as("found" as const),
67 Effect.catchTag("NotFound", () => Effect.succeed("gone" as const)),
68 Effect.repeat({
69 schedule: Schedule.spaced("1 second"),
70 until: (status) => status === "gone",
71 times: 10,
72 }),
73 );
74
75 export const waitUntilPartnerRepricingGone = (name: string) =>
76 cloudchannel.getAccountsChannelPartnerLinksChannelPartnerRepricingConfigs({ name }).pipe(
77 Effect.as("found" as const),
78 Effect.catchTag("NotFound", () => Effect.succeed("gone" as const)),
79 Effect.repeat({
80 schedule: Schedule.spaced("1 second"),
81 until: (status) => status === "gone",
82 times: 10,
83 }),
84 );