Files
zeekay 1b367e2b62 chore: rebase the tree onto upstream master
The tree was a debranded snapshot of upstream taken around 2026-02-20, and
upstream has moved about five months since. This replaces it with upstream
master, mechanically re-derived: bin/debrand does the rename, and the
pipeline and squashed migrations are restored from the shipped tree.

Not a merge. The previous import replaced the tree wholesale in a single
commit, so there is no shared content history to merge against. Reproducing
the rename on the new tree is what actually converges.

What survives: .hanzo/workflows, the Dockerfiles and bin/docker* entrypoints,
compose files, LLM.md, and insights/migrations. The squashed initial
migration is load-bearing — the live database records it by name, so
upstream's ~918 individual migrations cannot come back.

Nine products are dropped as unreferenced. Twenty-one more that we do not run
are kept anyway because the core app still imports them; unpicking those is a
refactor and does not belong in a rebase.

This base does not build yet, and the reasons are not in the rename:
upstream now wants Python 3.13.13 against our 3.12.12 and Django 5.2 against
our 4.2, and the dependency manifests still name upstream packages that we
republish under our own names. Those are decisions, not renames.
2026-08-01 15:44:40 -07:00

158 lines
4.2 KiB
TypeScript

/**
* InsightsQL Parser WebAssembly Module
*
* High-performance InsightsQL parser compiled to WebAssembly.
* All parse functions return JSON strings that should be parsed with JSON.parse().
*/
/**
* AST Position information
*/
export interface Position {
line: number
column: number
offset: number
}
/**
* Base AST node with position information
*/
export interface ASTNode {
node: string
start: Position
end: Position
[key: string]: any
}
/**
* Parse error object
*/
export interface ParseError {
error: true
type: 'SyntaxError' | 'ParsingError' | 'NotImplementedError'
message: string
start: Position
end: Position
}
/**
* Parse result - either an AST node or an error
*/
export type ParseResult = ASTNode | ParseError
/**
* InsightsQL Parser instance
*/
export interface InsightsQLParser {
/**
* Parse a InsightsQL expression
*
* @param input - The InsightsQL expression string to parse
* @param isInternal - If true, omits position information from the AST (default: false)
* @returns JSON string representing the AST or error
*
* @example
* ```typescript
* const result = parser.parseExpr('user_id + 100');
* const ast = JSON.parse(result);
* ```
*/
parseExpr(input: string, isInternal?: boolean): string
/**
* Parse a complete SELECT statement
*
* @param input - The SELECT statement string to parse
* @param isInternal - If true, omits position information from the AST (default: false)
* @returns JSON string representing the AST or error
*
* @example
* ```typescript
* const result = parser.parseSelect('SELECT * FROM events WHERE timestamp > now()');
* const ast = JSON.parse(result);
* ```
*/
parseSelect(input: string, isInternal?: boolean): string
/**
* Parse an ORDER BY expression
*
* @param input - The ORDER BY expression string to parse
* @param isInternal - If true, omits position information from the AST (default: false)
* @returns JSON string representing the AST or error
*
* @example
* ```typescript
* const result = parser.parseOrderExpr('timestamp DESC, user_id ASC');
* const ast = JSON.parse(result);
* ```
*/
parseOrderExpr(input: string, isInternal?: boolean): string
/**
* Parse a complete Script program
*
* @param input - The Script program string to parse
* @param isInternal - If true, omits position information from the AST (default: false)
* @returns JSON string representing the AST or error
*
* @example
* ```typescript
* const result = parser.parseProgram('let x := 42; return x;');
* const ast = JSON.parse(result);
* ```
*/
parseProgram(input: string, isInternal?: boolean): string
/**
* Parse a Script template string (f'...' syntax)
*
* @param input - The template string to parse
* @param isInternal - If true, omits position information from the AST (default: false)
* @returns JSON string representing the AST or error
*
* @example
* ```typescript
* const result = parser.parseFullTemplateString("f'Hello {name}'");
* const ast = JSON.parse(result);
* ```
*/
parseFullTemplateString(input: string, isInternal?: boolean): string
/**
* Unquote a string literal
*
* @param input - The quoted string literal
* @returns The unquoted string content
*
* @example
* ```typescript
* const text = parser.parseStringLiteralText("'hello world'");
* // Returns: "hello world"
* ```
*/
parseStringLiteralText(input: string): string
}
/**
* Factory function to create a InsightsQL Parser instance
*
* @returns Promise that resolves to a InsightsQLParser instance
*
* @example
* ```typescript
* import createInsightsQLParser from '@hanzo/insightsql-parser';
*
* const parser = await createInsightsQLParser();
* const result = parser.parseExpr('1 + 2');
* const ast: ParseResult = JSON.parse(result);
*
* if ('error' in ast) {
* console.error('Parse error:', ast.message);
* } else {
* console.log('Parsed successfully:', ast);
* }
* ```
*/
export default function createInsightsQLParser(): Promise<InsightsQLParser>