@tursodatabase/sync 0.5.0-pre.12 → 0.5.0-pre.13
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/dist/promise.d.ts +15 -0
- package/dist/promise.d.ts.map +1 -1
- package/dist/promise.js +104 -3
- package/index.js +48 -47
- package/package.json +9 -8
- package/dist/promise.test.d.ts +0 -2
- package/dist/promise.test.d.ts.map +0 -1
- package/dist/promise.test.js +0 -840
package/dist/promise.d.ts
CHANGED
|
@@ -26,6 +26,21 @@ declare class Database extends DatabasePromise {
|
|
|
26
26
|
* @returns statistic of current local database
|
|
27
27
|
*/
|
|
28
28
|
stats(): Promise<DatabaseStats>;
|
|
29
|
+
/**
|
|
30
|
+
* Executes the given SQL string.
|
|
31
|
+
* When remoteWrites is enabled, write statements are sent to the remote server.
|
|
32
|
+
*/
|
|
33
|
+
exec(sql: string): Promise<void>;
|
|
34
|
+
/**
|
|
35
|
+
* Prepares a SQL statement for execution.
|
|
36
|
+
* When remoteWrites is enabled, returns a wrapper that routes writes to remote.
|
|
37
|
+
*/
|
|
38
|
+
prepare(sql: string): any;
|
|
39
|
+
/**
|
|
40
|
+
* Returns a function that executes the given function in a transaction.
|
|
41
|
+
* When remoteWrites is enabled, the entire transaction goes to remote.
|
|
42
|
+
*/
|
|
43
|
+
transaction(fn: (...any: any[]) => Promise<any>): (...bindParameters: any[]) => Promise<any>;
|
|
29
44
|
/**
|
|
30
45
|
* close the database
|
|
31
46
|
*/
|
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,EAAE,cAAc,EAAW,mBAAmB,EAAE,oBAAoB,EAAE,0BAA0B,EAAE,aAAa,
|
|
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,EAAwE,MAAM,4BAA4B,CAAC;AAoDhQ,cAAM,QAAS,SAAQ,eAAe;;gBAMtB,IAAI,EAAE,YAAY;IAyF9B;;OAEG;IACY,OAAO;IAUtB;;;;OAIG;IACG,IAAI;IAWV;;;OAGG;IACG,IAAI;IAMV;;OAEG;IACG,UAAU;IAMhB;;OAEG;IACG,KAAK,IAAI,OAAO,CAAC,aAAa,CAAC;IAOrC;;;OAGG;IACY,IAAI,CAAC,GAAG,EAAE,MAAM;IAgB/B;;;OAGG;IACM,OAAO,CAAC,GAAG,EAAE,MAAM;IAkB5B;;;OAGG;IACM,WAAW,CAAC,EAAE,EAAE,CAAC,GAAG,GAAG,OAAA,KAAK,OAAO,CAAC,GAAG,CAAC;IAsCjD;;OAEG;IACY,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CASxC;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,5 +1,5 @@
|
|
|
1
1
|
import { DatabasePromise } from "@tursodatabase/database-common";
|
|
2
|
-
import { run, SyncEngineGuards, runner } from "@tursodatabase/sync-common";
|
|
2
|
+
import { run, SyncEngineGuards, runner, RemoteWriter, RemoteWriteStatement } from "@tursodatabase/sync-common";
|
|
3
3
|
import { SyncEngine, Database as NativeDatabase } from "#index";
|
|
4
4
|
import { promises } from "node:fs";
|
|
5
5
|
let NodeIO = {
|
|
@@ -40,13 +40,27 @@ function memoryIO() {
|
|
|
40
40
|
};
|
|
41
41
|
}
|
|
42
42
|
;
|
|
43
|
+
function resolveUrl(url) {
|
|
44
|
+
if (typeof url === "function") {
|
|
45
|
+
const resolved = url();
|
|
46
|
+
if (resolved == null) {
|
|
47
|
+
throw new Error("remoteWritesExperimental requires a non-null URL");
|
|
48
|
+
}
|
|
49
|
+
return resolved;
|
|
50
|
+
}
|
|
51
|
+
return url;
|
|
52
|
+
}
|
|
43
53
|
class Database extends DatabasePromise {
|
|
44
54
|
#engine;
|
|
45
55
|
#guards;
|
|
46
56
|
#runner;
|
|
57
|
+
#remoteWriter = null;
|
|
58
|
+
#db;
|
|
47
59
|
constructor(opts) {
|
|
48
60
|
if (opts.url == null) {
|
|
49
|
-
|
|
61
|
+
const db = new NativeDatabase(opts.path, { tracing: opts.tracing });
|
|
62
|
+
super(db);
|
|
63
|
+
this.#db = db;
|
|
50
64
|
this.#engine = null;
|
|
51
65
|
return;
|
|
52
66
|
}
|
|
@@ -77,7 +91,8 @@ class Database extends DatabasePromise {
|
|
|
77
91
|
longPollTimeoutMs: opts.longPollTimeoutMs,
|
|
78
92
|
tracing: opts.tracing,
|
|
79
93
|
bootstrapIfEmpty: typeof opts.url != "function" || opts.url() != null,
|
|
80
|
-
|
|
94
|
+
remoteEncryptionCipher: opts.remoteEncryption?.cipher,
|
|
95
|
+
remoteEncryptionKey: opts.remoteEncryption?.key,
|
|
81
96
|
partialSyncOpts: partialSyncOpts
|
|
82
97
|
});
|
|
83
98
|
let headers;
|
|
@@ -112,9 +127,19 @@ class Database extends DatabasePromise {
|
|
|
112
127
|
const io = memory ? memoryIO() : NodeIO;
|
|
113
128
|
const run = runner(runOpts, io, engine);
|
|
114
129
|
super(engine.db(), () => run.wait());
|
|
130
|
+
this.#db = engine.db();
|
|
115
131
|
this.#runner = run;
|
|
116
132
|
this.#engine = engine;
|
|
117
133
|
this.#guards = new SyncEngineGuards();
|
|
134
|
+
// Initialize remote writer if remoteWrites is enabled
|
|
135
|
+
if (opts.remoteWritesExperimental && opts.url) {
|
|
136
|
+
const url = resolveUrl(opts.url);
|
|
137
|
+
this.#remoteWriter = new RemoteWriter({
|
|
138
|
+
url,
|
|
139
|
+
authToken: opts.authToken,
|
|
140
|
+
remoteEncryptionKey: opts.remoteEncryption?.key,
|
|
141
|
+
});
|
|
142
|
+
}
|
|
118
143
|
}
|
|
119
144
|
/**
|
|
120
145
|
* connect database and initialize it in case of clean start
|
|
@@ -175,10 +200,86 @@ class Database extends DatabasePromise {
|
|
|
175
200
|
}
|
|
176
201
|
return (await run(this.#runner, this.#engine.stats()));
|
|
177
202
|
}
|
|
203
|
+
/**
|
|
204
|
+
* Executes the given SQL string.
|
|
205
|
+
* When remoteWrites is enabled, write statements are sent to the remote server.
|
|
206
|
+
*/
|
|
207
|
+
async exec(sql) {
|
|
208
|
+
if (!this.#remoteWriter)
|
|
209
|
+
return super.exec(sql);
|
|
210
|
+
const category = this.#db.classifySql(sql);
|
|
211
|
+
if (this.#remoteWriter.isInTransaction) {
|
|
212
|
+
const { shouldPull } = await this.#remoteWriter.execRemote(sql, category);
|
|
213
|
+
if (shouldPull)
|
|
214
|
+
await this.pull();
|
|
215
|
+
return;
|
|
216
|
+
}
|
|
217
|
+
if (category === "read")
|
|
218
|
+
return super.exec(sql);
|
|
219
|
+
const { shouldPull } = await this.#remoteWriter.execRemote(sql, category);
|
|
220
|
+
if (shouldPull)
|
|
221
|
+
await this.pull();
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* Prepares a SQL statement for execution.
|
|
225
|
+
* When remoteWrites is enabled, returns a wrapper that routes writes to remote.
|
|
226
|
+
*/
|
|
227
|
+
prepare(sql) {
|
|
228
|
+
const localStmt = super.prepare(sql);
|
|
229
|
+
if (!this.#remoteWriter) {
|
|
230
|
+
return localStmt;
|
|
231
|
+
}
|
|
232
|
+
const category = this.#db.classifySql(sql);
|
|
233
|
+
const isReadonly = category === "read";
|
|
234
|
+
return new RemoteWriteStatement(localStmt, sql, isReadonly, this.#remoteWriter, () => this.pull());
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* Returns a function that executes the given function in a transaction.
|
|
238
|
+
* When remoteWrites is enabled, the entire transaction goes to remote.
|
|
239
|
+
*/
|
|
240
|
+
transaction(fn) {
|
|
241
|
+
if (typeof fn !== "function")
|
|
242
|
+
throw new TypeError("Expected first argument to be a function");
|
|
243
|
+
if (!this.#remoteWriter) {
|
|
244
|
+
return super.transaction(fn);
|
|
245
|
+
}
|
|
246
|
+
const db = this;
|
|
247
|
+
const remoteWriter = this.#remoteWriter;
|
|
248
|
+
const wrapTxn = (mode) => {
|
|
249
|
+
return async (...bindParameters) => {
|
|
250
|
+
await remoteWriter.beginTransaction(mode);
|
|
251
|
+
try {
|
|
252
|
+
const result = await fn(...bindParameters);
|
|
253
|
+
await remoteWriter.commitTransaction();
|
|
254
|
+
await db.pull();
|
|
255
|
+
return result;
|
|
256
|
+
}
|
|
257
|
+
catch (err) {
|
|
258
|
+
await remoteWriter.rollbackTransaction();
|
|
259
|
+
throw err;
|
|
260
|
+
}
|
|
261
|
+
};
|
|
262
|
+
};
|
|
263
|
+
const properties = {
|
|
264
|
+
default: { value: wrapTxn("") },
|
|
265
|
+
deferred: { value: wrapTxn("DEFERRED") },
|
|
266
|
+
immediate: { value: wrapTxn("IMMEDIATE") },
|
|
267
|
+
exclusive: { value: wrapTxn("EXCLUSIVE") },
|
|
268
|
+
database: { value: this, enumerable: true },
|
|
269
|
+
};
|
|
270
|
+
Object.defineProperties(properties.default.value, properties);
|
|
271
|
+
Object.defineProperties(properties.deferred.value, properties);
|
|
272
|
+
Object.defineProperties(properties.immediate.value, properties);
|
|
273
|
+
Object.defineProperties(properties.exclusive.value, properties);
|
|
274
|
+
return properties.default.value;
|
|
275
|
+
}
|
|
178
276
|
/**
|
|
179
277
|
* close the database
|
|
180
278
|
*/
|
|
181
279
|
async close() {
|
|
280
|
+
if (this.#remoteWriter) {
|
|
281
|
+
await this.#remoteWriter.close();
|
|
282
|
+
}
|
|
182
283
|
await super.close();
|
|
183
284
|
if (this.#engine != null) {
|
|
184
285
|
this.#engine.close();
|
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.
|
|
85
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
84
|
+
if (bindingPackageVersion !== '0.5.0-pre.12' && 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.5.0-pre.12 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.
|
|
101
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
100
|
+
if (bindingPackageVersion !== '0.5.0-pre.12' && 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.5.0-pre.12 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.
|
|
121
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
120
|
+
if (bindingPackageVersion !== '0.5.0-pre.12' && 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.5.0-pre.12 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.
|
|
137
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
136
|
+
if (bindingPackageVersion !== '0.5.0-pre.12' && 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.5.0-pre.12 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.
|
|
153
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
152
|
+
if (bindingPackageVersion !== '0.5.0-pre.12' && 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.5.0-pre.12 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.
|
|
172
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
171
|
+
if (bindingPackageVersion !== '0.5.0-pre.12' && 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.5.0-pre.12 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.
|
|
188
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
187
|
+
if (bindingPackageVersion !== '0.5.0-pre.12' && 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.5.0-pre.12 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.
|
|
204
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
203
|
+
if (bindingPackageVersion !== '0.5.0-pre.12' && 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.5.0-pre.12 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.
|
|
224
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
223
|
+
if (bindingPackageVersion !== '0.5.0-pre.12' && 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.5.0-pre.12 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.
|
|
240
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
239
|
+
if (bindingPackageVersion !== '0.5.0-pre.12' && 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.5.0-pre.12 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.
|
|
261
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
260
|
+
if (bindingPackageVersion !== '0.5.0-pre.12' && 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.5.0-pre.12 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.
|
|
277
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
276
|
+
if (bindingPackageVersion !== '0.5.0-pre.12' && 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.5.0-pre.12 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.
|
|
295
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
294
|
+
if (bindingPackageVersion !== '0.5.0-pre.12' && 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.5.0-pre.12 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.
|
|
311
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
310
|
+
if (bindingPackageVersion !== '0.5.0-pre.12' && 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.5.0-pre.12 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.
|
|
329
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
328
|
+
if (bindingPackageVersion !== '0.5.0-pre.12' && 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.5.0-pre.12 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.
|
|
345
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
344
|
+
if (bindingPackageVersion !== '0.5.0-pre.12' && 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.5.0-pre.12 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.
|
|
363
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
362
|
+
if (bindingPackageVersion !== '0.5.0-pre.12' && 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.5.0-pre.12 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.
|
|
379
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
378
|
+
if (bindingPackageVersion !== '0.5.0-pre.12' && 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.5.0-pre.12 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.
|
|
396
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
395
|
+
if (bindingPackageVersion !== '0.5.0-pre.12' && 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.5.0-pre.12 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.
|
|
412
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
411
|
+
if (bindingPackageVersion !== '0.5.0-pre.12' && 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.5.0-pre.12 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.
|
|
432
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
431
|
+
if (bindingPackageVersion !== '0.5.0-pre.12' && 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.5.0-pre.12 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.
|
|
448
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
447
|
+
if (bindingPackageVersion !== '0.5.0-pre.12' && 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.5.0-pre.12 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.
|
|
464
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
463
|
+
if (bindingPackageVersion !== '0.5.0-pre.12' && 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.5.0-pre.12 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
465
465
|
}
|
|
466
466
|
return binding
|
|
467
467
|
} catch (e) {
|
|
@@ -508,10 +508,11 @@ if (!nativeBinding) {
|
|
|
508
508
|
throw new Error(`Failed to load native binding`)
|
|
509
509
|
}
|
|
510
510
|
|
|
511
|
-
const { BatchExecutor, Database, Statement, GeneratorHolder, JsDataCompletion, JsProtocolIo, JsProtocolRequestBytes, SyncEngine, SyncEngineChanges, DatabaseChangeTypeJs, SyncEngineProtocolVersion } = nativeBinding
|
|
511
|
+
const { BatchExecutor, Database, Statement, EncryptionCipher, GeneratorHolder, JsDataCompletion, JsProtocolIo, JsProtocolRequestBytes, SyncEngine, SyncEngineChanges, DatabaseChangeTypeJs, SyncEngineProtocolVersion } = nativeBinding
|
|
512
512
|
export { BatchExecutor }
|
|
513
513
|
export { Database }
|
|
514
514
|
export { Statement }
|
|
515
|
+
export { EncryptionCipher }
|
|
515
516
|
export { GeneratorHolder }
|
|
516
517
|
export { JsDataCompletion }
|
|
517
518
|
export { JsProtocolIo }
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tursodatabase/sync",
|
|
3
|
-
"version": "0.5.0-pre.
|
|
3
|
+
"version": "0.5.0-pre.13",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/tursodatabase/turso"
|
|
@@ -31,7 +31,8 @@
|
|
|
31
31
|
"napi-artifacts": "napi artifacts --output-dir .",
|
|
32
32
|
"tsc-build": "npm exec tsc",
|
|
33
33
|
"build": "npm run napi-build && npm run tsc-build",
|
|
34
|
-
"test": "VITE_TURSO_DB_URL=http://jj--a--a.localhost:8080 vitest --run",
|
|
34
|
+
"test": "VITE_TURSO_DB_URL=http://jj--a--a.localhost:8080 vitest --run --exclude remote-write.test.ts",
|
|
35
|
+
"test:remote-write": "vitest --run remote-write.test.ts",
|
|
35
36
|
"prepublishOnly": "npm run napi-dirs && npm run napi-artifacts && napi prepublish -t npm"
|
|
36
37
|
},
|
|
37
38
|
"napi": {
|
|
@@ -44,16 +45,16 @@
|
|
|
44
45
|
]
|
|
45
46
|
},
|
|
46
47
|
"dependencies": {
|
|
47
|
-
"@tursodatabase/database-common": "^0.5.0-pre.
|
|
48
|
-
"@tursodatabase/sync-common": "^0.5.0-pre.
|
|
48
|
+
"@tursodatabase/database-common": "^0.5.0-pre.13",
|
|
49
|
+
"@tursodatabase/sync-common": "^0.5.0-pre.13"
|
|
49
50
|
},
|
|
50
51
|
"imports": {
|
|
51
52
|
"#index": "./index.js"
|
|
52
53
|
},
|
|
53
54
|
"optionalDependencies": {
|
|
54
|
-
"@tursodatabase/sync-linux-x64-gnu": "0.5.0-pre.
|
|
55
|
-
"@tursodatabase/sync-win32-x64-msvc": "0.5.0-pre.
|
|
56
|
-
"@tursodatabase/sync-darwin-arm64": "0.5.0-pre.
|
|
57
|
-
"@tursodatabase/sync-linux-arm64-gnu": "0.5.0-pre.
|
|
55
|
+
"@tursodatabase/sync-linux-x64-gnu": "0.5.0-pre.13",
|
|
56
|
+
"@tursodatabase/sync-win32-x64-msvc": "0.5.0-pre.13",
|
|
57
|
+
"@tursodatabase/sync-darwin-arm64": "0.5.0-pre.13",
|
|
58
|
+
"@tursodatabase/sync-linux-arm64-gnu": "0.5.0-pre.13"
|
|
58
59
|
}
|
|
59
60
|
}
|
package/dist/promise.test.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"promise.test.d.ts","sourceRoot":"","sources":["../promise.test.ts"],"names":[],"mappings":""}
|