aranea-sdk-cli 0.3.6 → 0.3.7
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/dist/commands/knowledge.js +14 -8
- package/dist/commands/metatron.js +9 -5
- package/dist/index.js +1 -1
- package/package.json +1 -1
|
@@ -55,6 +55,7 @@ const axios_1 = __importDefault(require("axios"));
|
|
|
55
55
|
const fs = __importStar(require("fs"));
|
|
56
56
|
const path = __importStar(require("path"));
|
|
57
57
|
const config_1 = require("../config");
|
|
58
|
+
const auth_1 = require("./auth");
|
|
58
59
|
// ============================================================================
|
|
59
60
|
// Config
|
|
60
61
|
// ============================================================================
|
|
@@ -71,10 +72,15 @@ const CATEGORIES = ['api', 'guide', 'code', 'reference', 'incident', 'tip'];
|
|
|
71
72
|
// Helper Functions
|
|
72
73
|
// ============================================================================
|
|
73
74
|
/**
|
|
74
|
-
* Firebase Auth
|
|
75
|
+
* Firebase Auth トークンを取得(保存済み認証情報 or 環境変数)
|
|
75
76
|
*/
|
|
76
|
-
function getAuthToken() {
|
|
77
|
-
|
|
77
|
+
async function getAuthToken() {
|
|
78
|
+
// 1. 環境変数を優先
|
|
79
|
+
const envToken = process.env.ARANEA_AUTH_TOKEN || process.env.FIREBASE_AUTH_TOKEN;
|
|
80
|
+
if (envToken)
|
|
81
|
+
return envToken;
|
|
82
|
+
// 2. 保存済み認証情報から取得(自動リフレッシュ含む)
|
|
83
|
+
return await (0, auth_1.getValidToken)();
|
|
78
84
|
}
|
|
79
85
|
/**
|
|
80
86
|
* API呼び出し(Callable形式)
|
|
@@ -146,7 +152,7 @@ exports.knowledgeCommand
|
|
|
146
152
|
(0, config_1.warnIfProduction)(env, 'knowledge add');
|
|
147
153
|
console.log(chalk_1.default.bold(`\n=== Knowledge Add (${env}) ===\n`));
|
|
148
154
|
// 認証トークン
|
|
149
|
-
const token = options.token || getAuthToken();
|
|
155
|
+
const token = options.token || await getAuthToken();
|
|
150
156
|
if (!token) {
|
|
151
157
|
console.error(chalk_1.default.red('❌ 認証トークンが必要です。--token または ARANEA_AUTH_TOKEN 環境変数を設定'));
|
|
152
158
|
process.exit(1);
|
|
@@ -229,7 +235,7 @@ exports.knowledgeCommand
|
|
|
229
235
|
try {
|
|
230
236
|
const env = (0, config_1.resolveEnvironment)(options.endpoint);
|
|
231
237
|
console.log(chalk_1.default.bold(`\n=== Knowledge Search (${env}) ===\n`));
|
|
232
|
-
const token = options.token || getAuthToken();
|
|
238
|
+
const token = options.token || await getAuthToken();
|
|
233
239
|
if (!token) {
|
|
234
240
|
console.error(chalk_1.default.red('❌ 認証トークンが必要です'));
|
|
235
241
|
process.exit(1);
|
|
@@ -273,7 +279,7 @@ exports.knowledgeCommand
|
|
|
273
279
|
try {
|
|
274
280
|
const env = (0, config_1.resolveEnvironment)(options.endpoint);
|
|
275
281
|
console.log(chalk_1.default.bold(`\n=== Knowledge List (${env}) ===\n`));
|
|
276
|
-
const token = options.token || getAuthToken();
|
|
282
|
+
const token = options.token || await getAuthToken();
|
|
277
283
|
if (!token) {
|
|
278
284
|
console.error(chalk_1.default.red('❌ 認証トークンが必要です'));
|
|
279
285
|
process.exit(1);
|
|
@@ -315,7 +321,7 @@ exports.knowledgeCommand
|
|
|
315
321
|
try {
|
|
316
322
|
const env = (0, config_1.resolveEnvironment)(options.endpoint);
|
|
317
323
|
console.log(chalk_1.default.bold(`\n=== Knowledge Get (${env}) ===\n`));
|
|
318
|
-
const token = options.token || getAuthToken();
|
|
324
|
+
const token = options.token || await getAuthToken();
|
|
319
325
|
if (!token) {
|
|
320
326
|
console.error(chalk_1.default.red('❌ 認証トークンが必要です'));
|
|
321
327
|
process.exit(1);
|
|
@@ -348,7 +354,7 @@ exports.knowledgeCommand
|
|
|
348
354
|
const env = (0, config_1.resolveEnvironment)(options.endpoint);
|
|
349
355
|
(0, config_1.warnIfProduction)(env, 'knowledge delete');
|
|
350
356
|
console.log(chalk_1.default.bold(`\n=== Knowledge Delete (${env}) ===\n`));
|
|
351
|
-
const token = options.token || getAuthToken();
|
|
357
|
+
const token = options.token || await getAuthToken();
|
|
352
358
|
if (!token) {
|
|
353
359
|
console.error(chalk_1.default.red('❌ 認証トークンが必要です'));
|
|
354
360
|
process.exit(1);
|
|
@@ -52,6 +52,7 @@ const ora_1 = __importDefault(require("ora"));
|
|
|
52
52
|
const axios_1 = __importDefault(require("axios"));
|
|
53
53
|
const readline = __importStar(require("readline"));
|
|
54
54
|
const config_1 = require("../config");
|
|
55
|
+
const auth_1 = require("./auth");
|
|
55
56
|
// ============================================================================
|
|
56
57
|
// Config
|
|
57
58
|
// ============================================================================
|
|
@@ -66,10 +67,13 @@ function getMetatronApiBase(env) {
|
|
|
66
67
|
// Helper Functions
|
|
67
68
|
// ============================================================================
|
|
68
69
|
/**
|
|
69
|
-
* Firebase Auth
|
|
70
|
+
* Firebase Auth トークンを取得(保存済み認証情報 or 環境変数)
|
|
70
71
|
*/
|
|
71
|
-
function getAuthToken() {
|
|
72
|
-
|
|
72
|
+
async function getAuthToken() {
|
|
73
|
+
const envToken = process.env.ARANEA_AUTH_TOKEN || process.env.FIREBASE_AUTH_TOKEN;
|
|
74
|
+
if (envToken)
|
|
75
|
+
return envToken;
|
|
76
|
+
return await (0, auth_1.getValidToken)();
|
|
73
77
|
}
|
|
74
78
|
/**
|
|
75
79
|
* Metatron API呼び出し
|
|
@@ -127,7 +131,7 @@ exports.metatronCommand
|
|
|
127
131
|
console.log(chalk_1.default.bold(`\n=== AraneaMetatron (${env}) ===\n`));
|
|
128
132
|
console.log(chalk_1.default.gray(`Q: ${question}`));
|
|
129
133
|
}
|
|
130
|
-
const token = options.token || getAuthToken();
|
|
134
|
+
const token = options.token || await getAuthToken();
|
|
131
135
|
if (!token) {
|
|
132
136
|
console.error(chalk_1.default.red('❌ 認証トークンが必要です。--token または ARANEA_AUTH_TOKEN 環境変数を設定'));
|
|
133
137
|
process.exit(1);
|
|
@@ -159,7 +163,7 @@ exports.metatronCommand
|
|
|
159
163
|
console.log(chalk_1.default.bold(`\n=== AraneaMetatron Chat (${env}) ===\n`));
|
|
160
164
|
console.log(chalk_1.default.gray('AraneaSDKについて質問してください。'));
|
|
161
165
|
console.log(chalk_1.default.gray('終了するには "exit" または Ctrl+C を入力\n'));
|
|
162
|
-
const token = options.token || getAuthToken();
|
|
166
|
+
const token = options.token || await getAuthToken();
|
|
163
167
|
if (!token) {
|
|
164
168
|
console.error(chalk_1.default.red('❌ 認証トークンが必要です。--token または ARANEA_AUTH_TOKEN 環境変数を設定'));
|
|
165
169
|
process.exit(1);
|
package/dist/index.js
CHANGED