fireberry-api-client 1.0.0-beta.2.3 → 1.0.0-beta.2.3.2

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/README.md CHANGED
@@ -120,7 +120,20 @@ const result = await client.queryBuilder()
120
120
  .limit(50)
121
121
  .execute();
122
122
 
123
+ // Query by ID - automatically uses correct field name for object type
124
+ const account = await client.queryBuilder()
125
+ .objectType(1)
126
+ .whereId('abc123') // Uses 'accountid' automatically
127
+ .execute();
128
+
129
+ // Works with any object type
130
+ const contact = await client.queryBuilder()
131
+ .objectType(2)
132
+ .whereId('xyz789') // Uses 'contactid' automatically
133
+ .execute();
134
+
123
135
  // Available conditions:
136
+ // .whereId(value) - Query by primary ID (auto-mapped field)
124
137
  // .equals(value) - Exact match
125
138
  // .notEquals(value) - Not equal
126
139
  // .lessThan(value) - Less than
@@ -348,7 +361,7 @@ getObjectIdFieldName('1000'); // 'customobject1000id'
348
361
  // Get display name field
349
362
  getNameFieldByObjectType('1'); // 'accountname'
350
363
  getNameFieldByObjectType('2'); // 'fullname' (Contact)
351
- getNameFieldByObjectType('14'); // 'productname' (Product)
364
+ getNameFieldByObjectType('14'); // 'name' (Product)
352
365
 
353
366
  // Get label field for a lookup/dropdown field
354
367
  getLabelFieldForField('accountid', '1'); // 'accountname'
@@ -369,10 +382,10 @@ isLookupField('6'); // true
369
382
  | 4 | Opportunity | opportunityid | name |
370
383
  | 5 | Case | casesid | title |
371
384
  | 6 | Activity | activityid | subject |
372
- | 7 | Note | noteid | subject |
385
+ | 7 | Note | noteid | notetext |
373
386
  | 10 | Task | taskid | subject |
374
- | 13 | CRM Order | crmorderid | name |
375
- | 14 | Product | productid | productname |
387
+ | 13 | CRM Order | crmorderid | crmordernumber |
388
+ | 14 | Product | productid | name |
376
389
  | 1000+ | Custom Objects | customobject{N}id | name |
377
390
 
378
391
  ## Error Handling
