aranea-sdk-cli 0.3.15 → 0.3.16

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.
@@ -433,4 +433,90 @@ exports.mqttCommand
433
433
  process.exit(1);
434
434
  }
435
435
  });
436
+ // mqtt test - 認証不要のMQTTテスト送信
437
+ exports.mqttCommand
438
+ .command('test')
439
+ .description('認証不要のMQTTテスト送信(araneaMqttTest経由)')
440
+ .requiredOption('-l, --lacis-id <lacisId>', 'デバイスLacisID')
441
+ .option('--tid <tid>', 'テナントID', config_1.TEST_TENANT.tid)
442
+ .option('-t, --type <type>', 'コマンドタイプ (is04a: relay, pwm等)', 'relay')
443
+ .option('-a, --action <action>', 'アクション (is02a: scan等)')
444
+ .option('-p, --params <json>', 'パラメータ (JSON文字列)', '{}')
445
+ .option('--ttl <seconds>', 'TTL秒数', '30')
446
+ .option('-e, --endpoint <env>', '環境 (production/staging)', 'production')
447
+ .option('-d, --dry-run', 'リクエスト内容を表示のみ')
448
+ .action(async (options) => {
449
+ try {
450
+ console.log(chalk_1.default.bold('\n=== MQTT Test (No Auth) ===\n'));
451
+ // パラメータ解析
452
+ let params;
453
+ try {
454
+ params = JSON.parse(options.params);
455
+ }
456
+ catch (e) {
457
+ console.error(chalk_1.default.red('❌ --params のJSON解析に失敗しました'));
458
+ process.exit(1);
459
+ }
460
+ // リクエストボディ構築
461
+ const body = {
462
+ tid: options.tid,
463
+ lacisId: options.lacisId,
464
+ ttlSec: parseInt(options.ttl, 10),
465
+ };
466
+ if (options.action) {
467
+ // actionベース (is02a)
468
+ body.action = options.action;
469
+ body.params = params;
470
+ console.log(chalk_1.default.cyan('モード: actionベース (is02a)'));
471
+ }
472
+ else {
473
+ // typeベース (is04a)
474
+ body.type = options.type;
475
+ body.parameters = params;
476
+ console.log(chalk_1.default.cyan('モード: typeベース (is04a)'));
477
+ }
478
+ console.log(chalk_1.default.cyan('ターゲット:'));
479
+ console.log(` TID: ${body.tid}`);
480
+ console.log(` LacisID: ${options.lacisId}`);
481
+ console.log(` ${options.action ? 'Action' : 'Type'}: ${options.action || options.type}`);
482
+ console.log(` Parameters: ${JSON.stringify(params)}`);
483
+ console.log(` TTL: ${body.ttlSec}秒`);
484
+ console.log('');
485
+ if (options.dryRun) {
486
+ console.log(chalk_1.default.yellow('(dry-run モード: 実際には送信されません)'));
487
+ console.log(chalk_1.default.cyan('\nリクエストボディ:'));
488
+ console.log(JSON.stringify(body, null, 2));
489
+ return;
490
+ }
491
+ // araneaMqttTest エンドポイント呼び出し
492
+ const endpoint = (0, config_1.getEndpoint)(options.endpoint);
493
+ const url = endpoint.mqttTest;
494
+ const spinner = (0, ora_1.default)('MQTTテスト送信中...').start();
495
+ const response = await (0, node_fetch_1.default)(url, {
496
+ method: 'POST',
497
+ headers: {
498
+ 'Content-Type': 'application/json',
499
+ },
500
+ body: JSON.stringify(body),
501
+ });
502
+ const result = (await response.json());
503
+ spinner.stop();
504
+ console.log(chalk_1.default.cyan('レスポンス:'));
505
+ console.log(JSON.stringify(result, null, 2));
506
+ console.log('');
507
+ if (result.ok) {
508
+ console.log(chalk_1.default.green(`✓ MQTTテスト送信成功: ${result.cmdId}`));
509
+ console.log(chalk_1.default.gray(` Topic: ${result.topic}`));
510
+ }
511
+ else {
512
+ console.log(chalk_1.default.red(`✗ MQTTテスト送信失敗: ${result.error}`));
513
+ process.exit(1);
514
+ }
515
+ console.log('');
516
+ }
517
+ catch (error) {
518
+ console.error(chalk_1.default.red(`エラー: ${error.message}`));
519
+ process.exit(1);
520
+ }
521
+ });
436
522
  exports.default = exports.mqttCommand;
package/dist/config.d.ts CHANGED
@@ -12,6 +12,7 @@ export interface Endpoint {
12
12
  state: string;
13
13
  command: string;
14
14
  mqtt?: string;
15
+ mqttTest: string;
15
16
  schemaAPI: string;
16
17
  knowledgeAPI: string;
17
18
  metatronAPI: string;
package/dist/config.js CHANGED
@@ -22,6 +22,7 @@ exports.ENDPOINTS = {
22
22
  state: 'https://asia-northeast1-mobesorder.cloudfunctions.net/deviceStateReport',
23
23
  command: 'https://asia-northeast1-mobesorder.cloudfunctions.net/araneaDeviceCommand',
24
24
  mqtt: 'wss://aranea-mqtt-bridge-1010551946141.asia-northeast1.run.app',
25
+ mqttTest: 'https://asia-northeast1-mobesorder.cloudfunctions.net/araneaMqttTest',
25
26
  schemaAPI: 'https://asia-northeast1-mobesorder.cloudfunctions.net/araneaSchemaAPI',
26
27
  knowledgeAPI: 'https://asia-northeast1-mobesorder.cloudfunctions.net/araneaSDK_knowledgeManagement',
27
28
  metatronAPI: 'https://asia-northeast1-mobesorder.cloudfunctions.net/araneaSDK_metatronQuery',
@@ -32,6 +33,7 @@ exports.ENDPOINTS = {
32
33
  state: 'https://asia-northeast1-mobesorder-staging.cloudfunctions.net/deviceStateReport',
33
34
  command: 'https://asia-northeast1-mobesorder-staging.cloudfunctions.net/araneaDeviceCommand',
34
35
  mqtt: 'wss://aranea-mqtt-bridge-staging.asia-northeast1.run.app',
36
+ mqttTest: 'https://asia-northeast1-mobesorder-staging.cloudfunctions.net/araneaMqttTest',
35
37
  schemaAPI: 'https://asia-northeast1-mobesorder-staging.cloudfunctions.net/araneaSchemaAPI',
36
38
  knowledgeAPI: 'https://asia-northeast1-mobesorder-staging.cloudfunctions.net/araneaSDK_knowledgeManagement',
37
39
  metatronAPI: 'https://asia-northeast1-mobesorder-staging.cloudfunctions.net/araneaSDK_metatronQuery',
package/dist/index.js CHANGED
@@ -29,7 +29,7 @@ const program = new commander_1.Command();
29
29
  program
30
30
  .name('aranea-sdk')
31
31
  .description('AraneaSDK CLI - デバイス開発支援ツール')
32
- .version('0.3.15');
32
+ .version('0.3.16');
33
33
  // test コマンド
34
34
  program.addCommand(test_1.testCommand);
35
35
  // simulate コマンド
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aranea-sdk-cli",
3
- "version": "0.3.15",
3
+ "version": "0.3.16",
4
4
  "description": "AraneaSDK CLI - ESP32 IoTデバイス開発支援ツール",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",