Skip to content

Commit 0162bda

Browse files
committed
refactor(planetscale): rename actualRegion to region, drop displayName, add docs links
Address PR review feedback: - Rename actualRegion to region on Branch and Database output types (outputs overwrite inputs with actual values per alchemy convention) - Drop displayName from region output (redundant) - Use concise region: { slug: data.region.slug } in return statements - Add @see links to PlanetScale regions docs - Fix example slugs to include GCP regions
1 parent 7489dfb commit 0162bda

File tree

3 files changed

+33
-42
lines changed

3 files changed

+33
-42
lines changed

alchemy/src/planetscale/branch.ts

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,14 @@ export interface BranchProps extends PlanetScaleProps {
8888
* The region to create the branch in.
8989
* If not provided, the branch will be created in the default region for its database.
9090
* On adopt/update, if specified, the actual branch region is validated against this value.
91+
*
92+
* @see https://planetscale.com/docs/concepts/regions
9193
*/
9294
region?: {
9395
/**
94-
* The slug identifier of the region (e.g. "us-east", "eu-west")
96+
* The slug identifier of the region (e.g. "us-east", "eu-west", "gcp-us-central1")
97+
*
98+
* @see https://planetscale.com/docs/concepts/regions#available-regions
9599
*/
96100
slug: string;
97101
};
@@ -127,17 +131,17 @@ export interface Branch extends BranchProps {
127131
htmlUrl: string;
128132

129133
/**
130-
* The actual region of the branch as reported by PlanetScale
134+
* The region of the branch as reported by PlanetScale.
135+
*
136+
* @see https://planetscale.com/docs/concepts/regions
131137
*/
132-
actualRegion: {
138+
region: {
133139
/**
134-
* The slug identifier of the region (e.g. "us-east", "eu-west")
140+
* The slug identifier of the region (e.g. "us-east", "eu-west", "gcp-us-central1")
141+
*
142+
* @see https://planetscale.com/docs/concepts/regions#available-regions
135143
*/
136144
slug: string;
137-
/**
138-
* Display name of the region (e.g. "US East", "EU West")
139-
*/
140-
displayName: string;
141145
};
142146
}
143147

@@ -361,10 +365,7 @@ export const Branch = Resource(
361365
createdAt: data.created_at,
362366
updatedAt: data.updated_at,
363367
htmlUrl: data.html_url,
364-
actualRegion: {
365-
slug: data.region.slug,
366-
displayName: data.region.display_name,
367-
},
368+
region: { slug: data.region.slug },
368369
};
369370
}
370371
let clusterSize: string | undefined;
@@ -434,10 +435,7 @@ export const Branch = Resource(
434435
createdAt: data.created_at,
435436
updatedAt: data.updated_at,
436437
htmlUrl: data.html_url,
437-
actualRegion: {
438-
slug: data.region.slug,
439-
displayName: data.region.display_name,
440-
},
438+
region: { slug: data.region.slug },
441439
};
442440
},
443441
);

alchemy/src/planetscale/database.ts

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,15 @@ interface BaseDatabaseProps extends PlanetScaleProps {
4242
delete?: boolean;
4343

4444
/**
45-
* The region where the database will be created (create only)
45+
* The region where the database will be created (create only).
46+
*
47+
* @see https://planetscale.com/docs/concepts/regions
4648
*/
4749
region?: {
4850
/**
49-
* The slug identifier of the region
51+
* The slug identifier of the region (e.g. "us-east", "eu-west", "gcp-us-central1")
52+
*
53+
* @see https://planetscale.com/docs/concepts/regions#available-regions
5054
*/
5155
slug: string;
5256
};
@@ -219,17 +223,17 @@ export type Database = DatabaseProps & {
219223
organization: string;
220224

221225
/**
222-
* The actual region of the database as reported by PlanetScale
226+
* The region of the database as reported by PlanetScale.
227+
*
228+
* @see https://planetscale.com/docs/concepts/regions
223229
*/
224-
actualRegion: {
230+
region: {
225231
/**
226-
* The slug identifier of the region (e.g. "us-east", "eu-west")
232+
* The slug identifier of the region (e.g. "us-east", "eu-west", "gcp-us-central1")
233+
*
234+
* @see https://planetscale.com/docs/concepts/regions#available-regions
227235
*/
228236
slug: string;
229-
/**
230-
* Display name of the region (e.g. "US East", "EU West")
231-
*/
232-
displayName: string;
233237
};
234238
};
235239

@@ -480,10 +484,7 @@ export const Database = Resource(
480484
updatedAt: data.updated_at,
481485
htmlUrl: data.html_url,
482486
organization,
483-
actualRegion: {
484-
slug: data.region.slug,
485-
displayName: data.region.display_name,
486-
},
487+
region: { slug: data.region.slug },
487488
};
488489
}
489490

@@ -607,10 +608,7 @@ export const Database = Resource(
607608
updatedAt: updatedData.updated_at,
608609
htmlUrl: updatedData.html_url,
609610
organization,
610-
actualRegion: {
611-
slug: updatedData.region.slug,
612-
displayName: updatedData.region.display_name,
613-
},
611+
region: { slug: updatedData.region.slug },
614612
};
615613
}
616614
}
@@ -638,10 +636,7 @@ export const Database = Resource(
638636
updatedAt: data.updated_at,
639637
htmlUrl: data.html_url,
640638
organization,
641-
actualRegion: {
642-
slug: data.region.slug,
643-
displayName: data.region.display_name,
644-
},
639+
region: { slug: data.region.slug },
645640
};
646641
},
647642
);

alchemy/test/planetscale/database.test.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,8 @@ describe.skipIf(!process.env.PLANETSCALE_TEST).concurrent.each(kinds)(
5151
updatedAt: expect.any(String),
5252
htmlUrl: expect.any(String),
5353
kind,
54-
actualRegion: {
54+
region: {
5555
slug: expect.any(String),
56-
displayName: expect.any(String),
5756
},
5857
});
5958

@@ -314,9 +313,8 @@ describe.skipIf(!process.env.PLANETSCALE_TEST).concurrent.each(kinds)(
314313
delete: true,
315314
});
316315

317-
expect(database.actualRegion).toMatchObject({
316+
expect(database.region).toMatchObject({
318317
slug: "us-east",
319-
displayName: expect.any(String),
320318
});
321319

322320
// Now try to adopt it with a different region — should throw
@@ -341,7 +339,7 @@ describe.skipIf(!process.env.PLANETSCALE_TEST).concurrent.each(kinds)(
341339
delete: true,
342340
});
343341

344-
expect(adopted.actualRegion.slug).toBe("us-east");
342+
expect(adopted.region.slug).toBe("us-east");
345343
} finally {
346344
await destroy(scope);
347345
await assertDatabaseDeleted(api, organization, name);

0 commit comments

Comments
 (0)