@tthr/vue 0.0.62 → 0.0.64
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.
|
@@ -141,11 +141,13 @@ async function executeViaApi(config, functionName, functionType, args) {
|
|
|
141
141
|
apiPath = `${base}/api/v1/projects/${config.projectId}`;
|
|
142
142
|
}
|
|
143
143
|
// Order endpoints to try based on functionType hint
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
if (
|
|
147
|
-
|
|
148
|
-
|
|
144
|
+
// Note: action functions are executed via mutation endpoint (they have same capabilities)
|
|
145
|
+
const endpointTypes = ['mutation', 'query'];
|
|
146
|
+
// Move the hinted type to the front if valid (map 'action' to 'mutation')
|
|
147
|
+
const mappedType = functionType === 'action' ? 'mutation' : functionType;
|
|
148
|
+
if (mappedType && endpointTypes.includes(mappedType)) {
|
|
149
|
+
endpointTypes.splice(endpointTypes.indexOf(mappedType), 1);
|
|
150
|
+
endpointTypes.unshift(mappedType);
|
|
149
151
|
}
|
|
150
152
|
let lastError = null;
|
|
151
153
|
for (const type of endpointTypes) {
|
|
@@ -160,8 +162,15 @@ async function executeViaApi(config, functionName, functionType, args) {
|
|
|
160
162
|
body: JSON.stringify({ function: functionName, args }),
|
|
161
163
|
});
|
|
162
164
|
if (!response.ok) {
|
|
163
|
-
const
|
|
164
|
-
|
|
165
|
+
const responseText = await response.text();
|
|
166
|
+
let errorMsg;
|
|
167
|
+
try {
|
|
168
|
+
const error = JSON.parse(responseText);
|
|
169
|
+
errorMsg = error.error || error.message || `Function '${functionName}' failed with status ${response.status}`;
|
|
170
|
+
} catch {
|
|
171
|
+
errorMsg = responseText || `Function '${functionName}' failed with status ${response.status}`;
|
|
172
|
+
}
|
|
173
|
+
log.debug(`/${type} endpoint returned ${response.status}: ${errorMsg}`);
|
|
165
174
|
// If it's a type mismatch error, try the next endpoint
|
|
166
175
|
if (errorMsg.includes('not a') && errorMsg.includes("it's a")) {
|
|
167
176
|
log.debug(`Function type mismatch on /${type}, trying next endpoint...`);
|