@cosmoner/sdk 1.16.1 → 1.18.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
@@ -161,6 +161,39 @@ const { data: access } = await client.hosting.access(sites[0].id);
161
161
  `sftpPassword`. It needs no scope beyond `hosting:read`, so guard the key
162
162
  accordingly.
163
163
 
164
+ ### Site image, PHP version and email
165
+
166
+ A site runs one exact build of the site image and never changes build on its
167
+ own, except for a fix to a critical or known-exploited vulnerability, which is
168
+ applied during the night after `forcedUpdate.deadline`.
169
+
170
+ ```ts
171
+ const { data: image } = await client.hosting.image(siteId);
172
+ // image.current.tag, image.update (null when up to date), image.forcedUpdate,
173
+ // image.rollback (with `until`), image.php.{version, securitySupportEnds, offered}
174
+
175
+ if (image.update) await client.hosting.updateImage(siteId);
176
+ await client.hosting.rollbackImage(siteId); // within 7 days of the last change
177
+ await client.hosting.setPhpVersion(siteId, { phpVersion: image.php.offered[0] });
178
+ ```
179
+
180
+ `updateImage`, `rollbackImage` and `setPhpVersion` restart the site before
181
+ they answer, and each returns the image status afterwards. Only the versions in
182
+ `php.offered` are accepted; the API owns that list, so the SDK does not check
183
+ it. They need `hosting:write`.
184
+
185
+ ```ts
186
+ const { data: mail } = await client.hosting.mail(siteId);
187
+ // mail.enabled, mail.fromAddress, mail.domains — the verified email domains it can send from
188
+ await client.hosting.enableMail(siteId, { emailDomainId: mail.domains[0].id, localPart: "wordpress" });
189
+ await client.hosting.disableMail(siteId);
190
+ ```
191
+
192
+ `enableMail` lets the site's PHP `mail()` send as `<localPart>@<domain>`
193
+ through a new SMTP credential, and every email it sends is billed on the
194
+ project's email plan. `enableMail` and `disableMail` need `email:write` as well
195
+ as `hosting:write`.
196
+
164
197
  ## Resource namespaces
165
198
 
166
199
  Each of these works on one kind of resource and returns the API envelope.
@@ -86,6 +86,14 @@ export type FieldTable = Record<string, FieldSpec>;
86
86
  export declare const ENV_FIELDS: FieldTable;
87
87
  /** Fields of a service's `build` mapping. */
88
88
  export declare const BUILD_FIELDS: FieldTable;
89
+ /**
90
+ * Fields of a service's `previews` mapping.
91
+ *
92
+ * `enabled` only preselects pull request previews in the deploy wizard, which
93
+ * shows their hourly price there. Previews are billed, so the platform never
94
+ * switches them on or off from a commit to this file.
95
+ */
96
+ export declare const PREVIEWS_FIELDS: FieldTable;
89
97
  /** Fields of one entry under `services`. */
90
98
  export declare const SERVICE_FIELDS: FieldTable;
91
99
  /** Fields of the document itself. */
@@ -35,6 +35,16 @@ export interface DeploymentBuild {
35
35
  /** Where a static build writes the site. Static sites only. */
36
36
  output_dir?: string;
37
37
  }
38
+ /**
39
+ * Pull request previews for a service. GitHub repositories only.
40
+ *
41
+ * Previews are billed per preview for each hour they run, so `enabled` only
42
+ * preselects the option in the deploy wizard, where the price is shown. A
43
+ * commit never turns previews on or off.
44
+ */
45
+ export interface DeploymentPreviews {
46
+ enabled: boolean;
47
+ }
38
48
  /** One service defined by the file. Each deploy sets up one of them. */
