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.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- export { B as BatchCreateOptions, o as BatchDeleteOptions, s as BatchDeleteResult, q as BatchResult, m as BatchUpdateOptions, n as BatchUpdateRecord, C as CacheControl, O as CreateFieldOptions, z as CreateFieldOptionsBase, Q as CreateFieldResult, y as CreateFieldType, M as CreateFormulaFieldOptions, H as CreateLookupFieldOptions, E as CreateNumberFieldOptions, j as CreateOptions, J as CreatePicklistFieldOptions, N as CreateSimpleFieldOptions, K as CreateSummaryFieldOptions, A as CreateTextFieldOptions, D as DeleteOptions, d as FieldMetadataMap, v as FieldValue, T as FileUploadOptions, V as FileUploadResult, F as FireberryClient, f as FireberryClientConfig, u as FireberryField, t as FireberryObject, i as FireberryRecord, L as FormulaFieldType, x as GetFieldValuesResult, w as GetFieldsResult, G as GetObjectsResult, Y as HTTPTransportConfig, I as ID_FIELD_TO_OBJECT_TYPE, P as PicklistValue, b as RelatedFieldInfo, c as RelatedFieldResolution, R as RelatedFieldResolver, h as RequestOptions, Z as SDKTransportConfig, S as SummaryType, W as Transport, _ as TransportConfig, X as TransportRequestOptions, U as UpdateOptions, k as UpsertOptions, l as UpsertResult, e as expandRelatedFields, a as getObjectTypeFromReferenceField, g as getRelatedFieldInfo, $ as isHTTPTransportConfig, a0 as isSDKTransportConfig, p as parseRelatedField, r as resolveRelatedField } from './relatedFieldMapping-uUVpIJk9.cjs';
1
+ export { B as BatchCreateOptions, o as BatchDeleteOptions, s as BatchDeleteResult, q as BatchResult, m as BatchUpdateOptions, n as BatchUpdateRecord, C as CacheControl, O as CreateFieldOptions, z as CreateFieldOptionsBase, Q as CreateFieldResult, y as CreateFieldType, M as CreateFormulaFieldOptions, H as CreateLookupFieldOptions, E as CreateNumberFieldOptions, j as CreateOptions, J as CreatePicklistFieldOptions, N as CreateSimpleFieldOptions, K as CreateSummaryFieldOptions, A as CreateTextFieldOptions, D as DeleteOptions, d as FieldMetadataMap, v as FieldValue, T as FileUploadOptions, V as FileUploadResult, F as FireberryClient, f as FireberryClientConfig, u as FireberryField, t as FireberryObject, i as FireberryRecord, L as FormulaFieldType, x as GetFieldValuesResult, w as GetFieldsResult, G as GetObjectsResult, Y as HTTPTransportConfig, I as ID_FIELD_TO_OBJECT_TYPE, P as PicklistValue, b as RelatedFieldInfo, c as RelatedFieldResolution, R as RelatedFieldResolver, h as RequestOptions, Z as SDKTransportConfig, S as SummaryType, W as Transport, _ as TransportConfig, X as TransportRequestOptions, U as UpdateOptions, k as UpsertOptions, l as UpsertResult, e as expandRelatedFields, a as getObjectTypeFromReferenceField, g as getRelatedFieldInfo, $ as isHTTPTransportConfig, a0 as isSDKTransportConfig, p as parseRelatedField, r as resolveRelatedField } from './relatedFieldMapping-BvTlofIU.cjs';
2
2
  export { E as EXCLUDED_FIELDS_FOR_STAR_QUERY, l as FIELD_TYPE_IDS, m as FIELD_TYPE_MAPPINGS, i as FireberrySDKAPI, F as FireberrySDKClient, O as OBJECT_ID_MAP, n as OBJECT_NAME_MAP, Q as QueryBuilder, c as QueryConditionItem, h as QueryExplainResult, f as QueryItem, g as QueryOperator, a as QueryOptions, b as QueryResult, d as QuerySeparatorItem, k as SDKContext, S as SDKQueryPayload, j as SDKResponseData, e as escapeQueryValue, s as sanitizeQuery } from './excludedFields-Dk-ILROQ.cjs';
3
3
 
