trucontext 0.8.2 → 0.8.4
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/package.json
CHANGED
package/src/commands/apps.js
CHANGED
|
@@ -5,7 +5,7 @@ import { getActiveApp, setActiveApp } from '../config.js';
|
|
|
5
5
|
export async function appsCommand() {
|
|
6
6
|
try {
|
|
7
7
|
const res = await controlPlane('GET', '/apps');
|
|
8
|
-
const apps = res.data
|
|
8
|
+
const apps = Array.isArray(res.data) ? res.data : [];
|
|
9
9
|
const activeApp = getActiveApp();
|
|
10
10
|
|
|
11
11
|
if (apps.length === 0) {
|
|
@@ -27,7 +27,7 @@ export async function appsCommand() {
|
|
|
27
27
|
export async function useCommand(appId) {
|
|
28
28
|
try {
|
|
29
29
|
const res = await controlPlane('GET', '/apps');
|
|
30
|
-
const apps = res.data
|
|
30
|
+
const apps = Array.isArray(res.data) ? res.data : [];
|
|
31
31
|
const app = apps.find(a => a.appId === appId || a.name.toLowerCase() === appId.toLowerCase());
|
|
32
32
|
|
|
33
33
|
if (!app) {
|
package/src/commands/billing.js
CHANGED
|
@@ -45,7 +45,7 @@ export async function usageCommand(options) {
|
|
|
45
45
|
const params = [`period=${period}`];
|
|
46
46
|
if (source) params.push(`source=${source}`);
|
|
47
47
|
const res = await controlPlane('GET', `/billing/usage/${appId}?${params.join('&')}`);
|
|
48
|
-
const usage = res.data
|
|
48
|
+
const usage = res.data || {};
|
|
49
49
|
|
|
50
50
|
if (!usage || (!usage.apiCalls && !usage.llmInputTokens && !usage.processingMs)) {
|
|
51
51
|
console.log(chalk.yellow('No usage data available.'));
|
|
@@ -92,7 +92,7 @@ export async function usageHistoryCommand(options) {
|
|
|
92
92
|
const params = [`period=${period}`];
|
|
93
93
|
if (source) params.push(`source=${source}`);
|
|
94
94
|
const res = await controlPlane('GET', `/billing/usage/${appId}/history?${params.join('&')}`);
|
|
95
|
-
const historyData = res.data
|
|
95
|
+
const historyData = res.data || {};
|
|
96
96
|
const history = historyData.history || [];
|
|
97
97
|
|
|
98
98
|
if (history.length === 0) {
|
|
@@ -135,8 +135,7 @@ export async function usageHistoryCommand(options) {
|
|
|
135
135
|
export async function plansCommand() {
|
|
136
136
|
try {
|
|
137
137
|
const res = await controlPlane('GET', '/billing/plans');
|
|
138
|
-
const
|
|
139
|
-
const plans = plansData.plans || [];
|
|
138
|
+
const plans = Array.isArray(res.data) ? res.data : [];
|
|
140
139
|
|
|
141
140
|
if (plans.length === 0) {
|
|
142
141
|
console.log(chalk.yellow('No plans available.'));
|
package/src/commands/docs.js
CHANGED
|
@@ -4,7 +4,7 @@ import { publicApi } from '../client.js';
|
|
|
4
4
|
export async function docsListCommand() {
|
|
5
5
|
try {
|
|
6
6
|
const res = await publicApi('GET', '/public/docs');
|
|
7
|
-
const sections = res.data
|
|
7
|
+
const sections = Array.isArray(res.data) ? res.data : [];
|
|
8
8
|
|
|
9
9
|
if (sections.length === 0) {
|
|
10
10
|
console.log(chalk.yellow('No documentation available.'));
|
package/src/commands/entities.js
CHANGED
|
@@ -49,7 +49,7 @@ export async function entitiesListCommand(options) {
|
|
|
49
49
|
const path = `/apps/${appId}/entities${qs ? `?${qs}` : ''}`;
|
|
50
50
|
|
|
51
51
|
const res = await controlPlane('GET', path);
|
|
52
|
-
const entities = Array.isArray(res.data) ? res.data :
|
|
52
|
+
const entities = Array.isArray(res.data) ? res.data : [];
|
|
53
53
|
|
|
54
54
|
if (entities.length === 0) {
|
|
55
55
|
console.log(chalk.yellow('No entities found.'));
|
|
@@ -201,7 +201,7 @@ export async function entitiesEdgesCommand(entityId) {
|
|
|
201
201
|
try {
|
|
202
202
|
const appId = getActiveApp();
|
|
203
203
|
const res = await controlPlane('GET', `/apps/${appId}/entities/${entityId}/edges`);
|
|
204
|
-
const edges = res.data
|
|
204
|
+
const edges = Array.isArray(res.data) ? res.data : [];
|
|
205
205
|
|
|
206
206
|
if (edges.length === 0) {
|
|
207
207
|
console.log(chalk.yellow('No edges found.'));
|
package/src/commands/login.js
CHANGED
|
@@ -96,7 +96,7 @@ export async function loginCommand(options) {
|
|
|
96
96
|
// Fetch apps and select or create one
|
|
97
97
|
try {
|
|
98
98
|
const res = await controlPlane('GET', '/apps');
|
|
99
|
-
const apps = res.data
|
|
99
|
+
const apps = Array.isArray(res.data) ? res.data : [];
|
|
100
100
|
|
|
101
101
|
if (apps.length === 1) {
|
|
102
102
|
setActiveApp(apps[0].appId);
|
package/src/commands/roots.js
CHANGED
|
@@ -76,7 +76,7 @@ export function registerRootsCommand(program) {
|
|
|
76
76
|
try {
|
|
77
77
|
const appId = getActiveApp();
|
|
78
78
|
const res = await controlPlane('GET', `/apps/${appId}/roots`);
|
|
79
|
-
const rootNodes = res.data
|
|
79
|
+
const rootNodes = Array.isArray(res.data) ? res.data : [];
|
|
80
80
|
if (rootNodes.length === 0) {
|
|
81
81
|
console.log('No root nodes. Create one with: trucontext roots create');
|
|
82
82
|
return;
|