@cosmoner/sdk 1.8.0 → 1.9.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,40 @@ 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
+ Deletes are permanent, and a delete of a billed resource stops its billing.
170
+ `apps.update` changes settings only, for free; it leaves environment variables
171
+ to the deployment file. `domains.create` adds a domain you already own: publish
172
+ the returned `verificationRecord`, then call `verify`. Deleting an SSH key
173
+ leaves it on servers it was already installed on — `stillAuthorisedOn` counts
174
+ them.
175
+
169
176
  ## Secrets
170
177
 
171
178
  Stores the values a deployment file refers to with `from_secret`. Needs an API
package/dist/index.d.ts CHANGED
@@ -5,19 +5,19 @@ 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 AppStatus, type DeleteAppResponse, type DeployAppParams, type DeployAppResponse, type DeploymentPhase, type GetAppResponse, type GetDeploymentResponse, type ImageDeployPolicy, type ListAppsResponse, type UpdateAppParams, type UpdateAppResponse, type WaitForDeploymentParams, } from "./services/apps";
9
+ export { BucketsService, type Bucket, type DeleteBucketResponse, type ListBucketsResponse } from "./services/buckets";
10
+ export { DatabasesService, type DatabaseSummary, type DedicatedDatabase, type DedicatedDatabaseDetail, type DeleteDatabaseResponse, type GetDedicatedDatabaseResponse, type GetSharedDatabaseResponse, type ListDatabasesResponse, type ListDedicatedDatabasesResponse, type ListSharedDatabasesResponse, type SharedDatabase, } from "./services/databases";
11
+ export { DomainsService, type CreateDomainResponse, type DeleteDomainResponse, type DnsRecord, type Domain, type GetDomainResponse, type ListDomainsResponse, type VerificationRecord, type VerifyDomainResponse, } from "./services/domains";
12
12
  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";
13
+ export { HostingService, type DeleteHostingSiteResponse, type GetHostingAccessResponse, type GetHostingSiteParams, type GetHostingSiteResponse, type GetHostingSiteWithCredentialsResponse, type HostingAccess, type HostingSite, type HostingSiteStatus, type HostingSiteWithCredentials, type ListHostingSitesResponse, } from "./services/hosting";
14
14
  export { IamService, type GetIamCredentialResponse, type IamCredential, type IamCredentialList, type ListIamCredentialsResponse, } from "./services/iam";
15
15
  export { MembersService, type ListMembersResponse, type ProjectMember, type ProjectMembers } from "./services/members";
16
16
  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";
17
+ export { RedisService, type DeleteRedisDatabaseResponse, type GetRedisDatabaseResponse, type ListRedisDatabasesResponse, type RedisDatabase, type RedisDatabaseDetail, } from "./services/redis";
18
+ export { RegistriesService, type DeleteRegistryResponse, type GetRegistryResponse, type ListRegistriesResponse, type Registry, type RegistryRepository, } from "./services/registries";
19
+ export { ServersService, type DeleteServerResponse, type GetServerResponse, type ListServersResponse, type Server, type ServerDetail, type ServerStatus, } from "./services/servers";
20
+ export { SshKeysService, type CreateSshKeyParams, type CreateSshKeyResponse, type DeleteSshKeyResponse, type ListSshKeysResponse, type SshKey, } from "./services/ssh-keys";
21
21
  export { PROJECT_ENVIRONMENTS, type Actor, type ProjectEnvironment, } from "./services/project-config";
22
22
  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
23
  export { VariablesService, type CreateVariableParams, type GetVariableResponse, type ListVariablesParams, type ListVariablesResponse, type ProjectVariable, type SetVariableResponse, type UpdateVariableParams, } from "./services/variables";
package/dist/index.js CHANGED
@@ -202,6 +202,27 @@ var AppsService = class {
202
202
  await new Promise((resolve) => setTimeout(resolve, Math.min(interval, remaining)));
203
203
  }
204
204
  }
205
+ /**
206
+ * Changes an app's settings and applies them to the running app.
207
+ *
208
+ * Free: resizing, which is billed, is a separate call. The API answers 502
209
+ * when the settings were saved but the runtime refused them.
210
+ */
211
+ async update(appId, params) {
212
+ if (!appId) throw new Error("appId is required");
213
+ const { projectId, ...changes } = params ?? {};
214
+ const body = Object.fromEntries(Object.entries(changes).filter(([, value]) => value !== void 0));
215
+ if (Object.keys(body).length === 0) throw new Error("at least one change is required");
216
+ return this.transport.request("PATCH", `${this.basePath(projectId)}/${appId}`, { body });
217
+ }
218
+ /**
219
+ * Permanently deletes an app: its runtime, routing, custom hostname and
220
+ * billing, then the app itself. Its deployments go with it.
221
+ */
222
+ async delete(appId, params = {}) {
223
+ if (!appId) throw new Error("appId is required");
224
+ return this.transport.request("DELETE", `${this.basePath(params.projectId)}/${appId}`);
225
+ }
205
226
  };
206
227
 
207
228
  // src/services/buckets.ts
