@uipath/uipath-typescript 1.4.2 → 1.5.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/README.md +7 -1
- package/dist/agent-memory/index.d.ts +4 -1
- package/dist/agents/index.cjs +341 -6
- package/dist/agents/index.d.ts +717 -16
- package/dist/agents/index.mjs +342 -7
- package/dist/assets/index.cjs +132 -15
- package/dist/assets/index.d.ts +12 -1
- package/dist/assets/index.mjs +132 -15
- package/dist/attachments/index.cjs +120 -12
- package/dist/attachments/index.mjs +120 -12
- package/dist/buckets/index.cjs +136 -15
- package/dist/buckets/index.d.ts +12 -1
- package/dist/buckets/index.mjs +136 -15
- package/dist/cases/index.cjs +1203 -938
- package/dist/cases/index.d.ts +325 -45
- package/dist/cases/index.mjs +1203 -938
- package/dist/conversational-agent/index.cjs +48 -10
- package/dist/conversational-agent/index.d.ts +117 -6
- package/dist/conversational-agent/index.mjs +48 -10
- package/dist/core/index.cjs +1 -1
- package/dist/core/index.mjs +1 -1
- package/dist/entities/index.cjs +448 -9
- package/dist/entities/index.d.ts +441 -1
- package/dist/entities/index.mjs +447 -10
- package/dist/feedback/index.cjs +25 -9
- package/dist/feedback/index.mjs +25 -9
- package/dist/index.cjs +1281 -330
- package/dist/index.d.ts +1988 -143
- package/dist/index.mjs +1282 -331
- package/dist/index.umd.js +1230 -279
- package/dist/jobs/index.cjs +141 -19
- package/dist/jobs/index.d.ts +22 -6
- package/dist/jobs/index.mjs +141 -19
- package/dist/maestro-processes/index.cjs +553 -354
- package/dist/maestro-processes/index.d.ts +376 -47
- package/dist/maestro-processes/index.mjs +553 -354
- package/dist/notifications/index.cjs +2012 -0
- package/dist/notifications/index.d.ts +615 -0
- package/dist/notifications/index.mjs +2010 -0
- package/dist/processes/index.cjs +118 -18
- package/dist/processes/index.d.ts +18 -2
- package/dist/processes/index.mjs +118 -18
- package/dist/queues/index.cjs +131 -14
- package/dist/queues/index.d.ts +12 -1
- package/dist/queues/index.mjs +131 -14
- package/dist/tasks/index.cjs +125 -13
- package/dist/tasks/index.d.ts +4 -1
- package/dist/tasks/index.mjs +125 -13
- package/dist/traces/index.cjs +220 -6
- package/dist/traces/index.d.ts +360 -25
- package/dist/traces/index.mjs +221 -7
- package/package.json +14 -4
package/dist/jobs/index.cjs
CHANGED
|
@@ -956,7 +956,16 @@ const BUCKET_TOKEN_PARAMS = {
|
|
|
956
956
|
* Returns the original value if parsing fails.
|
|
957
957
|
*/
|
|
958
958
|
/**
|
|
959
|
-
* Transforms data by
|
|
959
|
+
* Transforms data by renaming each key in `data` exactly once, using the
|
|
960
|
+
* mapping (`sourceField → targetField`). Keys not present in the mapping
|
|
961
|
+
* pass through unchanged. The original (pre-rename) key is dropped — the
|
|
962
|
+
* result contains only the renamed key.
|
|
963
|
+
*
|
|
964
|
+
* Each rename is independent. If the mapping happens to contain chained
|
|
965
|
+
* entries (`a → b` and `b → c`), they do NOT compose: a field named `a`
|
|
966
|
+
* in `data` becomes `b` (not `c`), because the renames are applied based
|
|
967
|
+
* on the original data's keys, not the running result.
|
|
968
|
+
*
|
|
960
969
|
* @param data The source data to transform
|
|
961
970
|
* @param fieldMapping Object mapping source field names to target field names
|
|
962
971
|
* @returns Transformed data with mapped field names
|
|
@@ -979,21 +988,28 @@ const BUCKET_TOKEN_PARAMS = {
|
|
|
979
988
|
* // { userId: '123', name: 'john' },
|
|
980
989
|
* // { userId: '456', name: 'jane' }
|
|
981
990
|
* // ]
|
|
991
|
+
*
|
|
992
|
+
* // No chaining — `a → b` does not become `a → c` even if the map has `b → c`.
|
|
993
|
+
* transformData({ a: 1 }, { a: 'b', b: 'c' });
|
|
994
|
+
* // result = { b: 1 }
|
|
982
995
|
* ```
|
|
983
996
|
*/
|
|
984
997
|
function transformData(data, fieldMapping) {
|
|
998
|
+
// Pass null/undefined through unchanged — callers (e.g. AttachmentService.getById)
|
|
999
|
+
// may invoke this on optional fields that an OData `select` excluded.
|
|
1000
|
+
if (data == null) {
|
|
1001
|
+
return data;
|
|
1002
|
+
}
|
|
985
1003
|
// Handle array of objects
|
|
986
1004
|
if (Array.isArray(data)) {
|
|
987
1005
|
return data.map(item => transformData(item, fieldMapping));
|
|
988
1006
|
}
|
|
989
|
-
//
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
result[targetField] = value;
|
|
996
|
-
}
|
|
1007
|
+
// Walk the ORIGINAL data's keys, look up each in the mapping. One rename
|
|
1008
|
+
// per data key — no mutation of an in-progress result, so chains can't form.
|
|
1009
|
+
const result = {};
|
|
1010
|
+
for (const [key, value] of Object.entries(data)) {
|
|
1011
|
+
const renamedKey = fieldMapping[key] ?? key;
|
|
1012
|
+
result[renamedKey] = value;
|
|
997
1013
|
}
|
|
998
1014
|
return result;
|
|
999
1015
|
}
|
|
@@ -1103,6 +1119,97 @@ function addPrefixToKeys(obj, prefix, keys) {
|
|
|
1103
1119
|
}
|
|
1104
1120
|
return result;
|
|
1105
1121
|
}
|
|
1122
|
+
/**
|
|
1123
|
+
* Creates a new map with the keys and values reversed
|
|
1124
|
+
* @param map The original map to reverse
|
|
1125
|
+
* @returns A new map with keys and values swapped
|
|
1126
|
+
*
|
|
1127
|
+
* @example
|
|
1128
|
+
* ```typescript
|
|
1129
|
+
* const original = { key1: 'value1', key2: 'value2' };
|
|
1130
|
+
* const reversed = reverseMap(original);
|
|
1131
|
+
* // reversed = { value1: 'key1', value2: 'key2' }
|
|
1132
|
+
* ```
|
|
1133
|
+
*/
|
|
1134
|
+
function reverseMap(map) {
|
|
1135
|
+
return Object.entries(map).reduce((acc, [key, value]) => {
|
|
1136
|
+
acc[value] = key;
|
|
1137
|
+
return acc;
|
|
1138
|
+
}, {});
|
|
1139
|
+
}
|
|
1140
|
+
/**
|
|
1141
|
+
* OData query-string keys whose values may contain field identifiers that
|
|
1142
|
+
* need rewriting from SDK names → API names.
|
|
1143
|
+
*/
|
|
1144
|
+
const ODATA_FIELD_PARAM_KEYS = ['filter', 'orderby', 'select', 'expand'];
|
|
1145
|
+
/**
|
|
1146
|
+
* Matches one token at a time in an OData expression:
|
|
1147
|
+
* 1. A single-quoted string literal, allowing the `''` escape sequence —
|
|
1148
|
+
* consumed atomically so identifiers inside the literal can't match.
|
|
1149
|
+
* 2. An OData identifier (`[A-Za-z_][A-Za-z0-9_]*`).
|
|
1150
|
+
* Anything else (whitespace, operators, parens, commas) is left alone by
|
|
1151
|
+
* `String.prototype.replace`, which only substitutes matched substrings.
|
|
1152
|
+
*/
|
|
1153
|
+
const ODATA_TOKEN_RE = /'(?:[^']|'')*'|[A-Za-z_][A-Za-z0-9_]*/g;
|
|
1154
|
+
/**
|
|
1155
|
+
* Rewrites SDK field identifiers to API field identifiers inside an OData
|
|
1156
|
+
* expression string (`$filter`, `$orderby`, `$select`, `$expand`).
|
|
1157
|
+
*
|
|
1158
|
+
* Field maps (e.g. `JobMap`) rename API fields → SDK fields on responses, so
|
|
1159
|
+
* SDK consumers see the renamed names. Without this rewrite, the same name
|
|
1160
|
+
* in a `filter` string would be forwarded verbatim and the API (which still
|
|
1161
|
+
* uses the original name) would reject it.
|
|
1162
|
+
*
|
|
1163
|
+
* Quoted string literals (with the OData `''` escape) are preserved exactly:
|
|
1164
|
+
* the token regex consumes them whole, so identifiers inside literals never
|
|
1165
|
+
* match. Identifier tokens are looked up in the reversed field map.
|
|
1166
|
+
*
|
|
1167
|
+
* @example
|
|
1168
|
+
* ```typescript
|
|
1169
|
+
* const requestMap = { processName: 'releaseName' };
|
|
1170
|
+
* rewriteODataIdentifiers("processName eq 'processName'", requestMap);
|
|
1171
|
+
* // "releaseName eq 'processName'" — identifier rewritten, literal preserved
|
|
1172
|
+
* ```
|
|
1173
|
+
*/
|
|
1174
|
+
function rewriteODataIdentifiers(expression, requestMap) {
|
|
1175
|
+
if (!expression)
|
|
1176
|
+
return expression;
|
|
1177
|
+
return expression.replace(ODATA_TOKEN_RE, (match) => match.startsWith("'") ? match : (requestMap[match] ?? match));
|
|
1178
|
+
}
|
|
1179
|
+
/**
|
|
1180
|
+
* Symmetric counterpart of {@link transformRequest} for OData query options:
|
|
1181
|
+
* rewrites SDK field identifiers inside the recognized OData string params
|
|
1182
|
+
* (`filter`, `orderby`, `select`, `expand`) to their API names using the
|
|
1183
|
+
* reversed form of a response field map. Returns a shallow copy with the
|
|
1184
|
+
* relevant values rewritten; other keys pass through unchanged.
|
|
1185
|
+
*
|
|
1186
|
+
* Use at the OData edge so SDK consumers can refer to renamed fields by
|
|
1187
|
+
* their SDK name throughout — for reading the response and for filtering /
|
|
1188
|
+
* sorting / projecting / expanding.
|
|
1189
|
+
*
|
|
1190
|
+
* @param options The OData query options as authored with SDK field names
|
|
1191
|
+
* @param responseMap The response field map (API → SDK); reversed internally
|
|
1192
|
+
*
|
|
1193
|
+
* @example
|
|
1194
|
+
* ```typescript
|
|
1195
|
+
* // JobMap renames releaseName → processName on responses.
|
|
1196
|
+
* transformOptions({ filter: "processName eq 'X'" }, JobMap);
|
|
1197
|
+
* // { filter: "releaseName eq 'X'" }
|
|
1198
|
+
* ```
|
|
1199
|
+
*/
|
|
1200
|
+
function transformOptions(options, responseMap) {
|
|
1201
|
+
const requestMap = reverseMap(responseMap);
|
|
1202
|
+
if (Object.keys(requestMap).length === 0)
|
|
1203
|
+
return options;
|
|
1204
|
+
const result = { ...options };
|
|
1205
|
+
for (const key of ODATA_FIELD_PARAM_KEYS) {
|
|
1206
|
+
const value = result[key];
|
|
1207
|
+
if (typeof value === 'string') {
|
|
1208
|
+
result[key] = rewriteODataIdentifiers(value, requestMap);
|
|
1209
|
+
}
|
|
1210
|
+
}
|
|
1211
|
+
return result;
|
|
1212
|
+
}
|
|
1106
1213
|
|
|
1107
1214
|
/**
|
|
1108
1215
|
* Constants used throughout the pagination system
|
|
@@ -1866,9 +1973,12 @@ class FolderScopedService extends BaseService {
|
|
|
1866
1973
|
* @param name - Resource name to search for
|
|
1867
1974
|
* @param options - Folder scoping (`folderId` / `folderKey` / `folderPath`) + OData query options (`expand`, `select`)
|
|
1868
1975
|
* @param transform - Maps a raw OData item to the typed response (e.g. PascalCase → camelCase via field map)
|
|
1976
|
+
* @param responseFieldMap - Optional response field map (API → SDK), reversed internally by
|
|
1977
|
+
* `transformOptions` to rewrite SDK field names back to API names in user-supplied
|
|
1978
|
+
* `expand` / `select` (symmetric counterpart to `transform`)
|
|
1869
1979
|
* @throws ValidationError when inputs are malformed; NotFoundError when no match
|
|
1870
1980
|
*/
|
|
1871
|
-
async getByNameLookup(resourceType, endpoint, name, options, transform) {
|
|
1981
|
+
async getByNameLookup(resourceType, endpoint, name, options, transform, responseFieldMap) {
|
|
1872
1982
|
const validatedName = validateName(resourceType, name);
|
|
1873
1983
|
const { folderId, folderKey, folderPath, ...queryOptions } = options;
|
|
1874
1984
|
const headers = resolveFolderHeaders({
|
|
@@ -1878,8 +1988,11 @@ class FolderScopedService extends BaseService {
|
|
|
1878
1988
|
resourceType: `${resourceType}.getByName`,
|
|
1879
1989
|
fallbackFolderKey: this.config.folderKey,
|
|
1880
1990
|
});
|
|
1991
|
+
const apiFieldOptions = responseFieldMap
|
|
1992
|
+
? transformOptions(queryOptions, responseFieldMap)
|
|
1993
|
+
: queryOptions;
|
|
1881
1994
|
const apiOptions = {
|
|
1882
|
-
...addPrefixToKeys(
|
|
1995
|
+
...addPrefixToKeys(apiFieldOptions, ODATA_PREFIX, Object.keys(apiFieldOptions)),
|
|
1883
1996
|
'$filter': `Name eq '${validatedName.replace(SINGLE_QUOTE_RE, "''")}'`,
|
|
1884
1997
|
'$top': '1',
|
|
1885
1998
|
};
|
|
@@ -2068,9 +2181,10 @@ class AttachmentService extends BaseService {
|
|
|
2068
2181
|
if (!id) {
|
|
2069
2182
|
throw new ValidationError({ message: 'id is required for getById' });
|
|
2070
2183
|
}
|
|
2071
|
-
//
|
|
2072
|
-
|
|
2073
|
-
const
|
|
2184
|
+
// Response applies both maps (BucketMap on blobFileAccess, AttachmentsMap on top-level);
|
|
2185
|
+
// merge so SDK names from either are rewritten in one pass.
|
|
2186
|
+
const apiFieldOptions = transformOptions(options, { ...AttachmentsMap, ...BucketMap });
|
|
2187
|
+
const apiOptions = addPrefixToKeys(apiFieldOptions, ODATA_PREFIX, Object.keys(apiFieldOptions));
|
|
2074
2188
|
const response = await this.get(ORCHESTRATOR_ATTACHMENT_ENDPOINTS.GET_BY_ID(id), {
|
|
2075
2189
|
params: apiOptions,
|
|
2076
2190
|
});
|
|
@@ -2294,8 +2408,9 @@ class JobService extends FolderScopedService {
|
|
|
2294
2408
|
* const folderJobs = await jobs.getAll({ folderId: <folderId> });
|
|
2295
2409
|
*
|
|
2296
2410
|
* // With filtering
|
|
2297
|
-
* const
|
|
2298
|
-
* filter: "
|
|
2411
|
+
* const recentInvoiceJobs = await jobs.getAll({
|
|
2412
|
+
* filter: "processName eq 'InvoiceBot'",
|
|
2413
|
+
* orderby: 'createdTime desc',
|
|
2299
2414
|
* });
|
|
2300
2415
|
*
|
|
2301
2416
|
* // First page with pagination
|
|
@@ -2318,6 +2433,10 @@ class JobService extends FolderScopedService {
|
|
|
2318
2433
|
const rawJob = transformData(pascalToCamelCaseKeys(job), JobMap);
|
|
2319
2434
|
return createJobWithMethods(rawJob, this);
|
|
2320
2435
|
};
|
|
2436
|
+
// Rewrite renamed SDK field names → API names inside OData strings
|
|
2437
|
+
// before delegating, mirroring the transformRequest pattern used for
|
|
2438
|
+
// request bodies.
|
|
2439
|
+
const apiOptions = options ? transformOptions(options, JobMap) : options;
|
|
2321
2440
|
return PaginationHelpers.getAll({
|
|
2322
2441
|
serviceAccess: this.createPaginationServiceAccess(),
|
|
2323
2442
|
getEndpoint: () => JOB_ENDPOINTS.GET_ALL,
|
|
@@ -2333,7 +2452,7 @@ class JobService extends FolderScopedService {
|
|
|
2333
2452
|
countParam: ODATA_OFFSET_PARAMS.COUNT_PARAM,
|
|
2334
2453
|
},
|
|
2335
2454
|
},
|
|
2336
|
-
},
|
|
2455
|
+
}, apiOptions);
|
|
2337
2456
|
}
|
|
2338
2457
|
/**
|
|
2339
2458
|
* Gets a job by its unique key (GUID).
|
|
@@ -2370,8 +2489,8 @@ class JobService extends FolderScopedService {
|
|
|
2370
2489
|
throw new ValidationError({ message: 'folderId is required for getById' });
|
|
2371
2490
|
}
|
|
2372
2491
|
const headers = createHeaders({ [FOLDER_ID]: folderId });
|
|
2373
|
-
const
|
|
2374
|
-
const apiOptions =
|
|
2492
|
+
const apiFieldOptions = options ? transformOptions(options, JobMap) : {};
|
|
2493
|
+
const apiOptions = addPrefixToKeys(apiFieldOptions, ODATA_PREFIX, Object.keys(apiFieldOptions));
|
|
2375
2494
|
const response = await this.get(JOB_ENDPOINTS.GET_BY_KEY(id), {
|
|
2376
2495
|
params: apiOptions,
|
|
2377
2496
|
headers,
|
|
@@ -2674,6 +2793,9 @@ exports.JobState = void 0;
|
|
|
2674
2793
|
JobState["Stopped"] = "Stopped";
|
|
2675
2794
|
JobState["Suspended"] = "Suspended";
|
|
2676
2795
|
JobState["Resumed"] = "Resumed";
|
|
2796
|
+
JobState["Cancelled"] = "Cancelled";
|
|
2797
|
+
/** Server-side fallback for an unrecognized or missing job state. */
|
|
2798
|
+
JobState["Unknown"] = "Unknown";
|
|
2677
2799
|
})(exports.JobState || (exports.JobState = {}));
|
|
2678
2800
|
|
|
2679
2801
|
exports.JobService = JobService;
|
package/dist/jobs/index.d.ts
CHANGED
|
@@ -312,7 +312,10 @@ declare enum JobState {
|
|
|
312
312
|
Successful = "Successful",
|
|
313
313
|
Stopped = "Stopped",
|
|
314
314
|
Suspended = "Suspended",
|
|
315
|
-
Resumed = "Resumed"
|
|
315
|
+
Resumed = "Resumed",
|
|
316
|
+
Cancelled = "Cancelled",
|
|
317
|
+
/** Server-side fallback for an unrecognized or missing job state. */
|
|
318
|
+
Unknown = "Unknown"
|
|
316
319
|
}
|
|
317
320
|
interface BaseOptions {
|
|
318
321
|
expand?: string;
|
|
@@ -340,6 +343,14 @@ interface FolderScopedOptions extends BaseOptions {
|
|
|
340
343
|
folderPath?: string;
|
|
341
344
|
}
|
|
342
345
|
|
|
346
|
+
/**
|
|
347
|
+
* Type for field mapping configuration
|
|
348
|
+
* Maps source field names to target field names
|
|
349
|
+
*/
|
|
350
|
+
type FieldMapping = {
|
|
351
|
+
[sourceField: string]: string;
|
|
352
|
+
};
|
|
353
|
+
|
|
343
354
|
/**
|
|
344
355
|
* Base service for services that need folder-specific functionality.
|
|
345
356
|
*
|
|
@@ -381,9 +392,12 @@ declare class FolderScopedService extends BaseService {
|
|
|
381
392
|
* @param name - Resource name to search for
|
|
382
393
|
* @param options - Folder scoping (`folderId` / `folderKey` / `folderPath`) + OData query options (`expand`, `select`)
|
|
383
394
|
* @param transform - Maps a raw OData item to the typed response (e.g. PascalCase → camelCase via field map)
|
|
395
|
+
* @param responseFieldMap - Optional response field map (API → SDK), reversed internally by
|
|
396
|
+
* `transformOptions` to rewrite SDK field names back to API names in user-supplied
|
|
397
|
+
* `expand` / `select` (symmetric counterpart to `transform`)
|
|
384
398
|
* @throws ValidationError when inputs are malformed; NotFoundError when no match
|
|
385
399
|
*/
|
|
386
|
-
protected getByNameLookup<TRaw extends object, T>(resourceType: string, endpoint: string, name: string, options: FolderScopedOptions, transform: (raw: TRaw) => T): Promise<T>;
|
|
400
|
+
protected getByNameLookup<TRaw extends object, T>(resourceType: string, endpoint: string, name: string, options: FolderScopedOptions, transform: (raw: TRaw) => T, responseFieldMap?: FieldMapping): Promise<T>;
|
|
387
401
|
}
|
|
388
402
|
|
|
389
403
|
/**
|
|
@@ -741,8 +755,9 @@ interface JobServiceModel {
|
|
|
741
755
|
* const folderJobs = await jobs.getAll({ folderId: <folderId> });
|
|
742
756
|
*
|
|
743
757
|
* // With filtering
|
|
744
|
-
* const
|
|
745
|
-
* filter: "
|
|
758
|
+
* const recentInvoiceJobs = await jobs.getAll({
|
|
759
|
+
* filter: "processName eq 'InvoiceBot'",
|
|
760
|
+
* orderby: 'createdTime desc',
|
|
746
761
|
* });
|
|
747
762
|
*
|
|
748
763
|
* // First page with pagination
|
|
@@ -1001,8 +1016,9 @@ declare class JobService extends FolderScopedService implements JobServiceModel
|
|
|
1001
1016
|
* const folderJobs = await jobs.getAll({ folderId: <folderId> });
|
|
1002
1017
|
*
|
|
1003
1018
|
* // With filtering
|
|
1004
|
-
* const
|
|
1005
|
-
* filter: "
|
|
1019
|
+
* const recentInvoiceJobs = await jobs.getAll({
|
|
1020
|
+
* filter: "processName eq 'InvoiceBot'",
|
|
1021
|
+
* orderby: 'createdTime desc',
|
|
1006
1022
|
* });
|
|
1007
1023
|
*
|
|
1008
1024
|
* // First page with pagination
|
package/dist/jobs/index.mjs
CHANGED
|
@@ -954,7 +954,16 @@ const BUCKET_TOKEN_PARAMS = {
|
|
|
954
954
|
* Returns the original value if parsing fails.
|
|
955
955
|
*/
|
|
956
956
|
/**
|
|
957
|
-
* Transforms data by
|
|
957
|
+
* Transforms data by renaming each key in `data` exactly once, using the
|
|
958
|
+
* mapping (`sourceField → targetField`). Keys not present in the mapping
|
|
959
|
+
* pass through unchanged. The original (pre-rename) key is dropped — the
|
|
960
|
+
* result contains only the renamed key.
|
|
961
|
+
*
|
|
962
|
+
* Each rename is independent. If the mapping happens to contain chained
|
|
963
|
+
* entries (`a → b` and `b → c`), they do NOT compose: a field named `a`
|
|
964
|
+
* in `data` becomes `b` (not `c`), because the renames are applied based
|
|
965
|
+
* on the original data's keys, not the running result.
|
|
966
|
+
*
|
|
958
967
|
* @param data The source data to transform
|
|
959
968
|
* @param fieldMapping Object mapping source field names to target field names
|
|
960
969
|
* @returns Transformed data with mapped field names
|
|
@@ -977,21 +986,28 @@ const BUCKET_TOKEN_PARAMS = {
|
|
|
977
986
|
* // { userId: '123', name: 'john' },
|
|
978
987
|
* // { userId: '456', name: 'jane' }
|
|
979
988
|
* // ]
|
|
989
|
+
*
|
|
990
|
+
* // No chaining — `a → b` does not become `a → c` even if the map has `b → c`.
|
|
991
|
+
* transformData({ a: 1 }, { a: 'b', b: 'c' });
|
|
992
|
+
* // result = { b: 1 }
|
|
980
993
|
* ```
|
|
981
994
|
*/
|
|
982
995
|
function transformData(data, fieldMapping) {
|
|
996
|
+
// Pass null/undefined through unchanged — callers (e.g. AttachmentService.getById)
|
|
997
|
+
// may invoke this on optional fields that an OData `select` excluded.
|
|
998
|
+
if (data == null) {
|
|
999
|
+
return data;
|
|
1000
|
+
}
|
|
983
1001
|
// Handle array of objects
|
|
984
1002
|
if (Array.isArray(data)) {
|
|
985
1003
|
return data.map(item => transformData(item, fieldMapping));
|
|
986
1004
|
}
|
|
987
|
-
//
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
result[targetField] = value;
|
|
994
|
-
}
|
|
1005
|
+
// Walk the ORIGINAL data's keys, look up each in the mapping. One rename
|
|
1006
|
+
// per data key — no mutation of an in-progress result, so chains can't form.
|
|
1007
|
+
const result = {};
|
|
1008
|
+
for (const [key, value] of Object.entries(data)) {
|
|
1009
|
+
const renamedKey = fieldMapping[key] ?? key;
|
|
1010
|
+
result[renamedKey] = value;
|
|
995
1011
|
}
|
|
996
1012
|
return result;
|
|
997
1013
|
}
|
|
@@ -1101,6 +1117,97 @@ function addPrefixToKeys(obj, prefix, keys) {
|
|
|
1101
1117
|
}
|
|
1102
1118
|
return result;
|
|
1103
1119
|
}
|
|
1120
|
+
/**
|
|
1121
|
+
* Creates a new map with the keys and values reversed
|
|
1122
|
+
* @param map The original map to reverse
|
|
1123
|
+
* @returns A new map with keys and values swapped
|
|
1124
|
+
*
|
|
1125
|
+
* @example
|
|
1126
|
+
* ```typescript
|
|
1127
|
+
* const original = { key1: 'value1', key2: 'value2' };
|
|
1128
|
+
* const reversed = reverseMap(original);
|
|
1129
|
+
* // reversed = { value1: 'key1', value2: 'key2' }
|
|
1130
|
+
* ```
|
|
1131
|
+
*/
|
|
1132
|
+
function reverseMap(map) {
|
|
1133
|
+
return Object.entries(map).reduce((acc, [key, value]) => {
|
|
1134
|
+
acc[value] = key;
|
|
1135
|
+
return acc;
|
|
1136
|
+
}, {});
|
|
1137
|
+
}
|
|
1138
|
+
/**
|
|
1139
|
+
* OData query-string keys whose values may contain field identifiers that
|
|
1140
|
+
* need rewriting from SDK names → API names.
|
|
1141
|
+
*/
|
|
1142
|
+
const ODATA_FIELD_PARAM_KEYS = ['filter', 'orderby', 'select', 'expand'];
|
|
1143
|
+
/**
|
|
1144
|
+
* Matches one token at a time in an OData expression:
|
|
1145
|
+
* 1. A single-quoted string literal, allowing the `''` escape sequence —
|
|
1146
|
+
* consumed atomically so identifiers inside the literal can't match.
|
|
1147
|
+
* 2. An OData identifier (`[A-Za-z_][A-Za-z0-9_]*`).
|
|
1148
|
+
* Anything else (whitespace, operators, parens, commas) is left alone by
|
|
1149
|
+
* `String.prototype.replace`, which only substitutes matched substrings.
|
|
1150
|
+
*/
|
|
1151
|
+
const ODATA_TOKEN_RE = /'(?:[^']|'')*'|[A-Za-z_][A-Za-z0-9_]*/g;
|
|
1152
|
+
/**
|
|
1153
|
+
* Rewrites SDK field identifiers to API field identifiers inside an OData
|
|
1154
|
+
* expression string (`$filter`, `$orderby`, `$select`, `$expand`).
|
|
1155
|
+
*
|
|
1156
|
+
* Field maps (e.g. `JobMap`) rename API fields → SDK fields on responses, so
|
|
1157
|
+
* SDK consumers see the renamed names. Without this rewrite, the same name
|
|
1158
|
+
* in a `filter` string would be forwarded verbatim and the API (which still
|
|
1159
|
+
* uses the original name) would reject it.
|
|
1160
|
+
*
|
|
1161
|
+
* Quoted string literals (with the OData `''` escape) are preserved exactly:
|
|
1162
|
+
* the token regex consumes them whole, so identifiers inside literals never
|
|
1163
|
+
* match. Identifier tokens are looked up in the reversed field map.
|
|
1164
|
+
*
|
|
1165
|
+
* @example
|
|
1166
|
+
* ```typescript
|
|
1167
|
+
* const requestMap = { processName: 'releaseName' };
|
|
1168
|
+
* rewriteODataIdentifiers("processName eq 'processName'", requestMap);
|
|
1169
|
+
* // "releaseName eq 'processName'" — identifier rewritten, literal preserved
|
|
1170
|
+
* ```
|
|
1171
|
+
*/
|
|
1172
|
+
function rewriteODataIdentifiers(expression, requestMap) {
|
|
1173
|
+
if (!expression)
|
|
1174
|
+
return expression;
|
|
1175
|
+
return expression.replace(ODATA_TOKEN_RE, (match) => match.startsWith("'") ? match : (requestMap[match] ?? match));
|
|
1176
|
+
}
|
|
1177
|
+
/**
|
|
1178
|
+
* Symmetric counterpart of {@link transformRequest} for OData query options:
|
|
1179
|
+
* rewrites SDK field identifiers inside the recognized OData string params
|
|
1180
|
+
* (`filter`, `orderby`, `select`, `expand`) to their API names using the
|
|
1181
|
+
* reversed form of a response field map. Returns a shallow copy with the
|
|
1182
|
+
* relevant values rewritten; other keys pass through unchanged.
|
|
1183
|
+
*
|
|
1184
|
+
* Use at the OData edge so SDK consumers can refer to renamed fields by
|
|
1185
|
+
* their SDK name throughout — for reading the response and for filtering /
|
|
1186
|
+
* sorting / projecting / expanding.
|
|
1187
|
+
*
|
|
1188
|
+
* @param options The OData query options as authored with SDK field names
|
|
1189
|
+
* @param responseMap The response field map (API → SDK); reversed internally
|
|
1190
|
+
*
|
|
1191
|
+
* @example
|
|
1192
|
+
* ```typescript
|
|
1193
|
+
* // JobMap renames releaseName → processName on responses.
|
|
1194
|
+
* transformOptions({ filter: "processName eq 'X'" }, JobMap);
|
|
1195
|
+
* // { filter: "releaseName eq 'X'" }
|
|
1196
|
+
* ```
|
|
1197
|
+
*/
|
|
1198
|
+
function transformOptions(options, responseMap) {
|
|
1199
|
+
const requestMap = reverseMap(responseMap);
|
|
1200
|
+
if (Object.keys(requestMap).length === 0)
|
|
1201
|
+
return options;
|
|
1202
|
+
const result = { ...options };
|
|
1203
|
+
for (const key of ODATA_FIELD_PARAM_KEYS) {
|
|
1204
|
+
const value = result[key];
|
|
1205
|
+
if (typeof value === 'string') {
|
|
1206
|
+
result[key] = rewriteODataIdentifiers(value, requestMap);
|
|
1207
|
+
}
|
|
1208
|
+
}
|
|
1209
|
+
return result;
|
|
1210
|
+
}
|
|
1104
1211
|
|
|
1105
1212
|
/**
|
|
1106
1213
|
* Constants used throughout the pagination system
|
|
@@ -1864,9 +1971,12 @@ class FolderScopedService extends BaseService {
|
|
|
1864
1971
|
* @param name - Resource name to search for
|
|
1865
1972
|
* @param options - Folder scoping (`folderId` / `folderKey` / `folderPath`) + OData query options (`expand`, `select`)
|
|
1866
1973
|
* @param transform - Maps a raw OData item to the typed response (e.g. PascalCase → camelCase via field map)
|
|
1974
|
+
* @param responseFieldMap - Optional response field map (API → SDK), reversed internally by
|
|
1975
|
+
* `transformOptions` to rewrite SDK field names back to API names in user-supplied
|
|
1976
|
+
* `expand` / `select` (symmetric counterpart to `transform`)
|
|
1867
1977
|
* @throws ValidationError when inputs are malformed; NotFoundError when no match
|
|
1868
1978
|
*/
|
|
1869
|
-
async getByNameLookup(resourceType, endpoint, name, options, transform) {
|
|
1979
|
+
async getByNameLookup(resourceType, endpoint, name, options, transform, responseFieldMap) {
|
|
1870
1980
|
const validatedName = validateName(resourceType, name);
|
|
1871
1981
|
const { folderId, folderKey, folderPath, ...queryOptions } = options;
|
|
1872
1982
|
const headers = resolveFolderHeaders({
|
|
@@ -1876,8 +1986,11 @@ class FolderScopedService extends BaseService {
|
|
|
1876
1986
|
resourceType: `${resourceType}.getByName`,
|
|
1877
1987
|
fallbackFolderKey: this.config.folderKey,
|
|
1878
1988
|
});
|
|
1989
|
+
const apiFieldOptions = responseFieldMap
|
|
1990
|
+
? transformOptions(queryOptions, responseFieldMap)
|
|
1991
|
+
: queryOptions;
|
|
1879
1992
|
const apiOptions = {
|
|
1880
|
-
...addPrefixToKeys(
|
|
1993
|
+
...addPrefixToKeys(apiFieldOptions, ODATA_PREFIX, Object.keys(apiFieldOptions)),
|
|
1881
1994
|
'$filter': `Name eq '${validatedName.replace(SINGLE_QUOTE_RE, "''")}'`,
|
|
1882
1995
|
'$top': '1',
|
|
1883
1996
|
};
|
|
@@ -2066,9 +2179,10 @@ class AttachmentService extends BaseService {
|
|
|
2066
2179
|
if (!id) {
|
|
2067
2180
|
throw new ValidationError({ message: 'id is required for getById' });
|
|
2068
2181
|
}
|
|
2069
|
-
//
|
|
2070
|
-
|
|
2071
|
-
const
|
|
2182
|
+
// Response applies both maps (BucketMap on blobFileAccess, AttachmentsMap on top-level);
|
|
2183
|
+
// merge so SDK names from either are rewritten in one pass.
|
|
2184
|
+
const apiFieldOptions = transformOptions(options, { ...AttachmentsMap, ...BucketMap });
|
|
2185
|
+
const apiOptions = addPrefixToKeys(apiFieldOptions, ODATA_PREFIX, Object.keys(apiFieldOptions));
|
|
2072
2186
|
const response = await this.get(ORCHESTRATOR_ATTACHMENT_ENDPOINTS.GET_BY_ID(id), {
|
|
2073
2187
|
params: apiOptions,
|
|
2074
2188
|
});
|
|
@@ -2292,8 +2406,9 @@ class JobService extends FolderScopedService {
|
|
|
2292
2406
|
* const folderJobs = await jobs.getAll({ folderId: <folderId> });
|
|
2293
2407
|
*
|
|
2294
2408
|
* // With filtering
|
|
2295
|
-
* const
|
|
2296
|
-
* filter: "
|
|
2409
|
+
* const recentInvoiceJobs = await jobs.getAll({
|
|
2410
|
+
* filter: "processName eq 'InvoiceBot'",
|
|
2411
|
+
* orderby: 'createdTime desc',
|
|
2297
2412
|
* });
|
|
2298
2413
|
*
|
|
2299
2414
|
* // First page with pagination
|
|
@@ -2316,6 +2431,10 @@ class JobService extends FolderScopedService {
|
|
|
2316
2431
|
const rawJob = transformData(pascalToCamelCaseKeys(job), JobMap);
|
|
2317
2432
|
return createJobWithMethods(rawJob, this);
|
|
2318
2433
|
};
|
|
2434
|
+
// Rewrite renamed SDK field names → API names inside OData strings
|
|
2435
|
+
// before delegating, mirroring the transformRequest pattern used for
|
|
2436
|
+
// request bodies.
|
|
2437
|
+
const apiOptions = options ? transformOptions(options, JobMap) : options;
|
|
2319
2438
|
return PaginationHelpers.getAll({
|
|
2320
2439
|
serviceAccess: this.createPaginationServiceAccess(),
|
|
2321
2440
|
getEndpoint: () => JOB_ENDPOINTS.GET_ALL,
|
|
@@ -2331,7 +2450,7 @@ class JobService extends FolderScopedService {
|
|
|
2331
2450
|
countParam: ODATA_OFFSET_PARAMS.COUNT_PARAM,
|
|
2332
2451
|
},
|
|
2333
2452
|
},
|
|
2334
|
-
},
|
|
2453
|
+
}, apiOptions);
|
|
2335
2454
|
}
|
|
2336
2455
|
/**
|
|
2337
2456
|
* Gets a job by its unique key (GUID).
|
|
@@ -2368,8 +2487,8 @@ class JobService extends FolderScopedService {
|
|
|
2368
2487
|
throw new ValidationError({ message: 'folderId is required for getById' });
|
|
2369
2488
|
}
|
|
2370
2489
|
const headers = createHeaders({ [FOLDER_ID]: folderId });
|
|
2371
|
-
const
|
|
2372
|
-
const apiOptions =
|
|
2490
|
+
const apiFieldOptions = options ? transformOptions(options, JobMap) : {};
|
|
2491
|
+
const apiOptions = addPrefixToKeys(apiFieldOptions, ODATA_PREFIX, Object.keys(apiFieldOptions));
|
|
2373
2492
|
const response = await this.get(JOB_ENDPOINTS.GET_BY_KEY(id), {
|
|
2374
2493
|
params: apiOptions,
|
|
2375
2494
|
headers,
|
|
@@ -2672,6 +2791,9 @@ var JobState;
|
|
|
2672
2791
|
JobState["Stopped"] = "Stopped";
|
|
2673
2792
|
JobState["Suspended"] = "Suspended";
|
|
2674
2793
|
JobState["Resumed"] = "Resumed";
|
|
2794
|
+
JobState["Cancelled"] = "Cancelled";
|
|
2795
|
+
/** Server-side fallback for an unrecognized or missing job state. */
|
|
2796
|
+
JobState["Unknown"] = "Unknown";
|
|
2675
2797
|
})(JobState || (JobState = {}));
|
|
2676
2798
|
|
|
2677
2799
|
export { JobService, JobState, JobSubState, JobService as Jobs, ServerlessJobType, StopStrategy, createJobWithMethods };
|