@cosmoner/sdk 1.9.0 → 1.11.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 +13 -0
- package/dist/client.d.ts +3 -0
- package/dist/index.d.ts +12 -10
- package/dist/index.js +328 -1
- package/dist/index.mjs +327 -1
- package/dist/services/apps.d.ts +90 -0
- package/dist/services/buckets.d.ts +38 -0
- package/dist/services/catalog.d.ts +106 -0
- package/dist/services/databases.d.ts +31 -0
- package/dist/services/email.d.ts +31 -0
- package/dist/services/hosting.d.ts +52 -0
- package/dist/services/iam.d.ts +53 -0
- package/dist/services/preview.d.ts +29 -0
- package/dist/services/redis.d.ts +31 -0
- package/dist/services/registries.d.ts +42 -0
- package/dist/services/servers.d.ts +34 -0
- package/dist/services/ssh-keys.d.ts +13 -0
- package/dist/version.d.ts +2 -2
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -149,6 +149,64 @@ var AppsService = class {
|
|
|
149
149
|
if (!appId) throw new Error("appId is required");
|
|
150
150
|
return this.transport.request("DELETE", `${this.basePath(params.projectId)}/${appId}`);
|
|
151
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
|
+
}
|
|
152
210
|
};
|
|
153
211
|
|
|
154
212
|
// src/services/buckets.ts
|
|
@@ -173,6 +231,78 @@ var BucketsService = class {
|
|
|
173
231
|
basePath(projectId) {
|
|
174
232
|
return `/v1/projects/${resolveProjectId(this.config, projectId)}/storage/object-storage`;
|
|
175
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");
|
|
305
|
+
}
|
|
176
306
|
};
|
|
177
307
|
|
|
178
308
|
// src/services/databases.ts
|
|
@@ -229,6 +359,42 @@ var DatabasesService = class {
|
|
|
229
359
|
`${this.basePath(params.projectId)}/shared/${tenantId}`
|
|
230
360
|
);
|
|
231
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
|
+
}
|
|
232
398
|
};
|
|
233
399
|
|
|
234
400
|
// src/services/domains.ts
|
|
@@ -347,6 +513,33 @@ var EmailService = class {
|
|
|
347
513
|
`/v1/projects/${resolveProjectId(this.config, params.projectId)}/email/${emailDomainId}`
|
|
348
514
|
);
|
|
349
515
|
}
|
|
516
|
+
/**
|
|
517
|
+
* Creates an SMTP credential for a sending domain. The response holds
|
|
518
|
+
* `smtpPassword` this once: the API keeps only a hash.
|
|
519
|
+
*/
|
|
520
|
+
// eslint-disable-next-line require-await -- `async` makes the validation below reject rather than throw synchronously.
|
|
521
|
+
async createCredential(emailDomainId, params) {
|
|
522
|
+
if (!emailDomainId) throw new Error("emailDomainId is required");
|
|
523
|
+
if (!params?.label) throw new Error("label is required");
|
|
524
|
+
if (!params.fromAddress) throw new Error("fromAddress is required");
|
|
525
|
+
return this.transport.request(
|
|
526
|
+
"POST",
|
|
527
|
+
`/v1/projects/${resolveProjectId(this.config, params.projectId)}/email/${emailDomainId}/credentials`,
|
|
528
|
+
{ body: { label: params.label, fromAddress: params.fromAddress } }
|
|
529
|
+
);
|
|
530
|
+
}
|
|
531
|
+
/**
|
|
532
|
+
* Deletes an SMTP credential; anything sending with it stops working. The
|
|
533
|
+
* API answers 204, so there is nothing to return.
|
|
534
|
+
*/
|
|
535
|
+
async deleteCredential(emailDomainId, credentialId, params = {}) {
|
|
536
|
+
if (!emailDomainId) throw new Error("emailDomainId is required");
|
|
537
|
+
if (!credentialId) throw new Error("credentialId is required");
|
|
538
|
+
await this.transport.request(
|
|
539
|
+
"DELETE",
|
|
540
|
+
`/v1/projects/${resolveProjectId(this.config, params.projectId)}/email/${emailDomainId}/credentials/${credentialId}`
|
|
541
|
+
);
|
|
542
|
+
}
|
|
350
543
|
};
|
|
351
544
|
|
|
352
545
|
// src/services/hosting.ts
|
|
@@ -384,6 +577,36 @@ var HostingService = class {
|
|
|
384
577
|
if (!siteId) throw new Error("siteId is required");
|
|
385
578
|
return this.transport.request("DELETE", `${this.basePath(params.projectId)}/${siteId}`);
|
|
386
579
|
}
|
|
580
|
+
/** Lists hosting plans and their monthly prices. */
|
|
581
|
+
async prices(params = {}) {
|
|
582
|
+
return this.transport.request("GET", `${this.basePath(params.projectId)}/prices`);
|
|
583
|
+
}
|
|
584
|
+
/** Prices a site before ordering it. `monthly` is exact; `dueToday` is an estimate once the project has a subscription. */
|
|
585
|
+
async preview(params) {
|
|
586
|
+
if (!params?.tier) throw new Error("tier is required");
|
|
587
|
+
return this.transport.request("GET", `${this.basePath(params.projectId)}/preview`, {
|
|
588
|
+
query: { tier: params.tier, extraStorageGb: params.extraStorageGb ?? 0 }
|
|
589
|
+
});
|
|
590
|
+
}
|
|
591
|
+
/**
|
|
592
|
+
* Orders a hosting site, and its database when one is named.
|
|
593
|
+
*
|
|
594
|
+
* Charges the project's saved card immediately, with a prorated invoice. It
|
|
595
|
+
* is refused with 402 before anything is created when the project cannot be
|
|
596
|
+
* billed.
|
|
597
|
+
*/
|
|
598
|
+
async create(params) {
|
|
599
|
+
if (!params?.siteName) throw new Error("siteName is required");
|
|
600
|
+
return this.transport.request("POST", this.basePath(params.projectId), {
|
|
601
|
+
body: {
|
|
602
|
+
siteName: params.siteName,
|
|
603
|
+
tier: params.tier,
|
|
604
|
+
phpVersion: params.phpVersion,
|
|
605
|
+
database: params.database === void 0 ? void 0 : { name: params.database },
|
|
606
|
+
extraStorageGb: params.extraStorageGb
|
|
607
|
+
}
|
|
608
|
+
});
|
|
609
|
+
}
|
|
387
610
|
};
|
|
388
611
|
|
|
389
612
|
// src/services/iam.ts
|
|
@@ -416,6 +639,18 @@ var IamService = class {
|
|
|
416
639
|
if (!iamUserName) throw new Error("iamUserName is required");
|
|
417
640
|
await this.transport.request("DELETE", `${this.basePath(params.projectId)}/${encodeURIComponent(iamUserName)}`);
|
|
418
641
|
}
|
|
642
|
+
/**
|
|
643
|
+
* Creates an access key for object storage, the container registry, or both.
|
|
644
|
+
* The response holds `secretAccessKey` this once: the API keeps no copy, and
|
|
645
|
+
* no later read returns it.
|
|
646
|
+
*/
|
|
647
|
+
async create(params) {
|
|
648
|
+
if (!params?.label) throw new Error("label is required");
|
|
649
|
+
if (!params.storage && !params.registry) throw new Error("storage or registry is required");
|
|
650
|
+
return this.transport.request("POST", this.basePath(params.projectId), {
|
|
651
|
+
body: { label: params.label, storage: params.storage, registry: params.registry }
|
|
652
|
+
});
|
|
653
|
+
}
|
|
419
654
|
};
|
|
420
655
|
|
|
421
656
|
// src/services/members.ts
|
|
@@ -473,6 +708,29 @@ var RedisService = class {
|
|
|
473
708
|
if (!redisId) throw new Error("redisId is required");
|
|
474
709
|
return this.transport.request("DELETE", `${this.basePath(params.projectId)}/${redisId}`);
|
|
475
710
|
}
|
|
711
|
+
/** Prices a Redis database before ordering it. `monthly` is exact; `dueToday` is an estimate once the project has a subscription. */
|
|
712
|
+
async preview(params) {
|
|
713
|
+
if (!params?.plan) throw new Error("plan is required");
|
|
714
|
+
return this.transport.request("GET", `${this.basePath(params.projectId)}/preview`, {
|
|
715
|
+
query: { planSlug: params.plan }
|
|
716
|
+
});
|
|
717
|
+
}
|
|
718
|
+
/**
|
|
719
|
+
* Orders a Redis database. It starts `CREATING`; the response carries no
|
|
720
|
+
* id, so list and match the name to follow it.
|
|
721
|
+
*
|
|
722
|
+
* Charges the project's saved card immediately, with a prorated invoice. It
|
|
723
|
+
* is refused with 402 before anything is created when the project cannot be
|
|
724
|
+
* billed.
|
|
725
|
+
*/
|
|
726
|
+
async create(params) {
|
|
727
|
+
if (!params?.name) throw new Error("name is required");
|
|
728
|
+
if (!params.plan) throw new Error("plan is required");
|
|
729
|
+
if (!params.region) throw new Error("region is required");
|
|
730
|
+
return this.transport.request("POST", this.basePath(params.projectId), {
|
|
731
|
+
body: { name: params.name, planSlug: params.plan, region: params.region, dataPersistence: params.persistence }
|
|
732
|
+
});
|
|
733
|
+
}
|
|
476
734
|
};
|
|
477
735
|
|
|
478
736
|
// src/services/registries.ts
|
|
@@ -499,6 +757,32 @@ var RegistriesService = class {
|
|
|
499
757
|
if (!registryId) throw new Error("registryId is required");
|
|
500
758
|
return this.transport.request("DELETE", `${this.basePath(params.projectId)}/${registryId}`);
|
|
501
759
|
}
|
|
760
|
+
/**
|
|
761
|
+
* Prices a registry's base fee before ordering it. Storage and egress are
|
|
762
|
+
* metered and not included. `monthly` is exact; `dueToday` is an estimate
|
|
763
|
+
* once the project has a subscription.
|
|
764
|
+
*/
|
|
765
|
+
async preview(params = {}) {
|
|
766
|
+
return this.transport.request("GET", `${this.basePath(params.projectId)}/preview`);
|
|
767
|
+
}
|
|
768
|
+
/** Lists the providers a registry can be created with, and their regions. */
|
|
769
|
+
async providers(params = {}) {
|
|
770
|
+
return this.transport.request("GET", `${this.basePath(params.projectId)}/providers`);
|
|
771
|
+
}
|
|
772
|
+
/**
|
|
773
|
+
* Orders a registry. It is ready when this returns.
|
|
774
|
+
*
|
|
775
|
+
* Charges the project's saved card immediately, with a prorated invoice. It
|
|
776
|
+
* is refused with 402 before anything is created when the project cannot be
|
|
777
|
+
* billed.
|
|
778
|
+
*/
|
|
779
|
+
async create(params) {
|
|
780
|
+
if (!params?.name) throw new Error("name is required");
|
|
781
|
+
if (!params.region) throw new Error("region is required");
|
|
782
|
+
return this.transport.request("POST", this.basePath(params.projectId), {
|
|
783
|
+
body: { name: params.name, region: params.region, provider: params.provider }
|
|
784
|
+
});
|
|
785
|
+
}
|
|
502
786
|
};
|
|
503
787
|
|
|
504
788
|
// src/services/project-config.ts
|
|
@@ -631,6 +915,36 @@ var ServersService = class {
|
|
|
631
915
|
if (!serverId) throw new Error("serverId is required");
|
|
632
916
|
return this.transport.request("DELETE", `${this.basePath(params.projectId)}/${serverId}`);
|
|
633
917
|
}
|
|
918
|
+
/** Prices a server before ordering it. `monthly` is exact; `dueToday` is an estimate once the project has a subscription. */
|
|
919
|
+
async preview(params) {
|
|
920
|
+
if (!params?.size) throw new Error("size is required");
|
|
921
|
+
return this.transport.request("GET", `${this.basePath(params.projectId)}/preview`, {
|
|
922
|
+
query: { provider: params.provider ?? "digitalocean", slug: params.size }
|
|
923
|
+
});
|
|
924
|
+
}
|
|
925
|
+
/**
|
|
926
|
+
* Orders a server. It starts `PROVISIONING`; the response carries no id, so
|
|
927
|
+
* list servers and match the name to follow it.
|
|
928
|
+
*
|
|
929
|
+
* Charges the project's saved card immediately, with a prorated invoice. It
|
|
930
|
+
* is refused with 402 before anything is created when the project cannot be
|
|
931
|
+
* billed.
|
|
932
|
+
*/
|
|
933
|
+
async create(params) {
|
|
934
|
+
if (!params?.name) throw new Error("name is required");
|
|
935
|
+
if (!params.size) throw new Error("size is required");
|
|
936
|
+
if (!params.region) throw new Error("region is required");
|
|
937
|
+
return this.transport.request("POST", this.basePath(params.projectId), {
|
|
938
|
+
body: {
|
|
939
|
+
name: params.name,
|
|
940
|
+
slug: params.size,
|
|
941
|
+
provider: params.provider ?? "digitalocean",
|
|
942
|
+
region: params.region,
|
|
943
|
+
template: params.image,
|
|
944
|
+
sshKeyIds: params.sshKeyIds
|
|
945
|
+
}
|
|
946
|
+
});
|
|
947
|
+
}
|
|
634
948
|
};
|
|
635
949
|
|
|
636
950
|
// src/services/ssh-keys.ts
|
|
@@ -663,6 +977,16 @@ var SshKeysService = class {
|
|
|
663
977
|
basePath(projectId) {
|
|
664
978
|
return `/v1/projects/${resolveProjectId(this.config, projectId)}/ssh-keys`;
|
|
665
979
|
}
|
|
980
|
+
/**
|
|
981
|
+
* Generates a key pair and adds its public half to the project. The response
|
|
982
|
+
* holds `privateKey` this once: the API never stores it.
|
|
983
|
+
*/
|
|
984
|
+
async generate(params) {
|
|
985
|
+
if (!params?.name) throw new Error("name is required");
|
|
986
|
+
return this.transport.request("POST", `${this.basePath(params.projectId)}/generate`, {
|
|
987
|
+
body: { name: params.name }
|
|
988
|
+
});
|
|
989
|
+
}
|
|
666
990
|
};
|
|
667
991
|
|
|
668
992
|
// src/services/variables.ts
|
|
@@ -1111,7 +1435,7 @@ function sleep(ms) {
|
|
|
1111
1435
|
}
|
|
1112
1436
|
|
|
1113
1437
|
// src/version.ts
|
|
1114
|
-
var VERSION = "1.
|
|
1438
|
+
var VERSION = "1.11.0";
|
|
1115
1439
|
var USER_AGENT = `cosmoner-node/${VERSION}`;
|
|
1116
1440
|
|
|
1117
1441
|
// src/transport.ts
|
|
@@ -1243,6 +1567,7 @@ var Cosmoner = class {
|
|
|
1243
1567
|
this.iam = new IamService(this.transport, this.config);
|
|
1244
1568
|
this.members = new MembersService(this.transport, this.config);
|
|
1245
1569
|
this.projects = new ProjectsService(this.transport);
|
|
1570
|
+
this.catalog = new CatalogService(this.transport);
|
|
1246
1571
|
this.redis = new RedisService(this.transport, this.config);
|
|
1247
1572
|
this.registries = new RegistriesService(this.transport, this.config);
|
|
1248
1573
|
this.secrets = new SecretsService(this.transport, this.config);
|
|
@@ -1591,6 +1916,7 @@ export {
|
|
|
1591
1916
|
AppsService,
|
|
1592
1917
|
AuthenticationError,
|
|
1593
1918
|
BucketsService,
|
|
1919
|
+
CatalogService,
|
|
1594
1920
|
ConflictError,
|
|
1595
1921
|
Cosmoner,
|
|
1596
1922
|
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";
|
|
@@ -109,6 +110,67 @@ export interface UpdateAppParams extends ProjectScopedParams {
|
|
|
109
110
|
}
|
|
110
111
|
export type UpdateAppResponse = Envelope<App>;
|
|
111
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
|
+
}>;
|
|
112
174
|
/** App lookup and image deploy operations for a project. */
|
|
113
175
|
export declare class AppsService {
|
|
114
176
|
private readonly transport;
|
|
@@ -157,5 +219,33 @@ export declare class AppsService {
|
|
|
157
219
|
* billing, then the app itself. Its deployments go with it.
|
|
158
220
|
*/
|
|
159
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>;
|
|
160
250
|
}
|
|
161
251
|
export {};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/** Buckets service namespace — a project's object storage buckets. */
|
|
2
2
|
import { type ResolvedConfig } from "../config";
|
|
3
|
+
import type { CheckoutPreview } from "./preview";
|
|
3
4
|
import type { Transport } from "../transport";
|
|
4
5
|
/** A bucket as the API lists it. Its access keys are never part of a listing. */
|
|
5
6
|
export interface Bucket {
|
|
@@ -27,6 +28,28 @@ interface Envelope<T> {
|
|
|
27
28
|
}
|
|
28
29
|
export type ListBucketsResponse = Envelope<Bucket[]>;
|
|
29
30
|
export type DeleteBucketResponse = Envelope<Record<string, never>>;
|
|
31
|
+
/** A bucket's plan. */
|
|
32
|
+
export type BucketTier = "STARTER" | "GROWTH" | "SCALE" | "ENTERPRISE";
|
|
33
|
+
/** Arguments accepted by `client.buckets.preview()`. */
|
|
34
|
+
export interface PreviewBucketParams extends ProjectScopedParams {
|
|
35
|
+
/** Defaults to `STARTER`. */
|
|
36
|
+
tier?: BucketTier;
|
|
37
|
+
}
|
|
38
|
+
/** Arguments accepted by `client.buckets.create()`. */
|
|
39
|
+
export interface CreateBucketParams extends PreviewBucketParams {
|
|
40
|
+
/** 3–33 lowercase letters, digits and hyphens; unique in the project. */
|
|
41
|
+
name: string;
|
|
42
|
+
/** An AWS region, e.g. `eu-north-1`. */
|
|
43
|
+
region: string;
|
|
44
|
+
publicAccess?: boolean;
|
|
45
|
+
versioning?: boolean;
|
|
46
|
+
/** Needs `publicAccess`. CDN traffic is metered on top of the tier. */
|
|
47
|
+
cdnEnabled?: boolean;
|
|
48
|
+
}
|
|
49
|
+
export type PreviewBucketResponse = Envelope<CheckoutPreview>;
|
|
50
|
+
export type CreateBucketResponse = Envelope<{
|
|
51
|
+
deployed: true;
|
|
52
|
+
}>;
|
|
30
53
|
/** Read operations on a project's buckets. The API has no single-bucket read. */
|
|
31
54
|
export declare class BucketsService {
|
|
32
55
|
private readonly transport;
|
|
@@ -41,5 +64,20 @@ export declare class BucketsService {
|
|
|
41
64
|
delete(bucketId: string, params?: ProjectScopedParams): Promise<DeleteBucketResponse>;
|
|
42
65
|
/** Builds the collection route for the resolved project. */
|
|
43
66
|
private basePath;
|
|
67
|
+
/**
|
|
68
|
+
* Prices a bucket's tier before ordering it. CDN traffic is metered and not
|
|
69
|
+
* included. `monthly` is exact; `dueToday` is an estimate once the project
|
|
70
|
+
* has a subscription.
|
|
71
|
+
*/
|
|
72
|
+
preview(params?: PreviewBucketParams): Promise<PreviewBucketResponse>;
|
|
73
|
+
/**
|
|
74
|
+
* Orders a bucket. It is ready when this returns; names are unique, so list
|
|
75
|
+
* and match the name to read it.
|
|
76
|
+
*
|
|
77
|
+
* Charges the project's saved card immediately, with a prorated invoice. It
|
|
78
|
+
* is refused with 402 before anything is created when the project cannot be
|
|
79
|
+
* billed.
|
|
80
|
+
*/
|
|
81
|
+
create(params: CreateBucketParams): Promise<CreateBucketResponse>;
|
|
44
82
|
}
|
|
45
83
|
export {};
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Catalog service namespace — the sizes, plans and regions paid resources are
|
|
3
|
+
* ordered with. Account-level: it never uses the client's default project.
|
|
4
|
+
*/
|
|
5
|
+
import type { Transport } from "../transport";
|
|
6
|
+
/** A server size. */
|
|
7
|
+
export interface ServerSize {
|
|
8
|
+
slug: string;
|
|
9
|
+
description: string;
|
|
10
|
+
vcpus: number;
|
|
11
|
+
memoryMb: number;
|
|
12
|
+
diskGb: number;
|
|
13
|
+
transferTb: number;
|
|
14
|
+
/** Whole dollars. */
|
|
15
|
+
priceMonthly: number;
|
|
16
|
+
priceHourly: number;
|
|
17
|
+
}
|
|
18
|
+
/** A region a resource can be created in. */
|
|
19
|
+
export interface CatalogRegion {
|
|
20
|
+
slug: string;
|
|
21
|
+
name: string;
|
|
22
|
+
features?: string[];
|
|
23
|
+
}
|
|
24
|
+
/** A Redis plan. */
|
|
25
|
+
export interface RedisPlan {
|
|
26
|
+
slug: string;
|
|
27
|
+
name: string;
|
|
28
|
+
provider: string;
|
|
29
|
+
engine: string;
|
|
30
|
+
planType: string;
|
|
31
|
+
memoryMb: number;
|
|
32
|
+
throughputOps: number | null;
|
|
33
|
+
cpuMilli: number | null;
|
|
34
|
+
supportsReplication: boolean;
|
|
35
|
+
supportsPersistence: boolean;
|
|
36
|
+
/** Dollars. */
|
|
37
|
+
priceMonthly: number;
|
|
38
|
+
}
|
|
39
|
+
/** A dedicated database size. */
|
|
40
|
+
export interface DatabaseSize {
|
|
41
|
+
slug: string;
|
|
42
|
+
description: string;
|
|
43
|
+
nodeClass: string;
|
|
44
|
+
vcpus: number;
|
|
45
|
+
memoryMb: number;
|
|
46
|
+
diskGb: number;
|
|
47
|
+
/** Dollars. */
|
|
48
|
+
priceMonthly: number;
|
|
49
|
+
numNodes: number;
|
|
50
|
+
}
|
|
51
|
+
/** What dedicated databases can be created with. */
|
|
52
|
+
export interface DatabaseCatalog {
|
|
53
|
+
provider: string;
|
|
54
|
+
sizes: DatabaseSize[];
|
|
55
|
+
engines: Array<{
|
|
56
|
+
engine: string;
|
|
57
|
+
versions: string[];
|
|
58
|
+
}>;
|
|
59
|
+
regions: CatalogRegion[];
|
|
60
|
+
storage: unknown;
|
|
61
|
+
}
|
|
62
|
+
/** An app size, with the API's own snake_case keys. */
|
|
63
|
+
export interface AppSize {
|
|
64
|
+
name: string;
|
|
65
|
+
slug: string;
|
|
66
|
+
tier_slug: string;
|
|
67
|
+
cpu_type: string;
|
|
68
|
+
cpus: string | number;
|
|
69
|
+
memory_bytes: string | number;
|
|
70
|
+
bandwidth_allowance_gib?: string | number;
|
|
71
|
+
/** Dollars, as a string. */
|
|
72
|
+
usd_per_month: string;
|
|
73
|
+
}
|
|
74
|
+
interface Envelope<T> {
|
|
75
|
+
success: true;
|
|
76
|
+
data: T;
|
|
77
|
+
}
|
|
78
|
+
export type ListServerSizesResponse = Envelope<ServerSize[]>;
|
|
79
|
+
export type ListRegionsResponse = Envelope<CatalogRegion[]>;
|
|
80
|
+
export type ListServerImagesResponse = Envelope<Array<Record<string, unknown>>>;
|
|
81
|
+
export type ListRedisPlansResponse = Envelope<RedisPlan[]>;
|
|
82
|
+
export type GetDatabaseCatalogResponse = Envelope<DatabaseCatalog>;
|
|
83
|
+
export type ListAppSizesResponse = Envelope<AppSize[]>;
|
|
84
|
+
export type ListAppRegionsResponse = Envelope<Array<Record<string, unknown>>>;
|
|
85
|
+
/** Read-only lookups of what can be ordered. Any credential may call them. */
|
|
86
|
+
export declare class CatalogService {
|
|
87
|
+
private readonly transport;
|
|
88
|
+
constructor(transport: Transport);
|
|
89
|
+
/** Lists server sizes and their prices. */
|
|
90
|
+
serverSizes(): Promise<ListServerSizesResponse>;
|
|
91
|
+
/** Lists the regions servers can be created in. */
|
|
92
|
+
serverRegions(): Promise<ListRegionsResponse>;
|
|
93
|
+
/** Lists the one-click images a server can be created from. */
|
|
94
|
+
serverImages(): Promise<ListServerImagesResponse>;
|
|
95
|
+
/** Lists Redis plans and their prices. */
|
|
96
|
+
redisPlans(): Promise<ListRedisPlansResponse>;
|
|
97
|
+
/** Lists the regions Redis can be created in. */
|
|
98
|
+
redisRegions(): Promise<ListRegionsResponse>;
|
|
99
|
+
/** Lists dedicated database sizes, engines with their versions, and regions. */
|
|
100
|
+
databases(): Promise<GetDatabaseCatalogResponse>;
|
|
101
|
+
/** Lists app sizes and their prices. */
|
|
102
|
+
appSizes(): Promise<ListAppSizesResponse>;
|
|
103
|
+
/** Lists the regions apps can be created in. */
|
|
104
|
+
appRegions(): Promise<ListAppRegionsResponse>;
|
|
105
|
+
}
|
|
106
|
+
export {};
|