@forge/manifest

12.1.0-next.2-experimental-d99730712.1.0-next.3-experimental-44a932f
out/validators/twg-preview-scopes-validator.js
out/validators/twg-preview-scopes-validator.js
+32
Index: package/out/validators/twg-preview-scopes-validator.js
===================================================================
--- package/out/validators/twg-preview-scopes-validator.js
+++ package/out/validators/twg-preview-scopes-validator.js
@@ -0,0 +1,32 @@
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.TwgPreviewScopesValidator = void 0;
+const text_1 = require("../text");
+const utils_1 = require("../utils");
+const scopes_1 = require("../utils/scopes");
+const TWG_PREVIEW_SCOPES = ['read:graph:jira', 'read:graph:confluence'];
+class TwgPreviewScopesValidator {
+    async validate(manifest) {
+        if (!manifest?.typedContent?.permissions?.scopes) {
+            return { success: true, manifestObject: manifest };
+        }
+        const manifestScopes = (0, scopes_1.getAllScopeKeys)(manifest.typedContent.permissions.scopes);
+        const foundTwgScopes = manifestScopes.filter((scope) => TWG_PREVIEW_SCOPES.includes(scope));
+        if (foundTwgScopes.length > 0) {
+            return {
+                success: true,
+                manifestObject: manifest,
+                errors: [
+                    {
+                        message: text_1.errors.twgPreviewScopes(foundTwgScopes),
+                        reference: text_1.References.Deprecated,
+                        level: 'warning',
+                        ...(0, utils_1.findPosition)('scopes', manifest?.yamlContentByLine)
+                    }
+                ]
+            };
+        }
+        return { success: true, manifestObject: manifest };
+    }
+}
+exports.TwgPreviewScopesValidator = TwgPreviewScopesValidator;