@cosmoner/sdk 1.9.0 → 1.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -149,6 +149,64 @@ var AppsService = class {
149
149
  if (!appId) throw new Error("appId is required");
150
150
  return this.transport.request("DELETE", `${this.basePath(params.projectId)}/${appId}`);
151
151
  }
152
+ /** Prices an app of a size before ordering it. `monthly` is exact; `dueToday` is an estimate once the project has a subscription. */
153
+ async preview(params) {
154
+ if (!params?.size) throw new Error("size is required");
155
+ return this.transport.request("GET", `${this.basePath(params.projectId)}/preview`, {
156
+ query: { size: params.size }
157
+ });
158
+ }
159
+ /**
160
+ * Saves what an app should be, without creating or billing anything. The
161
+ * draft expires after 24 hours; `create()` turns it into an app. The app
162
+ * gets a Cosmoner subdomain.
163
+ */
164
+ async createDraft(params) {
165
+ if (!params?.name) throw new Error("name is required");
166
+ if (!params.size) throw new Error("size is required");
167
+ if (!params.region) throw new Error("region is required");
168
+ const { projectId, ...fields } = params;
169
+ return this.transport.request("POST", `${this.basePath(projectId)}/draft`, {
170
+ body: { ...fields, domainType: "cosmoner" }
171
+ });
172
+ }
173
+ /**
174
+ * Creates and deploys the app a draft describes. It starts `DEPLOYING`.
175
+ *
176
+ * Charges the project's saved card immediately, with a prorated invoice. It
177
+ * is refused with 402 before anything is created when the project cannot be
178
+ * billed.
179
+ */
180
+ async create(params) {
181
+ if (!params?.draftId) throw new Error("draftId is required");
182
+ if (!params.size) throw new Error("size is required");
183
+ return this.transport.request("POST", this.basePath(params.projectId), {
184
+ body: { draftId: params.draftId, size: params.size }
185
+ });
186
+ }
187
+ /** Lists the sizes an app can move to, and whether it can be resized at all. */
188
+ async sizes(appId, params = {}) {
189
+ if (!appId) throw new Error("appId is required");
190
+ return this.transport.request("GET", `${this.basePath(params.projectId)}/${appId}/sizes`);
191
+ }
192
+ /** Prices moving an app to another size. */
193
+ async resizePreview(appId, params) {
194
+ if (!appId) throw new Error("appId is required");
195
+ if (!params?.size) throw new Error("size is required");
196
+ return this.transport.request(
197
+ "GET",
198
+ `${this.basePath(params.projectId)}/${appId}/resize-preview`,
199
+ { query: { size: params.size } }
200
+ );
201
+ }
202
+ /** Moves an app to another size. Charges the difference to the saved card immediately. */
203
+ async resize(appId, params) {
204
+ if (!appId) throw new Error("appId is required");
205
+ if (!params?.size) throw new Error("size is required");
206
+ return this.transport.request("PATCH", `${this.basePath(params.projectId)}/${appId}/size`, {
207
+ body: { size: params.size }
208
+ });
209
+ }
152
210
  };
153
211
 
154
212
  // src/services/buckets.ts
