@cosmoner/sdk 1.11.0 → 1.12.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
@@ -148,18 +148,18 @@ A method taking an id rejects an empty one before sending anything.
148
148
 
149
149
  | Namespace | Read | Change |
150
150
  | --- | --- | --- |
151
- | `projects` | `list()`, `get(project)` — by id or slug | |
151
+ | `projects` | `list()`, `get(project)` — by id or slug | `update(project, { name })`, `delete(project)` |
152
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)` |
153
+ | `servers` | `list()`, `get(serverId)` — adds the installed `sshKeys` | `update(serverId, { name })`, `powerOn(serverId)`, `powerOff(serverId)`, `reboot(serverId)`, `delete(serverId)` |
154
154
  | `sshKeys` | `list()` | `create({ name, publicKey })`, `delete(sshKeyId)` |
155
- | `databases` | `list()` (every kind), `listDedicated()`, `getDedicated(databaseId)`, `listShared()`, `getShared(tenantId)` | `deleteDedicated(databaseId)`, `deleteShared(tenantId)` |
155
+ | `databases` | `list()` (every kind), `listDedicated()`, `getDedicated(databaseId)`, `listShared()`, `getShared(tenantId)` | `rotateSharedPassword(tenantId)`, `deleteDedicated(databaseId)`, `deleteShared(tenantId)` |
156
156
  | `redis` | `list()`, `get(redisId)` | `delete(redisId)` |
157
157
  | `domains` | `list()`, `get(domain)` — by id or name, such as `example.com` | `create(name)`, `verify(domain)`, `delete(domain)` |
158
158
  | `buckets` | `list()` — there is no single-bucket read | `delete(bucketId)` |
159
159
  | `registries` | `list()`, `get(registryId)` | `delete(registryId)` |
160
160
  | `iam` | `list()`, `get(iamUserName)` — the list holds `credentials` plus partial-failure `errors` | `delete(iamUserName)` |
161
161
  | `members` | `list()` — members and pending invitations | |
162
- | `email` | `listDomains()`, `getDomain(emailDomainId)`, alongside `send()` | `deleteDomain(emailDomainId)` |
162
+ | `email` | `listDomains()`, `getDomain(emailDomainId)`, `limits()`, alongside `send()` | `createDomain({ domainId })`, `createExternalDomain({ domainName })`, `verifyDomain(emailDomainId)`, `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
@@ -186,6 +186,16 @@ the returned `verificationRecord`, then call `verify`. Deleting an SSH key
186
186
  leaves it on servers it was already installed on — `stillAuthorisedOn` counts
187
187
  them.
188
188
 
189
+ Power actions are asynchronous: the server reads `PROVISIONING` until the
190
+ action settles, so read it again to see the outcome. `powerOff` cuts the power
191
+ outright, and a stopped server is still billed. `projects.delete` is refused
192
+ with 409 while the project still holds resources. `email.createDomain` sets up
193
+ a domain already in the project, `createExternalDomain` one whose DNS is hosted
194
+ elsewhere; publish the returned `dnsRecords`, then call `verifyDomain`, whose
195
+ first success puts the project's email plan on its subscription.
196
+ `databases.rotateSharedPassword` returns the new password this once, and the
197
+ old one stops working at once.
198
+
189
199
  ## Secrets
190
200
 
191
201
  Stores the values a deployment file refers to with `from_secret`. Needs an API
package/dist/index.d.ts CHANGED
@@ -8,17 +8,17 @@ export type { DeploymentBuild, DeploymentEnvVar, DeploymentIssue, DeploymentIssu
8
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
9
  export { BucketsService, type Bucket, type BucketTier, type CreateBucketParams, type CreateBucketResponse, type DeleteBucketResponse, type ListBucketsResponse, type PreviewBucketParams, type PreviewBucketResponse, } from "./services/buckets";
10
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";
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 RotateSharedDatabasePasswordResponse, type RotatedSharedDatabasePassword, type SharedDatabase, } from "./services/databases";
12
12
  export { DomainsService, type CreateDomainResponse, type DeleteDomainResponse, type DnsRecord, type Domain, type GetDomainResponse, type ListDomainsResponse, type VerificationRecord, type VerifyDomainResponse, } from "./services/domains";
