@cosmoner/sdk 1.8.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/README.md CHANGED
@@ -139,33 +139,53 @@ const { data: access } = await client.hosting.access(sites[0].id);
139
139
  `sftpPassword`. It needs no scope beyond `hosting:read`, so guard the key
140
140
  accordingly.
141
141
 
142
- ## Read-only namespaces
142
+ ## Resource namespaces
143
143
 
144
- Each of these reads one kind of resource and returns the API envelope. Every
145
- method takes `{ projectId }` to override the client default, except
144
+ Each of these works on one kind of resource and returns the API envelope.
145
+ Every method takes `{ projectId }` to override the client default, except
146
146
  `projects`, which reads across the account and never uses the default project.
147
147
  A method taking an id rejects an empty one before sending anything.
148
148
 
149
- | Namespace | Methods |
150
- | --- | --- |
151
- | `projects` | `list()`, `get(project)` — by id or slug |
152
- | `apps` | `get(appId)`, `logs(appId, { type: "BUILD" \| "RUN" })`, alongside `list()` and the deploy methods |
153
- | `servers` | `list()`, `get(serverId)` — adds the installed `sshKeys` |
154
- | `sshKeys` | `list()` |
155
- | `databases` | `list()` (every kind), `listDedicated()`, `getDedicated(databaseId)`, `listShared()`, `getShared(tenantId)` |
156
- | `redis` | `list()`, `get(redisId)` |
157
- | `domains` | `list()`, `get(domain)` — by id or name, such as `example.com` |
158
- | `buckets` | `list()` — there is no single-bucket read |
159
- | `registries` | `list()`, `get(registryId)` |
160
- | `iam` | `list()`, `get(iamUserName)` — the list holds `credentials` plus partial-failure `errors` |
161
- | `members` | `list()` — members and pending invitations |
162
- | `email` | `listDomains()`, `getDomain(emailDomainId)`, alongside `send()` |
149
+ | Namespace | Read | Change |
150
+ | --- | --- | --- |
151
+ | `projects` | `list()`, `get(project)` — by id or slug | |
152
+ | `apps` | `get(appId)`, `logs(appId, { type: "BUILD" \| "RUN" })`, alongside `list()` and the deploy methods | `update(appId, changes)`, `delete(appId)` |
153
+ | `servers` | `list()`, `get(serverId)` — adds the installed `sshKeys` | `delete(serverId)` |
154
+ | `sshKeys` | `list()` | `create({ name, publicKey })`, `delete(sshKeyId)` |
155
+ | `databases` | `list()` (every kind), `listDedicated()`, `getDedicated(databaseId)`, `listShared()`, `getShared(tenantId)` | `deleteDedicated(databaseId)`, `deleteShared(tenantId)` |
156
+ | `redis` | `list()`, `get(redisId)` | `delete(redisId)` |
157
+ | `domains` | `list()`, `get(domain)` — by id or name, such as `example.com` | `create(name)`, `verify(domain)`, `delete(domain)` |
158
+ | `buckets` | `list()` — there is no single-bucket read | `delete(bucketId)` |
159
+ | `registries` | `list()`, `get(registryId)` | `delete(registryId)` |
160
+ | `iam` | `list()`, `get(iamUserName)` — the list holds `credentials` plus partial-failure `errors` | `delete(iamUserName)` |
161
+ | `members` | `list()` — members and pending invitations | |
162
+ | `email` | `listDomains()`, `getDomain(emailDomainId)`, alongside `send()` | `deleteDomain(emailDomainId)` |
163
163
 
164
164
  Two of these return a credential, and each needs only the namespace's read
165
165
  scope, so guard keys that carry it: `databases.getDedicated` always includes
166
166
  `connectionUri`, a full connection URI with the password, and `redis.get`
167
167
  always includes the plaintext `password`.
168
168
 
169
+ ### Ordering paid resources
170
+
171
+ `servers.create`, `redis.create`, `databases.createDedicated`,
172
+ `buckets.create`, `registries.create`, `hosting.create`, `apps.create` and
173
+ `apps.resize` charge the project's saved card at once, and are refused with a
174
+ 402 before anything is created when the project cannot be billed. Each has a
175
+ `preview` (`previewDedicated`, `resizePreview`) that returns the price first:
176
+ `monthly` is exact, `dueToday` an estimate once the project has a
177
+ subscription. `client.catalog` lists the sizes, plans and regions to order
178
+ with, and needs no project. An app is ordered in two calls: `createDraft`
179
+ saves what it should be, for free, and `create` turns the draft into a billed
180
+ app.
181
+
182
+ Deletes are permanent, and a delete of a billed resource stops its billing.
183
+ `apps.update` changes settings only, for free; it leaves environment variables
184
+ to the deployment file. `domains.create` adds a domain you already own: publish
185
+ the returned `verificationRecord`, then call `verify`. Deleting an SSH key
186
+ leaves it on servers it was already installed on — `stillAuthorisedOn` counts
187
+ them.
188
+
169
189
  ## Secrets
