@cognica-io/uqa-wasm 0.1.6
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.
- package/LICENSE +661 -0
- package/LICENSE-NOTICE.md +11 -0
- package/LICENSES/UQA-FOSS-EXCEPTION-1.0.txt +85 -0
- package/LICENSES/UQA-NONCOMMERCIAL-EXCEPTION-1.0.txt +96 -0
- package/LICENSING.md +81 -0
- package/README.md +27 -0
- package/index.d.ts +259 -0
- package/index.mjs +1543 -0
- package/package.json +34 -0
- package/uqa.js +2 -0
- package/uqa.wasm +0 -0
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
UQA Engine FOSS Exception
|
|
2
|
+
Version 1.0, 3 August 2026
|
|
3
|
+
|
|
4
|
+
Copyright (c) 2023-2026 Cognica, Inc.
|
|
5
|
+
|
|
6
|
+
This Exception is an additional permission under section 7 of the GNU Affero
|
|
7
|
+
General Public License version 3 (the "AGPL"). It applies only to UQA Engine
|
|
8
|
+
material for which Cognica, Inc. has authority to grant this permission (the
|
|
9
|
+
"Program") and that is distributed with a notice referring to this Exception.
|
|
10
|
+
|
|
11
|
+
1. Definitions
|
|
12
|
+
|
|
13
|
+
"Application" means a work, other than the Program, that uses the Program
|
|
14
|
+
through a documented interface. Interfaces include Rust crate interfaces,
|
|
15
|
+
application binary interfaces, static or dynamic linking, foreign-function
|
|
16
|
+
interfaces, inter-process interfaces, language bindings, module imports, and
|
|
17
|
+
WebAssembly imports or bundling.
|
|
18
|
+
|
|
19
|
+
"Qualifying FOSS Application" means an Application for which:
|
|
20
|
+
|
|
21
|
+
a. the complete source code of the Application is made available under one
|
|
22
|
+
or more licenses approved by the Open Source Initiative at the time the
|
|
23
|
+
Application is conveyed or made available for remote use;
|
|
24
|
+
|
|
25
|
+
b. the source provided is the form preferred for making modifications and
|
|
26
|
+
includes the material reasonably required to build and run the
|
|
27
|
+
Application, excluding the Program, System Libraries as defined by the
|
|
28
|
+
AGPL, and unmodified third-party dependencies under their own licenses;
|
|
29
|
+
and
|
|
30
|
+
|
|
31
|
+
c. the Application is not merely a nominal or thin open-source wrapper whose
|
|
32
|
+
effective function is supplied by proprietary application code combined
|
|
33
|
+
with, loaded by, controlled by, or specifically designed for that
|
|
34
|
+
wrapper.
|
|
35
|
+
|
|
36
|
+
"Combined Work" means a work formed by combining the Program with a
|
|
37
|
+
Qualifying FOSS Application through one or more Interfaces.
|
|
38
|
+
|
|
39
|
+
2. Additional permission
|
|
40
|
+
|
|
41
|
+
To the extent permitted by the applicable license or licenses of the
|
|
42
|
+
Qualifying FOSS Application, you may combine the Program with that Application
|
|
43
|
+
and run, reproduce, and convey the resulting Combined Work without applying
|
|
44
|
+
the AGPL to the independent code of the Qualifying FOSS Application solely
|
|
45
|
+
because of that combination. The independent application code may remain
|
|
46
|
+
under its applicable OSI-approved license or licenses.
|
|
47
|
+
|
|
48
|
+
You may reproduce the minimum interface declarations reasonably necessary to
|
|
49
|
+
perform that combination without changing the license of the independent
|
|
50
|
+
application code. This permission does not extend to copied implementation
|
|
51
|
+
code from the Program.
|
|
52
|
+
|
|
53
|
+
3. Conditions and retained obligations
|
|
54
|
+
|
|
55
|
+
This Exception does not relicense the Program. The Program, modifications to
|
|
56
|
+
the Program, and Program implementation code copied into another work remain
|
|
57
|
+
governed by the AGPL. All AGPL obligations that apply to those portions,
|
|
58
|
+
including corresponding-source and remote-network-interaction obligations,
|
|
59
|
+
remain in force.
|
|
60
|
+
|
|
61
|
+
When conveying or making a Combined Work available under this Exception, you
|
|
62
|
+
must provide a copy of this Exception with the licensing notices for the
|
|
63
|
+
Program and identify the Program portions as AGPL-3.0-only with this additional
|
|
64
|
+
permission.
|
|
65
|
+
|
|
66
|
+
No permission is granted for a proprietary Application, for an Application
|
|
67
|
+
whose complete source is not available as required above, or for proprietary
|
|
68
|
+
modules that form part of the effective Application. If the requirements of
|
|
69
|
+
this Exception are not met, no additional permission is granted; rights that
|
|
70
|
+
you otherwise have under the AGPL remain unaffected.
|
|
71
|
+
|
|
72
|
+
This Exception grants permission only from the copyright holders of the
|
|
73
|
+
Program. It does not alter the license of the Qualifying FOSS Application or
|
|
74
|
+
guarantee that the Application's license permits the proposed combination.
|
|
75
|
+
|
|
76
|
+
4. No trademark or third-party grant
|
|
77
|
+
|
|
78
|
+
This Exception grants no right to use Cognica or UQA trademarks. It grants no
|
|
79
|
+
right in third-party material included with or used by the Program.
|
|
80
|
+
|
|
81
|
+
5. Removal
|
|
82
|
+
|
|
83
|
+
You may remove this additional permission from a copy or modified version as
|
|
84
|
+
allowed by section 7 of the AGPL. A copy from which it has been removed remains
|
|
85
|
+
available under the AGPL without this Exception.
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
UQA Engine Noncommercial Application Exception
|
|
2
|
+
Version 1.0, 3 August 2026
|
|
3
|
+
|
|
4
|
+
Copyright (c) 2023-2026 Cognica, Inc.
|
|
5
|
+
|
|
6
|
+
This Exception is an additional permission under section 7 of the GNU Affero
|
|
7
|
+
General Public License version 3 (the "AGPL"). It applies only to UQA Engine
|
|
8
|
+
material for which Cognica, Inc. has authority to grant this permission (the
|
|
9
|
+
"Program") and that is distributed with a notice referring to this Exception.
|
|
10
|
+
|
|
11
|
+
The AGPL itself permits commercial use. This Exception does not prohibit,
|
|
12
|
+
limit, or charge for any activity already permitted by the AGPL. It grants an
|
|
13
|
+
optional additional permission only for the qualifying uses defined below.
|
|
14
|
+
|
|
15
|
+
1. Definitions
|
|
16
|
+
|
|
17
|
+
"Application" means a work, other than the Program, that uses the Program
|
|
18
|
+
through a documented interface. Interfaces include Rust crate interfaces,
|
|
19
|
+
application binary interfaces, static or dynamic linking, foreign-function
|
|
20
|
+
interfaces, inter-process interfaces, language bindings, module imports, and
|
|
21
|
+
WebAssembly imports or bundling.
|
|
22
|
+
|
|
23
|
+
"Eligible User" means:
|
|
24
|
+
|
|
25
|
+
a. a natural person acting only on that person's own behalf;
|
|
26
|
+
|
|
27
|
+
b. an accredited educational institution or public research institution;
|
|
28
|
+
or
|
|
29
|
+
|
|
30
|
+
c. a nonprofit or charitable organization that does not distribute profits
|
|
31
|
+
to private owners or shareholders.
|
|
32
|
+
|
|
33
|
+
"Noncommercial Purpose" means personal learning, teaching, independent
|
|
34
|
+
academic research, reproducibility research, or charitable research that:
|
|
35
|
+
|
|
36
|
+
a. is not performed for direct or indirect monetary compensation or
|
|
37
|
+
commercial advantage;
|
|
38
|
+
|
|
39
|
+
b. does not support production operations, customer workloads, paid
|
|
40
|
+
consulting, advertising, subscriptions, sales, licensing, or another
|
|
41
|
+
revenue-generating activity;
|
|
42
|
+
|
|
43
|
+
c. is not development, testing, or evaluation of a product or service that
|
|
44
|
+
is intended for commercial use; and
|
|
45
|
+
|
|
46
|
+
d. is not performed for a for-profit sponsor that receives proprietary,
|
|
47
|
+
exclusive, or preferential rights in the work or its results.
|
|
48
|
+
|
|
49
|
+
"Qualifying Noncommercial Application" means an Application used and, if
|
|
50
|
+
applicable, conveyed by an Eligible User solely for a Noncommercial Purpose.
|
|
51
|
+
|
|
52
|
+
2. Additional permission
|
|
53
|
+
|
|
54
|
+
An Eligible User may combine the Program with a Qualifying Noncommercial
|
|
55
|
+
Application and use, reproduce, and convey the resulting combination without
|
|
56
|
+
applying the AGPL to the independent code of that Application solely because
|
|
57
|
+
of that combination. The independent application code may remain private or
|
|
58
|
+
under terms chosen by its copyright holder.
|
|
59
|
+
|
|
60
|
+
You may reproduce the minimum interface declarations reasonably necessary to
|
|
61
|
+
perform that combination without changing the license of the independent
|
|
62
|
+
application code. This permission does not extend to copied implementation
|
|
63
|
+
code from the Program.
|
|
64
|
+
|
|
65
|
+
3. Conditions and retained obligations
|
|
66
|
+
|
|
67
|
+
This Exception does not relicense the Program. The Program, modifications to
|
|
68
|
+
the Program, and Program implementation code copied into another work remain
|
|
69
|
+
governed by the AGPL. All AGPL obligations that apply to those portions,
|
|
70
|
+
including corresponding-source and remote-network-interaction obligations,
|
|
71
|
+
remain in force.
|
|
72
|
+
|
|
73
|
+
When conveying an application under this Exception, you must provide a copy of
|
|
74
|
+
this Exception with the licensing notices for the Program and identify the
|
|
75
|
+
Program portions as AGPL-3.0-only with this additional permission.
|
|
76
|
+
|
|
77
|
+
Each user and each use must independently satisfy the definitions above. If a
|
|
78
|
+
user or use ceases to qualify, this additional permission no longer applies to
|
|
79
|
+
that use. The user may continue under the AGPL or under separate written terms
|
|
80
|
+
from Cognica. Rights that the user otherwise has under the AGPL remain
|
|
81
|
+
unaffected.
|
|
82
|
+
|
|
83
|
+
Use by a for-profit entity, government operational use, paid or commercially
|
|
84
|
+
sponsored research, and commercial evaluation are not presumed to qualify.
|
|
85
|
+
They require compliance with the AGPL or separate written terms from Cognica.
|
|
86
|
+
|
|
87
|
+
4. No trademark or third-party grant
|
|
88
|
+
|
|
89
|
+
This Exception grants no right to use Cognica or UQA trademarks. It grants no
|
|
90
|
+
right in third-party material included with or used by the Program.
|
|
91
|
+
|
|
92
|
+
5. Removal
|
|
93
|
+
|
|
94
|
+
You may remove this additional permission from a copy or modified version as
|
|
95
|
+
allowed by section 7 of the AGPL. A copy from which it has been removed remains
|
|
96
|
+
available under the AGPL without this Exception.
|
package/LICENSING.md
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
# UQA Engine Licensing Policy
|
|
2
|
+
|
|
3
|
+
Policy version 1.0, effective 2026-08-03.
|
|
4
|
+
|
|
5
|
+
UQA Engine is open-source software licensed under the GNU Affero General Public License version 3 only (`AGPL-3.0-only`). Cognica, Inc. also provides two optional additional permissions and offers separate commercial terms. These alternatives do not revoke or reduce any right granted by the AGPL.
|
|
6
|
+
|
|
7
|
+
The legal terms are the [AGPL license](LICENSE) and the applicable exception text. This document explains how the available paths are intended to work; it does not replace those terms.
|
|
8
|
+
|
|
9
|
+
## Public-core commitment
|
|
10
|
+
|
|
11
|
+
Code accepted into the public UQA Engine core will remain available under at least one license approved by the Open Source Initiative. A commercial license for a release does not withdraw, terminate, or narrow rights already granted for that release under an open-source license.
|
|
12
|
+
|
|
13
|
+
## Available paths
|
|
14
|
+
|
|
15
|
+
| Path | Who may use it | License of an independent application | License of UQA Engine and modifications to UQA Engine |
|
|
16
|
+
| --- | --- | --- | --- |
|
|
17
|
+
| AGPL | Anyone, including commercial users | Governed by the AGPL to the extent the AGPL applies | AGPL-3.0-only |
|
|
18
|
+
| FOSS exception | A complete qualifying open-source application | May remain under its OSI-approved license | AGPL-3.0-only |
|
|
19
|
+
| Noncommercial exception | A qualifying personal, educational, academic, or charitable application | May remain under terms chosen by its author | AGPL-3.0-only |
|
|
20
|
+
| Commercial license | A customer with a signed agreement from Cognica | May remain proprietary as agreed | May remain proprietary as agreed |
|
|
21
|
+
|
|
22
|
+
Commercial activity is not prohibited by the AGPL. A business may use UQA Engine without paying a fee if it complies with the AGPL or qualifies for the FOSS exception. A commercial license is an alternative for a customer that needs rights beyond those public terms.
|
|
23
|
+
|
|
24
|
+
## 1. AGPL-3.0-only
|
|
25
|
+
|
|
26
|
+
The AGPL is the default license for the complete repository and all published packages unless a file or package states otherwise. It permits use for any purpose, including commercial use, subject to its conditions.
|
|
27
|
+
|
|
28
|
+
Use this path when the complete deployment and distribution can comply with the AGPL. The two public exceptions are optional; no one is required to use them.
|
|
29
|
+
|
|
30
|
+
## 2. FOSS exception
|
|
31
|
+
|
|
32
|
+
The [UQA Engine FOSS Exception](LICENSES/UQA-FOSS-EXCEPTION-1.0.txt) permits a qualifying application distributed with complete source under an OSI-approved license to combine with UQA Engine without changing the license of the application's independent code solely because of that combination.
|
|
33
|
+
|
|
34
|
+
The exception covers ordinary integration mechanisms, including static or dynamic linking, Rust dependencies, foreign-function interfaces, language bindings, imports, and WebAssembly bundling. It does not relicense UQA Engine as Apache-2.0, MIT, MPL-2.0, or the application's license. UQA Engine, copied UQA Engine implementation code, and modifications to UQA Engine remain under the AGPL. The application's own license must also permit the proposed combination; OSI approval alone does not guarantee license compatibility in every direction.
|
|
35
|
+
|
|
36
|
+
A commercial organization may use this exception when the complete application genuinely qualifies as open-source software. Publishing only a thin wrapper while keeping the effective application proprietary does not qualify.
|
|
37
|
+
|
|
38
|
+
## 3. Noncommercial exception
|
|
39
|
+
|
|
40
|
+
The [UQA Engine Noncommercial Application Exception](LICENSES/UQA-NONCOMMERCIAL-EXCEPTION-1.0.txt) permits a qualifying personal, educational, academic-research, or charitable application to keep its independent application code under terms chosen by its author.
|
|
41
|
+
|
|
42
|
+
The exception does not permit UQA Engine itself or modifications to UQA Engine to become proprietary. It does not cover paid services, advertising or subscription-supported services, customer workloads, commercial product development, consulting, or research performed for a for-profit sponsor that receives proprietary or exclusive results.
|
|
43
|
+
|
|
44
|
+
For-profit evaluation and proof-of-concept use are not automatically covered by this exception. Contact Cognica for written evaluation or commercial terms when the ordinary AGPL path is unsuitable.
|
|
45
|
+
|
|
46
|
+
## 4. Commercial license
|
|
47
|
+
|
|
48
|
+
Cognica offers separate commercial terms for proprietary applications, closed modifications, software-as-a-service deployments, OEM distribution, devices, appliances, and customers that require contractual support, warranties, or other assurances. See [COMMERCIAL.md](https://github.com/cognica-io/uqa-engine/blob/main/COMMERCIAL.md).
|
|
49
|
+
|
|
50
|
+
A commercial license is granted only through a separate signed agreement. The public repository does not itself grant commercial-license rights.
|
|
51
|
+
|
|
52
|
+
## Common cases
|
|
53
|
+
|
|
54
|
+
| Scenario | Expected path |
|
|
55
|
+
| --- | --- |
|
|
56
|
+
| An AGPL service publishes its complete corresponding source | AGPL |
|
|
57
|
+
| A company distributes a complete Apache-2.0 application that embeds UQA Engine | FOSS exception |
|
|
58
|
+
| An individual builds a private, unpaid learning project | Noncommercial exception |
|
|
59
|
+
| A university conducts independent academic research without proprietary sponsorship | Noncommercial exception |
|
|
60
|
+
| A company evaluates UQA Engine internally under the AGPL | AGPL |
|
|
61
|
+
| A proprietary SaaS product keeps its application and UQA Engine changes closed | Commercial license |
|
|
62
|
+
| An OEM embeds UQA Engine in a closed product or device | Commercial license |
|
|
63
|
+
| A proprietary product publishes only a thin open-source wrapper around UQA Engine | AGPL or commercial license; the FOSS exception does not apply |
|
|
64
|
+
|
|
65
|
+
## Third-party software
|
|
66
|
+
|
|
67
|
+
These terms apply only to material for which Cognica has authority to grant the stated rights. Dependencies, bundled libraries, data sets, models, and other third-party material remain governed by their own licenses and notices. A commercial agreement from Cognica does not replace third-party obligations.
|
|
68
|
+
|
|
69
|
+
## Package metadata and distributions
|
|
70
|
+
|
|
71
|
+
Cargo, Python, Node.js, and WebAssembly package metadata reports `AGPL-3.0-only` because the AGPL is the base open-source license. The two exceptions are additional permissions, not a choice to relicense UQA Engine under the application's license.
|
|
72
|
+
|
|
73
|
+
Official source and registry distributions must carry a licensing notice that identifies this policy and the applicable exception texts. A copy that does not carry an exception notice remains available under the AGPL but does not grant that optional exception. Redistributors relying on an exception must include the applicable exception text as required by that exception.
|
|
74
|
+
|
|
75
|
+
## Contributions
|
|
76
|
+
|
|
77
|
+
Alternative licensing requires Cognica to retain sufficient rights in every accepted contribution. External copyrightable contributions of code or documentation are governed by [CONTRIBUTOR_POLICY.md](https://github.com/cognica-io/uqa-engine/blob/main/CONTRIBUTOR_POLICY.md). Issues, design discussion, bug reports, and other feedback that do not contribute copyrightable material do not require a contributor agreement.
|
|
78
|
+
|
|
79
|
+
## Questions
|
|
80
|
+
|
|
81
|
+
Licensing questions and requests for evaluation or commercial terms may be sent to `jaepil@cognica.io`. Obtain independent legal advice for a definitive interpretation of how a license applies to a particular product or deployment.
|
package/README.md
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# UQA for Browser WebAssembly
|
|
2
|
+
|
|
3
|
+
`@cognica-io/uqa-wasm` provides the embedded UQA Engine and direct local or Cloud HTTP SQL for browser applications through WebAssembly.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
npm install @cognica-io/uqa-wasm
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Use
|
|
12
|
+
|
|
13
|
+
```javascript
|
|
14
|
+
import { Engine, UQA } from "@cognica-io/uqa-wasm";
|
|
15
|
+
|
|
16
|
+
await UQA.load();
|
|
17
|
+
const engine = await Engine.open(`${UQA.persistDir}/notes.uqa`);
|
|
18
|
+
const result = await engine.sql("SELECT 1 AS n");
|
|
19
|
+
console.log(result.rows);
|
|
20
|
+
engine.close();
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
See the [UQA Engine manual](https://github.com/cognica-io/uqa-engine/blob/main/docs/manual/reference/08-bindings-and-extensions.md) for the complete Browser WASM binding contract.
|
|
24
|
+
|
|
25
|
+
## License
|
|
26
|
+
|
|
27
|
+
UQA Engine is licensed under AGPL-3.0-only with optional FOSS and noncommercial application exceptions. See `LICENSING.md` in this package.
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Unified Query Algebra
|
|
3
|
+
//
|
|
4
|
+
// Copyright (c) 2023-2026 Cognica, Inc.
|
|
5
|
+
//
|
|
6
|
+
|
|
7
|
+
export type JSValue =
|
|
8
|
+
| null
|
|
9
|
+
| boolean
|
|
10
|
+
| number
|
|
11
|
+
| string
|
|
12
|
+
| Uint8Array
|
|
13
|
+
| JSValue[]
|
|
14
|
+
| { [key: string]: JSValue };
|
|
15
|
+
|
|
16
|
+
export type ParamInput = SQLParam | JSValue;
|
|
17
|
+
|
|
18
|
+
export type SQLFunctionVolatility = "volatile" | "stable" | "immutable";
|
|
19
|
+
|
|
20
|
+
export interface SQLFunctionOptions {
|
|
21
|
+
volatility?: SQLFunctionVolatility;
|
|
22
|
+
mayMutateEngine?: boolean;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export type SQLTableFunctionRows = JSValue[][] | Array<Record<string, JSValue>>;
|
|
26
|
+
|
|
27
|
+
export type SQLTableFunctionResult =
|
|
28
|
+
| { columns: string[]; rows: SQLTableFunctionRows }
|
|
29
|
+
| [string[], SQLTableFunctionRows];
|
|
30
|
+
|
|
31
|
+
export type SQLAggregateState =
|
|
32
|
+
& ({ observe(...args: JSValue[]): unknown } | { step(...args: JSValue[]): unknown })
|
|
33
|
+
& ({ finish(): JSValue } | { finalize(): JSValue });
|
|
34
|
+
|
|
35
|
+
export interface SQLResult {
|
|
36
|
+
columns: string[];
|
|
37
|
+
rows: Array<Record<string, JSValue>>;
|
|
38
|
+
affectedRows: number;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export interface HttpSQLExecution {
|
|
42
|
+
result: SQLResult;
|
|
43
|
+
requestId: string;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export interface HttpSQLBatchExecution {
|
|
47
|
+
results: SQLResult[];
|
|
48
|
+
requestId: string;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export type HttpSQLStreamFrame =
|
|
52
|
+
| { type: "metadata"; columns: string[]; rowCount: number; spilledToDisk: boolean; requestId: string }
|
|
53
|
+
| { type: "row"; row: Record<string, JSValue> }
|
|
54
|
+
| { type: "complete"; rowCount: number; requestId: string }
|
|
55
|
+
| { type: "error"; code: string; message: string; requestId: string };
|
|
56
|
+
|
|
57
|
+
export declare class HttpEngineError extends Error {
|
|
58
|
+
readonly code?: string;
|
|
59
|
+
readonly status?: number;
|
|
60
|
+
readonly requestId?: string;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export declare class HttpSQLStream implements AsyncIterable<HttpSQLStreamFrame> {
|
|
64
|
+
readonly requestId: string;
|
|
65
|
+
nextFrame(): Promise<HttpSQLStreamFrame | null>;
|
|
66
|
+
[Symbol.asyncIterator](): AsyncIterator<HttpSQLStreamFrame>;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export declare class HttpEngine {
|
|
70
|
+
constructor(url: string, token: string);
|
|
71
|
+
static fromEnv(environment?: { UQA_URL?: string; UQA_TOKEN?: string }): HttpEngine;
|
|
72
|
+
sql(query: string, params?: ParamInput[]): Promise<SQLResult>;
|
|
73
|
+
sqlWithMetadata(query: string, params?: ParamInput[]): Promise<HttpSQLExecution>;
|
|
74
|
+
sqlBatch(statements: Array<[string, ParamInput[]]>): Promise<SQLResult[]>;
|
|
75
|
+
sqlBatchWithMetadata(statements: Array<[string, ParamInput[]]>): Promise<HttpSQLBatchExecution>;
|
|
76
|
+
sqlStream(query: string, params?: ParamInput[]): Promise<HttpSQLStream>;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export interface SearchHit {
|
|
80
|
+
docId: number;
|
|
81
|
+
score: number;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export interface SQLNotice {
|
|
85
|
+
level: string;
|
|
86
|
+
message: string;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export interface ReliabilityBin {
|
|
90
|
+
avgPredicted: number;
|
|
91
|
+
avgActual: number;
|
|
92
|
+
count: number;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export interface CalibrationReport {
|
|
96
|
+
ece: number;
|
|
97
|
+
brier: number;
|
|
98
|
+
logLoss: number;
|
|
99
|
+
bins: ReliabilityBin[];
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export interface CompressionOptions {
|
|
103
|
+
codec?: string;
|
|
104
|
+
pageSize?: number;
|
|
105
|
+
chunkPages?: number;
|
|
106
|
+
level?: number;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/** Tagged SQL parameter (vector / tensor); scalars pass directly. */
|
|
110
|
+
export declare class SQLParam {
|
|
111
|
+
static scalar(value: JSValue | bigint): SQLParam;
|
|
112
|
+
static vector(values: Float32Array | number[]): SQLParam;
|
|
113
|
+
static tensor(values: Array<Float32Array | number[]>): SQLParam;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export declare function vector(values: Float32Array | number[]): SQLParam;
|
|
117
|
+
export declare function tensor(values: Array<Float32Array | number[]>): SQLParam;
|
|
118
|
+
|
|
119
|
+
export declare const UQA: {
|
|
120
|
+
/** Preload the WASM module and restore persisted databases. */
|
|
121
|
+
load(): Promise<void>;
|
|
122
|
+
/** Flush every persistent database to IndexedDB; rejects when IndexedDB is unavailable. */
|
|
123
|
+
persist(): Promise<void>;
|
|
124
|
+
/** Directory on the virtual filesystem that persists to IndexedDB. */
|
|
125
|
+
persistDir: string;
|
|
126
|
+
detectDatabaseFile(
|
|
127
|
+
path: string
|
|
128
|
+
): Promise<"missing" | "sqlite" | "compressed" | "compressed_encrypted" | "unrecognized">;
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
export declare class Engine {
|
|
132
|
+
/** Create an in-memory engine. */
|
|
133
|
+
static inMemory(): Promise<Engine>;
|
|
134
|
+
/**
|
|
135
|
+
* Open a persistent database on the virtual filesystem. Place it
|
|
136
|
+
* under `UQA.persistDir` and call `UQA.persist()` to survive page
|
|
137
|
+
* reloads. Encryption is not available in browser builds.
|
|
138
|
+
*/
|
|
139
|
+
static open(path: string): Promise<Engine>;
|
|
140
|
+
static openAuto(path: string): Promise<Engine>;
|
|
141
|
+
static openCompressed(path: string, options?: CompressionOptions): Promise<Engine>;
|
|
142
|
+
|
|
143
|
+
/** Create an independent SQL session over the same persistent database. */
|
|
144
|
+
newSession(): Promise<Engine>;
|
|
145
|
+
|
|
146
|
+
sql(query: string, params?: ParamInput[]): Promise<SQLResult>;
|
|
147
|
+
sqlBatch(statements: Array<[string, ParamInput[]]>): Promise<SQLResult[]>;
|
|
148
|
+
/** Register a synchronous JavaScript scalar callback. Promise results are rejected. */
|
|
149
|
+
registerScalarFunction(
|
|
150
|
+
name: string,
|
|
151
|
+
callback: (...args: JSValue[]) => JSValue,
|
|
152
|
+
options?: SQLFunctionOptions
|
|
153
|
+
): Promise<void>;
|
|
154
|
+
/** Register a synchronous JavaScript table callback. Promise results are rejected. */
|
|
155
|
+
registerTableFunction(
|
|
156
|
+
name: string,
|
|
157
|
+
callback: (...args: JSValue[]) => SQLTableFunctionResult,
|
|
158
|
+
options?: SQLFunctionOptions
|
|
159
|
+
): Promise<void>;
|
|
160
|
+
/** Register a factory that creates one synchronous JavaScript state object per SQL group. */
|
|
161
|
+
registerAggregateFunction(
|
|
162
|
+
name: string,
|
|
163
|
+
factory: () => SQLAggregateState,
|
|
164
|
+
options?: SQLFunctionOptions
|
|
165
|
+
): Promise<void>;
|
|
166
|
+
createDefaultTable(name: string, ftsFields: string[]): Promise<void>;
|
|
167
|
+
createVectorField(table: string, field: string, dimensions: number): Promise<boolean>;
|
|
168
|
+
addDocument(table: string, docId: number, document: Record<string, JSValue | bigint>): Promise<void>;
|
|
169
|
+
addDocumentWithVectors(
|
|
170
|
+
table: string,
|
|
171
|
+
docId: number,
|
|
172
|
+
document: Record<string, JSValue | bigint>,
|
|
173
|
+
vectors: Record<string, number[] | number[][]>
|
|
174
|
+
): Promise<void>;
|
|
175
|
+
addVector(table: string, docId: number, field: string, vector: Float32Array | number[]): Promise<boolean>;
|
|
176
|
+
addVectorValues(
|
|
177
|
+
table: string,
|
|
178
|
+
docId: number,
|
|
179
|
+
field: string,
|
|
180
|
+
vectors: Array<Float32Array | number[]>
|
|
181
|
+
): Promise<boolean>;
|
|
182
|
+
getDocument(table: string, docId: number): Promise<Record<string, JSValue> | null>;
|
|
183
|
+
deleteDocument(table: string, docId: number): Promise<void>;
|
|
184
|
+
documentCount(table: string): Promise<number>;
|
|
185
|
+
search(
|
|
186
|
+
table: string,
|
|
187
|
+
field: string,
|
|
188
|
+
query: string,
|
|
189
|
+
topK?: number,
|
|
190
|
+
scoring?: "bm25" | "bayesian"
|
|
191
|
+
): Promise<SearchHit[]>;
|
|
192
|
+
knnSearch(table: string, field: string, vector: Float32Array | number[], topK?: number): Promise<SearchHit[]>;
|
|
193
|
+
vectorSimilaritySearch(
|
|
194
|
+
table: string,
|
|
195
|
+
field: string,
|
|
196
|
+
vector: Float32Array | number[],
|
|
197
|
+
threshold: number
|
|
198
|
+
): Promise<SearchHit[]>;
|
|
199
|
+
hybridSearch(
|
|
200
|
+
table: string,
|
|
201
|
+
textField: string,
|
|
202
|
+
textQuery: string,
|
|
203
|
+
vectorField: string,
|
|
204
|
+
queryVector: Float32Array | number[],
|
|
205
|
+
topK?: number,
|
|
206
|
+
knnPool?: number
|
|
207
|
+
): Promise<SearchHit[]>;
|
|
208
|
+
robustHybridSearch(
|
|
209
|
+
table: string,
|
|
210
|
+
textField: string,
|
|
211
|
+
textQuery: string,
|
|
212
|
+
vectorField: string,
|
|
213
|
+
queryVector: Float32Array | number[],
|
|
214
|
+
topK?: number,
|
|
215
|
+
knnPool?: number,
|
|
216
|
+
alpha?: number
|
|
217
|
+
): Promise<SearchHit[]>;
|
|
218
|
+
estimateScoringParams(
|
|
219
|
+
table: string,
|
|
220
|
+
field: string,
|
|
221
|
+
nSamples?: number,
|
|
222
|
+
tokensPerQuery?: number,
|
|
223
|
+
seed?: number
|
|
224
|
+
): Promise<Record<string, number>>;
|
|
225
|
+
learnScoringParams(
|
|
226
|
+
table: string,
|
|
227
|
+
field: string,
|
|
228
|
+
query: string,
|
|
229
|
+
labels: Array<0 | 1>
|
|
230
|
+
): Promise<Record<string, number>>;
|
|
231
|
+
updateScoringParams(table: string, field: string, score: number, label: 0 | 1): Promise<void>;
|
|
232
|
+
calibrationReport(
|
|
233
|
+
table: string,
|
|
234
|
+
field: string,
|
|
235
|
+
query: string,
|
|
236
|
+
labels: Array<0 | 1>
|
|
237
|
+
): Promise<CalibrationReport>;
|
|
238
|
+
saveScoringParams(name: string, params: Record<string, number>): Promise<void>;
|
|
239
|
+
loadScoringParams(name: string): Promise<Record<string, number> | null>;
|
|
240
|
+
loadAllScoringParams(): Promise<Record<string, Record<string, number>>>;
|
|
241
|
+
dropScoringParams(name: string): Promise<boolean>;
|
|
242
|
+
runCypher(graph: string, query: string, params?: Record<string, JSValue>): Promise<SQLResult>;
|
|
243
|
+
createGraph(name: string): Promise<boolean>;
|
|
244
|
+
dropGraph(name: string): Promise<boolean>;
|
|
245
|
+
listGraphs(): Promise<string[]>;
|
|
246
|
+
listPathIndexes(): Promise<string[]>;
|
|
247
|
+
tableNames(): Promise<string[]>;
|
|
248
|
+
listViews(): Promise<string[]>;
|
|
249
|
+
listSchemas(): Promise<string[]>;
|
|
250
|
+
listSequences(): Promise<string[]>;
|
|
251
|
+
listNamedAnalyzers(): Promise<string[]>;
|
|
252
|
+
listForeignServers(): Promise<string[]>;
|
|
253
|
+
listForeignTables(): Promise<string[]>;
|
|
254
|
+
takeSQLNotices(): Promise<SQLNotice[]>;
|
|
255
|
+
sqlFunctionDepthLimit(): Promise<number>;
|
|
256
|
+
setSQLFunctionDepthLimit(limit: number): Promise<void>;
|
|
257
|
+
cancel(): Promise<void>;
|
|
258
|
+
close(): Promise<void>;
|
|
259
|
+
}
|