@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/processes/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
|
}
|
|
@@ -1166,6 +1182,79 @@ function transformRequest(data, responseMap) {
|
|
|
1166
1182
|
}
|
|
1167
1183
|
return result;
|
|
1168
1184
|
}
|
|
1185
|
+
/**
|
|
1186
|
+
* OData query-string keys whose values may contain field identifiers that
|
|
1187
|
+
* need rewriting from SDK names → API names.
|
|
1188
|
+
*/
|
|
1189
|
+
const ODATA_FIELD_PARAM_KEYS = ['filter', 'orderby', 'select', 'expand'];
|
|
1190
|
+
/**
|
|
1191
|
+
* Matches one token at a time in an OData expression:
|
|
1192
|
+
* 1. A single-quoted string literal, allowing the `''` escape sequence —
|
|
1193
|
+
* consumed atomically so identifiers inside the literal can't match.
|
|
1194
|
+
* 2. An OData identifier (`[A-Za-z_][A-Za-z0-9_]*`).
|
|
1195
|
+
* Anything else (whitespace, operators, parens, commas) is left alone by
|
|
1196
|
+
* `String.prototype.replace`, which only substitutes matched substrings.
|
|
1197
|
+
*/
|
|
1198
|
+
const ODATA_TOKEN_RE = /'(?:[^']|'')*'|[A-Za-z_][A-Za-z0-9_]*/g;
|
|
1199
|
+
/**
|
|
1200
|
+
* Rewrites SDK field identifiers to API field identifiers inside an OData
|
|
1201
|
+
* expression string (`$filter`, `$orderby`, `$select`, `$expand`).
|
|
1202
|
+
*
|
|
1203
|
+
* Field maps (e.g. `JobMap`) rename API fields → SDK fields on responses, so
|
|
1204
|
+
* SDK consumers see the renamed names. Without this rewrite, the same name
|
|
1205
|
+
* in a `filter` string would be forwarded verbatim and the API (which still
|
|
1206
|
+
* uses the original name) would reject it.
|
|
1207
|
+
*
|
|
1208
|
+
* Quoted string literals (with the OData `''` escape) are preserved exactly:
|
|
1209
|
+
* the token regex consumes them whole, so identifiers inside literals never
|
|
1210
|
+
* match. Identifier tokens are looked up in the reversed field map.
|
|
1211
|
+
*
|
|
1212
|
+
* @example
|
|
1213
|
+
* ```typescript
|
|
1214
|
+
* const requestMap = { processName: 'releaseName' };
|
|
1215
|
+
* rewriteODataIdentifiers("processName eq 'processName'", requestMap);
|
|
1216
|
+
* // "releaseName eq 'processName'" — identifier rewritten, literal preserved
|
|
1217
|
+
* ```
|
|
1218
|
+
*/
|
|
1219
|
+
function rewriteODataIdentifiers(expression, requestMap) {
|
|
1220
|
+
if (!expression)
|
|
1221
|
+
return expression;
|
|
1222
|
+
return expression.replace(ODATA_TOKEN_RE, (match) => match.startsWith("'") ? match : (requestMap[match] ?? match));
|
|
1223
|
+
}
|
|
1224
|
+
/**
|
|
1225
|
+
* Symmetric counterpart of {@link transformRequest} for OData query options:
|
|
1226
|
+
* rewrites SDK field identifiers inside the recognized OData string params
|
|
1227
|
+
* (`filter`, `orderby`, `select`, `expand`) to their API names using the
|
|
1228
|
+
* reversed form of a response field map. Returns a shallow copy with the
|
|
1229
|
+
* relevant values rewritten; other keys pass through unchanged.
|
|
1230
|
+
*
|
|
1231
|
+
* Use at the OData edge so SDK consumers can refer to renamed fields by
|
|
1232
|
+
* their SDK name throughout — for reading the response and for filtering /
|
|
1233
|
+
* sorting / projecting / expanding.
|
|
1234
|
+
*
|
|
1235
|
+
* @param options The OData query options as authored with SDK field names
|
|
1236
|
+
* @param responseMap The response field map (API → SDK); reversed internally
|
|
1237
|
+
*
|
|
1238
|
+
* @example
|
|
1239
|
+
* ```typescript
|
|
1240
|
+
* // JobMap renames releaseName → processName on responses.
|
|
1241
|
+
* transformOptions({ filter: "processName eq 'X'" }, JobMap);
|
|
1242
|
+
* // { filter: "releaseName eq 'X'" }
|
|
1243
|
+
* ```
|
|
1244
|
+
*/
|
|
1245
|
+
function transformOptions(options, responseMap) {
|
|
1246
|
+
const requestMap = reverseMap(responseMap);
|
|
1247
|
+
if (Object.keys(requestMap).length === 0)
|
|
1248
|
+
return options;
|
|
1249
|
+
const result = { ...options };
|
|
1250
|
+
for (const key of ODATA_FIELD_PARAM_KEYS) {
|
|
1251
|
+
const value = result[key];
|
|
1252
|
+
if (typeof value === 'string') {
|
|
1253
|
+
result[key] = rewriteODataIdentifiers(value, requestMap);
|
|
1254
|
+
}
|
|
1255
|
+
}
|
|
1256
|
+
return result;
|
|
1257
|
+
}
|
|
1169
1258
|
|
|
1170
1259
|
/**
|
|
1171
1260
|
* Constants used throughout the pagination system
|
|
@@ -1929,9 +2018,12 @@ class FolderScopedService extends BaseService {
|
|
|
1929
2018
|
* @param name - Resource name to search for
|
|
1930
2019
|
* @param options - Folder scoping (`folderId` / `folderKey` / `folderPath`) + OData query options (`expand`, `select`)
|
|
1931
2020
|
* @param transform - Maps a raw OData item to the typed response (e.g. PascalCase → camelCase via field map)
|
|
2021
|
+
* @param responseFieldMap - Optional response field map (API → SDK), reversed internally by
|
|
2022
|
+
* `transformOptions` to rewrite SDK field names back to API names in user-supplied
|
|
2023
|
+
* `expand` / `select` (symmetric counterpart to `transform`)
|
|
1932
2024
|
* @throws ValidationError when inputs are malformed; NotFoundError when no match
|
|
1933
2025
|
*/
|
|
1934
|
-
async getByNameLookup(resourceType, endpoint, name, options, transform) {
|
|
2026
|
+
async getByNameLookup(resourceType, endpoint, name, options, transform, responseFieldMap) {
|
|
1935
2027
|
const validatedName = validateName(resourceType, name);
|
|
1936
2028
|
const { folderId, folderKey, folderPath, ...queryOptions } = options;
|
|
1937
2029
|
const headers = resolveFolderHeaders({
|
|
@@ -1941,8 +2033,11 @@ class FolderScopedService extends BaseService {
|
|
|
1941
2033
|
resourceType: `${resourceType}.getByName`,
|
|
1942
2034
|
fallbackFolderKey: this.config.folderKey,
|
|
1943
2035
|
});
|
|
2036
|
+
const apiFieldOptions = responseFieldMap
|
|
2037
|
+
? transformOptions(queryOptions, responseFieldMap)
|
|
2038
|
+
: queryOptions;
|
|
1944
2039
|
const apiOptions = {
|
|
1945
|
-
...addPrefixToKeys(
|
|
2040
|
+
...addPrefixToKeys(apiFieldOptions, ODATA_PREFIX, Object.keys(apiFieldOptions)),
|
|
1946
2041
|
'$filter': `Name eq '${validatedName.replace(SINGLE_QUOTE_RE, "''")}'`,
|
|
1947
2042
|
'$top': '1',
|
|
1948
2043
|
};
|
|
@@ -2087,6 +2182,10 @@ class ProcessService extends FolderScopedService {
|
|
|
2087
2182
|
async getAll(options) {
|
|
2088
2183
|
// Transformation function for processes
|
|
2089
2184
|
const transformProcessResponse = (process) => transformData(pascalToCamelCaseKeys(process), ProcessMap);
|
|
2185
|
+
// Rewrite renamed SDK field names → API names inside OData strings
|
|
2186
|
+
// before delegating, mirroring the transformRequest pattern used for
|
|
2187
|
+
// request bodies.
|
|
2188
|
+
const apiOptions = options ? transformOptions(options, ProcessMap) : options;
|
|
2090
2189
|
return PaginationHelpers.getAll({
|
|
2091
2190
|
serviceAccess: this.createPaginationServiceAccess(),
|
|
2092
2191
|
getEndpoint: () => PROCESS_ENDPOINTS.GET_ALL,
|
|
@@ -2102,7 +2201,7 @@ class ProcessService extends FolderScopedService {
|
|
|
2102
2201
|
countParam: ODATA_OFFSET_PARAMS.COUNT_PARAM
|
|
2103
2202
|
}
|
|
2104
2203
|
}
|
|
2105
|
-
},
|
|
2204
|
+
}, apiOptions);
|
|
2106
2205
|
}
|
|
2107
2206
|
async start(request, optionsOrFolderId, legacyOptions) {
|
|
2108
2207
|
// Normalize the two overload forms into a single internal shape.
|
|
@@ -2136,9 +2235,10 @@ class ProcessService extends FolderScopedService {
|
|
|
2136
2235
|
const requestBody = {
|
|
2137
2236
|
startInfo: apiRequest
|
|
2138
2237
|
};
|
|
2139
|
-
//
|
|
2140
|
-
|
|
2141
|
-
const
|
|
2238
|
+
// Rewrite renamed SDK field names → API names inside OData strings,
|
|
2239
|
+
// then prefix all query parameter keys with '$' for OData.
|
|
2240
|
+
const apiFieldOptions = transformOptions(queryOptions, ProcessMap);
|
|
2241
|
+
const apiOptions = addPrefixToKeys(apiFieldOptions, ODATA_PREFIX, Object.keys(apiFieldOptions));
|
|
2142
2242
|
const response = await this.post(PROCESS_ENDPOINTS.START_PROCESS, requestBody, {
|
|
2143
2243
|
params: apiOptions,
|
|
2144
2244
|
headers
|
|
@@ -2166,8 +2266,8 @@ class ProcessService extends FolderScopedService {
|
|
|
2166
2266
|
*/
|
|
2167
2267
|
async getById(id, folderId, options = {}) {
|
|
2168
2268
|
const headers = createHeaders({ [FOLDER_ID]: folderId });
|
|
2169
|
-
const
|
|
2170
|
-
const apiOptions = addPrefixToKeys(
|
|
2269
|
+
const apiFieldOptions = transformOptions(options, ProcessMap);
|
|
2270
|
+
const apiOptions = addPrefixToKeys(apiFieldOptions, ODATA_PREFIX, Object.keys(apiFieldOptions));
|
|
2171
2271
|
const response = await this.get(PROCESS_ENDPOINTS.GET_BY_ID(id), {
|
|
2172
2272
|
headers,
|
|
2173
2273
|
params: apiOptions
|
|
@@ -2202,7 +2302,7 @@ class ProcessService extends FolderScopedService {
|
|
|
2202
2302
|
* ```
|
|
2203
2303
|
*/
|
|
2204
2304
|
async getByName(name, options = {}) {
|
|
2205
|
-
return this.getByNameLookup('Process', PROCESS_ENDPOINTS.GET_ALL, name, options, (raw) => transformData(pascalToCamelCaseKeys(raw), ProcessMap));
|
|
2305
|
+
return this.getByNameLookup('Process', PROCESS_ENDPOINTS.GET_ALL, name, options, (raw) => transformData(pascalToCamelCaseKeys(raw), ProcessMap), ProcessMap);
|
|
2206
2306
|
}
|
|
2207
2307
|
}
|
|
2208
2308
|
__decorate([
|
|
@@ -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
|
/**
|
|
@@ -670,6 +684,8 @@ interface ProcessStartResponse extends ProcessProperties, FolderProperties {
|
|
|
670
684
|
createdTime: string;
|
|
671
685
|
startingScheduleId: number | null;
|
|
672
686
|
processName: string;
|
|
687
|
+
/** Key of the process this job was started from. */
|
|
688
|
+
processKey: string;
|
|
673
689
|
type: JobType;
|
|
674
690
|
inputFile: string | null;
|
|
675
691
|
outputArguments: string | null;
|
package/dist/processes/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
|
}
|
|
@@ -1164,6 +1180,79 @@ function transformRequest(data, responseMap) {
|
|
|
1164
1180
|
}
|
|
1165
1181
|
return result;
|
|
1166
1182
|
}
|
|
1183
|
+
/**
|
|
1184
|
+
* OData query-string keys whose values may contain field identifiers that
|
|
1185
|
+
* need rewriting from SDK names → API names.
|
|
1186
|
+
*/
|
|
1187
|
+
const ODATA_FIELD_PARAM_KEYS = ['filter', 'orderby', 'select', 'expand'];
|
|
1188
|
+
/**
|
|
1189
|
+
* Matches one token at a time in an OData expression:
|
|
1190
|
+
* 1. A single-quoted string literal, allowing the `''` escape sequence —
|
|
1191
|
+
* consumed atomically so identifiers inside the literal can't match.
|
|
1192
|
+
* 2. An OData identifier (`[A-Za-z_][A-Za-z0-9_]*`).
|
|
1193
|
+
* Anything else (whitespace, operators, parens, commas) is left alone by
|
|
1194
|
+
* `String.prototype.replace`, which only substitutes matched substrings.
|
|
1195
|
+
*/
|
|
1196
|
+
const ODATA_TOKEN_RE = /'(?:[^']|'')*'|[A-Za-z_][A-Za-z0-9_]*/g;
|
|
1197
|
+
/**
|
|
1198
|
+
* Rewrites SDK field identifiers to API field identifiers inside an OData
|
|
1199
|
+
* expression string (`$filter`, `$orderby`, `$select`, `$expand`).
|
|
1200
|
+
*
|
|
1201
|
+
* Field maps (e.g. `JobMap`) rename API fields → SDK fields on responses, so
|
|
1202
|
+
* SDK consumers see the renamed names. Without this rewrite, the same name
|
|
1203
|
+
* in a `filter` string would be forwarded verbatim and the API (which still
|
|
1204
|
+
* uses the original name) would reject it.
|
|
1205
|
+
*
|
|
1206
|
+
* Quoted string literals (with the OData `''` escape) are preserved exactly:
|
|
1207
|
+
* the token regex consumes them whole, so identifiers inside literals never
|
|
1208
|
+
* match. Identifier tokens are looked up in the reversed field map.
|
|
1209
|
+
*
|
|
1210
|
+
* @example
|
|
1211
|
+
* ```typescript
|
|
1212
|
+
* const requestMap = { processName: 'releaseName' };
|
|
1213
|
+
* rewriteODataIdentifiers("processName eq 'processName'", requestMap);
|
|
1214
|
+
* // "releaseName eq 'processName'" — identifier rewritten, literal preserved
|
|
1215
|
+
* ```
|
|
1216
|
+
*/
|
|
1217
|
+
function rewriteODataIdentifiers(expression, requestMap) {
|
|
1218
|
+
if (!expression)
|
|
1219
|
+
return expression;
|
|
1220
|
+
return expression.replace(ODATA_TOKEN_RE, (match) => match.startsWith("'") ? match : (requestMap[match] ?? match));
|
|
1221
|
+
}
|
|
1222
|
+
/**
|
|
1223
|
+
* Symmetric counterpart of {@link transformRequest} for OData query options:
|
|
1224
|
+
* rewrites SDK field identifiers inside the recognized OData string params
|
|
1225
|
+
* (`filter`, `orderby`, `select`, `expand`) to their API names using the
|
|
1226
|
+
* reversed form of a response field map. Returns a shallow copy with the
|
|
1227
|
+
* relevant values rewritten; other keys pass through unchanged.
|
|
1228
|
+
*
|
|
1229
|
+
* Use at the OData edge so SDK consumers can refer to renamed fields by
|
|
1230
|
+
* their SDK name throughout — for reading the response and for filtering /
|
|
1231
|
+
* sorting / projecting / expanding.
|
|
1232
|
+
*
|
|
1233
|
+
* @param options The OData query options as authored with SDK field names
|
|
1234
|
+
* @param responseMap The response field map (API → SDK); reversed internally
|
|
1235
|
+
*
|
|
1236
|
+
* @example
|
|
1237
|
+
* ```typescript
|
|
1238
|
+
* // JobMap renames releaseName → processName on responses.
|
|
1239
|
+
* transformOptions({ filter: "processName eq 'X'" }, JobMap);
|
|
1240
|
+
* // { filter: "releaseName eq 'X'" }
|
|
1241
|
+
* ```
|
|
1242
|
+
*/
|
|
1243
|
+
function transformOptions(options, responseMap) {
|
|
1244
|
+
const requestMap = reverseMap(responseMap);
|
|
1245
|
+
if (Object.keys(requestMap).length === 0)
|
|
1246
|
+
return options;
|
|
1247
|
+
const result = { ...options };
|
|
1248
|
+
for (const key of ODATA_FIELD_PARAM_KEYS) {
|
|
1249
|
+
const value = result[key];
|
|
1250
|
+
if (typeof value === 'string') {
|
|
1251
|
+
result[key] = rewriteODataIdentifiers(value, requestMap);
|
|
1252
|
+
}
|
|
1253
|
+
}
|
|
1254
|
+
return result;
|
|
1255
|
+
}
|
|
1167
1256
|
|
|
1168
1257
|
/**
|
|
1169
1258
|
* Constants used throughout the pagination system
|
|
@@ -1927,9 +2016,12 @@ class FolderScopedService extends BaseService {
|
|
|
1927
2016
|
* @param name - Resource name to search for
|
|
1928
2017
|
* @param options - Folder scoping (`folderId` / `folderKey` / `folderPath`) + OData query options (`expand`, `select`)
|
|
1929
2018
|
* @param transform - Maps a raw OData item to the typed response (e.g. PascalCase → camelCase via field map)
|
|
2019
|
+
* @param responseFieldMap - Optional response field map (API → SDK), reversed internally by
|
|
2020
|
+
* `transformOptions` to rewrite SDK field names back to API names in user-supplied
|
|
2021
|
+
* `expand` / `select` (symmetric counterpart to `transform`)
|
|
1930
2022
|
* @throws ValidationError when inputs are malformed; NotFoundError when no match
|
|
1931
2023
|
*/
|
|
1932
|
-
async getByNameLookup(resourceType, endpoint, name, options, transform) {
|
|
2024
|
+
async getByNameLookup(resourceType, endpoint, name, options, transform, responseFieldMap) {
|
|
1933
2025
|
const validatedName = validateName(resourceType, name);
|
|
1934
2026
|
const { folderId, folderKey, folderPath, ...queryOptions } = options;
|
|
1935
2027
|
const headers = resolveFolderHeaders({
|
|
@@ -1939,8 +2031,11 @@ class FolderScopedService extends BaseService {
|
|
|
1939
2031
|
resourceType: `${resourceType}.getByName`,
|
|
1940
2032
|
fallbackFolderKey: this.config.folderKey,
|
|
1941
2033
|
});
|
|
2034
|
+
const apiFieldOptions = responseFieldMap
|
|
2035
|
+
? transformOptions(queryOptions, responseFieldMap)
|
|
2036
|
+
: queryOptions;
|
|
1942
2037
|
const apiOptions = {
|
|
1943
|
-
...addPrefixToKeys(
|
|
2038
|
+
...addPrefixToKeys(apiFieldOptions, ODATA_PREFIX, Object.keys(apiFieldOptions)),
|
|
1944
2039
|
'$filter': `Name eq '${validatedName.replace(SINGLE_QUOTE_RE, "''")}'`,
|
|
1945
2040
|
'$top': '1',
|
|
1946
2041
|
};
|
|
@@ -2085,6 +2180,10 @@ class ProcessService extends FolderScopedService {
|
|
|
2085
2180
|
async getAll(options) {
|
|
2086
2181
|
// Transformation function for processes
|
|
2087
2182
|
const transformProcessResponse = (process) => transformData(pascalToCamelCaseKeys(process), ProcessMap);
|
|
2183
|
+
// Rewrite renamed SDK field names → API names inside OData strings
|
|
2184
|
+
// before delegating, mirroring the transformRequest pattern used for
|
|
2185
|
+
// request bodies.
|
|
2186
|
+
const apiOptions = options ? transformOptions(options, ProcessMap) : options;
|
|
2088
2187
|
return PaginationHelpers.getAll({
|
|
2089
2188
|
serviceAccess: this.createPaginationServiceAccess(),
|
|
2090
2189
|
getEndpoint: () => PROCESS_ENDPOINTS.GET_ALL,
|
|
@@ -2100,7 +2199,7 @@ class ProcessService extends FolderScopedService {
|
|
|
2100
2199
|
countParam: ODATA_OFFSET_PARAMS.COUNT_PARAM
|
|
2101
2200
|
}
|
|
2102
2201
|
}
|
|
2103
|
-
},
|
|
2202
|
+
}, apiOptions);
|
|
2104
2203
|
}
|
|
2105
2204
|
async start(request, optionsOrFolderId, legacyOptions) {
|
|
2106
2205
|
// Normalize the two overload forms into a single internal shape.
|
|
@@ -2134,9 +2233,10 @@ class ProcessService extends FolderScopedService {
|
|
|
2134
2233
|
const requestBody = {
|
|
2135
2234
|
startInfo: apiRequest
|
|
2136
2235
|
};
|
|
2137
|
-
//
|
|
2138
|
-
|
|
2139
|
-
const
|
|
2236
|
+
// Rewrite renamed SDK field names → API names inside OData strings,
|
|
2237
|
+
// then prefix all query parameter keys with '$' for OData.
|
|
2238
|
+
const apiFieldOptions = transformOptions(queryOptions, ProcessMap);
|
|
2239
|
+
const apiOptions = addPrefixToKeys(apiFieldOptions, ODATA_PREFIX, Object.keys(apiFieldOptions));
|
|
2140
2240
|
const response = await this.post(PROCESS_ENDPOINTS.START_PROCESS, requestBody, {
|
|
2141
2241
|
params: apiOptions,
|
|
2142
2242
|
headers
|
|
@@ -2164,8 +2264,8 @@ class ProcessService extends FolderScopedService {
|
|
|
2164
2264
|
*/
|
|
2165
2265
|
async getById(id, folderId, options = {}) {
|
|
2166
2266
|
const headers = createHeaders({ [FOLDER_ID]: folderId });
|
|
2167
|
-
const
|
|
2168
|
-
const apiOptions = addPrefixToKeys(
|
|
2267
|
+
const apiFieldOptions = transformOptions(options, ProcessMap);
|
|
2268
|
+
const apiOptions = addPrefixToKeys(apiFieldOptions, ODATA_PREFIX, Object.keys(apiFieldOptions));
|
|
2169
2269
|
const response = await this.get(PROCESS_ENDPOINTS.GET_BY_ID(id), {
|
|
2170
2270
|
headers,
|
|
2171
2271
|
params: apiOptions
|
|
@@ -2200,7 +2300,7 @@ class ProcessService extends FolderScopedService {
|
|
|
2200
2300
|
* ```
|
|
2201
2301
|
*/
|
|
2202
2302
|
async getByName(name, options = {}) {
|
|
2203
|
-
return this.getByNameLookup('Process', PROCESS_ENDPOINTS.GET_ALL, name, options, (raw) => transformData(pascalToCamelCaseKeys(raw), ProcessMap));
|
|
2303
|
+
return this.getByNameLookup('Process', PROCESS_ENDPOINTS.GET_ALL, name, options, (raw) => transformData(pascalToCamelCaseKeys(raw), ProcessMap), ProcessMap);
|
|
2204
2304
|
}
|
|
2205
2305
|
}
|
|
2206
2306
|
__decorate([
|