@gxp-dev/tools 2.0.28 → 2.0.29
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
|
@@ -304,17 +304,41 @@ export const useGxpStore = defineStore("gxp-portal-app", () => {
|
|
|
304
304
|
Object.keys(dependency.operations).length > 0
|
|
305
305
|
) {
|
|
306
306
|
Object.keys(dependency.operations).forEach((operation) => {
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
307
|
+
if (
|
|
308
|
+
Object.keys(apiOperations.value[dependency.identifier]).every(
|
|
309
|
+
(key) =>
|
|
310
|
+
[
|
|
311
|
+
"identifier",
|
|
312
|
+
"model",
|
|
313
|
+
"permissionKey",
|
|
314
|
+
"operations",
|
|
315
|
+
].includes(key)
|
|
316
|
+
)
|
|
317
|
+
) {
|
|
318
|
+
let method = "get";
|
|
319
|
+
let path = dependency.operations[operation];
|
|
320
|
+
if (path.includes(":")) {
|
|
321
|
+
let pathSplit = path.split(":");
|
|
322
|
+
method = pathSplit[0];
|
|
323
|
+
path = pathSplit[1];
|
|
324
|
+
}
|
|
325
|
+
path = path.replace(
|
|
326
|
+
"{teamSlug}/{projectSlug}",
|
|
327
|
+
pluginVars.value.projectId
|
|
328
|
+
);
|
|
329
|
+
path = path.replace(
|
|
330
|
+
`{${dependency.permissionKey}}`,
|
|
331
|
+
dependencyList.value[dependency.identifier]
|
|
332
|
+
);
|
|
333
|
+
if (!apiOperations.value[dependency.identifier]) {
|
|
334
|
+
apiOperations.value[dependency.identifier] = {};
|
|
335
|
+
}
|
|
336
|
+
apiOperations.value[dependency.identifier][operation] = {
|
|
337
|
+
method: method,
|
|
338
|
+
path: path,
|
|
339
|
+
model_key: dependency.permissionKey,
|
|
340
|
+
};
|
|
313
341
|
}
|
|
314
|
-
apiOperations.value[operation] = {
|
|
315
|
-
method: method,
|
|
316
|
-
path: path,
|
|
317
|
-
};
|
|
318
342
|
});
|
|
319
343
|
}
|
|
320
344
|
if (dependency.events && Object.keys(dependency.events).length > 0) {
|
|
@@ -397,8 +421,14 @@ export const useGxpStore = defineStore("gxp-portal-app", () => {
|
|
|
397
421
|
}
|
|
398
422
|
async function callApi(operation, identifier, data = {}) {
|
|
399
423
|
try {
|
|
400
|
-
const
|
|
401
|
-
|
|
424
|
+
const operationConfig = apiOperations.value[identifier][operation];
|
|
425
|
+
if (!operationConfig) {
|
|
426
|
+
throw new Error(`Operation not found: ${operation}`);
|
|
427
|
+
}
|
|
428
|
+
const response = await apiClient[operationConfig.method](
|
|
429
|
+
operationConfig.path,
|
|
430
|
+
data
|
|
431
|
+
);
|
|
402
432
|
return response.data;
|
|
403
433
|
} catch (error) {
|
|
404
434
|
throw new Error(`${method} ${endpoint}: ${error.message}`);
|