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