@@ -122,6 +122,27 @@ declare class QueryBuilder {
122
122
  * @param field - Field name to filter on
123
123
  */
124
124
  where(field: string): ConditionBuilder;
125
+ /**
126
+ * Adds a WHERE condition for the primary ID field, automatically mapped based on object type
127
+ * @param value - The ID value to match
128
+ * @throws Error if objectType is not set
129
+ *
130
+ * @example
131
+ * ```typescript
132
+ * // Instead of knowing the exact field name:
133
+ * new QueryBuilder(client)
134
+ * .objectType(1)
135
+ * .whereId('abc123') // Automatically uses 'accountid' for object type 1
136
+ * .execute();
137
+ *
138
+ * // Equivalent to:
139
+ * new QueryBuilder(client)
140
+ * .objectType(1)
141
+ * .where('accountid').equals('abc123')
142
+ * .execute();
143
+ * ```
144
+ */
145
+ whereId(value: string | number): this;
125
146
  /**
126
147
  * Adds an AND logical operator
127
148
  */
@@ -231,6 +252,7 @@ declare const FIELD_TYPE_MAPPINGS: Record<string, string>;
231
252
  /**
232
253
  * Object Type ID to Primary Key Field Mapping
233
254
  * Maps Fireberry object type IDs to their primary key field names
255
+ * Generated from actual API responses
234
256
  */
235
257
  declare const OBJECT_ID_MAP: Record<number, string>;
236
258
  /**
@@ -244,6 +266,7 @@ declare function getObjectIdFieldName(objectTypeId: string | number): string;
244
266
  /**
245
267
  * Object Type ID to Name Field Mapping
246
268
  * Maps Fireberry object type IDs to their display name field
269
+ * Generated from actual API responses
247
270
  */
248
271
  declare const OBJECT_NAME_MAP: Record<number, string>;
249
272
  /**
@@ -122,6 +122,27 @@ declare class QueryBuilder {
122
122
  * @param field - Field name to filter on
123
123
  */
124
124
  where(field: string): ConditionBuilder;
125
+ /**
126
+ * Adds a WHERE condition for the primary ID field, automatically mapped based on object type
127
+ * @param value - The ID value to match
128
+ * @throws Error if objectType is not set
129
+ *
130
+ * @example
131
+ * ```typescript
132
+ * // Instead of knowing the exact field name:
133
+ * new QueryBuilder(client)
134
+ * .objectType(1)
135
+ * .whereId('abc123') // Automatically uses 'accountid' for object type 1
136
+ * .execute();
137
+ *
138
+ * // Equivalent to:
139
+ * new QueryBuilder(client)
140
+ * .objectType(1)
141
+ * .where('accountid').equals('abc123')
142
+ * .execute();
143
+ * ```
144
+ */
145
+ whereId(value: string | number): this;
125
146
  /**
126
147
  * Adds an AND logical operator
127
148
  */
@@ -231,6 +252,7 @@ declare const FIELD_TYPE_MAPPINGS: Record<string, string>;
231
252
  /**
232
253
  * Object Type ID to Primary Key Field Mapping
233
254
  * Maps Fireberry object type IDs to their primary key field names
255
+ * Generated from actual API responses
234
256
  */
235
257
  declare const OBJECT_ID_MAP: Record<number, string>;
236
258
  /**
@@ -244,6 +266,7 @@ declare function getObjectIdFieldName(objectTypeId: string | number): string;
244
266
  /**
245
267
  * Object Type ID to Name Field Mapping
246
268
  * Maps Fireberry object type IDs to their display name field
269
+ * Generated from actual API responses
247
270
  */
248
271
  declare const OBJECT_NAME_MAP: Record<number, string>;
249
272
  /**
package/dist/index.cjs CHANGED
@@ -33,7 +33,7 @@ var init_excludedFields = __esm({
33
33
  exports.EXCLUDED_FIELDS_FOR_STAR_QUERY = {
34
34
  "7": ["deletedon", "deletedby"],
35
35
  // Note
36
- "8": ["deletedon", "deletedby"],
36
+ "8": ["deletedon", "deletedby", "s", "w", "o", "t", "description"],
37
37
  // Competitor
38
38
  "114": ["deletedon", "deletedby"],
39
39
  // Calendar Resource
@@ -188,6 +188,128 @@ function chunkArray(array, size) {
188
188
  return result;
189
189
  }
190
190
 
191
+ // src/constants/objectIds.ts
192
+ var OBJECT_ID_MAP = {
193
+ 1: "accountid",
194
+ // Account
195
+ 2: "contactid",
196
+ // Contact
197
+ 3: "leadid",
198
+ // Lead
199
+ 4: "opportunityid",
200
+ // Opportunity
201
+ 5: "casesid",
202
+ // Cases
203
+ 6: "activityid",
204
+ // Activity
205
+ 7: "noteid",
206
+ // Note
207
+ 8: "competitorid",
208
+ // Competitor
209
+ 9: "crmuserid",
210
+ // CrmUser
211
+ 10: "taskid",
212
+ // Task
213
+ 12: "quoteid",
214
+ // Quote
215
+ 13: "crmorderid",
216
+ // CrmOrder
217
+ 14: "productid",
218
+ // Product
219
+ 17: "crmorderitemid",
220
+ // CrmOrderItem
221
+ 20: "emailtemplateid",
222
+ // EmailTemplate
223
+ 23: "businessunitid",
224
+ // BusinessUnit
225
+ 25: "orgid",
226
+ // Org
227
+ 27: "printtemplateid",
228
+ // PrintTemplate
229
+ 28: "contractid",
230
+ // Contract
231
+ 33: "accountproductid",
232
+ // AccountProduct
233
+ 46: "projectid",
234
+ // Project
235
+ 55: "wfruleid",
236
+ // WFRule
237
+ 58: "mdobjectid",
238
+ // MDObject
239
+ 64: "roleid",
240
+ // Role
241
+ 67: "campaignid",
242
+ // Campaign
243
+ 70: "crmuserloginid",
244
+ // CrmUserLogin
245
+ 73: "systemfieldid",
246
+ // SystemField
247
+ 76: "articleid",
248
+ // Article
249
+ 77: "linkid",
250
+ // Link
251
+ 78: "invoiceid",
252
+ // Invoice
253
+ 80: "invoicereceiptitemid",
254
+ // InvoiceReceiptItem
255
+ 81: "invoiceid",
256
+ // InvoiceNo
257
+ 82: "invoiceid",
258
+ // InvoiceDraft
259
+ 83: "invoiceid",
260
+ // InvoiceReceipt
261
+ 84: "invoiceid",
262
+ // InvoiceReno
263
+ 85: "invoiceid",
264
+ // InvoiceCredit
265
+ 86: "invoiceid",
266
+ // InvoiceDelivery
267
+ 89: "iprestrictionid",
268
+ // IpRestriction
269
+ 90: "transactionitemid",
270
+ // TransactionItem
271
+ 93: "chargeid",
272
+ // Charge
273
+ 100: "calllogid",
274
+ // calllog
275
+ 101: "attendanceclockid",
276
+ // AttendanceClock
277
+ 102: "activitylogid",
278
+ // ActivityLog
279
+ 104: "conversationid",
280
+ // Conversation
281
+ 105: "teaminboxid",
282
+ // TeamInbox
283
+ 106: "texttemplateid",
284
+ // TextTemplate
285
+ 107: "facebookconnectionid",
286
+ // FacebookConnection
287
+ 109: "auditlogid",
288
+ // AuditLog
289
+ 110: "smstemplateid",
290
+ // SMSTemplate
291
+ 111: "providerverificationid",
292
+ // ProviderVerification
293
+ 114: "calendarresourceid",
294
+ // CalendarResource
295
+ 115: "journeyid",
296
+ // Journey
297
+ 116: "profileid",
298
+ // Profile
299
+ 117: "landingpageid"
300
+ // LandingPage
301
+ };
302
+ function getObjectIdFieldName(objectTypeId) {
303
+ const objectTypeNum = typeof objectTypeId === "string" ? parseInt(objectTypeId, 10) : objectTypeId;
304
+ if (OBJECT_ID_MAP[objectTypeNum]) {
305
+ return OBJECT_ID_MAP[objectTypeNum];
306
+ }
307
+ if (objectTypeNum >= 1e3) {
308
+ return `customobject${objectTypeNum}id`;
309
+ }
310
+ return "id";
311
+ }
312
+
191
313
  // src/utils/queryBuilder.ts
192
314
  function escapeQueryValue(value) {
193
315
  if (!value) {
@@ -278,6 +400,34 @@ var QueryBuilder = class {
278
400
  this.currentField = field;
279
401
  return this.createConditionBuilder();
280
402
  }
403
+ /**
404
+ * Adds a WHERE condition for the primary ID field, automatically mapped based on object type
405
+ * @param value - The ID value to match
406
+ * @throws Error if objectType is not set
407
+ *
408
+ * @example
409
+ * ```typescript
410
+ * // Instead of knowing the exact field name:
411
+ * new QueryBuilder(client)
412
+ * .objectType(1)
413
+ * .whereId('abc123') // Automatically uses 'accountid' for object type 1
414
+ * .execute();
415
+ *
416
+ * // Equivalent to:
417
+ * new QueryBuilder(client)
418
+ * .objectType(1)
419
+ * .where('accountid').equals('abc123')
420
+ * .execute();
421
+ * ```
422
+ */
423
+ whereId(value) {
424
+ if (!this.objectTypeId) {
425
+ throw new Error("Object type must be set before using whereId(). Call .objectType() first.");
426
+ }
427
+ const idField = getObjectIdFieldName(this.objectTypeId);
428
+ this.addCondition(idField, "=", String(value));
429
+ return this;
430
+ }
281
431
  /**
282
432
  * Adds an AND logical operator
283
433
  */
@@ -703,46 +853,6 @@ var MetadataAPI = class {
703
853
  }
704
854
  };
