@forge/cli-shared

8.15.3-next.08.15.3-next.1
out/graphql/minimal-graphql-runner.js
~out/graphql/minimal-graphql-runner.jsModified
+11−1
Index: package/out/graphql/minimal-graphql-runner.js
===================================================================
--- package/out/graphql/minimal-graphql-runner.js
+++ package/out/graphql/minimal-graphql-runner.js
@@ -1,7 +1,7 @@
 "use strict";
 Object.defineProperty(exports, "__esModule", { value: true });
-exports.MinimalGraphQLRunner = exports.GraphqlError = exports.GraphQLProviderServiceError = exports.OutdatedClientVersionError = exports.GraphQLAuthenticationError = exports.BUSINESS_UNITS = exports.NON_PROD_BUSINESS_UNIT = exports.PROD_BUSINESS_UNIT = exports.SERVICE_NAME = void 0;
+exports.MinimalGraphQLRunner = exports.GraphqlError = exports.GraphQLProviderServiceError = exports.InsufficientScopesError = exports.OutdatedClientVersionError = exports.GraphQLAuthenticationError = exports.BUSINESS_UNITS = exports.NON_PROD_BUSINESS_UNIT = exports.PROD_BUSINESS_UNIT = exports.SERVICE_NAME = void 0;
 const graphql_request_1 = require("graphql-request");
 const index_1 = require("../index");
 const shared_1 = require("../shared");
 const ui_1 = require("../ui");
@@ -18,14 +18,21 @@
 class GraphQLAuthenticationError extends shared_1.UserError {
 }
 exports.GraphQLAuthenticationError = GraphQLAuthenticationError;
 const isOutdatedClientVersionError = (error) => error.message?.includes('client version is outdated');
+const isInsufficientScopesError = (error) => error.message?.includes('This request does not contain the right authorisation scopes');
 class OutdatedClientVersionError extends shared_1.UserError {
     constructor() {
         super(ui_1.Text.graphQL.outdatedClientVersion);
     }
 }
 exports.OutdatedClientVersionError = OutdatedClientVersionError;
+class InsufficientScopesError extends shared_1.UserError {
+    constructor() {
+        super(ui_1.Text.graphQL.insufficientScopes);
+    }
+}
+exports.InsufficientScopesError = InsufficientScopesError;
 class GraphQLProviderServiceError extends shared_1.BaseError {
     userError;
     code;
     statusCode;
@@ -120,8 +127,11 @@
                 if (errors) {
                     if (errors.find((e) => isOutdatedClientVersionError(e))) {
                         throw new OutdatedClientVersionError();
                     }
+                    if (errors.find((e) => isInsufficientScopesError(e))) {
+                        throw new InsufficientScopesError();
+                    }
                     const { statusCode } = (0, index_1.getError)(errors);
                     const isUserError = statusCode && statusCode >= 400 && statusCode < 500 ? true : false;
                     throw new GraphQLProviderServiceError(isUserError, requestId, errors);
                 }