ot-gateway 0.9.0 → 0.11.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/VERSION +1 -1
- package/apps/gateway/src/main.mjs +683 -211
- package/apps/web/out/404/index.html +1 -0
- package/apps/web/out/404.html +1 -1
- package/apps/web/out/__next.__PAGE__.txt +28 -26
- package/apps/web/out/__next._full.txt +23 -21
- package/apps/web/out/__next._tree.txt +2 -2
- package/apps/web/out/_next/static/chunks/03_syxbyimnor.js +1 -0
- package/apps/web/out/_next/static/chunks/1-_c1aqhwim5t.css +1 -0
- package/apps/web/out/_next/static/chunks/10i96w66fwhkr.js +31 -0
- package/apps/web/out/_next/static/chunks/1bh2-eknm9t8k.js +1 -0
- package/apps/web/out/_next/static/chunks/259s9pubapqip.js +1 -0
- package/apps/web/out/_next/static/chunks/25dqruymh00rk.js +1 -0
- package/apps/web/out/_next/static/chunks/2r_w-j--qdreu.js +22 -0
- package/apps/web/out/_next/static/chunks/3b0ql-jh_xg_k.js +12 -0
- package/apps/web/out/_next/static/chunks/3o5cr1y-sws-u.js +1 -0
- package/apps/web/out/_not-found/__next._full.txt +21 -19
- package/apps/web/out/_not-found/__next._not-found.__PAGE__.txt +27 -25
- package/apps/web/out/_not-found/__next._tree.txt +2 -2
- package/apps/web/out/_not-found/index.html +1 -0
- package/apps/web/out/_not-found/index.txt +22 -0
- package/apps/web/out/index.html +1 -1
- package/apps/web/out/index.txt +23 -21
- package/apps/web/out/messages/__next._full.txt +27 -0
- package/apps/web/out/messages/__next._tree.txt +4 -0
- package/apps/web/out/messages/__next.messages.__PAGE__.txt +33 -0
- package/apps/web/out/messages/index.html +1 -0
- package/apps/web/out/messages/index.txt +27 -0
- package/apps/web/out/points/__next._full.txt +27 -0
- package/apps/web/out/points/__next._tree.txt +4 -0
- package/apps/web/out/points/__next.points.__PAGE__.txt +33 -0
- package/apps/web/out/points/index.html +1 -0
- package/apps/web/out/points/index.txt +27 -0
- package/apps/web/out/settings/__next._full.txt +27 -0
- package/apps/web/out/settings/__next._tree.txt +4 -0
- package/apps/web/out/settings/__next.settings.__PAGE__.txt +33 -0
- package/apps/web/out/settings/index.html +1 -0
- package/apps/web/out/settings/index.txt +27 -0
- package/examples/gateway.json +37 -37
- package/package.json +1 -1
- package/packaging/compose.yaml +4 -2
- package/apps/web/out/_next/static/chunks/0csls39kpdzgy.js +0 -22
- package/apps/web/out/_next/static/chunks/162tvyao0-i49.js +0 -12
- package/apps/web/out/_next/static/chunks/29-6f2cs5ih9t.css +0 -1
- package/apps/web/out/_next/static/chunks/3oyy-mvhhfmq3.js +0 -31
- package/apps/web/out/_not-found.html +0 -1
- package/apps/web/out/_not-found.txt +0 -20
- /package/apps/web/out/_next/static/{POtpNv-gjWNowyFSmxfAr → r5hL3CDxDJkHMarR92YKm}/_buildManifest.js +0 -0
- /package/apps/web/out/_next/static/{POtpNv-gjWNowyFSmxfAr → r5hL3CDxDJkHMarR92YKm}/_clientMiddlewareManifest.js +0 -0
- /package/apps/web/out/_next/static/{POtpNv-gjWNowyFSmxfAr → r5hL3CDxDJkHMarR92YKm}/_ssgManifest.js +0 -0
|
@@ -40,9 +40,9 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
40
40
|
mod
|
|
41
41
|
));
|
|
42
42
|
|
|
43
|
-
// ../../node_modules/.pnpm/ws@8.22.
|
|
43
|
+
// ../../node_modules/.pnpm/ws@8.22.2/node_modules/ws/lib/constants.js
|
|
44
44
|
var require_constants = __commonJS({
|
|
45
|
-
"../../node_modules/.pnpm/ws@8.22.
|
|
45
|
+
"../../node_modules/.pnpm/ws@8.22.2/node_modules/ws/lib/constants.js"(exports, module) {
|
|
46
46
|
"use strict";
|
|
47
47
|
var BINARY_TYPES = ["nodebuffer", "arraybuffer", "fragments"];
|
|
48
48
|
var hasBlob = typeof Blob !== "undefined";
|
|
@@ -63,9 +63,9 @@ var require_constants = __commonJS({
|
|
|
63
63
|
}
|
|
64
64
|
});
|
|
65
65
|
|
|
66
|
-
// ../../node_modules/.pnpm/ws@8.22.
|
|
66
|
+
// ../../node_modules/.pnpm/ws@8.22.2/node_modules/ws/lib/buffer-util.js
|
|
67
67
|
var require_buffer_util = __commonJS({
|
|
68
|
-
"../../node_modules/.pnpm/ws@8.22.
|
|
68
|
+
"../../node_modules/.pnpm/ws@8.22.2/node_modules/ws/lib/buffer-util.js"(exports, module) {
|
|
69
69
|
"use strict";
|
|
70
70
|
var { websocketMask, websocketUnmask } = __require("http");
|
|
71
71
|
var { EMPTY_BUFFER } = require_constants();
|
|
@@ -148,9 +148,9 @@ var require_buffer_util = __commonJS({
|
|
|
148
148
|
}
|
|
149
149
|
});
|
|
150
150
|
|
|
151
|
-
// ../../node_modules/.pnpm/ws@8.22.
|
|
151
|
+
// ../../node_modules/.pnpm/ws@8.22.2/node_modules/ws/lib/limiter.js
|
|
152
152
|
var require_limiter = __commonJS({
|
|
153
|
-
"../../node_modules/.pnpm/ws@8.22.
|
|
153
|
+
"../../node_modules/.pnpm/ws@8.22.2/node_modules/ws/lib/limiter.js"(exports, module) {
|
|
154
154
|
"use strict";
|
|
155
155
|
var kDone = /* @__PURE__ */ Symbol("kDone");
|
|
156
156
|
var kRun = /* @__PURE__ */ Symbol("kRun");
|
|
@@ -198,9 +198,9 @@ var require_limiter = __commonJS({
|
|
|
198
198
|
}
|
|
199
199
|
});
|
|
200
200
|
|
|
201
|
-
// ../../node_modules/.pnpm/ws@8.22.
|
|
201
|
+
// ../../node_modules/.pnpm/ws@8.22.2/node_modules/ws/lib/permessage-deflate.js
|
|
202
202
|
var require_permessage_deflate = __commonJS({
|
|
203
|
-
"../../node_modules/.pnpm/ws@8.22.
|
|
203
|
+
"../../node_modules/.pnpm/ws@8.22.2/node_modules/ws/lib/permessage-deflate.js"(exports, module) {
|
|
204
204
|
"use strict";
|
|
205
205
|
var zlib = __require("zlib");
|
|
206
206
|
var bufferUtil = require_buffer_util();
|
|
@@ -581,9 +581,9 @@ var require_permessage_deflate = __commonJS({
|
|
|
581
581
|
}
|
|
582
582
|
});
|
|
583
583
|
|
|
584
|
-
// ../../node_modules/.pnpm/ws@8.22.
|
|
584
|
+
// ../../node_modules/.pnpm/ws@8.22.2/node_modules/ws/lib/validation.js
|
|
585
585
|
var require_validation = __commonJS({
|
|
586
|
-
"../../node_modules/.pnpm/ws@8.22.
|
|
586
|
+
"../../node_modules/.pnpm/ws@8.22.2/node_modules/ws/lib/validation.js"(exports, module) {
|
|
587
587
|
"use strict";
|
|
588
588
|
var { isUtf8 } = __require("buffer");
|
|
589
589
|
var { hasBlob } = require_constants();
|
|
@@ -782,9 +782,9 @@ var require_validation = __commonJS({
|
|
|
782
782
|
}
|
|
783
783
|
});
|
|
784
784
|
|
|
785
|
-
// ../../node_modules/.pnpm/ws@8.22.
|
|
785
|
+
// ../../node_modules/.pnpm/ws@8.22.2/node_modules/ws/lib/receiver.js
|
|
786
786
|
var require_receiver = __commonJS({
|
|
787
|
-
"../../node_modules/.pnpm/ws@8.22.
|
|
787
|
+
"../../node_modules/.pnpm/ws@8.22.2/node_modules/ws/lib/receiver.js"(exports, module) {
|
|
788
788
|
"use strict";
|
|
789
789
|
var { Writable } = __require("stream");
|
|
790
790
|
var PerMessageDeflate2 = require_permessage_deflate();
|
|
@@ -1194,6 +1194,7 @@ var require_receiver = __commonJS({
|
|
|
1194
1194
|
unmask(data, this._mask);
|
|
1195
1195
|
}
|
|
1196
1196
|
}
|
|
1197
|
+
this._mask = void 0;
|
|
1197
1198
|
if (this._opcode > 7) {
|
|
1198
1199
|
this.controlMessage(data, cb);
|
|
1199
1200
|
return;
|
|
@@ -1405,9 +1406,9 @@ var require_receiver = __commonJS({
|
|
|
1405
1406
|
}
|
|
1406
1407
|
});
|
|
1407
1408
|
|
|
1408
|
-
// ../../node_modules/.pnpm/ws@8.22.
|
|
1409
|
+
// ../../node_modules/.pnpm/ws@8.22.2/node_modules/ws/lib/sender.js
|
|
1409
1410
|
var require_sender = __commonJS({
|
|
1410
|
-
"../../node_modules/.pnpm/ws@8.22.
|
|
1411
|
+
"../../node_modules/.pnpm/ws@8.22.2/node_modules/ws/lib/sender.js"(exports, module) {
|
|
1411
1412
|
"use strict";
|
|
1412
1413
|
var { Duplex: Duplex2 } = __require("stream");
|
|
1413
1414
|
var { randomFillSync } = __require("crypto");
|
|
@@ -1901,9 +1902,9 @@ var require_sender = __commonJS({
|
|
|
1901
1902
|
}
|
|
1902
1903
|
});
|
|
1903
1904
|
|
|
1904
|
-
// ../../node_modules/.pnpm/ws@8.22.
|
|
1905
|
+
// ../../node_modules/.pnpm/ws@8.22.2/node_modules/ws/lib/event-target.js
|
|
1905
1906
|
var require_event_target = __commonJS({
|
|
1906
|
-
"../../node_modules/.pnpm/ws@8.22.
|
|
1907
|
+
"../../node_modules/.pnpm/ws@8.22.2/node_modules/ws/lib/event-target.js"(exports, module) {
|
|
1907
1908
|
"use strict";
|
|
1908
1909
|
var { kForOnEventAttribute, kListener } = require_constants();
|
|
1909
1910
|
var kCode = /* @__PURE__ */ Symbol("kCode");
|
|
@@ -2130,9 +2131,9 @@ var require_event_target = __commonJS({
|
|
|
2130
2131
|
}
|
|
2131
2132
|
});
|
|
2132
2133
|
|
|
2133
|
-
// ../../node_modules/.pnpm/ws@8.22.
|
|
2134
|
+
// ../../node_modules/.pnpm/ws@8.22.2/node_modules/ws/lib/extension.js
|
|
2134
2135
|
var require_extension = __commonJS({
|
|
2135
|
-
"../../node_modules/.pnpm/ws@8.22.
|
|
2136
|
+
"../../node_modules/.pnpm/ws@8.22.2/node_modules/ws/lib/extension.js"(exports, module) {
|
|
2136
2137
|
"use strict";
|
|
2137
2138
|
var { tokenChars } = require_validation();
|
|
2138
2139
|
function push(dest, name, elem) {
|
|
@@ -2283,14 +2284,15 @@ var require_extension = __commonJS({
|
|
|
2283
2284
|
}
|
|
2284
2285
|
});
|
|
2285
2286
|
|
|
2286
|
-
// ../../node_modules/.pnpm/ws@8.22.
|
|
2287
|
+
// ../../node_modules/.pnpm/ws@8.22.2/node_modules/ws/lib/websocket.js
|
|
2287
2288
|
var require_websocket = __commonJS({
|
|
2288
|
-
"../../node_modules/.pnpm/ws@8.22.
|
|
2289
|
+
"../../node_modules/.pnpm/ws@8.22.2/node_modules/ws/lib/websocket.js"(exports, module) {
|
|
2289
2290
|
"use strict";
|
|
2290
2291
|
var EventEmitter = __require("events");
|
|
2291
2292
|
var https = __require("https");
|
|
2292
2293
|
var http2 = __require("http");
|
|
2293
2294
|
var net = __require("net");
|
|
2295
|
+
var querystring = __require("querystring");
|
|
2294
2296
|
var tls = __require("tls");
|
|
2295
2297
|
var { randomBytes: randomBytes2, createHash } = __require("crypto");
|
|
2296
2298
|
var { Duplex: Duplex2, Readable: Readable6 } = __require("stream");
|
|
@@ -2817,10 +2819,9 @@ var require_websocket = __commonJS({
|
|
|
2817
2819
|
throw new SyntaxError(`Invalid URL: ${address}`);
|
|
2818
2820
|
}
|
|
2819
2821
|
}
|
|
2820
|
-
if (parsedUrl.protocol === "http:") {
|
|
2821
|
-
parsedUrl
|
|
2822
|
-
|
|
2823
|
-
parsedUrl.protocol = "wss:";
|
|
2822
|
+
if (parsedUrl.protocol === "http:" || parsedUrl.protocol === "https:") {
|
|
2823
|
+
parsedUrl = new URL4(parsedUrl);
|
|
2824
|
+
parsedUrl.protocol = parsedUrl.protocol === "http:" ? "ws:" : "wss:";
|
|
2824
2825
|
}
|
|
2825
2826
|
websocket._url = parsedUrl.href;
|
|
2826
2827
|
const isSecure = parsedUrl.protocol === "wss:";
|
|
@@ -2889,7 +2890,9 @@ var require_websocket = __commonJS({
|
|
|
2889
2890
|
}
|
|
2890
2891
|
}
|
|
2891
2892
|
if (parsedUrl.username || parsedUrl.password) {
|
|
2892
|
-
|
|
2893
|
+
const username = querystring.unescape(parsedUrl.username);
|
|
2894
|
+
const password = querystring.unescape(parsedUrl.password);
|
|
2895
|
+
opts.auth = `${username}:${password}`;
|
|
2893
2896
|
}
|
|
2894
2897
|
if (isIpcUrl) {
|
|
2895
2898
|
const i = opts.path.indexOf(":");
|
|
@@ -3094,8 +3097,13 @@ var require_websocket = __commonJS({
|
|
|
3094
3097
|
function receiverOnConclude(code, reason) {
|
|
3095
3098
|
const websocket = this[kWebSocket];
|
|
3096
3099
|
websocket._closeFrameReceived = true;
|
|
3097
|
-
websocket._closeMessage = reason;
|
|
3098
3100
|
websocket._closeCode = code;
|
|
3101
|
+
if (reason.length === 0) {
|
|
3102
|
+
websocket._closeMessage = EMPTY_BUFFER;
|
|
3103
|
+
} else {
|
|
3104
|
+
websocket._closeMessage = Buffer.allocUnsafeSlow(reason.length);
|
|
3105
|
+
websocket._closeMessage.set(reason);
|
|
3106
|
+
}
|
|
3099
3107
|
if (websocket._socket[kWebSocket] === void 0) return;
|
|
3100
3108
|
websocket._socket.removeListener("data", socketOnData);
|
|
3101
3109
|
process.nextTick(resume, websocket._socket);
|
|
@@ -3197,9 +3205,9 @@ var require_websocket = __commonJS({
|
|
|
3197
3205
|
}
|
|
3198
3206
|
});
|
|
3199
3207
|
|
|
3200
|
-
// ../../node_modules/.pnpm/ws@8.22.
|
|
3208
|
+
// ../../node_modules/.pnpm/ws@8.22.2/node_modules/ws/lib/stream.js
|
|
3201
3209
|
var require_stream = __commonJS({
|
|
3202
|
-
"../../node_modules/.pnpm/ws@8.22.
|
|
3210
|
+
"../../node_modules/.pnpm/ws@8.22.2/node_modules/ws/lib/stream.js"(exports, module) {
|
|
3203
3211
|
"use strict";
|
|
3204
3212
|
var WebSocket3 = require_websocket();
|
|
3205
3213
|
var { Duplex: Duplex2 } = __require("stream");
|
|
@@ -3295,9 +3303,9 @@ var require_stream = __commonJS({
|
|
|
3295
3303
|
}
|
|
3296
3304
|
});
|
|
3297
3305
|
|
|
3298
|
-
// ../../node_modules/.pnpm/ws@8.22.
|
|
3306
|
+
// ../../node_modules/.pnpm/ws@8.22.2/node_modules/ws/lib/subprotocol.js
|
|
3299
3307
|
var require_subprotocol = __commonJS({
|
|
3300
|
-
"../../node_modules/.pnpm/ws@8.22.
|
|
3308
|
+
"../../node_modules/.pnpm/ws@8.22.2/node_modules/ws/lib/subprotocol.js"(exports, module) {
|
|
3301
3309
|
"use strict";
|
|
3302
3310
|
var { tokenChars } = require_validation();
|
|
3303
3311
|
function parse9(header) {
|
|
@@ -3340,9 +3348,9 @@ var require_subprotocol = __commonJS({
|
|
|
3340
3348
|
}
|
|
3341
3349
|
});
|
|
3342
3350
|
|
|
3343
|
-
// ../../node_modules/.pnpm/ws@8.22.
|
|
3351
|
+
// ../../node_modules/.pnpm/ws@8.22.2/node_modules/ws/lib/websocket-server.js
|
|
3344
3352
|
var require_websocket_server = __commonJS({
|
|
3345
|
-
"../../node_modules/.pnpm/ws@8.22.
|
|
3353
|
+
"../../node_modules/.pnpm/ws@8.22.2/node_modules/ws/lib/websocket-server.js"(exports, module) {
|
|
3346
3354
|
"use strict";
|
|
3347
3355
|
var EventEmitter = __require("events");
|
|
3348
3356
|
var http2 = __require("http");
|
|
@@ -3844,6 +3852,19 @@ __export(Context_exports, {
|
|
|
3844
3852
|
pick: () => pick
|
|
3845
3853
|
});
|
|
3846
3854
|
|
|
3855
|
+
// ../../node_modules/.pnpm/effect@4.1.2/node_modules/effect/dist/Equal.js
|
|
3856
|
+
var Equal_exports = {};
|
|
3857
|
+
__export(Equal_exports, {
|
|
3858
|
+
asEquivalence: () => asEquivalence,
|
|
3859
|
+
byReference: () => byReference,
|
|
3860
|
+
byReferenceUnsafe: () => byReferenceUnsafe,
|
|
3861
|
+
equals: () => equals,
|
|
3862
|
+
isEqual: () => isEqual,
|
|
3863
|
+
makeCompareMap: () => makeCompareMap,
|
|
3864
|
+
makeCompareSet: () => makeCompareSet,
|
|
3865
|
+
symbol: () => symbol2
|
|
3866
|
+
});
|
|
3867
|
+
|
|
3847
3868
|
// ../../node_modules/.pnpm/effect@4.1.2/node_modules/effect/dist/Pipeable.js
|
|
3848
3869
|
var pipeArguments = (self, args2) => {
|
|
3849
3870
|
switch (args2.length) {
|
|
@@ -4400,6 +4421,7 @@ function makeCompareSet(equivalence) {
|
|
|
4400
4421
|
}
|
|
4401
4422
|
var isEqual = (u) => hasProperty(u, symbol2) && typeof u[symbol2] === "function";
|
|
4402
4423
|
var asEquivalence = () => equals;
|
|
4424
|
+
var byReference = (obj) => byReferenceUnsafe(new Proxy(obj, {}));
|
|
4403
4425
|
var byReferenceUnsafe = (obj) => {
|
|
4404
4426
|
byReferenceInstances.add(obj);
|
|
4405
4427
|
return obj;
|
|
@@ -11698,11 +11720,40 @@ var doneUnsafe = (self, effect2) => {
|
|
|
11698
11720
|
var into = /* @__PURE__ */ dual(2, (self, deferred) => uninterruptibleMask((restore) => flatMap4(exit(restore(self)), (exit3) => done3(deferred, exit3))));
|
|
11699
11721
|
|
|
11700
11722
|
// ../../node_modules/.pnpm/effect@4.1.2/node_modules/effect/dist/References.js
|
|
11723
|
+
var References_exports = {};
|
|
11724
|
+
__export(References_exports, {
|
|
11725
|
+
CurrentLogAnnotations: () => CurrentLogAnnotations2,
|
|
11726
|
+
CurrentLogLevel: () => CurrentLogLevel2,
|
|
11727
|
+
CurrentLogSpans: () => CurrentLogSpans2,
|
|
11728
|
+
CurrentLoggers: () => CurrentLoggers2,
|
|
11729
|
+
CurrentStackFrame: () => CurrentStackFrame2,
|
|
11730
|
+
CurrentTraceLevel: () => CurrentTraceLevel,
|
|
11731
|
+
DisablePropagation: () => DisablePropagation,
|
|
11732
|
+
LogToStderr: () => LogToStderr2,
|
|
11733
|
+
MaxOpsBeforeYield: () => MaxOpsBeforeYield,
|
|
11734
|
+
MinimumLogLevel: () => MinimumLogLevel2,
|
|
11735
|
+
MinimumTraceLevel: () => MinimumTraceLevel,
|
|
11736
|
+
PreventSchedulerYield: () => PreventSchedulerYield,
|
|
11737
|
+
Scheduler: () => Scheduler,
|
|
11738
|
+
Tracer: () => Tracer,
|
|
11739
|
+
TracerEnabled: () => TracerEnabled2,
|
|
11740
|
+
TracerSpanAnnotations: () => TracerSpanAnnotations2,
|
|
11741
|
+
TracerSpanLinks: () => TracerSpanLinks2,
|
|
11742
|
+
TracerTimingEnabled: () => TracerTimingEnabled2,
|
|
11743
|
+
UnhandledLogLevel: () => UnhandledLogLevel2
|
|
11744
|
+
});
|
|
11701
11745
|
var CurrentLogAnnotations2 = CurrentLogAnnotations;
|
|
11746
|
+
var CurrentLogLevel2 = CurrentLogLevel;
|
|
11702
11747
|
var CurrentLogSpans2 = CurrentLogSpans;
|
|
11703
11748
|
var CurrentStackFrame2 = CurrentStackFrame;
|
|
11704
11749
|
var MinimumLogLevel2 = MinimumLogLevel;
|
|
11750
|
+
var TracerEnabled2 = TracerEnabled;
|
|
11751
|
+
var TracerSpanAnnotations2 = TracerSpanAnnotations;
|
|
11752
|
+
var TracerSpanLinks2 = TracerSpanLinks;
|
|
11705
11753
|
var TracerTimingEnabled2 = TracerTimingEnabled;
|
|
11754
|
+
var UnhandledLogLevel2 = UnhandledLogLevel;
|
|
11755
|
+
var CurrentLoggers2 = CurrentLoggers;
|
|
11756
|
+
var LogToStderr2 = LogToStderr;
|
|
11706
11757
|
|
|
11707
11758
|
// ../../node_modules/.pnpm/effect@4.1.2/node_modules/effect/dist/Scope.js
|
|
11708
11759
|
var Scope_exports = {};
|
|
@@ -23176,8 +23227,8 @@ var decodeJsonError = (input) => {
|
|
|
23176
23227
|
};
|
|
23177
23228
|
var encodeUnknownAsJson = (input) => {
|
|
23178
23229
|
try {
|
|
23179
|
-
const
|
|
23180
|
-
return
|
|
23230
|
+
const json4 = formatJson(input);
|
|
23231
|
+
return json4 === void 0 ? format(input) : JSON.parse(json4);
|
|
23181
23232
|
} catch {
|
|
23182
23233
|
return format(input);
|
|
23183
23234
|
}
|
|
@@ -25589,14 +25640,14 @@ var template = (strings, ...expressions) => {
|
|
|
25589
25640
|
var unwrap5 = (item) => isRedacted(item) ? value3(item) : String(item);
|
|
25590
25641
|
var toWord = (item) => isRedacted(item) ? item : String(item);
|
|
25591
25642
|
var reservedWords = /* @__PURE__ */ new Set(["!", "{", "}", "and", "begin", "case", "coproc", "do", "done", "elif", "else", "end", "esac", "fi", "for", "foreach", "function", "if", "in", "nocorrect", "not", "or", "repeat", "select", "switch", "then", "time", "until", "while"]);
|
|
25592
|
-
var quoteWord = (format11, value4,
|
|
25643
|
+
var quoteWord = (format11, value4, program) => {
|
|
25593
25644
|
switch (format11) {
|
|
25594
25645
|
case "posix":
|
|
25595
|
-
return
|
|
25646
|
+
return program && reservedWords.has(value4) ? `'${value4}'` : quotePosix(value4);
|
|
25596
25647
|
case "powershell":
|
|
25597
25648
|
return quotePowerShell(value4);
|
|
25598
25649
|
case "windows":
|
|
25599
|
-
return
|
|
25650
|
+
return program && !value4.includes('"') ? quoteWindowsProgram(value4) : quoteWindowsArgument(value4);
|
|
25600
25651
|
}
|
|
25601
25652
|
};
|
|
25602
25653
|
var joinWords = (format11, quoted) => format11 === "powershell" ? `& ${quoted.join(" ")}` : quoted.join(" ");
|
|
@@ -25787,14 +25838,14 @@ var parseFdName = (name) => {
|
|
|
25787
25838
|
};
|
|
25788
25839
|
var fdName = (fd) => `fd${fd}`;
|
|
25789
25840
|
var parseTemplate2 = (templates, expressions) => {
|
|
25790
|
-
const [
|
|
25791
|
-
if (typeof
|
|
25841
|
+
const [program = "", ...args2] = getOrThrow2(template(templates, ...expressions));
|
|
25842
|
+
if (typeof program !== "string") {
|
|
25792
25843
|
throw new CommandLineError({
|
|
25793
25844
|
reason: "InvalidArgument",
|
|
25794
25845
|
message: "The program name of a command cannot be Redacted"
|
|
25795
25846
|
});
|
|
25796
25847
|
}
|
|
25797
|
-
return [
|
|
25848
|
+
return [program, args2];
|
|
25798
25849
|
};
|
|
25799
25850
|
var shellScript = (templates, expressions) => {
|
|
25800
25851
|
if (expressions.length > 0) {
|
|
@@ -39150,8 +39201,8 @@ var dnsSeconds = /* @__PURE__ */ dnsUint32.pipe(/* @__PURE__ */ decodeTo2(Durati
|
|
|
39150
39201
|
var dnsRecordOfType = (type, fields) => declare((u) => isDnsRecord(u) && u._tag === type, {
|
|
39151
39202
|
identifier: `Dns${type.charAt(0)}${type.slice(1).toLowerCase()}Record`,
|
|
39152
39203
|
toCodecJson: () => {
|
|
39153
|
-
const
|
|
39154
|
-
return link3()(
|
|
39204
|
+
const json4 = TaggedStruct(type, fields);
|
|
39205
|
+
return link3()(json4, transformEffect2({
|
|
39155
39206
|
decode: (input, options3) => {
|
|
39156
39207
|
const {
|
|
39157
39208
|
_tag,
|
|
@@ -41502,8 +41553,8 @@ var awaitEmpty = (self) => whileLoop2({
|
|
|
41502
41553
|
// ../../node_modules/.pnpm/effect@4.1.2/node_modules/effect/dist/Logger.js
|
|
41503
41554
|
var Logger_exports = {};
|
|
41504
41555
|
__export(Logger_exports, {
|
|
41505
|
-
CurrentLoggers: () =>
|
|
41506
|
-
LogToStderr: () =>
|
|
41556
|
+
CurrentLoggers: () => CurrentLoggers3,
|
|
41557
|
+
LogToStderr: () => LogToStderr3,
|
|
41507
41558
|
batched: () => batched,
|
|
41508
41559
|
consoleJson: () => consoleJson,
|
|
41509
41560
|
consoleLogFmt: () => consoleLogFmt,
|
|
@@ -41528,8 +41579,8 @@ __export(Logger_exports, {
|
|
|
41528
41579
|
});
|
|
41529
41580
|
var TypeId56 = "~effect/Logger";
|
|
41530
41581
|
var isLogger = (u) => hasProperty(u, TypeId56);
|
|
41531
|
-
var
|
|
41532
|
-
var
|
|
41582
|
+
var CurrentLoggers3 = CurrentLoggers;
|
|
41583
|
+
var LogToStderr3 = LogToStderr;
|
|
41533
41584
|
var map15 = /* @__PURE__ */ dual(2, (self, f) => loggerMake((options3) => f(self.log(options3))));
|
|
41534
41585
|
var withConsoleLog = (self) => loggerMake((options3) => {
|
|
41535
41586
|
const console2 = options3.fiber.getRef(ConsoleRef);
|
|
@@ -41653,7 +41704,7 @@ var consoleLogFmt = /* @__PURE__ */ withConsoleLog(formatLogFmt);
|
|
|
41653
41704
|
var consoleStructured = /* @__PURE__ */ withConsoleLog(formatStructured);
|
|
41654
41705
|
var consoleJson = /* @__PURE__ */ withConsoleLog(formatJson2);
|
|
41655
41706
|
var tracerLogger2 = tracerLogger;
|
|
41656
|
-
var layer13 = (loggers, options3) => effect(
|
|
41707
|
+
var layer13 = (loggers, options3) => effect(CurrentLoggers3, withFiber(fnUntraced(function* (fiber3) {
|
|
41657
41708
|
const currentLoggers = new Set(options3?.mergeWithExisting === true ? fiber3.getRef(CurrentLoggers) : []);
|
|
41658
41709
|
for (const logger2 of loggers) {
|
|
41659
41710
|
currentLoggers.add(isEffect(logger2) ? yield* logger2 : logger2);
|
|
@@ -49802,17 +49853,17 @@ var resolveFormatter = /* @__PURE__ */ contextWith2((context3) => succeed7(getOr
|
|
|
49802
49853
|
})));
|
|
49803
49854
|
|
|
49804
49855
|
// ../../node_modules/.pnpm/effect@4.1.2/node_modules/effect/dist/cli/internal/lexer.js
|
|
49805
|
-
function lex(
|
|
49806
|
-
const endIndex =
|
|
49856
|
+
function lex(argv2) {
|
|
49857
|
+
const endIndex = argv2.indexOf("--");
|
|
49807
49858
|
if (endIndex === -1) {
|
|
49808
49859
|
return {
|
|
49809
|
-
tokens: lexTokens(
|
|
49860
|
+
tokens: lexTokens(argv2),
|
|
49810
49861
|
trailingOperands: []
|
|
49811
49862
|
};
|
|
49812
49863
|
}
|
|
49813
49864
|
return {
|
|
49814
|
-
tokens: lexTokens(
|
|
49815
|
-
trailingOperands:
|
|
49865
|
+
tokens: lexTokens(argv2.slice(0, endIndex)),
|
|
49866
|
+
trailingOperands: argv2.slice(endIndex + 1)
|
|
49816
49867
|
};
|
|
49817
49868
|
}
|
|
49818
49869
|
var negativeNumberRegex = /^-(?:\d+\.?\d*|\.\d+)(?:[eE][+-]?\d+)?$/;
|
|
@@ -51027,19 +51078,19 @@ var runWith2 = (command, config) => {
|
|
|
51027
51078
|
});
|
|
51028
51079
|
}
|
|
51029
51080
|
const input = yield* commandImpl.parse(parsedArgs).pipe(toShowHelp);
|
|
51030
|
-
let
|
|
51081
|
+
let program = commandImpl.handle(input, [command.name]);
|
|
51031
51082
|
const logLevel = activeFlags.includes(LogLevel2) ? (yield* LogLevel2.flag.parse(emptyArgs).pipe(toShowHelp))[1] : none2();
|
|
51032
|
-
|
|
51083
|
+
program = provideService2(program, LogLevel2, logLevel);
|
|
51033
51084
|
for (const flag of activeFlags) {
|
|
51034
51085
|
if (flag._tag !== "Setting" || flag === LogLevel2) continue;
|
|
51035
51086
|
const [, value4] = yield* flag.flag.parse(emptyArgs).pipe(toShowHelp);
|
|
51036
|
-
|
|
51087
|
+
program = provideService2(program, flag, value4);
|
|
51037
51088
|
}
|
|
51038
51089
|
const services = match(logLevel, {
|
|
51039
51090
|
onNone: () => empty(),
|
|
51040
51091
|
onSome: (level) => make5(MinimumLogLevel2, level)
|
|
51041
51092
|
});
|
|
51042
|
-
yield* provideContext2(
|
|
51093
|
+
yield* provideContext2(program, services);
|
|
51043
51094
|
}, catchFilter2((error2) => isCliError(error2) && error2._tag === "ShowHelp" ? succeed2(error2) : fail2(error2), (error2) => andThen4(showHelp(command, error2, config.renderErrors !== false), fail7(error2))), catchFilter2((error2) => {
|
|
51044
51095
|
if (config.renderErrors === false || !isObjectKeyword(error2)) return fail2(error2);
|
|
51045
51096
|
const userMessage2 = getUserMessage(error2);
|
|
@@ -51160,7 +51211,7 @@ var closeWindow = (window2, atMono, toMs, intervalMs, unit) => {
|
|
|
51160
51211
|
var Slug = Schema_exports.String.pipe(
|
|
51161
51212
|
Schema_exports.check(
|
|
51162
51213
|
Schema_exports.isPattern(/^[a-z0-9][a-z0-9_-]*$/, {
|
|
51163
|
-
message: "Expected a slug: lowercase letters, digits, - and _, starting with a letter or digit (
|
|
51214
|
+
message: "Expected a slug: lowercase letters, digits, - and _, starting with a letter or digit (site-1, not Site 1)"
|
|
51164
51215
|
}),
|
|
51165
51216
|
Schema_exports.isMaxLength(64)
|
|
51166
51217
|
)
|
|
@@ -51342,6 +51393,22 @@ var makeMemoryPublisher = Effect_exports.sync(() => {
|
|
|
51342
51393
|
});
|
|
51343
51394
|
|
|
51344
51395
|
// ../../packages/core/src/Telemetry.ts
|
|
51396
|
+
function makeValueCounters() {
|
|
51397
|
+
return {
|
|
51398
|
+
published: Metric_exports.counter("ot_gateway_values_published", {
|
|
51399
|
+
description: "Point values published",
|
|
51400
|
+
incremental: true
|
|
51401
|
+
}),
|
|
51402
|
+
suppressed: Metric_exports.counter("ot_gateway_values_suppressed", {
|
|
51403
|
+
description: "Point values held back in change mode",
|
|
51404
|
+
incremental: true
|
|
51405
|
+
}),
|
|
51406
|
+
pushed: Metric_exports.counter("ot_gateway_pushed_readings", {
|
|
51407
|
+
description: "Values pushed by devices between polls",
|
|
51408
|
+
incremental: true
|
|
51409
|
+
})
|
|
51410
|
+
};
|
|
51411
|
+
}
|
|
51345
51412
|
var seconds2 = { unit: "seconds" };
|
|
51346
51413
|
var pollCycles = Metric_exports.counter("ot_gateway_poll_cycles", {
|
|
51347
51414
|
description: "Polling cycles finished, by outcome",
|
|
@@ -51362,14 +51429,8 @@ var publishFailures = Metric_exports.counter("ot_gateway_publish_failures", {
|
|
|
51362
51429
|
description: "Messages that failed to publish",
|
|
51363
51430
|
incremental: true
|
|
51364
51431
|
});
|
|
51365
|
-
var valuesPublished =
|
|
51366
|
-
|
|
51367
|
-
incremental: true
|
|
51368
|
-
});
|
|
51369
|
-
var valuesSuppressed = Metric_exports.counter("ot_gateway_values_suppressed", {
|
|
51370
|
-
description: "Point values held back in change mode",
|
|
51371
|
-
incremental: true
|
|
51372
|
-
});
|
|
51432
|
+
var valuesPublished = makeValueCounters().published;
|
|
51433
|
+
var valuesSuppressed = makeValueCounters().suppressed;
|
|
51373
51434
|
var deviceLastSuccess = Metric_exports.gauge("ot_gateway_device_last_success_timestamp_seconds", {
|
|
51374
51435
|
description: "Unix time of the last successful polling cycle of a device",
|
|
51375
51436
|
attributes: seconds2
|
|
@@ -51382,10 +51443,7 @@ var deviceRestarts = Metric_exports.counter("ot_gateway_device_restarts", {
|
|
|
51382
51443
|
description: "Device pipelines restarted after a defect",
|
|
51383
51444
|
incremental: true
|
|
51384
51445
|
});
|
|
51385
|
-
var pushedReadings =
|
|
51386
|
-
description: "Values pushed by devices between polls",
|
|
51387
|
-
incremental: true
|
|
51388
|
-
});
|
|
51446
|
+
var pushedReadings = makeValueCounters().pushed;
|
|
51389
51447
|
var pushedPoints = Metric_exports.gauge("ot_gateway_pushed_points", {
|
|
51390
51448
|
description: "Points kept up to date by device pushes instead of polling",
|
|
51391
51449
|
attributes: { unit: "{point}" }
|
|
@@ -52959,6 +53017,7 @@ var isRetryable = (driver, error2) => {
|
|
|
52959
53017
|
var countCycle = (outcome) => Metric_exports.update(Metric_exports.withAttributes(pollCycles, { outcome }), 1);
|
|
52960
53018
|
var runDevice = Effect_exports.fn("runDevice")(function* (ctx, driver) {
|
|
52961
53019
|
const publisher = yield* Publisher;
|
|
53020
|
+
const counters = makeValueCounters();
|
|
52962
53021
|
const points2 = new Map(driver.points.map((p) => [p.id, p]));
|
|
52963
53022
|
const policies = new Map(driver.points.map((p) => [p.id, publishOf(ctx.publish, p)]));
|
|
52964
53023
|
const policyOf = (pointId) => policies.get(pointId) ?? everyRead;
|
|
@@ -53075,7 +53134,7 @@ var runDevice = Effect_exports.fn("runDevice")(function* (ctx, driver) {
|
|
|
53075
53134
|
const sentAt = lastSentAt.get(point.id);
|
|
53076
53135
|
const quietTooLong = policy2.maxSilenceMs !== void 0 && sentAt !== void 0 && atMono - sentAt >= policy2.maxSilenceMs;
|
|
53077
53136
|
if (!quietTooLong && !exceedsDeadband(Option_exports.fromUndefinedOr(last2.get(point.id)), value4, policy2.deadband)) {
|
|
53078
|
-
return yield* Metric_exports.update(
|
|
53137
|
+
return yield* Metric_exports.update(counters.suppressed, 1);
|
|
53079
53138
|
}
|
|
53080
53139
|
if (!(yield* send(point.id, message))) return;
|
|
53081
53140
|
last2.set(point.id, value4);
|
|
@@ -53084,12 +53143,14 @@ var runDevice = Effect_exports.fn("runDevice")(function* (ctx, driver) {
|
|
|
53084
53143
|
}
|
|
53085
53144
|
}
|
|
53086
53145
|
});
|
|
53146
|
+
let unavailable2;
|
|
53087
53147
|
const send = Effect_exports.fnUntraced(function* (pointId, message) {
|
|
53148
|
+
if (unavailable2 !== void 0) return false;
|
|
53088
53149
|
const sent = yield* publishPoint(pointTopic(topicFor(pointId)), JSON.stringify(message)).pipe(
|
|
53089
53150
|
Effect_exports.as(true),
|
|
53090
53151
|
Effect_exports.catchTag("PublishError", (error2) => Effect_exports.as(skipRefused(error2), false))
|
|
53091
53152
|
);
|
|
53092
|
-
if (sent) yield* Metric_exports.update(
|
|
53153
|
+
if (sent) yield* Metric_exports.update(counters.published, 1);
|
|
53093
53154
|
return sent;
|
|
53094
53155
|
});
|
|
53095
53156
|
const closeWindows = Effect_exports.fnUntraced(function* (intervalMs, endMs) {
|
|
@@ -53141,10 +53202,26 @@ var runDevice = Effect_exports.fn("runDevice")(function* (ctx, driver) {
|
|
|
53141
53202
|
const readAt = yield* Clock_exports.currentTimeMillis;
|
|
53142
53203
|
yield* Metric_exports.update(deviceLastSuccess, readAt / 1e3);
|
|
53143
53204
|
yield* Effect_exports.annotateCurrentSpan("ot_gateway.readings", readings.length);
|
|
53144
|
-
const
|
|
53205
|
+
const failedPublish = yield* handling.withPermit(
|
|
53206
|
+
Effect_exports.gen(function* () {
|
|
53207
|
+
unavailable2 = void 0;
|
|
53208
|
+
for (const reading of readings) {
|
|
53209
|
+
const handled = yield* Effect_exports.result(handleReading(reading, polledSince));
|
|
53210
|
+
if (Result_exports.isFailure(handled)) unavailable2 ??= handled.failure;
|
|
53211
|
+
}
|
|
53212
|
+
return unavailable2;
|
|
53213
|
+
}).pipe(
|
|
53214
|
+
// Also when the cycle's deadline interrupts it: pushed values and closing windows must not skip publishing.
|
|
53215
|
+
Effect_exports.ensuring(
|
|
53216
|
+
Effect_exports.sync(() => {
|
|
53217
|
+
unavailable2 = void 0;
|
|
53218
|
+
})
|
|
53219
|
+
)
|
|
53220
|
+
)
|
|
53221
|
+
);
|
|
53145
53222
|
ctx.health?.recordSuccess(driver.deviceId, readAt);
|
|
53146
53223
|
yield* deviceRecovered;
|
|
53147
|
-
if (
|
|
53224
|
+
if (failedPublish !== void 0) return yield* failedPublish;
|
|
53148
53225
|
yield* countCycle("ok");
|
|
53149
53226
|
}).pipe(
|
|
53150
53227
|
deadline("poll-cycle"),
|
|
@@ -53196,7 +53273,7 @@ var runDevice = Effect_exports.fn("runDevice")(function* (ctx, driver) {
|
|
|
53196
53273
|
const pushLost = (message, annotations2) => Effect_exports.all([publishFailed("values", message, annotations2), Metric_exports.update(publishFailures, 1)]);
|
|
53197
53274
|
const pushed = driver.changes === void 0 ? Effect_exports.void : Stream_exports.runForEach(
|
|
53198
53275
|
driver.changes,
|
|
53199
|
-
(reading) => Metric_exports.update(
|
|
53276
|
+
(reading) => Metric_exports.update(counters.pushed, 1).pipe(
|
|
53200
53277
|
// Under the deadline, so a hung publish cannot keep the permit from the polling cycle forever.
|
|
53201
53278
|
Effect_exports.andThen(handling.withPermit(handleReading(reading)).pipe(deadline("pushed-value"))),
|
|
53202
53279
|
// The value is lost; the next change, renewal notification or poll brings the point's value again.
|
|
@@ -53942,7 +54019,7 @@ var NativeSocket = class {
|
|
|
53942
54019
|
// ../../node_modules/.pnpm/@effect+platform-node-shared@4.1.2_effect@4.1.2/node_modules/@effect/platform-node-shared/dist/NodeSocketServer.js
|
|
53943
54020
|
import * as Net3 from "node:net";
|
|
53944
54021
|
|
|
53945
|
-
// ../../node_modules/.pnpm/ws@8.22.
|
|
54022
|
+
// ../../node_modules/.pnpm/ws@8.22.2/node_modules/ws/wrapper.mjs
|
|
53946
54023
|
var import_stream3 = __toESM(require_stream(), 1);
|
|
53947
54024
|
var import_extension = __toESM(require_extension(), 1);
|
|
53948
54025
|
var import_permessage_deflate = __toESM(require_permessage_deflate(), 1);
|
|
@@ -55828,7 +55905,14 @@ var logDefect = (message) => (defect) => Effect_exports.logError(message).pipe(E
|
|
|
55828
55905
|
var BACKLOG = 1024;
|
|
55829
55906
|
var COV_CONCURRENCY = 4;
|
|
55830
55907
|
var COV_SILENT_IN_A_ROW = 2 * COV_CONCURRENCY;
|
|
55831
|
-
var
|
|
55908
|
+
var sameInet = (left, right) => left.port === right.port && (left._tag === "InetAddressV4" ? right._tag === "InetAddressV4" : right._tag === "InetAddressV6" && left.scopeId === right.scopeId) && left.address[Equal_exports.symbol](right.address);
|
|
55909
|
+
var sameAddress = (left, right) => {
|
|
55910
|
+
if (!sameInet(left.address, right.address)) return false;
|
|
55911
|
+
if (left.network?.network !== right.network?.network) return false;
|
|
55912
|
+
const leftHops = left.network?.address ?? [];
|
|
55913
|
+
const rightHops = right.network?.address ?? [];
|
|
55914
|
+
return leftHops.length === rightHops.length && leftHops.every((byte, index2) => byte === rightHops[index2]);
|
|
55915
|
+
};
|
|
55832
55916
|
var describeObject = (object) => `${nameOf(ObjectType, object.objectType)}:${object.instance}`;
|
|
55833
55917
|
var OTHER_DEVICE = "for another device";
|
|
55834
55918
|
var makeCovSubscriptions = (deps) => {
|
|
@@ -57854,8 +57938,9 @@ var decodeVariableByteInteger = (bytes3, offset = 0) => {
|
|
|
57854
57938
|
}
|
|
57855
57939
|
return new MqttCodecError({ message: "malformed variable byte integer" });
|
|
57856
57940
|
};
|
|
57941
|
+
var utf82 = new TextEncoder();
|
|
57857
57942
|
var encodeUtf8String = (value4) => {
|
|
57858
|
-
const encoded =
|
|
57943
|
+
const encoded = utf82.encode(value4);
|
|
57859
57944
|
if (encoded.length > 65535) throw new RangeError("string too long");
|
|
57860
57945
|
const out = new Uint8Array(2 + encoded.length);
|
|
57861
57946
|
new DataView(out.buffer).setUint16(0, encoded.length);
|
|
@@ -58217,23 +58302,74 @@ var connackReasonName = (code) => ({
|
|
|
58217
58302
|
159: "connection rate exceeded"
|
|
58218
58303
|
})[code] ?? `reason code 0x${code.toString(16)}`;
|
|
58219
58304
|
var encodePublish = (publish2, version2 = 5) => {
|
|
58220
|
-
const
|
|
58221
|
-
|
|
58222
|
-
|
|
58223
|
-
|
|
58224
|
-
|
|
58225
|
-
|
|
58226
|
-
|
|
58227
|
-
|
|
58228
|
-
|
|
58229
|
-
|
|
58230
|
-
|
|
58231
|
-
|
|
58232
|
-
|
|
58233
|
-
|
|
58234
|
-
|
|
58235
|
-
|
|
58236
|
-
|
|
58305
|
+
const topic = utf8String(publish2.topic);
|
|
58306
|
+
const withProperties = version2 === 5;
|
|
58307
|
+
const responseTopic = withProperties && publish2.responseTopic !== void 0 ? utf8String(publish2.responseTopic) : void 0;
|
|
58308
|
+
const expiry = withProperties ? publish2.messageExpirySeconds : void 0;
|
|
58309
|
+
const correlation = withProperties ? publish2.correlationData : void 0;
|
|
58310
|
+
let propertiesLength = 0;
|
|
58311
|
+
if (withProperties) {
|
|
58312
|
+
propertiesLength = 2;
|
|
58313
|
+
if (expiry !== void 0) propertiesLength += 5;
|
|
58314
|
+
if (responseTopic !== void 0) propertiesLength += 3 + responseTopic.length;
|
|
58315
|
+
if (correlation !== void 0) propertiesLength += 3 + correlation.length;
|
|
58316
|
+
}
|
|
58317
|
+
const bodyLength = 2 + topic.length + (publish2.qos > 0 ? 2 : 0) + (withProperties ? variableByteIntegerLength(propertiesLength) + propertiesLength : 0) + publish2.payload.length;
|
|
58318
|
+
const out = new Uint8Array(1 + variableByteIntegerLength(bodyLength) + bodyLength);
|
|
58319
|
+
out[0] = PacketType.PUBLISH << 4 | publish2.qos << 1 | (publish2.retain ? 1 : 0);
|
|
58320
|
+
let offset = writeVariableByteInteger(out, 1, bodyLength);
|
|
58321
|
+
offset = writeU16(out, offset, topic.length);
|
|
58322
|
+
out.set(topic, offset);
|
|
58323
|
+
offset += topic.length;
|
|
58324
|
+
if (publish2.qos > 0) offset = writeU16(out, offset, publish2.packetId ?? 0);
|
|
58325
|
+
if (withProperties) {
|
|
58326
|
+
offset = writeVariableByteInteger(out, offset, propertiesLength);
|
|
58327
|
+
out[offset++] = Property.PayloadFormatIndicator;
|
|
58328
|
+
out[offset++] = 1;
|
|
58329
|
+
if (expiry !== void 0) {
|
|
58330
|
+
out[offset++] = Property.MessageExpiryInterval;
|
|
58331
|
+
new DataView(out.buffer).setUint32(offset, expiry >>> 0);
|
|
58332
|
+
offset += 4;
|
|
58333
|
+
}
|
|
58334
|
+
if (responseTopic !== void 0) {
|
|
58335
|
+
out[offset++] = Property.ResponseTopic;
|
|
58336
|
+
offset = writeU16(out, offset, responseTopic.length);
|
|
58337
|
+
out.set(responseTopic, offset);
|
|
58338
|
+
offset += responseTopic.length;
|
|
58339
|
+
}
|
|
58340
|
+
if (correlation !== void 0) {
|
|
58341
|
+
out[offset++] = Property.CorrelationData;
|
|
58342
|
+
offset = writeU16(out, offset, correlation.length);
|
|
58343
|
+
out.set(correlation, offset);
|
|
58344
|
+
offset += correlation.length;
|
|
58345
|
+
}
|
|
58346
|
+
}
|
|
58347
|
+
out.set(publish2.payload, offset);
|
|
58348
|
+
return out;
|
|
58349
|
+
};
|
|
58350
|
+
var utf8String = (value4) => {
|
|
58351
|
+
const bytes3 = encoder9.encode(value4);
|
|
58352
|
+
if (bytes3.length > 65535) throw new RangeError("string too long");
|
|
58353
|
+
return bytes3;
|
|
58354
|
+
};
|
|
58355
|
+
var variableByteIntegerLength = (value4) => {
|
|
58356
|
+
if (value4 > MAX_VARIABLE_BYTE_INTEGER) throw new RangeError(`value out of range: ${value4}`);
|
|
58357
|
+
return value4 < 128 ? 1 : value4 < 16384 ? 2 : value4 < 2097152 ? 3 : 4;
|
|
58358
|
+
};
|
|
58359
|
+
var writeVariableByteInteger = (out, offset, value4) => {
|
|
58360
|
+
let rest = value4;
|
|
58361
|
+
do {
|
|
58362
|
+
let byte = rest % 128;
|
|
58363
|
+
rest = Math.floor(rest / 128);
|
|
58364
|
+
if (rest > 0) byte |= 128;
|
|
58365
|
+
out[offset++] = byte;
|
|
58366
|
+
} while (rest > 0);
|
|
58367
|
+
return offset;
|
|
58368
|
+
};
|
|
58369
|
+
var writeU16 = (out, offset, value4) => {
|
|
58370
|
+
out[offset] = value4 >> 8 & 255;
|
|
58371
|
+
out[offset + 1] = value4 & 255;
|
|
58372
|
+
return offset + 2;
|
|
58237
58373
|
};
|
|
58238
58374
|
var decodePublish = (flags, body, version2 = 5) => decodeWith2(body, (r) => {
|
|
58239
58375
|
const qos = flags >> 1 & 3;
|
|
@@ -58360,7 +58496,7 @@ var countConnect3 = (outcome) => Metric_exports.update(Metric_exports.withAttrib
|
|
|
58360
58496
|
var topicProblem = (topic) => {
|
|
58361
58497
|
if (topic.length === 0) return "topic is empty";
|
|
58362
58498
|
if (topic.includes("+") || topic.includes("#")) return "topic contains a wildcard";
|
|
58363
|
-
if (encoder10.encode(topic).length > 65535) return "topic is longer than 65,535 bytes";
|
|
58499
|
+
if (topic.length > 65535 / 3 && encoder10.encode(topic).length > 65535) return "topic is longer than 65,535 bytes";
|
|
58364
58500
|
return void 0;
|
|
58365
58501
|
};
|
|
58366
58502
|
var makeMqttClient = Effect_exports.fn("makeMqttClient")(function* (socket, options3) {
|
|
@@ -58844,7 +58980,7 @@ var MqttPublisher = (settings, options3 = {}) => Layer_exports.effect(
|
|
|
58844
58980
|
}
|
|
58845
58981
|
const openTimeout2 = options3.connectTimeout ?? "10 seconds";
|
|
58846
58982
|
const socket = options3.network ? yield* options3.network.tcp({ host: address.host, port: address.port, openTimeout: openTimeout2 }) : address.tls ? yield* makeTls({ host: address.host, port: address.port, servername: address.host, openTimeout: openTimeout2 }) : yield* makeNet({ host: address.host, port: address.port, openTimeout: openTimeout2 });
|
|
58847
|
-
const { health, network: _network, ...clientOptions } = options3;
|
|
58983
|
+
const { health, network: _network, onConnected, ...clientOptions } = options3;
|
|
58848
58984
|
const retained = /* @__PURE__ */ new Map();
|
|
58849
58985
|
let connection = 0;
|
|
58850
58986
|
const publishRetained = Effect_exports.fnUntraced(function* (client2, topic, payload) {
|
|
@@ -58853,6 +58989,8 @@ var MqttPublisher = (settings, options3 = {}) => Layer_exports.effect(
|
|
|
58853
58989
|
});
|
|
58854
58990
|
const onConnect = Effect_exports.fnUntraced(function* (client2) {
|
|
58855
58991
|
connection++;
|
|
58992
|
+
const info2 = yield* client2.connection;
|
|
58993
|
+
if (info2 !== void 0 && onConnected !== void 0) yield* onConnected(info2);
|
|
58856
58994
|
if (health !== void 0) {
|
|
58857
58995
|
yield* publishRetained(client2, health.topic, yield* health.online).pipe(
|
|
58858
58996
|
Effect_exports.catchTag(
|
|
@@ -59116,8 +59254,8 @@ var paceOf = (speed) => ({
|
|
|
59116
59254
|
update: Schedule_exports.spaced(Math.max(50, Math.round(1e3 / speed)))
|
|
59117
59255
|
});
|
|
59118
59256
|
var rangeByUnit = {
|
|
59119
|
-
"unit:DEG_C": [
|
|
59120
|
-
"unit:DEG_F": [
|
|
59257
|
+
"unit:DEG_C": [25, 40],
|
|
59258
|
+
"unit:DEG_F": [77, 104],
|
|
59121
59259
|
"unit:PERCENT_RelativeHumidity": [30, 60],
|
|
59122
59260
|
"unit:PPM": [400, 1200],
|
|
59123
59261
|
"unit:PA": [100, 400]
|
|
@@ -59330,6 +59468,48 @@ var csvField = (value4) => {
|
|
|
59330
59468
|
var toCsv = (rows) => `${rows.map((fields) => fields.map(csvField).join(",")).join("\n")}
|
|
59331
59469
|
`;
|
|
59332
59470
|
|
|
59471
|
+
// src/Output.ts
|
|
59472
|
+
var isJsonMode = (argv2) => argv2.includes("--json");
|
|
59473
|
+
var ResultConsole = Context_exports.Reference("@ot-gateway/gateway/ResultConsole", {
|
|
59474
|
+
defaultValue: () => void 0
|
|
59475
|
+
});
|
|
59476
|
+
var printResult = (text4) => Effect_exports.flatMap(
|
|
59477
|
+
ResultConsole,
|
|
59478
|
+
(results2) => results2 === void 0 ? Console_exports.log(text4) : Effect_exports.sync(() => {
|
|
59479
|
+
results2.log(text4);
|
|
59480
|
+
})
|
|
59481
|
+
);
|
|
59482
|
+
var printJson = (value4) => printResult(JSON.stringify(value4, null, 2));
|
|
59483
|
+
var stderrConsole = (base) => ({
|
|
59484
|
+
assert: (condition, ...args2) => base.assert(condition, ...args2),
|
|
59485
|
+
clear: () => base.clear(),
|
|
59486
|
+
count: (label2) => base.count(label2),
|
|
59487
|
+
countReset: (label2) => base.countReset(label2),
|
|
59488
|
+
debug: (...args2) => base.debug(...args2),
|
|
59489
|
+
dir: (...args2) => base.error(...args2),
|
|
59490
|
+
dirxml: (...args2) => base.error(...args2),
|
|
59491
|
+
error: (...args2) => base.error(...args2),
|
|
59492
|
+
group: (...args2) => base.group(...args2),
|
|
59493
|
+
groupCollapsed: (...args2) => base.groupCollapsed(...args2),
|
|
59494
|
+
groupEnd: () => base.groupEnd(),
|
|
59495
|
+
info: (...args2) => base.error(...args2),
|
|
59496
|
+
log: (...args2) => base.error(...args2),
|
|
59497
|
+
table: (data) => base.error(data),
|
|
59498
|
+
time: (label2) => base.time(label2),
|
|
59499
|
+
timeEnd: (label2) => base.timeEnd(label2),
|
|
59500
|
+
timeLog: (label2, ...args2) => base.timeLog(label2, ...args2),
|
|
59501
|
+
trace: (...args2) => base.trace(...args2),
|
|
59502
|
+
warn: (...args2) => base.warn(...args2)
|
|
59503
|
+
});
|
|
59504
|
+
var isUsageError = (error2) => error2._tag === "ShowHelp" && error2.errors.length > 0;
|
|
59505
|
+
var USAGE_EXIT_CODE = 2;
|
|
59506
|
+
var usageFailure = (error2) => ({
|
|
59507
|
+
ok: false,
|
|
59508
|
+
code: "usage",
|
|
59509
|
+
error: error2.errors.map((each) => each.message).join("; "),
|
|
59510
|
+
hint: `ot-gateway ${[...error2.commandPath.slice(1), "--help"].join(" ")} lists the commands and flags`
|
|
59511
|
+
});
|
|
59512
|
+
|
|
59333
59513
|
// src/Discover.ts
|
|
59334
59514
|
var LISTEN = "3 seconds";
|
|
59335
59515
|
var TRUSTED_SOURCE = "a source you trust (commissioning sheet, device display, DHCP reservation)";
|
|
@@ -59468,10 +59648,7 @@ var discoverDrafts = (config, network, options3 = {}) => Effect_exports.gen(func
|
|
|
59468
59648
|
const existing = config.devices.map((device) => device.id);
|
|
59469
59649
|
return draftDevices(described.flat(), existing);
|
|
59470
59650
|
}).pipe(Effect_exports.scoped);
|
|
59471
|
-
var discover = (config, network, options3 = {}) => Effect_exports.flatMap(
|
|
59472
|
-
discoverDrafts(config, network, options3),
|
|
59473
|
-
(devices) => Console_exports.log(JSON.stringify({ devices }, null, 2))
|
|
59474
|
-
);
|
|
59651
|
+
var discover = (config, network, options3 = {}) => Effect_exports.flatMap(discoverDrafts(config, network, options3), (devices) => printJson({ devices }));
|
|
59475
59652
|
var pointColumn = (point) => slugify(point.name) === point.id && !/^[=+\-@\t\r]/.test(point.name) ? point.name : point.id;
|
|
59476
59653
|
var draftPointsList = (drafts) => {
|
|
59477
59654
|
const header = ["device", "point", "unit", "device_instance", "address", "object_type", "object_instance"];
|
|
@@ -60113,7 +60290,7 @@ var describePointsListSchema = () => {
|
|
|
60113
60290
|
};
|
|
60114
60291
|
var templateRows = [
|
|
60115
60292
|
{
|
|
60116
|
-
device: "
|
|
60293
|
+
device: "Energy meter",
|
|
60117
60294
|
point: "Active power",
|
|
60118
60295
|
unit: "kW",
|
|
60119
60296
|
interval_s: "5",
|
|
@@ -60125,7 +60302,7 @@ var templateRows = [
|
|
|
60125
60302
|
byte_order: "CDAB"
|
|
60126
60303
|
},
|
|
60127
60304
|
{
|
|
60128
|
-
device: "
|
|
60305
|
+
device: "Energy meter",
|
|
60129
60306
|
point: "Energy",
|
|
60130
60307
|
unit: "kWh",
|
|
60131
60308
|
interval_s: "5",
|
|
@@ -60147,8 +60324,8 @@ var templateRows = [
|
|
|
60147
60324
|
profile: "eastron-sdm630"
|
|
60148
60325
|
},
|
|
60149
60326
|
{
|
|
60150
|
-
device: "
|
|
60151
|
-
point: "
|
|
60327
|
+
device: "Heat pump",
|
|
60328
|
+
point: "Flow temperature",
|
|
60152
60329
|
unit: "\xB0C",
|
|
60153
60330
|
interval_s: "30",
|
|
60154
60331
|
deadband: "0.2",
|
|
@@ -60157,8 +60334,8 @@ var templateRows = [
|
|
|
60157
60334
|
object_instance: "1"
|
|
60158
60335
|
},
|
|
60159
60336
|
{
|
|
60160
|
-
device: "
|
|
60161
|
-
point: "
|
|
60337
|
+
device: "Heat pump",
|
|
60338
|
+
point: "Compressor running",
|
|
60162
60339
|
interval_s: "30",
|
|
60163
60340
|
publish: "change",
|
|
60164
60341
|
device_instance: "2001",
|
|
@@ -60410,22 +60587,22 @@ var simulatedDevice = {
|
|
|
60410
60587
|
pollIntervalMs: 2e3,
|
|
60411
60588
|
points: [
|
|
60412
60589
|
{
|
|
60413
|
-
id: "
|
|
60414
|
-
name: "Simulated
|
|
60590
|
+
id: "flow-temp",
|
|
60591
|
+
name: "Simulated flow temperature",
|
|
60415
60592
|
unit: "unit:DEG_C",
|
|
60416
60593
|
deadband: 0.2,
|
|
60417
60594
|
waveform: "sine",
|
|
60418
|
-
min:
|
|
60419
|
-
max:
|
|
60595
|
+
min: 30,
|
|
60596
|
+
max: 38,
|
|
60420
60597
|
periodSeconds: 60
|
|
60421
60598
|
},
|
|
60422
60599
|
{
|
|
60423
|
-
id: "
|
|
60424
|
-
name: "Simulated
|
|
60425
|
-
unit: "unit:
|
|
60600
|
+
id: "power",
|
|
60601
|
+
name: "Simulated power",
|
|
60602
|
+
unit: "unit:KiloW",
|
|
60426
60603
|
waveform: "ramp",
|
|
60427
60604
|
min: 0,
|
|
60428
|
-
max:
|
|
60605
|
+
max: 8,
|
|
60429
60606
|
periodSeconds: 30
|
|
60430
60607
|
}
|
|
60431
60608
|
]
|
|
@@ -60455,7 +60632,7 @@ var lanInterfaces = (interfaces) => Object.entries(interfaces).flatMap(
|
|
|
60455
60632
|
return [{ name, address: info2.address, broadcast: broadcast2 }];
|
|
60456
60633
|
})
|
|
60457
60634
|
);
|
|
60458
|
-
var slugMessage = "lowercase letters, digits, - and _, starting with a letter or digit (
|
|
60635
|
+
var slugMessage = "lowercase letters, digits, - and _, starting with a letter or digit (site-1, not Site 1)";
|
|
60459
60636
|
var validSlug = (value4) => Schema_exports.is(Slug)(value4) ? Effect_exports.succeed(value4) : Effect_exports.fail(slugMessage);
|
|
60460
60637
|
var validBrokerUrl = (value4) => parseBrokerUrl(value4).pipe(
|
|
60461
60638
|
Effect_exports.as(value4),
|
|
@@ -60616,6 +60793,8 @@ var nextSteps = (path, config, folder = { written: [], kept: [] }) => {
|
|
|
60616
60793
|
];
|
|
60617
60794
|
const commands2 = [
|
|
60618
60795
|
...folderPath === "." ? [] : [[`cd ${folderPath}`, "the gateway's folder"]],
|
|
60796
|
+
// Before anything is started: a wrong URL, port or password shows here, not later as a stale gateway.
|
|
60797
|
+
[`ot-gateway broker${argument}`, `check that ${config.mqtt.url} answers, with a message there and back`],
|
|
60619
60798
|
...devices,
|
|
60620
60799
|
...compose5 ? [
|
|
60621
60800
|
["docker compose up -d", "start it in Docker, restarted after a crash or a reboot"],
|
|
@@ -61823,8 +62002,8 @@ var HttpClientError = class extends (/* @__PURE__ */ TaggedError2("HttpClientErr
|
|
|
61823
62002
|
var formatReason = (tag2) => tag2.endsWith("Error") ? tag2.slice(0, -5) : tag2;
|
|
61824
62003
|
var formatMessage = (reason, description, info2) => description ? `${reason}: ${description} (${info2})` : `${reason} error (${info2})`;
|
|
61825
62004
|
var formatMethodAndUrl = (request3) => `${request3.method} ${redactUrl(request3.url)}`;
|
|
61826
|
-
var reasonToJSON = (reason,
|
|
61827
|
-
...
|
|
62005
|
+
var reasonToJSON = (reason, json4) => ({
|
|
62006
|
+
...json4,
|
|
61828
62007
|
request: {
|
|
61829
62008
|
_id: "HttpClientRequest",
|
|
61830
62009
|
method: reason.request.method,
|
|
@@ -69731,7 +69910,7 @@ function makePayloadStreamDecoder(schema2, options3) {
|
|
|
69731
69910
|
return (request3) => readBody(request3).pipe(pipeThroughChannel(decode8({
|
|
69732
69911
|
ignoreEmptyLines: true,
|
|
69733
69912
|
maxLineBytes
|
|
69734
|
-
})), mapEffect2((
|
|
69913
|
+
})), mapEffect2((json4) => decodeElement(json4)), mapError6((error2) => {
|
|
69735
69914
|
if (HttpApiPayloadTooLarge.is(error2)) return error2;
|
|
69736
69915
|
if (!isNdjsonError(error2)) return new HttpApiSchemaError({
|
|
69737
69916
|
kind: "Payload",
|
|
@@ -70590,7 +70769,7 @@ function makeStreamBodyDecoder(streamSchema, options3) {
|
|
|
70590
70769
|
description: `NDJSON line exceeds maxElementBytes of ${maxElementBytes} bytes`
|
|
70591
70770
|
})
|
|
70592
70771
|
});
|
|
70593
|
-
}), mapEffect2((
|
|
70772
|
+
}), mapEffect2((json4) => decodeElement(json4)));
|
|
70594
70773
|
}
|
|
70595
70774
|
const decoder6 = makeSseDecoder(streamSchema, options3);
|
|
70596
70775
|
return (response, sseOptions) => decodeSseStream(response.stream, streamSchema, decoder6(sseOptions));
|
|
@@ -70871,6 +71050,8 @@ var DeviceStatus = Schema_exports.Struct({
|
|
|
70871
71050
|
/** Why the device is failing (the health topic's reason). */
|
|
70872
71051
|
reason: Schema_exports.optionalKey(Schema_exports.String),
|
|
70873
71052
|
lastSuccess: Schema_exports.optionalKey(Schema_exports.Number),
|
|
71053
|
+
/** How many points the config gives it, also when `points` is left out (`/api/status?points=none`). */
|
|
71054
|
+
pointCount: Schema_exports.Number,
|
|
70874
71055
|
points: Schema_exports.Array(PointStatus)
|
|
70875
71056
|
});
|
|
70876
71057
|
var CommandStatus = Schema_exports.Struct({
|
|
@@ -70917,6 +71098,41 @@ var MessageStatus = Schema_exports.Struct({
|
|
|
70917
71098
|
/** Messages on this topic since the gateway started. */
|
|
70918
71099
|
count: Schema_exports.Number
|
|
70919
71100
|
});
|
|
71101
|
+
var BrokerConnection = Schema_exports.Struct({
|
|
71102
|
+
protocolVersion: Schema_exports.Literals(["5", "3.1.1"]),
|
|
71103
|
+
maximumQoS: Schema_exports.Literals([0, 1]),
|
|
71104
|
+
retainAvailable: Schema_exports.Boolean,
|
|
71105
|
+
/** Seconds between pings, the broker's if it set one. */
|
|
71106
|
+
keepAliveSeconds: Schema_exports.Number,
|
|
71107
|
+
/** Unacknowledged QoS 1 publishes the gateway allows itself. */
|
|
71108
|
+
receiveMaximum: Schema_exports.Number,
|
|
71109
|
+
/** Bytes; absent when the broker announced no limit. */
|
|
71110
|
+
maximumPacketSize: Schema_exports.optionalKey(Schema_exports.Number)
|
|
71111
|
+
});
|
|
71112
|
+
var BrokerStatus = Schema_exports.Struct({
|
|
71113
|
+
url: Schema_exports.String,
|
|
71114
|
+
connected: Schema_exports.Boolean,
|
|
71115
|
+
/** Unix ms of the latest successful connect, and what the broker allowed then; absent before the first. */
|
|
71116
|
+
connectedAt: Schema_exports.optionalKey(Schema_exports.Number),
|
|
71117
|
+
connection: Schema_exports.optionalKey(BrokerConnection),
|
|
71118
|
+
/** Successful connects (the first one and every reconnect), and attempts that failed or the broker refused. */
|
|
71119
|
+
connects: Schema_exports.Number,
|
|
71120
|
+
failedConnects: Schema_exports.Number,
|
|
71121
|
+
/** Point values published, and messages that could not be published (without a buffer, those are lost). */
|
|
71122
|
+
published: Schema_exports.Number,
|
|
71123
|
+
publishFailures: Schema_exports.Number
|
|
71124
|
+
});
|
|
71125
|
+
var BufferStatus = Schema_exports.Struct({
|
|
71126
|
+
path: Schema_exports.String,
|
|
71127
|
+
rows: Schema_exports.Number,
|
|
71128
|
+
maxRows: Schema_exports.Number,
|
|
71129
|
+
dropped: Schema_exports.Number,
|
|
71130
|
+
written: Schema_exports.Number,
|
|
71131
|
+
delivered: Schema_exports.Number,
|
|
71132
|
+
droppedBy: Schema_exports.Record(Schema_exports.String, Schema_exports.Number),
|
|
71133
|
+
failures: Schema_exports.Number,
|
|
71134
|
+
disabled: Schema_exports.Boolean
|
|
71135
|
+
});
|
|
70920
71136
|
var GatewayStatus = Schema_exports.Struct({
|
|
70921
71137
|
site: Schema_exports.String,
|
|
70922
71138
|
building: Schema_exports.String,
|
|
@@ -70924,25 +71140,52 @@ var GatewayStatus = Schema_exports.Struct({
|
|
|
70924
71140
|
/** Unix ms when the gateway started, and when this snapshot was taken. */
|
|
70925
71141
|
since: Schema_exports.Number,
|
|
70926
71142
|
now: Schema_exports.Number,
|
|
70927
|
-
broker:
|
|
70928
|
-
/**
|
|
70929
|
-
|
|
70930
|
-
* messages the buffer gave up on since the gateway started (overflow past `maxRows`, refused, unreadable, ...).
|
|
70931
|
-
*/
|
|
70932
|
-
buffer: Schema_exports.optionalKey(
|
|
70933
|
-
Schema_exports.Struct({ path: Schema_exports.String, rows: Schema_exports.Number, maxRows: Schema_exports.Number, dropped: Schema_exports.Number })
|
|
70934
|
-
),
|
|
71143
|
+
broker: BrokerStatus,
|
|
71144
|
+
/** Absent without a `buffer` in the config. */
|
|
71145
|
+
buffer: Schema_exports.optionalKey(BufferStatus),
|
|
70935
71146
|
/** Absent until the host monitor's first sample. */
|
|
70936
71147
|
host: Schema_exports.optionalKey(HostStatus),
|
|
70937
71148
|
devices: Schema_exports.Array(DeviceStatus),
|
|
70938
71149
|
/** The most recent commands, newest first. */
|
|
70939
71150
|
commands: Schema_exports.Array(CommandStatus)
|
|
70940
71151
|
});
|
|
71152
|
+
var PointReading = Schema_exports.Struct({
|
|
71153
|
+
device: Schema_exports.String,
|
|
71154
|
+
point: Schema_exports.String,
|
|
71155
|
+
value: Schema_exports.optionalKey(Schema_exports.Union([Schema_exports.Number, Schema_exports.Boolean])),
|
|
71156
|
+
ts: Schema_exports.optionalKey(Schema_exports.Number)
|
|
71157
|
+
});
|
|
71158
|
+
var PointReadings = Schema_exports.Struct({ readings: Schema_exports.Array(PointReading) });
|
|
71159
|
+
var MAX_VALUES_PER_REQUEST = 500;
|
|
71160
|
+
var ValuesQueryInvalid = class extends Schema_exports.TaggedError()(
|
|
71161
|
+
"ValuesQueryInvalid",
|
|
71162
|
+
{ message: Schema_exports.String },
|
|
71163
|
+
{ httpApiStatus: 400 }
|
|
71164
|
+
) {
|
|
71165
|
+
};
|
|
70941
71166
|
var Messages = Schema_exports.Struct({
|
|
70942
71167
|
messages: Schema_exports.Array(MessageStatus),
|
|
70943
71168
|
/** Topics left out because the gateway keeps at most this many. */
|
|
70944
71169
|
droppedTopics: Schema_exports.Number
|
|
70945
71170
|
});
|
|
71171
|
+
var PointInfo = Schema_exports.Struct({
|
|
71172
|
+
device: Schema_exports.String,
|
|
71173
|
+
id: Schema_exports.String,
|
|
71174
|
+
name: Schema_exports.String,
|
|
71175
|
+
unit: Schema_exports.optionalKey(Schema_exports.String),
|
|
71176
|
+
writable: Schema_exports.Boolean,
|
|
71177
|
+
/** The MQTT topic its values go to (`site/building/device/point`). */
|
|
71178
|
+
topic: Schema_exports.String,
|
|
71179
|
+
/** Where the gateway reads it, in the config's words: `holding 40 · float32 CDAB`, `analog-input 3 · present-value`. */
|
|
71180
|
+
source: Schema_exports.String,
|
|
71181
|
+
/** How its values go out: `every read`, `on change ≥ 0.5`, `aggregate every 15 min`. */
|
|
71182
|
+
publish: Schema_exports.String,
|
|
71183
|
+
limits: Schema_exports.optionalKey(Schema_exports.Struct({ min: Schema_exports.Number, max: Schema_exports.Number })),
|
|
71184
|
+
scaling: Schema_exports.optionalKey(Schema_exports.Struct({ factor: Schema_exports.Number, offset: Schema_exports.Number })),
|
|
71185
|
+
brick: Schema_exports.optionalKey(Schema_exports.String),
|
|
71186
|
+
haystack: Schema_exports.optionalKey(Schema_exports.Array(Schema_exports.String))
|
|
71187
|
+
});
|
|
71188
|
+
var PointCatalog = Schema_exports.Struct({ points: Schema_exports.Array(PointInfo) });
|
|
70946
71189
|
var HistoryBucket = Schema_exports.Struct({
|
|
70947
71190
|
t: Schema_exports.Number,
|
|
70948
71191
|
min: Schema_exports.Number,
|
|
@@ -70971,7 +71214,36 @@ var HistoryQueryInvalid = class extends Schema_exports.TaggedError()(
|
|
|
70971
71214
|
{ httpApiStatus: 400 }
|
|
70972
71215
|
) {
|
|
70973
71216
|
};
|
|
70974
|
-
var
|
|
71217
|
+
var ConfigEntry = Schema_exports.Struct({ key: Schema_exports.String, value: Schema_exports.Json });
|
|
71218
|
+
var ConfigView = Schema_exports.Struct({
|
|
71219
|
+
sections: Schema_exports.Array(Schema_exports.Struct({ key: Schema_exports.String, entries: Schema_exports.Array(ConfigEntry) })),
|
|
71220
|
+
devices: Schema_exports.Array(
|
|
71221
|
+
Schema_exports.Struct({
|
|
71222
|
+
id: Schema_exports.String,
|
|
71223
|
+
protocol: Schema_exports.String,
|
|
71224
|
+
pointCount: Schema_exports.Number,
|
|
71225
|
+
entries: Schema_exports.Array(ConfigEntry)
|
|
71226
|
+
})
|
|
71227
|
+
)
|
|
71228
|
+
});
|
|
71229
|
+
var StatusGroup = class extends HttpApiGroup_exports.make("status").add(
|
|
71230
|
+
HttpApiEndpoint_exports.get("status", "/api/status", {
|
|
71231
|
+
query: {
|
|
71232
|
+
/** `none` leaves each device's `points` empty: health without every value, for a page that pages them. */
|
|
71233
|
+
points: Schema_exports.optional(Schema_exports.Literals(["all", "none"]))
|
|
71234
|
+
},
|
|
71235
|
+
success: GatewayStatus
|
|
71236
|
+
})
|
|
71237
|
+
).add(
|
|
71238
|
+
HttpApiEndpoint_exports.get("values", "/api/values", {
|
|
71239
|
+
query: {
|
|
71240
|
+
/** Comma-separated `device/point` keys (ids are slugs, so neither has a comma or a slash). */
|
|
71241
|
+
points: Schema_exports.String
|
|
71242
|
+
},
|
|
71243
|
+
success: PointReadings,
|
|
71244
|
+
error: ValuesQueryInvalid
|
|
71245
|
+
})
|
|
71246
|
+
).add(HttpApiEndpoint_exports.get("messages", "/api/messages", { success: Messages })).add(HttpApiEndpoint_exports.get("points", "/api/points", { success: PointCatalog })).add(HttpApiEndpoint_exports.get("config", "/api/config", { success: ConfigView })).add(
|
|
70975
71247
|
HttpApiEndpoint_exports.get("history", "/api/history", {
|
|
70976
71248
|
query: {
|
|
70977
71249
|
device: Schema_exports.String,
|
|
@@ -71479,13 +71751,13 @@ var formatStatus = (status3) => {
|
|
|
71479
71751
|
...status3.devices.map((device) => {
|
|
71480
71752
|
const lastRead = device.lastSuccess === void 0 ? "no read yet" : `read ${ago(status3.now - device.lastSuccess)} ago`;
|
|
71481
71753
|
const reason = device.reason === void 0 ? "" : ` (${device.reason})`;
|
|
71482
|
-
return ` ${device.id.padEnd(width3)} ${device.status.padEnd(8)} ${device.protocol}, ${device.
|
|
71754
|
+
return ` ${device.id.padEnd(width3)} ${device.status.padEnd(8)} ${device.protocol}, ${device.pointCount} point(s), ${lastRead}${reason}`;
|
|
71483
71755
|
})
|
|
71484
71756
|
].join("\n");
|
|
71485
71757
|
};
|
|
71486
71758
|
var advice = "Is the gateway running (ot-gateway run, or ot-gateway demo)? If its status page is elsewhere, pass --url.";
|
|
71487
|
-
var fetchGatewayStatus = (url) => HttpApiClient_exports.make(OtGatewayApi, { baseUrl: url }).pipe(
|
|
71488
|
-
Effect_exports.flatMap((client) => client.status.status()),
|
|
71759
|
+
var fetchGatewayStatus = (url, points2 = "all") => HttpApiClient_exports.make(OtGatewayApi, { baseUrl: url }).pipe(
|
|
71760
|
+
Effect_exports.flatMap((client) => client.status.status({ query: { points: points2 } })),
|
|
71489
71761
|
Effect_exports.provide(FetchHttpClient_exports.layer),
|
|
71490
71762
|
// Unreachable, a timeout or an answer that does not decode: the same advice for each.
|
|
71491
71763
|
Effect_exports.mapError(
|
|
@@ -71497,8 +71769,8 @@ var fetchGatewayStatus = (url) => HttpApiClient_exports.make(OtGatewayApi, { bas
|
|
|
71497
71769
|
})
|
|
71498
71770
|
);
|
|
71499
71771
|
var statusReport = Effect_exports.fn("statusReport")(function* (url, options3 = {}) {
|
|
71500
|
-
const status3 = yield* fetchGatewayStatus(url);
|
|
71501
|
-
yield*
|
|
71772
|
+
const status3 = yield* fetchGatewayStatus(url, options3.json === true ? "all" : "none");
|
|
71773
|
+
yield* options3.json === true ? printJson(status3) : Console_exports.log(formatStatus(status3));
|
|
71502
71774
|
});
|
|
71503
71775
|
|
|
71504
71776
|
// src/Broker.ts
|
|
@@ -71527,7 +71799,14 @@ var firstDialOf = (client, url) => client.firstDial.pipe(
|
|
|
71527
71799
|
duration: DIAL_TIMEOUT,
|
|
71528
71800
|
orElse: () => Effect_exports.fail(new MqttConnectionError({ message: `no answer within ${DIAL_TIMEOUT}` }))
|
|
71529
71801
|
}),
|
|
71530
|
-
Effect_exports.mapError(
|
|
71802
|
+
Effect_exports.mapError(
|
|
71803
|
+
(error2) => (
|
|
71804
|
+
// The socket's message starts with "could not connect" itself: say it once, with the URL.
|
|
71805
|
+
new BrokerCommandError({
|
|
71806
|
+
message: `could not connect to ${url}: ${error2.message.replace(/^could not connect(: )?/, "")}`
|
|
71807
|
+
})
|
|
71808
|
+
)
|
|
71809
|
+
)
|
|
71531
71810
|
);
|
|
71532
71811
|
var brokerWarnings = (info2, roundTripMs, topic) => [
|
|
71533
71812
|
...info2.protocolVersion === "3.1.1" ? [
|
|
@@ -71609,6 +71888,14 @@ var formatMessage2 = (message, at) => {
|
|
|
71609
71888
|
const payload = flat.length > MAX_PAYLOAD ? `${flat.slice(0, MAX_PAYLOAD)}\u2026` : flat;
|
|
71610
71889
|
return `${time2} ${message.retain ? "retained " : ""}${message.topic} ${payload}`;
|
|
71611
71890
|
};
|
|
71891
|
+
var messageRecord = (message, at) => {
|
|
71892
|
+
let payload = message.payload;
|
|
71893
|
+
try {
|
|
71894
|
+
payload = JSON.parse(message.payload);
|
|
71895
|
+
} catch {
|
|
71896
|
+
}
|
|
71897
|
+
return JSON.stringify({ at: at.toISOString(), topic: message.topic, retained: message.retain, payload });
|
|
71898
|
+
};
|
|
71612
71899
|
var watch3 = Effect_exports.fn("watch")(function* (config, options3 = {}) {
|
|
71613
71900
|
const filter14 = options3.topic ?? watchFilter(config);
|
|
71614
71901
|
yield* brokerClient(config.mqtt, "watch", {
|
|
@@ -71616,7 +71903,7 @@ var watch3 = Effect_exports.fn("watch")(function* (config, options3 = {}) {
|
|
|
71616
71903
|
onConnect: () => Console_exports.error(
|
|
71617
71904
|
`watching ${filter14} on ${config.mqtt.url} (${options3.seconds === void 0 ? "Ctrl-C to stop" : `for ${options3.seconds} s`})`
|
|
71618
71905
|
),
|
|
71619
|
-
onMessage: (message) => Console_exports.log(formatMessage2(message, /* @__PURE__ */ new Date()))
|
|
71906
|
+
onMessage: (message) => options3.json === true ? printResult(messageRecord(message, /* @__PURE__ */ new Date())) : Console_exports.log(formatMessage2(message, /* @__PURE__ */ new Date()))
|
|
71620
71907
|
});
|
|
71621
71908
|
yield* Console_exports.error(`connecting to ${config.mqtt.url}\u2026`);
|
|
71622
71909
|
if (options3.seconds === void 0) return yield* Effect_exports.never;
|
|
@@ -72336,6 +72623,8 @@ var monotonicMillis2 = Effect_exports.map(Clock_exports.monotonicTimeNanos, (nan
|
|
|
72336
72623
|
var cannotOpen = "buffer file cannot be opened: running WITHOUT store-and-forward, values are lost while the broker is down";
|
|
72337
72624
|
var makeBufferedPublisher = Effect_exports.fnUntraced(function* (settings, options3) {
|
|
72338
72625
|
const inner = yield* Publisher;
|
|
72626
|
+
const ownAttributes = yield* Metric_exports.CurrentMetricAttributes;
|
|
72627
|
+
const setGauge = (gauge3, value4) => Metric_exports.update(gauge3, value4).pipe(Effect_exports.provideService(Metric_exports.CurrentMetricAttributes, ownAttributes));
|
|
72339
72628
|
const batchSize = options3.batchSize ?? 100;
|
|
72340
72629
|
const retryDelay = options3.retryDelay ?? "5 seconds";
|
|
72341
72630
|
const checkInterval = options3.checkInterval ?? "30 seconds";
|
|
@@ -72356,20 +72645,20 @@ var makeBufferedPublisher = Effect_exports.fnUntraced(function* (settings, optio
|
|
|
72356
72645
|
const setPending = Effect_exports.fnUntraced(function* (target, rows) {
|
|
72357
72646
|
target.pending = Math.max(0, rows);
|
|
72358
72647
|
if (target !== current) return;
|
|
72359
|
-
yield*
|
|
72648
|
+
yield* setGauge(bufferRows, target.pending);
|
|
72360
72649
|
if (target.pending > 0) yield* Latch_exports.open(hasRows);
|
|
72361
72650
|
else yield* Latch_exports.close(hasRows);
|
|
72362
72651
|
});
|
|
72363
72652
|
const install = Effect_exports.fnUntraced(function* (database) {
|
|
72364
72653
|
if (database === void 0) {
|
|
72365
72654
|
current = void 0;
|
|
72366
|
-
yield*
|
|
72367
|
-
yield*
|
|
72655
|
+
yield* setGauge(bufferDisabled, 1);
|
|
72656
|
+
yield* setGauge(bufferRows, 0);
|
|
72368
72657
|
return yield* Latch_exports.close(hasRows);
|
|
72369
72658
|
}
|
|
72370
72659
|
const target = makeStore(database, yield* database.outbox.count());
|
|
72371
72660
|
current = target;
|
|
72372
|
-
yield*
|
|
72661
|
+
yield* setGauge(bufferDisabled, 0);
|
|
72373
72662
|
yield* setPending(target, target.pending);
|
|
72374
72663
|
if (target.pending > 0) {
|
|
72375
72664
|
yield* Effect_exports.logInfo("buffered messages waiting from a previous run").pipe(
|
|
@@ -74374,6 +74663,96 @@ var handleCause = (nodeResponse, originalResponse) => (originalCause) => flatMap
|
|
|
74374
74663
|
return failCause4(headersSent ? combine2(originalCause, die2(originalResponse)) : cause);
|
|
74375
74664
|
});
|
|
74376
74665
|
|
|
74666
|
+
// src/PointCatalog.ts
|
|
74667
|
+
var durationLabel = (ms) => {
|
|
74668
|
+
if (ms < 6e4) return `${Number((ms / 1e3).toFixed(1))} s`;
|
|
74669
|
+
if (ms < 36e5) return `${Number((ms / 6e4).toFixed(1))} min`;
|
|
74670
|
+
return `${Number((ms / 36e5).toFixed(1))} h`;
|
|
74671
|
+
};
|
|
74672
|
+
var publishLabel = (publish2) => {
|
|
74673
|
+
switch (publish2.mode) {
|
|
74674
|
+
case "sample":
|
|
74675
|
+
return publish2.intervalMs === void 0 ? "every read" : `latest, every ${durationLabel(publish2.intervalMs)}`;
|
|
74676
|
+
case "aggregate":
|
|
74677
|
+
return `aggregate every ${durationLabel(publish2.intervalMs)}`;
|
|
74678
|
+
case "change": {
|
|
74679
|
+
const change = publish2.deadband === void 0 || publish2.deadband === 0 ? "on change" : `on change \u2265 ${publish2.deadband}`;
|
|
74680
|
+
return publish2.maxSilenceMs === void 0 ? change : `${change}, at least every ${durationLabel(publish2.maxSilenceMs)}`;
|
|
74681
|
+
}
|
|
74682
|
+
}
|
|
74683
|
+
};
|
|
74684
|
+
var modbusSource = (point) => {
|
|
74685
|
+
const bit = point.bit === void 0 ? "" : ` bit ${point.bit}`;
|
|
74686
|
+
const order = point.table === "holding" || point.table === "input" ? ` ${point.byteOrder}` : "";
|
|
74687
|
+
return `${point.table} ${point.address}${bit} \xB7 ${point.dataType}${order}`;
|
|
74688
|
+
};
|
|
74689
|
+
var bacnetSource = (point) => `${point.objectType} ${point.instance} \xB7 ${point.property}${point.writable ? ` \xB7 priority ${point.priority}` : ""}`;
|
|
74690
|
+
var simulatedSource = (point) => point.waveform === "constant" ? `constant ${point.min}` : `${point.waveform} ${point.min} to ${point.max} \xB7 ${durationLabel(point.periodSeconds * 1e3)}`;
|
|
74691
|
+
var sourcedPoints = (device) => {
|
|
74692
|
+
switch (device.protocol) {
|
|
74693
|
+
case "modbus-tcp":
|
|
74694
|
+
return device.points.map((point) => [point, modbusSource(point)]);
|
|
74695
|
+
case "bacnet-ip":
|
|
74696
|
+
return device.points.map((point) => [point, bacnetSource(point)]);
|
|
74697
|
+
case "simulator":
|
|
74698
|
+
return device.points.map((point) => [point, simulatedSource(point)]);
|
|
74699
|
+
}
|
|
74700
|
+
};
|
|
74701
|
+
var pointCatalog = (config) => ({
|
|
74702
|
+
points: config.devices.flatMap(
|
|
74703
|
+
(device) => sourcedPoints(device).map(([point, source]) => {
|
|
74704
|
+
const semantics = point.semantics;
|
|
74705
|
+
return {
|
|
74706
|
+
device: device.id,
|
|
74707
|
+
id: point.id,
|
|
74708
|
+
name: point.name,
|
|
74709
|
+
...point.unit === void 0 ? {} : { unit: point.unit },
|
|
74710
|
+
writable: point.writable,
|
|
74711
|
+
topic: pointTopic({ site: config.site, building: config.building, device: device.id, point: point.id }),
|
|
74712
|
+
source,
|
|
74713
|
+
publish: publishLabel(publishOf(device.publish, point)),
|
|
74714
|
+
...point.limits === void 0 ? {} : { limits: point.limits },
|
|
74715
|
+
...point.scaling === void 0 ? {} : { scaling: point.scaling },
|
|
74716
|
+
...semantics?.brick === void 0 ? {} : { brick: semantics.brick },
|
|
74717
|
+
...semantics?.haystack === void 0 ? {} : { haystack: semantics.haystack }
|
|
74718
|
+
};
|
|
74719
|
+
})
|
|
74720
|
+
)
|
|
74721
|
+
});
|
|
74722
|
+
|
|
74723
|
+
// src/ConfigView.ts
|
|
74724
|
+
var encodeConfig = Schema_exports.encodeSync(GatewayConfig);
|
|
74725
|
+
var asJson = Schema_exports.decodeUnknownSync(Schema_exports.Json);
|
|
74726
|
+
var isObject2 = (value4) => typeof value4 === "object" && value4 !== null && !Array.isArray(value4);
|
|
74727
|
+
var entriesOf = (object, skip2 = []) => Object.entries(object).filter(([key5]) => !skip2.includes(key5)).map(([key5, value4]) => ({ key: key5, value: value4 }));
|
|
74728
|
+
var configView = (config) => {
|
|
74729
|
+
const encoded = asJson(encodeConfig(config));
|
|
74730
|
+
if (!isObject2(encoded)) return { sections: [], devices: [] };
|
|
74731
|
+
const usesBacnet = config.devices.some((device) => device.protocol === "bacnet-ip");
|
|
74732
|
+
const top = Object.entries(encoded);
|
|
74733
|
+
const sections = [
|
|
74734
|
+
{ key: "gateway", entries: top.filter(([, value4]) => !isObject2(value4) && !Array.isArray(value4)) },
|
|
74735
|
+
...top.filter(([key5, value4]) => isObject2(value4) && (key5 !== "bacnet" || usesBacnet)).map(([key5, value4]) => ({ key: key5, entries: isObject2(value4) ? Object.entries(value4) : [] }))
|
|
74736
|
+
].map((section) => ({
|
|
74737
|
+
key: section.key,
|
|
74738
|
+
entries: section.entries.map(([key5, value4]) => ({ key: key5, value: value4 }))
|
|
74739
|
+
}));
|
|
74740
|
+
const devices = config.devices.map((device, index2) => {
|
|
74741
|
+
const raw3 = Array.isArray(encoded["devices"]) ? encoded["devices"][index2] : void 0;
|
|
74742
|
+
return {
|
|
74743
|
+
id: device.id,
|
|
74744
|
+
protocol: device.protocol,
|
|
74745
|
+
pointCount: device.points.length,
|
|
74746
|
+
// The publish mode in words, as the Points tab shows it, and the default spelled out when the file has none.
|
|
74747
|
+
entries: [
|
|
74748
|
+
...raw3 !== void 0 && isObject2(raw3) ? entriesOf(raw3, ["id", "protocol", "points", "publish"]) : [],
|
|
74749
|
+
{ key: "publish", value: publishLabel(device.publish ?? everyRead) }
|
|
74750
|
+
]
|
|
74751
|
+
};
|
|
74752
|
+
});
|
|
74753
|
+
return { sections, devices };
|
|
74754
|
+
};
|
|
74755
|
+
|
|
74377
74756
|
// src/Status.ts
|
|
74378
74757
|
import { createServer as createServer2 } from "node:http";
|
|
74379
74758
|
import { fileURLToPath as fileURLToPath5 } from "node:url";
|
|
@@ -74393,6 +74772,14 @@ var makeStatusState = (config, health, since, host) => {
|
|
|
74393
74772
|
const latest = /* @__PURE__ */ new Map();
|
|
74394
74773
|
const droppedTopics = /* @__PURE__ */ new Set();
|
|
74395
74774
|
const commands2 = [];
|
|
74775
|
+
let broker;
|
|
74776
|
+
const catalog = pointCatalog(config);
|
|
74777
|
+
const settings = configView(config);
|
|
74778
|
+
const configured = new Set(catalog.points.map((point) => `${point.device}/${point.id}`));
|
|
74779
|
+
const lastRead = (key5) => {
|
|
74780
|
+
const payload = payloads.get(key5);
|
|
74781
|
+
return reads.get(key5) ?? Option_exports.getOrUndefined(payload === void 0 ? Option_exports.none() : decodeValue2(payload));
|
|
74782
|
+
};
|
|
74396
74783
|
const attributes = { site: config.site, building: config.building };
|
|
74397
74784
|
return {
|
|
74398
74785
|
recordPublish: (topic, payload, message) => {
|
|
@@ -74415,6 +74802,9 @@ var makeStatusState = (config, health, since, host) => {
|
|
|
74415
74802
|
reads.set(`${device}/${point}`, { value: value4, ts });
|
|
74416
74803
|
}
|
|
74417
74804
|
},
|
|
74805
|
+
recordBrokerConnection: (at, connection) => {
|
|
74806
|
+
broker = { at, connection };
|
|
74807
|
+
},
|
|
74418
74808
|
recordCommand: (at, command, outcome) => {
|
|
74419
74809
|
commands2.unshift({
|
|
74420
74810
|
at,
|
|
@@ -74425,14 +74815,16 @@ var makeStatusState = (config, health, since, host) => {
|
|
|
74425
74815
|
});
|
|
74426
74816
|
if (commands2.length > RECENT_COMMANDS) commands2.length = RECENT_COMMANDS;
|
|
74427
74817
|
},
|
|
74428
|
-
snapshot: Effect_exports.gen(function* () {
|
|
74818
|
+
snapshot: (points2 = "all") => Effect_exports.gen(function* () {
|
|
74429
74819
|
const now2 = yield* Clock_exports.currentTimeMillis;
|
|
74430
74820
|
const connected = (yield* Metric_exports.value(Metric_exports.withAttributes(mqttConnected, attributes))).value === 1;
|
|
74431
74821
|
const rows = (yield* Metric_exports.value(Metric_exports.withAttributes(bufferRows, attributes))).value;
|
|
74432
|
-
|
|
74433
|
-
|
|
74434
|
-
|
|
74435
|
-
|
|
74822
|
+
const disabled2 = (yield* Metric_exports.value(Metric_exports.withAttributes(bufferDisabled, attributes))).value === 1;
|
|
74823
|
+
const total = totals(yield* Metric_exports.snapshot, attributes);
|
|
74824
|
+
const droppedBy = Object.fromEntries(
|
|
74825
|
+
bufferDropReasons.map((reason) => [reason, total(bufferDropped.id, { reason })])
|
|
74826
|
+
);
|
|
74827
|
+
const dropped = Object.values(droppedBy).reduce((sum3, count2) => sum3 + count2, 0);
|
|
74436
74828
|
const devices = config.devices.map((device) => {
|
|
74437
74829
|
const state = health.devices.get(device.id) ?? { status: "starting" };
|
|
74438
74830
|
return {
|
|
@@ -74442,10 +74834,9 @@ var makeStatusState = (config, health, since, host) => {
|
|
|
74442
74834
|
pollIntervalMs: device.pollIntervalMs,
|
|
74443
74835
|
...state.reason === void 0 ? {} : { reason: state.reason },
|
|
74444
74836
|
...state.lastSuccess === void 0 ? {} : { lastSuccess: state.lastSuccess },
|
|
74445
|
-
|
|
74446
|
-
|
|
74447
|
-
const
|
|
74448
|
-
const last2 = reads.get(key5) ?? Option_exports.getOrUndefined(payload === void 0 ? Option_exports.none() : decodeValue2(payload));
|
|
74837
|
+
pointCount: device.points.length,
|
|
74838
|
+
points: points2 === "none" ? [] : device.points.map((point) => {
|
|
74839
|
+
const last2 = lastRead(`${device.id}/${point.id}`);
|
|
74449
74840
|
return {
|
|
74450
74841
|
id: point.id,
|
|
74451
74842
|
name: point.name,
|
|
@@ -74463,13 +74854,54 @@ var makeStatusState = (config, health, since, host) => {
|
|
|
74463
74854
|
id: config.id,
|
|
74464
74855
|
since,
|
|
74465
74856
|
now: now2,
|
|
74466
|
-
broker: {
|
|
74467
|
-
|
|
74857
|
+
broker: {
|
|
74858
|
+
url: config.mqtt.url,
|
|
74859
|
+
connected,
|
|
74860
|
+
...broker === void 0 ? {} : { connectedAt: broker.at, connection: broker.connection },
|
|
74861
|
+
connects: total(mqttConnects.id, { outcome: "ok" }),
|
|
74862
|
+
failedConnects: total(mqttConnects.id, { outcome: "failed" }) + total(mqttConnects.id, { outcome: "rejected" }),
|
|
74863
|
+
published: total(valuesPublished.id),
|
|
74864
|
+
publishFailures: total(publishFailures.id)
|
|
74865
|
+
},
|
|
74866
|
+
...config.buffer === void 0 ? {} : {
|
|
74867
|
+
buffer: {
|
|
74868
|
+
path: config.buffer.path,
|
|
74869
|
+
rows: Math.max(0, rows),
|
|
74870
|
+
maxRows: config.buffer.maxRows,
|
|
74871
|
+
dropped,
|
|
74872
|
+
written: total(bufferWritten.id),
|
|
74873
|
+
delivered: total(bufferDrained.id),
|
|
74874
|
+
droppedBy,
|
|
74875
|
+
failures: total(bufferFailures.id),
|
|
74876
|
+
disabled: disabled2
|
|
74877
|
+
}
|
|
74878
|
+
},
|
|
74468
74879
|
...host === void 0 || sample === void 0 ? {} : { host: { version: host.version, node: process.versions.node, ...sample } },
|
|
74469
74880
|
devices,
|
|
74470
74881
|
commands: [...commands2]
|
|
74471
74882
|
};
|
|
74472
74883
|
}),
|
|
74884
|
+
values: (keys4) => Effect_exports.gen(function* () {
|
|
74885
|
+
const asked = keys4.split(",").filter((key5) => key5 !== "");
|
|
74886
|
+
if (asked.length > MAX_VALUES_PER_REQUEST) {
|
|
74887
|
+
return yield* new ValuesQueryInvalid({
|
|
74888
|
+
message: `${asked.length} points asked for, at most ${MAX_VALUES_PER_REQUEST} per request`
|
|
74889
|
+
});
|
|
74890
|
+
}
|
|
74891
|
+
const readings = asked.flatMap((key5) => {
|
|
74892
|
+
if (!configured.has(key5)) return [];
|
|
74893
|
+
const slash = key5.indexOf("/");
|
|
74894
|
+
const last2 = lastRead(key5);
|
|
74895
|
+
return [
|
|
74896
|
+
{
|
|
74897
|
+
device: key5.slice(0, slash),
|
|
74898
|
+
point: key5.slice(slash + 1),
|
|
74899
|
+
...last2 === void 0 ? {} : { value: last2.value, ts: last2.ts }
|
|
74900
|
+
}
|
|
74901
|
+
];
|
|
74902
|
+
});
|
|
74903
|
+
return { readings };
|
|
74904
|
+
}),
|
|
74473
74905
|
messages: Effect_exports.sync(() => ({
|
|
74474
74906
|
messages: [...latest.entries()].toSorted(([a], [b]) => a < b ? -1 : a > b ? 1 : 0).map(([topic, message]) => ({
|
|
74475
74907
|
topic,
|
|
@@ -74480,9 +74912,21 @@ var makeStatusState = (config, health, since, host) => {
|
|
|
74480
74912
|
count: message.count
|
|
74481
74913
|
})),
|
|
74482
74914
|
droppedTopics: droppedTopics.size
|
|
74483
|
-
}))
|
|
74915
|
+
})),
|
|
74916
|
+
points: Effect_exports.succeed(catalog),
|
|
74917
|
+
config: Effect_exports.succeed(settings)
|
|
74484
74918
|
};
|
|
74485
74919
|
};
|
|
74920
|
+
var totals = (snapshots, scope3) => (id2, match9 = {}) => {
|
|
74921
|
+
const wanted = Object.entries({ ...scope3, ...match9 });
|
|
74922
|
+
let sum3 = 0;
|
|
74923
|
+
for (const snapshot3 of snapshots) {
|
|
74924
|
+
if (snapshot3.id !== id2 || snapshot3.type !== "Counter") continue;
|
|
74925
|
+
const attributes = snapshot3.attributes ?? {};
|
|
74926
|
+
if (wanted.every(([key5, value4]) => attributes[key5] === value4)) sum3 += Number(snapshot3.state.count);
|
|
74927
|
+
}
|
|
74928
|
+
return sum3;
|
|
74929
|
+
};
|
|
74486
74930
|
var DEFAULT_HISTORY_MS = 36e5;
|
|
74487
74931
|
var historyHandler = (config, history) => (request3) => Effect_exports.gen(function* () {
|
|
74488
74932
|
if (history === void 0) {
|
|
@@ -74513,7 +74957,7 @@ var serveStatus = (settings, state, history = () => Effect_exports.fail(new Hist
|
|
|
74513
74957
|
HttpApiBuilder_exports.group(
|
|
74514
74958
|
OtGatewayApi,
|
|
74515
74959
|
"status",
|
|
74516
|
-
(handlers) => handlers.handle("status", () => state.snapshot).handle("messages", () => state.messages).handle("history", ({ query: query3 }) => history(query3))
|
|
74960
|
+
(handlers) => handlers.handle("status", ({ query: query3 }) => state.snapshot(query3.points)).handle("values", ({ query: query3 }) => state.values(query3.points)).handle("messages", () => state.messages).handle("points", () => state.points).handle("config", () => state.config).handle("history", ({ query: query3 }) => history(query3))
|
|
74517
74961
|
)
|
|
74518
74962
|
)
|
|
74519
74963
|
);
|
|
@@ -75219,8 +75663,8 @@ function jsonReplacer(key5, value4) {
|
|
|
75219
75663
|
return value4;
|
|
75220
75664
|
}
|
|
75221
75665
|
var jsonBody = (data) => {
|
|
75222
|
-
const
|
|
75223
|
-
return text2(
|
|
75666
|
+
const json4 = JSON.stringify(data);
|
|
75667
|
+
return text2(json4.includes("null") || json4.includes('"bytesValue":') ? JSON.stringify(data, jsonReplacer) : json4, "application/json");
|
|
75224
75668
|
};
|
|
75225
75669
|
var layerJson = /* @__PURE__ */ succeed6(OtlpSerialization, {
|
|
75226
75670
|
traces: (spans) => jsonBody(spans),
|
|
@@ -76256,6 +76700,9 @@ var northbound = (config, health, options3, routing, status3, staleMeta) => {
|
|
|
76256
76700
|
health: { topic: health.topic, online: health.online },
|
|
76257
76701
|
// With a buffer, a value that cannot go out now is stored, so waiting for the broker would only stall reads.
|
|
76258
76702
|
waitForConnection: config.buffer === void 0,
|
|
76703
|
+
...status3 === void 0 ? {} : {
|
|
76704
|
+
onConnected: (connection) => Effect_exports.map(Clock_exports.currentTimeMillis, (at) => status3.recordBrokerConnection(at, connection))
|
|
76705
|
+
},
|
|
76259
76706
|
...options3.network === void 0 ? {} : { network: options3.network },
|
|
76260
76707
|
subscriptions: [...commandSubscriptions, ...staleMeta.subscriptions],
|
|
76261
76708
|
// A `$meta` topic is never a command topic (`.../$set`), so each message has one taker.
|
|
@@ -76379,12 +76826,7 @@ var jsonFlag = Flag_exports.Boolean("json").pipe(
|
|
|
76379
76826
|
Flag_exports.withDefault(false)
|
|
76380
76827
|
);
|
|
76381
76828
|
var errorText = (error2) => error2 instanceof Error ? error2.message : String(error2);
|
|
76382
|
-
var jsonFailure = (
|
|
76383
|
-
Effect_exports.tapError(
|
|
76384
|
-
(error2) => Console_exports.log(JSON.stringify({ ok: false, ...fields, error: errorText(error2) }, null, 2))
|
|
76385
|
-
)
|
|
76386
|
-
) : effect2;
|
|
76387
|
-
var printJson = (value4) => Console_exports.log(JSON.stringify(value4, null, 2));
|
|
76829
|
+
var jsonFailure = (json4, fields = {}) => (effect2) => json4 ? effect2.pipe(Effect_exports.tapError((error2) => printJson({ ok: false, ...fields, error: errorText(error2) }))) : effect2;
|
|
76388
76830
|
var dryRunFlag = (description) => Flag_exports.Boolean("dry-run").pipe(Flag_exports.withDescription(description), Flag_exports.withDefault(false));
|
|
76389
76831
|
var runConfigured = Effect_exports.fn("runConfigured")(function* (config) {
|
|
76390
76832
|
const version2 = yield* readVersion;
|
|
@@ -76419,9 +76861,9 @@ var run9 = Command_exports.make(
|
|
|
76419
76861
|
var check2 = Command_exports.make(
|
|
76420
76862
|
"check",
|
|
76421
76863
|
{ config: configPath, json: jsonFlag },
|
|
76422
|
-
({ config, json:
|
|
76423
|
-
Effect_exports.flatMap((decoded) =>
|
|
76424
|
-
jsonFailure(
|
|
76864
|
+
({ config, json: json4 }) => loadConfig(config).pipe(
|
|
76865
|
+
Effect_exports.flatMap((decoded) => json4 ? printJson(configSummary(decoded)) : Console_exports.log(describeConfig(decoded))),
|
|
76866
|
+
jsonFailure(json4, { path: config })
|
|
76425
76867
|
)
|
|
76426
76868
|
).pipe(Command_exports.withDescription("Validate a config without connecting to anything; lists every mistake with its path"));
|
|
76427
76869
|
var discoverCommand = Command_exports.make(
|
|
@@ -76441,10 +76883,10 @@ var discoverCommand = Command_exports.make(
|
|
|
76441
76883
|
json: jsonFlag
|
|
76442
76884
|
},
|
|
76443
76885
|
// The draft is JSON already; --json makes a failure JSON too.
|
|
76444
|
-
({ config, pointsList, address, json:
|
|
76886
|
+
({ config, pointsList, address, json: json4 }) => Effect_exports.flatMap(loadConfig(config), (decoded) => {
|
|
76445
76887
|
const options3 = { address: Option_exports.getOrUndefined(address) };
|
|
76446
76888
|
return Option_exports.isSome(pointsList) ? discoverToPointsList(decoded, pointsList.value, void 0, options3) : discover(decoded, void 0, options3);
|
|
76447
|
-
}).pipe(jsonFailure(
|
|
76889
|
+
}).pipe(jsonFailure(json4, { path: config }))
|
|
76448
76890
|
).pipe(
|
|
76449
76891
|
Command_exports.withDescription(
|
|
76450
76892
|
"Find BACnet devices through the config's bacnet settings and print a draft of their devices entries, read-only"
|
|
@@ -76493,7 +76935,7 @@ var init2 = Command_exports.make(
|
|
|
76493
76935
|
Argument_exports.optional,
|
|
76494
76936
|
Argument_exports.map(Option_exports.getOrUndefined)
|
|
76495
76937
|
),
|
|
76496
|
-
site: optionalFlag("site", "The site, the first topic segment (a slug:
|
|
76938
|
+
site: optionalFlag("site", "The site, the first topic segment (a slug: site-1)"),
|
|
76497
76939
|
building: optionalFlag("building", "The building, the second topic segment"),
|
|
76498
76940
|
broker: optionalFlag("broker", "The MQTT broker URL, mqtts:// for TLS"),
|
|
76499
76941
|
username: optionalFlag("username", "The broker username"),
|
|
@@ -76517,9 +76959,9 @@ var init2 = Command_exports.make(
|
|
|
76517
76959
|
Flag_exports.withDefault(false)
|
|
76518
76960
|
)
|
|
76519
76961
|
},
|
|
76520
|
-
({ directory, json:
|
|
76521
|
-
const interactive = !
|
|
76522
|
-
if (!given.yes && !
|
|
76962
|
+
({ directory, json: json4, ...given }) => Effect_exports.gen(function* () {
|
|
76963
|
+
const interactive = !json4 && isInteractive(given.yes, process.stdin.isTTY);
|
|
76964
|
+
if (!given.yes && !json4 && !interactive) {
|
|
76523
76965
|
yield* Console_exports.error(
|
|
76524
76966
|
"no terminal, so init asks nothing: the flags answer and the defaults fill the rest (--help lists the flags)"
|
|
76525
76967
|
);
|
|
@@ -76530,7 +76972,7 @@ var init2 = Command_exports.make(
|
|
|
76530
76972
|
if (written === void 0) return yield* Console_exports.log(`kept ${config} as it is`);
|
|
76531
76973
|
const folder = yield* writeFolderFiles(config, written, { dryRun: flags.dryRun });
|
|
76532
76974
|
const files = { ...folder, written: [config, ...folder.written] };
|
|
76533
|
-
if (
|
|
76975
|
+
if (json4) {
|
|
76534
76976
|
return yield* printJson({
|
|
76535
76977
|
...configSummary(written),
|
|
76536
76978
|
dryRun: flags.dryRun,
|
|
@@ -76551,7 +76993,7 @@ var init2 = Command_exports.make(
|
|
|
76551
76993
|
yield* Console_exports.log(describeConfig(written));
|
|
76552
76994
|
yield* Console_exports.log(nextSteps(config, written, files));
|
|
76553
76995
|
}).pipe(
|
|
76554
|
-
jsonFailure(
|
|
76996
|
+
jsonFailure(json4),
|
|
76555
76997
|
Effect_exports.catchTag(
|
|
76556
76998
|
"QuitError",
|
|
76557
76999
|
() => Console_exports.error("init cancelled, nothing written").pipe(Effect_exports.andThen(Effect_exports.sync(() => process.exitCode = 1)))
|
|
@@ -76563,15 +77005,15 @@ var init2 = Command_exports.make(
|
|
|
76563
77005
|
),
|
|
76564
77006
|
Command_exports.withExamples([
|
|
76565
77007
|
{
|
|
76566
|
-
command: "ot-gateway init
|
|
76567
|
-
description: "Make the folder
|
|
77008
|
+
command: "ot-gateway init site-1",
|
|
77009
|
+
description: "Make the folder site-1 and write the gateway's files in it"
|
|
76568
77010
|
},
|
|
76569
77011
|
{ command: "ot-gateway init .", description: "Write them in this folder" },
|
|
76570
77012
|
{
|
|
76571
|
-
command: "ot-gateway init
|
|
77013
|
+
command: "ot-gateway init site-1 --yes --site site-1 --broker mqtts://broker.example:8883 --points points.csv",
|
|
76572
77014
|
description: "The same without questions, for scripts and agents"
|
|
76573
77015
|
},
|
|
76574
|
-
{ command: "ot-gateway init
|
|
77016
|
+
{ command: "ot-gateway init site-1 --json --dry-run --site site-1", description: "Only show it, as JSON" }
|
|
76575
77017
|
])
|
|
76576
77018
|
);
|
|
76577
77019
|
var importCommand = Command_exports.make(
|
|
@@ -76584,14 +77026,14 @@ var importCommand = Command_exports.make(
|
|
|
76584
77026
|
dryRun: dryRunFlag("Check the list and print its devices instead of adding them to the config"),
|
|
76585
77027
|
json: jsonFlag
|
|
76586
77028
|
},
|
|
76587
|
-
({ list, config, dryRun, json:
|
|
77029
|
+
({ list, config, dryRun, json: json4 }) => Effect_exports.gen(function* () {
|
|
76588
77030
|
const { added, config: written } = yield* importPointsList(list, config, { dryRun });
|
|
76589
77031
|
const points2 = added.reduce((total, device) => total + device.points.length, 0);
|
|
76590
|
-
if (
|
|
77032
|
+
if (json4) return yield* printJson({ ok: true, dryRun, path: config, points: points2, devices: added });
|
|
76591
77033
|
if (written === void 0) return yield* printJson({ devices: added });
|
|
76592
77034
|
yield* Console_exports.log(`added ${added.length} device(s) with ${points2} point(s) to ${config}, none writable`);
|
|
76593
77035
|
yield* Console_exports.log(describeConfig(written));
|
|
76594
|
-
}).pipe(jsonFailure(
|
|
77036
|
+
}).pipe(jsonFailure(json4, { path: config }))
|
|
76595
77037
|
).pipe(
|
|
76596
77038
|
Command_exports.withDescription(
|
|
76597
77039
|
"Add the devices of a points list (CSV: device, point, host, register, type, unit, \u2026) to the config"
|
|
@@ -76604,7 +77046,7 @@ var importCommand = Command_exports.make(
|
|
|
76604
77046
|
var schemaCommand = Command_exports.make(
|
|
76605
77047
|
"schema",
|
|
76606
77048
|
{ json: jsonFlag },
|
|
76607
|
-
({ json:
|
|
77049
|
+
({ json: json4 }) => json4 ? printJson(pointsListSchema()) : Console_exports.log(describePointsListSchema())
|
|
76608
77050
|
).pipe(Command_exports.withDescription("The points list's columns, rules and allowed values"));
|
|
76609
77051
|
var templateCommand = Command_exports.make(
|
|
76610
77052
|
"template",
|
|
@@ -76632,9 +77074,9 @@ var fromEdeCommand = Command_exports.make(
|
|
|
76632
77074
|
var profilesList = Command_exports.make(
|
|
76633
77075
|
"list",
|
|
76634
77076
|
{ json: jsonFlag },
|
|
76635
|
-
({ json:
|
|
77077
|
+
({ json: json4 }) => Effect_exports.gen(function* () {
|
|
76636
77078
|
const profiles2 = yield* libraryProfiles();
|
|
76637
|
-
if (
|
|
77079
|
+
if (json4) {
|
|
76638
77080
|
return yield* printJson(
|
|
76639
77081
|
profiles2.map(({ id: id2, vendor, model, verified, points: points2 }) => ({
|
|
76640
77082
|
id: id2,
|
|
@@ -76651,7 +77093,7 @@ var profilesList = Command_exports.make(
|
|
|
76651
77093
|
(profile) => `${profile.id.padEnd(width3)}${profile.vendor} ${profile.model}, ${profile.points.length} points${profile.verified ? "" : ", from its register map (not yet checked on a device)"}`
|
|
76652
77094
|
).join("\n")
|
|
76653
77095
|
);
|
|
76654
|
-
}).pipe(jsonFailure(
|
|
77096
|
+
}).pipe(jsonFailure(json4))
|
|
76655
77097
|
).pipe(Command_exports.withDescription("The device profiles a points list can name in its profile column"));
|
|
76656
77098
|
var profilesShow = Command_exports.make(
|
|
76657
77099
|
"show",
|
|
@@ -76659,19 +77101,21 @@ var profilesShow = Command_exports.make(
|
|
|
76659
77101
|
profile: Argument_exports.String("profile").pipe(Argument_exports.withDescription("A profile id, or a path ending in .json")),
|
|
76660
77102
|
json: jsonFlag
|
|
76661
77103
|
},
|
|
76662
|
-
({ profile, json:
|
|
77104
|
+
({ profile, json: json4 }) => Effect_exports.gen(function* () {
|
|
76663
77105
|
const found = yield* resolveProfile(profile, { relativeTo: process.cwd() });
|
|
76664
|
-
if (
|
|
77106
|
+
if (json4) return yield* printJson(found);
|
|
76665
77107
|
yield* Console_exports.log(describeProfile(found));
|
|
76666
|
-
}).pipe(jsonFailure(
|
|
77108
|
+
}).pipe(jsonFailure(json4))
|
|
76667
77109
|
).pipe(
|
|
76668
77110
|
Command_exports.withDescription("One profile's points: names, registers, types and units"),
|
|
77111
|
+
// `get`, as other CLIs name reading one thing.
|
|
77112
|
+
Command_exports.withAlias("get"),
|
|
76669
77113
|
Command_exports.withExamples([{ command: "ot-gateway profiles show eastron-sdm630", description: "The SDM630's points" }])
|
|
76670
77114
|
);
|
|
76671
77115
|
var profilesSchema = Command_exports.make(
|
|
76672
77116
|
"schema",
|
|
76673
77117
|
{ json: jsonFlag },
|
|
76674
|
-
({ json:
|
|
77118
|
+
({ json: json4 }) => json4 ? printJson(profileJsonSchema()) : Console_exports.log(describeProfileFormat())
|
|
76675
77119
|
).pipe(Command_exports.withDescription("The profile format, to write one from a register map"));
|
|
76676
77120
|
var profiles = Command_exports.make("profiles").pipe(
|
|
76677
77121
|
Command_exports.withDescription("Device profiles: a Modbus model's registers, named once and reused by points lists"),
|
|
@@ -76696,27 +77140,32 @@ var watchCommand = Command_exports.make(
|
|
|
76696
77140
|
(seconds3) => `--seconds takes 1 or more, not ${seconds3}`
|
|
76697
77141
|
),
|
|
76698
77142
|
Flag_exports.optional
|
|
77143
|
+
),
|
|
77144
|
+
json: Flag_exports.Boolean("json").pipe(
|
|
77145
|
+
Flag_exports.withDescription("One JSON object per message and line (NDJSON): at, topic, retained, payload"),
|
|
77146
|
+
Flag_exports.withDefault(false)
|
|
76699
77147
|
)
|
|
76700
77148
|
},
|
|
76701
|
-
({ config, topic, seconds: seconds3 }) => Effect_exports.flatMap(
|
|
77149
|
+
({ config, topic, seconds: seconds3, json: json4 }) => Effect_exports.flatMap(
|
|
76702
77150
|
loadConfig(config),
|
|
76703
|
-
(decoded) => watch3(decoded, { topic: Option_exports.getOrUndefined(topic), seconds: Option_exports.getOrUndefined(seconds3) })
|
|
76704
|
-
)
|
|
77151
|
+
(decoded) => watch3(decoded, { topic: Option_exports.getOrUndefined(topic), seconds: Option_exports.getOrUndefined(seconds3), json: json4 })
|
|
77152
|
+
).pipe(jsonFailure(json4, { path: config }))
|
|
76705
77153
|
).pipe(
|
|
76706
77154
|
Command_exports.withDescription("Print what arrives at the config's broker under its site and building, as it arrives"),
|
|
76707
77155
|
Command_exports.withExamples([
|
|
76708
77156
|
{ command: "ot-gateway watch", description: "Watch the broker in ot-gateway.json" },
|
|
76709
|
-
{ command: "ot-gateway watch --topic '
|
|
76710
|
-
{ command: "ot-gateway watch --seconds 10", description: "Ten seconds of it, then stop" }
|
|
77157
|
+
{ command: "ot-gateway watch --topic 'site-1/building-a/heat-pump/#'", description: "Only one device" },
|
|
77158
|
+
{ command: "ot-gateway watch --seconds 10", description: "Ten seconds of it, then stop" },
|
|
77159
|
+
{ command: "ot-gateway watch --seconds 10 --json", description: "The same as JSON lines, for scripts and agents" }
|
|
76711
77160
|
])
|
|
76712
77161
|
);
|
|
76713
77162
|
var brokerCommand = Command_exports.make(
|
|
76714
77163
|
"broker",
|
|
76715
77164
|
{ config: configPath, json: jsonFlag },
|
|
76716
|
-
({ config, json:
|
|
77165
|
+
({ config, json: json4 }) => loadConfig(config).pipe(
|
|
76717
77166
|
Effect_exports.flatMap(checkBroker),
|
|
76718
|
-
Effect_exports.flatMap((report) =>
|
|
76719
|
-
jsonFailure(
|
|
77167
|
+
Effect_exports.flatMap((report) => json4 ? printJson(report) : Console_exports.log(formatBrokerReport(report))),
|
|
77168
|
+
jsonFailure(json4, { path: config })
|
|
76720
77169
|
)
|
|
76721
77170
|
).pipe(
|
|
76722
77171
|
Command_exports.withDescription(
|
|
@@ -76754,10 +77203,10 @@ var publishCommand = Command_exports.make(
|
|
|
76754
77203
|
),
|
|
76755
77204
|
json: jsonFlag
|
|
76756
77205
|
},
|
|
76757
|
-
({ topic, payload, config, retain, qos, json:
|
|
77206
|
+
({ topic, payload, config, retain, qos, json: json4 }) => loadConfig(config).pipe(
|
|
76758
77207
|
Effect_exports.flatMap((decoded) => publishOnce(decoded, topic, payload, { retain, qos })),
|
|
76759
|
-
Effect_exports.flatMap((result4) =>
|
|
76760
|
-
jsonFailure(
|
|
77208
|
+
Effect_exports.flatMap((result4) => json4 ? printJson(result4) : Console_exports.log(formatPublished(result4))),
|
|
77209
|
+
jsonFailure(json4, { topic })
|
|
76761
77210
|
)
|
|
76762
77211
|
).pipe(
|
|
76763
77212
|
Command_exports.withDescription("Send one message to the config's broker, as the gateway's user"),
|
|
@@ -76778,10 +77227,10 @@ var status2 = Command_exports.make(
|
|
|
76778
77227
|
),
|
|
76779
77228
|
json: jsonFlag
|
|
76780
77229
|
},
|
|
76781
|
-
({ url, json:
|
|
77230
|
+
({ url, json: json4 }) => statusReport(url, { json: json4 }).pipe(jsonFailure(json4, { url }))
|
|
76782
77231
|
).pipe(Command_exports.withDescription("The running gateway's status: its broker, buffer and one line per device"));
|
|
76783
77232
|
var rootDescription = [
|
|
76784
|
-
"OT Gateway: Modbus TCP and BACnet/IP in, MQTT 5 out, safe commands back",
|
|
77233
|
+
"OT Gateway: Modbus TCP and BACnet/IP in, MQTT 5 or 3.1.1 out, safe commands back",
|
|
76785
77234
|
"",
|
|
76786
77235
|
" For AI agents: nothing asks without a terminal, and --json prints results and failures as JSON.",
|
|
76787
77236
|
" points schema --json the points list's columns: translate any list or EDE file into it",
|
|
@@ -76823,19 +77272,28 @@ var subcommands = /* @__PURE__ */ new Set([
|
|
|
76823
77272
|
"publish",
|
|
76824
77273
|
"status"
|
|
76825
77274
|
]);
|
|
76826
|
-
var toCliArgs = (
|
|
76827
|
-
const [first] =
|
|
77275
|
+
var toCliArgs = (argv2) => {
|
|
77276
|
+
const [first] = argv2;
|
|
76828
77277
|
if (first !== void 0 && (subcommands.has(first) || first.startsWith("-") && !legacyFlags.has(first))) {
|
|
76829
|
-
return
|
|
77278
|
+
return argv2;
|
|
77279
|
+
}
|
|
77280
|
+
if (first !== void 0 && !legacyFlags.has(first) && !looksLikePath(first) && !argv2.some((arg) => legacyFlags.has(arg))) {
|
|
77281
|
+
return argv2;
|
|
76830
77282
|
}
|
|
76831
77283
|
for (const flag of legacyFlags) {
|
|
76832
|
-
if (
|
|
77284
|
+
if (argv2.includes(flag)) return [flag.slice(2), ...argv2.filter((arg) => arg !== flag)];
|
|
76833
77285
|
}
|
|
76834
|
-
return ["run", ...
|
|
77286
|
+
return ["run", ...argv2];
|
|
76835
77287
|
};
|
|
76836
77288
|
var legacyFlags = /* @__PURE__ */ new Set(["--check", "--discover"]);
|
|
77289
|
+
var looksLikePath = (arg) => arg.includes("/") || arg.includes("\\") || arg.includes(".");
|
|
76837
77290
|
var cliVersion = (version2) => version2.replace(/^v(?=\d)/, "");
|
|
76838
|
-
var runCli = (
|
|
77291
|
+
var runCli = (argv2) => {
|
|
77292
|
+
const args2 = toCliArgs(argv2);
|
|
77293
|
+
const program = Effect_exports.flatMap(readVersion, (version2) => Command_exports.runWith(cli, { version: cliVersion(version2) })(args2));
|
|
77294
|
+
return longRunning.has(args2[0] ?? "") ? program : Effect_exports.provideService(program, References_exports.MinimumLogLevel, "Warn");
|
|
77295
|
+
};
|
|
77296
|
+
var longRunning = /* @__PURE__ */ new Set(["run", "demo"]);
|
|
76839
77297
|
|
|
76840
77298
|
// src/EnvFile.ts
|
|
76841
77299
|
import { readFileSync } from "node:fs";
|
|
@@ -76858,6 +77316,12 @@ var loadEnvFile = (file3 = envFileName, env = process.env) => {
|
|
|
76858
77316
|
// src/Shutdown.ts
|
|
76859
77317
|
var gatewayTeardown = (exit3, onExit5) => {
|
|
76860
77318
|
if (Exit_exports.isFailure(exit3) && Cause_exports.hasInterruptsOnly(exit3.cause)) return onExit5(0);
|
|
77319
|
+
if (Exit_exports.isFailure(exit3)) {
|
|
77320
|
+
const error2 = Cause_exports.findError(exit3.cause);
|
|
77321
|
+
if (Result_exports.isSuccess(error2) && CliError_exports.isCliError(error2.success) && isUsageError(error2.success)) {
|
|
77322
|
+
return onExit5(USAGE_EXIT_CODE);
|
|
77323
|
+
}
|
|
77324
|
+
}
|
|
76861
77325
|
return Runtime_exports.defaultTeardown(exit3, onExit5);
|
|
76862
77326
|
};
|
|
76863
77327
|
|
|
@@ -76867,15 +77331,23 @@ var reportFailure = (cause) => {
|
|
|
76867
77331
|
if (Cause_exports.hasInterruptsOnly(cause)) return Effect_exports.void;
|
|
76868
77332
|
const error2 = Cause_exports.findError(cause);
|
|
76869
77333
|
if (Result_exports.isFailure(error2) || Cause_exports.hasDies(cause)) return Effect_exports.logError(cause);
|
|
76870
|
-
if (CliError_exports.isCliError(error2.success))
|
|
76871
|
-
|
|
77334
|
+
if (CliError_exports.isCliError(error2.success)) {
|
|
77335
|
+
return json3 && isUsageError(error2.success) ? printJson(usageFailure(error2.success)) : Effect_exports.void;
|
|
77336
|
+
}
|
|
77337
|
+
return json3 ? Effect_exports.void : Effect_exports.logError(error2.success.message);
|
|
76872
77338
|
};
|
|
76873
77339
|
loadEnvFile();
|
|
76874
77340
|
var extraEnvFile = process.env["OT_GATEWAY_ENV_FILE"];
|
|
76875
77341
|
if (extraEnvFile !== void 0 && extraEnvFile !== "") loadEnvFile(extraEnvFile);
|
|
76876
|
-
var
|
|
76877
|
-
|
|
77342
|
+
var argv = process.argv.slice(2);
|
|
77343
|
+
var json3 = isJsonMode(argv);
|
|
77344
|
+
runCli(argv).pipe(
|
|
76878
77345
|
Effect_exports.tapCause(reportFailure),
|
|
77346
|
+
// --json: stdout is the JSON result alone (Output.ts), so help, banners and progress go to stderr.
|
|
77347
|
+
json3 ? (effect2) => effect2.pipe(
|
|
77348
|
+
Effect_exports.updateService(Console_exports.Console, stderrConsole),
|
|
77349
|
+
Effect_exports.provideService(ResultConsole, globalThis.console)
|
|
77350
|
+
) : identity,
|
|
76879
77351
|
// Logs, the final failure among them, go to stderr: stdout is for results, so `check --json | jq` gets JSON only.
|
|
76880
77352
|
Effect_exports.provideService(Logger_exports.LogToStderr, true),
|
|
76881
77353
|
Effect_exports.provide(layer11),
|