170
190
 
171
191
  Stores the values a deployment file refers to with `from_secret`. Needs an API
package/dist/client.d.ts CHANGED
@@ -2,6 +2,7 @@
2
2
  import { type CosmonerConfig } from "./config";
3
3
  import { AppsService } from "./services/apps";
4
4
  import { BucketsService } from "./services/buckets";
5
+ import { CatalogService } from "./services/catalog";
5
6
  import { DatabasesService } from "./services/databases";
6
7
  import { DomainsService } from "./services/domains";
7
8
  import { EmailService } from "./services/email";
@@ -46,6 +47,8 @@ export declare class Cosmoner {
46
47
  readonly members: MembersService;
47
48
  /** Account-level: never uses the client's default project. */
48
49
  readonly projects: ProjectsService;
50
+ /** Sizes, plans and regions to order with. Account-level. */
51
+ readonly catalog: CatalogService;
49
52
  readonly redis: RedisService;
50
53
  readonly registries: RegistriesService;
51
54
  readonly secrets: SecretsService;
package/dist/index.d.ts CHANGED
@@ -5,19 +5,21 @@ export { AuthenticationError, ConflictError, CosmonerConnectionError, CosmonerEr
5
5
  export { APP_SCHEMA_URL, DEPLOYMENT_FILE_PATHS, DEPLOYMENT_KEY_ORDER, DEPLOYMENT_VERSION, MAX_DEPLOYMENT_BYTES, } from "./deployment/spec";
6
6
  export { validateDeployment, validateDeploymentDocument, } from "./deployment/validate";
7
7
  export type { DeploymentBuild, DeploymentEnvVar, DeploymentIssue, DeploymentIssueSeverity, DeploymentService, DeploymentTemplate, DeploymentValidationResult, ValidateDeploymentOptions, } from "./deployment/types";
8
- export { AppsService, FINISHED_DEPLOYMENT_PHASES, type App, type AppDeployment, type AppLogLine, type AppLogType, type AppLogsParams, type AppLogsResponse, type AppStatus, type DeployAppParams, type DeployAppResponse, type DeploymentPhase, type GetAppResponse, type GetDeploymentResponse, type ImageDeployPolicy, type ListAppsResponse, type WaitForDeploymentParams, } from "./services/apps";
9
- export { BucketsService, type Bucket, type ListBucketsResponse } from "./services/buckets";
10
- export { DatabasesService, type DatabaseSummary, type DedicatedDatabase, type DedicatedDatabaseDetail, type GetDedicatedDatabaseResponse, type GetSharedDatabaseResponse, type ListDatabasesResponse, type ListDedicatedDatabasesResponse, type ListSharedDatabasesResponse, type SharedDatabase, } from "./services/databases";
11
- export { DomainsService, type DnsRecord, type Domain, type GetDomainResponse, type ListDomainsResponse, } from "./services/domains";
8
+ export { AppsService, FINISHED_DEPLOYMENT_PHASES, type App, type AppDeployment, type AppLogLine, type AppLogType, type AppLogsParams, type AppLogsResponse, type AppSizes, type AppStatus, type CreateAppDraftParams, type CreateAppDraftResponse, type CreateAppParams, type CreateAppResponse, type DeleteAppResponse, type DeployAppParams, type DeployAppResponse, type DeploymentPhase, type GetAppResponse, type GetAppSizesResponse, type GetDeploymentResponse, type ImageDeployPolicy, type ListAppsResponse, type PreviewAppResizeResponse, type PreviewAppResponse, type ResizeAppResponse, type UpdateAppParams, type UpdateAppResponse, type WaitForDeploymentParams, } from "./services/apps";
9
+ export { BucketsService, type Bucket, type BucketTier, type CreateBucketParams, type CreateBucketResponse, type DeleteBucketResponse, type ListBucketsResponse, type PreviewBucketParams, type PreviewBucketResponse, } from "./services/buckets";
10
+ export { CatalogService, type AppSize, type CatalogRegion, type DatabaseCatalog, type DatabaseSize, type GetDatabaseCatalogResponse, type ListAppRegionsResponse, type ListAppSizesResponse, type ListRedisPlansResponse, type ListRegionsResponse, type ListServerImagesResponse, type ListServerSizesResponse, type RedisPlan, type ServerSize, } from "./services/catalog";
11
+ export { DatabasesService, type CreateDedicatedDatabaseParams, type CreateDedicatedDatabaseResponse, type DatabaseSummary, type DedicatedDatabase, type DedicatedDatabaseDetail, type DeleteDatabaseResponse, type GetDedicatedDatabaseResponse, type GetSharedDatabaseResponse, type ListDatabasesResponse, type ListDedicatedDatabasesResponse, type ListSharedDatabasesResponse, type PreviewDedicatedDatabaseParams, type PreviewDedicatedDatabaseResponse, type SharedDatabase, } from "./services/databases";
12
+ export { DomainsService, type CreateDomainResponse, type DeleteDomainResponse, type DnsRecord, type Domain, type GetDomainResponse, type ListDomainsResponse, type VerificationRecord, type VerifyDomainResponse, } from "./services/domains";
12
13
  export { EmailService, type EmailDomain, type EmailDomainDetail, type GetEmailDomainResponse, type ListEmailDomainsResponse, type SendEmailParams, type SendEmailResponse, } from "./services/email";
13
- export { HostingService, type GetHostingAccessResponse, type GetHostingSiteParams, type GetHostingSiteResponse, type GetHostingSiteWithCredentialsResponse, type HostingAccess, type HostingSite, type HostingSiteStatus, type HostingSiteWithCredentials, type ListHostingSitesResponse, } from "./services/hosting";
14
+ export { HostingService, type CreateHostingSiteParams, type CreateHostingSiteResponse, type DeleteHostingSiteResponse, type GetHostingAccessResponse, type GetHostingSiteParams, type GetHostingSiteResponse, type GetHostingSiteWithCredentialsResponse, type HostingAccess, type HostingPrice, type HostingSite, type HostingSiteStatus, type HostingSiteWithCredentials, type HostingTier, type ListHostingPricesResponse, type ListHostingSitesResponse, type PreviewHostingSiteParams, type PreviewHostingSiteResponse, } from "./services/hosting";
14
15
  export { IamService, type GetIamCredentialResponse, type IamCredential, type IamCredentialList, type ListIamCredentialsResponse, } from "./services/iam";
15
16
  export { MembersService, type ListMembersResponse, type ProjectMember, type ProjectMembers } from "./services/members";
17
+ export type { CheckoutPreview, PlanChangePreview } from "./services/preview";
16
18
  export { ProjectsService, type GetProjectResponse, type ListProjectsResponse, type Project } from "./services/projects";
17
- export { RedisService, type GetRedisDatabaseResponse, type ListRedisDatabasesResponse, type RedisDatabase, type RedisDatabaseDetail, } from "./services/redis";
18
- export { RegistriesService, type GetRegistryResponse, type ListRegistriesResponse, type Registry, type RegistryRepository, } from "./services/registries";
19
- export { ServersService, type GetServerResponse, type ListServersResponse, type Server, type ServerDetail, type ServerStatus, } from "./services/servers";
20
- export { SshKeysService, type ListSshKeysResponse, type SshKey } from "./services/ssh-keys";
19
+ export { RedisService, type CreateRedisParams, type CreateRedisResponse, type DeleteRedisDatabaseResponse, type GetRedisDatabaseResponse, type ListRedisDatabasesResponse, type PreviewRedisParams, type PreviewRedisResponse, type RedisDatabase, type RedisDatabaseDetail, type RedisPersistence, } from "./services/redis";
20
+ export { RegistriesService, type CreateRegistryParams, type CreateRegistryResponse, type DeleteRegistryResponse, type GetRegistryResponse, type ListRegistriesResponse, type ListRegistryProvidersResponse, type PreviewRegistryResponse, type Registry, type RegistryProvider, type RegistryRepository, } from "./services/registries";
21
+ export { ServersService, type CreateServerParams, type CreateServerResponse, type DeleteServerResponse, type GetServerResponse, type ListServersResponse, type PreviewServerParams, type PreviewServerResponse, type Server, type ServerDetail, type ServerStatus, } from "./services/servers";
22
+ export { SshKeysService, type CreateSshKeyParams, type CreateSshKeyResponse, type DeleteSshKeyResponse, type ListSshKeysResponse, type SshKey, } from "./services/ssh-keys";
21
23
  export { PROJECT_ENVIRONMENTS, type Actor, type ProjectEnvironment, } from "./services/project-config";
22
24
  export { SecretsService, type CreateSecretParams, type GetSecretAuditResponse, type GetSecretResponse, type GetSecretsUsageResponse, type ListSecretsParams, type ListSecretsResponse, type ProjectSecret, type RevealedProjectSecret, type SecretAuditEntry, type SecretsUsage, type SetSecretResponse, type UpdateSecretParams, } from "./services/secrets";
23
25
  export { VariablesService, type CreateVariableParams, type GetVariableResponse, type ListVariablesParams, type ListVariablesResponse, type ProjectVariable, type SetVariableResponse, type UpdateVariableParams, } from "./services/variables";
package/dist/index.js CHANGED
@@ -24,6 +24,7 @@ __export(index_exports, {
24
24
  AppsService: () => AppsService,
25
25
  AuthenticationError: () => AuthenticationError,
26
26
  BucketsService: () => BucketsService,
27
+ CatalogService: () => CatalogService,
27
28
  ConflictError: () => ConflictError,
28
29
  Cosmoner: () => Cosmoner,
29
30
  CosmonerConnectionError: () => CosmonerConnectionError,
@@ -202,6 +203,85 @@ var AppsService = class {
202
203
  await new Promise((resolve) => setTimeout(resolve, Math.min(interval, remaining)));
203
204
  }
204
205
  }
206
+ /**
207
+ * Changes an app's settings and applies them to the running app.
208
+ *
209
+ * Free: resizing, which is billed, is a separate call. The API answers 502
210
+ * when the settings were saved but the runtime refused them.
211
+ */
212
+ async update(appId, params) {
213
+ if (!appId) throw new Error("appId is required");
214
+ const { projectId, ...changes } = params ?? {};
215
+ const body = Object.fromEntries(Object.entries(changes).filter(([, value]) => value !== void 0));
216
+ if (Object.keys(body).length === 0) throw new Error("at least one change is required");
217
+ return this.transport.request("PATCH", `${this.basePath(projectId)}/${appId}`, { body });
218
+ }
219
+ /**
220
+ * Permanently deletes an app: its runtime, routing, custom hostname and
221
+ * billing, then the app itself. Its deployments go with it.
222
+ */
223
+ async delete(appId, params = {}) {
224
+ if (!appId) throw new Error("appId is required");
225
+ return this.transport.request("DELETE", `${this.basePath(params.projectId)}/${appId}`);
226
+ }
227
+ /** Prices an app of a size before ordering it. `monthly` is exact; `dueToday` is an estimate once the project has a subscription. */
228
+ async preview(params) {
229
+ if (!params?.size) throw new Error("size is required");
230
+ return this.transport.request("GET", `${this.basePath(params.projectId)}/preview`, {
231
+ query: { size: params.size }
232
+ });
233
+ }
234
+ /**
235
+ * Saves what an app should be, without creating or billing anything. The
236
+ * draft expires after 24 hours; `create()` turns it into an app. The app
237
+ * gets a Cosmoner subdomain.
238
+ */
239
+ async createDraft(params) {
240
+ if (!params?.name) throw new Error("name is required");
241
+ if (!params.size) throw new Error("size is required");
242
+ if (!params.region) throw new Error("region is required");
243
+ const { projectId, ...fields } = params;
244
+ return this.transport.request("POST", `${this.basePath(projectId)}/draft`, {
245
+ body: { ...fields, domainType: "cosmoner" }
246
+ });
247
+ }
248
+ /**
249
+ * Creates and deploys the app a draft describes. It starts `DEPLOYING`.
250
+ *
251
+ * Charges the project's saved card immediately, with a prorated invoice. It
252
+ * is refused with 402 before anything is created when the project cannot be
253
+ * billed.
254
+ */
255
+ async create(params) {
256
+ if (!params?.draftId) throw new Error("draftId is required");
257
+ if (!params.size) throw new Error("size is required");
258
+ return this.transport.request("POST", this.basePath(params.projectId), {
259
+ body: { draftId: params.draftId, size: params.size }
260
+ });
261
+ }
262
+ /** Lists the sizes an app can move to, and whether it can be resized at all. */
263
+ async sizes(appId, params = {}) {
264
+ if (!appId) throw new Error("appId is required");
265
+ return this.transport.request("GET", `${this.basePath(params.projectId)}/${appId}/sizes`);
266
+ }
267
+ /** Prices moving an app to another size. */
268
+ async resizePreview(appId, params) {
269
+ if (!appId) throw new Error("appId is required");
270
+ if (!params?.size) throw new Error("size is required");
271
+ return this.transport.request(
272
+ "GET",
273
+ `${this.basePath(params.projectId)}/${appId}/resize-preview`,
274
+ { query: { size: params.size } }
275
+ );
276
+ }
277
+ /** Moves an app to another size. Charges the difference to the saved card immediately. */
278
+ async resize(appId, params) {
279
+ if (!appId) throw new Error("appId is required");
280
+ if (!params?.size) throw new Error("size is required");
281
+ return this.transport.request("PATCH", `${this.basePath(params.projectId)}/${appId}/size`, {
282
+ body: { size: params.size }
283
+ });
284
+ }
205
285
  };
206
286
 
207
287
  // src/services/buckets.ts
@@ -212,10 +292,91 @@ var BucketsService = class {
212
292
  }
213
293
  /** Lists every bucket in the project. */
214
294
  async list(params = {}) {
215
- return this.transport.request(
216
- "GET",
217
- `/v1/projects/${resolveProjectId(this.config, params.projectId)}/storage/object-storage`
218
- );
295
+ return this.transport.request("GET", this.basePath(params.projectId));
296
+ }
297
+ /**
298
+ * Permanently deletes a bucket with every object in it and the access
299
+ * credentials made for it, and stops its billing.
300
+ */
301
+ async delete(bucketId, params = {}) {
302
+ if (!bucketId) throw new Error("bucketId is required");
303
+ return this.transport.request("DELETE", `${this.basePath(params.projectId)}/${bucketId}`);
304
+ }
305
+ /** Builds the collection route for the resolved project. */
306
+ basePath(projectId) {
307
+ return `/v1/projects/${resolveProjectId(this.config, projectId)}/storage/object-storage`;
308
+ }
309
+ /**
310
+ * Prices a bucket's tier before ordering it. CDN traffic is metered and not
311
+ * included. `monthly` is exact; `dueToday` is an estimate once the project
312
+ * has a subscription.
313
+ */
314
+ async preview(params = {}) {
315
+ return this.transport.request("GET", `${this.basePath(params.projectId)}/preview`, {
316
+ query: { provider: "AWS_S3", tier: params.tier ?? "STARTER" }
317
+ });
318
+ }
319
+ /**
320
+ * Orders a bucket. It is ready when this returns; names are unique, so list
321
+ * and match the name to read it.
322
+ *
323
+ * Charges the project's saved card immediately, with a prorated invoice. It
324
+ * is refused with 402 before anything is created when the project cannot be
325
+ * billed.
326
+ */
327
+ async create(params) {
328
+ if (!params?.name) throw new Error("name is required");
329
+ if (!params.region) throw new Error("region is required");
330
+ return this.transport.request("POST", this.basePath(params.projectId), {
331
+ body: {
332
+ name: params.name,
333
+ provider: "AWS_S3",
334
+ region: params.region,
335
+ tier: params.tier,
336
+ publicAccess: params.publicAccess,
337
+ versioning: params.versioning,
338
+ cdnEnabled: params.cdnEnabled
339
+ }
340
+ });
341
+ }
342
+ };
343
+
344
+ // src/services/catalog.ts
345
+ var CatalogService = class {
346
+ constructor(transport) {
347
+ this.transport = transport;
348
+ }
349
+ /** Lists server sizes and their prices. */
350
+ async serverSizes() {
351
+ return this.transport.request("GET", "/v1/catalog/servers/sizes");
352
+ }
353
+ /** Lists the regions servers can be created in. */
354
+ async serverRegions() {
355
+ return this.transport.request("GET", "/v1/catalog/servers/regions");
356
+ }
357
+ /** Lists the one-click images a server can be created from. */
358
+ async serverImages() {
359
+ return this.transport.request("GET", "/v1/catalog/servers/1-clicks");
360
+ }
361
+ /** Lists Redis plans and their prices. */
362
+ async redisPlans() {
363
+ return this.transport.request("GET", "/v1/catalog/redis/plans");
364
+ }
365
+ /** Lists the regions Redis can be created in. */
366
+ async redisRegions() {
367
+ return this.transport.request("GET", "/v1/catalog/redis/regions");
368
+ }
369
+ /** Lists dedicated database sizes, engines with their versions, and regions. */
370
+ async databases() {
371
+ return this.transport.request("GET", "/v1/catalog/databases");
372
+ }
373
+ /** Lists app sizes and their prices. */
374
+ async appSizes() {
375
+ return this.transport.request("GET", "/v1/catalog/apps/sizes");
376
+ }
377
+ /** Lists the regions apps can be created in. */
378
+ async appRegions() {
379
+ return this.transport.request("GET", "/v1/catalog/apps/regions");
219
380
  }
220
381
  };
221
382
 
@@ -257,6 +418,58 @@ var DatabasesService = class {
257
418
  if (!tenantId) throw new Error("tenantId is required");
258
419
  return this.transport.request("GET", `${this.basePath(params.projectId)}/shared/${tenantId}`);
259
420
  }
421
+ /** Permanently deletes a dedicated database cluster and its data, and stops its billing. */
422
+ async deleteDedicated(databaseId, params = {}) {
423
+ if (!databaseId) throw new Error("databaseId is required");
424
+ return this.transport.request(
425
+ "DELETE",
426
+ `${this.basePath(params.projectId)}/dedicated/${databaseId}`
427
+ );
428
+ }
429
+ /** Permanently deletes a shared database and its data, and stops its billing. */
430
+ async deleteShared(tenantId, params = {}) {
431
+ if (!tenantId) throw new Error("tenantId is required");
432
+ return this.transport.request(
433
+ "DELETE",
434
+ `${this.basePath(params.projectId)}/shared/${tenantId}`
435
+ );
436
+ }
437
+ /** Prices a dedicated database before ordering it. `monthly` is exact; `dueToday` is an estimate once the project has a subscription. */
438
+ async previewDedicated(params) {
439
+ if (!params?.size) throw new Error("size is required");
440
+ return this.transport.request(
441
+ "GET",
442
+ `${this.basePath(params.projectId)}/dedicated/preview`,
443
+ { query: { slug: params.size } }
444
+ );
445
+ }
446
+ /**
447
+ * Orders a dedicated database. It starts `CREATING`; the response carries
448
+ * no id, so list and match the name to follow it.
449
+ *
450
+ * Charges the project's saved card immediately, with a prorated invoice. It
451
+ * is refused with 402 before anything is created when the project cannot be
452
+ * billed.
453
+ */
454
+ async createDedicated(params) {
455
+ if (!params?.name) throw new Error("name is required");
456
+ if (!params.size) throw new Error("size is required");
457
+ if (!params.version) throw new Error("version is required");
458
+ if (!params.region) throw new Error("region is required");
459
+ return this.transport.request(
460
+ "POST",
461
+ `${this.basePath(params.projectId)}/dedicated`,
462
+ {
463
+ body: {
464
+ name: params.name,
465
+ engine: params.engine ?? "POSTGRESQL",
466
+ version: params.version,
467
+ slug: params.size,
468
+ region: params.region
469
+ }
470
+ }
471
+ );
472
+ }
260
473
  };
