@cosmoner/sdk 1.14.1 → 1.15.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 +20 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +25 -1
- package/dist/index.mjs +25 -1
- package/dist/services/apps.d.ts +21 -1
- package/dist/version.d.ts +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -126,6 +126,26 @@ Needs `apps:read`.
|
|
|
126
126
|
`client.apps.list()` and `client.apps.getDeployment(appId, deploymentId)` are
|
|
127
127
|
the single calls underneath.
|
|
128
128
|
|
|
129
|
+
### `client.apps.listDeployments(appId, params?)` and `client.apps.rollback(appId, deploymentId, params?)`
|
|
130
|
+
|
|
131
|
+
`listDeployments` returns the app's twenty most recent deployments, newest
|
|
132
|
+
first. Each also carries `current`, whether its image is the one the app runs
|
|
133
|
+
now, and `rollbackable`, whether the app can go back to it. Needs `apps:read`.
|
|
134
|
+
|
|
135
|
+
`rollback` puts the app back on the image an earlier deployment ran, without
|
|
136
|
+
building, and returns the new deployment without waiting. It works for apps
|
|
137
|
+
built from a repository as well as image apps. Only the image goes back: the app
|
|
138
|
+
keeps its current environment variables and settings. Needs `apps:write`.
|
|
139
|
+
|
|
140
|
+
```ts
|
|
141
|
+
const { data: history } = await client.apps.listDeployments(appId);
|
|
142
|
+
const previous = history.find((d) => d.rollbackable);
|
|
143
|
+
if (previous) {
|
|
144
|
+
const { data: rollback } = await client.apps.rollback(appId, previous.id);
|
|
145
|
+
await client.apps.waitForDeployment(appId, rollback.id);
|
|
146
|
+
}
|
|
147
|
+
```
|
|
148
|
+
|
|
129
149
|
## Hosting
|
|
130
150
|
|
|
131
151
|
Reads a project's shared hosting sites and where to reach their files. Needs an
|
package/dist/index.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ 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 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";
|
|
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";
|
package/dist/index.js
CHANGED
|
@@ -177,6 +177,30 @@ var AppsService = class {
|
|
|
177
177
|
`${this.basePath(params.projectId)}/${appId}/deployments/${deploymentId}`
|
|
178
178
|
);
|
|
179
179
|
}
|
|
180
|
+
/** Lists the app's most recent deployments, newest first. */
|
|
181
|
+
async listDeployments(appId, params = {}) {
|
|
182
|
+
if (!appId) throw new Error("appId is required");
|
|
183
|
+
return this.transport.request(
|
|
184
|
+
"GET",
|
|
185
|
+
`${this.basePath(params.projectId)}/${appId}/deployments`
|
|
186
|
+
);
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Rolls the app back to the image an earlier deployment ran, without
|
|
190
|
+
* building, and returns the new deployment without waiting.
|
|
191
|
+
*
|
|
192
|
+
* Only the image goes back: the app keeps its current environment variables
|
|
193
|
+
* and settings. Pick a deployment `listDeployments()` marks `rollbackable`,
|
|
194
|
+
* and pair with `waitForDeployment()` to learn whether the rollout succeeded.
|
|
195
|
+
*/
|
|
196
|
+
async rollback(appId, deploymentId, params = {}) {
|
|
197
|
+
if (!appId) throw new Error("appId is required");
|
|
198
|
+
if (!deploymentId) throw new Error("deploymentId is required");
|
|
199
|
+
return this.transport.request(
|
|
200
|
+
"POST",
|
|
201
|
+
`${this.basePath(params.projectId)}/${appId}/deployments/${deploymentId}/rollback`
|
|
202
|
+
);
|
|
203
|
+
}
|
|
180
204
|
/**
|
|
181
205
|
* Polls a deployment until it finishes, and returns it in its final phase.
|
|
182
206
|
*
|
|
@@ -1624,7 +1648,7 @@ function sleep(ms) {
|
|
|
1624
1648
|
}
|
|
1625
1649
|
|
|
1626
1650
|
// src/version.ts
|
|
1627
|
-
var VERSION = "1.
|
|
1651
|
+
var VERSION = "1.15.0";
|
|
1628
1652
|
var USER_AGENT = `cosmoner-node/${VERSION}`;
|
|
1629
1653
|
|
|
1630
1654
|
// src/transport.ts
|
package/dist/index.mjs
CHANGED
|
@@ -102,6 +102,30 @@ var AppsService = class {
|
|
|
102
102
|
`${this.basePath(params.projectId)}/${appId}/deployments/${deploymentId}`
|
|
103
103
|
);
|
|
104
104
|
}
|
|
105
|
+
/** Lists the app's most recent deployments, newest first. */
|
|
106
|
+
async listDeployments(appId, params = {}) {
|
|
107
|
+
if (!appId) throw new Error("appId is required");
|
|
108
|
+
return this.transport.request(
|
|
109
|
+
"GET",
|
|
110
|
+
`${this.basePath(params.projectId)}/${appId}/deployments`
|
|
111
|
+
);
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Rolls the app back to the image an earlier deployment ran, without
|
|
115
|
+
* building, and returns the new deployment without waiting.
|
|
116
|
+
*
|
|
117
|
+
* Only the image goes back: the app keeps its current environment variables
|
|
118
|
+
* and settings. Pick a deployment `listDeployments()` marks `rollbackable`,
|
|
119
|
+
* and pair with `waitForDeployment()` to learn whether the rollout succeeded.
|
|
120
|
+
*/
|
|
121
|
+
async rollback(appId, deploymentId, params = {}) {
|
|
122
|
+
if (!appId) throw new Error("appId is required");
|
|
123
|
+
if (!deploymentId) throw new Error("deploymentId is required");
|
|
124
|
+
return this.transport.request(
|
|
125
|
+
"POST",
|
|
126
|
+
`${this.basePath(params.projectId)}/${appId}/deployments/${deploymentId}/rollback`
|
|
127
|
+
);
|
|
128
|
+
}
|
|
105
129
|
/**
|
|
106
130
|
* Polls a deployment until it finishes, and returns it in its final phase.
|
|
107
131
|
*
|
|
@@ -1549,7 +1573,7 @@ function sleep(ms) {
|
|
|
1549
1573
|
}
|
|
1550
1574
|
|
|
1551
1575
|
// src/version.ts
|
|
1552
|
-
var VERSION = "1.
|
|
1576
|
+
var VERSION = "1.15.0";
|
|
1553
1577
|
var USER_AGENT = `cosmoner-node/${VERSION}`;
|
|
1554
1578
|
|
|
1555
1579
|
// src/transport.ts
|
package/dist/services/apps.d.ts
CHANGED
|
@@ -36,13 +36,20 @@ export interface AppDeployment {
|
|
|
36
36
|
phase: DeploymentPhase;
|
|
37
37
|
/** Why it happened, e.g. "registry push" or "api deploy". */
|
|
38
38
|
cause: string | null;
|
|
39
|
-
/** The image reference that was deployed. */
|
|
39
|
+
/** The image reference that was deployed. Null until a build has produced its image. */
|
|
40
40
|
imageRef: string | null;
|
|
41
41
|
imageDigest: string | null;
|
|
42
42
|
error: string | null;
|
|
43
43
|
startedAt: string;
|
|
44
44
|
finishedAt: string | null;
|
|
45
45
|
}
|
|
46
|
+
/** One deployment in an app's history, as `client.apps.listDeployments()` returns it. */
|
|
47
|
+
export interface AppDeploymentHistoryEntry extends AppDeployment {
|
|
48
|
+
/** Whether this deployment's image is the one the app runs now. */
|
|
49
|
+
current: boolean;
|
|
50
|
+
/** Whether the app can be rolled back to this deployment. */
|
|
51
|
+
rollbackable: boolean;
|
|
52
|
+
}
|
|
46
53
|
/** Options accepted by every method, for working across projects. */
|
|
47
54
|
export interface ProjectScopedParams {
|
|
48
55
|
/** Overrides the client-level default project for this call. */
|
|
@@ -90,6 +97,8 @@ export type AppLogsResponse = Envelope<{
|
|
|
90
97
|
}>;
|
|
91
98
|
export type DeployAppResponse = Envelope<AppDeployment>;
|
|
92
99
|
export type GetDeploymentResponse = Envelope<AppDeployment>;
|
|
100
|
+
export type ListDeploymentsResponse = Envelope<AppDeploymentHistoryEntry[]>;
|
|
101
|
+
export type RollbackAppResponse = Envelope<AppDeployment>;
|
|
93
102
|
/**
|
|
94
103
|
* The settings `client.apps.update()` can change. Every field is optional, but
|
|
95
104
|
* a call must change at least one. Environment variables are left out on
|
|
@@ -199,6 +208,17 @@ export declare class AppsService {
|
|
|
199
208
|
deploy(appId: string, params?: DeployAppParams): Promise<DeployAppResponse>;
|
|
200
209
|
/** Fetches one deployment's current phase. */
|
|
201
210
|
getDeployment(appId: string, deploymentId: string, params?: ProjectScopedParams): Promise<GetDeploymentResponse>;
|
|
211
|
+
/** Lists the app's most recent deployments, newest first. */
|
|
212
|
+
listDeployments(appId: string, params?: ProjectScopedParams): Promise<ListDeploymentsResponse>;
|
|
213
|
+
/**
|
|
214
|
+
* Rolls the app back to the image an earlier deployment ran, without
|
|
215
|
+
* building, and returns the new deployment without waiting.
|
|
216
|
+
*
|
|
217
|
+
* Only the image goes back: the app keeps its current environment variables
|
|
218
|
+
* and settings. Pick a deployment `listDeployments()` marks `rollbackable`,
|
|
219
|
+
* and pair with `waitForDeployment()` to learn whether the rollout succeeded.
|
|
220
|
+
*/
|
|
221
|
+
rollback(appId: string, deploymentId: string, params?: ProjectScopedParams): Promise<RollbackAppResponse>;
|
|
202
222
|
/**
|
|
203
223
|
* Polls a deployment until it finishes, and returns it in its final phase.
|
|
204
224
|
*
|
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.
|
|
12
|
-
export declare const USER_AGENT = "cosmoner-node/1.
|
|
11
|
+
export declare const VERSION = "1.15.0";
|
|
12
|
+
export declare const USER_AGENT = "cosmoner-node/1.15.0";
|