@atlassianlabs/jql-ast

中文文档
2.1.0发布于 2023/07/12TypeScriptESM + CJS近 30 天下载 8861

JQL Abstract Syntax Tree

原始使用文档
文档目录9 节
  1. Goals
  2. What Jast is not
  3. Use cases
  4. Basic usage
  5. Installation
  6. Documentation
  7. FAQ
  8. Support
  9. License

JQL AST

Atlassian license

JQL Abstract Syntax Tree (JAST) is a json schema used to represent parsed JQL.

Goals

  • A Jast from one platform should be re-usable as a Jast from another (Java ↔︎ JS ↔︎ iOS)
  • Contain enough information to render a rich JQL editing experience (e.g. Syntax highlighting)
  • Represent invalid and partially formed JQL (and contain detailed information on syntax errors)

What Jast is not

  • Does not represent every detail appearing in the real syntax, but rather just the structural or content-related details (e.g. Parentheses are implicit in the tree structure so they are not included as nodes)
  • Does not contain any data specific to a individual Jira instance (besides the string of the original JQL query itself). Eg: no knowledge of available fields/users/values/operators
  • Syntax validation should not be performed on the Jast (this is done using the CST)
  • Autocomplete suggestions should not be populated using the Jast (this is done using the CST)

Use cases

  • Syntax highlighting
  • Rendering errors

Basic usage

To generate an AST you need the JQL string you want to parse and a JastBuilder.

import { JastBuilder, Jast } from "@atlassianlabs/jql-ast";

const someJqlQuery = 'issuetype = bug';
const myJast: Jast = new JastBuilder().build(someJqlQuery);

Installation

yarn add @atlassianlabs/jql-ast

Documentation

Refer to docs for more details.

FAQ

Why do we need an Abstact Syntaxt Tree (over the free CST)?

ANTLR4 auto-generated parsers already generate a Concrete Syntax Tree from a JQL string. This tree is more detailed than the AST but otherwise VERY similar, why not just use that?

The main reason is that the CST doesn’t immediately fulfill all of the listed goals above. But there are some other differences to mention:

  • The produced CST is not directly under our control, so updates to ANTLR4 syntax implementation only need to cause updates to the AST generator, no UI component updates necessary.
  • CST is not inherently serializable, but we can send a pre-parsed AST to be rendered early / in SSR without loading the whole parser and ANTLR4 runtime immediately.
  • Since we control creation of the AST, we can make logically consistent transformations to it without going through the parser again.
  • We can make sensible simplifications to the tree, e.g. combining ORDER BY into one terminal node instead of three, collapsing inactive notCompoundOperators, etc.

Support

For developers outside of Atlassian looking for help, or to report issues, please make a post on the community forum. We will monitor the forums and redirect topics to the appropriate maintainers.

License

Copyright (c) 2021 - 2022 Atlassian and others. Apache 2.0 licensed, see LICENSE file.

版本与发布记录

@atlassianlabs/jql-ast 共发布 4 个版本,首次发布于 2021/12/10;过去 12 个月发布了 0 个版本。

版本发布日期距今
2.1.0latest2023/07/123 年前
2.0.02023/06/023 年前
1.0.02022/02/214 年前
0.0.12021/12/104 年前

关于 @atlassianlabs/jql-ast 的常见问题

@atlassianlabs/jql-ast 是什么?

JQL Abstract Syntax Tree

如何安装 @atlassianlabs/jql-ast?

在项目目录运行 npm install @atlassianlabs/jql-ast,或使用 pnpm add / yarn add / bun add。

@atlassianlabs/jql-ast 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@atlassianlabs/jql-ast 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@atlassianlabs/jql-ast 可以商用吗?

@atlassianlabs/jql-ast 使用 未声明 许可。package.json 没有声明许可证。没有许可证的代码默认保留全部权利,商用前请联系作者或查看仓库中的 LICENSE 文件。以上为概括,不构成法律意见,请以许可原文为准。

@atlassianlabs/jql-ast 的下载量有多少?

根据 npm 官方下载统计,@atlassianlabs/jql-ast 在 2026/10/07 – 2026/11/05 这 30 天内被下载 8,861 次,日均约 295 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@atlassianlabs/jql-ast 还在维护吗?

最新版本 2.1.0 发布于 2023/07/12(3 年前);至今共发布 4 个版本,其中过去 12 个月发布了 0 个;首次发布于 2021/12/10。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。