13
- export { EmailService, type CreateSmtpCredentialParams, type CreateSmtpCredentialResponse, type EmailDomain, type EmailDomainDetail, type GetEmailDomainResponse, type ListEmailDomainsResponse, type NewSmtpCredential, type SendEmailParams, type SendEmailResponse, } from "./services/email";
13
+ export { EmailService, type CreateEmailDomainParams, type CreateEmailDomainResponse, type CreateExternalEmailDomainParams, type CreateSmtpCredentialParams, type CreateSmtpCredentialResponse, type EmailDomain, type EmailDomainDetail, type EmailDomainVerification, type EmailLimits, type GetEmailDomainResponse, type GetEmailLimitsResponse, type ListEmailDomainsResponse, type NewSmtpCredential, type SendEmailParams, type SendEmailResponse, type VerifyEmailDomainResponse, } from "./services/email";
14
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";
15
15
  export { IamService, type CreateIamCredentialParams, type CreateIamCredentialResponse, type GetIamCredentialResponse, type IamCredential, type IamCredentialList, type IamRegistryGrant, type IamStorageGrant, type ListIamCredentialsResponse, type NewIamCredential, } from "./services/iam";
16
16
  export { MembersService, type ListMembersResponse, type ProjectMember, type ProjectMembers } from "./services/members";
17
17
  export type { CheckoutPreview, PlanChangePreview } from "./services/preview";
18
- export { ProjectsService, type GetProjectResponse, type ListProjectsResponse, type Project } from "./services/projects";
18
+ export { ProjectsService, type DeleteProjectResponse, type GetProjectResponse, type ListProjectsResponse, type Project, type UpdateProjectParams, type UpdateProjectResponse, } from "./services/projects";
19
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
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";
21
+ export { ServersService, type CreateServerParams, type CreateServerResponse, type DeleteServerResponse, type GetServerResponse, type ListServersResponse, type PreviewServerParams, type PreviewServerResponse, type ServerActionResponse, type Server, type ServerDetail, type ServerStatus, type UpdateServerParams, type UpdateServerResponse, } from "./services/servers";
22
22
  export { SshKeysService, type CreateSshKeyParams, type CreateSshKeyResponse, type DeleteSshKeyResponse, type GenerateSshKeyResponse, type GeneratedSshKey, type ListSshKeysResponse, type SshKey, } from "./services/ssh-keys";
23
23
  export { PROJECT_ENVIRONMENTS, type Actor, type ProjectEnvironment, } from "./services/project-config";
24
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";
package/dist/index.js CHANGED
@@ -434,6 +434,18 @@ var DatabasesService = class {
434
434
  `${this.basePath(params.projectId)}/shared/${tenantId}`
435
435
  );
436
436
  }
437
+ /**
438
+ * Replaces a shared database's password. The old one stops working at once,
439
+ * so anything connecting with it fails until it is given the new one. The
440
+ * response holds the new password this once.
441
+ */
442
+ async rotateSharedPassword(tenantId, params = {}) {
443
+ if (!tenantId) throw new Error("tenantId is required");
444
+ return this.transport.request(
445
+ "POST",
446
+ `${this.basePath(params.projectId)}/shared/${tenantId}/rotate-password`
447
+ );
448
+ }
437
449
  /** Prices a dedicated database before ordering it. `monthly` is exact; `dueToday` is an estimate once the project has a subscription. */
438
450
  async previewDedicated(params) {
439
451
  if (!params?.size) throw new Error("size is required");
@@ -577,6 +589,56 @@ var EmailService = class {
577
589
  `/v1/projects/${resolveProjectId(this.config, params.projectId)}/email/${emailDomainId}`
578
590
  );
579
591
  }
