Skip to content

Commit 67e6471

Browse files
Feature/#354 deprecation of jql search and evaluate expression endpoints (#355)
* chore: Vulnerability fix `npm fix audit` * chore: fix error when running vitest RangeError: options.minThreads and options.maxThreads must not conflict Fixed by adding `--minWorkers=8` to `test:unit` in package.json * test: define unit test for v3 enhanced search * feat: implement v3 enhanced search * chore: fix broken anchor * test: define unit test for v2 enhanced search * feat: implement v2 enhanced search * chore: fix typo in v2 * chore: fix wrong interface name * test: define unit test for v3 jiraExpressions Only implemented unit test for the newly added function evaluateJiraExpressionUsingEnhancedSearch() * feat: implement v3 jiraExpressions Implemented new function evaluateJiraExpressionUsingEnhancedSearch() * test: define unit test for v2 jiraExpressions Only implemented unit test for the newly added function evaluateJiraExpressionUsingEnhancedSearch() * feat: implement v2 jiraExpressions Implemented new function evaluateJiraExpressionUsingEnhancedSearch() * chore: change minWorkers to 1 for vitest --------- Co-authored-by: Vladislav Tupikin <[email protected]>
1 parent 4b1ae94 commit 67e6471

10 files changed

+631
-0
lines changed

