@axiom-lattice/client-sdk 3.0.6 → 4.0.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.
Files changed (40) hide show
  1. package/dist/__tests__/a2a-keys.test.d.ts +8 -0
  2. package/dist/__tests__/a2a-keys.test.d.ts.map +1 -0
  3. package/dist/__tests__/a2a-keys.test.js +110 -0
  4. package/dist/__tests__/a2a-keys.test.js.map +1 -0
  5. package/dist/__tests__/export-import.test.d.ts +2 -0
  6. package/dist/__tests__/export-import.test.d.ts.map +1 -0
  7. package/dist/__tests__/export-import.test.js +245 -0
  8. package/dist/__tests__/export-import.test.js.map +1 -0
  9. package/dist/__tests__/tasks.test.d.ts +2 -0
  10. package/dist/__tests__/tasks.test.d.ts.map +1 -0
  11. package/dist/__tests__/tasks.test.js +67 -0
  12. package/dist/__tests__/tasks.test.js.map +1 -0
  13. package/dist/__tests__/workspace-client.test.d.ts +10 -0
  14. package/dist/__tests__/workspace-client.test.d.ts.map +1 -0
  15. package/dist/__tests__/workspace-client.test.js +56 -0
  16. package/dist/__tests__/workspace-client.test.js.map +1 -0
  17. package/dist/abstract-client.d.ts +59 -2
  18. package/dist/abstract-client.d.ts.map +1 -1
  19. package/dist/abstract-client.js +74 -3
  20. package/dist/abstract-client.js.map +1 -1
  21. package/dist/client.d.ts +2 -0
  22. package/dist/client.d.ts.map +1 -1
  23. package/dist/client.js +2 -0
  24. package/dist/client.js.map +1 -1
  25. package/dist/export-import.d.ts +136 -24
  26. package/dist/export-import.d.ts.map +1 -1
  27. package/dist/export-import.js +142 -48
  28. package/dist/export-import.js.map +1 -1
  29. package/dist/index.d.ts +263 -33
  30. package/dist/index.js +258 -96
  31. package/dist/index.js.map +1 -1
  32. package/dist/index.mjs +258 -96
  33. package/dist/index.mjs.map +1 -1
  34. package/dist/types.d.ts +60 -0
  35. package/dist/types.d.ts.map +1 -1
  36. package/dist/workspace-client.d.ts +2 -2
  37. package/dist/workspace-client.d.ts.map +1 -1
  38. package/dist/workspace-client.js +7 -2
  39. package/dist/workspace-client.js.map +1 -1
  40. package/package.json +2 -2
package/dist/index.mjs CHANGED
@@ -2129,6 +2129,77 @@ var AbstractClient = class {
2129
2129
  }
2130
2130
  }
2131
2131
  };