39
49
  export interface DeploymentService {
40
50
  name: string;
@@ -51,6 +61,7 @@ export interface DeploymentService {
51
61
  instance_size?: string;
52
62
  instances?: number;
53
63
  autodeploy?: boolean;
64
+ previews?: DeploymentPreviews;
54
65
  envs?: DeploymentEnvVar[];
55
66
  }
56
67
  /**
package/dist/index.d.ts CHANGED
@@ -4,14 +4,14 @@ export { DEFAULT_BASE_URL, DEFAULT_MAX_RETRIES, DEFAULT_TIMEOUT_MS, type Cosmone
4
4
  export { AuthenticationError, ConflictError, CosmonerConnectionError, CosmonerError, CosmonerTimeoutError, InsufficientScopeError, NotFoundError, RateLimitError, ServerError, ValidationError, WebhookSignatureError, } from "./errors";
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
- export type { DeploymentBuild, DeploymentEnvVar, DeploymentIssue, DeploymentIssueSeverity, DeploymentService, DeploymentTemplate, DeploymentValidationResult, ValidateDeploymentOptions, } from "./deployment/types";
7
+ export type { DeploymentBuild, DeploymentEnvVar, DeploymentIssue, DeploymentIssueSeverity, DeploymentPreviews, DeploymentService, DeploymentTemplate, DeploymentValidationResult, ValidateDeploymentOptions, } from "./deployment/types";
8
8
  export { AppsService, FINISHED_DEPLOYMENT_PHASES, type App, type AppDeployment, type AppDeploymentHistoryEntry, 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 ListDeploymentsResponse, type PreviewAppResizeResponse, type PreviewAppResponse, type ResizeAppResponse, type RollbackAppResponse, 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
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
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
- 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
+ export { HostingService, type CreateHostingSiteParams, type CreateHostingSiteResponse, type DeleteHostingSiteResponse, type EnableHostingMailParams, type GetHostingAccessResponse, type GetHostingSiteParams, type GetHostingSiteResponse, type GetHostingSiteWithCredentialsResponse, type HostingAccess, type HostingImageBuild, type HostingImageStatus, type HostingImageStatusResponse, type HostingImageUpdate, type HostingMailStatus, type HostingMailStatusResponse, type HostingPrice, type HostingSite, type HostingSiteStatus, type HostingSiteWithCredentials, type HostingTier, type ListHostingPricesResponse, type ListHostingSitesResponse, type PreviewHostingSiteParams, type PreviewHostingSiteResponse, type SetHostingPhpVersionParams, } 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";
package/dist/index.js CHANGED
@@ -768,6 +768,76 @@ var HostingService = class {
768
768
  }
769
769
  });
770
770
  }
771
+ /**
772
+ * Reads which build of the site image a site runs, the patched build it can
773
+ * update to, whether that update will be applied automatically and when,
774
+ * what it can roll back to, and where its PHP version stands.
775
+ */
776
+ async image(siteId, params = {}) {
777
+ if (!siteId) throw new Error("siteId is required");
778
+ return this.transport.request("GET", `${this.basePath(params.projectId)}/${siteId}/image`);
779
+ }
780
+ /**
781
+ * Moves a site to the newest patched build of its PHP version, the `update`
782
+ * in `image()`. The site restarts before this answers, which interrupts it
783
+ * for a few seconds; `rollbackImage()` restores the previous build for 7 days.
784
+ * Answers 409 when the site already runs the newest build.
785
+ */
786
+ async updateImage(siteId, params = {}) {
787
+ if (!siteId) throw new Error("siteId is required");
788
+ return this.transport.request("POST", `${this.basePath(params.projectId)}/${siteId}/image/update`);
789
+ }
790
+ /**
791
+ * Returns a site to the build it ran before its last update or PHP version
792
+ * change, PHP version included, until `rollback.until` in `image()`. The site
793
+ * restarts before this answers. A rollback cannot itself be rolled back, and
794
+ * rolling back a forced security update only postpones it.
795
+ */
796
+ async rollbackImage(siteId, params = {}) {
797
+ if (!siteId) throw new Error("siteId is required");
798
+ return this.transport.request("POST", `${this.basePath(params.projectId)}/${siteId}/image/rollback`);
799
+ }
800
+ /**
801
+ * Moves a site to another PHP version, onto its newest patched build. Only
802
+ * the versions in `php.offered` from `image()` are accepted; the API owns
803
+ * that list. The site restarts before this answers, and `rollbackImage()`
804
+ * restores the previous version for 7 days.
805
+ */
806
+ async setPhpVersion(siteId, params) {
807
+ if (!siteId) throw new Error("siteId is required");
808
+ if (!params?.phpVersion) throw new Error("phpVersion is required");
809
+ return this.transport.request("PATCH", `${this.basePath(params.projectId)}/${siteId}/php-version`, {
810
+ body: { phpVersion: params.phpVersion }
811
+ });
812
+ }
813
+ /** Reads whether a site's PHP `mail()` can send, the address it sends as, and the domains it could send from. */
814
+ async mail(siteId, params = {}) {
815
+ if (!siteId) throw new Error("siteId is required");
816
+ return this.transport.request("GET", `${this.basePath(params.projectId)}/${siteId}/mail`);
817
+ }
818
+ /**
819
+ * Lets a site's PHP `mail()` send as `<localPart>@<domain>`, through a new
820
+ * SMTP credential on the verified email domain `emailDomainId`. Every email
821
+ * the site sends is billed on the project's email plan. Sent again with
822
+ * another address, it replaces the site's credential. Needs `email:write` as
823
+ * well as `hosting:write`.
824
+ */
825
+ async enableMail(siteId, params) {
826
+ if (!siteId) throw new Error("siteId is required");
827
+ if (!params?.emailDomainId) throw new Error("emailDomainId is required");
828
+ if (!params.localPart) throw new Error("localPart is required");
829
+ return this.transport.request("PUT", `${this.basePath(params.projectId)}/${siteId}/mail`, {
830
+ body: { emailDomainId: params.emailDomainId, localPart: params.localPart }
831
+ });
832
+ }
833
+ /**
834
+ * Stops a site sending email and deletes its SMTP credential; afterwards
835
+ * `mail()` returns `false`. Needs `email:write` as well as `hosting:write`.
836
+ */
837
+ async disableMail(siteId, params = {}) {
838
+ if (!siteId) throw new Error("siteId is required");
839
+ return this.transport.request("DELETE", `${this.basePath(params.projectId)}/${siteId}/mail`);
840
+ }
771
841
  };
