@axiom-lattice/client-sdk 4.2.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/index.mjs CHANGED
@@ -2200,6 +2200,127 @@ var AbstractClient = class {
2200
2200
  return response.data;
2201
2201
  }
2202
2202
  };
2203
+ /** Capability bundle namespace for managing tenant-scoped bundles. */
2204
+ this.capabilityBundles = {
2205
+ /**
2206
+ * List all capability bundles visible to the current tenant.
2207
+ * @returns The tenant's capability bundles, unwrapped from the API response.
2208
+ */
2209
+ list: async () => {
2210
+ const response = await this.makeRequest(
2211
+ "/api/capability-bundles"
2212
+ );
2213
+ return response.data;
2214
+ },
2215
+ /**
2216
+ * List valid bundles together with safe invalid-record summaries.
2217
+ * @returns Inventory suitable for management and remediation workflows.
2218
+ */
2219
+ listInventory: async () => {
2220
+ const response = await this.makeRequest("/api/capability-bundles");
2221
+ return { bundles: response.data, errors: response.errors ?? [] };
2222
+ },
2223
+ /**
2224
+ * Get one capability bundle by identifier.
2225
+ * @param bundleId - Capability bundle identifier.
2226
+ * @returns The requested capability bundle.
2227
+ */
2228
+ get: async (bundleId) => {
2229
+ const response = await this.makeRequest(
2230
+ `/api/capability-bundles/${encodeURIComponent(bundleId)}`
2231
+ );
2232
+ return response.data;
2233
+ },
2234
+ /**
2235
+ * Create a capability bundle for the current tenant.
2236
+ * @param input - Bundle name, optional description, and capabilities. The server generates the stable key.
2237
+ * @returns The created capability bundle.
2238
+ */
2239
+ create: async (input) => {
2240
+ const response = await this.makeRequest(
2241
+ "/api/capability-bundles",
2242
+ { method: "POST", body: input }
2243
+ );
2244
+ return response.data;
2245
+ },
2246
+ /**
2247
+ * Update a capability bundle for the current tenant.
2248
+ * @param bundleId - Capability bundle identifier.
2249
+ * @param input - The partial bundle fields and required expected revision to update.
2250
+ * @returns The updated capability bundle.
2251
+ */
2252
+ update: async (bundleId, input) => {
2253
+ const response = await this.makeRequest(
2254
+ `/api/capability-bundles/${encodeURIComponent(bundleId)}`,
2255
+ { method: "PUT", body: input }
2256
+ );
2257
+ return response.data;
2258
+ },
2259
+ /**
2260
+ * Delete a capability bundle when the backend permits deletion.
2261
+ * @param bundleId - Capability bundle identifier.
2262
+ * @returns A promise that resolves after the bundle is deleted.
2263
+ * @throws ApiError when the bundle is missing, in use, or the request fails.
2264
+ */
2265
+ delete: async (bundleId) => {
2266
+ await this.makeRequest(
2267
+ `/api/capability-bundles/${encodeURIComponent(bundleId)}`,
2268
+ { method: "DELETE" }
2269
+ );
2270
+ }
2271
+ };
2272
+ this.projects = {
2273
+ capabilities: {
2274
+ /**
2275
+ * Get a project's selected bundles and its persisted capability preview.
2276
+ * @param projectId - Project identifier.
2277
+ * @returns The project, selected bundles, and preview resolved from persisted selections.
2278
+ */
2279
+ get: async (projectId) => {
2280
+ const response = await this.makeRequest(
2281
+ `/api/projects/${encodeURIComponent(projectId)}/capability-bundles`
2282
+ );
2283
+ return response.data;
2284
+ },
2285
+ /**
2286
+ * Replace a project's selected capability bundles.
2287
+ * @param projectId - Project identifier.
2288
+ * @param bundleIds - Ordered capability bundle identifiers to persist.
2289
+ * @returns The updated project, selected bundles, and persisted-selection preview.
2290
+ */
2291
+ update: async (projectId, bundleIds, expectedRevisions) => {
2292
+ const response = await this.makeRequest(
2293
+ `/api/projects/${encodeURIComponent(projectId)}/capability-bundles`,
2294
+ { method: "PUT", body: { bundleIds, expectedRevisions } }
2295
+ );
2296
+ return response.data;
2297
+ },
2298
+ /**
2299
+ * Preview the capability bundles currently persisted on a project.
2300
+ * @param projectId - Project identifier.
2301
+ * @returns The preview resolved from the project's persisted bundle selections.
2302
+ */
2303
+ preview: async (projectId) => {
2304
+ const response = await this.makeRequest(
2305
+ `/api/projects/${encodeURIComponent(projectId)}/capability-preview`
2306
+ );
2307
+ return response.data;
2308
+ },
2309
+ /**
2310
+ * Preview a draft bundle selection without changing the project.
2311
+ * @param projectId - Project identifier.
2312
+ * @param bundleIds - Ordered capability bundle identifiers to preview.
2313
+ * @returns The draft preview resolved from the supplied bundle IDs; no project state is changed.
2314
+ */
2315
+ previewWithBundles: async (projectId, bundleIds) => {
2316
+ const response = await this.makeRequest(
2317
+ `/api/projects/${encodeURIComponent(projectId)}/capability-preview`,
2318
+ { method: "POST", body: { bundleIds } }
2319
+ );
2320
+ return response.data;
2321
+ }
2322
+ }
2323
+ };
2203
2324
  /** Agent Web Apps namespace for managing React SDK publications. */