@@ -173,6 +231,78 @@ var BucketsService = class {
173
231
  basePath(projectId) {
174
232
  return `/v1/projects/${resolveProjectId(this.config, projectId)}/storage/object-storage`;
175
233
  }
234
+ /**
235
+ * Prices a bucket's tier before ordering it. CDN traffic is metered and not
236
+ * included. `monthly` is exact; `dueToday` is an estimate once the project
237
+ * has a subscription.
238
+ */
239
+ async preview(params = {}) {
240
+ return this.transport.request("GET", `${this.basePath(params.projectId)}/preview`, {
241
+ query: { provider: "AWS_S3", tier: params.tier ?? "STARTER" }
242
+ });
243
+ }
244
+ /**
245
+ * Orders a bucket. It is ready when this returns; names are unique, so list
246
+ * and match the name to read it.
247
+ *
248
+ * Charges the project's saved card immediately, with a prorated invoice. It
249
+ * is refused with 402 before anything is created when the project cannot be
250
+ * billed.
251
+ */
252
+ async create(params) {
253
+ if (!params?.name) throw new Error("name is required");
254
+ if (!params.region) throw new Error("region is required");
255
+ return this.transport.request("POST", this.basePath(params.projectId), {
256
+ body: {
257
+ name: params.name,
258
+ provider: "AWS_S3",
259
+ region: params.region,
260
+ tier: params.tier,
261
+ publicAccess: params.publicAccess,
262
+ versioning: params.versioning,
263
+ cdnEnabled: params.cdnEnabled
264
+ }
265
+ });
266
+ }
267
+ };
268
+
269
+ // src/services/catalog.ts
270
+ var CatalogService = class {
271
+ constructor(transport) {
272
+ this.transport = transport;
273
+ }
274
+ /** Lists server sizes and their prices. */
275
+ async serverSizes() {
276
+ return this.transport.request("GET", "/v1/catalog/servers/sizes");
277
+ }
278
+ /** Lists the regions servers can be created in. */
279
+ async serverRegions() {
280
+ return this.transport.request("GET", "/v1/catalog/servers/regions");
281
+ }
282
+ /** Lists the one-click images a server can be created from. */
283
+ async serverImages() {
284
+ return this.transport.request("GET", "/v1/catalog/servers/1-clicks");
285
+ }
286
+ /** Lists Redis plans and their prices. */
287
+ async redisPlans() {
288
+ return this.transport.request("GET", "/v1/catalog/redis/plans");
289
+ }
290
+ /** Lists the regions Redis can be created in. */
291
+ async redisRegions() {
292
+ return this.transport.request("GET", "/v1/catalog/redis/regions");
293
+ }
294
+ /** Lists dedicated database sizes, engines with their versions, and regions. */
295
+ async databases() {
296
+ return this.transport.request("GET", "/v1/catalog/databases");
297
+ }
298
+ /** Lists app sizes and their prices. */
299
+ async appSizes() {
300
+ return this.transport.request("GET", "/v1/catalog/apps/sizes");
301
+ }
302
+ /** Lists the regions apps can be created in. */
303
+ async appRegions() {
304
+ return this.transport.request("GET", "/v1/catalog/apps/regions");
305
+ }
176
306
  };
177
307
 
178
308
  // src/services/databases.ts
@@ -229,6 +359,42 @@ var DatabasesService = class {
229
359
  `${this.basePath(params.projectId)}/shared/${tenantId}`
230
360
  );
231
361
  }
362
+ /** Prices a dedicated database before ordering it. `monthly` is exact; `dueToday` is an estimate once the project has a subscription. */
363
+ async previewDedicated(params) {
364
+ if (!params?.size) throw new Error("size is required");
365
+ return this.transport.request(
366
+ "GET",
367
+ `${this.basePath(params.projectId)}/dedicated/preview`,
368
+ { query: { slug: params.size } }
369
+ );
370
+ }
371
+ /**
372
+ * Orders a dedicated database. It starts `CREATING`; the response carries
373
+ * no id, so list and match the name to follow it.
374
+ *
375
+ * Charges the project's saved card immediately, with a prorated invoice. It
376
+ * is refused with 402 before anything is created when the project cannot be
377
+ * billed.
378
+ */
379
+ async createDedicated(params) {
380
+ if (!params?.name) throw new Error("name is required");
381
+ if (!params.size) throw new Error("size is required");
382
+ if (!params.version) throw new Error("version is required");
383
+ if (!params.region) throw new Error("region is required");
384
+ return this.transport.request(
385
+ "POST",
386
+ `${this.basePath(params.projectId)}/dedicated`,
387
+ {
388
+ body: {
389
+ name: params.name,
390
+ engine: params.engine ?? "POSTGRESQL",
391
+ version: params.version,
392
+ slug: params.size,
393
+ region: params.region
394
+ }
395
+ }
396
+ );
397
+ }
232
398
  };
