@axiom-lattice/client-sdk 4.0.0 → 4.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/dist/index.mjs CHANGED
@@ -2200,6 +2200,86 @@ var AbstractClient = class {
2200
2200
  return response.data;
2201
2201
  }
2202
2202
  };
2203
+ /** Agent Web Apps namespace for managing React SDK publications. */
2204
+ this.webApps = {
2205
+ /**
2206
+ * Lists Agent Web Apps, optionally filtered by assistant.
2207
+ * @param params - Optional assistant filter
2208
+ * @returns A promise that resolves to the publication records and total
2209
+ */
2210
+ list: async (params) => {
2211
+ const searchParams = new URLSearchParams();
2212
+ if (params?.assistantId) {
2213
+ searchParams.set("assistantId", params.assistantId);
2214
+ }
2215
+ const query = searchParams.toString();
2216
+ const response = await this.makeRequest(`/api/web-apps${query ? `?${query}` : ""}`);
2217
+ return {
2218
+ records: response.data.records.map((record) => this.hydrateAgentWebApp(record)),
2219
+ total: response.data.total
2220
+ };
2221
+ },
2222
+ /**
2223
+ * Retrieves an Agent Web App by ID.
2224
+ * @param id - Agent Web App identifier
2225
+ * @returns A promise that resolves to the publication
2226
+ */
2227
+ get: async (id) => {
2228
+ const response = await this.makeRequest(`/api/web-apps/${encodeURIComponent(id)}`);
2229
+ return this.hydrateAgentWebApp(response.data);
2230
+ },
2231
+ /**
2232
+ * Creates an Agent Web App.
2233
+ * @param input - Publication configuration
2234
+ * @returns A promise that resolves to the created publication
2235
+ */
2236
+ create: async (input) => {
2237
+ const response = await this.makeRequest("/api/web-apps", { method: "POST", body: input });
2238
+ return this.hydrateAgentWebApp(response.data);
2239
+ },
2240
+ /**
2241
+ * Updates editable fields on an Agent Web App.
2242
+ * @param id - Agent Web App identifier
2243
+ * @param input - Fields to update
2244
+ * @returns A promise that resolves to the updated publication
2245
+ */
2246
+ update: async (id, input) => {
2247
+ const response = await this.makeRequest(`/api/web-apps/${encodeURIComponent(id)}`, {
2248
+ method: "PATCH",
2249
+ body: input
2250
+ });
2251
+ return this.hydrateAgentWebApp(response.data);
2252
+ },
2253
+ /**
2254
+ * Enables an Agent Web App.
2255
+ * @param id - Agent Web App identifier
2256
+ * @returns A promise that resolves to the enabled publication
2257
+ */
2258
+ enable: async (id) => {
2259
+ const response = await this.makeRequest(`/api/web-apps/${encodeURIComponent(id)}/enable`, { method: "POST" });
2260
+ return this.hydrateAgentWebApp(response.data);
2261
+ },
2262
+ /**
2263
+ * Disables an Agent Web App.
2264
+ * @param id - Agent Web App identifier
2265
+ * @returns A promise that resolves to the disabled publication
2266
+ */
2267
+ disable: async (id) => {
2268
+ const response = await this.makeRequest(`/api/web-apps/${encodeURIComponent(id)}/disable`, { method: "POST" });
2269
+ return this.hydrateAgentWebApp(response.data);
2270
+ },
2271
+ /**
2272
+ * Permanently deletes an Agent Web App.
2273
+ * @param id - Agent Web App identifier
2274
+ * @returns A promise that resolves when the publication is deleted
2275
+ */
2276
+ delete: async (id) => {
2277
+ await this.makeRequest(
2278
+ `/api/web-apps/${encodeURIComponent(id)}`,
2279
+ { method: "DELETE" }
2280
+ );
2281
+ }
2282
+ };
2203
2283
  /**
2204
2284
  * Skills namespace for managing skills
2205
2285
  */
@@ -2772,6 +2852,27 @@ var AbstractClient = class {
2772
2852
  }
2773
2853
  };
2774
2854
  }
2855
+ hydrateAgentWebApp(value) {
2856
+ if (!value || typeof value !== "object" || Array.isArray(value)) {
2857
+ throw new ApiError("Invalid Agent Web App response", 500, value);
2858
+ }
2859
+ const record = value;
2860
+ const hydrateDate = (field) => {
2861
+ const raw = record[field];
2862
+ const date = raw instanceof Date ? new Date(raw.getTime()) : new Date(
2863
+ typeof raw === "string" || typeof raw === "number" ? raw : Number.NaN
2864
+ );
2865
+ if (Number.isNaN(date.getTime())) {
2866
+ throw new ApiError(`Invalid Agent Web App ${field}`, 500, value);
2867
+ }
2868
+ return date;
2869
+ };
2870
+ return {
2871
+ ...record,
2872
+ createdAt: hydrateDate("createdAt"),
2873
+ updatedAt: hydrateDate("updatedAt")
2874
+ };
2875
+ }
2775
2876
  /**
2776
2877
  * Set handler for 401 unauthorized errors
2777
2878
  * @param handler - Callback function to handle unauthorized errors