{"_id":"@dash0hq/codemirror-promql","_rev":"6-a701a85a3a7aeb772f96e4421700212b","name":"@dash0hq/codemirror-promql","dist-tags":{"latest":"0.302.1-dash03"},"versions":{"0.302.1":{"name":"@dash0hq/codemirror-promql","version":"0.302.1","keywords":["promql","codemirror","mode","prometheus"],"author":{"name":"Prometheus Authors","email":"prometheus-developers@googlegroups.com"},"license":"Apache-2.0","_id":"@dash0hq/codemirror-promql@0.302.1","maintainers":[{"name":"bripkens","email":"bripkens@gmail.com"},{"name":"basti1302","email":"bastian.krol@web.de"}],"homepage":"https://github.com/prometheus/prometheus/blob/main/web/ui/module/codemirror-promql/README.md","bugs":{"url":"https://github.com/prometheus/prometheus/issues"},"dist":{"shasum":"0c9cd2112a9c7aa4ca02bdc48455e7bc1ce8c41c","tarball":"https://registry.npmjs.org/@dash0hq/codemirror-promql/-/codemirror-promql-0.302.1.tgz","fileCount":120,"integrity":"sha512-lUPBILlEB4tc1k/shnb3hgEU+y1572czQb+pDnwiUPvUJjgdlxx283VcRMu+lkF/CES6Fc4f12+JZ4BA4nQF7w==","signatures":[{"sig":"MEUCIEMDd3lX+XFQS3/U4WcQ2cUMPFs5sxD0+X2U7rzJFR2qAiEA+xuo8BS5AAvh0kZVuzOXXnL+rxoTubmrSLxUUBAODAI=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":483060},"main":"dist/cjs/index.js","types":"dist/esm/index.d.ts","module":"dist/esm/index.js","engines":{"node":">=12.0.0"},"gitHead":"8d1bf9337029321847534b7a30028c7c4bf0b08e","scripts":{"lint":"eslint src/ --ext .ts","test":"NODE_OPTIONS=--experimental-vm-modules jest --runInBand","build":"npm run build:lib","lint:fix":"eslint --fix src/ --ext .ts","build:lib":"bash ./build.sh"},"_npmUser":{"name":"bripkens","email":"bripkens@gmail.com"},"prettier":{"printWidth":150,"singleQuote":true,"trailingComma":"es5"},"repository":{"url":"git+https://github.com/prometheus/prometheus.git","type":"git"},"_npmVersion":"11.3.0","description":"a CodeMirror mode for the PromQL language","directories":{},"_nodeVersion":"20.17.0","dependencies":{"lru-cache":"^11.0.2","@prometheus-io/lezer-promql":"0.302.1"},"_hasShrinkwrap":false,"devDependencies":{"nock":"^14.0.1","@lezer/lr":"^1.4.2","@lezer/common":"^1.2.3","@codemirror/lint":"^6.8.4","@codemirror/view":"^6.36.4","@lezer/highlight":"^1.2.0","isomorphic-fetch":"^3.0.0","@codemirror/state":"^6.5.2","@codemirror/language":"^6.10.8","eslint-plugin-prettier":"^5.2.3","@codemirror/autocomplete":"^6.18.4"},"peerDependencies":{"@lezer/common":"^1.0.1","@codemirror/lint":"^6.0.0","@codemirror/view":"^6.4.0","@codemirror/state":"^6.1.1","@codemirror/language":"^6.3.0","@codemirror/autocomplete":"^6.4.0"},"_npmOperationalInternal":{"tmp":"tmp/codemirror-promql_0.302.1_1745597705904_0.03347653181537624","host":"s3://npm-registry-packages-npm-production"}},"0.302.1-dash01":{"name":"@dash0hq/codemirror-promql","version":"0.302.1-dash01","keywords":["promql","codemirror","mode","prometheus"],"author":{"name":"Prometheus Authors","email":"prometheus-developers@googlegroups.com"},"license":"Apache-2.0","_id":"@dash0hq/codemirror-promql@0.302.1-dash01","maintainers":[{"name":"bripkens","email":"bripkens@gmail.com"},{"name":"basti1302","email":"bastian.krol@web.de"}],"homepage":"https://github.com/prometheus/prometheus/blob/main/web/ui/module/codemirror-promql/README.md","bugs":{"url":"https://github.com/prometheus/prometheus/issues"},"dist":{"shasum":"2c7e8afe7291c9c00f77ced987f914225a51005b","tarball":"https://registry.npmjs.org/@dash0hq/codemirror-promql/-/codemirror-promql-0.302.1-dash01.tgz","fileCount":120,"integrity":"sha512-Sw8YI5utrTf0gJlycWUsrLY3ZKKBmi3OjEjfSgQIg0p2SVu7H2Ymk9/IMTX8C6QCO8IwHUk2uyUt/jVQ+LOneg==","signatures":[{"sig":"MEQCIFe8cTxVc70oecNejxpoUnB5Ay0QmICGgL6Mccz5uR/jAiBeMniuJNX+fVZbRErrtXCdxNzogaJoUMgIqNIb6coBuQ==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":493102},"main":"dist/cjs/index.js","types":"dist/esm/index.d.ts","module":"dist/esm/index.js","engines":{"node":">=12.0.0"},"gitHead":"745e90355ad45d489a5e70b9a3e9916a7e22fb10","scripts":{"lint":"eslint src/ --ext .ts","test":"NODE_OPTIONS=--experimental-vm-modules jest --runInBand","build":"npm run build:lib","lint:fix":"eslint --fix src/ --ext .ts","build:lib":"bash ./build.sh"},"_npmUser":{"name":"bripkens","email":"bripkens@gmail.com"},"prettier":{"printWidth":150,"singleQuote":true,"trailingComma":"es5"},"repository":{"url":"git+https://github.com/prometheus/prometheus.git","type":"git"},"_npmVersion":"10.8.2","description":"a CodeMirror mode for the PromQL language","directories":{},"_nodeVersion":"20.18.0","dependencies":{"lru-cache":"^11.0.2","@prometheus-io/lezer-promql":"0.302.1"},"_hasShrinkwrap":false,"devDependencies":{"nock":"^14.0.1","@lezer/lr":"^1.4.2","@lezer/common":"^1.2.3","@codemirror/lint":"^6.8.4","@codemirror/view":"^6.36.4","@lezer/highlight":"^1.2.0","isomorphic-fetch":"^3.0.0","@codemirror/state":"^6.5.2","@codemirror/language":"^6.10.8","eslint-plugin-prettier":"^5.2.3","@codemirror/autocomplete":"^6.18.4"},"peerDependencies":{"@lezer/common":"^1.0.1","@codemirror/lint":"^6.0.0","@codemirror/view":"^6.4.0","@codemirror/state":"^6.1.1","@codemirror/language":"^6.3.0","@codemirror/autocomplete":"^6.4.0"},"_npmOperationalInternal":{"tmp":"tmp/codemirror-promql_0.302.1-dash01_1746635465651_0.18312657324301873","host":"s3://npm-registry-packages-npm-production"}},"0.302.1-dash02":{"name":"@dash0hq/codemirror-promql","version":"0.302.1-dash02","keywords":["promql","codemirror","mode","prometheus"],"author":{"name":"Prometheus Authors","email":"prometheus-developers@googlegroups.com"},"license":"Apache-2.0","_id":"@dash0hq/codemirror-promql@0.302.1-dash02","maintainers":[{"name":"bripkens","email":"bripkens@gmail.com"},{"name":"basti1302","email":"bastian.krol@web.de"},{"name":"thiemok","email":"krausethiemo@googlemail.com"}],"homepage":"https://github.com/prometheus/prometheus/blob/main/web/ui/module/codemirror-promql/README.md","bugs":{"url":"https://github.com/prometheus/prometheus/issues"},"dist":{"shasum":"f9fd6eab42419e77e3fc97ff4206ec5adf4e9267","tarball":"https://registry.npmjs.org/@dash0hq/codemirror-promql/-/codemirror-promql-0.302.1-dash02.tgz","fileCount":120,"integrity":"sha512-SBHFR8MihNXRY3T1vAk93mG1L7NgHuBgb6xQvOZ4wbu4qV/tc5FJ/J/Z67O6+25qmkOZnw60KXOvO6cICdE+9A==","signatures":[{"sig":"MEUCIQCSY56AXC3TE7kG2CJold3ixBmrLqLy86mw3dujlnGvIAIgctxyOICrVWzVu7sRmAJqJqOiWmCM5Sw1RuUx5tFgO3o=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":499964},"main":"dist/cjs/index.js","types":"dist/esm/index.d.ts","module":"dist/esm/index.js","engines":{"node":">=12.0.0"},"gitHead":"acd860375b45efb96347e42b6d86330ab0bf7f2d","scripts":{"lint":"eslint src/ --ext .ts","test":"NODE_OPTIONS=--experimental-vm-modules jest --runInBand","build":"npm run build:lib","lint:fix":"eslint --fix src/ --ext .ts","build:lib":"bash ./build.sh"},"_npmUser":{"name":"bripkens","email":"bripkens@gmail.com"},"prettier":{"printWidth":150,"singleQuote":true,"trailingComma":"es5"},"repository":{"url":"git+https://github.com/prometheus/prometheus.git","type":"git"},"_npmVersion":"10.8.2","description":"a CodeMirror mode for the PromQL language","directories":{},"_nodeVersion":"20.18.0","dependencies":{"lru-cache":"^11.0.2","@prometheus-io/lezer-promql":"0.302.1"},"_hasShrinkwrap":false,"devDependencies":{"nock":"^14.0.1","@lezer/lr":"^1.4.2","@lezer/common":"^1.2.3","@codemirror/lint":"^6.8.4","@codemirror/view":"^6.36.4","@lezer/highlight":"^1.2.0","isomorphic-fetch":"^3.0.0","@codemirror/state":"^6.5.2","@codemirror/language":"^6.10.8","eslint-plugin-prettier":"^5.2.3","@codemirror/autocomplete":"^6.18.4"},"peerDependencies":{"@lezer/common":"^1.0.1","@codemirror/lint":"^6.0.0","@codemirror/view":"^6.4.0","@codemirror/state":"^6.1.1","@codemirror/language":"^6.3.0","@codemirror/autocomplete":"^6.4.0"},"_npmOperationalInternal":{"tmp":"tmp/codemirror-promql_0.302.1-dash02_1766731293310_0.3254201439472564","host":"s3://npm-registry-packages-npm-production"}},"0.302.1-dash03":{"name":"@dash0hq/codemirror-promql","version":"0.302.1-dash03","description":"a CodeMirror mode for the PromQL language","types":"dist/esm/index.d.ts","module":"dist/esm/index.js","main":"dist/cjs/index.js","scripts":{"build":"npm run build:lib","build:lib":"bash ./build.sh","test":"NODE_OPTIONS=--experimental-vm-modules jest --runInBand","lint":"eslint src/ --ext .ts","lint:fix":"eslint --fix src/ --ext .ts"},"repository":{"type":"git","url":"git+https://github.com/prometheus/prometheus.git"},"keywords":["promql","codemirror","mode","prometheus"],"author":{"name":"Prometheus Authors","email":"prometheus-developers@googlegroups.com"},"license":"Apache-2.0","bugs":{"url":"https://github.com/prometheus/prometheus/issues"},"homepage":"https://github.com/prometheus/prometheus/blob/main/web/ui/module/codemirror-promql/README.md","dependencies":{"@dash0hq/lezer-promql":"0.302.1-dash03","lru-cache":"^11.0.2"},"devDependencies":{"@codemirror/autocomplete":"^6.18.4","@codemirror/language":"^6.10.8","@codemirror/lint":"^6.8.4","@codemirror/state":"^6.5.2","@codemirror/view":"^6.36.4","@lezer/common":"^1.2.3","@lezer/highlight":"^1.2.0","@lezer/lr":"^1.4.2","eslint-plugin-prettier":"^5.2.3","isomorphic-fetch":"^3.0.0","nock":"^14.0.1"},"peerDependencies":{"@codemirror/autocomplete":"^6.4.0","@codemirror/language":"^6.3.0","@codemirror/lint":"^6.0.0","@codemirror/state":"^6.1.1","@codemirror/view":"^6.4.0","@lezer/common":"^1.0.1"},"prettier":{"singleQuote":true,"trailingComma":"es5","printWidth":150},"engines":{"node":">=12.0.0"},"gitHead":"be137238be2fa3e7b031c42d4a9e30a62f22af6a","_id":"@dash0hq/codemirror-promql@0.302.1-dash03","_nodeVersion":"25.6.0","_npmVersion":"11.8.0","dist":{"integrity":"sha512-pB60fmrjxFROrMLypR01nTsp+ekGtr1kjyjiatVfj/P1/KCEBSVfM4n9fwWYYWU1vrSTdLvOyyxBEcXbybod9g==","shasum":"7e9ba1a5d76cf1a44d787f8681f38bdde0edc446","tarball":"https://registry.npmjs.org/@dash0hq/codemirror-promql/-/codemirror-promql-0.302.1-dash03.tgz","fileCount":120,"unpackedSize":505015,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCICMv+X778VzZClj8RUbKcTd7DM1QBIqjM26a5A0Hck+CAiEA5WKNtXevI/H/28TecyJCzJWUIRNANtCikfSc/Z0ASMg="}]},"_npmUser":{"name":"mmanciop","email":"michele.mancioppi@gmail.com"},"directories":{},"maintainers":[{"name":"bripkens","email":"bripkens@gmail.com"},{"name":"basti1302","email":"bastian.krol@web.de"},{"name":"mmanciop","email":"michele.mancioppi@gmail.com"},{"name":"thiemok","email":"krausethiemo@googlemail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/codemirror-promql_0.302.1-dash03_1774862519968_0.2993746926750598"},"_hasShrinkwrap":false}},"time":{"created":"2025-04-25T16:15:05.830Z","modified":"2026-03-30T09:22:00.304Z","0.302.1":"2025-04-25T16:15:06.101Z","0.302.1-dash01":"2025-05-07T16:31:05.856Z","0.302.1-dash02":"2025-12-26T06:41:33.456Z","0.302.1-dash03":"2026-03-30T09:22:00.111Z"},"bugs":{"url":"https://github.com/prometheus/prometheus/issues"},"author":{"name":"Prometheus Authors","email":"prometheus-developers@googlegroups.com"},"license":"Apache-2.0","homepage":"https://github.com/prometheus/prometheus/blob/main/web/ui/module/codemirror-promql/README.md","keywords":["promql","codemirror","mode","prometheus"],"repository":{"type":"git","url":"git+https://github.com/prometheus/prometheus.git"},"description":"a CodeMirror mode for the PromQL language","maintainers":[{"name":"bripkens","email":"bripkens@gmail.com"},{"name":"basti1302","email":"bastian.krol@web.de"},{"name":"mmanciop","email":"michele.mancioppi@gmail.com"},{"name":"thiemok","email":"krausethiemo@googlemail.com"}],"readme":"CodeMirror-promql\n=================\n\nThis project provides a mode for [CodeMirror](https://codemirror.net/6/) that handles syntax highlighting, linting\nand autocompletion for PromQL ([Prometheus Query Language](https://prometheus.io/docs/introduction/overview/)).\n\n![preview](https://user-images.githubusercontent.com/4548045/95660829-d5e4b680-0b2a-11eb-9ecb-41dca6396273.gif)\n\n## Installation\n\nThis mode is available as a npm package:\n\n```bash\nnpm install --save @dash0hq/codemirror-promql\n```\n\n**Note:** You will have to manually install different packages that are part\nof [CodeMirror](https://codemirror.net/6/), as they are a peer dependency to this package. Here are the different\npackages you need to install:\n\n* **@codemirror/autocomplete**\n* **@codemirror/language**\n* **@codemirror/lint**\n* **@codemirror/state**\n* **@codemirror/view**\n* **@lezer/common**\n\n```bash\nnpm install --save @codemirror/autocomplete @codemirror/language @codemirror/lint @codemirror/state @codemirror/view @lezer/common\n```\n\n**Note 2**: that's the minimum required to install the lib. You would probably need to install as well the dependency\n**@codemirror/basic-setup** to ease the setup of codeMirror itself:\n\n```bash\nnpm install --save @codemirror/basic-setup\n```\n\n## Usage\n\nAs the setup of the PromQL language can a bit tricky in CMN, this lib provides a class `PromQLExtension`\nwhich is here to help you to configure the different extensions we aim to provide.\n\n### Default setup\n\nIf you want to enjoy about the different features provided without taking too much time to understand how to configure\nthem, then the easiest way is this one:\n\n```typescript\nimport {PromQLExtension} from '@dash0hq/codemirror-promql';\nimport {basicSetup} from '@codemirror/basic-setup';\nimport {EditorState} from '@codemirror/state';\nimport {EditorView} from '@codemirror/view';\n\nconst promQL = new PromQLExtension()\nnew EditorView({\n    state: EditorState.create({\n        extensions: [basicSetup, promQL.asExtension()],\n    }),\n    // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n    // tslint:disable-next-line:no-non-null-assertion\n    parent: document.getElementById('editor')!,\n});\n```\n\nUsing the default setup will activate:\n\n* syntax highlighting\n* an offline autocompletion that will suggest PromQL keywords such as functions / aggregations, depending on the\n  context.\n* an offline linter that will display PromQL syntax errors (which is closer to what Prometheus returns)\n\n### Deactivate autocompletion - linter\n\nIn case you would like to deactivate the linter and/or the autocompletion it's simple as that:\n\n```typescript\nconst promQL = new PromQLExtension().activateLinter(false).activateCompletion(false) // here the linter and the autocomplete are deactivated\n```\n\n### Linter\n\nThere is no particular configuration today for the linter. Feel free to file an issue if you have some use cases that\nwould require configurability.\n\n### Autocompletion\n\nThe autocompletion feature provides multiple different parameters that can be used to adapt this lib to your\nenvironment.\n\n#### maxMetricsMetadata\n\n`maxMetricsMetadata` is the maximum number of metrics in Prometheus for which metadata is fetched. If the number of\nmetrics exceeds this limit, no metric metadata is fetched at all.\n\nBy default, the limit is 10 000 metrics.\n\nUse it cautiously. A high value of this limit can cause a crash of your browser due to too many data fetched.\n\n```typescript\nconst promQL = new PromQLExtension().setComplete({maxMetricsMetadata: 10000})\n```\n\n#### Connect the autocompletion extension to a remote Prometheus server\n\nConnecting the autocompletion extension to a remote Prometheus server will provide autocompletion of metric names, label\nnames, and label values.\n\n##### Use the default Prometheus client\n\n###### Prometheus URL\n\nIf you want to use the default Prometheus client provided by this lib, you have to provide the url used to contact the\nPrometheus server.\n\nNote: this is the only mandatory parameter in case you want to use the default Prometheus client. Without this\nparameter, the rest of the config will be ignored, and the Prometheus client won't be initialized.\n\n```typescript\nconst promQL = new PromQLExtension().setComplete({remote: {url: 'https://prometheus.land'}})\n```\n\n###### Override FetchFn\n\nIn case your Prometheus server is protected and requires a special HTTP client, you can override the function `fetchFn`\nthat is used to perform any required HTTP request.\n\n```typescript\nconst promQL = new PromQLExtension().setComplete({remote: {fetchFn: myHTTPClient}})\n```\n\n###### Duration to use for looking back when retrieving metrics / labels\n\nIf you are a bit familiar with the Prometheus API, you are aware that you can pass a time interval that is used to tell\nto Prometheus which period of time you are looking for when retrieving metadata (like metrics / labels).\n\nIn case you would like to provide your own duration, you can override the variable `lookbackInterval`. By default, the\nvalue is `12 * 60 * 60 * 1000` (12h). The value must be defined in **milliseconds**.\n\n```typescript\nconst promQL = new PromQLExtension().setComplete({remote: {lookbackInterval: 12 * 60 * 60 * 1000}})\n```\n\n###### Error Handling\n\nYou can set up your own error handler to catch any HTTP error that can occur when the PrometheusClient is contacting\nPrometheus.\n\n```typescript\nconst promQL = new PromQLExtension().setComplete({remote: {httpErrorHandler: (error: any) => console.error(error)}})\n```\n\n###### HTTP method used\n\nBy default, the Prometheus client will use the HTTP method `POST` when contacting Prometheus for the\nendpoints `/api/v1/labels` and `/api/v1/series`.\n\nYou can change it to use the HTTP method `GET` if you prefer.\n\n```typescript\nconst promQL = new PromQLExtension().setComplete({remote: {httpMethod: 'GET'}})\n```\n\n###### HTTP request headers\n\nIf you need to send specific HTTP headers along with the requests to Prometheus, you can adjust that as follows:\n\n```typescript\nconst customHeaders = new Headers({'header-name': 'test-value'});\nconst promql = new PromQLExtension().setComplete({remote: {requestHeaders: customHeaders}})\n```\n\n###### Override the API Prefix\n\nThe default Prometheus Client, when building the query to get data from Prometheus, is using an API prefix which is by\ndefault `/api/v1`.\n\nYou can override this value like this:\n\n```typescript\nconst promql = new PromQLExtension().setComplete({remote: {apiPrefix: '/my/api/prefix'}})\n```\n\n###### Cache\n\nThe default client has an embedded cache that is used to store the different metrics and labels retrieved from a remote\nPrometheus server.\n\n###### Max Age\n\nThe data are stored in the cache for a limited amount of time defined by the variable `maxAge` which is by default 5\nminutes. The value must be defined in **milliseconds**.\n\n```typescript\nconst promQL = new PromQLExtension().setComplete({remote: {cache: {maxAge: 5 * 60 * 1000}}})\n```\n\n###### Initial Metric List\n\nThe cache can be initialized with a list of metric names. It is useful when you already have the list of the metrics\nsomewhere else in your application, and you would like to share this list with the embedded Prometheus client\nof `codemirror-promql`.\n\nNote: keep in mind that this list will be kept into the embedded Prometheus client until the time defined by `maxAge`.\n\n```typescript\nconst promQL = new PromQLExtension().setComplete({\n    remote: {\n        cache: {\n            initialMetricList: [\n                'ALERTS',\n                'ALERTS_FOR_STATE',\n                'alertmanager_alerts',\n                'alertmanager_alerts_invalid_total',\n                'alertmanager_alerts_received_total',\n            ]\n        }\n    }\n})\n```\n\n##### Override the default Prometheus client\n\nIn case you are not satisfied by our default Prometheus client, you can still provide your own. It has to implement the\ninterface [PrometheusClient](https://github.com/prometheus/codemirror-promql/blob/main/src/client/prometheus.ts#L24-L39)\n.\n\n```typescript\nconst promQL = new PromQLExtension().setComplete({remote: MyPrometheusClient})\n```\n\n#### Provide your own implementation of the autocompletion\n\nIn case you would like to provide you own implementation of the autocompletion, you can simply do it like that:\n\n```typescript\nconst promQL = new PromQLExtension().setComplete({completeStrategy: myCustomImpl})\n```\n\nNote: In case this parameter is provided, then the rest of the configuration is ignored.\n\n### Example\n\n* [ReactJS example](https://github.com/prometheus/prometheus/blob/431ea75a11ca165dad9dd5d629b3cf975f4c186b/web/ui/react-app/src/pages/graph/CMExpressionInput.tsx)\n* [Angular example](https://github.com/perses/perses/blob/28b3bdac88b0ed7a4602f9c91106442eafcb6c34/internal/api/front/perses/src/app/project/prometheusrule/promql-editor/promql-editor.component.ts)\n\n## License\n\nThe code is licensed under an [Apache 2.0](https://github.com/prometheus/prometheus/blob/main/LICENSE) license.\n","readmeFilename":"README.md"}