@wvlet/wvlet 2025.1.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,26 @@
1
+ import { CompileOptions } from './types.js';
2
+ /**
3
+ * Wvlet compiler for TypeScript/JavaScript
4
+ */
5
+ export declare class WvletCompiler {
6
+ private options;
7
+ /**
8
+ * Create a new Wvlet compiler instance
9
+ * @param options Default compilation options
10
+ */
11
+ constructor(options?: CompileOptions);
12
+ /**
13
+ * Compile a Wvlet query to SQL
14
+ * @param query The Wvlet query string
15
+ * @param options Override compilation options for this query
16
+ * @returns The compiled SQL string
17
+ * @throws {CompilationError} If compilation fails
18
+ */
19
+ compile(query: string, options?: CompileOptions): string;
20
+ /**
21
+ * Get the version of the Wvlet compiler
22
+ * @returns The version string
23
+ */
24
+ static getVersion(): string;
25
+ }
26
+ //# sourceMappingURL=compiler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compiler.d.ts","sourceRoot":"","sources":["../../src/compiler.ts"],"names":[],"mappings":"AACA,OAAO,EACL,cAAc,EAGf,MAAM,YAAY,CAAC;AAEpB;;GAEG;AACH,qBAAa,aAAa;IACxB,OAAO,CAAC,OAAO,CAAiB;IAEhC;;;OAGG;gBACS,OAAO,GAAE,cAAmB;IAOxC;;;;;;OAMG;IACH,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,MAAM;IA6BxD;;;OAGG;IACH,MAAM,CAAC,UAAU,IAAI,MAAM;CAG5B"}
@@ -0,0 +1,56 @@
1
+ import { WvletJS } from '../lib/main.js';
2
+ import { CompilationError } from './types.js';
3
+ /**
4
+ * Wvlet compiler for TypeScript/JavaScript
5
+ */
6
+ export class WvletCompiler {
7
+ /**
8
+ * Create a new Wvlet compiler instance
9
+ * @param options Default compilation options
10
+ */
11
+ constructor(options = {}) {
12
+ this.options = {
13
+ target: 'duckdb',
14
+ ...options
15
+ };
16
+ }
17
+ /**
18
+ * Compile a Wvlet query to SQL
19
+ * @param query The Wvlet query string
20
+ * @param options Override compilation options for this query
21
+ * @returns The compiled SQL string
22
+ * @throws {CompilationError} If compilation fails
23
+ */
24
+ compile(query, options) {
25
+ const compileOptions = { ...this.options, ...options };
26
+ const optionsJson = JSON.stringify(compileOptions);
27
+ try {
28
+ const responseJson = WvletJS.compile(query, optionsJson);
29
+ const response = JSON.parse(responseJson);
30
+ if (response.success && response.sql) {
31
+ return response.sql;
32
+ }
33
+ else if (response.error) {
34
+ throw new CompilationError(response.error.message, response.error.statusCode, response.error.location);
35
+ }
36
+ else {
37
+ throw new Error('Invalid response from compiler');
38
+ }
39
+ }
40
+ catch (error) {
41
+ if (error instanceof CompilationError) {
42
+ throw error;
43
+ }
44
+ // Re-throw original error to preserve stack trace
45
+ throw error;
46
+ }
47
+ }
48
+ /**
49
+ * Get the version of the Wvlet compiler
50
+ * @returns The version string
51
+ */
52
+ static getVersion() {
53
+ return WvletJS.getVersion();
54
+ }
55
+ }
56
+ //# sourceMappingURL=compiler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compiler.js","sourceRoot":"","sources":["../../src/compiler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AACzC,OAAO,EAGL,gBAAgB,EACjB,MAAM,YAAY,CAAC;AAEpB;;GAEG;AACH,MAAM,OAAO,aAAa;IAGxB;;;OAGG;IACH,YAAY,UAA0B,EAAE;QACtC,IAAI,CAAC,OAAO,GAAG;YACb,MAAM,EAAE,QAAQ;YAChB,GAAG,OAAO;SACX,CAAC;IACJ,CAAC;IAED;;;;;;OAMG;IACH,OAAO,CAAC,KAAa,EAAE,OAAwB;QAC7C,MAAM,cAAc,GAAG,EAAE,GAAG,IAAI,CAAC,OAAO,EAAE,GAAG,OAAO,EAAE,CAAC;QACvD,MAAM,WAAW,GAAG,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC;QAEnD,IAAI,CAAC;YACH,MAAM,YAAY,GAAG,OAAO,CAAC,OAAO,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC;YACzD,MAAM,QAAQ,GAAoB,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;YAE3D,IAAI,QAAQ,CAAC,OAAO,IAAI,QAAQ,CAAC,GAAG,EAAE,CAAC;gBACrC,OAAO,QAAQ,CAAC,GAAG,CAAC;YACtB,CAAC;iBAAM,IAAI,QAAQ,CAAC,KAAK,EAAE,CAAC;gBAC1B,MAAM,IAAI,gBAAgB,CACxB,QAAQ,CAAC,KAAK,CAAC,OAAO,EACtB,QAAQ,CAAC,KAAK,CAAC,UAAU,EACzB,QAAQ,CAAC,KAAK,CAAC,QAAQ,CACxB,CAAC;YACJ,CAAC;iBAAM,CAAC;gBACN,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAC;YACpD,CAAC;QACH,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,KAAK,YAAY,gBAAgB,EAAE,CAAC;gBACtC,MAAM,KAAK,CAAC;YACd,CAAC;YAED,kDAAkD;YAClD,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;IAED;;;OAGG;IACH,MAAM,CAAC,UAAU;QACf,OAAO,OAAO,CAAC,UAAU,EAAE,CAAC;IAC9B,CAAC;CACF"}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Wvlet TypeScript SDK
3
+ *
4
+ * A TypeScript/JavaScript SDK for the Wvlet query language compiler.
5
+ * Compile Wvlet queries to SQL for various database engines.
6
+ *
7
+ * @packageDocumentation
8
+ */
9
+ export { WvletCompiler } from './compiler.js';
10
+ export { CompileOptions, CompileResponse, CompileError, ErrorLocation, CompilationError } from './types.js';
11
+ /**
12
+ * Compile a Wvlet query to SQL using default options
13
+ * @param query The Wvlet query string
14
+ * @returns The compiled SQL string
15
+ * @throws {CompilationError} If compilation fails
16
+ */
17
+ export declare function compile(query: string): string;
18
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EACL,cAAc,EACd,eAAe,EACf,YAAY,EACZ,aAAa,EACb,gBAAgB,EACjB,MAAM,YAAY,CAAC;AAKpB;;;;;GAKG;AACH,wBAAgB,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAG7C"}
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Wvlet TypeScript SDK
3
+ *
4
+ * A TypeScript/JavaScript SDK for the Wvlet query language compiler.
5
+ * Compile Wvlet queries to SQL for various database engines.
6
+ *
7
+ * @packageDocumentation
8
+ */
9
+ export { WvletCompiler } from './compiler.js';
10
+ export { CompilationError } from './types.js';
11
+ // Re-export the default compiler function for convenience
12
+ import { WvletCompiler } from './compiler.js';
13
+ /**
14
+ * Compile a Wvlet query to SQL using default options
15
+ * @param query The Wvlet query string
16
+ * @returns The compiled SQL string
17
+ * @throws {CompilationError} If compilation fails
18
+ */
19
+ export function compile(query) {
20
+ const compiler = new WvletCompiler();
21
+ return compiler.compile(query);
22
+ }
23
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EAKL,gBAAgB,EACjB,MAAM,YAAY,CAAC;AAEpB,0DAA0D;AAC1D,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAE9C;;;;;GAKG;AACH,MAAM,UAAU,OAAO,CAAC,KAAa;IACnC,MAAM,QAAQ,GAAG,IAAI,aAAa,EAAE,CAAC;IACrC,OAAO,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AACjC,CAAC"}
@@ -0,0 +1,82 @@
1
+ /**
2
+ * Compilation options for Wvlet queries
3
+ */
4
+ export interface CompileOptions {
5
+ /**
6
+ * Target SQL dialect
7
+ * @default 'duckdb'
8
+ */
9
+ target?: 'duckdb' | 'trino';
10
+ /**
11
+ * Profile name for configuration
12
+ */
13
+ profile?: string;
14
+ }
15
+ /**
16
+ * Compilation response from the Wvlet compiler
17
+ */
18
+ export interface CompileResponse {
19
+ /**
20
+ * Whether the compilation was successful
21
+ */
22
+ success: boolean;
23
+ /**
24
+ * The compiled SQL query (if successful)
25
+ */
26
+ sql?: string;
27
+ /**
28
+ * Error information (if failed)
29
+ */
30
+ error?: CompileError;
31
+ }
32
+ /**
33
+ * Compilation error information
34
+ */
35
+ export interface CompileError {
36
+ /**
37
+ * Error status code
38
+ */
39
+ statusCode: string;
40
+ /**
41
+ * Human-readable error message
42
+ */
43
+ message: string;
44
+ /**
45
+ * Source location where the error occurred
46
+ */
47
+ location?: ErrorLocation;
48
+ }
49
+ /**
50
+ * Source location information for errors
51
+ */
52
+ export interface ErrorLocation {
53
+ /**
54
+ * Relative file path
55
+ */
56
+ path: string;
57
+ /**
58
+ * File name only
59
+ */
60
+ fileName: string;
61
+ /**
62
+ * Line number (1-based)
63
+ */
64
+ line: number;
65
+ /**
66
+ * Column number (1-based)
67
+ */
68
+ column: number;
69
+ /**
70
+ * Content of the source line
71
+ */
72
+ lineContent?: string;
73
+ }
74
+ /**
75
+ * Error thrown when compilation fails
76
+ */
77
+ export declare class CompilationError extends Error {
78
+ statusCode: string;
79
+ location?: ErrorLocation | undefined;
80
+ constructor(message: string, statusCode: string, location?: ErrorLocation | undefined);
81
+ }
82
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B;;;OAGG;IACH,MAAM,CAAC,EAAE,QAAQ,GAAG,OAAO,CAAC;IAE5B;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B;;OAEG;IACH,OAAO,EAAE,OAAO,CAAC;IAEjB;;OAEG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IAEb;;OAEG;IACH,KAAK,CAAC,EAAE,YAAY,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;IAEnB;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,QAAQ,CAAC,EAAE,aAAa,CAAC;CAC1B;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;IAEjB;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IAEf;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;GAEG;AACH,qBAAa,gBAAiB,SAAQ,KAAK;IAGhC,UAAU,EAAE,MAAM;IAClB,QAAQ,CAAC,EAAE,aAAa;gBAF/B,OAAO,EAAE,MAAM,EACR,UAAU,EAAE,MAAM,EAClB,QAAQ,CAAC,EAAE,aAAa,YAAA;CAKlC"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Error thrown when compilation fails
3
+ */
4
+ export class CompilationError extends Error {
5
+ constructor(message, statusCode, location) {
6
+ super(message);
7
+ this.statusCode = statusCode;
8
+ this.location = location;
9
+ this.name = 'CompilationError';
10
+ }
11
+ }
12
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAsFA;;GAEG;AACH,MAAM,OAAO,gBAAiB,SAAQ,KAAK;IACzC,YACE,OAAe,EACR,UAAkB,EAClB,QAAwB;QAE/B,KAAK,CAAC,OAAO,CAAC,CAAC;QAHR,eAAU,GAAV,UAAU,CAAQ;QAClB,aAAQ,GAAR,QAAQ,CAAgB;QAG/B,IAAI,CAAC,IAAI,GAAG,kBAAkB,CAAC;IACjC,CAAC;CACF"}