@enerlence/suntropy-cli 0.8.0 → 0.8.2
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/bin/suntropy.js +30 -5
- package/dist/bin/suntropy.js.map +1 -1
- package/package.json +1 -1
package/dist/bin/suntropy.js
CHANGED
|
@@ -139,6 +139,15 @@ function createUnauthClient(baseURL) {
|
|
|
139
139
|
headers: { "Content-Type": "application/json" }
|
|
140
140
|
});
|
|
141
141
|
}
|
|
142
|
+
function assertFound(data, entity, id) {
|
|
143
|
+
const isEmptyObject = data != null && typeof data === "object" && !Array.isArray(data) && Object.keys(data).length === 0;
|
|
144
|
+
if (data == null || typeof data !== "object" || Array.isArray(data) || isEmptyObject) {
|
|
145
|
+
throw new Error(
|
|
146
|
+
`${entity} not found: ${id}. The backend returned an empty response \u2014 verify the id is correct and belongs to your account and environment (the CLI and the app must point to the same backend).`
|
|
147
|
+
);
|
|
148
|
+
}
|
|
149
|
+
return data;
|
|
150
|
+
}
|
|
142
151
|
function handleApiError(err) {
|
|
143
152
|
if (axios.isAxiosError(err)) {
|
|
144
153
|
const ae = err;
|
|
@@ -2184,7 +2193,7 @@ function registerStudyBuilderCommands(studies) {
|
|
|
2184
2193
|
const global = getGlobalOpts7(studies);
|
|
2185
2194
|
const client = createServiceClient("solar", global);
|
|
2186
2195
|
const res = await client.get(`/solar-study/findById/${studyId}`);
|
|
2187
|
-
const study = res.data;
|
|
2196
|
+
const study = assertFound(res.data, "Solar study", studyId);
|
|
2188
2197
|
const { stepsProgress, missing } = evaluateSteps(study);
|
|
2189
2198
|
const progress = study.solarStudyProgress || {};
|
|
2190
2199
|
progress.stepsProgress = stepsProgress;
|
|
@@ -3155,7 +3164,23 @@ Example: suntropy studies set data --file study.json --data '{"referenceId":"REF
|
|
|
3155
3164
|
replyToName: opts.replyToName
|
|
3156
3165
|
});
|
|
3157
3166
|
const res = await client.post(`/solar-study/addSolarStudyComment/${studyId}`, comment);
|
|
3158
|
-
|
|
3167
|
+
const saved = assertFound(res.data, "Solar study", studyId);
|
|
3168
|
+
output(
|
|
3169
|
+
{
|
|
3170
|
+
success: true,
|
|
3171
|
+
message: `Comentario a\xF1adido al estudio ${studyId}`,
|
|
3172
|
+
studyId,
|
|
3173
|
+
commentsCount: Array.isArray(saved.comments) ? saved.comments.length : void 0,
|
|
3174
|
+
comment: {
|
|
3175
|
+
type: comment.type,
|
|
3176
|
+
creationUserUID: comment.creationUserUID,
|
|
3177
|
+
creationTimestamp: comment.creationTimestamp,
|
|
3178
|
+
aiGenerated: comment.aiGenerated ?? false,
|
|
3179
|
+
content: comment.content
|
|
3180
|
+
}
|
|
3181
|
+
},
|
|
3182
|
+
global
|
|
3183
|
+
);
|
|
3159
3184
|
} catch (err) {
|
|
3160
3185
|
outputError(handleApiError(err));
|
|
3161
3186
|
}
|
|
@@ -3470,7 +3495,7 @@ function registerStudiesCommands(program2) {
|
|
|
3470
3495
|
const global = getGlobalOpts8(studies);
|
|
3471
3496
|
const client = createServiceClient("solar", global);
|
|
3472
3497
|
const res = await client.get(`/solar-study/findById/${studyId}`);
|
|
3473
|
-
const study = res.data;
|
|
3498
|
+
const study = assertFound(res.data, "Solar study", studyId);
|
|
3474
3499
|
const filtered = global.fields ? study : filterStudy(study, opts.expand);
|
|
3475
3500
|
if (global.fields) {
|
|
3476
3501
|
const requested = global.fields.split(",").map((f) => f.trim());
|
|
@@ -3492,7 +3517,7 @@ function registerStudiesCommands(program2) {
|
|
|
3492
3517
|
const global = getGlobalOpts8(studies);
|
|
3493
3518
|
const client = createServiceClient("solar", global);
|
|
3494
3519
|
const res = await client.get(`/solar-study/findById/${studyId}`);
|
|
3495
|
-
const study = res.data;
|
|
3520
|
+
const study = assertFound(res.data, "Solar study", studyId);
|
|
3496
3521
|
let curveData;
|
|
3497
3522
|
switch (curveName) {
|
|
3498
3523
|
case "consumption":
|
|
@@ -4323,7 +4348,7 @@ function registerGeocodeCommands(program2) {
|
|
|
4323
4348
|
}
|
|
4324
4349
|
|
|
4325
4350
|
// src/index.ts
|
|
4326
|
-
var CLI_VERSION = true ? "0.8.
|
|
4351
|
+
var CLI_VERSION = true ? "0.8.2" : "0.0.0-dev";
|
|
4327
4352
|
function createProgram() {
|
|
4328
4353
|
const program2 = new Command3();
|
|
4329
4354
|
program2.name("suntropy").description("Agent-first CLI for Suntropy solar platform. Optimized for programmatic data manipulation and progressive exploration.").version(CLI_VERSION).option("--format <format>", "Output format: json (default), human, csv", "json").option("--fields <fields>", "Comma-separated fields to include in output").option("--server <url>", "Override API server URL").option("--token <jwt>", "Override authentication token").option("--profile <name>", "Use a specific config profile").option("--verbose", "Show HTTP request/response details on stderr").option("--quiet", "Suppress non-data output").option("--save <file>", "Save output to file (also writes to stdout)");
|