@enerlence/suntropy-cli 0.11.1 → 0.11.3
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 +25 -4
- package/dist/bin/suntropy.js.map +1 -1
- package/package.json +1 -1
package/dist/bin/suntropy.js
CHANGED
|
@@ -92,9 +92,9 @@ function resolveAuth(opts) {
|
|
|
92
92
|
const config = loadConfig();
|
|
93
93
|
const profile = getActiveProfile(config, opts.profile);
|
|
94
94
|
const server = opts.server || profile.server;
|
|
95
|
-
const token = opts.token || profile.token;
|
|
95
|
+
const token = opts.token || process.env.SUNTROPY_API_KEY || profile.token;
|
|
96
96
|
if (!token) {
|
|
97
|
-
throw new Error("Not authenticated. Run: suntropy auth set-key --key <jwt> or suntropy auth login");
|
|
97
|
+
throw new Error("Not authenticated. Run: suntropy auth set-key --key <jwt> or suntropy auth login, or set the SUNTROPY_API_KEY env var.");
|
|
98
98
|
}
|
|
99
99
|
return { server, token };
|
|
100
100
|
}
|
|
@@ -2175,6 +2175,21 @@ function resolveSurfaceCoordinates(surface, study) {
|
|
|
2175
2175
|
}
|
|
2176
2176
|
return null;
|
|
2177
2177
|
}
|
|
2178
|
+
function resolveSurfaceInstalledPower(surface, study) {
|
|
2179
|
+
const explicit = surface.installedPower;
|
|
2180
|
+
if (Number.isFinite(explicit) && explicit > 0) {
|
|
2181
|
+
return { installedPower: explicit, isDefault: false };
|
|
2182
|
+
}
|
|
2183
|
+
const solarPanel = study.solarPanel;
|
|
2184
|
+
const kitPanel = study.solarKit?.kitSolarPanel;
|
|
2185
|
+
const panelPeakPower = solarPanel?.peakPower || kitPanel?.peakPower || void 0;
|
|
2186
|
+
const layout = surface.panelsLayoutPolygons;
|
|
2187
|
+
const panelCount = layout !== void 0 ? layout.length || 0 : surface.panelNumber;
|
|
2188
|
+
if (panelPeakPower && Number.isFinite(panelCount) && panelCount > 0) {
|
|
2189
|
+
return { installedPower: panelCount * panelPeakPower, isDefault: false };
|
|
2190
|
+
}
|
|
2191
|
+
return { installedPower: 5e3, isDefault: true };
|
|
2192
|
+
}
|
|
2178
2193
|
function registerStudyBuilderCommands(studies) {
|
|
2179
2194
|
studies.command("init").description(
|
|
2180
2195
|
'Create a new study workspace (local JSON file with defaults).\nExample: suntropy studies init --file /tmp/study.json --name "Residencial 5kW"'
|
|
@@ -2726,10 +2741,16 @@ Example: suntropy studies set data --file study.json --data '{"referenceId":"REF
|
|
|
2726
2741
|
continue;
|
|
2727
2742
|
}
|
|
2728
2743
|
const { lat, lng } = coords;
|
|
2744
|
+
const { installedPower, isDefault } = resolveSurfaceInstalledPower(surface, study);
|
|
2745
|
+
if (isDefault) {
|
|
2746
|
+
outputError(new Error(
|
|
2747
|
+
`Surface ${idx} has no resolvable installed power (no installedPower, and no panel layout / panelNumber with a solarPanel/solarKit peak power). Using the 5000W default \u2014 production will be wrong. Set the panels and kit/panel before calculating.`
|
|
2748
|
+
));
|
|
2749
|
+
}
|
|
2729
2750
|
const body = {
|
|
2730
2751
|
lat,
|
|
2731
2752
|
long: lng,
|
|
2732
|
-
instaledPower:
|
|
2753
|
+
instaledPower: installedPower,
|
|
2733
2754
|
angle: surface.inclination || surface.angle || 30,
|
|
2734
2755
|
azimuth: surface.orientation || surface.azimuth || 180,
|
|
2735
2756
|
lossesPercentage: parseFloat(opts.losses),
|
|
@@ -4577,7 +4598,7 @@ function registerCommandProfileCommand(program2) {
|
|
|
4577
4598
|
}
|
|
4578
4599
|
|
|
4579
4600
|
// src/index.ts
|
|
4580
|
-
var CLI_VERSION = true ? "0.11.
|
|
4601
|
+
var CLI_VERSION = true ? "0.11.3" : "0.0.0-dev";
|
|
4581
4602
|
function createProgram() {
|
|
4582
4603
|
const program2 = new Command3();
|
|
4583
4604
|
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)");
|