@gxp-dev/tools 2.0.27 → 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.
@@ -82,8 +82,9 @@ function groupPathsByTag(openApiSpec) {
82
82
  };
83
83
  }
84
84
 
85
- // Extract permission from x-permission.permission (singular)
85
+ // Extract permission and permission_key from x-permission
86
86
  const permission = pathInfo["x-permission"]?.permission;
87
+ const permissionKey = pathInfo["x-permission"]?.permission_key;
87
88
 
88
89
  tagGroups[tag].paths.push({
89
90
  path: pathUrl,
@@ -91,6 +92,7 @@ function groupPathsByTag(openApiSpec) {
91
92
  operationId: pathInfo.operationId || "",
92
93
  summary: pathInfo.summary || "",
93
94
  permission: permission || null,
95
+ permissionKey: permissionKey || null,
94
96
  });
95
97
  }
96
98
  }
@@ -683,10 +685,26 @@ async function addDependencyCommand(argv) {
683
685
 
684
686
  // Collect all permissions from selected paths
685
687
  const allPermissions = new Set();
688
+ let permissionKey = null;
686
689
  for (const pathInfo of selectedPaths) {
687
690
  if (pathInfo.permission) {
688
691
  allPermissions.add(pathInfo.permission);
689
692
  }
693
+ // Get permission_key from first path that has it (should be same for all)
694
+ if (!permissionKey && pathInfo.permissionKey) {
695
+ permissionKey = pathInfo.permissionKey;
696
+ }
697
+ }
698
+
699
+ // Build operations object from selected paths
700
+ const operations = {};
701
+ for (const pathInfo of selectedPaths) {
702
+ if (pathInfo.operationId) {
703
+ // Remove "portal.v1.project." prefix from operationId
704
+ const cleanOperationId = pathInfo.operationId.replace(/^portal\.v1\.project\./, "");
705
+ // Prepend method to path (e.g., "get:/v1/projects/...")
706
+ operations[cleanOperationId] = `${pathInfo.method.toLowerCase()}:${pathInfo.path}`;
707
+ }
690
708
  }
691
709
 
692
710
  // Build events object
@@ -699,7 +717,9 @@ async function addDependencyCommand(argv) {
699
717
  const dependency = {
700
718
  identifier,
701
719
  model: selectedTag.name,
720
+ permissionKey: permissionKey,
702
721
  permissions: Array.from(allPermissions).sort(),
722
+ operations,
703
723
  events,
704
724
  };
705
725
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gxp-dev/tools",
3
- "version": "2.0.27",
3
+ "version": "2.0.29",
4
4
  "description": "Dev tools to create platform plugins",
5
5
  "type": "commonjs",
6
6
  "publishConfig": {
@@ -129,6 +129,8 @@ export const useGxpStore = defineStore("gxp-portal-app", () => {
129
129
  const portalAssets = ref({ ...defaultData.portalAssets });
130
130
  const portal = ref(defaultData.portal);
131
131
 
132
+ const apiOperations = ref({});
133
+
132
134
  // Loading state for manifest
133
135
  const manifestLoaded = ref(false);
134
136
  const manifestError = ref(null);
@@ -297,6 +299,48 @@ export const useGxpStore = defineStore("gxp-portal-app", () => {
297
299
  // Initialize dependency-based sockets based on the new structure
298
300
  if (Array.isArray(dependencies.value)) {
299
301
  dependencies.value.forEach((dependency) => {
302
+ if (
303
+ dependency.operations &&
304
+ Object.keys(dependency.operations).length > 0
305
+ ) {
306
+ Object.keys(dependency.operations).forEach((operation) => {
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
+ };
341
+ }
342
+ });
343
+ }
300
344
  if (dependency.events && Object.keys(dependency.events).length > 0) {
301
345
  // Create socket listeners for each event type
302
346
  sockets[dependency.identifier] = {};
@@ -375,9 +419,16 @@ export const useGxpStore = defineStore("gxp-portal-app", () => {
375
419
  throw new Error(`DELETE ${endpoint}: ${error.message}`);
376
420
  }
377
421
  }
378
- async function callApi(endpoint, method, data = {}) {
422
+ async function callApi(operation, identifier, data = {}) {
379
423
  try {
380
- const response = await apiClient[method](endpoint, data);
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
+ );
381
432
  return response.data;
382
433
  } catch (error) {
383
434
  throw new Error(`${method} ${endpoint}: ${error.message}`);