772
842
 
773
843
  // src/services/iam.ts
@@ -1648,7 +1718,7 @@ function sleep(ms) {
1648
1718
  }
1649
1719
 
1650
1720
  // src/version.ts
1651
- var VERSION = "1.16.1";
1721
+ var VERSION = "1.18.0";
1652
1722
  var USER_AGENT = `cosmoner-node/${VERSION}`;
1653
1723
 
1654
1724
  // src/transport.ts
@@ -1836,6 +1906,9 @@ var BUILD_FIELDS = {
1836
1906
  command: { kind: "string", maxLength: 1024 },
1837
1907
  output_dir: { kind: "string", maxLength: 512 }
1838
1908
  };
1909
+ var PREVIEWS_FIELDS = {
1910
+ enabled: { kind: "boolean", required: true }
1911
+ };
1839
1912
  var SERVICE_FIELDS = {
1840
1913
  name: {
1841
1914
  kind: "string",
@@ -1855,6 +1928,7 @@ var SERVICE_FIELDS = {
1855
1928
  instance_size: { kind: "string", maxLength: 64 },
1856
1929
  instances: { kind: "integer", minimum: 1, maximum: 10 },
1857
1930
  autodeploy: { kind: "boolean" },
1931
+ previews: { kind: "object", fields: PREVIEWS_FIELDS },
1858
1932
  envs: { kind: "array", maxItems: 100, item: { kind: "object", fields: ENV_FIELDS } }
1859
1933
  };
1860
1934
  var ROOT_FIELDS = {
package/dist/index.mjs CHANGED
@@ -693,6 +693,76 @@ var HostingService = class {
693
693
  }
694
694
  });
695
695
  }