592
+ /**
593
+ * Sets a domain already in the project up for sending. The response lists
594
+ * the DNS records to publish; then call `verifyDomain`. 409 when email is
595
+ * already set up on it.
596
+ */
597
+ // eslint-disable-next-line require-await -- `async` makes the validation below reject rather than throw synchronously.
598
+ async createDomain(params) {
599
+ if (!params?.domainId) throw new Error("domainId is required");
600
+ return this.transport.request(
601
+ "POST",
602
+ `/v1/projects/${resolveProjectId(this.config, params.projectId)}/email`,
603
+ { body: { domainId: params.domainId } }
604
+ );
605
+ }
606
+ /**
607
+ * Sets up sending from a domain whose DNS is hosted elsewhere, adding it to
608
+ * the project as `PENDING` until its records resolve. The response lists the
609
+ * DNS records to publish; then call `verifyDomain`. 409 when the project
610
+ * already has the domain — use `createDomain` — or it cannot be used here.
611
+ */
612
+ // eslint-disable-next-line require-await -- `async` makes the validation below reject rather than throw synchronously.
613
+ async createExternalDomain(params) {
614
+ if (!params?.domainName) throw new Error("domainName is required");
615
+ return this.transport.request(
616
+ "POST",
617
+ `/v1/projects/${resolveProjectId(this.config, params.projectId)}/email/external`,
618
+ { body: { domainName: params.domainName } }
619
+ );
620
+ }
621
+ /**
622
+ * Checks a sending domain's DNS records. When they all resolve the domain
623
+ * goes `ACTIVE`, and its first activation puts the project's email plan on
624
+ * its subscription — refused with 402 when the project cannot be billed.
625
+ */
626
+ // eslint-disable-next-line require-await -- `async` makes the validation below reject rather than throw synchronously.
627
+ async verifyDomain(emailDomainId, params = {}) {
628
+ if (!emailDomainId) throw new Error("emailDomainId is required");
629
+ return this.transport.request(
630
+ "POST",
631
+ `/v1/projects/${resolveProjectId(this.config, params.projectId)}/email/${emailDomainId}/verify`
632
+ );
633
+ }
634
+ /** Reads the project's email plan, its sending limits and its usage against them. */
635
+ // eslint-disable-next-line require-await -- kept `async` like every method here, so callers get one promise contract.
636
+ async limits(params = {}) {
637
+ return this.transport.request(
638
+ "GET",
639
+ `/v1/projects/${resolveProjectId(this.config, params.projectId)}/email/limits`
640
+ );
641
+ }
580
642
  /**
581
643
  * Stops sending from a domain and removes it from email. The domain itself
582
644
  * stays in the project. The API answers 204, so there is nothing to return.
@@ -757,6 +819,23 @@ var ProjectsService = class {
757
819
  if (!project) throw new Error("project is required");
758
820
  return this.transport.request("GET", `/v1/projects/${encodeURIComponent(project)}`);
759
821
  }
822
+ /** Renames a project. Owners and admins only; 409 when the caller already has a project of that name. */
823
+ async update(project, params) {
824
+ if (!project) throw new Error("project is required");
825
+ if (!params?.name) throw new Error("name is required");
826
+ return this.transport.request("PATCH", `/v1/projects/${encodeURIComponent(project)}`, {
827
+ body: { name: params.name }
828
+ });
829
+ }
830
+ /**
831
+ * Permanently deletes a project. Owner only, and refused with 409 while it
832
+ * still holds resources — servers, apps, databases and the rest have to be
833
+ * deleted first, so nothing is left running and billed with no project.
834
+ */
835
+ async delete(project) {
836
+ if (!project) throw new Error("project is required");
837
+ return this.transport.request("DELETE", `/v1/projects/${encodeURIComponent(project)}`);
838
+ }
760
839
  };
761
840
 
762
841
  // src/services/redis.ts
@@ -985,6 +1064,34 @@ var ServersService = class {
985
1064
  if (!serverId) throw new Error("serverId is required");
986
1065
  return this.transport.request("GET", `${this.basePath(params.projectId)}/${serverId}`);
987
1066
  }
1067
+ /** Renames a server. */
1068
+ async update(serverId, params) {
1069
+ if (!serverId) throw new Error("serverId is required");
1070
+ if (!params?.name) throw new Error("name is required");
1071
+ return this.transport.request("PATCH", `${this.basePath(params.projectId)}/${serverId}`, {
1072
+ body: { name: params.name }
1073
+ });
1074
+ }
1075
+ /**
1076
+ * Powers a stopped server on. Asynchronous: the server reads `PROVISIONING`
1077
+ * until it settles, so read it again to see the outcome. Refused with 409
1078
+ * while it is still being provisioned or is already running.
1079
+ */
1080
+ async powerOn(serverId, params = {}) {
1081
+ return this.action(serverId, "power_on", params);
1082
+ }
1083
+ /**
1084
+ * Cuts a running server's power — a hard stop, like pulling the plug, not a
1085
+ * shutdown its operating system sees coming. Asynchronous, like `powerOn`.
1086
+ * A stopped server is still billed.
1087
+ */
1088
+ async powerOff(serverId, params = {}) {
1089
+ return this.action(serverId, "power_off", params);
1090
+ }
1091
+ /** Reboots a running server. Asynchronous, like `powerOn`. */
1092
+ async reboot(serverId, params = {}) {
1093
+ return this.action(serverId, "reboot", params);
1094
+ }
988
1095
  /** Permanently deletes a server and its disk, and stops its billing. */
