fireberry-api-client 1.0.2-beta.1.2 → 1.0.2-beta.1.4
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.cjs +58 -13
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +58 -13
- package/dist/index.js.map +1 -1
- package/dist/{relatedFieldMapping-uUVpIJk9.d.cts → relatedFieldMapping-BvTlofIU.d.cts} +2 -1
- package/dist/{relatedFieldMapping-6o0SKPT2.d.ts → relatedFieldMapping-D0fbCEeA.d.ts} +2 -1
- package/dist/utils/index.d.cts +2 -2
- package/dist/utils/index.d.ts +2 -2
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1296,14 +1296,20 @@ var HTTPTransport = class {
|
|
|
1296
1296
|
};
|
|
1297
1297
|
}
|
|
1298
1298
|
/**
|
|
1299
|
-
* Executes a fetch request with retry logic for 429 errors
|
|
1299
|
+
* Executes a fetch request with retry logic for 429 errors and timeouts
|
|
1300
|
+
* Implements exponential backoff for timeout duration
|
|
1300
1301
|
*/
|
|
1301
1302
|
async executeWithRetry(url, options, retryCount = 0) {
|
|
1302
1303
|
try {
|
|
1304
|
+
const maxTimeout = 3e5;
|
|
1305
|
+
const currentTimeout = Math.min(
|
|
1306
|
+
this.config.timeout * Math.pow(2, retryCount),
|
|
1307
|
+
maxTimeout
|
|
1308
|
+
);
|
|
1303
1309
|
const timeoutController = new AbortController();
|
|
1304
1310
|
const timeoutId = setTimeout(() => {
|
|
1305
1311
|
timeoutController.abort();
|
|
1306
|
-
},
|
|
1312
|
+
}, currentTimeout);
|
|
1307
1313
|
const combinedSignal = options.signal ? this.combineSignals([options.signal, timeoutController.signal]) : timeoutController.signal;
|
|
1308
1314
|
const response = await fetch(url, {
|
|
1309
1315
|
...options,
|
|
@@ -1334,7 +1340,17 @@ var HTTPTransport = class {
|
|
|
1334
1340
|
return body;
|
|
1335
1341
|
} catch (error) {
|
|
1336
1342
|
if (error instanceof Error && error.name === "AbortError") {
|
|
1337
|
-
|
|
1343
|
+
if (options.signal?.aborted) {
|
|
1344
|
+
throw createNetworkError(error);
|
|
1345
|
+
}
|
|
1346
|
+
if (this.config.retryOn429 && retryCount < this.config.maxRetries) {
|
|
1347
|
+
await wait(this.config.retryDelay);
|
|
1348
|
+
return this.executeWithRetry(url, options, retryCount + 1);
|
|
1349
|
+
}
|
|
1350
|
+
throw new FireberryError("Request timeout after max retries", {
|
|
1351
|
+
code: "TIMEOUT" /* TIMEOUT */,
|
|
1352
|
+
context: { retryCount }
|
|
1353
|
+
});
|
|
1338
1354
|
}
|
|
1339
1355
|
if (error instanceof FireberryError) {
|
|
1340
1356
|
throw error;
|
|
@@ -1422,10 +1438,18 @@ var SDKTransport = class {
|
|
|
1422
1438
|
}
|
|
1423
1439
|
);
|
|
1424
1440
|
}
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
(
|
|
1428
|
-
|
|
1441
|
+
let records = [];
|
|
1442
|
+
if (response.data && typeof response.data === "object") {
|
|
1443
|
+
if ("Data" in response.data && Array.isArray(response.data.Data)) {
|
|
1444
|
+
records = response.data.Data;
|
|
1445
|
+
} else if (Array.isArray(response.data)) {
|
|
1446
|
+
records = response.data.filter(
|
|
1447
|
+
(record) => record && typeof record === "object"
|
|
1448
|
+
);
|
|
1449
|
+
} else if (!("Columns" in response.data)) {
|
|
1450
|
+
records = [response.data];
|
|
1451
|
+
}
|
|
1452
|
+
}
|
|
1429
1453
|
return {
|
|
1430
1454
|
records,
|
|
1431
1455
|
total: records.length,
|
|
@@ -1575,10 +1599,18 @@ var SDKTransport = class {
|
|
|
1575
1599
|
}
|
|
1576
1600
|
);
|
|
1577
1601
|
}
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
(
|
|
1581
|
-
|
|
1602
|
+
let validRecords = [];
|
|
1603
|
+
if (response.data && typeof response.data === "object") {
|
|
1604
|
+
if ("Data" in response.data && Array.isArray(response.data.Data)) {
|
|
1605
|
+
validRecords = response.data.Data;
|
|
1606
|
+
} else if (Array.isArray(response.data)) {
|
|
1607
|
+
validRecords = response.data.filter(
|
|
1608
|
+
(record) => record && typeof record === "object"
|
|
1609
|
+
);
|
|
1610
|
+
} else if (!("Columns" in response.data)) {
|
|
1611
|
+
validRecords = [response.data];
|
|
1612
|
+
}
|
|
1613
|
+
}
|
|
1582
1614
|
allRecords.push(...validRecords);
|
|
1583
1615
|
if (limit && allRecords.length >= limit) {
|
|
1584
1616
|
allRecords.splice(limit);
|
|
@@ -1980,8 +2012,21 @@ var RecordsAPI = class {
|
|
|
1980
2012
|
if (existingRecords.length > 0) {
|
|
1981
2013
|
const existingRecord = existingRecords[0];
|
|
1982
2014
|
const idFieldName = getObjectIdFieldName(objectTypeStr);
|
|
1983
|
-
|
|
1984
|
-
|
|
2015
|
+
let recordId = existingRecord[idFieldName];
|
|
2016
|
+
if (recordId === void 0 || recordId === null) {
|
|
2017
|
+
const actualIdField = Object.keys(existingRecord).find(
|
|
2018
|
+
(key) => key.toLowerCase() === idFieldName.toLowerCase()
|
|
2019
|
+
);
|
|
2020
|
+
if (actualIdField) {
|
|
2021
|
+
recordId = existingRecord[actualIdField];
|
|
2022
|
+
}
|
|
2023
|
+
}
|
|
2024
|
+
if (recordId === void 0 || recordId === null) {
|
|
2025
|
+
throw new Error(
|
|
2026
|
+
`Could not find ID field "${idFieldName}" in existing record. Available fields: ${Object.keys(existingRecord).join(", ")}`
|
|
2027
|
+
);
|
|
2028
|
+
}
|
|
2029
|
+
const updatedRecord = await this.update(objectTypeStr, String(recordId), data, options);
|
|
1985
2030
|
return {
|
|
1986
2031
|
success: true,
|
|
1987
2032
|
operationType: "update",
|