@@ -212,10 +233,19 @@ var BucketsService = class {
212
233
  }
213
234
  /** Lists every bucket in the project. */
214
235
  async list(params = {}) {
215
- return this.transport.request(
216
- "GET",
217
- `/v1/projects/${resolveProjectId(this.config, params.projectId)}/storage/object-storage`
218
- );
236
+ return this.transport.request("GET", this.basePath(params.projectId));
237
+ }
238
+ /**
239
+ * Permanently deletes a bucket with every object in it and the access
240
+ * credentials made for it, and stops its billing.
241
+ */
242
+ async delete(bucketId, params = {}) {
243
+ if (!bucketId) throw new Error("bucketId is required");
244
+ return this.transport.request("DELETE", `${this.basePath(params.projectId)}/${bucketId}`);
245
+ }
246
+ /** Builds the collection route for the resolved project. */
247
+ basePath(projectId) {
248
+ return `/v1/projects/${resolveProjectId(this.config, projectId)}/storage/object-storage`;
219
249
  }
220
250
  };
221
251
 
@@ -257,6 +287,22 @@ var DatabasesService = class {
257
287
  if (!tenantId) throw new Error("tenantId is required");
258
288
  return this.transport.request("GET", `${this.basePath(params.projectId)}/shared/${tenantId}`);
259
289
  }
290
+ /** Permanently deletes a dedicated database cluster and its data, and stops its billing. */
291
+ async deleteDedicated(databaseId, params = {}) {
292
+ if (!databaseId) throw new Error("databaseId is required");
293
+ return this.transport.request(
294
+ "DELETE",
295
+ `${this.basePath(params.projectId)}/dedicated/${databaseId}`
296
+ );
297
+ }
298
+ /** Permanently deletes a shared database and its data, and stops its billing. */
299
+ async deleteShared(tenantId, params = {}) {
300
+ if (!tenantId) throw new Error("tenantId is required");
301
+ return this.transport.request(
302
+ "DELETE",
303
+ `${this.basePath(params.projectId)}/shared/${tenantId}`
304
+ );
305
+ }
260
306
  };
261
307
 
262
308
  // src/services/domains.ts
@@ -281,6 +327,36 @@ var DomainsService = class {
281
327
  `${this.basePath(params.projectId)}/${encodeURIComponent(domain)}`
282
328
  );
283
329
  }
330
+ /**
331
+ * Adds a domain you already own, e.g. `example.com`. Free. Publish the
332
+ * returned `verificationRecord`, then call `verify()`. Buying a domain is not
333
+ * part of the SDK.
334
+ */
335
+ async create(name, params = {}) {
336
+ if (!name) throw new Error("name is required");
337
+ return this.transport.request("POST", this.basePath(params.projectId), {
338
+ body: { name, type: "EXTERNAL" }
339
+ });
340
+ }
341
+ /** Checks a domain's verification record, by domain id or name. */
342
+ async verify(domain, params = {}) {
343
+ if (!domain) throw new Error("domain is required");
344
+ return this.transport.request(
345
+ "POST",
346
+ `${this.basePath(params.projectId)}/${encodeURIComponent(domain)}/verify`
347
+ );
348
+ }
349
+ /**
350
+ * Removes a domain and its DNS records, by id or name. Refused with 409
351
+ * while an app or an email domain uses it.
352
+ */
353
+ async delete(domain, params = {}) {
354
+ if (!domain) throw new Error("domain is required");
355
+ return this.transport.request(
356
+ "DELETE",
357
+ `${this.basePath(params.projectId)}/${encodeURIComponent(domain)}`
358
+ );
359
+ }
284
360
  };
285
361
 
286
362
  // src/services/email.ts
@@ -334,6 +410,17 @@ var EmailService = class {
334
410
  `/v1/projects/${resolveProjectId(this.config, params.projectId)}/email/${emailDomainId}`
335
411
  );
336
412
  }
413
+ /**
414
+ * Stops sending from a domain and removes it from email. The domain itself
415
+ * stays in the project. The API answers 204, so there is nothing to return.
416
+ */
417
+ async deleteDomain(emailDomainId, params = {}) {
418
+ if (!emailDomainId) throw new Error("emailDomainId is required");
419
+ await this.transport.request(
420
+ "DELETE",
421
+ `/v1/projects/${resolveProjectId(this.config, params.projectId)}/email/${emailDomainId}`
422
+ );
423
+ }
337
424
  };
338
425
 
339
426
  // src/services/hosting.ts
@@ -366,6 +453,11 @@ var HostingService = class {
366
453
  `${this.basePath(params.projectId)}/${siteId}/access`
367
454
  );
368
455
  }
456
+ /** Permanently deletes a hosting site with its files, databases and domains, and stops its billing. */
457
+ async delete(siteId, params = {}) {
458
+ if (!siteId) throw new Error("siteId is required");
459
+ return this.transport.request("DELETE", `${this.basePath(params.projectId)}/${siteId}`);
460
+ }
369
461
  };
370
462
 
371
463
  // src/services/iam.ts
