@based/db 0.0.50 → 0.0.52
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/libdeflate.dylib +0 -0
- package/dist/lib/darwin_aarch64/libjemalloc_selva.2.dylib +0 -0
- 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/hooks.js +7 -2
- package/dist/src/schema.js +8 -8
- package/dist/src/server/index.js +7 -1
- package/package.json +2 -2
|
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
|
|
Binary file
|
|
Binary file
|
package/dist/src/hooks.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import picocolors from 'picocolors';
|
|
2
|
+
import { displayTarget } from './client/query/display.js';
|
|
1
3
|
export const getDefaultHooks = (server, subInterval = 200) => {
|
|
2
4
|
return {
|
|
3
5
|
subscribe(q, onData, onError) {
|
|
@@ -8,7 +10,7 @@ export const getDefaultHooks = (server, subInterval = 200) => {
|
|
|
8
10
|
if (killed) {
|
|
9
11
|
return;
|
|
10
12
|
}
|
|
11
|
-
if (res.byteLength >=
|
|
13
|
+
if (res.byteLength >= 4) {
|
|
12
14
|
onData(res);
|
|
13
15
|
}
|
|
14
16
|
else if (res.byteLength === 1 && res[0] === 0) {
|
|
@@ -17,7 +19,10 @@ export const getDefaultHooks = (server, subInterval = 200) => {
|
|
|
17
19
|
return;
|
|
18
20
|
}
|
|
19
21
|
else {
|
|
20
|
-
|
|
22
|
+
const def = this.def;
|
|
23
|
+
let name = picocolors.red(`QueryError[${displayTarget(def)}]\n`);
|
|
24
|
+
name += ` Incorrect buffer received in subscription (maybe server not started ${res.byteLength}) bytes\n`;
|
|
25
|
+
onError(new Error(name));
|
|
21
26
|
}
|
|
22
27
|
timer = setTimeout(poll, subInterval);
|
|
23
28
|
};
|
package/dist/src/schema.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { getPropType } from '@based/schema';
|
|
2
|
+
import { deepCopy } from '@saulx/utils';
|
|
2
3
|
const exclude = new Set(['id', 'lastId', 'hash']);
|
|
3
4
|
export const schemaLooseEqual = (a, b, key) => {
|
|
4
5
|
if (a === b) {
|
|
@@ -49,13 +50,10 @@ export const schemaLooseEqual = (a, b, key) => {
|
|
|
49
50
|
export const parseSchema = (strictSchema) => {
|
|
50
51
|
let parsedSchema = strictSchema;
|
|
51
52
|
if (strictSchema.props) {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
const props = { ...strictSchema.props };
|
|
57
|
-
for (const key in props) {
|
|
58
|
-
const prop = props[key];
|
|
53
|
+
// TODO do this more precise
|
|
54
|
+
parsedSchema = deepCopy(strictSchema);
|
|
55
|
+
for (const key in parsedSchema.props) {
|
|
56
|
+
const prop = parsedSchema.props[key];
|
|
59
57
|
const propType = getPropType(prop);
|
|
60
58
|
let refProp;
|
|
61
59
|
if (propType === 'reference') {
|
|
@@ -63,6 +61,7 @@ export const parseSchema = (strictSchema) => {
|
|
|
63
61
|
}
|
|
64
62
|
else if (propType === 'references') {
|
|
65
63
|
refProp = prop.items;
|
|
64
|
+
prop.items = refProp;
|
|
66
65
|
}
|
|
67
66
|
if (refProp) {
|
|
68
67
|
const type = parsedSchema.types[refProp.ref];
|
|
@@ -82,10 +81,11 @@ export const parseSchema = (strictSchema) => {
|
|
|
82
81
|
refProp.prop = inverseKey;
|
|
83
82
|
}
|
|
84
83
|
}
|
|
84
|
+
parsedSchema.types ??= {};
|
|
85
85
|
// @ts-ignore This creates an internal type to use for root props
|
|
86
86
|
parsedSchema.types._root = {
|
|
87
87
|
id: 1,
|
|
88
|
-
props,
|
|
88
|
+
props: parsedSchema.props,
|
|
89
89
|
};
|
|
90
90
|
delete parsedSchema.props;
|
|
91
91
|
}
|
package/dist/src/server/index.js
CHANGED
|
@@ -287,7 +287,13 @@ export class DbServer {
|
|
|
287
287
|
if (schemaLooseEqual(parsedSchema, this.schema)) {
|
|
288
288
|
return this.schema;
|
|
289
289
|
}
|
|
290
|
-
|
|
290
|
+
try {
|
|
291
|
+
return this.migrateSchema(strictSchema, transformFns);
|
|
292
|
+
}
|
|
293
|
+
catch (e) {
|
|
294
|
+
console.error('error migrating schema:', e);
|
|
295
|
+
return this.schema;
|
|
296
|
+
}
|
|
291
297
|
}
|
|
292
298
|
this.schema = {
|
|
293
299
|
lastId: this.schema.lastId,
|