aranea-sdk-cli 0.3.17 → 0.5.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.
@@ -4,6 +4,13 @@
4
4
  * Usage:
5
5
  * aranea-sdk validate type --type "aranea_ar-is04a"
6
6
  * aranea-sdk validate lacis-id --lacis-id "3004AABBCCDDEEFF0001"
7
+ * aranea-sdk validate product-code --code "1201"
8
+ *
9
+ * ProductCode 4進数ルール:
10
+ * 標準製品: 0, 1, 2, 3 のみで構成 (ASCII→4進数変換)
11
+ * 固有プロジェクト: 4-9 を含む (カスタムプロジェクト用)
12
+ *
13
+ * @see doc/APPS/araneaSDK/Design/11_ProductCode_Quaternary_Rule.md
7
14
  */
8
15
  import { Command } from 'commander';
9
16
  export declare const validateCommand: Command;
@@ -5,6 +5,13 @@
5
5
  * Usage:
6
6
  * aranea-sdk validate type --type "aranea_ar-is04a"
7
7
  * aranea-sdk validate lacis-id --lacis-id "3004AABBCCDDEEFF0001"
8
+ * aranea-sdk validate product-code --code "1201"
9
+ *
10
+ * ProductCode 4進数ルール:
11
+ * 標準製品: 0, 1, 2, 3 のみで構成 (ASCII→4進数変換)
12
+ * 固有プロジェクト: 4-9 を含む (カスタムプロジェクト用)
13
+ *
14
+ * @see doc/APPS/araneaSDK/Design/11_ProductCode_Quaternary_Rule.md
8
15
  */
9
16
  var __importDefault = (this && this.__importDefault) || function (mod) {
10
17
  return (mod && mod.__esModule) ? mod : { "default": mod };
@@ -13,6 +20,55 @@ Object.defineProperty(exports, "__esModule", { value: true });
13
20
  exports.validateCommand = void 0;
14
21
  const commander_1 = require("commander");
15
22
  const chalk_1 = __importDefault(require("chalk"));
23
+ // ============================================================
24
+ // ProductCode 4進数ユーティリティ
25
+ // ============================================================
26
+ /**
27
+ * ASCII文字を4進数 (quaternary) に変換
28
+ * @param char 単一の文字
29
+ * @returns 4桁の4進数文字列
30
+ */
31
+ function asciiToQuaternary(char) {
32
+ const ascii = char.charCodeAt(0);
33
+ let result = '';
34
+ let num = ascii;
35
+ for (let i = 0; i < 4; i++) {
36
+ result = (num % 4) + result;
37
+ num = Math.floor(num / 4);
38
+ }
39
+ return result.padStart(4, '0');
40
+ }
41
+ /**
42
+ * 4進数を元のASCII文字に逆変換
43
+ * @param quaternary 4桁の4進数文字列
44
+ * @returns 元の文字 (変換不可能な場合はnull)
45
+ */
46
+ function quaternaryToAscii(quaternary) {
47
+ if (!/^[0-3]{4}$/.test(quaternary)) {
48
+ return null;
49
+ }
50
+ let ascii = 0;
51
+ for (let i = 0; i < 4; i++) {
52
+ ascii = ascii * 4 + parseInt(quaternary[i], 10);
53
+ }
54
+ // ASCII printable range check (32-126)
55
+ if (ascii >= 32 && ascii <= 126) {
56
+ return String.fromCharCode(ascii);
57
+ }
58
+ return null;
59
+ }
60
+ /**
61
+ * ProductCodeが4進数のみで構成されているか (標準製品)
62
+ */
63
+ function isQuaternaryProductCode(productCode) {
64
+ return /^[0-3]{4}$/.test(productCode);
65
+ }
66
+ /**
67
+ * ProductCodeが固有プロジェクト用か (4-9を含む)
68
+ */
69
+ function isProprietaryProductCode(productCode) {
70
+ return /^\d{4}$/.test(productCode) && /[4-9]/.test(productCode);
71
+ }
16
72
  exports.validateCommand = new commander_1.Command('validate')
17
73
  .description('入力値のバリデーション');
18
74
  // validate type
@@ -112,6 +168,24 @@ exports.validateCommand
112
168
  console.log(` ProductType: ${productType}`);
113
169
  console.log(` MAC: ${mac}`);
114
170
  console.log(` ProductCode: ${productCode}`);
171
+ // ProductCode 4進数チェック
172
+ console.log('');
173
+ console.log(chalk_1.default.bold('ProductCode 分析:'));
174
+ if (isQuaternaryProductCode(productCode)) {
175
+ const originalChar = quaternaryToAscii(productCode);
176
+ console.log(chalk_1.default.green(` ✓ 標準製品 (4進数: 0-3のみ)`));
177
+ if (originalChar) {
178
+ console.log(` 元の枝番: '${originalChar}' (ASCII ${originalChar.charCodeAt(0)})`);
179
+ }
180
+ }
181
+ else if (isProprietaryProductCode(productCode)) {
182
+ console.log(chalk_1.default.yellow(` ⚠ 固有プロジェクト (4-9を含む)`));
183
+ console.log(chalk_1.default.yellow(` このデバイスは固有プロジェクトとして登録されます`));
184
+ console.log(chalk_1.default.cyan(` Admin UI の「プロジェクト」セクションで管理してください`));
185
+ }
186
+ else {
187
+ console.log(chalk_1.default.red(` ✗ 無効なProductCode形式`));
188
+ }
115
189
  }
