@forge/cli

14.1.0-next.21-experimental-554d41714.1.0-next.19-experimental-fd0ebbc
out/custom-scopes/repository.js
~out/custom-scopes/repository.jsModified
+11−7
Index: package/out/custom-scopes/repository.js
===================================================================
--- package/out/custom-scopes/repository.js
+++ package/out/custom-scopes/repository.js
@@ -1,7 +1,8 @@
 "use strict";
 Object.defineProperty(exports, "__esModule", { value: true });
 exports.create = exports.SCOPE_FETCH_BATCH_SIZE_MAX = void 0;
+const cli_shared_1 = require("@forge/cli-shared");
 exports.SCOPE_FETCH_BATCH_SIZE_MAX = 64;
 const create = (graphqlClient) => {
     return new DefaultRepository(graphqlClient);
 };
@@ -21,21 +22,23 @@
         do {
             const remainingLimit = limit ? limit - scopes.length : undefined;
             const result = await this.fetchPage(appId, environmentId, cursor, remainingLimit);
             requestId = result.requestId;
-            if (!result.appCustomScopes?.nodes || !result.appCustomScopes?.pageInfo) {
+            const connection = result.appCustomScopes;
+            if (!connection?.nodes || !connection.pageInfo) {
                 return { status: "InvalidResponseError", requestId };
             }
-            const { nodes, pageInfo: { hasNextPage, endCursor } } = result.appCustomScopes;
+            const nodes = connection.nodes ?? [];
+            const { hasNextPage, endCursor } = connection.pageInfo ?? {};
             const validNodes = nodes.filter((node) => node !== null);
             scopes.push(...(limit ? validNodes.slice(0, limit - scopes.length) : validNodes));
             cursor = hasNextPage && endCursor ? endCursor : undefined;
         } while (cursor && (!limit || scopes.length < limit));
         return { status: "Ok", requestId, scopes };
     }
     fetchPage(appId, environmentId, cursor, maxItems) {
         const pageSize = Math.min(exports.SCOPE_FETCH_BATCH_SIZE_MAX, maxItems ?? exports.SCOPE_FETCH_BATCH_SIZE_MAX);
-        const QUERY = `
+        const QUERY = (0, cli_shared_1.graphql)(`
       query forge_cli_getAppCustomScopes($appId: ID!, $environmentId: ID!, $first: Int, $after: String) {
         appCustomScopes(appId: $appId, environmentId: $environmentId, first: $first, after: $after)
           @optIn(to: ["custom-scopes-eap"]) {
           nodes {
@@ -47,18 +50,18 @@
             endCursor
           }
         }
       }
-    `;
+    `);
         return this.graphqlClient.query(QUERY, {
             appId,
             environmentId,
             first: pageSize,
             after: cursor
         });
     }
     async store(input) {
-        const MUTATION = `
+        const MUTATION = (0, cli_shared_1.graphql)(`
       mutation forge_cli_createAppCustomScopes($input: CreateAppCustomScopesInput!) {
         createAppCustomScopes(input: $input) @optIn(to: ["custom-scopes-eap"]) {
           success
           errors {
@@ -69,12 +72,13 @@
             }
           }
         }
       }
-    `;
-        const { response: { createAppCustomScopes: { success, errors } }, requestId } = await this.graphqlClient.mutate(MUTATION, {
+    `);
+        const { response, requestId } = await this.graphqlClient.mutate(MUTATION, {
             input
         });
+        const { success, errors } = (0, cli_shared_1.requireMutationPayload)(response.createAppCustomScopes, requestId);
         if (success) {
             return { status: "Ok", requestId };
         }
         const mappedErrors = (errors || []).map(({ message, extensions }) => ({