@based/db 0.0.60 → 0.0.62
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/lib/darwin_aarch64/libnode-v20.node +0 -0
- package/dist/lib/darwin_aarch64/libnode-v21.node +0 -0
- package/dist/lib/darwin_aarch64/libnode-v22.node +0 -0
- package/dist/lib/darwin_aarch64/libnode-v23.node +0 -0
- package/dist/lib/darwin_aarch64/libnode-v24.node +0 -0
- package/dist/lib/darwin_aarch64/libselva.dylib +0 -0
- package/dist/lib/linux_aarch64/libnode-v20.node +0 -0
- package/dist/lib/linux_aarch64/libnode-v21.node +0 -0
- package/dist/lib/linux_aarch64/libnode-v22.node +0 -0
- package/dist/lib/linux_aarch64/libnode-v23.node +0 -0
- package/dist/lib/linux_aarch64/libnode-v24.node +0 -0
- package/dist/lib/linux_aarch64/libselva.so +0 -0
- package/dist/lib/linux_x86_64/libnode-v20.node +0 -0
- package/dist/lib/linux_x86_64/libnode-v21.node +0 -0
- package/dist/lib/linux_x86_64/libnode-v22.node +0 -0
- package/dist/lib/linux_x86_64/libnode-v23.node +0 -0
- package/dist/lib/linux_x86_64/libnode-v24.node +0 -0
- package/dist/lib/linux_x86_64/libselva.so +0 -0
- package/dist/src/client/modify/references/references.js +1 -1
- package/dist/src/client/query/BasedDbQuery.js +7 -13
- package/dist/src/server/DbWorker.js +5 -0
- package/dist/src/server/index.js +9 -7
- package/dist/src/server/migrate/index.js +1 -2
- package/dist/src/server/schema.d.ts +1 -1
- package/dist/src/server/schema.js +1 -1
- package/package.json +1 -1
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -7,7 +7,7 @@ export function writeReferences(value, ctx, schema, def, res, mod) {
|
|
|
7
7
|
if (typeof value !== 'object') {
|
|
8
8
|
return new ModifyError(def, value);
|
|
9
9
|
}
|
|
10
|
-
if (value === null) {
|
|
10
|
+
if (value === null || (Array.isArray(value) && value.length === 0)) {
|
|
11
11
|
if (ctx.len + 11 > ctx.max) {
|
|
12
12
|
return RANGE_ERR;
|
|
13
13
|
}
|
|
@@ -11,6 +11,7 @@ import { langCodesMap } from '@based/schema';
|
|
|
11
11
|
import { convertFilter } from './filter/convertFilter.js';
|
|
12
12
|
import { validateLocale, validateRange } from './validation.js';
|
|
13
13
|
import { DEF_RANGE_PROP_LIMIT } from './thresholds.js';
|
|
14
|
+
import { wait } from '@saulx/utils';
|
|
14
15
|
import { displayTarget } from './display.js';
|
|
15
16
|
import picocolors from 'picocolors';
|
|
16
17
|
export class QueryBranch {
|
|
@@ -305,9 +306,6 @@ export class BasedDbQuery extends QueryBranch {
|
|
|
305
306
|
}
|
|
306
307
|
}
|
|
307
308
|
}
|
|
308
|
-
// const def = createQueryDef(db, QueryDefType.Root, target, skipValidation)
|
|
309
|
-
// def.schemaChecksum = db.schema?.hash || 0
|
|
310
|
-
// def: QueryDef
|
|
311
309
|
super(db);
|
|
312
310
|
this.db = db;
|
|
313
311
|
this.skipValidation = skipValidation;
|
|
@@ -340,17 +338,13 @@ export class BasedDbQuery extends QueryBranch {
|
|
|
340
338
|
const res = await this.db.hooks.getQueryBuf(buf);
|
|
341
339
|
if (res.byteLength === 1) {
|
|
342
340
|
if (res[0] === 0) {
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
}
|
|
349
|
-
else {
|
|
350
|
-
this.db.emit('info', 'query get schema mismatch - got the same already');
|
|
351
|
-
this.reset();
|
|
352
|
-
return this.#getInternal(resolve, reject);
|
|
341
|
+
this.reset();
|
|
342
|
+
this.db.emit('info', 'query get schema mismatch - awaiting new schema (max 15s)');
|
|
343
|
+
const ok = await Promise.race([wait(15e3), this.db.once('schema')]);
|
|
344
|
+
if (!ok) {
|
|
345
|
+
reject(new Error('schema mismath'));
|
|
353
346
|
}
|
|
347
|
+
return this.#getInternal(resolve, reject);
|
|
354
348
|
}
|
|
355
349
|
else {
|
|
356
350
|
reject(new Error('unexpected error'));
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { MessageChannel, Worker } from 'node:worker_threads';
|
|
2
2
|
import { fileURLToPath } from 'node:url';
|
|
3
3
|
import { dirname, join } from 'node:path';
|
|
4
|
+
import { readUint64 } from '@saulx/utils';
|
|
4
5
|
const __filename = fileURLToPath(import.meta.url);
|
|
5
6
|
const __dirname = dirname(__filename);
|
|
6
7
|
const workerPath = join(__dirname, 'worker.js');
|
|
@@ -60,6 +61,10 @@ export class DbWorker {
|
|
|
60
61
|
return new Promise(this.callback);
|
|
61
62
|
}
|
|
62
63
|
getQueryBuf(buf) {
|
|
64
|
+
const schemaChecksum = readUint64(buf, buf.byteLength - 8);
|
|
65
|
+
if (schemaChecksum !== this.db.schema?.hash) {
|
|
66
|
+
return Promise.resolve(new Uint8Array(1));
|
|
67
|
+
}
|
|
63
68
|
this.channel.postMessage(buf);
|
|
64
69
|
return new Promise(this.callback);
|
|
65
70
|
}
|
package/dist/src/server/index.js
CHANGED
|
@@ -437,13 +437,15 @@ export class DbServer extends DbShared {
|
|
|
437
437
|
}
|
|
438
438
|
async destroy() {
|
|
439
439
|
await this.stop(true);
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
440
|
+
if (this.fileSystemPath) {
|
|
441
|
+
await rm(this.fileSystemPath, { recursive: true }).catch((err) => {
|
|
442
|
+
// console.warn(
|
|
443
|
+
// 'Error removing dump folder',
|
|
444
|
+
// this.fileSystemPath,
|
|
445
|
+
// err.message,
|
|
446
|
+
// ),
|
|
447
|
+
});
|
|
448
|
+
}
|
|
447
449
|
}
|
|
448
450
|
}
|
|
449
451
|
//# sourceMappingURL=index.js.map
|
|
@@ -55,8 +55,7 @@ export const migrate = async (server, fromSchema, toSchema, transform) => {
|
|
|
55
55
|
return;
|
|
56
56
|
}
|
|
57
57
|
setSchemaOnServer(tmpDb.server, toSchema);
|
|
58
|
-
|
|
59
|
-
await setNativeSchema(tmpDb.server, toSchema);
|
|
58
|
+
setNativeSchema(tmpDb.server, toSchema);
|
|
60
59
|
if (abort()) {
|
|
61
60
|
await tmpDb.destroy();
|
|
62
61
|
return;
|
|
@@ -3,5 +3,5 @@ import { DbSchema } from '../schema.js';
|
|
|
3
3
|
import { StrictSchema } from '@based/schema';
|
|
4
4
|
export declare const setSchemaOnServer: (server: DbServer, schema: DbSchema) => void;
|
|
5
5
|
export declare const writeSchemaFile: (server: DbServer, schema: DbSchema) => Promise<void>;
|
|
6
|
-
export declare const setNativeSchema: (server: DbServer, schema: DbSchema) =>
|
|
6
|
+
export declare const setNativeSchema: (server: DbServer, schema: DbSchema) => void;
|
|
7
7
|
export declare const strictSchemaToDbSchema: (schema: StrictSchema) => DbSchema;
|
|
@@ -22,7 +22,7 @@ export const writeSchemaFile = async (server, schema) => {
|
|
|
22
22
|
throw new Error(`Error writing schema to a file path ${schemaFilePath}}`);
|
|
23
23
|
}
|
|
24
24
|
};
|
|
25
|
-
export const setNativeSchema =
|
|
25
|
+
export const setNativeSchema = (server, schema) => {
|
|
26
26
|
const types = Object.keys(server.schemaTypesParsed);
|
|
27
27
|
const s = schemaToSelvaBuffer(server.schemaTypesParsed);
|
|
28
28
|
for (let i = 0; i < s.length; i++) {
|