989
1096
  async delete(serverId, params = {}) {
990
1097
  if (!serverId) throw new Error("serverId is required");
@@ -1020,6 +1127,13 @@ var ServersService = class {
1020
1127
  }
1021
1128
  });
1022
1129
  }
1130
+ /** Runs one power action. */
1131
+ async action(serverId, action, params) {
1132
+ if (!serverId) throw new Error("serverId is required");
1133
+ return this.transport.request("POST", `${this.basePath(params.projectId)}/${serverId}/actions`, {
1134
+ body: { action }
1135
+ });
1136
+ }
1023
1137
  };
1024
1138
 
1025
1139
  // src/services/ssh-keys.ts
@@ -1510,7 +1624,7 @@ function sleep(ms) {
1510
1624
  }
1511
1625
 
1512
1626
  // src/version.ts
1513
- var VERSION = "1.11.0";
1627
+ var VERSION = "1.12.0";
1514
1628
  var USER_AGENT = `cosmoner-node/${VERSION}`;
1515
1629
 
1516
1630
  // src/transport.ts
package/dist/index.mjs CHANGED
@@ -359,6 +359,18 @@ var DatabasesService = class {
359
359
  `${this.basePath(params.projectId)}/shared/${tenantId}`
360
360
  );
361
361
  }
362
+ /**
363
+ * Replaces a shared database's password. The old one stops working at once,
364
+ * so anything connecting with it fails until it is given the new one. The
365
+ * response holds the new password this once.
366
+ */
367
+ async rotateSharedPassword(tenantId, params = {}) {
368
+ if (!tenantId) throw new Error("tenantId is required");
369
+ return this.transport.request(
370
+ "POST",
371
+ `${this.basePath(params.projectId)}/shared/${tenantId}/rotate-password`
372
+ );
373
+ }
362
374
  /** Prices a dedicated database before ordering it. `monthly` is exact; `dueToday` is an estimate once the project has a subscription. */
363
375
  async previewDedicated(params) {
364
376
  if (!params?.size) throw new Error("size is required");
@@ -502,6 +514,56 @@ var EmailService = class {
502
514
  `/v1/projects/${resolveProjectId(this.config, params.projectId)}/email/${emailDomainId}`
503
515
  );
504
516
  }
