@apocaliss92/nodelink-js 0.3.5 → 0.3.9

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.
@@ -1,4 +1,5 @@
1
1
  import {
2
+ captureModelFixtures,
2
3
  collectCgiDiagnostics,
3
4
  collectMultifocalDiagnostics,
4
5
  collectNativeDiagnostics,
@@ -9,8 +10,9 @@ import {
9
10
  runMultifocalDiagnosticsConsecutively,
10
11
  sampleStreams,
11
12
  testChannelStreams
12
- } from "./chunk-APEEZ4UN.js";
13
+ } from "./chunk-6Q6MK4WG.js";
13
14
  export {
15
+ captureModelFixtures,
14
16
  collectCgiDiagnostics,
15
17
  collectMultifocalDiagnostics,
16
18
  collectNativeDiagnostics,
@@ -22,4 +24,4 @@ export {
22
24
  sampleStreams,
23
25
  testChannelStreams
24
26
  };
25
- //# sourceMappingURL=DiagnosticsTools-2JQRV5FE.js.map
27
+ //# sourceMappingURL=DiagnosticsTools-DQDDBRM6.js.map
@@ -4903,6 +4903,10 @@ function writeJson(filePath, obj) {
4903
4903
  mkdirp(path4.dirname(filePath));
4904
4904
  fs4.writeFileSync(filePath, JSON.stringify(obj, null, 2));
4905
4905
  }
4906
+ function writeText(filePath, text) {
4907
+ mkdirp(path4.dirname(filePath));
4908
+ fs4.writeFileSync(filePath, text);
4909
+ }
4906
4910
  function appendNdjson(filePath, obj) {
4907
4911
  mkdirp(path4.dirname(filePath));
4908
4912
  fs4.appendFileSync(filePath, JSON.stringify(obj) + "\n");
@@ -7166,6 +7170,172 @@ async function runAllDiagnosticsConsecutively(params) {
7166
7170
  streamsDir
7167
7171
  };
7168
7172
  }
7173
+ async function captureModelFixtures(params) {
7174
+ const { api, channel, outDir } = params;
7175
+ const log = params.log ?? console.log;
7176
+ mkdirp(outDir);
7177
+ const calls = {};
7178
+ const errors = [];
7179
+ async function capture(name, fn, writer) {
7180
+ try {
7181
+ const value = await fn();
7182
+ calls[name] = { ok: true, value };
7183
+ if (writer && value !== void 0 && value !== null) {
7184
+ writer(value);
7185
+ }
7186
+ log(` \u2713 ${name}`);
7187
+ return value;
7188
+ } catch (e) {
7189
+ const msg = e instanceof Error ? e.message : String(e);
7190
+ calls[name] = { ok: false, error: msg };
7191
+ errors.push(`${name}: ${msg}`);
7192
+ log(` \u2717 ${name}: ${msg}`);
7193
+ return void 0;
7194
+ }
7195
+ }
7196
+ const info = await capture(
7197
+ "getInfo",
7198
+ () => api.getInfo(channel),
7199
+ (v) => writeJson(path4.join(outDir, "device-info.json"), v)
7200
+ );
7201
+ const support = await capture(
7202
+ "getSupportInfo",
7203
+ () => api.getSupportInfo(),
7204
+ (v) => writeJson(path4.join(outDir, "support-info.json"), v)
7205
+ );
7206
+ const abilities = await capture(
7207
+ "getAbilityInfo",
7208
+ () => api.getAbilityInfo(),
7209
+ (v) => writeJson(path4.join(outDir, "ability-info.json"), v)
7210
+ );
7211
+ await capture(
7212
+ "getDeviceCapabilities",
7213
+ () => api.getDeviceCapabilities(channel),
7214
+ (v) => writeJson(path4.join(outDir, "capabilities.json"), v)
7215
+ );
7216
+ await capture("cmd289-WhiteLed", () => api.sendXml({
7217
+ cmdId: BC_CMD_ID_GET_WHITE_LED,
7218
+ channel,
7219
+ timeoutMs: 3e3
7220
+ }), (v) => writeText(path4.join(outDir, "cmd289-white-led.xml"), v));
7221
+ await capture(
7222
+ "getStreamMetadata",
7223
+ () => api.getStreamMetadata(channel),
7224
+ (v) => writeJson(path4.join(outDir, "stream-metadata.json"), v)
7225
+ );
7226
+ await capture(
7227
+ "getEncXml",
7228
+ () => api.getEncXml(channel),
7229
+ (v) => writeText(path4.join(outDir, "enc-config.xml"), v)
7230
+ );
7231
+ await capture(
7232
+ "getPorts",
7233
+ () => api.getPorts(),
7234
+ (v) => writeJson(path4.join(outDir, "ports.json"), v)
7235
+ );
7236
+ await capture(
7237
+ "getTalkAbility",
7238
+ () => api.getTalkAbility(channel),
7239
+ (v) => writeJson(path4.join(outDir, "talk-ability.json"), v)
7240
+ );
7241
+ await capture(
7242
+ "getTwoWayAudioConfig",
7243
+ () => api.getTwoWayAudioConfig(channel),
7244
+ (v) => writeJson(path4.join(outDir, "two-way-audio-config.json"), v)
7245
+ );
7246
+ await capture(
7247
+ "getAiState",
7248
+ () => api.getAiState(channel),
7249
+ (v) => writeJson(path4.join(outDir, "ai-state.json"), v)
7250
+ );
7251
+ await capture(
7252
+ "getAiCfg",
7253
+ () => api.getAiCfg(channel),
7254
+ (v) => writeJson(path4.join(outDir, "ai-cfg.json"), v)
7255
+ );
7256
+ await capture(
7257
+ "getOsd",
7258
+ () => api.getOsd(channel),
7259
+ (v) => writeJson(path4.join(outDir, "osd.json"), v)
7260
+ );
7261
+ await capture(
7262
+ "getMotionAlarm",
7263
+ () => api.getMotionAlarm(channel),
7264
+ (v) => writeJson(path4.join(outDir, "motion-alarm.json"), v)
7265
+ );
7266
+ await capture(
7267
+ "getRecordCfg",
7268
+ () => api.getRecordCfg(channel),
7269
+ (v) => writeJson(path4.join(outDir, "record-cfg.json"), v)
7270
+ );
7271
+ await capture(
7272
+ "getVideoInput",
7273
+ () => api.getVideoInput(channel),
7274
+ (v) => writeJson(path4.join(outDir, "video-input.json"), v)
7275
+ );
7276
+ await capture(
7277
+ "getPtzPresets",
7278
+ () => api.getPtzPresets(channel),
7279
+ (v) => writeJson(path4.join(outDir, "ptz-presets.json"), v)
7280
+ );
7281
+ await capture(
7282
+ "getNetworkInfo",
7283
+ () => api.getNetworkInfo(),
7284
+ (v) => writeJson(path4.join(outDir, "network-info.json"), v)
7285
+ );
7286
+ await capture(
7287
+ "getSystemGeneral",
7288
+ () => api.getSystemGeneral(),
7289
+ (v) => writeJson(path4.join(outDir, "system-general.json"), v)
7290
+ );
7291
+ await capture(
7292
+ "getWifiSignal",
7293
+ () => api.getWifiSignal(channel),
7294
+ (v) => writeJson(path4.join(outDir, "wifi-signal.json"), v)
7295
+ );
7296
+ await capture(
7297
+ "getWhiteLedState",
7298
+ () => api.getWhiteLedState(channel),
7299
+ (v) => writeJson(path4.join(outDir, "white-led-state.json"), v)
7300
+ );
7301
+ await capture(
7302
+ "getFloodlightOnMotion",
7303
+ () => api.getFloodlightOnMotion(channel),
7304
+ (v) => writeJson(path4.join(outDir, "floodlight-on-motion.json"), v)
7305
+ );
7306
+ await capture(
7307
+ "buildVideoStreamOptions",
7308
+ () => api.buildVideoStreamOptions({ channel }),
7309
+ (v) => writeJson(path4.join(outDir, "video-stream-options.json"), v)
7310
+ );
7311
+ const total = Object.keys(calls).length;
7312
+ const ok = Object.values(calls).filter((c) => c.ok).length;
7313
+ const failed = total - ok;
7314
+ const summary = { total, ok, failed, errors };
7315
+ writeJson(path4.join(outDir, "_summary.json"), {
7316
+ collectedAt: (/* @__PURE__ */ new Date()).toISOString(),
7317
+ model: info?.type ?? "unknown",
7318
+ itemNo: info?.itemNo ?? "unknown",
7319
+ firmwareVersion: info?.firmwareVersion ?? "unknown",
7320
+ channel,
7321
+ ...summary,
7322
+ calls: Object.fromEntries(
7323
+ Object.entries(calls).map(([k, v]) => [
7324
+ k,
7325
+ v.ok ? "ok" : `FAILED: ${v.error}`
7326
+ ])
7327
+ )
7328
+ });
7329
+ log(`
7330
+ Summary: ${ok}/${total} ok, ${failed} failed`);
7331
+ if (errors.length) {
7332
+ log(` Errors:`);
7333
+ for (const err of errors) {
7334
+ log(` - ${err}`);
7335
+ }
7336
+ }
7337
+ return { calls, outDir, summary };
7338
+ }
7169
7339
 
7170
7340
  export {
7171
7341
  __require,
@@ -7348,7 +7518,8 @@ export {
7348
7518
  collectMultifocalDiagnostics,
7349
7519
  runMultifocalDiagnosticsConsecutively,
7350
7520
  runAllDiagnosticsConsecutively,
7521
+ captureModelFixtures,
7351
7522
  parseRecordingFileName,
7352
7523
  ReolinkCgiApi
7353
7524
  };
7354
- //# sourceMappingURL=chunk-APEEZ4UN.js.map
7525
+ //# sourceMappingURL=chunk-6Q6MK4WG.js.map