@uipath/uipath-typescript 1.4.1 → 1.5.0
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/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 +25 -9
- package/dist/assets/index.mjs +25 -9
- package/dist/attachments/index.cjs +25 -9
- package/dist/attachments/index.mjs +25 -9
- package/dist/buckets/index.cjs +25 -9
- package/dist/buckets/index.mjs +25 -9
- package/dist/cases/index.cjs +621 -524
- package/dist/cases/index.d.ts +186 -43
- package/dist/cases/index.mjs +621 -524
- package/dist/conversational-agent/index.cjs +25 -9
- package/dist/conversational-agent/index.mjs +25 -9
- package/dist/core/index.cjs +1 -1
- package/dist/core/index.mjs +1 -1
- package/dist/document-understanding/index.cjs +84 -84
- package/dist/document-understanding/index.d.ts +2 -1
- package/dist/document-understanding/index.mjs +1 -1
- package/dist/entities/index.cjs +25 -9
- package/dist/entities/index.mjs +25 -9
- package/dist/feedback/index.cjs +25 -9
- package/dist/feedback/index.mjs +25 -9
- package/dist/index.cjs +332 -62
- package/dist/index.d.ts +827 -89
- package/dist/index.mjs +333 -63
- package/dist/index.umd.js +332 -62
- package/dist/jobs/index.cjs +129 -14
- package/dist/jobs/index.d.ts +10 -5
- package/dist/jobs/index.mjs +129 -14
- package/dist/maestro-processes/index.cjs +198 -100
- package/dist/maestro-processes/index.d.ts +188 -43
- package/dist/maestro-processes/index.mjs +198 -100
- package/dist/processes/index.cjs +25 -9
- package/dist/processes/index.d.ts +6 -1
- package/dist/processes/index.mjs +25 -9
- package/dist/queues/index.cjs +25 -9
- package/dist/queues/index.mjs +25 -9
- package/dist/tasks/index.cjs +25 -9
- package/dist/tasks/index.d.ts +4 -1
- package/dist/tasks/index.mjs +25 -9
- package/dist/traces/index.cjs +2 -2
- package/dist/traces/index.d.ts +3 -3
- package/dist/traces/index.mjs +2 -2
- package/package.json +1 -1
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
|
|
@@ -2294,8 +2401,9 @@ class JobService extends FolderScopedService {
|
|
|
2294
2401
|
* const folderJobs = await jobs.getAll({ folderId: <folderId> });
|
|
2295
2402
|
*
|
|
2296
2403
|
* // With filtering
|
|
2297
|
-
* const
|
|
2298
|
-
* filter: "
|
|
2404
|
+
* const recentInvoiceJobs = await jobs.getAll({
|
|
2405
|
+
* filter: "processName eq 'InvoiceBot'",
|
|
2406
|
+
* orderby: 'createdTime desc',
|
|
2299
2407
|
* });
|
|
2300
2408
|
*
|
|
2301
2409
|
* // First page with pagination
|
|
@@ -2318,6 +2426,10 @@ class JobService extends FolderScopedService {
|
|
|
2318
2426
|
const rawJob = transformData(pascalToCamelCaseKeys(job), JobMap);
|
|
2319
2427
|
return createJobWithMethods(rawJob, this);
|
|
2320
2428
|
};
|
|
2429
|
+
// Rewrite renamed SDK field names → API names inside OData strings
|
|
2430
|
+
// before delegating, mirroring the transformRequest pattern used for
|
|
2431
|
+
// request bodies.
|
|
2432
|
+
const apiOptions = options ? transformOptions(options, JobMap) : options;
|
|
2321
2433
|
return PaginationHelpers.getAll({
|
|
2322
2434
|
serviceAccess: this.createPaginationServiceAccess(),
|
|
2323
2435
|
getEndpoint: () => JOB_ENDPOINTS.GET_ALL,
|
|
@@ -2333,7 +2445,7 @@ class JobService extends FolderScopedService {
|
|
|
2333
2445
|
countParam: ODATA_OFFSET_PARAMS.COUNT_PARAM,
|
|
2334
2446
|
},
|
|
2335
2447
|
},
|
|
2336
|
-
},
|
|
2448
|
+
}, apiOptions);
|
|
2337
2449
|
}
|
|
2338
2450
|
/**
|
|
2339
2451
|
* Gets a job by its unique key (GUID).
|
|
@@ -2370,8 +2482,8 @@ class JobService extends FolderScopedService {
|
|
|
2370
2482
|
throw new ValidationError({ message: 'folderId is required for getById' });
|
|
2371
2483
|
}
|
|
2372
2484
|
const headers = createHeaders({ [FOLDER_ID]: folderId });
|
|
2373
|
-
const
|
|
2374
|
-
const apiOptions =
|
|
2485
|
+
const apiFieldOptions = options ? transformOptions(options, JobMap) : {};
|
|
2486
|
+
const apiOptions = addPrefixToKeys(apiFieldOptions, ODATA_PREFIX, Object.keys(apiFieldOptions));
|
|
2375
2487
|
const response = await this.get(JOB_ENDPOINTS.GET_BY_KEY(id), {
|
|
2376
2488
|
params: apiOptions,
|
|
2377
2489
|
headers,
|
|
@@ -2674,6 +2786,9 @@ exports.JobState = void 0;
|
|
|
2674
2786
|
JobState["Stopped"] = "Stopped";
|
|
2675
2787
|
JobState["Suspended"] = "Suspended";
|
|
2676
2788
|
JobState["Resumed"] = "Resumed";
|
|
2789
|
+
JobState["Cancelled"] = "Cancelled";
|
|
2790
|
+
/** Server-side fallback for an unrecognized or missing job state. */
|
|
2791
|
+
JobState["Unknown"] = "Unknown";
|
|
2677
2792
|
})(exports.JobState || (exports.JobState = {}));
|
|
2678
2793
|
|
|
2679
2794
|
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;
|
|
@@ -741,8 +744,9 @@ interface JobServiceModel {
|
|
|
741
744
|
* const folderJobs = await jobs.getAll({ folderId: <folderId> });
|
|
742
745
|
*
|
|
743
746
|
* // With filtering
|
|
744
|
-
* const
|
|
745
|
-
* filter: "
|
|
747
|
+
* const recentInvoiceJobs = await jobs.getAll({
|
|
748
|
+
* filter: "processName eq 'InvoiceBot'",
|
|
749
|
+
* orderby: 'createdTime desc',
|
|
746
750
|
* });
|
|
747
751
|
*
|
|
748
752
|
* // First page with pagination
|
|
@@ -1001,8 +1005,9 @@ declare class JobService extends FolderScopedService implements JobServiceModel
|
|
|
1001
1005
|
* const folderJobs = await jobs.getAll({ folderId: <folderId> });
|
|
1002
1006
|
*
|
|
1003
1007
|
* // With filtering
|
|
1004
|
-
* const
|
|
1005
|
-
* filter: "
|
|
1008
|
+
* const recentInvoiceJobs = await jobs.getAll({
|
|
1009
|
+
* filter: "processName eq 'InvoiceBot'",
|
|
1010
|
+
* orderby: 'createdTime desc',
|
|
1006
1011
|
* });
|
|
1007
1012
|
*
|
|
1008
1013
|
* // 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
|
|
@@ -2292,8 +2399,9 @@ class JobService extends FolderScopedService {
|
|
|
2292
2399
|
* const folderJobs = await jobs.getAll({ folderId: <folderId> });
|
|
2293
2400
|
*
|
|
2294
2401
|
* // With filtering
|
|
2295
|
-
* const
|
|
2296
|
-
* filter: "
|
|
2402
|
+
* const recentInvoiceJobs = await jobs.getAll({
|
|
2403
|
+
* filter: "processName eq 'InvoiceBot'",
|
|
2404
|
+
* orderby: 'createdTime desc',
|
|
2297
2405
|
* });
|
|
2298
2406
|
*
|
|
2299
2407
|
* // First page with pagination
|
|
@@ -2316,6 +2424,10 @@ class JobService extends FolderScopedService {
|
|
|
2316
2424
|
const rawJob = transformData(pascalToCamelCaseKeys(job), JobMap);
|
|
2317
2425
|
return createJobWithMethods(rawJob, this);
|
|
2318
2426
|
};
|
|
2427
|
+
// Rewrite renamed SDK field names → API names inside OData strings
|
|
2428
|
+
// before delegating, mirroring the transformRequest pattern used for
|
|
2429
|
+
// request bodies.
|
|
2430
|
+
const apiOptions = options ? transformOptions(options, JobMap) : options;
|
|
2319
2431
|
return PaginationHelpers.getAll({
|
|
2320
2432
|
serviceAccess: this.createPaginationServiceAccess(),
|
|
2321
2433
|
getEndpoint: () => JOB_ENDPOINTS.GET_ALL,
|
|
@@ -2331,7 +2443,7 @@ class JobService extends FolderScopedService {
|
|
|
2331
2443
|
countParam: ODATA_OFFSET_PARAMS.COUNT_PARAM,
|
|
2332
2444
|
},
|
|
2333
2445
|
},
|
|
2334
|
-
},
|
|
2446
|
+
}, apiOptions);
|
|
2335
2447
|
}
|
|
2336
2448
|
/**
|
|
2337
2449
|
* Gets a job by its unique key (GUID).
|
|
@@ -2368,8 +2480,8 @@ class JobService extends FolderScopedService {
|
|
|
2368
2480
|
throw new ValidationError({ message: 'folderId is required for getById' });
|
|
2369
2481
|
}
|
|
2370
2482
|
const headers = createHeaders({ [FOLDER_ID]: folderId });
|
|
2371
|
-
const
|
|
2372
|
-
const apiOptions =
|
|
2483
|
+
const apiFieldOptions = options ? transformOptions(options, JobMap) : {};
|
|
2484
|
+
const apiOptions = addPrefixToKeys(apiFieldOptions, ODATA_PREFIX, Object.keys(apiFieldOptions));
|
|
2373
2485
|
const response = await this.get(JOB_ENDPOINTS.GET_BY_KEY(id), {
|
|
2374
2486
|
params: apiOptions,
|
|
2375
2487
|
headers,
|
|
@@ -2672,6 +2784,9 @@ var JobState;
|
|
|
2672
2784
|
JobState["Stopped"] = "Stopped";
|
|
2673
2785
|
JobState["Suspended"] = "Suspended";
|
|
2674
2786
|
JobState["Resumed"] = "Resumed";
|
|
2787
|
+
JobState["Cancelled"] = "Cancelled";
|
|
2788
|
+
/** Server-side fallback for an unrecognized or missing job state. */
|
|
2789
|
+
JobState["Unknown"] = "Unknown";
|
|
2675
2790
|
})(JobState || (JobState = {}));
|
|
2676
2791
|
|
|
2677
2792
|
export { JobService, JobState, JobSubState, JobService as Jobs, ServerlessJobType, StopStrategy, createJobWithMethods };
|