@@ -390,6 +482,14 @@ var IamService = class {
390
482
  `${this.basePath(params.projectId)}/${encodeURIComponent(iamUserName)}`
391
483
  );
392
484
  }
485
+ /**
486
+ * Deletes an IAM user and its access keys, by user name. Anything using the
487
+ * keys stops working. The API answers 204, so there is nothing to return.
488
+ */
489
+ async delete(iamUserName, params = {}) {
490
+ if (!iamUserName) throw new Error("iamUserName is required");
491
+ await this.transport.request("DELETE", `${this.basePath(params.projectId)}/${encodeURIComponent(iamUserName)}`);
492
+ }
393
493
  };
394
494
 
395
495
  // src/services/members.ts
@@ -442,6 +542,11 @@ var RedisService = class {
442
542
  if (!redisId) throw new Error("redisId is required");
443
543
  return this.transport.request("GET", `${this.basePath(params.projectId)}/${redisId}`);
444
544
  }
545
+ /** Permanently deletes a Redis database and its data, and stops its billing. */
546
+ async delete(redisId, params = {}) {
547
+ if (!redisId) throw new Error("redisId is required");
548
+ return this.transport.request("DELETE", `${this.basePath(params.projectId)}/${redisId}`);
549
+ }
445
550
  };
446
551
 
447
552
  // src/services/registries.ts
@@ -463,6 +568,11 @@ var RegistriesService = class {
463
568
  if (!registryId) throw new Error("registryId is required");
464
569
  return this.transport.request("GET", `${this.basePath(params.projectId)}/${registryId}`);
465
570
  }
571
+ /** Permanently deletes a registry with every repository and image in it, and stops its billing. */
572
+ async delete(registryId, params = {}) {
573
+ if (!registryId) throw new Error("registryId is required");
574
+ return this.transport.request("DELETE", `${this.basePath(params.projectId)}/${registryId}`);
575
+ }
466
576
  };
467
577
 
468
578
  // src/services/project-config.ts
@@ -590,6 +700,11 @@ var ServersService = class {
590
700
  if (!serverId) throw new Error("serverId is required");
591
701
  return this.transport.request("GET", `${this.basePath(params.projectId)}/${serverId}`);
592
702
  }
703
+ /** Permanently deletes a server and its disk, and stops its billing. */
704
+ async delete(serverId, params = {}) {
705
+ if (!serverId) throw new Error("serverId is required");
706
+ return this.transport.request("DELETE", `${this.basePath(params.projectId)}/${serverId}`);
707
+ }
593
708
  };
594
709
 
595
710
  // src/services/ssh-keys.ts
@@ -600,10 +715,27 @@ var SshKeysService = class {
600
715
  }
601
716
  /** Lists every SSH key in the project. */
602
717
  async list(params = {}) {
603
- return this.transport.request(
604
- "GET",
605
- `/v1/projects/${resolveProjectId(this.config, params.projectId)}/ssh-keys`
606
- );
718
+ return this.transport.request("GET", this.basePath(params.projectId));
719
+ }
720
+ /** Adds a public key to the project, for installing on servers created later. */
721
+ async create(params) {
722
+ if (!params?.name) throw new Error("name is required");
723
+ if (!params.publicKey) throw new Error("publicKey is required");
724
+ return this.transport.request("POST", this.basePath(params.projectId), {
725
+ body: { name: params.name, publicKey: params.publicKey }
726
+ });
727
+ }
728
+ /**
729
+ * Removes a key from the project. Servers it was already installed on keep
730
+ * accepting it; `stillAuthorisedOn` says how many.
731
+ */
732
+ async delete(sshKeyId, params = {}) {
733
+ if (!sshKeyId) throw new Error("sshKeyId is required");
734
+ return this.transport.request("DELETE", `${this.basePath(params.projectId)}/${sshKeyId}`);
735
+ }
736
+ /** Builds the collection route for the resolved project. */
737
+ basePath(projectId) {
738
+ return `/v1/projects/${resolveProjectId(this.config, projectId)}/ssh-keys`;
607
739
  }
608
740
  };
609
741
 
@@ -1053,7 +1185,7 @@ function sleep(ms) {
1053
1185
  }
1054
1186
 
1055
1187
  // src/version.ts
1056
- var VERSION = "1.8.0";
1188
+ var VERSION = "1.9.0";
1057
1189
  var USER_AGENT = `cosmoner-node/${VERSION}`;
1058
1190
 
1059
1191
  // src/transport.ts
package/dist/index.mjs CHANGED
@@ -128,6 +128,27 @@ var AppsService = class {
128
128
  await new Promise((resolve) => setTimeout(resolve, Math.min(interval, remaining)));
129
129
  }
130
130
  }
