@mxtommy/kip 4.7.0-beta.2 → 4.7.0-beta.3
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/package.json +1 -1
- package/plugin/history-series.service.js +91 -13
- package/plugin/index.js +110 -8
- package/plugin/kip-plugin/src/history-series.service.js +537 -0
- package/plugin/kip-plugin/src/index.js +1194 -0
- package/plugin/kip-plugin/src/openApi.json +787 -0
- package/plugin/kip-plugin/src/sqlite-history-storage.service.js +1122 -0
- package/plugin/openApi.json +14 -0
- package/plugin/sqlite-history-storage.service.js +13 -19
- package/plugin/src/app/core/contracts/kip-series-contract.js +14 -0
- package/plugin/src/app/core/contracts/kip-series-contract.spec.js +68 -0
- package/public/assets/svg/icons.svg +1 -1
- package/public/{chunk-3MSOVKX6.js → chunk-4YDVZHMH.js} +1 -1
- package/public/{chunk-7H5VXIPS.js → chunk-7ZZK5KBC.js} +1 -1
- package/public/{chunk-EZZ4IJBX.js → chunk-AB34PRGT.js} +1 -1
- package/public/{chunk-NK7SNP45.js → chunk-AQROQY2F.js} +1 -1
- package/public/{chunk-CMHH7BXX.js → chunk-BQPPRM7O.js} +1 -1
- package/public/{chunk-64MHGMIL.js → chunk-CRJ2S7XQ.js} +2 -2
- package/public/{chunk-7EAIOLCB.js → chunk-IENESD5Q.js} +1 -1
- package/public/{chunk-CHMMSVYD.js → chunk-M37BLWHF.js} +5 -5
- package/public/{chunk-Y4DXERRE.js → chunk-OXKOGBYN.js} +12 -12
- package/public/{chunk-FVGLVFWP.js → chunk-QV7OHVD5.js} +1 -1
- package/public/{chunk-NFUW7ILE.js → chunk-SDPSUOCJ.js} +1 -1
- package/public/{chunk-B3VMWHNV.js → chunk-YY4ZUJFI.js} +1 -1
- package/public/index.html +1 -1
- package/public/{main-VB3XIM4H.js → main-5HQ6OYM7.js} +1 -1
package/plugin/openApi.json
CHANGED
|
@@ -150,6 +150,20 @@
|
|
|
150
150
|
"path": {
|
|
151
151
|
"type": "string"
|
|
152
152
|
},
|
|
153
|
+
"expansionMode": {
|
|
154
|
+
"type": "string",
|
|
155
|
+
"nullable": true,
|
|
156
|
+
"enum": [
|
|
157
|
+
"bms-battery-tree"
|
|
158
|
+
]
|
|
159
|
+
},
|
|
160
|
+
"allowedBatteryIds": {
|
|
161
|
+
"type": "array",
|
|
162
|
+
"nullable": true,
|
|
163
|
+
"items": {
|
|
164
|
+
"type": "string"
|
|
165
|
+
}
|
|
166
|
+
},
|
|
153
167
|
"context": {
|
|
154
168
|
"type": "string",
|
|
155
169
|
"nullable": true
|
|
@@ -38,7 +38,7 @@ const fs_1 = require("fs");
|
|
|
38
38
|
const path_1 = require("path");
|
|
39
39
|
const DEFAULT_STORAGE_CONFIG = {
|
|
40
40
|
engine: 'node:sqlite',
|
|
41
|
-
databaseFile: '
|
|
41
|
+
databaseFile: '',
|
|
42
42
|
flushIntervalMs: 30_000
|
|
43
43
|
};
|
|
44
44
|
/**
|
|
@@ -49,8 +49,7 @@ class SqliteHistoryStorageService {
|
|
|
49
49
|
static FOUR_HOURS_INTERVAL = 4 * 60 * 60 * 1000;
|
|
50
50
|
static STALE_SERIES_AGE_MS = 180 * 24 * 60 * 60 * 1000;
|
|
51
51
|
static PRUNE_BATCH_SIZE = 10_000;
|
|
52
|
-
config
|
|
53
|
-
dataDirPath = null;
|
|
52
|
+
config;
|
|
54
53
|
logger = {
|
|
55
54
|
debug: () => undefined,
|
|
56
55
|
error: () => undefined
|
|
@@ -66,6 +65,16 @@ class SqliteHistoryStorageService {
|
|
|
66
65
|
vacuumJob = null;
|
|
67
66
|
pruneJob = null;
|
|
68
67
|
staleSeriesCleanupJob = null;
|
|
68
|
+
constructor(dataDirPath) {
|
|
69
|
+
const normalizedDataDirPath = typeof dataDirPath === 'string' ? dataDirPath.trim() : '';
|
|
70
|
+
if (!normalizedDataDirPath) {
|
|
71
|
+
throw new Error('SqliteHistoryStorageService requires a valid dataDirPath from server.getDataDirPath()');
|
|
72
|
+
}
|
|
73
|
+
this.config = {
|
|
74
|
+
...DEFAULT_STORAGE_CONFIG,
|
|
75
|
+
databaseFile: (0, path_1.join)(normalizedDataDirPath, 'historicalData', 'kip-history.sqlite')
|
|
76
|
+
};
|
|
77
|
+
}
|
|
69
78
|
/**
|
|
70
79
|
* Sets logger callbacks used by the storage service.
|
|
71
80
|
*
|
|
@@ -89,27 +98,12 @@ class SqliteHistoryStorageService {
|
|
|
89
98
|
*/
|
|
90
99
|
configure() {
|
|
91
100
|
this.initialized = false;
|
|
92
|
-
const databaseFile = this.dataDirPath
|
|
93
|
-
? (0, path_1.join)(this.dataDirPath, 'historicalData', 'kip-history.sqlite')
|
|
94
|
-
: DEFAULT_STORAGE_CONFIG.databaseFile;
|
|
95
101
|
this.config = {
|
|
96
102
|
...DEFAULT_STORAGE_CONFIG,
|
|
97
|
-
databaseFile
|
|
103
|
+
databaseFile: this.config.databaseFile
|
|
98
104
|
};
|
|
99
105
|
return this.config;
|
|
100
106
|
}
|
|
101
|
-
/**
|
|
102
|
-
* Sets the base directory for persisted history data.
|
|
103
|
-
*
|
|
104
|
-
* @param {string | null} baseDir Absolute directory path for plugin data.
|
|
105
|
-
* @returns {void}
|
|
106
|
-
*
|
|
107
|
-
* @example
|
|
108
|
-
* storage.setDataDirPath('/var/lib/signalk');
|
|
109
|
-
*/
|
|
110
|
-
setDataDirPath(baseDir) {
|
|
111
|
-
this.dataDirPath = typeof baseDir === 'string' && baseDir.trim() ? baseDir.trim() : null;
|
|
112
|
-
}
|
|
113
107
|
/**
|
|
114
108
|
* Updates runtime availability of node:sqlite, clearing stored errors when enabled.
|
|
115
109
|
*
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isKipTemplateSeriesDefinition = isKipTemplateSeriesDefinition;
|
|
4
|
+
exports.isKipConcreteSeriesDefinition = isKipConcreteSeriesDefinition;
|
|
5
|
+
exports.isKipSeriesEnabled = isKipSeriesEnabled;
|
|
6
|
+
function isKipTemplateSeriesDefinition(series) {
|
|
7
|
+
return series.expansionMode === 'bms-battery-tree';
|
|
8
|
+
}
|
|
9
|
+
function isKipConcreteSeriesDefinition(series) {
|
|
10
|
+
return series.expansionMode == null;
|
|
11
|
+
}
|
|
12
|
+
function isKipSeriesEnabled(series) {
|
|
13
|
+
return series.enabled;
|
|
14
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const kip_series_contract_1 = require("./kip-series-contract");
|
|
4
|
+
describe('kip-series-contract guards', () => {
|
|
5
|
+
const concreteSeries = {
|
|
6
|
+
seriesId: 'widget-1:datachart',
|
|
7
|
+
datasetUuid: 'widget-1',
|
|
8
|
+
ownerWidgetUuid: 'widget-1',
|
|
9
|
+
ownerWidgetSelector: 'widget-data-chart',
|
|
10
|
+
path: 'navigation.speedThroughWater',
|
|
11
|
+
expansionMode: null,
|
|
12
|
+
allowedBatteryIds: null,
|
|
13
|
+
context: 'vessels.self',
|
|
14
|
+
source: 'default',
|
|
15
|
+
timeScale: 'minute',
|
|
16
|
+
period: 10,
|
|
17
|
+
retentionDurationMs: null,
|
|
18
|
+
sampleTime: 1000,
|
|
19
|
+
enabled: true,
|
|
20
|
+
};
|
|
21
|
+
const templateSeries = {
|
|
22
|
+
seriesId: 'widget-2:bms-template',
|
|
23
|
+
datasetUuid: 'widget-2:bms-template',
|
|
24
|
+
ownerWidgetUuid: 'widget-2',
|
|
25
|
+
ownerWidgetSelector: 'widget-bms',
|
|
26
|
+
path: 'self.electrical.batteries.*',
|
|
27
|
+
expansionMode: 'bms-battery-tree',
|
|
28
|
+
allowedBatteryIds: ['house', 'start'],
|
|
29
|
+
context: 'vessels.self',
|
|
30
|
+
source: 'default',
|
|
31
|
+
timeScale: 'hour',
|
|
32
|
+
period: 24,
|
|
33
|
+
retentionDurationMs: 86400000,
|
|
34
|
+
sampleTime: null,
|
|
35
|
+
enabled: true,
|
|
36
|
+
};
|
|
37
|
+
it('identifies concrete series definitions', () => {
|
|
38
|
+
const value = concreteSeries;
|
|
39
|
+
expect((0, kip_series_contract_1.isKipConcreteSeriesDefinition)(value)).toBeTrue();
|
|
40
|
+
expect((0, kip_series_contract_1.isKipTemplateSeriesDefinition)(value)).toBeFalse();
|
|
41
|
+
});
|
|
42
|
+
it('identifies template series definitions', () => {
|
|
43
|
+
const value = templateSeries;
|
|
44
|
+
expect((0, kip_series_contract_1.isKipTemplateSeriesDefinition)(value)).toBeTrue();
|
|
45
|
+
expect((0, kip_series_contract_1.isKipConcreteSeriesDefinition)(value)).toBeFalse();
|
|
46
|
+
});
|
|
47
|
+
it('treats enabled false as disabled', () => {
|
|
48
|
+
expect((0, kip_series_contract_1.isKipSeriesEnabled)(concreteSeries)).toBeTrue();
|
|
49
|
+
expect((0, kip_series_contract_1.isKipSeriesEnabled)({ ...concreteSeries, enabled: false })).toBeFalse();
|
|
50
|
+
});
|
|
51
|
+
it('preserves template-only battery filters', () => {
|
|
52
|
+
const value = templateSeries;
|
|
53
|
+
if (!(0, kip_series_contract_1.isKipTemplateSeriesDefinition)(value)) {
|
|
54
|
+
fail('Expected template series definition');
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
expect(value.allowedBatteryIds).toEqual(['house', 'start']);
|
|
58
|
+
});
|
|
59
|
+
it('keeps concrete series free of template expansion state', () => {
|
|
60
|
+
const value = concreteSeries;
|
|
61
|
+
if (!(0, kip_series_contract_1.isKipConcreteSeriesDefinition)(value)) {
|
|
62
|
+
fail('Expected concrete series definition');
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
expect(value.expansionMode ?? null).toBeNull();
|
|
66
|
+
expect(value.allowedBatteryIds ?? null).toBeNull();
|
|
67
|
+
});
|
|
68
|
+
});
|
|
@@ -337,7 +337,7 @@
|
|
|
337
337
|
<path stroke="currentColor" stroke-linecap="round" stroke-miterlimit="10" stroke-width="3" d="M44.999 20.501v6.9987"></path>
|
|
338
338
|
</svg>
|
|
339
339
|
<svg id="battery_charging" xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 16 16">
|
|
340
|
-
<path d="M9.585 2.568a0.5 0.5 0 0 1 0.226 0.58L8.677 6.832h1.99a0.5 0.5 0 0 1 0.364 0.843l-5.334 5.667a0.5 0.5 0 0 1 -0.842 -0.49L5.99 9.167H4a0.5 0.5 0 0 1 -0.364 -0.843l5.333 -5.667a0.5 0.5 0 0 1 0.616 -0.09z" stroke-width="1"></path>
|
|
340
|
+
<path fill="var(--mat-sys-primary)" d="M9.585 2.568a0.5 0.5 0 0 1 0.226 0.58L8.677 6.832h1.99a0.5 0.5 0 0 1 0.364 0.843l-5.334 5.667a0.5 0.5 0 0 1 -0.842 -0.49L5.99 9.167H4a0.5 0.5 0 0 1 -0.364 -0.843l5.333 -5.667a0.5 0.5 0 0 1 0.616 -0.09z" stroke-width="1"></path>
|
|
341
341
|
<path d="M2 4h4.332l-0.94 1H2a1 1 0 0 0 -1 1v4a1 1 0 0 0 1 1h2.38l-0.308 1H2a2 2 0 0 1 -2 -2V6a2 2 0 0 1 2 -2" stroke-width="1"></path>
|
|
342
342
|
<path d="M2 6h2.45L2.908 7.639A1.5 1.5 0 0 0 3.313 10H2zm8.595 -2 -0.308 1H12a1 1 0 0 1 1 1v4a1 1 0 0 1 -1 1H9.276l-0.942 1H12a2 2 0 0 0 2 -2V6a2 2 0 0 0 -2 -2z" stroke-width="1"></path>
|
|
343
343
|
<path d="M12 10h-1.783l1.542 -1.639q0.146 -0.156 0.241 -0.34zm0 -3.354V6h-0.646a1.5 1.5 0 0 1 0.646 0.646M16 8a1.5 1.5 0 0 1 -1.5 1.5v-3A1.5 1.5 0 0 1 16 8" stroke-width="1"></path>
|