fireberry-api-client 1.0.0-beta.1

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.
@@ -0,0 +1,871 @@
1
+ import { Q as QueryBuilder } from './excludedFields-CGXgZN8Y.js';
2
+ export { E as EXCLUDED_FIELDS_FOR_STAR_QUERY, F as FIELD_TYPE_IDS, a as FIELD_TYPE_MAPPINGS, O as OBJECT_ID_MAP, b as OBJECT_NAME_MAP, e as escapeQueryValue, s as sanitizeQuery } from './excludedFields-CGXgZN8Y.js';
3
+
4
+ /**
5
+ * Configuration options for FireberryClient
6
+ */
7
+ interface FireberryClientConfig {
8
+ /** Fireberry API key */
9
+ apiKey: string;
10
+ /** Base URL for API requests (default: https://api.fireberry.com) */
11
+ baseUrl?: string;
12
+ /** Request timeout in milliseconds (default: 30000) */
13
+ timeout?: number;
14
+ /** Whether to retry on 429 rate limit errors (default: true) */
15
+ retryOn429?: boolean;
16
+ /** Maximum number of retries for 429 errors (default: 120) */
17
+ maxRetries?: number;
18
+ /** Delay between retries in milliseconds (default: 1000) */
19
+ retryDelay?: number;
20
+ /** Enable in-memory metadata cache (default: false) */
21
+ cacheMetadata?: boolean;
22
+ /** Cache TTL in milliseconds (default: 300000 = 5 minutes) */
23
+ cacheTTL?: number;
24
+ }
25
+ /**
26
+ * Options for HTTP requests
27
+ */
28
+ interface RequestOptions {
29
+ /** HTTP method */
30
+ method: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';
31
+ /** API endpoint path */
32
+ endpoint: string;
33
+ /** Query parameters */
34
+ query?: Record<string, string | number | boolean>;
35
+ /** Request body */
36
+ body?: unknown;
37
+ /** Additional headers */
38
+ headers?: Record<string, string>;
39
+ /** AbortSignal for cancellation */
40
+ signal?: AbortSignal;
41
+ }
42
+ /**
43
+ * Cache control interface
44
+ */
45
+ interface CacheControl {
46
+ /** Clear entire cache */
47
+ clear(): void;
48
+ /** Clear fields cache for an object type */
49
+ clearFields(objectType: string): void;
50
+ /** Clear field values cache for a specific field */
51
+ clearFieldValues(objectType: string, fieldName: string): void;
52
+ /** Clear objects cache */
53
+ clearObjects(): void;
54
+ }
55
+
56
+ /**
57
+ * Options for query operations
58
+ */
59
+ interface QueryOptions {
60
+ /** Object type ID */
61
+ objectType: string;
62
+ /** Fields to return (array or comma-separated string, '*' for all) */
63
+ fields?: string | string[];
64
+ /** Query filter string */
65
+ query?: string;
66
+ /** Field to sort by (default: modifiedon) */
67
+ sortBy?: string;
68
+ /** Sort direction (default: desc) */
69
+ sortType?: 'asc' | 'desc';
70
+ /** Maximum number of records to return */
71
+ limit?: number;
72
+ /** Whether to return label values alongside IDs for dropdowns/lookups */
73
+ showRealValue?: boolean;
74
+ /** Page number (1-indexed) */
75
+ page?: number;
76
+ /** Page size (default: 500, max: 500) */
77
+ pageSize?: number;
78
+ /** Automatically fetch all pages (default: true) */
79
+ autoPage?: boolean;
80
+ /** AbortSignal for cancellation */
81
+ signal?: AbortSignal;
82
+ }
83
+ /**
84
+ * Query result
85
+ */
86
+ interface QueryResult<T = Record<string, unknown>> {
87
+ /** Array of records */
88
+ records: T[];
89
+ /** Total number of records returned */
90
+ total: number;
91
+ /** Whether the query was successful */
92
+ success: boolean;
93
+ }
94
+ /**
95
+ * Query condition item for query builder
96
+ */
97
+ interface QueryConditionItem {
98
+ itemType: 'condition';
99
+ field: string;
100
+ operator: QueryOperator;
101
+ value?: string;
102
+ joinOperator?: 'and' | 'or';
103
+ }
104
+ /**
105
+ * Query separator item for grouping
106
+ */
107
+ interface QuerySeparatorItem {
108
+ itemType: 'separator';
109
+ logicOperator: 'and' | 'or';
110
+ }
111
+ /**
112
+ * Query item type
113
+ */
114
+ type QueryItem = QueryConditionItem | QuerySeparatorItem;
115
+ /**
116
+ * Native Fireberry query operators
117
+ */
118
+ type QueryOperator = '=' | '!=' | '<' | '>' | '<=' | '>=' | 'start-with' | 'not-start-with' | 'is-null' | 'is-not-null';
119
+
120
+ /**
121
+ * Fireberry object/entity type
122
+ */
123
+ interface FireberryObject {
124
+ /** Object type ID */
125
+ objectType: number;
126
+ /** Display name */
127
+ name: string;
128
+ /** System name (API name) */
129
+ systemName: string;
130
+ }
131
+ /**
132
+ * Fireberry field metadata
133
+ */
134
+ interface FireberryField {
135
+ /** Field API name */
136
+ fieldName: string;
137
+ /** Field display label */
138
+ label: string;
139
+ /** System field type ID (UUID) */
140
+ systemFieldTypeId: string;
141
+ /** Human-readable field type */
142
+ fieldType?: string;
143
+ /** Whether field is required */
144
+ required?: boolean;
145
+ /** Default value if any */
146
+ defaultValue?: unknown;
147
+ /** Max length for text fields */
148
+ maxLength?: number;
149
+ /** Precision for number fields */
150
+ precision?: number;
151
+ /** Related object ID for lookup fields */
152
+ relatedObjectId?: string;
153
+ }
154
+ /**
155
+ * Dropdown/picklist value
156
+ */
157
+ interface FieldValue {
158
+ /** Display name */
159
+ name: string;
160
+ /** Value (usually numeric ID) */
161
+ value: string;
162
+ }
163
+ /**
164
+ * Result of getObjects operation
165
+ */
166
+ interface GetObjectsResult {
167
+ /** Array of objects */
168
+ objects: FireberryObject[];
169
+ /** Total count */
170
+ total: number;
171
+ /** Success flag */
172
+ success: boolean;
173
+ }
174
+ /**
175
+ * Result of getFields operation
176
+ */
177
+ interface GetFieldsResult {
178
+ /** Object type ID */
179
+ objectTypeId: string;
180
+ /** Array of fields */
181
+ fields: FireberryField[];
182
+ /** Total count */
183
+ total: number;
184
+ /** Success flag */
185
+ success: boolean;
186
+ }
187
+ /**
188
+ * Result of getFieldValues operation
189
+ */
190
+ interface GetFieldValuesResult {
191
+ /** Object type ID */
192
+ objectTypeId: string;
193
+ /** Field name */
194
+ fieldName: string;
195
+ /** Array of values */
196
+ values: FieldValue[];
197
+ /** Total count */
198
+ total: number;
199
+ /** Success flag */
200
+ success: boolean;
201
+ }
202
+
203
+ /**
204
+ * Metadata API for retrieving Fireberry schema information
205
+ */
206
+ declare class MetadataAPI {
207
+ private readonly client;
208
+ constructor(client: FireberryClient);
209
+ /**
210
+ * Gets all available objects/entity types from Fireberry
211
+ *
212
+ * @param signal - Optional AbortSignal for cancellation
213
+ * @returns List of all objects
214
+ *
215
+ * @example
216
+ * ```typescript
217
+ * const result = await client.metadata.getObjects();
218
+ * console.log(result.objects); // [{ objectType: 1, name: 'Account', ... }, ...]
219
+ * ```
220
+ */
221
+ getObjects(signal?: AbortSignal): Promise<GetObjectsResult>;
222
+ /**
223
+ * Gets all fields for a specific object type
224
+ *
225
+ * @param objectType - The object type ID (e.g., '1' for Account)
226
+ * @param signal - Optional AbortSignal for cancellation
227
+ * @returns List of fields with metadata
228
+ *
229
+ * @example
230
+ * ```typescript
231
+ * const result = await client.metadata.getFields('1');
232
+ * console.log(result.fields); // [{ fieldName: 'accountid', label: 'Account ID', ... }, ...]
233
+ * ```
234
+ */
235
+ getFields(objectType: string | number, signal?: AbortSignal): Promise<GetFieldsResult>;
236
+ /**
237
+ * Gets all possible values for a dropdown field
238
+ *
239
+ * @param objectType - The object type ID
240
+ * @param fieldName - The field name
241
+ * @param signal - Optional AbortSignal for cancellation
242
+ * @returns List of dropdown values
243
+ *
244
+ * @example
245
+ * ```typescript
246
+ * const result = await client.metadata.getFieldValues('1', 'statuscode');
247
+ * console.log(result.values); // [{ name: 'Active', value: '1' }, { name: 'Inactive', value: '2' }]
248
+ * ```
249
+ */
250
+ getFieldValues(objectType: string | number, fieldName: string, signal?: AbortSignal): Promise<GetFieldValuesResult>;
251
+ }
252
+
253
+ /**
254
+ * Generic record type
255
+ */
256
+ type FireberryRecord = Record<string, unknown>;
257
+ /**
258
+ * Options for create operation
259
+ */
260
+ interface CreateOptions {
261
+ /** AbortSignal for cancellation */
262
+ signal?: AbortSignal;
263
+ }
264
+ /**
265
+ * Options for update operation
266
+ */
267
+ interface UpdateOptions {
268
+ /** AbortSignal for cancellation */
269
+ signal?: AbortSignal;
270
+ }
271
+ /**
272
+ * Options for delete operation
273
+ */
274
+ interface DeleteOptions {
275
+ /** AbortSignal for cancellation */
276
+ signal?: AbortSignal;
277
+ }
278
+ /**
279
+ * Options for upsert operation
280
+ */
281
+ interface UpsertOptions {
282
+ /** AbortSignal for cancellation */
283
+ signal?: AbortSignal;
284
+ }
285
+ /**
286
+ * Result of upsert operation
287
+ */
288
+ interface UpsertResult {
289
+ /** Whether the operation was successful */
290
+ success: boolean;
291
+ /** Type of operation performed */
292
+ operationType: 'create' | 'update';
293
+ /** Key fields used for matching */
294
+ upsertKeys: string[];
295
+ /** Values of key fields */
296
+ upsertKeyValues: Record<string, unknown>;
297
+ /** Previous record data (null if created) */
298
+ oldRecord: FireberryRecord | null;
299
+ /** New record data */
300
+ newRecord: FireberryRecord;
301
+ }
302
+ /**
303
+ * Options for batch create operation
304
+ */
305
+ interface BatchCreateOptions {
306
+ /** AbortSignal for cancellation */
307
+ signal?: AbortSignal;
308
+ }
309
+ /**
310
+ * Options for batch update operation
311
+ */
312
+ interface BatchUpdateOptions {
313
+ /** AbortSignal for cancellation */
314
+ signal?: AbortSignal;
315
+ }
316
+ /**
317
+ * Record for batch update (includes id)
318
+ */
319
+ interface BatchUpdateRecord {
320
+ id: string;
321
+ record: FireberryRecord;
322
+ }
323
+ /**
324
+ * Options for batch delete operation
325
+ */
326
+ interface BatchDeleteOptions {
327
+ /** AbortSignal for cancellation */
328
+ signal?: AbortSignal;
329
+ }
330
+ /**
331
+ * Result of batch operation
332
+ */
333
+ interface BatchResult {
334
+ /** Whether the operation was successful */
335
+ success: boolean;
336
+ /** Response data from API */
337
+ data: unknown[];
338
+ /** Number of records processed */
339
+ count: number;
340
+ }
341
+ /**
342
+ * Result of batch delete operation
343
+ */
344
+ interface BatchDeleteResult {
345
+ /** Whether the operation was successful */
346
+ success: boolean;
347
+ /** IDs of deleted records */
348
+ ids: string[];
349
+ /** Number of records deleted */
350
+ count: number;
351
+ }
352
+
353
+ /**
354
+ * Records API for CRUD operations on Fireberry records
355
+ */
356
+ declare class RecordsAPI {
357
+ private readonly client;
358
+ constructor(client: FireberryClient);
359
+ /**
360
+ * Creates a new record in Fireberry
361
+ *
362
+ * @param objectType - The object type ID (e.g., '1' for Account)
363
+ * @param data - Record data to create
364
+ * @param options - Optional settings
365
+ * @returns Created record data
366
+ *
367
+ * @example
368
+ * ```typescript
369
+ * const result = await client.records.create('1', {
370
+ * accountname: 'New Account',
371
+ * emailaddress1: 'contact@example.com',
372
+ * });
373
+ * ```
374
+ */
375
+ create(objectType: string | number, data: FireberryRecord, options?: CreateOptions): Promise<FireberryRecord>;
376
+ /**
377
+ * Updates an existing record in Fireberry
378
+ *
379
+ * @param objectType - The object type ID
380
+ * @param recordId - The record ID to update
381
+ * @param data - Record data to update
382
+ * @param options - Optional settings
383
+ * @returns Updated record data
384
+ *
385
+ * @example
386
+ * ```typescript
387
+ * const result = await client.records.update('1', 'abc123', {
388
+ * accountname: 'Updated Account Name',
389
+ * });
390
+ * ```
391
+ */
392
+ update(objectType: string | number, recordId: string, data: FireberryRecord, options?: UpdateOptions): Promise<FireberryRecord>;
393
+ /**
394
+ * Deletes a record from Fireberry
395
+ *
396
+ * @param objectType - The object type ID
397
+ * @param recordId - The record ID to delete
398
+ * @param options - Optional settings
399
+ * @returns Success status
400
+ *
401
+ * @example
402
+ * ```typescript
403
+ * await client.records.delete('1', 'abc123');
404
+ * ```
405
+ */
406
+ delete(objectType: string | number, recordId: string, options?: DeleteOptions): Promise<{
407
+ success: boolean;
408
+ id: string;
409
+ }>;
410
+ /**
411
+ * Upserts a record (creates if not exists, updates if exists)
412
+ *
413
+ * @param objectType - The object type ID
414
+ * @param keyFields - Fields to use for matching existing records
415
+ * @param data - Record data to upsert
416
+ * @param options - Optional settings
417
+ * @returns Upsert result with operation type and record data
418
+ *
419
+ * @example
420
+ * ```typescript
421
+ * const result = await client.records.upsert('1', ['emailaddress1'], {
422
+ * accountname: 'Acme Corp',
423
+ * emailaddress1: 'contact@acme.com',
424
+ * });
425
+ * console.log(result.operationType); // 'create' or 'update'
426
+ * ```
427
+ */
428
+ upsert(objectType: string | number, keyFields: string[], data: FireberryRecord, options?: UpsertOptions): Promise<UpsertResult>;
429
+ }
430
+
431
+ /**
432
+ * Batch API for bulk operations on Fireberry records
433
+ * Automatically chunks large datasets into API-compatible batches of 20
434
+ */
435
+ declare class BatchAPI {
436
+ private readonly client;
437
+ constructor(client: FireberryClient);
438
+ /**
439
+ * Creates multiple records in batch
440
+ * Automatically chunks into batches of 20 records
441
+ *
442
+ * @param objectType - The object type ID
443
+ * @param records - Array of records to create
444
+ * @param options - Optional settings
445
+ * @returns Batch result with all created records
446
+ *
447
+ * @example
448
+ * ```typescript
449
+ * const result = await client.batch.create('1', [
450
+ * { accountname: 'Account 1' },
451
+ * { accountname: 'Account 2' },
452
+ * ]);
453
+ * console.log(result.count); // 2
454
+ * ```
455
+ */
456
+ create(objectType: string | number, records: FireberryRecord[], options?: BatchCreateOptions): Promise<BatchResult>;
457
+ /**
458
+ * Updates multiple records in batch
459
+ * Automatically chunks into batches of 20 records
460
+ *
461
+ * @param objectType - The object type ID
462
+ * @param records - Array of records with ID and data to update
463
+ * @param options - Optional settings
464
+ * @returns Batch result with all updated records
465
+ *
466
+ * @example
467
+ * ```typescript
468
+ * const result = await client.batch.update('1', [
469
+ * { id: 'abc123', record: { accountname: 'Updated 1' } },
470
+ * { id: 'def456', record: { accountname: 'Updated 2' } },
471
+ * ]);
472
+ * ```
473
+ */
474
+ update(objectType: string | number, records: BatchUpdateRecord[], options?: BatchUpdateOptions): Promise<BatchResult>;
475
+ /**
476
+ * Deletes multiple records in batch
477
+ * Automatically chunks into batches of 20 records
478
+ *
479
+ * @param objectType - The object type ID
480
+ * @param recordIds - Array of record IDs to delete
481
+ * @param options - Optional settings
482
+ * @returns Batch delete result with deleted IDs
483
+ *
484
+ * @example
485
+ * ```typescript
486
+ * const result = await client.batch.delete('1', ['abc123', 'def456']);
487
+ * console.log(result.ids); // ['abc123', 'def456']
488
+ * ```
489
+ */
490
+ delete(objectType: string | number, recordIds: string[], options?: BatchDeleteOptions): Promise<BatchDeleteResult>;
491
+ }
492
+
493
+ /**
494
+ * Field types supported for creation
495
+ */
496
+ type CreateFieldType = 'text' | 'textarea' | 'email' | 'url' | 'phone' | 'number' | 'date' | 'datetime' | 'html' | 'lookup' | 'picklist' | 'formula' | 'summary';
497
+ /**
498
+ * Base options for creating a field
499
+ */
500
+ interface CreateFieldOptionsBase {
501
+ /** Field type */
502
+ type: CreateFieldType;
503
+ /** Field API name (must be unique, should start with 'pcf') */
504
+ fieldName: string;
505
+ /** Display label */
506
+ label: string;
507
+ /** Default value */
508
+ defaultValue?: string;
509
+ /** Track changes */
510
+ follow?: boolean;
511
+ /** Enable auto-complete */
512
+ autoComplete?: boolean;
513
+ }
514
+ /**
515
+ * Options for text/email/url fields
516
+ */
517
+ interface CreateTextFieldOptions extends CreateFieldOptionsBase {
518
+ type: 'text' | 'email' | 'url';
519
+ /** Maximum length (1-200) */
520
+ maxLength?: number;
521
+ }
522
+ /**
523
+ * Options for number fields
524
+ */
525
+ interface CreateNumberFieldOptions extends CreateFieldOptionsBase {
526
+ type: 'number';
527
+ /** Decimal precision (0-4) */
528
+ precision?: number;
529
+ }
530
+ /**
531
+ * Options for lookup fields
532
+ */
533
+ interface CreateLookupFieldOptions extends CreateFieldOptionsBase {
534
+ type: 'lookup';
535
+ /** Related object type ID */
536
+ relatedObjectId: string;
537
+ }
538
+ /**
539
+ * Picklist value for field creation
540
+ */
541
+ interface PicklistValue {
542
+ name: string;
543
+ value: string;
544
+ }
545
+ /**
546
+ * Options for picklist fields
547
+ */
548
+ interface CreatePicklistFieldOptions extends CreateFieldOptionsBase {
549
+ type: 'picklist';
550
+ /** Picklist values */
551
+ values: PicklistValue[];
552
+ }
553
+ /**
554
+ * Summary types
555
+ */
556
+ type SummaryType = 'avg' | 'count' | 'max' | 'min' | 'sum';
557
+ /**
558
+ * Options for summary fields
559
+ */
560
+ interface CreateSummaryFieldOptions extends CreateFieldOptionsBase {
561
+ type: 'summary';
562
+ /** Summary calculation type */
563
+ summaryType: SummaryType;
564
+ /** Related object to summarize */
565
+ relatedObjectId: string;
566
+ /** Field to summarize (required for sum, avg, min, max) */
567
+ summaryField?: string;
568
+ }
569
+ /**
570
+ * Formula result types
571
+ */
572
+ type FormulaFieldType = 'text' | 'number' | 'date' | 'boolean';
573
+ /**
574
+ * Options for formula fields
575
+ */
576
+ interface CreateFormulaFieldOptions extends CreateFieldOptionsBase {
577
+ type: 'formula';
578
+ /** Formula expression */
579
+ formula: string;
580
+ /** Output field type */
581
+ formulaFieldType: FormulaFieldType;
582
+ /** Precision for numeric formulas */
583
+ formulaPrecision?: number;
584
+ }
585
+ /**
586
+ * Options for other simple fields
587
+ */
588
+ interface CreateSimpleFieldOptions extends CreateFieldOptionsBase {
589
+ type: 'textarea' | 'phone' | 'date' | 'datetime' | 'html';
590
+ }
591
+ /**
592
+ * Union type for all field creation options
593
+ */
594
+ type CreateFieldOptions = CreateTextFieldOptions | CreateNumberFieldOptions | CreateLookupFieldOptions | CreatePicklistFieldOptions | CreateSummaryFieldOptions | CreateFormulaFieldOptions | CreateSimpleFieldOptions;
595
+ /**
596
+ * Result of field creation
597
+ */
598
+ interface CreateFieldResult {
599
+ /** Object type ID */
600
+ objectTypeId: string;
601
+ /** Field type */
602
+ fieldType: CreateFieldType;
603
+ /** Created field data */
604
+ fieldData: Record<string, unknown>;
605
+ /** Success flag */
606
+ success: boolean;
607
+ }
608
+
609
+ /**
610
+ * Fields API for creating custom fields in Fireberry
611
+ */
612
+ declare class FieldsAPI {
613
+ private readonly client;
614
+ constructor(client: FireberryClient);
615
+ /**
616
+ * Creates a new custom field in a Fireberry object
617
+ *
618
+ * @param objectType - The object type ID
619
+ * @param options - Field creation options
620
+ * @returns Created field result
621
+ *
622
+ * @example
623
+ * ```typescript
624
+ * // Create a text field
625
+ * const result = await client.fields.create('1', {
626
+ * type: 'text',
627
+ * fieldName: 'pcf_custom_field',
628
+ * label: 'Custom Field',
629
+ * maxLength: 100,
630
+ * });
631
+ *
632
+ * // Create a picklist field
633
+ * const result = await client.fields.create('1', {
634
+ * type: 'picklist',
635
+ * fieldName: 'pcf_status',
636
+ * label: 'Status',
637
+ * values: [
638
+ * { name: 'Active', value: '1' },
639
+ * { name: 'Inactive', value: '2' },
640
+ * ],
641
+ * });
642
+ *
643
+ * // Create a lookup field
644
+ * const result = await client.fields.create('2', {
645
+ * type: 'lookup',
646
+ * fieldName: 'pcf_related_account',
647
+ * label: 'Related Account',
648
+ * relatedObjectId: '1',
649
+ * });
650
+ * ```
651
+ */
652
+ create(objectType: string | number, options: CreateFieldOptions): Promise<CreateFieldResult>;
653
+ }
654
+
655
+ /**
656
+ * Options for file upload
657
+ */
658
+ interface FileUploadOptions {
659
+ /** File content as Buffer */
660
+ buffer: Buffer;
661
+ /** File name */
662
+ filename: string;
663
+ /** MIME type */
664
+ mimeType: string;
665
+ }
666
+ /**
667
+ * Result of file upload
668
+ */
669
+ interface FileUploadResult {
670
+ /** Success flag */
671
+ success: boolean;
672
+ /** Object type */
673
+ objectType: string;
674
+ /** Record ID */
675
+ recordId: string;
676
+ /** Uploaded file name */
677
+ fileName: string;
678
+ /** File MIME type */
679
+ mimeType: string;
680
+ /** File size in bytes */
681
+ fileSize: number;
682
+ /** API response */
683
+ response: unknown;
684
+ }
685
+ /**
686
+ * Files API for file operations in Fireberry
687
+ */
688
+ declare class FilesAPI {
689
+ private readonly client;
690
+ constructor(client: FireberryClient);
691
+ /**
692
+ * Uploads a file attachment to a Fireberry record
693
+ *
694
+ * @param objectType - The object type ID
695
+ * @param recordId - The record ID to attach the file to
696
+ * @param options - File upload options
697
+ * @param signal - Optional AbortSignal for cancellation
698
+ * @returns Upload result
699
+ *
700
+ * @example
701
+ * ```typescript
702
+ * import { readFileSync } from 'fs';
703
+ *
704
+ * const fileBuffer = readFileSync('document.pdf');
705
+ * const result = await client.files.upload('1', 'abc123', {
706
+ * buffer: fileBuffer,
707
+ * filename: 'document.pdf',
708
+ * mimeType: 'application/pdf',
709
+ * });
710
+ * ```
711
+ */
712
+ upload(objectType: string | number, recordId: string, options: FileUploadOptions, signal?: AbortSignal): Promise<FileUploadResult>;
713
+ }
714
+
715
+ /**
716
+ * FireberryClient - Main client for interacting with the Fireberry CRM API
717
+ *
718
+ * @example
719
+ * ```typescript
720
+ * const client = new FireberryClient({
721
+ * apiKey: 'your-api-key',
722
+ * retryOn429: true,
723
+ * maxRetries: 120,
724
+ * });
725
+ *
726
+ * // Query records
727
+ * const result = await client.query({
728
+ * objectType: '1',
729
+ * fields: ['accountid', 'name'],
730
+ * query: '(statuscode = 1)',
731
+ * });
732
+ *
733
+ * // Use query builder
734
+ * const result = await client.queryBuilder()
735
+ * .objectType('1')
736
+ * .select('accountid', 'name')
737
+ * .where('statuscode').equals('1')
738
+ * .execute();
739
+ * ```
740
+ */
741
+ declare class FireberryClient {
742
+ private readonly config;
743
+ private readonly cacheStore;
744
+ /** Metadata API operations */
745
+ readonly metadata: MetadataAPI;
746
+ /** Records CRUD operations */
747
+ readonly records: RecordsAPI;
748
+ /** Batch operations */
749
+ readonly batch: BatchAPI;
750
+ /** Field management operations */
751
+ readonly fields: FieldsAPI;
752
+ /** File operations */
753
+ readonly files: FilesAPI;
754
+ /**
755
+ * Creates a new FireberryClient instance
756
+ */
757
+ constructor(config: FireberryClientConfig);
758
+ /**
759
+ * Gets the client configuration
760
+ */
761
+ getConfig(): Readonly<Required<FireberryClientConfig>>;
762
+ /**
763
+ * Cache control methods
764
+ */
765
+ readonly cache: CacheControl;
766
+ /**
767
+ * Gets cached data if valid, or undefined if not cached or expired
768
+ */
769
+ getCached<T>(type: 'objects'): T | undefined;
770
+ getCached<T>(type: 'fields', objectType: string): T | undefined;
771
+ getCached<T>(type: 'fieldValues', objectType: string, fieldName: string): T | undefined;
772
+ /**
773
+ * Sets cached data
774
+ */
775
+ setCache(type: 'objects', data: unknown): void;
776
+ setCache(type: 'fields', objectType: string, data: unknown): void;
777
+ setCache(type: 'fieldValues', objectType: string, fieldName: string, data: unknown): void;
778
+ /**
779
+ * Creates a new QueryBuilder instance
780
+ */
781
+ queryBuilder(): QueryBuilder;
782
+ /**
783
+ * Executes a query against the Fireberry API
784
+ */
785
+ query(options: QueryOptions): Promise<QueryResult>;
786
+ /**
787
+ * Fetches all pages of a query
788
+ */
789
+ private queryAllPages;
790
+ /**
791
+ * Expands '*' fields to actual field names, excluding problematic fields for specific object types
792
+ */
793
+ private expandStarFields;
794
+ /**
795
+ * Makes a raw API request to the Fireberry API
796
+ */
797
+ request<T = unknown>(options: RequestOptions): Promise<T>;
798
+ /**
799
+ * Executes a fetch request with retry logic for 429 errors
800
+ */
801
+ private executeWithRetry;
802
+ /**
803
+ * Combines multiple abort signals into one
804
+ */
805
+ private combineSignals;
806
+ }
807
+
808
+ /**
809
+ * Error codes for Fireberry API errors
810
+ */
811
+ declare enum FireberryErrorCode {
812
+ /** Unknown or unexpected error */
813
+ UNKNOWN = "UNKNOWN",
814
+ /** Network error (connection failed, DNS, etc.) */
815
+ NETWORK_ERROR = "NETWORK_ERROR",
816
+ /** Request timeout */
817
+ TIMEOUT = "TIMEOUT",
818
+ /** Authentication failed (invalid API key) */
819
+ AUTHENTICATION_FAILED = "AUTHENTICATION_FAILED",
820
+ /** Authorization failed (missing permissions) */
821
+ AUTHORIZATION_FAILED = "AUTHORIZATION_FAILED",
822
+ /** Resource not found */
823
+ NOT_FOUND = "NOT_FOUND",
824
+ /** Rate limit exceeded (429) */
825
+ RATE_LIMITED = "RATE_LIMITED",
826
+ /** Invalid request parameters */
827
+ INVALID_REQUEST = "INVALID_REQUEST",
828
+ /** Server error (5xx) */
829
+ SERVER_ERROR = "SERVER_ERROR",
830
+ /** Request was aborted */
831
+ ABORTED = "ABORTED",
832
+ /** Invalid response from API */
833
+ INVALID_RESPONSE = "INVALID_RESPONSE"
834
+ }
835
+ /**
836
+ * Options for creating a FireberryError
837
+ */
838
+ interface FireberryErrorOptions {
839
+ /** Error code */
840
+ code: FireberryErrorCode;
841
+ /** HTTP status code if applicable */
842
+ statusCode?: number;
843
+ /** Original error that caused this error */
844
+ cause?: Error;
845
+ /** Additional context data */
846
+ context?: Record<string, unknown>;
847
+ }
848
+ /**
849
+ * Custom error class for Fireberry API errors
850
+ */
851
+ declare class FireberryError extends Error {
852
+ /** Error code */
853
+ readonly code: FireberryErrorCode;
854
+ /** HTTP status code if applicable */
855
+ readonly statusCode?: number;
856
+ /** Original error that caused this error */
857
+ readonly cause?: Error;
858
+ /** Additional context data */
859
+ readonly context?: Record<string, unknown>;
860
+ constructor(message: string, options: FireberryErrorOptions);
861
+ /**
862
+ * Creates a string representation of the error
863
+ */
864
+ toString(): string;
865
+ /**
866
+ * Converts the error to a plain object for logging/serialization
867
+ */
868
+ toJSON(): Record<string, unknown>;
869
+ }
870
+
871
+ export { type BatchCreateOptions, type BatchDeleteOptions, type BatchDeleteResult, type BatchResult, type BatchUpdateOptions, type BatchUpdateRecord, type CacheControl, type CreateFieldOptions, type CreateFieldOptionsBase, type CreateFieldResult, type CreateFieldType, type CreateFormulaFieldOptions, type CreateLookupFieldOptions, type CreateNumberFieldOptions, type CreateOptions, type CreatePicklistFieldOptions, type CreateSimpleFieldOptions, type CreateSummaryFieldOptions, type CreateTextFieldOptions, type DeleteOptions, type FieldValue, type FileUploadOptions, type FileUploadResult, FireberryClient, type FireberryClientConfig, FireberryError, FireberryErrorCode, type FireberryErrorOptions, type FireberryField, type FireberryObject, type FireberryRecord, type FormulaFieldType, type GetFieldValuesResult, type GetFieldsResult, type GetObjectsResult, type PicklistValue, QueryBuilder, type QueryConditionItem, type QueryItem, type QueryOperator, type QueryOptions, type QueryResult, type QuerySeparatorItem, type RequestOptions, type SummaryType, type UpdateOptions, type UpsertOptions, type UpsertResult };