131
+ /**
132
+ * Changes an app's settings and applies them to the running app.
133
+ *
134
+ * Free: resizing, which is billed, is a separate call. The API answers 502
135
+ * when the settings were saved but the runtime refused them.
136
+ */
137
+ async update(appId, params) {
138
+ if (!appId) throw new Error("appId is required");
139
+ const { projectId, ...changes } = params ?? {};
140
+ const body = Object.fromEntries(Object.entries(changes).filter(([, value]) => value !== void 0));
141
+ if (Object.keys(body).length === 0) throw new Error("at least one change is required");
142
+ return this.transport.request("PATCH", `${this.basePath(projectId)}/${appId}`, { body });
143
+ }
144
+ /**
145
+ * Permanently deletes an app: its runtime, routing, custom hostname and
146
+ * billing, then the app itself. Its deployments go with it.
147
+ */
148
+ async delete(appId, params = {}) {
149
+ if (!appId) throw new Error("appId is required");
150
+ return this.transport.request("DELETE", `${this.basePath(params.projectId)}/${appId}`);
151
+ }
131
152
  };
132
153
 
133
154
  // src/services/buckets.ts
@@ -138,10 +159,19 @@ var BucketsService = class {
138
159
  }
139
160
  /** Lists every bucket in the project. */
140
161
  async list(params = {}) {
141
- return this.transport.request(
142
- "GET",
143
- `/v1/projects/${resolveProjectId(this.config, params.projectId)}/storage/object-storage`
144
- );
162
+ return this.transport.request("GET", this.basePath(params.projectId));
163
+ }
164
+ /**
165
+ * Permanently deletes a bucket with every object in it and the access
166
+ * credentials made for it, and stops its billing.
167
+ */
168
+ async delete(bucketId, params = {}) {
169
+ if (!bucketId) throw new Error("bucketId is required");
170
+ return this.transport.request("DELETE", `${this.basePath(params.projectId)}/${bucketId}`);
171
+ }
172
+ /** Builds the collection route for the resolved project. */
173
+ basePath(projectId) {
174
+ return `/v1/projects/${resolveProjectId(this.config, projectId)}/storage/object-storage`;
145
175
  }
146
176
  };
147
177
 
@@ -183,6 +213,22 @@ var DatabasesService = class {
183
213
  if (!tenantId) throw new Error("tenantId is required");
184
214
  return this.transport.request("GET", `${this.basePath(params.projectId)}/shared/${tenantId}`);
185
215
  }
216
+ /** Permanently deletes a dedicated database cluster and its data, and stops its billing. */
217
+ async deleteDedicated(databaseId, params = {}) {
218
+ if (!databaseId) throw new Error("databaseId is required");
219
+ return this.transport.request(
220
+ "DELETE",
221
+ `${this.basePath(params.projectId)}/dedicated/${databaseId}`
222
+ );
223
+ }
224
+ /** Permanently deletes a shared database and its data, and stops its billing. */
225
+ async deleteShared(tenantId, params = {}) {
226
+ if (!tenantId) throw new Error("tenantId is required");
227
+ return this.transport.request(
228
+ "DELETE",
229
+ `${this.basePath(params.projectId)}/shared/${tenantId}`
230
+ );
231
+ }
186
232
  };
187
233
 
188
234
  // src/services/domains.ts
@@ -207,6 +253,36 @@ var DomainsService = class {
207
253
  `${this.basePath(params.projectId)}/${encodeURIComponent(domain)}`
208
254
  );
209
255
  }
256
+ /**
257
+ * Adds a domain you already own, e.g. `example.com`. Free. Publish the
258
+ * returned `verificationRecord`, then call `verify()`. Buying a domain is not
259
+ * part of the SDK.
260
+ */
261
+ async create(name, params = {}) {
262
+ if (!name) throw new Error("name is required");
263
+ return this.transport.request("POST", this.basePath(params.projectId), {
264
+ body: { name, type: "EXTERNAL" }
265
+ });
266
+ }
267
+ /** Checks a domain's verification record, by domain id or name. */
268
+ async verify(domain, params = {}) {
269
+ if (!domain) throw new Error("domain is required");
270
+ return this.transport.request(
271
+ "POST",
272
+ `${this.basePath(params.projectId)}/${encodeURIComponent(domain)}/verify`
273
+ );
274
+ }
275
+ /**
276
+ * Removes a domain and its DNS records, by id or name. Refused with 409
277
+ * while an app or an email domain uses it.
278
+ */
279
+ async delete(domain, params = {}) {
280
+ if (!domain) throw new Error("domain is required");
281
+ return this.transport.request(
282
+ "DELETE",
283
+ `${this.basePath(params.projectId)}/${encodeURIComponent(domain)}`
284
+ );
285
+ }
210
286
  };
211
287
 
212
288
  // src/services/email.ts
@@ -260,6 +336,17 @@ var EmailService = class {
260
336
  `/v1/projects/${resolveProjectId(this.config, params.projectId)}/email/${emailDomainId}`
261
337
  );
262
338
  }
339
+ /**
340
+ * Stops sending from a domain and removes it from email. The domain itself
341
+ * stays in the project. The API answers 204, so there is nothing to return.
342
+ */
343
+ async deleteDomain(emailDomainId, params = {}) {
344
+ if (!emailDomainId) throw new Error("emailDomainId is required");
345
+ await this.transport.request(
346
+ "DELETE",
347
+ `/v1/projects/${resolveProjectId(this.config, params.projectId)}/email/${emailDomainId}`
348
+ );
349
+ }
263
350
  };