2204
2325
  this.webApps = {
2205
2326
  /**
@@ -3796,6 +3917,32 @@ var WeChatClient = class extends AbstractClient {
3796
3917
  setTenantId(tenantId) {
3797
3918
  this.tenantId = tenantId;
3798
3919
  }
3920
+ /**
3921
+ * Set workspace and project headers for requests made by this client.
3922
+ * @param workspaceId - Workspace identifier, or undefined to leave it unchanged
3923
+ * @param projectId - Project identifier, or undefined to leave it unchanged
3924
+ */
3925
+ setWorkspaceContext(workspaceId, projectId) {
3926
+ if (workspaceId !== void 0) {
3927
+ if (workspaceId)
3928
+ this.workspaceHeaders["x-workspace-id"] = workspaceId;
3929
+ else
3930
+ delete this.workspaceHeaders["x-workspace-id"];
3931
+ }
3932
+ if (projectId !== void 0) {
3933
+ if (projectId)
3934
+ this.workspaceHeaders["x-project-id"] = projectId;
3935
+ else
3936
+ delete this.workspaceHeaders["x-project-id"];
3937
+ }
3938
+ }
3939
+ /**
3940
+ * Get the workspace and project headers currently applied to this client.
3941
+ * @returns A copy of the current workspace and project header values
3942
+ */
3943
+ getWorkspaceHeaders() {
3944
+ return { ...this.workspaceHeaders };
3945
+ }
3799
3946
  /**
3800
3947
  * Creates a new instance of the client with the given configuration
3801
3948
  * @param config - Configuration options for the client
@@ -3826,7 +3973,8 @@ var WeChatClient = class extends AbstractClient {
3826
3973
  return this.wechatRequest({
3827
3974
  url: fullUrl,
3828
3975
  method,
3829
- data: options?.body
3976
+ data: options?.body,
3977
+ headers: this.getWorkspaceHeaders()
3830
3978
  });
3831
3979
  }
3832
3980
  /**
@@ -3906,11 +4054,12 @@ var WeChatClient = class extends AbstractClient {
3906
4054
  * @private
3907
4055
  */
3908
4056
  async wechatRequest(options) {
3909
- const { url, method, data } = options;
4057
+ const { url, method, data, headers: requestHeaders } = options;
3910
4058
  const headers = {
3911
4059
  "Content-Type": "application/json",
3912
4060
  Authorization: `Bearer ${this.config.apiKey}`,
3913
- ...this.config.headers
4061
+ ...this.config.headers,
4062
+ ...requestHeaders
3914
4063
  };
3915
4064
  if (this.tenantId) {
3916
4065
  headers["x-tenant-id"] = this.tenantId;