696
+ /**
697
+ * Reads which build of the site image a site runs, the patched build it can
698
+ * update to, whether that update will be applied automatically and when,
699
+ * what it can roll back to, and where its PHP version stands.
700
+ */
701
+ async image(siteId, params = {}) {
702
+ if (!siteId) throw new Error("siteId is required");
703
+ return this.transport.request("GET", `${this.basePath(params.projectId)}/${siteId}/image`);
704
+ }
705
+ /**
706
+ * Moves a site to the newest patched build of its PHP version, the `update`
707
+ * in `image()`. The site restarts before this answers, which interrupts it
708
+ * for a few seconds; `rollbackImage()` restores the previous build for 7 days.
709
+ * Answers 409 when the site already runs the newest build.
710
+ */
711
+ async updateImage(siteId, params = {}) {
712
+ if (!siteId) throw new Error("siteId is required");
713
+ return this.transport.request("POST", `${this.basePath(params.projectId)}/${siteId}/image/update`);
714
+ }
715
+ /**
716
+ * Returns a site to the build it ran before its last update or PHP version
717
+ * change, PHP version included, until `rollback.until` in `image()`. The site
718
+ * restarts before this answers. A rollback cannot itself be rolled back, and
719
+ * rolling back a forced security update only postpones it.
720
+ */
721
+ async rollbackImage(siteId, params = {}) {
722
+ if (!siteId) throw new Error("siteId is required");
723
+ return this.transport.request("POST", `${this.basePath(params.projectId)}/${siteId}/image/rollback`);
724
+ }
725
+ /**
726
+ * Moves a site to another PHP version, onto its newest patched build. Only
727
+ * the versions in `php.offered` from `image()` are accepted; the API owns
728
+ * that list. The site restarts before this answers, and `rollbackImage()`
729
+ * restores the previous version for 7 days.
730
+ */
731
+ async setPhpVersion(siteId, params) {
732
+ if (!siteId) throw new Error("siteId is required");
733
+ if (!params?.phpVersion) throw new Error("phpVersion is required");
734
+ return this.transport.request("PATCH", `${this.basePath(params.projectId)}/${siteId}/php-version`, {
735
+ body: { phpVersion: params.phpVersion }
736
+ });
737
+ }
738
+ /** Reads whether a site's PHP `mail()` can send, the address it sends as, and the domains it could send from. */
739
+ async mail(siteId, params = {}) {
740
+ if (!siteId) throw new Error("siteId is required");
741
+ return this.transport.request("GET", `${this.basePath(params.projectId)}/${siteId}/mail`);
742
+ }
743
+ /**
744
+ * Lets a site's PHP `mail()` send as `<localPart>@<domain>`, through a new
745
+ * SMTP credential on the verified email domain `emailDomainId`. Every email
746
+ * the site sends is billed on the project's email plan. Sent again with
747
+ * another address, it replaces the site's credential. Needs `email:write` as
748
+ * well as `hosting:write`.
749
+ */
750
+ async enableMail(siteId, params) {
751
+ if (!siteId) throw new Error("siteId is required");
752
+ if (!params?.emailDomainId) throw new Error("emailDomainId is required");
753
+ if (!params.localPart) throw new Error("localPart is required");
754
+ return this.transport.request("PUT", `${this.basePath(params.projectId)}/${siteId}/mail`, {
755
+ body: { emailDomainId: params.emailDomainId, localPart: params.localPart }
756
+ });
757
+ }
758
+ /**
759
+ * Stops a site sending email and deletes its SMTP credential; afterwards
760
+ * `mail()` returns `false`. Needs `email:write` as well as `hosting:write`.
761
+ */
762
+ async disableMail(siteId, params = {}) {
763
+ if (!siteId) throw new Error("siteId is required");
764
+ return this.transport.request("DELETE", `${this.basePath(params.projectId)}/${siteId}/mail`);
765
+ }
696
766
  };
697
767
 
698
768
  // src/services/iam.ts
@@ -1573,7 +1643,7 @@ function sleep(ms) {
1573
1643
  }
1574
1644
 
1575
1645
  // src/version.ts
1576
- var VERSION = "1.16.1";
1646
+ var VERSION = "1.18.0";
1577
1647
  var USER_AGENT = `cosmoner-node/${VERSION}`;
1578
1648
 
1579
1649
  // src/transport.ts
@@ -1761,6 +1831,9 @@ var BUILD_FIELDS = {
1761
1831
  command: { kind: "string", maxLength: 1024 },
1762
1832
  output_dir: { kind: "string", maxLength: 512 }
1763
1833
  };