2132
+ /**
2133
+ * A2A API keys namespace for managing A2A API keys
2134
+ */
2135
+ this.a2aKeys = {
2136
+ /**
2137
+ * Lists A2A API keys, optionally filtered by tenant
2138
+ * Key values are masked in list responses
2139
+ * @param params - Optional tenant filter and pagination
2140
+ * @returns A promise that resolves to the list of key records and total
2141
+ */
2142
+ list: async (params) => {
2143
+ const searchParams = new URLSearchParams();
2144
+ if (params?.tenantId)
2145
+ searchParams.set("tenantId", params.tenantId);
2146
+ if (params?.limit !== void 0)
2147
+ searchParams.set("limit", String(params.limit));
2148
+ if (params?.offset !== void 0)
2149
+ searchParams.set("offset", String(params.offset));
2150
+ const qs = searchParams.toString();
2151
+ const response = await this.makeRequest(`/api/a2a/keys${qs ? `?${qs}` : ""}`);
2152
+ return response.data;
2153
+ },
2154
+ /**
2155
+ * Creates a new A2A API key
2156
+ * The full key value is returned only from this call
2157
+ * @param input - Key creation input (tenant, project, optional assistant whitelist and label)
2158
+ * @returns A promise that resolves to the created key record (full key value)
2159
+ */
2160
+ create: async (input) => {
2161
+ const response = await this.makeRequest("/api/a2a/keys", { method: "POST", body: input });
2162
+ return response.data;
2163
+ },
2164
+ /**
2165
+ * Permanently deletes an A2A API key
2166
+ * @param id - Key identifier
2167
+ * @returns A promise that resolves when the key is deleted
2168
+ */
2169
+ delete: async (id) => {
2170
+ await this.makeRequest(`/api/a2a/keys/${id}`, {
2171
+ method: "DELETE"
2172
+ });
2173
+ },
2174
+ /**
2175
+ * Disables an A2A API key
2176
+ * @param id - Key identifier
2177
+ * @returns A promise that resolves to the updated key record
2178
+ */
2179
+ disable: async (id) => {
2180
+ const response = await this.makeRequest(`/api/a2a/keys/${id}/disable`, { method: "POST" });
2181
+ return response.data;
2182
+ },
2183
+ /**
2184
+ * Enables a previously disabled A2A API key
2185
+ * @param id - Key identifier
2186
+ * @returns A promise that resolves to the updated key record
2187
+ */
2188
+ enable: async (id) => {
2189
+ const response = await this.makeRequest(`/api/a2a/keys/${id}/enable`, { method: "POST" });
2190
+ return response.data;
2191
+ },
2192
+ /**
2193
+ * Rotates an A2A API key, generating a new key value
2194
+ * The full new key value is returned only from this call
2195
+ * @param id - Key identifier
2196
+ * @returns A promise that resolves to the updated key record (full new key value)
2197
+ */
2198
+ rotate: async (id) => {
2199
+ const response = await this.makeRequest(`/api/a2a/keys/${id}/rotate`, { method: "POST" });
2200
+ return response.data;
2201
+ }
2202
+ };
2132
2203
  /**
2133
2204
  * Skills namespace for managing skills
2134
2205
  */
