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.
@@ -1,5 +1,127 @@
1
1
  'use strict';
2
2
 
3
+ // src/constants/objectIds.ts
4
+ var OBJECT_ID_MAP = {
5
+ 1: "accountid",
6
+ // Account
7
+ 2: "contactid",
8
+ // Contact
9
+ 3: "leadid",
10
+ // Lead
11
+ 4: "opportunityid",
12
+ // Opportunity
13
+ 5: "casesid",
14
+ // Cases
15
+ 6: "activityid",
16
+ // Activity
17
+ 7: "noteid",
18
+ // Note
19
+ 8: "competitorid",
20
+ // Competitor
21
+ 9: "crmuserid",
22
+ // CrmUser
23
+ 10: "taskid",
24
+ // Task
25
+ 12: "quoteid",
26
+ // Quote
27
+ 13: "crmorderid",
28
+ // CrmOrder
29
+ 14: "productid",
30
+ // Product
31
+ 17: "crmorderitemid",
32
+ // CrmOrderItem
33
+ 20: "emailtemplateid",
34
+ // EmailTemplate
35
+ 23: "businessunitid",
36
+ // BusinessUnit
37
+ 25: "orgid",
38
+ // Org
39
+ 27: "printtemplateid",
40
+ // PrintTemplate
41
+ 28: "contractid",
42
+ // Contract
43
+ 33: "accountproductid",
44
+ // AccountProduct
45
+ 46: "projectid",
46
+ // Project
47
+ 55: "wfruleid",
48
+ // WFRule
49
+ 58: "mdobjectid",
50
+ // MDObject
51
+ 64: "roleid",
52
+ // Role
53
+ 67: "campaignid",
54
+ // Campaign
55
+ 70: "crmuserloginid",
56
+ // CrmUserLogin
57
+ 73: "systemfieldid",
58
+ // SystemField
59
+ 76: "articleid",
60
+ // Article
61
+ 77: "linkid",
62
+ // Link
63
+ 78: "invoiceid",
64
+ // Invoice
65
+ 80: "invoicereceiptitemid",
66
+ // InvoiceReceiptItem
67
+ 81: "invoiceid",
68
+ // InvoiceNo
69
+ 82: "invoiceid",
70
+ // InvoiceDraft
71
+ 83: "invoiceid",
72
+ // InvoiceReceipt
73
+ 84: "invoiceid",
74
+ // InvoiceReno
75
+ 85: "invoiceid",
76
+ // InvoiceCredit
77
+ 86: "invoiceid",
78
+ // InvoiceDelivery
79
+ 89: "iprestrictionid",
80
+ // IpRestriction
81
+ 90: "transactionitemid",
82
+ // TransactionItem
83
+ 93: "chargeid",
84
+ // Charge
85
+ 100: "calllogid",
86
+ // calllog
87
+ 101: "attendanceclockid",
88
+ // AttendanceClock
89
+ 102: "activitylogid",
90
+ // ActivityLog
91
+ 104: "conversationid",
92
+ // Conversation
93
+ 105: "teaminboxid",
94
+ // TeamInbox
95
+ 106: "texttemplateid",
96
+ // TextTemplate
97
+ 107: "facebookconnectionid",
98
+ // FacebookConnection
99
+ 109: "auditlogid",
100
+ // AuditLog
101
+ 110: "smstemplateid",
102
+ // SMSTemplate
103
+ 111: "providerverificationid",
104
+ // ProviderVerification
105
+ 114: "calendarresourceid",
106
+ // CalendarResource
107
+ 115: "journeyid",
108
+ // Journey
109
+ 116: "profileid",
110
+ // Profile
111
+ 117: "landingpageid"
112
+ // LandingPage
113
+ };
114
+ function getObjectIdFieldName(objectTypeId) {
115
+ const objectTypeNum = typeof objectTypeId === "string" ? parseInt(objectTypeId, 10) : objectTypeId;
116
+ if (OBJECT_ID_MAP[objectTypeNum]) {
117
+ return OBJECT_ID_MAP[objectTypeNum];
118
+ }
119
+ if (objectTypeNum >= 1e3) {
120
+ return `customobject${objectTypeNum}id`;
121
+ }
122
+ return "id";
123
+ }
124
+
3
125
  // src/utils/queryBuilder.ts
