@uipath/uipath-typescript 1.2.2 → 1.3.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.
Files changed (41) hide show
  1. package/dist/assets/index.cjs +5 -8
  2. package/dist/assets/index.d.ts +3 -1
  3. package/dist/assets/index.mjs +5 -8
  4. package/dist/attachments/index.cjs +5 -8
  5. package/dist/attachments/index.d.ts +3 -1
  6. package/dist/attachments/index.mjs +5 -8
  7. package/dist/buckets/index.cjs +5 -8
  8. package/dist/buckets/index.d.ts +3 -1
  9. package/dist/buckets/index.mjs +5 -8
  10. package/dist/cases/index.cjs +5 -8
  11. package/dist/cases/index.d.ts +3 -1
  12. package/dist/cases/index.mjs +5 -8
  13. package/dist/conversational-agent/index.cjs +38 -16
  14. package/dist/conversational-agent/index.d.ts +26 -4
  15. package/dist/conversational-agent/index.mjs +38 -16
  16. package/dist/core/index.cjs +2 -2
  17. package/dist/core/index.d.ts +2 -2
  18. package/dist/core/index.mjs +2 -2
  19. package/dist/entities/index.cjs +697 -317
  20. package/dist/entities/index.d.ts +572 -58
  21. package/dist/entities/index.mjs +698 -318
  22. package/dist/index.cjs +727 -161
  23. package/dist/index.d.ts +697 -69
  24. package/dist/index.mjs +727 -162
  25. package/dist/index.umd.js +727 -161
  26. package/dist/jobs/index.cjs +278 -20
  27. package/dist/jobs/index.d.ts +214 -19
  28. package/dist/jobs/index.mjs +278 -21
  29. package/dist/maestro-processes/index.cjs +5 -8
  30. package/dist/maestro-processes/index.d.ts +3 -1
  31. package/dist/maestro-processes/index.mjs +5 -8
  32. package/dist/processes/index.cjs +5 -8
  33. package/dist/processes/index.d.ts +3 -1
  34. package/dist/processes/index.mjs +5 -8
  35. package/dist/queues/index.cjs +5 -8
  36. package/dist/queues/index.d.ts +3 -1
  37. package/dist/queues/index.mjs +5 -8
  38. package/dist/tasks/index.cjs +5 -8
  39. package/dist/tasks/index.d.ts +3 -1
  40. package/dist/tasks/index.mjs +5 -8
  41. package/package.json +1 -1
@@ -43,31 +43,43 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
43
43
  };
44
44
 
45
45
  /**
46
- * Type guards for error response types
46
+ * Base error class for all UiPath SDK errors
47
+ * Extends Error for standard error handling compatibility
47
48
  */
