fireberry-api-client 1.0.2-beta.1.0 → 1.0.2-beta.1.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,11 +1,23 @@
1
- import { Q as QueryBuilder, a as QueryOptions, b as QueryResult } from './excludedFields-CuQ8Dp-N.js';
1
+ import { F as FireberrySDKClient, a as QueryOptions, b as QueryResult, Q as QueryBuilder } from './excludedFields-Dk-ILROQ.js';
2
2
 
3
3
  /**
4
4
  * Configuration options for FireberryClient
5
+ * Supports two modes:
6
+ * 1. API Key mode: Provide apiKey for direct HTTP API access
7
+ * 2. SDK mode: Provide sdk for iframe messaging (CRUD only, metadata requires apiKey)
8
+ * 3. Hybrid mode: Provide both sdk and apiKey (SDK for CRUD, API for metadata)
5
9
  */
6
10
  interface FireberryClientConfig {
7
- /** Fireberry API key */
8
- apiKey: string;
11
+ /**
12
+ * Fireberry API key (required for API mode, optional for SDK mode)
13
+ * If using SDK mode without apiKey, metadata operations will not be available
14
+ */
15
+ apiKey?: string;
16
+ /**
17
+ * Fireberry SDK client instance (optional)
18
+ * When provided, CRUD operations will use SDK iframe messaging instead of HTTP
19
+ */
20
+ sdk?: FireberrySDKClient;
9
21
  /** Base URL for API requests (default: https://api.fireberry.com) */
10
22
  baseUrl?: string;
11
23
  /** Request timeout in milliseconds (default: 30000) */
@@ -62,6 +74,263 @@ interface CacheControl {
62
74
  clearObjects(): void;
63
75
  }
64
76
 
77
+ /**
78
+ * Generic record type
79
+ */
80
+ type FireberryRecord = Record<string, unknown>;
81
+ /**
82
+ * Options for create operation
83
+ */
84
+ interface CreateOptions {
85
+ /** AbortSignal for cancellation */
86
+ signal?: AbortSignal;
87
+ }
88
+ /**
89
+ * Options for update operation
90
+ */
91
+ interface UpdateOptions {
92
+ /** AbortSignal for cancellation */
93
+ signal?: AbortSignal;
94
+ }
95
+ /**
96
+ * Options for delete operation
97
+ */
98
+ interface DeleteOptions {
99
+ /** AbortSignal for cancellation */
100
+ signal?: AbortSignal;
101
+ }
102
+ /**
103
+ * Options for upsert operation
104
+ */
105
+ interface UpsertOptions {
106
+ /** AbortSignal for cancellation */
107
+ signal?: AbortSignal;
108
+ }
109
+ /**
110
+ * Result of upsert operation
111
+ */
112
+ interface UpsertResult {
113
+ /** Whether the operation was successful */
114
+ success: boolean;
115
+ /** Type of operation performed */
116
+ operationType: 'create' | 'update';
117
+ /** Key fields used for matching */
118
+ upsertKeys: string[];
119
+ /** Values of key fields */
120
+ upsertKeyValues: Record<string, unknown>;
121
+ /** Previous record data (null if created) */
122
+ oldRecord: FireberryRecord | null;
123
+ /** New record data */
124
+ newRecord: FireberryRecord;
125
+ }
126
+ /**
127
+ * Options for batch create operation
128
+ */
129
+ interface BatchCreateOptions {
130
+ /** AbortSignal for cancellation */
131
+ signal?: AbortSignal;
132
+ }
133
+ /**
134
+ * Options for batch update operation
135
+ */
136
+ interface BatchUpdateOptions {
137
+ /** AbortSignal for cancellation */
138
+ signal?: AbortSignal;
139
+ }
140
+ /**
141
+ * Record for batch update (includes id)
142
+ */
143
+ interface BatchUpdateRecord {
144
+ id: string;
145
+ record: FireberryRecord;
146
+ }
147
+ /**
148
+ * Options for batch delete operation
149
+ */
150
+ interface BatchDeleteOptions {
151
+ /** AbortSignal for cancellation */
152
+ signal?: AbortSignal;
153
+ }
154
+ /**
155
+ * Result of batch operation
156
+ */
157
+ interface BatchResult {
158
+ /** Whether the operation was successful */
159
+ success: boolean;
160
+ /** Response data from API */
161
+ data: unknown[];
162
+ /** Number of records processed */
163
+ count: number;
164
+ }
165
+ /**
166
+ * Result of batch delete operation
167
+ */
168
+ interface BatchDeleteResult {
169
+ /** Whether the operation was successful */
170
+ success: boolean;
171
+ /** IDs of deleted records */
172
+ ids: string[];
173
+ /** Number of records deleted */
174
+ count: number;
175
+ }
176
+
177
+ /**
178
+ * Transport layer types for abstracting communication with Fireberry
179
+ * Supports both HTTP API and SDK iframe messaging
180
+ */
181
+
182
+ /**
183
+ * Generic transport request options
184
+ */
185
+ interface TransportRequestOptions {
186
+ method: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';
187
+ endpoint: string;
188
+ query?: Record<string, string | number | boolean>;
189
+ body?: unknown;
190
+ headers?: Record<string, string>;
191
+ signal?: AbortSignal;
192
+ }
193
+ /**
194
+ * Transport interface that both HTTP and SDK implementations must follow
195
+ */
196
+ interface Transport {
197
+ /**
198
+ * Execute a raw request through this transport
199
+ */
200
+ request<T = unknown>(options: TransportRequestOptions): Promise<T>;
201
+ /**
202
+ * Execute a query operation
203
+ */
204
+ query(options: QueryOptions): Promise<QueryResult>;
205
+ /**
206
+ * Create a record
207
+ */
208
+ createRecord(objectType: string, data: FireberryRecord, signal?: AbortSignal): Promise<FireberryRecord>;
209
+ /**
210
+ * Update a record
211
+ */
212
+ updateRecord(objectType: string, recordId: string, data: FireberryRecord, signal?: AbortSignal): Promise<FireberryRecord>;
213
+ /**
214
+ * Delete a record
215
+ */
216
+ deleteRecord(objectType: string, recordId: string, signal?: AbortSignal): Promise<{
217
+ success: boolean;
218
+ id: string;
219
+ }>;
220
+ /**
221
+ * Batch create records
222
+ */
223
+ batchCreate(objectType: string, records: FireberryRecord[], signal?: AbortSignal): Promise<{
224
+ success: boolean;
225
+ data: unknown[];
226
+ count: number;
227
+ }>;
228
+ /**
229
+ * Batch update records
230
+ */
231
+ batchUpdate(objectType: string, records: Array<{
232
+ id: string;
233
+ record: FireberryRecord;
234
+ }>, signal?: AbortSignal): Promise<{
235
+ success: boolean;
236
+ data: unknown[];
237
+ count: number;
238
+ }>;
239
+ /**
240
+ * Batch delete records
241
+ */
242
+ batchDelete(objectType: string, recordIds: string[], signal?: AbortSignal): Promise<{
243
+ success: boolean;
244
+ ids: string[];
245
+ count: number;
246
+ }>;
247
+ /**
248
+ * Get the transport type
249
+ */
250
+ getType(): 'http' | 'sdk';
251
+ }
252
+ /**
253
+ * Configuration for HTTP transport
254
+ */
255
+ interface HTTPTransportConfig {
256
+ apiKey: string;
257
+ baseUrl?: string;
258
+ timeout?: number;
259
+ retryOn429?: boolean;
260
+ maxRetries?: number;
261
+ retryDelay?: number;
262
+ }
263
+ /**
264
+ * Configuration for SDK transport
265
+ */
266
+ interface SDKTransportConfig {
267
+ sdk: FireberrySDKClient;
268
+ }
269
+ /**
270
+ * Union type for transport configuration
271
+ */
272
+ type TransportConfig = HTTPTransportConfig | SDKTransportConfig;
273
+ /**
274
+ * Type guard to check if config is HTTP transport config
275
+ */
276
+ declare function isHTTPTransportConfig(config: TransportConfig): config is HTTPTransportConfig;
277
+ /**
278
+ * Type guard to check if config is SDK transport config
279
+ */
280
+ declare function isSDKTransportConfig(config: TransportConfig): config is SDKTransportConfig;
281
+
282
+ /**
283
+ * HTTP Transport implementation for Fireberry API
284
+ * Uses direct HTTP requests with API key authentication
285
+ */
286
+
287
+ /**
288
+ * HTTP transport for API key-based communication
289
+ */
290
+ declare class HTTPTransport implements Transport {
291
+ private readonly config;
292
+ constructor(config: HTTPTransportConfig);
293
+ getType(): 'http';
294
+ request<T = unknown>(options: TransportRequestOptions): Promise<T>;
295
+ query(options: QueryOptions): Promise<QueryResult>;
296
+ createRecord(objectType: string, data: FireberryRecord, signal?: AbortSignal): Promise<FireberryRecord>;
297
+ updateRecord(objectType: string, recordId: string, data: FireberryRecord, signal?: AbortSignal): Promise<FireberryRecord>;
298
+ deleteRecord(objectType: string, recordId: string, signal?: AbortSignal): Promise<{
299
+ success: boolean;
300
+ id: string;
301
+ }>;
302
+ batchCreate(objectType: string, records: FireberryRecord[], signal?: AbortSignal): Promise<{
303
+ success: boolean;
304
+ data: unknown[];
305
+ count: number;
306
+ }>;
307
+ batchUpdate(objectType: string, records: Array<{
308
+ id: string;
309
+ record: FireberryRecord;
310
+ }>, signal?: AbortSignal): Promise<{
311
+ success: boolean;
312
+ data: unknown[];
313
+ count: number;
314
+ }>;
315
+ batchDelete(objectType: string, recordIds: string[], signal?: AbortSignal): Promise<{
316
+ success: boolean;
317
+ ids: string[];
318
+ count: number;
319
+ }>;
320
+ /**
321
+ * Fetches all pages of a query
322
+ */
323
+ private queryAllPages;
324
+ /**
325
+ * Executes a fetch request with retry logic for 429 errors
326
+ */
327
+ private executeWithRetry;
328
+ /**
329
+ * Combines multiple abort signals into one
330
+ */
331
+ private combineSignals;
332
+ }
333
+
65
334
  /**
66
335
  * Fireberry object/entity type
67
336
  */
@@ -158,6 +427,11 @@ interface GetFieldValuesResult {
158
427
  declare class MetadataAPI {
159
428
  private readonly client;
160
429
  constructor(client: FireberryClient);
430
+ /**
431
+ * Checks if metadata operations are available and throws error if not
432
+ * @private
433
+ */
434
+ private ensureMetadataAvailable;
161
435
  /**
162
436
  * Gets all available objects/entity types from Fireberry
163
437
  *
@@ -217,106 +491,6 @@ declare class MetadataAPI {
217
491
  getFieldValues(objectType: string | number, fieldName: string, signal?: AbortSignal): Promise<GetFieldValuesResult>;
218
492
  }
219
493
 
220
- /**
221
- * Generic record type
222
- */
223
- type FireberryRecord = Record<string, unknown>;
224
- /**
225
- * Options for create operation
226
- */
227
- interface CreateOptions {
228
- /** AbortSignal for cancellation */
229
- signal?: AbortSignal;
230
- }
231
- /**
232
- * Options for update operation
233
- */
234
- interface UpdateOptions {
235
- /** AbortSignal for cancellation */
236
- signal?: AbortSignal;
237
- }
238
- /**
239
- * Options for delete operation
240
- */
241
- interface DeleteOptions {
242
- /** AbortSignal for cancellation */
243
- signal?: AbortSignal;
244
- }
245
- /**
246
- * Options for upsert operation
247
- */
248
- interface UpsertOptions {
249
- /** AbortSignal for cancellation */
250
- signal?: AbortSignal;
251
- }
252
- /**
253
- * Result of upsert operation
254
- */
255
- interface UpsertResult {
256
- /** Whether the operation was successful */
257
- success: boolean;
258
- /** Type of operation performed */
259
- operationType: 'create' | 'update';
260
- /** Key fields used for matching */
261
- upsertKeys: string[];
262
- /** Values of key fields */
263
- upsertKeyValues: Record<string, unknown>;
264
- /** Previous record data (null if created) */
265
- oldRecord: FireberryRecord | null;
266
- /** New record data */
267
- newRecord: FireberryRecord;
268
- }
269
- /**
270
- * Options for batch create operation
271
- */
272
- interface BatchCreateOptions {
273
- /** AbortSignal for cancellation */
274
- signal?: AbortSignal;
275
- }
276
- /**
277
- * Options for batch update operation
278
- */
279
- interface BatchUpdateOptions {
280
- /** AbortSignal for cancellation */
281
- signal?: AbortSignal;
282
- }
283
- /**
284
- * Record for batch update (includes id)
285
- */
286
- interface BatchUpdateRecord {
287
- id: string;
288
- record: FireberryRecord;
289
- }
290
- /**
291
- * Options for batch delete operation
292
- */
293
- interface BatchDeleteOptions {
294
- /** AbortSignal for cancellation */
295
- signal?: AbortSignal;
296
- }
297
- /**
298
- * Result of batch operation
299
- */
300
- interface BatchResult {
301
- /** Whether the operation was successful */
302
- success: boolean;
303
- /** Response data from API */
304
- data: unknown[];
305
- /** Number of records processed */
306
- count: number;
307
- }
308
- /**
309
- * Result of batch delete operation
310
- */
311
- interface BatchDeleteResult {
312
- /** Whether the operation was successful */
313
- success: boolean;
314
- /** IDs of deleted records */
315
- ids: string[];
316
- /** Number of records deleted */
317
- count: number;
318
- }
319
-
320
494
  /**
321
495
  * Records API for CRUD operations on Fireberry records
322
496
  */
@@ -707,9 +881,12 @@ declare class FilesAPI {
707
881
  */
708
882
  declare class FireberryClient {
709
883
  private readonly config;
884
+ private readonly normalizedConfig;
710
885
  private readonly cacheStore;
711
886
  private readonly inFlightQueries;
712
887
  private readonly queryCache;
888
+ private readonly transport;
889
+ private readonly metadataTransport;
713
890
  /** Metadata API operations */
714
891
  readonly metadata: MetadataAPI;
715
892
  /** Records CRUD operations */
@@ -725,9 +902,35 @@ declare class FireberryClient {
725
902
  */
726
903
  constructor(config: FireberryClientConfig);
727
904
  /**
728
- * Gets the client configuration
905
+ * Gets the client configuration with all defaults applied
906
+ */
907
+ getConfig(): Readonly<FireberryClientConfig & {
908
+ baseUrl: string;
909
+ timeout: number;
910
+ retryOn429: boolean;
911
+ maxRetries: number;
912
+ retryDelay: number;
913
+ cacheMetadata: boolean;
914
+ cacheTTL: number;
915
+ cacheQueryResults: boolean;
916
+ queryResultCacheTTL: number;
917
+ invalidateCacheOnMutation: boolean;
918
+ }>;
919
+ /**
920
+ * Gets the transport instance (for internal use by API modules)
921
+ * @internal
922
+ */
923
+ getTransport(): Transport;
924
+ /**
925
+ * Gets the metadata transport instance (for internal use by MetadataAPI)
926
+ * Returns null if metadata is not available (SDK-only mode without API key)
927
+ * @internal
928
+ */
929
+ getMetadataTransport(): HTTPTransport | null;
930
+ /**
931
+ * Checks if metadata operations are available
729
932
  */
730
- getConfig(): Readonly<Required<FireberryClientConfig>>;
933
+ isMetadataAvailable(): boolean;
731
934
  /**
732
935
  * Cache control methods
733
936
  */
@@ -826,26 +1029,16 @@ declare class FireberryClient {
826
1029
  * Internal query execution (without deduplication)
827
1030
  */
828
1031
  private executeQuery;
829
- /**
830
- * Fetches all pages of a query
831
- */
832
- private queryAllPages;
833
1032
  /**
834
1033
  * Expands '*' fields to actual field names, excluding problematic fields for specific object types
835
1034
  */
836
1035
  private expandStarFields;
837
1036
  /**
838
1037
  * Makes a raw API request to the Fireberry API
1038
+ * @deprecated Use getTransport() or getMetadataTransport() for new code
1039
+ * @internal This method is kept for backwards compatibility with API modules
839
1040
  */
840
1041
  request<T = unknown>(options: RequestOptions): Promise<T>;
841
- /**
842
- * Executes a fetch request with retry logic for 429 errors
843
- */
844
- private executeWithRetry;
845
- /**
846
- * Combines multiple abort signals into one
847
- */
848
- private combineSignals;
849
1042
  }
850
1043
 
851
1044
  /**
@@ -1076,4 +1269,4 @@ declare function expandRelatedFields(fields: string[]): string[];
1076
1269
  */
1077
1270
  declare function getRelatedFieldInfo(fieldName: string): (RelatedFieldInfo & RelatedFieldResolution) | null;
1078
1271
 
1079
- export { type CreateTextFieldOptions as A, type BatchCreateOptions as B, type CacheControl as C, type DeleteOptions as D, type CreateNumberFieldOptions as E, FireberryClient as F, type GetObjectsResult as G, type CreateLookupFieldOptions as H, ID_FIELD_TO_OBJECT_TYPE as I, type CreatePicklistFieldOptions as J, type CreateSummaryFieldOptions as K, type FormulaFieldType as L, type CreateFormulaFieldOptions as M, type CreateSimpleFieldOptions as N, type CreateFieldOptions as O, type PicklistValue as P, type CreateFieldResult as Q, RelatedFieldResolver as R, type SummaryType as S, type FileUploadOptions as T, type UpdateOptions as U, type FileUploadResult as V, isCodeField as W, getCodeFieldFromLabel as X, getLabelFieldFromCode as Y, isDropdownFieldByMetadata as Z, getObjectTypeFromReferenceField as a, type RelatedFieldInfo as b, type RelatedFieldResolution as c, type FieldMetadataMap as d, expandRelatedFields as e, type FireberryClientConfig as f, getRelatedFieldInfo as g, type RequestOptions as h, type FireberryRecord as i, type CreateOptions as j, type UpsertOptions as k, type UpsertResult as l, type BatchUpdateOptions as m, type BatchUpdateRecord as n, type BatchDeleteOptions as o, parseRelatedField as p, type BatchResult as q, resolveRelatedField as r, type BatchDeleteResult as s, type FireberryObject as t, type FireberryField as u, type FieldValue as v, type GetFieldsResult as w, type GetFieldValuesResult as x, type CreateFieldType as y, type CreateFieldOptionsBase as z };
1272
+ export { isHTTPTransportConfig as $, type CreateTextFieldOptions as A, type BatchCreateOptions as B, type CacheControl as C, type DeleteOptions as D, type CreateNumberFieldOptions as E, FireberryClient as F, type GetObjectsResult as G, type CreateLookupFieldOptions as H, ID_FIELD_TO_OBJECT_TYPE as I, type CreatePicklistFieldOptions as J, type CreateSummaryFieldOptions as K, type FormulaFieldType as L, type CreateFormulaFieldOptions as M, type CreateSimpleFieldOptions as N, type CreateFieldOptions as O, type PicklistValue as P, type CreateFieldResult as Q, RelatedFieldResolver as R, type SummaryType as S, type FileUploadOptions as T, type UpdateOptions as U, type FileUploadResult as V, type Transport as W, type TransportRequestOptions as X, type HTTPTransportConfig as Y, type SDKTransportConfig as Z, type TransportConfig as _, getObjectTypeFromReferenceField as a, isSDKTransportConfig as a0, isCodeField as a1, getCodeFieldFromLabel as a2, getLabelFieldFromCode as a3, isDropdownFieldByMetadata as a4, type RelatedFieldInfo as b, type RelatedFieldResolution as c, type FieldMetadataMap as d, expandRelatedFields as e, type FireberryClientConfig as f, getRelatedFieldInfo as g, type RequestOptions as h, type FireberryRecord as i, type CreateOptions as j, type UpsertOptions as k, type UpsertResult as l, type BatchUpdateOptions as m, type BatchUpdateRecord as n, type BatchDeleteOptions as o, parseRelatedField as p, type BatchResult as q, resolveRelatedField as r, type BatchDeleteResult as s, type FireberryObject as t, type FireberryField as u, type FieldValue as v, type GetFieldsResult as w, type GetFieldValuesResult as x, type CreateFieldType as y, type CreateFieldOptionsBase as z };