@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/processes/index.cjs
CHANGED
|
@@ -1182,6 +1182,79 @@ function transformRequest(data, responseMap) {
|
|
|
1182
1182
|
}
|
|
1183
1183
|
return result;
|
|
1184
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
|
+
}
|
|
1185
1258
|
|
|
1186
1259
|
/**
|
|
1187
1260
|
* Constants used throughout the pagination system
|
|
@@ -1945,9 +2018,12 @@ class FolderScopedService extends BaseService {
|
|
|
1945
2018
|
* @param name - Resource name to search for
|
|
1946
2019
|
* @param options - Folder scoping (`folderId` / `folderKey` / `folderPath`) + OData query options (`expand`, `select`)
|
|
1947
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`)
|
|
1948
2024
|
* @throws ValidationError when inputs are malformed; NotFoundError when no match
|
|
1949
2025
|
*/
|
|
1950
|
-
async getByNameLookup(resourceType, endpoint, name, options, transform) {
|
|
2026
|
+
async getByNameLookup(resourceType, endpoint, name, options, transform, responseFieldMap) {
|
|
1951
2027
|
const validatedName = validateName(resourceType, name);
|
|
1952
2028
|
const { folderId, folderKey, folderPath, ...queryOptions } = options;
|
|
1953
2029
|
const headers = resolveFolderHeaders({
|
|
@@ -1957,8 +2033,11 @@ class FolderScopedService extends BaseService {
|
|
|
1957
2033
|
resourceType: `${resourceType}.getByName`,
|
|
1958
2034
|
fallbackFolderKey: this.config.folderKey,
|
|
1959
2035
|
});
|
|
2036
|
+
const apiFieldOptions = responseFieldMap
|
|
2037
|
+
? transformOptions(queryOptions, responseFieldMap)
|
|
2038
|
+
: queryOptions;
|
|
1960
2039
|
const apiOptions = {
|
|
1961
|
-
...addPrefixToKeys(
|
|
2040
|
+
...addPrefixToKeys(apiFieldOptions, ODATA_PREFIX, Object.keys(apiFieldOptions)),
|
|
1962
2041
|
'$filter': `Name eq '${validatedName.replace(SINGLE_QUOTE_RE, "''")}'`,
|
|
1963
2042
|
'$top': '1',
|
|
1964
2043
|
};
|
|
@@ -2103,6 +2182,10 @@ class ProcessService extends FolderScopedService {
|
|
|
2103
2182
|
async getAll(options) {
|
|
2104
2183
|
// Transformation function for processes
|
|
2105
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;
|
|
2106
2189
|
return PaginationHelpers.getAll({
|
|
2107
2190
|
serviceAccess: this.createPaginationServiceAccess(),
|
|
2108
2191
|
getEndpoint: () => PROCESS_ENDPOINTS.GET_ALL,
|
|
@@ -2118,7 +2201,7 @@ class ProcessService extends FolderScopedService {
|
|
|
2118
2201
|
countParam: ODATA_OFFSET_PARAMS.COUNT_PARAM
|
|
2119
2202
|
}
|
|
2120
2203
|
}
|
|
2121
|
-
},
|
|
2204
|
+
}, apiOptions);
|
|
2122
2205
|
}
|
|
2123
2206
|
async start(request, optionsOrFolderId, legacyOptions) {
|
|
2124
2207
|
// Normalize the two overload forms into a single internal shape.
|
|
@@ -2152,9 +2235,10 @@ class ProcessService extends FolderScopedService {
|
|
|
2152
2235
|
const requestBody = {
|
|
2153
2236
|
startInfo: apiRequest
|
|
2154
2237
|
};
|
|
2155
|
-
//
|
|
2156
|
-
|
|
2157
|
-
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));
|
|
2158
2242
|
const response = await this.post(PROCESS_ENDPOINTS.START_PROCESS, requestBody, {
|
|
2159
2243
|
params: apiOptions,
|
|
2160
2244
|
headers
|
|
@@ -2182,8 +2266,8 @@ class ProcessService extends FolderScopedService {
|
|
|
2182
2266
|
*/
|
|
2183
2267
|
async getById(id, folderId, options = {}) {
|
|
2184
2268
|
const headers = createHeaders({ [FOLDER_ID]: folderId });
|
|
2185
|
-
const
|
|
2186
|
-
const apiOptions = addPrefixToKeys(
|
|
2269
|
+
const apiFieldOptions = transformOptions(options, ProcessMap);
|
|
2270
|
+
const apiOptions = addPrefixToKeys(apiFieldOptions, ODATA_PREFIX, Object.keys(apiFieldOptions));
|
|
2187
2271
|
const response = await this.get(PROCESS_ENDPOINTS.GET_BY_ID(id), {
|
|
2188
2272
|
headers,
|
|
2189
2273
|
params: apiOptions
|
|
@@ -2218,7 +2302,7 @@ class ProcessService extends FolderScopedService {
|
|
|
2218
2302
|
* ```
|
|
2219
2303
|
*/
|
|
2220
2304
|
async getByName(name, options = {}) {
|
|
2221
|
-
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);
|
|
2222
2306
|
}
|
|
2223
2307
|
}
|
|
2224
2308
|
__decorate([
|
|
@@ -343,6 +343,14 @@ interface FolderScopedOptions extends BaseOptions {
|
|
|
343
343
|
folderPath?: string;
|
|
344
344
|
}
|
|
345
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
|
+
|
|
346
354
|
/**
|
|
347
355
|
* Base service for services that need folder-specific functionality.
|
|
348
356
|
*
|
|
@@ -384,9 +392,12 @@ declare class FolderScopedService extends BaseService {
|
|
|
384
392
|
* @param name - Resource name to search for
|
|
385
393
|
* @param options - Folder scoping (`folderId` / `folderKey` / `folderPath`) + OData query options (`expand`, `select`)
|
|
386
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`)
|
|
387
398
|
* @throws ValidationError when inputs are malformed; NotFoundError when no match
|
|
388
399
|
*/
|
|
389
|
-
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>;
|
|
390
401
|
}
|
|
391
402
|
|
|
392
403
|
/**
|
package/dist/processes/index.mjs
CHANGED
|
@@ -1180,6 +1180,79 @@ function transformRequest(data, responseMap) {
|
|
|
1180
1180
|
}
|
|
1181
1181
|
return result;
|
|
1182
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
|
+
}
|
|
1183
1256
|
|
|
1184
1257
|
/**
|
|
1185
1258
|
* Constants used throughout the pagination system
|
|
@@ -1943,9 +2016,12 @@ class FolderScopedService extends BaseService {
|
|
|
1943
2016
|
* @param name - Resource name to search for
|
|
1944
2017
|
* @param options - Folder scoping (`folderId` / `folderKey` / `folderPath`) + OData query options (`expand`, `select`)
|
|
1945
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`)
|
|
1946
2022
|
* @throws ValidationError when inputs are malformed; NotFoundError when no match
|
|
1947
2023
|
*/
|
|
1948
|
-
async getByNameLookup(resourceType, endpoint, name, options, transform) {
|
|
2024
|
+
async getByNameLookup(resourceType, endpoint, name, options, transform, responseFieldMap) {
|
|
1949
2025
|
const validatedName = validateName(resourceType, name);
|
|
1950
2026
|
const { folderId, folderKey, folderPath, ...queryOptions } = options;
|
|
1951
2027
|
const headers = resolveFolderHeaders({
|
|
@@ -1955,8 +2031,11 @@ class FolderScopedService extends BaseService {
|
|
|
1955
2031
|
resourceType: `${resourceType}.getByName`,
|
|
1956
2032
|
fallbackFolderKey: this.config.folderKey,
|
|
1957
2033
|
});
|
|
2034
|
+
const apiFieldOptions = responseFieldMap
|
|
2035
|
+
? transformOptions(queryOptions, responseFieldMap)
|
|
2036
|
+
: queryOptions;
|
|
1958
2037
|
const apiOptions = {
|
|
1959
|
-
...addPrefixToKeys(
|
|
2038
|
+
...addPrefixToKeys(apiFieldOptions, ODATA_PREFIX, Object.keys(apiFieldOptions)),
|
|
1960
2039
|
'$filter': `Name eq '${validatedName.replace(SINGLE_QUOTE_RE, "''")}'`,
|
|
1961
2040
|
'$top': '1',
|
|
1962
2041
|
};
|
|
@@ -2101,6 +2180,10 @@ class ProcessService extends FolderScopedService {
|
|
|
2101
2180
|
async getAll(options) {
|
|
2102
2181
|
// Transformation function for processes
|
|
2103
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;
|
|
2104
2187
|
return PaginationHelpers.getAll({
|
|
2105
2188
|
serviceAccess: this.createPaginationServiceAccess(),
|
|
2106
2189
|
getEndpoint: () => PROCESS_ENDPOINTS.GET_ALL,
|
|
@@ -2116,7 +2199,7 @@ class ProcessService extends FolderScopedService {
|
|
|
2116
2199
|
countParam: ODATA_OFFSET_PARAMS.COUNT_PARAM
|
|
2117
2200
|
}
|
|
2118
2201
|
}
|
|
2119
|
-
},
|
|
2202
|
+
}, apiOptions);
|
|
2120
2203
|
}
|
|
2121
2204
|
async start(request, optionsOrFolderId, legacyOptions) {
|
|
2122
2205
|
// Normalize the two overload forms into a single internal shape.
|
|
@@ -2150,9 +2233,10 @@ class ProcessService extends FolderScopedService {
|
|
|
2150
2233
|
const requestBody = {
|
|
2151
2234
|
startInfo: apiRequest
|
|
2152
2235
|
};
|
|
2153
|
-
//
|
|
2154
|
-
|
|
2155
|
-
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));
|
|
2156
2240
|
const response = await this.post(PROCESS_ENDPOINTS.START_PROCESS, requestBody, {
|
|
2157
2241
|
params: apiOptions,
|
|
2158
2242
|
headers
|
|
@@ -2180,8 +2264,8 @@ class ProcessService extends FolderScopedService {
|
|
|
2180
2264
|
*/
|
|
2181
2265
|
async getById(id, folderId, options = {}) {
|
|
2182
2266
|
const headers = createHeaders({ [FOLDER_ID]: folderId });
|
|
2183
|
-
const
|
|
2184
|
-
const apiOptions = addPrefixToKeys(
|
|
2267
|
+
const apiFieldOptions = transformOptions(options, ProcessMap);
|
|
2268
|
+
const apiOptions = addPrefixToKeys(apiFieldOptions, ODATA_PREFIX, Object.keys(apiFieldOptions));
|
|
2185
2269
|
const response = await this.get(PROCESS_ENDPOINTS.GET_BY_ID(id), {
|
|
2186
2270
|
headers,
|
|
2187
2271
|
params: apiOptions
|
|
@@ -2216,7 +2300,7 @@ class ProcessService extends FolderScopedService {
|
|
|
2216
2300
|
* ```
|
|
2217
2301
|
*/
|
|
2218
2302
|
async getByName(name, options = {}) {
|
|
2219
|
-
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);
|
|
2220
2304
|
}
|
|
2221
2305
|
}
|
|
2222
2306
|
__decorate([
|
package/dist/queues/index.cjs
CHANGED
|
@@ -1119,6 +1119,97 @@ function addPrefixToKeys(obj, prefix, keys) {
|
|
|
1119
1119
|
}
|
|
1120
1120
|
return result;
|
|
1121
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
|
+
}
|
|
1122
1213
|
|
|
1123
1214
|
/**
|
|
1124
1215
|
* Constants used throughout the pagination system
|
|
@@ -1882,9 +1973,12 @@ class FolderScopedService extends BaseService {
|
|
|
1882
1973
|
* @param name - Resource name to search for
|
|
1883
1974
|
* @param options - Folder scoping (`folderId` / `folderKey` / `folderPath`) + OData query options (`expand`, `select`)
|
|
1884
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`)
|
|
1885
1979
|
* @throws ValidationError when inputs are malformed; NotFoundError when no match
|
|
1886
1980
|
*/
|
|
1887
|
-
async getByNameLookup(resourceType, endpoint, name, options, transform) {
|
|
1981
|
+
async getByNameLookup(resourceType, endpoint, name, options, transform, responseFieldMap) {
|
|
1888
1982
|
const validatedName = validateName(resourceType, name);
|
|
1889
1983
|
const { folderId, folderKey, folderPath, ...queryOptions } = options;
|
|
1890
1984
|
const headers = resolveFolderHeaders({
|
|
@@ -1894,8 +1988,11 @@ class FolderScopedService extends BaseService {
|
|
|
1894
1988
|
resourceType: `${resourceType}.getByName`,
|
|
1895
1989
|
fallbackFolderKey: this.config.folderKey,
|
|
1896
1990
|
});
|
|
1991
|
+
const apiFieldOptions = responseFieldMap
|
|
1992
|
+
? transformOptions(queryOptions, responseFieldMap)
|
|
1993
|
+
: queryOptions;
|
|
1897
1994
|
const apiOptions = {
|
|
1898
|
-
...addPrefixToKeys(
|
|
1995
|
+
...addPrefixToKeys(apiFieldOptions, ODATA_PREFIX, Object.keys(apiFieldOptions)),
|
|
1899
1996
|
'$filter': `Name eq '${validatedName.replace(SINGLE_QUOTE_RE, "''")}'`,
|
|
1900
1997
|
'$top': '1',
|
|
1901
1998
|
};
|
|
@@ -2032,6 +2129,10 @@ class QueueService extends FolderScopedService {
|
|
|
2032
2129
|
async getAll(options) {
|
|
2033
2130
|
// Transformation function for queues
|
|
2034
2131
|
const transformQueueResponse = (queue) => transformData(pascalToCamelCaseKeys(queue), QueueMap);
|
|
2132
|
+
// Rewrite renamed SDK field names → API names inside OData strings
|
|
2133
|
+
// before delegating, mirroring the transformRequest pattern used for
|
|
2134
|
+
// request bodies.
|
|
2135
|
+
const apiOptions = options ? transformOptions(options, QueueMap) : options;
|
|
2035
2136
|
return PaginationHelpers.getAll({
|
|
2036
2137
|
serviceAccess: this.createPaginationServiceAccess(),
|
|
2037
2138
|
getEndpoint: (folderId) => folderId ? QUEUE_ENDPOINTS.GET_BY_FOLDER : QUEUE_ENDPOINTS.GET_ALL,
|
|
@@ -2047,7 +2148,7 @@ class QueueService extends FolderScopedService {
|
|
|
2047
2148
|
countParam: ODATA_OFFSET_PARAMS.COUNT_PARAM
|
|
2048
2149
|
}
|
|
2049
2150
|
}
|
|
2050
|
-
},
|
|
2151
|
+
}, apiOptions);
|
|
2051
2152
|
}
|
|
2052
2153
|
/**
|
|
2053
2154
|
* Gets a single queue by ID
|
|
@@ -2068,8 +2169,8 @@ class QueueService extends FolderScopedService {
|
|
|
2068
2169
|
*/
|
|
2069
2170
|
async getById(id, folderId, options = {}) {
|
|
2070
2171
|
const headers = createHeaders({ [FOLDER_ID]: folderId });
|
|
2071
|
-
const
|
|
2072
|
-
const apiOptions = addPrefixToKeys(
|
|
2172
|
+
const apiFieldOptions = transformOptions(options, QueueMap);
|
|
2173
|
+
const apiOptions = addPrefixToKeys(apiFieldOptions, ODATA_PREFIX, Object.keys(apiFieldOptions));
|
|
2073
2174
|
const response = await this.get(QUEUE_ENDPOINTS.GET_BY_ID(id), {
|
|
2074
2175
|
headers,
|
|
2075
2176
|
params: apiOptions
|
package/dist/queues/index.d.ts
CHANGED
|
@@ -326,6 +326,14 @@ interface FolderScopedOptions extends BaseOptions {
|
|
|
326
326
|
folderPath?: string;
|
|
327
327
|
}
|
|
328
328
|
|
|
329
|
+
/**
|
|
330
|
+
* Type for field mapping configuration
|
|
331
|
+
* Maps source field names to target field names
|
|
332
|
+
*/
|
|
333
|
+
type FieldMapping = {
|
|
334
|
+
[sourceField: string]: string;
|
|
335
|
+
};
|
|
336
|
+
|
|
329
337
|
/**
|
|
330
338
|
* Base service for services that need folder-specific functionality.
|
|
331
339
|
*
|
|
@@ -367,9 +375,12 @@ declare class FolderScopedService extends BaseService {
|
|
|
367
375
|
* @param name - Resource name to search for
|
|
368
376
|
* @param options - Folder scoping (`folderId` / `folderKey` / `folderPath`) + OData query options (`expand`, `select`)
|
|
369
377
|
* @param transform - Maps a raw OData item to the typed response (e.g. PascalCase → camelCase via field map)
|
|
378
|
+
* @param responseFieldMap - Optional response field map (API → SDK), reversed internally by
|
|
379
|
+
* `transformOptions` to rewrite SDK field names back to API names in user-supplied
|
|
380
|
+
* `expand` / `select` (symmetric counterpart to `transform`)
|
|
370
381
|
* @throws ValidationError when inputs are malformed; NotFoundError when no match
|
|
371
382
|
*/
|
|
372
|
-
protected getByNameLookup<TRaw extends object, T>(resourceType: string, endpoint: string, name: string, options: FolderScopedOptions, transform: (raw: TRaw) => T): Promise<T>;
|
|
383
|
+
protected getByNameLookup<TRaw extends object, T>(resourceType: string, endpoint: string, name: string, options: FolderScopedOptions, transform: (raw: TRaw) => T, responseFieldMap?: FieldMapping): Promise<T>;
|
|
373
384
|
}
|
|
374
385
|
|
|
375
386
|
/**
|