233
399
 
234
400
  // src/services/domains.ts
@@ -384,6 +550,36 @@ var HostingService = class {
384
550
  if (!siteId) throw new Error("siteId is required");
385
551
  return this.transport.request("DELETE", `${this.basePath(params.projectId)}/${siteId}`);
386
552
  }
553
+ /** Lists hosting plans and their monthly prices. */
554
+ async prices(params = {}) {
555
+ return this.transport.request("GET", `${this.basePath(params.projectId)}/prices`);
556
+ }
557
+ /** Prices a site before ordering it. `monthly` is exact; `dueToday` is an estimate once the project has a subscription. */
558
+ async preview(params) {
559
+ if (!params?.tier) throw new Error("tier is required");
560
+ return this.transport.request("GET", `${this.basePath(params.projectId)}/preview`, {
561
+ query: { tier: params.tier, extraStorageGb: params.extraStorageGb ?? 0 }
562
+ });
563
+ }
564
+ /**
565
+ * Orders a hosting site, and its database when one is named.
566
+ *
567
+ * Charges the project's saved card immediately, with a prorated invoice. It
568
+ * is refused with 402 before anything is created when the project cannot be
569
+ * billed.
570
+ */
571
+ async create(params) {
572
+ if (!params?.siteName) throw new Error("siteName is required");
573
+ return this.transport.request("POST", this.basePath(params.projectId), {
574
+ body: {
575
+ siteName: params.siteName,
576
+ tier: params.tier,
577
+ phpVersion: params.phpVersion,
578
+ database: params.database === void 0 ? void 0 : { name: params.database },
579
+ extraStorageGb: params.extraStorageGb
580
+ }
581
+ });
582
+ }
387
583
  };
388
584
 
389
585
  // src/services/iam.ts
@@ -473,6 +669,29 @@ var RedisService = class {
473
669
  if (!redisId) throw new Error("redisId is required");
474
670
  return this.transport.request("DELETE", `${this.basePath(params.projectId)}/${redisId}`);
475
671
  }
672
+ /** Prices a Redis database before ordering it. `monthly` is exact; `dueToday` is an estimate once the project has a subscription. */
673
+ async preview(params) {
674
+ if (!params?.plan) throw new Error("plan is required");
675
+ return this.transport.request("GET", `${this.basePath(params.projectId)}/preview`, {
676
+ query: { planSlug: params.plan }
677
+ });
678
+ }
679
+ /**
680
+ * Orders a Redis database. It starts `CREATING`; the response carries no
681
+ * id, so list and match the name to follow it.
682
+ *
683
+ * Charges the project's saved card immediately, with a prorated invoice. It
684
+ * is refused with 402 before anything is created when the project cannot be
685
+ * billed.
686
+ */
687
+ async create(params) {
688
+ if (!params?.name) throw new Error("name is required");
689
+ if (!params.plan) throw new Error("plan is required");
690
+ if (!params.region) throw new Error("region is required");
691
+ return this.transport.request("POST", this.basePath(params.projectId), {
692
+ body: { name: params.name, planSlug: params.plan, region: params.region, dataPersistence: params.persistence }
693
+ });
694
+ }
476
695
  };
477
696
 
478
697
  // src/services/registries.ts
@@ -499,6 +718,32 @@ var RegistriesService = class {
499
718
  if (!registryId) throw new Error("registryId is required");
500
719
  return this.transport.request("DELETE", `${this.basePath(params.projectId)}/${registryId}`);
501
720
  }
