@nsshunt/stsvueutils 2.0.13 → 2.0.14
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/stsvueutils.mjs +0 -174
- package/dist/stsvueutils.mjs.map +1 -1
- package/dist/stsvueutils.umd.js +2 -175
- package/dist/stsvueutils.umd.js.map +1 -1
- package/package.json +1 -1
- package/types/index.d.ts +0 -1
- package/types/index.d.ts.map +1 -1
- package/types/plugins/workerManager.d.ts.map +1 -1
- package/types/plugins/observabilitySubscriberManager.d.ts +0 -13
- package/types/plugins/observabilitySubscriberManager.d.ts.map +0 -1
- package/types/stores/modelStore.d.ts +0 -39
- package/types/stores/modelStore.d.ts.map +0 -1
package/dist/stsvueutils.mjs
CHANGED
|
@@ -22,7 +22,6 @@ import { inject } from "vue";
|
|
|
22
22
|
import { defaultLogger, ModelDelimeter, Sleep } from "@nsshunt/stsutils";
|
|
23
23
|
import { STSInstrumentControllerPluginKey, GetSTSInstrumentController, Gauge, GetSTSInstrumentControllerPluginKey } from "@nsshunt/stsobservability";
|
|
24
24
|
import { defineStore } from "pinia";
|
|
25
|
-
import _cloneDeep from "lodash.clonedeep";
|
|
26
25
|
const STSStoragePluginKey = Symbol("storage");
|
|
27
26
|
const STSEmitterPluginKey = Symbol("emitter");
|
|
28
27
|
const STSWorkerManagerPluginKey = Symbol("workerManager");
|
|
@@ -2179,38 +2178,6 @@ class STSWorkerManager {
|
|
|
2179
2178
|
}
|
|
2180
2179
|
return busyWorker;
|
|
2181
2180
|
});
|
|
2182
|
-
/*
|
|
2183
|
-
StopRunner = async () => {
|
|
2184
|
-
// Calculate the worker with the most runners
|
|
2185
|
-
let largestRunnerWorker: IWorkerEx | null = null;
|
|
2186
|
-
for (const [, stsWorker] of Object.entries(this.WorkersEx)) {
|
|
2187
|
-
if (largestRunnerWorker) {
|
|
2188
|
-
if (Object.keys(stsWorker.runnersEx).length > Object.keys(largestRunnerWorker.runnersEx).length) {
|
|
2189
|
-
largestRunnerWorker = stsWorker;
|
|
2190
|
-
}
|
|
2191
|
-
} else {
|
|
2192
|
-
largestRunnerWorker = stsWorker;
|
|
2193
|
-
}
|
|
2194
|
-
}
|
|
2195
|
-
if (largestRunnerWorker) largestRunnerWorker.StopRunner();
|
|
2196
|
-
}
|
|
2197
|
-
*/
|
|
2198
|
-
/*
|
|
2199
|
-
StopWorker = async () => {
|
|
2200
|
-
// Calculate the worker with the least runners
|
|
2201
|
-
let largestRunnerWorker: IWorkerEx | null = null;
|
|
2202
|
-
for (const [, stsWorker] of Object.entries(this.WorkersEx)) {
|
|
2203
|
-
if (largestRunnerWorker) {
|
|
2204
|
-
if (Object.keys(stsWorker.runnersEx).length < Object.keys(largestRunnerWorker.runnersEx).length) {
|
|
2205
|
-
largestRunnerWorker = stsWorker;
|
|
2206
|
-
}
|
|
2207
|
-
} else {
|
|
2208
|
-
largestRunnerWorker = stsWorker;
|
|
2209
|
-
}
|
|
2210
|
-
}
|
|
2211
|
-
if (largestRunnerWorker) largestRunnerWorker.Stop();
|
|
2212
|
-
}
|
|
2213
|
-
*/
|
|
2214
2181
|
__publicField(this, "StopAllWorkers", async () => {
|
|
2215
2182
|
const promArray = [];
|
|
2216
2183
|
for (const [, stsWorker] of Object.entries(this.WorkersEx)) {
|
|
@@ -2472,145 +2439,6 @@ _debug6 = new WeakMap();
|
|
|
2472
2439
|
_SetMessagePort = new WeakMap();
|
|
2473
2440
|
_AddAsyncRunner = new WeakMap();
|
|
2474
2441
|
_StopRunners = new WeakMap();
|
|
2475
|
-
var _estate = /* @__PURE__ */ ((_estate2) => {
|
|
2476
|
-
_estate2["IDLE"] = "idle";
|
|
2477
|
-
_estate2["STARTING"] = "starting";
|
|
2478
|
-
_estate2["STARTED"] = "started";
|
|
2479
|
-
_estate2["STOPPING"] = "stopping";
|
|
2480
|
-
_estate2["DELAYED_START"] = "delayed_start";
|
|
2481
|
-
return _estate2;
|
|
2482
|
-
})(_estate || {});
|
|
2483
|
-
const ModelStore = defineStore("__sts__ModelStore", {
|
|
2484
|
-
// State
|
|
2485
|
-
// https://pinia.vuejs.org/core-concepts/state.html
|
|
2486
|
-
state: () => {
|
|
2487
|
-
return {
|
|
2488
|
-
_models: {},
|
|
2489
|
-
_state: {},
|
|
2490
|
-
_observabilitySubscriberManager: {}
|
|
2491
|
-
};
|
|
2492
|
-
},
|
|
2493
|
-
// Getters
|
|
2494
|
-
// https://pinia.vuejs.org/core-concepts/getters.html
|
|
2495
|
-
// Actions
|
|
2496
|
-
// https://pinia.vuejs.org/core-concepts/actions.html
|
|
2497
|
-
actions: {
|
|
2498
|
-
/*
|
|
2499
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
2500
|
-
UpdateModel(model: MasterModel): void {
|
|
2501
|
-
//this.masterModel.serviceModel = _cloneDeep(model.serviceModel.model);
|
|
2502
|
-
//this.masterModel.agentModel = _cloneDeep(model.agentModel.model);
|
|
2503
|
-
},
|
|
2504
|
-
UpdateLogDataDirect(modeNode: any, logData: string[]): void {
|
|
2505
|
-
if (modeNode.instruments) {
|
|
2506
|
-
modeNode.instruments[Gauge.LOGGER] = {
|
|
2507
|
-
'_': 'd',
|
|
2508
|
-
val: _cloneDeep(logData)
|
|
2509
|
-
} as any
|
|
2510
|
-
modeNode.instruments[Gauge.LOGGER_COPY] = {
|
|
2511
|
-
'_': 'd',
|
|
2512
|
-
val: _cloneDeep(logData)
|
|
2513
|
-
} as any
|
|
2514
|
-
}
|
|
2515
|
-
},
|
|
2516
|
-
UpdateLogData(modeNode: any, logData: string[]): void {
|
|
2517
|
-
this.UpdateLogDataDirect(modeNode, [ ]);
|
|
2518
|
-
if (modeNode.instruments && modeNode.children) {
|
|
2519
|
-
for (const [k, v] of Object.entries(modeNode.children) as any) {
|
|
2520
|
-
this.UpdateLogDataDirect(v, [ ]);
|
|
2521
|
-
}
|
|
2522
|
-
}
|
|
2523
|
-
},
|
|
2524
|
-
UpdateModelEx(model: ModelNode): void {
|
|
2525
|
-
try {
|
|
2526
|
-
this.model = _cloneDeep((model as any).data);
|
|
2527
|
-
if (!this.model.context?.serviceInstanceId) {
|
|
2528
|
-
// Remove aggregated logs (legacy instruments when logs part of payload) for non serviceInstanceId 'levels'
|
|
2529
|
-
this.UpdateLogData(this.model, [ ]);
|
|
2530
|
-
}
|
|
2531
|
-
} catch (error) {
|
|
2532
|
-
console.error(chalk.red(`${error}`));
|
|
2533
|
-
//console.error(chalk.red(`${JSON.stringify(this.model)}`));
|
|
2534
|
-
}
|
|
2535
|
-
},
|
|
2536
|
-
UpdateModelLogs(nodeId: string, logMessages: string[]): void {
|
|
2537
|
-
const topicSplit = nodeId.split('_');
|
|
2538
|
-
const serviceInstanceId = `${topicSplit[0]}@${topicSplit[1]}`;
|
|
2539
|
-
const serviceInstanceProcessId = `${topicSplit[2]}@${topicSplit[3]}`;
|
|
2540
|
-
|
|
2541
|
-
//topic = (serviceInstanceId + '_' + serviceInstanceProcessId).replace(/@/g, '_');
|
|
2542
|
-
if (this.model.children) {
|
|
2543
|
-
for (const [k, v] of Object.entries(this.model.children) as any) {
|
|
2544
|
-
if (v.context.serviceInstanceId.localeCompare(serviceInstanceId) === 0) {
|
|
2545
|
-
if (v.context.serviceInstanceProcessId.localeCompare(serviceInstanceProcessId) === 0) {
|
|
2546
|
-
this.UpdateLogDataDirect(v, logMessages);
|
|
2547
|
-
}
|
|
2548
|
-
}
|
|
2549
|
-
}
|
|
2550
|
-
}
|
|
2551
|
-
},
|
|
2552
|
-
*/
|
|
2553
|
-
GetSate(modelId) {
|
|
2554
|
-
if (!this._state[modelId]) {
|
|
2555
|
-
this._state[modelId] = "idle";
|
|
2556
|
-
}
|
|
2557
|
-
return this._state[modelId];
|
|
2558
|
-
},
|
|
2559
|
-
UpdateSate(modelId, newSate) {
|
|
2560
|
-
this._state[modelId] = newSate;
|
|
2561
|
-
},
|
|
2562
|
-
UpdateObservabilitySubscriberManager(modelId, observabilitySubscriberManager) {
|
|
2563
|
-
if (observabilitySubscriberManager === null) {
|
|
2564
|
-
delete this._observabilitySubscriberManager[modelId];
|
|
2565
|
-
} else {
|
|
2566
|
-
this._observabilitySubscriberManager[modelId] = observabilitySubscriberManager;
|
|
2567
|
-
}
|
|
2568
|
-
},
|
|
2569
|
-
SetupNewModelId(modelId) {
|
|
2570
|
-
this._models[modelId] = {
|
|
2571
|
-
serviceModel: {},
|
|
2572
|
-
agentModel: {},
|
|
2573
|
-
modelMeta: {},
|
|
2574
|
-
serviceModelSubscriptionKey: null,
|
|
2575
|
-
agentModelSubscriptionKey: null,
|
|
2576
|
-
friendlyName: {},
|
|
2577
|
-
friendNameIndex: 1,
|
|
2578
|
-
state: "idle"
|
|
2579
|
-
};
|
|
2580
|
-
},
|
|
2581
|
-
UpdateServiceModel(modelId, model, subscriptionKey) {
|
|
2582
|
-
try {
|
|
2583
|
-
if (!this._models[modelId]) {
|
|
2584
|
-
this.SetupNewModelId(modelId);
|
|
2585
|
-
}
|
|
2586
|
-
this._models[modelId].serviceModel = _cloneDeep(model);
|
|
2587
|
-
this._models[modelId].serviceModelSubscriptionKey = subscriptionKey;
|
|
2588
|
-
} catch (error) {
|
|
2589
|
-
console.error(error);
|
|
2590
|
-
}
|
|
2591
|
-
},
|
|
2592
|
-
UpdateAgentModel(modelId, model, subscriptionKey) {
|
|
2593
|
-
if (!this._models[modelId]) {
|
|
2594
|
-
this.SetupNewModelId(modelId);
|
|
2595
|
-
}
|
|
2596
|
-
this._models[modelId].agentModel = _cloneDeep(model);
|
|
2597
|
-
this._models[modelId].agentModelSubscriptionKey = subscriptionKey;
|
|
2598
|
-
},
|
|
2599
|
-
GetFriendName(modelId, id) {
|
|
2600
|
-
try {
|
|
2601
|
-
if (!this._models[modelId]) {
|
|
2602
|
-
this.SetupNewModelId(modelId);
|
|
2603
|
-
}
|
|
2604
|
-
if (!this._models[modelId].friendlyName[id]) {
|
|
2605
|
-
this._models[modelId].friendlyName[id] = `FN${this._models[modelId].friendNameIndex++}@${id.split("@")[1]}`;
|
|
2606
|
-
}
|
|
2607
|
-
return this._models[modelId].friendlyName[id];
|
|
2608
|
-
} catch (error) {
|
|
2609
|
-
return `Error: ${error}`;
|
|
2610
|
-
}
|
|
2611
|
-
}
|
|
2612
|
-
}
|
|
2613
|
-
});
|
|
2614
2442
|
export {
|
|
2615
2443
|
ClientStorageFactory,
|
|
2616
2444
|
ClientStorageType,
|
|
@@ -2619,7 +2447,6 @@ export {
|
|
|
2619
2447
|
GetSTSInstrumentControllerPluginKeyWM,
|
|
2620
2448
|
IRunnerState,
|
|
2621
2449
|
IWorkerState,
|
|
2622
|
-
ModelStore,
|
|
2623
2450
|
RequestResponseHelper,
|
|
2624
2451
|
STSEmitterPlugin,
|
|
2625
2452
|
STSEmitterPluginKey,
|
|
@@ -2631,7 +2458,6 @@ export {
|
|
|
2631
2458
|
TelemetryStore,
|
|
2632
2459
|
URI_BASE_VUEUTILS,
|
|
2633
2460
|
WorkerInstance,
|
|
2634
|
-
_estate,
|
|
2635
2461
|
eIWMessageCommands,
|
|
2636
2462
|
useSTSEmitterPlugin,
|
|
2637
2463
|
useSTSStoragePlugin,
|