@hoststack.dev/sdk 0.8.2 → 0.9.2
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/dist/index.cjs +34 -16
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +100 -35
- package/dist/index.d.ts +100 -35
- package/dist/index.js +35 -16
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,35 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Region identifiers accepted by every endpoint that takes a `region`
|
|
3
|
+
* input. Mirrors `packages/shared/src/constants/regions.ts:30` — keep
|
|
4
|
+
* the two in sync when adding a region.
|
|
5
|
+
*/
|
|
6
|
+
type RegionId = 'eu-central-1' | 'eu-central-2' | 'eu-west-1' | 'us-east-1';
|
|
1
7
|
interface Project {
|
|
2
8
|
id: number;
|
|
3
9
|
publicId: string;
|
|
4
10
|
name: string;
|
|
5
11
|
slug: string;
|
|
6
12
|
description?: string | null;
|
|
7
|
-
region:
|
|
13
|
+
region: RegionId;
|
|
8
14
|
createdAt: string;
|
|
9
15
|
updatedAt: string;
|
|
10
16
|
}
|
|
11
17
|
interface CreateProjectInput {
|
|
12
18
|
name: string;
|
|
13
19
|
description?: string;
|
|
14
|
-
region?:
|
|
20
|
+
region?: RegionId;
|
|
15
21
|
}
|
|
16
22
|
interface UpdateProjectInput {
|
|
17
23
|
name?: string;
|
|
18
24
|
description?: string;
|
|
19
25
|
}
|
|
26
|
+
type ServiceType = 'web_service' | 'private_service' | 'worker' | 'cron_job' | 'static_site';
|
|
27
|
+
/**
|
|
28
|
+
* v89: `sleeping` is the free-tier idle state — container is `docker pause`d
|
|
29
|
+
* but warm-resumes <100ms on the next request. Distinct from `suspended`
|
|
30
|
+
* (admin/user action; container fully stopped, requires a deploy to revive).
|
|
31
|
+
*/
|
|
32
|
+
type ServiceStatus = 'active' | 'deploying' | 'suspended' | 'failed' | 'not_deployed' | 'sleeping';
|
|
33
|
+
type ServicePlan = 'pico' | 'nano' | 'micro' | 'starter' | 'standard' | 'pro_standard' | 'pro_large';
|
|
20
34
|
interface Service {
|
|
21
35
|
id: number;
|
|
22
36
|
publicId: string;
|
|
23
37
|
name: string;
|
|
24
|
-
type:
|
|
25
|
-
status:
|
|
38
|
+
type: ServiceType;
|
|
39
|
+
status: ServiceStatus;
|
|
26
40
|
internalUrl?: string | null;
|
|
27
41
|
projectId: number;
|
|
28
42
|
createdAt: string;
|
|
29
43
|
updatedAt: string;
|
|
30
44
|
}
|
|
31
|
-
type ServiceType = 'web_service' | 'private_service' | 'worker' | 'cron_job' | 'static_site';
|
|
32
|
-
type ServicePlan = 'pico' | 'nano' | 'micro' | 'starter' | 'standard' | 'pro_standard' | 'pro_large';
|
|
33
45
|
interface CreateServiceInput {
|
|
34
46
|
name: string;
|
|
35
47
|
type: ServiceType;
|
|
@@ -60,6 +72,8 @@ interface CreateServiceInput {
|
|
|
60
72
|
runtime?: string;
|
|
61
73
|
autoDeploy?: boolean;
|
|
62
74
|
multistage?: boolean;
|
|
75
|
+
/** True when this service is a dev environment (agentic dev-env image, or manually flagged). */
|
|
76
|
+
isDevEnvironment?: boolean;
|
|
63
77
|
}
|
|
64
78
|
/**
|
|
65
79
|
* Fields that live on the `services` row — write via PATCH /services/:tid/:sid.
|
|
@@ -147,11 +161,17 @@ interface UpdateServiceConfigInput {
|
|
|
147
161
|
action: 'drop' | 'downgrade';
|
|
148
162
|
}> | null;
|
|
149
163
|
}
|
|
164
|
+
/**
|
|
165
|
+
* `superseded` (v63 P4) means a newer push for the same (service, branch) arrived
|
|
166
|
+
* before this deploy could finish. Distinct from `cancelled` (operator-initiated).
|
|
167
|
+
*/
|
|
168
|
+
type DeployStatus = 'pending' | 'building' | 'build_failed' | 'deploying' | 'live' | 'failed' | 'cancelled' | 'deactivated' | 'superseded';
|
|
169
|
+
type DeployTrigger = 'github_push' | 'gitlab_push' | 'bitbucket_push' | 'manual' | 'rollback' | 'api' | 'config_change';
|
|
150
170
|
interface Deploy {
|
|
151
171
|
id: number;
|
|
152
172
|
publicId: string;
|
|
153
|
-
status:
|
|
154
|
-
trigger:
|
|
173
|
+
status: DeployStatus;
|
|
174
|
+
trigger: DeployTrigger;
|
|
155
175
|
commitHash?: string | null;
|
|
156
176
|
commitMessage?: string | null;
|
|
157
177
|
createdAt: string;
|
|
@@ -196,6 +216,13 @@ interface TriggerDeployInput {
|
|
|
196
216
|
}
|
|
197
217
|
/** Managed database engines supported by HostStack. */
|
|
198
218
|
type DatabaseEngine = 'postgres' | 'redis' | 'mysql' | 'mariadb' | 'mongodb';
|
|
219
|
+
/**
|
|
220
|
+
* `migrating` (v89 Phase 4) is the transient state while the agent runs the
|
|
221
|
+
* single-node → HA migration (pg_dump → bootstrap → pg_restore). Reads stay
|
|
222
|
+
* read-only during this window.
|
|
223
|
+
*/
|
|
224
|
+
type DatabaseStatus = 'creating' | 'available' | 'suspended' | 'deleting' | 'error' | 'migrating';
|
|
225
|
+
type DatabasePlan = 'free' | 'micro' | 'starter' | 'standard' | 'pro';
|
|
199
226
|
interface Database {
|
|
200
227
|
id: number;
|
|
201
228
|
publicId: string;
|
|
@@ -203,10 +230,10 @@ interface Database {
|
|
|
203
230
|
/** The engine name. The legacy `type` alias still ships in API responses
|
|
204
231
|
* but is deprecated — read `engine` going forward. */
|
|
205
232
|
engine: DatabaseEngine;
|
|
206
|
-
status:
|
|
233
|
+
status: DatabaseStatus;
|
|
207
234
|
version?: string | null;
|
|
208
|
-
plan?:
|
|
209
|
-
region?:
|
|
235
|
+
plan?: DatabasePlan | null;
|
|
236
|
+
region?: RegionId | null;
|
|
210
237
|
projectId: number;
|
|
211
238
|
diskSizeGb?: number;
|
|
212
239
|
memoryMb?: number;
|
|
@@ -227,12 +254,12 @@ interface CreateDatabaseInput {
|
|
|
227
254
|
*/
|
|
228
255
|
environmentId?: number;
|
|
229
256
|
version?: string;
|
|
230
|
-
plan?:
|
|
231
|
-
region?:
|
|
257
|
+
plan?: DatabasePlan;
|
|
258
|
+
region?: RegionId;
|
|
232
259
|
}
|
|
233
260
|
interface UpdateDatabaseInput {
|
|
234
261
|
name?: string;
|
|
235
|
-
plan?:
|
|
262
|
+
plan?: DatabasePlan;
|
|
236
263
|
/** Grow the database disk in GB. Cannot shrink. */
|
|
237
264
|
diskSizeGb?: number;
|
|
238
265
|
}
|
|
@@ -275,11 +302,12 @@ interface UpdateVolumeInput {
|
|
|
275
302
|
mountPath?: string;
|
|
276
303
|
sizeGb?: number;
|
|
277
304
|
}
|
|
305
|
+
type DomainStatus = 'pending' | 'active' | 'failed' | 'deleting';
|
|
278
306
|
interface Domain {
|
|
279
307
|
id: number;
|
|
280
308
|
publicId: string;
|
|
281
309
|
domain: string;
|
|
282
|
-
status:
|
|
310
|
+
status: DomainStatus;
|
|
283
311
|
verified: boolean;
|
|
284
312
|
serviceId?: number | null;
|
|
285
313
|
createdAt: string;
|
|
@@ -330,12 +358,13 @@ interface User {
|
|
|
330
358
|
email: string;
|
|
331
359
|
avatarUrl?: string | null;
|
|
332
360
|
}
|
|
361
|
+
type TeamRole = 'owner' | 'admin' | 'member';
|
|
333
362
|
interface Team {
|
|
334
363
|
id: number;
|
|
335
364
|
publicId: string;
|
|
336
365
|
name: string;
|
|
337
366
|
slug: string;
|
|
338
|
-
role:
|
|
367
|
+
role: TeamRole;
|
|
339
368
|
}
|
|
340
369
|
interface MeResponse {
|
|
341
370
|
/** Null when authenticated with an API key (no associated user). */
|
|
@@ -345,7 +374,12 @@ interface MeResponse {
|
|
|
345
374
|
id: number;
|
|
346
375
|
permission: string;
|
|
347
376
|
};
|
|
377
|
+
/** `'test'` when the API is wired to Stripe's test mode, `'live'` otherwise. */
|
|
348
378
|
stripeMode?: string;
|
|
379
|
+
/** True when the caller is a superadmin acting on behalf of another team. Always false for API-key auth. */
|
|
380
|
+
isImpersonating?: boolean;
|
|
381
|
+
/** v88 P1b: server-side flag the dashboard renders as a "please add a card" prompt for free-tier teams 14+ days in. */
|
|
382
|
+
cardPromptVisible?: boolean;
|
|
349
383
|
}
|
|
350
384
|
/**
|
|
351
385
|
* A single point in a service metrics time series. Same shape used for
|
|
@@ -376,14 +410,16 @@ interface ServiceMetricsSnapshot {
|
|
|
376
410
|
containerCount: number;
|
|
377
411
|
} | null;
|
|
378
412
|
}
|
|
413
|
+
type CronExecutionStatus = 'pending' | 'running' | 'succeeded' | 'failed';
|
|
414
|
+
type CronExecutionTrigger = 'scheduled' | 'manual';
|
|
379
415
|
interface CronExecution {
|
|
380
416
|
id: number;
|
|
381
417
|
publicId: string;
|
|
382
|
-
status:
|
|
418
|
+
status: CronExecutionStatus;
|
|
383
419
|
startedAt?: string | null;
|
|
384
420
|
finishedAt?: string | null;
|
|
385
421
|
exitCode?: number | null;
|
|
386
|
-
triggeredBy?:
|
|
422
|
+
triggeredBy?: CronExecutionTrigger | null;
|
|
387
423
|
createdAt: string;
|
|
388
424
|
}
|
|
389
425
|
interface ActivityLogEntry {
|
|
@@ -827,8 +863,8 @@ declare class ServicesResource {
|
|
|
827
863
|
list(teamId: IdInput, filters?: {
|
|
828
864
|
projectId?: number | string;
|
|
829
865
|
environmentId?: number | string;
|
|
830
|
-
status?:
|
|
831
|
-
type?:
|
|
866
|
+
status?: ServiceStatus;
|
|
867
|
+
type?: ServiceType;
|
|
832
868
|
}): Promise<{
|
|
833
869
|
services: Service[];
|
|
834
870
|
}>;
|
|
@@ -928,6 +964,20 @@ declare class ServicesResource {
|
|
|
928
964
|
streamLogs(teamId: IdInput, serviceId: IdInput, options?: StreamLogsOptions): AsyncGenerator<LogEntry>;
|
|
929
965
|
}
|
|
930
966
|
|
|
967
|
+
declare class TeamsResource {
|
|
968
|
+
private client;
|
|
969
|
+
constructor(client: HostStack);
|
|
970
|
+
/**
|
|
971
|
+
* List the teams the authenticated principal can access.
|
|
972
|
+
*
|
|
973
|
+
* Session auth: all teams the user belongs to.
|
|
974
|
+
* API-key auth: the single team the key is bound to.
|
|
975
|
+
*/
|
|
976
|
+
list(): Promise<{
|
|
977
|
+
teams: Team[];
|
|
978
|
+
}>;
|
|
979
|
+
}
|
|
980
|
+
|
|
931
981
|
/**
|
|
932
982
|
* Manage persistent disks attached to a service.
|
|
933
983
|
*
|
|
@@ -1041,7 +1091,15 @@ declare class HostStack {
|
|
|
1041
1091
|
* failures, restart loops, ACME failures, git auth losses, etc.
|
|
1042
1092
|
*/
|
|
1043
1093
|
readonly notifications: NotificationsResource;
|
|
1094
|
+
/** List the teams this API key (or session) can access. */
|
|
1095
|
+
readonly teams: TeamsResource;
|
|
1044
1096
|
constructor(options: HostStackOptions);
|
|
1097
|
+
/**
|
|
1098
|
+
* Identify the authenticated principal. For API-key auth, `user` is
|
|
1099
|
+
* `null` and `team` is the team the key is bound to; `apiKey` carries
|
|
1100
|
+
* the key's permission scope (read or full).
|
|
1101
|
+
*/
|
|
1102
|
+
me(): Promise<MeResponse>;
|
|
1045
1103
|
/**
|
|
1046
1104
|
* Make an authenticated request to the HostStack API.
|
|
1047
1105
|
* Used internally by resource classes. Can also be used for custom API calls.
|
|
@@ -1089,32 +1147,39 @@ declare class RateLimitError extends HostStackError {
|
|
|
1089
1147
|
|
|
1090
1148
|
/**
|
|
1091
1149
|
* Standard pagination parameters for list requests.
|
|
1150
|
+
*
|
|
1151
|
+
* Mirrors `packages/shared/src/schemas/pagination.ts` — the API uses
|
|
1152
|
+
* `page` (1-based) + `perPage` (≤100) everywhere. Use these names
|
|
1153
|
+
* directly in your code; the SDK serializes them as the matching
|
|
1154
|
+
* query-string params.
|
|
1092
1155
|
*/
|
|
1093
1156
|
interface PaginationParams {
|
|
1094
|
-
/**
|
|
1095
|
-
|
|
1096
|
-
/**
|
|
1097
|
-
|
|
1157
|
+
/** 1-based page number. Default `1`. */
|
|
1158
|
+
page?: number;
|
|
1159
|
+
/** Items per page. Range 1–100, default `20`. */
|
|
1160
|
+
perPage?: number;
|
|
1161
|
+
/** Free-text search applied server-side. ≤200 chars. */
|
|
1162
|
+
search?: string;
|
|
1163
|
+
/** Column to sort by (route-dependent). */
|
|
1164
|
+
sortBy?: string;
|
|
1165
|
+
/** Sort direction. Default `'desc'`. */
|
|
1166
|
+
sortOrder?: 'asc' | 'desc';
|
|
1098
1167
|
}
|
|
1099
1168
|
/**
|
|
1100
|
-
* A paginated response wrapper.
|
|
1169
|
+
* A paginated response wrapper. Mirrors the shape every paginated API
|
|
1170
|
+
* endpoint returns under `data` + `total` + `page` + `perPage` + `totalPages`.
|
|
1101
1171
|
*/
|
|
1102
1172
|
interface PaginatedResponse<T> {
|
|
1103
|
-
|
|
1173
|
+
data: T[];
|
|
1104
1174
|
total: number;
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1175
|
+
page: number;
|
|
1176
|
+
perPage: number;
|
|
1177
|
+
totalPages: number;
|
|
1108
1178
|
}
|
|
1109
1179
|
/**
|
|
1110
1180
|
* Builds a query string from pagination params.
|
|
1111
1181
|
* Returns an empty string if no params are set.
|
|
1112
1182
|
*/
|
|
1113
1183
|
declare function buildPaginationQuery(params?: PaginationParams): string;
|
|
1114
|
-
/**
|
|
1115
|
-
* Wraps a plain array result into a PaginatedResponse.
|
|
1116
|
-
* Useful when the API returns a flat array without pagination metadata.
|
|
1117
|
-
*/
|
|
1118
|
-
declare function wrapArray<T>(items: T[], params?: PaginationParams): PaginatedResponse<T>;
|
|
1119
1184
|
|
|
1120
|
-
export { type ActivityLogEntry, type AddDomainInput, AuthenticationError, type BulkSetEnvVarsInput, ConflictError, type CreateDatabaseInput, type CreateEnvVarInput, type CreateEnvironmentInput, type CreateProjectInput, type CreateServiceInput, type CreateVolumeInput, type CronExecution, type Database, type DatabaseCredentials, type Deploy, type DeployListResponse, type DeployLogEntry, type Domain, type EnvVar, type Environment, ForbiddenError, HostStack, HostStackError, type HostStackOptions, type IdInput, type LogEntry$1 as LogEntry, type MeResponse, NotFoundError, type NotificationChannel, type NotificationChannelEvent, type NotificationChannelType, type PaginatedResponse, type PaginationParams, type Project, RateLimitError, type Service, type ServiceConfig, type ServiceMetricsPoint, type ServiceMetricsSnapshot, type ServicePlan, type ServiceType, type StreamLogsOptions, type Team, type TriggerDeployInput, type UpdateDatabaseInput, type UpdateDomainInput, type UpdateEnvVarInput, type UpdateEnvironmentInput, type UpdateProjectInput, type UpdateServiceConfigInput, type UpdateServiceInput, type UpdateVolumeInput, type User, type Volume, buildPaginationQuery
|
|
1185
|
+
export { type ActivityLogEntry, type AddDomainInput, AuthenticationError, type BulkSetEnvVarsInput, ConflictError, type CreateDatabaseInput, type CreateEnvVarInput, type CreateEnvironmentInput, type CreateProjectInput, type CreateServiceInput, type CreateVolumeInput, type CronExecution, type CronExecutionStatus, type CronExecutionTrigger, type Database, type DatabaseCredentials, type DatabaseEngine, type DatabasePlan, type DatabaseStatus, type Deploy, type DeployListResponse, type DeployLogEntry, type DeployStatus, type DeployTrigger, type Domain, type DomainStatus, type EnvVar, type EnvVarTarget, type Environment, ForbiddenError, HostStack, HostStackError, type HostStackOptions, type IdInput, type LogEntry$1 as LogEntry, type MeResponse, NotFoundError, type NotificationChannel, type NotificationChannelEvent, type NotificationChannelType, type PaginatedResponse, type PaginationParams, type Project, RateLimitError, type RegionId, type Service, type ServiceConfig, type ServiceMetricsPoint, type ServiceMetricsSnapshot, type ServicePlan, type ServiceStatus, type ServiceType, type StreamLogsOptions, type Team, type TeamRole, type TriggerDeployInput, type UpdateDatabaseInput, type UpdateDomainInput, type UpdateEnvVarInput, type UpdateEnvironmentInput, type UpdateProjectInput, type UpdateServiceConfigInput, type UpdateServiceInput, type UpdateVolumeInput, type User, type Volume, buildPaginationQuery };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,35 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Region identifiers accepted by every endpoint that takes a `region`
|
|
3
|
+
* input. Mirrors `packages/shared/src/constants/regions.ts:30` — keep
|
|
4
|
+
* the two in sync when adding a region.
|
|
5
|
+
*/
|
|
6
|
+
type RegionId = 'eu-central-1' | 'eu-central-2' | 'eu-west-1' | 'us-east-1';
|
|
1
7
|
interface Project {
|
|
2
8
|
id: number;
|
|
3
9
|
publicId: string;
|
|
4
10
|
name: string;
|
|
5
11
|
slug: string;
|
|
6
12
|
description?: string | null;
|
|
7
|
-
region:
|
|
13
|
+
region: RegionId;
|
|
8
14
|
createdAt: string;
|
|
9
15
|
updatedAt: string;
|
|
10
16
|
}
|
|
11
17
|
interface CreateProjectInput {
|
|
12
18
|
name: string;
|
|
13
19
|
description?: string;
|
|
14
|
-
region?:
|
|
20
|
+
region?: RegionId;
|
|
15
21
|
}
|
|
16
22
|
interface UpdateProjectInput {
|
|
17
23
|
name?: string;
|
|
18
24
|
description?: string;
|
|
19
25
|
}
|
|
26
|
+
type ServiceType = 'web_service' | 'private_service' | 'worker' | 'cron_job' | 'static_site';
|
|
27
|
+
/**
|
|
28
|
+
* v89: `sleeping` is the free-tier idle state — container is `docker pause`d
|
|
29
|
+
* but warm-resumes <100ms on the next request. Distinct from `suspended`
|
|
30
|
+
* (admin/user action; container fully stopped, requires a deploy to revive).
|
|
31
|
+
*/
|
|
32
|
+
type ServiceStatus = 'active' | 'deploying' | 'suspended' | 'failed' | 'not_deployed' | 'sleeping';
|
|
33
|
+
type ServicePlan = 'pico' | 'nano' | 'micro' | 'starter' | 'standard' | 'pro_standard' | 'pro_large';
|
|
20
34
|
interface Service {
|
|
21
35
|
id: number;
|
|
22
36
|
publicId: string;
|
|
23
37
|
name: string;
|
|
24
|
-
type:
|
|
25
|
-
status:
|
|
38
|
+
type: ServiceType;
|
|
39
|
+
status: ServiceStatus;
|
|
26
40
|
internalUrl?: string | null;
|
|
27
41
|
projectId: number;
|
|
28
42
|
createdAt: string;
|
|
29
43
|
updatedAt: string;
|
|
30
44
|
}
|
|
31
|
-
type ServiceType = 'web_service' | 'private_service' | 'worker' | 'cron_job' | 'static_site';
|
|
32
|
-
type ServicePlan = 'pico' | 'nano' | 'micro' | 'starter' | 'standard' | 'pro_standard' | 'pro_large';
|
|
33
45
|
interface CreateServiceInput {
|
|
34
46
|
name: string;
|
|
35
47
|
type: ServiceType;
|
|
@@ -60,6 +72,8 @@ interface CreateServiceInput {
|
|
|
60
72
|
runtime?: string;
|
|
61
73
|
autoDeploy?: boolean;
|
|
62
74
|
multistage?: boolean;
|
|
75
|
+
/** True when this service is a dev environment (agentic dev-env image, or manually flagged). */
|
|
76
|
+
isDevEnvironment?: boolean;
|
|
63
77
|
}
|
|
64
78
|
/**
|
|
65
79
|
* Fields that live on the `services` row — write via PATCH /services/:tid/:sid.
|
|
@@ -147,11 +161,17 @@ interface UpdateServiceConfigInput {
|
|
|
147
161
|
action: 'drop' | 'downgrade';
|
|
148
162
|
}> | null;
|
|
149
163
|
}
|
|
164
|
+
/**
|
|
165
|
+
* `superseded` (v63 P4) means a newer push for the same (service, branch) arrived
|
|
166
|
+
* before this deploy could finish. Distinct from `cancelled` (operator-initiated).
|
|
167
|
+
*/
|
|
168
|
+
type DeployStatus = 'pending' | 'building' | 'build_failed' | 'deploying' | 'live' | 'failed' | 'cancelled' | 'deactivated' | 'superseded';
|
|
169
|
+
type DeployTrigger = 'github_push' | 'gitlab_push' | 'bitbucket_push' | 'manual' | 'rollback' | 'api' | 'config_change';
|
|
150
170
|
interface Deploy {
|
|
151
171
|
id: number;
|
|
152
172
|
publicId: string;
|
|
153
|
-
status:
|
|
154
|
-
trigger:
|
|
173
|
+
status: DeployStatus;
|
|
174
|
+
trigger: DeployTrigger;
|
|
155
175
|
commitHash?: string | null;
|
|
156
176
|
commitMessage?: string | null;
|
|
157
177
|
createdAt: string;
|
|
@@ -196,6 +216,13 @@ interface TriggerDeployInput {
|
|
|
196
216
|
}
|
|
197
217
|
/** Managed database engines supported by HostStack. */
|
|
198
218
|
type DatabaseEngine = 'postgres' | 'redis' | 'mysql' | 'mariadb' | 'mongodb';
|
|
219
|
+
/**
|
|
220
|
+
* `migrating` (v89 Phase 4) is the transient state while the agent runs the
|
|
221
|
+
* single-node → HA migration (pg_dump → bootstrap → pg_restore). Reads stay
|
|
222
|
+
* read-only during this window.
|
|
223
|
+
*/
|
|
224
|
+
type DatabaseStatus = 'creating' | 'available' | 'suspended' | 'deleting' | 'error' | 'migrating';
|
|
225
|
+
type DatabasePlan = 'free' | 'micro' | 'starter' | 'standard' | 'pro';
|
|
199
226
|
interface Database {
|
|
200
227
|
id: number;
|
|
201
228
|
publicId: string;
|
|
@@ -203,10 +230,10 @@ interface Database {
|
|
|
203
230
|
/** The engine name. The legacy `type` alias still ships in API responses
|
|
204
231
|
* but is deprecated — read `engine` going forward. */
|
|
205
232
|
engine: DatabaseEngine;
|
|
206
|
-
status:
|
|
233
|
+
status: DatabaseStatus;
|
|
207
234
|
version?: string | null;
|
|
208
|
-
plan?:
|
|
209
|
-
region?:
|
|
235
|
+
plan?: DatabasePlan | null;
|
|
236
|
+
region?: RegionId | null;
|
|
210
237
|
projectId: number;
|
|
211
238
|
diskSizeGb?: number;
|
|
212
239
|
memoryMb?: number;
|
|
@@ -227,12 +254,12 @@ interface CreateDatabaseInput {
|
|
|
227
254
|
*/
|
|
228
255
|
environmentId?: number;
|
|
229
256
|
version?: string;
|
|
230
|
-
plan?:
|
|
231
|
-
region?:
|
|
257
|
+
plan?: DatabasePlan;
|
|
258
|
+
region?: RegionId;
|
|
232
259
|
}
|
|
233
260
|
interface UpdateDatabaseInput {
|
|
234
261
|
name?: string;
|
|
235
|
-
plan?:
|
|
262
|
+
plan?: DatabasePlan;
|
|
236
263
|
/** Grow the database disk in GB. Cannot shrink. */
|
|
237
264
|
diskSizeGb?: number;
|
|
238
265
|
}
|
|
@@ -275,11 +302,12 @@ interface UpdateVolumeInput {
|
|
|
275
302
|
mountPath?: string;
|
|
276
303
|
sizeGb?: number;
|
|
277
304
|
}
|
|
305
|
+
type DomainStatus = 'pending' | 'active' | 'failed' | 'deleting';
|
|
278
306
|
interface Domain {
|
|
279
307
|
id: number;
|
|
280
308
|
publicId: string;
|
|
281
309
|
domain: string;
|
|
282
|
-
status:
|
|
310
|
+
status: DomainStatus;
|
|
283
311
|
verified: boolean;
|
|
284
312
|
serviceId?: number | null;
|
|
285
313
|
createdAt: string;
|
|
@@ -330,12 +358,13 @@ interface User {
|
|
|
330
358
|
email: string;
|
|
331
359
|
avatarUrl?: string | null;
|
|
332
360
|
}
|
|
361
|
+
type TeamRole = 'owner' | 'admin' | 'member';
|
|
333
362
|
interface Team {
|
|
334
363
|
id: number;
|
|
335
364
|
publicId: string;
|
|
336
365
|
name: string;
|
|
337
366
|
slug: string;
|
|
338
|
-
role:
|
|
367
|
+
role: TeamRole;
|
|
339
368
|
}
|
|
340
369
|
interface MeResponse {
|
|
341
370
|
/** Null when authenticated with an API key (no associated user). */
|
|
@@ -345,7 +374,12 @@ interface MeResponse {
|
|
|
345
374
|
id: number;
|
|
346
375
|
permission: string;
|
|
347
376
|
};
|
|
377
|
+
/** `'test'` when the API is wired to Stripe's test mode, `'live'` otherwise. */
|
|
348
378
|
stripeMode?: string;
|
|
379
|
+
/** True when the caller is a superadmin acting on behalf of another team. Always false for API-key auth. */
|
|
380
|
+
isImpersonating?: boolean;
|
|
381
|
+
/** v88 P1b: server-side flag the dashboard renders as a "please add a card" prompt for free-tier teams 14+ days in. */
|
|
382
|
+
cardPromptVisible?: boolean;
|
|
349
383
|
}
|
|
350
384
|
/**
|
|
351
385
|
* A single point in a service metrics time series. Same shape used for
|
|
@@ -376,14 +410,16 @@ interface ServiceMetricsSnapshot {
|
|
|
376
410
|
containerCount: number;
|
|
377
411
|
} | null;
|
|
378
412
|
}
|
|
413
|
+
type CronExecutionStatus = 'pending' | 'running' | 'succeeded' | 'failed';
|
|
414
|
+
type CronExecutionTrigger = 'scheduled' | 'manual';
|
|
379
415
|
interface CronExecution {
|
|
380
416
|
id: number;
|
|
381
417
|
publicId: string;
|
|
382
|
-
status:
|
|
418
|
+
status: CronExecutionStatus;
|
|
383
419
|
startedAt?: string | null;
|
|
384
420
|
finishedAt?: string | null;
|
|
385
421
|
exitCode?: number | null;
|
|
386
|
-
triggeredBy?:
|
|
422
|
+
triggeredBy?: CronExecutionTrigger | null;
|
|
387
423
|
createdAt: string;
|
|
388
424
|
}
|
|
389
425
|
interface ActivityLogEntry {
|
|
@@ -827,8 +863,8 @@ declare class ServicesResource {
|
|
|
827
863
|
list(teamId: IdInput, filters?: {
|
|
828
864
|
projectId?: number | string;
|
|
829
865
|
environmentId?: number | string;
|
|
830
|
-
status?:
|
|
831
|
-
type?:
|
|
866
|
+
status?: ServiceStatus;
|
|
867
|
+
type?: ServiceType;
|
|
832
868
|
}): Promise<{
|
|
833
869
|
services: Service[];
|
|
834
870
|
}>;
|
|
@@ -928,6 +964,20 @@ declare class ServicesResource {
|
|
|
928
964
|
streamLogs(teamId: IdInput, serviceId: IdInput, options?: StreamLogsOptions): AsyncGenerator<LogEntry>;
|
|
929
965
|
}
|
|
930
966
|
|
|
967
|
+
declare class TeamsResource {
|
|
968
|
+
private client;
|
|
969
|
+
constructor(client: HostStack);
|
|
970
|
+
/**
|
|
971
|
+
* List the teams the authenticated principal can access.
|
|
972
|
+
*
|
|
973
|
+
* Session auth: all teams the user belongs to.
|
|
974
|
+
* API-key auth: the single team the key is bound to.
|
|
975
|
+
*/
|
|
976
|
+
list(): Promise<{
|
|
977
|
+
teams: Team[];
|
|
978
|
+
}>;
|
|
979
|
+
}
|
|
980
|
+
|
|
931
981
|
/**
|
|
932
982
|
* Manage persistent disks attached to a service.
|
|
933
983
|
*
|
|
@@ -1041,7 +1091,15 @@ declare class HostStack {
|
|
|
1041
1091
|
* failures, restart loops, ACME failures, git auth losses, etc.
|
|
1042
1092
|
*/
|
|
1043
1093
|
readonly notifications: NotificationsResource;
|
|
1094
|
+
/** List the teams this API key (or session) can access. */
|
|
1095
|
+
readonly teams: TeamsResource;
|
|
1044
1096
|
constructor(options: HostStackOptions);
|
|
1097
|
+
/**
|
|
1098
|
+
* Identify the authenticated principal. For API-key auth, `user` is
|
|
1099
|
+
* `null` and `team` is the team the key is bound to; `apiKey` carries
|
|
1100
|
+
* the key's permission scope (read or full).
|
|
1101
|
+
*/
|
|
1102
|
+
me(): Promise<MeResponse>;
|
|
1045
1103
|
/**
|
|
1046
1104
|
* Make an authenticated request to the HostStack API.
|
|
1047
1105
|
* Used internally by resource classes. Can also be used for custom API calls.
|
|
@@ -1089,32 +1147,39 @@ declare class RateLimitError extends HostStackError {
|
|
|
1089
1147
|
|
|
1090
1148
|
/**
|
|
1091
1149
|
* Standard pagination parameters for list requests.
|
|
1150
|
+
*
|
|
1151
|
+
* Mirrors `packages/shared/src/schemas/pagination.ts` — the API uses
|
|
1152
|
+
* `page` (1-based) + `perPage` (≤100) everywhere. Use these names
|
|
1153
|
+
* directly in your code; the SDK serializes them as the matching
|
|
1154
|
+
* query-string params.
|
|
1092
1155
|
*/
|
|
1093
1156
|
interface PaginationParams {
|
|
1094
|
-
/**
|
|
1095
|
-
|
|
1096
|
-
/**
|
|
1097
|
-
|
|
1157
|
+
/** 1-based page number. Default `1`. */
|
|
1158
|
+
page?: number;
|
|
1159
|
+
/** Items per page. Range 1–100, default `20`. */
|
|
1160
|
+
perPage?: number;
|
|
1161
|
+
/** Free-text search applied server-side. ≤200 chars. */
|
|
1162
|
+
search?: string;
|
|
1163
|
+
/** Column to sort by (route-dependent). */
|
|
1164
|
+
sortBy?: string;
|
|
1165
|
+
/** Sort direction. Default `'desc'`. */
|
|
1166
|
+
sortOrder?: 'asc' | 'desc';
|
|
1098
1167
|
}
|
|
1099
1168
|
/**
|
|
1100
|
-
* A paginated response wrapper.
|
|
1169
|
+
* A paginated response wrapper. Mirrors the shape every paginated API
|
|
1170
|
+
* endpoint returns under `data` + `total` + `page` + `perPage` + `totalPages`.
|
|
1101
1171
|
*/
|
|
1102
1172
|
interface PaginatedResponse<T> {
|
|
1103
|
-
|
|
1173
|
+
data: T[];
|
|
1104
1174
|
total: number;
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1175
|
+
page: number;
|
|
1176
|
+
perPage: number;
|
|
1177
|
+
totalPages: number;
|
|
1108
1178
|
}
|
|
1109
1179
|
/**
|
|
1110
1180
|
* Builds a query string from pagination params.
|
|
1111
1181
|
* Returns an empty string if no params are set.
|
|
1112
1182
|
*/
|
|
1113
1183
|
declare function buildPaginationQuery(params?: PaginationParams): string;
|
|
1114
|
-
/**
|
|
1115
|
-
* Wraps a plain array result into a PaginatedResponse.
|
|
1116
|
-
* Useful when the API returns a flat array without pagination metadata.
|
|
1117
|
-
*/
|
|
1118
|
-
declare function wrapArray<T>(items: T[], params?: PaginationParams): PaginatedResponse<T>;
|
|
1119
1184
|
|
|
1120
|
-
export { type ActivityLogEntry, type AddDomainInput, AuthenticationError, type BulkSetEnvVarsInput, ConflictError, type CreateDatabaseInput, type CreateEnvVarInput, type CreateEnvironmentInput, type CreateProjectInput, type CreateServiceInput, type CreateVolumeInput, type CronExecution, type Database, type DatabaseCredentials, type Deploy, type DeployListResponse, type DeployLogEntry, type Domain, type EnvVar, type Environment, ForbiddenError, HostStack, HostStackError, type HostStackOptions, type IdInput, type LogEntry$1 as LogEntry, type MeResponse, NotFoundError, type NotificationChannel, type NotificationChannelEvent, type NotificationChannelType, type PaginatedResponse, type PaginationParams, type Project, RateLimitError, type Service, type ServiceConfig, type ServiceMetricsPoint, type ServiceMetricsSnapshot, type ServicePlan, type ServiceType, type StreamLogsOptions, type Team, type TriggerDeployInput, type UpdateDatabaseInput, type UpdateDomainInput, type UpdateEnvVarInput, type UpdateEnvironmentInput, type UpdateProjectInput, type UpdateServiceConfigInput, type UpdateServiceInput, type UpdateVolumeInput, type User, type Volume, buildPaginationQuery
|
|
1185
|
+
export { type ActivityLogEntry, type AddDomainInput, AuthenticationError, type BulkSetEnvVarsInput, ConflictError, type CreateDatabaseInput, type CreateEnvVarInput, type CreateEnvironmentInput, type CreateProjectInput, type CreateServiceInput, type CreateVolumeInput, type CronExecution, type CronExecutionStatus, type CronExecutionTrigger, type Database, type DatabaseCredentials, type DatabaseEngine, type DatabasePlan, type DatabaseStatus, type Deploy, type DeployListResponse, type DeployLogEntry, type DeployStatus, type DeployTrigger, type Domain, type DomainStatus, type EnvVar, type EnvVarTarget, type Environment, ForbiddenError, HostStack, HostStackError, type HostStackOptions, type IdInput, type LogEntry$1 as LogEntry, type MeResponse, NotFoundError, type NotificationChannel, type NotificationChannelEvent, type NotificationChannelType, type PaginatedResponse, type PaginationParams, type Project, RateLimitError, type RegionId, type Service, type ServiceConfig, type ServiceMetricsPoint, type ServiceMetricsSnapshot, type ServicePlan, type ServiceStatus, type ServiceType, type StreamLogsOptions, type Team, type TeamRole, type TriggerDeployInput, type UpdateDatabaseInput, type UpdateDomainInput, type UpdateEnvVarInput, type UpdateEnvironmentInput, type UpdateProjectInput, type UpdateServiceConfigInput, type UpdateServiceInput, type UpdateVolumeInput, type User, type Volume, buildPaginationQuery };
|
package/dist/index.js
CHANGED
|
@@ -565,12 +565,12 @@ function normalizeEntries(logs) {
|
|
|
565
565
|
return logs;
|
|
566
566
|
}
|
|
567
567
|
function sleep(ms, signal) {
|
|
568
|
-
return new Promise((resolve
|
|
568
|
+
return new Promise((resolve) => {
|
|
569
569
|
const timer = setTimeout(resolve, ms);
|
|
570
570
|
if (signal) {
|
|
571
571
|
signal.addEventListener("abort", () => {
|
|
572
572
|
clearTimeout(timer);
|
|
573
|
-
|
|
573
|
+
resolve();
|
|
574
574
|
});
|
|
575
575
|
}
|
|
576
576
|
});
|
|
@@ -727,6 +727,22 @@ var ServicesResource = class {
|
|
|
727
727
|
}
|
|
728
728
|
};
|
|
729
729
|
|
|
730
|
+
// src/resources/teams.ts
|
|
731
|
+
var TeamsResource = class {
|
|
732
|
+
constructor(client) {
|
|
733
|
+
this.client = client;
|
|
734
|
+
}
|
|
735
|
+
/**
|
|
736
|
+
* List the teams the authenticated principal can access.
|
|
737
|
+
*
|
|
738
|
+
* Session auth: all teams the user belongs to.
|
|
739
|
+
* API-key auth: the single team the key is bound to.
|
|
740
|
+
*/
|
|
741
|
+
async list() {
|
|
742
|
+
return this.client.request("GET", "/api/auth/teams");
|
|
743
|
+
}
|
|
744
|
+
};
|
|
745
|
+
|
|
730
746
|
// src/resources/volumes.ts
|
|
731
747
|
var VolumesResource = class {
|
|
732
748
|
constructor(client) {
|
|
@@ -816,6 +832,8 @@ var HostStack = class {
|
|
|
816
832
|
* failures, restart loops, ACME failures, git auth losses, etc.
|
|
817
833
|
*/
|
|
818
834
|
notifications;
|
|
835
|
+
/** List the teams this API key (or session) can access. */
|
|
836
|
+
teams;
|
|
819
837
|
constructor(options) {
|
|
820
838
|
if (!options.apiKey) {
|
|
821
839
|
throw new Error("apiKey is required");
|
|
@@ -832,6 +850,15 @@ var HostStack = class {
|
|
|
832
850
|
this.cron = new CronResource(this);
|
|
833
851
|
this.volumes = new VolumesResource(this);
|
|
834
852
|
this.notifications = new NotificationsResource(this);
|
|
853
|
+
this.teams = new TeamsResource(this);
|
|
854
|
+
}
|
|
855
|
+
/**
|
|
856
|
+
* Identify the authenticated principal. For API-key auth, `user` is
|
|
857
|
+
* `null` and `team` is the team the key is bound to; `apiKey` carries
|
|
858
|
+
* the key's permission scope (read or full).
|
|
859
|
+
*/
|
|
860
|
+
async me() {
|
|
861
|
+
return this.request("GET", "/api/auth/me");
|
|
835
862
|
}
|
|
836
863
|
/**
|
|
837
864
|
* Make an authenticated request to the HostStack API.
|
|
@@ -985,23 +1012,15 @@ function cacheScope(scope) {
|
|
|
985
1012
|
function buildPaginationQuery(params) {
|
|
986
1013
|
if (!params) return "";
|
|
987
1014
|
const qs = new URLSearchParams();
|
|
988
|
-
if (params.
|
|
989
|
-
if (params.
|
|
1015
|
+
if (params.page !== void 0) qs.set("page", String(params.page));
|
|
1016
|
+
if (params.perPage !== void 0) qs.set("perPage", String(params.perPage));
|
|
1017
|
+
if (params.search !== void 0) qs.set("search", params.search);
|
|
1018
|
+
if (params.sortBy !== void 0) qs.set("sortBy", params.sortBy);
|
|
1019
|
+
if (params.sortOrder !== void 0) qs.set("sortOrder", params.sortOrder);
|
|
990
1020
|
const str = qs.toString();
|
|
991
1021
|
return str ? `?${str}` : "";
|
|
992
1022
|
}
|
|
993
|
-
function wrapArray(items, params) {
|
|
994
|
-
const limit = params?.limit ?? items.length;
|
|
995
|
-
const offset = params?.offset ?? 0;
|
|
996
|
-
return {
|
|
997
|
-
items,
|
|
998
|
-
total: items.length,
|
|
999
|
-
limit,
|
|
1000
|
-
offset,
|
|
1001
|
-
hasMore: false
|
|
1002
|
-
};
|
|
1003
|
-
}
|
|
1004
1023
|
|
|
1005
|
-
export { AuthenticationError, ConflictError, ForbiddenError, HostStack, HostStackError, NotFoundError, RateLimitError, buildPaginationQuery
|
|
1024
|
+
export { AuthenticationError, ConflictError, ForbiddenError, HostStack, HostStackError, NotFoundError, RateLimitError, buildPaginationQuery };
|
|
1006
1025
|
//# sourceMappingURL=index.js.map
|
|
1007
1026
|
//# sourceMappingURL=index.js.map
|