116
190
  }
117
191
  else {
@@ -165,3 +239,131 @@ exports.validateCommand
165
239
  }
166
240
  console.log('');
167
241
  });
242
+ // validate product-code
243
+ exports.validateCommand
244
+ .command('product-code')
245
+ .description('ProductCodeの4進数ルールを検証')
246
+ .requiredOption('-c, --code <code>', '検証するProductCode (4桁)')
247
+ .option('-v, --variant <char>', '枝番から4進数を生成 (例: a, b, A)')
248
+ .action((options) => {
249
+ console.log(chalk_1.default.bold('\n=== ProductCode バリデーション ===\n'));
250
+ // 枝番から生成モード
251
+ if (options.variant) {
252
+ const variant = options.variant;
253
+ console.log(`枝番: '${variant}'`);
254
+ console.log('');
255
+ if (variant.length !== 1) {
256
+ console.log(chalk_1.default.red('✗ 枝番は1文字である必要があります'));
257
+ console.log('');
258
+ return;
259
+ }
260
+ const quaternary = asciiToQuaternary(variant);
261
+ const ascii = variant.charCodeAt(0);
262
+ console.log(chalk_1.default.green('✓ 4進数変換結果:'));
263
+ console.log(` 文字: '${variant}'`);
264
+ console.log(` ASCII: ${ascii}`);
265
+ console.log(` ProductCode: ${quaternary}`);
266
+ console.log('');
267
+ // よく使う枝番の一覧
268
+ console.log(chalk_1.default.bold('よく使う枝番の変換表:'));
269
+ const commonVariants = ['a', 'b', 'c', 'd', 'A', 'B', '0', '1'];
270
+ commonVariants.forEach((v) => {
271
+ const q = asciiToQuaternary(v);
272
+ const marker = v === variant ? chalk_1.default.cyan(' ← 選択中') : '';
273
+ console.log(` '${v}' (ASCII ${v.charCodeAt(0).toString().padStart(3)}) → ${q}${marker}`);
274
+ });
275
+ console.log('');
276
+ return;
277
+ }
278
+ // ProductCode検証モード
279
+ const code = options.code;
280
+ console.log(`入力: ${code}`);
281
+ console.log('');
282
+ // 形式チェック
283
+ if (!/^\d{4}$/.test(code)) {
284
+ console.log(chalk_1.default.red('✗ ProductCodeは4桁の数字である必要があります'));
285
+ console.log('');
286
+ return;
287
+ }
288
+ // 4進数チェック
289
+ if (isQuaternaryProductCode(code)) {
290
+ const originalChar = quaternaryToAscii(code);
291
+ console.log(chalk_1.default.green('✓ 標準製品 ProductCode'));
292
+ console.log(` 種別: 4進数 (0, 1, 2, 3 のみ)`);
293
+ console.log('');
294
+ if (originalChar) {
295
+ console.log(chalk_1.default.bold('逆変換結果:'));
296
+ console.log(` ProductCode ${code} → 枝番 '${originalChar}' (ASCII ${originalChar.charCodeAt(0)})`);
297
+ }
298
+ else {
299
+ console.log(chalk_1.default.dim(' (ASCII印字可能範囲外のため枝番を特定できません)'));
300
+ }
301
+ }
302
+ else if (isProprietaryProductCode(code)) {
303
+ console.log(chalk_1.default.yellow('⚠ 固有プロジェクト ProductCode'));
304
+ console.log(` 種別: 非4進数 (4-9 を含む)`);
305
+ console.log('');
306
+ console.log(chalk_1.default.bold('固有プロジェクトの登録:'));
307
+ console.log(' 1. Admin UI の AraneaSDK → プロジェクト セクションを開く');
308
+ console.log(' 2. 新規プロジェクトを作成');
309
+ console.log(' 3. このProductCode を使用するデバイスタイプを紐付け');
310
+ console.log('');
311
+ console.log(chalk_1.default.cyan('ヒント: 標準製品にする場合は 0-3 のみで構成してください'));
312
+ console.log(chalk_1.default.cyan(' 例: 枝番 "a" の場合は --variant a で確認できます'));
313
+ }
314
+ else {
315
+ console.log(chalk_1.default.red('✗ 無効なProductCode'));
316
+ }
317
+ console.log('');
318
+ });
319
+ // validate convert (4進数変換ツール)
320
+ exports.validateCommand
321
+ .command('convert')
322
+ .description('枝番とProductCodeの相互変換')
323
+ .option('-t, --to-quaternary <char>', '枝番を4進数ProductCodeに変換')
324
+ .option('-f, --from-quaternary <code>', '4進数ProductCodeを枝番に逆変換')
325
+ .action((options) => {
326
+ console.log(chalk_1.default.bold('\n=== 4進数変換ツール ===\n'));
327
+ if (options.toQuaternary) {
328
+ const char = options.toQuaternary;
329
+ if (char.length !== 1) {
330
+ console.log(chalk_1.default.red('✗ 1文字を指定してください'));
331
+ return;
332
+ }
333
+ const quaternary = asciiToQuaternary(char);
334
+ console.log(`'${char}' (ASCII ${char.charCodeAt(0)}) → ProductCode: ${quaternary}`);
335
+ }
336
+ else if (options.fromQuaternary) {
337
+ const code = options.fromQuaternary;
338
+ if (!/^[0-3]{4}$/.test(code)) {
339
+ console.log(chalk_1.default.red('✗ 4桁の4進数 (0-3のみ) を指定してください'));
340
+ return;
341
+ }
342
+ const char = quaternaryToAscii(code);
343
+ if (char) {
344
+ console.log(`ProductCode: ${code} → '${char}' (ASCII ${char.charCodeAt(0)})`);
345
+ }
346
+ else {
347
+ console.log(chalk_1.default.yellow(`ProductCode: ${code} → (印字不可能文字)`));
348
+ }
349
+ }
350
+ else {
351
+ // 変換表を表示
352
+ console.log('使い方:');
353
+ console.log(' aranea-cli validate convert --to-quaternary a');
354
+ console.log(' aranea-cli validate convert --from-quaternary 1201');
355
+ console.log('');
356
+ console.log(chalk_1.default.bold('よく使う枝番の変換表:'));
357
+ const variants = [
358
+ 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h',
359
+ 'A', 'B', 'C', 'D',
360
+ '0', '1', '2', '3', '4', '5'
361
+ ];
362
+ variants.forEach((v) => {
363
+ const q = asciiToQuaternary(v);
364
+ const type = isQuaternaryProductCode(q) ? chalk_1.default.green('標準') : chalk_1.default.yellow('固有');
365
+ console.log(` '${v}' (ASCII ${v.charCodeAt(0).toString().padStart(3)}) → ${q} [${type}]`);
366
+ });
367
+ }
368
+ console.log('');
369
+ });
package/dist/config.d.ts CHANGED
@@ -16,6 +16,8 @@ export interface Endpoint {
16
16
  schemaAPI: string;
17
17
  knowledgeAPI: string;
18
18
  metatronAPI: string;
19
+ backlogAPI: string;
20
+ registryAPI: string;
19
21
  webhookBase: string;
20
22
  }
