@uipath/uipath-typescript 1.5.0 → 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/assets/index.cjs +107 -6
- package/dist/assets/index.d.ts +12 -1
- package/dist/assets/index.mjs +107 -6
- package/dist/attachments/index.cjs +95 -3
- package/dist/attachments/index.mjs +95 -3
- package/dist/buckets/index.cjs +111 -6
- package/dist/buckets/index.d.ts +12 -1
- package/dist/buckets/index.mjs +111 -6
- package/dist/cases/index.cjs +434 -266
- package/dist/cases/index.d.ts +140 -3
- package/dist/cases/index.mjs +434 -266
- package/dist/conversational-agent/index.cjs +23 -1
- package/dist/conversational-agent/index.d.ts +117 -6
- package/dist/conversational-agent/index.mjs +23 -1
- package/dist/core/index.cjs +1 -1
- package/dist/core/index.mjs +1 -1
- package/dist/entities/index.cjs +423 -0
- package/dist/entities/index.d.ts +441 -1
- package/dist/entities/index.mjs +422 -1
- package/dist/index.cjs +974 -293
- package/dist/index.d.ts +1150 -43
- package/dist/index.mjs +975 -294
- package/dist/index.umd.js +974 -293
- package/dist/jobs/index.cjs +12 -5
- package/dist/jobs/index.d.ts +12 -1
- package/dist/jobs/index.mjs +12 -5
- package/dist/maestro-processes/index.cjs +344 -243
- package/dist/maestro-processes/index.d.ts +189 -5
- package/dist/maestro-processes/index.mjs +344 -243
- 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 +93 -9
- package/dist/processes/index.d.ts +12 -1
- package/dist/processes/index.mjs +93 -9
- package/dist/queues/index.cjs +106 -5
- package/dist/queues/index.d.ts +12 -1
- package/dist/queues/index.mjs +106 -5
- package/dist/tasks/index.cjs +100 -4
- package/dist/tasks/index.mjs +100 -4
- package/dist/traces/index.cjs +218 -4
- package/dist/traces/index.d.ts +357 -22
- package/dist/traces/index.mjs +219 -5
- package/package.json +14 -4
package/dist/queues/index.mjs
CHANGED
|
@@ -1117,6 +1117,97 @@ function addPrefixToKeys(obj, prefix, keys) {
|
|
|
1117
1117
|
}
|
|
1118
1118
|
return result;
|
|
1119
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
|
+
}
|
|
1120
1211
|
|
|
1121
1212
|
/**
|
|
1122
1213
|
* Constants used throughout the pagination system
|
|
@@ -1880,9 +1971,12 @@ class FolderScopedService extends BaseService {
|
|
|
1880
1971
|
* @param name - Resource name to search for
|
|
1881
1972
|
* @param options - Folder scoping (`folderId` / `folderKey` / `folderPath`) + OData query options (`expand`, `select`)
|
|
1882
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`)
|
|
1883
1977
|
* @throws ValidationError when inputs are malformed; NotFoundError when no match
|
|
1884
1978
|
*/
|
|
1885
|
-
async getByNameLookup(resourceType, endpoint, name, options, transform) {
|
|
1979
|
+
async getByNameLookup(resourceType, endpoint, name, options, transform, responseFieldMap) {
|
|
1886
1980
|
const validatedName = validateName(resourceType, name);
|
|
1887
1981
|
const { folderId, folderKey, folderPath, ...queryOptions } = options;
|
|
1888
1982
|
const headers = resolveFolderHeaders({
|
|
@@ -1892,8 +1986,11 @@ class FolderScopedService extends BaseService {
|
|
|
1892
1986
|
resourceType: `${resourceType}.getByName`,
|
|
1893
1987
|
fallbackFolderKey: this.config.folderKey,
|
|
1894
1988
|
});
|
|
1989
|
+
const apiFieldOptions = responseFieldMap
|
|
1990
|
+
? transformOptions(queryOptions, responseFieldMap)
|
|
1991
|
+
: queryOptions;
|
|
1895
1992
|
const apiOptions = {
|
|
1896
|
-
...addPrefixToKeys(
|
|
1993
|
+
...addPrefixToKeys(apiFieldOptions, ODATA_PREFIX, Object.keys(apiFieldOptions)),
|
|
1897
1994
|
'$filter': `Name eq '${validatedName.replace(SINGLE_QUOTE_RE, "''")}'`,
|
|
1898
1995
|
'$top': '1',
|
|
1899
1996
|
};
|
|
@@ -2030,6 +2127,10 @@ class QueueService extends FolderScopedService {
|
|
|
2030
2127
|
async getAll(options) {
|
|
2031
2128
|
// Transformation function for queues
|
|
2032
2129
|
const transformQueueResponse = (queue) => transformData(pascalToCamelCaseKeys(queue), QueueMap);
|
|
2130
|
+
// Rewrite renamed SDK field names → API names inside OData strings
|
|
2131
|
+
// before delegating, mirroring the transformRequest pattern used for
|
|
2132
|
+
// request bodies.
|
|
2133
|
+
const apiOptions = options ? transformOptions(options, QueueMap) : options;
|
|
2033
2134
|
return PaginationHelpers.getAll({
|
|
2034
2135
|
serviceAccess: this.createPaginationServiceAccess(),
|
|
2035
2136
|
getEndpoint: (folderId) => folderId ? QUEUE_ENDPOINTS.GET_BY_FOLDER : QUEUE_ENDPOINTS.GET_ALL,
|
|
@@ -2045,7 +2146,7 @@ class QueueService extends FolderScopedService {
|
|
|
2045
2146
|
countParam: ODATA_OFFSET_PARAMS.COUNT_PARAM
|
|
2046
2147
|
}
|
|
2047
2148
|
}
|
|
2048
|
-
},
|
|
2149
|
+
}, apiOptions);
|
|
2049
2150
|
}
|
|
2050
2151
|
/**
|
|
2051
2152
|
* Gets a single queue by ID
|
|
@@ -2066,8 +2167,8 @@ class QueueService extends FolderScopedService {
|
|
|
2066
2167
|
*/
|
|
2067
2168
|
async getById(id, folderId, options = {}) {
|
|
2068
2169
|
const headers = createHeaders({ [FOLDER_ID]: folderId });
|
|
2069
|
-
const
|
|
2070
|
-
const apiOptions = addPrefixToKeys(
|
|
2170
|
+
const apiFieldOptions = transformOptions(options, QueueMap);
|
|
2171
|
+
const apiOptions = addPrefixToKeys(apiFieldOptions, ODATA_PREFIX, Object.keys(apiFieldOptions));
|
|
2071
2172
|
const response = await this.get(QUEUE_ENDPOINTS.GET_BY_ID(id), {
|
|
2072
2173
|
headers,
|
|
2073
2174
|
params: apiOptions
|
package/dist/tasks/index.cjs
CHANGED
|
@@ -983,6 +983,97 @@ function addPrefixToKeys(obj, prefix, keys) {
|
|
|
983
983
|
}
|
|
984
984
|
return result;
|
|
985
985
|
}
|
|
986
|
+
/**
|
|
987
|
+
* Creates a new map with the keys and values reversed
|
|
988
|
+
* @param map The original map to reverse
|
|
989
|
+
* @returns A new map with keys and values swapped
|
|
990
|
+
*
|
|
991
|
+
* @example
|
|
992
|
+
* ```typescript
|
|
993
|
+
* const original = { key1: 'value1', key2: 'value2' };
|
|
994
|
+
* const reversed = reverseMap(original);
|
|
995
|
+
* // reversed = { value1: 'key1', value2: 'key2' }
|
|
996
|
+
* ```
|
|
997
|
+
*/
|
|
998
|
+
function reverseMap(map) {
|
|
999
|
+
return Object.entries(map).reduce((acc, [key, value]) => {
|
|
1000
|
+
acc[value] = key;
|
|
1001
|
+
return acc;
|
|
1002
|
+
}, {});
|
|
1003
|
+
}
|
|
1004
|
+
/**
|
|
1005
|
+
* OData query-string keys whose values may contain field identifiers that
|
|
1006
|
+
* need rewriting from SDK names → API names.
|
|
1007
|
+
*/
|
|
1008
|
+
const ODATA_FIELD_PARAM_KEYS = ['filter', 'orderby', 'select', 'expand'];
|
|
1009
|
+
/**
|
|
1010
|
+
* Matches one token at a time in an OData expression:
|
|
1011
|
+
* 1. A single-quoted string literal, allowing the `''` escape sequence —
|
|
1012
|
+
* consumed atomically so identifiers inside the literal can't match.
|
|
1013
|
+
* 2. An OData identifier (`[A-Za-z_][A-Za-z0-9_]*`).
|
|
1014
|
+
* Anything else (whitespace, operators, parens, commas) is left alone by
|
|
1015
|
+
* `String.prototype.replace`, which only substitutes matched substrings.
|
|
1016
|
+
*/
|
|
1017
|
+
const ODATA_TOKEN_RE = /'(?:[^']|'')*'|[A-Za-z_][A-Za-z0-9_]*/g;
|
|
1018
|
+
/**
|
|
1019
|
+
* Rewrites SDK field identifiers to API field identifiers inside an OData
|
|
1020
|
+
* expression string (`$filter`, `$orderby`, `$select`, `$expand`).
|
|
1021
|
+
*
|
|
1022
|
+
* Field maps (e.g. `JobMap`) rename API fields → SDK fields on responses, so
|
|
1023
|
+
* SDK consumers see the renamed names. Without this rewrite, the same name
|
|
1024
|
+
* in a `filter` string would be forwarded verbatim and the API (which still
|
|
1025
|
+
* uses the original name) would reject it.
|
|
1026
|
+
*
|
|
1027
|
+
* Quoted string literals (with the OData `''` escape) are preserved exactly:
|
|
1028
|
+
* the token regex consumes them whole, so identifiers inside literals never
|
|
1029
|
+
* match. Identifier tokens are looked up in the reversed field map.
|
|
1030
|
+
*
|
|
1031
|
+
* @example
|
|
1032
|
+
* ```typescript
|
|
1033
|
+
* const requestMap = { processName: 'releaseName' };
|
|
1034
|
+
* rewriteODataIdentifiers("processName eq 'processName'", requestMap);
|
|
1035
|
+
* // "releaseName eq 'processName'" — identifier rewritten, literal preserved
|
|
1036
|
+
* ```
|
|
1037
|
+
*/
|
|
1038
|
+
function rewriteODataIdentifiers(expression, requestMap) {
|
|
1039
|
+
if (!expression)
|
|
1040
|
+
return expression;
|
|
1041
|
+
return expression.replace(ODATA_TOKEN_RE, (match) => match.startsWith("'") ? match : (requestMap[match] ?? match));
|
|
1042
|
+
}
|
|
1043
|
+
/**
|
|
1044
|
+
* Symmetric counterpart of {@link transformRequest} for OData query options:
|
|
1045
|
+
* rewrites SDK field identifiers inside the recognized OData string params
|
|
1046
|
+
* (`filter`, `orderby`, `select`, `expand`) to their API names using the
|
|
1047
|
+
* reversed form of a response field map. Returns a shallow copy with the
|
|
1048
|
+
* relevant values rewritten; other keys pass through unchanged.
|
|
1049
|
+
*
|
|
1050
|
+
* Use at the OData edge so SDK consumers can refer to renamed fields by
|
|
1051
|
+
* their SDK name throughout — for reading the response and for filtering /
|
|
1052
|
+
* sorting / projecting / expanding.
|
|
1053
|
+
*
|
|
1054
|
+
* @param options The OData query options as authored with SDK field names
|
|
1055
|
+
* @param responseMap The response field map (API → SDK); reversed internally
|
|
1056
|
+
*
|
|
1057
|
+
* @example
|
|
1058
|
+
* ```typescript
|
|
1059
|
+
* // JobMap renames releaseName → processName on responses.
|
|
1060
|
+
* transformOptions({ filter: "processName eq 'X'" }, JobMap);
|
|
1061
|
+
* // { filter: "releaseName eq 'X'" }
|
|
1062
|
+
* ```
|
|
1063
|
+
*/
|
|
1064
|
+
function transformOptions(options, responseMap) {
|
|
1065
|
+
const requestMap = reverseMap(responseMap);
|
|
1066
|
+
if (Object.keys(requestMap).length === 0)
|
|
1067
|
+
return options;
|
|
1068
|
+
const result = { ...options };
|
|
1069
|
+
for (const key of ODATA_FIELD_PARAM_KEYS) {
|
|
1070
|
+
const value = result[key];
|
|
1071
|
+
if (typeof value === 'string') {
|
|
1072
|
+
result[key] = rewriteODataIdentifiers(value, requestMap);
|
|
1073
|
+
}
|
|
1074
|
+
}
|
|
1075
|
+
return result;
|
|
1076
|
+
}
|
|
986
1077
|
|
|
987
1078
|
/**
|
|
988
1079
|
* Constants used throughout the pagination system
|
|
@@ -2276,6 +2367,10 @@ class TaskService extends BaseService {
|
|
|
2276
2367
|
const transformedTask = transformData(pascalToCamelCaseKeys(task), TaskMap);
|
|
2277
2368
|
return createTaskWithMethods(applyDataTransforms(transformedTask, { field: 'status', valueMap: TaskStatusMap }), this);
|
|
2278
2369
|
};
|
|
2370
|
+
// Rewrite renamed SDK field names → API names inside OData strings
|
|
2371
|
+
// before delegating, mirroring the transformRequest pattern used for
|
|
2372
|
+
// request bodies.
|
|
2373
|
+
const apiOptions = options ? transformOptions(options, TaskMap) : options;
|
|
2279
2374
|
return PaginationHelpers.getAll({
|
|
2280
2375
|
serviceAccess: this.createPaginationServiceAccess(),
|
|
2281
2376
|
getEndpoint: () => endpoint,
|
|
@@ -2292,7 +2387,7 @@ class TaskService extends BaseService {
|
|
|
2292
2387
|
countParam: ODATA_OFFSET_PARAMS.COUNT_PARAM // OData OFFSET parameter
|
|
2293
2388
|
}
|
|
2294
2389
|
}
|
|
2295
|
-
},
|
|
2390
|
+
}, apiOptions);
|
|
2296
2391
|
}
|
|
2297
2392
|
/**
|
|
2298
2393
|
* Gets a task by ID
|
|
@@ -2328,9 +2423,10 @@ class TaskService extends BaseService {
|
|
|
2328
2423
|
const headers = createHeaders({ [FOLDER_ID]: folderId });
|
|
2329
2424
|
// Add default expand parameters
|
|
2330
2425
|
const modifiedOptions = this.addDefaultExpand(restOptions);
|
|
2331
|
-
//
|
|
2332
|
-
|
|
2333
|
-
const
|
|
2426
|
+
// Rewrite renamed SDK field names → API names inside OData strings,
|
|
2427
|
+
// then prefix all keys for OData.
|
|
2428
|
+
const apiFieldOptions = transformOptions(modifiedOptions, TaskMap);
|
|
2429
|
+
const apiOptions = addPrefixToKeys(apiFieldOptions, ODATA_PREFIX, Object.keys(apiFieldOptions));
|
|
2334
2430
|
const response = await this.get(TASK_ENDPOINTS.GET_BY_ID(id), {
|
|
2335
2431
|
params: apiOptions,
|
|
2336
2432
|
headers
|
package/dist/tasks/index.mjs
CHANGED
|
@@ -981,6 +981,97 @@ function addPrefixToKeys(obj, prefix, keys) {
|
|
|
981
981
|
}
|
|
982
982
|
return result;
|
|
983
983
|
}
|
|
984
|
+
/**
|
|
985
|
+
* Creates a new map with the keys and values reversed
|
|
986
|
+
* @param map The original map to reverse
|
|
987
|
+
* @returns A new map with keys and values swapped
|
|
988
|
+
*
|
|
989
|
+
* @example
|
|
990
|
+
* ```typescript
|
|
991
|
+
* const original = { key1: 'value1', key2: 'value2' };
|
|
992
|
+
* const reversed = reverseMap(original);
|
|
993
|
+
* // reversed = { value1: 'key1', value2: 'key2' }
|
|
994
|
+
* ```
|
|
995
|
+
*/
|
|
996
|
+
function reverseMap(map) {
|
|
997
|
+
return Object.entries(map).reduce((acc, [key, value]) => {
|
|
998
|
+
acc[value] = key;
|
|
999
|
+
return acc;
|
|
1000
|
+
}, {});
|
|
1001
|
+
}
|
|
1002
|
+
/**
|
|
1003
|
+
* OData query-string keys whose values may contain field identifiers that
|
|
1004
|
+
* need rewriting from SDK names → API names.
|
|
1005
|
+
*/
|
|
1006
|
+
const ODATA_FIELD_PARAM_KEYS = ['filter', 'orderby', 'select', 'expand'];
|
|
1007
|
+
/**
|
|
1008
|
+
* Matches one token at a time in an OData expression:
|
|
1009
|
+
* 1. A single-quoted string literal, allowing the `''` escape sequence —
|
|
1010
|
+
* consumed atomically so identifiers inside the literal can't match.
|
|
1011
|
+
* 2. An OData identifier (`[A-Za-z_][A-Za-z0-9_]*`).
|
|
1012
|
+
* Anything else (whitespace, operators, parens, commas) is left alone by
|
|
1013
|
+
* `String.prototype.replace`, which only substitutes matched substrings.
|
|
1014
|
+
*/
|
|
1015
|
+
const ODATA_TOKEN_RE = /'(?:[^']|'')*'|[A-Za-z_][A-Za-z0-9_]*/g;
|
|
1016
|
+
/**
|
|
1017
|
+
* Rewrites SDK field identifiers to API field identifiers inside an OData
|
|
1018
|
+
* expression string (`$filter`, `$orderby`, `$select`, `$expand`).
|
|
1019
|
+
*
|
|
1020
|
+
* Field maps (e.g. `JobMap`) rename API fields → SDK fields on responses, so
|
|
1021
|
+
* SDK consumers see the renamed names. Without this rewrite, the same name
|
|
1022
|
+
* in a `filter` string would be forwarded verbatim and the API (which still
|
|
1023
|
+
* uses the original name) would reject it.
|
|
1024
|
+
*
|
|
1025
|
+
* Quoted string literals (with the OData `''` escape) are preserved exactly:
|
|
1026
|
+
* the token regex consumes them whole, so identifiers inside literals never
|
|
1027
|
+
* match. Identifier tokens are looked up in the reversed field map.
|
|
1028
|
+
*
|
|
1029
|
+
* @example
|
|
1030
|
+
* ```typescript
|
|
1031
|
+
* const requestMap = { processName: 'releaseName' };
|
|
1032
|
+
* rewriteODataIdentifiers("processName eq 'processName'", requestMap);
|
|
1033
|
+
* // "releaseName eq 'processName'" — identifier rewritten, literal preserved
|
|
1034
|
+
* ```
|
|
1035
|
+
*/
|
|
1036
|
+
function rewriteODataIdentifiers(expression, requestMap) {
|
|
1037
|
+
if (!expression)
|
|
1038
|
+
return expression;
|
|
1039
|
+
return expression.replace(ODATA_TOKEN_RE, (match) => match.startsWith("'") ? match : (requestMap[match] ?? match));
|
|
1040
|
+
}
|
|
1041
|
+
/**
|
|
1042
|
+
* Symmetric counterpart of {@link transformRequest} for OData query options:
|
|
1043
|
+
* rewrites SDK field identifiers inside the recognized OData string params
|
|
1044
|
+
* (`filter`, `orderby`, `select`, `expand`) to their API names using the
|
|
1045
|
+
* reversed form of a response field map. Returns a shallow copy with the
|
|
1046
|
+
* relevant values rewritten; other keys pass through unchanged.
|
|
1047
|
+
*
|
|
1048
|
+
* Use at the OData edge so SDK consumers can refer to renamed fields by
|
|
1049
|
+
* their SDK name throughout — for reading the response and for filtering /
|
|
1050
|
+
* sorting / projecting / expanding.
|
|
1051
|
+
*
|
|
1052
|
+
* @param options The OData query options as authored with SDK field names
|
|
1053
|
+
* @param responseMap The response field map (API → SDK); reversed internally
|
|
1054
|
+
*
|
|
1055
|
+
* @example
|
|
1056
|
+
* ```typescript
|
|
1057
|
+
* // JobMap renames releaseName → processName on responses.
|
|
1058
|
+
* transformOptions({ filter: "processName eq 'X'" }, JobMap);
|
|
1059
|
+
* // { filter: "releaseName eq 'X'" }
|
|
1060
|
+
* ```
|
|
1061
|
+
*/
|
|
1062
|
+
function transformOptions(options, responseMap) {
|
|
1063
|
+
const requestMap = reverseMap(responseMap);
|
|
1064
|
+
if (Object.keys(requestMap).length === 0)
|
|
1065
|
+
return options;
|
|
1066
|
+
const result = { ...options };
|
|
1067
|
+
for (const key of ODATA_FIELD_PARAM_KEYS) {
|
|
1068
|
+
const value = result[key];
|
|
1069
|
+
if (typeof value === 'string') {
|
|
1070
|
+
result[key] = rewriteODataIdentifiers(value, requestMap);
|
|
1071
|
+
}
|
|
1072
|
+
}
|
|
1073
|
+
return result;
|
|
1074
|
+
}
|
|
984
1075
|
|
|
985
1076
|
/**
|
|
986
1077
|
* Constants used throughout the pagination system
|
|
@@ -2274,6 +2365,10 @@ class TaskService extends BaseService {
|
|
|
2274
2365
|
const transformedTask = transformData(pascalToCamelCaseKeys(task), TaskMap);
|
|
2275
2366
|
return createTaskWithMethods(applyDataTransforms(transformedTask, { field: 'status', valueMap: TaskStatusMap }), this);
|
|
2276
2367
|
};
|
|
2368
|
+
// Rewrite renamed SDK field names → API names inside OData strings
|
|
2369
|
+
// before delegating, mirroring the transformRequest pattern used for
|
|
2370
|
+
// request bodies.
|
|
2371
|
+
const apiOptions = options ? transformOptions(options, TaskMap) : options;
|
|
2277
2372
|
return PaginationHelpers.getAll({
|
|
2278
2373
|
serviceAccess: this.createPaginationServiceAccess(),
|
|
2279
2374
|
getEndpoint: () => endpoint,
|
|
@@ -2290,7 +2385,7 @@ class TaskService extends BaseService {
|
|
|
2290
2385
|
countParam: ODATA_OFFSET_PARAMS.COUNT_PARAM // OData OFFSET parameter
|
|
2291
2386
|
}
|
|
2292
2387
|
}
|
|
2293
|
-
},
|
|
2388
|
+
}, apiOptions);
|
|
2294
2389
|
}
|
|
2295
2390
|
/**
|
|
2296
2391
|
* Gets a task by ID
|
|
@@ -2326,9 +2421,10 @@ class TaskService extends BaseService {
|
|
|
2326
2421
|
const headers = createHeaders({ [FOLDER_ID]: folderId });
|
|
2327
2422
|
// Add default expand parameters
|
|
2328
2423
|
const modifiedOptions = this.addDefaultExpand(restOptions);
|
|
2329
|
-
//
|
|
2330
|
-
|
|
2331
|
-
const
|
|
2424
|
+
// Rewrite renamed SDK field names → API names inside OData strings,
|
|
2425
|
+
// then prefix all keys for OData.
|
|
2426
|
+
const apiFieldOptions = transformOptions(modifiedOptions, TaskMap);
|
|
2427
|
+
const apiOptions = addPrefixToKeys(apiFieldOptions, ODATA_PREFIX, Object.keys(apiFieldOptions));
|
|
2332
2428
|
const response = await this.get(TASK_ENDPOINTS.GET_BY_ID(id), {
|
|
2333
2429
|
params: apiOptions,
|
|
2334
2430
|
headers
|