261
474
 
262
475
  // src/services/domains.ts
@@ -281,6 +494,36 @@ var DomainsService = class {
281
494
  `${this.basePath(params.projectId)}/${encodeURIComponent(domain)}`
282
495
  );
283
496
  }
497
+ /**
498
+ * Adds a domain you already own, e.g. `example.com`. Free. Publish the
499
+ * returned `verificationRecord`, then call `verify()`. Buying a domain is not
500
+ * part of the SDK.
501
+ */
502
+ async create(name, params = {}) {
503
+ if (!name) throw new Error("name is required");
504
+ return this.transport.request("POST", this.basePath(params.projectId), {
505
+ body: { name, type: "EXTERNAL" }
506
+ });
507
+ }
508
+ /** Checks a domain's verification record, by domain id or name. */
509
+ async verify(domain, params = {}) {
510
+ if (!domain) throw new Error("domain is required");
511
+ return this.transport.request(
512
+ "POST",
513
+ `${this.basePath(params.projectId)}/${encodeURIComponent(domain)}/verify`
514
+ );
515
+ }
516
+ /**
517
+ * Removes a domain and its DNS records, by id or name. Refused with 409
518
+ * while an app or an email domain uses it.
519
+ */
520
+ async delete(domain, params = {}) {
521
+ if (!domain) throw new Error("domain is required");
522
+ return this.transport.request(
523
+ "DELETE",
524
+ `${this.basePath(params.projectId)}/${encodeURIComponent(domain)}`
525
+ );
526
+ }
284
527
  };