21
23
  export declare const ENDPOINTS: Record<Environment, Endpoint>;
package/dist/config.js CHANGED
@@ -26,6 +26,8 @@ exports.ENDPOINTS = {
26
26
  schemaAPI: 'https://asia-northeast1-mobesorder.cloudfunctions.net/araneaSchemaAPI',
27
27
  knowledgeAPI: 'https://asia-northeast1-mobesorder.cloudfunctions.net/araneaSDK_knowledgeManagement',
28
28
  metatronAPI: 'https://asia-northeast1-mobesorder.cloudfunctions.net/araneaSDK_metatronQuery',
29
+ backlogAPI: 'https://asia-northeast1-mobesorder.cloudfunctions.net/araneaBacklogAPI',
30
+ registryAPI: 'https://asia-northeast1-mobesorder.cloudfunctions.net/araneaRegistryAPI',
29
31
  webhookBase: 'https://us-central1-mobesorder.cloudfunctions.net',
30
32
  },
31
33
  staging: {
@@ -37,6 +39,8 @@ exports.ENDPOINTS = {
37
39
  schemaAPI: 'https://asia-northeast1-mobesorder-staging.cloudfunctions.net/araneaSchemaAPI',
38
40
  knowledgeAPI: 'https://asia-northeast1-mobesorder-staging.cloudfunctions.net/araneaSDK_knowledgeManagement',
39
41
  metatronAPI: 'https://asia-northeast1-mobesorder-staging.cloudfunctions.net/araneaSDK_metatronQuery',
42
+ backlogAPI: 'https://asia-northeast1-mobesorder-staging.cloudfunctions.net/araneaBacklogAPI',
43
+ registryAPI: 'https://asia-northeast1-mobesorder-staging.cloudfunctions.net/araneaRegistryAPI',
40
44
  webhookBase: 'https://us-central1-mobesorder-staging.cloudfunctions.net',
41
45
  },
42
46
  };