src/version2/issueSearch.ts

Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -463,4 +463,144 @@ export class IssueSearch {
463463

464464
return this.client.sendRequest(config, callback);
465465
}
466+
467+
/**
468+
* Searches for issues using [JQL](https://confluence.atlassian.com/x/egORLQ). Recent updates might not be immediately
469+
* visible in the returned search results.
470+
*
471+
* If you need [read-after-write](https://developer.atlassian.com/cloud/jira/platform/search-and-reconcile/) consistency,
472+
* you can utilize the `reconcileIssues` parameter to ensure stronger consistency assurances.
473+
*
474+
* If the JQL query expression is too large to be encoded as a query parameter, use the
475+
* [POST](#searchforissuesusingjqlenhancedsearchpost) version of this resource.
476+
*
477+
* This operation can be accessed anonymously.
478+
*
479+
* **[Permissions](https://developer.atlassian.com/cloud/jira/platform/rest/v2/intro/#permissions) required:** Issues
480+
* are included in the response where the user has:
481+
*
482+
* - _Browse projects_ [project permission](https://confluence.atlassian.com/x/yodKLg) for the project containing the
483+
* issue.
484+
* - If [issue-level security](https://confluence.atlassian.com/x/J4lKLg) is configured, issue-level security permission
485+
* to view the issue.
486+
*/
487+
async searchForIssuesUsingJqlEnhancedSearch<T = Models.SearchAndReconcileResults>(
488+
parameters: Parameters.SearchForIssuesUsingJqlEnhancedSearch | undefined,
489+
callback: Callback<T>,
490+
): Promise<void>;
491+
/**
492+
* Searches for issues using [JQL](https://confluence.atlassian.com/x/egORLQ). Recent updates might not be immediately
493+
* visible in the returned search results.
494+
*
495+
* If you need [read-after-write](https://developer.atlassian.com/cloud/jira/platform/search-and-reconcile/) consistency,
496+
* you can utilize the `reconcileIssues` parameter to ensure stronger consistency assurances.
497+
*
498+
* If the JQL query expression is too large to be encoded as a query parameter, use the
499+
* [POST](#searchforissuesusingjqlenhancedsearchpost) version of this resource.
500+
*
501+
* This operation can be accessed anonymously.
502+
*
503+
* **[Permissions](https://developer.atlassian.com/cloud/jira/platform/rest/v2/intro/#permissions) required:** Issues
504+
* are included in the response where the user has:
505+
*
506+
* - _Browse projects_ [project permission](https://confluence.atlassian.com/x/yodKLg) for the project containing the
507+
* issue.
508+
* - If [issue-level security](https://confluence.atlassian.com/x/J4lKLg) is configured, issue-level security permission
509+
* to view the issue.
510+
*/
511+
async searchForIssuesUsingJqlEnhancedSearch<T = Models.SearchAndReconcileResults>(
512+
parameters?: Parameters.SearchForIssuesUsingJqlEnhancedSearch,
513+
callback?: never,
514+
): Promise<T>;
515+
async searchForIssuesUsingJqlEnhancedSearch<T = Models.SearchAndReconcileResults>(
516+
parameters?: Parameters.SearchForIssuesUsingJqlEnhancedSearch,
517+
callback?: Callback<T>,
518+
): Promise<void | T> {
519+
const config: RequestConfig = {
520+
url: '/rest/api/2/search/jql',
521+
method: 'GET',
522+
params: {
523+
jql: parameters?.jql,
524+
nextPageToken: parameters?.nextPageToken,
525+
maxResults: parameters?.maxResults,
526+
fields: parameters?.fields,
527+
expand: parameters?.expand,
528+
properties: parameters?.properties,
529+
fieldsByKeys: parameters?.fieldsByKeys,
530+
failFast: parameters?.failFast,
531+
reconcileIssues: parameters?.reconcileIssues,
532+
},
533+
};
534+
535+
return this.client.sendRequest(config, callback);
536+
}
537+
538+
/**
539+
* Searches for issues using [JQL](https://confluence.atlassian.com/x/egORLQ).
540+
*
541+
* If you need [read-after-write](https://developer.atlassian.com/cloud/jira/platform/search-and-reconcile/) consistency,
542+
* you can utilize the `reconcileIssues` parameter to ensure stronger consistency assurances.
543+
*
544+
* There is a [GET](#searchforissuesusingjqlenhancedsearch) version of this resource that can be used for smaller JQL query
545+
* expressions.
546+
*
547+
* This operation can be accessed anonymously.
548+
*
549+
* **[Permissions](https://developer.atlassian.com/cloud/jira/platform/rest/v2/intro/#permissions) required:** Issues
550+
* are included in the response where the user has:
551+
*
552+
* - _Browse projects_ [project permission](https://confluence.atlassian.com/x/yodKLg) for the project containing the
553+
* issue.
554+
* - If [issue-level security](https://confluence.atlassian.com/x/J4lKLg) is configured, issue-level security permission
555+
* to view the issue.
556+
*/
557+
async searchForIssuesUsingJqlEnhancedSearchPost<T = Models.SearchAndReconcileResults>(
558+
parameters: Parameters.SearchForIssuesUsingJqlEnhancedSearchPost | undefined,
559+
callback: Callback<T>,
560+
): Promise<void>;
561+
/**
562+
* Searches for issues using [JQL](https://confluence.atlassian.com/x/egORLQ).
563+
*
564+
* If you need [read-after-write](https://developer.atlassian.com/cloud/jira/platform/search-and-reconcile/) consistency,
565+
* you can utilize the `reconcileIssues` parameter to ensure stronger consistency assurances.
566+
*
567+
* There is a [GET](#searchforissuesusingjqlenhancedsearch) version of this resource that can be used for smaller JQL query
568+
* expressions.
569+
*
570+
* This operation can be accessed anonymously.
571+
*
572+
* **[Permissions](https://developer.atlassian.com/cloud/jira/platform/rest/v2/intro/#permissions) required:** Issues
573+
* are included in the response where the user has:
574+
*
575+
* - _Browse projects_ [project permission](https://confluence.atlassian.com/x/yodKLg) for the project containing the
576+
* issue.
577+
* - If [issue-level security](https://confluence.atlassian.com/x/J4lKLg) is configured, issue-level security permission
578+
* to view the issue.
579+
*/
580+
async searchForIssuesUsingJqlEnhancedSearchPost<T = Models.SearchAndReconcileResults>(
581+
parameters?: Parameters.SearchForIssuesUsingJqlEnhancedSearchPost,
582+
callback?: never,
583+
): Promise<T>;
584+
async searchForIssuesUsingJqlEnhancedSearchPost<T = Models.SearchAndReconcileResults>(
585+
parameters?: Parameters.SearchForIssuesUsingJqlEnhancedSearchPost,
586+
callback?: Callback<T>,
587+
): Promise<void | T> {
588+
const config: RequestConfig = {
589+
url: '/rest/api/2/search',
590+
method: 'POST',
591+
data: {
592+
jql: parameters?.jql,
593+
nextPageToken: parameters?.nextPageToken,
594+
maxResults: parameters?.maxResults,
595+
fields: parameters?.fields,
596+
expand: parameters?.expand,
597+
properties: parameters?.properties,
598+
fieldsByKeys: parameters?.fieldsByKeys,
599+
failFast: parameters?.failFast,
600+
reconcileIssues: parameters?.reconcileIssues,
601+
},
602+
};
603+
604+
return this.client.sendRequest(config, callback);
605+
}
466606
}