285
528
 
286
529
  // src/services/email.ts
@@ -334,6 +577,17 @@ var EmailService = class {
334
577
  `/v1/projects/${resolveProjectId(this.config, params.projectId)}/email/${emailDomainId}`
335
578
  );
336
579
  }
580
+ /**
581
+ * Stops sending from a domain and removes it from email. The domain itself
582
+ * stays in the project. The API answers 204, so there is nothing to return.
583
+ */
584
+ async deleteDomain(emailDomainId, params = {}) {
585
+ if (!emailDomainId) throw new Error("emailDomainId is required");
586
+ await this.transport.request(
587
+ "DELETE",
588
+ `/v1/projects/${resolveProjectId(this.config, params.projectId)}/email/${emailDomainId}`
589
+ );
590
+ }
337
591
  };
338
592
 
339
593
  // src/services/hosting.ts
@@ -366,6 +620,41 @@ var HostingService = class {
366
620
  `${this.basePath(params.projectId)}/${siteId}/access`
367
621
  );
368
622
  }
623
+ /** Permanently deletes a hosting site with its files, databases and domains, and stops its billing. */
624
+ async delete(siteId, params = {}) {
625
+ if (!siteId) throw new Error("siteId is required");
626
+ return this.transport.request("DELETE", `${this.basePath(params.projectId)}/${siteId}`);
627
+ }
628
+ /** Lists hosting plans and their monthly prices. */
629
+ async prices(params = {}) {
630
+ return this.transport.request("GET", `${this.basePath(params.projectId)}/prices`);
631
+ }
632
+ /** Prices a site before ordering it. `monthly` is exact; `dueToday` is an estimate once the project has a subscription. */
633
+ async preview(params) {
634
+ if (!params?.tier) throw new Error("tier is required");
635
+ return this.transport.request("GET", `${this.basePath(params.projectId)}/preview`, {
636
+ query: { tier: params.tier, extraStorageGb: params.extraStorageGb ?? 0 }
637
+ });
638
+ }
639
+ /**
640
+ * Orders a hosting site, and its database when one is named.
641
+ *
642
+ * Charges the project's saved card immediately, with a prorated invoice. It
643
+ * is refused with 402 before anything is created when the project cannot be
644
+ * billed.
645
+ */
646
+ async create(params) {
647
+ if (!params?.siteName) throw new Error("siteName is required");
648
+ return this.transport.request("POST", this.basePath(params.projectId), {
649
+ body: {
650
+ siteName: params.siteName,
651
+ tier: params.tier,
652
+ phpVersion: params.phpVersion,
653
+ database: params.database === void 0 ? void 0 : { name: params.database },
654
+ extraStorageGb: params.extraStorageGb
655
+ }
656
+ });
657
+ }
369
658
  };
