@harperfast/harper-pro 5.0.5 → 5.0.6
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/core/bin/status.js +2 -2
- package/core/bin/stop.js +5 -6
- package/core/components/EntryHandler.ts +4 -2
- package/core/components/Scope.ts +1 -1
- package/core/components/componentLoader.ts +11 -4
- package/core/components/requestRestart.ts +17 -2
- package/core/dataLayer/harperBridge/TableSizeObject.ts +35 -0
- package/core/dataLayer/harperBridge/lmdbBridge/lmdbUtility/lmdbGetTableSize.ts +24 -0
- package/core/package-lock.json +1020 -101
- package/core/resources/DatabaseTransaction.ts +8 -3
- package/core/resources/Table.ts +12 -17
- package/core/resources/databases.ts +2 -2
- package/core/resources/graphql.ts +163 -165
- package/core/resources/indexes/HierarchicalNavigableSmallWorld.ts +14 -3
- package/core/resources/indexes/vector.ts +17 -0
- package/core/resources/loadEnv.ts +20 -16
- package/core/resources/login.ts +4 -3
- package/core/resources/roles.ts +60 -65
- package/core/security/auth.ts +15 -14
- package/core/security/jsLoader.ts +27 -9
- package/core/server/REST.ts +10 -11
- package/core/server/fastifyRoutes.ts +30 -29
- package/core/server/graphqlQuerying.ts +4 -3
- package/core/server/http.ts +175 -1
- package/core/server/mqtt.ts +8 -2
- package/core/server/serverHelpers/serverUtilities.ts +2 -5
- package/core/server/threads/threadServer.js +30 -2
- package/core/server/throttle.ts +18 -0
- package/core/utility/environment/environmentManager.js +10 -4
- package/core/utility/environment/systemInformation.ts +698 -0
- package/core/utility/hdbTerms.ts +1 -0
- package/core/utility/operation_authorization.js +2 -5
- package/dist/core/bin/status.js +2 -2
- package/dist/core/bin/status.js.map +1 -1
- package/dist/core/bin/stop.js +5 -5
- package/dist/core/bin/stop.js.map +1 -1
- package/dist/core/components/EntryHandler.js +4 -2
- package/dist/core/components/EntryHandler.js.map +1 -1
- package/dist/core/components/Scope.js +1 -1
- package/dist/core/components/Scope.js.map +1 -1
- package/dist/core/components/componentLoader.js +11 -3
- package/dist/core/components/componentLoader.js.map +1 -1
- package/dist/core/components/requestRestart.js +12 -1
- package/dist/core/components/requestRestart.js.map +1 -1
- package/dist/core/dataLayer/harperBridge/TableSizeObject.js +32 -0
- package/dist/core/dataLayer/harperBridge/TableSizeObject.js.map +1 -0
- package/dist/core/dataLayer/harperBridge/lmdbBridge/lmdbUtility/lmdbGetTableSize.js +18 -19
- package/dist/core/dataLayer/harperBridge/lmdbBridge/lmdbUtility/lmdbGetTableSize.js.map +1 -1
- package/dist/core/resources/DatabaseTransaction.js +6 -1
- package/dist/core/resources/DatabaseTransaction.js.map +1 -1
- package/dist/core/resources/Table.js +14 -18
- package/dist/core/resources/Table.js.map +1 -1
- package/dist/core/resources/databases.js +2 -1
- package/dist/core/resources/databases.js.map +1 -1
- package/dist/core/resources/graphql.js +176 -176
- package/dist/core/resources/graphql.js.map +1 -1
- package/dist/core/resources/indexes/HierarchicalNavigableSmallWorld.js +14 -2
- package/dist/core/resources/indexes/HierarchicalNavigableSmallWorld.js.map +1 -1
- package/dist/core/resources/indexes/vector.js +14 -0
- package/dist/core/resources/indexes/vector.js.map +1 -1
- package/dist/core/resources/loadEnv.js +20 -17
- package/dist/core/resources/loadEnv.js.map +1 -1
- package/dist/core/resources/login.js +4 -4
- package/dist/core/resources/login.js.map +1 -1
- package/dist/core/resources/roles.js +64 -68
- package/dist/core/resources/roles.js.map +1 -1
- package/dist/core/security/auth.js +17 -15
- package/dist/core/security/auth.js.map +1 -1
- package/dist/core/security/jsLoader.js +29 -9
- package/dist/core/security/jsLoader.js.map +1 -1
- package/dist/core/server/REST.js +11 -11
- package/dist/core/server/REST.js.map +1 -1
- package/dist/core/server/fastifyRoutes.js +30 -29
- package/dist/core/server/fastifyRoutes.js.map +1 -1
- package/dist/core/server/graphqlQuerying.js +5 -4
- package/dist/core/server/graphqlQuerying.js.map +1 -1
- package/dist/core/server/http.js +179 -0
- package/dist/core/server/http.js.map +1 -1
- package/dist/core/server/mqtt.js +5 -3
- package/dist/core/server/mqtt.js.map +1 -1
- package/dist/core/server/serverHelpers/serverUtilities.js +2 -2
- package/dist/core/server/serverHelpers/serverUtilities.js.map +1 -1
- package/dist/core/server/threads/threadServer.js +26 -2
- package/dist/core/server/threads/threadServer.js.map +1 -1
- package/dist/core/server/throttle.js +17 -0
- package/dist/core/server/throttle.js.map +1 -1
- package/dist/core/utility/environment/environmentManager.js +9 -4
- package/dist/core/utility/environment/environmentManager.js.map +1 -1
- package/dist/core/utility/environment/systemInformation.js +359 -219
- package/dist/core/utility/environment/systemInformation.js.map +1 -1
- package/dist/core/utility/hdbTerms.js +1 -0
- package/dist/core/utility/hdbTerms.js.map +1 -1
- package/dist/core/utility/operation_authorization.js +2 -2
- package/dist/core/utility/operation_authorization.js.map +1 -1
- package/dist/licensing/usageLicensing.js +1 -1
- package/dist/licensing/usageLicensing.js.map +1 -1
- package/licensing/usageLicensing.ts +1 -1
- package/npm-shrinkwrap.json +982 -62
- package/package.json +2 -1
- package/studio/web/assets/{index-D07pIqJt.js → index-qbLPhOzw.js} +2 -2
- package/studio/web/assets/{index-D07pIqJt.js.map → index-qbLPhOzw.js.map} +1 -1
- package/studio/web/index.html +1 -1
- package/core/dataLayer/harperBridge/lmdbBridge/lmdbUtility/TableSizeObject.js +0 -25
- package/core/dataLayer/harperBridge/lmdbBridge/lmdbUtility/lmdbGetTableSize.js +0 -34
- package/core/utility/environment/systemInformation.js +0 -355
- package/dist/core/dataLayer/harperBridge/lmdbBridge/lmdbUtility/TableSizeObject.js +0 -24
- package/dist/core/dataLayer/harperBridge/lmdbBridge/lmdbUtility/TableSizeObject.js.map +0 -1
package/core/bin/status.js
CHANGED
|
@@ -6,7 +6,7 @@ const YAML = require('yaml');
|
|
|
6
6
|
|
|
7
7
|
const hdbTerms = require('../utility/hdbTerms.ts');
|
|
8
8
|
const hdbLog = require('../utility/logging/harper_logger.js');
|
|
9
|
-
const
|
|
9
|
+
const systemInformation = require('../utility/environment/systemInformation.ts');
|
|
10
10
|
const envMgr = require('../utility/environment/environmentManager.js');
|
|
11
11
|
const installation = require('../utility/installation.ts');
|
|
12
12
|
envMgr.initSync();
|
|
@@ -51,7 +51,7 @@ async function status() {
|
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
// Check the saved pid against any running hdb processes
|
|
54
|
-
const hdbSysInfo = await
|
|
54
|
+
const hdbSysInfo = await systemInformation.getHDBProcessInfo();
|
|
55
55
|
for (const proc of hdbSysInfo.core) {
|
|
56
56
|
if (proc.pid === hdbPid) {
|
|
57
57
|
status.harperdb.status = STATUSES.RUNNING;
|
package/core/bin/stop.js
CHANGED
|
@@ -4,7 +4,7 @@ const hdbLogger = require('../utility/logging/harper_logger.js');
|
|
|
4
4
|
const util = require('util');
|
|
5
5
|
const childProcess = require('child_process');
|
|
6
6
|
const exec = util.promisify(childProcess.exec);
|
|
7
|
-
const
|
|
7
|
+
const systemInformation = require('../utility/environment/systemInformation.ts');
|
|
8
8
|
|
|
9
9
|
const STOP_MSG = 'Stopping Harper Pro.';
|
|
10
10
|
|
|
@@ -14,9 +14,8 @@ async function stop() {
|
|
|
14
14
|
console.log(STOP_MSG);
|
|
15
15
|
hdbLogger.notify(STOP_MSG);
|
|
16
16
|
|
|
17
|
-
const processes = await
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
});
|
|
17
|
+
const processes = await systemInformation.getHDBProcessInfo();
|
|
18
|
+
for (const { pid } of processes.core) {
|
|
19
|
+
exec(`kill ${pid}`);
|
|
20
|
+
}
|
|
22
21
|
}
|
|
@@ -189,12 +189,14 @@ export class EntryHandler extends EventEmitter<EntryHandlerEventMap> {
|
|
|
189
189
|
.watch(this.#component.commonPatternBase, {
|
|
190
190
|
cwd: this.#component.directory,
|
|
191
191
|
persistent: false,
|
|
192
|
+
followSymlinks: false,
|
|
192
193
|
ignored: (path) => {
|
|
193
194
|
const normalizedPath = path.replace(/\\/g, '/');
|
|
194
195
|
const normalizedBases = allowedBases.map((base) => base.replace(/\\/g, '/'));
|
|
195
196
|
return (
|
|
196
|
-
normalizedPath
|
|
197
|
-
|
|
197
|
+
normalizedPath.includes('/node_modules') ||
|
|
198
|
+
(normalizedPath !== this.#component.directory.replace(/\\/g, '/') &&
|
|
199
|
+
normalizedBases.every((base) => !normalizedPath.startsWith(base)))
|
|
198
200
|
);
|
|
199
201
|
},
|
|
200
202
|
})
|
package/core/components/Scope.ts
CHANGED
|
@@ -63,7 +63,7 @@ export class Scope extends EventEmitter<ScopeEventsMap> {
|
|
|
63
63
|
this.#pluginName = pluginName;
|
|
64
64
|
this.#directory = directory;
|
|
65
65
|
this.#configFilePath = configFilePath;
|
|
66
|
-
this.#logger =
|
|
66
|
+
this.#logger = loggerWithTag(this.#appName);
|
|
67
67
|
|
|
68
68
|
this.databaseEvents = databaseEventsEmitter;
|
|
69
69
|
this.applicationScope = applicationScope;
|
|
@@ -17,7 +17,8 @@ import * as staticFiles from '../server/static.ts';
|
|
|
17
17
|
import * as loadEnv from '../resources/loadEnv.ts';
|
|
18
18
|
import harperLogger from '../utility/logging/harper_logger.js';
|
|
19
19
|
import * as dataLoader from '../resources/dataLoader.ts';
|
|
20
|
-
import {
|
|
20
|
+
import { restartWorkers, getWorkerIndex } from '../server/threads/manageThreads.js';
|
|
21
|
+
import { resetRestartNeeded, subscribeToRestartRequests } from './requestRestart.ts';
|
|
21
22
|
import { scopedImport } from '../security/jsLoader.ts';
|
|
22
23
|
import { server } from '../server/Server.ts';
|
|
23
24
|
import { Resources } from '../resources/Resources.ts';
|
|
@@ -515,10 +516,16 @@ export async function loadComponent(
|
|
|
515
516
|
}
|
|
516
517
|
|
|
517
518
|
compName = parentCompName;
|
|
518
|
-
// Auto restart threads on changes to any app folder. TODO: Make this configurable
|
|
519
519
|
if (isMainThread && !watchesSetup && autoReload) {
|
|
520
|
-
|
|
521
|
-
|
|
520
|
+
let debounceTimer: ReturnType<typeof setTimeout> | null = null;
|
|
521
|
+
subscribeToRestartRequests(() => {
|
|
522
|
+
if (debounceTimer) clearTimeout(debounceTimer);
|
|
523
|
+
debounceTimer = setTimeout(async () => {
|
|
524
|
+
debounceTimer = null;
|
|
525
|
+
resetRestartNeeded();
|
|
526
|
+
await loadComponentDirectories();
|
|
527
|
+
restartWorkers();
|
|
528
|
+
}, 500);
|
|
522
529
|
});
|
|
523
530
|
}
|
|
524
531
|
if ((config.extensionModule || config.pluginModule) && (!isMainThread || config.runOnMainThread)) {
|
|
@@ -1,11 +1,19 @@
|
|
|
1
1
|
import { Status } from '../server/status/index.ts';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
interface NotifyingArrayBuffer extends ArrayBuffer {
|
|
4
|
+
notify(): void;
|
|
5
|
+
cancel(): void;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
let restartArrayBuffer: NotifyingArrayBuffer;
|
|
4
9
|
let restartNeededArray: Uint8Array;
|
|
10
|
+
let onRestartRequestedCallback: (() => void) | null = null;
|
|
5
11
|
|
|
6
12
|
function ensureInitialized() {
|
|
7
13
|
if (!restartArrayBuffer) {
|
|
8
|
-
restartArrayBuffer = Status.primaryStore.getUserSharedBuffer('restart-needed', new ArrayBuffer(1)
|
|
14
|
+
restartArrayBuffer = Status.primaryStore.getUserSharedBuffer('restart-needed', new ArrayBuffer(1), {
|
|
15
|
+
callback: () => onRestartRequestedCallback?.(),
|
|
16
|
+
}) as NotifyingArrayBuffer;
|
|
9
17
|
restartNeededArray = new Uint8Array(restartArrayBuffer);
|
|
10
18
|
}
|
|
11
19
|
}
|
|
@@ -13,6 +21,7 @@ function ensureInitialized() {
|
|
|
13
21
|
export function requestRestart() {
|
|
14
22
|
ensureInitialized();
|
|
15
23
|
restartNeededArray[0] = 1;
|
|
24
|
+
restartArrayBuffer.notify();
|
|
16
25
|
}
|
|
17
26
|
|
|
18
27
|
export function restartNeeded() {
|
|
@@ -24,3 +33,9 @@ export function resetRestartNeeded() {
|
|
|
24
33
|
ensureInitialized();
|
|
25
34
|
restartNeededArray[0] = 0;
|
|
26
35
|
}
|
|
36
|
+
|
|
37
|
+
export function subscribeToRestartRequests(callback: () => void) {
|
|
38
|
+
ensureInitialized();
|
|
39
|
+
if (onRestartRequestedCallback) throw new Error('A restart-request subscriber is already registered');
|
|
40
|
+
onRestartRequestedCallback = callback;
|
|
41
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Represents the table size entry for a RocksDB or LMDB table.
|
|
3
|
+
*/
|
|
4
|
+
export class TableSizeObject {
|
|
5
|
+
schema: string;
|
|
6
|
+
table: string;
|
|
7
|
+
tableSize: number;
|
|
8
|
+
recordCount: number;
|
|
9
|
+
transactionLogSize: number;
|
|
10
|
+
transactionLogRecordCount?: number;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* @param schema - The schema of the table
|
|
14
|
+
* @param table - The name of the table
|
|
15
|
+
* @param tableSize - The data size of the table in bytes
|
|
16
|
+
* @param recordCount - The number of entries in the table
|
|
17
|
+
* @param transactionLogSize - The number of entries in the transaction log
|
|
18
|
+
* @param transactionLogRecordCount - The data size of the transaction log in bytes
|
|
19
|
+
*/
|
|
20
|
+
constructor(
|
|
21
|
+
schema: string,
|
|
22
|
+
table: string,
|
|
23
|
+
tableSize: number = 0,
|
|
24
|
+
recordCount: number = 0,
|
|
25
|
+
transactionLogSize: number = 0,
|
|
26
|
+
transactionLogRecordCount?: number
|
|
27
|
+
) {
|
|
28
|
+
this.schema = schema;
|
|
29
|
+
this.table = table;
|
|
30
|
+
this.tableSize = tableSize;
|
|
31
|
+
this.recordCount = recordCount;
|
|
32
|
+
this.transactionLogSize = transactionLogSize;
|
|
33
|
+
this.transactionLogRecordCount = transactionLogRecordCount;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { TableSizeObject } from '../../TableSizeObject.ts';
|
|
2
|
+
import logger from '../../../../utility/logging/harper_logger.js';
|
|
3
|
+
import type { Table } from '../../../../resources/databases.ts';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Calculates the number of entries & data size in bytes for a table & its transaction log
|
|
7
|
+
* @param table
|
|
8
|
+
* @returns {TableSizeObject}
|
|
9
|
+
*/
|
|
10
|
+
export function lmdbGetTableSize(table: Table) {
|
|
11
|
+
const tableStats = new TableSizeObject(table.databaseName, table.tableName);
|
|
12
|
+
try {
|
|
13
|
+
const dbiStat = table.primaryStore.getStats();
|
|
14
|
+
|
|
15
|
+
//get the txn log record count
|
|
16
|
+
const txnDbiStat = table.auditStore?.getStats();
|
|
17
|
+
|
|
18
|
+
tableStats.recordCount = dbiStat.entryCount;
|
|
19
|
+
tableStats.transactionLogRecordCount = txnDbiStat.entryCount;
|
|
20
|
+
} catch (e) {
|
|
21
|
+
logger.warn(`unable to stat table dbi due to ${e}`);
|
|
22
|
+
}
|
|
23
|
+
return tableStats;
|
|
24
|
+
}
|