@based/db 0.2.8 → 0.2.9
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-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/libnode-v25.node +0 -0
- package/dist/lib/darwin_aarch64/libselva.dylib +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/libnode-v25.node +0 -0
- package/dist/lib/linux_aarch64/libselva.so +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/libnode-v25.node +0 -0
- package/dist/lib/linux_x86_64/libselva.so +0 -0
- package/dist/src/server/index.js +2 -9
- package/dist/src/server/migrate/index.js +19 -1
- package/dist/src/server/subscription.d.ts +1 -0
- package/dist/src/server/subscription.js +9 -0
- 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
|
package/dist/src/server/index.js
CHANGED
|
@@ -13,6 +13,7 @@ import { DbShared } from '../shared/DbBase.js';
|
|
|
13
13
|
import { setNativeSchema, setSchemaOnServer, writeSchemaFile, } from './schema.js';
|
|
14
14
|
import { resizeModifyDirtyRanges } from './resizeModifyDirtyRanges.js';
|
|
15
15
|
import { loadBlock, unloadBlock } from './blocks.js';
|
|
16
|
+
import { initDefaultSubscriptions } from './subscription.js';
|
|
16
17
|
const emptyUint8Array = new Uint8Array(0);
|
|
17
18
|
class SortIndex {
|
|
18
19
|
constructor(buf, dbCtxExternal) {
|
|
@@ -26,15 +27,7 @@ class SortIndex {
|
|
|
26
27
|
export class DbServer extends DbShared {
|
|
27
28
|
modifyDirtyRanges;
|
|
28
29
|
dbCtxExternal; // pointer to zig dbCtx
|
|
29
|
-
subscriptions =
|
|
30
|
-
subInterval: 200,
|
|
31
|
-
active: 0,
|
|
32
|
-
updateHandler: null,
|
|
33
|
-
ids: new Map(),
|
|
34
|
-
fullType: new Map(),
|
|
35
|
-
updateId: 1,
|
|
36
|
-
now: { listeners: new Set(), lastUpdated: 1 },
|
|
37
|
-
};
|
|
30
|
+
subscriptions = initDefaultSubscriptions();
|
|
38
31
|
migrating = null;
|
|
39
32
|
saveInProgress = false;
|
|
40
33
|
fileSystemPath;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BasedDb, save } from '../../index.js';
|
|
1
|
+
import { BasedDb, initDefaultSubscriptions, save } from '../../index.js';
|
|
2
2
|
import { dirname, join } from 'path';
|
|
3
3
|
import { Worker, MessageChannel } from 'node:worker_threads';
|
|
4
4
|
import native from '../../native.js';
|
|
@@ -140,6 +140,23 @@ export const migrate = async (server, fromSchema, toSchema, transform) => {
|
|
|
140
140
|
const end = start + def.blockCapacity - 1;
|
|
141
141
|
rangesToMigrate.push({ typeId, start, end });
|
|
142
142
|
});
|
|
143
|
+
rangesToMigrate.sort((a, b) => {
|
|
144
|
+
const typeA = server.schemaTypesParsedById[a.typeId];
|
|
145
|
+
const typeB = server.schemaTypesParsedById[b.typeId];
|
|
146
|
+
for (const k in typeA.props) {
|
|
147
|
+
const prop = typeA.props[k];
|
|
148
|
+
if (prop.dependent && prop.inverseTypeName === typeB.type) {
|
|
149
|
+
return 1;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
for (const k in typeB.props) {
|
|
153
|
+
const prop = typeB.props[k];
|
|
154
|
+
if (prop.dependent && prop.inverseTypeName === typeA.type) {
|
|
155
|
+
return -1;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
return 0;
|
|
159
|
+
});
|
|
143
160
|
await waitUntilSleeping(workerState);
|
|
144
161
|
while (i < rangesToMigrate.length) {
|
|
145
162
|
if (abort()) {
|
|
@@ -176,6 +193,7 @@ export const migrate = async (server, fromSchema, toSchema, transform) => {
|
|
|
176
193
|
}
|
|
177
194
|
server.dbCtxExternal = toCtx;
|
|
178
195
|
server.sortIndexes = {};
|
|
196
|
+
server.subscriptions = initDefaultSubscriptions();
|
|
179
197
|
setSchemaOnServer(server, toSchema);
|
|
180
198
|
tmpDb.server.dbCtxExternal = fromCtx;
|
|
181
199
|
// TODO makes this SYNC
|
|
@@ -27,6 +27,7 @@ export type Subscriptions = {
|
|
|
27
27
|
};
|
|
28
28
|
subInterval: number;
|
|
29
29
|
};
|
|
30
|
+
export declare const initDefaultSubscriptions: () => Subscriptions;
|
|
30
31
|
export declare const startUpdateHandler: (server: DbServer) => void;
|
|
31
32
|
export declare const registerSubscription: (server: DbServer, query: Uint8Array, sub: Uint8Array, onData: OnData, onError: OnError, subInterval?: number) => () => void;
|
|
32
33
|
export {};
|
|
@@ -3,6 +3,15 @@ import { SubscriptionType, } from '../client/query/subscription/types.js';
|
|
|
3
3
|
import native from '../native.js';
|
|
4
4
|
import { MAX_ID } from '@based/schema';
|
|
5
5
|
import { styleText } from 'util';
|
|
6
|
+
export const initDefaultSubscriptions = () => ({
|
|
7
|
+
subInterval: 200,
|
|
8
|
+
active: 0,
|
|
9
|
+
updateHandler: null,
|
|
10
|
+
ids: new Map(),
|
|
11
|
+
fullType: new Map(),
|
|
12
|
+
updateId: 1,
|
|
13
|
+
now: { listeners: new Set(), lastUpdated: 1 },
|
|
14
|
+
});
|
|
6
15
|
export const startUpdateHandler = (server) => {
|
|
7
16
|
// skip next if queries are sitll in progress can add a number for each staged sub
|
|
8
17
|
// combine this with handled modify
|