package/dist/index.js CHANGED
@@ -25,11 +25,14 @@ const device_1 = require("./commands/device");
25
25
  const knowledge_1 = require("./commands/knowledge");
26
26
  const metatron_1 = require("./commands/metatron");
27
27
  const auth_1 = require("./commands/auth");
28
+ const backlog_1 = require("./commands/backlog");
29
+ const registry_1 = require("./commands/registry");
30
+ const control_1 = require("./commands/control");
28
31
  const program = new commander_1.Command();
29
32
  program
30
33
  .name('aranea-sdk')
31
34
  .description('AraneaSDK CLI - デバイス開発支援ツール')
32
- .version('0.3.17');
35
+ .version('0.4.1');
33
36
  // test コマンド
34
37
  program.addCommand(test_1.testCommand);
35
38
  // simulate コマンド
@@ -50,4 +53,11 @@ program.addCommand(knowledge_1.knowledgeCommand);
50
53
  program.addCommand(metatron_1.metatronCommand);
51
54
  // auth コマンド (v0.3.1)
52
55
  program.addCommand(auth_1.authCommand);
56
+ // backlog コマンド (v0.4.0)
57
+ program.addCommand(backlog_1.backlogCommand);
58
+ // registry コマンド (v0.4.0)
59
+ program.addCommand(registry_1.registryCommand);
60
+ // control コマンド (v0.4.1) - Control型管理(安全機構付き)
61
+ // @see doc/APPS/araneaSDK/headDesign/59_METATRON_CONTROL_SUGGESTION.md Section 8
62
+ program.addCommand(control_1.controlCommand);
53
63
  program.parse(process.argv);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aranea-sdk-cli",
3
- "version": "0.3.17",
3
+ "version": "0.5.1",
4
4
  "description": "AraneaSDK CLI - ESP32 IoTデバイス開発支援ツール",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -45,6 +45,7 @@
45
45
  "axios": "^1.6.0",
46
46
  "chalk": "^4.1.2",
47
47
  "commander": "^12.0.0",
48
+ "firebase-admin": "^13.0.0",
48
49
  "inquirer": "^8.2.6",
49
50
  "node-fetch": "^2.7.0",
50
51
  "ora": "^5.4.1"
@@ -59,15 +60,7 @@
59
60
  "engines": {
60
61
  "node": ">=18.0.0"
61
62
  },
62
- "peerDependencies": {
63
- "firebase-admin": ">=11.0.0"
64
- },
65
- "peerDependenciesMeta": {
66
- "firebase-admin": {
67
- "optional": true
68
- }
69
- },
70
- "publishConfig": {
63
+ "publishConfig": {
71
64
  "access": "public"
72
65
  }
73
66
  }