4
4
  /**
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { B as BatchCreateOptions, o as BatchDeleteOptions, s as BatchDeleteResult, q as BatchResult, m as BatchUpdateOptions, n as BatchUpdateRecord, C as CacheControl, O as CreateFieldOptions, z as CreateFieldOptionsBase, Q as CreateFieldResult, y as CreateFieldType, M as CreateFormulaFieldOptions, H as CreateLookupFieldOptions, E as CreateNumberFieldOptions, j as CreateOptions, J as CreatePicklistFieldOptions, N as CreateSimpleFieldOptions, K as CreateSummaryFieldOptions, A as CreateTextFieldOptions, D as DeleteOptions, d as FieldMetadataMap, v as FieldValue, T as FileUploadOptions, V as FileUploadResult, F as FireberryClient, f as FireberryClientConfig, u as FireberryField, t as FireberryObject, i as FireberryRecord, L as FormulaFieldType, x as GetFieldValuesResult, w as GetFieldsResult, G as GetObjectsResult, Y as HTTPTransportConfig, I as ID_FIELD_TO_OBJECT_TYPE, P as PicklistValue, b as RelatedFieldInfo, c as RelatedFieldResolution, R as RelatedFieldResolver, h as RequestOptions, Z as SDKTransportConfig, S as SummaryType, W as Transport, _ as TransportConfig, X as TransportRequestOptions, U as UpdateOptions, k as UpsertOptions, l as UpsertResult, e as expandRelatedFields, a as getObjectTypeFromReferenceField, g as getRelatedFieldInfo, $ as isHTTPTransportConfig, a0 as isSDKTransportConfig, p as parseRelatedField, r as resolveRelatedField } from './relatedFieldMapping-6o0SKPT2.js';
1
+ export { B as BatchCreateOptions, o as BatchDeleteOptions, s as BatchDeleteResult, q as BatchResult, m as BatchUpdateOptions, n as BatchUpdateRecord, C as CacheControl, O as CreateFieldOptions, z as CreateFieldOptionsBase, Q as CreateFieldResult, y as CreateFieldType, M as CreateFormulaFieldOptions, H as CreateLookupFieldOptions, E as CreateNumberFieldOptions, j as CreateOptions, J as CreatePicklistFieldOptions, N as CreateSimpleFieldOptions, K as CreateSummaryFieldOptions, A as CreateTextFieldOptions, D as DeleteOptions, d as FieldMetadataMap, v as FieldValue, T as FileUploadOptions, V as FileUploadResult, F as FireberryClient, f as FireberryClientConfig, u as FireberryField, t as FireberryObject, i as FireberryRecord, L as FormulaFieldType, x as GetFieldValuesResult, w as GetFieldsResult, G as GetObjectsResult, Y as HTTPTransportConfig, I as ID_FIELD_TO_OBJECT_TYPE, P as PicklistValue, b as RelatedFieldInfo, c as RelatedFieldResolution, R as RelatedFieldResolver, h as RequestOptions, Z as SDKTransportConfig, S as SummaryType, W as Transport, _ as TransportConfig, X as TransportRequestOptions, U as UpdateOptions, k as UpsertOptions, l as UpsertResult, e as expandRelatedFields, a as getObjectTypeFromReferenceField, g as getRelatedFieldInfo, $ as isHTTPTransportConfig, a0 as isSDKTransportConfig, p as parseRelatedField, r as resolveRelatedField } from './relatedFieldMapping-D0fbCEeA.js';
2
2
  export { E as EXCLUDED_FIELDS_FOR_STAR_QUERY, l as FIELD_TYPE_IDS, m as FIELD_TYPE_MAPPINGS, i as FireberrySDKAPI, F as FireberrySDKClient, O as OBJECT_ID_MAP, n as OBJECT_NAME_MAP, Q as QueryBuilder, c as QueryConditionItem, h as QueryExplainResult, f as QueryItem, g as QueryOperator, a as QueryOptions, b as QueryResult, d as QuerySeparatorItem, k as SDKContext, S as SDKQueryPayload, j as SDKResponseData, e as escapeQueryValue, s as sanitizeQuery } from './excludedFields-Dk-ILROQ.js';
3
3
 
4
4
  /**
package/dist/index.js CHANGED
@@ -1294,14 +1294,20 @@ var HTTPTransport = class {
1294
1294
  };
1295
1295
  }
1296
1296
  /**
1297
- * Executes a fetch request with retry logic for 429 errors
1297
+ * Executes a fetch request with retry logic for 429 errors and timeouts
1298
+ * Implements exponential backoff for timeout duration
1298
1299
  */
