aegis-platform-sdk 0.1.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/CHANGELOG.md +11 -0
- package/LICENSE +14 -0
- package/README.md +105 -0
- package/dist/index.cjs +719 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +497 -0
- package/dist/index.d.ts +497 -0
- package/dist/index.js +688 -0
- package/dist/index.js.map +1 -0
- package/package.json +53 -0
- package/skills/aegis-sdk/SKILL.md +88 -0
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,719 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var index_exports = {};
|
|
22
|
+
__export(index_exports, {
|
|
23
|
+
AegisAPIError: () => AegisAPIError,
|
|
24
|
+
AegisClient: () => AegisClient,
|
|
25
|
+
AuthError: () => AuthError,
|
|
26
|
+
NotFoundError: () => NotFoundError,
|
|
27
|
+
PermissionDeniedError: () => PermissionDeniedError
|
|
28
|
+
});
|
|
29
|
+
module.exports = __toCommonJS(index_exports);
|
|
30
|
+
|
|
31
|
+
// src/errors.ts
|
|
32
|
+
var AegisAPIError = class extends Error {
|
|
33
|
+
statusCode;
|
|
34
|
+
detail;
|
|
35
|
+
payload;
|
|
36
|
+
constructor(statusCode, detail = "", payload = null) {
|
|
37
|
+
super(`HTTP ${statusCode}: ${detail}`);
|
|
38
|
+
this.name = new.target.name;
|
|
39
|
+
this.statusCode = statusCode;
|
|
40
|
+
this.detail = detail;
|
|
41
|
+
this.payload = payload;
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
var AuthError = class extends AegisAPIError {
|
|
45
|
+
};
|
|
46
|
+
var PermissionDeniedError = class extends AegisAPIError {
|
|
47
|
+
};
|
|
48
|
+
var NotFoundError = class extends AegisAPIError {
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
// src/transport.ts
|
|
52
|
+
function buildUrl(baseUrl, path, params) {
|
|
53
|
+
const url = new URL(baseUrl.replace(/\/+$/, "") + path);
|
|
54
|
+
if (params) {
|
|
55
|
+
for (const [key, value] of Object.entries(params)) {
|
|
56
|
+
if (value !== void 0 && value !== null) url.searchParams.set(key, String(value));
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return url.toString();
|
|
60
|
+
}
|
|
61
|
+
async function handleResponse(res) {
|
|
62
|
+
if (res.status === 204) return null;
|
|
63
|
+
const text = await res.text();
|
|
64
|
+
let payload = text;
|
|
65
|
+
try {
|
|
66
|
+
payload = text ? JSON.parse(text) : null;
|
|
67
|
+
} catch {
|
|
68
|
+
}
|
|
69
|
+
if (res.ok) return payload;
|
|
70
|
+
let detail = "";
|
|
71
|
+
if (payload && typeof payload === "object" && "detail" in payload) {
|
|
72
|
+
detail = String(payload.detail ?? "");
|
|
73
|
+
} else if (typeof payload === "string") {
|
|
74
|
+
detail = payload;
|
|
75
|
+
}
|
|
76
|
+
if (res.status === 401) throw new AuthError(401, detail || "unauthenticated", payload);
|
|
77
|
+
if (res.status === 403) throw new PermissionDeniedError(403, detail || "forbidden", payload);
|
|
78
|
+
if (res.status === 404) throw new NotFoundError(404, detail || "not found", payload);
|
|
79
|
+
throw new AegisAPIError(res.status, detail || text, payload);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// src/resources/auth.ts
|
|
83
|
+
var AuthResource = class {
|
|
84
|
+
constructor(t, setToken) {
|
|
85
|
+
this.t = t;
|
|
86
|
+
this.setToken = setToken;
|
|
87
|
+
}
|
|
88
|
+
t;
|
|
89
|
+
setToken;
|
|
90
|
+
async login(username, password, opts = {}) {
|
|
91
|
+
const body = { username, password };
|
|
92
|
+
if (opts.totpCode) body.totp_code = opts.totpCode;
|
|
93
|
+
const pair = await this.t.request("POST", "/auth/login", { json: body });
|
|
94
|
+
if (opts.attach !== false) this.setToken(pair.access_token);
|
|
95
|
+
return pair;
|
|
96
|
+
}
|
|
97
|
+
me() {
|
|
98
|
+
return this.t.request("GET", "/auth/me");
|
|
99
|
+
}
|
|
100
|
+
/** Activate a vendor dev-mode session; requires the `vendor` role. */
|
|
101
|
+
enableDevMode(password) {
|
|
102
|
+
return this.t.request("POST", "/me/dev-mode", { json: { password } });
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
// src/resources/iam.ts
|
|
107
|
+
var UsersResource = class {
|
|
108
|
+
constructor(t) {
|
|
109
|
+
this.t = t;
|
|
110
|
+
}
|
|
111
|
+
t;
|
|
112
|
+
list() {
|
|
113
|
+
return this.t.request("GET", "/iam/users");
|
|
114
|
+
}
|
|
115
|
+
get(userId) {
|
|
116
|
+
return this.t.request("GET", `/iam/users/${userId}`);
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
var RolesResource = class {
|
|
120
|
+
constructor(t) {
|
|
121
|
+
this.t = t;
|
|
122
|
+
}
|
|
123
|
+
t;
|
|
124
|
+
list() {
|
|
125
|
+
return this.t.request("GET", "/iam/roles");
|
|
126
|
+
}
|
|
127
|
+
get(roleId) {
|
|
128
|
+
return this.t.request("GET", `/iam/roles/${roleId}`);
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
var GroupsResource = class {
|
|
132
|
+
constructor(t) {
|
|
133
|
+
this.t = t;
|
|
134
|
+
}
|
|
135
|
+
t;
|
|
136
|
+
list(opts = {}) {
|
|
137
|
+
return this.t.request("GET", "/iam/groups", { params: opts });
|
|
138
|
+
}
|
|
139
|
+
get(groupId) {
|
|
140
|
+
return this.t.request("GET", `/iam/groups/${groupId}`);
|
|
141
|
+
}
|
|
142
|
+
create(name, description) {
|
|
143
|
+
return this.t.request("POST", "/iam/groups", { json: { name, description } });
|
|
144
|
+
}
|
|
145
|
+
update(groupId, patch) {
|
|
146
|
+
return this.t.request("PATCH", `/iam/groups/${groupId}`, { json: patch });
|
|
147
|
+
}
|
|
148
|
+
delete(groupId) {
|
|
149
|
+
return this.t.request("DELETE", `/iam/groups/${groupId}`);
|
|
150
|
+
}
|
|
151
|
+
listMembers(groupId) {
|
|
152
|
+
return this.t.request("GET", `/iam/groups/${groupId}/members`);
|
|
153
|
+
}
|
|
154
|
+
addMember(groupId, userId) {
|
|
155
|
+
return this.t.request("POST", `/iam/groups/${groupId}/members`, { json: { user_id: userId } });
|
|
156
|
+
}
|
|
157
|
+
removeMember(groupId, userId) {
|
|
158
|
+
return this.t.request("DELETE", `/iam/groups/${groupId}/members/${userId}`);
|
|
159
|
+
}
|
|
160
|
+
listForUser(userId) {
|
|
161
|
+
return this.t.request("GET", `/iam/users/${userId}/groups`);
|
|
162
|
+
}
|
|
163
|
+
};
|
|
164
|
+
var PermissionsResource = class {
|
|
165
|
+
constructor(t) {
|
|
166
|
+
this.t = t;
|
|
167
|
+
}
|
|
168
|
+
t;
|
|
169
|
+
list(resource) {
|
|
170
|
+
return this.t.request("GET", "/iam/permissions", { params: { resource } });
|
|
171
|
+
}
|
|
172
|
+
};
|
|
173
|
+
var NavResource = class {
|
|
174
|
+
constructor(t) {
|
|
175
|
+
this.t = t;
|
|
176
|
+
}
|
|
177
|
+
t;
|
|
178
|
+
tree(asRoleId) {
|
|
179
|
+
return this.t.request("GET", "/iam/nav", { params: { as_role_id: asRoleId } });
|
|
180
|
+
}
|
|
181
|
+
};
|
|
182
|
+
var IamResource = class {
|
|
183
|
+
users;
|
|
184
|
+
roles;
|
|
185
|
+
groups;
|
|
186
|
+
permissions;
|
|
187
|
+
nav;
|
|
188
|
+
constructor(t) {
|
|
189
|
+
this.users = new UsersResource(t);
|
|
190
|
+
this.roles = new RolesResource(t);
|
|
191
|
+
this.groups = new GroupsResource(t);
|
|
192
|
+
this.permissions = new PermissionsResource(t);
|
|
193
|
+
this.nav = new NavResource(t);
|
|
194
|
+
}
|
|
195
|
+
};
|
|
196
|
+
|
|
197
|
+
// src/resources/osdk.ts
|
|
198
|
+
var OsdkResource = class {
|
|
199
|
+
constructor(t) {
|
|
200
|
+
this.t = t;
|
|
201
|
+
}
|
|
202
|
+
t;
|
|
203
|
+
list() {
|
|
204
|
+
return this.t.request("GET", "/governance/tokens");
|
|
205
|
+
}
|
|
206
|
+
get(tokenId) {
|
|
207
|
+
return this.t.request("GET", `/governance/tokens/${tokenId}`);
|
|
208
|
+
}
|
|
209
|
+
/** Returns the plaintext secret ONCE — stash it like any other secret. */
|
|
210
|
+
create(name, scopes, expiresAt) {
|
|
211
|
+
return this.t.request("POST", "/governance/tokens", {
|
|
212
|
+
json: { name, scopes, expires_at: expiresAt }
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
rotate(tokenId) {
|
|
216
|
+
return this.t.request("POST", `/governance/tokens/${tokenId}/rotate`);
|
|
217
|
+
}
|
|
218
|
+
revoke(tokenId) {
|
|
219
|
+
return this.t.request("DELETE", `/governance/tokens/${tokenId}`);
|
|
220
|
+
}
|
|
221
|
+
};
|
|
222
|
+
|
|
223
|
+
// src/resources/operator.ts
|
|
224
|
+
var OperatorTasksResource = class {
|
|
225
|
+
constructor(t) {
|
|
226
|
+
this.t = t;
|
|
227
|
+
}
|
|
228
|
+
t;
|
|
229
|
+
list(opts = {}) {
|
|
230
|
+
return this.t.request("GET", "/operator/tasks", { params: { ...opts } });
|
|
231
|
+
}
|
|
232
|
+
get(taskId) {
|
|
233
|
+
return this.t.request("GET", `/operator/tasks/${taskId}`);
|
|
234
|
+
}
|
|
235
|
+
create(input) {
|
|
236
|
+
return this.t.request("POST", "/operator/tasks", { json: input });
|
|
237
|
+
}
|
|
238
|
+
cancel(taskId) {
|
|
239
|
+
return this.t.request("PATCH", `/operator/tasks/${taskId}`, { json: { action: "cancel" } });
|
|
240
|
+
}
|
|
241
|
+
retry(taskId) {
|
|
242
|
+
return this.t.request("PATCH", `/operator/tasks/${taskId}`, { json: { action: "retry" } });
|
|
243
|
+
}
|
|
244
|
+
reprioritize(taskId, priority) {
|
|
245
|
+
return this.t.request("PATCH", `/operator/tasks/${taskId}`, {
|
|
246
|
+
json: { action: "reprioritize", priority }
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
};
|
|
250
|
+
var OperatorResource = class {
|
|
251
|
+
tasks;
|
|
252
|
+
constructor(t) {
|
|
253
|
+
this.tasks = new OperatorTasksResource(t);
|
|
254
|
+
}
|
|
255
|
+
};
|
|
256
|
+
|
|
257
|
+
// src/resources/ontology.ts
|
|
258
|
+
var ObjectsResource = class {
|
|
259
|
+
constructor(t) {
|
|
260
|
+
this.t = t;
|
|
261
|
+
}
|
|
262
|
+
t;
|
|
263
|
+
get(objectId) {
|
|
264
|
+
return this.t.request("GET", `/ontology/nodes/${objectId}`);
|
|
265
|
+
}
|
|
266
|
+
list(kind, opts = {}) {
|
|
267
|
+
return this.t.request("GET", "/ontology/nodes", { params: { node_type: kind, ...opts } });
|
|
268
|
+
}
|
|
269
|
+
create(kind, properties, name) {
|
|
270
|
+
return this.t.request("POST", "/ontology/nodes", {
|
|
271
|
+
json: { kind, properties, name }
|
|
272
|
+
});
|
|
273
|
+
}
|
|
274
|
+
createMany(kind, items, markings) {
|
|
275
|
+
return this.t.request("POST", "/ontology/nodes/bulk", { json: { kind, items, markings } });
|
|
276
|
+
}
|
|
277
|
+
delete(objectId) {
|
|
278
|
+
return this.t.request("DELETE", `/ontology/nodes/${objectId}`);
|
|
279
|
+
}
|
|
280
|
+
bulkDelete(opts) {
|
|
281
|
+
return this.t.request("POST", "/ontology/nodes/bulk-delete", { json: opts });
|
|
282
|
+
}
|
|
283
|
+
links(objectId) {
|
|
284
|
+
return this.t.request("GET", `/entities/${objectId}/links`);
|
|
285
|
+
}
|
|
286
|
+
history(objectId) {
|
|
287
|
+
return this.t.request("GET", `/lineage/by-asset/${objectId}`);
|
|
288
|
+
}
|
|
289
|
+
queryTimeseries(objectId, propertyName, opts = {}) {
|
|
290
|
+
return this.t.request(
|
|
291
|
+
"POST",
|
|
292
|
+
`/ontology/nodes/${objectId}/properties/${propertyName}/timeseries-query`,
|
|
293
|
+
{ json: opts }
|
|
294
|
+
);
|
|
295
|
+
}
|
|
296
|
+
appendTimeseries(objectId, propertyName, points) {
|
|
297
|
+
return this.t.request(
|
|
298
|
+
"POST",
|
|
299
|
+
`/ontology/nodes/${objectId}/properties/${propertyName}/timeseries/append`,
|
|
300
|
+
{ json: { points } }
|
|
301
|
+
);
|
|
302
|
+
}
|
|
303
|
+
};
|
|
304
|
+
var GraphResource = class {
|
|
305
|
+
constructor(t) {
|
|
306
|
+
this.t = t;
|
|
307
|
+
}
|
|
308
|
+
t;
|
|
309
|
+
expand(seedId, opts = {}) {
|
|
310
|
+
return this.t.request("GET", `/entities/${seedId}/graph`, { params: opts });
|
|
311
|
+
}
|
|
312
|
+
};
|
|
313
|
+
var ExplorerResource = class {
|
|
314
|
+
constructor(t) {
|
|
315
|
+
this.t = t;
|
|
316
|
+
}
|
|
317
|
+
t;
|
|
318
|
+
histogram(property, filters) {
|
|
319
|
+
return this.t.request("GET", "/entities/aggregate", {
|
|
320
|
+
params: { property, ...filters }
|
|
321
|
+
});
|
|
322
|
+
}
|
|
323
|
+
timeline(filters, bin) {
|
|
324
|
+
return this.t.request("GET", "/entities/timeline", {
|
|
325
|
+
params: { bin, ...filters }
|
|
326
|
+
});
|
|
327
|
+
}
|
|
328
|
+
};
|
|
329
|
+
var ObjectTypesResource = class {
|
|
330
|
+
constructor(t) {
|
|
331
|
+
this.t = t;
|
|
332
|
+
}
|
|
333
|
+
t;
|
|
334
|
+
get(kind) {
|
|
335
|
+
return this.t.request("GET", `/ontology/object-types/${kind}`);
|
|
336
|
+
}
|
|
337
|
+
create(kind, input) {
|
|
338
|
+
return this.t.request("POST", "/ontology/object-types", { json: { kind, ...input } });
|
|
339
|
+
}
|
|
340
|
+
update(kind, input) {
|
|
341
|
+
return this.t.request("PUT", `/ontology/object-types/${kind}`, { json: input });
|
|
342
|
+
}
|
|
343
|
+
delete(kind) {
|
|
344
|
+
return this.t.request("DELETE", `/ontology/object-types/${kind}`);
|
|
345
|
+
}
|
|
346
|
+
};
|
|
347
|
+
var LinkTypesResource = class {
|
|
348
|
+
constructor(t) {
|
|
349
|
+
this.t = t;
|
|
350
|
+
}
|
|
351
|
+
t;
|
|
352
|
+
declare(input) {
|
|
353
|
+
return this.t.request("POST", "/ontology/link-types", { json: input });
|
|
354
|
+
}
|
|
355
|
+
delete(edgeId) {
|
|
356
|
+
return this.t.request("DELETE", `/ontology/link-types/${edgeId}`);
|
|
357
|
+
}
|
|
358
|
+
};
|
|
359
|
+
var OntologyResource = class {
|
|
360
|
+
constructor(t) {
|
|
361
|
+
this.t = t;
|
|
362
|
+
this.objects = new ObjectsResource(t);
|
|
363
|
+
this.graph = new GraphResource(t);
|
|
364
|
+
this.explorer = new ExplorerResource(t);
|
|
365
|
+
this.objectTypes = new ObjectTypesResource(t);
|
|
366
|
+
this.linkTypes = new LinkTypesResource(t);
|
|
367
|
+
}
|
|
368
|
+
t;
|
|
369
|
+
objects;
|
|
370
|
+
graph;
|
|
371
|
+
explorer;
|
|
372
|
+
objectTypes;
|
|
373
|
+
linkTypes;
|
|
374
|
+
/** Shortcut — same as `objectTypes.get(kind)`. */
|
|
375
|
+
objectType(kind) {
|
|
376
|
+
return this.objectTypes.get(kind);
|
|
377
|
+
}
|
|
378
|
+
osdkManifest() {
|
|
379
|
+
return this.t.request("GET", "/ontology/osdk/manifest");
|
|
380
|
+
}
|
|
381
|
+
osdkFunctions() {
|
|
382
|
+
return this.t.request("GET", "/ontology/osdk/manifest/functions");
|
|
383
|
+
}
|
|
384
|
+
osdkGenerate(lang) {
|
|
385
|
+
return this.t.request("GET", "/ontology/osdk/generate", { params: { lang } });
|
|
386
|
+
}
|
|
387
|
+
};
|
|
388
|
+
|
|
389
|
+
// src/resources/aip.ts
|
|
390
|
+
var FlowsResource = class {
|
|
391
|
+
constructor(t) {
|
|
392
|
+
this.t = t;
|
|
393
|
+
}
|
|
394
|
+
t;
|
|
395
|
+
list() {
|
|
396
|
+
return this.t.request("GET", "/campaign/flows");
|
|
397
|
+
}
|
|
398
|
+
get(flowId) {
|
|
399
|
+
return this.t.request("GET", `/campaign/flows/${flowId}`);
|
|
400
|
+
}
|
|
401
|
+
runs(flowId) {
|
|
402
|
+
return this.t.request("GET", `/campaign/flows/${flowId}/runs`);
|
|
403
|
+
}
|
|
404
|
+
patch(flowId, payload) {
|
|
405
|
+
return this.t.request("PATCH", `/campaign/flows/${flowId}`, { json: payload });
|
|
406
|
+
}
|
|
407
|
+
run(flowId, dryRun) {
|
|
408
|
+
return this.t.request("POST", `/campaign/flows/${flowId}/run`, {
|
|
409
|
+
json: dryRun === void 0 ? {} : { dry_run: dryRun }
|
|
410
|
+
});
|
|
411
|
+
}
|
|
412
|
+
};
|
|
413
|
+
var AgentsResource = class {
|
|
414
|
+
constructor(t) {
|
|
415
|
+
this.t = t;
|
|
416
|
+
}
|
|
417
|
+
t;
|
|
418
|
+
list() {
|
|
419
|
+
return this.t.request("GET", "/campaign/agents");
|
|
420
|
+
}
|
|
421
|
+
get(agentId) {
|
|
422
|
+
return this.t.request("GET", `/campaign/agents/${agentId}`);
|
|
423
|
+
}
|
|
424
|
+
patch(agentId, config) {
|
|
425
|
+
return this.t.request("PATCH", `/campaign/agents/${agentId}`, { json: config });
|
|
426
|
+
}
|
|
427
|
+
manualRun(agentId) {
|
|
428
|
+
return this.t.request("POST", `/campaign/agents/${agentId}/runs`);
|
|
429
|
+
}
|
|
430
|
+
runs(agentId) {
|
|
431
|
+
return this.t.request("GET", `/campaign/agents/${agentId}/runs`);
|
|
432
|
+
}
|
|
433
|
+
};
|
|
434
|
+
var ModelsResource = class {
|
|
435
|
+
constructor(t) {
|
|
436
|
+
this.t = t;
|
|
437
|
+
}
|
|
438
|
+
t;
|
|
439
|
+
catalog(provider) {
|
|
440
|
+
return this.t.request("GET", "/platform/v25/aip/models/catalog", { params: { provider } });
|
|
441
|
+
}
|
|
442
|
+
defaults() {
|
|
443
|
+
return this.t.request("GET", "/platform/v25/aip/models/defaults");
|
|
444
|
+
}
|
|
445
|
+
setDefault(input) {
|
|
446
|
+
return this.t.request("PUT", "/platform/v25/aip/models/defaults", { json: input });
|
|
447
|
+
}
|
|
448
|
+
};
|
|
449
|
+
var BudgetResource = class {
|
|
450
|
+
constructor(t) {
|
|
451
|
+
this.t = t;
|
|
452
|
+
}
|
|
453
|
+
t;
|
|
454
|
+
get() {
|
|
455
|
+
return this.t.request("GET", "/platform/v23/llm-budget");
|
|
456
|
+
}
|
|
457
|
+
set(tokensPerMonth) {
|
|
458
|
+
return this.t.request("PUT", "/platform/v23/llm-budget", {
|
|
459
|
+
json: { tokens_per_month: tokensPerMonth }
|
|
460
|
+
});
|
|
461
|
+
}
|
|
462
|
+
};
|
|
463
|
+
var AipResource = class {
|
|
464
|
+
flows;
|
|
465
|
+
agents;
|
|
466
|
+
models;
|
|
467
|
+
budget;
|
|
468
|
+
constructor(t) {
|
|
469
|
+
this.flows = new FlowsResource(t);
|
|
470
|
+
this.agents = new AgentsResource(t);
|
|
471
|
+
this.models = new ModelsResource(t);
|
|
472
|
+
this.budget = new BudgetResource(t);
|
|
473
|
+
}
|
|
474
|
+
};
|
|
475
|
+
|
|
476
|
+
// src/resources/functions.ts
|
|
477
|
+
var FunctionsResource = class {
|
|
478
|
+
constructor(t) {
|
|
479
|
+
this.t = t;
|
|
480
|
+
}
|
|
481
|
+
t;
|
|
482
|
+
list() {
|
|
483
|
+
return this.t.request("GET", "/platform/v26/functions");
|
|
484
|
+
}
|
|
485
|
+
get(slug) {
|
|
486
|
+
return this.t.request("GET", `/platform/v26/functions/${slug}`);
|
|
487
|
+
}
|
|
488
|
+
create(input) {
|
|
489
|
+
return this.t.request("POST", "/platform/v26/functions", { json: input });
|
|
490
|
+
}
|
|
491
|
+
invoke(slug, inputs, opts = {}) {
|
|
492
|
+
return this.t.request("POST", `/platform/v26/functions/${slug}/invoke`, {
|
|
493
|
+
json: { inputs: inputs ?? {}, ...opts }
|
|
494
|
+
});
|
|
495
|
+
}
|
|
496
|
+
tests(slug) {
|
|
497
|
+
return this.t.request("GET", `/platform/v26/functions/${slug}/tests`);
|
|
498
|
+
}
|
|
499
|
+
addTest(slug, name, inputs, expectedContains) {
|
|
500
|
+
return this.t.request("POST", `/platform/v26/functions/${slug}/tests`, {
|
|
501
|
+
json: { name, inputs, expected_contains: expectedContains }
|
|
502
|
+
});
|
|
503
|
+
}
|
|
504
|
+
runTest(slug, testId) {
|
|
505
|
+
return this.t.request("POST", `/platform/v26/functions/${slug}/tests/${testId}/run`);
|
|
506
|
+
}
|
|
507
|
+
runTests(slug) {
|
|
508
|
+
return this.t.request("POST", `/platform/v26/functions/${slug}/test`);
|
|
509
|
+
}
|
|
510
|
+
publish(slug, branch) {
|
|
511
|
+
return this.t.request("POST", `/platform/v26/functions/${slug}/publish`, {
|
|
512
|
+
json: branch ? { branch } : {}
|
|
513
|
+
});
|
|
514
|
+
}
|
|
515
|
+
versions(slug) {
|
|
516
|
+
return this.t.request("GET", `/platform/v26/functions/${slug}/versions`);
|
|
517
|
+
}
|
|
518
|
+
pullRequests(slug, status) {
|
|
519
|
+
return this.t.request("GET", `/platform/v26/functions/${slug}/pull-requests`, {
|
|
520
|
+
params: { status }
|
|
521
|
+
});
|
|
522
|
+
}
|
|
523
|
+
openPullRequest(slug, input) {
|
|
524
|
+
return this.t.request("POST", `/platform/v26/functions/${slug}/pull-requests`, { json: input });
|
|
525
|
+
}
|
|
526
|
+
updatePullRequest(slug, prId, patch) {
|
|
527
|
+
return this.t.request("PATCH", `/platform/v26/functions/${slug}/pull-requests/${prId}`, {
|
|
528
|
+
json: patch
|
|
529
|
+
});
|
|
530
|
+
}
|
|
531
|
+
runPrCi(slug, prId) {
|
|
532
|
+
return this.t.request("POST", `/platform/v26/functions/${slug}/pull-requests/${prId}/ci`);
|
|
533
|
+
}
|
|
534
|
+
reviewPullRequest(slug, prId, decision, comment) {
|
|
535
|
+
return this.t.request("POST", `/platform/v26/functions/${slug}/pull-requests/${prId}/reviews`, {
|
|
536
|
+
json: { decision, comment }
|
|
537
|
+
});
|
|
538
|
+
}
|
|
539
|
+
mergePullRequest(slug, prId) {
|
|
540
|
+
return this.t.request("POST", `/platform/v26/functions/${slug}/pull-requests/${prId}/merge`);
|
|
541
|
+
}
|
|
542
|
+
};
|
|
543
|
+
var CodeRepositoriesResource = class {
|
|
544
|
+
constructor(t) {
|
|
545
|
+
this.t = t;
|
|
546
|
+
}
|
|
547
|
+
t;
|
|
548
|
+
list() {
|
|
549
|
+
return this.t.request("GET", "/platform/v26/code-repositories");
|
|
550
|
+
}
|
|
551
|
+
create(input) {
|
|
552
|
+
return this.t.request("POST", "/platform/v26/code-repositories", { json: input });
|
|
553
|
+
}
|
|
554
|
+
branches(repoId) {
|
|
555
|
+
return this.t.request("GET", `/platform/v26/code-repositories/${repoId}/branches`);
|
|
556
|
+
}
|
|
557
|
+
createBranch(repoId, name, description) {
|
|
558
|
+
return this.t.request("POST", `/platform/v26/code-repositories/${repoId}/branches`, {
|
|
559
|
+
json: { name, description }
|
|
560
|
+
});
|
|
561
|
+
}
|
|
562
|
+
functions(repoId) {
|
|
563
|
+
return this.t.request("GET", `/platform/v26/code-repositories/${repoId}/functions`);
|
|
564
|
+
}
|
|
565
|
+
assignFunction(repoId, slug) {
|
|
566
|
+
return this.t.request("POST", `/platform/v26/code-repositories/${repoId}/functions`, {
|
|
567
|
+
json: { slug }
|
|
568
|
+
});
|
|
569
|
+
}
|
|
570
|
+
runCi(repoId) {
|
|
571
|
+
return this.t.request("POST", `/platform/v26/code-repositories/${repoId}/ci`);
|
|
572
|
+
}
|
|
573
|
+
mergeBranch(repoId, sourceBranch, into) {
|
|
574
|
+
return this.t.request("POST", `/platform/v26/code-repositories/${repoId}/merge`, {
|
|
575
|
+
json: { source_branch: sourceBranch, into }
|
|
576
|
+
});
|
|
577
|
+
}
|
|
578
|
+
};
|
|
579
|
+
|
|
580
|
+
// src/resources/datasets.ts
|
|
581
|
+
var DatasetsResource = class {
|
|
582
|
+
constructor(t) {
|
|
583
|
+
this.t = t;
|
|
584
|
+
}
|
|
585
|
+
t;
|
|
586
|
+
list() {
|
|
587
|
+
return this.t.request("GET", "/datasets");
|
|
588
|
+
}
|
|
589
|
+
get(name) {
|
|
590
|
+
return this.t.request("GET", `/datasets/${name}`);
|
|
591
|
+
}
|
|
592
|
+
sample(name, limit) {
|
|
593
|
+
return this.t.request("GET", `/datasets/${name}/sample`, { params: { limit } });
|
|
594
|
+
}
|
|
595
|
+
listBranches(name) {
|
|
596
|
+
return this.t.request("GET", `/datasets/${name}/branches`);
|
|
597
|
+
}
|
|
598
|
+
createBranch(name, branchName, opts = {}) {
|
|
599
|
+
return this.t.request("POST", `/datasets/${name}/branches`, {
|
|
600
|
+
json: { branch_name: branchName, ...opts }
|
|
601
|
+
});
|
|
602
|
+
}
|
|
603
|
+
deactivateBranch(name, branchName) {
|
|
604
|
+
return this.t.request("DELETE", `/datasets/${name}/branches/${branchName}`);
|
|
605
|
+
}
|
|
606
|
+
listTransactions(name, branch) {
|
|
607
|
+
return this.t.request("GET", `/datasets/${name}/transactions`, { params: { branch } });
|
|
608
|
+
}
|
|
609
|
+
beginTransaction(name, kind, branch) {
|
|
610
|
+
return this.t.request("POST", `/datasets/${name}/transactions`, { json: { kind, branch } });
|
|
611
|
+
}
|
|
612
|
+
commitTransaction(name, txId, inputPayload) {
|
|
613
|
+
return this.t.request("POST", `/datasets/${name}/transactions/${txId}/commit`, {
|
|
614
|
+
json: inputPayload
|
|
615
|
+
});
|
|
616
|
+
}
|
|
617
|
+
abortTransaction(name, txId, reason) {
|
|
618
|
+
return this.t.request("POST", `/datasets/${name}/transactions/${txId}/abort`, {
|
|
619
|
+
json: { reason }
|
|
620
|
+
});
|
|
621
|
+
}
|
|
622
|
+
mergeFastForward(name, source, into) {
|
|
623
|
+
return this.t.request("POST", `/datasets/${name}/branches/${source}/merge`, {
|
|
624
|
+
json: { into }
|
|
625
|
+
});
|
|
626
|
+
}
|
|
627
|
+
/** 409 responses carry the conflict body in `AegisAPIError.payload`. */
|
|
628
|
+
mergeThreeWay(name, source, into, resolutions) {
|
|
629
|
+
return this.t.request("POST", `/datasets/${name}/branches/${source}/merge3`, {
|
|
630
|
+
json: { into, resolutions }
|
|
631
|
+
});
|
|
632
|
+
}
|
|
633
|
+
getClassification(name) {
|
|
634
|
+
return this.t.request("GET", `/datasets/${name}/classification`);
|
|
635
|
+
}
|
|
636
|
+
setClassification(name, patch) {
|
|
637
|
+
return this.t.request("PATCH", `/datasets/${name}/classification`, { json: patch });
|
|
638
|
+
}
|
|
639
|
+
listMarkings(name) {
|
|
640
|
+
return this.t.request("GET", `/datasets/${name}/markings`);
|
|
641
|
+
}
|
|
642
|
+
applyMarking(name, markingId) {
|
|
643
|
+
return this.t.request("POST", `/datasets/${name}/markings`, { json: { marking_id: markingId } });
|
|
644
|
+
}
|
|
645
|
+
removeMarking(name, markingId) {
|
|
646
|
+
return this.t.request("DELETE", `/datasets/${name}/markings/${markingId}`);
|
|
647
|
+
}
|
|
648
|
+
};
|
|
649
|
+
|
|
650
|
+
// src/client.ts
|
|
651
|
+
function envVar(name) {
|
|
652
|
+
if (typeof process !== "undefined" && process.env) return process.env[name];
|
|
653
|
+
return void 0;
|
|
654
|
+
}
|
|
655
|
+
var AegisClient = class {
|
|
656
|
+
baseUrl;
|
|
657
|
+
_token;
|
|
658
|
+
timeoutMs;
|
|
659
|
+
_fetch;
|
|
660
|
+
auth;
|
|
661
|
+
iam;
|
|
662
|
+
osdk;
|
|
663
|
+
operator;
|
|
664
|
+
ontology;
|
|
665
|
+
aip;
|
|
666
|
+
functions;
|
|
667
|
+
codeRepositories;
|
|
668
|
+
datasets;
|
|
669
|
+
constructor(options = {}) {
|
|
670
|
+
const baseUrl = options.baseUrl ?? envVar("AEGIS_API_URL") ?? "http://localhost:8002";
|
|
671
|
+
this.baseUrl = baseUrl.replace(/\/+$/, "");
|
|
672
|
+
this._token = options.token ?? envVar("AEGIS_TOKEN") ?? null;
|
|
673
|
+
this.timeoutMs = options.timeoutMs ?? 15e3;
|
|
674
|
+
this._fetch = options.fetch ?? globalThis.fetch.bind(globalThis);
|
|
675
|
+
this.auth = new AuthResource(this, (t) => this.setToken(t));
|
|
676
|
+
this.iam = new IamResource(this);
|
|
677
|
+
this.osdk = new OsdkResource(this);
|
|
678
|
+
this.operator = new OperatorResource(this);
|
|
679
|
+
this.ontology = new OntologyResource(this);
|
|
680
|
+
this.aip = new AipResource(this);
|
|
681
|
+
this.functions = new FunctionsResource(this);
|
|
682
|
+
this.codeRepositories = new CodeRepositoriesResource(this);
|
|
683
|
+
this.datasets = new DatasetsResource(this);
|
|
684
|
+
}
|
|
685
|
+
/** Replace the active bearer token (or clear with `null`). */
|
|
686
|
+
setToken(token) {
|
|
687
|
+
this._token = token;
|
|
688
|
+
}
|
|
689
|
+
get token() {
|
|
690
|
+
return this._token;
|
|
691
|
+
}
|
|
692
|
+
/** Generic escape hatch — call any AEGIS endpoint not yet wrapped. */
|
|
693
|
+
async request(method, path, opts = {}) {
|
|
694
|
+
const url = buildUrl(this.baseUrl, path, opts.params);
|
|
695
|
+
const headers = {};
|
|
696
|
+
if (this._token) headers.Authorization = `Bearer ${this._token}`;
|
|
697
|
+
const init = { method, headers };
|
|
698
|
+
if (opts.json !== void 0) {
|
|
699
|
+
headers["Content-Type"] = "application/json";
|
|
700
|
+
init.body = JSON.stringify(opts.json);
|
|
701
|
+
}
|
|
702
|
+
if (opts.signal) {
|
|
703
|
+
init.signal = opts.signal;
|
|
704
|
+
} else if (typeof AbortSignal !== "undefined" && "timeout" in AbortSignal) {
|
|
705
|
+
init.signal = AbortSignal.timeout(this.timeoutMs);
|
|
706
|
+
}
|
|
707
|
+
const res = await this._fetch(url, init);
|
|
708
|
+
return handleResponse(res);
|
|
709
|
+
}
|
|
710
|
+
};
|
|
711
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
712
|
+
0 && (module.exports = {
|
|
713
|
+
AegisAPIError,
|
|
714
|
+
AegisClient,
|
|
715
|
+
AuthError,
|
|
716
|
+
NotFoundError,
|
|
717
|
+
PermissionDeniedError
|
|
718
|
+
});
|
|
719
|
+
//# sourceMappingURL=index.cjs.map
|