npm package diff

Package: @forge/cli

Versions: 12.8.0-next.18-experimental-003d118 - 12.8.0-next.24

File: package/out/custom-scopes/repository.js

Index: package/out/custom-scopes/repository.js
===================================================================
--- package/out/custom-scopes/repository.js
+++ package/out/custom-scopes/repository.js
@@ -0,0 +1,99 @@
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.create = exports.SCOPE_FETCH_BATCH_SIZE_MAX = void 0;
+exports.SCOPE_FETCH_BATCH_SIZE_MAX = 64;
+const create = (graphqlClient) => {
+    return new DefaultRepository(graphqlClient);
+};
+exports.create = create;
+class DefaultRepository {
+    graphqlClient;
+    constructor(graphqlClient) {
+        this.graphqlClient = graphqlClient;
+    }
+    async load(appId, environmentId, limit) {
+        const QUERY = `
+      query getAppCustomScopes(
+        $appId: ID!
+        $environmentId: ID!
+        $first: Int
+        $after: String
+      ) {
+        appCustomScopes(
+          appId: $appId
+          environmentId: $environmentId
+          first: $first
+          after: $after
+        ) {
+          nodes {
+            name
+            displayName
+          }
+          pageInfo {
+            hasNextPage
+            endCursor
+          }
+        }
+      }
+    `;
+        let hasNextPage = true;
+        let cursor = undefined;
+        const scopes = [];
+        let requestId;
+        while (hasNextPage && (!limit || scopes.length < limit)) {
+            const remainingLimit = limit ? limit - scopes.length : exports.SCOPE_FETCH_BATCH_SIZE_MAX;
+            const numScopesToFetch = Math.min(exports.SCOPE_FETCH_BATCH_SIZE_MAX, remainingLimit);
+            const result = await this.graphqlClient.query(QUERY, {
+                appId,
+                environmentId,
+                first: numScopesToFetch,
+                after: cursor
+            });
+            requestId = result.requestId;
+            if (!result.appCustomScopes?.nodes || !result.appCustomScopes?.pageInfo) {
+                return { status: "InvalidResponseError", requestId };
+            }
+            const { nodes, pageInfo } = result.appCustomScopes;
+            for (const node of nodes) {
+                if (node) {
+                    scopes.push(node);
+                    if (limit && scopes.length >= limit) {
+                        break;
+                    }
+                }
+            }
+            hasNextPage = pageInfo.hasNextPage;
+            cursor = pageInfo.endCursor || undefined;
+        }
+        return { status: "Ok", requestId, scopes };
+    }
+    async store(input) {
+        const MUTATION = `
+      mutation forge_cli_createAppCustomScopes($input: CreateAppCustomScopesInput!) {
+        createAppCustomScopes(input: $input) {
+          success
+          errors {
+            message
+            extensions {
+              errorType
+              statusCode
+            }
+          }
+        }
+      }
+    `;
+        const { response: { createAppCustomScopes: { success, errors } }, requestId } = await this.graphqlClient.mutate(MUTATION, {
+            input
+        });
+        if (success) {
+            return { status: "Ok", requestId };
+        }
+        const mappedErrors = (errors || []).map(({ message, extensions }) => {
+            const code = extensions?.statusCode || 'unknown-status';
+            const type = extensions?.errorType || 'unknown-type';
+            return `${code}/${type}: ${message || 'unknown error'}`;
+        });
+        return { status: "RemoteError", requestId, errors: mappedErrors };
+    }
+}
+//# sourceMappingURL=repository.js.map
\ No newline at end of file