aranea-sdk-cli 0.1.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.
@@ -0,0 +1,167 @@
1
+ "use strict";
2
+ /**
3
+ * validate コマンド
4
+ *
5
+ * Usage:
6
+ * aranea-sdk validate type --type "aranea_ar-is04a"
7
+ * aranea-sdk validate lacis-id --lacis-id "3004AABBCCDDEEFF0001"
8
+ */
9
+ var __importDefault = (this && this.__importDefault) || function (mod) {
10
+ return (mod && mod.__esModule) ? mod : { "default": mod };
11
+ };
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ exports.validateCommand = void 0;
14
+ const commander_1 = require("commander");
15
+ const chalk_1 = __importDefault(require("chalk"));
16
+ exports.validateCommand = new commander_1.Command('validate')
17
+ .description('入力値のバリデーション');
18
+ // validate type
19
+ exports.validateCommand
20
+ .command('type')
21
+ .description('Type名の形式を検証')
22
+ .requiredOption('-t, --type <type>', '検証するType名')
23
+ .action((options) => {
24
+ console.log(chalk_1.default.bold('\n=== Type名バリデーション ===\n'));
25
+ console.log(`入力: ${options.type}`);
26
+ console.log('');
27
+ const type = options.type;
28
+ const issues = [];
29
+ const warnings = [];
30
+ // 1. aranea_ プレフィックスチェック
31
+ if (!type.startsWith('aranea_')) {
32
+ if (type.startsWith('ISMS_')) {
33
+ issues.push(`旧プレフィックス 'ISMS_' を使用しています`);
34
+ warnings.push(`推奨: 'aranea_${type.replace('ISMS_', '')}'`);
35
+ }
36
+ else if (type.startsWith('ar-')) {
37
+ issues.push(`プレフィックスがありません`);
38
+ warnings.push(`推奨: 'aranea_${type}'`);
39
+ }
40
+ else {
41
+ issues.push(`'aranea_' プレフィックスがありません`);
42
+ }
43
+ }
44
+ // 2. 形式チェック (aranea_ar-is{XX}{variant})
45
+ const pattern = /^aranea_ar-is(\d{2})([a-z])?$/;
46
+ const match = type.match(pattern);
47
+ if (type.startsWith('aranea_') && !match) {
48
+ issues.push(`AraneaDevice Type の形式に適合しません`);
49
+ warnings.push(`形式: aranea_ar-is{番号}{枝番(a-z)}`);
50
+ warnings.push(`例: aranea_ar-is04a, aranea_ar-is10`);
51
+ }
52
+ // 3. 結果表示
53
+ if (issues.length === 0) {
54
+ console.log(chalk_1.default.green('✓ Type名は正しい形式です'));
55
+ if (match) {
56
+ const productNumber = match[1];
57
+ const variant = match[2] || '(なし)';
58
+ console.log('');
59
+ console.log(` ProductNumber: ${productNumber}`);
60
+ console.log(` 枝番: ${variant}`);
61
+ }
62
+ }
63
+ else {
64
+ console.log(chalk_1.default.red('✗ 問題が見つかりました:'));
65
+ issues.forEach((issue) => {
66
+ console.log(chalk_1.default.red(` - ${issue}`));
67
+ });
68
+ if (warnings.length > 0) {
69
+ console.log('');
70
+ console.log(chalk_1.default.yellow('推奨事項:'));
71
+ warnings.forEach((warning) => {
72
+ console.log(chalk_1.default.yellow(` ${warning}`));
73
+ });
74
+ }
75
+ }
76
+ console.log('');
77
+ });
78
+ // validate lacis-id
79
+ exports.validateCommand
80
+ .command('lacis-id')
81
+ .description('LacisIDの形式を検証')
82
+ .requiredOption('-l, --lacis-id <lacisId>', '検証するLacisID')
83
+ .action((options) => {
84
+ console.log(chalk_1.default.bold('\n=== LacisID バリデーション ===\n'));
85
+ console.log(`入力: ${options.lacisId}`);
86
+ console.log('');
87
+ const lacisId = options.lacisId;
88
+ const issues = [];
89
+ // 1. 長さチェック
90
+ if (lacisId.length !== 20) {
91
+ issues.push(`長さが20桁ではありません (現在: ${lacisId.length}桁)`);
92
+ }
93
+ // 2. 数字チェック (deviceWithMAC形式の場合はHEXも許可)
94
+ if (!/^[0-9A-Fa-f]+$/.test(lacisId)) {
95
+ issues.push(`無効な文字が含まれています (0-9, A-F のみ許可)`);
96
+ }
97
+ // 3. araneaDevice プレフィックスチェック (3で始まる)
98
+ if (lacisId.length >= 1 && lacisId[0] !== '3') {
99
+ issues.push(`araneaDevice の場合、先頭は '3' である必要があります`);
100
+ }
101
+ // 4. 結果表示
102
+ if (issues.length === 0) {
103
+ console.log(chalk_1.default.green('✓ LacisIDは正しい形式です'));
104
+ console.log('');
105
+ // 構造解析 (deviceWithMAC形式)
106
+ if (lacisId.length === 20) {
107
+ const prefix = lacisId.substring(0, 1);
108
+ const productType = lacisId.substring(1, 4);
109
+ const mac = lacisId.substring(4, 16);
110
+ const productCode = lacisId.substring(16, 20);
111
+ console.log(` Prefix: ${prefix} (3 = araneaDevice)`);
112
+ console.log(` ProductType: ${productType}`);
113
+ console.log(` MAC: ${mac}`);
114
+ console.log(` ProductCode: ${productCode}`);
115
+ }
116
+ }
117
+ else {
118
+ console.log(chalk_1.default.red('✗ 問題が見つかりました:'));
119
+ issues.forEach((issue) => {
120
+ console.log(chalk_1.default.red(` - ${issue}`));
121
+ });
122
+ }
123
+ console.log('');
124
+ });
125
+ // validate mac
126
+ exports.validateCommand
127
+ .command('mac')
128
+ .description('MACアドレスの形式を検証')
129
+ .requiredOption('-m, --mac <mac>', '検証するMACアドレス')
130
+ .action((options) => {
131
+ console.log(chalk_1.default.bold('\n=== MACアドレス バリデーション ===\n'));
132
+ console.log(`入力: ${options.mac}`);
133
+ console.log('');
134
+ let mac = options.mac;
135
+ const issues = [];
136
+ const warnings = [];
137
+ // コロン/ハイフン除去
138
+ const cleanMac = mac.replace(/[:\-]/g, '').toUpperCase();
139
+ if (cleanMac !== mac) {
140
+ warnings.push(`正規化: ${mac} → ${cleanMac}`);
141
+ }
142
+ // 長さチェック
143
+ if (cleanMac.length !== 12) {
144
+ issues.push(`長さが12桁ではありません (現在: ${cleanMac.length}桁)`);
145
+ }
146
+ // HEXチェック
147
+ if (!/^[0-9A-F]+$/.test(cleanMac)) {
148
+ issues.push(`無効な文字が含まれています (0-9, A-F のみ許可)`);
149
+ }
150
+ // 結果表示
151
+ if (issues.length === 0) {
152
+ console.log(chalk_1.default.green('✓ MACアドレスは正しい形式です'));
153
+ if (warnings.length > 0) {
154
+ console.log('');
155
+ warnings.forEach((w) => console.log(chalk_1.default.yellow(` ${w}`)));
156
+ }
157
+ console.log('');
158
+ console.log(` 使用形式: ${cleanMac}`);
159
+ }
160
+ else {
161
+ console.log(chalk_1.default.red('✗ 問題が見つかりました:'));
162
+ issues.forEach((issue) => {
163
+ console.log(chalk_1.default.red(` - ${issue}`));
164
+ });
165
+ }
166
+ console.log('');
167
+ });
@@ -0,0 +1,16 @@
1
+ /**
2
+ * AraneaSDK CLI Configuration
3
+ */
4
+ export interface Endpoint {
5
+ gate: string;
6
+ state: string;
7
+ mqtt?: string;
8
+ }
9
+ export declare const ENDPOINTS: Record<string, Endpoint>;
10
+ export declare const TEST_TENANT: {
11
+ tid: string;
12
+ primaryLacisId: string;
13
+ primaryEmail: string;
14
+ primaryCic: string;
15
+ };
16
+ export declare function getEndpoint(env: string): Endpoint;
package/dist/config.js ADDED
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ /**
3
+ * AraneaSDK CLI Configuration
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.TEST_TENANT = exports.ENDPOINTS = void 0;
7
+ exports.getEndpoint = getEndpoint;
8
+ exports.ENDPOINTS = {
9
+ production: {
10
+ gate: 'https://asia-northeast1-mobesorder.cloudfunctions.net/araneaDeviceGate',
11
+ state: 'https://asia-northeast1-mobesorder.cloudfunctions.net/deviceStateReport',
12
+ mqtt: 'wss://aranea-mqtt-bridge-1010551946141.asia-northeast1.run.app',
13
+ },
14
+ staging: {
15
+ gate: 'https://asia-northeast1-mobesorder-staging.cloudfunctions.net/araneaDeviceGate',
16
+ state: 'https://asia-northeast1-mobesorder-staging.cloudfunctions.net/deviceStateReport',
17
+ mqtt: 'wss://aranea-mqtt-bridge-staging.asia-northeast1.run.app',
18
+ },
19
+ };
20
+ exports.TEST_TENANT = {
21
+ tid: 'T9999999999999999999',
22
+ primaryLacisId: '17347487748391988274',
23
+ primaryEmail: 'dev@araneadevice.dev',
24
+ primaryCic: '022029',
25
+ };
26
+ function getEndpoint(env) {
27
+ const endpoint = exports.ENDPOINTS[env];
28
+ if (!endpoint) {
29
+ throw new Error(`Unknown environment: ${env}. Use 'production' or 'staging'.`);
30
+ }
31
+ return endpoint;
32
+ }
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * AraneaSDK CLI
4
+ *
5
+ * デバイス開発支援ツール
6
+ *
7
+ * Usage:
8
+ * aranea-sdk test connection --endpoint staging
9
+ * aranea-sdk test auth --tid T999... --lacis-id 173... --cic 022029
10
+ * aranea-sdk simulate state-report --file test.json --dry-run
11
+ * aranea-sdk validate type --type "aranea_ar-is04a"
12
+ * aranea-sdk schema get --type "aranea_ar-is04a"
13
+ * aranea-sdk register --type "aranea_ar-is04a" --mac "AABBCCDDEEFF" --dry-run
14
+ */
15
+ export {};
package/dist/index.js ADDED
@@ -0,0 +1,38 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ /**
4
+ * AraneaSDK CLI
5
+ *
6
+ * デバイス開発支援ツール
7
+ *
8
+ * Usage:
9
+ * aranea-sdk test connection --endpoint staging
10
+ * aranea-sdk test auth --tid T999... --lacis-id 173... --cic 022029
11
+ * aranea-sdk simulate state-report --file test.json --dry-run
12
+ * aranea-sdk validate type --type "aranea_ar-is04a"
13
+ * aranea-sdk schema get --type "aranea_ar-is04a"
14
+ * aranea-sdk register --type "aranea_ar-is04a" --mac "AABBCCDDEEFF" --dry-run
15
+ */
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ const commander_1 = require("commander");
18
+ const test_1 = require("./commands/test");
19
+ const simulate_1 = require("./commands/simulate");
20
+ const validate_1 = require("./commands/validate");
21
+ const schema_1 = require("./commands/schema");
22
+ const register_1 = require("./commands/register");
23
+ const program = new commander_1.Command();
24
+ program
25
+ .name('aranea-sdk')
26
+ .description('AraneaSDK CLI - デバイス開発支援ツール')
27
+ .version('0.1.0');
28
+ // test コマンド
29
+ program.addCommand(test_1.testCommand);
30
+ // simulate コマンド
31
+ program.addCommand(simulate_1.simulateCommand);
32
+ // validate コマンド
33
+ program.addCommand(validate_1.validateCommand);
34
+ // schema コマンド
35
+ program.addCommand(schema_1.schemaCommand);
36
+ // register コマンド
37
+ program.addCommand(register_1.registerCommand);
38
+ program.parse(process.argv);
package/package.json ADDED
@@ -0,0 +1,64 @@
1
+ {
2
+ "name": "aranea-sdk-cli",
3
+ "version": "0.1.0",
4
+ "description": "AraneaSDK CLI - ESP32 IoTデバイス開発支援ツール",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "bin": {
8
+ "aranea-sdk": "./dist/index.js"
9
+ },
10
+ "scripts": {
11
+ "build": "tsc",
12
+ "dev": "ts-node src/index.ts",
13
+ "test": "jest",
14
+ "prepublishOnly": "npm run build"
15
+ },
16
+ "keywords": [
17
+ "aranea",
18
+ "araneaSDK",
19
+ "esp32",
20
+ "iot",
21
+ "device",
22
+ "cli",
23
+ "mobes"
24
+ ],
25
+ "author": {
26
+ "name": "AraneaSDK Team",
27
+ "email": "dev@araneadevice.dev"
28
+ },
29
+ "license": "MIT",
30
+ "repository": {
31
+ "type": "git",
32
+ "url": "https://github.com/warusakudeveroper/mobes2.0.git",
33
+ "directory": "scripts/aranea-cli"
34
+ },
35
+ "bugs": {
36
+ "url": "https://github.com/warusakudeveroper/mobes2.0/issues"
37
+ },
38
+ "homepage": "https://github.com/warusakudeveroper/mobes2.0/tree/main/scripts/aranea-cli#readme",
39
+ "files": [
40
+ "dist",
41
+ "README.md",
42
+ "LICENSE"
43
+ ],
44
+ "dependencies": {
45
+ "commander": "^12.0.0",
46
+ "chalk": "^4.1.2",
47
+ "node-fetch": "^2.7.0",
48
+ "ora": "^5.4.1",
49
+ "inquirer": "^8.2.6"
50
+ },
51
+ "devDependencies": {
52
+ "@types/node": "^20.0.0",
53
+ "@types/node-fetch": "^2.6.11",
54
+ "@types/inquirer": "^9.0.7",
55
+ "typescript": "^5.0.0",
56
+ "ts-node": "^10.9.2"
57
+ },
58
+ "engines": {
59
+ "node": ">=18.0.0"
60
+ },
61
+ "publishConfig": {
62
+ "access": "public"
63
+ }
64
+ }