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