@tursodatabase/sync 0.2.0-pre.9 → 0.2.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/README.md +2 -2
- package/dist/promise.d.ts +7 -6
- package/dist/promise.d.ts.map +1 -1
- package/dist/promise.js +57 -12
- package/dist/promise.test.js +75 -3
- package/index.js +48 -47
- package/package.json +7 -7
package/README.md
CHANGED
|
@@ -16,14 +16,14 @@
|
|
|
16
16
|
|
|
17
17
|
This package is the Turso embedded database library for JavaScript in Node.
|
|
18
18
|
|
|
19
|
-
> **⚠️ Warning:** This software is
|
|
19
|
+
> **⚠️ Warning:** This software is in BETA. It may still contain bugs and unexpected behavior. Use caution with production data and ensure you have backups.
|
|
20
20
|
|
|
21
21
|
## Features
|
|
22
22
|
|
|
23
23
|
- **SQLite compatible:** SQLite query language and file format support ([status](https://github.com/tursodatabase/turso/blob/main/COMPAT.md)).
|
|
24
24
|
- **In-process**: No network overhead, runs directly in your Node.js process
|
|
25
25
|
- **TypeScript support**: Full TypeScript definitions included
|
|
26
|
-
- **Cross-platform**: Supports Linux (x86 and arm64), macOS, Windows (browser is supported in the separate package `@tursodatabase/database-
|
|
26
|
+
- **Cross-platform**: Supports Linux (x86 and arm64), macOS, Windows (browser is supported in the separate package `@tursodatabase/database-wasm` package)
|
|
27
27
|
|
|
28
28
|
## Installation
|
|
29
29
|
|
package/dist/promise.d.ts
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
import { DatabasePromise } from "@tursodatabase/database-common";
|
|
2
|
-
import { DatabaseOpts
|
|
2
|
+
import { DatabaseOpts, EncryptionOpts, DatabaseRowMutation, DatabaseRowStatement, DatabaseRowTransformResult, DatabaseStats } from "@tursodatabase/sync-common";
|
|
3
3
|
declare class Database extends DatabasePromise {
|
|
4
4
|
#private;
|
|
5
|
-
constructor(opts:
|
|
5
|
+
constructor(opts: DatabaseOpts);
|
|
6
6
|
/**
|
|
7
7
|
* connect database and initialize it in case of clean start
|
|
8
8
|
*/
|
|
9
9
|
connect(): Promise<void>;
|
|
10
10
|
/**
|
|
11
11
|
* pull new changes from the remote database
|
|
12
|
-
* if {@link
|
|
12
|
+
* if {@link DatabaseOpts.longPollTimeoutMs} is set - then server will hold the connection open until either new changes will appear in the database or timeout occurs.
|
|
13
13
|
* @returns true if new changes were pulled from the remote
|
|
14
14
|
*/
|
|
15
15
|
pull(): Promise<boolean>;
|
|
16
16
|
/**
|
|
17
17
|
* push new local changes to the remote database
|
|
18
|
-
* if {@link
|
|
18
|
+
* if {@link DatabaseOpts.transform} is set - then provided callback will be called for every mutation before sending it to the remote
|
|
19
19
|
*/
|
|
20
20
|
push(): Promise<void>;
|
|
21
21
|
/**
|
|
@@ -37,6 +37,7 @@ declare class Database extends DatabasePromise {
|
|
|
37
37
|
* @param {Object} opts - Options for database behavior.
|
|
38
38
|
* @returns {Promise<Database>} - A promise that resolves to a Database instance.
|
|
39
39
|
*/
|
|
40
|
-
declare function connect(opts:
|
|
41
|
-
export { connect, Database
|
|
40
|
+
declare function connect(opts: DatabaseOpts): Promise<Database>;
|
|
41
|
+
export { connect, Database };
|
|
42
|
+
export type { DatabaseOpts, EncryptionOpts, DatabaseRowMutation, DatabaseRowStatement, DatabaseRowTransformResult };
|
|
42
43
|
//# sourceMappingURL=promise.d.ts.map
|
package/dist/promise.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"promise.d.ts","sourceRoot":"","sources":["../promise.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAA;AAChE,OAAO,EAAmB,YAAY,
|
|
1
|
+
{"version":3,"file":"promise.d.ts","sourceRoot":"","sources":["../promise.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAA;AAChE,OAAO,EAAmB,YAAY,EAAE,cAAc,EAAW,mBAAmB,EAAE,oBAAoB,EAAE,0BAA0B,EAAE,aAAa,EAAoB,MAAM,4BAA4B,CAAC;AAwC5M,cAAM,QAAS,SAAQ,eAAe;;gBAKtB,IAAI,EAAE,YAAY;IAiD9B;;OAEG;IACY,OAAO;IAUtB;;;;OAIG;IACG,IAAI;IAWV;;;OAGG;IACG,IAAI;IAMV;;OAEG;IACG,UAAU;IAMhB;;OAEG;IACG,KAAK,IAAI,OAAO,CAAC,aAAa,CAAC;IAMrC;;OAEG;IACY,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAMxC;AAED;;;;;GAKG;AACH,iBAAe,OAAO,CAAC,IAAI,EAAE,YAAY,GAAG,OAAO,CAAC,QAAQ,CAAC,CAI5D;AAED,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAA;AAC5B,YAAY,EAAE,YAAY,EAAE,cAAc,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,0BAA0B,EAAE,CAAA"}
|
package/dist/promise.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DatabasePromise } from "@tursodatabase/database-common";
|
|
2
2
|
import { run, SyncEngineGuards } from "@tursodatabase/sync-common";
|
|
3
|
-
import { SyncEngine } from "#index";
|
|
3
|
+
import { SyncEngine, Database as NativeDatabase } from "#index";
|
|
4
4
|
import { promises } from "node:fs";
|
|
5
5
|
let NodeIO = {
|
|
6
6
|
async read(path) {
|
|
@@ -46,6 +46,11 @@ class Database extends DatabasePromise {
|
|
|
46
46
|
#io;
|
|
47
47
|
#guards;
|
|
48
48
|
constructor(opts) {
|
|
49
|
+
if (opts.url == null) {
|
|
50
|
+
super(new NativeDatabase(opts.path, { tracing: opts.tracing }));
|
|
51
|
+
this.#engine = null;
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
49
54
|
const engine = new SyncEngine({
|
|
50
55
|
path: opts.path,
|
|
51
56
|
clientName: opts.clientName,
|
|
@@ -53,15 +58,31 @@ class Database extends DatabasePromise {
|
|
|
53
58
|
protocolVersion: "v1" /* SyncEngineProtocolVersion.V1 */,
|
|
54
59
|
longPollTimeoutMs: opts.longPollTimeoutMs,
|
|
55
60
|
tracing: opts.tracing,
|
|
61
|
+
bootstrapIfEmpty: typeof opts.url != "function" || opts.url() != null,
|
|
62
|
+
remoteEncryption: opts.remoteEncryption?.cipher,
|
|
56
63
|
});
|
|
57
64
|
super(engine.db());
|
|
58
|
-
let headers
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
+
let headers;
|
|
66
|
+
if (typeof opts.authToken == "function") {
|
|
67
|
+
const authToken = opts.authToken;
|
|
68
|
+
headers = async () => ({
|
|
69
|
+
...(opts.authToken != null && { "Authorization": `Bearer ${await authToken()}` }),
|
|
70
|
+
...(opts.remoteEncryption != null && {
|
|
71
|
+
"x-turso-encryption-key": opts.remoteEncryption.key,
|
|
72
|
+
"x-turso-encryption-cipher": opts.remoteEncryption.cipher,
|
|
73
|
+
})
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
const authToken = opts.authToken;
|
|
78
|
+
headers = {
|
|
79
|
+
...(opts.authToken != null && { "Authorization": `Bearer ${authToken}` }),
|
|
80
|
+
...(opts.remoteEncryption != null && {
|
|
81
|
+
"x-turso-encryption-key": opts.remoteEncryption.key,
|
|
82
|
+
"x-turso-encryption-cipher": opts.remoteEncryption.cipher,
|
|
83
|
+
})
|
|
84
|
+
};
|
|
85
|
+
}
|
|
65
86
|
this.#runOpts = {
|
|
66
87
|
url: opts.url,
|
|
67
88
|
headers: headers,
|
|
@@ -76,14 +97,26 @@ class Database extends DatabasePromise {
|
|
|
76
97
|
* connect database and initialize it in case of clean start
|
|
77
98
|
*/
|
|
78
99
|
async connect() {
|
|
79
|
-
|
|
100
|
+
if (this.connected) {
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
else if (this.#engine == null) {
|
|
104
|
+
await super.connect();
|
|
105
|
+
}
|
|
106
|
+
else {
|
|
107
|
+
await run(this.#runOpts, this.#io, this.#engine, this.#engine.connect());
|
|
108
|
+
}
|
|
109
|
+
this.connected = true;
|
|
80
110
|
}
|
|
81
111
|
/**
|
|
82
112
|
* pull new changes from the remote database
|
|
83
|
-
* if {@link
|
|
113
|
+
* if {@link DatabaseOpts.longPollTimeoutMs} is set - then server will hold the connection open until either new changes will appear in the database or timeout occurs.
|
|
84
114
|
* @returns true if new changes were pulled from the remote
|
|
85
115
|
*/
|
|
86
116
|
async pull() {
|
|
117
|
+
if (this.#engine == null) {
|
|
118
|
+
throw new Error("sync is disabled as database was opened without sync support");
|
|
119
|
+
}
|
|
87
120
|
const changes = await this.#guards.wait(async () => await run(this.#runOpts, this.#io, this.#engine, this.#engine.wait()));
|
|
88
121
|
if (changes.empty()) {
|
|
89
122
|
return false;
|
|
@@ -93,28 +126,40 @@ class Database extends DatabasePromise {
|
|
|
93
126
|
}
|
|
94
127
|
/**
|
|
95
128
|
* push new local changes to the remote database
|
|
96
|
-
* if {@link
|
|
129
|
+
* if {@link DatabaseOpts.transform} is set - then provided callback will be called for every mutation before sending it to the remote
|
|
97
130
|
*/
|
|
98
131
|
async push() {
|
|
132
|
+
if (this.#engine == null) {
|
|
133
|
+
throw new Error("sync is disabled as database was opened without sync support");
|
|
134
|
+
}
|
|
99
135
|
await this.#guards.push(async () => await run(this.#runOpts, this.#io, this.#engine, this.#engine.push()));
|
|
100
136
|
}
|
|
101
137
|
/**
|
|
102
138
|
* checkpoint WAL for local database
|
|
103
139
|
*/
|
|
104
140
|
async checkpoint() {
|
|
141
|
+
if (this.#engine == null) {
|
|
142
|
+
throw new Error("sync is disabled as database was opened without sync support");
|
|
143
|
+
}
|
|
105
144
|
await this.#guards.checkpoint(async () => await run(this.#runOpts, this.#io, this.#engine, this.#engine.checkpoint()));
|
|
106
145
|
}
|
|
107
146
|
/**
|
|
108
147
|
* @returns statistic of current local database
|
|
109
148
|
*/
|
|
110
149
|
async stats() {
|
|
150
|
+
if (this.#engine == null) {
|
|
151
|
+
throw new Error("sync is disabled as database was opened without sync support");
|
|
152
|
+
}
|
|
111
153
|
return (await run(this.#runOpts, this.#io, this.#engine, this.#engine.stats()));
|
|
112
154
|
}
|
|
113
155
|
/**
|
|
114
156
|
* close the database
|
|
115
157
|
*/
|
|
116
158
|
async close() {
|
|
117
|
-
|
|
159
|
+
await super.close();
|
|
160
|
+
if (this.#engine != null) {
|
|
161
|
+
this.#engine.close();
|
|
162
|
+
}
|
|
118
163
|
}
|
|
119
164
|
}
|
|
120
165
|
/**
|
package/dist/promise.test.js
CHANGED
|
@@ -2,6 +2,7 @@ import { unlinkSync } from "node:fs";
|
|
|
2
2
|
import { expect, test } from 'vitest';
|
|
3
3
|
import { connect, Database } from './promise.js';
|
|
4
4
|
const localeCompare = (a, b) => a.x.localeCompare(b.x);
|
|
5
|
+
const intCompare = (a, b) => a.x - b.x;
|
|
5
6
|
function cleanup(path) {
|
|
6
7
|
unlinkSync(path);
|
|
7
8
|
unlinkSync(`${path}-wal`);
|
|
@@ -12,12 +13,83 @@ function cleanup(path) {
|
|
|
12
13
|
}
|
|
13
14
|
catch (e) { }
|
|
14
15
|
}
|
|
15
|
-
test('
|
|
16
|
+
test('simple-db', async () => {
|
|
17
|
+
const db = new Database({ path: ':memory:' });
|
|
18
|
+
expect(await db.prepare("SELECT 1 as x").all()).toEqual([{ x: 1 }]);
|
|
19
|
+
await db.exec("CREATE TABLE t(x)");
|
|
20
|
+
await db.exec("INSERT INTO t VALUES (1), (2), (3)");
|
|
21
|
+
expect(await db.prepare("SELECT * FROM t").all()).toEqual([{ x: 1 }, { x: 2 }, { x: 3 }]);
|
|
22
|
+
await expect(async () => await db.pull()).rejects.toThrowError(/sync is disabled as database was opened without sync support/);
|
|
23
|
+
});
|
|
24
|
+
test('implicit connect', async () => {
|
|
16
25
|
const db = new Database({ path: ':memory:', url: process.env.VITE_TURSO_DB_URL });
|
|
17
|
-
|
|
18
|
-
await
|
|
26
|
+
const defer = db.prepare("SELECT * FROM not_found");
|
|
27
|
+
await expect(async () => await defer.all()).rejects.toThrowError(/no such table: not_found/);
|
|
28
|
+
expect(() => db.prepare("SELECT * FROM not_found")).toThrowError(/no such table: not_found/);
|
|
19
29
|
expect(await db.prepare("SELECT 1 as x").all()).toEqual([{ x: 1 }]);
|
|
20
30
|
});
|
|
31
|
+
test('defered sync', async () => {
|
|
32
|
+
{
|
|
33
|
+
const db = await connect({ path: ':memory:', url: process.env.VITE_TURSO_DB_URL });
|
|
34
|
+
await db.exec("CREATE TABLE IF NOT EXISTS t(x)");
|
|
35
|
+
await db.exec("DELETE FROM t");
|
|
36
|
+
await db.exec("INSERT INTO t VALUES (100)");
|
|
37
|
+
await db.push();
|
|
38
|
+
await db.close();
|
|
39
|
+
}
|
|
40
|
+
let url = null;
|
|
41
|
+
const db = new Database({ path: ':memory:', url: () => url });
|
|
42
|
+
await db.prepare("CREATE TABLE t(x)").run();
|
|
43
|
+
await db.prepare("INSERT INTO t VALUES (1), (2), (3), (42)").run();
|
|
44
|
+
expect(await db.prepare("SELECT * FROM t").all()).toEqual([{ x: 1 }, { x: 2 }, { x: 3 }, { x: 42 }]);
|
|
45
|
+
await expect(async () => await db.pull()).rejects.toThrow(/url is empty - sync is paused/);
|
|
46
|
+
url = process.env.VITE_TURSO_DB_URL;
|
|
47
|
+
await db.pull();
|
|
48
|
+
expect(await db.prepare("SELECT * FROM t").all()).toEqual([{ x: 100 }, { x: 1 }, { x: 2 }, { x: 3 }, { x: 42 }]);
|
|
49
|
+
});
|
|
50
|
+
test('encryption sync', async () => {
|
|
51
|
+
const KEY = 'l/FWopMfZisTLgBX4A42AergrCrYKjiO3BfkJUwv83I=';
|
|
52
|
+
const URL = 'http://encrypted--a--a.localhost:10000';
|
|
53
|
+
{
|
|
54
|
+
const db = await connect({ path: ':memory:', url: URL, remoteEncryption: { key: KEY, cipher: 'aes256gcm' } });
|
|
55
|
+
await db.exec("CREATE TABLE IF NOT EXISTS t(x)");
|
|
56
|
+
await db.exec("DELETE FROM t");
|
|
57
|
+
await db.push();
|
|
58
|
+
await db.close();
|
|
59
|
+
}
|
|
60
|
+
const db1 = await connect({ path: ':memory:', url: URL, remoteEncryption: { key: KEY, cipher: 'aes256gcm' } });
|
|
61
|
+
const db2 = await connect({ path: ':memory:', url: URL, remoteEncryption: { key: KEY, cipher: 'aes256gcm' } });
|
|
62
|
+
await db1.exec("INSERT INTO t VALUES (1), (2), (3)");
|
|
63
|
+
await db2.exec("INSERT INTO t VALUES (4), (5), (6)");
|
|
64
|
+
expect(await db1.prepare("SELECT * FROM t").all()).toEqual([{ x: 1 }, { x: 2 }, { x: 3 }]);
|
|
65
|
+
expect(await db2.prepare("SELECT * FROM t").all()).toEqual([{ x: 4 }, { x: 5 }, { x: 6 }]);
|
|
66
|
+
await Promise.all([db1.push(), db2.push()]);
|
|
67
|
+
await Promise.all([db1.pull(), db2.pull()]);
|
|
68
|
+
const expected = [{ x: 1 }, { x: 2 }, { x: 3 }, { x: 4 }, { x: 5 }, { x: 6 }];
|
|
69
|
+
expect((await db1.prepare("SELECT * FROM t").all()).sort(intCompare)).toEqual(expected.sort(intCompare));
|
|
70
|
+
expect((await db2.prepare("SELECT * FROM t").all()).sort(intCompare)).toEqual(expected.sort(intCompare));
|
|
71
|
+
});
|
|
72
|
+
test('defered encryption sync', async () => {
|
|
73
|
+
const URL = 'http://encrypted--a--a.localhost:10000';
|
|
74
|
+
const KEY = 'l/FWopMfZisTLgBX4A42AergrCrYKjiO3BfkJUwv83I=';
|
|
75
|
+
let url = null;
|
|
76
|
+
{
|
|
77
|
+
const db = await connect({ path: ':memory:', url: URL, remoteEncryption: { key: KEY, cipher: 'aes256gcm' } });
|
|
78
|
+
await db.exec("CREATE TABLE IF NOT EXISTS t(x)");
|
|
79
|
+
await db.exec("DELETE FROM t");
|
|
80
|
+
await db.exec("INSERT INTO t VALUES (100)");
|
|
81
|
+
await db.push();
|
|
82
|
+
await db.close();
|
|
83
|
+
}
|
|
84
|
+
const db = await connect({ path: ':memory:', url: () => url, remoteEncryption: { key: KEY, cipher: 'aes256gcm' } });
|
|
85
|
+
await db.exec("CREATE TABLE IF NOT EXISTS t(x)");
|
|
86
|
+
await db.exec("INSERT INTO t VALUES (1), (2), (3)");
|
|
87
|
+
expect(await db.prepare("SELECT * FROM t").all()).toEqual([{ x: 1 }, { x: 2 }, { x: 3 }]);
|
|
88
|
+
url = URL;
|
|
89
|
+
await db.pull();
|
|
90
|
+
const expected = [{ x: 100 }, { x: 1 }, { x: 2 }, { x: 3 }];
|
|
91
|
+
expect((await db.prepare("SELECT * FROM t").all())).toEqual(expected);
|
|
92
|
+
});
|
|
21
93
|
test('select-after-push', async () => {
|
|
22
94
|
{
|
|
23
95
|
const db = await connect({ path: ':memory:', url: process.env.VITE_TURSO_DB_URL });
|
package/index.js
CHANGED
|
@@ -81,8 +81,8 @@ function requireNative() {
|
|
|
81
81
|
try {
|
|
82
82
|
const binding = require('@tursodatabase/sync-android-arm64')
|
|
83
83
|
const bindingPackageVersion = require('@tursodatabase/sync-android-arm64/package.json').version
|
|
84
|
-
if (bindingPackageVersion !== '0.2.0-pre.
|
|
85
|
-
throw new Error(`Native binding package version mismatch, expected 0.2.0-pre.
|
|
84
|
+
if (bindingPackageVersion !== '0.2.0-pre.13' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
85
|
+
throw new Error(`Native binding package version mismatch, expected 0.2.0-pre.13 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
86
86
|
}
|
|
87
87
|
return binding
|
|
88
88
|
} catch (e) {
|
|
@@ -97,8 +97,8 @@ function requireNative() {
|
|
|
97
97
|
try {
|
|
98
98
|
const binding = require('@tursodatabase/sync-android-arm-eabi')
|
|
99
99
|
const bindingPackageVersion = require('@tursodatabase/sync-android-arm-eabi/package.json').version
|
|
100
|
-
if (bindingPackageVersion !== '0.2.0-pre.
|
|
101
|
-
throw new Error(`Native binding package version mismatch, expected 0.2.0-pre.
|
|
100
|
+
if (bindingPackageVersion !== '0.2.0-pre.13' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
101
|
+
throw new Error(`Native binding package version mismatch, expected 0.2.0-pre.13 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
102
102
|
}
|
|
103
103
|
return binding
|
|
104
104
|
} catch (e) {
|
|
@@ -117,8 +117,8 @@ function requireNative() {
|
|
|
117
117
|
try {
|
|
118
118
|
const binding = require('@tursodatabase/sync-win32-x64-msvc')
|
|
119
119
|
const bindingPackageVersion = require('@tursodatabase/sync-win32-x64-msvc/package.json').version
|
|
120
|
-
if (bindingPackageVersion !== '0.2.0-pre.
|
|
121
|
-
throw new Error(`Native binding package version mismatch, expected 0.2.0-pre.
|
|
120
|
+
if (bindingPackageVersion !== '0.2.0-pre.13' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
121
|
+
throw new Error(`Native binding package version mismatch, expected 0.2.0-pre.13 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
122
122
|
}
|
|
123
123
|
return binding
|
|
124
124
|
} catch (e) {
|
|
@@ -133,8 +133,8 @@ function requireNative() {
|
|
|
133
133
|
try {
|
|
134
134
|
const binding = require('@tursodatabase/sync-win32-ia32-msvc')
|
|
135
135
|
const bindingPackageVersion = require('@tursodatabase/sync-win32-ia32-msvc/package.json').version
|
|
136
|
-
if (bindingPackageVersion !== '0.2.0-pre.
|
|
137
|
-
throw new Error(`Native binding package version mismatch, expected 0.2.0-pre.
|
|
136
|
+
if (bindingPackageVersion !== '0.2.0-pre.13' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
137
|
+
throw new Error(`Native binding package version mismatch, expected 0.2.0-pre.13 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
138
138
|
}
|
|
139
139
|
return binding
|
|
140
140
|
} catch (e) {
|
|
@@ -149,8 +149,8 @@ function requireNative() {
|
|
|
149
149
|
try {
|
|
150
150
|
const binding = require('@tursodatabase/sync-win32-arm64-msvc')
|
|
151
151
|
const bindingPackageVersion = require('@tursodatabase/sync-win32-arm64-msvc/package.json').version
|
|
152
|
-
if (bindingPackageVersion !== '0.2.0-pre.
|
|
153
|
-
throw new Error(`Native binding package version mismatch, expected 0.2.0-pre.
|
|
152
|
+
if (bindingPackageVersion !== '0.2.0-pre.13' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
153
|
+
throw new Error(`Native binding package version mismatch, expected 0.2.0-pre.13 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
154
154
|
}
|
|
155
155
|
return binding
|
|
156
156
|
} catch (e) {
|
|
@@ -168,8 +168,8 @@ function requireNative() {
|
|
|
168
168
|
try {
|
|
169
169
|
const binding = require('@tursodatabase/sync-darwin-universal')
|
|
170
170
|
const bindingPackageVersion = require('@tursodatabase/sync-darwin-universal/package.json').version
|
|
171
|
-
if (bindingPackageVersion !== '0.2.0-pre.
|
|
172
|
-
throw new Error(`Native binding package version mismatch, expected 0.2.0-pre.
|
|
171
|
+
if (bindingPackageVersion !== '0.2.0-pre.13' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
172
|
+
throw new Error(`Native binding package version mismatch, expected 0.2.0-pre.13 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
173
173
|
}
|
|
174
174
|
return binding
|
|
175
175
|
} catch (e) {
|
|
@@ -184,8 +184,8 @@ function requireNative() {
|
|
|
184
184
|
try {
|
|
185
185
|
const binding = require('@tursodatabase/sync-darwin-x64')
|
|
186
186
|
const bindingPackageVersion = require('@tursodatabase/sync-darwin-x64/package.json').version
|
|
187
|
-
if (bindingPackageVersion !== '0.2.0-pre.
|
|
188
|
-
throw new Error(`Native binding package version mismatch, expected 0.2.0-pre.
|
|
187
|
+
if (bindingPackageVersion !== '0.2.0-pre.13' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
188
|
+
throw new Error(`Native binding package version mismatch, expected 0.2.0-pre.13 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
189
189
|
}
|
|
190
190
|
return binding
|
|
191
191
|
} catch (e) {
|
|
@@ -200,8 +200,8 @@ function requireNative() {
|
|
|
200
200
|
try {
|
|
201
201
|
const binding = require('@tursodatabase/sync-darwin-arm64')
|
|
202
202
|
const bindingPackageVersion = require('@tursodatabase/sync-darwin-arm64/package.json').version
|
|
203
|
-
if (bindingPackageVersion !== '0.2.0-pre.
|
|
204
|
-
throw new Error(`Native binding package version mismatch, expected 0.2.0-pre.
|
|
203
|
+
if (bindingPackageVersion !== '0.2.0-pre.13' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
204
|
+
throw new Error(`Native binding package version mismatch, expected 0.2.0-pre.13 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
205
205
|
}
|
|
206
206
|
return binding
|
|
207
207
|
} catch (e) {
|
|
@@ -220,8 +220,8 @@ function requireNative() {
|
|
|
220
220
|
try {
|
|
221
221
|
const binding = require('@tursodatabase/sync-freebsd-x64')
|
|
222
222
|
const bindingPackageVersion = require('@tursodatabase/sync-freebsd-x64/package.json').version
|
|
223
|
-
if (bindingPackageVersion !== '0.2.0-pre.
|
|
224
|
-
throw new Error(`Native binding package version mismatch, expected 0.2.0-pre.
|
|
223
|
+
if (bindingPackageVersion !== '0.2.0-pre.13' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
224
|
+
throw new Error(`Native binding package version mismatch, expected 0.2.0-pre.13 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
225
225
|
}
|
|
226
226
|
return binding
|
|
227
227
|
} catch (e) {
|
|
@@ -236,8 +236,8 @@ function requireNative() {
|
|
|
236
236
|
try {
|
|
237
237
|
const binding = require('@tursodatabase/sync-freebsd-arm64')
|
|
238
238
|
const bindingPackageVersion = require('@tursodatabase/sync-freebsd-arm64/package.json').version
|
|
239
|
-
if (bindingPackageVersion !== '0.2.0-pre.
|
|
240
|
-
throw new Error(`Native binding package version mismatch, expected 0.2.0-pre.
|
|
239
|
+
if (bindingPackageVersion !== '0.2.0-pre.13' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
240
|
+
throw new Error(`Native binding package version mismatch, expected 0.2.0-pre.13 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
241
241
|
}
|
|
242
242
|
return binding
|
|
243
243
|
} catch (e) {
|
|
@@ -257,8 +257,8 @@ function requireNative() {
|
|
|
257
257
|
try {
|
|
258
258
|
const binding = require('@tursodatabase/sync-linux-x64-musl')
|
|
259
259
|
const bindingPackageVersion = require('@tursodatabase/sync-linux-x64-musl/package.json').version
|
|
260
|
-
if (bindingPackageVersion !== '0.2.0-pre.
|
|
261
|
-
throw new Error(`Native binding package version mismatch, expected 0.2.0-pre.
|
|
260
|
+
if (bindingPackageVersion !== '0.2.0-pre.13' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
261
|
+
throw new Error(`Native binding package version mismatch, expected 0.2.0-pre.13 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
262
262
|
}
|
|
263
263
|
return binding
|
|
264
264
|
} catch (e) {
|
|
@@ -273,8 +273,8 @@ function requireNative() {
|
|
|
273
273
|
try {
|
|
274
274
|
const binding = require('@tursodatabase/sync-linux-x64-gnu')
|
|
275
275
|
const bindingPackageVersion = require('@tursodatabase/sync-linux-x64-gnu/package.json').version
|
|
276
|
-
if (bindingPackageVersion !== '0.2.0-pre.
|
|
277
|
-
throw new Error(`Native binding package version mismatch, expected 0.2.0-pre.
|
|
276
|
+
if (bindingPackageVersion !== '0.2.0-pre.13' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
277
|
+
throw new Error(`Native binding package version mismatch, expected 0.2.0-pre.13 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
278
278
|
}
|
|
279
279
|
return binding
|
|
280
280
|
} catch (e) {
|
|
@@ -291,8 +291,8 @@ function requireNative() {
|
|
|
291
291
|
try {
|
|
292
292
|
const binding = require('@tursodatabase/sync-linux-arm64-musl')
|
|
293
293
|
const bindingPackageVersion = require('@tursodatabase/sync-linux-arm64-musl/package.json').version
|
|
294
|
-
if (bindingPackageVersion !== '0.2.0-pre.
|
|
295
|
-
throw new Error(`Native binding package version mismatch, expected 0.2.0-pre.
|
|
294
|
+
if (bindingPackageVersion !== '0.2.0-pre.13' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
295
|
+
throw new Error(`Native binding package version mismatch, expected 0.2.0-pre.13 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
296
296
|
}
|
|
297
297
|
return binding
|
|
298
298
|
} catch (e) {
|
|
@@ -307,8 +307,8 @@ function requireNative() {
|
|
|
307
307
|
try {
|
|
308
308
|
const binding = require('@tursodatabase/sync-linux-arm64-gnu')
|
|
309
309
|
const bindingPackageVersion = require('@tursodatabase/sync-linux-arm64-gnu/package.json').version
|
|
310
|
-
if (bindingPackageVersion !== '0.2.0-pre.
|
|
311
|
-
throw new Error(`Native binding package version mismatch, expected 0.2.0-pre.
|
|
310
|
+
if (bindingPackageVersion !== '0.2.0-pre.13' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
311
|
+
throw new Error(`Native binding package version mismatch, expected 0.2.0-pre.13 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
312
312
|
}
|
|
313
313
|
return binding
|
|
314
314
|
} catch (e) {
|
|
@@ -325,8 +325,8 @@ function requireNative() {
|
|
|
325
325
|
try {
|
|
326
326
|
const binding = require('@tursodatabase/sync-linux-arm-musleabihf')
|
|
327
327
|
const bindingPackageVersion = require('@tursodatabase/sync-linux-arm-musleabihf/package.json').version
|
|
328
|
-
if (bindingPackageVersion !== '0.2.0-pre.
|
|
329
|
-
throw new Error(`Native binding package version mismatch, expected 0.2.0-pre.
|
|
328
|
+
if (bindingPackageVersion !== '0.2.0-pre.13' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
329
|
+
throw new Error(`Native binding package version mismatch, expected 0.2.0-pre.13 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
330
330
|
}
|
|
331
331
|
return binding
|
|
332
332
|
} catch (e) {
|
|
@@ -341,8 +341,8 @@ function requireNative() {
|
|
|
341
341
|
try {
|
|
342
342
|
const binding = require('@tursodatabase/sync-linux-arm-gnueabihf')
|
|
343
343
|
const bindingPackageVersion = require('@tursodatabase/sync-linux-arm-gnueabihf/package.json').version
|
|
344
|
-
if (bindingPackageVersion !== '0.2.0-pre.
|
|
345
|
-
throw new Error(`Native binding package version mismatch, expected 0.2.0-pre.
|
|
344
|
+
if (bindingPackageVersion !== '0.2.0-pre.13' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
345
|
+
throw new Error(`Native binding package version mismatch, expected 0.2.0-pre.13 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
346
346
|
}
|
|
347
347
|
return binding
|
|
348
348
|
} catch (e) {
|
|
@@ -359,8 +359,8 @@ function requireNative() {
|
|
|
359
359
|
try {
|
|
360
360
|
const binding = require('@tursodatabase/sync-linux-riscv64-musl')
|
|
361
361
|
const bindingPackageVersion = require('@tursodatabase/sync-linux-riscv64-musl/package.json').version
|
|
362
|
-
if (bindingPackageVersion !== '0.2.0-pre.
|
|
363
|
-
throw new Error(`Native binding package version mismatch, expected 0.2.0-pre.
|
|
362
|
+
if (bindingPackageVersion !== '0.2.0-pre.13' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
363
|
+
throw new Error(`Native binding package version mismatch, expected 0.2.0-pre.13 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
364
364
|
}
|
|
365
365
|
return binding
|
|
366
366
|
} catch (e) {
|
|
@@ -375,8 +375,8 @@ function requireNative() {
|
|
|
375
375
|
try {
|
|
376
376
|
const binding = require('@tursodatabase/sync-linux-riscv64-gnu')
|
|
377
377
|
const bindingPackageVersion = require('@tursodatabase/sync-linux-riscv64-gnu/package.json').version
|
|
378
|
-
if (bindingPackageVersion !== '0.2.0-pre.
|
|
379
|
-
throw new Error(`Native binding package version mismatch, expected 0.2.0-pre.
|
|
378
|
+
if (bindingPackageVersion !== '0.2.0-pre.13' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
379
|
+
throw new Error(`Native binding package version mismatch, expected 0.2.0-pre.13 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
380
380
|
}
|
|
381
381
|
return binding
|
|
382
382
|
} catch (e) {
|
|
@@ -392,8 +392,8 @@ function requireNative() {
|
|
|
392
392
|
try {
|
|
393
393
|
const binding = require('@tursodatabase/sync-linux-ppc64-gnu')
|
|
394
394
|
const bindingPackageVersion = require('@tursodatabase/sync-linux-ppc64-gnu/package.json').version
|
|
395
|
-
if (bindingPackageVersion !== '0.2.0-pre.
|
|
396
|
-
throw new Error(`Native binding package version mismatch, expected 0.2.0-pre.
|
|
395
|
+
if (bindingPackageVersion !== '0.2.0-pre.13' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
396
|
+
throw new Error(`Native binding package version mismatch, expected 0.2.0-pre.13 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
397
397
|
}
|
|
398
398
|
return binding
|
|
399
399
|
} catch (e) {
|
|
@@ -408,8 +408,8 @@ function requireNative() {
|
|
|
408
408
|
try {
|
|
409
409
|
const binding = require('@tursodatabase/sync-linux-s390x-gnu')
|
|
410
410
|
const bindingPackageVersion = require('@tursodatabase/sync-linux-s390x-gnu/package.json').version
|
|
411
|
-
if (bindingPackageVersion !== '0.2.0-pre.
|
|
412
|
-
throw new Error(`Native binding package version mismatch, expected 0.2.0-pre.
|
|
411
|
+
if (bindingPackageVersion !== '0.2.0-pre.13' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
412
|
+
throw new Error(`Native binding package version mismatch, expected 0.2.0-pre.13 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
413
413
|
}
|
|
414
414
|
return binding
|
|
415
415
|
} catch (e) {
|
|
@@ -428,8 +428,8 @@ function requireNative() {
|
|
|
428
428
|
try {
|
|
429
429
|
const binding = require('@tursodatabase/sync-openharmony-arm64')
|
|
430
430
|
const bindingPackageVersion = require('@tursodatabase/sync-openharmony-arm64/package.json').version
|
|
431
|
-
if (bindingPackageVersion !== '0.2.0-pre.
|
|
432
|
-
throw new Error(`Native binding package version mismatch, expected 0.2.0-pre.
|
|
431
|
+
if (bindingPackageVersion !== '0.2.0-pre.13' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
432
|
+
throw new Error(`Native binding package version mismatch, expected 0.2.0-pre.13 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
433
433
|
}
|
|
434
434
|
return binding
|
|
435
435
|
} catch (e) {
|
|
@@ -444,8 +444,8 @@ function requireNative() {
|
|
|
444
444
|
try {
|
|
445
445
|
const binding = require('@tursodatabase/sync-openharmony-x64')
|
|
446
446
|
const bindingPackageVersion = require('@tursodatabase/sync-openharmony-x64/package.json').version
|
|
447
|
-
if (bindingPackageVersion !== '0.2.0-pre.
|
|
448
|
-
throw new Error(`Native binding package version mismatch, expected 0.2.0-pre.
|
|
447
|
+
if (bindingPackageVersion !== '0.2.0-pre.13' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
448
|
+
throw new Error(`Native binding package version mismatch, expected 0.2.0-pre.13 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
449
449
|
}
|
|
450
450
|
return binding
|
|
451
451
|
} catch (e) {
|
|
@@ -460,8 +460,8 @@ function requireNative() {
|
|
|
460
460
|
try {
|
|
461
461
|
const binding = require('@tursodatabase/sync-openharmony-arm')
|
|
462
462
|
const bindingPackageVersion = require('@tursodatabase/sync-openharmony-arm/package.json').version
|
|
463
|
-
if (bindingPackageVersion !== '0.2.0-pre.
|
|
464
|
-
throw new Error(`Native binding package version mismatch, expected 0.2.0-pre.
|
|
463
|
+
if (bindingPackageVersion !== '0.2.0-pre.13' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
464
|
+
throw new Error(`Native binding package version mismatch, expected 0.2.0-pre.13 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
465
465
|
}
|
|
466
466
|
return binding
|
|
467
467
|
} catch (e) {
|
|
@@ -508,7 +508,8 @@ if (!nativeBinding) {
|
|
|
508
508
|
throw new Error(`Failed to load native binding`)
|
|
509
509
|
}
|
|
510
510
|
|
|
511
|
-
const { Database, Statement, GeneratorHolder, JsDataCompletion, JsProtocolIo, JsProtocolRequestBytes, SyncEngine, SyncEngineChanges, DatabaseChangeTypeJs, SyncEngineProtocolVersion } = nativeBinding
|
|
511
|
+
const { BatchExecutor, Database, Statement, GeneratorHolder, JsDataCompletion, JsProtocolIo, JsProtocolRequestBytes, SyncEngine, SyncEngineChanges, DatabaseChangeTypeJs, SyncEngineProtocolVersion } = nativeBinding
|
|
512
|
+
export { BatchExecutor }
|
|
512
513
|
export { Database }
|
|
513
514
|
export { Statement }
|
|
514
515
|
export { GeneratorHolder }
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tursodatabase/sync",
|
|
3
|
-
"version": "0.2.0
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/tursodatabase/turso"
|
|
@@ -44,16 +44,16 @@
|
|
|
44
44
|
]
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"@tursodatabase/database-common": "^0.2.0
|
|
48
|
-
"@tursodatabase/sync-common": "^0.2.0
|
|
47
|
+
"@tursodatabase/database-common": "^0.2.0",
|
|
48
|
+
"@tursodatabase/sync-common": "^0.2.0"
|
|
49
49
|
},
|
|
50
50
|
"imports": {
|
|
51
51
|
"#index": "./index.js"
|
|
52
52
|
},
|
|
53
53
|
"optionalDependencies": {
|
|
54
|
-
"@tursodatabase/sync-linux-x64-gnu": "0.2.0
|
|
55
|
-
"@tursodatabase/sync-win32-x64-msvc": "0.2.0
|
|
56
|
-
"@tursodatabase/sync-darwin-arm64": "0.2.0
|
|
57
|
-
"@tursodatabase/sync-linux-arm64-gnu": "0.2.0
|
|
54
|
+
"@tursodatabase/sync-linux-x64-gnu": "0.2.0",
|
|
55
|
+
"@tursodatabase/sync-win32-x64-msvc": "0.2.0",
|
|
56
|
+
"@tursodatabase/sync-darwin-arm64": "0.2.0",
|
|
57
|
+
"@tursodatabase/sync-linux-arm64-gnu": "0.2.0"
|
|
58
58
|
}
|
|
59
59
|
}
|