4
126
  function escapeQueryValue(value) {
5
127
  if (!value) {
@@ -90,6 +212,34 @@ var QueryBuilder = class {
90
212
  this.currentField = field;
91
213
  return this.createConditionBuilder();
92
214
  }
215
+ /**
216
+ * Adds a WHERE condition for the primary ID field, automatically mapped based on object type
217
+ * @param value - The ID value to match
218
+ * @throws Error if objectType is not set
219
+ *
220
+ * @example
221
+ * ```typescript
222
+ * // Instead of knowing the exact field name:
223
+ * new QueryBuilder(client)
224
+ * .objectType(1)
225
+ * .whereId('abc123') // Automatically uses 'accountid' for object type 1
226
+ * .execute();
227
+ *
228
+ * // Equivalent to:
229
+ * new QueryBuilder(client)
230
+ * .objectType(1)
231
+ * .where('accountid').equals('abc123')
232
+ * .execute();
233
+ * ```
234
+ */
235
+ whereId(value) {
236
+ if (!this.objectTypeId) {
237
+ throw new Error("Object type must be set before using whereId(). Call .objectType() first.");
238
+ }
239
+ const idField = getObjectIdFieldName(this.objectTypeId);
240
+ this.addCondition(idField, "=", String(value));
241
+ return this;
242
+ }
93
243
  /**
94
244
  * Adds an AND logical operator
95
245
  */
@@ -513,46 +663,6 @@ function getLabelFieldForField(fieldName, objectType) {
513
663
  return `${fieldName}name`;
514
664
  }
515
665
 
516
- // src/constants/objectIds.ts
517
- var OBJECT_ID_MAP = {
518
- 1: "accountid",
519
- 2: "contactid",
520
- 3: "leadid",
521
- 4: "opportunityid",
522
- 5: "casesid",
523
- 6: "activityid",
524
- 7: "noteid",
525
- 8: "competitorid",
526
- 9: "crmuserid",
527
- 10: "taskid",
528
- 13: "crmorderid",
529
- 14: "productid",
530
- 17: "crmorderitemid",
531
- 20: "emailtemplateid",
532
- 23: "businessunitid",
533
- 27: "printtemplateid",
534
- 28: "contractid",
535
- 33: "accountproductid",
536
- 46: "projectid",
537
- 67: "campaignid",
538
- 76: "articleid",
539
- 86: "invoiceid",
540
- 101: "attendanceclockid",
541
- 102: "activitylogid",
542
- 104: "conversationid",
543
- 114: "calendarresourceid"
544
- };
545
- function getObjectIdFieldName(objectTypeId) {
546
- const objectTypeNum = typeof objectTypeId === "string" ? parseInt(objectTypeId, 10) : objectTypeId;
547
- if (OBJECT_ID_MAP[objectTypeNum]) {
548
- return OBJECT_ID_MAP[objectTypeNum];
549
- }
550
- if (objectTypeNum >= 1e3) {
551
- return `customobject${objectTypeNum}id`;
552
- }
553
- return "id";
554
- }
555
-
556
666
  // src/constants/objectNames.ts
557
667
  var OBJECT_NAME_MAP = {
558
668
  1: "accountname",
@@ -564,49 +674,105 @@ var OBJECT_NAME_MAP = {
564
674
  4: "name",
565
675
  // Opportunity
566
676
  5: "title",
567
- // Case
677
+ // Cases
568
678
  6: "subject",
569
679
  // Activity
570
- 7: "subject",
680
+ 7: "notetext",
571
681
  // Note
572
- 8: "name",
682
+ 8: "competitorname",
573
683
  // Competitor
574
684
  9: "fullname",
575
- // CRM User
685
+ // CrmUser
576
686
  10: "subject",
577
687
  // Task
578
- 13: "name",
579
- // CRM Order
580
- 14: "productname",
688
+ 12: "quotenumber",
689
+ // Quote
690
+ 13: "crmordernumber",
691
+ // CrmOrder
692
+ 14: "name",
581
693
  // Product
582
694
  17: "productname",
583
- // CRM Order Item
584
- 20: "name",
585
- // Email Template
695
+ // CrmOrderItem
696
+ 20: "title",
697
+ // EmailTemplate
586
698
  23: "name",
587
- // Business Unit
699
+ // BusinessUnit
700
+ 25: "orgname",
701
+ // Org
588
702
  27: "name",
589
- // Print Template
590
- 28: "name",
703
+ // PrintTemplate
704
+ 28: "contractname",
591
705
  // Contract
592
- 33: "productname",
593
- // Account Product
594
- 46: "name",
706
+ 33: "productid",
707
+ // AccountProduct (uses productid as display)
708
+ 46: "projectname",
595
709
  // Project
596
- 67: "name",
710
+ 55: "rulename",
711
+ // WFRule
712
+ 58: "name",
713
+ // MDObject
714
+ 64: "rolename",
715
+ // Role
716
+ 67: "campaignname",
597
717
  // Campaign
598
- 76: "title",
718
+ 70: "browsername",
719
+ // CrmUserLogin
720
+ 73: "label",
721
+ // SystemField (using label as name field)
722
+ 76: "articlename",
599
723
  // Article
600
- 86: "name",
724
+ 77: "linkname",
725
+ // Link
726
+ 78: "invoicenumber",
601
727
  // Invoice
728
+ 80: "documentnumber",
729
+ // InvoiceReceiptItem
730
+ 81: "invoicenumber",
731
+ // InvoiceNo
732
+ 82: "invoicenumber",
733
+ // InvoiceDraft
734
+ 83: "invoicenumber",
735
+ // InvoiceReceipt
736
+ 84: "invoicenumber",
737
+ // InvoiceReno
738
+ 85: "invoicenumber",
739
+ // InvoiceCredit
740
+ 86: "invoicenumber",
741
+ // InvoiceDelivery
742
+ 89: "name",
743
+ // IpRestriction
744
+ 90: "documentnumber",
745
+ // TransactionItem
746
+ 93: "name",
747
+ // Charge
748
+ 100: "callerid",
749
+ // calllog
602
750
  101: "name",
603
- // Attendance Clock
604
- 102: "subject",
605
- // Activity Log
751
+ // AttendanceClock
752
+ 102: "activitylognumber",
753
+ // ActivityLog
606
754
  104: "subject",
607
755
  // Conversation
608
- 114: "name"
609
- // Calendar Resource
756
+ 105: "name",
757
+ // TeamInbox
758
+ 106: "name",
759
+ // TextTemplate
760
+ 107: "name",
761
+ // FacebookConnection
762
+ 109: "name",
763
+ // AuditLog
764
+ 110: "name",
765
+ // SMSTemplate
766
+ 111: "name",
767
+ // ProviderVerification
768
+ 114: "name",
769
+ // CalendarResource
770
+ 115: "name",
771
+ // Journey
772
+ 116: "name",
773
+ // Profile
774
+ 117: "name"
775
+ // LandingPage
610
776
  };
611
777
  function getNameFieldByObjectType(objectTypeId) {
612
778
  const objectTypeNum = typeof objectTypeId === "string" ? parseInt(objectTypeId, 10) : objectTypeId;
@@ -623,7 +789,7 @@ function getNameFieldByObjectType(objectTypeId) {
623
789
  var EXCLUDED_FIELDS_FOR_STAR_QUERY = {
624
790
  "7": ["deletedon", "deletedby"],
625
791
  // Note
626
- "8": ["deletedon", "deletedby"],
792
+ "8": ["deletedon", "deletedby", "s", "w", "o", "t", "description"],
627
793
  // Competitor
628
794
  "114": ["deletedon", "deletedby"],
629
795
  // Calendar Resource