npm package diff
Package: @forge/manifest
Versions: 11.0.0-next.0 - 11.0.0-next.1
File: package/out/validators/product-trigger-scopes-validator.js
Index: package/out/validators/product-trigger-scopes-validator.js
===================================================================
--- package/out/validators/product-trigger-scopes-validator.js
+++ package/out/validators/product-trigger-scopes-validator.js
@@ -1,10 +1,17 @@
 "use strict";
 Object.defineProperty(exports, "__esModule", { value: true });
-exports.ProductTriggerScopesValidator = void 0;
+exports.ProductTriggerScopesValidator = exports.validateEventScopes = void 0;
 const text_1 = require("../text");
 const utils_1 = require("../utils");
 const scopes_1 = require("../scopes");
+async function validateEventScopes(event, scopes, config) {
+    const emptyRequiredScopes = { current: [] };
+    const requiredScopes = config.mapping.find((entry) => entry.productEvent === event)?.oAuthScopes || emptyRequiredScopes;
+    const missingScopes = await (0, scopes_1.getMissingScopes)(scopes, requiredScopes);
+    return { requiredScopes, missingScopes };
+}
+exports.validateEventScopes = validateEventScopes;
 class ProductTriggerScopesValidator {
     config;
     constructor(config) {
         this.config = config;
@@ -16,12 +23,8 @@
                 manifestObject: manifest
             };
         }
         const validationErrors = [];
-        const getRequiredScopes = (productEvent) => {
-            const emptyRequiredScopes = { current: [] };
-            return (this.config.mapping.find((value) => value.productEvent == productEvent)?.oAuthScopes || emptyRequiredScopes);
-        };
         const addValidationError = (scope, event) => {
             validationErrors.push({
                 message: text_1.errors.permissions.missingPermissionFromScope(scope, event),
                 reference: text_1.References.MissingScopes,
@@ -40,10 +43,9 @@
         }
         const manifestScopes = manifest.typedContent.permissions?.scopes || [];
         for (const element of manifest.typedContent.modules.trigger) {
             for (const event of element.events) {
-                const requiredScopes = getRequiredScopes(event);
-                const missingScopes = await (0, scopes_1.getMissingScopes)(manifestScopes, requiredScopes);
+                const { missingScopes } = await validateEventScopes(event, manifestScopes, this.config);
                 missingScopes.forEach((scope) => addValidationError(scope, event));
             }
         }
         return {