@hoststack.dev/sdk 0.1.1 → 0.2.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/dist/index.cjs +279 -76
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +89 -47
- package/dist/index.d.ts +89 -47
- package/dist/index.js +279 -76
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -33,27 +33,32 @@ var CronResource = class {
|
|
|
33
33
|
}
|
|
34
34
|
/** List cron executions for a service. */
|
|
35
35
|
async list(teamId, serviceId, options) {
|
|
36
|
+
const tid = await this.client.resolveId(teamId, { kind: "team" });
|
|
37
|
+
const sid = await this.client.resolveId(serviceId, { kind: "service", teamId: tid });
|
|
36
38
|
const params = new URLSearchParams();
|
|
37
39
|
if (options?.limit) params.set("limit", String(options.limit));
|
|
38
40
|
const qs = params.toString();
|
|
39
41
|
return this.client.request(
|
|
40
42
|
"GET",
|
|
41
|
-
`/api/services/${
|
|
43
|
+
`/api/services/${tid}/${sid}/cron-executions${qs ? `?${qs}` : ""}`
|
|
42
44
|
);
|
|
43
45
|
}
|
|
44
46
|
/** Get a single cron execution by ID. */
|
|
45
47
|
async get(teamId, serviceId, executionId) {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
48
|
+
const tid = await this.client.resolveId(teamId, { kind: "team" });
|
|
49
|
+
const sid = await this.client.resolveId(serviceId, { kind: "service", teamId: tid });
|
|
50
|
+
const eid = await this.client.resolveId(executionId, {
|
|
51
|
+
kind: "cronExecution",
|
|
52
|
+
teamId: tid,
|
|
53
|
+
serviceId: sid
|
|
54
|
+
});
|
|
55
|
+
return this.client.request("GET", `/api/services/${tid}/${sid}/cron-executions/${eid}`);
|
|
50
56
|
}
|
|
51
57
|
/** Trigger an immediate cron execution. */
|
|
52
58
|
async trigger(teamId, serviceId) {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
);
|
|
59
|
+
const tid = await this.client.resolveId(teamId, { kind: "team" });
|
|
60
|
+
const sid = await this.client.resolveId(serviceId, { kind: "service", teamId: tid });
|
|
61
|
+
return this.client.request("POST", `/api/services/${tid}/${sid}/cron-executions/trigger`);
|
|
57
62
|
}
|
|
58
63
|
};
|
|
59
64
|
|
|
@@ -64,39 +69,56 @@ var DatabasesResource = class {
|
|
|
64
69
|
}
|
|
65
70
|
/** List all databases for a project. */
|
|
66
71
|
async list(teamId, projectId) {
|
|
67
|
-
|
|
72
|
+
const tid = await this.client.resolveId(teamId, { kind: "team" });
|
|
73
|
+
const pid = await this.client.resolveId(projectId, { kind: "project", teamId: tid });
|
|
74
|
+
return this.client.request("GET", `/api/databases/${tid}?projectId=${pid}`);
|
|
68
75
|
}
|
|
69
76
|
/** Get a single database by ID. */
|
|
70
77
|
async get(teamId, databaseId) {
|
|
71
|
-
|
|
78
|
+
const tid = await this.client.resolveId(teamId, { kind: "team" });
|
|
79
|
+
const did = await this.client.resolveId(databaseId, { kind: "database", teamId: tid });
|
|
80
|
+
return this.client.request("GET", `/api/databases/${tid}/${did}`);
|
|
72
81
|
}
|
|
73
82
|
/** Create a new database. */
|
|
74
83
|
async create(teamId, data) {
|
|
75
|
-
|
|
84
|
+
const tid = await this.client.resolveId(teamId, { kind: "team" });
|
|
85
|
+
return this.client.request("POST", `/api/databases/${tid}`, data);
|
|
76
86
|
}
|
|
77
87
|
/** Update a database. */
|
|
78
88
|
async update(teamId, databaseId, data) {
|
|
79
|
-
|
|
89
|
+
const tid = await this.client.resolveId(teamId, { kind: "team" });
|
|
90
|
+
const did = await this.client.resolveId(databaseId, { kind: "database", teamId: tid });
|
|
91
|
+
return this.client.request("PATCH", `/api/databases/${tid}/${did}`, data);
|
|
80
92
|
}
|
|
81
93
|
/** Delete a database. */
|
|
82
94
|
async delete(teamId, databaseId) {
|
|
83
|
-
|
|
95
|
+
const tid = await this.client.resolveId(teamId, { kind: "team" });
|
|
96
|
+
const did = await this.client.resolveId(databaseId, { kind: "database", teamId: tid });
|
|
97
|
+
return this.client.request("DELETE", `/api/databases/${tid}/${did}`);
|
|
84
98
|
}
|
|
85
99
|
/** Suspend a database. */
|
|
86
100
|
async suspend(teamId, databaseId) {
|
|
87
|
-
|
|
101
|
+
const tid = await this.client.resolveId(teamId, { kind: "team" });
|
|
102
|
+
const did = await this.client.resolveId(databaseId, { kind: "database", teamId: tid });
|
|
103
|
+
return this.client.request("POST", `/api/databases/${tid}/${did}/suspend`);
|
|
88
104
|
}
|
|
89
105
|
/** Resume a suspended database. */
|
|
90
106
|
async resume(teamId, databaseId) {
|
|
91
|
-
|
|
107
|
+
const tid = await this.client.resolveId(teamId, { kind: "team" });
|
|
108
|
+
const did = await this.client.resolveId(databaseId, { kind: "database", teamId: tid });
|
|
109
|
+
return this.client.request("POST", `/api/databases/${tid}/${did}/resume`);
|
|
92
110
|
}
|
|
93
111
|
/** Get connection credentials. */
|
|
94
112
|
async getCredentials(teamId, databaseId) {
|
|
95
|
-
|
|
113
|
+
const tid = await this.client.resolveId(teamId, { kind: "team" });
|
|
114
|
+
const did = await this.client.resolveId(databaseId, { kind: "database", teamId: tid });
|
|
115
|
+
return this.client.request("GET", `/api/databases/${tid}/${did}/credentials`);
|
|
96
116
|
}
|
|
97
117
|
/** Reset the database password. */
|
|
98
118
|
async resetPassword(teamId, databaseId) {
|
|
99
|
-
|
|
119
|
+
const tid = await this.client.resolveId(teamId, { kind: "team" });
|
|
120
|
+
const did = await this.client.resolveId(databaseId, { kind: "database", teamId: tid });
|
|
121
|
+
return this.client.request("POST", `/api/databases/${tid}/${did}/reset-password`);
|
|
100
122
|
}
|
|
101
123
|
};
|
|
102
124
|
|
|
@@ -107,43 +129,59 @@ var DeploysResource = class {
|
|
|
107
129
|
}
|
|
108
130
|
/** List deploys for a service. */
|
|
109
131
|
async list(teamId, serviceId) {
|
|
110
|
-
|
|
132
|
+
const tid = await this.client.resolveId(teamId, { kind: "team" });
|
|
133
|
+
const sid = await this.client.resolveId(serviceId, { kind: "service", teamId: tid });
|
|
134
|
+
return this.client.request("GET", `/api/services/${tid}/${sid}/deploys`);
|
|
111
135
|
}
|
|
112
136
|
/** Get a single deploy by ID. */
|
|
113
137
|
async get(teamId, serviceId, deployId) {
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
138
|
+
const tid = await this.client.resolveId(teamId, { kind: "team" });
|
|
139
|
+
const sid = await this.client.resolveId(serviceId, { kind: "service", teamId: tid });
|
|
140
|
+
const did = await this.client.resolveId(deployId, {
|
|
141
|
+
kind: "deploy",
|
|
142
|
+
teamId: tid,
|
|
143
|
+
serviceId: sid
|
|
144
|
+
});
|
|
145
|
+
return this.client.request("GET", `/api/services/${tid}/${sid}/deploys/${did}`);
|
|
118
146
|
}
|
|
119
147
|
/** Trigger a new deploy. */
|
|
120
148
|
async trigger(teamId, serviceId, data) {
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
data ?? {}
|
|
125
|
-
);
|
|
149
|
+
const tid = await this.client.resolveId(teamId, { kind: "team" });
|
|
150
|
+
const sid = await this.client.resolveId(serviceId, { kind: "service", teamId: tid });
|
|
151
|
+
return this.client.request("POST", `/api/services/${tid}/${sid}/deploys`, data ?? {});
|
|
126
152
|
}
|
|
127
153
|
/** Cancel an in-progress deploy. */
|
|
128
154
|
async cancel(teamId, serviceId, deployId) {
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
155
|
+
const tid = await this.client.resolveId(teamId, { kind: "team" });
|
|
156
|
+
const sid = await this.client.resolveId(serviceId, { kind: "service", teamId: tid });
|
|
157
|
+
const did = await this.client.resolveId(deployId, {
|
|
158
|
+
kind: "deploy",
|
|
159
|
+
teamId: tid,
|
|
160
|
+
serviceId: sid
|
|
161
|
+
});
|
|
162
|
+
return this.client.request("POST", `/api/services/${tid}/${sid}/deploys/${did}/cancel`);
|
|
133
163
|
}
|
|
134
164
|
/** Rollback to a previous deploy. */
|
|
135
165
|
async rollback(teamId, serviceId, deployId) {
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
166
|
+
const tid = await this.client.resolveId(teamId, { kind: "team" });
|
|
167
|
+
const sid = await this.client.resolveId(serviceId, { kind: "service", teamId: tid });
|
|
168
|
+
const did = await this.client.resolveId(deployId, {
|
|
169
|
+
kind: "deploy",
|
|
170
|
+
teamId: tid,
|
|
171
|
+
serviceId: sid
|
|
172
|
+
});
|
|
173
|
+
return this.client.request("POST", `/api/services/${tid}/${sid}/deploys/${did}/rollback`);
|
|
140
174
|
}
|
|
141
175
|
/** Get build logs for a deploy. */
|
|
142
176
|
async getLogs(teamId, serviceId, deployId) {
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
177
|
+
const tid = await this.client.resolveId(teamId, { kind: "team" });
|
|
178
|
+
const sid = await this.client.resolveId(serviceId, { kind: "service", teamId: tid });
|
|
179
|
+
const did = await this.client.resolveId(deployId, {
|
|
180
|
+
kind: "deploy",
|
|
181
|
+
teamId: tid,
|
|
182
|
+
serviceId: sid
|
|
183
|
+
});
|
|
184
|
+
return this.client.request("GET", `/api/services/${tid}/${sid}/deploys/${did}/logs`);
|
|
147
185
|
}
|
|
148
186
|
};
|
|
149
187
|
|
|
@@ -154,23 +192,31 @@ var DomainsResource = class {
|
|
|
154
192
|
}
|
|
155
193
|
/** List all domains for the active team. */
|
|
156
194
|
async list(teamId) {
|
|
157
|
-
|
|
195
|
+
const tid = await this.client.resolveId(teamId, { kind: "team" });
|
|
196
|
+
return this.client.request("GET", `/api/domains/${tid}`);
|
|
158
197
|
}
|
|
159
198
|
/** Add a custom domain. */
|
|
160
199
|
async add(teamId, data) {
|
|
161
|
-
|
|
200
|
+
const tid = await this.client.resolveId(teamId, { kind: "team" });
|
|
201
|
+
return this.client.request("POST", `/api/domains/${tid}`, data);
|
|
162
202
|
}
|
|
163
203
|
/** Update a domain. */
|
|
164
204
|
async update(teamId, domainId, data) {
|
|
165
|
-
|
|
205
|
+
const tid = await this.client.resolveId(teamId, { kind: "team" });
|
|
206
|
+
const did = await this.client.resolveId(domainId, { kind: "domain", teamId: tid });
|
|
207
|
+
return this.client.request("PATCH", `/api/domains/${tid}/${did}`, data);
|
|
166
208
|
}
|
|
167
209
|
/** Remove a domain. */
|
|
168
210
|
async remove(teamId, domainId) {
|
|
169
|
-
|
|
211
|
+
const tid = await this.client.resolveId(teamId, { kind: "team" });
|
|
212
|
+
const did = await this.client.resolveId(domainId, { kind: "domain", teamId: tid });
|
|
213
|
+
return this.client.request("DELETE", `/api/domains/${tid}/${did}`);
|
|
170
214
|
}
|
|
171
215
|
/** Verify domain DNS configuration. */
|
|
172
216
|
async verify(teamId, domainId) {
|
|
173
|
-
|
|
217
|
+
const tid = await this.client.resolveId(teamId, { kind: "team" });
|
|
218
|
+
const did = await this.client.resolveId(domainId, { kind: "domain", teamId: tid });
|
|
219
|
+
return this.client.request("POST", `/api/domains/${tid}/${did}/verify`);
|
|
174
220
|
}
|
|
175
221
|
};
|
|
176
222
|
|
|
@@ -181,30 +227,43 @@ var EnvVarsResource = class {
|
|
|
181
227
|
}
|
|
182
228
|
/** List all environment variables for a service. */
|
|
183
229
|
async list(teamId, serviceId) {
|
|
184
|
-
|
|
230
|
+
const tid = await this.client.resolveId(teamId, { kind: "team" });
|
|
231
|
+
const sid = await this.client.resolveId(serviceId, { kind: "service", teamId: tid });
|
|
232
|
+
return this.client.request("GET", `/api/services/${tid}/${sid}/env`);
|
|
185
233
|
}
|
|
186
234
|
/** Create a new environment variable. */
|
|
187
235
|
async create(teamId, serviceId, data) {
|
|
188
|
-
|
|
236
|
+
const tid = await this.client.resolveId(teamId, { kind: "team" });
|
|
237
|
+
const sid = await this.client.resolveId(serviceId, { kind: "service", teamId: tid });
|
|
238
|
+
return this.client.request("POST", `/api/services/${tid}/${sid}/env`, data);
|
|
189
239
|
}
|
|
190
240
|
/** Update an environment variable. */
|
|
191
241
|
async update(teamId, serviceId, envVarId, data) {
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
242
|
+
const tid = await this.client.resolveId(teamId, { kind: "team" });
|
|
243
|
+
const sid = await this.client.resolveId(serviceId, { kind: "service", teamId: tid });
|
|
244
|
+
const eid = await this.client.resolveId(envVarId, {
|
|
245
|
+
kind: "envVar",
|
|
246
|
+
teamId: tid,
|
|
247
|
+
serviceId: sid
|
|
248
|
+
});
|
|
249
|
+
return this.client.request("PATCH", `/api/services/${tid}/${sid}/env/${eid}`, data);
|
|
197
250
|
}
|
|
198
251
|
/** Delete an environment variable. */
|
|
199
252
|
async delete(teamId, serviceId, envVarId) {
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
253
|
+
const tid = await this.client.resolveId(teamId, { kind: "team" });
|
|
254
|
+
const sid = await this.client.resolveId(serviceId, { kind: "service", teamId: tid });
|
|
255
|
+
const eid = await this.client.resolveId(envVarId, {
|
|
256
|
+
kind: "envVar",
|
|
257
|
+
teamId: tid,
|
|
258
|
+
serviceId: sid
|
|
259
|
+
});
|
|
260
|
+
return this.client.request("DELETE", `/api/services/${tid}/${sid}/env/${eid}`);
|
|
204
261
|
}
|
|
205
262
|
/** Bulk set environment variables (create or update). */
|
|
206
263
|
async bulkSet(teamId, serviceId, data) {
|
|
207
|
-
|
|
264
|
+
const tid = await this.client.resolveId(teamId, { kind: "team" });
|
|
265
|
+
const sid = await this.client.resolveId(serviceId, { kind: "service", teamId: tid });
|
|
266
|
+
return this.client.request("PUT", `/api/services/${tid}/${sid}/env/bulk`, data);
|
|
208
267
|
}
|
|
209
268
|
};
|
|
210
269
|
|
|
@@ -215,23 +274,31 @@ var ProjectsResource = class {
|
|
|
215
274
|
}
|
|
216
275
|
/** List all projects for the active team. */
|
|
217
276
|
async list(teamId) {
|
|
218
|
-
|
|
277
|
+
const tid = await this.client.resolveId(teamId, { kind: "team" });
|
|
278
|
+
return this.client.request("GET", `/api/projects/${tid}`);
|
|
219
279
|
}
|
|
220
280
|
/** Get a single project by ID. */
|
|
221
281
|
async get(teamId, projectId) {
|
|
222
|
-
|
|
282
|
+
const tid = await this.client.resolveId(teamId, { kind: "team" });
|
|
283
|
+
const pid = await this.client.resolveId(projectId, { kind: "project", teamId: tid });
|
|
284
|
+
return this.client.request("GET", `/api/projects/${tid}/${pid}`);
|
|
223
285
|
}
|
|
224
286
|
/** Create a new project. */
|
|
225
287
|
async create(teamId, data) {
|
|
226
|
-
|
|
288
|
+
const tid = await this.client.resolveId(teamId, { kind: "team" });
|
|
289
|
+
return this.client.request("POST", `/api/projects/${tid}`, data);
|
|
227
290
|
}
|
|
228
291
|
/** Update a project. */
|
|
229
292
|
async update(teamId, projectId, data) {
|
|
230
|
-
|
|
293
|
+
const tid = await this.client.resolveId(teamId, { kind: "team" });
|
|
294
|
+
const pid = await this.client.resolveId(projectId, { kind: "project", teamId: tid });
|
|
295
|
+
return this.client.request("PATCH", `/api/projects/${tid}/${pid}`, data);
|
|
231
296
|
}
|
|
232
297
|
/** Delete a project. */
|
|
233
298
|
async delete(teamId, projectId) {
|
|
234
|
-
|
|
299
|
+
const tid = await this.client.resolveId(teamId, { kind: "team" });
|
|
300
|
+
const pid = await this.client.resolveId(projectId, { kind: "project", teamId: tid });
|
|
301
|
+
return this.client.request("DELETE", `/api/projects/${tid}/${pid}`);
|
|
235
302
|
}
|
|
236
303
|
};
|
|
237
304
|
|
|
@@ -299,46 +366,66 @@ var ServicesResource = class {
|
|
|
299
366
|
}
|
|
300
367
|
/** List all services for the active team. */
|
|
301
368
|
async list(teamId) {
|
|
302
|
-
|
|
369
|
+
const tid = await this.client.resolveId(teamId, { kind: "team" });
|
|
370
|
+
return this.client.request("GET", `/api/services/${tid}`);
|
|
303
371
|
}
|
|
304
372
|
/** Get a single service by ID. */
|
|
305
373
|
async get(teamId, serviceId) {
|
|
306
|
-
|
|
374
|
+
const tid = await this.client.resolveId(teamId, { kind: "team" });
|
|
375
|
+
const sid = await this.client.resolveId(serviceId, { kind: "service", teamId: tid });
|
|
376
|
+
return this.client.request("GET", `/api/services/${tid}/${sid}`);
|
|
307
377
|
}
|
|
308
378
|
/** Create a new service. */
|
|
309
379
|
async create(teamId, data) {
|
|
310
|
-
|
|
380
|
+
const tid = await this.client.resolveId(teamId, { kind: "team" });
|
|
381
|
+
return this.client.request("POST", `/api/services/${tid}`, data);
|
|
311
382
|
}
|
|
312
383
|
/** Update a service. */
|
|
313
384
|
async update(teamId, serviceId, data) {
|
|
314
|
-
|
|
385
|
+
const tid = await this.client.resolveId(teamId, { kind: "team" });
|
|
386
|
+
const sid = await this.client.resolveId(serviceId, { kind: "service", teamId: tid });
|
|
387
|
+
return this.client.request("PATCH", `/api/services/${tid}/${sid}`, data);
|
|
315
388
|
}
|
|
316
389
|
/** Delete a service. */
|
|
317
390
|
async delete(teamId, serviceId) {
|
|
318
|
-
|
|
391
|
+
const tid = await this.client.resolveId(teamId, { kind: "team" });
|
|
392
|
+
const sid = await this.client.resolveId(serviceId, { kind: "service", teamId: tid });
|
|
393
|
+
return this.client.request("DELETE", `/api/services/${tid}/${sid}`);
|
|
319
394
|
}
|
|
320
395
|
/** Suspend a service. */
|
|
321
396
|
async suspend(teamId, serviceId) {
|
|
322
|
-
|
|
397
|
+
const tid = await this.client.resolveId(teamId, { kind: "team" });
|
|
398
|
+
const sid = await this.client.resolveId(serviceId, { kind: "service", teamId: tid });
|
|
399
|
+
return this.client.request("POST", `/api/services/${tid}/${sid}/suspend`);
|
|
323
400
|
}
|
|
324
401
|
/** Resume a suspended service. */
|
|
325
402
|
async resume(teamId, serviceId) {
|
|
326
|
-
|
|
403
|
+
const tid = await this.client.resolveId(teamId, { kind: "team" });
|
|
404
|
+
const sid = await this.client.resolveId(serviceId, { kind: "service", teamId: tid });
|
|
405
|
+
return this.client.request("POST", `/api/services/${tid}/${sid}/resume`);
|
|
327
406
|
}
|
|
328
407
|
/** Get service metrics. */
|
|
329
408
|
async getMetrics(teamId, serviceId) {
|
|
330
|
-
|
|
409
|
+
const tid = await this.client.resolveId(teamId, { kind: "team" });
|
|
410
|
+
const sid = await this.client.resolveId(serviceId, { kind: "service", teamId: tid });
|
|
411
|
+
return this.client.request("GET", `/api/services/${tid}/${sid}/metrics`);
|
|
331
412
|
}
|
|
332
413
|
/** Get service configuration. */
|
|
333
414
|
async getConfig(teamId, serviceId) {
|
|
334
|
-
|
|
415
|
+
const tid = await this.client.resolveId(teamId, { kind: "team" });
|
|
416
|
+
const sid = await this.client.resolveId(serviceId, { kind: "service", teamId: tid });
|
|
417
|
+
return this.client.request("GET", `/api/services/${tid}/${sid}/config`);
|
|
335
418
|
}
|
|
336
419
|
/** Update service configuration. */
|
|
337
420
|
async updateConfig(teamId, serviceId, data) {
|
|
338
|
-
|
|
421
|
+
const tid = await this.client.resolveId(teamId, { kind: "team" });
|
|
422
|
+
const sid = await this.client.resolveId(serviceId, { kind: "service", teamId: tid });
|
|
423
|
+
return this.client.request("PATCH", `/api/services/${tid}/${sid}/config`, data);
|
|
339
424
|
}
|
|
340
425
|
/** Get runtime logs for a service. */
|
|
341
426
|
async getRuntimeLogs(teamId, serviceId, options) {
|
|
427
|
+
const tid = await this.client.resolveId(teamId, { kind: "team" });
|
|
428
|
+
const sid = await this.client.resolveId(serviceId, { kind: "service", teamId: tid });
|
|
342
429
|
const params = new URLSearchParams();
|
|
343
430
|
if (options?.lines) params.set("lines", String(options.lines));
|
|
344
431
|
if (options?.since) params.set("since", options.since);
|
|
@@ -346,7 +433,7 @@ var ServicesResource = class {
|
|
|
346
433
|
const qs = params.toString();
|
|
347
434
|
return this.client.request(
|
|
348
435
|
"GET",
|
|
349
|
-
`/api/services/${
|
|
436
|
+
`/api/services/${tid}/${sid}/runtime-logs${qs ? `?${qs}` : ""}`
|
|
350
437
|
);
|
|
351
438
|
}
|
|
352
439
|
/**
|
|
@@ -361,9 +448,11 @@ var ServicesResource = class {
|
|
|
361
448
|
* }
|
|
362
449
|
* ```
|
|
363
450
|
*/
|
|
364
|
-
streamLogs(teamId, serviceId, options) {
|
|
365
|
-
const
|
|
366
|
-
|
|
451
|
+
async *streamLogs(teamId, serviceId, options) {
|
|
452
|
+
const tid = await this.client.resolveId(teamId, { kind: "team" });
|
|
453
|
+
const sid = await this.client.resolveId(serviceId, { kind: "service", teamId: tid });
|
|
454
|
+
const basePath = `/api/services/${tid}/${sid}/runtime-logs`;
|
|
455
|
+
yield* streamLogsViaPolling(
|
|
367
456
|
(path) => this.client.request("GET", path),
|
|
368
457
|
basePath,
|
|
369
458
|
options
|
|
@@ -372,9 +461,21 @@ var ServicesResource = class {
|
|
|
372
461
|
};
|
|
373
462
|
|
|
374
463
|
// src/client.ts
|
|
464
|
+
var PREFIX = {
|
|
465
|
+
team: "team_",
|
|
466
|
+
project: "prj_",
|
|
467
|
+
service: "svc_",
|
|
468
|
+
deploy: "dpl_",
|
|
469
|
+
database: "db_",
|
|
470
|
+
domain: "dom_",
|
|
471
|
+
envVar: "env_",
|
|
472
|
+
cronExecution: "cjob_"
|
|
473
|
+
};
|
|
375
474
|
var HostStack = class {
|
|
376
475
|
apiKey;
|
|
377
476
|
baseUrl;
|
|
477
|
+
// publicId → numeric id, scoped by parent context. Lifetime: client instance.
|
|
478
|
+
idCache = /* @__PURE__ */ new Map();
|
|
378
479
|
/** Manage projects. */
|
|
379
480
|
projects;
|
|
380
481
|
/** Manage services (web, worker, cron). */
|
|
@@ -439,7 +540,109 @@ var HostStack = class {
|
|
|
439
540
|
}
|
|
440
541
|
return res.json();
|
|
441
542
|
}
|
|
543
|
+
/**
|
|
544
|
+
* Resolve a publicId-or-numeric id input to a numeric database id. Numeric
|
|
545
|
+
* inputs short-circuit; publicIds (svc_xyz, dpl_xyz, etc.) are looked up
|
|
546
|
+
* via the relevant list endpoint and cached on this client instance.
|
|
547
|
+
*
|
|
548
|
+
* The API addresses everything by numeric id internally; this resolver lets
|
|
549
|
+
* SDK/MCP consumers pass either form interchangeably without burning extra
|
|
550
|
+
* round-trips on subsequent calls.
|
|
551
|
+
*/
|
|
552
|
+
async resolveId(input, scope) {
|
|
553
|
+
if (typeof input === "number") return input;
|
|
554
|
+
if (/^\d+$/.test(input)) return Number.parseInt(input, 10);
|
|
555
|
+
const expectedPrefix = PREFIX[scope.kind];
|
|
556
|
+
if (!input.startsWith(expectedPrefix)) {
|
|
557
|
+
throw new HostStackError(
|
|
558
|
+
400,
|
|
559
|
+
`Invalid ${scope.kind} id "${input}": expected ${expectedPrefix}xxx or numeric.`
|
|
560
|
+
);
|
|
561
|
+
}
|
|
562
|
+
const cacheKey = `${cacheScope(scope)}:${input}`;
|
|
563
|
+
const cached = this.idCache.get(cacheKey);
|
|
564
|
+
if (cached !== void 0) return cached;
|
|
565
|
+
const items = await this.fetchForResolution(scope);
|
|
566
|
+
const match = items.find((it) => it.publicId === input);
|
|
567
|
+
if (!match) {
|
|
568
|
+
throw new NotFoundError(`${scope.kind} ${input} not found`);
|
|
569
|
+
}
|
|
570
|
+
this.idCache.set(cacheKey, match.id);
|
|
571
|
+
return match.id;
|
|
572
|
+
}
|
|
573
|
+
async fetchForResolution(scope) {
|
|
574
|
+
switch (scope.kind) {
|
|
575
|
+
case "team": {
|
|
576
|
+
const r = await this.request(
|
|
577
|
+
"GET",
|
|
578
|
+
"/api/teams"
|
|
579
|
+
);
|
|
580
|
+
return r.teams ?? [];
|
|
581
|
+
}
|
|
582
|
+
case "project": {
|
|
583
|
+
const r = await this.request(
|
|
584
|
+
"GET",
|
|
585
|
+
`/api/projects/${scope.teamId}`
|
|
586
|
+
);
|
|
587
|
+
return r.projects ?? [];
|
|
588
|
+
}
|
|
589
|
+
case "service": {
|
|
590
|
+
const r = await this.request(
|
|
591
|
+
"GET",
|
|
592
|
+
`/api/services/${scope.teamId}`
|
|
593
|
+
);
|
|
594
|
+
return r.services ?? [];
|
|
595
|
+
}
|
|
596
|
+
case "deploy": {
|
|
597
|
+
const r = await this.request(
|
|
598
|
+
"GET",
|
|
599
|
+
`/api/services/${scope.teamId}/${scope.serviceId}/deploys`
|
|
600
|
+
);
|
|
601
|
+
return r.deploys ?? [];
|
|
602
|
+
}
|
|
603
|
+
case "database": {
|
|
604
|
+
const r = await this.request(
|
|
605
|
+
"GET",
|
|
606
|
+
`/api/databases/${scope.teamId}`
|
|
607
|
+
);
|
|
608
|
+
return r.databases ?? [];
|
|
609
|
+
}
|
|
610
|
+
case "domain": {
|
|
611
|
+
const r = await this.request(
|
|
612
|
+
"GET",
|
|
613
|
+
`/api/domains/${scope.teamId}`
|
|
614
|
+
);
|
|
615
|
+
return r.domains ?? [];
|
|
616
|
+
}
|
|
617
|
+
case "envVar": {
|
|
618
|
+
const r = await this.request(
|
|
619
|
+
"GET",
|
|
620
|
+
`/api/services/${scope.teamId}/${scope.serviceId}/env`
|
|
621
|
+
);
|
|
622
|
+
return r.envVars ?? [];
|
|
623
|
+
}
|
|
624
|
+
case "cronExecution": {
|
|
625
|
+
const r = await this.request("GET", `/api/services/${scope.teamId}/${scope.serviceId}/cron-executions`);
|
|
626
|
+
return r.executions ?? [];
|
|
627
|
+
}
|
|
628
|
+
}
|
|
629
|
+
}
|
|
442
630
|
};
|
|
631
|
+
function cacheScope(scope) {
|
|
632
|
+
switch (scope.kind) {
|
|
633
|
+
case "team":
|
|
634
|
+
return "team";
|
|
635
|
+
case "project":
|
|
636
|
+
case "service":
|
|
637
|
+
case "database":
|
|
638
|
+
case "domain":
|
|
639
|
+
return `${scope.kind}:${scope.teamId}`;
|
|
640
|
+
case "deploy":
|
|
641
|
+
case "envVar":
|
|
642
|
+
case "cronExecution":
|
|
643
|
+
return `${scope.kind}:${scope.teamId}:${scope.serviceId}`;
|
|
644
|
+
}
|
|
645
|
+
}
|
|
443
646
|
|
|
444
647
|
// src/pagination.ts
|
|
445
648
|
function buildPaginationQuery(params) {
|