517
+ /**
518
+ * Sets a domain already in the project up for sending. The response lists
519
+ * the DNS records to publish; then call `verifyDomain`. 409 when email is
520
+ * already set up on it.
521
+ */
522
+ // eslint-disable-next-line require-await -- `async` makes the validation below reject rather than throw synchronously.
523
+ async createDomain(params) {
524
+ if (!params?.domainId) throw new Error("domainId is required");
525
+ return this.transport.request(
526
+ "POST",
527
+ `/v1/projects/${resolveProjectId(this.config, params.projectId)}/email`,
528
+ { body: { domainId: params.domainId } }
529
+ );
530
+ }
531
+ /**
532
+ * Sets up sending from a domain whose DNS is hosted elsewhere, adding it to
533
+ * the project as `PENDING` until its records resolve. The response lists the
534
+ * DNS records to publish; then call `verifyDomain`. 409 when the project
535
+ * already has the domain — use `createDomain` — or it cannot be used here.
536
+ */
537
+ // eslint-disable-next-line require-await -- `async` makes the validation below reject rather than throw synchronously.
538
+ async createExternalDomain(params) {
539
+ if (!params?.domainName) throw new Error("domainName is required");
540
+ return this.transport.request(
541
+ "POST",
542
+ `/v1/projects/${resolveProjectId(this.config, params.projectId)}/email/external`,
543
+ { body: { domainName: params.domainName } }
544
+ );
545
+ }
546
+ /**
547
+ * Checks a sending domain's DNS records. When they all resolve the domain
548
+ * goes `ACTIVE`, and its first activation puts the project's email plan on
549
+ * its subscription — refused with 402 when the project cannot be billed.
550
+ */
551
+ // eslint-disable-next-line require-await -- `async` makes the validation below reject rather than throw synchronously.
552
+ async verifyDomain(emailDomainId, params = {}) {
553
+ if (!emailDomainId) throw new Error("emailDomainId is required");
554
+ return this.transport.request(
555
+ "POST",
556
+ `/v1/projects/${resolveProjectId(this.config, params.projectId)}/email/${emailDomainId}/verify`
557
+ );
558
+ }
559
+ /** Reads the project's email plan, its sending limits and its usage against them. */
560
+ // eslint-disable-next-line require-await -- kept `async` like every method here, so callers get one promise contract.
561
+ async limits(params = {}) {
562
+ return this.transport.request(
563
+ "GET",
564
+ `/v1/projects/${resolveProjectId(this.config, params.projectId)}/email/limits`
565
+ );
566
+ }
505
567
  /**
506
568
  * Stops sending from a domain and removes it from email. The domain itself
507
569
  * stays in the project. The API answers 204, so there is nothing to return.
@@ -682,6 +744,23 @@ var ProjectsService = class {
682
744
  if (!project) throw new Error("project is required");
683
745
  return this.transport.request("GET", `/v1/projects/${encodeURIComponent(project)}`);
684
746
  }
747
+ /** Renames a project. Owners and admins only; 409 when the caller already has a project of that name. */
748
+ async update(project, params) {
749
+ if (!project) throw new Error("project is required");
750
+ if (!params?.name) throw new Error("name is required");
751
+ return this.transport.request("PATCH", `/v1/projects/${encodeURIComponent(project)}`, {
752
+ body: { name: params.name }
753
+ });
754
+ }
755
+ /**
756
+ * Permanently deletes a project. Owner only, and refused with 409 while it
757
+ * still holds resources — servers, apps, databases and the rest have to be
758
+ * deleted first, so nothing is left running and billed with no project.
759
+ */
760
+ async delete(project) {
761
+ if (!project) throw new Error("project is required");
762
+ return this.transport.request("DELETE", `/v1/projects/${encodeURIComponent(project)}`);
763
+ }
685
764
  };
686
765
 
687
766
  // src/services/redis.ts
@@ -910,6 +989,34 @@ var ServersService = class {
910
989
  if (!serverId) throw new Error("serverId is required");
911
990
  return this.transport.request("GET", `${this.basePath(params.projectId)}/${serverId}`);
912
991
  }
992
+ /** Renames a server. */
993
+ async update(serverId, params) {
994
+ if (!serverId) throw new Error("serverId is required");
995
+ if (!params?.name) throw new Error("name is required");
996
+ return this.transport.request("PATCH", `${this.basePath(params.projectId)}/${serverId}`, {
997
+ body: { name: params.name }
998
+ });
999
+ }
1000
+ /**
1001
+ * Powers a stopped server on. Asynchronous: the server reads `PROVISIONING`
1002
+ * until it settles, so read it again to see the outcome. Refused with 409
1003
+ * while it is still being provisioned or is already running.
1004
+ */
1005
+ async powerOn(serverId, params = {}) {
1006
+ return this.action(serverId, "power_on", params);
1007
+ }
1008
+ /**
1009
+ * Cuts a running server's power — a hard stop, like pulling the plug, not a
1010
+ * shutdown its operating system sees coming. Asynchronous, like `powerOn`.
1011
+ * A stopped server is still billed.
1012
+ */
1013
+ async powerOff(serverId, params = {}) {
1014
+ return this.action(serverId, "power_off", params);
1015
+ }
1016
+ /** Reboots a running server. Asynchronous, like `powerOn`. */
1017
+ async reboot(serverId, params = {}) {
1018
+ return this.action(serverId, "reboot", params);
1019
+ }
913
1020
  /** Permanently deletes a server and its disk, and stops its billing. */
914
1021
  async delete(serverId, params = {}) {
915
1022
  if (!serverId) throw new Error("serverId is required");
@@ -945,6 +1052,13 @@ var ServersService = class {
945
1052
  }
946
1053
  });