705
855
 
706
- // src/constants/objectIds.ts
707
- var OBJECT_ID_MAP = {
708
- 1: "accountid",
709
- 2: "contactid",
710
- 3: "leadid",
711
- 4: "opportunityid",
712
- 5: "casesid",
713
- 6: "activityid",
714
- 7: "noteid",
715
- 8: "competitorid",
716
- 9: "crmuserid",
717
- 10: "taskid",
718
- 13: "crmorderid",
719
- 14: "productid",
720
- 17: "crmorderitemid",
721
- 20: "emailtemplateid",
722
- 23: "businessunitid",
723
- 27: "printtemplateid",
724
- 28: "contractid",
725
- 33: "accountproductid",
726
- 46: "projectid",
727
- 67: "campaignid",
728
- 76: "articleid",
729
- 86: "invoiceid",
730
- 101: "attendanceclockid",
731
- 102: "activitylogid",
732
- 104: "conversationid",
733
- 114: "calendarresourceid"
734
- };
735
- function getObjectIdFieldName(objectTypeId) {
736
- const objectTypeNum = typeof objectTypeId === "string" ? parseInt(objectTypeId, 10) : objectTypeId;
737
- if (OBJECT_ID_MAP[objectTypeNum]) {
738
- return OBJECT_ID_MAP[objectTypeNum];
739
- }
740
- if (objectTypeNum >= 1e3) {
741
- return `customobject${objectTypeNum}id`;
742
- }
743
- return "id";
744
- }
745
-
746
856
  // src/api/records.ts