@@ -2649,11 +2720,11 @@ var AbstractClient = class {
2649
2720
  delete: async (id) => {
2650
2721
  await this.makeRequest(`/api/tasks/${id}`, { method: "DELETE" });
2651
2722
  },
2652
- complete: async (id) => {
2653
- const response = await this.makeRequest(`/api/tasks/${id}/complete`, { method: "PATCH" });
2723
+ complete: async (id, data) => {
2724
+ const response = await this.makeRequest(`/api/tasks/${id}/complete`, { method: "PATCH", body: data });
2654
2725
  if (!response.data)
2655
2726
  throw new ApiError("Failed to complete task", 500);
2656
- return response.data;
2727
+ return response;
2657
2728
  },
2658
2729
  workItems: {
2659
2730
  list: async (taskId, params) => {
@@ -2960,6 +3031,182 @@ var ResourcesClient = class {
2960
3031
  }
2961
3032
  };
2962
3033
 
3034
+ // src/export-import.ts
3035
+ function base64ToBytes(base64) {
3036
+ if (typeof globalThis.atob === "function") {
3037
+ const binary = globalThis.atob(base64);
3038
+ const bytes = new Uint8Array(binary.length);
3039
+ for (let index = 0; index < binary.length; index += 1) {
3040
+ bytes[index] = binary.charCodeAt(index);
3041
+ }
3042
+ return bytes;
3043
+ }
3044
+ return new Uint8Array(Buffer.from(base64, "base64"));
3045
+ }
3046
+ function bytesToArrayBuffer(bytes) {
3047
+ return bytes.buffer.slice(bytes.byteOffset, bytes.byteOffset + bytes.byteLength);
3048
+ }
3049
+ async function archiveToBlob(archive) {
3050
+ if (typeof archive === "string") {
3051
+ return {
3052
+ blob: new Blob([bytesToArrayBuffer(base64ToBytes(archive))], { type: "application/gzip" }),
3053
+ filename: "tenant-import.tar.gz"
3054
+ };
3055
+ }
3056
+ if (archive instanceof Blob) {
3057
+ const filename = "name" in archive && typeof archive.name === "string" ? archive.name : "tenant-import.tar.gz";
3058
+ return { blob: archive, filename };
3059
+ }
3060
+ const bytes = archive instanceof Uint8Array ? archive : archive instanceof ArrayBuffer ? new Uint8Array(archive) : new Uint8Array(await archive.arrayBuffer());
3061
+ return {
3062
+ blob: new Blob([bytesToArrayBuffer(bytes)], { type: "application/gzip" }),
3063
+ filename: "tenant-import.tar.gz"
3064
+ };
3065
+ }
3066
+ function attachmentFilename(contentDisposition) {
3067
+ if (!contentDisposition)
3068
+ return "tenant-export.tar.gz";
3069
+ const encoded = contentDisposition.match(/filename\*=UTF-8''([^;]+)/i)?.[1];
3070
+ if (encoded) {
3071
+ try {
3072
+ return decodeURIComponent(encoded);
3073
+ } catch {
3074
+ return encoded;
3075
+ }
3076
+ }
3077
+ return contentDisposition.match(/filename="([^"]+)"/i)?.[1] ?? contentDisposition.match(/filename=([^;\s]+)/i)?.[1] ?? "tenant-export.tar.gz";
3078
+ }
3079
+ var ExportImportClient = class {
3080
+ /**
3081
+ * Creates an export/import client.
3082
+ *
3083
+ * @param config - Base client configuration.
3084
+ * @param headerProvider - Optional provider for headers that change after construction.
3085
+ */
3086
+ constructor(config, headerProvider) {
3087
+ this.baseURL = config.baseURL;
3088
+ this.headers = {
3089
+ "Content-Type": "application/json",
3090
+ Authorization: `Bearer ${config.apiKey}`,
3091
+ ...config.headers
3092
+ };
3093
+ this.headerProvider = headerProvider;
3094
+ }
3095
+ async request(url, options = {}) {
3096
+ const headers = {
3097
+ ...this.headers,
3098
+ ...this.headerProvider?.(),
3099
+ ...options.headers
3100
+ };
3101
+ if (options.body instanceof FormData) {
3102
+ for (const name of Object.keys(headers)) {
3103
+ if (name.toLowerCase() === "content-type")
3104
+ delete headers[name];
3105
+ }
3106
+ }
3107
+ const response = await fetch(`${this.baseURL}${url}`, {
3108
+ method: options.method ?? "GET",
3109
+ ...options,
3110
+ headers
3111
+ });
3112
+ const envelope = await response.json().catch(() => ({}));
3113
+ if (!response.ok || envelope.success === false) {
3114
+ throw new Error(
3115
+ envelope.message || envelope.error || `HTTP error! Status: ${response.status}`
3116
+ );
3117
+ }
3118
+ if (envelope.data === void 0) {
3119
+ throw new Error(envelope.message || envelope.error || "API response contained no data");
3120
+ }
3121
+ return envelope.data;
3122
+ }
3123
+ /** Returns all entity types registered for export. */
3124
+ getExportableTypes() {
3125
+ return this.request("/api/tenants/exportable-types");
3126
+ }
3127
+ /** Starts an export or returns dependencies requiring confirmation. */
3128
+ exportConfig(tenantId, entityTypes, entityIds) {
3129
+ return this.request(`/api/tenants/${tenantId}/export`, {
3130
+ method: "POST",
3131
+ body: JSON.stringify({ entityTypes, ...entityIds ? { entityIds } : {} })
3132
+ });
3133
+ }
3134
+ /** Starts an export after confirming dependency additions. */
3135
+ exportConfigConfirm(tenantId, entityTypes, entityIds) {
3136
+ return this.request(`/api/tenants/${tenantId}/export/confirm`, {
3137
+ method: "POST",
3138
+ body: JSON.stringify({ entityTypes, ...entityIds ? { entityIds } : {} })
3139
+ });
3140
+ }
3141
+ /** Lists selectable entities for the requested export types. */
3142
+ previewEntities(tenantId, entityTypes) {
3143
+ return this.request(
3144
+ `/api/tenants/${tenantId}/export/entities`,
3145
+ { method: "POST", body: JSON.stringify({ entityTypes }) }
3146
+ );
3147
+ }
3148
+ /** Returns the gateway URL for an export download job. */
3149
+ getExportDownloadUrl(tenantId, jobId) {
3150
+ return `${this.baseURL}/api/tenants/${tenantId}/export/${jobId}/download`;
3151
+ }
3152
+ /** Downloads an export archive as raw bytes. */
3153
+ async downloadExport(tenantId, jobId) {
3154
+ const response = await fetch(
3155
+ `${this.baseURL}/api/tenants/${tenantId}/export/${jobId}/download`,
3156
+ {
3157
+ method: "GET",
3158
+ headers: {
3159
+ ...this.headers,
3160
+ ...this.headerProvider?.()
3161
+ }
3162
+ }
3163
+ );
3164
+ if (!response.ok) {
3165
+ const envelope = await response.json().catch(() => ({}));
3166
+ throw new Error(
3167
+ envelope.message || envelope.error || `HTTP error! Status: ${response.status}`
3168
+ );
3169
+ }
3170
+ return {
3171
+ filename: attachmentFilename(response.headers.get("Content-Disposition")),
3172
+ data: new Uint8Array(await response.arrayBuffer())
3173
+ };
3174
+ }
3175
+ /** Previews an archive or plain JSON bundle import. */
3176
+ async importPreview(tenantId, source) {
3177
+ if (source.archive !== void 0) {
3178
+ const form = new FormData();
3179
+ const { blob, filename } = await archiveToBlob(source.archive);
3180
+ form.append("file", blob, filename);
3181
+ return this.request(`/api/tenants/${tenantId}/import/preview`, {
3182
+ method: "POST",
3183
+ body: form
3184
+ });
3185
+ }
3186
+ return this.request(`/api/tenants/${tenantId}/import/preview`, {
3187
+ method: "POST",
3188
+ body: JSON.stringify({ bundle: source.bundle })
3189
+ });
3190
+ }
3191
+ /** Applies an archive or plain JSON bundle import with conflict resolutions. */
3192
+ async importApply(tenantId, source, resolutions) {
3193
+ if (source.archive !== void 0) {
3194
+ const form = new FormData();
3195
+ const { blob, filename } = await archiveToBlob(source.archive);
3196
+ form.append("file", blob, filename);
3197
+ form.append("resolutions", JSON.stringify(resolutions));
3198
+ return this.request(`/api/tenants/${tenantId}/import/apply`, {
3199
+ method: "POST",
3200
+ body: form
3201
+ });
3202
+ }
3203
+ return this.request(`/api/tenants/${tenantId}/import/apply`, {
3204
+ method: "POST",
3205
+ body: JSON.stringify({ bundle: source.bundle, resolutions })
3206
+ });
3207
+ }
3208
+ };
3209
+
2963
3210
  // src/client.ts
2964
3211
  var _Client = class extends AbstractClient {
2965
3212
  /**
@@ -2974,6 +3221,7 @@ var _Client = class extends AbstractClient {
2974
3221
  ...this.config.headers
2975
3222
  };
2976
3223
  this.resources = new ResourcesClient(this.config.baseURL, () => this.getAllHeaders());
3224
+ this.exportImport = new ExportImportClient(this.config, () => this.getAllHeaders());
2977
3225
  }
2978
3226
  /**
2979
3227
  * Helper method to handle fetch responses and errors
@@ -3734,9 +3982,14 @@ var WorkspaceClient = class {
3734
3982
  });
3735
3983
  }
3736
3984
  // ==================== Project CRUD ====================
3737
- async listProjects(workspaceId) {
3985
+ async listProjects(workspaceId, kind) {
3986
+ const params = new URLSearchParams();
3987
+ if (kind) {
3988
+ params.set("kind", kind);
3989
+ }
3990
+ const qs = params.toString();
3738
3991
  const response = await this.request(
3739
- `/api/workspaces/${workspaceId}/projects`
3992
+ `/api/workspaces/${workspaceId}/projects${qs ? `?${qs}` : ""}`
3740
3993
  );
3741
3994
  return response.data || [];
3742
3995
  }
@@ -3875,97 +4128,6 @@ var WorkspaceClient = class {
3875
4128
  }
3876
4129
  };
3877
4130
 
3878
- // src/export-import.ts
3879
- var ExportImportClient = class {
3880
- constructor(config) {
3881
- this.baseURL = config.baseURL;
3882
- this.headers = {
3883
- "Content-Type": "application/json",
3884
- Authorization: `Bearer ${config.apiKey}`,
3885
- ...config.headers
3886
- };
3887
- }
3888
- async request(url, options = {}) {
3889
- const fullUrl = `${this.baseURL}${url}`;
3890
- const response = await fetch(fullUrl, {
3891
- ...options,
3892
- headers: {
3893
- ...this.headers,
3894
- ...options.headers
3895
- }
3896
- });
3897
- if (!response.ok) {
3898
- const err = await response.json().catch(() => ({}));
3899
- throw new Error(
3900
- err.message || `HTTP error! Status: ${response.status}`
3901
- );
3902
- }
3903
- return response.json();
3904
- }
3905
- async getExportableTypes() {
3906
- const response = await this.request(
3907
- "/api/tenants/exportable-types"
3908
- );
3909
- return response.data || [];
3910
- }
3911
- async exportConfig(tenantId, entityTypes) {
3912
- const response = await this.request(
3913
- `/api/tenants/${tenantId}/export`,
3914
- {
3915
- method: "POST",
3916
- body: JSON.stringify({ entityTypes })
3917
- }
3918
- );
3919
- return response.data;
3920
- }
3921
- async exportConfigConfirm(tenantId, entityTypes) {
3922
- const response = await this.request(
3923
- `/api/tenants/${tenantId}/export/confirm`,
3924
- {
3925
- method: "POST",
3926
- body: JSON.stringify({ entityTypes })
3927
- }
3928
- );
3929
- return response.data;
3930
- }
3931
- getExportDownloadUrl(tenantId, jobId) {
3932
- return `${this.baseURL}/api/tenants/${tenantId}/export/${jobId}/download`;
3933
- }
3934
- async importPreview(tenantId, file) {
3935
- const formData = new FormData();
3936
- formData.append("file", file);
3937
- const fullUrl = `${this.baseURL}/api/tenants/${tenantId}/import/preview`;
3938
- const headers = { ...this.headers };
3939
- delete headers["Content-Type"];
3940
- const response = await fetch(fullUrl, {
3941
- method: "POST",
3942
- headers,
3943
- body: formData
3944
- });
3945
- if (!response.ok) {
3946
- const err = await response.json().catch(() => ({}));
3947
- throw new Error(
3948
- err.message || `HTTP error! Status: ${response.status}`
3949
- );
3950
- }
3951
- const json = await response.json();
3952
- if (!json.success || !json.data) {
3953
- throw new Error(json.error || "Import preview failed");
3954
- }
3955
- return json.data;
3956
- }
3957
- async importApply(tenantId, bundle, resolutions) {
3958
- const response = await this.request(
3959
- `/api/tenants/${tenantId}/import/apply`,
3960
- {
3961
- method: "POST",
3962
- body: JSON.stringify({ bundle, resolutions })
3963
- }
3964
- );
3965
- return response.data;
3966
- }
3967
- };
3968
-
3969
4131
  // src/ChunkMessageMerger.ts
3970
4132
  import { parse } from "best-effort-json-parser";
3971
4133
  function createSimpleMessageMerger() {