src/version2/jiraExpressions.ts

Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,4 +339,149 @@ export class JiraExpressions {
339339

340340
return this.client.sendRequest(config, callback);
341341
}
342+
343+
/**
344+
* Evaluates a Jira expression and returns its value. The difference between this and `eval` is that this endpoint
345+
* uses the enhanced search API when evaluating JQL queries. This API is eventually consistent, unlike the strongly
346+
* consistent `eval` API. This allows for better performance and scalability. In addition, this API's response for
347+
* JQL evaluation is based on a scrolling view (backed by a `nextPageToken`) instead of a paginated view
348+
* (backed by `startAt` and `totalCount`).
349+
*
350+
* This resource can be used to test Jira expressions that you plan to use elsewhere, or to fetch data in a flexible
351+
* way. Consult the [Jira expressions
352+
* documentation](https://developer.atlassian.com/cloud/jira/platform/jira-expressions/) for more details.
353+
*
354+
* #### Context variables
355+
*
356+
* The following context variables are available to Jira expressions evaluated by this resource. Their presence
357+
* depends on various factors; usually you need to manually request them in the context object sent in the payload,
358+
* but some of them are added automatically under certain conditions.
359+
*
360+
* - `user` ([User](https://developer.atlassian.com/cloud/jira/platform/jira-expressions-type-reference#user)): The
361+
* current user. Always available and equal to `null` if the request is anonymous.
362+
* - `app` ([App](https://developer.atlassian.com/cloud/jira/platform/jira-expressions-type-reference#app)): The
363+
* [Connect app](https://developer.atlassian.com/cloud/jira/platform/index/#connect-apps) that made the request.
364+
* Available only for authenticated requests made by Connect Apps (read more here: [Authentication for Connect
365+
* apps](https://developer.atlassian.com/cloud/jira/platform/security-for-connect-apps/)).
366+
* - `issue` ([Issue](https://developer.atlassian.com/cloud/jira/platform/jira-expressions-type-reference#issue)): The
367+
* current issue. Available only when the issue is provided in the request context object.
368+
* - `issues` ([List](https://developer.atlassian.com/cloud/jira/platform/jira-expressions-type-reference#list) of
369+
* [Issues](https://developer.atlassian.com/cloud/jira/platform/jira-expressions-type-reference#issue)): A
370+
* collection of issues matching a JQL query. Available only when JQL is provided in the request context object.
371+
* - `project` ([Project](https://developer.atlassian.com/cloud/jira/platform/jira-expressions-type-reference#project)):
372+
* The current project. Available only when the project is provided in the request context object.
373+
* - `sprint` ([Sprint](https://developer.atlassian.com/cloud/jira/platform/jira-expressions-type-reference#sprint)):
374+
* The current sprint. Available only when the sprint is provided in the request context object.
375+
* - `board` ([Board](https://developer.atlassian.com/cloud/jira/platform/jira-expressions-type-reference#board)): The
376+
* current board. Available only when the board is provided in the request context object.
377+
* - `serviceDesk`
378+
* ([ServiceDesk](https://developer.atlassian.com/cloud/jira/platform/jira-expressions-type-reference#servicedesk)):
379+
* The current service desk. Available only when the service desk is provided in the request context object.
380+
* - `customerRequest`
381+
* ([CustomerRequest](https://developer.atlassian.com/cloud/jira/platform/jira-expressions-type-reference#customerrequest)):
382+
* The current customer request. Available only when the customer request is provided in the request context
383+
* object.
384+
*
385+
* In addition, you can pass custom context variables along with their types. You can then access them from
386+
* the Jira expression by key. You can use the following variables in a custom context:
387+
*
388+
* - `user`: A [user](https://developer.atlassian.com/cloud/jira/platform/jira-expressions-type-reference#user)
389+
* specified as an Atlassian account ID.
390+
* - `issue`: An [issue](https://developer.atlassian.com/cloud/jira/platform/jira-expressions-type-reference#issue)
391+
* specified by ID or key. All the fields of the issue object are available in the Jira expression.
392+
* - `json`: A JSON object containing custom content.
393+
* - `list`: A JSON list of `user`, `issue`, or `json` variable types.
394+
*
395+
* This operation can be accessed anonymously.
396+
*
397+
* **[Permissions](https://developer.atlassian.com/cloud/jira/platform/rest/v2/intro/#permissions) required**: None.
398+
* However, an expression may return different results for different users depending on their permissions. For
399+
* example, different users may see different comments on the same issue. Permission to access Jira Software is
400+
* required to access Jira Software context variables (`board` and `sprint`) or fields (for example, `issue.sprint`).
401+
*/
402+
async evaluateJiraExpressionUsingEnhancedSearch<T = Models.JExpEvaluateJiraExpressionResult>(
403+
parameters: Parameters.EvaluateJiraExpressionUsingEnhancedSearch | undefined,
404+
callback: Callback<T>,
405+
): Promise<void>;
406+
/**
407+
* Evaluates a Jira expression and returns its value. The difference between this and `eval` is that this endpoint
408+
* uses the enhanced search API when evaluating JQL queries. This API is eventually consistent, unlike the strongly
409+
* consistent `eval` API. This allows for better performance and scalability. In addition, this API's response for
410+
* JQL evaluation is based on a scrolling view (backed by a `nextPageToken`) instead of a paginated view
411+
* (backed by `startAt` and `totalCount`).
412+
*
413+
* This resource can be used to test Jira expressions that you plan to use elsewhere, or to fetch data in a flexible
414+
* way. Consult the [Jira expressions
415+
* documentation](https://developer.atlassian.com/cloud/jira/platform/jira-expressions/) for more details.
416+
*
417+
* #### Context variables
418+
*
419+
* The following context variables are available to Jira expressions evaluated by this resource. Their presence
420+
* depends on various factors; usually you need to manually request them in the context object sent in the payload,
421+
* but some of them are added automatically under certain conditions.
422+
*
423+
* - `user` ([User](https://developer.atlassian.com/cloud/jira/platform/jira-expressions-type-reference#user)): The
424+
* current user. Always available and equal to `null` if the request is anonymous.
425+
* - `app` ([App](https://developer.atlassian.com/cloud/jira/platform/jira-expressions-type-reference#app)): The
426+
* [Connect app](https://developer.atlassian.com/cloud/jira/platform/index/#connect-apps) that made the request.
427+
* Available only for authenticated requests made by Connect Apps (read more here: [Authentication for Connect
428+
* apps](https://developer.atlassian.com/cloud/jira/platform/security-for-connect-apps/)).
429+
* - `issue` ([Issue](https://developer.atlassian.com/cloud/jira/platform/jira-expressions-type-reference#issue)): The
430+
* current issue. Available only when the issue is provided in the request context object.
431+
* - `issues` ([List](https://developer.atlassian.com/cloud/jira/platform/jira-expressions-type-reference#list) of
432+
* [Issues](https://developer.atlassian.com/cloud/jira/platform/jira-expressions-type-reference#issue)): A
433+
* collection of issues matching a JQL query. Available only when JQL is provided in the request context object.
434+
* - `project` ([Project](https://developer.atlassian.com/cloud/jira/platform/jira-expressions-type-reference#project)):
435+
* The current project. Available only when the project is provided in the request context object.
436+
* - `sprint` ([Sprint](https://developer.atlassian.com/cloud/jira/platform/jira-expressions-type-reference#sprint)):
437+
* The current sprint. Available only when the sprint is provided in the request context object.
438+
* - `board` ([Board](https://developer.atlassian.com/cloud/jira/platform/jira-expressions-type-reference#board)): The
439+
* current board. Available only when the board is provided in the request context object.
440+
* - `serviceDesk`
441+
* ([ServiceDesk](https://developer.atlassian.com/cloud/jira/platform/jira-expressions-type-reference#servicedesk)):
442+
* The current service desk. Available only when the service desk is provided in the request context object.
443+
* - `customerRequest`
444+
* ([CustomerRequest](https://developer.atlassian.com/cloud/jira/platform/jira-expressions-type-reference#customerrequest)):
445+
* The current customer request. Available only when the customer request is provided in the request context
446+
* object.
447+
*
448+
* In addition, you can pass custom context variables along with their types. You can then access them from
449+
* the Jira expression by key. You can use the following variables in a custom context:
450+
*
451+
* - `user`: A [user](https://developer.atlassian.com/cloud/jira/platform/jira-expressions-type-reference#user)
452+
* specified as an Atlassian account ID.
453+
* - `issue`: An [issue](https://developer.atlassian.com/cloud/jira/platform/jira-expressions-type-reference#issue)
454+
* specified by ID or key. All the fields of the issue object are available in the Jira expression.
455+
* - `json`: A JSON object containing custom content.
456+
* - `list`: A JSON list of `user`, `issue`, or `json` variable types.
457+
*
458+
* This operation can be accessed anonymously.
459+
*
460+
* **[Permissions](https://developer.atlassian.com/cloud/jira/platform/rest/v2/intro/#permissions) required**: None.
461+
* However, an expression may return different results for different users depending on their permissions. For
462+
* example, different users may see different comments on the same issue. Permission to access Jira Software is
463+
* required to access Jira Software context variables (`board` and `sprint`) or fields (for example, `issue.sprint`).
464+
*/
465+
async evaluateJiraExpressionUsingEnhancedSearch<T = Models.JExpEvaluateJiraExpressionResult>(
466+
parameters?: Parameters.EvaluateJiraExpressionUsingEnhancedSearch,
467+
callback?: never,
468+
): Promise<T>;
469+
async evaluateJiraExpressionUsingEnhancedSearch<T = Models.JExpEvaluateJiraExpressionResult>(
470+
parameters?: Parameters.EvaluateJiraExpressionUsingEnhancedSearch,
471+
callback?: Callback<T>,
472+
): Promise<void | T> {
473+
const config: RequestConfig = {
474+
url: '/rest/api/2/expression/evaluate',
475+
method: 'POST',
476+
params: {
477+
expand: parameters?.expand,
478+
},
479+
data: {
480+
expression: parameters?.expression,
481+
context: parameters?.context,
482+
},
483+
};
484+
485+
return this.client.sendRequest(config, callback);
486+
}
342487
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { JExpEvaluateMetaData } from './jExpEvaluateMetaData';
2+
3+
/** The result of evaluating a Jira expression. */
4+
export interface JExpEvaluateJiraExpressionResult {
5+
/**
6+
* The value of the evaluated expression. It may be a primitive JSON value or a Jira REST API object. (Some
7+
* expressions do not produce any meaningful results—for example, an expression that returns a lambda function—if
8+
* that's the case a simple string representation is returned. These string representations should not be relied upon
9+
* and may change without notice.)
10+
*/
11+
value: any;
12+
meta?: JExpEvaluateMetaData;
13+
}

0 commit comments

Comments
 (0)