747
857
  var RecordsAPI = class {
748
858
  constructor(client) {
@@ -1604,49 +1714,105 @@ var OBJECT_NAME_MAP = {
1604
1714
  4: "name",
1605
1715
  // Opportunity
1606
1716
  5: "title",
1607
- // Case
1717
+ // Cases
1608
1718
  6: "subject",
1609
1719
  // Activity
1610
- 7: "subject",
1720
+ 7: "notetext",
1611
1721
  // Note
1612
- 8: "name",
1722
+ 8: "competitorname",
1613
1723
  // Competitor
1614
1724
  9: "fullname",
1615
- // CRM User
1725
+ // CrmUser
1616
1726
  10: "subject",
1617
1727
  // Task
1618
- 13: "name",
1619
- // CRM Order
1620
- 14: "productname",
1728
+ 12: "quotenumber",
1729
+ // Quote
1730
+ 13: "crmordernumber",
1731
+ // CrmOrder
1732
+ 14: "name",
1621
1733
  // Product
1622
1734
  17: "productname",
1623
- // CRM Order Item
1624
- 20: "name",
1625
- // Email Template
1735
+ // CrmOrderItem
1736
+ 20: "title",
1737
+ // EmailTemplate
1626
1738
  23: "name",
1627
- // Business Unit
1739
+ // BusinessUnit
1740
+ 25: "orgname",
1741
+ // Org
1628
1742
  27: "name",
1629
- // Print Template
1630
- 28: "name",
1743
+ // PrintTemplate
1744
+ 28: "contractname",
1631
1745
  // Contract
1632
- 33: "productname",
1633
- // Account Product
1634
- 46: "name",
1746
+ 33: "productid",
1747
+ // AccountProduct (uses productid as display)
1748
+ 46: "projectname",
1635
1749
  // Project
1636
- 67: "name",
1750
+ 55: "rulename",
1751
+ // WFRule
1752
+ 58: "name",
1753
+ // MDObject
1754
+ 64: "rolename",
1755
+ // Role
1756
+ 67: "campaignname",
1637
1757
  // Campaign
1638
- 76: "title",
1758
+ 70: "browsername",
1759
+ // CrmUserLogin
1760
+ 73: "label",
1761
+ // SystemField (using label as name field)
1762
+ 76: "articlename",
1639
1763
  // Article
1640
- 86: "name",
1764
+ 77: "linkname",
1765
+ // Link
1766
+ 78: "invoicenumber",
1641
1767
  // Invoice
1768
+ 80: "documentnumber",
1769
+ // InvoiceReceiptItem
1770
+ 81: "invoicenumber",
1771
+ // InvoiceNo
1772
+ 82: "invoicenumber",
1773
+ // InvoiceDraft
1774
+ 83: "invoicenumber",
1775
+ // InvoiceReceipt
1776
+ 84: "invoicenumber",
1777
+ // InvoiceReno
1778
+ 85: "invoicenumber",
1779
+ // InvoiceCredit
1780
+ 86: "invoicenumber",
1781
+ // InvoiceDelivery
1782
+ 89: "name",
1783
+ // IpRestriction
1784
+ 90: "documentnumber",
1785
+ // TransactionItem
1786
+ 93: "name",
1787
+ // Charge
1788
+ 100: "callerid",
1789
+ // calllog
1642
1790
  101: "name",
1643
- // Attendance Clock
1644
- 102: "subject",
1645
- // Activity Log
1791
+ // AttendanceClock
1792
+ 102: "activitylognumber",
1793
+ // ActivityLog
1646
1794
  104: "subject",
1647
1795
  // Conversation
1648
- 114: "name"
1649
- // Calendar Resource
1796
+ 105: "name",
1797
+ // TeamInbox
1798
+ 106: "name",
1799
+ // TextTemplate
1800
+ 107: "name",
1801
+ // FacebookConnection
1802
+ 109: "name",
1803
+ // AuditLog
1804
+ 110: "name",
1805
+ // SMSTemplate
1806
+ 111: "name",
1807
+ // ProviderVerification
1808
+ 114: "name",
1809
+ // CalendarResource
1810
+ 115: "name",
1811
+ // Journey
1812
+ 116: "name",
1813
+ // Profile
1814
+ 117: "name"
1815
+ // LandingPage
1650
1816
  };
1651
1817
 
1652
1818
  // src/constants/index.ts