@terrantula/sdk 0.0.1
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/LICENSE +201 -0
- package/README.md +26 -0
- package/dist/audit-export-BJSNZ9ic.d.mts +56 -0
- package/dist/audit-export-BJSNZ9ic.d.ts +56 -0
- package/dist/chunk-NTU2AEMP.mjs +1507 -0
- package/dist/index.d.mts +22569 -0
- package/dist/index.d.ts +22569 -0
- package/dist/index.js +1530 -0
- package/dist/index.mjs +10 -0
- package/dist/local.d.mts +16806 -0
- package/dist/local.d.ts +16806 -0
- package/dist/local.js +1549 -0
- package/dist/local.mjs +27 -0
- package/package.json +80 -0
|
@@ -0,0 +1,1507 @@
|
|
|
1
|
+
// src/index.ts
|
|
2
|
+
import { hc as hc4 } from "hono/client";
|
|
3
|
+
import { Hono } from "hono";
|
|
4
|
+
|
|
5
|
+
// src/helpers.ts
|
|
6
|
+
function fallbackMessage(status) {
|
|
7
|
+
return `Request failed with status ${status}`;
|
|
8
|
+
}
|
|
9
|
+
var TerrantulaError = class extends Error {
|
|
10
|
+
constructor(status, body) {
|
|
11
|
+
const message = body != null && typeof body === "object" && "error" in body ? String(body.error) : fallbackMessage(status);
|
|
12
|
+
super(message);
|
|
13
|
+
this.status = status;
|
|
14
|
+
this.body = body;
|
|
15
|
+
this.name = "TerrantulaError";
|
|
16
|
+
}
|
|
17
|
+
status;
|
|
18
|
+
body;
|
|
19
|
+
};
|
|
20
|
+
function withSchema(schema, fn) {
|
|
21
|
+
return Object.assign(fn, { schema });
|
|
22
|
+
}
|
|
23
|
+
async function call(p) {
|
|
24
|
+
const res = await p;
|
|
25
|
+
const body = await res.json().catch(() => ({}));
|
|
26
|
+
if (!res.ok) throw new TerrantulaError(res.status, body);
|
|
27
|
+
return body;
|
|
28
|
+
}
|
|
29
|
+
var buildHeaders = (token) => {
|
|
30
|
+
if (!token) return {};
|
|
31
|
+
if (typeof token === "function")
|
|
32
|
+
return async () => ({ Authorization: `Bearer ${await token()}` });
|
|
33
|
+
return { Authorization: `Bearer ${token}` };
|
|
34
|
+
};
|
|
35
|
+
function stringifyQuery(params) {
|
|
36
|
+
return Object.fromEntries(
|
|
37
|
+
Object.entries(params).filter(([, v]) => v !== void 0).map(([k, v]) => [k, String(v)])
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// src/orgs.ts
|
|
42
|
+
import { z } from "zod";
|
|
43
|
+
async function personalTokensRequest(baseUrl, hcOpts, path, init = {}) {
|
|
44
|
+
const fetchImpl = hcOpts?.fetch ?? fetch;
|
|
45
|
+
const rawHeaders = hcOpts?.headers;
|
|
46
|
+
const resolvedHeaders = typeof rawHeaders === "function" ? await rawHeaders() : rawHeaders ?? {};
|
|
47
|
+
return fetchImpl(`${baseUrl}${path}`, {
|
|
48
|
+
...init,
|
|
49
|
+
// why: RequestInit['headers'] is HeadersInit (a union); we narrow to Record<string,string> after the static-record check above.
|
|
50
|
+
headers: { ...resolvedHeaders, ...init.headers }
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
async function callPersonalTokens(res) {
|
|
54
|
+
if (!res.ok) {
|
|
55
|
+
let message = fallbackMessage(res.status);
|
|
56
|
+
try {
|
|
57
|
+
const body = await res.json();
|
|
58
|
+
if (body.error) message = body.error;
|
|
59
|
+
} catch {
|
|
60
|
+
}
|
|
61
|
+
throw new TerrantulaError(res.status, { error: message });
|
|
62
|
+
}
|
|
63
|
+
return res.json();
|
|
64
|
+
}
|
|
65
|
+
function createOrgsClient(cloud, baseUrl, hcOpts) {
|
|
66
|
+
return {
|
|
67
|
+
create: withSchema(
|
|
68
|
+
z.object({
|
|
69
|
+
name: z.string().describe("Display name"),
|
|
70
|
+
slug: z.string().describe("URL slug (lowercase, hyphens only)")
|
|
71
|
+
}),
|
|
72
|
+
(params) => call(cloud.orgs.$post({ json: params }))
|
|
73
|
+
),
|
|
74
|
+
get: withSchema(
|
|
75
|
+
z.object({
|
|
76
|
+
id: z.string().describe("Organization ID")
|
|
77
|
+
}),
|
|
78
|
+
(params) => call(cloud.orgs[":id"].$get({ param: params }))
|
|
79
|
+
),
|
|
80
|
+
listUsers: withSchema(
|
|
81
|
+
z.object({
|
|
82
|
+
id: z.string().describe("Organization ID")
|
|
83
|
+
}),
|
|
84
|
+
(params) => call(cloud.orgs[":id"].users.$get({ param: params }))
|
|
85
|
+
),
|
|
86
|
+
inviteUser: withSchema(
|
|
87
|
+
z.object({
|
|
88
|
+
id: z.string().describe("Organization ID"),
|
|
89
|
+
email: z.string().describe("User email"),
|
|
90
|
+
name: z.string().describe("User full name"),
|
|
91
|
+
role: z.enum(["owner", "admin", "member"]).optional().describe("Role (owner|admin|member)")
|
|
92
|
+
}),
|
|
93
|
+
(params) => {
|
|
94
|
+
const { id, ...body } = params;
|
|
95
|
+
return call(cloud.orgs[":id"].users.$post({ param: { id }, json: body }));
|
|
96
|
+
}
|
|
97
|
+
),
|
|
98
|
+
updateUserRole: withSchema(
|
|
99
|
+
z.object({
|
|
100
|
+
id: z.string().describe("Organization ID"),
|
|
101
|
+
userId: z.string().describe("User ID"),
|
|
102
|
+
role: z.enum(["owner", "admin", "member"]).describe("New role")
|
|
103
|
+
}),
|
|
104
|
+
(params) => {
|
|
105
|
+
const { id, userId, ...body } = params;
|
|
106
|
+
return call(
|
|
107
|
+
cloud.orgs[":id"].users[":userId"].$patch({ param: { id, userId }, json: body })
|
|
108
|
+
);
|
|
109
|
+
}
|
|
110
|
+
),
|
|
111
|
+
removeUser: withSchema(
|
|
112
|
+
z.object({
|
|
113
|
+
id: z.string().describe("Organization ID"),
|
|
114
|
+
userId: z.string().describe("User ID")
|
|
115
|
+
}),
|
|
116
|
+
(params) => call(cloud.orgs[":id"].users[":userId"].$delete({ param: params }))
|
|
117
|
+
),
|
|
118
|
+
leave: withSchema(
|
|
119
|
+
z.object({
|
|
120
|
+
id: z.string().describe("Organization ID")
|
|
121
|
+
}),
|
|
122
|
+
(params) => call(cloud.orgs[":id"].leave.$post({ param: params }))
|
|
123
|
+
),
|
|
124
|
+
delete: withSchema(
|
|
125
|
+
z.object({
|
|
126
|
+
id: z.string().describe("Organization ID")
|
|
127
|
+
}),
|
|
128
|
+
(params) => call(cloud.orgs[":id"].$delete({ param: params }))
|
|
129
|
+
),
|
|
130
|
+
listPersonalTokens: withSchema(
|
|
131
|
+
z.object({
|
|
132
|
+
id: z.string().describe("Organization ID")
|
|
133
|
+
}),
|
|
134
|
+
async (params) => callPersonalTokens(
|
|
135
|
+
await personalTokensRequest(baseUrl, hcOpts, `/orgs/${params.id}/personal-tokens`)
|
|
136
|
+
)
|
|
137
|
+
),
|
|
138
|
+
createPersonalToken: withSchema(
|
|
139
|
+
z.object({
|
|
140
|
+
id: z.string().describe("Organization ID"),
|
|
141
|
+
name: z.string().describe("Token label"),
|
|
142
|
+
expiresAt: z.string().datetime().optional().describe("Optional ISO expiry")
|
|
143
|
+
}),
|
|
144
|
+
async (params) => {
|
|
145
|
+
const { id, ...body } = params;
|
|
146
|
+
return callPersonalTokens(
|
|
147
|
+
await personalTokensRequest(baseUrl, hcOpts, `/orgs/${id}/personal-tokens`, {
|
|
148
|
+
method: "POST",
|
|
149
|
+
headers: { "Content-Type": "application/json" },
|
|
150
|
+
body: JSON.stringify(body)
|
|
151
|
+
})
|
|
152
|
+
);
|
|
153
|
+
}
|
|
154
|
+
),
|
|
155
|
+
revokePersonalToken: withSchema(
|
|
156
|
+
z.object({
|
|
157
|
+
id: z.string().describe("Organization ID"),
|
|
158
|
+
tokenId: z.string().describe("Personal token ID")
|
|
159
|
+
}),
|
|
160
|
+
async (params) => callPersonalTokens(
|
|
161
|
+
await personalTokensRequest(
|
|
162
|
+
baseUrl,
|
|
163
|
+
hcOpts,
|
|
164
|
+
`/orgs/${params.id}/personal-tokens/${params.tokenId}`,
|
|
165
|
+
{ method: "DELETE" }
|
|
166
|
+
)
|
|
167
|
+
)
|
|
168
|
+
),
|
|
169
|
+
listSsoExtras: withSchema(
|
|
170
|
+
z.object({
|
|
171
|
+
id: z.string().describe("Organization ID")
|
|
172
|
+
}),
|
|
173
|
+
async (params) => callPersonalTokens(
|
|
174
|
+
await personalTokensRequest(baseUrl, hcOpts, `/orgs/${params.id}/sso-extras`)
|
|
175
|
+
)
|
|
176
|
+
),
|
|
177
|
+
setSsoForce: withSchema(
|
|
178
|
+
z.object({
|
|
179
|
+
id: z.string().describe("Organization ID"),
|
|
180
|
+
providerId: z.string().describe("SSO provider ID"),
|
|
181
|
+
forceSso: z.boolean().describe("Force-SSO toggle for this provider")
|
|
182
|
+
}),
|
|
183
|
+
async (params) => callPersonalTokens(
|
|
184
|
+
await personalTokensRequest(
|
|
185
|
+
baseUrl,
|
|
186
|
+
hcOpts,
|
|
187
|
+
`/orgs/${params.id}/sso-extras/${params.providerId}`,
|
|
188
|
+
{
|
|
189
|
+
method: "PATCH",
|
|
190
|
+
headers: { "Content-Type": "application/json" },
|
|
191
|
+
body: JSON.stringify({ forceSso: params.forceSso })
|
|
192
|
+
}
|
|
193
|
+
)
|
|
194
|
+
)
|
|
195
|
+
)
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
// src/projects.ts
|
|
200
|
+
import { z as z2 } from "zod";
|
|
201
|
+
import { hc } from "hono/client";
|
|
202
|
+
function createProjectsClient(cloud, baseUrl, hcOpts) {
|
|
203
|
+
return {
|
|
204
|
+
list: withSchema(
|
|
205
|
+
z2.object({
|
|
206
|
+
orgId: z2.string().describe("Organization ID")
|
|
207
|
+
}),
|
|
208
|
+
(params) => call(cloud.orgs[":orgId"].projects.$get({ param: params }))
|
|
209
|
+
),
|
|
210
|
+
create: withSchema(
|
|
211
|
+
z2.object({
|
|
212
|
+
orgId: z2.string().describe("Organization ID"),
|
|
213
|
+
name: z2.string().describe("Project name"),
|
|
214
|
+
slug: z2.string().describe("URL slug (lowercase, hyphens only)")
|
|
215
|
+
}),
|
|
216
|
+
(params) => {
|
|
217
|
+
const { orgId, ...body } = params;
|
|
218
|
+
return call(cloud.orgs[":orgId"].projects.$post({ param: { orgId }, json: body }));
|
|
219
|
+
}
|
|
220
|
+
),
|
|
221
|
+
get: withSchema(
|
|
222
|
+
z2.object({
|
|
223
|
+
orgId: z2.string().describe("Organization ID"),
|
|
224
|
+
projectId: z2.string().describe("Project ID")
|
|
225
|
+
}),
|
|
226
|
+
(params) => call(cloud.orgs[":orgId"].projects[":projectId"].$get({ param: params }))
|
|
227
|
+
),
|
|
228
|
+
delete: withSchema(
|
|
229
|
+
z2.object({
|
|
230
|
+
orgId: z2.string().describe("Organization ID"),
|
|
231
|
+
projectId: z2.string().describe("Project ID")
|
|
232
|
+
}),
|
|
233
|
+
(params) => call(cloud.orgs[":orgId"].projects[":projectId"].$delete({ param: params }))
|
|
234
|
+
),
|
|
235
|
+
update: withSchema(
|
|
236
|
+
z2.object({
|
|
237
|
+
orgId: z2.string().describe("Organization ID"),
|
|
238
|
+
projectId: z2.string().describe("Project ID"),
|
|
239
|
+
name: z2.string().optional().describe("New project name"),
|
|
240
|
+
metadata: z2.record(z2.unknown()).optional().describe("Per-project UI settings")
|
|
241
|
+
}),
|
|
242
|
+
(params) => {
|
|
243
|
+
const { orgId, projectId, ...body } = params;
|
|
244
|
+
return call(
|
|
245
|
+
cloud.orgs[":orgId"].projects[":projectId"].$put({
|
|
246
|
+
param: { orgId, projectId },
|
|
247
|
+
json: body
|
|
248
|
+
})
|
|
249
|
+
);
|
|
250
|
+
}
|
|
251
|
+
),
|
|
252
|
+
listMembers: withSchema(
|
|
253
|
+
z2.object({
|
|
254
|
+
orgId: z2.string().describe("Organization ID"),
|
|
255
|
+
projectId: z2.string().describe("Project ID")
|
|
256
|
+
}),
|
|
257
|
+
(params) => call(cloud.orgs[":orgId"].projects[":projectId"].members.$get({ param: params }))
|
|
258
|
+
),
|
|
259
|
+
addMember: withSchema(
|
|
260
|
+
z2.object({
|
|
261
|
+
orgId: z2.string().describe("Organization ID"),
|
|
262
|
+
projectId: z2.string().describe("Project ID"),
|
|
263
|
+
userId: z2.string().describe("User ID"),
|
|
264
|
+
role: z2.enum(["owner", "admin", "member", "viewer"]).optional().describe("Role (owner|admin|member|viewer)"),
|
|
265
|
+
envName: z2.string().optional().describe("Optional env scope; omit for project-wide access")
|
|
266
|
+
}),
|
|
267
|
+
(params) => {
|
|
268
|
+
const { orgId, projectId, ...body } = params;
|
|
269
|
+
return call(
|
|
270
|
+
cloud.orgs[":orgId"].projects[":projectId"].members.$post({
|
|
271
|
+
param: { orgId, projectId },
|
|
272
|
+
json: body
|
|
273
|
+
})
|
|
274
|
+
);
|
|
275
|
+
}
|
|
276
|
+
),
|
|
277
|
+
removeMember: withSchema(
|
|
278
|
+
z2.object({
|
|
279
|
+
orgId: z2.string().describe("Organization ID"),
|
|
280
|
+
projectId: z2.string().describe("Project ID"),
|
|
281
|
+
userId: z2.string().describe("User ID")
|
|
282
|
+
}),
|
|
283
|
+
(params) => call(
|
|
284
|
+
cloud.orgs[":orgId"].projects[":projectId"].members[":userId"].$delete({
|
|
285
|
+
param: params
|
|
286
|
+
})
|
|
287
|
+
)
|
|
288
|
+
),
|
|
289
|
+
updateCellScopes: withSchema(
|
|
290
|
+
z2.object({
|
|
291
|
+
orgId: z2.string().describe("Organization ID"),
|
|
292
|
+
projectId: z2.string().describe("Project ID"),
|
|
293
|
+
userId: z2.string().describe("User ID"),
|
|
294
|
+
cellScopes: z2.union([z2.array(z2.string()), z2.null()]).describe("null = all cells; array = restrict to listed cell-label values")
|
|
295
|
+
}),
|
|
296
|
+
(params) => {
|
|
297
|
+
const { orgId, projectId, userId, cellScopes } = params;
|
|
298
|
+
return call(
|
|
299
|
+
cloud.orgs[":orgId"].projects[":projectId"].members[":userId"]["cell-scopes"].$put({
|
|
300
|
+
param: { orgId, projectId, userId },
|
|
301
|
+
json: { cellScopes }
|
|
302
|
+
})
|
|
303
|
+
);
|
|
304
|
+
}
|
|
305
|
+
),
|
|
306
|
+
listTokens: withSchema(
|
|
307
|
+
z2.object({
|
|
308
|
+
orgId: z2.string().describe("Organization ID"),
|
|
309
|
+
projectId: z2.string().describe("Project ID")
|
|
310
|
+
}),
|
|
311
|
+
(params) => call(
|
|
312
|
+
hc(
|
|
313
|
+
`${baseUrl}/orgs/${params.orgId}/projects/${params.projectId}/tokens`,
|
|
314
|
+
hcOpts
|
|
315
|
+
).index.$get()
|
|
316
|
+
)
|
|
317
|
+
),
|
|
318
|
+
createToken: withSchema(
|
|
319
|
+
z2.object({
|
|
320
|
+
orgId: z2.string().describe("Organization ID"),
|
|
321
|
+
projectId: z2.string().describe("Project ID"),
|
|
322
|
+
name: z2.string().describe("Token name"),
|
|
323
|
+
role: z2.enum(["owner", "admin", "member", "viewer"]).optional().describe("Role (owner|admin|member|viewer)"),
|
|
324
|
+
expiresAt: z2.string().optional().describe("Expiry timestamp (ISO 8601)"),
|
|
325
|
+
envName: z2.string().optional().describe("Optional env scope; omit for project-wide access"),
|
|
326
|
+
cellScopes: z2.union([z2.array(z2.string()), z2.null()]).optional().describe(
|
|
327
|
+
"Optional cell scope; null/omitted = all cells, array = restrict to listed cell-label values"
|
|
328
|
+
)
|
|
329
|
+
}),
|
|
330
|
+
(params) => {
|
|
331
|
+
const { orgId, projectId, ...body } = params;
|
|
332
|
+
return call(
|
|
333
|
+
hc(
|
|
334
|
+
`${baseUrl}/orgs/${orgId}/projects/${projectId}/tokens`,
|
|
335
|
+
hcOpts
|
|
336
|
+
).index.$post({ json: body })
|
|
337
|
+
);
|
|
338
|
+
}
|
|
339
|
+
),
|
|
340
|
+
revokeToken: withSchema(
|
|
341
|
+
z2.object({
|
|
342
|
+
orgId: z2.string().describe("Organization ID"),
|
|
343
|
+
projectId: z2.string().describe("Project ID"),
|
|
344
|
+
tokenId: z2.string().describe("Token ID")
|
|
345
|
+
}),
|
|
346
|
+
(params) => call(
|
|
347
|
+
hc(
|
|
348
|
+
`${baseUrl}/orgs/${params.orgId}/projects/${params.projectId}/tokens`,
|
|
349
|
+
hcOpts
|
|
350
|
+
)[":tokenId"].$delete({ param: { tokenId: params.tokenId } })
|
|
351
|
+
)
|
|
352
|
+
)
|
|
353
|
+
};
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
// src/entities.ts
|
|
357
|
+
import { z as z3 } from "zod";
|
|
358
|
+
import {
|
|
359
|
+
EntityTypeSchema,
|
|
360
|
+
EntitySchema
|
|
361
|
+
} from "@terrantula/types";
|
|
362
|
+
function createEntityTypesClient(proj) {
|
|
363
|
+
return {
|
|
364
|
+
list: withSchema(
|
|
365
|
+
z3.object({
|
|
366
|
+
projectId: z3.string().describe("Project ID")
|
|
367
|
+
}),
|
|
368
|
+
(params) => call(proj(params.projectId)["entity-types"].$get())
|
|
369
|
+
),
|
|
370
|
+
get: withSchema(
|
|
371
|
+
z3.object({
|
|
372
|
+
projectId: z3.string().describe("Project ID"),
|
|
373
|
+
name: z3.string().describe("Entity type name")
|
|
374
|
+
}),
|
|
375
|
+
(params) => call(proj(params.projectId)["entity-types"][":name"].$get({ param: { name: params.name } }))
|
|
376
|
+
),
|
|
377
|
+
create: withSchema(
|
|
378
|
+
EntityTypeSchema.extend({ projectId: z3.string().describe("Project ID") }),
|
|
379
|
+
(params) => {
|
|
380
|
+
const { projectId, ...body } = params;
|
|
381
|
+
return call(proj(projectId)["entity-types"].$post({ json: body }));
|
|
382
|
+
}
|
|
383
|
+
),
|
|
384
|
+
update: withSchema(
|
|
385
|
+
EntityTypeSchema.extend({ projectId: z3.string().describe("Project ID") }),
|
|
386
|
+
(params) => {
|
|
387
|
+
const { projectId, ...body } = params;
|
|
388
|
+
return call(
|
|
389
|
+
proj(projectId)["entity-types"][":name"].$put({ param: { name: params.name }, json: body })
|
|
390
|
+
);
|
|
391
|
+
}
|
|
392
|
+
),
|
|
393
|
+
delete: withSchema(
|
|
394
|
+
z3.object({
|
|
395
|
+
projectId: z3.string().describe("Project ID"),
|
|
396
|
+
name: z3.string().describe("Entity type name")
|
|
397
|
+
}),
|
|
398
|
+
(params) => call(
|
|
399
|
+
proj(params.projectId)["entity-types"][":name"].$delete({ param: { name: params.name } })
|
|
400
|
+
)
|
|
401
|
+
)
|
|
402
|
+
};
|
|
403
|
+
}
|
|
404
|
+
function createEntitiesClient(projEnv) {
|
|
405
|
+
return {
|
|
406
|
+
list: withSchema(
|
|
407
|
+
z3.object({
|
|
408
|
+
projectId: z3.string().describe("Project ID"),
|
|
409
|
+
envName: z3.string().describe("Environment name"),
|
|
410
|
+
entityType: z3.string().optional().describe("Filter by entity type"),
|
|
411
|
+
state: z3.string().optional().describe("Filter by state"),
|
|
412
|
+
pool: z3.string().optional().describe("Filter by pool membership"),
|
|
413
|
+
limit: z3.coerce.number().int().min(1).max(100).optional().describe("Max results (1-100)"),
|
|
414
|
+
cursor: z3.string().optional().describe("Pagination cursor")
|
|
415
|
+
}),
|
|
416
|
+
(params) => {
|
|
417
|
+
const { projectId, envName, ...query } = params;
|
|
418
|
+
return call(
|
|
419
|
+
projEnv(projectId, envName)["entities"].$get({ query: stringifyQuery(query) })
|
|
420
|
+
);
|
|
421
|
+
}
|
|
422
|
+
),
|
|
423
|
+
get: withSchema(
|
|
424
|
+
z3.object({
|
|
425
|
+
projectId: z3.string().describe("Project ID"),
|
|
426
|
+
envName: z3.string().describe("Environment name"),
|
|
427
|
+
id: z3.string().uuid().describe("Entity ID")
|
|
428
|
+
}),
|
|
429
|
+
(params) => call(projEnv(params.projectId, params.envName)["entities"][":id"].$get({ param: { id: params.id } }))
|
|
430
|
+
),
|
|
431
|
+
create: withSchema(
|
|
432
|
+
EntitySchema.extend({
|
|
433
|
+
projectId: z3.string().describe("Project ID"),
|
|
434
|
+
envName: z3.string().describe("Environment name")
|
|
435
|
+
}),
|
|
436
|
+
(params) => {
|
|
437
|
+
const { projectId, envName, ...body } = params;
|
|
438
|
+
return call(projEnv(projectId, envName)["entities"].$post({ json: body }));
|
|
439
|
+
}
|
|
440
|
+
),
|
|
441
|
+
delete: withSchema(
|
|
442
|
+
z3.object({
|
|
443
|
+
projectId: z3.string().describe("Project ID"),
|
|
444
|
+
envName: z3.string().describe("Environment name"),
|
|
445
|
+
id: z3.string().uuid().describe("Entity ID")
|
|
446
|
+
}),
|
|
447
|
+
(params) => call(
|
|
448
|
+
projEnv(params.projectId, params.envName)["entities"][":id"].$delete({ param: { id: params.id } })
|
|
449
|
+
)
|
|
450
|
+
),
|
|
451
|
+
setMetric: withSchema(
|
|
452
|
+
z3.object({
|
|
453
|
+
projectId: z3.string().describe("Project ID"),
|
|
454
|
+
envName: z3.string().describe("Environment name"),
|
|
455
|
+
id: z3.string().uuid().describe("Entity ID"),
|
|
456
|
+
metricName: z3.string().describe("Metric name"),
|
|
457
|
+
value: z3.number().describe("Metric value")
|
|
458
|
+
}),
|
|
459
|
+
(params) => {
|
|
460
|
+
const { projectId, envName, id, metricName, value } = params;
|
|
461
|
+
return call(
|
|
462
|
+
projEnv(projectId, envName)["entities"][":id"]["metrics"][":metricName"].$put({
|
|
463
|
+
param: { id, metricName },
|
|
464
|
+
json: { value }
|
|
465
|
+
})
|
|
466
|
+
);
|
|
467
|
+
}
|
|
468
|
+
),
|
|
469
|
+
trigger: withSchema(
|
|
470
|
+
z3.object({
|
|
471
|
+
projectId: z3.string().describe("Project ID"),
|
|
472
|
+
envName: z3.string().describe("Environment name"),
|
|
473
|
+
id: z3.string().uuid().describe("Entity ID"),
|
|
474
|
+
actionName: z3.string().describe("Action name"),
|
|
475
|
+
parameters: z3.record(z3.unknown()).optional().describe("Action parameters as JSON"),
|
|
476
|
+
recommendations: z3.record(z3.string()).optional().describe("Recommendation selections as JSON")
|
|
477
|
+
}).describe("Trigger an instance-scope action on a single entity"),
|
|
478
|
+
(params) => {
|
|
479
|
+
const { projectId, envName, id, actionName, parameters, recommendations } = params;
|
|
480
|
+
return call(
|
|
481
|
+
projEnv(projectId, envName)["entities"][":id"]["actions"][":actionName"].$post({
|
|
482
|
+
param: { id, actionName },
|
|
483
|
+
json: { parameters, recommendations }
|
|
484
|
+
})
|
|
485
|
+
);
|
|
486
|
+
}
|
|
487
|
+
),
|
|
488
|
+
getMetrics: withSchema(
|
|
489
|
+
z3.object({
|
|
490
|
+
projectId: z3.string().describe("Project ID"),
|
|
491
|
+
envName: z3.string().describe("Environment name"),
|
|
492
|
+
entityId: z3.string().describe("Entity ID")
|
|
493
|
+
}),
|
|
494
|
+
(params) => call(projEnv(params.projectId, params.envName).entities[":id"].metrics.$get({ param: { id: params.entityId } }))
|
|
495
|
+
),
|
|
496
|
+
getMetricsBatch: withSchema(
|
|
497
|
+
z3.object({
|
|
498
|
+
projectId: z3.string().describe("Project ID"),
|
|
499
|
+
envName: z3.string().describe("Environment name"),
|
|
500
|
+
entityIds: z3.array(z3.string().uuid()).min(1).max(500).describe("Entity IDs to fetch metrics for (max 500)")
|
|
501
|
+
}),
|
|
502
|
+
(params) => {
|
|
503
|
+
const { projectId, envName, entityIds } = params;
|
|
504
|
+
return call(
|
|
505
|
+
projEnv(projectId, envName).entities.metrics.$get({
|
|
506
|
+
query: { ids: entityIds.join(",") }
|
|
507
|
+
})
|
|
508
|
+
);
|
|
509
|
+
}
|
|
510
|
+
),
|
|
511
|
+
getRelationships: withSchema(
|
|
512
|
+
z3.object({
|
|
513
|
+
projectId: z3.string().describe("Project ID"),
|
|
514
|
+
envName: z3.string().describe("Environment name"),
|
|
515
|
+
entityId: z3.string().describe("Entity ID")
|
|
516
|
+
}),
|
|
517
|
+
(params) => call(projEnv(params.projectId, params.envName).entities[":id"].relationships.$get({ param: { id: params.entityId } }))
|
|
518
|
+
),
|
|
519
|
+
syncStamp: withSchema(
|
|
520
|
+
z3.object({
|
|
521
|
+
projectId: z3.string().describe("Project ID"),
|
|
522
|
+
envName: z3.string().describe("Environment name"),
|
|
523
|
+
id: z3.string().uuid().describe("Entity ID"),
|
|
524
|
+
source: z3.string().min(1).describe("Source-of-truth name (e.g. argo, k8s, aws)"),
|
|
525
|
+
observedAt: z3.string().datetime().optional().describe("ISO-8601 observation timestamp; defaults to server time")
|
|
526
|
+
}),
|
|
527
|
+
(params) => {
|
|
528
|
+
const { projectId, envName, id, source, observedAt } = params;
|
|
529
|
+
return call(
|
|
530
|
+
projEnv(projectId, envName)["entities"][":id"]["sync-stamp"].$post({
|
|
531
|
+
param: { id },
|
|
532
|
+
json: { source, observedAt }
|
|
533
|
+
})
|
|
534
|
+
);
|
|
535
|
+
}
|
|
536
|
+
)
|
|
537
|
+
};
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
// src/cells.ts
|
|
541
|
+
import { z as z4 } from "zod";
|
|
542
|
+
import { CellSchema } from "@terrantula/types";
|
|
543
|
+
function createCellsClient(proj) {
|
|
544
|
+
return {
|
|
545
|
+
list: withSchema(
|
|
546
|
+
z4.object({
|
|
547
|
+
projectId: z4.string().describe("Project ID")
|
|
548
|
+
}),
|
|
549
|
+
(params) => call(proj(params.projectId)["cells"].$get())
|
|
550
|
+
),
|
|
551
|
+
get: withSchema(
|
|
552
|
+
z4.object({
|
|
553
|
+
projectId: z4.string().describe("Project ID"),
|
|
554
|
+
name: z4.string().describe("Cell name")
|
|
555
|
+
}),
|
|
556
|
+
(params) => call(proj(params.projectId)["cells"][":name"].$get({ param: { name: params.name } }))
|
|
557
|
+
),
|
|
558
|
+
create: withSchema(
|
|
559
|
+
CellSchema.extend({ projectId: z4.string().describe("Project ID") }),
|
|
560
|
+
(params) => {
|
|
561
|
+
const { projectId, ...body } = params;
|
|
562
|
+
return call(proj(projectId)["cells"].$post({ json: body }));
|
|
563
|
+
}
|
|
564
|
+
),
|
|
565
|
+
update: withSchema(
|
|
566
|
+
CellSchema.extend({ projectId: z4.string().describe("Project ID") }),
|
|
567
|
+
(params) => {
|
|
568
|
+
const { projectId, ...body } = params;
|
|
569
|
+
return call(
|
|
570
|
+
proj(projectId)["cells"][":name"].$put({ param: { name: params.name }, json: body })
|
|
571
|
+
);
|
|
572
|
+
}
|
|
573
|
+
),
|
|
574
|
+
delete: withSchema(
|
|
575
|
+
z4.object({
|
|
576
|
+
projectId: z4.string().describe("Project ID"),
|
|
577
|
+
name: z4.string().describe("Cell name")
|
|
578
|
+
}),
|
|
579
|
+
(params) => call(proj(params.projectId)["cells"][":name"].$delete({ param: { name: params.name } }))
|
|
580
|
+
),
|
|
581
|
+
listMembers: withSchema(
|
|
582
|
+
z4.object({
|
|
583
|
+
projectId: z4.string().describe("Project ID"),
|
|
584
|
+
name: z4.string().describe("Cell name")
|
|
585
|
+
}),
|
|
586
|
+
(params) => call(
|
|
587
|
+
proj(params.projectId)["cells"][":name"]["members"].$get({ param: { name: params.name } })
|
|
588
|
+
)
|
|
589
|
+
),
|
|
590
|
+
addMember: withSchema(
|
|
591
|
+
z4.object({
|
|
592
|
+
projectId: z4.string().describe("Project ID"),
|
|
593
|
+
name: z4.string().describe("Cell name"),
|
|
594
|
+
entityId: z4.string().uuid().describe("Entity ID")
|
|
595
|
+
}),
|
|
596
|
+
(params) => {
|
|
597
|
+
const { projectId, name, entityId } = params;
|
|
598
|
+
return call(
|
|
599
|
+
proj(projectId)["cells"][":name"]["members"].$post({
|
|
600
|
+
param: { name },
|
|
601
|
+
json: { entityId }
|
|
602
|
+
})
|
|
603
|
+
);
|
|
604
|
+
}
|
|
605
|
+
),
|
|
606
|
+
removeMember: withSchema(
|
|
607
|
+
z4.object({
|
|
608
|
+
projectId: z4.string().describe("Project ID"),
|
|
609
|
+
name: z4.string().describe("Cell name"),
|
|
610
|
+
entityId: z4.string().uuid().describe("Entity ID")
|
|
611
|
+
}),
|
|
612
|
+
(params) => call(
|
|
613
|
+
proj(params.projectId)["cells"][":name"]["members"][":entityId"].$delete({
|
|
614
|
+
param: { name: params.name, entityId: params.entityId }
|
|
615
|
+
})
|
|
616
|
+
)
|
|
617
|
+
)
|
|
618
|
+
};
|
|
619
|
+
}
|
|
620
|
+
|
|
621
|
+
// src/relationships.ts
|
|
622
|
+
import { z as z5 } from "zod";
|
|
623
|
+
import { RelationshipTypeSchema, RelationshipSchema } from "@terrantula/types";
|
|
624
|
+
function createRelationshipTypesClient(proj) {
|
|
625
|
+
return {
|
|
626
|
+
list: withSchema(
|
|
627
|
+
z5.object({
|
|
628
|
+
projectId: z5.string().describe("Project ID")
|
|
629
|
+
}),
|
|
630
|
+
(params) => call(proj(params.projectId)["relationship-types"].$get())
|
|
631
|
+
),
|
|
632
|
+
get: withSchema(
|
|
633
|
+
z5.object({
|
|
634
|
+
projectId: z5.string().describe("Project ID"),
|
|
635
|
+
name: z5.string().describe("Relationship type name")
|
|
636
|
+
}),
|
|
637
|
+
(params) => call(
|
|
638
|
+
proj(params.projectId)["relationship-types"][":name"].$get({
|
|
639
|
+
param: { name: params.name }
|
|
640
|
+
})
|
|
641
|
+
)
|
|
642
|
+
),
|
|
643
|
+
create: withSchema(
|
|
644
|
+
RelationshipTypeSchema.extend({ projectId: z5.string().describe("Project ID") }),
|
|
645
|
+
(params) => {
|
|
646
|
+
const { projectId, ...body } = params;
|
|
647
|
+
return call(proj(projectId)["relationship-types"].$post({ json: body }));
|
|
648
|
+
}
|
|
649
|
+
),
|
|
650
|
+
update: withSchema(
|
|
651
|
+
RelationshipTypeSchema.extend({ projectId: z5.string().describe("Project ID") }),
|
|
652
|
+
(params) => {
|
|
653
|
+
const { projectId, ...body } = params;
|
|
654
|
+
return call(
|
|
655
|
+
proj(projectId)["relationship-types"][":name"].$put({
|
|
656
|
+
param: { name: params.name },
|
|
657
|
+
json: body
|
|
658
|
+
})
|
|
659
|
+
);
|
|
660
|
+
}
|
|
661
|
+
),
|
|
662
|
+
delete: withSchema(
|
|
663
|
+
z5.object({
|
|
664
|
+
projectId: z5.string().describe("Project ID"),
|
|
665
|
+
name: z5.string().describe("Relationship type name")
|
|
666
|
+
}),
|
|
667
|
+
(params) => call(
|
|
668
|
+
proj(params.projectId)["relationship-types"][":name"].$delete({
|
|
669
|
+
param: { name: params.name }
|
|
670
|
+
})
|
|
671
|
+
)
|
|
672
|
+
)
|
|
673
|
+
};
|
|
674
|
+
}
|
|
675
|
+
function createRelationshipsClient(projEnv) {
|
|
676
|
+
return {
|
|
677
|
+
list: withSchema(
|
|
678
|
+
z5.object({
|
|
679
|
+
projectId: z5.string().describe("Project ID"),
|
|
680
|
+
envName: z5.string().describe("Environment name"),
|
|
681
|
+
relationshipType: z5.string().optional().describe("Filter by relationship type"),
|
|
682
|
+
state: z5.string().optional().describe("Filter by state"),
|
|
683
|
+
fromEntity: z5.string().uuid().optional().describe("Filter by from-entity ID"),
|
|
684
|
+
toEntity: z5.string().uuid().optional().describe("Filter by to-entity ID"),
|
|
685
|
+
fromEntityPool: z5.string().optional().describe("Filter by from-entity pool"),
|
|
686
|
+
toEntityPool: z5.string().optional().describe("Filter by to-entity pool"),
|
|
687
|
+
limit: z5.coerce.number().int().min(1).max(100).optional().describe("Max results (1-100)")
|
|
688
|
+
}),
|
|
689
|
+
(params) => {
|
|
690
|
+
const { projectId, envName, ...query } = params;
|
|
691
|
+
return call(
|
|
692
|
+
projEnv(projectId, envName)["relationships"].$get({ query: stringifyQuery(query) })
|
|
693
|
+
);
|
|
694
|
+
}
|
|
695
|
+
),
|
|
696
|
+
get: withSchema(
|
|
697
|
+
z5.object({
|
|
698
|
+
projectId: z5.string().describe("Project ID"),
|
|
699
|
+
envName: z5.string().describe("Environment name"),
|
|
700
|
+
id: z5.string().uuid().describe("Relationship ID")
|
|
701
|
+
}),
|
|
702
|
+
(params) => call(
|
|
703
|
+
projEnv(params.projectId, params.envName)["relationships"][":id"].$get({ param: { id: params.id } })
|
|
704
|
+
)
|
|
705
|
+
),
|
|
706
|
+
create: withSchema(
|
|
707
|
+
RelationshipSchema.extend({
|
|
708
|
+
projectId: z5.string().describe("Project ID"),
|
|
709
|
+
envName: z5.string().describe("Environment name")
|
|
710
|
+
}),
|
|
711
|
+
(params) => {
|
|
712
|
+
const { projectId, envName, ...body } = params;
|
|
713
|
+
return call(projEnv(projectId, envName)["relationships"].$post({ json: body }));
|
|
714
|
+
}
|
|
715
|
+
),
|
|
716
|
+
delete: withSchema(
|
|
717
|
+
z5.object({
|
|
718
|
+
projectId: z5.string().describe("Project ID"),
|
|
719
|
+
envName: z5.string().describe("Environment name"),
|
|
720
|
+
id: z5.string().uuid().describe("Relationship ID")
|
|
721
|
+
}),
|
|
722
|
+
(params) => call(
|
|
723
|
+
projEnv(params.projectId, params.envName)["relationships"][":id"].$delete({ param: { id: params.id } })
|
|
724
|
+
)
|
|
725
|
+
)
|
|
726
|
+
};
|
|
727
|
+
}
|
|
728
|
+
|
|
729
|
+
// src/actions.ts
|
|
730
|
+
import { z as z6 } from "zod";
|
|
731
|
+
import { ActionSchema } from "@terrantula/types";
|
|
732
|
+
function createActionsClient(proj, projEnv) {
|
|
733
|
+
return {
|
|
734
|
+
list: withSchema(
|
|
735
|
+
z6.object({
|
|
736
|
+
projectId: z6.string().describe("Project ID")
|
|
737
|
+
}),
|
|
738
|
+
(params) => call(proj(params.projectId)["actions"].$get())
|
|
739
|
+
),
|
|
740
|
+
get: withSchema(
|
|
741
|
+
z6.object({
|
|
742
|
+
projectId: z6.string().describe("Project ID"),
|
|
743
|
+
name: z6.string().describe("Action name")
|
|
744
|
+
}),
|
|
745
|
+
(params) => call(proj(params.projectId)["actions"][":name"].$get({ param: { name: params.name } }))
|
|
746
|
+
),
|
|
747
|
+
create: withSchema(
|
|
748
|
+
ActionSchema.extend({ projectId: z6.string().describe("Project ID") }),
|
|
749
|
+
(params) => {
|
|
750
|
+
const { projectId, ...body } = params;
|
|
751
|
+
return call(proj(projectId)["actions"].$post({ json: body }));
|
|
752
|
+
}
|
|
753
|
+
),
|
|
754
|
+
update: withSchema(
|
|
755
|
+
ActionSchema.extend({ projectId: z6.string().describe("Project ID") }),
|
|
756
|
+
(params) => {
|
|
757
|
+
const { projectId, ...body } = params;
|
|
758
|
+
return call(
|
|
759
|
+
proj(projectId)["actions"][":name"].$put({ param: { name: params.name }, json: body })
|
|
760
|
+
);
|
|
761
|
+
}
|
|
762
|
+
),
|
|
763
|
+
delete: withSchema(
|
|
764
|
+
z6.object({
|
|
765
|
+
projectId: z6.string().describe("Project ID"),
|
|
766
|
+
name: z6.string().describe("Action name")
|
|
767
|
+
}),
|
|
768
|
+
(params) => call(
|
|
769
|
+
proj(params.projectId)["actions"][":name"].$delete({ param: { name: params.name } })
|
|
770
|
+
)
|
|
771
|
+
),
|
|
772
|
+
run: withSchema(
|
|
773
|
+
z6.object({
|
|
774
|
+
projectId: z6.string().describe("Project ID"),
|
|
775
|
+
envName: z6.string().describe("Environment name"),
|
|
776
|
+
actionName: z6.string().describe("Action name"),
|
|
777
|
+
parameters: z6.record(z6.unknown()).optional().describe("Action parameters as JSON"),
|
|
778
|
+
recommendations: z6.record(z6.string()).optional().describe("Recommendation selections as JSON")
|
|
779
|
+
}),
|
|
780
|
+
(params) => {
|
|
781
|
+
const { projectId, envName, actionName, parameters, recommendations } = params;
|
|
782
|
+
return call(
|
|
783
|
+
projEnv(projectId, envName)["actions"][":name"]["run"].$post({
|
|
784
|
+
param: { name: actionName },
|
|
785
|
+
json: { parameters, recommendations }
|
|
786
|
+
})
|
|
787
|
+
);
|
|
788
|
+
}
|
|
789
|
+
)
|
|
790
|
+
};
|
|
791
|
+
}
|
|
792
|
+
function createActionRunsClient(projEnv) {
|
|
793
|
+
return {
|
|
794
|
+
list: withSchema(
|
|
795
|
+
z6.object({
|
|
796
|
+
projectId: z6.string().describe("Project ID"),
|
|
797
|
+
envName: z6.string().describe("Environment name"),
|
|
798
|
+
actionName: z6.string().optional().describe("Filter by action name"),
|
|
799
|
+
entityId: z6.string().uuid().optional().describe("Filter by entity ID"),
|
|
800
|
+
status: z6.enum(["pending", "running", "succeeded", "failed", "cancelled"]).optional().describe("Filter by status"),
|
|
801
|
+
limit: z6.coerce.number().int().min(1).max(100).optional().describe("Max results (1-100)")
|
|
802
|
+
}),
|
|
803
|
+
(params) => {
|
|
804
|
+
const { projectId, envName, ...query } = params;
|
|
805
|
+
return call(
|
|
806
|
+
projEnv(projectId, envName)["action-runs"].$get({ query: stringifyQuery(query) })
|
|
807
|
+
);
|
|
808
|
+
}
|
|
809
|
+
),
|
|
810
|
+
get: withSchema(
|
|
811
|
+
z6.object({
|
|
812
|
+
projectId: z6.string().describe("Project ID"),
|
|
813
|
+
envName: z6.string().describe("Environment name"),
|
|
814
|
+
id: z6.string().uuid().describe("Action run ID")
|
|
815
|
+
}),
|
|
816
|
+
(params) => call(
|
|
817
|
+
projEnv(params.projectId, params.envName)["action-runs"][":id"].$get({ param: { id: params.id } })
|
|
818
|
+
)
|
|
819
|
+
),
|
|
820
|
+
cancel: withSchema(
|
|
821
|
+
z6.object({
|
|
822
|
+
projectId: z6.string().describe("Project ID"),
|
|
823
|
+
envName: z6.string().describe("Environment name"),
|
|
824
|
+
id: z6.string().uuid().describe("Action run ID")
|
|
825
|
+
}),
|
|
826
|
+
(params) => call(
|
|
827
|
+
projEnv(params.projectId, params.envName)["action-runs"][":id"].$delete({ param: { id: params.id } })
|
|
828
|
+
)
|
|
829
|
+
)
|
|
830
|
+
};
|
|
831
|
+
}
|
|
832
|
+
|
|
833
|
+
// src/secrets.ts
|
|
834
|
+
import { z as z7 } from "zod";
|
|
835
|
+
import { ApplyRequestSchema } from "@terrantula/types";
|
|
836
|
+
function createSecretsClient(projEnv) {
|
|
837
|
+
return {
|
|
838
|
+
list: withSchema(
|
|
839
|
+
z7.object({
|
|
840
|
+
projectId: z7.string().describe("Project ID"),
|
|
841
|
+
envName: z7.string().describe("Environment name")
|
|
842
|
+
}),
|
|
843
|
+
(params) => call(projEnv(params.projectId, params.envName)["secrets"].$get())
|
|
844
|
+
),
|
|
845
|
+
get: withSchema(
|
|
846
|
+
z7.object({
|
|
847
|
+
projectId: z7.string().describe("Project ID"),
|
|
848
|
+
envName: z7.string().describe("Environment name"),
|
|
849
|
+
name: z7.string().describe("Secret name")
|
|
850
|
+
}),
|
|
851
|
+
(params) => call(
|
|
852
|
+
projEnv(params.projectId, params.envName)["secrets"][":name"].$get({ param: { name: params.name } })
|
|
853
|
+
)
|
|
854
|
+
),
|
|
855
|
+
create: withSchema(
|
|
856
|
+
z7.object({
|
|
857
|
+
projectId: z7.string().describe("Project ID"),
|
|
858
|
+
envName: z7.string().describe("Environment name"),
|
|
859
|
+
name: z7.string().describe("Secret name"),
|
|
860
|
+
description: z7.string().optional().describe("Description")
|
|
861
|
+
}),
|
|
862
|
+
(params) => {
|
|
863
|
+
const { projectId, envName, name, description } = params;
|
|
864
|
+
return call(
|
|
865
|
+
projEnv(projectId, envName)["secrets"].$post({ json: { kind: "Secret", name, description } })
|
|
866
|
+
);
|
|
867
|
+
}
|
|
868
|
+
),
|
|
869
|
+
delete: withSchema(
|
|
870
|
+
z7.object({
|
|
871
|
+
projectId: z7.string().describe("Project ID"),
|
|
872
|
+
envName: z7.string().describe("Environment name"),
|
|
873
|
+
name: z7.string().describe("Secret name")
|
|
874
|
+
}),
|
|
875
|
+
(params) => call(
|
|
876
|
+
projEnv(params.projectId, params.envName)["secrets"][":name"].$delete({ param: { name: params.name } })
|
|
877
|
+
)
|
|
878
|
+
),
|
|
879
|
+
setValue: withSchema(
|
|
880
|
+
z7.object({
|
|
881
|
+
projectId: z7.string().describe("Project ID"),
|
|
882
|
+
envName: z7.string().describe("Environment name"),
|
|
883
|
+
name: z7.string().describe("Secret name"),
|
|
884
|
+
value: z7.string().min(1).describe("Secret value")
|
|
885
|
+
}),
|
|
886
|
+
(params) => {
|
|
887
|
+
const { projectId, envName, name, value } = params;
|
|
888
|
+
return call(
|
|
889
|
+
projEnv(projectId, envName)["secrets"][":name"]["value"].$put({
|
|
890
|
+
param: { name },
|
|
891
|
+
json: { value }
|
|
892
|
+
})
|
|
893
|
+
);
|
|
894
|
+
}
|
|
895
|
+
)
|
|
896
|
+
};
|
|
897
|
+
}
|
|
898
|
+
function createApplyClient(projEnv) {
|
|
899
|
+
return withSchema(
|
|
900
|
+
ApplyRequestSchema.extend({
|
|
901
|
+
projectId: z7.string().describe("Project ID"),
|
|
902
|
+
envName: z7.string().describe("Environment name")
|
|
903
|
+
}),
|
|
904
|
+
(params) => {
|
|
905
|
+
const { projectId, envName, ...body } = params;
|
|
906
|
+
return call(projEnv(projectId, envName)["apply"].$post({ json: body }));
|
|
907
|
+
}
|
|
908
|
+
);
|
|
909
|
+
}
|
|
910
|
+
|
|
911
|
+
// src/github.ts
|
|
912
|
+
import { z as z8 } from "zod";
|
|
913
|
+
function createGithubClient(cloud, _baseUrl, _hcOpts) {
|
|
914
|
+
return {
|
|
915
|
+
connect: withSchema(
|
|
916
|
+
z8.object({
|
|
917
|
+
projectId: z8.string().describe("Project ID")
|
|
918
|
+
}),
|
|
919
|
+
(params) => call(cloud.api.github["install-url"].$post({ json: params }))
|
|
920
|
+
),
|
|
921
|
+
installations: {
|
|
922
|
+
list: withSchema(
|
|
923
|
+
z8.object({
|
|
924
|
+
orgId: z8.string().describe("Organization ID")
|
|
925
|
+
}),
|
|
926
|
+
(params) => call(cloud.api.github.installations.$get({ query: params }))
|
|
927
|
+
),
|
|
928
|
+
repos: withSchema(
|
|
929
|
+
z8.object({
|
|
930
|
+
installationId: z8.string().describe("Installation row ID")
|
|
931
|
+
}),
|
|
932
|
+
(params) => call(
|
|
933
|
+
cloud.api.github.installations[":installationId"].repos.$get({
|
|
934
|
+
param: params
|
|
935
|
+
})
|
|
936
|
+
)
|
|
937
|
+
),
|
|
938
|
+
disconnect: withSchema(
|
|
939
|
+
z8.object({
|
|
940
|
+
installationId: z8.string().describe("Installation row ID")
|
|
941
|
+
}),
|
|
942
|
+
(params) => call(
|
|
943
|
+
cloud.api.github.installations[":installationId"].$delete({
|
|
944
|
+
param: params
|
|
945
|
+
})
|
|
946
|
+
)
|
|
947
|
+
),
|
|
948
|
+
recover: withSchema(
|
|
949
|
+
z8.object({
|
|
950
|
+
orgId: z8.string().describe("Organization ID"),
|
|
951
|
+
installationId: z8.number().int().positive().describe("GitHub installation ID (from the GitHub install URL)")
|
|
952
|
+
}),
|
|
953
|
+
(params) => call(cloud.api.github.installations.recover.$post({ json: params }))
|
|
954
|
+
)
|
|
955
|
+
},
|
|
956
|
+
projects: {
|
|
957
|
+
linkRepo: withSchema(
|
|
958
|
+
z8.object({
|
|
959
|
+
orgId: z8.string().describe("Organization ID"),
|
|
960
|
+
projectId: z8.string().describe("Project ID"),
|
|
961
|
+
installationId: z8.string().describe("Installation row ID"),
|
|
962
|
+
owner: z8.string().describe("GitHub repo owner"),
|
|
963
|
+
name: z8.string().describe("GitHub repo name")
|
|
964
|
+
}),
|
|
965
|
+
(params) => {
|
|
966
|
+
const { orgId, projectId, ...body } = params;
|
|
967
|
+
return call(
|
|
968
|
+
cloud.orgs[":orgId"].projects[":projectId"]["github-repos"].$post({
|
|
969
|
+
param: { orgId, projectId },
|
|
970
|
+
json: body
|
|
971
|
+
})
|
|
972
|
+
);
|
|
973
|
+
}
|
|
974
|
+
),
|
|
975
|
+
unlinkRepo: withSchema(
|
|
976
|
+
z8.object({
|
|
977
|
+
orgId: z8.string().describe("Organization ID"),
|
|
978
|
+
projectId: z8.string().describe("Project ID"),
|
|
979
|
+
owner: z8.string().describe("GitHub repo owner"),
|
|
980
|
+
name: z8.string().describe("GitHub repo name")
|
|
981
|
+
}),
|
|
982
|
+
(params) => call(
|
|
983
|
+
cloud.orgs[":orgId"].projects[":projectId"]["github-repos"][":owner"][":name"].$delete({
|
|
984
|
+
param: params
|
|
985
|
+
})
|
|
986
|
+
)
|
|
987
|
+
)
|
|
988
|
+
}
|
|
989
|
+
};
|
|
990
|
+
}
|
|
991
|
+
|
|
992
|
+
// src/export.ts
|
|
993
|
+
import { z as z9 } from "zod";
|
|
994
|
+
var SERVER_FIELDS = /* @__PURE__ */ new Set(["id", "projectId", "envId", "createdAt", "updatedAt"]);
|
|
995
|
+
function stripServerFields(row) {
|
|
996
|
+
const out = {};
|
|
997
|
+
for (const [key, value] of Object.entries(row)) {
|
|
998
|
+
if (!SERVER_FIELDS.has(key)) out[key] = value;
|
|
999
|
+
}
|
|
1000
|
+
return out;
|
|
1001
|
+
}
|
|
1002
|
+
function createExportCatalogFn(proj, projEnv) {
|
|
1003
|
+
return withSchema(
|
|
1004
|
+
z9.object({
|
|
1005
|
+
projectId: z9.string().describe("Project ID"),
|
|
1006
|
+
envName: z9.string().describe("Environment name to export secret declarations from")
|
|
1007
|
+
}).describe("Export every catalog kind as a single apply-shaped payload"),
|
|
1008
|
+
async (params) => {
|
|
1009
|
+
const projClient = proj(params.projectId);
|
|
1010
|
+
const envClient = projEnv(params.projectId, params.envName);
|
|
1011
|
+
const [entityTypes, cells, relationshipTypes, actions, secrets] = await Promise.all([
|
|
1012
|
+
call(projClient["entity-types"].$get()),
|
|
1013
|
+
call(projClient["cells"].$get()),
|
|
1014
|
+
call(projClient["relationship-types"].$get()),
|
|
1015
|
+
call(projClient["actions"].$get()),
|
|
1016
|
+
call(envClient["secrets"].$get())
|
|
1017
|
+
]);
|
|
1018
|
+
const items = [
|
|
1019
|
+
...entityTypes.map(
|
|
1020
|
+
(r) => ({ kind: "EntityType", ...stripServerFields(r) })
|
|
1021
|
+
),
|
|
1022
|
+
...cells.map(
|
|
1023
|
+
(r) => ({ kind: "Cell", ...stripServerFields(r) })
|
|
1024
|
+
),
|
|
1025
|
+
...relationshipTypes.map(
|
|
1026
|
+
(r) => ({ kind: "RelationshipType", ...stripServerFields(r) })
|
|
1027
|
+
),
|
|
1028
|
+
...actions.map(
|
|
1029
|
+
(r) => ({ kind: "Action", ...stripServerFields(r) })
|
|
1030
|
+
),
|
|
1031
|
+
...secrets.map(
|
|
1032
|
+
(r) => ({ kind: "Secret", ...stripServerFields(r) })
|
|
1033
|
+
)
|
|
1034
|
+
];
|
|
1035
|
+
return { items };
|
|
1036
|
+
}
|
|
1037
|
+
);
|
|
1038
|
+
}
|
|
1039
|
+
|
|
1040
|
+
// src/catalog-revisions.ts
|
|
1041
|
+
import { z as z10 } from "zod";
|
|
1042
|
+
function createCatalogRevisionsClient(proj) {
|
|
1043
|
+
return {
|
|
1044
|
+
list: withSchema(
|
|
1045
|
+
z10.object({
|
|
1046
|
+
projectId: z10.string().describe("Project ID"),
|
|
1047
|
+
limit: z10.coerce.number().int().min(1).max(200).optional().describe("Max revisions to return (1-200)")
|
|
1048
|
+
}),
|
|
1049
|
+
(params) => {
|
|
1050
|
+
const { projectId, ...query } = params;
|
|
1051
|
+
return call(
|
|
1052
|
+
proj(projectId)["catalog-revisions"].$get({ query: stringifyQuery(query) })
|
|
1053
|
+
);
|
|
1054
|
+
}
|
|
1055
|
+
),
|
|
1056
|
+
get: withSchema(
|
|
1057
|
+
z10.object({
|
|
1058
|
+
projectId: z10.string().describe("Project ID"),
|
|
1059
|
+
id: z10.string().uuid().describe("Revision ID")
|
|
1060
|
+
}),
|
|
1061
|
+
(params) => call(
|
|
1062
|
+
proj(params.projectId)["catalog-revisions"][":id"].$get({ param: { id: params.id } })
|
|
1063
|
+
)
|
|
1064
|
+
),
|
|
1065
|
+
snapshots: withSchema(
|
|
1066
|
+
z10.object({
|
|
1067
|
+
projectId: z10.string().describe("Project ID"),
|
|
1068
|
+
id: z10.string().uuid().describe("Revision ID to read snapshots for")
|
|
1069
|
+
}),
|
|
1070
|
+
(params) => call(
|
|
1071
|
+
proj(params.projectId)["catalog-revisions"][":id"]["snapshots"].$get({
|
|
1072
|
+
param: { id: params.id }
|
|
1073
|
+
})
|
|
1074
|
+
)
|
|
1075
|
+
),
|
|
1076
|
+
/**
|
|
1077
|
+
* Roll back to a previous revision. Optionally filtered to a single hunk
|
|
1078
|
+
* via `hunkId`. Destructive rollbacks (e.g. reverting a create) require
|
|
1079
|
+
* `force: true`, mirroring POST /apply.
|
|
1080
|
+
*/
|
|
1081
|
+
rollback: withSchema(
|
|
1082
|
+
z10.object({
|
|
1083
|
+
projectId: z10.string().describe("Project ID"),
|
|
1084
|
+
id: z10.string().uuid().describe("Revision ID to roll back to"),
|
|
1085
|
+
hunkId: z10.string().uuid().optional().describe("Single-hunk filter"),
|
|
1086
|
+
force: z10.boolean().optional().describe("Required if the inverse diff is destructive")
|
|
1087
|
+
}),
|
|
1088
|
+
(params) => {
|
|
1089
|
+
const { projectId, id, hunkId, force } = params;
|
|
1090
|
+
return call(
|
|
1091
|
+
proj(projectId)["catalog-revisions"][":id"]["rollback"].$post({
|
|
1092
|
+
param: { id },
|
|
1093
|
+
json: { force: force ?? false },
|
|
1094
|
+
query: hunkId ? stringifyQuery({ hunkId }) : void 0
|
|
1095
|
+
})
|
|
1096
|
+
);
|
|
1097
|
+
}
|
|
1098
|
+
)
|
|
1099
|
+
};
|
|
1100
|
+
}
|
|
1101
|
+
|
|
1102
|
+
// src/audit-events.ts
|
|
1103
|
+
import { z as z11 } from "zod";
|
|
1104
|
+
function createAuditEventsClient(proj) {
|
|
1105
|
+
return {
|
|
1106
|
+
list: withSchema(
|
|
1107
|
+
z11.object({
|
|
1108
|
+
projectId: z11.string().describe("Project ID"),
|
|
1109
|
+
envName: z11.string().optional().describe("Filter to a single env"),
|
|
1110
|
+
actorType: z11.enum(["user", "token"]).optional().describe("Filter by actor type"),
|
|
1111
|
+
actorId: z11.string().optional().describe("Filter by actor (user.id or apikey.id)"),
|
|
1112
|
+
action: z11.string().optional().describe('Comma-separated actions (e.g. "create,delete")'),
|
|
1113
|
+
resourceKind: z11.string().optional().describe("Filter to one resource kind (Entity | Token | Member | \u2026)"),
|
|
1114
|
+
since: z11.string().datetime().optional().describe("ISO timestamp; only events strictly after this are returned"),
|
|
1115
|
+
limit: z11.coerce.number().int().min(1).max(500).optional().describe("Max rows (1-500)")
|
|
1116
|
+
}).describe("List audit events for a project \u2014 auditor-friendly read-only feed"),
|
|
1117
|
+
(params) => {
|
|
1118
|
+
const { projectId, ...query } = params;
|
|
1119
|
+
return call(proj(projectId)["audit-events"].$get({ query: stringifyQuery(query) }));
|
|
1120
|
+
}
|
|
1121
|
+
)
|
|
1122
|
+
};
|
|
1123
|
+
}
|
|
1124
|
+
|
|
1125
|
+
// src/environments.ts
|
|
1126
|
+
import { z as z12 } from "zod";
|
|
1127
|
+
function createEnvironmentsClient(proj) {
|
|
1128
|
+
return {
|
|
1129
|
+
list: withSchema(
|
|
1130
|
+
z12.object({
|
|
1131
|
+
projectId: z12.string().describe("Project ID")
|
|
1132
|
+
}),
|
|
1133
|
+
(params) => call(proj(params.projectId)["environments"].$get())
|
|
1134
|
+
),
|
|
1135
|
+
create: withSchema(
|
|
1136
|
+
z12.object({
|
|
1137
|
+
projectId: z12.string().describe("Project ID"),
|
|
1138
|
+
name: z12.string().min(1).max(31).regex(/^[a-z0-9][a-z0-9-]{0,30}$/).describe("Environment name (lowercase letters, digits, hyphens; max 31 chars)")
|
|
1139
|
+
}),
|
|
1140
|
+
(params) => {
|
|
1141
|
+
const { projectId, name } = params;
|
|
1142
|
+
return call(proj(projectId)["environments"].$post({ json: { name } }));
|
|
1143
|
+
}
|
|
1144
|
+
),
|
|
1145
|
+
delete: withSchema(
|
|
1146
|
+
z12.object({
|
|
1147
|
+
projectId: z12.string().describe("Project ID"),
|
|
1148
|
+
name: z12.string().describe("Environment name")
|
|
1149
|
+
}),
|
|
1150
|
+
(params) => call(
|
|
1151
|
+
proj(params.projectId)["environments"][":envName"].$delete({
|
|
1152
|
+
param: { envName: params.name }
|
|
1153
|
+
})
|
|
1154
|
+
)
|
|
1155
|
+
)
|
|
1156
|
+
};
|
|
1157
|
+
}
|
|
1158
|
+
|
|
1159
|
+
// src/drift-events.ts
|
|
1160
|
+
import { z as z13 } from "zod";
|
|
1161
|
+
function createDriftEventsClient(projEnv) {
|
|
1162
|
+
return {
|
|
1163
|
+
list: withSchema(
|
|
1164
|
+
z13.object({
|
|
1165
|
+
projectId: z13.string().describe("Project ID"),
|
|
1166
|
+
envName: z13.string().describe("Environment name"),
|
|
1167
|
+
status: z13.enum(["open", "accepted", "reapplied", "snoozed"]).optional(),
|
|
1168
|
+
kind: z13.string().optional().describe("Filter by entity type name"),
|
|
1169
|
+
entityId: z13.string().uuid().optional(),
|
|
1170
|
+
since: z13.string().optional().describe("ISO timestamp lower bound on detectedAt"),
|
|
1171
|
+
limit: z13.coerce.number().int().min(1).max(500).optional()
|
|
1172
|
+
}),
|
|
1173
|
+
(params) => {
|
|
1174
|
+
const { projectId, envName, ...query } = params;
|
|
1175
|
+
return call(
|
|
1176
|
+
projEnv(projectId, envName)["drift-events"].$get({ query: stringifyQuery(query) })
|
|
1177
|
+
);
|
|
1178
|
+
}
|
|
1179
|
+
),
|
|
1180
|
+
count: withSchema(
|
|
1181
|
+
z13.object({ projectId: z13.string(), envName: z13.string() }),
|
|
1182
|
+
(params) => call(projEnv(params.projectId, params.envName)["drift-events"].count.$get())
|
|
1183
|
+
),
|
|
1184
|
+
get: withSchema(
|
|
1185
|
+
z13.object({
|
|
1186
|
+
projectId: z13.string(),
|
|
1187
|
+
envName: z13.string(),
|
|
1188
|
+
id: z13.string().uuid()
|
|
1189
|
+
}),
|
|
1190
|
+
(params) => call(
|
|
1191
|
+
projEnv(params.projectId, params.envName)["drift-events"][":id"].$get({
|
|
1192
|
+
param: { id: params.id }
|
|
1193
|
+
})
|
|
1194
|
+
)
|
|
1195
|
+
),
|
|
1196
|
+
accept: withSchema(
|
|
1197
|
+
z13.object({
|
|
1198
|
+
projectId: z13.string(),
|
|
1199
|
+
envName: z13.string(),
|
|
1200
|
+
id: z13.string().uuid()
|
|
1201
|
+
}),
|
|
1202
|
+
(params) => call(
|
|
1203
|
+
projEnv(params.projectId, params.envName)["drift-events"][":id"].accept.$post({
|
|
1204
|
+
param: { id: params.id }
|
|
1205
|
+
})
|
|
1206
|
+
)
|
|
1207
|
+
),
|
|
1208
|
+
reapply: withSchema(
|
|
1209
|
+
z13.object({
|
|
1210
|
+
projectId: z13.string(),
|
|
1211
|
+
envName: z13.string(),
|
|
1212
|
+
id: z13.string().uuid()
|
|
1213
|
+
}),
|
|
1214
|
+
(params) => call(
|
|
1215
|
+
projEnv(params.projectId, params.envName)["drift-events"][":id"].reapply.$post({
|
|
1216
|
+
param: { id: params.id }
|
|
1217
|
+
})
|
|
1218
|
+
)
|
|
1219
|
+
),
|
|
1220
|
+
snooze: withSchema(
|
|
1221
|
+
z13.object({
|
|
1222
|
+
projectId: z13.string(),
|
|
1223
|
+
envName: z13.string(),
|
|
1224
|
+
id: z13.string().uuid(),
|
|
1225
|
+
untilSeconds: z13.number().int().positive().optional()
|
|
1226
|
+
}),
|
|
1227
|
+
(params) => call(
|
|
1228
|
+
projEnv(params.projectId, params.envName)["drift-events"][":id"].snooze.$post({
|
|
1229
|
+
param: { id: params.id },
|
|
1230
|
+
json: { untilSeconds: params.untilSeconds }
|
|
1231
|
+
})
|
|
1232
|
+
)
|
|
1233
|
+
)
|
|
1234
|
+
};
|
|
1235
|
+
}
|
|
1236
|
+
|
|
1237
|
+
// src/stats.ts
|
|
1238
|
+
import { z as z14 } from "zod";
|
|
1239
|
+
var WindowSchema = z14.enum(["1h", "24h", "7d"]).optional().describe("Time window \u2014 default 24h");
|
|
1240
|
+
var BucketSchema = z14.enum(["1m", "5m", "1h", "1d"]).optional().describe("Bucket granularity \u2014 default 1h");
|
|
1241
|
+
function createStatsClient(proj) {
|
|
1242
|
+
return {
|
|
1243
|
+
entitiesByState: withSchema(
|
|
1244
|
+
z14.object({
|
|
1245
|
+
projectId: z14.string().describe("Project ID"),
|
|
1246
|
+
window: WindowSchema,
|
|
1247
|
+
bucket: BucketSchema
|
|
1248
|
+
}),
|
|
1249
|
+
(params) => {
|
|
1250
|
+
const { projectId, ...query } = params;
|
|
1251
|
+
return call(proj(projectId)["stats"]["entities-by-state"].$get({ query: stringifyQuery(query) }));
|
|
1252
|
+
}
|
|
1253
|
+
),
|
|
1254
|
+
runsByType: withSchema(
|
|
1255
|
+
z14.object({
|
|
1256
|
+
projectId: z14.string().describe("Project ID"),
|
|
1257
|
+
window: WindowSchema
|
|
1258
|
+
}),
|
|
1259
|
+
(params) => {
|
|
1260
|
+
const { projectId, ...query } = params;
|
|
1261
|
+
return call(proj(projectId)["stats"]["runs-by-type"].$get({ query: stringifyQuery(query) }));
|
|
1262
|
+
}
|
|
1263
|
+
),
|
|
1264
|
+
failingKinds: withSchema(
|
|
1265
|
+
z14.object({
|
|
1266
|
+
projectId: z14.string().describe("Project ID"),
|
|
1267
|
+
window: WindowSchema
|
|
1268
|
+
}),
|
|
1269
|
+
(params) => {
|
|
1270
|
+
const { projectId, ...query } = params;
|
|
1271
|
+
return call(proj(projectId)["stats"]["failing-kinds"].$get({ query: stringifyQuery(query) }));
|
|
1272
|
+
}
|
|
1273
|
+
),
|
|
1274
|
+
driftDensity: withSchema(
|
|
1275
|
+
z14.object({
|
|
1276
|
+
projectId: z14.string().describe("Project ID"),
|
|
1277
|
+
dim: z14.string().optional().describe('Dimensions to bucket \u2014 e.g. "kind,cell"')
|
|
1278
|
+
}),
|
|
1279
|
+
(params) => {
|
|
1280
|
+
const { projectId, ...query } = params;
|
|
1281
|
+
return call(proj(projectId)["stats"]["drift-density"].$get({ query: stringifyQuery(query) }));
|
|
1282
|
+
}
|
|
1283
|
+
)
|
|
1284
|
+
};
|
|
1285
|
+
}
|
|
1286
|
+
|
|
1287
|
+
// src/notifications.ts
|
|
1288
|
+
import { z as z15 } from "zod";
|
|
1289
|
+
import { hc as hc2 } from "hono/client";
|
|
1290
|
+
function createNotificationsClient(baseUrl, hcOpts) {
|
|
1291
|
+
const c = hc2(`${baseUrl}/notifications`, hcOpts);
|
|
1292
|
+
return {
|
|
1293
|
+
list: withSchema(
|
|
1294
|
+
z15.object({
|
|
1295
|
+
limit: z15.coerce.number().int().min(1).max(100).optional(),
|
|
1296
|
+
unread: z15.boolean().optional()
|
|
1297
|
+
}),
|
|
1298
|
+
(params) => {
|
|
1299
|
+
const query = {};
|
|
1300
|
+
if (params.limit !== void 0) query.limit = String(params.limit);
|
|
1301
|
+
if (params.unread !== void 0) query.unread = String(params.unread);
|
|
1302
|
+
return call(c.index.$get({ query }));
|
|
1303
|
+
}
|
|
1304
|
+
),
|
|
1305
|
+
read: withSchema(
|
|
1306
|
+
z15.object({ id: z15.string().uuid() }),
|
|
1307
|
+
(params) => call(c[":id"].read.$post({ param: { id: params.id } }))
|
|
1308
|
+
),
|
|
1309
|
+
readAll: withSchema(
|
|
1310
|
+
z15.object({}),
|
|
1311
|
+
() => call(c["read-all"].$post())
|
|
1312
|
+
)
|
|
1313
|
+
};
|
|
1314
|
+
}
|
|
1315
|
+
|
|
1316
|
+
// src/audit-export.ts
|
|
1317
|
+
import { z as z16 } from "zod";
|
|
1318
|
+
async function rawRequest(baseUrl, hcOpts, path, init = {}) {
|
|
1319
|
+
const fetchImpl = hcOpts?.fetch ?? fetch;
|
|
1320
|
+
const rawHeaders = hcOpts?.headers;
|
|
1321
|
+
const resolvedHeaders = typeof rawHeaders === "function" ? await rawHeaders() : rawHeaders ?? {};
|
|
1322
|
+
return fetchImpl(`${baseUrl}${path}`, {
|
|
1323
|
+
...init,
|
|
1324
|
+
headers: {
|
|
1325
|
+
...resolvedHeaders,
|
|
1326
|
+
...init.headers
|
|
1327
|
+
}
|
|
1328
|
+
});
|
|
1329
|
+
}
|
|
1330
|
+
async function callRaw(res) {
|
|
1331
|
+
if (!res.ok) {
|
|
1332
|
+
let message = fallbackMessage(res.status);
|
|
1333
|
+
try {
|
|
1334
|
+
const body = await res.json();
|
|
1335
|
+
if (body.error) message = body.error;
|
|
1336
|
+
} catch {
|
|
1337
|
+
}
|
|
1338
|
+
throw new TerrantulaError(res.status, { error: message });
|
|
1339
|
+
}
|
|
1340
|
+
return res.json();
|
|
1341
|
+
}
|
|
1342
|
+
function createAuditExportClient(baseUrl, hcOpts) {
|
|
1343
|
+
return {
|
|
1344
|
+
/** GET /orgs/:orgId/audit-export/config — returns current config or throws 404. */
|
|
1345
|
+
getConfig: withSchema(
|
|
1346
|
+
z16.object({ orgId: z16.string().describe("Organization ID") }),
|
|
1347
|
+
async (params) => callRaw(
|
|
1348
|
+
await rawRequest(baseUrl, hcOpts, `/orgs/${params.orgId}/audit-export/config`)
|
|
1349
|
+
)
|
|
1350
|
+
),
|
|
1351
|
+
/** POST /orgs/:orgId/audit-export/config — upsert the S3 export config. */
|
|
1352
|
+
setConfig: withSchema(
|
|
1353
|
+
z16.object({
|
|
1354
|
+
orgId: z16.string().describe("Organization ID"),
|
|
1355
|
+
bucket: z16.string().describe("S3 bucket name"),
|
|
1356
|
+
region: z16.string().describe("AWS region"),
|
|
1357
|
+
roleArn: z16.string().describe("IAM role ARN for assume-role"),
|
|
1358
|
+
enabled: z16.boolean().optional().describe("Enable/disable export")
|
|
1359
|
+
}),
|
|
1360
|
+
async (params) => {
|
|
1361
|
+
const { orgId, ...body } = params;
|
|
1362
|
+
return callRaw(
|
|
1363
|
+
await rawRequest(baseUrl, hcOpts, `/orgs/${orgId}/audit-export/config`, {
|
|
1364
|
+
method: "POST",
|
|
1365
|
+
headers: { "Content-Type": "application/json" },
|
|
1366
|
+
body: JSON.stringify(body)
|
|
1367
|
+
})
|
|
1368
|
+
);
|
|
1369
|
+
}
|
|
1370
|
+
),
|
|
1371
|
+
/** POST /orgs/:orgId/audit-export/test-connection — dry-run write+delete. */
|
|
1372
|
+
testConnection: withSchema(
|
|
1373
|
+
z16.object({
|
|
1374
|
+
orgId: z16.string().describe("Organization ID"),
|
|
1375
|
+
bucket: z16.string().describe("S3 bucket name"),
|
|
1376
|
+
region: z16.string().describe("AWS region"),
|
|
1377
|
+
roleArn: z16.string().describe("IAM role ARN for assume-role")
|
|
1378
|
+
}),
|
|
1379
|
+
async (params) => {
|
|
1380
|
+
const { orgId, ...body } = params;
|
|
1381
|
+
return callRaw(
|
|
1382
|
+
await rawRequest(baseUrl, hcOpts, `/orgs/${orgId}/audit-export/test-connection`, {
|
|
1383
|
+
method: "POST",
|
|
1384
|
+
headers: { "Content-Type": "application/json" },
|
|
1385
|
+
body: JSON.stringify(body)
|
|
1386
|
+
})
|
|
1387
|
+
);
|
|
1388
|
+
}
|
|
1389
|
+
),
|
|
1390
|
+
/** GET /orgs/:orgId/audit-export/runs — recent batch run history. */
|
|
1391
|
+
listRuns: withSchema(
|
|
1392
|
+
z16.object({
|
|
1393
|
+
orgId: z16.string().describe("Organization ID"),
|
|
1394
|
+
limit: z16.number().optional().describe("Max results (default 20, max 100)")
|
|
1395
|
+
}),
|
|
1396
|
+
async (params) => {
|
|
1397
|
+
const qs = params.limit ? `?limit=${params.limit}` : "";
|
|
1398
|
+
return callRaw(
|
|
1399
|
+
await rawRequest(
|
|
1400
|
+
baseUrl,
|
|
1401
|
+
hcOpts,
|
|
1402
|
+
`/orgs/${params.orgId}/audit-export/runs${qs}`
|
|
1403
|
+
)
|
|
1404
|
+
);
|
|
1405
|
+
}
|
|
1406
|
+
)
|
|
1407
|
+
};
|
|
1408
|
+
}
|
|
1409
|
+
|
|
1410
|
+
// src/user-preferences.ts
|
|
1411
|
+
import { hc as hc3 } from "hono/client";
|
|
1412
|
+
function createUserPreferencesClient(baseUrl, hcOpts) {
|
|
1413
|
+
const c = hc3(
|
|
1414
|
+
`${baseUrl}/user/preferences`,
|
|
1415
|
+
hcOpts
|
|
1416
|
+
);
|
|
1417
|
+
return {
|
|
1418
|
+
get: (key) => call(c[":key"].$get({ param: { key } })),
|
|
1419
|
+
set: (key, value) => call(
|
|
1420
|
+
c[":key"].$put({
|
|
1421
|
+
param: { key },
|
|
1422
|
+
json: { value }
|
|
1423
|
+
})
|
|
1424
|
+
),
|
|
1425
|
+
delete: (key) => call(c[":key"].$delete({ param: { key } }))
|
|
1426
|
+
};
|
|
1427
|
+
}
|
|
1428
|
+
|
|
1429
|
+
// src/index.ts
|
|
1430
|
+
var createClient = (baseUrl, options = {}) => {
|
|
1431
|
+
const opts = typeof options === "string" || typeof options === "function" ? { token: options } : options;
|
|
1432
|
+
const headers = buildHeaders(opts.token);
|
|
1433
|
+
const fetchImpl = opts.fetch;
|
|
1434
|
+
const hcOpts = fetchImpl ? { headers, fetch: fetchImpl } : { headers };
|
|
1435
|
+
const cloud = hc4(baseUrl, hcOpts);
|
|
1436
|
+
const proj = (projectId) => hc4(`${baseUrl}/projects/${projectId}`, hcOpts);
|
|
1437
|
+
const projEnv = (projectId, envName) => hc4(`${baseUrl}/projects/${projectId}/envs/${envName}`, hcOpts);
|
|
1438
|
+
const cells = createCellsClient(proj);
|
|
1439
|
+
const catalogRevisions = createCatalogRevisionsClient(proj);
|
|
1440
|
+
const exportCatalog = createExportCatalogFn(proj, projEnv);
|
|
1441
|
+
const client = {
|
|
1442
|
+
orgs: createOrgsClient(cloud, baseUrl, hcOpts),
|
|
1443
|
+
projects: createProjectsClient(cloud, baseUrl, hcOpts),
|
|
1444
|
+
github: createGithubClient(cloud, baseUrl, hcOpts),
|
|
1445
|
+
environments: createEnvironmentsClient(proj),
|
|
1446
|
+
entityTypes: createEntityTypesClient(proj),
|
|
1447
|
+
entities: createEntitiesClient(projEnv),
|
|
1448
|
+
cells,
|
|
1449
|
+
relationshipTypes: createRelationshipTypesClient(proj),
|
|
1450
|
+
relationships: createRelationshipsClient(projEnv),
|
|
1451
|
+
actions: createActionsClient(proj, projEnv),
|
|
1452
|
+
actionRuns: createActionRunsClient(projEnv),
|
|
1453
|
+
secrets: createSecretsClient(projEnv),
|
|
1454
|
+
apply: createApplyClient(projEnv),
|
|
1455
|
+
catalogRevisions,
|
|
1456
|
+
auditEvents: createAuditEventsClient(proj),
|
|
1457
|
+
driftEvents: createDriftEventsClient(projEnv),
|
|
1458
|
+
stats: createStatsClient(proj),
|
|
1459
|
+
notifications: createNotificationsClient(baseUrl, hcOpts),
|
|
1460
|
+
auditExport: createAuditExportClient(baseUrl, hcOpts),
|
|
1461
|
+
userPreferences: createUserPreferencesClient(baseUrl, hcOpts),
|
|
1462
|
+
exportCatalog
|
|
1463
|
+
};
|
|
1464
|
+
let warnedPools = false;
|
|
1465
|
+
let warnedApplyRevisions = false;
|
|
1466
|
+
let warnedExportSchema = false;
|
|
1467
|
+
Object.defineProperty(client, "pools", {
|
|
1468
|
+
enumerable: false,
|
|
1469
|
+
configurable: true,
|
|
1470
|
+
get() {
|
|
1471
|
+
if (!warnedPools) {
|
|
1472
|
+
console.warn("[@terrantula/sdk] `client.pools` is deprecated \u2014 use `client.cells`. Will be removed next release.");
|
|
1473
|
+
warnedPools = true;
|
|
1474
|
+
}
|
|
1475
|
+
return cells;
|
|
1476
|
+
}
|
|
1477
|
+
});
|
|
1478
|
+
Object.defineProperty(client, "applyRevisions", {
|
|
1479
|
+
enumerable: false,
|
|
1480
|
+
configurable: true,
|
|
1481
|
+
get() {
|
|
1482
|
+
if (!warnedApplyRevisions) {
|
|
1483
|
+
console.warn("[@terrantula/sdk] `client.applyRevisions` is deprecated \u2014 use `client.catalogRevisions`. Will be removed next release.");
|
|
1484
|
+
warnedApplyRevisions = true;
|
|
1485
|
+
}
|
|
1486
|
+
return catalogRevisions;
|
|
1487
|
+
}
|
|
1488
|
+
});
|
|
1489
|
+
Object.defineProperty(client, "exportSchema", {
|
|
1490
|
+
enumerable: false,
|
|
1491
|
+
configurable: true,
|
|
1492
|
+
get() {
|
|
1493
|
+
if (!warnedExportSchema) {
|
|
1494
|
+
console.warn("[@terrantula/sdk] `client.exportSchema` is deprecated \u2014 use `client.exportCatalog`. Will be removed next release.");
|
|
1495
|
+
warnedExportSchema = true;
|
|
1496
|
+
}
|
|
1497
|
+
return exportCatalog;
|
|
1498
|
+
}
|
|
1499
|
+
});
|
|
1500
|
+
return client;
|
|
1501
|
+
};
|
|
1502
|
+
|
|
1503
|
+
export {
|
|
1504
|
+
TerrantulaError,
|
|
1505
|
+
withSchema,
|
|
1506
|
+
createClient
|
|
1507
|
+
};
|