{"_id":"@dynatrace-sdk/dqlint","_rev":"2-2272f450f5539dd08dcc61385576567d","name":"@dynatrace-sdk/dqlint","dist-tags":{"latest":"1.5.0"},"versions":{"1.3.0":{"name":"@dynatrace-sdk/dqlint","version":"1.3.0","author":{"name":"Felix Neustifter & Johannes Krahofer"},"license":"Apache-2.0","_id":"@dynatrace-sdk/dqlint@1.3.0","maintainers":[{"name":"dynatrace-nodejs","email":"nodejs@dynatrace.com"},{"name":"stefan.wolfsteiner.dynatrace","email":"stefan.wolfsteiner@dynatrace.com"},{"name":"wasserb","email":"Stefan.wasserbauer@dynatrace.com"}],"bin":{"dqlint":"cli/cjs/index.js"},"dist":{"shasum":"b9713d992f1c478ab855704d03898239ff3e4e57","tarball":"https://registry.npmjs.org/@dynatrace-sdk/dqlint/-/dqlint-1.3.0.tgz","fileCount":16,"integrity":"sha512-gKrGGdRf+KUP+19vDQFlzaU9dho+q1UPCQ7+Txy2tm2GFc4T3irN23pbJZlW7PCqecpBBLkxu/tJ5mEGD9+k2Q==","signatures":[{"sig":"MEUCIAEZwi5xUxK0tZmquNK2Bb9gC3yJo9od6oZMcSfthSkjAiEAoYDGsA+1WyGKMzefrs05ehGwE3fs1St4RNOX7zsB4dU=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":159359},"main":"./cjs/index.js","_from":"file:dynatrace-sdk-dqlint-1.3.0.tgz","types":"./types/index.d.ts","module":"./esm/index.js","exports":{".":{"types":"./types/index.d.ts","import":"./esm/index.js","module":"./esm/index.js","browser":"./esm/index.js","require":"./cjs/index.js"},"./cli":{"types":"./cli/types/index.d.ts","import":"./cli/esm/index.js","module":"./cli/esm/index.js","browser":"./cli/esm/index.js","require":"./cli/cjs/index.js"},"./prettier-plugin":{"types":"./prettier-plugin/types/index.d.ts","import":"./prettier-plugin/esm/index.js","module":"./prettier-plugin/esm/index.js","browser":"./prettier-plugin/esm/index.js","require":"./prettier-plugin/cjs/index.js"}},"_npmUser":{"name":"dynatrace-nodejs","email":"nodejs@dynatrace.com"},"_resolved":"/tmp/npm-publish-@dynatrace-sdk-dqlint-1.3.0-nAhi3u/dynatrace-sdk-dqlint-1.3.0.tgz","_integrity":"sha512-gKrGGdRf+KUP+19vDQFlzaU9dho+q1UPCQ7+Txy2tm2GFc4T3irN23pbJZlW7PCqecpBBLkxu/tJ5mEGD9+k2Q==","_npmVersion":"11.6.2","description":"Core formatting logic for DQL, CLI and Prettier plugin","directories":{},"sideEffects":false,"_nodeVersion":"24.13.0","_hasShrinkwrap":false,"peerDependencies":{"prettier":"^3.0.0"},"_npmOperationalInternal":{"tmp":"tmp/dqlint_1.3.0_1781187513937_0.4837638015900494","host":"s3://npm-registry-packages-npm-production"}},"1.5.0":{"name":"@dynatrace-sdk/dqlint","version":"1.5.0","description":"Core formatting logic for DQL, CLI and Prettier plugin","sideEffects":false,"exports":{".":{"types":"./types/index.d.ts","require":"./cjs/index.js","browser":"./esm/index.js","module":"./esm/index.js","import":"./esm/index.js"},"./cli":{"types":"./cli/types/index.d.ts","require":"./cli/cjs/index.js","browser":"./cli/esm/index.js","module":"./cli/esm/index.js","import":"./cli/esm/index.js"},"./prettier-plugin":{"types":"./prettier-plugin/types/index.d.ts","require":"./prettier-plugin/cjs/index.js","browser":"./prettier-plugin/esm/index.js","module":"./prettier-plugin/esm/index.js","import":"./prettier-plugin/esm/index.js"}},"bin":{"dqlint":"cli/cjs/index.js"},"main":"./cjs/index.js","types":"./types/index.d.ts","peerDependencies":{"prettier":"^3.0.0"},"author":{"name":"Felix Neustifter & Johannes Krahofer"},"license":"Apache-2.0","module":"./esm/index.js","_id":"@dynatrace-sdk/dqlint@1.5.0","_integrity":"sha512-WQoeg58lKCt9/zAusXllhMwhGTDD/q115Q0Aiy1cdeyz5sGdx0J7L922v0yaHVdJeF7LqfInWIywonMYzW4jAw==","_resolved":"/tmp/npm-publish-@dynatrace-sdk-dqlint-1.5.0-2e3iT9/dynatrace-sdk-dqlint-1.5.0.tgz","_from":"file:dynatrace-sdk-dqlint-1.5.0.tgz","_nodeVersion":"24.18.0","_npmVersion":"11.16.0","dist":{"integrity":"sha512-WQoeg58lKCt9/zAusXllhMwhGTDD/q115Q0Aiy1cdeyz5sGdx0J7L922v0yaHVdJeF7LqfInWIywonMYzW4jAw==","shasum":"a6cff4e1ee21418672cdbb2e0f74d749a7bf4e1e","tarball":"https://registry.npmjs.org/@dynatrace-sdk/dqlint/-/dqlint-1.5.0.tgz","fileCount":15,"unpackedSize":185434,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIH5CevbCeLA39BbpEboqrzGZBTuEsdYzrjKG21IoNsWWAiEAtPqSz9WeEJ6MXSQt861hfKKp+xSYKLGE23RuFWry08I="}]},"_npmUser":{"name":"dynatrace-nodejs","email":"nodejs@dynatrace.com"},"directories":{},"maintainers":[{"name":"dynatrace-nodejs","email":"nodejs@dynatrace.com"},{"name":"stefan.wolfsteiner.dynatrace","email":"stefan.wolfsteiner@dynatrace.com"},{"name":"wasserb","email":"Stefan.wasserbauer@dynatrace.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/dqlint_1.5.0_1784705951682_0.9404718149231612"},"_hasShrinkwrap":false}},"time":{"created":"2026-06-11T14:18:33.772Z","modified":"2026-07-22T07:39:12.030Z","1.3.0":"2026-06-11T14:18:34.100Z","1.5.0":"2026-07-22T07:39:11.819Z"},"author":{"name":"Felix Neustifter & Johannes Krahofer"},"license":"Apache-2.0","description":"Core formatting logic for DQL, CLI and Prettier plugin","maintainers":[{"name":"dynatrace-nodejs","email":"nodejs@dynatrace.com"},{"name":"stefan.wolfsteiner.dynatrace","email":"stefan.wolfsteiner@dynatrace.com"},{"name":"wasserb","email":"Stefan.wasserbauer@dynatrace.com"}],"readme":"# @dynatrace-sdk/dqlint\n\nA simple and efficient DQL (Dynatrace Query Language) formatter.\n\n## Features\n\nFor the complete rule reference with before/after examples see [`docs/rules.md`](./docs/rules.md).\n\n**Command layout**\n- Each `|` command is placed on its own line.\n- The first argument stays on the command line; subsequent arguments align beneath it.\n- Named (`key: value`) arguments and block arguments use a two-space indent from the command, and all later arguments in the same command follow that indent.\n- `fetch`, `smartscapeNodes`, and `smartscapeEdges` stay single-line; all other leading commands split per argument.\n- Multi-line function-call arguments align under the opening parenthesis.\n\n**Blocks and subqueries**\n- Single-element `{ }` blocks get a space inside; single-element `[ ]` blocks don't.\n- Multi-element blocks expand to one element per line with indentation.\n- Subqueries inside `[ ]` are formatted recursively with the same rules as a top-level query.\n\n**Spacing**\n- Commas are followed by a single space (unless a line break follows).\n- Semantic colons (`key:`) get a trailing space; URL colons (`://`) and namespace colons (`dt.entity:type`) are left untouched.\n- Assignment and comparison operators (`=`, `==`, `!=`, `<=`, `>=`, `=~`) get one space on each side.\n- Binary arithmetic operators (`+`, `-`, `*`, `/`) get one space on each side; unary signs on numeric literals and durations are left attached.\n- The `@` time-alignment operator (e.g. `-2h@h`) is written without surrounding spaces.\n\n**Preserved content**\n- Quoted strings (`\"…\"`, `'…'`, `` `…` ``) are never modified.\n- Template variables (`${…}`) are passed through verbatim.\n- Line comments (`//`) are passed through verbatim.\n- Multiple consecutive blank lines are collapsed to at most one.\n- Trailing comments and blank lines at the end of a command stay at the left margin.\n\n## Usage\n\n`@dynatrace-sdk/dqlint` has three independent surfaces. Use whichever fits your workflow:\n\n| Surface | When to use |\n|---|---|\n| [**Library**](#library) | Format DQL strings programmatically inside application code. |\n| [**CLI**](#cli) | Scan and fix DQL strings in source files, or format a query on the command line. |\n| [**Prettier plugin**](#prettier-plugin) | Auto-format DQL on save in your editor via Prettier. |\n\n---\n\n## Library\n\n### Installation\n\n```bash\nnpm install @dynatrace-sdk/dqlint\n# or\nyarn add @dynatrace-sdk/dqlint\n# or\npnpm add @dynatrace-sdk/dqlint\n```\n\n### Usage\n\nImport `formatDql` and call it with any DQL string. The function is stateless and pure: the same input always produces the same output.\n\n```typescript\nimport { formatDql } from '@dynatrace-sdk/dqlint';\n\nconst formatted = formatDql(\n  'fetch logs | filter loglevel == \"ERROR\" | limit 10',\n);\nconsole.log(formatted);\n// fetch logs\n// | filter loglevel == \"ERROR\"\n// | limit 10\n```\n\n---\n\n## CLI\n\nThe CLI scans source files for DQL strings, reports their formatted versions, and can rewrite them in place.\n\n### Prerequisites\n\nThe CLI requires Node.js. Install the package as a project dev dependency so the `dqlint` binary is available via `npx` or as an npm script:\n\n```bash\nnpm install --save-dev @dynatrace-sdk/dqlint\n# or\nyarn add --dev @dynatrace-sdk/dqlint\n# or\npnpm add --save-dev @dynatrace-sdk/dqlint\n```\n\n> **Note:** Running `npx dqlint` without a prior installation will download the package on demand, which works for one-off use but is slower and doesn't pin a version. For CI or pre-commit hooks, install it as a dev dependency.\n\n### Usage\n\n```bash\nnpx dqlint <path...> [--ext=.ts,.tsx] [--fix] [--add-dql-tag]\n```\n\n`<path...>` accepts one or more files or directories. Directories are scanned recursively.\n\nAdd it as an npm script for convenience:\n\n```json\n{\n  \"scripts\": {\n    \"dqlint\": \"dqlint src\"\n  }\n}\n```\n\n#### Supported file extensions\n\nBy default `dqlint` scans `.txt`, `.dql`, `.js`, `.jsx`, `.ts`, and `.tsx` files. Override with `--ext`:\n\n```bash\ndqlint src --ext=.ts,.tsx   # only TypeScript files\ndqlint src --ext=ts,tsx     # dots are added automatically\n```\n\n#### Fixing files in place\n\nThe `--fix` flag rewrites each file with formatted DQL strings replacing the originals:\n\n```bash\ndqlint src --fix\n```\n\n#### Adding `dql` tags\n\nThe `--add-dql-tag` flag wraps detected DQL strings with the `dql` template tag and inserts the corresponding import statement. This is the recommended migration step before enabling the Prettier plugin:\n\n```bash\ndqlint src --add-dql-tag\n```\n\nInput:\n\n```typescript\nconst query = `fetch logs | filter loglevel == \"ERROR\"`;\n```\n\nOutput:\n\n```typescript\nimport { dql } from '@dynatrace-sdk/dqlint';\n\nconst query = dql`fetch logs | filter loglevel == \"ERROR\"`;\n```\n\n> **Note:** `--add-dql-tag` converts single- and double-quoted strings to template literals, because the `dql` tag only works with template literals.\n\nCombine `--fix` and `--add-dql-tag` to format and tag in one pass:\n\n```bash\ndqlint src --fix --add-dql-tag\n```\n\n#### Raw string mode\n\nFormat a DQL string directly without reading any files:\n\n```bash\ndqlint --raw \"fetch logs | filter loglevel == \\\"ERROR\\\" | limit 10\"\n```\n\nEach argument after `--raw` is formatted and printed to `stdout`. Useful for quick checks or editor integrations.\n\n#### Exit codes\n\n| Code | Meaning |\n|---|---|\n| `0` | Success: files were processed or raw strings were formatted. |\n| `1` | Incorrect usage: no paths provided, no strings in `--raw` mode, or no matching files found. |\n| `2` | File or path not found. |\n| `3` | Unexpected error reading a file. |\n\n---\n\n## Prettier Plugin\n\nThe Prettier plugin formats DQL automatically on save inside tagged template literals, commented template literals, and `.dql` files.\n\n### Prerequisites\n\n- `prettier` must be installed in your project (declared as an optional peer dependency).\n- The package itself must be installed.\n\n### Installation\n\n```bash\nnpm install --save-dev @dynatrace-sdk/dqlint prettier\n# or\nyarn add --dev @dynatrace-sdk/dqlint prettier\n# or\npnpm add --save-dev @dynatrace-sdk/dqlint prettier\n```\n\n### Configuration\n\nAdd the plugin to your `.prettierrc`:\n\n```json\n{\n  \"plugins\": [\"@dynatrace-sdk/dqlint/prettier-plugin\"]\n}\n```\n\nThe plugin is published as a separate subpath export (`/prettier-plugin`) so that application code importing only `formatDql` or the `dql` tag doesn't transitively pull Prettier into the consumer bundle.\n\n### Usage\n\nThe plugin formats DQL inside any of the following:\n\n**Tagged template literals** are the preferred approach. Import the `dql` tag from the package root (it's a tiny, dependency-free identity function and doesn't pull in Prettier):\n\n```typescript\nimport { dql } from '@dynatrace-sdk/dqlint';\n\nconst query = dql`fetch logs | filter loglevel == \"ERROR\" | limit 10`;\n```\n\nAfter running Prettier:\n\n```typescript\nconst query = dql`fetch logs\n| filter loglevel == \"ERROR\"\n| limit 10`;\n```\n\n**Commented template literals** are for when you can't add the `dql` tag:\n\n```typescript\nconst query = /* dql */ `fetch logs | filter loglevel == \"ERROR\" | limit 10`;\n```\n\n**`.dql` files**: standalone DQL files are formatted as a whole:\n\n```dql\nfetch logs | filter loglevel == \"ERROR\" | limit 10\n```\n\nTo add `dql` tags to an existing codebase automatically, see [`--add-dql-tag`](#adding-dql-tags) in the CLI section.\n\n---\n\n## Development\n\n1. Install dependencies: `pnpm install`\n2. Build: `pnpm nx build dqlint`\n3. Run tests: `pnpm nx test dqlint`\n4. Lint: `pnpm nx lint dqlint`\n\n---\n\n## Help\n\nQuestions or feedback? Join [#help-dqlint](https://dynatrace.enterprise.slack.com/archives/C0BEDG3D9RC) on Slack.\n","readmeFilename":"README.md"}