721
+ /**
722
+ * Prices a registry's base fee before ordering it. Storage and egress are
723
+ * metered and not included. `monthly` is exact; `dueToday` is an estimate
724
+ * once the project has a subscription.
725
+ */
726
+ async preview(params = {}) {
727
+ return this.transport.request("GET", `${this.basePath(params.projectId)}/preview`);
728
+ }
729
+ /** Lists the providers a registry can be created with, and their regions. */
730
+ async providers(params = {}) {
731
+ return this.transport.request("GET", `${this.basePath(params.projectId)}/providers`);
732
+ }
733
+ /**
734
+ * Orders a registry. It is ready when this returns.
735
+ *
736
+ * Charges the project's saved card immediately, with a prorated invoice. It
737
+ * is refused with 402 before anything is created when the project cannot be
738
+ * billed.
739
+ */
740
+ async create(params) {
741
+ if (!params?.name) throw new Error("name is required");
742
+ if (!params.region) throw new Error("region is required");
743
+ return this.transport.request("POST", this.basePath(params.projectId), {
744
+ body: { name: params.name, region: params.region, provider: params.provider }
745
+ });
746
+ }
502
747
  };
503
748
 
504
749
  // src/services/project-config.ts
@@ -631,6 +876,36 @@ var ServersService = class {
631
876
  if (!serverId) throw new Error("serverId is required");
632
877
  return this.transport.request("DELETE", `${this.basePath(params.projectId)}/${serverId}`);
633
878
  }
879
+ /** Prices a server before ordering it. `monthly` is exact; `dueToday` is an estimate once the project has a subscription. */
880
+ async preview(params) {
881
+ if (!params?.size) throw new Error("size is required");
882
+ return this.transport.request("GET", `${this.basePath(params.projectId)}/preview`, {
883
+ query: { provider: params.provider ?? "digitalocean", slug: params.size }
884
+ });
885
+ }
886
+ /**
887
+ * Orders a server. It starts `PROVISIONING`; the response carries no id, so
888
+ * list servers and match the name to follow it.
889
+ *
890
+ * Charges the project's saved card immediately, with a prorated invoice. It
891
+ * is refused with 402 before anything is created when the project cannot be
892
+ * billed.
893
+ */
894
+ async create(params) {
895
+ if (!params?.name) throw new Error("name is required");
896
+ if (!params.size) throw new Error("size is required");
897
+ if (!params.region) throw new Error("region is required");
898
+ return this.transport.request("POST", this.basePath(params.projectId), {
899
+ body: {
900
+ name: params.name,
901
+ slug: params.size,
902
+ provider: params.provider ?? "digitalocean",
903
+ region: params.region,
904
+ template: params.image,
905
+ sshKeyIds: params.sshKeyIds
906
+ }
907
+ });
908
+ }
634
909
  };
635
910
 
636
911
  // src/services/ssh-keys.ts
@@ -1111,7 +1386,7 @@ function sleep(ms) {
1111
1386
  }
1112
1387
 
1113
1388
  // src/version.ts
1114
- var VERSION = "1.9.0";
1389
+ var VERSION = "1.10.0";
1115
1390
  var USER_AGENT = `cosmoner-node/${VERSION}`;
1116
1391
 
1117
1392
  // src/transport.ts