370
659
 
371
660
  // src/services/iam.ts
@@ -390,6 +679,14 @@ var IamService = class {
390
679
  `${this.basePath(params.projectId)}/${encodeURIComponent(iamUserName)}`
391
680
  );
392
681
  }
682
+ /**
683
+ * Deletes an IAM user and its access keys, by user name. Anything using the
684
+ * keys stops working. The API answers 204, so there is nothing to return.
685
+ */
686
+ async delete(iamUserName, params = {}) {
687
+ if (!iamUserName) throw new Error("iamUserName is required");
688
+ await this.transport.request("DELETE", `${this.basePath(params.projectId)}/${encodeURIComponent(iamUserName)}`);
689
+ }
393
690
  };
394
691
 
395
692
  // src/services/members.ts
@@ -442,6 +739,34 @@ var RedisService = class {
442
739
  if (!redisId) throw new Error("redisId is required");
443
740
  return this.transport.request("GET", `${this.basePath(params.projectId)}/${redisId}`);
444
741
  }
742
+ /** Permanently deletes a Redis database and its data, and stops its billing. */
743
+ async delete(redisId, params = {}) {
744
+ if (!redisId) throw new Error("redisId is required");
745
+ return this.transport.request("DELETE", `${this.basePath(params.projectId)}/${redisId}`);
746
+ }
747
+ /** Prices a Redis database before ordering it. `monthly` is exact; `dueToday` is an estimate once the project has a subscription. */
748
+ async preview(params) {
749
+ if (!params?.plan) throw new Error("plan is required");
750
+ return this.transport.request("GET", `${this.basePath(params.projectId)}/preview`, {
751
+ query: { planSlug: params.plan }
752
+ });
753
+ }
754
+ /**
755
+ * Orders a Redis database. It starts `CREATING`; the response carries no
756
+ * id, so list and match the name to follow it.
757
+ *
758
+ * Charges the project's saved card immediately, with a prorated invoice. It
759
+ * is refused with 402 before anything is created when the project cannot be
760
+ * billed.
761
+ */
762
+ async create(params) {
763
+ if (!params?.name) throw new Error("name is required");
764
+ if (!params.plan) throw new Error("plan is required");
765
+ if (!params.region) throw new Error("region is required");
766
+ return this.transport.request("POST", this.basePath(params.projectId), {
767
+ body: { name: params.name, planSlug: params.plan, region: params.region, dataPersistence: params.persistence }
768
+ });
769
+ }
445
770
  };
