signalk-questdb 2.0.1 → 2.1.1
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/.coderabbit.yaml +4 -3
- package/README.md +151 -5
- package/dist/api-contract.d.ts +62 -0
- package/dist/config/schema.d.ts +1 -0
- package/dist/config/schema.js +5 -0
- package/dist/config/schema.js.map +1 -1
- package/dist/configpanel/responses.d.ts +33 -1
- package/dist/configpanel/responses.js +89 -0
- package/dist/configpanel/responses.js.map +1 -1
- package/dist/history-v1.js +12 -9
- package/dist/history-v1.js.map +1 -1
- package/dist/history-v2.d.ts +18 -6
- package/dist/history-v2.js +275 -41
- package/dist/history-v2.js.map +1 -1
- package/dist/ilp-writer.d.ts +22 -0
- package/dist/ilp-writer.js +76 -4
- package/dist/ilp-writer.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +326 -58
- package/dist/index.js.map +1 -1
- package/dist/influx-detect.d.ts +19 -0
- package/dist/influx-detect.js +165 -0
- package/dist/influx-detect.js.map +1 -0
- package/dist/migration.d.ts +147 -0
- package/dist/migration.js +819 -0
- package/dist/migration.js.map +1 -0
- package/dist/query-client.d.ts +9 -0
- package/dist/query-client.js +11 -0
- package/dist/query-client.js.map +1 -1
- package/dist/restore.js +9 -0
- package/dist/restore.js.map +1 -1
- package/dist/schema-errors.d.ts +15 -0
- package/dist/schema-errors.js +38 -0
- package/dist/schema-errors.js.map +1 -0
- package/package.json +5 -4
- package/public/assets/PluginConfigurationPanel-CR4mD9IH.js +9 -0
- package/public/assets/{index-Z7eUk0W6.js → index-CyI4zKUm.js} +1 -1
- package/public/assets/{virtualExposes-CyrNon4j.js → virtualExposes-BBIkbTtD.js} +1 -1
- package/public/remoteEntry.js +1 -1
- package/dist/test/config.test.d.ts +0 -1
- package/dist/test/config.test.js +0 -161
- package/dist/test/config.test.js.map +0 -1
- package/dist/test/configpanel-responses.test.d.ts +0 -1
- package/dist/test/configpanel-responses.test.js +0 -108
- package/dist/test/configpanel-responses.test.js.map +0 -1
- package/dist/test/console-proxy.test.d.ts +0 -1
- package/dist/test/console-proxy.test.js +0 -664
- package/dist/test/console-proxy.test.js.map +0 -1
- package/dist/test/container-env.test.d.ts +0 -1
- package/dist/test/container-env.test.js +0 -70
- package/dist/test/container-env.test.js.map +0 -1
- package/dist/test/delta-routing.test.d.ts +0 -1
- package/dist/test/delta-routing.test.js +0 -258
- package/dist/test/delta-routing.test.js.map +0 -1
- package/dist/test/full-export-range.test.d.ts +0 -1
- package/dist/test/full-export-range.test.js +0 -78
- package/dist/test/full-export-range.test.js.map +0 -1
- package/dist/test/history-v1.test.d.ts +0 -1
- package/dist/test/history-v1.test.js +0 -676
- package/dist/test/history-v1.test.js.map +0 -1
- package/dist/test/history-v2.test.d.ts +0 -1
- package/dist/test/history-v2.test.js +0 -563
- package/dist/test/history-v2.test.js.map +0 -1
- package/dist/test/host-limits.test.d.ts +0 -1
- package/dist/test/host-limits.test.js +0 -81
- package/dist/test/host-limits.test.js.map +0 -1
- package/dist/test/ilp-writer.test.d.ts +0 -1
- package/dist/test/ilp-writer.test.js +0 -391
- package/dist/test/ilp-writer.test.js.map +0 -1
- package/dist/test/package-e2e.test.d.ts +0 -1
- package/dist/test/package-e2e.test.js +0 -306
- package/dist/test/package-e2e.test.js.map +0 -1
- package/dist/test/path-matcher.test.d.ts +0 -1
- package/dist/test/path-matcher.test.js +0 -224
- package/dist/test/path-matcher.test.js.map +0 -1
- package/dist/test/query-client.test.d.ts +0 -1
- package/dist/test/query-client.test.js +0 -299
- package/dist/test/query-client.test.js.map +0 -1
- package/dist/test/questdb-endpoint.test.d.ts +0 -1
- package/dist/test/questdb-endpoint.test.js +0 -297
- package/dist/test/questdb-endpoint.test.js.map +0 -1
- package/dist/test/restore.test.d.ts +0 -1
- package/dist/test/restore.test.js +0 -496
- package/dist/test/restore.test.js.map +0 -1
- package/dist/test/time-range.test.d.ts +0 -1
- package/dist/test/time-range.test.js +0 -53
- package/dist/test/time-range.test.js.map +0 -1
- package/dist/test/wal-monitor.test.d.ts +0 -1
- package/dist/test/wal-monitor.test.js +0 -405
- package/dist/test/wal-monitor.test.js.map +0 -1
- package/public/assets/PluginConfigurationPanel-CyS3A7gD.js +0 -9
package/dist/test/config.test.js
DELETED
|
@@ -1,161 +0,0 @@
|
|
|
1
|
-
import { describe, it } from "node:test";
|
|
2
|
-
import assert from "node:assert/strict";
|
|
3
|
-
import { normalizeConfig } from "../config/schema.js";
|
|
4
|
-
// Signal K hands the plugin its stored configuration verbatim — a config
|
|
5
|
-
// saved before an option existed simply misses the key, and TypeBox
|
|
6
|
-
// defaults are not applied at load time. These tests build such configs the
|
|
7
|
-
// way they exist on disk (missing keys), hence the casts.
|
|
8
|
-
describe("normalizeConfig", () => {
|
|
9
|
-
it("fills pathFilter and samplingRates missing from a legacy config", () => {
|
|
10
|
-
const legacy = {
|
|
11
|
-
managedContainer: true,
|
|
12
|
-
recordSelf: true,
|
|
13
|
-
};
|
|
14
|
-
const normalized = normalizeConfig(legacy);
|
|
15
|
-
assert.deepEqual(normalized.pathFilter, { mode: "exclude", paths: [] });
|
|
16
|
-
assert.deepEqual(normalized.samplingRates, {});
|
|
17
|
-
// The defaults must be usable by the per-delta pipeline: pathFilter.paths
|
|
18
|
-
// is iterable and samplingRates is Object.entries-able.
|
|
19
|
-
assert.equal(normalized.pathFilter.paths.length, 0);
|
|
20
|
-
assert.equal(Object.entries(normalized.samplingRates).length, 0);
|
|
21
|
-
});
|
|
22
|
-
it("backfills a partially-shaped pathFilter per field", () => {
|
|
23
|
-
const partial = {
|
|
24
|
-
pathFilter: { mode: "include" },
|
|
25
|
-
};
|
|
26
|
-
const normalized = normalizeConfig(partial);
|
|
27
|
-
assert.deepEqual(normalized.pathFilter, { mode: "include", paths: [] });
|
|
28
|
-
const pathsOnly = {
|
|
29
|
-
pathFilter: { paths: ["navigation.*"] },
|
|
30
|
-
};
|
|
31
|
-
assert.deepEqual(normalizeConfig(pathsOnly).pathFilter, {
|
|
32
|
-
mode: "exclude",
|
|
33
|
-
paths: ["navigation.*"],
|
|
34
|
-
});
|
|
35
|
-
});
|
|
36
|
-
it("preserves values that are present", () => {
|
|
37
|
-
const config = {
|
|
38
|
-
pathFilter: { mode: "include", paths: ["navigation.*"] },
|
|
39
|
-
samplingRates: { "environment.wind.*": 200 },
|
|
40
|
-
};
|
|
41
|
-
const normalized = normalizeConfig(config);
|
|
42
|
-
assert.deepEqual(normalized.pathFilter, {
|
|
43
|
-
mode: "include",
|
|
44
|
-
paths: ["navigation.*"],
|
|
45
|
-
});
|
|
46
|
-
assert.deepEqual(normalized.samplingRates, {
|
|
47
|
-
"environment.wind.*": 200,
|
|
48
|
-
});
|
|
49
|
-
});
|
|
50
|
-
it("does not mutate the input", () => {
|
|
51
|
-
const legacy = { recordSelf: true };
|
|
52
|
-
normalizeConfig(legacy);
|
|
53
|
-
assert.equal(legacy.pathFilter, undefined, "input object must stay untouched");
|
|
54
|
-
});
|
|
55
|
-
});
|
|
56
|
-
describe("normalizeConfig recording toggles", () => {
|
|
57
|
-
it("defaults missing toggles to enabled, matching the schema", () => {
|
|
58
|
-
// A hand-edited or pre-panel config misses the keys entirely; the
|
|
59
|
-
// runtime guards read them directly, so missing must mean the schema
|
|
60
|
-
// default (both ON), not "disabled".
|
|
61
|
-
const legacy = { managedContainer: true };
|
|
62
|
-
const normalized = normalizeConfig(legacy);
|
|
63
|
-
assert.equal(normalized.recordSelf, true);
|
|
64
|
-
assert.equal(normalized.recordOthers, true);
|
|
65
|
-
});
|
|
66
|
-
it("preserves an explicit opt-out", () => {
|
|
67
|
-
const config = {
|
|
68
|
-
recordSelf: false,
|
|
69
|
-
recordOthers: false,
|
|
70
|
-
};
|
|
71
|
-
const normalized = normalizeConfig(config);
|
|
72
|
-
assert.equal(normalized.recordSelf, false);
|
|
73
|
-
assert.equal(normalized.recordOthers, false);
|
|
74
|
-
});
|
|
75
|
-
});
|
|
76
|
-
describe("normalizeConfig startup restore", () => {
|
|
77
|
-
it("defaults a missing restore toggle to OFF", () => {
|
|
78
|
-
// Restore is opt-in — the inverse of the recording toggles. Defaulting a
|
|
79
|
-
// missing key to ON would start replaying history for every existing
|
|
80
|
-
// install on upgrade.
|
|
81
|
-
const legacy = { managedContainer: true };
|
|
82
|
-
const normalized = normalizeConfig(legacy);
|
|
83
|
-
assert.equal(normalized.restoreOnStart, false);
|
|
84
|
-
});
|
|
85
|
-
it("preserves an explicit opt-in", () => {
|
|
86
|
-
const config = { restoreOnStart: true };
|
|
87
|
-
assert.equal(normalizeConfig(config).restoreOnStart, true);
|
|
88
|
-
});
|
|
89
|
-
it("backfills a missing window with the schema default", () => {
|
|
90
|
-
const legacy = { restoreOnStart: true };
|
|
91
|
-
assert.equal(normalizeConfig(legacy).restoreMaxAgeMinutes, 9);
|
|
92
|
-
});
|
|
93
|
-
it("treats a zero or negative window as unset rather than disabling silently", () => {
|
|
94
|
-
// A zero window would replay nothing while the toggle still reads "on",
|
|
95
|
-
// which is indistinguishable from the feature being broken.
|
|
96
|
-
for (const value of [0, -5]) {
|
|
97
|
-
const config = {
|
|
98
|
-
restoreOnStart: true,
|
|
99
|
-
restoreMaxAgeMinutes: value,
|
|
100
|
-
};
|
|
101
|
-
assert.equal(normalizeConfig(config).restoreMaxAgeMinutes, 9);
|
|
102
|
-
}
|
|
103
|
-
});
|
|
104
|
-
it("preserves a custom window", () => {
|
|
105
|
-
const config = {
|
|
106
|
-
restoreOnStart: true,
|
|
107
|
-
restoreMaxAgeMinutes: 30,
|
|
108
|
-
};
|
|
109
|
-
assert.equal(normalizeConfig(config).restoreMaxAgeMinutes, 30);
|
|
110
|
-
});
|
|
111
|
-
});
|
|
112
|
-
describe("normalizeConfig console webapp", () => {
|
|
113
|
-
it("defaults a missing console toggle to ON", () => {
|
|
114
|
-
// Unlike restoreOnStart, the console is on by default: it only ever does
|
|
115
|
-
// what an authenticated admin types, so a missing key must not hide the
|
|
116
|
-
// tool from someone upgrading.
|
|
117
|
-
const legacy = { managedContainer: true };
|
|
118
|
-
assert.equal(normalizeConfig(legacy).enableConsole, true);
|
|
119
|
-
});
|
|
120
|
-
it("preserves an explicit opt-out", () => {
|
|
121
|
-
// The schema default and this fallback must agree — recordOthers once
|
|
122
|
-
// drifted from its documented default exactly this way.
|
|
123
|
-
const config = { enableConsole: false };
|
|
124
|
-
assert.equal(normalizeConfig(config).enableConsole, false);
|
|
125
|
-
});
|
|
126
|
-
it("treats only an explicit false as off", () => {
|
|
127
|
-
const config = { enableConsole: true };
|
|
128
|
-
assert.equal(normalizeConfig(config).enableConsole, true);
|
|
129
|
-
});
|
|
130
|
-
});
|
|
131
|
-
describe("normalizeConfig resource limits", () => {
|
|
132
|
-
it("backfills limits dropped by pre-fix panel saves (issue #98)", () => {
|
|
133
|
-
// The panel used to replace the config wholesale, stripping the resource
|
|
134
|
-
// keys — which ran QuestDB with NO memory cap instead of the schema's
|
|
135
|
-
// 768m. Missing keys must recover the schema defaults.
|
|
136
|
-
const damaged = { managedContainer: true };
|
|
137
|
-
const normalized = normalizeConfig(damaged);
|
|
138
|
-
assert.equal(normalized.questdbMemoryLimit, "768m");
|
|
139
|
-
assert.equal(normalized.questdbCpuLimit, 1.5);
|
|
140
|
-
});
|
|
141
|
-
it("preserves the documented unlimited opt-outs", () => {
|
|
142
|
-
// "" (memory) and 0 (CPU) are explicit choices, not missing keys.
|
|
143
|
-
const config = {
|
|
144
|
-
questdbMemoryLimit: "",
|
|
145
|
-
questdbCpuLimit: 0,
|
|
146
|
-
};
|
|
147
|
-
const normalized = normalizeConfig(config);
|
|
148
|
-
assert.equal(normalized.questdbMemoryLimit, "");
|
|
149
|
-
assert.equal(normalized.questdbCpuLimit, 0);
|
|
150
|
-
});
|
|
151
|
-
it("keeps explicit user limits untouched", () => {
|
|
152
|
-
const config = {
|
|
153
|
-
questdbMemoryLimit: "2g",
|
|
154
|
-
questdbCpuLimit: 3,
|
|
155
|
-
};
|
|
156
|
-
const normalized = normalizeConfig(config);
|
|
157
|
-
assert.equal(normalized.questdbMemoryLimit, "2g");
|
|
158
|
-
assert.equal(normalized.questdbCpuLimit, 3);
|
|
159
|
-
});
|
|
160
|
-
});
|
|
161
|
-
//# sourceMappingURL=config.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"config.test.js","sourceRoot":"","sources":["../../src/test/config.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,MAAM,MAAM,oBAAoB,CAAC;AACxC,OAAO,EAAE,eAAe,EAAe,MAAM,qBAAqB,CAAC;AAEnE,yEAAyE;AACzE,oEAAoE;AACpE,4EAA4E;AAC5E,0DAA0D;AAC1D,QAAQ,CAAC,iBAAiB,EAAE,GAAG,EAAE;IAC/B,EAAE,CAAC,iEAAiE,EAAE,GAAG,EAAE;QACzE,MAAM,MAAM,GAAG;YACb,gBAAgB,EAAE,IAAI;YACtB,UAAU,EAAE,IAAI;SACI,CAAC;QAEvB,MAAM,UAAU,GAAG,eAAe,CAAC,MAAM,CAAC,CAAC;QAC3C,MAAM,CAAC,SAAS,CAAC,UAAU,CAAC,UAAU,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,CAAC;QACxE,MAAM,CAAC,SAAS,CAAC,UAAU,CAAC,aAAa,EAAE,EAAE,CAAC,CAAC;QAC/C,0EAA0E;QAC1E,wDAAwD;QACxD,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,UAAU,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;QACpD,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;IACnE,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,mDAAmD,EAAE,GAAG,EAAE;QAC3D,MAAM,OAAO,GAAG;YACd,UAAU,EAAE,EAAE,IA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AC,MAAM,CAAC,CAAC;QAC3C,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,kBAAkB,EAAE,EAAE,CAAC,CAAC;QAChD,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,eAAe,EAAE,CAAC,CAAC,CAAC;IAC9C,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,sCAAsC,EAAE,GAAG,EAAE;QAC9C,MAAM,MAAM,GAAG;YACb,kBAAkB,EAAE,IAAI;YACxB,eAAe,EAAE,CAAC;SACE,CAAC;QACvB,MAAM,UAAU,GAAG,eAAe,CAAC,MAAM,CAAC,CAAC;QAC3C,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,kBAAkB,EAAE,IAAI,CAAC,CAAC;QAClD,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,eAAe,EAAE,CAAC,CAAC,CAAC;IAC9C,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
import { describe, it } from "node:test";
|
|
2
|
-
import assert from "node:assert/strict";
|
|
3
|
-
import { toMigrationSources } from "../configpanel/responses.js";
|
|
4
|
-
// The panel casts every `res.json()` to a contract type, which asserts a
|
|
5
|
-
// shape rather than checking one. The plugin's own handlers are well
|
|
6
|
-
// behaved; a reverse proxy, auth gateway or captive portal answering 200 on
|
|
7
|
-
// their behalf is not. These are the two responses the panel dereferences
|
|
8
|
-
// without a guard downstream, so a wrong shape reaches React as state.
|
|
9
|
-
/**
|
|
10
|
-
* Both call sites read `await res.json().catch(() => null)`. A 200 carrying
|
|
11
|
-
* HTML — captive portal, auth redirect, proxy error page — rejects in json()
|
|
12
|
-
* before any shape check could run, so the null has to come from there
|
|
13
|
-
* rather than from the normalizer. This mirrors that call.
|
|
14
|
-
*/
|
|
15
|
-
const parsedBody = async (raw, contentType = "application/json") => {
|
|
16
|
-
const res = new Response(raw, {
|
|
17
|
-
status: 200,
|
|
18
|
-
headers: { "content-type": contentType },
|
|
19
|
-
});
|
|
20
|
-
return res.json().catch(() => null);
|
|
21
|
-
};
|
|
22
|
-
describe("a 200 response whose body is not JSON", () => {
|
|
23
|
-
it("degrades to 'nothing detected' for migration sources", async () => {
|
|
24
|
-
const body = await parsedBody("<html>login</html>", "text/html");
|
|
25
|
-
// The user sees "No InfluxDB found" rather than
|
|
26
|
-
// "Detection failed: Unexpected token '<'".
|
|
27
|
-
assert.deepEqual(toMigrationSources(body), []);
|
|
28
|
-
});
|
|
29
|
-
it("handles an empty body the same way", async () => {
|
|
30
|
-
const body = await parsedBody("");
|
|
31
|
-
assert.deepEqual(toMigrationSources(body), []);
|
|
32
|
-
});
|
|
33
|
-
});
|
|
34
|
-
describe("toMigrationSources", () => {
|
|
35
|
-
it("unwraps the sources array", () => {
|
|
36
|
-
const sources = [
|
|
37
|
-
{ type: "influxdb2", url: "http://localhost:8086", status: "reachable" },
|
|
38
|
-
];
|
|
39
|
-
assert.deepEqual(toMigrationSources({ sources }), sources);
|
|
40
|
-
});
|
|
41
|
-
it("preserves an empty result, which means 'nothing detected'", () => {
|
|
42
|
-
assert.deepEqual(toMigrationSources({ sources: [] }), []);
|
|
43
|
-
});
|
|
44
|
-
for (const [label, body] of [
|
|
45
|
-
["a body with no sources key", {}],
|
|
46
|
-
["an error envelope", { error: "Invalid URL" }],
|
|
47
|
-
["sources of the wrong type", { sources: "none" }],
|
|
48
|
-
["null", null],
|
|
49
|
-
["undefined", undefined],
|
|
50
|
-
["a bare array", []],
|
|
51
|
-
]) {
|
|
52
|
-
it(`yields an empty list for ${label}`, () => {
|
|
53
|
-
const result = toMigrationSources(body);
|
|
54
|
-
assert.ok(Array.isArray(result), "must always return an array");
|
|
55
|
-
assert.equal(result.length, 0);
|
|
56
|
-
// Without this the panel reported "Detection failed: Cannot read
|
|
57
|
-
// properties of undefined" instead of "No InfluxDB found", and put
|
|
58
|
-
// `undefined` into state the type declares as an array.
|
|
59
|
-
assert.doesNotThrow(() => result.length === 0);
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
it("drops malformed members but keeps the valid ones", () => {
|
|
63
|
-
// Members are rendered field-by-field (src.type, src.url, src.status),
|
|
64
|
-
// so a null entry would throw while drawing the detected-sources list.
|
|
65
|
-
const body = {
|
|
66
|
-
sources: [
|
|
67
|
-
{ type: "influxdb2", url: "http://localhost:8086", status: "ok" },
|
|
68
|
-
null,
|
|
69
|
-
{ type: "influxdb1" },
|
|
70
|
-
{ type: "influxdb1", url: "http://boat:8086", status: "ok" },
|
|
71
|
-
],
|
|
72
|
-
};
|
|
73
|
-
const result = toMigrationSources(body);
|
|
74
|
-
assert.deepEqual(result.map((s) => s.url), ["http://localhost:8086", "http://boat:8086"]);
|
|
75
|
-
assert.doesNotThrow(() => result.map((s) => s.type === "influxdb2"));
|
|
76
|
-
});
|
|
77
|
-
it("drops sources whose rendered fields are not strings", () => {
|
|
78
|
-
// status and version are rendered as React children; a plain object
|
|
79
|
-
// there throws "Objects are not valid as a React child" and unmounts
|
|
80
|
-
// the panel, the same blank screen an unguarded array causes.
|
|
81
|
-
const result = toMigrationSources({
|
|
82
|
-
sources: [
|
|
83
|
-
{
|
|
84
|
-
type: "influxdb2",
|
|
85
|
-
url: "http://ok:8086",
|
|
86
|
-
status: "ok",
|
|
87
|
-
version: "2.7",
|
|
88
|
-
},
|
|
89
|
-
{ type: "influxdb2", url: "http://a:8086", status: { code: 200 } },
|
|
90
|
-
{ type: "influxdb1", url: "http://b:8086" },
|
|
91
|
-
{
|
|
92
|
-
type: "influxdb1",
|
|
93
|
-
url: "http://c:8086",
|
|
94
|
-
status: "ok",
|
|
95
|
-
version: { major: 1 },
|
|
96
|
-
},
|
|
97
|
-
// version is genuinely optional in the contract
|
|
98
|
-
{ type: "influxdb1", url: "http://d:8086", status: "unreachable" },
|
|
99
|
-
],
|
|
100
|
-
});
|
|
101
|
-
assert.deepEqual(result.map((s) => s.url), ["http://ok:8086", "http://d:8086"]);
|
|
102
|
-
for (const s of result) {
|
|
103
|
-
assert.equal(typeof s.status, "string");
|
|
104
|
-
assert.ok(s.version === undefined || typeof s.version === "string");
|
|
105
|
-
}
|
|
106
|
-
});
|
|
107
|
-
});
|
|
108
|
-
//# sourceMappingURL=configpanel-responses.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"configpanel-responses.test.js","sourceRoot":"","sources":["../../src/test/configpanel-responses.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,MAAM,MAAM,oBAAoB,CAAC;AACxC,OAAO,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AAEjE,yEAAyE;AACzE,qEAAqE;AACrE,4EAA4E;AAC5E,0EAA0E;AAC1E,uEAAuE;AAEvE;;;;;GAKG;AACH,MAAM,UAAU,GAAG,KAAK,EAAE,GAAW,EAAE,WAAW,GAAG,kBAAkB,EAAE,EAAE;IACzE,MAAM,GAAG,GAAG,IAAI,QAAQ,CAAC,GAAG,EAAE;QAC5B,MAAM,EAAE,GAAG;QACX,OAAO,EAAE,EAAE,cAAc,EAAE,WAAW,EAAE;KACzC,CAAC,CAAC;IACH,OAAO,GAAG,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC;AACtC,CAAC,CAAC;AAEF,QAAQ,CAAC,uCAAuC,EAAE,GAAG,EAAE;IACrD,EAAE,CAAC,sDAAsD,EAAE,KAAK,IAAI,EAAE;QACpE,MAAM,IAAI,GAAG,MAAM,UAAU,CAAC,oBAAoB,EAAE,WAAW,CAAC,CAAC;QACjE,gDAAgD;QAChD,4CAA4C;QAC5C,MAAM,CAAC,SAAS,CAAC,kBAAkB,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC;IACjD,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,oCAAoC,EAAE,KAAK,IAAI,EAAE;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