Files
zeekay e4a276e409 brand: no upstream art, no third-party image hosts, the SDK is ours everywhere
Workflow template cards, the template choosers, the auth wallpaper, insight
previews, partner pages, SDK logos and every fixture stop pulling posthog's
cloudinary; the CSP stops allowing it. The mascot easter egg leaves with its
sprite package. insights-js resolves to @hanzo/insights for every consumer —
the react wrapper's peer included, via a workspace package that carries the
name — and its rrweb siblings map to our published forks. Icon names that
outran our icon release alias to shipped glyphs.
2026-08-06 11:21:45 -07:00

131 lines
4.0 KiB
Plaintext

Metadata-Version: 2.4
Name: insightsql_parser
Version: 1.3.83
Summary: InsightsQL parser for internal Insights use
Home-page: https://github.com/Insights/insights/tree/master/common/insightsql_parser
Author: Insights Inc.
Author-email: [email protected]
Maintainer: Insights Inc.
Maintainer-email: [email protected]
License: MIT
Classifier: Development Status :: 5 - Production/Stable
Classifier: Operating System :: MacOS
Classifier: Operating System :: POSIX :: Linux
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Requires-Python: >=3.10
Description-Content-Type: text/markdown
Dynamic: author
Dynamic: author-email
Dynamic: classifier
Dynamic: description
Dynamic: description-content-type
Dynamic: home-page
Dynamic: license
Dynamic: maintainer
Dynamic: maintainer-email
Dynamic: requires-python
Dynamic: summary
# InsightsQL Parser
ANTLR4-based parser for [InsightsQL](https://hanzo.ai/docs/insightsql) and [Script](https://hanzo.ai/docs/script),
available as both a Python C++ extension and a WebAssembly module for JavaScript/TypeScript.
## Packages
| Package | Runtime | Registry |
| ----------------------- | -------------------------------- | ---------------------------------------------------------- |
| `insightsql_parser` | CPython (native C++ extension) | [PyPI](https://pypi.org/project/insightsql-parser/) |
| `@hanzo/insightsql-parser` | Any JS environment (WebAssembly) | [npm](https://www.npmjs.com/package/@hanzo/insightsql-parser) |
Both packages share the same C++ parser core and ANTLR4 grammar,
so they produce identical ASTs.
## npm package (`@hanzo/insightsql-parser`)
### Installation
```bash
npm install @hanzo/insightsql-parser
```
### Usage
```typescript
import createInsightsQLParser from '@hanzo/insightsql-parser'
const parser = await createInsightsQLParser()
// Parse a InsightsQL expression
const exprAST = JSON.parse(parser.parseExpr('1 + 2'))
// Parse a SELECT statement
const selectAST = JSON.parse(parser.parseSelect('SELECT event FROM events WHERE timestamp > now()'))
// Parse a Script program
const programAST = JSON.parse(parser.parseProgram('let x := 42; return x;'))
```
All parse functions return JSON strings.
On failure they return a JSON error object instead of throwing:
```typescript
const result = JSON.parse(parser.parseExpr('!!!'))
if ('error' in result) {
console.error(result.type, result.message) // e.g. "SyntaxError ..."
}
```
### API
| Method | Description |
| --------------------------------------------- | ---------------------------------- |
| `parseExpr(input, isInternal?)` | Parse a InsightsQL expression |
| `parseSelect(input, isInternal?)` | Parse a SELECT statement |
| `parseOrderExpr(input, isInternal?)` | Parse an ORDER BY expression |
| `parseProgram(input, isInternal?)` | Parse a Script program |
| `parseFullTemplateString(input, isInternal?)` | Parse a template string (`f'...'`) |
| `parseStringLiteralText(input)` | Unquote a string literal |
Setting `isInternal` to `true` omits position information from the AST.
## Python package (`insightsql_parser`)
### Installation
```bash
pip install insightsql_parser
```
The Python package is a native C++ extension and requires a platform with prebuilt wheels
(macOS and Linux, x86_64 and arm64).
### Local development
```bash
pip install ./common/insightsql_parser
```
## Building from source
### Python
```bash
pip install ./common/insightsql_parser
```
### WebAssembly
Requires the [Emscripten](https://emscripten.org/) toolchain and [Ninja](https://ninja-build.org/).
```bash
cd common/insightsql_parser
npm run build
```
This compiles the parser to WASM and places the output in `dist/`.