1299
1300
  async executeWithRetry(url, options, retryCount = 0) {
1300
1301
  try {
1302
+ const maxTimeout = 3e5;
1303
+ const currentTimeout = Math.min(
1304
+ this.config.timeout * Math.pow(2, retryCount),
1305
+ maxTimeout
1306
+ );
1301
1307
  const timeoutController = new AbortController();
1302
1308
  const timeoutId = setTimeout(() => {
1303
1309
  timeoutController.abort();
1304
- }, this.config.timeout);
1310
+ }, currentTimeout);
1305
1311
  const combinedSignal = options.signal ? this.combineSignals([options.signal, timeoutController.signal]) : timeoutController.signal;
1306
1312
  const response = await fetch(url, {
1307
1313
  ...options,
@@ -1332,7 +1338,17 @@ var HTTPTransport = class {
1332
1338
  return body;
1333
1339
  } catch (error) {
1334
1340
  if (error instanceof Error && error.name === "AbortError") {
1335
- throw createNetworkError(error);
1341
+ if (options.signal?.aborted) {
1342
+ throw createNetworkError(error);
1343
+ }
1344
+ if (this.config.retryOn429 && retryCount < this.config.maxRetries) {
1345
+ await wait(this.config.retryDelay);
1346
+ return this.executeWithRetry(url, options, retryCount + 1);
1347
+ }
1348
+ throw new FireberryError("Request timeout after max retries", {
1349
+ code: "TIMEOUT" /* TIMEOUT */,
1350
+ context: { retryCount }
1351
+ });
1336
1352
  }
1337
1353
  if (error instanceof FireberryError) {
1338
1354
  throw error;
@@ -1420,10 +1436,18 @@ var SDKTransport = class {
1420
1436
  }
1421
1437
  );
1422
1438
  }
1423
- const pageData = Array.isArray(response.data) ? response.data : [response.data];
1424
- const records = pageData.filter(
1425
- (record) => record && typeof record === "object"
1426
- );
1439
+ let records = [];
1440
+ if (response.data && typeof response.data === "object") {
1441
+ if ("Data" in response.data && Array.isArray(response.data.Data)) {
1442
+ records = response.data.Data;
1443
+ } else if (Array.isArray(response.data)) {
1444
+ records = response.data.filter(
1445
+ (record) => record && typeof record === "object"
1446
+ );
1447
+ } else if (!("Columns" in response.data)) {
1448
+ records = [response.data];
1449
+ }
1450
+ }
1427
1451
  return {
1428
1452
  records,
1429
1453
  total: records.length,
@@ -1573,10 +1597,18 @@ var SDKTransport = class {
1573
1597
  }
1574
1598
  );
1575
1599
  }
1576
- const pageData = Array.isArray(response.data) ? response.data : [response.data];
1577
- const validRecords = pageData.filter(
1578
- (record) => record && typeof record === "object"
1579
- );
1600
+ let validRecords = [];
1601
+ if (response.data && typeof response.data === "object") {
1602
+ if ("Data" in response.data && Array.isArray(response.data.Data)) {
1603
+ validRecords = response.data.Data;
1604
+ } else if (Array.isArray(response.data)) {
1605
+ validRecords = response.data.filter(
1606
+ (record) => record && typeof record === "object"
1607
+ );
1608
+ } else if (!("Columns" in response.data)) {
1609
+ validRecords = [response.data];
1610
+ }
1611
+ }
1580
1612
  allRecords.push(...validRecords);
1581
1613
  if (limit && allRecords.length >= limit) {
1582
1614
  allRecords.splice(limit);
@@ -1978,8 +2010,21 @@ var RecordsAPI = class {
1978
2010
  if (existingRecords.length > 0) {
1979
2011
  const existingRecord = existingRecords[0];
1980
2012
  const idFieldName = getObjectIdFieldName(objectTypeStr);
1981
- const recordId = String(existingRecord[idFieldName]);
1982
- const updatedRecord = await this.update(objectTypeStr, recordId, data, options);
2013
+ let recordId = existingRecord[idFieldName];
2014
+ if (recordId === void 0 || recordId === null) {
2015
+ const actualIdField = Object.keys(existingRecord).find(
2016
+ (key) => key.toLowerCase() === idFieldName.toLowerCase()
2017
+ );
2018
+ if (actualIdField) {
2019
+ recordId = existingRecord[actualIdField];
2020
+ }
2021
+ }
2022
+ if (recordId === void 0 || recordId === null) {
2023
+ throw new Error(
2024
+ `Could not find ID field "${idFieldName}" in existing record. Available fields: ${Object.keys(existingRecord).join(", ")}`
2025
+ );
2026
+ }
2027
+ const updatedRecord = await this.update(objectTypeStr, String(recordId), data, options);
1983
2028
  return {
1984
2029
  success: true,
1985
2030
  operationType: "update",