fireberry-api-client 1.0.2-beta.1.2 → 1.0.2-beta.1.3
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 +39 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +39 -10
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1420,10 +1420,18 @@ var SDKTransport = class {
|
|
|
1420
1420
|
}
|
|
1421
1421
|
);
|
|
1422
1422
|
}
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
(
|
|
1426
|
-
|
|
1423
|
+
let records = [];
|
|
1424
|
+
if (response.data && typeof response.data === "object") {
|
|
1425
|
+
if ("Data" in response.data && Array.isArray(response.data.Data)) {
|
|
1426
|
+
records = response.data.Data;
|
|
1427
|
+
} else if (Array.isArray(response.data)) {
|
|
1428
|
+
records = response.data.filter(
|
|
1429
|
+
(record) => record && typeof record === "object"
|
|
1430
|
+
);
|
|
1431
|
+
} else if (!("Columns" in response.data)) {
|
|
1432
|
+
records = [response.data];
|
|
1433
|
+
}
|
|
1434
|
+
}
|
|
1427
1435
|
return {
|
|
1428
1436
|
records,
|
|
1429
1437
|
total: records.length,
|
|
@@ -1573,10 +1581,18 @@ var SDKTransport = class {
|
|
|
1573
1581
|
}
|
|
1574
1582
|
);
|
|
1575
1583
|
}
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
(
|
|
1579
|
-
|
|
1584
|
+
let validRecords = [];
|
|
1585
|
+
if (response.data && typeof response.data === "object") {
|
|
1586
|
+
if ("Data" in response.data && Array.isArray(response.data.Data)) {
|
|
1587
|
+
validRecords = response.data.Data;
|
|
1588
|
+
} else if (Array.isArray(response.data)) {
|
|
1589
|
+
validRecords = response.data.filter(
|
|
1590
|
+
(record) => record && typeof record === "object"
|
|
1591
|
+
);
|
|
1592
|
+
} else if (!("Columns" in response.data)) {
|
|
1593
|
+
validRecords = [response.data];
|
|
1594
|
+
}
|
|
1595
|
+
}
|
|
1580
1596
|
allRecords.push(...validRecords);
|
|
1581
1597
|
if (limit && allRecords.length >= limit) {
|
|
1582
1598
|
allRecords.splice(limit);
|
|
@@ -1978,8 +1994,21 @@ var RecordsAPI = class {
|
|
|
1978
1994
|
if (existingRecords.length > 0) {
|
|
1979
1995
|
const existingRecord = existingRecords[0];
|
|
1980
1996
|
const idFieldName = getObjectIdFieldName(objectTypeStr);
|
|
1981
|
-
|
|
1982
|
-
|
|
1997
|
+
let recordId = existingRecord[idFieldName];
|
|
1998
|
+
if (recordId === void 0 || recordId === null) {
|
|
1999
|
+
const actualIdField = Object.keys(existingRecord).find(
|
|
2000
|
+
(key) => key.toLowerCase() === idFieldName.toLowerCase()
|
|
2001
|
+
);
|
|
2002
|
+
if (actualIdField) {
|
|
2003
|
+
recordId = existingRecord[actualIdField];
|
|
2004
|
+
}
|
|
2005
|
+
}
|
|
2006
|
+
if (recordId === void 0 || recordId === null) {
|
|
2007
|
+
throw new Error(
|
|
2008
|
+
`Could not find ID field "${idFieldName}" in existing record. Available fields: ${Object.keys(existingRecord).join(", ")}`
|
|
2009
|
+
);
|
|
2010
|
+
}
|
|
2011
|
+
const updatedRecord = await this.update(objectTypeStr, String(recordId), data, options);
|
|
1983
2012
|
return {
|
|
1984
2013
|
success: true,
|
|
1985
2014
|
operationType: "update",
|