1834
+ var PREVIEWS_FIELDS = {
1835
+ enabled: { kind: "boolean", required: true }
1836
+ };
1764
1837
  var SERVICE_FIELDS = {
1765
1838
  name: {
1766
1839
  kind: "string",
@@ -1780,6 +1853,7 @@ var SERVICE_FIELDS = {
1780
1853
  instance_size: { kind: "string", maxLength: 64 },
1781
1854
  instances: { kind: "integer", minimum: 1, maximum: 10 },
1782
1855
  autodeploy: { kind: "boolean" },
1856
+ previews: { kind: "object", fields: PREVIEWS_FIELDS },
1783
1857
  envs: { kind: "array", maxItems: 100, item: { kind: "object", fields: ENV_FIELDS } }
1784
1858
  };
1785
1859
  var ROOT_FIELDS = {
@@ -1,4 +1,7 @@
1
- /** Hosting service namespace — shared web hosting sites and how to reach their files. */
1
+ /**
2
+ * Hosting service namespace — shared web hosting sites, how to reach their
3
+ * files, the site image they run and whether they can send email.
4
+ */
2
5
  import { type ResolvedConfig } from "../config";
3
6
  import type { CheckoutPreview } from "./preview";
4
7
  import type { Transport } from "../transport";
@@ -92,7 +95,7 @@ export interface CreateHostingSiteParams extends ProjectScopedParams {
92
95
  siteName: string;
93
96
  /** Defaults to `STARTER` server-side. */
94
97
  tier?: HostingTier;
95
- /** `8.1`, `8.2` or `8.3`; defaults to `8.3` server-side. */
98
+ /** One of the offered PHP versions; the API owns that list and picks a default when left out. */
96
99
  phpVersion?: string;
97
100
  /** Creates a MySQL database with this name alongside the site. */
98
101
  database?: string;
@@ -111,7 +114,99 @@ export type CreateHostingSiteResponse = Envelope<{
111
114
  /** Set when the site was created but its database was not. */
112
115
  databaseError?: string;
113
116
  }>;
114
- /** Read operations on a project's shared hosting sites. */
117
+ /** One build of the site image. */
118
+ export interface HostingImageBuild {
119
+ phpVersion: string;
120
+ /**
121
+ * The build's dated tag, e.g. `8.4-20261025`. Null for a site created before
122
+ * images were pinned that has not been updated since.
123
+ */
124
+ tag: string | null;
125
+ /** The build's image digest, `sha256:…`. Null exactly when `tag` is. */
126
+ digest: string | null;
127
+ }
128
+ /** A newer patched build of the site's PHP version. */
129
+ export interface HostingImageUpdate {
130
+ phpVersion: string;
131
+ tag: string;
132
+ digest: string;
133
+ /** When the build was made, when known. */
134
+ builtAt: string | null;
135
+ /** The build fixes a vulnerability rated critical. */
136
+ critical: boolean;
137
+ /** The build fixes a vulnerability known to be exploited. */
138
+ knownExploited: boolean;
139
+ /** The critical or known-exploited vulnerabilities it fixes, by CVE id, when known. */
140
+ cves: string[];
141
+ /** The PHP release inside the build, e.g. `8.4.28`, when known. */
142
+ phpPatch: string | null;
143
+ /** The build carries a newer PHP release than the site runs; PHP's own security fixes show up here rather than in `cves`. */
144
+ phpRelease: boolean;
145
+ }
146
+ /** Which build of the site image a site runs, what it can update to, and what it can roll back to. */
147
+ export interface HostingImageStatus {
148
+ /** The build the site runs. It changes only through an update, a rollback, a PHP version change or a forced security update. */
149
+ current: HostingImageBuild;
150
+ /** When the current build was applied. Null before the site's first change. */
151
+ updatedAt: string | null;
152
+ /** A newer patched build of the site's PHP version, or null when the site is up to date. */
153
+ update: HostingImageUpdate | null;
154
+ /**
155
+ * Set when the update fixes a critical or known-exploited vulnerability; it
156
+ * is then applied automatically during the night after `deadline`.
157
+ */
158
+ forcedUpdate: {
159
+ deadline: string;
160
+ } | null;
161
+ /** The build the site ran before its last change, while `until` has not passed. */
162
+ rollback: (HostingImageBuild & {
163
+ until: string;
164
+ }) | null;
165
+ php: {
166
+ version: string;
167
+ /** The last day the version receives security fixes, as `YYYY-MM-DD`. */
168
+ securitySupportEnds: string | null;
169
+ /** No longer offered for new sites; the site should be upgraded. */
170
+ deprecated: boolean;
171
+ /** The versions `setPhpVersion()` accepts. */
172
+ offered: string[];
173
+ };
174
+ }
175
+ /** Whether a site's PHP `mail()` can send, and as whom. */
176
+ export interface HostingMailStatus {
177
+ /** Whether sites in this environment can send email at all. When false, `enableMail()` answers 503. */
178
+ available: boolean;
179
+ /** Whether the site's `mail()` sends. While false it returns `false`. */
180
+ enabled: boolean;
181
+ /** The address the site sends as. Null while email is off. */
182
+ fromAddress: string | null;
183
+ /** The SMTP credential the site sends with, listed under the project's email domains. Null while email is off. */
184
+ credentialId: string | null;
185
+ /** The email domain of that credential. Null while email is off. */
186
+ emailDomainId: string | null;
187
+ /** The project's verified email domains the site can send from. */
188
+ domains: Array<{
189
+ id: string;
190
+ name: string;
191
+ }>;
192
+ }
193
+ /** Arguments accepted by `client.hosting.setPhpVersion()`. */
194
+ export interface SetHostingPhpVersionParams extends ProjectScopedParams {
195
+ /** One of `php.offered` from `image()`. */
196
+ phpVersion: string;
197
+ }
198
+ /** Arguments accepted by `client.hosting.enableMail()`. */
199
+ export interface EnableHostingMailParams extends ProjectScopedParams {
200
+ /** A verified email domain of the project, from `mail()` or `client.email.listDomains()`. */
201
+ emailDomainId: string;
202
+ /** The part before the @ of the address the site sends as, e.g. `wordpress`. */
203
+ localPart: string;
204
+ }
205
+ /** Every image route answers with the site's image status as it stands afterwards. */
206
+ export type HostingImageStatusResponse = Envelope<HostingImageStatus>;
207
+ /** Every mail route answers with the site's mail status as it stands afterwards. */
208
+ export type HostingMailStatusResponse = Envelope<HostingMailStatus>;
209
+ /** Operations on a project's shared hosting sites. */
115
210
  export declare class HostingService {
116
211
  private readonly transport;
117
212
  private readonly config;
@@ -141,5 +236,47 @@ export declare class HostingService {
141
236
  * billed.
142
237
  */
143
238
  create(params: CreateHostingSiteParams): Promise<CreateHostingSiteResponse>;
239
+ /**
240
+ * Reads which build of the site image a site runs, the patched build it can
241
+ * update to, whether that update will be applied automatically and when,
242
+ * what it can roll back to, and where its PHP version stands.
243
+ */
244
+ image(siteId: string, params?: ProjectScopedParams): Promise<HostingImageStatusResponse>;
245
+ /**
246
+ * Moves a site to the newest patched build of its PHP version, the `update`
247
+ * in `image()`. The site restarts before this answers, which interrupts it
248
+ * for a few seconds; `rollbackImage()` restores the previous build for 7 days.
249
+ * Answers 409 when the site already runs the newest build.
250
+ */
251
+ updateImage(siteId: string, params?: ProjectScopedParams): Promise<HostingImageStatusResponse>;
252
+ /**
253
+ * Returns a site to the build it ran before its last update or PHP version
254
+ * change, PHP version included, until `rollback.until` in `image()`. The site
255
+ * restarts before this answers. A rollback cannot itself be rolled back, and
256
+ * rolling back a forced security update only postpones it.
257
+ */
258
+ rollbackImage(siteId: string, params?: ProjectScopedParams): Promise<HostingImageStatusResponse>;
259
+ /**
260
+ * Moves a site to another PHP version, onto its newest patched build. Only
261
+ * the versions in `php.offered` from `image()` are accepted; the API owns
262
+ * that list. The site restarts before this answers, and `rollbackImage()`
263
+ * restores the previous version for 7 days.
264
+ */
265
+ setPhpVersion(siteId: string, params: SetHostingPhpVersionParams): Promise<HostingImageStatusResponse>;
266
+ /** Reads whether a site's PHP `mail()` can send, the address it sends as, and the domains it could send from. */
267
+ mail(siteId: string, params?: ProjectScopedParams): Promise<HostingMailStatusResponse>;
268
+ /**
269
+ * Lets a site's PHP `mail()` send as `<localPart>@<domain>`, through a new
270
+ * SMTP credential on the verified email domain `emailDomainId`. Every email
271
+ * the site sends is billed on the project's email plan. Sent again with
272
+ * another address, it replaces the site's credential. Needs `email:write` as
273
+ * well as `hosting:write`.
274
+ */
275
+ enableMail(siteId: string, params: EnableHostingMailParams): Promise<HostingMailStatusResponse>;
276
+ /**
277
+ * Stops a site sending email and deletes its SMTP credential; afterwards
278
+ * `mail()` returns `false`. Needs `email:write` as well as `hosting:write`.
279
+ */
280
+ disableMail(siteId: string, params?: ProjectScopedParams): Promise<HostingMailStatusResponse>;
144
281
  }
145
282
  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.16.1";
12
- export declare const USER_AGENT = "cosmoner-node/1.16.1";
11
+ export declare const VERSION = "1.18.0";
12
+ export declare const USER_AGENT = "cosmoner-node/1.18.0";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cosmoner/sdk",
3
- "version": "1.16.1",
3
+ "version": "1.18.0",
4
4
  "description": "Cosmoner SDK for Node.js",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",