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,372 @@
1
+ export { C as ConditionBuilder, 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, Q as QueryBuilder, e as escapeQueryValue, d as getExcludedFieldsForStarQuery, c as getNameFieldByObjectType, g as getObjectIdFieldName, s as sanitizeQuery } from '../excludedFields-CGXgZN8Y.js';
2
+ export { g as getLabelFieldForField, i as isDropdownField, b as isDropdownOrLookupField, a as isLookupField } from '../fieldTypes-BLzJTzpI.js';
3
+
4
+ /**
5
+ * Type definitions for @fireberry/sdk compatibility
6
+ * These types mirror the Fireberry SDK's API for seamless integration
7
+ */
8
+ /**
9
+ * Query payload expected by the Fireberry SDK
10
+ */
11
+ interface SDKQueryPayload {
12
+ /** Comma-separated field names to return */
13
+ fields: string;
14
+ /** Query filter string */
15
+ query: string;
16
+ /** Number of records per page */
17
+ page_size?: number;
18
+ /** Page number (1-based) */
19
+ page_number?: number;
20
+ }
21
+ /**
22
+ * Response error from SDK
23
+ */
24
+ interface SDKResponseError {
25
+ data: Record<string, unknown> & {
26
+ Message?: string;
27
+ };
28
+ status: number;
29
+ statusText: string;
30
+ }
31
+ /**
32
+ * Response data from SDK operations
33
+ */
34
+ interface SDKResponseData<T = Record<string, unknown>> {
35
+ type?: string;
36
+ success: boolean;
37
+ data: T & {
38
+ requestId?: string;
39
+ };
40
+ error?: SDKResponseError;
41
+ isParentReady: boolean;
42
+ requestId: string;
43
+ }
44
+ /**
45
+ * Record details from SDK context
46
+ */
47
+ interface SDKRecordDetails {
48
+ type?: number;
49
+ id?: string;
50
+ }
51
+ /**
52
+ * User details from SDK context
53
+ */
54
+ interface SDKUserDetails {
55
+ fullName?: string;
56
+ id?: string;
57
+ }
58
+ /**
59
+ * SDK context information
60
+ */
61
+ interface SDKContext {
62
+ user: SDKUserDetails;
63
+ record: SDKRecordDetails;
64
+ }
65
+ /**
66
+ * Generic payload type for create/update operations
67
+ */
68
+ type SDKPayload = Record<string, unknown>;
69
+ /**
70
+ * Fireberry SDK API interface
71
+ * Matches the API surface of @fireberry/sdk
72
+ */
73
+ interface FireberrySDKAPI<TData = Record<string, unknown>> {
74
+ /** Query records with filtering and pagination */
75
+ query: (objectType: string | number, payload: SDKQueryPayload) => Promise<SDKResponseData<TData>>;
76
+ /** Create a new record */
77
+ create: <T extends SDKPayload>(objectType: string | number, payload: T) => Promise<SDKResponseData<TData>>;
78
+ /** Delete a record by ID */
79
+ delete: (objectType: string | number, recordId: string) => Promise<SDKResponseData<TData>>;
80
+ /** Update an existing record */
81
+ update: <T extends SDKPayload>(objectType: string | number, recordId: string, payload: T) => Promise<SDKResponseData<TData>>;
82
+ }
83
+ /**
84
+ * Fireberry SDK Client interface
85
+ * Matches the structure of FireberryClientSDK from @fireberry/sdk
86
+ */
87
+ interface FireberrySDKClient<TData = Record<string, unknown>> {
88
+ /** Access to CRUD API methods */
89
+ readonly api: FireberrySDKAPI<TData>;
90
+ /** Current context (record and user info) - null if not initialized */
91
+ readonly context: SDKContext | null;
92
+ /** Initialize context from parent Fireberry window */
93
+ initializeContext(): Promise<FireberrySDKClient<TData>>;
94
+ /** Clean up event listeners and pending requests */
95
+ destroy(): void;
96
+ }
97
+
98
+ /**
99
+ * SDK Adapter for @fireberry/sdk
100
+ *
101
+ * This module provides utilities to enhance the Fireberry SDK with
102
+ * QueryBuilder and field mapping capabilities from fireberry-api-client.
103
+ *
104
+ * @example
105
+ * ```typescript
106
+ * import FireberryClientSDK from '@fireberry/sdk/client';
107
+ * import { createSDKQueryBuilder, EnhancedSDK } from 'fireberry-api-client/sdk';
108
+ *
109
+ * // Option 1: Use query builder factory
110
+ * const sdk = new FireberryClientSDK();
111
+ * await sdk.initializeContext();
112
+ *
113
+ * const queryBuilder = createSDKQueryBuilder(sdk);
114
+ * const results = await queryBuilder(1)
115
+ * .select('accountid', 'accountname', 'statuscode')
116
+ * .where('statuscode').equals('1')
117
+ * .execute();
118
+ *
119
+ * // Option 2: Use enhanced SDK wrapper
120
+ * const enhanced = EnhancedSDK.create(sdk);
121
+ * const results = await enhanced
122
+ * .query(1)
123
+ * .select('accountid', 'accountname')
124
+ * .where('statuscode').equals('1')
125
+ * .execute();
126
+ * ```
127
+ *
128
+ * @packageDocumentation
129
+ */
130
+
131
+ /**
132
+ * Condition builder that returns SDKQueryBuilder for fluent chaining
133
+ */
134
+ interface SDKConditionBuilder {
135
+ equals(value: string | number): SDKQueryBuilder;
136
+ notEquals(value: string | number): SDKQueryBuilder;
137
+ lessThan(value: string | number): SDKQueryBuilder;
138
+ greaterThan(value: string | number): SDKQueryBuilder;
139
+ lessThanOrEqual(value: string | number): SDKQueryBuilder;
140
+ greaterThanOrEqual(value: string | number): SDKQueryBuilder;
141
+ contains(value: string): SDKQueryBuilder;
142
+ notContains(value: string): SDKQueryBuilder;
143
+ startsWith(value: string): SDKQueryBuilder;
144
+ notStartsWith(value: string): SDKQueryBuilder;
145
+ isNull(): SDKQueryBuilder;
146
+ isNotNull(): SDKQueryBuilder;
147
+ }
148
+ /**
149
+ * SDK-compatible query builder that executes via the Fireberry SDK
150
+ */
151
+ declare class SDKQueryBuilder {
152
+ private builder;
153
+ private objectTypeId;
154
+ private sdk;
155
+ private selectedFields;
156
+ private pageSizeValue?;
157
+ private pageNum;
158
+ constructor(sdk: FireberrySDKAPI, objectType: number | string);
159
+ /**
160
+ * Select fields to return
161
+ * @param fields - Field names to include in results
162
+ */
163
+ select(...fields: string[]): this;
164
+ /**
165
+ * Select fields with their label fields automatically included
166
+ * Useful for dropdown and lookup fields where you want both ID and display value
167
+ * @param fields - Field names to include
168
+ */
169
+ selectWithLabels(...fields: string[]): this;
170
+ /**
171
+ * Start a WHERE condition
172
+ * @param field - Field name to filter on
173
+ */
174
+ where(field: string): SDKConditionBuilder;
175
+ /**
176
+ * Add AND logical operator
177
+ */
178
+ and(): this;
179
+ /**
180
+ * Add OR logical operator
181
+ */
182
+ or(): this;
183
+ /**
184
+ * Set page size for pagination
185
+ * @param size - Number of records per page
186
+ */
187
+ pageSize(size: number): this;
188
+ /**
189
+ * Set page number for pagination
190
+ * @param page - Page number (1-based)
191
+ */
192
+ page(page: number): this;
193
+ /**
194
+ * Build the query payload without executing
195
+ * Useful if you want to modify the payload before sending
196
+ */
197
+ toQueryPayload(): SDKQueryPayload;
198
+ /**
199
+ * Execute the query via the SDK
200
+ */
201
+ execute<T = Record<string, unknown>>(): Promise<SDKResponseData<T>>;
202
+ }
203
+ /**
204
+ * Creates a query builder factory bound to a Fireberry SDK instance
205
+ *
206
+ * @param sdk - Fireberry SDK client or API instance
207
+ * @returns Factory function that creates SDKQueryBuilder instances
208
+ *
209
+ * @example
210
+ * ```typescript
211
+ * import FireberryClientSDK from '@fireberry/sdk/client';
212
+ * import { createSDKQueryBuilder } from 'fireberry-api-client/sdk';
213
+ *
214
+ * const sdk = new FireberryClientSDK();
215
+ * await sdk.initializeContext();
216
+ *
217
+ * const queryBuilder = createSDKQueryBuilder(sdk);
218
+ *
219
+ * // Query accounts where status is active
220
+ * const results = await queryBuilder(1) // 1 = Account object type
221
+ * .select('accountid', 'accountname', 'statuscode', 'status')
222
+ * .where('statuscode').equals('1')
223
+ * .pageSize(50)
224
+ * .execute();
225
+ * ```
226
+ */
227
+ declare function createSDKQueryBuilder(sdk: FireberrySDKClient | FireberrySDKAPI): (objectType: number | string) => SDKQueryBuilder;
228
+ /**
229
+ * Enhanced SDK wrapper that combines Fireberry SDK with utility functions
230
+ * Provides a more feature-rich API for working with Fireberry data
231
+ */
232
+ declare class EnhancedSDK<TData = Record<string, unknown>> {
233
+ private sdk;
234
+ private constructor();
235
+ /**
236
+ * Create an EnhancedSDK wrapper around an existing SDK instance
237
+ * The SDK should already be initialized with context
238
+ *
239
+ * @param sdk - Initialized Fireberry SDK client
240
+ */
241
+ static create<T = Record<string, unknown>>(sdk: FireberrySDKClient<T>): EnhancedSDK<T>;
242
+ /**
243
+ * Get the current context (user and record info)
244
+ */
245
+ get context(): SDKContext | null;
246
+ /**
247
+ * Get the underlying SDK API for direct access
248
+ */
249
+ get api(): FireberrySDKAPI<TData>;
250
+ /**
251
+ * Get the current user ID from context
252
+ */
253
+ get userId(): string | undefined;
254
+ /**
255
+ * Get the current user's full name from context
256
+ */
257
+ get userFullName(): string | undefined;
258
+ /**
259
+ * Get the current record ID from context
260
+ */
261
+ get recordId(): string | undefined;
262
+ /**
263
+ * Get the current record's object type from context
264
+ */
265
+ get recordType(): number | undefined;
266
+ /**
267
+ * Start building a query for an object type
268
+ *
269
+ * @param objectType - Object type ID (e.g., 1 for Account, 2 for Contact)
270
+ * @returns SDKQueryBuilder for fluent query construction
271
+ *
272
+ * @example
273
+ * ```typescript
274
+ * const results = await enhanced
275
+ * .query(1)
276
+ * .select('accountid', 'accountname')
277
+ * .where('ownerid').equals(enhanced.userId)
278
+ * .execute();
279
+ * ```
280
+ */
281
+ query(objectType: number | string): SDKQueryBuilder;
282
+ /**
283
+ * Get the primary key field name for an object type
284
+ *
285
+ * @param objectType - Object type ID
286
+ * @returns Primary key field name (e.g., 'accountid' for type 1)
287
+ *
288
+ * @example
289
+ * ```typescript
290
+ * const idField = enhanced.getIdField(1); // 'accountid'
291
+ * const idField = enhanced.getIdField(2); // 'contactid'
292
+ * ```
293
+ */
294
+ getIdField(objectType: number | string): string;
295
+ /**
296
+ * Get the display name field for an object type
297
+ *
298
+ * @param objectType - Object type ID
299
+ * @returns Name field (e.g., 'accountname' for type 1, 'fullname' for type 2)
300
+ *
301
+ * @example
302
+ * ```typescript
303
+ * const nameField = enhanced.getNameField(1); // 'accountname'
304
+ * const nameField = enhanced.getNameField(2); // 'fullname'
305
+ * ```
306
+ */
307
+ getNameField(objectType: number | string): string;
308
+ /**
309
+ * Get the label field for a dropdown or lookup field
310
+ *
311
+ * @param fieldName - API field name
312
+ * @param objectType - Object type ID
313
+ * @returns Label field name, or empty string if not applicable
314
+ *
315
+ * @example
316
+ * ```typescript
317
+ * const labelField = enhanced.getLabelField('statuscode', 1); // 'status'
318
+ * const labelField = enhanced.getLabelField('ownerid', 1); // 'ownername'
319
+ * ```
320
+ */
321
+ getLabelField(fieldName: string, objectType: number | string): string;
322
+ /**
323
+ * Get fields that should be excluded from * (star) queries for an object type
324
+ * Some fields cause API errors when included in broad queries
325
+ *
326
+ * @param objectType - Object type ID
327
+ * @returns Array of field names to exclude
328
+ */
329
+ getExcludedFields(objectType: number | string): string[];
330
+ /**
331
+ * Expand field list to include label fields for dropdowns and lookups
332
+ *
333
+ * @param fields - Original field list
334
+ * @param objectType - Object type ID
335
+ * @returns Expanded field list with label fields
336
+ *
337
+ * @example
338
+ * ```typescript
339
+ * const fields = enhanced.expandFieldsWithLabels(['statuscode', 'ownerid'], 1);
340
+ * // Returns: ['statuscode', 'status', 'ownerid', 'ownername']
341
+ * ```
342
+ */
343
+ expandFieldsWithLabels(fields: string[], objectType: number | string): string[];
344
+ /**
345
+ * Create a record
346
+ *
347
+ * @param objectType - Object type ID
348
+ * @param data - Record data
349
+ */
350
+ create<T extends Record<string, unknown>>(objectType: number | string, data: T): Promise<SDKResponseData<TData>>;
351
+ /**
352
+ * Update a record
353
+ *
354
+ * @param objectType - Object type ID
355
+ * @param recordId - Record ID to update
356
+ * @param data - Updated field values
357
+ */
358
+ update<T extends Record<string, unknown>>(objectType: number | string, recordId: string, data: T): Promise<SDKResponseData<TData>>;
359
+ /**
360
+ * Delete a record
361
+ *
362
+ * @param objectType - Object type ID
363
+ * @param recordId - Record ID to delete
364
+ */
365
+ delete(objectType: number | string, recordId: string): Promise<SDKResponseData<TData>>;
366
+ /**
367
+ * Clean up the underlying SDK
368
+ */
369
+ destroy(): void;
370
+ }
371
+
372
+ export { EnhancedSDK, type FireberrySDKAPI, type FireberrySDKClient, type SDKContext, SDKQueryBuilder, type SDKQueryPayload, type SDKResponseData, createSDKQueryBuilder };