@@ -1243,6 +1518,7 @@ var Cosmoner = class {
1243
1518
  this.iam = new IamService(this.transport, this.config);
1244
1519
  this.members = new MembersService(this.transport, this.config);
1245
1520
  this.projects = new ProjectsService(this.transport);
1521
+ this.catalog = new CatalogService(this.transport);
1246
1522
  this.redis = new RedisService(this.transport, this.config);
1247
1523
  this.registries = new RegistriesService(this.transport, this.config);
1248
1524
  this.secrets = new SecretsService(this.transport, this.config);
@@ -1591,6 +1867,7 @@ export {
1591
1867
  AppsService,
1592
1868
  AuthenticationError,
1593
1869
  BucketsService,
1870
+ CatalogService,
1594
1871
  ConflictError,
1595
1872
  Cosmoner,
1596
1873
  CosmonerConnectionError,
@@ -1,5 +1,6 @@
1
1
  /** Apps service namespace — finding apps and rolling image apps onto a new image. */
2
2
  import { type ResolvedConfig } from "../config";
3
+ import type { CheckoutPreview, PlanChangePreview } from "./preview";
3
4
  import type { Transport } from "../transport";
4
5
  /** Lifecycle state of an app as a whole. */
5
6
  export type AppStatus = "DEPLOYING" | "RUNNING" | "STOPPED" | "ERROR" | "TERMINATED";
@@ -109,6 +110,67 @@ export interface UpdateAppParams extends ProjectScopedParams {
109
110
  }
110
111
  export type UpdateAppResponse = Envelope<App>;
111
112
  export type DeleteAppResponse = Envelope<Record<string, never>>;
113
+ /** Arguments accepted by `client.apps.createDraft()`. Pass a repository or an image. */
114
+ export interface CreateAppDraftParams extends ProjectScopedParams {
115
+ name: string;
116
+ /** A size slug from `client.catalog.appSizes()`. */
117
+ size: string;
118
+ /** A region slug from `client.catalog.appRegions()`. */
119
+ region: string;
120
+ appType?: "service" | "static";
121
+ gitProvider?: "github" | "gitlab" | "bitbucket";
122
+ /** `owner/repo`. */
123
+ gitRepo?: string;
124
+ gitBranch?: string;
125
+ sourceDir?: string;
126
+ buildStrategy?: "nixpacks" | "docker";
127
+ buildCommand?: string;
128
+ runCommand?: string;
129
+ outputDir?: string;
130
+ publicPort?: number;
131
+ internalPort?: number;
132
+ autoDeploy?: boolean;
133
+ containerRegistry?: "dockerhub" | "ghcr" | "cosmoner";
134
+ containerImage?: string;
135
+ /** The image's listening port, as a string. */
136
+ containerPublicPort?: string;
137
+ imageDeployPolicy?: ImageDeployPolicy;
138
+ instances?: number;
139
+ }
140
+ /** Arguments accepted by `client.apps.create()`. */
141
+ export interface CreateAppParams extends ProjectScopedParams {
142
+ draftId: string;
143
+ /** The size to bill; pass the draft's. */
144
+ size: string;
145
+ }
146
+ /** An app's sizes, and whether it can be resized at all. */
147
+ export interface AppSizes {
148
+ currentSize: string;
149
+ resizable: boolean;
150
+ sizes: Array<{
151
+ slug: string;
152
+ name: string;
153
+ tierSlug: string;
154
+ cpuType: string;
155
+ cpus: number;
156
+ memoryMb: number;
157
+ bandwidthGib: number;
158
+ priceMonthly: number;
159
+ }>;
160
+ }
161
+ export type PreviewAppResponse = Envelope<CheckoutPreview>;
162
+ export type CreateAppDraftResponse = Envelope<{
163
+ draftId: string;
164
+ }>;
165
+ export type CreateAppResponse = Envelope<{
166
+ deployed: true;
167
+ appId: string;
168
+ }>;
169
+ export type GetAppSizesResponse = Envelope<AppSizes>;
170
+ export type PreviewAppResizeResponse = Envelope<PlanChangePreview>;
171
+ export type ResizeAppResponse = Envelope<{
172
+ instanceSize: string;
173
+ }>;
112
174
  /** App lookup and image deploy operations for a project. */
113
175
  export declare class AppsService {
114
176
  private readonly transport;
@@ -157,5 +219,33 @@ export declare class AppsService {
157
219
  * billing, then the app itself. Its deployments go with it.
158
220
  */
159
221
  delete(appId: string, params?: ProjectScopedParams): Promise<DeleteAppResponse>;
222
+ /** Prices an app of a size before ordering it. `monthly` is exact; `dueToday` is an estimate once the project has a subscription. */
223
+ preview(params: {
224
+ size: string;
225
+ } & ProjectScopedParams): Promise<PreviewAppResponse>;
226
+ /**
227
+ * Saves what an app should be, without creating or billing anything. The
228
+ * draft expires after 24 hours; `create()` turns it into an app. The app
229
+ * gets a Cosmoner subdomain.
230
+ */
231
+ createDraft(params: CreateAppDraftParams): Promise<CreateAppDraftResponse>;
232
+ /**
233
+ * Creates and deploys the app a draft describes. It starts `DEPLOYING`.
234
+ *
235
+ * Charges the project's saved card immediately, with a prorated invoice. It
236
+ * is refused with 402 before anything is created when the project cannot be
237
+ * billed.
238
+ */
239
+ create(params: CreateAppParams): Promise<CreateAppResponse>;
240
+ /** Lists the sizes an app can move to, and whether it can be resized at all. */
241
+ sizes(appId: string, params?: ProjectScopedParams): Promise<GetAppSizesResponse>;
242
+ /** Prices moving an app to another size. */
243
+ resizePreview(appId: string, params: {
244
+ size: string;
245
+ } & ProjectScopedParams): Promise<PreviewAppResizeResponse>;
246
+ /** Moves an app to another size. Charges the difference to the saved card immediately. */
247
+ resize(appId: string, params: {
248
+ size: string;
249
+ } & ProjectScopedParams): Promise<ResizeAppResponse>;
160
250
  }
161
251
  export {};
@@ -1,5 +1,6 @@
1
1
  /** Buckets service namespace — a project's object storage buckets. */
2
2
  import { type ResolvedConfig } from "../config";
3
+ import type { CheckoutPreview } from "./preview";
3
4
  import type { Transport } from "../transport";
4
5
  /** A bucket as the API lists it. Its access keys are never part of a listing. */
5
6
  export interface Bucket {
@@ -27,6 +28,28 @@ interface Envelope<T> {
27
28
  }
28
29
  export type ListBucketsResponse = Envelope<Bucket[]>;
29
30
  export type DeleteBucketResponse = Envelope<Record<string, never>>;
31
+ /** A bucket's plan. */
32
+ export type BucketTier = "STARTER" | "GROWTH" | "SCALE" | "ENTERPRISE";
33
+ /** Arguments accepted by `client.buckets.preview()`. */
34
+ export interface PreviewBucketParams extends ProjectScopedParams {
35
+ /** Defaults to `STARTER`. */
36
+ tier?: BucketTier;
37
+ }
38
+ /** Arguments accepted by `client.buckets.create()`. */
39
+ export interface CreateBucketParams extends PreviewBucketParams {
40
+ /** 3–33 lowercase letters, digits and hyphens; unique in the project. */
41
+ name: string;
42
+ /** An AWS region, e.g. `eu-north-1`. */
43
+ region: string;
44
+ publicAccess?: boolean;
45
+ versioning?: boolean;
46
+ /** Needs `publicAccess`. CDN traffic is metered on top of the tier. */
47
+ cdnEnabled?: boolean;
48
+ }
49
+ export type PreviewBucketResponse = Envelope<CheckoutPreview>;
50
+ export type CreateBucketResponse = Envelope<{
51
+ deployed: true;
52
+ }>;
30
53
  /** Read operations on a project's buckets. The API has no single-bucket read. */
31
54
  export declare class BucketsService {
32
55
  private readonly transport;
@@ -41,5 +64,20 @@ export declare class BucketsService {
41
64
  delete(bucketId: string, params?: ProjectScopedParams): Promise<DeleteBucketResponse>;
42
65
  /** Builds the collection route for the resolved project. */
43
66
  private basePath;
67
+ /**
68
+ * Prices a bucket's tier before ordering it. CDN traffic is metered and not
69
+ * included. `monthly` is exact; `dueToday` is an estimate once the project
70
+ * has a subscription.
71
+ */
72
+ preview(params?: PreviewBucketParams): Promise<PreviewBucketResponse>;
73
+ /**
74
+ * Orders a bucket. It is ready when this returns; names are unique, so list
75
+ * and match the name to read it.
76
+ *
77
+ * Charges the project's saved card immediately, with a prorated invoice. It
78
+ * is refused with 402 before anything is created when the project cannot be
79
+ * billed.
80
+ */
81
+ create(params: CreateBucketParams): Promise<CreateBucketResponse>;
44
82
  }
45
83
  export {};
@@ -0,0 +1,106 @@
1
+ /**
2
+ * Catalog service namespace — the sizes, plans and regions paid resources are
3
+ * ordered with. Account-level: it never uses the client's default project.
4
+ */
5
+ import type { Transport } from "../transport";
6
+ /** A server size. */
7
+ export interface ServerSize {
8
+ slug: string;
9
+ description: string;
10
+ vcpus: number;
11
+ memoryMb: number;
12
+ diskGb: number;
13
+ transferTb: number;
14
+ /** Whole dollars. */
15
+ priceMonthly: number;
16
+ priceHourly: number;
17
+ }
18
+ /** A region a resource can be created in. */
19
+ export interface CatalogRegion {
20
+ slug: string;
21
+ name: string;
22
+ features?: string[];
23
+ }
24
+ /** A Redis plan. */
25
+ export interface RedisPlan {
26
+ slug: string;
27
+ name: string;
28
+ provider: string;
29
+ engine: string;
30
+ planType: string;
31
+ memoryMb: number;
32
+ throughputOps: number | null;
33
+ cpuMilli: number | null;
34
+ supportsReplication: boolean;
35
+ supportsPersistence: boolean;
36
+ /** Dollars. */
37
+ priceMonthly: number;
38
+ }
39
+ /** A dedicated database size. */
40
+ export interface DatabaseSize {
41
+ slug: string;
42
+ description: string;
43
+ nodeClass: string;
44
+ vcpus: number;
45
+ memoryMb: number;
46
+ diskGb: number;
47
+ /** Dollars. */
48
+ priceMonthly: number;
49
+ numNodes: number;
50
+ }
51
+ /** What dedicated databases can be created with. */
52
+ export interface DatabaseCatalog {
53
+ provider: string;
54
+ sizes: DatabaseSize[];
55
+ engines: Array<{
56
+ engine: string;
57
+ versions: string[];
58
+ }>;
59
+ regions: CatalogRegion[];
60
+ storage: unknown;
61
+ }
62
+ /** An app size, with the API's own snake_case keys. */
63
+ export interface AppSize {
64
+ name: string;
65
+ slug: string;
66
+ tier_slug: string;
67
+ cpu_type: string;
68
+ cpus: string | number;
69
+ memory_bytes: string | number;
70
+ bandwidth_allowance_gib?: string | number;
71
+ /** Dollars, as a string. */
72
+ usd_per_month: string;
73
+ }
74
+ interface Envelope<T> {
75
+ success: true;
76
+ data: T;
77
+ }
78
+ export type ListServerSizesResponse = Envelope<ServerSize[]>;
79
+ export type ListRegionsResponse = Envelope<CatalogRegion[]>;
80
+ export type ListServerImagesResponse = Envelope<Array<Record<string, unknown>>>;
81
+ export type ListRedisPlansResponse = Envelope<RedisPlan[]>;
82
+ export type GetDatabaseCatalogResponse = Envelope<DatabaseCatalog>;
83
+ export type ListAppSizesResponse = Envelope<AppSize[]>;
84
+ export type ListAppRegionsResponse = Envelope<Array<Record<string, unknown>>>;
85
+ /** Read-only lookups of what can be ordered. Any credential may call them. */
86
+ export declare class CatalogService {
87
+ private readonly transport;
88
+ constructor(transport: Transport);
89
+ /** Lists server sizes and their prices. */
90
+ serverSizes(): Promise<ListServerSizesResponse>;
91
+ /** Lists the regions servers can be created in. */
92
+ serverRegions(): Promise<ListRegionsResponse>;
93
+ /** Lists the one-click images a server can be created from. */
94
+ serverImages(): Promise<ListServerImagesResponse>;
95
+ /** Lists Redis plans and their prices. */
96
+ redisPlans(): Promise<ListRedisPlansResponse>;
97
+ /** Lists the regions Redis can be created in. */
98
+ redisRegions(): Promise<ListRegionsResponse>;
99
+ /** Lists dedicated database sizes, engines with their versions, and regions. */
100
+ databases(): Promise<GetDatabaseCatalogResponse>;
101
+ /** Lists app sizes and their prices. */
102
+ appSizes(): Promise<ListAppSizesResponse>;
103
+ /** Lists the regions apps can be created in. */
104
+ appRegions(): Promise<ListAppRegionsResponse>;
105
+ }
106
+ export {};
@@ -1,5 +1,6 @@
1
1
  /** Databases service namespace — a project's dedicated and shared databases. */
2
2
  import { type ResolvedConfig } from "../config";
3
+ import type { CheckoutPreview } from "./preview";
3
4
  import type { Transport } from "../transport";
4
5
  /** One database of any kind, as the project overview lists it. */
5
6
  export interface DatabaseSummary {
@@ -83,6 +84,25 @@ export type GetDedicatedDatabaseResponse = Envelope<DedicatedDatabaseDetail>;
83
84
  export type ListSharedDatabasesResponse = Envelope<SharedDatabase[]>;
84
85
  export type GetSharedDatabaseResponse = Envelope<SharedDatabase>;
85
86
  export type DeleteDatabaseResponse = Envelope<Record<string, never>>;
87
+ /** Arguments accepted by `client.databases.previewDedicated()`. */
88
+ export interface PreviewDedicatedDatabaseParams extends ProjectScopedParams {
89
+ /** A size slug from `client.catalog.databases()`. */
90
+ size: string;
91
+ }
92
+ /** Arguments accepted by `client.databases.createDedicated()`. */
93
+ export interface CreateDedicatedDatabaseParams extends PreviewDedicatedDatabaseParams {
94
+ name: string;
95
+ /** An engine version from `client.catalog.databases()`, e.g. `"17"`. */
96
+ version: string;
97
+ /** A region slug from `client.catalog.databases()`. */
98
+ region: string;
99
+ /** Defaults to `POSTGRESQL`, the only engine on sale. */
100
+ engine?: string;
101
+ }
102
+ export type PreviewDedicatedDatabaseResponse = Envelope<CheckoutPreview>;
103
+ export type CreateDedicatedDatabaseResponse = Envelope<{
104
+ deployed: true;
105
+ }>;
86
106
  /** Read operations on a project's databases. */
87
107
  export declare class DatabasesService {
88
108
  private readonly transport;
@@ -107,5 +127,16 @@ export declare class DatabasesService {
107
127
  deleteDedicated(databaseId: string, params?: ProjectScopedParams): Promise<DeleteDatabaseResponse>;
108
128
  /** Permanently deletes a shared database and its data, and stops its billing. */
109
129
  deleteShared(tenantId: string, params?: ProjectScopedParams): Promise<DeleteDatabaseResponse>;
130
+ /** Prices a dedicated database before ordering it. `monthly` is exact; `dueToday` is an estimate once the project has a subscription. */
131
+ previewDedicated(params: PreviewDedicatedDatabaseParams): Promise<PreviewDedicatedDatabaseResponse>;
132
+ /**
133
+ * Orders a dedicated database. It starts `CREATING`; the response carries
134
+ * no id, so list and match the name to follow it.
135
+ *
136
+ * Charges the project's saved card immediately, with a prorated invoice. It
137
+ * is refused with 402 before anything is created when the project cannot be
138
+ * billed.
139
+ */
140
+ createDedicated(params: CreateDedicatedDatabaseParams): Promise<CreateDedicatedDatabaseResponse>;
110
141
  }
111
142
  export {};