@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 664 lines 22.4 KB
Raw
1 import * as spanner from "@distilled.cloud/gcp/spanner_v1";
2 import { Unowned } from "alchemy/AdoptPolicy";
3 import { isResolved } from "alchemy/Diff";
4 import { createPhysicalName } from "alchemy/PhysicalName";
5 import * as Provider from "alchemy/Provider";
6 import { Resource } from "alchemy/Resource";
7 import { tagRecord } from "alchemy/Tags";
8 import * as Data from "effect/Data";
9 import * as Effect from "effect/Effect";
10 import * as Schedule from "effect/Schedule";
11 import * as Stream from "effect/Stream";
12 import { GcpEnvironment } from "../Environment.ts";
13 import {
14 createInternalLabels,
15 diffLabels,
16 hasAlchemyLabels,
17 stripInternalLabels,
18 toLabels,
19 } from "../Labels.ts";
20 import type { Providers } from "../Providers.ts";
21 import { waitForOperation } from "./operations.ts";
22
23 const DEFAULT_PROCESSING_UNITS = 100;
24 const DEFAULT_INSTANCE_TYPE = "PROVISIONED";
25 const DEFAULT_EDITION = "STANDARD";
26 const DEFAULT_BACKUP_SCHEDULE = "NONE";
27 const MAX_INSTANCE_ID_LENGTH = 64;
28 const MAX_DISPLAY_NAME_LENGTH = 30;
29 const MIN_DISPLAY_NAME_LENGTH = 4;
30
31 export type InstanceType = spanner.InstanceInstanceTypeEnum | (string & {});
32 export type InstanceEdition = spanner.InstanceEditionEnum | (string & {});
33 export type InstanceDefaultBackupScheduleType =
34 | spanner.InstanceDefaultBackupScheduleTypeEnum
35 | (string & {});
36
37 export type AutoscalingLimits = {
38 /** Minimum nodes. Mutually exclusive with processing-unit limits. */
39 minNodes?: number;
40 /** Minimum processing units (multiples of 1000). */
41 minProcessingUnits?: number;
42 /** Maximum nodes. */
43 maxNodes?: number;
44 /** Maximum processing units (multiples of 1000). */
45 maxProcessingUnits?: number;
46 };
47
48 export type AutoscalingTargets = {
49 /** Target high-priority CPU percent (`10`–`90`). */
50 highPriorityCpuUtilizationPercent?: number;
51 /** Target total CPU percent (`10`–`90`). */
52 totalCpuUtilizationPercent?: number;
53 /** Target storage percent (`10`–`99`). */
54 storageUtilizationPercent?: number;
55 };
56
57 export type AutoscalingConfig = {
58 /** Min/max compute capacity. */
59 autoscalingLimits?: AutoscalingLimits;
60 /** CPU and storage targets. */
61 autoscalingTargets?: AutoscalingTargets;
62 };
63
64 export type ReplicaComputeCapacity = {
65 /** Replica location (e.g. `us-central1`). */
66 location?: string;
67 /** Nodes allocated to this replica selection. */
68 nodeCount?: number;
69 /** Processing units allocated to this replica selection. */
70 processingUnits?: number;
71 };
72
73 export type InstanceProps = {
74 /**
75 * Instance id (the `{instance}` segment of
76 * `projects/{project}/instances/{instance}`). If omitted, a unique name
77 * is generated from the stack, stage, and logical id. Must match
78 * `^[a-z][-a-z0-9]*[a-z0-9]$` (2–64 characters). Immutable — changing
79 * it replaces the instance.
80 */
81 instanceId?: string;
82 /**
83 * Instance configuration id (`regional-us-central1`) or full name
84 * (`projects/{project}/instanceConfigs/{config}`). Immutable —
85 * changing it replaces the instance.
86 * @default `regional-{region}` for the stack's GCP region (`GCP.Region`, else the profile region, else `us-central1`)
87 */
88 config?: string;
89 /**
90 * User-facing display name. Must be unique per project and 4–30
91 * characters. Defaults to a truncated instance id.
92 */
93 displayName?: string;
94 /**
95 * User labels. Alchemy ownership labels are merged in automatically.
96 */
97 labels?: Record<string, string>;
98 /**
99 * Processing units. Mutually exclusive with `nodeCount`. Ignored when
100 * autoscaling is enabled or `instanceType` is `FREE_INSTANCE`.
101 * @default 100
102 */
103 processingUnits?: number;
104 /**
105 * Node count. Mutually exclusive with `processingUnits`. Ignored when
106 * autoscaling is enabled or `instanceType` is `FREE_INSTANCE`.
107 */
108 nodeCount?: number;
109 /**
110 * Autoscaling configuration. When set, `nodeCount` and
111 * `processingUnits` become output-only.
112 */
113 autoscalingConfig?: AutoscalingConfig;
114 /**
115 * Instance type. Immutable — changing it replaces the instance.
116 * @default "PROVISIONED"
117 */
118 instanceType?: InstanceType;
119 /**
120 * Edition (`STANDARD`, `ENTERPRISE`, `ENTERPRISE_PLUS`).
121 * @default "STANDARD"
122 */
123 edition?: InstanceEdition;
124 /**
125 * Default backup schedule for new databases. `NONE` skips automatic
126 * schedules (required for free instances).
127 * @default "NONE"
128 */
129 defaultBackupScheduleType?: InstanceDefaultBackupScheduleType;
130 };
131
132 export type Instance = Resource<
133 "GCP.Spanner.Instance",
134 InstanceProps,
135 {
136 /** Full resource name `projects/{project}/instances/{instance}`. */
137 name: string;
138 /** Instance id (last path segment). */
139 instanceId: string;
140 /** Project id. */
141 project: string;
142 /** Full instance config name. */
143 config: string;
144 /** User-facing display name. */
145 displayName: string | undefined;
146 /** User labels (Alchemy ownership labels stripped). */
147 labels: Record<string, string>;
148 /** Processing units currently allocated. */
149 processingUnits: number | undefined;
150 /** Nodes currently allocated. */
151 nodeCount: number | undefined;
152 /** Autoscaling configuration, if enabled. */
153 autoscalingConfig: AutoscalingConfig | undefined;
154 /** Compute capacity per replica selection. */
155 replicaComputeCapacity: ReplicaComputeCapacity[];
156 /** Instance type (`PROVISIONED`, `FREE_INSTANCE`). */
157 instanceType: string | undefined;
158 /** Edition (`STANDARD`, `ENTERPRISE`, `ENTERPRISE_PLUS`). */
159 edition: string | undefined;
160 /** Default backup schedule type. */
161 defaultBackupScheduleType: string | undefined;
162 /** Current instance state (`CREATING`, `READY`). */
163 state: string | undefined;
164 /** RFC3339 creation timestamp. */
165 createTime: string | undefined;
166 /** RFC3339 last-update timestamp. */
167 updateTime: string | undefined;
168 },
169 never,
170 Providers
171 >;
172
173 /**
174 * A Cloud Spanner instance.
175 *
176 * Changing `instanceId`, `config`, or `instanceType` replaces the
177 * instance. Display name, labels, compute capacity, edition, backup
178 * schedule, and autoscaling update in place. Create, update, and delete
179 * are long-running operations — a 100 processing-unit regional instance
180 * typically takes one to two minutes.
181 *
182 * ### Creating an Instance
183 * **Example:** Generated name, 100 processing units
184 * ```typescript
185 * const instance = yield* GCP.Spanner.Instance("App", {});
186 * ```
187 *
188 * **Example:** Explicit id, config, and labels
189 * ```typescript
190 * const instance = yield* GCP.Spanner.Instance("App", {
191 * instanceId: "app-spanner",
192 * config: "regional-us-central1",
193 * displayName: "app-spanner",
194 * processingUnits: 100,
195 * labels: { env: "prod" },
196 * });
197 * ```
198 *
199 * ### Observing Instances
200 * **Example:** Read the bound instance
201 * ```typescript
202 * const getInstance = yield* GCP.Spanner.GetInstance(instance);
203 * const live = yield* getInstance();
204 * ```
205 *
206 * @resource
207 * @category Spanner
208 */
209 export const Instance = Resource<Instance>("GCP.Spanner.Instance");
210
211 export class InstanceNotResolved extends Data.TaggedError("GCP.Spanner.InstanceNotResolved")<{
212 resourceName: string;
213 }> {}
214
215 export class InstanceNotReady extends Data.TaggedError("GCP.Spanner.InstanceNotReady")<{
216 resourceName: string;
217 state: string;
218 }> {}
219
220 export class InstanceStillExists extends Data.TaggedError("GCP.Spanner.InstanceStillExists")<{
221 resourceName: string;
222 }> {}
223
224 const lastSegment = (value: string) => {
225 const trimmed = value.replace(/\/+$/, "");
226 const parts = trimmed.split("/");
227 return parts[parts.length - 1] || trimmed;
228 };
229
230 const normalizeEnum = (value: string | undefined, fallback: string) => {
231 const next = (value ?? fallback).toUpperCase();
232 return next.endsWith("_UNSPECIFIED") ? fallback : next;
233 };
234
235 const normalizeInstanceType = (value: string | undefined) =>
236 normalizeEnum(value, DEFAULT_INSTANCE_TYPE);
237
238 const normalizeEdition = (value: string | undefined) => normalizeEnum(value, DEFAULT_EDITION);
239
240 const normalizeBackupSchedule = (value: string | undefined) =>
241 normalizeEnum(value, DEFAULT_BACKUP_SCHEDULE);
242
243 const defaultConfigId = (region: string) => `regional-${region}`;
244
245 const configIdOf = (config: string | undefined, region: string) =>
246 lastSegment(config ?? defaultConfigId(region)).toLowerCase();
247
248 const configNameOf = (project: string, config: string | undefined, region: string) => {
249 const raw = (config ?? defaultConfigId(region)).trim();
250 if (raw.includes("/")) return raw;
251 return `projects/${project}/instanceConfigs/${raw}`;
252 };
253
254 const resourceName = (project: string, instanceId: string) =>
255 `projects/${project}/instances/${instanceId}`;
256
257 const parseName = (name: string) => {
258 const parts = name.split("/").filter((part) => part.length > 0);
259 const instancesAt = parts.lastIndexOf("instances");
260 const projectsAt = parts.lastIndexOf("projects");
261 return {
262 project: projectsAt >= 0 && parts[projectsAt + 1] ? parts[projectsAt + 1]! : "",
263 instanceId:
264 instancesAt >= 0 && parts[instancesAt + 1] ? parts[instancesAt + 1]! : lastSegment(name),
265 };
266 };
267
268 const toSpannerId = (name: string) => {
269 let next = name
270 .toLowerCase()
271 .replace(/[^a-z0-9-]/g, "-")
272 .replace(/-+/g, "-");
273 next = next.replace(/^-+/, "").replace(/-+$/g, "");
274 if (!/^[a-z]/.test(next)) next = `s${next}`;
275 next = next.slice(0, MAX_INSTANCE_ID_LENGTH).replace(/-+$/g, "");
276 if (next.length < 2) next = `${next}xx`.slice(0, MAX_INSTANCE_ID_LENGTH);
277 return next;
278 };
279
280 const toId = (id: string, instanceId: string | undefined, existing?: string) =>
281 Effect.gen(function* () {
282 if (instanceId !== undefined) return instanceId;
283 if (existing !== undefined) return existing;
284 return toSpannerId(
285 yield* createPhysicalName({
286 id,
287 maxLength: MAX_INSTANCE_ID_LENGTH,
288 lowercase: true,
289 }),
290 );
291 });
292
293 const displayNameOf = (instanceId: string, displayName?: string) => {
294 const source = (displayName ?? instanceId).trim();
295 let next = source.slice(0, MAX_DISPLAY_NAME_LENGTH);
296 if (next.length < MIN_DISPLAY_NAME_LENGTH) {
297 next = `${next}inst`.slice(0, MAX_DISPLAY_NAME_LENGTH);
298 }
299 return next;
300 };
301
302 const userLabels = (
303 labels: Record<string, string | undefined> | null | undefined,
304 ): Record<string, string> => stripInternalLabels(tagRecord(labels));
305
306 const autoscalingOf = (
307 config: spanner.AutoscalingConfig | undefined,
308 ): AutoscalingConfig | undefined => {
309 if (config === undefined) return undefined;
310 return {
311 autoscalingLimits: config.autoscalingLimits
312 ? {
313 minNodes: config.autoscalingLimits.minNodes,
314 minProcessingUnits: config.autoscalingLimits.minProcessingUnits,
315 maxNodes: config.autoscalingLimits.maxNodes,
316 maxProcessingUnits: config.autoscalingLimits.maxProcessingUnits,
317 }
318 : undefined,
319 autoscalingTargets: config.autoscalingTargets
320 ? {
321 highPriorityCpuUtilizationPercent:
322 config.autoscalingTargets.highPriorityCpuUtilizationPercent,
323 totalCpuUtilizationPercent: config.autoscalingTargets.totalCpuUtilizationPercent,
324 storageUtilizationPercent: config.autoscalingTargets.storageUtilizationPercent,
325 }
326 : undefined,
327 };
328 };
329
330 const replicaCapacityOf = (
331 items: spanner.ReplicaComputeCapacityList | undefined,
332 ): ReplicaComputeCapacity[] =>
333 (items ?? []).map((item) => ({
334 location: item.replicaSelection?.location,
335 nodeCount: item.nodeCount,
336 processingUnits: item.processingUnits,
337 }));
338
339 const autoscalingKey = (config: AutoscalingConfig | undefined) => JSON.stringify(config ?? null);
340
341 const toAttrs = (instance: spanner.Instance, project: string): Instance["Attributes"] => {
342 const name = instance.name ?? "";
343 const parsed = parseName(name);
344 return {
345 name,
346 instanceId: parsed.instanceId,
347 project: parsed.project || project,
348 config: instance.config ?? "",
349 displayName: instance.displayName,
350 labels: userLabels(instance.labels),
351 processingUnits: instance.processingUnits,
352 nodeCount: instance.nodeCount,
353 autoscalingConfig: autoscalingOf(instance.autoscalingConfig),
354 replicaComputeCapacity: replicaCapacityOf(instance.replicaComputeCapacity),
355 instanceType: instance.instanceType,
356 edition: instance.edition,
357 defaultBackupScheduleType: instance.defaultBackupScheduleType,
358 state: instance.state,
359 createTime: instance.createTime,
360 updateTime: instance.updateTime,
361 };
362 };
363
364 const getByName = (name: string) =>
365 spanner.getProjectsInstances({ name }).pipe(Effect.catchTag("NotFound", () => Effect.undefined));
366
367 const waitUntilExists = (name: string) =>
368 getByName(name).pipe(
369 Effect.flatMap((instance) =>
370 instance
371 ? Effect.succeed(instance)
372 : Effect.fail(new InstanceNotResolved({ resourceName: name })),
373 ),
374 Effect.retry({
375 while: (error) => error._tag === "GCP.Spanner.InstanceNotResolved",
376 times: 8,
377 schedule: Schedule.spaced("2 seconds"),
378 }),
379 );
380
381 const waitUntilReady = (name: string) =>
382 getByName(name).pipe(
383 Effect.filterOrFail(
384 (instance): instance is spanner.Instance => instance !== undefined,
385 () => new InstanceNotResolved({ resourceName: name }),
386 ),
387 Effect.filterOrFail(
388 (instance) => (instance.state ?? "STATE_UNSPECIFIED") === "READY",
389 (instance) =>
390 new InstanceNotReady({
391 resourceName: name,
392 state: instance.state ?? "STATE_UNSPECIFIED",
393 }),
394 ),
395 Effect.retry({
396 while: (error) =>
397 error._tag === "GCP.Spanner.InstanceNotReady" ||
398 error._tag === "GCP.Spanner.InstanceNotResolved",
399 times: 10,
400 schedule: Schedule.spaced("8 seconds"),
401 }),
402 );
403
404 const waitUntilGone = (name: string) =>
405 getByName(name).pipe(
406 Effect.flatMap((instance) =>
407 instance === undefined
408 ? Effect.void
409 : Effect.fail(new InstanceStillExists({ resourceName: name })),
410 ),
411 Effect.retry({
412 while: (error) => error._tag === "GCP.Spanner.InstanceStillExists",
413 times: 10,
414 schedule: Schedule.spaced("8 seconds"),
415 }),
416 );
417
418 const retryConcurrentChanges = <A, E extends { readonly _tag: string }, R>(
419 effect: Effect.Effect<A, E, R>,
420 ) =>
421 effect.pipe(
422 Effect.retry({
423 while: (error) => error._tag === "Conflict",
424 times: 8,
425 schedule: Schedule.spaced("5 seconds"),
426 }),
427 );
428
429 const toCreateInstance = (
430 name: string,
431 news: InstanceProps,
432 project: string,
433 region: string,
434 desiredLabels: Record<string, string>,
435 instanceType: string,
436 displayName: string,
437 ): spanner.Instance => {
438 const free = instanceType === "FREE_INSTANCE";
439 const autoscaling = news.autoscalingConfig;
440 const body: spanner.Instance = {
441 name,
442 config: configNameOf(project, news.config, region),
443 displayName,
444 labels: desiredLabels,
445 instanceType,
446 };
447 if (!free) {
448 body.edition = news.edition ? normalizeEdition(news.edition) : DEFAULT_EDITION;
449 body.defaultBackupScheduleType = news.defaultBackupScheduleType
450 ? normalizeBackupSchedule(news.defaultBackupScheduleType)
451 : DEFAULT_BACKUP_SCHEDULE;
452 }
453 if (autoscaling !== undefined) {
454 body.autoscalingConfig = autoscaling;
455 } else if (!free) {
456 if (news.nodeCount !== undefined) {
457 body.nodeCount = news.nodeCount;
458 } else {
459 body.processingUnits = news.processingUnits ?? DEFAULT_PROCESSING_UNITS;
460 }
461 }
462 return body;
463 };
464
465 export const InstanceProvider = () =>
466 Provider.succeed(Instance, {
467 stables: ["name", "instanceId", "project", "config", "createTime"],
468
469 diff: Effect.fn(function* ({ news, olds, output }) {
470 if (!isResolved(news)) return undefined;
471 const env = yield* GcpEnvironment.current;
472
473 const previousId = olds?.instanceId ?? output?.instanceId;
474 const nextId = news.instanceId ?? previousId;
475 const previousConfig = configIdOf(olds?.config ?? output?.config, env.region);
476 const nextConfig = configIdOf(news.config ?? output?.config, env.region);
477 const previousType = normalizeInstanceType(olds?.instanceType ?? output?.instanceType);
478 const nextType = normalizeInstanceType(news.instanceType ?? output?.instanceType);
479
480 const replace =
481 (previousId !== undefined && nextId !== undefined && nextId !== previousId) ||
482 previousConfig !== nextConfig ||
483 previousType !== nextType;
484
485 if (!replace) return undefined;
486 return {
487 action: "replace" as const,
488 deleteFirst:
489 previousConfig !== nextConfig ||
490 previousType !== nextType ||
491 (previousId !== undefined && nextId === previousId),
492 };
493 }),
494
495 read: Effect.fn(function* ({ id, olds, output }) {
496 const env = yield* GcpEnvironment.current;
497 const instanceId = yield* toId(id, olds?.instanceId, output?.instanceId);
498 const name = output?.name ?? resourceName(env.project, instanceId);
499 const existing = yield* getByName(name);
500 if (existing === undefined) return undefined;
501 const attrs = toAttrs(existing, env.project);
502 return (yield* hasAlchemyLabels(id, tagRecord(existing.labels))) ? attrs : Unowned(attrs);
503 }),
504
505 list: () =>
506 Effect.gen(function* () {
507 const env = yield* GcpEnvironment.current;
508 return yield* spanner.listProjectsInstances
509 .pages({
510 parent: `projects/${env.project}`,
511 pageSize: 1000,
512 })
513 .pipe(
514 Stream.flatMap((page) => Stream.fromIterable(page.instances ?? [])),
515 Stream.filter((instance) =>
516 Object.keys(instance.labels ?? {}).some((key) => key.startsWith("alchemy-")),
517 ),
518 Stream.map((instance) => toAttrs(instance, env.project)),
519 Stream.runCollect,
520 Effect.map((chunk) => Array.from(chunk)),
521 Effect.catchTag("NotFound", () => Effect.succeed([])),
522 );
523 }),
524
525 reconcile: Effect.fn(function* ({ id, news, output }) {
526 const env = yield* GcpEnvironment.current;
527 const instanceId = yield* toId(id, news.instanceId, output?.instanceId);
528 const name = resourceName(env.project, instanceId);
529 const instanceType = normalizeInstanceType(news.instanceType);
530 const displayName = displayNameOf(instanceId, news.displayName);
531 const desiredLabels = {
532 ...toLabels(news.labels),
533 ...(yield* createInternalLabels(id)),
534 };
535
536 let current = yield* getByName(output?.name ?? name);
537
538 if (current === undefined) {
539 const created = yield* spanner
540 .createProjectsInstances({
541 parent: `projects/${env.project}`,
542 body: {
543 instanceId,
544 instance: toCreateInstance(
545 name,
546 news,
547 env.project,
548 env.region,
549 desiredLabels,
550 instanceType,
551 displayName,
552 ),
553 },
554 })
555 .pipe(Effect.catchTag("Conflict", () => Effect.undefined));
556 if (created !== undefined) {
557 yield* waitForOperation(created, { alreadyExistsOk: true });
558 }
559 current = yield* waitUntilExists(name);
560 }
561
562 if (current === undefined) {
563 return yield* new InstanceNotResolved({ resourceName: name });
564 }
565
566 if ((current.state ?? "") !== "READY") {
567 current = yield* waitUntilReady(name);
568 }
569
570 const observedLabels = tagRecord(current.labels);
571 const { upsert, removed } = diffLabels(observedLabels, desiredLabels);
572 const labelsChanged = upsert.length > 0 || removed.length > 0;
573 const displayNameChanged = (current.displayName ?? "") !== displayName;
574 const editionChanged =
575 news.edition !== undefined &&
576 normalizeEdition(current.edition) !== normalizeEdition(news.edition);
577 const backupChanged =
578 news.defaultBackupScheduleType !== undefined &&
579 normalizeBackupSchedule(current.defaultBackupScheduleType) !==
580 normalizeBackupSchedule(news.defaultBackupScheduleType);
581 const autoscalingChanged =
582 news.autoscalingConfig !== undefined &&
583 autoscalingKey(autoscalingOf(current.autoscalingConfig)) !==
584 autoscalingKey(news.autoscalingConfig);
585 const processingUnitsChanged =
586 news.autoscalingConfig === undefined &&
587 news.nodeCount === undefined &&
588 news.processingUnits !== undefined &&
589 (current.processingUnits ?? 0) !== news.processingUnits;
590 const nodeCountChanged =
591 news.autoscalingConfig === undefined &&
592 news.nodeCount !== undefined &&
593 (current.nodeCount ?? 0) !== news.nodeCount;
594
595 if (
596 labelsChanged ||
597 displayNameChanged ||
598 editionChanged ||
599 backupChanged ||
600 autoscalingChanged ||
601 processingUnitsChanged ||
602 nodeCountChanged
603 ) {
604 const fieldMask = [
605 labelsChanged ? "labels" : undefined,
606 displayNameChanged ? "display_name" : undefined,
607 editionChanged ? "edition" : undefined,
608 backupChanged ? "default_backup_schedule_type" : undefined,
609 autoscalingChanged ? "autoscaling_config" : undefined,
610 processingUnitsChanged ? "processing_units" : undefined,
611 nodeCountChanged ? "node_count" : undefined,
612 ].filter((field): field is string => field !== undefined);
613
614 const patchBody: spanner.Instance = {
615 name,
616 labels: desiredLabels,
617 displayName,
618 };
619 if (editionChanged && news.edition !== undefined) {
620 patchBody.edition = normalizeEdition(news.edition);
621 }
622 if (backupChanged && news.defaultBackupScheduleType !== undefined) {
623 patchBody.defaultBackupScheduleType = normalizeBackupSchedule(
624 news.defaultBackupScheduleType,
625 );
626 }
627 if (autoscalingChanged) {
628 patchBody.autoscalingConfig = news.autoscalingConfig;
629 }
630 if (processingUnitsChanged) {
631 patchBody.processingUnits = news.processingUnits;
632 }
633 if (nodeCountChanged) {
634 patchBody.nodeCount = news.nodeCount;
635 }
636
637 const patched = yield* retryConcurrentChanges(
638 spanner.patchProjectsInstances({
639 name,
640 body: {
641 instance: patchBody,
642 fieldMask: fieldMask.join(","),
643 },
644 }),
645 );
646 yield* waitForOperation(patched);
647 current = yield* waitUntilReady(name);
648 }
649
650 return toAttrs(current, env.project);
651 }),
652
653 delete: Effect.fn(function* ({ output }) {
654 yield* spanner.deleteProjectsInstances({ name: output.name }).pipe(
655 Effect.catchTag("NotFound", () => Effect.void),
656 Effect.retry({
657 while: (error) => error._tag === "Conflict",
658 times: 8,
659 schedule: Schedule.spaced("5 seconds"),
660 }),
661 );
662 yield* waitUntilGone(output.name);
663 }),
664 });