@axiom-lattice/client-sdk 4.1.0 → 4.2.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/dist/__tests__/capability-bundles.test.d.ts +2 -0
- package/dist/__tests__/capability-bundles.test.d.ts.map +1 -0
- package/dist/__tests__/capability-bundles.test.js +143 -0
- package/dist/__tests__/capability-bundles.test.js.map +1 -0
- package/dist/__tests__/streamEvents.test.js +33 -0
- package/dist/__tests__/streamEvents.test.js.map +1 -1
- package/dist/__tests__/workspace-client.test.js +21 -0
- package/dist/__tests__/workspace-client.test.js.map +1 -1
- package/dist/abstract-client.d.ts +70 -1
- package/dist/abstract-client.d.ts.map +1 -1
- package/dist/abstract-client.js +98 -0
- package/dist/abstract-client.js.map +1 -1
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +48 -16
- package/dist/client.js.map +1 -1
- package/dist/index.d.ts +115 -3
- package/dist/index.js +226 -16
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +226 -16
- package/dist/index.mjs.map +1 -1
- package/dist/types.d.ts +20 -2
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/wechat-client.d.ts +11 -0
- package/dist/wechat-client.d.ts.map +1 -1
- package/dist/wechat-client.js +29 -1
- package/dist/wechat-client.js.map +1 -1
- package/dist/workspace-client.d.ts +14 -0
- package/dist/workspace-client.d.ts.map +1 -1
- package/dist/workspace-client.js +24 -0
- package/dist/workspace-client.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -2224,6 +2224,127 @@ var AbstractClient = class {
|
|
|
2224
2224
|
return response.data;
|
|
2225
2225
|
}
|
|
2226
2226
|
};
|
|
2227
|
+
/** Capability bundle namespace for managing tenant-scoped bundles. */
|
|
2228
|
+
this.capabilityBundles = {
|
|
2229
|
+
/**
|
|
2230
|
+
* List all capability bundles visible to the current tenant.
|
|
2231
|
+
* @returns The tenant's capability bundles, unwrapped from the API response.
|
|
2232
|
+
*/
|
|
2233
|
+
list: async () => {
|
|
2234
|
+
const response = await this.makeRequest(
|
|
2235
|
+
"/api/capability-bundles"
|
|
2236
|
+
);
|
|
2237
|
+
return response.data;
|
|
2238
|
+
},
|
|
2239
|
+
/**
|
|
2240
|
+
* List valid bundles together with safe invalid-record summaries.
|
|
2241
|
+
* @returns Inventory suitable for management and remediation workflows.
|
|
2242
|
+
*/
|
|
2243
|
+
listInventory: async () => {
|
|
2244
|
+
const response = await this.makeRequest("/api/capability-bundles");
|
|
2245
|
+
return { bundles: response.data, errors: response.errors ?? [] };
|
|
2246
|
+
},
|
|
2247
|
+
/**
|
|
2248
|
+
* Get one capability bundle by identifier.
|
|
2249
|
+
* @param bundleId - Capability bundle identifier.
|
|
2250
|
+
* @returns The requested capability bundle.
|
|
2251
|
+
*/
|
|
2252
|
+
get: async (bundleId) => {
|
|
2253
|
+
const response = await this.makeRequest(
|
|
2254
|
+
`/api/capability-bundles/${encodeURIComponent(bundleId)}`
|
|
2255
|
+
);
|
|
2256
|
+
return response.data;
|
|
2257
|
+
},
|
|
2258
|
+
/**
|
|
2259
|
+
* Create a capability bundle for the current tenant.
|
|
2260
|
+
* @param input - Bundle name, optional description, and capabilities. The server generates the stable key.
|
|
2261
|
+
* @returns The created capability bundle.
|
|
2262
|
+
*/
|
|
2263
|
+
create: async (input) => {
|
|
2264
|
+
const response = await this.makeRequest(
|
|
2265
|
+
"/api/capability-bundles",
|
|
2266
|
+
{ method: "POST", body: input }
|
|
2267
|
+
);
|
|
2268
|
+
return response.data;
|
|
2269
|
+
},
|
|
2270
|
+
/**
|
|
2271
|
+
* Update a capability bundle for the current tenant.
|
|
2272
|
+
* @param bundleId - Capability bundle identifier.
|
|
2273
|
+
* @param input - The partial bundle fields and required expected revision to update.
|
|
2274
|
+
* @returns The updated capability bundle.
|
|
2275
|
+
*/
|
|
2276
|
+
update: async (bundleId, input) => {
|
|
2277
|
+
const response = await this.makeRequest(
|
|
2278
|
+
`/api/capability-bundles/${encodeURIComponent(bundleId)}`,
|
|
2279
|
+
{ method: "PUT", body: input }
|
|
2280
|
+
);
|
|
2281
|
+
return response.data;
|
|
2282
|
+
},
|
|
2283
|
+
/**
|
|
2284
|
+
* Delete a capability bundle when the backend permits deletion.
|
|
2285
|
+
* @param bundleId - Capability bundle identifier.
|
|
2286
|
+
* @returns A promise that resolves after the bundle is deleted.
|
|
2287
|
+
* @throws ApiError when the bundle is missing, in use, or the request fails.
|
|
2288
|
+
*/
|
|
2289
|
+
delete: async (bundleId) => {
|
|
2290
|
+
await this.makeRequest(
|
|
2291
|
+
`/api/capability-bundles/${encodeURIComponent(bundleId)}`,
|
|
2292
|
+
{ method: "DELETE" }
|
|
2293
|
+
);
|
|
2294
|
+
}
|
|
2295
|
+
};
|
|
2296
|
+
this.projects = {
|
|
2297
|
+
capabilities: {
|
|
2298
|
+
/**
|
|
2299
|
+
* Get a project's selected bundles and its persisted capability preview.
|
|
2300
|
+
* @param projectId - Project identifier.
|
|
2301
|
+
* @returns The project, selected bundles, and preview resolved from persisted selections.
|
|
2302
|
+
*/
|
|
2303
|
+
get: async (projectId) => {
|
|
2304
|
+
const response = await this.makeRequest(
|
|
2305
|
+
`/api/projects/${encodeURIComponent(projectId)}/capability-bundles`
|
|
2306
|
+
);
|
|
2307
|
+
return response.data;
|
|
2308
|
+
},
|
|
2309
|
+
/**
|
|
2310
|
+
* Replace a project's selected capability bundles.
|
|
2311
|
+
* @param projectId - Project identifier.
|
|
2312
|
+
* @param bundleIds - Ordered capability bundle identifiers to persist.
|
|
2313
|
+
* @returns The updated project, selected bundles, and persisted-selection preview.
|
|
2314
|
+
*/
|
|
2315
|
+
update: async (projectId, bundleIds, expectedRevisions) => {
|
|
2316
|
+
const response = await this.makeRequest(
|
|
2317
|
+
`/api/projects/${encodeURIComponent(projectId)}/capability-bundles`,
|
|
2318
|
+
{ method: "PUT", body: { bundleIds, expectedRevisions } }
|
|
2319
|
+
);
|
|
2320
|
+
return response.data;
|
|
2321
|
+
},
|
|
2322
|
+
/**
|
|
2323
|
+
* Preview the capability bundles currently persisted on a project.
|
|
2324
|
+
* @param projectId - Project identifier.
|
|
2325
|
+
* @returns The preview resolved from the project's persisted bundle selections.
|
|
2326
|
+
*/
|
|
2327
|
+
preview: async (projectId) => {
|
|
2328
|
+
const response = await this.makeRequest(
|
|
2329
|
+
`/api/projects/${encodeURIComponent(projectId)}/capability-preview`
|
|
2330
|
+
);
|
|
2331
|
+
return response.data;
|
|
2332
|
+
},
|
|
2333
|
+
/**
|
|
2334
|
+
* Preview a draft bundle selection without changing the project.
|
|
2335
|
+
* @param projectId - Project identifier.
|
|
2336
|
+
* @param bundleIds - Ordered capability bundle identifiers to preview.
|
|
2337
|
+
* @returns The draft preview resolved from the supplied bundle IDs; no project state is changed.
|
|
2338
|
+
*/
|
|
2339
|
+
previewWithBundles: async (projectId, bundleIds) => {
|
|
2340
|
+
const response = await this.makeRequest(
|
|
2341
|
+
`/api/projects/${encodeURIComponent(projectId)}/capability-preview`,
|
|
2342
|
+
{ method: "POST", body: { bundleIds } }
|
|
2343
|
+
);
|
|
2344
|
+
return response.data;
|
|
2345
|
+
}
|
|
2346
|
+
}
|
|
2347
|
+
};
|
|
2227
2348
|
/** Agent Web Apps namespace for managing React SDK publications. */
|
|
2228
2349
|
this.webApps = {
|
|
2229
2350
|
/**
|
|
@@ -3642,25 +3763,59 @@ var _Client = class extends AbstractClient {
|
|
|
3642
3763
|
const reader = res.body.getReader();
|
|
3643
3764
|
const decoder = new TextDecoder();
|
|
3644
3765
|
let buffer = "";
|
|
3766
|
+
let event = "";
|
|
3767
|
+
let dataLines = [];
|
|
3768
|
+
const processLine = (rawLine) => {
|
|
3769
|
+
const line = rawLine.endsWith("\r") ? rawLine.slice(0, -1) : rawLine;
|
|
3770
|
+
if (line === "") {
|
|
3771
|
+
if (dataLines.length === 0) {
|
|
3772
|
+
event = "";
|
|
3773
|
+
return null;
|
|
3774
|
+
}
|
|
3775
|
+
const data = dataLines.join("\n");
|
|
3776
|
+
const eventName = event;
|
|
3777
|
+
event = "";
|
|
3778
|
+
dataLines = [];
|
|
3779
|
+
try {
|
|
3780
|
+
return { event: eventName, data: JSON.parse(data) };
|
|
3781
|
+
} catch {
|
|
3782
|
+
return null;
|
|
3783
|
+
}
|
|
3784
|
+
}
|
|
3785
|
+
if (line.startsWith(":"))
|
|
3786
|
+
return null;
|
|
3787
|
+
const separator = line.indexOf(":");
|
|
3788
|
+
const field = separator === -1 ? line : line.slice(0, separator);
|
|
3789
|
+
let value = separator === -1 ? "" : line.slice(separator + 1);
|
|
3790
|
+
if (value.startsWith(" "))
|
|
3791
|
+
value = value.slice(1);
|
|
3792
|
+
if (field === "event")
|
|
3793
|
+
event = value;
|
|
3794
|
+
else if (field === "data")
|
|
3795
|
+
dataLines.push(value);
|
|
3796
|
+
return null;
|
|
3797
|
+
};
|
|
3645
3798
|
while (true) {
|
|
3646
3799
|
const { done, value } = await reader.read();
|
|
3647
|
-
if (done)
|
|
3800
|
+
if (done) {
|
|
3801
|
+
buffer += decoder.decode();
|
|
3648
3802
|
break;
|
|
3803
|
+
}
|
|
3649
3804
|
buffer += decoder.decode(value, { stream: true });
|
|
3650
|
-
|
|
3651
|
-
|
|
3652
|
-
|
|
3653
|
-
|
|
3654
|
-
if (
|
|
3655
|
-
|
|
3656
|
-
|
|
3657
|
-
try {
|
|
3658
|
-
yield { event, data: JSON.parse(line.slice(6)) };
|
|
3659
|
-
} catch {
|
|
3660
|
-
}
|
|
3661
|
-
}
|
|
3805
|
+
let newline = buffer.indexOf("\n");
|
|
3806
|
+
while (newline !== -1) {
|
|
3807
|
+
const parsed = processLine(buffer.slice(0, newline));
|
|
3808
|
+
buffer = buffer.slice(newline + 1);
|
|
3809
|
+
if (parsed)
|
|
3810
|
+
yield parsed;
|
|
3811
|
+
newline = buffer.indexOf("\n");
|
|
3662
3812
|
}
|
|
3663
3813
|
}
|
|
3814
|
+
if (buffer.length > 0)
|
|
3815
|
+
processLine(buffer);
|
|
3816
|
+
const finalEvent = processLine("");
|
|
3817
|
+
if (finalEvent)
|
|
3818
|
+
yield finalEvent;
|
|
3664
3819
|
}
|
|
3665
3820
|
/**
|
|
3666
3821
|
* Get all headers including workspace context
|
|
@@ -3786,6 +3941,32 @@ var WeChatClient = class extends AbstractClient {
|
|
|
3786
3941
|
setTenantId(tenantId) {
|
|
3787
3942
|
this.tenantId = tenantId;
|
|
3788
3943
|
}
|
|
3944
|
+
/**
|
|
3945
|
+
* Set workspace and project headers for requests made by this client.
|
|
3946
|
+
* @param workspaceId - Workspace identifier, or undefined to leave it unchanged
|
|
3947
|
+
* @param projectId - Project identifier, or undefined to leave it unchanged
|
|
3948
|
+
*/
|
|
3949
|
+
setWorkspaceContext(workspaceId, projectId) {
|
|
3950
|
+
if (workspaceId !== void 0) {
|
|
3951
|
+
if (workspaceId)
|
|
3952
|
+
this.workspaceHeaders["x-workspace-id"] = workspaceId;
|
|
3953
|
+
else
|
|
3954
|
+
delete this.workspaceHeaders["x-workspace-id"];
|
|
3955
|
+
}
|
|
3956
|
+
if (projectId !== void 0) {
|
|
3957
|
+
if (projectId)
|
|
3958
|
+
this.workspaceHeaders["x-project-id"] = projectId;
|
|
3959
|
+
else
|
|
3960
|
+
delete this.workspaceHeaders["x-project-id"];
|
|
3961
|
+
}
|
|
3962
|
+
}
|
|
3963
|
+
/**
|
|
3964
|
+
* Get the workspace and project headers currently applied to this client.
|
|
3965
|
+
* @returns A copy of the current workspace and project header values
|
|
3966
|
+
*/
|
|
3967
|
+
getWorkspaceHeaders() {
|
|
3968
|
+
return { ...this.workspaceHeaders };
|
|
3969
|
+
}
|
|
3789
3970
|
/**
|
|
3790
3971
|
* Creates a new instance of the client with the given configuration
|
|
3791
3972
|
* @param config - Configuration options for the client
|
|
@@ -3816,7 +3997,8 @@ var WeChatClient = class extends AbstractClient {
|
|
|
3816
3997
|
return this.wechatRequest({
|
|
3817
3998
|
url: fullUrl,
|
|
3818
3999
|
method,
|
|
3819
|
-
data: options?.body
|
|
4000
|
+
data: options?.body,
|
|
4001
|
+
headers: this.getWorkspaceHeaders()
|
|
3820
4002
|
});
|
|
3821
4003
|
}
|
|
3822
4004
|
/**
|
|
@@ -3896,11 +4078,12 @@ var WeChatClient = class extends AbstractClient {
|
|
|
3896
4078
|
* @private
|
|
3897
4079
|
*/
|
|
3898
4080
|
async wechatRequest(options) {
|
|
3899
|
-
const { url, method, data } = options;
|
|
4081
|
+
const { url, method, data, headers: requestHeaders } = options;
|
|
3900
4082
|
const headers = {
|
|
3901
4083
|
"Content-Type": "application/json",
|
|
3902
4084
|
Authorization: `Bearer ${this.config.apiKey}`,
|
|
3903
|
-
...this.config.headers
|
|
4085
|
+
...this.config.headers,
|
|
4086
|
+
...requestHeaders
|
|
3904
4087
|
};
|
|
3905
4088
|
if (this.tenantId) {
|
|
3906
4089
|
headers["x-tenant-id"] = this.tenantId;
|
|
@@ -4224,6 +4407,33 @@ var WorkspaceClient = class {
|
|
|
4224
4407
|
}
|
|
4225
4408
|
return `${this.baseURL}/api/workspaces/${workspaceId}/projects/${projectId}/downloadfile?${params}`;
|
|
4226
4409
|
}
|
|
4410
|
+
/**
|
|
4411
|
+
* Download a project folder as an authenticated ZIP Blob.
|
|
4412
|
+
*
|
|
4413
|
+
* The request is scoped by this client's bearer token and tenant headers;
|
|
4414
|
+
* callers are responsible for triggering browser download behavior.
|
|
4415
|
+
*
|
|
4416
|
+
* @param workspaceId - Workspace identifier.
|
|
4417
|
+
* @param projectId - Project identifier.
|
|
4418
|
+
* @param folderPath - Backend folder path to archive.
|
|
4419
|
+
* @param assistantId - Optional sandbox assistant context.
|
|
4420
|
+
* @returns The ZIP response as a Blob.
|
|
4421
|
+
* @throws Error when the authenticated request fails.
|
|
4422
|
+
*/
|
|
4423
|
+
async downloadFolder(workspaceId, projectId, folderPath, assistantId) {
|
|
4424
|
+
const params = new URLSearchParams({ path: folderPath, tenantId: this.tenantId });
|
|
4425
|
+
if (assistantId)
|
|
4426
|
+
params.set("assistantId", assistantId);
|
|
4427
|
+
const response = await fetch(
|
|
4428
|
+
`${this.baseURL}/api/workspaces/${workspaceId}/projects/${projectId}/downloadfolder?${params}`,
|
|
4429
|
+
{ headers: this.headers }
|
|
4430
|
+
);
|
|
4431
|
+
if (!response.ok) {
|
|
4432
|
+
const error = await response.json().catch(() => ({}));
|
|
4433
|
+
throw new Error(error.error || error.message || `HTTP error! Status: ${response.status}`);
|
|
4434
|
+
}
|
|
4435
|
+
return response.blob();
|
|
4436
|
+
}
|
|
4227
4437
|
/**
|
|
4228
4438
|
* Get a URL for viewing a file inline in the browser (not download).
|
|
4229
4439
|
* The file will be displayed in the browser rather than downloaded.
|