@statezero/core 0.1.2 → 0.1.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/dist/cli/commands/syncModels.js +19 -20
- package/package.json +1 -1
|
@@ -97,32 +97,27 @@ import { loadConfigFromFile } from "../configFileLoader.js";
|
|
|
97
97
|
// Fallback Selection for Inquirer Errors
|
|
98
98
|
// --------------------
|
|
99
99
|
/**
|
|
100
|
-
* Simple fallback
|
|
100
|
+
* Simple fallback that generates all models when inquirer fails
|
|
101
101
|
* @param {Array} choices - Array of choice objects with {name, value, checked} properties
|
|
102
102
|
* @param {string} message - Selection message
|
|
103
|
-
* @returns {Promise<Array>} -
|
|
103
|
+
* @returns {Promise<Array>} - All model values
|
|
104
104
|
*/
|
|
105
|
-
async function
|
|
105
|
+
async function fallbackSelectAll(choices, message) {
|
|
106
106
|
console.log(`\n${message}`);
|
|
107
|
-
console.log("Interactive selection not available -
|
|
108
|
-
const
|
|
107
|
+
console.log("Interactive selection not available - generating ALL models:");
|
|
108
|
+
const allModels = [];
|
|
109
109
|
for (const choice of choices) {
|
|
110
110
|
// Skip separators (they don't have a 'value' property)
|
|
111
111
|
if (!choice.value) {
|
|
112
112
|
console.log(choice.name); // Print separator text
|
|
113
113
|
continue;
|
|
114
114
|
}
|
|
115
|
-
//
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
console.log(` ✓ ${choice.name}`);
|
|
119
|
-
}
|
|
120
|
-
else {
|
|
121
|
-
console.log(` ${choice.name}`);
|
|
122
|
-
}
|
|
115
|
+
// Add ALL models, regardless of checked status
|
|
116
|
+
allModels.push(choice.value);
|
|
117
|
+
console.log(` ✓ ${choice.name}`);
|
|
123
118
|
}
|
|
124
|
-
console.log(`\
|
|
125
|
-
return
|
|
119
|
+
console.log(`\nGenerating ALL ${allModels.length} models.`);
|
|
120
|
+
return allModels;
|
|
126
121
|
}
|
|
127
122
|
/**
|
|
128
123
|
* Model selection with inquirer fallback
|
|
@@ -146,9 +141,9 @@ async function selectModels(choices, message) {
|
|
|
146
141
|
return selectedModels;
|
|
147
142
|
}
|
|
148
143
|
catch (error) {
|
|
149
|
-
// Fall back to
|
|
150
|
-
console.warn("Interactive selection failed,
|
|
151
|
-
return await
|
|
144
|
+
// Fall back to generating all models if inquirer fails for any reason
|
|
145
|
+
console.warn("Interactive selection failed, generating all models:", error.message);
|
|
146
|
+
return await fallbackSelectAll(choices, message);
|
|
152
147
|
}
|
|
153
148
|
}
|
|
154
149
|
// --------------------
|
|
@@ -516,8 +511,9 @@ const dtsTemplate = Handlebars.compile(TS_DECLARATION_TEMPLATE);
|
|
|
516
511
|
* @returns {Promise<{model: string, relativePath: string}>}
|
|
517
512
|
*/
|
|
518
513
|
async function generateSchemaForModel(backend, model) {
|
|
514
|
+
const authHeaders = backend.getAuthHeaders ? backend.getAuthHeaders() : {};
|
|
519
515
|
const schemaUrl = `${backend.API_URL}/${model}/get-schema/`;
|
|
520
|
-
const schemaResponse = await axios.get(schemaUrl);
|
|
516
|
+
const schemaResponse = await axios.get(schemaUrl, authHeaders);
|
|
521
517
|
/** @type {SchemaDefinition} */
|
|
522
518
|
let schema;
|
|
523
519
|
if (schemaResponse.data.components?.schemas?.[model]) {
|
|
@@ -1012,7 +1008,10 @@ async function main() {
|
|
|
1012
1008
|
const backend = backendConfigs[key];
|
|
1013
1009
|
backend.NAME = key;
|
|
1014
1010
|
try {
|
|
1015
|
-
const
|
|
1011
|
+
const authHeaders = backend.getAuthHeaders
|
|
1012
|
+
? backend.getAuthHeaders()
|
|
1013
|
+
: {};
|
|
1014
|
+
const response = await axios.get(`${backend.API_URL}/models/`, authHeaders);
|
|
1016
1015
|
return { backend, models: response.data };
|
|
1017
1016
|
}
|
|
1018
1017
|
catch (error) {
|
package/package.json
CHANGED