446
771
 
447
772
  // src/services/registries.ts
@@ -463,6 +788,37 @@ var RegistriesService = class {
463
788
  if (!registryId) throw new Error("registryId is required");
464
789
  return this.transport.request("GET", `${this.basePath(params.projectId)}/${registryId}`);
465
790
  }
791
+ /** Permanently deletes a registry with every repository and image in it, and stops its billing. */
792
+ async delete(registryId, params = {}) {
793
+ if (!registryId) throw new Error("registryId is required");
794
+ return this.transport.request("DELETE", `${this.basePath(params.projectId)}/${registryId}`);
795
+ }
796
+ /**
797
+ * Prices a registry's base fee before ordering it. Storage and egress are
798
+ * metered and not included. `monthly` is exact; `dueToday` is an estimate
799
+ * once the project has a subscription.
800
+ */
801
+ async preview(params = {}) {
802
+ return this.transport.request("GET", `${this.basePath(params.projectId)}/preview`);
803
+ }
804
+ /** Lists the providers a registry can be created with, and their regions. */
805
+ async providers(params = {}) {
806
+ return this.transport.request("GET", `${this.basePath(params.projectId)}/providers`);
807
+ }
808
+ /**
809
+ * Orders a registry. It is ready when this returns.
810
+ *
811
+ * Charges the project's saved card immediately, with a prorated invoice. It
812
+ * is refused with 402 before anything is created when the project cannot be
813
+ * billed.
814
+ */
815
+ async create(params) {
816
+ if (!params?.name) throw new Error("name is required");
817
+ if (!params.region) throw new Error("region is required");
818
+ return this.transport.request("POST", this.basePath(params.projectId), {
819
+ body: { name: params.name, region: params.region, provider: params.provider }
820
+ });
821
+ }
466
822
  };