48
- function isOrchestratorError(error) {
49
- return typeof error === 'object' &&
50
- error !== null &&
51
- 'message' in error &&
52
- 'errorCode' in error &&
53
- typeof error.message === 'string' &&
54
- typeof error.errorCode === 'number';
55
- }
56
- function isEntityError(error) {
57
- return typeof error === 'object' &&
58
- error !== null &&
59
- 'error' in error &&
60
- typeof error.error === 'string';
61
- }
62
- function isPimsError(error) {
63
- return typeof error === 'object' &&
64
- error !== null &&
65
- 'type' in error &&
66
- 'title' in error &&
67
- 'status' in error &&
68
- typeof error.type === 'string' &&
69
- typeof error.title === 'string' &&
70
- typeof error.status === 'number';
49
+ class UiPathError extends Error {
50
+ constructor(type, params) {
51
+ super(params.message);
52
+ this.name = type;
53
+ this.type = type;
54
+ this.statusCode = params.statusCode;
55
+ this.requestId = params.requestId;
56
+ this.timestamp = new Date();
57
+ // Maintains proper stack trace for where our error was thrown
58
+ if (Error.captureStackTrace) {
59
+ Error.captureStackTrace(this, this.constructor);
60
+ }
61
+ }
62
+ /**
63
+ * Returns a clean JSON representation of the error
64
+ */
65
+ toJSON() {
66
+ return {
67
+ type: this.type,
68
+ message: this.message,
69
+ statusCode: this.statusCode,
70
+ requestId: this.requestId,
71
+ timestamp: this.timestamp
72
+ };
73
+ }
74
+ /**
75
+ * Returns detailed debug information including stack trace
76
+ */
77
+ getDebugInfo() {
78
+ return {
79
+ ...this.toJSON(),
80
+ stack: this.stack
81
+ };
82
+ }
71
83
  }
72
84
 
73
85
  /**
@@ -131,6 +143,161 @@ const ErrorMessages = {
131
143
  const ErrorNames = {
132
144
  ABORT_ERROR: 'AbortError'};
133
145
 
146
+ /**
147
+ * Error thrown when authentication fails (401 errors)
148
+ * Common scenarios:
149
+ * - Invalid credentials
150
+ * - Expired token
151
+ * - Missing authentication
152
+ */
153
+ class AuthenticationError extends UiPathError {
154
+ constructor(params = {}) {
155
+ super(ErrorType.AUTHENTICATION, {
156
+ message: params.message || ErrorMessages.AUTHENTICATION_FAILED,
157
+ statusCode: params.statusCode ?? HttpStatus.UNAUTHORIZED,
158
+ requestId: params.requestId
159
+ });
160
+ }
161
+ }
162
+
163
+ /**
164
+ * Error thrown when authorization fails (403 errors)
165
+ * Common scenarios:
166
+ * - Insufficient permissions
167
+ * - Access denied to resource
168
+ * - Invalid scope
169
+ */
170
+ class AuthorizationError extends UiPathError {
171
+ constructor(params = {}) {
172
+ super(ErrorType.AUTHORIZATION, {
173
+ message: params.message || ErrorMessages.ACCESS_DENIED,
174
+ statusCode: params.statusCode ?? HttpStatus.FORBIDDEN,
175
+ requestId: params.requestId
176
+ });
177
+ }
178
+ }
179
+
180
+ /**
181
+ * Error thrown when validation fails (400 errors or client-side validation)
182
+ * Common scenarios:
183
+ * - Invalid input parameters
184
+ * - Missing required fields
185
+ * - Invalid data format
186
+ */
187
+ class ValidationError extends UiPathError {
188
+ constructor(params = {}) {
189
+ super(ErrorType.VALIDATION, {
190
+ message: params.message || ErrorMessages.VALIDATION_FAILED,
191
+ statusCode: params.statusCode ?? HttpStatus.BAD_REQUEST,
192
+ requestId: params.requestId
193
+ });
194
+ }
195
+ }
196
+
197
+ /**
198
+ * Error thrown when a resource is not found (404 errors)
199
+ * Common scenarios:
200
+ * - Resource doesn't exist
201
+ * - Invalid ID provided
202
+ * - Resource deleted
203
+ */
204
+ class NotFoundError extends UiPathError {
205
+ constructor(params = {}) {
206
+ super(ErrorType.NOT_FOUND, {
207
+ message: params.message || ErrorMessages.RESOURCE_NOT_FOUND,
208
+ statusCode: params.statusCode ?? HttpStatus.NOT_FOUND,
209
+ requestId: params.requestId
210
+ });
211
+ }
212
+ }
213
+
214
+ /**
215
+ * Error thrown when rate limit is exceeded (429 errors)
216
+ * Common scenarios:
217
+ * - Too many requests in a time window
218
+ * - API throttling
219
+ */
220
+ class RateLimitError extends UiPathError {
221
+ constructor(params = {}) {
222
+ super(ErrorType.RATE_LIMIT, {
223
+ message: params.message || ErrorMessages.RATE_LIMIT_EXCEEDED,
224
+ statusCode: params.statusCode ?? HttpStatus.TOO_MANY_REQUESTS,
225
+ requestId: params.requestId
226
+ });
227
+ }
228
+ }
229
+
230
+ /**
231
+ * Error thrown when server encounters an error (5xx errors)
232
+ * Common scenarios:
233
+ * - Internal server error
234
+ * - Service unavailable
235
+ * - Gateway timeout
236
+ */
237
+ class ServerError extends UiPathError {
238
+ constructor(params = {}) {
239
+ super(ErrorType.SERVER, {
240
+ message: params.message || ErrorMessages.INTERNAL_SERVER_ERROR,
241
+ statusCode: params.statusCode ?? HttpStatus.INTERNAL_SERVER_ERROR,
242
+ requestId: params.requestId
243
+ });
244
+ }
245
+ /**
246
+ * Checks if this is a temporary error that might succeed on retry
247
+ */
248
+ get isRetryable() {
249
+ return this.statusCode === HttpStatus.BAD_GATEWAY ||
250
+ this.statusCode === HttpStatus.SERVICE_UNAVAILABLE ||
251
+ this.statusCode === HttpStatus.GATEWAY_TIMEOUT;
252
+ }
253
+ }
254
+
255
+ /**
256
+ * Error thrown when network/connection issues occur
257
+ * Common scenarios:
258
+ * - Connection timeout
259
+ * - DNS resolution failure
260
+ * - Network unreachable
261
+ * - Request aborted
262
+ */
263
+ class NetworkError extends UiPathError {
264
+ constructor(params = {}) {
265
+ super(ErrorType.NETWORK, {
266
+ message: params.message || ErrorMessages.NETWORK_ERROR,
267
+ statusCode: params.statusCode, // Network errors typically don't have HTTP status codes
268
+ requestId: params.requestId
269
+ });
270
+ }
271
+ }
272
+
273
+ /**
274
+ * Type guards for error response types
275
+ */
276
+ function isOrchestratorError(error) {
277
+ return typeof error === 'object' &&
278
+ error !== null &&
279
+ 'message' in error &&
280
+ 'errorCode' in error &&
281
+ typeof error.message === 'string' &&
282
+ typeof error.errorCode === 'number';
283
+ }
284
+ function isEntityError(error) {
285
+ return typeof error === 'object' &&
286
+ error !== null &&
287
+ 'error' in error &&
288
+ typeof error.error === 'string';
289
+ }
290
+ function isPimsError(error) {
291
+ return typeof error === 'object' &&
292
+ error !== null &&
293
+ 'type' in error &&
294
+ 'title' in error &&
295
+ 'status' in error &&
296
+ typeof error.type === 'string' &&
297
+ typeof error.title === 'string' &&
298
+ typeof error.status === 'number';
299
+ }
300
+
134
301
  /**
135
302
  * Parser for Orchestrator/Task error format
136
303
  */
@@ -281,173 +448,6 @@ class ErrorResponseParser {
281
448
  // Export singleton instance
282
449
  const errorResponseParser = new ErrorResponseParser();
283
450
 
284
- /**
285
- * Base error class for all UiPath SDK errors
286
- * Extends Error for standard error handling compatibility
287
- */
288
- class UiPathError extends Error {
289
- constructor(type, params) {
290
- super(params.message);
291
- this.name = type;
292
- this.type = type;
293
- this.statusCode = params.statusCode;
294
- this.requestId = params.requestId;
295
- this.timestamp = new Date();
296
- // Maintains proper stack trace for where our error was thrown
297
- if (Error.captureStackTrace) {
298
- Error.captureStackTrace(this, this.constructor);
299
- }
300
- }
301
- /**
302
- * Returns a clean JSON representation of the error
303
- */
304
- toJSON() {
305
- return {
306
- type: this.type,
307
- message: this.message,
308
- statusCode: this.statusCode,
309
- requestId: this.requestId,
310
- timestamp: this.timestamp
311
- };
312
- }
313
- /**
314
- * Returns detailed debug information including stack trace
315
- */
316
- getDebugInfo() {
317
- return {
318
- ...this.toJSON(),
319
- stack: this.stack
320
- };
321
- }
322
- }
323
-
324
- /**
325
- * Error thrown when authentication fails (401 errors)
326
- * Common scenarios:
327
- * - Invalid credentials
328
- * - Expired token
329
- * - Missing authentication
330
- */
331
- class AuthenticationError extends UiPathError {
332
- constructor(params = {}) {
333
- super(ErrorType.AUTHENTICATION, {
334
- message: params.message || ErrorMessages.AUTHENTICATION_FAILED,
335
- statusCode: params.statusCode ?? HttpStatus.UNAUTHORIZED,
336
- requestId: params.requestId
337
- });
338
- }
339
- }
340
-
341
- /**
342
- * Error thrown when authorization fails (403 errors)
343
- * Common scenarios:
344
- * - Insufficient permissions
345
- * - Access denied to resource
346
- * - Invalid scope
347
- */
348
- class AuthorizationError extends UiPathError {
349
- constructor(params = {}) {
350
- super(ErrorType.AUTHORIZATION, {
351
- message: params.message || ErrorMessages.ACCESS_DENIED,
352
- statusCode: params.statusCode ?? HttpStatus.FORBIDDEN,
353
- requestId: params.requestId
354
- });
355
- }
356
- }
357
-
358
- /**
359
- * Error thrown when validation fails (400 errors or client-side validation)
360
- * Common scenarios:
361
- * - Invalid input parameters
362
- * - Missing required fields
363
- * - Invalid data format
364
- */
365
- class ValidationError extends UiPathError {
366
- constructor(params = {}) {
367
- super(ErrorType.VALIDATION, {
368
- message: params.message || ErrorMessages.VALIDATION_FAILED,
369
- statusCode: params.statusCode ?? HttpStatus.BAD_REQUEST,
370
- requestId: params.requestId
371
- });
372
- }
373
- }
374
-
375
- /**
376
- * Error thrown when a resource is not found (404 errors)
377
- * Common scenarios:
378
- * - Resource doesn't exist
379
- * - Invalid ID provided
380
- * - Resource deleted
381
- */
382
- class NotFoundError extends UiPathError {
383
- constructor(params = {}) {
384
- super(ErrorType.NOT_FOUND, {
385
- message: params.message || ErrorMessages.RESOURCE_NOT_FOUND,
386
- statusCode: params.statusCode ?? HttpStatus.NOT_FOUND,
387
- requestId: params.requestId
388
- });
389
- }
390
- }
391
-
392
- /**
393
- * Error thrown when rate limit is exceeded (429 errors)
394
- * Common scenarios:
395
- * - Too many requests in a time window
396
- * - API throttling
397
- */
398
- class RateLimitError extends UiPathError {
399
- constructor(params = {}) {
400
- super(ErrorType.RATE_LIMIT, {
401
- message: params.message || ErrorMessages.RATE_LIMIT_EXCEEDED,
402
- statusCode: params.statusCode ?? HttpStatus.TOO_MANY_REQUESTS,
403
- requestId: params.requestId
404
- });
405
- }
406
- }
407
-
408
- /**
409
- * Error thrown when server encounters an error (5xx errors)
410
- * Common scenarios:
411
- * - Internal server error
412
- * - Service unavailable
413
- * - Gateway timeout
414
- */
415
- class ServerError extends UiPathError {
416
- constructor(params = {}) {
417
- super(ErrorType.SERVER, {
418
- message: params.message || ErrorMessages.INTERNAL_SERVER_ERROR,
419
- statusCode: params.statusCode ?? HttpStatus.INTERNAL_SERVER_ERROR,
420
- requestId: params.requestId
421
- });
422
- }
423
- /**
424
- * Checks if this is a temporary error that might succeed on retry
425
- */
426
- get isRetryable() {
427
- return this.statusCode === HttpStatus.BAD_GATEWAY ||
428
- this.statusCode === HttpStatus.SERVICE_UNAVAILABLE ||
429
- this.statusCode === HttpStatus.GATEWAY_TIMEOUT;
430
- }
431
- }
432
-
433
- /**
434
- * Error thrown when network/connection issues occur
435
- * Common scenarios:
436
- * - Connection timeout
437
- * - DNS resolution failure
438
- * - Network unreachable
439
- * - Request aborted
440
- */
441
- class NetworkError extends UiPathError {
442
- constructor(params = {}) {
443
- super(ErrorType.NETWORK, {
444
- message: params.message || ErrorMessages.NETWORK_ERROR,
445
- statusCode: params.statusCode, // Network errors typically don't have HTTP status codes
446
- requestId: params.requestId
447
- });
448
- }
449
- }
450
-
451
451
  /**
452
452
  * Factory for creating typed errors based on HTTP status codes
453
453
  * Follows the Factory pattern for clean error instantiation
@@ -524,15 +524,11 @@ const RESPONSE_TYPES = {
524
524
 
525
525
  class ApiClient {
526
526
  constructor(config, executionContext, tokenManager, clientConfig = {}) {
527
- this.defaultHeaders = {};
528
527
  this.config = config;
529
528
  this.executionContext = executionContext;
530
529
  this.clientConfig = clientConfig;
531
530
  this.tokenManager = tokenManager;
532
531
  }
533
- setDefaultHeaders(headers) {
534
- this.defaultHeaders = { ...this.defaultHeaders, ...headers };
535
- }
536
532
  /**
537
533
  * Gets a valid authentication token, refreshing if necessary.
538
534
  * Used internally for API requests and exposed for services that need manual auth headers.
@@ -548,7 +544,6 @@ class ApiClient {
548
544
  return {
549
545
  'Authorization': `Bearer ${token}`,
550
546
  'Content-Type': CONTENT_TYPES.JSON,
551
- ...this.defaultHeaders,
552
547
  ...this.clientConfig.headers
553
548
  };
554
549
  }
@@ -1409,6 +1404,8 @@ class BaseService {
1409
1404
  *
1410
1405
  * @param instance - UiPath SDK instance providing authentication and configuration.
1411
1406
  * Services receive this via dependency injection in the modular pattern.
1407
+ * @param headers - Optional default headers to include in every request (e.g. `x-uipath-external-user-id` for
1408
+ * CAS external-app auth)
1412
1409
  *
1413
1410
  * @example
1414
1411
  * ```typescript
@@ -1428,11 +1425,11 @@ class BaseService {
1428
1425
  * const entities = new Entities(sdk);
1429
1426
  * ```
1430
1427
  */
1431
- constructor(instance) {
1428
+ constructor(instance, headers) {
1432
1429
  // Private field - not visible via Object.keys() or any reflection
1433
1430
  _BaseService_apiClient.set(this, void 0);
1434
1431
  const { config, context, tokenManager } = SDKInternalsRegistry.get(instance);
1435
- __classPrivateFieldSet(this, _BaseService_apiClient, new ApiClient(config, context, tokenManager), "f");
1432
+ __classPrivateFieldSet(this, _BaseService_apiClient, new ApiClient(config, context, tokenManager, headers ? { headers } : {}), "f");
1436
1433
  }
1437
1434
  /**
1438
1435
  * Gets a valid authentication token, refreshing if necessary.
@@ -1691,34 +1688,145 @@ function createEntityMethods(entityData, service) {
1691
1688
  throw new Error('Entity ID is undefined');
1692
1689
  return service.deleteAttachment(entityData.id, recordId, fieldName);
1693
1690
  },
1691
+ async queryRecords(options) {
1692
+ if (!entityData.id)
1693
+ throw new Error('Entity ID is undefined');
1694
+ return service.queryRecordsById(entityData.id, options);
1695
+ },
1696
+ async importRecords(file) {
1697
+ if (!entityData.id)
1698
+ throw new Error('Entity ID is undefined');
1699
+ return service.importRecordsById(entityData.id, file);
1700
+ },
1694
1701
  async insert(data, options) {
1695
1702
  return this.insertRecord(data, options);
1696
1703
  },
1697
1704
  async batchInsert(data, options) {
1698
1705
  return this.insertRecords(data, options);
1699
1706
  },
1700
- async update(data, options) {
1701
- return this.updateRecords(data, options);
1702
- },
1703
- async delete(recordIds, options) {
1704
- return this.deleteRecords(recordIds, options);
1705
- },
1706
1707
  async getRecords(options) {
1707
1708
  return this.getAllRecords(options);
1708
- }
1709
+ },
1710
+ async delete() {
1711
+ if (!entityData.id)
1712
+ throw new Error('Entity ID is undefined');
1713
+ return service.deleteById(entityData.id);
1714
+ },
1715
+ async update(options) {
1716
+ if (!entityData.id)
1717
+ throw new Error('Entity ID is undefined');
1718
+ return service.updateById(entityData.id, options);
1719
+ },
1709
1720
  };
1710
1721
  }
1711
1722
  /**
1712
- * Creates an actionable entity metadata by combining entity with operational methods
1713
- *
1714
- * @param entityData - Entity metadata
1715
- * @param service - The entity service instance
1716
- * @returns Entity metadata with added methods
1723
+ * Creates an actionable entity by combining entity metadata with data and management methods
1724
+ *
1725
+ * @param entityMetadata - Entity metadata
1726
+ * @param service - The entity service instance
1727
+ * @returns Entity metadata with added methods
1728
+ */
1729
+ function createEntityWithMethods(entityData, service) {
1730
+ const methods = createEntityMethods(entityData, service);
1731
+ return Object.assign({}, entityData, methods);
1732
+ }
1733
+
1734
+ /**
1735
+ * Entity field data type names (SQL-level types returned by the API)
1736
+ */
1737
+ var EntityFieldDataType;
1738
+ (function (EntityFieldDataType) {
1739
+ EntityFieldDataType["UUID"] = "UUID";
1740
+ EntityFieldDataType["STRING"] = "STRING";
1741
+ EntityFieldDataType["INTEGER"] = "INTEGER";
1742
+ EntityFieldDataType["DATETIME"] = "DATETIME";
1743
+ EntityFieldDataType["DATETIME_WITH_TZ"] = "DATETIME_WITH_TZ";
1744
+ EntityFieldDataType["DECIMAL"] = "DECIMAL";
1745
+ EntityFieldDataType["FLOAT"] = "FLOAT";
1746
+ EntityFieldDataType["DOUBLE"] = "DOUBLE";
1747
+ EntityFieldDataType["DATE"] = "DATE";
1748
+ EntityFieldDataType["BOOLEAN"] = "BOOLEAN";
1749
+ EntityFieldDataType["BIG_INTEGER"] = "BIG_INTEGER";
1750
+ EntityFieldDataType["MULTILINE_TEXT"] = "MULTILINE_TEXT";
1751
+ EntityFieldDataType["FILE"] = "FILE";
1752
+ EntityFieldDataType["CHOICE_SET_SINGLE"] = "CHOICE_SET_SINGLE";
1753
+ EntityFieldDataType["CHOICE_SET_MULTIPLE"] = "CHOICE_SET_MULTIPLE";
1754
+ EntityFieldDataType["AUTO_NUMBER"] = "AUTO_NUMBER";
1755
+ EntityFieldDataType["RELATIONSHIP"] = "RELATIONSHIP";
1756
+ })(EntityFieldDataType || (EntityFieldDataType = {}));
1757
+ /**
1758
+ * Logical operator for combining query filter groups
1759
+ */
1760
+ var LogicalOperator;
1761
+ (function (LogicalOperator) {
1762
+ /** Combine conditions with AND — all conditions must match */
1763
+ LogicalOperator[LogicalOperator["And"] = 0] = "And";
1764
+ /** Combine conditions with OR — any condition must match */
1765
+ LogicalOperator[LogicalOperator["Or"] = 1] = "Or";
1766
+ })(LogicalOperator || (LogicalOperator = {}));
1767
+ /**
1768
+ * Comparison operators for entity query filters.
1769
+ * Not all operators are valid for all field types.
1770
+ */
1771
+ var QueryFilterOperator;
1772
+ (function (QueryFilterOperator) {
1773
+ QueryFilterOperator["Equals"] = "=";
1774
+ QueryFilterOperator["NotEquals"] = "!=";
1775
+ QueryFilterOperator["GreaterThan"] = ">";
1776
+ QueryFilterOperator["LessThan"] = "<";
1777
+ QueryFilterOperator["GreaterThanOrEqual"] = ">=";
1778
+ QueryFilterOperator["LessThanOrEqual"] = "<=";
1779
+ QueryFilterOperator["Contains"] = "contains";
1780
+ QueryFilterOperator["NotContains"] = "not contains";
1781
+ QueryFilterOperator["StartsWith"] = "startswith";
1782
+ QueryFilterOperator["EndsWith"] = "endswith";
1783
+ QueryFilterOperator["In"] = "in";
1784
+ QueryFilterOperator["NotIn"] = "not in";
1785
+ })(QueryFilterOperator || (QueryFilterOperator = {}));
1786
+ /**
1787
+ * Entity type enum
1717
1788
  */
1718
- function createEntityWithMethods(entityData, service) {
1719
- const methods = createEntityMethods(entityData, service);
1720
- return Object.assign({}, entityData, methods);
1721
- }
1789
+ var EntityType;
1790
+ (function (EntityType) {
1791
+ EntityType["Entity"] = "Entity";
1792
+ EntityType["ChoiceSet"] = "ChoiceSet";
1793
+ EntityType["InternalEntity"] = "InternalEntity";
1794
+ EntityType["SystemEntity"] = "SystemEntity";
1795
+ })(EntityType || (EntityType = {}));
1796
+ /**
1797
+ * Reference types for fields
1798
+ */
1799
+ var ReferenceType;
1800
+ (function (ReferenceType) {
1801
+ ReferenceType["ManyToOne"] = "ManyToOne";
1802
+ })(ReferenceType || (ReferenceType = {}));
1803
+ /**
1804
+ * Field display types
1805
+ */
1806
+ var FieldDisplayType;
1807
+ (function (FieldDisplayType) {
1808
+ FieldDisplayType["Basic"] = "Basic";
1809
+ FieldDisplayType["Relationship"] = "Relationship";
1810
+ FieldDisplayType["File"] = "File";
1811
+ FieldDisplayType["ChoiceSetSingle"] = "ChoiceSetSingle";
1812
+ FieldDisplayType["ChoiceSetMultiple"] = "ChoiceSetMultiple";
1813
+ FieldDisplayType["AutoNumber"] = "AutoNumber";
1814
+ })(FieldDisplayType || (FieldDisplayType = {}));
1815
+ /**
1816
+ * Data direction type for external fields
1817
+ */
1818
+ var DataDirectionType;
1819
+ (function (DataDirectionType) {
1820
+ DataDirectionType["ReadOnly"] = "ReadOnly";
1821
+ DataDirectionType["ReadAndWrite"] = "ReadAndWrite";
1822
+ })(DataDirectionType || (DataDirectionType = {}));
1823
+ /**
1824
+ * Join type for source join criteria
1825
+ */
1826
+ var JoinType;
1827
+ (function (JoinType) {
1828
+ JoinType["LeftJoin"] = "LeftJoin";
1829
+ })(JoinType || (JoinType = {}));
1722
1830
 
1723
1831
  /**
1724
1832
  * Base path constants for different services
@@ -1728,6 +1836,12 @@ const DATAFABRIC_BASE = 'datafabric_';
1728
1836
  /**
1729
1837
  * Data Fabric Service Endpoints
1730
1838
  */
1839
+ /**
1840
+ * Default folder key used for tenant-level Data Fabric entities.
1841
+ * Tenant-level entities are not scoped to a folder; this is the
1842
+ * conventional placeholder value the API expects.
1843
+ */
1844
+ const DATA_FABRIC_TENANT_FOLDER_ID = '00000000-0000-0000-0000-000000000000';
1731
1845
  /**
1732
1846
  * Data Fabric Entity Service Endpoints
1733
1847
  */
@@ -1742,6 +1856,11 @@ const DATA_FABRIC_ENDPOINTS = {
1742
1856
  UPDATE_RECORD_BY_ID: (entityId, recordId) => `${DATAFABRIC_BASE}/api/EntityService/entity/${entityId}/update/${recordId}`,
1743
1857
  UPDATE_BY_ID: (entityId) => `${DATAFABRIC_BASE}/api/EntityService/entity/${entityId}/update-batch`,
1744
1858
  DELETE_BY_ID: (entityId) => `${DATAFABRIC_BASE}/api/EntityService/entity/${entityId}/delete-batch`,
1859
+ UPSERT: `${DATAFABRIC_BASE}/api/Entity`,
1860
+ DELETE: (entityId) => `${DATAFABRIC_BASE}/api/Entity/${entityId}`,
1861
+ UPDATE_METADATA: (entityId) => `${DATAFABRIC_BASE}/api/Entity/${entityId}/metadata`,
1862
+ QUERY_BY_ID: (entityId) => `${DATAFABRIC_BASE}/api/EntityService/entity/${entityId}/query`,
1863
+ BULK_UPLOAD_BY_ID: (entityId) => `${DATAFABRIC_BASE}/api/EntityService/entity/${entityId}/bulk-upload`,
1745
1864
  DOWNLOAD_ATTACHMENT: (entityId, recordId, fieldName) => `${DATAFABRIC_BASE}/api/Attachment/entity/${entityId}/${recordId}/${fieldName}`,
1746
1865
  UPLOAD_ATTACHMENT: (entityId, recordId, fieldName) => `${DATAFABRIC_BASE}/api/Attachment/entity/${entityId}/${recordId}/${fieldName}`,
1747
1866
  DELETE_ATTACHMENT: (entityId, recordId, fieldName) => `${DATAFABRIC_BASE}/api/Attachment/entity/${entityId}/${recordId}/${fieldName}`,
@@ -1787,69 +1906,6 @@ function createParams(paramsObj = {}) {
1787
1906
  return params;
1788
1907
  }
1789
1908
 
1790
- /**
1791
- * Entity field type names
1792
- */
1793
- var EntityFieldDataType;
1794
- (function (EntityFieldDataType) {
1795
- EntityFieldDataType["UUID"] = "UUID";
1796
- EntityFieldDataType["STRING"] = "STRING";
1797
- EntityFieldDataType["INTEGER"] = "INTEGER";
1798
- EntityFieldDataType["DATETIME"] = "DATETIME";
1799
- EntityFieldDataType["DATETIME_WITH_TZ"] = "DATETIME_WITH_TZ";
1800
- EntityFieldDataType["DECIMAL"] = "DECIMAL";
1801
- EntityFieldDataType["FLOAT"] = "FLOAT";
1802
- EntityFieldDataType["DOUBLE"] = "DOUBLE";
1803
- EntityFieldDataType["DATE"] = "DATE";
1804
- EntityFieldDataType["BOOLEAN"] = "BOOLEAN";
1805
- EntityFieldDataType["BIG_INTEGER"] = "BIG_INTEGER";
1806
- EntityFieldDataType["MULTILINE_TEXT"] = "MULTILINE_TEXT";
1807
- })(EntityFieldDataType || (EntityFieldDataType = {}));
1808
- /**
1809
- * Entity type enum
1810
- */
1811
- var EntityType;
1812
- (function (EntityType) {
1813
- EntityType["Entity"] = "Entity";
1814
- EntityType["ChoiceSet"] = "ChoiceSet";
1815
- EntityType["InternalEntity"] = "InternalEntity";
1816
- EntityType["SystemEntity"] = "SystemEntity";
1817
- })(EntityType || (EntityType = {}));
1818
- /**
1819
- * Reference types for fields
1820
- */
1821
- var ReferenceType;
1822
- (function (ReferenceType) {
1823
- ReferenceType["ManyToOne"] = "ManyToOne";
1824
- })(ReferenceType || (ReferenceType = {}));
1825
- /**
1826
- * Field display types
1827
- */
1828
- var FieldDisplayType;
1829
- (function (FieldDisplayType) {
1830
- FieldDisplayType["Basic"] = "Basic";
1831
- FieldDisplayType["Relationship"] = "Relationship";
1832
- FieldDisplayType["File"] = "File";
1833
- FieldDisplayType["ChoiceSetSingle"] = "ChoiceSetSingle";
1834
- FieldDisplayType["ChoiceSetMultiple"] = "ChoiceSetMultiple";
1835
- FieldDisplayType["AutoNumber"] = "AutoNumber";
1836
- })(FieldDisplayType || (FieldDisplayType = {}));
1837
- /**
1838
- * Data direction type for external fields
1839
- */
1840
- var DataDirectionType;
1841
- (function (DataDirectionType) {
1842
- DataDirectionType["ReadOnly"] = "ReadOnly";
1843
- DataDirectionType["ReadAndWrite"] = "ReadAndWrite";
1844
- })(DataDirectionType || (DataDirectionType = {}));
1845
- /**
1846
- * Join type for source join criteria
1847
- */
1848
- var JoinType;
1849
- (function (JoinType) {
1850
- JoinType["LeftJoin"] = "LeftJoin";
1851
- })(JoinType || (JoinType = {}));
1852
-
1853
1909
  /**
1854
1910
  * Entity field data types (SQL types from API)
1855
1911
  */
@@ -1868,6 +1924,7 @@ var SqlFieldType;
1868
1924
  SqlFieldType["DECIMAL"] = "DECIMAL";
1869
1925
  SqlFieldType["MULTILINE"] = "MULTILINE";
1870
1926
  })(SqlFieldType || (SqlFieldType = {}));
1927
+
1871
1928
  /**
1872
1929
  * Maps fields for Entities
1873
1930
  */
@@ -1877,6 +1934,40 @@ const EntityMap = {
1877
1934
  sqlType: 'fieldDataType',
1878
1935
  fieldDefinition: 'fieldMetaData'
1879
1936
  };
1937
+ /**
1938
+ * Maps EntityFieldDataType values to the API field payload components for create/update operations
1939
+ */
1940
+ const EntitySchemaFieldTypeMap = {
1941
+ [EntityFieldDataType.UUID]: { sqlTypeName: SqlFieldType.UNIQUEIDENTIFIER, fieldDisplayType: FieldDisplayType.Basic },
1942
+ [EntityFieldDataType.STRING]: { sqlTypeName: SqlFieldType.NVARCHAR, fieldDisplayType: FieldDisplayType.Basic },
1943
+ [EntityFieldDataType.INTEGER]: { sqlTypeName: SqlFieldType.INT, fieldDisplayType: FieldDisplayType.Basic },
1944
+ [EntityFieldDataType.DATETIME]: { sqlTypeName: SqlFieldType.DATETIME2, fieldDisplayType: FieldDisplayType.Basic },
1945
+ [EntityFieldDataType.DATETIME_WITH_TZ]: { sqlTypeName: SqlFieldType.DATETIMEOFFSET, fieldDisplayType: FieldDisplayType.Basic },
1946
+ [EntityFieldDataType.DECIMAL]: { sqlTypeName: SqlFieldType.DECIMAL, fieldDisplayType: FieldDisplayType.Basic },
1947
+ [EntityFieldDataType.FLOAT]: { sqlTypeName: SqlFieldType.FLOAT, fieldDisplayType: FieldDisplayType.Basic },
1948
+ [EntityFieldDataType.DOUBLE]: { sqlTypeName: SqlFieldType.REAL, fieldDisplayType: FieldDisplayType.Basic },
1949
+ [EntityFieldDataType.DATE]: { sqlTypeName: SqlFieldType.DATE, fieldDisplayType: FieldDisplayType.Basic },
1950
+ [EntityFieldDataType.BOOLEAN]: { sqlTypeName: SqlFieldType.BIT, fieldDisplayType: FieldDisplayType.Basic },
1951
+ [EntityFieldDataType.BIG_INTEGER]: { sqlTypeName: SqlFieldType.BIGINT, fieldDisplayType: FieldDisplayType.Basic },
1952
+ [EntityFieldDataType.MULTILINE_TEXT]: { sqlTypeName: SqlFieldType.MULTILINE, fieldDisplayType: FieldDisplayType.Basic },
1953
+ [EntityFieldDataType.FILE]: { sqlTypeName: SqlFieldType.UNIQUEIDENTIFIER, fieldDisplayType: FieldDisplayType.File },
1954
+ [EntityFieldDataType.CHOICE_SET_SINGLE]: { sqlTypeName: SqlFieldType.INT, fieldDisplayType: FieldDisplayType.ChoiceSetSingle },
1955
+ [EntityFieldDataType.CHOICE_SET_MULTIPLE]: { sqlTypeName: SqlFieldType.NVARCHAR, fieldDisplayType: FieldDisplayType.ChoiceSetMultiple },
1956
+ [EntityFieldDataType.AUTO_NUMBER]: { sqlTypeName: SqlFieldType.DECIMAL, fieldDisplayType: FieldDisplayType.AutoNumber },
1957
+ [EntityFieldDataType.RELATIONSHIP]: { sqlTypeName: SqlFieldType.UNIQUEIDENTIFIER, fieldDisplayType: FieldDisplayType.Relationship },
1958
+ };
1959
+ /**
1960
+ * Maps FieldDisplayType values to EntityFieldDataType for types that share SQL types
1961
+ * with other field types (File, ChoiceSetSingle, ChoiceSetMultiple, AutoNumber).
1962
+ * Used during read-side transformation to produce the correct EntityFieldDataType.
1963
+ */
1964
+ const FieldDisplayTypeToDataType = {
1965
+ [FieldDisplayType.File]: EntityFieldDataType.FILE,
1966
+ [FieldDisplayType.ChoiceSetSingle]: EntityFieldDataType.CHOICE_SET_SINGLE,
1967
+ [FieldDisplayType.ChoiceSetMultiple]: EntityFieldDataType.CHOICE_SET_MULTIPLE,
1968
+ [FieldDisplayType.AutoNumber]: EntityFieldDataType.AUTO_NUMBER,
1969
+ [FieldDisplayType.Relationship]: EntityFieldDataType.RELATIONSHIP,
1970
+ };
1880
1971
  /**
1881
1972
  * Maps SQL field types to friendly display names
1882
1973
  */
@@ -1892,7 +1983,7 @@ const EntityFieldTypeMap = {
1892
1983
  [SqlFieldType.DATE]: EntityFieldDataType.DATE,
1893
1984
  [SqlFieldType.BIT]: EntityFieldDataType.BOOLEAN,
1894
1985
  [SqlFieldType.DECIMAL]: EntityFieldDataType.DECIMAL,
1895
- [SqlFieldType.MULTILINE]: EntityFieldDataType.MULTILINE_TEXT
1986
+ [SqlFieldType.MULTILINE]: EntityFieldDataType.MULTILINE_TEXT,
1896
1987
  };
1897
1988
 
1898
1989
  /**
@@ -1901,7 +1992,7 @@ const EntityFieldTypeMap = {
1901
1992
  // Connection string placeholder that will be replaced during build
1902
1993
  const CONNECTION_STRING = "InstrumentationKey=a6efa11d-1feb-4508-9738-e13e12dcae5e;IngestionEndpoint=https://westeurope-5.in.applicationinsights.azure.com/;LiveEndpoint=https://westeurope.livediagnostics.monitor.azure.com/;ApplicationId=7c58eb1c-9581-4ba6-839e-11725848a037";
1903
1994
  // SDK Version placeholder
1904
- const SDK_VERSION = "1.2.2";
1995
+ const SDK_VERSION = "1.3.1";
1905
1996
  const VERSION = "Version";
1906
1997
  const SERVICE = "Service";
1907
1998
  const CLOUD_ORGANIZATION_NAME = "CloudOrganizationName";
@@ -2284,11 +2375,7 @@ class EntityService extends BaseService {
2284
2375
  expansionLevel: options.expansionLevel
2285
2376
  });
2286
2377
  const response = await this.get(DATA_FABRIC_ENDPOINTS.ENTITY.GET_RECORD_BY_ID(entityId, recordId), { params });
2287
- // Convert PascalCase response to camelCase
2288
- const camelResponse = pascalToCamelCaseKeys(response.data);
2289
- // Apply EntityMap transformations
2290
- const transformedResponse = transformData(camelResponse, EntityMap);
2291
- return transformedResponse;
2378
+ return response.data;
2292
2379
  }
2293
2380
  /**
2294
2381
  * Inserts a single record into an entity by entity ID
@@ -2321,9 +2408,7 @@ class EntityService extends BaseService {
2321
2408
  params,
2322
2409
  ...options
2323
2410
  });
2324
- // Convert PascalCase response to camelCase
2325
- const camelResponse = pascalToCamelCaseKeys(response.data);
2326
- return camelResponse;
2411
+ return response.data;
2327
2412
  }
2328
2413
  /**
2329
2414
  * Inserts data into an entity by entity ID using batch insert
@@ -2364,9 +2449,7 @@ class EntityService extends BaseService {
2364
2449
  params,
2365
2450
  ...options
2366
2451
  });
2367
- // Convert PascalCase response to camelCase
2368
- const camelResponse = pascalToCamelCaseKeys(response.data);
2369
- return camelResponse;
2452
+ return response.data;
2370
2453
  }
2371
2454
  /**
2372
2455
  * Updates a single record in an entity by entity ID
@@ -2400,9 +2483,7 @@ class EntityService extends BaseService {
2400
2483
  params,
2401
2484
  ...options
2402
2485
  });
2403
- // Convert PascalCase response to camelCase
2404
- const camelResponse = pascalToCamelCaseKeys(response.data);
2405
- return camelResponse;
2486
+ return response.data;
2406
2487
  }
2407
2488
  /**
2408
2489
  * Updates data in an entity by entity ID
@@ -2444,9 +2525,7 @@ class EntityService extends BaseService {
2444
2525
  params,
2445
2526
  ...options
2446
2527
  });
2447
- // Convert PascalCase response to camelCase
2448
- const camelResponse = pascalToCamelCaseKeys(response.data);
2449
- return camelResponse;
2528
+ return response.data;
2450
2529
  }
2451
2530
  /**
2452
2531
  * Deletes data from an entity by entity ID
@@ -2476,9 +2555,7 @@ class EntityService extends BaseService {
2476
2555
  params,
2477
2556
  ...options
2478
2557
  });
2479
- // Convert PascalCase response to camelCase
2480
- const camelResponse = pascalToCamelCaseKeys(response.data);
2481
- return camelResponse;
2558
+ return response.data;
2482
2559
  }
2483
2560
  /**
2484
2561
  * Gets all entities in the system
@@ -2510,6 +2587,99 @@ class EntityService extends BaseService {
2510
2587
  });
2511
2588
  return entities;
2512
2589
  }
2590
+ /**
2591
+ * Queries entity records with filters, sorting, and pagination
2592
+ *
2593
+ * @param id - UUID of the entity
2594
+ * @param options - Query options including filterGroup, selectedFields, sortOptions, and pagination
2595
+ * @returns Promise resolving to {@link NonPaginatedResponse} without pagination options,
2596
+ * or {@link PaginatedResponse} when `pageSize`, `cursor`, or `jumpToPage` are provided
2597
+ *
2598
+ * @example
2599
+ * ```typescript
2600
+ * import { Entities, LogicalOperator, QueryFilterOperator } from '@uipath/uipath-typescript/entities';
2601
+ *
2602
+ * const entities = new Entities(sdk);
2603
+ *
2604
+ * // Non-paginated query with a filter
2605
+ * const result = await entities.queryRecordsById("<entityId>", {
2606
+ * filterGroup: {
2607
+ * logicalOperator: LogicalOperator.And,
2608
+ * queryFilters: [
2609
+ * { fieldName: "status", operator: QueryFilterOperator.Equals, value: "active" }
2610
+ * ]
2611
+ * },
2612
+ * sortOptions: [{ fieldName: "created_at", isDescending: true }],
2613
+ * });
2614
+ * console.log(`Found ${result.totalCount} records`);
2615
+ *
2616
+ * // With pagination
2617
+ * const page1 = await entities.queryRecordsById("<entityId>", {
2618
+ * filterGroup: { queryFilters: [{ fieldName: "status", operator: QueryFilterOperator.Equals, value: "active" }] },
2619
+ * pageSize: 25,
2620
+ * });
2621
+ * if (page1.hasNextPage) {
2622
+ * const page2 = await entities.queryRecordsById("<entityId>", { cursor: page1.nextCursor });
2623
+ * }
2624
+ * ```
2625
+ */
2626
+ async queryRecordsById(id, options) {
2627
+ return PaginationHelpers.getAll({
2628
+ serviceAccess: this.createPaginationServiceAccess(),
2629
+ getEndpoint: () => DATA_FABRIC_ENDPOINTS.ENTITY.QUERY_BY_ID(id),
2630
+ method: HTTP_METHODS.POST,
2631
+ pagination: {
2632
+ paginationType: PaginationType.OFFSET,
2633
+ itemsField: ENTITY_PAGINATION.ITEMS_FIELD,
2634
+ totalCountField: ENTITY_PAGINATION.TOTAL_COUNT_FIELD,
2635
+ paginationParams: {
2636
+ pageSizeParam: ENTITY_OFFSET_PARAMS.PAGE_SIZE_PARAM,
2637
+ offsetParam: ENTITY_OFFSET_PARAMS.OFFSET_PARAM,
2638
+ countParam: ENTITY_OFFSET_PARAMS.COUNT_PARAM
2639
+ }
2640
+ },
2641
+ excludeFromPrefix: ['expansionLevel', 'filterGroup', 'selectedFields', 'sortOptions']
2642
+ }, options);
2643
+ }
2644
+ /**
2645
+ * Imports records from a CSV file into an entity
2646
+ *
2647
+ * @param id - UUID of the entity
2648
+ * @param file - CSV file to import (Blob, File, or Uint8Array)
2649
+ * @returns Promise resolving to import result with record counts
2650
+ *
2651
+ * @example
2652
+ * ```typescript
2653
+ * import { Entities } from '@uipath/uipath-typescript/entities';
2654
+ *
2655
+ * const entities = new Entities(sdk);
2656
+ *
2657
+ * // Browser: upload from file input
2658
+ * const fileInput = document.getElementById('csv-input') as HTMLInputElement;
2659
+ * const result = await entities.importRecordsById("<entityId>", fileInput.files[0]);
2660
+ *
2661
+ * // Node.js: read from disk
2662
+ * const fileBuffer = fs.readFileSync('records.csv');
2663
+ * const result = await entities.importRecordsById("<entityId>", new Blob([fileBuffer], { type: 'text/csv' }));
2664
+ *
2665
+ * console.log(`Inserted ${result.insertedRecords} of ${result.totalRecords} records`);
2666
+ * if (result.errorFileLink) {
2667
+ * console.log(`Error file link: ${result.errorFileLink}`);
2668
+ * }
2669
+ * ```
2670
+ * @internal
2671
+ */
2672
+ async importRecordsById(id, file) {
2673
+ const formData = new FormData();
2674
+ if (file instanceof Uint8Array) {
2675
+ formData.append('file', new Blob([file.buffer]));
2676
+ }
2677
+ else {
2678
+ formData.append('file', file);
2679
+ }
2680
+ const response = await this.post(DATA_FABRIC_ENDPOINTS.ENTITY.BULK_UPLOAD_BY_ID(id), formData);
2681
+ return response.data;
2682
+ }
2513
2683
  /**
2514
2684
  * Downloads an attachment from an entity record field
2515
2685
  *
@@ -2530,7 +2700,7 @@ class EntityService extends BaseService {
2530
2700
  *
2531
2701
  * // Get the recordId from getAllRecords()
2532
2702
  * const records = await entities.getAllRecords(entityId);
2533
- * const recordId = records[0].id;
2703
+ * const recordId = records[0].Id;
2534
2704
  *
2535
2705
  * // Download attachment for a specific record and field
2536
2706
  * const blob = await entities.downloadAttachment(entityId, recordId, 'Documents');
@@ -2564,7 +2734,7 @@ class EntityService extends BaseService {
2564
2734
  *
2565
2735
  * // Get the recordId from getAllRecords()
2566
2736
  * const records = await entities.getAllRecords(entityId);
2567
- * const recordId = records[0].id;
2737
+ * const recordId = records[0].Id;
2568
2738
  *
2569
2739
  * // Upload a file attachment
2570
2740
  * const response = await entities.uploadAttachment(entityId, recordId, 'Documents', file);
@@ -2580,9 +2750,7 @@ class EntityService extends BaseService {
2580
2750
  }
2581
2751
  const params = createParams({ expansionLevel: options?.expansionLevel });
2582
2752
  const response = await this.post(DATA_FABRIC_ENDPOINTS.ENTITY.UPLOAD_ATTACHMENT(entityId, recordId, fieldName), formData, { params });
2583
- // Convert PascalCase response to camelCase
2584
- const camelResponse = pascalToCamelCaseKeys(response.data);
2585
- return camelResponse;
2753
+ return response.data;
2586
2754
  }
2587
2755
  /**
2588
2756
  * Removes an attachment from a File-type field of an entity record
@@ -2604,7 +2772,7 @@ class EntityService extends BaseService {
2604
2772
  *
2605
2773
  * // Get the recordId from getAllRecords()
2606
2774
  * const records = await entities.getAllRecords(entityId);
2607
- * const recordId = records[0].id;
2775
+ * const recordId = records[0].Id;
2608
2776
  *
2609
2777
  * // Delete attachment for a specific record and field
2610
2778
  * await entities.deleteAttachment(entityId, recordId, 'Documents');
@@ -2636,18 +2804,169 @@ class EntityService extends BaseService {
2636
2804
  return this.insertRecordsById(id, data, options);
2637
2805
  }
2638
2806
  /**
2639
- * @hidden
2640
- * @deprecated Use {@link updateRecordsById} instead.
2807
+ * Creates a new Data Fabric entity with the given schema
2808
+ *
2809
+ * @param name - Entity name — must start with a letter and contain
2810
+ * only letters, numbers, and underscores (e.g., `"productCatalog"`).
2811
+ * @param fields - Array of field definitions
2812
+ * @param options - Optional entity-level settings ({@link EntityCreateOptions})
2813
+ * @returns Promise resolving to the ID of the created entity
2814
+ *
2815
+ * @example
2816
+ * ```typescript
2817
+ * const entityId = await entities.create("product_catalog", [
2818
+ * { fieldName: "product_name", type: EntityFieldDataType.STRING, isRequired: true, isUnique: true },
2819
+ * { fieldName: "price", type: EntityFieldDataType.INTEGER, defaultValue: "0" },
2820
+ * ], { displayName: "Product Catalog", description: "Our product catalog", isRbacEnabled: true });
2821
+ * ```
2822
+ * @internal
2641
2823
  */
2642
- async updateById(id, data, options = {}) {
2643
- return this.updateRecordsById(id, data, options);
2824
+ async create(name, fields, options) {
2825
+ this.validateName(name, 'entity');
2826
+ for (const field of fields) {
2827
+ this.validateName(field.fieldName, 'field');
2828
+ }
2829
+ const opts = options ?? {};
2830
+ const payload = {
2831
+ ...(opts.description !== undefined && { description: opts.description }),
2832
+ displayName: opts.displayName ?? name,
2833
+ entityDefinition: {
2834
+ name,
2835
+ fields: fields.map(f => this.buildSchemaFieldPayload(f)),
2836
+ folderId: opts.folderKey ?? DATA_FABRIC_TENANT_FOLDER_ID,
2837
+ isRbacEnabled: opts.isRbacEnabled ?? false,
2838
+ isInsightsEnabled: opts.isAnalyticsEnabled ?? false,
2839
+ externalFields: opts.externalFields ?? [],
2840
+ },
2841
+ };
2842
+ const response = await this.post(DATA_FABRIC_ENDPOINTS.ENTITY.UPSERT, payload);
2843
+ return response.data;
2644
2844
  }
2645
2845
  /**
2646
- * @hidden
2647
- * @deprecated Use {@link deleteRecordsById} instead.
2846
+ * Deletes a Data Fabric entity and all its records
2847
+ *
2848
+ * @param id - UUID of the entity to delete
2849
+ * @returns Promise resolving when the entity is deleted
2850
+ *
2851
+ * @example
2852
+ * ```typescript
2853
+ * await entities.deleteById("<entityId>");
2854
+ * ```
2855
+ * @internal
2856
+ */
2857
+ async deleteById(id) {
2858
+ await this.delete(DATA_FABRIC_ENDPOINTS.ENTITY.DELETE(id));
2859
+ }
2860
+ /**
2861
+ * Updates an existing Data Fabric entity — schema and/or metadata.
2862
+ *
2863
+ * Provide any combination of schema fields (`addFields`, `removeFields`, `updateFields`) and
2864
+ * metadata fields (`displayName`, `description`, `isRbacEnabled`). Each group is applied
2865
+ * only when the corresponding fields are present.
2866
+ *
2867
+ * **Warning:** Schema changes (`addFields`, `removeFields`, `updateFields`) use a
2868
+ * read-modify-write pattern — concurrent calls on the same entity may silently
2869
+ * overwrite each other's changes.
2870
+ *
2871
+ * @param id - UUID of the entity to update
2872
+ * @param options - Changes to apply ({@link EntityUpdateByIdOptions})
2873
+ * @returns Promise resolving when the update is complete
2874
+ *
2875
+ * @example
2876
+ * ```typescript
2877
+ * // Schema-only
2878
+ * await entities.updateById("<entityId>", {
2879
+ * addFields: [{ fieldName: "notes", type: EntityFieldDataType.MULTILINE_TEXT }],
2880
+ * removeFields: [{ fieldName: "old_field" }],
2881
+ * });
2882
+ *
2883
+ * // Metadata-only
2884
+ * await entities.updateById("<entityId>", {
2885
+ * displayName: "My Updated Entity",
2886
+ * description: "Updated description",
2887
+ * });
2888
+ *
2889
+ * // Combined
2890
+ * await entities.updateById("<entityId>", {
2891
+ * updateFields: [{ id: "<fieldId>", displayName: "Unit Price", isRequired: true }],
2892
+ * displayName: "Price Catalog",
2893
+ * });
2894
+ * ```
2895
+ * @internal
2896
+ */
2897
+ async updateById(id, options) {
2898
+ const opts = options ?? {};
2899
+ const hasSchemaChanges = !!(opts.addFields?.length || opts.removeFields?.length || opts.updateFields?.length);
2900
+ const hasMetadataChanges = opts.displayName !== undefined || opts.description !== undefined || opts.isRbacEnabled !== undefined;
2901
+ if (hasSchemaChanges) {
2902
+ await this.applySchemaUpdate(id, opts);
2903
+ }
2904
+ if (hasMetadataChanges) {
2905
+ await this.patch(DATA_FABRIC_ENDPOINTS.ENTITY.UPDATE_METADATA(id), {
2906
+ ...(opts.displayName !== undefined && { displayName: opts.displayName }),
2907
+ ...(opts.description !== undefined && { description: opts.description }),
2908
+ ...(opts.isRbacEnabled !== undefined && { isRbacEnabled: opts.isRbacEnabled }),
2909
+ });
2910
+ }
2911
+ }
2912
+ /**
2913
+ * Fetches the current entity schema, applies the field delta, then posts the full updated schema.
2914
+ *
2915
+ * @param entityId - UUID of the entity to update
2916
+ * @param options - Field changes to apply
2917
+ * @private
2648
2918
  */
2649
- async deleteById(id, recordIds, options = {}) {
2650
- return this.deleteRecordsById(id, recordIds, options);
2919
+ async applySchemaUpdate(entityId, options) {
2920
+ const entityResponse = await this.get(DATA_FABRIC_ENDPOINTS.ENTITY.GET_BY_ID(entityId));
2921
+ const raw = entityResponse.data;
2922
+ // Carry forward existing non-system fields from GET response (skip system/primary-key fields)
2923
+ let fields = (raw.fields ?? [])
2924
+ .filter(f => !f.isSystemField && !f.isPrimaryKey);
2925
+ // Filter out removed fields
2926
+ if (options.removeFields?.length) {
2927
+ const removeSet = new Set(options.removeFields.map(r => r.fieldName));
2928
+ fields = fields.filter(f => !removeSet.has(f.name));
2929
+ }
2930
+ // Apply per-field metadata updates (matched by field ID)
2931
+ if (options.updateFields?.length) {
2932
+ const updateMap = new Map(options.updateFields.map(u => [u.id, u]));
2933
+ fields = fields.map(f => {
2934
+ const update = updateMap.get(f.id ?? '');
2935
+ if (!update)
2936
+ return f;
2937
+ return {
2938
+ ...f,
2939
+ ...(update.displayName !== undefined && { displayName: update.displayName }),
2940
+ ...(update.description !== undefined && { description: update.description }),
2941
+ ...(update.isRequired !== undefined && { isRequired: update.isRequired }),
2942
+ ...(update.isUnique !== undefined && { isUnique: update.isUnique }),
2943
+ ...(update.isRbacEnabled !== undefined && { isRbacEnabled: update.isRbacEnabled }),
2944
+ ...(update.isEncrypted !== undefined && { isEncrypted: update.isEncrypted }),
2945
+ ...(update.defaultValue !== undefined && { defaultValue: update.defaultValue }),
2946
+ };
2947
+ });
2948
+ }
2949
+ // Build and append new fields
2950
+ const newFields = [];
2951
+ if (options.addFields?.length) {
2952
+ for (const field of options.addFields) {
2953
+ this.validateName(field.fieldName, 'field');
2954
+ }
2955
+ newFields.push(...options.addFields.map(f => this.buildSchemaFieldPayload(f)));
2956
+ }
2957
+ await this.post(DATA_FABRIC_ENDPOINTS.ENTITY.UPSERT, {
2958
+ displayName: raw.displayName,
2959
+ description: raw.description,
2960
+ entityDefinition: {
2961
+ id: entityId,
2962
+ name: raw.name,
2963
+ fields: [...fields, ...newFields],
2964
+ folderId: raw.folderId ?? DATA_FABRIC_TENANT_FOLDER_ID,
2965
+ isRbacEnabled: raw.isRbacEnabled ?? false,
2966
+ isInsightsEnabled: raw.isInsightsEnabled ?? false,
2967
+ externalFields: raw.externalFields ?? [],
2968
+ },
2969
+ });
2651
2970
  }
2652
2971
  /**
2653
2972
  * Orchestrates all field mapping transformations
@@ -2671,11 +2990,20 @@ class EntityService extends BaseService {
2671
2990
  metadata.fields = metadata.fields.map(field => {
2672
2991
  // Rename sqlType to fieldDataType
2673
2992
  let transformedField = transformData(field, EntityMap);
2674
- // Map SQL field type to friendly name
2993
+ // Map field type: prefer fieldDisplayType for types that share SQL types (File, ChoiceSet, AutoNumber)
2675
2994
  if (transformedField.fieldDataType?.name) {
2676
- const sqlTypeName = transformedField.fieldDataType.name;
2677
- if (EntityFieldTypeMap[sqlTypeName]) {
2678
- transformedField.fieldDataType.name = EntityFieldTypeMap[sqlTypeName];
2995
+ const displayTypeMapped = transformedField.fieldDisplayType
2996
+ ? FieldDisplayTypeToDataType[transformedField.fieldDisplayType]
2997
+ : undefined;
2998
+ if (displayTypeMapped) {
2999
+ transformedField.fieldDataType.name = displayTypeMapped;
3000
+ }
3001
+ else {
3002
+ const rawSqlTypeName = field.sqlType?.name;
3003
+ const mapped = rawSqlTypeName ? EntityFieldTypeMap[rawSqlTypeName] : undefined;
3004
+ if (mapped) {
3005
+ transformedField.fieldDataType.name = mapped;
3006
+ }
2679
3007
  }
2680
3008
  }
2681
3009
  this.transformNestedReferences(transformedField);
@@ -2719,7 +3047,44 @@ class EntityService extends BaseService {
2719
3047
  return externalSource;
2720
3048
  });
2721
3049
  }
3050
+ /** Converts a user-facing EntityCreateFieldOptions to the raw API field payload */
3051
+ buildSchemaFieldPayload(field) {
3052
+ this.validateName(field.fieldName, 'field');
3053
+ const mapping = EntitySchemaFieldTypeMap[field.type ?? EntityFieldDataType.STRING];
3054
+ return {
3055
+ name: field.fieldName,
3056
+ displayName: field.displayName ?? field.fieldName,
3057
+ sqlType: { name: mapping.sqlTypeName },
3058
+ fieldDisplayType: mapping.fieldDisplayType,
3059
+ description: field.description ?? '',
3060
+ isRequired: field.isRequired ?? false,
3061
+ isUnique: field.isUnique ?? false,
3062
+ isRbacEnabled: field.isRbacEnabled ?? false,
3063
+ isEncrypted: field.isEncrypted ?? false,
3064
+ ...(field.defaultValue !== undefined && { defaultValue: field.defaultValue }),
3065
+ ...(field.choiceSetId !== undefined && { choiceSetId: field.choiceSetId }),
3066
+ ...(field.referenceEntityName !== undefined && { referenceEntityName: field.referenceEntityName }),
3067
+ ...(field.referenceFieldName !== undefined && { referenceFieldName: field.referenceFieldName }),
3068
+ };
3069
+ }
3070
+ validateName(name, context) {
3071
+ if (name.length < 3 || name.length > 100 || !/^[a-zA-Z]\w*$/.test(name)) {
3072
+ const suggestion = name.replace(/\W/g, '').replace(/^[0-9_]+/, '');
3073
+ const defaultName = `My${context.charAt(0).toUpperCase() + context.slice(1)}`;
3074
+ throw new ValidationError({
3075
+ message: `Invalid ${context} name '${name}'. Must start with a letter, contain only letters, numbers, and underscores, 3–100 characters (e.g., "${suggestion || defaultName}").`
3076
+ });
3077
+ }
3078
+ if (context === 'field' && EntityService.RESERVED_FIELD_NAMES.has(name)) {
3079
+ throw new ValidationError({
3080
+ message: `Field name '${name}' is reserved. Reserved names: ${[...EntityService.RESERVED_FIELD_NAMES].join(', ')}.`
3081
+ });
3082
+ }
3083
+ }
2722
3084
  }
3085
+ EntityService.RESERVED_FIELD_NAMES = new Set([
3086
+ 'Id', 'CreatedBy', 'CreateTime', 'UpdatedBy', 'UpdateTime'
3087
+ ]);
2723
3088
  __decorate([
2724
3089
  track('Entities.GetById')
2725
3090
  ], EntityService.prototype, "getById", null);
@@ -2747,6 +3112,12 @@ __decorate([
2747
3112
  __decorate([
2748
3113
  track('Entities.GetAll')
2749
3114
  ], EntityService.prototype, "getAll", null);
3115
+ __decorate([
3116
+ track('Entities.QueryRecordsById')
3117
+ ], EntityService.prototype, "queryRecordsById", null);
3118
+ __decorate([
3119
+ track('Entities.ImportRecordsById')
3120
+ ], EntityService.prototype, "importRecordsById", null);
2750
3121
  __decorate([
2751
3122
  track('Entities.DownloadAttachment')
2752
3123
  ], EntityService.prototype, "downloadAttachment", null);
@@ -2756,6 +3127,15 @@ __decorate([
2756
3127
  __decorate([
2757
3128
  track('Entities.DeleteAttachment')
2758
3129
  ], EntityService.prototype, "deleteAttachment", null);
3130
+ __decorate([
3131
+ track('Entities.Create')
3132
+ ], EntityService.prototype, "create", null);
3133
+ __decorate([
3134
+ track('Entities.DeleteById')
3135
+ ], EntityService.prototype, "deleteById", null);
3136
+ __decorate([
3137
+ track('Entities.UpdateById')
3138
+ ], EntityService.prototype, "updateById", null);
2759
3139
 
2760
3140
  class ChoiceSetService extends BaseService {
2761
3141
  /**
@@ -2855,4 +3235,4 @@ __decorate([
2855
3235
  track('Choicesets.GetById')
2856
3236
  ], ChoiceSetService.prototype, "getById", null);
2857
3237
 
2858
- export { ChoiceSetService, ChoiceSetService as ChoiceSets, DataDirectionType, EntityService as Entities, EntityFieldDataType, EntityService, EntityType, FieldDisplayType, JoinType, ReferenceType, createEntityWithMethods };
3238
+ export { ChoiceSetService, ChoiceSetService as ChoiceSets, DataDirectionType, EntityService as Entities, EntityFieldDataType, EntityService, EntityType, FieldDisplayType, JoinType, LogicalOperator, QueryFilterOperator, ReferenceType, createEntityWithMethods };