947
1054
  }
1055
+ /** Runs one power action. */
1056
+ async action(serverId, action, params) {
1057
+ if (!serverId) throw new Error("serverId is required");
1058
+ return this.transport.request("POST", `${this.basePath(params.projectId)}/${serverId}/actions`, {
1059
+ body: { action }
1060
+ });
1061
+ }
948
1062
  };
949
1063
 
950
1064
  // src/services/ssh-keys.ts
@@ -1435,7 +1549,7 @@ function sleep(ms) {
1435
1549
  }
1436
1550
 
1437
1551
  // src/version.ts
1438
- var VERSION = "1.11.0";
1552
+ var VERSION = "1.12.0";
1439
1553
  var USER_AGENT = `cosmoner-node/${VERSION}`;
1440
1554
 
1441
1555
  // src/transport.ts
@@ -84,6 +84,14 @@ export type GetDedicatedDatabaseResponse = Envelope<DedicatedDatabaseDetail>;
84
84
  export type ListSharedDatabasesResponse = Envelope<SharedDatabase[]>;
85
85
  export type GetSharedDatabaseResponse = Envelope<SharedDatabase>;
86
86
  export type DeleteDatabaseResponse = Envelope<Record<string, never>>;
87
+ /** A shared database's new password, returned this once. */
88
+ export interface RotatedSharedDatabasePassword {
89
+ /** Store it now: no later read returns it. */
90
+ password: string;
91
+ /** The connection string with the new password in it. */
92
+ connectionUri: string;
93
+ }
94
+ export type RotateSharedDatabasePasswordResponse = Envelope<RotatedSharedDatabasePassword>;
87
95
  /** Arguments accepted by `client.databases.previewDedicated()`. */