467
823
 
468
824
  // src/services/project-config.ts
@@ -590,6 +946,41 @@ var ServersService = class {
590
946
  if (!serverId) throw new Error("serverId is required");
591
947
  return this.transport.request("GET", `${this.basePath(params.projectId)}/${serverId}`);
592
948
  }
949
+ /** Permanently deletes a server and its disk, and stops its billing. */
950
+ async delete(serverId, params = {}) {
951
+ if (!serverId) throw new Error("serverId is required");
952
+ return this.transport.request("DELETE", `${this.basePath(params.projectId)}/${serverId}`);
953
+ }
954
+ /** Prices a server before ordering it. `monthly` is exact; `dueToday` is an estimate once the project has a subscription. */
955
+ async preview(params) {
956
+ if (!params?.size) throw new Error("size is required");
957
+ return this.transport.request("GET", `${this.basePath(params.projectId)}/preview`, {
958
+ query: { provider: params.provider ?? "digitalocean", slug: params.size }
959
+ });
960
+ }
961
+ /**
962
+ * Orders a server. It starts `PROVISIONING`; the response carries no id, so
963
+ * list servers and match the name to follow it.
964
+ *
965
+ * Charges the project's saved card immediately, with a prorated invoice. It
966
+ * is refused with 402 before anything is created when the project cannot be
967
+ * billed.
968
+ */
969
+ async create(params) {
970
+ if (!params?.name) throw new Error("name is required");
971
+ if (!params.size) throw new Error("size is required");
972
+ if (!params.region) throw new Error("region is required");
973
+ return this.transport.request("POST", this.basePath(params.projectId), {
974
+ body: {
975
+ name: params.name,
976
+ slug: params.size,
977
+ provider: params.provider ?? "digitalocean",
978
+ region: params.region,
979
+ template: params.image,
980
+ sshKeyIds: params.sshKeyIds
981
+ }
982
+ });
983
+ }
593
984
  };
