wolfronix-sdk 2.3.0 → 2.4.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
@@ -1,3 +1,5 @@
1
+ import "./chunk-EDTKPA2L.mjs";
2
+
1
3
  // src/crypto.ts
2
4
  var getCrypto = () => {
3
5
  if (typeof globalThis.crypto !== "undefined") {
@@ -348,7 +350,7 @@ var Wolfronix = class {
348
350
  for (let attempt = 1; attempt <= this.config.retries; attempt++) {
349
351
  try {
350
352
  const controller = new AbortController();
351
- const timeoutId = setTimeout(() => controller.abort(), this.config.timeout);
353
+ const timeoutId = formData ? null : setTimeout(() => controller.abort(), this.config.timeout);
352
354
  const fetchOptions = {
353
355
  method,
354
356
  headers,
@@ -356,7 +358,7 @@ var Wolfronix = class {
356
358
  };
357
359
  if (this.config.insecure && typeof process !== "undefined") {
358
360
  try {
359
- const { Agent } = await import("undici");
361
+ const { Agent } = await import("./undici-BDVTXO27.mjs");
360
362
  fetchOptions.dispatcher = new Agent({
361
363
  connect: { rejectUnauthorized: false }
362
364
  });
@@ -369,7 +371,7 @@ var Wolfronix = class {
369
371
  fetchOptions.body = JSON.stringify(body);
370
372
  }
371
373
  const response = await fetch(url, fetchOptions);
372
- clearTimeout(timeoutId);
374
+ if (timeoutId) clearTimeout(timeoutId);
373
375
  if (!response.ok) {
374
376
  const errorBody = await response.json().catch(() => ({}));
375
377
  if (response.status === 401) {
@@ -575,10 +577,8 @@ var Wolfronix = class {
575
577
  formData
576
578
  });
577
579
  return {
578
- status: response.status,
579
- file_id: String(response.file_id),
580
- file_size: response.file_size,
581
- enc_time_ms: response.enc_time_ms
580
+ ...response,
581
+ file_id: String(response.file_id)
582
582
  };
583
583
  }
584
584
  /**
@@ -1135,6 +1135,98 @@ var WolfronixStream = class {
1135
1135
  function createClient(config) {
1136
1136
  return new Wolfronix(config);
1137
1137
  }
1138
+ var WolfronixAdmin = class {
1139
+ constructor(config) {
1140
+ this.baseUrl = config.baseUrl.replace(/\/$/, "");
1141
+ this.adminKey = config.adminKey;
1142
+ this.timeout = config.timeout || 3e4;
1143
+ this.insecure = config.insecure || false;
1144
+ }
1145
+ async request(method, endpoint, body) {
1146
+ const url = `${this.baseUrl}${endpoint}`;
1147
+ const headers = {
1148
+ "X-Admin-Key": this.adminKey,
1149
+ "Accept": "application/json"
1150
+ };
1151
+ if (body) {
1152
+ headers["Content-Type"] = "application/json";
1153
+ }
1154
+ const controller = new AbortController();
1155
+ const timeoutId = setTimeout(() => controller.abort(), this.timeout);
1156
+ const fetchOptions = {
1157
+ method,
1158
+ headers,
1159
+ signal: controller.signal
1160
+ };
1161
+ if (this.insecure && typeof process !== "undefined") {
1162
+ try {
1163
+ const { Agent } = await import("./undici-BDVTXO27.mjs");
1164
+ fetchOptions.dispatcher = new Agent({
1165
+ connect: { rejectUnauthorized: false }
1166
+ });
1167
+ } catch {
1168
+ }
1169
+ }
1170
+ if (body) {
1171
+ fetchOptions.body = JSON.stringify(body);
1172
+ }
1173
+ const response = await fetch(url, fetchOptions);
1174
+ clearTimeout(timeoutId);
1175
+ if (!response.ok) {
1176
+ const errorBody = await response.json().catch(() => ({}));
1177
+ throw new WolfronixError(
1178
+ errorBody.error || `Request failed with status ${response.status}`,
1179
+ "ADMIN_REQUEST_ERROR",
1180
+ response.status,
1181
+ errorBody
1182
+ );
1183
+ }
1184
+ return await response.json();
1185
+ }
1186
+ /**
1187
+ * Register a new enterprise client.
1188
+ * For managed connectors (supabase, mongodb, mysql, firebase, postgresql),
1189
+ * provide db_type + db_config. For custom APIs, use db_type: 'custom_api' + api_endpoint.
1190
+ */
1191
+ async registerClient(params) {
1192
+ return this.request("POST", "/api/v1/enterprise/register", params);
1193
+ }
1194
+ /**
1195
+ * List all registered enterprise clients.
1196
+ */
1197
+ async listClients() {
1198
+ return this.request("GET", "/api/v1/enterprise/clients");
1199
+ }
1200
+ /**
1201
+ * Get details for a specific client.
1202
+ */
1203
+ async getClient(clientId) {
1204
+ return this.request("GET", `/api/v1/enterprise/clients/${encodeURIComponent(clientId)}`);
1205
+ }
1206
+ /**
1207
+ * Update a client's configuration (api_endpoint, db_type, db_config).
1208
+ */
1209
+ async updateClient(clientId, params) {
1210
+ return this.request("PUT", `/api/v1/enterprise/clients/${encodeURIComponent(clientId)}`, params);
1211
+ }
1212
+ /**
1213
+ * Deactivate (soft-delete) a client. Their wolfronix_key will stop working.
1214
+ */
1215
+ async deactivateClient(clientId) {
1216
+ return this.request("DELETE", `/api/v1/enterprise/clients/${encodeURIComponent(clientId)}`);
1217
+ }
1218
+ /**
1219
+ * Check server health.
1220
+ */
1221
+ async healthCheck() {
1222
+ try {
1223
+ await this.request("GET", "/health");
1224
+ return true;
1225
+ } catch {
1226
+ return false;
1227
+ }
1228
+ }
1229
+ };
1138
1230
  var index_default = Wolfronix;
1139
1231
  export {
1140
1232
  AuthenticationError,
@@ -1143,6 +1235,7 @@ export {
1143
1235
  PermissionDeniedError,
1144
1236
  ValidationError,
1145
1237
  Wolfronix,
1238
+ WolfronixAdmin,
1146
1239
  WolfronixError,
1147
1240
  WolfronixStream,
1148
1241
  createClient,