aranea-sdk-cli 0.1.4 → 0.3.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.
- package/README.md +281 -13
- package/dist/commands/knowledge.d.ts +14 -0
- package/dist/commands/knowledge.js +374 -0
- package/dist/commands/metatron.d.ts +12 -0
- package/dist/commands/metatron.js +255 -0
- package/dist/commands/mqtt.d.ts +16 -0
- package/dist/commands/mqtt.js +436 -0
- package/dist/commands/schema.d.ts +4 -0
- package/dist/commands/schema.js +446 -0
- package/dist/config.d.ts +1 -0
- package/dist/config.js +2 -0
- package/dist/index.js +10 -1
- package/package.json +9 -1
package/dist/commands/schema.js
CHANGED
|
@@ -6,7 +6,44 @@
|
|
|
6
6
|
* aranea-sdk schema get --type "aranea_ar-is04a"
|
|
7
7
|
* aranea-sdk schema list
|
|
8
8
|
* aranea-sdk schema validate --type "aranea_ar-is04a" --file state.json
|
|
9
|
+
* aranea-sdk schema validate-schema --file schema.json
|
|
10
|
+
* aranea-sdk schema push --file schema.json [--token TOKEN]
|
|
11
|
+
* aranea-sdk schema promote --type "aranea_ar-is04a" [--token TOKEN]
|
|
12
|
+
* aranea-sdk schema info --type "aranea_ar-is04a"
|
|
9
13
|
*/
|
|
14
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
15
|
+
if (k2 === undefined) k2 = k;
|
|
16
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
17
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
18
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
19
|
+
}
|
|
20
|
+
Object.defineProperty(o, k2, desc);
|
|
21
|
+
}) : (function(o, m, k, k2) {
|
|
22
|
+
if (k2 === undefined) k2 = k;
|
|
23
|
+
o[k2] = m[k];
|
|
24
|
+
}));
|
|
25
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
26
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
27
|
+
}) : function(o, v) {
|
|
28
|
+
o["default"] = v;
|
|
29
|
+
});
|
|
30
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
31
|
+
var ownKeys = function(o) {
|
|
32
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
33
|
+
var ar = [];
|
|
34
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
35
|
+
return ar;
|
|
36
|
+
};
|
|
37
|
+
return ownKeys(o);
|
|
38
|
+
};
|
|
39
|
+
return function (mod) {
|
|
40
|
+
if (mod && mod.__esModule) return mod;
|
|
41
|
+
var result = {};
|
|
42
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
43
|
+
__setModuleDefault(result, mod);
|
|
44
|
+
return result;
|
|
45
|
+
};
|
|
46
|
+
})();
|
|
10
47
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
11
48
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
12
49
|
};
|
|
@@ -16,6 +53,8 @@ const commander_1 = require("commander");
|
|
|
16
53
|
const chalk_1 = __importDefault(require("chalk"));
|
|
17
54
|
const ora_1 = __importDefault(require("ora"));
|
|
18
55
|
const axios_1 = __importDefault(require("axios"));
|
|
56
|
+
const fs = __importStar(require("fs"));
|
|
57
|
+
const path = __importStar(require("path"));
|
|
19
58
|
// API Configuration
|
|
20
59
|
const SCHEMA_API_BASE = 'https://asia-northeast1-mobesorder.cloudfunctions.net/araneaSchemaAPI';
|
|
21
60
|
// API Functions
|
|
@@ -348,3 +387,410 @@ exports.schemaCommand
|
|
|
348
387
|
process.exit(1);
|
|
349
388
|
}
|
|
350
389
|
});
|
|
390
|
+
// Helper: Get auth token from options or environment
|
|
391
|
+
function getAuthToken(options) {
|
|
392
|
+
return options.token || process.env.ARANEA_AUTH_TOKEN || process.env.FIREBASE_AUTH_TOKEN || null;
|
|
393
|
+
}
|
|
394
|
+
// Helper: Validate schema file structure
|
|
395
|
+
function validateSchemaStructure(schema) {
|
|
396
|
+
const errors = [];
|
|
397
|
+
// Required top-level fields
|
|
398
|
+
const requiredFields = ['type', 'stateSchema'];
|
|
399
|
+
for (const field of requiredFields) {
|
|
400
|
+
if (!schema[field]) {
|
|
401
|
+
errors.push(`Missing required field: ${field}`);
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
// Type validation
|
|
405
|
+
if (schema.type && typeof schema.type !== 'string') {
|
|
406
|
+
errors.push('Field "type" must be a string');
|
|
407
|
+
}
|
|
408
|
+
// ProductType validation
|
|
409
|
+
if (schema.productType && !/^\d{3}$/.test(schema.productType)) {
|
|
410
|
+
errors.push('Field "productType" must be a 3-digit string (e.g., "001")');
|
|
411
|
+
}
|
|
412
|
+
// stateSchema validation
|
|
413
|
+
if (schema.stateSchema) {
|
|
414
|
+
if (typeof schema.stateSchema !== 'object') {
|
|
415
|
+
errors.push('Field "stateSchema" must be an object');
|
|
416
|
+
}
|
|
417
|
+
else if (schema.stateSchema.type !== 'object') {
|
|
418
|
+
errors.push('Field "stateSchema.type" must be "object"');
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
// configSchema validation (optional but if present, must be object)
|
|
422
|
+
if (schema.configSchema && typeof schema.configSchema !== 'object') {
|
|
423
|
+
errors.push('Field "configSchema" must be an object');
|
|
424
|
+
}
|
|
425
|
+
// commandSchema validation (optional but if present, must be object)
|
|
426
|
+
if (schema.commandSchema && typeof schema.commandSchema !== 'object') {
|
|
427
|
+
errors.push('Field "commandSchema" must be an object');
|
|
428
|
+
}
|
|
429
|
+
// capabilities validation (optional but if present, must be array)
|
|
430
|
+
if (schema.capabilities && !Array.isArray(schema.capabilities)) {
|
|
431
|
+
errors.push('Field "capabilities" must be an array');
|
|
432
|
+
}
|
|
433
|
+
// features validation (optional but if present, must be array)
|
|
434
|
+
if (schema.features && !Array.isArray(schema.features)) {
|
|
435
|
+
errors.push('Field "features" must be an array');
|
|
436
|
+
}
|
|
437
|
+
return { valid: errors.length === 0, errors };
|
|
438
|
+
}
|
|
439
|
+
// schema validate-schema - validate a schema definition file
|
|
440
|
+
exports.schemaCommand
|
|
441
|
+
.command('validate-schema')
|
|
442
|
+
.description('Validate a schema definition JSON file (static validation)')
|
|
443
|
+
.requiredOption('-f, --file <path>', 'Schema JSON file path')
|
|
444
|
+
.action(async (options) => {
|
|
445
|
+
const spinner = (0, ora_1.default)('Validating schema file...').start();
|
|
446
|
+
try {
|
|
447
|
+
const filePath = path.resolve(options.file);
|
|
448
|
+
if (!fs.existsSync(filePath)) {
|
|
449
|
+
spinner.fail(`File not found: ${filePath}`);
|
|
450
|
+
process.exit(1);
|
|
451
|
+
}
|
|
452
|
+
const fileContent = fs.readFileSync(filePath, 'utf-8');
|
|
453
|
+
let schema;
|
|
454
|
+
try {
|
|
455
|
+
schema = JSON.parse(fileContent);
|
|
456
|
+
}
|
|
457
|
+
catch (parseError) {
|
|
458
|
+
spinner.fail(`Invalid JSON: ${parseError.message}`);
|
|
459
|
+
process.exit(1);
|
|
460
|
+
}
|
|
461
|
+
const { valid, errors } = validateSchemaStructure(schema);
|
|
462
|
+
spinner.stop();
|
|
463
|
+
console.log(chalk_1.default.bold('\n=== Schema File Validation ===\n'));
|
|
464
|
+
console.log(`File: ${filePath}`);
|
|
465
|
+
console.log(`Type: ${schema.type || '(not specified)'}`);
|
|
466
|
+
console.log('');
|
|
467
|
+
if (valid) {
|
|
468
|
+
console.log(chalk_1.default.green('✓ Schema structure is valid'));
|
|
469
|
+
console.log('');
|
|
470
|
+
// Show summary
|
|
471
|
+
console.log(chalk_1.default.bold('Schema Summary:'));
|
|
472
|
+
console.log(` Type: ${schema.type}`);
|
|
473
|
+
console.log(` DisplayName: ${schema.displayName || '(not specified)'}`);
|
|
474
|
+
console.log(` ProductType: ${schema.productType || '(not specified)'}`);
|
|
475
|
+
const stateFields = Object.keys(schema.stateSchema?.properties || {});
|
|
476
|
+
console.log(` State Fields: ${stateFields.length} (${stateFields.join(', ') || 'none'})`);
|
|
477
|
+
const configFields = Object.keys(schema.configSchema?.properties || {});
|
|
478
|
+
console.log(` Config Fields: ${configFields.length} (${configFields.join(', ') || 'none'})`);
|
|
479
|
+
const cmdFields = Object.keys(schema.commandSchema?.properties || {});
|
|
480
|
+
console.log(` Command Fields: ${cmdFields.length} (${cmdFields.join(', ') || 'none'})`);
|
|
481
|
+
console.log('');
|
|
482
|
+
console.log(chalk_1.default.cyan('Ready to push with: aranea-sdk schema push --file ' + options.file));
|
|
483
|
+
}
|
|
484
|
+
else {
|
|
485
|
+
console.log(chalk_1.default.red('✗ Schema validation failed'));
|
|
486
|
+
console.log('');
|
|
487
|
+
console.log(chalk_1.default.red('Errors:'));
|
|
488
|
+
errors.forEach((err) => {
|
|
489
|
+
console.log(chalk_1.default.red(` - ${err}`));
|
|
490
|
+
});
|
|
491
|
+
}
|
|
492
|
+
console.log('');
|
|
493
|
+
if (!valid) {
|
|
494
|
+
process.exit(1);
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
catch (error) {
|
|
498
|
+
spinner.fail(`Validation error: ${error.message}`);
|
|
499
|
+
process.exit(1);
|
|
500
|
+
}
|
|
501
|
+
});
|
|
502
|
+
// schema push - push a schema to development state
|
|
503
|
+
exports.schemaCommand
|
|
504
|
+
.command('push')
|
|
505
|
+
.description('Push a schema to Firestore (development state)')
|
|
506
|
+
.requiredOption('-f, --file <path>', 'Schema JSON file path')
|
|
507
|
+
.option('-t, --token <token>', 'Firebase Auth ID token')
|
|
508
|
+
.option('-d, --dry-run', 'Show what would be pushed without actually pushing')
|
|
509
|
+
.action(async (options) => {
|
|
510
|
+
const spinner = (0, ora_1.default)('Preparing schema push...').start();
|
|
511
|
+
try {
|
|
512
|
+
const filePath = path.resolve(options.file);
|
|
513
|
+
if (!fs.existsSync(filePath)) {
|
|
514
|
+
spinner.fail(`File not found: ${filePath}`);
|
|
515
|
+
process.exit(1);
|
|
516
|
+
}
|
|
517
|
+
const fileContent = fs.readFileSync(filePath, 'utf-8');
|
|
518
|
+
let schema;
|
|
519
|
+
try {
|
|
520
|
+
schema = JSON.parse(fileContent);
|
|
521
|
+
}
|
|
522
|
+
catch (parseError) {
|
|
523
|
+
spinner.fail(`Invalid JSON: ${parseError.message}`);
|
|
524
|
+
process.exit(1);
|
|
525
|
+
}
|
|
526
|
+
// Validate schema structure
|
|
527
|
+
const { valid, errors } = validateSchemaStructure(schema);
|
|
528
|
+
if (!valid) {
|
|
529
|
+
spinner.fail('Schema validation failed');
|
|
530
|
+
console.log('');
|
|
531
|
+
errors.forEach((err) => console.log(chalk_1.default.red(` - ${err}`)));
|
|
532
|
+
process.exit(1);
|
|
533
|
+
}
|
|
534
|
+
const token = getAuthToken(options);
|
|
535
|
+
if (!token && !options.dryRun) {
|
|
536
|
+
spinner.fail('Authentication required');
|
|
537
|
+
console.log('');
|
|
538
|
+
console.log(chalk_1.default.yellow('Provide a token using one of:'));
|
|
539
|
+
console.log(' --token <TOKEN>');
|
|
540
|
+
console.log(' export ARANEA_AUTH_TOKEN=<TOKEN>');
|
|
541
|
+
console.log(' export FIREBASE_AUTH_TOKEN=<TOKEN>');
|
|
542
|
+
console.log('');
|
|
543
|
+
console.log(chalk_1.default.gray('Or use --dry-run to see what would be pushed'));
|
|
544
|
+
process.exit(1);
|
|
545
|
+
}
|
|
546
|
+
spinner.text = `Pushing schema: ${schema.type}...`;
|
|
547
|
+
// Prepare the document data
|
|
548
|
+
const now = new Date().toISOString();
|
|
549
|
+
const docData = {
|
|
550
|
+
type: schema.type,
|
|
551
|
+
displayName: schema.displayName || schema.type,
|
|
552
|
+
description: schema.description || '',
|
|
553
|
+
productType: schema.productType || '',
|
|
554
|
+
productCodes: schema.productCodes || [],
|
|
555
|
+
capabilities: schema.capabilities || [],
|
|
556
|
+
features: schema.features || [],
|
|
557
|
+
semanticTags: schema.semanticTags || [],
|
|
558
|
+
stateSchema: schema.stateSchema || {},
|
|
559
|
+
configSchema: schema.configSchema || {},
|
|
560
|
+
commandSchema: schema.commandSchema,
|
|
561
|
+
version: schema.version || 1,
|
|
562
|
+
state: 'development', // Always push to development
|
|
563
|
+
revisionNumber: 1, // Will be incremented if already exists
|
|
564
|
+
updatedAt: now,
|
|
565
|
+
updatedBy: 'cli',
|
|
566
|
+
};
|
|
567
|
+
if (options.dryRun) {
|
|
568
|
+
spinner.stop();
|
|
569
|
+
console.log(chalk_1.default.bold('\n=== Dry Run: Schema Push ===\n'));
|
|
570
|
+
console.log(chalk_1.default.yellow('Would push the following schema:'));
|
|
571
|
+
console.log('');
|
|
572
|
+
console.log(` Target: araneaSDK/typeSettings/schemas/${schema.type}`);
|
|
573
|
+
console.log(` State: ${chalk_1.default.cyan('development')}`);
|
|
574
|
+
console.log('');
|
|
575
|
+
console.log('Document Data:');
|
|
576
|
+
console.log(chalk_1.default.gray(JSON.stringify(docData, null, 2)));
|
|
577
|
+
console.log('');
|
|
578
|
+
console.log(chalk_1.default.gray('Remove --dry-run to actually push'));
|
|
579
|
+
return;
|
|
580
|
+
}
|
|
581
|
+
// Call the API to push
|
|
582
|
+
const response = await axios_1.default.post(`${SCHEMA_API_BASE}`, {
|
|
583
|
+
action: 'push',
|
|
584
|
+
schema: docData,
|
|
585
|
+
}, {
|
|
586
|
+
headers: {
|
|
587
|
+
'Content-Type': 'application/json',
|
|
588
|
+
Authorization: `Bearer ${token}`,
|
|
589
|
+
},
|
|
590
|
+
});
|
|
591
|
+
if (response.data.ok) {
|
|
592
|
+
spinner.succeed(`Schema "${schema.type}" pushed to development`);
|
|
593
|
+
console.log('');
|
|
594
|
+
console.log(` Path: ${response.data.path || `araneaSDK/typeSettings/schemas/${schema.type}`}`);
|
|
595
|
+
console.log(` Revision: ${response.data.revisionNumber || 1}`);
|
|
596
|
+
console.log('');
|
|
597
|
+
console.log(chalk_1.default.cyan(`To promote to production: aranea-sdk schema promote --type ${schema.type}`));
|
|
598
|
+
}
|
|
599
|
+
else {
|
|
600
|
+
spinner.fail(`Push failed: ${response.data.error || 'Unknown error'}`);
|
|
601
|
+
process.exit(1);
|
|
602
|
+
}
|
|
603
|
+
}
|
|
604
|
+
catch (error) {
|
|
605
|
+
if (error.response?.status === 401) {
|
|
606
|
+
spinner.fail('Authentication failed - invalid or expired token');
|
|
607
|
+
}
|
|
608
|
+
else if (error.response?.status === 403) {
|
|
609
|
+
spinner.fail('Permission denied - insufficient privileges');
|
|
610
|
+
}
|
|
611
|
+
else if (error.response?.data?.error) {
|
|
612
|
+
spinner.fail(`Push failed: ${error.response.data.error}`);
|
|
613
|
+
}
|
|
614
|
+
else {
|
|
615
|
+
spinner.fail(`Push failed: ${error.message}`);
|
|
616
|
+
}
|
|
617
|
+
process.exit(1);
|
|
618
|
+
}
|
|
619
|
+
});
|
|
620
|
+
// schema promote - promote a schema from development to production
|
|
621
|
+
exports.schemaCommand
|
|
622
|
+
.command('promote')
|
|
623
|
+
.description('Promote a schema from development to production')
|
|
624
|
+
.requiredOption('-t, --type <type>', 'Type name to promote')
|
|
625
|
+
.option('--token <token>', 'Firebase Auth ID token')
|
|
626
|
+
.option('-d, --dry-run', 'Show what would be promoted without actually promoting')
|
|
627
|
+
.action(async (options) => {
|
|
628
|
+
const spinner = (0, ora_1.default)(`Promoting schema: ${options.type}...`).start();
|
|
629
|
+
try {
|
|
630
|
+
const token = getAuthToken(options);
|
|
631
|
+
if (!token && !options.dryRun) {
|
|
632
|
+
spinner.fail('Authentication required');
|
|
633
|
+
console.log('');
|
|
634
|
+
console.log(chalk_1.default.yellow('Provide a token using one of:'));
|
|
635
|
+
console.log(' --token <TOKEN>');
|
|
636
|
+
console.log(' export ARANEA_AUTH_TOKEN=<TOKEN>');
|
|
637
|
+
console.log(' export FIREBASE_AUTH_TOKEN=<TOKEN>');
|
|
638
|
+
process.exit(1);
|
|
639
|
+
}
|
|
640
|
+
if (options.dryRun) {
|
|
641
|
+
// Fetch current schema info
|
|
642
|
+
const schemaResult = await fetchSchema(options.type);
|
|
643
|
+
spinner.stop();
|
|
644
|
+
console.log(chalk_1.default.bold('\n=== Dry Run: Schema Promote ===\n'));
|
|
645
|
+
if (!schemaResult.ok) {
|
|
646
|
+
console.log(chalk_1.default.red(`Schema "${options.type}" not found`));
|
|
647
|
+
process.exit(1);
|
|
648
|
+
}
|
|
649
|
+
const schema = schemaResult.schema;
|
|
650
|
+
console.log(chalk_1.default.yellow('Would promote the following schema:'));
|
|
651
|
+
console.log('');
|
|
652
|
+
console.log(` Type: ${schema.type}`);
|
|
653
|
+
console.log(` Current State: ${schema.state || 'unknown'}`);
|
|
654
|
+
console.log(` New State: ${chalk_1.default.green('production')}`);
|
|
655
|
+
console.log(` Revision: ${schema.revisionNumber || schema.version}`);
|
|
656
|
+
console.log('');
|
|
657
|
+
console.log(chalk_1.default.gray('Remove --dry-run to actually promote'));
|
|
658
|
+
return;
|
|
659
|
+
}
|
|
660
|
+
// Call the API to promote
|
|
661
|
+
const response = await axios_1.default.post(`${SCHEMA_API_BASE}`, {
|
|
662
|
+
action: 'promote',
|
|
663
|
+
type: options.type,
|
|
664
|
+
}, {
|
|
665
|
+
headers: {
|
|
666
|
+
'Content-Type': 'application/json',
|
|
667
|
+
Authorization: `Bearer ${token}`,
|
|
668
|
+
},
|
|
669
|
+
});
|
|
670
|
+
if (response.data.ok) {
|
|
671
|
+
spinner.succeed(`Schema "${options.type}" promoted to production`);
|
|
672
|
+
console.log('');
|
|
673
|
+
console.log(` Previous State: ${response.data.previousState || 'development'}`);
|
|
674
|
+
console.log(` New State: ${chalk_1.default.green('production')}`);
|
|
675
|
+
console.log(` Revision: ${response.data.revisionNumber || 'N/A'}`);
|
|
676
|
+
console.log('');
|
|
677
|
+
}
|
|
678
|
+
else {
|
|
679
|
+
spinner.fail(`Promote failed: ${response.data.error || 'Unknown error'}`);
|
|
680
|
+
process.exit(1);
|
|
681
|
+
}
|
|
682
|
+
}
|
|
683
|
+
catch (error) {
|
|
684
|
+
if (error.response?.status === 401) {
|
|
685
|
+
spinner.fail('Authentication failed - invalid or expired token');
|
|
686
|
+
}
|
|
687
|
+
else if (error.response?.status === 403) {
|
|
688
|
+
spinner.fail('Permission denied - insufficient privileges');
|
|
689
|
+
}
|
|
690
|
+
else if (error.response?.status === 404) {
|
|
691
|
+
spinner.fail(`Schema "${options.type}" not found`);
|
|
692
|
+
}
|
|
693
|
+
else if (error.response?.data?.error) {
|
|
694
|
+
spinner.fail(`Promote failed: ${error.response.data.error}`);
|
|
695
|
+
}
|
|
696
|
+
else {
|
|
697
|
+
spinner.fail(`Promote failed: ${error.message}`);
|
|
698
|
+
}
|
|
699
|
+
process.exit(1);
|
|
700
|
+
}
|
|
701
|
+
});
|
|
702
|
+
// schema info - show detailed schema information with revision history
|
|
703
|
+
exports.schemaCommand
|
|
704
|
+
.command('info')
|
|
705
|
+
.description('Show detailed schema information with revision history')
|
|
706
|
+
.requiredOption('-t, --type <type>', 'Type name')
|
|
707
|
+
.option('--json', 'Output as JSON')
|
|
708
|
+
.action(async (options) => {
|
|
709
|
+
const spinner = (0, ora_1.default)(`Fetching schema info: ${options.type}...`).start();
|
|
710
|
+
try {
|
|
711
|
+
// Fetch schema from API with extended info
|
|
712
|
+
const response = await axios_1.default.get(`${SCHEMA_API_BASE}`, {
|
|
713
|
+
params: {
|
|
714
|
+
action: 'info',
|
|
715
|
+
type: options.type,
|
|
716
|
+
},
|
|
717
|
+
});
|
|
718
|
+
spinner.stop();
|
|
719
|
+
if (!response.data.ok) {
|
|
720
|
+
console.log(chalk_1.default.red(`\nSchema "${options.type}" not found`));
|
|
721
|
+
if (response.data.availableTypes) {
|
|
722
|
+
console.log('');
|
|
723
|
+
console.log(chalk_1.default.yellow('Available Types:'));
|
|
724
|
+
response.data.availableTypes.forEach((t) => console.log(` - ${t}`));
|
|
725
|
+
}
|
|
726
|
+
process.exit(1);
|
|
727
|
+
}
|
|
728
|
+
const schema = response.data.schema;
|
|
729
|
+
const revisions = response.data.revisions || [];
|
|
730
|
+
if (options.json) {
|
|
731
|
+
console.log(JSON.stringify({ schema, revisions }, null, 2));
|
|
732
|
+
return;
|
|
733
|
+
}
|
|
734
|
+
console.log(chalk_1.default.bold(`\n=== Schema Info: ${schema.type} ===\n`));
|
|
735
|
+
// Basic info
|
|
736
|
+
console.log(chalk_1.default.cyan('Basic Information:'));
|
|
737
|
+
console.log(` Type: ${schema.type}`);
|
|
738
|
+
console.log(` DisplayName: ${schema.displayName || '(not set)'}`);
|
|
739
|
+
console.log(` Description: ${schema.description || '(not set)'}`);
|
|
740
|
+
console.log(` ProductType: ${schema.productType || '(not set)'}`);
|
|
741
|
+
console.log('');
|
|
742
|
+
// State info
|
|
743
|
+
console.log(chalk_1.default.cyan('State:'));
|
|
744
|
+
const stateColor = schema.state === 'production' ? chalk_1.default.green : chalk_1.default.yellow;
|
|
745
|
+
console.log(` Current State: ${stateColor(schema.state || 'unknown')}`);
|
|
746
|
+
console.log(` Revision Number: ${schema.revisionNumber || 1}`);
|
|
747
|
+
console.log(` Version: ${schema.version || 1}`);
|
|
748
|
+
console.log('');
|
|
749
|
+
// Timestamps
|
|
750
|
+
console.log(chalk_1.default.cyan('Timestamps:'));
|
|
751
|
+
console.log(` Created: ${schema.createdAt || 'N/A'}`);
|
|
752
|
+
console.log(` Updated: ${schema.updatedAt || 'N/A'}`);
|
|
753
|
+
console.log(` Updated By: ${schema.updatedBy || 'N/A'}`);
|
|
754
|
+
console.log('');
|
|
755
|
+
// Capabilities & Features
|
|
756
|
+
console.log(chalk_1.default.cyan('Capabilities & Features:'));
|
|
757
|
+
console.log(` Capabilities: ${(schema.capabilities || []).join(', ') || '(none)'}`);
|
|
758
|
+
console.log(` Features: ${(schema.features || []).join(', ') || '(none)'}`);
|
|
759
|
+
console.log('');
|
|
760
|
+
// Schema fields summary
|
|
761
|
+
console.log(chalk_1.default.cyan('Schema Fields:'));
|
|
762
|
+
const stateFields = Object.keys(schema.stateSchema?.properties || {});
|
|
763
|
+
const configFields = Object.keys(schema.configSchema?.properties || {});
|
|
764
|
+
const cmdFields = Object.keys(schema.commandSchema?.properties || {});
|
|
765
|
+
console.log(` State: ${stateFields.length} fields (${stateFields.slice(0, 5).join(', ')}${stateFields.length > 5 ? '...' : ''})`);
|
|
766
|
+
console.log(` Config: ${configFields.length} fields (${configFields.slice(0, 5).join(', ')}${configFields.length > 5 ? '...' : ''})`);
|
|
767
|
+
console.log(` Command: ${cmdFields.length} fields (${cmdFields.slice(0, 5).join(', ')}${cmdFields.length > 5 ? '...' : ''})`);
|
|
768
|
+
console.log('');
|
|
769
|
+
// Revision history
|
|
770
|
+
if (revisions.length > 0) {
|
|
771
|
+
console.log(chalk_1.default.cyan('Revision History:'));
|
|
772
|
+
revisions.forEach((rev) => {
|
|
773
|
+
const state = rev.state === 'production' ? chalk_1.default.green(rev.state) : chalk_1.default.yellow(rev.state);
|
|
774
|
+
console.log(` [${rev.revisionNumber}] ${state} - ${rev.updatedAt} by ${rev.updatedBy || 'system'}`);
|
|
775
|
+
});
|
|
776
|
+
console.log('');
|
|
777
|
+
}
|
|
778
|
+
// Actions
|
|
779
|
+
console.log(chalk_1.default.gray('Actions:'));
|
|
780
|
+
if (schema.state !== 'production') {
|
|
781
|
+
console.log(chalk_1.default.gray(` Promote: aranea-sdk schema promote --type ${schema.type}`));
|
|
782
|
+
}
|
|
783
|
+
console.log(chalk_1.default.gray(` Get full schema: aranea-sdk schema get --type ${schema.type} --json`));
|
|
784
|
+
console.log('');
|
|
785
|
+
}
|
|
786
|
+
catch (error) {
|
|
787
|
+
spinner.fail('Failed to fetch schema info');
|
|
788
|
+
if (error.response?.status === 404) {
|
|
789
|
+
console.log(chalk_1.default.red(`\nSchema "${options.type}" not found`));
|
|
790
|
+
}
|
|
791
|
+
else {
|
|
792
|
+
console.log(chalk_1.default.red(`\nError: ${error.message}`));
|
|
793
|
+
}
|
|
794
|
+
process.exit(1);
|
|
795
|
+
}
|
|
796
|
+
});
|
package/dist/config.d.ts
CHANGED
package/dist/config.js
CHANGED
|
@@ -9,11 +9,13 @@ exports.ENDPOINTS = {
|
|
|
9
9
|
production: {
|
|
10
10
|
gate: 'https://asia-northeast1-mobesorder.cloudfunctions.net/araneaDeviceGate',
|
|
11
11
|
state: 'https://asia-northeast1-mobesorder.cloudfunctions.net/deviceStateReport',
|
|
12
|
+
command: 'https://asia-northeast1-mobesorder.cloudfunctions.net/araneaDeviceCommand',
|
|
12
13
|
mqtt: 'wss://aranea-mqtt-bridge-1010551946141.asia-northeast1.run.app',
|
|
13
14
|
},
|
|
14
15
|
staging: {
|
|
15
16
|
gate: 'https://asia-northeast1-mobesorder-staging.cloudfunctions.net/araneaDeviceGate',
|
|
16
17
|
state: 'https://asia-northeast1-mobesorder-staging.cloudfunctions.net/deviceStateReport',
|
|
18
|
+
command: 'https://asia-northeast1-mobesorder-staging.cloudfunctions.net/araneaDeviceCommand',
|
|
17
19
|
mqtt: 'wss://aranea-mqtt-bridge-staging.asia-northeast1.run.app',
|
|
18
20
|
},
|
|
19
21
|
};
|
package/dist/index.js
CHANGED
|
@@ -20,11 +20,14 @@ const simulate_1 = require("./commands/simulate");
|
|
|
20
20
|
const validate_1 = require("./commands/validate");
|
|
21
21
|
const schema_1 = require("./commands/schema");
|
|
22
22
|
const register_1 = require("./commands/register");
|
|
23
|
+
const mqtt_1 = require("./commands/mqtt");
|
|
24
|
+
const knowledge_1 = require("./commands/knowledge");
|
|
25
|
+
const metatron_1 = require("./commands/metatron");
|
|
23
26
|
const program = new commander_1.Command();
|
|
24
27
|
program
|
|
25
28
|
.name('aranea-sdk')
|
|
26
29
|
.description('AraneaSDK CLI - デバイス開発支援ツール')
|
|
27
|
-
.version('0.
|
|
30
|
+
.version('0.3.0');
|
|
28
31
|
// test コマンド
|
|
29
32
|
program.addCommand(test_1.testCommand);
|
|
30
33
|
// simulate コマンド
|
|
@@ -35,4 +38,10 @@ program.addCommand(validate_1.validateCommand);
|
|
|
35
38
|
program.addCommand(schema_1.schemaCommand);
|
|
36
39
|
// register コマンド
|
|
37
40
|
program.addCommand(register_1.registerCommand);
|
|
41
|
+
// mqtt コマンド (v0.2.0 P0)
|
|
42
|
+
program.addCommand(mqtt_1.mqttCommand);
|
|
43
|
+
// knowledge コマンド (v0.2.1)
|
|
44
|
+
program.addCommand(knowledge_1.knowledgeCommand);
|
|
45
|
+
// metatron コマンド (v0.2.1)
|
|
46
|
+
program.addCommand(metatron_1.metatronCommand);
|
|
38
47
|
program.parse(process.argv);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "aranea-sdk-cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "AraneaSDK CLI - ESP32 IoTデバイス開発支援ツール",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -59,6 +59,14 @@
|
|
|
59
59
|
"engines": {
|
|
60
60
|
"node": ">=18.0.0"
|
|
61
61
|
},
|
|
62
|
+
"peerDependencies": {
|
|
63
|
+
"firebase-admin": ">=11.0.0"
|
|
64
|
+
},
|
|
65
|
+
"peerDependenciesMeta": {
|
|
66
|
+
"firebase-admin": {
|
|
67
|
+
"optional": true
|
|
68
|
+
}
|
|
69
|
+
},
|
|
62
70
|
"publishConfig": {
|
|
63
71
|
"access": "public"
|
|
64
72
|
}
|