594
985
 
595
986
  // src/services/ssh-keys.ts
@@ -600,10 +991,27 @@ var SshKeysService = class {
600
991
  }
601
992
  /** Lists every SSH key in the project. */
602
993
  async list(params = {}) {
603
- return this.transport.request(
604
- "GET",
605
- `/v1/projects/${resolveProjectId(this.config, params.projectId)}/ssh-keys`
606
- );
994
+ return this.transport.request("GET", this.basePath(params.projectId));
995
+ }
996
+ /** Adds a public key to the project, for installing on servers created later. */
997
+ async create(params) {
998
+ if (!params?.name) throw new Error("name is required");
999
+ if (!params.publicKey) throw new Error("publicKey is required");
1000
+ return this.transport.request("POST", this.basePath(params.projectId), {
1001
+ body: { name: params.name, publicKey: params.publicKey }
1002
+ });
1003
+ }
1004
+ /**
1005
+ * Removes a key from the project. Servers it was already installed on keep
1006
+ * accepting it; `stillAuthorisedOn` says how many.
1007
+ */
1008
+ async delete(sshKeyId, params = {}) {
1009
+ if (!sshKeyId) throw new Error("sshKeyId is required");
1010
+ return this.transport.request("DELETE", `${this.basePath(params.projectId)}/${sshKeyId}`);
1011
+ }
1012
+ /** Builds the collection route for the resolved project. */
1013
+ basePath(projectId) {
1014
+ return `/v1/projects/${resolveProjectId(this.config, projectId)}/ssh-keys`;
607
1015
  }
608
1016
  };
609
1017
 
@@ -1053,7 +1461,7 @@ function sleep(ms) {
1053
1461
  }
1054
1462
 
1055
1463
  // src/version.ts
1056
- var VERSION = "1.8.0";
1464
+ var VERSION = "1.10.0";
1057
1465
  var USER_AGENT = `cosmoner-node/${VERSION}`;
1058
1466
 
1059
1467
  // src/transport.ts
@@ -1185,6 +1593,7 @@ var Cosmoner = class {
1185
1593
  this.iam = new IamService(this.transport, this.config);
1186
1594
  this.members = new MembersService(this.transport, this.config);
1187
1595
  this.projects = new ProjectsService(this.transport);
1596
+ this.catalog = new CatalogService(this.transport);
1188
1597
  this.redis = new RedisService(this.transport, this.config);
1189
1598
  this.registries = new RegistriesService(this.transport, this.config);
1190
1599
  this.secrets = new SecretsService(this.transport, this.config);
@@ -1534,6 +1943,7 @@ var index_default = Cosmoner;
1534
1943
  AppsService,
1535
1944
  AuthenticationError,
1536
1945
  BucketsService,
1946
+ CatalogService,
1537
1947
  ConflictError,
1538
1948
  Cosmoner,
1539
1949
  CosmonerConnectionError,