264
351
 
265
352
  // src/services/hosting.ts
@@ -292,6 +379,11 @@ var HostingService = class {
292
379
  `${this.basePath(params.projectId)}/${siteId}/access`
293
380
  );
294
381
  }
382
+ /** Permanently deletes a hosting site with its files, databases and domains, and stops its billing. */
383
+ async delete(siteId, params = {}) {
384
+ if (!siteId) throw new Error("siteId is required");
385
+ return this.transport.request("DELETE", `${this.basePath(params.projectId)}/${siteId}`);
386
+ }
295
387
  };
296
388
 
297
389
  // src/services/iam.ts
@@ -316,6 +408,14 @@ var IamService = class {
316
408
  `${this.basePath(params.projectId)}/${encodeURIComponent(iamUserName)}`
317
409
  );
318
410
  }
411
+ /**
412
+ * Deletes an IAM user and its access keys, by user name. Anything using the
413
+ * keys stops working. The API answers 204, so there is nothing to return.
414
+ */
415
+ async delete(iamUserName, params = {}) {
416
+ if (!iamUserName) throw new Error("iamUserName is required");
417
+ await this.transport.request("DELETE", `${this.basePath(params.projectId)}/${encodeURIComponent(iamUserName)}`);
418
+ }
319
419
  };
320
420
 
321
421
  // src/services/members.ts
@@ -368,6 +468,11 @@ var RedisService = class {
368
468
  if (!redisId) throw new Error("redisId is required");
369
469
  return this.transport.request("GET", `${this.basePath(params.projectId)}/${redisId}`);
370
470
  }
471
+ /** Permanently deletes a Redis database and its data, and stops its billing. */
472
+ async delete(redisId, params = {}) {
473
+ if (!redisId) throw new Error("redisId is required");
474
+ return this.transport.request("DELETE", `${this.basePath(params.projectId)}/${redisId}`);
475
+ }
371
476
  };
372
477
 
373
478
  // src/services/registries.ts
@@ -389,6 +494,11 @@ var RegistriesService = class {
389
494
  if (!registryId) throw new Error("registryId is required");
390
495
  return this.transport.request("GET", `${this.basePath(params.projectId)}/${registryId}`);
391
496
  }
497
+ /** Permanently deletes a registry with every repository and image in it, and stops its billing. */
498
+ async delete(registryId, params = {}) {
499
+ if (!registryId) throw new Error("registryId is required");
500
+ return this.transport.request("DELETE", `${this.basePath(params.projectId)}/${registryId}`);
501
+ }
392
502
  };
393
503
 
394
504
  // src/services/project-config.ts
@@ -516,6 +626,11 @@ var ServersService = class {
516
626
  if (!serverId) throw new Error("serverId is required");
517
627
  return this.transport.request("GET", `${this.basePath(params.projectId)}/${serverId}`);
518
628
  }
629
+ /** Permanently deletes a server and its disk, and stops its billing. */
630
+ async delete(serverId, params = {}) {
631
+ if (!serverId) throw new Error("serverId is required");
632
+ return this.transport.request("DELETE", `${this.basePath(params.projectId)}/${serverId}`);
633
+ }
519
634
  };
520
635
 
521
636
  // src/services/ssh-keys.ts
@@ -526,10 +641,27 @@ var SshKeysService = class {
526
641
  }
527
642
  /** Lists every SSH key in the project. */
528
643
  async list(params = {}) {
529
- return this.transport.request(
530
- "GET",
531
- `/v1/projects/${resolveProjectId(this.config, params.projectId)}/ssh-keys`
532
- );
644
+ return this.transport.request("GET", this.basePath(params.projectId));
645
+ }
646
+ /** Adds a public key to the project, for installing on servers created later. */
647
+ async create(params) {
648
+ if (!params?.name) throw new Error("name is required");
649
+ if (!params.publicKey) throw new Error("publicKey is required");
650
+ return this.transport.request("POST", this.basePath(params.projectId), {
651
+ body: { name: params.name, publicKey: params.publicKey }
652
+ });
653
+ }
654
+ /**
655
+ * Removes a key from the project. Servers it was already installed on keep
656
+ * accepting it; `stillAuthorisedOn` says how many.
657
+ */
658
+ async delete(sshKeyId, params = {}) {
659
+ if (!sshKeyId) throw new Error("sshKeyId is required");
660
+ return this.transport.request("DELETE", `${this.basePath(params.projectId)}/${sshKeyId}`);
661
+ }
662
+ /** Builds the collection route for the resolved project. */
663
+ basePath(projectId) {
664
+ return `/v1/projects/${resolveProjectId(this.config, projectId)}/ssh-keys`;
533
665
  }
534
666
  };
535
667
 
@@ -979,7 +1111,7 @@ function sleep(ms) {
979
1111
  }
980
1112
 
981
1113
  // src/version.ts
982
- var VERSION = "1.8.0";
1114
+ var VERSION = "1.9.0";
983
1115
  var USER_AGENT = `cosmoner-node/${VERSION}`;
