@winkjs/composer 0.5.0 → 0.6.0
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 +8 -8
- package/src/core/batch/aoo-encoder.js +4 -4
- package/src/core/batch/sliding-window.js +2 -2
- package/src/core/codec/index.js +4 -4
- package/src/core/emitter-manager/mqtt/emitter.js +44 -14
- package/src/core/emitter-manager/mqtt/index.js +2 -1
- package/src/core/emitter-manager/terminal/assert-columns.js +1 -1
- package/src/core/emitter-manager/terminal/index.js +4 -4
- package/src/core/env-vars.js +44 -3
- package/src/core/logger/index.js +174 -0
- package/src/core/mqtt-protocol.js +2 -2
- package/src/core/partition-manager/get-stats.js +31 -0
- package/src/core/partition-manager/index.js +1 -0
- package/src/core/partition-manager/init.js +15 -0
- package/src/core/partition-manager/update.js +143 -87
- package/src/core/partition-manager/validate-flow.js +1 -1
- package/src/core/semantics/loader.js +1 -1
- package/src/core/semantics/warnings.js +5 -3
- package/src/core/shutdown-manager/index.js +71 -21
- package/src/core/source-manager/csv/start.js +109 -35
- package/src/core/source-manager/mqtt/client.js +95 -36
- package/src/core/source-manager/mqtt/dedup.js +3 -3
- package/src/core/source-manager/mqtt/index.js +1 -1
- package/src/core/source-manager/mqtt/status.js +67 -14
- package/src/core/source-manager/record-shape.js +55 -0
- package/src/core/source-manager/test-harness/field-generator.js +1 -1
- package/src/core/source-manager/test-harness/start.js +52 -10
- package/src/core/source-manager/test-harness/validate.js +1 -1
- package/src/core/storage-manager/questdb/assert-columns.js +2 -2
- package/src/core/storage-manager/questdb/ensure-tables.js +1 -1
- package/src/core/storage-manager/questdb/index.js +55 -17
- package/src/core/storage-manager/questdb/persist-plan.js +32 -8
- package/src/core/tunable/helpers.js +1 -1
- package/src/core/utils/callback-guard/index.js +155 -0
- package/src/core/utils/half-life/index.js +4 -4
- package/src/core/utils/validate/composer-validators.js +2 -2
- package/src/core/utils/validate/index.js +1 -1
- package/src/core/utils/validate/validate.js +1 -1
- package/src/core/wiring/assert-handle.js +5 -5
- package/src/core/wiring/assert-module.js +2 -2
- package/src/core/wiring/wire-emitters.js +4 -3
- package/src/core/wiring/wire-linear-graph.js +1 -1
- package/src/core/wiring/wire-node.js +6 -6
- package/src/core/wiring/wire-semantics.js +1 -1
- package/src/core/wiring/wire-storages.js +4 -3
- package/src/flow/driver.js +31 -6
- package/src/flow/expand-single-input-array.js +4 -4
- package/src/flow/flow-api-schemas.js +4 -4
- package/src/flow/flow.js +41 -41
- package/src/flow/for-each.js +12 -11
- package/src/flow/get-target-array.js +2 -2
- package/src/flow/load-node-module.js +1 -1
- package/src/flow/make-node-method.js +4 -4
- package/src/flow/resolve-pick-by-field.js +1 -1
- package/src/flow/run.js +176 -38
- package/src/flow/serialize.js +1 -1
- package/src/flow/spec-builder.js +1 -1
- package/src/flow/validate.js +1 -1
- package/src/nodes/butterworth-filter/init.js +5 -4
- package/src/nodes/categorize/update.js +3 -1
- package/src/nodes/controller/update.js +2 -1
- package/src/nodes/dwell-time-tracker/update.js +2 -1
- package/src/nodes/emit-if/helpers.js +57 -11
- package/src/nodes/emit-if/init.js +1 -1
- package/src/nodes/emit-if/update.js +8 -11
- package/src/nodes/page-hinkley/update.js +2 -1
- package/src/nodes/pass-if/update.js +3 -1
- package/src/nodes/persist-if/helpers.js +60 -4
- package/src/nodes/persist-if/init.js +1 -1
- package/src/nodes/persist-if/update.js +8 -16
- package/src/nodes/persistence-check/update.js +2 -1
- package/src/nodes/sanitize/update.js +4 -2
- package/src/nodes/swing-watch/update.js +3 -2
- package/src/nodes/threshold/update.js +2 -1
- package/src/nodes/trend/compute-confidence.js +4 -4
- package/src/nodes/trend/update.js +2 -1
- package/src/nodes/winnow/update.js +3 -1
- package/src/tools/training/features.js +13 -13
- package/src/tools/training/logistic.js +1 -1
- package/src/tools/training/metrics.js +2 -2
- package/src/tools/training/scale.js +2 -2
- package/src/tools/training/validate.js +7 -7
- package/src/core/emitter-manager/mqtt/mqtt-store.js +0 -538
- package/src/core/utils/console-formatter/index.js +0 -207
- package/src/nodes/archive/csv/index.js +0 -6
- package/src/nodes/archive/csv/init.js +0 -36
- package/src/nodes/archive/csv/load.js +0 -70
- package/src/nodes/archive/csv/reset.js +0 -14
- package/src/nodes/archive/csv/simple-parser.js +0 -216
- package/src/nodes/archive/csv/test.js +0 -173
- package/src/nodes/archive/csv/update.js +0 -63
- package/src/nodes/sse-emitter/index.js +0 -7
- package/src/nodes/sse-emitter/init.js +0 -105
- package/src/nodes/sse-emitter/introspect.js +0 -134
- package/src/nodes/sse-emitter/publish-to.js +0 -6
- package/src/nodes/sse-emitter/recompute.js +0 -16
- package/src/nodes/sse-emitter/reset.js +0 -19
- package/src/nodes/sse-emitter/update.js +0 -69
- package/src/nodes/sse-emitter/utils/broadcast-heartbeat.js +0 -36
- package/src/nodes/sse-emitter/utils/build-message.js +0 -31
- package/src/nodes/sse-emitter/utils/connection-manager.js +0 -45
- package/src/nodes/sse-emitter/utils/endpoint-initializer.js +0 -20
- package/src/nodes/sse-emitter/utils/health-monitor.js +0 -38
- package/src/nodes/sse-emitter/utils/qos-handler.js +0 -41
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
// utils/connection-manager.js
|
|
2
|
-
|
|
3
|
-
const createSSEHeaders = function () {
|
|
4
|
-
return {
|
|
5
|
-
'Content-Type': 'text/event-stream',
|
|
6
|
-
'Cache-Control': 'no-cache',
|
|
7
|
-
'Connection': 'keep-alive',
|
|
8
|
-
// eslint-disable-next-line no-warning-comments
|
|
9
|
-
// TODO: Remove next line in production - dashboard served from same port
|
|
10
|
-
'Access-Control-Allow-Origin': '*'
|
|
11
|
-
};
|
|
12
|
-
}; // createSSEHeaders()
|
|
13
|
-
|
|
14
|
-
const createConnection = function ( state, res, endpointName ) {
|
|
15
|
-
const connection = {
|
|
16
|
-
response: res,
|
|
17
|
-
endpoint: endpointName,
|
|
18
|
-
qos: state.endpointQoS[ endpointName ],
|
|
19
|
-
createdAt: Date.now(),
|
|
20
|
-
messagesSent: 0
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
state.connections[ endpointName ].push( connection );
|
|
24
|
-
state.totalConnections += 1;
|
|
25
|
-
|
|
26
|
-
return connection;
|
|
27
|
-
}; // createConnection()
|
|
28
|
-
|
|
29
|
-
const removeConnection = function ( state, connection, endpointName ) {
|
|
30
|
-
const connections = state.connections[ endpointName ];
|
|
31
|
-
const index = connections.indexOf( connection );
|
|
32
|
-
if ( index !== -1 ) {
|
|
33
|
-
connections.splice( index, 1 );
|
|
34
|
-
state.totalConnections -= 1;
|
|
35
|
-
console.log( `SSE ${endpointName} disconnected (${state.totalConnections}/${state.maxConnections})` );
|
|
36
|
-
}
|
|
37
|
-
}; // removeConnection()
|
|
38
|
-
|
|
39
|
-
const setupConnectionHandlers = function ( state, req, connection, endpointName ) {
|
|
40
|
-
const cleanup = () => removeConnection( state, connection, endpointName );
|
|
41
|
-
req.on( 'close', cleanup );
|
|
42
|
-
req.on( 'error', cleanup );
|
|
43
|
-
}; // setupConnectionHandlers()
|
|
44
|
-
|
|
45
|
-
export { createSSEHeaders, createConnection, removeConnection, setupConnectionHandlers };
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
// utils/endpoint-initializer.js
|
|
2
|
-
|
|
3
|
-
const initializeEndpoints = function ( state ) {
|
|
4
|
-
state.endpointNames = Object.keys( state.stats );
|
|
5
|
-
state.connections = Object.create( null );
|
|
6
|
-
state.endpointQoS = Object.create( null );
|
|
7
|
-
|
|
8
|
-
// Create connection arrays and store QoS levels
|
|
9
|
-
for ( let i = 0; i < state.endpointNames.length; i += 1 ) {
|
|
10
|
-
const endpointName = state.endpointNames[ i ];
|
|
11
|
-
state.connections[ endpointName ] = [];
|
|
12
|
-
|
|
13
|
-
// Apply QoS defaults: dashboard=0, database=2, others=1
|
|
14
|
-
const defaultQoS = endpointName === 'dashboard' ? 0 :
|
|
15
|
-
endpointName === 'database' ? 2 : 1;
|
|
16
|
-
state.endpointQoS[ endpointName ] = state.stats[ endpointName ].qos || defaultQoS;
|
|
17
|
-
}
|
|
18
|
-
}; // initializeEndpoints()
|
|
19
|
-
|
|
20
|
-
export { initializeEndpoints };
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
// utils/health-monitor.js
|
|
2
|
-
|
|
3
|
-
const buildHealthResponse = function ( state ) {
|
|
4
|
-
const endpointStats = Object.create( null );
|
|
5
|
-
for ( let i = 0; i < state.endpointNames.length; i += 1 ) {
|
|
6
|
-
const endpointName = state.endpointNames[ i ];
|
|
7
|
-
endpointStats[ endpointName ] = state.connections[ endpointName ].length;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
return {
|
|
11
|
-
nodeType: state.nodeType,
|
|
12
|
-
connections: {
|
|
13
|
-
total: state.totalConnections,
|
|
14
|
-
byEndpoint: endpointStats
|
|
15
|
-
},
|
|
16
|
-
stats: {
|
|
17
|
-
sent: state.totalSent,
|
|
18
|
-
errors: state.totalErrors
|
|
19
|
-
},
|
|
20
|
-
endpoints: state.endpointNames,
|
|
21
|
-
timestamp: Date.now()
|
|
22
|
-
};
|
|
23
|
-
}; // buildHealthResponse()
|
|
24
|
-
|
|
25
|
-
const handleHealthCheck = function ( state, res ) {
|
|
26
|
-
const healthData = buildHealthResponse( state );
|
|
27
|
-
res.writeHead( 200, {
|
|
28
|
-
'Content-Type': 'application/json',
|
|
29
|
-
// eslint-disable-next-line no-warning-comments
|
|
30
|
-
// TODO: Remove next 3 lines in production - dashboard served from same port
|
|
31
|
-
'Access-Control-Allow-Origin': '*',
|
|
32
|
-
'Access-Control-Allow-Methods': 'GET',
|
|
33
|
-
'Access-Control-Allow-Headers': 'Content-Type'
|
|
34
|
-
} );
|
|
35
|
-
res.end( JSON.stringify( healthData ) );
|
|
36
|
-
}; // handleHealthCheck()
|
|
37
|
-
|
|
38
|
-
export { buildHealthResponse, handleHealthCheck };
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
// utils/qos-handler.js
|
|
2
|
-
|
|
3
|
-
import { QOS_FIRE_AND_FORGET, QOS_BEST_EFFORT, QOS_RELIABLE } from '../introspect.js';
|
|
4
|
-
|
|
5
|
-
const fireAndForgetSend = function ( connection, message, state ) {
|
|
6
|
-
connection.response.write( message );
|
|
7
|
-
connection.messagesSent += 1;
|
|
8
|
-
state.totalSent += 1;
|
|
9
|
-
}; // fireAndForgetSend()
|
|
10
|
-
|
|
11
|
-
const bestEffortSend = function ( connection, message, state, endpointName ) {
|
|
12
|
-
const success = connection.response.write( message );
|
|
13
|
-
if ( success ) {
|
|
14
|
-
connection.messagesSent += 1;
|
|
15
|
-
state.totalSent += 1;
|
|
16
|
-
} else {
|
|
17
|
-
console.warn( `${endpointName} client backpressure - best effort` );
|
|
18
|
-
state.totalSent += 1; // Count as sent for metrics
|
|
19
|
-
}
|
|
20
|
-
}; // bestEffortSend()
|
|
21
|
-
|
|
22
|
-
const reliableSend = function ( connection, message, state, endpointName ) {
|
|
23
|
-
const success = connection.response.write( message );
|
|
24
|
-
if ( success ) {
|
|
25
|
-
connection.messagesSent += 1;
|
|
26
|
-
state.totalSent += 1;
|
|
27
|
-
} else {
|
|
28
|
-
console.warn( `${endpointName} client backpressure - reliable mode` );
|
|
29
|
-
// TO DO: Implement proper queuing for reliable delivery
|
|
30
|
-
state.totalSent += 1; // Count as sent for now
|
|
31
|
-
}
|
|
32
|
-
}; // reliableSend()
|
|
33
|
-
|
|
34
|
-
// O(1) QoS handler dispatch table
|
|
35
|
-
const QOS_HANDLERS = {
|
|
36
|
-
[ QOS_FIRE_AND_FORGET ]: fireAndForgetSend,
|
|
37
|
-
[ QOS_BEST_EFFORT ]: bestEffortSend,
|
|
38
|
-
[ QOS_RELIABLE ]: reliableSend
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
export { QOS_HANDLERS };
|