@cosmoner/sdk 1.8.0 → 1.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +37 -17
- package/dist/client.d.ts +3 -0
- package/dist/index.d.ts +11 -9
- package/dist/index.js +419 -9
- package/dist/index.mjs +418 -9
- package/dist/services/apps.d.ts +122 -0
- package/dist/services/buckets.d.ts +46 -0
- package/dist/services/catalog.d.ts +106 -0
- package/dist/services/databases.d.ts +36 -0
- package/dist/services/domains.d.ts +32 -0
- package/dist/services/email.d.ts +5 -0
- package/dist/services/hosting.d.ts +55 -0
- package/dist/services/iam.d.ts +5 -0
- package/dist/services/preview.d.ts +29 -0
- package/dist/services/redis.d.ts +34 -0
- package/dist/services/registries.d.ts +45 -0
- package/dist/services/servers.d.ts +37 -0
- package/dist/services/ssh-keys.d.ts +21 -1
- package/dist/version.d.ts +2 -2
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -128,6 +128,85 @@ 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
|
+
}
|
|
152
|
+
/** Prices an app of a size before ordering it. `monthly` is exact; `dueToday` is an estimate once the project has a subscription. */
|
|
153
|
+
async preview(params) {
|
|
154
|
+
if (!params?.size) throw new Error("size is required");
|
|
155
|
+
return this.transport.request("GET", `${this.basePath(params.projectId)}/preview`, {
|
|
156
|
+
query: { size: params.size }
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Saves what an app should be, without creating or billing anything. The
|
|
161
|
+
* draft expires after 24 hours; `create()` turns it into an app. The app
|
|
162
|
+
* gets a Cosmoner subdomain.
|
|
163
|
+
*/
|
|
164
|
+
async createDraft(params) {
|
|
165
|
+
if (!params?.name) throw new Error("name is required");
|
|
166
|
+
if (!params.size) throw new Error("size is required");
|
|
167
|
+
if (!params.region) throw new Error("region is required");
|
|
168
|
+
const { projectId, ...fields } = params;
|
|
169
|
+
return this.transport.request("POST", `${this.basePath(projectId)}/draft`, {
|
|
170
|
+
body: { ...fields, domainType: "cosmoner" }
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Creates and deploys the app a draft describes. It starts `DEPLOYING`.
|
|
175
|
+
*
|
|
176
|
+
* Charges the project's saved card immediately, with a prorated invoice. It
|
|
177
|
+
* is refused with 402 before anything is created when the project cannot be
|
|
178
|
+
* billed.
|
|
179
|
+
*/
|
|
180
|
+
async create(params) {
|
|
181
|
+
if (!params?.draftId) throw new Error("draftId is required");
|
|
182
|
+
if (!params.size) throw new Error("size is required");
|
|
183
|
+
return this.transport.request("POST", this.basePath(params.projectId), {
|
|
184
|
+
body: { draftId: params.draftId, size: params.size }
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
/** Lists the sizes an app can move to, and whether it can be resized at all. */
|
|
188
|
+
async sizes(appId, params = {}) {
|
|
189
|
+
if (!appId) throw new Error("appId is required");
|
|
190
|
+
return this.transport.request("GET", `${this.basePath(params.projectId)}/${appId}/sizes`);
|
|
191
|
+
}
|
|
192
|
+
/** Prices moving an app to another size. */
|
|
193
|
+
async resizePreview(appId, params) {
|
|
194
|
+
if (!appId) throw new Error("appId is required");
|
|
195
|
+
if (!params?.size) throw new Error("size is required");
|
|
196
|
+
return this.transport.request(
|
|
197
|
+
"GET",
|
|
198
|
+
`${this.basePath(params.projectId)}/${appId}/resize-preview`,
|
|
199
|
+
{ query: { size: params.size } }
|
|
200
|
+
);
|
|
201
|
+
}
|
|
202
|
+
/** Moves an app to another size. Charges the difference to the saved card immediately. */
|
|
203
|
+
async resize(appId, params) {
|
|
204
|
+
if (!appId) throw new Error("appId is required");
|
|
205
|
+
if (!params?.size) throw new Error("size is required");
|
|
206
|
+
return this.transport.request("PATCH", `${this.basePath(params.projectId)}/${appId}/size`, {
|
|
207
|
+
body: { size: params.size }
|
|
208
|
+
});
|
|
209
|
+
}
|
|
131
210
|
};
|
|
132
211
|
|
|
133
212
|
// src/services/buckets.ts
|
|
@@ -138,10 +217,91 @@ var BucketsService = class {
|
|
|
138
217
|
}
|
|
139
218
|
/** Lists every bucket in the project. */
|
|
140
219
|
async list(params = {}) {
|
|
141
|
-
return this.transport.request(
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
220
|
+
return this.transport.request("GET", this.basePath(params.projectId));
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* Permanently deletes a bucket with every object in it and the access
|
|
224
|
+
* credentials made for it, and stops its billing.
|
|
225
|
+
*/
|
|
226
|
+
async delete(bucketId, params = {}) {
|
|
227
|
+
if (!bucketId) throw new Error("bucketId is required");
|
|
228
|
+
return this.transport.request("DELETE", `${this.basePath(params.projectId)}/${bucketId}`);
|
|
229
|
+
}
|
|
230
|
+
/** Builds the collection route for the resolved project. */
|
|
231
|
+
basePath(projectId) {
|
|
232
|
+
return `/v1/projects/${resolveProjectId(this.config, projectId)}/storage/object-storage`;
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* Prices a bucket's tier before ordering it. CDN traffic is metered and not
|
|
236
|
+
* included. `monthly` is exact; `dueToday` is an estimate once the project
|
|
237
|
+
* has a subscription.
|
|
238
|
+
*/
|
|
239
|
+
async preview(params = {}) {
|
|
240
|
+
return this.transport.request("GET", `${this.basePath(params.projectId)}/preview`, {
|
|
241
|
+
query: { provider: "AWS_S3", tier: params.tier ?? "STARTER" }
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* Orders a bucket. It is ready when this returns; names are unique, so list
|
|
246
|
+
* and match the name to read it.
|
|
247
|
+
*
|
|
248
|
+
* Charges the project's saved card immediately, with a prorated invoice. It
|
|
249
|
+
* is refused with 402 before anything is created when the project cannot be
|
|
250
|
+
* billed.
|
|
251
|
+
*/
|
|
252
|
+
async create(params) {
|
|
253
|
+
if (!params?.name) throw new Error("name is required");
|
|
254
|
+
if (!params.region) throw new Error("region is required");
|
|
255
|
+
return this.transport.request("POST", this.basePath(params.projectId), {
|
|
256
|
+
body: {
|
|
257
|
+
name: params.name,
|
|
258
|
+
provider: "AWS_S3",
|
|
259
|
+
region: params.region,
|
|
260
|
+
tier: params.tier,
|
|
261
|
+
publicAccess: params.publicAccess,
|
|
262
|
+
versioning: params.versioning,
|
|
263
|
+
cdnEnabled: params.cdnEnabled
|
|
264
|
+
}
|
|
265
|
+
});
|
|
266
|
+
}
|
|
267
|
+
};
|
|
268
|
+
|
|
269
|
+
// src/services/catalog.ts
|
|
270
|
+
var CatalogService = class {
|
|
271
|
+
constructor(transport) {
|
|
272
|
+
this.transport = transport;
|
|
273
|
+
}
|
|
274
|
+
/** Lists server sizes and their prices. */
|
|
275
|
+
async serverSizes() {
|
|
276
|
+
return this.transport.request("GET", "/v1/catalog/servers/sizes");
|
|
277
|
+
}
|
|
278
|
+
/** Lists the regions servers can be created in. */
|
|
279
|
+
async serverRegions() {
|
|
280
|
+
return this.transport.request("GET", "/v1/catalog/servers/regions");
|
|
281
|
+
}
|
|
282
|
+
/** Lists the one-click images a server can be created from. */
|
|
283
|
+
async serverImages() {
|
|
284
|
+
return this.transport.request("GET", "/v1/catalog/servers/1-clicks");
|
|
285
|
+
}
|
|
286
|
+
/** Lists Redis plans and their prices. */
|
|
287
|
+
async redisPlans() {
|
|
288
|
+
return this.transport.request("GET", "/v1/catalog/redis/plans");
|
|
289
|
+
}
|
|
290
|
+
/** Lists the regions Redis can be created in. */
|
|
291
|
+
async redisRegions() {
|
|
292
|
+
return this.transport.request("GET", "/v1/catalog/redis/regions");
|
|
293
|
+
}
|
|
294
|
+
/** Lists dedicated database sizes, engines with their versions, and regions. */
|
|
295
|
+
async databases() {
|
|
296
|
+
return this.transport.request("GET", "/v1/catalog/databases");
|
|
297
|
+
}
|
|
298
|
+
/** Lists app sizes and their prices. */
|
|
299
|
+
async appSizes() {
|
|
300
|
+
return this.transport.request("GET", "/v1/catalog/apps/sizes");
|
|
301
|
+
}
|
|
302
|
+
/** Lists the regions apps can be created in. */
|
|
303
|
+
async appRegions() {
|
|
304
|
+
return this.transport.request("GET", "/v1/catalog/apps/regions");
|
|
145
305
|
}
|
|
146
306
|
};
|
|
147
307
|
|
|
@@ -183,6 +343,58 @@ var DatabasesService = class {
|
|
|
183
343
|
if (!tenantId) throw new Error("tenantId is required");
|
|
184
344
|
return this.transport.request("GET", `${this.basePath(params.projectId)}/shared/${tenantId}`);
|
|
185
345
|
}
|
|
346
|
+
/** Permanently deletes a dedicated database cluster and its data, and stops its billing. */
|
|
347
|
+
async deleteDedicated(databaseId, params = {}) {
|
|
348
|
+
if (!databaseId) throw new Error("databaseId is required");
|
|
349
|
+
return this.transport.request(
|
|
350
|
+
"DELETE",
|
|
351
|
+
`${this.basePath(params.projectId)}/dedicated/${databaseId}`
|
|
352
|
+
);
|
|
353
|
+
}
|
|
354
|
+
/** Permanently deletes a shared database and its data, and stops its billing. */
|
|
355
|
+
async deleteShared(tenantId, params = {}) {
|
|
356
|
+
if (!tenantId) throw new Error("tenantId is required");
|
|
357
|
+
return this.transport.request(
|
|
358
|
+
"DELETE",
|
|
359
|
+
`${this.basePath(params.projectId)}/shared/${tenantId}`
|
|
360
|
+
);
|
|
361
|
+
}
|
|
362
|
+
/** Prices a dedicated database before ordering it. `monthly` is exact; `dueToday` is an estimate once the project has a subscription. */
|
|
363
|
+
async previewDedicated(params) {
|
|
364
|
+
if (!params?.size) throw new Error("size is required");
|
|
365
|
+
return this.transport.request(
|
|
366
|
+
"GET",
|
|
367
|
+
`${this.basePath(params.projectId)}/dedicated/preview`,
|
|
368
|
+
{ query: { slug: params.size } }
|
|
369
|
+
);
|
|
370
|
+
}
|
|
371
|
+
/**
|
|
372
|
+
* Orders a dedicated database. It starts `CREATING`; the response carries
|
|
373
|
+
* no id, so list and match the name to follow it.
|
|
374
|
+
*
|
|
375
|
+
* Charges the project's saved card immediately, with a prorated invoice. It
|
|
376
|
+
* is refused with 402 before anything is created when the project cannot be
|
|
377
|
+
* billed.
|
|
378
|
+
*/
|
|
379
|
+
async createDedicated(params) {
|
|
380
|
+
if (!params?.name) throw new Error("name is required");
|
|
381
|
+
if (!params.size) throw new Error("size is required");
|
|
382
|
+
if (!params.version) throw new Error("version is required");
|
|
383
|
+
if (!params.region) throw new Error("region is required");
|
|
384
|
+
return this.transport.request(
|
|
385
|
+
"POST",
|
|
386
|
+
`${this.basePath(params.projectId)}/dedicated`,
|
|
387
|
+
{
|
|
388
|
+
body: {
|
|
389
|
+
name: params.name,
|
|
390
|
+
engine: params.engine ?? "POSTGRESQL",
|
|
391
|
+
version: params.version,
|
|
392
|
+
slug: params.size,
|
|
393
|
+
region: params.region
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
);
|
|
397
|
+
}
|
|
186
398
|
};
|
|
187
399
|
|
|
188
400
|
// src/services/domains.ts
|
|
@@ -207,6 +419,36 @@ var DomainsService = class {
|
|
|
207
419
|
`${this.basePath(params.projectId)}/${encodeURIComponent(domain)}`
|
|
208
420
|
);
|
|
209
421
|
}
|
|
422
|
+
/**
|
|
423
|
+
* Adds a domain you already own, e.g. `example.com`. Free. Publish the
|
|
424
|
+
* returned `verificationRecord`, then call `verify()`. Buying a domain is not
|
|
425
|
+
* part of the SDK.
|
|
426
|
+
*/
|
|
427
|
+
async create(name, params = {}) {
|
|
428
|
+
if (!name) throw new Error("name is required");
|
|
429
|
+
return this.transport.request("POST", this.basePath(params.projectId), {
|
|
430
|
+
body: { name, type: "EXTERNAL" }
|
|
431
|
+
});
|
|
432
|
+
}
|
|
433
|
+
/** Checks a domain's verification record, by domain id or name. */
|
|
434
|
+
async verify(domain, params = {}) {
|
|
435
|
+
if (!domain) throw new Error("domain is required");
|
|
436
|
+
return this.transport.request(
|
|
437
|
+
"POST",
|
|
438
|
+
`${this.basePath(params.projectId)}/${encodeURIComponent(domain)}/verify`
|
|
439
|
+
);
|
|
440
|
+
}
|
|
441
|
+
/**
|
|
442
|
+
* Removes a domain and its DNS records, by id or name. Refused with 409
|
|
443
|
+
* while an app or an email domain uses it.
|
|
444
|
+
*/
|
|
445
|
+
async delete(domain, params = {}) {
|
|
446
|
+
if (!domain) throw new Error("domain is required");
|
|
447
|
+
return this.transport.request(
|
|
448
|
+
"DELETE",
|
|
449
|
+
`${this.basePath(params.projectId)}/${encodeURIComponent(domain)}`
|
|
450
|
+
);
|
|
451
|
+
}
|
|
210
452
|
};
|
|
211
453
|
|
|
212
454
|
// src/services/email.ts
|
|
@@ -260,6 +502,17 @@ var EmailService = class {
|
|
|
260
502
|
`/v1/projects/${resolveProjectId(this.config, params.projectId)}/email/${emailDomainId}`
|
|
261
503
|
);
|
|
262
504
|
}
|
|
505
|
+
/**
|
|
506
|
+
* Stops sending from a domain and removes it from email. The domain itself
|
|
507
|
+
* stays in the project. The API answers 204, so there is nothing to return.
|
|
508
|
+
*/
|
|
509
|
+
async deleteDomain(emailDomainId, params = {}) {
|
|
510
|
+
if (!emailDomainId) throw new Error("emailDomainId is required");
|
|
511
|
+
await this.transport.request(
|
|
512
|
+
"DELETE",
|
|
513
|
+
`/v1/projects/${resolveProjectId(this.config, params.projectId)}/email/${emailDomainId}`
|
|
514
|
+
);
|
|
515
|
+
}
|
|
263
516
|
};
|
|
264
517
|
|
|
265
518
|
// src/services/hosting.ts
|
|
@@ -292,6 +545,41 @@ var HostingService = class {
|
|
|
292
545
|
`${this.basePath(params.projectId)}/${siteId}/access`
|
|
293
546
|
);
|
|
294
547
|
}
|
|
548
|
+
/** Permanently deletes a hosting site with its files, databases and domains, and stops its billing. */
|
|
549
|
+
async delete(siteId, params = {}) {
|
|
550
|
+
if (!siteId) throw new Error("siteId is required");
|
|
551
|
+
return this.transport.request("DELETE", `${this.basePath(params.projectId)}/${siteId}`);
|
|
552
|
+
}
|
|
553
|
+
/** Lists hosting plans and their monthly prices. */
|
|
554
|
+
async prices(params = {}) {
|
|
555
|
+
return this.transport.request("GET", `${this.basePath(params.projectId)}/prices`);
|
|
556
|
+
}
|
|
557
|
+
/** Prices a site before ordering it. `monthly` is exact; `dueToday` is an estimate once the project has a subscription. */
|
|
558
|
+
async preview(params) {
|
|
559
|
+
if (!params?.tier) throw new Error("tier is required");
|
|
560
|
+
return this.transport.request("GET", `${this.basePath(params.projectId)}/preview`, {
|
|
561
|
+
query: { tier: params.tier, extraStorageGb: params.extraStorageGb ?? 0 }
|
|
562
|
+
});
|
|
563
|
+
}
|
|
564
|
+
/**
|
|
565
|
+
* Orders a hosting site, and its database when one is named.
|
|
566
|
+
*
|
|
567
|
+
* Charges the project's saved card immediately, with a prorated invoice. It
|
|
568
|
+
* is refused with 402 before anything is created when the project cannot be
|
|
569
|
+
* billed.
|
|
570
|
+
*/
|
|
571
|
+
async create(params) {
|
|
572
|
+
if (!params?.siteName) throw new Error("siteName is required");
|
|
573
|
+
return this.transport.request("POST", this.basePath(params.projectId), {
|
|
574
|
+
body: {
|
|
575
|
+
siteName: params.siteName,
|
|
576
|
+
tier: params.tier,
|
|
577
|
+
phpVersion: params.phpVersion,
|
|
578
|
+
database: params.database === void 0 ? void 0 : { name: params.database },
|
|
579
|
+
extraStorageGb: params.extraStorageGb
|
|
580
|
+
}
|
|
581
|
+
});
|
|
582
|
+
}
|
|
295
583
|
};
|
|
296
584
|
|
|
297
585
|
// src/services/iam.ts
|
|
@@ -316,6 +604,14 @@ var IamService = class {
|
|
|
316
604
|
`${this.basePath(params.projectId)}/${encodeURIComponent(iamUserName)}`
|
|
317
605
|
);
|
|
318
606
|
}
|
|
607
|
+
/**
|
|
608
|
+
* Deletes an IAM user and its access keys, by user name. Anything using the
|
|
609
|
+
* keys stops working. The API answers 204, so there is nothing to return.
|
|
610
|
+
*/
|
|
611
|
+
async delete(iamUserName, params = {}) {
|
|
612
|
+
if (!iamUserName) throw new Error("iamUserName is required");
|
|
613
|
+
await this.transport.request("DELETE", `${this.basePath(params.projectId)}/${encodeURIComponent(iamUserName)}`);
|
|
614
|
+
}
|
|
319
615
|
};
|
|
320
616
|
|
|
321
617
|
// src/services/members.ts
|
|
@@ -368,6 +664,34 @@ var RedisService = class {
|
|
|
368
664
|
if (!redisId) throw new Error("redisId is required");
|
|
369
665
|
return this.transport.request("GET", `${this.basePath(params.projectId)}/${redisId}`);
|
|
370
666
|
}
|
|
667
|
+
/** Permanently deletes a Redis database and its data, and stops its billing. */
|
|
668
|
+
async delete(redisId, params = {}) {
|
|
669
|
+
if (!redisId) throw new Error("redisId is required");
|
|
670
|
+
return this.transport.request("DELETE", `${this.basePath(params.projectId)}/${redisId}`);
|
|
671
|
+
}
|
|
672
|
+
/** Prices a Redis database before ordering it. `monthly` is exact; `dueToday` is an estimate once the project has a subscription. */
|
|
673
|
+
async preview(params) {
|
|
674
|
+
if (!params?.plan) throw new Error("plan is required");
|
|
675
|
+
return this.transport.request("GET", `${this.basePath(params.projectId)}/preview`, {
|
|
676
|
+
query: { planSlug: params.plan }
|
|
677
|
+
});
|
|
678
|
+
}
|
|
679
|
+
/**
|
|
680
|
+
* Orders a Redis database. It starts `CREATING`; the response carries no
|
|
681
|
+
* id, so list and match the name to follow it.
|
|
682
|
+
*
|
|
683
|
+
* Charges the project's saved card immediately, with a prorated invoice. It
|
|
684
|
+
* is refused with 402 before anything is created when the project cannot be
|
|
685
|
+
* billed.
|
|
686
|
+
*/
|
|
687
|
+
async create(params) {
|
|
688
|
+
if (!params?.name) throw new Error("name is required");
|
|
689
|
+
if (!params.plan) throw new Error("plan is required");
|
|
690
|
+
if (!params.region) throw new Error("region is required");
|
|
691
|
+
return this.transport.request("POST", this.basePath(params.projectId), {
|
|
692
|
+
body: { name: params.name, planSlug: params.plan, region: params.region, dataPersistence: params.persistence }
|
|
693
|
+
});
|
|
694
|
+
}
|
|
371
695
|
};
|
|
372
696
|
|
|
373
697
|
// src/services/registries.ts
|
|
@@ -389,6 +713,37 @@ var RegistriesService = class {
|
|
|
389
713
|
if (!registryId) throw new Error("registryId is required");
|
|
390
714
|
return this.transport.request("GET", `${this.basePath(params.projectId)}/${registryId}`);
|
|
391
715
|
}
|
|
716
|
+
/** Permanently deletes a registry with every repository and image in it, and stops its billing. */
|
|
717
|
+
async delete(registryId, params = {}) {
|
|
718
|
+
if (!registryId) throw new Error("registryId is required");
|
|
719
|
+
return this.transport.request("DELETE", `${this.basePath(params.projectId)}/${registryId}`);
|
|
720
|
+
}
|
|
721
|
+
/**
|
|
722
|
+
* Prices a registry's base fee before ordering it. Storage and egress are
|
|
723
|
+
* metered and not included. `monthly` is exact; `dueToday` is an estimate
|
|
724
|
+
* once the project has a subscription.
|
|
725
|
+
*/
|
|
726
|
+
async preview(params = {}) {
|
|
727
|
+
return this.transport.request("GET", `${this.basePath(params.projectId)}/preview`);
|
|
728
|
+
}
|
|
729
|
+
/** Lists the providers a registry can be created with, and their regions. */
|
|
730
|
+
async providers(params = {}) {
|
|
731
|
+
return this.transport.request("GET", `${this.basePath(params.projectId)}/providers`);
|
|
732
|
+
}
|
|
733
|
+
/**
|
|
734
|
+
* Orders a registry. It is ready when this returns.
|
|
735
|
+
*
|
|
736
|
+
* Charges the project's saved card immediately, with a prorated invoice. It
|
|
737
|
+
* is refused with 402 before anything is created when the project cannot be
|
|
738
|
+
* billed.
|
|
739
|
+
*/
|
|
740
|
+
async create(params) {
|
|
741
|
+
if (!params?.name) throw new Error("name is required");
|
|
742
|
+
if (!params.region) throw new Error("region is required");
|
|
743
|
+
return this.transport.request("POST", this.basePath(params.projectId), {
|
|
744
|
+
body: { name: params.name, region: params.region, provider: params.provider }
|
|
745
|
+
});
|
|
746
|
+
}
|
|
392
747
|
};
|
|
393
748
|
|
|
394
749
|
// src/services/project-config.ts
|
|
@@ -516,6 +871,41 @@ var ServersService = class {
|
|
|
516
871
|
if (!serverId) throw new Error("serverId is required");
|
|
517
872
|
return this.transport.request("GET", `${this.basePath(params.projectId)}/${serverId}`);
|
|
518
873
|
}
|
|
874
|
+
/** Permanently deletes a server and its disk, and stops its billing. */
|
|
875
|
+
async delete(serverId, params = {}) {
|
|
876
|
+
if (!serverId) throw new Error("serverId is required");
|
|
877
|
+
return this.transport.request("DELETE", `${this.basePath(params.projectId)}/${serverId}`);
|
|
878
|
+
}
|
|
879
|
+
/** Prices a server before ordering it. `monthly` is exact; `dueToday` is an estimate once the project has a subscription. */
|
|
880
|
+
async preview(params) {
|
|
881
|
+
if (!params?.size) throw new Error("size is required");
|
|
882
|
+
return this.transport.request("GET", `${this.basePath(params.projectId)}/preview`, {
|
|
883
|
+
query: { provider: params.provider ?? "digitalocean", slug: params.size }
|
|
884
|
+
});
|
|
885
|
+
}
|
|
886
|
+
/**
|
|
887
|
+
* Orders a server. It starts `PROVISIONING`; the response carries no id, so
|
|
888
|
+
* list servers and match the name to follow it.
|
|
889
|
+
*
|
|
890
|
+
* Charges the project's saved card immediately, with a prorated invoice. It
|
|
891
|
+
* is refused with 402 before anything is created when the project cannot be
|
|
892
|
+
* billed.
|
|
893
|
+
*/
|
|
894
|
+
async create(params) {
|
|
895
|
+
if (!params?.name) throw new Error("name is required");
|
|
896
|
+
if (!params.size) throw new Error("size is required");
|
|
897
|
+
if (!params.region) throw new Error("region is required");
|
|
898
|
+
return this.transport.request("POST", this.basePath(params.projectId), {
|
|
899
|
+
body: {
|
|
900
|
+
name: params.name,
|
|
901
|
+
slug: params.size,
|
|
902
|
+
provider: params.provider ?? "digitalocean",
|
|
903
|
+
region: params.region,
|
|
904
|
+
template: params.image,
|
|
905
|
+
sshKeyIds: params.sshKeyIds
|
|
906
|
+
}
|
|
907
|
+
});
|
|
908
|
+
}
|
|
519
909
|
};
|
|
520
910
|
|
|
521
911
|
// src/services/ssh-keys.ts
|
|
@@ -526,10 +916,27 @@ var SshKeysService = class {
|
|
|
526
916
|
}
|
|
527
917
|
/** Lists every SSH key in the project. */
|
|
528
918
|
async list(params = {}) {
|
|
529
|
-
return this.transport.request(
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
919
|
+
return this.transport.request("GET", this.basePath(params.projectId));
|
|
920
|
+
}
|
|
921
|
+
/** Adds a public key to the project, for installing on servers created later. */
|
|
922
|
+
async create(params) {
|
|
923
|
+
if (!params?.name) throw new Error("name is required");
|
|
924
|
+
if (!params.publicKey) throw new Error("publicKey is required");
|
|
925
|
+
return this.transport.request("POST", this.basePath(params.projectId), {
|
|
926
|
+
body: { name: params.name, publicKey: params.publicKey }
|
|
927
|
+
});
|
|
928
|
+
}
|
|
929
|
+
/**
|
|
930
|
+
* Removes a key from the project. Servers it was already installed on keep
|
|
931
|
+
* accepting it; `stillAuthorisedOn` says how many.
|
|
932
|
+
*/
|
|
933
|
+
async delete(sshKeyId, params = {}) {
|
|
934
|
+
if (!sshKeyId) throw new Error("sshKeyId is required");
|
|
935
|
+
return this.transport.request("DELETE", `${this.basePath(params.projectId)}/${sshKeyId}`);
|
|
936
|
+
}
|
|
937
|
+
/** Builds the collection route for the resolved project. */
|
|
938
|
+
basePath(projectId) {
|
|
939
|
+
return `/v1/projects/${resolveProjectId(this.config, projectId)}/ssh-keys`;
|
|
533
940
|
}
|
|
534
941
|
};
|
|
535
942
|
|
|
@@ -979,7 +1386,7 @@ function sleep(ms) {
|
|
|
979
1386
|
}
|
|
980
1387
|
|
|
981
1388
|
// src/version.ts
|
|
982
|
-
var VERSION = "1.
|
|
1389
|
+
var VERSION = "1.10.0";
|
|
983
1390
|
var USER_AGENT = `cosmoner-node/${VERSION}`;
|
|
984
1391
|
|
|
985
1392
|
// src/transport.ts
|
|
@@ -1111,6 +1518,7 @@ var Cosmoner = class {
|
|
|
1111
1518
|
this.iam = new IamService(this.transport, this.config);
|
|
1112
1519
|
this.members = new MembersService(this.transport, this.config);
|
|
1113
1520
|
this.projects = new ProjectsService(this.transport);
|
|
1521
|
+
this.catalog = new CatalogService(this.transport);
|
|
1114
1522
|
this.redis = new RedisService(this.transport, this.config);
|
|
1115
1523
|
this.registries = new RegistriesService(this.transport, this.config);
|
|
1116
1524
|
this.secrets = new SecretsService(this.transport, this.config);
|
|
@@ -1459,6 +1867,7 @@ export {
|
|
|
1459
1867
|
AppsService,
|
|
1460
1868
|
AuthenticationError,
|
|
1461
1869
|
BucketsService,
|
|
1870
|
+
CatalogService,
|
|
1462
1871
|
ConflictError,
|
|
1463
1872
|
Cosmoner,
|
|
1464
1873
|
CosmonerConnectionError,
|
package/dist/services/apps.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/** Apps service namespace — finding apps and rolling image apps onto a new image. */
|
|
2
2
|
import { type ResolvedConfig } from "../config";
|
|
3
|
+
import type { CheckoutPreview, PlanChangePreview } from "./preview";
|
|
3
4
|
import type { Transport } from "../transport";
|
|
4
5
|
/** Lifecycle state of an app as a whole. */
|
|
5
6
|
export type AppStatus = "DEPLOYING" | "RUNNING" | "STOPPED" | "ERROR" | "TERMINATED";
|
|
@@ -89,6 +90,87 @@ export type AppLogsResponse = Envelope<{
|
|
|
89
90
|
}>;
|
|
90
91
|
export type DeployAppResponse = Envelope<AppDeployment>;
|
|
91
92
|
export type GetDeploymentResponse = Envelope<AppDeployment>;
|
|
93
|
+
/**
|
|
94
|
+
* The settings `client.apps.update()` can change. Every field is optional, but
|
|
95
|
+
* a call must change at least one. Environment variables are left out on
|
|
96
|
+
* purpose: they belong in the deployment file, and the API masks secret ones,
|
|
97
|
+
* so a read-modify-write of the list would be easy to get wrong.
|
|
98
|
+
*/
|
|
99
|
+
export interface UpdateAppParams extends ProjectScopedParams {
|
|
100
|
+
name?: string;
|
|
101
|
+
buildCommand?: string | null;
|
|
102
|
+
runCommand?: string | null;
|
|
103
|
+
outputDir?: string | null;
|
|
104
|
+
publicPort?: number | null;
|
|
105
|
+
internalPort?: number | null;
|
|
106
|
+
autoDeploy?: boolean;
|
|
107
|
+
imageDeployPolicy?: ImageDeployPolicy;
|
|
108
|
+
/** Refused for an app whose runtime cannot scale horizontally. */
|
|
109
|
+
instances?: number;
|
|
110
|
+
}
|
|
111
|
+
export type UpdateAppResponse = Envelope<App>;
|
|
112
|
+
export type DeleteAppResponse = Envelope<Record<string, never>>;
|
|
113
|
+
/** Arguments accepted by `client.apps.createDraft()`. Pass a repository or an image. */
|
|
114
|
+
export interface CreateAppDraftParams extends ProjectScopedParams {
|
|
115
|
+
name: string;
|
|
116
|
+
/** A size slug from `client.catalog.appSizes()`. */
|
|
117
|
+
size: string;
|
|
118
|
+
/** A region slug from `client.catalog.appRegions()`. */
|
|
119
|
+
region: string;
|
|
120
|
+
appType?: "service" | "static";
|
|
121
|
+
gitProvider?: "github" | "gitlab" | "bitbucket";
|
|
122
|
+
/** `owner/repo`. */
|
|
123
|
+
gitRepo?: string;
|
|
124
|
+
gitBranch?: string;
|
|
125
|
+
sourceDir?: string;
|
|
126
|
+
buildStrategy?: "nixpacks" | "docker";
|
|
127
|
+
buildCommand?: string;
|
|
128
|
+
runCommand?: string;
|
|
129
|
+
outputDir?: string;
|
|
130
|
+
publicPort?: number;
|
|
131
|
+
internalPort?: number;
|
|
132
|
+
autoDeploy?: boolean;
|
|
133
|
+
containerRegistry?: "dockerhub" | "ghcr" | "cosmoner";
|
|
134
|
+
containerImage?: string;
|
|
135
|
+
/** The image's listening port, as a string. */
|
|
136
|
+
containerPublicPort?: string;
|
|
137
|
+
imageDeployPolicy?: ImageDeployPolicy;
|
|
138
|
+
instances?: number;
|
|
139
|
+
}
|
|
140
|
+
/** Arguments accepted by `client.apps.create()`. */
|
|
141
|
+
export interface CreateAppParams extends ProjectScopedParams {
|
|
142
|
+
draftId: string;
|
|
143
|
+
/** The size to bill; pass the draft's. */
|
|
144
|
+
size: string;
|
|
145
|
+
}
|
|
146
|
+
/** An app's sizes, and whether it can be resized at all. */
|
|
147
|
+
export interface AppSizes {
|
|
148
|
+
currentSize: string;
|
|
149
|
+
resizable: boolean;
|
|
150
|
+
sizes: Array<{
|
|
151
|
+
slug: string;
|
|
152
|
+
name: string;
|
|
153
|
+
tierSlug: string;
|
|
154
|
+
cpuType: string;
|
|
155
|
+
cpus: number;
|
|
156
|
+
memoryMb: number;
|
|
157
|
+
bandwidthGib: number;
|
|
158
|
+
priceMonthly: number;
|
|
159
|
+
}>;
|
|
160
|
+
}
|
|
161
|
+
export type PreviewAppResponse = Envelope<CheckoutPreview>;
|
|
162
|
+
export type CreateAppDraftResponse = Envelope<{
|
|
163
|
+
draftId: string;
|
|
164
|
+
}>;
|
|
165
|
+
export type CreateAppResponse = Envelope<{
|
|
166
|
+
deployed: true;
|
|
167
|
+
appId: string;
|
|
168
|
+
}>;
|
|
169
|
+
export type GetAppSizesResponse = Envelope<AppSizes>;
|
|
170
|
+
export type PreviewAppResizeResponse = Envelope<PlanChangePreview>;
|
|
171
|
+
export type ResizeAppResponse = Envelope<{
|
|
172
|
+
instanceSize: string;
|
|
173
|
+
}>;
|
|
92
174
|
/** App lookup and image deploy operations for a project. */
|
|
93
175
|
export declare class AppsService {
|
|
94
176
|
private readonly transport;
|
|
@@ -125,5 +207,45 @@ export declare class AppsService {
|
|
|
125
207
|
* in which case the deployment keeps going server-side.
|
|
126
208
|
*/
|
|
127
209
|
waitForDeployment(appId: string, deploymentId: string, params?: WaitForDeploymentParams): Promise<AppDeployment>;
|
|
210
|
+
/**
|
|
211
|
+
* Changes an app's settings and applies them to the running app.
|
|
212
|
+
*
|
|
213
|
+
* Free: resizing, which is billed, is a separate call. The API answers 502
|
|
214
|
+
* when the settings were saved but the runtime refused them.
|
|
215
|
+
*/
|
|
216
|
+
update(appId: string, params: UpdateAppParams): Promise<UpdateAppResponse>;
|
|
217
|
+
/**
|
|
218
|
+
* Permanently deletes an app: its runtime, routing, custom hostname and
|
|
219
|
+
* billing, then the app itself. Its deployments go with it.
|
|
220
|
+
*/
|
|
221
|
+
delete(appId: string, params?: ProjectScopedParams): Promise<DeleteAppResponse>;
|
|
222
|
+
/** Prices an app of a size before ordering it. `monthly` is exact; `dueToday` is an estimate once the project has a subscription. */
|
|
223
|
+
preview(params: {
|
|
224
|
+
size: string;
|
|
225
|
+
} & ProjectScopedParams): Promise<PreviewAppResponse>;
|
|
226
|
+
/**
|
|
227
|
+
* Saves what an app should be, without creating or billing anything. The
|
|
228
|
+
* draft expires after 24 hours; `create()` turns it into an app. The app
|
|
229
|
+
* gets a Cosmoner subdomain.
|
|
230
|
+
*/
|
|
231
|
+
createDraft(params: CreateAppDraftParams): Promise<CreateAppDraftResponse>;
|
|
232
|
+
/**
|
|
233
|
+
* Creates and deploys the app a draft describes. It starts `DEPLOYING`.
|
|
234
|
+
*
|
|
235
|
+
* Charges the project's saved card immediately, with a prorated invoice. It
|
|
236
|
+
* is refused with 402 before anything is created when the project cannot be
|
|
237
|
+
* billed.
|
|
238
|
+
*/
|
|
239
|
+
create(params: CreateAppParams): Promise<CreateAppResponse>;
|
|
240
|
+
/** Lists the sizes an app can move to, and whether it can be resized at all. */
|
|
241
|
+
sizes(appId: string, params?: ProjectScopedParams): Promise<GetAppSizesResponse>;
|
|
242
|
+
/** Prices moving an app to another size. */
|
|
243
|
+
resizePreview(appId: string, params: {
|
|
244
|
+
size: string;
|
|
245
|
+
} & ProjectScopedParams): Promise<PreviewAppResizeResponse>;
|
|
246
|
+
/** Moves an app to another size. Charges the difference to the saved card immediately. */
|
|
247
|
+
resize(appId: string, params: {
|
|
248
|
+
size: string;
|
|
249
|
+
} & ProjectScopedParams): Promise<ResizeAppResponse>;
|
|
128
250
|
}
|
|
129
251
|
export {};
|