984
1116
 
985
1117
  // src/transport.ts
@@ -89,6 +89,26 @@ export type AppLogsResponse = Envelope<{
89
89
  }>;
90
90
  export type DeployAppResponse = Envelope<AppDeployment>;
91
91
  export type GetDeploymentResponse = Envelope<AppDeployment>;
92
+ /**
93
+ * The settings `client.apps.update()` can change. Every field is optional, but
94
+ * a call must change at least one. Environment variables are left out on
95
+ * purpose: they belong in the deployment file, and the API masks secret ones,
96
+ * so a read-modify-write of the list would be easy to get wrong.
97
+ */
98
+ export interface UpdateAppParams extends ProjectScopedParams {
99
+ name?: string;
100
+ buildCommand?: string | null;
101
+ runCommand?: string | null;
102
+ outputDir?: string | null;
103
+ publicPort?: number | null;
104
+ internalPort?: number | null;
105
+ autoDeploy?: boolean;
106
+ imageDeployPolicy?: ImageDeployPolicy;
107
+ /** Refused for an app whose runtime cannot scale horizontally. */
108
+ instances?: number;
109
+ }
110
+ export type UpdateAppResponse = Envelope<App>;
111
+ export type DeleteAppResponse = Envelope<Record<string, never>>;
92
112
  /** App lookup and image deploy operations for a project. */
