@oceanbase/seekdb-node 0.0.0-stage → 1.4.0

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 ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md CHANGED
@@ -1,3 +1,209 @@
1
- # Temporary Holding Version
1
+ # @oceanbase/seekdb-node
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Run a local [seekdb](https://github.com/oceanbase/seekdb) database from Node.js
4
+ or TypeScript, with a bundled native runtime and a small lifecycle API.
5
+
6
+ `seekdb.open()` starts or reuses a **separate seekdb server process** and returns
7
+ a handle. `connectionOptions()` supplies the endpoint for your MySQL-protocol
8
+ client, and `close()` releases the handle. This is not an in-process SQL engine
9
+ or a SQL client: your application owns its SQL connections and queries.
10
+
11
+ [Source repository](https://github.com/oceanbase/seekdb-bindings) ·
12
+ [Report an issue](https://github.com/oceanbase/seekdb-bindings/issues)
13
+
14
+ ## Install
15
+
16
+ ```sh
17
+ npm install @oceanbase/seekdb-node
18
+ ```
19
+
20
+ Keep npm optional dependencies enabled: npm selects the matching native runtime
21
+ package for your operating system and CPU. You do not need to install a platform
22
+ package manually, compile seekdb, or install a separate database server on a
23
+ supported platform. The native runtime makes the download larger than a
24
+ JavaScript-only package.
25
+
26
+ To run the SQL example below, also install `mysql2`:
27
+
28
+ ```sh
29
+ npm install mysql2
30
+ ```
31
+
32
+ `mysql2` is an example client, not a dependency of this lifecycle binding.
33
+
34
+ ## Supported environments
35
+
36
+ Node.js **22 or newer** is required; the release has been tested with Node.js
37
+ **22 and 24**. The package uses ES modules (`import`) and includes TypeScript
38
+ declarations. CommonJS `require()` is not an advertised entry point. Bun and
39
+ Deno have not been validated.
40
+
41
+ | Operating system | CPU | Requirements / validation |
42
+ |---|---|---|
43
+ | Linux | x86_64 (`x64`) | glibc 2.28 or newer |
44
+ | Linux | aarch64 (`arm64`) | glibc 2.28 or newer |
45
+ | macOS | Apple Silicon (`arm64`) | macOS 15.6.1 or newer, required by the bundled server |
46
+ | Windows | x86_64 (`x64`) | Tested on Windows 11; older Windows versions are not validated |
47
+
48
+ This release does not provide macOS Intel, Windows ARM64, 32-bit, or
49
+ Alpine/musl native packages. Do not copy `node_modules` between different
50
+ platforms; install dependencies on the target platform.
51
+
52
+ ## Quick start
53
+
54
+ Save the following as `example.mjs`, then run `node example.mjs`:
55
+
56
+ ```js
57
+ import { seekdb } from "@oceanbase/seekdb-node";
58
+ import mysql from "mysql2/promise";
59
+
60
+ const db = await seekdb.open("./seekdb.db", {
61
+ parameters: { memory_budget: "2G" },
62
+ });
63
+ let connection;
64
+ try {
65
+ const endpoint = db.connectionOptions();
66
+ let location;
67
+ if (endpoint.transport === "tcp") {
68
+ location = { host: endpoint.host, port: endpoint.port };
69
+ } else if (endpoint.transport === "unix_socket") {
70
+ location = { socketPath: endpoint.unixSocket };
71
+ } else {
72
+ throw new Error("This example uses TCP or Unix sockets; configure TCP or use a named-pipe-capable client.");
73
+ }
74
+ connection = await mysql.createConnection({
75
+ ...location,
76
+ user: endpoint.user,
77
+ password: "",
78
+ database: "test",
79
+ });
80
+ const [rows] = await connection.query("SELECT 1 AS value");
81
+ console.log(rows); // [{ value: 1 }]
82
+ } finally {
83
+ try {
84
+ if (connection) await connection.end();
85
+ } finally {
86
+ db.close();
87
+ }
88
+ }
89
+ ```
90
+
91
+ The example needs enough free memory for the requested `2G` database budget
92
+ plus Node.js and the operating system. The first open initializes the database
93
+ directory and can take longer than subsequent opens. Reopening the same
94
+ directory preserves its data.
95
+
96
+ The Windows release was tested over TCP. If you configure named-pipe transport,
97
+ use a client with a compatible adapter; `connectionOptions()` is transport
98
+ information, not a client-specific configuration object. To request a random
99
+ TCP port when spawning on Windows, pass `mysql_port_mode: "random"` in
100
+ `parameters`. Connect using the returned endpoint rather than a hard-coded port.
101
+
102
+ ## API
103
+
104
+ ### `await seekdb.open(dbDir, options?)`
105
+
106
+ Opens a local runtime handle, starting or reusing the server for `dbDir`.
107
+ `dbDir` must be a nonempty string. `options.parameters` is a record of server
108
+ parameter names and **string** values, for example
109
+ `{ parameters: { memory_budget: "2G" } }`.
110
+
111
+ Ordinary server parameters apply on first initialization and are then persisted
112
+ by seekdb. Operational parameters such as `port` and `mysql_port_mode` apply
113
+ when a server is spawned. Opening another handle does not reconfigure an
114
+ already-running server.
115
+
116
+ ### `db.connectionOptions()`
117
+
118
+ Returns one of these endpoint shapes while the handle is open:
119
+
120
+ ```ts
121
+ type ConnectionOptions =
122
+ | { transport: "tcp"; user: string; host: string; port: number }
123
+ | { transport: "unix_socket"; user: string; unixSocket: string }
124
+ | { transport: "named_pipe"; user: string; namedPipe: string };
125
+ ```
126
+
127
+ Use the `transport` discriminator to adapt it to your SQL client. Calling this
128
+ method after `close()` throws an error.
129
+
130
+ ### `db.close()`, `db.closed`, and `db.dbDir`
131
+
132
+ - `close()` synchronously releases this lifecycle handle. It is idempotent,
133
+ does not delete database files, and does not guarantee immediate server exit.
134
+ - Close SQL clients before releasing their lifecycle handle. Other open handles
135
+ can continue using the same database.
136
+ - `closed` reports whether this handle has been closed.
137
+ - `dbDir` is the absolute, normalized database directory.
138
+
139
+ Call `close()` explicitly; do not rely on garbage collection for cleanup.
140
+
141
+ ### Errors
142
+
143
+ Invalid JavaScript arguments are rejected with `TypeError`. Native startup
144
+ failures reject `open()` with an exported `seekdbError`, whose `returnCode` and
145
+ `message` contain the native error code and diagnostic.
146
+
147
+ ## Troubleshooting and scope
148
+
149
+ - **Missing native package:** keep optional dependencies enabled and reinstall
150
+ on the target machine. Verify that its OS, architecture, libc and Node.js
151
+ version are supported.
152
+ - **Startup failure:** inspect the error message, database directory permissions,
153
+ and available memory and disk space. Initialization and restart can take time.
154
+ - **SQL client failure:** use the endpoint returned by `connectionOptions()`;
155
+ keep the handle open while the SQL connection is in use.
156
+ - **Local use:** the example connects as the local `root` user with an empty
157
+ password. Do not expose this endpoint to untrusted networks without separately
158
+ configuring and validating authentication and network access controls.
159
+ - **Different SDK API:** this is not a drop-in replacement for
160
+ `@seekdb/js-bindings`. It exposes `open` / `connectionOptions` / `close`, not
161
+ the other SDK's `open` / `connect` / `execute` interface.
162
+
163
+ For a bug report, include your OS/version, CPU architecture, Node.js version,
164
+ package version, and a minimal reproduction. Remove credentials and private
165
+ database contents from logs before sharing them.
166
+
167
+ ## Building and contributing
168
+
169
+ Normal npm users do not need a compiler. For source builds, initialize the
170
+ repository submodules and use Node.js, CMake and a compatible native toolchain:
171
+
172
+ ```sh
173
+ git submodule update --init --recursive
174
+ cd typescript
175
+ npm ci --ignore-scripts
176
+ SEEKDB_BIN=/path/to/seekdb npm test
177
+ ```
178
+
179
+ `npm test` builds the C driver, Node-API addon and TypeScript before testing.
180
+ Linux source builds also need `readelf`, `ldd` and `patchelf`. Compiler overrides
181
+ `CC`, `CXX` and `LDFLAGS` are preserved; macOS uses the active Xcode toolchain
182
+ when no compiler override is supplied.
183
+
184
+ Alternatively, reuse an extracted, compatible libseekdb SDK. Its public C header
185
+ must match the source checkout; only the Node addon and TypeScript are rebuilt:
186
+
187
+ ```sh
188
+ SEEKDB_SDK_DIR=/path/to/libseekdb-sdk npm test
189
+ npm run pack:release -- --out-dir /path/to/artifacts
190
+ ```
191
+
192
+ On Windows PowerShell, assign environment variables with `$env:NAME = "value"`
193
+ instead of the POSIX syntax above. Initialize the Windows SDK/MSVC support
194
+ environment and set `SEEKDB_MSVC_RUNTIME_DIR` to the x64 `Microsoft.VC143.CRT`
195
+ redistributable directory when staging the Windows runtime.
196
+
197
+ Release packaging produces a common package and an exact-version platform
198
+ runtime package. Linux binaries must remain compatible with glibc 2.28; the
199
+ macOS minimum is determined by the bundled binaries. Test the installed
200
+ tarballs outside the source checkout on Node.js 22 and 24. Packing does not
201
+ publish anything to npm. The standalone Linux-only `pack:linux` route is for
202
+ development and is not the multi-platform release layout.
203
+
204
+ ## License
205
+
206
+ The bindings are licensed under
207
+ [Apache-2.0](https://github.com/oceanbase/seekdb-bindings/blob/main/LICENSE).
208
+ Bundled seekdb and third-party runtime components retain their own license and
209
+ notice terms; see the license and notice files included in each native package.
@@ -0,0 +1,33 @@
1
+ export interface OpenOptions {
2
+ /** seekdb server parameters. Ordinary parameters apply on first initialization. */
3
+ parameters?: Readonly<Record<string, string>>;
4
+ }
5
+ export type ConnectionOptions = {
6
+ transport: "tcp";
7
+ user: string;
8
+ host: string;
9
+ port: number;
10
+ } | {
11
+ transport: "unix_socket";
12
+ user: string;
13
+ unixSocket: string;
14
+ } | {
15
+ transport: "named_pipe";
16
+ user: string;
17
+ namedPipe: string;
18
+ };
19
+ /** A failure reported by libseekdb. */
20
+ export declare class seekdbError extends Error {
21
+ readonly returnCode: number;
22
+ constructor(message: string, returnCode: number, options?: ErrorOptions);
23
+ }
24
+ /** An open, local seekdb runtime. Close SQL clients before closing this handle. */
25
+ export declare class seekdb {
26
+ #private;
27
+ readonly dbDir: string;
28
+ private constructor();
29
+ static open(dbDir: string, options?: OpenOptions): Promise<seekdb>;
30
+ get closed(): boolean;
31
+ connectionOptions(): ConnectionOptions;
32
+ close(): void;
33
+ }
package/dist/index.js ADDED
@@ -0,0 +1,90 @@
1
+ import { createRequire } from "node:module";
2
+ import { readFileSync } from "node:fs";
3
+ import { resolve } from "node:path";
4
+ import { nativeDirectory } from "./native-loader.js";
5
+ const require = createRequire(import.meta.url);
6
+ const nativeDir = nativeDirectory();
7
+ const builtFor = JSON.parse(readFileSync(resolve(nativeDir, "platform.json"), "utf8"));
8
+ if (builtFor.platform !== process.platform || builtFor.arch !== process.arch) {
9
+ throw new Error(`seekdb native files target ${builtFor.platform}/${builtFor.arch}, ` +
10
+ `but this runtime is ${process.platform}/${process.arch}`);
11
+ }
12
+ if (builtFor.libc === "glibc") {
13
+ const report = process.report.getReport();
14
+ if (!report.header?.glibcVersionRuntime) {
15
+ throw new Error("This seekdb native package requires glibc; musl/Alpine is not supported");
16
+ }
17
+ }
18
+ const native = require(resolve(nativeDir, "seekdb_native.node"));
19
+ /** A failure reported by libseekdb. */
20
+ export class seekdbError extends Error {
21
+ returnCode;
22
+ constructor(message, returnCode, options) {
23
+ super(message, options);
24
+ this.name = "seekdbError";
25
+ this.returnCode = returnCode;
26
+ }
27
+ }
28
+ function parameterPairs(options) {
29
+ if (options === undefined)
30
+ return [];
31
+ if (options === null || typeof options !== "object") {
32
+ throw new TypeError("options must be an object");
33
+ }
34
+ const parameters = options.parameters;
35
+ if (parameters === undefined)
36
+ return [];
37
+ if (parameters === null || typeof parameters !== "object" || Array.isArray(parameters)) {
38
+ throw new TypeError("parameters must be a record of string values");
39
+ }
40
+ const pairs = [];
41
+ for (const [key, value] of Object.entries(parameters)) {
42
+ if (!key || typeof value !== "string") {
43
+ throw new TypeError("parameter keys must be nonempty and values must be strings");
44
+ }
45
+ pairs.push(key, value);
46
+ }
47
+ return pairs;
48
+ }
49
+ /** An open, local seekdb runtime. Close SQL clients before closing this handle. */
50
+ export class seekdb {
51
+ dbDir;
52
+ #handle;
53
+ constructor(dbDir, handle) {
54
+ this.dbDir = dbDir;
55
+ this.#handle = handle;
56
+ }
57
+ static async open(dbDir, options) {
58
+ if (typeof dbDir !== "string" || dbDir.length === 0) {
59
+ throw new TypeError("dbDir must be a nonempty string");
60
+ }
61
+ const pairs = parameterPairs(options);
62
+ const normalized = resolve(dbDir);
63
+ try {
64
+ const handle = await native.open(normalized, pairs);
65
+ return new seekdb(normalized, handle);
66
+ }
67
+ catch (error) {
68
+ if (error instanceof Error && "returnCode" in error &&
69
+ typeof error.returnCode === "number") {
70
+ throw new seekdbError(error.message, error.returnCode, { cause: error });
71
+ }
72
+ throw error;
73
+ }
74
+ }
75
+ get closed() {
76
+ return this.#handle === undefined;
77
+ }
78
+ connectionOptions() {
79
+ if (this.#handle === undefined) {
80
+ throw new Error("seekdb is closed");
81
+ }
82
+ return native.connectionOptions(this.#handle);
83
+ }
84
+ close() {
85
+ if (this.#handle !== undefined) {
86
+ native.close(this.#handle);
87
+ this.#handle = undefined;
88
+ }
89
+ }
90
+ }
@@ -0,0 +1,2 @@
1
+ export declare function nativePackageName(platform: string, arch: string): string;
2
+ export declare function nativeDirectory(): string;
@@ -0,0 +1,35 @@
1
+ import { createRequire } from "node:module";
2
+ import { existsSync } from "node:fs";
3
+ import { dirname, resolve } from "node:path";
4
+ import { fileURLToPath } from "node:url";
5
+ export function nativePackageName(platform, arch) {
6
+ const suffixes = {
7
+ "linux/x64": "linux-x64-gnu",
8
+ "linux/arm64": "linux-arm64-gnu",
9
+ "darwin/arm64": "darwin-arm64",
10
+ "win32/x64": "win32-x64",
11
+ };
12
+ const suffix = suffixes[`${platform}/${arch}`];
13
+ if (!suffix)
14
+ throw new Error(`Unsupported seekdb platform: ${platform}/${arch}`);
15
+ return `@oceanbase/seekdb-node-${suffix}`;
16
+ }
17
+ export function nativeDirectory() {
18
+ if (process.platform === "linux") {
19
+ const report = process.report.getReport();
20
+ if (!report.header?.glibcVersionRuntime) {
21
+ throw new Error("This seekdb native package requires glibc; musl/Alpine is not supported");
22
+ }
23
+ }
24
+ const local = resolve(dirname(fileURLToPath(import.meta.url)), "native");
25
+ if (existsSync(resolve(local, "platform.json")))
26
+ return local;
27
+ const name = nativePackageName(process.platform, process.arch);
28
+ const require = createRequire(import.meta.url);
29
+ try {
30
+ return resolve(dirname(require.resolve(`${name}/package.json`)), "native");
31
+ }
32
+ catch (cause) {
33
+ throw new Error(`Missing ${name}; install seekdb with optional dependencies enabled`, { cause });
34
+ }
35
+ }
package/package.json CHANGED
@@ -1,6 +1,50 @@
1
1
  {
2
2
  "name": "@oceanbase/seekdb-node",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "1.4.0",
4
+ "description": "Local seekdb lifecycle bindings for Node.js and TypeScript",
5
+ "license": "Apache-2.0",
6
+ "type": "module",
7
+ "engines": {
8
+ "node": ">=22"
9
+ },
10
+ "main": "./dist/index.js",
11
+ "types": "./dist/index.d.ts",
12
+ "exports": {
13
+ ".": {
14
+ "types": "./dist/index.d.ts",
15
+ "import": "./dist/index.js"
16
+ }
17
+ },
18
+ "files": [
19
+ "dist/",
20
+ "README.md"
21
+ ],
22
+ "gypfile": false,
23
+ "optionalDependencies": {
24
+ "@oceanbase/seekdb-node-linux-x64-gnu": "1.4.0",
25
+ "@oceanbase/seekdb-node-linux-arm64-gnu": "1.4.0",
26
+ "@oceanbase/seekdb-node-darwin-arm64": "1.4.0",
27
+ "@oceanbase/seekdb-node-win32-x64": "1.4.0"
28
+ },
29
+ "publishConfig": {
30
+ "access": "public",
31
+ "registry": "https://registry.npmjs.org"
32
+ },
33
+ "homepage": "https://github.com/oceanbase/seekdb-bindings/tree/main/typescript#readme",
34
+ "repository": {
35
+ "type": "git",
36
+ "url": "git+https://github.com/oceanbase/seekdb-bindings.git",
37
+ "directory": "typescript"
38
+ },
39
+ "bugs": {
40
+ "url": "https://github.com/oceanbase/seekdb-bindings/issues"
41
+ },
42
+ "keywords": [
43
+ "seekdb",
44
+ "oceanbase",
45
+ "database",
46
+ "mysql",
47
+ "typescript",
48
+ "node-api"
49
+ ]
50
+ }