88
96
  export interface PreviewDedicatedDatabaseParams extends ProjectScopedParams {
89
97
  /** A size slug from `client.catalog.databases()`. */
@@ -127,6 +135,12 @@ export declare class DatabasesService {
127
135
  deleteDedicated(databaseId: string, params?: ProjectScopedParams): Promise<DeleteDatabaseResponse>;
128
136
  /** Permanently deletes a shared database and its data, and stops its billing. */
129
137
  deleteShared(tenantId: string, params?: ProjectScopedParams): Promise<DeleteDatabaseResponse>;
138
+ /**
139
+ * Replaces a shared database's password. The old one stops working at once,
140
+ * so anything connecting with it fails until it is given the new one. The
141
+ * response holds the new password this once.
142
+ */
143
+ rotateSharedPassword(tenantId: string, params?: ProjectScopedParams): Promise<RotateSharedDatabasePasswordResponse>;
130
144
  /** Prices a dedicated database before ordering it. `monthly` is exact; `dueToday` is an estimate once the project has a subscription. */
131
145
  previewDedicated(params: PreviewDedicatedDatabaseParams): Promise<PreviewDedicatedDatabaseResponse>;
132
146
  /**
@@ -71,6 +71,64 @@ export interface GetEmailDomainResponse {
71
71
  success: true;
72
72
  data: EmailDomainDetail;
73
73
  }
74
+ /** Envelope returned by `client.email.createDomain()` and `createExternalDomain()`. */
75
+ export interface CreateEmailDomainResponse {
76
+ success: true;
77
+ data: EmailDomain;
78
+ }
79
+ /** Arguments accepted by `client.email.createDomain()`. */
80
+ export interface CreateEmailDomainParams extends ProjectScopedParams {
81
+ /** A domain already in the project, from `client.domains`. */
82
+ domainId: string;
83
+ }
84
+ /** Arguments accepted by `client.email.createExternalDomain()`. */
85
+ export interface CreateExternalEmailDomainParams extends ProjectScopedParams {
86
+ /** A domain whose DNS is hosted somewhere else. */
87
+ domainName: string;
88
+ }
89
+ /** What `client.email.verifyDomain()` found. */
90
+ export interface EmailDomainVerification {
91
+ status: EmailDomain["status"];
92
+ verifiedAt: string | null;
93
+ /** Each record to publish, and whether it was found. */
94
+ records: Array<EmailDomain["dnsRecords"][number] & {
95
+ verified: boolean;
96
+ error: string | null;
97
+ }>;
98
+ }
99
+ /** Envelope returned by `client.email.verifyDomain()`. */
100
+ export interface VerifyEmailDomainResponse {
101
+ success: true;
102
+ data: EmailDomainVerification;
103
+ }
104
+ /** The project's email plan, its allowances, and what it has sent against them. */
105
+ export interface EmailLimits {
106
+ plan: "PAY_AS_YOU_GO" | "STARTER" | "PRO" | "SCALE" | "BUSINESS";
107
+ /** Emails a month the plan's flat price covers; 0 on Pay as you go, where every email is billed. */
108
+ includedEmails: number;
109
+ /** The project's own monthly cap. */
110
+ monthlyQuota: number;
111
+ hourlyLimit: number;
112
+ dailyLimit: number;
113
+ sentThisMonth: number;
114
+ sentLastDay: number;
115
+ sentLastHour: number;
116
+ /** Start of the current quota month. */
117
+ periodStart: string;
118
+ /** Set while sending is paused: when it resumes. */
119
+ pausedUntil: string | null;
120
+ pauseReason: "HOURLY_LIMIT" | "DAILY_LIMIT" | "MONTHLY_QUOTA" | null;
121
+ pendingRequest: {
122
+ id: string;
123
+ requestedLimit: number;
124
+ createdAt: string;
125
+ } | null;
126
+ }
127
+ /** Envelope returned by `client.email.limits()`. */
128
+ export interface GetEmailLimitsResponse {
129
+ success: true;
130
+ data: EmailLimits;
131
+ }
74
132
  /** Arguments accepted by `client.email.createCredential()`. */
75
133
  export interface CreateSmtpCredentialParams extends ProjectScopedParams {
76
134
  label: string;
@@ -107,6 +165,27 @@ export declare class EmailService {
107
165
  listDomains(params?: ProjectScopedParams): Promise<ListEmailDomainsResponse>;
108
166
  /** Fetches one sending domain by its id (not its domain name). */
109
167
  getDomain(emailDomainId: string, params?: ProjectScopedParams): Promise<GetEmailDomainResponse>;
168
+ /**
169
+ * Sets a domain already in the project up for sending. The response lists
170
+ * the DNS records to publish; then call `verifyDomain`. 409 when email is
171
+ * already set up on it.
172
+ */
173
+ createDomain(params: CreateEmailDomainParams): Promise<CreateEmailDomainResponse>;
174
+ /**
175
+ * Sets up sending from a domain whose DNS is hosted elsewhere, adding it to
176
+ * the project as `PENDING` until its records resolve. The response lists the
177
+ * DNS records to publish; then call `verifyDomain`. 409 when the project
178
+ * already has the domain — use `createDomain` — or it cannot be used here.
179
+ */
180
+ createExternalDomain(params: CreateExternalEmailDomainParams): Promise<CreateEmailDomainResponse>;
181
+ /**
182
+ * Checks a sending domain's DNS records. When they all resolve the domain
183
+ * goes `ACTIVE`, and its first activation puts the project's email plan on
184
+ * its subscription — refused with 402 when the project cannot be billed.
185
+ */
186
+ verifyDomain(emailDomainId: string, params?: ProjectScopedParams): Promise<VerifyEmailDomainResponse>;
187
+ /** Reads the project's email plan, its sending limits and its usage against them. */
188
+ limits(params?: ProjectScopedParams): Promise<GetEmailLimitsResponse>;
110
189
  /**
111
190
  * Stops sending from a domain and removes it from email. The domain itself
112
191
  * stays in the project. The API answers 204, so there is nothing to return.
@@ -27,8 +27,15 @@ interface Envelope<T> {
27
27
  }
28
28
  export type ListProjectsResponse = Envelope<Project[]>;
29
29
  export type GetProjectResponse = Envelope<Project>;
30
+ /** Arguments accepted by `client.projects.update()`. */
31
+ export interface UpdateProjectParams {
32
+ /** 1–100 characters, unique among the caller's projects. */
33
+ name: string;
34
+ }
35
+ export type UpdateProjectResponse = Envelope<Pick<Project, "id" | "name" | "slug" | "billingEmail">>;
36
+ export type DeleteProjectResponse = Envelope<null>;
30
37
  /**
31
- * Reads the projects the credential can reach.
38
+ * The projects the credential can reach.
32
39
  *
33
40
  * Account-level: it never uses the client's default project. An API key sees
34
41
  * the one project it was issued for; a `cosmoner login` session sees every
@@ -41,5 +48,13 @@ export declare class ProjectsService {
41
48
  list(): Promise<ListProjectsResponse>;
42
49
  /** Fetches one project by id or slug. */
43
50
  get(project: string): Promise<GetProjectResponse>;
51
+ /** Renames a project. Owners and admins only; 409 when the caller already has a project of that name. */
52
+ update(project: string, params: UpdateProjectParams): Promise<UpdateProjectResponse>;
53
+ /**
54
+ * Permanently deletes a project. Owner only, and refused with 409 while it
55
+ * still holds resources — servers, apps, databases and the rest have to be
56
+ * deleted first, so nothing is left running and billed with no project.
57
+ */
58
+ delete(project: string): Promise<DeleteProjectResponse>;
44
59
  }
45
60
  export {};
@@ -43,6 +43,14 @@ interface Envelope<T> {
43
43
  export type ListServersResponse = Envelope<Server[]>;
44
44
  export type GetServerResponse = Envelope<ServerDetail>;
45
45
  export type DeleteServerResponse = Envelope<Record<string, never>>;
46
+ /** Arguments accepted by `client.servers.update()`. */
47
+ export interface UpdateServerParams extends ProjectScopedParams {
48
+ /** Lowercase letters, digits and hyphens, at most 63 characters. */
49
+ name: string;
50
+ }
51
+ export type UpdateServerResponse = Envelope<Server>;
52
+ /** The server as the action left it: `PROVISIONING` until the action settles. */
53
+ export type ServerActionResponse = Envelope<Server>;
46
54
  /** Arguments accepted by `client.servers.preview()`. */
47
55
  export interface PreviewServerParams extends ProjectScopedParams {
48
56
  /** A size slug from `client.catalog.serverSizes()`. */
@@ -76,6 +84,22 @@ export declare class ServersService {
76
84
  list(params?: ProjectScopedParams): Promise<ListServersResponse>;
77
85
  /** Fetches one server, with the SSH keys installed on it. */
78
86
  get(serverId: string, params?: ProjectScopedParams): Promise<GetServerResponse>;
87
+ /** Renames a server. */
88
+ update(serverId: string, params: UpdateServerParams): Promise<UpdateServerResponse>;
89
+ /**
90
+ * Powers a stopped server on. Asynchronous: the server reads `PROVISIONING`
91
+ * until it settles, so read it again to see the outcome. Refused with 409
92
+ * while it is still being provisioned or is already running.
93
+ */
94
+ powerOn(serverId: string, params?: ProjectScopedParams): Promise<ServerActionResponse>;
95
+ /**
96
+ * Cuts a running server's power — a hard stop, like pulling the plug, not a
97
+ * shutdown its operating system sees coming. Asynchronous, like `powerOn`.
98
+ * A stopped server is still billed.
99
+ */
100
+ powerOff(serverId: string, params?: ProjectScopedParams): Promise<ServerActionResponse>;
101
+ /** Reboots a running server. Asynchronous, like `powerOn`. */
102
+ reboot(serverId: string, params?: ProjectScopedParams): Promise<ServerActionResponse>;
79
103
  /** Permanently deletes a server and its disk, and stops its billing. */
80
104
  delete(serverId: string, params?: ProjectScopedParams): Promise<DeleteServerResponse>;
81
105
  /** Prices a server before ordering it. `monthly` is exact; `dueToday` is an estimate once the project has a subscription. */
@@ -89,5 +113,7 @@ export declare class ServersService {
89
113
  * billed.
90
114
  */
91
115
  create(params: CreateServerParams): Promise<CreateServerResponse>;
116
+ /** Runs one power action. */
117
+ private action;
92
118
  }
93
119
  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.11.0";
12
- export declare const USER_AGENT = "cosmoner-node/1.11.0";
11
+ export declare const VERSION = "1.12.0";
12
+ export declare const USER_AGENT = "cosmoner-node/1.12.0";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cosmoner/sdk",
3
- "version": "1.11.0",
3
+ "version": "1.12.0",
4
4
  "description": "Cosmoner SDK for Node.js",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",