93
113
  export declare class AppsService {
94
114
  private readonly transport;
@@ -125,5 +145,17 @@ export declare class AppsService {
125
145
  * in which case the deployment keeps going server-side.
126
146
  */
127
147
  waitForDeployment(appId: string, deploymentId: string, params?: WaitForDeploymentParams): Promise<AppDeployment>;
148
+ /**
149
+ * Changes an app's settings and applies them to the running app.
150
+ *
151
+ * Free: resizing, which is billed, is a separate call. The API answers 502
152
+ * when the settings were saved but the runtime refused them.
153
+ */
154
+ update(appId: string, params: UpdateAppParams): Promise<UpdateAppResponse>;
155
+ /**
156
+ * Permanently deletes an app: its runtime, routing, custom hostname and
157
+ * billing, then the app itself. Its deployments go with it.
158
+ */
159
+ delete(appId: string, params?: ProjectScopedParams): Promise<DeleteAppResponse>;
128
160
  }
129
161
  export {};
@@ -26,6 +26,7 @@ interface Envelope<T> {
26
26
  data: T;
27
27
  }
28
28
  export type ListBucketsResponse = Envelope<Bucket[]>;
29
+ export type DeleteBucketResponse = Envelope<Record<string, never>>;
29
30
  /** Read operations on a project's buckets. The API has no single-bucket read. */
30
31
  export declare class BucketsService {
31
32
  private readonly transport;
@@ -33,5 +34,12 @@ export declare class BucketsService {
33
34
  constructor(transport: Transport, config: ResolvedConfig);
34
35
  /** Lists every bucket in the project. */
35
36
  list(params?: ProjectScopedParams): Promise<ListBucketsResponse>;
37
+ /**
38
+ * Permanently deletes a bucket with every object in it and the access
39
+ * credentials made for it, and stops its billing.
40
+ */
41
+ delete(bucketId: string, params?: ProjectScopedParams): Promise<DeleteBucketResponse>;
42
+ /** Builds the collection route for the resolved project. */
43
+ private basePath;
36
44
  }
37
45
  export {};
@@ -82,6 +82,7 @@ export type ListDedicatedDatabasesResponse = Envelope<DedicatedDatabase[]>;
82
82
  export type GetDedicatedDatabaseResponse = Envelope<DedicatedDatabaseDetail>;
83
83
  export type ListSharedDatabasesResponse = Envelope<SharedDatabase[]>;
84
84
  export type GetSharedDatabaseResponse = Envelope<SharedDatabase>;
85
+ export type DeleteDatabaseResponse = Envelope<Record<string, never>>;
85
86
  /** Read operations on a project's databases. */
86
87
  export declare class DatabasesService {
87
88
  private readonly transport;
@@ -102,5 +103,9 @@ export declare class DatabasesService {
102
103
  listShared(params?: ProjectScopedParams): Promise<ListSharedDatabasesResponse>;
103
104
  /** Fetches one database on the shared cluster. */
104
105
  getShared(tenantId: string, params?: ProjectScopedParams): Promise<GetSharedDatabaseResponse>;
106
+ /** Permanently deletes a dedicated database cluster and its data, and stops its billing. */
107
+ deleteDedicated(databaseId: string, params?: ProjectScopedParams): Promise<DeleteDatabaseResponse>;
108
+ /** Permanently deletes a shared database and its data, and stops its billing. */
109
+ deleteShared(tenantId: string, params?: ProjectScopedParams): Promise<DeleteDatabaseResponse>;
105
110
  }
106
111
  export {};
@@ -39,6 +39,25 @@ interface Envelope<T> {
39
39
  }
40
40
  export type ListDomainsResponse = Envelope<Domain[]>;
41
41
  export type GetDomainResponse = Envelope<Domain>;
42
+ /** The TXT record that proves you control a domain you added. */
43
+ export interface VerificationRecord {
44
+ type: "TXT";
45
+ name: string;
46
+ value: string;
47
+ }
48
+ export type CreateDomainResponse = Envelope<Domain & {
49
+ verificationRecord: VerificationRecord;
50
+ }>;
51
+ export type VerifyDomainResponse = Envelope<{
52
+ status: "ACTIVE" | "PENDING";
53
+ verified: boolean;
54
+ record: VerificationRecord;
55
+ /** Why the lookup failed, when it did. */
56
+ error?: string;
57
+ }>;
58
+ export type DeleteDomainResponse = Envelope<{
59
+ id: string;
60
+ }>;
42
61
  /** Read operations on a project's domains. */
43
62
  export declare class DomainsService {
44
63
  private readonly transport;
@@ -50,5 +69,18 @@ export declare class DomainsService {
50
69
  list(params?: ProjectScopedParams): Promise<ListDomainsResponse>;
51
70
  /** Fetches one domain by id or by name, e.g. `example.com`. */
52
71
  get(domain: string, params?: ProjectScopedParams): Promise<GetDomainResponse>;
72
+ /**
73
+ * Adds a domain you already own, e.g. `example.com`. Free. Publish the
74
+ * returned `verificationRecord`, then call `verify()`. Buying a domain is not
75
+ * part of the SDK.
76
+ */
77
+ create(name: string, params?: ProjectScopedParams): Promise<CreateDomainResponse>;
78
+ /** Checks a domain's verification record, by domain id or name. */
79
+ verify(domain: string, params?: ProjectScopedParams): Promise<VerifyDomainResponse>;
80
+ /**
81
+ * Removes a domain and its DNS records, by id or name. Refused with 409
82
+ * while an app or an email domain uses it.
83
+ */
84
+ delete(domain: string, params?: ProjectScopedParams): Promise<DeleteDomainResponse>;
53
85
  }
54
86
  export {};
@@ -86,4 +86,9 @@ export declare class EmailService {
86
86
  listDomains(params?: ProjectScopedParams): Promise<ListEmailDomainsResponse>;
87
87
  /** Fetches one sending domain by its id (not its domain name). */
88
88
  getDomain(emailDomainId: string, params?: ProjectScopedParams): Promise<GetEmailDomainResponse>;
89
+ /**
90
+ * Stops sending from a domain and removes it from email. The domain itself
91
+ * stays in the project. The API answers 204, so there is nothing to return.
92
+ */
93
+ deleteDomain(emailDomainId: string, params?: ProjectScopedParams): Promise<void>;
89
94
  }
@@ -70,6 +70,7 @@ export type GetHostingSiteResponse = Envelope<HostingSite & {
70
70
  }>;
71
71
  export type GetHostingSiteWithCredentialsResponse = Envelope<HostingSiteWithCredentials>;
72
72
  export type GetHostingAccessResponse = Envelope<HostingAccess>;
73
+ export type DeleteHostingSiteResponse = Envelope<Record<string, never>>;
73
74
  /** Read operations on a project's shared hosting sites. */
74
75
  export declare class HostingService {
75
76
  private readonly transport;
@@ -86,5 +87,7 @@ export declare class HostingService {
86
87
  get(siteId: string, params?: GetHostingSiteParams): Promise<GetHostingSiteResponse>;
87
88
  /** Fetches the host, port and username for SFTP and SSH. */
88
89
  access(siteId: string, params?: ProjectScopedParams): Promise<GetHostingAccessResponse>;
90
+ /** Permanently deletes a hosting site with its files, databases and domains, and stops its billing. */
91
+ delete(siteId: string, params?: ProjectScopedParams): Promise<DeleteHostingSiteResponse>;
89
92
  }
90
93
  export {};
@@ -57,5 +57,10 @@ export declare class IamService {
57
57
  list(params?: ProjectScopedParams): Promise<ListIamCredentialsResponse>;
58
58
  /** Fetches one credential by its IAM user name. */
59
59
  get(iamUserName: string, params?: ProjectScopedParams): Promise<GetIamCredentialResponse>;
60
+ /**
61
+ * Deletes an IAM user and its access keys, by user name. Anything using the
62
+ * keys stops working. The API answers 204, so there is nothing to return.
63
+ */
64
+ delete(iamUserName: string, params?: ProjectScopedParams): Promise<void>;
60
65
  }
61
66
  export {};
@@ -40,6 +40,7 @@ interface Envelope<T> {
40
40
  }
41
41
  export type ListRedisDatabasesResponse = Envelope<RedisDatabase[]>;
42
42
  export type GetRedisDatabaseResponse = Envelope<RedisDatabaseDetail>;
43
+ export type DeleteRedisDatabaseResponse = Envelope<Record<string, never>>;
43
44
  /** Read operations on a project's Redis databases. */
44
45
  export declare class RedisService {
45
46
  private readonly transport;
@@ -51,5 +52,7 @@ export declare class RedisService {
51
52
  list(params?: ProjectScopedParams): Promise<ListRedisDatabasesResponse>;
52
53
  /** Fetches one Redis database, with its password; see {@link RedisDatabaseDetail}. */
53
54
  get(redisId: string, params?: ProjectScopedParams): Promise<GetRedisDatabaseResponse>;
55
+ /** Permanently deletes a Redis database and its data, and stops its billing. */
56
+ delete(redisId: string, params?: ProjectScopedParams): Promise<DeleteRedisDatabaseResponse>;
54
57
  }
55
58
  export {};
@@ -32,6 +32,7 @@ interface Envelope<T> {
32
32
  }
33
33
  export type ListRegistriesResponse = Envelope<Registry[]>;
34
34
  export type GetRegistryResponse = Envelope<Registry>;
35
+ export type DeleteRegistryResponse = Envelope<Record<string, never>>;
35
36
  /** Read operations on a project's container registries. */
36
37
  export declare class RegistriesService {
37
38
  private readonly transport;
@@ -43,5 +44,7 @@ export declare class RegistriesService {
43
44
  list(params?: ProjectScopedParams): Promise<ListRegistriesResponse>;
44
45
  /** Fetches one registry, with its repositories. */
45
46
  get(registryId: string, params?: ProjectScopedParams): Promise<GetRegistryResponse>;
47
+ /** Permanently deletes a registry with every repository and image in it, and stops its billing. */
48
+ delete(registryId: string, params?: ProjectScopedParams): Promise<DeleteRegistryResponse>;
46
49
  }
47
50
  export {};
@@ -41,6 +41,7 @@ interface Envelope<T> {
41
41
  }
42
42
  export type ListServersResponse = Envelope<Server[]>;
43
43
  export type GetServerResponse = Envelope<ServerDetail>;
44
+ export type DeleteServerResponse = Envelope<Record<string, never>>;
44
45
  /** Read operations on a project's servers. */
45
46
  export declare class ServersService {
46
47
  private readonly transport;
@@ -52,5 +53,7 @@ export declare class ServersService {
52
53
  list(params?: ProjectScopedParams): Promise<ListServersResponse>;
53
54
  /** Fetches one server, with the SSH keys installed on it. */
54
55
  get(serverId: string, params?: ProjectScopedParams): Promise<GetServerResponse>;
56
+ /** Permanently deletes a server and its disk, and stops its billing. */
57
+ delete(serverId: string, params?: ProjectScopedParams): Promise<DeleteServerResponse>;
55
58
  }
56
59
  export {};
@@ -20,12 +20,32 @@ interface Envelope<T> {
20
20
  data: T;
21
21
  }
22
22
  export type ListSshKeysResponse = Envelope<SshKey[]>;
23
- /** Read operations on a project's SSH keys. */
23
+ /** Arguments accepted by `client.sshKeys.create()`. */
24
+ export interface CreateSshKeyParams extends ProjectScopedParams {
25
+ name: string;
26
+ /** One OpenSSH public key line, e.g. the contents of `~/.ssh/id_ed25519.pub`. DSA keys are refused. */
27
+ publicKey: string;
28
+ }
29
+ export type CreateSshKeyResponse = Envelope<SshKey>;
30
+ export type DeleteSshKeyResponse = Envelope<{
31
+ /** Servers the key was already installed on, where it still works: deleting does not revoke it there. */
32
+ stillAuthorisedOn: number;
33
+ }>;
34
+ /** A project's SSH keys. */
24
35
  export declare class SshKeysService {
25
36
  private readonly transport;
26
37
  private readonly config;
27
38
  constructor(transport: Transport, config: ResolvedConfig);
28
39
  /** Lists every SSH key in the project. */
29
40
  list(params?: ProjectScopedParams): Promise<ListSshKeysResponse>;
41
+ /** Adds a public key to the project, for installing on servers created later. */
42
+ create(params: CreateSshKeyParams): Promise<CreateSshKeyResponse>;
43
+ /**
44
+ * Removes a key from the project. Servers it was already installed on keep
45
+ * accepting it; `stillAuthorisedOn` says how many.
46
+ */
47
+ delete(sshKeyId: string, params?: ProjectScopedParams): Promise<DeleteSshKeyResponse>;
48
+ /** Builds the collection route for the resolved project. */
49
+ private basePath;
30
50
  }
31
51
  export {};
package/dist/version.d.ts CHANGED
@@ -8,5 +8,5 @@
8
8
  * the release workflow runs that straight after `npm version`, and
9
9
  * `version.test.ts` fails the build if the two ever disagree.
10
10
  */
11
- export declare const VERSION = "1.8.0";
12
- export declare const USER_AGENT = "cosmoner-node/1.8.0";
11
+ export declare const VERSION = "1.9.0";
12
+ export declare const USER_AGENT = "cosmoner-node/1.9.0";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cosmoner/sdk",
3
- "version": "1.8.0",
3
+ "version": "1.9.0",
4
4
  "description": "Cosmoner SDK for Node.js",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",